<?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: Code Inspector: DELETE statement Part 2 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/code-inspector-delete-statement-part-2/m-p/12164952#M1978413</link>
    <description>&lt;P&gt;&lt;STRONG&gt;DELETE Statement 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You are again transferring data from the database to the application server which you don't need. You SELECT the field ORDID and you eliminate duplicated entries right after. The SELECT statement can do exactly that directly in the database: SELECT DISTINCT ordid ...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE Statement 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you have a NW 7.40 or newer system please do not use the MOVE statement any more. The code is way more readable if the target is always on the left side and the source on the right side.&lt;BR /&gt;But to the problem: Actually you don't need the additional flag. As you don't need to do anything with the &amp;lt;fs_plaf&amp;gt; after setting the flag, you can delete the line from the internal table right away:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_plaf
ASSIGNING FIELD-SYMBOL(&amp;lt;fs_plaf&amp;gt;).

  READ TABLE lt_zmrp
  WITH KEY cno_order = &amp;lt;fs_plaf&amp;gt;-plnum+3(7)
  TRANSPORTING NO FIELDS.

  IF sy-subrc NE 0.
    DELETE lt_plaf.
  ENDIF.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Additionally I removed the data copying from the READ statement. You don't need the result so you can omit the data transfer.&lt;/P&gt;&lt;P&gt;The best way would be to never read those lines and do a join with the statement where lt_zmrp is read.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Mar 2020 16:26:31 GMT</pubDate>
    <dc:creator>BiberM</dc:creator>
    <dc:date>2020-03-09T16:26:31Z</dc:date>
    <item>
      <title>Code Inspector: DELETE statement Part 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/code-inspector-delete-statement-part-2/m-p/12164951#M1978412</link>
      <description>&lt;P&gt;I think I need to make a new thread. Thanks for the help with my previous quesiton.&lt;/P&gt;
  &lt;P&gt;I have two DELETE statements showing in code inspector. Why would it be a performance issue?&lt;/P&gt;
  &lt;P&gt;Any suggestions?&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;  SELECT ordid
    FROM /bmw/ts_1143_log AS a
   WHERE ordid IN @s_ordid
     AND order_comp_flag EQ @space
     AND
  EXISTS ( SELECT *
             FROM zmrp
            WHERE cno_order  EQ a~ordid
              AND cid_status IN @s_status
              AND cno_assyl  IN @s_assyl )
    INTO TABLE @gt_log.

  IF sy-subrc EQ 0.

    SORT gt_log
      BY ordid.

    DELETE ADJACENT DUPLICATES FROM gt_log
      COMPARING ordid ##CI_SORTED.

  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;and&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;  LOOP AT lt_plaf
    ASSIGNING FIELD-SYMBOL(&amp;lt;fs_plaf&amp;gt;).

    READ TABLE lt_zmrp
      INTO DATA(ls_zmrp)
      WITH KEY cno_order = &amp;lt;fs_plaf&amp;gt;-plnum+3(7).

    IF sy-subrc NE 0.
      MOVE abap_true TO &amp;lt;fs_plaf&amp;gt;-xdel .
    ENDIF.

  ENDLOOP.

  DELETE lt_plaf
    WHERE xdel EQ abap_true.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 15:59:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/code-inspector-delete-statement-part-2/m-p/12164951#M1978412</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-03-09T15:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Code Inspector: DELETE statement Part 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/code-inspector-delete-statement-part-2/m-p/12164952#M1978413</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DELETE Statement 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You are again transferring data from the database to the application server which you don't need. You SELECT the field ORDID and you eliminate duplicated entries right after. The SELECT statement can do exactly that directly in the database: SELECT DISTINCT ordid ...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE Statement 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you have a NW 7.40 or newer system please do not use the MOVE statement any more. The code is way more readable if the target is always on the left side and the source on the right side.&lt;BR /&gt;But to the problem: Actually you don't need the additional flag. As you don't need to do anything with the &amp;lt;fs_plaf&amp;gt; after setting the flag, you can delete the line from the internal table right away:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_plaf
ASSIGNING FIELD-SYMBOL(&amp;lt;fs_plaf&amp;gt;).

  READ TABLE lt_zmrp
  WITH KEY cno_order = &amp;lt;fs_plaf&amp;gt;-plnum+3(7)
  TRANSPORTING NO FIELDS.

  IF sy-subrc NE 0.
    DELETE lt_plaf.
  ENDIF.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Additionally I removed the data copying from the READ statement. You don't need the result so you can omit the data transfer.&lt;/P&gt;&lt;P&gt;The best way would be to never read those lines and do a join with the statement where lt_zmrp is read.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 16:26:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/code-inspector-delete-statement-part-2/m-p/12164952#M1978413</guid>
      <dc:creator>BiberM</dc:creator>
      <dc:date>2020-03-09T16:26:31Z</dc:date>
    </item>
  </channel>
</rss>

