Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

webdynpro abap: how to set non-required field to require dynamically?

hi,

this is my case..

i have a DETAIL view which has a ViewContainerUIELement and a Review button. my ViewContainerUIElement(RECORD) has all the fields (input fields and checkboxes) i need to populate. now, i need to dynamically set one of the input field as Required if a certain checkbox is ticked. im thinking of placing the validation on the onActionReview (of the REVIEW button) so that i wont have to go to the next view (CONFIRMATION) if an error on Mandatory fields exists. i call the check_mandatory_attr_on_view on this onActionReview method.

how can i make it work and what classes/methods do i need to code?

will greatly appreciate the help..

regards,

Raquel

replied

Hi,

In the View Record Context create on atrribute STATE with type STRING. For that Input field for which u need mandatory in the Properties For the State bind the Attribute STATE.

After checking the Condition for the Checkbox,if the Condition is true then Set the Attribute STATE as 'required'.

DATA lo_el_context TYPE REF TO if_wd_context_element.

* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

if checkbox = 'X'.
* set single attribute
  lo_el_context->set_attribute(
      name =  `STATE`
      value = 'required' ).
else.
* set single attribute
  lo_el_context->set_attribute(
      name =  `STATE`
      value = 'Normal Item' ).

endif.

Regards,

Padmam.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question