cancel
Showing results for 
Search instead for 
Did you mean: 

mapping problem with coupled PO1 segments

Former Member
0 Kudos

The following idoc message is being processed:

- <E1EDP01 SEGMENT="1">

<POSEX>00011</POSEX>

<ACTION>001</ACTION>

<PSTYP>0</PSTYP>

<MENGE>1.000</MENGE>

<MENEE>PCE</MENEE>

<BMNG2>1.000</BMNG2>

<PMENE>PCE</PMENE>

<PEINH>1</PEINH>

<GEWEI>KGM</GEWEI>

<MATKL>79</MATKL>

<UEPOS>00010</UEPOS>

<BPUMN>1</BPUMN>

<BPUMZ>1</BPUMZ>

<BRGEW>0.7</BRGEW>

<WERKS>DC01</WERKS>

<LGORT>CD01</LGORT>

- <E1EDP20 SEGMENT="1">

<WMENG>1.000</WMENG>

<AMENG>0.000</AMENG>

<EDATU>20050302</EDATU>

</E1EDP20>

- <E1EDP19 SEGMENT="1">

<QUALF>002</QUALF>

<IDTNR>0017400</IDTNR>

</E1EDP19>

- <E1EDP19 SEGMENT="1">

<QUALF>001</QUALF>

<IDTNR>000000000000001683</IDTNR>

<KTEXT>PHILIPS HQ100 T</KTEXT>

</E1EDP19>

- <E1EDP19 SEGMENT="1">

<QUALF>003</QUALF>

<IDTNR>8710103083351</IDTNR>

</E1EDP19>

</E1EDP01>

- <E1EDP01 SEGMENT="1">

<POSEX>1</POSEX>

<UEPOS>00011</UEPOS>

<MATNR>000000000000001683</MATNR>

- <E1ADDI1 SEGMENT="1">

<ADDIMATNR>SERVICE_PREPACK</ADDIMATNR>

<ADDINUMBER>1.000</ADDINUMBER>

<ADDIVKME>PCE</ADDIVKME>

<ADDIFM>0005</ADDIFM>

<ADDIFM_TXT>SLS: transito-picken</ADDIFM_TXT>

</E1ADDI1>

- <E1EDPA1 SEGMENT="1">

<PARVW>SLS</PARVW>

<PARTN>0000000004</PARTN>

<NAME1>Osdorp 04</NAME1>

<NAME4>0000000004</NAME4>

<STRAS>Osdorpplein 138</STRAS>

<ORT01>Amsterdam</ORT01>

<PSTLZ>1068 EN</PSTLZ>

<LAND1>NL</LAND1>

<SPRAS>N</SPRAS>

<SPRAS_ISO>NL</SPRAS_ISO>

</E1EDPA1>

- <E1EDP19 SEGMENT="1">

<QUALF>017</QUALF>

<IDTNR>0001</IDTNR>

</E1EDP19>

</E1EDP01>

- <E1EDP01 SEGMENT="1">

<POSEX>00012</POSEX>

<ACTION>001</ACTION>

<PSTYP>0</PSTYP>

<MENGE>1.000</MENGE>

<MENEE>PCE</MENEE>

<BMNG2>1.000</BMNG2>

<PMENE>PCE</PMENE>

<PEINH>1</PEINH>

<GEWEI>KGM</GEWEI>

<MATKL>79</MATKL>

<UEPOS>00010</UEPOS>

<BPUMN>1</BPUMN>

<BPUMZ>1</BPUMZ>

<BRGEW>0.7</BRGEW>

<WERKS>DC01</WERKS>

<LGORT>CD01</LGORT>

- <E1EDP20 SEGMENT="1">

<WMENG>1.000</WMENG>

<AMENG>0.000</AMENG>

<EDATU>20050302</EDATU>

</E1EDP20>

- <E1EDP19 SEGMENT="1">

<QUALF>002</QUALF>

<IDTNR>0017400</IDTNR>

</E1EDP19>

- <E1EDP19 SEGMENT="1">

<QUALF>001</QUALF>

<IDTNR>000000000000001683</IDTNR>

<KTEXT>PHILIPS HQ100 T</KTEXT>

</E1EDP19>

- <E1EDP19 SEGMENT="1">

<QUALF>003</QUALF>

<IDTNR>8710103083351</IDTNR>

</E1EDP19>

</E1EDP01>

- <E1EDP01 SEGMENT="1">

<POSEX>1</POSEX>

<UEPOS>00012</UEPOS>

<MATNR>000000000000001683</MATNR>

- <E1ADDI1 SEGMENT="1">

<ADDIMATNR>SERVICE_PREPACK</ADDIMATNR>

<ADDINUMBER>1.000</ADDINUMBER>

<ADDIVKME>PCE</ADDIVKME>

<ADDIFM>0005</ADDIFM>

<ADDIFM_TXT>SLS: transito-picken</ADDIFM_TXT>

</E1ADDI1>

- <E1EDPA1 SEGMENT="1">

<PARVW>SLS</PARVW>

<PARTN>0000000022</PARTN>

<NAME1>Amersfoort 22</NAME1>

<NAME4>0000000022</NAME4>

<STRAS>Amsterdamseweg 8-1-</STRAS>

<ORT01>Amersfoort</ORT01>

<PSTLZ>3812 RS</PSTLZ>

<LAND1>NL</LAND1>

<SPRAS>N</SPRAS>

<SPRAS_ISO>NL</SPRAS_ISO>

</E1EDPA1>

- <E1EDP19 SEGMENT="1">

<QUALF>017</QUALF>

<IDTNR>0001</IDTNR>

</E1EDP19>

</E1EDP01>

Every position has data in two PO1 segments. The first one is referenced in the second one by the UEPOS field. In our mapping we want to create a record in a flat file when such a couple is existing in the idoc.

In my mapping I create a record in the flat file when the first segment is being found. At the second PO1 segment the record is not being written (exactly as wanted). Nevertheless I need to map a field out of the second PO1 segment to the flat file (a field in the PA1 segment), except I cannot access the field from the second segment in the first record. I should I do this??? Working with contexts isn't helping me neither.

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

When it is just one field you need, then you can do this easily with a user-defined function.

Which field do you want to extract from the second P01?

Regards

Stefan

Former Member
0 Kudos

Thanks for your answer. I already started creating a user defined function, but it doesn't do the job at the moment. I think I need to do something like this:

String SecondPO = (String) a[i+1];

result.addValue(SecondPO);

I want to map the field PARTN in the PA1 segment of the second PO1 segment. This field should only be mapped when the PARVW field has the value "SLS" (So if PARVW=SLS then PARTN is mapped).

- <E1EDPA1 SEGMENT="1">

<PARVW>SLS</PARVW>

<PARTN>0000000004</PARTN>

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

In your example only every second line has the PA1 segment. Is this common? In this case you can easily map PARVW to your target field without any restrictions.

If your source has more than one PA1 segment, you have to use a little more complex if statement to get the correct SLS address:

 
        PARVW  
               equalS  
Constant(SLS) /        if*  
                PARTN /     formatByExample - partn 
                   E1EDPA1 / 

(*) In the if statement you have to set the mark keepss = true.

This is only possible with SP13 and above, as the formatByExample does not exist earlier.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan,

Indeed this graphical mapping should be used. So far so good. Nevertheless my problem is that for the first PO1 segment a record is being created and the second PO1 segment is ignored on segment level. Therefore the field of the second segment cannot be linked to the first segment(the queues don't correspond). I think we should use a user defined function for this. How should we do this?

regards,

Mark

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

How do you map the P01 to the target to make sure that the second row is ignored? How does the target look like?

In the graphical mapping tool a structure is not ignored in total. Every queue is considered alone.

Regards

Stefan

Former Member
0 Kudos

The target looks like:

Document

RDCSOC

RDTREA

RDFIL1

RDNCDE

RDNLIG

RDPROD

RDQTE

RDCUST

RDARTC

RDFIL2

The PA1 field is filled in the RDCUST field. The document segment is being created with the following graphical mapping:

ACTION - exists - createif - removecontexts - DOCUMENT

The ACTION field is only present in the first PO1 segment. Therefore the second PO1 segment doesn't create a document segment.

stefan_grube
Active Contributor
0 Kudos

I could not find a solution without user-defined function (maybe any combination with useOneAsMany).

When you use a createIf then you have to provide a queue with values for each line. When you just link PARTN to any target field, your queue looks like this:

--

4

CC

22

--

Your queue should look like this:

--

4

CC

anyValue

CC

22

CC

anyValue

--

The additional line will be ignored, as the second P01 line is mark by a suppress.

This user defined function will give a solution:

for (int k=0; k<a.length; k++){
 result.addValue(a[k]);
 result.addValue("");
}

The for loop is not necessary in your case, but it makes the function more generic.

You map like follows:

PARTN - YourFunction - splitByValue - Target

Regards

Stefan

Former Member
0 Kudos

We need to use a user defined function. I'm sure now, except the code for the function is the problem.

the queue before the user defined function is:

grey

any value

grey

0000000004

grey

any value

grey

0000000022

darkgrey

When I use your code I get the following result queue:

grey

any value

empty value

grey

emtpy value

00000000004

empty value

grey

empty value

any value

empty value

grey

empty value

00000000022

empty value

dark grey

In stead of the queue above, we need the following result queue, I think:

grey

0000000004

grey

any value

grey

0000000022

grey

any value

darkgrey

How could we achieve this?

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

are you working with the same input structure as provided in the thread? The P01 occurs 4 times, the PARTN only 2 times. The next point is the context of PARTN. In my example I set the context to PA1 (default) this works.

If your input is different to that in the thread, post it exactly the way it is.

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

Here is the code to convert

grey
any value
grey
0000000004
grey
any value
grey
0000000022
darkgrey

into

grey
0000000004
grey
any value
grey
0000000022
grey
any value
darkgrey

You have to cache the whole queue:

boolean first = true; 

for (int k=0; k<a.length;k++)
  if ( ! a[k].equals(ResultList.CC))
    if (first)
      first = false;
    else {
      first = true;
      result.addValue(a[k]);
      result.addContextChange();
      result.addValue("");
      if  (k<a.length-1)
        result.addContextChange();
     } 

This works only, if the line comes strictly in pairs.

Hope that hepls,

Stefan

stefan_grube
Active Contributor
0 Kudos

Here a more generic approach which allows empty contexts:

int state = 1;

for (int k=0; k<a.length;k++)
     if (state == 1){
       if (a[k].equals(ResultList.CC))
        state = 2;
      }  else if (state == 2){
          state = 3;
          result.addValue(a[k]);
          result.addContextChange();
          result.addValue("");
          if  (k<a.length-1)
            result.addContextChange();
       }  else if (state == 3){
             if (a[k].equals(ResultList.CC))
               state = 1;
      }

Former Member
0 Kudos

Hi Stefan,

The two pieces of java code do the job quite well! I did a test with a few PO1 segments and it worked fine for that message. Thanks for your effort.

Now I did a test with a large message with a lot of PO1 segments and I found a inregularity. It looks like not every PO1 segment has a referencing PO1 segment. I think we need to check the UEPOS field of the second PO1 segment. This will be a big issue, I think? Do you have any idea how I could solve this? Maybe an extra parameter for the User defined funtion?

stefan_grube
Active Contributor
0 Kudos

Hi Mark,

Indeed this makes it very complicated.

Check, if this IDOC is valid, when the PARTN is missing.

If you need to create a differetn user-defined function, this blog might help you:

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

Regards

Stefan

Answers (1)

Answers (1)

moorthy
Active Contributor
0 Kudos

Hi,

This you can easily do with User Defined Function..

Hope this helps..

Regards,

Moorthy