Skip to Content
0
Jan 12, 2015 at 02:08 PM

BOPF EHSS_INCIDENT CREATE

228 Views

Hi All,

I am working on BOPF- EHHSS_INCIDENT. I have a question on the Node PERSON INVOLVED.

There is one node called "Persons involved" and another node called "Person Role". I am try to create a Person Involved with role assigning to that involved person, its getting created with single Involved person (i.e is reporting person) record. but I need to create an other Involved person (i.e Injured person) under the same ROOT node with Role, that means two Involved person under the same root node.So how to achieve this and here am attaching my code.

Please help me.

REPORT zehs_report_incident.

*&---------------------------------------------------------------------*

*& Selection Screen Definition *

*&---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_cat TYPE ehhss_inc_category_code,

title TYPE ehhss_inc_title,

plant TYPE ehfnd_plant_id.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS:

inj_fm TYPE ehhss_per_inv_first_name,

inj_lm TYPE ehfnd_party_last_name,

inj_tel TYPE ehhss_per_inv_telephone_number,

inj_org TYPE ehhss_per_inv_comp_org_unit,

inj_addr TYPE ehhss_per_inv_addr,

inj_eml TYPE ehhss_per_inv_email.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.

PARAMETERS:

wt_fm TYPE ehhss_per_inv_first_name,

wt_lm TYPE ehfnd_party_last_name,

wt_tel TYPE ehhss_per_inv_telephone_number,

wt_org TYPE ehhss_per_inv_comp_org_unit,

wt_addr TYPE ehhss_per_inv_addr,

wt_eml TYPE ehhss_per_inv_email.

SELECTION-SCREEN END OF BLOCK b3.

*&---------------------------------------------------------------------*

*& Local Class Definitions *

*&---------------------------------------------------------------------*

CLASS lcl_output DEFINITION CREATE PRIVATE.

PUBLIC SECTION.

CLASS-METHODS:

create_category IMPORTING iv_category_id

TYPE ehhss_inc_category_code.

PRIVATE SECTION.

"Instance Attributes:

DATA mo_txn_mngr TYPE REF TO /bobf/if_tra_transaction_mgr.

DATA mo_svc_mngr TYPE REF TO /bobf/if_tra_service_manager.

DATA mo_bo_conf TYPE REF TO /bobf/if_frw_configuration.

"Instance Methods:

METHODS:

constructor RAISING /bobf/cx_frw,

get_category_for_id IMPORTING iv_category_id

TYPE ehhss_inc_category_code

RETURNING VALUE(rv_category_key)

TYPE /bobf/conf_key

RAISING /bobf/cx_frw,

get_node_table IMPORTING iv_key TYPE /bobf/conf_key

iv_node_key TYPE /bobf/obm_node_key

iv_edit_mode TYPE /bobf/conf_edit_mode DEFAULT /bobf/if_conf_c=>sc_edit_read_only

RETURNING VALUE(rr_data) TYPE REF TO data

RAISING /bobf/cx_frw,

get_node_row IMPORTING iv_key TYPE /bobf/conf_key

iv_node_key TYPE /bobf/obm_node_key

iv_edit_mode TYPE /bobf/conf_edit_mode DEFAULT /bobf/if_conf_c=>sc_edit_read_only

iv_index TYPE i DEFAULT 1

RETURNING VALUE(rr_data) TYPE REF TO data

RAISING /bobf/cx_frw,

get_node_table_by_assoc IMPORTING iv_key TYPE /bobf/conf_key

iv_node_key TYPE /bobf/obm_node_key

iv_assoc_key TYPE /bobf/obm_assoc_key

iv_edit_mode TYPE /bobf/conf_edit_mode DEFAULT /bobf/if_conf_c=>sc_edit_read_only

RETURNING VALUE(rr_data) TYPE REF TO data

RAISING /bobf/cx_frw,

get_node_row_by_assoc IMPORTING iv_key TYPE /bobf/conf_key

iv_node_key TYPE /bobf/obm_node_key

iv_assoc_key TYPE /bobf/obm_assoc_key

iv_edit_mode TYPE /bobf/conf_edit_mode DEFAULT /bobf/if_conf_c=>sc_edit_read_only

iv_index TYPE i DEFAULT 1

RETURNING VALUE(rr_data) TYPE REF TO data

RAISING /bobf/cx_frw,

display_messages IMPORTING io_message

TYPE REF TO /bobf/if_frw_message.

ENDCLASS.

CLASS lcl_output IMPLEMENTATION.

METHOD constructor.

"Obtain a reference to the BOPF transaction manager:

me->mo_txn_mngr =

/bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).

"Obtain a reference to the BOPF service manager:

me->mo_svc_mngr =

/bobf/cl_tra_serv_mgr_factory=>get_service_manager(

if_ehhss_inc_c=>sc_bo_key ).

"Access the metadata for the EHHSS_INCIDENT Incident BO:

me->mo_bo_conf =

/bobf/cl_frw_factory=>get_configuration(

if_ehhss_inc_c=>sc_bo_key ).

ENDMETHOD. " METHOD constructor

METHOD create_category.

"Method-Local Data Declarations:

DATA lo_driver TYPE REF TO lcl_output.

DATA lt_mod TYPE /bobf/t_frw_modification.

DATA lo_change TYPE REF TO /bobf/if_tra_change.

DATA lo_message TYPE REF TO /bobf/if_frw_message.

DATA lv_rejected TYPE boole_d.

DATA lx_bopf_ex TYPE REF TO /bobf/cx_frw.

DATA lv_err_msg TYPE string.

DATA lr_s_basic TYPE REF TO ehhsss_inc_basic_info_all.

DATA lr_s_root TYPE REF TO ehhsss_inc_root.

DATA lr_s_root2 TYPE REF TO ehhsss_inc_root.

DATA lr_s_per_inv TYPE REF TO ehhsss_inc_person_involved.

DATA lr_s_per_inv2 TYPE REF TO ehhsss_inc_person_involved.

DATA lr_s_per_role TYPE REF TO ehhsss_inc_person_role.

DATA lr_s_per_role2 TYPE REF TO ehhsss_inc_person_role.

DATA lr_s_per_inj TYPE REF TO ehhsss_inc_person_initial.

DATA lr_s_per_with TYPE REF TO ehhsss_inc_person_initial.

DATA lr_s_group TYPE REF TO EHHSSS_INC_GROUP.

TYPES: BEGIN OF tab_type,

para TYPE string,

dobj TYPE string,

END OF tab_type.

* Declaring the work variables.......................

DATA: id TYPE c LENGTH 10,

text1 TYPE string,

text2 TYPE string,

text3 TYPE string,

line TYPE tab_type,

itab TYPE STANDARD TABLE OF tab_type.

DATA : timestamp TYPE tzonref-tstamps,

time TYPE sy-uzeit,

date TYPE sy-datum.

FIELD-SYMBOLS:

<ls_mod> LIKE LINE OF lt_mod.

* The following function module is used to convert the

* time and date into GMT timestamp

CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'

EXPORTING

i_datlo = sy-datum

i_timlo = sy-uzeit

i_tzone = sy-zonlo

IMPORTING

e_timestamp = timestamp.

"Use the BOPF API to create a new category record:

TRY.

"Instantiate the driver class:

CREATE OBJECT lo_driver.

"Build the ROOT node:

CREATE DATA lr_s_root.

lr_s_root->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_root->category = iv_category_id.

lr_s_root->status = '01'.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_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.

"Build the BASIC_INFO_ALL node:

CREATE DATA lr_s_basic.

lr_s_basic->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_basic->title = title.

lr_s_basic->plant_id = plant.

lr_s_basic->start_timestamp = timestamp.

lr_s_basic->start_time_zone = sy-zonlo.

lr_s_basic->end_time_zone = sy-zonlo.

lr_s_basic->rep_time_zone = sy-zonlo.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-basic_info_all.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-root.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-root-basic_info_all.

<ls_mod>-source_key = lr_s_root->key.

<ls_mod>-key = lr_s_basic->key.

<ls_mod>-data = lr_s_basic.

"Build the GROUP node:

create data lr_s_group.

lr_s_group->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_group->DATETIME_CR = timestamp.

lr_s_group->USER_ID_CR = sy-uname.

lr_s_group->DATETIME_CH = timestamp.

lr_s_group->USER_ID_CH = sy-uname.

lr_s_group->NM_GROUP = 'EHHSS_IGR_OCC_INC'. "Injury / Illness ------ " can be change later

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-GROUP.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-root.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-root-GROUP.

<ls_mod>-source_key = lr_s_root->key.

<ls_mod>-key = lr_s_group->key.

<ls_mod>-data = lr_s_group.

clear sy-index.

do 2 times.

if sy-index = 1.

****First Involved Person

"Create the lr_s_per_inv node: person involved

CREATE DATA lr_s_per_inv.

lr_s_per_inv->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_inv->id = sy-uname.

lr_s_per_inv->full_name = sy-uname.

* lr_s_per_inv->roles_desc = 'Reporting Person'.

* lr_s_per_inv->roles_short_desc = 'Reporting Person'.

* lr_s_per_inv->full_name_disp = sy-uname.

* lr_s_per_inv->role_sort_code = 'EHHSS_PR_REPORT_PER'. "Reporting person

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-root.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-root-person_involved.

<ls_mod>-source_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_inv->key.

<ls_mod>-data = lr_s_per_inv.

"Create the lr_s_per_role node: Involved PERSON_ROLE

CREATE DATA lr_s_per_role.

lr_s_per_role->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_role->role = 'EHHSS_PR_REPORT_PER'.

lr_s_per_role->role_desc = 'Reporting Person'.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_role.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-person_involved-person_role.

<ls_mod>-source_key = lr_s_per_inv->key.

<ls_mod>-root_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_role->key.

<ls_mod>-data = lr_s_per_role.

*************************

else.

****Second Involved Person

"Create the lr_s_per_inv node: person involved

* lr_s_root = get_subnode_by_key( iv_assoc_key = if_ehhss_inc_c=>sc_association-root-basic_info_all ).

CREATE DATA lr_s_per_inv2.

lr_s_per_inv2->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_inv2->id = sy-uname.

* lr_s_per_inv->full_name = sy-uname.

* lr_s_per_inv->roles_desc = 'Reporting Person'.

* lr_s_per_inv->roles_short_desc = 'Reporting Person'.

* lr_s_per_inv->full_name_disp = sy-uname.

* lr_s_per_inv->role_sort_code = 'EHHSS_PR_REPORT_PER'. "Reporting person

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-root.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-root-person_involved.

<ls_mod>-source_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_inv2->key.

<ls_mod>-data = lr_s_per_inv2.

*

"Create the lr_s_per_role node: Involved PERSON_ROLE 2

CREATE DATA lr_s_per_role2.

lr_s_per_role2->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_role2->role = 'EHHSS_PR_INJURED_PER'.

lr_s_per_role2->role_desc = 'Injured Person'.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_role.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-person_involved-person_role.

<ls_mod>-source_key = lr_s_per_inv2->key. "lr_s_per_inv->key.

<ls_mod>-root_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_role2->key.

<ls_mod>-data = lr_s_per_role2.

************************

"Create the lr_s_per_inj node: Injured person initial

CREATE DATA lr_s_per_inj.

lr_s_per_inj->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_inj->first_name = inj_fm.

lr_s_per_inj->last_name = inj_lm.

lr_s_per_inj->telephone_number = inj_tel.

lr_s_per_inj->comp_org_unit = inj_org.

lr_s_per_inj->addr = inj_addr.

lr_s_per_inj->email = inj_eml.

* else.

* lr_s_per_inJ->FIRST_NAME = wt_FM.

* lr_s_per_inJ->LAST_NAME = wt_LM.

* lr_s_per_inJ->TELEPHONE_NUMBER = wt_TEL.

* lr_s_per_inJ->COMP_ORG_UNIT = wt_ORG.

* lr_s_per_inJ->ADDR = wt_ADDR.

* lr_s_per_inJ->EMAIL = wt_EML.

* endif.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_initial.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-person_involved-person_initial.

<ls_mod>-source_key = lr_s_per_inv->key.

<ls_mod>-root_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_inj->key.

<ls_mod>-data = lr_s_per_inj.

"Create the lr_s_per_role node: Injured PERSON_ROLE

CREATE DATA lr_s_per_role.

lr_s_per_role->key = /bobf/cl_frw_factory=>get_new_key( ).

lr_s_per_role->role = 'EHHSS_PR_INJURED_PER'.

lr_s_per_role->role_desc = 'Injured Person'.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = if_ehhss_inc_c=>sc_node-person_role.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = if_ehhss_inc_c=>sc_node-person_involved.

<ls_mod>-association = if_ehhss_inc_c=>sc_association-person_involved-person_role.

<ls_mod>-source_key = lr_s_per_inv->key. "lr_s_per_inv->key.

<ls_mod>-root_key = lr_s_root->key.

<ls_mod>-key = lr_s_per_role->key.

<ls_mod>-data = lr_s_per_role.

endif.

enddo.

"Create the category record:

CALL METHOD lo_driver->mo_svc_mngr->modify

EXPORTING

it_modification = lt_mod

IMPORTING

eo_change = lo_change

eo_message = lo_message.

"Check for errors:

IF lo_message IS BOUND.

IF lo_message->check( ) EQ abap_true.

lo_driver->display_messages( lo_message ).

RETURN.

ENDIF.

ENDIF.

"Apply the transactional changes:

CALL METHOD lo_driver->mo_txn_mngr->save

IMPORTING

eo_message = lo_message

ev_rejected = lv_rejected.

IF lv_rejected EQ abap_true.

lo_driver->display_messages( lo_message ).

RETURN.

ENDIF.

***Get the Incident ID number

types : begin of ty_root,

id_num type EHHSS_INC_ID,

end of ty_root.

data: it_root type standard table of ty_root,

wa_root type ty_root.

data: w_lines type sy-tfill.

DATA: ID_NUM TYPE EHHSS_INC_ID.

select ID from EHHSSD_INC_ROOT into table it_root.

describe table it_root lines w_lines.

read table it_root into wa_root index w_lines.

IF sy-subrc = 0.

ID_NUM = wa_root-id_num.

SHIFT ID_NUM LEFT DELETING LEADING '0'.

ENDIF.

**Exporting the message to Memory id

text1 = 'Incident'.

text2 = id_num.

text3 = 'reported; responsible incident manager notified'.

line-para = 'P1'.

line-dobj = 'TEXT1'.

APPEND line TO itab.

line-para = 'P2'.

line-dobj = 'TEXT2'.

APPEND line TO itab.

line-para = 'P3'.

line-dobj = 'TEXT3'.

APPEND line TO itab.

EXPORT (itab) TO MEMORY ID id.

"If we get to here, then the operation was successful:

WRITE: / 'Incident', ID_NUM, 'created successfully.'.

CATCH /bobf/cx_frw INTO lx_bopf_ex.

lv_err_msg = lx_bopf_ex->get_text( ).

WRITE: / lv_err_msg.

ENDTRY.

ENDMETHOD. " METHOD create_category

METHOD get_category_for_id.

"Method-Local Data Declarations:

DATA lo_driver TYPE REF TO lcl_output.

DATA lt_parameters TYPE /bobf/t_frw_query_selparam.

DATA lt_category_keys TYPE /bobf/t_frw_key.

DATA lx_bopf_ex TYPE REF TO /bobf/cx_frw.

DATA lv_err_msg TYPE string.

FIELD-SYMBOLS <ls_parameter> LIKE LINE OF lt_parameters.

FIELD-SYMBOLS <ls_category_key> LIKE LINE OF lt_category_keys.

"Instantiate the test driver class:

CREATE OBJECT lo_driver.

"Though we could conceivably lookup the category using an SQL query,

"the preferred method of selection is a BOPF query:

APPEND INITIAL LINE TO lt_parameters ASSIGNING <ls_parameter>.

* <ls_parameter>-attribute_name = IF_EHHSS_INC_C=>sc_query_attribute-root-select_by_attributes-category_id.

* <ls_parameter>-sign = 'I'.

* <ls_parameter>-option = 'EQ'.

* <ls_parameter>-low = iv_category_id.

* CALL METHOD lo_driver->mo_svc_mngr->query

* EXPORTING

* iv_query_key = IF_EHHSS_INC_C=>sc_query-root-select_by_attributes

* it_selection_parameters = lt_parameters

* IMPORTING

* et_key = lt_category_keys.

"Return the matching category's KEY value:

READ TABLE lt_category_keys INDEX 1 ASSIGNING <ls_category_key>.

IF sy-subrc EQ 0.

rv_category_key = <ls_category_key>-key.

ENDIF.

ENDMETHOD. " METHOD get_category_for_id

METHOD get_node_table.

"Method-Local Data Declarations:

DATA lt_key TYPE /bobf/t_frw_key.

DATA ls_node_conf TYPE /bobf/s_confro_node.

DATA lo_change TYPE REF TO /bobf/if_tra_change.

DATA lo_message TYPE REF TO /bobf/if_frw_message.

FIELD-SYMBOLS <ls_key> LIKE LINE OF lt_key.

FIELD-SYMBOLS <lt_data> TYPE INDEX TABLE.

"Lookup the node's configuration:

CALL METHOD mo_bo_conf->get_node

EXPORTING

iv_node_key = iv_node_key

IMPORTING

es_node = ls_node_conf.

"Use the node configuration metadata to create the result table:

CREATE DATA rr_data TYPE (ls_node_conf-data_table_type).

ASSIGN rr_data->* TO <lt_data>.

"Retrieve the target node:

APPEND INITIAL LINE TO lt_key ASSIGNING <ls_key>.

<ls_key>-key = iv_key.

CALL METHOD mo_svc_mngr->retrieve

EXPORTING

iv_node_key = iv_node_key

it_key = lt_key

IMPORTING

eo_message = lo_message

eo_change = lo_change

et_data = <lt_data>.

"Check the results:

IF lo_message IS BOUND.

IF lo_message->check( ) EQ abap_true.

display_messages( lo_message ).

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

ENDIF.

ENDMETHOD. " METHOD get_node_table

METHOD get_node_row.

"Method-Local Data Declarations:

DATA lr_t_data TYPE REF TO data.

FIELD-SYMBOLS <lt_data> TYPE INDEX TABLE.

FIELD-SYMBOLS <ls_row> TYPE any.

"Lookup the node data:

lr_t_data =

get_node_table( iv_key = iv_key

iv_node_key = iv_node_key

iv_edit_mode = iv_edit_mode ).

IF lr_t_data IS NOT BOUND.

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

"Try to pull the record at the specified index:

ASSIGN lr_t_data->* TO <lt_data>.

READ TABLE <lt_data> INDEX iv_index ASSIGNING <ls_row>.

IF sy-subrc EQ 0.

GET REFERENCE OF <ls_row> INTO rr_data.

ELSE.

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

ENDMETHOD. " METHOD get_node_row

METHOD get_node_table_by_assoc.

"Method-Local Data Declarations:

DATA lt_key TYPE /bobf/t_frw_key.

DATA ls_node_conf TYPE /bobf/s_confro_node.

DATA ls_association TYPE /bobf/s_confro_assoc.

DATA lo_change TYPE REF TO /bobf/if_tra_change.

DATA lo_message TYPE REF TO /bobf/if_frw_message.

FIELD-SYMBOLS <ls_key> LIKE LINE OF lt_key.

FIELD-SYMBOLS <lt_data> TYPE INDEX TABLE.

"Lookup the association metadata to find out more

"information about the target sub-node:

CALL METHOD mo_bo_conf->get_assoc

EXPORTING

iv_assoc_key = iv_assoc_key

iv_node_key = iv_node_key

IMPORTING

es_assoc = ls_association.

IF ls_association-target_node IS NOT BOUND.

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

ls_node_conf = ls_association-target_node->*.

"Use the node configuration metadata to create the result table:

CREATE DATA rr_data TYPE (ls_node_conf-data_table_type).

ASSIGN rr_data->* TO <lt_data>.

"Retrieve the target node:

APPEND INITIAL LINE TO lt_key ASSIGNING <ls_key>.

<ls_key>-key = iv_key.

CALL METHOD mo_svc_mngr->retrieve_by_association

EXPORTING

iv_node_key = iv_node_key

it_key = lt_key

iv_association = iv_assoc_key

iv_fill_data = abap_true

IMPORTING

eo_message = lo_message

eo_change = lo_change

et_data = <lt_data>.

"Check the results:

IF lo_message IS BOUND.

IF lo_message->check( ) EQ abap_true.

display_messages( lo_message ).

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

ENDIF.

ENDMETHOD. " METHOD get_node_table_by_assoc

METHOD get_node_row_by_assoc.

"Method-Local Data Declarations:

DATA lr_t_data TYPE REF TO data.

FIELD-SYMBOLS <lt_data> TYPE INDEX TABLE.

FIELD-SYMBOLS <ls_row> TYPE any.

"Lookup the node data:

lr_t_data =

get_node_table_by_assoc( iv_key = iv_key

iv_node_key = iv_node_key

iv_assoc_key = iv_assoc_key

iv_edit_mode = iv_edit_mode ).

IF lr_t_data IS NOT BOUND.

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

"Try to pull the record at the specified index:

ASSIGN lr_t_data->* TO <lt_data>.

READ TABLE <lt_data> INDEX iv_index ASSIGNING <ls_row>.

IF sy-subrc EQ 0.

GET REFERENCE OF <ls_row> INTO rr_data.

ELSE.

RAISE EXCEPTION TYPE /bobf/cx_dac.

ENDIF.

ENDMETHOD. " METHOD get_node_row_by_assoc

METHOD display_messages.

"Method-Local Data Declarations:

DATA lt_messages TYPE /bobf/t_frw_message_k.

DATA lv_msg_text TYPE string.

FIELD-SYMBOLS <ls_message> LIKE LINE OF lt_messages.

"Sanity check:

CHECK io_message IS BOUND.

"Output each of the messages in the collection:

io_message->get_messages( IMPORTING et_message = lt_messages ).

LOOP AT lt_messages ASSIGNING <ls_message>.

lv_msg_text = <ls_message>-message->get_text( ).

WRITE: / lv_msg_text.

ENDLOOP.

ENDMETHOD. " METHOD display_messages

ENDCLASS.

*&---------------------------------------------------------------------*

*& START-OF-SELECTION Event Module *

*&---------------------------------------------------------------------*

START-OF-SELECTION.

"Run the program:

lcl_output=>create_category( iv_category_id = p_cat ).

Thanks & Regards,

Shakeel