cancel
Showing results for 
Search instead for 
Did you mean: 

new challenge with graphical mapping

Former Member
0 Kudos

Hi Experts

I Have the following structure

<Header>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_3>

<packnr>ECC</packnr>

<\segment_3>

<segment_3>

<packnr>EDD</packnr>

<\segment_3>

</Header>

To the target structur which is a flat file , I have to map the paknr twice , hence we will have 2 lines in the target structure

but I have also to map the belnr in segment_1.that it will correspond to the number of lines obtaines by the segment_3

that means I have to map the belnr only twice.

I have tried with several node function but the third segment_1 is always puched to the next line.

please advice.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I am expecting your belner will be same all the time .

Like in your example . So you can use

belner (Context Should be on segment_1) - >

Copy Value ->

segment_3 -> Use One as Many -> Target .

Packnr ->

CopyValue : Copies value on target side only once, no matters how many times the element repeated on source side. i.e it suppress the sender value.

Use OneAsmany has three Input .

First Input - > Value need to be repeat .

Second - > First value will be repeat on the basis of second input ( I mean No of times) in your case 2.

Third Input -> based on this value, It will Insert Context in Output Queue. i.e 1000 , Conext Change , 1000

Note: Second and Third input should has equal no of values.

Regards

Prabhat Sharma

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

My understanding is that the belnr should repeat as many times as of packnr...

then try using useoneasmany node functions and check it out..

HTH

Rajesh

Former Member
0 Kudos

copy and paste expected target structure also

Former Member
0 Kudos

Hi again

This is the target structure

<order>

<header>

</header>

<Item>

<f1></f1>

<f2></f2>

<f3></f3>

<TARGETBELNR></TARGETBELNR>

<TARGETPACKNR></TARGETPACKNR>

</Item>

</order>

Item node has to be created as many times as <segment_3> occurs , that is twice in this case

paknr should be mapped to <TARGETPACKNR> , in this case twice.

and belnr should be mapped to <TARGETBELNR> but only twice as we have only to lines with the Item

I hope it is clear

Thanks

Former Member
0 Kudos

Hi

Please go through this link from help.sap.com to use UseoneasMany fucntion which fits your requirement,

[http://help.sap.com/saphelp_nwpi71/helpdata/en/d2/58cd3b11571962e10000000a11402f/frameset.htm]

Regards,

kalpana.

Former Member
0 Kudos

Hi, Malu:

Try this first, and let us know what is the outcome:

<segment_3> -


> <Item>

/segment_1/belnr --->/Item/TARGETBELNR

/segment_3/packnr --->/Item/TARGETPACKNR

I think it should be working, even the queue length for /segment_1/belnr is 3, sinc target parent node item only has 2, it it should get only first two values from the queue.

Regards

Liang

Former Member
0 Kudos

Maul.. Is the source structure dynamic? At all times is this going to be like how you have mentioned? Can there be 4 belners and 5 packnrs?

Former Member
0 Kudos

Hi all

Thanks for the many suggestions I will try then and get back

and yes Is the source structure is dynamic, it can be many belners and few or many packnrs, but the belners is always the same in each item node .

BR

Former Member
0 Kudos

Hi Malu,

Try as Liang suggested.

Apart from this i would advise you to go for Belnr maping like :

<segment_3> -


> <Item>

if /segment_3/packnr ---> exists (use node function) then map /segment_1/belnr --->/Item/TARGETBELNR

/segment_3/packnr --->/Item/TARGETPACKNR

Thanks,

Jyoti

Former Member
0 Kudos

Hi all

by trying Liang suggestion , it is puching the last belnr to the next target item node .

In the Use One as Many suggested by Prabhat I am having this error

Runtime exception when processing target-field mapping /ns0:Shipment/Order/Item/LAUFTNR; root message: Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Too few values in the first queue in function useOneAsMany. It must have the same number of contexts as the second queue] in class com.sap.aii.mappingtool.flib7.NodeFunctions method useOneAsMany[[Ljava.lang.String;@218e681e, [Ljava.lang.String;@c559ac8, [Ljava.lang.String;@4824c6cb, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@66775e6d, com.sap.aii.mappingtool.tf7.rt.Context@26d87aa9]

besides using the copy value will always take the first value and repeat it , even if we hvae another value for another node , so I took it out but still have the error mentioned.

Prabhat can yoy please state exactly how the parameter for use one as many should be

BR

Former Member
0 Kudos

Use one as many has three input q's. First input would be the single value you want to pass as many (get only the single belner value). Second input would be the number of times the value has to be passed. Third would be the how you want the contexts to be inserted between values.

There should be some problem with the way you have given the inputs (esp wrt to the contexts/ values inside one set of contexts); that is why you are getting the error you have mentioned.

Check the below link which explains how each fn is being used. Go to the One as many function here.

http://wiki.sdn.sap.com/wiki/display/XI/Explainnodefunctions

Former Member
0 Kudos

Hi SXMI

I have triede the Use one as many , it will only take the first belnr for alle the Item line

The source can have multiple Header with different belnr and packnr each time

like this

<Header>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_1>

<belnr>10000</belnr>

<\segment_1>

<segment_3>

<packnr>ECC</packnr>

<\segment_3>

<segment_3>

<packnr>EDD</packnr>

<\segment_3>

</Header>

<Header>

<segment_1>

<belnr>20000</belnr>

<\segment_1>

<segment_1>

<belnr>20000</belnr>

<\segment_1>

<segment_1>

<belnr>20000</belnr>

<\segment_1>

<segment_3>

<packnr>ABB</packnr>

<\segment_3>

<segment_3>

<packnr>ACC</packnr>

<\segment_3>

</Header>

Probably I am doing something wrong but I can not figure oute what is it

Thanks

Former Member
0 Kudos

Hi,

If i understood u correctly..then go with the below suggested UDF and mapping:

UDF1: Context: All values of a queue

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

{

result.addValue(b<i>);

}

1) Segment_3 -> Item

2) Segment_3----


>

-


UDF1------TARGETPACKNR

paknr->removeContext->

3) Segment_3----


>

-


UDF1------TARGETBELNR

belnr ->removeContext->

Thanks

Amit

Former Member
0 Kudos

Thanks