REPORT ZZBGS057  MESSAGE-ID Z1.
*----------------------------------------------------------------------*
* Description: Utillity listning authorization objects per             *
*              application (objectclass), per function per object with *
*              all fields and activities.                              *
*                                                                      *
*              Used in analyzing the authorization system in R/3.      *
*                                                                      *
* Implementing The program is client indepent but writes only informa- * 
*              tion about one client.                                  *
*                                                                      *
*                                                                      *
* Submitting:  Via transaction SA38 eller via batch job execution      *
*                                                                      *
* Parametre:   Use of generic parameters                               *
*                                                                      *
* Customizing: The program needs no customization.                     *
*                                                                      *
* Change of    Chech tables and structures.                            *
* release:                                                             *
*                                                                      *
* Programmer:  Benny G. Sørensen                                       *
* Date:        Oct 1995.                                               *
* SAP R/3:     2.2F                                                    *
*-------------------------------Corrections----------------------------*
* Date        Userid     Correction                                    *
* 20.10.1995  BGS        Start of development.
*----------------------------------------------------------------------*
*-----------------------------------------------------------------------
* Tables
*-----------------------------------------------------------------------
TABLES: TOBFA      "Applikations
       ,TOBFC      "Relation between object classes and funtions
       ,TOBC       "Object class
       ,TOBJ       "Authorization Objects
       ,TOBJT      "Authorization description
       ,TOBF       "Relation between objects and functions
       ,TOBFT      "Description of TOBF
       ,TOBJC      "Empty
       ,TOBCT      "Texts for Authorization Object Classes
       ,TBRG       "Authorization groups
       ,TBRGT      "Authorization usergroup description
       ,TDDAT      "Maintenance areas for tables
       ,TRDIR      "System table with ABAP/4 program attributes
       ,DD04V      "Datadictionary - dataelement
       ,TACTZ      "Valid activity codes for each authorization object
       ,TACT       "Activity codes
       ,TACTT      "Activity codes decriptions
*      ,T055       "Field group fields
*      ,T055G      "Field groups
*      ,T055T      "Field group decriptions
*      ,TSTC       "Transaction Codes
*      ,TSTCT      "Transaction code descriptions
*      ,TRCL       "Program classes
*      ,TRCLT      "Program classes descriptions
       .
*-----------------------------------------------------------------------
* Parameters
*-----------------------------------------------------------------------
PARAMETER: P_OCLSS LIKE TOBCT-OCLSS.

*-----------------------------------------------------------------------
* Output data definitions
*-----------------------------------------------------------------------
DATA: BEGIN OF APPFUNKOBJ OCCURS 0
      ,OCLSS    LIKE TOBJ-OCLSS
      ,CTEXT    LIKE TOBCT-CTEXT
      ,FUN_ID   LIKE TOBF-FUN_ID
      ,FUN_TEXT LIKE TOBFT-FUN_TEXT
      ,OBJCT    LIKE TOBJ-OBJCT
      ,TTEXT    LIKE TOBJT-TTEXT
      ,FIEL1    LIKE TOBJ-FIEL1
      ,FIEL2    LIKE TOBJ-FIEL2
      ,FIEL3    LIKE TOBJ-FIEL3
      ,FIEL4    LIKE TOBJ-FIEL4
      ,FIEL5    LIKE TOBJ-FIEL5
      ,FIEL6    LIKE TOBJ-FIEL6
      ,FIEL7    LIKE TOBJ-FIEL7
      ,FIEL8    LIKE TOBJ-FIEL8
      ,FIEL9    LIKE TOBJ-FIEL9
      ,FIEL0    LIKE TOBJ-FIEL0
      .
DATA END OF APPFUNKOBJ.

*----------------------------------------------------------------------*
* Start-of-selection
*----------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM VIS_APPL_FUNK_OBJ.

*----------------------------------------------------------------------*
* VIS_APPL_FUNK_OBJ
*----------------------------------------------------------------------*
FORM VIS_APPL_FUNK_OBJ.
     CLEAR TOBJ.
     SELECT * FROM TOBJ
       WHERE OCLSS LIKE P_OCLSS.
       CLEAR APPFUNKOBJ.
       MOVE-CORRESPONDING TOBJ TO APPFUNKOBJ.
       CLEAR TOBJT.
       SELECT SINGLE * FROM TOBJT
         WHERE LANGU  = SY-LANGU
           AND OBJECT = TOBJ-OBJCT.
       IF SY-SUBRC = 0.
         APPFUNKOBJ-TTEXT = TOBJT-TTEXT.
       ELSE.
         APPFUNKOBJ-TTEXT = '??????????'.
       ENDIF.
       CLEAR TOBCT.
       SELECT SINGLE * FROM TOBCT
         WHERE LANGU = SY-LANGU
           AND OCLSS = TOBJ-OCLSS.
       IF SY-SUBRC = 0.
         APPFUNKOBJ-CTEXT = TOBCT-CTEXT.
       ELSE.
         APPFUNKOBJ-CTEXT = '??????????'.
       ENDIF.

*      Pick up relation to functions
       CLEAR TOBF.
       SELECT * FROM TOBF
         WHERE OBJECT = TOBJ-OBJCT.
         APPFUNKOBJ-FUN_ID = TOBF-FUN_ID.
         CLEAR TOBFT.
         SELECT SINGLE * FROM TOBFT
           WHERE LANGU = SY-LANGU
             AND FUN_ID = TOBF-FUN_ID.
         IF SY-SUBRC = 0.
           APPFUNKOBJ-FUN_TEXT = TOBFT-FUN_TEXT.
         ELSE.
           APPFUNKOBJ-FUN_TEXT = 'No text for businessfunction exists'.
         ENDIF.
       ENDSELECT.

       IF SY-SUBRC NE 0.
         APPFUNKOBJ-FUN_ID   = ' -  -  -  '.
         APPFUNKOBJ-FUN_TEXT = 'No relation to businessfunction'.
       ENDIF.
       APPEND APPFUNKOBJ.
     ENDSELECT.

     SORT APPFUNKOBJ BY OCLSS FUN_ID OBJCT.

     LOOP AT APPFUNKOBJ.
       ON CHANGE OF APPFUNKOBJ-OCLSS.
         NEW-PAGE.
         WRITE: /01 APPFUNKOBJ-OCLSS
                ,6 APPFUNKOBJ-CTEXT
                .
       ENDON.

       ON CHANGE OF APPFUNKOBJ-FUN_ID.
         WRITE: /6  APPFUNKOBJ-FUN_ID
                ,18 APPFUNKOBJ-FUN_TEXT
                .
       ENDON.

       ON CHANGE OF APPFUNKOBJ-OBJCT.
         WRITE: /18 APPFUNKOBJ-OBJCT
                ,30 APPFUNKOBJ-TTEXT.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL1.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL2.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL3.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL4.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL5.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL6.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL7.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL8.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL9.
         PERFORM WRITE_FIELDS USING APPFUNKOBJ-FIEL0.
       ENDON.

     ENDLOOP.

ENDFORM.

*----------------------------------------------------------------------*
* WRITE_FIELDS
*----------------------------------------------------------------------*
FORM WRITE_FIELDS USING FIELD.

  IF FIELD NE SPACE.
    IF FIELD NE 'ACTVT'.
      CLEAR DD04V.
      SELECT SINGLE * FROM DD04V
        WHERE ROLLNAME   = FIELD
          AND DDLANGUAGE = SY-LANGU.
      WRITE: /30 FIELD
           ,  42 DD04V-DDTEXT.
    ELSE.
      WRITE: /30 FIELD
           ,  42 'Activity'.
        CLEAR TACTZ.
        SELECT * FROM TACTZ
          WHERE BROBJ = APPFUNKOBJ-OBJCT.
          WRITE: /42 TACTZ-ACTVT.
          SELECT SINGLE * FROM TACTT
            WHERE SPRAS = SY-LANGU
              AND ACTVT = TACTZ-ACTVT.
            WRITE 45 TACTT-LTEXT.
        ENDSELECT.
    ENDIF.
  ENDIF.

ENDFORM.