2012 Dec 30 6:05 AM
LOOP AT record.
SELECT * FROM drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel
WHERE qmnum EQ drad-objky
AND bequi EQ record-equnr.
APPEND it_viqmel.
ENDSELECT.
ENDSELECT.
ENDLOOP.
here viqmel is a view constructed on 4 tables. here it takes much time while executing the program.
Anyone can post, how to avoid this code.
2012 Dec 30 6:52 AM
There is a better way arround, Have a look. No new structures introduced
SELECT * FROM drad into it_drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel
for all entries in it_drad
WHERE qmnum EQ it_drad-objky.
loop at it_vigmel.
read table record with key equnr eq it_vigmel-begui.
if sy-subrc ne 0.
DELETE TABLE it_vigmel.
endif.
endloop
The total iteration of loops is reduced. expeced less number of times it will go inside if sy-subrc ne 0.
Do a runtime analysis see which is better.
LOOP AT record.
SELECT * FROM drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel
WHERE qmnum EQ drad-objky
AND bequi EQ record-equnr.
APPEND it_viqmel.
ENDSELECT.
ENDSELECT.
ENDLOOP.
here viqmel is a view constructed on 4 tables. here it takes much time while executing the program.
Anyone can post, how to avoid this code.
2012 Dec 30 6:40 AM
Hi,
I have also introduced another itab here it_vigmel_temp and a work area wa_it_vigmel.
This will hit the database 2 times where as earlier it would have been hitting too many times.
Its better to avoid writing selects inside select.
to avoid writing selects inside loop.
Time for loop(count) is same.
SELECT * FROM drad into it_drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel_temp
for all entries in it_drad
WHERE qmnum EQ it_drad-objky.
refresh it_vigmel.
loop at record.
read table it_vigmel_temp into wa_vigmel with key begui eq record-equnr.
if sy-subrc = 0.
append wa_vigmel to it_vigmel.
endif.
endloop.
Do a runtime analysis figure out what happens.
I hope this helps.
HAPPY ABAPing!!
2012 Dec 30 6:52 AM
There is a better way arround, Have a look. No new structures introduced
SELECT * FROM drad into it_drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel
for all entries in it_drad
WHERE qmnum EQ it_drad-objky.
loop at it_vigmel.
read table record with key equnr eq it_vigmel-begui.
if sy-subrc ne 0.
DELETE TABLE it_vigmel.
endif.
endloop
The total iteration of loops is reduced. expeced less number of times it will go inside if sy-subrc ne 0.
Do a runtime analysis see which is better.
2013 Jan 03 2:34 PM
Hi, It can be improve further using the following tips
1) VIQMEL is database view on 3 table, if it is possible and your data is in single table then used single table for fetch the data instead of using the view.
2) Check the driver table should not be empty.
3) Used the fields symbol for processing the data instead of internal table with header line or work area.
4) Use the appropriate internal table type for data processing.
2013 Jan 11 4:24 PM
You could get all the required values using FOR ALL ENTRIES IN and then use parallel cursor. That can improve performance.
2013 Feb 14 1:39 PM
SELECT * FROM drad into table it_drad WHERE doknr = h_fco_doknr.
SELECT * FROM viqmel INTO it_viqmel
FOR ALL ENTRIES IN it_drad
WHERE qmnum EQ drad-objky.
LOOP AT record.
LOOP AT it_drad.
LOOP AT it_viqmel WHERE bequi EQ record-equnr.
clear: it_output.
it_output = it_viqmel.
APPEND it_output.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Regards,
Vijay Pimputkar
2013 Mar 04 1:07 PM
SELECT * FROM drad into table it_drad
WHERE doknr = h_fco_doknr.
IF it_drad[] is not initial.
SELECT * FROM viqmel INTO it_viqmel
FOR ALL ENTRIES IN it_drad
WHERE qmnum EQ drad-objky.
LOOP AT record.
read table it_viqmel with key bequi = record-equnr.
if sy-subrc ne 0.
delete it_viqmel.
endif.
endloop.
endif.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |