Parameter Name | Description |
IS_CTX | Details about the BO and Node for which node class is being called. This parameter is a structure. Some important attributes of the parameter are: BO_KEY - BO Key of the node ROOT_NODE_KEY - Node key of the BO. Please note, the key is not the node instance key, rather it's the node key. We can use this key to compare the node key of the BO using <constant_interface>=>SC_NODE-ROOT NODE_KEY - This is the node key of the BO. Please note, this is also not the instance of the node, rather the node key of the BO |
IT_KEY | These are the node instances for which the node class is being called. This values can be used to retrieve the data using IO_READ parameter. Refer to the below link for example: https://help.sap.com/viewer/aa7fc5c3c1524844b811735b9373252a/7.52.8/en-US/40a8d99985d640919f1c2344e9... |
IO_READ | Used to retrieve the data. Please use the above link for the example usage |
IO_MODIFY | Used to modify the node data. In our case, we will use it to default the value in the node instance. |
(Above screenshot is from BOBX)
Double click on the node class name been provide by you. If the class is not existing, you will get below pop-up, click on yes.
(We can see the required interface is implemented)
(Both the method from the interface can be seen)
DATA:
ls_root TYPE zras_d_root.
LOOP AT it_key INTO DATA(ls_key).
"Default values
ls_root-title = |Title Defaulted in Node Class|.
"Update default values
io_modify->update(
EXPORTING
iv_node = is_ctx-node_key " Node
iv_key = ls_key-key " Key
is_data = REF #( ls_root ) " Data
it_changed_fields = VALUE #( ( |TITLE| ) ) " List of Names (e.g. Fieldnames)
).
ENDLOOP.
(Image depicting the service manager interface which is used to call the node class)
*&---------------------------------------------------------------------*
*& Report ZRAS_DATA_NODE_CLASS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zras_call_node_class.
CLASS lcl_ras_data DEFINITION.
PUBLIC SECTION.
METHODS:
constructor,
create_new_root
IMPORTING im_s_root TYPE zras_s_root_d
RETURNING VALUE(rt_o_message) TYPE REF TO /bobf/if_frw_message.
PRIVATE SECTION.
DATA:
mo_smngr_ras TYPE REF TO /bobf/if_tra_service_manager,
mo_tmngr TYPE REF TO /bobf/if_tra_transaction_mgr.
ENDCLASS.
START-OF-SELECTION.
"Create object of local class
DATA(lo_ras_data) = NEW lcl_ras_data( ).
"Fill the node
DATA(lo_message) = lo_ras_data->create_new_root(
im_s_root = VALUE #(
status = '01'
type = 'WA_RAS'
is_simulated = abap_false
)
).
IF lo_message IS BOUND.
IF lo_message->check( ) EQ abap_true.
MESSAGE 'Creation failed' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
MESSAGE 'Creation successful' TYPE 'S'.
ENDIF.
ELSE.
MESSAGE 'Creation successful' TYPE 'S'.
ENDIF.
CLASS lcl_ras_data IMPLEMENTATION.
METHOD constructor.
"Get reference of the service manager
mo_smngr_ras = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( zif_risk_assessment_c=>sc_bo_key ).
"Get reference of transactional manager
mo_tmngr = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
ENDMETHOD.
METHOD create_new_root.
FREE rt_o_message.
DATA:
lt_root TYPE zras_t_root.
"Move corresponding values
DATA(ls_ras_root) = CORRESPONDING zras_d_root( im_s_root ).
"Get new UUID
ls_ras_root-db_key = /bobf/cl_frw_factory=>get_new_key( ).
APPEND CONV zras_s_root(
CORRESPONDING #(
ls_ras_root
MAPPING key = db_key
)
) TO lt_root.
"Retrive default value --> Point to keep in mind, here LT_ROOT is the table type of the COMBINED Structure
mo_smngr_ras->retrieve_default_node_values(
EXPORTING
iv_node_key = zif_risk_assessment_c=>sc_node-root " Node
CHANGING
ct_data = lt_root
).
LOOP AT lt_root INTO DATA(ls_root_dt).
ls_ras_root = CORRESPONDING #( ls_root_dt MAPPING db_key = key ).
"Assign value to modificationt table
DATA(lt_modif) = VALUE /bobf/t_frw_modification(
( node = zif_risk_assessment_c=>sc_node-root
change_mode = /bobf/if_frw_c=>sc_modify_create
key = ls_ras_root-db_key
data = REF #( ls_ras_root ) )
).
ENDLOOP.
"Modify the data
mo_smngr_ras->modify(
EXPORTING
it_modification = lt_modif " Changes
IMPORTING
eo_change = DATA(lo_change) " Interface of Change Object
eo_message = rt_o_message " Interface of Message Object
).
IF rt_o_message IS BOUND.
IF rt_o_message->check( ) EQ abap_true.
RETURN.
ENDIF.
ENDIF.
"Save data to data base
mo_tmngr->save(
IMPORTING
eo_message = rt_o_message
).
ENDMETHOD.
ENDCLASS.
Data in the database:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |