SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Utillity for Maintenance Single profiles



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Jan 22, 2010 4:17 pm    Post subject: Utillity for Maintenance Single profiles Reply with quote

Code:
*&---------------------------------------------------------------------*
*& Report  ZZAUT004                                                    *
REPORT ZZAUT004 MESSAGE-ID 01.
*----------------------------------------------------------------------*
* Topic:       Utillity for Maintenance Single profiles.               *
*                                                                      *
* Description: Enhanced maintenance function for maintenance the pro-  *
*              files (single). With this program you enter the profile *
*              name profile text and up to x objects and authorization *
*                                                                      *
* Implementing The program is client independent.                      *
*                                                                      *
* 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 releasechange.  *
* release:                                                             *
*                                                                      *
* R/3 Release: Developed and tested in R/3 Release:                    *
*              3.0F                                                    *
*                                                                      *
* Programmer:  Benny G. Sшrensen,                                      *
* Date:        May 1997.                                               *
*                                                                      *
*------------------------------ Questions -----------------------------*
* Version  2
*-------------------------------Corrections----------------------------*
* Date        Userid     Correction     Text                           *
* ::.::.::::  ::::::::   :::::::::::::: :::::::::::::::::::::::::::::  *
*----------------------------------------------------------------------*
TABLES: SSCRFIELDS.
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
   PARAMETERS: P_PROF LIKE USR10-PROFN
              ,P_TEXT LIKE USR11-PTEXT.
SELECTION-SCREEN END OF BLOCK BLK1.

SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT0 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH0  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT1 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH1  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT2 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH2  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT3 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH3  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT4 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH4  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT5 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH5  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT6 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH6  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT7 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH7  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT8 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH8  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJCT9 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUTH9  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC10 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT10  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC11 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT11  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC12 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT12  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC13 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT13  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC14 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT14  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC15 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT15  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC16 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT16  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC17 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT17  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC18 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT18  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) TEXT-000 .
      PARAMETERS:  P_OBJC19 LIKE TOBJ-OBJCT.
      SELECTION-SCREEN COMMENT (3) TEXT-003 .
      PARAMETERS:  P_AUT19  LIKE USR12-AUTH.
    SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BLK2.

SELECTION-SCREEN FUNCTION KEY 1. "Insert

INCLUDE MS01CTP2.
INCLUDE MS01CTCO.
*----------------------------------------------------------------------*
* EVENT: Initialization
*----------------------------------------------------------------------*
INITIALIZATION.
  SSCRFIELDS-FUNCTXT_01 = TEXT-023. "Insert

*----------------------------------------------------------------------*
* EVENT: validate users entries on the selection screen                *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
  IF SSCRFIELDS-UCOMM = 'FC01'.
    PERFORM NEW_PROFILE.
  ENDIF.

*---------------------------------------------------------------------*
*       FORM ADD_TABPRO                                               *
*---------------------------------------------------------------------*
FORM NEW_PROFILE.
  CLEAR TABPRO. REFRESH TABPRO.

  PERFORM ADD_TABPRO  USING P_OBJCT0 P_AUTH0.
  PERFORM ADD_TABPRO  USING P_OBJCT1 P_AUTH1.
  PERFORM ADD_TABPRO  USING P_OBJCT2 P_AUTH2.
  PERFORM ADD_TABPRO  USING P_OBJCT3 P_AUTH3.
  PERFORM ADD_TABPRO  USING P_OBJCT4 P_AUTH4.
  PERFORM ADD_TABPRO  USING P_OBJCT5 P_AUTH5.
  PERFORM ADD_TABPRO  USING P_OBJCT6 P_AUTH6.
  PERFORM ADD_TABPRO  USING P_OBJCT7 P_AUTH7.
  PERFORM ADD_TABPRO  USING P_OBJCT8 P_AUTH8.
  PERFORM ADD_TABPRO  USING P_OBJCT9 P_AUTH9.

  PERFORM ADD_TABPRO  USING P_OBJC10 P_AUT10.
  PERFORM ADD_TABPRO  USING P_OBJC11 P_AUT11.
  PERFORM ADD_TABPRO  USING P_OBJC12 P_AUT12.
  PERFORM ADD_TABPRO  USING P_OBJC13 P_AUT13.
  PERFORM ADD_TABPRO  USING P_OBJC14 P_AUT14.
  PERFORM ADD_TABPRO  USING P_OBJC15 P_AUT15.
  PERFORM ADD_TABPRO  USING P_OBJC16 P_AUT16.
  PERFORM ADD_TABPRO  USING P_OBJC17 P_AUT17.
  PERFORM ADD_TABPRO  USING P_OBJC18 P_AUT18.
  PERFORM ADD_TABPRO  USING P_OBJC19 P_AUT19.

  LOOP AT TABPRO.
    SELECT SINGLE * FROM USR12
      WHERE OBJCT = TABPRO-OBJECT
        AND AKTPS = 'A'
        AND AUTH  = TABPRO-RULE.
    IF SY-SUBRC NE 0.
      MESSAGE S215 WITH TABPRO-RULE.
    ENDIF.
  ENDLOOP.

  PERFORM UPD_PROFILE USING SPACE P_PROF 'P' P_TEXT.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM ADD_TABPRO                                               *
*---------------------------------------------------------------------*
FORM ADD_TABPRO USING VALUE(OBJCT) VALUE(AUTH) .
  CHECK NOT ( OBJCT IS INITIAL ).
  CHECK NOT ( AUTH  IS INITIAL ).
  CLEAR TABPRO.
  TABPRO-OBJECT = OBJCT.
  TABPRO-OTEXT  = ''.
  TABPRO-RULE   = AUTH.
  TABPRO-MARK   = SPACE.
  APPEND TABPRO.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM UPD_PROFILE                                              *
*---------------------------------------------------------------------*
FORM UPD_PROFILE USING
         VALUE(DIVISION) VALUE(PROFILE) VALUE(AKTPAS) PTEXT.
  PERFORM UPD_USR10
          USING PROFILE AKTPAS SPACE 'S'.
* Profiletext sichern, falls einer angegeben wurde
  IF PTEXT <> SPACE.
    PERFORM UPD_USR11 USING PROFILE AKTPAS PTEXT.
  ENDIF.
  PCHANGE = 0.
  PERFORM SAVED.
  PERFORM AKTIV USING 'P'.
  MESSAGE S210 WITH PROFILE.
ENDFORM.

FORM AKTIV USING AKTPAS.
  IF AKTPAS = 'P'.
    STATE = 11.
  ELSE.
    STATE = 12.
  ENDIF.
ENDFORM.
FORM SAVED.
  IF STATE < 10.
    STATE = STATE + 10.
  ENDIF.
ENDFORM.
FORM UPD_USR10 USING VALUE(PROFILE) VALUE(AKTPAS) VALUE(DIVISION)
                     VALUE(BTYP).
DATA: OFF TYPE I,
      Z   TYPE I VALUE 0,
      MAX TYPE I,
      LONGSTRING(3750),
      LONGSTRING1(3750).

DATA: BEGIN OF INTUST10C OCCURS 50.
        INCLUDE STRUCTURE UST10C.
DATA: END OF INTUST10C.

DATA: BEGIN OF INTUST10S OCCURS 50.
        INCLUDE STRUCTURE UST10S.
DATA: END OF INTUST10S.
*
  SELECT SINGLE * FROM USR10
         WHERE PROFN = PROFILE
         AND   AKTPS  = AKTPAS.
  RC = SY-SUBRC.
  MOVE-CORRESPONDING USR10 TO *USR10.
  CLEAR USR10.
  CLEAR LONGSTRING.
  USR10-PROFN = PROFILE.
  USR10-AKTPS = AKTPAS.
  USR10-DIVIS = DIVISION.
  USR10-TYP   = BTYP.
  OFF = 2.
  Z = 0.
  IF USR10-TYP = COLECTPROF.
    MAX = MAXREC - PROFLNG.
    LOOP AT TABCPF.
      WRITE TABCPF-PROF TO LONGSTRING+OFF(PROFLNG).
      OFF = OFF + PROFLNG.
      Z = Z + 1.
      IF OFF > MAX.
        MESSAGE W269.
        EXIT.
      ENDIF.
    ENDLOOP.
  ELSE.
    IF USR10-TYP = SINGLEPROF.
      MAX = MAXREC - OBJLNG - AUTHLNG.
      LOOP AT TABPRO.
        WRITE TABPRO-OBJECT TO LONGSTRING+OFF(OBJLNG).
        OFF = OFF + OBJLNG.
        WRITE TABPRO-RULE TO LONGSTRING+OFF(AUTHLNG).
        OFF = OFF + AUTHLNG.
        IF OFF > MAX.
          MESSAGE W260.
          EXIT.
        ENDIF.
        Z = Z + 1.
      ENDLOOP.
    ENDIF.
  ENDIF.
  USR10-NRAUT = OFF.
  USR10-AUTHS = LONGSTRING.

  IF RC = 0.

    IF AKTPAS = AKTIVATED.
      IF *USR10-AUTHS(1) <> REC_TYPE_CREATE AND
         *USR10-AUTHS(1) <> REC_TYPE_MODIFY.
        SELECT * FROM USH10
               WHERE PROFN = PROFILE.
          EXIT.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          WRITE REC_TYPE_CREATE TO *USR10-AUTHS(1).
        ELSE.
          MOVE-CORRESPONDING *USR10 TO USH10.
          CLEAR USH10-AUTHS.
          INSERT USH10.
          *USR10-MODDA = SY-DATUM.
          *USR10-MODTI = SY-UZEIT - 1.
          *USR10-MODBE = SY-UNAME.
        ENDIF.
      ENDIF.
      MOVE-CORRESPONDING *USR10 TO USH10.
      INSERT USH10.
      IF SY-SUBRC <> 0.
        MESSAGE S297 WITH 'IH10' SY-SUBRC.
      ENDIF.
    ENDIF.
*
    USR10-MODBE = SY-UNAME.
    USR10-MODDA = SY-DATUM.
    USR10-MODTI = SY-UZEIT.
    WRITE REC_TYPE_MODIFY TO USR10-AUTHS(1).
    UPDATE USR10.
  ELSE.                               "Record is new
    USR10-MODBE = SY-UNAME.
    USR10-MODDA = SY-DATUM.
    USR10-MODTI = SY-UZEIT.
    WRITE REC_TYPE_CREATE TO USR10-AUTHS(1).
    INSERT USR10.
  ENDIF.
  IF BTYP = COLECTPROF.
  SELECT * FROM UST10C INTO INTUST10C
         WHERE PROFN   = PROFILE
         AND   AKTPS   = AKTPAS.
    APPEND INTUST10C.
  ENDSELECT.
* Activate Transparente Tables ust10c or ust10s
  SORT INTUST10C.
  LOOP AT INTUST10C.
    READ TABLE TABCPF WITH KEY PROF = INTUST10C-SUBPROF.
    IF SY-SUBRC <> 0.
      DELETE FROM UST10C
             WHERE PROFN   = INTUST10C-PROFN
             AND   AKTPS   = INTUST10C-AKTPS
             AND   SUBPROF = INTUST10C-SUBPROF.
    ENDIF.
  ENDLOOP.
  UST10C-PROFN = PROFILE.
  UST10C-AKTPS = AKTPAS.
  LOOP AT TABCPF.
    READ TABLE INTUST10C WITH KEY SUBPROF = TABCPF-PROF.
    IF SY-SUBRC <> 0.
      UST10C-SUBPROF = TABCPF-PROF.
      INSERT UST10C.
    ENDIF.
  ENDLOOP.
  ELSE.
  SELECT * FROM UST10S INTO INTUST10S
         WHERE PROFN   = PROFILE
         AND   AKTPS   = AKTPAS.
    APPEND INTUST10S.
  ENDSELECT.
  SORT INTUST10S.
  LOOP AT INTUST10S.
    READ TABLE TABPRO WITH KEY OBJECT  = INTUST10S-OBJCT
                               RULE    = INTUST10S-AUTH.
    IF SY-SUBRC <> 0.
      DELETE FROM UST10S
             WHERE PROFN   = INTUST10S-PROFN
             AND   AKTPS   = INTUST10S-AKTPS
             AND   OBJCT   = INTUST10S-OBJCT
             AND   AUTH    = INTUST10S-AUTH.
    ENDIF.
  ENDLOOP.
  UST10S-PROFN = PROFILE.
  UST10S-AKTPS = AKTPAS.
  LOOP AT TABPRO.
    READ TABLE INTUST10S WITH KEY OBJCT  = TABPRO-OBJECT
                                  AUTH   = TABPRO-RULE.
    IF SY-SUBRC <> 0.
      UST10S-OBJCT   = TABPRO-OBJECT.
      UST10S-AUTH    = TABPRO-RULE.
      INSERT UST10S.
    ENDIF.
  ENDLOOP.
  ENDIF.
ENDFORM.

FORM UPD_USR11 USING VALUE(PROFILE) VALUE(AKTPAS) VALUE(PTEXT).
    SELECT SINGLE * FROM USR11
           WHERE LANGU = SY-LANGU
           AND   PROFN = PROFILE
           AND   AKTPS = AKTPAS.
      USR11-PTEXT = PTEXT.
    IF SY-SUBRC = 0.
      UPDATE USR11.
      IF SY-SUBRC <> 0.
        MESSAGE S297 WITH 'UR11' SY-SUBRC.
      ENDIF.
    ELSE.
      USR11-LANGU = SY-LANGU.
      USR11-PROFN = PROFILE.
      USR11-AKTPS = AKTPAS.
      INSERT  USR11.
      IF SY-SUBRC <> 0.
        MESSAGE S297 WITH 'IR11' SY-SUBRC.
      ENDIF.
    ENDIF.
ENDFORM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.