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: 

select stmt

0 Kudos

Hi,

Can any one suggest me how to place the below select statement in a subroutine currently which was executing in a loop .

select single kappl objky kschl into wa_otype

from nast

where kappl = wa_vbrk-kappl

and objky = wa_vbrk-objky.

wa_vbrk-kschl = wa_otype-kschl.

we can get wa_... from the loop.

instead of writing multiple time the same code i want to move this to subroutine.

Regards,

Cheritha

7 REPLIES 7

former_member188827
Active Contributor
0 Kudos

loop at itab into wa.

perform selection using wa.

endloop.

when u double click on the perform statement, it 'll create a form.

between form and endform statements copy ur code of select.

plz reward points if it helps

Message was edited by:

abapuser

varma_narayana
Active Contributor
0 Kudos

Hi ..

from Performance point of view It is better to Write this select statement directly in the LOOP instead of calling a subroutine.

so no need to change ur code..

<b>Reward if Helpful</b>

Former Member
0 Kudos

Hi,

there is no need of writing the code in the way u are expecting.the way u have written is the efficient one...

<b>reward if helpful</b>

rgds,

bharat.

dev_parbutteea
Active Contributor
0 Kudos

Hi,

it think that it wud be better for performance if u do the select before the loop by using select for all entries.

then in loop, you just do a read statement.

Regards

former_member198275
Active Contributor
0 Kudos

• Values can be passed through PERFORM to FORM.

• Giving the flexibility to use the same subroutine multiple number of times.

Syntax1: PERFORM <XXXX> using <YYY>

changing <MMM>

FORM <XXXX> using <YYY> like <ZZZ>

changing <MMM> like <NNN> - Pass by reference

OR

FORM <XXXX> using value (YYY) like <ZZZ> - Pass by value, creates another copy of the variable.

Example1:

PERFORM date-invert using in-date

Changing out-date

FORM date-invert using in-date like datum

Syntax2: PERFORM function-name(program) IF FOUND.

Example2: PERFORM HEADER(FORMPOOL) IF FOUND.

Former Member
0 Kudos

Hello Cheritha,

Writing Select statement in a loop is not suggestable... it will kill performance.

-


use SELECT... FOR ALL ENTRIES IN itab. It will fetch all the related data for itab. Don't use loop...

any way i'm giving procedure for that also.

loop at ....

perform routine.

endloop.

form routine.

select single kappl objky kschl into wa_otype

from nast

where kappl = wa_vbrk-kappl

and objky = wa_vbrk-objky.

wa_vbrk-kschl = wa_otype-kschl.

we can get wa_... from the loop.

endform.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Former Member
0 Kudos

Hi Cheritha,

Try the below code.

Loop At t_vbrk into wa_vbrk.

Perform sub_select using wa_vbrk

changing wa_otype.

Endloop.

Form sub_select p_wa_vbrk type ty_vbrk

p_wa_otype type ty_otype.

select single kappl objky kschl into p_wa_otype

from nast

where kappl =p_ wa_vbrk-kappl

and objky = p_wa_vbrk-objky.

wa_vbrk-kschl = p_wa_otype-kschl.

EndFORM.

The p_wa_otype will be replicate as wa_otype inthe loop.

Thanks.