2022 Jul 15 10:02 PM
Hi guys
When going through the loop (I put the attachment) it takes a while and there is a time out error. I researched ways to improve performance and I wanted to know if you can give suggestions by looking at the attached code.
Thanks loop.txt
2022 Jul 16 6:34 AM
Start by moving your SELECT outside the LOOP.
After that, use SAT to know what needs to be optimized.
2022 Jul 16 6:30 PM
The code is complicated.
For example, there are two SELECT FOR ALL ENTRIES : you should ensure that there are no duplicates regarding the WHERE clause
* SELECT bukrs belnr gjahr budat xblnr cpudt cputm usnam tcode stblg bktxt kursf glvor awtyp awkey
* APPENDING TABLE t_bkpf*
* FROM bkpf
* FOR ALL ENTRIES IN t_ztbfi905
* WHERE bukrs EQ t_ztbfi905-bukrs_bsik
* AND belnr EQ t_ztbfi905-n_doc
* AND gjahr EQ t_ztbfi905-ano_n_doc.
t_ztbfi905_tmp[] = t_ztbfi905[].
SORT t_ztbfi905_tmp[] BY bukrs_bsik n_doc ano_n_doc.
DELETE ADJACENT DUPLICATES FROM t_ztbfi905_tmp COMPARING bukrs_bsik n_doc ano_n_doc.
SELECT bukrs belnr gjahr budat xblnr cpudt cputm usnam tcode stblg bktxt kursf glvor awtyp awkey
APPENDING TABLE t_bkpf*
FROM bkpf
FOR ALL ENTRIES IN t_ztbfi905_tmp
WHERE bukrs EQ t_ztbfi905_tmp-bukrs_bsik
AND belnr EQ t_ztbfi905_tmp-n_doc
AND gjahr EQ t_ztbfi905_tmp-ano_n_doc.
2022 Jul 16 7:27 PM
Hi ronaldo.aparecido,
you use several loops and combine them. Please check if you can join them in the SQL query.
If you need lookup tables, try to use hash tables with unique keys.
Regards
Thorsten
2022 Aug 05 2:35 AM
Before using FOR ALL ENRIES you check if internal table has value or not?