Hallo,
habe das Problem folgendermassen gelöst:
( nicht alle Datendeklarationen werden benötigt
)
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
ls_ps_count_def type dms_checkout_def,
ls_ps_doc_file type dms_doc_file,
ls_ps_draw type draw,
ls_ps_frontend type dms_frontend_data,
lt_ptx_content type table of drao,
ls_ptx_content type drao,
lv_lines type sy-tabix,
lv_strlen type xstring,
lv_count type i,
lv_orblk type string,
l_length type p length 16,
l_content type tsf_xsf_ct,
w_file type xstring,
l_grline type line of tsf_xsf_ct,
l_linelength type i,
url type string,
guid type guid_32,
matnr1 type bapi_doc_drad-objectkey,
cached_response type ref to if_http_response,
lt_documentlist type table of bapi_doc_keys,
ls_documentlist type bapi_doc_keys,
lt_documentfiles type table of bapi_doc_files2,
ls_documentfiles type bapi_doc_files2,
* sructure for export table with mime data and content
ls_table_urls type zbc_ols_url,
ls_draz type draz,
lv_text type string.
constants: lc_objecttype
type bapi_doc_drad
-objecttype
value 'MARA'.
- GeSHi ©
Ausgangspunkt ist der Materialstamm.
Hier erhalten wir die einem Materialstamm zugeordneten Dokumentenstämme mit Documenttype, Documentnumber, und Documentpart
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
call function 'BAPI_DOCUMENT_GETOBJECTDOCS'
exporting
objecttype = lc_objecttype
objectkey = matnr1
currentversionsonly = 'X'
date = sy-datum
documentlist = lt_documentlist.
- GeSHi ©
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
loop at lt_documentlist
into ls_documentlist
.
- GeSHi ©
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
select * from drao
into table lt_ptx_content
where dokar = ls_documentlist-documenttype
and doknr = ls_documentlist-documentnumber
and dokvr = ls_documentlist-documentversion
and doktl = ls_documentlist-documentpart
and appnr = ls_documentfiles-originaltype.
- GeSHi ©
jetzt werden die BINÄR-Daten in ein XSTRING-Feld transportiert damit dieses
anschliessend der Funktion zur Verfügung gestellt werden kann.
Ermittlung der Gesamtanzahl Zeilen
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
describe table lt_ptx_content lines lv_lines.
- GeSHi ©
Lesen des letzten Eintrage um für diesen die Länge zu ermitten. Der letzte
Eintrag füllt unter Umständen nicht das gesamte Feld. Es darf aber in das
XSTRING Feld nur in der tatsächlichen Länge angehängt werden. Alle anderen
Tabelleneinträge füllen das Feld immer komplett, nur das letzte nicht.
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
read table lt_ptx_content into ls_ptx_content index lv_lines.
- GeSHi ©
jetzt das letzte Feld in eine lokale Variable
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
move ls_ptx_content
-orblk
to lv_orblk
.
- GeSHi ©
jetzt bestimmen wir die tatsächliche Länge des letzten Feldes
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
lv_strlen = strlen( lv_orblk ).
- GeSHi ©
jetzt wird noch die Feldänge des Originalfeldes besorgt (sind hier 2550)
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
describe field ls_ptx_content-orblk length l_linelength in byte mode.
- GeSHi ©
nun werden die einzelnen Tabelleneinträge in das XSTING-Feld gefüllt. Immer
das komplette Feld bis zum letzten Eintrag
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
loop at lt_ptx_content
into ls_ptx_content
.
- GeSHi ©
Zähler ist kleiner als Gesamtanzahl Zeilen
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- GeSHi ©
hänge die Daten an das XSTRING Feld an
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
concatenate w_file ls_ptx_content
-orblk
into w_file
in byte mode. l_length = l_length + l_linelength.
- GeSHi ©
beim letzten Eintrag wird nur in Länge der tatsächlich vorhandenen
Daten angehängt.
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
concatenate w_file ls_ptx_content
-orblk
&#
40;lv_strlen
&#
41;
into w_file
in byte mode. lv_count = lv_count + 1.
- GeSHi ©
Das Feld w_file enthät nun die Binären Daten des Bilds aus dem Dokumentenstamm.
Anschließend muss eine URL zusammengebastelt werden, mit welcher das Bild (Link) im Layout gebunden wird. Stelle diese URL als variable vom Typ String in deinen View-Context:
siehe hier:
http://forums.sdn.sap.com/thread.jspa?t ... 0&tstart=0Viel Spaß
und Gruß.
Daniel.