cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to assign Freight Units to Freight Order with proxy /SCMTMS/TRANSPORTATIONORDERGEN ?

veerusap
Participant
0 Kudos

Hi,

I have a requirement on enhancement for proxy for TMS. I'm new to proxy and BOBF. I know there are some threads and sap note in some scn threads but those doesn't have details information.

The requirement is, The TMS will send the data to S4 through SOAP/proxy /SCMTMS/TRANSPORTATIONORDERGEN . But after creating FO there is no FU created under FO. No FUs are assigned to FO as standard functionality doesn't have the feature. I need help where I can enhance this and if anyone can send code that would be appreciated.

and the second requirement is, I want to enhance the same standard proxy by adding few additional fields. is it possible to enhance standard SOAP API ?

Regards,

Satish

Accepted Solutions (1)

Accepted Solutions (1)

Dhivya
Active Participant
0 Kudos

Hi Satish,

Reference type for lif_srv_tor is /BOBF/IF_TRA_SERVICE_MANAGER.

After Declaration, you have to instantiate as below

lif_srv_tor = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key )

Regards,

Dhivya

veerusap
Participant
0 Kudos

Hi bdhivya,

Thanks for your reply !

Could you please help me,

1) how I can achieve the "de-assignment of FU from FO" by using the BADI: /SCMTMS/TOR_SE_TOR_GN_REQ .

2) how I can add custom fields to the same proxy /SCMTMS/TRANSPORTATIONORDERGEN. Where and how I can add the Z fields ?

Regards,

Satish

Dhivya
Active Participant
0 Kudos

Hi Satish,

Try 'REMOVE_TOR_ASSIGNMENTS' action from TOR BO.

Thanks,

Dhivya

veerusap
Participant
0 Kudos

Hi bdhivya,

Thanks for your inputs !

I implemented the logic in my BADI: /SCMTMS/TOR_SE_TOR_GN_REQ, by taking reference of action REMOVE_TOR_ASSIGNMENTS. The FUs are getting deleted success fully from FO. But still the FUs are there in the Document flow tab. And I cannot assign the deleted FUs to new/same FO. Because still the FUs are showing under document flow tab (Fiori screen)

Can any one help me what I missed ?

Thanks !!

Answers (4)

Answers (4)

I have done this using below action, You need to pass FO key, and List of FUs to be assigned in lt_param(Pass FU numbers separate by ','). It is working for me.

* Perform the action to assign FU to Freight order by FU ID---

lo_srv_mgr->do_action( EXPORTING

iv_act_key = /scmtms/if_tor_c=>sc_action-root-add_fu_by_fuid

it_key = lt_fo_key

is_parameters = lt_param

IMPORTING

et_failed_key = DATA(lt_failed_key)

eo_message = DATA(lo_message) ).

0cool1234
Discoverer
0 Kudos

Hi, how are you doing this in CREATE scenario? I am getting a failed key because the key does not yet exist in the tables. It only works in CHANGE scenario for me.

0 Kudos

0cool123

I am having Creation strategy for it and it works for me.

0cool1234
Discoverer
0 Kudos

Can you please share code snippet on how you achieved this?

0 Kudos

This code works for me. But my issue is the items are getting copied from FU to FO. Can someone help with that.

*Get Service Manager----------------------------------DATA(lo_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(

/scmtms/if_tor_c=>sc_bo_key ).

*Get the FO key which is getting created---------------------
LOOP AT it_request ASSIGNING FIELD-SYMBOL(<lfs_request>) .
DATA(lo_chaco_request) = /scmtms/cl_tor_helper_chaco=>cast_request( <lfs_request> ).
CHECK lo_chaco_request IS BOUND.
lt_key = lo_chaco_request->mt_tor_key.
ENDLOOP.
**Get the document details-------------------------------------
CALL METHOD lo_srv_mgr->retrieve
EXPORTING
iv_node_key = /scmtms/if_tor_c=>sc_node-root
it_key = lt_key
iv_fill_data = abap_true
iv_invalidate_cache = abap_true
IMPORTING
et_data = lt_tor_root.

**Get Document reference details-------------------------------

lo_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = /scmtms/if_tor_c=>sc_node-root
it_key = lt_key
iv_association = /scmtms/if_tor_c=>sc_association-root-docreference
iv_fill_data = abap_true
iv_edit_mode = /bobf/if_conf_c=>sc_edit_read_only
IMPORTING
et_key_link = lt_fo_doc_link

et_data = lt_doc_ref ).

* Read index 1 as Create strategy triggers for one FO at a time--------------READ TABLE lt_tor_root ASSIGNING FIELD-SYMBOL(<lfs_tor_root>) INDEX 1.

IF sy-subrc = 0.
*Collect all the FUs to be attached to FO-------------------
LOOP AT lt_fo_doc_link ASSIGNING FIELDSYMBOL(<lfs_doc_link>) WHERE source_key = <lfs_tor_root>-key.
READ TABLE lt_doc_ref ASSIGNING FIELD-SYMBOL(<lfs_doc_ref>) WITH KEY key = <lfs_doc_link>-target_key.
IF sy-subrc EQ 0 AND <lfs_doc_ref>-btd_tco EQ lc_btd_id.
TRY.
IF lv_string IS INITIAL.
lv_string = <lfs_doc_ref>-btd_id+25(10).
ELSE.
*Prepare string of all FUs to prepare input parameter for Action
CONCATENATE lv_string <lfs_doc_ref>btd_id+25(10) INTO lv_string SEPARATED BY lc_comma. "','.
ENDIF.
CLEANUP.
ENDTRY.
ENDIF.
ENDLOOP.

lo_srv_mgr->do_action( EXPORTING

iv_act_key = /scmtms/if_tor_c=>sc_action-root-add_fu_by_fuid
it_key = lt_fo_key
is_parameters = lt_param
IMPORTING
et_failed_key = DATA(lt_failed_key)

eo_message = DATA(lo_message) ).

petra_just
Active Participant
0 Kudos

Hi Satish,

To create an after event freight order and assign one or more freight units to it, you can create your own proxy. I have created a class that creates an empty freight order with the following input fields:

Departure date
Fo Type
Licence plate number
Start location
End location

you can then make a segment below this header segment with the FU id to add. based on this, you can use the below coding to create a freight order and add FUs to it.

  "Create empty freight order
    /scmtms/cl_tor_factory=>create_tor_tour(
      EXPORTING
         iv_do_modify            = abap_true
         iv_tor_type             = 'ZFO1'
         iv_create_initial_stage = abap_true
         iv_creation_type        = /scmtms/if_tor_const=>sc_creation_type-manual

      IMPORTING
         es_tor_root             = DATA(ls_tor_root)
         et_tor_item             = DATA(lt_item)
         et_tor_stop             = DATA(lt_stop)

      CHANGING
         co_message              = lo_message ).

    "convert location ids
    /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_location_c=>sc_bo_key )->convert_altern_key(
      EXPORTING
        iv_node_key   = /scmtms/if_location_c=>sc_node-root
        iv_altkey_key = /scmtms/if_location_c=>sc_alternative_key-root-location_id
        it_key        = VALUE /scmtms/t_loc_alt_id( ( iv_src_loc ) ( iv_dest_loc ) )
      IMPORTING
        et_result     = lt_result ).

    "check if locations exist
    lv_nr_loc_lines = lines( lt_result ).
    IF lv_nr_loc_lines < 2.
      MESSAGE ID 'ZTM' TYPE 'E'  NUMBER '019' RAISING location_does_not_exist.
    ENDIF.

    "Update locations and dates into stops
    LOOP AT lt_stop ASSIGNING FIELD-SYMBOL(<stop>).
      IF <stop>-stop_cat EQ /scmtms/if_tor_const=>sc_tor_stop_cat-outbound.
        <stop>-log_locid    = iv_src_loc.
        <stop>-log_loc_uuid = lt_result[ 1 ]-key.
        CONVERT DATE sy-datum INTO TIME STAMP lv_start_date_time TIME ZONE 'CET'.
        <stop>-plan_trans_time = lv_start_date_time.
      ELSE.
        <stop>-log_locid    = lv_dest_loc.
        <stop>-log_loc_uuid = lt_result[ 2 ]-key.
        CONVERT DATE sy-datum INTO TIME STAMP lv_end_date_time TIME ZONE 'CET'.
        <stop>-plan_trans_time = lv_end_date_time.
      ENDIF.

      "prepare stop updates
      INSERT VALUE #(
          change_mode = /bobf/if_frw_c=>sc_modify_update
          node = /scmtms/if_tor_c=>sc_node-stop
          key  = <stop>-key
          data = REF #( <stop> )
        ) INTO TABLE lt_mod.

    ENDLOOP.

    "persist the changes
    CALL METHOD lo_srv_tor->modify
      EXPORTING
        it_modification = lt_mod
      IMPORTING
        eo_message      = lo_message.

    CALL METHOD lo_tra_tor->save(
      IMPORTING
        ev_rejected         = lv_rejected
        eo_change           = lo_change
        eo_message          = lo_message
        et_rejecting_bo_key = lt_rej_bo_key ).

    CLEAR lt_mod.

To assign the fu to the FO, you can use this:

   "Fill parameters for adding fu to FO
          CREATE DATA lr_add_fu_param.
          lr_add_fu_param->string = lv_fu_id.
          lr_add_fu_param->target_item_keys = lt_fu_key.
          lr_add_fu_param->abort_when_error = 'X'.

          "Call action Add fu ID to FO without stage changes
          lif_srv_tor->do_action(
          EXPORTING
            iv_act_key           = /scmtms/if_tor_c=>sc_action-root-add_fu_by_fuid
            it_key               = lt_fo_key
            is_parameters        = lr_add_fu_param
         IMPORTING
            eo_change            = DATA(lo_change)
            eo_message           = lif_message
            et_failed_key        = lt_failed_key
            et_failed_action_key = DATA(lt_failed_action_key) ).
        ENDIF.

If the stage of the Fu is different from the FO, use this:

  CREATE DATA lr_fu_w_planning.
            lr_fu_w_planning->stop_succ_keys = lt_stage_first_key.

            "add an pu and a new stage
            lif_srv_tor->do_action(
            EXPORTING
              iv_act_key           = /scmtms/if_tor_c=>sc_action-root-add_fustage_with_planning
              it_key               = lt_fo_key
              is_parameters        = lr_fu_w_planning
           IMPORTING
              eo_change            = lo_change
              eo_message           = lif_message
              et_failed_key        = lt_failed_key
              et_failed_action_key = lt_failed_action_key ).

            IF lt_failed_key IS INITIAL.
              iv_fu_assigned = 'X'.
            ELSE. 
veerusap
Participant
0 Kudos

Hi phunger,

Thanks for your reply !

I'm trying to add FUs to FOs by using implementing BADI : /SCMTMS/TOR_SE_TOR_GN_REQ . The FO and FU data is coming through SOAP/proxy /SCMTMS/TRANSPORTATIONORDERGEN .

And if you have the code for assigning FU to FO and de-assign FU from FO, please share that would be really helpful to me.

Regards,

veeranjaneyuluvalluri
DominikTylczyn
Active Contributor
0 Kudos

Hello veeranjaneyuluvalluri

I guess you are asking about the TransportationOrderGenericRequest_In interface. Unfortunately it's not capable of assigning existing freight units to the freight order being created by the interface. That is explained in the note 2722559 - Usage of TransportationOrderGenericRequest_In in SAP Transportation Management:

This service is only capable of creating LOCAL items and cannot reference items of an existing demand document, such as a Freight Unit.

You can find the following SAP Best Practice Order-Based Transportation Consolidation – Outbound (3EP) that suggests that such an assignment is possible. I've run an OSS incident about that. SAP Support explained that the flow is available only in S/4HANA cloud edition but not in the on premise one.

Best regards

Dominik Tylczynski

veerusap
Participant
0 Kudos

Hi Dominik,

Thanks for quick reply !

Yes I'm talking about the TransportationOrderGenericRequest_In interface. You mean, is this enhancement completely not possible in S/4 HANA on-premise edition ?

We are creating freight order from Fiori application.

Do you have any alternative solution to fulfill this requirement ?

Thanks again !

Regards,

Satish