Posted: Wed Aug 20, 2008 10:04 am Post subject: Summary of Roles, Profiles and Authorizations by User ID v.2
Code:
REPORT ZHRKOPAR_SECURITY_2 LINE-SIZE 121
NO STANDARD PAGE HEADING MESSAGE-ID ZZ.
************************************************************************
* Program name : ZHRKOPAR_SECURITY_2
* Original Author : James Frazier
* Creation Date : 09-20-2002
* Description : Summary of Roles, Profiles and Authorizations by
* User ID
*
* Frequency : Variable
* Project Name : LIS
************************************************************************
* MODIFICATION LOG
************************************************************************
* Change Change Change Change Version
* Author Date Description Number
*----------------------------------------------------------------------*
*
*
*
************************************************************************
************************************************************************
* TABLES
************************************************************************
TABLES: ADCP, " Person/Address assignment (central address administ
ADRP, " Persons (central address administration)
AGR_HIER, " Table for Structure Information for Menu
AGR_HIERT, " Role menu texts
AGR_USERS, " Assignment of roles to users
AGR_TEXTS, " File Structure for Hierarchical Menu - Customer
DFIES, " DD Interface: Table Fields for DDIF_FIELDINFO_GET
HRP1000, " PD Object Name
PA0105, " HR Master Record: Infotype 0105 (Communications)
PERNR, "
USR02, " Logon data
USR04, " User master authorizations
USR11, " User Master Texts for Profiles (USR10)
USR12, " User master authorization values
USR21, " Assign user name address key
UST04, " User masters
TOBJT. " Texts for Objects in Table TOBJ
************************************************************************
* STANDARD INCLUDES
************************************************************************
*INCLUDE ZHRKOPAIFSTANDARD_HEADER.
************************************************************************
* DATA DECLARATIONS
************************************************************************
DATA: BEGIN OF ITAB-USER OCCURS 10,
USERID LIKE USR04-BNAME,
USERN LIKE USR21-PERSNUMBER,
AD_ADDRNUM LIKE USR21-ADDRNUMBER,
END OF ITAB-USER.
DATA: BEGIN OF ITAB_S OCCURS 10,
AGR_NAME LIKE AGR_USERS-AGR_NAME,
END OF ITAB_S.
DATA: BEGIN OF ITAB_R OCCURS 10,
AGR_NAME LIKE AGR_USERS-AGR_NAME,
END OF ITAB_R.
DATA: BEGIN OF I_TAB OCCURS 10,
LNAME(25),
FNAME(20),
PERNR LIKE PERNR-PERNR,
USERID LIKE USR04-BNAME,
EDATE(10),
ROLE(40),
BEGDA(10),
ENDDA(10),
POSITION(30),
WERKS(4),
ORG(20),
END OF I_TAB.
DATA: BEGIN OF INTFIELD OCCURS 10,
FIELDNAME LIKE TOBJ-FIEL1,
LNG TYPE I,
TYPE,
FTEXT LIKE DFIES-SCRTEXT_L,
CONVEXIT LIKE DFIES-CONVEXIT,
END OF INTFIELD.
DATA: BEGIN OF TABPRO OCCURS 500,
USERID LIKE USR04-BNAME,
PROFILE LIKE XU213-PROFILE,
END OF TABPRO.
DATA: BEGIN OF TABAUTH OCCURS 500,
USERID LIKE USR04-BNAME, "Userid
PROFILE LIKE XU213-PROFILE, "Profile
OBJECT LIKE USR12-OBJCT, "Object
RULE LIKE USR12-AUTH, "Authorization
END OF TABAUTH.
DATA: BEGIN OF TABVAL OCCURS 500,
USERID LIKE USR04-BNAME,
PROFILE LIKE XU213-PROFILE,
OBJECT LIKE USR12-OBJCT,
RULE LIKE USR12-AUTH, "Authorization
SFIELD LIKE TOBJ-FIEL1, "Field Name
VON(18), "Value From
BIS(18), "Value To
USED-IN-REPORT-ALREADY,
END OF TABVAL.
DATA: USER-NAME LIKE USR03-NAME1,
USER-ID(14),
WS-TEXT(10),
SYST_LANGUAGE VALUE 'D',
TEMP-USERID LIKE USR04-BNAME,
TEMP-PROFILE LIKE XU213-PROFILE,
MAXCPF TYPE I VALUE 300,
MAXPRO TYPE I VALUE 170,
FLDLNG LIKE SY-FDPOS VALUE 10, "Field
AUTHLNG LIKE SY-FDPOS VALUE 12,
OBJLNG LIKE SY-FDPOS VALUE 10, "Object
PROFLNG LIKE SY-FDPOS VALUE 12,
PREV-RULE LIKE USR12-AUTH, "Authorization
PREV-OBJECT LIKE USR12-OBJCT,
PREV-SFIELD LIKE TOBJ-FIEL1.
DATA: I0001 LIKE P0001 OCCURS 0 WITH HEADER LINE.
DATA: WS-VALID-FL.
FIELD-SYMBOLS: <TEXT>.
*---> ALV Declarations <---
TYPE-POOLS: slis.
DATA: header_alv_wa TYPE slis_listheader,
header_alv TYPE slis_t_listheader.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF fieldcat,
sortcat TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
eventcat TYPE slis_t_event,
eventcat_ln LIKE LINE OF eventcat.
DATA: is_layout TYPE slis_layout_alv.
DATA: col_pos TYPE i.
DATA: g_save(1) TYPE c,
g_exit(1) TYPE c,
gx_variant LIKE disvariant,
g_variant LIKE disvariant,
g_repid LIKE sy-repid.
DATA: gt_titel TYPE lvc_title.
************************************************************************
* SCREEN SELECTION OPTION
************************************************************************
SELECT-OPTIONS BNAME FOR USR02-BNAME DEFAULT SY-UNAME.
PARAMETER PERN LIKE PA0105-PERNR matchcode object prem .
SET PARAMETER ID 'PER' FIELD pern.
************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
PERFORM GET-NAME.
END-OF-SELECTION.
Perform Format-Data.
************************************************************************
* FORM PROCESSING
************************************************************************
FORM GET-NAME.
* Retrives all Users Ids from selection screen
SELECT * FROM USR21
WHERE BNAME IN BNAME.
MOVE USR21-BNAME TO ITAB-USER-USERID.
MOVE USR21-PERSNUMBER TO ITAB-USER-USERN.
MOVE USR21-ADDRNUMBER TO ITAB-USER-AD_ADDRNUM.
APPEND ITAB-USER.
ENDSELECT.
* Formats all Valid User Id
LOOP AT ITAB-USER.
CLEAR: I_TAB, WS-VALID-FL.
AT NEW USERID.
ENDAT.
CLEAR: ADCP, ADRP, ITAB_S, ITAB_R,
USER-NAME, USER-ID, AGR_TEXTS, USR11.
REFRESH: ITAB_R.
IF ITAB-USER-USERN = SPACE.
MOVE 'User Name NOT Available' TO USER-NAME.
ELSE.
* Retrives Department
SELECT * FROM ADCP
WHERE ADDRNUMBER EQ ITAB-USER-AD_ADDRNUM.
ENDSELECT.
* Retrives User Id Name
SELECT * FROM ADRP
WHERE PERSNUMBER EQ ITAB-USER-USERN.
ENDSELECT.
IF SY-SUBRC EQ 0.
MOVE ADRP-NAME_LAST TO I_TAB-LNAME.
MOVE ADRP-NAME_FIRST TO I_TAB-FNAME.
MOVE ITAB-USER-USERID TO I_TAB-USERID.
ENDIF.
ENDIF.
PERFORM GET-PA-DATA.
* Retrives Role Data Based on User ID
SELECT * FROM AGR_USERS
WHERE UNAME EQ ITAB-USER-USERID
AND FROM_DAT LE SY-DATUM
AND TO_DAT GE SY-DATUM.
MOVE AGR_USERS-AGR_NAME TO I_TAB-ROLE.
WRITE AGR_USERS-FROM_DAT TO I_TAB-BEGDA.
WRITE AGR_USERS-TO_DAT TO I_TAB-ENDDA.
IF WS-VALID-FL EQ SPACE.
COLLECT I_TAB.
ENDIF.
ENDSELECT.
ENDLOOP.
ENDFORM.
*----------------*
FORM GET-PA-DATA.
CLEAR: I0001, PA0105.
REFRESH: I0001.
IF NOT ( PERN IS INITIAL ).
SELECT * FROM PA0105
WHERE ENDDA GE SY-DATUM
AND PERNR EQ PERN
AND USRTY EQ '0001' "System user name (SY-UNAME)
AND USRID EQ ITAB-USER-USERID.
ENDSELECT.
IF SY-SUBRC NE 0.
MOVE 'X' TO WS-VALID-FL.
ENDIF.
ELSE.
SELECT * FROM PA0105
WHERE ENDDA GE SY-DATUM
AND USRTY EQ '0001' "System user name (SY-UNAME)
AND USRID EQ ITAB-USER-USERID.
ENDSELECT.
ENDIF.
IF SY-SUBRC EQ 0.
MOVE PA0105-PERNR TO I_TAB-PERNR.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
PERNR = PA0105-PERNR
INFTY = '0001'
BEGDA = SY-DATUM
ENDDA = SY-DATUM
TABLES
INFTY_TAB = I0001
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
LOOP AT I0001.
ENDLOOP.
MOVE I0001-PLANS TO I_TAB-POSITION.
MOVE I0001-WERKS TO I_TAB-WERKS.
MOVE I0001-VDSK1 TO I_TAB-ORG.
SELECT * FROM hrp1000 WHERE plvar EQ '01'
AND otype EQ 'S'
AND objid EQ I0001-PLANS .
ENDSELECT.
IF sy-subrc EQ 0.
MOVE hrp1000-stext TO I_TAB-POSITION.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
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.