ABAP读取工单状态函数优化STATUS_READ

ZSTATUS_READ
1.如下是获取工单状态类,可以自行转换RFC或者代码
METHOD GET_PO_STATUS_LINES BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING JEST TJ02 TJ04 TJ02T AUFK.
–完成生产订单抬头状态的转换
ET_PO_STATUS =
SELECT AUFNR,STRING_AGG(TXT04,‘-’ ORDER BY LINEP,STATP,TXT04) AS PO_STATUS FROM (
SELECT AUFNR,OBJNR,STAT,LINEP,STATP,TXT04,TXT30
FROM (
SELECT DISTINCT T1.AUFNR,T2.OBJNR,T2.STAT,T5.TXT04,T5.TXT30,T3.NODIS,IFNULL(T4.LINEP,99) AS LINEP ,IFNULL(T4.STATP,99) AS STATP FROM AUFK T1
INNER JOIN :IT_RESULT_PO T0
ON T1.AUFNR = T0.AUFNR
LEFT JOIN JEST T2
ON T1.OBJNR = T2.OBJNR AND T2.INACT = ‘’
LEFT JOIN TJ02 T3
ON T2.STAT = T3.ISTAT AND T3.NODIS = ‘’
LEFT JOIN TJ04 T4
ON T2.STAT = T4.ISTAT AND T4.OBTYP = ‘ORH’
LEFT JOIN TJ02T T5
ON T2.STAT = T5.ISTAT AND T5.SPRAS = ‘1’
WHERE
–T1.OBJNR = ‘OR000001000040’ AND
T1.MANDT = :LV_CLIENT AND T2.MANDT = :LV_CLIENT
AND T3.NODIS IS NOT NULL
ORDER BY T2.STAT
)
)
GROUP BY AUFNR;

ENDMETHOD.

METHOD GET_RESB_OBJNR BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING AFKO TJ02 TJ04 TJ02T RESB JEST.
–完成生产订单组件明细状态的转换
ET_RESB_OBJNR =
SELECT AUFNR,MATNR,CASE WHEN LOCATE(STRING_AGG(TXT04,‘-’ ORDER BY LINEP,STATP,TXT04),‘-’) > 0 THEN SUBSTR_BEFORE(STRING_AGG(TXT04,‘-’ ORDER BY LINEP,STATP,TXT04),‘-’)
ELSE STRING_AGG(TXT04,‘-’ ORDER BY LINEP,STATP,TXT04) END AS PO_STATUS FROM (
SELECT AUFNR,MATNR,OBJNR,STAT,LINEP,STATP,TXT04,TXT30
FROM (
SELECT DISTINCT T1.AUFNR,T6.MATNR,T2.OBJNR,T2.STAT,T5.TXT04,T5.TXT30,T3.NODIS,IFNULL(T4.LINEP,99) AS LINEP ,IFNULL(T4.STATP,99) AS STATP FROM AFKO T1
INNER JOIN RESB T6
ON T1.RSNUM = T6.RSNUM
INNER JOIN :IT_RESULT_RESB T0
ON T0.AUFNR = T1.AUFNR AND T0.MATNR = T6.MATNR
LEFT JOIN JEST T2
ON T6.OBJNR = T2.OBJNR AND T2.INACT = ‘’
LEFT JOIN TJ02 T3
ON T2.STAT = T3.ISTAT AND T3.NODIS = ‘’
LEFT JOIN TJ04 T4
ON T2.STAT = T4.ISTAT AND T4.OBTYP = ‘OKP’
LEFT JOIN TJ02T T5
ON T2.STAT = T5.ISTAT AND T5.SPRAS = ‘1’
WHERE
–T1.AUFNR = ‘000000800000’ AND
T1.MANDT = :LV_CLIENT AND T2.MANDT = :LV_CLIENT AND T6.“MANDT” = :LV_CLIENT
AND T3.NODIS IS NOT NULL
ORDER BY T2.STAT
)
)
GROUP BY AUFNR,MATNR
;

ENDMETHOD.

你可能感兴趣的:(ABAP,SAP,abap,SAP)