工艺路线导入程序(感谢依风提供)
**&---------------------------------------------------------*
**& Author : *
**& Create date : 2007/04/03 *
**& Program type : Report *
**& Report name : ZPPPR_ROUTING_INPUT *
**& Description : ROUTING_INPUT *
**& FINISH ON : *
**& TRANSPROT REQUEST : *
**&---------------------------------------------------------*
REPORT zpppr_routing_input MESSAGE-ID zmc95
NO STANDARD PAGE HEADING "输出的报表不使用标准的页标题
LINE-SIZE 500. "输出的报表每页的字符宽度.
*---->define table->bapi
DATA: group TYPE bapi1012_tsk_c-task_list_group,
group_counter TYPE bapi1012_tsk_c-group_counter,
sequence_no TYPE bapi1012_opr_c-sequence_no,
task_list_usage TYPE bapi1012_tsk_c-task_list_usage,
task_list_status TYPE bapi1012_tsk_c-task_list_status,
lot_size_from TYPE bapi1012_tsk_c-lot_size_from,
lot_size_to TYPE bapi1012_tsk_c-lot_size_to,
task_measure_unit TYPE bapi1012_tsk_c-task_measure_unit,
application TYPE bapi1012_control_data-application,
testrun TYPE bapiflag,
profile TYPE bapi1012_control_data-profile,
bomusage TYPE bapi1012_control_data-bom_usage,
task TYPE bapi1012_tsk_c OCCURS 0 WITH HEADER LINE,
materialtaskallocation TYPE bapi1012_mtk_c OCCURS 0 WITH HEADER LINE,
sequence TYPE bapi1012_seq_c OCCURS 0 WITH HEADER LINE,
operation TYPE bapi1012_opr_c OCCURS 0 WITH HEADER LINE,
suboperation TYPE bapi1012_sub_opr_c OCCURS 0 WITH HEADER LINE,
referenceoperation TYPE bapi1012_ref_opr_c OCCURS 0 WITH HEADER LINE,
workcenterreference TYPE bapi1012_wc_ref_opr_c OCCURS 0 WITH HEADER LINE,
componentallocation TYPE bapi1012_com_c OCCURS 0 WITH HEADER LINE,
productionresource TYPE bapi1012_prt_c OCCURS 0 WITH HEADER LINE,
inspcharacteristic TYPE bapi1012_cha_c OCCURS 0 WITH HEADER LINE,
textallocation TYPE bapi1012_txt_hdr_c OCCURS 0 WITH HEADER LINE,
text TYPE bapi1012_txt_c OCCURS 0 WITH HEADER LINE,
return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
bapi_retn_info LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*---->message table
DATA: BEGIN OF t_error OCCURS 0.
DATA material LIKE bapi1012_mtk_c-material.
INCLUDE STRUCTURE bapiret2.
DATA: END OF t_error.
*---->inner table
DATA: BEGIN OF itab1 OCCURS 0 ,
material LIKE bapi1012_mtk_c-material,
plant LIKE bapi1012_mtk_c-plant,
description1 LIKE bapi1012_tsk_c-description,
activity LIKE bapi1012_opr_c-activity,
work_cntr LIKE bapi1012_opr_c-work_cntr,
control_key LIKE bapi1012_opr_c-control_key,
description LIKE bapi1012_opr_c-description,
base_quantity LIKE bapi1012_opr_c-base_quantity,
std_value_01 LIKE bapi1012_opr_c-std_value_01,
std_value_02 LIKE bapi1012_opr_c-std_value_02,
* max_no_of_splits LIKE bapi1012_opr_c-max_no_of_splits,
FJS(2) TYPE C,
ind_splitting_reqrd LIKE bapi1012_opr_c-ind_splitting_reqrd,
required_overlapping LIKE bapi1012_opr_c-required_overlapping,
min_send_ahead_qty LIKE bapi1012_opr_c-min_send_ahead_qty,
ext_proc_with_subcontract_ind LIKE bapi1012_opr_c-ext_proc_with_subcontract_ind,
info_rec LIKE bapi1012_opr_c-info_rec,
purch_org LIKE bapi1012_opr_c-purch_org,
cost_elem LIKE bapi1012_opr_c-cost_elem,
COST_RELEVANT like bapi1012_opr_c-COST_RELEVANT,
END OF itab1.
DATA: BEGIN OF itab OCCURS 0 ,
material LIKE bapi1012_mtk_c-material,
plant LIKE bapi1012_mtk_c-plant,
description1 LIKE bapi1012_tsk_c-description,
activity LIKE bapi1012_opr_c-activity,
work_cntr LIKE bapi1012_opr_c-work_cntr,
control_key LIKE bapi1012_opr_c-control_key,
description LIKE bapi1012_opr_c-description,
base_quantity LIKE bapi1012_opr_c-base_quantity,
std_value_01 LIKE bapi1012_opr_c-std_value_01,
std_value_02 LIKE bapi1012_opr_c-std_value_02,
max_no_of_splits LIKE bapi1012_opr_c-max_no_of_splits,
ind_splitting_reqrd LIKE bapi1012_opr_c-ind_splitting_reqrd,
required_overlapping LIKE bapi1012_opr_c-required_overlapping,
min_send_ahead_qty LIKE bapi1012_opr_c-min_send_ahead_qty,
ext_proc_with_subcontract_ind LIKE bapi1012_opr_c-ext_proc_with_subcontract_ind,
info_rec LIKE bapi1012_opr_c-info_rec,
purch_org LIKE bapi1012_opr_c-purch_org,
cost_elem LIKE bapi1012_opr_c-cost_elem,
END OF itab.
DATA : gt_itab LIKE itab OCCURS 0 WITH HEADER LINE.
DATA : lv_cancel(1) TYPE c.
*---->upload
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = 'C:/Documents and Settings/Administrator/Desktop/工艺路线.txt'
filetype = 'DAT'
IMPORTING
cancel = lv_cancel
TABLES
data_tab = itab1
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF lv_cancel EQ 'X'.
LEAVE PROGRAM.
ENDIF.
IF sy-subrc <> 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
SORT itab1 BY material plant activity.
LOOP AT ITAB1.
MOVE-CORRESPONDING ITAB1 TO ITAB.
CONDENSE ITAB1-FJS NO-GAPS.
ITAB-max_no_of_splits = ITAB1-FJS.
APPEND ITAB.
ENDLOOP.
SORT ITAB BY MATERIAL PLANT.
LOOP AT itab.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = itab-material
IMPORTING
output = itab-material.
MOVE itab TO gt_itab.
APPEND gt_itab.
*-----〉item-sequence
*operation-group_counter = '1'.
operation-activity = itab-activity.
operation-control_key = itab-control_key.
operation-work_cntr = itab-work_cntr.
operation-description = itab-description.
operation-plant = itab-plant.
* operation-operation_measure_unit = 'EA'.
operation-denominator = 1.
operation-nominator = 1.
operation-base_quantity = itab-base_quantity.
operation-std_value_01 = itab-std_value_01.
operation-std_value_02 = itab-std_value_02.
operation-ind_splitting_reqrd = itab-ind_splitting_reqrd." 'X'."分解
operation-max_no_of_splits = itab-max_no_of_splits."'1'."分解数
operation-required_overlapping = itab-required_overlapping."'X'."要求重叠
operation-min_send_ahead_qty = itab-min_send_ahead_qty."'10'."最小发送数量
operation-ext_proc_with_subcontract_ind = itab-ext_proc_with_subcontract_ind."'X'.
operation-info_rec = itab-info_rec.
operation-purch_org = itab-purch_org.
operation-cost_elem = itab-cost_elem.
operation-COST_RELEVANT = 'X'."成本核算标示
APPEND operation.
AT END OF material.
*-----〉header
task-task_list_usage = '1'.
task-task_list_status = '4'.
**---->unit
select single MEINS into task-task_measure_unit
from mara
where matnr = gt_itab-material.
* task-task_measure_unit = 'EA'.
task-description = gt_itab-description1."'TEST ROUTING'.
task-plant = gt_itab-plant.
task-valid_from = sy-datum.
task-valid_to_date = '99991231'.
APPEND task.
materialtaskallocation-material = gt_itab-material.
materialtaskallocation-plant = gt_itab-plant.
task-valid_from = sy-datum.
task-valid_to_date = '99991231'.
APPEND materialtaskallocation.
CALL FUNCTION 'BAPI_ROUTING_CREATE'
EXPORTING
testrun = testrun
profile = profile
bomusage = bomusage
application = application
IMPORTING
group = group
groupcounter = group_counter
TABLES
task = task
materialtaskallocation = materialtaskallocation
sequence = sequence
operation = operation
suboperation = suboperation
referenceoperation = referenceoperation
workcenterreference = workcenterreference
componentallocation = componentallocation
productionresource = productionresource
inspcharacteristic = inspcharacteristic
textallocation = textallocation
text = text
return = return.
REFRESH task.
REFRESH GT_ITAB.
REFRESH materialtaskallocation.
REFRESH operation.
LOOP AT return.
IF return-type EQ 'E' OR return-type EQ 'A'.
t_error-material = materialtaskallocation-material.
t_error-message = return-message.
APPEND t_error.
ELSE.
COMMIT WORK.
ENDIF.
ENDLOOP.
LOOP AT t_error.
WRITE:/ t_error-material,t_error-message.
ENDLOOP.
ENDAT.
ENDLOOP.
ENDIF.
模板
物料 | 工厂 | 工艺路线描述 | 工序号 | 工作中心 | 控制码 | 工序描述 | 基本数量 | 标准值 | 标准值 | 分解数 | 所需分解 | 要求重叠 | 最小发送数量 | 外协 | 信息记录 | 采购组织 | 成本要素 |
3010000001 | 1200 | 对些工艺路线的描述 | 0010 | 300000 | PP01 | 本工艺的描述1 | 10 | 200 | 200 | 1 | X | X | 50 | ||||
3010000001 | 1200 | 对些工艺路线的描述 | 0020 | 300001 | PP03 | 本工艺的描述2 | 20 | 200 | 200 | 1 | X | X | 50 | ||||
3010000001 | 1200 | 对些工艺路线的描述 | 0030 | PP02 | 本工艺的描述3 | 1 | 200 | 200 | 1 | X | X | 50 | X | 5500000021 | 1000 | 5001004000 | |
2010000010 | 1200 | 对些工艺路线的描述 | 0020 | 300001 | PP03 | 本工艺的描述22 | 100 | 130 | 130 | 1 | X | X | 50 |