Skip to Content
0

UDF to check value in Queue

Oct 23, 2017 at 12:46 PM

58

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Evgeniy Kolmakov Oct 23, 2017 at 01:31 PM
1

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.


Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

udf.jpg (72.7 kB)
0
Mark Dihiansan Oct 25, 2017 at 08:14 AM
0

Hi Pankaj,

Can you try this mapping?

BETRG

QUALF

Test (without 004 on first line item)

with 004 on first line item

Regards,

Mark


betrg.png (47.2 kB)
qualf.png (46.9 kB)
test.png (27.5 kB)
test.png (27.9 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

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.

0

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

test.png (31.6 kB)
0
Evgeniy Kolmakov Oct 24, 2017 at 10:22 AM
0

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.


Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Evgeniy,

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

Regards,

Pankaj

0
avatar image
Former Member Oct 24, 2017 at 11:31 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

Regards, Evgeniy.

0