cancel
Showing results for 
Search instead for 
Did you mean: 

checking if source node exists in IDoc

Former Member
0 Kudos

Dear All,

I am checking if the source Idoc node exists using node function exists . I have an issue when passing the source values to the output node.

For eg in a shipment idoc SHPMNT05 . I am checking if source E1EDT43 segment exists if it does not then I need to create as many E1EDT43 segments in the target as there are E1EDL37 segments in the source. In PI my mapping is as below.

                               then E1EDT43   

E1EDT43 - exists - if                          --> target E1EDT43

                              else E1EDL37

If there are 2 E1EDT43 segments in the source it produces the corresponding 2 E1EDT43 segments in the target but if  E1EDT43 segments does not exists in the source and there are 2 E1EDL37 segments in the source it produces only 1 E1EDT43 segment in the target.

Can you please advice as to how I can produce 2 E1EDT43 segments in the target when there are 2 E1EDL37 segments in the source?

Thanks for your help.

Teresa

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Easiest solution would be to use duplicate subtree:

1. Edit the mapping

2. On your target field, right-click E1EDT43 and then select duplicate subtree

3. Use the first condition on the first E1EDT43 (ifWithoutElse)

4. Use the second condition on the second E1EDT43 (ifWithoutElse)

Hope this helps,

Mark

Former Member
0 Kudos

Thanks Mark. I will try your suggestion and hope it helps my issue.

markangelo_dihiansan
Active Contributor
0 Kudos

Please do, that is the only way to make it work without resorting to UDF

Former Member
0 Kudos

Thank you Mark. You were right on target

Former Member
0 Kudos

Hello,

What if you have more than 2 occurrences of E1EDL37 segment in idoc? then i think duplicate subtree wont help?

Thanks

Amit Srivastava

Answers (1)

Answers (1)

nabendu_sen
Active Contributor
0 Kudos

Hi Teresa,

You need to use UDF for this. Suppose when 2 values of Source are coming 2 contexts (<exists> true, true) are created, but for when no source exists only 1 false (<exists> false) is generated, thats why irresepctive of everything it will always pass 1 'E1EDL37' to Target 'E1EDT43' when Source 'E1EDT43' does not exist.

Former Member
0 Kudos

Thank you Sen . You are correct it passes only 1 E1ED737 if source not does not exist. Can you please provide a sample UDF for this mapping. I am new in the area of UDF's and try to use graphical mapping. Appreciate your help.

Former Member
0 Kudos

Dear Sen,

I created the UDF in PI . For the UDF I have two inputs var1 and var2 and one output.

In mapping as below I am confused with the ELSE condition as to how to use the two inputs of the UDF. Can you please let me know,

IF E1EDT43 exists then output of (IF..ELSE)----> target  E1EDT43

     ELSE --->    

Thank you.