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 2 times.

Former Member
0 Likes
2,815

hi Abapers,

anyone can plx help me with performance in loop 2 times?

I need something like this:

LOOP AT ti_sbook FROM sbook_index.

READ TABLE ti_spfli BINARY SEARCH.

WHILE sy-subrc = 0.

cont1 = cont1 + 1.

spfli_index = spfli_index + 1.

READ TABLE ti_spfli INDEX spfli_index.

ENDWHILE.

spfli_index = 1.

sbook_index = sbook_index + 1.

ENDLOOP.

obs: I need to read all records.

Regards

Allan Cristian

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,521

Hi Allan,

There should be some common field between TI_SBOOK & TI_SPFLI.


LOOP AT ti_sbook FROM sbook_index.
READ TABLE ti_spfli with key sno = ti_sbool-sno binary search.
ENDLOOP.

BEst regards,

Prashant

8 REPLIES 8
Read only

Former Member
0 Likes
1,521

Hi Allan,

Can you please let us know your requirement exactly?

Satish

Read only

0 Likes
1,521

hi Satish,

I need to read itab2 for each record of itab1.

I excludes no records necessary before.

I need cont for example, how many register is in itab1 from itab2 and how many isn't at each record of itab2.

can be Select with endselect, loop...

I need do it passing for all entries

Regards

Allan Cristian

Message was edited by:

Allan Cristian

Read only

0 Likes
1,521

Allan,

do like this.

loop at itab1 into wa1.

read table itab2 with key f1 = wa1-f1.

if sy-subrc = 0.

cnt1 = cnt1 + 1.

else.

cnt2 = cnt2 + 1.

delete itab1 where f1 = wa1-f1.

endif.

endloop.

write : cnt1,cnt2.

Hope this will help you.

<b><REMOVED BY MODERATOR></b>

Satish

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
1,522

Hi Allan,

There should be some common field between TI_SBOOK & TI_SPFLI.


LOOP AT ti_sbook FROM sbook_index.
READ TABLE ti_spfli with key sno = ti_sbool-sno binary search.
ENDLOOP.

BEst regards,

Prashant

Read only

rodrigo_paisante3
Active Contributor
0 Likes
1,521

Hi, you dont need to pass in full records.

if you want to gain performance check the indexed loop, like this:

LOOP AT bkpf_tab INTO bkpf_lin.

READ TABLE bseg_tab INTO bseg_lin

WITH KEY bukrs = bkpf_lin-bukrs

BINARY SEARCH.

bseg_index = sy-tabix.

IF sy-subrc = 0.

*-- PERFORM EXECUCAO

ENDIF.

WHILE sy-subrc = 0.

bseg_index = bseg_index + 1.

READ TABLE bseg_tab

INTO bseg_lin

INDEX bseg_index.

IF bseg_lin-bukrs <> bkpf_lin-bukrs.

sy-subrc = 99.

ELSE.

*-- PERFORM EXECUCAO

ENDIF.

ENDWHILE.

ENDLOOP.

if you want just to count the values, do the nested loop...

Regards

Read only

Former Member
0 Likes
1,521

Hi Allan,

is your problem got resolved? Reward points for the helpful answers.

Satish

Read only

0 Likes
1,521

hi Satish,

at time it's not solved,

Dont worry, I'll reward for the answers, I'm working at...

<b><REMOVED BY MODERATOR></b>

Regards

Allan Cristian

Message was edited by:

Allan Cristian

Message was edited by:

Alvaro Tejada Galindo

Read only

0 Likes
1,521

Hi Allan,

I think the best way is to go with two loops and check the performance in SE30.

Regards,

Atish