2015 Jul 17 1:52 PM
In a custom BO, we have header node and item (status) node (relationship 1-n). For the first time, While inserting data i fill both header and item node and able to populate data correctly.
Now, My requirement is to add only items (status) and while doing so i am getting an error. Please find the below code. Any suggestion/document will help . Thanks.
CREATE DATA lref_status.
lref_status->key = /bobf/cl_frw_factory=>get_new_key( ).
lref_status->rdoc = ls_header-rdoc.
lref_status->st_date = sy-datum.
lref_status->st_time = sy-uzeit.
lref_status->status = '02'.
lref_status->message = 'Status record updated'.
ls_mod-node = zif_bopf_ief_c=>sc_node-ief_status.
ls_mod-change_mode = /bobf/if_frw_c=>sc_modify_create.
ls_mod-source_node = zif_bopf_ief_c=>sc_node-ief_header.
ls_mod-source_key = ls_header-key.
ls_mod-key = lref_status->key .
ls_mod-data = lref_status.
APPEND ls_mod TO lt_mod.
CLEAR : ls_mod , lref_status .
TRY.
CREATE OBJECT lo_driver.
CALL METHOD lo_driver->mo_svc_mngr->modify
EXPORTING
it_modification = lt_mod
IMPORTING
eo_change = lref_change
eo_message = lref_message.
"Check for errors:
IF lref_message IS BOUND.
IF lref_message->check( ) EQ abap_true.
lo_driver->display_messages( lref_message ).
RETURN.
ENDIF.
ENDIF.
"Apply the transactional changes:
CALL METHOD lo_driver->mo_txn_mngr->save
IMPORTING
eo_message = lref_message
ev_rejected = lv_rejected.
IF lv_rejected EQ abap_true.
lo_driver->display_messages( lref_message ).
RETURN.
ENDIF.
CATCH /bobf/cx_frw INTO lx_bopf_ex.
lv_err_msg = lx_bopf_ex->get_text( ).
WRITE 😕 lv_err_msg.
ENDTRY.
Error :
Category ABAP Programming Error
Runtime Errors DATREF_NOT_ASSIGNED
ABAP Program /BOBF/CL_FRW==================CP
Application Component AP-RC-BOF-RNT
Date and Time 17.07.2015 08:41:26
254 READ TABLE lt_new_node
255 WITH KEY node = <ls_mod>-source_node
256 key = <ls_mod>-source_key
257 TRANSPORTING NO FIELDS.
>>>>> IF sy-subrc <> 0 AND
2015 Jul 18 6:01 AM
Hi Kumaran,
if you create a subnode, you have to pass the association via which you are going to create it in the modification instruction.
Did this solve your issue?
Btw: you can omitt the key/handling (like getting a new key). You only need this if you are creating multiple nodes which shall be associated in order to create the items for the correct headers.
Cheers,
Oliver
In a custom BO, we have header node and item (status) node (relationship 1-n). For the first time, While inserting data i fill both header and item node and able to populate data correctly.
Now, My requirement is to add only items (status) and while doing so i am getting an error. Please find the below code. Any suggestion/document will help . Thanks.
CREATE DATA lref_status.
lref_status->key = /bobf/cl_frw_factory=>get_new_key( ).
lref_status->rdoc = ls_header-rdoc.
lref_status->st_date = sy-datum.
lref_status->st_time = sy-uzeit.
lref_status->status = '02'.
lref_status->message = 'Status record updated'.
ls_mod-node = zif_bopf_ief_c=>sc_node-ief_status.
ls_mod-change_mode = /bobf/if_frw_c=>sc_modify_create.
ls_mod-source_node = zif_bopf_ief_c=>sc_node-ief_header.
ls_mod-source_key = ls_header-key.
ls_mod-key = lref_status->key .
ls_mod-data = lref_status.
APPEND ls_mod TO lt_mod.
CLEAR : ls_mod , lref_status .
TRY.
CREATE OBJECT lo_driver.
CALL METHOD lo_driver->mo_svc_mngr->modify
EXPORTING
it_modification = lt_mod
IMPORTING
eo_change = lref_change
eo_message = lref_message.
"Check for errors:
IF lref_message IS BOUND.
IF lref_message->check( ) EQ abap_true.
lo_driver->display_messages( lref_message ).
RETURN.
ENDIF.
ENDIF.
"Apply the transactional changes:
CALL METHOD lo_driver->mo_txn_mngr->save
IMPORTING
eo_message = lref_message
ev_rejected = lv_rejected.
IF lv_rejected EQ abap_true.
lo_driver->display_messages( lref_message ).
RETURN.
ENDIF.
CATCH /bobf/cx_frw INTO lx_bopf_ex.
lv_err_msg = lx_bopf_ex->get_text( ).
WRITE 😕 lv_err_msg.
ENDTRY.
Error :
Category ABAP Programming Error
Runtime Errors DATREF_NOT_ASSIGNED
ABAP Program /BOBF/CL_FRW==================CP
Application Component AP-RC-BOF-RNT
Date and Time 17.07.2015 08:41:26
254 READ TABLE lt_new_node
255 WITH KEY node = <ls_mod>-source_node
256 key = <ls_mod>-source_key
257 TRANSPORTING NO FIELDS.
>>>>> IF sy-subrc <> 0 AND
2015 Jul 18 6:01 AM
Hi Kumaran,
if you create a subnode, you have to pass the association via which you are going to create it in the modification instruction.
Did this solve your issue?
Btw: you can omitt the key/handling (like getting a new key). You only need this if you are creating multiple nodes which shall be associated in order to create the items for the correct headers.
Cheers,
Oliver
2015 Jul 20 9:11 AM
Hi Oliver,
Thanks you very much. What a wonderful start for a monday.
Regards,
Kumaran
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |