below the script which utilize API to generate CCID's from concatenated segment
values
cc_valid :=
fnd_flex_keyval.validate_segs ('CREATE_COMBINATION',
'SQLGL',
'GL#',
101, -- accounting structure id
sg_compound, -- concatenated segment values
like '101.00000.203.11'
'V',
TO_CHAR (SYSDATE),
'ALL',
NULL,
NULL,
NULL,
NULL,
FALSE,
FALSE,
fnd_global.resp_appl_id (),
fnd_global.resp_id (),
fnd_global.user_id ()
);
IF (cc_valid = FALSE)
THEN
errmsg := 'Error' || fnd_flex_keyval.error_message;
RESULT := errmsg;
ELSE
RESULT := fnd_flex_keyval.combination_id;
END IF;
fnd_file.put_line (fnd_file.log,
'Result: ' || TO_CHAR (RESULT)
);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Think you can look at using the below API which would check for the existence of
the combination. if exists it would return the Code combination id else it would
create the code combination id. This would help you to avoid any duplicate check
etc.
SET SERVEROUTPUT ON
DECLARE
v_combination_id NUMBER;
vSegmentArray Fnd_Flex_Ext.segmentarray;
BEGIN
-- Assuming for a 6 segment COA
vSegmentArray(1) := < Value for Segment1>;
vSegmentArray(2) := < Value for Segment2>;
vSegmentArray(3) := < Value for Segment3>;
vSegmentArray(4) := < Value for Segment4>;
vSegmentArray(5) := < Value for Segment5>;
vSegmentArray(6) := < Value for Segment6>;
Fnd_Flex_Ext.get_combination_id
(application_short_name => 'SQLGL'
key_flex_code I => ''GL#'' ,
structure_number => <Your Chart of Account id>,
validation_date => SYSDATE,
n_segments => < number of segment used in your
COA>, -- should be 6 as we have assigned 6 segment
segments => vSegmentArray ,
combination_id => v_combination_id ,
-- out variable providing Code combination id, if success would be positive value
data_set => -1
);
DBMS_OUTPUT.PUT_LINE( ' Combination id ' || v_combination_id );
END;
Hope the above helps.