以下是程序可以设置对表进行分组,并把组分给用户,达到用户分权限组管理表的功能,此功能使用函数调用SE16N,来显示表,其实也可以增加一下,当有权限时调用SM30维护表。
增加两个表:
1.表 ZSE16N_AUTHGRP(ZSE16N 权限组描述)
2.表 ZSE16N (SE16N屏幕变式对照表)
ABAP程序源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
*&---------------------------------------------* *& Report ZFIR_015 *& *&---------------------------------------------* *& *& *&---------------------------------------------* REPORT ZFIR_015 LINE-SIZE 70. *** 数据定义 ********************************* DATA: BEGIN OF GS_TABNAME, * index TYPE sy-index, TABNAME LIKE DD02T-TABNAME, DDTEXT LIKE DD02T-DDTEXT, END OF GS_TABNAME. DATA: GT_TBACT LIKE TABLE OF GS_TABNAME, GT_SE16N_AUTHGRP TYPE TABLE OF ZSE16N_AUTHGRP. DATA: G_MTEXT TYPE STRING. *** SELECTION-SCREEN ************************ PARAMETERS: P_TABNAM TYPE DD02T-TABNAME OBLIGATORY. ********************************************* INITIALIZATION. PERFORM FRM_AUTH_CHECK. PERFORM FRM_INIT. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_TABNAM. PERFORM FRM_F4_TABNAME. ********************************************** START-OF-SELECTION. PERFORM FRM_GO. END-OF-SELECTION. IF G_MTEXT IS NOT INITIAL. MESSAGE S001(BL) DISPLAY LIKE 'E' WITH G_MTEXT . ENDIF. *&---------------------------------------------* *& Form frm_go *&---------------------------------------------* * text *----------------------------------------------* FORM FRM_GO. CLEAR G_MTEXT. DATA: L_SCVARIANT LIKE SHDSVCI-SCVARIANT. "判断输入的表名是否有权限,并生成屏幕变式名。 READ TABLE GT_TBACT TRANSPORTING NO FIELDS WITH KEY TABNAME = P_TABNAM BINARY SEARCH. IF SY-SUBRC = 0. L_SCVARIANT = P_TABNAM. SHIFT L_SCVARIANT LEFT CIRCULAR. CONCATENATE 'ZSV_' L_SCVARIANT INTO L_SCVARIANT. ELSE. G_MTEXT = TEXT-001. RETURN. ENDIF. * CALL FUNCTION 'RS_HDSYS_GET_SC_VARIANT' *{ INSERT QASK902552 2 DO 2 TIMES. *} INSERT "检查屏幕变式。 CALL FUNCTION 'RS_HDSYS_READ_SC_VARIANT_DB' EXPORTING SCVARIANT = L_SCVARIANT EXCEPTIONS NO_VARIANT = 1 OTHERS = 2. *{ DELETE QASK902552 5 *\ IF sy-subrc <> 0. *} DELETE *{ INSERT QASK902552 4 IF SY-SUBRC = 0. EXIT. ELSE. IF SY-INDEX = 1. L_SCVARIANT = P_TABNAM. CONCATENATE 'ZSV_' L_SCVARIANT INTO L_SCVARIANT. CONTINUE. ENDIF. *} INSERT MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO INTO G_MTEXT WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. RETURN. ENDIF. *{ INSERT QASK902552 3 ENDDO. *} INSERT "设置 SE16N 屏幕变式。 CALL FUNCTION 'RS_HDSYS_SET_SC_VARIANT' EXPORTING PROGNAME = 'SAPLSE16N' DYNPRO = '100' SCVARIANT = L_SCVARIANT OVERWRITE_SCVARIANT = 'X' SET_IMMEDIATELY = 'X'. * WAIT UP TO '0.5' SECONDS. "设置 SE16N 要查看的表。 SET PARAMETER ID 'DTB' FIELD P_TABNAM. *"调用 SE16N SUBMIT RK_SE16N AND RETURN. ENDFORM. "frm_go *&---------------------------------------------* *& Form frm_auth_check *&---------------------------------------------* * text *----------------------------------------------* FORM FRM_AUTH_CHECK. FIELD-SYMBOLS:<LFS_AUTHGRP> LIKE LINE OF GT_SE16N_AUTHGRP. SELECT ZAUTHGRP INTO CORRESPONDING FIELDS OF TABLE GT_SE16N_AUTHGRP FROM ZSE16N_AUTHGRP. CHECK SY-SUBRC = 0. LOOP AT GT_SE16N_AUTHGRP ASSIGNING <LFS_AUTHGRP>. AUTHORITY-CHECK OBJECT 'Z_AUTHGRP' ID 'ACTVT' FIELD '03' ID 'ZAUTHGRP' FIELD <LFS_AUTHGRP>-ZAUTHGRP . IF SY-SUBRC <> 0. DELETE GT_SE16N_AUTHGRP INDEX SY-TABIX. ENDIF. ENDLOOP. ENDFORM. "frm_auth_check *&---------------------------------------------* *& Form frm_init *&---------------------------------------------* * text *----------------------------------------------* FORM FRM_INIT. CHECK LINES( GT_SE16N_AUTHGRP ) > 0. SELECT D~TABNAME D~DDTEXT FROM ZSE16N AS Z INNER JOIN DD02T AS D ON Z~TABLENAME = D~TABNAME INTO CORRESPONDING FIELDS OF TABLE GT_TBACT FOR ALL ENTRIES IN GT_SE16N_AUTHGRP WHERE Z~ZAUTHGRP = GT_SE16N_AUTHGRP-ZAUTHGRP AND D~DDLANGUAGE = SY-LANGU. CHECK SY-SUBRC = 0. SORT GT_TBACT BY TABNAME. DELETE ADJACENT DUPLICATES FROM GT_TBACT COMPARING TABNAME. ENDFORM. "frm_init *&---------------------------------------------------------------------* *& Form frm_f4_tabname *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM FRM_F4_TABNAME. DATA:LT_RETURN_TAB TYPE TABLE OF DDSHRETVAL. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING RETFIELD = 'TABNAME' PVALKEY = 'TABNAME' DYNPPROG = SY-REPID DYNPNR = SY-DYNNR DYNPROFIELD = 'P_TABNAM' VALUE_ORG = 'S' DISPLAY = 'F' CALLBACK_PROGRAM = SY-REPID TABLES VALUE_TAB = GT_TBACT RETURN_TAB = LT_RETURN_TAB EXCEPTIONS PARAMETER_ERROR = 1 NO_VALUES_FOUND = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO INTO G_MTEXT WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. "frm_f4_tabname |