DBA Data[Home] [Help]

PACKAGE BODY: APPS.AK_REGION_PVT

Source


1 package body AK_REGION_PVT as
2 /* $Header: akdvregb.pls 120.6.12020000.2 2012/11/20 19:18:23 tshort ship $ */
3 
4 /*
5 --=======================================================
6 --  Function    VALIDATE_GRAPH
7 --
8 --  Usage       Private API for validating a region graph. This
9 --              API should only be called by other APIs that are
10 --              owned by the Core Modules Team (AK).
11 --
12 --  Desc        Perform validation on a region graph record.
13 --
14 --  Results     The API returns the standard p_return_status parameter
15 --              indicating one of the standard return statuses :
16 --                  * Unexpected error
17 --                  * Error
18 --                  * Success
19 --              In addition, this function returns TRUE if all
20 --              validation tests are passed, or FALSE otherwise.
21 --  Parameters  Region graph columns
22 --              p_caller : IN required
23 --                  Must be one of the following values defined
24 --                  in package AK_ON_OBJECTS_PVT:
25 --                  - G_CREATE   (if calling from the Create API)
26 --                  - G_DOWNLOAD (if calling from the Download API)
27 --                  - G_UPDATE   (if calling from the Update API)
28 --
29 --  Note        This API is intended for performing record-level
30 --              validation. It is not designed for item-level
31 --              validation.
32 --
33 --  Version     Initial version number  =   1.0
34 --  History     Current version number  =   1.0
35 --=======================================================
36 function VALIDATE_GRAPH (
37 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
38 p_api_version_number       IN      NUMBER,
39 p_return_status            OUT NOCOPY     VARCHAR2,
40 p_region_application_id    IN      NUMBER,
41 p_region_code              IN      VARCHAR2,
42 p_graph_number	     IN	     NUMBER := FND_API.G_MISS_NUM,
43 p_graph_style		     IN      NUMBER := FND_API.G_MISS_NUM,
44 p_display_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
45 p_depth_radius	     IN      NUMBER := FND_API.G_MISS_NUM,
46 p_graph_title		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
47 p_y_axis_label	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
48 p_caller		     IN      VARCHAR2,
49 p_pass		     IN	     NUMBER := 2
50 ) return BOOLEAN is
51 cursor l_check_region_csr is
52 select  region_style
53 from    AK_REGIONS
54 where   region_application_id = p_region_application_id
55 and     region_code = p_region_code;
56 
57 l_api_version_number      CONSTANT number := 1.0;
58 l_api_name                CONSTANT varchar2(30) := 'Validate_Graph';
59 l_dummy                   NUMBER;
60 l_reg_style		    VARCHAR2(30);
61 l_error                   BOOLEAN;
62 l_return_status           VARCHAR2(1);
63 l_validation_level	    NUMBER := FND_API.G_VALID_LEVEL_NONE;
64 
65 begin
66 IF NOT FND_API.Compatible_API_Call (
67 l_api_version_number, p_api_version_number, l_api_name,
68 G_PKG_NAME) then
69 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
70 return FALSE;
71 END IF;
72 
73 l_error := FALSE;
74 
75 --** if validation level is none, no validation is necessary
76 if (p_validation_level = FND_API.G_VALID_LEVEL_NONE) then
77 p_return_status := FND_API.G_RET_STS_SUCCESS;
78 return TRUE;
79 end if;
80 
81 --** check that key columns are not null and not missing **
82 if ((p_region_application_id is null) or
83 (p_region_application_id = FND_API.G_MISS_NUM)) then
84 l_error := TRUE;
85 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
86 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
87 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_APPLICATION_ID');
88 FND_MSG_PUB.Add;
89 end if;
90 end if;
91 
92 if ((p_region_code is null) or
93 (p_region_code = FND_API.G_MISS_CHAR)) then
94 l_error := TRUE;
95 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
96 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
97 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_CODE');
98 FND_MSG_PUB.Add;
99 end if;
100 end if;
101 
102 if ((p_graph_number is null) or
103 (p_graph_number =  FND_API.G_MISS_NUM)) then
104 l_error := TRUE;
105 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
106 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
107 FND_MESSAGE.SET_TOKEN('COLUMN', 'ATTRIBUTE_CODE');
108 FND_MSG_PUB.Add;
109 end if;
110 end if;
111 
112 -- - Check that the parent region exists and retrieve the
113 --   database object name referenced by the parent region
114 open l_check_region_csr;
115 fetch l_check_region_csr into l_reg_style;
116 if (l_check_region_csr%notfound) then
117 l_error := TRUE;
118 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
119 FND_MESSAGE.SET_NAME('AK','AK_INVALID_REGION_REFERENCE');
120 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
121 ' ' || p_region_code );
122 FND_MSG_PUB.Add;
123 end if;
124 --dbms_output.put_line('Parent region does not exist!');
125 end if;
126 if (l_reg_style <> 'GRAPH_DATA') then
127 l_error := TRUE;
128 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
129 FND_MESSAGE.SET_NAME('AK','AK_INVALID_REGION_STYLE');
130 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
131 ' ' || p_region_code );
132 FND_MSG_PUB.Add;
133 end if;
134 end if;
135 close l_check_region_csr;
136 
137 --** check that required columns are not null and, unless calling  **
138 --** from UPDATE procedure, the columns are not missing            **
139 
140 if ((p_graph_style is null) or
141 (p_graph_style = FND_API.G_MISS_NUM and
142 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
143 l_error := TRUE;
144 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
145 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
146 FND_MESSAGE.SET_TOKEN('COLUMN', 'GRAPH_STYLE');
147 FND_MSG_PUB.Add;
148 end if;
149 end if;
150 
151 if ((p_display_flag is null) or
152 (p_display_flag = FND_API.G_MISS_CHAR and
153 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
154 l_error := TRUE;
155 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
156 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
157 FND_MESSAGE.SET_TOKEN('COLUMN', 'DISPLAY_FLAG');
158 FND_MSG_PUB.Add;
159 end if;
160 end if;
161 
162 -- === Validate columns ===
163 --
164 -- display_flag
165 --
166 if (p_display_flag <> FND_API.G_MISS_CHAR) then
167 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_display_flag)) then
168 l_error := TRUE;
169 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
170 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
171 FND_MESSAGE.SET_TOKEN('COLUMN','DISPLAY_FLAG');
172 FND_MSG_PUB.Add;
173 end if;
174 end if;
175 end if;
176 
177 
178 -- return true if no error, false otherwise
179 p_return_status := FND_API.G_RET_STS_SUCCESS;
180 return (not l_error);
181 
182 EXCEPTION
183 WHEN FND_API.G_EXC_ERROR THEN
184 p_return_status := FND_API.G_RET_STS_ERROR;
185 return FALSE;
186 WHEN OTHERS THEN
187 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
188 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
189 SUBSTR (SQLERRM, 1, 240) );
190 FND_MSG_PUB.Add;
191 return FALSE;
192 
193 end VALIDATE_GRAPH;
194 */
195 
196 --=======================================================
197 --  Function    VALIDATE_ITEM
198 --
199 --  Usage       Private API for validating a region item. This
200 --              API should only be called by other APIs that are
201 --              owned by the Core Modules Team (AK).
202 --
203 --  Desc        Perform validation on a region item record.
204 --
205 --  Results     The API returns the standard p_return_status parameter
206 --              indicating one of the standard return statuses :
207 --                  * Unexpected error
208 --                  * Error
209 --                  * Success
210 --              In addition, this function returns TRUE if all
211 --              validation tests are passed, or FALSE otherwise.
212 --  Parameters  Region item columns
213 --              p_caller : IN required
214 --                  Must be one of the following values defined
215 --                  in package AK_ON_OBJECTS_PVT:
216 --                  - G_CREATE   (if calling from the Create API)
217 --                  - G_DOWNLOAD (if calling from the Download API)
218 --                  - G_UPDATE   (if calling from the Update API)
219 --
220 --  Note        This API is intended for performing record-level
221 --              validation. It is not designed for item-level
222 --              validation.
223 --
224 --  Version     Initial version number  =   1.0
225 --  History     Current version number  =   1.0
226 --=======================================================
227 function VALIDATE_ITEM (
228 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
229 p_api_version_number       IN      NUMBER,
230 p_return_status            OUT NOCOPY     VARCHAR2,
231 p_region_application_id    IN      NUMBER,
232 p_region_code              IN      VARCHAR2,
233 p_attribute_application_id IN      NUMBER := FND_API.G_MISS_NUM,
234 p_attribute_code           IN      VARCHAR2 := FND_API.G_MISS_CHAR,
235 p_display_sequence         IN      NUMBER := FND_API.G_MISS_NUM,
236 p_node_display_flag        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
237 p_node_query_flag          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
238 p_attribute_label_length   IN      NUMBER := FND_API.G_MISS_NUM,
239 p_display_value_length     IN      NUMBER := FND_API.G_MISS_NUM,
240 p_bold                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
241 p_italic                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
242 p_vertical_alignment       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
243 p_horizontal_alignment     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
244 p_item_style               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
245 p_object_attribute_flag    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
246 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
247 p_update_flag              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
248 p_required_flag            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
249 p_security_code            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
250 p_default_value_varchar2   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
251 p_default_value_number     IN      NUMBER := FND_API.G_MISS_NUM,
252 p_default_value_date       IN      DATE := FND_API.G_MISS_DATE,
253 p_nested_region_appl_id IN     NUMBER := FND_API.G_MISS_NUM,
254 p_nested_region_code       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
255 p_lov_region_application_id IN     NUMBER := FND_API.G_MISS_NUM,
256 p_lov_region_code          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
257 p_lov_foreign_key_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
258 p_lov_attribute_application_id IN  NUMBER := FND_API.G_MISS_NUM,
259 p_lov_attribute_code       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
260 p_lov_default_flag         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
261 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
262 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
263 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
264 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
265 p_order_sequence           IN      NUMBER := FND_API.G_MISS_NUM,
266 p_order_direction          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
267 p_menu_name		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
268 p_flexfield_name	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
269 p_flexfield_application_id IN      NUMBER   := FND_API.G_MISS_NUM,
270 p_tabular_function_code    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
271 p_tip_type                 IN      VARCHAR2 := FND_API.G_MISS_CHAR,
272 p_tip_message_name         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
273 p_tip_message_application_id   IN      NUMBER   := FND_API.G_MISS_NUM,
274 p_flex_segment_list        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
275 p_entity_id                IN      VARCHAR2 := FND_API.G_MISS_CHAR,
276 p_anchor                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
277 p_poplist_view_usage_name  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
278 p_user_customizable	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
279 p_sortby_view_attribute_name   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
280 p_invoke_function_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
281 p_expansion		     IN      NUMBER := FND_API.G_MISS_NUM,
282 p_als_max_length	     IN      NUMBER := FND_API.G_MISS_NUM,
283 p_initial_sort_sequence    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
284 p_customization_application_id IN  NUMBER := FND_API.G_MISS_NUM,
285 p_customization_code	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
286 p_attribute_label_long     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
287 p_attribute_label_short    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
288 p_caller                   IN      VARCHAR2,
289 p_pass                     IN      NUMBER := 2
290 ) return BOOLEAN is
291 cursor l_check_region_csr is
292 select  database_object_name
293 from    AK_REGIONS
294 where   region_application_id = p_region_application_id
295 and     region_code = p_region_code;
296 cursor l_check_seq_csr is
297 select  1
298 from    AK_REGION_ITEMS
299 where   region_application_id = p_region_application_id
300 and     region_code = p_region_code
301 and     display_sequence = p_display_sequence
302 and     ( (attribute_application_id <> p_attribute_application_id)
303 or        (attribute_code <> p_attribute_code) );
304 cursor l_check_menu_name (param_menu_name varchar2) is
305 select 1
306 from FND_MENUS_VL
307 where menu_name = param_menu_name;
308 cursor l_check_flexfield_name (param_flexfield_name varchar2,
309 param_flexfield_application_id number) is
310 select 1
311 from  FND_DESCRIPTIVE_FLEXS FLEX
312 where FLEX.DESCRIPTIVE_FLEXFIELD_NAME not like '$SRS$.%'
313 and   FLEX.DESCRIPTIVE_FLEXFIELD_NAME = param_flexfield_name
314 and   FLEX.APPLICATION_ID = param_flexfield_application_id
315 union
316 select 1
317 from  FND_ID_FLEXS FLEX
318 where FLEX.ID_FLEX_CODE = param_flexfield_name
319 and   FLEX.APPLICATION_ID = param_flexfield_application_id;
320 
321 cursor l_check_message_name (param_message_name varchar2,
322 param_message_application_id number) is
323 select 1
324 from  FND_NEW_MESSAGES MSG
325 where MSG.MESSAGE_NAME = param_message_name
326 and   MSG.APPLICATION_ID = param_message_application_id;
327 
328 cursor l_check_entity_id (param_entity_id varchar2) is
329 select 1
330 from FND_DOCUMENT_ENTITIES
331 where data_object_code = param_entity_id;
332 l_api_version_number      CONSTANT number := 1.0;
333 l_api_name                CONSTANT varchar2(30) := 'Validate_Item';
334 l_database_object_name    VARCHAR2(30);
335 l_dummy                   NUMBER;
336 l_error                   BOOLEAN;
337 l_return_status           VARCHAR2(1);
338 begin
339 
340 IF NOT FND_API.Compatible_API_Call (
341 l_api_version_number, p_api_version_number, l_api_name,
342 G_PKG_NAME) then
343 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
344 return FALSE;
345 END IF;
346 
347 l_error := FALSE;
348 
349 --** if validation level is none, no validation is necessary
350 if (p_validation_level = FND_API.G_VALID_LEVEL_NONE) then
351 p_return_status := FND_API.G_RET_STS_SUCCESS;
352 return TRUE;
353 end if;
354 
355 --** check that key columns are not null and not missing **
356 if ((p_region_application_id is null) or
357 (p_region_application_id = FND_API.G_MISS_NUM)) then
358 l_error := TRUE;
359 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
360 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
361 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_APPLICATION_ID');
362 FND_MSG_PUB.Add;
363 end if;
364 end if;
365 
366 if ((p_region_code is null) or
367 (p_region_code = FND_API.G_MISS_CHAR)) then
368 l_error := TRUE;
369 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
370 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
371 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_CODE');
372 FND_MSG_PUB.Add;
373 end if;
374 end if;
375 
376 if ((p_attribute_application_id is null) or
377 (p_attribute_application_id = FND_API.G_MISS_NUM)) then
378 l_error := TRUE;
379 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
380 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
381 FND_MESSAGE.SET_TOKEN('COLUMN', 'ATTRIBUTE_APPLICATION_ID');
382 FND_MSG_PUB.Add;
383 end if;
384 end if;
385 
386 if ((p_attribute_code is null) or
387 (p_attribute_code = FND_API.G_MISS_CHAR)) then
388 l_error := TRUE;
389 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
390 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
391 FND_MESSAGE.SET_TOKEN('COLUMN', 'ATTRIBUTE_CODE');
392 FND_MSG_PUB.Add;
393 end if;
394 end if;
395 
396 -- - Check that the parent region exists and retrieve the
397 --   database object name referenced by the parent region
398 open l_check_region_csr;
399 fetch l_check_region_csr into l_database_object_name;
400 if (l_check_region_csr%notfound) then
401 l_error := TRUE;
402 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
403 FND_MESSAGE.SET_NAME('AK','AK_INVALID_REGION_REFERENCE');
404 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
405 ' ' || p_region_code );
406 FND_MSG_PUB.Add;
407 end if;
408 --dbms_output.put_line('Parent region does not exist!');
409 end if;
410 close l_check_region_csr;
411 
412 --
413 --   Check that the attribute or object attribute referenced exists
414 --
415 if (p_object_attribute_flag = 'Y') then
416 if (NOT AK_OBJECT_PVT.ATTRIBUTE_EXISTS (
417 p_api_version_number => 1.0,
418 p_return_status => l_return_status,
419 p_database_object_name => l_database_object_name,
420 p_attribute_application_id => p_attribute_application_id,
421 p_attribute_code => p_attribute_code) ) then
422 l_error := TRUE;
423 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
424 FND_MESSAGE.SET_NAME('AK','AK_INVALID_OA_REFERENCE');
425 FND_MESSAGE.SET_TOKEN('KEY', l_database_object_name ||
426 ' ' || to_char(p_attribute_application_id) ||
427 ' ' || p_attribute_code);
428 FND_MSG_PUB.Add;
429 end if;
430 RAISE FND_API.G_EXC_ERROR;
431 --dbms_output.put_line('Object Attribute referenced does not exist!');
432 end if;
433 else
434 if (NOT AK_ATTRIBUTE_PVT.ATTRIBUTE_EXISTS (
435 p_api_version_number => 1.0,
436 p_return_status => l_return_status,
437 p_attribute_application_id => p_attribute_application_id,
438 p_attribute_code => p_attribute_code) ) then
439 l_error := TRUE;
440 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
441 FND_MESSAGE.SET_NAME('AK','AK_INVALID_ATTR_REFERENCE');
442 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_attribute_application_id) ||
443 ' ' || p_attribute_code);
444 FND_MSG_PUB.Add;
445 end if;
446 RAISE FND_API.G_EXC_ERROR;
447 -- dbms_output.put_line('Attribute referenced does not exist!');
448 end if;
449 end if;
450 
451 --** check that required columns are not null and, unless calling  **
452 --** from UPDATE procedure, the columns are not missing            **
453 
454 if ((p_display_sequence is null) or
455 (p_display_sequence = FND_API.G_MISS_NUM and
456 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
457 l_error := TRUE;
458 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
459 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
460 FND_MESSAGE.SET_TOKEN('COLUMN', 'DISPLAY_SEQUENCE');
461 FND_MSG_PUB.Add;
462 end if;
463 end if;
464 
465 if ((p_node_display_flag is null) or
466 (p_node_display_flag = FND_API.G_MISS_CHAR and
467 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
468 l_error := TRUE;
469 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
470 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
471 FND_MESSAGE.SET_TOKEN('COLUMN', 'NODE_DISPLAY_FLAG');
472 FND_MSG_PUB.Add;
473 end if;
474 end if;
475 
476 if ((p_node_query_flag is null) or
477 (p_node_query_flag = FND_API.G_MISS_CHAR and
478 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
479 l_error := TRUE;
480 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
481 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
482 FND_MESSAGE.SET_TOKEN('COLUMN', 'NODE_QUERY_FLAG');
483 FND_MSG_PUB.Add;
484 end if;
485 end if;
486 
487 if ((p_attribute_label_length is null) or
488 (p_attribute_label_length = FND_API.G_MISS_NUM and
489 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
490 l_error := TRUE;
491 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
492 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
493 FND_MESSAGE.SET_TOKEN('COLUMN', 'ATTRIBUTE_LABEL_LENGTH');
494 FND_MSG_PUB.Add;
495 end if;
496 end if;
497 
498 if ((p_display_value_length is null) or
499 (p_display_value_length = FND_API.G_MISS_NUM and
500 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
501 l_error := TRUE;
502 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
503 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
504 FND_MESSAGE.SET_TOKEN('COLUMN', 'DISPLAY_VALUE_LENGTH');
505 FND_MSG_PUB.Add;
506 end if;
507 end if;
508 
509 if ((p_bold is null) or
510 (p_bold = FND_API.G_MISS_CHAR and
511 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
512 l_error := TRUE;
513 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
514 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
515 FND_MESSAGE.SET_TOKEN('COLUMN', 'BOLD');
516 FND_MSG_PUB.Add;
517 end if;
518 end if;
519 
520 if ((p_italic is null) or
521 (p_italic = FND_API.G_MISS_CHAR and
522 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
523 l_error := TRUE;
524 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
525 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
526 FND_MESSAGE.SET_TOKEN('COLUMN','ITALIC');
527 FND_MSG_PUB.Add;
528 end if;
529 end if;
530 
531 if ((p_vertical_alignment is null) or
532 (p_vertical_alignment = FND_API.G_MISS_CHAR and
533 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
534 l_error := TRUE;
535 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
536 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
537 FND_MESSAGE.SET_TOKEN('COLUMN', 'VERTICAL_ALIGNMENT');
538 FND_MSG_PUB.Add;
539 end if;
540 end if;
541 
542 if ((p_horizontal_alignment is null) or
543 (p_horizontal_alignment = FND_API.G_MISS_CHAR and
544 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
545 l_error := TRUE;
546 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
547 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
548 FND_MESSAGE.SET_TOKEN('COLUMN', 'HORIZONTAL_ALIGNMENT');
549 FND_MSG_PUB.Add;
550 end if;
551 end if;
552 
553 if ((p_item_style is null) or
554 (p_item_style = FND_API.G_MISS_CHAR and
555 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
556 l_error := TRUE;
557 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
558 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
559 FND_MESSAGE.SET_TOKEN('COLUMN', 'ITEM_SYTLE');
560 FND_MSG_PUB.Add;
561 end if;
562 end if;
563 
564 if ((p_object_attribute_flag is null) or
565 (p_object_attribute_flag = FND_API.G_MISS_CHAR and
566 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
567 l_error := TRUE;
568 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
569 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
570 FND_MESSAGE.SET_TOKEN('COLUMN', 'OBJECT_ATTRIBUTE_FLAG');
571 FND_MSG_PUB.Add;
572 end if;
573 end if;
574 
575 if ((p_update_flag is null) or
576 (p_update_flag = FND_API.G_MISS_CHAR and
577 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
578 l_error := TRUE;
579 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
580 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
581 FND_MESSAGE.SET_TOKEN('COLUMN', 'UPDATE_FLAG');
582 FND_MSG_PUB.Add;
583 end if;
584 end if;
585 
586 if ((p_required_flag is null) or
587 (p_required_flag = FND_API.G_MISS_CHAR and
588 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
589 l_error := TRUE;
590 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
591 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
592 FND_MESSAGE.SET_TOKEN('COLUMN', 'REQUIRED_FLAG');
593 FND_MSG_PUB.Add;
594 end if;
595 end if;
596 
597 -- === Validate columns ===
598 --
599 -- display_sequence
600 --
601 if (p_display_sequence <> FND_API.G_MISS_NUM) then
602 open l_check_seq_csr;
603 fetch l_check_seq_csr into l_dummy;
604 if (l_check_seq_csr%found) then
605 l_error := TRUE;
606 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
607 FND_MESSAGE.SET_NAME('AK','AK_UNIQUE_DISPLAY_SEQUENCE');
608 FND_MSG_PUB.Add;
609 end if;
610 end if;
611 close l_check_seq_csr;
612 end if;
613 
614 -- - node_display_flag
615 if (p_node_display_flag <> FND_API.G_MISS_CHAR) then
616 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_node_display_flag)) then
617 l_error := TRUE;
618 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
619 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
620 FND_MESSAGE.SET_TOKEN('COLUMN','NODE_DISPLAY_FLAG');
621 FND_MSG_PUB.Add;
622 end if;
623 end if;
624 end if;
625 
626 -- - node_query_flag
627 if (p_node_query_flag <> FND_API.G_MISS_CHAR) then
628 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_node_query_flag)) then
629 l_error := TRUE;
630 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
631 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
632 FND_MESSAGE.SET_TOKEN('COLUMN','NODE_QUERY_FLAG');
633 FND_MSG_PUB.Add;
634 end if;
635 end if;
636 end if;
637 
638 -- - bold
639 if (p_bold <> FND_API.G_MISS_CHAR) then
640 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_bold)) then
641 l_error := TRUE;
642 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
643 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
644 FND_MESSAGE.SET_TOKEN('COLUMN','BOLD');
645 FND_MSG_PUB.Add;
646 end if;
647 end if;
648 end if;
649 
650 -- - italic
651 if (p_italic <> FND_API.G_MISS_CHAR) then
652 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_italic)) then
653 l_error := TRUE;
654 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
655 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
656 FND_MESSAGE.SET_TOKEN('COLUMN','ITALIC');
657 FND_MSG_PUB.Add;
658 end if;
659 end if;
660 end if;
661 
662 -- - vertical alignment
663 if (p_vertical_alignment <> FND_API.G_MISS_CHAR) then
664 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
665 p_api_version_number => 1.0,
666 p_return_status => l_return_status,
667 p_lookup_type  => 'VERTICAL_ALIGNMENT',
668 p_lookup_code => p_vertical_alignment)) then
669 l_error := TRUE;
670 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
671 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
672 FND_MESSAGE.SET_TOKEN('COLUMN','VERTICAL_ALIGNMENT');
673 FND_MSG_PUB.Add;
674 end if;
675 end if;
676 end if;
677 
678 -- - horizontal alignment
679 if (p_horizontal_alignment <> FND_API.G_MISS_CHAR) then
680 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
681 p_api_version_number => 1.0,
682 p_return_status => l_return_status,
683 p_lookup_type  => 'HORIZONTAL_ALIGNMENT',
684 p_lookup_code => p_horizontal_alignment)) then
685 l_error := TRUE;
686 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
687 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
688 FND_MESSAGE.SET_TOKEN('COLUMN','HORIZONTAL_ALIGNMENT');
689 FND_MSG_PUB.Add;
690 end if;
691 end if;
692 end if;
693 
694 -- - item style
695 if (p_item_style <> FND_API.G_MISS_CHAR) then
696 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
697 p_api_version_number => 1.0,
698 p_return_status => l_return_status,
699 p_lookup_type  => 'ITEM_STYLE',
700 p_lookup_code => p_item_style)) then
701 l_error := TRUE;
702 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
703 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
704 FND_MESSAGE.SET_TOKEN('COLUMN','ITEM_STYLE');
705 FND_MSG_PUB.Add;
706 end if;
707 end if;
708 end if;
709 
710 -- - object attribute flag
711 if (p_object_attribute_flag <> FND_API.G_MISS_CHAR) then
712 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_object_attribute_flag)) then
713 l_error := TRUE;
714 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
715 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
716 FND_MESSAGE.SET_TOKEN('COLUMN','OBJECT_ATTRIBUTE_FLAG');
717 FND_MSG_PUB.Add;
718 end if;
719 end if;
720 end if;
721 
722 -- - update_flag
723 if (p_update_flag <> FND_API.G_MISS_CHAR) then
724 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_update_flag)) then
725 l_error := TRUE;
726 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
727 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
728 FND_MESSAGE.SET_TOKEN('COLUMN','UPDATE_FLAG');
729 FND_MSG_PUB.Add;
730 end if;
731 end if;
732 end if;
733 
734 -- - required_flag
735 if (p_required_flag <> FND_API.G_MISS_CHAR) then
736 if (NOT AK_ON_OBJECTS_PVT.VALID_YES_NO(p_required_flag)) then
737 l_error := TRUE;
738 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
739 FND_MESSAGE.SET_NAME('AK','AK_VALUE_NOT_YES_NO');
740 FND_MESSAGE.SET_TOKEN('COLUMN','REQUIRED_FLAG');
741 FND_MSG_PUB.Add;
742 end if;
743 end if;
744 end if;
745 
746 -- - nested_region_application_id and nested_region_code
747 if ( (p_nested_region_appl_id <> FND_API.G_MISS_NUM) and
748 (p_nested_region_appl_id is not null) ) or
749 ( (p_nested_region_code <> FND_API.G_MISS_CHAR) and
750 (p_nested_region_code is not null) )then
751 if (NOT AK_REGION_PVT.REGION_EXISTS(
752 p_api_version_number => 1.0,
753 p_return_status => l_return_status,
754 p_region_application_id => p_nested_region_appl_id,
755 p_region_code => p_nested_region_code)) then
756 l_error := TRUE;
757 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
758 FND_MESSAGE.SET_NAME('AK','AK_NST_REG_DOES_NOT_EXIST');
759 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_nested_region_appl_id) || ' ' || p_nested_region_code);
760 FND_MSG_PUB.Add;
761 end if;
762 end if;
763 end if;
764 
765 -- - lov_region_application_id and lov_region_code
766 if ( (p_lov_region_application_id <> FND_API.G_MISS_NUM) and
767 (p_lov_region_application_id is not null) ) or
768 ( (p_lov_region_code <> FND_API.G_MISS_CHAR) and
769 (p_lov_region_code is not null) )then
770 if (NOT AK_REGION_PVT.REGION_EXISTS(
771 p_api_version_number => 1.0,
772 p_return_status => l_return_status,
773 p_region_application_id => p_lov_region_application_id,
774 p_region_code => p_lov_region_code)) then
775 l_error := TRUE;
776 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
777 FND_MESSAGE.SET_NAME('AK','AK_LOV_REG_DOES_NOT_EXIST');
778 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_lov_region_application_id) || ' ' || p_lov_region_code);
779 FND_MSG_PUB.Add;
780 end if;
781 end if;
782 end if;
783 
784 -- - lov_attribute_application_id and lov_attribute_code
785 if ( (p_lov_attribute_application_id <> FND_API.G_MISS_NUM) and
786 (p_lov_attribute_application_id is not null) ) or
787 ( (p_lov_attribute_code <> FND_API.G_MISS_CHAR) and
788 (p_lov_attribute_code is not null) )then
789 if (NOT AK_REGION_PVT.ITEM_EXISTS(
790 p_api_version_number => 1.0,
791 p_return_status => l_return_status,
792 p_region_application_id => p_lov_region_application_id,
793 p_region_code => p_lov_region_code,
794 p_attribute_application_id => p_lov_attribute_application_id,
795 p_attribute_code => p_lov_attribute_code)) then
796 l_error := TRUE;
797 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
798 FND_MESSAGE.SET_NAME('AK','AK_INVALID_LOV_ITEM_REFERENCE');
799 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id)||' '||p_region_code||' '||
800 to_char(p_attribute_application_id) ||' ' || p_attribute_code);
801 FND_MSG_PUB.Add;
802 end if;
803 end if;
804 end if;
805 
806 -- - lov_foreign_key
807 if (p_lov_foreign_key_name <> FND_API.G_MISS_CHAR) and
808 (p_lov_foreign_key_name is not null) then
809 if (NOT AK_KEY_PVT.FOREIGN_KEY_EXISTS(
810 p_api_version_number => 1.0,
811 p_return_status => l_return_status,
812 p_foreign_key_name => p_lov_foreign_key_name)) then
813 l_error := TRUE;
814 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
815 FND_MESSAGE.SET_NAME('AK','AK_INVALID_LOV_FK_REFERENCE');
816 FND_MSG_PUB.Add;
817 end if;
818 end if;
819 end if;
820 
821 -- - lov_default_flag
822 if (p_lov_default_flag <> FND_API.G_MISS_CHAR) then
823 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
824 p_api_version_number => 1.0,
825 p_return_status => l_return_status,
826 p_lookup_type  => 'LOV_DEFAULT_FLAG',
827 p_lookup_code => p_lov_default_flag)) then
828 l_error := TRUE;
829 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
830 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
831 FND_MESSAGE.SET_TOKEN('COLUMN','LOV_DEFAULT_FLAG');
832 FND_MSG_PUB.Add;
833 end if;
834 end if;
835 end if;
836 
837 -- - order_direction
838 if (p_order_direction <> FND_API.G_MISS_CHAR) then
839 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
840 p_api_version_number => 1.0,
841 p_return_status => l_return_status,
842 p_lookup_type  => 'ORDER_DIRECTION',
843 p_lookup_code => p_order_direction)) then
844 l_error := TRUE;
845 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
846 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
847 FND_MESSAGE.SET_TOKEN('COLUMN','ORDER_DIRECTION');
848 FND_MSG_PUB.Add;
849 end if;
850 end if;
851 end if;
852 
853 -- - menu_name
854 if (p_menu_name <> FND_API.G_MISS_CHAR and p_menu_name is not null) then
855 open l_check_menu_name(p_menu_name);
856 fetch l_check_menu_name into l_dummy;
857 if ( l_check_menu_name%notfound) then
858 l_error := TRUE;
859 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
860 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
861 FND_MESSAGE.SET_TOKEN('COLUMN','MENU_NAME');
862 FND_MSG_PUB.Add;
863 end if;
864 end if;
865 close l_check_menu_name;
866 end if;
867 
868 -- - flexfield_name
869 if (p_flexfield_name <> FND_API.G_MISS_CHAR and p_flexfield_name is not null) then
870 open l_check_flexfield_name(p_flexfield_name, p_flexfield_application_id);
871 fetch l_check_flexfield_name into l_dummy;
872 if ( l_check_flexfield_name%notfound) then
873 l_error := TRUE;
874 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
875 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
876 FND_MESSAGE.SET_TOKEN('COLUMN','FLEXFIELD_NAME');
877 FND_MSG_PUB.Add;
878 end if;
879 end if;
880 close l_check_flexfield_name;
881 end if;
882 
883 -- tip message
884 if (p_tip_message_name <> FND_API.G_MISS_CHAR and p_tip_message_name is not null) then
885 open l_check_message_name(p_tip_message_name, p_tip_message_application_id);
886 fetch l_check_message_name into l_dummy;
887 if ( l_check_message_name%notfound) then
888 l_error := TRUE;
889 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
890 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
891 FND_MESSAGE.SET_TOKEN('COLUMN','TIP_MESSAGE_NAME');
892 FND_MSG_PUB.Add;
893 end if;
894 end if;
895 close l_check_message_name;
896 end if;
897 
898 -- entity id
899 if (p_entity_id <> FND_API.G_MISS_CHAR and p_entity_id is not null) then
900 open l_check_entity_id(p_entity_id);
901 fetch l_check_entity_id into l_dummy;
902 if ( l_check_entity_id%notfound) then
903 l_error := TRUE;
904 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
905 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
906 FND_MESSAGE.SET_TOKEN('COLUMN','ENTITY_ID');
907 FND_MSG_PUB.Add;
908 end if;
909 end if;
910 close l_check_entity_id;
911 end if;
912 
913 -- initial_sort_sequence
914 if (p_initial_sort_sequence <> FND_API.G_MISS_CHAR and
915 p_initial_sort_sequence is not null) then
916 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
917 p_api_version_number => 1.0,
918 p_return_status => l_return_status,
919 p_lookup_type  => 'INIT_SORT_TYPE',
920 p_lookup_code => p_initial_sort_sequence)) then
921 l_error := TRUE;
922 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass =
923 2) then
924 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
925 FND_MESSAGE.SET_TOKEN('COLUMN','INITIAL_SORT_SEQUENCE');
926 FND_MSG_PUB.Add;
927 end if;
928 end if;
929 end if;
930 
931 -- return true if no error, false otherwise
932 p_return_status := FND_API.G_RET_STS_SUCCESS;
933 return (not l_error);
934 
935 EXCEPTION
936 WHEN FND_API.G_EXC_ERROR THEN
937 p_return_status := FND_API.G_RET_STS_ERROR;
938 return FALSE;
939 WHEN OTHERS THEN
940 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
941 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
942 SUBSTR (SQLERRM, 1, 240) );
943 FND_MSG_PUB.Add;
944 return FALSE;
945 
946 end VALIDATE_ITEM;
947 
948 --=======================================================
949 --  Function    VALIDATE_REGION
950 --
951 --  Usage       Private API for validating a region. This
952 --              API should only be called by other APIs that are
953 --              owned by the Core Modules Team (AK).
954 --
955 --  Desc        Perform validation on a region record.
956 --
957 --  Results     The API returns the standard p_return_status parameter
958 --              indicating one of the standard return statuses :
959 --                  * Unexpected error
960 --                  * Error
961 --                  * Success
962 --              In addition, this function returns TRUE if all
963 --              validation tests are passed, or FALSE otherwise.
964 --  Parameters  Region columns
965 --              p_caller : IN required
966 --                  Must be one of the following values defined
967 --                  in package AK_ON_OBJECTS_PVT:
968 --                  - G_CREATE   (if calling from the Create API)
969 --                  - G_DOWNLOAD (if calling from the Download API)
970 --                  - G_UPDATE   (if calling from the Update API)
971 --
972 --  Note        This API is intended for performing record-level
973 --              validation. It is not designed for item-level
974 --              validation.
975 --
976 --  Version     Initial version number  =   1.0
977 --  History     Current version number  =   1.0
978 --=======================================================
979 function VALIDATE_REGION (
980 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
981 p_api_version_number       IN      NUMBER,
982 p_return_status            OUT NOCOPY     VARCHAR2,
983 p_region_application_id    IN      NUMBER := FND_API.G_MISS_NUM,
984 p_region_code              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
985 p_database_object_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
986 p_region_style             IN      VARCHAR2 := FND_API.G_MISS_CHAR,
987 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
988 p_num_columns              IN      NUMBER := FND_API.G_MISS_NUM,
989 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
990 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
991 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
992 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
993 p_name                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
994 p_description              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
995 p_caller                   IN      VARCHAR2,
996 p_pass                     IN      NUMBER := 2
997 ) return BOOLEAN is
998 l_api_version_number CONSTANT number := 1.0;
999 l_api_name           CONSTANT varchar2(30) := 'Validate_Region';
1000 l_error              BOOLEAN;
1001 l_return_status      varchar2(1);
1002 begin
1003 
1004 IF NOT FND_API.Compatible_API_Call (
1005 l_api_version_number, p_api_version_number, l_api_name,
1006 G_PKG_NAME) then
1007 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1008 return FALSE;
1009 END IF;
1010 
1011 l_error := FALSE;
1012 
1013 --** if validation level is none, no validation is necessary
1014 if (p_validation_level = FND_API.G_VALID_LEVEL_NONE) then
1015 p_return_status := FND_API.G_RET_STS_SUCCESS;
1016 return TRUE;
1017 end if;
1018 
1019 --** check that key columns are not null and not missing **
1020 if ((p_region_application_id is null) or
1021 (p_region_application_id = FND_API.G_MISS_NUM)) then
1022 l_error := TRUE;
1023 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1024 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
1025 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_APPLICATION_ID');
1026 FND_MSG_PUB.Add;
1027 end if;
1028 end if;
1029 
1030 if ((p_region_code is null) or
1031 (p_region_code = FND_API.G_MISS_CHAR)) then
1032 l_error := TRUE;
1033 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1034 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
1035 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_CODE');
1036 FND_MSG_PUB.Add;
1037 end if;
1038 end if;
1039 
1040 --** check that required columns are not null and, unless calling  **
1041 --** from UPDATE procedure, the columns are not missing            **
1042 if ((p_database_object_name is null) or
1043 (p_database_object_name = FND_API.G_MISS_CHAR and
1044 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
1045 l_error := TRUE;
1046 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1047 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
1048 FND_MESSAGE.SET_TOKEN('COLUMN', 'DATABASE_OBJECT_NAME');
1049 FND_MSG_PUB.Add;
1050 end if;
1051 end if;
1052 
1053 if (p_region_style is null) or
1054 ((p_region_style = FND_API.G_MISS_CHAR) and
1055 (p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
1056 l_error := TRUE;
1057 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1058 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
1059 FND_MESSAGE.SET_TOKEN('COLUMN', 'REGION_STYLE');
1060 FND_MSG_PUB.Add;
1061 end if;
1062 end if;
1063 
1064 if ((p_name is null) or
1065 (p_name = FND_API.G_MISS_CHAR and
1066 p_caller <> AK_ON_OBJECTS_PVT.G_UPDATE)) then
1067 l_error := TRUE;
1068 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1069 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_BE_NULL');
1070 FND_MESSAGE.SET_TOKEN('COLUMN', 'NAME');
1071 FND_MSG_PUB.Add;
1072 end if;
1073 end if;
1074 
1075 --** Validate columns **
1076 -- - Database object name
1077 if (p_database_object_name <> FND_API.G_MISS_CHAR) then
1078 if (NOT AK_OBJECT_PVT.OBJECT_EXISTS (
1079 p_api_version_number => 1.0,
1080 p_return_status => l_return_status,
1081 p_database_object_name => p_database_object_name)) then
1082 l_error := TRUE;
1083 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1084 FND_MESSAGE.SET_NAME('AK','AK_INVALID_OBJECT_REFERENCE');
1085 FND_MESSAGE.SET_TOKEN('KEY', p_database_object_name);
1086 FND_MSG_PUB.Add;
1087 end if;
1088 --dbms_output.put_line(l_api_name || ' Invalid database object name');
1089 end if;
1090 end if;
1091 
1092 -- - Region style
1093 if (p_region_style <> FND_API.G_MISS_CHAR) then
1094 if (NOT AK_ON_OBJECTS_PVT.VALID_LOOKUP_CODE (
1095 p_api_version_number => 1.0,
1096 p_return_status => l_return_status,
1097 p_lookup_type => 'REGION_STYLE',
1098 p_lookup_code => p_region_style)) then
1099 l_error := TRUE;
1100 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) and (p_pass = 2) then
1101 FND_MESSAGE.SET_NAME('AK','AK_INVALID_COLUMN_VALUE');
1102 FND_MESSAGE.SET_TOKEN('COLUMN','REGION_STYLE');
1103 FND_MSG_PUB.Add;
1104 end if;
1105 --dbms_output.put_line(l_api_name || ' Invalid region style');
1106 end if;
1107 end if;
1108 
1109 -- return true if no error, false otherwise
1110 p_return_status := FND_API.G_RET_STS_SUCCESS;
1111 return (not l_error);
1112 
1113 EXCEPTION
1114 WHEN FND_API.G_EXC_ERROR THEN
1115 p_return_status := FND_API.G_RET_STS_ERROR;
1116 return FALSE;
1117 WHEN OTHERS THEN
1118 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1119 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
1120 SUBSTR (SQLERRM, 1, 240) );
1121 FND_MSG_PUB.Add;
1122 return FALSE;
1123 
1124 end VALIDATE_REGION;
1125 
1126 /*
1127 --=======================================================
1128 --  Procedure   WRITE_GRAPH_COL_TO_BUFFER (local procedure)
1129 --
1130 --  Usage       Local procedure for writing the given region
1131 --              graph column records to the output file.
1132 --              Not designed to be called from outside this package.
1133 --
1134 --  Desc        This procedure writes graph_columns to output file
1135 --
1136 --  Results     The API returns the standard p_return_status parameter
1137 --              indicating one of the standard return statuses :
1138 --                  * Unexpected error
1139 --                  * Error
1140 --                  * Success
1141 --  Parameters
1142 --              p_region_application_id : IN required
1143 --              p_region_code : IN required
1144 --                  Key value of the Category Usage to be extracted to the loader
1145 --                  file.
1146 --              p_attribute_application_id : IN required
1147 --                  Key value of the Category Usage to be extracted to the loader
1148 --                  file.
1149 --              p_attribute_code : IN required
1150 --                  Key value of the Category Usage to be extracted to the loader
1151 --                  file.
1152 --              p_category_id : IN required
1153 --                  Key value of the Category Usage to be extracted to the loader
1154 --                  file.
1155 --              p_nls_language : IN required
1156 --                  The NLS langauge that should be used when
1157 --                  extracting data from the TL table
1158 --=======================================================
1159 procedure WRITE_GRAPH_COL_TO_BUFFER (
1160 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
1161 p_return_status            OUT NOCOPY     VARCHAR2,
1162 p_region_application_id    IN      NUMBER,
1163 p_region_code              IN      VARCHAR2,
1164 p_graph_number	     IN      NUMBER
1165 ) is
1166 cursor l_get_graph_columns_csr is
1167 select *
1168 from AK_REGION_GRAPH_COLUMNS
1169 where REGION_APPLICATION_ID = p_region_application_id
1170 and   REGION_CODE = p_region_code
1171 and   GRAPH_NUMBER = p_graph_number;
1172 l_api_name           CONSTANT varchar2(50) := 'Write_Graph_Col_to_Buffer';
1173 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
1174 l_index              NUMBER;
1175 l_graph_columns_rec   AK_REGION_GRAPH_COLUMNS%ROWTYPE;
1176 l_return_status      varchar2(1);
1177 begin
1178 -- Retrieve region information from the database
1179 
1180 open l_get_graph_columns_csr;
1181 loop
1182 fetch l_get_graph_columns_csr into l_graph_columns_rec;
1183 exit when l_get_graph_columns_csr%notfound;
1184 
1185 -- Region graph column must be validated before it is written to the file
1186 
1187 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
1188 if not AK_REGION2_PVT.VALIDATE_GRAPH_COLUMN (
1189 p_validation_level => p_validation_level,
1190 p_api_version_number => 1.0,
1191 p_return_status => l_return_status,
1192 p_region_application_id => l_graph_columns_rec.region_application_id,
1193 p_region_code => l_graph_columns_rec.region_code,
1194 p_attribute_application_id => l_graph_columns_rec.attribute_application_id,
1195 p_attribute_code => l_graph_columns_rec.attribute_code,
1196 p_graph_number => l_graph_columns_rec.graph_number,
1197 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD)
1198 then
1199 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
1200 FND_MESSAGE.SET_NAME('AK','AK_GRAPH_COLUMN_NOT_DOWNLOADED');
1201 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1202 p_region_code);
1203 FND_MSG_PUB.Add;
1204 end if;
1205 close l_get_graph_columns_csr;
1206 raise FND_API.G_EXC_ERROR;
1207 end if; -- if AK_REGION2_PVT.VALIDATE_GRAPH_COLUMN
1208 end if; -- if p_validation_level
1209 
1210 -- Write region lov relation into buffer
1211 -- write a blank line after region item
1212 l_index := 1;
1213 l_databuffer_tbl(l_index) := ' ';
1214 l_index := l_index + 1;
1215 l_databuffer_tbl(l_index) := '    BEGIN REGION_GRAPH_COLUMN "' ||
1216 nvl(to_char(l_graph_columns_rec.attribute_application_id), '')
1217 || '" "' ||
1218 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_graph_columns_rec.attribute_code) || '" ';
1219 -- - Write out who columns
1220 l_index := l_index + 1;
1221 l_databuffer_tbl(l_index) := '      CREATED_BY = "' ||
1222 nvl(to_char(l_graph_columns_rec.created_by),'') || '"';
1223 l_index := l_index + 1;
1224 l_databuffer_tbl(l_index) := '      CREATION_DATE = "' ||
1225 to_char(l_graph_columns_rec.creation_date,
1226 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1227 l_index := l_index + 1;
1228 l_databuffer_tbl(l_index) := '      LAST_UPDATED_BY = "' ||
1229 nvl(to_char(l_graph_columns_rec.last_updated_by),'') || '"';
1230 l_index := l_index + 1;
1231 l_databuffer_tbl(l_index) := '      LAST_UPDATE_DATE = "' ||
1232 to_char(l_graph_columns_rec.last_update_date,
1233 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1234 l_index := l_index + 1;
1235 l_databuffer_tbl(l_index) := '      LAST_UPDATE_LOGIN = "' ||
1236 nvl(to_char(l_graph_columns_rec.last_update_login),'') || '"';
1237 
1238 l_index := l_index + 1;
1239 l_databuffer_tbl(l_index) := '    END REGION_GRAPH_COLUMN';
1240 l_index := l_index + 1;
1241 l_databuffer_tbl(l_index) := ' ';
1242 
1243 -- - Write the 'END REGION_GRAPH_COLUMN' to the specified file
1244 AK_ON_OBJECTS_PVT.WRITE_FILE (
1245 p_return_status => l_return_status,
1246 p_buffer_tbl => l_databuffer_tbl,
1247 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
1248 );
1249 -- If API call returns with an error status...
1250 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1251 (l_return_status = FND_API.G_RET_STS_ERROR) then
1252 close l_get_graph_columns_csr;
1253 RAISE FND_API.G_EXC_ERROR;
1254 end if;
1255 
1256 end loop;
1257 close l_get_graph_columns_csr;
1258 
1259 p_return_status := FND_API.G_RET_STS_SUCCESS;
1260 
1261 EXCEPTION
1262 WHEN VALUE_ERROR THEN
1263 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1264 FND_MESSAGE.SET_NAME('AK','AK_GRAPH_COLUMN_VALUE_ERROR');
1265 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1266 p_region_code);
1267 FND_MSG_PUB.Add;
1268 end if;
1269 p_return_status := FND_API.G_RET_STS_ERROR;
1270 WHEN FND_API.G_EXC_ERROR THEN
1271 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1272 FND_MESSAGE.SET_NAME('AK','AK_GRAPH_COLUMN_NOT_DOWNLOADED');
1273 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1274 p_region_code);
1275 FND_MSG_PUB.Add;
1276 end if;
1277 p_return_status := FND_API.G_RET_STS_ERROR;
1278 WHEN OTHERS THEN
1279 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1280 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
1281 SUBSTR (SQLERRM, 1, 240) );
1282 FND_MSG_PUB.Add;
1283 end WRITE_GRAPH_COL_TO_BUFFER;
1284 */
1285 
1286 --=======================================================
1287 --  Procedure   WRITE_CAT_USAGES_TO_BUFFER (local procedure)
1288 --
1289 --  Usage       Local procedure for writing the given region
1290 --              item category usages records to the output file.
1291 --              Not designed to be called from outside this package.
1292 --
1293 --  Desc        This procedure writes category_usages to output file
1294 --
1295 --  Results     The API returns the standard p_return_status parameter
1296 --              indicating one of the standard return statuses :
1297 --                  * Unexpected error
1298 --                  * Error
1299 --                  * Success
1300 --  Parameters
1301 --              p_region_application_id : IN required
1302 --              p_region_code : IN required
1303 --                  Key value of the Category Usage to be extracted to the loader
1304 --                  file.
1305 --              p_attribute_application_id : IN required
1306 --                  Key value of the Category Usage to be extracted to the loader
1307 --                  file.
1308 --              p_attribute_code : IN required
1309 --                  Key value of the Category Usage to be extracted to the loader
1310 --                  file.
1311 --              p_category_id : IN required
1312 --                  Key value of the Category Usage to be extracted to the loader
1313 --                  file.
1314 --              p_nls_language : IN required
1315 --                  The NLS langauge that should be used when
1316 --                  extracting data from the TL table
1317 --=======================================================
1318 procedure WRITE_CAT_USAGES_TO_BUFFER (
1319 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
1320 p_return_status            OUT NOCOPY     VARCHAR2,
1321 p_region_application_id    IN      NUMBER,
1322 p_region_code              IN      VARCHAR2,
1323 p_attribute_application_id IN		 NUMBER,
1324 p_attribute_code           IN      VARCHAR2
1325 ) is
1326 cursor l_get_category_usages_csr is
1327 select *
1328 from  AK_CATEGORY_USAGES
1329 where REGION_APPLICATION_ID = p_region_application_id
1330 and   REGION_CODE = p_region_code
1331 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
1332 and   ATTRIBUTE_CODE = p_attribute_code;
1333 l_api_name           CONSTANT varchar2(50) := 'Write_category_usages_to_buffer';
1334 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
1335 l_index              NUMBER;
1336 l_category_usage_rec   AK_CATEGORY_USAGES%ROWTYPE;
1337 l_return_status      varchar2(1);
1338 begin
1339 -- Retrieve region information from the database
1340 
1341 open l_get_category_usages_csr;
1342 loop
1343 fetch l_get_category_usages_csr into l_category_usage_rec;
1344 exit when l_get_category_usages_csr%notfound;
1345 
1346 -- Region lov relation must be validated before it is written to the file
1347 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
1348 if not AK_REGION2_PVT.VALIDATE_CATEGORY_USAGE (
1349 p_validation_level => p_validation_level,
1350 p_api_version_number => 1.0,
1351 p_return_status => l_return_status,
1352 p_region_application_id => l_category_usage_rec.region_application_id,
1353 p_region_code => l_category_usage_rec.region_code,
1354 p_attribute_application_id => l_category_usage_rec.attribute_application_id,
1355 p_attribute_code => l_category_usage_rec.attribute_code,
1356 p_category_name => l_category_usage_rec.category_name,
1357 p_category_id => l_category_usage_rec.category_id,
1358 p_application_id => l_category_usage_rec.application_id,
1359 p_show_all => l_category_usage_rec.show_all,
1360 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD)
1361 then
1362 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
1363 FND_MESSAGE.SET_NAME('AK','AK_CATEGORY_USAGE_NOT_DOWNLOADED');
1364 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1365 p_region_code||' '||to_char(p_attribute_application_id)||
1366 ' '||p_attribute_code);
1367 FND_MSG_PUB.Add;
1368 end if;
1369 close l_get_category_usages_csr;
1370 raise FND_API.G_EXC_ERROR;
1371 end if; /* if AK_REGION2_PVT.VALIDATE_CATEGORY_USAGE */
1372 end if; /* if p_validation_level */
1373 
1374 -- Write category_usage into buffer
1375 -- write a blank line after region item
1376 l_index := 1;
1377 l_databuffer_tbl(l_index) := ' ';
1378 l_index := l_index + 1;
1379 l_databuffer_tbl(l_index) := '    BEGIN CATEGORY_USAGE "' ||
1380 nvl(to_char(l_category_usage_rec.category_id),'') || '"';
1381 if ((l_category_usage_rec.application_id IS NOT NULL) and
1382 (l_category_usage_rec.application_id <> FND_API.G_MISS_NUM)) then
1383 l_index := l_index + 1;
1384 l_databuffer_tbl(l_index) := '      APPLICATION_ID = "' ||
1385 nvl(to_char(l_category_usage_rec.application_id),'') || '"';
1386 end if;
1387 if ((l_category_usage_rec.category_id IS NOT NULL) and
1388 (l_category_usage_rec.category_id <> FND_API.G_MISS_NUM)) then
1389 l_index := l_index + 1;
1390 l_databuffer_tbl(l_index) := '      CATEGORY_NAME = "' ||
1391 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_category_usage_rec.category_name)|| '"';
1392 end if;
1393 if ((l_category_usage_rec.show_all IS NOT NULL) and
1394 (l_category_usage_rec.show_all <> FND_API.G_MISS_CHAR)) then
1395 l_index := l_index + 1;
1396 l_databuffer_tbl(l_index) := '      SHOW_ALL = "' ||
1397 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_category_usage_rec.show_all)|| '"';
1398 end if;
1399 -- - Write out who columns
1400 l_index := l_index + 1;
1401 l_databuffer_tbl(l_index) := '      CREATED_BY = "' ||
1402 nvl(to_char(l_category_usage_rec.created_by),'') || '"';
1403 l_index := l_index + 1;
1404 l_databuffer_tbl(l_index) := '      CREATION_DATE = "' ||
1405 to_char(l_category_usage_rec.creation_date,
1406 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1407 l_index := l_index + 1;
1408 -- CHANGED TO OWNER FOR R12
1409 -- l_databuffer_tbl(l_index) := '      LAST_UPDATED_BY = "' ||
1410 -- nvl(to_char(l_category_usage_rec.last_updated_by),'') || '"';
1411 l_databuffer_tbl(l_index) := '      OWNER = "' ||
1412 FND_LOAD_UTIL.OWNER_NAME(l_category_usage_rec.last_updated_by) || '"';
1413 l_index := l_index + 1;
1414 l_databuffer_tbl(l_index) := '      LAST_UPDATE_DATE = "' ||
1415 to_char(l_category_usage_rec.last_update_date,
1416 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1417 l_index := l_index + 1;
1418 l_databuffer_tbl(l_index) := '      LAST_UPDATE_LOGIN = "' ||
1419 nvl(to_char(l_category_usage_rec.last_update_login),'') || '"';
1420 
1421 l_index := l_index + 1;
1422 l_databuffer_tbl(l_index) := '    END CATEGORY_USAGE';
1423 l_index := l_index + 1;
1424 l_databuffer_tbl(l_index) := ' ';
1425 
1426 -- - Write the 'END CATEGORY_USAGE' to the specified file
1427 AK_ON_OBJECTS_PVT.WRITE_FILE (
1428 p_return_status => l_return_status,
1429 p_buffer_tbl => l_databuffer_tbl,
1430 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
1431 );
1432 -- If API call returns with an error status...
1433 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1434 (l_return_status = FND_API.G_RET_STS_ERROR) then
1435 close l_get_category_usages_csr;
1436 RAISE FND_API.G_EXC_ERROR;
1437 end if;
1438 
1439 end loop;
1440 close l_get_category_usages_csr;
1441 
1442 p_return_status := FND_API.G_RET_STS_SUCCESS;
1443 
1444 EXCEPTION
1445 WHEN VALUE_ERROR THEN
1446 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1447 FND_MESSAGE.SET_NAME('AK','AK_CATEGORY_USAGE_VALUE_ERROR');
1448 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1449 p_region_code||' '||to_char(p_attribute_application_id)||
1450 ' '||p_attribute_code);
1451 FND_MSG_PUB.Add;
1452 end if;
1453 p_return_status := FND_API.G_RET_STS_ERROR;
1454 WHEN FND_API.G_EXC_ERROR THEN
1455 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1456 FND_MESSAGE.SET_NAME('AK','AK_CATEGORY_USAGE_NOT_DOWNLOADED');
1457 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1458 p_region_code||' '||to_char(p_attribute_application_id)||
1459 ' '||p_attribute_code);
1460 FND_MSG_PUB.Add;
1461 end if;
1462 p_return_status := FND_API.G_RET_STS_ERROR;
1463 WHEN OTHERS THEN
1464 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1465 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
1466 SUBSTR (SQLERRM, 1, 240) );
1467 FND_MSG_PUB.Add;
1468 end WRITE_CAT_USAGES_TO_BUFFER;
1469 
1470 --=======================================================
1471 --  Procedure   WRITE_LOV_RELATION_TO_BUFFER (local procedure)
1472 --
1473 --  Usage       Local procedure for writing the given region
1474 --              lov relation records to the output file.
1475 --              Not designed to be called from outside this package.
1476 --
1477 --  Desc        This procedure first retreives and writes the given
1478 --              region to the loader file. Then it calls other local
1479 --              procedure to write all its region items to the same output
1480 --              file.
1481 --
1482 --  Results     The API returns the standard p_return_status parameter
1483 --              indicating one of the standard return statuses :
1484 --                  * Unexpected error
1485 --                  * Error
1486 --                  * Success
1487 --  Parameters
1488 --              p_region_application_id : IN required
1489 --              p_region_code : IN required
1490 --                  Key value of the Region to be extracted to the loader
1491 --                  file.
1492 --              p_nls_language : IN required
1493 --                  The NLS langauge that should be used when
1494 --                  extracting data from the TL table
1495 --=======================================================
1496 procedure WRITE_LOV_RELATION_TO_BUFFER (
1497 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
1498 p_return_status            OUT NOCOPY     VARCHAR2,
1499 p_region_application_id    IN      NUMBER,
1500 p_region_code              IN      VARCHAR2,
1501 p_attribute_application_id IN		 NUMBER,
1502 p_attribute_code           IN      VARCHAR2,
1503 p_lov_region_appl_id		 IN		 NUMBER,
1504 p_lov_region_code			 IN		 VARCHAR2
1505 ) is
1506 cursor l_get_lov_relations_csr is
1507 select *
1508 from  AK_REGION_LOV_RELATIONS
1509 where REGION_APPLICATION_ID = p_region_application_id
1510 and   REGION_CODE = p_region_code
1511 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
1512 and   ATTRIBUTE_CODE = p_attribute_code;
1513 l_api_name           CONSTANT varchar2(30) := 'Write_lov_relation_to_buffer';
1514 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
1515 l_index              NUMBER;
1516 l_lov_relation_rec   AK_REGION_LOV_RELATIONS%ROWTYPE;
1517 l_return_status      varchar2(1);
1518 begin
1519 -- Retrieve region information from the database
1520 
1521 open l_get_lov_relations_csr;
1522 loop
1523 fetch l_get_lov_relations_csr into l_lov_relation_rec;
1524 exit when l_get_lov_relations_csr%notfound;
1525 
1526 -- Region lov relation must be validated before it is written to the file
1527 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
1528 if not AK_REGION2_PVT.VALIDATE_LOV_RELATION (
1529 p_validation_level => p_validation_level,
1530 p_api_version_number => 1.0,
1531 p_return_status => l_return_status,
1532 p_region_application_id => l_lov_relation_rec.region_application_id,
1533 p_region_code => l_lov_relation_rec.region_code,
1534 p_attribute_application_id => l_lov_relation_rec.attribute_application_id,
1535 p_attribute_code => l_lov_relation_rec.attribute_code,
1536 p_lov_region_appl_id => l_lov_relation_rec.lov_region_appl_id,
1537 p_lov_region_code => l_lov_relation_rec.lov_region_code,
1538 p_lov_attribute_appl_id => l_lov_relation_rec.lov_attribute_appl_id,
1539 p_lov_attribute_code => l_lov_relation_rec.lov_attribute_code,
1540 p_base_attribute_appl_id => l_lov_relation_rec.base_attribute_appl_id,
1541 p_base_attribute_code => l_lov_relation_rec.base_attribute_code,
1542 p_direction_flag => l_lov_relation_rec.direction_flag,
1543 p_base_region_appl_id => l_lov_relation_rec.base_region_appl_id,
1544 p_base_region_code => l_lov_relation_rec.base_region_code,
1545 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD)
1546 then
1547 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
1548 FND_MESSAGE.SET_NAME('AK','AK_LOV_RELATION_NOT_DOWNLOADED');
1549 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1550 p_region_code);
1551 FND_MSG_PUB.Add;
1552 end if;
1553 close l_get_lov_relations_csr;
1554 raise FND_API.G_EXC_ERROR;
1555 end if; /* if AK_REGION2_PVT.VALIDATE_LOV_RELATION */
1556 end if; /* if p_validation_level */
1557 
1558 -- Write region lov relation into buffer
1559 -- write a blank line after region item
1560 l_index := 1;
1561 l_databuffer_tbl(l_index) := ' ';
1562 l_index := l_index + 1;
1563 l_databuffer_tbl(l_index) := '    BEGIN REGION_LOV_RELATION "' ||
1564 nvl(to_char(l_lov_relation_rec.lov_region_appl_id), '') || '" "' ||
1565 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.lov_region_code) || '" "'||
1566 nvl(to_char(l_lov_relation_rec.lov_attribute_appl_id), '') || '" "' ||
1567 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.lov_attribute_code) || '" "'||
1568 nvl(to_char(l_lov_relation_rec.base_attribute_appl_id), '') || '" "' ||
1569 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.base_attribute_code)|| '" "'||
1570 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.direction_flag)|| '"';
1571 if ((l_lov_relation_rec.base_region_appl_id IS NOT NULL) and
1572 (l_lov_relation_rec.base_region_appl_id <> FND_API.G_MISS_NUM)) then
1573 l_index := l_index + 1;
1574 l_databuffer_tbl(l_index) := '      BASE_REGION_APPL_ID = "' ||
1575 nvl(to_char(l_lov_relation_rec.base_region_appl_id), '') || '"';
1576 end if;
1577 if ((l_lov_relation_rec.base_region_code IS NOT NULL) and
1578 (l_lov_relation_rec.base_region_code <> FND_API.G_MISS_CHAR)) then
1579 l_index := l_index + 1;
1580 l_databuffer_tbl(l_index) := '      BASE_REGION_CODE = "' ||
1581 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.base_region_code) || '"';
1582 end if;
1583 l_index := l_index + 1;
1584 l_databuffer_tbl(l_index) := '      REQUIRED_FLAG = "' ||
1585 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_lov_relation_rec.required_flag) ||
1586 '"';
1587 -- - Write out who columns
1588 l_index := l_index + 1;
1589 l_databuffer_tbl(l_index) := '      CREATED_BY = "' ||
1590 nvl(to_char(l_lov_relation_rec.created_by),'') || '"';
1591 l_index := l_index + 1;
1592 l_databuffer_tbl(l_index) := '      CREATION_DATE = "' ||
1593 to_char(l_lov_relation_rec.creation_date,
1594 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1595 l_index := l_index + 1;
1596 -- CHANGED TO OWNER FOR R12
1597 -- l_databuffer_tbl(l_index) := '      LAST_UPDATED_BY = "' ||
1598 -- nvl(to_char(l_lov_relation_rec.last_updated_by),'') || '"';
1599 l_databuffer_tbl(l_index) := '      OWNER = "' ||
1600 FND_LOAD_UTIL.OWNER_NAME(l_lov_relation_rec.last_updated_by) || '"';
1601 l_index := l_index + 1;
1602 l_databuffer_tbl(l_index) := '      LAST_UPDATE_DATE = "' ||
1603 to_char(l_lov_relation_rec.last_update_date,
1604 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1605 l_index := l_index + 1;
1606 l_databuffer_tbl(l_index) := '      LAST_UPDATE_LOGIN = "' ||
1607 nvl(to_char(l_lov_relation_rec.last_update_login),'') || '"';
1608 
1609 l_index := l_index + 1;
1610 l_databuffer_tbl(l_index) := '    END REGION_LOV_RELATION';
1611 l_index := l_index + 1;
1612 l_databuffer_tbl(l_index) := ' ';
1613 
1614 -- - Write the 'END REGION_LOV_RELATION' to the specified file
1615 AK_ON_OBJECTS_PVT.WRITE_FILE (
1616 p_return_status => l_return_status,
1617 p_buffer_tbl => l_databuffer_tbl,
1618 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
1619 );
1620 -- If API call returns with an error status...
1621 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1622 (l_return_status = FND_API.G_RET_STS_ERROR) then
1623 close l_get_lov_relations_csr;
1624 RAISE FND_API.G_EXC_ERROR;
1625 end if;
1626 
1627 end loop;
1628 close l_get_lov_relations_csr;
1629 
1630 p_return_status := FND_API.G_RET_STS_SUCCESS;
1631 
1632 EXCEPTION
1633 WHEN VALUE_ERROR THEN
1634 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1635 FND_MESSAGE.SET_NAME('AK','AK_LOV_REGION_VALUE_ERROR');
1636 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1637 p_region_code||' '||to_char(p_attribute_application_id)||
1638 ' '||p_attribute_code||' '||to_char(p_lov_region_appl_id)||
1639 ' '||p_lov_region_code);
1640 FND_MSG_PUB.Add;
1641 end if;
1642 p_return_status := FND_API.G_RET_STS_ERROR;
1643 WHEN FND_API.G_EXC_ERROR THEN
1644 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1645 FND_MESSAGE.SET_NAME('AK','AK_LOV_RELATION_NOT_DOWNLOADED');
1646 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
1647 p_region_code||' '||to_char(p_attribute_application_id)||
1648 ' '||p_attribute_code||' '||to_char(p_lov_region_appl_id)||
1649 ' '||p_lov_region_code);
1650 FND_MSG_PUB.Add;
1651 end if;
1652 p_return_status := FND_API.G_RET_STS_ERROR;
1653 WHEN OTHERS THEN
1654 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1655 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
1656 SUBSTR (SQLERRM, 1, 240) );
1657 FND_MSG_PUB.Add;
1658 end WRITE_LOV_RELATION_TO_BUFFER;
1659 
1660 /*
1661 --=======================================================
1662 --  Procedure   WRITE_GRAPH_TO_BUFFER (local procedure)
1663 --
1664 --  Usage       Local procedure for writing all region graphs
1665 --              for the given region to the output file.
1666 --              Not designed to be called from outside this package.
1667 --
1668 --  Desc        This procedure retrieves all Region Graphs
1669 --              that belongs to the given region from the database,
1670 --              and writes them to the output file
1671 --              in loader file format.
1672 --
1673 --  Results     The API returns the standard p_return_status parameter
1674 --              indicating one of the standard return statuses :
1675 --                  * Unexpected error
1676 --                  * Error
1677 --                  * Success
1678 --  Parameters
1679 --              p_region_application_id : IN required
1680 --              p_region_code : IN required
1681 --                  Key value of the Region record whose region
1682 --                  items are to be extracted to the loader file.
1683 --              p_nls_language : IN required
1684 --                  The NLS langauge that should be used when
1685 --                  extracting data from the TL table
1686 --=======================================================
1687 procedure WRITE_GRAPH_TO_BUFFER (
1688 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
1689 p_return_status            OUT NOCOPY     VARCHAR2,
1690 p_region_application_id    IN      NUMBER,
1691 p_region_code              IN      VARCHAR2,
1692 p_nls_language             IN      VARCHAR2
1693 ) is
1694 cursor l_get_graphs_csr is
1695 select *
1696 from   AK_REGION_GRAPHS
1697 where  REGION_APPLICATION_ID = p_region_application_id
1698 and    REGION_CODE = p_region_code;
1699 cursor l_get_graph_tl_csr (graph_number number) is
1700 select *
1701 from   AK_REGION_GRAPHS_TL
1702 where  REGION_APPLICATION_ID = p_region_application_id
1703 and    REGION_CODE = p_region_code
1704 and    GRAPH_NUMBER = graph_number
1705 and    LANGUAGE = p_nls_language;
1706 cursor l_column_exists_csr ( region_appl_id_param number,
1707 region_code_param varchar2,
1708 graph_number_param number) is
1709 select 1
1710 from ak_region_graph_columns
1711 where region_application_id = region_appl_id_param
1712 and region_code = region_code_param
1713 and graph_number = graph_number_param;
1714 
1715 l_api_name           CONSTANT varchar2(30) := 'Write_Graph_to_buffer';
1716 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
1717 l_index              NUMBER;
1718 l_graphs_rec	       AK_REGION_GRAPHS%ROWTYPE;
1719 l_graphs_tl_rec       AK_REGION_GRAPHS_TL%ROWTYPE;
1720 l_return_status      varchar2(1);
1721 l_write_column_flag boolean := false;
1722 begin
1723 -- Find out where the next buffer element to be written to
1724 l_index := 1;
1725 
1726 -- Retrieve region graph and its TL information from the database
1727 
1728 open l_get_graphs_csr;
1729 loop
1730 fetch l_get_graphs_csr into l_graphs_rec;
1731 exit when l_get_graphs_csr%notfound;
1732 open l_get_graph_tl_csr(l_graphs_rec.graph_number);
1733 fetch l_get_graph_tl_csr into l_graphs_tl_rec;
1734 if l_get_graph_tl_csr%found then
1735 -- write this region graph if it is validated
1736 if (p_validation_level <> FND_API.G_VALID_LEVEL_NONE) and
1737 not AK_REGION_PVT.VALIDATE_GRAPH (
1738 p_validation_level => p_validation_level,
1739 p_api_version_number => 1.0,
1740 p_return_status => l_return_status,
1741 p_region_application_id => l_graphs_rec.region_application_id,
1742 p_region_code => l_graphs_rec.region_code,
1743 p_graph_number => l_graphs_rec.graph_number,
1744 p_graph_style => l_graphs_Rec.graph_style,
1745 p_display_flag => l_graphs_rec.display_flag,
1746 p_depth_radius => l_graphs_rec.depth_radius,
1747 p_graph_title => l_graphs_tl_rec.graph_title,
1748 p_y_axis_label => l_graphs_tl_rec.y_axis_label,
1749 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD) then
1750 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1751 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_DOWNLOADED');
1752 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
1753 ' ' || p_region_code ||
1754 ' ' || to_char(l_graphs_rec.graph_number));
1755 FND_MSG_PUB.Add;
1756 close l_get_graph_tl_csr;
1757 close l_get_graphs_csr;
1758 RAISE FND_API.G_EXC_ERROR;
1759 end if;
1760 
1761 else
1762 l_databuffer_tbl(l_index) := ' ';
1763 l_index := l_index + 1;
1764 l_databuffer_tbl(l_index) := '  BEGIN REGION_GRAPH "' ||
1765 l_graphs_rec.graph_number || '"';
1766 l_index := l_index + 1;
1767 l_databuffer_tbl(l_index) := '    GRAPH_STYLE = "' ||
1768 nvl(to_char(l_graphs_rec.graph_style),'') || '"';
1769 if ((l_graphs_rec.display_flag IS NOT NULL) and
1770 (l_graphs_rec.display_flag <> FND_API.G_MISS_CHAR)) then
1771 l_index := l_index + 1;
1772 l_databuffer_tbl(l_index) := '    DISPLAY_FLAG = "' ||
1773 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_graphs_rec.display_flag)||
1774 '"';
1775 end if;
1776 if ((l_graphs_rec.depth_radius IS NOT NULL) and
1777 (l_graphs_rec.depth_radius <> FND_API.G_MISS_NUM)) then
1778 l_index := l_index + 1;
1779 l_databuffer_tbl(l_index) := '    DEPTH_RADIUS = "' ||
1780 nvl(to_char(l_graphs_rec.depth_radius),'') || '"';
1781 end if;
1782 -- - Write out who columns
1783 l_index := l_index + 1;
1784 l_databuffer_tbl(l_index) := '    CREATED_BY = "' ||
1785 nvl(to_char(l_graphs_rec.created_by),'') || '"';
1786 l_index := l_index + 1;
1787 l_databuffer_tbl(l_index) := '    CREATION_DATE = "' ||
1788 to_char(l_graphs_rec.creation_date,
1789 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1790 l_index := l_index + 1;
1791 l_databuffer_tbl(l_index) := '    LAST_UPDATED_BY = "' ||
1792 nvl(to_char(l_graphs_rec.last_updated_by),'') || '"';
1793 l_index := l_index + 1;
1794 l_databuffer_tbl(l_index) := '    LAST_UPDATE_DATE = "' ||
1795 to_char(l_graphs_rec.last_update_date,
1796 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
1797 l_index := l_index + 1;
1798 l_databuffer_tbl(l_index) := '    LAST_UPDATE_LOGIN = "' ||
1799 nvl(to_char(l_graphs_rec.last_update_login),'') || '"';
1800 
1801 if ((l_graphs_tl_rec.graph_title IS NOT NULL) and
1802 (l_graphs_tl_rec.graph_title <> FND_API.G_MISS_CHAR)) then
1803 l_index := l_index + 1;
1804 l_databuffer_tbl(l_index) := '    GRAPH_TITLE = "'||
1805 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_graphs_tl_rec.graph_title)||
1806 '"';
1807 end if;
1808 if ((l_graphs_tl_rec.y_axis_label IS NOT NULL) and
1809 (l_graphs_tl_rec.graph_title <> FND_API.G_MISS_CHAR)) then
1810 l_index := l_index + 1;
1811 l_databuffer_tbl(l_index) := '    Y_AXIS_LABEL = "'||
1812 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_graphs_tl_rec.y_axis_label)||
1813 '"';
1814 end if;
1815 
1816 -- - Write the region graph data to the specified file
1817 AK_ON_OBJECTS_PVT.WRITE_FILE (
1818 p_return_status => l_return_status,
1819 p_buffer_tbl => l_databuffer_tbl,
1820 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
1821 );
1822 -- If API call returns with an error status...
1823 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1824 (l_return_status = FND_API.G_RET_STS_ERROR) then
1825 close l_get_graph_tl_csr;
1826 close l_get_graphs_csr;
1827 RAISE FND_API.G_EXC_ERROR;
1828 end if;
1829 
1830 l_databuffer_tbl.delete;
1831 
1832 for l_chk_columns in l_column_exists_csr (p_region_application_id,
1833 p_region_code, l_graphs_rec.graph_number) loop
1834 l_write_column_flag := true;
1835 end loop;
1836 if l_write_column_flag then
1837 WRITE_GRAPH_COL_TO_BUFFER(
1838 p_validation_level => p_validation_level,
1839 p_return_status => l_return_status,
1840 p_region_application_id => p_region_application_id,
1841 p_region_code => p_region_code,
1842 p_graph_number => l_graphs_rec.graph_number
1843 );
1844 else
1845 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
1846 FND_MESSAGE.SET_NAME('AK','AK_GRAPH_COL_DOES_NOT_EXIST');
1847 FND_MSG_PUB.Add;
1848 end if;
1849 -- RAISE FND_API.G_EXC_ERROR;
1850 end if; -- end if l_write_column_flag
1851 
1852 --
1853 -- Download aborts if validation fails in WRITE_GRAPH_COL_TO_BUFFER
1854 --
1855 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1856 (l_return_status = FND_API.G_RET_STS_ERROR) then
1857 RAISE FND_API.G_EXC_ERROR;
1858 end if;
1859 
1860 -- finish up region items
1861 l_index := l_index + 1;
1862 l_databuffer_tbl(l_index) := '  END REGION_GRAPH';
1863 l_index := l_index + 1;
1864 l_databuffer_tbl(l_index) := ' ';
1865 end if; -- validation OK
1866 
1867 end if; -- if TL record found
1868 close l_get_graph_tl_csr;
1869 
1870 end loop;
1871 close l_get_graphs_csr;
1872 
1873 -- - Write region item data out to the specified file
1874 --   don't call write_file if there are no items for this region
1875 
1876 if (l_databuffer_tbl.count > 0) then
1877 AK_ON_OBJECTS_PVT.WRITE_FILE (
1878 p_return_status => l_return_status,
1879 p_buffer_tbl => l_databuffer_tbl,
1880 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
1881 );
1882 -- If API call returns with an error status...
1883 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
1884 (l_return_status = FND_API.G_RET_STS_ERROR) then
1885 RAISE FND_API.G_EXC_ERROR;
1886 end if;
1887 end if;
1888 
1889 p_return_status := FND_API.G_RET_STS_SUCCESS;
1890 
1891 EXCEPTION
1892 WHEN VALUE_ERROR THEN
1893 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1894 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_VALUE_ERROR');
1895 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
1896 ' ' || p_region_code ||
1897 ' ' || l_graphs_rec.graph_number);
1898 FND_MSG_PUB.Add;
1899 end if;
1900 p_return_status := FND_API.G_RET_STS_ERROR;
1901 WHEN FND_API.G_EXC_ERROR THEN
1902 p_return_status := FND_API.G_RET_STS_ERROR;
1903 WHEN OTHERS THEN
1904 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1905 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
1906 SUBSTR (SQLERRM, 1, 240) );
1907 FND_MSG_PUB.Add;
1908 end WRITE_GRAPH_TO_BUFFER;
1909 */
1910 
1911 --=======================================================
1912 --  Procedure   WRITE_ITEM_TO_BUFFER (local procedure)
1913 --
1914 --  Usage       Local procedure for writing all region items
1915 --              for the given region to the output file.
1916 --              Not designed to be called from outside this package.
1917 --
1918 --  Desc        This procedure retrieves all Region Items
1919 --              that belongs to the given region from the database,
1920 --              and writes them to the output file
1921 --              in loader file format.
1922 --
1923 --  Results     The API returns the standard p_return_status parameter
1924 --              indicating one of the standard return statuses :
1925 --                  * Unexpected error
1926 --                  * Error
1927 --                  * Success
1928 --  Parameters
1929 --              p_region_application_id : IN required
1930 --              p_region_code : IN required
1931 --                  Key value of the Region record whose region
1932 --                  items are to be extracted to the loader file.
1933 --              p_nls_language : IN required
1934 --                  The NLS langauge that should be used when
1935 --                  extracting data from the TL table
1936 --=======================================================
1937 procedure WRITE_ITEM_TO_BUFFER (
1938 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
1939 p_return_status            OUT NOCOPY     VARCHAR2,
1940 p_region_application_id    IN      NUMBER,
1941 p_region_code              IN      VARCHAR2,
1942 p_nls_language             IN      VARCHAR2
1943 ) is
1944 cursor l_get_items_csr is
1945 select *
1946 from   AK_REGION_ITEMS
1947 where  REGION_APPLICATION_ID = p_region_application_id
1948 and    REGION_CODE = p_region_code;
1949 cursor l_get_item_tl_csr (attribute_appl_id_param number,
1950 attribute_code_param varchar2) is
1951 select *
1952 from   AK_REGION_ITEMS_TL
1953 where  REGION_APPLICATION_ID = p_region_application_id
1954 and    REGION_CODE = p_region_code
1955 and    ATTRIBUTE_APPLICATION_ID = attribute_appl_id_param
1956 and    ATTRIBUTE_CODE = attribute_code_param
1957 and    LANGUAGE = p_nls_language;
1958 cursor l_relation_exists_csr ( region_appl_id_param number,
1959 region_code_param varchar2,
1960 attribute_appl_id_param number,
1961 attribute_code_param varchar2,
1962 lov_region_appl_id_param number,
1963 lov_region_code_param varchar2 ) is
1964 select 1
1965 from ak_region_lov_relations
1966 where region_application_id = region_appl_id_param
1967 and region_code = region_code_param
1968 and attribute_application_id = attribute_appl_id_param
1969 and attribute_code = attribute_code_param
1970 and lov_region_appl_id = lov_region_appl_id_param
1971 and lov_region_code = lov_region_code_param;
1972 cursor l_category_usages_csr( region_appl_id_param number,
1973 region_code_param varchar2,
1974 attribute_appl_id_param number,
1975 attribute_code_param varchar2) is
1976 select 1
1977 from ak_category_usages acu, ak_region_items ari
1978 where acu.region_code = region_code_param
1979 and acu.region_application_id = region_appl_id_param
1980 and acu.attribute_code = attribute_code_param
1981 and acu.attribute_application_id = attribute_appl_id_param
1982 and ari.region_code = acu.region_code
1983 and ari.region_application_id = acu.region_application_id
1984 and ari.attribute_code = acu.attribute_code
1985 and ari.attribute_application_id = acu.attribute_application_id
1986 and ( ari.item_style = 'ATTACHMENT_IMAGE'
1987 or ari.item_style = 'ATTACHMENT_LINK');
1988 
1989 l_api_name           CONSTANT varchar2(30) := 'Write_Item_to_buffer';
1990 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
1991 l_index              NUMBER;
1992 l_items_rec          AK_REGION_ITEMS%ROWTYPE;
1993 l_items_tl_rec       AK_REGION_ITEMS_TL%ROWTYPE;
1994 l_return_status      varchar2(1);
1995 l_write_relation_flag boolean := false;
1996 l_write_category_usages_flag boolean := false;
1997 begin
1998 -- Find out where the next buffer element to be written to
1999 l_index := 1;
2000 
2001 -- Retrieve region item and its TL information from the database
2002 
2003 open l_get_items_csr;
2004 loop
2005 fetch l_get_items_csr into l_items_rec;
2006 exit when l_get_items_csr%notfound;
2007 open l_get_item_tl_csr(l_items_rec.attribute_application_id,
2008 l_items_rec.attribute_code);
2009 fetch l_get_item_tl_csr into l_items_tl_rec;
2010 if l_get_item_tl_csr%found then
2011 -- write this region item if it is validated
2012 if (p_validation_level <> FND_API.G_VALID_LEVEL_NONE) and
2013 not AK_REGION_PVT.VALIDATE_ITEM (
2014 p_validation_level => p_validation_level,
2015 p_api_version_number => 1.0,
2016 p_return_status => l_return_status,
2017 p_region_application_id => l_items_rec.region_application_id,
2018 p_region_code => l_items_rec.region_code,
2019 p_attribute_application_id => l_items_rec.attribute_application_id,
2020 p_attribute_code => l_items_rec.attribute_code,
2021 p_display_sequence => l_items_rec.display_sequence,
2022 p_node_display_flag => l_items_rec.node_display_flag,
2023 p_node_query_flag => l_items_rec.node_query_flag,
2024 p_attribute_label_length => l_items_rec.attribute_label_length,
2025 p_display_value_length => l_items_rec.display_value_length,
2026 p_bold => l_items_rec.bold,
2027 p_italic => l_items_rec.italic,
2028 p_vertical_alignment => l_items_rec.vertical_alignment,
2029 p_horizontal_alignment => l_items_rec.horizontal_alignment,
2030 p_item_style => l_items_rec.item_style,
2031 p_object_attribute_flag => l_items_rec.object_attribute_flag,
2032 p_icx_custom_call => l_items_rec.icx_custom_call,
2033 p_update_flag => l_items_rec.update_flag,
2034 p_required_flag => l_items_rec.required_flag,
2035 p_security_code => l_items_rec.security_code,
2036 p_default_value_varchar2 => l_items_rec.default_value_varchar2,
2037 p_default_value_number => l_items_rec.default_value_number,
2038 p_default_value_date => l_items_rec.default_value_date,
2039 p_nested_region_appl_id => l_items_rec.nested_region_application_id,
2040 p_nested_region_code => l_items_rec.nested_region_code,
2041 p_lov_region_application_id =>
2042 l_items_rec.lov_region_application_id,
2043 p_lov_region_code => l_items_rec.lov_region_code,
2044 p_lov_foreign_key_name => l_items_rec.lov_foreign_key_name,
2045 p_lov_attribute_application_id =>
2046 l_items_rec.lov_attribute_application_id,
2047 p_lov_attribute_code => l_items_rec.lov_attribute_code,
2048 p_lov_default_flag => l_items_rec.lov_default_flag,
2049 p_region_defaulting_api_pkg =>
2050 l_items_rec.region_defaulting_api_pkg,
2051 p_region_defaulting_api_proc =>
2052 l_items_rec.region_defaulting_api_proc,
2053 p_region_validation_api_pkg =>
2054 l_items_rec.region_validation_api_pkg,
2055 p_region_validation_api_proc =>
2056 l_items_rec.region_validation_api_proc,
2057 p_order_sequence => l_items_rec.order_sequence,
2058 p_order_direction => l_items_rec.order_direction,
2059 p_menu_name => l_items_rec.menu_name,
2060 p_flexfield_name => l_items_rec.flexfield_name,
2061 p_flexfield_application_id => l_items_rec.flexfield_application_id,
2062 p_tabular_function_code    => l_items_rec.tabular_function_code,
2063 p_tip_type                 => l_items_rec.tip_type,
2064 p_tip_message_name         => l_items_rec.tip_message_name,
2065 p_tip_message_application_id  => l_items_rec.tip_message_application_id ,
2066 p_flex_segment_list        => l_items_rec.flex_segment_list,
2067 p_entity_id  => l_items_rec.entity_id ,
2068 p_anchor     => l_items_rec.anchor,
2069 p_poplist_view_usage_name => l_items_rec.poplist_view_usage_name,
2070 p_user_customizable => l_items_rec.user_customizable,
2071 p_sortby_view_attribute_name => l_items_rec.sortby_view_attribute_name,
2072 p_invoke_function_name => l_items_rec.invoke_function_name,
2073 p_expansion => l_items_rec.expansion,
2074 p_als_max_length => l_items_rec.als_max_length,
2075 p_initial_sort_sequence => l_items_rec.initial_sort_sequence,
2076 p_customization_application_id => l_items_rec.customization_application_id,
2077 p_customization_code => l_items_rec.customization_code,
2078 p_attribute_label_long => l_items_tl_rec.attribute_label_long,
2079 p_attribute_label_short => l_items_tl_rec.attribute_label_short,
2080 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD) then
2081 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2082 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_DOWNLOADED');
2083 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
2084 ' ' || p_region_code ||
2085 ' ' || to_char(l_items_rec.attribute_application_id) ||
2086 ' ' || l_items_rec.attribute_code);
2087 FND_MSG_PUB.Add;
2088 close l_get_item_tl_csr;
2089 close l_get_items_csr;
2090 RAISE FND_API.G_EXC_ERROR;
2091 end if;
2092 
2093 else
2094 l_databuffer_tbl(l_index) := ' ';
2095 l_index := l_index + 1;
2096 l_databuffer_tbl(l_index) := '  BEGIN REGION_ITEM "' ||
2097 l_items_rec.attribute_application_id || '" "' ||
2098 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.attribute_code) ||
2099 '"';
2100 l_index := l_index + 1;
2101 l_databuffer_tbl(l_index) := '    DISPLAY_SEQUENCE = "' ||
2102 nvl(to_char(l_items_rec.display_sequence),'') || '"';
2103 l_index := l_index + 1;
2104 l_databuffer_tbl(l_index) := '    NODE_DISPLAY_FLAG = "' ||
2105 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.node_display_flag)||
2106 '"';
2107 l_index := l_index + 1;
2108 l_databuffer_tbl(l_index) := '    NODE_QUERY_FLAG = "' ||
2109 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.node_query_flag) ||
2110 '"';
2111 l_index := l_index + 1;
2112 l_databuffer_tbl(l_index) := '    ATTRIBUTE_LABEL_LENGTH = "' ||
2113 nvl(to_char(l_items_rec.attribute_label_length),'') || '"';
2114 l_index := l_index + 1;
2115 l_databuffer_tbl(l_index) := '    DISPLAY_VALUE_LENGTH = "' ||
2116 nvl(to_char(l_items_rec.display_value_length),'') || '"';
2117 l_index := l_index + 1;
2118 l_databuffer_tbl(l_index) := '    BOLD = "' ||
2119 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.bold) || '"';
2120 l_index := l_index + 1;
2121 l_databuffer_tbl(l_index) := '    ITALIC = "' ||
2122 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.italic) || '"';
2123 l_index := l_index + 1;
2124 l_databuffer_tbl(l_index) := '    VERTICAL_ALIGNMENT = "' ||
2125 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.vertical_alignment)
2126 || '"';
2127 l_index := l_index + 1;
2128 l_databuffer_tbl(l_index) := '    HORIZONTAL_ALIGNMENT = "' ||
2129 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2130 l_items_rec.horizontal_alignment)|| '"';
2131 l_index := l_index + 1;
2132 l_databuffer_tbl(l_index) := '    ITEM_STYLE = "' ||
2133 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_items_rec.item_style) || '"';
2134 l_index := l_index + 1;
2135 l_databuffer_tbl(l_index) := '    OBJECT_ATTRIBUTE_FLAG = "' ||
2136 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2137 l_items_rec.object_attribute_flag) || '"';
2138 
2139 if ((l_items_rec.icx_custom_call IS NOT NULL) and
2140 (l_items_rec.icx_custom_call <> FND_API.G_MISS_CHAR)) then
2141 l_index := l_index + 1;
2142 l_databuffer_tbl(l_index) := '    ICX_CUSTOM_CALL = "' ||
2143 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2144 l_items_rec.icx_custom_call) || '"';
2145 end if;
2146 
2147 l_index := l_index + 1;
2148 l_databuffer_tbl(l_index) := '    UPDATE_FLAG = "' ||
2149 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2150 l_items_rec.update_flag) || '"';
2151 l_index := l_index + 1;
2152 l_databuffer_tbl(l_index) := '    REQUIRED_FLAG = "' ||
2153 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2154 l_items_rec.required_flag) || '"';
2155 if ((l_items_rec.security_code IS NOT NULL) and
2156 (l_items_rec.security_code <> FND_API.G_MISS_CHAR)) then
2157 l_index := l_index + 1;
2158 l_databuffer_tbl(l_index) := '    SECURITY_CODE = "' ||
2159 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2160 l_items_rec.security_code) || '"';
2161 end if;
2162 if ((l_items_rec.default_value_varchar2 IS NOT NULL) and
2163 (l_items_rec.default_value_varchar2 <> FND_API.G_MISS_CHAR)) then
2164 l_index := l_index + 1;
2165 l_databuffer_tbl(l_index) := '    DEFAULT_VALUE_VARCHAR2 = "' ||
2166 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2167 l_items_rec.default_value_varchar2) || '"';
2168 end if;
2169 if ((l_items_rec.default_value_number IS NOT NULL) and
2170 (l_items_rec.default_value_number <> FND_API.G_MISS_NUM)) then
2171 l_index := l_index + 1;
2172 l_databuffer_tbl(l_index) := '    DEFAULT_VALUE_NUMBER = "' ||
2173 nvl(to_char(l_items_rec.default_value_number),'') || '"';
2174 end if;
2175 if ((l_items_rec.default_value_date IS NOT NULL) and
2176 (l_items_rec.default_value_date <> FND_API.G_MISS_DATE)) then
2177 l_index := l_index + 1;
2178 l_databuffer_tbl(l_index) := '    DEFAULT_VALUE_DATE = "' ||
2179 to_char(l_items_rec.default_value_date,
2180 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
2181 end if;
2182 if ((l_items_rec.lov_region_application_id IS NOT NULL) and
2183 (l_items_rec.lov_region_application_id <> FND_API.G_MISS_NUM) and
2184 (l_items_rec.lov_region_code IS NOT NULL) and
2185 (l_items_rec.lov_region_code <> FND_API.G_MISS_CHAR)) then
2186 l_index := l_index + 1;
2187 l_databuffer_tbl(l_index) := '    LOV_REGION = "' ||
2188 nvl(to_char(l_items_rec.lov_region_application_id),'')||'" "'||
2189 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2190 l_items_rec.lov_region_code)|| '"';
2191 end if;
2192 if ((l_items_rec.lov_foreign_key_name IS NOT NULL) and
2193 (l_items_rec.lov_foreign_key_name <> FND_API.G_MISS_CHAR)) then
2194 l_index := l_index + 1;
2195 l_databuffer_tbl(l_index) := '    LOV_FOREIGN_KEY_NAME = "' ||
2196 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2197 l_items_rec.lov_foreign_key_name)|| '"';
2198 end if;
2199 if ((l_items_rec.lov_attribute_application_id IS NOT NULL) and
2200 (l_items_rec.lov_attribute_application_id <> FND_API.G_MISS_NUM) and
2201 (l_items_rec.lov_attribute_code IS NOT NULL) and
2202 (l_items_rec.lov_attribute_code <> FND_API.G_MISS_CHAR)) then
2203 l_index := l_index + 1;
2204 l_databuffer_tbl(l_index) := '    LOV_ATTRIBUTE = "' ||
2205 nvl(to_char(l_items_rec.lov_attribute_application_id),'')||'" "'||
2206 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2207 l_items_rec.lov_attribute_code)|| '"';
2208 end if;
2209 if ((l_items_rec.lov_default_flag IS NOT NULL) and
2210 (l_items_rec.lov_default_flag <> FND_API.G_MISS_CHAR)) then
2211 l_index := l_index + 1;
2212 l_databuffer_tbl(l_index) := '    LOV_DEFAULT_FLAG = "' ||
2213 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2214 l_items_rec.lov_default_flag)|| '"';
2215 end if;
2216 if ((l_items_rec.region_defaulting_api_pkg IS NOT NULL) and
2217 (l_items_rec.region_defaulting_api_pkg <> FND_API.G_MISS_CHAR)) then
2218 l_index := l_index + 1;
2219 l_databuffer_tbl(l_index) := '    REGION_DEFAULTING_API_PKG = "' ||
2220 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2221 l_items_rec.region_defaulting_api_pkg)|| '"';
2222 end if;
2223 if ((l_items_rec.region_defaulting_api_proc IS NOT NULL) and
2224 (l_items_rec.region_defaulting_api_proc <> FND_API.G_MISS_CHAR)) then
2225 l_index := l_index + 1;
2226 l_databuffer_tbl(l_index) := '    REGION_DEFAULTING_API_PROC = "' ||
2227 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2228 l_items_rec.region_defaulting_api_proc)|| '"';
2229 end if;
2230 if ((l_items_rec.region_validation_api_pkg IS NOT NULL) and
2231 (l_items_rec.region_validation_api_pkg <> FND_API.G_MISS_CHAR)) then
2232 l_index := l_index + 1;
2233 l_databuffer_tbl(l_index) := '    REGION_VALIDATION_API_PKG = "' ||
2234 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2235 l_items_rec.region_validation_api_pkg)|| '"';
2236 end if;
2237 if ((l_items_rec.region_validation_api_proc IS NOT NULL) and
2238 (l_items_rec.region_validation_api_proc <> FND_API.G_MISS_CHAR)) then
2239 l_index := l_index + 1;
2240 l_databuffer_tbl(l_index) := '    REGION_VALIDATION_API_PROC = "' ||
2241 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2242 l_items_rec.region_validation_api_proc) || '"';
2243 end if;
2244 if ((l_items_rec.order_sequence IS NOT NULL) and
2245 (l_items_rec.order_sequence <> FND_API.G_MISS_NUM)) then
2246 l_index := l_index + 1;
2247 l_databuffer_tbl(l_index) := '    ORDER_SEQUENCE = "' ||
2248 nvl(to_char(l_items_rec.order_sequence),'') || '"';
2249 end if;
2250 if ((l_items_rec.order_direction IS NOT NULL) and
2251 (l_items_rec.order_direction <> FND_API.G_MISS_CHAR)) then
2252 l_index := l_index + 1;
2253 l_databuffer_tbl(l_index) := '    ORDER_DIRECTION = "' ||
2254 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2255 l_items_rec.order_direction)|| '"';
2256 end if;
2257 
2258 -- new columns for JSP renderer
2259 if ((l_items_rec.display_height IS NOT NULL) and
2260 (l_items_rec.display_height <> FND_API.G_MISS_NUM)) then
2261 l_index := l_index + 1;
2262 l_databuffer_tbl(l_index) := '    DISPLAY_HEIGHT = "' ||
2263 nvl(to_char(l_items_rec.display_height),'') || '"';
2264 end if;
2265 if ((l_items_rec.submit IS NOT NULL) and
2266 (l_items_rec.submit <> FND_API.G_MISS_CHAR)) then
2267 l_index := l_index + 1;
2268 l_databuffer_tbl(l_index) := '    SUBMIT = "' ||
2269 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2270 l_items_rec.submit)|| '"';
2271 end if;
2272 if ((l_items_rec.encrypt IS NOT NULL) and
2273 (l_items_rec.encrypt <> FND_API.G_MISS_CHAR)) then
2274 l_index := l_index + 1;
2275 l_databuffer_tbl(l_index) := '    ENCRYPT = "' ||
2276 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2277 l_items_rec.encrypt)|| '"';
2278 end if;
2279 if ((l_items_rec.css_class_name IS NOT NULL) and
2280 (l_items_rec.css_class_name <> FND_API.G_MISS_CHAR)) then
2281 l_index := l_index + 1;
2282 l_databuffer_tbl(l_index) := '    CSS_CLASS_NAME = "' ||
2283 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2284 l_items_rec.css_class_name)|| '"';
2285 end if;
2286 if ((l_items_rec.view_usage_name IS NOT NULL) and
2287 (l_items_rec.view_usage_name <> FND_API.G_MISS_CHAR)) then
2288 l_index := l_index + 1;
2289 l_databuffer_tbl(l_index) := '    VIEW_USAGE_NAME = "' ||
2290 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2291 l_items_rec.view_usage_name)|| '"';
2292 end if;
2293 if ((l_items_rec.view_attribute_name IS NOT NULL) and
2294 (l_items_rec.view_attribute_name <> FND_API.G_MISS_CHAR)) then
2295 l_index := l_index + 1;
2296 l_databuffer_tbl(l_index) := '    VIEW_ATTRIBUTE_NAME = "' ||
2297 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2298 l_items_rec.view_attribute_name)|| '"';
2299 end if;
2300 if ((l_items_rec.nested_region_application_id IS NOT NULL) and
2301 (l_items_rec.nested_region_application_id <> FND_API.G_MISS_NUM)) then
2302 l_index := l_index + 1;
2303 l_databuffer_tbl(l_index) := '    NESTED_REGION_APPLICATION_ID = "' ||
2304 nvl(to_char(l_items_rec.nested_region_application_id),'') || '"';
2305 end if;
2306 if ((l_items_rec.nested_region_code IS NOT NULL) and
2307 (l_items_rec.nested_region_code <> FND_API.G_MISS_CHAR)) then
2308 l_index := l_index + 1;
2309 l_databuffer_tbl(l_index) := '    NESTED_REGION_CODE = "' ||
2310 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2311 l_items_rec.nested_region_code)|| '"';
2312 end if;
2313 if ((l_items_rec.url IS NOT NULL) and
2314 (l_items_rec.url <> FND_API.G_MISS_CHAR)) then
2315 l_index := l_index + 1;
2316 l_databuffer_tbl(l_index) := '    URL = "' ||
2317 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2318 l_items_rec.url)|| '"';
2319 end if;
2320 if ((l_items_rec.poplist_viewobject IS NOT NULL) and
2321 (l_items_rec.poplist_viewobject <> FND_API.G_MISS_CHAR)) then
2322 l_index := l_index + 1;
2323 l_databuffer_tbl(l_index) := '    POPLIST_VIEWOBJECT = "' ||
2324 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2325 l_items_rec.poplist_viewobject)|| '"';
2326 end if;
2327 if ((l_items_rec.poplist_display_attribute IS NOT NULL) and
2328 (l_items_rec.poplist_display_attribute <> FND_API.G_MISS_CHAR)) then
2329 l_index := l_index + 1;
2330 l_databuffer_tbl(l_index) := '    POPLIST_DISPLAY_ATTRIBUTE = "' ||
2331 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2332 l_items_rec.poplist_display_attribute)|| '"';
2333 end if;
2334 if ((l_items_rec.poplist_value_attribute IS NOT NULL) and
2335 (l_items_rec.poplist_value_attribute <> FND_API.G_MISS_CHAR)) then
2336 l_index := l_index + 1;
2337 l_databuffer_tbl(l_index) := '    POPLIST_VALUE_ATTRIBUTE = "' ||
2338 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2339 l_items_rec.poplist_value_attribute)|| '"';
2340 end if;
2341 if ((l_items_rec.image_file_name IS NOT NULL) and
2342 (l_items_rec.image_file_name <> FND_API.G_MISS_CHAR)) then
2343 l_index := l_index + 1;
2344 l_databuffer_tbl(l_index) := '    IMAGE_FILE_NAME = "' ||
2345 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2346 l_items_rec.image_file_name)|| '"';
2347 end if;
2348 if ((l_items_rec.item_name IS NOT NULL) and
2349 (l_items_rec.item_name <> FND_API.G_MISS_CHAR)) then
2350 l_index := l_index + 1;
2351 l_databuffer_tbl(l_index) := '    ITEM_NAME = "' ||
2352 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2353 l_items_rec.item_name)|| '"';
2354 end if;
2355 if ((l_items_rec.css_label_class_name IS NOT NULL) and
2356 (l_items_rec.css_label_class_name <> FND_API.G_MISS_CHAR)) then
2357 l_index := l_index + 1;
2358 l_databuffer_tbl(l_index) := '    CSS_LABEL_CLASS_NAME = "' ||
2359 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2360 l_items_rec.css_label_class_name)|| '"';
2361 end if;
2362 if ((l_items_rec.menu_name IS NOT NULL) and
2363 (l_items_rec.menu_name <> FND_API.G_MISS_CHAR)) then
2364 l_index := l_index + 1;
2365 l_databuffer_tbl(l_index) := '    MENU_NAME = "' ||
2366 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2367 l_items_rec.menu_name)|| '"';
2368 end if;
2369 -- Flexfield References for region items that point at flex definitions
2370 if ((l_items_rec.flexfield_name IS NOT NULL) and
2371 (l_items_rec.flexfield_name <> FND_API.G_MISS_CHAR)) then
2372 l_index := l_index + 1;
2373 l_databuffer_tbl(l_index) := '    FLEXFIELD_NAME = "' ||
2374 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2375 l_items_rec.flexfield_name)|| '"';
2376 end if;
2377 if ((l_items_rec.flexfield_application_id IS NOT NULL) and
2378 (l_items_rec.flexfield_application_id <> FND_API.G_MISS_NUM)) then
2379 l_index := l_index + 1;
2380 l_databuffer_tbl(l_index) := '    FLEXFIELD_APPLICATION_ID = "' ||
2381 nvl(to_char(l_items_rec.flexfield_application_id),'') || '"';
2382 end if;
2383 
2384 -- Tabular Function Code
2385 if ((l_items_rec.tabular_function_code IS NOT NULL) and
2386 (l_items_rec.tabular_function_code <> FND_API.G_MISS_CHAR)) then
2387 l_index := l_index + 1;
2388 l_databuffer_tbl(l_index) := '    TABULAR_FUNCTION_CODE = "' ||
2389 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2390 l_items_rec.tabular_function_code)|| '"';
2391 end if;
2392 
2393 -- Tip Type
2394 if ((l_items_rec.tip_type IS NOT NULL) and
2395 (l_items_rec.tip_type <> FND_API.G_MISS_CHAR)) then
2396 l_index := l_index + 1;
2397 l_databuffer_tbl(l_index) := '    TIP_TYPE = "' ||
2398 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2399 l_items_rec.tip_type)|| '"';
2400 end if;
2401 
2402 -- Tip Message
2403 if ((l_items_rec.tip_message_name IS NOT NULL) and
2404 (l_items_rec.tip_message_name <> FND_API.G_MISS_CHAR)) then
2405 l_index := l_index + 1;
2406 l_databuffer_tbl(l_index) := '    TIP_MESSAGE_NAME = "' ||
2407 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2408 l_items_rec.tip_message_name)|| '"';
2409 end if;
2410 if ((l_items_rec.tip_message_application_id IS NOT NULL) and
2411 (l_items_rec.tip_message_application_id <> FND_API.G_MISS_NUM)) then
2412 l_index := l_index + 1;
2413 l_databuffer_tbl(l_index) := '    TIP_MESSAGE_APPLICATION_ID = "' ||
2414 nvl(to_char(l_items_rec.tip_message_application_id),'') || '"';
2415 end if;
2416 
2417 -- Flex segment_list
2418 if ((l_items_rec.flex_segment_list IS NOT NULL) and
2419 (l_items_rec.flex_segment_list <> FND_API.G_MISS_CHAR)) then
2420 l_index := l_index + 1;
2421 l_databuffer_tbl(l_index) := '    FLEX_SEGMENT_LIST = "' ||
2422 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2423 l_items_rec.flex_segment_list)|| '"';
2424 end if;
2425 
2426 -- Entity Id
2427 if ((l_items_rec.entity_id IS NOT NULL) and
2428 (l_items_rec.entity_id <> FND_API.G_MISS_CHAR)) then
2429 l_index := l_index + 1;
2430 l_databuffer_tbl(l_index) := '    ENTITY_ID = "' ||
2431 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2432 l_items_rec.entity_id)|| '"';
2433 end if;
2434 
2435 -- Anchor
2436 if ((l_items_rec.anchor IS NOT NULL) and
2437 (l_items_rec.anchor <> FND_API.G_MISS_CHAR)) then
2438 l_index := l_index + 1;
2439 l_databuffer_tbl(l_index) := '    ANCHOR = "' ||
2440 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2441 l_items_rec.anchor)|| '"';
2442 end if;
2443 
2444 -- Poplist view usage name
2445 if ((l_items_rec.poplist_view_usage_name IS NOT NULL) and
2446 (l_items_rec.poplist_view_usage_name <> FND_API.G_MISS_CHAR)) then
2447 l_index := l_index + 1;
2448 l_databuffer_tbl(l_index) := '    POPLIST_VIEW_USAGE_NAME = "' ||
2449 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2450 l_items_rec.poplist_view_usage_name)|| '"';
2451 end if;
2452 
2453 -- User Customizable
2454 if ((l_items_rec.user_customizable IS NOT NULL) and
2455 (l_items_rec.user_customizable <> FND_API.G_MISS_CHAR)) then
2456 l_index := l_index + 1;
2457 l_databuffer_tbl(l_index) := '    USER_CUSTOMIZABLE = "' ||
2458 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2459 l_items_rec.user_customizable)|| '"';
2460 end if;
2461 
2462 -- Sortby view attribute name
2463 if ((l_items_rec.sortby_view_attribute_name IS NOT NULL) and
2464 (l_items_rec.sortby_view_attribute_name <> FND_API.G_MISS_CHAR)) then
2465 l_index := l_index + 1;
2466 l_databuffer_tbl(l_index) := '    SORTBY_VIEW_ATTRIBUTE_NAME = "' ||
2467 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2468 l_items_rec.sortby_view_attribute_name)|| '"';
2469 end if;
2470 
2471 -- Admin Customizable
2472 if ((l_items_rec.admin_customizable IS NOT NULL) and
2473 (l_items_rec.admin_customizable <> FND_API.G_MISS_CHAR)) then
2474 l_index := l_index + 1;
2475 l_databuffer_tbl(l_index) := '    ADMIN_CUSTOMIZABLE = "' ||
2476 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2477 l_items_rec.admin_customizable)|| '"';
2478 end if;
2479 
2480 -- Invoke Function Name
2481 if ((l_items_rec.invoke_function_name IS NOT NULL) and
2482 (l_items_rec.invoke_function_name <> FND_API.G_MISS_CHAR)) then
2483 l_index := l_index + 1;
2484 l_databuffer_tbl(l_index) := '    INVOKE_FUNCTION_NAME = "' ||
2485 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2486 l_items_rec.invoke_function_name)|| '"';
2487 end if;
2488 
2489 -- Expansion
2490 if ((l_items_rec.expansion IS NOT NULL) and
2491 (l_items_rec.expansion <> FND_API.G_MISS_NUM)) then
2492 l_index := l_index + 1;
2493 l_databuffer_tbl(l_index) := '    EXPANSION = "' ||
2494 nvl(to_char(l_items_rec.expansion),'') || '"';
2495 end if;
2496 
2497 -- ALS Max Length
2498 if ((l_items_rec.als_max_length IS NOT NULL) and
2499 (l_items_rec.als_max_length <> FND_API.G_MISS_NUM)) then
2500 l_index := l_index + 1;
2501 l_databuffer_tbl(l_index) := '    ALS_MAX_LENGTH = "' ||
2502 nvl(to_char(l_items_rec.als_max_length),'') || '"';
2503 end if;
2504 
2505 -- INITIAL_SORT_SEQUENCE
2506 if ((l_items_rec.initial_sort_sequence IS NOT NULL) and
2507 (l_items_rec.initial_sort_sequence <> FND_API.G_MISS_CHAR)) then
2508 l_index := l_index + 1;
2509 l_databuffer_tbl(l_index) := '    INITIAL_SORT_SEQUENCE = "' ||
2510 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2511 l_items_rec.initial_sort_sequence)|| '"';
2512 end if;
2513 
2514 -- CUSTOMIZATION_APPLICATION_ID
2515 if ((l_items_rec.customization_application_id IS NOT NULL) and
2516 (l_items_rec.customization_application_id <> FND_API.G_MISS_NUM)) then
2517 l_index := l_index + 1;
2518 l_databuffer_tbl(l_index) := '    CUSTOMIZATION_APPLICATION_ID = "' ||
2519 nvl(to_char(l_items_rec.customization_application_id),'') || '"';
2520 end if;
2521 
2522 -- CUSTOMIZATION_CODE
2523 if ((l_items_rec.customization_code IS NOT NULL) and
2524 (l_items_rec.customization_code <> FND_API.G_MISS_CHAR)) then
2525 l_index := l_index + 1;
2526 l_databuffer_tbl(l_index) := '    CUSTOMIZATION_CODE = "' ||
2527 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2528 l_items_rec.customization_code)|| '"';
2529 end if;
2530 
2531 
2532 -- Flex Field Columns
2533 --
2534 if ((l_items_rec.attribute_category IS NOT NULL) and
2535 (l_items_rec.attribute_category <> FND_API.G_MISS_CHAR)) then
2536 l_index := l_index + 1;
2537 l_databuffer_tbl(l_index) := '    ATTRIBUTE_CATEGORY = "' ||
2538 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2539 l_items_rec.attribute_category) || '"';
2540 end if;
2541 if ((l_items_rec.attribute1 IS NOT NULL) and
2542 (l_items_rec.attribute1 <> FND_API.G_MISS_CHAR)) then
2543 l_index := l_index + 1;
2544 l_databuffer_tbl(l_index) := '    ATTRIBUTE1 = "' ||
2545 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2546 l_items_rec.attribute1) || '"';
2547 end if;
2548 if ((l_items_rec.attribute2 IS NOT NULL) and
2549 (l_items_rec.attribute2 <> FND_API.G_MISS_CHAR)) then
2550 l_index := l_index + 1;
2551 l_databuffer_tbl(l_index) := '    ATTRIBUTE2 = "' ||
2552 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2553 l_items_rec.attribute2) || '"';
2554 end if;
2555 if ((l_items_rec.attribute3 IS NOT NULL) and
2556 (l_items_rec.attribute3 <> FND_API.G_MISS_CHAR)) then
2557 l_index := l_index + 1;
2558 l_databuffer_tbl(l_index) := '    ATTRIBUTE3 = "' ||
2559 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2560 l_items_rec.attribute3) || '"';
2561 end if;
2562 if ((l_items_rec.attribute4 IS NOT NULL) and
2563 (l_items_rec.attribute4 <> FND_API.G_MISS_CHAR)) then
2564 l_index := l_index + 1;
2565 l_databuffer_tbl(l_index) := '    ATTRIBUTE4 = "' ||
2566 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2567 l_items_rec.attribute4) || '"';
2568 end if;
2569 if ((l_items_rec.attribute5 IS NOT NULL) and
2570 (l_items_rec.attribute5 <> FND_API.G_MISS_CHAR)) then
2571 l_index := l_index + 1;
2572 l_databuffer_tbl(l_index) := '    ATTRIBUTE5 = "' ||
2573 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2574 l_items_rec.attribute5) || '"';
2575 end if;
2576 if ((l_items_rec.attribute6 IS NOT NULL) and
2577 (l_items_rec.attribute6 <> FND_API.G_MISS_CHAR)) then
2578 l_index := l_index + 1;
2579 l_databuffer_tbl(l_index) := '    ATTRIBUTE6 = "' ||
2580 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2581 l_items_rec.attribute6) || '"';
2582 end if;
2583 if ((l_items_rec.attribute7 IS NOT NULL) and
2584 (l_items_rec.attribute7 <> FND_API.G_MISS_CHAR)) then
2585 l_index := l_index + 1;
2586 l_databuffer_tbl(l_index) := '    ATTRIBUTE7 = "' ||
2587 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2588 l_items_rec.attribute7) || '"';
2589 end if;
2590 if ((l_items_rec.attribute8 IS NOT NULL) and
2591 (l_items_rec.attribute8 <> FND_API.G_MISS_CHAR)) then
2592 l_index := l_index + 1;
2593 l_databuffer_tbl(l_index) := '    ATTRIBUTE8 = "' ||
2594 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2595 l_items_rec.attribute8) || '"';
2596 end if;
2597 if ((l_items_rec.attribute9 IS NOT NULL) and
2598 (l_items_rec.attribute9 <> FND_API.G_MISS_CHAR)) then
2599 l_index := l_index + 1;
2600 l_databuffer_tbl(l_index) := '    ATTRIBUTE9 = "' ||
2601 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2602 l_items_rec.attribute9) || '"';
2603 end if;
2604 if ((l_items_rec.attribute10 IS NOT NULL) and
2605 (l_items_rec.attribute10 <> FND_API.G_MISS_CHAR)) then
2606 l_index := l_index + 1;
2607 l_databuffer_tbl(l_index) := '    ATTRIBUTE10 = "' ||
2608 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2609 l_items_rec.attribute10) || '"';
2610 end if;
2611 if ((l_items_rec.attribute11 IS NOT NULL) and
2612 (l_items_rec.attribute11 <> FND_API.G_MISS_CHAR)) then
2613 l_index := l_index + 1;
2614 l_databuffer_tbl(l_index) := '    ATTRIBUTE11 = "' ||
2615 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2616 l_items_rec.attribute11) || '"';
2617 end if;
2618 if ((l_items_rec.attribute12 IS NOT NULL) and
2619 (l_items_rec.attribute12 <> FND_API.G_MISS_CHAR)) then
2620 l_index := l_index + 1;
2621 l_databuffer_tbl(l_index) := '    ATTRIBUTE12 = "' ||
2622 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2623 l_items_rec.attribute12) || '"';
2624 end if;
2625 if ((l_items_rec.attribute13 IS NOT NULL) and
2626 (l_items_rec.attribute13 <> FND_API.G_MISS_CHAR)) then
2627 l_index := l_index + 1;
2628 l_databuffer_tbl(l_index) := '    ATTRIBUTE13 = "' ||
2629 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2630 l_items_rec.attribute13) || '"';
2631 end if;
2632 if ((l_items_rec.attribute14 IS NOT NULL) and
2633 (l_items_rec.attribute14 <> FND_API.G_MISS_CHAR)) then
2634 l_index := l_index + 1;
2635 l_databuffer_tbl(l_index) := '    ATTRIBUTE14 = "' ||
2636 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2637 l_items_rec.attribute14) || '"';
2638 end if;
2639 if ((l_items_rec.attribute15 IS NOT NULL) and
2640 (l_items_rec.attribute15 <> FND_API.G_MISS_CHAR)) then
2641 l_index := l_index + 1;
2642 l_databuffer_tbl(l_index) := '    ATTRIBUTE15 = "' ||
2643 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2644 l_items_rec.attribute15) || '"';
2645 end if;
2646 -- - Write out who columns
2647 l_index := l_index + 1;
2648 l_databuffer_tbl(l_index) := '    CREATED_BY = "' ||
2649 nvl(to_char(l_items_rec.created_by),'') || '"';
2650 l_index := l_index + 1;
2651 l_databuffer_tbl(l_index) := '    CREATION_DATE = "' ||
2652 to_char(l_items_rec.creation_date,
2653 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
2654 l_index := l_index + 1;
2655 -- CHANGED TO OWNER FOR R12
2656 --l_databuffer_tbl(l_index) := '    LAST_UPDATED_BY = "' ||
2657 --nvl(to_char(l_items_rec.last_updated_by),'') || '"';
2658 l_databuffer_tbl(l_index) := '    OWNER = "' ||
2659 FND_LOAD_UTIL.OWNER_NAME(l_items_rec.last_updated_by) || '"';
2660 l_index := l_index + 1;
2661 l_databuffer_tbl(l_index) := '    LAST_UPDATE_DATE = "' ||
2662 to_char(l_items_rec.last_update_date,
2663 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
2664 l_index := l_index + 1;
2665 l_databuffer_tbl(l_index) := '    LAST_UPDATE_LOGIN = "' ||
2666 nvl(to_char(l_items_rec.last_update_login),'') || '"';
2667 
2668 -- TL table entries
2669 if ((l_items_tl_rec.attribute_label_long IS NOT NULL) and
2670 (l_items_tl_rec.attribute_label_long <> FND_API.G_MISS_CHAR)) then
2671 l_index := l_index + 1;
2672 l_databuffer_tbl(l_index) := '    ATTRIBUTE_LABEL_LONG = "' ||
2673 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2674 l_items_tl_rec.attribute_label_long)|| '"';
2675 end if;
2676 if ((l_items_tl_rec.attribute_label_short IS NOT NULL) and
2677 (l_items_tl_rec.attribute_label_short <> FND_API.G_MISS_CHAR)) then
2678 l_index := l_index + 1;
2679 l_databuffer_tbl(l_index) := '    ATTRIBUTE_LABEL_SHORT = "' ||
2680 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2681 l_items_tl_rec.attribute_label_short)|| '"';
2682 end if;
2683 if ((l_items_tl_rec.description IS NOT NULL) and
2684 (l_items_tl_rec.description <> FND_API.G_MISS_CHAR)) then
2685 l_index := l_index + 1;
2686 l_databuffer_tbl(l_index) := '    DESCRIPTION = "' ||
2687 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2688 l_items_tl_rec.description)|| '"';
2689 end if;
2690 
2691 -- - Write the region item data to the specified file
2692 AK_ON_OBJECTS_PVT.WRITE_FILE (
2693 p_return_status => l_return_status,
2694 p_buffer_tbl => l_databuffer_tbl,
2695 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
2696 );
2697 -- If API call returns with an error status...
2698 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
2699 (l_return_status = FND_API.G_RET_STS_ERROR) then
2700 close l_get_item_tl_csr;
2701 close l_get_items_csr;
2702 RAISE FND_API.G_EXC_ERROR;
2703 end if;
2704 
2705 l_databuffer_tbl.delete;
2706 
2707 if ( l_items_rec.lov_region_application_id is not null and
2708 l_items_rec.lov_region_code is not null ) then
2709 for l_chk_relation_csr in l_relation_exists_csr (p_region_application_id, p_region_code, l_items_rec.attribute_application_id, l_items_rec.attribute_code, l_items_rec.lov_region_application_id, l_items_rec.lov_region_code ) loop
2710 l_write_relation_flag := true;
2711 end loop;
2712 if l_write_relation_flag then
2713 WRITE_LOV_RELATION_TO_BUFFER(
2714 p_validation_level => p_validation_level,
2715 p_return_status => l_return_status,
2716 p_region_application_id => p_region_application_id,
2717 p_region_code => p_region_code,
2718 p_attribute_application_id => l_items_rec.attribute_application_id,
2719 p_attribute_code => l_items_rec.attribute_code,
2720 p_lov_region_appl_id => l_items_rec.lov_region_application_id,
2721 p_lov_region_code => l_items_rec.lov_region_code
2722 );
2723 else
2724 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
2725 FND_MESSAGE.SET_NAME('AK','AK_LOV_RELATION_DOES_NOT_EXIST');
2726 FND_MSG_PUB.Add;
2727 end if;
2728 -- RAISE FND_API.G_EXC_ERROR;
2729 end if; -- end if l_write_relation_flag
2730 end if;
2731 
2732 for l_chk_category_usages in l_category_usages_csr (p_region_application_id, p_region_code, l_items_rec.attribute_application_id, l_items_rec.attribute_code) loop
2733 l_write_category_usages_flag := true;
2734 end loop;
2735 if l_write_category_usages_flag then
2736 WRITE_CAT_USAGES_TO_BUFFER(
2737 p_validation_level => p_validation_level,
2738 p_return_status => l_return_status,
2739 p_region_application_id => p_region_application_id,
2740 p_region_code => p_region_code,
2741 p_attribute_application_id => l_items_rec.attribute_application_id,
2742 p_attribute_code => l_items_rec.attribute_code
2743 );
2744 end if; -- end if l_write_category_usages_flag
2745 
2746 --
2747 -- Download aborts if validation fails in WRITE_CAT_USAGES_TO_BUFFER
2748 --
2749 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
2750 (l_return_status = FND_API.G_RET_STS_ERROR) then
2751 close l_get_item_tl_csr;
2752 close l_get_items_csr;
2753 RAISE FND_API.G_EXC_ERROR;
2754 end if;
2755 
2756 -- finish up region items
2757 l_index := l_index + 1;
2758 l_databuffer_tbl(l_index) := '  END REGION_ITEM';
2759 l_index := l_index + 1;
2760 l_databuffer_tbl(l_index) := ' ';
2761 end if; -- validation OK
2762 
2763 end if; -- if TL record found
2764 close l_get_item_tl_csr;
2765 
2766 end loop;
2767 close l_get_items_csr;
2768 
2769 -- - Write region item data out to the specified file
2770 --   don't call write_file if there are no items for this region
2771 
2772 if (l_databuffer_tbl.count > 0) then
2773 AK_ON_OBJECTS_PVT.WRITE_FILE (
2774 p_return_status => l_return_status,
2775 p_buffer_tbl => l_databuffer_tbl,
2776 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
2777 );
2778 -- If API call returns with an error status...
2779 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
2780 (l_return_status = FND_API.G_RET_STS_ERROR) then
2781 RAISE FND_API.G_EXC_ERROR;
2782 end if;
2783 end if;
2784 
2785 p_return_status := FND_API.G_RET_STS_SUCCESS;
2786 
2787 EXCEPTION
2788 WHEN VALUE_ERROR THEN
2789 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2790 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_VALUE_ERROR');
2791 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
2792 ' ' || p_region_code ||
2793 ' ' || to_char(l_items_rec.attribute_application_id) ||
2794 ' ' || l_items_rec.attribute_code);
2795 FND_MSG_PUB.Add;
2796 end if;
2797 p_return_status := FND_API.G_RET_STS_ERROR;
2798 WHEN FND_API.G_EXC_ERROR THEN
2799 p_return_status := FND_API.G_RET_STS_ERROR;
2800 WHEN OTHERS THEN
2801 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2802 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
2803 SUBSTR (SQLERRM, 1, 240) );
2804 FND_MSG_PUB.Add;
2805 end WRITE_ITEM_TO_BUFFER;
2806 
2807 --=======================================================
2808 --  Procedure   WRITE_TO_BUFFER (local procedure)
2809 --
2810 --  Usage       Local procedure for writing the given region
2811 --              and all its children records to the output file.
2812 --              Not designed to be called from outside this package.
2813 --
2814 --  Desc        This procedure first retreives and writes the given
2815 --              region to the loader file. Then it calls other local
2816 --              procedure to write all its region items to the same output
2817 --              file.
2818 --
2819 --  Results     The API returns the standard p_return_status parameter
2820 --              indicating one of the standard return statuses :
2821 --                  * Unexpected error
2822 --                  * Error
2823 --                  * Success
2824 --  Parameters
2825 --              p_region_application_id : IN required
2826 --              p_region_code : IN required
2827 --                  Key value of the Region to be extracted to the loader
2828 --                  file.
2829 --              p_nls_language : IN required
2830 --                  The NLS langauge that should be used when
2831 --                  extracting data from the TL table
2832 --=======================================================
2833 procedure WRITE_TO_BUFFER (
2834 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
2835 p_return_status            OUT NOCOPY     VARCHAR2,
2836 p_region_application_id    IN      NUMBER,
2837 p_region_code              IN      VARCHAR2,
2838 p_nls_language             IN      VARCHAR2
2839 ) is
2840 cursor l_get_region_csr is
2841 select *
2842 from  AK_REGIONS
2843 where REGION_APPLICATION_ID = p_region_application_id
2844 and   REGION_CODE = p_region_code;
2845 cursor l_get_region_tl_csr is
2846 select *
2847 from  AK_REGIONS_TL
2848 where REGION_APPLICATION_ID = p_region_application_id
2849 and   REGION_CODE = p_region_code
2850 and   LANGUAGE = p_nls_language;
2851 l_api_name           CONSTANT varchar2(30) := 'Write_to_buffer';
2852 l_databuffer_tbl     AK_ON_OBJECTS_PUB.Buffer_Tbl_Type;
2853 l_index              NUMBER;
2854 l_regions_rec        AK_REGIONS%ROWTYPE;
2855 l_regions_tl_rec     AK_REGIONS_TL%ROWTYPE;
2856 l_return_status      varchar2(1);
2857 begin
2858 -- Retrieve region information from the database
2859 
2860 open l_get_region_csr;
2861 fetch l_get_region_csr into l_regions_rec;
2862 if (l_get_region_csr%notfound) then
2863 close l_get_region_csr;
2864 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
2865 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
2866 FND_MSG_PUB.Add;
2867 end if;
2868 -- dbms_output.put_line('Cannot find region '||p_region_code);
2869 RAISE FND_API.G_EXC_ERROR;
2870 end if;
2871 close l_get_region_csr;
2872 
2873 -- Retrieve region TL information from the database
2874 
2875 open l_get_region_tl_csr;
2876 fetch l_get_region_tl_csr into l_regions_tl_rec;
2877 if (l_get_region_tl_csr%notfound) then
2878 close l_get_region_tl_csr;
2879 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
2880 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
2881 FND_MSG_PUB.Add;
2882 end if;
2883 --dbms_output.put_line('Cannot find region TL '||p_region_code);
2884 RAISE FND_API.G_EXC_ERROR;
2885 end if;
2886 close l_get_region_tl_csr;
2887 
2888 -- Region must be validated before it is written to the file
2889 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
2890 if not AK_REGION_PVT.VALIDATE_REGION (
2891 p_validation_level => p_validation_level,
2892 p_api_version_number => 1.0,
2893 p_return_status => l_return_status,
2894 p_region_application_id => l_regions_rec.region_application_id,
2895 p_region_code => l_regions_rec.region_code,
2896 p_database_object_name => l_regions_rec.database_object_name,
2897 p_region_style => l_regions_rec.region_style,
2898 p_icx_custom_call => l_regions_rec.icx_custom_call,
2899 p_num_columns => l_regions_rec.num_columns,
2900 p_region_defaulting_api_pkg => l_regions_rec.region_defaulting_api_pkg,
2901 p_region_defaulting_api_proc =>
2902 l_regions_rec.region_defaulting_api_proc,
2903 p_region_validation_api_pkg => l_regions_rec.region_validation_api_pkg,
2904 p_region_validation_api_proc =>
2905 l_regions_rec.region_validation_api_proc,
2906 p_name => l_regions_tl_rec.name,
2907 p_description => l_regions_tl_rec.description,
2908 p_caller => AK_ON_OBJECTS_PVT.G_DOWNLOAD)
2909 then
2910 --  dbms_output.put_line('Region ' || p_region_code
2911 --  || ' not downloaded due to validation error');
2912 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
2913 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_DOWNLOADED');
2914 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||' '||
2915 p_region_code);
2916 FND_MSG_PUB.Add;
2917 end if;
2918 raise FND_API.G_EXC_ERROR;
2919 end if; /* if AK_REGION_PVT.VALIDATE_REGION */
2920 end if; /* if p_validation_level */
2921 
2922 -- Write region into buffer
2923 l_index := 1;
2924 
2925 l_databuffer_tbl(l_index) := 'BEGIN REGION "' ||
2926 nvl(to_char(p_region_application_id), '') || '" "' ||
2927 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(p_region_code) || '"';
2928 l_index := l_index + 1;
2929 l_databuffer_tbl(l_index) := '  DATABASE_OBJECT_NAME = "' ||
2930 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_regions_rec.database_object_name)
2931 || '"';
2932 l_index := l_index + 1;
2933 l_databuffer_tbl(l_index) := '  REGION_STYLE = "' ||
2934 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_regions_rec.region_style) || '"';
2935 if ((l_regions_rec.num_columns IS NOT NULL) and
2936 (l_regions_rec.num_columns <> FND_API.G_MISS_NUM)) then
2937 l_index := l_index + 1;
2938 l_databuffer_tbl(l_index) := '  NUM_COLUMNS = "' ||
2939 nvl(to_char(l_regions_rec.num_columns), '') || '"';
2940 end if;
2941 if ((l_regions_rec.icx_custom_call IS NOT NULL) and
2942 (l_regions_rec.icx_custom_call <> FND_API.G_MISS_CHAR)) then
2943 l_index := l_index + 1;
2944 l_databuffer_tbl(l_index) := '  ICX_CUSTOM_CALL = "' ||
2945 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_regions_rec.icx_custom_call)||'"';
2946 end if;
2947 if ((l_regions_rec.region_defaulting_api_pkg IS NOT NULL) and
2948 (l_regions_rec.region_defaulting_api_pkg <> FND_API.G_MISS_CHAR)) then
2949 l_index := l_index + 1;
2950 l_databuffer_tbl(l_index) := '  REGION_DEFAULTING_API_PKG = "' ||
2951 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2952 l_regions_rec.region_defaulting_api_pkg)|| '"';
2953 end if;
2954 if ((l_regions_rec.region_defaulting_api_proc IS NOT NULL) and
2955 (l_regions_rec.region_defaulting_api_proc <> FND_API.G_MISS_CHAR)) then
2956 l_index := l_index + 1;
2957 l_databuffer_tbl(l_index) := '  REGION_DEFAULTING_API_PROC = "' ||
2958 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2959 l_regions_rec.region_defaulting_api_proc)|| '"';
2960 end if;
2961 if ((l_regions_rec.region_validation_api_pkg IS NOT NULL) and
2962 (l_regions_rec.region_validation_api_pkg <> FND_API.G_MISS_CHAR)) then
2963 l_index := l_index + 1;
2964 l_databuffer_tbl(l_index) := '  REGION_VALIDATION_API_PKG = "' ||
2965 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2966 l_regions_rec.region_validation_api_pkg)|| '"';
2967 end if;
2968 if ((l_regions_rec.region_validation_api_proc IS NOT NULL) and
2969 (l_regions_rec.region_validation_api_proc <> FND_API.G_MISS_CHAR)) then
2970 l_index := l_index + 1;
2971 l_databuffer_tbl(l_index) := '  REGION_VALIDATION_API_PROC = "' ||
2972 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2973 l_regions_rec.region_validation_api_proc)|| '"';
2974 end if;
2975 if ((l_regions_rec.applicationmodule_object_type IS NOT NULL) and
2976 (l_regions_rec.applicationmodule_object_type <> FND_API.G_MISS_CHAR)) then
2977 l_index := l_index + 1;
2978 l_databuffer_tbl(l_index) := '  APPLICATIONMODULE_OBJECT_TYPE = "' ||
2979 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2980 l_regions_rec.applicationmodule_object_type)|| '"';
2981 end if;
2982 if ((l_regions_rec.num_rows_display IS NOT NULL) and
2983 (l_regions_rec.num_rows_display <> FND_API.G_MISS_NUM)) then
2984 l_index := l_index + 1;
2985 l_databuffer_tbl(l_index) := '  NUM_ROWS_DISPLAY = "' ||
2986 nvl(to_char(l_regions_rec.num_rows_display), '') || '"';
2987 end if;
2988 if ((l_regions_rec.region_object_type IS NOT NULL) and
2989 (l_regions_rec.region_object_type <> FND_API.G_MISS_CHAR)) then
2990 l_index := l_index + 1;
2991 l_databuffer_tbl(l_index) := '  REGION_OBJECT_TYPE = "' ||
2992 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
2993 l_regions_rec.region_object_type)|| '"';
2994 end if;
2995 if ((l_regions_rec.image_file_name IS NOT NULL) and
2996 (l_regions_rec.image_file_name <> FND_API.G_MISS_CHAR)) then
2997 l_index := l_index + 1;
2998 l_databuffer_tbl(l_index) := '  IMAGE_FILE_NAME = "' ||
2999 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3000 l_regions_rec.image_file_name)|| '"';
3001 end if;
3002 if ((l_regions_rec.isform_flag IS NOT NULL) and
3003 (l_regions_rec.isform_flag <> FND_API.G_MISS_CHAR)) then
3004 l_index := l_index + 1;
3005 l_databuffer_tbl(l_index) := '  ISFORM_FLAG = "' ||
3006 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3007 l_regions_rec.isform_flag)|| '"';
3008 end if;
3009 if ((l_regions_rec.help_target IS NOT NULL) and
3010 (l_regions_rec.help_target <> FND_API.G_MISS_CHAR)) then
3011 l_index := l_index + 1;
3012 l_databuffer_tbl(l_index) := '  HELP_TARGET = "' ||
3013 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3014 l_regions_rec.help_target)|| '"';
3015 end if;
3016 if ((l_regions_rec.style_sheet_filename IS NOT NULL) and
3017 (l_regions_rec.style_sheet_filename <> FND_API.G_MISS_CHAR)) then
3018 l_index := l_index + 1;
3019 l_databuffer_tbl(l_index) := '  STYLE_SHEET_FILENAME = "' ||
3020 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3021 l_regions_rec.style_sheet_filename)|| '"';
3022 end if;
3023 if ((l_regions_rec.version IS NOT NULL) and
3024 (l_regions_rec.version <> FND_API.G_MISS_CHAR)) then
3025 l_index := l_index + 1;
3026 l_databuffer_tbl(l_index) := '  VERSION = "' ||
3027 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3028 l_regions_rec.version)|| '"';
3029 end if;
3030 if ((l_regions_rec.applicationmodule_usage_name IS NOT NULL) and
3031 (l_regions_rec.applicationmodule_usage_name <> FND_API.G_MISS_CHAR)) then
3032 l_index := l_index + 1;
3033 l_databuffer_tbl(l_index) := '  APPLICATIONMODULE_USAGE_NAME = "' ||
3034 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3035 l_regions_rec.applicationmodule_usage_name)|| '"';
3036 end if;
3037 if ((l_regions_rec.add_indexed_children IS NOT NULL) and
3038 (l_regions_rec.add_indexed_children <> FND_API.G_MISS_CHAR)) then
3039 l_index := l_index + 1;
3040 l_databuffer_tbl(l_index) := '  ADD_INDEXED_CHILDREN = "' ||
3041 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3042 l_regions_rec.add_indexed_children)|| '"';
3043 end if;
3044 if ((l_regions_rec.stateful_flag IS NOT NULL) and
3045 (l_regions_rec.stateful_flag <> FND_API.G_MISS_CHAR)) then
3046 l_index := l_index + 1;
3047 l_databuffer_tbl(l_index) := '  STATEFUL_FLAG = "' ||
3048 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3049 l_regions_rec.stateful_flag)|| '"';
3050 end if;
3051 if ((l_regions_rec.function_name IS NOT NULL) and
3052 (l_regions_rec.function_name <> FND_API.G_MISS_CHAR)) then
3053 l_index := l_index + 1;
3054 l_databuffer_tbl(l_index) := '  FUNCTION_NAME = "' ||
3055 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3056 l_regions_rec.function_name)|| '"';
3057 end if;
3058 if ((l_regions_rec.children_view_usage_name IS NOT NULL) and
3059 (l_regions_rec.children_view_usage_name <> FND_API.G_MISS_CHAR)) then
3060 l_index := l_index + 1;
3061 l_databuffer_tbl(l_index) := '  CHILDREN_VIEW_USAGE_NAME = "' ||
3062 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3063 l_regions_rec.children_view_usage_name)|| '"';
3064 end if;
3065 if ((l_regions_rec.search_panel IS NOT NULL) and
3066 (l_regions_rec.search_panel <> FND_API.G_MISS_CHAR)) then
3067 l_index := l_index + 1;
3068 l_databuffer_tbl(l_index) := '  SEARCH_PANEL = "' ||
3069 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3070 l_regions_rec.search_panel)|| '"';
3071 end if;
3072 if ((l_regions_rec.advanced_search_panel IS NOT NULL) and
3073 (l_regions_rec.advanced_search_panel <> FND_API.G_MISS_CHAR)) then
3074 l_index := l_index + 1;
3075 l_databuffer_tbl(l_index) := '  ADVANCED_SEARCH_PANEL = "' ||
3076 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3077 l_regions_rec.advanced_search_panel)|| '"';
3078 end if;
3079 if ((l_regions_rec.customize_panel IS NOT NULL) and
3080 (l_regions_rec.customize_panel <> FND_API.G_MISS_CHAR)) then
3081 l_index := l_index + 1;
3082 l_databuffer_tbl(l_index) := '  CUSTOMIZE_PANEL = "' ||
3083 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3084 l_regions_rec.customize_panel)|| '"';
3085 end if;
3086 if ((l_regions_rec.default_search_panel IS NOT NULL) and
3087 (l_regions_rec.default_search_panel <> FND_API.G_MISS_CHAR)) then
3088 l_index := l_index + 1;
3089 l_databuffer_tbl(l_index) := '  DEFAULT_SEARCH_PANEL = "' ||
3090 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3091 l_regions_rec.default_search_panel)|| '"';
3092 end if;
3093 if ((l_regions_rec.results_based_search IS NOT NULL) and
3094 (l_regions_rec.results_based_search <> FND_API.G_MISS_CHAR)) then
3095 l_index := l_index + 1;
3096 l_databuffer_tbl(l_index) := '  RESULTS_BASED_SEARCH = "' ||
3097 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3098 l_regions_rec.results_based_search)|| '"';
3099 end if;
3100 if ((l_regions_rec.display_graph_table IS NOT NULL) and
3101 (l_regions_rec.display_graph_table <> FND_API.G_MISS_CHAR)) then
3102 l_index := l_index + 1;
3103 l_databuffer_tbl(l_index) := '  DISPLAY_GRAPH_TABLE = "' ||
3104 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3105 l_regions_rec.display_graph_table)|| '"';
3106 end if;
3107 if ((l_regions_rec.disable_header IS NOT NULL) and
3108 (l_regions_rec.disable_header <> FND_API.G_MISS_CHAR)) then
3109 l_index := l_index + 1;
3110 l_databuffer_tbl(l_index) := '  DISABLE_HEADER = "' ||
3111 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3112 l_regions_rec.disable_header)|| '"';
3113 end if;
3114 if ((l_regions_rec.standalone IS NOT NULL) and
3115 (l_regions_rec.standalone <> FND_API.G_MISS_CHAR)) then
3116 l_index := l_index + 1;
3117 l_databuffer_tbl(l_index) := '  STANDALONE = "' ||
3118 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3119 l_regions_rec.standalone)|| '"';
3120 end if;
3121 if ((l_regions_rec.auto_customization_criteria IS NOT NULL) and
3122 (l_regions_rec.auto_customization_criteria <> FND_API.G_MISS_CHAR)) then
3123 l_index := l_index + 1;
3124 l_databuffer_tbl(l_index) := '  AUTO_CUSTOMIZATION_CRITERIA = "' ||
3125 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3126 l_regions_rec.auto_customization_criteria)|| '"';
3127 end if;
3128 
3129 -- Flex Fields
3130 --
3131 if ((l_regions_rec.attribute_category IS NOT NULL) and
3132 (l_regions_rec.attribute_category <> FND_API.G_MISS_CHAR)) then
3133 l_index := l_index + 1;
3134 l_databuffer_tbl(l_index) := '  ATTRIBUTE_CATEGORY = "' ||
3135 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3136 l_regions_rec.attribute_category) || '"';
3137 end if;
3138 if ((l_regions_rec.attribute1 IS NOT NULL) and
3139 (l_regions_rec.attribute1 <> FND_API.G_MISS_CHAR)) then
3140 l_index := l_index + 1;
3141 l_databuffer_tbl(l_index) := '  ATTRIBUTE1 = "' ||
3142 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3143 l_regions_rec.attribute1) || '"';
3144 end if;
3145 if ((l_regions_rec.attribute2 IS NOT NULL) and
3146 (l_regions_rec.attribute2 <> FND_API.G_MISS_CHAR)) then
3147 l_index := l_index + 1;
3148 l_databuffer_tbl(l_index) := '  ATTRIBUTE2 = "' ||
3149 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3150 l_regions_rec.attribute2) || '"';
3151 end if;
3152 if ((l_regions_rec.attribute3 IS NOT NULL) and
3153 (l_regions_rec.attribute3 <> FND_API.G_MISS_CHAR)) then
3154 l_index := l_index + 1;
3155 l_databuffer_tbl(l_index) := '  ATTRIBUTE3 = "' ||
3156 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3157 l_regions_rec.attribute3) || '"';
3158 end if;
3159 if ((l_regions_rec.attribute4 IS NOT NULL) and
3160 (l_regions_rec.attribute4 <> FND_API.G_MISS_CHAR)) then
3161 l_index := l_index + 1;
3162 l_databuffer_tbl(l_index) := '  ATTRIBUTE4 = "' ||
3163 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3164 l_regions_rec.attribute4) || '"';
3165 end if;
3166 if ((l_regions_rec.attribute5 IS NOT NULL) and
3167 (l_regions_rec.attribute5 <> FND_API.G_MISS_CHAR)) then
3168 l_index := l_index + 1;
3169 l_databuffer_tbl(l_index) := '  ATTRIBUTE5 = "' ||
3170 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3171 l_regions_rec.attribute5) || '"';
3172 end if;
3173 if ((l_regions_rec.attribute6 IS NOT NULL) and
3174 (l_regions_rec.attribute6 <> FND_API.G_MISS_CHAR)) then
3175 l_index := l_index + 1;
3176 l_databuffer_tbl(l_index) := '  ATTRIBUTE6 = "' ||
3177 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3178 l_regions_rec.attribute6) || '"';
3179 end if;
3180 if ((l_regions_rec.attribute7 IS NOT NULL) and
3181 (l_regions_rec.attribute7 <> FND_API.G_MISS_CHAR)) then
3182 l_index := l_index + 1;
3183 l_databuffer_tbl(l_index) := '  ATTRIBUTE7 = "' ||
3184 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3185 l_regions_rec.attribute7) || '"';
3186 end if;
3187 if ((l_regions_rec.attribute8 IS NOT NULL) and
3188 (l_regions_rec.attribute8 <> FND_API.G_MISS_CHAR)) then
3189 l_index := l_index + 1;
3190 l_databuffer_tbl(l_index) := '  ATTRIBUTE8 = "' ||
3191 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3192 l_regions_rec.attribute8) || '"';
3193 end if;
3194 if ((l_regions_rec.attribute9 IS NOT NULL) and
3195 (l_regions_rec.attribute9 <> FND_API.G_MISS_CHAR)) then
3196 l_index := l_index + 1;
3197 l_databuffer_tbl(l_index) := '  ATTRIBUTE9 = "' ||
3198 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3199 l_regions_rec.attribute9) || '"';
3200 end if;
3201 if ((l_regions_rec.attribute10 IS NOT NULL) and
3202 (l_regions_rec.attribute10 <> FND_API.G_MISS_CHAR)) then
3203 l_index := l_index + 1;
3204 l_databuffer_tbl(l_index) := '  ATTRIBUTE10 = "' ||
3205 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3206 l_regions_rec.attribute10) || '"';
3207 end if;
3208 if ((l_regions_rec.attribute11 IS NOT NULL) and
3209 (l_regions_rec.attribute11 <> FND_API.G_MISS_CHAR)) then
3210 l_index := l_index + 1;
3211 l_databuffer_tbl(l_index) := '  ATTRIBUTE11 = "' ||
3212 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3213 l_regions_rec.attribute11) || '"';
3214 end if;
3215 if ((l_regions_rec.attribute12 IS NOT NULL) and
3216 (l_regions_rec.attribute12 <> FND_API.G_MISS_CHAR)) then
3217 l_index := l_index + 1;
3218 l_databuffer_tbl(l_index) := '  ATTRIBUTE12 = "' ||
3219 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3220 l_regions_rec.attribute12) || '"';
3221 end if;
3222 if ((l_regions_rec.attribute13 IS NOT NULL) and
3223 (l_regions_rec.attribute13 <> FND_API.G_MISS_CHAR)) then
3224 l_index := l_index + 1;
3225 l_databuffer_tbl(l_index) := '  ATTRIBUTE13 = "' ||
3226 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3227 l_regions_rec.attribute13) || '"';
3228 end if;
3229 if ((l_regions_rec.attribute14 IS NOT NULL) and
3230 (l_regions_rec.attribute14 <> FND_API.G_MISS_CHAR)) then
3231 l_index := l_index + 1;
3232 l_databuffer_tbl(l_index) := '  ATTRIBUTE14 = "' ||
3233 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3234 l_regions_rec.attribute14) || '"';
3235 end if;
3236 if ((l_regions_rec.attribute15 IS NOT NULL) and
3237 (l_regions_rec.attribute15 <> FND_API.G_MISS_CHAR)) then
3238 l_index := l_index + 1;
3239 l_databuffer_tbl(l_index) := '  ATTRIBUTE15 = "' ||
3240 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(
3241 l_regions_rec.attribute15) || '"';
3242 end if;
3243 -- - Write out who columns
3244 l_index := l_index + 1;
3245 l_databuffer_tbl(l_index) := '  CREATED_BY = "' ||
3246 nvl(to_char(l_regions_rec.created_by),'') || '"';
3247 l_index := l_index + 1;
3248 l_databuffer_tbl(l_index) := '  CREATION_DATE = "' ||
3249 to_char(l_regions_rec.creation_date,
3250 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
3251 l_index := l_index + 1;
3252 -- CHANGED TO OWNER FOR R12
3253 -- l_databuffer_tbl(l_index) := '  LAST_UPDATED_BY = "' ||
3254 -- nvl(to_char(l_regions_rec.last_updated_by),'') || '"';
3255 l_databuffer_tbl(l_index) := '  OWNER = "' ||
3256 FND_LOAD_UTIL.OWNER_NAME(l_regions_rec.last_updated_by) || '"';
3257 l_index := l_index + 1;
3258 l_databuffer_tbl(l_index) := '  LAST_UPDATE_DATE = "' ||
3259 to_char(l_regions_rec.last_update_date,
3260 AK_ON_OBJECTS_PUB.G_DATE_FORMAT) || '"';
3261 l_index := l_index + 1;
3262 l_databuffer_tbl(l_index) := '  LAST_UPDATE_LOGIN = "' ||
3263 nvl(to_char(l_regions_rec.last_update_login),'') || '"';
3264 
3265 -- translation columns
3266 --
3267 if ((l_regions_tl_rec.name IS NOT NULL) and
3268 (l_regions_tl_rec.name <> FND_API.G_MISS_CHAR)) then
3269 l_index := l_index + 1;
3270 l_databuffer_tbl(l_index) := '  NAME = "' ||
3271 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_regions_tl_rec.name)||'"';
3272 end if;
3273 if ((l_regions_tl_rec.description IS NOT NULL) and
3274 (l_regions_tl_rec.description <> FND_API.G_MISS_CHAR)) then
3275 l_index := l_index + 1;
3276 l_databuffer_tbl(l_index) := '  DESCRIPTION = "' ||
3277 AK_ON_OBJECTS_PVT.REPLACE_SPECIAL_CHAR(l_regions_tl_rec.description)||'"';
3278 end if;
3279 
3280 -- - Write the region data to the specified file
3281 AK_ON_OBJECTS_PVT.WRITE_FILE (
3282 p_return_status => l_return_status,
3283 p_buffer_tbl => l_databuffer_tbl,
3284 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
3285 );
3286 -- If API call returns with an error status...
3287 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
3288 (l_return_status = FND_API.G_RET_STS_ERROR) then
3289 RAISE FND_API.G_EXC_ERROR;
3290 end if;
3291 
3292 l_databuffer_tbl.delete;
3293 
3294 WRITE_ITEM_TO_BUFFER (
3295 p_validation_level => p_validation_level,
3296 p_return_status => l_return_status,
3297 p_region_application_id => l_regions_rec.region_application_id,
3298 p_region_code => l_regions_rec.region_code,
3299 p_nls_language => p_nls_language
3300 );
3301 --
3302 -- Download aborts if validation fails in WRITE_ITEM_TO_BUFFER
3303 --
3304 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
3305 (l_return_status = FND_API.G_RET_STS_ERROR) then
3306 RAISE FND_API.G_EXC_ERROR;
3307 end if;
3308 
3309 /*
3310 WRITE_GRAPH_TO_BUFFER (
3311 p_validation_level => p_validation_level,
3312 p_return_status => l_return_status,
3313 p_region_application_id => l_regions_rec.region_application_id,
3314 p_region_code => l_regions_rec.region_code,
3315 p_nls_language => p_nls_language
3316 );
3317 */
3318 
3319 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
3320 (l_return_status = FND_API.G_RET_STS_ERROR) then
3321 RAISE FND_API.G_EXC_ERROR;
3322 end if;
3323 
3324 l_index := 1;
3325 l_databuffer_tbl(l_index) := 'END REGION';
3326 l_index := l_index + 1;
3327 l_databuffer_tbl(l_index) := ' ';
3328 
3329 -- - Write the 'END REGION' to the specified file
3330 AK_ON_OBJECTS_PVT.WRITE_FILE (
3331 p_return_status => l_return_status,
3332 p_buffer_tbl => l_databuffer_tbl,
3333 p_write_mode => AK_ON_OBJECTS_PUB.G_APPEND
3334 );
3335 -- If API call returns with an error status...
3336 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
3337 (l_return_status = FND_API.G_RET_STS_ERROR) then
3338 RAISE FND_API.G_EXC_ERROR;
3339 end if;
3340 
3341 p_return_status := FND_API.G_RET_STS_SUCCESS;
3342 
3343 EXCEPTION
3344 WHEN VALUE_ERROR THEN
3345 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3346 FND_MESSAGE.SET_NAME('AK','AK_REGION_VALUE_ERROR');
3347 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
3348 ' ' || p_region_code);
3349 FND_MSG_PUB.Add;
3350 end if;
3351 p_return_status := FND_API.G_RET_STS_ERROR;
3352 WHEN FND_API.G_EXC_ERROR THEN
3353 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3354 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_DOWNLOADED');
3355 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
3356 ' ' || p_region_code);
3357 FND_MSG_PUB.Add;
3358 end if;
3359 p_return_status := FND_API.G_RET_STS_ERROR;
3360 WHEN OTHERS THEN
3361 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3362 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
3363 SUBSTR (SQLERRM, 1, 240) );
3364 FND_MSG_PUB.Add;
3365 end WRITE_TO_BUFFER;
3366 
3367 /*
3368 --=======================================================
3369 --  Procedure   CREATE_GRAPH
3370 --
3371 --  Usage       Private API for creating a region graph. This
3372 --              API should only be called by other APIs that are
3373 --              owned by the Core Modules Team (AK).
3374 --
3375 --  Desc        Creates a region graph using the given info.
3376 --              This API should only be called by other APIs that are
3377 --              owned by the Core Modules Team (AK).
3378 --
3379 --  Results     The API returns the standard p_return_status parameter
3380 --              indicating one of the standard return statuses :
3381 --                  * Unexpected error
3382 --                  * Error
3383 --                  * Success
3384 --  Parameters  Region Item columns
3385 --              p_loader_timestamp : IN optional
3386 --                  If a timestamp is passed, the API will create the
3387 --                  record using this timestamp. Only the upload API
3388 --                  should call with this parameter loaded.
3389 --
3390 --  Version     Initial version number  =   1.0
3391 --  History     Current version number  =   1.0
3392 --=======================================================
3393 procedure CREATE_GRAPH (
3394 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
3395 p_api_version_number       IN      NUMBER,
3396 p_init_msg_tbl             IN      BOOLEAN := FALSE,
3397 p_msg_count                OUT NOCOPY     NUMBER,
3398 p_msg_data                 OUT NOCOPY     VARCHAR2,
3399 p_return_status            OUT NOCOPY     VARCHAR2,
3400 p_region_application_id    IN      NUMBER,
3401 p_region_code              IN      VARCHAR2,
3402 p_graph_number	     IN	     NUMBER := FND_API.G_MISS_NUM,
3403 p_graph_style		     IN      NUMBER := FND_API.G_MISS_NUM,
3404 p_display_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3405 p_depth_radius	     IN      NUMBER := FND_API.G_MISS_NUM,
3406 p_graph_title		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3407 p_y_axis_label	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3408 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
3409 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
3410 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
3411 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
3412 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
3413 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
3414 p_pass                     IN      NUMBER,
3415 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
3416 ) is
3417 l_api_version_number      CONSTANT number := 1.0;
3418 l_api_name                CONSTANT varchar2(30) := 'Create_Graph';
3419 l_created_by			NUMBER;
3420 l_creation_date		DATE;
3421 l_last_update_date		DATE;
3422 l_last_update_login		NUMBER;
3423 l_last_updated_by		NUMBER;
3424 l_y_axis_label		VARCHAR2(80);
3425 l_graph_title			VARCHAR2(240);
3426 l_depth_radius		NUMBER(15);
3427 l_display_flag		VARCHAR2(1);
3428 l_graph_style			NUMBER(15);
3429 l_graph_number		NUMBER(15);
3430 l_return_status		VARCHAR2(1);
3431 l_lang			VARCHAR2(30);
3432 begin
3433 IF NOT FND_API.Compatible_API_Call (
3434 l_api_version_number, p_api_version_number, l_api_name,
3435 G_PKG_NAME) then
3436 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3437 return;
3438 END IF;
3439 
3440 -- Initialize the message table if requested.
3441 
3442 if p_init_msg_tbl then
3443 FND_MSG_PUB.initialize;
3444 end if;
3445 
3446 savepoint start_create_graph;
3447 
3448 --** check to see if row already exists **
3449 if AK_REGION_PVT.GRAPH_EXISTS (
3450 p_api_version_number => 1.0,
3451 p_return_status => l_return_status,
3452 p_region_application_id => p_region_application_id,
3453 p_region_code => p_region_code,
3454 p_graph_number => p_graph_number) then
3455 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
3456 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_EXISTS');
3457 FND_MSG_PUB.Add;
3458 end if;
3459 --dbms_output.put_line(l_api_name || 'Error - row already exists');
3460 raise FND_API.G_EXC_ERROR;
3461 end if;
3462 
3463 --** validate table columns passed in **
3464 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
3465 if not VALIDATE_GRAPH (
3466 p_validation_level => p_validation_level,
3467 p_api_version_number => p_api_version_number,
3468 p_return_status => p_return_status,
3469 p_region_application_id => p_region_application_id,
3470 p_region_code => p_region_code,
3471 p_graph_number => p_graph_number,
3472 p_graph_style => p_graph_style,
3473 p_display_flag => p_display_flag,
3474 p_depth_radius => p_depth_radius,
3475 p_graph_title => p_graph_title,
3476 p_y_axis_label => p_y_axis_label,
3477 p_caller => AK_ON_OBJECTS_PVT.G_CREATE,
3478 p_pass => p_pass
3479 ) then
3480 -- Do not raise an error if it's the first pass
3481 if (p_pass = 1) then
3482 p_copy_redo_flag := TRUE;
3483 else
3484 raise FND_API.G_EXC_ERROR;
3485 end if;
3486 end if;
3487 end if;
3488 
3489 --** Load non-required columns if their values are given **
3490 if (p_depth_radius <> FND_API.G_MISS_NUM) then
3491 l_depth_radius := p_depth_radius;
3492 end if;
3493 
3494 if (p_graph_title <> FND_API.G_MISS_CHAR) then
3495 l_graph_title := p_graph_title;
3496 end if;
3497 
3498 if (p_y_axis_label <> FND_API.G_MISS_CHAR) then
3499 l_y_axis_label := p_y_axis_label;
3500 end if;
3501 
3502 -- Create record if no validation error was found
3503 
3504 -- Set WHO columns
3505 AK_UPLOAD_GRP.G_UPLOAD_DATE := p_last_update_date;
3506 AK_ON_OBJECTS_PVT.SET_WHO (
3507 p_return_status => l_return_status,
3508 p_loader_timestamp => p_loader_timestamp,
3509 p_created_by => l_created_by,
3510 p_creation_date => l_creation_date,
3511 p_last_updated_by => l_last_updated_by,
3512 p_last_update_date => l_last_update_date,
3513 p_last_update_login => l_last_update_login);
3514 
3515   if (AK_UPLOAD_GRP.G_NON_SEED_DATA) then
3516         l_created_by := p_created_by;
3517         l_last_updated_by := p_last_updated_by;
3518         l_last_update_login := p_last_update_login;
3519   end if;
3520 
3521 select userenv('LANG') into l_lang
3522 from dual;
3523 
3524 insert into AK_REGION_GRAPHS (
3525 REGION_APPLICATION_ID,
3526 REGION_CODE,
3527 GRAPH_NUMBER,
3528 GRAPH_STYLE,
3529 DISPLAY_FLAG,
3530 DEPTH_RADIUS,
3531 CREATION_DATE,
3532 CREATED_BY,
3533 LAST_UPDATE_DATE,
3534 LAST_UPDATED_BY,
3535 LAST_UPDATE_LOGIN
3536 ) values (
3537 p_region_application_id,
3538 p_region_code,
3539 p_graph_number,
3540 p_graph_style,
3541 p_display_flag,
3542 l_depth_radius,
3543 l_creation_date,
3544 l_created_by,
3545 l_last_update_date,
3546 l_last_updated_by,
3547 l_last_update_login
3548 );
3549 
3550 --** row should exists before inserting rows for other languages **
3551 if NOT AK_REGION_PVT.GRAPH_EXISTS (
3552 p_api_version_number => 1.0,
3553 p_return_status => l_return_status,
3554 p_region_application_id => p_region_application_id,
3555 p_region_code => p_region_code,
3556 p_graph_number => p_graph_number) then
3557 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
3558 FND_MESSAGE.SET_NAME('AK','AK_INSERT_REG_GRAPH_FAILED');
3559 FND_MSG_PUB.Add;
3560 end if;
3561 --dbms_output.put_line(l_api_name || 'Error - row already exists');
3562 raise FND_API.G_EXC_ERROR;
3563 end if;
3564 
3565 insert into AK_REGION_GRAPHS_TL (
3566 REGION_APPLICATION_ID,
3567 REGION_CODE,
3568 GRAPH_NUMBER,
3569 LANGUAGE,
3570 GRAPH_TITLE,
3571 Y_AXIS_LABEL,
3572 SOURCE_LANG,
3573 CREATED_BY,
3574 CREATION_DATE,
3575 LAST_UPDATED_BY,
3576 LAST_UPDATE_DATE,
3577 LAST_UPDATE_LOGIN
3578 ) select
3579 p_region_application_id,
3580 p_region_code,
3581 p_graph_number,
3582 L.LANGUAGE_CODE,
3583 l_graph_title,
3584 l_y_axis_label,
3585 decode(L.LANGUAGE_CODE, l_lang, L.LANGUAGE_CODE, l_lang),
3586 l_created_by,
3587 l_creation_date,
3588 l_last_updated_by,
3589 l_last_update_date,
3590 l_last_update_login
3591 from FND_LANGUAGES L
3592 where L.INSTALLED_FLAG in ('I', 'B')
3593 and not exists
3594 (select NULL
3595 from AK_REGION_GRAPHS_TL T
3596 where T.REGION_APPLICATION_ID = p_region_application_id
3597 and T.REGION_CODE = p_region_code
3598 and T.GRAPH_NUMBER = p_graph_number
3599 and T.LANGUAGE = L.LANGUAGE_CODE);
3600 
3601 --  ** commit the insert **
3602 commit;
3603 
3604 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
3605 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_CREATED');
3606 FND_MESSAGE.SET_TOKEN('OBJECT', 'AK_LC_REGION_GRAPH',TRUE);
3607 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
3608 ' ' || p_region_code ||
3609 ' ' || p_graph_number);
3610 FND_MSG_PUB.Add;
3611 end if;
3612 
3613 p_return_status := FND_API.G_RET_STS_SUCCESS;
3614 
3615 FND_MSG_PUB.Count_And_Get (
3616 p_count => p_msg_count,
3617 p_data => p_msg_data);
3618 
3619 EXCEPTION
3620 WHEN VALUE_ERROR THEN
3621 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3622 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_VALUE_ERROR');
3623 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
3624 ' ' || p_region_code ||
3625 ' ' || p_graph_number);
3626 FND_MSG_PUB.Add;
3627 end if;
3628 p_return_status := FND_API.G_RET_STS_ERROR;
3629 rollback to start_create_graph;
3630 FND_MSG_PUB.Count_And_Get (
3631 p_count => p_msg_count,
3632 p_data => p_msg_data);
3633 WHEN FND_API.G_EXC_ERROR THEN
3634 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3635 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_CREATED');
3636 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
3637 ' ' || p_region_code ||
3638 ' ' || p_graph_number);
3639 FND_MSG_PUB.Add;
3640 end if;
3641 p_return_status := FND_API.G_RET_STS_ERROR;
3642 rollback to start_create_graph;
3643 FND_MSG_PUB.Count_And_Get (
3644 p_count => p_msg_count,
3645 p_data => p_msg_data);
3646 WHEN OTHERS THEN
3647 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3648 rollback to start_create_graph;
3649 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
3650 SUBSTR (SQLERRM, 1, 240) );
3651 FND_MSG_PUB.Add;
3652 FND_MSG_PUB.Count_And_Get (
3653 p_count => p_msg_count,
3654 p_data => p_msg_data);
3655 end CREATE_GRAPH;
3656 */
3657 
3658 --=======================================================
3659 --  Procedure   CREATE_ITEM
3660 --
3661 --  Usage       Private API for creating a region item. This
3662 --              API should only be called by other APIs that are
3663 --              owned by the Core Modules Team (AK).
3664 --
3665 --  Desc        Creates a region item using the given info.
3666 --              This API should only be called by other APIs that are
3667 --              owned by the Core Modules Team (AK).
3668 --
3669 --  Results     The API returns the standard p_return_status parameter
3670 --              indicating one of the standard return statuses :
3671 --                  * Unexpected error
3672 --                  * Error
3673 --                  * Success
3674 --  Parameters  Region Item columns
3675 --              p_loader_timestamp : IN optional
3676 --                  If a timestamp is passed, the API will create the
3677 --                  record using this timestamp. Only the upload API
3678 --                  should call with this parameter loaded.
3679 --
3680 --  Version     Initial version number  =   1.0
3681 --  History     Current version number  =   1.0
3682 --=======================================================
3683 procedure CREATE_ITEM (
3684 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
3685 p_api_version_number       IN      NUMBER,
3686 p_init_msg_tbl             IN      BOOLEAN := FALSE,
3687 p_msg_count                OUT NOCOPY     NUMBER,
3688 p_msg_data                 OUT NOCOPY     VARCHAR2,
3689 p_return_status            OUT NOCOPY     VARCHAR2,
3690 p_region_application_id    IN      NUMBER,
3691 p_region_code              IN      VARCHAR2,
3692 p_attribute_application_id IN      NUMBER,
3693 p_attribute_code           IN      VARCHAR2,
3694 p_display_sequence         IN      NUMBER,
3695 p_node_display_flag        IN      VARCHAR2,
3696 p_node_query_flag          IN      VARCHAR2,
3697 p_attribute_label_length   IN      NUMBER,
3698 p_display_value_length     IN      NUMBER,
3699 p_bold                     IN      VARCHAR2,
3700 p_italic                   IN      VARCHAR2,
3701 p_vertical_alignment       IN      VARCHAR2,
3702 p_horizontal_alignment     IN      VARCHAR2,
3703 p_item_style               IN      VARCHAR2,
3704 p_object_attribute_flag    IN      VARCHAR2,
3705 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3706 p_update_flag              IN      VARCHAR2,
3707 p_required_flag            IN      VARCHAR2,
3708 p_security_code            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3709 p_default_value_varchar2   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3710 p_default_value_number     IN      NUMBER := FND_API.G_MISS_NUM,
3711 p_default_value_date       IN      DATE := FND_API.G_MISS_DATE,
3712 p_lov_region_application_id IN     NUMBER := FND_API.G_MISS_NUM,
3713 p_lov_region_code          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3714 p_lov_foreign_key_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3715 p_lov_attribute_application_id IN  NUMBER := FND_API.G_MISS_NUM,
3716 p_lov_attribute_code       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3717 p_lov_default_flag         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3718 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
3719 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
3720 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
3721 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
3722 p_order_sequence           IN      NUMBER := FND_API.G_MISS_NUM,
3723 p_order_direction          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3724 p_display_height		IN	NUMBER := FND_API.G_MISS_NUM,
3725 p_submit			IN		 VARCHAR2,
3726 p_encrypt			IN		 VARCHAR2,
3727 p_css_class_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3728 p_view_usage_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3729 p_view_attribute_name		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3730 p_nested_region_appl_id	 IN		 NUMBER := FND_API.G_MISS_NUM,
3731 p_nested_region_code		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3732 p_url						 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3733 p_poplist_viewobject		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3734 p_poplist_display_attr   	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3735 p_poplist_value_attr		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3736 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3737 p_item_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3738 p_css_label_class_name	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
3739 p_menu_name		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
3740 p_flexfield_name	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
3741 p_flexfield_application_id IN	     NUMBER   := FND_API.G_MISS_NUM,
3742 p_tabular_function_code    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3743 p_tip_type                 IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3744 p_tip_message_name         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3745 p_tip_message_application_id   IN      NUMBER   := FND_API.G_MISS_NUM,
3746 p_flex_segment_list            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3747 p_entity_id                IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3748 p_anchor                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3749 p_poplist_view_usage_name  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3750 p_user_customizable	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3751 p_sortby_view_attribute_name   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3752 p_admin_customizable	     IN	     VARCHAR2,
3753 p_invoke_function_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3754 p_expansion		     IN      NUMBER   := FND_API.G_MISS_NUM,
3755 p_als_max_length	     IN      NUMBER   := FND_API.G_MISS_NUM,
3756 p_initial_sort_sequence    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3757 p_customization_application_id IN  NUMBER   := FND_API.G_MISS_NUM,
3758 p_customization_code	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3759 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3760 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3761 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3762 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3763 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3764 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3765 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3766 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3767 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3768 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3769 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3770 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3771 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3772 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3773 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3774 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3775 p_attribute_label_long     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3776 p_attribute_label_short    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3777 p_description			     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
3778 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
3779 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
3780 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
3781 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
3782 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
3783 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
3784 p_pass                     IN      NUMBER,
3785 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
3786 
3787 ) is
3788 l_api_version_number      CONSTANT number := 1.0;
3789 l_api_name                CONSTANT varchar2(30) := 'Create_Item';
3790 l_attribute_label_long    VARCHAR2(80);
3791 l_attribute_label_short   VARCHAR2(40);
3792 l_description				VARCHAR2(2000);
3793 l_created_by              number;
3794 l_creation_date           date;
3795 l_error                   boolean;
3796 l_icx_custom_call         VARCHAR2(80) := null;
3797 l_default_value_varchar2  VARCHAR2(240) := null;
3798 l_default_value_number    number;
3799 l_default_value_date      date;
3800 l_lang                    varchar2(30);
3801 l_last_update_date        date;
3802 l_last_update_login       number;
3803 l_last_updated_by         number;
3804 l_lov_attribute_appl_id   NUMBER;
3805 l_lov_attribute_code      VARCHAR2(30);
3806 l_lov_foreign_key_name    VARCHAR2(30);
3807 l_lov_region_appl_id      NUMBER;
3808 l_lov_region_code         VARCHAR2(30);
3809 l_lov_default_flag        VARCHAR2(1);
3810 l_order_sequence          NUMBER;
3811 l_order_direction         VARCHAR2(30);
3812 l_region_defaulting_api_pkg      VARCHAR2(30);
3813 l_region_defaulting_api_proc     VARCHAR2(30);
3814 l_region_validation_api_pkg      VARCHAR2(30);
3815 l_region_validation_api_proc     VARCHAR2(30);
3816 l_display_height			NUMBER;
3817 l_submit					VARCHAR2(1) := 'N';
3818 l_encrypt					VARCHAR2(1) := 'N';
3819 l_css_class_name				VARCHAR2(80);
3820 l_view_usage_name			VARCHAR2(80);
3821 l_view_attribute_name		VARCHAR2(80);
3822 l_nested_region_appl_id	NUMBER;
3823 l_nested_region_code		VARCHAR2(30);
3824 l_url						VARCHAR2(2000);
3825 l_poplist_viewobject		VARCHAR2(240);
3826 l_poplist_display_attr	VARCHAR2(80);
3827 l_poplist_value_attr		VARCHAR2(80);
3828 l_image_file_name			VARCHAR2(80);
3829 l_item_name				VARCHAR2(30);
3830 l_css_label_class_name	VARCHAR2(80);
3831 l_menu_name				VARCHAR2(30);
3832 l_flexfield_name			VARCHAR2(40);
3833 l_flexfield_application_id		NUMBER;
3834 l_tabular_function_code          VARCHAR2(30);
3835 l_tip_type                       VARCHAR2(30);
3836 l_tip_message_name               VARCHAR2(30);
3837 l_tip_message_application_id     NUMBER;
3838 l_flex_segment_list                    VARCHAR2(4000);
3839 l_entity_id               VARCHAR2(30);
3840 l_anchor                  VARCHAR2(1);
3841 l_poplist_view_usage_name VARCHAR2(80);
3842 l_user_customizable	    VARCHAR2(1);
3843 l_sortby_view_attribute_name VARCHAR2(80);
3844 l_admin_customizable	    VARCHAR2(1) := 'Y';
3845 l_invoke_function_name    VARCHAR2(30);
3846 l_expansion		    NUMBER;
3847 l_als_max_length	    NUMBER;
3848 l_initial_sort_sequence   VARCHAR2(30);
3849 l_customization_application_id	NUMBER;
3850 l_customization_code	    VARCHAR2(30);
3851 l_attribute_category      VARCHAR2(30);
3852 l_attribute1              VARCHAR2(150);
3853 l_attribute2              VARCHAR2(150);
3854 l_attribute3              VARCHAR2(150);
3855 l_attribute4              VARCHAR2(150);
3856 l_attribute5              VARCHAR2(150);
3857 l_attribute6              VARCHAR2(150);
3858 l_attribute7              VARCHAR2(150);
3859 l_attribute8              VARCHAR2(150);
3860 l_attribute9              VARCHAR2(150);
3861 l_attribute10             VARCHAR2(150);
3862 l_attribute11             VARCHAR2(150);
3863 l_attribute12             VARCHAR2(150);
3864 l_attribute13             VARCHAR2(150);
3865 l_attribute14             VARCHAR2(150);
3866 l_attribute15             VARCHAR2(150);
3867 l_return_status           varchar2(1);
3868 l_security_code           VARCHAR2(30);
3869 l_update_flag             VARCHAR2(1) := 'Y';
3870 begin
3871 
3872 IF NOT FND_API.Compatible_API_Call (
3873 l_api_version_number, p_api_version_number, l_api_name,
3874 G_PKG_NAME) then
3875 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3876 return;
3877 END IF;
3878 
3879 -- Initialize the message table if requested.
3880 
3881 if p_init_msg_tbl then
3882 FND_MSG_PUB.initialize;
3883 end if;
3884 
3885 savepoint start_create_item;
3886 
3887 /* TSHORT - 5665840 - new logic to avoid unique constraint error */
3888 /* now if we hit that error the exception handling calls update_item */
3889 /* --** check to see if row already exists **
3890 if AK_REGION_PVT.ITEM_EXISTS (
3891 p_api_version_number => 1.0,
3892 p_return_status => l_return_status,
3893 p_region_application_id => p_region_application_id,
3894 p_region_code => p_region_code,
3895 p_attribute_application_id => p_attribute_application_id,
3896 p_attribute_code => p_attribute_code) then
3897 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
3898 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_EXISTS');
3899 FND_MSG_PUB.Add;
3900 end if;
3901 --dbms_output.put_line(l_api_name || 'Error - row already exists');
3902 raise FND_API.G_EXC_ERROR;
3903 end if; */
3904 
3905 if (p_display_sequence IS NOT NULL) and
3906 (p_display_sequence <> FND_API.G_MISS_NUM) then
3907 --** Check the given display sequence number
3908 AK_REGION2_PVT.CHECK_DISPLAY_SEQUENCE (  p_validation_level => p_validation_level,
3909 p_region_code => p_region_code,
3910 p_region_application_id => p_region_application_id,
3911 p_attribute_code => p_attribute_code,
3912 p_attribute_application_id => p_attribute_application_id,
3913 p_display_sequence => p_display_sequence,
3914 p_return_status => l_return_status,
3915 p_msg_count => p_msg_count,
3916 p_msg_data => p_msg_data,
3917 p_pass => p_pass,
3918 p_copy_redo_flag => p_copy_redo_flag);
3919 
3920 --** Check the return status and act accordingly
3921 if (l_return_status = FND_API.G_RET_STS_ERROR) or
3922 (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
3923 raise FND_API.G_EXC_ERROR;
3924 end if;
3925 end if;
3926 
3927 --** validate table columns passed in **
3928 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
3929 if not AK_REGION_PVT.VALIDATE_ITEM (
3930 p_validation_level => p_validation_level,
3931 p_api_version_number => 1.0,
3932 p_return_status => l_return_status,
3933 p_region_application_id => p_region_application_id,
3934 p_region_code => p_region_code,
3935 p_attribute_application_id => p_attribute_application_id,
3936 p_attribute_code => p_attribute_code,
3937 p_display_sequence => p_display_sequence,
3938 p_node_display_flag => p_node_display_flag,
3939 p_node_query_flag => p_node_query_flag,
3940 p_attribute_label_length => p_attribute_label_length,
3941 p_display_value_length => p_display_value_length,
3942 p_bold => p_bold,
3943 p_italic => p_italic,
3944 p_vertical_alignment => p_vertical_alignment,
3945 p_horizontal_alignment => p_horizontal_alignment,
3946 p_item_style => p_item_style,
3947 p_object_attribute_flag => p_object_attribute_flag,
3948 p_icx_custom_call => p_icx_custom_call,
3949 p_update_flag => p_update_flag,
3950 p_required_flag => p_required_flag,
3951 p_security_code => p_security_code,
3952 p_default_value_varchar2 => p_default_value_varchar2,
3953 p_default_value_number => p_default_value_number,
3954 p_default_value_date => p_default_value_date,
3955 p_nested_region_appl_id => p_nested_region_appl_id,
3956 p_nested_region_code => p_nested_region_code,
3957 p_lov_region_application_id => p_lov_region_application_id,
3958 p_lov_region_code => p_lov_region_code,
3959 p_lov_foreign_key_name => p_lov_foreign_key_name,
3960 p_lov_attribute_application_id => p_lov_attribute_application_id,
3961 p_lov_attribute_code => p_lov_attribute_code,
3962 p_lov_default_flag => p_lov_default_flag,
3963 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
3964 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
3965 p_region_validation_api_pkg => p_region_validation_api_pkg,
3966 p_region_validation_api_proc => p_region_validation_api_proc,
3967 p_order_sequence => p_order_sequence,
3968 p_order_direction => p_order_direction,
3969 p_menu_name => p_menu_name,
3970 p_flexfield_name => p_flexfield_name,
3971 p_flexfield_application_id => p_flexfield_application_id,
3972 p_tabular_function_code    => p_tabular_function_code,
3973 p_tip_type                 => p_tip_type,
3974 p_tip_message_name         => p_tip_message_name,
3975 p_tip_message_application_id  => p_tip_message_application_id ,
3976 p_flex_segment_list        => p_flex_segment_list,
3977 p_entity_id                => p_entity_id,
3978 p_anchor                   => p_anchor,
3979 p_poplist_view_usage_name  => p_poplist_view_usage_name,
3980 p_user_customizable	       => p_user_customizable,
3981 p_sortby_view_attribute_name => p_sortby_view_attribute_name,
3982 p_invoke_function_name => p_invoke_function_name,
3983 p_expansion => p_expansion,
3984 p_als_max_length => p_als_max_length,
3985 p_initial_sort_sequence => p_initial_sort_sequence,
3986 p_customization_application_id => p_customization_application_id,
3987 p_customization_code => p_customization_code,
3988 p_attribute_label_long => p_attribute_label_long,
3989 p_attribute_label_short => p_attribute_label_short,
3990 p_caller => AK_ON_OBJECTS_PVT.G_CREATE,
3991 p_pass => p_pass
3992 ) then
3993 -- Do not raise an error if it's the first pass
3994 if (p_pass = 1) then
3995 p_copy_redo_flag := TRUE;
3996 else
3997 raise FND_API.G_EXC_ERROR;
3998 end if;
3999 end if;
4000 end if;
4001 
4002 -- Do not insert if fails validation ie. p_copy_redo_flag = true
4003 if (not p_copy_redo_flag) then
4004 
4005 --
4006 -- special logic for handling update_flag, bug#2054285
4007 -- set update_flag to 'Y'
4008 -- do not change update_flag to 'Y' if FILE_FORMAT_VERSION > 115.14
4009 --
4010 l_update_flag := p_update_flag;
4011 if ( ( AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER1 or
4012 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER2 or
4013 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER3 or
4014 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER4 or
4015 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER5 or
4016 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER6 or
4017 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER7 or
4018 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER8 or
4019 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER9 or
4020 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER11 or
4021 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER12 ) and
4022 ( p_item_style = 'CHECKBOX' or p_item_style = 'DESCRIPTIVE_FLEX' or
4023 p_item_style = 'KEY_FLEX' or p_item_style = 'FILE' or
4024 p_item_style = 'FORM_PARAMETER_BEAN' or p_item_style = 'RADIO_BUTTON' or
4025 p_item_style  = 'POPLIST' or p_item_style = 'HIDDEN' or
4026 p_item_style = 'TEXT_INPUT' or p_item_style = 'RADIO_GROUP' ) and
4027 INSTR(p_region_code,'POR') <> 1 ) then
4028 l_update_flag := 'Y';
4029 end if;
4030 
4031 -- default a value for submit and encrypt columns if no value is given
4032 if ( p_submit <> FND_API.G_MISS_CHAR and p_submit is not null ) then
4033 l_submit := p_submit;
4034 end if;
4035 if ( p_encrypt <> FND_API.G_MISS_CHAR and p_encrypt is not null ) then
4036 l_encrypt := p_encrypt;
4037 end if;
4038 if ( p_admin_customizable <> FND_API.G_MISS_CHAR and p_admin_customizable is not null ) then
4039 l_admin_customizable := p_admin_customizable;
4040 end if;
4041 
4042 --** Load non-required columns if their values are given **
4043 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) then
4044 l_icx_custom_call := p_icx_custom_call;
4045 end if;
4046 
4047 if (p_security_code <> FND_API.G_MISS_CHAR) then
4048 l_security_code := p_security_code;
4049 end if;
4050 
4051 if (p_default_value_varchar2 <> FND_API.G_MISS_CHAR) then
4052 l_default_value_varchar2 := p_default_value_varchar2;
4053 end if;
4054 
4055 if (p_default_value_number <> FND_API.G_MISS_NUM) then
4056 l_default_value_number := p_default_value_number;
4057 end if;
4058 
4059 if (p_default_value_date <> FND_API.G_MISS_DATE) then
4060 l_default_value_date := p_default_value_date;
4061 end if;
4062 
4063 if (p_lov_region_application_id <> FND_API.G_MISS_NUM) then
4064 l_lov_region_appl_id := p_lov_region_application_id;
4065 end if;
4066 
4067 if (p_lov_region_code <> FND_API.G_MISS_CHAR) then
4068 l_lov_region_code := p_lov_region_code;
4069 end if;
4070 
4071 if (p_lov_foreign_key_name <> FND_API.G_MISS_CHAR) then
4072 l_lov_foreign_key_name := p_lov_foreign_key_name;
4073 end if;
4074 
4075 if (p_lov_attribute_application_id <> FND_API.G_MISS_NUM) then
4076 l_lov_attribute_appl_id := p_lov_attribute_application_id;
4077 end if;
4078 
4079 if (p_lov_attribute_code <> FND_API.G_MISS_CHAR) then
4080 l_lov_attribute_code := p_lov_attribute_code;
4081 end if;
4082 
4083 if (p_lov_default_flag <> FND_API.G_MISS_CHAR) then
4084 l_lov_default_flag := p_lov_default_flag;
4085 end if;
4086 
4087 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
4088 l_region_defaulting_api_pkg := p_region_defaulting_api_pkg;
4089 end if;
4090 
4091 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
4092 l_region_defaulting_api_proc := p_region_defaulting_api_proc;
4093 end if;
4094 
4095 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
4096 l_region_validation_api_pkg := p_region_validation_api_pkg;
4097 end if;
4098 
4099 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
4100 l_region_validation_api_proc := p_region_validation_api_proc;
4101 end if;
4102 
4103 if (p_order_sequence <> FND_API.G_MISS_NUM) then
4104 l_order_sequence := p_order_sequence;
4105 end if;
4106 
4107 if (p_order_direction <> FND_API.G_MISS_CHAR) then
4108 l_order_direction := p_order_direction;
4109 end if;
4110 
4111 if (p_display_height <> FND_API.G_MISS_NUM) then
4112 l_display_height := p_display_height;
4113 end if;
4114 
4115 if (p_css_class_name <> FND_API.G_MISS_CHAR) then
4116 l_css_class_name := p_css_class_name;
4117 end if;
4118 
4119 if (p_view_usage_name <> FND_API.G_MISS_CHAR) then
4120 l_view_usage_name := p_view_usage_name;
4121 end if;
4122 
4123 if (p_view_attribute_name <> FND_API.G_MISS_CHAR) then
4124 l_view_attribute_name := p_view_attribute_name;
4125 end if;
4126 
4127 if (p_nested_region_appl_id <> FND_API.G_MISS_NUM) then
4128 l_nested_region_appl_id := p_nested_region_appl_id;
4129 end if;
4130 
4131 if (p_nested_region_code <> FND_API.G_MISS_CHAR) then
4132 l_nested_region_code := p_nested_region_code;
4133 end if;
4134 
4135 if (p_url <> FND_API.G_MISS_CHAR) then
4136 l_url := p_url;
4137 end if;
4138 
4139 if (p_poplist_viewobject <> FND_API.G_MISS_CHAR) then
4140 l_poplist_viewobject := p_poplist_viewobject;
4141 end if;
4142 
4143 if (p_poplist_display_attr <> FND_API.G_MISS_CHAR) then
4144 l_poplist_display_attr := p_poplist_display_attr;
4145 end if;
4146 
4147 if (p_poplist_value_attr <> FND_API.G_MISS_CHAR) then
4148 l_poplist_value_attr := p_poplist_value_attr;
4149 end if;
4150 
4151 if (p_image_file_name <> FND_API.G_MISS_CHAR) then
4152 l_image_file_name := p_image_file_name;
4153 end if;
4154 
4155 if (p_item_name <> FND_API.G_MISS_CHAR) then
4156 l_item_name := p_item_name;
4157 end if;
4158 
4159 if (p_css_label_class_name <> FND_API.G_MISS_CHAR) then
4160 l_css_label_class_name := p_css_label_class_name;
4161 end if;
4162 
4163 if (p_menu_name <> FND_API.G_MISS_CHAR) then
4164 l_menu_name := p_menu_name;
4165 end if;
4166 
4167 if (p_flexfield_name <> FND_API.G_MISS_CHAR) then
4168 l_flexfield_name := p_flexfield_name;
4169 end if;
4170 
4171 if (p_flexfield_application_id <> FND_API.G_MISS_NUM) then
4172 l_flexfield_application_id := p_flexfield_application_id;
4173 end if;
4174 
4175 if (p_tabular_function_code <> FND_API.G_MISS_CHAR) then
4176 l_tabular_function_code := p_tabular_function_code;
4177 end if;
4178 
4179 if (p_tip_type <> FND_API.G_MISS_CHAR) then
4180 l_tip_type := p_tip_type;
4181 end if;
4182 
4183 if (p_tip_message_name <> FND_API.G_MISS_CHAR) then
4184 l_tip_message_name := p_tip_message_name;
4185 end if;
4186 
4187 if (p_tip_message_application_id <> FND_API.G_MISS_NUM) then
4188 l_tip_message_application_id := p_tip_message_application_id;
4189 end if;
4190 
4191 if (p_flex_segment_list <> FND_API.G_MISS_CHAR) then
4192 l_flex_segment_list := p_flex_segment_list;
4193 end if;
4194 
4195 if (p_entity_id <> FND_API.G_MISS_CHAR) then
4196 l_entity_id := p_entity_id;
4197 end if;
4198 
4199 if (p_anchor <> FND_API.G_MISS_CHAR) then
4200 l_anchor := p_anchor;
4201 end if;
4202 
4203 if (p_poplist_view_usage_name <> FND_API.G_MISS_CHAR) then
4204 l_poplist_view_usage_name:= p_poplist_view_usage_name;
4205 end if;
4206 
4207 if (p_user_customizable <> FND_API.G_MISS_CHAR) then
4208 l_user_customizable:= p_user_customizable;
4209 end if;
4210 
4211 if (p_sortby_view_attribute_name <> FND_API.G_MISS_CHAR) then
4212 l_sortby_view_attribute_name:= p_sortby_view_attribute_name;
4213 end if;
4214 
4215 if (p_invoke_function_name <> FND_API.G_MISS_CHAR) then
4216 l_invoke_function_name:= p_invoke_function_name;
4217 end if;
4218 
4219 if (p_expansion <> FND_API.G_MISS_NUM) then
4220 l_expansion := p_expansion;
4221 end if;
4222 
4223 if (p_als_max_length <> FND_API.G_MISS_NUM) then
4224 l_als_max_length := p_als_max_length;
4225 end if;
4226 
4227 if (p_initial_sort_sequence<> FND_API.G_MISS_CHAR) then
4228 l_initial_sort_sequence := p_initial_sort_sequence;
4229 end if;
4230 
4231 if (p_customization_application_id <> FND_API.G_MISS_NUM) then
4232 l_customization_application_id := p_customization_application_id;
4233 end if;
4234 
4235 if (p_customization_code <> FND_API.G_MISS_CHAR) then
4236 l_customization_code := p_customization_code;
4237 end if;
4238 
4239 if (p_attribute_category <> FND_API.G_MISS_CHAR) then
4240 l_attribute_category := p_attribute_category;
4241 end if;
4242 
4243 if (p_attribute1 <> FND_API.G_MISS_CHAR) then
4244 l_attribute1 := p_attribute1;
4245 end if;
4246 
4247 if (p_attribute2 <> FND_API.G_MISS_CHAR) then
4248 l_attribute2 := p_attribute2;
4249 end if;
4250 
4251 if (p_attribute3 <> FND_API.G_MISS_CHAR) then
4252 l_attribute3 := p_attribute3;
4253 end if;
4254 
4255 if (p_attribute4 <> FND_API.G_MISS_CHAR) then
4256 l_attribute4 := p_attribute4;
4257 end if;
4258 
4259 if (p_attribute5 <> FND_API.G_MISS_CHAR) then
4260 l_attribute5 := p_attribute5;
4261 end if;
4262 
4263 if (p_attribute6 <> FND_API.G_MISS_CHAR) then
4264 l_attribute6 := p_attribute6;
4265 end if;
4266 
4267 if (p_attribute7 <> FND_API.G_MISS_CHAR) then
4268 l_attribute7:= p_attribute7;
4269 end if;
4270 
4271 if (p_attribute8 <> FND_API.G_MISS_CHAR) then
4272 l_attribute8 := p_attribute8;
4273 end if;
4274 
4275 if (p_attribute9 <> FND_API.G_MISS_CHAR) then
4276 l_attribute9 := p_attribute9;
4277 end if;
4278 
4279 if (p_attribute10 <> FND_API.G_MISS_CHAR) then
4280 l_attribute10 := p_attribute10;
4281 end if;
4282 
4283 if (p_attribute11 <> FND_API.G_MISS_CHAR) then
4284 l_attribute11 := p_attribute11;
4285 end if;
4286 
4287 if (p_attribute12 <> FND_API.G_MISS_CHAR) then
4288 l_attribute12 := p_attribute12;
4289 end if;
4290 
4291 if (p_attribute13 <> FND_API.G_MISS_CHAR) then
4292 l_attribute13 := p_attribute13;
4293 end if;
4294 
4295 if (p_attribute14 <> FND_API.G_MISS_CHAR) then
4296 l_attribute14 := p_attribute14;
4297 end if;
4298 
4299 if (p_attribute15 <> FND_API.G_MISS_CHAR) then
4300 l_attribute15 := p_attribute15;
4301 end if;
4302 
4303 if (p_attribute_label_long <> FND_API.G_MISS_CHAR) then
4304 l_attribute_label_long := p_attribute_label_long;
4305 end if;
4306 
4307 if (p_attribute_label_short <> FND_API.G_MISS_CHAR) then
4308 l_attribute_label_short := p_attribute_label_short;
4309 end if;
4310 
4311 if (p_description <> FND_API.G_MISS_CHAR) then
4312 l_description := p_description;
4313 end if;
4314 
4315   if (p_created_by <> FND_API.G_MISS_NUM) then
4316     l_created_by := p_created_by;
4317   end if;
4318 
4319   if (p_creation_date <> FND_API.G_MISS_DATE) then
4320     l_creation_date := p_creation_date;
4321   end if;
4322 
4323   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
4324     l_last_updated_by := p_last_updated_by;
4325   end if;
4326 
4327   if (p_last_update_date <> FND_API.G_MISS_DATE) then
4328     l_last_update_date := p_last_update_date;
4329   end if;
4330 
4331   if (p_last_update_login <> FND_API.G_MISS_NUM) then
4332     l_last_update_login := p_last_update_login;
4333   end if;
4334 
4335 -- Create record if no validation error was found
4336   --  NOTE - Calling IS_UPDATEABLE for backward compatibility
4337   --  old jlt files didn't have who columns and IS_UPDATEABLE
4338   --  calls SET_WHO which populates those columns, for later
4339   --  jlt files IS_UPDATEABLE will always return TRUE for CREATE
4340 
4341 if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
4342        p_loader_timestamp => p_loader_timestamp,
4343        p_created_by => l_created_by,
4344        p_creation_date => l_creation_date,
4345        p_last_updated_by => l_last_updated_by,
4346        p_db_last_updated_by => null,
4347        p_last_update_date => l_last_update_date,
4348        p_db_last_update_date => null,
4349        p_last_update_login => l_last_update_login,
4350        p_create_or_update => 'CREATE') then
4351      null;
4352   end if;
4353 
4354 select userenv('LANG') into l_lang
4355 from dual;
4356 
4357 insert into AK_REGION_ITEMS (
4358 REGION_APPLICATION_ID,
4359 REGION_CODE,
4360 ATTRIBUTE_APPLICATION_ID,
4361 ATTRIBUTE_CODE,
4362 DISPLAY_SEQUENCE,
4363 NODE_DISPLAY_FLAG,
4364 NODE_QUERY_FLAG,
4365 ATTRIBUTE_LABEL_LENGTH,
4366 DISPLAY_VALUE_LENGTH,
4367 BOLD,
4368 ITALIC,
4369 VERTICAL_ALIGNMENT,
4370 HORIZONTAL_ALIGNMENT,
4371 ITEM_STYLE,
4372 OBJECT_ATTRIBUTE_FLAG,
4373 ICX_CUSTOM_CALL,
4374 UPDATE_FLAG,
4375 REQUIRED_FLAG,
4376 SECURITY_CODE,
4377 DEFAULT_VALUE_VARCHAR2,
4378 DEFAULT_VALUE_NUMBER,
4379 DEFAULT_VALUE_DATE,
4380 LOV_REGION_APPLICATION_ID,
4381 LOV_REGION_CODE,
4382 LOV_FOREIGN_KEY_NAME,
4383 LOV_ATTRIBUTE_APPLICATION_ID,
4384 LOV_ATTRIBUTE_CODE,
4385 LOV_DEFAULT_FLAG,
4386 REGION_DEFAULTING_API_PKG,
4387 REGION_DEFAULTING_API_PROC,
4388 REGION_VALIDATION_API_PKG,
4389 REGION_VALIDATION_API_PROC,
4390 ORDER_SEQUENCE,
4391 ORDER_DIRECTION,
4392 DISPLAY_HEIGHT,
4393 SUBMIT,
4394 ENCRYPT,
4395 CSS_CLASS_NAME,
4396 VIEW_USAGE_NAME,
4397 VIEW_ATTRIBUTE_NAME,
4398 NESTED_REGION_APPLICATION_ID,
4399 NESTED_REGION_CODE,
4400 URL,
4401 POPLIST_VIEWOBJECT,
4402 POPLIST_DISPLAY_ATTRIBUTE,
4403 POPLIST_VALUE_ATTRIBUTE,
4404 IMAGE_FILE_NAME,
4405 ITEM_NAME,
4406 CSS_LABEL_CLASS_NAME,
4407 MENU_NAME,
4408 FLEXFIELD_NAME,
4409 FLEXFIELD_APPLICATION_ID,
4410 TABULAR_FUNCTION_CODE,
4411 TIP_TYPE,
4412 TIP_MESSAGE_NAME,
4413 TIP_MESSAGE_APPLICATION_ID,
4414 FLEX_SEGMENT_LIST,
4415 ENTITY_ID,
4416 ANCHOR,
4417 POPLIST_VIEW_USAGE_NAME,
4418 USER_CUSTOMIZABLE,
4419 SORTBY_VIEW_ATTRIBUTE_NAME,
4420 ADMIN_CUSTOMIZABLE,
4421 INVOKE_FUNCTION_NAME,
4422 EXPANSION,
4423 ALS_MAX_LENGTH,
4424 INITIAL_SORT_SEQUENCE,
4425 CUSTOMIZATION_APPLICATION_ID,
4426 CUSTOMIZATION_CODE,
4427 ATTRIBUTE_CATEGORY,
4428 ATTRIBUTE1,
4429 ATTRIBUTE2,
4430 ATTRIBUTE3,
4431 ATTRIBUTE4,
4432 ATTRIBUTE5,
4433 ATTRIBUTE6,
4434 ATTRIBUTE7,
4435 ATTRIBUTE8,
4436 ATTRIBUTE9,
4437 ATTRIBUTE10,
4438 ATTRIBUTE11,
4439 ATTRIBUTE12,
4440 ATTRIBUTE13,
4441 ATTRIBUTE14,
4442 ATTRIBUTE15,
4443 CREATION_DATE,
4444 CREATED_BY,
4445 LAST_UPDATE_DATE,
4446 LAST_UPDATED_BY,
4447 LAST_UPDATE_LOGIN
4448 ) values (
4449 p_region_application_id,
4450 p_region_code,
4451 p_attribute_application_id,
4452 p_attribute_code,
4453 p_display_sequence,
4454 p_node_display_flag,
4455 p_node_query_flag,
4456 p_attribute_label_length,
4457 p_display_value_length,
4458 p_bold,
4459 p_italic,
4460 p_vertical_alignment,
4461 p_horizontal_alignment,
4462 p_item_style,
4463 p_object_attribute_flag,
4464 l_icx_custom_call,
4465 l_update_flag,
4466 p_required_flag,
4467 l_security_code,
4468 l_default_value_varchar2,
4469 l_default_value_number,
4470 l_default_value_date,
4471 l_lov_region_appl_id,
4472 l_lov_region_code,
4473 l_lov_foreign_key_name,
4474 l_lov_attribute_appl_id,
4475 l_lov_attribute_code,
4476 l_lov_default_flag,
4477 l_region_defaulting_api_pkg,
4478 l_region_defaulting_api_proc,
4479 l_region_validation_api_pkg,
4480 l_region_validation_api_proc,
4481 l_order_sequence,
4482 l_order_direction,
4483 l_display_height,
4484 l_submit,
4485 l_encrypt,
4486 l_css_class_name,
4487 l_view_usage_name,
4488 l_view_attribute_name,
4489 l_nested_region_appl_id,
4490 l_nested_region_code,
4491 l_url,
4492 l_poplist_viewobject,
4493 l_poplist_display_attr,
4494 l_poplist_value_attr,
4495 l_image_file_name,
4496 l_item_name,
4497 l_css_label_class_name,
4498 l_menu_name,
4499 l_flexfield_name,
4500 l_flexfield_application_id,
4501 l_tabular_function_code,
4502 l_tip_type,
4503 l_tip_message_name,
4504 l_tip_message_application_id,
4505 l_flex_segment_list,
4506 l_entity_id,
4507 l_anchor,
4508 l_poplist_view_usage_name,
4509 l_user_customizable,
4510 l_sortby_view_attribute_name,
4511 l_admin_customizable,
4512 l_invoke_function_name,
4513 l_expansion,
4514 l_als_max_length,
4515 l_initial_sort_sequence,
4516 l_customization_application_id,
4517 l_customization_code,
4518 l_attribute_category,
4519 l_attribute1,
4520 l_attribute2,
4521 l_attribute3,
4522 l_attribute4,
4523 l_attribute5,
4524 l_attribute6,
4525 l_attribute7,
4526 l_attribute8,
4527 l_attribute9,
4528 l_attribute10,
4529 l_attribute11,
4530 l_attribute12,
4531 l_attribute13,
4532 l_attribute14,
4533 l_attribute15,
4534 l_creation_date,
4535 l_created_by,
4536 l_last_update_date,
4537 l_last_updated_by,
4538 l_last_update_login
4539 );
4540 
4541 --** row should exists before inserting rows for other languages **
4542 if NOT AK_REGION_PVT.ITEM_EXISTS (
4543 p_api_version_number => 1.0,
4544 p_return_status => l_return_status,
4545 p_region_application_id => p_region_application_id,
4546 p_region_code => p_region_code,
4547 p_attribute_application_id => p_attribute_application_id,
4548 p_attribute_code => p_attribute_code) then
4549 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
4550 FND_MESSAGE.SET_NAME('AK','AK_INSERT_REG_ITEM_FAILED');
4551 FND_MSG_PUB.Add;
4552 end if;
4553 --dbms_output.put_line(l_api_name || 'Error - row already exists');
4554 raise FND_API.G_EXC_ERROR;
4555 end if;
4556 
4557 insert into AK_REGION_ITEMS_TL (
4558 REGION_APPLICATION_ID,
4559 REGION_CODE,
4560 ATTRIBUTE_APPLICATION_ID,
4561 ATTRIBUTE_CODE,
4562 LANGUAGE,
4563 ATTRIBUTE_LABEL_LONG,
4564 ATTRIBUTE_LABEL_SHORT,
4565 DESCRIPTION,
4566 SOURCE_LANG,
4567 CREATED_BY,
4568 CREATION_DATE,
4569 LAST_UPDATED_BY,
4570 LAST_UPDATE_DATE,
4571 LAST_UPDATE_LOGIN
4572 ) select
4573 p_region_application_id,
4574 p_region_code,
4575 p_attribute_application_id,
4576 p_attribute_code,
4577 L.LANGUAGE_CODE,
4578 l_attribute_label_long,
4579 l_attribute_label_short,
4580 l_description,
4581 decode(L.LANGUAGE_CODE, l_lang, L.LANGUAGE_CODE, l_lang),
4582 l_created_by,
4583 l_creation_date,
4584 l_last_updated_by,
4585 l_last_update_date,
4586 l_last_update_login
4587 from FND_LANGUAGES L
4588 where L.INSTALLED_FLAG in ('I', 'B')
4589 and not exists
4590 (select NULL
4591 from AK_REGION_ITEMS_TL T
4592 where T.REGION_APPLICATION_ID = p_region_application_id
4593 and T.REGION_CODE = p_region_code
4594 and T.ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
4595 and T.ATTRIBUTE_CODE = p_attribute_code
4596 and T.LANGUAGE = L.LANGUAGE_CODE);
4597 
4598 --  /** commit the insert **/
4599  commit;
4600 
4601 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
4602 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_CREATED');
4603 FND_MESSAGE.SET_TOKEN('OBJECT', 'AK_LC_REGION_ITEM',TRUE);
4604 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4605 ' ' || p_region_code ||
4606 ' ' || to_char(p_attribute_application_id) ||
4607 ' ' || p_attribute_code);
4608 FND_MSG_PUB.Add;
4609 end if;
4610 
4611 end if; -- /* if not p_copy_redo_flag */
4612 
4613 p_return_status := FND_API.G_RET_STS_SUCCESS;
4614 
4615 FND_MSG_PUB.Count_And_Get (
4616 p_count => p_msg_count,
4617 p_data => p_msg_data);
4618 
4619 
4620 EXCEPTION
4621 WHEN VALUE_ERROR THEN
4622 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
4623 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_VALUE_ERROR');
4624 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4625 ' ' || p_region_code ||
4626 ' ' || to_char(p_attribute_application_id) ||
4627 ' ' || p_attribute_code);
4628 FND_MSG_PUB.Add;
4629 end if;
4630 p_return_status := FND_API.G_RET_STS_ERROR;
4631 rollback to start_create_item;
4632 FND_MSG_PUB.Count_And_Get (
4633 p_count => p_msg_count,
4634 p_data => p_msg_data);
4635 WHEN FND_API.G_EXC_ERROR THEN
4636 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
4637 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_CREATED');
4638 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4639 ' ' || p_region_code ||
4640 ' ' || to_char(p_attribute_application_id) ||
4641 ' ' || p_attribute_code);
4642 FND_MSG_PUB.Add;
4643 end if;
4644 p_return_status := FND_API.G_RET_STS_ERROR;
4645 rollback to start_create_item;
4646 FND_MSG_PUB.Count_And_Get (
4647 p_count => p_msg_count,
4648 p_data => p_msg_data);
4649 WHEN OTHERS THEN
4650     if (SQLCODE = -1) then
4651         rollback to start_create_item;
4652         AK_REGION_PVT.UPDATE_ITEM (
4653           p_validation_level => p_validation_level,
4654           p_api_version_number => 1.0,
4655           p_msg_count => p_msg_count,
4656           p_msg_data => p_msg_data,
4657           p_return_status => p_return_status,
4658           p_region_application_id => p_region_application_id,
4659           p_region_code => p_region_code,
4660           p_attribute_application_id => p_attribute_application_id,
4661           p_attribute_code => p_attribute_code,
4662           p_display_sequence => p_display_sequence,
4663           p_node_display_flag => p_node_display_flag,
4664           p_node_query_flag => p_node_query_flag,
4665           p_attribute_label_length => p_attribute_label_length,
4666           p_display_value_length => p_display_value_length,
4667           p_bold => p_bold,
4668           p_italic => p_italic,
4669           p_vertical_alignment => p_vertical_alignment,
4670           p_horizontal_alignment => p_horizontal_alignment,
4671           p_item_style => p_item_style,
4672           p_object_attribute_flag => p_object_attribute_flag,
4673           p_icx_custom_call => p_icx_custom_call,
4674           p_update_flag => p_update_flag,
4675           p_required_flag => p_required_flag,
4676           p_security_code => p_security_code,
4677           p_default_value_varchar2 => p_default_value_varchar2,
4678           p_default_value_number => p_default_value_number,
4679           p_default_value_date => p_default_value_date,
4680           p_lov_region_application_id => p_lov_region_application_id,
4681           p_lov_region_code => p_lov_region_code,
4682           p_lov_foreign_key_name => p_lov_foreign_key_name,
4683           p_lov_attribute_application_id => p_lov_attribute_application_id,
4684           p_lov_attribute_code => p_lov_attribute_code,
4685           p_lov_default_flag => p_lov_default_flag,
4686           p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
4687           p_region_defaulting_api_proc => p_region_defaulting_api_proc,
4688           p_region_validation_api_pkg => p_region_validation_api_pkg,
4689           p_region_validation_api_proc => p_region_validation_api_proc,
4690           p_order_sequence => p_order_sequence,
4691           p_order_direction => p_order_direction,
4692           p_display_height => p_display_height,
4693           p_submit => p_submit,
4694           p_encrypt => p_encrypt,
4695           p_css_class_name => p_css_class_name,
4696           p_view_usage_name => p_view_usage_name,
4697           p_view_attribute_name => p_view_attribute_name,
4698           p_nested_region_appl_id => p_nested_region_appl_id,
4699           p_nested_region_code => p_nested_region_code,
4700           p_url => p_url,
4701           p_poplist_viewobject => p_poplist_viewobject,
4702           p_poplist_display_attr => p_poplist_display_attr,
4703           p_poplist_value_attr => p_poplist_value_attr,
4704           p_image_file_name => p_image_file_name,
4705           p_item_name => p_item_name,
4706           p_css_label_class_name => p_css_label_class_name,
4707           p_menu_name => p_menu_name,
4708           p_flexfield_name => p_flexfield_name,
4709           p_flexfield_application_id => p_flexfield_application_id,
4710           p_tabular_function_code    => p_tabular_function_code,
4711           p_tip_type                 => p_tip_type,
4712           p_tip_message_name         => p_tip_message_name,
4713           p_tip_message_application_id  => p_tip_message_application_id ,
4714           p_flex_segment_list        => p_flex_segment_list,
4715           p_entity_id  => p_entity_id,
4716           p_anchor     => p_anchor,
4717           p_poplist_view_usage_name => p_poplist_view_usage_name,
4718           p_user_customizable => p_user_customizable,
4719           p_sortby_view_attribute_name => p_sortby_view_attribute_name,
4720           p_admin_customizable => p_admin_customizable,
4721           p_invoke_function_name => p_invoke_function_name,
4722           p_expansion => p_expansion,
4723           p_als_max_length => p_als_max_length,
4724           p_initial_sort_sequence => p_initial_sort_sequence,
4725           p_customization_application_id => p_customization_application_id,
4726           p_customization_code => p_customization_code,
4727           p_attribute_category => p_attribute_category,
4728           p_attribute1 => p_attribute1,
4729           p_attribute2 => p_attribute2,
4730           p_attribute3 => p_attribute3,
4731           p_attribute4 => p_attribute4,
4732           p_attribute5 => p_attribute5,
4733           p_attribute6 => p_attribute6,
4734           p_attribute7 => p_attribute7,
4735           p_attribute8 => p_attribute8,
4736           p_attribute9 => p_attribute9,
4737           p_attribute10 => p_attribute10,
4738           p_attribute11 => p_attribute11,
4739           p_attribute12 => p_attribute12,
4740           p_attribute13 => p_attribute13,
4741           p_attribute14 => p_attribute14,
4742           p_attribute15 => p_attribute15,
4743           p_attribute_label_long => p_attribute_label_long,
4744           p_attribute_label_short => p_attribute_label_short,
4745           p_description => p_description,
4746           p_created_by => p_created_by,
4747           p_creation_date => p_creation_date,
4748           p_last_updated_by => p_last_updated_by,
4749           p_last_update_date => p_last_update_date,
4750           p_last_update_login => p_last_update_login,
4751           p_loader_timestamp => p_loader_timestamp,
4752           p_pass => p_pass,
4753           p_copy_redo_flag => p_copy_redo_flag
4754           );
4755        else
4756 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4757 rollback to start_create_item;
4758 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
4759 SUBSTR (SQLERRM, 1, 240) );
4760 FND_MSG_PUB.Add;
4761 FND_MSG_PUB.Count_And_Get (
4762 p_count => p_msg_count,
4763 p_data => p_msg_data);
4764 end if;
4765 end CREATE_ITEM;
4766 
4767 --=======================================================
4768 --  Procedure   CREATE_REGION
4769 --
4770 --  Usage       Private API for creating a region. This
4771 --              API should only be called by other APIs that are
4772 --              owned by the Core Modules Team (AK).
4773 --
4774 --  Desc        Creates a region using the given info.
4775 --              This API should only be called by other APIs that are
4776 --              owned by the Core Modules Team (AK).
4777 --
4778 --  Results     The API returns the standard p_return_status parameter
4779 --              indicating one of the standard return statuses :
4780 --                  * Unexpected error
4781 --                  * Error
4782 --                  * Success
4783 --  Parameters  Region columns
4784 --              p_loader_timestamp : IN optional
4785 --                  If a timestamp is passed, the API will create the
4786 --                  record using this timestamp. Only the upload API
4787 --                  should call with this parameter loaded.
4788 --
4789 --  Version     Initial version number  =   1.0
4790 --  History     Current version number  =   1.0
4791 --=======================================================
4792 procedure CREATE_REGION (
4793 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
4794 p_api_version_number       IN      NUMBER,
4795 p_init_msg_tbl             IN      BOOLEAN := FALSE,
4796 p_msg_count                OUT NOCOPY     NUMBER,
4797 p_msg_data                 OUT NOCOPY     VARCHAR2,
4798 p_return_status            OUT NOCOPY     VARCHAR2,
4799 p_region_application_id    IN      NUMBER,
4800 p_region_code              IN      VARCHAR2,
4801 p_database_object_name     IN      VARCHAR2,
4802 p_region_style             IN      VARCHAR2,
4803 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4804 p_num_columns              IN      NUMBER := FND_API.G_MISS_NUM,
4805 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
4806 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
4807 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
4808 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
4809 p_appmodule_object_type	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4810 p_num_rows_display		 IN		 NUMBER := FND_API.G_MISS_NUM,
4811 p_region_object_type		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4812 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4813 p_isform_flag				 IN		 VARCHAR2,
4814 p_help_target 			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4815 p_style_sheet_filename	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4816 p_version                  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4817 p_applicationmodule_usage_name IN  VARCHAR2 := FND_API.G_MISS_CHAR,
4818 p_add_indexed_children     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4819 p_stateful_flag	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
4820 p_function_name            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4821 p_children_view_usage_name IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4822 p_search_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4823 p_advanced_search_panel    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4824 p_customize_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4825 p_default_search_panel     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4826 p_results_based_search     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4827 p_display_graph_table      IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4828 p_disable_header	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4829 p_standalone		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4830 p_auto_customization_criteria IN   VARCHAR2 := FND_API.G_MISS_CHAR,
4831 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4832 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4833 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4834 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4835 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4836 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4837 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4838 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4839 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4840 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4841 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4842 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4843 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4844 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4845 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4846 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4847 p_name                     IN      VARCHAR2,
4848 p_description              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4849 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
4850 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
4851 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
4852 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
4853 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
4854 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
4855 p_pass                     IN      NUMBER,
4856 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
4857 ) is
4858 l_attribute_category VARCHAR2(30);
4859 l_attribute1         VARCHAR2(150);
4860 l_attribute2         VARCHAR2(150);
4861 l_attribute3         VARCHAR2(150);
4862 l_attribute4         VARCHAR2(150);
4863 l_attribute5         VARCHAR2(150);
4864 l_attribute6         VARCHAR2(150);
4865 l_attribute7         VARCHAR2(150);
4866 l_attribute8         VARCHAR2(150);
4867 l_attribute9         VARCHAR2(150);
4868 l_attribute10        VARCHAR2(150);
4869 l_attribute11        VARCHAR2(150);
4870 l_attribute12        VARCHAR2(150);
4871 l_attribute13        VARCHAR2(150);
4872 l_attribute14        VARCHAR2(150);
4873 l_attribute15        VARCHAR2(150);
4874 l_api_version_number CONSTANT number := 1.0;
4875 l_api_name           CONSTANT varchar2(30) := 'Create_Region';
4876 l_created_by         number;
4877 l_creation_date      date;
4878 l_description        VARCHAR2(2000) := null;
4879 l_icx_custom_call    VARCHAR2(80) := null;
4880 l_lang               varchar2(30);
4881 l_last_update_date   date;
4882 l_last_update_login  number;
4883 l_last_updated_by    number;
4884 l_num_columns        NUMBER := null;
4885 l_region_defaulting_api_pkg      VARCHAR2(30);
4886 l_region_defaulting_api_proc     VARCHAR2(30);
4887 l_region_validation_api_pkg      VARCHAR2(30);
4888 l_region_validation_api_proc     VARCHAR2(30);
4889 l_appmodule_object_type			VARCHAR2(240);
4890 l_num_rows_display				NUMBER;
4891 l_region_object_type				VARCHAR2(240);
4892 l_image_file_name					VARCHAR2(80);
4893 l_isform_flag						VARCHAR2(1) := 'N';
4894 l_help_target						VARCHAR2(240);
4895 l_style_sheet_filename			VARCHAR2(240);
4896 l_version							VARCHAR2(30);
4897 l_appmodule_usage_name	        VARCHAR2(80);
4898 l_add_indexed_children	        VARCHAR2(1);
4899 l_stateful_flag			VARCHAR2(1);
4900 l_function_name			VARCHAR2(30);
4901 l_children_view_usage_name		VARCHAR2(80);
4902 l_search_panel			VARCHAR2(1);
4903 l_advanced_search_panel		VARCHAR2(1);
4904 l_customize_panel			VARCHAR2(1);
4905 l_default_search_panel		VARCHAR2(30);
4906 l_results_based_search		VARCHAR2(1);
4907 l_display_graph_table			VARCHAR2(1);
4908 l_disable_header			VARCHAR2(1);
4909 l_standalone				VARCHAR2(1);
4910 l_auto_customization_criteria		VARCHAR2(1);
4911 l_return_status      varchar2(1);
4912 begin
4913 
4914 IF NOT FND_API.Compatible_API_Call (
4915 l_api_version_number, p_api_version_number, l_api_name,
4916 G_PKG_NAME) then
4917 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4918 return;
4919 END IF;
4920 
4921 -- Initialize the message table if requested.
4922 
4923 if p_init_msg_tbl then
4924 FND_MSG_PUB.initialize;
4925 end if;
4926 
4927 savepoint start_create_region;
4928 
4929 --** check to see if row already exists **
4930 if AK_REGION_PVT.REGION_EXISTS (
4931 p_api_version_number => 1.0,
4932 p_return_status => l_return_status,
4933 p_region_application_id => p_region_application_id,
4934 p_region_code => p_region_code) then
4935 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
4936 FND_MESSAGE.SET_NAME('AK','AK_REGION_EXISTS');
4937 FND_MSG_PUB.Add;
4938 end if;
4939 -- dbms_output.put_line(G_PKG_NAME || 'Error - Row already exists');
4940 raise FND_API.G_EXC_ERROR;
4941 end if;
4942 
4943 --** validate table columns passed in **
4944 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
4945 if not AK_REGION_PVT.VALIDATE_REGION (
4946 p_validation_level => p_validation_level,
4947 p_api_version_number => 1.0,
4948 p_return_status => l_return_status,
4949 p_region_application_id => p_region_application_id,
4950 p_region_code => p_region_code,
4951 p_database_object_name => p_database_object_name,
4952 p_region_style => p_region_style,
4953 p_icx_custom_call => p_icx_custom_call,
4954 p_num_columns => p_num_columns,
4955 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
4956 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
4957 p_region_validation_api_pkg => p_region_validation_api_pkg,
4958 p_region_validation_api_proc => p_region_validation_api_proc,
4959 p_name => p_name,
4960 p_description => p_description,
4961 p_caller => AK_ON_OBJECTS_PVT.G_CREATE,
4962 p_pass => p_pass
4963 ) then
4964 -- Do not raise an error if it's the first pass
4965 if (p_pass = 1) then
4966 p_copy_redo_flag := TRUE;
4967 else
4968 raise FND_API.G_EXC_ERROR;
4969 end if;
4970 end if;
4971 end if;
4972 
4973   -- Do not insert if fails validation ie. p_copy_redo_flag = true
4974   if (not p_copy_redo_flag) then
4975 
4976 --** Load non-required columns if their values are given **
4977 if (p_description <> FND_API.G_MISS_CHAR) then
4978 l_description := p_description;
4979 end if;
4980 
4981 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) then
4982 l_icx_custom_call := p_icx_custom_call;
4983 end if;
4984 
4985 if (p_num_columns <> FND_API.G_MISS_NUM) then
4986 l_num_columns := p_num_columns;
4987 end if;
4988 
4989 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
4990 l_region_defaulting_api_pkg := p_region_defaulting_api_pkg;
4991 end if;
4992 
4993 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
4994 l_region_defaulting_api_proc := p_region_defaulting_api_proc;
4995 end if;
4996 
4997 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
4998 l_region_validation_api_pkg := p_region_validation_api_pkg;
4999 end if;
5000 
5001 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
5002 l_region_validation_api_proc := p_region_validation_api_proc;
5003 end if;
5004 
5005 if (p_appmodule_object_type <> FND_API.G_MISS_CHAR) then
5006 l_appmodule_object_type := p_appmodule_object_type;
5007 end if;
5008 
5009 if (p_num_rows_display <> FND_API.G_MISS_NUM) then
5010 l_num_rows_display := p_num_rows_display;
5011 end if;
5012 
5013 if (p_region_object_type <> FND_API.G_MISS_CHAR) then
5014 l_region_object_type := p_region_object_type;
5015 end if;
5016 
5017 if (p_image_file_name <> FND_API.G_MISS_CHAR) then
5018 l_image_file_name := p_image_file_name;
5019 end if;
5020 
5021 if (p_isform_flag <> FND_API.G_MISS_CHAR) then
5022 l_isform_flag := p_isform_flag;
5023 end if;
5024 
5025 if (p_help_target <> FND_API.G_MISS_CHAR) then
5026 l_help_target := p_help_target;
5027 end if;
5028 
5029 if (p_style_sheet_filename <> FND_API.G_MISS_CHAR) then
5030 l_style_sheet_filename := p_style_sheet_filename;
5031 end if;
5032 
5033 if (p_version <> FND_API.G_MISS_CHAR) then
5034 l_version := p_version;
5035 end if;
5036 
5037 if (p_applicationmodule_usage_name <> FND_API.G_MISS_CHAR) then
5038 l_appmodule_usage_name := p_applicationmodule_usage_name;
5039 end if;
5040 
5041 if (p_add_indexed_children <> FND_API.G_MISS_CHAR) then
5042 l_add_indexed_children := p_add_indexed_children;
5043 end if;
5044 
5045 if (p_stateful_flag <> FND_API.G_MISS_CHAR) then
5046 l_stateful_flag := p_stateful_flag;
5047 end if;
5048 
5049 if (p_function_name <> FND_API.G_MISS_CHAR) then
5050 l_function_name := p_function_name;
5051 end if;
5052 
5053 if (p_children_view_usage_name <> FND_API.G_MISS_CHAR) then
5054 l_children_view_usage_name := p_children_view_usage_name;
5055 end if;
5056 
5057 if (p_search_panel <> FND_API.G_MISS_CHAR) then
5058 l_search_panel := p_search_panel;
5059 end if;
5060 
5061 if (p_advanced_search_panel <> FND_API.G_MISS_CHAR) then
5062 l_advanced_search_panel := p_advanced_search_panel;
5063 end if;
5064 
5065 if (p_customize_panel <> FND_API.G_MISS_CHAR) then
5066 l_customize_panel := p_customize_panel;
5067 end if;
5068 
5069 if (p_default_search_panel <> FND_API.G_MISS_CHAR) then
5070 l_default_search_panel := p_default_search_panel;
5071 end if;
5072 
5073 if (p_results_based_search <> FND_API.G_MISS_CHAR) then
5074 l_results_based_search := p_results_based_search;
5075 end if;
5076 
5077 if (p_display_graph_table <> FND_API.G_MISS_CHAR) then
5078 l_display_graph_table := p_display_graph_table;
5079 end if;
5080 
5081 if (p_disable_header <> FND_API.G_MISS_CHAR) then
5082 l_disable_header := p_disable_header;
5083 end if;
5084 
5085 -- standalone is now a non-null column and it should have default value sets to 'Y'
5086 if (p_standalone <> FND_API.G_MISS_CHAR and p_standalone is not null) then
5087 l_standalone := p_standalone;
5088 else
5089 l_standalone := 'Y';
5090 end if;
5091 
5092 if (p_auto_customization_criteria <> FND_API.G_MISS_CHAR) then
5093 l_auto_customization_criteria := p_auto_customization_criteria;
5094 end if;
5095 
5096 if (p_attribute_category <> FND_API.G_MISS_CHAR) then
5097 l_attribute_category := p_attribute_category;
5098 end if;
5099 
5100 if (p_attribute1 <> FND_API.G_MISS_CHAR) then
5101 l_attribute1 := p_attribute1;
5102 end if;
5103 
5104 if (p_attribute2 <> FND_API.G_MISS_CHAR) then
5105 l_attribute2 := p_attribute2;
5106 end if;
5107 
5108 if (p_attribute3 <> FND_API.G_MISS_CHAR) then
5109 l_attribute3 := p_attribute3;
5110 end if;
5111 
5112 if (p_attribute4 <> FND_API.G_MISS_CHAR) then
5113 l_attribute4 := p_attribute4;
5114 end if;
5115 
5116 if (p_attribute5 <> FND_API.G_MISS_CHAR) then
5117 l_attribute5 := p_attribute5;
5118 end if;
5119 
5120 if (p_attribute6 <> FND_API.G_MISS_CHAR) then
5121 l_attribute6 := p_attribute6;
5122 end if;
5123 
5124 if (p_attribute7 <> FND_API.G_MISS_CHAR) then
5125 l_attribute7:= p_attribute7;
5126 end if;
5127 
5128 if (p_attribute8 <> FND_API.G_MISS_CHAR) then
5129 l_attribute8 := p_attribute8;
5130 end if;
5131 
5132 if (p_attribute9 <> FND_API.G_MISS_CHAR) then
5133 l_attribute9 := p_attribute9;
5134 end if;
5135 
5136 if (p_attribute10 <> FND_API.G_MISS_CHAR) then
5137 l_attribute10 := p_attribute10;
5138 end if;
5139 
5140 if (p_attribute11 <> FND_API.G_MISS_CHAR) then
5141 l_attribute11 := p_attribute11;
5142 end if;
5143 
5144 if (p_attribute12 <> FND_API.G_MISS_CHAR) then
5145 l_attribute12 := p_attribute12;
5146 end if;
5147 
5148 if (p_attribute13 <> FND_API.G_MISS_CHAR) then
5149 l_attribute13 := p_attribute13;
5150 end if;
5151 
5152 if (p_attribute14 <> FND_API.G_MISS_CHAR) then
5153 l_attribute14 := p_attribute14;
5154 end if;
5155 
5156 if (p_attribute15 <> FND_API.G_MISS_CHAR) then
5157 l_attribute15 := p_attribute15;
5158 end if;
5159 
5160   if (p_created_by <> FND_API.G_MISS_NUM) then
5161     l_created_by := p_created_by;
5162   end if;
5163 
5164   if (p_creation_date <> FND_API.G_MISS_DATE) then
5165     l_creation_date := p_creation_date;
5166   end if;
5167 
5168   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
5169     l_last_updated_by := p_last_updated_by;
5170   end if;
5171 
5172   if (p_last_update_date <> FND_API.G_MISS_DATE) then
5173     l_last_update_date := p_last_update_date;
5174   end if;
5175 
5176   if (p_last_update_login <> FND_API.G_MISS_NUM) then
5177     l_last_update_login := p_last_update_login;
5178   end if;
5179 
5180 -- Create record if no validation error was found
5181   --  NOTE - Calling IS_UPDATEABLE for backward compatibility
5182   --  old jlt files didn't have who columns and IS_UPDATEABLE
5183   --  calls SET_WHO which populates those columns, for later
5184   --  jlt files IS_UPDATEABLE will always return TRUE for CREATE
5185 
5186 if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
5187        p_loader_timestamp => p_loader_timestamp,
5188        p_created_by => l_created_by,
5189        p_creation_date => l_creation_date,
5190        p_last_updated_by => l_last_updated_by,
5191        p_db_last_updated_by => null,
5192        p_last_update_date => l_last_update_date,
5193        p_db_last_update_date => null,
5194        p_last_update_login => l_last_update_login,
5195        p_create_or_update => 'CREATE') then
5196      null;
5197   end if;
5198 
5199 select userenv('LANG') into l_lang
5200 from dual;
5201 
5202 insert into AK_REGIONS (
5203 REGION_APPLICATION_ID,
5204 REGION_CODE,
5205 DATABASE_OBJECT_NAME,
5206 REGION_STYLE,
5207 ICX_CUSTOM_CALL,
5208 NUM_COLUMNS,
5209 REGION_DEFAULTING_API_PKG,
5210 REGION_DEFAULTING_API_PROC,
5211 REGION_VALIDATION_API_PKG,
5212 REGION_VALIDATION_API_PROC,
5213 APPLICATIONMODULE_OBJECT_TYPE,
5214 NUM_ROWS_DISPLAY,
5215 REGION_OBJECT_TYPE,
5216 IMAGE_FILE_NAME,
5217 ISFORM_FLAG,
5218 HELP_TARGET,
5219 STYLE_SHEET_FILENAME,
5220 VERSION,
5221 APPLICATIONMODULE_USAGE_NAME,
5222 ADD_INDEXED_CHILDREN,
5223 STATEFUL_FLAG,
5224 FUNCTION_NAME,
5225 CHILDREN_VIEW_USAGE_NAME,
5226 SEARCH_PANEL,
5227 ADVANCED_SEARCH_PANEL,
5228 CUSTOMIZE_PANEL,
5229 DEFAULT_SEARCH_PANEL,
5230 RESULTS_BASED_SEARCH,
5231 DISPLAY_GRAPH_TABLE,
5232 DISABLE_HEADER,
5233 STANDALONE,
5234 AUTO_CUSTOMIZATION_CRITERIA,
5235 ATTRIBUTE_CATEGORY,
5236 ATTRIBUTE1,
5237 ATTRIBUTE2,
5238 ATTRIBUTE3,
5239 ATTRIBUTE4,
5240 ATTRIBUTE5,
5241 ATTRIBUTE6,
5242 ATTRIBUTE7,
5243 ATTRIBUTE8,
5244 ATTRIBUTE9,
5245 ATTRIBUTE10,
5246 ATTRIBUTE11,
5247 ATTRIBUTE12,
5248 ATTRIBUTE13,
5249 ATTRIBUTE14,
5250 ATTRIBUTE15,
5251 CREATION_DATE,
5252 CREATED_BY,
5253 LAST_UPDATE_DATE,
5254 LAST_UPDATED_BY,
5255 LAST_UPDATE_LOGIN
5256 ) values (
5257 p_region_application_id,
5258 p_region_code,
5259 p_database_object_name,
5260 p_region_style,
5261 l_icx_custom_call,
5262 l_num_columns,
5263 l_region_defaulting_api_pkg,
5264 l_region_defaulting_api_proc,
5265 l_region_validation_api_pkg,
5266 l_region_validation_api_proc,
5267 l_appmodule_object_type,
5268 l_num_rows_display,
5269 l_region_object_type,
5270 l_image_file_name,
5271 l_isform_flag,
5272 l_help_target,
5273 l_style_sheet_filename,
5274 l_version,
5275 l_appmodule_usage_name,
5276 l_add_indexed_children,
5277 l_stateful_flag,
5278 l_function_name,
5279 l_children_view_usage_name,
5280 l_search_panel,
5281 l_advanced_search_panel,
5282 l_customize_panel,
5283 l_default_search_panel,
5284 l_results_based_search,
5285 l_display_graph_table,
5286 l_disable_header,
5287 l_standalone,
5288 l_auto_customization_criteria,
5289 l_attribute_category,
5290 l_attribute1,
5291 l_attribute2,
5292 l_attribute3,
5293 l_attribute4,
5294 l_attribute5,
5295 l_attribute6,
5296 l_attribute7,
5297 l_attribute8,
5298 l_attribute9,
5299 l_attribute10,
5300 l_attribute11,
5301 l_attribute12,
5302 l_attribute13,
5303 l_attribute14,
5304 l_attribute15,
5305 l_creation_date,
5306 l_created_by,
5307 l_last_update_date,
5308 l_last_updated_by,
5309 l_last_update_login
5310 );
5311 
5312 --** row should exists before inserting rows for other languages **
5313 if NOT AK_REGION_PVT.REGION_EXISTS (
5314 p_api_version_number => 1.0,
5315 p_return_status => l_return_status,
5316 p_region_application_id => p_region_application_id,
5317 p_region_code => p_region_code) then
5318 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5319 FND_MESSAGE.SET_NAME('AK','AK_INSERT_REGION_FAILED');
5320 FND_MSG_PUB.Add;
5321 end if;
5322 -- dbms_output.put_line(G_PKG_NAME || 'Error - First insert failed');
5323 raise FND_API.G_EXC_ERROR;
5324 end if;
5325 
5326 insert into AK_REGIONS_TL (
5327 REGION_APPLICATION_ID,
5328 REGION_CODE,
5329 LANGUAGE,
5330 NAME,
5331 DESCRIPTION,
5332 SOURCE_LANG,
5333 CREATED_BY,
5334 CREATION_DATE,
5335 LAST_UPDATED_BY,
5336 LAST_UPDATE_DATE,
5337 LAST_UPDATE_LOGIN
5338 ) select
5339 p_region_application_id,
5340 p_region_code,
5341 L.LANGUAGE_CODE,
5342 p_name,
5343 l_description,
5344 decode(L.LANGUAGE_CODE, l_lang, L.LANGUAGE_CODE, l_lang),
5345 l_created_by,
5346 l_creation_date,
5347 l_last_updated_by,
5348 l_last_update_date,
5349 l_last_update_login
5350 from FND_LANGUAGES L
5351 where L.INSTALLED_FLAG in ('I', 'B')
5352 and not exists
5353 (select NULL
5354 from AK_REGIONS_TL T
5355 where T.REGION_APPLICATION_ID = p_region_application_id
5356 and T.REGION_CODE = p_region_code
5357 and T.LANGUAGE = L.LANGUAGE_CODE);
5358 
5359 --  /** commit the insert **/
5360  commit;
5361 
5362 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
5363 FND_MESSAGE.SET_NAME('AK','AK_REGION_CREATED');
5364 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5365 ' ' || p_region_code);
5366 FND_MSG_PUB.Add;
5367 end if;
5368 
5369   end if; -- /* if not p_copy_redo_flag */
5370 
5371 p_return_status := FND_API.G_RET_STS_SUCCESS;
5372 
5373 FND_MSG_PUB.Count_And_Get (
5374 p_count => p_msg_count,
5375 p_data => p_msg_data);
5376 
5377 EXCEPTION
5378 WHEN VALUE_ERROR THEN
5379 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5380 FND_MESSAGE.SET_NAME('AK','AK_REGION_VALUE_ERROR');
5381 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5382 ' ' || p_region_code);
5383 FND_MSG_PUB.Add;
5384 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5385 SUBSTR (SQLERRM, 1, 240));
5386 FND_MSG_PUB.Add;
5387 end if;
5388 p_return_status := FND_API.G_RET_STS_ERROR;
5389 rollback to start_create_region;
5390 FND_MSG_PUB.Count_And_Get (
5391 p_count => p_msg_count,
5392 p_data => p_msg_data);
5393 WHEN FND_API.G_EXC_ERROR THEN
5394 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5395 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_CREATED');
5396 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5397 ' ' || p_region_code);
5398 FND_MSG_PUB.Add;
5399 end if;
5400 p_return_status := FND_API.G_RET_STS_ERROR;
5401 rollback to start_create_region;
5402 FND_MSG_PUB.Count_And_Get (
5403 p_count => p_msg_count,
5404 p_data => p_msg_data);
5405 WHEN OTHERS THEN
5406      if (SQLCODE = -1) then
5407         rollback to start_create_region;
5408          AK_REGION_PVT.UPDATE_REGION(
5409            p_validation_level => p_validation_level,
5410            p_api_version_number => 1.0,
5411            p_msg_count => p_msg_count,
5412            p_msg_data => p_msg_data,
5413            p_return_status => p_return_status,
5414            p_region_application_id => p_region_application_id,
5415            p_region_code => p_region_code,
5416            p_database_object_name =>p_database_object_name,
5417            p_region_style => p_region_style,
5418            p_num_columns => p_num_columns,
5419            p_icx_custom_call => p_icx_custom_call,
5420            p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
5421            p_region_defaulting_api_proc => p_region_defaulting_api_proc,
5422            p_region_validation_api_pkg => p_region_validation_api_pkg,
5423            p_region_validation_api_proc => p_region_validation_api_proc,
5424            p_appmodule_object_type => p_appmodule_object_type,
5425            p_num_rows_display => p_num_rows_display,
5426            p_region_object_type => p_region_object_type,
5427            p_image_file_name => p_image_file_name,
5428            p_isform_flag => p_isform_flag,
5429            p_help_target => p_help_target,
5430            p_style_sheet_filename => p_style_sheet_filename,
5431            p_version => p_version,
5432            p_applicationmodule_usage_name => p_applicationmodule_usage_name,
5433            p_add_indexed_children => p_add_indexed_children,
5434            p_stateful_flag => p_stateful_flag,
5435            p_function_name => p_function_name,
5436            p_children_view_usage_name => p_children_view_usage_name,
5437           p_search_panel => p_search_panel,
5438           p_advanced_search_panel => p_advanced_search_panel,
5439           p_customize_panel => p_customize_panel,
5440           p_default_search_panel => p_default_search_panel,
5441           p_results_based_search => p_results_based_search,
5442           p_display_graph_table => p_display_graph_table,
5443           p_disable_header => p_disable_header,
5444           p_standalone => p_standalone,
5445           p_auto_customization_criteria => p_auto_customization_criteria,
5446            p_attribute_category => p_attribute_category,
5447            p_attribute1 => p_attribute1,
5448            p_attribute2 => p_attribute2,
5449            p_attribute3 => p_attribute3,
5450            p_attribute4 => p_attribute4,
5451            p_attribute5 => p_attribute5,
5452            p_attribute6 => p_attribute6,
5453            p_attribute7 => p_attribute7,
5454            p_attribute8 => p_attribute8,
5455            p_attribute9 => p_attribute9,
5456            p_attribute10 => p_attribute10,
5457            p_attribute11 => p_attribute11,
5458            p_attribute12 => p_attribute12,
5459            p_attribute13 => p_attribute13,
5460            p_attribute14 => p_attribute14,
5461            p_attribute15 => p_attribute15,
5462            p_name => p_name,
5463            p_description => p_description,
5464            p_created_by => p_created_by,
5465            p_creation_date => p_creation_date,
5466            p_last_updated_by => p_last_updated_by,
5467            p_last_update_date => p_last_update_date,
5468            p_last_update_login => p_last_update_login,
5469            p_loader_timestamp => p_loader_timestamp,
5470            p_pass => p_pass,
5471            p_copy_redo_flag => p_copy_redo_flag
5472            );
5473 else
5474 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5475 rollback to start_create_region;
5476 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5477 SUBSTR (SQLERRM, 1, 240) );
5478 FND_MSG_PUB.Add;
5479 FND_MSG_PUB.Count_And_Get (
5480 p_count => p_msg_count,
5481 p_data => p_msg_data);
5482 end if;
5483 end CREATE_REGION;
5484 
5485 /*
5486 --=======================================================
5487 --  Procedure   DELETE_GRAPH
5488 --
5489 --  Usage       Private API for deleting a region graph. This
5490 --              API should only be called by other APIs that are
5491 --              owned by the Core Modules Team (AK).
5492 --
5493 --  Desc        Deletes a region item with the given key value.
5494 --
5495 --  Results     The API returns the standard p_return_status parameter
5496 --              indicating one of the standard return statuses :
5497 --                  * Unexpected error
5498 --                  * Error
5499 --                  * Success
5500 --  Parameters  p_region_application_id : IN required
5501 --              p_region_code : IN required
5502 --              p_attribute_application_id : IN required
5503 --              p_attribute_code : IN required
5504 --                  Key value of the region item to be deleted.
5505 --              p_delete_cascade : IN required
5506 --                  If p_delete_cascade flag is 'Y', also delete all
5507 --                  rows in other tables that references this record.
5508 --                  Otherwise, this record will not be deleted if there
5509 --                  are any other rows referencing it.
5510 --
5511 --  Version     Initial version number  =   1.0
5512 --  History     Current version number  =   1.0
5513 --=======================================================
5514 procedure DELETE_GRAPH (
5515 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
5516 p_api_version_number       IN      NUMBER,
5517 p_init_msg_tbl             IN      BOOLEAN := FALSE,
5518 p_msg_count                OUT NOCOPY     NUMBER,
5519 p_msg_data                 OUT NOCOPY     VARCHAR2,
5520 p_return_status            OUT NOCOPY     VARCHAR2,
5521 p_region_application_id    IN      NUMBER,
5522 p_region_code              IN      VARCHAR2,
5523 p_graph_number	     IN	     NUMBER,
5524 p_delete_cascade           IN      VARCHAR2
5525 ) is
5526 cursor l_get_graph_column_csr is
5527 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
5528 from AK_REGION_GRAPH_COLUMNS
5529 where region_application_id = p_region_application_id
5530 and region_code = p_region_code
5531 and graph_number = p_graph_number;
5532 l_api_version_number    CONSTANT number := 1.0;
5533 l_api_name              CONSTANT varchar2(30):= 'Delete_Item';
5534 l_msg_count             NUMBER;
5535 l_msg_data              VARCHAR2(2000);
5536 l_attribute_application_id	NUMBER;
5537 l_attribute_code		VARCHAR2(30);
5538 l_return_status		VARCHAR2(1);
5539 begin
5540 IF NOT FND_API.Compatible_API_Call (
5541 l_api_version_number, p_api_version_number, l_api_name,
5542 G_PKG_NAME) then
5543 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5544 return;
5545 END IF;
5546 
5547 -- Initialize the message table if requested.
5548 
5549 if p_init_msg_tbl then
5550 FND_MSG_PUB.initialize;
5551 end if;
5552 
5553 savepoint start_delete_graph;
5554 
5555 --
5556 -- error if region item to be deleted does not exists
5557 --
5558 if NOT AK_REGION_PVT.GRAPH_EXISTS (
5559 p_api_version_number => 1.0,
5560 p_return_status => l_return_status,
5561 p_region_application_id => p_region_application_id,
5562 p_region_code => p_region_code,
5563 p_graph_number => p_graph_number) then
5564 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5565 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5566 FND_MSG_PUB.Add;
5567 end if;
5568 raise FND_API.G_EXC_ERROR;
5569 end if;
5570 
5571 if (p_delete_cascade = 'N') then
5572 --
5573 -- If we are not deleting any referencing records, we cannot
5574 -- delete the region item if it is being referenced in any of
5575 -- following tables.
5576 --
5577 -- AK_REGION_GRAPH_COLUMNS
5578 --
5579 open l_get_graph_column_csr;
5580 fetch l_get_graph_column_csr into l_attribute_application_id,
5581 l_attribute_code;
5582 if l_get_graph_column_csr%found then
5583 close l_get_graph_column_csr;
5584 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5585 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
5586 FND_MSG_PUB.Add;
5587 end if;
5588 raise FND_API.G_EXC_ERROR;
5589 end if;
5590 close l_get_graph_column_csr;
5591 --  else
5592 end if;
5593 --
5594 -- Otherwise, delete all referencing rows in other tables
5595 --
5596 -- AK_REGION_GRAPH_COLUMNS
5597 -- LOOK AT AK_FLOW_PVT.DELETE_PAGE_REGION_ITEM to write this code
5598 --    open l_get_graph_column_csr;
5599 --    loop
5600 --      fetch l_get_graph_column_csr into l_attribute_application_id,
5601 --					l_attribute_code;
5602 --      exit when l_get_graph_column_csr%notfound;
5603 --      AK_REGION2_PVT.DELETE_GRAPH_COLUMN(
5604 --        p_validation_level => p_validation_level,
5605 --        p_api_version_number => 1.0,
5606 --        p_msg_count => l_msg_count,
5607 --        p_msg_data => l_msg_data,
5608 --        p_return_status => l_return_status,
5609 --        p_region_application_id => p_region_application_id,
5610 --        p_region_code => p_region_code,
5611 --	p_graph_number => p_graph_number,
5612 --	p_attribute_application_id => l_attribute_application_id,
5613 --        p_attribute_code => l_attribute_code
5614 --      );
5615 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
5616 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
5617 --        close l_get_graph_column_csr;
5618 --        raise FND_API.G_EXC_ERROR;
5619 --      end if;
5620 --    end loop;
5621 --    close l_get_graph_column_csr;
5622 --  end if;
5623 
5624 --
5625 -- delete region graph once we checked that there are no references
5626 -- to it, or all references have been deleted.
5627 --
5628 delete from ak_region_graphs
5629 where region_application_id = p_region_application_id
5630 and    region_code = p_region_code
5631 and    graph_number = p_graph_number;
5632 
5633 if (sql%notfound) then
5634 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5635 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5636 FND_MSG_PUB.Add;
5637 end if;
5638 raise FND_API.G_EXC_ERROR;
5639 end if;
5640 
5641 delete from ak_region_graphs_tl
5642 where  region_application_id = p_region_application_id
5643 and    region_code = p_region_code
5644 and    graph_number = p_graph_number;
5645 
5646 if (sql%notfound) then
5647 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5648 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5649 FND_MSG_PUB.Add;
5650 end if;
5651 raise FND_API.G_EXC_ERROR;
5652 end if;
5653 
5654 --
5655 -- Load success message
5656 --
5657 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
5658 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DELETED');
5659 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5660 ' ' || p_region_code ||
5661 ' ' || p_graph_number);
5662 FND_MSG_PUB.Add;
5663 end if;
5664 
5665 p_return_status := FND_API.G_RET_STS_SUCCESS;
5666 
5667 FND_MSG_PUB.Count_And_Get (
5668 p_count => p_msg_count,
5669 p_data => p_msg_data);
5670 
5671 EXCEPTION
5672 WHEN FND_API.G_EXC_ERROR THEN
5673 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5674 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_DELETED');
5675 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5676 ' ' || p_region_code ||
5677 ' ' || p_graph_number);
5678 FND_MSG_PUB.Add;
5679 end if;
5680 p_return_status := FND_API.G_RET_STS_ERROR;
5681 rollback to start_delete_graph;
5682 FND_MSG_PUB.Count_And_Get (
5683 p_count => p_msg_count,
5684 p_data => p_msg_data);
5685 WHEN OTHERS THEN
5686 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5687 rollback to start_delete_graph;
5688 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5689 SUBSTR (SQLERRM, 1, 240) );
5690 FND_MSG_PUB.Add;
5691 FND_MSG_PUB.Count_And_Get (
5692 p_count => p_msg_count,
5693 p_data => p_msg_data);
5694 end DELETE_GRAPH;
5695 */
5696 
5697 --=======================================================
5698 --  Procedure   DELETE_ITEM
5699 --
5700 --  Usage       Private API for deleting a region item. This
5701 --              API should only be called by other APIs that are
5702 --              owned by the Core Modules Team (AK).
5703 --
5704 --  Desc        Deletes a region item with the given key value.
5705 --
5706 --  Results     The API returns the standard p_return_status parameter
5707 --              indicating one of the standard return statuses :
5708 --                  * Unexpected error
5709 --                  * Error
5710 --                  * Success
5711 --  Parameters  p_region_application_id : IN required
5712 --              p_region_code : IN required
5713 --              p_attribute_application_id : IN required
5714 --              p_attribute_code : IN required
5715 --                  Key value of the region item to be deleted.
5716 --              p_delete_cascade : IN required
5717 --                  If p_delete_cascade flag is 'Y', also delete all
5718 --                  rows in other tables that references this record.
5719 --                  Otherwise, this record will not be deleted if there
5720 --                  are any other rows referencing it.
5721 --
5722 --  Version     Initial version number  =   1.0
5723 --  History     Current version number  =   1.0
5724 --=======================================================
5725 procedure DELETE_ITEM (
5726 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
5727 p_api_version_number       IN      NUMBER,
5728 p_init_msg_tbl             IN      BOOLEAN := FALSE,
5729 p_msg_count                OUT NOCOPY     NUMBER,
5730 p_msg_data                 OUT NOCOPY     VARCHAR2,
5731 p_return_status            OUT NOCOPY     VARCHAR2,
5732 p_region_application_id    IN      NUMBER,
5733 p_region_code              IN      VARCHAR2,
5734 p_attribute_application_id IN      NUMBER,
5735 p_attribute_code           IN      VARCHAR2,
5736 p_delete_cascade           IN      VARCHAR2
5737 ) is
5738 cursor l_get_lov_relations_csr is
5739 select LOV_REGION_APPL_ID, LOV_REGION_CODE, LOV_ATTRIBUTE_APPL_ID,
5740 LOV_ATTRIBUTE_CODE, BASE_ATTRIBUTE_APPL_ID, BASE_ATTRIBUTE_CODE,
5741 DIRECTION_FLAG, BASE_REGION_APPL_ID, BASE_REGION_CODE
5742 from AK_REGION_LOV_RELATIONS
5743 where region_application_id = p_region_application_id
5744 and   region_code = p_region_code
5745 and   attribute_application_id = p_attribute_application_id
5746 and   attribute_code = p_attribute_code;
5747 cursor l_get_category_usages_csr is
5748 select CATEGORY_ID
5749 from  AK_CATEGORY_USAGES
5750 where region_application_id = p_region_application_id
5751 and   region_code = p_region_code
5752 and   attribute_application_id = p_attribute_application_id
5753 and   attribute_code = p_attribute_code;
5754 cursor l_get_page_region_item_csr is
5755 select FLOW_APPLICATION_ID, FLOW_CODE, PAGE_APPLICATION_ID, PAGE_CODE
5756 from  AK_FLOW_PAGE_REGION_ITEMS
5757 where region_application_id = p_region_application_id
5758 and   region_code = p_region_code
5759 and   attribute_application_id = p_attribute_application_id
5760 and   attribute_code = p_attribute_code;
5761 l_api_version_number    CONSTANT number := 1.0;
5762 l_api_name              CONSTANT varchar2(30):= 'Delete_Item';
5763 l_msg_count             NUMBER;
5764 l_msg_data              VARCHAR2(2000);
5765 l_flow_application_id   NUMBER;
5766 l_flow_code             VARCHAR2(30);
5767 l_page_application_id   NUMBER;
5768 l_page_code             VARCHAR2(30);
5769 l_lov_region_appl_id    NUMBER;
5770 l_lov_region_code       VARCHAR2(30);
5771 l_base_attribute_appl_id NUMBER;
5772 l_base_attribute_code   VARCHAR2(30);
5773 l_direction_flag        VARCHAR2(30);
5774 l_base_region_appl_id	  NUMBER;
5775 l_base_region_code	  VARCHAR2(30);
5776 l_lov_attribute_appl_id NUMBER;
5777 l_lov_attribute_code    VARCHAR2(30);
5778 l_category_id	 	  NUMBER;
5779 l_return_status         varchar2(1);
5780 begin
5781 IF NOT FND_API.Compatible_API_Call (
5782 l_api_version_number, p_api_version_number, l_api_name,
5783 G_PKG_NAME) then
5784 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5785 return;
5786 END IF;
5787 
5788 -- Initialize the message table if requested.
5789 
5790 if p_init_msg_tbl then
5791 FND_MSG_PUB.initialize;
5792 end if;
5793 
5794 savepoint start_delete_item;
5795 
5796 --
5797 -- error if region item to be deleted does not exists
5798 --
5799 if NOT AK_REGION_PVT.ITEM_EXISTS (
5800 p_api_version_number => 1.0,
5801 p_return_status => l_return_status,
5802 p_region_application_id => p_region_application_id,
5803 p_region_code => p_region_code,
5804 p_attribute_application_id => p_attribute_application_id,
5805 p_attribute_code => p_attribute_code) then
5806 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5807 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5808 FND_MSG_PUB.Add;
5809 end if;
5810 raise FND_API.G_EXC_ERROR;
5811 end if;
5812 
5813 if (p_delete_cascade = 'N') then
5814 --
5815 -- If we are not deleting any referencing records, we cannot
5816 -- delete the region item if it is being referenced in any of
5817 -- following tables.
5818 --
5819 -- AK_FLOW_PAGE_REGION_ITEMS
5820 --
5821 open l_get_page_region_item_csr;
5822 fetch l_get_page_region_item_csr into l_flow_application_id, l_flow_code,
5823 l_page_application_id, l_page_code;
5824 if l_get_page_region_item_csr%found then
5825 close l_get_page_region_item_csr;
5826 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5827 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
5828 FND_MSG_PUB.Add;
5829 end if;
5830 raise FND_API.G_EXC_ERROR;
5831 end if;
5832 close l_get_page_region_item_csr;
5833 else
5834 --
5835 -- Otherwise, delete all referencing rows in other tables
5836 --
5837 -- AK_REGION_LOV_RELATIONS
5838 --
5839 open l_get_lov_relations_csr;
5840 loop
5841 fetch l_get_lov_relations_csr into l_lov_region_appl_id,
5842 l_lov_region_code, l_lov_attribute_appl_id, l_lov_attribute_code,
5843 l_base_attribute_appl_id, l_base_attribute_code, l_direction_flag,
5844 l_base_region_appl_id, l_base_region_code;
5845 exit when l_get_lov_relations_csr%notfound;
5846 delete from ak_region_lov_relations
5847 where  region_application_id = p_region_application_id
5848 and    region_code = p_region_code
5849 and    attribute_application_id = p_attribute_application_id
5850 and    attribute_code = p_attribute_code
5851 and    lov_region_appl_id = l_lov_region_appl_id
5852 and    lov_region_code = l_lov_region_code
5853 and    lov_attribute_appl_id = l_lov_attribute_appl_id
5854 and    lov_attribute_code = l_lov_attribute_code
5855 and    base_attribute_appl_id = l_base_attribute_appl_id
5856 and    base_attribute_code = l_base_attribute_code
5857 and    direction_flag = l_direction_flag
5858 and    base_region_appl_id = l_base_region_appl_id
5859 and    base_region_code = l_base_region_code;
5860 
5861 if (sql%notfound) then
5862 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5863 FND_MESSAGE.SET_NAME('AK','AK_LOV_REL_DOES_NOT_EXIST');
5864 FND_MSG_PUB.Add;
5865 end if;
5866 close l_get_lov_relations_csr;
5867 raise FND_API.G_EXC_ERROR;
5868 end if;
5869 end loop;
5870 close l_get_lov_relations_csr;
5871 
5872 --
5873 -- AK_CATEGORY_USAGES
5874 --
5875 open l_get_category_usages_csr;
5876 loop
5877 fetch l_get_category_usages_csr into l_category_id;
5878 exit when l_get_category_usages_csr%notfound;
5879 delete from ak_category_usages
5880 where  region_application_id = p_region_application_id
5881 and    region_code = p_region_code
5882 and    attribute_application_id = p_attribute_application_id
5883 and    attribute_code = p_attribute_code
5884 and    category_id = l_category_id;
5885 
5886 if (sql%notfound) then
5887 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5888 FND_MESSAGE.SET_NAME('AK','AK_CAT_USAGE_DOES_NOT_EXIST');
5889 FND_MSG_PUB.Add;
5890 end if;
5891 close l_get_category_usages_csr;
5892 raise FND_API.G_EXC_ERROR;
5893 end if;
5894 end loop;
5895 close l_get_category_usages_csr;
5896 
5897 --
5898 -- AK_FLOW_PAGE_REGION_ITEMS
5899 --
5900 --    open l_get_page_region_item_csr;
5901 --    loop
5902 --      fetch l_get_page_region_item_csr into l_flow_application_id, l_flow_code,
5903 --                                        l_page_application_id, l_page_code;
5904 --      exit when l_get_page_region_item_csr%notfound;
5905 --      AK_FLOW_PVT.DELETE_PAGE_REGION_ITEM (
5906 --        p_validation_level => p_validation_level,
5907 --        p_api_version_number => 1.0,
5908 --        p_msg_count => l_msg_count,
5909 --        p_msg_data => l_msg_data,
5910 --        p_return_status => l_return_status,
5911 --        p_flow_application_id => l_flow_application_id,
5912 --        p_flow_code => l_flow_code,
5913 --        p_page_application_id => l_page_application_id,
5914 --        p_page_code => l_page_code,
5915 --        p_region_application_id => p_region_application_id,
5916 --        p_region_code => p_region_code,
5917 --        p_attribute_application_id => p_attribute_application_id,
5918 --        p_attribute_code => p_attribute_code,
5919 --        p_delete_cascade => p_delete_cascade
5920 --      );
5921 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
5922 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
5923 --        close l_get_page_region_item_csr;
5924 --        raise FND_API.G_EXC_ERROR;
5925 --      end if;
5926 --    end loop;
5927 --    close l_get_page_region_item_csr;
5928 end if;
5929 
5930 --
5931 -- delete region item once we checked that there are no references
5932 -- to it, or all references have been deleted.
5933 --
5934 delete from ak_region_items
5935 where  region_application_id = p_region_application_id
5936 and    region_code = p_region_code
5937 and    attribute_application_id = p_attribute_application_id
5938 and    attribute_code = p_attribute_code;
5939 
5940 if (sql%notfound) then
5941 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5942 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5943 FND_MSG_PUB.Add;
5944 end if;
5945 raise FND_API.G_EXC_ERROR;
5946 end if;
5947 
5948 delete from ak_region_items_tl
5949 where  region_application_id = p_region_application_id
5950 and    region_code = p_region_code
5951 and    attribute_application_id = p_attribute_application_id
5952 and    attribute_code = p_attribute_code;
5953 
5954 if (sql%notfound) then
5955 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5956 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5957 FND_MSG_PUB.Add;
5958 end if;
5959 raise FND_API.G_EXC_ERROR;
5960 end if;
5961 
5962 --
5963 -- Load success message
5964 --
5965 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
5966 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DELETED');
5967 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5968 ' ' || p_region_code ||
5969 ' ' || to_char(p_attribute_application_id) ||
5970 ' ' || p_attribute_code);
5971 FND_MSG_PUB.Add;
5972 end if;
5973 
5974 p_return_status := FND_API.G_RET_STS_SUCCESS;
5975 
5976 FND_MSG_PUB.Count_And_Get (
5977 p_count => p_msg_count,
5978 p_data => p_msg_data);
5979 
5980 EXCEPTION
5981 WHEN FND_API.G_EXC_ERROR THEN
5982 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5983 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_DELETED');
5984 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5985 ' ' || p_region_code ||
5986 ' ' || to_char(p_attribute_application_id) ||
5987 ' ' || p_attribute_code);
5988 FND_MSG_PUB.Add;
5989 end if;
5990 p_return_status := FND_API.G_RET_STS_ERROR;
5991 rollback to start_delete_item;
5992 FND_MSG_PUB.Count_And_Get (
5993 p_count => p_msg_count,
5994 p_data => p_msg_data);
5995 WHEN OTHERS THEN
5996 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5997 rollback to start_delete_item;
5998 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5999 SUBSTR (SQLERRM, 1, 240) );
6000 FND_MSG_PUB.Add;
6001 FND_MSG_PUB.Count_And_Get (
6002 p_count => p_msg_count,
6003 p_data => p_msg_data);
6004 end DELETE_ITEM;
6005 
6006 --=======================================================
6007 --  Procedure   DELETE_REGION
6008 --
6009 --  Usage       Private API for deleting a region. This
6010 --              API should only be called by other APIs that are
6011 --              owned by the Core Modules Team (AK).
6012 --
6013 --  Desc        Deletes a region with the given key value.
6014 --
6015 --  Results     The API returns the standard p_return_status parameter
6016 --              indicating one of the standard return statuses :
6017 --                  * Unexpected error
6018 --                  * Error
6019 --                  * Success
6020 --  Parameters  p_region_application_id : IN required
6021 --              p_region_code : IN required
6022 --                  Key value of the region to be deleted.
6023 --              p_delete_cascade : IN required
6024 --                  If p_delete_cascade flag is 'Y', also delete all
6025 --                  rows in other tables that references this record.
6026 --                  Otherwise, this record will not be deleted if there
6027 --                  are any other rows referencing it.
6028 --
6029 --  Version     Initial version number  =   1.0
6030 --  History     Current version number  =   1.0
6031 --=======================================================
6032 procedure DELETE_REGION (
6033 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
6034 p_api_version_number       IN      NUMBER,
6035 p_init_msg_tbl             IN      BOOLEAN := FALSE,
6036 p_msg_count                OUT NOCOPY     NUMBER,
6037 p_msg_data                 OUT NOCOPY     VARCHAR2,
6038 p_return_status            OUT NOCOPY     VARCHAR2,
6039 p_region_application_id    IN      NUMBER,
6040 p_region_code              IN      VARCHAR2,
6041 p_delete_cascade           IN      VARCHAR2
6042 ) is
6043 cursor l_is_region_a_child_csr is
6044 select region_code, region_application_id
6045 from AK_REGION_ITEMS
6046 where region_code <> p_region_code
6047 and   region_application_id <> p_region_application_id
6048 and   (lov_region_code = p_region_code
6049 and   lov_region_application_id = p_region_application_id)
6050 or    (nested_region_code = p_region_code
6051 and   nested_region_application_id = p_region_application_id);
6052 cursor l_get_page_region_csr is
6053 select FLOW_APPLICATION_ID, FLOW_CODE, PAGE_APPLICATION_ID, PAGE_CODE
6054 from  AK_FLOW_PAGE_REGIONS
6055 where region_application_id = p_region_application_id
6056 and   region_code = p_region_code;
6057 cursor l_get_items_csr is
6058 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
6059 from  AK_REGION_ITEMS
6060 where region_application_id = p_region_application_id
6061 and   region_code = p_region_code;
6062 cursor l_get_navigations_csr is
6063 select DATABASE_OBJECT_NAME, ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE,
6064 VALUE_VARCHAR2, VALUE_DATE, VALUE_NUMBER
6065 from  AK_OBJECT_ATTRIBUTE_NAVIGATION
6066 where to_region_appl_id = p_region_application_id
6067 and   to_region_code = p_region_code;
6068 l_api_version_number    CONSTANT number := 1.0;
6069 l_api_name              CONSTANT varchar2(30):= 'Delete_Region';
6070 l_attribute_application_id NUMBER;
6071 l_attribute_code        VARCHAR2(30);
6072 l_database_object_name  VARCHAR2(30);
6073 l_flow_application_id   NUMBER;
6074 l_flow_code             VARCHAR2(30);
6075 l_msg_count             NUMBER;
6076 l_msg_data              VARCHAR2(2000);
6077 l_page_application_id   NUMBER;
6078 l_page_code             VARCHAR2(30);
6079 l_region_code 	  VARCHAR2(30);
6080 l_region_application_id NUMBER;
6081 l_return_status         varchar2(1);
6082 l_value_date            DATE;
6083 l_value_number          NUMBER;
6084 l_value_varchar2        VARCHAR2(240);
6085 begin
6086 IF NOT FND_API.Compatible_API_Call (
6087 l_api_version_number, p_api_version_number, l_api_name,
6088 G_PKG_NAME) then
6089 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6090 return;
6091 END IF;
6092 
6093 -- Initialize the message table if requested.
6094 
6095 if p_init_msg_tbl then
6096 FND_MSG_PUB.initialize;
6097 end if;
6098 
6099 savepoint start_delete_region;
6100 
6101 /** do not raise exception when region does not exist,
6102 * and do not print out warning message
6103 --
6104 -- error if primary key to be deleted does not exists
6105 --
6106 if NOT AK_REGION_PVT.REGION_EXISTS (
6107 p_api_version_number => 1.0,
6108 p_return_status => l_return_status,
6109 p_region_application_id => p_region_application_id,
6110 p_region_code => p_region_code) then
6111 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6112 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6113 FND_MSG_PUB.Add;
6114 end if;
6115 raise FND_API.G_EXC_ERROR;
6116 end if;
6117 **/
6118 
6119 if AK_REGION_PVT.REGION_EXISTS (
6120 p_api_version_number => 1.0,
6121 p_return_status => l_return_status,
6122 p_region_application_id => p_region_application_id,
6123 p_region_code => p_region_code) then
6124 
6125 open l_is_region_a_child_csr;
6126 fetch l_is_region_a_child_csr into l_region_code, l_region_application_id;
6127 if l_is_region_a_child_csr%found then
6128 close l_is_region_a_child_csr;
6129 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6130 FND_MESSAGE.SET_NAME('AK','AK_REGION_IS_CHILD');
6131 FND_MSG_PUB.Add;
6132 end if;
6133 raise FND_API.G_EXC_ERROR;
6134 end if;
6135 close l_is_region_a_child_csr;
6136 
6137 if (p_delete_cascade = 'N') then
6138 --
6139 -- If we are not deleting any referencing records, we cannot
6140 -- delete the region if it is being referenced in any of
6141 -- following tables.
6142 --
6143 -- AK_REGION_ITEMS
6144 --
6145 open l_get_items_csr;
6146 fetch l_get_items_csr into l_attribute_application_id, l_attribute_code;
6147 if l_get_items_csr%found then
6148 close l_get_items_csr;
6149 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6150 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
6151 FND_MSG_PUB.Add;
6152 end if;
6153 raise FND_API.G_EXC_ERROR;
6154 end if;
6155 close l_get_items_csr;
6156 --
6157 -- AK_FLOW_PAGE_REGIONS
6158 --
6159 open l_get_page_region_csr;
6160 fetch l_get_page_region_csr into l_flow_application_id, l_flow_code,
6161 l_page_application_id, l_page_code;
6162 if l_get_page_region_csr%found then
6163 close l_get_page_region_csr;
6164 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6165 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_PGREG');
6166 FND_MSG_PUB.Add;
6167 end if;
6168 raise FND_API.G_EXC_ERROR;
6169 end if;
6170 close l_get_page_region_csr;
6171 --
6172 -- AK_OBJECT_ATTRIBUTE_NAVIGATION
6173 --
6174 open l_get_navigations_csr;
6175 fetch l_get_navigations_csr into l_database_object_name,
6176 l_attribute_application_id, l_attribute_code,
6177 l_value_varchar2, l_value_date, l_value_number;
6178 if l_get_navigations_csr%found then
6179 close l_get_navigations_csr;
6180 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6181 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_NAV');
6182 FND_MSG_PUB.Add;
6183 end if;
6184 raise FND_API.G_EXC_ERROR;
6185 end if;
6186 close l_get_navigations_csr;
6187 else
6188 --
6189 -- Otherwise, delete all referencing rows in other tables
6190 --
6191 -- AK_REGION_TIEMS
6192 --
6193 open l_get_items_csr;
6194 loop
6195 fetch l_get_items_csr into l_attribute_application_id, l_attribute_code;
6196 exit when l_get_items_csr%notfound;
6197 AK_REGION_PVT.DELETE_ITEM (
6198 p_validation_level => p_validation_level,
6199 p_api_version_number => 1.0,
6200 p_msg_count => l_msg_count,
6201 p_msg_data => l_msg_data,
6202 p_return_status => l_return_status,
6203 p_region_application_id => p_region_application_id,
6204 p_region_code => p_region_code,
6205 p_attribute_application_id => l_attribute_application_id,
6206 p_attribute_code => l_attribute_code,
6207 p_delete_cascade => p_delete_cascade
6208 );
6209 if (l_return_status = FND_API.G_RET_STS_ERROR) or
6210 (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6211 close l_get_items_csr;
6212 raise FND_API.G_EXC_ERROR;
6213 end if;
6214 end loop;
6215 close l_get_items_csr;
6216 --
6217 -- AK_FLOW_PAGE_REGIONS
6218 --
6219 --    open l_get_page_region_csr;
6220 --    loop
6221 --      fetch l_get_page_region_csr into l_flow_application_id, l_flow_code,
6222 --                                   l_page_application_id, l_page_code;
6223 --      exit when l_get_page_region_csr%notfound;
6224 --      AK_FLOW_PVT.DELETE_PAGE_REGION (
6225 --        p_validation_level => p_validation_level,
6226 --        p_api_version_number => 1.0,
6227 --        p_msg_count => l_msg_count,
6228 --        p_msg_data => l_msg_data,
6229 --        p_return_status => l_return_status,
6230 --        p_flow_application_id => l_flow_application_id,
6231 --        p_flow_code => l_flow_code,
6232 --        p_page_application_id => l_page_application_id,
6233 --        p_page_code => l_page_code,
6234 --        p_region_application_id => p_region_application_id,
6235 --        p_region_code => p_region_code,
6236 --        p_delete_cascade => p_delete_cascade
6237 --      );
6238 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
6239 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6240 --        close l_get_page_region_csr;
6241 --        raise FND_API.G_EXC_ERROR;
6242 --      end if;
6243 --    end loop;
6244 --    close l_get_page_region_csr;
6245 --
6246 -- AK_OBJECT_ATTRIBUTE_NAVIGATION
6247 --
6248 --    open l_get_navigations_csr;
6249 --    loop
6250 --      fetch l_get_navigations_csr into l_database_object_name,
6251 --                       l_attribute_application_id, l_attribute_code,
6252 --                       l_value_varchar2, l_value_date, l_value_number;
6253 --      exit when l_get_navigations_csr%notfound;
6254 --      AK_OBJECT_PVT.DELETE_ATTRIBUTE_NAVIGATION (
6255 --        p_validation_level => p_validation_level,
6256 --        p_api_version_number => 1.0,
6257 --        p_msg_count => l_msg_count,
6258 --        p_msg_data => l_msg_data,
6259 --        p_return_status => l_return_status,
6260 --        p_database_object_name => l_database_object_name,
6261 --        p_attribute_application_id => l_attribute_application_id,
6262 --        p_attribute_code => l_attribute_code,
6263 --        p_value_varchar2 => l_value_varchar2,
6264 --        p_value_date => l_value_date,
6265 --        p_value_number => l_value_number,
6266 --        p_delete_cascade => p_delete_cascade
6267 --      );
6268 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
6269 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6270 --        close l_get_navigations_csr;
6271 --        raise FND_API.G_EXC_ERROR;
6272 --      end if;
6273 --    end loop;
6274 --    close l_get_navigations_csr;
6275 
6276 end if;
6277 
6278 --
6279 -- delete region item once we checked that there are no references
6280 -- to it, or all references have been deleted.
6281 --
6282 delete from ak_regions
6283 where  region_application_id = p_region_application_id
6284 and    region_code = p_region_code;
6285 
6286 if (sql%notfound) then
6287 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6288 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6289 FND_MSG_PUB.Add;
6290 end if;
6291 raise FND_API.G_EXC_ERROR;
6292 end if;
6293 
6294 delete from ak_regions_tl
6295 where  region_application_id = p_region_application_id
6296 and    region_code = p_region_code;
6297 
6298 if (sql%notfound) then
6299 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6300 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6301 FND_MESSAGE.SET_TOKEN('OBJECT', 'AK_LC_REGION',TRUE);
6302 FND_MSG_PUB.Add;
6303 end if;
6304 raise FND_API.G_EXC_ERROR;
6305 end if;
6306 
6307 --
6308 -- Load success message
6309 --
6310 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
6311 FND_MESSAGE.SET_NAME('AK','AK_REGION_DELETED');
6312 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
6313 ' ' || p_region_code);
6314 FND_MSG_PUB.Add;
6315 end if;
6316 end if; -- region exists
6317 
6318 p_return_status := FND_API.G_RET_STS_SUCCESS;
6319 
6320 FND_MSG_PUB.Count_And_Get (
6321 p_count => p_msg_count,
6322 p_data => p_msg_data);
6323 
6324 EXCEPTION
6325 WHEN FND_API.G_EXC_ERROR THEN
6326 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6327 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_DELETED');
6328 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
6329 ' ' || p_region_code);
6330 FND_MSG_PUB.Add;
6331 end if;
6332 p_return_status := FND_API.G_RET_STS_ERROR;
6333 rollback to start_delete_region;
6334 FND_MSG_PUB.Count_And_Get (
6335 p_count => p_msg_count,
6336 p_data => p_msg_data);
6337 WHEN OTHERS THEN
6338 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6339 rollback to start_delete_region;
6340 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6341 SUBSTR (SQLERRM, 1, 240) );
6342 FND_MSG_PUB.Add;
6343 FND_MSG_PUB.Count_And_Get (
6344 p_count => p_msg_count,
6345 p_data => p_msg_data);
6346 end DELETE_REGION;
6347 
6348 --=======================================================
6349 --  Procedure   DOWNLOAD_REGION
6350 --
6351 --  Usage       Private API for downloading regions. This
6352 --              API should only be called by other APIs that are
6353 --              owned by the Core Modules Team (AK).
6354 --
6355 --  Desc        This API will extract the regions selected
6356 --              by application ID or by key values from the
6357 --              database to the output file.
6358 --              If a region is selected for writing to the loader
6359 --              file, all its children records (including region items)
6360 --              will also be written.
6361 --
6362 --  Results     The API returns the standard p_return_status parameter
6363 --              indicating one of the standard return statuses :
6364 --                  * Unexpected error
6365 --                  * Error
6366 --                  * Success
6367 --  Parameters
6368 --              p_nls_language : IN optional
6369 --                  NLS language for database. If none if given,
6370 --                  the current NLS language will be used.
6371 --              p_get_object_flag : IN required
6372 --                  Call DOWNLOAD_OBJECT API to extract objects that
6373 --                  are referenced by the regions that will be extracted
6374 --                  by this API if this parameter is 'Y'.
6375 --
6376 --              One of the following parameters must be provided:
6377 --
6378 --              p_application_id : IN optional
6379 --                  If given, all attributes for this application ID
6380 --                  will be written to the output file.
6381 --                  p_application_id will be ignored if a table is
6382 --                  given in p_region_pk_tbl.
6383 --              p_region_pk_tbl : IN optional
6384 --                  If given, only regions whose key values are
6385 --                  included in this table will be written to the
6386 --                  output file.
6387 --
6388 --
6389 --  Version     Initial version number  =   1.0
6390 --  History     Current version number  =   1.0
6391 --=======================================================
6392 procedure DOWNLOAD_REGION (
6393 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
6394 p_api_version_number       IN      NUMBER,
6395 p_return_status            OUT NOCOPY     VARCHAR2,
6396 p_application_id           IN      NUMBER := FND_API.G_MISS_NUM,
6397 p_region_pk_tbl            IN OUT NOCOPY     AK_REGION_PUB.Region_PK_Tbl_Type,
6398 p_nls_language             IN      VARCHAR2,
6399 p_get_object_flag          IN      VARCHAR2
6400 ) is
6401 cursor l_get_region_list_csr (application_id number) is
6402 select region_application_id, region_code
6403 from   AK_REGIONS
6404 where  REGION_APPLICATION_ID = application_id;
6405 cursor l_get_region_items_csr (region_appl_id_param number,
6406 region_code_param varchar2) is
6407 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
6408 from   AK_REGION_ITEMS
6409 where  region_application_id = region_appl_id_param
6410 and    region_code = region_code_param
6411 and    object_attribute_flag = 'N';
6412 cursor l_get_target_regions_csr (region_appl_id_param number,
6413 region_code_param varchar2) is
6414 select distinct to_region_appl_id, to_region_code
6415 from   AK_OBJECT_ATTRIBUTE_NAVIGATION aoan, AK_REGIONS ar
6416 where  ar.region_application_id = region_appl_id_param
6417 and    ar.region_code = region_code_param
6418 and    aoan.database_object_name = ar.database_object_name;
6419 cursor l_get_database_object_name_csr (region_appl_id_param number,
6420 region_code_param varchar2) is
6421 select DATABASE_OBJECT_NAME
6422 from   AK_REGIONS
6423 where  region_application_id = region_appl_id_param
6424 and    region_code = region_code_param;
6425 cursor l_get_ri_lov_regions_csr (region_appl_id_param number,
6426 region_code_param varchar2) is
6427 select distinct lov_region_application_id, lov_region_code
6428 from   AK_REGION_ITEMS
6429 where  region_application_id = region_appl_id_param
6430 and    region_code = region_code_param
6431 and    lov_region_application_id is not null
6432 and    lov_region_code is not null;
6433 cursor l_get_oa_lov_regions_csr (region_appl_id_param number,
6434 region_code_param varchar2) is
6435 select distinct aoa.lov_region_application_id, aoa.lov_region_code
6436 from   AK_REGIONS ar, AK_OBJECT_ATTRIBUTES aoa
6437 where  ar.region_application_id = region_appl_id_param
6438 and    ar.region_code = region_code_param
6439 and    ar.database_object_name = aoa.database_object_name
6440 and    aoa.lov_region_application_id is not null
6441 and    aoa.lov_region_code is not null;
6442 cursor l_get_attr_lov_regions_csr (region_appl_id_param number,
6443 region_code_param varchar2) is
6444 select distinct aa.lov_region_application_id, aa.lov_region_code
6445 from   AK_REGION_ITEMS ar, AK_ATTRIBUTES aa
6446 where  ar.region_application_id = region_appl_id_param
6447 and    ar.region_code = region_code_param
6448 and    ar.object_attribute_flag = 'N'
6449 and    ar.attribute_application_id = aa.attribute_application_id
6450 and    ar.attribute_code = aa.attribute_code
6451 and    aa.lov_region_application_id is not null
6452 and    aa.lov_region_code is not null;
6453 cursor l_get_lov_region_items_csr (region_appl_id_param number,
6454 region_code_param varchar2) is
6455 select region_application_id, region_code, attribute_application_id,
6456 attribute_code
6457 from   ak_region_items
6458 where  region_application_id = region_appl_id_param
6459 and    region_code = region_code_param
6460 and    object_attribute_flag = 'N'
6461 and    lov_region_application_id is not null
6462 and    lov_region_code is not null;
6463 cursor l_get_relation_lov_regions_csr (region_appl_id_param number,
6464 region_code_param varchar2,
6465 attribute_appl_id_param number,
6466 attribute_code_param varchar2) is
6467 select distinct lov_region_appl_id, lov_region_code
6468 from   ak_region_lov_relations
6469 where  region_application_id = region_appl_id_param
6470 and    region_code = region_code_param
6471 and    attribute_application_id = attribute_appl_id_param
6472 and    attribute_code = attribute_code_param;
6473 
6474 l_api_version_number CONSTANT number := 1.0;
6475 l_api_name           CONSTANT varchar2(30) := 'Download_Region';
6476 l_attribute_pk_tbl   AK_ATTRIBUTE_PUB.Attribute_PK_Tbl_Type;
6477 l_msg_count          NUMBER;
6478 l_msg_data           VARCHAR2(2000);
6479 l_object_pk_tbl      AK_OBJECT_PUB.Object_PK_Tbl_Type;
6480 l_index              NUMBER;
6481 l_region_pk_tbl      AK_REGION_PUB.Region_PK_Tbl_Type;
6482 l_return_status      varchar2(1);
6483 begin
6484 IF NOT FND_API.Compatible_API_Call (
6485 l_api_version_number, p_api_version_number, l_api_name,
6486 G_PKG_NAME) then
6487 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6488 return;
6489 END IF;
6490 
6491 -- Check that one of the following selection criteria is given:
6492 -- - p_application_id alone, or
6493 -- - a list of region_application_id and region_code in p_object_PK_tbl
6494 if (p_application_id = FND_API.G_MISS_NUM) then
6495 if (p_region_PK_tbl.count = 0) then
6496 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6497 FND_MESSAGE.SET_NAME('AK','AK_NO_SELECTION');
6498 FND_MSG_PUB.Add;
6499 end if;
6500 raise FND_API.G_EXC_ERROR;
6501 end if;
6502 else
6503 if (p_region_PK_tbl.count > 0) then
6504 -- both application ID and a list of regions to be extracted are
6505 -- given, issue a warning that we will ignore the application ID
6506 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6507 FND_MESSAGE.SET_NAME('AK','AK_APPL_ID_IGNORED');
6508 FND_MSG_PUB.Add;
6509 end if;
6510 end if;
6511 end if;
6512 
6513 -- If selecting by application ID, first load a region primary key tabl
6514 -- with the primary key of all regions for the given application ID.
6515 -- If selecting by a list of regions, simply copy the region primary key
6516 -- table with the parameter
6517 if (p_region_PK_tbl.count > 0) then
6518 l_region_pk_tbl := p_region_pk_tbl;
6519 else
6520 l_index := 1;
6521 open l_get_region_list_csr(p_application_id);
6522 loop
6523 fetch l_get_region_list_csr into
6524 l_region_pk_tbl(l_index).region_appl_id,
6525 l_region_pk_tbl(l_index).region_code;
6526 exit when l_get_region_list_csr%notfound;
6527 l_index := l_index + 1;
6528 end loop;
6529 close l_get_region_list_csr;
6530 end if;
6531 
6532 -- Build a list of objects and attributes referenced by all the regions
6533 -- to be extracted from the database. Also add LOV regions and target
6534 -- regions of some object attribute navigation records to the list
6535 -- of regions to be extracted.
6536 --
6537 l_index := l_region_pk_tbl.FIRST;
6538 
6539 while (l_index is not null) loop
6540 -- Include regions that are the target regions of some object attribute
6541 -- navigation records of objects that will be extracted along with the
6542 -- given list of regions
6543 for l_region_rec in l_get_target_regions_csr (
6544 l_region_pk_tbl(l_index).region_appl_id,
6545 l_region_pk_tbl(l_index).region_code) LOOP
6546 ak_region_pvt.insert_region_pk_table(
6547 p_return_status => l_return_status,
6548 p_region_application_id => l_region_rec.to_region_appl_id,
6549 p_region_code => l_region_rec.to_region_code,
6550 p_region_pk_tbl => l_region_pk_tbl);
6551 end loop;
6552 
6553 -- If the download object flag is 'Y', add
6554 -- the database object referenced by this region to the object
6555 -- list, which will be used to download those objects.
6556 --
6557 if (p_get_object_flag = 'Y')  then
6558 --
6559 -- Add the object referenced by this region to the object list
6560 --
6561 for l_object_rec in l_get_database_object_name_csr(
6562 l_region_pk_tbl(l_index).region_appl_id,
6563 l_region_pk_tbl(l_index).region_code) LOOP
6564 AK_OBJECT_PVT.INSERT_OBJECT_PK_TABLE (
6565 p_return_status => l_return_status,
6566 p_database_object_name => l_object_rec.database_object_name,
6567 p_object_pk_tbl => l_object_pk_tbl);
6568 end loop;
6569 
6570 if (AK_DOWNLOAD_GRP.G_DOWNLOAD_ATTR = 'Y') then
6571 -- Get all attributes referenced by all region items in this region
6572 -- and add them to the attribute list
6573 for l_attribute_rec in l_get_region_items_csr (
6574 l_region_pk_tbl(l_index).region_appl_id,
6575 l_region_pk_tbl(l_index).region_code) LOOP
6576 AK_ATTRIBUTE_PVT.INSERT_ATTRIBUTE_PK_TABLE (
6577 p_return_status => l_return_status,
6578 p_attribute_application_id =>
6579 l_attribute_rec.attribute_application_id,
6580 p_attribute_code => l_attribute_rec.attribute_code,
6581 p_attribute_pk_tbl => l_attribute_pk_tbl);
6582 end loop;
6583 end if;
6584 
6585 -- Add LOV Region used by all region items in this region
6586 -- to the list of regions to be downloaded
6587 for l_region_rec in l_get_ri_lov_regions_csr (
6588 l_region_pk_tbl(l_index).region_appl_id,
6589 l_region_pk_tbl(l_index).region_code) LOOP
6590 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6591 p_return_status => l_return_status,
6592 p_region_application_id =>
6593 l_region_rec.lov_region_application_id,
6594 p_region_code => l_region_rec.lov_region_code,
6595 p_region_pk_tbl => l_region_pk_tbl);
6596 end loop;
6597 
6598 -- Add LOV Region used by all object attributes in the object
6599 -- referenced by this region to the list of regions to be downloaded
6600 for l_region_rec in l_get_oa_lov_regions_csr (
6601 l_region_pk_tbl(l_index).region_appl_id,
6602 l_region_pk_tbl(l_index).region_code) LOOP
6603 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6604 p_return_status => l_return_status,
6605 p_region_application_id =>
6606 l_region_rec.lov_region_application_id,
6607 p_region_code => l_region_rec.lov_region_code,
6608 p_region_pk_tbl => l_region_pk_tbl);
6609 end loop;
6610 
6611 -- Add LOV Region used by all attributes referenced by any
6612 -- region item to the list of regions to be downloaded
6613 for l_region_rec in l_get_attr_lov_regions_csr (
6614 l_region_pk_tbl(l_index).region_appl_id,
6615 l_region_pk_tbl(l_index).region_code) LOOP
6616 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6617 p_return_status => l_return_status,
6618 p_region_application_id =>
6619 l_region_rec.lov_region_application_id,
6620 p_region_code => l_region_rec.lov_region_code,
6621 p_region_pk_tbl => l_region_pk_tbl);
6622 end loop;
6623 
6624 for l_region_attr_rec in l_get_lov_region_items_csr(
6625 l_region_pk_tbl(l_index).region_appl_id,
6626 l_region_pk_tbl(l_index).region_code) LOOP
6627 for l_region_rec in l_get_relation_lov_regions_csr (
6628 l_region_attr_rec.region_application_id,
6629 l_region_attr_rec.region_code,
6630 l_region_attr_rec.attribute_application_id,
6631 l_region_attr_rec.attribute_code) loop
6632 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6633 p_return_status => l_return_status,
6634 p_region_application_id =>
6635 l_region_rec.lov_region_appl_id,
6636 p_region_code => l_region_rec.lov_region_code,
6637 p_region_pk_tbl => l_region_pk_tbl);
6638 end loop;
6639 end loop;
6640 
6641 -- Add Nested Region used by all region items in this region
6642 -- to the list of regions to be downloaded
6643 AK_REGION_PVT.ADD_NESTED_REG_TO_REG_PK (
6644 p_region_application_id =>
6645 l_region_pk_tbl(l_index).region_appl_id,
6646 p_region_code => l_region_pk_tbl(l_index).region_code,
6647 p_region_pk_tbl => l_region_pk_tbl);
6648 
6649 
6650 end if; /* if p_get_object_flag = 'Y' */
6651 
6652 -- Ready to download the next region in the list
6653 l_index := l_region_pk_tbl.NEXT(l_index);
6654 end loop;
6655 
6656 -- set l_index to the last index number in the region table
6657 l_index := l_region_pk_tbl.LAST;
6658 
6659 --
6660 -- If the get object flag is 'Y', call download_object to retrieve
6661 -- all objects and attributes referenced by any of the selected regions.
6662 if (p_get_object_flag = 'Y') then
6663 if (l_object_pk_tbl.count > 0)  then
6664 AK_OBJECT2_PVT.DOWNLOAD_OBJECT (
6665 p_validation_level => p_validation_level,
6666 p_api_version_number => 1.0,
6667 p_return_status => l_return_status,
6668 p_object_pk_tbl => l_object_pk_tbl,
6669 p_attribute_pk_tbl => l_attribute_pk_tbl,
6670 p_nls_language => p_nls_language,
6671 p_get_region_flag => 'N'
6672 );
6673 
6674 if (l_return_status = FND_API.G_RET_STS_ERROR) or
6675 (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6676 -- dbms_output.put_line(l_api_name || ' Error downloading objects');
6677 raise FND_API.G_EXC_ERROR;
6678 end if;
6679 end if;
6680 end if;
6681 
6682 if (AK_DOWNLOAD_GRP.G_DOWNLOAD_REG = 'Y') then
6683 -- Write details for each selected region, including its items, to a
6684 -- buffer to be passed back to the calling procedure.
6685 l_index := l_region_pk_tbl.FIRST;
6686 
6687 while (l_index is not null) loop
6688 --
6689 -- Write region information from the database
6690 --
6691 --dbms_output.put_line('writing region #'||to_char(l_index) || ':' ||
6692 --                      l_region_pk_tbl(l_index).region_code);
6693 
6694 if ( (l_region_pk_tbl(l_index).region_appl_id <> FND_API.G_MISS_NUM) and
6695 (l_region_pk_tbl(l_index).region_appl_id is not null) and
6696 (l_region_pk_tbl(l_index).region_code <> FND_API.G_MISS_CHAR) and
6697 (l_region_pk_tbl(l_index).region_code is not null) ) then
6698 WRITE_TO_BUFFER(
6699 p_validation_level => p_validation_level,
6700 p_return_status => l_return_status,
6701 p_region_application_id => l_region_pk_tbl(l_index).region_appl_id,
6702 p_region_code => l_region_pk_tbl(l_index).region_code,
6703 p_nls_language => p_nls_language
6704 );
6705 end if;
6706 
6707 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
6708 (l_return_status = FND_API.G_RET_STS_ERROR) then
6709 RAISE FND_API.G_EXC_ERROR;
6710 end if;
6711 
6712 -- Ready to download the next region in the list
6713 l_index := l_region_pk_tbl.NEXT(l_index);
6714 end loop;
6715 end if; /*G_DOWNLOAD_REG*/
6716 
6717 p_region_pk_tbl := l_region_pk_tbl;
6718 p_return_status := FND_API.G_RET_STS_SUCCESS;
6719 
6720 EXCEPTION
6721 WHEN VALUE_ERROR THEN
6722 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6723 FND_MESSAGE.SET_NAME('AK','AK_REGION_PK_VALUE_ERROR');
6724 FND_MSG_PUB.Add;
6725 end if;
6726 --dbms_output.put_line('Value error occurred - check your region list.');
6727 p_return_status := FND_API.G_RET_STS_ERROR;
6728 WHEN FND_API.G_EXC_ERROR THEN
6729 p_return_status := FND_API.G_RET_STS_ERROR;
6730 WHEN OTHERS THEN
6731 --dbms_output.put_line(SUBSTR(SQLERRM,1,240));
6732 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6733 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6734 SUBSTR (SQLERRM, 1, 240) );
6735 FND_MSG_PUB.Add;
6736 end DOWNLOAD_REGION;
6737 
6738 --=======================================================
6739 --  Procedure   INSERT_REGION_PK_TABLE
6740 --
6741 --  Usage       Private API for inserting the given region's
6742 --              primary key value into the given object
6743 --              table.
6744 --              This API should only be called by other APIs
6745 --              that are owned by the Core Modules Team (AK).
6746 --
6747 --  Desc        This API inserts the given region's primary
6748 --              key value into a given region table
6749 --              (of type Object_PK_Tbl_Type) only if the
6750 --              primary key does not already exist in the table.
6751 --
6752 --  Results     The API returns the standard p_return_status parameter
6753 --              indicating one of the standard return statuses :
6754 --                  * Unexpected error
6755 --                  * Error
6756 --                  * Success
6757 --  Parameters  p_region_application_id : IN required
6758 --              p_region_code : IN required
6759 --                  Key value of the region to be inserted to the
6760 --                  table.
6761 --              p_region_pk_tbl : IN OUT
6762 --                  Region table to be updated.
6763 --
6764 --  Version     Initial version number  =   1.0
6765 --  History     Current version number  =   1.0
6766 --=======================================================
6767 procedure INSERT_REGION_PK_TABLE (
6768 p_return_status            OUT NOCOPY     VARCHAR2,
6769 p_region_application_id    IN      NUMBER,
6770 p_region_code              IN      VARCHAR2,
6771 p_region_pk_tbl            IN OUT NOCOPY  AK_REGION_PUB.Region_PK_Tbl_Type
6772 ) is
6773 l_api_version_number CONSTANT number := 1.0;
6774 l_api_name           CONSTANT varchar2(30) := 'Insert_Region_PK_Table';
6775 l_index         NUMBER;
6776 begin
6777 --
6778 -- if table is empty, just insert the region primary key into it
6779 --
6780 if (p_region_pk_tbl.count = 0) then
6781 --dbms_output.put_line('Inserted region: ' || p_region_code ||
6782 --                     ' into element #1');
6783 p_region_pk_tbl(1).region_appl_id := p_region_application_id;
6784 p_region_pk_tbl(1).region_code := p_region_code;
6785 return;
6786 end if;
6787 
6788 --
6789 -- otherwise, insert the region to the end of the table if it is
6790 -- not already in the table. If it is already in the table, return
6791 -- without changing the table.
6792 --
6793 for l_index in p_region_pk_tbl.FIRST .. p_region_pk_tbl.LAST loop
6794 if (p_region_pk_tbl.exists(l_index)) then
6795 if (p_region_pk_tbl(l_index).region_appl_id = p_region_application_id)
6796 and
6797 (p_region_pk_tbl(l_index).region_code = p_region_code) then
6798 return;
6799 end if;
6800 end if;
6801 end loop;
6802 
6803 --dbms_output.put_line('Inserted region: ' || p_region_code ||
6804 --                     ' into element #' || to_char(p_region_pk_tbl.LAST + 1));
6805 l_index := p_region_pk_tbl.LAST + 1;
6806 p_region_pk_tbl(l_index).region_appl_id := p_region_application_id;
6807 p_region_pk_tbl(l_index).region_code := p_region_code;
6808 
6809 
6810 EXCEPTION
6811 WHEN FND_API.G_EXC_ERROR THEN
6812 p_return_status := FND_API.G_RET_STS_ERROR;
6813 WHEN OTHERS THEN
6814 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6815 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6816 SUBSTR (SQLERRM, 1, 240) );
6817 FND_MSG_PUB.Add;
6818 end INSERT_REGION_PK_TABLE;
6819 
6820 /*
6821 --=======================================================
6822 --  Function    GRAPH_EXISTS
6823 --
6824 --  Usage       Private API for checking for the existence of
6825 --              a region graph with the given key values. This
6826 --              API should only be called by other APIs that are
6827 --              owned by the Core Modules Team (AK).
6828 --
6829 --  Desc        This API check to see if a region graph record
6830 --              exists with the given key values.
6831 --
6832 --  Results     The API returns the standard p_return_status parameter
6833 --              indicating one of the standard return statuses :
6834 --                  * Unexpected error
6835 --                  * Error
6836 --                  * Success
6837 --              This function will return TRUE if such an object
6838 --              attribute exists, or FALSE otherwise.
6839 --  Parameters  Region Graph key columns
6840 --
6841 --  Version     Initial version number  =   1.0
6842 --  History     Current version number  =   1.0
6843 --=======================================================
6844 function GRAPH_EXISTS (
6845 p_api_version_number       IN      NUMBER,
6846 p_return_status            OUT NOCOPY     VARCHAR2,
6847 p_region_application_id    IN      NUMBER,
6848 p_region_code              IN      VARCHAR2,
6849 p_graph_number	     IN	     NUMBER
6850 ) return BOOLEAN is
6851 cursor l_check_csr is
6852 select 1
6853 from  AK_REGION_GRAPHS
6854 where region_application_id = p_region_application_id
6855 and   region_code = p_region_code
6856 and   graph_number = p_graph_number;
6857 l_api_version_number CONSTANT number := 1.0;
6858 l_api_name           CONSTANT varchar2(30) := 'Item_Exists';
6859 l_dummy              number;
6860 begin
6861 IF NOT FND_API.Compatible_API_Call (
6862 l_api_version_number, p_api_version_number, l_api_name,
6863 G_PKG_NAME) then
6864 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6865 return FALSE;
6866 END IF;
6867 
6868 open l_check_csr;
6869 fetch l_check_csr into l_dummy;
6870 if (l_check_csr%notfound) then
6871 close l_check_csr;
6872 p_return_status := FND_API.G_RET_STS_SUCCESS;
6873 return FALSE;
6874 else
6875 close l_check_csr;
6876 p_return_status := FND_API.G_RET_STS_SUCCESS;
6877 return TRUE;
6878 end if;
6879 
6880 EXCEPTION
6881 WHEN FND_API.G_EXC_ERROR THEN
6882 p_return_status := FND_API.G_RET_STS_ERROR;
6883 return FALSE;
6884 WHEN OTHERS THEN
6885 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6886 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6887 SUBSTR (SQLERRM, 1, 240) );
6888 FND_MSG_PUB.Add;
6889 return FALSE;
6890 
6891 end GRAPH_EXISTS;
6892 */
6893 
6894 --=======================================================
6895 --  Function    ITEM_EXISTS
6896 --
6897 --  Usage       Private API for checking for the existence of
6898 --              a region item with the given key values. This
6899 --              API should only be called by other APIs that are
6900 --              owned by the Core Modules Team (AK).
6901 --
6902 --  Desc        This API check to see if a region item record
6903 --              exists with the given key values.
6904 --
6905 --  Results     The API returns the standard p_return_status parameter
6906 --              indicating one of the standard return statuses :
6907 --                  * Unexpected error
6908 --                  * Error
6909 --                  * Success
6910 --              This function will return TRUE if such an object
6911 --              attribute exists, or FALSE otherwise.
6912 --  Parameters  Region Item key columns
6913 --
6914 --  Version     Initial version number  =   1.0
6915 --  History     Current version number  =   1.0
6916 --=======================================================
6917 function ITEM_EXISTS (
6918 p_api_version_number       IN      NUMBER,
6919 p_return_status            OUT NOCOPY     VARCHAR2,
6920 p_region_application_id    IN      NUMBER,
6921 p_region_code              IN      VARCHAR2,
6922 p_attribute_application_id IN      NUMBER,
6923 p_attribute_code           IN      VARCHAR2
6924 ) return BOOLEAN is
6925 cursor l_check_csr is
6926 select 1
6927 from  AK_REGION_ITEMS
6928 where region_application_id = p_region_application_id
6929 and   region_code = p_region_code
6930 and   attribute_application_id = p_attribute_application_id
6931 and   attribute_code = p_attribute_code;
6932 l_api_version_number CONSTANT number := 1.0;
6933 l_api_name           CONSTANT varchar2(30) := 'Item_Exists';
6934 l_dummy              number;
6935 begin
6936 IF NOT FND_API.Compatible_API_Call (
6937 l_api_version_number, p_api_version_number, l_api_name,
6938 G_PKG_NAME) then
6939 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6940 return FALSE;
6941 END IF;
6942 
6943 open l_check_csr;
6944 fetch l_check_csr into l_dummy;
6945 if (l_check_csr%notfound) then
6946 close l_check_csr;
6947 p_return_status := FND_API.G_RET_STS_SUCCESS;
6948 return FALSE;
6949 else
6950 close l_check_csr;
6951 p_return_status := FND_API.G_RET_STS_SUCCESS;
6952 return TRUE;
6953 end if;
6954 
6955 EXCEPTION
6956 WHEN FND_API.G_EXC_ERROR THEN
6957 p_return_status := FND_API.G_RET_STS_ERROR;
6958 return FALSE;
6959 WHEN OTHERS THEN
6960 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6961 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6962 SUBSTR (SQLERRM, 1, 240) );
6963 FND_MSG_PUB.Add;
6964 return FALSE;
6965 
6966 end ITEM_EXISTS;
6967 
6968 --=======================================================
6969 --  Function    REGION_EXISTS
6970 --
6971 --  Usage       Private API for checking for the existence of
6972 --              a region with the given key values. This
6973 --              API should only be called by other APIs that are
6974 --              owned by the Core Modules Team (AK).
6975 --
6976 --  Desc        This API check to see if a region record
6977 --              exists with the given key values.
6978 --
6979 --  Results     The API returns the standard p_return_status parameter
6980 --              indicating one of the standard return statuses :
6981 --                  * Unexpected error
6982 --                  * Error
6983 --                  * Success
6984 --              This function will return TRUE if such an object
6985 --              attribute exists, or FALSE otherwise.
6986 --  Parameters  Region key columns
6987 --
6988 --  Version     Initial version number  =   1.0
6989 --  History     Current version number  =   1.0
6990 --=======================================================
6991 function REGION_EXISTS (
6992 p_api_version_number       IN      NUMBER,
6993 p_return_status            OUT NOCOPY     VARCHAR2,
6994 p_region_application_id    IN      NUMBER,
6995 p_region_code              IN      VARCHAR2
6996 ) return BOOLEAN is
6997 cursor l_check_region_csr is
6998 select 1
6999 from  AK_REGIONS
7000 where region_application_id = p_region_application_id
7001 and   region_code = p_region_code;
7002 l_api_version_number CONSTANT number := 1.0;
7003 l_api_name           CONSTANT varchar2(30) := 'Region_Exists';
7004 l_dummy              number;
7005 begin
7006 IF NOT FND_API.Compatible_API_Call (
7007 l_api_version_number, p_api_version_number, l_api_name,
7008 G_PKG_NAME) then
7009 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7010 return FALSE;
7011 END IF;
7012 
7013 open l_check_region_csr;
7014 fetch l_check_region_csr into l_dummy;
7015 if (l_check_region_csr%notfound) then
7016 close l_check_region_csr;
7017 p_return_status := FND_API.G_RET_STS_SUCCESS;
7018 return FALSE;
7019 else
7020 close l_check_region_csr;
7021 p_return_status := FND_API.G_RET_STS_SUCCESS;
7022 return TRUE;
7023 end if;
7024 
7025 EXCEPTION
7026 WHEN FND_API.G_EXC_ERROR THEN
7027 p_return_status := FND_API.G_RET_STS_ERROR;
7028 return FALSE;
7029 WHEN OTHERS THEN
7030 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7031 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
7032 SUBSTR (SQLERRM, 1, 240) );
7033 FND_MSG_PUB.Add;
7034 return FALSE;
7035 end REGION_EXISTS;
7036 
7037 /*
7038 --=======================================================
7039 --  Procedure   UPDATE_GRAPH
7040 --
7041 --  Usage       Private API for updating a region graph.
7042 --              This API should only be called by other APIs
7043 --              that are owned by the Core Modules Team (AK).
7044 --
7045 --  Desc        This API updates a region graph using the given info
7046 --
7047 --  Results     The API returns the standard p_return_status parameter
7048 --              indicating one of the standard return statuses :
7049 --                  * Unexpected error
7050 --                  * Error
7051 --                  * Success
7052 --  Parameters  Region Graph columns
7053 --              p_loader_timestamp : IN optional
7054 --                  If a timestamp is passed, the API will update the
7055 --                  record using this timestamp. Only the upload API
7056 --                  should call with this parameter loaded.
7057 --
7058 --  Version     Initial version number  =   1.0
7059 --  History     Current version number  =   1.0
7060 --=======================================================
7061 procedure UPDATE_GRAPH (
7062 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
7063 p_api_version_number       IN      NUMBER,
7064 p_init_msg_tbl             IN      BOOLEAN := FALSE,
7065 p_msg_count                OUT NOCOPY     NUMBER,
7066 p_msg_data                 OUT NOCOPY     VARCHAR2,
7067 p_return_status            OUT NOCOPY     VARCHAR2,
7068 p_region_application_id    IN      NUMBER,
7069 p_region_code              IN      VARCHAR2,
7070 p_graph_number	     IN      NUMBER,
7071 p_graph_style		     IN      NUMBER := FND_API.G_MISS_NUM,
7072 p_display_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7073 p_depth_radius	     IN      NUMBER := FND_API.G_MISS_NUM,
7074 p_graph_title		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7075 p_y_axis_label	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7076 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
7077 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
7078 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
7079 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
7080 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
7081 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
7082 p_pass                     IN      NUMBER,
7083 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
7084 ) is
7085 cursor l_get_row_csr is
7086 select *
7087 from  AK_REGION_GRAPHS
7088 where REGION_APPLICATION_ID = p_region_application_id
7089 and   REGION_CODE = p_region_code
7090 and   GRAPH_NUMBER = p_graph_number
7091 for update of GRAPH_STYLE;
7092 cursor l_get_tl_row_csr (lang_parm varchar2) is
7093 select *
7094 from  AK_REGION_GRAPHS_TL
7095 where REGION_APPLICATION_ID = p_region_application_id
7096 and   REGION_CODE = p_region_code
7097 and   GRAPH_NUMBER = p_graph_number
7098 and   LANGUAGE = lang_parm
7099 for update of GRAPH_TITLE;
7100 l_api_version_number     CONSTANT number := 1.0;
7101 l_api_name               CONSTANT varchar2(30) := 'Update_Graph';
7102 l_created_by             number;
7103 l_creation_date          date;
7104 l_graphs_rec              ak_region_graphs%ROWTYPE;
7105 l_graphs_tl_rec           ak_region_graphs_tl%ROWTYPE;
7106 l_error                  boolean;
7107 l_lang                   varchar2(30);
7108 l_last_update_date       date;
7109 l_last_update_login      number;
7110 l_last_updated_by        number;
7111 l_return_status          varchar2(1);
7112 l_submit                                      varchar2(1) := 'N';
7113 l_encrypt                                     varchar2(1) := 'N';
7114 l_admin_customizable	 			varchar2(1) := 'Y';
7115 begin
7116 IF NOT FND_API.Compatible_API_Call (
7117 l_api_version_number, p_api_version_number, l_api_name,
7118 G_PKG_NAME) then
7119 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7120 return;
7121 END IF;
7122 
7123 -- Initialize the message table if requested.
7124 
7125 if p_init_msg_tbl then
7126 FND_MSG_PUB.initialize;
7127 end if;
7128 
7129 savepoint start_update_graph;
7130 
7131 select userenv('LANG') into l_lang
7132 from dual;
7133 
7134 --** retrieve ak_region_graphs row if it exists **
7135 open l_get_row_csr;
7136 fetch l_get_row_csr into l_graphs_rec;
7137 if (l_get_row_csr%notfound) then
7138 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7139 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
7140 FND_MSG_PUB.Add;
7141 end if;
7142 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
7143 close l_get_row_csr;
7144 raise FND_API.G_EXC_ERROR;
7145 end if;
7146 close l_get_row_csr;
7147 
7148 --** retrieve ak_region_graphss_tl row if it exists **
7149 open l_get_tl_row_csr(l_lang);
7150 fetch l_get_tl_row_csr into l_graphs_tl_rec;
7151 if (l_get_tl_row_csr%notfound) then
7152 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7153 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
7154 FND_MSG_PUB.Add;
7155 end if;
7156 -- dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
7157 close l_get_tl_row_csr;
7158 raise FND_API.G_EXC_ERROR;
7159 end if;
7160 close l_get_tl_row_csr;
7161 
7162 --
7163 -- validate table columns passed in
7164 --
7165 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
7166 if not VALIDATE_GRAPH (
7167 p_validation_level => p_validation_level,
7168 p_api_version_number => 1.0,
7169 p_return_status => l_return_status,
7170 p_region_application_id => p_region_application_id,
7171 p_region_code => p_region_code,
7172 p_graph_number => p_graph_number,
7173 p_graph_style => p_graph_style,
7174 p_display_flag => p_display_flag,
7175 p_depth_radius => p_depth_radius,
7176 p_graph_title => p_graph_title,
7177 p_y_axis_label => p_y_axis_label,
7178 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
7179 p_pass => p_pass
7180 ) then
7181 --dbms_output.put_line(l_api_name || ' validation failed');
7182 -- Do not raise an error if it's the first pass
7183 if (p_pass = 1) then
7184 p_copy_redo_flag := TRUE;
7185 else
7186 raise FND_API.G_EXC_ERROR;
7187 end if;
7188 end if;
7189 end if;
7190 
7191 --** Load record to be updated to the database **
7192 --** - first load nullable columns **
7193 
7194 if (p_display_flag <> FND_API.G_MISS_CHAR) or
7195 (p_display_flag is null) then
7196 l_graphs_rec.display_flag := p_display_flag;
7197 end if;
7198 
7199 if (p_depth_radius <> FND_API.G_MISS_NUM) or
7200 (p_depth_radius is null) then
7201 l_graphs_rec.depth_radius := p_depth_radius;
7202 end if;
7203 
7204 if (p_graph_title <> FND_API.G_MISS_CHAR) or
7205 (p_graph_title is null) then
7206 l_graphs_tl_rec.graph_title := p_graph_title;
7207 end if;
7208 
7209 if (p_y_axis_label <> FND_API.G_MISS_CHAR) or
7210 (p_y_axis_label is null) then
7211 l_graphs_tl_rec.y_axis_label := p_y_axis_label;
7212 end if;
7213 
7214 --** - next, load non-null columns **
7215 
7216 if (p_graph_style <> FND_API.G_MISS_NUM) then
7217 l_graphs_rec.graph_style := p_graph_style;
7218 end if;
7219 
7220 -- Set WHO columns
7221 AK_UPLOAD_GRP.G_UPLOAD_DATE := p_last_update_date;
7222 AK_ON_OBJECTS_PVT.SET_WHO (
7223 p_return_status => l_return_status,
7224 p_loader_timestamp => p_loader_timestamp,
7225 p_created_by => l_created_by,
7226 p_creation_date => l_creation_date,
7227 p_last_updated_by => l_last_updated_by,
7228 p_last_update_date => l_last_update_date,
7229 p_last_update_login => l_last_update_login);
7230 
7231   if (AK_UPLOAD_GRP.G_NON_SEED_DATA) then
7232         l_created_by := p_created_by;
7233         l_last_updated_by := p_last_updated_by;
7234         l_last_update_login := p_last_update_login;
7235   end if;
7236 
7237 update AK_REGION_GRAPHS set
7238 GRAPH_STYLE = l_graphs_rec.graph_style,
7239 DISPLAY_FLAG = l_graphs_rec.display_flag,
7240 LAST_UPDATE_DATE = l_last_update_date,
7241 LAST_UPDATED_BY = l_last_updated_by,
7242 LAST_UPDATE_LOGIN = l_last_update_login
7243 where REGION_APPLICATION_ID = p_region_application_id
7244 and   REGION_CODE = p_region_code
7245 and   GRAPH_NUMBER = p_graph_number;
7246 if (sql%notfound) then
7247 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7248 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATE_FAILED');
7249 FND_MSG_PUB.Add;
7250 end if;
7251 -- dbms_output.put_line(l_api_name || 'Row does not exist during update');
7252 raise FND_API.G_EXC_ERROR;
7253 end if;
7254 
7255 update AK_REGION_GRAPHS_TL set
7256 GRAPH_TITLE = l_graphs_tl_rec.graph_title,
7257 Y_AXIS_LABEL = l_graphs_tl_rec.y_axis_label,
7258 LAST_UPDATED_BY = l_last_updated_by,
7259 LAST_UPDATE_DATE = l_last_update_date,
7260 LAST_UPDATE_LOGIN = l_last_update_login,
7261 SOURCE_LANG = l_lang
7262 where REGION_APPLICATION_ID = p_region_application_id
7263 and   REGION_CODE = p_region_code
7264 and   GRAPH_NUMBER = p_graph_number
7265 and   l_lang in (LANGUAGE, SOURCE_LANG);
7266 if (sql%notfound) then
7267 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7268 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATE_FAILED');
7269 FND_MSG_PUB.Add;
7270 end if;
7271 --dbms_output.put_line(l_api_name || 'TL Row does not exist during update');
7272 raise FND_API.G_EXC_ERROR;
7273 end if;
7274 
7275 --  ** commit the update **
7276 commit;
7277 
7278 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
7279 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATED');
7280 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7281 ' ' || p_region_code ||
7282 ' ' || p_graph_number);
7283 FND_MSG_PUB.Add;
7284 end if;
7285 
7286 p_return_status := FND_API.G_RET_STS_SUCCESS;
7287 
7288 FND_MSG_PUB.Count_And_Get (
7289 p_count => p_msg_count,
7290 p_data => p_msg_data);
7291 
7292 EXCEPTION
7293 WHEN VALUE_ERROR THEN
7294 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7295 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_VALUE_ERROR');
7296 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7297 ' ' || p_region_code ||
7298 ' ' || p_graph_number);
7299 FND_MSG_PUB.Add;
7300 end if;
7301 rollback to start_update_graph;
7302 p_return_status := FND_API.G_RET_STS_ERROR;
7303 FND_MSG_PUB.Count_And_Get (
7304 p_count => p_msg_count,
7305 p_data => p_msg_data);
7306 WHEN FND_API.G_EXC_ERROR THEN
7307 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7308 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_UPDATED');
7309 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7310 ' ' || p_region_code ||
7311 ' ' || p_graph_number);
7312 FND_MSG_PUB.Add;
7313 end if;
7314 p_return_status := FND_API.G_RET_STS_ERROR;
7315 rollback to start_update_graph;
7316 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
7317 SUBSTR (SQLERRM, 1, 240) );
7318 FND_MSG_PUB.Add;
7319 FND_MSG_PUB.Count_And_Get (
7320 p_count => p_msg_count,
7321 p_data => p_msg_data);
7322 end UPDATE_GRAPH;
7323 */
7324 
7325 --=======================================================
7326 --  Procedure   UPDATE_ITEM
7327 --
7328 --  Usage       Private API for updating a region item.
7329 --              This API should only be called by other APIs
7330 --              that are owned by the Core Modules Team (AK).
7331 --
7332 --  Desc        This API updates a region item using the given info
7333 --
7334 --  Results     The API returns the standard p_return_status parameter
7335 --              indicating one of the standard return statuses :
7336 --                  * Unexpected error
7337 --                  * Error
7338 --                  * Success
7339 --  Parameters  Region Item columns
7340 --              p_loader_timestamp : IN optional
7341 --                  If a timestamp is passed, the API will update the
7342 --                  record using this timestamp. Only the upload API
7343 --                  should call with this parameter loaded.
7344 --
7345 --  Version     Initial version number  =   1.0
7346 --  History     Current version number  =   1.0
7347 --=======================================================
7348 procedure UPDATE_ITEM (
7349 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
7350 p_api_version_number       IN      NUMBER,
7351 p_init_msg_tbl             IN      BOOLEAN := FALSE,
7352 p_msg_count                OUT NOCOPY     NUMBER,
7353 p_msg_data                 OUT NOCOPY     VARCHAR2,
7354 p_return_status            OUT NOCOPY     VARCHAR2,
7355 p_region_application_id    IN      NUMBER,
7356 p_region_code              IN      VARCHAR2,
7357 p_attribute_application_id IN      NUMBER,
7358 p_attribute_code           IN      VARCHAR2,
7359 p_display_sequence         IN      NUMBER := FND_API.G_MISS_NUM,
7360 p_node_display_flag        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7361 p_node_query_flag          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7362 p_attribute_label_length   IN      NUMBER := FND_API.G_MISS_NUM,
7363 p_display_value_length     IN      NUMBER := FND_API.G_MISS_NUM,
7364 p_bold                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7365 p_italic                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7366 p_vertical_alignment       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7367 p_horizontal_alignment     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7368 p_item_style               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7369 p_object_attribute_flag    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7370 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7371 p_update_flag              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7372 p_required_flag            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7373 p_security_code            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7374 p_default_value_varchar2   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7375 p_default_value_number     IN      NUMBER := FND_API.G_MISS_NUM,
7376 p_default_value_date       IN      DATE := FND_API.G_MISS_DATE,
7377 p_lov_region_application_id IN     NUMBER := FND_API.G_MISS_NUM,
7378 p_lov_region_code          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7379 p_lov_foreign_key_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7380 p_lov_attribute_application_id IN  NUMBER := FND_API.G_MISS_NUM,
7381 p_lov_attribute_code       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7382 p_lov_default_flag         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7383 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
7384 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
7385 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
7386 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
7387 p_order_sequence           IN      NUMBER := FND_API.G_MISS_NUM,
7388 p_order_direction          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7389 p_display_height			 IN		 NUMBER := FND_API.G_MISS_NUM,
7390 p_submit					 IN		 VARCHAR2,
7391 p_encrypt					 IN		 VARCHAR2,
7392 p_css_class_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7393 p_view_usage_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7394 p_view_attribute_name		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7395 p_nested_region_appl_id	 IN		 NUMBER := FND_API.G_MISS_NUM,
7396 p_nested_region_code		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7397 p_url						 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7398 p_poplist_viewobject		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7399 p_poplist_display_attr	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7400 p_poplist_value_attr		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7401 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7402 p_item_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7403 p_css_label_class_name	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7404 p_menu_name		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7405 p_flexfield_name	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7406 p_flexfield_application_id IN	     NUMBER   := FND_API.G_MISS_NUM,
7407 p_tabular_function_code    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7408 p_tip_type                 IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7409 p_tip_message_name         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7410 p_tip_message_application_id   IN      NUMBER   := FND_API.G_MISS_NUM,
7411 p_flex_segment_list        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7412 p_entity_id                IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7413 p_anchor                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7414 p_poplist_view_usage_name  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7415 p_user_customizable	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7416 p_sortby_view_attribute_name   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7417 p_admin_customizable		IN	VARCHAR2,
7418 p_invoke_function_name	IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7419 p_expansion		     IN      NUMBER   := FND_API.G_MISS_NUM,
7420 p_als_max_length	     IN      NUMBER   := FND_API.G_MISS_NUM,
7421 p_initial_sort_sequence    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7422 p_customization_application_id IN  NUMBER   := FND_API.G_MISS_NUM,
7423 p_customization_code	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7424 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7425 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7426 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7427 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7428 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7429 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7430 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7431 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7432 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7433 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7434 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7435 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7436 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7437 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7438 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7439 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7440 p_attribute_label_long     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7441 p_attribute_label_short    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7442 p_description				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7443 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
7444 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
7445 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
7446 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
7447 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
7448 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
7449 p_pass                     IN      NUMBER,
7450 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
7451 ) is
7452 cursor l_get_row_csr is
7453 select *
7454 from  AK_REGION_ITEMS
7455 where REGION_APPLICATION_ID = p_region_application_id
7456 and   REGION_CODE = p_region_code
7457 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
7458 and   ATTRIBUTE_CODE = p_attribute_code
7459 for   update of DISPLAY_SEQUENCE;
7460 cursor l_get_tl_row_csr (lang_parm varchar2) is
7461 select *
7462 from  AK_REGION_ITEMS_TL
7463 where REGION_APPLICATION_ID = p_region_application_id
7464 and   REGION_CODE = p_region_code
7465 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
7466 and   ATTRIBUTE_CODE = p_attribute_code
7467 and   LANGUAGE = lang_parm
7468 for update of ATTRIBUTE_LABEL_LONG;
7469 l_api_version_number     CONSTANT number := 1.0;
7470 l_api_name               CONSTANT varchar2(30) := 'Update_Item';
7471 l_created_by             number;
7472 l_creation_date          date;
7473 l_items_rec              ak_region_items%ROWTYPE;
7474 l_items_tl_rec           ak_region_items_tl%ROWTYPE;
7475 l_error                  boolean;
7476 l_lang                   varchar2(30);
7477 l_last_update_date       date;
7478 l_last_update_login      number;
7479 l_last_updated_by        number;
7480 l_object_attribute_flag  VARCHAR2(1);
7481 l_return_status          varchar2(1);
7482 l_submit					varchar2(1) := 'N';
7483 l_encrypt					varchar2(1) := 'N';
7484 l_admin_customizable				varchar2(1) := 'Y';
7485 l_file_version	number;
7486 l_create_or_update       VARCHAR2(10);
7487 begin
7488 IF NOT FND_API.Compatible_API_Call (
7489 l_api_version_number, p_api_version_number, l_api_name,
7490 G_PKG_NAME) then
7491 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7492 return;
7493 END IF;
7494 
7495 -- Initialize the message table if requested.
7496 
7497 if p_init_msg_tbl then
7498 FND_MSG_PUB.initialize;
7499 end if;
7500 
7501 savepoint start_update_item;
7502 
7503 select userenv('LANG') into l_lang
7504 from dual;
7505 
7506 --** retrieve ak_region_items row if it exists **
7507 open l_get_row_csr;
7508 fetch l_get_row_csr into l_items_rec;
7509 if (l_get_row_csr%notfound) then
7510 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7511 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
7512 FND_MSG_PUB.Add;
7513 end if;
7514 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
7515 close l_get_row_csr;
7516 raise FND_API.G_EXC_ERROR;
7517 end if;
7518 close l_get_row_csr;
7519 
7520 --** retrieve ak_region_items_tl row if it exists **
7521 open l_get_tl_row_csr(l_lang);
7522 fetch l_get_tl_row_csr into l_items_tl_rec;
7523 if (l_get_tl_row_csr%notfound) then
7524 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7525 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
7526 FND_MSG_PUB.Add;
7527 end if;
7528 -- dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
7529 close l_get_tl_row_csr;
7530 raise FND_API.G_EXC_ERROR;
7531 end if;
7532 close l_get_tl_row_csr;
7533 
7534 --
7535 -- If the object_attribute_flag is missing, pass the value in the
7536 -- database to the validate_item procedure. This is done such that
7537 -- the validate_item procedure can check the validity of attribute
7538 -- key fields against ak_attributes or ak_object_attributes.
7539 --
7540 if (p_object_attribute_flag = FND_API.G_MISS_CHAR) then
7541 l_object_attribute_flag := l_items_rec.object_attribute_flag;
7542 else
7543 l_object_attribute_flag := p_object_attribute_flag;
7544 end if;
7545 
7546 if (p_display_sequence IS NOT NULL) and
7547 (p_display_sequence <> FND_API.G_MISS_NUM) then
7548 --** Check the given display sequence number
7549 AK_REGION2_PVT.CHECK_DISPLAY_SEQUENCE (  p_validation_level => p_validation_level,
7550 p_region_code => p_region_code,
7551 p_region_application_id => p_region_application_id,
7552 p_attribute_code => p_attribute_code,
7553 p_attribute_application_id => p_attribute_application_id,
7554 p_display_sequence => p_display_sequence,
7555 p_return_status => l_return_status,
7556 p_msg_count => p_msg_count,
7557 p_msg_data => p_msg_data,
7558 p_pass => p_pass,
7559 p_copy_redo_flag => p_copy_redo_flag);
7560 end if;
7561 
7562 --
7563 -- validate table columns passed in
7564 -- ** Note the special processing for object_attribute_flag **
7565 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
7566 if not AK_REGION_PVT.VALIDATE_ITEM (
7567 p_validation_level => p_validation_level,
7568 p_api_version_number => 1.0,
7569 p_return_status => l_return_status,
7570 p_region_application_id => p_region_application_id,
7571 p_region_code => p_region_code,
7572 p_attribute_application_id => p_attribute_application_id,
7573 p_attribute_code => p_attribute_code,
7574 p_display_sequence => p_display_sequence,
7575 p_node_display_flag => p_node_display_flag,
7576 p_node_query_flag => p_node_query_flag,
7577 p_attribute_label_length => p_attribute_label_length,
7578 p_display_value_length => p_display_value_length,
7579 p_bold => p_bold,
7580 p_italic => p_italic,
7581 p_vertical_alignment => p_vertical_alignment,
7582 p_horizontal_alignment => p_horizontal_alignment,
7583 p_item_style => p_item_style,
7584 p_object_attribute_flag => l_object_attribute_flag,
7585 p_icx_custom_call => p_icx_custom_call,
7586 p_update_flag => p_update_flag,
7587 p_required_flag => p_required_flag,
7588 p_security_code => p_security_code,
7589 p_default_value_varchar2 => p_default_value_varchar2,
7590 p_default_value_number => p_default_value_number,
7591 p_default_value_date => p_default_value_date,
7592 p_nested_region_appl_id => p_nested_region_appl_id,
7593 p_nested_region_code => p_nested_region_code,
7594 p_lov_region_application_id => p_lov_region_application_id,
7595 p_lov_region_code => p_lov_region_code,
7596 p_lov_foreign_key_name => p_lov_foreign_key_name,
7597 p_lov_attribute_application_id => p_lov_attribute_application_id,
7598 p_lov_attribute_code => p_lov_attribute_code,
7599 p_lov_default_flag => p_lov_default_flag,
7600 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
7601 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
7602 p_region_validation_api_pkg => p_region_validation_api_pkg,
7603 p_region_validation_api_proc => p_region_validation_api_proc,
7604 p_order_sequence => p_order_sequence,
7605 p_order_direction => p_order_direction,
7606 p_menu_name => p_menu_name,
7607 p_flexfield_name => p_flexfield_name,
7608 p_flexfield_application_id => p_flexfield_application_id,
7609 p_tabular_function_code    => p_tabular_function_code,
7610 p_tip_type                 => p_tip_type,
7611 p_tip_message_name          => p_tip_message_name,
7612 p_tip_message_application_id  => p_tip_message_application_id ,
7613 p_flex_segment_list        => p_flex_segment_list,
7614 p_entity_id                => p_entity_id,
7615 p_anchor                   => p_anchor,
7616 p_poplist_view_usage_name  => p_poplist_view_usage_name,
7617 p_user_customizable	       => p_user_customizable,
7618 p_sortby_view_attribute_name => p_sortby_view_attribute_name,
7619 p_invoke_function_name	=> p_invoke_function_name,
7620 p_expansion			=> p_expansion,
7621 p_als_max_length		=> p_als_max_length,
7622 p_initial_sort_sequence     => p_initial_sort_sequence,
7623 p_customization_application_id => p_customization_application_id,
7624 p_customization_code => p_customization_application_id,
7625 p_attribute_label_long => p_attribute_label_long,
7626 p_attribute_label_short => p_attribute_label_short,
7627 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
7628 p_pass => p_pass
7629 ) then
7630 --dbms_output.put_line(l_api_name || ' validation failed');
7631 -- Do not raise an error if it's the first pass
7632 if (p_pass = 1) then
7633 p_copy_redo_flag := TRUE;
7634 else
7635 raise FND_API.G_EXC_ERROR;
7636 end if;
7637 end if;
7638 end if;
7639 
7640   -- Do not update if fails validation ie. p_copy_redo_flag = true
7641   if (not p_copy_redo_flag) then
7642 
7643 --** Load record to be updated to the database **
7644 --** - first load nullable columns **
7645 
7646 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) or
7647 (p_icx_custom_call is null) then
7648 l_items_rec.icx_custom_call := p_icx_custom_call;
7649 end if;
7650 
7651 if (p_security_code <> FND_API.G_MISS_CHAR) or
7652 (p_security_code is null) then
7653 l_items_rec.security_code := p_security_code;
7654 end if;
7655 
7656 if (p_default_value_varchar2 <> FND_API.G_MISS_CHAR) or
7657 (p_default_value_varchar2 is null) then
7658 l_items_rec.default_value_varchar2 := p_default_value_varchar2;
7659 end if;
7660 
7661 if (p_default_value_number <> FND_API.G_MISS_NUM) or
7662 (p_default_value_number is null) then
7663 l_items_rec.default_value_number := p_default_value_number;
7664 end if;
7665 
7666 if (p_default_value_date <> FND_API.G_MISS_DATE) or
7667 (p_default_value_date is null) then
7668 l_items_rec.default_value_date := p_default_value_date;
7669 end if;
7670 
7671 if (p_lov_region_application_id <> FND_API.G_MISS_NUM) or
7672 (p_lov_region_application_id is null) then
7673 l_items_rec.lov_region_application_id := p_lov_region_application_id;
7674 end if;
7675 
7676 if (p_lov_region_code <> FND_API.G_MISS_CHAR) or
7677 (p_lov_region_code is null) then
7678 l_items_rec.lov_region_code := p_lov_region_code;
7679 end if;
7680 
7681 if (p_lov_foreign_key_name <> FND_API.G_MISS_CHAR) or
7682 (p_lov_foreign_key_name is null) then
7683 l_items_rec.lov_foreign_key_name := p_lov_foreign_key_name;
7684 end if;
7685 
7686 if (p_lov_attribute_application_id <> FND_API.G_MISS_NUM) or
7687 (p_lov_attribute_application_id is null) then
7688 l_items_rec.lov_attribute_application_id := p_lov_attribute_application_id;
7689 end if;
7690 
7691 if (p_lov_attribute_code <> FND_API.G_MISS_CHAR) or
7692 (p_lov_attribute_code is null) then
7693 l_items_rec.lov_attribute_code := p_lov_attribute_code;
7694 end if;
7695 
7696 if (p_lov_default_flag <> FND_API.G_MISS_CHAR) or
7697 (p_lov_default_flag is null) then
7698 l_items_rec.lov_default_flag := p_lov_default_flag;
7699 end if;
7700 
7701 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) or
7702 (p_region_defaulting_api_pkg is null) then
7703 l_items_rec.region_defaulting_api_pkg := p_region_defaulting_api_pkg;
7704 end if;
7705 
7706 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) or
7707 (p_region_defaulting_api_proc is null) then
7708 l_items_rec.region_defaulting_api_proc := p_region_defaulting_api_proc;
7709 end if;
7710 
7711 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) or
7712 (p_region_validation_api_pkg is null) then
7713 l_items_rec.region_validation_api_pkg := p_region_validation_api_pkg;
7714 end if;
7715 
7716 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) or
7717 (p_region_validation_api_proc is null) then
7718 l_items_rec.region_validation_api_proc := p_region_validation_api_proc;
7719 end if;
7720 
7721 if (p_order_sequence <> FND_API.G_MISS_NUM) or
7722 (p_order_sequence is null) then
7723 l_items_rec.order_sequence := p_order_sequence;
7724 end if;
7725 
7726 if (p_order_direction <> FND_API.G_MISS_CHAR) or
7727 (p_order_direction is null) then
7728 l_items_rec.order_direction := p_order_direction;
7729 end if;
7730 
7731 if (p_display_height <> FND_API.G_MISS_NUM) then
7732 l_items_rec.display_height := p_display_height;
7733 end if;
7734 
7735 if (p_css_class_name <> FND_API.G_MISS_CHAR) or
7736 (p_css_class_name is null) then
7737 l_items_rec.css_class_name := p_css_class_name;
7738 end if;
7739 
7740 if (p_view_usage_name <> FND_API.G_MISS_CHAR) or
7741 (p_view_usage_name is null) then
7742 l_items_rec.view_usage_name := p_view_usage_name;
7743 end if;
7744 
7745 if (p_view_attribute_name <> FND_API.G_MISS_CHAR) or
7746 (p_view_attribute_name is null) then
7747 l_items_rec.view_attribute_name := p_view_attribute_name;
7748 end if;
7749 
7750 if (p_nested_region_appl_id <> FND_API.G_MISS_NUM) or
7751 (p_nested_region_appl_id is null) then
7752 l_items_rec.nested_region_application_id := p_nested_region_appl_id;
7753 end if;
7754 
7755 if (p_nested_region_code <> FND_API.G_MISS_CHAR) or
7756 (p_nested_region_code is null) then
7757 l_items_rec.nested_region_code := p_nested_region_code;
7758 end if;
7759 
7760 if (p_url <> FND_API.G_MISS_CHAR) or
7761 (p_url is null) then
7762 l_items_rec.url := p_url;
7763 end if;
7764 
7765 if (p_poplist_viewobject <> FND_API.G_MISS_CHAR) or
7766 (p_poplist_viewobject is null) then
7767 l_items_rec.poplist_viewobject := p_poplist_viewobject;
7768 end if;
7769 
7770 if (p_poplist_display_attr <> FND_API.G_MISS_CHAR) or
7771 (p_poplist_display_attr is null) then
7772 l_items_rec.poplist_display_attribute := p_poplist_display_attr;
7773 end if;
7774 
7775 if (p_poplist_value_attr <> FND_API.G_MISS_CHAR) or
7776 (p_poplist_value_attr is null) then
7777 l_items_rec.poplist_value_attribute := p_poplist_value_attr;
7778 end if;
7779 
7780 if (p_image_file_name <> FND_API.G_MISS_CHAR) or
7781 (p_image_file_name is null) then
7782 l_items_rec.image_file_name := p_image_file_name;
7783 end if;
7784 
7785 if (p_item_name <> FND_API.G_MISS_CHAR) or
7786 (p_item_name is null) then
7787 l_items_rec.item_name := p_item_name;
7788 end if;
7789 
7790 if (p_css_label_class_name <> FND_API.G_MISS_CHAR) or
7791 (p_css_label_class_name is null) then
7792 l_items_rec.css_label_class_name := p_css_label_class_name;
7793 end if;
7794 
7795 if (p_menu_name <> FND_API.G_MISS_CHAR) or
7796 (p_menu_name is null) then
7797 l_items_rec.menu_name := p_menu_name;
7798 end if;
7799 
7800 if (p_flexfield_name <> FND_API.G_MISS_CHAR) or
7801 (p_flexfield_name is null) then
7802 l_items_rec.flexfield_name := p_flexfield_name;
7803 end if;
7804 
7805 if (p_flexfield_application_id <> FND_API.G_MISS_NUM) or
7806 (p_flexfield_application_id is null) then
7807 l_items_rec.flexfield_application_id := p_flexfield_application_id;
7808 end if;
7809 
7810 if (p_tabular_function_code <> FND_API.G_MISS_CHAR) or
7811 (p_tabular_function_code is null) then
7812 l_items_rec.tabular_function_code := p_tabular_function_code;
7813 end if;
7814 
7815 if (p_tip_type <> FND_API.G_MISS_CHAR) or
7816 (p_tip_type is null) then
7817 l_items_rec.tip_type := p_tip_type;
7818 end if;
7819 
7820 if (p_tip_message_name <> FND_API.G_MISS_CHAR) or
7821 (p_tip_message_name is null) then
7822 l_items_rec.tip_message_name := p_tip_message_name;
7823 end if;
7824 
7825 if (p_tip_message_application_id <> FND_API.G_MISS_NUM) or
7826 (p_tip_message_application_id is null) then
7827 l_items_rec.tip_message_application_id := p_tip_message_application_id;
7828 end if;
7829 
7830 if (p_flex_segment_list <> FND_API.G_MISS_CHAR) or
7831 (p_flex_segment_list is null) then
7832 l_items_rec.flex_segment_list := p_flex_segment_list;
7833 end if;
7834 
7835 if (p_entity_id <> FND_API.G_MISS_CHAR) or
7836 (p_entity_id is null) then
7837 l_items_rec.entity_id := p_entity_id;
7838 end if;
7839 
7840 if (p_anchor <> FND_API.G_MISS_CHAR or p_anchor is null) then
7841 l_items_rec.anchor := p_anchor;
7842 end if;
7843 
7844 if (p_poplist_view_usage_name <> FND_API.G_MISS_CHAR) or
7845 (p_poplist_view_usage_name is null) then
7846 l_items_rec.poplist_view_usage_name := p_poplist_view_usage_name;
7847 end if;
7848 
7849 if (p_user_customizable <> FND_API.G_MISS_CHAR) or
7850 (p_user_customizable is null) then
7851 l_items_rec.user_customizable := p_user_customizable;
7852 end if;
7853 
7854 if (p_sortby_view_attribute_name <> FND_API.G_MISS_CHAR) or
7855 (p_sortby_view_attribute_name is null) then
7856 l_items_rec.sortby_view_attribute_name := p_sortby_view_attribute_name;
7857 end if;
7858 
7859 if (p_invoke_function_name <> FND_API.G_MISS_CHAR) or
7860 (p_invoke_function_name is null) then
7861 l_items_rec.invoke_function_name := p_invoke_function_name;
7862 end if;
7863 
7864 if (p_expansion <> FND_API.G_MISS_NUM) or
7865 (p_expansion is null) then
7866 l_items_rec.expansion := p_expansion;
7867 end if;
7868 
7869 if (p_als_max_length <> FND_API.G_MISS_NUM) or
7870 (p_als_max_length is null) then
7871 l_items_rec.als_max_length := p_als_max_length;
7872 end if;
7873 
7874 if (p_initial_sort_sequence <> FND_API.G_MISS_CHAR) or
7875 (p_initial_sort_sequence is null) then
7876 l_items_rec.initial_sort_sequence := p_initial_sort_sequence;
7877 end if;
7878 
7879 if (p_customization_application_id <> FND_API.G_MISS_NUM) or
7880 (p_customization_application_id is null) then
7881 l_items_rec.customization_application_id := p_customization_application_id;
7882 end if;
7883 
7884 if (p_customization_code <> FND_API.G_MISS_CHAR) or
7885 (p_customization_code is null) then
7886 l_items_rec.customization_code := p_customization_code;
7887 end if;
7888 
7889 if (p_attribute_category <> FND_API.G_MISS_CHAR) or
7890 (p_attribute_category is null) then
7891 l_items_rec.attribute_category := p_attribute_category;
7892 end if;
7893 if (p_attribute1 <> FND_API.G_MISS_CHAR) or
7894 (p_attribute1 is null) then
7895 l_items_rec.attribute1 := p_attribute1;
7896 end if;
7897 if (p_attribute2 <> FND_API.G_MISS_CHAR) or
7898 (p_attribute2 is null) then
7899 l_items_rec.attribute2 := p_attribute2;
7900 end if;
7901 if (p_attribute3 <> FND_API.G_MISS_CHAR) or
7902 (p_attribute3 is null) then
7903 l_items_rec.attribute3 := p_attribute3;
7904 end if;
7905 if (p_attribute4 <> FND_API.G_MISS_CHAR) or
7906 (p_attribute4 is null) then
7907 l_items_rec.attribute4 := p_attribute4;
7908 end if;
7909 if (p_attribute5 <> FND_API.G_MISS_CHAR) or
7910 (p_attribute5 is null) then
7911 l_items_rec.attribute5 := p_attribute5;
7912 end if;
7913 if (p_attribute6 <> FND_API.G_MISS_CHAR) or
7914 (p_attribute6 is null) then
7915 l_items_rec.attribute6 := p_attribute6;
7916 end if;
7917 if (p_attribute7 <> FND_API.G_MISS_CHAR) or
7918 (p_attribute7 is null) then
7919 l_items_rec.attribute7 := p_attribute7;
7920 end if;
7921 if (p_attribute8 <> FND_API.G_MISS_CHAR) or
7922 (p_attribute8 is null) then
7923 l_items_rec.attribute8 := p_attribute8;
7924 end if;
7925 if (p_attribute9 <> FND_API.G_MISS_CHAR) or
7926 (p_attribute9 is null) then
7927 l_items_rec.attribute9 := p_attribute9;
7928 end if;
7929 if (p_attribute10 <> FND_API.G_MISS_CHAR) or
7930 (p_attribute10 is null) then
7931 l_items_rec.attribute10 := p_attribute10;
7932 end if;
7933 if (p_attribute11 <> FND_API.G_MISS_CHAR) or
7934 (p_attribute11 is null) then
7935 l_items_rec.attribute11 := p_attribute11;
7936 end if;
7937 if (p_attribute12 <> FND_API.G_MISS_CHAR) or
7938 (p_attribute12 is null) then
7939 l_items_rec.attribute12 := p_attribute12;
7940 end if;
7941 if (p_attribute13 <> FND_API.G_MISS_CHAR) or
7942 (p_attribute13 is null) then
7943 l_items_rec.attribute13 := p_attribute13;
7944 end if;
7945 
7946 if (p_attribute14 <> FND_API.G_MISS_CHAR) or
7947 (p_attribute14 is null) then
7948 l_items_rec.attribute14 := p_attribute14;
7949 end if;
7950 
7951 if (p_attribute15 <> FND_API.G_MISS_CHAR) or
7952 (p_attribute15 is null) then
7953 l_items_rec.attribute15 := p_attribute15;
7954 end if;
7955 
7956 if (p_attribute_label_long <> FND_API.G_MISS_CHAR) or
7957 (p_attribute_label_long is null) then
7958 l_items_tl_rec.attribute_label_long := p_attribute_label_long;
7959 end if;
7960 
7961 if (p_attribute_label_short <> FND_API.G_MISS_CHAR) or
7962 (p_attribute_label_short is null) then
7963 l_items_tl_rec.attribute_label_short := p_attribute_label_short;
7964 end if;
7965 
7966 if (p_description <> FND_API.G_MISS_CHAR) or
7967 (p_description is null) then
7968 l_items_tl_rec.description := p_description;
7969 end if;
7970 
7971 --** - next, load non-null columns **
7972 
7973 if (p_display_sequence<> FND_API.G_MISS_NUM) then
7974 l_items_rec.display_sequence := p_display_sequence;
7975 end if;
7976 if (p_node_display_flag <> FND_API.G_MISS_CHAR) then
7977 l_items_rec.node_display_flag := p_node_display_flag;
7978 end if;
7979 if (p_node_query_flag <> FND_API.G_MISS_CHAR) then
7980 l_items_rec.node_query_flag := p_node_query_flag;
7981 end if;
7982 if (p_attribute_label_length <> FND_API.G_MISS_NUM) then
7983 l_items_rec.attribute_label_length := p_attribute_label_length;
7984 end if;
7985 if (p_display_value_length <> FND_API.G_MISS_NUM) then
7986 l_items_rec.display_value_length := p_display_value_length;
7987 end if;
7988 if (p_bold <> FND_API.G_MISS_CHAR) then
7989 l_items_rec.bold := p_bold;
7990 end if;
7991 if (p_italic <> FND_API.G_MISS_CHAR) then
7992 l_items_rec.italic := p_italic;
7993 end if;
7994 if (p_vertical_alignment <> FND_API.G_MISS_CHAR) then
7995 l_items_rec.vertical_alignment := p_vertical_alignment;
7996 end if;
7997 if (p_horizontal_alignment <> FND_API.G_MISS_CHAR) then
7998 l_items_rec.horizontal_alignment := p_horizontal_alignment;
7999 end if;
8000 if (p_item_style <> FND_API.G_MISS_CHAR) then
8001 l_items_rec.item_style := p_item_style;
8002 end if;
8003 if (p_object_attribute_flag <> FND_API.G_MISS_CHAR) then
8004 l_items_rec.object_attribute_flag := p_object_attribute_flag;
8005 end if;
8006 if (p_update_flag <> FND_API.G_MISS_CHAR) then
8007 l_items_rec.update_flag := p_update_flag;
8008 end if;
8009 --
8010 -- special logic for handling update_flag, bug#2054285
8011 -- set update_flag to 'Y'
8012 -- do not change update_flag to 'Y' if FILE_FORMAT_VERSION > 115.14
8013 --
8014 if ( ( AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER1 or
8015 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER2 or
8016 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER3 or
8017 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER4 or
8018 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER5 or
8019 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER6 or
8020 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER7 or
8021 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER8 or
8022 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER9 or
8023 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER11 or
8024 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER12 ) and
8025 ( p_item_style = 'CHECKBOX' or p_item_style = 'DESCRIPTIVE_FLEX' or
8026 p_item_style = 'KEY_FLEX' or p_item_style = 'FILE' or
8027 p_item_style = 'FORM_PARAMETER_BEAN' or p_item_style = 'RADIO_BUTTON' or
8028 p_item_style  = 'POPLIST' or p_item_style = 'HIDDEN' or
8029 p_item_style = 'TEXT_INPUT' or p_item_style = 'RADIO_GROUP') and
8030 INSTR(p_region_code,'POR') <> 1 ) then
8031 l_items_rec.update_flag := 'Y';
8032 end if;
8033 
8034 
8035 if (p_required_flag <> FND_API.G_MISS_CHAR) then
8036 l_items_rec.required_flag := p_required_flag;
8037 end if;
8038 if (p_submit <> FND_API.G_MISS_CHAR and p_submit is not null) then
8039 l_items_rec.submit := p_submit;
8040 else
8041 l_items_rec.submit := l_submit;
8042 end if;
8043 if (p_encrypt <> FND_API.G_MISS_CHAR and p_encrypt is not null) then
8044 l_items_rec.encrypt := p_encrypt;
8045 else
8046 l_items_rec.encrypt := l_encrypt;
8047 end if;
8048 if (p_admin_customizable <> FND_API.G_MISS_CHAR and p_admin_customizable is not null) then
8049 l_items_rec.admin_customizable := p_admin_customizable;
8050 else
8051 l_items_rec.admin_customizable := l_admin_customizable;
8052 end if;
8053   if (p_created_by <> FND_API.G_MISS_NUM) then
8054     l_created_by := p_created_by;
8055   end if;
8056   if (p_creation_date <> FND_API.G_MISS_DATE) then
8057     l_creation_date := p_creation_date;
8058   end if;
8059   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
8060     l_last_updated_by := p_last_updated_by;
8061   end if;
8062   if (p_last_update_date <> FND_API.G_MISS_DATE) then
8063     l_last_update_date := p_last_update_date;
8064   end if;
8065   if (p_last_update_login <> FND_API.G_MISS_NUM) then
8066     l_last_update_login := p_last_update_login;
8067   end if;
8068 
8069   /* 5452422 - if display_sequence has been raised then force update */
8070   if (p_display_sequence >= 1000000) then
8071 	l_create_or_update := 'FORCE';
8072   else
8073 	l_create_or_update := 'UPDATE';
8074   end if;
8075 
8076   if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
8077        p_loader_timestamp => p_loader_timestamp,
8078        p_created_by => l_created_by,
8079        p_creation_date => l_creation_date,
8080        p_last_updated_by => l_last_updated_by,
8081        p_db_last_updated_by => l_items_rec.last_updated_by,
8082        p_last_update_date => l_last_update_date,
8083        p_db_last_update_date => l_items_rec.last_update_date,
8084        p_last_update_login => l_last_update_login,
8085        p_create_or_update => l_create_or_update) then
8086 
8087 update AK_REGION_ITEMS set
8088 DISPLAY_SEQUENCE = l_items_rec.display_sequence,
8089 NODE_DISPLAY_FLAG = l_items_rec.node_display_flag,
8090 NODE_QUERY_FLAG = l_items_rec.node_query_flag,
8091 ATTRIBUTE_LABEL_LENGTH = l_items_rec.attribute_label_length,
8092 DISPLAY_VALUE_LENGTH = l_items_rec.display_value_length,
8093 BOLD = l_items_rec.bold,
8094 ITALIC = l_items_rec.italic,
8095 VERTICAL_ALIGNMENT = l_items_rec.vertical_alignment,
8096 HORIZONTAL_ALIGNMENT = l_items_rec.horizontal_alignment,
8097 ITEM_STYLE = l_items_rec.item_style,
8098 OBJECT_ATTRIBUTE_FLAG = l_items_rec.object_attribute_flag,
8099 ICX_CUSTOM_CALL = l_items_rec.icx_custom_call,
8100 UPDATE_FLAG = l_items_rec.update_flag,
8101 REQUIRED_FLAG = l_items_rec.required_flag,
8102 SECURITY_CODE = l_items_rec.security_code,
8103 DEFAULT_VALUE_VARCHAR2 = l_items_rec.default_value_varchar2,
8104 DEFAULT_VALUE_NUMBER = l_items_rec.default_value_number,
8105 DEFAULT_VALUE_DATE = l_items_rec.default_value_date,
8106 LOV_REGION_APPLICATION_ID = l_items_rec.lov_region_application_id,
8107 LOV_REGION_CODE = l_items_rec.lov_region_code,
8108 LOV_FOREIGN_KEY_NAME = l_items_rec.lov_foreign_key_name,
8109 LOV_ATTRIBUTE_APPLICATION_ID =
8110 l_items_rec.lov_attribute_application_id,
8111 LOV_ATTRIBUTE_CODE = l_items_rec.lov_attribute_code,
8112 LOV_DEFAULT_FLAG = l_items_rec.lov_default_flag,
8113 REGION_DEFAULTING_API_PKG = l_items_rec.region_defaulting_api_pkg,
8114 REGION_DEFAULTING_API_PROC = l_items_rec.region_defaulting_api_proc,
8115 REGION_VALIDATION_API_PKG = l_items_rec.region_validation_api_pkg,
8116 REGION_VALIDATION_API_PROC = l_items_rec.region_validation_api_proc,
8117 ORDER_SEQUENCE = l_items_rec.order_sequence,
8118 ORDER_DIRECTION = l_items_rec.order_direction,
8119 DISPLAY_HEIGHT = l_items_rec.display_height,
8120 SUBMIT = l_items_rec.submit,
8121 ENCRYPT = l_items_rec.encrypt,
8122 css_class_name = l_items_rec.css_class_name,
8123 VIEW_USAGE_NAME = l_items_rec.view_usage_name,
8124 VIEW_ATTRIBUTE_NAME = l_items_rec.view_attribute_name,
8125 NESTED_REGION_APPLICATION_ID = l_items_rec.nested_region_application_id,
8126 NESTED_REGION_CODE = l_items_rec.nested_region_code,
8127 URL = l_items_rec.url,
8128 POPLIST_VIEWOBJECT = l_items_rec.poplist_viewobject,
8129 POPLIST_DISPLAY_ATTRIBUTE = l_items_rec.poplist_display_attribute,
8130 POPLIST_VALUE_ATTRIBUTE = l_Items_rec.poplist_value_attribute,
8131 IMAGE_FILE_NAME = l_items_rec.image_file_name,
8132 ITEM_NAME = l_items_rec.item_name,
8133 CSS_LABEL_CLASS_NAME = l_items_rec.css_label_class_name,
8134 MENU_NAME = l_items_rec.menu_name,
8135 FLEXFIELD_NAME = l_items_rec.flexfield_name,
8136 FLEXFIELD_APPLICATION_ID = l_items_rec.flexfield_application_id,
8137 TABULAR_FUNCTION_CODE = l_items_rec.tabular_function_code,
8138 TIP_TYPE  = l_items_rec.tip_type,
8139 TIP_MESSAGE_NAME = l_items_rec.tip_message_name,
8140 TIP_MESSAGE_APPLICATION_ID = l_items_rec.tip_message_application_id,
8141 FLEX_SEGMENT_LIST = l_items_rec.flex_segment_list,
8142 ENTITY_ID = l_items_rec.entity_id,
8143 ANCHOR = l_items_rec.anchor,
8144 POPLIST_VIEW_USAGE_NAME = l_items_rec.poplist_view_usage_name,
8145 USER_CUSTOMIZABLE = l_items_rec.user_customizable,
8146 SORTBY_VIEW_ATTRIBUTE_NAME = l_items_rec.sortby_view_attribute_name,
8147 ADMIN_CUSTOMIZABLE = l_items_rec.admin_customizable,
8148 INVOKE_FUNCTION_NAME = l_items_rec.invoke_function_name,
8149 EXPANSION = l_items_rec.expansion,
8150 ALS_MAX_LENGTH = l_items_rec.als_max_length,
8151 INITIAL_SORT_SEQUENCE = l_items_rec.initial_sort_sequence,
8152 CUSTOMIZATION_APPLICATION_ID = l_items_rec.customization_application_id,
8153 CUSTOMIZATION_CODE = l_items_rec.customization_code,
8154 ATTRIBUTE_CATEGORY = l_items_rec.attribute_category,
8155 ATTRIBUTE1 = l_items_rec.attribute1,
8156 ATTRIBUTE2 = l_items_rec.attribute2,
8157 ATTRIBUTE3 = l_items_rec.attribute3,
8158 ATTRIBUTE4 = l_items_rec.attribute4,
8159 ATTRIBUTE5 = l_items_rec.attribute5,
8160 ATTRIBUTE6 = l_items_rec.attribute6,
8161 ATTRIBUTE7 = l_items_rec.attribute7,
8162 ATTRIBUTE8 = l_items_rec.attribute8,
8163 ATTRIBUTE9 = l_items_rec.attribute9,
8164 ATTRIBUTE10 = l_items_rec.attribute10,
8165 ATTRIBUTE11 = l_items_rec.attribute11,
8166 ATTRIBUTE12 = l_items_rec.attribute12,
8167 ATTRIBUTE13 = l_items_rec.attribute13,
8168 ATTRIBUTE14 = l_items_rec.attribute14,
8169 ATTRIBUTE15 = l_items_rec.attribute15,
8170 LAST_UPDATE_DATE = l_last_update_date,
8171 LAST_UPDATED_BY = l_last_updated_by,
8172 LAST_UPDATE_LOGIN = l_last_update_login
8173 where REGION_APPLICATION_ID = p_region_application_id
8174 and   REGION_CODE = p_region_code
8175 and   attribute_application_id = p_attribute_application_id
8176 and   attribute_code = p_attribute_code;
8177 if (sql%notfound) then
8178 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8179 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATE_FAILED');
8180 FND_MSG_PUB.Add;
8181 end if;
8182 -- dbms_output.put_line(l_api_name || 'Row does not exist during update');
8183 raise FND_API.G_EXC_ERROR;
8184 end if;
8185 
8186 update AK_REGION_ITEMS_TL set
8187 ATTRIBUTE_LABEL_LONG = l_items_tl_rec.attribute_label_long,
8188 ATTRIBUTE_LABEL_SHORT = l_items_tl_rec.attribute_label_short,
8189 DESCRIPTION = l_items_tl_rec.description,
8190 LAST_UPDATED_BY = l_last_updated_by,
8191 LAST_UPDATE_DATE = l_last_update_date,
8192 LAST_UPDATE_LOGIN = l_last_update_login,
8193 SOURCE_LANG = l_lang
8194 where REGION_APPLICATION_ID = p_region_application_id
8195 and   REGION_CODE = p_region_code
8196 and   attribute_application_id = p_attribute_application_id
8197 and   attribute_code = p_attribute_code
8198 and   l_lang in (LANGUAGE, SOURCE_LANG);
8199 if (sql%notfound) then
8200 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8201 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATE_FAILED');
8202 FND_MSG_PUB.Add;
8203 end if;
8204 --dbms_output.put_line(l_api_name || 'TL Row does not exist during update');
8205 raise FND_API.G_EXC_ERROR;
8206 end if;
8207 
8208 --  /** commit the update **/
8209  commit;
8210 
8211 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
8212 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATED');
8213 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8214 ' ' || p_region_code ||
8215 ' ' || to_char(p_attribute_application_id) ||
8216 ' ' || p_attribute_code);
8217 FND_MSG_PUB.Add;
8218 end if;
8219 
8220 end if;
8221 
8222   end if; -- /* if not p_copy_redo_flag */
8223 
8224 p_return_status := FND_API.G_RET_STS_SUCCESS;
8225 
8226 FND_MSG_PUB.Count_And_Get (
8227 p_count => p_msg_count,
8228 p_data => p_msg_data);
8229 
8230 EXCEPTION
8231 WHEN VALUE_ERROR THEN
8232 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8233 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_VALUE_ERROR');
8234 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8235 ' ' || p_region_code ||
8236 ' ' || to_char(p_attribute_application_id) ||
8237 ' ' || p_attribute_code);
8238 FND_MSG_PUB.Add;
8239 end if;
8240 rollback to start_update_item;
8241 p_return_status := FND_API.G_RET_STS_ERROR;
8242 FND_MSG_PUB.Count_And_Get (
8243 p_count => p_msg_count,
8244 p_data => p_msg_data);
8245 WHEN FND_API.G_EXC_ERROR THEN
8246 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8247 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_UPDATED');
8248 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8249 ' ' || p_region_code ||
8250 ' ' || to_char(p_attribute_application_id) ||
8251 ' ' || p_attribute_code);
8252 FND_MSG_PUB.Add;
8253 end if;
8254 p_return_status := FND_API.G_RET_STS_ERROR;
8255 rollback to start_update_item;
8256 FND_MSG_PUB.Count_And_Get (
8257 p_count => p_msg_count,
8258 p_data => p_msg_data);
8259 WHEN OTHERS THEN
8260 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8261 rollback to start_update_item;
8262 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8263 SUBSTR (SQLERRM, 1, 240) );
8264 FND_MSG_PUB.Add;
8265 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_UPDATED');
8266 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8267 ' ' || p_region_code ||
8268 ' ' || to_char(p_attribute_application_id) ||
8269 ' ' || p_attribute_code);
8270 FND_MSG_PUB.Add;
8271 FND_MSG_PUB.Count_And_Get (
8272 p_count => p_msg_count,
8273 p_data => p_msg_data);
8274 end UPDATE_ITEM;
8275 
8276 --=======================================================
8277 --  Procedure   UPDATE_REGION
8278 --
8279 --  Usage       Private API for updating a region.
8280 --              This API should only be called by other APIs
8281 --              that are owned by the Core Modules Team (AK).
8282 --
8283 --  Desc        This API updates a region using the given info
8284 --
8285 --  Results     The API returns the standard p_return_status parameter
8286 --              indicating one of the standard return statuses :
8287 --                  * Unexpected error
8288 --                  * Error
8289 --                  * Success
8290 --  Parameters  Region columns
8291 --              p_loader_timestamp : IN optional
8292 --                  If a timestamp is passed, the API will update the
8293 --                  record using this timestamp. Only the upload API
8294 --                  should call with this parameter loaded.
8295 --
8296 --  Version     Initial version number  =   1.0
8297 --  History     Current version number  =   1.0
8298 --=======================================================
8299 procedure UPDATE_REGION (
8300 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
8301 p_api_version_number       IN      NUMBER,
8302 p_init_msg_tbl             IN      BOOLEAN := FALSE,
8303 p_msg_count                OUT NOCOPY     NUMBER,
8304 p_msg_data                 OUT NOCOPY     VARCHAR2,
8305 p_return_status            OUT NOCOPY     VARCHAR2,
8306 p_region_application_id    IN      NUMBER,
8307 p_region_code              IN      VARCHAR2,
8308 p_database_object_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8309 p_region_style             IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8310 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8311 p_num_columns              IN      NUMBER := FND_API.G_MISS_NUM,
8312 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
8313 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
8314 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
8315 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
8316 p_appmodule_object_type	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8317 p_num_rows_display		 IN		 NUMBER := FND_API.G_MISS_NUM,
8318 p_region_object_type		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8319 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8320 p_isform_flag				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8321 p_help_target				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8322 p_style_sheet_filename	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8323 p_version                  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8324 p_applicationmodule_usage_name IN  VARCHAR2 := FND_API.G_MISS_CHAR,
8325 p_add_indexed_children     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8326 p_stateful_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8327 p_function_name            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8328 p_children_view_usage_name IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8329 p_search_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8330 p_advanced_search_panel    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8331 p_customize_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8332 p_default_search_panel     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8333 p_results_based_search     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8334 p_display_graph_table	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8335 p_disable_header	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8336 p_standalone		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8337 p_auto_customization_criteria IN   VARCHAR2 := FND_API.G_MISS_CHAR,
8338 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8339 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8340 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8341 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8342 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8343 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8344 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8345 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8346 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8347 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8348 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8349 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8350 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8351 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8352 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8353 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8354 p_name                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8355 p_description              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8356 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
8357 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
8358 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
8359 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
8360 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
8361 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
8362 p_pass                     IN      NUMBER,
8363 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
8364 ) is
8365 cursor l_get_row_csr is
8366 select *
8367 from  AK_REGIONS
8368 where REGION_APPLICATION_ID = p_region_application_id
8369 and   REGION_CODE = p_region_code
8370 for update of REGION_STYLE;
8371 cursor l_get_tl_row_csr (lang_parm varchar2) is
8372 select *
8373 from  AK_REGIONS_TL
8374 where REGION_APPLICATION_ID = p_region_application_id
8375 and   REGION_CODE = p_region_code
8376 and   LANGUAGE = lang_parm
8377 for update of NAME;
8378 l_api_version_number      CONSTANT number := 1.0;
8379 l_api_name                CONSTANT varchar2(30) := 'Update_Region';
8380 l_created_by              number;
8381 l_creation_date           date;
8382 l_regions_rec             AK_REGIONS%ROWTYPE;
8383 l_regions_tl_rec          AK_REGIONS_TL%ROWTYPE;
8384 l_isform_flag				VARCHAR2(1) := 'N';
8385 l_lang                    varchar2(30);
8386 l_last_update_date        date;
8387 l_last_update_login       number;
8388 l_last_updated_by         number;
8389 l_return_status           varchar2(1);
8390 l_file_version	number;
8391 begin
8392 IF NOT FND_API.Compatible_API_Call (
8393 l_api_version_number, p_api_version_number, l_api_name,
8394 G_PKG_NAME) then
8395 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8396 return;
8397 END IF;
8398 
8399 -- Initialize the message table if requested.
8400 
8401 if p_init_msg_tbl then
8402 FND_MSG_PUB.initialize;
8403 end if;
8404 
8405 savepoint start_update_region;
8406 
8407 select userenv('LANG') into l_lang
8408 from dual;
8409 
8410 --** retrieve ak_regions row if it exists **
8411 open l_get_row_csr;
8412 fetch l_get_row_csr into l_regions_rec;
8413 if (l_get_row_csr%notfound) then
8414 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
8415 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
8416 FND_MSG_PUB.Add;
8417 end if;
8418 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
8419 close l_get_row_csr;
8420 raise FND_API.G_EXC_ERROR;
8421 end if;
8422 close l_get_row_csr;
8423 
8424 --** retrieve ak_regions_tl row if it exists **
8425 open l_get_tl_row_csr(l_lang);
8426 fetch l_get_tl_row_csr into l_regions_tl_rec;
8427 if (l_get_tl_row_csr%notfound) then
8428 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
8429 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
8430 FND_MSG_PUB.Add;
8431 end if;
8432 --dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
8433 close l_get_tl_row_csr;
8434 raise FND_API.G_EXC_ERROR;
8435 end if;
8436 close l_get_tl_row_csr;
8437 
8438 --** validate table columns passed in **
8439 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
8440 if not AK_REGION_PVT.VALIDATE_REGION (
8441 p_validation_level => p_validation_level,
8442 p_api_version_number => 1.0,
8443 p_return_status => l_return_status,
8444 p_region_application_id => p_region_application_id,
8445 p_region_code => p_region_code,
8446 p_database_object_name => p_database_object_name,
8447 p_region_style => p_region_style,
8448 p_icx_custom_call => p_icx_custom_call,
8449 p_num_columns => p_num_columns,
8450 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
8451 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
8452 p_region_validation_api_pkg => p_region_validation_api_pkg,
8453 p_region_validation_api_proc => p_region_validation_api_proc,
8454 p_name => p_name,
8455 p_description => p_description,
8456 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
8457 p_pass => p_pass
8458 ) then
8459 --dbms_output.put_line(l_api_name || 'validation failed');
8460 -- Do not raise an error if it's the first pass
8461 if (p_pass = 1) then
8462 p_copy_redo_flag := TRUE;
8463 else
8464 raise FND_API.G_EXC_ERROR;
8465 end if; -- /* if p_pass */
8466 end if;
8467 end if;
8468 
8469   -- Do not update if fails validation ie. p_copy_redo_flag = true
8470   if (not p_copy_redo_flag) then
8471 
8472 --** Load record to be updated to the database **
8473 --** - first load nullable columns **
8474 
8475 if (p_icx_custom_call  <> FND_API.G_MISS_CHAR) or
8476 (p_icx_custom_call is null) then
8477 l_regions_rec.icx_custom_call := p_icx_custom_call;
8478 end if;
8479 
8480 if (p_description <> FND_API.G_MISS_CHAR) or
8481 (p_description is null) then
8482 l_regions_tl_rec.description := p_description;
8483 end if;
8484 if (p_num_columns <> FND_API.G_MISS_NUM) or
8485 (p_num_columns is null) then
8486 l_regions_rec.num_columns := p_num_columns;
8487 end if;
8488 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
8489 l_regions_rec.region_defaulting_api_pkg := p_region_defaulting_api_pkg;
8490 end if;
8491 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
8492 l_regions_rec.region_defaulting_api_proc := p_region_defaulting_api_proc;
8493 end if;
8494 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
8495 l_regions_rec.region_validation_api_pkg := p_region_validation_api_pkg;
8496 end if;
8497 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
8498 l_regions_rec.region_validation_api_proc := p_region_validation_api_proc;
8499 end if;
8500 -- * new jsp columns * --
8501 if (p_appmodule_object_type  <> FND_API.G_MISS_CHAR) or
8502 (p_appmodule_object_type is null) then
8503 l_regions_rec.applicationmodule_object_type := p_appmodule_object_type;
8504 end if;
8505 if (p_num_rows_display  <> FND_API.G_MISS_NUM) or
8506 (p_num_rows_display is null) then
8507 l_regions_rec.num_rows_display := p_num_rows_display;
8508 end if;
8509 if (p_region_object_type  <> FND_API.G_MISS_CHAR) or
8510 (p_region_object_type is null) then
8511 l_regions_rec.region_object_type := p_region_object_type;
8512 end if;
8513 if (p_image_file_name  <> FND_API.G_MISS_CHAR) or
8514 (p_image_file_name is null) then
8515 l_regions_rec.image_file_name := p_image_file_name;
8516 end if;
8517 if (p_isform_flag  <> FND_API.G_MISS_CHAR) and (p_isform_flag is not null) then
8518 l_regions_rec.isform_flag := p_isform_flag;
8519 else
8520 l_regions_rec.isform_flag := l_isform_flag;
8521 end if;
8522 if (p_help_target  <> FND_API.G_MISS_CHAR) or
8523 (p_help_target is null) then
8524 l_regions_rec.help_target := p_help_target;
8525 end if;
8526 if (p_style_sheet_filename  <> FND_API.G_MISS_CHAR) or
8527 (p_style_sheet_filename is null) then
8528 l_regions_rec.style_sheet_filename := p_style_sheet_filename;
8529 end if;
8530 if (p_version  <> FND_API.G_MISS_CHAR) or
8531 (p_version is null) then
8532 l_regions_rec.version := p_version;
8533 end if;
8534 if (p_applicationmodule_usage_name  <> FND_API.G_MISS_CHAR) or
8535 (p_applicationmodule_usage_name is null) then
8536 l_regions_rec.applicationmodule_usage_name := p_applicationmodule_usage_name;
8537 end if;
8538 if (p_add_indexed_children  <> FND_API.G_MISS_CHAR) or
8539 (p_add_indexed_children is null) then
8540 l_regions_rec.add_indexed_children := p_add_indexed_children;
8541 end if;
8542 if (p_stateful_flag  <> FND_API.G_MISS_CHAR) or
8543 (p_stateful_flag is null) then
8544 l_regions_rec.stateful_flag := p_stateful_flag;
8545 end if;
8546 if (p_function_name  <> FND_API.G_MISS_CHAR) or
8547 (p_function_name is null) then
8548 l_regions_rec.function_name := p_function_name;
8549 end if;
8550 if (p_children_view_usage_name  <> FND_API.G_MISS_CHAR) or
8551 (p_children_view_usage_name is null) then
8552 l_regions_rec.children_view_usage_name := p_children_view_usage_name;
8553 end if;
8554 if (p_search_panel <> FND_API.G_MISS_CHAR) or
8555 (p_search_panel is null) then
8556 l_regions_rec.search_panel := p_search_panel;
8557 end if;
8558 if (p_advanced_search_panel <> FND_API.G_MISS_CHAR) or
8559 (p_advanced_search_panel is null) then
8560 l_regions_rec.advanced_search_panel := p_advanced_search_panel;
8561 end if;
8562 if (p_customize_panel <> FND_API.G_MISS_CHAR) or
8563 (p_customize_panel is null) then
8564 l_regions_rec.customize_panel := p_customize_panel;
8565 end if;
8566 if (p_default_search_panel <> FND_API.G_MISS_CHAR) or
8567 (p_default_search_panel is null) then
8568 l_regions_rec.default_search_panel := p_default_search_panel;
8569 end if;
8570 if (p_results_based_search <> FND_API.G_MISS_CHAR) or
8571 (p_results_based_search is null) then
8572 l_regions_rec.results_based_search := p_results_based_search;
8573 end if;
8574 if (p_display_graph_table <> FND_API.G_MISS_CHAR) or
8575 (p_display_graph_table is null) then
8576 l_regions_rec.display_graph_table := p_display_graph_table;
8577 end if;
8578 if (p_disable_header <> FND_API.G_MISS_CHAR) or
8579 (p_disable_header is null) then
8580 l_regions_rec.disable_header := p_disable_header;
8581 end if;
8582 if (p_auto_customization_criteria <> FND_API.G_MISS_CHAR) or
8583 (p_auto_customization_criteria is null) then
8584 l_regions_rec.auto_customization_criteria := p_auto_customization_criteria;
8585 end if;
8586 
8587 --** non-null, non-key columns **
8588 if (p_standalone <> FND_API.G_MISS_CHAR) or
8589 (p_standalone is not null) then
8590 l_regions_rec.standalone := p_standalone;
8591 else
8592 l_regions_rec.standalone := 'Y';
8593 end if;
8594 
8595 
8596 -- * flex field columns * --
8597 if (p_attribute_category <> FND_API.G_MISS_CHAR) or
8598 (p_attribute_category is null) then
8599 l_regions_rec.attribute_category := p_attribute_category;
8600 end if;
8601 if (p_attribute1 <> FND_API.G_MISS_CHAR) or
8602 (p_attribute1 is null) then
8603 l_regions_rec.attribute1 := p_attribute1;
8604 end if;
8605 if (p_attribute2 <> FND_API.G_MISS_CHAR) or
8606 (p_attribute2 is null) then
8607 l_regions_rec.attribute2 := p_attribute2;
8608 end if;
8609 if (p_attribute3 <> FND_API.G_MISS_CHAR) or
8610 (p_attribute3 is null) then
8611 l_regions_rec.attribute3 := p_attribute3;
8612 end if;
8613 if (p_attribute4 <> FND_API.G_MISS_CHAR) or
8614 (p_attribute4 is null) then
8615 l_regions_rec.attribute4 := p_attribute4;
8616 end if;
8617 if (p_attribute5 <> FND_API.G_MISS_CHAR) or
8618 (p_attribute5 is null) then
8619 l_regions_rec.attribute5 := p_attribute5;
8620 end if;
8621 if (p_attribute6 <> FND_API.G_MISS_CHAR) or
8622 (p_attribute6 is null) then
8623 l_regions_rec.attribute6 := p_attribute6;
8624 end if;
8625 if (p_attribute7 <> FND_API.G_MISS_CHAR) or
8626 (p_attribute7 is null) then
8627 l_regions_rec.attribute7 := p_attribute7;
8628 end if;
8629 if (p_attribute8 <> FND_API.G_MISS_CHAR) or
8630 (p_attribute8 is null) then
8631 l_regions_rec.attribute8 := p_attribute8;
8632 end if;
8633 if (p_attribute9 <> FND_API.G_MISS_CHAR) or
8634 (p_attribute9 is null) then
8635 l_regions_rec.attribute9 := p_attribute9;
8636 end if;
8637 if (p_attribute10 <> FND_API.G_MISS_CHAR) or
8638 (p_attribute10 is null) then
8639 l_regions_rec.attribute10 := p_attribute10;
8640 end if;
8641 if (p_attribute11 <> FND_API.G_MISS_CHAR) or
8642 (p_attribute11 is null) then
8643 l_regions_rec.attribute11 := p_attribute11;
8644 end if;
8645 if (p_attribute12 <> FND_API.G_MISS_CHAR) or
8646 (p_attribute12 is null) then
8647 l_regions_rec.attribute12 := p_attribute12;
8648 end if;
8649 if (p_attribute13 <> FND_API.G_MISS_CHAR) or
8650 (p_attribute13 is null) then
8651 l_regions_rec.attribute13 := p_attribute13;
8652 end if;
8653 if (p_attribute14 <> FND_API.G_MISS_CHAR) or
8654 (p_attribute14 is null) then
8655 l_regions_rec.attribute14 := p_attribute14;
8656 end if;
8657 if (p_attribute15 <> FND_API.G_MISS_CHAR) or
8658 (p_attribute15 is null) then
8659 l_regions_rec.attribute15 := p_attribute15;
8660 end if;
8661 
8662 --** - next, load non-null, non-key columns **
8663 
8664 if (p_database_object_name <> FND_API.G_MISS_CHAR) then
8665 l_regions_rec.database_object_name := p_database_object_name;
8666 end if;
8667 if (p_region_style <> FND_API.G_MISS_CHAR) then
8668 l_regions_rec.region_style := p_region_style;
8669 end if;
8670 if (p_name <> FND_API.G_MISS_CHAR) then
8671 l_regions_tl_rec.name := p_name;
8672 end if;
8673 
8674   if (p_created_by <> FND_API.G_MISS_NUM) then
8675     l_created_by := p_created_by;
8676   end if;
8677   if (p_creation_date <> FND_API.G_MISS_DATE) then
8678     l_creation_date := p_creation_date;
8679   end if;
8680   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
8681     l_last_updated_by := p_last_updated_by;
8682   end if;
8683   if (p_last_update_date <> FND_API.G_MISS_DATE) then
8684     l_last_update_date := p_last_update_date;
8685   end if;
8686   if (p_last_update_login <> FND_API.G_MISS_NUM) then
8687     l_last_update_login := p_last_update_login;
8688   end if;
8689 
8690 -- Set WHO columns
8691 
8692   if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
8693        p_loader_timestamp => p_loader_timestamp,
8694        p_created_by => l_created_by,
8695        p_creation_date => l_creation_date,
8696        p_last_updated_by => l_last_updated_by,
8697        p_db_last_updated_by => l_regions_rec.last_updated_by,
8698        p_last_update_date => l_last_update_date,
8699        p_db_last_update_date => l_regions_rec.last_update_date,
8700        p_last_update_login => l_last_update_login,
8701        p_create_or_update => 'UPDATE') then
8702 
8703 update AK_REGIONS set
8704 DATABASE_OBJECT_NAME = l_regions_rec.database_object_name,
8705 REGION_STYLE = l_regions_rec.region_style,
8706 ICX_CUSTOM_CALL = l_regions_rec.icx_custom_call,
8707 NUM_COLUMNS = l_regions_rec.num_columns,
8708 REGION_DEFAULTING_API_PKG = l_regions_rec.region_defaulting_api_pkg,
8709 REGION_DEFAULTING_API_PROC = l_regions_rec.region_defaulting_api_proc,
8710 REGION_VALIDATION_API_PKG = l_regions_rec.region_validation_api_pkg,
8711 REGION_VALIDATION_API_PROC = l_regions_rec.region_validation_api_proc,
8712 APPLICATIONMODULE_OBJECT_TYPE = l_regions_rec.applicationmodule_object_type,
8713 NUM_ROWS_DISPLAY = l_regions_rec.num_rows_display,
8714 REGION_OBJECT_TYPE = l_regions_rec.region_object_type,
8715 IMAGE_FILE_NAME = l_regions_rec.image_file_name,
8716 ISFORM_FLAG = l_regions_rec.isform_flag,
8717 HELP_TARGET = l_regions_rec.help_target,
8718 STYLE_SHEET_FILENAME = l_regions_rec.style_sheet_filename,
8719 VERSION = l_regions_rec.version,
8720 APPLICATIONMODULE_USAGE_NAME = l_regions_rec.applicationmodule_usage_name,
8721 ADD_INDEXED_CHILDREN = l_regions_rec.add_indexed_children,
8722 STATEFUL_FLAG = l_regions_rec.stateful_flag,
8723 FUNCTION_NAME = l_regions_rec.function_name,
8724 CHILDREN_VIEW_USAGE_NAME = l_regions_rec.children_view_usage_name,
8725 SEARCH_PANEL = l_regions_rec.search_panel,
8726 ADVANCED_SEARCH_PANEL = l_regions_rec.advanced_search_panel,
8727 CUSTOMIZE_PANEL = l_regions_rec.customize_panel,
8728 DEFAULT_SEARCH_PANEL = l_regions_rec.default_search_panel,
8729 RESULTS_BASED_SEARCH = l_regions_rec.results_based_search,
8730 DISPLAY_GRAPH_TABLE = l_regions_rec.display_graph_table,
8731 DISABLE_HEADER = l_regions_rec.disable_header,
8732 STANDALONE = l_regions_rec.standalone,
8733 AUTO_CUSTOMIZATION_CRITERIA = l_regions_rec.auto_customization_criteria,
8734 ATTRIBUTE_CATEGORY = l_regions_rec.attribute_category,
8735 ATTRIBUTE1 = l_regions_rec.attribute1,
8736 ATTRIBUTE2 = l_regions_rec.attribute2,
8737 ATTRIBUTE3 = l_regions_rec.attribute3,
8738 ATTRIBUTE4 = l_regions_rec.attribute4,
8739 ATTRIBUTE5 = l_regions_rec.attribute5,
8740 ATTRIBUTE6 = l_regions_rec.attribute6,
8741 ATTRIBUTE7 = l_regions_rec.attribute7,
8742 ATTRIBUTE8 = l_regions_rec.attribute8,
8743 ATTRIBUTE9 = l_regions_rec.attribute9,
8744 ATTRIBUTE10 = l_regions_rec.attribute10,
8745 ATTRIBUTE11 = l_regions_rec.attribute11,
8746 ATTRIBUTE12 = l_regions_rec.attribute12,
8747 ATTRIBUTE13 = l_regions_rec.attribute13,
8748 ATTRIBUTE14 = l_regions_rec.attribute14,
8749 ATTRIBUTE15 = l_regions_rec.attribute15,
8750 LAST_UPDATE_DATE = l_last_update_date,
8751 LAST_UPDATED_BY = l_last_updated_by,
8752 LAST_UPDATE_LOGIN = l_last_update_login
8753 where REGION_APPLICATION_ID = p_region_application_id
8754 and   REGION_CODE = p_region_code;
8755 if (sql%notfound) then
8756 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8757 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATE_FAILED');
8758 FND_MSG_PUB.Add;
8759 end if;
8760 raise FND_API.G_EXC_ERROR;
8761 end if;
8762 
8763 update AK_REGIONS_TL set
8764 NAME = l_regions_tl_rec.name,
8765 DESCRIPTION = l_regions_tl_rec.description,
8766 LAST_UPDATE_DATE = l_last_update_date,
8767 LAST_UPDATED_BY = l_last_updated_by,
8768 LAST_UPDATE_LOGIN = l_last_update_login,
8769 SOURCE_LANG = l_lang
8770 where REGION_APPLICATION_ID = p_region_application_id
8771 and   REGION_CODE = p_region_code
8772 and   l_lang in (LANGUAGE, SOURCE_LANG);
8773 
8774 if (sql%notfound) then
8775 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8776 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATE_FAILED');
8777 FND_MSG_PUB.Add;
8778 end if;
8779 raise FND_API.G_EXC_ERROR;
8780 end if;
8781 
8782 --  /** commit the update **/
8783  commit;
8784 
8785 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
8786 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATED');
8787 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8788 ' ' || p_region_code);
8789 FND_MSG_PUB.Add;
8790 end if;
8791 
8792 end if;
8793 
8794   end if; -- /* if not p_copy_redo_flag */
8795 
8796 p_return_status := FND_API.G_RET_STS_SUCCESS;
8797 
8798 FND_MSG_PUB.Count_And_Get (
8799 p_count => p_msg_count,
8800 p_data => p_msg_data);
8801 
8802 EXCEPTION
8803 WHEN VALUE_ERROR THEN
8804 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8805 FND_MESSAGE.SET_NAME('AK','AK_REGION_VALUE_ERROR');
8806 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8807 ' ' || p_region_code);
8808 FND_MSG_PUB.Add;
8809 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8810 SUBSTR (SQLERRM, 1, 240));
8811 FND_MSG_PUB.Add;
8812 
8813 end if;
8814 rollback to start_update_region;
8815 p_return_status := FND_API.G_RET_STS_ERROR;
8816 FND_MSG_PUB.Count_And_Get (
8817 p_count => p_msg_count,
8818 p_data => p_msg_data);
8819 WHEN FND_API.G_EXC_ERROR THEN
8820 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8821 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_UPDATED');
8822 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8823 ' ' || p_region_code);
8824 FND_MSG_PUB.Add;
8825 end if;
8826 p_return_status := FND_API.G_RET_STS_ERROR;
8827 rollback to start_update_region;
8828 FND_MSG_PUB.Count_And_Get (
8829 p_count => p_msg_count,
8830 p_data => p_msg_data);
8831 WHEN OTHERS THEN
8832 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8833 rollback to start_update_region;
8834 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8835 SUBSTR (SQLERRM, 1, 240) );
8836 FND_MSG_PUB.Add;
8837 FND_MSG_PUB.Count_And_Get (
8838 p_count => p_msg_count,
8839 p_data => p_msg_data);
8840 FND_MSG_PUB.Count_And_Get (
8841 p_count => p_msg_count,
8842 p_data => p_msg_data);
8843 end UPDATE_REGION;
8844 
8845 Function REGION_KEY_EXISTS (
8846 p_region_application_id	in	number,
8847 p_region_code				in	varchar2,
8848 p_region_pk_tbl			in 	ak_region_pub.region_pk_tbl_type
8849 ) return boolean is
8850 
8851 l_exist	boolean := true;
8852 
8853 begin
8854 if (p_region_pk_tbl.count = 0) then
8855 l_exist := false;
8856 end if;
8857 
8858 for l_index in p_region_pk_tbl.FIRST .. p_region_pk_tbl.LAST loop
8859 if (p_region_pk_tbl.exists(l_index)) then
8860 if (p_region_pk_tbl(l_index).region_appl_id = p_region_application_id)
8861 and
8862 (p_region_pk_tbl(l_index).region_code = p_region_code) then
8863 l_exist := true;
8864 exit;
8865 end if;
8866 end if;
8867 end loop;
8868 return l_exist;
8869 end;
8870 
8871 Procedure ADD_NESTED_REG_TO_REG_PK (
8872 p_region_application_id	IN	number,
8873 p_region_code		IN	varchar2,
8874 p_region_pk_tbl		IN OUT NOCOPY  AK_REGION_PUB.Region_PK_Tbl_Type
8875 ) IS
8876 cursor l_get_ri_nested_regions_csr (region_appl_id_param number,
8877 region_code_param varchar2) is
8878 select distinct nested_region_application_id, nested_region_code
8879 from   AK_REGION_ITEMS
8880 where  region_application_id = region_appl_id_param
8881 and    region_code = region_code_param
8882 and    nested_region_application_id is not null
8883 and    nested_region_code is not null;
8884 cursor l_get_non_train_region_csr(region_appl_id_param number,
8885 region_code_param varchar2) is
8886 select region_application_id, region_code
8887 from ak_regions_vl
8888 where region_application_id = region_appl_id_param
8889 and region_code = region_code_param
8890 and region_style <> 'TRAIN';
8891 l_return_status	varchar2(1);
8892 begin
8893 for l_region_rec in l_get_ri_nested_regions_csr (
8894 p_region_application_id, p_region_code) loop
8895 for l_non_train_region_rec in l_get_non_train_region_csr(l_region_rec.nested_region_application_id, l_region_rec.nested_region_code) loop
8896 if ( NOT REGION_KEY_EXISTS(l_region_rec.nested_region_application_id, l_region_rec.nested_region_code, p_region_pk_tbl) ) then
8897 -- drilling into the nested levels
8898 AK_REGION_PVT.ADD_NESTED_REG_TO_REG_PK(
8899 l_region_rec.nested_region_application_id,
8900 l_region_rec.nested_region_code,
8901 p_region_pk_tbl);
8902 end if;
8903 end loop; -- end l_get_non_train_region_csr
8904 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
8905 p_return_status => l_return_status,
8906 p_region_application_id =>
8907 l_region_rec.nested_region_application_id,
8908 p_region_code => l_region_rec.nested_region_code,
8909 p_region_pk_tbl => p_region_pk_tbl);
8910 end loop;
8911 
8912 end ADD_NESTED_REG_TO_REG_PK;
8913 
8914 
8915 end AK_REGION_PVT;