cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Context Problem

Former Member
0 Kudos

Hi All,

I hav a <b>source structure</b> as

<?xml version="1.0" encoding="UTF-8"?>

<ns0:OB xmlns:ns0="http://cibasc.com/anil">

<Root>

<VBELN/>

<EDL24> -


1..Unbounded

<NTEGW/>

<MATNR/>

<ETXTH9>

<FUNCTION>pck</FUNCTION>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>qqq</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>rrr</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>u</TDFORMAT>

<TDLINE>mmm</TDLINE>

</ETXTP9>

</ETXTH9>

<ETXTH9>

<FUNCTION>pck</FUNCTION>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>qqq</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>rrr</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>u</TDFORMAT>

<TDLINE>ppp</TDLINE>

</ETXTP9>

</ETXTH9>

<ETXTH9>

<FUNCTION>pck</FUNCTION>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>qqq</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>c</TDFORMAT>

<TDLINE>rrr</TDLINE>

</ETXTP9>

<ETXTP9>

<TDFORMAT>cu</TDFORMAT>

<TDLINE>ttt</TDLINE>

</ETXTP9>

</ETXTH9>

</EDL24>

</Root>

</ns0:OB>

The Target Structure is :

<Root>

<Attrib> -


0 to Unbounded

<Element1>

<Element2>

<Element3>

<Element4>

</Attrib>

</Root>

Now i wanna map <VEBLN> which is under Root to Element1

<VEBLN> --- <Element1>

<NETGW> <b>if not equal to 0 then</b> -


<Element2> (If this condition fails, the mapping for this occurence of EDL24 shud b stopped and shud goahead with the next occurence.

<TDLINE> -


<Element4> The condition for this is as follows:

Check for the element FUNCTION whose value is 'pck' and if it 'pck', then again check for the element TDFORMAT in the segment ETXTP9 for the value 'cu'. if it 'cu', then populate the Element4 with the TDLINE.

I had tried in most of the ways....but din't get it..

Any help wud b appreciated.

Thnx in Advance

Anil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

<i>1. <VEBLN> --- <Element1></i>you can map it directly since they are in the same context

<i>2. <NETGW> if not equal to 0 then -


<Element2></i>You the if then else to solve this.

<i>3. <TDLINE> -


<Element4> The condition for this is as follows:

Check for the element FUNCTION whose value is 'pck' and if it 'pck', then again check for the element TDFORMAT in the segment ETXTP9 for the value 'cu'. if it 'cu', then populate the Element4 with the TDLINE.</i>

First, do a remove context for TDFORMAT.

This will make TDFORMAT to be in the same context as Function.

i.e, both TDFORMAT and function will have the same parent <ETXTH9>

now, you can use the normal mapping.

regards,

Smitha.

Former Member
0 Kudos

Hi Anil,

1. <VEBLN> --- <Element1> --> Map this as it is

2. <NETGW> if not equal to 0 then -


<Element2> (If this condition fails, the mapping for this occurence of EDL24 shud b stopped and shud goahead with the next occurence.

<NETGW>user defined function<Attrib> 0...unbounded

Here in the user defined function you can check if the value is 0, if yes then you can suppress else you can create the node.

Hence, for each true it will create a occurance.

3. <TDLINE> -


<Element4> The condition for this is as follows:

Check for the element FUNCTION whose value is 'pck' and if it 'pck', then again check for the element TDFORMAT in the segment ETXTP9 for the value 'cu'. if it 'cu', then populate the Element4 with the TDLINE.

<Input>user defined function<element4>

In hte user defined function you will have three Inputs of TDLINE, TDFORMAT and ETXTP9. If your conditons are true then place the output as TDLINE.

Now you will have <ATTRIB> created only for conditon satisfied and then you can fillt he corresponding values accordingly.

Regards

Vijaya

Former Member
0 Kudos

Hi Vijaya,

Thnx for the help.

>>><Input>user defined function<element4>

In hte user defined function you will have three Inputs of TDLINE, TDFORMAT and ETXTP9. If your conditons are true then place the output as TDLINE.

I was tried this for long time b4 posting. but cudn't get it. the problem here is that <function> and <tdline> are in different contexts and the occurences are also different. i din't know how to handle them in a user defined function.

Help wud be appreciated.

Thnx

Anil

Former Member
0 Kudos

Hi ANil,

Since your FUNCTION is a part of header, you can store this value in a global variable. Just declare a gloabl variable and store it for every IDoc.

keep the rest two as Input and use the global variable to check the field.

Hope this resolves it.

Regards

Vijaya

Former Member
0 Kudos

Hi Vijaya,

In my case Function is not a part of the header.

The structure is something like this:

<ETXTH9>-------1..Unbounded

<FUNCTION>-----0....1

<ETXTP9>-------0...Unbounded

<TDLINE>----


0...1

<TDFORMAT> -


0...1

</ETXTP9>

</ETXTH9>

In the above structure, for each occurence of ETXTH9, the function has to be compared against 'PCK'. if yes, then compare TDFORMAT again with teh value 'CU'. if yes, then only u have to send the value of the TDLINE into the target field.if any of the cases fails, then an empty vlaue shud be mapped.

Please help me out... i had tried a lot and also hav the deadline.

Thnx in Adv

Anil

Former Member
0 Kudos

Hi,

Try this...

Mapping:

NTEGW(with context as ROOT)>getNTEGW>Attrib

VBELN(with context as ROOT )--\

NTEGW(with context as ROOT )|>useOneAsMany-->Element1

NTEGW(with context as EDL24)--/

NTEGW(with context as EDL24)-->Element2

-


TDLINE(ETXTP9)-----><b>THEN</b>

FUNCTION(ETXTH9)--\

TDFORMAT(ETXTH9)--|->useOneAsMany-\

TDFORMAT(ETXTP9)--/

-


|->Equals-\

-


CONSTANT("pck")-/

-


|->and-><b>IF</b>->formatbyexample->pass->E4

-


TDFORMAT(ETXTP9)-\

-


|->StringEquals-/

-


CONSTANT("pck")-/

-


CONSTANT("dontpass")-----><b>ELSE</b>

<b>UserDefinedFunctions:</b>

<b>Choose: QUE option:</b>

public void getNTEGW(String[] NTEGW,ResultList result,Container container){

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

if(NTEGW<i>.equals("0"))

result.addValue(ResultList.SUPPRESS);

else

result.addValue(NTEGW<i>);

}

<b>Choose: Context option:</b>

public void pass(String[] a,ResultList result,Container container){

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

if(!a<i>.equals("dontpass"))

result.addValue(a<i>);

}

Regards,

KNS Kumar.