2008 Feb 07 3:04 PM
Hi everybody
The new cl_salv_table class is fine for a lot of things but it definitely needs EDIT type of functionality -- doesn't need a huge amount but the user should be able to edit individual cell(s) and insert / delete lines as with the current cl_gui_alv_grid.
To show SAP that this function is needed just postunder this a single line Agree.
If enough replies come back I'm sure SAP will consider this in future.
I'd love to do a Poll but this Forum doesn't seem to have that facility available.
Cheers
jimbo
2011 Aug 29 10:10 AM
2011 Sep 13 8:27 AM
2011 Oct 12 2:50 PM
2011 Nov 01 11:01 AM
Hi all
Thanks for the support
I copied THIS from one of the Blogs -- it's an UNOFFICIAL and probably not a recommended way but it will provide some limited edit functionality -- however full edit stuff like ON DATA CHANGE etc isn't readily implementable even using this get around
(Thanks to the original blogger --can't remember who it was however).
PROGRAM z_salv_test_selection.
Simple ALV display using cl_SALV factory class but with added EDIT functionality
FIELD-SYMBOLS:
<f_tabl> TYPE STANDARD TABLE.
PARAMETERS:
p_tname TYPE tabname16 OBLIGATORY,
p_rows(5) TYPE c DEFAULT '300'.
*
----
Define the Local class inheriting from the CL_SALV_MODEL_LIST
to get an access of the model, controller and adapter which inturn
provides the Grid Object
----
CLASS lcl_salv_model DEFINITION INHERITING FROM cl_salv_model_list.
PUBLIC SECTION.
DATA: o_control TYPE REF TO cl_salv_controller_model,
o_adapter TYPE REF TO cl_salv_adapter.
METHODS:
grabe_model
IMPORTING
io_model TYPE REF TO cl_salv_model,
grabe_controller,
grabe_adapter.
PRIVATE SECTION.
DATA: lo_model TYPE REF TO cl_salv_model.
ENDCLASS. "LCL_SALV_MODEL DEFINITION
----
Event handler for the added buttons
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function.
ENDCLASS. "lcl_event_handler DEFINITION
----
Local Report class - Definition
----
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
TYPES: ty_zps_ccmap TYPE STANDARD TABLE OF zps_ccmap.
DATA: t_data TYPE ty_zps_ccmap.
DATA: o_salv TYPE REF TO cl_salv_table.
DATA: o_salv_model TYPE REF TO lcl_salv_model.
METHODS:
get_data
EXCEPTIONS no_data_found,
check_selection "Dynamic table definition
EXCEPTIONS invalid_table,
generate_output.
PRIVATE SECTION.
TYPE-POOLS: abap.
DATA: tab TYPE REF TO cl_abap_structdescr,
wa_tab TYPE REF TO cl_abap_structdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
i_tab TYPE REF TO cl_abap_tabledescr,
i_table TYPE REF TO data.
ENDCLASS. "lcl_report DEFINITION
----
Global data
----
DATA: lo_report TYPE REF TO lcl_report.
AT SELECTION-SCREEN.
CREATE OBJECT lo_report.
CALL METHOD lo_report->check_selection
EXCEPTIONS
invalid_table = 1.
IF sy-subrc <> 0.
MESSAGE e001(00) WITH
p_tname ' is not a Transparant Table'.
ENDIF.
START-OF-SELECTION.
----
Start of selection
----
START-OF-SELECTION.
IF lo_report IS INITIAL.
CREATE OBJECT lo_report.
ENDIF.
CALL METHOD lo_report->get_data
EXCEPTIONS
no_data_found = 1.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'No data found'.
lo_report->get_data( ).
ELSE.
lo_report->generate_output( ).
ENDIF.
----
Local Report class - Implementation
----
CLASS lcl_report IMPLEMENTATION.
METHOD check_selection.
SELECT COUNT( * )
FROM dd02l
WHERE tabname = p_tname
AND as4local = 'A'
AND tabclass = 'TRANSP'.
IF sy-subrc <> 0.
RAISE invalid_table.
ENDIF.
ENDMETHOD. "check_selection
METHOD get_data.
tab ?= cl_abap_typedescr=>describe_by_name( p_tname ).
comp_tab = tab->get_components( ).
wa_tab = cl_abap_structdescr=>create( comp_tab ).
i_tab = cl_abap_tabledescr=>create( wa_tab ).
CREATE DATA i_table TYPE HANDLE i_tab.
ASSIGN i_table->* TO <f_tabl>.
IF p_rows IS INITIAL.
p_rows = '50000'.
ENDIF.
*Get data
SELECT * FROM (p_tname)
INTO TABLE <f_tabl>
UP TO p_rows ROWS.
IF sy-subrc <> 0.
RAISE no_data_found.
ENDIF.
ENDMETHOD. "get_data
METHOD generate_output.
*...New ALV Instance ...............................................
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = w_alv1
list_display = abap_false
IMPORTING
r_salv_table = o_salv
CHANGING
t_table = <f_tabl> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
*...PF Status.......................................................
Add MYFUNCTION from the report SALV_DEMO_TABLE_EVENTS
o_salv->set_screen_status(
pfstatus = 'SALV_STANDARD'
report = 'SALV_DEMO_TABLE_EVENTS'
set_functions = o_salv->c_functions_all ).
*...Event handler for the button.....................................
DATA: lo_events TYPE REF TO cl_salv_events_table,
lo_event_h TYPE REF TO lcl_event_handler.
event object
lo_events = o_salv->get_event( ).
event handler
CREATE OBJECT lo_event_h.
setting up the event handler
SET HANDLER lo_event_h->on_user_command FOR lo_events.
*...Get Model Object ...............................................
DATA: lo_alv_mod TYPE REF TO cl_salv_model.
Narrow casting
lo_alv_mod ?= o_salv.
object for the local inherited class from the CL_SALV_MODEL_LIST
CREATE OBJECT o_salv_model.
grabe model to use it later
CALL METHOD o_salv_model->grabe_model
EXPORTING
io_model = lo_alv_mod.
*...Generate ALV output ...............................................
o_salv->display( ).
ENDMETHOD. "generate_output
ENDCLASS. "lcl_report IMPLEMENTATION
----
LCL_SALV_MODEL implementation
----
CLASS lcl_salv_model IMPLEMENTATION.
METHOD grabe_model.
save the model
lo_model = io_model.
ENDMETHOD. "grabe_model
METHOD grabe_controller.
save the controller
o_control = lo_model->r_controller.
ENDMETHOD. "grabe_controller
METHOD grabe_adapter.
save the adapter from controller
o_adapter ?= lo_model->r_controller->r_adapter.
ENDMETHOD. "grabe_adapter
ENDCLASS. "LCL_SALV_MODEL IMPLEMENTATION
----
Event Handler for the SALV
----
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_user_command.
DATA: lo_grid TYPE REF TO cl_gui_alv_grid,
lo_full_adap TYPE REF TO cl_salv_fullscreen_adapter.
DATA: ls_layout TYPE lvc_s_layo.
CASE e_salv_function.
Make ALV as Editable ALV
WHEN 'MYFUNCTION'.
Contorller
CALL METHOD lo_report->o_salv_model->grabe_controller.
Adapter
CALL METHOD lo_report->o_salv_model->grabe_adapter.
Fullscreen Adapter (Down Casting)
lo_full_adap ?= lo_report->o_salv_model->o_adapter.
Get the Grid
lo_grid = lo_full_adap->get_grid( ).
Got the Grid .. ?
IF lo_grid IS BOUND.
Editable ALV
ls_layout-edit = 'X'.
Set the front layout of ALV
CALL METHOD lo_grid->set_frontend_layout
EXPORTING
is_layout = ls_layout.
refresh the table
CALL METHOD lo_grid->refresh_table_display.
ENDIF.
ENDCASE.
ENDMETHOD. "on_user_command
ENDCLASS. "lcl_event_handler IMPLEMENTATION
2011 Nov 13 6:24 PM
2012 Jan 09 2:34 AM
2012 Jan 09 2:48 PM
You're welcome!
Although I have to aver, that SAP doesn't support this kind of "workaround"!!!
2012 Jan 26 10:36 PM
2012 Jan 31 11:46 PM
2012 Feb 01 9:17 AM
Hi Custodio,
not yet, still waiting for my idea to create a new chapter for "ABAP stack" on Idea place. Else I don't know where to place the idea. Duhh, many "ideas" and "places" in this sentence
Regards, Uwe
2012 Feb 01 9:40 AM
Hi Uwe,
is there already an idea to create the ABAP area? But you can use the Area https://cw.sdn.sap.com/cw/community/ideas/sap_netweaver as ABAP is one incarnation of NetWeaver.
Best regards
Gregor
2012 Feb 01 10:37 AM
is there already an idea to create the ABAP area?
Yes, since October: https://cw.sdn.sap.com/cw/ideas/6046
But you can use the Area https://cw.sdn.sap.com/cw/community/ideas/sap_netweaver as ABAP is one incarnation of NetWeaver.
Will do.
2012 Feb 01 10:53 AM
Gregor: seams that it's not possible to post ideas on a main session (Netweaver) just in sub-sessions.
Now I posted this idea on "Suggest new topics" Maybe this helps for my other idea ("ABAP stack")
Here is the idea: https://cw.sdn.sap.com/cw/ideas/8349
2012 Feb 16 4:18 PM
thanks , nice development the abap ideas. just voted for the cl_salv edit functionality
I really don't understand why SAP wants developers to stick with the old and very usefull functions instead of adopting OO which can do half of what the function did in the past ? I thought they wanted everybody to adapt OO ?
kind regards
arthur
2012 Mar 06 7:50 AM
2012 Feb 16 11:52 AM
2012 May 04 5:27 PM
2012 Jun 25 11:32 PM
2012 Jun 27 9:08 AM
2012 Aug 08 4:13 PM
2013 Feb 19 2:50 PM
2013 Feb 22 9:37 PM
Hi guys
I agree and if I can push my luck, I would like to have the possibility to have more than one line as column header.
It is over 10 years I am waiting for that feature.
2013 Feb 22 11:29 PM
Daniel, did you try with the hierseq version of SALV?
Regards.
2013 Feb 25 2:12 PM
Hello Nahuel
If I am right, the hierseq version is displaying the information like the old "Display list" format and not like an ALV format.
My point is: Using the ALV format (Grid or worksheet format), it will be interesting to have the possibility to have 2 lines for each columns that is requiring longer header column without having to enlarge those ones to fit it.
Regards
Daniel
2013 Mar 10 9:36 PM
over 5 years later ...
And where are we now?
Yes, I would also prefer to have only one ALV model with all kinds of possibilities !?
still same situation ?!
2013 Mar 11 3:42 PM
I also would like to have an edit functionallity.
In my opinion it is extremly strange that SAP didn't made this possible for years. Editing is just a basic functionallity for a lot of ALV applications and if it is not supported the SALV class is just not useable. Sorry SAP, but not providing a mayor function requested by hunderts of developers for several years is just dishonorable for a big software company!
2020 Feb 25 1:31 PM
Feb-2020 and the editable column or field not exist yet. Team SAP please, provide this for us!!
2020 Feb 25 1:52 PM
2022 Mar 08 1:50 PM
For fun read this --> "International Editable SALV Day".
Purchase Paul Hardy's ABAP2TheFuture Book and you will have editable ALV.
I was able to extend his code to enable coloring of entire rows or individual fields in the row. His code is nice and well-structured and will teach you OO ABAP as a by-product.
You could also look here "Fast ALV" which is done by Łukasz Pęgiel for another way of having editable ALVs.
2024 Aug 05 9:26 PM
I came from the future to say it's way easier to add edit capabilities in CL_SALV_TABLE in comparison with creating a Fiori Elements List Report using OData V4 and Service bindings with weird looking unmanaged implementations.