从SAP转换PRPS POSID到格式化的WBS元素

时间:2019-04-08 08:46:40

标签: java sql sap

我正在寻找一种将POSID表中的PRPS列转换为格式化的WBS元素(如SAP)的方法,向我们展示了没有SAP功能。

我已经找到TCJED表来获取掩码,并且我已经看到了进行转换的ABAP函数,但是我对ABAP不满意。

有人知道如何使用TCJED表中的蒙版吗?

有时POSID的末尾有一些0,但它们未出现在格式化的WBS元素上。

我想用Java或SQL做到这一点。

3 个答案:

答案 0 :(得分:0)

您可以致电FM CONVERSION_EXIT_ABPSP_INPUT。此FM将POSID的内部格式转换为Dynpros中看到的外部格式。

答案 1 :(得分:0)

有一个程序REPS_PSEXT_ID_CONV “将项目和WBS元素的内部ID转换为外部ID”

将在SE38执行后将PRPS / PROJ外部定义存储在表PSEXT_ID_CONV的EXT_ID_CONV字段中。

此程序用于在HANA上进行企业搜索。

在同一软件包中,我们找到了BADIs WORKBREAKDOWN_UPDATE和PROJECTDEF_UPDATE,可以在表PSEXT_ID_CONV中的提交上应用与REPS_PSEXT_ID_CONV类似的逻辑,并在提交时进行向上插入。

要实现BADI,还请查看OSS 2915621-BADi WORKBREAKDOWN_UPDATE AT_SAVE未调用。

在PS配置中(tcode / nspro),我们还发现了badi可用/

enter image description here

希望获得帮助,

干杯

答案 2 :(得分:0)

我找到了解决方案,这里是 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);