Friday, May 30, 2008

XML Publisher Part 2

I hope you enjoy the first part XML Publisher Part 1!!! This time we will bring XML Publisher one step up. We will use Application Engine, PeopleCode and XMLP together to produce a nice looking batch report. The concept are like SQR, retrieving data from database via SQL SELECT, formating data and displaying data to a report usually in the form of PDF, CSV, etc.

In order to retrieve data using PeopleCode you need to populate a rowset.
import PSXP_XMLGEN:*;

/*Create Rowset*/
&rs = CreateRowset(Record.PERSONAl_DATA);

You need to fill this rowset with data by doing this;

/*Fill Rowset*/
&rs.FILL("WHERE FILL.EMPLID LIKE 'EID000%'");

You'll notice that I have an import statement on top. That is an delivered Application Package, inside that package are methods that we will use in our code.

We will now create our Sample Data File and Schema File by running the code above and the code below.

/*Create Schema*/
&rds = create PSXP_XMLGEN:RowSetDS(); /*example package method*/
&mySchema = &rds.GetXSDSchema(&rs);
&f1 = GetFile("c:\temp\JOB_XSD.xsd", "W", %FilePath_Absolute);
&f1.WriteLine(&mySchema);
&f1.Close();

/*Create Sample XML File*/
&myXMLFile = &rds.GetXMLData(&rs, "c:\temp\JOB_XSD.xsd");
&f2 = GetFile("c:\temp\JOB_XML.xml", "W", %FilePath_Absolute);
&f2.WriteLine(&myXMLFile);
&f2.Close();


This code will generate two files, an schema file with extension .xsd and sample data file with extension .xml. You need to upload the files in the report category page within PeopleSoft, create Data Source Definition (apply the things you learned from Part 1) choose Rowset data source type instead of PS Query. Also create the Report Definition and Process definition. Add few more lines to the Peoplecode and you will able to run and produce report. Your code should look like this;

import PSXP_RPTDEFNMANAGER:*;
import PSXP_XMLGEN:*;

&sRptDefn = "JOB_DEFN";
&sTemplateId = "JOB_TEMP";
&sLangCode = "";
&dtAsOfDate = %Date;
&sOutputFmt = "PDF";
&RptOutputDir = "c:\temp\" "XMLP";

&ReportDef.OutDestination = &RptOutputDir;

/*Set-Up Report*/
&ReportDef = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn);
&ReportDef.Get();

/*Create Rowset*/
&rs = CreateRowset(Record.PERSONAl_DATA);


/*Fill Rowset*/&rs.FILL("WHERE FILL.EMPLID LIKE 'EID000%'");

/*Create Schema*/
&rds = create PSXP_XMLGEN:RowSetDS(); /*package method*/
&mySchema = &rds.GetXSDSchema(&rs);
&f1 = GetFile("c:\temp\JOB_XSD.xsd", "W", %FilePath_Absolute);
&f1.WriteLine(&mySchema);
&f1.Close();


/*Create Sample XML File*/
&myXMLFile = &rds.GetXMLData(&rs, "c:\temp\JOB_XSD.xsd");
&f2 = GetFile("c:\temp\JOB_XML.xml", "W", %FilePath_Absolute);
&f2.WriteLine(&myXMLFile);
&f2.Close();


/* output format */
&sOutputFormat = &sOutputFmt;

/*Provide a Data Source for the Report*/
&ReportDef.SetRuntimeDataRowset(&rs);

/*Generate the Report*/
&ReportDef.ProcessReport(&sTemplateId, %Language_User, %Date, &sOutputFormat);

/*Publish the Report*/
&ReportDef.Publish("", &RptOutputDir, "XMLP", JOB_AET.PROCESS_INSTANCE);
&sFileExt = GetFileExtension(&sOutputFormat);


27 comments:

Anonymous said...

You do not need a Recordset. That is an option. but you can create an appengine that queries the information and put it in a file definition with type=XML you can see this working in SA with the trasncripts ( XML version ).

Anonymous said...

Of course you can always choose XML as type. You can also choose XMLDoc, Rowset and PS Query as type. Actually, you can do a lot with XML Publisher.. at least on my opinion.
I'm just trying to do a Rowset on this example, I even uses PS Query as data source type in an appengine (see App Engine running XML Publisher with PS Query Data Source) just for fun.
It was nice for you to stop by, please feel free to share your idea.

Thanks,
PSoftTechGuy

Anonymous said...

hello....this was very helpful; however, where does the code gets written? how to create the sample file once you select Rowset Data Source Type?

Anonymous said...

You can place it on PeopleCode. I usually used XMLP when I need a report output from my App Engine. I put all information that need to be reported on one of the temp table, that way its easy to manipulate cause your dealing with one record. At the beginning of this post it has a code to create sample file.

Anonymous said...

HEy PSoftTechGuy:

I enjoyed your write-up on XMLP with XML-File data source. Unfortunatley I keep running into the same error:

XML Publisher ProcessReport Job Start: 2008-08-22-17.50.31.000000
Report Definition Name: ZSR_CSH_BAS
Template ID: ZSR_CSH_BAS_2
Language CD: ENG
As of date: 2008-08-22
Output format: PDF
Actual output format: 2
Actual template ID: ZSR_CSH_BAS_2
Actual template date: 2008-08-22
Actual Language Code: ENG
%This.OutDestination : F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2
TMPLFILE: F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2\RptInst\ZSR_CSH_BAS_2.xsl
RTFFILE: F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2\CASHBAS.rtf
XSL template: F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2\RptInst\ZSR_CSH_BAS_2.xsl
Xliff File:
%This.OutDestination : F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2
OutputEditable = false
xmlpublisher PTFOProcessor.generateOutput error. XSL file:F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2\RptInst\ZSR_CSH_BAS_2.xsl Data file:C:\TEMP\CASHBAS.XML Xliff file: Output file:F:\psoft\fscm\dev\appserv\prcs\FSCMDEV\files\XMLP\7cab19c2-70ad-11dd-81a6-8db36cf50bf2\RptInst\ZSR_CSH_BAS.pdf Format:2
XDOException:null
167 17.50.31 0.000000 Error generating report output: (235,2309) PSXP_RPTDEFNMANAGER.ReportDefn.OnExecute Name:ProcessReport PCPC:51640 Statement:1154

Called from:SCM_BI_XMLP.BI_XMLP.OnExecute Name:DoProcessReport Statement:21

Called from:SCM_BI_XMLP.XMLFile.OnExecute Name:GenReport Statement:8

Called from:ZSR_CASH_BAS.MAIN.GBL.default.1900-01-01.Step02.OnExecute Statement:333

Any ideas?

Anonymous said...

Thanks Dan!

Hey, did you check the all variables you are passing on the "Generate the Report" block? Please make sure you have all the set-up correct and all variables defined. Looks to me the Xliff File was not created and this file is needed to generate output.

Anonymous said...

Hey,PsoftTechGuy:
I just found ur blog,and i had the same problem with Dan!...Xliff file,en..i will look into it,thanks!
i will be back on this soon.

Anonymous said...

Hi,PsoftTechGuy:
My sitiuation here is i can run the report successfuly if i set the run parameter to fewer data,on the other hand,if i change run parameter,more data will be handled by the report,it will end up error,just like Dan,i doubt it is a Memory or Performance issue.
maybe it is not a xliff problem,the successful report also show a blank xliff info in the log....
so do u have other idea?thanks!

Anonymous said...

Hey Raymond, Is your output file in EXCEL(XLS) format? Based on your situation, your report will run successfuly if you set it to fewer data and error otherwise. The reason why I ask if your output is in Excel format is it has a limited number of rows (~65536), maybe your output rows exceed this number.

Anonymous said...

My program worked fine, till I changed my underlying temp table to populate the rowset. What should I do to refresh the xml & schema to recognize new field

Thanks really appreciate

Anonymous said...

Did you also changed the XML and XSD in your Report Definition on-line?

Anonymous said...

No I haven't. I have commented out all the report defn peoplecode leaving out the XML file creation PeopleCode. I was thinking, I would create the files(xml & xsd) first and then upload that to report Defn

Thanks Again..

Anonymous said...

Hey,Psoft:
Thanks!
I had solved my prroblem,i log a ticket in official webiste,and they help me out.
The reason is somehow our app or prcs server's configuration point the 'JAVAVM Options' parameter to a wrong file.i don't exactly know the reason,but i change it ,it works. below is the whole soluction.
Thanks for your help!

Anonymous said...

How to troubleshoot the above error appeared when running particular XMLP Reports?

Answer(A):
=========
This error,usually I have encountered due to out of memory.When a report is run with a large volume of data to view it this error could come up.

You should check the following:

1. Java options on both psprcs.cfg and psappsrv.cfg files are configured correctly.

Process Scheduler configuration setup:

1) Open the psprcs.cfg file
2) Manipulate the JavaVM entry: JavaVM Options=-Xrs -Dxdo.ConfigFile=../xdo.cfg.
3) Delete caches & Bounce the scheduler.

App Server configuration setup:

1) Open the psappsrv.cfg file
2) Manipulate the JavaVM entry: JavaVM Options=-Xrs -Dxdo.ConfigFile=../xdo.cfg.
3) Add to PATH=%PS_HOME%/appserv/class/xdo56.jar ;%PS_HOME%/appserv/class/axdoparser.jar
;C:\WIN2003;C:\WIN2003\SYSTEM32
3) Delete caches & Bounce the server.

2. Verify if the directory 'CACHE' are created under appserver and process scheduler domain.

Hari Reddy said...

Hi,

I am currently doing few XMLP reports where i need to change the tempates based on some conditions, could you please suggest me how can i do this?

Regards
Hari

Anonymous said...

Hey Hari,

Do you mean, you have an existing template and you just need to edit it based on some addition on the requirements? If thats the case you can go to Report Definition online on the Template Tab and download and edit the template. If this is your first try on editing the template you need to download some plugins please see PeopleBooks on instruction for creating and editing template (PeopleBooks > Enterprise PeopleTools 8.49 PeopleBook: XML Publisher for PeopleSoft Enterprise > Creating Report Templates)

Hari Reddy said...

Hi PsoftGuy,
Thanks for your quick response, but my requirement is for producing a online PDF, i have multiple templates(RTF) for a report, based on the Business Unit the user enter on the page, template needs to be changed at runtime and a PDF needs to be generated (on click of a push button).

Anonymous said...

hi,PsftGuy:
i had this problem,could u help me.thanks!

i am now facing a problem,i had designed a xml publisher report,it run ok,but when run to xls,the zero in the field will be automatic trim,for example,'000000043',will be trim to '43' and show in the output xls file,no mater i open it in web browser or download it and open in excel.my schema file had indicated it is a string type field.
Though i could add ="filed value" or 'field value in the field,but it is not a comfortable solution

Anonymous said...

hey PsftGuy

your info are really valuable.I am new to XML publisher. I used your code to generate a sample report.The PDF file also generated. But when i open the PDF it says "There was an error in opening this document.The file cannot be opened because it has no pages".I used rowset as datasource.I am sure the rowset i created contains data.

Where i went wrong?

Please guide me

Anonymous said...

Hi PSftGuy, question, it appears that the xdo.cfg file we have in PS_HOME/appserv location is not being recognized. Should this config file be located elsewhere? the app serv config file has the appropriate javavmoptions set so not sure why it's not recognizing changes in this file. And does it need to be placed differently depending on whether being used by the app server or if we have a process creating the content... does the process scheduler look for it else where?

Unknown said...

I'm new to both BI Publisher and the Application Engine, but I have a question.

From reading the documentation on the 'Fill' procedure, it states that you can't use this using a state record. How do you get around that? I apologize if my question isn't worded correctly, and feel free to comment and ask questions to clarify.

Thanks,
Chris

Unknown said...

Thank you PsoftTechGuy for your outstanding posts. I have a two cent question: I just want to use a psquery to create a multiple rowset into an xmlp report. basically i am trying to get a report in which i have the number of applicants whom resume have been reviwed by managers during the year by category of employees.

I heard that xmlp does not allow multiple rowset...is there any workaround?

Unknown said...

Is there a way to access the report that is generated by XML Publisher when using PeopleCode.

I have some code behind a button on a page which will generate a report using XML Publisher (using the PeopleCode classes).

When I use the Publish method it puts the file into the directory I've specfied on the server, but it disappears within a few seconds.

Is there a way to keep the file there until I decide to delete it myself?

Sri D said...

Hi PeopleSoftguy,
Thank you very much for explaining the XMLP report using Rowset as Data Source.can you explain in depth how to achieve this.I mean the step by step process.I have a report definition with PS Query as Data Source and I need to run this report from a Process Scheduler.I know that I have to write an app Engine Program.Tell me how do I chieve this.

Thanks in Advance

RAMESH said...

heyy buddy, thnks for the post..its very helpful..I ahve a question ...I am using DISPLAYOUTPUT() method rather than Publish() .. but no output window gets pop up... Could you suggest wht cud b the reason..??

Unknown said...

HI,

I am getting issues with teh Report Defn while running the program in the AE. The template has 2 inner loops and when viewing the preview, able to view it. Any help please.

Thanks,

ramesh said...

Hi,

Memory allocation.
JavaVM (min/max memory setup) in setEnv.sh file should be changed - recycle the environment and cleare cache.