CREATE OR REPLACE PROCEDURE HRIS_TRAVEL_CANCELLATION(
    P_TRAVEL_ID HRIS_EMPLOYEE_TRAVEL_REQUEST.TRAVEL_ID%TYPE )
    AS
    V_VOUCHER_NO   VARCHAR2(255 BYTE);
    TABLE_COUNT NUMBER(1,0);
begin
SELECT 
voucher_no into V_VOUCHER_NO 
FROM HRIS_EMPLOYEE_TRAVEL_REQUEST
WHERE STATUS='C' and travel_id=P_TRAVEL_ID;

IF(V_VOUCHER_NO IS NOT NULL)
THEN 
-- TO SET DELETED FLAG IN MASTER_TRANSACTION
select count(*) INTO TABLE_COUNT from user_tables where table_name = upper('MASTER_TRANSACTION');
IF(TABLE_COUNT>0)THEN
UPDATE MASTER_TRANSACTION  SET DELETED_FLAG='Y',DELETED_BY='HRIS',DELETED_DATE=TRUNC(SYSDATE) WHERE  VOUCHER_NO=V_VOUCHER_NO;
END IF;

-- TO SET DELETED FLAG IN FA_DOUBLE_VOUCHER
TABLE_COUNT:=0;
select count(*) INTO TABLE_COUNT from user_tables where table_name = upper('FA_DOUBLE_VOUCHER');
IF(TABLE_COUNT>0)THEN
UPDATE FA_DOUBLE_VOUCHER  SET DELETED_FLAG='Y' WHERE  VOUCHER_NO=V_VOUCHER_NO;
END IF;

-- TO SET DELETED FLAG IN FA_VOUCHER_SUB_DETAIL
TABLE_COUNT:=0;
select count(*) INTO TABLE_COUNT from user_tables where table_name = upper('FA_VOUCHER_SUB_DETAIL');
IF(TABLE_COUNT>0)THEN
UPDATE FA_VOUCHER_SUB_DETAIL  SET DELETED_FLAG='Y' WHERE  VOUCHER_NO=V_VOUCHER_NO;
END IF;

-- TO SET DELETED FLAG IN FA_SUB_LEDGER
TABLE_COUNT:=0;
select count(*) INTO TABLE_COUNT from user_tables where table_name = upper('FA_SUB_LEDGER');
IF(TABLE_COUNT>0)THEN
UPDATE FA_SUB_LEDGER  SET DELETED_FLAG='Y' WHERE  VOUCHER_NO=V_VOUCHER_NO;
END IF;

-- TO SET DELETED FLAG IN FA_GENERAL_LEDGER
TABLE_COUNT:=0;
select count(*) INTO TABLE_COUNT from user_tables where table_name = upper('FA_GENERAL_LEDGER');
IF(TABLE_COUNT>0)THEN
UPDATE FA_GENERAL_LEDGER  SET DELETED_FLAG='Y' WHERE  VOUCHER_NO=V_VOUCHER_NO;
END IF;

END IF;




end;



