Code: Alles auswählen.
method ONACTIONOPEN_PDF .
DATA lr_el_context TYPE REF TO if_wd_context_element.
DATA materialnummer TYPE mara-matnr VALUE '000000000000602205'.
DATA lt_draw TYPE DRAW.
DATA lt_drad TYPE DRAD.
DATA lv_xurl TYPE xstring.
DATA lv_url TYPE string.
DATA ls_documentdata TYPE bapi_doc_draw2.
SELECT * FROM DRAD INTO lt_drad WHERE OBJKY = materialnummer AND DOKAR = 'ZBA'.
ENDSELECT.
SELECT * FROM DRAW INTO lt_draw WHERE DOKNR = lt_drad-doknr.
ENDSELECT.
*Pfad und weitere Informationen über Datei holen
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = lt_draw-dokar
documentnumber = lt_draw-doknr
documentpart = lt_draw-doktl
documentversion = lt_draw-dokvr
* GETOBJECTLINKS = ' '
* GETCOMPONENTS = ' '
* GETSTATUSLOG = ' '
* GETLONGTEXTS = ' '
* GETACTIVEFILES = 'X'
* GETDOCDESCRIPTIONS = 'X'
* GETDOCFILES = 'X'
* GETCLASSIFICATION = ' '
* GETSTRUCTURE = ' '
* GETWHEREUSED = ' '
* HOSTNAME = ' '
* INHERITED = 'X'
IMPORTING
DOCUMENTDATA = ls_documentdata
* RETURN = ls_return
* TABLES
* OBJECTLINKS =
* DOCUMENTDESCRIPTIONS =
* LONGTEXTS =
* STATUSLOG =
* DOCUMENTFILES =
* COMPONENTS =
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTSTRUCTURE =
* WHEREUSEDLIST =
.
*Pfad setzen
lv_url = ls_documentdata-docfile1.
*Pfad in XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_url
* MIMETYPE = 'pdf'
* ENCODING =
IMPORTING
BUFFER = lv_xurl
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
*Attribut holen
lr_el_context = wd_context->get_element( ).
*Attribut mit xPfad setzen
lr_el_context->set_attribute(
EXPORTING
name = 'PDF'
value = lv_xurl ).
endmethod.