CREATE OR REPLACE PROCEDURE XX_GL_EXTRACT_ENABLE_ACCOUNT AS
v_set_id number;
v_position_account_type number:=3;
v_acc_flex_value_set varchar2(240):='XXX_COA_ACCOUNT'; /**Pass the COA name/
flex_value_exeception EXCEPTION;
v_upd_count number:=0;
BEGIN
SELECT flex_value_set_id
INTO v_set_id
FROM fnd_flex_value_sets
WHERE flex_value_set_name = v_acc_flex_value_set;
IF v_set_id IS NULL
THEN
RAISE flex_value_exeception;
END IF;
IF v_set_id IS NOT NULL
THEN
SELECT COUNT (v.flex_value)
INTO v_upd_count
FROM fnd_flex_hierarchies_tl h,
fnd_flex_values v,
fnd_flex_values_tl vt,
gl_lookups l1,
gl_lookups l2,
gl_lookups l5
WHERE h.flex_value_set_id(+) = v_set_id
AND h.hierarchy_id(+) = v.structured_hierarchy_level
AND h.language(+) = USERENV ('LANG')
AND v.flex_value_set_id = v_set_id
AND vt.flex_value_id = v.flex_value_id + 0
AND vt.language = USERENV ('LANG')
AND v.enabled_flag = l1.lookup_code
AND l1.lookup_type = 'YES/NO'
AND v.summary_flag = l2.lookup_code
AND l2.lookup_type = 'YES/NO'
AND NVL (
SUBSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
INSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
fnd_global.newline,
1,
v_position_account_type
)
+ 1,
1
),
'A'
) = l5.lookup_code(+)
AND l5.lookup_type(+) = 'ACCOUNT TYPE'
AND l5.lookup_code IN ('A', 'L', 'O');
IF v_upd_count > 1
THEN
UPDATE fnd_flex_values
SET attribute1 = 'Y', value_category = 'XXX_COA_ACCOUNT'
WHERE flex_value IN
(SELECT v.flex_value
FROM fnd_flex_hierarchies_tl h,
fnd_flex_values v,
fnd_flex_values_tl vt,
gl_lookups l1,
gl_lookups l2,
gl_lookups l5
WHERE h.flex_value_set_id(+) = v_set_id
AND h.hierarchy_id(+) =
v.structured_hierarchy_level
AND h.language(+) = USERENV ('LANG')
AND v.flex_value_set_id = v_set_id
AND vt.flex_value_id = v.flex_value_id + 0
AND vt.language = USERENV ('LANG')
AND v.enabled_flag = l1.lookup_code
AND l1.lookup_type = 'YES/NO'
AND v.summary_flag = l2.lookup_code
AND l2.lookup_type = 'YES/NO'
AND NVL (
SUBSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
INSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
fnd_global.newline,
1,
v_position_account_type
)
+ 1,
1
),
'A'
) = l5.lookup_code(+)
AND l5.lookup_type(+) = 'ACCOUNT TYPE'
AND l5.lookup_code IN ('A', 'L', 'O'));
END IF;
Commit;
END IF;
DBMS_OUTPUT.put_line (
'Number of Records updated :' || TO_CHAR (v_upd_count)
);
EXCEPTION
WHEN flex_value_exeception
THEN
DBMS_OUTPUT.put_line('Unable to deriver flex value set id for the value set XXX_COA_ACCOUNT');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in updating DFF values for Natural account'
);
END XX_GL_EXTRACT_ENABLE_ACCOUNT;
/
v_set_id number;
v_position_account_type number:=3;
v_acc_flex_value_set varchar2(240):='XXX_COA_ACCOUNT'; /**Pass the COA name/
flex_value_exeception EXCEPTION;
v_upd_count number:=0;
BEGIN
SELECT flex_value_set_id
INTO v_set_id
FROM fnd_flex_value_sets
WHERE flex_value_set_name = v_acc_flex_value_set;
IF v_set_id IS NULL
THEN
RAISE flex_value_exeception;
END IF;
IF v_set_id IS NOT NULL
THEN
SELECT COUNT (v.flex_value)
INTO v_upd_count
FROM fnd_flex_hierarchies_tl h,
fnd_flex_values v,
fnd_flex_values_tl vt,
gl_lookups l1,
gl_lookups l2,
gl_lookups l5
WHERE h.flex_value_set_id(+) = v_set_id
AND h.hierarchy_id(+) = v.structured_hierarchy_level
AND h.language(+) = USERENV ('LANG')
AND v.flex_value_set_id = v_set_id
AND vt.flex_value_id = v.flex_value_id + 0
AND vt.language = USERENV ('LANG')
AND v.enabled_flag = l1.lookup_code
AND l1.lookup_type = 'YES/NO'
AND v.summary_flag = l2.lookup_code
AND l2.lookup_type = 'YES/NO'
AND NVL (
SUBSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
INSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
fnd_global.newline,
1,
v_position_account_type
)
+ 1,
1
),
'A'
) = l5.lookup_code(+)
AND l5.lookup_type(+) = 'ACCOUNT TYPE'
AND l5.lookup_code IN ('A', 'L', 'O');
IF v_upd_count > 1
THEN
UPDATE fnd_flex_values
SET attribute1 = 'Y', value_category = 'XXX_COA_ACCOUNT'
WHERE flex_value IN
(SELECT v.flex_value
FROM fnd_flex_hierarchies_tl h,
fnd_flex_values v,
fnd_flex_values_tl vt,
gl_lookups l1,
gl_lookups l2,
gl_lookups l5
WHERE h.flex_value_set_id(+) = v_set_id
AND h.hierarchy_id(+) =
v.structured_hierarchy_level
AND h.language(+) = USERENV ('LANG')
AND v.flex_value_set_id = v_set_id
AND vt.flex_value_id = v.flex_value_id + 0
AND vt.language = USERENV ('LANG')
AND v.enabled_flag = l1.lookup_code
AND l1.lookup_type = 'YES/NO'
AND v.summary_flag = l2.lookup_code
AND l2.lookup_type = 'YES/NO'
AND NVL (
SUBSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
INSTRB (
fnd_global.newline
|| v.compiled_value_attributes
|| fnd_global.newline,
fnd_global.newline,
1,
v_position_account_type
)
+ 1,
1
),
'A'
) = l5.lookup_code(+)
AND l5.lookup_type(+) = 'ACCOUNT TYPE'
AND l5.lookup_code IN ('A', 'L', 'O'));
END IF;
Commit;
END IF;
DBMS_OUTPUT.put_line (
'Number of Records updated :' || TO_CHAR (v_upd_count)
);
EXCEPTION
WHEN flex_value_exeception
THEN
DBMS_OUTPUT.put_line('Unable to deriver flex value set id for the value set XXX_COA_ACCOUNT');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in updating DFF values for Natural account'
);
END XX_GL_EXTRACT_ENABLE_ACCOUNT;
/