Vous êtes sur la page 1sur 5

CREATE TABLE APPS.

DEV_PERSONAL_PAY_METHOD
(
LINE_ID NUMBER,
EFFECTIVE_DATE DATE,
EMPLOYEE_NUMBER VARCHAR2(100 BYTE),
PAY_METHOD_NAME VARCHAR2(240 BYTE),
PRIORITY NUMBER(20),
PAYMENT_PERCENTAGE NUMBER(20),
BANK_NAME VARCHAR2(240 BYTE),
BRANCH_NAME VARCHAR2(240 BYTE),
CITY VARCHAR2(240 BYTE),
ACCOUNT_NAME VARCHAR2(240 BYTE),
ACCOUNT_NUMBER VARCHAR2(240 BYTE),
ACCOUNT_TYPE VARCHAR2(240 BYTE),
PAYMENT_MODE VARCHAR2(240 BYTE),
PROCESS_FLAG CHAR(1 BYTE),
ERROR_DESCRIPTION VARCHAR2(240 BYTE),
EXT_ACCT_ID NUMBER,
OBJ_VER_NUMBER NUMBER,
EFF_START_DATE DATE,
EFF_END_DATE DATE,
COMMENT_ID NUMBER
)

--CREATE OR REPLACE PROCEDURE APPS.DEV_CREATE_ASG_PAYMENT_METHOD


--IS

EXEC DBMS_OUTPUT.ENABLE(10000000);

DECLARE
CURSOR C_EMP_PM
IS

SELECT *
FROM DEV_PERSONAL_PAY_METHOD
WHERE 1 = 1 AND LINE_ID = 51;

LC_C_EMP_PM C_EMP_PM%ROWTYPE;
L_PERSONAL_PAYMENT_METHOD_ID NUMBER;
L_ORG_PAYMENT_METHOD_ID NUMBER;
L_EXTERNAL_ACCOUNT_ID NUMBER;
L_OBJECT_VERSION_NUMBER NUMBER;
L_EFFECTIVE_START_DATE DATE;
L_EFFECTIVE_END_DATE DATE;
L_COMMENT_ID NUMBER;
ERR_DESC VARCHAR2 (240);
LV_TERRITORY_CODE CHAR (2);
LV_PM_FLAG CHAR (1);
L_EMP_ASSG_ID NUMBER (20);
L_PM_ID NUMBER;
AS_EFFECTIVE_START_DATE DATE;
L_PAYMENT_TYPE_ID NUMBER;
P_PERSONAL_PAYMENT_METHOD_ID NUMBER;
P_EXTERNAL_ACCOUNT_ID NUMBER;
P_OBJECT_VERSION_NUMBER NUMBER;
P_EFFECTIVE_START_DATE DATE;
P_EFFECTIVE_END_DATE DATE;
P_COMMENT_ID NUMBER;

BEGIN
LV_TERRITORY_CODE := 'PK';

OPEN C_EMP_PM;

LOOP
FETCH C_EMP_PM
INTO LC_C_EMP_PM;
DBMS_OUTPUT.PUT_LINE ('IN LOOP');
EXIT WHEN C_EMP_PM%NOTFOUND;

BEGIN
-------------------------------------------------------------
--
-- EMPLOYEE ASSIGNMENT ID
-------------------------------------------------------------
--

BEGIN
SELECT PAAF.ASSIGNMENT_ID, PAAF.EFFECTIVE_START_DATE
INTO L_EMP_ASSG_ID, AS_EFFECTIVE_START_DATE
FROM PER_ALL_ASSIGNMENTS_F PAAF
WHERE PAAF.PERSON_ID =
(SELECT DISTINCT PAPF.PERSON_ID
FROM PER_ALL_PEOPLE_F PAPF
WHERE PAPF.EMPLOYEE_NUMBER =

LC_C_EMP_PM.EMPLOYEE_NUMBER)
AND PAAF.PRIMARY_FLAG = 'Y'
AND SYSDATE BETWEEN PAAF.EFFECTIVE_START_DATE AND
PAAF.EFFECTIVE_END_DATE;
EXCEPTION
WHEN OTHERS
THEN
ERR_DESC := 'EMPLOYEE NOT FOUND';
END;

BEGIN
SELECT OPM.ORG_PAYMENT_METHOD_ID, OPM.EXTERNAL_ACCOUNT_ID,
OPM.OBJECT_VERSION_NUMBER
INTO L_ORG_PAYMENT_METHOD_ID, L_EXTERNAL_ACCOUNT_ID,
L_OBJECT_VERSION_NUMBER
FROM PAY_ORG_PAYMENT_METHODS_F OPM
WHERE TRIM (OPM.ORG_PAYMENT_METHOD_NAME) =
TRIM
(LC_C_EMP_PM.PAY_METHOD_NAME)
AND SYSDATE BETWEEN OPM.EFFECTIVE_START_DATE AND
OPM.EFFECTIVE_END_DATE;
EXCEPTION
WHEN OTHERS
THEN
ERR_DESC := ERR_DESC || 'PAYMENT METHOD NOT FOUND OR
ACTIVE.';
END;

HR_PERSONAL_PAY_METHOD_API.CREATE_PERSONAL_PAY_METHOD
(P_VALIDATE => FALSE,
P_EFFECTIVE_DATE =>
LC_C_EMP_PM.EFFECTIVE_DATE ,
P_ASSIGNMENT_ID => L_EMP_ASSG_ID,
P_ORG_PAYMENT_METHOD_ID =>
L_ORG_PAYMENT_METHOD_ID,
P_PERCENTAGE =>
LC_C_EMP_PM.PAYMENT_PERCENTAGE,
P_PRIORITY => LC_C_EMP_PM.PRIORITY,
P_TERRITORY_CODE => 'PK',
P_SEGMENT1 =>
LC_C_EMP_PM.ACCOUNT_NAME,
P_SEGMENT2 =>
LC_C_EMP_PM.ACCOUNT_NUMBER,
P_SEGMENT3 =>
LC_C_EMP_PM.ACCOUNT_TYPE,
P_SEGMENT4 => LC_C_EMP_PM.BANK_NAME,
P_SEGMENT5 =>
LC_C_EMP_PM.BRANCH_NAME,
P_PERSONAL_PAYMENT_METHOD_ID =>
P_PERSONAL_PAYMENT_METHOD_ID ,
P_EXTERNAL_ACCOUNT_ID => P_EXTERNAL_ACCOUNT_ID,
P_OBJECT_VERSION_NUMBER =>
P_OBJECT_VERSION_NUMBER,
P_EFFECTIVE_START_DATE => P_EFFECTIVE_START_DATE,
P_EFFECTIVE_END_DATE => P_EFFECTIVE_END_DATE,
P_COMMENT_ID => P_COMMENT_ID
);

IF P_PERSONAL_PAYMENT_METHOD_ID IS NOT NULL


THEN
LV_PM_FLAG := 'Y';
ERR_DESC := 'NO ERROR';
END IF;

IF LV_PM_FLAG = 'Y'
THEN
UPDATE DEV_PERSONAL_PAY_METHOD
SET ERROR_DESCRIPTION = ERR_DESC,
PROCESS_FLAG = LV_PM_FLAG,
OBJ_VER_NUMBER = L_OBJECT_VERSION_NUMBER,
EFF_START_DATE = L_EFFECTIVE_START_DATE,
EFF_END_DATE = L_EFFECTIVE_END_DATE,
COMMENT_ID = L_COMMENT_ID,
EXT_ACCT_ID = L_EXTERNAL_ACCOUNT_ID
WHERE EMPLOYEE_NUMBER = LC_C_EMP_PM.EMPLOYEE_NUMBER
AND LINE_ID = LC_C_EMP_PM.LINE_ID;
ELSE
ERR_DESC := '1.' || ERR_DESC || SQLERRM;

UPDATE DEV_PERSONAL_PAY_METHOD
SET ERROR_DESCRIPTION = ERR_DESC,
PROCESS_FLAG = 'N'
WHERE EMPLOYEE_NUMBER = LC_C_EMP_PM.EMPLOYEE_NUMBER
AND LINE_ID = LC_C_EMP_PM.LINE_ID;

END IF;
EXCEPTION
WHEN OTHERS
THEN
LV_PM_FLAG := 'N';
ERR_DESC := '2.' || ERR_DESC || SQLERRM;

UPDATE DEV_PERSONAL_PAY_METHOD
SET ERROR_DESCRIPTION = ERR_DESC,
PROCESS_FLAG = LV_PM_FLAG
WHERE EMPLOYEE_NUMBER = LC_C_EMP_PM.EMPLOYEE_NUMBER
AND LINE_ID = LC_C_EMP_PM.LINE_ID;

END;

P_PERSONAL_PAYMENT_METHOD_ID := NULL;
L_ORG_PAYMENT_METHOD_ID := NULL;
L_EXTERNAL_ACCOUNT_ID := NULL;
L_OBJECT_VERSION_NUMBER := NULL;
L_EFFECTIVE_START_DATE := NULL;
L_EFFECTIVE_END_DATE := NULL;
L_COMMENT_ID := NULL;
ERR_DESC := NULL;
LV_TERRITORY_CODE := NULL;
LV_PM_FLAG := NULL;
L_EMP_ASSG_ID := NULL;
L_PM_ID := NULL;
AS_EFFECTIVE_START_DATE := NULL;
L_PAYMENT_TYPE_ID := NULL;
COMMIT;
END LOOP;

CLOSE C_EMP_PM;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE (SUBSTR (SQLERRM, 1, 250));

DBMS_OUTPUT.PUT_LINE (P_PERSONAL_PAYMENT_METHOD_ID||'-'||
L_ORG_PAYMENT_METHOD_ID||'-'||
ERR_DESC||'-'||
L_EMP_ASSG_ID||'-'||
L_PAYMENT_TYPE_ID

);
END;
/