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

CL_GUI_CUSTOM_CONTAINER

Former Member
0 Likes
2,907

Hi xperts,

I am using CL_GUI_CUSTOM_CONTAINER class in one of my module pool program. Could you please explain me what is the usage of method 'Free' in this class in detail, if possible with some examples.

Thanks,

Rahul

3 REPLIES 3
Read only

Former Member
0 Likes
2,200

hi rahul,

hope it helps.

Use this method to destroy a custom control at the frontend. Once you have called this method, you should also initialize the object reference ( FREE my_control ).

CALL METHOD my_control->free

EXCEPTIONS cntl_error = 1

cntl_system_error = 2.

reward if helpful.

regards,

srishti

Read only

Former Member
0 Likes
2,200

hi,

Use the method free to destroy the Custom Control at the frontend. If you no longer need the control container, release it as well:

When you destroy a container, all controls in it are automatically destroyed as well. If you have already destroyed a control and try to destroy it again, an error occurs.

CALL METHOD picture->free

EXCEPTIONS cntl_error = 1

cntl_system_error = 2.

CALL METHOD container->free

EXCEPTIONS cntl_error = 1

cntl_system_error = 2

EXAMPLE

REPORT zalv_grid1.

TABLES: mara,marc.

DATA:obj_custom TYPE REF TO cl_gui_custom_container,

obj_alv TYPE REF TO cl_gui_alv_grid.

DATA: it_mara TYPE TABLE OF mara,

wa_mara TYPE mara,

wa_layout TYPE lvc_s_layo,

wa_variant TYPE disvariant,

x_save.

DATA:it_marc TYPE TABLE OF marc,

wa_marc TYPE marc.

SELECT-OPTIONS: s_matnr FOR mara-matnr DEFAULT 1 TO 500.

*

START-OF-SELECTION.

SELECT * FROM mara INTO TABLE it_mara

WHERE matnr IN s_matnr.

CALL SCREEN '100'.

----


  • CLASS cl_dbclick DEFINITION

----


*

----


CLASS cl_dbclick DEFINITION.

PUBLIC SECTION.

METHODS dbl FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column.

ENDCLASS.

DATA: obj1 TYPE REF TO cl_dbclick.

----


  • CLASS cl_dbclick IMPLEMENTATION

----


*

----


CLASS cl_dbclick IMPLEMENTATION.

METHOD dbl.

IF e_row-rowtype = space AND NOT e_row-index IS INITIAL.

READ TABLE it_mara INDEX e_row-index INTO wa_mara.

SELECT * FROM marc INTO TABLE it_marc

WHERE matnr = wa_mara-matnr.

CALL METHOD obj_custom->free

EXCEPTIONS

cntl_error = 1

cntl_system_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.

CALL SCREEN '200'.

ENDIF.

ENDMETHOD. "dbl

ENDCLASS. "cl_dbclick IMPLEMENTATION

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CALL METHOD obj_custom->free

EXCEPTIONS

cntl_error = 1

cntl_system_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.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module filldata OUTPUT

&----


  • text

----


MODULE filldata OUTPUT.

CREATE OBJECT obj_custom

EXPORTING

container_name = 'CONTROL'.

CREATE OBJECT obj_alv

EXPORTING

i_parent = obj_custom.

CREATE OBJECT obj1.

SET HANDLER obj1->dbl FOR obj_alv.

CALL METHOD obj_alv->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'MARA'

is_variant = wa_variant

i_save = x_save

  • i_default = 'X'

is_layout = wa_layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = it_mara

  • it_fieldcatalog =

  • it_sort =

  • it_filter =

  • EXCEPTIONS

  • invalid_parameter_combination = 1

  • program_error = 2

  • too_many_lines = 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.

ENDIF.

ENDMODULE. " filldata OUTPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'STATUS'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


MODULE status_0200 OUTPUT.

SET PF-STATUS 'STATUS'.

    • * SET TITLEBAR 'xxx'.

  • SUPPRESS DIALOG.

    • SET PARAMETER ID 'MAT' FIELD wa_mara-matnr.

*

  • LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.

*

*WRITE:/ wa_mara-matnr,

  • wa_mara-mbrsh,

  • wa_mara-meins.

CREATE OBJECT obj_custom

EXPORTING

container_name = 'CONTROL'.

CREATE OBJECT obj_alv

EXPORTING

i_parent = obj_custom.

CALL METHOD obj_alv->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'MARC'

  • is_variant = wa_variant

  • i_save = x_save

  • i_default = 'X'

  • is_layout = wa_layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = it_marc

  • it_fieldcatalog =

  • it_sort =

  • it_filter =

  • EXCEPTIONS

  • invalid_parameter_combination = 1

  • program_error = 2

  • too_many_lines = 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.

ENDIF.

ENDMODULE. " STATUS_0200 OUTPUT

&----


*& Module layout OUTPUT

&----


  • text

----


MODULE layout OUTPUT.

wa_layout-grid_title = 'MATERIAL DATA'.

wa_layout-zebra = 'X'.

  • wa_layout-edit = 'X'.

ENDMODULE. " layout OUTPUT

&----


*& Module variant OUTPUT

&----


  • text

----


MODULE variant OUTPUT.

wa_variant-report = 'ZALV_GRID1'.

x_save = 'A'.

ENDMODULE. " variant OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


MODULE user_command_0200 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

CALL METHOD obj_custom->free

EXCEPTIONS

cntl_error = 1

cntl_system_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.

LEAVE TO SCREEN '100'.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

thanks,

raji

Read only

Former Member
0 Likes
2,200

hi ,

In plain simple language when u dont need the container in ur screen on any particular event then FREE method is used .