Sy subrc 12

ABAP Keyword Documentation → ABAP − Reference → Authorizations

Quick Reference

Other versions: 7.31 | 7.40 | 7.54


AUTHORITY-CHECK OBJECT auth_obj [FOR USER user] ID id1 {FIELD val1}|DUMMY [ID id2 {FIELD val2}|DUMMY][ID id10 {FIELD val10}|DUMMY].


… FOR USER user


This statement checks whether an authorization is entered in the user master record of the current user or of the user specified in user for the authorization object entered in auth_obj, and whether this authorization is sufficient for the request specified in the statement. If the addition FOR USER is not specified, the authorization of the current user is checked.

auth_obj expects a flat character-like field containing the name of an authorization object in upper case. The following can be specified for auth_obj:

  • Literal or constants If the data object auth_obj is specified as a character literal or as a constant, it can be evaluated statically and the specified authorization object is identified as the used object.
  • Variable If the data object auth_obj is specified as a variable, it is specified only dynamically and the content is not evaluated statically.

If id1 … id10 is specified, at least one and a maximum of 10 different authorization fields must be specified for the authorization object in question. id1 … id10 expects flat character-like fields containing the names of the authorization fields in uppercase. If an authorization field is specified that does not appear in the authorization object, checks are not possible and sy-subrc is set to 4. Each specified authorization field expects either a value to be checked by FIELD in a flat character-like field val1 … val10 or the addition DUMMY. The value being checked can have a maximum of 40 characters and no more than 40 places from val1 … val10 are evaluated. Fields that are longer produce a warning from the extended program check.

The authorization check is carried out if the check indicator for the specified authorization object for the current context is set to check with any proposal status. If the check indicator is set to no check, no authorization check is carried out and sy-subrc is set to 0, as with a successful check.

The authorization check is successful if one or more authorizations are created for the authorization object in the user master record and if, for at least one of the authorizations, each of the value sets defined there for the authorization fields specified using ID includes the value val1 … val10 to be checked. Authorization fields that are not included in the statement or that have DUMMY specified for them are not checked. If the check is successful, sy-subrc is set to 0. Otherwise, it is set to a value not equal to 0 (see below).

System Fields

sy-subrc Meaning 0 Authorization successful or no check was carried out. An authorization for the authorization object was found in the user master record. Its value sets include the specified values. 4 Authorization check not successful. One or more authorizations were found for the authorizationobject in the user master record and they include the value sets, but not the values specified, or incorrect authorization fields or too many fields were specified. 12 No authorization was found for the authorization object in the user master record. 24 This return code is no longer set. 40 An invalid user name was specified in user.

In updates the statement AUTHORITY-CHECK always sets the value sy-subrc to 0 and does not make an authorization check.

Checks whether the current user has the authorization to display the airline he or she entered on the selection screen. The authorization object used here is S_CARRID and includes the authorization fields CARRID for identifying an airline and ACTVT for the activity. The code “03” represents the activity “Display”, which is one of the activities assigned to the authorization object S_CARRID.

Related Posts