You are on page 1of 5

Reports with XML Publisher

(Using BI Publisher and Microsoft Word)


Connected Query Report

Date 08/03/2013
By Ayesha Jaffar

1. Go to Reporting Tools -> Connected Query ->Connected Query Quick Start

2.
3.
4.
5.

After pressing Next you have to select parent query table and child parent query for connecting.
Map fields in parent child relationship for maintain connection and press next.
Check that below given xml is according to your data and click Complete.
Go to Reporting Tools -> Connected Query -> Connected Query Viewer search there this query
by name.
6. Click Preview XML link and save this this in C:\temp.
7. Now make report named MY_PR_REPORT and upload this document in that. Then that report
must be give us its own generated XML file.

In App Designer:
1.
2.
3.
4.

Create New Project PROJ_CON_REPORT.


Create Record MY_DEMO_WORK. Add two fields GENRATE_PB1 and TEST_COMPONENT.
Open and Insert Record SA_TEST_CMP_TBL. (It will use as prompt).
Create a page and drag field TEST_COMPONENT from record MY_DEMO_WORK And add
button from menu bar.
5. Set button properties record as MY_DEMO_WORK and field as GENERATE_PB1.
6. Add Code (given below) on the event of FieldChange of GENERATE_PB1.
import PSXP_RPTDEFNMANAGER:*;
Local Record &rcdQryPrompts;

Local string &LanguageCd, &MyTemplate, &MyReportName, &OutFormat, &State;


Local date &AsOfDate;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Set XML Publisher report required parameters
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&LanguageCd = "";
&AsOfDate = %Date;
&OutFormat = "PDF";
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Create a PDF using XML Report Definition MY_XMLP_DEMO
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&MyReportName = "MY_PR_REPORT";
&MyTemplate = "MY_PR_REPORT_1";
rem &MyReportName = "MY_CON_REPT";
rem &MyTemplate = "MY_CON_REPT_1";

*/

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Hard code my State value - would normally pull from a field on the page */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
try
rem &State = GetField(CC_TEMP_DEPT.DEPARTMENT_ID).Value;

If GetField(MY_DEMO_WORK.TEST_COMPONENT).Value <> "" Then


SQLExec("TRUNCATE TABLE PS_MY_DEMO_WORK");
SQLExec("INSERT INTO PS_MY_DEMO_WORK(GENERATE_PB1,TEST_COMPONENT) VALUES(:1,:2)", 2,
GetField(MY_DEMO_WORK.TEST_COMPONENT).Value);
Else
&MyReportName = "CONN_REPORT";
&MyTemplate = "CONN_REPORT_1";
End-If;

GetField(MY_DEMO_WORK.TEST_COMPONENT).Value = "";
/*MessageBox(0, "", 0, 1, GetField(GEN_CONN_REPORT.DEPARTMENT_ID).Value);*/
CommitWork();
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Declare and Instantiate (construct) your Report Definition Object
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn = create

*/

PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Get a handle on your Report Definition
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&oReportDefn.Get();
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Since there is a prompt to the query used in this report, you need to */
/* provide the value for the prompt
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* &rcdQryPrompts = &oReportDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
&oReportDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Provide a value to the State Prompt
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
REM &rcdQryPrompts.DEPARTMENT_ID.Value = 1;
REM End-If;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Kick of the report process
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
rem MessageBox(0, "", 0, 1, "abc");
&oReportDefn.ProcessReport(&MyTemplate, &LanguageCd, &AsOfDate, &OutFormat);
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* CommitWork must be called prior to displaying the output since the */
/* application package performed work and SQL statements. If you do
*/
/* not commit the work performed to this point you will receive an
*/
/* error like Think-time PeopleCode event (ViewAttachment), but a SQL */
/* update has occurred in the commit interval. (2, 148)
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
CommitWork();
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Display Report to the user
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&oReportDefn.DisplayOutput();
end-try;

Now you can add component and menu to register it on portal.


Good Luck!

Note:
Make 1 report for all data and 1 for selection. Means make 2 reports.

You might also like