cancel
Showing results for 
Search instead for 
Did you mean: 

message mapping for E1EDPT1/E1EDPT2/TDLINE split and assign in proper context of E1EDPT2

Former Member
0 Kudos

hi all,

i've a source structure and target structure which looks like this below

        <L_PO1>

          <S_PO1>

            <D_330>30</D_330>

            <D_355>BD</D_355>

            <D_235>BP</D_235>

            <D_234>MAT1</D_234>

          </S_PO1>

          <L_PID>

            <S_PID>

              <D_349>F</D_349>

              <D_352>description which can have length 140 characters max</D_352>

            </S_PID>

          </L_PID>

          <L_PID>

            <S_PID>

              <D_349>F</D_349>

              <D_352>another description for the same MAT1 which also can have max 140 char</D_352>

            </S_PID>

          </L_PID>

        </L_PO1>

The target structure is a IDOC orders and it should look like this below after the mapping of item level segment

<E1EDP01 SEGMENT="1">

<MENGE>30</MENGE>

<MENEE>BD</MENEE>

<E1EDP19 SEGMENT="1">

<QUALF>001</QUALF>

<IDTNR>MAT1</IDTNR>

</E1EDP19>

<E1EDPT1 SEGMENT="1">

<TDID>Z001</TDID>

<TSSPRAS>E</TSSPRAS>

<E1EDPT2 SEGMENT="1">

<TDLINE>take first 70 characters of the description</TDLINE> "if the description is greater than 70 characters

<TDFORMAT>/</TDFORMAT>

</E1EDPT2>

<E1EDPT2 SEGMENT="1">

<TDLINE>remaining 70 characters or less from the description</TDLINE> "create a new TDLINE with a new context of E1EDPT2.

<TDFORMAT>/</TDFORMAT>

</E1EDPT2>

<E1EDPT2 SEGMENT="1">

<TDLINE>this description is not greater than 70 characters</TDLINE> " no need to split because it's not more than 70 characters.

<TDFORMAT>/</TDFORMAT>

</E1EDPT2>

</E1EDPT1>

</E1EDP01>

so, basically, I have to split description into 70 characters if its more than 70 characters and assign to a new TDLINE field.

howz it doable?

thx

mike

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

Hi Michael,

you need to use UDF for this req. Please refer the UDF code given by Amit in below thread

regards,

Harish

Former Member
0 Kudos

Harish,

I am not really looking for splitting. Splitting can be done using standard function Node pool fragment single value but once split I am not sure now to assign the values to E1EDPT2 and TDLINE to repeat for each and every value and thats where I need help to be precise Should have made my ask clear before.

thx

mike

engswee
Active Contributor

Edit: Swapped E1EDPT1 and E1EDPT2 mapping

Hi Michael

Try the following UDF of type All Values of Queue. It has two output fields.


public void genText(String[] a, ResultList parent, ResultList line, Container container) throws StreamTransformationException {

  int limit = 70;

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

   if(a[i].equals(ResultList.CC)) {

    line.addContextChange();

    parent.addContextChange();

   } else {

    String text = a[i];

    while(!text.isEmpty()) {

     parent.addValue("");

     if(text.length() > limit) {    

      line.addValue(text.substring(0, limit));

      line.addContextChange();

      text = text.substring(limit);

     } else {

      line.addValue(text);

      break;

     }

    }

   }

  }

}

Following is the mapping logic for the E1EDPT1 E1EDPT2 and TDLINE fields.

Sample output (I've not included the other ORDERS05 fields)

Rgds

Eng Swee

Message was edited by: Eng Swee Yeoh

Former Member
0 Kudos

Hi Eng,

thanks a lot for the reply. But this is not exactly I want. I want all the description for the same item under one E1EDP01 node. With your UDF, it is adding context for each and every E1EDPT2 value which is not what I want. For the above example, I want all the description to come under same E1EDP01 node under multiple E1EDPT2 /TDLINE under a single E1EDPT1 node. Makes sense?

thx

mike

former_member184720
Active Contributor
0 Kudos

I think you just need to add remove context after the UDF when you map it E1EDPT2  segment.


Your mapping should be like this-


D_352 -> UDF -> Remove context ->E1EDPT2


D_352 -> UDF ->E1EDPT2/TDLINE






Former Member
0 Kudos

hi Harish,

The udf is written to add parent context (E1EDPT2) and if we remove the context for E1EDPT2, then it won't work properly because E1EDPT2 if it is assigned 2 null values for example before CC, it will repeat only 2 times instead of 3 times if the description is 2 and one of them is more than 70 characters. makes sense? And if we pass all the descriptin to E1EDPT2 without any context change, it will repeat more than 3 times when it was supposed to repeat only 3 times. This will create erroneous result.

thx

mike

Former Member
0 Kudos

Eng should be able to help is my hope. Any one else before Eng replies.

thx

mike

engswee
Active Contributor
0 Kudos

Mike

I was lazy and didn't get around to load a full 850 as the source structure, so couldn't really see the minor context difference.

The change is real easy, just comment out a line.

I didn't map the rest of the fields, but you should be able to take care of the rest.

Output

Rgds

Eng Swee

engswee
Active Contributor
0 Kudos

Actually wait. That does not work if there are more than one PO1. Give me a few minutes. I'll sort it out... Hahaha....

former_member184720
Active Contributor
0 Kudos

Ooops.. Deleted my reply.. just saw your reply and i see that both does same thing

Don't know logic for other header node's creation to give a try..

Message was edited by: Hareesh Gampa

Former Member
0 Kudos

yes hahaha

thx

mike

engswee
Active Contributor
0 Kudos

Ok this should be it, hopefully (crossing fingers!)

Change the execution type to "All Values of a Context"


  int limit = 70; 

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

    String text = a[i]; 

    while(!text.isEmpty()) { 

     parent.addValue(""); 

     if(text.length() > limit) {      

      line.addValue(text.substring(0, limit)); 

      text = text.substring(limit); 

     } else { 

      line.addValue(text); 

      break; 

     } 

    }  

  }

Slight changes to the mapping flow

- Change context of D_352 to L_PO1

- Add SplitByValue to second output of UDF before TDLINE

I've tested with two occurrences of L_PO1 and it should work fine.

Former Member
0 Kudos

Very neat Eng. I will test and mark it as correct answer soon. Appreciate your effort.

thx

mike

Former Member
0 Kudos

absolutely awesome. thanks a lot Eng. Wouldn't have done without your help.

thx

mike

engswee
Active Contributor
0 Kudos

Brilliant! Really glad to know that it's working. Glad to have been of assistance.

Former Member
0 Kudos

One thing I noticed while testing is it is pulling 70 characters but in the code it's substring (0, 70) right? that should be 71 chars or 70 chars?

thx

mike

engswee
Active Contributor
0 Kudos

substring(0,70) will get 70 characters. It will take from beginIndex to (endIndex - 1), refer to the following JavaDoc description of substring function.

String (Java Platform SE 7 )

Former Member
0 Kudos

thanks....

Answers (0)