Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

custom BO : Insert additonal only in item node.

Kumaranl
Explorer
0 Likes
872

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
775

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

2 REPLIES 2
Read only

Former Member
0 Likes
776

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

Read only

0 Likes
775

Hi Oliver,

Thanks you very much. What a wonderful start for a monday.

Regards,

Kumaran