<?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 Inner Join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879757#M369546</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! &lt;/P&gt;&lt;P&gt;  I have a report that require 1 to many relationship in 4 tables: BKPF, BSIS, T012K, T012.&lt;/P&gt;&lt;P&gt; Now I would like to join table BVOR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Techical spec is as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
1. Get (BUKRS, BELNR, GJAHR, HKONT) from BSIS with conditions BUKRS = parameter-BUKRS, HKONT between '750000' to '759999', GJAHR = select_option-GJAHR and BELNR = select_option-BELNR.
2. Get (BUKRS, BELNR, GJAHR, BVORG, HKONT) from BKPF with conditions BUKRS = BSIS-BUKRS, GJAHR = BSIS-GJAHR, BELNR = BSIS-BELNR AND BKTXT = ('&amp;amp;W&amp;amp;' OR '&amp;amp;w&amp;amp;').
3. Get (BANKN, HBKID) from T012K with conditions BUKRS = BKPF-BUKRS, HKONT = BKPF-HKONT.
4. Get (BANKS) from T012 with conditions BUKRS = BKPF-BUKRS, HBKID = T012K~HBKID.
5. Get (BUKRS, BELNR, GJAHR, BVORG) from BVOR with conditions BUKRS &amp;lt;&amp;gt; BKPF-BUKRS, BELNR &amp;lt;&amp;gt; BELNR, BVORG = BKPF-BVORG.

  SELECT BSIS~BUKRS BSIS~BELNR BSIS~GJAHR BKPF~HKONT
         BKPF~BVORG T012K~BANKN T012K~HBKID 
         INTO CORRESPONDING FIELDS OF TABLE ITAB
         FROM BSIS INNER JOIN BKPF  ON  BSIS~BUKRS = BKPF~BUKRS
                                    AND BSIS~BELNR = BKPF~BELNR
                                    AND BSIS~GJAHR = BKPF~GJAHR
                   INNER JOIN T012K ON  T012K~BUKRS = BKPF~BUKRS
                                    AND T012K~HKONT = BKPF~HKONT
                   INNER JOIN T012  ON  T012~BUKRS = BKPF~BUKRS
                                    AND T012~HBKID = T012K~HBKID
                   WHERE BSIS~BUKRS = P_BUKRS  "parameter
                     AND BSIS~BELNR IN S_BELNR "select option
                     AND BSIS~GJAHR IN S_GJAHR "select option
                     AND BSIS~HKONT BETWEEN '0000750000' AND '0000759999'
                     AND BKPF~BKTXT EQ '&amp;amp;W&amp;amp;' OR
                         BKPF~HKONT EQ '&amp;amp;w&amp;amp;'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code above join tables BSIS, BKPF, T012K and T012. Can I join BVOR table too? But in BVOR, I need to store the BUKRS, BELNR and GJAHR. If I add 3 more fields to my ITAB, I have to name the field like BUKR1, BELN1 and GJAH1 so that data from BVOR won't overwrite the data get from BSIS. Is it possible?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
- If it is not possible, how should I write the code (1 to many). Should I loop ITAB and select data from BVOR and store the data to another internal table? 
- How if I would like to join both internal table?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please kindly give me suggestion as I wish this program can get better performance than having inner loop. Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;ying ying&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jan 2007 13:32:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-23T13:32:03Z</dc:date>
    <item>
      <title>Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879757#M369546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! &lt;/P&gt;&lt;P&gt;  I have a report that require 1 to many relationship in 4 tables: BKPF, BSIS, T012K, T012.&lt;/P&gt;&lt;P&gt; Now I would like to join table BVOR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Techical spec is as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
1. Get (BUKRS, BELNR, GJAHR, HKONT) from BSIS with conditions BUKRS = parameter-BUKRS, HKONT between '750000' to '759999', GJAHR = select_option-GJAHR and BELNR = select_option-BELNR.
2. Get (BUKRS, BELNR, GJAHR, BVORG, HKONT) from BKPF with conditions BUKRS = BSIS-BUKRS, GJAHR = BSIS-GJAHR, BELNR = BSIS-BELNR AND BKTXT = ('&amp;amp;W&amp;amp;' OR '&amp;amp;w&amp;amp;').
3. Get (BANKN, HBKID) from T012K with conditions BUKRS = BKPF-BUKRS, HKONT = BKPF-HKONT.
4. Get (BANKS) from T012 with conditions BUKRS = BKPF-BUKRS, HBKID = T012K~HBKID.
5. Get (BUKRS, BELNR, GJAHR, BVORG) from BVOR with conditions BUKRS &amp;lt;&amp;gt; BKPF-BUKRS, BELNR &amp;lt;&amp;gt; BELNR, BVORG = BKPF-BVORG.

  SELECT BSIS~BUKRS BSIS~BELNR BSIS~GJAHR BKPF~HKONT
         BKPF~BVORG T012K~BANKN T012K~HBKID 
         INTO CORRESPONDING FIELDS OF TABLE ITAB
         FROM BSIS INNER JOIN BKPF  ON  BSIS~BUKRS = BKPF~BUKRS
                                    AND BSIS~BELNR = BKPF~BELNR
                                    AND BSIS~GJAHR = BKPF~GJAHR
                   INNER JOIN T012K ON  T012K~BUKRS = BKPF~BUKRS
                                    AND T012K~HKONT = BKPF~HKONT
                   INNER JOIN T012  ON  T012~BUKRS = BKPF~BUKRS
                                    AND T012~HBKID = T012K~HBKID
                   WHERE BSIS~BUKRS = P_BUKRS  "parameter
                     AND BSIS~BELNR IN S_BELNR "select option
                     AND BSIS~GJAHR IN S_GJAHR "select option
                     AND BSIS~HKONT BETWEEN '0000750000' AND '0000759999'
                     AND BKPF~BKTXT EQ '&amp;amp;W&amp;amp;' OR
                         BKPF~HKONT EQ '&amp;amp;w&amp;amp;'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code above join tables BSIS, BKPF, T012K and T012. Can I join BVOR table too? But in BVOR, I need to store the BUKRS, BELNR and GJAHR. If I add 3 more fields to my ITAB, I have to name the field like BUKR1, BELN1 and GJAH1 so that data from BVOR won't overwrite the data get from BSIS. Is it possible?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
- If it is not possible, how should I write the code (1 to many). Should I loop ITAB and select data from BVOR and store the data to another internal table? 
- How if I would like to join both internal table?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please kindly give me suggestion as I wish this program can get better performance than having inner loop. Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;ying ying&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 13:32:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879757#M369546</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T13:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879758#M369547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand why you want to get BVOR-BVORG. You already are getting BKPF-BVORG. Will they be different?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in any event, I wouldn't add complexity to this select. I'd do a separate select into an internal table for  BVOR and use a binary read to get this data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:25:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879758#M369547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879759#M369548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;  thanks for your prompt reply. The data from BVOR will be used to further data retrival. &lt;/P&gt;&lt;P&gt;  I will try on your binary read in this report. Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:32:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879759#M369548</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879760#M369549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK - but I go back to my original question - is the BVOR value different from that in BKPF?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also - BVORG is the first filed of the primary key for this table, so you will not be using an index to read it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:43:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879760#M369549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879761#M369550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Hi Rob,

 I need to get inter-company document from BVOR. So, I need the conditions to be 
BUKRS NE BKPF-BUKRS. BELNR NE BKPF-BELNR and BVORG EQ BKPF-BVORG.
 This spec was written by FICO analyst. I have no accounting background and new to 
ABAP, so i hope I can learn from this forum in order to write a better performance report.

After I get all the data on above. I will need to get Invoices Paid from BSAK and Advance
Payment Details from BSIK. 
1. To get Invoice Paid from BSAK: conditions are BUKRS = BKPF-BUKRS, AUGDT = 
    BKPF-BUDAT, AUGBL = BKPF-BELNR and BELNR &amp;lt;&amp;gt; BKPF-BELNR, if cannot get,
    conditions change to BUKRS = BVOR-BUKRS, AUGDT = BKPF-BUDAT, AUGBL = 
    BVOR-BELNR and BELNR &amp;lt;&amp;gt; BVOR-BELNR
2. To get Advance Payment Details from BSIK: conditions are BUKRS = BKPF-BUKRS,
    BELNR = BKPF-BELNR and GJAHR = BKPF-GJAHR. If cannot get, conditions 
    change to BUKRS = BVOR-BUKRS, BELNR = BVOR-BELNR and GJAHR = 
    BVOR-GJAHR.
This is the reason I need to get data from BVOR too.

cheers
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 15:20:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879761#M369550</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T15:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879762#M369551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you find that your inner join is not performing well, you could consider breaking it up into individual select-statements. First select from BKPF, and use the reduced list to then select from BSIS and the others.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further, check the amount of data in T012 and T012K tables. If it is not much, then have two separate select-statements to select data from these two tables into separate internal tables, and READ the internal table to get the data for each BSIS record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jan 2007 17:53:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1879762#M369551</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-26T17:53:31Z</dc:date>
    </item>
  </channel>
</rss>

