* ------------------------------------------------- ----------------------
* Program ID: ZTEST904
* Program name: ZTEST904
* ------------------------------------------------- ----------------------
* CREATED DATE: 2004/09/04
* Created by: LG
* Description: This program is learning how to call through the program
* The Script screen that has been done to generate a report.
* ------------------------------------------------- ----------------------
* Modification:
* Date Modified Modified by Transport Request Description
* 2004/09/18 LG Version: 01/01 Learning
* ------------------------------------------------- ----------------------
Report ztest904.
* Define the table that needs to be used
******************************************************
Tables: MSEG,
Mara,
MKPF.
* Define an internal table (with the header)
******************************************************
Data: Begin of Itab Occurs 0,
A Like mseg-mblnr,
B Like mseg-zeile,
END OF ITAB.
* Insert some data used.
******************************************************
DO 30 Times.
ITAB-a = 'Test Data'.
ITAB-B = SY-INDEX.
Append itab.
Enddo.
* Display screen data and display the above print button. User Click to print
* Then call the printed Script. Displays the data that promises.
******************************************************
* Initialization
******************************************************
INITIALIZATION.
* At Selection-Screen.
******************************************************
At Selection-Screen.
* Start-of-selection
******************************************************
Start-of-selection.
Set Pf-Status 'ZTEST_904'.
Perform print_itab Tables itab.
* AT User-Command.
******************************************************
AT User-Command.
Case Sy-Ucomm.
WHEN 'user_print'.
Write: / 'Button Clikcked'.
Perform Open_Form.
Perform Start_form.
DO 50 TIMES.
Perform write_form using '' main '' set'.enddo.
Perform end_form.
Perform close_form.
Endcase.
* TOP-OF-PAGE.
******************************************************
TOP-OF-PAGE.
* End-of-page.
******************************************************
END-OF-PAGE.
* & ------------------------------------------------ ----------------------
* & Form: Print_itab
* & ------------------------------------------------ ----------------------
*
* ------------------------------------------------- ----------------------
*
* ------------------------------------------------- ----------------------
* Form Print_itab Tables JTAB LIKE ITAB [].
Form Print_itab Tables JTAB Structure ITAB.
Loop at JTAB.
Write: / JTAB-A, 10 JTAB-B.
Endloop.
ENDFORM.
Form Print_page.
ENDFORM.
Form Open_FORM.
Call function 'open_form'
Exporting
* Application = 'TX'
* Archive_index =
* Archive_Params =
Device = 'printer'
* Dialog = 'x'
Form = 'ZTEST904'
Language = SY-LANGU
* Options =
* Mail_sender =
* Mail_recipient =
* Mail_Appl_Object =
* Raw_data_interface = '*'
* Importing
* Language =
* New_archive_params =
* Result =
EXCEPTIONS
Canceled = 1DEvice = 2
Form = 3
Options = 4
Unclosed = 5
Mail_Options = 6
Archive_ERROR = 7
INVALID_FAX_NUMBER = 8
More_params_needed_in_batch = 9
SPOOL_ERROR = 10
Others = 11
.
IF SY-SUBRC <> 0.
Message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
Form close_form.
Call function 'close_form'
* Importing
* Result =
* RDI_RESULT =
* Tables
* OTFDATA =
EXCEPTIONS
Unidened = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
Send_error = 3
SPOOL_ERROR = 4
Others = 5
.
IF SY-SUBRC <> 0.
Message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM START_FORM.
Call function 'start_form'
Exporting
* Archive_index =
Form = 'ZTEST904'
* Language = ''
StartPage = 'frist'
* Program = ''
* Mail_Appl_Object =
* Importing
* Language =
EXCEPTIONS
Form = 1
Format = 2
Unended = 3
Unopened = 4
Unused = 5
SPOOL_ERROR = 6
Others = 7.
IF SY-SUBRC <> 0.
Message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
Form end_form.
Call function 'end_form'
* Importing
* Result =
EXCEPTIONS
Unidened = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SPOOL_ERROR = 3
Others = 4
.
IF SY-SUBRC <> 0.
Message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM WRITE_FORM USING ELE WIN FUNC.
Call function 'write_form'
Exporting
ELEMENT = ELE
Function = func
* Type = 'body'
WINDOW = WIN
* Importing
* Pending_lines =
EXCEPTIONS
ELEMENT = 1
Function = 2
TYPE = 3
Unopened = 4
Unstearted = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
Others = 9
.
IF SY-SUBRC <> 0.
Message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.