cancel
Showing results for 
Search instead for 
Did you mean: 

TM - assign Pu to FO

petra_just
Active Participant
0 Kudos

hi experts,

today, i need to assign a package unit to a freight order using BOPF. I have finished the method to assign Fu to Fo and used add_fustage_with_planning. Now, I need a similar action for add_pustage_with_planning. this action adds the stage if it is not there.

does someone have a hint for me? thanking you in advance

Petra

Accepted Solutions (0)

Answers (3)

Answers (3)

petra_just
Active Participant
0 Kudos

hi,

unfortunately, the action for the fu has NOT worked for me. Finally, I used the action insert_stage: the coding looks as follows and works for me.

After inserting the stage with the PU end location at the end, I can just use add_TU_by_TUID. Of course, I only insert the stage if there is no stage with this end location.

METHOD insert_stage.

    DATA:
      lo_srv_tor         TYPE REF TO /bobf/if_tra_service_manager,
      lo_tra_tor         TYPE REF TO /bobf/if_tra_transaction_mgr,
      lt_fo_key          TYPE /bobf/t_frw_key,
      lv_fo_key          TYPE /bobf/conf_key,
      lt_stop_first      TYPE /scmtms/t_tor_stop_k,
      lt_stop_first_key  TYPE /bobf/t_frw_key,
      lt_stage_first_key TYPE /bobf/t_frw_key,
      lt_mod             TYPE /bobf/t_frw_modification,
      ls_mod             TYPE /bobf/s_frw_modification,
      lv_rejected        TYPE boole_d,
      lr_param           TYPE REF TO /scmtms/s_param_loc_info,
      lv_UUID            TYPE /SCMTMS/LOCUUID.


    "Initiate service and transaction managers
    lo_srv_tor = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key )."Srv Manager TOR object
    lo_tra_tor = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )."Transaction Manager

    CLEAR lt_mod.

    lv_fo_key = /scmtms/cl_tor_helper_root=>return_key_for_torid( iv_torid = iv_freight_order_id ).
    IF lv_fo_key IS NOT INITIAL.
      APPEND VALUE #( key = lv_fo_key ) TO lt_fo_key.
    ENDIF.

    "Read the stages of the FO
    lo_srv_tor->retrieve_by_association(
    EXPORTING
          iv_node_key             = /scmtms/if_tor_c=>sc_node-root
          it_key                  = lt_fo_key
          iv_fill_data            = abap_false
          iv_association          = /scmtms/if_tor_c=>sc_association-root-stop_first
    IMPORTING
          eo_message              = DATA(lo_message)
          et_target_key           = lt_stop_first_key
          et_failed_key           = DATA(lt_failed_key) ).

    "Select the first stage
    lo_srv_tor->retrieve_by_association(
    EXPORTING
          iv_node_key             = /scmtms/if_tor_c=>sc_node-stop
          it_key                  = lt_stop_first_key
          iv_fill_data            = abap_false
          iv_association          = /scmtms/if_tor_c=>sc_association-stop-stop_successor

    IMPORTING
          eo_message              = lo_message
          et_target_key           = lt_stage_first_key
          et_failed_key           = lt_failed_key ).

    "prepare the parameters for stage insertion
      SELECT SINGLE LOC_UUID
        FROM /SAPAPO/LOC
        INTO lv_UUID
        WHERE LOCNO = iv_locid.

    CREATE DATA lr_param.
    lr_param->log_loc_uuid = lv_uuid.
    lr_param->log_locid = iv_locid.



    "Insert stage at the end
    lo_srv_tor->do_action(
      EXPORTING
        iv_act_key           = /scmtms/if_tor_c=>sc_action-stop_successor-insert_after
        it_key               = lt_stage_first_key
        is_parameters        = lr_param

     IMPORTING
        eo_change            = DATA(lo_change)
        eo_message           = lo_message
        et_failed_key        = lt_failed_key
        et_failed_action_key = DATA(lt_failed_action_key) ).

    "Persist the changes
    lo_tra_tor->save(
        IMPORTING
          ev_rejected         = lv_rejected
          eo_change           = lo_change
          eo_message          = lo_message
          et_rejecting_bo_key = DATA(lt_rej_bo_key) ).

    IF lv_rejected IS INITIAL AND lt_failed_key IS INITIAL.
      iv_stage_inserted = 'X'.
    ENDIF.

  ENDMETHOD.
petra_just
Active Participant
0 Kudos

thanks, Dragos. I value your help a lot. I will try and revert back.

Dragoș
Employee
Employee
0 Kudos

Hi Petra,

I think that - in spite of its name - the action ADD_FUSTAGE_WITH_PLANNING can be used for any kind of requirement stages, including CU/PU/RU/TU stages... Could you try it?

Regards,
Dragoș