Sie sind auf Seite 1von 11

 Step-by-Step Guide to Develop XMLP Report using XMLDoc as Data Source Type

o Applicable for PeopleTools 8.48 to PeopleTools 8.50


o Not Valid for PeopleTools 8.51
o Some of the information in the screenshots are modified/removed to protect the
identity of the customer
 What we are trying to achieve
o Create a printable version of the Travel Request information for the employees to
print/sign and submit to the finance department from the Travel Request Transaction
Component/Page
o Screenshot of Employee Transaction Page for viewing Travel Request, with a button to
generate the printable version in PDF format using XMLP
o Screenshot of the printable version of the Travel Request Page after clicking the print button
o Step-by-Step Guide to develop this kind of XMLP Reports
o Create a Data Source – Data Source Type – XMLDoc Object

o My suggestion for creating Sample Data File is to create it using PeopleCode/AE-File


Layout
o My suggestion for creating Schema File will be to use the command line utility trang.jar.
This can be downloaded from http://www.thaiopensource.com/download/. Use the
following command: trang.jar TravelRequest.xml TravelRequest.xsd
o Create the RTF Template based on the requirement and the Sample Data File created in the
above steps
o Create Report Definition
o

o
o
o Write the following PeopleCode in the FieldChange Event of the Print Button. Please note in our
page design we have one record in scroll level 0 and 2 scrolls in level 1. Also note the
winmessage marked in bold and highlighted in yellow can be used to generate the Sample data
file.
o The code consists of 2 part.
o Part 1 creates the XMLDoc
o Part 2 runs the XMLP Report using the class in PeopleSoft delivered Application Package
PSXP_RPTDEFNMANAGER
/************************************************************************/

import PSXP_RPTDEFNMANAGER:*;

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;

If %Page = Page.soa_TR_HDR Then

Local Rowset &rsHeader = GetLevel0();

Local Record &recHeader = GetRecord(Record.soa_TR_HDR);

Local XmlDoc &xmldocRoot = CreateXmlDoc("<?xml version='1.0'?><root></root>");

Local XmlNode &nodeRoot = &xmldocRoot.DocumentElement;


Local XmlNode &nodeCurrent, &nodeParent, &nodeDetail, &nodeAudit;

/* Header Elements */

&nodeCurrent = &nodeRoot.AddElement("soa_reimb_id");

&nodeCurrent.NodeValue = &recHeader.soa_REIMB_ID.Value;

&nodeCurrent = &nodeRoot.AddElement("rpt_date");

&nodeCurrent.NodeValue = String(%Date);

&nodeCurrent = &nodeRoot.AddElement("rpt_time");

&nodeCurrent.NodeValue = Substring(String(%Time), 0, 5);

&nodeCurrent = &nodeRoot.AddElement("soa_travel_type");

&nodeCurrent.NodeValue = "Travel Request";

&nodeCurrent = &nodeRoot.AddElement("name");

&nodeCurrent.NodeValue = &recHeader.GetField(Field.NAME).Value;

&nodeCurrent = &nodeRoot.AddElement("emplid");

&nodeCurrent.NodeValue = &recHeader.EMPLID.Value;

&nodeCurrent = &nodeRoot.AddElement("soa_reimb_status");

SQLExec("select xlatlongname from psxlatitem a where fieldname=:1 and fieldvalue=:2 and


a.effdt = (select max(b.effdt) from psxlatitem b where a.fieldname=b.fieldname and
a.fieldvalue=b.fieldvalue and b.effdt <=%DateIn(:3)) ", "soa_REIMB_STATUS",
&recHeader.soa_REIMB_STATUS.Value, %Date, &ReimbStatus);

&nodeCurrent.NodeValue = &ReimbStatus;

&nodeCurrent = &nodeRoot.AddElement("soa_busn_purpose");

SQLExec("select xlatlongname from psxlatitem a where fieldname=:1 and fieldvalue=:2 and


a.effdt = (select max(b.effdt) from psxlatitem b where a.fieldname=b.fieldname and
a.fieldvalue=b.fieldvalue and b.effdt <=%DateIn(:3)) ", "soa_BUSN_PURPOSE",
&recHeader.soa_BUSN_PURPOSE.Value, %Date, &BusnPurpose);

&nodeCurrent.NodeValue = &BusnPurpose;
&nodeCurrent = &nodeRoot.AddElement("grade");

&nodeCurrent.NodeValue = &recHeader.GRADE.Value;

&nodeCurrent = &nodeRoot.AddElement("deptid");

&nodeCurrent.NodeValue = &recHeader.DEPTID.Value;

&nodeCurrent = &nodeRoot.AddElement("business_unit");

&nodeCurrent.NodeValue = &recHeader.BUSINESS_UNIT.Value;

&nodeCurrent = &nodeRoot.AddElement("phone");

&nodeCurrent.NodeValue = &recHeader.PHONE.Value;

&nodeCurrent = &nodeRoot.AddElement("end_dt");

&nodeCurrent.NodeValue = &recHeader.END_DT.Value;

&nodeCurrent = &nodeRoot.AddElement("start_dt");

&nodeCurrent.NodeValue = &recHeader.START_DT.Value;

/**************************************************/

/* Details */

Local Rowset &rsDetailItem = GetLevel0()(1).GetRowset(Scroll.soa_TR_DTL);

For &k = 1 To &rsDetailItem.ActiveRowCount

Local Record &recDtlItem = &rsDetailItem(&k).GetRecord(Record.soa_TR_DTL);

/* Only include real detail items as sometimes there's a dummy tools row which we */

/* don't want. We check if this is a real row by seeing if the value is populated. */

If All(&recDtlItem.soa_EXPENSE_TYPE.Value) Then

&nodeDetail = &nodeRoot.AddElement("detail");

&nodeCurrent = &nodeDetail.AddElement("soa_expense_type");

&nodeCurrent.NodeValue = &recDtlItem.soa_EXPENSE_TYPE.Value;

&nodeCurrent = &nodeDetail.AddElement("soa_bkng_dt");

&nodeCurrent.NodeValue = &recDtlItem.soa_BKNG_DT.Value;
&nodeCurrent = &nodeDetail.AddElement("soa_orig_loc");

&nodeCurrent.NodeValue = &recDtlItem.soa_ORIG_LOC.Value;

&nodeCurrent = &nodeDetail.AddElement("soa_dest_loc");

&nodeCurrent.NodeValue = &recDtlItem.soa_DEST_LOC.Value;

&nodeCurrent = &nodeDetail.AddElement("soa_prfrd_mrchnt");

&nodeCurrent.NodeValue = &recDtlItem.soa_PRFRD_MRCHNT.Value;

&nodeCurrent = &nodeDetail.AddElement("descr");

&nodeCurrent.NodeValue = &recDtlItem.DESCR.Value;

End-If

End-For;

/* Audit */

Local Rowset &rsAuditItem = GetLevel0()(1).GetRowset(Scroll.soa_TR_AUDIT);

For &k = 1 To &rsAuditItem.ActiveRowCount

Local Record &recAuditItem = &rsAuditItem(&k).GetRecord(Record.soa_TR_AUDIT);

/* Only include real detail items as sometimes there's a dummy tools row which we */

/* don't want. We check if this is a real row by seeing if the value is popuated. */

If All(&recAuditItem.DATETIME_UPDATED.Value) Then

&nodeDetail = &nodeRoot.AddElement("audit");

&nodeCurrent = &nodeDetail.AddElement("datetime_updated");

&nodeCurrent.NodeValue = Substring(&recAuditItem.DATETIME_UPDATED.Value, 0, 10);

&nodeCurrent = &nodeDetail.AddElement("oprid");

&nodeCurrent.NodeValue = &recAuditItem.OPRID.Value;

&nodeCurrent = &nodeDetail.AddElement("soa_reimb_status");
SQLExec("select xlatlongname from psxlatitem a where fieldname=:1 and fieldvalue=:2 and
a.effdt = (select max(b.effdt) from psxlatitem b where a.fieldname=b.fieldname and
a.fieldvalue=b.fieldvalue and b.effdt <=%DateIn(:3)) ", "soa_REIMB_STATUS",
&recAuditItem.soa_REIMB_STATUS.Value, %Date, &AuditReimbStatus);

&nodeCurrent.NodeValue = &AuditReimbStatus;

&nodeCurrent = &nodeDetail.AddElement("comments_254");

&nodeCurrent.NodeValue = &recAuditItem.COMMENTS_254.Value;

End-If

End-For;

/********************************************************/

rem WinMessage(&xmldocRoot.GenXmlString());

try

/* detect system directory separator */

&sDirSep = GetDirSeparator();

/* create process directory */

CreateDirectory("XMLP", %FilePath_Relative);

/* start logging */

WriteToLog(%ApplicationLogFence_Level1, "*** XML Publisher View Report Job Start: " |


String(%Datetime) | "***");

WriteToLog(%ApplicationLogFence_Level1, "Report Name = " | "soa_TRAVEL_R");

WriteToLog(%ApplicationLogFence_Level1, "As of Date = " | %Date);

WriteToLog(%ApplicationLogFence_Level1, "Output Format = " | 2);

WriteToLog(%ApplicationLogFence_Level1, "Language Code = " | %Language_User);

/* create report defn object */

&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn("soa_TRAVEL_R");


&oRptDefn.Get();

/* output directory */

&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;

&oRptDefn.SetRuntimeDataXMLDoc(&xmldocRoot);

&oRptDefn.ProcessReport(&sTemplateId, %Language_User, %Date, "");

&sFileExt = GetFileExtension(&sOutputFormat);

CommitWork();

/* display the output */

&oRptDefn.DisplayOutput();

/* cleanup */

DeleteLocalFile(&sOutputFile, %FilePath_Absolute);

WriteToLog(%ApplicationLogFence_Level1, "*** XML Publisher View Report Job End: " |


String(%Datetime) | "***");

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-If;

/*************************************************************************/

Das könnte Ihnen auch gefallen