Calling Smartform into our Driver Program

  • Whenever we execute our smartform, As we can see, it directly navigates to the SE37 ( function Builder : initial screen ).



  • So, for our each smartform, SAP will automatically create a function module at the runtime.

Note :-

  • If you change the contents of the smartform, then it is possible that the name of the function module may change at the runtime, so it is not a good practice to use the same function module of the smartform every time.

Calling Our Employee Details Smartform to our Driver Program :-

  • Step 1 :- Create a executable program in ABAP Editor ( SE38 ) transaction code.

  • Step 2 :- Since, we are passing employee id as an input to our smartform so, for that we will create a parameter for the same.



  • Step 3 :- Since, we have already discussed that for our smartform, SAP automatically creates a function module, so we can use it directly in our program.




Execute the Program :-

  • Press F8 to execute the code and pass employee number = 103 as input and press f8.




How can we know the name of our function module using the name of the smartform ?

  • It is possible that someone can ask you that how can I know the name of my function module, if I have the name of smartform.

  • For knowing the name of the function module, we use

    SSF_FUNCTION_MODULE_NAME



    • Here, using FM_NAME we can import the name of our function module.
    • and we can pass it instead of the function module for our smartform.

Code :-

*&---------------------------------------------------------------------*
*& Report ZAR_SMARTFORM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZAR_SMARTFORM.

PARAMETERS : p_emp_id type ZAR_EMPLOYEE_ID.

DATA : lv_function_module type RS38L_FNAM.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname                 = 'ZAR_SMARTFORM'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 IMPORTING
   FM_NAME                  = lv_function_module
 EXCEPTIONS
   NO_FORM                  = 1
   NO_FUNCTION_MODULE       = 2
   OTHERS                   = 3
          .

CALL FUNCTION lv_function_module
  EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
    p_emp_id                   = p_emp_id
* 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
          .

Execute the code :-





Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming

Introduction to SAP