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

alv oo refresh data problem

Former Member
0 Likes
2,574

Hi experts:

I'm using 'CALL METHOD grid1->set_table_for_first_display to display' and edit data in alv oo .

When I changed the data, the changed can not be refresh in internal table, and I use method 'CALL METHOD grid1->REFRESH_TABLE_DISPLAY.' but It don't work.

So,anyone please help me,thanks.

Reword points if helpful.

Eric

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,956

Hi,

use this method in the PAI event

CALL METHOD g_alv->check_changed_data.

then your changes to the internal table will be reflected.

I hope it will help you.

If you have any questions revert me back.

Regards

Manjari.

8 REPLIES 8
Read only

Former Member
0 Likes
1,956

hii

loop at internal table

call -


endloop

refresh ur internal table here.

or go through this link

https://www.sdn.sap.com/irj/sdn/forums

thnks

Edited by: pardeep kumar on Aug 11, 2008 1:36 PM

Read only

Former Member
0 Likes
1,956

I guess you don't quite catch me.

Read only

Former Member
0 Likes
1,957

Hi,

use this method in the PAI event

CALL METHOD g_alv->check_changed_data.

then your changes to the internal table will be reflected.

I hope it will help you.

If you have any questions revert me back.

Regards

Manjari.

Read only

Former Member
0 Likes
1,956

i hope you are coding it like this in the PBO...

if grid1 is not bound.

create grid instance, set field catalog and call set_table_for_first_display.

else.

call method grid1->refresh_table_display().

endif.

if you are doing it as above, try calling CL_GUI_CFW=>FLUSH() method after grid1->refresh_table_display()

~Piyush Patil

Read only

Former Member
0 Likes
1,956

In the PAI module you call this at the very beginning.

call method grid->check_changed_data.

after this method call all the data will be updated to internal table.

apart from that You also registe the edit events.

Before calling the set display method

call method grid->register_edit_event
               exporting
                  i_event_id = cl_gui_alv_grid=>mc_evt_enter.

Read only

Former Member
0 Likes
1,956

Hi,

plz try with the help of below code :

Give class definition in TOPin module pool :

*----------------------------------------------------------------------*
* Class Definition .
*----------------------------------------------------------------------*
CLASS g_cl_alv_control DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
    handle_data_changed
    FOR EVENT data_changed OF cl_gui_alv_grid
    IMPORTING er_data_changed.

ENDCLASS.                    "lcl_alv_control DEFINITION

In Main program class implementation :

*----------------------------------------------------------------------*
*       CLASS g_cl_alv_control IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS g_cl_alv_control IMPLEMENTATION.

*method to handle the changed data in ALV.
  METHOD handle_data_changed.
*local data
    DATA: l_wa_good TYPE lvc_s_modi.

    LOOP AT er_data_changed->mt_good_cells INTO l_wa_good.

      CLEAR : g_wa_outtab, g_error.
      READ TABLE g_t_outtab INTO g_wa_outtab INDEX l_wa_good-row_id .
      CHECK sy-subrc EQ 0.
      IF g_wa_outtab-status = l_wa_good-value.
        CONTINUE.
      ENDIF.
*logic to set the status as per role.
* if the status is approved we cannot change the status to any thing else.
      IF g_wa_outtab-status = c_app.

        MESSAGE e021.
        g_error = 'X'.
        l_wa_good-value = c_app.

      ENDIF.
* if the role is representative, he can only change the status to 'submitted' only.
      IF g_flag_role = 'R'.
        IF l_wa_good-value NE c_sub.
          MESSAGE e015.
          g_error = 'X'.
          g_wa_outtab-status = l_wa_good-value.
        ENDIF.
* if the role is supervisor, he can only change the status to 'change needed' or 'approved' only if the request is submitted by representative.
      ELSEIF g_flag_role = 'S'.
        IF g_wa_outtab-status = c_sub.
          IF l_wa_good-value = c_chg_needed OR l_wa_good-value = c_app.

          ELSE.
            MESSAGE e016.
            g_error = 'X'.
            g_wa_outtab-status = l_wa_good-value.
          ENDIF.
        ELSEIF g_wa_outtab-status = c_chg_needed.
          MESSAGE e016.
        ELSE.
          MESSAGE e052.
          g_error = 'X'.
          g_wa_outtab-status = l_wa_good-value.
        ENDIF.
      ENDIF.
      IF g_error NE 'X'.
        g_wa_outtab-update = 'X'.
        MODIFY g_t_outtab FROM g_wa_outtab INDEX l_wa_good-row_id.
      ENDIF.
    ENDLOOP.
  ENDMETHOD.                    "handle_data_changed

ENDCLASS.                    "lcl_alv_control IMPLEMENTATION
*&---------------------------------------------------------------------*

Then in PAI :

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_9001 INPUT.

* check if the data is changed in ALV.

  CALL METHOD g_alv_grid_9001->check_changed_data.

ENDMODULE.                 " USER_COMMAND_9001  INPUT

In main program :

*&---------------------------------------------------------------------*
*&      Form  display_table_9003
*&---------------------------------------------------------------------*
* ALV display for user status.

FORM f0302_display_table_9001 .
 IF g_screen_active_9001 IS INITIAL.
    PERFORM f0201_set_drop_down.
    CALL METHOD g_alv_grid_9001->set_table_for_first_display
      EXPORTING
        i_bypassing_buffer            = 'X'
        is_layout                     = g_wa_layout
        it_toolbar_excluding          = g_t_toolbar_excl
      CHANGING
        it_outtab                     = g_t_outtab[]
        it_fieldcatalog               = g_t_fcat_9001
      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.

    IF g_flag_role = 'S' OR g_flag_role = 'R'.
      CALL METHOD g_alv_grid_9001->set_ready_for_input
        EXPORTING
          i_ready_for_input = '1'.
      SET HANDLER g_cl_alv_control=>handle_data_changed
      FOR g_alv_grid_9001.

      g_screen_active_9001 = 'X'.
    ELSE.
      CALL METHOD g_alv_grid_9001->refresh_table_display.

    ENDIF.
  ENDIF.



ENDFORM.                    " display_table_9003

hope this helps.

thanx,

dhanashri.

Read only

former_member787646
Contributor
0 Likes
1,956

Hi

Try the following code and check.

DATA ref_grid TYPE REF TO cl_gui_alv_grid.

IF ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

ENDIF.

IF ref_grid IS NOT INITIAL.

CALL METHOD ref_grid->check_changed_data.

ENDIF.

LOOP AT ITAB.

<your code goes here>

ENDLOOP.

Hope it helps.

Murthy

Read only

Former Member
0 Likes
1,956

CALL METHOD g_alv->check_changed_data solved my problem, thank you all.

eric