BC170_2.12.1
Authorizations,
Passing Between Programs,
Catching Runtime Errors
BC170_2.12.2
Objectives
• The participants will be able to:
– Define Authority Objects and how they are
used in SAP
– Describe how to use the following
commands in an ABAP Program:
• EXPORT
• IMPORT
– Describe how to catch run time errors in
SAP
BC170_2.12.3
Authority Objects in SAP
BC170_2.12.4
The AUTHORITY-CHECK
Statement
AUTHORITY-CHECK OBJECT ‘S_DEVELOP’
ID ‘DEVCLASS’ FIELD
‘YLJS’
ID ‘OBJTYPE’ DUMMY
ID ‘OBJNAME’ DUMMY
ID ‘P_GROUP’ DUMMY
ID ‘ACTVT’ ‘03’.
The option DUMMY
suppresses the check
for
the specified field. The
net
effect is that the user
can
perform any activity on
development class YLJS.
The AUTHORITY-CHECK
lists the fields to be
checked and verifies
what the user is
attempting to do
against what the user is
authorized to do.
BC170_2.12.5
AUTHORITY-CHECK OBJECT ‘S_DEVELOP’
ID ‘DEVCLASS’ FIELD ‘YLJS’
ID ‘OBJTYPE’ DUMMY
ID ‘OBJNAME’ DUMMY
ID ‘P_GROUP’ DUMMY
ID ‘ACTVT’ ‘01’.
IF SY-SUBRC <> 0.
WRITE: / ‘You are not authorized to
development’,
‘class YLJS.’.
EXIT.
ENDIF.
Reacting to the AUTHORITY-
CHECK Statement
BC170_2.12.6
Authority Check Timing
PARAMETERS: CO_CODE LIKE BSIK-BUKRS.
SELECT *
FROM BSIK
WHERE BUKRS = CO_CODE
ORDER BY PRIMARY KEY.
AUTHORITY-CHECK OBJECT ‘F_KNA1_BUK’
ID ‘BUKRS’ VALUE CO_CODE
ID ‘ACTVT’ ‘03’.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDSELECT.
BA
D!
BC170_2.12.7
The EXPORT Statement
EXPORT KNA1-KUNNR
KNA1-BUKRS
TO MEMORY.
EXPORT SY-SUBRC
TO MEMORY ID ‘LJS1’.
BC170_2.12.8
The IMPORT Statement
IMPORT <variable name>
FROM MEMORY.
BC170_2.12.9
Catching Runtime Errors
CATCH SYSTEM-EXCEPTIONS
ARITHMETIC_ERRORS = 5
CONVERSION_ERRORS = 6.
[…..]
ENDCATCH.
BC170_2.12.10
Completing the CATCH Code
DATA:
int type I,
char(3) type C value ‘ABC’.
[…..]
CATCH SYSTEM-EXCEPTIONS
CONVERSION_ERRORS = 1.
[…..]
MOVE char TO int. “MOVE keyword to trigger CATCH
[…..]
ENDCATCH.
IF SY-SUBRC = 1.
WRITE: / ‘Conversion error has occurred’.
ENDIF.
BC170_2.12.11
Summary
• The participants should be able to:
– Define Authority Objects and how they are
used in SAP
– Describe how to use the following
commands in an ABAP Program:
• EXPORT
• IMPORT
– Describe how to catch run time errors in
SAP
BC170_2.12.12