* Dokumentart (TA DC10, Tabelle TDWA)
PARAMETERS: p_type TYPE bapi_doc_aux-doctype OBLIGATORY.
* Dokumentnummer, mit Suchhilfe auf Tabelle DRAW (Dokumentinformationssatz)
PARAMETERS: p_num TYPE bapi_doc_aux-docnumber OBLIGATORY DEFAULT '10000000001' MATCHCODE OBJECT /plmb/dir_elm.
* Teildokument
PARAMETERS: p_part TYPE bapi_doc_aux-docpart OBLIGATORY DEFAULT '000'.
* Dokumentversion
PARAMETERS: p_ver TYPE bapi_doc_aux-docversion OBLIGATORY DEFAULT '00'.
START-OF-SELECTION.
DATA: lv_bapi_doc_draw2 TYPE bapi_doc_draw2.
DATA: lv_bapiret2 TYPE bapiret2.
DATA: it_documentfiles TYPE STANDARD TABLE OF bapi_doc_files2 WITH DEFAULT KEY.
* Determine Detail Data for a Document
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = p_type
documentnumber = p_num
documentpart = p_part
documentversion = p_ver
getactivefiles = abap_true
getdocdescriptions = abap_true
getdocfiles = abap_true
IMPORTING
documentdata = lv_bapi_doc_draw2
return = lv_bapiret2
TABLES
documentfiles = it_documentfiles.
cl_demo_output=>write_data( p_type ).
cl_demo_output=>write_data( p_num ).
cl_demo_output=>write_data( p_part ).
cl_demo_output=>write_data( p_ver ).
cl_demo_output=>write_data( lv_bapiret2 ).
cl_demo_output=>write_data( lv_bapi_doc_draw2 ).
cl_demo_output=>write_data( it_documentfiles ).
IF lv_bapiret2-type CA 'EA'.
ELSE.
IF lines( it_documentfiles ) > 0.
DATA: it_access_info TYPE STANDARD TABLE OF scms_acinf WITH DEFAULT KEY.
DATA: it_content_txt TYPE STANDARD TABLE OF sdokcntasc WITH DEFAULT KEY.
DATA: it_content_bin TYPE STANDARD TABLE OF sdokcntbin WITH DEFAULT KEY.
* CMS: Dokument lesen
CALL FUNCTION 'SCMS_DOC_READ'
EXPORTING
stor_cat = it_documentfiles[ 1 ]-storagecategory
doc_id = it_documentfiles[ 1 ]-file_id
no_cache = abap_true
TABLES
access_info = it_access_info
content_txt = it_content_txt
content_bin = it_content_bin
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 sy-subrc = 0.
cl_demo_output=>write_data( it_access_info ).
cl_demo_output=>write_data( it_content_txt ).
* Binärdaten für weitere Verarbeitung (Speichern, Anzeigen ...)
cl_demo_output=>write_data( it_content_bin ).
ENDIF.
ENDIF.
* HTML-Code vom Demo-Output holen
DATA(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
cl_abap_browser=>show_html( EXPORTING title = 'SCMS_DOC_READ'
html_string = lv_html
container = cl_gui_container=>default_screen ).
* cl_gui_container=>default_screen erzwingen
WRITE: space.
ENDIF.