Posted: Fri Jan 22, 2010 4:16 pm Post subject: Utillity for Maintenance Authorizations
Code:
REPORT ZZAUT002 MESSAGE-ID Z1.
*----------------------------------------------------------------------*
* Topic: Utillity for Maintenance Authorizations. *
* *
* Description: Enhanced maintenance function for maintenance the aut- *
* horizations in SAP R/3. With this program you enter the *
* authorization object name, and authorizations. *
* *
* Implementing The program is client independent. The program does not *
* respond to F8=EXECUTE but only respond to pushbuttoms. *
* *
* Authoriza. Standard authorization checks as in the normal editor. *
* *
* Submitting: Run by SA38, SE38. *
* *
* Parametre: Object, Authorizations. *
* *
* Output: Files on the desktop or presentation server: *
* *
* Customizing: No need for customization. *
* *
* Change of You only need to do the syntax check at releasechage. *
* release: *
* *
* R/3 Release: Developed and tested in R/3 Release: *
* 3.0F *
* *
* Programmer: Benny G. Sшrensen *
* Date: Nov 1996. *
* *
*------------------------------ Questions -----------------------------*
* Version 2
*-------------------------------Corrections----------------------------*
* Date Userid Correction Text *
* ::.::.:::: :::::::: :::::::::::::: ::::::::::::::::::::::::::::: *
*----------------------------------------------------------------------*
INCLUDE MS01CTCO.
*----------------------------------------------------------------------*
* Tables
*----------------------------------------------------------------------*
TABLES: USR12 ,USR13 ,SSCRFIELDS, TOBJ.
*----------------------------------------------------------------------*
* Parameters *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_OBJCT LIKE USR13-OBJCT DEFAULT ''.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) TEXT-105 .
PARAMETERS: P_AUTH LIKE USR13-AUTH DEFAULT '4XXX_'.
* ,p_text like usr13-atext default ''.
SELECTION-SCREEN END OF LINE.
PARAMETERS: P_MASK LIKE USR13-AUTH DEFAULT '4*'.
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN FUNCTION KEY 1. "Insert
SELECTION-SCREEN FUNCTION KEY 2. "Change
SELECTION-SCREEN FUNCTION KEY 3. "List
*----------------------------------------------------------------------*
* Work Variables and internal tables
*----------------------------------------------------------------------*
DATA: BEGIN OF W_AUTH OCCURS 10
,AUTH LIKE USR13-AUTH
,FILLER(5) TYPE C
,TEXT LIKE USR13-ATEXT
,END OF W_AUTH.
*----------------------------------------------------------------------*
* Constants
*----------------------------------------------------------------------*
DATA: FAIL TYPE I VALUE 1
,OK LIKE SY-SUBRC VALUE 0 "Code for Ok
,ERROR LIKE SY-SUBRC VALUE -1 "Code for error
,RETURN_CODE LIKE SY-SUBRC VALUE -1 "Code for error
,YES TYPE I VALUE 1 "Boolean = YES
,NO TYPE I VALUE 0 "Boolean = NO
,EXISTS TYPE I VALUE 0 "Boolean = YES/NO
.
*----------------------------------------------------------------------*
* EVENT: Initialization
*----------------------------------------------------------------------*
INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = TEXT-003. "Insert
SSCRFIELDS-FUNCTXT_02 = TEXT-004. "Change
SSCRFIELDS-FUNCTXT_03 = TEXT-005. "List
*----------------------------------------------------------------------*
* EVENT: validate users entries on the selection screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'FC01'.
PERFORM EXISTS_OBJECT USING P_OBJCT RETURN_CODE.
IF RETURN_CODE NE OK AND RETURN_CODE NE 2.
MESSAGE E000 WITH TEXT-102.
EXIT.
ENDIF.
PERFORM MAINTAIN_AUTHORIZATION USING P_OBJCT P_AUTH.
ENDIF.
IF SSCRFIELDS-UCOMM = 'FC02'.
PERFORM EXISTS_OBJECT USING P_OBJCT RETURN_CODE.
CASE RETURN_CODE.
WHEN 1. MESSAGE E000 WITH TEXT-102.
WHEN 2. MESSAGE E000 WITH TEXT-103.
ENDCASE.
CHECK RETURN_CODE = OK.
PERFORM MAINTAIN_AUTHORIZATION USING P_OBJCT P_AUTH.
ENDIF.
*&---------------------------------------------------------------------*
*& Form MAINTAIN_AUTHORIZATION
*&---------------------------------------------------------------------*
FORM MAINTAIN_AUTHORIZATION USING P_OBJCT LIKE USR13-OBJCT
P_AUTH LIKE USR13-AUTH.
CALL FUNCTION 'MAINT_AUTHORIZATION'
EXPORTING
AUTHNAME = P_AUTH
OBJECTNAME = P_OBJCT
EXCEPTIONS
FOREIGN_LOCK = 1
NO_AUTHORIZATION = 2
SYSTEM_FAILURE = 3
OTHERS = 4.
IF SY-SUBRC NE OK.
MESSAGE E000 WITH TEXT-101.
ENDIF.
ENDFORM. " MAINTAIN_AUTHORIZATION
*&---------------------------------------------------------------------*
*& Form EXISTS_OBJECT
*&---------------------------------------------------------------------*
FORM EXISTS_OBJECT USING P_OBJCT LIKE TOBJ-OBJCT
RETURN_CODE LIKE SY-SUBRC.
RETURN_CODE = OK.
SELECT SINGLE * FROM TOBJ
WHERE OBJCT = P_OBJCT.
IF SY-SUBRC NE OK.
RETURN_CODE = 1.
EXIT.
ENDIF.
SELECT * FROM USR13
WHERE OBJCT = P_OBJCT
AND AUTH = P_AUTH
AND LANGU = SY-LANGU .
ENDSELECT.
IF SY-SUBRC NE OK.
RETURN_CODE = 2.
EXIT.
ENDIF.
ENDFORM. " EXISTS_OBJECT
*&---------------------------------------------------------------------*
*& Form LIST_AUTHORIZATION
*&---------------------------------------------------------------------*
FORM LIST_AUTHORIZATION.
DATA: CHOISE LIKE SY-TABIX.
CLEAR W_AUTH.
REFRESH W_AUTH.
TRANSLATE P_MASK USING '*%'.
TRANSLATE P_AUTH USING '*%'.
SELECT * FROM USR13
WHERE OBJCT = P_OBJCT
AND LANGU = SY-LANGU
AND AUTH LIKE P_MASK.
W_AUTH-AUTH = USR13-AUTH.
W_AUTH-TEXT = USR13-ATEXT.
APPEND W_AUTH.
ENDSELECT.
CHECK SY-SUBRC = OK.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.