05-27-2016 1:31 PM
Dear Guru's
Good day. I Need some help for an issue. Currently i have a program to display the list of work order. I am also fetching the status of the work order by objnr in viaufkst and getting the status text using FM STATUS_TEXT_EDIT. Now my issue is only need display the work order with Status REL . In case if the work order is with Status TECO i need to delete the particular work order from the internal table. .Please kindly assist. below is the code I'm using to get status.
SELECT SINGLE objnr FROM viaufkst CLIENT SPECIFIED INTO g_objnr
WHERE mandt = sy-mandt AND aufnr = wa_get_mic-aufnr.
IF g_objnr IS NOT INITIAL.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
client = sy-mandt
flg_user_stat = 'X'
objnr = g_objnr
only_active = 'X'
spras = sy-langu
bypass_buffer = 'X'
IMPORTING
* ANW_STAT_EXISTING =
* E_STSMA =
line = line
* USER_LINE =
* STONR =
* EXCEPTIONS
* OBJECT_NOT_FOUND = 1
* OTHERS = 2
Thanks and Regards
SBM
05-27-2016 3:41 PM
balaji
One easy method without any fm or objnr, but only by using simply the Order number.
TABLES:afih.
SELECT-OPTIONS: so_aufnr FOR afih-aufnr.
TYPES: BEGIN OF ty_ord,
aufnr TYPE aufnr,
iphas TYPE pm_phase,
END OF ty_ord.
DATA: it_ord TYPE TABLE OF ty_ord.
SELECT aufnr iphas FROM afih INTO TABLE it_ord WHERE aufnr IN so_aufnr.
DELETE it_ord WHERE iphas <> '2'.
Means: The field IPHAS in table AFIH indicates the Order status and if it is '2' then it is an order with system status REL. So at the end of the code above the internal table it_ord is left with all REL orders.
Good luck
KJogeswaraRao
05-27-2016 2:34 PM
balaji
You should go for fm STATUS_READ ins place of STATUS_TEXT_EDIT. Here you will get individual statuses in a table. See this example:
DATA:i_stat LIKE jstat OCCURS 0 WITH HEADER LINE,
l_objnr TYPE j_objnr.
SELECT SINGLE objnr FROM aufk INTO l_objnr WHERE aufnr = i_viqmel-aufnr.
CALL FUNCTION 'STATUS_READ'
EXPORTING
objnr = i_viqmel-objnr
only_active = 'X'
TABLES
status = i_stat.
Here you have the internal table i_stat with all active system statuses of the particular Order. Now
LOOP AT i_stat.
IF i_stat-stat = 'I0002'.
< your code>
ENDIF.
ENDLOOP.
Hope you've understood that I0002 is the REL status.
Good luck
KJogeswaraRao
05-27-2016 3:41 PM
balaji
One easy method without any fm or objnr, but only by using simply the Order number.
TABLES:afih.
SELECT-OPTIONS: so_aufnr FOR afih-aufnr.
TYPES: BEGIN OF ty_ord,
aufnr TYPE aufnr,
iphas TYPE pm_phase,
END OF ty_ord.
DATA: it_ord TYPE TABLE OF ty_ord.
SELECT aufnr iphas FROM afih INTO TABLE it_ord WHERE aufnr IN so_aufnr.
DELETE it_ord WHERE iphas <> '2'.
Means: The field IPHAS in table AFIH indicates the Order status and if it is '2' then it is an order with system status REL. So at the end of the code above the internal table it_ord is left with all REL orders.
Good luck
KJogeswaraRao
05-29-2016 7:16 PM
Hi Klogeswara Rao,
Thanks a lot for your reply. It was really helpful . I manage to solve it by your second suggestion.
Thanks and Regards
Shankar
06-06-2016 2:22 PM
For reference, if you want to check on a status not related to IPHAS
" TJ02T : (En) REL = I0002
SELECT * INTO TABLE itab FROM aufk
WHERE aufnr IN s_aufne " add your criteria
AND EXISTS ( SELECT * FROM jest WHERE objnr EQ aufk~objnr AND stat = 'I0002' AND inact = ' ' ).
Regards,
Raymond
06-06-2016 2:34 PM
Thank you Raymond . I am benefited from your reply.
Regards
KJogeswaraRao
05-27-2016 8:44 PM
Hi,
There is a better option rather then selecting the orders and doing a loop for status read.
There is a tcode iw38, the report for this is RIAFUK20 , in this there are fields for status and order numbers.
Go through that report and check the field names in the selection screen.
In your code use SUBMIT <REPORT NAME> and put the conditional values for the status field.
It will be very optimized and useful .
Check table JEST & JSTO for status.
Regards
Ashish
05-29-2016 7:16 PM
05-29-2016 8:02 PM
05-30-2016 4:11 AM