ABAP Program Authorization

In your editor program, click Goto -> Attributes

Key in the authorization in the Authorization Group.

------------------------------------------------------------------------------------------------
ABAP Authorization Example by: Rajiv Ranjan Singh

PROCESS BEFORE OUTPUT.
 MODULE STATUS_1000.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_1000.
*-----------------------------------------------------------------------
*Main Menu program for Short Leave transaction
*-----------------------------------------------

*&---------------------------------------------------------------------*
*& Module pool       ZRJ000                                            *
*&---------------------------------------------------------------------*

PROGRAM  ZRJ000                                                      .
DATA: OK_CODE LIKE SY-UCOMM.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_1000 OUTPUT.
  SET PF-STATUS 'MAIN'.
  SET TITLEBAR 'MAIN'.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1000 INPUT.
  CASE OK_CODE.
    WHEN 'M001'.
      CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
           EXPORTING
                ACTION    = 'S'               " Display
                VIEW_NAME = 'ZTRN'.
    WHEN 'M002'.
      PERFORM CHECK_AUTHORISATION USING 'ZRJD01'. "Display Short Leave
    WHEN 'T001'.
      PERFORM CHECK_AUTHORISATION USING 'ZRJR01'. "Delete Records of zsl_txn
    WHEN 'T002'.
      PERFORM CHECK_AUTHORISATION USING 'ZRJD02'. "Modify Records of Zsl_txn
    WHEN 'BACK' OR 'CANC' OR 'EXIT' OR 'E001'.
      SET SCREEN  0.
      LEAVE SCREEN.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  CHECK_AUTHORISATION
*&---------------------------------------------------------------------*
FORM CHECK_AUTHORISATION USING P_TCODE.
  AUTHORITY-CHECK OBJECT 'S_TCODE' ID 'TCD' FIELD P_TCODE.
  IF SY-SUBRC NE 0.
    MESSAGE S261(SF) WITH P_TCODE.
  ELSE.
    CALL TRANSACTION P_TCODE.
  ENDIF.
ENDFORM.                    " CHECK_AUTHORISATION

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.