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: 

ALV grid not updating the correct value in the internal table

Former Member
0 Kudos

hi all,

I have searched this question in the SDN but I am not getting a clear answer. SO need helping hand from the expert.

I am using a ALV grid and in the toolbar there is a button " CHANGEREP" which display another ALV grid based on the date entered in the pop-up window.

in the first time when I clicked this button, the value displayed correctly then I change new date and click the button again, the old value is displayed in the ALV grid.

I checked in debugging mode , ts_output is getting updated but not displayed correctly in the ALV grid.

please find the piece of code



MODULE status_1002 OUTPUT.

  DATA : gr_event_handler2 TYPE REF TO lcl_event_handler .

  SET PF-STATUS 'Z_ALV2'.

* Create Container the first time Only

*  IF NOT g_custom_container2 IS INITIAL.
*    EXIT.
*  ENDIF.

* Create CONTAINER & GRID for ALV


    CREATE OBJECT g_custom_container2
      EXPORTING
        container_name = g_container2.

    CREATE OBJECT grid2
      EXPORTING
        i_parent = g_custom_container2.



    CALL METHOD grid2->set_table_for_first_display
      EXPORTING
        is_layout            = ga_layout
        it_toolbar_excluding = ty_exclude
      CHANGING
        it_outtab            = ts_output
        it_fieldcatalog      = gt_fieldcat[].

    CALL METHOD grid2->refresh_table_display.


ENDMODULE.                    "status_1002 OUTPUT


MODULE user_command_1002 INPUT.

  CASE sy-ucomm.

* For EXIT, CANCEL,BACK

    WHEN 'EXIT'   OR
         'BACK'   OR
         'CANCEL' OR
         '&F03'.

      CLEAR : gt_fieldcat[],
              ty_exclude[],
              ts_output[].

      FREE grid2.


      LEAVE TO SCREEN 0.

  ENDCASE.


ENDMODULE.                    "user_command_1002 INPUT


1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Free Container also.

I mean,

R_cont->free().


MODULE status_1002 OUTPUT.
 
  DATA : gr_event_handler2 TYPE REF TO lcl_event_handler .
 
  SET PF-STATUS 'Z_ALV2'.
 
* Create Container the first time Only
 
*  IF NOT g_custom_container2 IS INITIAL.
*    EXIT.
*  ENDIF.
 
* Create CONTAINER & GRID for ALV
 
 
    CREATE OBJECT g_custom_container2
      EXPORTING
        container_name = g_container2.
 
    CREATE OBJECT grid2
      EXPORTING
        i_parent = g_custom_container2.
 
 
 
    CALL METHOD grid2->set_table_for_first_display
      EXPORTING
        is_layout            = ga_layout
        it_toolbar_excluding = ty_exclude
      CHANGING
        it_outtab            = ts_output
        it_fieldcatalog      = gt_fieldcat[].
 
    CALL METHOD grid2->refresh_table_display.
 

ENDMODULE.                    "status_1002 OUTPUT
 
 
MODULE user_command_1002 INPUT.
 
  CASE sy-ucomm.
 
* For EXIT, CANCEL,BACK
 
    WHEN 'EXIT'   OR
         'BACK'   OR
         'CANCEL' OR
         '&F03'.
 
      CLEAR : gt_fieldcat[],
              ty_exclude[],
              ts_output[].
 
      FREE grid2.
 
 g_custom_container2->free( ). "add This statement
      LEAVE TO SCREEN 0.
 
  ENDCASE.
 
 
ENDMODULE.                    "user_command_1002 INPUT
 
 

Regrads,

Raghava Channooru.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Free Container also.

I mean,

R_cont->free().


MODULE status_1002 OUTPUT.
 
  DATA : gr_event_handler2 TYPE REF TO lcl_event_handler .
 
  SET PF-STATUS 'Z_ALV2'.
 
* Create Container the first time Only
 
*  IF NOT g_custom_container2 IS INITIAL.
*    EXIT.
*  ENDIF.
 
* Create CONTAINER & GRID for ALV
 
 
    CREATE OBJECT g_custom_container2
      EXPORTING
        container_name = g_container2.
 
    CREATE OBJECT grid2
      EXPORTING
        i_parent = g_custom_container2.
 
 
 
    CALL METHOD grid2->set_table_for_first_display
      EXPORTING
        is_layout            = ga_layout
        it_toolbar_excluding = ty_exclude
      CHANGING
        it_outtab            = ts_output
        it_fieldcatalog      = gt_fieldcat[].
 
    CALL METHOD grid2->refresh_table_display.
 

ENDMODULE.                    "status_1002 OUTPUT
 
 
MODULE user_command_1002 INPUT.
 
  CASE sy-ucomm.
 
* For EXIT, CANCEL,BACK
 
    WHEN 'EXIT'   OR
         'BACK'   OR
         'CANCEL' OR
         '&F03'.
 
      CLEAR : gt_fieldcat[],
              ty_exclude[],
              ts_output[].
 
      FREE grid2.
 
 g_custom_container2->free( ). "add This statement
      LEAVE TO SCREEN 0.
 
  ENDCASE.
 
 
ENDMODULE.                    "user_command_1002 INPUT
 
 

Regrads,

Raghava Channooru.

0 Kudos

Thanks Raghava , u have solved the problem.

Former Member
0 Kudos

Hi,

Can you tell me what code u have written for under CHANGEREP button.

Eg: MODULE user_command_screenno INPUT.

CASE sy-ucomm.

WHEN 'CHANGEREP'

Code.********

I think when u r clicking the same button it is not updating your corresponding table.

send me ur code for CHANGEREP button.

Regards,

Raj.

0 Kudos

I guess, you should call the ALV Method refresh_table_display.

your_alv_object->refresh_table_display

exporting

is_stable = ls_s_stbl

exceptions

finished = 1

others = 2.

This method refreshs the ALV after e.g. a data change in your internal table. You don't need to destroy your ALV after a data update.

Regards,

Martin