ABAP-记录SAP用户登录IP等信息日志
SAP标准也有日志,不过要开审计才能看,或者通过STAD,本文是做了个增强来记录日志
增强点,SMOD->SUSR0001,日志表参考USR41,因为USR41会记录目前用户登陆时的IP信息,所以稍作改动就能直接作为日志表
1 DATA: 2 LT_USR41 TYPE TABLE OF USR41, 3 LS_ZBST0001 TYPE ZBST0001, 4 LT_ZBST0001 TYPE TABLE OF ZBST0001. 5 DATA: 6 LV_GID TYPE GUID_32, "GUID 7 LV_OPCODE_USR_ATTR(1) TYPE X VALUE 5, 8 LV_TID TYPE USR41-TERMID. 9 10 CALL 'ThUsrInfo' ID 'OPCODE' FIELD LV_OPCODE_USR_ATTR 11 ID 'TID' FIELD LV_TID. "#EC CI_CCALL 12 13 SELECT * 14 FROM USR41 15 INTO CORRESPONDING FIELDS OF TABLE LT_ZBST0001 16 WHERE BNAME = SY-UNAME 17 AND TERMID = LV_TID 18 AND LOGON_DATE = SY-DATUM 19 AND LOGON_TIME = SY-UZEIT. 20 21 IF SY-SUBRC = 0. 22 CALL FUNCTION 'RS_DME_MG_GENERATE_GUID' 23 IMPORTING 24 E_GUID_32 = LV_GID. 25 26 LS_ZBST0001-ZGUID = LV_GID. 27 MODIFY LT_ZBST0001 FROM LS_ZBST0001 TRANSPORTING ZGUID 28 WHERE ZGUID IS INITIAL. 29 30 MODIFY ZBST0001 FROM TABLE LT_ZBST0001. 31 ENDIF.