Thursday, December 23, 2010

File Attachments


File Attachments Overview:
To achieve this functionality we need following records
Delivered Records:
FILE_ATTACH_WRK:              Contains the delivered code to create attachments
FILE_ATTDET_SBR:                 Is saved as another record (FTP record (any SQL record)) ex: TEST_FTP
Created Records:
Transaction record (Ex: TEST_TRANS): This record holds the key fields along with ATTACHSYSFILENAME and ATTACHUSERFILE fields into this record.
FTP record (Ex: TEST_FTP): This record will hold the attachment.  This record will contain only the sub-record FILE_ATTDET_SBRNo other fields can be placed on this record or the delivered process will not work.
Process:
  1. Build the records:
  • Create a new record that has only the sub record of FILE_ATTDET_SBR in it.  No other fields can be added to this record.( Ex: TEST_FTP)
  • Create a new record (Ex: TEST_TRANS) that has key fields .
  • Create the new tables at the database level.
  1. Create the page:
  • Create the page according to the requirement and use the field from the record FILE_ATTACH_WRK for attachment buttons/links.
  • TEST_TRANS.ATTACHUSERFILE(FileName) DisplayOnly.
  • All other columns from TEST_TRANS are Invisible.
  • Fields from FILE_ATTACH_WRK (ATTACHADD, ATTACHVIEW, and ATTACHDELETE) are pushbuttons.
  • TEST_FTP is not added to this page or any page
  1. Create Component
  2. Add a new URL definition Online:


    Note: This is not necessary if you are storing to the Database, since it is highly unlikely you will switch the record that the file attachments will be inserted into. If storing on a file server, you should create a URL definition since server names can change.
    1. Browse to Main Menu > PeopleTools > Utilities > URLs.
    2. Add a new URL (i.e. DEMO_URL).
    The URL, when inserting the file into the database, but be the record that will be storing the File Attachment.
    The text must be in the format of:
                   Storing to Database:             record://TEST_FTP
                   Storing on File Server:         http://myserverpath.com/whatever
                                                                        ftp://my_ftp_server/path
    Save the URL definition

     
  3. Add Peoplecode
  • RowInit: You will need to determine the rules behind enabling or disabling the pushbuttons. There is delivered function on FILE_ATTACH_WRK.ATTACHADD. RowInit that can be called or you can add own logic.
        (Can call in component PeopleCode <COMPONENT>.FILE_ATTACH_WRK.RowInit).
  • Add the following code to the component record field PeopleCode <COMPONENT>.FILE_ATTACH_WRK.ATTACHADD.FieldChange


    Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange;
    Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;


    Local number &CurRow, &RETCODE;
    Local string &Guid, &URL_ID;


    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    /* Call the correct database record where your file attachment */
    /* will be stored */
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    &URL_ID = "URL.DEMO_URL";


    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    /* In order to make sure the attachmentname is unique */
    /* you can add a GUID in front of your File name */
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    &Guid = UuidGenBase64();


    add_attachment(@&URL_ID, "", &Guid, 0, True, "Record.TEST_TRANS", TEST_TRANS.ATTACHSYSFILENAME,
    TEST_TRANS.ATTACHUSERFILE, 2, &RETCODE);


    If &RETCODE = %Attachment_Success Then
    display_attachment_buttons();
    DoSaveNow();
    End-If;
  • Add the following code to the component record field PeopleCode <COMPONENT>.FILE_ATTACH_WRK. ATTACHVIEW.FieldChange

    Declare Function view_attachment PeopleCode FILE_ATTACH_WRK.ATTACHVIEW FieldChange;
    Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;

    Local string &URL_ID;
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    /* Call the correct database record where your file attachment */
    /* will be stored */
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    &URL_ID = "URL.DEMO_URL";

    view_attachment(@&URL_ID, TEST_TRANS.ATTACHSYSFILENAME, TEST_TRANS.ATTACHUSERFILE, 2, &RETCODE);

    If &RETCODE = %Attachment_Success Then
    display_attachment_buttons();
    DoSaveNow();
    End-If;
  • Add the following code to the component record field PeopleCode <COMPONENT>.FILE_ATTACH_WRK. ATTACHDELETE.FieldChange

    Declare Function delete_attachment PeopleCode FILE_ATTACH_WRK.ATTACHDELETE FieldChange;
    Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;

    Local number &Ret;
    Local String &URL_ID;

    &Ret = MessageBox(%MsgStyle_YesNo, "", 0, 0, "Are you sure you would like to delete the attachment?");
    If &Ret = %MsgResult_Yes Then
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    /* Call the correct database record where your file attachment */
    /* will be stored */
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    &URL_ID = "URL.DEMO_URL";

    delete_attachment(@&URL_ID, TEST_TRANS.ATTACHSYSFILENAME, TEST_TRANS.ATTACHUSERFILE, 2, &RETCODE);

    If &RETCODE = %Attachment_Success Then
    display_attachment_buttons();
    DoSaveNow();
    End-If;
    End-If;
  • Add the following code to the component record PeopleCode <COMPONENT>.<Record>.<FirstKey>.SaveEdit

    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    /* This code is necessary so that when an attachment is deleted */
    /* the now empty row can be deleted from the database */
    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
    Local number &Rs_Count, &i;
    Local Rowset &Rs;

    &Rs = GetLevel0()(1).GetRowset(Scroll.TEST_TRANS);
    &Rs_Count = &Rs.ActiveRowCount;
    For &i = &Rs_Count To 1 Step - 1
    If None(&Rs(&i).TEST_TRNS.ATTACHSYSFILENAME.Value) Then
    &Rs.DeleteRow(&i);
    End-If;
    End-For;
NOTE:
SYNTAX: AddAttachment(URLDestination,
DirAndFileName,
FileType,
UserFile[, MaxSize [, PreserveCase[, UploadPageTitle[, AllowLargeChunks]]]] )
PreserveCaseSpecify a Boolean value to indicate whether the case of the extension of the specified file is preserved or not; True, preserve the case, False, convert the file name extension to all lowercase letters.
The default value is False.
Warning! If you use the PreserveCase parameter, it is important that you use it in a consistent manner with all the relevant file-processing functions or you may encounter unexpected file-not-found errors.
NOTE: Configuring the Web Server to Support Additional MIME Types

Web Server
Location of Deployment Copy
WebLogicPS_HOME/webserv/web_server/applications/peoplesoft/PORTAL.war/WEB-INF/web.xml
WebSpherePS_HOME/webserv/profile_name/installedApps/app_nameNodeCell/app_name.ear/PORTAL.war/WEB-INF/web.xml
You must restart your web server before these changes are recognized.

Sunday, December 19, 2010

Auto-Displaying / Skipping Search page results

If you need to have the search results defaulted when search page is loaded, then SetSearchDialogBehaviour function is used.

This function is normally used in the context of skipping the search page if you provide all wildcard values.

If a complete value is provided for all search keys before calling the SetSearchDialog behaviour function, then the search page will be skipped and the users will be taken directly into the transaction page. But the actual idea behind the function is that it will auto-trigger the search functionality. So naturally when just a wild card value is given to the search fields and the function invoked, then all the search results will be displayed.

Example for auto-displaying: If EMPLID is the only search field, the following code can be written to popualte the search results automatically on loading the search page.

/*Code in SearchInit.*/

REC.EMPLID.value = '%';
SetSearchDialogBehaviour(0);

Example for Skipping / Bypass: If EMPLID is the only search field, the following code can be written to skipp the search page.

/*Code in SearchInit.*/
EMPLID = %EmployeeId;
SetSearchDialogBehavior(0);

Note: SetSearchDialogBehavior can only be used in SearchInit PeopleCode.

Parameters: force_or_skip : A Number equal to one of the following values:
                                                     0: sets the dialog behavior to skip if possible.
                                                     1: sets the dialog behavior to force display.

Wednesday, November 24, 2010

Adding New Object OwnerId

The following steps is required to add new object ownerid.


Step1: open the field OBJECTOWNERID.
Step2: Add new translate value.
Step3: save the field.

Friday, November 19, 2010

PIA Navigation for a Component

The following query is used to get the PIA Navigation for a component:

SELECT DISTINCT Rtrim (Reverse (Sys_connect_by_path (Reverse (portal_label),

                                ' > ')), ' > ')

                "PIA NAVIGATION"

FROM   psprsmdefn

WHERE  portal_name = 'EMPLOYEE'

       AND portal_prntobjname = 'PORTAL_ROOT_OBJECT'

START WITH portal_uri_seg2 = 'COMPONENT_NAME'

CONNECT BY PRIOR portal_prntobjname = portal_objname; 

Wednesday, November 17, 2010

Important MetaSQL of SQL- Action in AE

%ProcessInstance    - To get the PROCESS_INSTANCE
%OperatorId           - To get the Operator Id i.e UserId
%RUNCONTROL - To get the RuncontrolId

Friday, November 12, 2010

Applying Patch to NT Server

The following steps describes how to apply patch in NT server using VM Ware:

1. Open the vmware and select the server.
2. Download patch.
3. Stop Process Scheduler.
   <>/appserver/psadmin.exe
4. Install patch.
5. Restart  the server.
6. Start the Process Scheduler.
   <>/appserver/psadmin.exe

Tuesday, November 9, 2010

Change Homepage Logo

Open the following defination and changed them.
1. NEW_PS_LOGO (Image Type) - To change the logo.
2. PORTAL_UNI_HEADER_NS4X (Html Type) - Change logo name on mouse over.
3. PORTAL_UNI_HEARDER_NNS (Html Type)
4. PT_BRANDING (Application Package Type) - Deals to manipulate homepage and portal look.

Note: Dont change image name in PT_BRANDING application package. Have a backup of original Image type as NEW_PS_LOGO1 and update NEW_PS_LOGO with your image.

PeopleSoft OBJECTTYPE


PeopleSoft OBJECTTYPE:
0RecordPSRECDEFN
1IndexesPSKEYDEFN
2FieldsPSDBFIELD
3Field FormatsPSFMTDEFN
4TranslatesPSXLATITEM
5PagesPSPNLDEFN
6MenusPSMENUDEFN
7ComponentsPSPNLGRPDEFN
8Record PeopleCodePSPCMPROG
9Menu PeopleCodePSPCMPROG
10QueriesPSQRYDEFN
11Tree StructuresPSTREESTRCT
12TreesPSTREEDEFN
13Access GroupsPS_ACCESS_GRP_TBL
14ColoursPSCOLORDEFN
15StylesPSSTYLEDEFN
17Business ProcessesPSBUSPROCDEFN
18ActivitiesPSACTIVITYDEFN
19RolesPSROLEDEFN
20Process DefinitionsPRCSDEFN
21Server DefinitionsPS_SERVERDEFN
22Process Type DefinitionsPS_PRCSTYPEDEFN
23Job DefinitionsPS_PRCSJOBDEFN
24Recurrence DefinitionsPS_PRCSRECUR
25Message Catalog EntriesPSMSGCATDEFN
26Dimension DefinitionPS_DIMENSION
27Cube DefinitionTO_Find
28Cube Instance DefinitionTO_Find
29Business InterlinkPSIODEFN
30SQLPSSQLDESCR
31File Layout DefinitionsPSFLDDEFN
32Component InterfacesPSBCDEFN
33Application Engine ProgramsPSAEAPPLDEFN
34Application Engine SectionsPSAESECTDEFN
35Message NodesPSMSGNODEDEFN
36Message ChannelsPSMSGCATDEFN
37Message DefinitionsPSMSGDEFN
38Approval Rule SetAPPR_RULE_HDR
39Message PeopleCodePSPCMPROG
40Subscription PeopleCodePSPCMPROG
42Comp. Interface PeopleCodePSPCMPROG
43Application Engine PeopleCodePSPCMPROG
44Page PeopleCodePSPCMPROG
46Component PeopleCodePSPCMPROG
47Component Record PeopleCodePSPCMPROG
48Component Rec Fld PeopleCodePSPCMPROG
49ImagesPSCONTDEFN
52File ReferencesPSFILEREDEFN
53Permission ListsPSCLASSDEFN
54Portal Registry DefinitionsTO_Find
55Portal Registry StructuresPSPRSMDEFN
56URL DefinitionsPSURLDEFN
57Application PackagesPSPACKAGEDEFN
58Application Package PeopleCodePSPCMPROG
60Analytic TypesTO_Find
62XSLTTO_Find
64Mobile PagesPSMPDEFN
68File ReferencesPSFILEREDEFN
69File Type CodesPSTYPECODEDEFN
72Dignostic Plug InsTO_Find
73Analytic ModelsTO_Find
79ServicePSSERVICE
80Service OperationPSOPERATION
81Service Operation HandlerPSOPRHDLR
82Service Operation VersionPSOPRVERDFN
83Service Operation RoutingSIBRTNGDEFN
84IB QueuesSIBQUEUEINST
85XLMP Template Definition
86XLMP Report Definition
87XMLP File Definition
88XMPL Data Source Definition

Thursday, October 14, 2010

Overview Of Portal Registry And Content References


Portal Registry
Each portal is defined by a portal registry.
A portal registry has a tree-like structure in which content references are organized, classified, and registered.
A portal registry contains folders and content references.
In the portal registry, folders organize content references into a multilevel hierarchy
Every portal registry contains a root folder and a Portal Objects folder.
There are several ways to access and maintain the portal registry:
  • Use the registration wizard to register content references, assign security, and update.
  • Use the Menu Import feature to upgrade custom menu group definitions.
  • Use portal administration pages to add, change, or delete folders and content references from a portal registry.
  • Use the portal registry API for programmatic access to the registry.
  • Use the security synchronization process to update the portal registry security based on the menu and script security.
Content references
Content references are definitions that have been entered or registered in the portal registry.
Content references fall into four categories:
  1. homepage tabs
  2. target content
  3. templates
  4. pagelets
Access to content references is controlled by permission lists assigned when the content reference is created.

Difference Between Pay003.sqr and Ddp001.Sqr

Pay003.sqr: Prints physical payroll check.
Ddp001.sqr: Is used for direct deposit.
Ddp003.sqr: Is used to print for payroll Advice.

Main Tables Used: PS_PAY_CALENDAR
                                 PS_PAY_CAL_BAL_ID
                                 PS_PAY_CHECK
                                 PS_PAYGROUP_TBL
                                 PS_COMPANY_TBL

Friday, October 1, 2010

Calculation Of Compensation Rate


Frequency table lists the formulas that are used to convert compensation from one frequency to another:

Calculation DescriptionFormula
From hourly to annualCompensation rate × job standard hours / frequency factor of standard work period
From other frequencies to annualCompensation rate × compensation rate frequency factor
From annual to hourlyAnnual compensation rate / job standard hours × frequency factor of standard work period
From annual to other frequenciesAnnual compensation rate / desired frequency factor

The following is the formula for calculating hourly rates:
Hourly rate = compensation rate × compensation frequency factor / standard hours × standard work period frequency factor

Tuesday, September 28, 2010

NA Payroll Configuration Tables

Payroll Configuration Tables:

Foundation:
1. National ID Type
2. Name Suffix
3. Action
4. Action Reason
5. Banks
6. Form Table
7. Source Bank Accounts
8. Holiday Schedule

Earnings:
1. Earnings Table
2. Earnings Program Table
3. Special Accumulators Table
4. Review Special Accumulators

Deductions:
1. Deduction Table
2. General Deduction Table
3. Company General Deduction
4. Deduction Subset Table
5. Review Deduction Subsets

Processing:
1. Pay Group
2. Balance ID
3. Pay Run ID
4. Pay Calendars
5. Create Pay Calendars
6. Pay Message Table
7. Paycheck options
8. Rapid Entry Pay sheet
9. Configuration Online Printing
10. Final Check Program
11. Final Check Action / Reason

U.S. Taxes:

1. Tax Location Code.
2. Federal/State Tax Table
3. Company State Tax
4. State Tax Reciprocity
5. SWT Marital Status
6. Taxable Gross Definition.
7. Local Tax Table
8. Company Local Tax Table
9. Local Tax Reciprocity Table
10. Work Locality Reciprocity

Garnishment:
1. Disposable Earnings Definition
2. Disposable Earnings Defn – CAN
3. Rules Table
4. Rules Table – CAN
5. Proration Rules Definition
6. State Proration Rules
7. Clone Rules
8. Payee Table

RETROACTIVE PAY:
1. Retroactive Pay Program
2. Retroactive Pay Mass Request

BUSINESS PAYROLL SURVEY:
1. Reporting Unit Table
2. Business Information
3. Activity Table

Payroll for North America relies heavily on the information that is set up in the HRMS foundation tables, such as :
Installation
• SetID
• Location
Department
Company
• Frequency
Job Code

How To delete a process

Once a process is added (PeopleTools -> Process Scheduler -> Process) then it can be deleted from the following table.
1. PS_PRCSDEFN
2. PS_PRCSDEFNGRP
3. PS_PRCSDEFNPNL
4. PSPRCSRQST
5. PS_PRCSDEFNXFER ( Not required always)
6. PSPNLFIELD ( Not required always)

Department Security Tree

Always create a department security tree with the name "DEPT_SECURITY" as it is hardcoded in various views and very important in implementing Row level security. If this naming is not followed then departments under newly created tree will not be available while setting up the security on "Security by Dept Tree" page.

Monday, September 6, 2010

How can you Specify the Type and Size of File Attachments That Can Be Uploaded?

Use the Maxsize & Filetype option in the Addattachment function Call.

Syntax: AddAttachment(URLDestination, DirAndFilename, FileType, UserFile, MaxSize)

URLDestination - A reference to a URL. This can be either a URL name, in the form URL.URLName, or a string. This is where the file is transferred to.

DirAndFileName - A directory and filename. This is appended to the URLDestination to make up the full URL where the file is transferred to.
Note. The URLDestination requires "/" (forward) slashes. Because the DirAndFileName parameter is appended to the URL, it also requires only "/" slashes. "\" (backward) slashes are NOT supported in anyway for either the URLDestination or the DirAndFileName parameter.

FileType - A string to use as a suggestion for the extension file type, such as ".doc", ".gif", ".properties" and so on. Passing in a null string (that is, two double-quotes with no space ("")) will invoke all files (*.*)

UserFile - The name of the file on the source system.

MaxSize - Specify, in kilobytes, the maximum size of the attachment.

So, if you specify 100, that means the maximum size allowed is 100k.

The FileType parameter is only a suggestion. Specifying it does not enforce specific file types. If you do not want specific file types (such as .exe or .bat) you must write PeopleCode to discern the name and file type of the attached file and delete it.

When the end user views attachments using the ViewAttachment function, some browsers treat documents as HTML regardless of file extension, and thus execute embedded java script. You may want to write a PeopleCode program to only allow specific file extensions to be viewed.

Wednesday, August 4, 2010

Validate field using Regular Expression.

Example: Validate E-mail Id. We can use other validation (like PAN, SSN validations etc.) by changing the regular expression.
/***************************************************/
Function emailvlidation()
Local JavaObject &email_Regex = CreateJavaObject("java.lang.String", "^([0-9a-zA-Z]+[- ._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$");

Local JavaObject &Actual_String = CreateJavaObject("java.lang.String", EM_EMAIL.EMAIL_ADDR);

If &Actual_String.matches(&email_Regex) Then
/*Nothing*/
EM_EMAIL.EMAIL_ADDR.Style = "PSEDITBOX";
Else
EM_EMAIL.EMAIL_ADDR.Style = "PSERROR";
Error ("Please provide correct Email address");
End-If;

End-Function;

/***************************************************/

Read A Flat File Using File Layout And Insert Into The Specific Component Using CI ( Bulk Insert )

Read A Flat File Using File Layout And Insert Into The Specific Component Using CI:
Approach:
Get the sample flat file and create a File Layout.
Create the CI for the component.
Create an AE and drag the File Layout and CI for dynamic code generation in the peoplecode action

Sample Code:
/*******************************************************************************/
Local File &FILE1;
Local Record &REC1;
Local SQL &SQL1;
Local Rowset &RS1, &RS2;
Local integer &M;
/* *****************************************************************/
Function StartSession
try
&oSession = %Session;
&oSession.PSMessagesMode = 1;
catch Exception &ex
&LOGFILE.WriteLine(&ex.ToString());
end-try;
End-Function;
/*******************************************************************/
Function ImportData(&RS1 As Rowset)
try
&oEmPDpndtBlInsCi = &oSession.GetCompIntfc(CompIntfc.EM_P_DPNDT_BL_INS_CI);
If &oEmPDpndtBlInsCi = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc failed");
End-If;

&oEmPDpndtBlInsCi.InteractiveMode = False;
&oEmPDpndtBlInsCi.GetHistoryItems = True;
&oEmPDpndtBlInsCi.EditHistoryItems = False;

&recPerInfo = CreateRecord(Record.EM_PER_INFO);
&recPerInfo1 = CreateRecord(Record.EM_PER_INFO1);
&recBnkInf = CreateRecord(Record.EM_BANK_INFO);
&recdpdntInf = CreateRecord(Record.EM_DPNDNT_INFO);
&LOGFILE.WriteRowset(&RS);
&RS1(1).GetRecord(1).CopyFieldsTo(&recPerInfo);
&oEmPDpndtBlInsCi.EMPLID = &recPerInfo.EMPLID.Value;

rem ***** Execute Get *****;
If Not &oEmPDpndtBlInsCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
errorHandler();
throw CreateException(0, 0, "Get failed");
End-If;

&oEmPerInfo1Collection = &oEmPDpndtBlInsCi.EM_PER_INFO1;
&RS2 = &RS1(1).GetRowset(Scroll.EM_PER_INFO1);
For &i = 1 To &RS2.ActiveRowCount
If &i > 1 Then
&oEmPerInfo1 = &oEmPerInfo1Collection.EM_PER_INFO1.InsertItem(1);
Else
&oEmPerInfo1 = &oEmPerInfo1Collection.Item(1);
End-If;
&RS2.GetRow(&i).GetRecord(Record.EM_PER_INFO1).CopyFieldsTo(&recPerInfo1);
&oEmPerInfo1.EFFDT = &recPerInfo1.EFFDT.Value;
&oEmPerInfo1.SEX = &recPerInfo1.SEX.Value;
&oEmPerInfo1.MAR_STATUS = &recPerInfo1.MAR_STATUS.Value;

End-For;

&RS3 = &RS1(1).GetRowset(Scroll.EM_BANK_INFO);
&oEmBankInfoCollection = &oEmPDpndtBlInsCi.EM_BANK_INFO;
For &j = 1 To &RS3.ActiveRowCount
If &j > 1 Then
&oEmBankInfo = &oEmBankInfoCollection.EM_BANK_INFO.InsertItem(1);
Else
&oEmBankInfo = &oEmBankInfoCollection.Item(&j);
End-If;
&RS3.GetRow(&j).GetRecord(Record.EM_BANK_INFO).CopyFieldsTo(&recBnkInf);
&oEmBankInfo.BANK_NM = &recBnkInf.BANK_NM.Value;
&oEmBankInfo.BANK_ACCOUNT_NUM = &recBnkInf.BANK_ACCOUNT_NUM.Value;
End-For;

rem ***** End: Get/Set Component Interface Properties *****;
rem ***** Execute Save *****;
If Not &oEmPDpndtBlInsCi.Save() Then;
rem errorHandler();
throw CreateException(0, 0, "Save failed");
End-If;
catch Exception &ex
&fileLog.WriteLine(&ex.ToString());
end-try;
End-Function;
rem *****************************************************************;
rem * PeopleCode to Import Data *;
rem *****************************************************************;
&FILE1 = GetFile("C:\Documents and Settings\pmundhr\Desktop\dpndBlkIns.csv", "r", "a", %FilePath_Absolute);
&LOGFILE = GetFile("C:\Documents and Settings\pmundhr\Desktop\dpndBlkIns.csv.err", "W", %FilePath_Absolute);
StartSession();
&FILE1.SetFileLayout(FileLayout.EM_P_DPNDT_IB);
&LOGFILE.SetFileLayout(FileLayout.EM_P_DPNDT_IB);
&RS1 = &FILE1.CreateRowset();
&RS = CreateRowset(Record.EM_PER_INFO, CreateRowset(Record.EM_PER_INFO1), CreateRowset(Record.EM_BANK_INFO), CreateRowset(Record.EM_DPNDNT_INFO));

&RS1 = &FILE1.ReadRowset();
While &RS1 <> Null;
ImportData(&RS1);
&RS1 = &FILE1.ReadRowset();
End-While;

&FILE1.Close();
&LOGFILE.Close();
/******************************************************************************/
Sample FileLayout Image:

Tuesday, August 3, 2010

Company And Employee Count Based On Plan Type And Benefit Plan

Requirement:

Make a page containing two drop downs, one for Plan Type, and another containing Benefit Plans associated to selected Plan Type. On selecting this Plan Type and Benefit Plan, number of Employees of respective Companies should be shown on the page.

Approach:

We need to fill the grid based on selected Plan Type and Benefit Plan. So based on selected value we need to populate the data into grid.

We selected the required table based on Plan Type and used query for getting the data. These data is populated into the grid.

Main People code Functions used and its use in this requirement:

1. Insertrow : for inserting row into scroll or grid.

2. Deleterow: for deleting row from scroll or grid.

Sample Code used for this requirement:

Local number &counter = 1;
Local number &flag = 1;
&PlanType = PM_BEN_ASGN_VW.PLAN_TYPE.Value;
&BenefitPlan = PM_BEN_ASGN_VW.BENEFIT_PLAN.Value;

/*************************************************************/

&plan = Substring(PM_BEN_ASGN_VW.PLAN_TYPE, 0, 1);
Evaluate &plan
When "1"
&sPlanTableName = "PS_HEALTH_BENEFIT";
Break;
When "2"
 &sPlanTableName = "PS_LIFE_ADD_BEN";
Break;
When "3"
&sPlanTableName = "PS_DISABILITY_BEN";
Break;
When "4"
&sPlanTableName = "PS_SAVINGS_PLAN";
Break;
When "5"
&sPlanTableName = "PS_LEAVE_PLAN";
Break;
When "6"
&sPlanTableName = "PS_FSA_BENEFIT";
Break;
When "7"
&sPlanTableName = "PS_RTRMNT_PLAN";
Break;
When "8"
&sPlanTableName = "PS_PENSION_PLAN";
Break;
When "9"
&sPlanTableName = "PS_VACATION_BEN";
Break;
When "A"
&sPlanTableName = "PS_SIMPLE_BENEFIT";
Break;
End-Evaluate;

Sql1 = CreateSQL("SELECT PLAN_TYPE,BENEFIT_PLAN,COMPANY,COUNT(COMPANY) COUNTEMP FROM (SELECT J.COMPANY, J.EMPLID , A.PLAN_TYPE , A.BENEFIT_PLAN FROM "
&sPlanTableName
" A, PS_JOB J WHERE J.EMPLID = A.EMPLID AND A.PLAN_TYPE = '"
&PlanType
"' AND A.BENEFIT_PLAN = '"
&BenefitPlan
"' AND J.EFFDT =(SELECT MAX(EFFDT) FROM PS_JOB JE WHERE JE.EMPLID = J.EMPLID AND JE.EFFDT <= GETDATE()) AND J.EFFSEQ = (SELECT MAX(EFFSEQ) FROM PS_JOB JS WHERE JS.EMPLID = J.EMPLID AND JS.EFFDT = J.EFFDT) GROUP BY J.COMPANY, J.EMPLID,A.PLAN_TYPE , A.BENEFIT_PLAN) B GROUP BY PLAN_TYPE,BENEFIT_PLAN,COMPANY ");

&rwset2 = GetLevel0()(1).GetRowset(Scroll.PM_BEN_CNT_SUMM);
&row_count1 = &rwset2.ActiveRowCount;
While &Sql1.Fetch(&PLAN_TYPE1, &BENEFIT_PLAN1, &COMPANY1, &COUNTEMP)
&rwset2.GetRow(&row_count1).PM_BEN_CNT_SUMM.PLAN_TYPE.Value = &PLAN_TYPE1;
&rwset2.GetRow(&row_count1).PM_BEN_CNT_SUMM.BENEFIT_PLAN.Value = &BENEFIT_PLAN1;
&rwset2.GetRow(&row_count1).PM_BEN_CNT_SUMM.COMPANY.Value = &COMPANY1;
&rwset2.GetRow(&row_count1).PM_BEN_CNT_SUMM.COUNT_1.Value = &COUNTEMP;

&rwset2.InsertRow(&row_count1);

&row_count1 = &row_count1 + 1;
End-While;

&rwset2.DeleteRow(&row_count1);
/*************************************************************/