标签:tin exp rms ret cal tsm scope obj 原创文章
项目中,生产订单的状态是了解生产过程的主要依据,也是自开发报表中常用到的,下面是生产订单状态的几个函数以及生产订单技术关闭、生产订单报工的几个函数,希望对用到的兄弟有所帮助。
[相关表]
JEST-对象的系统状态(I****)和用户状态(E****)
JSTO-状态对象信息
TJ02T-系统状态文本
-用户状态文本
【锁对象】:生产订单锁对象 ESORDER
函数: ENQUEUE_ESORDER, DEQUEUE_ESORDER
[函数1]:检查多个对象的状态并过滤
CALL FUNCTION ‘STATUS_CHECK_MULTI‘
EXPORTING
status = cns_stat_20 "系统状态或用户状态
flg_exclude = cns_active "X or space
TABLES
OBJECTS = gt_objnr_tab.
[函数2]:读取对象的所有有效状态的文本
CALL FUNCTION ‘STATUS_TEXT_EDIT‘
EXPORTING
* CLIENT = SY-MANDT
* FLG_USER_STAT = ‘ ‘
objnr = <fs_aufk>-objnr
only_active = ‘X‘
spras = sy-langu
* BYPASS_BUFFER = ‘ ‘
IMPORTING
* ANW_STAT_EXISTING =
* E_STSMA =
line = <fs_aufk>-sttxt
* USER_LINE =
* STONR =
EXCEPTIONS
object_not_found = 1
OTHERS = 2
[函数3]:读取单个对象的对象状态
CALL FUNCTION ‘STATUS_OBJECT_READ‘
EXPORTING
client = sy-mandt
objnr = up_objnr
IMPORTING
e_jsto = ls_jsto
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
[函数4]:改变对象用户状态
CALL FUNCTION ‘I_CHANGE_STATUS‘
EXPORTING
objnr = up_objnr
estat_inactive = cns_stat_20
estat_active = cns_stat_10
stsma = ls_jsto-stsma
EXCEPTIONS
cannot_update = 1
OTHERS = 2.
注意:用户状态改变时,一个状态设置为激活,另一个状态需要设置为非激活
【函数5】:改变对象系统状态
CALL FUNCTION ‘STATUS_CHANGE_INTERN‘
EXPORTING
* CHECK_ONLY = ‘ ‘
client = sy-mandt
objnr = up_objnr
* ZEILE = ‘ ‘
* SET_CHGKZ =
IMPORTING
error_occurred = lv_error
object_not_found = lv_object_not_found
status_inconsistent = lv_status_inconsistent
status_not_allowed = lv_status_not_allowed
TABLES
status = tp_jstat
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4
注意:在Tables参数Status中,需要一并准备好相互切换的两组状态,一个设置为激活,另一个设置为非激活
【函数6】:订单技术关闭
CALL FUNCTION ‘BAPI_PRODORD_COMPLETE_TECH‘
* EXPORTING
* SCOPE_COMPL_TECH = ‘1‘
* WORK_PROCESS_GROUP = ‘COWORK_BAPI‘
* WORK_PROCESS_MAX = 99
IMPORTING
return = ls_return
TABLES
orders = lt_aufnr
detail_return = lt_detail
* APPLICATION_LOG =
【函数6】:生产订单报工函数
DATA:IT_TT TYPE TABLE OF BAPI_PP_TIMETICKET,
WA_TT TYPE BAPI_PP_TIMETICKET,
IT_DR TYPE TABLE OF BAPI_CORU_RETURN,
WA_DR TYPE BAPI_CORU_RETURN,
WA_RETURN TYPE BAPIRET1,
I_ERRMSG TYPE BAPIRET2-MESSAGE,"记录返回消息中的错误消息
I_TIME(14) TYPE C, "传送时间
I_ERRFLG TYPE C,
I_COUNT TYPE I."用于对导入数据的行数记录
CLEAR:WA_TT,
I_COUNT,
I_ERRMSG,
I_ERRFLG,
WA_RETURN.
* * 订单号转换
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT‘
EXPORTING
INPUT = ITAB_SER05-PPAUFNR
IMPORTING
OUTPUT = WA_TT-ORDERID.
WA_TT-OPERATION = V_VORNR.
WA_TT-YIELD = ‘1‘.
WA_TT-POSTG_DATE = SY-DATUM.
DATA:C_VORNR TYPE AFVC-VORNR,
C_AUFNR TYPE AFKO-AUFNR,
C_APLZL TYPE AFVC-APLZL,
C_AUFPL TYPE AFVC-AUFPL,
WA_AFVV TYPE AFVV.
CLEAR IT_TT.
REFRESH IT_TT.
CLEAR IT_DR.
REFRESH IT_DR.
SELECT SINGLE AFVC~APLZL AFVC~AUFPL
INTO (C_APLZL, C_AUFPL)
FROM AFVC INNER JOIN AFKO
ON AFVC~AUFPL = AFKO~AUFPL
WHERE AFKO~AUFNR = WA_TT-ORDERID
AND AFVC~VORNR = V_VORNR.
SELECT SINGLE * FROM AFVV INTO WA_AFVV
WHERE AUFPL = C_AUFPL
AND APLZL = C_APLZL.
WA_TT-FIN_CONF = ‘1‘.
WA_TT-CONF_ACTI_UNIT1 = WA_AFVV-VGE01.
WA_TT-CONF_ACTI_UNIT2 = WA_AFVV-VGE02.
WA_TT-CONF_ACTI_UNIT3 = WA_AFVV-VGE03.
WA_TT-CONF_ACTI_UNIT4 = WA_AFVV-VGE04.
WA_TT-CONF_ACTI_UNIT5 = WA_AFVV-VGE05.
WA_TT-CONF_ACTI_UNIT6 = WA_AFVV-VGE06.
WA_TT-CONF_ACTIVITY1 = WA_TT-YIELD * WA_AFVV-VGW01 / WA_AFVV-BMSCH.
WA_TT-CONF_ACTIVITY2 = WA_TT-YIELD * WA_AFVV-VGW02 / WA_AFVV-BMSCH.
WA_TT-CONF_ACTIVITY3 = WA_TT-YIELD * WA_AFVV-VGW03 / WA_AFVV-BMSCH.
WA_TT-CONF_ACTIVITY4 = WA_TT-YIELD * WA_AFVV-VGW04 / WA_AFVV-BMSCH.
WA_TT-CONF_ACTIVITY5 = WA_TT-YIELD * WA_AFVV-VGW05 / WA_AFVV-BMSCH.
WA_TT-CONF_ACTIVITY6 = WA_TT-YIELD * WA_AFVV-VGW06 / WA_AFVV-BMSCH.
* ************************
APPEND WA_TT TO IT_TT.
CALL FUNCTION ‘BAPI_PRODORDCONF_CREATE_TT‘ "主要是这个BAPI
IMPORTING
RETURN = WA_RETURN
TABLES
TIMETICKETS = IT_TT
DETAIL_RETURN = IT_DR.
* 处理BAPI错误
CLEAR I_ERRFLG.
CLEAR I_ERRMSG.
LOOP AT IT_DR INTO WA_DR.
IF WA_DR-TYPE = ‘E‘.
I_ERRFLG = ‘X‘.
I_ERRMSG = WA_DR-MESSAGE.
ELSE.
ENDIF.
IF I_ERRFLG IS INITIAL.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘
EXPORTING
WAIT = ‘X‘.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
MESSAGE E232(ZLC) WITH I_ERRMSG.
DELETE FROM ZPPBG WHERE SERNR = RESULT1-SERNR.
ENDIF.
ENDLOOP.
---------------------
作者:ChampaignWolf
来源:CSDN
原文:https://blog.csdn.net/champaignwolf/article/details/45362637
版权声明:本文为博主原创文章,转载请附上博文链接!
标签:tin exp rms ret cal tsm scope obj 原创文章
原文地址:https://www.cnblogs.com/hdchen/p/10291155.html