<?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: Looping problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627187#M1281423</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from ztable into i_output for all entries in itab
       where field1 = itab-field1.

select * from ztable appending corresponding fields of table i_output 
       for all entries in jtab
       where field2 = jtab-field2.

loop at i_output.
v_tabix = sy-tabix.
  read table itab with key field1 = i_output-field1.
  if sy-subrc eq 0.
     read table jtab with key field2 = i_output-field2.
     if sy-subrc ne 0.
        delete i_output index v_tabix.
     endif.
  else.
     delete i_output index v_tabix.
  endif.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after this loop i_output contains your values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 May 2009 00:22:10 GMT</pubDate>
    <dc:creator>former_member194669</dc:creator>
    <dc:date>2009-05-13T00:22:10Z</dc:date>
    <item>
      <title>Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627186#M1281422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My internal table ITAB has a field called FIELD1 and has following values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
6789
6795
3456
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and my JTAB has a field called FIELD2 and has following values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
AA
GG
JI
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to pick values from a databse table ZTABLE and put in another internal table KTAB. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my select query is as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select FIELD3 FROM ZTABLE into KTAB-FIELD3 WHERE ZTABLE-FIELD1 = ITAB-FIELD1 AND ZTABLE-FIELD2 = JTAB-FIELD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the problem is ..i have to fill KTAB for all entries in ITAB and JTAB...that means after looping and executing the select query..my KTAB should have 3 values for KTAB-FIELD3 that have been picked from ZTABLE-FIELD3. based on values from ITAB and JTAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how should i loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jessica Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2009 23:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627186#M1281422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-12T23:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627187#M1281423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from ztable into i_output for all entries in itab
       where field1 = itab-field1.

select * from ztable appending corresponding fields of table i_output 
       for all entries in jtab
       where field2 = jtab-field2.

loop at i_output.
v_tabix = sy-tabix.
  read table itab with key field1 = i_output-field1.
  if sy-subrc eq 0.
     read table jtab with key field2 = i_output-field2.
     if sy-subrc ne 0.
        delete i_output index v_tabix.
     endif.
  else.
     delete i_output index v_tabix.
  endif.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after this loop i_output contains your values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 00:22:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627187#M1281423</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2009-05-13T00:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627188#M1281424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a@s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the code but in second query &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from ztable appending corresponding fields of table i_output 
       for all entries in jtab
       where field2 = jtab-field2
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is showing me a syntax erroe saying "Wrong expression "APPENDING" in FROM clause WHERE condition."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u help me..what is correct syntax for the second select stmt that you posted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;JEssica Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 00:39:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627188#M1281424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T00:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627189#M1281425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi jessica,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add Into After appending &amp;amp; Try this code sample,, It will work,,,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA : BEGIN OF ITAB OCCURS 0,
       FIELD1(10),
      END OF ITAB.
DATA : BEGIN OF JTAB OCCURS 0,
       FIELD2(10),
      END OF JTAB.
DATA : BEGIN OF KTAB OCCURS 0,
       FIELD1(10),
       FIELD2(10),
      END OF KTAB.

ITAB-FIELD1 = 'ABCD'.
APPEND ITAB.
ITAB-FIELD1 = 'BCDE'.
APPEND ITAB.
ITAB-FIELD1 = 'CDEF'.
APPEND ITAB.

JTAB-FIELD2 = '1234'.
APPEND JTAB.
JTAB-FIELD2 = '2345'.
APPEND JTAB.
JTAB-FIELD2 = '3456'.
APPEND JTAB.

CLEAR : ITAB, JTAB.

LOOP AT ITAB .
  READ TABLE JTAB INTO JTAB INDEX SY-TABIX.
  KTAB-FIELD1 = ITAB-FIELD1.
  KTAB-FIELD2 = JTAB-FIELD2.
  APPEND KTAB.
  CLEAR : ITAB, JTAB, KTAB.
ENDLOOP.

SELECT * FROM ZTABLE INTO IT_FINAL FOR ALL ENTRIES IN KTAB
       WHERE FIELD1 = KTAB-FIELD1 AND FIELD2 = KTAB-FIELD2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;Dileep .C&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 01:16:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627189#M1281425</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T01:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627190#M1281426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select * from ztable INTO appending corresponding fields of table i_output &lt;/P&gt;&lt;P&gt;       for all entries in jtab&lt;/P&gt;&lt;P&gt;       where field2 = jtab-field2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add INTO before appending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kiran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 01:19:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627190#M1281426</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T01:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627191#M1281427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is in 1st query coz of which u r getting error in 2nd query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your query:-&lt;/P&gt;&lt;P&gt;select * from ztable &lt;STRONG&gt;into&lt;/STRONG&gt; i_output for all entries in itab&lt;/P&gt;&lt;P&gt;       where field1 = itab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;corrected query:-&lt;/P&gt;&lt;P&gt;select * from ztable &lt;STRONG&gt;into table&lt;/STRONG&gt; i_output for all entries in itab&lt;/P&gt;&lt;P&gt;       where field1 = itab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE :here itab should be an internal table with header line of type ztable.&lt;/P&gt;&lt;P&gt;data itab type table of ztable with header line.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 04:52:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627191#M1281427</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T04:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627192#M1281428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;
Hi Jessica sam,
Just try this way. It works.
&lt;PRE&gt;&lt;CODE&gt;
IF NOT itab[] IS INITIAL.
  SELECT *
  FROM ztable
  INTO TABLE ktab
  FOR ALL ENTRIES IN itab
  WHERE field1 = itab-field1.
ENDIF.

IF NOT jtab[] IS INITIAL.
  SELECT *
  FROM ztable
  INTO TABLE ktab
  FOR ALL ENTRIES IN jtab
  WHERE field2 = jtab-field2.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;

Thanks
Venkat
&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 05:38:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627192#M1281428</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2009-05-13T05:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627193#M1281429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanke evry body solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 14:12:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem/m-p/5627193#M1281429</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T14:12:53Z</dc:date>
    </item>
  </channel>
</rss>

