cancel
Showing results for 
Search instead for 
Did you mean: 

Making a particular column of a table red when there is an error

Former Member
0 Kudos

Hello Experts,

I have a table UI element in a view and a user can manually enter the values in the columns.

I have 3 columns for that table.

Now when i enter values in four rows then i am taking 3rd column of 1st row and second column of 2nd row and then comparing them.

If there is an error in the comparision then i am using REPORT_ATTRIBUTE_ERROR and thus giving the attribute and element name.

Now the issue i am facing is the column that is being marked red is always of the 1st row no matter the error is from 3 or 4 or any other row.

Now how can i mark the exact column in red.

Please help.

Thanks in Advance,

Shravan

Accepted Solutions (1)

Accepted Solutions (1)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

1. get all the elemets of the node...

2. loop at all_elements into ls_elements.

ls_elements=>get_static_att

exporitng

ls_values

" check for error

if ls_values-sdate > ls_value-edate...

  • report message

CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = 'edate is less than sdate'

  • MESSAGE_TYPE = CO_TYPE_ERROR

ELEMENT = lo_el_ref_no_tbl_view. " this is a wrong one ,,,, you have to use "ls_elements."

ATTRIBUTE_NAME = 'EDATE'.

endif.

Answers (2)

Answers (2)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

you can make use of methods which will give you all the elements in the table

and then you can read those elements using get_static_att methods for the values..

and then you can compare ,,, now you will have the exact element as well

1. put this code outside the loop..

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = lo_message_manager.

2. you are looping at the table which holds value, instead you need to loop at the table which has elements

node->get_elements ...something like that.... use this to get all the elements

loop at all_elements into ls_elements.

ls_elements=>get_static_att

" check for error

if sy-subrc eq 0.

  • report message

CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = 'edate is less than sdate'

  • MESSAGE_TYPE = CO_TYPE_ERROR

ELEMENT = lo_el_ref_no_tbl_view. " this is a wrong one ,,,, you have to use "ls_elements."

ATTRIBUTE_NAME = 'EDATE'.

endif.

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

You can actual do this one...

your value of the context element is wrong...

i believe as you are comparing the values in a table...

now you hold the context element of the first row...

you can make use of methods which will give you all the elements in the table

and then you can read those elements using get_static_att methods for the values..

and then you can compare ,,, now you will have the exact element as well

Former Member
0 Kudos

Hi ,

Thanks for the quick reply...

Here is the code i am using.But not able to get what i require....

CALL METHOD LO_ND_REF_NO_TBL_VIEW->GET_STATIC_ATTRIBUTES_TABLE

EXPORTING

FROM = 1

TO = 2147483647

IMPORTING

TABLE = lt_ref_no_tbl_view

.

LOOP at lt_ref_no_tbl_view INTO lw_ref_no_tbl_view.

if lw_ref_no_tbl_view-edate lt lw_ref_no_tbl_view-sdate.

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_ELEMENT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = 'edate is less than sdate'

  • MESSAGE_TYPE = CO_TYPE_ERROR

ELEMENT = lo_el_ref_no_tbl_view.

ATTRIBUTE_NAME = 'EDATE'.

When the error is in the second row the 1st row column is being highlited....

Please help

Thanks,

Shravan

saravanan_narayanan
Active Contributor
0 Kudos

Hello Shravan,

you are passing ELEMENT as lo_el_ref_no_tbl_view instead of lw_ref_no_tbl_view. I hope this is typo error.

With your logic

if lw_ref_no_tbl_view-edate lt lw_ref_no_tbl_view-sdate.

, you are always comparing EDATE and SDATE of the same row. Is this your requirement?

BR, Saravanan

Former Member
0 Kudos

Hello Saravanan,

Yes that was my requirement.

I need to raise the error message based on the comparision between start date and end date.

My problem is that the concerned column is not highlited.

Always the 1st row is only being highlited.

Hope you understood my issue...

Thanks,

Shravan

saravanan_narayanan
Active Contributor
0 Kudos

Hello Shravan,

then I would go with what SSM proposed.



data lt_elements type WDR_CONTEXT_ELEMENT_SET.
data lo_element type ref to if_wd_context_element.


lo_api_controller ?= wd_This->Wd_Get_Api( ).
CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = lo_message_manager.


"Get all the elements in the table
lt_elements = LO_ND_REF_NO_TBL_VIEW->get_elements( ).

"Loop thru all the elements

loop at lt_elements into lo_element.
   lo_element->get_static_attributes( lw_ref_no_tbl_view ).

   if lw_ref_no_tbl_view-edate lt lw_ref_no_tbl_view-sdate.

      CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
         EXPORTING
           MESSAGE_TEXT = 'edate is less than sdate'
* MESSAGE_TYPE = CO_TYPE_ERROR
          ELEMENT = lo_element
          ATTRIBUTE_NAME = 'EDATE'.

   endif.

endloop.

BR, Saravanan

Former Member
0 Kudos

Thank You both

Problem got solved..

Cheers,

Shravan