DBA Data[Home] [Help]

PACKAGE BODY: APPS.QP_QP_FORM_SEG

Source


1 PACKAGE BODY QP_QP_Form_Seg AS
2 /* $Header: QPXFSEGB.pls 120.2 2005/08/03 07:37:08 srashmi noship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'QP_QP_Form_Seg';
7 
8 --  Global variables holding cached record.
9 
10 g_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
11 g_db_SEG_rec                  QP_Attributes_PUB.Seg_Rec_Type;
12 
13 --  Forward declaration of procedures maintaining entity record cache.
14 
15 PROCEDURE Write_SEG
16 (   p_SEG_rec                       IN  QP_Attributes_PUB.Seg_Rec_Type
17 ,   p_db_record                     IN  BOOLEAN := FALSE
18 );
19 
20 FUNCTION Get_SEG
21 (   p_db_record                     IN  BOOLEAN := FALSE
22 ,   p_segment_id                    IN  NUMBER
23 )
24 RETURN QP_Attributes_PUB.Seg_Rec_Type;
25 
26 PROCEDURE Clear_SEG;
27 
28 --  Global variable holding performed operations.
29 
30 g_opr__tbl                    QP_Attributes_PUB.Seg_Tbl_Type;
31 
32 --  Procedure : Default_Attributes
33 --
34 
35 PROCEDURE Default_Attributes
36 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
37 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
38 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
39 ,   x_attribute1                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
40 ,   x_attribute10                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
41 ,   x_attribute11                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
42 ,   x_attribute12                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
43 ,   x_attribute13                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
44 ,   x_attribute14                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
45 ,   x_attribute15                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
46 ,   x_attribute2                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
47 ,   x_attribute3                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
48 ,   x_attribute4                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
49 ,   x_attribute5                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
50 ,   x_attribute6                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
51 ,   x_attribute7                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
52 ,   x_attribute8                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
53 ,   x_attribute9                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
54 ,   x_availability_in_basic         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
55 ,   x_context                       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
56 ,   x_prc_context_id                OUT NOCOPY /* file.sql.39 change */ NUMBER
57 ,   x_seeded_flag                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
58 ,   x_seeded_format_type            OUT NOCOPY /* file.sql.39 change */ VARCHAR2
59 ,   x_seeded_precedence             OUT NOCOPY /* file.sql.39 change */ NUMBER
60 ,   x_seeded_segment_name           OUT NOCOPY /* file.sql.39 change */ VARCHAR2
61 ,   x_seeded_description	    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
62 ,   x_seeded_valueset_id            OUT NOCOPY /* file.sql.39 change */ NUMBER
63 ,   x_segment_code               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
64 ,   x_segment_id                    OUT NOCOPY /* file.sql.39 change */ NUMBER
65 ,   x_application_id                OUT NOCOPY /* file.sql.39 change */ NUMBER
66 ,   x_segment_mapping_column        OUT NOCOPY /* file.sql.39 change */ VARCHAR2
67 ,   x_user_format_type              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
68 ,   x_user_precedence               OUT NOCOPY /* file.sql.39 change */ NUMBER
69 ,   x_user_segment_name             OUT NOCOPY /* file.sql.39 change */ VARCHAR2
70 ,   x_user_description		    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
71 ,   x_user_valueset_id              OUT NOCOPY /* file.sql.39 change */ NUMBER
72 ,   x_prc_context                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
73 ,   x_seeded                        OUT NOCOPY /* file.sql.39 change */ VARCHAR2
74 ,   x_seeded_valueset               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
75 ,   x_segment                       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
76 ,   x_user_valueset                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
77 ,   x_required_flag		    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
78 ,   x_party_hierarchy_enabled_flag       OUT NOCOPY VARCHAR2  -- Added for TCA
79 )
80 IS
81 l_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
82 l_SEG_val_rec                 QP_Attributes_PUB.Seg_Val_Rec_Type;
83 l_SEG_tbl                     QP_Attributes_PUB.Seg_Tbl_Type;
84 l_control_rec                 QP_GLOBALS.Control_Rec_Type;
85 l_return_status               VARCHAR2(1);
86 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
87 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
88 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
89 BEGIN
90 
91     --  Set control flags.
92 
93     l_control_rec.controlled_operation := TRUE;
94     l_control_rec.default_attributes   := TRUE;
95 
96     l_control_rec.change_attributes    := FALSE;
97     l_control_rec.validate_entity      := FALSE;
98     l_control_rec.write_to_DB          := FALSE;
99     l_control_rec.process              := FALSE;
100 
101     --  Instruct API to retain its caches
102 
103     l_control_rec.clear_api_cache      := FALSE;
104     l_control_rec.clear_api_requests   := FALSE;
105 
106     --  Load IN parameters if any exist
107 
108 
109     --  Defaulting of flex values is currently done by the form.
110     --  Set flex attributes to NULL in order to avoid defaulting them.
111 
112     l_SEG_rec.attribute1                          := NULL;
113     l_SEG_rec.attribute10                         := NULL;
114     l_SEG_rec.attribute11                         := NULL;
115     l_SEG_rec.attribute12                         := NULL;
116     l_SEG_rec.attribute13                         := NULL;
117     l_SEG_rec.attribute14                         := NULL;
118     l_SEG_rec.attribute15                         := NULL;
119     l_SEG_rec.attribute2                          := NULL;
120     l_SEG_rec.attribute3                          := NULL;
121     l_SEG_rec.attribute4                          := NULL;
122     l_SEG_rec.attribute5                          := NULL;
123     l_SEG_rec.attribute6                          := NULL;
124     l_SEG_rec.attribute7                          := NULL;
125     l_SEG_rec.attribute8                          := NULL;
126     l_SEG_rec.attribute9                          := NULL;
127     l_SEG_rec.context                             := NULL;
128 
129     --  Set Operation to Create
130 
131     l_SEG_rec.operation := QP_GLOBALS.G_OPR_CREATE;
132 
133     --  Populate SEG table
134 
135     l_SEG_tbl(1) := l_SEG_rec;
136 
137     --  Call QP_Attributes_PVT.Process_Attributes
138 
139     QP_Attributes_PVT.Process_Attributes
140     (   p_api_version_number          => 1.0
141     ,   p_init_msg_list               => FND_API.G_TRUE
142     ,   x_return_status               => l_return_status
143     ,   x_msg_count                   => x_msg_count
144     ,   x_msg_data                    => x_msg_data
145     ,   p_control_rec                 => l_control_rec
146     ,   p_SEG_tbl                     => l_SEG_tbl
147     ,   x_CON_rec                     => l_x_CON_rec
148     ,   x_SEG_tbl                     => l_x_SEG_tbl
149     );
150 
151     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
152         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
153     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
154         RAISE FND_API.G_EXC_ERROR;
155     END IF;
156 
157 
158     --  Unload out tbl
159 
160     l_x_SEG_rec := l_x_SEG_tbl(1);
161 
162     --  Load OUT parameters.
163 
164     x_attribute1                   := l_x_SEG_rec.attribute1;
165     x_attribute10                  := l_x_SEG_rec.attribute10;
166     x_attribute11                  := l_x_SEG_rec.attribute11;
167     x_attribute12                  := l_x_SEG_rec.attribute12;
168     x_attribute13                  := l_x_SEG_rec.attribute13;
169     x_attribute14                  := l_x_SEG_rec.attribute14;
170     x_attribute15                  := l_x_SEG_rec.attribute15;
171     x_attribute2                   := l_x_SEG_rec.attribute2;
172     x_attribute3                   := l_x_SEG_rec.attribute3;
173     x_attribute4                   := l_x_SEG_rec.attribute4;
174     x_attribute5                   := l_x_SEG_rec.attribute5;
175     x_attribute6                   := l_x_SEG_rec.attribute6;
176     x_attribute7                   := l_x_SEG_rec.attribute7;
177     x_attribute8                   := l_x_SEG_rec.attribute8;
178     x_attribute9                   := l_x_SEG_rec.attribute9;
179     x_availability_in_basic        := l_x_SEG_rec.availability_in_basic;
180     x_context                      := l_x_SEG_rec.context;
181     x_prc_context_id               := l_x_SEG_rec.prc_context_id;
182     x_seeded_flag                  := l_x_SEG_rec.seeded_flag;
183     x_seeded_format_type           := l_x_SEG_rec.seeded_format_type;
184     x_seeded_precedence            := l_x_SEG_rec.seeded_precedence;
185     x_seeded_segment_name          := l_x_SEG_rec.seeded_segment_name;
186     x_seeded_description 	   := l_x_SEG_rec.seeded_description;
187     x_seeded_valueset_id           := l_x_SEG_rec.seeded_valueset_id;
188     x_segment_code                 := l_x_SEG_rec.segment_code;
189     x_segment_id                   := l_x_SEG_rec.segment_id;
190     x_application_id               := l_x_SEG_rec.application_id;
191     x_segment_mapping_column       := l_x_SEG_rec.segment_mapping_column;
192     x_user_format_type             := l_x_SEG_rec.user_format_type;
193     x_user_precedence              := l_x_SEG_rec.user_precedence;
194     x_user_segment_name            := l_x_SEG_rec.user_segment_name;
195     x_user_description 		   := l_x_SEG_rec.user_description;
196     x_user_valueset_id             := l_x_SEG_rec.user_valueset_id;
197     x_required_flag		   := l_x_SEG_rec.required_flag;
198     x_party_hierarchy_enabled_flag      := l_x_SEG_rec.party_hierarchy_enabled_flag; --Added for TCA
199 
200     --  Load display out parameters if any
201 
202     l_SEG_val_rec := QP_Seg_Util.Get_Values
203     (   p_SEG_rec                     => l_x_SEG_rec
204     );
205     x_prc_context                  := l_SEG_val_rec.prc_context;
206     x_seeded                       := l_SEG_val_rec.seeded;
207     x_seeded_valueset              := l_SEG_val_rec.seeded_valueset;
208     x_segment                      := l_SEG_val_rec.segment;
209     x_user_valueset                := l_SEG_val_rec.user_valueset;
210 
211     --  Write to cache.
212     --  Set db_flag to False before writing to cache
213 
214     l_x_SEG_rec.db_flag := FND_API.G_FALSE;
215 
216     Write_SEG
217     (   p_SEG_rec                     => l_x_SEG_rec
218     );
219 
220     --  Set return status.
221 
222     x_return_status := FND_API.G_RET_STS_SUCCESS;
223 
224     --  Get message count and data
225 
226     OE_MSG_PUB.Count_And_Get
227     (   p_count                       => x_msg_count
228     ,   p_data                        => x_msg_data
229     );
230 
231 
232 EXCEPTION
233 
234     WHEN FND_API.G_EXC_ERROR THEN
235 
236         x_return_status := FND_API.G_RET_STS_ERROR;
237 
238         --  Get message count and data
239 
240         OE_MSG_PUB.Count_And_Get
241         (   p_count                       => x_msg_count
242         ,   p_data                        => x_msg_data
243         );
244 
245     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
246 
247         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
248 
249         --  Get message count and data
250 
251         OE_MSG_PUB.Count_And_Get
252         (   p_count                       => x_msg_count
253         ,   p_data                        => x_msg_data
254         );
255 
256     WHEN OTHERS THEN
257 
258         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
259 
260         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
261         THEN
262             OE_MSG_PUB.Add_Exc_Msg
263             (   G_PKG_NAME
264             ,   'Default_Attributes'
265             );
266         END IF;
267 
268         --  Get message count and data
269 
270         OE_MSG_PUB.Count_And_Get
271         (   p_count                       => x_msg_count
272         ,   p_data                        => x_msg_data
273         );
274 
275 END Default_Attributes;
276 
277 --  Procedure   :   Change_Attribute
278 --
279 
280 PROCEDURE Change_Attribute
281 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
282 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
283 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
284 ,   p_segment_id                    IN  NUMBER
285 ,   p_attr_id                       IN  NUMBER
286 ,   p_attr_value                    IN  VARCHAR2
287 ,   p_attribute1                    IN  VARCHAR2
288 ,   p_attribute10                   IN  VARCHAR2
289 ,   p_attribute11                   IN  VARCHAR2
290 ,   p_attribute12                   IN  VARCHAR2
291 ,   p_attribute13                   IN  VARCHAR2
292 ,   p_attribute14                   IN  VARCHAR2
293 ,   p_attribute15                   IN  VARCHAR2
294 ,   p_attribute2                    IN  VARCHAR2
295 ,   p_attribute3                    IN  VARCHAR2
296 ,   p_attribute4                    IN  VARCHAR2
297 ,   p_attribute5                    IN  VARCHAR2
298 ,   p_attribute6                    IN  VARCHAR2
299 ,   p_attribute7                    IN  VARCHAR2
300 ,   p_attribute8                    IN  VARCHAR2
301 ,   p_attribute9                    IN  VARCHAR2
302 ,   p_context                       IN  VARCHAR2
303 ,   x_attribute1                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
304 ,   x_attribute10                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
305 ,   x_attribute11                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
306 ,   x_attribute12                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
307 ,   x_attribute13                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
308 ,   x_attribute14                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
309 ,   x_attribute15                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
310 ,   x_attribute2                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
311 ,   x_attribute3                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
312 ,   x_attribute4                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
313 ,   x_attribute5                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
314 ,   x_attribute6                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
315 ,   x_attribute7                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
316 ,   x_attribute8                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
317 ,   x_attribute9                    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
318 ,   x_availability_in_basic         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
319 ,   x_context                       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
320 ,   x_prc_context_id                OUT NOCOPY /* file.sql.39 change */ NUMBER
321 ,   x_seeded_flag                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
322 ,   x_seeded_format_type            OUT NOCOPY /* file.sql.39 change */ VARCHAR2
323 ,   x_seeded_precedence             OUT NOCOPY /* file.sql.39 change */ NUMBER
324 ,   x_seeded_segment_name           OUT NOCOPY /* file.sql.39 change */ VARCHAR2
325 ,   x_seeded_description	    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
326 ,   x_seeded_valueset_id            OUT NOCOPY /* file.sql.39 change */ NUMBER
327 ,   x_segment_code               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
328 ,   x_segment_id                    OUT NOCOPY /* file.sql.39 change */ NUMBER
329 ,   x_application_id                OUT NOCOPY /* file.sql.39 change */ NUMBER
330 ,   x_segment_mapping_column        OUT NOCOPY /* file.sql.39 change */ VARCHAR2
331 ,   x_user_format_type              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
332 ,   x_user_precedence               OUT NOCOPY /* file.sql.39 change */ NUMBER
333 ,   x_user_segment_name             OUT NOCOPY /* file.sql.39 change */ VARCHAR2
334 ,   x_user_description		    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
335 ,   x_user_valueset_id              OUT NOCOPY /* file.sql.39 change */ NUMBER
336 ,   x_prc_context                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
337 ,   x_seeded                        OUT NOCOPY /* file.sql.39 change */ VARCHAR2
338 ,   x_seeded_valueset               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
339 ,   x_segment                       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
340 ,   x_user_valueset                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
341 ,   x_required_flag		    OUT NOCOPY /* file.sql.39 change */ VARCHAR2
342 ,   x_party_hierarchy_enabled_flag       OUT NOCOPY VARCHAR2  --Added for TCA
343 )
344 IS
345 l_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
346 l_old_SEG_rec                 QP_Attributes_PUB.Seg_Rec_Type;
347 l_SEG_val_rec                 QP_Attributes_PUB.Seg_Val_Rec_Type;
348 l_SEG_tbl                     QP_Attributes_PUB.Seg_Tbl_Type;
349 l_old_SEG_tbl                 QP_Attributes_PUB.Seg_Tbl_Type;
350 l_control_rec                 QP_GLOBALS.Control_Rec_Type;
351 l_return_status               VARCHAR2(1);
352 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
353 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
354 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
355 BEGIN
356 
357     --  Set control flags.
358 
359     l_control_rec.controlled_operation := TRUE;
360     l_control_rec.change_attributes    := TRUE;
361 
362     l_control_rec.default_attributes   := FALSE;
363     l_control_rec.validate_entity      := FALSE;
364     l_control_rec.write_to_DB          := FALSE;
365     l_control_rec.process              := FALSE;
366 
367     --  Instruct API to retain its caches
368 
369     l_control_rec.clear_api_cache      := FALSE;
370     l_control_rec.clear_api_requests   := FALSE;
371 
372     --  Read SEG from cache
373 
374     l_SEG_rec := Get_SEG
375     (   p_db_record                   => FALSE
376     ,   p_segment_id                  => p_segment_id
377     );
378 
379     l_old_SEG_rec                  := l_SEG_rec;
380 
381     IF p_attr_id = QP_Seg_Util.G_AVAILABILITY_IN_BASIC THEN
382         l_SEG_rec.availability_in_basic := p_attr_value;
383     ELSIF p_attr_id = QP_Seg_Util.G_PRC_CONTEXT THEN
384         l_SEG_rec.prc_context_id := TO_NUMBER(p_attr_value);
385     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED THEN
386         l_SEG_rec.seeded_flag := p_attr_value;
387     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED_FORMAT_TYPE THEN
388         l_SEG_rec.seeded_format_type := p_attr_value;
389     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED_PRECEDENCE THEN
390         l_SEG_rec.seeded_precedence := TO_NUMBER(p_attr_value);
391     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED_SEGMENT_NAME THEN
392         l_SEG_rec.seeded_segment_name := p_attr_value;
393     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED_VALUESET THEN
394         l_SEG_rec.seeded_valueset_id := TO_NUMBER(p_attr_value);
395     ELSIF p_attr_id = QP_Seg_Util.G_SEGMENT_code THEN
396         l_SEG_rec.segment_code := p_attr_value;
397     ELSIF p_attr_id = QP_Seg_Util.G_SEGMENT THEN
398         l_SEG_rec.segment_id := TO_NUMBER(p_attr_value);
399     ELSIF p_attr_id = QP_Seg_Util.G_APPLICATION_ID THEN
400         l_SEG_rec.application_id := TO_NUMBER(p_attr_value);
401     ELSIF p_attr_id = QP_Seg_Util.G_SEGMENT_MAPPING_COLUMN THEN
402         l_SEG_rec.segment_mapping_column := p_attr_value;
403     ELSIF p_attr_id = QP_Seg_Util.G_USER_FORMAT_TYPE THEN
404         l_SEG_rec.user_format_type := p_attr_value;
405     ELSIF p_attr_id = QP_Seg_Util.G_USER_PRECEDENCE THEN
406         l_SEG_rec.user_precedence := TO_NUMBER(p_attr_value);
407     ELSIF p_attr_id = QP_Seg_Util.G_USER_SEGMENT_NAME THEN
408         l_SEG_rec.user_segment_name := p_attr_value;
409     ELSIF p_attr_id = QP_Seg_Util.G_USER_VALUESET THEN
410         l_SEG_rec.user_valueset_id := TO_NUMBER(p_attr_value);
411     ELSIF p_attr_id = QP_Seg_Util.G_SEEDED_DESCRIPTION THEN
412           l_SEG_rec.seeded_description := p_attr_value;
413     ELSIF p_attr_id = QP_Seg_Util.G_USER_DESCRIPTION THEN
414           l_SEG_rec.user_description := p_attr_value;
415     ELSIF p_attr_id = QP_Seg_Util.G_REQUIRED_FLAG THEN
416           l_SEG_rec.required_flag := NVL(p_attr_value, 'N');
417    -- Added for TCA
418     ELSIF p_attr_id = QP_Seg_Util.G_PARTY_HIERARCHY_ENABLED_FLAG THEN
419           l_SEG_rec.party_hierarchy_enabled_flag := NVL(p_attr_value, 'N');
420     ELSIF p_attr_id = QP_Seg_Util.G_ATTRIBUTE1
421     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE10
422     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE11
423     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE12
424     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE13
425     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE14
426     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE15
427     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE2
428     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE3
429     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE4
430     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE5
431     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE6
432     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE7
433     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE8
434     OR     p_attr_id = QP_Seg_Util.G_ATTRIBUTE9
435     OR     p_attr_id = QP_Seg_Util.G_CONTEXT
436     THEN
437 
438         l_SEG_rec.attribute1           := p_attribute1;
439         l_SEG_rec.attribute10          := p_attribute10;
440         l_SEG_rec.attribute11          := p_attribute11;
441         l_SEG_rec.attribute12          := p_attribute12;
442         l_SEG_rec.attribute13          := p_attribute13;
443         l_SEG_rec.attribute14          := p_attribute14;
444         l_SEG_rec.attribute15          := p_attribute15;
445         l_SEG_rec.attribute2           := p_attribute2;
446         l_SEG_rec.attribute3           := p_attribute3;
447         l_SEG_rec.attribute4           := p_attribute4;
448         l_SEG_rec.attribute5           := p_attribute5;
449         l_SEG_rec.attribute6           := p_attribute6;
450         l_SEG_rec.attribute7           := p_attribute7;
451         l_SEG_rec.attribute8           := p_attribute8;
452         l_SEG_rec.attribute9           := p_attribute9;
453         l_SEG_rec.context              := p_context;
454 
455     ELSE
456 
457         --  Unexpected error, unrecognized attribute
458 
459         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
460         THEN
461             OE_MSG_PUB.Add_Exc_Msg
462             (   G_PKG_NAME
463             ,   'Change_Attribute'
464             ,   'Unrecognized attribute'
465             );
466         END IF;
467 
468         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
469 
470     END IF;
471 
472     --  Set Operation.
473 
474     IF FND_API.To_Boolean(l_SEG_rec.db_flag) THEN
475         l_SEG_rec.operation := QP_GLOBALS.G_OPR_UPDATE;
476     ELSE
477         l_SEG_rec.operation := QP_GLOBALS.G_OPR_CREATE;
478     END IF;
479 
480     --  Populate SEG table
481 
482     l_SEG_tbl(1) := l_SEG_rec;
483     l_old_SEG_tbl(1) := l_old_SEG_rec;
484 
485     --  Call QP_Attributes_PVT.Process_Attributes
486 
487     QP_Attributes_PVT.Process_Attributes
488     (   p_api_version_number          => 1.0
489     ,   p_init_msg_list               => FND_API.G_TRUE
490     ,   p_validation_level            => FND_API.G_VALID_LEVEL_NONE
491     ,   x_return_status               => l_return_status
492     ,   x_msg_count                   => x_msg_count
493     ,   x_msg_data                    => x_msg_data
494     ,   p_control_rec                 => l_control_rec
495     ,   p_SEG_tbl                     => l_SEG_tbl
496     ,   p_old_SEG_tbl                 => l_old_SEG_tbl
497     ,   x_CON_rec                     => l_x_CON_rec
498     ,   x_SEG_tbl                     => l_x_SEG_tbl
499     );
500 
501     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
502         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
503     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
504         RAISE FND_API.G_EXC_ERROR;
505     END IF;
506 
507 
508     --  Unload out tbl
509 
510     l_x_SEG_rec := l_x_SEG_tbl(1);
511 
512     --  Init OUT parameters to missing.
513 
514     x_attribute1                   := FND_API.G_MISS_CHAR;
515     x_attribute10                  := FND_API.G_MISS_CHAR;
516     x_attribute11                  := FND_API.G_MISS_CHAR;
517     x_attribute12                  := FND_API.G_MISS_CHAR;
518     x_attribute13                  := FND_API.G_MISS_CHAR;
519     x_attribute14                  := FND_API.G_MISS_CHAR;
520     x_attribute15                  := FND_API.G_MISS_CHAR;
521     x_attribute2                   := FND_API.G_MISS_CHAR;
522     x_attribute3                   := FND_API.G_MISS_CHAR;
523     x_attribute4                   := FND_API.G_MISS_CHAR;
524     x_attribute5                   := FND_API.G_MISS_CHAR;
525     x_attribute6                   := FND_API.G_MISS_CHAR;
526     x_attribute7                   := FND_API.G_MISS_CHAR;
527     x_attribute8                   := FND_API.G_MISS_CHAR;
528     x_attribute9                   := FND_API.G_MISS_CHAR;
529     x_availability_in_basic        := FND_API.G_MISS_CHAR;
530     x_context                      := FND_API.G_MISS_CHAR;
531     x_prc_context_id               := FND_API.G_MISS_NUM;
532     x_seeded_flag                  := FND_API.G_MISS_CHAR;
533     x_seeded_format_type           := FND_API.G_MISS_CHAR;
534     x_seeded_precedence            := FND_API.G_MISS_NUM;
535     x_seeded_segment_name          := FND_API.G_MISS_CHAR;
536     x_seeded_valueset_id           := FND_API.G_MISS_NUM;
537     x_segment_code              := FND_API.G_MISS_CHAR;
538     x_segment_id                   := FND_API.G_MISS_NUM;
539     x_application_id               := FND_API.G_MISS_NUM;
540     x_segment_mapping_column       := FND_API.G_MISS_CHAR;
541     x_user_format_type             := FND_API.G_MISS_CHAR;
542     x_user_precedence              := FND_API.G_MISS_NUM;
543     x_user_segment_name            := FND_API.G_MISS_CHAR;
544     x_user_valueset_id             := FND_API.G_MISS_NUM;
545     x_prc_context                  := FND_API.G_MISS_CHAR;
546     x_seeded                       := FND_API.G_MISS_CHAR;
547     x_seeded_valueset              := FND_API.G_MISS_CHAR;
548     x_segment                      := FND_API.G_MISS_CHAR;
549     x_user_valueset                := FND_API.G_MISS_CHAR;
550     x_seeded_description           := FND_API.G_MISS_CHAR;
551     x_user_description             := FND_API.G_MISS_CHAR;
552     x_required_flag		   := FND_API.G_MISS_CHAR;
553     x_party_hierarchy_enabled_flag      := FND_API.G_MISS_CHAR;   -- Added for TCA
554 
555     --  Load display out parameters if any
556 
557     l_SEG_val_rec := QP_Seg_Util.Get_Values
558     (   p_SEG_rec                     => l_x_SEG_rec
559     ,   p_old_SEG_rec                 => l_SEG_rec
560     );
561 
562     --  Return changed attributes.
563 
564     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute1,
565                             l_SEG_rec.attribute1)
566     THEN
567         x_attribute1 := l_x_SEG_rec.attribute1;
568     END IF;
569 
570     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute10,
571                             l_SEG_rec.attribute10)
572     THEN
573         x_attribute10 := l_x_SEG_rec.attribute10;
574     END IF;
575 
576     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute11,
577                             l_SEG_rec.attribute11)
578     THEN
579         x_attribute11 := l_x_SEG_rec.attribute11;
580     END IF;
581 
582     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute12,
583                             l_SEG_rec.attribute12)
584     THEN
585         x_attribute12 := l_x_SEG_rec.attribute12;
586     END IF;
587 
588     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute13,
589                             l_SEG_rec.attribute13)
590     THEN
591         x_attribute13 := l_x_SEG_rec.attribute13;
592     END IF;
593 
594     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute14,
595                             l_SEG_rec.attribute14)
596     THEN
597         x_attribute14 := l_x_SEG_rec.attribute14;
598     END IF;
599 
600     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute15,
601                             l_SEG_rec.attribute15)
602     THEN
603         x_attribute15 := l_x_SEG_rec.attribute15;
604     END IF;
605 
606     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute2,
607                             l_SEG_rec.attribute2)
608     THEN
609         x_attribute2 := l_x_SEG_rec.attribute2;
610     END IF;
611 
612     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute3,
613                             l_SEG_rec.attribute3)
614     THEN
615         x_attribute3 := l_x_SEG_rec.attribute3;
616     END IF;
617 
618     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute4,
619                             l_SEG_rec.attribute4)
620     THEN
621         x_attribute4 := l_x_SEG_rec.attribute4;
622     END IF;
623 
624     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute5,
625                             l_SEG_rec.attribute5)
626     THEN
627         x_attribute5 := l_x_SEG_rec.attribute5;
628     END IF;
629 
630     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute6,
631                             l_SEG_rec.attribute6)
632     THEN
633         x_attribute6 := l_x_SEG_rec.attribute6;
634     END IF;
635 
636     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute7,
637                             l_SEG_rec.attribute7)
638     THEN
639         x_attribute7 := l_x_SEG_rec.attribute7;
640     END IF;
641 
642     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute8,
643                             l_SEG_rec.attribute8)
644     THEN
645         x_attribute8 := l_x_SEG_rec.attribute8;
646     END IF;
647 
648     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.attribute9,
649                             l_SEG_rec.attribute9)
650     THEN
651         x_attribute9 := l_x_SEG_rec.attribute9;
652     END IF;
653 
654     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.availability_in_basic,
655                             l_SEG_rec.availability_in_basic)
656     THEN
657         x_availability_in_basic := l_x_SEG_rec.availability_in_basic;
658     END IF;
659 
660     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.context,
661                             l_SEG_rec.context)
662     THEN
663         x_context := l_x_SEG_rec.context;
664     END IF;
665 
666     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.prc_context_id,
667                             l_SEG_rec.prc_context_id)
668     THEN
669         x_prc_context_id := l_x_SEG_rec.prc_context_id;
670         x_prc_context := l_SEG_val_rec.prc_context;
671     END IF;
672 
673     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_flag,
674                             l_SEG_rec.seeded_flag)
675     THEN
676         x_seeded_flag := l_x_SEG_rec.seeded_flag;
677         x_seeded := l_SEG_val_rec.seeded;
678     END IF;
679 
680     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_format_type,
681                             l_SEG_rec.seeded_format_type)
682     THEN
683         x_seeded_format_type := l_x_SEG_rec.seeded_format_type;
684     END IF;
685 
686     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_precedence,
687                             l_SEG_rec.seeded_precedence)
688     THEN
689         x_seeded_precedence := l_x_SEG_rec.seeded_precedence;
690     END IF;
691 
692     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_segment_name,
693                             l_SEG_rec.seeded_segment_name)
694     THEN
695         x_seeded_segment_name := l_x_SEG_rec.seeded_segment_name;
696     END IF;
697 
698     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_description,
699                             l_SEG_rec.seeded_description)
700     THEN
701         x_seeded_description := l_x_SEG_rec.seeded_description;
702     END IF;
703 
704      IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.user_description,
705                              l_SEG_rec.user_description)
706     THEN
707         x_user_description := l_x_SEG_rec.user_description;
708     END IF;
709 
710     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.seeded_valueset_id,
711                             l_SEG_rec.seeded_valueset_id)
712     THEN
713         x_seeded_valueset_id := l_x_SEG_rec.seeded_valueset_id;
714         x_seeded_valueset := l_SEG_val_rec.seeded_valueset;
715     END IF;
716 
717     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.segment_code,
718                             l_SEG_rec.segment_code)
719     THEN
720         x_segment_code := l_x_SEG_rec.segment_code;
721     END IF;
722 
723     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.segment_id,
724                             l_SEG_rec.segment_id)
725     THEN
726         x_segment_id := l_x_SEG_rec.segment_id;
727         x_segment := l_SEG_val_rec.segment;
728     END IF;
729 
730     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.application_id,
731                             l_SEG_rec.application_id)
732     THEN
733         x_application_id := l_x_SEG_rec.application_id;
734     END IF;
735 
736     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.segment_mapping_column,
737                             l_SEG_rec.segment_mapping_column)
738     THEN
739         x_segment_mapping_column := l_x_SEG_rec.segment_mapping_column;
740     END IF;
741 
742     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.user_format_type,
743                             l_SEG_rec.user_format_type)
744     THEN
745         x_user_format_type := l_x_SEG_rec.user_format_type;
746     END IF;
747 
748     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.user_precedence,
749                             l_SEG_rec.user_precedence)
750     THEN
751         x_user_precedence := l_x_SEG_rec.user_precedence;
752     END IF;
753 
754     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.user_segment_name,
755                             l_SEG_rec.user_segment_name)
756     THEN
757         x_user_segment_name := l_x_SEG_rec.user_segment_name;
758     END IF;
759 
760     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.required_flag,
761                             l_SEG_rec.required_flag)
762     THEN
763         x_required_flag := NVL(l_x_SEG_rec.required_flag, 'N');
764     END IF;
765 
766     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.user_valueset_id,
767                             l_SEG_rec.user_valueset_id)
768     THEN
769         x_user_valueset_id := l_x_SEG_rec.user_valueset_id;
770         x_user_valueset := l_SEG_val_rec.user_valueset;
771     END IF;
772     -- Added for TCA
773     IF NOT QP_GLOBALS.Equal(l_x_SEG_rec.party_hierarchy_enabled_flag,
774                             l_SEG_rec.party_hierarchy_enabled_flag)
775     THEN
776         x_party_hierarchy_enabled_flag := NVL(l_x_SEG_rec.party_hierarchy_enabled_flag, 'N');
777     END IF;
778 
779 
780     --  Write to cache.
781 
782     Write_SEG
783     (   p_SEG_rec                     => l_x_SEG_rec
784     );
785 
786     --  Set return status.
787 
788     x_return_status := FND_API.G_RET_STS_SUCCESS;
789 
790     --  Get message count and data
791 
792     OE_MSG_PUB.Count_And_Get
793     (   p_count                       => x_msg_count
794     ,   p_data                        => x_msg_data
795     );
796 
797 
798 EXCEPTION
799 
800     WHEN FND_API.G_EXC_ERROR THEN
801 
802         x_return_status := FND_API.G_RET_STS_ERROR;
803 
804         --  Get message count and data
805 
806         OE_MSG_PUB.Count_And_Get
807         (   p_count                       => x_msg_count
808         ,   p_data                        => x_msg_data
809         );
810 
811     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
812 
813         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
814 
815         --  Get message count and data
816 
817         OE_MSG_PUB.Count_And_Get
818         (   p_count                       => x_msg_count
819         ,   p_data                        => x_msg_data
820         );
821 
822     WHEN OTHERS THEN
823 
824         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
825 
826         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
827         THEN
828             OE_MSG_PUB.Add_Exc_Msg
829             (   G_PKG_NAME
830             ,   'Change_Attribute'
831             );
832         END IF;
833 
834         --  Get message count and data
835 
836         OE_MSG_PUB.Count_And_Get
837         (   p_count                       => x_msg_count
838         ,   p_data                        => x_msg_data
839         );
840 
841 END Change_Attribute;
842 
843 --  Procedure       Validate_And_Write
844 --
845 
846 PROCEDURE Validate_And_Write
847 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
848 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
849 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
850 ,   p_segment_id                    IN  NUMBER
851 ,   x_creation_date                 OUT NOCOPY /* file.sql.39 change */ DATE
852 ,   x_created_by                    OUT NOCOPY /* file.sql.39 change */ NUMBER
853 ,   x_last_update_date              OUT NOCOPY /* file.sql.39 change */ DATE
854 ,   x_last_updated_by               OUT NOCOPY /* file.sql.39 change */ NUMBER
855 ,   x_last_update_login             OUT NOCOPY /* file.sql.39 change */ NUMBER
856 )
857 IS
858 l_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
859 l_old_SEG_rec                 QP_Attributes_PUB.Seg_Rec_Type;
860 l_SEG_tbl                     QP_Attributes_PUB.Seg_Tbl_Type;
861 l_old_SEG_tbl                 QP_Attributes_PUB.Seg_Tbl_Type;
862 l_control_rec                 QP_GLOBALS.Control_Rec_Type;
863 l_return_status               VARCHAR2(1);
864 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
865 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
866 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
867 dummy_seg_id varchar2(25);
868 dummy_app_id varchar2(25);
869 BEGIN
870 
871     --  Set control flags.
872 
873     l_control_rec.controlled_operation := TRUE;
874     l_control_rec.validate_entity      := TRUE;
875     l_control_rec.write_to_DB          := TRUE;
876 
877     l_control_rec.default_attributes   := FALSE;
878     l_control_rec.change_attributes    := FALSE;
879     l_control_rec.process              := FALSE;
880 
881     --  Instruct API to retain its caches
882 
883     l_control_rec.clear_api_cache      := FALSE;
884     l_control_rec.clear_api_requests   := FALSE;
885 
886     --  Read SEG from cache
887 
888 
889     if g_db_seg_rec.segment_id = FND_API.G_MISS_NUM then
890          dummy_seg_id := 'G_MISS_NUM';
891     else
892 	 dummy_seg_id := g_db_seg_rec.segment_id;
893     end if;
894 
895     if g_db_seg_rec.application_id = FND_API.G_MISS_NUM then
896          dummy_app_id := 'G_MISS_NUM';
897     else
898 	 dummy_app_id := g_db_seg_rec.application_id;
899     end if;
900 
901     l_old_SEG_rec := Get_SEG
902     (   p_db_record                   => TRUE
903     ,   p_segment_id                  => p_segment_id
904     );
905 
906     if g_db_seg_rec.segment_id = FND_API.G_MISS_NUM then
907          dummy_seg_id := 'G_MISS_NUM';
908     else
909 	 dummy_seg_id := g_db_seg_rec.segment_id;
910     end if;
911 
912     if g_db_seg_rec.application_id = FND_API.G_MISS_NUM then
913          dummy_app_id := 'G_MISS_NUM';
914     else
915 	 dummy_app_id := g_db_seg_rec.application_id;
916     end if;
917 
918     l_SEG_rec := Get_SEG
919     (   p_db_record                   => FALSE
920     ,   p_segment_id                  => p_segment_id
921     );
922 
923     --  Set Operation.
924 
925     IF FND_API.To_Boolean(l_SEG_rec.db_flag) THEN
926         l_SEG_rec.operation := QP_GLOBALS.G_OPR_UPDATE;
927     ELSE
928         l_SEG_rec.operation := QP_GLOBALS.G_OPR_CREATE;
929     END IF;
930 
931     --  Populate SEG table
932 
933     l_SEG_tbl(1) := l_SEG_rec;
934     l_old_SEG_tbl(1) := l_old_SEG_rec;
935 
936     --  Call QP_Attributes_PVT.Process_Attributes
937 
938     QP_Attributes_PVT.Process_Attributes
939     (   p_api_version_number          => 1.0
940     ,   p_init_msg_list               => FND_API.G_TRUE
941     ,   x_return_status               => l_return_status
942     ,   x_msg_count                   => x_msg_count
943     ,   x_msg_data                    => x_msg_data
944     ,   p_control_rec                 => l_control_rec
945     ,   p_SEG_tbl                     => l_SEG_tbl
946     ,   p_old_SEG_tbl                 => l_old_SEG_tbl
947     ,   x_CON_rec                     => l_x_CON_rec
948     ,   x_SEG_tbl                     => l_x_SEG_tbl
949     );
950 
951     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
952         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
953     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
954         RAISE FND_API.G_EXC_ERROR;
955     END IF;
956 
957 
958     --  Load OUT parameters.
959 
960     l_x_SEG_rec := l_x_SEG_tbl(1);
961 
962     x_creation_date                := l_x_SEG_rec.creation_date;
963     x_created_by                   := l_x_SEG_rec.created_by;
964     x_last_update_date             := l_x_SEG_rec.last_update_date;
965     x_last_updated_by              := l_x_SEG_rec.last_updated_by;
966     x_last_update_login            := l_x_SEG_rec.last_update_login;
967 
968     --  Clear SEG record cache
969 
970     Clear_SEG;
971 
972     --  Keep track of performed operations.
973 
974     l_old_SEG_rec.operation := l_SEG_rec.operation;
975 
976 
977     --  Set return status.
978 
979     x_return_status := FND_API.G_RET_STS_SUCCESS;
980 
981     --  Get message count and data
982 
983     OE_MSG_PUB.Count_And_Get
984     (   p_count                       => x_msg_count
985     ,   p_data                        => x_msg_data
986     );
987 
988 
989 EXCEPTION
990 
991     WHEN FND_API.G_EXC_ERROR THEN
992 
993         x_return_status := FND_API.G_RET_STS_ERROR;
994 
995         --  Get message count and data
996 
997         OE_MSG_PUB.Count_And_Get
998         (   p_count                       => x_msg_count
999         ,   p_data                        => x_msg_data
1000         );
1001 
1002     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1003 
1004         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1005 
1006         --  Get message count and data
1007 
1008         OE_MSG_PUB.Count_And_Get
1009         (   p_count                       => x_msg_count
1010         ,   p_data                        => x_msg_data
1011         );
1012 
1013     WHEN OTHERS THEN
1014 
1015         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1016 
1017         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1018         THEN
1019             OE_MSG_PUB.Add_Exc_Msg
1020             (   G_PKG_NAME
1021             ,   'Validate_And_Write'
1022             );
1023         END IF;
1024 
1025         --  Get message count and data
1026 
1027         OE_MSG_PUB.Count_And_Get
1028         (   p_count                       => x_msg_count
1029         ,   p_data                        => x_msg_data
1030         );
1031 
1032 END Validate_And_Write;
1033 
1034 --  Procedure       Delete_Row
1035 --
1036 
1037 PROCEDURE Delete_Row
1038 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1039 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
1040 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1041 ,   p_segment_id                    IN  NUMBER
1042 )
1043 IS
1044 l_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
1045 l_SEG_tbl                     QP_Attributes_PUB.Seg_Tbl_Type;
1046 l_control_rec                 QP_GLOBALS.Control_Rec_Type;
1047 l_return_status               VARCHAR2(1);
1048 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
1049 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
1050 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
1051 BEGIN
1052 
1053     --  Set control flags.
1054 
1055     l_control_rec.controlled_operation := TRUE;
1056     l_control_rec.validate_entity      := TRUE;
1057     l_control_rec.write_to_DB          := TRUE;
1058 
1059     l_control_rec.default_attributes   := FALSE;
1060     l_control_rec.change_attributes    := FALSE;
1061     l_control_rec.process              := FALSE;
1062 
1063     --  Instruct API to retain its caches
1064 
1065     l_control_rec.clear_api_cache      := FALSE;
1066     l_control_rec.clear_api_requests   := FALSE;
1067 
1068     --  Read DB record from cache
1069 
1070     l_SEG_rec := Get_SEG
1071     (   p_db_record                   => TRUE
1072     ,   p_segment_id                  => p_segment_id
1073     );
1074 
1075     --  Set Operation.
1076 
1077     l_SEG_rec.operation := QP_GLOBALS.G_OPR_DELETE;
1078 
1079     --  Populate SEG table
1080 
1081     l_SEG_tbl(1) := l_SEG_rec;
1082 
1083     --  Call QP_Attributes_PVT.Process_Attributes
1084 
1085     QP_Attributes_PVT.Process_Attributes
1086     (   p_api_version_number          => 1.0
1087     ,   p_init_msg_list               => FND_API.G_TRUE
1088     ,   x_return_status               => l_return_status
1089     ,   x_msg_count                   => x_msg_count
1090     ,   x_msg_data                    => x_msg_data
1091     ,   p_control_rec                 => l_control_rec
1092     ,   p_SEG_tbl                     => l_SEG_tbl
1093     ,   x_CON_rec                     => l_x_CON_rec
1094     ,   x_SEG_tbl                     => l_x_SEG_tbl
1095     );
1096 
1097     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1098         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1099     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1100         RAISE FND_API.G_EXC_ERROR;
1101     END IF;
1102 
1103 
1104     --  Clear SEG record cache
1105 
1106     Clear_SEG;
1107 
1108     --  Set return status.
1109 
1110     x_return_status := FND_API.G_RET_STS_SUCCESS;
1111 
1112     --  Get message count and data
1113 
1114     OE_MSG_PUB.Count_And_Get
1115     (   p_count                       => x_msg_count
1116     ,   p_data                        => x_msg_data
1117     );
1118 
1119 
1120 EXCEPTION
1121 
1122     WHEN FND_API.G_EXC_ERROR THEN
1123 
1124         x_return_status := FND_API.G_RET_STS_ERROR;
1125 
1126         --  Get message count and data
1127 
1128         OE_MSG_PUB.Count_And_Get
1129         (   p_count                       => x_msg_count
1130         ,   p_data                        => x_msg_data
1131         );
1132 
1133     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1134 
1135         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1136 
1137         --  Get message count and data
1138 
1139         OE_MSG_PUB.Count_And_Get
1140         (   p_count                       => x_msg_count
1141         ,   p_data                        => x_msg_data
1142         );
1143 
1144     WHEN OTHERS THEN
1145 
1146         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1147 
1148         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1149         THEN
1150             OE_MSG_PUB.Add_Exc_Msg
1151             (   G_PKG_NAME
1152             ,   'Delete_Row'
1153             );
1154         END IF;
1155 
1156         --  Get message count and data
1157 
1158         OE_MSG_PUB.Count_And_Get
1159         (   p_count                       => x_msg_count
1160         ,   p_data                        => x_msg_data
1161         );
1162 
1163 END Delete_Row;
1164 
1165 --  Procedure       Process_Entity
1166 --
1167 
1168 PROCEDURE Process_Entity
1169 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1170 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
1171 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1172 )
1173 IS
1174 l_control_rec                 QP_GLOBALS.Control_Rec_Type;
1175 l_return_status               VARCHAR2(1);
1176 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
1177 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
1178 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
1179 BEGIN
1180 
1181     --  Set control flags.
1182 
1183     l_control_rec.controlled_operation := TRUE;
1184     l_control_rec.process              := TRUE;
1185     l_control_rec.process_entity       := QP_GLOBALS.G_ENTITY_SEG;
1186 
1187     l_control_rec.default_attributes   := FALSE;
1188     l_control_rec.change_attributes    := FALSE;
1189     l_control_rec.validate_entity      := FALSE;
1190     l_control_rec.write_to_DB          := FALSE;
1191 
1192     --  Instruct API to clear its request table
1193 
1194     l_control_rec.clear_api_cache      := FALSE;
1195     l_control_rec.clear_api_requests   := FALSE;
1196 
1197     --  Call QP_Attributes_PVT.Process_Attributes
1198 
1199     QP_Attributes_PVT.Process_Attributes
1200     (   p_api_version_number          => 1.0
1201     ,   p_init_msg_list               => FND_API.G_TRUE
1202     ,   x_return_status               => l_return_status
1203     ,   x_msg_count                   => x_msg_count
1204     ,   x_msg_data                    => x_msg_data
1205     ,   p_control_rec                 => l_control_rec
1206     ,   x_CON_rec                     => l_x_CON_rec
1207     ,   x_SEG_tbl                     => l_x_SEG_tbl
1208     );
1209 
1210     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1211         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1212     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1213         RAISE FND_API.G_EXC_ERROR;
1214     END IF;
1215 
1216 
1217     --  Set return status.
1218 
1219     x_return_status := FND_API.G_RET_STS_SUCCESS;
1220 
1221     --  Get message count and data
1222 
1223     OE_MSG_PUB.Count_And_Get
1224     (   p_count                       => x_msg_count
1225     ,   p_data                        => x_msg_data
1226     );
1227 
1228 
1229 EXCEPTION
1230 
1231     WHEN FND_API.G_EXC_ERROR THEN
1232 
1233         x_return_status := FND_API.G_RET_STS_ERROR;
1234 
1235         --  Get message count and data
1236 
1237         OE_MSG_PUB.Count_And_Get
1238         (   p_count                       => x_msg_count
1239         ,   p_data                        => x_msg_data
1240         );
1241 
1242     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1243 
1244         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1245 
1246         --  Get message count and data
1247 
1248         OE_MSG_PUB.Count_And_Get
1249         (   p_count                       => x_msg_count
1250         ,   p_data                        => x_msg_data
1251         );
1252 
1253     WHEN OTHERS THEN
1254 
1255         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1256 
1257         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1258         THEN
1259             OE_MSG_PUB.Add_Exc_Msg
1260             (   G_PKG_NAME
1261             ,   'Process_Entity'
1262             );
1263         END IF;
1264 
1265         --  Get message count and data
1266 
1267         OE_MSG_PUB.Count_And_Get
1268         (   p_count                       => x_msg_count
1269         ,   p_data                        => x_msg_data
1270         );
1271 
1272 END Process_Entity;
1273 
1274 --  Procedure       lock_Row
1275 --
1276 
1277 PROCEDURE Lock_Row
1278 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1279 ,   x_msg_count                     OUT NOCOPY /* file.sql.39 change */ NUMBER
1280 ,   x_msg_data                      OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1281 ,   p_attribute1                    IN  VARCHAR2
1282 ,   p_attribute10                   IN  VARCHAR2
1283 ,   p_attribute11                   IN  VARCHAR2
1284 ,   p_attribute12                   IN  VARCHAR2
1285 ,   p_attribute13                   IN  VARCHAR2
1286 ,   p_attribute14                   IN  VARCHAR2
1287 ,   p_attribute15                   IN  VARCHAR2
1288 ,   p_attribute2                    IN  VARCHAR2
1289 ,   p_attribute3                    IN  VARCHAR2
1290 ,   p_attribute4                    IN  VARCHAR2
1291 ,   p_attribute5                    IN  VARCHAR2
1292 ,   p_attribute6                    IN  VARCHAR2
1293 ,   p_attribute7                    IN  VARCHAR2
1294 ,   p_attribute8                    IN  VARCHAR2
1295 ,   p_attribute9                    IN  VARCHAR2
1296 ,   p_availability_in_basic         IN  VARCHAR2
1297 ,   p_context                       IN  VARCHAR2
1298 ,   p_created_by                    IN  NUMBER
1299 ,   p_creation_date                 IN  DATE
1300 ,   p_last_updated_by               IN  NUMBER
1301 ,   p_last_update_date              IN  DATE
1302 ,   p_last_update_login             IN  NUMBER
1303 ,   p_prc_context_id                IN  NUMBER
1304 ,   p_program_application_id        IN  NUMBER
1305 ,   p_program_id                    IN  NUMBER
1306 ,   p_program_update_date           IN  DATE
1307 ,   p_seeded_flag                   IN  VARCHAR2
1308 ,   p_seeded_format_type            IN  VARCHAR2
1309 ,   p_seeded_precedence             IN  NUMBER
1310 ,   p_seeded_segment_name           IN  VARCHAR2
1311 ,   p_seeded_description     	    IN  VARCHAR2
1312 ,   p_seeded_valueset_id            IN  NUMBER
1313 ,   p_segment_code               IN  VARCHAR2
1314 ,   p_segment_id                    IN  NUMBER
1315 ,   p_application_id                IN  NUMBER
1316 ,   p_segment_mapping_column        IN  VARCHAR2
1317 ,   p_user_format_type              IN  VARCHAR2
1318 ,   p_user_precedence               IN  NUMBER
1319 ,   p_user_segment_name             IN  VARCHAR2
1320 ,   p_user_description		    IN  VARCHAR2
1321 ,   p_user_valueset_id              IN  NUMBER
1322 ,   p_required_flag		    IN  VARCHAR2
1323 ,   p_party_hierarchy_enabled_flag       IN  VARCHAR2    -- Added for TCA
1324 )
1325 IS
1326 l_return_status               VARCHAR2(1);
1327 l_SEG_rec                     QP_Attributes_PUB.Seg_Rec_Type;
1328 l_SEG_tbl                     QP_Attributes_PUB.Seg_Tbl_Type;
1329 l_x_CON_rec                   QP_Attributes_PUB.Con_Rec_Type;
1330 l_x_SEG_rec                   QP_Attributes_PUB.Seg_Rec_Type;
1331 l_x_SEG_tbl                   QP_Attributes_PUB.Seg_Tbl_Type;
1332 BEGIN
1333 
1334     --  Load SEG record
1335 
1336     l_SEG_rec.attribute1           := p_attribute1;
1337     l_SEG_rec.attribute10          := p_attribute10;
1338     l_SEG_rec.attribute11          := p_attribute11;
1339     l_SEG_rec.attribute12          := p_attribute12;
1340     l_SEG_rec.attribute13          := p_attribute13;
1341     l_SEG_rec.attribute14          := p_attribute14;
1342     l_SEG_rec.attribute15          := p_attribute15;
1343     l_SEG_rec.attribute2           := p_attribute2;
1344     l_SEG_rec.attribute3           := p_attribute3;
1345     l_SEG_rec.attribute4           := p_attribute4;
1346     l_SEG_rec.attribute5           := p_attribute5;
1347     l_SEG_rec.attribute6           := p_attribute6;
1348     l_SEG_rec.attribute7           := p_attribute7;
1349     l_SEG_rec.attribute8           := p_attribute8;
1350     l_SEG_rec.attribute9           := p_attribute9;
1351     l_SEG_rec.availability_in_basic := p_availability_in_basic;
1352     l_SEG_rec.context              := p_context;
1353     l_SEG_rec.created_by           := p_created_by;
1354     l_SEG_rec.creation_date        := p_creation_date;
1355     l_SEG_rec.last_updated_by      := p_last_updated_by;
1356     l_SEG_rec.last_update_date     := p_last_update_date;
1357     l_SEG_rec.last_update_login    := p_last_update_login;
1358     l_SEG_rec.prc_context_id       := p_prc_context_id;
1359     l_SEG_rec.program_application_id := p_program_application_id;
1360     l_SEG_rec.program_id           := p_program_id;
1361     l_SEG_rec.program_update_date  := p_program_update_date;
1362     l_SEG_rec.seeded_flag          := p_seeded_flag;
1363     l_SEG_rec.seeded_format_type   := p_seeded_format_type;
1364     l_SEG_rec.seeded_precedence    := p_seeded_precedence;
1365     l_SEG_rec.seeded_segment_name  := p_seeded_segment_name;
1366     l_SEG_rec.seeded_valueset_id   := p_seeded_valueset_id;
1367     l_SEG_rec.segment_code      := p_segment_code;
1368     l_SEG_rec.segment_id           := p_segment_id;
1369     l_SEG_rec.application_id       := p_application_id;
1370     l_SEG_rec.segment_mapping_column := p_segment_mapping_column;
1371     l_SEG_rec.user_format_type     := p_user_format_type;
1372     l_SEG_rec.user_precedence      := p_user_precedence;
1373     l_SEG_rec.user_segment_name    := p_user_segment_name;
1374     l_SEG_rec.user_valueset_id     := p_user_valueset_id;
1375     l_SEG_rec.seeded_description   := p_seeded_description;
1376     l_SEG_rec.user_description     := p_user_description;
1377     l_SEG_rec.required_flag	   := p_required_flag;
1378     l_SEG_rec.party_hierarchy_enabled_flag := p_party_hierarchy_enabled_flag; -- Added for TCA
1379     --  Populate SEG table
1380 
1381     l_SEG_tbl(1) := l_SEG_rec;
1382 
1383     --  Call QP_Attributes_PVT.Lock_Attributes
1384 
1385     QP_Attributes_PVT.Lock_Attributes
1386     (   p_api_version_number          => 1.0
1387     ,   p_init_msg_list               => FND_API.G_TRUE
1388     ,   x_return_status               => l_return_status
1389     ,   x_msg_count                   => x_msg_count
1390     ,   x_msg_data                    => x_msg_data
1391     ,   p_SEG_tbl                     => l_SEG_tbl
1392     ,   x_CON_rec                     => l_x_CON_rec
1393     ,   x_SEG_tbl                     => l_x_SEG_tbl
1394     );
1395 
1396     IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1397 
1398         --  Set DB flag and write record to cache.
1399 
1400         l_x_SEG_rec.db_flag := FND_API.G_TRUE;
1401 
1402         Write_SEG
1403         (   p_SEG_rec                     => l_x_SEG_rec
1404         ,   p_db_record                   => TRUE
1405         );
1406 
1407     END IF;
1408 
1409     --  Set return status.
1410 
1411     x_return_status := l_return_status;
1412 
1413     --  Get message count and data
1414 
1415     OE_MSG_PUB.Count_And_Get
1416     (   p_count                       => x_msg_count
1417     ,   p_data                        => x_msg_data
1418     );
1419 
1420 
1421 EXCEPTION
1422 
1423     WHEN OTHERS THEN
1424 
1425         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1426         THEN
1427             OE_MSG_PUB.Add_Exc_Msg
1428             (   G_PKG_NAME
1429             ,   'Lock_Row'
1430             );
1431         END IF;
1432 
1433         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1434 
1435         --  Get message count and data
1436 
1437         OE_MSG_PUB.Count_And_Get
1438         (   p_count                       => x_msg_count
1439         ,   p_data                        => x_msg_data
1440         );
1441 
1442 
1443 
1444 END Lock_Row;
1445 
1446 --  Procedures maintaining SEG record cache.
1447 
1448 PROCEDURE Write_SEG
1449 (   p_SEG_rec                       IN  QP_Attributes_PUB.Seg_Rec_Type
1450 ,   p_db_record                     IN  BOOLEAN := FALSE
1451 )
1452 IS
1453 BEGIN
1454 
1455     g_SEG_rec := p_SEG_rec;
1456 
1457     IF p_db_record THEN
1458 
1459         g_db_SEG_rec := p_SEG_rec;
1460 
1461     END IF;
1462 
1463 END Write_Seg;
1464 
1465 FUNCTION Get_SEG
1466 (   p_db_record                     IN  BOOLEAN := FALSE
1467 ,   p_segment_id                    IN  NUMBER
1468 )
1469 RETURN QP_Attributes_PUB.Seg_Rec_Type
1470 IS
1471 BEGIN
1472 
1473     IF  p_segment_id <> g_SEG_rec.segment_id
1474     THEN
1475 
1476         --  Query row from DB
1477 
1478         g_SEG_rec := QP_Seg_Util.Query_Row
1479         (   p_segment_id                  => p_segment_id
1480         );
1481 
1482         g_SEG_rec.db_flag              := FND_API.G_TRUE;
1483 
1484         --  Load DB record
1485 
1486         g_db_SEG_rec                   := g_SEG_rec;
1487 
1488     END IF;
1489 
1490     IF p_db_record THEN
1491 
1492         RETURN g_db_SEG_rec;
1493 
1494     ELSE
1495 
1496         RETURN g_SEG_rec;
1497 
1498     END IF;
1499 
1500 END Get_Seg;
1501 
1502 PROCEDURE Clear_Seg
1503 IS
1504 BEGIN
1505 
1506     g_SEG_rec                      := QP_Attributes_PUB.G_MISS_SEG_REC;
1507     g_db_SEG_rec                   := QP_Attributes_PUB.G_MISS_SEG_REC;
1508 
1509 END Clear_Seg;
1510 
1511 END QP_QP_Form_Seg;