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: 

regarding alv report edit

Former Member
0 Kudos
90

hi

could u plz tell me how to edit the values of the alv grid display

could u plz explain clearly with code

1 ACCEPTED SOLUTION

Former Member
0 Kudos
70

Set the EDIT parameter in the field catalog of the field you want to edit to 'X'. This field will then be editable. To capture the values of the edited field, use the method check_changed_data of the class cl_gui_alv_grid.

Refer to package SLIS for examples.

Please mark points if the solution was useful.

Regards,

Manoj

5 REPLIES 5

Former Member
0 Kudos
71

Set the EDIT parameter in the field catalog of the field you want to edit to 'X'. This field will then be editable. To capture the values of the edited field, use the method check_changed_data of the class cl_gui_alv_grid.

Refer to package SLIS for examples.

Please mark points if the solution was useful.

Regards,

Manoj

Former Member
0 Kudos
70

Hi,

Check this Program .

data: ok_code like sy-ucomm,

save_ok like sy-ucomm,

g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',

g_grid type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container,

gs_layout type lvc_s_layo,

g_max type i value 100.

data: gt_outtab type table of sflight.

*----


*

  • MAIN *

*----


*

call screen 100 starting at 1 1..

*----


*

  • MODULE PBO OUTPUT *

*----


*

module pbo output.

set pf-status 'MAIN100'.

set titlebar 'MAIN100'.

if g_custom_container is initial.

create object g_custom_container

exporting container_name = g_container.

create object g_grid

exporting i_parent = g_custom_container.

*§1.Set status of all cells to editable using the layout structure.

gs_layout-edit = 'X'.

select * from sflight into table gt_outtab up to g_max rows.

call method g_grid->set_table_for_first_display

exporting i_structure_name = 'SFLIGHT'

is_layout = gs_layout

changing it_outtab = gt_outtab.

*§2.Use SET_READY_FOR_INPUT to allow editing initially.

  • (state "editable and ready for input").

call method g_grid->set_ready_for_input

exporting i_ready_for_input = 1.

endif.

endmodule.

*----


*

  • MODULE PAI INPUT *

*----


*

module pai input.

save_ok = ok_code.

clear ok_code.

case save_ok.

when 'EXIT'.

perform exit_program.

when 'SWITCH'.

perform switch_edit_mode.

when others.

  • do nothing

endcase.

endmodule.

*----


*

  • FORM EXIT_PROGRAM *

*----


*

form exit_program.

leave program.

endform.

*&----


*

*& Form SWITCH_EDIT_MODE

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form switch_edit_mode.

*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.

if g_grid->is_ready_for_input( ) eq 0.

*§4.Use SET_READY_FOR_INPUT to switch between the substates.

call method g_grid->set_ready_for_input

exporting i_ready_for_input = 1.

else.

call method g_grid->set_ready_for_input

exporting i_ready_for_input = 0.

endif.

endform. " SWITCH_EDIT_MODE

For more information check the standard programs :BCALV_EDIT_*

reward if it helps..

Regards,

Omkar.

Former Member
0 Kudos
70

hi

<b> check the following code to edit the values in alv grid. hope it will definitely gelp u lot.</b>



*&---------------------------------------------------------------------*
*& Report  ZTESTDEMO_INTERACTIVE_LIST_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZTESTDEMO_INTERACTIVE_LIST_2.

TABLES: MARA,MARC,MARD.


* internal table itab_mara 3 fields matnr, ernam,mtart
DATA: BEGIN OF ITAB_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,  " material number
ERNAM LIKE MARA-ERNAM,  " name of person who create
MTART LIKE MARA-MTART,  " Material Type
END OF ITAB_MARA.

* internal table itab_marc 3 fields matnr, werks,lvorm

DATA: BEGIN OF ITAB_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,  " Plant
LVORM LIKE MARC-LVORM,  " Flag Material for Deletion at Plant Level
END OF ITAB_MARC.

* internal table itab_mard 2 fields

DATA: BEGIN OF ITAB_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,  " Storage Location
END OF ITAB_MARD.

SELECT-OPTIONS: S_MTART FOR MARA-MTART.

INITIALIZATION.

S_MTART-LOW = 'HALB'.
S_MTART-HIGH = 'HAWA'.
S_MTART-OPTION = 'BT'.
APPEND S_MTART.

START-OF-SELECTION.

SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
S_MTART.

PERFORM DISPLAY.


TOP-OF-PAGE.
WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.


FORM DISPLAY.

LOOP AT ITAB_MARA.
WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
HIDE: ITAB_MARA-MATNR.
ENDLOOP.

ENDFORM.

AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.

SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
ITAB_MARA-MATNR.
PERFORM DISPLAY1.

WHEN 2.

SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
ITAB_MARC-MATNR.
PERFORM DISPLAY2.

when 3.
sy-lsind = 0.
ENDCASE.

FORM DISPLAY1.
LOOP AT ITAB_MARC.
WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
HIDE: ITAB_MARC-MATNR.
ENDLOOP.

WRITE:/ SY-LSIND.
ENDFORM.

FORM DISPLAY2.
LOOP AT ITAB_MARD.
WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
ENDLOOP.
WRITE:/ SY-LSIND.

ENDFORM.


regards

ravish

<b>plz dont forget to reward if useful</b>

Former Member
0 Kudos
70

Hi,

When you create your ALV fieldcatalog add the 'EDIT' option ,with that particular fiedls which want to make editable.

wa_fieldcat-tabname     = 'ITAB'.
  wa_fieldcat-fieldname   = 'PARNR1'.
  wa_fieldcat-col_pos     = 12.
  wa_fieldcat-outputlen   = 12.
  wa_fieldcat-edit   = 'X'
  wa_fieldcat-seltext_l   = 'Person Resp.'.
  wa_fieldcat-seltext_m   = 'Person Resp.'.
  wa_fieldcat-seltext_s   = 'Person Resp.'.

  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

<i><b>Regards

Debjani

rewards point for helpful answer</b></i>

Former Member
0 Kudos
70

hi rajesh

please use <fieldcatalog name>-edit = 'X' this shows entire colomn in edit mode so that u can edit the particular field....

thanks,

maheedhar.t