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: 

Editing a ALV Grid

Former Member
0 Kudos

Hi all,

I have an ALV listing some records and I have a button in the application toolbar to enable the edit mode. When i click on the 'Edit' button, I should be able to edit the existing records only (which involves modifying the values and deleting a row) and I should not be allowed to insert new records ( the plus + button to be disabled? ). Is there a way to do that? Can you please help me out in this?

Thanks in advance.

Regards,

Venkat.

1 ACCEPTED SOLUTION

peter_ruiz2
Active Contributor
0 Kudos

hi,

define the Append button in the IT_EXCLUDING for the ALV GRID.

here is an example.

using Objects:

data: lwa_xclde TYPE ui_func.

data: git_xclde type ui_functions.

lwa_xclde = cl_gui_alv_grid=>mc_fc_loc_append_row.

APPEND lwa_xclde TO git_xclde.

CLEAR lwa_xclde.

CALL METHOD go_alvgd->set_table_for_first_display

EXPORTING

is_layout = gwa_lyout

it_toolbar_excluding = git_xclde

CHANGING

it_outtab = git_otput

it_fieldcatalog = git_fldct

it_sort = git_sortx.

regards,

Peter

Edited by: Peter Ruiz on Jul 16, 2008 6:30 PM

9 REPLIES 9

Former Member
0 Kudos

hi,

Check out this link.

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_editable.htm

this may help.

Regards

Sumit AGarwal

Former Member
0 Kudos

Copy the GUi status of the program SAPLSALV

Go to menu painter se41

Give a fcode to the edit button activate it.

write the logic in the PAI.

Hope it helps

peter_ruiz2
Active Contributor
0 Kudos

hi,

define the Append button in the IT_EXCLUDING for the ALV GRID.

here is an example.

using Objects:

data: lwa_xclde TYPE ui_func.

data: git_xclde type ui_functions.

lwa_xclde = cl_gui_alv_grid=>mc_fc_loc_append_row.

APPEND lwa_xclde TO git_xclde.

CLEAR lwa_xclde.

CALL METHOD go_alvgd->set_table_for_first_display

EXPORTING

is_layout = gwa_lyout

it_toolbar_excluding = git_xclde

CHANGING

it_outtab = git_otput

it_fieldcatalog = git_fldct

it_sort = git_sortx.

regards,

Peter

Edited by: Peter Ruiz on Jul 16, 2008 6:30 PM

0 Kudos

Hi all,

Thanks a lot for your replies; however, these do not seem to work. I will explain the problem a bit more.

I display an internal table with two fields - one of them being a field with drop-down box - in the output ALV Grid using the set_table_for_first_display method.

When I click on the 'Edit' button in the application toolbar, I should be allowed to choose a different value from the dropdown box and I should not be able to insert a new record. What happens currently is that, when I click on the 'Edit' button, the + button in the ALV toolbar is enabled and on pressing this, I get a new row created. However, I should not be able to insert any rows in that table (maybe disabling the + button in the ALV toolbar would help). I should be able to only change the value of one of the fields displayed or delete an existing row.

Is there a way to achieve this?

Thanks in advance.

Regards,

Venkat.

0 Kudos

hi,

give me your email address. i can send you a sample program that will provide the solution for your requirement.

regards,

Peter

0 Kudos

Hi Peter,

Please send it to the mail id as mentioned in my profile.

Thanks a lot!

Regards,

Venkat.

0 Kudos

Alternative way:-->

Before calling the screen with container

describe table i_output lines v_rows_prev.

then in PAI while saving



  call method g_grid->check_changed_data
    importing
      e_valid = v_valid.
  if v_valid eq 'X'.
  describe table i_output lines v_rows_current.      
  if v_rows_prev ne v_rows_current.
     message e999 with 'New rows cannot be inserted'.
  endif.
  endif.

a®s

Edited by: a®s on Jul 16, 2008 7:40 AM

0 Kudos

hi Venkat,

please check your email. i have sent it already.

regards,

Peter

Former Member
0 Kudos

1st copy ur std. pf status to a zpf-status then a pass routine name for PFstatus to the ALV FM.

  • Display report

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_structure_name = p_table

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_PF_STATUS'

TABLES

t_outtab = <dyn_table>

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

append the fcode for + button in internal table rt_extab

&----


*& Form SET_PF_STATUS

&----


  • Setting custom PF-Status

----


  • -->RT_EXTAB Excluding table

----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

data: w_extab type slis_extab.

w_extab-fcode = < Fcode for + button>.

append w_extab to rt_extab.

SET PF-STATUS 'Z_STANDARD' excluding rt_extab.

ENDFORM. "SET_PF_STATUS

Regards,

Joy.