cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping based on field positions

santosh_k3
Active Participant
0 Kudos

Hi All,

It is a file to IDOC scenario

i am getting a file with Multiple H1 , AM records and the field positions of these records as 01,02,03 as given below.

01 02 03

H1 C

AM U 00000002

AM X 00000012

AM U 00000002

AM X 00000020

AM G 00000003

AM T 00000005

H1 S

AM U 00000002

AM X 00000030

AM U 00000002

AM X 00000040

AM G 00000005

AM T 00000006

and based on the this H1-02 record( C & S) i need to pick AM-03 values when ever AM-02 is "X".

ie., when ever the H1-02 = "C" then in target field i need to have AM-03 values as -ve whenever AM-02 = "X".

and when ever the H1-02 = "S" then in target field i need to have AM-03 values whenever AM-02 = "X".

output : IDOC fields Target C and TargetS.

1) TargetC : when H1-02 = C

-00000012

-00000020

2) TargetS : when H1-02 = S

00000030

00000040

Please provide help on this requirement.

Thanks

Sai_SHA

Edited by: sai_SHA on Jan 13, 2012 10:55 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

one more option...



H1-02----
       --------equals-------
Constant(C)                   \
                ---------------OR---------IfWithoutElse(Constant()----Then)----------Target (Node)
H1-02----                     /
       ----------equals-------
Constant (S)



H1-02----------------------------------------------\
                                                       \
AM-02(Change its context to immediate parent)-----------UDF1----remove context---splitby value(each value)---udf2---TargetField                               /
                                                      /
AM-03 (change its context to immediate parent)--------

UDF1:

excution type : all values of a context

input: var1, var2, var3


String a ="";
String b="";
if(var1[0].equals("c"))
{
for(int j=0;j<var2.length;j++)
{
if(var2[j].equals("x"))
{
a = a +  "-" + var3[j] +  ";";
}
}
result.addValue(a);
}

if( var1[0].equals("s"))
{
for(int j=0;j<var2.length;j++)
{
if(var2[j].equals("x"))
{
b = b + var3[j] +  ";";
}
}
result.addValue(b);
}

UDF2:


String [ ] b = a[0].split(";");
for(int i=0;i<b.length;i++)
{
result.addValue(b<i>);
 }
 

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try below mapping for Target C:

1. Match the H1-02 with C constant. Keep the context of H1-02 at higher level.

2. Map the above to ifWithoutElse func.

3.To the other input of ifWithoutElse, map another ifWithoutElse.

For second ifWithoutElse, again check if AM-02 is X; if it is X pass -ve value of AM-03.

Same should be done for Target S.

-Supriya.