|
SAPScripts Print Program Structure
and Function
The print program is used to print forms. The program retrieves the necessary data from database tables, defines the order of in which text elements are printed, chooses a form for printing and selects an output device and print options. Function modules in a print program: When you print a form you must use
the statements OPEN_FORM and CLOSE_FORM. To combine forms into a single
spool request use START_FORM and END_FORM.
Structure of a print program * Read data
SELECT *
* Open form printing - Must be called
before working with any of the other form function modules.
* To begin several identical forms
containing different data within a single spool request, begin each form
using START_FORM, and end it using END_FORM
* Write text elements to a window
of the form
* Ends spool request started with
START_FORM
* Closes form printing
OPEN_FORM function Syntax: CALL FUNCTION 'OPEN_FORM' * EXPORTING
* IMPORTING
* EXCEPTIONS
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. Some important parameters:
CLOSE_FORM function CALL FUNCTION 'CLOSE_FORM' * IMPORTING
* EXCEPTIONS
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. Parameters:
WRITE_FORM function CALL FUNCTION 'WRITE_FORM' * EXPORTING
* IMPORTING
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. Some important parameters:
Example of how to use the WRITE_FORM function module together with a script. Form layout of the MAIN window /E INTRODUCTION
/E ITEM_HEADER
/E ITEM_LINE
/E CLOSING_REMARK The print program * Writing INTRODUCTION CALL FUNCTION 'WRITE_FORM' EXPORTING
EXCEPTIONS
* Writing ITEM_HEADER CALL FUNCTION 'WRITE_FORM' EXPORTING
EXCEPTIONS
OTHERS
= 8
* Set ITEM_HEADER into TOP area of main window for subsequent pages CALL FUNCTION 'WRITE_FORM' EXPORTING
EXCEPTIONS
* Write ITEM_LINE LOOP AT ..... CALL FUNCTION 'WRITE_FORM'
EXPORTING
EXCEPTIONS
ENDLOOP. * Delete ITEM_HEADER from TOP area of main window CALL FUNCTION 'WRITE_FORM' EXPORTING
EXCEPTIONS
* Print CLOSING_REMARK CALL FUNCTION 'WRITE_FORM' EXPORTING
EXCEPTIONS
START_FORM function CALL FUNCTION 'START_FORM' * EXPORTING
* IMPORTING
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. END_FORM function CALL FUNCTION 'END_FORM' * IMPORTING
* EXCEPTIONS
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. CONTROL_FORM function The CONTROL_FORM function module allows you to create SapScript control statements from within an APAB program. Syntax: CALL FUNCTION 'CONTROL_FORM' EXPORTING
* EXCEPTIONS
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO
ENDIF. Example: Protecting the text element ITEM_LINE CALL FUNCTION 'CONTROL_FORM' EXPORTING
CALL FUNCTION 'WRITE_FORM'
CALL FUNCTION 'CONTROL_FORM'
|
|
Fast Links:
ABAP Books
SAP Scripts Tips
Best regards,
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|