Skip to Content
avatar image
Former Member

Retrieve Archived PDF and print

Hi Folks,

I have certificates which have been archived. Once I get the Archiv Id of the document from TOA01, how do I use this data to print?

The Archived Document is a PDF Document. Could you please advise steps on how this data can be retrieved and printed?

Information I have presently is that I can get the archived data in Binary Format with FM ARCHIVOBJECT_GET_TABLE

How do you process this binary data to get it printed?

Greatly appreciate any help.

Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    May 07, 2013 at 03:55 PM

    Hi All

    I know this is an old post but this is how I achieved it.

    I use fm ARCHIVOBJECT_GET_TABLE to get the document  I then use fm 'SCMS_BINARY_TO_XSTRING' to convert to xstring and finally ADS_WRITE_TO_FILE to write the file to the spool, code below

    <p>

    DATA:

       l_handle           TYPE sy-tabix,

       l_spoolid          TYPE tsp01-rqident,                    "#EC NEEDED

       l_partname         TYPE adspart,                          "#EC NEEDED

       l_new_partname     TYPE adspart,                          "#EC NEEDED

       l_filename(128)    TYPE c.

    l_v_partname = 'darrenTest1'.

    * Create a new spool order for the PDF'S

    CALL FUNCTION 'ADS_SR_OPEN'

       EXPORTING

         dest             = l_v_prdest

         immediate_print  = abap_true

    *   append           = ' ' "append

         doctype          = 'ADSP'

         titleline        = 'DarrenTest'

       IMPORTING

         handle           = l_v_handle

         spoolid          = l_v_spoolid

         partname         = l_v_partname

       EXCEPTIONS

         device_missing   = 1

         no_such_device   = 2

         operation_failed = 3

         wrong_doctype    = 4

         wrong_devicetype = 5

         OTHERS           = 6.

    CALL FUNCTION 'ADS_GET_PATH'

       IMPORTING

         ads_path = l_v_globaldir.

    PERFORM get_statements.

    READ TABLE gt_return INTO ls_doc INDEX 1.

    CLEAR l_filename.

    *l_v_partname = 'darrenTest1'.

    l_filename = |{ l_v_partname }.pdf|.

    CALL FUNCTION 'ADS_WRITE_TO_FILE'

       EXPORTING

         filename                     = l_filename

         buffer                       = ls_doc-bindoc " this is the xstring

    *   APPEND                       = ' '

    *   USEGLOBALDIR                 = 'X'

       EXCEPTIONS

         cannot_open_file             = 1

         open_dataset_no_authority    = 2

         open_dataset_internal_error  = 3

         open_dataset_too_many_files  = 4

         dataset_cant_close           = 5

         close_dataset_internal_error = 6

         cannot_close_file            = 7

         cannot_transfer_data         = 8

         transfer_internal_error      = 9

         dataset_write_error          = 10

         OTHERS                       = 11.

    CALL FUNCTION 'ADS_SR_CONFIRM'

       EXPORTING

         handle           = l_v_handle

         partname         = l_v_partname

         size             = 0

         pages            = 0

    *   NO_PDF           = ' '

       IMPORTING

         new_partname     = l_new_partname

       EXCEPTIONS

         handle_not_valid = 1

         operation_failed = 2

         OTHERS           = 3.

    CALL FUNCTION 'ADS_SR_CLOSE'

       EXPORTING

         handle           = l_v_handle

         final            = abap_true

       EXCEPTIONS

         handle_not_valid = 1

         operation_failed = 2

         OTHERS           = 3.

    RETURN.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 23, 2010 at 04:55 PM

    Anyone who's done something similar? Really appreciate any information you could share.

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 23, 2010 at 05:33 PM

    ARCHIVOBJECT_GET_TABLE will return you these values..

    IMPORTING
          length                   = gv_len
          binlength                = gv_binlen
        TABLES
          archivobject             = gt_archiv
          binarchivobject          = gt_binar

    then just use GUI_DOWNLOAD with filetype 'BIN' and pass gt_binar into BIN_TAB....

    task done...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 23, 2010 at 06:28 PM

    Soumyaprakash,

    Thank you for the information on the GUI_DOWNLOAD FM. Yes, this does download the data in a PDF file onto my local machine.

    But this is not what is required.

    I need to send this data to a spool (should open up as a PDF in SP02 when you open the spool request created)

    Could you please advise in that regard too?

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 11, 2013 at 03:10 AM

    Hi,

    You can refer the below link where I have just posted a possible ⚠️ solution & see whether that helps.

    Solution! (Hopefully) :Print label image in GIF format

    Regards,

    Gokul

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Gokul,

      I am able to print it using FM's RSPO_SR_OPEN, RSPO_SR_WRITE_BINARY etc. It works fine on one printer but in the second printer it doesn't work. Both the printers are of POST2 type. What do you think could be the issue?

      Tnx,

      Venkat