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: 

Archivobject_get_table returns empty table

Former Member
0 Kudos

Hello,

I'm having trouble since I changed the archive process of PDFs to binary.

I have one programm which is reading a pdf in binary mode like this:

"Step1 read pdf to xstring:
      OPEN DATASET im_filepath FOR INPUT IN BINARY MODE.
      DO.
        READ DATASET im_filepath INTO lf_tempxstr.
        IF sy-subrc <> 0.
          CONCATENATE lf_pdfxstr lf_tempxstr INTO lf_pdfxstr IN BYTE MODE.
          EXIT.
        ENDIF.
        CONCATENATE lf_pdfxstr lf_tempxstr INTO lf_pdfxstr IN BYTE MODE.
      ENDDO.
      CLOSE DATASET im_filepath.

"Step2 xstring to binary table:
 CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = lf_pdfxstr
    TABLES
      binary_tab = tb_binfile.

"Step 3 archiving:
CALL FUNCTION 'ARCHIVOBJECT_CREATE_TABLE'
    EXPORTING
      archiv_id                = pa_arcid
      document_type            = 'PDF'
    IMPORTING
      archiv_doc_id            = gs_inv-arcdocid
    TABLES
      binarchivobject          = tb_binfile

This works without errors and I get an archiv_doc_id to the file.

In another program I try to retrieve the file from the archive again:

CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'
    EXPORTING
      archiv_id                = co_arc_id
      document_type            = 'PDF'
      archiv_doc_id            = gs_invdata-arcdocid
    TABLES
      binarchivobject          = lt_file_data

This also works without errors, but the lt_file_data table remains empty. Can anyone help me and say what I am doing wrong here?

Best regards.

1 ACCEPTED SOLUTION

Former Member

I solved it myself.

Apparently, when using function 'ARCHIVOBJECT_TABLE_CREATE' and passing the file as binarchivobject, you need to pass the length parameter too, which you can get from the 'SCMS_XSTRING_TO_BIN' function. Doing this I were able to retrieve the file again.

2 REPLIES 2

Former Member

I solved it myself.

Apparently, when using function 'ARCHIVOBJECT_TABLE_CREATE' and passing the file as binarchivobject, you need to pass the length parameter too, which you can get from the 'SCMS_XSTRING_TO_BIN' function. Doing this I were able to retrieve the file again.

0 Kudos

It worked for me. Thanks!