<?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 Select Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/3198410#M762185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abapers,&lt;/P&gt;&lt;P&gt;There is a select query inside a loop below is the logic:&lt;/P&gt;&lt;P&gt;selct-options:s_vbeln for vbrk-vbeln&lt;/P&gt;&lt;P&gt;                            no-display.&lt;/P&gt;&lt;P&gt;select tknum exti1 exti2 dpabf upabf from vttk into table i_vttk&lt;/P&gt;&lt;P&gt;             where exti1 in r_exti1 and       " = P_EXTI1 AND&lt;/P&gt;&lt;P&gt;                   exti2 in r_exti2.          " = P_EXTI2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select tknum vbeln from vttp into table i_vttp&lt;/P&gt;&lt;P&gt;             for all entries in i_vttk&lt;/P&gt;&lt;P&gt;             where tknum = i_vttk-tknum.&lt;/P&gt;&lt;P&gt;        if s_vbeln is initial.&lt;/P&gt;&lt;P&gt;          loop at i_vttp.&lt;/P&gt;&lt;P&gt;            select vbelv vbeln into (vbfa-vbelv, vbfa-vbeln)&lt;/P&gt;&lt;P&gt;                     from vbfa where vbelv = i_vttp-vbeln and&lt;/P&gt;&lt;P&gt;                                 vbtyp_n = 'U'.       "ProForma Invoice&lt;/P&gt;&lt;P&gt;              s_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;              s_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;              s_vbeln-low    = vbfa-vbeln.&lt;/P&gt;&lt;P&gt;              collect s_vbeln.&lt;/P&gt;&lt;P&gt;            endselect.&lt;/P&gt;&lt;P&gt;          endloop.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have replaced this code by using below logic , could someone help me out is this, is it  right or any modifications need to be done:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR  :i_vttp.&lt;/P&gt;&lt;P&gt;        REFRESH:i_vttp.&lt;/P&gt;&lt;P&gt;        IF NOT i_vttk[] IS INITIAL.&lt;/P&gt;&lt;P&gt;          SELECT tknum&lt;/P&gt;&lt;P&gt;                 tpnum&lt;/P&gt;&lt;P&gt;                 vbeln&lt;/P&gt;&lt;P&gt;                 INTO TABLE i_vttp&lt;/P&gt;&lt;P&gt;                 FROM vttp&lt;/P&gt;&lt;P&gt;                 FOR ALL ENTRIES IN i_vttk&lt;/P&gt;&lt;P&gt;                 WHERE tknum = i_vttk-tknum.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;        IF NOT i_vttp[] IS INITIAL.&lt;/P&gt;&lt;P&gt;          SELECT vbelv&lt;/P&gt;&lt;P&gt;                 posnv&lt;/P&gt;&lt;P&gt;                 vbeln&lt;/P&gt;&lt;P&gt;                 posnn&lt;/P&gt;&lt;P&gt;                 vbtyp_n&lt;/P&gt;&lt;P&gt;              INTO TABLE gt_vbfa1&lt;/P&gt;&lt;P&gt;                    FROM vbfa&lt;/P&gt;&lt;P&gt;                    FOR ALL ENTRIES IN i_vttp&lt;/P&gt;&lt;P&gt;                    WHERE vbelv   = i_vttp-vbeln&lt;/P&gt;&lt;P&gt;                    AND   vbtyp_n = gc_vbtyp_n.           "ProForma Invoice&lt;/P&gt;&lt;P&gt;          IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;            SORT gt_vbfa1 BY vbelv.&lt;/P&gt;&lt;P&gt;            LOOP AT gt_vbfa1 INTO gk_vbfa1 WHERE vbelv = i_vttp-vbeln AND&lt;/P&gt;&lt;P&gt;                                                     vbtyp_n = gc_vbtyp_n.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              s_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;              s_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;              s_vbeln-low    = gk_vbfa1-vbeln.&lt;/P&gt;&lt;P&gt;              COLLECT s_vbeln.&lt;/P&gt;&lt;P&gt;              CLEAR:gk_vbfa1.&lt;/P&gt;&lt;P&gt;            ENDLOOP.&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;&lt;/P&gt;&lt;P&gt;Please do the needful, its quite urgent.&lt;/P&gt;&lt;P&gt;Regards/Thanks,&lt;/P&gt;&lt;P&gt;Rizwana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Dec 2007 08:25:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-12-12T08:25:18Z</dc:date>
    <item>
      <title>Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/3198410#M762185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abapers,&lt;/P&gt;&lt;P&gt;There is a select query inside a loop below is the logic:&lt;/P&gt;&lt;P&gt;selct-options:s_vbeln for vbrk-vbeln&lt;/P&gt;&lt;P&gt;                            no-display.&lt;/P&gt;&lt;P&gt;select tknum exti1 exti2 dpabf upabf from vttk into table i_vttk&lt;/P&gt;&lt;P&gt;             where exti1 in r_exti1 and       " = P_EXTI1 AND&lt;/P&gt;&lt;P&gt;                   exti2 in r_exti2.          " = P_EXTI2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select tknum vbeln from vttp into table i_vttp&lt;/P&gt;&lt;P&gt;             for all entries in i_vttk&lt;/P&gt;&lt;P&gt;             where tknum = i_vttk-tknum.&lt;/P&gt;&lt;P&gt;        if s_vbeln is initial.&lt;/P&gt;&lt;P&gt;          loop at i_vttp.&lt;/P&gt;&lt;P&gt;            select vbelv vbeln into (vbfa-vbelv, vbfa-vbeln)&lt;/P&gt;&lt;P&gt;                     from vbfa where vbelv = i_vttp-vbeln and&lt;/P&gt;&lt;P&gt;                                 vbtyp_n = 'U'.       "ProForma Invoice&lt;/P&gt;&lt;P&gt;              s_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;              s_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;              s_vbeln-low    = vbfa-vbeln.&lt;/P&gt;&lt;P&gt;              collect s_vbeln.&lt;/P&gt;&lt;P&gt;            endselect.&lt;/P&gt;&lt;P&gt;          endloop.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have replaced this code by using below logic , could someone help me out is this, is it  right or any modifications need to be done:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR  :i_vttp.&lt;/P&gt;&lt;P&gt;        REFRESH:i_vttp.&lt;/P&gt;&lt;P&gt;        IF NOT i_vttk[] IS INITIAL.&lt;/P&gt;&lt;P&gt;          SELECT tknum&lt;/P&gt;&lt;P&gt;                 tpnum&lt;/P&gt;&lt;P&gt;                 vbeln&lt;/P&gt;&lt;P&gt;                 INTO TABLE i_vttp&lt;/P&gt;&lt;P&gt;                 FROM vttp&lt;/P&gt;&lt;P&gt;                 FOR ALL ENTRIES IN i_vttk&lt;/P&gt;&lt;P&gt;                 WHERE tknum = i_vttk-tknum.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;        IF NOT i_vttp[] IS INITIAL.&lt;/P&gt;&lt;P&gt;          SELECT vbelv&lt;/P&gt;&lt;P&gt;                 posnv&lt;/P&gt;&lt;P&gt;                 vbeln&lt;/P&gt;&lt;P&gt;                 posnn&lt;/P&gt;&lt;P&gt;                 vbtyp_n&lt;/P&gt;&lt;P&gt;              INTO TABLE gt_vbfa1&lt;/P&gt;&lt;P&gt;                    FROM vbfa&lt;/P&gt;&lt;P&gt;                    FOR ALL ENTRIES IN i_vttp&lt;/P&gt;&lt;P&gt;                    WHERE vbelv   = i_vttp-vbeln&lt;/P&gt;&lt;P&gt;                    AND   vbtyp_n = gc_vbtyp_n.           "ProForma Invoice&lt;/P&gt;&lt;P&gt;          IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;            SORT gt_vbfa1 BY vbelv.&lt;/P&gt;&lt;P&gt;            LOOP AT gt_vbfa1 INTO gk_vbfa1 WHERE vbelv = i_vttp-vbeln AND&lt;/P&gt;&lt;P&gt;                                                     vbtyp_n = gc_vbtyp_n.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              s_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;              s_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;              s_vbeln-low    = gk_vbfa1-vbeln.&lt;/P&gt;&lt;P&gt;              COLLECT s_vbeln.&lt;/P&gt;&lt;P&gt;              CLEAR:gk_vbfa1.&lt;/P&gt;&lt;P&gt;            ENDLOOP.&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;&lt;/P&gt;&lt;P&gt;Please do the needful, its quite urgent.&lt;/P&gt;&lt;P&gt;Regards/Thanks,&lt;/P&gt;&lt;P&gt;Rizwana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 08:25:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/3198410#M762185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T08:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/3198411#M762186</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;It is fine. Now you need to use Read statements inside the loop to get the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 08:30:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/3198411#M762186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T08:30:18Z</dc:date>
    </item>
  </channel>
</rss>

