According to your needs, you can use FM AIP9_STATUS_READ or FM STATUS_READ.
FM AIP9_STATUS_READ
DATA : lv_objnr TYPE j_objnr,
lv_system_status TYPE j_stext, " (CHAR40)
lv_user_status TYPE j_stext. " (CHAR40)
CONCATENATE 'OR' gv_aufnr INTO lv_objnr.
CALL FUNCTION 'AIP9_STATUS_READ'
EXPORTING
i_objnr = lv_objnr
i_spras = sy-langu
IMPORTING
e_sysst = lv_system_status
e_anwst = lv_user_status.
This will return in each wa list of system and user external status (in requested language) separated by space.
FM STATUS_READ :
DATA : lv_objnr TYPE j_objnr,
lt_status TYPE STANDARD TABLE OF jstat,
lv_status_schema TYPE j_stsma.
CONCATENATE 'OR' gv_aufnr INTO lv_objnr.
CALL FUNCTION 'STATUS_READ'
EXPORTING
objnr = lv_objnr
only_active = 'X'
IMPORTING
stsma = lv_status_schema
TABLES
status = lt_status
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
This will return internal status id in LT_STATUS.
Example (in LT_STATUS-STAT) :
- E0010
- E0026
- I0001
- I0004
- I0016
- I0028
System status start with I.
User status start with E.
Get system status
Check table TJ02T :
IF lt_status IS NOT INITIAL.
SELECT istat, " Internal system status
txt04 " External system status (depending lanquage)
FROM tj02t
INTO TABLE @DATA(lt_tj02t)
FOR ALL ENTRIES IN @lt_status
WHERE istat = @lt_status-stat
AND spras = @sy-langu.
ENDIF.
Get user status
Check table TJ30T :
IF lt_status IS NOT INITIAL.
SELECT estat, " Internal user status
txt04, " External user status (depending lanquage)
txt30 " Status description
FROM tj30t
INTO TABLE @DATA(lt_tj30t)
FOR ALL ENTRIES IN @lt_status
WHERE STSMA = @gv_status_profile
and estat = @lt_status-stat
AND spras = @sy-langu.
ENDIF.
Get user status from Prod order with description
# Check ABAP code below :
SELECT SINGLE objnr FROM caufv INTO @DATA(lv_objnr)
WHERE aufnr = @gv_aufnr.
IF sy-subrc = 0.
" Get status scheme
SELECT SINGLE stsma FROM jsto INTO @DATA(lv_stsma)
WHERE objnr = @lv_objnr.
IF sy-subrc = 0.
" Get user status (extern value) and its description
SELECT tj30t~txt04 AS user_status,
tj30t~txt30 AS description
FROM jest INNER JOIN tj30t ON tj30t~stsma = @lv_stsma
AND tj30t~estat = jest~stat
INTO TABLE @DATA(lt_status)
WHERE jest~objnr = @lv_objnr
AND jest~inact = ''
AND tj30t~spras = @gv_langu.
ENDIF.
ENDIF.
Mass retrieve prod. order status :
SELECT aufk~aufnr,
tj30t~txt04 AS user_status,
tj30t~txt30 AS description
FROM jest
INNER JOIN aufk ON aufk~objnr = jest~objnr
INNER JOIN jsto on jsto~objnr = aufk~objnr
INNER JOIN tj30t ON tj30t~stsma = jsto~stsma
AND tj30t~estat = jest~stat
INTO TABLE @DATA(lt_status)
FOR ALL ENTRIES IN @lt_prodorder
WHERE aufk~aufnr = @lt_prodorder-aufnr
AND jest~inact = ''
AND tj30t~spras = @sy-langu. " <== May be changed with working language
Get system status from Prod order operations with description
Mass retrieve prod. order operations status :
SELECT afvc~aufpl, afvc~aplzl,
tj02t~txt04 AS system_status,
tj02t~txt30 AS description
FROM jest
INNER JOIN afvc ON afvc~objnr = jest~objnr
INNER JOIN tj02t ON tj02t~istat = jest~stat
INTO TABLE @DATA(lt_status_operation)
FOR ALL ENTRIES IN @lt_afvc
WHERE afvc~aufpl = @lt_afvc-aufpl
AND afvc~aplzl = @lt_afvc-aplzl
AND jest~inact = ''
AND tj02t~spras = @sy-langu. " <== May be changed with working language
Search tag : OF, prodord
About the author