我正在寻找一种将表中的POSID
列PRPS
转换为格式化的 WBS 元素的方法,例如 SAP 向我们展示没有 SAP 函数的情况。
我找到了TCJED
获取掩码的表格,我看到了一个 ABAP 函数来进行转换,但我对 ABAP 不满意。
有人知道如何使用 TCJED 表中的掩码吗?
有时0
在 POSID 的末尾有一些,但它们不会出现在格式化的 WBS 元素上。
我想在 Java 或 SQL 中执行此操作。
[编辑 1 年 1 个月后 :) ]
我找到了解决方案,这里是 PL/SQL 代码:
掩码来自 tcjed 表。elementtoconvert 是原始 WBS 或原始 Proj。
if (trim(mask) = '' or mask is null or trim(elementtoconvert) ='' or elementtoconvert is null) then
return elementToConvert;
end if;
select substring(elementToConvert, 1, currentPos) into wbs_Element_formated;
select currentPos + 1 into currentPos;
select string_to_array(substring(mask, 2, length(mask)-1),'-') into parts;
for i in 1 .. array_upper(parts,1) loop
select parts[i] like 'X%' into isXGroup;
if (currentPos > length(elementToConvert)) then
exit;
end if;
select currentPos + length(parts[i]) into endIndex;
if (endIndex > length(elementToConvert)) then
select regexp_replace(substring(elementToConvert, currentPos), E'\\s+', '') into groupValue;
else
select regexp_replace(substring(elementToConvert, currentPos, length(parts[i])), E'\\s+', '') into groupValue;
end if;
if (isXGroup and length(parts[i]) > length(groupValue)) then
select groupValue || Repeat(' ', length(parts[i]) - length(groupValue)) into groupValue;
end if;
select currentPos + length(parts[i]) into currentPos;
if isXGroup = false then
if trim(groupValue) = '' then
continue;
end if;
if (groupValue ~* ('0{' || length(parts[i]) ||'}')) then
if(parts[array_upper(parts,1) -1] = parts[i]) then
exit;
end if;
select trim(substring(elementToConvert, currentPos)) into nextChars;
if(nextChars = '' or nextChars ~* ('0{' || length(parts[i]) ||'}')) then
exit;
end if;
end if;
end if;
select wbs_Element_formated || '-' || groupValue into wbs_Element_formated;
end loop;
loop
Exit when regexp_replace(wbs_Element_formated, E'\\s+$', '') not like '%-';
select substring(wbs_Element_formated,1, length(wbs_Element_formated)-1) into wbs_Element_formated;
end loop;
return trim(trailing ' ' from wbs_Element_formated);
我找到了解决方案,这里是 PL/SQL 代码:
掩码来自 tcjed 表。elementtoconvert 是原始 WBS 或原始 Proj。
if (trim(mask) = '' or mask is null or trim(elementtoconvert) ='' or elementtoconvert is null) then
return elementToConvert;
end if;
select substring(elementToConvert, 1, currentPos) into wbs_Element_formated;
select currentPos + 1 into currentPos;
select string_to_array(substring(mask, 2, length(mask)-1),'-') into parts;
for i in 1 .. array_upper(parts,1) loop
select parts[i] like 'X%' into isXGroup;
if (currentPos > length(elementToConvert)) then
exit;
end if;
select currentPos + length(parts[i]) into endIndex;
if (endIndex > length(elementToConvert)) then
select regexp_replace(substring(elementToConvert, currentPos), E'\\s+', '') into groupValue;
else
select regexp_replace(substring(elementToConvert, currentPos, length(parts[i])), E'\\s+', '') into groupValue;
end if;
if (isXGroup and length(parts[i]) > length(groupValue)) then
select groupValue || Repeat(' ', length(parts[i]) - length(groupValue)) into groupValue;
end if;
select currentPos + length(parts[i]) into currentPos;
if isXGroup = false then
if trim(groupValue) = '' then
continue;
end if;
if (groupValue ~* ('0{' || length(parts[i]) ||'}')) then
if(parts[array_upper(parts,1) -1] = parts[i]) then
exit;
end if;
select trim(substring(elementToConvert, currentPos)) into nextChars;
if(nextChars = '' or nextChars ~* ('0{' || length(parts[i]) ||'}')) then
exit;
end if;
end if;
end if;
select wbs_Element_formated || '-' || groupValue into wbs_Element_formated;
end loop;
loop
Exit when regexp_replace(wbs_Element_formated, E'\\s+$', '') not like '%-';
select substring(wbs_Element_formated,1, length(wbs_Element_formated)-1) into wbs_Element_formated;
end loop;
return trim(trailing ' ' from wbs_Element_formated);