Hello friends,

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.

The Background:

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:

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:

1.JPG

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

The code:


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.

The code:


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.

Capture.JPG.

NOTE:

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



Conclusion

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

KJogeswaraRao

To report this post you need to login first.

6 Comments

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

  1. VINAY REDDY

    sir,

    tc10-trtyp = ‘A’

    similarly can we disable(grey out the field) a particular field in standard transaction,

    like the data into that field should be taken from Ztable..

    (0) 
    1. K Jogeswara Rao Post author

      Hello VINAY,

      Good question.

      That’s been a pending job for me to verify since very long. In fact I posted this document when I got clues from some post in SCN for my task of disabling fields after REL status. Manytimes I thought of verifying it whether this is a local coding or applicable to other areas? So you may please verify on your own. My instinct says should be nearly matching with other standard programs in the corresponding authority check forms. The form here is authority_check_auart_SMOD.

      Thank you for liking this post VINAY.

      Regards

      KJogeswaraRao

      (0) 
      1. VINAY REDDY

        sir,

        i found this badi in scn IWO1_SCREEN_MODIFY for (IW32),

        and i have tested it , by using this i was able to grey out non mandatory fields

        by writing the below code,

        if screen-name = ‘CAUFVD-KTEXT’.   

        screen-input = 0.

        MODIFY SCREEN.

        endif.

        and at the time of save updating the field with required text by your code(

        How to default values to Notifications and Orders ?)

        if sy-tcode eq ‘IW31’ and  caufvd_imp-auart = ‘PM80’.

              caufvd_imp-ktext = ‘Vin Order’.

            CALL FUNCTION ‘CO_IH_SET_HEADER’
              EXPORTING
                caufvd_imp = caufvd_imp.

            PERFORM header_update(saplcoih).

        ENDIF.

        please correct me if any mistakes…

        (0) 
  2. Pavan Kumar CS

    Nice document Sir.

    I used it to block a particular order type. Initially opted for user exit IWO10009, which only checks while saving. Now in initial screen itself user will be notified.

    (0) 

Leave a Reply