Skip to Content
avatar image
Former Member

UDF to check value in Queue

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 23, 2017 at 01:31 PM

    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.

    Add comment
    10|10000 characters needed 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)
  • Oct 25, 2017 at 08:14 AM

    Hi Pankaj,

    Can you try this mapping?

    BETRG

    QUALF

    Test (without 004 on first line item)

    with 004 on first line item

    Regards,

    Mark

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 24, 2017 at 10:22 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

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

    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

    Add comment
    10|10000 characters needed characters exceeded