cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping help on "If then else"

sherin_jose4
Participant
0 Kudos

Hi,

I am struck in a mapping logic,

If QUALF equals "013", then map the same context of IDTNR to target.

If QUALF not equals "013" and QUALF equals "001" then map the corresponding IDTNR value of  001.

001 -- Should fail

013 -- Should pass

<---Context change--->

001 -- Should pass for 001

Ideally the expected values are Should pass (013) and Should pass for 001 (001) with a context change.

The Should fail value occurs because the first context QUALF has the values 001 and 013 in the same set of records.

Need you inputs in getting the desired result without a UDF.

Accepted Solutions (1)

Accepted Solutions (1)

ambrish_mishra
Active Contributor

Hi Sherin,

Appreciate the way you explained the problem.

I think it will be overtly complicated without a UDF. Let me explain why!

Normally IDTNR with Qualf is associated with E1EDP19 segment and different values may or may not occur per IDoc. Now since you have to keep the context to E1EDP01 or above so in a context it will check for each value in sequence (01 first and then so on... it goes to else). You have 2 true conditions and which will propagate through the queue and rest will give suppress.

Since you have to populate the material id once in the target per IDoc, you cannot achieve it through just if and else or if without else.

It would be better if you write a UDF to meet your requirement.

Ambrish

sherin_jose4
Participant
0 Kudos

Can someone get me the UDF to achieve this ?

anupam_ghosh2
Active Contributor
0 Kudos

Hi Sherin,

               Need the source and target XML to write the UDF.

Regards

Anupam

ambrish_mishra
Active Contributor
0 Kudos

Hi Sherin,

Here is the UDF:

Parameters

qualf map to QUALF (should be at context E1EDP01)

idtnr map to IDTNR (should be at context E1EDP01

____________________________________________

String output = new String();

for (int i=0; i< qualf.length;i++)

if(qualf[i].equals("001"))

    output =  idtnr[i];

else if(qualf[i].equals("013"))

    output =  idtnr[i];

result.addValue(output);

____________________________________________

Please find the mapping and test case below:

Hope this resolves your problem.

Ambrish

ambrish_mishra
Active Contributor
0 Kudos

Better screenshot :

First E1EDP01 had 3 E1EDP19s with 001, 013 and 017 where should pass 13 should go

second E1EDP01 had 2 E1EDP19s with 001 and 017 where should pass001 should go

third E1EDP01 had 1 E1EDP19 with 018 where null should go since no relevant material id came through from SAP for target system.

Hope it is clear now

Ambrish

sherin_jose4
Participant
0 Kudos

Hi Ambrish,

Thanks a lot for the detailed explanation and code.

This worked perfectly fine, but failed for some test cases. However, i have added some mode node functions to tally up with the code to make it work.

Cheers,

Sherin Jose

ambrish_mishra
Active Contributor
0 Kudos

Nice way you explained your requirement!

cheers

Ambrish

Answers (0)