cancel
Showing results for 
Search instead for 
Did you mean: 

How to put focus on a cell in ALV table for error handling?

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

   I have a webdynpro ALV report. In the ALV table there is a column ROUTECODE which is editable.

   If there are 5 rows in the ALV table and user changes the field ROUTECODE of the second row and press enter button.

   Then if the entered value is invalid, how to put focus on that cell ( field ROUTECODE of second row) with error message?

I have tried the sample code below but got stuck.

    lo_api_controller ?= wd_this->wd_get_api( ).
     CALL METHOD lo_api_controller->get_message_manager
       RECEIVING
         message_manager = lo_message_manager.

* report message
     CALL METHOD lo_message_manager->report_attribute_error_message(
       EXPORTING
         message_text   = lv_error
         element        =  <--  Here how to get reference of the context element (
field ROUTECODE of second row) ?
         attribute_name = 'ROUTECODE' ).

   

Thanks

Gopal

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

To get the reference of 2nd row use the below code.

lo_el_<NODE> = lo_nd_<NODE>->get_element( index = 2 ).

For error handling you can simply loop the internal table and and validate the field and display error.

EX:

LOOP AT lt_flight INTO ls_flight.

*    Do Validation

   if error.

     lo_el_flight = lo_nd_flight->get_element( index = sy-tabix ).

     Display error

endif.

ENDLOOP.

Hope this helps u.,

Regards,

Kiran