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: 

How to create an editable ALV?

Former Member
20,514

How to create an editable ALV?

8 REPLIES 8

amit_khare
Active Contributor
0 Kudos
1,772

Check the thread -

Regards,

Amit

Reward all helpful replies.

Former Member
0 Kudos
1,772

USE FIELDCATLOG

ls_fcat-edit = 'X'.

0 Kudos
1,772

Hi Sheshu / Kallouri,

I am in need of an editble ALV , I saw in the reply message of Sheshu marmaddy , he mentions of the program BCALV_EDIT_04 , could I know where to look into it, I am need of an ALV , which saves data to an internal table and then finally to an database table table.

Please reply ASAP, thanks.

0 Kudos
1,772

hi

GOTO----


>SE80

select package option

enter package name as SLIS

in this package u can find all ALV programs

Regards

Nagesh.Paruchuri

Former Member
1,772

Hi,

Check these programs,

BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.

BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.

BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.

The report checks the input value(s) semantically and provides protocol messages in case of error

BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to

implement the saving of the new data.

BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:

(1) how to define a column for editable checkboxes for an attribute of your list

(2) how to evaluate the checked checkboxes

(3) how to switch between editable and non-editable checkboxes

BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV

Grid Control.

BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.

BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects

are dealt with:

(1) how to replace the standard f4 help

(2) how to pass the selected value to the ALV Grid Control

(3) how to build an f4 help, whose value range depend on a value of another cell.

Regards,

Azaz Ali.

Former Member
0 Kudos
1,772

Suppose wa_f is the work area u are using for ur field catalog

and itab_f is the internal table.

do this for the fields which u want to make editable

wa_f-edit = 'X'.

APPEND ITAB_F FROM WA_F.

Former Member
0 Kudos
1,772

The follow program demonstrates how to make individual fields of an ALV grid editable (NetPR greater than 10).

Changes required from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this

field with style attribute and adding an entry to layout control table. Also from the previous examples used on

this website you will also need to change the data type of the fieldcatalog, the layout and use a different function

module for displaying the report.

&----


*& Report ZDEMO_ALVGRID_EDIT *

*& *

&----


*& *

*& Example of a simple ALV Grid Report *

*& ................................... *

*& *

*& The basic ALV grid, Enhanced to display specific fields as *

*& editable depending on field value *

&----


REPORT ZDEMO_ALVGRID_EDIT .

TABLES: ekko.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

field_style TYPE lvc_t_styl, "FOR DISABLE

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,

wa_fieldcat TYPE lvc_s_fcat,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE lvc_s_layo, "slis_layout_alv,

gd_repid LIKE sy-repid.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM set_specific_field_attributes.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-scrtext_m = 'Purchase Order'.

wa_fieldcat-col_pos = 0.

wa_fieldcat-outputlen = 10.

wa_fieldcat-emphasize = 'X'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-scrtext_m = 'PO Item'.

wa_fieldcat-col_pos = 1.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STATU'.

wa_fieldcat-scrtext_m = 'Status'.

wa_fieldcat-col_pos = 2.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-scrtext_m = 'Item change date'.

wa_fieldcat-col_pos = 3.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-scrtext_m = 'Material Number'.

wa_fieldcat-col_pos = 4.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-scrtext_m = 'PO quantity'.

wa_fieldcat-col_pos = 5.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-scrtext_m = 'Order Unit'.

wa_fieldcat-col_pos = 6.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-scrtext_m = 'Net Price'.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 15.

wa_fieldcat-datatype = 'CURR'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PEINH'.

wa_fieldcat-scrtext_m = 'Price Unit'.

wa_fieldcat-col_pos = 8.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

  • Set layout field for field attributes(i.e. input/output)

gd_layout-stylefname = 'FIELD_STYLE'.

gd_layout-zebra = 'X'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


FORM display_alv_report.

gd_repid = sy-repid.

  • call function 'REUSE_ALV_GRID_DISPLAY'

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_callback_program = gd_repid

  • i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = gd_layout

it_fieldcat_lvc = it_fieldcat

i_save = 'X'

TABLES

t_outtab = it_ekko

EXCEPTIONS

program_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.

ENDFORM. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh

UP TO 10 ROWS

FROM ekpo

INTO CORRESPONDING FIELDS OF TABLE it_ekko.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form set_specific_field_attributes

&----


  • populate FIELD_STYLE table with specific field attributes

----


form set_specific_field_attributes .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

  • Populate style variable (FIELD_STYLE) with style properties

*

  • The NETPR field/column has been set to editable in the fieldcatalog...

  • The following code sets it to be disabled(display only) if 'NETPR'

  • is gt than 10.

LOOP AT it_ekko INTO wa_ekko.

IF wa_ekko-netpr GT 10.

ls_stylerow-fieldname = 'NETPR' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

"set field to disabled

APPEND ls_stylerow TO wa_ekko-field_style.

MODIFY it_ekko FROM wa_ekko.

ENDIF.

ENDLOOP.

endform. " set_specific_field_attributes

Former Member
0 Kudos
1,772

Hi,

To get a clear idea follow given standard pgms.

BCALV_EDIT_01 TO BCALV_EDIT_04.

Regards,

Naveen M.