Monday, May 8, 2017

Rowsets

A Rowset represents a scroll / collection of rows. 
If a rowset is instantiated with the GetRowset method then that object represents the data on the component/page.  However if it is instantiated with the CreateRowset method then it is a standalone rowset.  Standalone rowsets allow you to work on data without it being automatically tied to the database.
Rowset objects are declared with type Rowset:
Local Rowset &MYROWSET;

The Rowset class has a number of built in methods and properties. Some of the
most common are listed below.


Methods:
GetRowset, GetRow, GetRecord, GetField
FlushRow, Flush, DeleteRow - remove data from the rowset
Fill, CopyTo, InsertRow - add data to the rowset
Sort - sort data in the rowset

Properties:
ActiveRowCount - returns number of active rows for the rowset
Level - returns level of the rowset

The basic structure of the drilling down through the rowset is shown below:



Below is an example:



Below are links to other blogs I have found very helpful learning about rowsets:

http://peoplesoftobjectoriented.blogspot.com/

http://hariprasadpeoplesoft.blogspot.com/2012/04/populating-data-into-grid.html


Wednesday, May 3, 2017

Custom Print Button Using HTML Area to Print Peoplesoft Page


A very simple way to adding a Print button to print a Peoplesoft page is by just using some javascript and putting it inside of an HTML Area.  Then add that HTML Area to the Peoplesoft page:




Sending Emails with Generic Templates

One way to send emails via Peoplesoft is by using the Generic Templates component located at this path:

Main Menu -- PeopleTools -- Workflow -- Notifications -- Generic Templates

Then the setup code would be: 



You will need to use data mover scripts to migrate the template...
Export:
SET OUTPUT c:\temp\EMAIL_TEMPLATES.DAT;
SET LOG c:\temp\EMAIL_TEMPLATES_EXP.LOG;

EXPORT PS_WL_TEMPLATE_GEN WHERE WL_TEMPLATE_ID IN ('MyNewEmail');
EXPORT PS_WL_TEMPL_GEN_TK WHERE WL_TEMPLATE_ID IN ('MyNewEmail');

Import:
SET INPUT c:\temp\EMAIL_TEMPLATES.DAT;
SET LOG c:\temp\EMAIL_TEMPLATES_IMP.LOG;

DELETE FROM PS_WL_TEMPLATE_GEN WHERE WL_TEMPLATE_ID IN ('MyNewEmail');
DELETE FROM PS_WL_TEMPL_GEN_TK WHERE WL_TEMPLATE_ID IN ('MyNewEmail');

IMPORT *;


Tuesday, May 2, 2017

Running a BI Publisher Process via Peoplecode

Below is a snippet of code showing how to initiate a process via peoplecode.  This specific scenario is using the delivered record FUNCLIB_SF.PRINT_RECEIPT.  It is setting up a BI Publisher process.

Note - For emailing a BI Publisher report the Process Instance can not be 0.
Peoplesoft has some delivered app classes to handle BI Publisher reports (ex: how the report is displayed - browser, email, printer, etc) which can be found in PSXP_RPTDEFNMANAGER:ReportDefn

                  If %Page = Page.CSH_OFF_DEPT Or
                        %Page = Page.CSH_RCPT_DETAIL Then
                     &sProcessName = "PSXPQRYRPT";
                  End-If;
                 
                  &sRunCntlid = "PRINT_RECEIPT";
                  &sProcessType = "XML Publisher";
                 
                  &RQST = CreateProcessRequest();
                  &RQST.ProcessType = &sProcessType;
                  &RQST.ProcessName = &sProcessName;
                  &RQST.RunControlID = &sRunCntlid;
                 
                  &RQST.RunLocation = "SERVER";
                 
                  &RQST.OutDestType = "6";
                  &RQST.OutDestFormat = "2";
                 
                  &RQST.RunDateTime = %Datetime;
                  &RQST.TimeZone = %ServerTimeZone;
                  If &EmailDept = "Y" And
                        &EmailReceipt Then
                     &RQST.OutDestType = "5";
                     &RQST.OutDestFormat = "2";
                     &RQST.OutDest = &EmailID; /*&EmailID;*/
                     &RQST.EmailSubject = "BI Publisher Report";
                     &RQST.EmailText = "BI Publisher Report";
                  End-If;
                  &RQST.Schedule();
                  &iProcessStatus = &RQST.Status;
................
................
If SetBIPublisherProcess(&sBIPubStat) = True Then
                     rem Exit (0);
.................
.................
Function SetBIPublisherProcess(&sBIPubStat As string) Returns boolean;
   Local SSF_CASHIERING:PrintReceipt:ReportingContext &RptContext = create SSF_CASHIERING:PrintReceipt:ReportingContext();
   Local SSF_CASHIERING:PrintReceipt:BIPubReport &BIPubReport = create SSF_CASHIERING:PrintReceipt:BIPubReport( False);
  
   Local string &sBindRecordName = "%Table(RUN_CNTL_SF)";
   Local string &sPromptRecName = "Record.PSCONQRSRUNPRMX";
   Local Record &RecRunCntlSF = CreateRecord(Record.RUN_CNTL_SF);
  
   Local array of array of string &aFldBindNames;
  
   &aFldBindNames = CreateArray(CreateArray("BUSINESS_UNIT", "CASHIER_OFFICE", "RECEIPT_NBR", "OPRID", "RUN_CNTL_ID"));
   &aFldBindNames.Push(CreateArray("BUSINESS_UNIT", "CASHIER_OFFICE", "RECEIPT_NBR", "OPRID", "RUN_CNTL_ID"));
  
   rem Update Bind Record(RUN_CNTL_SF);
   &RecRunCntlSF.OPRID.Value = %UserId;
   &RecRunCntlSF.RUN_CNTL_ID.Value = &sRunCntlid;
   &RecRunCntlSF.BUSINESS_UNIT.Value = &sBusinessUnit;
   &RecRunCntlSF.CASHIER_OFFICE.Value = &sCashierOffice;
   &RecRunCntlSF.RECEIPT_NBR.Value = &iReceiptNbr;
   &RecRunCntlSF.Delete();
   &RecRunCntlSF.Insert();
  
  
   Evaluate CSH_OFF_RECEIPT.CO_TRANS_TYPE.Value
   When "03"
      rem Departmental Receipt;
      &sReportDefinition = "SF750R_DRCPT";
      &sReportTemplateDef = "SF750R_DRCPT_1";
      Break;
   When-Other;
      Break;
   End-Evaluate;
 
   &RptContext.RunControlId = &sRunCntlid;
   &RptContext.ProcessInstance = &RQST.ProcessInstance;
   &RptContext.PromptRec = &sPromptRecName;
   &RptContext.ReportName = &sReportDefinition;
   &RptContext.TemplateId = &sReportTemplateDef;
   &RptContext.LanguageCd = "";
   &RptContext.AsOfDate = %Date;
   &RptContext.CQName = "SF750R_BI_CSH_OFF_RCPT_PRINT";
   &RptContext.OutDestFormat = 2;
   &RptContext.OutDestType = &nOutDestType;
   &RptContext.OutDestPrinter = &sOutDestPrinter;
   &RptContext.FldBindNames = &aFldBindNames;
   &RptContext.BindRecordName = &sBindRecordName;
  
   If &BIPubReport.GenerateReceipt(&RptContext) = True Then
      Return True;
   Else
      Return False;
   End-If;
  
End-Function;

Monday, February 6, 2017

Did you try clearing cache?

Aside from browser cache, Peoplesoft has 3 types of cache that can cause issues with performance. 

If you are having issues with how you are expecting the functionality to behave and you have verified that your updated code is in the desired environment then try clearing the related options listed.

Process Scheduler cache relates to app engine code, sql and sections along with component interface code.  Other processes like SQRs and COBOL don't use cache.

App Server cache relates to code ran in the web browser such as peoplecode, pages and components.  It also needs to be cleared after upgrades and bundle applications.

Webserver cache usually needs to be ran after a bundle application, upgrade, patches.  Also sometimes you will not see content references or folders that have been migrated.  Assuming you have the necessary security to view them, you may need to clear the webserver cache.

Peoplesoft URL Format

The format of a peoplesoft url is broken up into the following parts:

http://server/servlet_name/sitename/portalname/nodename/content_type/content_id?content_parm

The different content type are shown in the image below:


The servlet_name can be 'psp' or 'psc'.  'psc' (peoplesoft component) displays only the content of the peoplesoft component as opposed to 'psp' (peoplesoft portal) which will display the portal layout along with the component content.  This can be very useful when you want to print the data on the screen but don't want it to be distorted or to include the headers/footers.

You can read up more about peoplesoft urls at the link below:

https://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tprt/concept_PortalURLFormats-c071f6.html

Wednesday, January 11, 2017

Max Effective Date and %EffdtCheck

Below is an example to get the max effective dated row.

   SELECT * FROM PS_TEST T
  WHERE T.EMPLID = '9999999'
    AND T.EFFDT = (SELECT MAX(T1.EFFDT)
                    FROM PS_TEST T1
                   WHERE T1.EMPLID = T.EMPLID
                     AND T1.EFFDT <= SYSDATE)

    AND T.EFFSEQ = (SELECT MAX(T2.EFFSEQ)
                    FROM PS_TEST T2
                   WHERE T2.EMPLID = T.EMPLID
                     AND T2.EMPL_RCD = T.EMPL_RCD
                     AND T2.EFFDT = T.EFFDT)


====================================================================
Also the metasql for this functionality is %EffdtCheck


SELECT *
FROM PS_JOB JOB
WHERE EMPLID = :1
AND EMPL_RCD = :2
AND %EffdtCheck(JOB, JOB_ES, %CurrentDateIn)

expands into this:

SELECT *
FROM PS_JOB JOB
WHERE EMPLID = :1
AND EMPL_RCD = :2
AND JOB_ES.EFFDT=(
SELECT MAX(EFFDT)
FROM PS_JOB JOB
WHERE JOB.EMPLID=JOB_ES.EMPLID
AND JOB.EMPL_RCD=JOB_ES.EMPL_RCD
AND JOB.EFFSEQ=JOB_ES.EFFSEQ /* this shouldn't be used in EFFDT sub-query */
AND JOB.EFFDT<=TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD'))

This information was taken directly from the 2 urls below.  They describe it in 
greater detail.

http://peoplesoft.wikidot.com/effdtcheck
http://peoplesoftconcept.blogspot.com/2014/03/sql-query-for-max-effective-max-effdt.html

Adding Images in Peoplesoft

Below is a simple way to display images on a Peoplesoft page.  The code below is an example of adding them to a derived record field within a grid based.  The field type is ImageReference.

The code below is looping through a rowset and setting the derived record field to the image. This example determines whether or not to display this image based on the value returned from the sql.