cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping help required

Former Member
0 Kudos

Hi All,

i am doing IDOC-File scenario.

i have a problem in mapping.

Source IDOC structure in hierarchy:

ZIDOC->E1QWE->Field1,Field2,Field3

Target structure:

TMSG->DETAILS-> DetailLine->fld1, fld3

Example Source IDOC:

<ZIDOC>

<E1QWE>

<Field1>11</Field1>

<Field3>22</Field3>

</E1QWE>

<E1QWE>

<Field1>33</Field1>

<Field2>44</Field2>

<Field3>55</Field3>

</E1QWE>

<E1QWE>

<Field1>66</Field1>

<Field3>77</Field3>

</E1QWE>

<E1QWE>

<Field2>88</Field2>

</E1QWE>

</ZIDOC>

The problem is for every E1QWE segment where E1QWE->Field2 <b>does not exist</b>, a DetailLine node should be created in Target XML.

So Target XML for above source XML will be:

<TMSG>

<DETAILS>

<DetailLine>

<fld1>11</fld1>

<fld3>22</fld3>

</DetailLine>

<DetailLine>

<fld1>66</fld1>

<fld3>77</fld3>

</DetailLine>

</DETAILS>

</TMSG>

Can anybody suggest how to implement this non-exist condition in mapping?

Thanks,

Rajeev Gupta

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Rajeev,

There is a node function MAPWITHDEFAULT.

1.Use MAPWITHDEFAULT and give some String Sequence as the Default value.

2 . Write a UDF That will check for the DEFAULT value and if the DEFAULT value exists, then create the target nodes else ignore the same.

Regards

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

But there is still a problem

there are 2 conditions:

(i.) Field2 does not exist

(ii.) Field2 node is there but it does not have a value like <Field2></Field2>

MAPWITHDEFAULT works with condition but not for (ii) condition.

<b>So what to do for (ii) condition?</b>

Moreover in my target XML, see the DETAILS node - its occurance is 0..1 and the DetailLine node has occurance 1..unbounded. So if any of the above 2 conditions exist, then a DETALS node should be created and as many E1QWE segments satisfy any of the 2 conditions, those many DetailLine nodes should be created. <b>So how to create these DETAILS node and DetailLine nodes.</b>

Thanks,

Rajeev Gupta

bhavesh_kantilal
Active Contributor
0 Kudos

Rajeev,

><i>MAPWITHDEFAULT works with condition but not for (ii) condition.</i>

In your UDF check for a blank String "" or your Default String and do the needfil . Condition ii will also work fine in this case.

1. Use the MAPWITHDEFAULT logic to create DETAILineNODE for every node that satisifies your conditon.

2. For the DETAILS node, write an Adavanced UDF that will check for the values of Field Node and do the logic implementation . Again before the Input to the Adavnced UDF, MAPWITHDEFAULT should be used.

Regards

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

please give some more details........ok i will have to create a UDF........see i should do:

E1QWE-Field2 -> MAPWITHDEFAULT -> RemoveContext - > MyUDF ->CreatIf->DETAILS

Now my question the argument to MyUDF should be an array for containing all the Field2 values of the complete IDOC because i have to check the complete IDOC to see if there is any E1QWE segment with <Field2 /> data - then only DETAILS node should be created.

Can you please provide some more detail on this UDF.

Thanks,

Rajeev Gupta

Answers (1)

Answers (1)

prabhu_s2
Active Contributor
0 Kudos

not much clear with ur requirement

<b>The problem is for every E1QWE segment where E1QWE->Field2 does not exist, a DetailLine node should be created in Target XML.</b>

Former Member
0 Kudos

Hi All,

Means see in ZIDOC there can be many E1QWE segments. now if there is at least one E1QWE segment which <b>does not have a Field2 item</b> in it - or - there is at least one E1QWE segment <b>which has a Field2 item in it with no data like <Field2></Field2>,</b> then <b>only</b> in target the DETAILS node should be created and in that DETAILS node , a DetailLine node should be created...........

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Please check this...i tested with your example and it works....

once you get the idea you can extend it...

Field2-->mapWithDefault['PASS']-->removeContexts
                                                                                equalsS-->if,then-->  removecontext -->DetailLine
                                                /                    /
                                COnstant['PASS']         COnstant['']

now for fld1 and fld3, the logic is mostly the same, the difference is that instead of the '' constant going out of 'ifwithoutelse', field1/field3 goes...and there is also a 'splitbyvalue' just before mapping to fld1/fld3..

added...

**************

also the 'removecontexts' just before the 'equalsS' need to be taken off for fld1/fld3 mapping...

Thanks.

Message was edited by:

Deepu Venugopal

Former Member
0 Kudos

Hi Venu,

Sorry your solution did not worked for me..........in my input i gave in source 3 E1QWE segments . the first has

<Field2>2</Field2> data . the second and third has <Field2 /> data.

But no DETAILS node was generated. See also my above posting.

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi Rajeev,

I thought you would have done ampping for details node....i assumed it to be 1..1...

anyways...for the 'Details' node the mpping needs to be same as detailsline execpt for that you need to add a collapse context right at the end before mapping to 'Details'...

this is a very common requirement and you donot need to write any UDF for this...

Again..as i told you might need to extend this...i have checked for a condition where 'field2' is absent...ie. what 'mapwithDefault' does....along with 'mapwithdefault' you might need to add a check to see if field2 is ''

which would look like this...

Field2-->mapWithDefault['PASS']-->removeContexts
                                                                                equalsS-->  OR -->goes to if then
                                                /           / 
                                COnstant['PASS']           /
                                                          /
                                     Field2 --> equalsS-->
                                              /
                                  Constant['']

Thanks.

Message was edited by:

Deepu Venugopal

Former Member
0 Kudos

Hi Venugopal/All,

Can you please explain again how to generate one DETAILS node and variable DetaillLine nodes with condition that Field2 will have <Field2 /> data.

i have done:

Field2 ->removecontext ->

equalsS -> collapsecontext -> creatif -> DETAILS

Constant[]->

Field2 ->

equalsS -> splitbyvalue -> creatif -> DetailLine

Constant[]->

On executing above with source file having 3 E1QWE NODES with <Field2>11</Field2> , <Field2 /> , <Field2 /> data - No DETILS node is getting created.

Please suggest what to solve this query.

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi ,

This should work.


FIELD2 -->mapwithdefault['']-->removeContext-->equalsS-->if,then-->removecontext-->collapsecontext-->details
                                             /          /
                                constant['']   constant['']

FIELD2 -->mapwithdefault['']-->removeContext-->equalsS-->if,then-->removecontext-->detaillines
                                             /          /
                                constant['']   constant['']

FIELD2 -->mapwithdefault['']-->equalsS-->if,then-->removecontext-->splitBYValue-->FLD1
                              /          /
                  constant['']      FIELD1

FIELD2 -->mapwithdefault['']-->equalsS-->if,then-->removecontext-->splitBYValue-->FLD3
                              /          /
                  constant['']      FIELD3

Thanks.