cancel
Showing results for 
Search instead for 
Did you mean: 

context mapping for a field based on a condition

Former Member
0 Kudos

Hi All,

I have the following mapping requirement :

Source Structure : Multiple delivery document with line numbers,batch numbers ,toteid's & Serial numbers.Each row in the table below is a record (0.. many).

One Target Idoc is created for one delivery.

DEl#Line#Batch#MaterialSerialToteIDQty
123101ABC
81232
123201DEF
81233
1241089ABC
81232
1241090ABC
81244
124201DEF
81233
125101XYZ788105
125101XYZ798101
125101XYZ808101
125101XYZ818101
125201DEF
8103

How segments should  be created


IDOC  ( 1...9999) 1 delivery per Idoc

|

E1EDL20 ( 1...9999) ONLY 1 segment per Idoc

|_______E1EDL24 (0...9999) multiple segments per line item and batch# combination for a delivery

                     |

                HIPO --- If there are more than one Batch # for a lineItem# then populate this field with lineitem# else Blank.

The output should be as follows for a delivery Idoc

IDOC (Del#124)

|

E1EDL20

|_______E1ED24

                    |____HIPO = 10

|_______E1ED24

                    |____HIPO = 10

|_______E1ED24

                    |____HIPO = <Blank>

Thanks,

Collins



Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Collins,

please follo the below mapping screen shots

Regards,

Venkat.

Former Member
0 Kudos

Hi Venkat,

Thanks for your input . The field HIPO is getting populated with line number for all deliveries except for Del# 123 , whereas it should populate only for Del#124  and its lineitem#10 which has got 2 batch numbers 89,90.

Any thoughts..

Collins

0 Kudos

Hi Colins,

please try with this mapping

Regards,

Venkat

Former Member
0 Kudos

Hi Venkat,

The field HIPO is getting blank on all segments now.

Thanks,

C

Former Member
0 Kudos

Can someone help me with the mapping requirement above.I am trying with the below mapping but it is not working.

Thanks,

Collins

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can try this mapping:

The output is:

Apologies for the late response, I was on vacation

Hope this helps,

Mark

Former Member
0 Kudos

Hi Collins,

Please try this mapping. I think this is giving correct output.

I wrote two UDF here- Tile and multiple_occurance

Title is having execution type as " all value in context"

===================================

MappingTrace trace;
trace = container.getTrace();
trace.addWarning("length   "+var1.length);
int i=0;
for (i=0 ; i<var1.length-1; i++)
{

  result.addValue(var1[i]);
if (var1[i+1]!=var1[i])
result.addContextChange();


}
result.addValue(var1[i]);

======================================

and another is UDF is  multiple_occrance

and its code is here-

This is also having execution type as " all value in context"

/////////////////////////////////////////////////////////////////////////////////

int i=0;
i=var1.length;
if (i>1)
{
for (int j=0; j<i;j++)
result.addValue(var1[j]);

}
else
result.addValue("");

//////////////////////////////////////////////////////////////////////////////////////