cancel
Showing results for 
Search instead for 
Did you mean: 

repeat the source field multiple times

Former Member
0 Kudos

Hello,

IDOC - File

The source IDOC structure is :

+ZIDOC

++IDOC

+++E1ABC1

++++BELNR (fields of segment E1ABC1)

++++GEWEI (fields of segment E1ABC1)

++++ABLAD (fields of segment E1ABC1)

+++E1EDP01

++++SPTYP (fields of segment E1EDP01)

++++ZITEMMM (Custom IDOC segment)

+++++abcd (fields of custom IDOC segment)

+++++xyza (fields of custom IDOC segment)

+++++itemno (fields of custom IDOC segment)

On the target side, I have mapped Item(1...unbounded)

with node E1EDPO1 and the no of occurances of E1EDPO1, those many no of item lines are being produced

but I have only one field , BELNR which is from the segment E1ABC1. This is populating only for the first occurance.

its not being repeated for the next item records(item2, item3, item4... so on)

now I have to populate the same BELNR data in all the item fields

How can I acheive it?

Is there any standard function to achieve the same?

regards,

Nikhil.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi nikhil,

<i><b>I followed as you instructed and placed BELNR,E1EDP01, E1ABC1 as the 3 inputs</b></i>

The second & third inputs are not the Segments, u need to give one field from the segment of E1EDP01 like SPTYP, the same field need to give as 3rd input. And change the context of 2nd input to the context of first input..

Try this and let me know. It will defenately works.

Cheers

Veera

Former Member
0 Kudos

Veera,

Great !!!!

its working now

Can you tell me logic how do I use UseOneAsMany

any blog or pdf

This is because I have to populate 3 more such fields from different segments

Thanks

Nikhil.

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi nikhil,

>>> <i>This is because I have to populate 3 more such fields from different segments</i>

You can fallow the same for 3 fields.Here u need to ensure that the first input field occurs only once and need to identify the field which is occurs no.of times.

Refer the following link .

http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/frameset.htm

Cheers

Veera

Former Member
0 Kudos

HI nikhil,

the inputs of useOneAsmany functions like, 1st input is BELNR, Identify the mandatory field which is always populate in the segment E1EDP01 and give that field as 2nd input, let me say for eg:SPTYP , and 3rd input is also SPTYP. Change the context of Second input to the context of first input.in your case the second input context need to be set E1ABC1.

By doing this you can get the value BELNR, how many no.of times the value SPTYP occurs in payload.

Hope it helps to solve u r problem. And let me know u r proceedings.

Cheers

Veera

>>>Reward Points,if it is needful.

Former Member
0 Kudos

Veera,

I followed as you instructed and placed BELNR,E1EDP01, E1ABC1 as the 3 inputs

it throwed the follwoing error.

The message is: Exception:[com.sap.aii.mappingtool.tf3.IllegalInstanceException: Too many values in second queue in function useOneAsMany. It must have over all contexts the same number of values as third queue] in class com.sap.aii.mappingtool.flib3.NodeFunctions method useOneAsMany[, , ]

Nikhil.

Former Member
0 Kudos

try using useOneAsMany from node functions

1st parameter will be BELNR,

2nd & 3rd will be E1EDPO1.. these 2 will have different context...

refer this blog for useOneAsMany

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

Former Member
0 Kudos

The source DT is mentined above.

The receiver DT is in the following way :

+MT_CR_AT

++RECV

+++Header

++++field1

++++field2

++++field3

++++field4

+++Orderitm

++++field1

++++field2

++++field3

++++field4

+++Orderchild

++++field1

++++field2

++++field3

++++field4

Now i want one of the 4 fileds of the reciever segment(from Orderitm and Orderchild) to be mapped to the BELNR of the E1ABC1

used "UseOneAsMany"

with BELNR and E1EDPO1 and E1EDPO1 as 3 inputs according to Mugdha

not working

Nikhil.

Former Member
0 Kudos

PS :

I meant, the Orderitm and OrderChild repeat n no of times based on E1EDPO1 occurance

but BELNR's value(actually it appears to have only one ) should be repeated in Orderitm and Orderchild for each of the n repetetions.

Former Member
0 Kudos

try setting context this way

useOneAsMany inputs

1. BELNR - set context to <b>topmost</b> node (i guess ZIDOC in your case)

2. E1EDPO1 - context to topmost node again

3.E1EDPO1 - context to IDOC node

output will be mapped to your desired target element

Former Member
0 Kudos

Mugdha,

the BELNR is not repeating even after changing the contexts

Nikhil.

Former Member
0 Kudos

Hi Nikhil,

The source structure is very clear.

Cant understand the target structure.

If you would just give that too ,will try solving the problem!!

Regards,

Manju.

Former Member
0 Kudos

Hi

I think for your needs it is enough to use the standard function CopyValue

BELNR -> CopyValue[0] -> item

Best,

Daniele

Former Member
0 Kudos

Daniele,

the copyvalue thing is not working out

thanks anyways

Former Member
0 Kudos

hi Daniele do u think will split by value work in this case?

Former Member
0 Kudos

HI Nikhil,

Have you tried the code which is written by me.

Try that it will work.

Thanks and Regards,

Chirag Gohil

Former Member
0 Kudos

> Daniele,

> the copyvalue thing is not working out

> thanks anyways

Hi Nikhil,

that's weird, if the source field (BELNR) and segment (E1ABC1) occur exactly once, then copyvalue should work.

Be sure you were not testing it with the "Display Queue" tool but use the "Strat transformation" button to perform the whole mapping.

regards,

Daniele

Former Member
0 Kudos

HI,

Use the std function useofmany or write an UDF.

Input: a=E1EDP01 which repeats many times

b=BELNR repeats only once

take the value of a in one context.

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

{

result.addValue(b(0));

}

This functions repeats the value of b as many time your a value is repeating.

Thanks and Regards,

Chirag Gohil.