Display thumbnails of documents using a content server (KPRO) with ABAP
Hi all,
In my first blog on SCN I want to show some tricky stuff to get the thumbnail image data and show up in a Dynpro.
In every ERP system is a document storage involved. But for this example I want to show how to get the image data out of a external storage. There are different description for it and maybe I mixed it up: content server, KPRO (knowledge provider)
Tcodes:
SAP menu –> Logistics –> Project System –> Documents –> Document Management System –> Document:
- CV01N, … , CV04N
The bad thing for a external storage is that the ERP system doesn’t get the image data directly, if you call up an original, it just send the Link-address from the content server to the client (SAP Gui). There is no (image)data transfer between ERP and the client.
So the key is to get the link URL and show this thumbnail in a dynpro. I suppose that the customizing is set up correctly with a defined Thumbnail (small picture) WS-application.
Well there is a function CL_DMS_THUMBNAIL_DISPLAY=>GET_URL to catch the URL for the selected document number.
The next thing is to set up an custom container in a dynpro screen create the objects and show up the image data to it.
The thumbnail will be shown in the same height and width what the custom container has in your dynpro.
The complete code with additional pictures is available here: https://wiki.sdn.sap.com/wiki/x/kgB_Ag
–> code snip – begin
DATA: gv_url TYPE dms_url,
gs_doc TYPE bapi_doc_keys,
gr_thumbnail TYPE REF TO cl_gui_custom_container,
gr_picture TYPE REF TO cl_gui_picture.
CALL METHOD cl_dms_thumbnail_display=>get_url
EXPORTING i_doc = gs_doc
IMPORTING e_url = gv_url.
IF NOT gv_url IS INITIAL.
CREATE OBJECT gr_thumbnail
EXPORTING container_name = ‘CV_THUMBNAIL’.
CREATE OBJECT gr_picture
EXPORTING parent = gr_thumbnail.
CALL METHOD gr_picture->set_display_mode
EXPORTING display_mode = gr_picture->display_mode_fit_center.
gr_picture->load_picture_from_url_async( url = gv_url ).
ENDIF.
–> code snip – end
My next quest is to show up such thumbnails into print forms (Adobe Interactive Forms, Smartforms, SAP Script) and put it out on printers. If you have useful hints please write it down in the comments or extend the wiki page. Thanks!
Actually this URL basically works like a REST based Web Service. You can call the URL and the response body is the image data. You can get the data into ABAP memory using the CL_HTTP_CLIENT class. This class allows you to make HTTP Requests directly from ABAP.
Once you have the image content in memory on ABAP you can do all sorts of interesting things. I have written programs in the past to send the image data to the IGS to do image format conversions or done direct manipulation on the image at the byte level in ABAP directly (rotation, inversion, etc).
thanks for your comment!
If my testsystem is ready again on monday (finally with EHP3) 🙂 I'll test it.
I remember the image processing thing which was initialized by Blag 🙂 and now found additional weblogs for this class on sdn by you.
Hopefully it brings me one step forward to print originals on paper...
Thanks so much
Steffen
I tried out what you said, but the problem is that the URL I'll get by the CL_DMS_THUMBNAIL_DISPLAY=>GET_URL is not an "http" one. It is something like that:
SAPR3://SAPR3CMS/get/100/ZCS_5FTEST_5FSYSTEM_5F100/7DC37D4857B78E7DE1000000AC138504/216_5FKL_5FED.jpg (I'm able to follow this link on the harddrive of the content server [the '5F' seem to be some escape characters])
And I didn't found a why to create a valid HTTP link out of this.
What I found out is that the string (7DC37D4857B78E7DE1000000AC138504) is the document id which is coded and in SAP somethin like that '21100396'
Do you have more helpful suggestions?
Thanks, Steffen
thanx
hasan