cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Edit how to save changes to DB??

Former Member
0 Kudos

Hello!

I tried the Editing ALV tutorial and one part is not clear for me.

When pressing the save button you want to check the edited Data in an ALV grid.

METHOD onactionsave .
  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
* Check for changes
  l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
  l_ref_interfacecontroller->data_check( ).
ENDMETHOD.

The tutorial now says

"Implement an event handler method for the interface event ON_DATA_CHECK with the following functionality"

Now my problem is. which events/methods are triggered to check the data? and to save the changes to the DB?

Which methods do i have to implement??

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

thanks!

but i don't know where to implement the ON_DATA_CHECK event trigger?

Because when i add the event in the event handler of my view, than is called onactionon_data_check! there is always the "onaction" part before.

Former Member
0 Kudos

Hi Thomas,

No need to add to your actions of view,directly go to the methods enter method name like ON_DATA_CHECK,Method type is event handler and then press F4 in Event column,select ON_DATA_CHECK from interface Controller.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Thomas,

ON_DATA_CHECK event is triggered every time when you change the data in table.

You have to implement an Event handler method for event ON_DATA_CHECK and inside that method write a logic to validate and save to data base table.Please check below code.

You have a parameter r_param in the method.It will hold modified value.you can validate that value against check table and raise error message if it is not a valid input.check below code.

METHOD ondatacheck .

DATA: node_node_flighttab TYPE REF TO if_wd_context_node,

elem_node_flighttab TYPE REF TO if_wd_context_element,

lt_sflight TYPE if_resultview=>elements_node_flighttab.

  • save data only if no error has occured

CHECK r_param->t_error_cells IS INITIAL.

node_node_flighttab = wd_context->get_child_node( name = `NODE_FLIGHTTAB` ).

  • get data from context node <NODE_FLIGHTTAB>

node_node_flighttab->get_static_attributes_table(

IMPORTING table = lt_sflight ).

*validate value

select carrid from sflght into v_sflight where carrid = r_param-value.

if sy-subrc ne 0.

  • raise error message

else.

*update to the data base.

modify table zsflight from lt_sflight transporting carrid.

endif.

Former Member
0 Kudos

I tried you sample code because I was having problems with inserting into my database.

I didn`t succed because of this "select carrid from sflght into v_sflight where carrid = r_param-value."

I know what is lt_sflight and probably zsflights is the database table that needs to be changed...But I don`t see any connection between these 2 and sflght and v_sflight. Should I use a READ INTO to make a connection?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

ilinktrinel, please do not add new questions to existing threads. Also your question doesn't seem related to Web Dynpro. You seem to have questions about basic ABAP SQL syntax. I would propose that you ask this question as a new thread in ABAP General.

Carola1
Product and Topic Expert
Product and Topic Expert
0 Kudos

Sorry, this is no answer, but I'm also interested in the ALV Edit Tutorial. Where can I find it ?

Thanks. Kind regards.

Carola