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;
/
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;
/
No comments:
Post a Comment