on 01-03-2014 6:41 AM
Dear Experts,
we have requirement where in we have created few AET fields in BTADMINI. now upon saving my order i have written a piece of code in EH_ONSAVE where in i am writting the values for these fields using set_property. I can see the new values in entity but these values are not passed on to genil and i dont see the same when i check in genil_bol_browser. . The attaribute of these field and entity are changebale. your help will be appreciated.below is the code that i have used.
data: lr_core type ref to cl_crm_bol_core,
lr_query type ref to CL_CRM_BOL_QUERY_SERVICE,
LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,
LR_ENTITY TYPE REF TO cl_crm_bol_entity,
LV_TRANSACTION TYPE REF TO if_bol_transaction_context.
DATA: lt_parameters TYPE crmt_name_value_pair_tab,
ls_parameters TYPE crmt_name_value_pair.
* Get the BOL Core instance
lr_core = cl_Crm_bol_core=>get_instance( ).
* Load the component set
LR_CORE->LOAD_COMPONENT_SET( 'BT' ).
* Create the query instance by passing the search object name
lr_query = CL_CRM_BOL_QUERY_SERVICE=>get_instance(
iv_query_name = 'BTQuery1O' ).
* Add the selection parameters
ls_parameters-name = 'OBJECT_ID'.
ls_parameters-value = LV_OBJID.
APPEND ls_parameters TO lt_parameters.
CALL METHOD lr_query->set_query_parameters
EXPORTING
it_parameters = lt_parameters
iv_convert = abap_true.
*Get the result list
LR_RESULT = LR_QUERY->GET_QUERY_RESULT( ).
* Get the first object(entity) in the result list
LR_ENTITY ?= LR_RESULT->get_current( ).
LR_ENTITY ?= LR_ENTITY->get_related_entity( iv_relation_name = 'BTOrderHeader' ).
LR_ENTITY ?= LR_ENTITY->get_related_entity( iv_relation_name = 'BTHeaderItemsExt').
LR_ENTITY ?= LR_ENTITY->get_related_entity( iv_relation_name = 'BTOrderItemAll').
* Lock and modify the property
if LR_ENTITY->lock( ) = if_genil_Boolean=>true.
*Change the fields
LR_ENTITY->set_property( iv_attr_name = 'ZZFLD00000Y' iv_value = LV_OBJID ).
LR_ENTITY->set_property( iv_attr_name = 'ZZFLD00000Z' iv_value = LV_OBJID ).
*Core
LR_CORE->modify( ).
LV_TRANSACTION = lr_core->get_transaction( ).
*LV_TRANSACTION = LR_ENTITY->get_transaction( ).
LV_TRANSACTION->save( ).
LV_TRANSACTION->commit( ).
endif
Thanks & Regards,
Ameet
PS : the same code is working in my own system but in the client system it is not working. Is there any additional setting ?
Hi Ameet,
Try methods activate_sending( ) and switch_to_change_mode( ).
Before setting property, call switch_to_change_mode( ). After this call method activate_sending( ).
You can also try calling method reread( ) after modify( ).
Hope this helps.
Regards,
Pallavi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you redefined EH_ONSAVE ? If yes then you haven't called super->save method (also then you would not need to expliciltly call save ).
~Kavindra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kavindra,
Its not working even if i write the code as a separate report. then also data is not getting saved. As i mentioned earlier I am not able to change the values in genil_bol_browser in edit mode. probably if we get this sorted i think it would work. but i am not sure how.
Thanks & Regards,
Ameet
Hi Ameet ,
I think the problem occurs because the fields are not editable. Try this
if lv_entity->is_Changeable = abap_true ( ). This statement should return false in your case.
lv_entity->set_property_as_string( ...... ).
endif.
If the property is not changeable , then either the property is set
a) GET_I_<attr_name>
b) Maintained in the GENIL class.
And since the field is added through AET , GET_I_<attr_name> would not help. Hence I guess the properties returned from GENIL are causing the issue. I am surprised how this can happen.
Just Try this iv_display_mode_support = abap_true during the BOL core startup. This may help.
~Kavindra
Hi Amit,
In the code You have used BTOrderItemAll which is having 1:N relationship, so Get Related Entity will always returns the first entity from Collection.
Try below code.
data:lr_coll type ref to if_bol_bo_col.
lr_coll ?= lr_entity->get_related_enitites( iv_relation_name = 'BTOrderItemAll' ).
lr_entity ?= lr_coll->get_first( ).
while lr_entity is bound.
LR_ENTITY->set_property( iv_attr_name = 'ZZFLD00000Y' iv_value = LV_OBJID ).
LR_ENTITY->set_property( iv_attr_name = 'ZZFLD00000Z' iv_value = LV_OBJID ).
lr_entity ?= lr_coll->get_next( ).
endwhile.
As you are writing this logic in EH_ONSAVE,
LV_TRANSACTION->commit( ) is not required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Tejaswini,
Thanks for the reply.
I did check and changed the code as per the one that you have sent. However the issue still remains. I just want to add that the field I want to update is an AET field.
I can see the value getting changed in lr_entity but the same is not getting flushed to genil.
methods check_save_possible( ) and check_save_needed( ) all return value 'true'.
Thanks & Regards,
Ameet Jha
Hello Ameet,
You have written below code after setting field values in entity:--
LV_TRANSACTION = lr_core->get_transaction( ). // it is not correct.
*LV_TRANSACTION = LR_ENTITY->get_transaction( ).
LV_TRANSACTION->save( ).
LV_TRANSACTION->commit( ).
it should be ,
lr_core->modify( ). // this method of bol core is delegated to MODIFY method of relevant genil component.
lv_transaction = lr_entitty->get_transaction( ).
check lr_transaction->check_save_needed eq abap_true.
check lr_transaction->check_save_possible eq abap_true.
if lr_transaction->save( ) = abap_true. // explicit call of save method of transaction context is forwarded to the genIL. system reads transaction context and calls SAVE method of genil component.
lr_transaction->commit( ).
else.
lr_transaction->rollback( ).
endif.
Try it out.
Thanks,
Amit
Hi Amit,
It is set as "Not Defined".
I have observed one thing that in the entity the attribute ref becomes initial after calling LR_CORE->modify( ). I am not sure why this should happen.
Just to add that i checked genil_bol_browser in change mode and there also i am not able to save the data in my custom field. any idea on how to deal with this ?
Thanks & Regards,
Ameet
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.