cancel
Showing results for 
Search instead for 
Did you mean: 

1:n Mapping.

Former Member
0 Kudos

Hi Experts,

Have a requirement such that depending on a single field in the input structure ( Say Dummy 1) I need to populate multiple segments in the output structure.

Suppose If Dummy 1 is 1 and i need to populate a segment (1...99).

can you anyone please show me some idea on this.

Thanks,

Prem

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prem,

If the population is based in some other field, I mean is the number of times depend on other field, the best option is use "UseOneUsMany" function.(and maybe you want to format your output with different contexts)

I other cases, the best option is use a UDF to replicate the field the times You want.

Regards

Ivan

Former Member
0 Kudos

thanks for ur replies. Can u pls let me know how this can be attained.

My scenario if file to Idoc.

I have a header field which is 0:1 occurance, Based on these values i need to pass the values to a segment for all the line items.

Former Member
0 Kudos

Hi.

So you need a UDF , receive two Parameters value and repeat

Try this


 for (int i = 0 ; i < repeat ; i++){
    result.addValue(value);
}

Former Member
0 Kudos

I tried this. But how will i pass a single value (in my case the header value ) and an array to the UDF.

Former Member
0 Kudos

hi

The header value has an ocurrence 0..1 right? ..so the function repeat many times the Header[value]. the repeat[parameter] is a constant.

Edited by: Luis Ortiz on Jul 16, 2009 9:26 AM

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Would you be able to give the source and target structure? Also please provide a sample input/output so we could help you more.

regards,

Former Member
0 Kudos

yes. but we cannot have the output as result array.. We can only return the value and cant use result.addvalue in the udf.

Correct me if am wrong

Former Member
0 Kudos

Hi Mark,

am mapping dummy to a segment E1MAKTM-MAKTX.

Dummy is a field which will contain the text this text needs to be split for every 4 character and populate it into multiple E1MAKTM.

This is the requirement.

If the input is

Thanks for answering my posts

the outpu should be

Than

ks fo

rans

weri

....

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

This is possible via UDF, see mapping below:


for the node E1MAKTM, use this mapping:
 
sourceNode --> UDF --> equalsS --> not --> ifWithoutElse --> removeContext --> E1MAKTM
            constant: --> /                      / 
                         sourceNode --> UDF --> / 
 
for the node MAKTX, use this mapping:
 
sourceNode --> UDF --> equalsS --> not --> ifWithoutElse --> removeContext --> splitByValue:eachValue --> E1MAKTM
            constant: --> /                      / 
                         sourceNode --> UDF --> / 
 
here is the UDF, type is CONTEXT
Argument: anInput
 
int cnt = 0;
StringBuffer sb = new StringBuffer();
char temp[] = new char[anInput[0].length()];
for(int a=0;a<anInput[0].length();a++){
temp[a]=anInput[0].charAt(a);}
for(int a=0;a<temp.length;a++){
if(temp[a]==' ')
sb = sb.append(temp[a]);
else
{sb = sb.append(temp[a]);cnt++;}
if(cnt%4==0){result.addValue(sb.toString());sb = new StringBuffer();}}
result.addValue(sb.toString());

The constant in this code is a space.

sorry for the unoptimized code, but this is working...

hope this helps,

Edited by: Mark Dihiansan on Jul 17, 2009 7:22 PM

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Experts,

Have a requirement such that depending on a single field in the input structure ( Say Dummy 1) I need to populate multiple segments in the output structure.

Suppose If Dummy 1 is 1 and i need to populate a segment (1...99).

can you anyone please show me some idea on this.

Thanks,

Prem

Hi you can use Node funtions.

Dummy >> UseOneAsMany.

Former Member
0 Kudos

Hi,

It could be ABAP mapping or using node functions like useAsMany in graphic mapping... It depends on the message required. Could you please specify it?

Regards,

Radek