Continuing the process of preserving the solutions to Frequently Asked Questions, today I chose this subject. Few might have understood the possible need behind this simple title. However, I will explain.
There were threads asking for solution where they want Orders with some status to be prohibited from processing. The ‘Do not Execute‘ function is the ready answer for the Orders which are in CRTD status. But generally the queries were for REL Orders? There are two situations of this requirement.
- In Case1, customer wants all the Orders of certain Order type and in REL status are to be prevented from changes, Only viewing should be possible through IW32.
- In Case2, specific Orders faultily created and released need to be prevented from processing.
Similarly there were queries where Authorization check at the initial screen of IW32 was sought. Obviously this as an alternative route to control through Roles.
- We take this as Case3 of this blog .
One way of doing addressing all these is definitely through user-exit IWO10009. But this method stops users at the time of Saving the Order. Means, user spends time and effort to make all changes in the Order and system refuses his changes when he tries to Save the Order. Also achieving a perfect solution for Cases1,2 through user-status (OIBS) transaction control is not possible.
So the requirement is to stop the user in the beginning itself of IW32. The ways to do it.
- Change the IW32 to display mode for all such Orders
- Stop user at the initial screen of IW32 itself by throwing a message such as ‘This Order is prohibited from changes, use IW33 for viewing‘ OR ‘You are not authorized for IW32‘ .
The solutions discussed here are very effective using an Implicit Enhancement point in the include LCOIHF7R of Order program (SAPLCOIH). Here there is an enhancement point at the end of the form AUTHORITY_CHECK_AUART_SMOD .
The place to put our code:
Means, I have created an Enhancement named ZPM_STAT at the enhancement point provided by the system, where I got access to put my code. Now let’s see the codes for various cases and situations.
First we look at the Case1, Situation1: For all Orders of certain Type and in REL status, Converting IW32 to Display mode
IF caufvd-auart = 'ZM03' AND sy-tcode = 'IW32' AND caufvd-iphas = '2'. tc10-trtyp = 'A'. "Replace 'V' by 'A'. MESSAGE: 'Changing to Display' TYPE 'S'. ENDIF.
This code turns IW32 to Display mode for all released ZM03 Orders (you will change this Order type to yours)
Case1: Situation2: For all Orders of certain Type and in REL status, Stopping user to enter the Order through IW32.
IF caufvd-auart = 'ZM03' AND sy-tcode = 'IW32' AND caufvd-iphas = '2'. MESSAGE: 'This Order has been prohibited from changes. For viewing use tcode ''IW33''.' TYPE 'E' DISPLAY LIKE 'I'. ENDIF.
This throws this error popup at the initial screen of IW32 for all ZM03 Released Orders.
In cases like this, the user can do TECO and CLSD through IW38.
Now let’s look at Case2
Case2: Specific Orders to be barred from handling. Means users to be stopped at the initial screen of IW32.
Obviously, these Orders can be any type. Because this requirement as mentioned earlier is often for defective Creations which were already put into REL status.
Pre-requisite to handle this situation
Create a Ztable say ZPM_BLK_ORD having the Order(aufnr) field. (If you want more Order related fields you can have). Create this table with TMG (Table maintenance Generator) so that you will be able to update this table (Add/Delete) with Order numbers through tcode SM30 or through a Ztcode.
Now, the code in this case.
DATA: v_aufnr TYPE aufk-aufnr. CLEAR: v_aufnr. SELECT single aufnr FROM zpm_blk_ord INTO v_aufnr WHERE aufnr = caufvd-aufnr. IF v_aufnr IS NOT INITIAL. MESSAGE: 'This Order has been prohibited from changes.' TYPE 'E' DISPLAY LIKE 'I'. ENDIF.
This also throws similar error popup as shown earlier when user tries to use IW32 for all such Orders which are entered in the ztable ZPM_BLK_ORD.
Now let’s see the Case3.
Case3: Specific Users to be restricted from handling IW32.
Pre-requisite to handle this situation
Create a Ztable say ZPM_BLK_USR having the UserId(uname) field. As above create this table with TMG .
Now the code in this case.
DATA: v_uname TYPE uname. CLEAR: v_uname. SELECT single uname FROM zpm_blk_usr INTO v_unmae WHERE uname = sy-uname. IF v_uname IS NOT INITIAL. MESSAGE: 'You are not authorized for IW32.' TYPE 'E' DISPLAY LIKE 'I'. ENDIF.
This also throws similar error popup as shown earlier when user tries to use IW32 , whose userId has been included in the ztable ZPM_BLK_USR..
We may have several similar situations. How this post helps is, it is giving the information about the enhancement point and giving sample codes which will be helpful in meeting similar requirements. All cases other than already illustrated can be very easily managed through simple changes in the codes given.
Hope members will find this post useful.
Thank you and Regards