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

Refresh custom control to show another image | Module pool programming

Former Member
0 Likes
2,491

Hi experts, I'm facing this issue :

1 - Via a screen, the user enter the name of a logo which was previously added via SE78

2 - On a custom control the logo should be displayed.

It works only when I save and run again the program...

I want to refresh the custom container within the PBO to be able to display the changed logo.

For displaying images I'm using this Form  (the variables are in blue) :

FORM show_image CHANGING   lv_cont_name

   lv_pic_name TYPE tdobname.

*    data: l_object      like p_object,

*        l_name        like p_name.

   DATA: w_lines TYPE i.

   TYPES pict_line(256) TYPE c.

   DATA :

   container TYPE REF TO cl_gui_custom_container,

   editor TYPE REF TO cl_gui_textedit,

   picture TYPE REF TO cl_gui_picture,

   pict_tab TYPE TABLE OF pict_line,

   url(255) TYPE c.

   DATA: graphic_url(255).

   DATA: BEGIN OF graphic_table OCCURS 0,

           line(255) TYPE x,

         END OF graphic_table.

   DATA: l_graphic_conv TYPE i.

   DATA: l_graphic_offs TYPE i.

   DATA: graphic_size TYPE i.

   DATA: l_graphic_xstr TYPE xstring.

   CALL METHOD cl_gui_cfw=>flush.

   CREATE OBJECT:

   container EXPORTING container_name = lv_cont_name,

   picture EXPORTING parent = container.

   CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

     EXPORTING

       p_object       = 'GRAPHICS'

       p_name         = lv_pic_name

       p_id           = 'BMAP'

       p_btype        = 'BCOL'

     RECEIVING

       p_bmp          = l_graphic_xstr

*  EXCEPTIONS

*    NOT_FOUND      = 1

*    INTERNAL_ERROR = 2

*    others         = 3

           .

   IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   graphic_size = XSTRLEN( l_graphic_xstr ).

   l_graphic_conv = graphic_size.

   l_graphic_offs = 0.

   WHILE l_graphic_conv > 255.

     graphic_table-line = l_graphic_xstr+l_graphic_offs(255).

     APPEND graphic_table.

     l_graphic_offs = l_graphic_offs + 255.

     l_graphic_conv = l_graphic_conv - 255.

   ENDWHILE.

   graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

   APPEND graphic_table.

   CALL FUNCTION 'DP_CREATE_URL'

     EXPORTING

       type     = 'IMAGE'

       subtype  = 'X-UNKNOWN'

       size     = graphic_size

       lifetime = 'T'

     TABLES

       data     = graphic_table

     CHANGING

       url      = url.

   CALL METHOD picture->load_picture_from_url

     EXPORTING

       url = url.

   CALL METHOD picture->set_display_mode

     EXPORTING

       display_mode = picture->display_mode_fit_center.

ENDFORM.                    "Show_Image

1 ACCEPTED SOLUTION
Read only

max_anjos
Explorer
1,342

Hi,

Try this examples:

"

IF url IS NOT INITIAL.

    CALL METHOD picture->clear_picture

      EXCEPTIONS

        error = 1.

  

  CALL METHOD picture->load_picture_from_url

     EXPORTING

       url = url.

   CALL METHOD picture->set_display_mode

     EXPORTING

       display_mode = picture->display_mode_fit_center.

    CALL METHOD picture->set_display_mode

      EXPORTING

        display_mode = picture->display_mode_normal_center

      EXCEPTIONS

        error        = 1.

    CALL METHOD cl_gui_cfw=>update_view.

  ENDIF.

"

6 REPLIES 6
Read only

max_anjos
Explorer
1,343

Hi,

Try this examples:

"

IF url IS NOT INITIAL.

    CALL METHOD picture->clear_picture

      EXCEPTIONS

        error = 1.

  

  CALL METHOD picture->load_picture_from_url

     EXPORTING

       url = url.

   CALL METHOD picture->set_display_mode

     EXPORTING

       display_mode = picture->display_mode_fit_center.

    CALL METHOD picture->set_display_mode

      EXPORTING

        display_mode = picture->display_mode_normal_center

      EXCEPTIONS

        error        = 1.

    CALL METHOD cl_gui_cfw=>update_view.

  ENDIF.

"

Read only

Former Member
0 Likes
1,342

I was using local variables, when I declered them as global vars it worked pretty well, thank you.

Read only

0 Likes
1,342

Hi,

Here I really insert the objects "picture" and "container" as global variables, and it worked!:

FORM show_image CHANGING   lv_cont_name

                                                              lv_pic_name TYPE tdobname.

*    data: l_object      like p_object,

*        l_name        like p_name.

   DATA: w_lines TYPE i.

   TYPES pict_line(256) TYPE c.

   DATA :

   container TYPE REF TO cl_gui_custom_container,

   editor TYPE REF TO cl_gui_textedit,

   picture TYPE REF TO cl_gui_picture,

   pict_tab TYPE TABLE OF pict_line,

   url(255) TYPE c.

   DATA: graphic_url(255).

   DATA: BEGIN OF graphic_table OCCURS 0,

           line(255) TYPE x,

         END OF graphic_table.

   DATA: l_graphic_conv TYPE i.

   DATA: l_graphic_offs TYPE i.

   DATA: graphic_size TYPE i.

   DATA: l_graphic_xstr TYPE xstring.

   CALL METHOD cl_gui_cfw=>flush.

"only alteration

IF container IS NOT BOUND.

     CREATE OBJECT

       container

       EXPORTING

         container_name = lv_cont_name.

   ENDIF.

  IF picture IS NOT BOUND.

    CREATE OBJECT picture

       EXPORTING

         parent = container .

  ENDIF.


   CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

     EXPORTING

       p_object       = 'GRAPHICS'

       p_name         = lv_pic_name

       p_id           = 'BMAP'

       p_btype        = 'BCOL'

     RECEIVING

       p_bmp          = l_graphic_xstr

*  EXCEPTIONS

*    NOT_FOUND      = 1

*    INTERNAL_ERROR = 2

*    others         = 3

           .

   IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   graphic_size = XSTRLEN( l_graphic_xstr ).

   l_graphic_conv = graphic_size.

   l_graphic_offs = 0.

   WHILE l_graphic_conv > 255.

     graphic_table-line = l_graphic_xstr+l_graphic_offs(255).

     APPEND graphic_table.

     l_graphic_offs = l_graphic_offs + 255.

     l_graphic_conv = l_graphic_conv - 255.

   ENDWHILE.

   graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

   APPEND graphic_table.

   CALL FUNCTION 'DP_CREATE_URL'

     EXPORTING

       type     = 'IMAGE'

       subtype  = 'X-UNKNOWN'

       size     = graphic_size

       lifetime = 'T'

     TABLES

       data     = graphic_table

     CHANGING

       url      = url.

   CALL METHOD picture->load_picture_from_url

     EXPORTING

       url = url.

   CALL METHOD picture->set_display_mode

     EXPORTING

       display_mode = picture->display_mode_fit_center.

ENDFORM.                    "Show_Image

Read only

max_anjos
Explorer
0 Likes
1,342

This message was moderated.

Read only

Former Member
0 Likes
1,342

Dear Max dos anjos, your answer was helpful to me, but unfortunately the image still displayed after changing the logo name and loading the PBO. 

Read only

0 Likes
1,342

I'm sorry, I believed that my answer helped in this choice! But, with the objects as global variables... It worked?