on 11-20-2020 8:56 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks, Dragos. I value your help a lot. I will try and revert back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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ș
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.