cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping question

AlexanderApel
Participant
0 Kudos

Hi Experts,

i need your help. I receive one xml-file with 1..n segments of lines and i have to map this lines in only one output line without the header.

my Input:

and my target output:

can anyone help me to resolve this?

Regards,

Alex

Accepted Solutions (1)

Accepted Solutions (1)

suman_sourabh
Participant
0 Kudos

Hello Alexander,

As per my understanding if your input file structure is as TestInput.xml and the expected output file structure is Test_Output.xml then you can get this output file (both the files are attached) as below:

Change the context of the field <ADDITXT> to the grand parent <E1WTADAL1>

write the udf taking the text field <ADDITXT> as input and the Execution type as Context..

String myOut="";

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

myOut = myOut+var1[i];

}

result.addValue(myOut);

hope this will help.

Regards,
Suman

Answers (1)

Answers (1)

azharshaikh
Active Contributor
0 Kudos

Hi,

You can use the Concat function from Text group and map the required fields from Source to Target node.

Regards,

Azhar

AlexanderApel
Participant
0 Kudos

Hi Azhar,

sorry i forget the structure...

in this case i don't know how to use Concat correctly.

i already played around with the Context but i don´t get the right result.

Regards,

Alex

suman_saha
Contributor
0 Kudos

Hi,

I guess you can't use concat function as it is adding the values of same field value.

You need to keep adding the value in a global variable and at last assign the value of that global variable to the output field.

Suman

suman_saha
Contributor
0 Kudos

Hi,

You can use ADDITXT input of a Queue UDF:

String[] store = new String[1];

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

{

store[0] = store[0]+","+var1<i>;

}

result.addValue(store[0]);

Suman

AlexanderApel
Participant
0 Kudos

Hi Suman,

this is really helpful but now i have the next problem...

result with your UDF:

but i need like this one:

best regards,

Alex

suman_saha
Contributor
0 Kudos

now you need to use useOneAsMany:

Inputs:

1. The output of udf

2. ADDIMATNR

3. ADDIMATNR.

Suman

AlexanderApel
Participant
0 Kudos

now i get an Exception:

Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Too many values in the second queue in function useOneAsMany. The number of values for all contexts must be the same as the number of values for the third queue] in class com.sap.aii.mappingtool.flib7.NodeFunctions method useOneAsMany[[Ljava.lang.String;@4f2db49d, [Ljava.lang.String;@41acd807, [Ljava.lang.String;@3a9ad540, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@b267acf, com.sap.aii.mappingtool.tf7.rt.Context@b48b1c1]

See error logs for details    

former_member184720
Active Contributor
0 Kudos

Check your useoneasmany function.

Follow the below wiki to understand the function and correct your mapping accordingly.

Explain node functions - Process Integration - SCN Wiki

nabendu_sen
Active Contributor
0 Kudos

Hi Alex,

I can see you are sending same value to all the Target fields. If your UDF is generating correct String, just use "copyValue" function from Constant segment. Then the same value will be copied irrespective of the occurrence of the Target field.

But copyValue will work if you want pass the SAME value. Give a try.

UDF Output --> copyValue --> <temp_ABEZ>

Regards,

Nabendu.

suman_saha
Contributor
0 Kudos

Hi,

Try :

Inputs:

1. The output of udf

2. E1WTADAL2

3. ADDIMATNR.

Suman