Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 

Motivation

    In my previous blog, I have described the analytical features shipped with SAP NetWeaver 7.3, EhP 1, SP6 of SAP NetWeaver BPM that are represented by the NWA dashboard and the BPM Analytics API. Here, I'll give the coding example of a web service which uses the BPM Analytics API and show how to use the developed web service to create a report in Crystal Reports. The code of the web service is available here.

Development of the Custom Web Service Using the BPM Analytics API

As the coding example here, we shall use the standard web service developed in NWDI. The interface of the service represents a facade for the BPM Analytics API. The methods of the interface are as follows:

public int getCountOfProcessesInError () throws Exception;
public int getCountOfTasksEscalated () throws Exception;
public int getCountOfTasksInError () throws Exception;
public int getCountOfTasksWithoutOwner () throws Exception;
public List<String> getEventTypes ();
public List<EventStatisticsWrapper> getEventStatistics (Date startTime, Date endTime, List<String> eventTypes, long intervalInMilliseconds) throws Exception;
public List<String> getProcesssStatuses ();
public List<DurationStatisticsWrapper> getProcessDurationStatistics(Date startTime, Date endTime, String processStatus, int noOfTopProcessModels) throws Exception;
public List<StatusStatisticsWrapper> getProcessStatusStatistics (Date startTime, Date endTime, List<String> processStatuses, int noOfTopProcessModels) throws Exception;
public List<String> getTaskStatuses ();
public List<DurationStatisticsWrapper> getTaskDurationStatistics (Date startTime, Date endTime, String taskStatus, int noOfTopProcessModels) throws Exception;
public List<StatusStatisticsWrapper> getTaskStatusStatistics (Date startTime, Date endTime, List<String> taskStatuses, int noOfTopProcessModels) throws Exception;

     We use the wrapping classes (e.g. DurationStatisticsWrapper) as containers for pieces of statistical information for proper XML formatting of the web service responses.

     To correctly assess user authentication, the interface of the web service should be annotated as follows:

@AuthenticationRT(AuthenticationMethod = { "sapsp:HTTPBasic", "sapsp:HTTPSSO2" })
@AuthenticationDT(authenticationLevel = AuthenticationEnumsAuthenticationLevel.BASIC)

    Otherwise, all the calls of the methods of the BPM Analytics API would be considered to be fired by the guest user who is very unlikely to be a business process or task administrator for any process or task instances.

Using the Developed Web Service in Crystal Reports

In this section, I'll describe a way to create a custom report in Crystal Reports which uses the previously developed web service.

The report will provide the information about the duration of the processes that currently have the status IN_PROCESS.

So, the first step after deployment of the web service in the system is to create a standard report. This can be done by going to File -> New -> Standard Report... (or Ctrl + N shortcut):

After this, the data source connection properties should be specified. We shall use the WSDL file of the previously deployed web service. It can be accessed from Single Service Administration perspective in NWA:

Now we select XML and Web Services from the list of available data sources and toggle the Use HTTP(S) WSDL URL option where we specify the WSDL of the previously deployed web service:

After that, we provide the credentials of the user of interest. Please, note that the statistics will be obtained for the tasks and processes where the specified user is a process and/or task administrator:

After this, we select the getProcessDurationStatistics method from the list of available methods of the web service.

Now, we specify the input parameters of the method. They are as follows: the process instance creation start and end time, process status (we specify IN_PROGRESS here), and the number of top process models (let's specify 10 here):

After this, we have to select the fields that are going to be used in the report. It would be interesting for us to see the average, minimum, and maximum process execution time as well as the name of the corresponding process model:

Here is how the first report should look like:

After this, we could also specify the sorting options for the items in the table:

Aggregated values are also of interest. For instance, we select the maximum value of the maximum execution time and the minimum value of the minimum execution time of the process instances.

Then, we can also add a chart and specify that for each process model the maximum, minimum, and average execution time will be shown:

Here is how the final report looks like:

Resources

For the introduction into the BPM Analytics API, please, refer to my previous blog.

For further and more detailed information about the functionality of the BPM Analytics API, please, refer to the help documentation.

1 Comment