Skip to Content

Add FU to Frieght Booking in TM

TRY.
          " Create blank freight order with  doc type
*          /scmtms/cl_tor_factory=>create_tor_tour(
          /scmtms/cl_tor_factory=>create_tor_bo(
                EXPORTING
                  iv_tor_type             = lv_fo_type " Custom DOC type
*                iv_create_initial_stage = abap_true
                  is_bo_info              = ls_bo_info
                  iv_creation_type        = /scmtms/if_tor_const=>sc_creation_type-manual
                IMPORTING
                  es_tor_root             = ls_root
                  et_tor_item             = lt_fo_item
                  et_tor_stop             = lt_stop
                  et_tor_stop_succ        = lt_succ
                CHANGING
                  co_message              = lo_message ).
        CATCH cx_root.
	lv_error = abap_true.
          CONTINUE.
      ENDTRY.


**Modify created FO with required details - Sy uname , Add FU .
      ls_root-created_by = sy-uname.
      INSERT ls_root INTO TABLE lt_tor_root.

      TRY .
          CALL METHOD /scmtms/cl_mod_helper=>mod_create_multi
            EXPORTING
              it_data = lt_tor_root
              iv_node = /scmtms/if_tor_c=>sc_node-root
            CHANGING
              ct_mod  = lt_mod.
        CATCH cx_root.
	lv_error = abap_true.
          CONTINUE.
      ENDTRY.


      TRY.
          /scmtms/cl_mod_helper=>mod_create_multi(
                EXPORTING
                  it_data        = lt_fo_item
                  iv_node        = /scmtms/if_tor_c=>sc_node-item_tr
                  iv_source_node = /scmtms/if_tor_c=>sc_node-root
                  iv_association = /scmtms/if_tor_c=>sc_association-root-item_tr
                CHANGING
                  ct_mod         = lt_mod ).
          /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key )->modify( lt_mod ).
        CATCH cx_root.
	  lv_error = abap_true.
          CONTINUE.
      ENDTRY.

/bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )->save( IMPORTING eo_message = lo_message ) .
      CLEAR : ls_fo_key1.
      ls_fo_key1-key = ls_root-key.
      APPEND ls_fo_key1  TO lt_fo_key.


* added for Container
      CREATE DATA lr_param_cont.
      lr_param_cont->item_type = lc_cont. "CONT
      TRY.
          lo_srv_mgr->do_action(
          EXPORTING
          iv_act_key           = /scmtms/if_tor_c=>sc_action-root-add_container
          it_key               = lt_fo_key
          is_parameters        = lr_param_cont
          IMPORTING
          eo_change            = lo_change
          eo_message           = lo_message
          et_failed_key        = lt_failed_key ).

        CATCH cx_root.
	lv_error = abap_true.
          CONTINUE.
      ENDTRY.

      IF lt_failed_key IS NOT INITIAL.
        IF lo_message IS BOUND .
          /scmtms/cl_common_helper=>msg_convert_bopf_2_bapiret2(
          EXPORTING
          io_message  = lo_message
          CHANGING
          ct_bapiret2 = lt_return ).
          IF lt_return IS NOT INITIAL.
            LOOP AT lt_return INTO DATA(ls_return) .
              IF ls_return-type = 'E'.
                CONCATENATE ls_fail-error_desc lc_cm ls_return-message INTO ls_fail-error_desc.
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDIF.
        CONTINUE.
      ELSE.
        /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )->save( IMPORTING eo_message = lo_message ) .
      ENDIF.


      TRY .
          /scmtms/cl_tor_helper_read=>get_tor_data(
              EXPORTING
                it_root_key  = lt_fo_key
              IMPORTING
                et_all_items = DATA(lt_item) ).
        CATCH cx_root.
	lv_error = abap_true.
          CONTINUE.
      ENDTRY.


      READ TABLE lt_item INTO DATA(ls_item1) WITH KEY item_type = lc_cont  item_cat = lc_tur.
      IF sy-subrc EQ 0.
        ls_cont_no = ls_item1.
        ls_cont_no-platenumber = ls_hu1-package.
        INSERT ls_cont_no INTO TABLE lt_cont_no.


        TRY .
            /scmtms/cl_mod_helper=>mod_create_multi(
                      EXPORTING
                        it_data        = lt_cont_no
                        iv_node        = /scmtms/if_tor_c=>sc_node-item_tr
                        iv_source_node = /scmtms/if_tor_c=>sc_node-root
                        iv_association = /scmtms/if_tor_c=>sc_association-root-item_tr
                      CHANGING
                        ct_mod         = lt_mod ).


            /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key )->modify( lt_mod ).


          CATCH cx_root.
	lv_error = abap_true.
            CONTINUE.
        ENDTRY.
      ENDIF.


      /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )->save( IMPORTING eo_message = lo_message ) .


      CREATE DATA lr_param1.
      DATA(lt_hu_temp) = im_hu_t.
      DELETE lt_hu_temp WHERE labeltxt NE ls_likp-vbeln.
      LOOP AT lt_hu_temp INTO DATA(ls_hu1_n).
        DATA(lv_fu) = ls_hu1_n-tor_id.
        IF sy-tabix = 1.
          CONCATENATE lr_param1->string lv_fu INTO lr_param1->string.
        ELSE.
          CONCATENATE lr_param1->string lv_fu INTO lr_param1->string SEPARATED BY space.
        ENDIF.
        CLEAR: ls_hu1_n, lv_fu.
      ENDLOOP.


      LOOP AT lt_item INTO DATA(ls_item)." WHERE item_type = 'CONT'.
        CLEAR : ls_key.
        ls_key-key = ls_item-key.
        APPEND ls_key TO lt_item_key.
      ENDLOOP.


      lr_param1->target_item_keys = lt_item_key.
      TRY.
          lo_srv_mgr->do_action(
          EXPORTING
            iv_act_key           = /scmtms/if_tor_c=>sc_action-root-add_fu_by_fuid "item_tr-add_fu_by_fuid    "
            it_key               = lt_fo_key " rootkey
            is_parameters        = lr_param1
          IMPORTING
            eo_change            = lo_change
            eo_message           = lo_message
            et_failed_key        = lt_failed_key ).


        CATCH cx_root.
	lv_error = abap_true.
          CONTINUE.
      ENDTRY.

i am trying to create Auto Fright booking from a SE38 report using /scmtms/cl_tor_factory=>create_tor_bo() method.

it is creating Freight booking but when i call ADD_FU_BY_FUID action FUs are not added to Fright booking. Action is not returning messages, not returning failed keys and not updating FUs also.

one more issue is.. not allowing to add FUs manually also for those Fright bookings which are created from this program.

can anyone help me with this issue.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

0 Answers