Enable Key Flex Field (GL Code Combination) in Oracle Custom Form level
Requirement: Required to enable Accounting Key Flex Field in From Acct and To Acct fields in below custom form.
Custom Form:
Step 1: Find Accounting Key Flex Field Structure Number which you want to enable in custom form level
Accounting Flex Field Structure Code: MWANI_QATAR_COA
Find Flex Field Structure Number using below sql query
select ID_FLEX_NUM from FND_ID_FLEX_STRUCTURES where id_flex_code='GL#'
and Application_id=101
and ID_FLEX_STRUCTURE_CODE='MWANI_QATAR_COA'; -- for GL
Step 2: Add Following Code in WHEN-NEW-FORM-INSTANCE Form level trigger.
-----From Account-----
FND_KEY_FLEX.DEFINE(
block => 'BUDGET_HDR_BLOCK',
Field => 'FROM_ACCT',
Description => 'FROM_ACCT_DESC',
ID => 'FROM_ACCT_ID',
Appl_short_name => 'SQLGL',
Code => 'GL#',
Num => '50428',
--VRULE => 'GL_GLOBAL\nDETAIL_POSTING_ALLOWED \nE\nAPPL=''SQLGL'';
VRULE=>'\\nSUMMARY_FLAG\\nI\\nAPPL=SQLGL;NAME=GL_NO_PARENT_SEGMENT_ALLOWED\\nN', where_clause => 'summary_flag != ''Y''', QUERY_SECURITY =>'Y'
);
-----To Account-------
FND_KEY_FLEX.DEFINE(
block => 'BUDGET_HDR_BLOCK',
Field => 'TO_ACCT',
Description => 'TO_ACCT_DESC',
ID => 'TO_ACCT_ID',
Appl_short_name => 'SQLGL',
Code => 'GL#',
Num => '50428',
--VRULE => 'GL_GLOBAL\nDETAIL_POSTING_ALLOWED \nE\nAPPL=''SQLGL'';
VRULE=>'\\nSUMMARY_FLAG\\nI\\nAPPL=SQLGL;NAME=GL_NO_PARENT_SEGMENT_ALLOWED\\nN', where_clause => 'summary_flag != ''Y''', QUERY_SECURITY =>'Y'
);
Step 3: Add WHEN-NEW-ITEM-INSTANCE trigger at field level (field : FROM_ACCT & TO_ACCT)
FND_FLEX.EVENT('WHEN-NEW-ITEM-INSTANCE');
Step 4: Add KEY-EDIT trigger at field level (field : FROM_ACCT & TO_ACCT)
FND_FLEX.EVENT('KEY-EDIT');
Step 5: Add WHEN-VALIDATE-ITEM trigger at field level (field : FROM_ACCT & TO_ACCT)
FROM_ACCT Trigger:
FND_FLEX.EVENT('WHEN-VALIDATE-ITEM');
IF :BUDGET_HDR_BLOCK.FROM_ACCT_ID = -1 THEN
FND_MESSAGE.SET_STRING('You Have Selected An Undefined Code Combination !');
FND_MESSAGE.SHOW;
RAISE FORM_TRIGGER_FAILURE;
END IF;
TO_ACCT Trigger:
FND_FLEX.EVENT('WHEN-VALIDATE-ITEM');
IF :BUDGET_HDR_BLOCK.TO_ACCT_ID = -1 THEN
FND_MESSAGE.SET_STRING('You Have Selected An Undefined Code Combination !');
FND_MESSAGE.SHOW;
RAISE FORM_TRIGGER_FAILURE;
END IF;
Step 6: Set Filed property palette (FROM_ACCT & TO_ACCT)
FROM_ACCT
TO_ACCT
Step 7: Compile the Form and upload it on server.
Step 8: Key Flex field enabled on both field.
FROM_ACCT
TO_ACCT