Former Member

# Mapping - a curious scenario?

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.

10|10000 characters needed characters exceeded

### Related questions

Former Member
Posted on Jan 16, 2008 at 02:50 AM

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++)

}

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

10|10000 characters needed characters exceeded
• Former Member Former Member

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++)

{

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

}

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++)

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

for(int k=0;k<c.length;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

• Former Member
Posted on Jan 15, 2008 at 10:32 PM

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

10|10000 characters needed characters exceeded
• Former Member

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.

• Posted on Jan 22, 2008 at 04:44 AM

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.