Skip to Content
avatar image
Former Member

hi, hoe to convert script form into pdf format

hi,

how to convert script form into pdf format , plz any one knows help me .

regards

praveen

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Sep 02, 2007 at 06:05 AM

    hi to all,

    In case of script we can go for such a methodology.

    The basic Methodology for script is as follows.

    1. set the component TDGETOTF of the structure ITCPO & pass it into

    the parameter OPTIONS in the function module OPEN_FORM.

    2. Obtain the OTF data in the tables parameter in the function module

    CLOSE_FORM . The internal table used must be of the structure type

    ITCOO.

    3. Use the function module CONVERT_OTF in order o convert the OTF

    data into the pdf format, obtain the data in an internal table whose

    structure type is TLINE.

    This methodology would work for Scripts

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2007 at 08:36 AM
          REPORT Z1SCRIPT_TO_PDF .
     
    **********************DECLARATIONS*************************
     DATA: BEGIN OF ITAB OCCURS 0,
     CARRID TYPE SFLIGHT-CARRID,
     CONNID TYPE SFLIGHT-CONNID,
     PRICE TYPE SFLIGHT-PRICE,
     END OF ITAB.
     
     DATA: struct TYPE ITCPO.
     DATA: PDFTAB TYPE TABLE OF TLINE WITH HEADER LINE,
           DATAB TYPE TABLE OF ITCOO WITH HEADER LINE,
     
     DATA: BINFILESIZE TYPE I,
           FILE_NAME TYPE STRING,
           FILE_PATH TYPE STRING,
           FULL_PATH TYPE STRING.
    
    
    ****************************END OF DECLARATIONS********************************
    
     *To specify Printer name*
     struct-tddest = 'LP01'.
    
     *To specify no Print Preview*
     struct-tdnoprev = 'X'.
    
     *To access the SAP Script output in OTF format*
     struct-tdgetotf = 'X'.
    
    ***************************SAPSCRIPT GENERATION********************************
     CALL FUNCTION 'OPEN_FORM'
     EXPORTING
     * APPLICATION = 'TX'
     * ARCHIVE_INDEX =
     * ARCHIVE_PARAMS =
       DEVICE = 'PRINTER'
       DIALOG = space
       FORM = 'ZSCRIPT'
    *  LANGUAGE = SY-LANGU
       OPTIONS = struct
    *  MAIL_SENDER =
    *  MAIL_RECIPIENT =
    *  MAIL_APPL_OBJECT =
    *  RAW_DATA_INTERFACE = '*'
    *  SPONUMIV =
    
    *IMPORTING
    * LANGUAGE =
    * NEW_ARCHIVE_PARAMS =
    * 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.
    
    CALL FUNCTION 'START_FORM'
    EXPORTING
    * ARCHIVE_INDEX =
    FORM = 'ZSCRIPT'
    * LANGUAGE = ' '
    * STARTPAGE = ' '
    * PROGRAM = ' '
    * MAIL_APPL_OBJECT =
    * IMPORTING
    * LANGUAGE =
    EXCEPTIONS
    FORM = 1
    FORMAT = 2
    UNENDED = 3
    UNOPENED = 4
    UNUSED = 5
    SPOOL_ERROR = 6
    CODEPAGE = 7
    OTHERS = 8
    .
    
    
    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 = 'ELEM1'
    FUNCTION = 'SET'
    TYPE = 'BODY'
    WINDOW = 'MAIN'
    * IMPORTING
    * 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.
    
    SELECT CARRID CONNID PRICE FROM SFLIGHT INTO TABLE ITAB.
    
    LOOP AT ITAB.
    CALL FUNCTION 'WRITE_FORM'
    
    EXPORTING
    ELEMENT = 'ELEM2'
    FUNCTION = 'SET'
    TYPE = 'BODY'
    WINDOW = 'MAIN'
    * IMPORTING
    * 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.
    ENDLOOP.
    
    CALL FUNCTION 'END_FORM'
    * IMPORTING
    * RESULT =
    EXCEPTIONS
    UNOPENED = 1
    BAD_PAGEFORMAT_FOR_PRINT = 2
    SPOOL_ERROR = 3
    CODEPAGE = 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.
    
    CALL FUNCTION 'CLOSE_FORM'
    * IMPORTING
    * RESULT =
    * RDI_RESULT =
    TABLES
    OTFDATA = DATAB[]
    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.
    
    ***************************END OF SAPSCRIPT GENERATION********************************
    
    ***************************CONVERTING OTF DATA TO PDF DATA****************************
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    * MAX_LINEWIDTH = 132
    * ARCHIVE_INDEX = ' '
    © 2006 SAP AG 9
    * COPYNUMBER = 0
    * ASCII_BIDI_VIS2LOG = ' '
    * PDF_DELETE_OTFTAB = ' '
    IMPORTING
    BIN_FILESIZE = BINFILESIZE
    * BIN_FILE =
    TABLES
    otf = DATAB[]
    lines = PDFTAB[]
    * 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.
    
    *****************TAKING THE DOWNLOAD FILE PATH AS USER INPUT*************************
    
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    * EXPORTING
    * WINDOW_TITLE =
    * DEFAULT_EXTENSION =
    * DEFAULT_FILE_NAME =
    * FILE_FILTER =
    * INITIAL_DIRECTORY =
    * WITH_ENCODING =
    * PROMPT_ON_OVERWRITE = 'X'
    CHANGING
    
    filename = FILE_NAME
    path = FILE_PATH
    fullpath = FULL_PATH
    * USER_ACTION =
    * FILE_ENCODING =
    * EXCEPTIONS
    * CNTL_ERROR = 1
    * ERROR_NO_GUI = 2
    * NOT_SUPPORTED_BY_GUI = 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.
    
    ****************************DOWNLOADING THE PDF DATA**********************************
    
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = binfilesize
    FILENAME = 'D:myfile.pdf'
    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 =
    tables
    
    data_tab = PDFTAB[]
    * 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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2007 at 01:43 PM

    Hi kumar,

    try this hope u can solve.

    SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.

    Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.

    It look exactly like what you see during a spool display.

    Please note that it is not restricted to sapsciprts spool only. Any reports in the spool can be converted using the program 'RSTXPDFT4'

    Reward points if helpful

    Thanks

    Naveen khan

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 03, 2007 at 07:22 AM

    This will help to solve your problem...

    With screen shots.

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556

    Regards,

    Sairam

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 03, 2007 at 07:23 AM

    HI,

    first generate the spool for the script .

    then get the spool no from sp01

    call function'CONVERT_ABAP_SPOOL2PDF'

    IT WILL GIVE YOU THE PDF

    thanks

    vivekanand

    Add comment
    10|10000 characters needed characters exceeded