cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping: Map value from the first element in a context in target el

Former Member
0 Kudos

Hi experts,

I have a problem with a message mapping in XI. I hope you can help me. At first I will give you a source and a target structure. Then I will explain the problem.

<u>Source structure:</u>

<E1EDP01>

<E1EDPT1>

<TDID> ... </TDID>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

</E1EDPT1>

</E1EDP01>

The structure can contain more than one E1EDP01-Elements, more than one E1EDPT1-Elements and more than one E1EDPT2-Elements.

<u>target structure:</u>

<LineItem>

<vendmemo> ... </vendmemo>

</LineItem>

For every E1EDP01-Element my mapping creates one LineItem-Element in the target structure. To fill the element <vendmemo> the mapping should do the following steps:

The mapping should search in E1EDP01 for a E1EDPT1 with the TDID = Z505. And from this E1EDPT1-Element (with the TDID=Z505) the mapping should take the value <TDLINE> from the first E1EDPT2-Element in the context of the E1EDPT1-Element (the E1EDPT1 with the TDID=Z505) and put this value in <vendmemo>.

The mapping should do this action for every E1EDP01 -> so for every LineItem.

I tried it with UDF but I didn't found a solution. Can anybody help me?

best regards

Christopher

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christopher,

Try this:

E1EDP01 -


> LineItem.

for vendmemo use 2 UDFs.

TDID----


-


\

TDLINE(Context E1DPT1)----/UDF1--\formatByExample-->UDF2--->vendmemo

E1EDPT1----


/

UDF1 :

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

{

if(a<b>[</b>i<b>]</b>.equals("Z505"))

result.addValue(b<b>[</b>i<b>]</b>);

else

result.addValue("1");

}

UDF2 :

String flag = "false";

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

{

if(a<b>[</b>i<b>]</b> != "1" )

{

result.addValue(a<b>[</b>i<b>]</b>);

break;

}

}

if(flag != "true")

result.addValue(" ");

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi Maheshwari,

thanks for your help. Now the problem is solved and the mapping is working fine.

With best regards

Christopher

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi Christopher,

what error u getting???..... coz its working fine with me.

Give ur email id...i will send u screen shot.

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi Maheshwari,

thanks for your email. but your solution did'nt solve my problem. I replied to your e-mail. Pleas check it

Regards

Christopher

Former Member
0 Kudos

Hi Christopher,

its Context... what error u getting???..... coz its working fine with me.

Give ur email id...i will send u screen shot.

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi,

my e-mail: christopher.kuehn@dataprocess.de

Thank you very much ... I will try it next week and then I'll tell you what my results are.

Regards

Christopher

PS: I get no error. but the mapping puts wrong values in the vendmemo-elements

Former Member
0 Kudos

Hi Chirstopher,

Try this :

E1EDP01--->LineItem

TDID(Context-E1EDP01)----\UDF


\equalsS(from text)-ifThenElse--->vendmemo

TDLINE(Context-E1EDPT1)/ Constant[1]-/

3 input of ifThenElse

output of equalsS --->if

Constant[] (blanck)-->then

TDID(Context-E1EDP01)--\UDF->else

TDLINE(Context-E1EDPT1)--/

UDF :

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

{

if(a<b>[</b>i<b>]</b>.equals("Z505"))

{

result.addValue(b[0]);

}

else

result.addValue("1");

}

Hope this will work.

Thanks,

Maheshwari.

Former Member
0 Kudos

Thanks for your effort, but it isn't still working.

In the UDF: Should I choose "Context" or "Queue" as Cache?

I took Context.

Best regards

Christopher

henrique_pinto
Active Contributor
0 Kudos

Hey Cristopher, let me get this right.

Are you using multimapping? I mean, you are doing n:n mapping?

Regards,

Henrique.

Former Member
0 Kudos

Hi Henrique,

no I'm not using a multi-Mapping. The Mapping which I create is for an IDOC-to-File scenario.

The IDOC can contain one or more E1EDP01-elements. and for each of this E1EDP01-elements my mapping creates on LineItem-element in the target structure.

Thanks

Christopher

Former Member
0 Kudos

Hi

map the E1EDPT1 or multiple occurrence more one root element to target node

Regards

Chilla

Former Member
0 Kudos

Sorry, but I don't understand.

I mapped the E1EDP01 to LineItem. So that for every E1EDP01 one LineItem will be created.

Now I have to fill the element "vendmemo"

Thanks

Christopher

Former Member
0 Kudos

Hi Christopher,

have u tried with my solution???

Thanks,

Maheshwari

Former Member
0 Kudos

Hi Maheshwari,

yes I tried it, but it was not working

Thank you

Former Member
0 Kudos

Sorry, I was wrong ... my solution was not right. My solution was only working for a few test-instances.

In the next post i will give you some more information about my problem

Former Member
0 Kudos

Hi Christopher,

Try this.

TDID>RemoceContext\equalsS->createIf>LineItem

Canstant[Z505]----


/

UDF has 2 inputs:

TDID--


\UDF->vendmemo

TDLINE(<b>Context-E1EDP01</b>)---/

UDF :

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

{

if(a<b>[</b>i<b>]</b>.equals("Z505"))

{

result.addValue(b[0]);

}

}

In target structure for LineItem keep occurance as <b>0 to unbound</b>

let me know if u get any problem.

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi all,

thank you for your suggestions. I solved the Problem in the following way:

I set the context of TDID and TDLINE to E!EDP01. Here the target-field mapping:

TDID(Context: E1EDP01) -


UDF - collapseConexts - SplitByValue - vendmemo

TDLINE (Context: E1EDP01) --/

My UDF is the following:

String vendmemo="";
for (int i=0 ; i<tdid.length ; i++) {
   if (tdid<i>.equals("Z505")) {
      vendmemo=tdline<i>;
   }
}
result.addValue(""+vendmemo);

With best regards

Christopher

Former Member
0 Kudos

Hello experts,

i was wrong ... my mapping isn't still working. I had created a test instance. and only for this test instance the mapping (see above) works.

Can anybody help me? I'm trying the whole day but I can't find a solution. Here a second description of my problem:

<u>Source Structure:</u>

<E1EDP01>

<E1EDPT1>

<TDID> ... </TDID>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

</E1EDPT1>

</E1EDP01>

<E1EDP01>

<E1EDPT1>

<TDID> ... </TDID>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

<E1EDPT2>

<TDLINE> ... </TDLINE>

</E1EDPT2>

</E1EDPT1>

</E1EDP01>

...

<u>Target Structure:</u>

<LineItem>

<vendmemo> ... </vendmemo>

</LineItem>

<LineItem>

<vendmemo> ... </vendmemo>

</LineItem>

...

<u>Description of my Problem:</u>

For each E1EDP01 in the source structure the mapping creates one LineItem in the target structure.

The element "vendmemo" should be created in any case ... also if it will be empty.

To fill the element "vendmemo" the mapping should search in E1EDP01 for a E1EDPT1 with the TDID=Z505. If there is an element E1EDPT1 with the TDID=Z505, the mapping should write the TDLINE from the first E1EDPT2 (under the element E1EDPT1 with the TDID=Z505) in the target field "vendmemo".

The Problem is that TDLINE an TDID are not in the same context. I tried it with setting the context of both to E1EDP01. But it was not working ... have you any idea oder suggestion?

Thank you very much

best regards

Christopher

Former Member
0 Kudos

Hi Cristopher,

in graphical mapping, take TDID node....change its context to EDP01......take useOneAsMany function......in this take TDID as first argument, EDPT2 as second and EDPT2 as third argument.......take the output of this function to UDF input...in UDF take second input as TDLINE with context change to EDPT1....then in UDF in a loop check for TDID equal to Z505 and then send TDLINE as output in UDF...then use splitbyvalue function......take output of splitbyvalue to vendmemo..

Thanks,

Rajeev Gupta

prabhu_s2
Active Contributor
0 Kudos

hi

I did face issues like this but i took the other way for this which is not quite good to go without exploring the usage of graphical mapping. it can be done using java mapping. better and more control of this process. another way that strikes is to use advacned udf funtion which will play with context.