Sie sind auf Seite 1von 7

1] FND_FLEX_EXT.

GET_COMBINATION_ID:

This API Finds combination_id for given set of key flexfield segment values. Segment values
must be input in segments(1) segments(n_segments) in the order displayed.

It also creates a new combination if it is valid and the flexfield allows dynamic inserts and the
combination does not already exist. It commit the transaction soon after calling this function
since if a combination is created it will prevent other users creating similar combinations on any
flexfield until a commit is issued.

It performs all checks on values including security and cross-validation. Value security rules will
be checked for the current user identified in the FND_GLOBAL package.

Generally pass in SYSDATE for validation date. If validation date is null, this function considers
expired values valid and checks all cross-validation rules even if they are outdated.

This function returns TRUE if combination valid or FALSE and sets error message using
FND_MESSAGE utility on error or if invalid. If this function returns FALSE, use
GET_MESSAGE to get the text of the error message in the language of the database, or
GET_ENCODED_MESSAGE to get the error message in a language-independent encoded
format.

The Combination_id output may be NULL if combination is invalid.

Example: (Tested in R12.1.3)

1 SET serveroutput ON;


2 DECLARE
l_application_short_name VARCHAR2(240);
3 l_key_flex_code VARCHAR2(240);
4 l_structure_num NUMBER;
5 l_validation_date DATE;
6 n_segments NUMBER;
SEGMENTS APPS.FND_FLEX_EXT.SEGMENTARRAY;
7 l_combination_id NUMBER;
8 l_data_set NUMBER;
9 l_return BOOLEAN;
10 l_message VARCHAR2(240);
11 BEGIN
l_application_short_name := 'SQLGL';
12 l_key_flex_code := 'GL#';
13
14 SELECT id_flex_num
15 INTO l_structure_num
16 FROM apps.fnd_id_flex_structures
17 WHERE ID_FLEX_CODE = 'GL#'
AND ID_FLEX_STRUCTURE_CODE=<ACCOUNTING_FLEXFIELD>;
18
19 l_validation_date := SYSDATE;
20 n_segments := 6;
21 segments(1) := '00101';
22 segments(2) := '28506';
segments(3) := '00000';
23 segments(4) := '09063';
24 segments(5) := '00000';
25 segments(6) := '00000';
26 l_data_set := NULL;
27
28 l_return := FND_FLEX_EXT.GET_COMBINATION_ID(
application_short_name => l_application_short_name,
29 key_flex_code => l_key_flex_code,
30 structure_number => l_structure_num,
31 validation_date => l_validation_date,
32 n_segments => n_segments,
segments => segments,
33 combination_id => l_combination_id,
34 data_set => l_data_set
35 );
36 l_message:= FND_FLEX_EXT.GET_MESSAGE;
37
38 IFDBMS_OUTPUT.PUT_LINE('l_Return
l_return THEN
= TRUE');
39 DBMS_OUTPUT.PUT_LINE('COMBINATION_ID = ' || l_combination_id);
40 ELSE
41 DBMS_OUTPUT.PUT_LINE('Error: '||l_message);
42 END IF;
END;
43
44
45
46
47
48
49
50
51

2] FND_FLEX_EXT.get_ccid:

This API gets combination id for the specified key flexfield segments.It is identical to
get_combination_id() except this function takes segment values in a string concatenated by the
segment delimiter for this flexfield, and returns a positive combination id if valid or 0 on error.

3] FND_FLEX_KEYVAL.VALIDATE_SEGS:

These key flexfields server validations API are a low level interface to key flexfields
validation. They are designed to allow access to all the flexfields functionality, and to allow the
user to get only the information they need in return. Because of their generality, these functions
are more difficult to use than those in the FND_FLEX_EXT package. Oracle strongly suggests
using the functions in FND_FLEX_EXT package if at all possible.
This function finds combination from given segment values. Segments are passed in as a
concatenated string in increasing order of segment_number (display order).

Various Operations that can be performed are:

FIND_COMBINATION Combination must already exist.


CREATE_COMBINATION Combination is created if doesnt exist.
CREATE_COMB_NO_AT same as create_combination but does not use an
autonomous transaction.
CHECK_COMBINATION Checks if combination valid, doesnt create.
DEFAULT_COMBINATION Returns minimal default combination.
CHECK_SEGMENTS Validates segments individually.

If validation date is NULL checks all cross-validation rules. It returns TRUE if combination
valid or FALSE and sets error message on server if invalid. Use the default values if you do not
want any special functionality.

Example: (Tested in R12.1.3)

1 SET serveroutput ON;


DECLARE
2 l_segment1 GL_CODE_COMBINATIONS.SEGMENT1%TYPE;
3 l_segment2 GL_CODE_COMBINATIONS.SEGMENT2%TYPE;
4 l_segment3 GL_CODE_COMBINATIONS.SEGMENT3%TYPE;
5 l_segment4 GL_CODE_COMBINATIONS.SEGMENT4%TYPE;
6 l_segment5 GL_CODE_COMBINATIONS.SEGMENT5%TYPE;
l_segment6 GL_CODE_COMBINATIONS.SEGMENT6%TYPE;
7 l_valid_combination BOOLEAN;
8 l_cr_combination BOOLEAN;
9 l_ccid GL_CODE_COMBINATIONS_KFV.code_combination_id%TYPE;
1 l_structure_num FND_ID_FLEX_STRUCTURES.ID_FLEX_NUM%TYPE;
0 l_conc_segs GL_CODE_COMBINATIONS_KFV.CONCATENATED_SEGMENTS%TYPE;
p_error_msg1 VARCHAR2(240);
1 p_error_msg2 VARCHAR2(240);
1 BEGIN
1 l_segment1 := '00101';
2 l_segment2 := '28506';
l_segment3 := '00000';
1 l_segment4 := '14302';
3 l_segment5 := '00455';
1 l_segment6 := '00000';
4 l_conc_segs :=
1 l_segment1||'.'||l_segment2||'.'||l_segment3||'.'||l_segment4||'.'||l_segmen
t5||'.'||l_segment6 ;
5 BEGIN
1 SELECT id_flex_num
6 INTO l_structure_num
1 FROM apps.fnd_id_flex_structures
WHERE id_flex_code = 'GL#'
7 AND id_flex_structure_code='EPC_GL_ACCOUNTING_FLEXFIELD';
1 EXCEPTION
8 WHEN OTHERS THEN
1 l_structure_num:=NULL;
9 END;
---------------Check if CCID exits with the above Concatenated Segments---
2 ------------
0 BEGIN
2 SELECT code_combination_id
1 INTO l_ccid
FROM apps.gl_code_combinations_kfv
2 WHERE concatenated_segments = l_conc_segs;
2 EXCEPTION
2 WHEN OTHERS THEN
3 l_ccid:=NULL;
2 END;
IF l_ccid IS NOT NULL THEN
4 ------------------------The CCID is Available----------------------
2 DBMS_OUTPUT.PUT_LINE('COMBINATION_ID= ' ||l_ccid);
5 ELSE
2 DBMS_OUTPUT.PUT_LINE('This is a New Combination. Validation Starts....');
------------Validate the New Combination--------------------------
6 l_valid_combination := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS
2 (
7 operation => 'CHECK_COMBINATION',
2 appl_short_name => 'SQLGL',
8 key_flex_code => 'GL#',
structure_number => L_STRUCTURE_NUM,
2 concat_segments => L_CONC_SEGS
9 );
3 p_error_msg1 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
0
3 IF l_valid_combination then
1
3 DBMS_OUTPUT.PUT_LINE('Validation Successful! Creating the
Combination...');
2 -------------------Create the New CCID--------------------------
3
3 L_CR_COMBINATION := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS
3 (
4 operation => 'CREATE_COMBINATION',
appl_short_name => 'SQLGL',
3 key_flex_code => 'GL#',
5 structure_number => L_STRUCTURE_NUM,
3 concat_segments => L_CONC_SEGS );
6 p_error_msg2 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
3
7 IF l_cr_combination THEN
-------------------Fetch the New CCID--------------------------
3 SELECT code_combination_id
8 INTO l_ccid
3 FROM apps.gl_code_combinations_kfv
9 WHERE concatenated_segments = l_conc_segs;
DBMS_OUTPUT.PUT_LINE('NEW COMBINATION_ID = ' || l_ccid);
4 ELSE
0 -------------Error in creating a combination-----------------
4 DBMS_OUTPUT.PUT_LINE('Error in creating the combination:
1 '||p_error_msg2);
END IF;
4 ELSE
2 --------The segments in the account string are not defined in gl value
set----------
4 DBMS_OUTPUT.PUT_LINE('Error in validating the combination:
3 '||p_error_msg1);
4 END IF;
4 END IF;
EXCEPTION
4 WHEN OTHERS THEN
5 DBMS_OUTPUT.PUT_LINE(SQLCODE||' '||SQLERRM);
4 END;
6
4
7
4
8
4
9
5
0
5
1
5
2
5
3
5
4
5
5
5
6
5
7
5
8
5
9
6
0
6
1
6
2
6
3
6
4
6
5
6
6
6
7
6
8
6
9
7
0
7
1
7
2
7
3
7
4
7
5
7
6
7
7
7
8
7
9
8
0
8
1
8
2
8
3
8
4
8
5
8
6
8
7
8
8
8
9
9
0
9
1
9
2
9
3

Das könnte Ihnen auch gefallen