Following is the tested function to create account code combination if account code combination not exits.
CREATE OR REPLACE FUNCTION APPS.MY_CREATE_GL_CODE_COMBINATION
( P_CONCAT_SEGS IN VARCHAR2
) RETURN VARCHAR2
IS
L_KEYVAL_STATUS BOOLEAN;
L_COA_ID NUMBER;
BEGIN
L_COA_ID := 101;
L_KEYVAL_STATUS := FND_FLEX_KEYVAL.VALIDATE_SEGS(
'CREATE_COMBINATION',
'SQLGL',
'GL#',
L_COA_ID,
P_CONCAT_SEGS,
'V',
SYSDATE,
'ALL', NULL, NULL, NULL, NULL,
FALSE,FALSE, NULL, NULL, NULL);
IF L_KEYVAL_STATUS THEN
RETURN 'S';
ELSE
RETURN 'F';
END IF;
EXCEPTION WHEN OTHERS THEN
RETURN 'F';
END ;
------------------------------------------------------------------------------------------------------------
SELECT JG_CREATE_GL_CODE_COMBINATION('10.111.1010101.101.00.00.00') FROM DUAL;
Function will return 'S' for successful completion.
Prerequisites :
Flex Value should already be available for account creation.Function :
CREATE OR REPLACE FUNCTION APPS.MY_CREATE_GL_CODE_COMBINATION
( P_CONCAT_SEGS IN VARCHAR2
) RETURN VARCHAR2
IS
L_KEYVAL_STATUS BOOLEAN;
L_COA_ID NUMBER;
BEGIN
L_COA_ID := 101;
L_KEYVAL_STATUS := FND_FLEX_KEYVAL.VALIDATE_SEGS(
'CREATE_COMBINATION',
'SQLGL',
'GL#',
L_COA_ID,
P_CONCAT_SEGS,
'V',
SYSDATE,
'ALL', NULL, NULL, NULL, NULL,
FALSE,FALSE, NULL, NULL, NULL);
IF L_KEYVAL_STATUS THEN
RETURN 'S';
ELSE
RETURN 'F';
END IF;
EXCEPTION WHEN OTHERS THEN
RETURN 'F';
END ;
------------------------------------------------------------------------------------------------------------
To Execute Function :
SELECT JG_CREATE_GL_CODE_COMBINATION('10.111.1010101.101.00.00.00') FROM DUAL;
Function will return 'S' for successful completion.