‎2008 Jun 17 1:37 PM
hi,
may i know if every loop those can map records from bsad can be added into table it_temp.
loop at it_itab where umskz = 'W'.
select bukrs belnr gjahr buzei
into table it_temp
from bsad
where bukrs = it_itab-bukrs.
endloop.
thanks
‎2008 Jun 17 1:43 PM
I guess this way would be better:
Select BUKRS BELNR GJAHR BUZEI
INTO TABLE IT_TEMP
FROM BSAD
FOR ALL ENTRIES IN IT_TAB
WHERE BUKRS = IT_TAB-BUKRS
AND IT_TAB-UMSKZ = 'W'.
As Chandu said, in many cases it will improve the performance and give you a clearer code.
Tips for performance and code clearing:
- Sort your internal table by the key fields used for the comparisons on "Where" statement.
- If you think your comparison key values on IT_TAB will repeat many times, create an auxiliar table with just one entry of each value.
Regards
‎2008 Jun 17 1:40 PM
‎2008 Jun 17 1:41 PM
‎2008 Jun 17 1:41 PM
You can write your code like this:
loop at it_itab where umskz = 'W'.
select bukrs belnr gjahr buzei
appending table it_temp
from bsad
where bukrs = it_itab-bukrs.
endloop.
But note that this is nota good programming practice(Select within a loop).
Regards,
Ravi
‎2008 Jun 17 1:43 PM
Select inside a loop causes performance issue.
Instead of that
declare itab1 similar to itab.
loop at it_itab into wa_itab.
if wa_itam-umskz = 'W'.
move wa_itab to wa_itab1.
append wa_itab1 to it_itab1.
endif.
endloop.
select bukrs belnr gjahr buzei
into table it_temp
from bsad
for all entries in it_itab1
where bukrs = it_itab1-bukrs.Regards
Kannaiah
‎2008 Jun 17 1:43 PM
Hiiii...instead of using select with in loop....
use for all entries statement that would give a better performance and solve the problem ...
regards
chandu reddy
‎2008 Jun 17 1:43 PM
I guess this way would be better:
Select BUKRS BELNR GJAHR BUZEI
INTO TABLE IT_TEMP
FROM BSAD
FOR ALL ENTRIES IN IT_TAB
WHERE BUKRS = IT_TAB-BUKRS
AND IT_TAB-UMSKZ = 'W'.
As Chandu said, in many cases it will improve the performance and give you a clearer code.
Tips for performance and code clearing:
- Sort your internal table by the key fields used for the comparisons on "Where" statement.
- If you think your comparison key values on IT_TAB will repeat many times, create an auxiliar table with just one entry of each value.
Regards
‎2008 Jun 17 1:44 PM
hiii
you can use following type of query
SELECT carrid connid cityfrom cityto
FROM spfli
INTO (wa-carrid, wa-connid, wa-cityfrom, wa-cityto).
WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
ENDSELECT.or else you can use
... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab [PACKAGE SIZE n]
syntax for appending internal table
reward if useful
thx
twinkal
‎2008 Jun 17 1:44 PM
hi,
once getiing data into ur internal table it_tab.
write the second select stmt using For All Entries.
ex:
select ...
if not it_tab is initial.
select ...... into it_ttab1 for all entries in it_tab where.......
Rgds.,
subash
‎2008 Jun 17 1:45 PM
Hi,
don't use any DDL and DML statement within the loop.
anyway,
the it_temp will get last record only. if you want all the data use the below code.
loop at it_itab where umskz = 'W'.
select bukrs belnr gjahr buzei
appending table it_temp
from bsad
where bukrs = it_itab-bukrs.
endloop.
try to avoid the select statement within the loop.
Reward if found helpful.
Regards,
Boobalan Suburaj
‎2008 Jun 17 1:46 PM
‎2008 Jun 17 1:50 PM
Instead of LOOPs, try using FOR ALL ENTRIES IN.
Doing so, you'll improve the performance.
Example:
SELECT bukrs belnr gjahr buzei
INTO TABLE it_temp
FROM bsad
FOR ALL ENTRIES IN it_itab
WHERE bukrs = it_itab-bukrs.
Regards,
Brian Gonsales
‎2008 Jun 17 2:02 PM
hi hoffman,
actually it doesn't work.
the statement
it_itab-umskz = 'W'
is unknown to system.
thanks
‎2008 Jun 17 2:07 PM
hi,
IT_TAB1 =IT_TAB.
delete IT_TAB where umskz <> 'W'.
if you want other rec. take the copy of itab to itab1. otherwise leave it.
Select BUKRS BELNR GJAHR BUZEI
INTO TABLE IT_TEMP
FROM BSAD
FOR ALL ENTRIES IN IT_TAB
WHERE BUKRS = IT_TAB-BUKRS.
Reward if found helpful.
Regards,
Boobalan Suburaj
Edited by: Boobalan Suburaj on Jun 17, 2008 4:07 PM
‎2008 Jun 17 2:10 PM
hi,
define another internal table and copy all data into it:
itab2[] = itab[].delete all lines where umskz is not W:
DELETE itab2 WHERE umskz NE 'W'.Now you can do your select:
SELECT bukrs belnr gjahr buzei
INTO TABLE it_temp
FROM bsad
FOR ALL ENTRIES IN itab2
WHERE bukrs = itab2-bukrshope this helps
ec
‎2008 Jun 17 2:11 PM
hi,
the problem is here
AND IT_TAB-UMSKZ = 'W'.
i guess it_tab field cannot declare here as this is for bsad field.
if we declare something like umskz = it_tab-umskz, then it is ok. so you see the different position?
Select BUKRS BELNR GJAHR BUZEI
INTO TABLE IT_TEMP
FROM BSAD
FOR ALL ENTRIES IN IT_TAB
WHERE BUKRS = IT_TAB-BUKRS
AND IT_TAB-UMSKZ = 'W'.