The program extract below shows an example of function module calls for the following tasks:
Task |
Function Module |
---|---|
Open spool job |
FP_JOB_OPEN |
Determine form name |
FP_FUNCTION_MODULE_NAME |
Call generated function module of the form |
|
Close spool job |
FP_JOB_CLOSE |
In this example, the parameters CUSTOMER, BOOKINGS, and CONNECTIONS are sent to the form interface, where they must already be defined.
DATA: CUSTOMER TYPE SCUSTOM,
BOOKINGS TYPE TY_BOOKINGS,
CONNECTIONS TYPE TY_CONNECTIONS,
FM_NAME TYPE RS38L_FNAM,
FP_DOCPARAMS TYPE SFPDOCPARAMS,
FP_OUTPUTPARAMS TYPE SFPOUTPUTPARAMS.
* GETTING THE DATA
<data selection>
* PRINT:
* Sets the output parameters and opens the spool job
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
IE_OUTPUTPARAMS = FP_OUTPUTPARAMS
EXCEPTIONS
CANCEL = 1
USAGE_ERROR = 2
SYSTEM_ERROR = 3
INTERNAL_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
<error handling>
ENDIF.
* Get the name of the generated function module
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
I_NAME = '<form name>'
IMPORTING
E_FUNCNAME = FM_NAME.
IF SY-SUBRC <> 0.
<error handling>
ENDIF.
* Language and country setting (here US as an example)
fp_docparams-langu = 'D'.
fp_docparams-country = 'DE'.
* Call the generated function module
CALL FUNCTION FM_NAME
EXPORTING
/1BCDWB/DOCPARAMS = FP_DOCPARAMS
CUSTOMER = CUSTOMER
BOOKINGS = BOOKINGS
CONNECTIONS = CONNECTIONS
* IMPORTING
* /1BCDWB/FORMOUTPUT =
EXCEPTION S
USAGE_ERROR = 1
SYSTEM_ERROR = 2
INTERNAL_ERROR = 3.
IF SY-SUBRC <> 0 .
<error handling>
ENDIF.
* Close the spool job
CALL FUNCTION 'FP_JOB_CLOSE'
* IMPORTING
* E_RESULT =
EXCEPTIONS
USAGE_ERROR = 1
SYSTEM_ERROR = 2
INTERNAL_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
<error handling>
ENDIF.