Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Display PM orders with REL status only

Former Member
0 Kudos
1,457

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

1 ACCEPTED SOLUTION

jogeswararao_kavala
Active Contributor
0 Kudos
299

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

9 REPLIES 9

jogeswararao_kavala
Active Contributor
0 Kudos
299

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

jogeswararao_kavala
Active Contributor
0 Kudos
300

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

0 Kudos
299

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

0 Kudos
299

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

0 Kudos
299

Thank you Raymond . I am benefited from your reply.

Regards

KJogeswaraRao

Ashg1402
Contributor
0 Kudos
299

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

Former Member
0 Kudos
299

Hi,

Thank you very much to all.

Regards

Shankar

0 Kudos
299

This message was moderated.

Former Member
0 Kudos
299

Ok done. Thanks to all.

Thanks and Regards

Shankar