..3 Printing program
Modify the code of the report Z_SHIPPING_LABEL follows.
In the beginning of program, open workbook bundle, performing VIEWER_BUNDLE_OPEN in the function group ZXLWB.
Several times repeat context filling and calling the function module 'ZXLWB_CALLFORM', thus adding the form to bundle.
In the end of program, finalize workbook bundle, performing VIEWER_BUNDLE_CLOSE in the function group ZXLWB.
Final look of the printing program:
REPORT z_shipping_labels_3.
* declare the context
DATA:
gs_context TYPE zcontext_shipping_label .
* open workbooks bundle
PERFORM viewer_bundle_open IN PROGRAM saplzxlwb .
DO 4 TIMES .
* fill the context
CLEAR gs_context .
CASE sy-index .
WHEN 1 .
gs_context-to_name = 'Dan Tedford' .
gs_context-to_street = '811 Alworth Avenue' .
gs_context-to_town = 'Middlefield' .
gs_context-to_state = 'CA' .
gs_context-to_zip = '98567' .
WHEN 2 .
gs_context-to_name = 'Shane Hamby' .
gs_context-to_street = '852 Ocean View Rd.' .
gs_context-to_town = 'Bayshore' .
gs_context-to_state = 'CA' .
gs_context-to_zip = '94123' .
WHEN 3 .
gs_context-to_name = 'Dr.Henry Albrecht' .
gs_context-to_street = '522 Ravenswood' .
gs_context-to_town = 'East Bayshore' .
gs_context-to_state = 'CA' .
gs_context-to_zip = '93327' .
WHEN 4 .
gs_context-to_name = 'Hugh Molotsi' .
gs_context-to_street = '1980 N.Stonecrest Rd.' .
gs_context-to_town = 'West Middlefield' .
gs_context-to_state = 'CA' .
gs_context-to_zip = '12384' .
ENDCASE .
* add form (workbook) to bundle
CALL FUNCTION 'ZXLWB_CALLFORM'
EXPORTING
iv_formname = 'SHIPPING_LABEL'
iv_context_ref = gs_context
iv_viewer_title = gs_context-to_name " -->> title by name of recipient
EXCEPTIONS
OTHERS = 2.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF .
ENDDO .
* close and show bundle
PERFORM viewer_bundle_close IN PROGRAM saplzxlwb .