<?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: internal table looping problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691887#M1293325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;my heartfelt thanks to all of you  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;you guys are really great and this forum is simply awesome &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;buddy ankur, i am new to this forum in terms of content posting so i really dont know how to format &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;i wrote the whole thing within "&amp;lt;codes&amp;gt;" ,but its appearing unformatted.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;THERE WAS A  MISTAKE IN MY POST I AM CORRECTING IT. plz forgive me&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of it_final,  
"this is my internal table flds arranged according to the list output  
vbeln type vbap-vbeln{code,  
posnr type vbap-posnr, 
erdat type vbak-erdat,  
}kunnr type likp-kunnr,  
lfdat type likp-lfdat,  
name1 type kna1-name1,   
aufnr type vbak-aufnr,   
matnr typr vbap-matnr,   
arktx type vbap-arktx, 
kwmeng type vbap-kwmeng, 
vrkme type vbap-vrkme, 
vbeln1 type lips-vbeln, 
posnr 1type lips-posnr, 
lfimg type lips-lfimg, 
vrkme type lips-vrkme, 
vbeln2 type vbrp-vbeln,
posnr2 type vbrp-posnr, 
fklmg type vbrp-fklmg, 
vrkme1 type vbrp-vrkme, 
end of it_final.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;now plz tell me how to populate this internal table? which is the right method : &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;(1) looping at it_likp into wa_likp.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"based on the likp-vbeln i am fetching the flds from lips.
read table it_lips into wa_lips WITH KEY vbeln = wa_likp-vbeln. 
it_final-vbeln1 = wa_lips-vbeln.
it_final-posnr1 = wa_lips-posnr. 
it_final-fklmg = wa_lips-fkimg. 
it_final-vrkme1 = wa_lips-vrkme. 
append it_final. 
endloop.
loop at it_final.
read table it_vbrp WITH KEY vgbel = it_final-vbeln.
it_final-vbeln2 = wa_vbrp-vbeln. ........... 
modify it_final index sy-tabix transporting vbeln2.... 
similarly fetch the records from vbap, lips etc.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;(2 )another method&lt;/STRONG&gt;.           &lt;STRONG&gt;(in my earlier post i wrote  loop at it_likp)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;/U&gt;&lt;PRE&gt;&lt;U&gt;&lt;CODE&gt;LOOP AT IT_LIPS INTO WA_LIPS._
 _READ TABLE IT_LIKP INTO WA_LIKP WITH KEY VBELN = WA_LIPS-VBELN._
read table it_vbrp into wa_vbrp WITH KEY vgbel = wa_likp-vbeln.
read table it_vbap into wa_vbap WITH KEY vbeln = wa_lips-vgbel. 
ps: i am selecting vgbel and vgpos from lips and vbrp but not populating into it_final as it is not reqd. 
it_final-vbeln = wa_vbap-vbeln. 
it_final-posnr = wa_vbap-posnr. 
it_final-matnr = wa_vbap-matnr. 
it_final-vbeln1 = wa_lips-vbeln. 
it_final-posnr1 = wa_lips-posnr. 
it_final-lfimg = wa_lips-lfimg. 
it_final-lfdat = wa_likp-lfdat.
it_final-kunnr = wa_likp-kunnr.
it_final-vbeln2 = wa_vbrp-vbeln.
it_final-posnr3 = wa_vbrp-posnr. 
it_final-fklmg = wa_vbrp-fklmg. 
........ ......... append it_final.
clear it_final. 
endloop.&lt;/CODE&gt;&lt;/U&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt; 
-------------------------------------------------------------------------------------------------
*3rd method.*

&lt;/CODE&gt;&lt;/PRE&gt;itfinal is my internal table, it consists of the fields mentioned in "types" statement.&lt;/P&gt;&lt;P&gt;select vbeln lfdat ....(etc) into it_likp ..(where clause) &lt;/P&gt;&lt;P&gt;select vbeln posnr matnr lfimg vrkme from lips into corresponding fields of table it_final for all entries in it_likp where vbeln = it_likp-vbeln.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"now looping on it_final and fetching other fields from other tables."
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;loop at it_final into wa_final.&lt;/P&gt;&lt;P&gt;l_tabix = sy-tabix. &lt;STRONG&gt;(why are we doing this?)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;read table it_likp into wa_likp with key.....(contd)&lt;/P&gt;&lt;P&gt;wa_final-lfdat = wa_likp-lfdat.&lt;/P&gt;&lt;P&gt;wa_final-kunnr = wa_likp-kunnr.&lt;/P&gt;&lt;P&gt;read table it_vbap into wa_vbap with key....(contd)&lt;/P&gt;&lt;P&gt;wa_final-vbeln = wa_vbap-vbeln.&lt;/P&gt;&lt;P&gt;wa_final-posnr = wa_vbap-posnr.&lt;/P&gt;&lt;P&gt;read table it_vbrp ....&lt;/P&gt;&lt;P&gt;(contd)&lt;/P&gt;&lt;P&gt;modify it_final index l_tabix transporting lfdat kunnr vbeln posnr ...(etc).&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;***********************************&lt;/P&gt;&lt;P&gt;my question is why will i loop into the item table and not into the header table. amongst the above 3 which is a better method to follow and why? if u have some other coding techniques then pls tell me.&lt;/P&gt;&lt;P&gt;will it be better if i use 'MODIFY'  here instead of  'APPEND'? why are we storing the sy-tabix value here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 13 Jun 2009 17:25:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-13T17:25:40Z</dc:date>
    <item>
      <title>internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691882#M1293320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have 5 internal table it_vbrk, it_vbrp, it_vbak,it_vbap, it_lips and it_kna1 ..( the select-options was likp-erdat and likp-vbeln)&lt;/P&gt;&lt;P&gt;based on that i have done select 'for all entries' on it_likp into it_likp have selected 3 flds from likp, 7 flds from lips. now using &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;for all entries on&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; it_lips i have selected 5 flds from vbrp into it_vbrp.  based on for all entries on it_lips i have selected 5 flds from vbap.&lt;/P&gt;&lt;P&gt;now i have to populate my final internal table it_final.&lt;/P&gt;&lt;P&gt;****************************************************************************************************************&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of it_final,  "this is my internal table flds arranged according to the list output
vbeln type vbap-vbeln,
posnr type  vbap-posnr,
erdat type vbak-erdat,
kunnr type likp-kunnr,
name1 type kna1-name1,
aufnr type vbak-aufnr,
matnr typr vbap-matnr,
arktx type vbap-arktx,
kwmeng type vbap-kwmeng,
vrkme type vbap-vrkme,
vbeln1 type lips-vbeln,
posnr 1type lips-posnr,
lfimg type lips-lfimg,
vrkme type lips-vrkme,
vbeln2 type vbrp-vbeln,
posnr2 type vbrp-posnr,
fklmg type vbrp-fklmg,
vrkme1 type vbrp-vrkme,
end of it_final.
now plz tell me how to populate this internal table? which is the right method :
(1)  looping at it_likp into wa_likp. "based on the likp-vbeln i am fetching the flds from lips.
     read table it_lips into wa_lips where vbeln =  wa_likp-vbeln.
      it_final-vbeln1 = wa_lips-vbeln.
it_final-posnr1 = wa_lips-posnr.
it_final-fklmg = wa_lips-fkimg.
it_final-vrkme1 = wa_lips-vrkme.
append it_final. endloop.
loop at it_final.
read table it_vbrp where vgbel = it_final-vbeln.
it_final-vbeln2 = wa_vbrp-vbeln.
...........
modify it_final index sy-tabix transporting vbeln2....
similarly fetch the records from vbap, lips etc.

(2 )another method.
loop at it_likp into wa_likp.
read table it_lips into wa_lips where vbeln = wa_likp-vbeln.
read table it_vbrp into wa_vbrp where vgbel = wa_likp-vbeln.
read table it_vbap into wa_vbap where vbeln = wa_lips-vgbel.
[ps: i am selecting vgbel and vgpos from lips and vbrp but not populating into it_final as it is not reqd.]
it_final-vbeln = wa_vbap-vbeln.
it_final-posnr = wa_vbap-posnr.
it_final-matnr = wa_vbap-matnr.
it_final-vbeln1 = wa_lips-vbeln.
it_final-posnr1 = wa_lips-posnr.
it_final-lfimg = wa_lips-lfimg.
it_final-vbeln2 = wa_vbrp-vbeln.
it_final-posnr3 = wa_vbrp-posnr.
it_final-fklmg = wa_vbrp-fklmg.
........
.........
append it_final.
clear it_final.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;*************************************************************************************************************&lt;/P&gt;&lt;P&gt;now plz suggest which one is a better method to follow and why? suggest me some tips to select which table to use loop first and how? where shud i use read table? plz site some codes as an example.&lt;/P&gt;&lt;P&gt;elaborate answers will be highly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 11:51:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691882#M1293320</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-12T11:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691883#M1293321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you format your message.&lt;/P&gt;&lt;P&gt;It is difficult to understand. &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 12:24:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691883#M1293321</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-12T12:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691884#M1293322</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;Second method where you are reading the data from other tables is better approach.&lt;/P&gt;&lt;P&gt;Also, sort the tables on key fiels like vbeln posnr etc. Use binary search addition to read statement.&lt;/P&gt;&lt;P&gt;One correction read statement don't have where clause instead use WITH KEY addition.&lt;/P&gt;&lt;P&gt;Loop at the table which have most of the fields which you want to populate in final internal table and read other tables.&lt;/P&gt;&lt;P&gt;KR Jaideep,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 12:32:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691884#M1293322</guid>
      <dc:creator>jaideepsharma</dc:creator>
      <dc:date>2009-06-12T12:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691885#M1293323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;types: begin of it_final, &lt;/P&gt;&lt;P&gt;"this is my internal table flds arranged according to the list output&lt;/P&gt;&lt;P&gt; vbeln type vbap-vbeln,&lt;/P&gt;&lt;P&gt; posnr type vbap-posnr, &lt;/P&gt;&lt;P&gt;erdat type vbak-erdat, &lt;/P&gt;&lt;P&gt;kunnr type likp-kunnr, &lt;/P&gt;&lt;P&gt;name1 type kna1-name1, &lt;/P&gt;&lt;P&gt;aufnr type vbak-aufnr, &lt;/P&gt;&lt;P&gt;matnr typr vbap-matnr, &lt;/P&gt;&lt;P&gt;arktx type vbap-arktx, &lt;/P&gt;&lt;P&gt;kwmeng type vbap-kwmeng, &lt;/P&gt;&lt;P&gt;vrkme type vbap-vrkme, &lt;/P&gt;&lt;P&gt;vbeln1 type lips-vbeln, &lt;/P&gt;&lt;P&gt;posnr 1type lips-posnr, &lt;/P&gt;&lt;P&gt;lfimg type lips-lfimg, &lt;/P&gt;&lt;P&gt;vrkme type lips-vrkme, &lt;/P&gt;&lt;P&gt;vbeln2 type vbrp-vbeln,&lt;/P&gt;&lt;P&gt; posnr2 type vbrp-posnr, &lt;/P&gt;&lt;P&gt;fklmg type vbrp-fklmg, &lt;/P&gt;&lt;P&gt;vrkme1 type vbrp-vrkme, &lt;/P&gt;&lt;P&gt;end of it_final. &lt;/P&gt;&lt;P&gt;now plz tell me how to populate this internal table? which is the right method : &lt;/P&gt;&lt;P&gt;(1) looping at it_likp into wa_likp.&lt;/P&gt;&lt;P&gt; "based on the likp-vbeln i am fetching the flds from lips.&lt;/P&gt;&lt;P&gt; read table it_lips into wa_lips where vbeln = wa_likp-vbeln. &lt;/P&gt;&lt;P&gt;it_final-vbeln1 = wa_lips-vbeln.&lt;/P&gt;&lt;P&gt; it_final-posnr1 = wa_lips-posnr. &lt;/P&gt;&lt;P&gt;it_final-fklmg = wa_lips-fkimg. &lt;/P&gt;&lt;P&gt;it_final-vrkme1 = wa_lips-vrkme. &lt;/P&gt;&lt;P&gt;append it_final. &lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; loop at it_final.&lt;/P&gt;&lt;P&gt; read table it_vbrp where vgbel = it_final-vbeln.&lt;/P&gt;&lt;P&gt; it_final-vbeln2 = wa_vbrp-vbeln. ........... &lt;/P&gt;&lt;P&gt;modify it_final index sy-tabix transporting vbeln2.... &lt;/P&gt;&lt;P&gt;similarly fetch the records from vbap, lips etc.&lt;/P&gt;&lt;P&gt; (2 )another method. &lt;/P&gt;&lt;P&gt;loop at it_likp into wa_likp. &lt;/P&gt;&lt;P&gt;read table it_lips into wa_lips where vbeln = wa_likp-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; read table it_vbrp into wa_vbrp where vgbel = wa_likp-vbeln.&lt;/P&gt;&lt;P&gt; read table it_vbap into wa_vbap where vbeln = wa_lips-vgbel. &lt;/P&gt;&lt;P&gt;[ps: i am selecting vgbel and vgpos from lips and vbrp but not populating into it_final as it is not reqd.] &lt;/P&gt;&lt;P&gt;it_final-vbeln = wa_vbap-vbeln. &lt;/P&gt;&lt;P&gt;it_final-posnr = wa_vbap-posnr. &lt;/P&gt;&lt;P&gt;it_final-matnr = wa_vbap-matnr. &lt;/P&gt;&lt;P&gt;it_final-vbeln1 = wa_lips-vbeln. &lt;/P&gt;&lt;P&gt;it_final-posnr1 = wa_lips-posnr. &lt;/P&gt;&lt;P&gt;it_final-lfimg = wa_lips-lfimg. &lt;/P&gt;&lt;P&gt;it_final-vbeln2 = wa_vbrp-vbeln.&lt;/P&gt;&lt;P&gt; it_final-posnr3 = wa_vbrp-posnr. &lt;/P&gt;&lt;P&gt;it_final-fklmg = wa_vbrp-fklmg. &lt;/P&gt;&lt;P&gt;........ ......... append it_final.&lt;/P&gt;&lt;P&gt;clear it_final. &lt;/P&gt;&lt;P&gt;endloop. ************************************************************************************************************* &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2method is the fine ,&lt;/P&gt;&lt;P&gt;Because performance wise it is good ,withi in sigle loop you do this.&lt;/P&gt;&lt;P&gt;All the tables relation is important for second method.&lt;/P&gt;&lt;P&gt;In 1st method Two loops are there so getting the data in final table is difficult&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 12:36:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691885#M1293323</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-12T12:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691886#M1293324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a 2500 character limit on posting with formatting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 12:59:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691886#M1293324</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2009-06-12T12:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: internal table looping problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691887#M1293325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;my heartfelt thanks to all of you  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;you guys are really great and this forum is simply awesome &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;buddy ankur, i am new to this forum in terms of content posting so i really dont know how to format &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;i wrote the whole thing within "&amp;lt;codes&amp;gt;" ,but its appearing unformatted.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;THERE WAS A  MISTAKE IN MY POST I AM CORRECTING IT. plz forgive me&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of it_final,  
"this is my internal table flds arranged according to the list output  
vbeln type vbap-vbeln{code,  
posnr type vbap-posnr, 
erdat type vbak-erdat,  
}kunnr type likp-kunnr,  
lfdat type likp-lfdat,  
name1 type kna1-name1,   
aufnr type vbak-aufnr,   
matnr typr vbap-matnr,   
arktx type vbap-arktx, 
kwmeng type vbap-kwmeng, 
vrkme type vbap-vrkme, 
vbeln1 type lips-vbeln, 
posnr 1type lips-posnr, 
lfimg type lips-lfimg, 
vrkme type lips-vrkme, 
vbeln2 type vbrp-vbeln,
posnr2 type vbrp-posnr, 
fklmg type vbrp-fklmg, 
vrkme1 type vbrp-vrkme, 
end of it_final.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;now plz tell me how to populate this internal table? which is the right method : &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;(1) looping at it_likp into wa_likp.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"based on the likp-vbeln i am fetching the flds from lips.
read table it_lips into wa_lips WITH KEY vbeln = wa_likp-vbeln. 
it_final-vbeln1 = wa_lips-vbeln.
it_final-posnr1 = wa_lips-posnr. 
it_final-fklmg = wa_lips-fkimg. 
it_final-vrkme1 = wa_lips-vrkme. 
append it_final. 
endloop.
loop at it_final.
read table it_vbrp WITH KEY vgbel = it_final-vbeln.
it_final-vbeln2 = wa_vbrp-vbeln. ........... 
modify it_final index sy-tabix transporting vbeln2.... 
similarly fetch the records from vbap, lips etc.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;(2 )another method&lt;/STRONG&gt;.           &lt;STRONG&gt;(in my earlier post i wrote  loop at it_likp)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;/U&gt;&lt;PRE&gt;&lt;U&gt;&lt;CODE&gt;LOOP AT IT_LIPS INTO WA_LIPS._
 _READ TABLE IT_LIKP INTO WA_LIKP WITH KEY VBELN = WA_LIPS-VBELN._
read table it_vbrp into wa_vbrp WITH KEY vgbel = wa_likp-vbeln.
read table it_vbap into wa_vbap WITH KEY vbeln = wa_lips-vgbel. 
ps: i am selecting vgbel and vgpos from lips and vbrp but not populating into it_final as it is not reqd. 
it_final-vbeln = wa_vbap-vbeln. 
it_final-posnr = wa_vbap-posnr. 
it_final-matnr = wa_vbap-matnr. 
it_final-vbeln1 = wa_lips-vbeln. 
it_final-posnr1 = wa_lips-posnr. 
it_final-lfimg = wa_lips-lfimg. 
it_final-lfdat = wa_likp-lfdat.
it_final-kunnr = wa_likp-kunnr.
it_final-vbeln2 = wa_vbrp-vbeln.
it_final-posnr3 = wa_vbrp-posnr. 
it_final-fklmg = wa_vbrp-fklmg. 
........ ......... append it_final.
clear it_final. 
endloop.&lt;/CODE&gt;&lt;/U&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt; 
-------------------------------------------------------------------------------------------------
*3rd method.*

&lt;/CODE&gt;&lt;/PRE&gt;itfinal is my internal table, it consists of the fields mentioned in "types" statement.&lt;/P&gt;&lt;P&gt;select vbeln lfdat ....(etc) into it_likp ..(where clause) &lt;/P&gt;&lt;P&gt;select vbeln posnr matnr lfimg vrkme from lips into corresponding fields of table it_final for all entries in it_likp where vbeln = it_likp-vbeln.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"now looping on it_final and fetching other fields from other tables."
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;loop at it_final into wa_final.&lt;/P&gt;&lt;P&gt;l_tabix = sy-tabix. &lt;STRONG&gt;(why are we doing this?)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;read table it_likp into wa_likp with key.....(contd)&lt;/P&gt;&lt;P&gt;wa_final-lfdat = wa_likp-lfdat.&lt;/P&gt;&lt;P&gt;wa_final-kunnr = wa_likp-kunnr.&lt;/P&gt;&lt;P&gt;read table it_vbap into wa_vbap with key....(contd)&lt;/P&gt;&lt;P&gt;wa_final-vbeln = wa_vbap-vbeln.&lt;/P&gt;&lt;P&gt;wa_final-posnr = wa_vbap-posnr.&lt;/P&gt;&lt;P&gt;read table it_vbrp ....&lt;/P&gt;&lt;P&gt;(contd)&lt;/P&gt;&lt;P&gt;modify it_final index l_tabix transporting lfdat kunnr vbeln posnr ...(etc).&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;***********************************&lt;/P&gt;&lt;P&gt;my question is why will i loop into the item table and not into the header table. amongst the above 3 which is a better method to follow and why? if u have some other coding techniques then pls tell me.&lt;/P&gt;&lt;P&gt;will it be better if i use 'MODIFY'  here instead of  'APPEND'? why are we storing the sy-tabix value here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2009 17:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-looping-problem/m-p/5691887#M1293325</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-13T17:25:40Z</dc:date>
    </item>
  </channel>
</rss>

