cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping Context question

RafaelVieira
Active Participant
0 Kudos

Hi experts,

Trying to map IDoc to a JDBC structure, I'm facing the following situation:

Source structure:

   <IDOC BEGIN="1">
      <E1EDKA1 SEGMENT="1">
         <PARVW>RG</PARVW>
         <PARTN>805A</PARTN>
      </E1EDKA1>
      <E1EDKA1 SEGMENT="1">
         <PARVW>WE</PARVW>
         <PARTN>999A</PARTN>
      </E1EDKA1>
      <E1EDP01 SEGMENT="1">
         <POSEX>000010</POSEX>
         <E1EDPA1 SEGMENT="1">
            <PARVW>RG</PARVW>
            <PARTN>805B</PARTN>
         </E1EDPA1>
         <E1EDPA1 SEGMENT="1">
            <PARVW>WE</PARVW>
            <PARTN>999B</PARTN>
         </E1EDPA1>
      </E1EDP01>

Mapping:

[http://img695.imageshack.us/img695/3269/screenhunter011.png]

I expect the 999B as a result in the target field.

Why am I getting 805B instead?

Tks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The mapping link that you have provided is not accessible. However, as I understand from your post, you need to map the value of PARTN where PARVW is 'WE'.

If this is your requirement, use the If function along with mapWithDefault to ensure that the proper sequence is maintained.

Regards

Former Member
0 Kudos

Hi,

The link you provided is not working.

Please let me know if you are maintaining any conditions at target side (or) is it a one-to-one mapping.

However from your post I'm assuming that you are mapping PARTN field based on PARVW field.

If this is your usage then please use an If function in your mapping for the target field.

Thanks and Regards,

Prajwal Kumar

Answers (3)

Answers (3)

shweta_walaskar2
Contributor
0 Kudos

Hello again,

Sorry for the confusion.Please ignore my previous post .

As you have used E1EDP01 as a parameter to useOneAsMany function, I assumed that you are checking PARVW under E1EDKA1 segment.

I have checked the expected output value again (999B).

This means,you need to check for PARVW field under E1EDP01 segment and not under E1EDKA1 segment.

If this is the case,you don't need such a complicated mapping.

You can just have :

If(PARVW=WE) then PARTN mapped to ShipToNum

Context of PARVW and PARTN should be set to IDOC.

Please let us know if this works.

Thanks.

Best Regards,

Shweta

RafaelVieira
Active Participant
0 Kudos

Shweta, tks for ur reply.

However, the requirement is:

If E1EDP01-E1EDPA1-PARVW field exists, take the corresponding to 'WE' and then look for its corresponding PARTN (in the same context) to map to target field.

If it doesn't exists, take the E1EDKA1-PARVW = 'WE' and map its corresponding PARTN to target field.

With the mapping I provided in the screen shot above, the ELSE of the main IfElse condition is ok (when the E1EDP01-E1EDPA1-PARVW existence validation fails, the Else returns the corresponding PARTN from E1EDKA1 structure, which in my example is 999A).

But I'm still getting 805B instead of 999B.

Here are the steps queue details, if it helps:

[http://img37.imageshack.us/img37/8349/screenhunter019.png]

Appreciate any help.

RafaelVieira
Active Participant
0 Kudos

Any suggestion ?

RafaelVieira
Active Participant
0 Kudos

Hi,

can anyone suggest something?

Please, do not ignore the topic.

Is it required any other detail to better explain the question?

Tks.

Former Member
0 Kudos

Hi,

You can easily achieve this using a simple UDF (queue function) :

input parameters :

e1edpa1-parvw

e1edpa1-partn

e1edka1-parvw

e1edka1-partn

int flag = 0;
String retvalue = "";
for(int i=0;i<e1edpa1-parvw.length;i++){
   if(e1edpa1-parvw<i> == "WE"){
     retvalue = e1edpa1-partn<i>;
     flag = 1;
     break;
   }
}
if(flag == 0){
  for(int i=0;i<e1edka1-parvw.length;i++){
   if(e1edka1-parvw<i> == "WE"){
     retvalue = e1edka1-partn<i>;
     break;
   }
 }
}

result.addValue(retvalue);

You can enhance the udf using the search functions of arrays to eliminate the for loops.

Regards

Former Member
0 Kudos

Hello,

you don't need the ' exists' node . Try mapping the eqaulsS out straight to the 'if then else' input . Thanks.

RafaelVieira
Active Participant
0 Kudos

Shiladitya,

Are the input fields you mentioned really as a Parameter, instead of Arguments to the UDF?

As a parameter I cannot mapp the source fields to the UDF because it cannot create input fields.

Tried using them as Arguments in a new UDF (Exec. Type = Queue) but with NULL result being pushed in the output.

Any idea?

Also, is there any way of debug the java UDF?

Tks

Former Member
0 Kudos

Hi,

The input fields would need to be as arguments. sorry for the typo in the earlier post.

Also, ensure that all the four input fields do not have any context change in their input queues. For this, either keep the context of the inputs at the Idoc level or use the removeContext function before inserting the four input fields into the UDF.

Regards

RafaelVieira
Active Participant
0 Kudos

Shiladitya,

Did some adjusts when comparing the string arrays but it works.


   if(e1edpa1_parvw<i>.equalsIgnoreCase( v_WE)){
...
   if(e1edka1_parvw<i>.equalsIgnoreCase( v_WE)){
...

It works fine when we have both structures in the source side. When there's no EDPA1 structure, it fails.

I'm trying to check its existence before calling the UDF and will let you know the results (still not working).

Former Member
0 Kudos

One way to check for the existence of E1EDPA1 in the code would be :

if(e1edpa1-parvw.length > 0){

//the remaining logic of the for loop comes in here

}

RafaelVieira
Active Participant
0 Kudos

This UDF worked, but only when 1 source structure is being sent.

With more than 1, it's getting lost.

Solved by sending the parent node to an UDF, using the Return as XML property marked. Then, worked with the XML as text.

Tks.

shweta_walaskar2
Contributor
0 Kudos

Hello,

I was able to access the link:

Please perform following corrections:

1) Change Context of all PARVW and PARTN segments used to map this field to IDOC(Currently,these fields which are being passed to useOneAsMany function have context set to E1EDKA1) except PARVW = WE check passed to exists function.This PARVW should have context set to E1EDKA1

2) In Final IfThenElse, you are passing PARTN with context set to IDOC directly.

Please pass the same sequence with PARVW check (copy entire path which you are passing to removeContexts with context for PARVW and PARTN set to IDOC) in then .

(You anyway need to change context of these fields to IDOC which you are passing to removeContexts as mentioned in point 1)

I have tested it, this should produce shipToNum field with value 999B in your target structure.

Please let us know if this works for you.

Thanks.

Best Regards,

Shweta

Former Member
0 Kudos

Hi ,

Do u have any conditions to be satisfied before the value is sent to target and please provide the mapping requirement.

- Muru