cancel
Showing results for 
Search instead for 
Did you mean: 

How Highlight a CELL on an ALV table

former_member189690
Participant
0 Kudos

Hi all!

I'm trying to do some checks on an input field of an ALV table component. But using REPORT_ATTRIBUTE_T100_MESSAGE it doesn't highlight the CELL of the row if the check hasn't been passed succesfully.

I've used this source code but nothing appears on the screen, no message and no cell highlighted. I put my source code for more information:

LOOP AT lt_data_mod INTO ls_data_mod.

  • alternative access via index

lo_el_n_empleado = lo_nd_n_empleado->get_element( index = ls_data_mod-index ).

  • CHECK VALUE

  • report message

CALL METHOD wd_comp_controller->go_message->report_attribute_t100_message

EXPORTING

msg = ls_msg

element = lo_el_n_empleado

attribute_name = ls_data_mod-attribute. " The name of input field that it is being modified

All that source code is in ON_DATA_CHECK event of ALV component.

Can anyone help me ?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check if this thread helps:

Regards

Manas Dua

former_member189690
Participant
0 Kudos

Hi Manas,

Thank you for your help but this solution doesn't solve my problem, no message is appearing either Cell highlighted.

As an additional info of my issue: ALV table settings are builded dynamically on runtime. I put selection mode = 02 (Single no lead).

I call validation of data on ON_DATA_CHECK event of ALV component.

Any other solution please?

Thank you

Edited by: vanbelal on Mar 22, 2010 3:24 PM

Former Member
0 Kudos

Hi

well i was able to do that in one of project by doing following:


lo_nd_c_data_tab->set_lead_selection_index(
              EXPORTING
              index =  wd_comp_controller->lead_selection_index ) .

* get element via lead selection
    lo_el_c_data_tab = lo_nd_c_data_tab->get_element(  ).

* report message
    CALL METHOD lo_message_manager->report_element_t100_message
      EXPORTING
        msg     = wd_comp_controller->msg_parameters
        element = lo_el_c_data_tab.

make sure that you set the lead selection for the alv node....in the above code...wd_comp_controller->lead_selection_index is set in a loop....if i find an error by looping through the alv table...i exit the loop and set my this lead_selection_index parameter...and it is of type SY-TABIX...

wd_comp_controller->msg_parameters: this is of type SYMSG....

if this does not help you...pls provide your code what you are doing...then we can see where the issue is...

Thanks...

AS..

former_member189690
Participant
0 Kudos

Hello,

I put my source code:

ON_DATA_CHECK event of ALV:

lt_data_mod[] = lr_data->t_modified_cells[].

LOOP AT lt_data_mod INTO ls_data_mod.

  • alternative access via index

lo_el_n_empleado = lo_nd_n_empleado->get_element( index = ls_data_mod-index ).

  • get all declared attributes

lo_el_n_empleado->get_static_attributes(

IMPORTING

static_attributes = ls_n_empleado ).

  • Leemos la información inicial para hacer posteriormente los recalculos.

READ TABLE wd_this->gt_empleados_inicial INTO ls_empleados_inicial WITH KEY pernr = ls_n_empleado-pernr.

ASSIGN ls_data_mod-r_value->* TO .

  • Fijamos el valor del campo INCIN o PERIN en función de si el usuario ha modificado el valor en pantalla

IF ls_data_mod-r_value NE ls_data_mod-r_old_value AND

GE ls_n_empleado-incsu.

IF ls_data_mod-attribute = 'INCPA'.

ls_n_empleado-incin = abap_true.

ELSEIF ls_data_mod-attribute = 'PERVC'.

ls_n_empleado-perin = abap_true.

ENDIF.

ELSEIF <fs_data> LT ls_n_empleado-incsu. " Check if user entry is less than incsu value then throw message...

wd_comp_controller->show_message_2( imp_element = lo_el_n_empleado

imp_msgno = '622'

imp_attr = ls_data_mod-attribute ). " El valor introducido es menor que el " incremento sugerido

ENDIF.

METHOD show_message_2 .

DATA lv_message_id TYPE string.

DATA ls_msg TYPE symsg.

ls_msg-msgty = 'E'.

ls_msg-msgid = 'ZHR_CM'.

ls_msg-msgno = imp_msgno.

  • report message

CALL METHOD wd_this->go_message->report_attribute_t100_message

EXPORTING

msg = ls_msg

element = imp_element

attribute_name = imp_attr.

ENDMETHOD.

Also I've tried with report_element_t100_message method but nothing happens.

Thank you.

Edited by: vanbelal on Mar 22, 2010 4:54 PM

Former Member
0 Kudos

NA

Edited by: Manas Dua on Mar 22, 2010 10:00 PM

Former Member
0 Kudos

Hi,

just want to make sure that you know how ON_DATA_CHECK works....it will never get invoked if you change something on the alv table and hit enter....you need to press the check btn which appears on the top of alv table once you make alv editable....

this is what i am experiencing in my system.....you might be on a latest pack from SAP...i am on ecc6.0

so how are you invoking on_data_check event??

i will play with it little bit more and if time permits give you a solution...

Thanks..

AS..

Former Member
0 Kudos

Hi,

Alright here is the solution for your issue:


method CHECKINPUT .

data lo_r_param type ref to if_salv_wd_table_data_check.

lo_r_param = r_param.


  DATA lo_nd_flight_list_1 TYPE REF TO if_wd_context_node.

  DATA lo_el_flight_list_1 TYPE REF TO if_wd_context_element.
  DATA ls_flight_list_1 TYPE wd_this->element_flight_list_1.
  DATA lt_flight_list_1 TYPE wd_this->elements_flight_list_1.
* navigate from <CONTEXT> to <FLIGHT_LIST_1> via lead selection
  lo_nd_flight_list_1 = wd_context->path_get_node( path = `CHANGING.FLIGHT_LIST_1` ).


 data lo_tab type SALV_WD_T_TABLE_MOD_CELL.
data wa_lo_tab type SALV_WD_S_TABLE_MOD_CELL.

lo_tab = lo_r_param->T_MODIFIED_CELLS.
*assumption is that there will be only one entry per click of check btn...you can change this later
*as per your requirements
read table lo_tab into wa_lo_tab index 1.


lo_nd_flight_list_1->set_lead_selection_index(
              EXPORTING
              index =  wa_lo_tab-index ) .

* get element via lead selection
  lo_el_flight_list_1 = lo_nd_flight_list_1->get_element( ).



* get message manager
DATA lo_api_controller     TYPE REF TO if_wd_controller.
DATA lo_message_manager    TYPE REF TO if_wd_message_manager.

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              = 'the value was change'
    element                   = lo_el_flight_list_1
    attribute_name            = 'CARRID'
*    params                    =
*    msg_user_data             =
*    is_permanent              = ABAP_FALSE
*    scope_permanent_msg       = CO_MSG_SCOPE_CTXT_ELEMENT
*    msg_index                 =
*    cancel_navigation         =
*    is_validation_independent = ABAP_FALSE
*    enable_message_navigation =
*    view                      =
*  receiving
*    message_id                =
    .


Former Member
0 Kudos

the method is created as an event handler for alv event "ON_DATA_CHECK" as you know how to do it already....

but keep in mind that this method gets invoked only when user presses the "check" btn which shows up on top of alv table once you make alv editable...along with other btns: insert row, delete row btns

the above code highligt the cell where ever i changed the value and hit the check btn....and spits out a msg that value was changed....

hope this helps...

Thanks..

AS

need to split the thread into two...or code was getting messed up....

former_member189690
Participant
0 Kudos

Hi again guys,

More info about ALV settings, I have this settings for ALV table:

l_table->if_salv_wd_table_settings~set_selection_mode( '02' ).

l_table->if_salv_wd_table_settings~set_read_only( abap_false ).

l_table->if_salv_wd_std_functions~set_edit_check_available( abap_false ).

  • User don't want to have Check button

l_table->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).

  • With this line allows to throw ON_DATA_CHECK event

l_table->if_salv_wd_table_settings~set_cell_action_event_enabled( abap_true ). *

  • Allows throw event when user hit enter

As you can see user doesn't want to show Check button on ALV, so, is there any solution to do validation just pressing Enter button when user put a value on an input field CELL? In fact, ON_DATA_CHECK event it's being invoked fine when I press enter, why are the messages and highlights not being showed?

Thanks for yout help friends!

Former Member
0 Kudos

Hi,


l_value->if_salv_wd_table_settings~set_top_of_list_visible( value  = abap_true ).
l_value->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).
l_value->if_salv_wd_std_functions~set_edit_check_available( abap_false ). 
l_value->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).
l_value->if_salv_wd_std_functions~set_pdf_allowed( abap_true ).
l_value->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
l_value->if_salv_wd_std_functions~set_export_allowed( abap_true ).

these are my settings...it is also working for enter as well...can you try to show message for only one wrong entry...i mean do not use the looping...or exit looping the moment you find one wrong entry and look at the code what i posted last time...how to get all the change entries....

Thanks...

AS...

Note: you can also utilize method "WDDOBEFOREACTION"....once user hit the enter this method runs...but make sure that you run your code only when it is required...i mean enclosed your check code with some action name or condition...I tested this one as well...and this works too...

former_member189690
Participant
0 Kudos

Hi again,

I've tried to put code directly on WDDOBEFOREACTION setting element with index 1 as default and works fine!!! .

But now, I have more doubts. How can I get the index of element that is being modified before call method WDDOBEFOREACTION? I would need it to get element with the correct index.

More info, the user doesn't select the row with selection button, just click on a cell and put the value.

I see ON_CLICK ALV event but nothing happens when I click on a cell.

I feel very close to the final solution.

Many thanks!

Edited by: vanbelal on Mar 24, 2010 10:24 AM

Former Member
0 Kudos

Use ON_CELL_ACTION Event.

"  Set the ON_CELL_ACTION to true in WDDOMODIFYVIEW method
METHOD wddomodifyview.

* Instantiate the ALV
* Get Interface method GET_MODEL

  IF first_time IS INITIAL.
    CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
     EXPORTING
        value = abap_true. 

 ENDIF.
ENDMETHOD.

" Implement the event handler method ON_CELL_ACTION
METHOD oncell_action.
  DATA: l_element TYPE REF TO if_wd_context_element.
  DATA:ls_stru TYPE wd_this->element_cn_alv.

  DATA index TYPE i.

  index = r_param->index.

  DATA: l_node TYPE REF TO if_wd_context_node.
  l_node  = wd_context->get_child_node( 'CN_ALV' ).
  l_element = l_node->get_element( index ).
  l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).

ENDMETHOD.

former_member189690
Participant
0 Kudos

It works!

Many thanks to all!

Answers (1)

Answers (1)

Former Member
0 Kudos

@vanbelal:

I have the same problem.

If I set a linked Message in the on_cell_action_event(), it works.

If I set a linked Message only in the WDDOMODIFYVIEW(), it works only at first time (Parameter first_time doesn't used). At next roundtrip with "Enter" message doesn't linked.

If I set one linked message in the on_cell_action_event() AND second WDDOMODIFYVIEW(), both message works at the next roundtrip, too.

Allways, I must set the linked Message in on_cell_action()? Why doesn't work in WDDOMODIFYVIEW() correctly?

Edited by: Maik Sturm on Dec 13, 2011 11:30 AM