Archive for August, 2008

Creating an XML Export File with PeopleSoft


Part of MICA‘s web redesign project is going to involve doing data integration between our CMS (Ingeniux), and our HRMS (PeopleSoft).  Recently I have been playing with XML Publisher, and the flat files that it produces seem so perfect for distribution to our CMS.  I was a little disappointed that the XML documents that XML Publisher creates are not exposed for use as an integration point between systems.

So I began looking for other alternatives.

Integration Broker seems to be quite the rage for the moment.  After poking around with that, it seemed like a lot of work for what would ultimately be a flat file that is updated periodically when things like course descriptions, or degree plans changed.  While this may be useful for more interactive or personalized content, it doesn’t really fit the bill for static content.

The “simplest” (remember, this is PeopleSoft) way I found to create an XML file similar to the one created by XML Publisher is using File Layouts in Application Designer.

The rest of this article is about creating a simple File Layout.

There are 4 basic parts to creating a File Layout.

  1. Create or Select a Record for your data.  I used a view, to avoid having to deal with joins in PeopleCode.
  2. Create a File Layout Definition.
  3. Create an Application Engine Program, with a tiny bit of code in it.
  4. Stuff all these things into a project so you can maintain your sanity at a later time.

After you have selected the record with the data you want to export, create a new File Layout Definition (File->New Definition->File Layout).

New File Layout Definition

On the definition tab, right click “NEW FILE” and select Insert Record.  Search for the record you are using for your data, and double click it.  The Record Definition, and its columns will show up under “NEW FILE” now.  Save your File Layout Definition.

File Layout Definition

Click the Property Icon (Application Designer Property Icon), then click the “Use” tab, and select XML in the “File Layout Format” drop down. Click OK.

File Layout Property \

Create a new Application Engine Program (File->New->Application Engine Program).  Right click “Step01” and select “Insert Action”.  Click where it says “SQL”, and select “PeopleCode” from the drop down.

Application Engine Program New

Double click the new action to edit the PeopleCode.  Copy and paste this PeopleCode into the window:

Local Record &Rec;
Local File &File;
Local SQL &SQL;


&File = GetFile("c:\temp\export_sample.xml", "W", %FilePath_Absolute);
If &File.IsOpen Then
If &File.SetFileLayout(FileLayout.YOUR_FILE_LAYOUT_DEFINITION) Then
&Rec = CreateRecord(Record.YOUR_RECORD_DEFINITION);
&SQL = CreateSQL("%Selectall(:1)", &Rec);
While &SQL.Fetch(&Rec)
&File.WriteRecord(&Rec);
&File.WriteLine("</
YOUR_RECORD_DEFINITION>");
End-While;
Else
Error ("File Layout Not Correct");
End-If;
Else
Error ("file not open");
End-If;
&File.Close();

Save the above Peoplecode and close this window.  Insert all these definitions into your project, and make sure you build it, creating any views and tables you may have created for your data.  Click the Run Program Icon (Application Designer Run Program Icon), and voila: you have a XML file which can be used outside of PeopleSoft (View the File Layout XML Sample)