[相关表]
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 =
.