‎2007 May 23 8:59 AM
Hello,
I create a function module with import parameter matnr.
This function module calls a screen that displays an ALV with the whole info of matnr out of table mara.
I include this in a program where a material can be selected. This is then input for the function module. Everything looks good for the first material. However when the function module is called for a second material I still see the ALV with the data of the previous material.
When I debug the code I see that new data is selected and put on the alv (with method set_table_for_first_display) but still I see the old ALV (which I free by the way in the exit of my function module...). It drives me crazy, what's the problem?
<b>My function module:
</b>
FUNCTION ZJVB_TEST.
*"----------------------------------------------------------------------
*"*"Lokale interface:
*" IMPORTING
*" REFERENCE(I_MATNR) TYPE MATNR
*"----------------------------------------------------------------------
g_matnr = i_matnr.
call SCREEN 1979.
ENDFUNCTION.
<b>TOP include:</b>
FUNCTION-POOL ZJVB_TEST. "MESSAGE-ID ..
data: ok_code type sy-ucomm,
container type ref to cl_gui_custom_container,
alv type ref to cl_gui_alv_grid,
g_matnr type matnr.
*&---------------------------------------------------------------------*
*& Module STATUS_1979 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_1979 OUTPUT.
SET PF-STATUS 'FMAIN'.
* SET TITLEBAR 'xxx'.
if container is INITIAL.
CREATE OBJECT CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER' .
CREATE OBJECT ALV
EXPORTING
I_PARENT = container.
data: itab type TABLE OF mara.
select *
from mara
into TABLE itab
where matnr = g_matnr.
CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'MARA'
CHANGING
IT_OUTTAB = itab.
endif.
ENDMODULE. " STATUS_1979 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1979 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1979 INPUT.
case ok_code.
when 'BACK'.
free container.
free alv.
LEAVE to SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_1979 INPUT
<b>My program:</b>
*&---------------------------------------------------------------------*
*& Report ZJEROEN_ALV_FM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZJEROEN_ALV_FM.
data: ok_code type sy-ucomm,
l_matnr type matnr.
call SCREEN 1979.
*&---------------------------------------------------------------------*
*& Module STATUS_1979 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_1979 OUTPUT.
SET PF-STATUS 'MAIN'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_1979 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1979 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1979 INPUT.
case ok_code.
when 'BACK'.
leave to screen 0.
when 'CALL'.
CALL FUNCTION 'ZJVB_TEST'
EXPORTING
i_matnr = l_matnr.
endcase.
ENDMODULE. " USER_COMMAND_1979 INPUT
Thx for helping,
jeroen
‎2007 May 23 10:13 AM
Hi Jeroen,
Try using following methods, you put them at the end of MODULE STATUS_1979 OUTPUT
call method alv_grid->refresh_table_display.
call method cl_gui_cfw=>flush.
Best regards,
Dirk.
‎2007 May 23 10:13 AM
Hi Jeroen,
Try using following methods, you put them at the end of MODULE STATUS_1979 OUTPUT
call method alv_grid->refresh_table_display.
call method cl_gui_cfw=>flush.
Best regards,
Dirk.
‎2007 May 23 10:16 AM
Hi
<b>Refresh</b> your internal table <b>itab</b> before populating it with data from MARA table.
Regards,
Raj
‎2007 Nov 27 9:04 PM
Hello,
I found out that the container lifetime was the problem... When you create a container to put the ALV in the lifetime is set to default. Normally you never change this, I didn't mention it before I had the problem. But you have to change the lifetime to <your_instance_name>->lifetime_dynpro for instance my_container->lifetime_dynpro.
Also check this helplink: http://help.sap.com/saphelp_nw04/helpdata/en/9b/d080b79fc111d2bd68080009b4534c/frameset.htm
‎2015 Mar 25 6:27 PM
I had the same problem and solved it with this. Thank you.
CREATE OBJECT g_container2 EXPORTING
container_name = container2
lifetime = cl_gui_container=>lifetime_dynpro.
‎2015 Mar 26 1:45 AM
I think when you call the function second time, the program would not go into "if container is INITIAL." condition in the PBO of screen 1979.
You can try to set a breakpoint to check this.
I think you can put the select statement before "call screen".