Wednesday, 14 May 2014

How to create a XMLP Report with PS Query as data source and using PeopleCode?

What we are trying to achieve?

o   Create a XMLP report in pdf format of the content item information by clicking on a button on the page
o   Screenshot of the content item for the content type ‘COMPETENCY’, with a print button (highlighted in yellow) to the trigger the PeopleCode which generates XMLP report in PDF format.


o   Screenshot of the report output of the content item page after clicking the print button


·     Step-by-Step Guide to develop the above mentioned XMLP Report

o   Create a PSQuery which will list the content item information as displayed on page.




o   Create a Data Source of type “PS Query” using the PSQuery created in the above step


o   Under “Generate File” column you will see two links as ‘Generate’, click on both the links to generate XML and XSD files as highlighted in yellow.
o   The moment you click on Generate link, automatically XML and XSD file will be generated with a link under “File Column”.
o   Click on the first .XML file and .XSD File link to download the xml and xsd to your local machine (Use IE browser)  
o   Download and Install ‘Designer Helper’ in case not installed

o   Open Microsoft office word, click on the add-ins tab, click on the ‘Data’ and select ‘Load XML Data’, upload the XML file you have just downloaded on your local machine and ‘Load XSD Schema’ file from your local machine.
o   After loading data, you will get a confirm message ‘Data Load Successfully’.


o   Click on the ‘Insert’ tab, select Table wizard, select table then select columns which you want to show in your report and click next and finish as shown below


o   Template is ready with the fields as shown below:


o   Instead of using table wizard, you can directly drag and drop fields (use free form) in the template according to your business requirements.
o   Save the template as .RTF format
o   Create Report Definition, provide the name of your report definition
o   Select the data source id, which you have created earlier, from the prompt
o   Screenshot below for your reference
        

o   Upload the .rtf template you have created


o   Select output format type as PDF


                         o   Save the report definition.
o   Open application designer, write the following PeopleCode in the FieldChange Event of the Print Button. Please note in our page design we have level 0 and level 1.
o   The code consists of two parts.
      Part 1 provides all the prompt values which you have used in your PS Query as highlighted.
      Part 2 runs the XMLP Report using the class in PeopleSoft delivered Application Package
o   Provide the report definition and template id which you have created earlier as highlighted below:

===================PS Query code for XMLP Report=================

/* Include Application Package – Used for setting output format and process report */
import PSXP_RPTDEFNMANAGER:*;     
/* Declare delivered functions for specific tasks like setting up directory path, file extension etc  */
Declare Function DeleteLocalFile PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;
Declare Function GetDirSeparator PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;
Declare Function GetFileNameFromPath PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;
Declare Function GetDirectoryFromPath PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;
Declare Function GetFileExtension PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;

/* Declare variables */
Local PSXP_RPTDEFNMANAGER:ReportDefn &oRptDefn;
Local PSXP_RPTDEFNMANAGER:Utility &oUtil;
Local string &sDataDir;                       /* Data directory name*/
Local string &sDirSep;                         /* Directory separator */                  
Local string &sRptDefn;                      /* Contain report definition id */
Local string &sTemplateId;                 /* Contain template Id */
Local string &sOutputFile;                  /* Output file name  */
Local date &dAsOfDate;                     /* Date of running report */
Local string &sOutputFormat, &sFileExt;                         /*  Report output format and File extension */
Local Record &rcdQryPrompts;                        /* PS Query prompt record */
Local string &sOutputDir, &RptOutputDir;      /* Output directory and Report repository */

/* Try catch block starts */
Try
/* Provide report definition id*/
   &sRptDefn = "DK_CONTENT";
/*Provide template id defined in the report definition */
   &sTemplateId = " DK_CONTENT_1";
/* Current Date of execution*/
   &dAsOfDate = %Date;
   /* detect system directory separator */
   &sDirSep = GetDirSeparator();
   /* this method will create process directory in PSHOME server */
   CreateDirectory("XMLP", %FilePath_Relative);
   /* start logging for debugging purpose */
   WriteToLog(%ApplicationLogFence_Level1, "*** XML Publisher View Report Job Start: " | String(%Datetime) | "***");
   WriteToLog(%ApplicationLogFence_Level1, "Report Name = " | &sRptDefn);
   WriteToLog(%ApplicationLogFence_Level1, "Template id = " | &sTemplateId);
   WriteToLog(%ApplicationLogFence_Level1, "As of Date = " | &dAsOfDate);
   WriteToLog(%ApplicationLogFence_Level1, "Output Format = " | &sOutputFormat);
   WriteToLog(%ApplicationLogFence_Level1, "Language Code = " | %Language_User);
  
   /* instantiate report definition object and pass report definition id  */
   &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn);
   &oRptDefn.Get();
 
   /* output directory – after running the report the pdf output will be generated in the report repository */
   &RptOutputDir = GetEnv("PS_SERVDIR") | &sDirSep | "files" | &sDirSep | "XMLP" | &sDirSep | UuidGen();
   &sOutputDir = &RptOutputDir | &sDirSep | "RptInst";
   &sDataDir = &RptOutputDir | &sDirSep | "Data";
   CreateDirectory(&sOutputDir, %FilePath_Absolute);
   CreateDirectory(&sDataDir, %FilePath_Absolute);
 
   &oRptDefn.OutDestination = &RptOutputDir;
   /* select Output format in PDF specified as function parameter ‘2’ */
  /* 2 - PDF */
  /* 5 - HTM */
  /* 8 - XLS */
  /* 12 - RTF */
  
&sOutputFormat = &oRptDefn.GetOutDestFormatString(Value("2"));
   /* fill PS Query prompt record with values */
   &rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord();
   If Not &rcdQryPrompts = Null Then
 &rcdQryPrompts.JPM_CAT_TYPE.Value = JPM_CAT_ITEMS.JPM_CAT_TYPE.Value;
&rcdQryPrompts.JPM_CAT_ITEM_ID.Value = JPM_CAT_ITEMS.JPM_CAT_ITEM_ID.Value;
                /* Set all the prompt values in the PS Query  */
 &oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts);     
   End-If;
       /* Call process report function with template id, language, current date and output format in PDF  as function parameters */
   &oRptDefn.ProcessReport(&sTemplateId, %Language_User, &dAsOfDate, &sOutputFormat);
 /* Set file extension like PDF, HTM, XLS or RTF */
  &sFileExt = GetFileExtension(&sOutputFormat);
   CommitWork();
   /* Display the output  method will fetch the report from report repository and open the report it in a new browser */
   &oRptDefn.DisplayOutput();
   /* cleanup cache */
   DeleteLocalFile(&sOutputFile, %FilePath_Absolute);
   WriteToLog(%ApplicationLogFence_Level1, "*** XML Publisher View Report Job End: " | String(%Datetime) | "***");
/* Catch block starts */
catch Exception &Err
   Local string &sSub1, &sSub2, &sSub3, &sSub4, &sSub5;
   Evaluate &Err.SubstitutionCount
   When > 4
      &sSub5 = &Err.GetSubstitution(5);
   When > 3
      &sSub4 = &Err.GetSubstitution(4);
   When > 2
      &sSub3 = &Err.GetSubstitution(3);
   When > 1
      &sSub2 = &Err.GetSubstitution(2);
   When > 0
      &sSub1 = &Err.GetSubstitution(1);
   End-Evaluate;
   Error MsgGet(&Err.MessageSetNumber, &Err.MessageNumber, &Err.ToString(), &sSub1, &sSub2, &sSub3, &sSub4, &sSub5);
end-try;
/* End of Code */

Limitations:

  • This code will only work with the PS Query data source.
  • This code will not work for the report which fetches data directly from the page buffer instead from physical database record.
Contributed by Rohit

Thursday, 8 May 2014

PeopleSoft Test Framework Installation and Configuration - Part 2

In this follow up post, we will take a look at the configurations we need to do once the PTF client is installed.

Once the application is launched, the Local options and the Execution options need to be configured.

Configuring Local Options

Local Options and Execution options can be accessed by clicking the database name with a '@' symbol prefixed to it on the top left corner of the PTF client.


The local options are specific to the machine where the PTF client is installed. The process run options define the settings for timeout for each process status. With the configuration below, if a process invoked by PTF is in queued or posting status for 1 min, then the test will log a warning message.

Similarly, the output folder and the output format can be defined if PSQuery is run from PTF.


Configuring Execution Options

Unlike Local options which are specific to a machine where it is installed, execution options once defined – are stored in the application database, and are available for anyone who logins to that application database to create, modify test assets. Only the administrator (who has PTF Administrator role) can configure the execution options for a database.

An execution option is for a specific application – so if two applications are to be tested from the same PTF client, then we would require two execution options, one for each application.
           
Basic Options
Under the basic options tab, the URL for the application needs to be given along with the default user ID and password. This URL is used to launch the application when a recorded test is played back.
The process server and the date format can also be defined in this section.
Skip PageSave will skip the step in the test case which attempts to save the component.

       
      
Advanced Options       
Advanced Options tab provides the option to enable persistent variables in the environment. Persistent variables store information that can be accessed whenever the application database is used in PTF client. They are similar to registry variables.

           
PeopleTools Options
It is in PeopleTools Options tab, we provide the database user ID and password. This is very important – as this information is used to retrieve test assets already stored in the database.


Log Export
In this tab, we define where the log files generated by the test cases are to be posted. A test case log can also have snapshots of the PeopleSoft screens, and 'Export Images' option in this tab will export the screenshots as images in the log export file.       


Note: The installation and the screenshots in this post are from PeopleTools version 8.53. This might be different from the earlier version of tools. 

Contributed by Karthik and Swetanshu

PeopleSoft Test Framework Installation and Configuration - Part 1

Introduction

PeopleSoft Test Framework (PTF) is a functional testing tool delivered by Oracle starting from PeopleTools version 8.51. This tool employs record and playback approach, and is meant to simulate one user working on a system at any point of time. This is not a load testing tool and the test assets created using the PTF tool are PeopleSoft managed objects - similar to records, pages and components.


The development instance of PTF should have:

1.   PTF client instance
2.   Connection to PeopleSoft application where we conduct tests
3.   Microsoft Internet Explorer browser (preferably IE8 and above)
4.   Connection to PeopleSoft application database where the test assets are stored 

The scope of this post is to explain the steps involved in the installation of the PTF client, and the configuration of the same.


Prerequisites

Verify Integration Broker Setup 
·         Go to Main Menu > PeopleTools > Integration Broker > Configuration > Gateways
·         Ping Gateway and see if it is active

   
·         Click the Gateway Setup Properties link on the same page. Sign on to integration gateway properties file, and verify if the default app server URL is specified.

Configuring the Web Profile
·         Go to Main Menu > Peopletools > Web Profile > Web Profile Configuration
·         Select the profile name of the environment and click on Debugging tab.


·      As shown in the above screenshot, check the 'Show Connection & Sys Info' and 'Generate HTML for testing' checkboxes. If the 'Show Connection & Sys Info' checkbox is not checked, PTF will not record the component, page and menu names in the test assets. Also, if the 'Generate HTML for testing' is not checked, PTF will not record HTML objects correctly.

 Defining Configuration Options
·         Go to Main Menu > Peopletools > Lifecycle Tools > Test Framework > Define Configuration Options
·         Specify whether untrusted SSL certificates can be allowed, and also specify record options.

Internet Explorer Options
·         Add the PeopleSoft application URL and related domain names to the safe list (Internet Options > Security tab > Local Intranet > Sites button), so that there will not be any issues in launching the application when the PTF test scripts are played back.

Installation

PTF client is a software installed in user's machines, where they can create, modify and execute test assets. The assets that are created in PTF client are stored directly in the application database. This client is similar to Application Designer.

The executable file for PTF is usually available from the path <PS_HOME>\setup\PsTestFramework. Before executing this file, make sure Microsoft .NET framework v3.5 and above is installed in your system.

Step1: Double click the executable file 'setup.exe' available in the path mentioned above. That launches the installation wizard.


Step 2: After providing the path where the application needs to be installed, click Next till the installation completes.



Step 3: Once the installation is complete, go to Start Menu and launch the PTF application



Step 4:  When the application starts, create a new instance (environment where the test assets are to be stored) by clicking the 'New' button.


Step 5:  Provide the database name (where the test assets are to be stored), application server URL and port, the node ID of the application.

Also, the user ID and password need to be provided during this setup – and it should be ensured that the user ID provided should have any of these 3 delivered roles provided by PeopleSoft for PTF.

·         PTF User
·         PTF Editor
·         PTF Administrator

After providing the details, click OK.


Step 6: This will open the PTF client as below



Note: The installation and the screenshots in this post are from PeopleTools version 8.53. This might be different from the earlier version of tools. 

Please take a look at the Part 2 for details on the configuration.

Contributed by Karthik and Swetanshu.