August 2, 2010

Setting who columns on validation

Set Who columns in pre-insert:
BEGIN
DATA BLOCK NAME;
FND_STANDARD.SET_WHO;
PACKAGE.VALIDATE_APPROVAL;(Define this procedure in program units)
END;
Set Who columns in pre-update:

begin

XX_VALIDATE1;--procedure 1
XX_VALIDATE2;--procedure 2
fnd_standard.set_who;
PACKAGE.VALIDATE_APPROVAL;(Define this procedure in program units)
end;
Set triggers at when-new-record-instance-level
DECLARE
v_count number;

v_count2 number;

BEGIN

SELECT count(*) into v_count

FROM fnd_lookup_values
WHERE lookup_type = ‘Receipt Number’(count records ad new in db)

and sysdate between start_date_active and nvl(end_date_active,sysdate)

and lookup_code=fnd_global.user_id;
IF v_count = 0 then
--set datablock and procedure to validate SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_FALSE);
END IF;
IF v_count = 1 THEN

--SET_ITEM_PROPERTY('XXGOD_QUOTATION_HDR1.SALES_ORDER',ENABLED,PROPERTY_FALSE);

IF :XXGOD_JOB_CARD.APPROVALS ='Submitted' THEN

SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_TRUE);

ELSE

SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_FALSE);
END IF;
END IF;
END;
Validating Procedure and Package:


PACKAGE XX_VALIDATE IS
PROCEDURE VALIDATE_APPROVAL;
PROCEDURE VALIDATE_APPROVAL1;
PROCEDURE XVALID_DESC_PRO(EVENT IN VARCHAR2);
END;




PACKAGE BODY XX_VALIDATE IS
PROCEDURE VALIDATE_APPROVAL IS

BEGIN

IF :DATA_BLOCK_NAME.APPROVALS IS NULL THEN

FND_MESSAGE.SET_STRING('Status needs to be selected');

FND_MESSAGE.SHOW;

RAISE FORM_TRIGGER_FAILURE;

END IF;

IF :DATA_BLOCK_NAME.APPROVALS!='New'THEN

FND_MESSAGE.SET_STRING('This is a new Job card,select the status as New');
FND_MESSAGE.SHOW;

RAISE FORM_TRIGGER_FAILURE;

ELSE

XX_VALIDATE_1(CALLING ANOTHER PROCEDURE);
END IF;

EXCEPTION

WHEN OTHERS THEN
FND_MESSAGE.ERROR;

RAISE FORM_TRIGGER_FAILURE;
END;
---------------------------------------------------------------------------------------------

PROCEDURE VALIDATE_APPROVAL1 IS
CURSOR C1 IS SELECT APPROVALS FROM table_name WHERE JOB_ID=:data_bolck.item;
v1 VARCHAR2(20);

BEGIN

OPEN C1;

FETCH C1 INTO v1;

IF V1!=:DATA_BLOCK_NAME.APPROVALS THEN

IF V1='New' AND :DATA_BLOCK_NAME.APPROVALS!='Submitted' THEN
FND_MESSAGE.SET_STRING('This is a new Job card,needs to be Submitted');

FND_MESSAGE.SHOW;

RAISE FORM_TRIGGER_FAILURE;

END IF;
IF V1='Submitted' and :DATA_BLOCK_NAME.APPROVALS not in('Approved','Rejected') THEN
FND_MESSAGE.SET_STRING('Submitted Job card,needs to be Approved or Rejected');
FND_MESSAGE.SHOW;
raise form_trigger_failure;

END IF;


IF V1='Rejected' and :DATA_BLOCK_NAME.APPROVALS not in( 'Rejected','Submitted','Closed') THEN
FND_MESSAGE.SET_STRING('Rejected Quotation can only be Submitted or Closed');
FND_MESSAGE.SHOW;
raise form_trigger_failure;
END IF;
if v1='Approved' and :DATA_BLOCK_NAME.approvals not in('Inactive','Active') then
fnd_message.set_string('Approved Job can be Active or Inactive');
fnd_message.show;
raise form_trigger_failure;

end if;


IF v1='Inactive' and :DATA_BLOCK_NAME.approvals!='Active' then
FND_MESSAGE.SET_STRING('Select the status as Active');
FND_MESSAGE.SHOW;
raise form_trigger_failure;

END IF;


IF v1='Active' and : DATA_BLOCK_NAME .approvals!='Closed' then
FND_MESSAGE.SET_STRING('Active Job card has to be Closed');
FND_MESSAGE.SHOW;
raise form_trigger_failure;
END IF;
if v1='Closed' and : DATA_BLOCK_NAME.approvals!='Closed' then
FND_MESSAGE.SET_STRING('Closed Job card can not be modified');
FND_MESSAGE.SHOW;
raise form_trigger_failure;
end if;
END IF;
CLOSE C1;
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.ERROR;
RAISE FORM_TRIGGER_FAILURE;
END;


PROCEDURE XGOD_DESC_PRO(EVENT IN VARCHAR2)
IS
BEGIN
IF EVENT='PRE-FORM' THEN

FND_DESCR_FLEX.DEFINE(BLOCK => 'XXGOD_JOB_CARD',FIELD => 'DFF1',
APPL_SHORT_NAME => 'PO',DESC_FLEX_NAME => 'JobCardDFV');
END IF;
IF EVENT='WHEN-NEW-FORM-INSTANCE' THEN

FND_DESCR_FLEX.DEFINE(BLOCK => 'XXGOD_JOB_CARD',FIELD => 'DFF1',APPL_SHORT_NAME => 'PO',DESC_FLEX_NAME => 'JobCardDFV');

FND_DESCR_FLEX.DEFINE(BLOCK => 'XXGOD_JOB_CARD',FIELD => 'DFF',
APPL_SHORT_NAME => 'PO',DESC_FLEX_NAME => 'JobCardDFF1');

END IF;

EXCEPTION

WHEN OTHERS THEN

RAISE FORM_TRIGGER_FAILURE;
END;
END;


No comments:

Post a Comment

Thanks for your comments submitted.,will review and Post soon! by admin.

COALESCE-SQL

Coalesce- return the null values from the expression. It works similar to a case statement where if expression 1 is false then goes to expr...