srilikhitha,
See the following code/s which I tested successfully using fms STATUS_READ andSTATUS_CHANGE_EXTERN in include ZXWOCU07 (F/exit EXIT_SAPLCOIH_009 of user-exit IWO10009)..
- Suppose your user-status has present status ABCD and you want to convert to another user-status say OSTS.
- Suppose your status profile is PM_ORD
- Now you need to know the the ESTAT value of the OSTS status to use in the above fm.
- This you'll get from table TJ30T by inputting 'PM_ORD' in STSMA field and 'OSTS' in the TXT04 field.
- Suppose you got the ESTAT value as 'E0004'.
Now the code for changing the User-status to OSTS while saving the Order will be:
CALL FUNCTION 'STATUS_CHANGE_EXTERN'
EXPORTING
objnr = caufvd_imp-objnr
user_status = 'E0004'
set_inact = ' '.
After this whenever you Save the Order you'd find that the user status is changed to OSTS. At the same time you'd find the asttx value has also changed to OSTS.
Now the thing remains is:
- The above code should be applicable only when the linked Notification System status reads OSTS (means Outstanding Task).
- Now I need the ISTAT value of System status OSTS (to be used in the fm STATUS_READ) which I got from table TJ02T which is I0158 (This value is same for you and me).
This is the full code to be used in the same place explained above.
DATA:i_stat LIKE jstat OCCURS 0 WITH HEADER LINE,
l_objnr TYPE j_objnr.
SELECT SINGLE objnr FROM viqmel INTO l_objnr WHERE qmnum = caufvd_imp-qmnum.
CALL FUNCTION 'STATUS_READ'
EXPORTING
objnr = l_objnr
only_active = 'X'
TABLES
status = i_stat.
LOOP AT i_stat.
IF i_stat-stat = 'I0158'.
CALL FUNCTION 'STATUS_CHANGE_EXTERN'
EXPORTING
objnr = caufvd_imp-objnr
user_status = 'E0004'
set_inact = ' '.
ENDIF.
ENDLOOP.
Hope you'll be able to understand and make use of this solution worked-out for you. Please revert in case of any doubts.
Regards
KJogeswaraRao