Skip to Content
avatar image
Former Member

Converting SapScript to PDF file

Hi All

I try to convert the sapscript from spoollist to pdf. It is converted to pdf file but the page format of pdf file is differnt to sapscript as there is a great right margin added to the file .

i just want to know the various settings in sapscript or zpdf device type prior to convert so that the pdf file looks like the sapscript generated.

Thanks

Namrata

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Apr 03, 2006 at 05:53 AM

    CONVERT_OTFSPOOLJOB_2_PDF converts a OTF spool to PDF (i.e. Sapscript document)

    CONVERT_OTF Convert OTF format to various formats (TLINE table) ASCII or PDF

    CONVERT_OTF_2_PDF Convert OTF to PDF (TLINE table). OTF can be filled used archivelink. Calls CONVERT_OTF.

    CONVERT_OTF_2_PDF_ARCHIVELINK Convert OTF to PDF (TLINE table). Calls CONVERT_OTF. Looks like the function names for these two functions are mixed up J

    regards

    vinod

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 03, 2006 at 05:59 AM
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 03, 2006 at 06:04 AM

    Hi Namrata,

    Welcome to SDN.

    Plese check this sample code from other thread.

    REPORT zzz_jaytest .
    
    * Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    
    * Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    
    
    * Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    
    * Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    
    * Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    
    START-OF-SELECTION.
    
    * Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    
    * Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    
    * Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    
    LOOP AT i_pa0001 INTO w_pa0001.
    * Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    
    * Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    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.
    
    * Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    
    * Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    
    v_size = v_len_in.
    
    * Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.

    Hope this will help.

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ferry Lianto

      Thanks for your Tip it was really helpful

      but i have one prob when the PDF file is created the data repeates it self in the file its beacuse of the loop i think i.e

      LOOP AT i_pa0001 INTO w_pa0001.

      • Writting into the form

      CALL FUNCTION 'WRITE_FORM'

      EXPORTING

      element = 'MAIN'

      window = 'MAIN'.

      ENDLOOP.

      can you plz explain why are we using this loop.

      Thanks

      Namrata

  • Apr 03, 2006 at 06:07 AM

    hi

    just check the thread... convert-sapscript-to-pdf

    Cheers,

    Abdul

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 03, 2006 at 06:12 AM

    Hi,

    Please use the standard program RSTXPDFT4.

    If found answer suitable , then please reward the points.

    Regards,

    Irfan Hussain

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      I have already convert the sapscript using RSTXPDFT4 report but when i see the output in pdf the format of sapscript file is changed as the text alignment,barcode alignment and a right margin is added to it

      can you help me to solve this problem

      Thanks

      Namrata

  • avatar image
    Former Member
    Apr 03, 2006 at 06:25 AM

    hi

    just check the thread...

    converting-spool-to-pdf-document

    regards,

    Ananaya.S

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 04, 2006 at 11:31 AM

    Hi Namrata,

    You don't need to loop if you only have a record want to covert. Above sample code has 10 different records in the internal table and want to combine together into one file.

    Hope this will help.

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded