<?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: Read statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092153#M1181964</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, now I got your point. I wrote my previous post just to say that your READ will only return the first match for your specified key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the only connection between your two tables is only tknum that repeats in second table, i can only see the delete solution that was presented by Avinash. But now I make a question. Is it possible to have 5 lines in first table for one tknum and only four in the second for that tknum? If yes, you will have to repeat at least one vbeln (4 vbelns for 5 lines in first table). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isn't there another field to connect the two tables to know that this vbeln corresponds to that line (not the first vbeln to the first line, the second vbeln to the second line, and so on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Valter Oliveira&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 01 Feb 2009 14:53:49 GMT</pubDate>
    <dc:creator>valter_oliveira</dc:creator>
    <dc:date>2009-02-01T14:53:49Z</dc:date>
    <item>
      <title>Read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092149#M1181960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the bellow code the Read statement is reading the first record from gt_ship into lw_ship as the TKNUM same for all the 4 different  VBELN. As a result I am getting  same VBELN,same time(LFDAT) and same time(LFUHR) in the out put.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The gt_stage has the following TKNUM      TSNUM TSRFO ADRNRZ fields&lt;/P&gt;&lt;P&gt;gt_ship has the fields CROSS TKNUM       VBELN        LFDAT      LFUHR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I modify my read statement to read all the records from gt_ship to lw_ship?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT gt_stage_aux.&lt;/P&gt;&lt;P&gt;    CLEAR: lt_vtsp. REFRESH: lt_vtsp.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Begin of Insertion ITF06646-DV 20-1-2009 ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;      CLEAR LW_SHIP.&lt;/P&gt;&lt;P&gt;    READ TABLE gt_ship WITH KEY tknum = gt_stage_aux-tknum&lt;/P&gt;&lt;P&gt;                                cross = 'X'&lt;/P&gt;&lt;P&gt;                                INTO lw_ship.&lt;/P&gt;&lt;P&gt;      if not lw_ship-cross is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING lw_ship TO gt_stage.&lt;/P&gt;&lt;P&gt;      gt_stage-tsnum = gt_stage_aux-tsnum.&lt;/P&gt;&lt;P&gt;      gt_stage-tsrfo = gt_stage_aux-tsrfo.&lt;/P&gt;&lt;P&gt;      gt_stage-adrnrz = gt_stage_aux-adrnrz.&lt;/P&gt;&lt;P&gt;      APPEND gt_stage.&lt;/P&gt;&lt;P&gt;      CLEAR GT_STAGE.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDLOOP.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      CLEAR LW_SHIP.&lt;/P&gt;&lt;P&gt;       READ TABLE gt_ship WITH KEY tknum = gt_stage_aux-tknum&lt;/P&gt;&lt;P&gt;                                   CROSS = ' '&lt;/P&gt;&lt;P&gt;                                INTO lw_ship.&lt;/P&gt;&lt;P&gt;   IF lw_ship-cross is initial AND SY-SUBRC = 0.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;End of Insertion ITF06646-DV ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;    SELECT * FROM vtsp INTO TABLE lt_vtsp&lt;/P&gt;&lt;P&gt;    WHERE tknum = gt_stage_aux-tknum&lt;/P&gt;&lt;P&gt;      AND tsnum = gt_stage_aux-tsnum.&lt;/P&gt;&lt;P&gt;          LOOP AT lt_vtsp.&lt;/P&gt;&lt;P&gt;      CLEAR l_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      SELECT SINGLE vbeln INTO l_vbeln&lt;/P&gt;&lt;P&gt;      FROM vttp&lt;/P&gt;&lt;P&gt;      WHERE tknum = lt_vtsp-tknum&lt;/P&gt;&lt;P&gt;        AND tpnum = lt_vtsp-tpnum.&lt;/P&gt;&lt;P&gt;        CLEAR LW_SHIP.&lt;/P&gt;&lt;P&gt;      READ TABLE gt_ship WITH KEY vbeln = l_vbeln INTO lw_ship.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING lw_ship TO gt_stage.&lt;/P&gt;&lt;P&gt;      gt_stage-tsnum = gt_stage_aux-tsnum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Begin of insertion ITF03468-110107-PR&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      gt_stage-tsrfo = gt_stage_aux-tsrfo.&lt;/P&gt;&lt;P&gt;      gt_stage-adrnrz = gt_stage_aux-adrnrz.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;End of insertion ITF03468-110107-PR&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      APPEND gt_stage.&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;    ENDIF.  "ITF-06646 20.1.2009 DV&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Feb 2009 12:31:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092149#M1181960</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-01T12:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092150#M1181961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Must use a LOOP instead of a READ, like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT gt_ship INTO lw_ship 
               WHERE tknum = gt_stage_aux-tknum
                 AND cross = 'X'.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Feb 2009 12:33:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092150#M1181961</guid>
      <dc:creator>valter_oliveira</dc:creator>
      <dc:date>2009-02-01T12:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092151#M1181962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i want to read 1 record at a time of gt_ship into lw_ship for 1 record of gt_stage_aux.1st rec to 1st record,2nd record to second record....like that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Feb 2009 12:57:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092151#M1181962</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-01T12:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092152#M1181963</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 way..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lt_ship [] = gt_ship [].
LOOP AT gt_stage_aux.
CLEAR: lt_vtsp. REFRESH: lt_vtsp.

CLEAR LW_SHIP.
READ TABLE gt_ship WITH KEY tknum = gt_stage_aux-tknum
cross = 'X'
INTO lw_ship.
if not lw_ship-cross is initial.
Delete gt_ship index sy-tabix.     "      Add this line this will delete the read line 
MOVE-CORRESPONDING lw_ship TO gt_stage.
gt_stage-tsnum = gt_stage_aux-tsnum.
gt_stage-tsrfo = gt_stage_aux-tsrfo.
gt_stage-adrnrz = gt_stage_aux-adrnrz.
APPEND gt_stage.
CLEAR GT_STAGE.

ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the other way which is specified by Valter Oliveira.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Avinash Kodarapu on Feb 1, 2009 7:25 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Feb 2009 13:55:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092152#M1181963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-01T13:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092153#M1181964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, now I got your point. I wrote my previous post just to say that your READ will only return the first match for your specified key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the only connection between your two tables is only tknum that repeats in second table, i can only see the delete solution that was presented by Avinash. But now I make a question. Is it possible to have 5 lines in first table for one tknum and only four in the second for that tknum? If yes, you will have to repeat at least one vbeln (4 vbelns for 5 lines in first table). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isn't there another field to connect the two tables to know that this vbeln corresponds to that line (not the first vbeln to the first line, the second vbeln to the second line, and so on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Valter Oliveira&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Feb 2009 14:53:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/5092153#M1181964</guid>
      <dc:creator>valter_oliveira</dc:creator>
      <dc:date>2009-02-01T14:53:49Z</dc:date>
    </item>
  </channel>
</rss>

