How to incorporate and print several SMARTFORMS in one SPOOL request?

Printing several forms in one spool request


We will see how printed multiple forms may be included in a single spool
request. We will create a number of form pages comprising employees data. Each page
will contain one employee's salary information. The recipe will focus on the important
parts of the program related to Smart Form processing. We assume that an internal table
EMPLOYEE_LIST exists that contain the employee numbers of all personnel to be processed.


1. First, we call the function module SSF_FUNCTION_MODULE_NAME in order to get the
name of the Smart Form function module. The form name is passed to the function
module. The myfunction variable is based on the type RS38l_FNAM (not shown in
the following screenshot):





2. Then appropriate variables are defined for the Smart Form control structure and
output options based on dictionary structures.



3. The function module SSF_OPEN is then called.




4. A loop is run on the internal table employee_list for all employees. For each
employee, the form get_employee_data is called, which fetches the necessary
information of the employee in question and fills the internal table employee_data.
The no_open and no_close fields of the control parameters structure are assigned
the value 'X'. In addition, the tdnewid field of the output options structure is
assigned 'X'.


5. The function module of the Smart Form is then called and necessary data of the
employee provided along with control parameters and output option structures.





6. Finally, the SSF_CLOSE function module is called.

After executing the program, multiple pages of the forms are generated. For each employee,
a separate page appears along with the necessary information.



The call of the function module SSF_OPEN opens the spool job for form printing.
The tdnewid assigned to 'X' creates a new spool request. Within the loop, the no_open
and no_close fields are set to 'X', which ensures the spool request is not opened or closed
within the loop. The function module of the Smart Form is called in the loop and generates
the necessary output of each employee. When all employees are processed, the SSF_CLOSE
function module is called and the spool request is closed.


We can also avoid the usage of the SSF_OPEN and SSF_CLOSE function modules. In this
case, when we program that on the first employee, the spool job is opened and when we
program that on the last employee, the spool job is closed.

No comments:

Post a Comment