cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to check value in Queue

Former Member
0 Kudos

Hello Gurus,

I have following requirement:

In the Invoice IDoc, there are multiple E1EDP01 segments with many E1EDP26 sub segments. This segment has different QUALF and BETRG fields. Now, if there exist a qualifier with value 004, I need to pass the corresponding BTERG field value in output. But, if there is no qualifier with 004, I need to pass the value of BETRG with QUALF 002.

Issue: This is not possible with standard functions.

Could you please help with UDF for this.

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member190293
Active Contributor

Hi Pankaj!

Issue: This is not possible with standard functions.

Really? 🙂

QUALF and BETRG are in E1EDP01 context in both cases.

Or if you want to use UDF:

public void getConditionalValue(String valueToCheck, String valueToCheckIfNotFound, String[] queueToCheck, String[] queueToReturn, ResultList result, Container container) throws StreamTransformationException {
String retValue = ""; String retValueNotFound = ""; for (int i = 0; i < queueToCheck.length; i++) { if (queueToCheck[i].trim().equals(valueToCheck)) { retValue = queueToReturn[i].trim(); break; } else if (queueToCheck[i].trim().equals(valueToCheckIfNotFound)) retValueNotFound = queueToReturn[i].trim(); } result.addValue(!retValue.isEmpty() ? retValue : retValueNotFound);
}

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evgeniy,

Thanks for the help!. But the output is not what is desired.

1. The mapping with standard functions works fine when both the Qualifiers 004 and 002 exist. But not when 004 does not exist, output is blank.

2. Using UDF also, I am getting a blank output for both the scenarios.

Screenshots attached.

From the screenshots, in a single line Item, if the value qualifier 004 exist, BTERG of 004 need to be sent, else BTERG of 002 needs to be sent.

Hope this clarifies.

Thanks,

Pankaj

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Pankaj,

Can you try this mapping?

BETRG

QUALF

Test (without 004 on first line item)

with 004 on first line item

Regards,

Mark

former_member190293
Active Contributor
0 Kudos

Hi Mark!

And what is the result if neither "004" nor "002" qualifier exists for E1EDP01? I mean, for one or several of the multiple E1EDP01 segments? That's why I used MapWithDefault. Doesn't element's count in outbound queue goes wrong in such case?

Regards, Evgeniy.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Evgeniy,

It will output a blank. The collapse context just after the ifWithoutElse will insert an empty value when the input is SUPPRESS.

Regards,

Mark

Former Member
0 Kudos

Hi Evgeniy,

BTERG is required for each E1EDP01 segment. Any reason that you see why I am receiving blank values in output. As shown in screenshots.

Thanks,

Pankaj

former_member190293
Active Contributor
0 Kudos

The only difference I see in case of using standard functions is that you used "IfS" instead of "If".

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

Hi Pankaj!

If you could see from provided result screenshot, implementations worked in both cases right the way you described (ID - standard functions, Qty - UDF). So it looks strange especially in case of UDF.

One question: do you need the BETRG value for each E1EDP01 segment or the single value for all E1EDP01 segments?

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evgeniy,

Thanks for your help! yes IF worked. I was using IFS earlier.

Regards,

Pankaj