2010 May 05 11:33 AM
hy guys, got an issue with an alv 00 in a module pool.
When i call the screen 200 for the first time the alv is ok, but when i back to the select screen, change my selection and call again the screen 200, i still have the first ALV.
This my code:
FORM show_alv CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT grid
EXPORTING
i_parent = g_custom_container.
PERFORM toolbar CHANGING lt_exclude.
PERFORM build_fieldcat CHANGING pt_fieldcat.
gs_layout-stylefname = 'CELLTAB'.
IF NOT itb_zt1050[] IS INITIAL.
CALL METHOD grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = gs_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = itb_zt1050[].
CALL METHOD grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
*gestione toolbar e pai
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_user_command FOR grid.
SET HANDLER g_event_receiver->handle_toolbar FOR grid.
CALL METHOD grid->set_toolbar_interactive.
CREATE OBJECT g_verifier.
*gestione dei dati in input (specialmente LIFNR)
* SET HANDLER g_verifier->handle_data_changed FOR grid.
ELSE.
MESSAGE w208(00) WITH text-017 DISPLAY LIKE 'E'.
ENDIF.
ENDFORM.
and in the user command_200.
MODULE user_command_0200 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
CALL METHOD grid->free.
CALL METHOD g_custom_container->free.
CLEAR: grid, g_custom_container, g_container.
SET SCREEN 0.
CALL SCREEN '0100'.
WHEN 'SAVE'.
PERFORM save_data.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
* CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
ENDMODULE.
what didn't i clean or refresh correctly?
hy guys, got an issue with an alv 00 in a module pool.
When i call the screen 200 for the first time the alv is ok, but when i back to the select screen, change my selection and call again the screen 200, i still have the first ALV.
This my code:
FORM show_alv CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT grid
EXPORTING
i_parent = g_custom_container.
PERFORM toolbar CHANGING lt_exclude.
PERFORM build_fieldcat CHANGING pt_fieldcat.
gs_layout-stylefname = 'CELLTAB'.
IF NOT itb_zt1050[] IS INITIAL.
CALL METHOD grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = gs_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = itb_zt1050[].
CALL METHOD grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
*gestione toolbar e pai
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_user_command FOR grid.
SET HANDLER g_event_receiver->handle_toolbar FOR grid.
CALL METHOD grid->set_toolbar_interactive.
CREATE OBJECT g_verifier.
*gestione dei dati in input (specialmente LIFNR)
* SET HANDLER g_verifier->handle_data_changed FOR grid.
ELSE.
MESSAGE w208(00) WITH text-017 DISPLAY LIKE 'E'.
ENDIF.
ENDFORM.
and in the user command_200.
MODULE user_command_0200 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
CALL METHOD grid->free.
CALL METHOD g_custom_container->free.
CLEAR: grid, g_custom_container, g_container.
SET SCREEN 0.
CALL SCREEN '0100'.
WHEN 'SAVE'.
PERFORM save_data.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
* CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
ENDMODULE.
what didn't i clean or refresh correctly?
2010 May 05 11:46 AM
Hi,
MODULE user_command_0200 INPUT.
clear save_ok. "Write this statement
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
CALL METHOD grid->free.
CALL METHOD g_custom_container->free.
CLEAR: grid, g_custom_container, g_container.
Refresh:grid, g_custom_container, g_container. "Write this statement
SET SCREEN 0.
CALL SCREEN '0100'.
WHEN 'SAVE'.
PERFORM save_data.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
ENDMODULE.
Regards,
Raj.
2010 May 05 11:56 AM
2010 May 05 12:08 PM
I think the approach you should use is
IF container initial.
create container and alv
dispaly alv.
else.
refresh alv.
OR
If container is not initial.
free container, alv.
clear container, alv.
endif.
create container, alv.
dispaly alv.
Also one thing which catches my eye is
set screen 0.
call screen 100.
If 100 is your initial screen, don't nest the call screen. You will likely to get dump after several calls. Instead use either LEAVE TO SCREEN 0 (back on selection screen) then the initial 100 screen will be called automaticaly.
Or
SET SCREEN 0 and in screen 200 attributes set Next screen = 100.
Regards
Marcin
2010 May 05 12:04 PM
hi,
before creating object of container use this code i think it will help u out .
IF C_ALV IS NOT INITIAL.
CALL METHOD C_ALV->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
FREE C_ALV.
ENDIF.
ENDIF.
IF g_custom_container IS NOT INITIAL.
CALL METHOD g_custom_container->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
2010 May 05 12:06 PM
Hi,
Your coding as per my knowledge is correct .
Do one thing , Try with Leave to screen 100. instead of Call screen 100 and remove set screen 0.
Regards,
Raghava Channooru
2010 May 05 2:22 PM
i try almost all of yours contributions but didn't solve the issue.
i solved partially using
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
CALL METHOD grid->free.
CALL METHOD g_custom_container->free.
SET SCREEN 0.
LEAVE SCREEN. " '0100'.
WHEN 'SAVE'.
PERFORM save_data.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.'
If i don't do any change to the alv (like add a row or delete a row), it's works perfectly, i back to the selection screen normaly and can make another selection.
But as i make a change in the alv and save that change, anytime i call the screen 200 i'll have the same alv...
now i'm trying to manage the save option.
2010 May 05 2:47 PM
But as i make a change in the alv and save that change, anytime i call the screen 200 i'll have the same alv...
This is not beacuse of ALV but the table which is displayed by means of it.
Whenever you do a change in ALV and catch that change, it reflects in the iternal table (you have that changes output right away as changes sit in the table). So when you go back to selection screen I believe you don't refresh your table. Then when you display ALV once again it just shows the old content of the table.
In order to have new data, ensure you are populating from scratch this table every time the alv preparations starts, before it really gets displayed.
Regards
Marcin
2010 May 05 4:03 PM
the internal table is refreshed before the select. in debug i checked it's was refresh and it is. there's another value that must not cleaned correctly.
2010 May 05 4:21 PM
may be might help.
when i edit the alv , save and back to selection screen. my container and grid are initial. my internal table is refresh.
when i make a new selection and call the screen 200, when i arrive, the container is created, the grid is created, the internal got the new data (saw it in debug),
but when i call method grid->first_display...the alv contains the previous data...
i'm going crazy on it...
2010 May 27 2:47 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |