Skip to Content
avatar image
Former Member

Dynamically count the field

I have a scenario where the target field of one idoc segment should get populated ie. field should count how many other different segments are generated in the target.for example

segment A comes to 2 times then say field of segment C should be 2 in the target

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Aug 17, 2007 at 02:40 PM

    Guha,

    Could you give the sample input/output payload? It could be easy for us to suggest.

    Best regards,

    raj.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Map your E1EDK01 segment with "Count" node function and to the target side field you want to catch value.

      Don't forget to set Context of E1EdK01 to IDOC.

      Regards,

      Akshay.

      • Also dont forget to give points 😉

  • avatar image
    Former Member
    Aug 17, 2007 at 02:46 PM

    Arijit,

    You can use the function "Count" here....assign "A" as input to function count..it will return you number of "A" segments in payload.

    Nilesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 02:55 PM

    You can use the following UDF's for increment and initialisation of the counter

    Increment the Global Variable Counter

    public String incrementCounter(String a,Container container){

    //write your code here

    if(a.equals(" "))

    {

    Object o = container.getGlobalContainer().getParameter("CNTR");

    Integer ii;

    if( o == null ) ii = new Integer(0);

    else ii = (Integer)o;

    ii = new Integer( ii.intValue() + 1);

    container.getGlobalContainer().setParameter("CNTR", ii);

    String temp = ii.toString();

    return temp;

    }

    else return " ";

    <b>Intialise the Counter</b>

    Object o = container.getGlobalContainer().getParameter("CNTR");

    Integer ii = new Integer(0);;

    container.getGlobalContainer().setParameter("CNTR", ii);

    return "1";

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 01, 2007 at 01:30 PM

    Hi Guys thanks for the answers.

    Add comment
    10|10000 characters needed characters exceeded