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)
Do not forget to enter the currency Reference fields as shown below.
Step2
Have the entries, UserIds vs the Allowed limit of Plan Costs for Release. like shown below
Step3
Put this code in include ZXWO1U02of user-exit IWO10002.Tv_stat
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).
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 we need to put the following code in the include ZXWOCU07 of user-exit IWO10009, which stops the user from Releasing an Order during its Creation (IW31).
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 'E' DISPLAY LIKE 'I'. ENDIF.
This throws the error below if some one tries to do so.
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 But 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.
Regards
KJogeswaraRao