Application Development 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: 

Display Image

Former Member
0 Kudos

Hi Abapers,

I want to display a image in a module pool program... can you please provide me some help in this case

rg

sameer

1 ACCEPTED SOLUTION

valter_oliveira
Active Contributor
0 Kudos

First of all create a custom container (let's call it container) in your screen painter, and then create this variables (globally):


DATA: container TYPE REF TO cl_gui_custom_container,
      logo      TYPE REF TO cl_gui_picture.
DATA: url(255) TYPE c.
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
      html_table LIKE w3html OCCURS 1,
      return_code LIKE  w3param-ret_code,
      content_type LIKE  w3param-cont_type,
      content_length LIKE  w3param-cont_len,
      pic_data LIKE w3mime OCCURS 0,
      pic_size TYPE i.

Then, in your screen PBO, insert code similar to this:


MODULE m_ins_image.

* Only search first time
  CHECK url IS INITIAL.

* Initialize container object
  IF container IS INITIAL.
    CREATE OBJECT container
      EXPORTING
        container_name = 'CONTAINER'
      EXCEPTIONS
        OTHERS         = 1.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
  ENDIF.

* Inicialize logo object
  IF logo IS INITIAL.
    CREATE OBJECT logo
      EXPORTING
        parent = container
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
  ENDIF.

* Image name
  REFRESH query_table.
  query_table-name  = '_OBJECT_ID'.               
  query_table-value = 'ZPICTURE'.                 
  APPEND query_table.

* GET MIME
  CALL FUNCTION 'WWW_GET_MIME_OBJECT'
    TABLES
      query_string        = query_table
      html                = html_table
      mime                = pic_data
    CHANGING
      return_code         = return_code
      content_type        = content_type
      content_length      = content_length
    EXCEPTIONS
      object_not_found    = 1
      parameter_not_found = 2
      OTHERS              = 3.
  IF sy-subrc = 0.
    pic_size = content_length.
  ENDIF.

* DISPLAY data
  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      type     = 'image'
      subtype  = cndp_sap_tab_unknown
      size     = pic_size
      lifetime = cndp_lifetime_transaction
    TABLES
      data     = pic_data
    CHANGING
      url      = url
    EXCEPTIONS
      OTHERS   = 1.

  CALL METHOD logo->load_picture_from_url
    EXPORTING
      url    = url
    EXCEPTIONS
      OTHERS = 1.

ENDMODULE.

Regards.

Valter Oliveira.

1 REPLY 1

valter_oliveira
Active Contributor
0 Kudos

First of all create a custom container (let's call it container) in your screen painter, and then create this variables (globally):


DATA: container TYPE REF TO cl_gui_custom_container,
      logo      TYPE REF TO cl_gui_picture.
DATA: url(255) TYPE c.
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
      html_table LIKE w3html OCCURS 1,
      return_code LIKE  w3param-ret_code,
      content_type LIKE  w3param-cont_type,
      content_length LIKE  w3param-cont_len,
      pic_data LIKE w3mime OCCURS 0,
      pic_size TYPE i.

Then, in your screen PBO, insert code similar to this:


MODULE m_ins_image.

* Only search first time
  CHECK url IS INITIAL.

* Initialize container object
  IF container IS INITIAL.
    CREATE OBJECT container
      EXPORTING
        container_name = 'CONTAINER'
      EXCEPTIONS
        OTHERS         = 1.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
  ENDIF.

* Inicialize logo object
  IF logo IS INITIAL.
    CREATE OBJECT logo
      EXPORTING
        parent = container
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
  ENDIF.

* Image name
  REFRESH query_table.
  query_table-name  = '_OBJECT_ID'.               
  query_table-value = 'ZPICTURE'.                 
  APPEND query_table.

* GET MIME
  CALL FUNCTION 'WWW_GET_MIME_OBJECT'
    TABLES
      query_string        = query_table
      html                = html_table
      mime                = pic_data
    CHANGING
      return_code         = return_code
      content_type        = content_type
      content_length      = content_length
    EXCEPTIONS
      object_not_found    = 1
      parameter_not_found = 2
      OTHERS              = 3.
  IF sy-subrc = 0.
    pic_size = content_length.
  ENDIF.

* DISPLAY data
  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      type     = 'image'
      subtype  = cndp_sap_tab_unknown
      size     = pic_size
      lifetime = cndp_lifetime_transaction
    TABLES
      data     = pic_data
    CHANGING
      url      = url
    EXCEPTIONS
      OTHERS   = 1.

  CALL METHOD logo->load_picture_from_url
    EXPORTING
      url    = url
    EXCEPTIONS
      OTHERS = 1.

ENDMODULE.

Regards.

Valter Oliveira.