06-08-2022 10:34 AM
Hello together,
I want to download the attachment from an invoice via method cl_binary_relation=>read_links_of_binrel.
Unfortunately I don't get any result.
I tried with the business objects BU2037, VBRK and BUS2037001 but nothing works.
Do you have any idea.
My coding is:
" Businessobjekt-ID übernehmen
gs_object-instid = gs_invoices-vbeln.
gs_object-typeid = 'BUS2037'.
gs_object-catid = 'BO'.
TRY.
" Verknüpfungen zum Objekt lesen
CALL METHOD cl_binary_relation=>read_links_of_binrel
EXPORTING
is_object = gs_object
ip_relation = 'NOTE'
IMPORTING
et_links = gt_links.
IF NOT gt_links IS INITIAL.
LOOP AT gt_links INTO gs_links WHERE typeid_b = 'MESSAGE'.
" Optional: Schlüsselkomponenten extrahieren
gs_key = gs_links-instid_b.
WRITE: / 'foltp', gs_key-foltp
, / 'folyr', gs_key-folyr
, / 'folno', gs_key-folno
, / 'objtp', gs_key-objtp
, / 'objyr', gs_key-objyr
, / 'objno', gs_key-objno
.
" Die Dokumenten-ID für SAPOffice entspricht der ermittelten
" Instanz-ID
gd_doc_id = gs_links-instid_b.
" Dokumenteninhalte löschen
CLEAR
: gt_cont
, gt_contx
.
" Dokument lesen
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = gd_doc_id
IMPORTING
document_data = gs_doc_data
TABLES
object_content = gt_cont
contents_hex = gt_contx
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
" Fehlerbehandlung: Lesen des Dokuments
ELSE.
" Ausgabe einiger Kopfdaten
WRITE: / gs_doc_data-object_id
, gs_doc_data-obj_type
, gs_doc_data-obj_name
, gs_doc_data-obj_descr
.
ENDIF.
SKIP.
IF NOT gt_cont[] IS INITIAL.
" Es gibt Inhalt im Textformat
WRITE: 7 'TXT'.
ENDIF.
IF NOT gt_contx[] IS INITIAL.
" Es gibt Inhalt im Binärformat
WRITE: 14 'BIN'.
ENDIF.
ENDLOOP.
ENDIF.
ENDTRY.
06-08-2022 10:42 AM
06-08-2022 10:57 AM
Hi Sandra,
thanks for your comment.
But even with ATTA it does not work.
Best regards
Udo
06-08-2022 2:53 PM
Now it's working.
Seems I tested with the wrong invoices.
Thanks Sandra!