cancel
Showing results for 
Search instead for 
Did you mean: 

dyanamically showing required fields

Former Member
0 Kudos

Hi Everyone,

I have one input enable table with 5 fields. and one save button to save records in ztable. when i am entering any value in first field and other fields blank and clicks on SAVE button it should show message that 2nd field is mandatory.

i used following code and i have made 2nd field as state property Required.

but it is showing mandatory message for entire column.although i am entering 2 row entry of first field. it should show mandatory message for 2 rows of 2nd column.

data l_view_controller type ref to if_wd_view_controller.

l_view_controller = wd_this->wd_get_api( ).

cl_wd_dynamic_tool=>check_mandatory_attr_on_view( view_controller = l_view_controller ).

can anybody help me.

Thanx in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Use the GET_ELEMENTS of your node, Loop through the elements and check wether the fields are intial as per row wise and try to throw the error by urself.

Have you tried using CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTRIBUTES method for the same.

Regards,

Lekha.

gill367
Active Contributor
0 Kudos

Hello john,

in that case you cannot use the utility class you have to manually generate the error message like as shown below.

write this code in your eventhandler of SAVE button.


  data ct_el type ref to if_wd_context_element.
  DATA STR TYPE STRING.
  DATA RESULT TYPE WDY_BOOLEAN VALUE ABAP_FALSE.
ct_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
ct_el->get_attribute(
EXPORTING
NAME = 'TEST'                   "HERE GIVE THE NAME OF THE ATTRIBUTE FOR THE SECOND COL
IMPORTING
VALUE = STR


).
if STR is  initial.
        RESULT = abap_true.
endif.

IF RESULT EQ ABAP_TRUE.
*   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              =     'MANDATROY fIELD !!!!!!!'
      ELEMENT                   =      CT_EL
      ATTRIBUTE_NAME            =     'TEST'                 "NAME OF THE ATTRIBUTE

      .

  ENDIF.

thanks

sarbjeet singh