on 06-02-2011 1:00 PM
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
I have the same problem. How can I modify the property in BOL? Do you find a solution?
Regards, Roberto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.