7/22/2011

XML Publisher Using PeopleCode

How To Run XML Reports Using PeopleCode?

Here is the sample Peoplecode for XML Report.
You can write this peoplecode in field change event in the field where you want to trigger .


import PSXP_RPTDEFNMANAGER:*;
import PSXP_XMLGEN:*;
&QueryName = "";    /*your query name*/
&sRptDefn  = "";       /*your Report Defn*/
&sTmpltID  = "";       /*your Templete ID*/
Local integer &prcsInstId = Staterecord.PROCESS_INSTANCE.Value;
try
/* get report definition object */
&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn);
&oRptDefn.Get();
&rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
      &rcdQryPrompts.oprid.value = %OperatorId;
      &rcdQryPrompts.Run_CNTL_ID.value =     Staterecord.RUN_CNTL_ID.Value;
/*You can set more query prompts depends on your Datasource;
/* Set report definition object */
      &rcdQryPrompts =  &oRptDefn.setPSQueryPromptRecord(&rcdQryPrompts);
End-If;
/*generate report*/
/* Syntax : (TemplateID,Languagecode,Date,Format)*/
&oRptDefn.ProcessReport(&sTmpltID, "3", %Date, "PDF");    /*publish report */
/* Syntax :Publish(ServerName,ReportPath,olderName,ProcessInstanceId)*/
&oRptDefn.Publish("", "", "", &prcsInstId); 
CommitWork();
/*Displays Output When push button is clicked*/ 
&oRptDefn.DisplayOutput();   
catch Exception &Err
If Not &oRptDefn = Null Then
      &oRptDefn.Close();
End-If;
WriteToLog(%ApplicationLogFence_Error, &Err.ToString());
 &Err.Output();
end-try;
To View Report,the user should have PTPT2600(XMLP Report Developer) permission list.

No comments:

Post a Comment