Wednesday, December 17, 2014

PeopleSoft Technical Interview Questions & Answers (PeopleCode)

PeopleSoft Technical Interview Questions & Answers (PeopleCode)

 * Order of people code events firing?
1.  Searchinit 
2.  Searchsave
3.  Rowselect
4.  Prebuild
5.  Field Default
6.  Field Formula
7.  RowInit
8.  PostBuild
9.  Activate
10. FieldEdit
11. FieldChange     (PrePopup, ItemSelected)
12. RowInsert
13. RowDelete
14. SaveEdit
15. SavePreChange.
16. WorkFlow
17. SavePostChnage.

* What is the difference between FieldChange Event and FieldEdit Event ?
   FieldChange Event -  Use FieldChange PeopleCode to recalculate page field values, change the appearance of page controls, or perform other processing that results from a field change other than data validation. To validate the contents of the field, use the FieldEdit event.
The FieldChange event applies to the field and row that just changed.
FieldChange PeopleCode is often paired with RowInit PeopleCode. In these RowInit/FieldChange pairs, the RowInit PeopleCode checks values in the component and initializes the state or value of page controls accordingly. FieldChange PeopleCode then rechecks the values in the component during page execution and resets the state or value of page controls.
  FieldEdit Event -  Use FieldEdit PeopleCode to validate the contents of a field, supplementing standard system edits. If the data does not pass the validation, the PeopleCode program should display a message using the Error statement, which redisplays the page, displaying an error message and turning the field red.
FieldEdit PeopleCode can be associated with record fields and component record fields.

* What is the difference between PostBuild Event and PreBuild Event ?
  PostBuild Event -The PostBuild event is initiated after all the other component build events have been initiated. This event is often used to hide or unhide pages. It’s also used to set component variables. PostBuild PeopleCode is only associated with components.During the PostBuild event you will have access to the data read from the database into the component buffer structure. That’s why it is called PostBuild.
 PreBuild Event -The PreBuild event is initiated before the rest of the component build events. This event is often used to hide or unhide pages. It’s also used to set component variables.
PreBuild fires before any PeopleCode events on all the rows and fields in the component such as FieldDefault and RowInit. During the PreBuild event there will not be any data in the component buffer structure other than search record as its executing prior to the component build process. That’s why it is called PreBuild.

* Describe RowInit Event ?
  The RowInit event is initiated the first time that the Component Processor encounters a row of data. IUse it to set the initial state of component controls. This occurs during component build processing and row insert processing. It also occurs after a Select or SelectAll Rowset method, or a ScrollSelect or related function, is executed. RowInit is not field-specific.it triggers PeopleCode on all fields and on all rows in the component buffer.Do not use Error or Warning statements in RowInit PeopleCode: these cause a runtime error.

* Explain SaveEdit Event in peoplecode ?
The SaveEdit event is intiated whenever a user attempts to save the component. You can use SaveEdit PeopleCode to validate the consistency of data in component fields. Whenever a validation involves more than one component field, you should use SaveEdit PeopleCode. If a validation involves only one page field, use FieldEdit PeopleCode. SaveEdit is not field-specific: it triggers associated PeopleCode on every row of data in the component buffers, except rows flagged as deleted.

* Difference between SavePrechange and SavePostchange Events.
  SavePreChange Event -The SavePreChange event is initiated after SaveEdit completes without error.SavePreChange PeopleCode provides one final opportunity to manipulate data before the system updates the database.In Save Prechange we can get the data from Component Buffer for that particular Component.
 SavePostChange Event - SavePostChg is different from all other Peoplecode events since it is performed after the updates are made on the database.SavePost change Component Buffer is cleared we have to get data from Database and this is used to update values outside the database.

* Difference between SaveEdit and Fieldedit ?
Fieldedit event is fired every time for each row when field is edited where as 
SaveEdit is fired only once when a user click on save button .

* What is the component processor?                                                                                                Component processor is a runtime engine that controls processing of an application from the time user request the component from the menu till the database is updated and processing of component is completed.

* Explain about the component buffer and data buffer?
  Component Buffer contains all the Data of active component. The data buffer is used to store data added from sources other than the component, such as from a PeopleSoft Application Engine program, an application message, and so on. PeopleTools 8 provides an alternative to the scroll level, row, and field components in the form of the data buffer classes Rowset, Row, Record, and Field, which you reference using dot notation with object methods and properties.

*Difference between SQLExec and CreateSql? 
  SQLExec can only select a single row of data. If your SQL statement retrieves more than one row of data SQLExec sends only the first row to its output variables. Any subsequent rows are discarded.  CreateSQL If you need to SELECT multiple rows of data use the CreateSQL or GetSQL functions and the Fetch SQL class method.

*Explain about ACTIVE event?
  The Activate event get fired each page gets activated. Active PeopleCode can only be associated with pages. The event is used for security validations such as field enabling and hiding a scroll, enabling user to programmatically control the display of that page controls. This event is used for component build processing in add mode and update mode.

*What is deferred processing? 
Deferred processing is used speed up the data-entry process.  This means that the system does not validate the data for each field as you Tab through a page.  You can enter in all the data for your page without unnecessary trips to the server for data validation. Entered data is validated when:

  • You navigate to another page in the component 
  • Click the Save button 
  • Click the Refresh button (access key: Alt+0) 

If there are any errors in your data, you are notified at this time.
 Field Edit event will not fire until we press the SAVE button if the deferred processing is ON.


* Difference between Getrowset and Createrowset? 
   GetRowset is used to get rowset for a record in the component buffer.
   CreateRowset is used to create rowset for a record which is in database, and is also called as standalone rowset.

* What is scrollflush()  function ? 
   Used to remove all rows inside target scroll area and frees it associated buffer. Rows that are flushed are not deleted from the database. This function is often used to clear work scroll before a call to ScrollSelect.
Syntax: ScrollFlush (scrollpath)

* Explain about the workflow event?                                                                                              WorkFlow PeopleCode executes immediately after SavePreChange and before database update that precedes SavePostChange. The main purpose of the workflow event is to segregate PeopleCode related to workflow from the rest of applications PeopleCode. Only PeopleCode related workflow (Such as triggerbusinessevent) should be in workflow programs. Your program should be deal with workflow only after my SavePreChange process completed.

* Explain Think-time function? 
Think-time functions suspended processing until the user has taken some actions (such by clicking button in message box), or until external function has run to completion (for example a remote process).
Think-time function hold avoids the following events: SavePreChange, Workflow, RowSelect, SavePostChange.
 
* In which PC events dosave function is useful?
   FieldEdit, FieldChange, or ItemSelected.

To Create Component Interface from scratch in Peoplesoft

To Create Component Interface from scratch in Peoplesoft

To Create Component Interface from scratch


As you may or may not know, PeopleSoft delivers several component interfaces for most of the major components inside PeopleSoft.  For example, in HCM there are component interfaces such as ones for the JOB_DATA component and another for the PERSON information.

Each of these delivered component interfaces are also known as Enterprise Integration Points.  It's nice to be able to just utilize a delivered component interface in PeopleSoft when you need to get data inserted or updated into a delivered component.

Remember, the biggest reason for using a Component Interface is to trigger all of the same business rules, warnings, errors, etc.. that PeopleSoft triggers when a user is entering data on a page.  However, there are also instances when you will need to create your own Component Interface from scratch, because PeopleSoft does not provide one, or perhaps its a custom component of your own.

So, let's dive into creating a CI from scratch.

As I mentioned earlier, a component Interface is based on a single component withinPeopleTools. This is why you must know understand and know the structure of the component that you are creating a CI for. But, don’t worry, you can simply use the existing component within your application or create a component for the sole purpose of creating and building your component interface.

Remember, the CI components, such as the keys, are created based on settings in the referenced component. And, you create a Component Interface object the same as you would create any other PeopleTools object in Application Designer. Here are the steps for creating a New CI.

1. Select File, New from the Application Designer menu and choose Component Interface.



2. You will be asked to choose the Component on which this component interface is based.

3. Next, you will be asked if you want the fields exposed in the selected component to become the default properties of the component interface.


If you elect to have the property definitions automatically defaulted by the system, then all properties that appear on the pages of the underlying component are added to the component interface. I recommend that you choose Yes and accept the default properties. Even though the system adds the default properties, you may need to move other properties into the component view for the component to work.



An untitled component interface appears, showing the Get keys and Find keys. Remember, the Create keys are produced only if the underlying component is able to run in Add mode and Application Designer generates the keys for you as you drag definitions.

Also, notice the standard methods Cancel, Find, Get, and Save is automatically created.

You can begin adding properties to a new component interface at any point. However, you cannot add any user-defined methods to the component interface until you have saved the component interface. Once you have saved the component interface, you can further define user-defined methods.

Next, I'll be talking about the various rules you'll need to follow when creating a Component interface

Monday, December 15, 2014

Parallel Processing using Temporary Record with Application Engine in PeopleSoft

This is another important question we often encounter during the interviews. I have been struggling a lot to understand and finally did it with a classic example.


Parallel processing comes in picture when there is a requirement to process large bulk of rows without compromising the performance which might otherwise get impacted greatly with non-parallel based processing. We would try to understand this concept with an actual example where this concept has been used.

Requirement - There are 100,000 employees in the organization and many of them have more than one assignments (EMPL_RCD) hence the total number of rows in the PER_ORG_ASGN record collectively will be 120,000. Develop a program to update the primary job indicator flag for each employee in the table PRIMARY_JOBS.

Implementing Parallel Processing using Temporary Record with Application Engine

Step :1 Open the App Designer
Step :2 Create three record definitions BN_EMPLID_WRK, BN_EMPLID1_WRK and BN_JOB_WRK of type "Temporary Table"


Step 3: Create a record BN_AGE50_AET of type "Derived/Work" 



Step 4: Create a new Application Engine program "BN_UPD_PRIM" in app designer.
Step 5: Open the Application engine properties, go to "Temp Tables" tab and assign all three temp tables. Give the instance count as 10.



Step 6: Likewise, go to "State Records" tab and add the record BN_AGE50_AET.

Step 7: Build the temporary records BN_EMPLID_WRK, BN_EMPLID1_WRK and BN_JOB_WRK. App designer will create the number of instances for each of these temporary tables equal to given in the Program Properties -> Temp Tab - Instance count box which is "10" in our case which means the tables for each temp record will be created as below:

   BN_EMPLID_WRK -  BN_EMPLID_WRK1, BN_EMPLID_WRK2... up to 10 instances
   BN_EMPLID1_WRK - BN_EMPLID1_WRK1, BN_EMPLID1_WRK2.... up to 10 instances
   BN_JOB_WRK - BN_JOB_WRK1, BN_JOB_WRK2.... up to 10 instances

Step 8:  In the MAIN section of app engine (Or create a new section) add a Step/Action of SQL type, then add below SQL in that.



This SQL will load all the employees into temp table instances BN_EMPLID_WRK1, BN_EMPLID_WRK2... etc, Please make sure that you are using the meta sql %Table with the temp table name. 
Lets say we have 100,000 employees in PS_PERSON record and each employee has just one assignment in PS_PER_ORG_ASGN. Since we have instance count for the temp record to 10 so when the program is run, The selected 100000 rows will be divided into like 100000/10 = 10000 and each chunk of 10000 rows will be inserted into one of the available instances BN_EMPLID_WRK1, BN_EMPLID_WRK2 ...etc.

Please note that we don't have to worry about which instance a particular chunk is being inserted into instead, %Table metasql does that for us. However, Its not necessary that application engine will process the rows in exactly same way explained above, its just a logical explanation which is trying to convey that the number of selected rows i.e 100,000 will be divided and loaded into appropriate temp table instances to be processed simultaneously which is nothing but parallel processing.
Once above step is processed, the temp table BN_EMPLID_WRK has been loaded with large volume of data (1000,000 rows) of employees eligible to be processed. How many rows have been loaded in which temp table instance (BN_EMPLID_WRK1, BN_EMPLID_WRK2... etc) is none of our concerns.

Step 9: Add below Step/Action to update the statistics of temp table BN_EMPLID_WRK for the indexes to improve the performance when the rows are selected from the instances of this table in further steps.


Step 10: Add below Step/Action to get the JOB data (EFFDT, EFFSEQ and EMPL_STATUS) for each employee loaded in BN_EMPLID_WRK, and insert into another temp table BN_JOB_WRK (BN_JOB_WRK1, BN_JOB_WRK2 ... upto 10 instances).



Here again as you notice, we just used %Table metasql with the table BN_JOB_WRK in the SQL which will take care as to how should be the allocation of rows for the instances BN_JOB_WRK1, BN_JOB_WRK2...etc.

Step 11:  Add below Step/Action to update the statistics of temp table BN_JOB_WRK for the indexes to improve the performance when the rows are selected from the instances of this table in further steps.


Step 12: Add below Step/Action to select those employees loaded in the temp table BN_EMPLID_WRK who are all don't have more than one assignments (EMPL_RCD) for a benefit record number (BENEFIT_RCD_NBR), and insert into another temp table BN_EMPLID1_WRK (BN_EMPLID1_WRK1, BN_EMPLID1_WRK2...upto 10 instances).



Step 13: Add below Step/Action to update the statistics of temp table BN_EMPLID1_WRK for the indexes to improve the performance when the rows are selected from the instances of this table in further steps.



Step 14: Finally, mark the current EMPL_RCD as "Primary Job" in the  table PS_PRIMARY_JOBS for the processed employees by joining all three temp tables.


Well, it's quite evident that the procedure to implement parallel processing appears simpler than we thought. However, if we try to compare it with the non-parallel way of addressing the same request then it would certainly help us understand the concept clearly.

Let's discuss how would it have been addressed if there was no mechanism called "Parallel Processing". 
1) Record Definition - The number of records will be same but the record type for BN_EMPLID_WRK, BN_EMPLID1_WRK and BN_JOB_WRK will be "Table".
2) Since there is no temporary record created hence no need to assign the temp records in Program Properties -> Temp Tables. It won't be applicable.
3) No Need to use %Table metasql while referring to the records.

Everything else will remain exactly same. We also need to understand how different it will behave without parallel processing. 
In this case, When we run the program, The system will  store all the 100,000 rows into the table BN_EMPLID_WRK during the execution of Step 1 explained earlier unlike, into various temp table instances BN_EMPLID_WRK1, BN_EMPLID_WRK2..etc. So, when execution goes further then all the 100,000 rows are fetched from one table and processed but in case of parallel processing the chunk of rows i.e 10000 if fetched from each temp table instance and processed all simultaneously. 
Hence, If time taken to complete the processing is 20 Mins then it will be 20/10 ~ 2 to 5 Mins if parallel processing is used.