10-10-2018 12:25 PM
Hi,
I have two independent BOs, which at the moment are not related to each other (there is no association defined), let's call them First and Second.
If I try to create an instance in Second through a simple ABAP program, I can perfectly do something like this and the entry in the database will be created:
transaction_manager =
/bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
service_manager =
/bobf/cl_tra_serv_mgr_factory=>get_service_manager(
zif_i_secondnode_c=>sc_bo_key ).
object_configuration =
/bobf/cl_frw_factory=>get_configuration(
zif_i_secondnode_c=>sc_bo_key ).
data: second_node type ref to z_combined_structure.
second_node->key = /bobf/cl_frw_factory=>get_new_key( ).
second_node->concept = 'C0017'.
second_node->date = '20181017'.
second_node->description = 'brief description for this item'.
second_node->cost = '9.00'.
APPEND VALUE /bobf/s_frw_modification(
node = zif_i_secondnode_c=>sc_node-zsecond_node
change_mode = /bobf/if_frw_c=>sc_modify_create
key = second_node->key
data = second_node ) TO mod_table.
service_manager->modify(
EXPORTING it_modification = mod_table
IMPORTING eo_change = DATA(change_object)
eo_message = DATA(messages) ).
IF change_object->has_failed_changes( ) = abap_false.
"This doesnt give any error when running from an ABAP program
"But from an action from FIRST_NODE, I get a dump
transaction_manager->save(
IMPORTING ev_rejected = DATA(was_rejected)
eo_message = messages ).
ENDIF.
However, running this same code in a BOPF action from my object First, I get a runtime error.
How can I achieve such a result? Storing instances in BOs inside the Action for another BO.
10-23-2018 12:45 PM
Finally I got it working,
The modification had to be done using the transaction manager rather than the service manager, like this:
transaction_manager->modify(EXPORTING it_modification =
VALUE #( (node = zif_i_secondnode_c=>sc_node-zsecond_node
change_mode = /bobf/if_frw_c=>sc_modify_create
data = second_node) )
There was no need to call the SAVE change from the transaction manager either
10-11-2018 9:29 AM
Did you check, what happens if you dont do save-call from transactionmanager in action of first node?
How is the bopf action called? There should be the save-call and not inside the action.
10-16-2018 9:44 AM
Hi Christian,
Thanks for your reply!
If I don't do the save call, nothing happens. The entry is not saved in second_node.
The action is called CLOSE, I didn't understand your last sentece, did you mean the transaction_manager->save( ) call should not happen inside the CLOSE action from FIRST_NODE?
10-19-2018 9:06 AM
My question was mistakable...
Where is the close-action called? Do you call the action yourself with a servicemanager or is it called by any framework? I guess the save-call should happen after the action is called.
10-23-2018 12:41 PM
10-23-2018 12:45 PM
Finally I got it working,
The modification had to be done using the transaction manager rather than the service manager, like this:
transaction_manager->modify(EXPORTING it_modification =
VALUE #( (node = zif_i_secondnode_c=>sc_node-zsecond_node
change_mode = /bobf/if_frw_c=>sc_modify_create
data = second_node) )
There was no need to call the SAVE change from the transaction manager either