cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple occurance of a segment and its corresponding field

former_member187447
Participant
0 Kudos

Hi

I have a scenario in which i need to makea LIN segment occur multiple times based on a field LFIMG from source segment. But it just not end there, even the fields in the target segment LIN have some logic, SO i need to not only have an udF which can make the LIN occur multiple times but also make the fields occur in them.

Source:

E1EDL24

LFIMG

E1PT1 (subsegment of E1EDL24)

TDID

E1PT2 (Subsegment of E1PT1)

TDLINE

Target :

LIN

S1

S1logic is if TDID equals X and if TDLINE equals Y, Populate IN in S1

I started with simple code to repeat the occurances of LIN by doing the following, but that doesnt necessarily populate S1 that many times using graphical mapping. So i think i need to include even S1 mapping in the UDF. Please help me out here.

int counter = Integer.parseInt(var1[0]);

for(int i=0; i<counter; i++)

{

result.addValue(" ");

}

Edited by: kalyan golla on Dec 1, 2010 2:15 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Can you put the ocurrence of segments .

is your source this ?

E1EDL24

-


LFIMG. (e.g 0..1)

-


E1PT1

-


TDID

-


E1PT2

-


TDLINE

former_member187447
Participant
0 Kudos

E1EDL24 0...999999

LFIMG

E1PT1 0..99

TDID

E1PT2 0..9999999

TDLINE

Edited by: kalyan golla on Dec 1, 2010 4:08 AM

Former Member
0 Kudos

Hi

I guess var1[0] is LFIMG rigth ?

What option did you select in udf by queue or context?. choose queue if this the case

former_member187447
Participant
0 Kudos

Yes, LFIMG is Var1, I tried both the options, Queue and Context, neither of them could populated the fields in all the multiple occurances of the segment S_LIN.

Former Member
0 Kudos

Can you put a example - payload?

former_member187447
Participant
0 Kudos

- <E1EDL24 SEGMENT="1">

<POSNR>000010</POSNR>

<KDMAT>0360028</KDMAT>

<LFIMG>6.000</LFIMG>

<VRKME>CS</VRKME>

<LGMNG>6.000</LGMNG>

<MEINS>CS</MEINS>

- <E1TXTH9 SEGMENT="1"> -


This is the same as E1PT1

<TDOBJECT>VBBP</TDOBJECT>

<TDOBNAME>0500000296000010</TDOBNAME>

<TDID>Z016</TDID>

<TDSPRAS>E</TDSPRAS>

<LANGUA_ISO>EN</LANGUA_ISO>

- <E1TXTP9 SEGMENT="1"> -


sames as E1PT2

<TDFORMAT>*</TDFORMAT>

<TDLINE>Customer_Item_Number : 0360352</TDLINE>

</E1TXTP9>

- <E1TXTP9 SEGMENT="1"> -


same as E1PT2

<TDFORMAT>*</TDFORMAT>

</E1TXTP9>

- <E1TXTP9 SEGMENT="1"> -


same as E1PT2

<TDFORMAT>*</TDFORMAT>

</E1TXTP9>

</E1TXTH9>

as LFIMG is 6, i would need target as

S_LIN1[1]

0360352 --this is the Customer_Item_Number shown in bold above

S_LIN1[2]

0360352

S_LIN1[3]

0360352

S_LIN1[4]

0360352

S_LIN1[5]

0360352

S_LIN1[6]

0360352

Edited by: kalyan golla on Dec 1, 2010 4:43 PM

Edited by: kalyan golla on Dec 1, 2010 4:44 PM

Former Member
0 Kudos

Hi,

If i understood u correctly??u can proceed as below:

Create 2 UDFS:

UDF1: Input will be var1. Execution Type: All values of a context.

String a1=var1[0];

int a = Integer.parseInt(a1);

for(int k=0;k<a;k++)

{

result.addValue("");

}

UDF2:Input will be var,var2,var3 .Execution Type: All values of a context

int b= var2.length;

int c=var3.length;

int a = Integer.parseInt(var1[0]);

for(int k=0;k<a;k++)

{

for(int i=0;i<b;i++)

{

if(var2<i>.equals("x"))

{

for(int j=0;j<c;j++)

{

if(var3[j].equals("y"))

{

result.addValue("IN");

}

}

}

}

}

Mapping:

LFIMG UDF1-RemoveContext---LIN1

LFIMG -


TDID -


UDF2--SplitByValue--S1

TDLINE(right click and change its context to E1PT1)----

Note: Alter the values in UDF2(as per ur req).

Thanks

Amit

former_member187447
Participant
0 Kudos

I am getting the follwing error message at the UDF level for the field S1

Exception:[java.lang.ArrayIndexOutOfBoundsException: 0] in class com.sap.xi.tf._IDoc_DESADV_DELVRY05_to_ANSIX12_856_V4010XXXXX_ method testing[[Ljava.lang.String;@146da7e1, [Ljava.lang.String;@2b28af41, [Ljava.lang.String;@7c09ea89, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@6f0507fd, com.sap.aii.mappingtool.tf7.rt.Context@334fabfc]

My UDF for the Field S1mapping

public void testing(String[] LFIMG, String[] TDID, String[] TDLINE, ResultList result, Container container) throws StreamTransformationException{

int a = Integer.parseInt(LFIMG[0]);

int b = TDID.length;

int c = TDLINE.length;

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

{

for(int j=0; j<b; j++)

{

if(TDID[j].equals("Z016"))

{

for(int k=0; k<c; k++)

{

if(TDLINE[k].equals("CUSTOMER_ITEM_NUMBER :"))

{

result.addValue("IN");

break;

}

}

}

}

}

former_member187447
Participant
0 Kudos

I found a work around and got it fixed by graphical mapping, Thx to all of you anyway.