<?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: Subquery with internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224189#M1379594</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Advait,&lt;/P&gt;&lt;P&gt;i tried for all entries before but the problem in all entries that it compare the values of row by row. and this is not what i wanted i want the query to get the rows from the database table that has values appear even once in any of this field&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
input table
PRCTR         VKORG         MATKL
1000                         
                     COND          
                                         ALE_BAT
2000
                      EGHE
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then the query should get any record that has PRCTR=(1000 or 2000) and VKORG= (COND or EGHE)  and MATKL=(ALE_BAT)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that i made myself clear&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ebrahime on Oct 12, 2009 12:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Oct 2009 10:59:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-10-12T10:59:00Z</dc:date>
    <item>
      <title>Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224185#M1379590</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;I need to write a subquery between a database table and an input table i tried to write something like this &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select * from VBRP into table ZBAPI_output_VBRP
    where ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE
  and MATKL IN ( select MATKL from ZBAPI_INPUT_VBRP )
  and PRCTR in ( select PRCTR from zBAPI_INPUT_VBRP where PRCTR is not initial )
  and VKORG_AUFT in ( select VKORG_AUFT from zBAPI_INPUT_VBRP ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but it is not working ZBAPI_INPUT_VBRP and ZBAPI_output_VBRP are input and output tables can someone guide me what code i should write to make it write and i saw also in the forums that the performance of subqueries are slow so if you can tell me how i can do it in more efficient way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 09:50:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224185#M1379590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T09:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224186#M1379591</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;instead of this subquery, its better to define some range variable in selection screen.&lt;/P&gt;&lt;P&gt;populate them as per your requirement.&lt;/P&gt;&lt;P&gt;After that use those ranges into your main query.&lt;/P&gt;&lt;P&gt;it will improve the performance of your query as well as give you the right output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Range:&lt;/P&gt;&lt;P&gt;RANGES R_PROFCENT FOR GLPCA-RPRCTR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populating Profit Center:&lt;/P&gt;&lt;P&gt;SELECT PRCTR INTO R_PROFCENT-LOW&lt;/P&gt;&lt;P&gt;FROM CEPC&lt;/P&gt;&lt;P&gt;WHERE KOKRS = '1000'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  R_PROFCENT-SIGN = 'I'.&lt;/P&gt;&lt;P&gt;  R_PROFCENT-OPTION = 'EQ'.&lt;/P&gt;&lt;P&gt;  APPEND R_PROFCENT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Main Query:&lt;/P&gt;&lt;P&gt;SELECT * FROM GLPCA &lt;/P&gt;&lt;P&gt;WHERE RPRCTR = R_PROFCENT-LOW&lt;/P&gt;&lt;P&gt;  AND RACCT IN GLACNO&lt;/P&gt;&lt;P&gt;  AND BUDAT BETWEEN  STARTDATE AND POSTDATE&lt;/P&gt;&lt;P&gt;  AND BLART IN ('DB', 'DR', 'DZ').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you understand. Like this you can declare other ranges:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds,&lt;/P&gt;&lt;P&gt;Anil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 10:03:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224186#M1379591</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T10:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224187#M1379592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for your immediate reply i tested what you have given but the problem is that i am doing a BAPI and the input should come in a table (in my case zBAPI_INPUT_VBRP) that is why i cannot fill in the range also like this &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT PRCTR INTO R_PROFCENT-LOW
FROM zBAPI_INPUT_VBRP
WHERE PRCTR is NOT NULL .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;all i want is to get the rows from database table (VBRP)  that have the values appeared in the table (zBAPI_INPUT_VBRP) &lt;/P&gt;&lt;P&gt;as i mentioned in the subquery earlier&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 10:26:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224187#M1379592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T10:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224188#M1379593</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;Are you saying that zbpi_input_vbrp is an internal table ? If so, then you can use for all entries as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

Select * from VBRP into table ZBAPI_output_VBRP
for all entries in zbapi_input_vbrp
    where ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE
  and MATKL  = ZBAPI_INPUT_VBRP-maktl
  and PRCTR =  zBAPI_INPUT_VBRP-prctr
  and VKORG_AUFT = zBAPI_INPUT_VBRP -VKORG_AUFT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 10:46:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224188#M1379593</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T10:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224189#M1379594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Advait,&lt;/P&gt;&lt;P&gt;i tried for all entries before but the problem in all entries that it compare the values of row by row. and this is not what i wanted i want the query to get the rows from the database table that has values appear even once in any of this field&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
input table
PRCTR         VKORG         MATKL
1000                         
                     COND          
                                         ALE_BAT
2000
                      EGHE
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then the query should get any record that has PRCTR=(1000 or 2000) and VKORG= (COND or EGHE)  and MATKL=(ALE_BAT)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that i made myself clear&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ebrahime on Oct 12, 2009 12:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 10:59:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224189#M1379594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T10:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery with internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224190#M1379595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello i tried this code it is not getting any data also&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: R_PROFCENT type RANGE OF VBRP-PRCTR,
      R_PROFCENT_line LIKE LINE OF R_PROFCENT.


Loop at zBAPI_INPUT_VBRP INTO wa1 WHERE PRCTR is NOT initial.
  R_PROFCENT_line-LOW = wa1-PRCTR.
R_PROFCENT_line-SIGN = 'I'.
R_PROFCENT_line-OPTION = 'EQ'.
APPEND R_PROFCENT_line to R_PROFCENT.
endloop.


SELECT * FROM VBRP
  INTO ZBAPI_OUTPUT_VBRP
WHERE
     ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE
  and Vbrp~PRCTR in R_PROFCENT.

endselect.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2009 11:48:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subquery-with-internal-table/m-p/6224190#M1379595</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-12T11:48:40Z</dc:date>
    </item>
  </channel>
</rss>

