cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent mapping issue - Idoc to file

Former Member
0 Kudos

Hi,

I have the following XML from the IDOC (input message)

- <E1WPA04 SEGMENT="1">

<KONDART>ZKA2</KONDART>

.

.

- <E1WPA05 SEGMENT="1">

<KONDSATZ>5</KONDSATZ>

</E1WPA05>

</E1WPA04>

- <E1WPA04 SEGMENT="1">

<KONDART>VKP0</KONDART>

.

.

- <E1WPA05 SEGMENT="1">

<KONDWERT>19</KONDWERT>

<CURRENCY>INR</CURRENCY>

</E1WPA05>

</E1WPA04>

In the output I have only one filed called Retail Price which will be filled with E1WPA05->KONDWERT if E1WPA04->KONDART is "VKP0".

Now E1WPA04->KONDART can come multiple times (as in the xml shown above) and for each E1WPA04 there will be one E1WPA05. E1WPA05->KONDWERT is an amount (absolute value) and E1WPA05->KONDSATZ is in percentage. Depending upon E1WPA04->KONDART, we can either have abosulte value (KONDWERT) or percent (KONDSATZ) but not both.

For the about xml, the QUEUE for E1WPA04->KONDART looks like :

SUPPRESS

[ZKA2]

[ZKA2]

[VKP0]

[VKP0]

the QUEUE for E1WPA05->KONDWERT looks like:

SUPPRESS

SUPPRESS

[19]

[19]

Please help how can this mapping be done? Its really urgent.

Thanks a ton in advance,

Yash

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The problem is resolved now. I had to write advance UDFs and node functions to resolve the context issue.

Thanks all for the ehlp.

Regards,

Yash

Former Member
0 Kudos

HI,

I think this should work ....the saupress is coming means it will supress the target node and only it will pas the value 19 which there for that.."VKP0" condition and generate the target node.

You can do one thing if that is not working....

Write and UDF

Input will be a= E1WPA04->KONDART take it in one context

Input :b=KONDWERT

for(i=0;i<a.length;i++)

{

if(a{i}.equals("VKP0"))

{

result.addValue(b{i});

}

}

Thnx

Chirag

Former Member
0 Kudos

Hi Chirag,

I have used the same code and it works if there is only one E1WPA04 / E1WPA05 segment coming. When there are multiple segments it gives problem because i this there is some context problem.

The first problem it gives in the code is in line

for(i=0;i<a.length;i++)

saying "Array out of bound" which is really wierd.

Now for testing if I hardcode the value, the code doesnt give any error but the mapping doesnt happen correctly. Thats because array a (= E1WPA04->KONDART) has 2 values "ZKA2" and "VKP0" but array b (=KONDWERT) has only one value 19 corresponding to "VKP0". For "ZKA2" the field KONDWERT dont exists but KONDSATZ.

Hence a[1] is "VKP0" but b[1] is not 19. Most probably b[1] doesnt even exists. you can see that from the queue.

What can be done here?

Yash

Former Member
0 Kudos

yash,

here u can do one trick. u can force blank value for KONDWERT using exists node function and pass the same to ur UDF. Then u will have one to one value of KONDWERT to E1WPA04->KONDART.

Regards

Rajeev

Former Member
0 Kudos

HI,

Array index out of bound occurs because u have not taken all the value in one context..so I suggest try to take both the input values in one context and check the UDF.

Thnx

Chirag

Former Member
0 Kudos

Hi Chirag,

Can you please explain what does " take both the input values in one context" actually means? Do i need to use "Removecontexts" node function for a? Is this error coming out of the for loop (a.length)?

Please advice.

Yash

Former Member
0 Kudos

HI,

Before the UDF u just use the remove context and then give the output of remove context to UDF. So it will take all the value in one context.

Thnx

Chirag

Former Member
0 Kudos

Hello

u can write advance java function and take queue of E1WPA04->KONDART as well as E1WPA05->KONDWERT. Filter the values using similar java code

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

{

if(a(i).equals("VKP0");

{

ResultList.addValue(b(i)); //Use square brackets indicating array value

}

}

Change the context accordingly and i guess for each E1WPA04->KONDART there will be E1WPA05->KONDWERT value.

Regards

Rajeev

Edited by: Rajeev Patkie on Dec 26, 2007 11:43 AM

Former Member
0 Kudos

Hi Rajeev,

I used exactly the same code.

But here i guess there is a context problem because for each E1WPA04->KONDART there will be either E1WPA05->KONDWERT value or E1WPA05->KONDSATZ value. Not both as u can see from the xml.

Hence its not picking the correct vlaue from E1WPA05. also when i give i<a.length, i always give an error that "Array out of bound".

Can you please explain the complete solution.

thanks

Yash

Former Member
0 Kudos

Yash,

u can try one more thing. Instead of UDF u can use standard if else functions

if E1WPA04->KONDART equals "VKP0" then E1WPA05->KONDWERT. Then do remove context to remove SUPPRESS values and try to assign the same to target node.

Regards

Rajeev

Edited by: Rajeev Patkie on Dec 26, 2007 12:08 PM

Former Member
0 Kudos

Hi Rajeev,

How can we use if-else here when one input(E1WPA04->KONDART) is an array and the other is a constant ("VKP0")?

I mean first we have to use the function "EQUALS" to check if E1WPA04->KONDART equals to the constant "VKP0". But here if we see the queue of E1WPA04->KONDART, it will ahve 2 values ("VKP0" and "ZKA2"). Hence the "EQUALS" function will error out saying:

"Cannot cast ZKA2 to boolean] in class com.sap.aii.mappingtool.flib3.Bool method equals[ZKA2, VKP0, com.sap.aii.mappingtool.tf3.rt.Context@21ac21ac]".

anyway to do it?

Yash