Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Improve performance code

ronaldo_aparecido
Contributor
0 Kudos
546

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

4 REPLIES 4

Sandra_Rossi
Active Contributor
389

Start by moving your SELECT outside the LOOP.

After that, use SAT to know what needs to be optimized.

chaouki_akir
Contributor
389

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.

ThorstenHoefer
Active Contributor
389

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

former_member808116
Participant
0 Kudos
389

Before using FOR ALL ENRIES you check if internal table has value or not?