Application Development 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: 

Loop in normal ABAP vs AMDP

selva123
Explorer
0 Kudos

I write simple SELECT on MARA table in AMDP and populate an internal table with MARA data. I loop MARA internal table outside the AMDP and write some logic inside the loop. I can loop MARA internal table in AMDP itself using the statement FOR and write the same logic. Which will give better performance?

Looping Internal table in AMDP using FOR

DECLARE lv_index "$ABAP.type( sy-index )";     
DECLARE lv_matnr "$ABAP.type( matnr )";     
lt_mara = SELECT * FROM mara LIMIT 100;     
for lv_index in 1..record_count( :lt_mara ) do         
lv_matnr = :lt_mara.matnr[ lv_index ];         
-- Write all required logic      
END FOR ;
5 REPLIES 5

Sandra_Rossi
Active Contributor

Loop to do what?

matt
Active Contributor

sandra.rossi A bim bam boom.

Sandra_Rossi
Active Contributor
0 Kudos

One possibility (SQLScript of course):

    DECLARE pos INTEGER DEFAULT 0;
    DECLARE i INTEGER;
    FOR i IN 1..10 DO
        pos = :pos + 1;
    END FOR;

selva123
Explorer
0 Kudos

Sorry. My question was not detailed. I have rewritten my question. Please provide your valuable comments.

Sandra_Rossi
Active Contributor

So, what takes longer between

ABAP > DBI > network > DB execution > network > DBI > ABAP

and

ABAP > DBI > network > DB procedure > DB execution > DB procedure > network > DBI > ABAP

?

I guess the time depends on the volume of network traffic.

But is it significant compared to DB execution time?