Skip to Content

SAP PI/PO-Mapping UDF to differentiate parent/child at the same level

Hello Experts,

I have a requirement for which I might need a UDF.

0000000

0000010

0000020

0000030

0000000

0000000

0000010

0000020

In this example, I have 8 items 0000000 is the Top level Item.0000010, 0000020, 0000030 are supposedly childs of 0000000. Requirement, if 000000 has childs then pass true, else false, else if it is child ie 10, 20, 30 etc, then pass X. Problem: All come under the same level, there is no relation to parent and Child. So suggest me an udf.

I tried searching SDN and did not find any.

Expected Outupt for this scenario

0000000 - true

0000010 - X

0000020 - X

0000030 - X

0000000 - false

0000000 - true

0000010 - X

0000020 - X

Thanks,

Chan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 13 at 10:16 PM

    Hi Har` Chan,

    How are you getting the source data? is it in a XML? could you please share a sample source XML or the source data?

    or you can try this udf - where UDF type is all values of queue and vr is the input queue value and rs is the resultlist- hope this will help

    for (int i=0;i<vr.length;i++)
      {
          if (vr[i].equals("0000000"))
             {
                 if (i == vr.length-1)  
                   {
                   rs.addValue("false");
                     }  
                if (i != vr.length-1)  
                   {
                      if (!vr[i+1].equals("0000000"))
                           {
                             rs.addValue("true");
                           } 
                       else 
                           rs.addValue("false");
                    }
                  }
               if (!vr[i].equals("0000000"))
                         {
                              rs.addValue("X");
                          }
    
             
         }

    this will be the output and input -

    Thanks

    Sugata


    s.png (15.4 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 13 at 08:22 PM

    Hello Har chan

    Can you tell which system are you trying to connect on backend ? Where are you sending the data ? If its SAP/ABAP system, I'd do in ABAP as its easy to loop though the contents there instead in UDF in PI.

    Let me know if you need ABAP code for the same.

    Regards

    Ajay

    Add comment
    10|10000 characters needed characters exceeded