Skip to Content
0
Former Member
Aug 25, 2005 at 12:36 PM

Has anyone ever modified an Entity created with CREATE_RELATED_ENTITY and

288 Views

Has anyone ever modified an Entity created with CREATE_RELATED_ENTITY and saved that modification to the data base?

Could you please give me a tip as to how to do it?

I have been following the BOL Programming Cookbook (page 110) but my program does not write to the data base.

(In this case I am trying to create a FirstLevelComponent to an existing Ibase. I have also tried creating a SubLevelComponent to an existing FirstLevelComponent with the same apparent success in the debugger but the same lack of success saving to the data base.)

My steps are essentially:

· Access the top level entity (for example Root Ibase);

· Create a Related Entity at the next lower level (for example FirstLevelComponent of an IBase);

· Fill the properties of that Entity with my data;

. Save.

I do the things I understand I should do:

1) data: BOL_CORE type ref to cl_crm_bol_core.

BOL_CORE = cl_crm_bol_core=>get_instance( ).

BOL_CORE->start_up('ALL').

2) Access my Root:

data: lv_query type ref to cl_crm_bol_query_service.

lv_query = cl_crm_bol_query_service=>get_instance( ‘IBIBaseToAttrib’ ).

lv_query->set_property( iv_attr_name = 'IBASE' iv_value = '000000000000010932' ).

data: li_entity_col type ref to if_bol_entity_col.

li_entity_col = lv_query->get_query_result( ).

data: lr_entity_col_current type ref to cl_crm_bol_entity.

call method li_entity_col->get_current

RECEIVING

rv_result = lr_entity_col_current.

3) Create an Entity related to that Root:

data: lr_entity type ref to cl_crm_bol_entity.

call method lr_entity_col_current->CREATE_RELATED_ENTITY

EXPORTING

iv_relation_name = 'FirstLevelComponent'

RECEIVING

rv_result = lr_entity.

4) Fill that entity with data:

call method lr_entity->IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTIES ...

call method lr_entity->IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTY ... ...

5) After this things look good in the debugger – my entitity has the data structure required, filled with the data I just set.

6) Save thus or similarly, essentially MODIFY SAVE COMMIT:

I then try to save at this non-root level, without API factory call to Root level, because I am adding an entity below that level in an existing Root (Ibase).

li_transaction ?= BOL_CORE->GET_transaction( ).

check li_transaction is bound."if_bol_transaction_context

  • CORE MODIFY

BOL_CORE->MODIFY( ).

if li_transaction->check_save_possible( ) eq abap_true.

  • SAVE

if li_transaction->save( ) eq abap_true.

  • COMMIT

li_transaction->commit( ).

else.

  • ROLLBACK

li_transaction->rollback( ).

endif.

endif.

Everything runs without error but nothing is saved.

Any tips or thoughts would be very very much appreciated.

Kind regards

David Lawn