Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Approval Procedure

Hi,

In Business Partner Form I created an UDF for Approval Status and set a valid values as Approved and Not Approved. Default value is Not Approved.

If user creates a new vendor it will be Not Approved in Default. Only the Authorized super user can Approved the vendor. For this i created a procedure. The code follows:

IF (@transaction_type = 'A' or @transaction_type = 'U') AND @Object_type = '2'

Begin

DECLARE @usersign int, @appsts nvarchar(20)

SELECT @usersign=usersign,@appsts=U_appsts from dbo.OCRD where cardcode=@list_of_cols_val_tab_del

IF (@usersign not in (select userid from ousr where userid='1') and @appsts='A')

SELECT @ERROR = 1, @ERROR_MESSAGE = 'Only Authorized user can change the Status'

ELSE

SELECT @ERROR = 0, @ERROR_MESSAGE = 'SUCCESSFULLY UPDATED'

End

Here the problem is if User A has the rights & if a record created in user A then he is able to Approve it but User A is unable to Approve the record created by User B even though it has rights. Plz give me the solution.

Thanks in Advance,

Regards,

Madhavi

Former Member
replied

Hi,

I have a work around beside using your solution.

I suggest to create a UDF named approver, so it will be U_Approver. Assigned this FMS :

SELECT t1.userid from 
 OUSR T1 WHERE T1.INTERNAL_K = $[user]

Using the above FMS, it will make the UDF to be filled with userid number. Then make the field is unable to edit in all the users except in the user manager (user id 1). This can be done using UDF settings (CtrlshiftB) --> untick the active column of the field. So, it won't be able to change by all the users.

Use this following SP_TN :


IF (@transaction_type = 'A' or 
@transaction_type = 'U') AND @Object_type = '2'
Begin
DECLARE @usersign int, @appsts nvarchar(20), 
@approver nvarchar(20)

SELECT @usersign = usersign, @appsts = U_appsts, 
@approver = U_approver from dbo.OCRD 
where cardcode=@list_of_cols_val_tab_del
if (@appsts = 'A' and @approver <> '1')
SELECT @ERROR = 1, @ERROR_MESSAGE = 
'Only Authorized user can change the Status'
End

So, when user id = 1 open and want to approve, it will be available to do by override the approver value.

userid 1 can do that by shift+F2 or just type 1. After userid 1 changed the approver to be 1,, then userid 1 changes the U_Appsts to be approve. After changed, click update button.

It will be succesfully updated.

Rgds,

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question