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: 

Custom container not clearing in module pool screen.

0 Kudos

Dear Experts,

I have created a custom controllers MAT1,MAT2,MAT3.... in custom screen.

based on the material group selected the custom control (pitures) will be filled.

when I press material group1 , all the materials(pictures) of material group one are filling correctly in custom control .

problem is when I press material gruop2 it is showing material group1 only.

Its not clearing the custom control.

Can any one help me how to achieve this.

for your reference attached code

********************************************************

LOOP AT it_mat INTO wa_mat.
     CLEAR l_txt.
     CASE sy-tabix.
       WHEN 1.
         READ TABLE it_mat_img INTO wa_mat_img WITH KEY matnr = wa_mat-matnr.

*     SCREEN 9010.

         CREATE OBJECT container_mat1
           EXPORTING
             container_name = 'MAT1'.

         CREATE OBJECT picture_control_mat1 EXPORTING parent = container_mat1.

         REFRESH:event_tab.

         event-eventid = cl_gui_picture=>eventid_control_click.
         APPEND event TO event_tab.
         CALL METHOD picture_control_mat1->set_registered_events
           EXPORTING
             events = event_tab.

         CREATE OBJECT event_receiver_mat1.
         SET HANDLER event_receiver_mat1->event_handler_control_click
                         FOR picture_control_mat1.

         CALL METHOD picture_control_mat1->set_display_mode
           EXPORTING
             display_mode = cl_gui_picture=>display_mode_fit_center.

         CALL METHOD picture_control_mat1->set_3d_border
           EXPORTING
             border = 1.
         l_txt = wa_mat-matnr.
         CALL METHOD picture_control_mat1->set_tooltip
           EXPORTING
             text = l_txt. "'Test'.

         CLEAR :graphic_size,l_graphic_conv,l_graphic_xstr,graphic_url.
         REFRESH :graphic_table[].

         CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
           EXPORTING
             p_object  = 'GRAPHICS'
             p_name    = wa_mat_img-zimage "'ZRETAIL_LOGO' "wa_gp-zimage  ""IMAGE NAME - Image name from SE78
             p_id      = 'BMAP'
*           p_btype   = 'BMON'  "(BMON = black&white, BCOL = colour)
             p_btype   = 'BCOL'  "(BMON = black&white, BCOL = colour)
           RECEIVING
             p_bmp     = l_graphic_xstr
           EXCEPTIONS
             not_found = 1
             OTHERS    = 2.

         graphic_size = xstrlen( l_graphic_xstr ).
         CHECK graphic_size > 0.

         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'               "#EC NOTEXT
             subtype  = cndp_sap_tab_unknown " 'X-UNKNOWN'
             size     = graphic_size
             lifetime = cndp_lifetime_transaction  "'T'
           TABLES
             data     = graphic_table
           CHANGING
             url      = graphic_url
           EXCEPTIONS
*           dp_invalid_parameter = 1
*           dp_error_put_table   = 2
*           dp_error_general     = 3
             OTHERS   = 4.
         IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
           EXIT.
         ENDIF.

         CALL METHOD picture_control_mat1->load_picture_from_url
           EXPORTING
*           url = url.
             url = graphic_url.

         CALL METHOD picture_control_mat1->set_display_mode
           EXPORTING
             display_mode = cl_gui_picture=>display_mode_fit.
         "am
         CALL METHOD cl_gui_cfw=>flush
           EXCEPTIONS
             cntl_system_error = 1
             cntl_error        = 2.

         " am end

       WHEN 2 .
         BREAK-POINT.
         READ TABLE it_mat_img INTO wa_mat_img WITH KEY matnr = wa_mat-matnr.
         CREATE OBJECT container_mat2
           EXPORTING
             container_name = 'MAT2'.

         CREATE OBJECT picture_control_mat2 EXPORTING parent = container_mat2.

         REFRESH:event_tab.

         event-eventid = cl_gui_picture=>eventid_control_click.
         APPEND event TO event_tab.
         CALL METHOD picture_control_mat2->set_registered_events
           EXPORTING
             events = event_tab.

         CREATE OBJECT event_receiver_mat2.
         SET HANDLER event_receiver_mat2->event_handler_control_click
                         FOR picture_control_mat2.

         CALL METHOD picture_control_mat2->set_display_mode
           EXPORTING
             display_mode = cl_gui_picture=>display_mode_fit_center.

         CALL METHOD picture_control_mat2->set_3d_border
           EXPORTING
             border = 1.
         l_txt = wa_mat-matnr.
         CALL METHOD picture_control_mat2->set_tooltip
           EXPORTING
             text = l_txt. "'Test'.

         CLEAR :graphic_size,l_graphic_conv,l_graphic_xstr,graphic_url.
         REFRESH :graphic_table[].

         CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
           EXPORTING
             p_object  = 'GRAPHICS'
             p_name    = wa_mat_img-zimage  ""IMAGE NAME - Image name from SE78
             p_id      = 'BMAP'
*           p_btype   = 'BMON'  "(BMON = black&white, BCOL = colour)
             p_btype   = 'BCOL'  "(BMON = black&white, BCOL = colour)
           RECEIVING
             p_bmp     = l_graphic_xstr
           EXCEPTIONS
             not_found = 1
             OTHERS    = 2.

         graphic_size = xstrlen( l_graphic_xstr ).
         CHECK graphic_size > 0.

         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'               "#EC NOTEXT
             subtype  = cndp_sap_tab_unknown " 'X-UNKNOWN'
             size     = graphic_size
             lifetime = cndp_lifetime_transaction  "'T'
           TABLES
             data     = graphic_table
           CHANGING
             url      = graphic_url
           EXCEPTIONS
*           dp_invalid_parameter = 1
*           dp_error_put_table   = 2
*           dp_error_general     = 3
             OTHERS   = 4.
         IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
           EXIT.
         ENDIF.

         CALL METHOD picture_control_mat2->load_picture_from_url
           EXPORTING
*           url = url.
             url = graphic_url.

         CALL METHOD picture_control_mat2->set_display_mode
           EXPORTING
             display_mode = cl_gui_picture=>display_mode_fit.

       WHEN 3 .
       WHEN OTHERS.
     ENDCASE.

   ENDLOOP.

1 REPLY 1

Sandra_Rossi
Active Contributor
0 Kudos

I think it's the classic issue that you don't call the method FREE, so you always see the first control overriding the subsequent controls later instantiated.