Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Authorization problem

Former Member
0 Likes
1,119

Hi All,

The scenario is such ...the user should not have authorization to directly execute the MB01 transaction.

But there is a Z program which calls MB01 this is also executed by the same user.

But this time the the transaction should be executed .

is this possible & if yes whats the solution?

Thanks & regards

kapil

6 REPLIES 6
Read only

Former Member
0 Likes
797

I think you can block the transaction so that no one will be able to call this. check with the BASIS guys.

If that doesn't work instead of calling the transaction you can call the BAPI BAPI_GOODSMVT_CREATE

Regards,

Ravi

Note : Please mark the helpful answers

Read only

Former Member
0 Likes
797

Hai Kapil

go through this document

In PAI-100

Write Module MOD1.

AUTHORITY-CHECK OBJECT <Object-Name>

ID 'BUKRS' Field V_BUKRS.

ID 'ACTVT' Field '02' '02'--> for Change.

if sy-subrc <> 0.

Message E001 'Your Not Authorized to Enter this Code'.

endif.

Example :

Object Class : FI Field --> F_BKPF_BUK.

AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

ID 'BUKRS' Field V_BUKRS.

ID 'ACTVT' Field '02'.

For example:

program an AUTHORITY-CHECK.

AUTHORITY-CHECK OBJECT <authorization object>

ID <authority field 1> FIELD <field value 1>.

ID <authority field 2> FIELD <field value 2>.

...

ID <authority-field n> FIELD <field value n>.

The OBJECT parameter specifies the authorization object.

The ID parameter specifies an authorization field (in the authorization object).

The FIELD parameter specifies a value for the authorization field.

The authorization object and its fields have to be suitable for the transaction. In most cases you will be able to use the existing authorization objects to protect your data. But new developments may require that you define new authorization objects and fields.

-


go through report

-


TABLES: TOBJT.

DATA: OBJECT1 LIKE USR12-OBJCT,

OBJECT2 LIKE USR12-OBJCT,

OBJECT3 LIKE USR12-OBJCT,

AUTH1 LIKE USR12-AUTH,

AUTH2 LIKE USR12-AUTH,

AUTH3 LIKE USR12-AUTH,

IND LIKE SY-INDEX,

FLAG TYPE I.

DATA: BEGIN OF INTTAB OCCURS 30,

OBJECT LIKE USR12-OBJCT,

AUTH LIKE USR12-AUTH,

END OF INTTAB.

DATA: BEGIN OF INTTAB2 OCCURS 30,

OBJECT LIKE USR12-OBJCT,

AUTH LIKE USR12-AUTH,

EXPL LIKE TOBJT-TTEXT,

END OF INTTAB2.

DATA: BEGIN OF TABSET OCCURS 30,

SFIELD LIKE TOBJ-FIEL1,

VON(18),

BIS(18),

END OF TABSET.

*read up the authorizations from the user buffer

CALL 'ANALYSE_USERBUFFER'

ID 'AUTHS' FIELD INTTAB-SYS.

*filter out the multipy authorizatios of the same object

SORT INTTAB BY OBJECT.

DO.

IF SY-INDEX = 1.

OBJECT1 = ''. AUTH1 = ''.

READ TABLE INTTAB INDEX 1.

OBJECT2 = INTTAB-OBJECT .AUTH2 = INTTAB-AUTH.

READ TABLE INTTAB INDEX 2.

OBJECT3 = INTTAB-OBJECT.AUTH3 = INTTAB-AUTH.

ELSE.

OBJECT1 = OBJECT2. AUTH1 = AUTH2.

READ TABLE INTTAB INDEX SY-INDEX.

OBJECT2 = INTTAB-OBJECT .AUTH2 = INTTAB-AUTH.

IND = SY-INDEX + 1.

READ TABLE INTTAB INDEX IND.

IF SY-SUBRC = 0.

OBJECT3 = INTTAB-OBJECT.AUTH3 = INTTAB-AUTH.

ELSE.

OBJECT3 = ''. AUTH3 = ''.

IF OBJECT2 = OBJECT1 OR OBJECT2 = OBJECT3.

INTTAB2-OBJECT = OBJECT2.

INTTAB2-AUTH = AUTH2.

SELECT SINGLE * FROM TOBJT

WHERE LANGU = SY-LANGU

AND OBJECT = OBJECT2.

INTTAB2-EXPL = TOBJT-TTEXT.

ENDIF.

EXIT.

ENDIF.

ENDIF.

IF OBJECT2 = OBJECT1 OR OBJECT2 = OBJECT3.

INTTAB2-OBJECT = OBJECT2.

INTTAB2-AUTH = AUTH2.

SELECT SINGLE * FROM TOBJT

WHERE LANGU = SY-LANGU

AND OBJECT = OBJECT2.

INTTAB2-EXPL = TOBJT-TTEXT.

APPEND INTTAB2.

ENDIF.

ENDDO.

SORT INTTAB2 BY OBJECT AUTH.

*display the authorization and description, the objects, fields and

*field values

FLAG = 0. OBJECT1 = ''.

LOOP AT INTTAB2.

IF OBJECT1 = INTTAB2-OBJECT.

WRITE: / INTTAB2-AUTH COLOR 2.

PERFORM FIELD_VALUES.

LOOP AT TABSET.

WRITE: / TABSET-SFIELD, TABSET-VON, TABSET-BIS.

ENDLOOP.

ELSE.

SKIP.

WRITE: / INTTAB2-OBJECT COLOR 3, INTTAB2-EXPL COLOR 3.

PERFORM FIELD_VALUES.

WRITE: / INTTAB2-AUTH COLOR 2.

LOOP AT TABSET.

WRITE: / TABSET-SFIELD, TABSET-VON, TABSET-BIS.

ENDLOOP.

ENDIF.

OBJECT1 = INTTAB2-OBJECT.

ENDLOOP.

----


  • FORM FIELD_VALUES *

----


  • retrieve the field values of an authorization *

----


FORM FIELD_VALUES.

TABLES: USR12.

FIELD-SYMBOLS .

DATA: INTFLAG TYPE I VALUE 0, OFF TYPE I, VTYP, LNG TYPE I,

CLNG(2), GLNG(2), FLDLNG TYPE I VALUE 10, SETFILL.

SELECT SINGLE * FROM USR12

WHERE AUTH = INTTAB2-AUTH

AND OBJCT = INTTAB2-OBJECT

AND AKTPS = 'A'.

SETFILL = 0.

REFRESH TABSET.

CLEAR TABSET.

OFF = 2.

ASSIGN USR12-VALS+OFF(1) TO .

WRITE TO VTYP.

WHILE VTYP <> ' ' AND OFF < USR12-LNG.

OFF = OFF + 1.

CASE VTYP.

WHEN 'F'.

OFF = OFF + 5.

ASSIGN USR12-VALS+OFF(2) TO .

WRITE TO CLNG.

LNG = CLNG.

IF LNG <= 0.

EXIT.

ENDIF.

OFF = OFF + 2.

ASSIGN USR12-VALS+OFF(FLDLNG) TO .

WRITE TO TABSET-SFIELD.

OFF = OFF + FLDLNG.

WHEN 'E'.

ASSIGN USR12-VALS+OFF(LNG) TO .

WRITE TO TABSET-VON.

IF TABSET-VON = SPACE.

TABSET-VON = ''' '''.

ENDIF.

APPEND TABSET.

SETFILL = SETFILL + 1.

TABSET-VON = SPACE.

TABSET-BIS = SPACE.

OFF = OFF + LNG.

WHEN 'G'.

ASSIGN USR12-VALS+OFF(2) TO .

WRITE TO CLNG.

GLNG = CLNG.

OFF = OFF + 2.

ASSIGN USR12-VALS+OFF(LNG) TO .

IF INTFLAG = 0.

WRITE TO TABSET-VON.

WRITE '*' TO TABSET-VON+GLNG.

ELSE.

WRITE TO TABSET-BIS.

WRITE '*' TO TABSET-BIS+GLNG.

INTFLAG = 0.

ENDIF.

APPEND TABSET.

SETFILL = SETFILL + 1.

TABSET-VON = SPACE.

TABSET-BIS = SPACE.

OFF = OFF + LNG.

WHEN 'V'.

INTFLAG = 1.

ASSIGN USR12-VALS+OFF(LNG) TO .

WRITE TO TABSET-VON.

IF TABSET-VON = SPACE.

TABSET-VON = ''' '''.

ENDIF.

OFF = OFF + LNG.

WHEN 'B'.

INTFLAG = 0.

ASSIGN USR12-VALS+OFF(LNG) TO .

WRITE TO TABSET-BIS.

IF TABSET-BIS = SPACE.

TABSET-BIS = ''' '''.

ENDIF.

APPEND TABSET.

SETFILL = SETFILL + 1.

TABSET-VON = SPACE.

TABSET-BIS = SPACE.

OFF = OFF + LNG.

ENDCASE.

ASSIGN USR12-VALS+OFF(1) TO .

WRITE TO VTYP.

ENDWHILE.

ENDFORM.

-


go through this link

http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Authorizations.asp

also go through this Document

AUTHORITY-CHECK OBJECT object

ID name1 FIELD f1

ID name2 FIELD f2

...

ID name10 FIELD f10.

Effect

Explanation of IDs:

object Field which contains the name of the object for which the authorization is to be checked.

name1 ... Fields which contain the names of the name10 authorization fields defined in the object.

f1 ... Fields which contain the values for which the f10 authorization is to be checked.

AUTHORITY-CHECK checks for one object whether the user has an authorization that contains all values of f (see SAP authorization concept).

You must specify all authorizations for an object and a also a value for each ID (or DUMMY ).

The system checks the values for the ID s by AND-ing them together, i.e. all values must be part of an authorization assigned to the user.

If a user has several authorizations for an object, the values are OR-ed together. This means that if the CHECK finds all the specified values in one authorization, the user can proceed. Only if none of the authorizations for a user contains all the required values is the user rejected.

If the return code SY-SUBRC = 0, the user has the required authorization and may continue.

The return code is modified to suit the different error scenarios. The return code values have the following meaning:

4 User has no authorization in the SAP System for such an action. If necessary, change the user master record.

8 Too many parameters (fields, values). Maximum allowed is 10.

12 Specified object not maintained in the user master record.

16 No profile entered in the user master record.

24 The field names of the check call do not match those of an authorization. Either the authorization or the call is incorrect.

28 Incorrect structure for user master record.

32 Incorrect structure for user master record.

36 Incorrect structure for user master record.

If the return code value is 8 or possibly 24, inform the person responsible for the program. If the return code value is 4, 12, 15 or 24, consult your system administrator if you think you should have the relevant authorization. In the case of errors 28 to 36, contact SAP, since authorizations have probably been destroyed.

Individual authorizations are assigned to users in their respective user profiles, i.e. they are grouped together in profiles which are stored in the user master record.

Note

Instead of ID name FIELD f , you can also write ID name DUMMY . This means that no check is performed for the field concerned.

The check can only be performed on CHAR fields. All other field types result in 'unauthorized'.

Example

Check whether the user is authorized for a particular plant. In this case, the following authorization object applies:

Table OBJ : Definition of authorization object

M_EINF_WRK

ACTVT

WERKS

Here, M_EINF_WRK is the object name, whilst ACTVT and WERKS are authorization fields. For example, a user with the authorizations

M_EINF_WRK_BERECH1

ACTVT 01-03

WERKS 0001-0003 .

can display and change plants within the Purchasing and Materials Management areas.

Such a user would thus pass the checks

AUTHORITY-CHECK OBJECT 'M_EINF_WRK'

ID 'WERKS' FIELD '0002'

ID 'ACTVT' FIELD '02'.

AUTHORITY-CHECK OBJECT 'M_EINF_WRK'

ID 'WERKS' DUMMY

ID 'ACTVT' FIELD '01':

but would fail the check

AUTHORITY-CHECK OBJECT 'M_EINF_WRK'

ID 'WERKS' FIELD '0005'

ID 'ACTVT' FIELD '04'.

Thanks & Regards

Sreenivasulu P

Read only

Former Member
0 Likes
797

Hi Kapil,

I think what can be done is, attach the transaction code to your custom report e.g. ZMB01.

In case of user authorization , give authorization to this T-Code ZMB01 instead of Txn MB01.

This should serve the purpose.

Regds,

Akshay Bhagwat

Read only

Former Member
0 Likes
797

Hi,

in the INITIALIZATION event of the ZPROGRAM place this code..

ask your Basis to create the authorization object.

AUTHORITY-CHECK OBJECT V_OBJECT
ID 'SHTYP' Field V_SHTYP.
ID 'ACTVT' Field '01' 
if sy-subrc <> 0.
Message
endif.

and then use it in your Zprogram..

this way you can block him to use that transaction.

Regards

vijay

Read only

Former Member
0 Likes
797

Hi,

No it is not possible because ultimately the transaction is called and hence it will check the authorization but u can create a CPICK user which is a communication user which has all SAP authorizations.

Hope this helps.

Seema.

Read only

Former Member
0 Likes
797

Hello Kapil!

I had the same problem once, this was my solution:

Use an Authority Object (set it in the corresponding User Exit) in the standar transation to block the user while exceuting it directly. In program Z with instruction SET PARAMETER ID set a flag, you can read (GET PARAMETER ID )this flag in the same User Exit you set the Autority Check, if the flag is on means the user comes from the Z program, if so with an IF condition skip the autorithy check and clean the flag.

I hope I made myself clear and that this can help you!

Frinee