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: 

cl_salv_table --needs editable functionality -SAP please provide this

Former Member
16,104

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

Former Member
0 Kudos
1,985

We need this definately !

Currently I'm using *alv for editable tables and *salv for view tables, that's not satisfactorily.

Furthermore the *alv API disagrees with the modern *salv OO concept.

Hope SAP will implement the edit issue in *salv !

Regards

Olaf

bruce_hartley
Active Participant
0 Kudos
1,985

Add me to this list. I can't believe they didn't provide this. I just found out about this issue today from one of our developers who was using the old grid (reuse_alv) because of this issue.

Since all of our employees went to the new grid (cl_salv) class and don't know the old grid other than from examples, now we've got an issue because we stated up front to all of our contractors that only the new grid was to be used.

I know what SAP is going to say - use a dialog - that's a major pain compared to the old grid way. And now I've got a standards issue on my hands - oh what fun.

matt
Active Contributor
0 Kudos
1,985

I'm in.

>And now I've got a standards issue on my hands - oh what fun.

I love standards. So many to choose from...

matt

ThomasZloch
Active Contributor
0 Kudos
1,985

I strongly support this suggestion.

Cheers

Thomas

alejandro_bindi
Active Contributor
1,985

Count me in. I haven't used this new ALV OM a lot yet, but I've discovered this edit mode lack yesterday on a thread while searching for another functionality.

I just couldn't believe it. What would happen if you develop a fairly complicated program using CL_SALV* classes and then the user requests to "just add editing capability on this field and we're done" (which is quite common)? Half of the program would have to be redone using CL_GUI_ALV_GRID?

0 Kudos
1,985

I've tried a bit of "Old Fashioned" Hacking --- hope the US military are not reading this or I might be extradited to the US to serve 50 years in jail for "Terrorism" (referring to what the US are attempting to do to one of our UK citizens at the moment).

Inheriting the the cl_salv class doesn't actually help as this cl_salv_class makes calls all over the place and by the time you are done you are better off using the cl_gui_alv_grid anyway.

I certainly can understand the concept of making a quick easy callable ALV display has attractions but as people have posted users often want an "Editable" facility after a report has been designed.

I'm actually surprised this wasn't built in to the factory model.

Cheers

jimbo.

0 Kudos
1,985

Oh yes, there should definitely be an editing function!

BR Jörg

0 Kudos
1,985

Yeah

I too join the group, It's very much appreciated if edit option is incorporated!

Regards,

Ravi

Former Member
0 Kudos
1,985

Hello Everybody,

I am also facing the same problem , so include me also.

Thanks,

Pavan.

Former Member
0 Kudos
1,984

good thought Include me also.....

naimesh_patel
Active Contributor
0 Kudos
1,984

Before starting the poll, have look at this work around:

https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12187

Regards,

Naimesh Patel

0 Kudos
1,984

I am happy about the work-around. But I still think it should be available from cl_salv_table without that. It's annoying that SAP seems to have abandoned OO ALV in favor of webdynpro.

0 Kudos
1,984

Hi there

I'm still amazed this hasn't YET been done.

Actually Web Dynpro won't replace this functionality yet -- there's a big difference in running web dynpro and an OO report from a bog standard R/3 system.

Also -FM REUSE people

Don't use that -- use cl_gui_alv_grid -- this is fully OO and does have edit capability -- bit complex but does have it.

You can also run it in batch so there's absolutely NO NEED to use the old FM any more.

cheers

jimbo

0 Kudos
1,984

>

> Hi there

> I'm still amazed this hasn't YET been done.

> Actually Web Dynpro won't replace this functionality yet -- there's a big difference in running web dynpro and an OO report from a bog standard R/3 system.

>

> Also -FM REUSE people

>

> Don't use that -- use cl_gui_alv_grid -- this is fully OO and does have edit capability -- bit complex but does have it.

>

> You can also run it in batch so there's absolutely NO NEED to use the old FM any more.

>

> cheers

> jimbo

only problem is dat cl_gui_alv_grid doesn't have full screen mode. I started to investigate a new OO standard for the reuse_alv a few years ago but got stuck in the 2 classes cl_gui_alv_grid and cl_salv_table which both had major incapabilities compared to reuse_alv.

http://forums.sdn.sap.com/thread.jspa?threadID=301620

it's already complex enough to set up and understand 1 standard way of programming ALV lists editable or not. so It's not feasible to do a lot of investigation in setting up a standard for 1 class while you know that 1/3 of the z programms require the other class which require an equal amount of investigation and testing.

with the function GUI_UPLOAD they make a method 1-1 also called GUI_UPLOAD in CL_GUI_FRONTEND_SERVICES

which just calls the old function. so from now on I can easily use the method instead of the function.

why is that not done with the reuse_alv ?

Edited by: A. de Smidt on Oct 29, 2009 9:53 AM

0 Kudos
1,984

Hi there

this is a COMMON misconception - you CAN use the WHOLE screen in cl_gui_alv_grid.

Don't define a CUSTOM container - just use a docking container.

This gives you a FULL SCREEN.

If you need to split then use splitting control (continer).

(The CODE directive in the forum doesn't seem to work any more as I only get PLAIN TEXT input options.)

Cheers

jimbo

0 Kudos
1,984

I also tried this workaround, but it is still quite complicated...

there is another way to get acces to this functionality,

by using function module GET_GLOBALS_FROM_SLVC_FULLSCR

to get the reference to CL_GUI_ALV_GRID

In this example you just have to enter in the command field:

%_EDIT_ALL - to set the whole ALV editable

or

%_EDIT_[FIELDNAME] - to set only one column editable

in addition i added a check, so this is only available on NON-productive systems

*&---------------------------------------------------------------------*
*& Report  ZTEST_ALV_EDITABLE
*&
*&---------------------------------------------------------------------*

REPORT  ztest_alv_editable.

*----------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.

 PUBLIC SECTION.
   METHODS:
     on_user_command
       FOR EVENT added_function OF cl_salv_events
         IMPORTING e_salv_function,
     handle_data_changed
       FOR EVENT data_changed OF cl_gui_alv_grid
         IMPORTING er_data_changed sender.

ENDCLASS.                    "lcl_event_handler DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_report DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_report DEFINITION.

 PUBLIC SECTION.
   DATA: gt_tab TYPE REF TO data,
         gr_alv TYPE REF TO cl_salv_table.

   METHODS: constructor,
            show_alv.

ENDCLASS.                    "lcl_report DEFINITION

PARAMETERS: p_table TYPE tabname.

DATA: lr_report TYPE REF TO lcl_report.

START-OF-SELECTION.

 CREATE OBJECT lr_report.
 lr_report->show_alv( ).

*----------------------------------------------------------------------*
*       CLASS lcl_report IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.

 METHOD constructor.

   FIELD-SYMBOLS: <lt_tab> TYPE ANY TABLE.

   CREATE DATA gt_tab TYPE TABLE OF (p_table).
   ASSIGN gt_tab->* TO <lt_tab>.

   SELECT * FROM (p_table) INTO TABLE <lt_tab>.

 ENDMETHOD.                    "constructor

 METHOD show_alv.

   DATA: lr_func TYPE REF TO cl_salv_functions_list,
         lr_events    TYPE REF TO cl_salv_events_table,
         lr_handler   TYPE REF TO lcl_event_handler.

   FIELD-SYMBOLS: <lt_tab> TYPE ANY TABLE.
   ASSIGN gt_tab->* TO <lt_tab>.

   TRY.
       cl_salv_table=>factory(
       IMPORTING
         r_salv_table  = gr_alv
       CHANGING
         t_table       = <lt_tab> ).
     CATCH cx_salv_msg.
   ENDTRY.

   lr_func = gr_alv->get_functions( ).
   lr_func->set_all( 'X' ).

   lr_events = gr_alv->get_event( ).
   CREATE OBJECT lr_handler.
   SET HANDLER lr_handler->on_user_command FOR lr_events.

   gr_alv->display( ).

 ENDMETHOD.                    "show_alv

ENDCLASS.                    "lcl_report IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.

 METHOD on_user_command.

   DATA: lr_grid         TYPE REF TO cl_gui_alv_grid,
         lv_layout       TYPE lvc_s_layo,
         lt_fieldcat     TYPE lvc_t_fcat,
         lr_grid_events  TYPE REF TO lcl_event_handler,
         lv_fieldname    TYPE lvc_fname.

   FIELD-SYMBOLS: <ls_fieldcat> LIKE LINE OF lt_fieldcat.

   CALL FUNCTION 'PRGN_CHECK_SYSTEM_PRODUCTIVE'
     EXCEPTIONS
       client_is_productive = 1
       OTHERS               = 2.

   IF sy-subrc NE 1.

     IF e_salv_function(7) EQ '%_EDIT_'.

       IF e_salv_function NE '%_EDIT_ALL'.
         lv_fieldname = e_salv_function+7.
       ELSE.
         CLEAR lv_fieldname.
       ENDIF.

       CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
         IMPORTING
           e_grid = lr_grid.

       CALL METHOD lr_grid->get_frontend_layout
         IMPORTING
           es_layout = lv_layout.

       IF lv_fieldname IS NOT INITIAL.

         lr_grid->get_backend_fieldcatalog(
           IMPORTING et_fieldcatalog = lt_fieldcat ).

         READ TABLE lt_fieldcat ASSIGNING <ls_fieldcat>
           WITH KEY fieldname = lv_fieldname.

         IF <ls_fieldcat> IS NOT ASSIGNED.
           MESSAGE w398(00)
             WITH  'Fieldname'
                   lv_fieldname
                   'does not exist'.
           EXIT.
         ENDIF.

         IF <ls_fieldcat>-edit = 'X'.

           lv_layout-no_toolbar = abap_true.
           <ls_fieldcat>-edit = abap_false.

         ELSE.

           lv_layout-no_toolbar = abap_false.
           <ls_fieldcat>-edit = abap_true.

         ENDIF.

         lr_grid->set_frontend_fieldcatalog(
         EXPORTING it_fieldcatalog = lt_fieldcat ).

       ELSE.

         IF lv_layout-edit = abap_true.

           CLEAR lv_layout-edit.

         ELSE.

           lv_layout-edit = abap_true.

         ENDIF.

       ENDIF.

       CALL METHOD lr_grid->register_edit_event
         EXPORTING
           i_event_id = cl_gui_alv_grid=>mc_evt_enter.

       CREATE OBJECT lr_grid_events.
       SET HANDLER lr_grid_events->handle_data_changed FOR lr_grid.

       CALL METHOD lr_grid->set_frontend_layout
         EXPORTING
           is_layout = lv_layout.

       CALL METHOD lr_grid->refresh_table_display( ).

     ENDIF.
   ENDIF.

 ENDMETHOD.                    "on_user_command

Edited by: Jakob Simon Mainka on Dec 14, 2011 12:17 AM

0 Kudos
1,984

can you perhaps split the code blocks into several blocks, above a certain amount of characters code blocks are scrambled since they don't want you to copy past complete programs here on sdn

kind regards

arthur

0 Kudos
1,984

&----


*& Report ZTEST_ALV_EDITABLE

*&

&----


REPORT ztest_alv_editable.

----


  • CLASS lcl_event_handler DEFINITION

----


*

----


CLASS lcl_event_handler DEFINITION.

PUBLIC SECTION.

METHODS:

on_user_command

FOR EVENT added_function OF cl_salv_events

IMPORTING e_salv_function,

handle_data_changed

FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed sender.

ENDCLASS. "lcl_event_handler DEFINITION

----


  • CLASS lcl_report DEFINITION

----


*

----


CLASS lcl_report DEFINITION.

PUBLIC SECTION.

DATA: gt_tab TYPE REF TO data,

gr_alv TYPE REF TO cl_salv_table.

METHODS: constructor,

show_alv.

ENDCLASS. "lcl_report DEFINITION

PARAMETERS: p_table TYPE tabname.

DATA: lr_report TYPE REF TO lcl_report.

START-OF-SELECTION.

CREATE OBJECT lr_report.

lr_report->show_alv( ).

----


  • CLASS lcl_report IMPLEMENTATION

----


*

----


CLASS lcl_report IMPLEMENTATION.

METHOD constructor.

FIELD-SYMBOLS: <lt_tab> TYPE ANY TABLE.

CREATE DATA gt_tab TYPE TABLE OF (p_table).

ASSIGN gt_tab->* TO <lt_tab>.

SELECT * FROM (p_table) INTO TABLE <lt_tab>.

ENDMETHOD. "constructor

METHOD show_alv.

DATA: lr_func TYPE REF TO cl_salv_functions_list,

lr_events TYPE REF TO cl_salv_events_table,

lr_handler TYPE REF TO lcl_event_handler.

FIELD-SYMBOLS: <lt_tab> TYPE ANY TABLE.

ASSIGN gt_tab->* TO <lt_tab>.

TRY.

cl_salv_table=>factory(

IMPORTING

r_salv_table = gr_alv

CHANGING

t_table = <lt_tab> ).

CATCH cx_salv_msg.

ENDTRY.

lr_func = gr_alv->get_functions( ).

lr_func->set_all( 'X' ).

lr_events = gr_alv->get_event( ).

CREATE OBJECT lr_handler.

SET HANDLER lr_handler->on_user_command FOR lr_events.

gr_alv->display( ).

ENDMETHOD. "show_alv

ENDCLASS. "lcl_report IMPLEMENTATION

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


*

----


CLASS lcl_event_handler IMPLEMENTATION.

METHOD on_user_command.

DATA: lr_grid TYPE REF TO cl_gui_alv_grid,

lv_layout TYPE lvc_s_layo,

lt_fieldcat TYPE lvc_t_fcat,

lr_grid_events TYPE REF TO lcl_event_handler,

lv_fieldname TYPE lvc_fname.

FIELD-SYMBOLS: <ls_fieldcat> LIKE LINE OF lt_fieldcat.

CALL FUNCTION 'PRGN_CHECK_SYSTEM_PRODUCTIVE'

EXCEPTIONS

client_is_productive = 1

OTHERS = 2.

IF sy-subrc NE 1.

IF e_salv_function(7) EQ '%_EDIT_'.

IF e_salv_function NE '%_EDIT_ALL'.

lv_fieldname = e_salv_function+7.

ELSE.

CLEAR lv_fieldname.

ENDIF.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lr_grid.

CALL METHOD lr_grid->get_frontend_layout

IMPORTING

es_layout = lv_layout.

IF lv_fieldname IS NOT INITIAL.

lr_grid->get_backend_fieldcatalog(

IMPORTING et_fieldcatalog = lt_fieldcat ).

READ TABLE lt_fieldcat ASSIGNING <ls_fieldcat>

WITH KEY fieldname = lv_fieldname.

IF <ls_fieldcat> IS NOT ASSIGNED.

MESSAGE w398(00)

WITH 'Fieldname'

lv_fieldname

'does not exist'.

EXIT.

ENDIF.

IF <ls_fieldcat>-edit = 'X'.

lv_layout-no_toolbar = abap_true.

<ls_fieldcat>-edit = abap_false.

ELSE.

lv_layout-no_toolbar = abap_false.

<ls_fieldcat>-edit = abap_true.

ENDIF.

lr_grid->set_frontend_fieldcatalog(

EXPORTING it_fieldcatalog = lt_fieldcat ).

ELSE.

IF lv_layout-edit = abap_true.

CLEAR lv_layout-edit.

ELSE.

lv_layout-edit = abap_true.

ENDIF.

ENDIF.

CALL METHOD lr_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

CREATE OBJECT lr_grid_events.

SET HANDLER lr_grid_events->handle_data_changed FOR lr_grid.

CALL METHOD lr_grid->set_frontend_layout

EXPORTING

is_layout = lv_layout.

CALL METHOD lr_grid->refresh_table_display( ).

ENDIF.

ENDIF.

ENDMETHOD. "on_user_command

0 Kudos
1,984

thanks

Former Member
0 Kudos
1,984

Even i like the workaround I too think that there should be and "offical" (and supportet) way of makin an SALV Grid editable

0 Kudos
1,984

Please addd me to the Group

Former Member
0 Kudos
1,984

Supported already!!!

Flavio Rasseli

0 Kudos
1,984

Hi Flavio,

Do you mean the ALV editable functionality is now available in CL_SALV_TABLE? If yes, can you explain which method you used?

Cheers,

Jodie

0 Kudos
1,984

No! I mean: the CAUSE is supported by me!

Sorry.

Former Member
0 Kudos
1,984

To be fair, the V stands for Viewer, not Editor (cos that would make it ALE and confusing ). SAP should never have opened the original viewer code up for editing.

0 Kudos
1,984

so in that case if V stands for viewing there must come an class

CL_SALE_TABLE for the editing which inherits all the methods from CL_SALV_TABLE.

question remains the same. we also stick to reuse_alv since the class is not complete with the edit mode.

kind regards

arthur

0 Kudos
1,984

I Agree

Former Member
0 Kudos
1,984

Count me in.

Edited by: Shanmugam Maheswaran on Oct 29, 2009 6:23 PM

0 Kudos
1,984

Add me to the Group too guys. I had to convince our guys a lot to get back to cl_alv_grid instead cl_salv_table for edit purposes.

Regards

Former Member
0 Kudos
1,984

Count me in!

Containers aren't supported in batch mode (someone always requests their reports in background), and i'm getting tired of the REUSE function, this needs to be incorporated into this new architecture.

ali_husain3
Explorer
0 Kudos
1,984

I totally agree that ALV OM should have support for Editable content in the ALV. I have used the new model which is really nice and easy to understand, i just don't understand why the editing functionality is not supported. I haven't looked at the work around solution that was suggested here but i hope that i don't have to use the old classes since i never worked with them.

Former Member
0 Kudos
1,984

Hi,

I also tried finding the editing function but was not able to find anything.

I strongly support you in this. Lets see if SAP does something about it.

Regards,

Manish Kumar

paul_abrahamson_sap
Active Participant
0 Kudos
1,984

I agree.

I'd rather SAP supplied and supported a well-documented solution. Using workarounds like the one Naimesh Patel has blogged about is probably not supported by SAP.

Regards,

Paul

0 Kudos
1,984

+1

Uwe, aka @se38

0 Kudos
1,984

+1

0 Kudos
1,984

Yes, very annoying. Someone should come up with a solution to this!

fred_verheul
Active Contributor
0 Kudos
1,984

Count me in as well!

Regards, Fred

Former Member
0 Kudos
1,984

I agree

Max

jrg_wulf
Active Contributor
0 Kudos
1,984

I'm in it too.

Regards Jörg