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: 

Document-Download from Archive with Function Module SCMS_DOC_READ without success

0 Kudos

Hello together,

I try to download an attachment for an invoice from the Archive (Archivelink).

I tried it with FM SCMS_DOC_READ but without success.

I tried it also with other Function Modules (a.o. ARCHIV_GET_TABLE), also without success.

My coding is as following:

CONCATENATE gs_invoices-vbeln '%' INTO gv_vergleich.

SELECT SINGLE object_id arc_doc_id archiv_id reserve
FROM toa01
INTO ( lv_object_id, lw_connections-arc_doc_id, lw_connections-archiv_id, lv_document_type )
WHERE object_id LIKE gv_vergleich.

CALL FUNCTION 'SCMS_DOC_READ'
EXPORTING
mandt = sy-mandt
stor_cat = ' '
crep_id = lw_connections-archiv_id
doc_id = lw_connections-arc_doc_id
TABLES
access_info = lt_info
content_txt = lt_content_txt_1022
content_bin = lt_content_bin_1022
EXCEPTIONS
bad_storage_type = 1
bad_request = 2
unauthorized = 3
comp_not_found = 4
not_found = 5
forbidden = 6
conflict = 7
internal_server_error = 8
error_http = 9
error_signature = 10
error_config = 11
error_format = 12
error_parameter = 13
error = 14
OTHERS = 15.

If you can help with with any hint I would be lucky!

Kind regards

Udo

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

When you use the SAP ERP programs to get the archive and you trace the URL, is it the same URL that you access?

Trace using ICF recording – a possibility for analysing | SAP Blogs

Here's excerpt from blog post:

  1. Tr. SICF -> Client -> Recorder -> Activate Recording.
  2. Get the archive.
  3. Tr. SICF -> Client -> Recorder -> Deactivate Recording.
  4. To display: We can check this in Tr. SICFRECORDER. Here We have to click on the button ‘Client request’

NB: personally, I don't use SICFRECORDER, but it's the same: Tr. SICF -> Client -> Recorder -> Display Recording -> button ‘Client request’

0 Kudos

It's no problem of the URL anymore.

I debugged the program and the part with the URL worked correct.

0 Kudos

Alternatively I tried also function module ARCHIVOBJECT_GET_TABLE.

There is written an output-dataset (parameter binarchivobject), but in the end I cannot open the sent mail-attachment.

Here for your reference also the coding:

CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'

EXPORTING
archiv_id = lw_connections-archiv_id
document_type = lv_document_type_fb
archiv_doc_id = lw_connections-arc_doc_id
all_components = ' '
signature = ' ' " vorher = 'X'
compid = ' '
IMPORTING
binlength = e_length
TABLES
archivobject = et_archivobject
binarchivobject = et_binarchivobject
EXCEPTIONS
error_archiv = 1
error_communicationtable = 2
error_kernel = 3
OTHERS = 4.

CASE sy-subrc.
WHEN 0.

lv_docid = ls_obj-instid.

IF et_binarchivobject[] IS NOT INITIAL.

REFRESH lt_content_bin.

CALL METHOD cl_rmps_general_functions=>convert_1024_to_255
EXPORTING
im_tab_1024 = et_binarchivobject[]
RECEIVING
re_tab_255 = lt_content_bin[].

ENDIF.

l_lines = lines( lt_content_bin ).
l_size = l_lines * 255.

gr_send_request = cl_bcs=>create_persistent( ).

* ADD attchment

CONCATENATE 'Invoice_' gs_invoices-vbeln INTO l_subject.

CALL METHOD gr_document->add_attachment
EXPORTING
i_attachment_type = 'pdf' " l_extension " 'EXT'
i_attachment_subject = l_subject
i_attachment_language = sy-langu
i_attachment_size = l_size
i_att_content_hex = lt_content_bin. " l_attach.

If anybody have a hint what I could change that is works I would be grateful!

Kind regards

Udo

Sandra_Rossi
Active Contributor
0 Kudos

So, you're saying that SCMS_DOC_READ accesses the same URL as in real situation, so the parameters you pass are mostly correct, SAP gets the document successfully, but after that you are saying that it fails.

What exception do you get? Also provide the values of SY-MSGID, SY-MSGNO, and all SY-MSGV*.

0 Kudos

Hi Sandra,

I don't get any exception from SCMS_DOC_READ.

Also the variables SY-MSGID, SY-MSGNO, and all SY-MSGV* are empty. 😞

Kind regards

Udo