<?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: Select-option in select query condition in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219363#M1983460</link>
    <description>&lt;P&gt;You could loop at the select-options records and for each criteria (where SIGN = 'I' include) create a range with this unique record and loop into the resulting itab for a record matching it.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Oct 2020 07:01:02 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2020-10-05T07:01:02Z</dc:date>
    <item>
      <title>Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219359#M1983456</link>
      <description>&lt;P&gt;Dears,&lt;/P&gt;
  &lt;P&gt;Is there any elegant way to know which entries in select-option have not fetched records as where condition in Select statement?&lt;/P&gt;
  &lt;P&gt;I mean without comparing tables contents. if possible.&lt;/P&gt;
  &lt;P&gt;For example which matnr in so_matnr have not fetch records:&lt;/P&gt;
  &lt;P&gt;SELECT a~infrn a~matnr a~lifnr b~ekorg&lt;BR /&gt;INTO TABLE itab&lt;BR /&gt;FROM eina AS a&lt;BR /&gt;INNER JOIN eine AS b on a~infnr = b~infnr&lt;BR /&gt;WHERE a~matnr IN so_matnr&lt;BR /&gt; AND a~lifnr = p_lifnr&lt;BR /&gt; AND b~ekorg = p_ekorg.&lt;/P&gt;
  &lt;P&gt;thanks, Raj&lt;/P&gt;</description>
      <pubDate>Sat, 03 Oct 2020 20:52:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219359#M1983456</guid>
      <dc:creator>former_member657283</dc:creator>
      <dc:date>2020-10-03T20:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219360#M1983457</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Elegant = less coding vs. Performance (?)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If SO_MATNR comes from a selection where users can make all available select-options (eg. Includes/Excludes, Equal, Unequal, Between, Pattern, ...), than you would have to use MARA as the FROM table to select from, in order to define the &lt;EM&gt;&lt;STRONG&gt;relevant&lt;/STRONG&gt;&lt;/EM&gt; MATNRs and then do outer joins with EINE and EINA (available with ABAP 740, but not with 73x)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT m~matnr, a~infnr, a~lifnr, b~ekorg
INTO TABLE @DATA(itab)
FROM mara AS m
 LEFT JOIN eina AS a ON a~matnr = m~matnr AND a~lifnr = @p_lifnr
 LEFT JOIN eine AS b ON b~infnr = a~infnr AND b~ekorg = @p_ekorg
WHERE m~matnr IN @so_matnr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If SO_MATNR only contains Include Equal values where LOW is a &lt;STRONG&gt;&lt;EM&gt;relevant&lt;/EM&gt;&lt;/STRONG&gt; MATNR, or if you already have an internal table with the only relevant MATNRs, you can also join your internal table with eina and eine, instead of joining it with MARA (SO_MATNR could only be used with value LOW, if SO_MATNR is an internal table without a header structure). Be aware, that these select statement options are not possible with older ABAP versions (e.g. not available with 740, but available with 752)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_matnr,   
         matnr TYPE matnr,
       END OF ty_matnr.
DATA lt_matnr TYPE SORTED TABLE OF ty_matnr WITH UNIQUE KEY matnr. " internal table containing relevant MATNRs
"SELECT matnr FROM mara INTO TABLE lt_matnr. " just for testing purposes

SELECT m~matnr, a~infnr, a~lifnr, b~ekorg
FROM @lt_matnr AS m
 LEFT JOIN eina AS a ON a~matnr = m~matnr AND a~lifnr = @p_lifnr
 LEFT JOIN eine AS b ON b~infnr = a~infnr AND b~ekorg = @p_ekorg
  INTO TABLE @DATA(itab).
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Oct 2020 05:30:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219360#M1983457</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-10-04T05:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219361#M1983458</link>
      <description>&lt;P&gt;You say "which entries in select-option have not fetched records". But in select-option you may have conditions like I CP *ER*, E CP *S*, so for lines which imply material "ERS", what is the meaning of returning these 2 entries? That makes it impossible to answer your question. So I guess the question is more "which matnr values have not fetched records", right?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Oct 2020 07:39:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219361#M1983458</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-04T07:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219362#M1983459</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;rajesh_koothrappali&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Its impossible without comparing the entries of the table.&lt;/P&gt;&lt;P&gt;Few simple ways would be:&lt;/P&gt;&lt;P&gt;-&amp;gt; Pass Your resultant table to a temporary internal table. Now sort the temporary table based on MATNR and delete Adjacent duplicates. With this you will have unique entries of MATNR, Now compare the no of entries in the Temporary table against Selection Screen entries. If it is equals then all values have been fetched, if there is a difference then you can compare and find the left out materials.&lt;/P&gt;&lt;P&gt;-&amp;gt; Read your resultant table against all the entries fed in the selection screen, if the read fails then that is the MATNR you are looking for.&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;</description>
      <pubDate>Sun, 04 Oct 2020 15:54:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219362#M1983459</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2020-10-04T15:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219363#M1983460</link>
      <description>&lt;P&gt;You could loop at the select-options records and for each criteria (where SIGN = 'I' include) create a range with this unique record and loop into the resulting itab for a record matching it.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 07:01:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219363#M1983460</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2020-10-05T07:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219364#M1983461</link>
      <description>&lt;P&gt;Hello  &lt;SPAN class="mention-scrubbed"&gt;rajesh_koothrappali&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;It's not possible without a comparison. Furthermore, the SELECT-OPTIONS may contain range records, which makes any simple record by record comparison invalid.&lt;/P&gt;&lt;P&gt;What you could do is:&lt;/P&gt;&lt;P&gt;1. SELECT all materials from MARA table, to have a list of them.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT matnr
  FROM MARA
  WHERE matnr IN s_matnr
  INTO TABLE @DATA(lt_materials).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. SELECT data from documents (based on your SQL).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT a~infrn a~matnr a~lifnr b~ekorg
  INTO TABLE itab
  FROM eina AS a
  INNER JOIN eine AS b on a~infnr = b~infnr
  WHERE a~matnr IN so_matnr
    AND a~lifnr = p_lifnr
    AND b~ekorg = p_ekorg.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3. Compare the selected data.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_materials REFERENCE INTO DATA(ld_material).
  READ TABLE itab TRANSPORTING NO FIELDS
    WITH KEY matnr = ld_material-&amp;gt;matnr.
  IF sy-subrc = 0.
    " record exists
  ELSE.
    " record does not exist
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kind regards,&lt;/P&gt;Mateusz</description>
      <pubDate>Mon, 05 Oct 2020 07:21:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219364#M1983461</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2020-10-05T07:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219365#M1983462</link>
      <description>&lt;P&gt;Right Sandra, I meant a short coding to retrieve material values, included in selection, which get no records from Select.&lt;/P&gt;&lt;P&gt;Apologize for ambiguity and really thanks to everybody who gave their idea.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 18:48:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219365#M1983462</guid>
      <dc:creator>former_member657283</dc:creator>
      <dc:date>2020-10-05T18:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219366#M1983463</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;make user of &lt;STRONG&gt;FILTER&lt;/STRONG&gt; keyword!!&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 06:50:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219366#M1983463</guid>
      <dc:creator>Chintu6august</dc:creator>
      <dc:date>2020-10-06T06:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219367#M1983464</link>
      <description>&lt;P&gt;As I said, I guess the question is more "which matnr values have not fetched records".&lt;/P&gt;&lt;P&gt;It's possible to do an additional SELECT to achieve your goal, but it's better to do only one global SELECT (and then separate the two cases in ABAP, as explained by Michael).&lt;/P&gt;&lt;P&gt;Solution with one additional SELECT:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA itab_matnr TYPE TABLE OF mara-matnr.
SELECT matnr
  INTO TABLE itab_matnr
  FROM eina
  WHERE a~matnr IN so_matnr
    AND a~lifnr = p_lifnr
    AND NOT EXISTS(
      SELECT *
        FROM eina AS a
          INNER JOIN eine AS b ON a~infnr = b~infnr
        WHERE a~matnr IN so_matnr
          AND a~lifnr = p_lifnr
          AND b~ekorg = p_ekorg ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(to be compared to your original query, for reference:)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT a~infrn a~matnr a~lifnr b~ekorg
  INTO TABLE itab
  FROM eina AS a
    INNER JOIN eine AS b on a~infnr = b~infnr
  WHERE a~matnr IN so_matnr
    AND a~lifnr = p_lifnr
    AND b~ekorg = p_ekorg.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you want only one SELECT, Michael explained how to do it with a left outer join, but you may also desire to have MATNR that exist only in EINE, without extending to MARA. In that case, it's even more simple:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT a~infrn a~matnr a~lifnr b~ekorg
  INTO TABLE itab
  FROM eina AS a
    LEFT JOIN eine AS b on a~infnr = b~infnr
  WHERE a~matnr IN so_matnr
    AND a~lifnr = p_lifnr
    AND b~ekorg = p_ekorg.
LOOP AT itab INTO DATA(line) WHERE ekorg IS INITIAL.
  " all lines from EINA whose "MATNR values have not fetched records" (no line in EINE)
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Oct 2020 06:54:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219367#M1983464</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-06T06:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219368#M1983465</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;make use of  EXCEPT with FILTER keyword. &lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 06:58:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219368#M1983465</guid>
      <dc:creator>Chintu6august</dc:creator>
      <dc:date>2020-10-06T06:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select-option in select query condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219369#M1983466</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;rajesh_koothrappali&lt;/SPAN&gt;, you have asked for an 'elegant' solution without comparing table contents. &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;But the 'comparison' has to be done somewhere. &lt;BR /&gt;So either on database level or an ABAP level. &lt;/LI&gt;&lt;LI&gt;If a computation can be done on database level, it will in sum in almost all cases outperform the same computation on ABAP level. &lt;/LI&gt;&lt;LI&gt;It also leads in a lot of cases to less data being moved between database and ABAP, less necessary database accesses as well as less memory necessary in ABAP. &lt;/LI&gt;&lt;LI&gt;Of course there will be more computation and memory necessary on the database, but it is closer to the source of the data and it has to be performed somewhere. &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, if you can solve your problem with one select statement, that does the same as two select statements as well as loop search (which should be optimized by accessing the second table with a primary/secondary key), I would most likely go for the one select statement. If you need the information about what materials led to a hit and which didint, you can still simply separate your resulting table in two tables with a simple loop and check whether the values other than matnr are empty or not.&lt;/P&gt;&lt;P&gt;PS: &lt;STRONG&gt;Do you really need to know in your programme which matnr did not lead to hits, or is it just nice to know in order to test your programme?&lt;/STRONG&gt; &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;If you dont really need it, I would definitly not do the check for matnr without hits, neither on database nor on ABAP level (thats why I questioned the resulting 'performance' (loss) of a logic that also checks for missing entries)&lt;/LI&gt;&lt;LI&gt;Just for testing I would rather add a second logic that after successfull tests can easily be deactivated or deleted before going to production, without changing the logic of the main relevant coding.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 06 Oct 2020 08:55:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-option-in-select-query-condition/m-p/12219369#M1983466</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-10-06T08:55:51Z</dc:date>
    </item>
  </channel>
</rss>

