cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set new values in Entity

Former Member
0 Kudos

Hi Experts,

I am trying to change an entity from readonly to changeable and set property of an attribute. But, i am not successful. In the below "If ME->IS_CHAN......" condition, the second condition is not successful and it doesnot let the entity to change. I am not sure, from where the data is getting filled for "ME->CONTAINER_PROXY->DATA_REF->ATTRIBUTE_REF". Can someone please point me the solution ?

Thanks in advance.


method IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTY .
  data: LV_IDX       type CRMT_IDX,
        LV_PROPS_OBJ type ref to IF_GENIL_OBJ_ATTR_PROPERTIES.
  field-symbols: <DATA>  type any,
                 <VALUE> type any.

  MAKE_VALID_STATE( ).

  assign ME->CONTAINER_PROXY->DATA_REF->ATTRIBUTE_REF->* to <DATA>.
  assign component IV_ATTR_NAME of structure <DATA> to <VALUE>.
  if SY-SUBRC = 0.
*   check changeability of property
    LV_PROPS_OBJ = ME->CONTAINER_PROXY->GET_ATTR_PROPS_OBJ( ).
    try.
        LV_IDX = OBJECT_MODEL->GET_ATTR_IDX_BY_NAME(
                             IV_OBJECT_NAME = ME->MY_INSTANCE_KEY->OBJECT_NAME
                             IV_ATTR_NAME   = IV_ATTR_NAME ).


        if ME->IS_CHANGEABLE( ) = ABAP_TRUE and
           LV_PROPS_OBJ->GET_PROPERTY_BY_IDX( LV_IDX ) ne IF_GENIL_OBJ_ATTR_PROPERTIES=>READ_ONLY.

          if <VALUE> ne IV_VALUE.
            if ME->MY_MANAGER_ENTRY->DELTA_FLAG is initial.
*             first 'change' -> proof that entity is locked
              if ME->MY_MANAGER_ENTRY->LOCKED = FALSE.
                if ME->LOCK( ) = FALSE.
                  return.
                endif.
              endif.

Edited by: Gaurav Subramaniam on Jun 2, 2011 5:30 PM

Edited by: Gaurav Subramaniam on Jun 2, 2011 5:31 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I have the same problem. How can I modify the property in BOL? Do you find a solution?

Regards, Roberto

ratna_rajeshp
Active Participant
0 Kudos

Hi,

We cannot set the values of an attribute if it readonly at GENIL level .

So We if it is only for the Display in WEBUI We need to write the code in GETTER Method of the field .

If you want to update the underlying database also ,find the appropriate table where the data get updated and we need to update the database table directly.

Regards,

Ratna Rajesh.

Edited by: Ratna Rajesh .P on Aug 6, 2011 1:14 PM

ajaya_kumar
Active Participant
0 Kudos

Hi Gaurav,

Before calling the set_property() method, you should call switch_to_change_mode( ) method for example:


data:  lr_entity  type ref to cl_crm_bol_entity.
lr_entity ?= me->typed_context->btadminh->collection_wrapper->get_current( ).
lr_entity->switch_to_change_mode( ).

Cheers

Ajay

Former Member
0 Kudos

Hi Ajay,

Yes, the code is already there as you mentioned. But, in the above mentioned standard code, within the 'if' condition, only "ME->IS_CHANGEABLE( ) = ABAP_TRUE" is returning successfully. The other part of the 'if' condition is failing. Any idea ?

Thanks,

Gaurav.

ajaya_kumar
Active Participant
0 Kudos

Ok.

Then check and puta a break point in get_i_xxx() method for the atrribue. This method might be setting the attribute to read only.

-Ajay

Former Member
0 Kudos

Hi Ajay/All,

The attribute doesnot have any Get/Set methods. It is an table node. Any idea about the flow of standard code and where does it usually gets the values from ? Any SPRO settings needs to be checked ?

Best Regards,

Gaurav.

Former Member
0 Kudos

HI Gaurav,

The 2nd condition which is unsuccessful indiactes that your attribute has been marked as read only in your BOL model.

Thus ,the attribute property is being fetched as read only.

IN order to make it readable ,you would have to change the porperty of your attribute in your BOL genil model.

Suvidha

Former Member
0 Kudos

Hi Suvidha/All,

Can you please let me know, how to change the attribute in the BOL genil model or after we receive back ? Any specific methods to be checked/changed ?

Thanks,

Gaurav.

Former Member
0 Kudos

Hi Gaurav,

As already mentioned your entity is set to READ-ONLY mode at GenIL level. Hence, the following line returns READ-ONLY :-


LV_PROPS_OBJ->GET_PROPERTY_BY_IDX( LV_IDX ) ne IF_GENIL_OBJ_ATTR_PROPERTIES=>READ_ONLY.

This is set at GenIL level in the GenIL class. Hence, you'll have to find the GenIL class and look for method - SET_ATTR_PROPERTIES. Here you will find code that sets mode (changeable / readonly) each attribute.

Follow below steps :-

- Create a Zclass and inherit it from the above class.

- Redefine the above method.

- Set attributes to changeable mode.

Here is a sample code :-


  DATA: lv_attr_props       TYPE REF TO if_genil_obj_attr_properties.

* First get the property object
  lv_attr_props = iv_object->get_attr_props_obj( ).

  lv_attr_props->set_property_by_name( iv_name  = 'Field1'
                                       iv_value = if_genil_obj_attr_properties=>changeable ).
  lv_attr_props->set_property_by_name( iv_name  = 'Field2'
                                       iv_value = if_genil_obj_attr_properties=>changeable ).

Alternatively you can set attribute properties for all fields at once :-


* set property 'changeable' for all attributes
  lv_attr_props->set_all_properties( if_genil_obj_attr_properties=>changeable ).

Thanks,

Ashish