cancel
Showing results for 
Search instead for 
Did you mean: 

PI mapping

Former Member
0 Kudos

Hi,

I am looking for help in mapping.

I have IDOC ( SHPMNT05 ) to file. While creating shipment we have created Z text and user enters the value

In IDOC, under -<E1TXTH6 SEGMENT="1">we get the value TDID ( shown as ZPT1)

<TDOBJECT>VTTK</TDOBJECTP

<TDOBNAME>0004013669</TDOBNAME>

<TDID>ZPT1</TDID>

<TDSPRAS>E</TDSPRAS>

<LANGUA_ISO>EN</LANGUA_ISO>

-<E1TXTP6 SEGMENT="1">

<TDFORMAT>*</TDFORMAT>

<TDLINE>81014167,81014168</TDLINE

Now in target i am mapping this to another segment E1EDK33-GESZTD

Till now i am was mapping GESZTD fields as for ZPT1 as 1 and for ZPT2 as 2...up to ZPT9 for 9 ( last no of value)

Business wants this to reverse this..

ZPT9 has to be mapped to 1 and ZPT1 has to 9..

The no of ZPT* are not fixed.. In IDOC ,we can get  ZPT1, 2 up to 9 or none, as user can enter any text or up to 9 text  or nothing..

How can i achieve this reverse logic ( i guess by UDF)

Please advice.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Techie,

do you just want to change the order of the TDID-values, or some other fields along with them?

Regards,

Thomas

Former Member
0 Kudos

Hi Thomas,

This is my current mapping

For E1EDK33 segment

For GESZTD

In this, i am settling the ZST(x) to x where x can be from 1 to 9.

For e.g. ZST1 is 1 and ZST9 would be 9

Going forward, I would like to reverse this, where ZST9 would be 1 and ZST1 would be 9.

The issue is I don't know how many of ZST* would come as it is based on text entered by used.

It can be all 9 or none. So For e.g ZST(y) would be x  where y is max and x is 1

Please advice on this mapping.

former_member182412
Active Contributor
0 Kudos

Hi Techie,

If the values coming in a sequence, means ZPT1, ZPT2 ...ZPT9 then use below mapping.


public void mapGESZTD(String[] tdid, ResultList result, Container container) {

  for (int i = tdid.length - 1; i > -1; i--) {

  result.addValue(tdid[i].replace("ZPT", ""));

  }

  }

Test:

Regards,

Praveen.

Former Member
0 Kudos

Hi Techie,

i see you are stripping the TDID of the letters, so you only have numeric values. In that case, why not just use the node-function "sort"?

Otherwise, see Praveens post for an example UDF.

Regards,

Thomas

Former Member
0 Kudos

Thank for UDF. I just did the same

And source XML

Got the target as

Am i doing something wrong, as the order is same and i am looking for reverse

Thxs

former_member182412
Active Contributor
0 Kudos

Hi Techie,

UDF execution type should be All Values Of Queue instead of All Values Of Context.

Regards,

Praveen.

Former Member
0 Kudos

Hi. I tried with SORT approach and still getting same results

And getting same results as with UDF

I am looking for reverse  57 being 1 and 53 being 3.. Please advice, if anything wrong with these.

Source data is

Thxs

Answers (1)

Answers (1)

former_member190293
Active Contributor
0 Kudos

Hi Techie!

As far as now you get values 1..9 for your target field, the very "lazy" way is just to insert standard function FixValues where you can set new value for each of your 1..9 values.

Regards, Evgeniy.

Former Member
0 Kudos

Thanks for reply.

I thought of that option.. However my ZPT1 to ZPT9 are dynamic.. If user enter only 3 text elements,maximum no set is ZPT1 to 3 ..  So the logic would be, to set ZPT3 to 1 and so on..

If it is ZPT5, then 5 would go to 1.. However if there are text up to 9.. then ZPT9 should be 1 instead of ZPT5..User is free to enter up to 9 text all optional..

Having fixed value would not serve the purpose as it will always put fix values..

One of the logic i am thinking is , would be to first collect all ZPT* and find out which is the largest no ( 1 to 9) Set the largest to 1  then increment/decrements the rest of this..

I guess this would need some complex UDF for which i need help..

former_member190293
Active Contributor
0 Kudos

Try to use logic like:

(Max(Value) + 1) - Value.

This also can be done by using standard functions only.

Regards, Evgeniy.