Hi Shubhada,
The problem is that determinations are creating instances of some of the nodes. A determination is creating an instance of the REVISION node, but without the ROLE subnode instance—despite that the cardinality is 1:1…n. This results in the error Mandatory node ROLE missing.
The problem can be resolved by making two calls to the MODIFY method of the service manager. Create only the ROOT node instance with the first call, and the determinations will create additional node instances, including the REVISION node instance. Next get the key of the REVISION node instance, and use it to create an instance of the ROLE subnode by calling the MODIFY method again. Finally, commit the transaction by invoking the SAVE method of the transaction manager. Following is a code sample:
"Create the ROOT
CREATE DATA lr_s_root.
lr_s_root->key = /bobf/cl_frw_factory=>get_new_key( ).
lr_s_root->chm_nature = 'M'.
APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.
<ls_mod>-node = if_ehfnd_chm_c=>sc_node-root.
<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.
<ls_mod>-key = lr_s_root->key.
<ls_mod>-data = lr_s_root.
CALL METHOD me->mo_chm_bo->mo_svc_mngr->modify
EXPORTING
it_modification = lt_mod
IMPORTING
eo_change = lo_change
eo_message = lo_message.
FREE lt_mod.
"The REVISION node instance was created via a
"determination. Get its key; it's needed to
"create the ROLE node instance.
lt_change = lo_change->get_changes( ).
READ TABLE lt_change ASSIGNING <ls_change> INDEX 1.
<ls_change>-change_object->get_changes( IMPORTING et_change = lt_node_change ).
READ TABLE lt_node_change
WITH KEY key1 COMPONENTS node_key = if_ehfnd_chm_c=>sc_node-revision
ASSIGNING <ls_node_change>.
lv_rev_key = <ls_node_change>-key.
"Create the ROLE node instance; it's mandatory but was
"not created in a determination
CREATE DATA lr_s_role.
lr_s_role->key = /bobf/cl_frw_factory=>get_new_key( ).
lr_s_role->chemical_role = '1'.
APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.
<ls_mod>-node = if_ehfnd_chm_c=>sc_node-role.
<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.
<ls_mod>-source_node = if_ehfnd_chm_c=>sc_node-revision.
<ls_mod>-association =
if_ehfnd_chm_c=>sc_association-revision-role.
<ls_mod>-source_key = lv_rev_key.
<ls_mod>-key = lr_s_role->key.
<ls_mod>-data = lr_s_role.
CALL METHOD me->mo_chm_bo->mo_svc_mngr->modify
EXPORTING
it_modification = lt_mod
IMPORTING
eo_change = lo_change
eo_message = lo_message.
"Commit the transaction
CALL METHOD me->mo_chm_bo->mo_txn_mngr->save
IMPORTING
eo_message = lo_message
ev_rejected = lv_rejected.