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

Capture changed data in editable alv grid.

Former Member
0 Likes
7,212

Hi Gurus,

Am very munch new to ABAP.

I got a requirement where i have to display ztable data in full screen editable alv grid. where 1 field is editable.when the user change the value or delete the line and then click on save, the changed data have to be captured in ztable as a new entry without changing any data from the ztable.

Can u help me with the sample code or procedure.

am using bapi_reuse_alv_grid.

Thanks & regards.

1 ACCEPTED SOLUTION
Read only

mithun_shetty4
Contributor
0 Likes
3,100

For editable filed in ALV

while creating field catelog,Just pass fieldcat-edit = 'X' this will set column in editable mode.

for User command on save and delete.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'  "<--use this


FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

CASE r_ucomm.
WHEN '&IC1'.
READ TABLE iT_tab INTO wa_tab INDEX rs_selfield-tabindex.

WHEN 'SAVE'.

"-->code
WHEN 'DELE'.'
"-->code
ENDCASE.
ENDFORM. "user_command

6 REPLIES 6
Read only

mithun_shetty4
Contributor
0 Likes
3,101

For editable filed in ALV

while creating field catelog,Just pass fieldcat-edit = 'X' this will set column in editable mode.

for User command on save and delete.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'  "<--use this


FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

CASE r_ucomm.
WHEN '&IC1'.
READ TABLE iT_tab INTO wa_tab INDEX rs_selfield-tabindex.

WHEN 'SAVE'.

"-->code
WHEN 'DELE'.'
"-->code
ENDCASE.
ENDFORM. "user_command

Read only

Former Member
3,100

Hi,

Refer the below mentioned code.

DATA : ref_grid TYPE REF TO cl_gui_alv_grid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program       = g_repid
        i_callback_pf_status_set = alv_status_set
        i_callback_user_command  = alv_user_comm
        i_grid_title             = grid_title
        i_save                   = g_save
        is_variant               = gs_variant
        is_layout                = alv_layout
        it_fieldcat              = alv_fieldcat[]
        it_events                = gt_events[]
        it_sort                  = alv_sort[]
      IMPORTING
        e_exit_caused_by_caller  = g_exit_caused_by_caller
        es_exit_caused_by_user   = gs_exit_caused_by_user
      TABLES
        t_outtab                 = git_final[].

    PERFORM alv_user_comm USING r_ucomm
                                rs_selfield.

FORM alv_user_comm  USING    r_ucomm     LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.

*Determine the main component beign viewed
  READ TABLE git_final INTO gwa_final INDEX rs_selfield-tabindex.

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'   "This FM will get the reference of the changed data in ref_grid 
    IMPORTING
      e_grid = ref_grid.

  IF ref_grid IS NOT INITIAL.
    CALL METHOD ref_grid->check_changed_data( ).  "After calling this method your internal table will have updated values

    git_final_tmp = git_final.
endform.
modify Z* from git_final 

" Modify your ztable with the last stmnt.

It will definitely solve your issue. Come up with your queries if any..

Cheers

VJ

Read only

Former Member
0 Likes
3,100

Hi Gurus,

Everything is working fine..when i change the quantity field and save

its showing : too many decimal places (maximum 0)

MENGE type MENGE_D. "Quantity

Thanks & regards.

Read only

0 Likes
3,100

Hi ,

The Menge_d type quan13 with 3 decimal places , so its expecting decimal places , please enter value with 3 three decimals or change it into INT , then u didnt get any problem .

Regards

Siva

Read only

0 Likes
3,100

Hi,

In field catalog pass qfieldname filed and qtabname also ref_fieldname ref_tabname for MENGE.

Regards,

Ravi.

Read only

Former Member
0 Likes
3,100

Vishal Jindal solved my problem

Thanks & regards.