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

Former Member
0 Kudos

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

former_member223537
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Allan,

Can you please let us know your requirement exactly?

Satish

0 Kudos

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

0 Kudos

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

former_member223537
Active Contributor
0 Kudos

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

rodrigo_paisante3
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Allan,

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

Satish

0 Kudos

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

0 Kudos

Hi Allan,

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

Regards,

Atish