* Archiv-ID aus Tabelle TOAAR
PARAMETERS: p_arc TYPE toaar-archiv_id.
* ARC_DOC_ID: Beispiel siehe Tabelle TOA01, TOA02, TOA03
PARAMETERS: p_docid TYPE saeardoid DEFAULT '41C0CC07B977349DE10000000A450668'.
START-OF-SELECTION.
DATA: lv_toa0x TYPE toa01.
* Pr?fen, ob das Archivobjekt in der Tabelle TOA01, TOA02 oder TOA03 abgelegt ist
* Tabelle TOA01
SELECT SINGLE *
INTO @lv_toa0x
FROM toa01
WHERE arc_doc_id = @p_docid
AND archiv_id = @p_arc.
IF sy-subrc <> 0.
* Tabelle TOA02
SELECT SINGLE *
INTO @lv_toa0x
FROM toa02
WHERE arc_doc_id = @p_docid
AND archiv_id = @p_arc.
ENDIF.
IF sy-subrc <> 0.
* Tabelle TOA03
SELECT SINGLE *
INTO @lv_toa0x
FROM toa03
WHERE arc_doc_id = @p_docid
AND archiv_id = @p_arc.
ENDIF.
IF sy-subrc = 0.
WRITE: / lv_toa0x-sap_object.
WRITE: / lv_toa0x-object_id.
WRITE: / lv_toa0x-archiv_id.
WRITE: / lv_toa0x-arc_doc_id.
WRITE: / lv_toa0x-ar_object.
WRITE: / lv_toa0x-ar_date.
WRITE: / lv_toa0x-del_date.
WRITE: / lv_toa0x-reserve.
ULINE.
DATA: lv_url TYPE swk_url.
* CMS:AO API Url für Dokumentzugriff
CALL FUNCTION 'SCMS_AO_URL_READ'
EXPORTING
arc_id = p_arc
doc_id = p_docid
IMPORTING
url = lv_url
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc = 0.
* URL anzeigen, kann auch im cl_gui_html_viewer direkt angezeigt werden
WRITE: / lv_url.
* DATA(o_html) = new cl_gui_html_viewer( parent = cl_gui_container=>default_screen ).
* o_html->show_url( lv_url ).
ULINE.
ELSE.
WRITE: / 'URL-Error:', sy-subrc.
ENDIF.
DATA(lv_length) = 0.
DATA: it_bin_data TYPE STANDARD TABLE OF tbl1024 WITH DEFAULT KEY.
DATA: lv_status TYPE char64.
DATA: lv_doc_type TYPE char64.
DATA: lv_arch_date TYPE d.
DATA: lv_arch_time TYPE t.
DATA: lv_mimetype TYPE char64.
DATA: it_scms_comps TYPE STANDARD TABLE OF scms_comps WITH DEFAULT KEY.
DATA: it_scms_compsl TYPE STANDARD TABLE OF scms_compsl WITH DEFAULT KEY.
* Status des AO lesen
* CMS: AO API Statusabfrage
CALL FUNCTION 'SCMS_AO_STATUS'
EXPORTING
arc_id = p_arc
doc_id = p_docid
IMPORTING
status = lv_status
doc_type = lv_doc_type
arch_date = lv_arch_date
arch_time = lv_arch_time
mimetype = lv_mimetype
TABLES
comps = it_scms_comps
compsl = it_scms_compsl
EXCEPTIONS
error_http = 1
error_kernel = 2
error_archiv = 3
error_config = 4
OTHERS = 5.
IF sy-subrc = 0.
LOOP AT it_scms_comps ASSIGNING FIELD-SYMBOL(<c>).
WRITE: / <c>-compid, <c>-mimetype, <c>-compsize, <c>-compdatec, <c>-comptimec, <c>-compdatem, <c>-comptimem, <c>-status.
ENDLOOP.
ELSE.
WRITE: / 'Status-Error:', sy-subrc.
ENDIF.
ULINE.
* Bin?rdaten des AO lesen
* CMS: AO API Dokument bereitstellen Tabelle
CALL FUNCTION 'SCMS_AO_TABLE_GET'
EXPORTING
arc_id = p_arc
doc_id = p_docid
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 getting AO-data:', sy-subrc.
ENDIF.
ELSE.
WRITE: / 'ARC_DOC_ID not found:', sy-subrc.
ENDIF.