Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

To display image from a rawstring.

Former Member
0 Likes
2,272

Hello everyone,

I m trying to display image on screen with CL_GUI_PICTURE. Additionally, the image is stored in database as RAWSTRING.

I have tried using  DP_CREATE_URL to create a published URL for image. Below is the code snippet which is not working. On the other hand, I am able to display image uploaded via SE78 so the container usage is fine.

TYPES: BEGIN OF ts_hex,

            hex TYPE xstring,

          END OF ts_hex.


data: lt_pic type table of ts_hex,

        ls_pic type ts_hex.

select single * into ls_table_row from <images_table>.


ls_pic-hex = ls_table_row-image_hex.

append ls_pic to lt_pic.

CALL FUNCTION 'DP_CREATE_URL'

      EXPORTING

        type     = 'IMAGE'

        subtype  = cndp_sap_tab_unknown

      TABLES

         data = lt_pic

      CHANGING

           url = lv_url.

CALL METHOD lo_picture->load_picture_from_url_async

       EXPORTING

         url = lv_url.

Hello everyone,

I m trying to display image on screen with CL_GUI_PICTURE. Additionally, the image is stored in database as RAWSTRING.

I have tried using  DP_CREATE_URL to create a published URL for image. Below is the code snippet which is not working. On the other hand, I am able to display image uploaded via SE78 so the container usage is fine.

TYPES: BEGIN OF ts_hex,

            hex TYPE xstring,

          END OF ts_hex.


data: lt_pic type table of ts_hex,

        ls_pic type ts_hex.

select single * into ls_table_row from <images_table>.


ls_pic-hex = ls_table_row-image_hex.

append ls_pic to lt_pic.

CALL FUNCTION 'DP_CREATE_URL'

      EXPORTING

        type     = 'IMAGE'

        subtype  = cndp_sap_tab_unknown

      TABLES

         data = lt_pic

      CHANGING

           url = lv_url.

CALL METHOD lo_picture->load_picture_from_url_async

       EXPORTING

         url = lv_url.

4 REPLIES 4
Read only

Former Member
0 Likes
1,641

Hi,

Provide graphic size  also in below function module.

  CALL FUNCTION 'DP_CREATE_URL'
  EXPORTING
  TYPE = 'IMAGE'
  SUBTYPE = 'X-UNKNOWN'
  SIZE = GRAPHIC_SIZE
  LIFETIME = 'T'
  TABLES
  DATA = GRAPHIC_TABLE
  CHANGING
  URL = URL.



Thanks,

Ashok.

Read only

0 Likes
1,641

Hi Ashok,

Thank you for your reply. Now program gives a short dump but I don't know what is going wrong.

Dump details:

Program                               SAPLOLEA

Include                                 LOLEAU10

Row                                     371

Module Type                        (FUNCTION)

Module Name                       AC_FLUSH_CALL_INTERNAL

Actual code:

CREATE OBJECT lo_custom_container

     EXPORTING

       container_name = 'CUSTOM_CONTAINER'.

 

   CREATE OBJECT lo_picture

     EXPORTING

       parent = lo_custom_container.

READ TABLE gt_pics INTO ls_image index 1.

     ls_pic_data-text = ls_image-picture.

     APPEND ls_pic_data TO lt_pic_data.

     lv_size = xstrlen( ls_pic_data-text ).

     CALL FUNCTION 'DP_CREATE_URL'

       EXPORTING

         type     = 'IMAGE'

         subtype  = 'X-UKNOWN'

         size     = lv_size

        lifetime = 'T'

      TABLES

         data     = lt_pic_data

      CHANGING

         url      = lv_logo_url.

     CALL METHOD lo_picture->load_picture_from_url

       EXPORTING

         url = lv_logo_url.

Read only

0 Likes
1,641

Hi,

Is gt_pics contains only one line?

Thanks,

Ashok.

Read only

0 Likes
1,641

Yes, it is one image per row. The data is something like this (this is not the entire field value as there are limitations to SE16)

75AB5A8A66A07BF8E97A06DAB1EEB8FFD8FFE000104A46494600010100000100010000FFDB00