Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve Archived PDF and print

Former Member
0 Kudos

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!

18 REPLIES 18

Former Member
0 Kudos

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

Cheers.

Former Member
0 Kudos

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...

Former Member
0 Kudos

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.

0 Kudos

hello friend,

Use the SAP standard report RSTXPDFT4 to create a PDF version of any SAP report output. You can then easily store, transfer, or email the PDF file to other team members or even to employees or external bodies. This saves you time and protects your output from users who might inadvertently change the data while trying to format it.

For more information check the below link.

http://www.hrexpertonline.com/archive//Volume_04_(2006)/Issue_08_(October)/V4I8A2.cfm?session=

Best Regards,

Jerry

0 Kudos

Hello,

I have the same requirement... to print a pdf that is stored in IXOS.

Just like you Ithara I have managed to get the file raw data with ARCHIVEOBJECT_GET_TABLE but now I don't know how to pass this into a spool order.

Any ideas?

Thank you,

Fábio Galvã

0 Kudos

Hello Ihtara,

Like I said, I managed to get the raw data from IXOS with the function module ARCHIVEOBJECT_GET_TABLE. Now I found out these function modules:

RSPO_SR_OPEN - to open a new spool request

RSPO_SR_TABLE_WRITE_BINARY - to write a binary table to the spool request

RSPO_SR_CLOSE - to close the spool request

These might work.

I don't have connection to IXOS at the moment to try them, but do you think these might work?

Thank you,

Fábio Galvã

0 Kudos

Hello Ihtara,

I've managed to create a empty spool order using FM RSPO_SR_OPEN, and then I perform a loop at the table binarchivobject, that the FM ARCHIVOBJECT_GET_TABLE returns with the binary of the pdf, writing the binary using FM RSPO_SR_WRITE_BINARY performing a MOVE binarchivobject-line TO data_line. After all the data is writen i use FM RSPO_SR_CLOSE to close the spool order.

Now, my problem is that what's sent to the printer is something like this:

"%PDF-1.4#1 0 obj#<</Type /Catalog#/Version /1.4#/Pages 4 0 R#>>#endobj#2 0 obj#<</Producer (Report.NET by root-software ag)#/CreationDate (D:20100615)#/

116.22 738.431 Td#(10ELM700434) Tj#ET#BT#172.913 738.431 Td#(15-06-2010 / 17-06-2010) Tj#ET#BT#314.646 738.431 Td#(Financeiro) Tj#ET#BT#399.685 738.431 "

and the printer does not recognize this as a PDF and prints the code just like this.

So i'm guessing I might need a conversion or something like this. Anyone as any Ideas?

Have you managed to solve this problem Ihtara?

Thank you,

Fábio Galvã

0 Kudos

Hi Fabio,

I am facing the same problem as you mentioned before.

Could you please let me know how did you solve it ?

Thanks in advance.

Best Regards,

Kevin Zhang

___________________________________________________________________________________________________

Hello Ihtara,

I've managed to create a empty spool order using FM RSPO_SR_OPEN, and then I perform a loop at the table binarchivobject, that the FM ARCHIVOBJECT_GET_TABLE returns with the binary of the pdf, writing the binary using FM RSPO_SR_WRITE_BINARY performing a MOVE binarchivobject-line TO data_line. After all the data is writen i use FM RSPO_SR_CLOSE to close the spool order.

Now, my problem is that what's sent to the printer is something like this:

"%PDF-1.4#1 0 obj#<</Type /Catalog#/Version /1.4#/Pages 4 0 R#>>#endobj#2 0 obj#<</Producer (Report.NET by root-software ag)#/CreationDate (D:20100615)#/

116.22 738.431 Td#(10ELM700434) Tj#ET#BT#172.913 738.431 Td#(15-06-2010 / 17-06-2010) Tj#ET#BT#314.646 738.431 Td#(Financeiro) Tj#ET#BT#399.685 738.431 "

and the printer does not recognize this as a PDF and prints the code just like this.

So i'm guessing I might need a conversion or something like this. Anyone as any Ideas?

Have you managed to solve this problem Ihtara?

Thank you,

Fábio Galvão

Edited by: Kevin Zhang on Mar 25, 2011 9:58 AM

0 Kudos

If anyone found the solution to this, please post.  Thanks!

0 Kudos

Hi,

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

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

Regards,

Gokul

darren_bambrick2
Active Participant
0 Kudos

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.

0 Kudos

Darren,

We have a similar situation and i tried  to copy your steps in my program. I have couple of questions. My PDF file exists in an application server path and i am able to move it to XString type. The FM, ADS_WRITE_TO_FILE seems to move the file again to a global directory which we do no want. Hence, i set the  USEGLOBAL Importing parameter as ''. Irrespective of that fact the program still tries to place the file in the global directory.

I can see a PDF in my spool but when i double click it says the file does not exist in my global directory( he file name is not complete i.e the global directory is very big and due to it the extension is only displayed as .PD instead of .PDF) . I do not want to move it to any global directory. I want it directly into my spool only. Can you help me fix it?

Thanks,

Venkat

0 Kudos

Hi Venkat

I am looking back on my program now, its been a whild since I finished it,  and I am using it to merge two pdf fields into one pdf spool.

i am using the global directory I will attach the updated code for you.

you can also check out the code in this method. CL_SALV_WD_C_TABLE_V_TABLE->ON_PDF_SEND_TO_PRINTER

<p>

return.



l_wa_old_spool-rqident = 30096.

APPEND l_wa_old_spool

   TO l_i_old_spools.

l_wa_old_spool-rqident = 30094.

APPEND l_wa_old_spool

   TO l_i_old_spools.



BREAK-POINT.

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.

data: lv_append type char1.



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_false

*   append           = ' ' "append

    doctype          = l_c_doctype

    titleline        = 'Darren Merge Test'

  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.



BREAK-POINT.

PERFORM get_statements.

READ TABLE gt_return INTO ls_doc INDEX 1.

CLEAR l_filename.

*CONCATENATE l_v_globaldir l_v

*l_v_partname = 'darrenTest1'.

*l_filename = |{ l_v_globaldir }/{ l_v_partname }.pdf |.

l_filename = |{ l_v_partname }.pdf |.



LOOP AT gt_return INTO ls_doc.

  if sy-tabix > 1.

    lv_append = 'X'.

  else.

    clear lv_append.

  endif.



  CALL FUNCTION 'ADS_WRITE_TO_FILE'

    EXPORTING

      filename                     = l_filename

      buffer                       = ls_doc-bindoc

      append                       = lv_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.

ENDLOOP.



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.



0 Kudos

Darren,

Sorry to bother you again but the PDF print somehow is not working for me. I also followed one of the standard programs which is used to send the PDF to print. The program first  accepts the PDF converted to PS format and then the actual PDF and places it in global directory. The program though does not use 'ADS_WRITE_TO_FILE' . Can you tell me what the use of 'ADS_WRITE_TO_FILE' is and how the document gets printed on placing the file in the global directory?

Currently, in my case the PDF gets moved to the spool but on double clicking the same, i get an error message saying the file is corrupt or does not exist.

Thanks,

Venkat

0 Kudos

Hi Darren,

I know it's a very old post but I would still have a question to your solution. I try to merge 4 PDFs to one spool entry and I did everything like you have described. When I open the spool in display mode, it says above 1 of 4 which Looks correct. But it shows just the first page. And only the first page is printed. Do you have any ideas how I could solve this? We are on 7.40.

By the way - your solution is the closest ever I've found to merge existing PDFs - thank you for that!

Regards

Nicola

0 Kudos

gokul_radhakrishnan3
Active Participant
0 Kudos

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

0 Kudos

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