Skip to Content
Technical Articles
Author's profile photo Rajiv Kanoria

Accessing and Updating Transportation Charges SAP Transportation Management

So as you experts know that Transportation Charges is a Dependent BOPF Node in SAP Transportation Management System.

I would not go too deep in explaining how do Dependent Nodes work and how they are placed in BOPF framework as there are already lot of posts around this.

Today we will focus only on the Charges Dependent Object and how do we use modification operations on Charges Dependent Node.

So lets start on accessing the Charges DO(Dependent Object) for a Freight Booking Object.

 

 

So Everyone here understands that TRANSPORTCHARGES in TOR Object is a dependent entity and can be accessed only by DO Keys.

SAP Standard has provided some methods to get these keys for you to make things easier for us.

 

So Assuming we need to get the Charges for a Freight Booking and then modify them using some external Program below would be the steps.(Code Extracts are from Embedded TM 1709, Please ignore naming convention in case they don’t appeal you  )

Get Service Manager for TOR using Service Manager   /bobf/cl_tra_serv_mgr_factory=>get_service_manager.

Get TRANSPORTCHARGES node data using Retrieve by Association on TOR Object and get the keys for TRANSPORTCHARGES .

Now the Fun Starts.

Now we need to fetch the runtime DO Keys for various nodes/subnodes/dependent nodes involved.

First we fetch the runtime Dependent Node key and Association Key for relation between TOR and TRANSPORTCHARGES. This utility method provided by SAP Standard to ease our work.

using /scmtms/cl_tcc_calc_utility=>get_bo_do_assoc(
EXPORTING
iv_bo_key        = /scmtms/if_tor_c=>sc_bo_key  ” Business Object
iv_node_key      = /scmtms/if_tor_c=>sc_node–root   ” Node
iv_do_key        = /scmtms/if_tcc_trnsp_chrg_c=>sc_bo_key
*          iv_calc_ctx      = iv_calc_ctx    ” Calculation Context
IMPORTING
ev_root_node_key = DATA(lv_do_key)    ” NodeID
ev_assoc_key     = DATA(lv_bo_do_assoc_key)    ” Node
).

We get lv_do_key(Runtime Node key for TRANSPORTATIONCHARGES for TOR Object) and lv_bo_do_assoc_key(Runtime Association key between TOR and TRANSPORTCHARGES)

Now comes another method to get the runtime node keys and association keys for dependent nodes.SAP provides another method   /scmtms/cl_common_helper=>get_do_entity_key.

This method has parameters like below.

DATA(lv_root_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node–root
).

iv_host_key is main Business Object BO Key to which the Dependent node is attached.

iv_host_do_node_key is the runtime node key for TRANSPORTCHARGE we fetched in step 5a.

iv_do_entity_cat specifies whether we want to fetch association or node key.

  •                      /bobf/if_conf_c=>sc_content_nod for Node Key
  •                     /bobf/if_conf_c=>sc_content_assoc for Association Key

iv_do_entity_key is node which you want to fetch. For eg. in this case its /SCMTMS/TCC_TRNSP_CHRG.

Now we fetch Node Keys and Association Keys for Charge Items and Charge Elements.

DATA(lv_root_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node–root
).    ” This is runtime node key for Charges Root

DATA(lv_it_chrg_it_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node–chargeitem
). ” This is runtime node key for Charges Items

DATA(lv_it_chrg_el_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node–itemchargeelement
).  ” This is runtime node key for Charges Elements

DATA(lv_chrg_chargit_assoc_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_assoc
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_association–root–chargeitem
) . ” This is runtime association key for Charges root to Charge Items
DATA(lv_chrgit_itchrgel_assoc_key) = /scmtms/cl_common_helper=>get_do_entity_key(
iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
iv_host_do_node_key = lv_do_key
iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_assoc
iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_association–chargeitem–           itemchargeelement
). “ This is runtime association key for Charges Item to Elements

 

Now Time to fetch existing Charge Items and Charge Elements using these runtime keys.

  1. This is fetching Charge Item Keys: lr_srvmgr->retrieve_by_association(
    EXPORTING
    iv_node_key             = lv_do_key“/scmtms/if_tor_c=>sc_node-transportcharges    ” Node
    it_key                  = lt_tcc_keys    ” Key Table
    iv_association          = ev_chrg_chargit_assoc_key“lv_txt_assoc    ” Association
    IMPORTING
    et_target_key           =  DATA(lt_chitemkeys)    ” Key Table for Charge Items
    ).
  2. This is fetching CHarge Elements :  lr_srvmgr->retrieve_by_association(
    EXPORTING
    iv_node_key             = ev_it_chrg_it_node_key“lv_do_key   ” Node
    it_key                  = lt_chitemkeys    ” Key Table
    iv_association          = ev_chrgit_itchrgel_assoc_key    ” Association
    iv_fill_data            = abap_true    ” Data element for domain BOOLE: TRUE (=’X’) and FALSE (=’ ‘)
    IMPORTING
    et_data                 = lt_chrel   ” Table for Charge Elements for Charge Items pushed in lt_chitemkeys
    et_target_key           =  DATA(lt_chelm)    ” Key Table for Charge Elements
    ).

Till here it was fetching , now its time to modify charge elements

  1. Assuming we want to add a new charge Element ,Prepare the Data table lt_chrel_new for Charge elements.This would be of the same Table Type as lt_chrel.Update your data in a similar table type of lt_chrel . Create data reference for lt_chrel_new.
  2. Create lt_modification.
  3. Below would be the LT_MODIFICATION Table.
  4. ls_chrel-key = /bobf/cl_frw_factory=>get_new_key( ) .. Make sure this is the same key in data table STEP 1.
  5. ls_mod–key          = ls_chrel–key.   ”  This is Charge Element Key
    ls_mod–source_key   = ls_chrel–parent_key.  ” This would be the source key for Charge Elements.In this case it would be Charge Items Key.
    ls_mod–source_node  = lv_it_chrg_it_node_key. ” This is the runtime node key for Charge Items 
    ls_mod–root_key     = ls_chrel–root_key.“This is the Root Key of the /SCMTMS/TCC_TRNSP/CHRG root.
    ls_mod–node         = ev_it_chrg_el_node_key.  “This is the runtime node key for Charge Elements 
    ls_mod–association  = ev_chrgit_itchrgel_assoc_key.This is the runtime association key for charge items to Charge Elements 
    ls_mod–change_mode  = /bobf/if_frw_c=>sc_modify_create. ” Operation Create, update, Delete
    ls_mod–data         = lr_chrel_new.

APPEND ls_mod TO lt_mod.

  1. Now from here call the Service manager Modify method and Transaction Manager Save Method to update the Charge Elements.

 

IF lr_srvmgr IS NOT BOUND.
    CALL METHOD /bobf/cl_tra_serv_mgr_factory=>get_service_manager
      EXPORTING
        iv_bo_key          = /scmtms/if_tor_c=>sc_bo_key
      RECEIVING
        eo_service_manager = lr_srvmgr.
  ENDIF.


  MOVE '00163E77B0961EE8BA96B910A4F81F35' TO ls_fo_key-key.   " Sample Key for Freight Booking

  APPEND ls_fo_key TO lt_fo_key.

  lr_srvmgr->retrieve_by_association(
     EXPORTING
       iv_node_key             =  /scmtms/if_tor_c=>sc_node-root   " Node
       it_key                  =   lt_fo_key  " Key Table
       iv_association          =  /scmtms/if_tor_c=>sc_association-root-transportcharges   " Association
       iv_fill_data            = abap_true    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')
     IMPORTING
       et_data                 = lt_tcc
       et_target_key           =  DATA(lt_tcc_keys)   " Key Table
   ).

/scmtms/cl_tcc_calc_utility=>get_bo_do_assoc(
        EXPORTING
          iv_bo_key        = /scmtms/if_tor_c=>sc_bo_key  " Business Object
          iv_node_key      = /scmtms/if_tor_c=>sc_node-root   " Node
          iv_do_key        = /scmtms/if_tcc_trnsp_chrg_c=>sc_bo_key
*          iv_calc_ctx      = iv_calc_ctx    " Calculation Context
        IMPORTING
          ev_root_node_key = DATA(lv_do_key)    " NodeID
          ev_assoc_key     = DATA(lv_bo_do_assoc_key)    " Node
      ).

DATA(lv_root_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
          iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
          iv_host_do_node_key = lv_do_key
           iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
          iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node-root
             ).

DATA(lv_it_chrg_it_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
          iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
          iv_host_do_node_key = lv_do_key
          iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
          iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node-chargeitem
             ).

DATA(lv_it_chrg_el_node_key) = /scmtms/cl_common_helper=>get_do_entity_key(
          iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
          iv_host_do_node_key = lv_do_key
          iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_nod
          iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_node-itemchargeelement
             ).

DATA(lv_chrg_chargit_assoc_key) = /scmtms/cl_common_helper=>get_do_entity_key(
          iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
          iv_host_do_node_key = lv_do_key
          iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_assoc
          iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_association-root-chargeitem
             ).

DATA(lv_chrgit_itchrgel_assoc_key) = /scmtms/cl_common_helper=>get_do_entity_key(
          iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
          iv_host_do_node_key = lv_do_key
          iv_do_entity_cat    = /bobf/if_conf_c=>sc_content_assoc
          iv_do_entity_key    = /scmtms/if_tcc_trnsp_chrg_c=>sc_association-chargeitem-itemchargeelement
             ).

  DATA: lt_chitem TYPE /scmtms/t_tcc_chrgitem_k.

  lr_srvmgr->retrieve_by_association(
    EXPORTING
      iv_node_key             = lv_do_key"/scmtms/if_tor_c=>sc_node-transportcharges    " Node
      it_key                  = lt_tcc_keys    " Key Table
      iv_association          = lv_chrg_chargit_assoc_key"    " Association
    IMPORTING
      et_target_key           =  DATA(lt_chitemkeys)    " Key Table
  ).

  lr_srvmgr->retrieve_by_association(
    EXPORTING
      iv_node_key             = lv_it_chrg_it_node_key "Node
      it_key                  = lt_chitemkeys    " Key Table
      iv_association          = lv_chrgit_itchrgel_assoc_key " Association
      iv_fill_data            = abap_true    
    IMPORTING
      et_data                 = lt_chrel
      et_target_key           =  DATA(lt_chelm)    " Key Table
  ).

Prepare your Data Table for Charge Elements Here.  
clear ls_chrel.
  ls_chrel-key = /bobf/cl_frw_factory=>get_new_key( ).
  ls_chrel-tcet084 = 'FB00'.
  ls_chrel-linenr = ls_chrel-linenr + 5.
  ls_chrel-amount = 40.
  ls_chrel-manual_entry = abap_true.
  

GET REFERENCE OF ls_chrel into DATA(lr_chrel).

  DATA : lt_mod TYPE /bobf/t_frw_modification,
         ls_mod TYPE /bobf/s_frw_modification.

READ TABLE lt_tcc_keys into DATA(ls_tcc_keys) index 1.

ls_mod-key          = ls_chrel-key.
ls_mod-source_key   = ls_chrel-parent_key.
ls_mod-source_node  = lv_it_chrg_it_node_key. " Charge Item Key
ls_mod-root_key     = ls_chrel-root_key."ls_tcc_keys-key. " Key for Charge DO
ls_mod-node         = lv_it_chrg_el_node_key.	" Node Key
ls_mod-association  = lv_chrgit_itchrgel_assoc_key.
ls_mod-change_mode  = /bobf/if_frw_c=>sc_modify_create.
ls_mod-data         = lr_chrel.

  APPEND ls_mod TO lt_mod.

"Call Service Manager
   lr_srvmgr->modify(
      EXPORTING
        it_modification = lt_mod
      IMPORTING
        eo_message      = lref_message
        eo_change       = lr_change ).

  CALL METHOD /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager
    RECEIVING
      eo_transaction_manager = lref_trans.

  CALL METHOD lref_trans->save
    IMPORTING
      eo_change   = lr_change
      eo_message  = lref_message.

 

 

Hope this will be able to resolve your queries on Charge Depenedent Object. Same behavior would be for any Dependent Objects like TEXT_COLLECTIONS , ATTACHMENTS etc.

 

Cheers!!

 

 

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rajiv Kanoria
      Rajiv Kanoria
      Blog Post Author

      Hi Folks,

       

      In the Blog and code you will find   /bobf/if_conf_c=>sc_content_assoc  which is modified from /bobf/if_conf_c=>sc_content_ass which the blog did not allow me to write due to some words not allowed in blog. Please make sure you update this to  /bobf/if_conf_c=>sc_content_ass before using.

      Author's profile photo Deepu SAP
      Deepu SAP

      Hi Rajiv,

       

      I found this blog very useful .

      I am trying to update Invoice charges in Order (instead of Creating charge element).

      First, I call the action CALC_TRANSPORTATION_CHARGES to set the empty calculation line and then I am planning to modify the Charge element node with the Amount and Currency.

      I tried to update using MODIFY method, but it is not working.

      Can you please share the code, if you have a working code snippet for modify the node contents ?

       

      Regards,

      Deepu.

      Author's profile photo Rajiv Kanoria
      Rajiv Kanoria
      Blog Post Author

      Please explain more details please. Question not clear

       

      Author's profile photo kumar manish
      kumar manish

      Hi Rajiv,

       

      Thanks for the wonderful insight. It is really very helpful.

      I have a similar kind of requirement to update a link in the attachment folder of a FO. I have followed your sample code. But got stuck at one point.

      /scmtms/cl_tcc_calc_utility=>get_bo_do_assoc(
              EXPORTING
                iv_bo_key        = /scmtms/if_tor_c=>sc_bo_key  " Business Object
                iv_node_key      = /scmtms/if_tor_c=>sc_node-root   " Node
                iv_do_key        = /scmtms/if_tcc_trnsp_chrg_c=>sc_bo_key
      *          iv_calc_ctx      = iv_calc_ctx    " Calculation Context
              IMPORTING
                ev_root_node_key = DATA(lv_do_key)    " NodeID
                ev_assoc_key     = DATA(lv_bo_do_assoc_key)    " Node
            ).
      

      What method can be used specific to the attachment folder as the same doesn't works? Can you please help me with the same.

      Author's profile photo Rajiv Kanoria
      Rajiv Kanoria
      Blog Post Author

      Hi Deepu,

      Above is a class for Charges only. Below is sample code for TRQ text collection.You can replace TRQ object with TOR object

      /scmtms/cl_common_helper=>get_do_keys_4_rba(
          EXPORTING
            iv_host_bo_key = /scmtms/if_trq_c=>sc_bo_key
            iv_host_do_node_key = /scmtms/if_trq_c=>sc_node-textcollection
            iv_do_node_key = /bobf/if_txc_c=>sc_node-text_content
            iv_do_assoc_key = /bobf/if_txc_c=>sc_association-text-text_content
            IMPORTING
              ev_node_key = lv_content_node_key
              ev_assoc_key = lv_content_assoc_key ).
      
      
      This class helps you to get the runtime node and association for any node. For eg. above will give you node key and association for Text Collection 'TEXT_CONTENT' node and association from 'TEXT' to 'TEXT_CONTENT'.
      
      
      Once you get this you can prepare your BOPF Modification Table for Modify.
      
      
      
      

      You can also refer Class : /SCMTMS/CL_TOR_HELPER_TEXT_COL

       

      Regards,

      Rajiv

      Author's profile photo Rajiv Kanoria
      Rajiv Kanoria
      Blog Post Author

      I replied to your query on

      https://answers.sap.com/questions/12727509/how-to-update-a-link-in-the-attachment-folder-of-a.html?childToView=12740288&answerPublished=true#answer-12740288

      Author's profile photo kumar manish
      kumar manish

      Hi Rajiv,

      Thanks a lot for your inputs and the source code.

      I tried executing the same and it did work for me but with an issue : - A record did got created in the attachment folder of the forwarding order but with a blank URL field. I am not able to figure out the exact reason for the same. The same thing is happening for the Freight order too. Is there anything which is missing in the config or any authorization issue?

      Please help.

      Regards,

      Manish

      Author's profile photo Chetan Bhole
      Chetan Bhole

      Hello Rajiv,

      Do you have sample code how to create Freight order programatically?

      Or any details how to achieve this then please share

      Author's profile photo Alex Hutchins
      Alex Hutchins

      Hi Rajiv,

      Thanks for the detailed blog and i think this one of the well explained one.

      I have a very similar requirement to your and infact i copied the code and made couple of changes.

      I created a report, which is running all fine with out any errors or exception, however its not able to create the charge element.

      I am pasting the code here, can you please tell whats wrong with this.

      DATA:
      lr_srvmgr  TYPE REF TO /bobf/if_tra_service_manager,
      lo_tcc_srv TYPE REF TO /bobf/if_tra_service_manager,
      lref_trans TYPE REF TO /bobf/if_tra_transaction_mgr,
      lt_fo_key  TYPE /bobf/t_frw_key,
      ls_fo_key  TYPE /bobf/s_frw_key,
      lt_tcc     TYPE /scmtms/t_tcc_root_k.

      IF lr_srvmgr IS NOT BOUND.
      CALL METHOD /bobf/cl_tra_serv_mgr_factory=>get_service_manager
      EXPORTING
      iv_bo_key          /scmtms/if_tor_c=>sc_bo_key
      RECEIVING
      eo_service_manager lr_srvmgr.
      ENDIF.

      **MOVE ‘005056A242AE1ED9B9AD5704B9384AF3’ TO ls_fo_key-key.   ” Sample Key for Freight Booking “389

      MOVE ‘005056A242AE1EEA8F92D29EDD940001’ TO ls_fo_keykey.  
      **005056A242AE1EEA8F930EBF1535C083″

      APPEND ls_fo_key TO lt_fo_key.

      lr_srvmgr->retrieve_by_association(
      EXPORTING
      iv_node_key             =  /scmtms/if_tor_c=>sc_noderoot   ” Node
      it_key                  =   lt_fo_key  ” Key Table
      iv_association          =  /scmtms/if_tor_c=>sc_associationroottransportcharges   ” Association
      iv_fill_data            abap_true    ” Data element for domain BOOLE: TRUE (=’X’) and FALSE (=’ ‘)
      IMPORTING
      et_data                 lt_tcc
      et_target_key           =  DATA(lt_tcc_keys)   ” Key Table
      ).

      /scmtms/cl_tcc_calc_utility=>get_bo_do_assoc(
      EXPORTING
      iv_bo_key        /scmtms/if_tor_c=>sc_bo_key  ” Business Object
      iv_node_key      /scmtms/if_tor_c=>sc_noderoot   ” Node
      iv_do_key        /scmtms/if_tcc_trnsp_chrg_c=>sc_bo_key
      *          iv_calc_ctx      = iv_calc_ctx    ” Calculation Context
      IMPORTING
      ev_root_node_key DATA(lv_do_key)    ” Runtime Node key for TRANSPORTATIONCHARGES for TOR Object
      ev_assoc_key     DATA(lv_bo_do_assoc_key)    ” Runtime Association key between TOR and TRANSPORTCHARGES
      ).

      DATA(lv_root_node_key/scmtms/cl_common_helper=>get_do_entity_key(
      iv_host_bo_key      /scmtms/if_tor_c=>sc_bo_key “Main Business Object BO Key to which the Dependent node is attached
      iv_host_do_node_key lv_do_key ” runtime node key for TRANSPORTCHARGE
      iv_do_entity_cat    /bobf/if_conf_c=>sc_content_nod “Node Key
      iv_do_entity_key    /scmtms/if_tcc_trnsp_chrg_c=>sc_noderoot ” node which you want to fetch, in this case its /SCMTMS/TCC_TRNSP_CHRG
      ).“This is runtime node key for Charges Root

      DATA(lv_it_chrg_it_node_key/scmtms/cl_common_helper=>get_do_entity_key(
      iv_host_bo_key      /scmtms/if_tor_c=>sc_bo_key
      iv_host_do_node_key lv_do_key
      iv_do_entity_cat    /bobf/if_conf_c=>sc_content_nod
      iv_do_entity_key    /scmtms/if_tcc_trnsp_chrg_c=>sc_nodechargeitem
      ).“This is runtime node key for Charges Items

      DATA(lv_it_chrg_el_node_key/scmtms/cl_common_helper=>get_do_entity_key(
      iv_host_bo_key      /scmtms/if_tor_c=>sc_bo_key
      iv_host_do_node_key lv_do_key
      iv_do_entity_cat    /bobf/if_conf_c=>sc_content_nod
      iv_do_entity_key    /scmtms/if_tcc_trnsp_chrg_c=>sc_nodeitemchargeelement
      ).“This is runtime node key for Charges Elements

      DATA(lv_chrg_chargit_assoc_key/scmtms/cl_common_helper=>get_do_entity_key(
      iv_host_bo_key      /scmtms/if_tor_c=>sc_bo_key
      iv_host_do_node_key lv_do_key
      iv_do_entity_cat    /bobf/if_conf_c=>sc_content_ass
      iv_do_entity_key    /scmtms/if_tcc_trnsp_chrg_c=>sc_associationrootchargeitem
      ).“This is runtime association key for Charges root to Charge Items

      DATA(lv_chrgit_itchrgel_assoc_key/scmtms/cl_common_helper=>get_do_entity_key(
      iv_host_bo_key      /scmtms/if_tor_c=>sc_bo_key
      iv_host_do_node_key lv_do_key
      iv_do_entity_cat    /bobf/if_conf_c=>sc_content_ass
      iv_do_entity_key    /scmtms/if_tcc_trnsp_chrg_c=>sc_associationchargeitemitemchargeelement
      ).“This is runtime association key for Charges Item to Elements

      DATAlt_chitem TYPE /scmtms/t_tcc_chrgitem_k,
      lt_chrel  TYPE /scmtms/t_tcc_trchrg_element_k,
      ls_chrel  TYPE /scmtms/s_tcc_trchrg_element_k.

      lr_srvmgr->retrieve_by_association(
      EXPORTING
      iv_node_key             lv_do_key“/scmtms/if_tor_c=>sc_node-transportcharges    ” Node
      it_key                  lt_tcc_keys    ” Key Table
      iv_association          lv_chrg_chargit_assoc_key”    ” Association
      IMPORTING
      et_target_key           =  DATA(lt_chitemkeys)    ” Key Table
      ).“Key Table for Charge Items

      lr_srvmgr->retrieve_by_association(
      EXPORTING
      iv_node_key             lv_it_chrg_it_node_key “Node
      it_key                  lt_chitemkeys    ” Key Table
      iv_association          lv_chrgit_itchrgel_assoc_key ” Association
      iv_fill_data            abap_true
      IMPORTING
      et_data                 lt_chrel “Table for Charge Elements for Charge Items pushed in lt_chitemkeys
      et_target_key           =  DATA(lt_chelm)    ” Key Table for Charge Elements
      ).
      **prepare your data table for charge elements here.
      CLEAR ls_chrel.
      READ TABLE lt_chrel INTO DATA(ls_chrel_existINDEX 1.” WITH KEY tcet084 = ‘FB00’.
      **READ TABLE lt_chrel INTO ls_chrel WITH KEY tcet084 = ‘FB00’.
      IF sysubrc IS INITIAL.
      ls_chrelkey /bobf/cl_frw_factory=>get_new_key)“Create
      ls_chreltcet084 ‘FB00’.
      ls_chrellinenr ls_chrel_existlinenr + 5.
      **  ls_chrel-amount = 5.
      ls_chrelrate_amount ‘0.0050’.
      ls_chrelmanual_entry abap_true.
      ENDIF.

      GET REFERENCE OF ls_chrel INTO DATA(lr_chrel).

      DATA lt_mod TYPE /bobf/t_frw_modification,
      ls_mod TYPE /bobf/s_frw_modification.

      READ TABLE lt_tcc_keys INTO DATA(ls_tcc_keysINDEX 1.

      ls_modkey          ls_chrelkey.
      ls_modsource_key   ls_chrel_existparent_key.
      ls_modsource_node  lv_it_chrg_it_node_key” Charge Item Key
      ls_modroot_key     ls_chrel_existroot_key.“ls_tcc_keys-key. ” Key for Charge DO
      ls_modnode         lv_it_chrg_el_node_key.  ” Node Key
      ls_modassociation  lv_chrgit_itchrgel_assoc_key.
      **ls_mod-change_mode  = /bobf/if_frw_c=>sc_modify_update.
      ls_modchange_mode  /bobf/if_frw_c=>sc_modify_create.
      ls_moddata         lr_chrel.

      APPEND ls_mod TO lt_mod.
      CLEAR ls_mod.

      “Call Service Manager
      lr_srvmgr->modify(
      EXPORTING
      it_modification lt_mod
      IMPORTING
      eo_message      DATA(lref_message)
      eo_change       DATA(lr_change).

      CALL METHOD /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager
      RECEIVING
      eo_transaction_manager lref_trans.

      CALL METHOD lref_trans->save
      IMPORTING
      eo_change  lr_change
      eo_message lref_message.

      Author's profile photo Rajiv Kanoria
      Rajiv Kanoria
      Blog Post Author

      Hi Alex,

      Can you try bu commenting the code for Charge Elements and just checking if Charges root & Charge Items are getting created. You can check the result in BOBT.

      If Charge Items are getting created, then we move forward from there.

      Regards,

      Rajiv

      Author's profile photo Valentin Banita
      Valentin Banita

      I think you problem is here:

       

      ls_modsource_key   ls_chrel_existparent_key.
      ls_modroot_key     ls_chrel_existroot_key.“ls_tcc_keys-key. ” Key for Charge DO

       

      You cleared ls_chrel a few lines above so by this point, parent_key and root_key are empty. These also need to be filled.