cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

sugata_bagchi2
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

ajay_sharma32
Discoverer
0 Kudos

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

0 Kudos

Thank you all for your help!.

Thanks,

Chan