‎2009 Dec 23 6:33 AM
Hi,
I am displaying a alv grid list in the output screen where some fields are editable using g_grid->set_table_for_first_display(oops).
I have even kept a push button in the application tool bar to save the changed fields.
All I have to do is take the data of changed & unchanged fields from the GRID and update some custom tables.
The problem I am facing is I am not able to capture the changed data in the output internal table.
Help me!
regards
Mac
‎2009 Dec 23 6:57 AM
Hi
I have a solution for your problem.
Call funciton Register_edit_event before calling function Refresh_table_display.Sample code is given below:
*--event to detect if data gets edited
CALL METHOD OBJ_ALV->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
And also capture ENTER button user command i.e. 'OK'.Sample code is given below:
*--when alv is edited and ENTER button is clicked then data ill be saved in internal table and edited data will be displayed on alv
IF OK_CODE = 'OK'.
*--metohd to detect if data was changed in oops alv
CALL METHOD OBJ_ALV->CHECK_CHANGED_DATA
IMPORTING
E_VALID =
CHANGING
C_REFRESH = 'X'
.
ENDIF.
Whenever you will edit fields of alv and press ENTER key then edited data will be displayed in alv and it will be modified in internal table too.
Hope this will resolve your problem.
Thanks & Regards,
Khushboo
‎2009 Dec 23 6:47 AM
write to update ur custom table in the HANDLE USER COMMAND.
METHOD handle_user_command.
CASE e_ucomm.
WHEN save.
update table wth the values entered
ENDCASE.
ENDMETHOD.
‎2009 Dec 23 6:57 AM
Hi
I have a solution for your problem.
Call funciton Register_edit_event before calling function Refresh_table_display.Sample code is given below:
*--event to detect if data gets edited
CALL METHOD OBJ_ALV->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
And also capture ENTER button user command i.e. 'OK'.Sample code is given below:
*--when alv is edited and ENTER button is clicked then data ill be saved in internal table and edited data will be displayed on alv
IF OK_CODE = 'OK'.
*--metohd to detect if data was changed in oops alv
CALL METHOD OBJ_ALV->CHECK_CHANGED_DATA
IMPORTING
E_VALID =
CHANGING
C_REFRESH = 'X'
.
ENDIF.
Whenever you will edit fields of alv and press ENTER key then edited data will be displayed in alv and it will be modified in internal table too.
Hope this will resolve your problem.
Thanks & Regards,
Khushboo
‎2009 Dec 23 7:24 AM
‎2009 Dec 23 7:39 AM
Hi
This is a part of a code which just shows to display and use a method to modify internal table after edited.
CALL METHOD MY_ALV2->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_LAY
CHANGING
IT_OUTTAB = IT_DISP2
IT_FIELDCATALOG = IT_FIELDCAT2
IT_SORT = IT_SORT
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.
CALL METHOD MY_ALV2->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Also in field catalogue, you have to use ref_field and ref_table fields
for ex.
WA_FIELDCAT2-REF_FIELD = 'NETPR'.
WA_FIELDCAT2-REF_TABLE = 'EKPO'.
I hope it works