‎2007 Oct 17 3:42 PM
Hi,
How we can convert functional module to subroutine.
for example i want to convert gui_download ( function module ) to
PERFORM GUI_DOWNLOAD.
Can you pls elaborate this using some code sample.
Regards,
Parnith.
‎2007 Oct 17 3:52 PM
It's easy
perform gui_download using filename ...etc.
form gui_download using p_filename type ....etc.
call function 'gui_download'
filename = p_filename
...etc.
Kind regards, Rob Dielemans
‎2007 Oct 17 3:52 PM
It's easy
perform gui_download using filename ...etc.
form gui_download using p_filename type ....etc.
call function 'gui_download'
filename = p_filename
...etc.
Kind regards, Rob Dielemans
‎2007 Oct 17 3:54 PM
Hi,
You just need to paste all the code from that FM to subroutine. But doing this is not recommended.
FM- When the functionality can be used in many programs. Big logic
Subroutine - To modularise the code. Same functionality within progra.
Regards,
Atish
‎2007 Oct 17 4:06 PM
Hi ,
Thanks for your reply.
can you pls let me know how actually we need to define parameters in that function module to parameters of subroutine.
And also how we need to code for exceptions in subroutine.
Can you pls explain me by taking one small example.( converting gui_download FM to
Form GUI_Download.
Regards,
Parnith.
‎2007 Oct 17 4:10 PM
First of all it is not a good idea to convert a fm into a subroutine. Why do you need to duplicate code?
If at all you want to do that, you can see function module import parameter declaration and declare your parameters into subroutine in similar fashion.
Like GUI_DOWNLOAD has import parameter FILENAME declared as string, you can do the same in your routine.
For exceptions, as you are handling this in routine, you need to use message command. Either you can store all messages into a internal table and display at the end or you can show error message and stop processing.
Hope this helps.
ashish
‎2007 Oct 17 4:11 PM
Hi,
I am not in front of system so can't explain using code.
But you have USING CHANGING and TABLES in subroutines whichcan be linked to IMPORTING EXPORTING/CHANGING TABLES in FM.
And for exceptions you need to write your error message using MESSAGE.
Regards,
Atish