*在sap中对于如何获取订单的状态,提供了至少两个函数(我自己知道的),分别是 status_read 和 status_text_edit。下面简单介绍这两个函数
*1.status_read 改函数的实现原理大概是通过订单的对象好(or+订单号) 到jest中取出字段stat inact.
*jest表中stat是一串从字面看不出意思的字符,可以根据stat到表tj02t中找到具体的描述。
*下面是具体用法
DATA:objnr TYPE aufk-objnr.
objnr = 'OR000000100014'.
DATA:t_status TYPE TABLE OF jstat WITH HEADER LINE.
"结果存放在STATUS表中
CALL FUNCTION 'STATUS_READ'
EXPORTING
client = sy-mandt
objnr = objnr
TABLES
status = t_status
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT t_status.
IF t_status = 'I0046'.
WRITE:'订单已关闭'.
EXIT.
ENDIF.
ENDLOOP.
"2.status_text_edit 改函数读取的结果是将订单状态拼接到一个字符串中,而且这个字符串是在前台订单上看到的状态,比较直接,这样做的结果就可能由于状态较多导致长度过长,在某些情况下取的数据可能不准。
"下面是一段代码
DATA:line TYPE bsvx-sttxt.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
client = sy-mandt
objnr = objnr
spras = sy-langu
IMPORTING
line = line
EXCEPTIONS
object_not_found = 1
OTHERS. "
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
SEARCH line FOR 'CLSD'.
IF sy-subrc = 0.
WRITE:'订单已关闭'.
ENDIF.
DATA i_jstat LIKE jstat OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'STATUS_READ'
EXPORTING
client = sy-mandt
objnr = i_caufv_resb-objnr "对象号
only_active = 'X'
* IMPORTING
* OBTYP =
* STSMA =
* STONR =
TABLES
status = i_jstat "目前的所有状态
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
LOOP AT i_jstat WHERE stat = 'I0013' "DLT 删除标识符.
OR stat = 'I0012' "DLV 交货
OR stat = 'I0045' "TECO 技术实现
OR stat = 'I0043' "LKD 冻结
OR stat = 'I0001' "CRTD 建立
OR stat = 'I0046' "CLSD 已结算
OR stat = 'I0076'. "DLID 删除标志
l_delete = 'X'.
EXIT.
ENDLOOP.
ABAP 获取工单状态的两个函数 STATUS_TEXT_EDIT 和 STATUS_READ 的简单介绍
最新推荐文章于 2024-07-08 18:27:31 发布