Skip to Content
avatar image
Former Member

RE: How to group data from file on to IDOC Header & Line Item based on 2 fields

Hello!! All

Need your help on the below:

I have a FILE to IDOC senario and need to group the data on the file to post IDOC based on data grouped by two fields (unique combication of Carton # & Order #).

Carton# ShipDate Quantity Prepacks Order#

1          12/22/013    10         450         101

1          12/22/013    20         200         102

1          12/22/013    30         100         103

2          12/27/013    10         100         201

2          12/27/013    20         200         202

1          12/28/013    10         500         105

The above needs to post 3 IDOC's as once you group by Carton # & Date you have 3 combinations

IDOC # 1

Header

Carton # 1         Ship Date - 12/22/013

With 3 Line Items

10 (Quantity)

20 (Quantity)

30 (Quantity)

IDOC # 2

Header

Carton # 2          Ship Date - 12/27/013

With 2 Line Items

10 (Quantity)

20 (Quantity)

IDOC # 3

Header

Carton # 1          Ship Date - 12/28/013

With 1 Line Items

10 (Quantity)

Can you please help on how this can be achieved - best approach in a graphical mapping ?!

Your help is greatly apprecaited!!

Thank you,

Ritu

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 19, 2013 at 02:21 PM

    Hi Ritu

    It's easy. First you have to do a content conversion in file sender adapter.

    Converting Text Format in the Sender File/FTP Adapter to XML - Configuring the File/FTP Adapter in Integration Directory…

    Then modify the idoc schema to allow to create more than one idoc

    When you upload the standard schema of an IDoc, you have to modify it. When

    referencing the element IDoc, the occurrence has to be changed from maxOccurs=”1” to

    maxOccurs=”unbounded”, as explained in SAP Note 814393

    Apply graphical mapping order by Carton contenated ( text / concat function) with ShipDate.

    Regards

    Javi


    Captura.JPG (14.6 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2013 at 03:50 PM

    Hey! Javier, Harish

    Thank you so much for your inputs - definetly very helpful & might work out!!

    ALSO, there is one additional requirement which got added - there is a limitation to have the Line Items restricted to 999 on the IDOC - In this case - I am told that we need to split the Line Items on a 2nd IDOC ... Any idea how this can achieved.

    Also, there will be some quanity values which I might have to aggregate on the first IDOC which I will have to carry over to the next IDOC.

    So, basically here are the 2 challenges I have:

    1. IDOC need to be restricted to '999' & the remainig Line Items need to be carried over to the 2nd IDOC.

    2. Additionally I need to aggregate the total Quantity related to a particular file and put it a separate field - still gettin the aggregate logic/requirement ironed out - However, how do i carry values from the first IDOC on to the 2nd IDOC ... whenever I encounter the scenario where there is possibility of Line Items exceeding 999 & I am slitting the file in to 2 or more IDOC's ....

    Appreciate all the help & going through the requirement details above!!

    Thanks again,

    Ritu

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ritu,

      try the modified code as context UDF

      int count = 0;
      Integer temp;
      try
      { temp = Integer.parseInt(input[i]); }
      catch (Exception e)
      { result.addValue(e); }

      if(temp>0)
      count = temp/999;
      else
      count = 1;

      for(int i=0;i<count;i++)
      result.addValue("true");

      for the addition requirement of quantity you can modify the code like below. you need to provide second input quantity with remove context.

      int count = 0, sum = 0,temp = 0, lin=0;

      try
      { temp = Integer.parseInt(input[0]); }
      catch (Exception e)
      { result.addValue(e); }

      if(temp>0)
      count = temp / 999;
      else
      count = 1;

      for(int j=0;j<quantity.length;j++)
      {sum = sum + Integer.parseInt(quantity[j]);
      lin = lin+1;
      if(lin==999)
      { lin = 0;
      if(sum>1000)
        { count = count+1;}
      sum=0;} }

      for(int i=0;i<count;i++)
      result.addValue("true");

      regards,

      Harish