Untitled
unknown
plain_text
a year ago
5.0 kB
11
Indexable
*--------------------------------------------------------------*
* Copyright © 2024, 2BM Software A/S
* All Rights Reserved.
* For more information, please contact info@2bmsoftware.com.
*--------------------------------------------------------------*
METHOD get_confirmations.
TYPES: BEGIN OF ty_usraddr,
bname TYPE xubname,
name_textc TYPE ad_namtext,
END OF ty_usraddr.
DATA:
lt_confirmations TYPE TABLE OF bapi_conf_key,
ls_confdetails TYPE bapi_alm_confirmation,
lt_orderrange TYPE TABLE OF bapi_pp_orderrange,
lt_useraddr TYPE TABLE OF ty_usraddr,
ls_useraddr TYPE ty_usraddr,
lv_oper TYPE bapi_alm_confirmation-operation,
lv_sub_oper TYPE bapi_alm_confirmation-sub_oper,
lv_un_work_iso TYPE isocd_unit,
lv_timestamp TYPE timestamp,
lv_startdatetime TYPE string.
FIELD-SYMBOLS:
<order> LIKE LINE OF it_orders,
<entity> LIKE LINE OF ct_confirmations,
<confirmation> LIKE LINE OF lt_confirmations,
<orderrange> LIKE LINE OF lt_orderrange.
" Append the orders into the bapi range table
LOOP AT it_orders ASSIGNING <order>.
APPEND INITIAL LINE TO lt_orderrange ASSIGNING <orderrange>.
<orderrange>-sign = 'I'.
<orderrange>-option = 'EQ'.
<orderrange>-low = <order>-orderid.
ENDLOOP.
" Get all order confirmations for given order range
IF lt_orderrange IS NOT INITIAL.
CALL FUNCTION 'BAPI_ALM_CONF_GETLIST'
EXPORTING
operation = lv_oper
suboperation = lv_sub_oper
TABLES
order_range = lt_orderrange
confirmations = lt_confirmations.
" Get the isocode for unit of work
SELECT SINGLE isocode INTO lv_un_work_iso
FROM t006 WHERE msehi = 'H'.
IF NOT lt_confirmations IS INITIAL.
" Get the user address data
SELECT bname name_textc FROM user_addr INTO TABLE lt_useraddr
FOR ALL ENTRIES IN lt_confirmations
WHERE bname = lt_confirmations-created_by.
IF sy-subrc EQ 0.
SORT lt_useraddr BY bname.
ENDIF.
ENDIF.
" Process order confirmations
LOOP AT lt_confirmations ASSIGNING <confirmation>.
" Get each Confirmation details
CALL FUNCTION 'BAPI_ALM_CONF_GETDETAIL'
EXPORTING
confirmation = <confirmation>-conf_no
confirmationcounter = <confirmation>-conf_cnt
IMPORTING
conf_detail = ls_confdetails.
IF <confirmation>-reversed <> 'X' AND
<confirmation>-rev_conf_cnt EQ '0'.
APPEND INITIAL LINE TO ct_confirmations ASSIGNING <entity>.
MOVE-CORRESPONDING ls_confdetails TO <entity>.
<entity>-confcounter = <confirmation>-conf_cnt.
" Convert the UOM
IF <entity>-un_work EQ 'MIN'.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = <entity>-act_work
no_type_check = 'X'
round_sign = ''
unit_in = <entity>-un_work
unit_out = 'H'
IMPORTING
output = <entity>-act_work
EXCEPTIONS
conversion_not_found = 1
division_by_zero = 2
input_invalid = 3
output_invalid = 4
overflow = 5
type_invalid = 6
units_missing = 7
unit_in_not_found = 8
unit_out_not_found = 9
OTHERS = 10.
IF sy-subrc EQ 0.
<entity>-un_work = 'H'.
IF NOT lv_un_work_iso IS INITIAL.
<entity>-un_work_iso = lv_un_work_iso.
ELSE.
<entity>-un_work_iso = 'H'.
ENDIF.
ENDIF.
ENDIF.
IF ls_confdetails-pers_no IS NOT INITIAL.
<entity>-pers_no = ls_confdetails-pers_no.
<entity>-fullname = ls_confdetails-name.
ELSE.
READ TABLE lt_useraddr INTO ls_useraddr
WITH KEY bname = ls_confdetails-created_by BINARY SEARCH.
IF sy-subrc EQ 0.
<entity>-fullname = ls_useraddr-name_textc.
ENDIF.
gcl_wo_cust_ext->get_employeeno( EXPORTING uname = ls_confdetails-created_by
IMPORTING persno = <entity>-pers_no ).
ENDIF.
CONVERT DATE ls_confdetails-exec_start_date TIME ls_confdetails-exec_start_time
INTO TIME STAMP lv_timestamp TIME ZONE gcl_wo_cust_ext->get_timezone( ).
lv_Startdatetime = lv_timestamp.
<entity>-startdatetime = lv_startdatetime.
ELSE.
ENDIF.
ENDLOOP.
ENDIF.
DELETE ct_confirmations WHERE act_work EQ 0.
ENDMETHOD.Editor is loading...
Leave a Comment