Search This Blog

Saturday, March 4, 2017

Custom Approver Group for Approval by the first supervisor, at most.SSHR Oracle Apps R12



Requirement:
Approval by the first supervisor, at most. If the employee applies, it works fine.
But if the supervisor applies for employee, and supervisor has supervisor attached is assignment screen, then it goes to his supervisor, which is not correct in this case.
Then, we need to create custom approver group.




SELECT TYR_GET_SUPERVISOR(:transactionId) FROM DUAL

FUNCTION TYR_GET_SUPERVISOR(p_transaction_id IN NUMBER
)
---Returns the person_id of first supervisor, if supervisor applies for the employeee no need to bring the supervisor's supervisor------
RETURN VARCHAR2
AS
L_person_id NUMBER(10);
L_selected_person_id hr_api_transactions.selected_person_id%TYPE;
L_creator_person_id hr_api_transactions.creator_person_id%TYPE;
l_business_group_id NUMBER;
BEGIN
fnd_profile.get ('PER_BUSINESS_GROUP_ID', l_business_group_id);
BEGIN
SELECT selected_person_id,creator_person_id
INTO L_selected_person_id,L_creator_person_id
FROM hr_api_transactions
WHERE transaction_id = p_transaction_id;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;

BEGIN

SELECT paaf.supervisor_id
INTO l_person_id
FROM per_all_people_f papf,
per_all_assignments_f paaf
WHERE papf.person_id=paaf.person_id
and papf.person_id=l_selected_person_id
AND TRUNC(SYSDATE) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date
AND PRIMARY_FLAG = 'Y';

EXCEPTION
WHEN NO_DATA_FOUND THEN
l_person_id :=null;
END;
IF (L_selected_person_id = L_person_id) OR (l_creator_person_id = l_person_id) THEN
RETURN NULL;
ELSE
RETURN 'PER:'||to_char(L_person_id);
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END TYR_GET_SUPERVISOR;


Saturday, February 25, 2017

Wednesday, February 22, 2017

Oracle WebADI Error BEE Spreadsheet Upload Error - Incorrect Format Of Date Unit Of Measure




Once Template is downloaded, check the date format.
In my scenario the date column was showing default effective date (sysdate) as '23-Feb-17'.

Uploading with the above date format was giving error.
So just use the formula in excel as  =TEXT(D12, "dd-mmm-yyyy")  then it was showing 23-Feb-2017

It worked fine.

Reference:
http://everydaylife.globalpost.com/keep-dates-text-excel-22095.html - section: Converting Existing Dates in Bulk

Monday, February 20, 2017

How to create separate excel files for each sheet in the Excel File



How to create separate excel files for each sheet in the Excel File.

1.       Open the excel file from a folder which has multiple sheets data , press Alt + F11 Open Microsoft Visual Basic
2.       Click Insert>Module and paste the below code


Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
    xWs.Copy
    Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls"
    Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

3.      Press F5 to run the code.

Wednesday, January 18, 2017

Oracle Apps R12 Adding Responsibilities to Users using API

DECLARE
--v_description VARCHAR2 (100) := 'SSHR User XX';
 v_app_short_name VARCHAR2 (100);
 v_resp_key VARCHAR2 (100);
 V_ERROR VARCHAR2(2000);
 V_COUNT NUMBER ;
 V_COUNT_ALL NUMBER := 0;
 CURSOR user_cur IS

 select a.application_short_name, r.responsibility_key
 from fnd_responsibility_vl r, fnd_application_vl a where
 r.application_id =a.application_id
 and R.responsibility_name = 'Employee Self Service xxComp'

 ;

 CURSOR get_emp is

 SELECT EMPLOYEE_ID PERSON_ID, USER_NAME
 FROM
 FND_USER FU
 WHERE
TRUNC(CREATION_DATE) = TRUNC(SYSDATE) --Created Users today
 AND END_DATE IS NULL
 AND EMPLOYEE_ID IS NOT NULL

 ;

user_rec user_cur%ROWTYPE;
get_emp_rec get_emp%ROWTYPE; 
BEGIN
OPEN get_emp;
loop
FETCH get_emp INTO get_emp_rec;
 EXIT WHEN get_emp%NOTFOUND;

 OPEN user_cur;
 LOOP
 FETCH user_cur INTO user_rec;
 EXIT WHEN user_cur%NOTFOUND;

 fnd_user_pkg.addresp(username => UPPER(get_emp_rec.user_name)
 ,resp_app => user_rec.application_short_name
 ,resp_key => user_rec.responsibility_key
 ,security_group => 'STANDARD'
 ,description => NULL
 ,start_date => SYSDATE
 ,end_date => null);
/*
 fnd_user_pkg.DelResp(username => UPPER(get_emp_rec.user_name)
,resp_app =>user_rec.application_short_name
,resp_key => user_rec.responsibility_key
,security_group => 'STANDARD'
);
 */
         
 END LOOP;
 CLOSE user_cur;
commit;


                --commit;
                V_COUNT_ALL := V_COUNT_ALL +1;
 
  END LOOP;
CLOSE get_emp;
DBMS_OUTPUT.PUT_LINE(V_COUNT_ALL);
EXCEPTION WHEN OTHERS THEN
V_ERROR := SQLERRM;

END;
/



Testing:


 Select b.user_name, c.responsibility_name, a.START_DATE, a.END_DATE
from fnd_user_resp_groups_direct a, fnd_user b, fnd_responsibility_tl c
where a.user_id = b.user_id
and a.responsibility_id = c.responsibility_id
and b.user_name LIKE 'TA%'
AND c.responsibility_name in ('Employee Self Service Fujairah')
order by 1

Oracle Apps R12 User Creation API

DECLARE
v_description VARCHAR2 (100) := '';
 v_app_short_name VARCHAR2 (100);
 v_resp_key VARCHAR2 (100);
 V_ERROR VARCHAR2(2000);
 V_COUNT NUMBER ;
 V_COUNT_ALL NUMBER := 0;

 CURSOR get_emp is

SELECT PAPF.PERSON_ID PERSON_ID, 'TA_'||PAPF.EMPLOYEE_NUMBER USER_NAME
FROM
PER_ALL_PEOPLE_F PAPF
,PER_ALL_ASSIGNMENTS_F PAAF
WHERE PAPF.PERSON_ID = PAAF.PERSON_ID
AND TRUNC(SYSDATE) BETWEEN PAPF.EFFECTIVE_START_DATE AND PAPF.EFFECTIVE_END_DATE
AND TRUNC(SYSDATE) BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE
AND PAAF.ORGANIZATION_ID = 221
AND PAAF.PERSON_ID NOT IN
(
SELECT EMPLOYEE_ID FROM FND_USER
WHERE EMPLOYEE_ID IN
(
SELECT  PAAF.PERSON_ID
FROM
 PER_ALL_ASSIGNMENTS_F PAAF
,PER_ALL_PEOPLE_F PAPF
WHERE PAAF.PRIMARY_FLAG = 'Y'
AND PERSON_TYPE_ID = 1120
AND PAPF.PERSON_ID = PAAF.PERSON_ID
AND TRUNC(SYSDATE) BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE
AND TRUNC(SYSDATE) BETWEEN PAPF.EFFECTIVE_START_DATE AND PAPF.EFFECTIVE_END_DATE
--AND CURRENT_EMPLOYEE_FLAG = 'Y'
AND PAAF.ORGANIZATION_ID = 221
)
 AND END_DATE IS  NULL
 )
 ;
--user_rec user_cur%ROWTYPE;
get_emp_rec get_emp%ROWTYPE; 
BEGIN
OPEN get_emp;
loop
 FETCH get_emp INTO get_emp_rec;
 EXIT WHEN get_emp%NOTFOUND;
 fnd_user_pkg.createuser
(x_user_name => get_emp_rec.user_name,
 x_owner => NULL,
 x_unencrypted_password => '12345',
 x_session_number => 0,
 x_start_date => SYSDATE,
 x_end_date => NULL,
 x_last_logon_date => NULL,
 x_description => v_description,
 x_password_date => NULL,
 x_password_accesses_left => NULL,
 x_password_lifespan_accesses => NULL,
 x_password_lifespan_days => NULL,
 x_employee_id => get_emp_rec.PERSON_ID,
 x_email_address => NULL,
 x_fax => NULL,
 x_customer_id => NULL,
 x_supplier_id => NULL,
 x_user_guid => NULL,
 x_change_source => NULL
 );
 COMMIT;

commit;


                --commit;
                V_COUNT_ALL := V_COUNT_ALL +1;
 
  END LOOP;
CLOSE get_emp;
DBMS_OUTPUT.PUT_LINE(V_COUNT_ALL);
EXCEPTION WHEN OTHERS THEN
V_ERROR := SQLERRM;


END;
/