<?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: dbcnt in a loop. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358864#M1233632</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you should try what I have written it is faster than any nested loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise the your loop has still the same problem as before, it is logically incorrect in the&lt;/P&gt;&lt;P&gt;order:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You must process the new table completely, not the output table!&lt;/P&gt;&lt;P&gt;And it is weird to input into loop table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
   SORT it_output BY eindt edt.

LOOP AT itab INTO wa.
   READ TABLE it_output
             TREANSPORTING NO FIELDS
             WITH KEY eindt = wa-eindt
                              eindt = wa-edt.
              BINARY SEARCH.
    idx = sy-tabix.
   IF ( SY-SUBRC eq 0 ).
      MODIFY it_output FROM wa INDEX idx.
   ELSE.
      INSERT wa INTO it_output INDEX idx
   ENDIF

ENDLOOP:
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please check the variable names,  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Mar 2009 07:49:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-25T07:49:17Z</dc:date>
    <item>
      <title>dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358858#M1233626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a loop the following select query is there , &lt;/P&gt;&lt;P&gt;Now I would like to get this out of loop , when I do that then how can I check dbcnt  on a read statement.&lt;/P&gt;&lt;P&gt;LOOP AT it_output.&lt;/P&gt;&lt;P&gt;    SELECT t&lt;SUB&gt;eindt s&lt;/SUB&gt;eindt&lt;/P&gt;&lt;P&gt;    INTO (it_output-eindt , it_output-edt)&lt;/P&gt;&lt;P&gt;    FROM eket AS t&lt;/P&gt;&lt;P&gt;    LEFT JOIN ekes AS s&lt;/P&gt;&lt;P&gt;    ON s&lt;SUB&gt;ebeln = t&lt;/SUB&gt;ebeln AND&lt;/P&gt;&lt;P&gt;       s&lt;SUB&gt;ebelp = t&lt;/SUB&gt;ebelp AND&lt;/P&gt;&lt;P&gt;       s~ebtyp = 'AB'&lt;/P&gt;&lt;P&gt;    WHERE t~ebeln = it_output-ebeln&lt;/P&gt;&lt;P&gt;     AND  t~ebelp = it_output-ebelp.&lt;/P&gt;&lt;P&gt;      IF sy-dbcnt = 1.&lt;/P&gt;&lt;P&gt;        MODIFY it_output.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        INSERT it_output.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDSELECT.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;Please suggest me whether this can be possible .&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 15:54:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358858#M1233626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T15:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358859#M1233627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you should first make sure of your logic. Why are you trying to insert a record into a table when it is unchanged? Why are you trying to insert a record into a table that you are looping at?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 16:02:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358859#M1233627</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T16:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358860#M1233628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this coding is very weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the sy-dbcnt is set by the select - endselect loop and not by the loop on the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the idea to insert lines into the table which is used in the loop is highly dangerous.&lt;/P&gt;&lt;P&gt;I am quite sure that you can create endless loops with that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if your on a basis newer than 6.10, then you can insert directly into the table which is &lt;/P&gt;&lt;P&gt;used in the FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this one, maybe it works. I know that it works in general but not every detail. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT t~eindt as eindt s~eindt as endt
             INTO INTO CORRESPONDINg FIELDS OF TABLE it_output
             FROM eket AS t
             LEFT JOIN ekes AS s
             ON s~ebeln = t~ebeln AND
             s~ebelp = t~ebelp AND
             s~ebtyp = 'AB'
             FOR ALL ENTRIES IN it_output.
             WHERE t~ebeln = it_output-ebeln
            AND t~ebelp = it_output-ebelp.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 16:24:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358860#M1233628</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T16:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358861#M1233629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is the following solution is right.&lt;/P&gt;&lt;P&gt;data: dbcnt type sy-dbcnt.      &lt;/P&gt;&lt;P&gt;if not it_output is initial.&lt;/P&gt;&lt;P&gt; SELECT t&lt;SUB&gt;eindt s&lt;/SUB&gt;eindt&lt;/P&gt;&lt;P&gt;    INTO table it_11 &lt;/P&gt;&lt;P&gt;    FROM eket AS t&lt;/P&gt;&lt;P&gt;    LEFT JOIN ekes AS s&lt;/P&gt;&lt;P&gt;    ON s&lt;SUB&gt;ebeln = t&lt;/SUB&gt;ebeln AND&lt;/P&gt;&lt;P&gt;       s&lt;SUB&gt;ebelp = t&lt;/SUB&gt;ebelp AND&lt;/P&gt;&lt;P&gt;       s~ebtyp = 'AB'&lt;/P&gt;&lt;P&gt;    WHERE t~ebeln = it_output-ebeln&lt;/P&gt;&lt;P&gt;     AND  t~ebelp = it_output-ebelp.&lt;/P&gt;&lt;P&gt;      if sy-dbcnt = 1.&lt;/P&gt;&lt;P&gt;        dbcnt = 1.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_output.&lt;/P&gt;&lt;P&gt;read table it_11 into wa_it11 with key ebeln =  it_output-ebeln &lt;/P&gt;&lt;P&gt;                                        ebelp = it_output-ebelp.&lt;/P&gt;&lt;P&gt;     if sy-subrc = 0 and dbcnt =1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        MODIFY it_output.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        INSERT it_output.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is this going to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 16:34:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358861#M1233629</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T16:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358862#M1233630</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;Is this something related to you early post ??&lt;/P&gt;&lt;P&gt;I think that what you asked is this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_xpto ASSIGNING &amp;lt;fs_xpto&amp;gt;
                   WITH KEY mblnr = (your mblnr value)
                            mjahr = (your mjahr value)
                   BINARY SEARCH.
IF sy-subrc EQ 0.   "&amp;lt;-- cheking the result of READ
  * exist on lt_xpto... so MODIFY
ELSE.
  * doesn't exist on lt_xpto... so INSERT
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please considerar a code review, since if you are changing your code to fill a internal table, doesn't make sense update one by one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Fernando Da Ros&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 16:35:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358862#M1233630</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T16:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358863#M1233631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need to use the sy-dbcnt.&lt;/P&gt;&lt;P&gt;In your code, after READ you also need to change the values of lt_output, before insert or modify.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something is strange in your code... FAE lt_output.... and want's to save on lt_output ?!?!?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Fernando Ros on Mar 24, 2009 5:39 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Fernando Ros on Mar 24, 2009 5:43 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 16:38:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358863#M1233631</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T16:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358864#M1233632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you should try what I have written it is faster than any nested loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise the your loop has still the same problem as before, it is logically incorrect in the&lt;/P&gt;&lt;P&gt;order:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You must process the new table completely, not the output table!&lt;/P&gt;&lt;P&gt;And it is weird to input into loop table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
   SORT it_output BY eindt edt.

LOOP AT itab INTO wa.
   READ TABLE it_output
             TREANSPORTING NO FIELDS
             WITH KEY eindt = wa-eindt
                              eindt = wa-edt.
              BINARY SEARCH.
    idx = sy-tabix.
   IF ( SY-SUBRC eq 0 ).
      MODIFY it_output FROM wa INDEX idx.
   ELSE.
      INSERT wa INTO it_output INDEX idx
   ENDIF

ENDLOOP:
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please check the variable names,  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 07:49:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358864#M1233632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-25T07:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358865#M1233633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ameer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this is what you are trying to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. You have an internal table it_output that has 2 fields to be populated from the eket and ekes tables viz. it_output-eindt and it_output-edt respectively&lt;/P&gt;&lt;P&gt;2. If the database table join returns more than one entries ... the it_output table needs to have one entry for every corresponding database result and that is why you try to insert the new records in the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the above is true ... this is why you cannot do what is written above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. eindt and edt values are not available in your it_output table yet!!! &lt;/P&gt;&lt;P&gt;2. Besides when you try to read from it_output or the other table with the keys as eindt and edt ... they are dates and they can very well repeat for the different combinations of ebeln and ebelp!!!!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just use the index as mentioned and do this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************************************************************************&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ls_eket_ekes,&lt;/P&gt;&lt;P&gt;   ebeln TYPE eket-ebeln,&lt;/P&gt;&lt;P&gt;  ebelp TYPE eket-ebelp,&lt;/P&gt;&lt;P&gt;  eindt TYPE eket-eindt,&lt;/P&gt;&lt;P&gt;  edt TYPE ekes-eindt,&lt;/P&gt;&lt;P&gt;      END OF ls_eket_ekes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lt_eket_ekes LIKE SORTED TABLE OF ls_eket_ekes with non-unique key ebeln ebelp .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**this will be your select statement to read from the database&lt;/P&gt;&lt;P&gt;SELECT t~ebeln&lt;/P&gt;&lt;P&gt;       t~ebelp&lt;/P&gt;&lt;P&gt;       t~eindt&lt;/P&gt;&lt;P&gt;       s~eindt AS edt&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE lt_eket_ekes&lt;/P&gt;&lt;P&gt;  FROM eket AS t&lt;/P&gt;&lt;P&gt;  LEFT JOIN ekes AS s&lt;/P&gt;&lt;P&gt;  ON t&lt;SUB&gt;ebeln EQ s&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;  AND t&lt;SUB&gt;ebelp EQ s&lt;/SUB&gt;ebelp&lt;/P&gt;&lt;P&gt;  AND s~ebtyp EQ 'AB'&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN it_output&lt;/P&gt;&lt;P&gt;  WHERE t~ebeln EQ it_output-ebeln&lt;/P&gt;&lt;P&gt;    AND t~ebelp EQ it_output-ebelp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**Now do this to move data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lv_first TYPE flag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_output by ebeln ebelp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_eket_ekes INTO ls_eket_ekes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  AT NEW ebelp.&lt;/P&gt;&lt;P&gt;    lv_first = 'X'.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF lv_first EQ 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE it_output&lt;/P&gt;&lt;P&gt;      WITH KEY ebeln = ls_eket_ekes-ebeln&lt;/P&gt;&lt;P&gt;               ebelp = ls_eket_ekes-ebelp&lt;/P&gt;&lt;P&gt;      BINARY SEARCH.&lt;/P&gt;&lt;P&gt;    idx = sy-tabix.&lt;/P&gt;&lt;P&gt;    IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      it_output-eindt = ls_eket_ekes-eindt.&lt;/P&gt;&lt;P&gt;      it_output-edt = ls_eket_ekes-edt.&lt;/P&gt;&lt;P&gt;      MODIFY it_output&lt;/P&gt;&lt;P&gt; TRANSPORTING eindt edt      &lt;/P&gt;&lt;P&gt;      index idx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR lv_first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    it_output-eindt = ls_eket_ekes-eindt.&lt;/P&gt;&lt;P&gt;    it_output-edt = ls_eket_ekes-edt.&lt;/P&gt;&lt;P&gt;    insert it_output index idx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this works!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Saika&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Saika Shaikh on Mar 26, 2009 9:40 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 19:31:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358865#M1233633</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-25T19:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: dbcnt in a loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358866#M1233634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no, that is not what I have written!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your coding is again full of bugs. Why don't you just follow what I have written, if you don't know&lt;/P&gt;&lt;P&gt;much about ABAP programming of internal tables. I don't understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table it_output is sorted otherwise the BINARY SEARCH does not work properly.&lt;/P&gt;&lt;P&gt;=&amp;gt; APPEND is forbidden !!!!!!!!!!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The MODIFY WHERE is the second big bug. It loop over the whole table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You must use the two operations with index, as I have written !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And forget the last SORT, the table is sorted once, and must stay sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simplify the whole thing by using a sorted table for it_output, if possible.&lt;/P&gt;&lt;P&gt;Then yon can't does anything wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2009 09:36:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dbcnt-in-a-loop/m-p/5358866#M1233634</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-26T09:36:22Z</dc:date>
    </item>
  </channel>
</rss>

