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

sub routine in Function module

Former Member
0 Likes
3,971

Hello

i want to create a subroutin in a function module

is it better to do like this


FUNCTION TEST.

perform f_routine using im_bukrs im_werks.

ENDFUNCTION.

form f_routine using im_bukrs im werks.
// here i have to use using import parameter since i wont have access to the import parameter
endform.

or i put the

perform in another include let's say include01 but in this way will i have access to my import parameter directly without the USING

1 ACCEPTED SOLUTION
Read only

Former Member
1,672
FUNCTION TEST.
 
perform f_routine using im_bukrs im_werks.
 
ENDFUNCTION.

you click on the routine and it will propose the include XXXXF01

then it will create the Form some thing like below. since you are passing params to the routine, here you can work the parameters.

form f_routine using  im_bukrs type bukrs
                              im werks type werks_d. 
// here i have to use using import parameter since i wont have access to the import parameter
endform.

7 REPLIES 7
Read only

Former Member
0 Likes
1,672

Hello,

Put your form in include01. Declare valriables with same type as that of your import paramters in TOP include. pass your import parameter values to these varibles before calling the perform. now you can use those variables in your form.

Read only

Former Member
0 Likes
1,672

Hi Newbie,

I dont think there is any performance issue or any kind of problem in your code you can use perform as you have used.

Thanks

Sudharshan

Read only

former_member217544
Active Contributor
0 Likes
1,672

Hi Newbie,

If you are askign about the parameters used in the subroutines form (im_bukrs and im_werks), you can very well use them in your form as they are getting passed to the form with "USING" statement.

But one thing you need to chnage in the form statement to use this is:

if im_bukrs is of type bukrs

and im_werks if of type werks

then you have to mention that in your form as

form f_routine using im_bukrs type bukrs

im_ werks type werks.

endform.

and If you are asking about the Function module parameters to use in form the you have to declare separately in the program.

Hope this will help

Reagrds.

Swarna Munukoti.

Edited by: Swarna Munukoti on Jul 24, 2008 8:24 AM

Edited by: Swarna Munukoti on Jul 24, 2008 8:25 AM

Read only

0 Likes
1,672

what i really want to know it what is the difference when ceating the subroutine in the FM itself just below the ENDFUNCTION

and the differenct when creating the subroutine in the include01

the only difference i see it that the first one i have to put USING since i can have access to my import parameter

while in the second way i have access to all my global variables including the import parameter

Read only

Former Member
0 Likes
1,672

If ur subroutine is used by 1 Fm then u can put it with the FM definition. like:

FUNCTION TEST.

perform f_routine using im_bukrs im_werks.

ENDFUNCTION.

form f_routine using im_bukrs im werks.

// here i have to use using import parameter since i wont have access to the import parameter

endform.

But if it is going to be used by multiple Fms then put it in a separate include program.

and if ur FM interface is global then u can access the import parameter(s) of ur FM directly within the subroutine without the USING clause. It is not dependent on where ur subroutine is defined.

Regards,

joy.

Read only

former_member195383
Active Contributor
0 Likes
1,672

Hi ...

Check the function grup inside which you have defined this FM. There will be other FMs.

If you want other FMs to use this subroutine, then declare the subrouting in an include of the function grup,

Other wise you can declare the subroutine as you have written.

Read only

Former Member
1,673
FUNCTION TEST.
 
perform f_routine using im_bukrs im_werks.
 
ENDFUNCTION.

you click on the routine and it will propose the include XXXXF01

then it will create the Form some thing like below. since you are passing params to the routine, here you can work the parameters.

form f_routine using  im_bukrs type bukrs
                              im werks type werks_d. 
// here i have to use using import parameter since i wont have access to the import parameter
endform.