Skip to Content

Create a FWO by BOPF code.

Hi guys i'm using /SCMTMS/CL_CPX_TPNRQ_REQ class to create a FWO by code ,

but to fill the parameters is very hard work.

I want to know if there is an other class more easily to do it.

Or other way.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 07, 2017 at 12:52 PM

    Hi Ronaldo,

    Keep it very simple, Create your own class or report for FWO creation and you can test with below code.

    REPORT ztm_code.
    DATA lt_trq_root     TYPE /scmtms/t_trq_root_k.
    DATA lt_trq_item     TYPE /scmtms/t_trq_item_k.
    DATA lr_trq_root     TYPE REF TO /scmtms/s_trq_root_k.
    DATA lr_trq_item     TYPE REF TO /scmtms/s_trq_item_k.
    DATA lt_modify       TYPE /bobf/t_frw_modification.
    DATA ls_modify       TYPE /bobf/s_frw_modification.
    * Get BO Service Manager - /SCMTMS/TRQ Business Object
    DATA(lr_trq_srvmgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
                                    iv_bo_key = /scmtms/if_trq_c=>sc_bo_key ).
    ***************************** Create ***********************************
    *&---> Create Root Node Instance
    * Fill Root Data
    CREATE DATA lr_trq_root.
    lr_trq_root->key      = lr_trq_srvmgr->get_new_key( ).
    lr_trq_root->trq_cat  = '03'. " Forwarding Order
    lr_trq_root->trq_type = 'ZFWO'.
    * Fill Other Attributes
    * Fill Modification Structure
    ls_modify-node        = /scmtms/if_trq_c=>sc_node-root.
    ls_modify-change_mode = /bobf/if_frw_c=>sc_modify_create.
    ls_modify-data        = lr_trq_root.
    ls_modify-key         = lr_trq_root->key.
    INSERT ls_modify INTO TABLE lt_modify.
    *&---> Create Item Node Instance ( Subnode )
    * Fill Item Data
    CREATE DATA lr_trq_item.
    lr_trq_item->key        = lr_trq_srvmgr->get_new_key( ).
    lr_trq_item->item_cat   = 'PRD'. " Product
    lr_trq_item->item_descr = 'demo'.
    * Fill Other Attributes
    * Fill Modification Structure
    CLEAR ls_modify.
    ls_modify-node        = /scmtms/if_trq_c=>sc_node-item.
    ls_modify-change_mode = /bobf/if_frw_c=>sc_modify_create.
    ls_modify-source_node = /scmtms/if_trq_c=>sc_node-root.
    ls_modify-association = /scmtms/if_trq_c=>sc_association-root-item.
    ls_modify-source_key  = lr_trq_root->key.
    ls_modify-root_key    = lr_trq_root->root_key.
    ls_modify-data        = lr_trq_item.
    ls_modify-key         = lr_trq_item->key.
    INSERT ls_modify INTO TABLE lt_modify.
    * Modify
    IF lt_modify IS NOT INITIAL.
      CALL METHOD lr_trq_srvmgr->modify
          it_modification = lt_modify    " Changes
          eo_change       = DATA(lo_change)    " Interface of Change Object
          eo_message      = DATA(lo_message).    " Interface of Message Object
    IF lo_change IS BOUND AND lo_change->has_failed_changes( ) EQ abap_false.
      DATA(lr_tra_mgr) = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
      CALL METHOD lr_tra_mgr->save
          iv_transaction_pattern = /bobf/if_tra_c=>gc_tp_save_and_continue   
          ev_rejected            = DATA(lv_rejected)
          eo_change              = lo_change
          eo_message             = lo_message.
          et_message              = DATA(lt_message) ).
    Add comment
    10|10000 characters needed characters exceeded