SAP: deleted users [when/who]?
Actions that are done to a user profile, be that creation, modification or deletion are tracked in a table USH04.
The field PROFS will reflect each of the actions referencing the following characters:
A: add
M: modify
D: delete
Simply enter the user you are interested in and see what has occured over the year.
The sales order … is currently being processed by user …
An inbound IDOC was failing due to the error [described in the title]. Some research resulted in the following results:
TR: SM12 displayed a list of locked elements in the system.
TR: SM04 displayed a list of logged in users in the local system.
TR: SM08 displayed a list of logged in users in all the app-servers [not just the current system].
Unfortunately in my case non of the mentioned transactions above helped me narrow down where the user was locking the system – in the end I’ve requested for the user to log back in and kill his session with a TR: /nex.
Retrieving user data [ABAP]
In this example we will explore attempts to gather information from SAP database tables. We aim to collect user information and display it on the screen using SELECT statements and internal TABLE variables.
For the purposes of this example we will be collecting information from the table USR02.
In order to access that information the program must explicitly reference the desired tables at the header of the file.
REPORT Z_USERS.
* Import the USR02 table in to the program.
TABLES: USR02.
Next we want to create a internal table for gathering information from the database. We will create a local variable table ‘USERS’ with two attributes. All variables used within the ABAP/4 program must be declared with DATA statements.
DATA
<name> Name of the variable
TYPE or LIKE Indicates the variable type.
VALUE Initial value of the variable.
DECIMAL Can only be used with appropriate types. Specifies the number of decimal places in the number.
* Define USERS internal table.
DATA: BEGIN OF USERS OCCURS 100,
NAME LIKE USR02-BNAME,
DATE LIKE USR02-TRDAT,
END OF USERS.
BEGIN OF USERS OCCURS 100: Specifies the name of the variable table ‘USERS’ and states that the table will contain a 100 records.
The two attributes that the table will contain are NAME and DATE with the same characteristics as BNAME and TRDAT attributes found in the USR02 table. The BNAME attribute stores the name of the user while the TRDAT attribute stores when the user previously logged in.
END OF USERS is a closing statement for the BEGIN statement.
The next step will be to use a SELECT statement to gather information from the USR02 table and populate our local USERS table.
* Select information from the USR02 table.
SELECT * FROM USR02.
CLEAR USERS.
* Copy over the information.
USERS-NAME = USR02-BNAME.
USERS-DATE = USR02-TRDAT.
APPEND USERS.
ENDSELECT.
The SELECT statement acts like a ‘loop’ if you will. Record by record the information will be gathered up from the USR02 table and transfered in to the USERS table. After going through each record the data is added to the USERS table using the APPEND statement.
Now that we gathered some information about the users that reside in the system lets display that info.
First lets find out how many users there are in total. To do that we will use the DESCRIBE statement that will return an attribute LENGTH of all the fields in the USER table.
* How many users were retrieved.
DESCRIBE TABLE USERS LINES LENGTH.
* Output the information on the screen.
WRITE: / 'There are: ', LENGTH, 'USERS'.
The final step in our program will include the displayed of collected user information.
Using a LOOP statement we will go through each element in the USERS table and output the information on the screen.
LOOP AT USERS.
WRITE: / USERS-NAME, USERS-DATE.
ENDLOOP.
Notice that the LOOP statement terminates with a corresponding ENDLOOP statement.
And this completes our glimpse of data gathering in SAP.