DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ID_FLEX_INFO

Source


1 PACKAGE BODY hr_id_flex_info
2 /* $Header: hrkflinf.pkb 120.0 2005/05/31 01:05:51 appldev noship $ */
3 AS
4   --
5   -- Global variables
6   --
7   g_application_short_name1      fnd_application.application_short_name%TYPE;
8   g_id_flex_code1                fnd_id_flexs.id_flex_code%TYPE;
9   g_set_defining_column_name     fnd_id_flexs.set_defining_column_name%TYPE;
10   g_application_id2              fnd_id_flexs.application_id%TYPE;
11   g_id_flex_code2                fnd_id_flexs.id_flex_code%TYPE;
12   g_segments                     t_segments := t_segments();
13 --
14 -- -----------------------------------------------------------------------------
15 -- |--------------------------< defining_column_name >-------------------------|
16 -- -----------------------------------------------------------------------------
17 FUNCTION defining_column_name
18   (p_application_short_name       IN     fnd_application.application_short_name%TYPE
19   ,p_id_flex_code                 IN     fnd_id_flexs.id_flex_code%TYPE
20   )
21 RETURN fnd_id_flexs.set_defining_column_name%TYPE
22 IS
23   --
24   -- Local cursors
25   --
26   CURSOR csr_id_flexs
27     (p_application_short_name       IN     fnd_application.application_short_name%TYPE
28     ,p_id_flex_code                 IN     fnd_id_flexs.id_flex_code%TYPE
29     )
30   IS
31     SELECT kfl.set_defining_column_name
32       FROM fnd_id_flexs kfl
33           ,fnd_application app
34      WHERE kfl.application_id = app.application_id
35        AND app.application_short_name = p_application_short_name
36        AND kfl.id_flex_code = p_id_flex_code;
37 --
38 BEGIN
39   --
40   IF    (p_application_short_name = g_application_short_name1)
41     AND (p_id_flex_code = g_id_flex_code1)
42   THEN
43     --
44     -- The last defining column name cached was for this key flexfield, so no
45     -- need to get it from the database again
46     --
47     NULL;
48   --
49   ELSE
50     --
51     -- The last defining column name cached was NOT for this key flexfield, so
52     -- need to get it from the database and cache it
53     --
54     OPEN csr_id_flexs
55       (p_application_short_name       => p_application_short_name
56       ,p_id_flex_code                 => p_id_flex_code
57       );
58     FETCH csr_id_flexs INTO g_set_defining_column_name;
59     CLOSE csr_id_flexs;
60     --
61     g_application_short_name1 := p_application_short_name;
62     g_id_flex_code1 := p_id_flex_code;
63   --
64   END IF;
65   --
66   RETURN(g_set_defining_column_name);
67 --
68 END defining_column_name;
69 --
70 -- -----------------------------------------------------------------------------
71 -- |--------------------------------< segments >-------------------------------|
72 -- -----------------------------------------------------------------------------
73 FUNCTION segments
74   (p_application_id               IN     fnd_id_flexs.application_id%TYPE
75   ,p_id_flex_code                 IN     fnd_id_flexs.id_flex_code%TYPE
76   )
77 RETURN t_segments
78 IS
79   --
80   -- Local cursors
81   --
82   CURSOR csr_columns
83     (p_application_id               IN     fnd_id_flexs.application_id%TYPE
84     ,p_id_flex_code                 IN     fnd_id_flexs.id_flex_code%TYPE
85     )
86   IS
87     SELECT col.column_name
88       FROM fnd_columns col
89           ,fnd_tables tbl
90           ,fnd_id_flexs flx
91      WHERE col.flexfield_usage_code = 'K'
92        AND col.table_id = tbl.table_id
93        AND col.application_id = tbl.application_id
94        AND tbl.application_id = flx.table_application_id
95        AND tbl.table_name = flx.application_table_name
96        AND flx.application_id = p_application_id
97        AND flx.id_flex_code = p_id_flex_code;
98   --
99   -- Local variables
100   --
101   l_segments                     t_segments := t_segments();
102 --
103 BEGIN
104   --
105   IF    (p_application_id = g_application_id2)
106     AND (p_id_flex_code = g_id_flex_code2)
107   THEN
108     --
109     l_segments := g_segments;
110   --
111   ELSE
112     --
113     FOR l_column in csr_columns
114       (p_application_id               => p_application_id
115       ,p_id_flex_code                 => p_id_flex_code
116       )
117     LOOP
118       --
119       -- Add segment to table
120       --
121       l_segments.EXTEND;
122       l_segments(l_segments.LAST).column_name := l_column.column_name;
123     --
124     END LOOP;
125     --
126     g_application_id2 := p_application_id;
127     g_id_flex_code2 := p_id_flex_code;
128     g_segments := l_segments;
129   --
130   END IF;
131   --
132   RETURN(l_segments);
133 --
134 END segments;
135 --
136 END hr_id_flex_info;