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

save the data in the grid using oops

Former Member
0 Likes
597

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
558

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

4 REPLIES 4
Read only

Former Member
0 Likes
558

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.

Read only

Former Member
0 Likes
559

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

Read only

0 Likes
558

Hi,

Can u pls send me the entire sample code pls.

Regards

Mac

Read only

Former Member
0 Likes
558

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