Skip to Content

Displaying an image stored in hex value format INDX Table at backend in the smartform(abap)

Nov 30, 2017 at 05:52 AM


avatar image

Hi Experts,

We have stored the image data fetched from the front-end SAPUI5 application into the INDX table at backend . We have used oData for saving this image in the hex value format in a specified area(RELID field) in INDX table.

We have to fetch this image and display it in a smartform output at abap end.

But We are not able to convert the image data stored in INDX table into a proper image format to be displayed in the smartform.

I am adding the oData /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM code for saving my image into INDX table.

font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
.L0S31 {
font-style: italic;
color: #808080;
.L0S32 {
color: #3399FF;
.L0S33 {
color: #4DA619;
.L0S52 {
color: #0000FF;
.L0S55 {
color: #800080;


 DATA: lv_id         TYPE indx_srtfd,

          lw_attachment TYPE zcl_ztest_jsqireport_mpc=>TS_ZATTACHMENT,

          lv_no         TYPE i.

 FIELD-SYMBOLS: <lfs_file> LIKE LINE OF gt_file.

    CONCATENATE 'ZATDAATT_' sy-uname INTO lv_id.

    IMPORT tab = gt_file

    FROM DATABASE indx(zm)

    ID lv_id.

    IF sy-subrc = 0.

      lv_no = lines( gt_file ).



*  <lfs_file>-notif_no = lv_notif_no.

    <lfs_file>-fname = iv_slug.

    lv_no = lv_no + 1.

    <lfs_file>-counter = lv_no.

    <lfs_file>-mime_type = is_media_resource-mime_type.

    <lfs_file>-data = is_media_resource-value.

    EXPORT tab = gt_file

    TO DATABASE indx(zm)

    ID lv_id.

 no_cache( ).

    lw_attachment-file_name = iv_slug.

    lw_attachment-mime_code = is_media_resource-mime_type.



        is_data = lw_attachment


        cr_data = er_entity


10 |10000 characters needed characters left characters exceeded

That's just a comment, not an answer:

  • That's a bad practice if you have done direct input into this standard database table (data cluster table INDX). You should always define/use a Z custom table. INDX is not a special table that customers can use.
  • It's also considered not to be the primary choice to save "files" into a data cluster table (statement EXPORT TO DATABASE). Instead, you should simply define a BLOB/RAWSTRING column in a Z custom classic transparent table (you may compress the file data before saving) because you may benefit of SQL BLOB features.

For more information, cf

* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Nov 30, 2017 at 11:40 AM

For printing an image in a smartform, upload it via transaction SE78, then embed it in the smart form. About dynamic images at runtime: there were several discussions/articles about it, as it's not standard.

10 |10000 characters needed characters left characters exceeded