* Archiv-ID aus Tabelle TOAAR
PARAMETERS: p_arc TYPE toaar-archiv_id.
* Dokumentart, in TOADV (SM30) gepflegt
PARAMETERS: p_aro TYPE toadv-ar_object DEFAULT 'SDOINVOICE'.
* Dateinamenerweiterung
PARAMETERS: p_dtype TYPE toaom-doc_type DEFAULT 'PDF'.
* SAP ArchiveLink: Objekt-Id (Objektidentifikator)
* SAP Objekt-Ident
* bei VBRK - '0070000000 0000000100'
* bei BUS1001006 - '0000000011000011111'
* Beispiele in TOA01, TOA02 oder TOA03
PARAMETERS: p_oid TYPE saeobjid DEFAULT '0070000000 0000000100'.
* SAP ArchiveLink: Objekttyp des Business Objekts
* VBRK - Kundeneinzelfaktura
* BUS1001006 - Standard Material
PARAMETERS: p_sobj TYPE tojtb-name DEFAULT 'VBRK'.
START-OF-SELECTION.
DATA: it_connect_info TYPE STANDARD TABLE OF toav0 WITH DEFAULT KEY.
* Alle verkn?pften Archivobjekte zum Objekt anhand der Selektionskriterien ermitteln
* SAP ArchiveLink: Ermitteln von Ablage-Id und Dok.-Id zu Anwendungsobject
CALL FUNCTION 'ARCHIV_CONNECTINFO_GET_META'
EXPORTING
archiv_id = p_arc
ar_object = p_aro
doc_type = p_dtype
object_id = p_oid
sap_object = p_sobj
TABLES
connect_info = it_connect_info
EXCEPTIONS
error_connectiontable = 1
OTHERS = 2.
IF sy-subrc = 0.
* Liste der Verkn?fpungen durchgehen und Bin?rdaten aus Archiv holen
LOOP AT it_connect_info ASSIGNING FIELD-SYMBOL(<ci>).
WRITE: / <ci>-archiv_id, <ci>-sap_object, <ci>-object_id, <ci>-arc_doc_id, <ci>-reserve.
DATA(lv_length) = 0.
DATA: it_bin_data TYPE STANDARD TABLE OF tbl1024 WITH DEFAULT KEY.
CLEAR: it_bin_data.
* Bin?rdaten des AO lesen
* CMS: AO API Dokument bereitstellen Tabelle
CALL FUNCTION 'SCMS_AO_TABLE_GET'
EXPORTING
arc_id = <ci>-archiv_id
doc_id = <ci>-arc_doc_id
IMPORTING
length = lv_length
TABLES
data = it_bin_data
EXCEPTIONS
error_http = 1
error_archiv = 2
error_kernel = 3
error_config = 4
OTHERS = 5.
IF sy-subrc = 0.
DATA: lv_xstring TYPE xstring.
* Bin?rdaten in xstring konvertieren
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = CONV i( lv_length )
IMPORTING
buffer = lv_xstring
TABLES
binary_tab = it_bin_data
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc = 0.
...
ENDIF.
ELSE.
WRITE: / 'Error:', sy-subrc.
ENDIF.
ENDLOOP.
ELSE.
WRITE: / 'Verbindungsdaten nicht gefunden:', sy-subrc.
ENDIF.