cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping - a curious scenario?

Former Member
0 Kudos

Hi,

I have an intresting scenario where in my input message looks like this.....2 customer master data.

Customer

SoldTo1

BillTo1

BillTo2

Customer

SoldTo2

BillTo3

BillTo4

ShipTo1

I would want to create a single idoc Debmdm06 structure with the segment E1KNA1M for each SoldToBillToShipTo.

How can i achieve this in graphical mapping ? any suggestions?

so hence as in above input, there will 7 E1KNA1Ms.

Accepted Solutions (1)

Accepted Solutions (1)

former_member214364
Active Contributor
0 Kudos

Hi BRamchan,

If you have source message structure as

Customer 1...unbounded

--SoldTo 0...unbounded

--BillTo 0...unbounded

--ShipTo 0...unbounded

and want to create E1KNAM segment as sum of (SoldTo+ BillTo + ShipTo) times use the following Context UDF code

public void RepeatSegment(String[] a,String[] b,String[] c,ResultList result,Container container)

{

int cnt;

cnt = a.length;

cnt = cnt + b.length;

cnt = cnt + c.length;

for(int k = 0;k<cnt ; k++)

result.addValue(" ");

}

This UDF takes 3 inputs i.e SoldTo,BillTo, ShipTo.

after each of these 3 inputs use removeContexts node function,the output from this node function map as UDF input.

Please let me know if your requirement is different from what i assumed.

Cheers,

Jag

Former Member
0 Kudos

Hey Jag,

My source message structure is

Customer 1..unbounded

--SoldTo 1..1

--BillTo 0..unbounded

--ShipTo 0..unbounded

I mapped the output from the UDF to E1KNA1M segment.

I tried your Context UDF code, but it had following errors upon testing it in IR

****************************************

Source code has syntax error: /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:208: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = a.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:209: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = cnt + b.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:209: incompatible types found : java.lang.String required: int cnt = cnt + b.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:210: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = cnt + c.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:210: incompatible types found : java.lang.String required: int cnt = cnt + c.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:212: cannot resolve symbol symbol : variable result location: class com.sap.xi.tf._Customers_ED_to_DEBMDM06_ result.addValue(" "); ^ 6 errors Source code has syntax error: /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:208: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = a.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:209: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = cnt + b.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:209: incompatible types found : java.lang.String required: int cnt = cnt + b.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:210: cannot resolve symbol symbol : variable length location: class java.lang.String cnt = cnt + c.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:210: incompatible types found : java.lang.String required: int cnt = cnt + c.length; ^ /usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map243542c0c46a11dc962800163573a310/source/com/sap/xi/tf/_Customers_ED_to_DEBMDM06_.java:212: cannot resolve symbol symbol : variable result location: class com.sap.xi.tf._Customers_ED_to_DEBMDM06_ result.addValue(" "); ^ 6 errors

former_member214364
Active Contributor
0 Kudos

Hi BRamchan,

i have given Context UDF code.i guess you created Value UDF.

To Change from Value UDF to Context UDF:

if you open your UDF,under Imports you can find Change number of Arguments button(pencil and glass symbol) just click on that.

it opens UDF initial screen,now you can see 3 catche options Value, Context,Queue.from these 3 options just select Context option(middle one) and click on create function button at the bottom of then screen.

Please let me know if there are any issues regarding this UDF.

Thanks,

Jag

Former Member
0 Kudos

Hey Jag,

Sorry i had missed that completely. That did the trick. Gr8 help mate!

Now, if i could trouble you more.

Since the target structure is a single E1KNA1M, how to map the SoldTo and BillTo data to the same structure for their own individual instances?

In the sense,

for SoldTo

DLRNUM ---> E1KNA1M-KUNNR

NAME ---> E1KNA1M-NAME1

for BillTo

NUM ---> E1KNA1M-KUNNR

NAME ---> E1KNA1M-NAME1.........etc

former_member214364
Active Contributor
0 Kudos

> DLRNUM ---> E1KNA1M-KUNNR

> NAME ---> E1KNA1M-NAME1

> for BillTo

> NUM ---> E1KNA1M-KUNNR

> NAME ---> E1KNA1M-NAME1.........etc

H BRamchan,

Where do you have these DLRNUM, NAME and NUM fields in Source structure and what are the occurrences of KUNNR, NAME1 fields in Target structure? if possible could you pelase send source and Target structures screenshot.

i look forward to hearing from you.

Cheers,

Jag

Former Member
0 Kudos

Let me give you a sample target data:

<CUSTOMERS_MT>

<CUSTOMER>

<SOLDTO>

<DLR-NBR>003400</DLR-NBR>

<NAME>SoldTo1</NAME>

</SOLDTO>

<BILLTO>

<NUM>003400</NUM>

<NAME>Bill 1</NAME>

</BILLTO>

<BILLTO>

<NUM>003400</NUM>

<NAME>Bill 2</NAME>

</BILLTO>

<SHIPTO>

<NUM>003400</NUM>

<NAME>Ship 2</NAME>

</SHIPTO>

</CUSTOMER>

<CUSTOMER>

<SOLDTO>

<DLR-NBR>003500</DLR-NBR>

<NAME>SoldTo2</NAME>

</SOLDTO>

<BILLTO>

<NUM>003500</NUM>

<NAME>Bill 3</NAME>

</BILLTO>

<SHIPTO>

<NUM>003500</NUM>

<NAME>Ship 3</NAME>

</SHIPTO>

</CUSTOMER>

</CUSTOMERS_MT>

As per our CONTEXT UDF, am getting 7 E1KNA1M segments......i would need the above data to appear as below in them:

<DEBMDM06>

<IDOC BEGIN="">

<E1KNA1M SEGMENT="">

<KUNNR>003400</KUNNR>

<NAME1>SoldTo1</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR></KUNNR>

<NAME1>BillTo 1</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR></KUNNR>

<NAME1>BillTo 2</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR></KUNNR>

<NAME1>ShipTo 1</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR>003500</KUNNR>

<NAME1>SoldTo2</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR></KUNNR>

<NAME1>BillTo 3</NAME1>

</E1KNA1M>

<E1KNA1M SEGMENT="">

<KUNNR></KUNNR>

<NAME1>ShipTo 3</NAME1>

</E1KNA1M>

</IDOC>

</DEBMDM06>

Edited by: BRamchan on Jan 18, 2008 2:06 PM

former_member214364
Active Contributor
0 Kudos

Hi BRamchan,

I have created 2 UDFs to map DLR-NBR(from SOLDTO node) and NAME elements from Source structure to KUNNR and NAME1 elements in target strcture.

1. Map DLR-NBR to KUNNR :-

Create Context UDF with 3 arguments

Code as follows

int cnt = b.length + c.length;

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

{

result.addValue(a[k]);

for(int m=0;m< cnt;m++)

result.addValue(ResultList.CC);

}

3 Inputs to UDF:

1st Argument is DLR-NBR element which is under SOLDTO node in source

2nd Argument is NAME element which is under BILLTO node in source(Change Context to CUSTOMER )

3rd Argument is NAME element which is under SHIPTO node in source(Change Context to CUSTOMER )

2.Map NAME to NAME1

Create Context UDF with 3 arguments

Code as follows

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

result.addValue(a[k]);

for(int k=0;k<b.length;k++)

result.addValue(b[k]);

for(int k=0;k<c.length;k++)

result.addValue(c[k]);

Note:- use SplitByValue node function between UDF and NAME1 field

3 Inputs to UDF:

1st Argument is NAME element which is under SOLDTO node in source( Change Context to CUSTOMER )

2nd Argument is NAME element which is under BILLTO node in source(Change Context to CUSTOMER )

3rd Argument is NAME element which is under SHIPTO node in source(Change Context to CUSTOMER )

Note:-Change Context to CUSTOMER

To do this context change just right click on source element in Data flow editor Context->CUSTOMER

Please let me know if you are have any issues with this logic.

Cheers,

Jag

Answers (2)

Answers (2)

Jitendra_Jeswan
Contributor
0 Kudos

Hi Can you write the target structure for the source message that you provided in your first post so it would be easy to interprete it well...

Regards.

Jeet.

Former Member
0 Kudos

Hi BRamchan,

In the target structure on the idoc right click on E1KNA1M and select duplicate tree. Do this seven times so that seven segments will be created. Now you map each segment to one segment from the source.

You can use exists and createif combination for this target segments to create or not to create. Once the segment is created map the filed what ever your business is expecting.

Regards,

---Satish

Former Member
0 Kudos

Hey Satish,

7 segments was only an example. This number would be dynamic. i would not know the exact number of segments to output until runtime.