Friday, July 31, 2009

Choose a template

<?choose:?>
  <?when: EEName='test'?>
   <?call:ANDREW1?>
  <?end when?>
  <?otherwise:?>
   <?call:ANDREW2?>
  <?end otherwise?>
<?end choose?>

Thursday, July 30, 2009

Calculate age

SELECT TRUNC(MONTHS_BETWEEN(SYSDATE,A.BIRTHDATE)/12) AS AGE
FROM PS_PERSON A

Clear out tracefile & set trace

Just replace the ip address..
Local File &file;
&file = GetFile(GetEnv("PS_SERVDIR") | "/LOGS/" | %OperatorId | "_172.18.31.49.tracesql", "W", %FilePath_Absolute);
rem &file.Delete();
&file.Close();
SetTraceSQL(3);
SetTracePC(2060);

Wednesday, July 29, 2009

Generate XML from the Rowset

   Local PSXP_XMLGEN:RowSetDS &ds = create PSXP_XMLGEN:RowSetDS();
   Local string &xml;
   &xml = &ds.getXMLData(GetLevel0(), "");
   WinMessage(&xml);

Monday, July 27, 2009

XML - XML File Source

1. Generate your xml file using PeopleCode and then use the following:
method DisplayReport
   
   Local PSXP_RPTDEFNMANAGER:ReportDefn &C1_appReport;
   
   rem Create the ReportDefn class;
   &C1_appReport = create PSXP_RPTDEFNMANAGER:ReportDefn(&C1_strRptDefnID);
   
   rem Close the file;
   &C1_appXmlFile.CloseFile();
   
   try
      
      rem Get the report definition and set the xml file for the run time and then display the report;
      &C1_appReport.Get();
      
      &C1_appReport.SetRuntimeDataXMLFile(&C1_appXmlFile.C1_strDirAndName);
      &C1_appReport.ProcessReport(&C1_strTmpltID, "", %Date, "");
      
      CommitWork();
      &C1_appReport.DisplayOutput();
      &C1_appXmlFile.DeleteFile();
      
   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-method;