Skip to Content
Author's profile photo K Jogeswara Rao

Release strategy for Work Orders based on Plan Cost (user-exit IWO10002)

Hello Friends again,

Thought of preserving a solution evolved while helping a member in a recent discussion

Objective:

To Control Order Release Authorizations using user-exit IWO10002 .

Order Releasing authorities at various levels will have their own limits for Releasing an Order (sometimes called DOP or Delegation Of Powers). Here we are discussing a situation where the Plan Costs should not go beyond the respective limits assigned to the users for Releasing an Order.

The Solution:

Step1

Create a Ztable (say ZPLANCOST) wtih TMG (Table Maintenance Generator to update the Table Entries)

1.JPG

Do not forget to enter the currency Reference fields as shown below.

Capture.JPG



Step2

Have the entries, UserIds vs the Allowed limit of Plan Costs for Release. like shown below

4.JPG

(The column heads User Name and Period value are coming from the data-elements we used in ztable.)

Step3

Put this code in include ZXWO1U02 of user-exit IWO10002.


DATA: v_stat TYPE char1.
SELECT SINGLE iphas FROM afih INTO v_stat WHERE aufnr = caufvd_imp-aufnr.
IF v_stat = '0'.
DATA:v_cost     TYPE bp_wpl,
        v_wrt      TYPE bp_wpl,
        v_wrt01    TYPE bp_wpl,
        v_wrt02    TYPE bp_wpl,
        v_wrt03    TYPE bp_wpl,
        v_wrt04    TYPE bp_wpl,
        v_wrt05    TYPE bp_wpl,
        v_wrt06    TYPE bp_wpl,
        v_wrt07    TYPE bp_wpl,
        v_wrt08    TYPE bp_wpl,
        v_wrt09    TYPE bp_wpl,
        v_wrt10    TYPE bp_wpl,
        v_wrt11    TYPE bp_wpl,
        v_wrt12    TYPE bp_wpl.
SELECT SINGLE cost FROM zplancost INTO v_cost WHERE uname = sy-uname.
SELECT SINGLE wrt01 wrt02 wrt03 wrt04 wrt05 wrt06 wrt07 wrt08 wrt09 wrt10 wrt11 wrt12
FROM pmco INTO ( v_wrt01, v_wrt02, v_wrt03, v_wrt04, v_wrt05, v_wrt06, v_wrt07,
v_wrt08, v_wrt09, v_wrt10, v_wrt11, v_wrt12 ) WHERE  objnr = caufvd_imp-objnr AND
wrttp = '01'.
  v_wrt = v_wrt01 + v_wrt02 + v_wrt03 + v_wrt04 + v_wrt05 + v_wrt06 + v_wrt07 + v_wrt08 +
  v_wrt09 + v_wrt10 + v_wrt11 + v_wrt12.
ENDIF.
IF v_wrt > v_cost.
     MESSAGE: 'Plan costs exceed your DOP limit, Order can not be released.' TYPE 'W' DISPLAY LIKE 'E'.
SET SCREEN 3000.
LEAVE SCREEN.
ENDIF.


With this code in place, when the user ABCD_EFGH tries to release an Order (with CRTD status) where the Plan Cost is more than 5000 the system will throw below error (when clicked on REL flag).

1.JPG


Means the user ABCD_EFGH will not be able to release the Order.

Step4

We are talking about Plan costs, means we are talking about things after the Order is Saved. If someone tries to Release at the time of Order creation itself with excessive plan costs the code will not stop.

For  this purpose  put the following code also after the above code.


IF sy-tcode = 'IW31'.
MESSAGE: 'Order can not be released while creating. Release Order thorugh ''IW32''.' TYPE 'W' DISPLAY LIKE 'E'.
SET SCREEN 3000.
LEAVE SCREEN.
ENDIF.

This throws the error below in the status bar if some one tries toRelease the Order in IW31 itself..

err.JPG


Note

Because we have TMG for Ztable, we will be able to maintain the Table entries in the Ztable (Add, Modify or Delete) in PRD client through SM30.


This solution evolved while my answering the discussion Using Permits to form Release Strategy   The code in the present blog has been improvised to take care of more possibilities of Plan costs.

Conclusion

  • I feel that one valuable thing in the above code is when a member studies and understands the code, he/she understands the table PMCO and its cost fields.
  • These solutions often become significant not for their being able to directly applying and resolving issues, but for triggering ideas and adopting them to our own similar issues. So look for the applications in your own area which could make use of the above solution.

24/05/2016

In another case, one of our scn friends wanted a solution ‘To stop Release of Refurbishment Order when its Plan cost exceeds 60% the Cost of New material’ . The solution code was worked-out, tested and given to him here: Restrict release of refurbishment order, if the Plan cost exceeds 60% or more than cost of new equipment.

26/05/2016

Then there was a challenge. The case is :

Order was Created with Components and not released. Now in IW32, if user makes changes to components tab like altering quantities OR adding more component lines the, this will immediately not reflect on Plan costs. So Order will get Released if the new Plan Costs (to be after save) is more than the limit of the user. To take care of this the following code needs to be put after the above codes.


IF sy-tcode = 'IW32'.
   TYPES: BEGIN OF ty_resb,
            matnr TYPE resb-matnr,
            rspos TYPE resb-rspos,
          END OF ty_resb.
   DATA: it_resb TYPE STANDARD TABLE OF resb WITH HEADER LINE,
         wa_resb LIKE LINE OF it_resb,
         lines   TYPE i,
         lines1  TYPE i.
   SELECT * FROM resb INTO TABLE it_resb WHERE aufnr = caufvd_imp-aufnr.
   DESCRIBE TABLE it_resb LINES lines.
   FIELD-SYMBOLS: <fs_resb> TYPE any.
   DATA: BEGIN OF i_resb OCCURS 0.
           INCLUDE STRUCTURE resb.
   DATA:END OF i_resb.
   ASSIGN ('(SAPLCOBC)resb_bt[]') TO <fs_resb>.
   i_resb[] = <fs_resb>.
   DESCRIBE TABLE i_resb LINES lines1.
   IF lines <> lines1.
     MESSAGE: 'First Save the Order before Release.' TYPE 'W' DISPLAY LIKE 'E'.
     SET SCREEN 3000.
     LEAVE SCREEN.
   ELSE.
     LOOP AT i_resb.
       READ TABLE it_resb INTO wa_resb WITH KEY rsnum = i_resb-rsnum rspos = i_resb-rspos.
       IF sy-subrc = 0.
         IF wa_resb-bdmng <> i_resb-bdmng.
           MESSAGE: 'First Save the Order before Release.' TYPE 'W' DISPLAY LIKE 'E'.
           SET SCREEN 3000.
           LEAVE SCREEN.
         ENDIF.
       ENDIF.
     ENDLOOP.
   ENDIF.
ENDIF.

This code throws the error below in the taskbar if someone modifies the data in Components tab and tries to release a this point. (Code has taken care of Quantities and new lines, additional requirement if any to be addressed by you).

Capture (1).JPG


…And thus this post started very simple and evolved into a complete solution.




Author’s other posts

Regards

KJogeswaraRao

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Amol Khaimar
      Amol Khaimar

      Thank you sir. Great document.

      Regards,

      Amol

      Author's profile photo PS R
      PS R

      K.J. Rao Sir,

      Helpful document to all, since this is an general requirement to almost all the industries.

      Warm Regards,

      PS R

      Author's profile photo Former Member
      Former Member

      Very helpful document !! Thanks Sir

      Regards

      Rubab Zehra

      Author's profile photo Former Member
      Former Member

      Hi Sir,

      Its very useful document. Thank you...

      Regards,

      Sam...

      Author's profile photo Imran Shaik Mohammed
      Imran Shaik Mohammed

      Hi,

      Its a very helpful document. Thank You.

      I will apply this during my roll out to new plants by including the Maintanance plant a one of the fields to segregate this function from other plants.

      Regards

      Imran

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you Imran

      That would serve the real purpose of this post's existence here.

      Regards

      KJogeswaraRao

      Author's profile photo Prashantha N
      Prashantha N

      Excellent document sir.

      Regards,

      Prashantha

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you for the inspiring words Prashantha !

      Regards

      KJogeswaraRao

      Author's profile photo VINAY REDDY
      VINAY REDDY

      sir,

      u r superb,

      it requires lots of patience to present the document in such a manner...

      thanks for u r neat explanation,

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you VINAY 🙂

      Regards

      KJogeswaraRao

      Author's profile photo Former Member
      Former Member

      JRK Sir,

                 hats off, i take a bow sir 🙂

      Thank u very much.

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      No, no Harsh

      I'm humbled with your gesture 🙂 .

      Thank you .

      Regards

      KJogeswaraRao

      Author's profile photo Ravikumar Rathinasamy
      Ravikumar Rathinasamy

      Hello Jogeswara

      Very good documement,

      Do we have any option to restrict the planned cost change after release of maintenance order or again it should go for approval incase any planned cost increase ?

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Yes Ravikumar,

      The logics detailed in the codes above demonstrate the we can manage  all such requirements using exits IWO10002, and IWO10009.  Thanks for your compliments.

      Regards

      KJogeswaraRao


      You may RATE the document.

      Author's profile photo ASHISH SINGHAL
      ASHISH SINGHAL

      Hello sir,

      Its very helpful documentation. I am in need of this functionality in my current project.


      Thank you so much!


      Regards,

      Ashish

      Author's profile photo Former Member
      Former Member

      Neatly documented and informative. Thanks for producing such a nice document.

      Regards

      Rakesh

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you Rakesh,

      Regards

      KJogeswaraRao

      Author's profile photo Abhishek Singh
      Abhishek Singh

      Hello Sir,

       

      It's a Very good and helpful document .

       

       

      Thanks & Regards,

      Abhishek Singh

       

      Author's profile photo Harikrishna Anumandla
      Harikrishna Anumandla

      Excellent Document !!!! Jogeshwara Rao Garu..

      Really fascinating posts by you…

      I guess this logic is applicable only before the fact (pre-release). Is there any way to control the cost of the work order after the fact the order is released? and how to control the cost of work order post release? Would be really helpful to all of us if you can guide us a solution on this scenario too...as it serves end to end process of pre-release and post-release to have control over order costs.