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: 
Read only

Loop in normal ABAP vs AMDP

selva123
Explorer
0 Likes
6,123

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 ;

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
Read only

Sandra_Rossi
Active Contributor
5,117

Loop to do what?

Read only

matt
Active Contributor
5,117

sandra.rossi A bim bam boom.

Read only

Sandra_Rossi
Active Contributor
5,117

One possibility (SQLScript of course):

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

selva123
Explorer
0 Likes
5,117

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

Read only

Sandra_Rossi
Active Contributor
5,117

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?