Search This Blog

Thursday, June 27, 2013

Understanding Restart in AE


Understanding Restart in AE

Application Engine programs save to the database (perform a commit) only when an entire program successfully completes. You must set individual commits where appropriate.

At the section level, you can set a commit after each step in a section. At the step level, you can require or defer commits for individual steps, or you can increase the commit frequency within a step to N iterations of a looping action, such as a Do Select of Do While, within a step.

The commit level that you select affects how restart works in a program. Each time Application Engine issues a commit with restart enabled, it records the current state of the program. The recording of the current state that Application Engine performs is referred to as a checkpoint.

Using the restart feature enables you to perform commits more often in a program. Restart reduces the overall effect on other users and processes while the background program is running because it reduces the number of rows that are locked by the program. Fewer rows allows multiple instances of the program to run concurrently (parallel processing), which may be useful for high-volume solutions.

With restart, if a failure occurs at any point in the process, the user can restart the program and expect the program to behave as follows:

    Ignore the steps that have already completed up to the last successful commit.

    Begin processing at the next step after the last successful commit.

The ability for Application Engine to remember completed steps depends on a record called AERUNCONTROL, which is keyed by process instance.

When a program runs, each time Application Engine issues a commit it also saves all of the information required for a program restart in the AERUNCONTROL record.

Reference : Peopletools 8.53

Monday, June 17, 2013

SQR Commands

1. Example of Rpad

let $COUNTRY = 'USA'

Below example adds spaces at the end.
Rpad($COUNTRY,6,' ') ==> USA   
                                       1 2 3 4 5 6

Rpad($COUNTRY,6,z) ==> USA  z z z
                                       1 2 3 4 5 6

Rpad($COUNTRY,3,z) ==> USA
                                       1 2 3

2. on-error command:

begin-sql on-error=Procedure-name

end-sql

The procedure will act as error handler and will have below code.
Whenever a runtime error occurs, the dynamic error message will be displayed.

begin-procedure Procedure-name
display 'Database error occurred'
display $sql-error
end-procedure ! Procedure-name

Wednesday, June 12, 2013

BI Publisher: Page number Reset

Agenda: To reset the page number when there is change in invoice number etc.

In the below example , we reset the page number once the Employee DeptID gets changed.

Below is the sample XML data.


Load the XML data successfully into RTF template.
After that get the data from Table Wizard and group the data by Deptid with Section break selected.
Below are the snapshots.



 

Add the Page Number to the Footer at the End as show below.

Now save the template and see the preview. The page number gets reset for change in DeptID as shown below.





Monday, June 10, 2013

%DateIn and %Dateout Meta Variables

%Datein  resolves to to_date('2013-06-10','YYYY-MM-DD')              
%Dateout resolves to to_char(date,'YYYY-MM-DD')

Easy way to remember , when to use %Datein and %Dateout.
Lets consider a simple database table below. 

TableName: EMP_ACTION







To retrieve data for a particular date , we use WHERE criteria to filter rows.
So in this case date coulmn is filtered as of particular Date.
Similary, only Date Value should be inserted into the column of Date data type.

In both the cases,  %Datein can be used, since it resolves into Date data type.

To format the date output, we use to_char(date,format). So in this case we use %Dateout

Sending multiple attachments through mail from App Engine

The below code will send multiple attachments through the mail.

AE Peoplecode:

import PT_MCF_MAIL:*; // Inlcude the App package

/**** Send Mail ****/

Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();

&email.From = ""; // when set to null, the email configured at server level will send mail

SQLExec("select URL from psurldefn where url_id = "URLid which stores the recipients list", &Email_To);
&email.Recipients = &Email_To;

&email.Subject = Place the Subject of the mail here;

Local string &plain_text = "Report Description";
Local PT_MCF_MAIL:MCFBodyPart &text = create PT_MCF_MAIL:MCFBodyPart();
&text.Text = &plain_text;

&File_name_path = Place the full path ( like /...../filename.pdf')
&file_name_email = Name of the attached filename (filename.pdf)
&File_name_path2 = Place the full path ( like /...../filename2.pdf')
&file_name_email2 = Name of the attached filename (filename2.pdf)


Local PT_MCF_MAIL:MCFBodyPart &attach1 = create PT_MCF_MAIL:MCFBodyPart();
Local PT_MCF_MAIL:MCFBodyPart &attach2 = create PT_MCF_MAIL:MCFBodyPart();

&attach1.SetAttachmentContent(&File_name_path, %FilePath_Absolute, &file_name_email, "Report Description", "", "");
&attach2.SetAttachmentContent(&File_name_path2, %FilePath_Absolute, &file_name_email2, "Report Description 2 ", "", "");

Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
&mp.AddBodyPart(&text);
&mp.AddBodyPart(&attach1);
&mp.AddBodyPart(&attach2);
&email.MultiPart = &mp ;

Local integer &res = &email.Send();

Local boolean &done;

Evaluate &resp
When %ObEmail_Delivered
   /* every thing ok */
   &done = True;
   Break;
  
When %ObEmail_NotDelivered
   /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses */
   &done = False;
   Break;
  
When %ObEmail_PartiallyDelivered
   /* Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses; */
   &done = True;
   Break;
  
When %ObEmail_FailedBeforeSending
   /* Get the Message Set Number, message number;
Or just get the formatted messages from &email.ErrorDescription,
&email.ErrorDetails;*/
  
   &done = False;
   Break;
End-Evaluate;

Sunday, June 9, 2013

Component Interface Part1


You might have already heard about Component Interface (CI) as a medium through which we can insert data into component.

Agenda: Creating CI.

 Lets discuss some basic steps which are required to develop CI.

1. Assign component to CI through App Designer.
2. Check the validity of CI.
3. If no errors great!! If some errors , it will show 'X' marks in the CI structure.
    Below are some possible reasons for these errors.
    a) Key structure mismatch between CI and Component.
    b) Some property is missing which needs to be added to CI.
   Note: Even though if you donot get errors, later point in time if underlying component is changed     make sure to make CI to be in Sync with the component.
4. Cross check the Mode in which you want to use the CI like Add mode etc.
5. Testing the CI from App Designer by passing some data to the key values of component.
6. And lastly , add the permission list to CI.

Generally for many of the Delivered components PeopleSoft comesup with Component Interfaces.
So if any of these delivered components are customized then we have to make sure the CI is in sync with the new structure.

Component Interaces also called as CI in short, are also known as Enterprise Integration Points (EIP).

Before going further, we shall see one example of how to insert data through CI.

Sending mail through App Engine program

Below code sends mail through App engine program.  The code uses the PT_MCF_MAIL package to send mail with attachment.

AE Peoplecode:

import PT_MCF_MAIL:*; // Inlcude the App package

/**** Send Mail ****/

Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();

&email.From = ""; // when set to null, the email configured at server level will send mail

SQLExec("select URL from psurldefn where url_id = "URLid which stores the recipients list", &Email_To);
&email.Recipients = &Email_To;

&email.Subject = Place the Subject of the mail here;

Local string &plain_text = "Report Description";
Local PT_MCF_MAIL:MCFBodyPart &text = create PT_MCF_MAIL:MCFBodyPart();
&text.Text = &plain_text;

&File_name_path = Place the full path ( like /...../filename.pdf')
&file_name_email = Name of the attached filename (filename.pdf)

Local PT_MCF_MAIL:MCFBodyPart &attach1 = create PT_MCF_MAIL:MCFBodyPart();
&attach1.SetAttachmentContent(&File_name_path, %FilePath_Absolute, &file_name_email, "Report Description", "", "");

Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
&mp.AddBodyPart(&text);
&mp.AddBodyPart(&attach1);
&email.MultiPart = &mp ;

Local integer &res = &email.Send();

Local boolean &done;

Evaluate &resp
When %ObEmail_Delivered
   /* every thing ok */
   &done = True;
   Break;
  
When %ObEmail_NotDelivered
   /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses */
   &done = False;
   Break;
  
When %ObEmail_PartiallyDelivered
   /* Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses; */
   &done = True;
   Break;
  
When %ObEmail_FailedBeforeSending
   /* Get the Message Set Number, message number;
Or just get the formatted messages from &email.ErrorDescription,
&email.ErrorDetails;*/
  
   &done = False;
   Break;
End-Evaluate;