<?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: Minor programming problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632057#M1282267</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;PRE&gt;&lt;CODE&gt;
US1        -field1
90          -field2
12/2009 -field3
1          -field4
3         -field5

Loop at it1.

read it2 with field1 field2 field3.
if sy-subrc = 0.
it2-field4  = it2-field4  + it1-field4  .
it2-field5  = it2-field5  + it1-field5  .
modify it2 from it2 transporting field4 field5 .
else.
move it1 to it2.
append it2 .
endif.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 May 2009 19:04:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-04T19:04:07Z</dc:date>
    <item>
      <title>Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632054#M1282264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello, i have written this piece of code in which I am taking the result data in to IT1 then I have to do the comparison and add my keyfigures for duplicate records and delete one of the duplicate records. I am not sure how to add my keyfigures for duplicated records and delete the duplicate record in WA_IT2. can someone help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: if i have the following records in WA_IT2, i want to combine those records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plant Division Calmonth Keyfigure1 Keyfigure2&lt;/P&gt;&lt;P&gt;US1 90 12/2009 1 2&lt;/P&gt;&lt;P&gt;US1 90 12/2009 1 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want it to look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;US1 90 12/2009 2 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT1 is my first internal table and WA_IT1 is work area for my first internal table&lt;/P&gt;&lt;P&gt;IT2 is my second interbal table and WA_IT2 is work area for my second internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND ls_target TO IT1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort IT1 by plant division calmonth.&lt;/P&gt;&lt;P&gt;CLEAR WA_IT2.&lt;/P&gt;&lt;P&gt;loop at IT1 INTO WA_IT1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if wa_IT2 is initial.&lt;/P&gt;&lt;P&gt;WA_IT2 = WA_IT1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****the first time the above code will execute because WA_IT2 will have nothing in it. The second time it will do the comparison which is as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;if WA_IT1-plant = WA_IT2-plant and&lt;/P&gt;&lt;P&gt;WA_IT1-division = WA_IT2-division and&lt;/P&gt;&lt;P&gt;WA_IT1-calmonth = WA_IT2-calmonth.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;add key figures.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;append WA_IT2 to et_target.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;append WA_IT2 to et_target.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 18:56:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632054#M1282264</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T18:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632055#M1282265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add the Key Figures of the Duplicate Records use COLLECT Statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To delete the Duplicate Records use Delete Adjacent Duplicates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 18:58:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632055#M1282265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T18:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632056#M1282266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks ajay, can you please add it in my code?i don't have any idea where and how to do this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 19:04:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632056#M1282266</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T19:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632057#M1282267</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;PRE&gt;&lt;CODE&gt;
US1        -field1
90          -field2
12/2009 -field3
1          -field4
3         -field5

Loop at it1.

read it2 with field1 field2 field3.
if sy-subrc = 0.
it2-field4  = it2-field4  + it1-field4  .
it2-field5  = it2-field5  + it1-field5  .
modify it2 from it2 transporting field4 field5 .
else.
move it1 to it2.
append it2 .
endif.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 19:04:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632057#M1282267</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T19:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632058#M1282268</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;To learn it....try by urself.........in case you are not able to do it.......we would help you out but first work on the given hints....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 19:07:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632058#M1282268</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T19:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632059#M1282269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plant Division Calmonth Keyfigure1 Keyfigure2&lt;/P&gt;&lt;P&gt;US1 90 12/2009 1 2&lt;/P&gt;&lt;P&gt;US1 90 12/2009 1 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want it to look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;US1 90 12/2009 2 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT1 is my first internal table and WA_IT1 is work area for my first internal table&lt;/P&gt;&lt;P&gt;IT2 is my second interbal table and WA_IT2 is work area for my second internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;APPEND ls_target TO it1.

SORT it1 BY plant division calmonth.
CLEAR wa_it2.
LOOP AT it1 INTO wa_it1.

  IF wa_it2 IS INITIAL.
    wa_it2 = wa_it1.

**** the first time the above code will execute because WA_IT2
**** will have nothing in it. The second time it will do the comparison which is as follows:

  ELSE.
    IF wa_it1-plant = wa_it2-plant AND
    wa_it1-division = wa_it2-division AND
    wa_it1-calmonth = wa_it2-calmonth.

      IF sy-subrc = 0

      COLLECT it2.
        DELETE ADJACENT DUPLICATES FROM it2 COMPARING plant division calmonth.

      ENDIF.


    ELSE.
      APPEND wa_it2 TO et_target.
    ENDIF.
  ENDIF.
ENDLOOP.
APPEND wa_it2 TO et_target.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Please format your code and use code tags to make it easier to read&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on May 4, 2009 5:09 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 19:15:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632059#M1282269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T19:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Minor programming problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632060#M1282270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If understood, you want group (SUM) of fields in the records. For this, use the command COLLECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or check the records one by one using loop (for example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adriano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2009 21:00:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/minor-programming-problem/m-p/5632060#M1282270</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-04T21:00:55Z</dc:date>
    </item>
  </channel>
</rss>

