Skip to Content
Author's profile photo Former Member

Why should we use Function Module SSF_FUNCTION_MODULE_NAME to call Smart forms from driver program

As we all know that whenever we create a smart form a function module is create for that to be called from the driver program. If you don’t know then create a smart form using TCode SMARTFORMS. To check the function module name generated for the smart form go to Environment ->Function Module Name as shown below.

A pop up would appear displaying the function module name. 

We can use this function module to call the smart form. But there is a critical logic behind not using this function module directly in driver program.
Whenever we create a smart form and activate it a function module is generated based on a naming convention. Smart forms internally use Number ranges to name the function module whenever we change and activate the smart form. In the above case the FM name is /1BCDWB/SF00000359. The function module for the next new and activated Smart Form would be /1BCDWB/SF00000360.
So when this smart form is transported to other systems a new function module name is generated according to the Number range in that system, then using the function module name directly in the driver program may result into dumps as the function module names is not available in the system. To handle this situation SAP developed Function module SSF_FUNCTION_MODULE_NAME to get the name of the function module for a smart form dynamically. If the form is not active, the FM raises the exception NO_FORM.
Look at the example program to call Smart forms dynamically.

DATA:

fname TYPE rs38l_fnam.

 

call function ‘SSF_FUNCTION_MODULE_NAME’

exporting

   formname                 = ‘ZSMARTFORMS_TRAINING2’

*   VARIANT                  = ‘ ‘

*   DIRECT_CALL              = ‘ ‘

importing

  fm_name                  = fname

* EXCEPTIONS

*   NO_FORM                  = 1

*   NO_FUNCTION_MODULE       = 2

*   OTHERS                   = 3

         .

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.


*Call the Smart form FM using the FNAME as below.
 

CALL FUNCTION FNAME

* EXPORTING

*   ARCHIVE_INDEX              =

*   ARCHIVE_INDEX_TAB          =

*   ARCHIVE_PARAMETERS         =

*   CONTROL_PARAMETERS         =

*   MAIL_APPL_OBJ              =

*   MAIL_RECIPIENT             =

*   MAIL_SENDER                =

*   OUTPUT_OPTIONS             =

*   USER_SETTINGS              = ‘X’

* IMPORTING

*   DOCUMENT_OUTPUT_INFO       =

*   JOB_OUTPUT_INFO            =

*   JOB_OUTPUT_OPTIONS         =

* EXCEPTIONS

*   FORMATTING_ERROR           = 1

*   INTERNAL_ERROR            = 2

*   SEND_ERROR                 = 3

*   USER_CANCELED              = 4

*   OTHERS                     = 5

         .

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.


Hope this helps in clarifying use of SSF_FUNCTION_MODULE_NAME.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Srinivas Kari
      Srinivas Kari

      Great document. A nice explanation of the use of FM SSF_FUNCTION_MODULE_NAME.