Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Author: Fareedas

Date: 25/ 04/2008

Introduction:

A SIMPLE PROGRAM TO CONVERTING SCRIPT FORM OUTPUT INTO PDF FORMATE.

Error rendering macro 'code': Invalid value specified for parameter 'lang'
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.

 

 

Regards

Fareeads

  • No labels

1 Comment