on ‎2020 Nov 30 2:45 PM
hi experts,
today, I need to update actual quantities on a TM package item. It sounds pretty simple, but the actuals are not on the item node of the package item. They are in the execution information Below the exection information, there is another item node and I have to report and event with code QUANTITY_LAST:
I have looked at the helper class /SCMTMS/CL_TOR_HELPER_QUANTITY, method add_quantities. It seems, I can add gross and net weight, but it does not look like it adds the quantities to the actuals into the execution node. I have checked QTY_MERGE_EXEC. it adjust the unit of measure of the related execution node if there is one. But, I would need a method that adds an execution node . I will try to set the package item as loaded, this will give me an event LOAD_END. Then, I should be able to try updating this node with actual quantities. any hints are welcome !!
thx
Petra
Request clarification before answering.
Thomas,
thank you for trying to help. This flag that you mentioned in the integration profile is to base the integration between erp and TM on actuals.
My question was related to posting actual quantities from a mobile device into the tm package unit.
the code that I have done and that works looks as follows:
"update the quantities on the execution nodes
IF lt_pu_item IS INITIAL.
"Package unit has no product item, therefore measures cannot be updated
MESSAGE ID 'ZTM' TYPE 'E' NUMBER '011' RAISING pu_has_no_product.
ELSE.
"Read tare weight from package item if filled
READ TABLE lt_pu_item ASSIGNING FIELD-SYMBOL(<pu_item>) INDEX 1.
IF <pu_item>-pkgun_wei_val IS NOT INITIAL.
lv_tare_weight = <pu_item>-pkgun_wei_val.
lv_pu_item_key = <pu_item>-key.
"If empty, read from Material master of package material
ELSE.
SELECT SINGLE brgew
FROM mara INTO lv_tare_weight
WHERE matnr = <pu_item>-product_id.
"if that is also empty, issue an exception
IF sy-subrc NE 0.
MESSAGE ID 'ZTM' TYPE 'E' NUMBER '016' RAISING tare_weight_empty.
ENDIF.
ENDIF.
"Calculate net weight
lv_net_weight = iv_gross_weight - lv_tare_weight.
"Issue error if net weight is negative
IF lv_net_weight < 0.
MESSAGE ID 'ZTM' TYPE 'E' NUMBER '007' RAISING net_weight_error.
ENDIF.
"Update actual height, gross weight, net weight and number of pieces into package item
INSERT VALUE #(
stop_key = lv_pu_stop_key
item_key = lv_pu_item_key
height = lv_hoehe
measuom = lv_measuom
gro_wei_val = iv_gross_weight
gro_wei_uni = 'KG'
net_wei_val = lv_net_weight
net_wei_uni = 'KG'
pkgun_wei_val = lv_tare_weight
pkgun_wei_uni = 'KG'
" slac_val = iv_num_of_pce
) INTO TABLE lt_item_qty.
"convert today`s date to time stamp
CONVERT DATE sy-datum INTO TIME STAMP lv_event_date TIME ZONE 'CET'.
CALL METHOD /scmtms/cl_tor_helper_event=>report_event
EXPORTING
iv_event_code = 'REPORT_QUANTITY'
it_tor_key = lt_pu_key
it_tor_root_stop = lt_pu_stop_link_key
iv_actual_date = lv_event_date
it_tor_stop_item = CORRESPONDING #( lt_item_qty MAPPING source_key = stop_key target_key = item_key )
iv_exec_info_source = 'T'
it_item_qty = lt_item_qty
iv_actual_tz = 'CET'
iv_event_status = 'R'
IMPORTING
et_failed_key = lt_failed_key
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 ).
"Update number of pieces
lo_srv_tor->retrieve_by_association(
EXPORTING
iv_node_key = /scmtms/if_tor_c=>sc_node-item_tr
it_key = lt_pu_item_key
iv_association = /scmtms/if_tor_c=>sc_association-item_tr-executioninformation_quan
iv_fill_data = abap_true
iv_edit_mode = /bobf/if_conf_c=>sc_edit_read_only
IMPORTING
eo_message = lo_message
et_data = lt_exec
et_target_key = lt_exec_key
et_failed_key = lt_failed_key ).
READ TABLE lt_exec ASSIGNING FIELD-SYMBOL(<ls_exec>) INDEX 1.
lv_pu_exec_key = <ls_exec>-key.
CREATE DATA lr_exec.
lr_exec->slac_val = iv_num_of_pce.
INSERT VALUE #(
change_mode = /bobf/if_frw_c=>sc_modify_update
node = /scmtms/if_tor_c=>sc_node-executioninformation
key = lv_pu_exec_key
data = lr_exec
changed_fields = VALUE #( ( /scmtms/if_tor_c=>sc_node_attribute-executioninformation-slac_val ) ) )
INTO TABLE lt_mod.
"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.
"Was the update successful?
IF lv_rejected IS INITIAL.
iv_update_ok = 'X'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Petra,
thanks for sharing your solution... this is great!
Cheers
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 17 | |
| 16 | |
| 6 | |
| 2 | |
| 1 | |
| 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.