1: 获取生产订单的对象标识
SELECT SINGLE objnr INTO l_objnr FROM aufk WHERE aufnr = "[订单号]"
2:获取系统状态
DATA BEGIN OF i_status OCCURS 0.
INCLUDE TYPE jstat.
DATA END OF i_status.
CALL FUNCTION 'STATUS_READ'
EXPORTING
client = sy-mandt
objnr = l_objnr
only_active = 'X'
TABLES
status = i_status
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
SELECT txt04 INTO TABLE l_txt
FROM tj02t
FOR ALL ENTRIES IN i_status
WHERE istat = i_status-stat
AND spras = '1'.
3:获取用户最终状态
SELECT MAX( estat ) INTO l_maxestat FROM tj30 WHERE stsma = l_stsma.
SELECT SINGLE stat FROM jest INTO l_stat
WHERE objnr = l_objnr AND stat LIKE 'E%' AND inact NE 'X'.
4: 同时获取系统状态用户状态
DATA BEGIN OF i_status OCCURS 0.
INCLUDE TYPE jstat.
DATA stsma LIKE jsto-stsma.
DATA sttxt LIKE bsvx-sttxt.
DATA stonr LIKE tj30-stonr.
DATA END OF i_status.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
client = sy-mandt
flg_user_stat = ' '
objnr = l_objnr
only_active = 'X'
spras = '1'
bypass_buffer = 'X'
IMPORTING
line = i_status-sttxt
e_stsma = i_status-stsma
stonr = i_status-stonr.
APPEND i_status.
DELETE ADJACENT DUPLICATES FROM i_status COMPARING ALL FIELDS.
5:系统用户状态相关表
JSTO-STSMA = TJ30-STSMA = TJ30T-STSMA
TJ30-ESTAT = JEST-ESTAT = TJ30T-ESTAT = TJ02-ISTAT = TJ02T-ISTAT "I开头的状态