<?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: Logic required for a Internal table  issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801756#M1467536</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;create another internal table itab2 with fields in following squence:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SERNP	STLNR       MATNR    FLAG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where flag is of type char1.move all data from your original internal table to itab2.then proceed as follows&lt;/P&gt;&lt;P&gt;sort  itab2 by sernp stlnr.&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;at new stlnr.&lt;/P&gt;&lt;P&gt;itab2-flag = 'X'.&lt;/P&gt;&lt;P&gt;modify itab2 transporting flag.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab2 where flag ne 'X'.&lt;/P&gt;&lt;P&gt;*do your calculation..&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Apr 2010 07:28:53 GMT</pubDate>
    <dc:creator>former_member188827</dc:creator>
    <dc:date>2010-04-09T07:28:53Z</dc:date>
    <item>
      <title>Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801755#M1467535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need a logic for my program, My internal table looks like below, I want to do one calucalation using my internal table. I need to check the STLNR and SERNP, if its comes once that suituvation no need todo any calculation, if its comes more then once (stlnr-15646 and 17203 comes more then once here )  then i need to take the particular records and i need to do another type of calculation.  Can anyone help this logic. How to seperate the repeated enteries?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MATNR	SERNP	STLNR
10Z0300	LX01	15637
10Z0305	LX01	15644
20G0279	LX01	15646
21J0484	LX01	15646
001575Y	LX01	16054
12L1000	LX01	17203
14N1092	LX01	17203
21Z0336	LX01	17203
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mohana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:21:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801755#M1467535</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-09T07:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801756#M1467536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;create another internal table itab2 with fields in following squence:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SERNP	STLNR       MATNR    FLAG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where flag is of type char1.move all data from your original internal table to itab2.then proceed as follows&lt;/P&gt;&lt;P&gt;sort  itab2 by sernp stlnr.&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;at new stlnr.&lt;/P&gt;&lt;P&gt;itab2-flag = 'X'.&lt;/P&gt;&lt;P&gt;modify itab2 transporting flag.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab2 where flag ne 'X'.&lt;/P&gt;&lt;P&gt;*do your calculation..&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:28:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801756#M1467536</guid>
      <dc:creator>former_member188827</dc:creator>
      <dc:date>2010-04-09T07:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801757#M1467537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi mohana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try as follows hope this helps&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data l_stlnr_count type i.
clear l_stlnr_count.

sort itab by sernp stlnr.
loop at sernp into wa_sernp.
l_stlnr_count = l_stlnr_count + 1.
at end of stlnr.
if l_stlnr_count &amp;gt; 1.
do your processing.
clear  l_stlnr_count,
endif.
endat..
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;tanmaya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:39:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801757#M1467537</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-09T07:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801758#M1467538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, One more alternate solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create new tab with columns stlnr, cnt.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop though exitsiting itab.
move-corresponding &amp;lt;wa&amp;gt; into &amp;lt;new wa&amp;gt;
move 1 to &amp;lt;new wa&amp;gt;-cnt.
collect &amp;lt;new wa&amp;gt; to &amp;lt;new itab&amp;gt;.
endloop.

loop through existing itab.
read table &amp;lt;new itab&amp;gt; into &amp;lt;new wa&amp;gt; with key sernp,stlnr.
if &amp;lt;new wa&amp;gt;-cnt gt 1.
 do process1.
else.
 do process 2.
endif.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;cnt = 0.
loop at itab into wa_itab.
  ON CHANGE OF stlnr
   if cnt &amp;gt; 1 
     do process 1.
   else
     do process 2.
   endif.
    cnt = 0.
  ENDON.
endloop.
   if cnt &amp;gt; 1 
     do process 1.
   else
     do process 2.
   endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vinod Kumar on Apr 9, 2010 1:17 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:41:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801758#M1467538</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-09T07:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801759#M1467539</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;Do not forget to sort the table on the basis of field on which you will use AT END OF or At NEW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change oyur internal table to the following format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	SERNP	STLNR        MATNR&lt;/P&gt;&lt;P&gt;	LX01	15637      10Z0300&lt;/P&gt;&lt;P&gt;	LX01	15644      10Z0305&lt;/P&gt;&lt;P&gt;	LX01	15646      20G0279&lt;/P&gt;&lt;P&gt;	LX01	15646     21J0484&lt;/P&gt;&lt;P&gt;	LX01	16054     001575Y&lt;/P&gt;&lt;P&gt;	LX01	17203     12L1000&lt;/P&gt;&lt;P&gt;	LX01	17203     14N1092&lt;/P&gt;&lt;P&gt;	LX01	17203     21Z0336&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_table DESCENDING BY sernp  stlnr.&lt;/P&gt;&lt;P&gt;    LOOP AT it_table  INTO wa_table.&lt;/P&gt;&lt;P&gt;      "Do something&lt;/P&gt;&lt;P&gt;      AT END OF STLNR.&lt;/P&gt;&lt;P&gt;        "count the number records&lt;/P&gt;&lt;P&gt;       " Now check if it is greater then one and put whatever logic you want&lt;/P&gt;&lt;P&gt;      ENDAT.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Rocky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:50:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801759#M1467539</guid>
      <dc:creator>Rocky1</dc:creator>
      <dc:date>2010-04-09T07:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801760#M1467540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try with the below steps.&lt;/P&gt;&lt;P&gt;1. Sort the internal table A (main) by SERNR and STLNR.&lt;/P&gt;&lt;P&gt;2. move the value into a local internal table B (type same of A).&lt;/P&gt;&lt;P&gt;3. delete adjacent duplcates from B comparing SERNR, STLNR.&lt;/P&gt;&lt;P&gt;4. loop at B into workarea.&lt;/P&gt;&lt;P&gt;5. read table A with key sernp = wa_B-sernp and stlnr =  wa_B-stlnr binary search transporting no fields.&lt;/P&gt;&lt;P&gt;6.if sy-subrc = 0. l_index = sy-tabix. &lt;/P&gt;&lt;P&gt;7. loop at A from l_index.&lt;/P&gt;&lt;P&gt;8. if wa_A-sernp =  wa_B-sernp and wa_A-stlnr =  wa_B-stlnr.&lt;/P&gt;&lt;P&gt;do the calculation.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;9. endloop A.&lt;/P&gt;&lt;P&gt;10. endif. "endif for sy-subrc&lt;/P&gt;&lt;P&gt;11. endloop B.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 07:59:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801760#M1467540</guid>
      <dc:creator>dibakar_balida</dc:creator>
      <dc:date>2010-04-09T07:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Logic required for a Internal table  issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801761#M1467541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let your below internal table be it_data with work area wa_data as the same structure as it_data.&lt;/P&gt;&lt;P&gt;Then you create another internal table with the same structure say it_data_copy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATNR	SERNP	STLNR&lt;/P&gt;&lt;P&gt;10Z0300	LX01	15637&lt;/P&gt;&lt;P&gt;10Z0305	LX01	15644&lt;/P&gt;&lt;P&gt;20G0279	LX01	15646&lt;/P&gt;&lt;P&gt;21J0484	LX01	15646&lt;/P&gt;&lt;P&gt;001575Y	LX01	16054&lt;/P&gt;&lt;P&gt;12L1000	LX01	17203&lt;/P&gt;&lt;P&gt;14N1092	LX01	17203&lt;/P&gt;&lt;P&gt;21Z0336	LX01	17203&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin of ty_stlnr,&lt;/P&gt;&lt;P&gt;            stlnr type STLNR,&lt;/P&gt;&lt;P&gt;           end of ty_stlnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : it_stlnr type table of ty_stlnr,&lt;/P&gt;&lt;P&gt;           wa_stlnr type ty_stlnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_data BY SERNP STLNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR : wa_data , wa_stlnr.&lt;/P&gt;&lt;P&gt;LOOP AT it_data INTO wa_data.&lt;/P&gt;&lt;P&gt;i_count = i_count+1.&lt;/P&gt;&lt;P&gt;AT END OF STLNR.&lt;/P&gt;&lt;P&gt;IF i_count GT 1.&lt;/P&gt;&lt;P&gt;wa_stlnr-stlnr = wa_data-stlnr.&lt;/P&gt;&lt;P&gt;APPEND wa_stlnr TO it_stlnr.&lt;/P&gt;&lt;P&gt;CLEAR wa_stlnr.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;i_count = 0.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;CLEAR wa_data.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="7" type="ul"&gt;&lt;P&gt;now it_stlnr contains the stlnr of the duplicate entries.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR : wa_data , wa_stlnr.&lt;/P&gt;&lt;P&gt;LOOP AT it_data INTO wa_data.&lt;/P&gt;&lt;P&gt;READ TABLE it_stlnr into wa_stlnr with key stlnr = wa_data-STLNR.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC EQ 0.&lt;/P&gt;&lt;P&gt;APPEND wa_data TO it_data_copy.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CLEAR : wa_data , wa_stlnr.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="7" type="ul"&gt;&lt;P&gt;it_data_copy now contains only the duplicate entries of it_data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the above piece of code should deliver you the desired result...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 10:52:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-required-for-a-internal-table-issue/m-p/6801761#M1467541</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-09T10:52:10Z</dc:date>
    </item>
  </channel>
</rss>

