cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict user update Item group in Item master data

Former Member
0 Kudos

Hi all,

i would like to Restrict user update Item group in Item master data.

I want to allow only manager user to modify the Item group in the item master data.

Please help me modify this TN.

If @object_type='4' and @transaction_type='U'

BEGIN

If Exists

(Select T0.ItemCode from OITM T0 Inner Join AITM T1

On T0.ItemCode=T1.ItemCode

Where T0.ItmsGrpCod<>T1.ItmsGrpCod and

And T0.ItemCode = @list_of_cols_val_tab_del)

BEGIN

Select @error = -1,

@error_message = 'You can not change Item Group'

End

End

Thanks in advance.

Kind Regads,

O.

Accepted Solutions (1)

Accepted Solutions (1)

KennedyT21
Active Contributor
0 Kudos

Hi

If you use the max of log instance it will solve i believe try this way...

BEGIN

If Exists

(Select max (T1.LogInstanc) from OITM T0

Inner Join AITM T1 On T0.ItemCode=T1.ItemCode

Where T0.ItmsGrpCod<>T1.ItmsGrpCod and

And T0.ItemCode = @list_of_cols_val_tab_del)

BEGIN

Select @error = -1,

@error_message = 'You can not change Item Group'

End

End

Hope Helpful

Regards

Kennedy

Former Member
0 Kudos

Hi Kennedy, i think you version can be good for me.

I still have problems.

1. I need to allow the modification for the manager user.

2. If I make any modification for this, I cannot do it, it gives me the error message from the sp. But i just wanted to change the description of that Item.

I have try the other querries from above, the join is not working for the OUSR, I need to check the currently loged in user against the manager. Is it possible?

Many thanks so far,

Kind regards,

Ottó

former_member204969
Active Contributor
0 Kudos

Use this to restrict the modification of the item group for the manager only:

IF @object_type = '4' and @transaction_type ='U'

Begin

declare @li int

set @li=(select max(a.loginstanc) from AITM a

where a.Itemcode=@list_of_cols_val_tab_del)

If exists

(select 1 FROM AITM T0

  Inner join OITM T1 ON T0.Itemcode = T1.ItemCode and T0.Loginstanc=@li

Where T1.ItemCode=@list_of_cols_val_tab_del

   and T1.Usersign2 !=1   -- for manager  

   and T0.ItmsGrpCod<>T1.ItmsGrpCod )

Select @error =1,

    @error_message = 'You schould not change item group !'

End

Former Member
0 Kudos

Thank you István,

I can use this, and modify for the customer's needs.

Thanks a lot.

Kind regards,

Ottó

Answers (2)

Answers (2)

former_member1269712
Active Contributor
0 Kudos

Hi Otto,

Try this...

If @object_type='4' and @transaction_type='U'

    BEGIN

        If Exists

            (SELECT OT.[ItemCode] FROM OITM OT 

            INNER JOIN OITB T0 ON OT.ItmsGrpCod = T0.ItmsGrpCod

            INNER JOIN OUSR T1 ON T0.userSign2 = T1.USERID

            WHERE OT.ItemCode = @list_of_cols_val_tab_del

            and OT.[ItmsGrpCod] <> T0.[ItmsGrpCod] and T1.User_code != 'Manager')

        BEGIN

            Select @error = -1,

            @error_message = 'You can not change Item Group'

        End

    End

   

Regards,

Sachin D

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi Nanassi Otto,

Try this:

If @object_type='4' and @transaction_type='U'

BEGIN

If Exists

(SELECT T0.[ItemCode] FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OUSR T2 ON T1.userSign2 = T2.USERID WHERE T0.ItemCode = @list_of_cols_val_tab_del) and T0.[ItmsGrpCod] <> T1.[ItmsGrpCod] and t2.user_code != 'log02'

BEGIN

Select @error = -1,

@error_message = 'You can not change Item Group'

End

End

Note: added OITB and OUSR table in your query.

Thanks & Regards,

Nagarajan