Lifecycle Applications

Engineering Change Management

Creating Custom Reports

Defining scenario-specific reports using reporting APIs

Use Case

Abstract

This article shows how to create a custom report based on specific scenarios using CAA-exposed APIs.

What You Will Learn With This Use Case

This use case demonstrates how to create custom reports by implementing ENOVIReportServices interface and using ENOVReportUtilities. Reporting utilities allow you to register your own class as a reporting source for the Send To->Reporter capabilities and to add objects you want to report to into a publish stream that can then be either made available via an XML file or shown in a browser as an HTML document after being formatted via XSL.

[Top]

The CAAENOVIReportServicesUEImpl Use Case

CAAENOVIReportServicesUEImpl  is a use case of the CAAReportSolutionServer.edu framework that illustrates ENOVReportingSolutionServer framework capabilities.

[Top]

What Does CAAENOVIReportServicesUEImpl Do

This use case demonstrates how to create custom reports by implementing ENOVIReportServices interface and using ENOVReportUtilities. Reporting utilities allow you to register your own class as a reporting source for the Send To->Reporter capabilities and to add objects you want to report to into a publish stream that can then be either made available via an XML file or shown in a browser as an HTML document after being formatted via XSL.

Processing performed by the CAAENOVIReportServicesUEImpl to generate a report can be generally described as:

After XML stream for the report is generated, reporting infrastructure will allow the user to apply a proper layout based on the formatter selected in the UI of Send To->Reporting Editor command.

Reporting views and XSLs that can be applied to each report are specified based on the object type in the ReportSettings.xml file.

This allows users to be able to build a report based on any data available via CAA-exposed APIs and then format it based on their requirements by executing following steps:

More detailed description for each of these steps will be provided in the Step-by-step section.

[Top]

How to Launch CAAENOVIReportServicesUEImpl

To launch CAAENOVIReportServicesUEImpl, you will need to execute the following steps:

[Top]

Where to Find the CAAENOVIReportServicesUEImpl Code

The CAAENOVIReportServicesUEImpl use case is made of one source and one header file located in the CAAENOVIReportServicesUEImpl.m module of the CAAReportSolutionServer.edu framework:

Windows InstallRootDirectory\CAAReportSolutionServer.edu\CAAENOVIReportServicesUEImpl.m\
Unix InstallRootDirectory/CAAReportSolutionServer.edu/CAAENOVIReportServicesUEImpl.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

There are eight logical steps in CAAENOVIReportServicesUEImpl:

  1. Selecting View Type
  2. Creating an ENOVPublihStream for the Report and an ENOVPublishObjectNode to Contain the ECO Report
  3. Generating a Report for ECO Object
  4. Retrieving Actions Pointed by this ECO
  5. Adding Child Actions into the Report
  6. Getting Attachments for Child Actions
  7. Adding Attachments to the Report
  8. Retrieving Report Stream

[Top]

Selecting View Type

...
  cout << "Report type is " << iViewName.ConvertToChar();
...

View type is a parameter passes into the implementation based on the selection made by the user in the Send To->Reporting Editor dialog. All view types available for selection are registered in a ReportSettings.xml file based on the object type. Inside the implementation, code can check the view type and determine the set of objects to be added to this report based on the type (in case when multiple different report types are available for the object type). In this sample, only one report type is provided so it is not controlled by view type.

[Top]

Creating an ENOVPublishStream for the Report and an ENOVPublishObjectNode to Contain the ECO Report

...
  ENOVPublishStream* pubStream = new ENOVPublishStream();
...
  ENOVPublishObjectNode * rootNode = new ENOVPublishObjectNode(pubStream) ;
...

The code above creates a ENOVPublishStream to contain the report, and a dedicated report node to contain an object report later to be filled in by an ECO report (see next section). The parameter passed into ENOVPublishObjectNode is a parent node for the node being constructed. In this case, the stream itself is used as a parent because we are creating a top-level node. This parent parameter can be used to control the structure of the report as will be shown later

[Top]

Generating a Report for ECO Object

...
  ENOVReportUtilities::GetData("one level",currentObject, rootNode, printedObjects);
...

CAA-exposed API ENOVReportUtilities::GetData() allows generation of a basic report for an object. The data for the object added will be generated using the BROWSE mask. Please see documentation for this API for details. In this case, we will generate a basic one-level report on our ECO, and we are going to place it into rootNode we have created above. Last parameter allows tracking of the objects being added to the report.

[Top]

Retrieving Actions Pointed by this ECO

...
  rc = curAction->GetMyPointedActions(childActions);
...

Inside custom implementation of the reports, any available CAA APIs can be used to collect objects that need to be added to the report. In this case, we are getting all child actions of this ECO to be added to the report.

[Top]

Adding Child Actions into the Report

...
 for(int i=1; i<=childActions.Size(); i++) {
   CATIVpmAFLAction_var childAction=childActions[i];
   ...
   ENOVPublishObjectNode * curActionNode = new ENOVPublishObjectNode(rootNode) ;
   rc = ENOVReportUtilities::GetData("one level",(CATIVpmFactoryObject_var)childAction,curActionNode, printedObjects);
 ...

For each child action, we are creating an ENOVPublishObjectNode to contain a report. Please note that when we are creating this node, we use a rootNode as a parent which will result in adding action reports under an EC report. Action report is then generated into this node by using ENOVReportUtilities::GetData as described earlier.

[Top]

Getting Attachments for Child Actions

...
  childAction->GetAllAttachements(attachments);
...

For this particular report example, we are going to retrieve all attachments from these actions to be added to the report. It can be done using existing CAA-exposed APIs.

[Top]

Adding Attachments to the Report

...
   for(int j =1; j <= attachments.Size(); j++) {
     ...
     ENOVPublishObjectNode * curAttachmentNode = new ENOVPublishObjectNode(curActionNode);
     rc = ENOVReportUtilities::GetData("one level",(CATIVpmFactoryObject_var)curAttachment,curAttachmentNode, printedObjects);
     ...

For each attachment, we are creating an ENOVPublishObjectNode to contain a report. Please note that when we are creating this node, we use a curActionNode as a parent which will result in adding attachment report under an EC report. As the result, we are going to have a three-level report hierarchy: ECO->Actions->Attachments. Attachment report is then generated into this node by using ENOVReportUtilities::GetData as described earlier.

[Top]

Retrieving Report Stream

...
   const char* tempStream = NULL;
   tempLength=0;
   int ReturnCode = pubStream->GetStream(tempStream,tempLength);
   oLengthContent=tempLength-1;  // -1 because of /0 at the end of the stream
   oStream = new char[oLengthContent];
   memcpy((char*)oStream,tempStream,oLengthContent);
 ...

After report structure is being created as ENOVPublishStream, the data then has to be converted into a byte array as described above.

[Top]

In Short

The main purpose of this use case is to explain how customers can create specific reports based on their requirements. Customers have a capability to control both content of the report by retrieving objects to be.

[Top]

References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Jun 2004] Document created
[Top]

Copyright © 1994-2002, Dassault Systèmes. All rights reserved.