BI Publisher Classes Example

The following example provides a complete example of the code first, then goes through the program line by line.

In the following example, a report is created from an existing report definition. It is populated with an already instantiated and populated XmlDoc object, then published.

The following is the complete code sample: the steps explain each line.

import PSXP_RPTDEFNMANAGER:ReportDefn;

Local string &sFileName = "c:\path\filename.xml";
Local string &rptDefnId = "Financial";
Local string &LanguageCode = "ENG";
Local date &effdt = Date(20090821);
Local string &outputfmt = "HTM";

Local string &folderName = "General";
Local string &serverName = "PSNT";
Local PSXP_RPTDEFNMANAGER:ReportDefn &rptDefn;

&rptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&rptDefnId);
&rptDefn.Get();
&rptDefn.SetRuntimeDataXMLFile(&sFileName);
&rptDefn.ProcessReport("", &languageCd, &effdt, &outputfmt);

&rptDefn.Publish(&serverName, "", &folderName, &PID);

To generate and publish a report:

  1. Import the appropriate application class.

    Because this program generates and publishes a report, you need to import the report manager definition class.

    import PSXP_RPTDEFNMANAGER:ReportDefn;
  2. Initialize variables.

    The variable declaration strings not only specify values for the variables, but give them type and scope as well. This can be very useful when debugging.

    Local string &sFileName = "c:\path\filename.xml";
    Local string &rptDefnId = "Financial";
    Local string &LanguageCode = "ENG";
    Local date &effdt = Date(20090821);
    Local string &outputfmt = "HTM";
    
    Local string &folderName = "General";
    Local string &serverName = "PSNT";
    Local PSXP_RPTDEFNMANAGER:ReportDefn &rptDefn;
    
  3. Instantiate the report definition object and initialize it.

    After you instantiate a report definition object, you must initialize it and populate it using the Get method.

    &rptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&rptDefnId);
    &rptDefn.Get();
    
  4. Specify the data for the report.

    This report uses an XML file as the data source, so you must specify the runtime data source for the report before you process it.

    &rptDefn.SetRuntimeDataXMLFile(&sFileName);
  5. Process the report.

    You must process the report, generate a version of it for the report repository, before you can distribute the report.

    &rptDefn.ProcessReport("", &languageCd, &effdt, &outputfmt); 
  6. Publish the report.

    After you've generated the report, you may want to publish it to another location.

    &rptDefn.Publish(&serverName, "", &folderName, &PID);