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

RE: avoid the select statements in loop

Former Member
0 Likes
923

Hi all,

Plz suggest me how to avoid the select statement in loop ?

any alternative is there?

loop at t_dfkkop.

clear dfkkko.

if not t_dfkkop-augbl is initial and

t_dfkkop-xragl is initial.

select single * from dfkkko

where opbel = t_dfkkop-augbl.

if sy-subrc = 0 and

dfkkko-blart = 'A3'.

delete t_dfkkop.

continue.

endif.

endif.

clear : w_augdt, w_stdat, w_process.

select max( augdt ) max( stdat )

into (w_augdt, w_stdat)

from dfkkrapt where opbel = t_dfkkop-opbel

and opupw = t_dfkkop-opupw

and opupk = t_dfkkop-opupk

and stdat ge w_clrfr

and stdat le w_clrto

group by opbel opupw opupk augdt stdat.

endselect.

8 REPLIES 8
Read only

Former Member
0 Likes
887

outside the loop .

use for all entries for table dfkkko ....... in the loop use read statement .

like that you will populate the data.

Read only

narin_nandivada3
Active Contributor
0 Likes
887

Hi,

Where exactly the ENDLOOP is placed? Can you tell that?

- Narin.

Read only

0 Likes
887

After the endselect two performs are there ,in these performs also too many select statements are used ,but those taking less time.

after that ENDLOOP is there.

Read only

0 Likes
887

Have you solved the issue?

Read only

0 Likes
887

not yet solved.

Read only

Former Member
0 Likes
887

Hi

Create an internal Table it_dfkkko with ur required fields.

then

select single field

into table it_dfkkko

from dfkkko

where opbel = t_dfkkop-augbl.

loop at t_dfkkop.

if not t_dfkkop-augbl is initial and

t_dfkkop-xragl is initial.

read table it_dfkkko with key field = t_dfkkop-field.

if sy-subrc = 0 and

dfkkko-blart = 'A3'.

delete t_dfkkop.

continue.

endif.

endif.

clear : w_augdt, w_stdat, w_process.

select max( augdt ) max( stdat )

into (w_augdt, w_stdat)

from dfkkrapt where opbel = t_dfkkop-opbel

and opupw = t_dfkkop-opupw

and opupk = t_dfkkop-opupk

and stdat ge w_clrfr

and stdat le w_clrto

group by opbel opupw opupk augdt stdat.

endselect.

Read only

0 Likes
887

really your reply helps me a lot.

Thank you for your due response.

Regards,

sam.

Read only

Former Member
0 Likes
887

Hi,

Please add

select single field

into table it_dfkkko

from dfkkko

for all entries in table t_dfkkop

where opbel = t_dfkkop-augbl.