ABAP-CA01工艺路线批导

  1 FUNCTION zfm_pp_0003.
  2 *"----------------------------------------------------------------------
  3 *"*"本地接口:
  4 *"  IMPORTING
  5 *"     VALUE(IV_TEST) TYPE  CHAR1 OPTIONAL
  6 *"  EXPORTING
  7 *"     VALUE(EV_TYPE) TYPE  CHAR1
  8 *"     VALUE(EV_MESSAGE) TYPE  CHAR255
  9 *"     VALUE(EV_GROUP) TYPE  BAPI1012_TSK_C-TASK_LIST_GROUP
 10 *"  TABLES
 11 *"      TI_INPUT STRUCTURE  ZSPP_0003 OPTIONAL
 12 *"----------------------------------------------------------------------
 13 
 14   DATA:lt_task                   TYPE TABLE OF bapi1012_tsk_c,
 15        ls_task                   TYPE bapi1012_tsk_c,
 16        lt_materialtaskallocation TYPE TABLE OF bapi1012_mtk_c,
 17        ls_materialtaskallocation TYPE bapi1012_mtk_c,
 18        lt_operation              TYPE TABLE OF bapi1012_opr_c,
 19        ls_operation              TYPE bapi1012_opr_c,
 20        lt_return                 TYPE TABLE OF bapiret2,
 21        ls_return                 TYPE bapiret2,
 22        lv_message                TYPE char255,
 23        lv_message_temp           TYPE char255,
 24        ls_testrun                TYPE bapiflag,
 25        lv_group                  TYPE bapi1012_tsk_c-task_list_group.
 26 
 27   REFRESH lt_task .
 28   REFRESH lt_materialtaskallocation .
 29   REFRESH lt_operation .
 30   REFRESH lt_return .
 31   CLEAR lv_message .
 32   CLEAR lv_group .
 33 
 34   LOOP AT ti_input ASSIGNING FIELD-SYMBOL(<fs_data>) .
 35 
 36     AT FIRST .
 37 
 38       CLEAR ls_materialtaskallocation .
 39 *      ls_materialtaskallocation-valid_to_date = '99991231'."有效截止日期
 40       ls_materialtaskallocation-task_list_group = <fs_data>-plnnr .
 41       ls_materialtaskallocation-material = <fs_data>-matnr ."物料
 42       ls_materialtaskallocation-plant = <fs_data>-werks ."工厂
 43       ls_materialtaskallocation-group_counter = <fs_data>-plnal ."组计数器
 44       ls_materialtaskallocation-valid_from = <fs_data>-datuv ."有效起始日期
 45       ls_materialtaskallocation-change_no = <fs_data>-aennr .
 46       APPEND ls_materialtaskallocation TO lt_materialtaskallocation .
 47 
 48       CLEAR ls_task .
 49       ls_task-task_list_group = <fs_data>-plnnr .
 50       ls_task-task_list_usage = <fs_data>-verwe ."任务清单使用
 51       ls_task-task_list_status = <fs_data>-statu ."状态
 52       ls_task-lot_size_from = <fs_data>-losvn ."最小批量
 53       ls_task-lot_size_to = <fs_data>-losbs ."最大批量
 54       ls_task-description = <fs_data>-ktext ."工艺路线描述
 55       ls_task-valid_from = <fs_data>-datuv."有效起始日期
 56       ls_task-plant = <fs_data>-werks .
 57       ls_task-group_counter = <fs_data>-plnal ."
 58 *      ls_task-valid_to_date = '99991231'."有效至
 59       ls_task-task_measure_unit = <fs_data>-meinh .
 60       ls_task-change_no = <fs_data>-aennr .
 61       APPEND ls_task TO lt_task .
 62 
 63     ENDAT .
 64 
 65     CLEAR ls_operation .
 66     ls_operation-change_no = <fs_data>-aennr .
 67 *    ls_operation-valid_to_date =  '99991231'."有效截止日期
 68     ls_operation-task_list_group = <fs_data>-plnnr .
 69     ls_operation-activity = <fs_data>-vornr ."操作/活动编号
 70     ls_operation-operation_measure_unit = <fs_data>-meinh ."作业的计量单位
 71     ls_operation-work_cntr = <fs_data>-arbpl."工作中心
 72     ls_operation-control_key = <fs_data>-steus ."控制码
 73     ls_operation-description = <fs_data>-ltxa1 ."工序短文本
 74     ls_operation-base_quantity = <fs_data>-bmsch ."基本数量
 75     ls_operation-std_value_01 = <fs_data>-vgw01."
 76     ls_operation-std_unit_01 = <fs_data>-vge01."
 77     ls_operation-std_value_02 = <fs_data>-vgw02."
 78     ls_operation-std_unit_02 = <fs_data>-vge02."
 79     ls_operation-std_value_03 = <fs_data>-vgw03."
 80     ls_operation-std_unit_03 = <fs_data>-vge03."
 81     ls_operation-std_value_04 = <fs_data>-vgw04."
 82     ls_operation-std_unit_04 = <fs_data>-vge04."
 83     ls_operation-std_value_05 = <fs_data>-vgw05."
 84     ls_operation-std_unit_05 = <fs_data>-vge05."
 85     ls_operation-std_value_06 = <fs_data>-vgw06."
 86     ls_operation-std_unit_06 = <fs_data>-vge06."
 87     ls_operation-valid_from = <fs_data>-datuv ."有效起始日期
 88     ls_operation-purch_org = <fs_data>-ekorg ."采购组织
 89     ls_operation-matl_group = <fs_data>-matkl ."物料组
 90     ls_operation-cost_elem = <fs_data>-sakto ."成本要素
 91     ls_operation-purch_group = <fs_data>-ekgrp ."外部加工活动的采购组
 92     ls_operation-standard_queue_time = <fs_data>-zwnor .
 93     ls_operation-standard_queue_time_unit = <fs_data>-zeiwn .
 94     ls_operation-denominator = '1'.
 95     ls_operation-nominator = '1'.
 96     ls_operation-plant = <fs_data>-werks .
 97     ls_operation-cost_relevant =  'X'. "与成本核算相关标志
 98     ls_operation-group_counter = <fs_data>-plnal ."
 99     ls_operation-userfields_keyword_id = <fs_data>-slwid .
100     ls_operation-userfield_ch20_00 = <fs_data>-usr00 .
101     ls_operation-task_list_group = <fs_data>-plnnr .
102     APPEND ls_operation TO lt_operation .
103 
104   ENDLOOP .
105 
106   ls_testrun-bapiflag = iv_test .
107   CALL FUNCTION 'BAPI_ROUTING_CREATE'
108     EXPORTING
109       testrun                = ls_testrun
110 *     PROFILE                =
111 *     BOMUSAGE               =
112 *     APPLICATION            =
113     IMPORTING
114       group                  = ev_group
115 *     GROUPCOUNTER           =
116     TABLES
117       task                   = lt_task
118       materialtaskallocation = lt_materialtaskallocation
119 *     SEQUENCE               =
120       operation              = lt_operation
121 *     SUBOPERATION           =
122 *     REFERENCEOPERATION     =
123 *     WORKCENTERREFERENCE    =
124 *     COMPONENTALLOCATION    =
125 *     PRODUCTIONRESOURCE     =
126 *     INSPCHARACTERISTIC     =
127 *     TEXTALLOCATION         =
128 *     TEXT                   =
129       return                 = lt_return
130 *     TASK_SEGMENT           =
131 *     DEPENDENCY_ALLOCATION  =
132 *     DEPENDENCY_ORDER       =
133 *     DEPENDENCY_DATA        =
134 *     DEPENDENCY_DESCRIPTION =
135 *     DEPENDENCY_DOCUMENTATION       =
136 *     DEPENDENCY_SOURCE      =
137     .
138 
139   LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A' .
140 
141     CLEAR lv_message_temp .
142 
143     CALL FUNCTION 'MESSAGE_TEXT_BUILD'
144       EXPORTING
145         msgid               = ls_return-id
146         msgnr               = ls_return-number
147         msgv1               = ls_return-message_v1
148         msgv2               = ls_return-message_v2
149         msgv3               = ls_return-message_v3
150         msgv4               = ls_return-message_v4
151       IMPORTING
152         message_text_output = lv_message_temp.
153 
154     lv_message = lv_message_temp && ';' && lv_message .
155 
156   ENDLOOP .
157 
158   IF lv_message IS INITIAL .
159 
160     IF iv_test = 'X' .
161 
162       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
163         EXPORTING
164           wait = 'X'
165 *   IMPORTING
166 *         RETURN        =
167         .
168     ELSE .
169       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
170         EXPORTING
171           wait = 'X'
172 *   IMPORTING
173 *         RETURN        =
174         .
175     ENDIF .
176     ev_type = 'S' .
177 
178   ELSE .
179 
180     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
181 *   IMPORTING
182 *     RETURN        =
183       .
184 
185     ev_type = 'E' .
186 
187   ENDIF .
188 
189   ev_message = lv_message .
190 
191 ENDFUNCTION.
posted @ 2023-05-13 16:18  TigerMan  阅读(212)  评论(0编辑  收藏  举报