cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Queues mismatch for E1EDP01 -> E1EDP05-KSCHL -KPERC

Former Member
0 Kudos

Hi Mapping Gurus,

I have an issue with UDF queues, I am really not good as of the momment with queues and arrays that's why I am seeking your help.

I have a mapping IDoc to FILE (fixed field); each row in the file will be generated for every IDoc item (1 row generated for every E1EDP01)

One target field in the row has a validation as follows:

If E1EDP05-KSCHL = VALUE1; then map -KPERC field of that E1EDP05's occurence to target field.

I can not achieve this with Standarad Functions only.

I encounter mismatch in the number of queues

For example I have one IDoc with seven E1EDP01, "each" having 4 E1EDP05 in it; "all" E1EDP05 has field KSCHL but only one has VALUE1; "not all" E1EDP05 has the field KPERC in it.

As you can see, there is already a mismatch in the number of queues between E1EDP05-KSCHL, E1EDP05-KPERC, and E1EDP01.

So if I have One IDoc with seven E1EDP01 having four E1EDP05 in it with having the VALUE1 on the second occurence of E1EDP05 on the second occurence of E1EDP01, my resulting file should consists of:

7 ROWS

on the 2nd ROW, the value of KPERC from the corresponding E1EDP05-KSCHL occurence will be mapped

While for the 1st, 3rd, 4th, 5th, 6th, 7th rows the field will be field with space.

***Previously I had a simple validation performed on this field, and it is populated in the correct ROW of the corresponding occurence of the E1EDP01 segment and for validation = false I have padded it with space successfully.

***The issue only arises on my new validation because of the mismatch in the queues thereby wrong value/context is being mapped

Given the requirement above, can someone provide me a UDF code wherein the UDF will take the occurrence of the KSCHL=VALUE1, determine on what occurrence of E1EDP01 it is, and map the corresponding KPERC value to the corresponding ROW

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Rahul,

Thanks for your replies, but the code you gave didn't solved it.

The whole point of my question was to achieve this requirement using 1 mapping step only.

I am running out of time to find the solution, so I decided to use a 2 step mapping, which almost readily solved the issue by mapWithDefault([]) to KPERC in 1st mapping step, this way on the second mapping step KPERC queue has the same # of queues of KSCHL already, instantly solved by that.

Thanks all for your time

RKothari
Contributor
0 Kudos

Hi,

Please try below UDF Code

int i;

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

if(KSCHL<i>.equals("VALUE1") )

{

result.addValue(""+KPERC<i>);

}

else

{

result.addValue(" ");

}

}

Regards,

Rahul

Former Member
0 Kudos

Hi Rahul,

I tried your code but it is not working

Reason, is your code's output queue is following the context of KSCHL

Again, my requirement is to follow the context of E1EDP01 containing an E1EDP05 that has the field KSCHL = VALUE1 and the corresponding KPERC value of it

RKothari
Contributor
0 Kudos

Hi,

What I understand from your requirement is that for the E1EDP01-E1EDP05-KSCHL = VALUE1 corresponding KPERC should go in the output file Else a blank should be sent.

Keep the context of KSCHL and KPERC at E1EDP01 and provide as input to below UDF Code.

int i; 
for(i=0;i<KSCHL.length;i++){
if(KSCHL<i>.equals("VALUE1") )
{
result.addValue(""+KPERC<i>);
}
}

Pass output of the udf to mapWithDefault(" ").

KSCHL and KPERC --> UDF --> mapWithDefault(" ") --> Target

Regards,

Rahul

Former Member
0 Kudos

Hi,

Can you please post the source code of the udf ?

Thanks,

Horia

Former Member
0 Kudos

Hi,

There is no UDF yet.

The working solution previously was using Standard Functions only (combination of boolean & node functions & a UDF to pad spaces if validation returns false) --> this is for the simple validation

But as I have said we have a complex validation now described in my post above, and the previous combinations of Standard Functions only are not outputting my requirement, That is why I am considering a UDF to handle this complex validation (not the padding of spaces)

Former Member
0 Kudos

hi,

you can do that with standard functions.

just keep the context at the lowest level, map with default and after that redo the context by using formatbyexample.

but it could be that a udf works