Skip to Content
avatar image
Former Member

Download spool to PDF document on application server

Hi,

I am using function CONVERT_OTFSPOOLJOB_2_PDF to convert a sapscript spool and then downloading the internal table provided to a pdf file on the application server. The sapscript form contains company logos.

After transferring the file from the application server to PC and then opening the pdf document I get the following message:

"There was an error while trying to parse an image."

The PDF doc contains everything except the company logo.

I noticed that this works (i.e. company logo is present in the downloaded file) when I transfer the internal table that contains the PDF contents onto my PC using GUI_DOWNLOAD using mode 'BIN'. However, when I transfer the contents of the same internal

table to a file on the application server using abap statement:

'Open Dataset <filename> FOR OUTPUT IN BINARY MODE'

I get the problem described above.

I noticed that SAP has provided standard program RSTXPDFT4 to convert a spool and download it into a PC file. However is there a similar program that downloads a spool onto the application server? Perhaps there is a 'special' way in downloading PDF documents onto the application server?

I don't this problem with sapscripts that do not have a company logo.

Is there a certain restriction on 'Open Dataset'with transfering logos in PDF documents?

Any help would be greatly appreciated in the form of reward points.

Thanks

Liam

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Oct 25, 2006 at 01:27 AM

    Hi.

    Try demo programe "RSTXPDFT5", it download PDF file

    to localPC and Server.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      The error might be because of empty chars in last line of pdf itab when writing the file to appserver..

      Use the following code when writing the pdf file to appserver:

      data: file(20) type c value '/tmp/tpdf.pdf'.
      
      data: v_lines type sy-tabix,
            v_length type i.
      describe table t_pdftab lines v_lines.
      
      open dataset file for output in binary mode.
      v_length = 134.
      loop at t_pdftab.
        if sy-tabix eq v_lines.
          v_length = strlen( t_pdftab ).
        endif.
        transfer t_pdftab to file length v_length..
      endloop.
      close dataset file.

      Another reason for the error, may be you are using ASCII mode when FTPing the file from appserver to PC.

      If you are using ftp, change the mode to binary.

      Regards

      Sridhar

      Message was edited by:

      Sridhar K

  • avatar image
    Former Member
    Dec 08, 2006 at 10:21 PM

    Hi,

    We convert some of our spools to pdf and store them on the app server using following high level process.

    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

    EXPORTING

    src_spoolid = p_spool

    no_dialog = 'X'

    dst_device = 'LOCL'

    TABLES

    pdf = lt_pdf

    EXCEPTIONS

    OTHERS = 0.

    • Write PDF file

    CALL FUNCTION 'GUID_CREATE'

    IMPORTING

    ev_guid_32 = l_guid.

    CONCATENATE '/your_path_goes_here/'

    l_guid

    INTO l_filename.

    CONCATENATE l_filename '.pdf' INTO l_filename.

    • Store

    OPEN DATASET l_filename IN TEXT MODE.

    IF NOT sy-subrc IS INITIAL. " only write pdf if new

    LOOP AT lt_pdf.

    TRANSFER lt_pdf TO l_filename.

    ENDLOOP.

    ENDIF.

    CLOSE DATASET l_filename.

    If it doesn't work, I would 1st try and play with image type. I'm wondering if it's tripping on image conversion. Perhaps revert to 1st principles and try monochrome bitmap and a few variations thereof. I stand by my code above. Definitely works. HTH, Dave

    Add comment
    10|10000 characters needed characters exceeded

  • May 17, 2012 at 10:01 PM

    Hi Liam,

    I am facing exactly the same problem . I am struggling with this from quite a long time.

    I do understand that its been too long you had this problem but would really appreciate if you help me with the solution.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • May 18, 2012 at 05:09 AM

    Hi,

    the following link may solve your problem

    http://scn.sap.com/thread/3177954

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 25, 2016 at 02:00 PM

    There are a solution for this problem in another thread. Check:

    Run program RSTXPDF3 and activate option FLATE_COMPR_OFF.

    Hope it helps another one.

    Add comment
    10|10000 characters needed characters exceeded