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

ALV Class

Former Member
0 Likes
660

Hello,

Is there any class that allows me to create an Editable ALV ?, I want to simulate a table maintenance, but instead of doing a table control, i´d like to do it with OO.

Any ideas and sample??

Thanks!!

Gabriel P.

5 REPLIES 5
Read only

Former Member
0 Likes
619

Please check class: <b>CL_GUI_ALV_GRID</b>.

Below are few programs which use the same class editable grids...

BCALV_EDIT_01

BCALV_EDIT_02

BCALV_EDIT_03

BCALV_EDIT_04

BCALV_EDIT_05

BCALV_EDIT_06

BCALV_EDIT_07

BCALV_EDIT_08

BCALV_GRID_EDIT

BCALV_GRID_EDIT_DELTA

BCALV_GRID_EDIT_DELTA_APPL

BCALV_GRID_EDIT_VERIFY_CLASSES

BCALV_GRID_EDIT_VERIFY_F01

BCALV_GRID_EDIT_VERIFY_M01

BCALV_GRID_EDIT_VERIFY_TOP

BCALV_TEST_GRID_EDIT

BCALV_TEST_GRID_EDITABLE

BCALV_TEST_GRID_EDIT_01

BCALV_TEST_GRID_EDIT_02

Where-used list on the class can give you more programs to refer.:)

Regards

Eswar

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
619

Hi,

You need to use class cl_alv_gui_grid.In this while calling the method set_table_for_first_display,you nee to pass parameters for fieldcatalog.In that make the particular field as edit = 'X'.

Check these links.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ec31e990-0201-0010-f4b6-c02d876c...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

Read only

Former Member
0 Likes
619

Hello,

Here is a sample code for editable ALV:

The class used is cl_gui_alv_grid.

Define a container in the screen and name it CONTAINER.Also set the pf status of the screen and assign function codes for SAVE,BACK and EXIT.

In the field catalog,by defining the field as editable,you can get an editable ALV.

Further,to save the changes made in the ALV,you need to handle the user command for SAVE button.

Report SAMPLE.

DATA: ALV type ref to cl_gui_alv_grid,

cont type ref to cl_gui_custom_container,

ok_code type sy-ucomm,

i_spfli type table of spfli,

l_valid type c.

DATA: I_fld type lvc_t_fcat,

wa_fld type lvc_s_fcat.

START-OF-SELECTION.

SELECT * FROM SPFLI INTO TABLE I_SPFLI.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'GUI'.

  • SET TITLEBAR 'xxx'.

if cont is initial.

CREATE OBJECT CONT

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

endif.

CREATE OBJECT ALV

EXPORTING

I_PARENT = cont.

wa_fld-fieldname = 'CARRID'.

wa_fld-ref_table = 'SPFLI'.

wa_fld-ref_field = 'CARRID'.

wa_fld-edit = 'X'.

append WA_FLD to I_FLD.

wa_fld-fieldname = 'CONNID'.

wa_fld-ref_table = 'SPFLI'.

wa_fld-ref_field = 'CONNID'.

wa_fld-edit = 'X'.

append WA_FLD to I_FLD.

wa_fld-fieldname = 'AIRPFROM'.

wa_fld-ref_table = 'SPFLI'.

wa_fld-ref_field = 'AIRPFROM'.

wa_fld-edit = 'X'.

append WA_FLD to I_FLD.

wa_fld-fieldname = 'AIRPTO'.

wa_fld-ref_table = 'SPFLI'.

wa_fld-ref_field = 'AIRPTO'.

wa_fld-edit = 'X'.

append WA_FLD to I_FLD.

CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY

  • EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

IT_OUTTAB = I_spfli

IT_FIELDCATALOG = I_FLD

  • IT_SORT =

  • IT_FILTER =

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

  • endif.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

case ok_code.

when 'BACK'.

CALL METHOD alv->FREE.

LEAVE to screen 0.

when 'EXIT'.

CALL METHOD alv->FREE.

LEAVE PROGRAM.

WHEN 'SAVE'.

call method alv->check_changed_data

importing e_valid = l_valid.

if l_valid = 'X'.

MODIFY SPFLI FROM TABLE I_SPFLI.

endif.

endcase.

ENDMODULE. " USER_COMMAND_0100 INPUT

Regards,

Beejal

**Reward if answer is found helpful

Read only

Former Member
0 Likes
619

Hi,

You have to do followiing things to make the ALV editable.

1) You have to modify the field Catalog fields to set the field EDIT as 'X'.

2) Call the method

CALL METHOD ALV_GRID_INSTANCE->set_ready_for_input

EXPORTING

i_ready_for_input = 0. ( For Display ) and '1' for Edit )

Put this after the set_table_for_first_display method.

3) If you want to check if the user has entered any value on the grid, use the Method : CALL METHOD ALV_GRID_INSTANCE->check_changed_data.

This will reflect as a change in your existiing data table to new data added on the editable grid.

Hope this helps..

Ketan

Read only

uwe_schieferstein
Active Contributor
0 Likes
619

Hello Gabriel

For details on ALV Grid programming (including editable grids) have a look at the excellent summary

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf,">An Easy Reference to ALV Grid Control</a>

Regards

Uwe