Read this below blog to have a overview how the CO Extension works.
http://mogalafzal.blogspot.com/2016/03/21-oaf-co-extension.html
Requirement:
To make the attachments mandatory in the review page for certain EIT and SIT Transactions, not all.
Created lookup value with the Function_name as lookup_code to validate attachments required. Attached procedures and images of lookups for reference.
1.
Page: /oracle/apps/per/selfservice/review/webui/ReviewPG
Controller: ReviewCO --> ReviewCOEx
Create new project with package name: xxcust.oracle.apps.per.selfservice.review.webui
import the folder from the java top : oracle.apps.per.selfservice.review.webui.ReviewCO (class file)
2.
Write below code in PFR in your extend of ReviewCO as ReviewCOEx java file.
public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean) {
OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
// throw new OAException("under sql exception"+oapagecontext.getParameter("OAFunc"),OAException.INFORMATION);
OADBTransactionImpl txn = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();
//getting the function id name and comparing it with our lookup values to check if required Y or N
String outParamValue = null;
CallableStatement callableStatement =
txn.createCallableStatement("begin P_GET_TXN_NAME_YN(:1, :2); end;",OADBTransaction.DEFAULT);
try {
callableStatement.setString(1,oapagecontext.getParameter("OAFunc"));// "HR_EIT_VS_SS"
callableStatement.registerOutParameter(2, Types.VARCHAR);
callableStatement.execute();
outParamValue = callableStatement.getString(2);
callableStatement.close();
} catch (SQLException sqle) {
throw new OAException("under sql exception"+sqle,OAException.ERROR);
}
OADBTransactionImpl txn2 = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();
OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
//getting the status of the Attachments as None for no attachments, but for arabic it is issue, so we are using lookup values for arabic ex: 'La shai' as 'None' in description.
String outParamValue2 = null;
CallableStatement callableStatement2 =
txn2.createCallableStatement("begin P_GET_ATTACH_STATUS(:1, :2); end;",OADBTransaction.DEFAULT);
try {
callableStatement2.setString(1,ssdn);
callableStatement2.registerOutParameter(2, Types.VARCHAR);
callableStatement2.execute();
outParamValue2 = callableStatement2.getString(2);
callableStatement2.close();
} catch (SQLException sqle2) {
throw new OAException("under sql exception"+sqle2,OAException.ERROR);
}
/* For testing the outputs
if (oapagecontext.getParameter("HrSubmit")!= null) {
throw new OAException("ssdn.trim " + ssdn.trim() + " outParamValue " +outParamValue + " outParamValue2 " +outParamValue2 ,OAException.ERROR);
}
//throw new OAException("outParamValue " +outParamValue,OAException.ERROR); }
*/
if ("Y".equals(outParamValue)){
if (oapagecontext.getParameter("HrSubmit")!= null)
{
// OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
// String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
//throw new OAException("ssdn.trim " + ssdn.trim(),OAException.ERROR);
if ("None".equals(outParamValue2 ) )//|| "View".equals(ssdn.trim()) )//|| "?? ???".contains(ssdn.trim()))
{
// throw new OAException("There is no attachment kindly click on add button and browse your attachment",OAException.ERROR);
throw new OAException("PER", "FUJ_ATTACHMENT_MAND", null, OAException.ERROR, null);
// throw new OAException("outParamValue2 " + outParamValue2 + " outParamValue " +outParamValue ,OAException.ERROR);
}
else
{
super.processFormRequest(oapagecontext, oawebbean);
}
}
else
{
//System.out.println("There exists an attachment to the expense claim. The process will now continue");
super.processFormRequest(oapagecontext, oawebbean);
}
}
else
{
super.processFormRequest(oapagecontext, oawebbean);
//throw new OAException("output value is "+outParamValue,OAException.ERROR);
}
}
3.
4 .
Personlization
5. Move the class folder to the java_top and test the same.
6. for any update in the java code, change the name of the file ex: ReviewCOEx to ReviewCOEx2 or 3 and so on, run/make the code run
and then repeat the step 4,5.
7. Procedures
CREATE OR REPLACE PROCEDURE APPS.P_GET_TXN_NAME_YN
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT 'Y'
INTO P_OUTPUT
FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_ATTACH_REQUIRED'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = P_TXN_NAME;
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/
DECLARE
A VARCHAR2(200);
BEGIN
--P_GET_ATTACH_STATUS('?? ???',A);
P_GET_ATTACH_STATUS('None',A);
DBMS_OUTPUT.PUT_LINE(A);
END;
CREATE OR REPLACE PROCEDURE APPS.P_GET_ATTACH_STATUS
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT DESCRIPTION
INTO P_OUTPUT
FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_VALID_COEX'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = UPPER(TRIM(P_TXN_NAME));
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/
No comments:
Post a Comment