How to Generate XML Publisher from Record Page and Run BI Publisher in PeopleCode

How to Generate XML Publisher from Record Page and Run BI Publisher in PeopleCode

How to select data on scroll area or data grid or data level 0 from page in peoplesoft.

Page for get data for create xml file and run bi publisher by peoplecod.

  1. Create Link or Button and use FieldChange Event : print pdf

 

2. Create PeopleCode for Run BI Publisher.

2.1 Create XML file for Data of RTF Template (Other Template)

               2.1.1 Create Datasource is XML type before create RTF Template go to Reporting tool > BI Publisher > Data Source

Data Source Type =XML

Data Source = Create Name

2.1.2 Upload xml file

2.1.3 Create Report Definition

  

2.2 Generate Report By Peoplecode

 

import PSXP_RPTDEFNMANAGER:*;
import EP_FUNCTIONS:EP_Utilities;

Declare Function GetDirSeparator PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;
Declare Function GetFileExtension PeopleCode PSXPFUNCLIB.FUNCLIB FieldFormula;

&EP_Utilities = create EP_FUNCTIONS:EP_Utilities();

Local XmlDoc &xmldocRoot = CreateXmlDoc(“<?xml version=’1.0′ encoding = ‘UTF-8’?><root></root>”);
Local XmlNode &nodeRoot = &xmldocRoot.DocumentElement;
Local XmlNode &nodeCurrent, &nodeParent, &nodeEvaluation, &nodeSection, &nodeItem, &nodeSubItem, &nodeEmployee;
/***********************************************************************************/

/*—- 2.1 Create XML file for Create RTF Template (Other Template) —*/

/*— Selete Data from Page —*/

&nodeCurrent = &nodeRoot.AddElement(“EMPLID”);
&nodeCurrent.NodeValue = TEST_DERIVED.EMPLID;
&nodeCurrent = &nodeRoot.AddElement(“NAME”);
&nodeCurrent.NodeValue = TEST_DERIVED.NAME;
&nodeCurrent = &nodeRoot.AddElement(“NATIONAL_ID”);
&nodeCurrent.NodeValue = TEST_DERIVED.NATIONAL_ID;
&nodeCurrent = &nodeRoot.AddElement(“DEPT_DESCR”);
&nodeCurrent.NodeValue = DEPT_TBL.DESCR254;

/*********Add list Element Scroll Left ***********/
Local Rowset &RS_LEV0, &RS_SECT1, &RS_SECT2;
Local Row &ROW1, &ROW2;

&RS_LEV0 = GetLevel0();
&listNode = &nodeRoot.AddElement(“LIST_ITEM”);

/*—– SCROLL LEFT —-*/
&RS_SECT1 = &RS_LEV0(1).GetRowset(Scroll.TEST_PSVARIABLE);

For &i = 1 To &RS_SECT1.ActiveRowCount

/*– Where condition data in scroll left of page–*/
If (&RS_SECT1(&i).TEST_PSVARIABLE.TEST_PS_FIX.Value = “Y”)  Then

&subNodeCurrent = &listNode.AddElement(“DESCRIPTION” | &i);
&subNodeCurrent.NodeValue = &RS_SECT1(&i).TEST_PSVARIABLE.DESCRIPTION.Value;

&subNodeCurrent = &listNode.AddElement(“DESCR_CALC” | &i);
&subNodeCurrent.NodeValue = &RS_SECT1(&i).TEST_PSVARIABLE.DESCR_CALC.Value;

End-If;

End-For;

/*—– SCROLL RIGHT —-*/

&RS_SECT2 = &RS_LEV0(1).GetRowset(Scroll.TEST_PSVARIABLE2);

For &i = 1 To &RS_SECT2.ActiveRowCount

/*– Where condition data in scroll right of page–*/
If (&RS_SECT2(&i).TEST_PSVARIABLE2.TEST_PS_FIX.Value = “Y”)  Then

&subNodeCurrent = &listNode.AddElement(“DESCRIPTION2” | &i);
&subNodeCurrent.NodeValue = &RS_SECT1(&i).TEST_PSVARIABLE2.DESCRIPTION.Value;

&subNodeCurrent = &listNode.AddElement(“DESCR_CALC2” | &i);
&subNodeCurrent.NodeValue = &RS_SECT2(&i).TEST_PSVARIABLE2.DESCR_CALC.Value;

End-If;

End-For;

&sFormattedXML = &xmldocRoot.GenFormattedXmlString();

/*– WinMessage for Get XML File for Data Source of this report –*/
WinMessage(&sFormattedXML);

 

/***********************************************************************************/
/*— (2.2) Generate Report —*/
Local date &AsOfDate;
Local string &LanguageCd, &MyReportName, &OutFormat, &sTemplateId;
try

/* detect system directory separator */
rem &sDirSep = GetDirSeparator();
/* create process directory */
rem WinMessage(“%FilePath_Relative : ” | %FilePath_Relative, 0);
CreateDirectory(“XMLP”, %FilePath_Relative);

/* Set XML Publisher report required parameters */
&LanguageCd = %Language_User;
&AsOfDate = %Date;
&MyReportName = “COACHING”;

/* create report defn object */
&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);
&oRptDefn.Get();

&oRptDefn.SetRuntimeDataXMLDoc(&xmldocRoot);
&oRptDefn.ProcessReport(&sTemplateId, &LanguageCd, &AsOfDate, “”);
&sFileExt = GetFileExtension(&sOutputFormat);
CommitWork();

/* display the output */
&oRptDefn.DisplayOutput();

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;

Posted in Peoplecode, PeopleSoft, Peoplesoft BI Publisher, XML Publisher.