CO11N:报工
"定义BAPI变量 DATA: LS_RETURN TYPE BAPIRET1. DATA: LT_TIMETICKETS TYPE TABLE OF BAPI_PP_TIMETICKET . DATA: LS_TIMETICKETS TYPE BAPI_PP_TIMETICKET . DATA: LT_DETAIL TYPE TABLE OF BAPI_CORU_RETURN . DATA: LS_DETAIL TYPE BAPI_CORU_RETURN . DATA: LT_GM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE. DATA: LS_GM TYPE BAPI2017_GM_ITEM_CREATE. DATA: L_MSG TYPE STRING. LOOP AT _T_CONF ASSIGNING FIELD-SYMBOL(<FS_CONF>) WHERE MATNR = IS_CONF-MATNR AND WERKS = IS_CONF-WERKS AND VORNR = IS_CONF-VORNR. LS_TIMETICKETS-ORDERID = <FS_CONF>-AUFNR ."订单 LS_TIMETICKETS-OPERATION = <FS_CONF>-VORNR ."工序 LS_TIMETICKETS-POSTG_DATE = <FS_CONF>-BUDAT ."记帐日期 LS_TIMETICKETS-FIN_CONF = '1' . "部分确认space\自动最终确认1\最后确认X LS_TIMETICKETS-CONF_ACTIVITY1 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT1 = <FS_CONF>-MEINS."单位 LS_TIMETICKETS-CONF_ACTIVITY2 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT2 = <FS_CONF>-MEINS."单位 LS_TIMETICKETS-CONF_ACTIVITY3 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT3 = <FS_CONF>-MEINS."单位 LS_TIMETICKETS-CONF_ACTIVITY4 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT4 = <FS_CONF>-MEINS."单位 LS_TIMETICKETS-CONF_ACTIVITY5 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT5 = <FS_CONF>-MEINS."单位 LS_TIMETICKETS-CONF_ACTIVITY6 = <FS_CONF>-LMNGA."数量 LS_TIMETICKETS-CONF_ACTI_UNIT6 = <FS_CONF>-MEINS."单位 APPEND LS_TIMETICKETS TO LT_TIMETICKETS. IF I_TEST IS NOT INITIAL. "检查时任务清单组号不跳号 CL_FS4MIG_CONTEXT=>SET_ACTIVE( ABAP_TRUE ). CL_FS4MIG_CONTEXT=>SET_IN_SIMULATION( ABAP_TRUE ). ELSE. "创建流水号或者使用流水号 CL_FS4MIG_CONTEXT=>SET_ACTIVE( SPACE ). CL_FS4MIG_CONTEXT=>SET_IN_SIMULATION( SPACE ). ENDIF. CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT' EXPORTING POST_WRONG_ENTRIES = '1' * TESTRUN = '' IMPORTING RETURN = LS_RETURN TABLES TIMETICKETS = LT_TIMETICKETS DETAIL_RETURN = LT_DETAIL. IF LINE_EXISTS( LT_DETAIL[ TYPE = 'I' ID = 'RU' NUMBER = '100' ] ). "处理成功 IF I_TEST IS INITIAL. MODIFY _T_CONF FROM VALUE #( MESSAGE = |生产订单{ <FS_CONF>-AUFNR }确认成功!| ISTAT = '3' ) TRANSPORTING MESSAGE ISTAT WHERE WERKS = <FS_CONF>-WERKS AND AUFNR = <FS_CONF>-AUFNR AND VORNR = <FS_CONF>-VORNR. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'. ELSE. "清空缓存、回滚、检查成功 CALL FUNCTION 'ROUTING_CLEARBUFFER'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. MODIFY _T_CONF FROM VALUE #( MESSAGE = |检查通过!| ISTAT = '2' ) TRANSPORTING MESSAGE ISTAT WHERE WERKS = <FS_CONF>-WERKS AND AUFNR = <FS_CONF>-AUFNR AND VORNR = <FS_CONF>-VORNR. R_TESTOK = ABAP_TRUE. ENDIF. ELSE. CALL FUNCTION 'ROUTING_CLEARBUFFER'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. LOOP AT LT_DETAIL INTO LS_DETAIL WHERE TYPE = 'E' OR TYPE = 'A'. L_MSG = |{ L_MSG };{ LS_DETAIL-MESSAGE }|. ENDLOOP. MODIFY _T_CONF FROM VALUE #( MESSAGE = L_MSG ISTAT = '1' ) TRANSPORTING MESSAGE ISTAT WHERE MATNR = IS_CONF-MATNR AND WERKS = IS_CONF-WERKS AND VORNR = IS_CONF-VORNR. ENDIF. ENDLOOP. CLEAR: LS_TIMETICKETS,LT_TIMETICKETS,L_MSG,LS_RETURN,LT_DETAIL.
"定义BAPI变量
DATA: LS_RETURN TYPE BAPIRET1.
DATA: LT_TIMETICKETS TYPE TABLE OF BAPI_PP_TIMETICKET .
DATA: LS_TIMETICKETS TYPE BAPI_PP_TIMETICKET .
DATA: LT_DETAIL TYPE TABLE OF BAPI_CORU_RETURN .
DATA: LS_DETAIL TYPE BAPI_CORU_RETURN .
DATA: LT_GM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE.
DATA: LS_GM TYPE BAPI2017_GM_ITEM_CREATE.
DATA: L_MSG TYPE STRING.
LOOP AT _T_CONF ASSIGNING FIELD-SYMBOL(<FS_CONF>)
WHERE MATNR = IS_CONF-MATNR
AND WERKS = IS_CONF-WERKS
AND VORNR = IS_CONF-VORNR.
LS_TIMETICKETS-ORDERID = <FS_CONF>-AUFNR ."订单
LS_TIMETICKETS-OPERATION = <FS_CONF>-VORNR ."工序
LS_TIMETICKETS-POSTG_DATE = <FS_CONF>-BUDAT ."记帐日期
LS_TIMETICKETS-FIN_CONF = '1' . "部分确认space\自动最终确认1\最后确认X
LS_TIMETICKETS-CONF_ACTIVITY1 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT1 = <FS_CONF>-MEINS."单位
LS_TIMETICKETS-CONF_ACTIVITY2 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT2 = <FS_CONF>-MEINS."单位
LS_TIMETICKETS-CONF_ACTIVITY3 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT3 = <FS_CONF>-MEINS."单位
LS_TIMETICKETS-CONF_ACTIVITY4 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT4 = <FS_CONF>-MEINS."单位
LS_TIMETICKETS-CONF_ACTIVITY5 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT5 = <FS_CONF>-MEINS."单位
LS_TIMETICKETS-CONF_ACTIVITY6 = <FS_CONF>-LMNGA."数量
LS_TIMETICKETS-CONF_ACTI_UNIT6 = <FS_CONF>-MEINS."单位
APPEND LS_TIMETICKETS TO LT_TIMETICKETS.
IF I_TEST IS NOT INITIAL.
"检查时任务清单组号不跳号
CL_FS4MIG_CONTEXT=>SET_ACTIVE( ABAP_TRUE ).
CL_FS4MIG_CONTEXT=>SET_IN_SIMULATION( ABAP_TRUE ).
ELSE.
"创建流水号或者使用流水号
CL_FS4MIG_CONTEXT=>SET_ACTIVE( SPACE ).
CL_FS4MIG_CONTEXT=>SET_IN_SIMULATION( SPACE ).
ENDIF.
CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'
EXPORTING
POST_WRONG_ENTRIES = '1'
* TESTRUN = ''
IMPORTING
RETURN = LS_RETURN
TABLES
TIMETICKETS = LT_TIMETICKETS
DETAIL_RETURN = LT_DETAIL.
IF LINE_EXISTS( LT_DETAIL[ TYPE = 'I' ID = 'RU' NUMBER = '100' ] ).
"处理成功
IF I_TEST IS INITIAL.
MODIFY _T_CONF FROM VALUE #( MESSAGE = |生产订单{ <FS_CONF>-AUFNR }确认成功!|
ISTAT = '3' )
TRANSPORTING MESSAGE ISTAT WHERE WERKS = <FS_CONF>-WERKS
AND AUFNR = <FS_CONF>-AUFNR
AND VORNR = <FS_CONF>-VORNR.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ELSE.
"清空缓存、回滚、检查成功
CALL FUNCTION 'ROUTING_CLEARBUFFER'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MODIFY _T_CONF FROM VALUE #( MESSAGE = |检查通过!| ISTAT = '2' )
TRANSPORTING MESSAGE ISTAT WHERE WERKS = <FS_CONF>-WERKS
AND AUFNR = <FS_CONF>-AUFNR
AND VORNR = <FS_CONF>-VORNR.
R_TESTOK = ABAP_TRUE.
ENDIF.
ELSE.
CALL FUNCTION 'ROUTING_CLEARBUFFER'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT LT_DETAIL INTO LS_DETAIL WHERE TYPE = 'E' OR TYPE = 'A'.
L_MSG = |{ L_MSG };{ LS_DETAIL-MESSAGE }|.
ENDLOOP.
MODIFY _T_CONF FROM VALUE #( MESSAGE = L_MSG ISTAT = '1' )
TRANSPORTING MESSAGE ISTAT WHERE MATNR = IS_CONF-MATNR
AND WERKS = IS_CONF-WERKS
AND VORNR = IS_CONF-VORNR.
ENDIF.
ENDLOOP.
CLEAR: LS_TIMETICKETS,LT_TIMETICKETS,L_MSG,LS_RETURN,LT_DETAIL.
标签:VORNR,报工,订单,LT,LS,CONF,生产,TIMETICKETS,TYPE From: https://www.cnblogs.com/yangliu11223/p/18154647