<?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: ABAP Inner join where statement uses same field twice in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674493#M2016504</link>
    <description>&lt;P&gt;Hi Jeff,&lt;BR /&gt;&lt;BR /&gt;If I understood your requirement correctly (VBELN must be only in one of the ranges), you need to use OR in your WHERE clause:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;      WHERE ( a~vbeln in s_vbeln OR a~vbeln in lt_err_range )&lt;BR /&gt;        AND ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;You could also build one common range table for VBELN, but that's not needed.&lt;/P&gt;&lt;P&gt;Another thing:&lt;BR /&gt; There's a 1:1 relationship between VBAK and VBUK.&lt;BR /&gt;But I just had a look: In our system VBUK is empty.&lt;/P&gt;&lt;P&gt;VBAK also has the field LFSTK (Delivery Status (All Items)).&lt;BR /&gt;Why do you need to JOIN with VBUK at all?&lt;/P&gt;&lt;P&gt;You can also use&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;and   a~lfstk = c_a.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;instead.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Thorsten.&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2023 05:39:11 GMT</pubDate>
    <dc:creator>thkolz</dc:creator>
    <dc:date>2023-05-12T05:39:11Z</dc:date>
    <item>
      <title>ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674492#M2016503</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;
  &lt;P&gt;I have a requirement where I'll be using inner join to collect data from vbak, vbap and vbuk. Now I haven't encountered this type of requirement before, due to lack of data, can you please tell me if this is possible?&lt;/P&gt;
  &lt;P&gt;- Requirement is to join 3 tables, but I must also collect order number from a custom table and join these old order numbers to the initial internal table result of the inner join. Therefore, the result of the inner join will be from the 3 tables plus consider also the values inside the range to when checking the 3 tables..&lt;/P&gt;
  &lt;P&gt;- Please see my where statement below, where I used vbak-vbeln(a~vbeln) to check selection screen input s_vbeln and used it again to include data from a custom table that I saved in a range in the following statement vbak-vbeln in lt_err_range.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;inner join vbuk as c&lt;BR /&gt;       on a~vbeln = c~vbeln&lt;BR /&gt;      where a~vbeln in s_vbeln&lt;BR /&gt;      and   a~vbeln in lt_err_range&lt;BR /&gt;      and   a~auart = p_auart&lt;BR /&gt;      and   a~kunnr in s_kunnr&lt;BR /&gt;      and   a~erdat in s_erdat&lt;BR /&gt;      and   a~vkorg = p_vkorg&lt;BR /&gt;      and   a~bsark = p_bsark&lt;BR /&gt;      and   c~lfstk = c_a.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I haven't tried something like this before but is this acceptable? &lt;/P&gt;
  &lt;P&gt;Appreciate your thoughts.&lt;/P&gt;
  &lt;P&gt;Thank you,&lt;/P&gt;
  &lt;P&gt;Geoff&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 04:31:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674492#M2016503</guid>
      <dc:creator>jeff_broodwar</dc:creator>
      <dc:date>2023-05-12T04:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674493#M2016504</link>
      <description>&lt;P&gt;Hi Jeff,&lt;BR /&gt;&lt;BR /&gt;If I understood your requirement correctly (VBELN must be only in one of the ranges), you need to use OR in your WHERE clause:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;      WHERE ( a~vbeln in s_vbeln OR a~vbeln in lt_err_range )&lt;BR /&gt;        AND ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;You could also build one common range table for VBELN, but that's not needed.&lt;/P&gt;&lt;P&gt;Another thing:&lt;BR /&gt; There's a 1:1 relationship between VBAK and VBUK.&lt;BR /&gt;But I just had a look: In our system VBUK is empty.&lt;/P&gt;&lt;P&gt;VBAK also has the field LFSTK (Delivery Status (All Items)).&lt;BR /&gt;Why do you need to JOIN with VBUK at all?&lt;/P&gt;&lt;P&gt;You can also use&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;and   a~lfstk = c_a.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;instead.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Thorsten.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 05:39:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674493#M2016504</guid>
      <dc:creator>thkolz</dc:creator>
      <dc:date>2023-05-12T05:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674494#M2016505</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;yes one table column (VBAK-VBELN) can have multiple WHERE conditions in one select.&lt;BR /&gt;In your case it is two range tables (IN operator) and they will be combined together in Database Select.&lt;/P&gt;&lt;P&gt;There can only be issue with contradicting conditions. For example "I EQ 123" + "E EQ 123"... But that can happen even in single range table. I am mentioning this that you should probably use s_vbeln to filter lt_err_range (or something like that, depends on your goal).&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 05:44:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674494#M2016505</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-05-12T05:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674495#M2016506</link>
      <description>&lt;P&gt;Remark: use ABAP Clean Code policy, i.e. name c_not_yet_processed (value 'A') rather than c_a.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 05:49:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674495#M2016506</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-12T05:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674496#M2016507</link>
      <description>&lt;P&gt;Noted thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 06:46:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674496#M2016507</guid>
      <dc:creator>jeff_broodwar</dc:creator>
      <dc:date>2023-05-12T06:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674497#M2016508</link>
      <description>&lt;P&gt;nope not one in the ranges using OR, but it should be searched in both selection screen and range table... which gave me an idea... I can just put all records in one range instead before putting it in inner join.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 06:48:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674497#M2016508</guid>
      <dc:creator>jeff_broodwar</dc:creator>
      <dc:date>2023-05-12T06:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674498#M2016509</link>
      <description>&lt;P&gt;Thanks for highlighting the point, I missed that. perhaps I can just put it all in one range table (eliminating duplicates) before using it in the inner join statement right? I think it's more clean and efficient that way.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 06:49:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674498#M2016509</guid>
      <dc:creator>jeff_broodwar</dc:creator>
      <dc:date>2023-05-12T06:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674499#M2016510</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;jeff.broodwar&lt;/SPAN&gt; Yes one range table would be best &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 07:20:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674499#M2016510</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-05-12T07:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Inner join where statement uses same field twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674500#M2016511</link>
      <description>&lt;P&gt;Thank you everyone for sharing your ideas, helped me come up with a solution.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 12:04:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-inner-join-where-statement-uses-same-field-twice/m-p/12674500#M2016511</guid>
      <dc:creator>jeff_broodwar</dc:creator>
      <dc:date>2023-05-12T12:04:25Z</dc:date>
    </item>
  </channel>
</rss>

