cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC Segment scan mapping issue.

Former Member
0 Kudos

Hi Experts,

I am working on a Idoc to JDBC mapping and meet some issue. Here is the source strcture.  plant.

-<ZMARAM SEGMENT="1">

<MATNR>000000000001006960</MATNR>

<ERSDA>20100428</ERSDA>

<MTART>LG01</MTART>

<MATKL>003015</MATKL>

<ZMBEWM SEGMENT="1">

  <MATNR>0000087H5944</MATNR>

  <BWKEY>0154</BWKEY>

  <VERPR>0987</VERPR> </ZMBEWM> 

  </ZMBEWM>

  <ZMBEWM SEGMENT="1">

  <MATNR>0000087H5944</MATNR>

  <BWKEY>0112</BWKEY> <PEINH>1</PEINH>

  <VERPR>0987</VERPR> </ZMBEWM>

  <ZMARCM SEGMENT="1">

  <MATNR>0000087H5944</MATNR>

  <WERKS>0110</WERKS>

  <PSTAT>DEAVQ</PSTAT>

  <ZPLOC>CN01</ZPLOC>

  </ZMARCM>

  <ZMARCM SEGMENT="1">

  <MATNR>0000087H5944</MATNR>

  <WERKS>0112</WERKS>

  <PSTAT>DEAVQ</PSTAT>

  <ZPLOC>CN01</ZPLOC>

  </ZMARCM>

first we need to filter one segment ZMARCM with WERKS = XXXX and convert corresponding lines to JDBC line one by one. So we mappe the ZMARCM to JDBC corresponding table. but now we have a new requirement for get the corresponing filelds of ZMBEWM add to the same JDBC table by ZMBEWM-BWKEY = ZMARCM-WERKS. How to do this. My question is if we can get the right content from ZMBEWM using starnd funtion. If not do we need to using UDF to do this? How to write this code for scan the ZMBEWM one by one?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

U can check this UDF (hope i understood ur req. correctly):

Input: var1, var2, var3

Execution type: all values of a context

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

{

for(int j=0;j<var2.length;j++)

{

if(var2[j].equals(var1[i]))

{

result.addValue(var3[j]);

break;

}

}

}

Mapping:

WERKS--------\

BWKEY---------UDF -SplitByValue(Each Value) - Target Field

VPER-----------/

Do remember to change the context of all these fields and set it to "ZMARAM"

Thanks

Amit Srivastava

Thanks

Amit Srivastava

Answers (1)

Answers (1)

ambrish_mishra
Active Contributor
0 Kudos

Hi,

this is how you can do it with standard functions.

It seems you are using a custom IDoc for material master.

I assume ZMARCM and ZMBEWM are at the same level in the IDoc.

You are already applying a filter for ZMARCM-WERKS. I assume it is something like this

If ZMARCM-WERKS EQ 'X' -> create target row.

ZMBEWM segment has WERKS value in field BWKEY.

For the fields where you need information from ZMBEWM, simply map like below:

If ZMBEWM-BWKEY EQ 'X' map ZMBEWM-field---> ifWithoutElse -> MapWithDefault ->Target field

MapWithdefault is in case you want to populate a blank in target in case ZMBEWM-field value does not exist for the plant in play.

Hope it answers your question

Ambrish