‎2010 Jul 13 12:04 AM
in the below query,what could be the best method to avoid select * and modify statements.Kindly suggest with the piece of code.thanks!
SELECT * FROM febep INTO CORRESPONDING FIELDS OF TABLE it_report
FOR ALL ENTRIES IN it_febko
WHERE kukey = it_febko-kukey
AND vgext <> '000'
AND kwbtr IN s_kwbtr
AND grpnr IN s_grpnr
AND vgint IN s_vgint
AND vgdef IN s_vgdef
AND belnr IN s_belnr
AND nbbln IN s_nbbln
AND budat IN s_budat.
" To get all details from other tables required to be displayed on the report
LOOP AT it_report INTO wa_report.
PERFORM f_get_info_from_it_febko.
wa_report-hbkid = wa_febko-hbkid.
wa_report-hktid = wa_febko-hktid.
wa_report-bukrs = wa_febko-bukrs.
MODIFY it_report FROM wa_report
TRANSPORTING: hbkid, hktid, bukrs.
PERFORM f_get_txt20.
wa_report-txt20 = wa_t028e-txt20.
MODIFY it_report FROM wa_report
TRANSPORTING txt20.
PERFORM f_get_vwezw.
wa_report-vwezw_txt = g_vwezw_txt.
MODIFY it_report FROM wa_report
TRANSPORTING vwezw_txt.
ENDLOOP.
SORT it_report BY hbkid hktid belnr bukrs.
‎2010 Jul 13 12:06 AM
‎2010 Jul 13 12:24 AM
Hi dummyid01!
The select statement can be enhanced avoiding the use of " * ". It's too much better create a structure and a internal table containing only the fields you will need to your report. When creating the structure, name the fields as they are named in the original tables from dictionary and then don't use " INTO CORRESPONDING FIELDS " addition.
Also, it's always good to think twice when using for all entries addition. You must check if your it_febko internal table is not empty before the SELECT clause.
Apart from the select, take care when calling functions and forms inside a loop. Try to develop a form which takes all the data you need and use READ TABLE inside the LOOP if necessary.
Of course, use field-symbols too. I'm sure these hints will enhance your code.
‎2010 Jul 13 10:25 AM
Hi,
Check for secondary index available on the table for the given selection criteria and check if it_fbko[] is not initial. before the given select .
if it_fbko[] is not initial.
SELECT * FROM febep INTO CORRESPONDING FIELDS OF TABLE it_report
FOR ALL ENTRIES IN it_febko
WHERE kukey = it_febko-kukey
AND vgext '000'
AND kwbtr IN s_kwbtr
AND grpnr IN s_grpnr
AND vgint IN s_vgint
AND vgdef IN s_vgdef
AND belnr IN s_belnr
AND nbbln IN s_nbbln
AND budat IN s_budat.
endif.