cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

hi Padmam,

i followed your suggestion above and i think that should be it.. however when i checked the required fields in onActionReview (using cl_wd_dynamic_tool=>check_mandatory_attr_on_view), the field i set as mandatory using the STATE is not set as mandatory. do i need to to some refresh on view or something? and how to do it?

btw, thanks for ur reply!

regards,

Raquel

-


hi Padmam,

my issue is solved, i created another action onToggle for the checkbox and now the input field i set as mandatory is correctly set.

BIG THANKS to you!

regards,

Raquel

Edited by: Raquel Tamayo on Mar 21, 2008 4:31 PM

Answers (0)