<?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: Combining 3 internal tables... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336867#M514615</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;The Rule Is prety simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always Loop at the table which has the most number of records and read the other tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so loop at delivery and read billing and sales..should work fine until..u have a delivery doc existing for every sales doc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jun 2007 09:36:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-05T09:36:21Z</dc:date>
    <item>
      <title>Combining 3 internal tables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336866#M514614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to combine 3 internal tables into 1 internal table. The 3 internal tables are&lt;/P&gt;&lt;P&gt;for the sales docs, delivery docs and billing docs. What I did was to loop my &lt;/P&gt;&lt;P&gt;sales docs table and from there I have a loop for the delivery docs table and&lt;/P&gt;&lt;P&gt;billing docs table. My problem is, there can be multiple delivery docs and billing&lt;/P&gt;&lt;P&gt;docs for a given sales doc. Please take a look at my code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
METHOD combine_data.
    FIELD-SYMBOLS: &amp;lt;fs_sales_tab&amp;gt; LIKE LINE OF im_sales_tab,
                   &amp;lt;fs_cust_tab&amp;gt;  LIKE LINE OF im_cust_tab,
                   &amp;lt;fs_dlv_tab&amp;gt;   LIKE LINE OF im_dlv_tab,
                   &amp;lt;fs_bill_tab&amp;gt;  LIKE LINE OF im_bill_tab.

    DATA: wa_output LIKE LINE OF ex_output.

    LOOP AT im_sales_tab ASSIGNING &amp;lt;fs_sales_tab&amp;gt;.
      wa_output-creation_date = &amp;lt;fs_sales_tab&amp;gt;-erdat.  "SO creation date
      wa_output-creation_time = &amp;lt;fs_sales_tab&amp;gt;-erzet.  "SO creation time
      wa_output-sales_doc     = &amp;lt;fs_sales_tab&amp;gt;-vbeln.  "Sales document
      wa_output-cust_code     = &amp;lt;fs_sales_tab&amp;gt;-kunnr.  "SO customer code

*     Customer description and ship-to description
      READ TABLE im_cust_tab ASSIGNING &amp;lt;fs_cust_tab&amp;gt; WITH KEY kunnr = &amp;lt;fs_sales_tab&amp;gt;-kunnr.
      IF sy-subrc = 0.
        MOVE &amp;lt;fs_cust_tab&amp;gt;-name1 TO: wa_output-cust_desc, wa_output-ship_to_desc.
      ENDIF.

      wa_output-po_num       = &amp;lt;fs_sales_tab&amp;gt;-bstnk.   "PO number
      wa_output-doc_type     = &amp;lt;fs_sales_tab&amp;gt;-auart.   "SO document type
      wa_output-req_dlv_date = &amp;lt;fs_sales_tab&amp;gt;-vdatu.   "SO req. delivery date
      wa_output-created_by   = &amp;lt;fs_sales_tab&amp;gt;-ernam.   "SO created by

*     Ship-to code and delivery document
      LOOP AT im_dlv_tab ASSIGNING &amp;lt;fs_dlv_tab&amp;gt; WHERE vgbel = &amp;lt;fs_sales_tab&amp;gt;-vbeln.
        wa_output-ship_to_code = &amp;lt;fs_dlv_tab&amp;gt;-kunnr.   "Ship-to code
        wa_output-del_doc      = &amp;lt;fs_dlv_tab&amp;gt;-vbeln.   "Delivery document
      ENDLOOP.

*     Billing document
      LOOP AT im_bill_tab ASSIGNING &amp;lt;fs_bill_tab&amp;gt; WHERE vbelv   = &amp;lt;fs_sales_tab&amp;gt;-vbeln
                                                    AND vbtyp_n =  'M'.
        wa_output-bill_doc = &amp;lt;fs_bill_tab&amp;gt;-vbeln.      "Billing document
      ENDLOOP.
    ENDLOOP.
  ENDMETHOD.                    "combine_data

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you guys and take care!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:31:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336866#M514614</guid>
      <dc:creator>aris_hidalgo</dc:creator>
      <dc:date>2007-06-05T09:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combining 3 internal tables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336867#M514615</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;The Rule Is prety simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always Loop at the table which has the most number of records and read the other tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so loop at delivery and read billing and sales..should work fine until..u have a delivery doc existing for every sales doc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:36:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336867#M514615</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-05T09:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Combining 3 internal tables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336868#M514616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;could someone please solve this problem...&lt;/P&gt;&lt;P&gt;one is a header table and the second one is line item and third is sub line item...&lt;/P&gt;&lt;P&gt;how can u combine all three internal tables into one... as item line is having multiple lines with same document no... &lt;/P&gt;&lt;P&gt;how can we achieve this..&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 06:16:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combining-3-internal-tables/m-p/2336868#M514616</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T06:16:17Z</dc:date>
    </item>
  </channel>
</rss>

