After we created a smartforms in Part I. Now we will going to create a Z driver program for our smartforms
2. Paste the sample code below
* Program Title : Demo Driver Program for Smart form
* Program Description: Demo Driver Program for smart form to print the PR Number.
* we will call here the smartform and pass a parameter
* SAP R/3 Module : Material Management (MM)
* SAP R/3 version : SAP R/3 Enterprise / Basis Release : 700
*** ------------------------------------------------------------------------------- ***
DATA : FM_NAME TYPE RS38L_FNAM. " Name of the Function Module
*-------------- START OF SELECTION SCREEN Design----------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: PR_NO LIKE EBAN-BANFN OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B1.
*-------------- END OF SELECTION SCREEN Design------------------------------*
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZPASS_PARAMETER' " Pass the smartform Name
IMPORTING
FM_NAME = FM_NAME " Name of Function Module
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.
* ----------------------------- FORMS ------------------
*Take Note: In the exporting, the PR_Number here is the parameter we defined in smartform
* Global settings then in the form Interface
* and PR_No is the parameter here in driver program that will going to pass in PR_Number
CALL FUNCTION FM_NAME
EXPORTING
PR_NUMBER = PR_NO
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE S000(ZSD_INV).
ENDIF.
3. Save and Activate your program
4.Click Direct processing
5. Enter parameter
6. Execute
Thanks!!! :D
ReplyDelete