Skip to Content
Author's profile photo Former Member

SD Userexit – I

Making Manual Entry for a Condition-type Possible for Selected Users in Sales order
 

Often there is a requirement for making a condition type (price, discount etc) non-modifiable for some-users and modifiable for others using the same SAP system or modifiable for certain document types (say OR ie Standard Sales Order) and non-modifiable in another order type (say CR ie Credit Memo Request). In standard SAP this is not possible. Using the controls for the condition-type (V/06 transaction) we can either make a condition type 

1.       No Limitations

2.       A : Free

3.       B : Automatic Entry has Priority

4.       C : Manual Entry has Priority

5.       D : Not possible to process manually 

Selecting any one of this option makes the condition type uniform across all document type and for users. Often the requirements are like for a group of users the condition type should behave like C option, for another group like D or for a specific document type it should be A and for others D. 

One of the easiest way to achieve this is through the user-exit USEREXIT_PRICING_PREPARE_TKOMP in the include MV45AFZZ. 

The following code will make the condition type PR00 modifiable for user ABAP1 and non-modifiable for all other users. 

FORM USEREXIT_PRICING_PREPARE_TKOMP.
 
DATA : i_T685A TYPE STANDARD TABLE OF T685A WITH HEADER LINE.
 
IF SY-UNAME = ‘ABAP1‘.
LOOP AT XKOMV.
IF XKOMV-KSCHL = ‘PR00‘.
SELECT * FROM T685A INTO TABLE I_T685A WHERE KSCHL = ‘PR00‘.
READ TABLE I_T685A WITH KEY KSCHL = XKOMV-KSCHL.
I_T685A-KMANU = ‘C‘.
MODIFY I_T685A INDEX SY-TABIX.
MODIFY T685A FROM TABLE I_T685A.
REFRESH I_T685A.
ENDIF.
 
ENDLOOP.
 
ELSE.
LOOP AT XKOMV.
IF XKOMV-KSCHL = ‘PR00‘.
SELECT * FROM T685A INTO TABLE I_T685A WHERE KSCHL = ‘PR00‘.
READ TABLE I_T685A WITH KEY KSCHL = XKOMV-KSCHL.
I_T685A-KMANU = ‘D‘.
MODIFY I_T685A INDEX SY-TABIX.
MODIFY T685A FROM TABLE I_T685A.
REFRESH I_T685A.
ENDIF.
ENDLOOP.
 
ENDIF.
 
ENDFORM.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hi Ashish,

      Good job, keep us updated as and when anything new comes up.

      AK

      Author's profile photo Former Member
      Former Member
      Hi,
      First of all thanks for sharing the code.
      But a big warning: It changes the SD customizing at the DB level!
      >> MODIFY T685A FROM TABLE I_T685A.
      Don't use this code; check Consulting notes OSS 105621 & 1165078 (SAP ERP only) to get similar functionality.
      Regards,
      Franck