‎2008 Jul 04 5:44 AM
Can I use Perform and Form inside a function module.
I have created one function in se37 and I am using perform and form in its source code, but the system is giving me the following error msg.
Incorrect nesting: Before the statement "FORM", the structure
introduced by "FUNCTION" must be concluded by "ENDFUNCTION" . . . . . .
. .
‎2008 Jul 04 5:45 AM
hi..
use the form ....endform...after the endfuction...statement..
In case of functions...u have to write the subroutine in that way only....
Edited by: Rudra Prasanna Mohapatra on Jul 4, 2008 6:45 AM
‎2008 Jul 04 5:51 AM
Hi,
You can write a perform statement in the FM. Write the Subroutene Perform < Subroutene Name>. Double click on the Subroutene the controle would take you to a new include.
Hope this will solve your problem.
Reward with out fail if found use full.........!
Cheers,
Rama.
‎2008 Jul 04 6:17 AM
But I am using perform and form in the source code that is present in se37 only
‎2008 Jul 04 6:19 AM
if you want it in the same Fm, write the form end form after ENDFUNCTION. and the perform should be between FUNCTION-ENDFUNCTION.
regards,
madhu
‎2008 Jul 04 5:49 AM
hi,
u can do it as rudra said. or u can put your form-endform in Include under the Fn.grp.
regards,
madhu
‎2008 Jul 04 5:50 AM
Hi Prakash,
Give the subroutines (form ....endform) after end function.
Regards,
Charumathi.B
‎2008 Jul 04 5:50 AM
Hi ,
You can do that .. but your form .. Endform should be after endfunction..
‎2008 Jul 04 5:52 AM
U can write performs/ subroutine calls in function module and declare an inlcude and write the forms/subroutine code inside that.
‎2008 Jul 04 6:09 AM
Hello Prakash,
Yes, of course you can but make sure you write the code between the FORM and ENDFORM statements in a separate Include program provided in the Main Program (menubar GoTo->Main Program) whose name ends in FUGRF01.
See example below for detailed explanation:
FUNCTION zpa_pa_wb_outbound_empl_iface .
PERFORM convert_dates CHANGING lt_wb_file.
........[ ]
........[ ]
........[ ]
ENDFUNCTION.
From this FM, click on Menubar, GoTo->Main Program. Here you'll see something like this:
*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE lzpa_pa_qh_wb_empl_fugrtop. " Global Data
INCLUDE lzpa_pa_qh_wb_empl_fugruxx. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZPA_PA_QH_WB_EMPL_FUGRF... " Subprograms
* INCLUDE LZPA_PA_QH_WB_EMPL_FUGRO... " PBO-Modules
* INCLUDE LZPA_PA_QH_WB_EMPL_FUGRI... " PAI-Modules
Delete the comment (*) of the first line under "User-defined Include-files" and change it to the following:
INCLUDE LZPA_PA_QH_WB_EMPL_FUGRF01.
Double click on the name of this include to create it, then write your own routine in this include, see below the example the coding in LZPA_PA_QH_WB_EMPL_FUGRF01:
*&---------------------------------------------------------------------*
*& Form CONVERT_DATES
*&---------------------------------------------------------------------*
FORM convert_dates CHANGING pt_wb_file TYPE tty_wb_empl.
FIELD-SYMBOLS: <fline> TYPE ty_wb_empl_struc.
DATA: lv_wb_begda TYPE begda,
lv_wb_endda TYPE endda.
LOOP AT pt_wb_file ASSIGNING <fline>.
lv_wb_begda = <fline>-start_date.
lv_wb_endda = <fline>-end_date.
<fline>-start_date = zcl_hr_utilities=>conv_date( lv_wb_begda ).
<fline>-end_date = zcl_hr_utilities=>conv_date( lv_wb_endda ).
ENDLOOP.
ENDFORM. " CONVERT_DATES
Now, Activate all your Includes including your main program and function group and module.
This is the correct way of writing a subroutine within a function module.
Hope this helps,
Cheers,
Sougata.