<?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: Read statement from 2 different internal table. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071915#M1504773</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;try thsi code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;]

TABLES: /bic/asalhdr0100,/bic/asalord0100.

DATA: chdate LIKE /bic/asalhdr0100 OCCURS 0 WITH HEADER LINE,
wa_chdate TYPE /bic/asalhdr0100,
cidate LIKE /bic/asalord0100 OCCURS 0 WITH HEADER LINE,
wa_cidate TYPE /bic/asalord0100.


SELECT * FROM /bic/asalord0100 INTO TABLE cidate.

SELECT * FROM /bic/asalhdr0100 INTO TABLE chdate FOR ALL ENTRIES IN cidate WHERE doc_number = cidate-doc_number.

LOOP AT chdate INTO wa_chdate.
  LOOP AT cidate INTO wa_cidate.

    IF wa_chdate-doc_number = wa_cidate-doc_number.
      READ TABLE chdate INTO wa_chdate WITH KEY doc_number = wa_cidate-doc_number .

      WRITE: wa_chdate-doc_number,
      wa_chdate-createdon,
      wa_cidate-doc_number.
    ENDIF.
  ENDLOOP.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pravin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jul 2010 11:35:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-26T11:35:40Z</dc:date>
    <item>
      <title>Read statement from 2 different internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071914#M1504772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to ABAP and try to work out these statements. Please can someone help me in correcting the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Requirement is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I have Sales Header Table&lt;/P&gt;&lt;P&gt;2. Sales Item Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the above table has Doc_number as the key filed and both has CREATEDON date . While reading the Data from SALES ITem table i have copy the CREATEON Date from SAles Header Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the above requirment i have used the following code which is going for unending loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Tables: /BIC/ASALHDR0100,/BIC/ASALORD0100.

DATA: CHDATE like /BIC/ASALHDR0100 occurs 0 with header line,
      WA_CHDATE type /BIC/ASALHDR0100,
      CiDATE like /BIC/ASALORD0100 occurs 0 with header line,
      WA_CiDATE type /BIC/ASALORd0100.


      SELECT * from /BIC/ASALORD0100 into table CIDATE.
  

      select * from /BIC/ASALHDR0100 into CHDATE for all entries in CIDATE where DOC_NUMBER = CIDATE-DOC_NUMBER.
Append CHDATE.
      endselect.



loop at CHDATE INTO WA_CHDATE.
    LOOP at CIDATE into WA_CIDATE.

    if WA_CHDATE-DOC_NUMBER = WA_CIDATE-DOC_NUMBER.
Read table CHDATE into WA_CHDATE with KEY doc_number = WA_CIDATE-doc_number .

          write: WA_CHDATE-DOC_NUMBER,
                  WA_chdate-createdon,
                 WA_CIDATE-DOC_NUMBER.
                 ENDIF.
                 ENDLOOP.

          endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Jul 26, 2010 9:34 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jul 2010 11:19:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071914#M1504772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-26T11:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement from 2 different internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071915#M1504773</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;try thsi code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;]

TABLES: /bic/asalhdr0100,/bic/asalord0100.

DATA: chdate LIKE /bic/asalhdr0100 OCCURS 0 WITH HEADER LINE,
wa_chdate TYPE /bic/asalhdr0100,
cidate LIKE /bic/asalord0100 OCCURS 0 WITH HEADER LINE,
wa_cidate TYPE /bic/asalord0100.


SELECT * FROM /bic/asalord0100 INTO TABLE cidate.

SELECT * FROM /bic/asalhdr0100 INTO TABLE chdate FOR ALL ENTRIES IN cidate WHERE doc_number = cidate-doc_number.

LOOP AT chdate INTO wa_chdate.
  LOOP AT cidate INTO wa_cidate.

    IF wa_chdate-doc_number = wa_cidate-doc_number.
      READ TABLE chdate INTO wa_chdate WITH KEY doc_number = wa_cidate-doc_number .

      WRITE: wa_chdate-doc_number,
      wa_chdate-createdon,
      wa_cidate-doc_number.
    ENDIF.
  ENDLOOP.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pravin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jul 2010 11:35:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071915#M1504773</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-26T11:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement from 2 different internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071916#M1504774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
 
DATA: chdate type table of  /bic/asalhdr0100 
wa_chdate TYPE /bic/asalhdr0100,
cidate type table of  /bic/asalord0100 ,
wa_cidate TYPE /bic/asalord0100.
 
 
SELECT * FROM /bic/asalord0100 INTO TABLE cidate.
 
if cidate[] is not initial
SELECT * FROM /bic/asalhdr0100 INTO TABLE chdate FOR ALL ENTRIES IN cidate WHERE doc_number = cidate-doc_number.
endif.
 
LOOP AT chdate INTO wa_chdate.
  LOOP AT cidate INTO wa_cidate where doc_number = wa_chdate-doc_number.
 

      WRITE: wa_chdate-doc_number,
      wa_chdate-createdon,
      wa_cidate-doc_number.

  ENDLOOP.
 
ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you can go for parallel cursor method.For that you have to sort the internal tables and go for loop.Performance point of view, parallel cursor method is very good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jul 2010 12:26:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071916#M1504774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-26T12:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement from 2 different internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071917#M1504775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt; 
DATA: CHDATE type table of /BIC/ASALHDR0100,
      WA_CHDATE type /BIC/ASALHDR0100,
      CiDATE type sorted table of /BIC/ASALORD0100 with unique key doc_number doc_item,  "&amp;lt;--Use as required
      WA_CiDATE type /BIC/ASALORd0100.
 
       SELECT * from /BIC/ASALORD0100 into table CIDATE.
      if cidate[] is not initial.
 	sort cidate by doc_number.
      select * from /BIC/ASALHDR0100 into table CHDATE
	 for all entries in CIDATE
         where DOC_NUMBER = CIDATE-DOC_NUMBER.
      endif.

loop at CHDATE INTO WA_CHDATE.
    LOOP at CIDATE into WA_CIDATE where doc_number = wa_chdate-doc_number.
           write: WA_CHDATE-DOC_NUMBER,
                  WA_chdate-createdon,
                 WA_CIDATE-DOC_NUMBER.
	   skip 1.
    ENDLOOP.
 endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jul 2010 13:43:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-from-2-different-internal-table/m-p/7071917#M1504775</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-07-26T13:43:39Z</dc:date>
    </item>
  </channel>
</rss>

