本文主要是介绍ABAP工单状态,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.REL / TECO
CASE is_item-stat.
WHEN ‘E0001’."将INACTI0001打上“X”。
PERFORM inact_change USING is_item-aufnr
CHANGING e_return .
WHEN 'E0003'.lv_user_st = 'RELEASE'. "下达WHEN 'E0004'.lv_user_st = 'TECO_WITH_NOTIF'. "技术完成
ENDCASE.
IF is_item-stat <> 'E0001' .
ls_methods-refnumber = 1.
ls_methods-objecttype = 'HEADER'.
ls_methods-method = lv_user_st. "用户状态
ls_methods-objectkey = is_item-aufnr.
APPEND ls_methods TO lt_methods.IF lt_methods IS NOT INITIAL.CLEAR ls_methods.ls_methods-method = 'SAVE'.APPEND ls_methods TO lt_methods.CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'TABLESit_methods = lt_methodsreturn = lt_returnit_userstatus = lt_usrstat1.IF sy-subrc = 0.LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A' .lv_retmsg = ls_return-message && '-' && lv_retmsg.CLEAR ls_return.ENDLOOP.IF lv_retmsg IS INITIAL.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = abap_true.e_return-zmsgtp = 'S'.e_return-zmsgtx = TEXT-001." MESSAGE S022(ZPM01) INTO e_return-zmsgtx.MESSAGE s024(zpm01) INTO e_return-zmsgtx." e_return-message = '维护工单状态成功!'.ELSE.CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.e_return-zmsgtp = 'E'." e_return-zmsgtx = TEXT-002.MESSAGE e023(zpm01) INTO e_return-zmsgtx.e_return-message = lv_retmsg.RETURN.ENDIF.ENDIF.
ENDIF.
ENDIF.
2.状态激活、取消:
DATA: it_jstat TYPE TABLE OF jstat,is_jstat TYPE jstat.
DATA: lv_objnr TYPE jsto-objnr.
SELECT SINGLE objnr INTO lv_objnr
FROM aufk
WHERE aufnr = pv_aufnr.
is_jstat-stat = ‘I0001’.
is_jstat-inact = ‘X’."取消
APPEND is_jstat TO it_jstat .
CALL FUNCTION ‘STATUS_CHANGE_INTERN’
EXPORTING
client = sy-mandt "当前客户端
objnr = lv_objnr "
TABLES
status = it_jstat
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4.
3.状态变更
DATA: ls_status TYPE jstat.
DATA: lt_status LIKE TABLE OF ls_status.
DATA: lv_objnr TYPE jsto-objnr,
lv_obtyp TYPE jsto-obtyp,
lv_stsma TYPE jsto-stsma,
lv_stonr TYPE tj30-stonr.
SELECT SINGLE objnr INTO lv_objnr
FROM aufk
WHERE aufnr = pv_aufnr.
IF lv_objnr IS NOT INITIAL.
CALL FUNCTION ‘STATUS_READ’
EXPORTING
client = sy-mandt
objnr = lv_objnr
IMPORTING
obtyp = lv_obtyp
stsma = lv_stsma
stonr = lv_stonr
TABLES
status = lt_status
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
- Implement suitable error handling here
ENDIF.
READ TABLE lt_status INTO ls_status WITH KEY stat = ‘E0001’.
IF sy-subrc EQ 0.
IF ls_status-inact IS INITIAL.
" 将用户状态“创建”改为“审批中”
CALL FUNCTION ‘I_CHANGE_STATUS’
EXPORTING
objnr = lv_objnr
estat_inactive = ‘E0001’
estat_active = ‘E0002’
stsma = lv_stsma
EXCEPTIONS
cannot_update = 1
OTHERS = 2.
IF sy-subrc <> 0. -
ENDIF.Implement suitable error handling hereENDIF. ENDIF.
ENDIF.
这篇关于ABAP工单状态的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!