<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reg  add internal table fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685666#M887516</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can execute another loop on the same internal table and write a logic to add the three required fields until there is a change of AUFNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: tempfield1 type i, tempfield2 type i, tempfield3 type i.
loop at &amp;lt;internal-table&amp;gt; into &amp;lt;workarea&amp;gt;.

tempfield1 = tempfield1 + workarea-field1.
tempfield2 = tempfield2 + workarea-field2.
tempfield3 = tempfield3 + workarea-field3.
on change of aufnr.
    move &amp;lt;tempfields&amp;gt; to &amp;lt;new internaltablefields&amp;gt;.
    clear: tempfield1, tempfield2, tempfield3.    
endon. 

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;reward points if this helps,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Kiran&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Apr 2008 10:45:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-21T10:45:53Z</dc:date>
    <item>
      <title>Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685656#M887506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i am having one internal table with following fields&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; bukrs,werks,kostl,arbpl,aufnr,gjahr,perio,tog001,wogtbr,megbtr  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  on this with changing of aufnr i need to add only tog001,wogbtr and megbtr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the record is as follows &lt;/P&gt;&lt;P&gt;Company Code	Plant	Cost.Centre	Work.Centre	Production.Order	Activity .Plan.Price	Total.Price	Total.Qty	Unit.of.measure&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007089	145.34	145.34	1.992	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007089	277.17	277.17	1.992	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007090	121.11	121.11	1.660	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007090	230.97	230.97	1.660	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007091	102.95	102.95	1.411	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007091	196.33	196.33	1.411	HR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; and i want the result as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Company Code	Plant	Cost.Centre	Work.Centre	Production.Order	Activity .Plan.Price	Total.Price	Total.Qty	Unit.of.measure&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007089	422.51	422.51	3.984	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007090	352.08	352.08	3.32	HR&lt;/P&gt;&lt;P&gt;1090	2001	10906092	APACKAGE	7007091	299.28	299.28	2.822	HR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please give the solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:22:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685656#M887506</guid>
      <dc:creator>mohan_subramania</dc:creator>
      <dc:date>2008-04-21T10:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685657#M887507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of appending to the internal table, you could try "collect into" to sum the numeric fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685657#M887507</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685658#M887508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Mohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Use COLLECT statement ...check out the below link for usage ...&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nwpi71/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nwpi71/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:26:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685658#M887508</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685659#M887509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;On change of AUFNR.&lt;/P&gt;&lt;P&gt; SUM.&lt;/P&gt;&lt;P&gt;ENDON.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:26:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685659#M887509</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685660#M887510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while appending the data into the internal table. &lt;/P&gt;&lt;P&gt;use COLLECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:29:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685660#M887510</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685661#M887511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;here i am getting the two price from two different selection and then append that into the final internal table.&lt;/P&gt;&lt;P&gt;so collect not working&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:34:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685661#M887511</guid>
      <dc:creator>mohan_subramania</dc:creator>
      <dc:date>2008-04-21T10:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685662#M887512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data sources shouldn't matter - why can't you fill a structure with the data from the various sources and "collect lst_my_data into gt_my_data" instead of "append lst_my_data to gt_my_data"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:37:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685662#M887512</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685663#M887513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Jonathan Coleman,&lt;/P&gt;&lt;P&gt;I dont think that COLLECT can be used..As the break-up will happen only on char fields for a collect...ok...so need to asssign that numeric value to a char for the same.&lt;/P&gt;&lt;P&gt;Reply if u note this..ok?&lt;/P&gt;&lt;P&gt;ullasuv @ yahoo . com&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:37:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685663#M887513</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685664#M887514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan,&lt;/P&gt;&lt;P&gt;first u get all the data into one internal table and then u use collect to move the data to final internal table.&lt;/P&gt;&lt;P&gt;here u need to use two internal tables. then it will be easy  i think so mohan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;reward if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;raam&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:38:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685664#M887514</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685665#M887515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear mohan,&lt;/P&gt;&lt;P&gt;there r 2 ways to achive this..&lt;/P&gt;&lt;P&gt;1. Use Collect. But u cannot use it as easily bcoz in COLLECT the break-up will happen on each char fields. So better u create 1 more field in ur internal table with char20,and assign this aufnr to this char field and can use COLLECT stmt.&lt;/P&gt;&lt;P&gt;2. By keeeping this aufnr and the structure of this internal table so..&lt;/P&gt;&lt;P&gt;At end of aufnr&lt;/P&gt;&lt;P&gt;  SUM&lt;/P&gt;&lt;P&gt;  wa_new_it-bukrs = wa_it-bukrs.&lt;/P&gt;&lt;P&gt;etc.....&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;wa_new_it-aufnr = wa_it-aufnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To achive the output;u need to declere 1 more internal table(say new_it and its work area wa_new_it.  ). here wa_it is the exiesting internal table u mentioned in ur query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:44:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685665#M887515</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685666#M887516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can execute another loop on the same internal table and write a logic to add the three required fields until there is a change of AUFNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: tempfield1 type i, tempfield2 type i, tempfield3 type i.
loop at &amp;lt;internal-table&amp;gt; into &amp;lt;workarea&amp;gt;.

tempfield1 = tempfield1 + workarea-field1.
tempfield2 = tempfield2 + workarea-field2.
tempfield3 = tempfield3 + workarea-field3.
on change of aufnr.
    move &amp;lt;tempfields&amp;gt; to &amp;lt;new internaltablefields&amp;gt;.
    clear: tempfield1, tempfield2, tempfield3.    
endon. 

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;reward points if this helps,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Kiran&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:45:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685666#M887516</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reg  add internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685667#M887517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA:
  BEGIN OF my_rec,
    bukrs         TYPE bukrs,
    werks         TYPE werks_d,
    kostl         TYPE kostl,
    arbpl(12)     TYPE c,
    aufnr         TYPE aufnr,
    gjahr         TYPE WRBTR,
*    perio         type GJAHR,
    tog001        TYPE WRBTR,
    wogtbr        TYPE WRBTR,
    megbtr(2)     TYPE c,
  END OF my_rec,
  my_rec_hold LIKE my_rec,
  it_tab1 LIKE STANDARD TABLE OF my_rec,
  it_tab2 LIKE STANDARD TABLE OF my_rec.

START-OF-SELECTION.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007089'.
  my_rec-gjahr = '145.34'.
  my_rec-tog001 = '145.34'.
  my_rec-wogtbr = '1.992'.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007089'.
  my_rec-gjahr = '277.17'.
  my_rec-tog001 = '277.17'.
  my_rec-wogtbr = '1.992'.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007090'.
  my_rec-gjahr = '121.11'.
  my_rec-tog001 = '121.11'.
  my_rec-wogtbr = '1.660'.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007090'.
  my_rec-gjahr = '230.97'.
  my_rec-tog001 = '230.97'.
  my_rec-wogtbr = '1.660'.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007091'.
  my_rec-gjahr = '102.95'.
  my_rec-tog001 = '102.95'.
  my_rec-wogtbr = '1.411 '.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  my_rec-bukrs = '1090'.
  my_rec-werks = '2010'.
  my_rec-kostl = '10906092'.
  my_rec-arbpl = 'APACKAGE'.
  my_rec-aufnr = '7007091'.
  my_rec-gjahr = '196.33'.
  my_rec-tog001 = '196.33'.
  my_rec-wogtbr = '1.411 '.
  my_rec-megbtr = 'HR'.
  APPEND my_rec TO it_tab1.

  CLEAR my_rec_hold.

  LOOP AT it_tab1 INTO my_rec.
    IF my_rec_hold IS INITIAL.
      my_rec_hold = my_rec.
      CONTINUE.
    ELSE.
      IF  my_rec_hold-bukrs EQ my_rec-bukrs
      AND my_rec_hold-werks EQ my_rec-werks
      AND my_rec_hold-kostl EQ my_rec-kostl
      AND my_rec_hold-bukrs EQ my_rec-bukrs
      AND my_rec_hold-aufnr EQ my_rec-aufnr
      AND my_rec_hold-megbtr EQ my_rec-megbtr.
        my_rec_hold-gjahr = my_rec_hold-gjahr + my_rec-gjahr.
        my_rec_hold-tog001 = my_rec_hold-tog001 + my_rec-tog001.
        my_rec_hold-wogtbr = my_rec_hold-wogtbr + my_rec-wogtbr.
      ELSE.
        APPEND my_rec_hold TO it_tab2.
        my_rec_hold = my_rec.
      ENDIF.
    ENDIF.
  ENDLOOP.
  APPEND my_rec_hold TO it_tab2.

  LOOP AT it_tab2 INTO my_rec.
    WRITE:/1 my_rec-bukrs,
           6 my_rec-werks,
           12 my_rec-kostl,
           25 my_rec-arbpl,
           40 my_rec-aufnr,
           55 my_rec-gjahr,
           70 my_rec-tog001,
           85 my_rec-wogtbr,
           105 my_rec-megbtr.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 10:52:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-add-internal-table-fields/m-p/3685667#M887517</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T10:52:44Z</dc:date>
    </item>
  </channel>
</rss>

