大家好,又见面了,我是你们的朋友全栈君。
FORM frm_upload USING value(ps_i_tabindex) LIKE sy-tabix
value(pc_i_fieldname) TYPE slis_fieldname
CHANGING
value(l_subrc) LIKE sy-subrc
value(l_msgtx) TYPE msgtx.
CLEAR:l_subrc,l_msgtx,g_lines.
DATA:
l_lines LIKE sy-tabix,
l_testrun TYPE bapiflag VALUE space,
l_group TYPE bapi1012_tsk_c-task_list_group,
l_groupcounter TYPE bapi1012_tsk_c-group_counter.
TYPES:BEGIN OF ty_routing_tbl,
plnty LIKE ckmlmv001-plnty_nd,
plnnr LIKE ckmlmv001-plnnr_nd,
plnal LIKE ckmlmv001-plnal_nd,
END OF ty_routing_tbl.
DATA:
ls_routing_tbl TYPE ty_routing_tbl,
le_routing_tbl TYPE STANDARD TABLE OF ty_routing_tbl.
DATA:
lt_tsk_tab LIKE STANDARD TABLE OF capp_tsk WITH HEADER LINE,
lt_seq_tab LIKE STANDARD TABLE OF capp_seq WITH HEADER LINE,
lt_opr_tab LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
lt_phase_tab LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
lt_subopr_tab LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
lt_rel_tab LIKE STANDARD TABLE OF capp_rel WITH HEADER LINE,
lt_com_tab LIKE STANDARD TABLE OF capp_com WITH HEADER LINE,
lt_referr_tab LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
lt_refmis_tab LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
lt_it_aenr LIKE STANDARD TABLE OF aenr WITH HEADER LINE.
DATA:
lt_task LIKE STANDARD TABLE OF bapi1012_tsk_c WITH HEADER LINE,
lt_materialtaskallocation LIKE STANDARD TABLE OF bapi1012_mtk_c WITH HEADER LINE,
lt_sequence LIKE STANDARD TABLE OF bapi1012_seq_c WITH HEADER LINE,
lt_operation LIKE STANDARD TABLE OF bapi1012_opr_c WITH HEADER LINE,
lt_suboperation LIKE STANDARD TABLE OF bapi1012_sub_opr_c WITH HEADER LINE,
lt_referenceoperation LIKE STANDARD TABLE OF bapi1012_ref_opr_c WITH HEADER LINE,
lt_workcenterreference LIKE STANDARD TABLE OF bapi1012_wc_ref_opr_c WITH HEADER LINE,
lt_componentallocation LIKE STANDARD TABLE OF bapi1012_com_c WITH HEADER LINE,
lt_productionresource LIKE STANDARD TABLE OF bapi1012_prt_c WITH HEADER LINE,
lt_inspcharacteristic LIKE STANDARD TABLE OF bapi1012_cha_c WITH HEADER LINE,
lt_textallocation LIKE STANDARD TABLE OF bapi1012_txt_hdr_c WITH HEADER LINE,
lt_text LIKE STANDARD TABLE OF bapi1012_txt_c WITH HEADER LINE,
lt_return LIKE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
DATA:
ls_return LIKE bapiret2,
ls_crhd LIKE crhd.
FIELD-SYMBOLS:<f_list> LIKE LINE OF gt_list.
l_lines = lines( gt_list ).
LOOP AT gt_list ASSIGNING <f_list> WHERE sel = 'X'.
g_tabix = sy-tabix.
CALL FUNCTION 'ZFM_SHOW_PROGRESSBAR'
EXPORTING
text = 'Creating Routing...'
curr_num = g_tabix
total_num = l_lines.
CALL FUNCTION 'CKBA_ROUTING_GET_LIST'
EXPORTING
i_matnr = <f_list>-matnr
i_werks = <f_list>-werks
IMPORTING
e_routing_tbl = le_routing_tbl
EXCEPTIONS
no_values = 1
OTHERS = 2.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
LOOP AT le_routing_tbl INTO ls_routing_tbl.
REFRESH:
lt_tsk_tab,
lt_seq_tab,
lt_opr_tab,
lt_phase_tab,
lt_subopr_tab,
lt_rel_tab,
lt_com_tab,
lt_referr_tab,
lt_refmis_tab,
lt_it_aenr.
REFRESH:
lt_task,
lt_materialtaskallocation,
lt_sequence,
lt_operation,
lt_suboperation,
lt_referenceoperation,
lt_workcenterreference,
lt_componentallocation,
lt_productionresource,
lt_inspcharacteristic,
lt_textallocation,
lt_text,
lt_return.
CALL FUNCTION 'CARO_ROUTING_READ'
EXPORTING
plnty = ls_routing_tbl-plnty
plnnr = ls_routing_tbl-plnnr
plnal = ls_routing_tbl-plnal
TABLES
tsk_tab = lt_tsk_tab
seq_tab = lt_seq_tab
opr_tab = lt_opr_tab
phase_tab = lt_phase_tab
subopr_tab = lt_subopr_tab
rel_tab = lt_rel_tab
com_tab = lt_com_tab
referr_tab = lt_referr_tab
refmis_tab = lt_refmis_tab
it_aenr = lt_it_aenr
EXCEPTIONS
not_found = 1
ref_not_exp = 2
not_valid = 3
OTHERS = 4.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
"Fill Header - lt_task
LOOP AT lt_tsk_tab.
CLEAR lt_task.
"lt_task-task_list_group = ''. "Key for Task List Group
lt_task-task_list_usage = lt_tsk_tab-verwe. "Task list usage
lt_task-task_list_status = lt_tsk_tab-statu. "Status
lt_task-task_measure_unit = lt_tsk_tab-plnme.
lt_task-description = lt_tsk_tab-ktext.
lt_task-plant = lt_tsk_tab-werks.
lt_task-valid_from = lt_tsk_tab-datuv.
lt_task-valid_to_date = lt_tsk_tab-datub.
APPEND lt_task.
ENDLOOP.
"Fill lt_materialtaskallocation
CLEAR lt_materialtaskallocation.
lt_materialtaskallocation-material = <f_list>-matnr_n.
lt_materialtaskallocation-plant = <f_list>-werks.
lt_materialtaskallocation-valid_from = lt_tsk_tab-datuv.
lt_materialtaskallocation-valid_to_date = lt_tsk_tab-datub.
APPEND lt_materialtaskallocation.
"Fill lt_operation
LOOP AT lt_opr_tab.
CLEAR lt_operation.
lt_operation-activity = lt_opr_tab-vornr. "操作/活动编号/Operation/Activity Number
lt_operation-control_key = lt_opr_tab-steus. "控制码/Control key
lt_operation-description = lt_opr_tab-ltxa1. "工序短文本
lt_operation-plant = lt_opr_tab-werks. "工厂
lt_operation-denominator = lt_opr_tab-umren. "用于转换工艺路线和工序单位的分母
lt_operation-nominator = lt_opr_tab-umrez. "用于转换任务清单和工序计量单位的计数器
lt_operation-base_quantity = lt_opr_tab-bmsch. "基本数量
lt_operation-acttype_01 = lt_opr_tab-lar01.
lt_operation-std_unit_01 = lt_opr_tab-vge01.
lt_operation-std_value_01 = lt_opr_tab-vgw01.
lt_operation-acttype_02 = lt_opr_tab-lar02.
lt_operation-std_unit_02 = lt_opr_tab-vge02.
lt_operation-std_value_02 = lt_opr_tab-vgw02.
lt_operation-acttype_03 = lt_opr_tab-lar03.
lt_operation-std_unit_03 = lt_opr_tab-vge03.
lt_operation-std_value_03 = lt_opr_tab-vgw03.
lt_operation-valid_from = lt_opr_tab-datuv.
lt_operation-valid_to_date = lt_opr_tab-datub.
lt_operation-cost_relevant = lt_opr_tab-ckselkz.
"Work center
CLEAR ls_crhd.
CALL FUNCTION 'CR_WORKSTATION_READ'
EXPORTING
id = lt_opr_tab-arbid
IMPORTING
ecrhd = ls_crhd
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
lt_operation-work_cntr = ls_crhd-arbpl. "工作中心
ENDIF.
APPEND lt_operation.
ENDLOOP.
CALL FUNCTION 'BAPI_ROUTING_CREATE'
EXPORTING
testrun = l_testrun
IMPORTING
group = l_group
groupcounter = l_groupcounter
TABLES
task = lt_task
materialtaskallocation = lt_materialtaskallocation
sequence = lt_sequence
operation = lt_operation
return = lt_return.
READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ls_return.
IF ls_return-type = 'E'.
ENDIF.
CONCATENATE <f_list>-msgtx l_group '/' l_groupcounter ';' INTO <f_list>-msgtx.
CONDENSE <f_list>-msgtx NO-GAPS.
IF <f_list>-icon <> icon_led_red.
<f_list>-werks_n = <f_list>-werks.
<f_list>-icon = icon_led_green.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
return = ls_return.
CONCATENATE <f_list>-msgtx l_group 'Error;' INTO <f_list>-msgtx.
CONDENSE <f_list>-msgtx NO-GAPS.
<f_list>-icon = icon_led_red.
ENDIF.
ENDLOOP.
ENDLOOP.
l_msgtx = 'Conversion is complete'.
ENDFORM.
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/163909.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...