Update Order user-status upon Save of Notification or Order‘ : Obviously we are talking about linked Notification-Order Scenario .

Dear Friends,

To my approximation I gave around 150 enhancement solutions so far while answering the queries. Among these I felt like documenting few (7 so far) because of their complex and interesting nature. I felt that the present one too is of similar nature and forum will be benefited if it is presented in the form of a technical blog.

So here it is:…….

It is about a recent call for help, where the member was seeking solution for her requirement which was expressed as:  When particular Task  is open in the Notification, how to update the user status in IW31/32 on Service Order . Please Suggest.” .


I felt this is another opportunity to contribute few lines of enhancement code to the forum. I gave the solution ie., the user-exit and the code. The code reads the System status of the Notification, if it finds OSTS (outstanding task) then it sets a specific user status (say ABCD) to the Order, obviously during Save (of Order as the requirement sounded).


The member then clarifies like: “No no, I do not want during Order Save, It to happen while Notification Save“.  Then I gave that solution too, other user-exit, and corresponding code obviously.


So here we are going to see both the solutions for

  1. Updating Order User-status during Order Save if Notification has outstanding tasks. (user-exit IWO10009,  F/exit EXIT_SAPLCOIH_009)
  2. Updating the Order User-status during Notification Save if Notification has outstanding tasks. (user-exit QQMA0014,  F/exit EXIT_SAPMIWO0_020)

Before we see the individual solution codes for both of these, let’s first look at the logic.

  • The start point is to know whether any outstanding Task is there in the Notification. This means Notification system status will have OSTS value.
  • To know this we need to use function module STATUS_READ. The input to this fm is Notification OBJNR value which we get from QMEL or VIQMEL table.
  • But the output from the above fm will be in code (not in text format OSTS). We need to know this code for our coding. This is known from table TJ02T when we input value ‘OSTS’ in the field ‘TXT04′  and ‘E’ in field SPRAS. We get the value asI0158‘ . (This common for you, me and for all others)
  • So in the code we need to tell to update the Order status to ‘ABCD’ if the Notification user status code is ‘I0158′.
  • We need to use function module ‘STATUS_CHANGE_EXTERN’ to update the Order user-status.
  • This fm works OBJNR value of Order as input which is
    • Readily available as a field in the Import structure (caufvd_imp) of the user-exit if it is case1 above
    • Need to get it from table AUFK if it is case2..
  • But this fm too needs code only not the text of user status (ABCD) to set it in Order. So how do we get it?
  • We get it from table TJ30T by inputting the Status profile of Order in field STSMA, value ‘ABCD’ in field TXT04 and value ‘E’ in field SPRAS. Let’s assume we got this as ‘E0004‘.
  • Now we are ready for coding.

If it is the case1, ie., Updating Order User-status during Order Save if Notification has outstanding tasks, we need to put the following code in include ZXWOCU07.


And the code is:

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_impqmnum.

CALL FUNCTION ‘STATUS_READ’

   EXPORTING

     objnr       = l_objnr

     only_active = ‘X’

   TABLES

     status      = i_stat.

LOOP AT i_stat.

   IF i_statstat = ‘I0158’.

     CALL FUNCTION ‘STATUS_CHANGE_EXTERN’

       EXPORTING

         objnr       = caufvd_impobjnr

         user_status = ‘E0004’

         set_inact   = ‘ ‘.

   ENDIF.

ENDLOOP.




If it is case2: Updating the Order User-status during Notification Save if Notification has outstanding tasks, we need to use the code below in the include ZXQQMU20.

The code is:

  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_viqmelaufnr.

   CALL FUNCTION ‘STATUS_READ’

     EXPORTING

       objnr       = i_viqmelobjnr

       only_active = ‘X’

     TABLES

       status      = i_stat.

   LOOP AT i_stat.

     IF i_statstat = ‘I0158’.

       CALL FUNCTION ‘STATUS_CHANGE_EXTERN’

         EXPORTING

           objnr       = l_objnr

           user_status = ‘E0004’

           set_inact   = ‘ ‘.

     ENDIF.

   ENDLOOP.

Note:

  • Though already mentioned in the logic points above, I want to remind about the ‘E0004‘ code used in the codes above. you have to get this value from table TJ30T by inputting your Order status profile in field STSMA, the user-status to be set in Order in field TXT04 and  ‘E’  in field SPRAS.
  • Both the codes I tested before posting to that discussion. If you are going to use, test well for its satisfactory working in the Dev servers.

…..And thus we arrive at the end of this post..

Thank you and Regards

KJogeswaraRao

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply