Statistical Records Part 4: How to read ST03N datasets from DB in NW2004
Have you ever asked the question “Who uses all these Z* reports? Are they used at all?” Well, ST03N could give you the answer, but sometimes you want get the result in a more condensed format. So you implement your own report to utilize the aggregated statistical records of ST03N calculating your own metrics and reports.
Probably you have noticed my last How to read ST03N datasets from DB where the API for NW2004s was presented. This blog is about NW2004 and previous releases.
The function SAPWL_WORKLOAD_GET_STATISTIC provides almost all the tables used by ST03N. This API is available for SAP_BASIS 640 (NW2004) and previous releases (with small changes). Implementing a small program you can read the data, and extract whatever you are interested in. The code snippet  shows you the basic steps.
Let’s have a short look at the interface of the function module. Before you can use this function you need to know the parameters.
PERIODTYPE specifies the type of the period you want to analyze. Valid values are D for days, W for weeks, and M for months.
STARTDATE is a date. Specify the day you are interested in.
Parameter HOSTID is not used any more. You can ignore this parameter.
INSTANCE is the name of an application server. Use the name TOTAL if you want to get the data of all application servers.
ONLY_APPLICATION_STATISTIC is a flag. Specify an X if you just want to read the table APPLICATION_STATISTIC.
The function returns many different tables. You can view all these data using ST03N. The lower left tree of ST03N titled Analysis Views shows the available datasets (see the following screenshot).
The first entry Workload Overview of the tree unfortunately needs a special treatment. To retrieve this data from the database you need to call another function SAPWL_WORKLOAD_GET_SUMMARY. The interface is shown here:
The importing parameter are the same as for SAPWL_WORKLOAD_GET_STATISTIC.
Now you are able to implement a program reading the ST03N datasets. But one question remains: Before you can read ST03N datasets you need to know which datasets are available. How can you read the contents of the workload database? The answer is easy: SAPWL_WORKLOAD_GET_DIRECTORY is the name of the function which gives you the table of contents. ST03N uses this function to build the directory tree of ST03N. An example is shown by the following screenshot.