Skip to Content

UDF Query

Hi,

Sender Message-

E1EDK21 segment will come N number of times in message.

E1EDK21 segment has 3 segments ORMNG,LFIMG and POSNR.

The condition is -

If [sum of all ORMNG segment] is equal to the [sum of all LFIMG with POSNR starting with '4' ] then CREATE Target Field EFIELD.

Can we achieve it using graphical message mapping. As I see sum of segments , i thought it can be achieved by UDF only. If so, please help in UDF for it.

Regards

Vijayant Jha

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 16, 2015 at 11:06 AM

    Hi,

    this can be achieve with graphical mapping

    first input of equals

    IF without else

    POSNR (on one context above) startwith (text function) '4'

    Then

    LFIMG


    After if without else output use SUM function


    second input of equals

    ORMNG (on one context above) --> Sum function


    the output of equals map to create if


    regards,

    Harish

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 16, 2015 at 01:25 PM

    Hello Vijayanth,

    You can use the below UDF for your requirement.

    I have a created a generic one for your above requirement.

    The execution type is : All values of Queue

    --UDF--

    public void createField(String[] ORMNG, String[] LFIMG, String[] POSNR, ResultList result, Container container) throws StreamTransformationException{
    AbstractTrace trace = container.getTrace();
    int additionORMNG=0;
    int additionLFIMG=0;
    for (int i=0; i<ORMNG.length;i++)
    {
    if (!ResultList.CC.equals(ORMNG[i]))
    {
      additionORMNG = additionORMNG + Integer.parseInt(ORMNG[i]);
    }
    }

    for (int j=0; j<LFIMG.length;j++)
    {
    if (!ResultList.CC.equals(LFIMG[j]))
    {
      trace.addInfo("POSNR"+POSNR[j].substring(0,1));
      if(POSNR[j].substring(0,1).equals("4"))
      {
       additionLFIMG= additionLFIMG+Integer.parseInt(LFIMG[j]);
      }
    }
    }
    trace.addInfo("additionORMNG"+additionORMNG);
    trace.addInfo("additionLFIMG"+additionLFIMG);
    if(additionORMNG==additionLFIMG)
    {
    result.addValue(" ");
    }
    else
    {
    result.addSuppress();
    }
    }

    -------------------------------------------------------------------

    Hope this helps you. 😊

    Regards,

    Satanik

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 19, 2015 at 01:49 PM

    Hello Vijayanth,

    Make sure there are no alphabets in the input values.

    The SUM function should work fine otherwise.

    Regards

    Sam

    Add comment
    10|10000 characters needed characters exceeded