cancel
Showing results for 
Search instead for 
Did you mean: 

Check Mandatory Fields when state is bound with context attribute

Former Member
0 Kudos

Hello All,

Currently i am facing problem in my SAP SRM 7.0 standard component.

Actually, i have to remove mandatory(State = Required) for one of my inputfileds for this I have written below code, but it has been remove only Red mark * infront of Inputfield, after that, i am trying to save other data, still it is asking me enter the required value.

here my input field bound with Context attribute, it is standard attribute.

data:lo_input1 type ref to cl_wd_input_field. 
  
   lo_input1 ?= VIEW->get_element( 'NAME_FIRST' ). 
   lo_input1->set_state( '00' ).

I am trying to delete state = required property from below component and view

Component Name : /SAPSRM/WDC_MOFC_PERSON
       View  :  V_PERSON

Can you help me on this?

Thanks

Sandeep.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

on my own

0 Kudos

Hi Sandeep Kumar,

I am also facing the same issue. Through enhancement pre-exit the mandatory symbol (*) was removed for the field 'FORM_OF_ADDRESS_DROPDOWN'. But during the save action the validation is triggering and asking to enter the required value.

Kindly let us know how you fixed this issue.

Thanks & Regards,

Kamal

Former Member
0 Kudos

hi,

This behavior is correct. state property does not also controls over the mandatory check.

Probably it is coded in one of the hook method like "doafteraction" .

Also search for the cl_wd_dynamic_tool=>check_mandatory_attr_on_view( ) in your code and disable this for your attribute.

Former Member
0 Kudos

Hi Baskaran,

Can you pls provide detail code, where i have to do the code changes .

Thanks in advance.

Thanks

Sandeep.

Former Member
0 Kudos

Sandeep,

You need to find out in your source where the check mandatory is done. You only have to comment it out. So check in the view, doBeforeaction,doafteraction methods.

Former Member
0 Kudos

Hi Baskaran ,

Thanks for ur reply ..

Eveen in that component they have not used cl_wd_dynamic_tool class for mandatory attributes

I want to share another thing with u that is

I am trying it in another way

with the following code which i have done in post exit is

let me explain u what i did

__first of all i got the child node of rootuielementcontaine

later

i get the childnode of container_left and assigned it to another class of ref cl_wd_uielemnent

now where i have struked is

*CALL METHOD LR_CHILD2->GET_CHILD

  • EXPORTING

  • ID = 'FORM_OF_ADDRESS_DROPDOWN'

    • INDEX =

  • RECEIVING

  • THE_CHILD = LR_C1.

what the error i am getting is

OBJECTS_OBJREF_NOT_ASSIGNED

Please correct me if there is any wrong inn the code ...

FORM_OF_ADDRESS_DROPDOWN--->ui element dropdown

r__ DATA lr_container TYPE REF TO cl_wd_uielement_container.

  • DATA lt_children TYPE cl_wd_uielement=>tt_uielement.

  • DATA lr_view TYPE REF TO if_wd_view.

  • DATA lr_child TYPE REF TO cl_wd_uielement.

  • DATA lr_child1 TYPE REF TO cl_wd_uielement.

    • DATA lr_child2 TYPE REF TO cl_wd_uielement.

  • data : LR_CON1 TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.

  • data : LR_CON2 TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.

          • SANDEEP

****************

  • lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

  • lt_children = lr_container->get_children( ).

*

  • CALL METHOD lr_container->get_child

  • EXPORTING

  • id = 'DATACONTAINER'

  • index = 1

  • RECEIVING

  • the_child = lr_CHILD.

.

  • .

  • LR_CON1 ?= LR_CHILD.

*

  • CALL METHOD LR_CON1->GET_CHILD

  • EXPORTING

  • ID = 'CONTAINER_LEFT'

    • INDEX = 1

  • RECEIVING

  • THE_CHILD = LR_CHILD1 .

  • DATA : LR_CHILD2 TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.

  • LR_CHILD2 ?= LR_CHILD1 .

*DATA : LR_C1 TYPE REF TO CL_WD_UIELEMENT.

*CALL METHOD LR_CHILD2->GET_CHILD

  • EXPORTING

  • ID = 'FORM_OF_ADDRESS_DROPDOWN'

    • INDEX =

  • RECEIVING

  • THE_CHILD = LR_C1.

  • .

*

*DATA : LR_DD TYPE REF TO CL_WD_DROPDOWN_BY_KEY .

*LR_DD ?= LR_C1 .

*

*CALL METHOD LR_DD->SET_STATE

  • EXPORTING

  • VALUE = '00'

  • .

*********

sandeep

saravanan_narayanan
Active Contributor
0 Kudos

Hello Sandeep,

to get the reference of the Drop down you dont need to navigate through the hierachy of UI elements. you can simply call view->get_element( 'FORM_OF_ADDRESS_DROPDOWN' )



DATA : LR_DD TYPE REF TO CL_WD_DROPDOWN_BY_KEY .
LR_DD ?= view->get_element( 'FORM_OF_ADDRESS_DROPDOWN' ).

CALL METHOD LR_DD->SET_STATE
 EXPORTING
 VALUE = '00'

BR, Saravanan

Former Member
0 Kudos

You code is not necessary to get the DDBI ui element from view.

I think saraa has already posted the code snippet for you.

Again : setting the state to false would only make the UI element with out the mandatory sign. Actual control might be in the WebDynpro abap or in the business logic methods/FM's might be checking if that attribute is filled. You need to find out from where this error is raised and in that place you have to make changes as well.