‎2007 Jan 24 7:55 AM
HI Gurus,
I have defined a variable g_custom_container as below,
g_custom_container type ref to cl_gui_custom_container,
and I am cheking in the program for its initial value as
if g_custom_container is initial.
perform create_and_init_ct1_alv changing gt_outtab[]
gt_fieldcat.
endif.
Now,
when I am executing the program, its not going inside the if condition becouse the value of the g_custom_container is not initial ,
Please tell the way to set g_custom_container to its initial value.
‎2007 Jan 24 8:04 AM
1. first time it will be initial ,then if u run the program again it will not be initial.
2. to set to initial value u have to clear that
<b> clear g_custom_container.</b>
but i am not clear with ur requirement
‎2007 Jan 24 8:01 AM
hi Manik,
Check it debug mode wheter the field ( g_custom_container ) is getting populated with some value ...
Regards,
Santosh
‎2007 Jan 24 8:04 AM
1. first time it will be initial ,then if u run the program again it will not be initial.
2. to set to initial value u have to clear that
<b> clear g_custom_container.</b>
but i am not clear with ur requirement
‎2007 Jan 24 8:04 AM
Hi,
before creating object for g_custom_container it is <b>initial</b>:
here's my code:
IF g_custom_container IS INITIAL.
PERFORM prepare_grid.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
...
initial value is sth like this in debug mode "0<>"
A.
‎2007 Jan 24 8:05 AM
Hi,
Check this code,
DATA : o_alvgrid1 TYPE REF TO cl_gui_alv_grid ,
cont_for_cognos1 TYPE scrfname VALUE 'BCALC_GRID_01_9100',
custom_container1 TYPE REF TO cl_gui_custom_container.
MODULE status_9001 OUTPUT.
IF custom_container1 IS INITIAL.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE'.
* Creating Object
CREATE OBJECT custom_container1
EXPORTING
container_name = cont_for_cognos1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT o_alvgrid1
EXPORTING i_parent = custom_container1.
ENDIF.
ENDMODULE.
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
PERFORM exit_program.
SET SCREEN '0'.
WHEN 'EXIT' OR 'CANC'.
PERFORM exit_program.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. USER_COMMAND_9000 INPUT
FORM exit_program.
CALL METHOD custom_container1->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = lv_repid
txt2 = sy-subrc
txt1 = 'Error in FLush'(500).
ENDIF.
ENDFORM.Hope this helps.
‎2007 Jan 24 8:06 AM
‎2007 Jan 24 8:31 AM
My code for calling the module is
&----
*& Module ct1_PBO OUTPUT
&----
text
----
module ct1_PBO output.
*call method g_custom_container->free.
if g_custom_container is initial.
perform create_and_init_ct1_alv changing gt_outtab[]
gt_fieldcat.
endif.
endmodule. " ct1_PBO OUTPUT
and the definition of perform create_and_init_ct1_alv changing gt_outtab[]
gt_fieldcat.
is
FORM create_and_init_ct1_alv CHANGING pt_outtab LIKE gt_outtab[]
pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions.
g_container = 'ZEXC_REC_CT1'.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Create Objekt to verify input values.
(This object is already needed in form SELECT_DATA).
CREATE OBJECT g_verifier.
SET HANDLER g_verifier->handle_data_changed FOR g_grid.
PERFORM select_data CHANGING pt_outtab[].
Build fieldcat and set columns LFIMG VRKME
NETPR WAERS edit enabled.
PERFORM build_fieldcat CHANGING pt_fieldcat.
PERFORM exclude_tb_functions CHANGING lt_exclude.
gs_layout-stylefname = 'CELLTAB'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = gs_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab[].
Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. "CREATE_AND_INIT_ALV
when I am executing the program it is showing me the previous values because it is not going inside the if condition .
I also used the statement
call method g_custom_container->free.
but its giving runtime error.
Please suggest the solution.
Please suggest.
‎2007 Jan 24 9:33 AM
You are probably getting a run-time error because when you call the method to free the custom container the custom container hasn't been instantiated yet.
You should only call the free method when you are leaving the screen where the container is placed.
Kevin
‎2007 Jan 24 9:50 AM
Hi,
In the PAI of the screen,on user command 'EXIT' or 'BACK' when you are leaving the screen,use these methods
CALL METHOD g_custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
Leave program.
Hope this helps.
Regards,
Beejal
**Reward if helpful
‎2007 Jan 24 8:08 AM
After the processing clear your custom container using
call method g_custom_container->free
Regards,
Raghavendra