A SIMPLE PROGRAM TO CONVERTING SCRIPT FORM OUTPUT INTO PDF FORMATE.
*&---------------------------------------------------------------------*
*& Report ZSCRIPT12
*&---------------------------------------------------------------------*
REPORT ZSCRIPT12.
data: form_name(20) type c.
DATA: IT_OTFDATA TYPE STANDARD TABLE OF ITCOO,
IT_TLINE TYPE STANDARD TABLE OF TLINE,
W_OPTIONS LIKE ITCPO .
W_OPTIONS-TDGETOTF = 'X'.
form_name = 'ZSCRPT_PDF'.
*data retreval
* open layoout
call function 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
* ARCHIVE_INDEX = ARCHIVE_INDEX
* ARCHIVE_PARAMS = ARCHIVE_PARAMS
DEVICE = 'PRINTER'
DIALOG = SPACE
FORM = form_name
* LANGUAGE = SY-LANGU
OPTIONS = W_OPTIONS
* MAIL_SENDER = MAIL_SENDER
* MAIL_RECIPIENT = MAIL_RECIPIENT
* MAIL_APPL_OBJECT = MAIL_APPL_OBJECT
* RAW_DATA_INTERFACE = '*'
* SPONUMIV = SPONUMIV
* IMPORTING
* LANGUAGE = LANGUAGE
* NEW_ARCHIVE_PARAMS = NEW_ARCHIVE_PARAMS
* RESULT = RESULT
* EXCEPTIONS
* CANCELED = 1
* DEVICE = 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
* CODEPAGE = 11
* OTHERS = 12
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* processing logic
* display data on to layout
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SOLD'
FUNCTION = 'APPEND'
TYPE = 'BODY'
WINDOW = 'SOLD'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'START'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN_DATA'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SOLD'
* FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* close layout
call function 'CLOSE_FORM'
* IMPORTING
* RESULT = RESULT
* RDI_RESULT = RDI_RESULT
TABLES
OTFDATA = IT_OTFDATA
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
DATA: BIN_FILESIZE TYPE I.
call function 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* BIN_FILE = BIN_FILE
tables
otf = IT_OTFDATA
lines = IT_Tline
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 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.
DATA: filename type string.
filename = 'c:\TEST\test.pdf'.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE = BIN_FILESIZE
filename = filename
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH = FILELENGTH
tables
data_tab = it_tline
* FIELDNAMES = FIELDNAMES
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* end.
*&---------------------------------------------------------------------*
*& Report ZSCRIPT12
*&---------------------------------------------------------------------*
REPORT ZSCRIPT12.
data: form_name(20) type c.
DATA: IT_OTFDATA TYPE STANDARD TABLE OF ITCOO,
IT_TLINE TYPE STANDARD TABLE OF TLINE,
W_OPTIONS LIKE ITCPO .
W_OPTIONS-TDGETOTF = 'X'.
form_name = 'ZSCRPT_PDF'.
*data retreval
* open layoout
call function 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
* ARCHIVE_INDEX = ARCHIVE_INDEX
* ARCHIVE_PARAMS = ARCHIVE_PARAMS
DEVICE = 'PRINTER'
DIALOG = SPACE
FORM = form_name
* LANGUAGE = SY-LANGU
OPTIONS = W_OPTIONS
* MAIL_SENDER = MAIL_SENDER
* MAIL_RECIPIENT = MAIL_RECIPIENT
* MAIL_APPL_OBJECT = MAIL_APPL_OBJECT
* RAW_DATA_INTERFACE = '*'
* SPONUMIV = SPONUMIV
* IMPORTING
* LANGUAGE = LANGUAGE
* NEW_ARCHIVE_PARAMS = NEW_ARCHIVE_PARAMS
* RESULT = RESULT
* EXCEPTIONS
* CANCELED = 1
* DEVICE = 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
* CODEPAGE = 11
* OTHERS = 12
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* processing logic
* display data on to layout
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SOLD'
FUNCTION = 'APPEND'
TYPE = 'BODY'
WINDOW = 'SOLD'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'START'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN_DATA'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SOLD'
* FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES = PENDING_LINES
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* close layout
call function 'CLOSE_FORM'
* IMPORTING
* RESULT = RESULT
* RDI_RESULT = RDI_RESULT
TABLES
OTFDATA = IT_OTFDATA
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
DATA: BIN_FILESIZE TYPE I.
call function 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* BIN_FILE = BIN_FILE
tables
otf = IT_OTFDATA
lines = IT_Tline
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 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.
DATA: filename type string.
filename = 'c:\TEST\test.pdf'.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE = BIN_FILESIZE
filename = filename
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH = FILELENGTH
tables
data_tab = it_tline
* FIELDNAMES = FIELDNAMES
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* end.
No comments:
Post a Comment