You are on page 1of 10

EO Extension in R12

We are extending the EO to perform below tasks

1) Defaulting the EmployeeId automatically


2) Set default value for Hire Date
3) Hire Date should not be less than System Date
4) End Date is not less than System Date as well as Hire Date.

Task 1 & 2

When we are navigating from search page to create page employee number is not populating
automatically and user enters the employee number manually so there are chances that user
may get error of primary key violation.

We click on “About this page” link to check the EO associated with this page as we know
defaulting of attributes is done in EOImpl.

We can see that page has QueryVO1 attached. Click on QueryVO1. Here we can see that it is
based on FwkTbxEmployeesEO that we need to extend for defaulting employee number.

http://oracleanil.blogspot.com/  Page 1 
As we can see that FwkTbxEmployeesEO is present in oracle.apps.ak.solution.schema.server
package hence we will copy the solution package from $JAVA_TOP and copy/ftp in
myprojects/oracle/apps/ak folder as well as in myclasses/oracle/apps/ak folder.

Create a new OA workspace as well as new Project.

Now right click on your project and click on New

Select Entity Object under Business Tier ADF Business Components click OK

http://oracleanil.blogspot.com/  Page 2 
1. Give the name as ExtFwkTbxEmployeesEO and click on Browse for extends and select
the original EO. Change the package name to oracle.apps.ak.ajay.schema.server.

2. In the Step 2 of 5: Attributes pane press the New from Table button to acquire the
attributes the EO will support. Shuttle all attributes in the Available pane to the Selected
pane by pressing the >> button.

3. Locate the RowId attribute and remove it from the Available pane by selecting it and
pressing the < button. If this is not done the existing view object will fail to work on the page.

http://oracleanil.blogspot.com/  Page 3 
4. Press the Next button 2 times to get to the Step 4 of 5: Java pane. Deselect the Accessors
and Select the Create by clicking in the check boxes. Also select the ValidateEntity() by
clicking in the check boxes. Remember that this extended EO will inhereit the Accessors
from the parent. Use the parent code whenever possible. Press the Next button.

5. Do not generate the Default View Object. Leave this checkbox unchecked.

http://oracleanil.blogspot.com/  Page 4 
6. Press the Finish button to create the new Entity Object.

NOTE: Remember, this action generates a fully functional Entity Object which functions
exactly like the parent. Any changes should be added to this extended Entity Object by
method overriding or overloading. After the new code is created and the substitution is in
place, all changes will run as if they had been made to the parent class.

Now Edit the ExtFwkTbxEmployeesEOImpl and add the defaulting logic for EmployeeId as well
as for Hire Date. For this we will override the Create method and set the EmployeeId based on
sequence value from database. Here is the modified create method.

http://oracleanil.blogspot.com/  Page 5 
public void create(AttributeList attributeList)
{
super.create(attributeList);
OADBTransaction dbt = getOADBTransaction();
Number empId = dbt.getSequenceValue("FWK_TBX_EMPLOYEES_S");
//FWK_TBX_EMPLOYEES_S is the sequence name existing in the database
setEmployeeId(empId);
setStartDate(dbt.getCurrentDBDate());
//Defaulting the Hire Date with Current system Date
}

Task 3 & 4 are refers to check that Hire date and end date are not less than system date and end
Date is not less than Hire Date

For this we will override setStartDate, setEndDate and validateEntity() method Here are the final
methods you need to copy to your ExtFwkTbxEmployeesEOImpl File

import oracle.jbo.domain.Date;
import oracle.apps.ak.solution.schema.server.FwkTbxEmployeesEOImpl;
import oracle.apps.fnd.framework.OAAttrValException;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OARowValException;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAEntityDefImpl;

import oracle.jbo.AttributeList;
import oracle.jbo.Key;
import oracle.jbo.domain.Number;
import oracle.jbo.server.EntityDefImpl;

/**Overriding SetStartDate Method to validate hiredate should not be


less than current date
*/
public void setStartDate(Date value){
validateStartDate(value);
super.setStartDate(value);
}
public void validateStartDate(Date value){
if (value!=null){
long sysDate =
getOADBTransaction().getCurrentDBDate().dateValue().getTime();
long dateValue = value.dateValue().getTime();
if (dateValue<sysDate){
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(),
getPrimaryKey(),
"StartDate",
value,
"AK",
"FWK_TBX_T_START_DATE_PAST");
}
}
}

http://oracleanil.blogspot.com/  Page 6 
/**Overriding setEndDate Method to validate enddate should not be
less than current date & hiredate.
*/
public void setEndDate(Date value){
validateEndDate(value);
super.setEndDate(value);
}
public void validateEndDate(Date value){
if (value!=null){
long sysDate =
getOADBTransaction().getCurrentDBDate().dateValue().getTime();
long dateValue = value.dateValue().getTime();
if (dateValue<sysDate){
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(),
getPrimaryKey(),
"EndDate",
value,
"AK",
"FWK_TBX_T_END_DATE_PAST");
}
}
}
/**Overriding validateEntity() Method to validate Enddate is not
less than hiredate
*/
protected void validateEntity() {
super.validateEntity();
Date startDate = getStartDate();
Date endDate = getEndDate();
if
(endDate.dateValue().getTime()<startDate.dateValue().getTime()){
throw new
OARowValException(OARowValException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(),
getPrimaryKey(),
"AK",
"FWK_TBX_T_START_END_BAD");
}
}

Now we need to perform the substitution so open project properties and go to Business
Components Substitutions

Select FwkTbxEmployeesEO in available list and Ext FwkTbxEmployeesEO in Substitute list and
click on Add button.

http://oracleanil.blogspot.com/  Page 7 
Now we need to deploy the files from local to server.

For this we will navigate to myclasses/oracle/apps/ak/ and zip up ajay folder and FTP it on
$JAVA_TOP/oracle/apps/ak/ and unzip the folder there

Now we need to run the jpximporter command.

java oracle.jrad.tools.xml.importer.JPXImporter
$JDEV_USER_HOME/myprojects/Extend.jpx -username apps -password apps -
dbconnection
"(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xxx.xx.oracle.com)(PORT=1521)
)(CONNECT_DATA=(SID=1346)))"

Now bounce the Apache and test your changes by running the page from application.

Here is new create page now

You can see that Employee number is automatically generated and hire date is defaulted to
current date as well. But right now our Employee Number is updateable so through
personalization we will set its read only property to true at site level.

http://oracleanil.blogspot.com/  Page 8 
For this Click on Personalize page Complete View Expand All
Click on personalize icon for messageTextInput: Number

Set “Read Only” property as true and click on Apply.

http://oracleanil.blogspot.com/  Page 9 
Here is your new page looks like with attribute level error thrown for Hire Date and End date less
than Current Date.

Cheers.. ☺
AJ

http://oracleanil.blogspot.com/  Page 10 

You might also like