I need to add a xStep node in the tree of a process order. I'm trying to do it through the CMX_XS* classes' methods, but I'm stuck with the if_cmx_xs_root->edit method.
The problem is that method calls a CO_BT* function module that checks a in-memory internal table, where my order is NOT because I'm not changing the order through standard transactions. I think it must exist a way to say the system I'm changing that order, but I cannot find it.
Up to now, my code looks like:
DATA: myfac TYPE REF TO if_cmx_xs_factory,
mylib TYPE REF TO if_cmx_xs_library,
mychange TYPE REF TO if_cmx_xs_change_object,
myroot TYPE REF TO if_cmx_xs_root,
mynode TYPE REF TO if_cmx_xs_node,
mycopy TYPE REF TO if_cmx_xs_node,
myex TYPE REF TO cx_cmx_xs_exception,
myerr TYPE string,
t_children TYPE cmx_xs_t_node.
myfac = cl_cmx_xs_system=>get_factory( ).
mylib = cl_cmx_xs_system=>get_library( ).
* Well, it seems we need another child, not the first one đŸ¤ª
TRY.
IF mychange IS INITIAL.
mychange = myfac->create_change_object_nonhist( ).
ENDIF.
CALL METHOD mylib->get_root_by_nid
EXPORTING
nid = <child>-parent_oid
change_object = mychange
RECEIVING
root = myroot.
CATCH cx_cmx_xs_exception INTO myex.
myerr = myex->if_message~get_text( ).
ENDTRY.
IF myerr IS INITIAL.
TRY.
CALL METHOD myroot->get_children
RECEIVING
children = t_children.
CATCH cx_cmx_xs_exception INTO myex.
myerr = myex->if_message~get_text( ).
ENDTRY.
IF myerr IS INITIAL.
READ TABLE t_children INTO mynode INDEX 3.
IF sy-subrc = 0.
TRY.
CALL METHOD mynode->get_copy
RECEIVING
result = mycopy.
CATCH cx_cmx_xs_exception INTO myex.
myerr = myex->if_message~get_text( ).
ENDTRY.
IF myerr IS INITIAL.
TRY.
myroot->edit( ).
myroot->append_child( mycopy ).
CATCH cx_cmx_xs_exception INTO myex.
myerr = myex->if_message~get_text( ).
ENDTRY.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
In the last TRY you can see the myroot->edit call, that triggers the excepcion message "Order xxxxx hass not been loaded."
I cannot get the message's information because it's not in the cx_cmx_xs_exception class (or I've not been able to find it yet).
Any hint would be appreciated. Thanks in advance,
Vic