0% found this document useful (0 votes)
264 views23 pages

2-Oracle Application Framework (OAF) Training Guide - Update, Delete Insert, Validation

This document provides training on performing data manipulation language (DML) operations and validation on jobs and positions in an Oracle Application Framework application. It includes steps for updating, deleting, and inserting job and position records. It demonstrates creating application module methods to commit changes, delete records by row reference, initialize new records, and get sequence values. It also shows configuring buttons and links to fire actions that call the application module methods.

Uploaded by

Preethi Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
264 views23 pages

2-Oracle Application Framework (OAF) Training Guide - Update, Delete Insert, Validation

This document provides training on performing data manipulation language (DML) operations and validation on jobs and positions in an Oracle Application Framework application. It includes steps for updating, deleting, and inserting job and position records. It demonstrates creating application module methods to commit changes, delete records by row reference, initialize new records, and get sequence values. It also shows configuring buttons and links to fire actions that call the application module methods.

Uploaded by

Preethi Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Oracle Application Framework Training Guide

Contents
1- Job and Position DML ................................................................................................. 1
1- Update.................................................................................................................................. 1
2- Delete ................................................................................................................................... 4
A.Delete Position ............................................................................................................ 4
B.Delete Job and its related Positions ........................................................................... 6
3- Insert ................................................................................. Error! Bookmark not defined.
A. Insert Position............................................................................................................. 9
A. Insert Job ................................................................................................................... 11

2- Job and Position Validation ..................................................................................... 14


A. Positions Dates Validation ...................................................................................... 14
B. Jobs Dates Validation ............................................................................................... 16
C. Job Headcount Validation ....................................................................................... 16
D. Position Headcount Validation .............................................................................. 18

View Object..................................................................................................................... 21

Oracle Application Framework Training Guide

1- Job and Position DML


Step
No.
1
2
3

Description

1- Update
As Default we will create Public method in AM and call it from CO when action fired on page
public void Save()
{
//Commeit changes to DB
getOADBTransaction().commit();
}

5
6

Click on Page (XxJobsAndPositionsPG.xml) and Right Click on MainRN New New Region

ID ButtonsRN
Region Syle pageButtonBar

Oracle Application Framework Training Guide

9
10

Right Click on ButtonsRN New Item

11

ID Save
Item Style submitButton
Prompt Save
Action Type fireAction
Event Save

12

13
14
15

We need to handle this action CO


Open CO (Double Click file XxJobsAndPositionsCO.java)
if (pAction.equals("Save"))
{
//Commit Changes
pXxHrAm.invokeMethod("Save");
}

Oracle Application Framework Training Guide


16

17
18

No Run Page query change in any field press save query again
Query

Change Oracle Technical Consultant to Standalone Technical Consultant

Press save
Query Again

Oracle Application Framework Training Guide


19

2- Delete

20

A.Delete Position

21
22

Double Click on ViewObject XxPositionsVO

23
24

Click on Java and check Generate Java files

25
26

After that there are one file created

27

Notes about View Object and its Files

28
29

Create Public method in AM


In import section
//To can uses methods in java files generated in previous step
import xx.oracle.apps.per.xxhr.server.XxPositionsVORowImpl;
public void DeletePositionByRowReff(String pRowReference)
{
//Define ViewObjectRow Variable and get in it current row
XxPositionsVORowImpl pPositionsVORow = (XxPositionsVORowImpl)findRowByRef(pRowReference);
//Remove this row
pPositionsVORow.remove();
}

30

Oracle Application Framework Training Guide


31

32
33

Right Click on PositionTable New Item

34

ID DeleteLink
Item Style Link
Action Type fireAction
Event DeletePosition
Right Click on DeleteLink

35
36

37

38

ID DeletePositionImg
Prompt Delete
Image URL deletearea_enabled.gif
All images will be find in root (<Jdeveloper path>\jdevhome\jdev\myhtml\OA_MEDIA)
You can put your own image and use it

Oracle Application Framework Training Guide


39
40

41

Open CO (Double Click file XxJobsAndPositionsCO.java)


Put
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
In inport section
if (pAction.equals("DeletePosition"))
{
//Define String variable get in it row refernce (Like Key) which action fire on it
String RowReference =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
//Define Serializable (List of parameters) and put row refernce in it
Serializable[] paramList = { RowReference };
//Invoke method we create in Application Module and pass to it parameters
pXxHrAm.invokeMethod("DeletePositionByRowReff",paramList);
}

42

43
44

Now Run Page and try to delete and save

45
46
47

Double Click on ViewObject XxJobsVO


Click on Java and check Generate Java files

48

After that there are one files created

B.Delete Job and its related Positions

Oracle Application Framework Training Guide


49

50
51
52

Create Two Public method in AM one for delete positions by jobid and other delete job by ref like previous
First One
public void DeletePositionByJobId(String pJobId)
{
//Define array and get all rows in XxPositionsVO1
Row pPositionsVORow[] =getXxPositionsVO1().getAllRowsInRange();
//Loop on this rows and delete row with job id passed in method "pJobId"
for(int i=0;i<pPositionsVORow.length;i++)
{
//Define ViewObjectRow Variable and get in it row by row
XxPositionsVORowImpl rowi=(XxPositionsVORowImpl)pPositionsVORow[i];
//Check if job id in this row equal to variable if yes then remove and continue loop
if (rowi.getJobId().toString().equals(pJobId))
{
rowi.remove();
}
}
}

53

54
55
56

Second one
In import section
import xx.oracle.apps.per.xxhr.server.XxJobsVORowImpl;
public void DeleteJobByRowReff(String pRowReference)
{
//Define ViewObjectRow Variable and get in it current row
XxJobsVORowImpl pJobVORow = (XxJobsVORowImpl)findRowByRef(pRowReference);
//Define String to get job id
String pJobId = pJobVORow.getJobId().toString();
//invoke method that delete position with jobid
DeletePositionByJobId(pJobId);
//Remove this row
pJobVORow.remove();
//Make first row selected
getXxJobsVO1().first().setAttribute("SelectFlag","Y");
}

Oracle Application Framework Training Guide


57

58
59

Right Click on JobTable New Item

60

ID DeleteJobLink
Item Style Link
Action Type fireAction
Event DeleteJob
Right Click on DeleteJobLink

61
62

63

64
65

ID DeleteJobImg
Prompt Delete
Image URL deletearea_enabled.gif
Open CO (Double Click file XxJobsAndPositionsCO.java)
if (pAction.equals("DeleteJob"))
{
//Define String variable get in it row refernce (Like Key) which action fire on it
String RowReference =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
//Define Serializable (List of parameters) and put row refernce in it
Serializable[] paramList = { RowReference };
//Invoke method we create in Application Module and pass to it parameters
pXxHrAm.invokeMethod("DeleteJobByRowReff",paramList);
}

Oracle Application Framework Training Guide


66

67
68

Now Run Page and try to delete Job and save

69
70

Right Click on PositionTable New tableActions

71

A new region created change


ID PositionTableActions
Right Click on PositionTableActions New Item

72
73

A. Insert Position

Oracle Application Framework Training Guide


74

75
76

77

ID AddPosition
Item Style submitButton
Prompt Add New Position
Action Type fireAction
Event AddPosition
Create Public method in AM
Put
import oracle.apps.fnd.framework.OAException;
In import scetion
public void IniPositionRecord()
{
//Check that there are records in JObVO to can create deatil for it
if (!getXxJobsVO1().isPreparedForExecution())
{
throw new OAException("Please select job record first",OAException.ERROR
);
}else
{
int RowCount = getXxJobsVO1().getRowCount();
if (RowCount == 0)
{
throw new OAException("Please select job record
first",OAException.ERROR);
}else
{
//Define ViewObject Variable and get in it XxJobsVO1 View Object
OAViewObject pPositionsVO = getXxPositionsVO1();
//Check if VO of able to create record
if (!pPositionsVO.isPreparedForExecution())
{
//if not prepared
pPositionsVO.setMaxFetchSize(0);
pPositionsVO.executeQuery();
pPositionsVO.setMaxFetchSize(-1);
}
pPositionsVO.last();
pPositionsVO.next();
Row pPositionsVORow = pPositionsVO.createRow();
pPositionsVO.insertRow(pPositionsVORow);
//Get position Id sequense like XX_POSITION_ID_SEQ.NextVal in Sql and
set Attribute PositionId
String pNewPositionId =
getOADBTransaction().getSequenceValue("XX_POSITION_ID_SEQ").toString();
pPositionsVORow.setAttribute("PositionId", pNewPositionId);

Oracle Application Framework Training Guide


}
}
}
78

79
80

In CO
if (pAction.equals("AddPosition"))
{
//Invoke method we create in Application Module to create new record in position VO
pXxHrAm.invokeMethod("IniPositionRecord");
}

81

82
83

Now Run Page and try to insert new reord in poistion

84

Right Click on JobTable New tableActions

A. Insert Job

Oracle Application Framework Training Guide


85

86
87
88

89

90
91

A new region created change


ID JobTableActions
Right Click on JobTableActions New Item

ID AddJob
Item Style submitButton
Prompt Add New Job
Action Type fireAction
Event AddJob
Create Public method in AM
public void IniJobRecord()
{
//Define ViewObject Variable and get in it XxJobsVO1 View Object
OAViewObject pJobsVO = getXxJobsVO1();
//Check if VO of able to create record
if (!pJobsVO.isPreparedForExecution())
{
//if not prepared
pJobsVO.setMaxFetchSize(0);
pJobsVO.executeQuery();
pJobsVO.setMaxFetchSize(-1);
}
pJobsVO.last();

Oracle Application Framework Training Guide


pJobsVO.next();
Row pJobsVORow = pJobsVO.createRow();
//To make radio group is check on new reocrd
pJobsVORow.setAttribute("SelectFlag", "Y");
pJobsVO.insertRow(pJobsVORow);
//Get position Id sequense like XX_JOB_ID_SEQ.NextVal in Sql and set Attribute JobId
String pNewJobId = getOADBTransaction().getSequenceValue("XX_JOB_ID_SEQ").toString();
pJobsVORow.setAttribute("JobId", pNewJobId);
}
92

93
94

In CO
if (pAction.equals("AddJob"))
{
//Invoke method we create in Application Module to create new record in position VO
pXxHrAm.invokeMethod("IniJobRecord");
}

95

96

Now Run Page and try to insert new reord in job

Oracle Application Framework Training Guide

2- Job and Position Validation


Step
No.
1
2
3

Description
Delete All data in XX_JOBS and XX_POISTIONS And run OA Project DML Script.sql Again
Set the four fields under PoistionTable and JobTable required Yes

A. Positions Dates Validation

We need to define meesage in application


Application Developer Application Messages

Name XX_POSITION_DATE_VALIDATION
Language US
Application Human Resources
Current Message Text In Poistion table effective start date can not be greater than effective end date

Open file XxPositionsEOImpl.java


xx.oracle.apps.per.xxhr.schema.server XxPositionsEO XxPositionsEOImpl.java
in this file we will find for each attribute two public void one for set and other for get

9
10

This will validate that if effective start date can not be greater that effective end date
In Import Section

Oracle Application Framework Training Guide

11

import oracle.apps.fnd.framework.OAAttrValException;
import oracle.apps.fnd.framework.OARowValException;
import oracle.jbo.domain.Timestamp;
import oracle.jbo.Row;
Search for public void setEffectiveStartDate
This is metod that responsible to set effective start date attribute in EO
Delete setAttributeInternal(EFFECTIVESTARTDATE, value);
And write
if (value != null)
{
Date pEffectiveEndDate =getEffectiveEndDate();
if (pEffectiveEndDate != null)
{
Timestamp pEffectiveStartDateTime = new Timestamp(value);
Timestamp pEffectiveEndDateTime = new Timestamp(pEffectiveEndDate);
if (pEffectiveEndDateTime.getTime()< pEffectiveStartDateTime.getTime() )
{
throw new OARowValException (
getEntityDef().getFullName(), // entity full definition name
getPrimaryKey(), // entity object primary key
"PER", // Message application short name
"XX_POSITION_DATE_VALIDATION"); // Message name
}else
{
setAttributeInternal(EFFECTIVESTARTDATE, value);
}
}else
{
setAttributeInternal(EFFECTIVESTARTDATE, value);
}
}else
{
setAttributeInternal(EFFECTIVESTARTDATE, value);
}

12

13

Search for public void setEffectiveEndDate


This is metod that responsible to set effective start date attribute in EO
Delete setAttributeInternal(EFFECTIVEENDDATE, value);

Oracle Application Framework Training Guide


And write
if (value != null)
{
Date pEffectiveStartDate =getEffectiveStartDate();
if (pEffectiveStartDate != null)
{
Timestamp pEffectiveStartDateTime = new Timestamp(pEffectiveStartDate);
Timestamp pEffectiveEndDateTime = new Timestamp(value);
if (pEffectiveEndDateTime.getTime()< pEffectiveStartDateTime.getTime() )
{
throw new OARowValException (
getEntityDef().getFullName(), // entity full definition name
getPrimaryKey(), // entity object primary key
"PER", // Message application short name
"XX_POSITION_DATE_VALIDATION"); // Message name
}else
{
setAttributeInternal(EFFECTIVEENDDATE, value);
}
}else
{
setAttributeInternal(EFFECTIVEENDDATE, value);
}
}else
{
setAttributeInternal(EFFECTIVEENDDATE, value);
}
14

15
16

Now try to update dates in position or insert new record and save
If you need to make this validation after enter data and press tab
You need to set the two fields (effective start date and effective end date )
Action Type fireAction
Event PoistionValidateDate
No need to handle this action in CO and AM as what we need in this case only to fire any action to refresh page
which make the http to send data to VO then to EO and our validation will fire
The action we put will fire when data changed inside fild and cursour is go out of field like post_change in forms

17

B. Jobs Dates Validation

18

Like the position dates validation but you need to create a new meesage (HomwWork)

19

C. Job Headcount Validation

Oracle Application Framework Training Guide


20
21

22
23

24
25

Delete All data in XX_JOBS and XX_POISTIONS And run OA Project DML Script.sql Again
Define Message
Name XX_JOB_HEADCOUNT_VALIDATE
Language US
Application Human Resources
Current Message Text In Job table job headcount cannot be less than total positions headcount
In file XxJobsEOImpl.java
Put
import xx.oracle.apps.per.xxhr.schema.server.XxPositionsEOImpl;
in import
Before the last Arc write our method
public float xxGetPositionHeadCount()
{
//Define Variable float
float PositionHeadCount =0 ;
//Get Position EO
RowIterator xRowIterator = getXxPositionsEO();
//Loop in this EO and sum headcount in this lines
while (xRowIterator.hasNext())
{
xRowIterator.next();
PositionHeadCount = PositionHeadCount +
Float.valueOf(xRowIterator.getCurrentRow().getAttribute("PositionHeadCount").toString()).floatValue();
}
//return total position head count
return PositionHeadCount;
}

26

27
28
29

Search for setJobHeadCount in the same file


if (value != null)
{
float PositionHeadCount = xxGetPositionHeadCount();
if (PositionHeadCount > value.floatValue() )
{
throw new OARowValException (
getEntityDef().getFullName(), // entity full definition name
getPrimaryKey(), // entity object primary key
"PER", // Message application short name
"XX_JOB_HEADCOUNT_VALIDATE"); // Message name
}else

Oracle Application Framework Training Guide


{
setAttributeInternal(JOBHEADCOUNT, value);
}
}else
{
setAttributeInternal(JOBHEADCOUNT, value);
}
30

31
32

click on JobHeadCount1

33

ActionType fireAction
Event JobHeadCountValidate
Now run page and try to change JobHeadCount to be less than 10

34
35
36

37
38
39

D. Position Headcount Validation


Define Message
Name XX_POSITION_HEADCOUNT_VALIDATE
Language US
Application Human Resources
Current Message Text In Position table position headcount cannot be greater than job headcount
In file XxPositionsEOImpl.java
Search for setPositionHeadCount
Number OldPoistionHeadCount = getPositionHeadCount();
float JobHeadCount = Float.valueOf(getXxJobsEO().getAttribute("JobHeadCount").toString()).floatValue();
setAttributeInternal(POSITIONHEADCOUNT, value);
if (value != null)
{
float AllPositionHeadCount = getXxJobsEO().xxGetPositionHeadCount();
if (AllPositionHeadCount > JobHeadCount )
{
setAttributeInternal(POSITIONHEADCOUNT, OldPoistionHeadCount);

Oracle Application Framework Training Guide


throw new OARowValException (
getEntityDef().getFullName(), // entity full definition name
getPrimaryKey(), // entity object primary key
"PER", // Message application short name
"XX_POSITION_HEADCOUNT_VALIDATE"); // Message name
}
}
40

41
42

click on PoisitonHeadCount

43

ActionType fireAction
Event PositionHeadCountValidate

Oracle Application Framework Training Guide


44

Now run page and try to change PoistionHeadCounts to be greater than 10

Oracle Application Framework Training Guide

View Object
Step
No.
45

46

Description
View Object Can be build Based on :
1- Entity object in case we will use it in DML like OUR Example
2- Query in case we will use it in LOV(Will be seen later in next Days)
Java Files For VO
1- ViewObject.xml Contain SQL of VO and eneity object based on it also attributes in VO
2- ViewObjectImp all us to deal with View object it self as one component with all its rows.
For Example if you need to get or set attribute in view object you have one method
Getattribute(Attributename) also in set SetAttribute(AttributeName,Value)
3- ViewObjectRowImp it deal with only on row we fetch this row by refrence of rownum or
For Example if you need to get or set attribute in row you have for each attribute two metodh one for ge
and other for set

You might also like