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

Perform under function

Former Member
1,906

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" . . . . . .
. .

9 REPLIES 9
Read only

former_member195383
Active Contributor
0 Likes
1,323

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

Read only

0 Likes
1,323

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.

Read only

0 Likes
1,323

But I am using perform and form in the source code that is present in se37 only

Read only

0 Likes
1,323

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

Read only

Former Member
0 Likes
1,323

hi,

u can do it as rudra said. or u can put your form-endform in Include under the Fn.grp.

regards,

madhu

Read only

Former Member
0 Likes
1,323

Hi Prakash,

Give the subroutines (form ....endform) after end function.

Regards,

Charumathi.B

Read only

sachin_mathapati
Contributor
0 Likes
1,323

Hi ,

You can do that .. but your form .. Endform should be after endfunction..

Read only

Former Member
0 Likes
1,323

U can write performs/ subroutine calls in function module and declare an inlcude and write the forms/subroutine code inside that.

Read only

Sougata
Active Contributor
0 Likes
1,323

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.