首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将PRPS POSID转换为SAP格式的WBS元素

将PRPS POSID转换为SAP格式的WBS元素
EN

Stack Overflow用户
提问于 2019-04-08 16:46:40
回答 3查看 3.2K关注 0票数 0

我正在寻找一种方法来转换从PRPS表的WBS列到一个格式化的WBS元素,如SAP向我们展示没有POSID函数。

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

有人知道如何使用TCJED表中的口罩吗?

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

我想用Java或SQL来做这件事。

编辑1年&1个月后:)

我找到了解决方案,下面是PL/SQL代码:

掩码来自tcjed表。要转换的元素是原始WBS或原始项目。

代码语言:javascript
复制
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);
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-01-22 00:19:02

我找到了解决方案,下面是PL/SQL代码:

掩码来自tcjed表。要转换的元素是原始WBS或原始项目。

代码语言:javascript
复制
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);
票数 0
EN

Stack Overflow用户

发布于 2019-04-08 18:44:42

你可以给FM CONVERSION_EXIT_ABPSP_INPUT打电话。此FM将POSID的内部格式转换为Dynpros中看到的外部格式。

票数 0
EN

Stack Overflow用户

发布于 2020-05-12 19:56:09

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

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

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

在同一个包中,我们可以找到BADIs、WORKBREAKDOWN_UPDATE和PROJECTDEF_UPDATE,其中可以应用与REPS_PSEXT_ID_CONV类似的逻辑,并在表PSEXT_ID_CONV中的提交时执行upsert。

要实现BADI,还可以看看OSS 2915621 - BADi WORKBREAKDOWN_UPDATE AT_SAVE not called。

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

希望这能有所帮助,

干杯,

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55569449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档