Skip to Content

Printing PDF attachment

Hello.

I'd like to print pdf document that is stored in SAP database as attachment to material record.

I am able to successfully read content of attachment thanks to FM SO_DOCUMENT_READ_API1

CALL FUNCTION 'SO_DOCUMENT_READ_API1'
       EXPORTING
         document_id                = lv_docid
       IMPORTING
         document_data              = ls_foldinfo
       TABLES
         object_header              = lt_objhead
         object_content             = lt_objcontent
         contents_hex               = lt_content
       EXCEPTIONS
         document_id_not_exist      = 1
         operation_no_authorization = 2
         x_error                    = 3
         OTHERS                     = 4.


I guess above function returns the content of pdf document in lt_content variable (DATA lt_content TYPE TABLE OF solix).

How can I send the content to spool?


Best regards,

Pawel


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Dec 30, 2014 at 08:46 AM

    Hi Pawel,

    You can download this internal table using GUI_DOWNLOAD on presentation server, then,

    you can print the document using method ‘CL_GUI_FRONTEND_SERVICES=>EXECUTE’ passing document path and ‘Print’ command.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 30, 2014 at 09:13 AM

    Hi Pawel,

    Not clear with your requirement.

    Make me clear if I am wrong,  through the Function Module, you are able to fetch the Attachment of any of the Material Document.

    After that you want to display the document

    or

    Want to create a spool for the same, where through SP02, you can see the document based on the Material No.

    Regards.

    Praveer.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Pawel,

      You can use the SCMS_XSTRING_TO_BINARY function module to change the PDF information to Binary Format,

      After that, you have to use the CL_GUI_HTML_VIEWER to display the Information in SAP Screen.

      Regards.

      Praveer.

  • avatar image
    Former Member
    Dec 30, 2014 at 10:26 AM

    Hi Pawel ,

                    If the data is in internal table , first display the content using grid display(reuse_alv_grid_display) or list display(reuse_alv_list_display)  and in the output use menu option list-->print to take the print out .

    Regards ,

    Rocky

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rocky.

      As I mentioned I'd like to create program that can be called in background with no user interface.

      Do you know wheter print option can be executed by calling ABAP Function Module?

      Regards,

      Pawel

  • avatar image
    Former Member
    Dec 30, 2014 at 08:23 PM

    [found on scn]SAP provides a function module ADS_CREATE_PDF_SPOOLJOB, that can put an PDF in the SAP spool system. Example program is FP_TEST_SAVE_PDF_TO_SPOOL.

    If not available, check note 0001855522.

    Regards Clemens

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Clemens,

      I was looking at the program FP_TEST_SAVE+PDF_TO_SPOOL.

      Inside the program the same FM called, but my Question in If System in not having the ADS server, will is work?

      Because, initially it's checking the ADS server is available or not.

      Regards.

      Praveer

  • Jan 02, 2015 at 07:14 AM

    Does anybody have any other suggestions?

    I cannot follow Clemens advice because ADS package is not available in my case.


    As I mentioned I am able to get binary content of PDF file using function SO_DOCUMENT_READ_API1.

    Afterwards applying one of the functions operating with the spool seems to be the right solution.

    I tested three of them:

    RSPO_SR_TABLE_WRITE_BINARY

    RSPO_SR_WRITE_BINARY

    RSPO_WRITE_SPOOLREQUEST

    but with no success.

    Likely due to the fact that binary content of PDF file must be converted to data understandable by printer.


    Does anybody know how to achieve that goal?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Pawel,

      when I read your initial question it came to my mind that SAP almost never was a friend of pdf. As you know, it is easy to convert anything to pdf, using 3rd-party tools or using SAP to convert spool output. The other way round is pretty diffficult.

      In SAP a precondition for pdf is the installation of Adobe document server ADS. As far as I know this is included in maintenance costs, so basis has to install it to get your task done.

      I'd hope there is any better solution but I don't expect too much.

      Best regards

      Clemens

  • avatar image
    Former Member
    Jan 02, 2015 at 09:39 AM

    Hello Pawel

    i think you 1st you are using  smartform FM for Calling Smartform then other Fm that is  otf To Pdf and then  so_document_Read_Api1...

    In above case you will not get print directrly because in 1st FM you are using getoft = 'X'.

    use Smartform FM twice and in 1st dont check getotf = 'X'. because when u check getotf -'X' that mens " Return of OTF table. No printing, display, or faxing "

    Add comment
    10|10000 characters needed characters exceeded

    • Hello.

      I don't use smartform at all. I have got file attachment to material record that I can get using SO_DOCUMENT_READ_API1 function. Should I convert contents_hex table of SO_DOCUMENT_READ_API1 function in order to print?


      Regards,

      Pawel