on 2024 Jan 31 4:05 PM
I have a problem with performance in transformation, I found LOOP inside the LOOP, which I read can affect performance. I'm trying to change it, but I keep getting errors. Do you have an idea how I can eliminate one loop to improve the performance?
LOOP AT it_dyn INTO wa_dyn WHERE chanm = 'LCCTR'.
SELECT *
FROM edir
INTO TABLE it_edir1
WHERE iobjnm = 'LCCTR' AND
dateto = '99991231'
hienm = wa_dyn-low.
IF sy-subrc = 0.
LOOP AT it_dir1 INTO ls_dir1.
APPEND ls_dir1 TO it_dir.
ENDLOOP.
ENDIF.
ENDLOOP.
Request clarification before answering.
Firstly, it is best practice not to use select statement inside a loop. You can populate another internal table where CHANM = 'LCCTR'. Best way to do it is copy IT_DYN to IT_DYN_2 and then delete IT_DYN_2 where CHANM <> 'LCCTR' and use for all entries to get the records in the select statement based on entries in IT_DYN_2.
Secondly, if you are just copying records from one internal table to another with same structure, you can use IT_DIR[] = IT_DIR1[].
Using any of the above mentioned points, you can improve the performance drastically. I am in favor of using both if possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
11 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.