How to add an image to a SAP Adobe Form from the MIME repository?

Esti picture Esti · Sep 7, 2010 · Viewed 14k times · Source

I have loaded an image to the SAP MIME Repository:

Name: watermark100.bmp

MIME Type: Icon (Under technical information on the properties window. I didn't set this, I assume SAP defaults that in based on the file type when I upload).

Now I'm trying to display this image in a SAP adobe form:

In the Form Interface I have created a global Constant:

GV_IMG_WATERMARK TYPE STRING VALUE 'watermark100.bmp'

In the Context I have created a Graphic Node:

Name:         WATERMARK
Graphic Type: GRAPHIC CONTENT
Field:        GV_IMG_WATERMARK 
MIME Type:    'icon'  //I have also tried '.bmp'

Unfortunately, when I test the form, no image displays. Any idea what I'm doing wrong?

Additional Comments:

  • I can display the image by pointing to the URL & embedding it in the form, but that is not sufficient for what I'm trying to do. The image have to be loaded from MIME, and displaying the node will be conditional.
  • There seems to be a somewhat convoluted way where I can convert the image to an XSTRING and pass that to the form, I will probably try that next, but it seems overly complex for what I'm trying to achieve.

Answer

Esti picture Esti · Sep 7, 2010

Ok I've solved it in the following way:

Changed the data declarations as follows: The URL just follows the tree structure in the MIME Repository

data:      gv_bmp_watermark type xstring.
constants: gc_url_watermark type string 
    value '/BC/PUBLIC/MyImages/watermark100.bmp'.

In the interface under Code Initialization I added the following: (Note that you have to import & export the relevant variables using the interface at the top - you'll get a fairly self-explanatory compile error if you don't)

//* Read Images
data: lr_api type ref to if_mr_api.

lr_api = cl_mime_repository_api=>get_api( ).

lr_api->get( exporting i_url = gc_url_watermark
             importing e_content = gv_bmp_watermark ).

The Context node only changed slightly:

Name:         WATERMARK         
Graphic Type: GRAPHIC CONTENT         
Field:        GV_BMP_WATERMARK          
MIME Type:    'image/bmp'