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

cl_salv_table --needs editable functionality -SAP please provide this

Former Member
31,065

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

109 REPLIES 109
Read only

Former Member
0 Likes
4,944

Agree

Read only

0 Likes
4,944

I Agree

Read only

Former Member
0 Likes
4,944

I would also really apreciate it

Read only

0 Likes
4,944

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

Read only

0 Likes
4,944

Agree.

Read only

andrs_sarcevic
Contributor
0 Likes
4,944

I couldn't agree more!

Read only

0 Likes
4,944

You're welcome!

Although I have to aver, that SAP doesn't support this kind of "workaround"!!!

Read only

Former Member
0 Likes
4,944

AGREE

Read only

custodio_deoliveira
Active Contributor
0 Likes
4,944

Agreed. Has it been added to idea place yet?

Read only

0 Likes
4,944

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

Read only

0 Likes
4,944

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

Read only

0 Likes
4,944

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.

Read only

0 Likes
4,944

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

Read only

0 Likes
4,944

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

Read only

0 Likes
4,944

So... did we win?

Read only

Former Member
0 Likes
4,944

Agree.

Read only

Former Member
0 Likes
4,944

Agree !!

Read only

Former Member
0 Likes
4,944

I agree.

Read only

Anand71
Active Contributor
0 Likes
4,944

Add me.

Read only

0 Likes
4,944

This is the solution for the original issue...

http://harelgilor.blogspot.com.ar/

Read only

Former Member
0 Likes
4,944

Agree!

Any news from SAP?

Read only

Former Member
0 Likes
4,944

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.

Read only

0 Likes
4,944

Daniel, did you try with the hierseq version of SALV?

Regards.

Read only

0 Likes
4,944

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

Read only

former_member203179
Participant
4,944

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 ?!

Read only

0 Likes
4,944

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!

Read only

former_member665159
Discoverer
0 Likes
4,944

Feb-2020 and the editable column or field not exist yet. Team SAP please, provide this for us!!

Read only

0 Likes
4,944

You could force it

Read only

christian_brhl
Explorer
4,944

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.

Read only

FabioPagoti
Active Contributor
4,660

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.