I have a code as below, which takes more than 200 minutes to execute, could you help me to improve the performance.
This code is triggered at User Command. Say users select all records (about 300K records) at first level output for next level drill down report:
The dynamic internal table
<OI_TABLE>has around 300K records with a field component calledBOXmarked as 'X' for those selected lines by the user.The program reads the selected lines from the dynamic internal table (
<OI_TABLE>), compare them to another standard internal table (GT_BSIS) which has around 300K records, whose clearing key value should be the same for both internal tables (1:Ncardinality).It then inserts those common records to the third standard internal table (
GT_L2_DISP) for further processing/display.
Code:
LOOP AT <oi_table> ASSIGNING <oi_line>.
ASSIGN COMPONENT 'BOX' OF STRUCTURE <oi_line> TO <oi_field>.
IF <oi_field> = 'X'.
ASSIGN COMPONENT 'CLEARING_KEY' OF STRUCTURE <oi_line> TO <oi_field>.
LOOP AT gt_bsis WHERE clearing_key = <oi_field>.
MOVE-CORRESPONDING gt_bsis TO gt_l2_disp.
APPEND gt_l2_disp.
ENDLOOP.
ENDIF.
ENDLOOP.
Here, <oi_table> contains data for first level ALV output and GT_BSIS would contain data for 2nd level ALV output.
My understanding :
If we can fill up standard internal table GT_BSIS and marking/passing 'X' to a column (say FLAG) in GT_BSIS, while user is selecting rows from ALV first level output, it would help in performance as ONE LOOP .. ENDLOOP could be avoided.
An indexed internal table may also be an option. Please suggest a way to improve the performance.
NB: our SAP System is ECC, ABAP 7.31, so please do not propose inline code/declaration.