REPORT ZBCAUTH1 .
*
************************************************************************
*
*   Profile listing according to          Erikki Tikka
*   user-id or client                     Sni-Finland
*                                         150495
************************************************************************
*
TABLES: USR01, USR04.
*
PARAMETERS: CLIENT LIKE SY-MANDT    DEFAULT '*  ',
            USER   LIKE USR01-BNAME DEFAULT '*'.
*
DATA:BEGIN OF IUSR01 OCCURS 0.
        INCLUDE STRUCTURE USR01.
DATA:END OF IUSR01.
DATA:ED-BNAME LIKE USR01-BNAME.
*
IF CLIENT = '*'.
  CASE USER.
    WHEN '*'.
      PERFORM ALL-ALL.
    WHEN OTHERS.
      PERFORM ALL-ONE.
  ENDCASE.
ELSE.
  CASE USER.
    WHEN '*'.
      PERFORM ONE-ALL.
    WHEN OTHERS.
      PERFORM ONE-ONE.
  ENDCASE.
ENDIF.
*
FORM ALL-ALL.
************************************************************************
*   Selection from all excisting Clients / All users
************************************************************************
*
  SELECT * FROM USR01
    CLIENT SPECIFIED
    INTO TABLE IUSR01.
*
  SORT IUSR01 BY BNAME MANDT.
*
  PERFORM LOOP-IUSR01.
*
ENDFORM.
*
FORM ALL-ONE.
************************************************************************
*   Selection from all excisting Clients / One user
************************************************************************
*
  SELECT * FROM USR01
    CLIENT SPECIFIED
    INTO TABLE IUSR01
    WHERE BNAME = USER.
*
  SORT IUSR01 BY BNAME MANDT.
*
  PERFORM LOOP-IUSR01.
*
ENDFORM.
*
FORM ONE-ALL.
************************************************************************
*   Selection from one excisting Client / All users
************************************************************************
*
  SELECT * FROM USR01
    CLIENT SPECIFIED
    INTO TABLE IUSR01
    WHERE MANDT = CLIENT.
*
  SORT IUSR01 BY BNAME MANDT.
*
  PERFORM LOOP-IUSR01.
ENDFORM.
*
PERFORM LOOP-IUSR01.
*
FORM ONE-ONE.
************************************************************************
*   Selection from one excisting Client / One users
************************************************************************
*
  SELECT * FROM USR01
    CLIENT SPECIFIED
    INTO TABLE IUSR01
    WHERE MANDT = CLIENT AND
          BNAME = USER.
*
  SORT IUSR01 BY BNAME MANDT.
ENDFORM.
*
PERFORM LOOP-IUSR01.
*
FORM LOOP-IUSR01.
************************************************************************
*   Loop internal-table / Search valid Profiles
************************************************************************
  LOOP AT IUSR01.
    IF ED-BNAME <> IUSR01-BNAME.
      WRITE /.
      WRITE: /2 IUSR01-BNAME.
    ENDIF.
    ED-BNAME = IUSR01-BNAME.
    SELECT * FROM USR04
      CLIENT SPECIFIED
      WHERE BNAME = IUSR01-BNAME AND
            MANDT = IUSR01-MANDT.
      PERFORM WRITE-RESULT.
    ENDSELECT.
  ENDLOOP.
ENDFORM.
*
FORM WRITE-RESULT.
************************************************************************
*   Prints out the result
************************************************************************
*
  WRITE: /2 IUSR01-MANDT, 6 USR04-NRPRO, 15 USR04-PROFS+2.
ENDFORM.