2007 Aug 29 7:04 AM
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
2007 Aug 29 7:08 AM
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
2007 Aug 29 7:11 AM
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>
2007 Aug 29 7:11 AM
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.
2007 Aug 29 7:11 AM
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
2007 Aug 29 7:14 AM
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.
2007 Aug 29 7:15 AM
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.
2007 Aug 29 7:51 AM
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.