Skip to Content
author's profile photo Former Member
Former Member

Unable to save values in GENIL for newly created AET fields

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 ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 06, 2014 at 02:16 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 08:24 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Amit Singh

      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

  • Posted on Jan 04, 2014 at 06:00 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

      Capture.PNG (28.0 kB)

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.