DBA Data[Home] [Help]

PACKAGE BODY: APPS.AK_REGION_PVT

Source


1 package body AK_REGION_PVT as
2 /* $Header: akdvregb.pls 120.6 2006/11/30 23:27:31 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 --
4003 -- special logic for handling update_flag, bug#2054285
4004 -- set update_flag to 'Y'
4005 -- do not change update_flag to 'Y' if FILE_FORMAT_VERSION > 115.14
4006 --
4007 l_update_flag := p_update_flag;
4008 if ( ( AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER1 or
4009 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER2 or
4010 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER3 or
4011 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER4 or
4012 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER5 or
4013 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER6 or
4014 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER7 or
4015 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER8 or
4016 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER9 or
4017 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER11 or
4018 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER12 ) and
4019 ( p_item_style = 'CHECKBOX' or p_item_style = 'DESCRIPTIVE_FLEX' or
4020 p_item_style = 'KEY_FLEX' or p_item_style = 'FILE' or
4021 p_item_style = 'FORM_PARAMETER_BEAN' or p_item_style = 'RADIO_BUTTON' or
4022 p_item_style  = 'POPLIST' or p_item_style = 'HIDDEN' or
4023 p_item_style = 'TEXT_INPUT' or p_item_style = 'RADIO_GROUP' ) and
4024 INSTR(p_region_code,'POR') <> 1 ) then
4025 l_update_flag := 'Y';
4026 end if;
4027 
4028 -- default a value for submit and encrypt columns if no value is given
4029 if ( p_submit <> FND_API.G_MISS_CHAR and p_submit is not null ) then
4030 l_submit := p_submit;
4031 end if;
4032 if ( p_encrypt <> FND_API.G_MISS_CHAR and p_encrypt is not null ) then
4033 l_encrypt := p_encrypt;
4034 end if;
4035 if ( p_admin_customizable <> FND_API.G_MISS_CHAR and p_admin_customizable is not null ) then
4036 l_admin_customizable := p_admin_customizable;
4037 end if;
4038 
4039 --** Load non-required columns if their values are given **
4040 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) then
4041 l_icx_custom_call := p_icx_custom_call;
4042 end if;
4043 
4044 if (p_security_code <> FND_API.G_MISS_CHAR) then
4045 l_security_code := p_security_code;
4046 end if;
4047 
4048 if (p_default_value_varchar2 <> FND_API.G_MISS_CHAR) then
4049 l_default_value_varchar2 := p_default_value_varchar2;
4050 end if;
4051 
4052 if (p_default_value_number <> FND_API.G_MISS_NUM) then
4053 l_default_value_number := p_default_value_number;
4054 end if;
4055 
4056 if (p_default_value_date <> FND_API.G_MISS_DATE) then
4057 l_default_value_date := p_default_value_date;
4058 end if;
4059 
4060 if (p_lov_region_application_id <> FND_API.G_MISS_NUM) then
4061 l_lov_region_appl_id := p_lov_region_application_id;
4062 end if;
4063 
4064 if (p_lov_region_code <> FND_API.G_MISS_CHAR) then
4065 l_lov_region_code := p_lov_region_code;
4066 end if;
4067 
4068 if (p_lov_foreign_key_name <> FND_API.G_MISS_CHAR) then
4069 l_lov_foreign_key_name := p_lov_foreign_key_name;
4070 end if;
4071 
4072 if (p_lov_attribute_application_id <> FND_API.G_MISS_NUM) then
4073 l_lov_attribute_appl_id := p_lov_attribute_application_id;
4074 end if;
4075 
4076 if (p_lov_attribute_code <> FND_API.G_MISS_CHAR) then
4077 l_lov_attribute_code := p_lov_attribute_code;
4078 end if;
4079 
4080 if (p_lov_default_flag <> FND_API.G_MISS_CHAR) then
4081 l_lov_default_flag := p_lov_default_flag;
4082 end if;
4083 
4084 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
4085 l_region_defaulting_api_pkg := p_region_defaulting_api_pkg;
4086 end if;
4087 
4088 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
4089 l_region_defaulting_api_proc := p_region_defaulting_api_proc;
4090 end if;
4091 
4092 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
4093 l_region_validation_api_pkg := p_region_validation_api_pkg;
4094 end if;
4095 
4096 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
4097 l_region_validation_api_proc := p_region_validation_api_proc;
4098 end if;
4099 
4100 if (p_order_sequence <> FND_API.G_MISS_NUM) then
4101 l_order_sequence := p_order_sequence;
4102 end if;
4103 
4104 if (p_order_direction <> FND_API.G_MISS_CHAR) then
4105 l_order_direction := p_order_direction;
4106 end if;
4107 
4108 if (p_display_height <> FND_API.G_MISS_NUM) then
4109 l_display_height := p_display_height;
4110 end if;
4111 
4112 if (p_css_class_name <> FND_API.G_MISS_CHAR) then
4113 l_css_class_name := p_css_class_name;
4114 end if;
4115 
4116 if (p_view_usage_name <> FND_API.G_MISS_CHAR) then
4117 l_view_usage_name := p_view_usage_name;
4118 end if;
4119 
4120 if (p_view_attribute_name <> FND_API.G_MISS_CHAR) then
4121 l_view_attribute_name := p_view_attribute_name;
4122 end if;
4123 
4124 if (p_nested_region_appl_id <> FND_API.G_MISS_NUM) then
4125 l_nested_region_appl_id := p_nested_region_appl_id;
4126 end if;
4127 
4128 if (p_nested_region_code <> FND_API.G_MISS_CHAR) then
4129 l_nested_region_code := p_nested_region_code;
4130 end if;
4131 
4132 if (p_url <> FND_API.G_MISS_CHAR) then
4133 l_url := p_url;
4134 end if;
4135 
4136 if (p_poplist_viewobject <> FND_API.G_MISS_CHAR) then
4137 l_poplist_viewobject := p_poplist_viewobject;
4138 end if;
4139 
4140 if (p_poplist_display_attr <> FND_API.G_MISS_CHAR) then
4141 l_poplist_display_attr := p_poplist_display_attr;
4142 end if;
4143 
4144 if (p_poplist_value_attr <> FND_API.G_MISS_CHAR) then
4145 l_poplist_value_attr := p_poplist_value_attr;
4146 end if;
4147 
4148 if (p_image_file_name <> FND_API.G_MISS_CHAR) then
4149 l_image_file_name := p_image_file_name;
4150 end if;
4151 
4152 if (p_item_name <> FND_API.G_MISS_CHAR) then
4153 l_item_name := p_item_name;
4154 end if;
4155 
4156 if (p_css_label_class_name <> FND_API.G_MISS_CHAR) then
4157 l_css_label_class_name := p_css_label_class_name;
4158 end if;
4159 
4160 if (p_menu_name <> FND_API.G_MISS_CHAR) then
4161 l_menu_name := p_menu_name;
4162 end if;
4163 
4164 if (p_flexfield_name <> FND_API.G_MISS_CHAR) then
4165 l_flexfield_name := p_flexfield_name;
4166 end if;
4167 
4168 if (p_flexfield_application_id <> FND_API.G_MISS_NUM) then
4169 l_flexfield_application_id := p_flexfield_application_id;
4170 end if;
4171 
4172 if (p_tabular_function_code <> FND_API.G_MISS_CHAR) then
4173 l_tabular_function_code := p_tabular_function_code;
4174 end if;
4175 
4176 if (p_tip_type <> FND_API.G_MISS_CHAR) then
4177 l_tip_type := p_tip_type;
4178 end if;
4179 
4180 if (p_tip_message_name <> FND_API.G_MISS_CHAR) then
4181 l_tip_message_name := p_tip_message_name;
4182 end if;
4183 
4184 if (p_tip_message_application_id <> FND_API.G_MISS_NUM) then
4185 l_tip_message_application_id := p_tip_message_application_id;
4186 end if;
4187 
4188 if (p_flex_segment_list <> FND_API.G_MISS_CHAR) then
4189 l_flex_segment_list := p_flex_segment_list;
4190 end if;
4191 
4192 if (p_entity_id <> FND_API.G_MISS_CHAR) then
4193 l_entity_id := p_entity_id;
4194 end if;
4195 
4196 if (p_anchor <> FND_API.G_MISS_CHAR) then
4197 l_anchor := p_anchor;
4198 end if;
4199 
4200 if (p_poplist_view_usage_name <> FND_API.G_MISS_CHAR) then
4201 l_poplist_view_usage_name:= p_poplist_view_usage_name;
4202 end if;
4203 
4204 if (p_user_customizable <> FND_API.G_MISS_CHAR) then
4205 l_user_customizable:= p_user_customizable;
4206 end if;
4207 
4208 if (p_sortby_view_attribute_name <> FND_API.G_MISS_CHAR) then
4209 l_sortby_view_attribute_name:= p_sortby_view_attribute_name;
4210 end if;
4211 
4212 if (p_invoke_function_name <> FND_API.G_MISS_CHAR) then
4213 l_invoke_function_name:= p_invoke_function_name;
4214 end if;
4215 
4216 if (p_expansion <> FND_API.G_MISS_NUM) then
4217 l_expansion := p_expansion;
4218 end if;
4219 
4220 if (p_als_max_length <> FND_API.G_MISS_NUM) then
4221 l_als_max_length := p_als_max_length;
4222 end if;
4223 
4224 if (p_initial_sort_sequence<> FND_API.G_MISS_CHAR) then
4225 l_initial_sort_sequence := p_initial_sort_sequence;
4226 end if;
4227 
4228 if (p_customization_application_id <> FND_API.G_MISS_NUM) then
4229 l_customization_application_id := p_customization_application_id;
4230 end if;
4231 
4232 if (p_customization_code <> FND_API.G_MISS_CHAR) then
4233 l_customization_code := p_customization_code;
4234 end if;
4235 
4236 if (p_attribute_category <> FND_API.G_MISS_CHAR) then
4237 l_attribute_category := p_attribute_category;
4238 end if;
4239 
4240 if (p_attribute1 <> FND_API.G_MISS_CHAR) then
4241 l_attribute1 := p_attribute1;
4242 end if;
4243 
4244 if (p_attribute2 <> FND_API.G_MISS_CHAR) then
4245 l_attribute2 := p_attribute2;
4246 end if;
4247 
4248 if (p_attribute3 <> FND_API.G_MISS_CHAR) then
4249 l_attribute3 := p_attribute3;
4250 end if;
4251 
4252 if (p_attribute4 <> FND_API.G_MISS_CHAR) then
4253 l_attribute4 := p_attribute4;
4254 end if;
4255 
4256 if (p_attribute5 <> FND_API.G_MISS_CHAR) then
4257 l_attribute5 := p_attribute5;
4258 end if;
4259 
4260 if (p_attribute6 <> FND_API.G_MISS_CHAR) then
4261 l_attribute6 := p_attribute6;
4262 end if;
4263 
4264 if (p_attribute7 <> FND_API.G_MISS_CHAR) then
4265 l_attribute7:= p_attribute7;
4266 end if;
4267 
4268 if (p_attribute8 <> FND_API.G_MISS_CHAR) then
4269 l_attribute8 := p_attribute8;
4270 end if;
4271 
4272 if (p_attribute9 <> FND_API.G_MISS_CHAR) then
4273 l_attribute9 := p_attribute9;
4274 end if;
4275 
4276 if (p_attribute10 <> FND_API.G_MISS_CHAR) then
4277 l_attribute10 := p_attribute10;
4278 end if;
4279 
4280 if (p_attribute11 <> FND_API.G_MISS_CHAR) then
4281 l_attribute11 := p_attribute11;
4282 end if;
4283 
4284 if (p_attribute12 <> FND_API.G_MISS_CHAR) then
4285 l_attribute12 := p_attribute12;
4286 end if;
4287 
4288 if (p_attribute13 <> FND_API.G_MISS_CHAR) then
4289 l_attribute13 := p_attribute13;
4290 end if;
4291 
4292 if (p_attribute14 <> FND_API.G_MISS_CHAR) then
4293 l_attribute14 := p_attribute14;
4294 end if;
4295 
4296 if (p_attribute15 <> FND_API.G_MISS_CHAR) then
4297 l_attribute15 := p_attribute15;
4298 end if;
4299 
4300 if (p_attribute_label_long <> FND_API.G_MISS_CHAR) then
4301 l_attribute_label_long := p_attribute_label_long;
4302 end if;
4303 
4304 if (p_attribute_label_short <> FND_API.G_MISS_CHAR) then
4305 l_attribute_label_short := p_attribute_label_short;
4306 end if;
4307 
4308 if (p_description <> FND_API.G_MISS_CHAR) then
4309 l_description := p_description;
4310 end if;
4311 
4312   if (p_created_by <> FND_API.G_MISS_NUM) then
4313     l_created_by := p_created_by;
4314   end if;
4315 
4316   if (p_creation_date <> FND_API.G_MISS_DATE) then
4317     l_creation_date := p_creation_date;
4318   end if;
4319 
4320   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
4321     l_last_updated_by := p_last_updated_by;
4322   end if;
4323 
4324   if (p_last_update_date <> FND_API.G_MISS_DATE) then
4325     l_last_update_date := p_last_update_date;
4326   end if;
4327 
4328   if (p_last_update_login <> FND_API.G_MISS_NUM) then
4329     l_last_update_login := p_last_update_login;
4330   end if;
4331 
4332 -- Create record if no validation error was found
4333   --  NOTE - Calling IS_UPDATEABLE for backward compatibility
4334   --  old jlt files didn't have who columns and IS_UPDATEABLE
4335   --  calls SET_WHO which populates those columns, for later
4336   --  jlt files IS_UPDATEABLE will always return TRUE for CREATE
4337 
4338 if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
4339        p_loader_timestamp => p_loader_timestamp,
4340        p_created_by => l_created_by,
4341        p_creation_date => l_creation_date,
4342        p_last_updated_by => l_last_updated_by,
4343        p_db_last_updated_by => null,
4344        p_last_update_date => l_last_update_date,
4345        p_db_last_update_date => null,
4346        p_last_update_login => l_last_update_login,
4347        p_create_or_update => 'CREATE') then
4348      null;
4349   end if;
4350 
4351 select userenv('LANG') into l_lang
4352 from dual;
4353 
4354 insert into AK_REGION_ITEMS (
4355 REGION_APPLICATION_ID,
4356 REGION_CODE,
4357 ATTRIBUTE_APPLICATION_ID,
4358 ATTRIBUTE_CODE,
4359 DISPLAY_SEQUENCE,
4360 NODE_DISPLAY_FLAG,
4361 NODE_QUERY_FLAG,
4362 ATTRIBUTE_LABEL_LENGTH,
4363 DISPLAY_VALUE_LENGTH,
4364 BOLD,
4365 ITALIC,
4366 VERTICAL_ALIGNMENT,
4367 HORIZONTAL_ALIGNMENT,
4368 ITEM_STYLE,
4369 OBJECT_ATTRIBUTE_FLAG,
4370 ICX_CUSTOM_CALL,
4371 UPDATE_FLAG,
4372 REQUIRED_FLAG,
4373 SECURITY_CODE,
4374 DEFAULT_VALUE_VARCHAR2,
4375 DEFAULT_VALUE_NUMBER,
4376 DEFAULT_VALUE_DATE,
4377 LOV_REGION_APPLICATION_ID,
4378 LOV_REGION_CODE,
4379 LOV_FOREIGN_KEY_NAME,
4380 LOV_ATTRIBUTE_APPLICATION_ID,
4381 LOV_ATTRIBUTE_CODE,
4382 LOV_DEFAULT_FLAG,
4383 REGION_DEFAULTING_API_PKG,
4384 REGION_DEFAULTING_API_PROC,
4385 REGION_VALIDATION_API_PKG,
4386 REGION_VALIDATION_API_PROC,
4387 ORDER_SEQUENCE,
4388 ORDER_DIRECTION,
4389 DISPLAY_HEIGHT,
4390 SUBMIT,
4391 ENCRYPT,
4392 CSS_CLASS_NAME,
4393 VIEW_USAGE_NAME,
4394 VIEW_ATTRIBUTE_NAME,
4395 NESTED_REGION_APPLICATION_ID,
4396 NESTED_REGION_CODE,
4397 URL,
4398 POPLIST_VIEWOBJECT,
4399 POPLIST_DISPLAY_ATTRIBUTE,
4400 POPLIST_VALUE_ATTRIBUTE,
4401 IMAGE_FILE_NAME,
4402 ITEM_NAME,
4403 CSS_LABEL_CLASS_NAME,
4404 MENU_NAME,
4405 FLEXFIELD_NAME,
4406 FLEXFIELD_APPLICATION_ID,
4407 TABULAR_FUNCTION_CODE,
4408 TIP_TYPE,
4409 TIP_MESSAGE_NAME,
4410 TIP_MESSAGE_APPLICATION_ID,
4411 FLEX_SEGMENT_LIST,
4412 ENTITY_ID,
4413 ANCHOR,
4414 POPLIST_VIEW_USAGE_NAME,
4415 USER_CUSTOMIZABLE,
4416 SORTBY_VIEW_ATTRIBUTE_NAME,
4417 ADMIN_CUSTOMIZABLE,
4418 INVOKE_FUNCTION_NAME,
4419 EXPANSION,
4420 ALS_MAX_LENGTH,
4421 INITIAL_SORT_SEQUENCE,
4422 CUSTOMIZATION_APPLICATION_ID,
4423 CUSTOMIZATION_CODE,
4424 ATTRIBUTE_CATEGORY,
4425 ATTRIBUTE1,
4426 ATTRIBUTE2,
4427 ATTRIBUTE3,
4428 ATTRIBUTE4,
4429 ATTRIBUTE5,
4430 ATTRIBUTE6,
4431 ATTRIBUTE7,
4432 ATTRIBUTE8,
4433 ATTRIBUTE9,
4434 ATTRIBUTE10,
4435 ATTRIBUTE11,
4436 ATTRIBUTE12,
4437 ATTRIBUTE13,
4438 ATTRIBUTE14,
4439 ATTRIBUTE15,
4440 CREATION_DATE,
4441 CREATED_BY,
4442 LAST_UPDATE_DATE,
4443 LAST_UPDATED_BY,
4444 LAST_UPDATE_LOGIN
4445 ) values (
4446 p_region_application_id,
4447 p_region_code,
4448 p_attribute_application_id,
4449 p_attribute_code,
4450 p_display_sequence,
4451 p_node_display_flag,
4452 p_node_query_flag,
4453 p_attribute_label_length,
4454 p_display_value_length,
4455 p_bold,
4456 p_italic,
4457 p_vertical_alignment,
4458 p_horizontal_alignment,
4459 p_item_style,
4460 p_object_attribute_flag,
4461 l_icx_custom_call,
4462 l_update_flag,
4463 p_required_flag,
4464 l_security_code,
4465 l_default_value_varchar2,
4466 l_default_value_number,
4467 l_default_value_date,
4468 l_lov_region_appl_id,
4469 l_lov_region_code,
4470 l_lov_foreign_key_name,
4471 l_lov_attribute_appl_id,
4472 l_lov_attribute_code,
4473 l_lov_default_flag,
4474 l_region_defaulting_api_pkg,
4475 l_region_defaulting_api_proc,
4476 l_region_validation_api_pkg,
4477 l_region_validation_api_proc,
4478 l_order_sequence,
4479 l_order_direction,
4480 l_display_height,
4481 l_submit,
4482 l_encrypt,
4483 l_css_class_name,
4484 l_view_usage_name,
4485 l_view_attribute_name,
4486 l_nested_region_appl_id,
4487 l_nested_region_code,
4488 l_url,
4489 l_poplist_viewobject,
4490 l_poplist_display_attr,
4491 l_poplist_value_attr,
4492 l_image_file_name,
4493 l_item_name,
4494 l_css_label_class_name,
4495 l_menu_name,
4496 l_flexfield_name,
4497 l_flexfield_application_id,
4498 l_tabular_function_code,
4499 l_tip_type,
4500 l_tip_message_name,
4501 l_tip_message_application_id,
4502 l_flex_segment_list,
4503 l_entity_id,
4504 l_anchor,
4505 l_poplist_view_usage_name,
4506 l_user_customizable,
4507 l_sortby_view_attribute_name,
4508 l_admin_customizable,
4509 l_invoke_function_name,
4510 l_expansion,
4511 l_als_max_length,
4512 l_initial_sort_sequence,
4513 l_customization_application_id,
4514 l_customization_code,
4515 l_attribute_category,
4516 l_attribute1,
4517 l_attribute2,
4518 l_attribute3,
4519 l_attribute4,
4520 l_attribute5,
4521 l_attribute6,
4522 l_attribute7,
4523 l_attribute8,
4524 l_attribute9,
4525 l_attribute10,
4526 l_attribute11,
4527 l_attribute12,
4528 l_attribute13,
4529 l_attribute14,
4530 l_attribute15,
4531 l_creation_date,
4532 l_created_by,
4533 l_last_update_date,
4534 l_last_updated_by,
4535 l_last_update_login
4536 );
4537 
4538 --** row should exists before inserting rows for other languages **
4539 if NOT AK_REGION_PVT.ITEM_EXISTS (
4540 p_api_version_number => 1.0,
4541 p_return_status => l_return_status,
4542 p_region_application_id => p_region_application_id,
4543 p_region_code => p_region_code,
4544 p_attribute_application_id => p_attribute_application_id,
4545 p_attribute_code => p_attribute_code) then
4546 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
4547 FND_MESSAGE.SET_NAME('AK','AK_INSERT_REG_ITEM_FAILED');
4548 FND_MSG_PUB.Add;
4549 end if;
4550 --dbms_output.put_line(l_api_name || 'Error - row already exists');
4551 raise FND_API.G_EXC_ERROR;
4552 end if;
4553 
4554 insert into AK_REGION_ITEMS_TL (
4555 REGION_APPLICATION_ID,
4556 REGION_CODE,
4557 ATTRIBUTE_APPLICATION_ID,
4558 ATTRIBUTE_CODE,
4559 LANGUAGE,
4560 ATTRIBUTE_LABEL_LONG,
4561 ATTRIBUTE_LABEL_SHORT,
4562 DESCRIPTION,
4563 SOURCE_LANG,
4564 CREATED_BY,
4565 CREATION_DATE,
4566 LAST_UPDATED_BY,
4567 LAST_UPDATE_DATE,
4568 LAST_UPDATE_LOGIN
4569 ) select
4570 p_region_application_id,
4571 p_region_code,
4572 p_attribute_application_id,
4573 p_attribute_code,
4574 L.LANGUAGE_CODE,
4575 l_attribute_label_long,
4576 l_attribute_label_short,
4577 l_description,
4578 decode(L.LANGUAGE_CODE, l_lang, L.LANGUAGE_CODE, l_lang),
4579 l_created_by,
4580 l_creation_date,
4581 l_last_updated_by,
4582 l_last_update_date,
4583 l_last_update_login
4584 from FND_LANGUAGES L
4585 where L.INSTALLED_FLAG in ('I', 'B')
4586 and not exists
4587 (select NULL
4588 from AK_REGION_ITEMS_TL T
4589 where T.REGION_APPLICATION_ID = p_region_application_id
4590 and T.REGION_CODE = p_region_code
4591 and T.ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
4592 and T.ATTRIBUTE_CODE = p_attribute_code
4593 and T.LANGUAGE = L.LANGUAGE_CODE);
4594 
4595 --  /** commit the insert **/
4596  commit;
4597 
4598 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
4599 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_CREATED');
4600 FND_MESSAGE.SET_TOKEN('OBJECT', 'AK_LC_REGION_ITEM',TRUE);
4601 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4602 ' ' || p_region_code ||
4603 ' ' || to_char(p_attribute_application_id) ||
4604 ' ' || p_attribute_code);
4605 FND_MSG_PUB.Add;
4606 end if;
4607 
4608 p_return_status := FND_API.G_RET_STS_SUCCESS;
4609 
4610 FND_MSG_PUB.Count_And_Get (
4611 p_count => p_msg_count,
4612 p_data => p_msg_data);
4613 
4614 EXCEPTION
4615 WHEN VALUE_ERROR THEN
4616 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
4617 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_VALUE_ERROR');
4618 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4619 ' ' || p_region_code ||
4620 ' ' || to_char(p_attribute_application_id) ||
4621 ' ' || p_attribute_code);
4622 FND_MSG_PUB.Add;
4623 end if;
4624 p_return_status := FND_API.G_RET_STS_ERROR;
4625 rollback to start_create_item;
4626 FND_MSG_PUB.Count_And_Get (
4627 p_count => p_msg_count,
4628 p_data => p_msg_data);
4629 WHEN FND_API.G_EXC_ERROR THEN
4630 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
4631 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_CREATED');
4632 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
4633 ' ' || p_region_code ||
4634 ' ' || to_char(p_attribute_application_id) ||
4635 ' ' || p_attribute_code);
4636 FND_MSG_PUB.Add;
4637 end if;
4638 p_return_status := FND_API.G_RET_STS_ERROR;
4639 rollback to start_create_item;
4640 FND_MSG_PUB.Count_And_Get (
4641 p_count => p_msg_count,
4642 p_data => p_msg_data);
4643 WHEN OTHERS THEN
4644     if (SQLCODE = -1) then
4645         rollback to start_create_item;
4646         AK_REGION_PVT.UPDATE_ITEM (
4647           p_validation_level => p_validation_level,
4648           p_api_version_number => 1.0,
4649           p_msg_count => p_msg_count,
4650           p_msg_data => p_msg_data,
4651           p_return_status => p_return_status,
4652           p_region_application_id => p_region_application_id,
4653           p_region_code => p_region_code,
4654           p_attribute_application_id => p_attribute_application_id,
4655           p_attribute_code => p_attribute_code,
4656           p_display_sequence => p_display_sequence,
4657           p_node_display_flag => p_node_display_flag,
4658           p_node_query_flag => p_node_query_flag,
4659           p_attribute_label_length => p_attribute_label_length,
4660           p_display_value_length => p_display_value_length,
4661           p_bold => p_bold,
4662           p_italic => p_italic,
4663           p_vertical_alignment => p_vertical_alignment,
4664           p_horizontal_alignment => p_horizontal_alignment,
4665           p_item_style => p_item_style,
4666           p_object_attribute_flag => p_object_attribute_flag,
4667           p_icx_custom_call => p_icx_custom_call,
4668           p_update_flag => p_update_flag,
4669           p_required_flag => p_required_flag,
4670           p_security_code => p_security_code,
4671           p_default_value_varchar2 => p_default_value_varchar2,
4672           p_default_value_number => p_default_value_number,
4673           p_default_value_date => p_default_value_date,
4674           p_lov_region_application_id => p_lov_region_application_id,
4675           p_lov_region_code => p_lov_region_code,
4676           p_lov_foreign_key_name => p_lov_foreign_key_name,
4677           p_lov_attribute_application_id => p_lov_attribute_application_id,
4678           p_lov_attribute_code => p_lov_attribute_code,
4679           p_lov_default_flag => p_lov_default_flag,
4680           p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
4681           p_region_defaulting_api_proc => p_region_defaulting_api_proc,
4682           p_region_validation_api_pkg => p_region_validation_api_pkg,
4683           p_region_validation_api_proc => p_region_validation_api_proc,
4684           p_order_sequence => p_order_sequence,
4685           p_order_direction => p_order_direction,
4686           p_display_height => p_display_height,
4687           p_submit => p_submit,
4688           p_encrypt => p_encrypt,
4689           p_css_class_name => p_css_class_name,
4690           p_view_usage_name => p_view_usage_name,
4691           p_view_attribute_name => p_view_attribute_name,
4692           p_nested_region_appl_id => p_nested_region_appl_id,
4693           p_nested_region_code => p_nested_region_code,
4694           p_url => p_url,
4695           p_poplist_viewobject => p_poplist_viewobject,
4696           p_poplist_display_attr => p_poplist_display_attr,
4697           p_poplist_value_attr => p_poplist_value_attr,
4698           p_image_file_name => p_image_file_name,
4699           p_item_name => p_item_name,
4700           p_css_label_class_name => p_css_label_class_name,
4701           p_menu_name => p_menu_name,
4702           p_flexfield_name => p_flexfield_name,
4703           p_flexfield_application_id => p_flexfield_application_id,
4704           p_tabular_function_code    => p_tabular_function_code,
4705           p_tip_type                 => p_tip_type,
4706           p_tip_message_name         => p_tip_message_name,
4707           p_tip_message_application_id  => p_tip_message_application_id ,
4708           p_flex_segment_list        => p_flex_segment_list,
4709           p_entity_id  => p_entity_id,
4710           p_anchor     => p_anchor,
4711           p_poplist_view_usage_name => p_poplist_view_usage_name,
4712           p_user_customizable => p_user_customizable,
4713           p_sortby_view_attribute_name => p_sortby_view_attribute_name,
4714           p_admin_customizable => p_admin_customizable,
4715           p_invoke_function_name => p_invoke_function_name,
4716           p_expansion => p_expansion,
4717           p_als_max_length => p_als_max_length,
4718           p_initial_sort_sequence => p_initial_sort_sequence,
4719           p_customization_application_id => p_customization_application_id,
4720           p_customization_code => p_customization_code,
4721           p_attribute_category => p_attribute_category,
4722           p_attribute1 => p_attribute1,
4723           p_attribute2 => p_attribute2,
4724           p_attribute3 => p_attribute3,
4725           p_attribute4 => p_attribute4,
4726           p_attribute5 => p_attribute5,
4727           p_attribute6 => p_attribute6,
4728           p_attribute7 => p_attribute7,
4729           p_attribute8 => p_attribute8,
4730           p_attribute9 => p_attribute9,
4731           p_attribute10 => p_attribute10,
4732           p_attribute11 => p_attribute11,
4733           p_attribute12 => p_attribute12,
4734           p_attribute13 => p_attribute13,
4735           p_attribute14 => p_attribute14,
4736           p_attribute15 => p_attribute15,
4737           p_attribute_label_long => p_attribute_label_long,
4738           p_attribute_label_short => p_attribute_label_short,
4739           p_description => p_description,
4740           p_created_by => p_created_by,
4741           p_creation_date => p_creation_date,
4742           p_last_updated_by => p_last_updated_by,
4743           p_last_update_date => p_last_update_date,
4744           p_last_update_login => p_last_update_login,
4745           p_loader_timestamp => p_loader_timestamp,
4746           p_pass => p_pass,
4747           p_copy_redo_flag => p_copy_redo_flag
4748           );
4749        else
4750 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4751 rollback to start_create_item;
4752 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
4753 SUBSTR (SQLERRM, 1, 240) );
4754 FND_MSG_PUB.Add;
4755 FND_MSG_PUB.Count_And_Get (
4756 p_count => p_msg_count,
4757 p_data => p_msg_data);
4758 end if;
4759 end CREATE_ITEM;
4760 
4761 --=======================================================
4762 --  Procedure   CREATE_REGION
4763 --
4764 --  Usage       Private API for creating a region. This
4765 --              API should only be called by other APIs that are
4766 --              owned by the Core Modules Team (AK).
4767 --
4768 --  Desc        Creates a region using the given info.
4769 --              This API should only be called by other APIs that are
4770 --              owned by the Core Modules Team (AK).
4771 --
4772 --  Results     The API returns the standard p_return_status parameter
4773 --              indicating one of the standard return statuses :
4774 --                  * Unexpected error
4775 --                  * Error
4776 --                  * Success
4777 --  Parameters  Region columns
4778 --              p_loader_timestamp : IN optional
4779 --                  If a timestamp is passed, the API will create the
4780 --                  record using this timestamp. Only the upload API
4781 --                  should call with this parameter loaded.
4782 --
4783 --  Version     Initial version number  =   1.0
4784 --  History     Current version number  =   1.0
4785 --=======================================================
4786 procedure CREATE_REGION (
4787 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
4788 p_api_version_number       IN      NUMBER,
4789 p_init_msg_tbl             IN      BOOLEAN := FALSE,
4790 p_msg_count                OUT NOCOPY     NUMBER,
4791 p_msg_data                 OUT NOCOPY     VARCHAR2,
4792 p_return_status            OUT NOCOPY     VARCHAR2,
4793 p_region_application_id    IN      NUMBER,
4794 p_region_code              IN      VARCHAR2,
4795 p_database_object_name     IN      VARCHAR2,
4796 p_region_style             IN      VARCHAR2,
4797 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4798 p_num_columns              IN      NUMBER := FND_API.G_MISS_NUM,
4799 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
4800 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
4801 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
4802 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
4803 p_appmodule_object_type	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4804 p_num_rows_display		 IN		 NUMBER := FND_API.G_MISS_NUM,
4805 p_region_object_type		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4806 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4807 p_isform_flag				 IN		 VARCHAR2,
4808 p_help_target 			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4809 p_style_sheet_filename	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
4810 p_version                  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4811 p_applicationmodule_usage_name IN  VARCHAR2 := FND_API.G_MISS_CHAR,
4812 p_add_indexed_children     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4813 p_stateful_flag	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
4814 p_function_name            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4815 p_children_view_usage_name IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4816 p_search_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4817 p_advanced_search_panel    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4818 p_customize_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4819 p_default_search_panel     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4820 p_results_based_search     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4821 p_display_graph_table      IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4822 p_disable_header	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4823 p_standalone		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4824 p_auto_customization_criteria IN   VARCHAR2 := FND_API.G_MISS_CHAR,
4825 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4826 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4827 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4828 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4829 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4830 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4831 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4832 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4833 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4834 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4835 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4836 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4837 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4838 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4839 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4840 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4841 p_name                     IN      VARCHAR2,
4842 p_description              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
4843 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
4844 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
4845 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
4846 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
4847 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
4848 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
4849 p_pass                     IN      NUMBER,
4850 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
4851 ) is
4852 l_attribute_category VARCHAR2(30);
4853 l_attribute1         VARCHAR2(150);
4854 l_attribute2         VARCHAR2(150);
4855 l_attribute3         VARCHAR2(150);
4856 l_attribute4         VARCHAR2(150);
4857 l_attribute5         VARCHAR2(150);
4858 l_attribute6         VARCHAR2(150);
4859 l_attribute7         VARCHAR2(150);
4860 l_attribute8         VARCHAR2(150);
4861 l_attribute9         VARCHAR2(150);
4862 l_attribute10        VARCHAR2(150);
4863 l_attribute11        VARCHAR2(150);
4864 l_attribute12        VARCHAR2(150);
4865 l_attribute13        VARCHAR2(150);
4866 l_attribute14        VARCHAR2(150);
4867 l_attribute15        VARCHAR2(150);
4868 l_api_version_number CONSTANT number := 1.0;
4869 l_api_name           CONSTANT varchar2(30) := 'Create_Region';
4870 l_created_by         number;
4871 l_creation_date      date;
4872 l_description        VARCHAR2(2000) := null;
4873 l_icx_custom_call    VARCHAR2(80) := null;
4874 l_lang               varchar2(30);
4875 l_last_update_date   date;
4876 l_last_update_login  number;
4877 l_last_updated_by    number;
4878 l_num_columns        NUMBER := null;
4879 l_region_defaulting_api_pkg      VARCHAR2(30);
4880 l_region_defaulting_api_proc     VARCHAR2(30);
4881 l_region_validation_api_pkg      VARCHAR2(30);
4882 l_region_validation_api_proc     VARCHAR2(30);
4883 l_appmodule_object_type			VARCHAR2(240);
4884 l_num_rows_display				NUMBER;
4885 l_region_object_type				VARCHAR2(240);
4886 l_image_file_name					VARCHAR2(80);
4887 l_isform_flag						VARCHAR2(1) := 'N';
4888 l_help_target						VARCHAR2(240);
4889 l_style_sheet_filename			VARCHAR2(240);
4890 l_version							VARCHAR2(30);
4891 l_appmodule_usage_name	        VARCHAR2(80);
4892 l_add_indexed_children	        VARCHAR2(1);
4893 l_stateful_flag			VARCHAR2(1);
4894 l_function_name			VARCHAR2(30);
4895 l_children_view_usage_name		VARCHAR2(80);
4896 l_search_panel			VARCHAR2(1);
4897 l_advanced_search_panel		VARCHAR2(1);
4898 l_customize_panel			VARCHAR2(1);
4899 l_default_search_panel		VARCHAR2(30);
4900 l_results_based_search		VARCHAR2(1);
4901 l_display_graph_table			VARCHAR2(1);
4902 l_disable_header			VARCHAR2(1);
4903 l_standalone				VARCHAR2(1);
4904 l_auto_customization_criteria		VARCHAR2(1);
4905 l_return_status      varchar2(1);
4906 begin
4907 
4908 IF NOT FND_API.Compatible_API_Call (
4909 l_api_version_number, p_api_version_number, l_api_name,
4910 G_PKG_NAME) then
4911 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4912 return;
4913 END IF;
4914 
4915 -- Initialize the message table if requested.
4916 
4917 if p_init_msg_tbl then
4918 FND_MSG_PUB.initialize;
4919 end if;
4920 
4921 savepoint start_create_region;
4922 
4923 --** check to see if row already exists **
4924 if AK_REGION_PVT.REGION_EXISTS (
4925 p_api_version_number => 1.0,
4926 p_return_status => l_return_status,
4927 p_region_application_id => p_region_application_id,
4928 p_region_code => p_region_code) then
4929 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
4930 FND_MESSAGE.SET_NAME('AK','AK_REGION_EXISTS');
4931 FND_MSG_PUB.Add;
4932 end if;
4933 -- dbms_output.put_line(G_PKG_NAME || 'Error - Row already exists');
4934 raise FND_API.G_EXC_ERROR;
4935 end if;
4936 
4937 --** validate table columns passed in **
4938 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
4939 if not AK_REGION_PVT.VALIDATE_REGION (
4940 p_validation_level => p_validation_level,
4941 p_api_version_number => 1.0,
4942 p_return_status => l_return_status,
4943 p_region_application_id => p_region_application_id,
4944 p_region_code => p_region_code,
4945 p_database_object_name => p_database_object_name,
4946 p_region_style => p_region_style,
4947 p_icx_custom_call => p_icx_custom_call,
4948 p_num_columns => p_num_columns,
4949 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
4950 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
4951 p_region_validation_api_pkg => p_region_validation_api_pkg,
4952 p_region_validation_api_proc => p_region_validation_api_proc,
4953 p_name => p_name,
4954 p_description => p_description,
4955 p_caller => AK_ON_OBJECTS_PVT.G_CREATE,
4956 p_pass => p_pass
4957 ) then
4958 -- Do not raise an error if it's the first pass
4959 if (p_pass = 1) then
4960 p_copy_redo_flag := TRUE;
4961 else
4962 raise FND_API.G_EXC_ERROR;
4963 end if;
4964 end if;
4965 end if;
4966 
4967 --** Load non-required columns if their values are given **
4968 if (p_description <> FND_API.G_MISS_CHAR) then
4969 l_description := p_description;
4970 end if;
4971 
4972 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) then
4973 l_icx_custom_call := p_icx_custom_call;
4974 end if;
4975 
4976 if (p_num_columns <> FND_API.G_MISS_NUM) then
4977 l_num_columns := p_num_columns;
4978 end if;
4979 
4980 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
4981 l_region_defaulting_api_pkg := p_region_defaulting_api_pkg;
4982 end if;
4983 
4984 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
4985 l_region_defaulting_api_proc := p_region_defaulting_api_proc;
4986 end if;
4987 
4988 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
4989 l_region_validation_api_pkg := p_region_validation_api_pkg;
4990 end if;
4991 
4992 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
4993 l_region_validation_api_proc := p_region_validation_api_proc;
4994 end if;
4995 
4996 if (p_appmodule_object_type <> FND_API.G_MISS_CHAR) then
4997 l_appmodule_object_type := p_appmodule_object_type;
4998 end if;
4999 
5000 if (p_num_rows_display <> FND_API.G_MISS_NUM) then
5001 l_num_rows_display := p_num_rows_display;
5002 end if;
5003 
5004 if (p_region_object_type <> FND_API.G_MISS_CHAR) then
5005 l_region_object_type := p_region_object_type;
5006 end if;
5007 
5008 if (p_image_file_name <> FND_API.G_MISS_CHAR) then
5009 l_image_file_name := p_image_file_name;
5010 end if;
5011 
5012 if (p_isform_flag <> FND_API.G_MISS_CHAR) then
5013 l_isform_flag := p_isform_flag;
5014 end if;
5015 
5016 if (p_help_target <> FND_API.G_MISS_CHAR) then
5017 l_help_target := p_help_target;
5018 end if;
5019 
5020 if (p_style_sheet_filename <> FND_API.G_MISS_CHAR) then
5021 l_style_sheet_filename := p_style_sheet_filename;
5022 end if;
5023 
5024 if (p_version <> FND_API.G_MISS_CHAR) then
5025 l_version := p_version;
5026 end if;
5027 
5028 if (p_applicationmodule_usage_name <> FND_API.G_MISS_CHAR) then
5029 l_appmodule_usage_name := p_applicationmodule_usage_name;
5030 end if;
5031 
5032 if (p_add_indexed_children <> FND_API.G_MISS_CHAR) then
5033 l_add_indexed_children := p_add_indexed_children;
5034 end if;
5035 
5036 if (p_stateful_flag <> FND_API.G_MISS_CHAR) then
5037 l_stateful_flag := p_stateful_flag;
5038 end if;
5039 
5040 if (p_function_name <> FND_API.G_MISS_CHAR) then
5041 l_function_name := p_function_name;
5042 end if;
5043 
5044 if (p_children_view_usage_name <> FND_API.G_MISS_CHAR) then
5045 l_children_view_usage_name := p_children_view_usage_name;
5046 end if;
5047 
5048 if (p_search_panel <> FND_API.G_MISS_CHAR) then
5049 l_search_panel := p_search_panel;
5050 end if;
5051 
5052 if (p_advanced_search_panel <> FND_API.G_MISS_CHAR) then
5053 l_advanced_search_panel := p_advanced_search_panel;
5054 end if;
5055 
5056 if (p_customize_panel <> FND_API.G_MISS_CHAR) then
5057 l_customize_panel := p_customize_panel;
5058 end if;
5059 
5060 if (p_default_search_panel <> FND_API.G_MISS_CHAR) then
5061 l_default_search_panel := p_default_search_panel;
5062 end if;
5063 
5064 if (p_results_based_search <> FND_API.G_MISS_CHAR) then
5065 l_results_based_search := p_results_based_search;
5066 end if;
5067 
5068 if (p_display_graph_table <> FND_API.G_MISS_CHAR) then
5069 l_display_graph_table := p_display_graph_table;
5070 end if;
5071 
5072 if (p_disable_header <> FND_API.G_MISS_CHAR) then
5073 l_disable_header := p_disable_header;
5074 end if;
5075 
5076 -- standalone is now a non-null column and it should have default value sets to 'Y'
5077 if (p_standalone <> FND_API.G_MISS_CHAR and p_standalone is not null) then
5078 l_standalone := p_standalone;
5079 else
5080 l_standalone := 'Y';
5081 end if;
5082 
5083 if (p_auto_customization_criteria <> FND_API.G_MISS_CHAR) then
5084 l_auto_customization_criteria := p_auto_customization_criteria;
5085 end if;
5086 
5087 if (p_attribute_category <> FND_API.G_MISS_CHAR) then
5088 l_attribute_category := p_attribute_category;
5089 end if;
5090 
5091 if (p_attribute1 <> FND_API.G_MISS_CHAR) then
5092 l_attribute1 := p_attribute1;
5093 end if;
5094 
5095 if (p_attribute2 <> FND_API.G_MISS_CHAR) then
5096 l_attribute2 := p_attribute2;
5097 end if;
5098 
5099 if (p_attribute3 <> FND_API.G_MISS_CHAR) then
5100 l_attribute3 := p_attribute3;
5101 end if;
5102 
5103 if (p_attribute4 <> FND_API.G_MISS_CHAR) then
5104 l_attribute4 := p_attribute4;
5105 end if;
5106 
5107 if (p_attribute5 <> FND_API.G_MISS_CHAR) then
5108 l_attribute5 := p_attribute5;
5109 end if;
5110 
5111 if (p_attribute6 <> FND_API.G_MISS_CHAR) then
5112 l_attribute6 := p_attribute6;
5113 end if;
5114 
5115 if (p_attribute7 <> FND_API.G_MISS_CHAR) then
5116 l_attribute7:= p_attribute7;
5117 end if;
5118 
5119 if (p_attribute8 <> FND_API.G_MISS_CHAR) then
5120 l_attribute8 := p_attribute8;
5121 end if;
5122 
5123 if (p_attribute9 <> FND_API.G_MISS_CHAR) then
5124 l_attribute9 := p_attribute9;
5125 end if;
5126 
5127 if (p_attribute10 <> FND_API.G_MISS_CHAR) then
5128 l_attribute10 := p_attribute10;
5129 end if;
5130 
5131 if (p_attribute11 <> FND_API.G_MISS_CHAR) then
5132 l_attribute11 := p_attribute11;
5133 end if;
5134 
5135 if (p_attribute12 <> FND_API.G_MISS_CHAR) then
5136 l_attribute12 := p_attribute12;
5137 end if;
5138 
5139 if (p_attribute13 <> FND_API.G_MISS_CHAR) then
5140 l_attribute13 := p_attribute13;
5141 end if;
5142 
5143 if (p_attribute14 <> FND_API.G_MISS_CHAR) then
5144 l_attribute14 := p_attribute14;
5145 end if;
5146 
5147 if (p_attribute15 <> FND_API.G_MISS_CHAR) then
5148 l_attribute15 := p_attribute15;
5149 end if;
5150 
5151   if (p_created_by <> FND_API.G_MISS_NUM) then
5152     l_created_by := p_created_by;
5153   end if;
5154 
5155   if (p_creation_date <> FND_API.G_MISS_DATE) then
5156     l_creation_date := p_creation_date;
5157   end if;
5158 
5159   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
5160     l_last_updated_by := p_last_updated_by;
5161   end if;
5162 
5163   if (p_last_update_date <> FND_API.G_MISS_DATE) then
5164     l_last_update_date := p_last_update_date;
5165   end if;
5166 
5167   if (p_last_update_login <> FND_API.G_MISS_NUM) then
5168     l_last_update_login := p_last_update_login;
5169   end if;
5170 
5171 -- Create record if no validation error was found
5172   --  NOTE - Calling IS_UPDATEABLE for backward compatibility
5173   --  old jlt files didn't have who columns and IS_UPDATEABLE
5174   --  calls SET_WHO which populates those columns, for later
5175   --  jlt files IS_UPDATEABLE will always return TRUE for CREATE
5176 
5177 if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
5178        p_loader_timestamp => p_loader_timestamp,
5179        p_created_by => l_created_by,
5180        p_creation_date => l_creation_date,
5181        p_last_updated_by => l_last_updated_by,
5182        p_db_last_updated_by => null,
5183        p_last_update_date => l_last_update_date,
5184        p_db_last_update_date => null,
5185        p_last_update_login => l_last_update_login,
5186        p_create_or_update => 'CREATE') then
5187      null;
5188   end if;
5189 
5190 select userenv('LANG') into l_lang
5191 from dual;
5192 
5193 insert into AK_REGIONS (
5194 REGION_APPLICATION_ID,
5195 REGION_CODE,
5196 DATABASE_OBJECT_NAME,
5197 REGION_STYLE,
5198 ICX_CUSTOM_CALL,
5199 NUM_COLUMNS,
5200 REGION_DEFAULTING_API_PKG,
5201 REGION_DEFAULTING_API_PROC,
5202 REGION_VALIDATION_API_PKG,
5203 REGION_VALIDATION_API_PROC,
5204 APPLICATIONMODULE_OBJECT_TYPE,
5205 NUM_ROWS_DISPLAY,
5206 REGION_OBJECT_TYPE,
5207 IMAGE_FILE_NAME,
5208 ISFORM_FLAG,
5209 HELP_TARGET,
5210 STYLE_SHEET_FILENAME,
5211 VERSION,
5212 APPLICATIONMODULE_USAGE_NAME,
5213 ADD_INDEXED_CHILDREN,
5214 STATEFUL_FLAG,
5215 FUNCTION_NAME,
5216 CHILDREN_VIEW_USAGE_NAME,
5217 SEARCH_PANEL,
5218 ADVANCED_SEARCH_PANEL,
5219 CUSTOMIZE_PANEL,
5220 DEFAULT_SEARCH_PANEL,
5221 RESULTS_BASED_SEARCH,
5222 DISPLAY_GRAPH_TABLE,
5223 DISABLE_HEADER,
5224 STANDALONE,
5225 AUTO_CUSTOMIZATION_CRITERIA,
5226 ATTRIBUTE_CATEGORY,
5227 ATTRIBUTE1,
5228 ATTRIBUTE2,
5229 ATTRIBUTE3,
5230 ATTRIBUTE4,
5231 ATTRIBUTE5,
5232 ATTRIBUTE6,
5233 ATTRIBUTE7,
5234 ATTRIBUTE8,
5235 ATTRIBUTE9,
5236 ATTRIBUTE10,
5237 ATTRIBUTE11,
5238 ATTRIBUTE12,
5239 ATTRIBUTE13,
5240 ATTRIBUTE14,
5241 ATTRIBUTE15,
5242 CREATION_DATE,
5243 CREATED_BY,
5244 LAST_UPDATE_DATE,
5245 LAST_UPDATED_BY,
5246 LAST_UPDATE_LOGIN
5247 ) values (
5248 p_region_application_id,
5249 p_region_code,
5250 p_database_object_name,
5251 p_region_style,
5252 l_icx_custom_call,
5253 l_num_columns,
5254 l_region_defaulting_api_pkg,
5255 l_region_defaulting_api_proc,
5256 l_region_validation_api_pkg,
5257 l_region_validation_api_proc,
5258 l_appmodule_object_type,
5259 l_num_rows_display,
5260 l_region_object_type,
5261 l_image_file_name,
5262 l_isform_flag,
5263 l_help_target,
5264 l_style_sheet_filename,
5265 l_version,
5266 l_appmodule_usage_name,
5267 l_add_indexed_children,
5268 l_stateful_flag,
5269 l_function_name,
5270 l_children_view_usage_name,
5271 l_search_panel,
5272 l_advanced_search_panel,
5273 l_customize_panel,
5274 l_default_search_panel,
5275 l_results_based_search,
5276 l_display_graph_table,
5277 l_disable_header,
5278 l_standalone,
5279 l_auto_customization_criteria,
5280 l_attribute_category,
5281 l_attribute1,
5282 l_attribute2,
5283 l_attribute3,
5284 l_attribute4,
5285 l_attribute5,
5286 l_attribute6,
5287 l_attribute7,
5288 l_attribute8,
5289 l_attribute9,
5290 l_attribute10,
5291 l_attribute11,
5292 l_attribute12,
5293 l_attribute13,
5294 l_attribute14,
5295 l_attribute15,
5296 l_creation_date,
5297 l_created_by,
5298 l_last_update_date,
5299 l_last_updated_by,
5300 l_last_update_login
5301 );
5302 
5303 --** row should exists before inserting rows for other languages **
5304 if NOT AK_REGION_PVT.REGION_EXISTS (
5305 p_api_version_number => 1.0,
5306 p_return_status => l_return_status,
5307 p_region_application_id => p_region_application_id,
5308 p_region_code => p_region_code) then
5309 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5310 FND_MESSAGE.SET_NAME('AK','AK_INSERT_REGION_FAILED');
5311 FND_MSG_PUB.Add;
5312 end if;
5313 -- dbms_output.put_line(G_PKG_NAME || 'Error - First insert failed');
5314 raise FND_API.G_EXC_ERROR;
5315 end if;
5316 
5317 insert into AK_REGIONS_TL (
5318 REGION_APPLICATION_ID,
5319 REGION_CODE,
5320 LANGUAGE,
5321 NAME,
5322 DESCRIPTION,
5323 SOURCE_LANG,
5324 CREATED_BY,
5325 CREATION_DATE,
5326 LAST_UPDATED_BY,
5327 LAST_UPDATE_DATE,
5328 LAST_UPDATE_LOGIN
5329 ) select
5330 p_region_application_id,
5331 p_region_code,
5332 L.LANGUAGE_CODE,
5333 p_name,
5334 l_description,
5335 decode(L.LANGUAGE_CODE, l_lang, L.LANGUAGE_CODE, l_lang),
5336 l_created_by,
5337 l_creation_date,
5338 l_last_updated_by,
5339 l_last_update_date,
5340 l_last_update_login
5341 from FND_LANGUAGES L
5342 where L.INSTALLED_FLAG in ('I', 'B')
5343 and not exists
5344 (select NULL
5345 from AK_REGIONS_TL T
5346 where T.REGION_APPLICATION_ID = p_region_application_id
5347 and T.REGION_CODE = p_region_code
5348 and T.LANGUAGE = L.LANGUAGE_CODE);
5349 
5350 --  /** commit the insert **/
5351  commit;
5352 
5353 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
5354 FND_MESSAGE.SET_NAME('AK','AK_REGION_CREATED');
5355 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5356 ' ' || p_region_code);
5357 FND_MSG_PUB.Add;
5358 end if;
5359 
5360 p_return_status := FND_API.G_RET_STS_SUCCESS;
5361 
5362 FND_MSG_PUB.Count_And_Get (
5363 p_count => p_msg_count,
5364 p_data => p_msg_data);
5365 
5366 EXCEPTION
5367 WHEN VALUE_ERROR THEN
5368 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5369 FND_MESSAGE.SET_NAME('AK','AK_REGION_VALUE_ERROR');
5370 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5371 ' ' || p_region_code);
5372 FND_MSG_PUB.Add;
5373 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5374 SUBSTR (SQLERRM, 1, 240));
5375 FND_MSG_PUB.Add;
5376 end if;
5377 p_return_status := FND_API.G_RET_STS_ERROR;
5378 rollback to start_create_region;
5379 FND_MSG_PUB.Count_And_Get (
5380 p_count => p_msg_count,
5381 p_data => p_msg_data);
5382 WHEN FND_API.G_EXC_ERROR THEN
5383 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5384 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_CREATED');
5385 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5386 ' ' || p_region_code);
5387 FND_MSG_PUB.Add;
5388 end if;
5389 p_return_status := FND_API.G_RET_STS_ERROR;
5390 rollback to start_create_region;
5391 FND_MSG_PUB.Count_And_Get (
5392 p_count => p_msg_count,
5393 p_data => p_msg_data);
5394 WHEN OTHERS THEN
5395      if (SQLCODE = -1) then
5396         rollback to start_create_region;
5397          AK_REGION_PVT.UPDATE_REGION(
5398            p_validation_level => p_validation_level,
5399            p_api_version_number => 1.0,
5400            p_msg_count => p_msg_count,
5401            p_msg_data => p_msg_data,
5402            p_return_status => p_return_status,
5403            p_region_application_id => p_region_application_id,
5404            p_region_code => p_region_code,
5405            p_database_object_name =>p_database_object_name,
5406            p_region_style => p_region_style,
5407            p_num_columns => p_num_columns,
5408            p_icx_custom_call => p_icx_custom_call,
5409            p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
5410            p_region_defaulting_api_proc => p_region_defaulting_api_proc,
5411            p_region_validation_api_pkg => p_region_validation_api_pkg,
5412            p_region_validation_api_proc => p_region_validation_api_proc,
5413            p_appmodule_object_type => p_appmodule_object_type,
5414            p_num_rows_display => p_num_rows_display,
5415            p_region_object_type => p_region_object_type,
5416            p_image_file_name => p_image_file_name,
5417            p_isform_flag => p_isform_flag,
5418            p_help_target => p_help_target,
5419            p_style_sheet_filename => p_style_sheet_filename,
5420            p_version => p_version,
5421            p_applicationmodule_usage_name => p_applicationmodule_usage_name,
5422            p_add_indexed_children => p_add_indexed_children,
5423            p_stateful_flag => p_stateful_flag,
5424            p_function_name => p_function_name,
5425            p_children_view_usage_name => p_children_view_usage_name,
5426           p_search_panel => p_search_panel,
5427           p_advanced_search_panel => p_advanced_search_panel,
5428           p_customize_panel => p_customize_panel,
5429           p_default_search_panel => p_default_search_panel,
5430           p_results_based_search => p_results_based_search,
5431           p_display_graph_table => p_display_graph_table,
5432           p_disable_header => p_disable_header,
5433           p_standalone => p_standalone,
5434           p_auto_customization_criteria => p_auto_customization_criteria,
5435            p_attribute_category => p_attribute_category,
5436            p_attribute1 => p_attribute1,
5437            p_attribute2 => p_attribute2,
5438            p_attribute3 => p_attribute3,
5439            p_attribute4 => p_attribute4,
5440            p_attribute5 => p_attribute5,
5441            p_attribute6 => p_attribute6,
5442            p_attribute7 => p_attribute7,
5443            p_attribute8 => p_attribute8,
5444            p_attribute9 => p_attribute9,
5445            p_attribute10 => p_attribute10,
5446            p_attribute11 => p_attribute11,
5447            p_attribute12 => p_attribute12,
5448            p_attribute13 => p_attribute13,
5449            p_attribute14 => p_attribute14,
5450            p_attribute15 => p_attribute15,
5451            p_name => p_name,
5452            p_description => p_description,
5453            p_created_by => p_created_by,
5454            p_creation_date => p_creation_date,
5455            p_last_updated_by => p_last_updated_by,
5456            p_last_update_date => p_last_update_date,
5457            p_last_update_login => p_last_update_login,
5458            p_loader_timestamp => p_loader_timestamp,
5459            p_pass => p_pass,
5460            p_copy_redo_flag => p_copy_redo_flag
5461            );
5462 else
5463 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5464 rollback to start_create_region;
5465 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5466 SUBSTR (SQLERRM, 1, 240) );
5467 FND_MSG_PUB.Add;
5468 FND_MSG_PUB.Count_And_Get (
5469 p_count => p_msg_count,
5470 p_data => p_msg_data);
5471 end if;
5472 end CREATE_REGION;
5473 
5474 /*
5475 --=======================================================
5476 --  Procedure   DELETE_GRAPH
5477 --
5478 --  Usage       Private API for deleting a region graph. This
5479 --              API should only be called by other APIs that are
5480 --              owned by the Core Modules Team (AK).
5481 --
5482 --  Desc        Deletes a region item with the given key value.
5483 --
5484 --  Results     The API returns the standard p_return_status parameter
5485 --              indicating one of the standard return statuses :
5486 --                  * Unexpected error
5487 --                  * Error
5488 --                  * Success
5489 --  Parameters  p_region_application_id : IN required
5490 --              p_region_code : IN required
5491 --              p_attribute_application_id : IN required
5492 --              p_attribute_code : IN required
5493 --                  Key value of the region item to be deleted.
5494 --              p_delete_cascade : IN required
5495 --                  If p_delete_cascade flag is 'Y', also delete all
5496 --                  rows in other tables that references this record.
5497 --                  Otherwise, this record will not be deleted if there
5498 --                  are any other rows referencing it.
5499 --
5500 --  Version     Initial version number  =   1.0
5501 --  History     Current version number  =   1.0
5502 --=======================================================
5503 procedure DELETE_GRAPH (
5504 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
5505 p_api_version_number       IN      NUMBER,
5506 p_init_msg_tbl             IN      BOOLEAN := FALSE,
5507 p_msg_count                OUT NOCOPY     NUMBER,
5508 p_msg_data                 OUT NOCOPY     VARCHAR2,
5509 p_return_status            OUT NOCOPY     VARCHAR2,
5510 p_region_application_id    IN      NUMBER,
5511 p_region_code              IN      VARCHAR2,
5512 p_graph_number	     IN	     NUMBER,
5513 p_delete_cascade           IN      VARCHAR2
5514 ) is
5515 cursor l_get_graph_column_csr is
5516 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
5517 from AK_REGION_GRAPH_COLUMNS
5518 where region_application_id = p_region_application_id
5519 and region_code = p_region_code
5520 and graph_number = p_graph_number;
5521 l_api_version_number    CONSTANT number := 1.0;
5522 l_api_name              CONSTANT varchar2(30):= 'Delete_Item';
5523 l_msg_count             NUMBER;
5524 l_msg_data              VARCHAR2(2000);
5525 l_attribute_application_id	NUMBER;
5526 l_attribute_code		VARCHAR2(30);
5527 l_return_status		VARCHAR2(1);
5528 begin
5529 IF NOT FND_API.Compatible_API_Call (
5530 l_api_version_number, p_api_version_number, l_api_name,
5531 G_PKG_NAME) then
5532 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5533 return;
5534 END IF;
5535 
5536 -- Initialize the message table if requested.
5537 
5538 if p_init_msg_tbl then
5539 FND_MSG_PUB.initialize;
5540 end if;
5541 
5542 savepoint start_delete_graph;
5543 
5544 --
5545 -- error if region item to be deleted does not exists
5546 --
5547 if NOT AK_REGION_PVT.GRAPH_EXISTS (
5548 p_api_version_number => 1.0,
5549 p_return_status => l_return_status,
5550 p_region_application_id => p_region_application_id,
5551 p_region_code => p_region_code,
5552 p_graph_number => p_graph_number) then
5553 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5554 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5555 FND_MSG_PUB.Add;
5556 end if;
5557 raise FND_API.G_EXC_ERROR;
5558 end if;
5559 
5560 if (p_delete_cascade = 'N') then
5561 --
5562 -- If we are not deleting any referencing records, we cannot
5563 -- delete the region item if it is being referenced in any of
5564 -- following tables.
5565 --
5566 -- AK_REGION_GRAPH_COLUMNS
5567 --
5568 open l_get_graph_column_csr;
5569 fetch l_get_graph_column_csr into l_attribute_application_id,
5570 l_attribute_code;
5571 if l_get_graph_column_csr%found then
5572 close l_get_graph_column_csr;
5573 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5574 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
5575 FND_MSG_PUB.Add;
5576 end if;
5577 raise FND_API.G_EXC_ERROR;
5578 end if;
5579 close l_get_graph_column_csr;
5580 --  else
5581 end if;
5582 --
5583 -- Otherwise, delete all referencing rows in other tables
5584 --
5585 -- AK_REGION_GRAPH_COLUMNS
5586 -- LOOK AT AK_FLOW_PVT.DELETE_PAGE_REGION_ITEM to write this code
5587 --    open l_get_graph_column_csr;
5588 --    loop
5589 --      fetch l_get_graph_column_csr into l_attribute_application_id,
5590 --					l_attribute_code;
5591 --      exit when l_get_graph_column_csr%notfound;
5592 --      AK_REGION2_PVT.DELETE_GRAPH_COLUMN(
5593 --        p_validation_level => p_validation_level,
5594 --        p_api_version_number => 1.0,
5595 --        p_msg_count => l_msg_count,
5596 --        p_msg_data => l_msg_data,
5597 --        p_return_status => l_return_status,
5598 --        p_region_application_id => p_region_application_id,
5599 --        p_region_code => p_region_code,
5600 --	p_graph_number => p_graph_number,
5601 --	p_attribute_application_id => l_attribute_application_id,
5602 --        p_attribute_code => l_attribute_code
5603 --      );
5604 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
5605 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
5606 --        close l_get_graph_column_csr;
5607 --        raise FND_API.G_EXC_ERROR;
5608 --      end if;
5609 --    end loop;
5610 --    close l_get_graph_column_csr;
5611 --  end if;
5612 
5613 --
5614 -- delete region graph once we checked that there are no references
5615 -- to it, or all references have been deleted.
5616 --
5617 delete from ak_region_graphs
5618 where region_application_id = p_region_application_id
5619 and    region_code = p_region_code
5620 and    graph_number = p_graph_number;
5621 
5622 if (sql%notfound) then
5623 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5624 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5625 FND_MSG_PUB.Add;
5626 end if;
5627 raise FND_API.G_EXC_ERROR;
5628 end if;
5629 
5630 delete from ak_region_graphs_tl
5631 where  region_application_id = p_region_application_id
5632 and    region_code = p_region_code
5633 and    graph_number = p_graph_number;
5634 
5635 if (sql%notfound) then
5636 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5637 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
5638 FND_MSG_PUB.Add;
5639 end if;
5640 raise FND_API.G_EXC_ERROR;
5641 end if;
5642 
5643 --
5644 -- Load success message
5645 --
5646 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
5647 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DELETED');
5648 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5649 ' ' || p_region_code ||
5650 ' ' || p_graph_number);
5651 FND_MSG_PUB.Add;
5652 end if;
5653 
5654 p_return_status := FND_API.G_RET_STS_SUCCESS;
5655 
5656 FND_MSG_PUB.Count_And_Get (
5657 p_count => p_msg_count,
5658 p_data => p_msg_data);
5659 
5660 EXCEPTION
5661 WHEN FND_API.G_EXC_ERROR THEN
5662 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5663 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_DELETED');
5664 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5665 ' ' || p_region_code ||
5666 ' ' || p_graph_number);
5667 FND_MSG_PUB.Add;
5668 end if;
5669 p_return_status := FND_API.G_RET_STS_ERROR;
5670 rollback to start_delete_graph;
5671 FND_MSG_PUB.Count_And_Get (
5672 p_count => p_msg_count,
5673 p_data => p_msg_data);
5674 WHEN OTHERS THEN
5675 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5676 rollback to start_delete_graph;
5677 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5678 SUBSTR (SQLERRM, 1, 240) );
5679 FND_MSG_PUB.Add;
5680 FND_MSG_PUB.Count_And_Get (
5681 p_count => p_msg_count,
5682 p_data => p_msg_data);
5683 end DELETE_GRAPH;
5684 */
5685 
5686 --=======================================================
5687 --  Procedure   DELETE_ITEM
5688 --
5689 --  Usage       Private API for deleting a region item. This
5690 --              API should only be called by other APIs that are
5691 --              owned by the Core Modules Team (AK).
5692 --
5693 --  Desc        Deletes a region item with the given key value.
5694 --
5695 --  Results     The API returns the standard p_return_status parameter
5696 --              indicating one of the standard return statuses :
5697 --                  * Unexpected error
5698 --                  * Error
5699 --                  * Success
5700 --  Parameters  p_region_application_id : IN required
5701 --              p_region_code : IN required
5702 --              p_attribute_application_id : IN required
5703 --              p_attribute_code : IN required
5704 --                  Key value of the region item to be deleted.
5705 --              p_delete_cascade : IN required
5706 --                  If p_delete_cascade flag is 'Y', also delete all
5707 --                  rows in other tables that references this record.
5708 --                  Otherwise, this record will not be deleted if there
5709 --                  are any other rows referencing it.
5710 --
5711 --  Version     Initial version number  =   1.0
5712 --  History     Current version number  =   1.0
5713 --=======================================================
5714 procedure DELETE_ITEM (
5715 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
5716 p_api_version_number       IN      NUMBER,
5717 p_init_msg_tbl             IN      BOOLEAN := FALSE,
5718 p_msg_count                OUT NOCOPY     NUMBER,
5719 p_msg_data                 OUT NOCOPY     VARCHAR2,
5720 p_return_status            OUT NOCOPY     VARCHAR2,
5721 p_region_application_id    IN      NUMBER,
5722 p_region_code              IN      VARCHAR2,
5723 p_attribute_application_id IN      NUMBER,
5724 p_attribute_code           IN      VARCHAR2,
5725 p_delete_cascade           IN      VARCHAR2
5726 ) is
5727 cursor l_get_lov_relations_csr is
5728 select LOV_REGION_APPL_ID, LOV_REGION_CODE, LOV_ATTRIBUTE_APPL_ID,
5729 LOV_ATTRIBUTE_CODE, BASE_ATTRIBUTE_APPL_ID, BASE_ATTRIBUTE_CODE,
5730 DIRECTION_FLAG, BASE_REGION_APPL_ID, BASE_REGION_CODE
5731 from AK_REGION_LOV_RELATIONS
5732 where region_application_id = p_region_application_id
5733 and   region_code = p_region_code
5734 and   attribute_application_id = p_attribute_application_id
5735 and   attribute_code = p_attribute_code;
5736 cursor l_get_category_usages_csr is
5737 select CATEGORY_ID
5738 from  AK_CATEGORY_USAGES
5739 where region_application_id = p_region_application_id
5740 and   region_code = p_region_code
5741 and   attribute_application_id = p_attribute_application_id
5742 and   attribute_code = p_attribute_code;
5743 cursor l_get_page_region_item_csr is
5744 select FLOW_APPLICATION_ID, FLOW_CODE, PAGE_APPLICATION_ID, PAGE_CODE
5745 from  AK_FLOW_PAGE_REGION_ITEMS
5746 where region_application_id = p_region_application_id
5747 and   region_code = p_region_code
5748 and   attribute_application_id = p_attribute_application_id
5749 and   attribute_code = p_attribute_code;
5750 l_api_version_number    CONSTANT number := 1.0;
5751 l_api_name              CONSTANT varchar2(30):= 'Delete_Item';
5752 l_msg_count             NUMBER;
5753 l_msg_data              VARCHAR2(2000);
5754 l_flow_application_id   NUMBER;
5755 l_flow_code             VARCHAR2(30);
5756 l_page_application_id   NUMBER;
5757 l_page_code             VARCHAR2(30);
5758 l_lov_region_appl_id    NUMBER;
5759 l_lov_region_code       VARCHAR2(30);
5760 l_base_attribute_appl_id NUMBER;
5761 l_base_attribute_code   VARCHAR2(30);
5762 l_direction_flag        VARCHAR2(30);
5763 l_base_region_appl_id	  NUMBER;
5764 l_base_region_code	  VARCHAR2(30);
5765 l_lov_attribute_appl_id NUMBER;
5766 l_lov_attribute_code    VARCHAR2(30);
5767 l_category_id	 	  NUMBER;
5768 l_return_status         varchar2(1);
5769 begin
5770 IF NOT FND_API.Compatible_API_Call (
5771 l_api_version_number, p_api_version_number, l_api_name,
5772 G_PKG_NAME) then
5773 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5774 return;
5775 END IF;
5776 
5777 -- Initialize the message table if requested.
5778 
5779 if p_init_msg_tbl then
5780 FND_MSG_PUB.initialize;
5781 end if;
5782 
5783 savepoint start_delete_item;
5784 
5785 --
5786 -- error if region item to be deleted does not exists
5787 --
5788 if NOT AK_REGION_PVT.ITEM_EXISTS (
5789 p_api_version_number => 1.0,
5790 p_return_status => l_return_status,
5791 p_region_application_id => p_region_application_id,
5792 p_region_code => p_region_code,
5793 p_attribute_application_id => p_attribute_application_id,
5794 p_attribute_code => p_attribute_code) then
5795 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5796 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5797 FND_MSG_PUB.Add;
5798 end if;
5799 raise FND_API.G_EXC_ERROR;
5800 end if;
5801 
5802 if (p_delete_cascade = 'N') then
5803 --
5804 -- If we are not deleting any referencing records, we cannot
5805 -- delete the region item if it is being referenced in any of
5806 -- following tables.
5807 --
5808 -- AK_FLOW_PAGE_REGION_ITEMS
5809 --
5810 open l_get_page_region_item_csr;
5811 fetch l_get_page_region_item_csr into l_flow_application_id, l_flow_code,
5812 l_page_application_id, l_page_code;
5813 if l_get_page_region_item_csr%found then
5814 close l_get_page_region_item_csr;
5815 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5816 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
5817 FND_MSG_PUB.Add;
5818 end if;
5819 raise FND_API.G_EXC_ERROR;
5820 end if;
5821 close l_get_page_region_item_csr;
5822 else
5823 --
5824 -- Otherwise, delete all referencing rows in other tables
5825 --
5826 -- AK_REGION_LOV_RELATIONS
5827 --
5828 open l_get_lov_relations_csr;
5829 loop
5830 fetch l_get_lov_relations_csr into l_lov_region_appl_id,
5831 l_lov_region_code, l_lov_attribute_appl_id, l_lov_attribute_code,
5832 l_base_attribute_appl_id, l_base_attribute_code, l_direction_flag,
5833 l_base_region_appl_id, l_base_region_code;
5834 exit when l_get_lov_relations_csr%notfound;
5835 delete from ak_region_lov_relations
5836 where  region_application_id = p_region_application_id
5837 and    region_code = p_region_code
5838 and    attribute_application_id = p_attribute_application_id
5839 and    attribute_code = p_attribute_code
5840 and    lov_region_appl_id = l_lov_region_appl_id
5841 and    lov_region_code = l_lov_region_code
5842 and    lov_attribute_appl_id = l_lov_attribute_appl_id
5843 and    lov_attribute_code = l_lov_attribute_code
5844 and    base_attribute_appl_id = l_base_attribute_appl_id
5845 and    base_attribute_code = l_base_attribute_code
5846 and    direction_flag = l_direction_flag
5847 and    base_region_appl_id = l_base_region_appl_id
5848 and    base_region_code = l_base_region_code;
5849 
5850 if (sql%notfound) then
5851 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5852 FND_MESSAGE.SET_NAME('AK','AK_LOV_REL_DOES_NOT_EXIST');
5853 FND_MSG_PUB.Add;
5854 end if;
5855 close l_get_lov_relations_csr;
5856 raise FND_API.G_EXC_ERROR;
5857 end if;
5858 end loop;
5859 close l_get_lov_relations_csr;
5860 
5861 --
5862 -- AK_CATEGORY_USAGES
5863 --
5864 open l_get_category_usages_csr;
5865 loop
5866 fetch l_get_category_usages_csr into l_category_id;
5867 exit when l_get_category_usages_csr%notfound;
5868 delete from ak_category_usages
5869 where  region_application_id = p_region_application_id
5870 and    region_code = p_region_code
5871 and    attribute_application_id = p_attribute_application_id
5872 and    attribute_code = p_attribute_code
5873 and    category_id = l_category_id;
5874 
5875 if (sql%notfound) then
5876 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5877 FND_MESSAGE.SET_NAME('AK','AK_CAT_USAGE_DOES_NOT_EXIST');
5878 FND_MSG_PUB.Add;
5879 end if;
5880 close l_get_category_usages_csr;
5881 raise FND_API.G_EXC_ERROR;
5882 end if;
5883 end loop;
5884 close l_get_category_usages_csr;
5885 
5886 --
5887 -- AK_FLOW_PAGE_REGION_ITEMS
5888 --
5889 --    open l_get_page_region_item_csr;
5890 --    loop
5891 --      fetch l_get_page_region_item_csr into l_flow_application_id, l_flow_code,
5892 --                                        l_page_application_id, l_page_code;
5893 --      exit when l_get_page_region_item_csr%notfound;
5894 --      AK_FLOW_PVT.DELETE_PAGE_REGION_ITEM (
5895 --        p_validation_level => p_validation_level,
5896 --        p_api_version_number => 1.0,
5897 --        p_msg_count => l_msg_count,
5898 --        p_msg_data => l_msg_data,
5899 --        p_return_status => l_return_status,
5900 --        p_flow_application_id => l_flow_application_id,
5901 --        p_flow_code => l_flow_code,
5902 --        p_page_application_id => l_page_application_id,
5903 --        p_page_code => l_page_code,
5904 --        p_region_application_id => p_region_application_id,
5905 --        p_region_code => p_region_code,
5906 --        p_attribute_application_id => p_attribute_application_id,
5907 --        p_attribute_code => p_attribute_code,
5908 --        p_delete_cascade => p_delete_cascade
5909 --      );
5910 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
5911 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
5912 --        close l_get_page_region_item_csr;
5913 --        raise FND_API.G_EXC_ERROR;
5914 --      end if;
5915 --    end loop;
5916 --    close l_get_page_region_item_csr;
5917 end if;
5918 
5919 --
5920 -- delete region item once we checked that there are no references
5921 -- to it, or all references have been deleted.
5922 --
5923 delete from ak_region_items
5924 where  region_application_id = p_region_application_id
5925 and    region_code = p_region_code
5926 and    attribute_application_id = p_attribute_application_id
5927 and    attribute_code = p_attribute_code;
5928 
5929 if (sql%notfound) then
5930 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5931 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5932 FND_MSG_PUB.Add;
5933 end if;
5934 raise FND_API.G_EXC_ERROR;
5935 end if;
5936 
5937 delete from ak_region_items_tl
5938 where  region_application_id = p_region_application_id
5939 and    region_code = p_region_code
5940 and    attribute_application_id = p_attribute_application_id
5941 and    attribute_code = p_attribute_code;
5942 
5943 if (sql%notfound) then
5944 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
5945 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
5946 FND_MSG_PUB.Add;
5947 end if;
5948 raise FND_API.G_EXC_ERROR;
5949 end if;
5950 
5951 --
5952 -- Load success message
5953 --
5954 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
5955 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DELETED');
5956 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5957 ' ' || p_region_code ||
5958 ' ' || to_char(p_attribute_application_id) ||
5959 ' ' || p_attribute_code);
5960 FND_MSG_PUB.Add;
5961 end if;
5962 
5963 p_return_status := FND_API.G_RET_STS_SUCCESS;
5964 
5965 FND_MSG_PUB.Count_And_Get (
5966 p_count => p_msg_count,
5967 p_data => p_msg_data);
5968 
5969 EXCEPTION
5970 WHEN FND_API.G_EXC_ERROR THEN
5971 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
5972 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_DELETED');
5973 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
5974 ' ' || p_region_code ||
5975 ' ' || to_char(p_attribute_application_id) ||
5976 ' ' || p_attribute_code);
5977 FND_MSG_PUB.Add;
5978 end if;
5979 p_return_status := FND_API.G_RET_STS_ERROR;
5980 rollback to start_delete_item;
5981 FND_MSG_PUB.Count_And_Get (
5982 p_count => p_msg_count,
5983 p_data => p_msg_data);
5984 WHEN OTHERS THEN
5985 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5986 rollback to start_delete_item;
5987 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
5988 SUBSTR (SQLERRM, 1, 240) );
5989 FND_MSG_PUB.Add;
5990 FND_MSG_PUB.Count_And_Get (
5991 p_count => p_msg_count,
5992 p_data => p_msg_data);
5993 end DELETE_ITEM;
5994 
5995 --=======================================================
5996 --  Procedure   DELETE_REGION
5997 --
5998 --  Usage       Private API for deleting a region. This
5999 --              API should only be called by other APIs that are
6000 --              owned by the Core Modules Team (AK).
6001 --
6002 --  Desc        Deletes a region with the given key value.
6003 --
6004 --  Results     The API returns the standard p_return_status parameter
6005 --              indicating one of the standard return statuses :
6006 --                  * Unexpected error
6007 --                  * Error
6008 --                  * Success
6009 --  Parameters  p_region_application_id : IN required
6010 --              p_region_code : IN required
6011 --                  Key value of the region to be deleted.
6012 --              p_delete_cascade : IN required
6013 --                  If p_delete_cascade flag is 'Y', also delete all
6014 --                  rows in other tables that references this record.
6015 --                  Otherwise, this record will not be deleted if there
6016 --                  are any other rows referencing it.
6017 --
6018 --  Version     Initial version number  =   1.0
6019 --  History     Current version number  =   1.0
6020 --=======================================================
6021 procedure DELETE_REGION (
6022 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
6023 p_api_version_number       IN      NUMBER,
6024 p_init_msg_tbl             IN      BOOLEAN := FALSE,
6025 p_msg_count                OUT NOCOPY     NUMBER,
6026 p_msg_data                 OUT NOCOPY     VARCHAR2,
6027 p_return_status            OUT NOCOPY     VARCHAR2,
6028 p_region_application_id    IN      NUMBER,
6029 p_region_code              IN      VARCHAR2,
6030 p_delete_cascade           IN      VARCHAR2
6031 ) is
6032 cursor l_is_region_a_child_csr is
6033 select region_code, region_application_id
6034 from AK_REGION_ITEMS
6035 where region_code <> p_region_code
6036 and   region_application_id <> p_region_application_id
6037 and   (lov_region_code = p_region_code
6038 and   lov_region_application_id = p_region_application_id)
6039 or    (nested_region_code = p_region_code
6040 and   nested_region_application_id = p_region_application_id);
6041 cursor l_get_page_region_csr is
6042 select FLOW_APPLICATION_ID, FLOW_CODE, PAGE_APPLICATION_ID, PAGE_CODE
6043 from  AK_FLOW_PAGE_REGIONS
6044 where region_application_id = p_region_application_id
6045 and   region_code = p_region_code;
6046 cursor l_get_items_csr is
6047 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
6048 from  AK_REGION_ITEMS
6049 where region_application_id = p_region_application_id
6050 and   region_code = p_region_code;
6051 cursor l_get_navigations_csr is
6052 select DATABASE_OBJECT_NAME, ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE,
6053 VALUE_VARCHAR2, VALUE_DATE, VALUE_NUMBER
6054 from  AK_OBJECT_ATTRIBUTE_NAVIGATION
6055 where to_region_appl_id = p_region_application_id
6056 and   to_region_code = p_region_code;
6057 l_api_version_number    CONSTANT number := 1.0;
6058 l_api_name              CONSTANT varchar2(30):= 'Delete_Region';
6059 l_attribute_application_id NUMBER;
6060 l_attribute_code        VARCHAR2(30);
6061 l_database_object_name  VARCHAR2(30);
6062 l_flow_application_id   NUMBER;
6063 l_flow_code             VARCHAR2(30);
6064 l_msg_count             NUMBER;
6065 l_msg_data              VARCHAR2(2000);
6066 l_page_application_id   NUMBER;
6067 l_page_code             VARCHAR2(30);
6068 l_region_code 	  VARCHAR2(30);
6069 l_region_application_id NUMBER;
6070 l_return_status         varchar2(1);
6071 l_value_date            DATE;
6072 l_value_number          NUMBER;
6073 l_value_varchar2        VARCHAR2(240);
6074 begin
6075 IF NOT FND_API.Compatible_API_Call (
6076 l_api_version_number, p_api_version_number, l_api_name,
6077 G_PKG_NAME) then
6078 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6079 return;
6080 END IF;
6081 
6082 -- Initialize the message table if requested.
6083 
6084 if p_init_msg_tbl then
6085 FND_MSG_PUB.initialize;
6086 end if;
6087 
6088 savepoint start_delete_region;
6089 
6090 /** do not raise exception when region does not exist,
6091 * and do not print out warning message
6092 --
6093 -- error if primary key to be deleted does not exists
6094 --
6095 if NOT AK_REGION_PVT.REGION_EXISTS (
6096 p_api_version_number => 1.0,
6097 p_return_status => l_return_status,
6098 p_region_application_id => p_region_application_id,
6099 p_region_code => p_region_code) then
6100 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6101 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6102 FND_MSG_PUB.Add;
6103 end if;
6104 raise FND_API.G_EXC_ERROR;
6105 end if;
6106 **/
6107 
6108 if AK_REGION_PVT.REGION_EXISTS (
6109 p_api_version_number => 1.0,
6110 p_return_status => l_return_status,
6111 p_region_application_id => p_region_application_id,
6112 p_region_code => p_region_code) then
6113 
6114 open l_is_region_a_child_csr;
6115 fetch l_is_region_a_child_csr into l_region_code, l_region_application_id;
6116 if l_is_region_a_child_csr%found then
6117 close l_is_region_a_child_csr;
6118 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6119 FND_MESSAGE.SET_NAME('AK','AK_REGION_IS_CHILD');
6120 FND_MSG_PUB.Add;
6121 end if;
6122 raise FND_API.G_EXC_ERROR;
6123 end if;
6124 close l_is_region_a_child_csr;
6125 
6126 if (p_delete_cascade = 'N') then
6127 --
6128 -- If we are not deleting any referencing records, we cannot
6129 -- delete the region if it is being referenced in any of
6130 -- following tables.
6131 --
6132 -- AK_REGION_ITEMS
6133 --
6134 open l_get_items_csr;
6135 fetch l_get_items_csr into l_attribute_application_id, l_attribute_code;
6136 if l_get_items_csr%found then
6137 close l_get_items_csr;
6138 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6139 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_RI');
6140 FND_MSG_PUB.Add;
6141 end if;
6142 raise FND_API.G_EXC_ERROR;
6143 end if;
6144 close l_get_items_csr;
6145 --
6146 -- AK_FLOW_PAGE_REGIONS
6147 --
6148 open l_get_page_region_csr;
6149 fetch l_get_page_region_csr into l_flow_application_id, l_flow_code,
6150 l_page_application_id, l_page_code;
6151 if l_get_page_region_csr%found then
6152 close l_get_page_region_csr;
6153 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6154 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_PGREG');
6155 FND_MSG_PUB.Add;
6156 end if;
6157 raise FND_API.G_EXC_ERROR;
6158 end if;
6159 close l_get_page_region_csr;
6160 --
6161 -- AK_OBJECT_ATTRIBUTE_NAVIGATION
6162 --
6163 open l_get_navigations_csr;
6164 fetch l_get_navigations_csr into l_database_object_name,
6165 l_attribute_application_id, l_attribute_code,
6166 l_value_varchar2, l_value_date, l_value_number;
6167 if l_get_navigations_csr%found then
6168 close l_get_navigations_csr;
6169 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6170 FND_MESSAGE.SET_NAME('AK','AK_CANNOT_DEL_REF_REG_NAV');
6171 FND_MSG_PUB.Add;
6172 end if;
6173 raise FND_API.G_EXC_ERROR;
6174 end if;
6175 close l_get_navigations_csr;
6176 else
6177 --
6178 -- Otherwise, delete all referencing rows in other tables
6179 --
6180 -- AK_REGION_TIEMS
6181 --
6182 open l_get_items_csr;
6183 loop
6184 fetch l_get_items_csr into l_attribute_application_id, l_attribute_code;
6185 exit when l_get_items_csr%notfound;
6186 AK_REGION_PVT.DELETE_ITEM (
6187 p_validation_level => p_validation_level,
6188 p_api_version_number => 1.0,
6189 p_msg_count => l_msg_count,
6190 p_msg_data => l_msg_data,
6191 p_return_status => l_return_status,
6192 p_region_application_id => p_region_application_id,
6193 p_region_code => p_region_code,
6194 p_attribute_application_id => l_attribute_application_id,
6195 p_attribute_code => l_attribute_code,
6196 p_delete_cascade => p_delete_cascade
6197 );
6198 if (l_return_status = FND_API.G_RET_STS_ERROR) or
6199 (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6200 close l_get_items_csr;
6201 raise FND_API.G_EXC_ERROR;
6202 end if;
6203 end loop;
6204 close l_get_items_csr;
6205 --
6206 -- AK_FLOW_PAGE_REGIONS
6207 --
6208 --    open l_get_page_region_csr;
6209 --    loop
6210 --      fetch l_get_page_region_csr into l_flow_application_id, l_flow_code,
6211 --                                   l_page_application_id, l_page_code;
6212 --      exit when l_get_page_region_csr%notfound;
6213 --      AK_FLOW_PVT.DELETE_PAGE_REGION (
6214 --        p_validation_level => p_validation_level,
6215 --        p_api_version_number => 1.0,
6216 --        p_msg_count => l_msg_count,
6217 --        p_msg_data => l_msg_data,
6218 --        p_return_status => l_return_status,
6219 --        p_flow_application_id => l_flow_application_id,
6220 --        p_flow_code => l_flow_code,
6221 --        p_page_application_id => l_page_application_id,
6222 --        p_page_code => l_page_code,
6223 --        p_region_application_id => p_region_application_id,
6224 --        p_region_code => p_region_code,
6225 --        p_delete_cascade => p_delete_cascade
6226 --      );
6227 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
6228 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6229 --        close l_get_page_region_csr;
6230 --        raise FND_API.G_EXC_ERROR;
6231 --      end if;
6232 --    end loop;
6233 --    close l_get_page_region_csr;
6234 --
6235 -- AK_OBJECT_ATTRIBUTE_NAVIGATION
6236 --
6237 --    open l_get_navigations_csr;
6238 --    loop
6239 --      fetch l_get_navigations_csr into l_database_object_name,
6240 --                       l_attribute_application_id, l_attribute_code,
6241 --                       l_value_varchar2, l_value_date, l_value_number;
6242 --      exit when l_get_navigations_csr%notfound;
6243 --      AK_OBJECT_PVT.DELETE_ATTRIBUTE_NAVIGATION (
6244 --        p_validation_level => p_validation_level,
6245 --        p_api_version_number => 1.0,
6246 --        p_msg_count => l_msg_count,
6247 --        p_msg_data => l_msg_data,
6248 --        p_return_status => l_return_status,
6249 --        p_database_object_name => l_database_object_name,
6250 --        p_attribute_application_id => l_attribute_application_id,
6251 --        p_attribute_code => l_attribute_code,
6252 --        p_value_varchar2 => l_value_varchar2,
6253 --        p_value_date => l_value_date,
6254 --        p_value_number => l_value_number,
6255 --        p_delete_cascade => p_delete_cascade
6256 --      );
6257 --      if (l_return_status = FND_API.G_RET_STS_ERROR) or
6258 --         (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6259 --        close l_get_navigations_csr;
6260 --        raise FND_API.G_EXC_ERROR;
6261 --      end if;
6262 --    end loop;
6263 --    close l_get_navigations_csr;
6264 
6265 end if;
6266 
6267 --
6268 -- delete region item once we checked that there are no references
6269 -- to it, or all references have been deleted.
6270 --
6271 delete from ak_regions
6272 where  region_application_id = p_region_application_id
6273 and    region_code = p_region_code;
6274 
6275 if (sql%notfound) then
6276 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6277 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6278 FND_MSG_PUB.Add;
6279 end if;
6280 raise FND_API.G_EXC_ERROR;
6281 end if;
6282 
6283 delete from ak_regions_tl
6284 where  region_application_id = p_region_application_id
6285 and    region_code = p_region_code;
6286 
6287 if (sql%notfound) then
6288 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
6289 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
6290 FND_MESSAGE.SET_TOKEN('OBJECT', 'AK_LC_REGION',TRUE);
6291 FND_MSG_PUB.Add;
6292 end if;
6293 raise FND_API.G_EXC_ERROR;
6294 end if;
6295 
6296 --
6297 -- Load success message
6298 --
6299 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) then
6300 FND_MESSAGE.SET_NAME('AK','AK_REGION_DELETED');
6301 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
6302 ' ' || p_region_code);
6303 FND_MSG_PUB.Add;
6304 end if;
6305 end if; -- region exists
6306 
6307 p_return_status := FND_API.G_RET_STS_SUCCESS;
6308 
6309 FND_MSG_PUB.Count_And_Get (
6310 p_count => p_msg_count,
6311 p_data => p_msg_data);
6312 
6313 EXCEPTION
6314 WHEN FND_API.G_EXC_ERROR THEN
6315 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6316 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_DELETED');
6317 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
6318 ' ' || p_region_code);
6319 FND_MSG_PUB.Add;
6320 end if;
6321 p_return_status := FND_API.G_RET_STS_ERROR;
6322 rollback to start_delete_region;
6323 FND_MSG_PUB.Count_And_Get (
6324 p_count => p_msg_count,
6325 p_data => p_msg_data);
6326 WHEN OTHERS THEN
6327 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6328 rollback to start_delete_region;
6329 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6330 SUBSTR (SQLERRM, 1, 240) );
6331 FND_MSG_PUB.Add;
6332 FND_MSG_PUB.Count_And_Get (
6333 p_count => p_msg_count,
6334 p_data => p_msg_data);
6335 end DELETE_REGION;
6336 
6337 --=======================================================
6338 --  Procedure   DOWNLOAD_REGION
6339 --
6340 --  Usage       Private API for downloading regions. This
6341 --              API should only be called by other APIs that are
6342 --              owned by the Core Modules Team (AK).
6343 --
6344 --  Desc        This API will extract the regions selected
6345 --              by application ID or by key values from the
6346 --              database to the output file.
6347 --              If a region is selected for writing to the loader
6348 --              file, all its children records (including region items)
6349 --              will also be written.
6350 --
6351 --  Results     The API returns the standard p_return_status parameter
6352 --              indicating one of the standard return statuses :
6353 --                  * Unexpected error
6354 --                  * Error
6355 --                  * Success
6356 --  Parameters
6357 --              p_nls_language : IN optional
6358 --                  NLS language for database. If none if given,
6359 --                  the current NLS language will be used.
6360 --              p_get_object_flag : IN required
6361 --                  Call DOWNLOAD_OBJECT API to extract objects that
6362 --                  are referenced by the regions that will be extracted
6363 --                  by this API if this parameter is 'Y'.
6364 --
6365 --              One of the following parameters must be provided:
6366 --
6367 --              p_application_id : IN optional
6368 --                  If given, all attributes for this application ID
6369 --                  will be written to the output file.
6370 --                  p_application_id will be ignored if a table is
6371 --                  given in p_region_pk_tbl.
6372 --              p_region_pk_tbl : IN optional
6373 --                  If given, only regions whose key values are
6374 --                  included in this table will be written to the
6375 --                  output file.
6376 --
6377 --
6378 --  Version     Initial version number  =   1.0
6379 --  History     Current version number  =   1.0
6380 --=======================================================
6381 procedure DOWNLOAD_REGION (
6382 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
6383 p_api_version_number       IN      NUMBER,
6384 p_return_status            OUT NOCOPY     VARCHAR2,
6385 p_application_id           IN      NUMBER := FND_API.G_MISS_NUM,
6386 p_region_pk_tbl            IN OUT NOCOPY     AK_REGION_PUB.Region_PK_Tbl_Type,
6387 p_nls_language             IN      VARCHAR2,
6388 p_get_object_flag          IN      VARCHAR2
6389 ) is
6390 cursor l_get_region_list_csr (application_id number) is
6391 select region_application_id, region_code
6392 from   AK_REGIONS
6393 where  REGION_APPLICATION_ID = application_id;
6394 cursor l_get_region_items_csr (region_appl_id_param number,
6395 region_code_param varchar2) is
6396 select ATTRIBUTE_APPLICATION_ID, ATTRIBUTE_CODE
6397 from   AK_REGION_ITEMS
6398 where  region_application_id = region_appl_id_param
6399 and    region_code = region_code_param
6400 and    object_attribute_flag = 'N';
6401 cursor l_get_target_regions_csr (region_appl_id_param number,
6402 region_code_param varchar2) is
6403 select distinct to_region_appl_id, to_region_code
6404 from   AK_OBJECT_ATTRIBUTE_NAVIGATION aoan, AK_REGIONS ar
6405 where  ar.region_application_id = region_appl_id_param
6406 and    ar.region_code = region_code_param
6407 and    aoan.database_object_name = ar.database_object_name;
6408 cursor l_get_database_object_name_csr (region_appl_id_param number,
6409 region_code_param varchar2) is
6410 select DATABASE_OBJECT_NAME
6411 from   AK_REGIONS
6412 where  region_application_id = region_appl_id_param
6413 and    region_code = region_code_param;
6414 cursor l_get_ri_lov_regions_csr (region_appl_id_param number,
6415 region_code_param varchar2) is
6416 select distinct lov_region_application_id, lov_region_code
6417 from   AK_REGION_ITEMS
6418 where  region_application_id = region_appl_id_param
6419 and    region_code = region_code_param
6420 and    lov_region_application_id is not null
6421 and    lov_region_code is not null;
6422 cursor l_get_oa_lov_regions_csr (region_appl_id_param number,
6423 region_code_param varchar2) is
6424 select distinct aoa.lov_region_application_id, aoa.lov_region_code
6425 from   AK_REGIONS ar, AK_OBJECT_ATTRIBUTES aoa
6426 where  ar.region_application_id = region_appl_id_param
6427 and    ar.region_code = region_code_param
6428 and    ar.database_object_name = aoa.database_object_name
6429 and    aoa.lov_region_application_id is not null
6430 and    aoa.lov_region_code is not null;
6431 cursor l_get_attr_lov_regions_csr (region_appl_id_param number,
6432 region_code_param varchar2) is
6433 select distinct aa.lov_region_application_id, aa.lov_region_code
6434 from   AK_REGION_ITEMS ar, AK_ATTRIBUTES aa
6435 where  ar.region_application_id = region_appl_id_param
6436 and    ar.region_code = region_code_param
6437 and    ar.object_attribute_flag = 'N'
6438 and    ar.attribute_application_id = aa.attribute_application_id
6439 and    ar.attribute_code = aa.attribute_code
6440 and    aa.lov_region_application_id is not null
6441 and    aa.lov_region_code is not null;
6442 cursor l_get_lov_region_items_csr (region_appl_id_param number,
6443 region_code_param varchar2) is
6444 select region_application_id, region_code, attribute_application_id,
6445 attribute_code
6446 from   ak_region_items
6447 where  region_application_id = region_appl_id_param
6448 and    region_code = region_code_param
6449 and    object_attribute_flag = 'N'
6450 and    lov_region_application_id is not null
6451 and    lov_region_code is not null;
6452 cursor l_get_relation_lov_regions_csr (region_appl_id_param number,
6453 region_code_param varchar2,
6454 attribute_appl_id_param number,
6455 attribute_code_param varchar2) is
6456 select distinct lov_region_appl_id, lov_region_code
6457 from   ak_region_lov_relations
6458 where  region_application_id = region_appl_id_param
6459 and    region_code = region_code_param
6460 and    attribute_application_id = attribute_appl_id_param
6461 and    attribute_code = attribute_code_param;
6462 
6463 l_api_version_number CONSTANT number := 1.0;
6464 l_api_name           CONSTANT varchar2(30) := 'Download_Region';
6465 l_attribute_pk_tbl   AK_ATTRIBUTE_PUB.Attribute_PK_Tbl_Type;
6466 l_msg_count          NUMBER;
6467 l_msg_data           VARCHAR2(2000);
6468 l_object_pk_tbl      AK_OBJECT_PUB.Object_PK_Tbl_Type;
6469 l_index              NUMBER;
6470 l_region_pk_tbl      AK_REGION_PUB.Region_PK_Tbl_Type;
6471 l_return_status      varchar2(1);
6472 begin
6473 IF NOT FND_API.Compatible_API_Call (
6474 l_api_version_number, p_api_version_number, l_api_name,
6475 G_PKG_NAME) then
6476 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6477 return;
6478 END IF;
6479 
6480 -- Check that one of the following selection criteria is given:
6481 -- - p_application_id alone, or
6482 -- - a list of region_application_id and region_code in p_object_PK_tbl
6483 if (p_application_id = FND_API.G_MISS_NUM) then
6484 if (p_region_PK_tbl.count = 0) then
6485 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6486 FND_MESSAGE.SET_NAME('AK','AK_NO_SELECTION');
6487 FND_MSG_PUB.Add;
6488 end if;
6489 raise FND_API.G_EXC_ERROR;
6490 end if;
6491 else
6492 if (p_region_PK_tbl.count > 0) then
6493 -- both application ID and a list of regions to be extracted are
6494 -- given, issue a warning that we will ignore the application ID
6495 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6496 FND_MESSAGE.SET_NAME('AK','AK_APPL_ID_IGNORED');
6497 FND_MSG_PUB.Add;
6498 end if;
6499 end if;
6500 end if;
6501 
6502 -- If selecting by application ID, first load a region primary key tabl
6503 -- with the primary key of all regions for the given application ID.
6504 -- If selecting by a list of regions, simply copy the region primary key
6505 -- table with the parameter
6506 if (p_region_PK_tbl.count > 0) then
6507 l_region_pk_tbl := p_region_pk_tbl;
6508 else
6509 l_index := 1;
6510 open l_get_region_list_csr(p_application_id);
6511 loop
6512 fetch l_get_region_list_csr into
6513 l_region_pk_tbl(l_index).region_appl_id,
6514 l_region_pk_tbl(l_index).region_code;
6515 exit when l_get_region_list_csr%notfound;
6516 l_index := l_index + 1;
6517 end loop;
6518 close l_get_region_list_csr;
6519 end if;
6520 
6521 -- Build a list of objects and attributes referenced by all the regions
6522 -- to be extracted from the database. Also add LOV regions and target
6523 -- regions of some object attribute navigation records to the list
6524 -- of regions to be extracted.
6525 --
6526 l_index := l_region_pk_tbl.FIRST;
6527 
6528 while (l_index is not null) loop
6529 -- Include regions that are the target regions of some object attribute
6530 -- navigation records of objects that will be extracted along with the
6531 -- given list of regions
6532 for l_region_rec in l_get_target_regions_csr (
6533 l_region_pk_tbl(l_index).region_appl_id,
6534 l_region_pk_tbl(l_index).region_code) LOOP
6535 ak_region_pvt.insert_region_pk_table(
6536 p_return_status => l_return_status,
6537 p_region_application_id => l_region_rec.to_region_appl_id,
6538 p_region_code => l_region_rec.to_region_code,
6539 p_region_pk_tbl => l_region_pk_tbl);
6540 end loop;
6541 
6542 -- If the download object flag is 'Y', add
6543 -- the database object referenced by this region to the object
6544 -- list, which will be used to download those objects.
6545 --
6546 if (p_get_object_flag = 'Y')  then
6547 --
6548 -- Add the object referenced by this region to the object list
6549 --
6550 for l_object_rec in l_get_database_object_name_csr(
6551 l_region_pk_tbl(l_index).region_appl_id,
6552 l_region_pk_tbl(l_index).region_code) LOOP
6553 AK_OBJECT_PVT.INSERT_OBJECT_PK_TABLE (
6554 p_return_status => l_return_status,
6555 p_database_object_name => l_object_rec.database_object_name,
6556 p_object_pk_tbl => l_object_pk_tbl);
6557 end loop;
6558 
6559 if (AK_DOWNLOAD_GRP.G_DOWNLOAD_ATTR = 'Y') then
6560 -- Get all attributes referenced by all region items in this region
6561 -- and add them to the attribute list
6562 for l_attribute_rec in l_get_region_items_csr (
6563 l_region_pk_tbl(l_index).region_appl_id,
6564 l_region_pk_tbl(l_index).region_code) LOOP
6565 AK_ATTRIBUTE_PVT.INSERT_ATTRIBUTE_PK_TABLE (
6566 p_return_status => l_return_status,
6567 p_attribute_application_id =>
6568 l_attribute_rec.attribute_application_id,
6569 p_attribute_code => l_attribute_rec.attribute_code,
6570 p_attribute_pk_tbl => l_attribute_pk_tbl);
6571 end loop;
6572 end if;
6573 
6574 -- Add LOV Region used by all region items in this region
6575 -- to the list of regions to be downloaded
6576 for l_region_rec in l_get_ri_lov_regions_csr (
6577 l_region_pk_tbl(l_index).region_appl_id,
6578 l_region_pk_tbl(l_index).region_code) LOOP
6579 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6580 p_return_status => l_return_status,
6581 p_region_application_id =>
6582 l_region_rec.lov_region_application_id,
6583 p_region_code => l_region_rec.lov_region_code,
6584 p_region_pk_tbl => l_region_pk_tbl);
6585 end loop;
6586 
6587 -- Add LOV Region used by all object attributes in the object
6588 -- referenced by this region to the list of regions to be downloaded
6589 for l_region_rec in l_get_oa_lov_regions_csr (
6590 l_region_pk_tbl(l_index).region_appl_id,
6591 l_region_pk_tbl(l_index).region_code) LOOP
6592 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6593 p_return_status => l_return_status,
6594 p_region_application_id =>
6595 l_region_rec.lov_region_application_id,
6596 p_region_code => l_region_rec.lov_region_code,
6597 p_region_pk_tbl => l_region_pk_tbl);
6598 end loop;
6599 
6600 -- Add LOV Region used by all attributes referenced by any
6601 -- region item to the list of regions to be downloaded
6602 for l_region_rec in l_get_attr_lov_regions_csr (
6603 l_region_pk_tbl(l_index).region_appl_id,
6604 l_region_pk_tbl(l_index).region_code) LOOP
6605 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6606 p_return_status => l_return_status,
6607 p_region_application_id =>
6608 l_region_rec.lov_region_application_id,
6609 p_region_code => l_region_rec.lov_region_code,
6610 p_region_pk_tbl => l_region_pk_tbl);
6611 end loop;
6612 
6613 for l_region_attr_rec in l_get_lov_region_items_csr(
6614 l_region_pk_tbl(l_index).region_appl_id,
6615 l_region_pk_tbl(l_index).region_code) LOOP
6616 for l_region_rec in l_get_relation_lov_regions_csr (
6617 l_region_attr_rec.region_application_id,
6618 l_region_attr_rec.region_code,
6619 l_region_attr_rec.attribute_application_id,
6620 l_region_attr_rec.attribute_code) loop
6621 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
6622 p_return_status => l_return_status,
6623 p_region_application_id =>
6624 l_region_rec.lov_region_appl_id,
6625 p_region_code => l_region_rec.lov_region_code,
6626 p_region_pk_tbl => l_region_pk_tbl);
6627 end loop;
6628 end loop;
6629 
6630 -- Add Nested Region used by all region items in this region
6631 -- to the list of regions to be downloaded
6632 AK_REGION_PVT.ADD_NESTED_REG_TO_REG_PK (
6633 p_region_application_id =>
6634 l_region_pk_tbl(l_index).region_appl_id,
6635 p_region_code => l_region_pk_tbl(l_index).region_code,
6636 p_region_pk_tbl => l_region_pk_tbl);
6637 
6638 
6639 end if; /* if p_get_object_flag = 'Y' */
6640 
6641 -- Ready to download the next region in the list
6642 l_index := l_region_pk_tbl.NEXT(l_index);
6643 end loop;
6644 
6645 -- set l_index to the last index number in the region table
6646 l_index := l_region_pk_tbl.LAST;
6647 
6648 --
6649 -- If the get object flag is 'Y', call download_object to retrieve
6650 -- all objects and attributes referenced by any of the selected regions.
6651 if (p_get_object_flag = 'Y') then
6652 if (l_object_pk_tbl.count > 0)  then
6653 AK_OBJECT2_PVT.DOWNLOAD_OBJECT (
6654 p_validation_level => p_validation_level,
6655 p_api_version_number => 1.0,
6656 p_return_status => l_return_status,
6657 p_object_pk_tbl => l_object_pk_tbl,
6658 p_attribute_pk_tbl => l_attribute_pk_tbl,
6659 p_nls_language => p_nls_language,
6660 p_get_region_flag => 'N'
6661 );
6662 
6663 if (l_return_status = FND_API.G_RET_STS_ERROR) or
6664 (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) then
6665 -- dbms_output.put_line(l_api_name || ' Error downloading objects');
6666 raise FND_API.G_EXC_ERROR;
6667 end if;
6668 end if;
6669 end if;
6670 
6671 if (AK_DOWNLOAD_GRP.G_DOWNLOAD_REG = 'Y') then
6672 -- Write details for each selected region, including its items, to a
6673 -- buffer to be passed back to the calling procedure.
6674 l_index := l_region_pk_tbl.FIRST;
6675 
6676 while (l_index is not null) loop
6677 --
6678 -- Write region information from the database
6679 --
6680 --dbms_output.put_line('writing region #'||to_char(l_index) || ':' ||
6681 --                      l_region_pk_tbl(l_index).region_code);
6682 
6683 if ( (l_region_pk_tbl(l_index).region_appl_id <> FND_API.G_MISS_NUM) and
6684 (l_region_pk_tbl(l_index).region_appl_id is not null) and
6685 (l_region_pk_tbl(l_index).region_code <> FND_API.G_MISS_CHAR) and
6686 (l_region_pk_tbl(l_index).region_code is not null) ) then
6687 WRITE_TO_BUFFER(
6688 p_validation_level => p_validation_level,
6689 p_return_status => l_return_status,
6690 p_region_application_id => l_region_pk_tbl(l_index).region_appl_id,
6691 p_region_code => l_region_pk_tbl(l_index).region_code,
6692 p_nls_language => p_nls_language
6693 );
6694 end if;
6695 
6696 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
6697 (l_return_status = FND_API.G_RET_STS_ERROR) then
6698 RAISE FND_API.G_EXC_ERROR;
6699 end if;
6700 
6701 -- Ready to download the next region in the list
6702 l_index := l_region_pk_tbl.NEXT(l_index);
6703 end loop;
6704 end if; /*G_DOWNLOAD_REG*/
6705 
6706 p_region_pk_tbl := l_region_pk_tbl;
6707 p_return_status := FND_API.G_RET_STS_SUCCESS;
6708 
6709 EXCEPTION
6710 WHEN VALUE_ERROR THEN
6711 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6712 FND_MESSAGE.SET_NAME('AK','AK_REGION_PK_VALUE_ERROR');
6713 FND_MSG_PUB.Add;
6714 end if;
6715 --dbms_output.put_line('Value error occurred - check your region list.');
6716 p_return_status := FND_API.G_RET_STS_ERROR;
6717 WHEN FND_API.G_EXC_ERROR THEN
6718 p_return_status := FND_API.G_RET_STS_ERROR;
6719 WHEN OTHERS THEN
6720 --dbms_output.put_line(SUBSTR(SQLERRM,1,240));
6721 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6722 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6723 SUBSTR (SQLERRM, 1, 240) );
6724 FND_MSG_PUB.Add;
6725 end DOWNLOAD_REGION;
6726 
6727 --=======================================================
6728 --  Procedure   INSERT_REGION_PK_TABLE
6729 --
6730 --  Usage       Private API for inserting the given region's
6731 --              primary key value into the given object
6732 --              table.
6733 --              This API should only be called by other APIs
6734 --              that are owned by the Core Modules Team (AK).
6735 --
6736 --  Desc        This API inserts the given region's primary
6737 --              key value into a given region table
6738 --              (of type Object_PK_Tbl_Type) only if the
6739 --              primary key does not already exist in the table.
6740 --
6741 --  Results     The API returns the standard p_return_status parameter
6742 --              indicating one of the standard return statuses :
6743 --                  * Unexpected error
6744 --                  * Error
6745 --                  * Success
6746 --  Parameters  p_region_application_id : IN required
6747 --              p_region_code : IN required
6748 --                  Key value of the region to be inserted to the
6749 --                  table.
6750 --              p_region_pk_tbl : IN OUT
6751 --                  Region table to be updated.
6752 --
6753 --  Version     Initial version number  =   1.0
6754 --  History     Current version number  =   1.0
6755 --=======================================================
6756 procedure INSERT_REGION_PK_TABLE (
6757 p_return_status            OUT NOCOPY     VARCHAR2,
6758 p_region_application_id    IN      NUMBER,
6759 p_region_code              IN      VARCHAR2,
6760 p_region_pk_tbl            IN OUT NOCOPY  AK_REGION_PUB.Region_PK_Tbl_Type
6761 ) is
6762 l_api_version_number CONSTANT number := 1.0;
6763 l_api_name           CONSTANT varchar2(30) := 'Insert_Region_PK_Table';
6764 l_index         NUMBER;
6765 begin
6766 --
6767 -- if table is empty, just insert the region primary key into it
6768 --
6769 if (p_region_pk_tbl.count = 0) then
6770 --dbms_output.put_line('Inserted region: ' || p_region_code ||
6771 --                     ' into element #1');
6772 p_region_pk_tbl(1).region_appl_id := p_region_application_id;
6773 p_region_pk_tbl(1).region_code := p_region_code;
6774 return;
6775 end if;
6776 
6777 --
6778 -- otherwise, insert the region to the end of the table if it is
6779 -- not already in the table. If it is already in the table, return
6780 -- without changing the table.
6781 --
6782 for l_index in p_region_pk_tbl.FIRST .. p_region_pk_tbl.LAST loop
6783 if (p_region_pk_tbl.exists(l_index)) then
6784 if (p_region_pk_tbl(l_index).region_appl_id = p_region_application_id)
6785 and
6786 (p_region_pk_tbl(l_index).region_code = p_region_code) then
6787 return;
6788 end if;
6789 end if;
6790 end loop;
6791 
6792 --dbms_output.put_line('Inserted region: ' || p_region_code ||
6793 --                     ' into element #' || to_char(p_region_pk_tbl.LAST + 1));
6794 l_index := p_region_pk_tbl.LAST + 1;
6795 p_region_pk_tbl(l_index).region_appl_id := p_region_application_id;
6796 p_region_pk_tbl(l_index).region_code := p_region_code;
6797 
6798 
6799 EXCEPTION
6800 WHEN FND_API.G_EXC_ERROR THEN
6801 p_return_status := FND_API.G_RET_STS_ERROR;
6802 WHEN OTHERS THEN
6803 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6804 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6805 SUBSTR (SQLERRM, 1, 240) );
6806 FND_MSG_PUB.Add;
6807 end INSERT_REGION_PK_TABLE;
6808 
6809 /*
6810 --=======================================================
6811 --  Function    GRAPH_EXISTS
6812 --
6813 --  Usage       Private API for checking for the existence of
6814 --              a region graph with the given key values. This
6815 --              API should only be called by other APIs that are
6816 --              owned by the Core Modules Team (AK).
6817 --
6818 --  Desc        This API check to see if a region graph record
6819 --              exists with the given key values.
6820 --
6821 --  Results     The API returns the standard p_return_status parameter
6822 --              indicating one of the standard return statuses :
6823 --                  * Unexpected error
6824 --                  * Error
6825 --                  * Success
6826 --              This function will return TRUE if such an object
6827 --              attribute exists, or FALSE otherwise.
6828 --  Parameters  Region Graph key columns
6829 --
6830 --  Version     Initial version number  =   1.0
6831 --  History     Current version number  =   1.0
6832 --=======================================================
6833 function GRAPH_EXISTS (
6834 p_api_version_number       IN      NUMBER,
6835 p_return_status            OUT NOCOPY     VARCHAR2,
6836 p_region_application_id    IN      NUMBER,
6837 p_region_code              IN      VARCHAR2,
6838 p_graph_number	     IN	     NUMBER
6839 ) return BOOLEAN is
6840 cursor l_check_csr is
6841 select 1
6842 from  AK_REGION_GRAPHS
6843 where region_application_id = p_region_application_id
6844 and   region_code = p_region_code
6845 and   graph_number = p_graph_number;
6846 l_api_version_number CONSTANT number := 1.0;
6847 l_api_name           CONSTANT varchar2(30) := 'Item_Exists';
6848 l_dummy              number;
6849 begin
6850 IF NOT FND_API.Compatible_API_Call (
6851 l_api_version_number, p_api_version_number, l_api_name,
6852 G_PKG_NAME) then
6853 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6854 return FALSE;
6855 END IF;
6856 
6857 open l_check_csr;
6858 fetch l_check_csr into l_dummy;
6859 if (l_check_csr%notfound) then
6860 close l_check_csr;
6861 p_return_status := FND_API.G_RET_STS_SUCCESS;
6862 return FALSE;
6863 else
6864 close l_check_csr;
6865 p_return_status := FND_API.G_RET_STS_SUCCESS;
6866 return TRUE;
6867 end if;
6868 
6869 EXCEPTION
6870 WHEN FND_API.G_EXC_ERROR THEN
6871 p_return_status := FND_API.G_RET_STS_ERROR;
6872 return FALSE;
6873 WHEN OTHERS THEN
6874 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6875 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6876 SUBSTR (SQLERRM, 1, 240) );
6877 FND_MSG_PUB.Add;
6878 return FALSE;
6879 
6880 end GRAPH_EXISTS;
6881 */
6882 
6883 --=======================================================
6884 --  Function    ITEM_EXISTS
6885 --
6886 --  Usage       Private API for checking for the existence of
6887 --              a region item with the given key values. This
6888 --              API should only be called by other APIs that are
6889 --              owned by the Core Modules Team (AK).
6890 --
6891 --  Desc        This API check to see if a region item record
6892 --              exists with the given key values.
6893 --
6894 --  Results     The API returns the standard p_return_status parameter
6895 --              indicating one of the standard return statuses :
6896 --                  * Unexpected error
6897 --                  * Error
6898 --                  * Success
6899 --              This function will return TRUE if such an object
6900 --              attribute exists, or FALSE otherwise.
6901 --  Parameters  Region Item key columns
6902 --
6903 --  Version     Initial version number  =   1.0
6904 --  History     Current version number  =   1.0
6905 --=======================================================
6906 function ITEM_EXISTS (
6907 p_api_version_number       IN      NUMBER,
6908 p_return_status            OUT NOCOPY     VARCHAR2,
6909 p_region_application_id    IN      NUMBER,
6910 p_region_code              IN      VARCHAR2,
6911 p_attribute_application_id IN      NUMBER,
6912 p_attribute_code           IN      VARCHAR2
6913 ) return BOOLEAN is
6914 cursor l_check_csr is
6915 select 1
6916 from  AK_REGION_ITEMS
6917 where region_application_id = p_region_application_id
6918 and   region_code = p_region_code
6919 and   attribute_application_id = p_attribute_application_id
6920 and   attribute_code = p_attribute_code;
6921 l_api_version_number CONSTANT number := 1.0;
6922 l_api_name           CONSTANT varchar2(30) := 'Item_Exists';
6923 l_dummy              number;
6924 begin
6925 IF NOT FND_API.Compatible_API_Call (
6926 l_api_version_number, p_api_version_number, l_api_name,
6927 G_PKG_NAME) then
6928 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6929 return FALSE;
6930 END IF;
6931 
6932 open l_check_csr;
6933 fetch l_check_csr into l_dummy;
6934 if (l_check_csr%notfound) then
6935 close l_check_csr;
6936 p_return_status := FND_API.G_RET_STS_SUCCESS;
6937 return FALSE;
6938 else
6939 close l_check_csr;
6940 p_return_status := FND_API.G_RET_STS_SUCCESS;
6941 return TRUE;
6942 end if;
6943 
6944 EXCEPTION
6945 WHEN FND_API.G_EXC_ERROR THEN
6946 p_return_status := FND_API.G_RET_STS_ERROR;
6947 return FALSE;
6948 WHEN OTHERS THEN
6949 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6950 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
6951 SUBSTR (SQLERRM, 1, 240) );
6952 FND_MSG_PUB.Add;
6953 return FALSE;
6954 
6955 end ITEM_EXISTS;
6956 
6957 --=======================================================
6958 --  Function    REGION_EXISTS
6959 --
6960 --  Usage       Private API for checking for the existence of
6961 --              a region with the given key values. This
6962 --              API should only be called by other APIs that are
6963 --              owned by the Core Modules Team (AK).
6964 --
6965 --  Desc        This API check to see if a region record
6966 --              exists with the given key values.
6967 --
6968 --  Results     The API returns the standard p_return_status parameter
6969 --              indicating one of the standard return statuses :
6970 --                  * Unexpected error
6971 --                  * Error
6972 --                  * Success
6973 --              This function will return TRUE if such an object
6974 --              attribute exists, or FALSE otherwise.
6975 --  Parameters  Region key columns
6976 --
6977 --  Version     Initial version number  =   1.0
6978 --  History     Current version number  =   1.0
6979 --=======================================================
6980 function REGION_EXISTS (
6981 p_api_version_number       IN      NUMBER,
6982 p_return_status            OUT NOCOPY     VARCHAR2,
6983 p_region_application_id    IN      NUMBER,
6984 p_region_code              IN      VARCHAR2
6985 ) return BOOLEAN is
6986 cursor l_check_region_csr is
6987 select 1
6988 from  AK_REGIONS
6989 where region_application_id = p_region_application_id
6990 and   region_code = p_region_code;
6991 l_api_version_number CONSTANT number := 1.0;
6992 l_api_name           CONSTANT varchar2(30) := 'Region_Exists';
6993 l_dummy              number;
6994 begin
6995 IF NOT FND_API.Compatible_API_Call (
6996 l_api_version_number, p_api_version_number, l_api_name,
6997 G_PKG_NAME) then
6998 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6999 return FALSE;
7000 END IF;
7001 
7002 open l_check_region_csr;
7003 fetch l_check_region_csr into l_dummy;
7004 if (l_check_region_csr%notfound) then
7005 close l_check_region_csr;
7006 p_return_status := FND_API.G_RET_STS_SUCCESS;
7007 return FALSE;
7008 else
7009 close l_check_region_csr;
7010 p_return_status := FND_API.G_RET_STS_SUCCESS;
7011 return TRUE;
7012 end if;
7013 
7014 EXCEPTION
7015 WHEN FND_API.G_EXC_ERROR THEN
7016 p_return_status := FND_API.G_RET_STS_ERROR;
7017 return FALSE;
7018 WHEN OTHERS THEN
7019 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7020 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
7021 SUBSTR (SQLERRM, 1, 240) );
7022 FND_MSG_PUB.Add;
7023 return FALSE;
7024 end REGION_EXISTS;
7025 
7026 /*
7027 --=======================================================
7028 --  Procedure   UPDATE_GRAPH
7029 --
7030 --  Usage       Private API for updating a region graph.
7031 --              This API should only be called by other APIs
7032 --              that are owned by the Core Modules Team (AK).
7033 --
7034 --  Desc        This API updates a region graph using the given info
7035 --
7036 --  Results     The API returns the standard p_return_status parameter
7037 --              indicating one of the standard return statuses :
7038 --                  * Unexpected error
7039 --                  * Error
7040 --                  * Success
7041 --  Parameters  Region Graph columns
7042 --              p_loader_timestamp : IN optional
7043 --                  If a timestamp is passed, the API will update the
7044 --                  record using this timestamp. Only the upload API
7045 --                  should call with this parameter loaded.
7046 --
7047 --  Version     Initial version number  =   1.0
7048 --  History     Current version number  =   1.0
7049 --=======================================================
7050 procedure UPDATE_GRAPH (
7051 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
7052 p_api_version_number       IN      NUMBER,
7053 p_init_msg_tbl             IN      BOOLEAN := FALSE,
7054 p_msg_count                OUT NOCOPY     NUMBER,
7055 p_msg_data                 OUT NOCOPY     VARCHAR2,
7056 p_return_status            OUT NOCOPY     VARCHAR2,
7057 p_region_application_id    IN      NUMBER,
7058 p_region_code              IN      VARCHAR2,
7059 p_graph_number	     IN      NUMBER,
7060 p_graph_style		     IN      NUMBER := FND_API.G_MISS_NUM,
7061 p_display_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7062 p_depth_radius	     IN      NUMBER := FND_API.G_MISS_NUM,
7063 p_graph_title		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7064 p_y_axis_label	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7065 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
7066 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
7067 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
7068 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
7069 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
7070 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
7071 p_pass                     IN      NUMBER,
7072 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
7073 ) is
7074 cursor l_get_row_csr is
7075 select *
7076 from  AK_REGION_GRAPHS
7077 where REGION_APPLICATION_ID = p_region_application_id
7078 and   REGION_CODE = p_region_code
7079 and   GRAPH_NUMBER = p_graph_number
7080 for update of GRAPH_STYLE;
7081 cursor l_get_tl_row_csr (lang_parm varchar2) is
7082 select *
7083 from  AK_REGION_GRAPHS_TL
7084 where REGION_APPLICATION_ID = p_region_application_id
7085 and   REGION_CODE = p_region_code
7086 and   GRAPH_NUMBER = p_graph_number
7087 and   LANGUAGE = lang_parm
7088 for update of GRAPH_TITLE;
7089 l_api_version_number     CONSTANT number := 1.0;
7090 l_api_name               CONSTANT varchar2(30) := 'Update_Graph';
7091 l_created_by             number;
7092 l_creation_date          date;
7093 l_graphs_rec              ak_region_graphs%ROWTYPE;
7094 l_graphs_tl_rec           ak_region_graphs_tl%ROWTYPE;
7095 l_error                  boolean;
7096 l_lang                   varchar2(30);
7097 l_last_update_date       date;
7098 l_last_update_login      number;
7099 l_last_updated_by        number;
7100 l_return_status          varchar2(1);
7101 l_submit                                      varchar2(1) := 'N';
7102 l_encrypt                                     varchar2(1) := 'N';
7103 l_admin_customizable	 			varchar2(1) := 'Y';
7104 begin
7105 IF NOT FND_API.Compatible_API_Call (
7106 l_api_version_number, p_api_version_number, l_api_name,
7107 G_PKG_NAME) then
7108 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7109 return;
7110 END IF;
7111 
7112 -- Initialize the message table if requested.
7113 
7114 if p_init_msg_tbl then
7115 FND_MSG_PUB.initialize;
7116 end if;
7117 
7118 savepoint start_update_graph;
7119 
7120 select userenv('LANG') into l_lang
7121 from dual;
7122 
7123 --** retrieve ak_region_graphs row if it exists **
7124 open l_get_row_csr;
7125 fetch l_get_row_csr into l_graphs_rec;
7126 if (l_get_row_csr%notfound) then
7127 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7128 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
7129 FND_MSG_PUB.Add;
7130 end if;
7131 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
7132 close l_get_row_csr;
7133 raise FND_API.G_EXC_ERROR;
7134 end if;
7135 close l_get_row_csr;
7136 
7137 --** retrieve ak_region_graphss_tl row if it exists **
7138 open l_get_tl_row_csr(l_lang);
7139 fetch l_get_tl_row_csr into l_graphs_tl_rec;
7140 if (l_get_tl_row_csr%notfound) then
7141 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7142 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_DOES_NOT_EXIST');
7143 FND_MSG_PUB.Add;
7144 end if;
7145 -- dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
7146 close l_get_tl_row_csr;
7147 raise FND_API.G_EXC_ERROR;
7148 end if;
7149 close l_get_tl_row_csr;
7150 
7151 --
7152 -- validate table columns passed in
7153 --
7154 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
7155 if not VALIDATE_GRAPH (
7156 p_validation_level => p_validation_level,
7157 p_api_version_number => 1.0,
7158 p_return_status => l_return_status,
7159 p_region_application_id => p_region_application_id,
7160 p_region_code => p_region_code,
7161 p_graph_number => p_graph_number,
7162 p_graph_style => p_graph_style,
7163 p_display_flag => p_display_flag,
7164 p_depth_radius => p_depth_radius,
7165 p_graph_title => p_graph_title,
7166 p_y_axis_label => p_y_axis_label,
7167 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
7168 p_pass => p_pass
7169 ) then
7170 --dbms_output.put_line(l_api_name || ' validation failed');
7171 -- Do not raise an error if it's the first pass
7172 if (p_pass = 1) then
7173 p_copy_redo_flag := TRUE;
7174 else
7175 raise FND_API.G_EXC_ERROR;
7176 end if;
7177 end if;
7178 end if;
7179 
7180 --** Load record to be updated to the database **
7181 --** - first load nullable columns **
7182 
7183 if (p_display_flag <> FND_API.G_MISS_CHAR) or
7184 (p_display_flag is null) then
7185 l_graphs_rec.display_flag := p_display_flag;
7186 end if;
7187 
7188 if (p_depth_radius <> FND_API.G_MISS_NUM) or
7189 (p_depth_radius is null) then
7190 l_graphs_rec.depth_radius := p_depth_radius;
7191 end if;
7192 
7193 if (p_graph_title <> FND_API.G_MISS_CHAR) or
7194 (p_graph_title is null) then
7195 l_graphs_tl_rec.graph_title := p_graph_title;
7196 end if;
7197 
7198 if (p_y_axis_label <> FND_API.G_MISS_CHAR) or
7199 (p_y_axis_label is null) then
7200 l_graphs_tl_rec.y_axis_label := p_y_axis_label;
7201 end if;
7202 
7203 --** - next, load non-null columns **
7204 
7205 if (p_graph_style <> FND_API.G_MISS_NUM) then
7206 l_graphs_rec.graph_style := p_graph_style;
7207 end if;
7208 
7209 -- Set WHO columns
7210 AK_UPLOAD_GRP.G_UPLOAD_DATE := p_last_update_date;
7211 AK_ON_OBJECTS_PVT.SET_WHO (
7212 p_return_status => l_return_status,
7213 p_loader_timestamp => p_loader_timestamp,
7214 p_created_by => l_created_by,
7215 p_creation_date => l_creation_date,
7216 p_last_updated_by => l_last_updated_by,
7217 p_last_update_date => l_last_update_date,
7218 p_last_update_login => l_last_update_login);
7219 
7220   if (AK_UPLOAD_GRP.G_NON_SEED_DATA) then
7221         l_created_by := p_created_by;
7222         l_last_updated_by := p_last_updated_by;
7223         l_last_update_login := p_last_update_login;
7224   end if;
7225 
7226 update AK_REGION_GRAPHS set
7227 GRAPH_STYLE = l_graphs_rec.graph_style,
7228 DISPLAY_FLAG = l_graphs_rec.display_flag,
7229 LAST_UPDATE_DATE = l_last_update_date,
7230 LAST_UPDATED_BY = l_last_updated_by,
7231 LAST_UPDATE_LOGIN = l_last_update_login
7232 where REGION_APPLICATION_ID = p_region_application_id
7233 and   REGION_CODE = p_region_code
7234 and   GRAPH_NUMBER = p_graph_number;
7235 if (sql%notfound) then
7236 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7237 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATE_FAILED');
7238 FND_MSG_PUB.Add;
7239 end if;
7240 -- dbms_output.put_line(l_api_name || 'Row does not exist during update');
7241 raise FND_API.G_EXC_ERROR;
7242 end if;
7243 
7244 update AK_REGION_GRAPHS_TL set
7245 GRAPH_TITLE = l_graphs_tl_rec.graph_title,
7246 Y_AXIS_LABEL = l_graphs_tl_rec.y_axis_label,
7247 LAST_UPDATED_BY = l_last_updated_by,
7248 LAST_UPDATE_DATE = l_last_update_date,
7249 LAST_UPDATE_LOGIN = l_last_update_login,
7250 SOURCE_LANG = l_lang
7251 where REGION_APPLICATION_ID = p_region_application_id
7252 and   REGION_CODE = p_region_code
7253 and   GRAPH_NUMBER = p_graph_number
7254 and   l_lang in (LANGUAGE, SOURCE_LANG);
7255 if (sql%notfound) then
7256 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7257 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATE_FAILED');
7258 FND_MSG_PUB.Add;
7259 end if;
7260 --dbms_output.put_line(l_api_name || 'TL Row does not exist during update');
7261 raise FND_API.G_EXC_ERROR;
7262 end if;
7263 
7264 --  ** commit the update **
7265 commit;
7266 
7267 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
7268 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_UPDATED');
7269 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7270 ' ' || p_region_code ||
7271 ' ' || p_graph_number);
7272 FND_MSG_PUB.Add;
7273 end if;
7274 
7275 p_return_status := FND_API.G_RET_STS_SUCCESS;
7276 
7277 FND_MSG_PUB.Count_And_Get (
7278 p_count => p_msg_count,
7279 p_data => p_msg_data);
7280 
7281 EXCEPTION
7282 WHEN VALUE_ERROR THEN
7283 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7284 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_VALUE_ERROR');
7285 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7286 ' ' || p_region_code ||
7287 ' ' || p_graph_number);
7288 FND_MSG_PUB.Add;
7289 end if;
7290 rollback to start_update_graph;
7291 p_return_status := FND_API.G_RET_STS_ERROR;
7292 FND_MSG_PUB.Count_And_Get (
7293 p_count => p_msg_count,
7294 p_data => p_msg_data);
7295 WHEN FND_API.G_EXC_ERROR THEN
7296 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7297 FND_MESSAGE.SET_NAME('AK','AK_REG_GRAPH_NOT_UPDATED');
7298 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
7299 ' ' || p_region_code ||
7300 ' ' || p_graph_number);
7301 FND_MSG_PUB.Add;
7302 end if;
7303 p_return_status := FND_API.G_RET_STS_ERROR;
7304 rollback to start_update_graph;
7305 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
7306 SUBSTR (SQLERRM, 1, 240) );
7307 FND_MSG_PUB.Add;
7308 FND_MSG_PUB.Count_And_Get (
7309 p_count => p_msg_count,
7310 p_data => p_msg_data);
7311 end UPDATE_GRAPH;
7312 */
7313 
7314 --=======================================================
7315 --  Procedure   UPDATE_ITEM
7316 --
7317 --  Usage       Private API for updating a region item.
7318 --              This API should only be called by other APIs
7319 --              that are owned by the Core Modules Team (AK).
7320 --
7321 --  Desc        This API updates a region item using the given info
7322 --
7323 --  Results     The API returns the standard p_return_status parameter
7324 --              indicating one of the standard return statuses :
7325 --                  * Unexpected error
7326 --                  * Error
7327 --                  * Success
7328 --  Parameters  Region Item columns
7329 --              p_loader_timestamp : IN optional
7330 --                  If a timestamp is passed, the API will update the
7331 --                  record using this timestamp. Only the upload API
7332 --                  should call with this parameter loaded.
7333 --
7334 --  Version     Initial version number  =   1.0
7335 --  History     Current version number  =   1.0
7336 --=======================================================
7337 procedure UPDATE_ITEM (
7338 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
7339 p_api_version_number       IN      NUMBER,
7340 p_init_msg_tbl             IN      BOOLEAN := FALSE,
7341 p_msg_count                OUT NOCOPY     NUMBER,
7342 p_msg_data                 OUT NOCOPY     VARCHAR2,
7343 p_return_status            OUT NOCOPY     VARCHAR2,
7344 p_region_application_id    IN      NUMBER,
7345 p_region_code              IN      VARCHAR2,
7346 p_attribute_application_id IN      NUMBER,
7347 p_attribute_code           IN      VARCHAR2,
7348 p_display_sequence         IN      NUMBER := FND_API.G_MISS_NUM,
7349 p_node_display_flag        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7350 p_node_query_flag          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7351 p_attribute_label_length   IN      NUMBER := FND_API.G_MISS_NUM,
7352 p_display_value_length     IN      NUMBER := FND_API.G_MISS_NUM,
7353 p_bold                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7354 p_italic                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7355 p_vertical_alignment       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7356 p_horizontal_alignment     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7357 p_item_style               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7358 p_object_attribute_flag    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7359 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7360 p_update_flag              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7361 p_required_flag            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7362 p_security_code            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7363 p_default_value_varchar2   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7364 p_default_value_number     IN      NUMBER := FND_API.G_MISS_NUM,
7365 p_default_value_date       IN      DATE := FND_API.G_MISS_DATE,
7366 p_lov_region_application_id IN     NUMBER := FND_API.G_MISS_NUM,
7367 p_lov_region_code          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7368 p_lov_foreign_key_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7369 p_lov_attribute_application_id IN  NUMBER := FND_API.G_MISS_NUM,
7370 p_lov_attribute_code       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7371 p_lov_default_flag         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7372 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
7373 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
7374 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
7375 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
7376 p_order_sequence           IN      NUMBER := FND_API.G_MISS_NUM,
7377 p_order_direction          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7378 p_display_height			 IN		 NUMBER := FND_API.G_MISS_NUM,
7379 p_submit					 IN		 VARCHAR2,
7380 p_encrypt					 IN		 VARCHAR2,
7381 p_css_class_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7382 p_view_usage_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7383 p_view_attribute_name		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7384 p_nested_region_appl_id	 IN		 NUMBER := FND_API.G_MISS_NUM,
7385 p_nested_region_code		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7386 p_url						 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7387 p_poplist_viewobject		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7388 p_poplist_display_attr	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7389 p_poplist_value_attr		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7390 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7391 p_item_name				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7392 p_css_label_class_name	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7393 p_menu_name		     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7394 p_flexfield_name	     IN	     VARCHAR2 := FND_API.G_MISS_CHAR,
7395 p_flexfield_application_id IN	     NUMBER   := FND_API.G_MISS_NUM,
7396 p_tabular_function_code    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7397 p_tip_type                 IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7398 p_tip_message_name         IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7399 p_tip_message_application_id   IN      NUMBER   := FND_API.G_MISS_NUM,
7400 p_flex_segment_list        IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7401 p_entity_id                IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7402 p_anchor                   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7403 p_poplist_view_usage_name  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7404 p_user_customizable	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7405 p_sortby_view_attribute_name   IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7406 p_admin_customizable		IN	VARCHAR2,
7407 p_invoke_function_name	IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7408 p_expansion		     IN      NUMBER   := FND_API.G_MISS_NUM,
7409 p_als_max_length	     IN      NUMBER   := FND_API.G_MISS_NUM,
7410 p_initial_sort_sequence    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7411 p_customization_application_id IN  NUMBER   := FND_API.G_MISS_NUM,
7412 p_customization_code	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7413 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7414 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7415 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7416 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7417 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7418 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7419 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7420 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7421 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7422 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7423 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7424 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7425 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7426 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7427 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7428 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7429 p_attribute_label_long     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7430 p_attribute_label_short    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
7431 p_description				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
7432 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
7433 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
7434 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
7435 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
7436 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
7437 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
7438 p_pass                     IN      NUMBER,
7439 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
7440 ) is
7441 cursor l_get_row_csr is
7442 select *
7443 from  AK_REGION_ITEMS
7444 where REGION_APPLICATION_ID = p_region_application_id
7445 and   REGION_CODE = p_region_code
7446 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
7447 and   ATTRIBUTE_CODE = p_attribute_code
7448 for   update of DISPLAY_SEQUENCE;
7449 cursor l_get_tl_row_csr (lang_parm varchar2) is
7450 select *
7451 from  AK_REGION_ITEMS_TL
7452 where REGION_APPLICATION_ID = p_region_application_id
7453 and   REGION_CODE = p_region_code
7454 and   ATTRIBUTE_APPLICATION_ID = p_attribute_application_id
7455 and   ATTRIBUTE_CODE = p_attribute_code
7456 and   LANGUAGE = lang_parm
7457 for update of ATTRIBUTE_LABEL_LONG;
7458 l_api_version_number     CONSTANT number := 1.0;
7459 l_api_name               CONSTANT varchar2(30) := 'Update_Item';
7460 l_created_by             number;
7461 l_creation_date          date;
7462 l_items_rec              ak_region_items%ROWTYPE;
7463 l_items_tl_rec           ak_region_items_tl%ROWTYPE;
7464 l_error                  boolean;
7465 l_lang                   varchar2(30);
7466 l_last_update_date       date;
7467 l_last_update_login      number;
7468 l_last_updated_by        number;
7469 l_object_attribute_flag  VARCHAR2(1);
7470 l_return_status          varchar2(1);
7471 l_submit					varchar2(1) := 'N';
7472 l_encrypt					varchar2(1) := 'N';
7473 l_admin_customizable				varchar2(1) := 'Y';
7474 l_file_version	number;
7475 l_create_or_update       VARCHAR2(10);
7476 begin
7477 IF NOT FND_API.Compatible_API_Call (
7478 l_api_version_number, p_api_version_number, l_api_name,
7479 G_PKG_NAME) then
7480 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7481 return;
7482 END IF;
7483 
7484 -- Initialize the message table if requested.
7485 
7486 if p_init_msg_tbl then
7487 FND_MSG_PUB.initialize;
7488 end if;
7489 
7490 savepoint start_update_item;
7491 
7492 select userenv('LANG') into l_lang
7493 from dual;
7494 
7495 --** retrieve ak_region_items row if it exists **
7496 open l_get_row_csr;
7497 fetch l_get_row_csr into l_items_rec;
7498 if (l_get_row_csr%notfound) then
7499 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7500 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
7501 FND_MSG_PUB.Add;
7502 end if;
7503 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
7504 close l_get_row_csr;
7505 raise FND_API.G_EXC_ERROR;
7506 end if;
7507 close l_get_row_csr;
7508 
7509 --** retrieve ak_region_items_tl row if it exists **
7510 open l_get_tl_row_csr(l_lang);
7511 fetch l_get_tl_row_csr into l_items_tl_rec;
7512 if (l_get_tl_row_csr%notfound) then
7513 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
7514 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_DOES_NOT_EXIST');
7515 FND_MSG_PUB.Add;
7516 end if;
7517 -- dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
7518 close l_get_tl_row_csr;
7519 raise FND_API.G_EXC_ERROR;
7520 end if;
7521 close l_get_tl_row_csr;
7522 
7523 --
7524 -- If the object_attribute_flag is missing, pass the value in the
7525 -- database to the validate_item procedure. This is done such that
7526 -- the validate_item procedure can check the validity of attribute
7527 -- key fields against ak_attributes or ak_object_attributes.
7528 --
7529 if (p_object_attribute_flag = FND_API.G_MISS_CHAR) then
7530 l_object_attribute_flag := l_items_rec.object_attribute_flag;
7531 else
7532 l_object_attribute_flag := p_object_attribute_flag;
7533 end if;
7534 
7535 if (p_display_sequence IS NOT NULL) and
7536 (p_display_sequence <> FND_API.G_MISS_NUM) then
7537 --** Check the given display sequence number
7538 AK_REGION2_PVT.CHECK_DISPLAY_SEQUENCE (  p_validation_level => p_validation_level,
7539 p_region_code => p_region_code,
7540 p_region_application_id => p_region_application_id,
7541 p_attribute_code => p_attribute_code,
7542 p_attribute_application_id => p_attribute_application_id,
7543 p_display_sequence => p_display_sequence,
7544 p_return_status => l_return_status,
7545 p_msg_count => p_msg_count,
7546 p_msg_data => p_msg_data,
7547 p_pass => p_pass,
7548 p_copy_redo_flag => p_copy_redo_flag);
7549 end if;
7550 
7551 --
7552 -- validate table columns passed in
7553 -- ** Note the special processing for object_attribute_flag **
7554 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
7555 if not AK_REGION_PVT.VALIDATE_ITEM (
7556 p_validation_level => p_validation_level,
7557 p_api_version_number => 1.0,
7558 p_return_status => l_return_status,
7559 p_region_application_id => p_region_application_id,
7560 p_region_code => p_region_code,
7561 p_attribute_application_id => p_attribute_application_id,
7562 p_attribute_code => p_attribute_code,
7563 p_display_sequence => p_display_sequence,
7564 p_node_display_flag => p_node_display_flag,
7565 p_node_query_flag => p_node_query_flag,
7566 p_attribute_label_length => p_attribute_label_length,
7567 p_display_value_length => p_display_value_length,
7568 p_bold => p_bold,
7569 p_italic => p_italic,
7570 p_vertical_alignment => p_vertical_alignment,
7571 p_horizontal_alignment => p_horizontal_alignment,
7572 p_item_style => p_item_style,
7573 p_object_attribute_flag => l_object_attribute_flag,
7574 p_icx_custom_call => p_icx_custom_call,
7575 p_update_flag => p_update_flag,
7576 p_required_flag => p_required_flag,
7577 p_security_code => p_security_code,
7578 p_default_value_varchar2 => p_default_value_varchar2,
7579 p_default_value_number => p_default_value_number,
7580 p_default_value_date => p_default_value_date,
7581 p_nested_region_appl_id => p_nested_region_appl_id,
7582 p_nested_region_code => p_nested_region_code,
7583 p_lov_region_application_id => p_lov_region_application_id,
7584 p_lov_region_code => p_lov_region_code,
7585 p_lov_foreign_key_name => p_lov_foreign_key_name,
7586 p_lov_attribute_application_id => p_lov_attribute_application_id,
7587 p_lov_attribute_code => p_lov_attribute_code,
7588 p_lov_default_flag => p_lov_default_flag,
7589 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
7590 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
7591 p_region_validation_api_pkg => p_region_validation_api_pkg,
7592 p_region_validation_api_proc => p_region_validation_api_proc,
7593 p_order_sequence => p_order_sequence,
7594 p_order_direction => p_order_direction,
7595 p_menu_name => p_menu_name,
7596 p_flexfield_name => p_flexfield_name,
7597 p_flexfield_application_id => p_flexfield_application_id,
7598 p_tabular_function_code    => p_tabular_function_code,
7599 p_tip_type                 => p_tip_type,
7600 p_tip_message_name          => p_tip_message_name,
7601 p_tip_message_application_id  => p_tip_message_application_id ,
7602 p_flex_segment_list        => p_flex_segment_list,
7603 p_entity_id                => p_entity_id,
7604 p_anchor                   => p_anchor,
7605 p_poplist_view_usage_name  => p_poplist_view_usage_name,
7606 p_user_customizable	       => p_user_customizable,
7607 p_sortby_view_attribute_name => p_sortby_view_attribute_name,
7608 p_invoke_function_name	=> p_invoke_function_name,
7609 p_expansion			=> p_expansion,
7610 p_als_max_length		=> p_als_max_length,
7611 p_initial_sort_sequence     => p_initial_sort_sequence,
7612 p_customization_application_id => p_customization_application_id,
7613 p_customization_code => p_customization_application_id,
7614 p_attribute_label_long => p_attribute_label_long,
7615 p_attribute_label_short => p_attribute_label_short,
7616 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
7617 p_pass => p_pass
7618 ) then
7619 --dbms_output.put_line(l_api_name || ' validation failed');
7620 -- Do not raise an error if it's the first pass
7621 if (p_pass = 1) then
7622 p_copy_redo_flag := TRUE;
7623 else
7624 raise FND_API.G_EXC_ERROR;
7625 end if;
7626 end if;
7627 end if;
7628 
7629 --** Load record to be updated to the database **
7630 --** - first load nullable columns **
7631 
7632 if (p_icx_custom_call <> FND_API.G_MISS_CHAR) or
7633 (p_icx_custom_call is null) then
7634 l_items_rec.icx_custom_call := p_icx_custom_call;
7635 end if;
7636 
7637 if (p_security_code <> FND_API.G_MISS_CHAR) or
7638 (p_security_code is null) then
7639 l_items_rec.security_code := p_security_code;
7640 end if;
7641 
7642 if (p_default_value_varchar2 <> FND_API.G_MISS_CHAR) or
7643 (p_default_value_varchar2 is null) then
7644 l_items_rec.default_value_varchar2 := p_default_value_varchar2;
7645 end if;
7646 
7647 if (p_default_value_number <> FND_API.G_MISS_NUM) or
7648 (p_default_value_number is null) then
7649 l_items_rec.default_value_number := p_default_value_number;
7650 end if;
7651 
7652 if (p_default_value_date <> FND_API.G_MISS_DATE) or
7653 (p_default_value_date is null) then
7654 l_items_rec.default_value_date := p_default_value_date;
7655 end if;
7656 
7657 if (p_lov_region_application_id <> FND_API.G_MISS_NUM) or
7658 (p_lov_region_application_id is null) then
7659 l_items_rec.lov_region_application_id := p_lov_region_application_id;
7660 end if;
7661 
7662 if (p_lov_region_code <> FND_API.G_MISS_CHAR) or
7663 (p_lov_region_code is null) then
7664 l_items_rec.lov_region_code := p_lov_region_code;
7665 end if;
7666 
7667 if (p_lov_foreign_key_name <> FND_API.G_MISS_CHAR) or
7668 (p_lov_foreign_key_name is null) then
7669 l_items_rec.lov_foreign_key_name := p_lov_foreign_key_name;
7670 end if;
7671 
7672 if (p_lov_attribute_application_id <> FND_API.G_MISS_NUM) or
7673 (p_lov_attribute_application_id is null) then
7674 l_items_rec.lov_attribute_application_id := p_lov_attribute_application_id;
7675 end if;
7676 
7677 if (p_lov_attribute_code <> FND_API.G_MISS_CHAR) or
7678 (p_lov_attribute_code is null) then
7679 l_items_rec.lov_attribute_code := p_lov_attribute_code;
7680 end if;
7681 
7682 if (p_lov_default_flag <> FND_API.G_MISS_CHAR) or
7683 (p_lov_default_flag is null) then
7684 l_items_rec.lov_default_flag := p_lov_default_flag;
7685 end if;
7686 
7687 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) or
7688 (p_region_defaulting_api_pkg is null) then
7689 l_items_rec.region_defaulting_api_pkg := p_region_defaulting_api_pkg;
7690 end if;
7691 
7692 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) or
7693 (p_region_defaulting_api_proc is null) then
7694 l_items_rec.region_defaulting_api_proc := p_region_defaulting_api_proc;
7695 end if;
7696 
7697 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) or
7698 (p_region_validation_api_pkg is null) then
7699 l_items_rec.region_validation_api_pkg := p_region_validation_api_pkg;
7700 end if;
7701 
7702 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) or
7703 (p_region_validation_api_proc is null) then
7704 l_items_rec.region_validation_api_proc := p_region_validation_api_proc;
7705 end if;
7706 
7707 if (p_order_sequence <> FND_API.G_MISS_NUM) or
7708 (p_order_sequence is null) then
7709 l_items_rec.order_sequence := p_order_sequence;
7710 end if;
7711 
7712 if (p_order_direction <> FND_API.G_MISS_CHAR) or
7713 (p_order_direction is null) then
7714 l_items_rec.order_direction := p_order_direction;
7715 end if;
7716 
7717 if (p_display_height <> FND_API.G_MISS_NUM) then
7718 l_items_rec.display_height := p_display_height;
7719 end if;
7720 
7721 if (p_css_class_name <> FND_API.G_MISS_CHAR) or
7722 (p_css_class_name is null) then
7723 l_items_rec.css_class_name := p_css_class_name;
7724 end if;
7725 
7726 if (p_view_usage_name <> FND_API.G_MISS_CHAR) or
7727 (p_view_usage_name is null) then
7728 l_items_rec.view_usage_name := p_view_usage_name;
7729 end if;
7730 
7731 if (p_view_attribute_name <> FND_API.G_MISS_CHAR) or
7732 (p_view_attribute_name is null) then
7733 l_items_rec.view_attribute_name := p_view_attribute_name;
7734 end if;
7735 
7736 if (p_nested_region_appl_id <> FND_API.G_MISS_NUM) or
7737 (p_nested_region_appl_id is null) then
7738 l_items_rec.nested_region_application_id := p_nested_region_appl_id;
7739 end if;
7740 
7741 if (p_nested_region_code <> FND_API.G_MISS_CHAR) or
7742 (p_nested_region_code is null) then
7743 l_items_rec.nested_region_code := p_nested_region_code;
7744 end if;
7745 
7746 if (p_url <> FND_API.G_MISS_CHAR) or
7747 (p_url is null) then
7748 l_items_rec.url := p_url;
7749 end if;
7750 
7751 if (p_poplist_viewobject <> FND_API.G_MISS_CHAR) or
7752 (p_poplist_viewobject is null) then
7753 l_items_rec.poplist_viewobject := p_poplist_viewobject;
7754 end if;
7755 
7756 if (p_poplist_display_attr <> FND_API.G_MISS_CHAR) or
7757 (p_poplist_display_attr is null) then
7758 l_items_rec.poplist_display_attribute := p_poplist_display_attr;
7759 end if;
7760 
7761 if (p_poplist_value_attr <> FND_API.G_MISS_CHAR) or
7762 (p_poplist_value_attr is null) then
7763 l_items_rec.poplist_value_attribute := p_poplist_value_attr;
7764 end if;
7765 
7766 if (p_image_file_name <> FND_API.G_MISS_CHAR) or
7767 (p_image_file_name is null) then
7768 l_items_rec.image_file_name := p_image_file_name;
7769 end if;
7770 
7771 if (p_item_name <> FND_API.G_MISS_CHAR) or
7772 (p_item_name is null) then
7773 l_items_rec.item_name := p_item_name;
7774 end if;
7775 
7776 if (p_css_label_class_name <> FND_API.G_MISS_CHAR) or
7777 (p_css_label_class_name is null) then
7778 l_items_rec.css_label_class_name := p_css_label_class_name;
7779 end if;
7780 
7781 if (p_menu_name <> FND_API.G_MISS_CHAR) or
7782 (p_menu_name is null) then
7783 l_items_rec.menu_name := p_menu_name;
7784 end if;
7785 
7786 if (p_flexfield_name <> FND_API.G_MISS_CHAR) or
7787 (p_flexfield_name is null) then
7788 l_items_rec.flexfield_name := p_flexfield_name;
7789 end if;
7790 
7791 if (p_flexfield_application_id <> FND_API.G_MISS_NUM) or
7792 (p_flexfield_application_id is null) then
7793 l_items_rec.flexfield_application_id := p_flexfield_application_id;
7794 end if;
7795 
7796 if (p_tabular_function_code <> FND_API.G_MISS_CHAR) or
7797 (p_tabular_function_code is null) then
7798 l_items_rec.tabular_function_code := p_tabular_function_code;
7799 end if;
7800 
7801 if (p_tip_type <> FND_API.G_MISS_CHAR) or
7802 (p_tip_type is null) then
7803 l_items_rec.tip_type := p_tip_type;
7804 end if;
7805 
7806 if (p_tip_message_name <> FND_API.G_MISS_CHAR) or
7807 (p_tip_message_name is null) then
7808 l_items_rec.tip_message_name := p_tip_message_name;
7809 end if;
7810 
7811 if (p_tip_message_application_id <> FND_API.G_MISS_NUM) or
7812 (p_tip_message_application_id is null) then
7813 l_items_rec.tip_message_application_id := p_tip_message_application_id;
7814 end if;
7815 
7816 if (p_flex_segment_list <> FND_API.G_MISS_CHAR) or
7817 (p_flex_segment_list is null) then
7818 l_items_rec.flex_segment_list := p_flex_segment_list;
7819 end if;
7820 
7821 if (p_entity_id <> FND_API.G_MISS_CHAR) or
7822 (p_entity_id is null) then
7823 l_items_rec.entity_id := p_entity_id;
7824 end if;
7825 
7826 if (p_anchor <> FND_API.G_MISS_CHAR or p_anchor is null) then
7827 l_items_rec.anchor := p_anchor;
7828 end if;
7829 
7830 if (p_poplist_view_usage_name <> FND_API.G_MISS_CHAR) or
7831 (p_poplist_view_usage_name is null) then
7832 l_items_rec.poplist_view_usage_name := p_poplist_view_usage_name;
7833 end if;
7834 
7835 if (p_user_customizable <> FND_API.G_MISS_CHAR) or
7836 (p_user_customizable is null) then
7837 l_items_rec.user_customizable := p_user_customizable;
7838 end if;
7839 
7840 if (p_sortby_view_attribute_name <> FND_API.G_MISS_CHAR) or
7841 (p_sortby_view_attribute_name is null) then
7842 l_items_rec.sortby_view_attribute_name := p_sortby_view_attribute_name;
7843 end if;
7844 
7845 if (p_invoke_function_name <> FND_API.G_MISS_CHAR) or
7846 (p_invoke_function_name is null) then
7847 l_items_rec.invoke_function_name := p_invoke_function_name;
7848 end if;
7849 
7850 if (p_expansion <> FND_API.G_MISS_NUM) or
7851 (p_expansion is null) then
7852 l_items_rec.expansion := p_expansion;
7853 end if;
7854 
7855 if (p_als_max_length <> FND_API.G_MISS_NUM) or
7856 (p_als_max_length is null) then
7857 l_items_rec.als_max_length := p_als_max_length;
7858 end if;
7859 
7860 if (p_initial_sort_sequence <> FND_API.G_MISS_CHAR) or
7861 (p_initial_sort_sequence is null) then
7862 l_items_rec.initial_sort_sequence := p_initial_sort_sequence;
7863 end if;
7864 
7865 if (p_customization_application_id <> FND_API.G_MISS_NUM) or
7866 (p_customization_application_id is null) then
7867 l_items_rec.customization_application_id := p_customization_application_id;
7868 end if;
7869 
7870 if (p_customization_code <> FND_API.G_MISS_CHAR) or
7871 (p_customization_code is null) then
7872 l_items_rec.customization_code := p_customization_code;
7873 end if;
7874 
7875 if (p_attribute_category <> FND_API.G_MISS_CHAR) or
7876 (p_attribute_category is null) then
7877 l_items_rec.attribute_category := p_attribute_category;
7878 end if;
7879 if (p_attribute1 <> FND_API.G_MISS_CHAR) or
7880 (p_attribute1 is null) then
7881 l_items_rec.attribute1 := p_attribute1;
7882 end if;
7883 if (p_attribute2 <> FND_API.G_MISS_CHAR) or
7884 (p_attribute2 is null) then
7885 l_items_rec.attribute2 := p_attribute2;
7886 end if;
7887 if (p_attribute3 <> FND_API.G_MISS_CHAR) or
7888 (p_attribute3 is null) then
7889 l_items_rec.attribute3 := p_attribute3;
7890 end if;
7891 if (p_attribute4 <> FND_API.G_MISS_CHAR) or
7892 (p_attribute4 is null) then
7893 l_items_rec.attribute4 := p_attribute4;
7894 end if;
7895 if (p_attribute5 <> FND_API.G_MISS_CHAR) or
7896 (p_attribute5 is null) then
7897 l_items_rec.attribute5 := p_attribute5;
7898 end if;
7899 if (p_attribute6 <> FND_API.G_MISS_CHAR) or
7900 (p_attribute6 is null) then
7901 l_items_rec.attribute6 := p_attribute6;
7902 end if;
7903 if (p_attribute7 <> FND_API.G_MISS_CHAR) or
7904 (p_attribute7 is null) then
7905 l_items_rec.attribute7 := p_attribute7;
7906 end if;
7907 if (p_attribute8 <> FND_API.G_MISS_CHAR) or
7908 (p_attribute8 is null) then
7909 l_items_rec.attribute8 := p_attribute8;
7910 end if;
7911 if (p_attribute9 <> FND_API.G_MISS_CHAR) or
7912 (p_attribute9 is null) then
7913 l_items_rec.attribute9 := p_attribute9;
7914 end if;
7915 if (p_attribute10 <> FND_API.G_MISS_CHAR) or
7916 (p_attribute10 is null) then
7917 l_items_rec.attribute10 := p_attribute10;
7918 end if;
7919 if (p_attribute11 <> FND_API.G_MISS_CHAR) or
7920 (p_attribute11 is null) then
7921 l_items_rec.attribute11 := p_attribute11;
7922 end if;
7923 if (p_attribute12 <> FND_API.G_MISS_CHAR) or
7924 (p_attribute12 is null) then
7925 l_items_rec.attribute12 := p_attribute12;
7926 end if;
7927 if (p_attribute13 <> FND_API.G_MISS_CHAR) or
7928 (p_attribute13 is null) then
7929 l_items_rec.attribute13 := p_attribute13;
7930 end if;
7931 
7932 if (p_attribute14 <> FND_API.G_MISS_CHAR) or
7933 (p_attribute14 is null) then
7934 l_items_rec.attribute14 := p_attribute14;
7935 end if;
7936 
7937 if (p_attribute15 <> FND_API.G_MISS_CHAR) or
7938 (p_attribute15 is null) then
7939 l_items_rec.attribute15 := p_attribute15;
7940 end if;
7941 
7942 if (p_attribute_label_long <> FND_API.G_MISS_CHAR) or
7943 (p_attribute_label_long is null) then
7944 l_items_tl_rec.attribute_label_long := p_attribute_label_long;
7945 end if;
7946 
7947 if (p_attribute_label_short <> FND_API.G_MISS_CHAR) or
7948 (p_attribute_label_short is null) then
7949 l_items_tl_rec.attribute_label_short := p_attribute_label_short;
7950 end if;
7951 
7952 if (p_description <> FND_API.G_MISS_CHAR) or
7953 (p_description is null) then
7954 l_items_tl_rec.description := p_description;
7955 end if;
7956 
7957 --** - next, load non-null columns **
7958 
7959 if (p_display_sequence<> FND_API.G_MISS_NUM) then
7960 l_items_rec.display_sequence := p_display_sequence;
7961 end if;
7962 if (p_node_display_flag <> FND_API.G_MISS_CHAR) then
7963 l_items_rec.node_display_flag := p_node_display_flag;
7964 end if;
7965 if (p_node_query_flag <> FND_API.G_MISS_CHAR) then
7966 l_items_rec.node_query_flag := p_node_query_flag;
7967 end if;
7968 if (p_attribute_label_length <> FND_API.G_MISS_NUM) then
7969 l_items_rec.attribute_label_length := p_attribute_label_length;
7970 end if;
7971 if (p_display_value_length <> FND_API.G_MISS_NUM) then
7972 l_items_rec.display_value_length := p_display_value_length;
7973 end if;
7974 if (p_bold <> FND_API.G_MISS_CHAR) then
7975 l_items_rec.bold := p_bold;
7976 end if;
7977 if (p_italic <> FND_API.G_MISS_CHAR) then
7978 l_items_rec.italic := p_italic;
7979 end if;
7980 if (p_vertical_alignment <> FND_API.G_MISS_CHAR) then
7981 l_items_rec.vertical_alignment := p_vertical_alignment;
7982 end if;
7983 if (p_horizontal_alignment <> FND_API.G_MISS_CHAR) then
7984 l_items_rec.horizontal_alignment := p_horizontal_alignment;
7985 end if;
7986 if (p_item_style <> FND_API.G_MISS_CHAR) then
7987 l_items_rec.item_style := p_item_style;
7988 end if;
7989 if (p_object_attribute_flag <> FND_API.G_MISS_CHAR) then
7990 l_items_rec.object_attribute_flag := p_object_attribute_flag;
7991 end if;
7992 if (p_update_flag <> FND_API.G_MISS_CHAR) then
7993 l_items_rec.update_flag := p_update_flag;
7994 end if;
7995 --
7996 -- special logic for handling update_flag, bug#2054285
7997 -- set update_flag to 'Y'
7998 -- do not change update_flag to 'Y' if FILE_FORMAT_VERSION > 115.14
7999 --
8000 if ( ( AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER1 or
8001 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER2 or
8002 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER3 or
8003 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER4 or
8004 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER5 or
8005 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER6 or
8006 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER7 or
8007 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER8 or
8008 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER9 or
8009 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER11 or
8010 AK_ON_OBJECTS_PUB.G_UPLOAD_FILE_VERSION = AK_ON_OBJECTS_PUB.G_OLD_FILE_FORMAT_VER12 ) and
8011 ( p_item_style = 'CHECKBOX' or p_item_style = 'DESCRIPTIVE_FLEX' or
8012 p_item_style = 'KEY_FLEX' or p_item_style = 'FILE' or
8013 p_item_style = 'FORM_PARAMETER_BEAN' or p_item_style = 'RADIO_BUTTON' or
8014 p_item_style  = 'POPLIST' or p_item_style = 'HIDDEN' or
8015 p_item_style = 'TEXT_INPUT' or p_item_style = 'RADIO_GROUP') and
8016 INSTR(p_region_code,'POR') <> 1 ) then
8017 l_items_rec.update_flag := 'Y';
8018 end if;
8019 
8020 
8021 if (p_required_flag <> FND_API.G_MISS_CHAR) then
8022 l_items_rec.required_flag := p_required_flag;
8023 end if;
8024 if (p_submit <> FND_API.G_MISS_CHAR and p_submit is not null) then
8025 l_items_rec.submit := p_submit;
8026 else
8027 l_items_rec.submit := l_submit;
8028 end if;
8029 if (p_encrypt <> FND_API.G_MISS_CHAR and p_encrypt is not null) then
8030 l_items_rec.encrypt := p_encrypt;
8031 else
8032 l_items_rec.encrypt := l_encrypt;
8033 end if;
8034 if (p_admin_customizable <> FND_API.G_MISS_CHAR and p_admin_customizable is not null) then
8035 l_items_rec.admin_customizable := p_admin_customizable;
8036 else
8037 l_items_rec.admin_customizable := l_admin_customizable;
8038 end if;
8039   if (p_created_by <> FND_API.G_MISS_NUM) then
8040     l_created_by := p_created_by;
8041   end if;
8042   if (p_creation_date <> FND_API.G_MISS_DATE) then
8043     l_creation_date := p_creation_date;
8044   end if;
8045   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
8046     l_last_updated_by := p_last_updated_by;
8047   end if;
8048   if (p_last_update_date <> FND_API.G_MISS_DATE) then
8049     l_last_update_date := p_last_update_date;
8050   end if;
8051   if (p_last_update_login <> FND_API.G_MISS_NUM) then
8052     l_last_update_login := p_last_update_login;
8053   end if;
8054 
8055   /* 5452422 - if display_sequence has been raised then force update */
8056   if (p_display_sequence >= 1000000) then
8057 	l_create_or_update := 'FORCE';
8058   else
8059 	l_create_or_update := 'UPDATE';
8060   end if;
8061 
8062   if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
8063        p_loader_timestamp => p_loader_timestamp,
8064        p_created_by => l_created_by,
8065        p_creation_date => l_creation_date,
8066        p_last_updated_by => l_last_updated_by,
8067        p_db_last_updated_by => l_items_rec.last_updated_by,
8068        p_last_update_date => l_last_update_date,
8069        p_db_last_update_date => l_items_rec.last_update_date,
8070        p_last_update_login => l_last_update_login,
8071        p_create_or_update => l_create_or_update) then
8072 
8073 update AK_REGION_ITEMS set
8074 DISPLAY_SEQUENCE = l_items_rec.display_sequence,
8075 NODE_DISPLAY_FLAG = l_items_rec.node_display_flag,
8076 NODE_QUERY_FLAG = l_items_rec.node_query_flag,
8077 ATTRIBUTE_LABEL_LENGTH = l_items_rec.attribute_label_length,
8078 DISPLAY_VALUE_LENGTH = l_items_rec.display_value_length,
8079 BOLD = l_items_rec.bold,
8080 ITALIC = l_items_rec.italic,
8081 VERTICAL_ALIGNMENT = l_items_rec.vertical_alignment,
8082 HORIZONTAL_ALIGNMENT = l_items_rec.horizontal_alignment,
8083 ITEM_STYLE = l_items_rec.item_style,
8084 OBJECT_ATTRIBUTE_FLAG = l_items_rec.object_attribute_flag,
8085 ICX_CUSTOM_CALL = l_items_rec.icx_custom_call,
8086 UPDATE_FLAG = l_items_rec.update_flag,
8087 REQUIRED_FLAG = l_items_rec.required_flag,
8088 SECURITY_CODE = l_items_rec.security_code,
8089 DEFAULT_VALUE_VARCHAR2 = l_items_rec.default_value_varchar2,
8090 DEFAULT_VALUE_NUMBER = l_items_rec.default_value_number,
8091 DEFAULT_VALUE_DATE = l_items_rec.default_value_date,
8092 LOV_REGION_APPLICATION_ID = l_items_rec.lov_region_application_id,
8093 LOV_REGION_CODE = l_items_rec.lov_region_code,
8094 LOV_FOREIGN_KEY_NAME = l_items_rec.lov_foreign_key_name,
8095 LOV_ATTRIBUTE_APPLICATION_ID =
8096 l_items_rec.lov_attribute_application_id,
8097 LOV_ATTRIBUTE_CODE = l_items_rec.lov_attribute_code,
8098 LOV_DEFAULT_FLAG = l_items_rec.lov_default_flag,
8099 REGION_DEFAULTING_API_PKG = l_items_rec.region_defaulting_api_pkg,
8100 REGION_DEFAULTING_API_PROC = l_items_rec.region_defaulting_api_proc,
8101 REGION_VALIDATION_API_PKG = l_items_rec.region_validation_api_pkg,
8102 REGION_VALIDATION_API_PROC = l_items_rec.region_validation_api_proc,
8103 ORDER_SEQUENCE = l_items_rec.order_sequence,
8104 ORDER_DIRECTION = l_items_rec.order_direction,
8105 DISPLAY_HEIGHT = l_items_rec.display_height,
8106 SUBMIT = l_items_rec.submit,
8107 ENCRYPT = l_items_rec.encrypt,
8108 css_class_name = l_items_rec.css_class_name,
8109 VIEW_USAGE_NAME = l_items_rec.view_usage_name,
8110 VIEW_ATTRIBUTE_NAME = l_items_rec.view_attribute_name,
8111 NESTED_REGION_APPLICATION_ID = l_items_rec.nested_region_application_id,
8112 NESTED_REGION_CODE = l_items_rec.nested_region_code,
8113 URL = l_items_rec.url,
8114 POPLIST_VIEWOBJECT = l_items_rec.poplist_viewobject,
8115 POPLIST_DISPLAY_ATTRIBUTE = l_items_rec.poplist_display_attribute,
8116 POPLIST_VALUE_ATTRIBUTE = l_Items_rec.poplist_value_attribute,
8117 IMAGE_FILE_NAME = l_items_rec.image_file_name,
8118 ITEM_NAME = l_items_rec.item_name,
8119 CSS_LABEL_CLASS_NAME = l_items_rec.css_label_class_name,
8120 MENU_NAME = l_items_rec.menu_name,
8121 FLEXFIELD_NAME = l_items_rec.flexfield_name,
8122 FLEXFIELD_APPLICATION_ID = l_items_rec.flexfield_application_id,
8123 TABULAR_FUNCTION_CODE = l_items_rec.tabular_function_code,
8124 TIP_TYPE  = l_items_rec.tip_type,
8125 TIP_MESSAGE_NAME = l_items_rec.tip_message_name,
8126 TIP_MESSAGE_APPLICATION_ID = l_items_rec.tip_message_application_id,
8127 FLEX_SEGMENT_LIST = l_items_rec.flex_segment_list,
8128 ENTITY_ID = l_items_rec.entity_id,
8129 ANCHOR = l_items_rec.anchor,
8130 POPLIST_VIEW_USAGE_NAME = l_items_rec.poplist_view_usage_name,
8131 USER_CUSTOMIZABLE = l_items_rec.user_customizable,
8132 SORTBY_VIEW_ATTRIBUTE_NAME = l_items_rec.sortby_view_attribute_name,
8133 ADMIN_CUSTOMIZABLE = l_items_rec.admin_customizable,
8134 INVOKE_FUNCTION_NAME = l_items_rec.invoke_function_name,
8135 EXPANSION = l_items_rec.expansion,
8136 ALS_MAX_LENGTH = l_items_rec.als_max_length,
8137 INITIAL_SORT_SEQUENCE = l_items_rec.initial_sort_sequence,
8138 CUSTOMIZATION_APPLICATION_ID = l_items_rec.customization_application_id,
8139 CUSTOMIZATION_CODE = l_items_rec.customization_code,
8140 ATTRIBUTE_CATEGORY = l_items_rec.attribute_category,
8141 ATTRIBUTE1 = l_items_rec.attribute1,
8142 ATTRIBUTE2 = l_items_rec.attribute2,
8143 ATTRIBUTE3 = l_items_rec.attribute3,
8144 ATTRIBUTE4 = l_items_rec.attribute4,
8145 ATTRIBUTE5 = l_items_rec.attribute5,
8146 ATTRIBUTE6 = l_items_rec.attribute6,
8147 ATTRIBUTE7 = l_items_rec.attribute7,
8148 ATTRIBUTE8 = l_items_rec.attribute8,
8149 ATTRIBUTE9 = l_items_rec.attribute9,
8150 ATTRIBUTE10 = l_items_rec.attribute10,
8151 ATTRIBUTE11 = l_items_rec.attribute11,
8152 ATTRIBUTE12 = l_items_rec.attribute12,
8153 ATTRIBUTE13 = l_items_rec.attribute13,
8154 ATTRIBUTE14 = l_items_rec.attribute14,
8155 ATTRIBUTE15 = l_items_rec.attribute15,
8156 LAST_UPDATE_DATE = l_last_update_date,
8157 LAST_UPDATED_BY = l_last_updated_by,
8158 LAST_UPDATE_LOGIN = l_last_update_login
8159 where REGION_APPLICATION_ID = p_region_application_id
8160 and   REGION_CODE = p_region_code
8161 and   attribute_application_id = p_attribute_application_id
8162 and   attribute_code = p_attribute_code;
8163 if (sql%notfound) then
8164 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8165 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATE_FAILED');
8166 FND_MSG_PUB.Add;
8167 end if;
8168 -- dbms_output.put_line(l_api_name || 'Row does not exist during update');
8169 raise FND_API.G_EXC_ERROR;
8170 end if;
8171 
8172 update AK_REGION_ITEMS_TL set
8173 ATTRIBUTE_LABEL_LONG = l_items_tl_rec.attribute_label_long,
8174 ATTRIBUTE_LABEL_SHORT = l_items_tl_rec.attribute_label_short,
8175 DESCRIPTION = l_items_tl_rec.description,
8176 LAST_UPDATED_BY = l_last_updated_by,
8177 LAST_UPDATE_DATE = l_last_update_date,
8178 LAST_UPDATE_LOGIN = l_last_update_login,
8179 SOURCE_LANG = l_lang
8180 where REGION_APPLICATION_ID = p_region_application_id
8181 and   REGION_CODE = p_region_code
8182 and   attribute_application_id = p_attribute_application_id
8183 and   attribute_code = p_attribute_code
8184 and   l_lang in (LANGUAGE, SOURCE_LANG);
8185 if (sql%notfound) then
8186 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8187 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATE_FAILED');
8188 FND_MSG_PUB.Add;
8189 end if;
8190 --dbms_output.put_line(l_api_name || 'TL Row does not exist during update');
8191 raise FND_API.G_EXC_ERROR;
8192 end if;
8193 
8194 --  /** commit the update **/
8195  commit;
8196 
8197 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
8198 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_UPDATED');
8199 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8200 ' ' || p_region_code ||
8201 ' ' || to_char(p_attribute_application_id) ||
8202 ' ' || p_attribute_code);
8203 FND_MSG_PUB.Add;
8204 end if;
8205 
8206 end if;
8207 p_return_status := FND_API.G_RET_STS_SUCCESS;
8208 
8209 FND_MSG_PUB.Count_And_Get (
8210 p_count => p_msg_count,
8211 p_data => p_msg_data);
8212 
8213 EXCEPTION
8214 WHEN VALUE_ERROR THEN
8215 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8216 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_VALUE_ERROR');
8217 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8218 ' ' || p_region_code ||
8219 ' ' || to_char(p_attribute_application_id) ||
8220 ' ' || p_attribute_code);
8221 FND_MSG_PUB.Add;
8222 end if;
8223 rollback to start_update_item;
8224 p_return_status := FND_API.G_RET_STS_ERROR;
8225 FND_MSG_PUB.Count_And_Get (
8226 p_count => p_msg_count,
8227 p_data => p_msg_data);
8228 WHEN FND_API.G_EXC_ERROR THEN
8229 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8230 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_UPDATED');
8231 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8232 ' ' || p_region_code ||
8233 ' ' || to_char(p_attribute_application_id) ||
8234 ' ' || p_attribute_code);
8235 FND_MSG_PUB.Add;
8236 end if;
8237 p_return_status := FND_API.G_RET_STS_ERROR;
8238 rollback to start_update_item;
8239 FND_MSG_PUB.Count_And_Get (
8240 p_count => p_msg_count,
8241 p_data => p_msg_data);
8242 WHEN OTHERS THEN
8243 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8244 rollback to start_update_item;
8245 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8246 SUBSTR (SQLERRM, 1, 240) );
8247 FND_MSG_PUB.Add;
8248 FND_MESSAGE.SET_NAME('AK','AK_REG_ITEM_NOT_UPDATED');
8249 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8250 ' ' || p_region_code ||
8251 ' ' || to_char(p_attribute_application_id) ||
8252 ' ' || p_attribute_code);
8253 FND_MSG_PUB.Add;
8254 FND_MSG_PUB.Count_And_Get (
8255 p_count => p_msg_count,
8256 p_data => p_msg_data);
8257 end UPDATE_ITEM;
8258 
8259 --=======================================================
8260 --  Procedure   UPDATE_REGION
8261 --
8262 --  Usage       Private API for updating a region.
8263 --              This API should only be called by other APIs
8264 --              that are owned by the Core Modules Team (AK).
8265 --
8266 --  Desc        This API updates a region using the given info
8267 --
8268 --  Results     The API returns the standard p_return_status parameter
8269 --              indicating one of the standard return statuses :
8270 --                  * Unexpected error
8271 --                  * Error
8272 --                  * Success
8273 --  Parameters  Region columns
8274 --              p_loader_timestamp : IN optional
8275 --                  If a timestamp is passed, the API will update the
8276 --                  record using this timestamp. Only the upload API
8277 --                  should call with this parameter loaded.
8278 --
8279 --  Version     Initial version number  =   1.0
8280 --  History     Current version number  =   1.0
8281 --=======================================================
8282 procedure UPDATE_REGION (
8283 p_validation_level         IN      NUMBER := FND_API.G_VALID_LEVEL_FULL,
8284 p_api_version_number       IN      NUMBER,
8285 p_init_msg_tbl             IN      BOOLEAN := FALSE,
8286 p_msg_count                OUT NOCOPY     NUMBER,
8287 p_msg_data                 OUT NOCOPY     VARCHAR2,
8288 p_return_status            OUT NOCOPY     VARCHAR2,
8289 p_region_application_id    IN      NUMBER,
8290 p_region_code              IN      VARCHAR2,
8291 p_database_object_name     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8292 p_region_style             IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8293 p_icx_custom_call          IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8294 p_num_columns              IN      NUMBER := FND_API.G_MISS_NUM,
8295 p_region_defaulting_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
8296 p_region_defaulting_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
8297 p_region_validation_api_pkg IN     VARCHAR2 := FND_API.G_MISS_CHAR,
8298 p_region_validation_api_proc IN    VARCHAR2 := FND_API.G_MISS_CHAR,
8299 p_appmodule_object_type	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8300 p_num_rows_display		 IN		 NUMBER := FND_API.G_MISS_NUM,
8301 p_region_object_type		 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8302 p_image_file_name			 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8303 p_isform_flag				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8304 p_help_target				 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8305 p_style_sheet_filename	 IN		 VARCHAR2 := FND_API.G_MISS_CHAR,
8306 p_version                  IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8307 p_applicationmodule_usage_name IN  VARCHAR2 := FND_API.G_MISS_CHAR,
8308 p_add_indexed_children     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8309 p_stateful_flag	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8310 p_function_name            IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8311 p_children_view_usage_name IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8312 p_search_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8313 p_advanced_search_panel    IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8314 p_customize_panel	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8315 p_default_search_panel     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8316 p_results_based_search     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8317 p_display_graph_table	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8318 p_disable_header	     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8319 p_standalone		     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8320 p_auto_customization_criteria IN   VARCHAR2 := FND_API.G_MISS_CHAR,
8321 p_attribute_category       IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8322 p_attribute1               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8323 p_attribute2               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8324 p_attribute3               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8325 p_attribute4               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8326 p_attribute5               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8327 p_attribute6               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8328 p_attribute7               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8329 p_attribute8               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8330 p_attribute9               IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8331 p_attribute10              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8332 p_attribute11              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8333 p_attribute12              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8334 p_attribute13              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8335 p_attribute14              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8336 p_attribute15              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8337 p_name                     IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8338 p_description              IN      VARCHAR2 := FND_API.G_MISS_CHAR,
8339 p_created_by               IN     NUMBER := FND_API.G_MISS_NUM,
8340 p_creation_date            IN      DATE := FND_API.G_MISS_DATE,
8341 p_last_updated_by          IN     NUMBER := FND_API.G_MISS_NUM,
8342 p_last_update_date         IN      DATE := FND_API.G_MISS_DATE,
8343 p_last_update_login        IN     NUMBER := FND_API.G_MISS_NUM,
8344 p_loader_timestamp         IN      DATE := FND_API.G_MISS_DATE,
8345 p_pass                     IN      NUMBER,
8346 p_copy_redo_flag           IN OUT NOCOPY  BOOLEAN
8347 ) is
8348 cursor l_get_row_csr is
8349 select *
8350 from  AK_REGIONS
8351 where REGION_APPLICATION_ID = p_region_application_id
8352 and   REGION_CODE = p_region_code
8353 for update of REGION_STYLE;
8354 cursor l_get_tl_row_csr (lang_parm varchar2) is
8355 select *
8356 from  AK_REGIONS_TL
8357 where REGION_APPLICATION_ID = p_region_application_id
8358 and   REGION_CODE = p_region_code
8359 and   LANGUAGE = lang_parm
8360 for update of NAME;
8361 l_api_version_number      CONSTANT number := 1.0;
8362 l_api_name                CONSTANT varchar2(30) := 'Update_Region';
8363 l_created_by              number;
8364 l_creation_date           date;
8365 l_regions_rec             AK_REGIONS%ROWTYPE;
8366 l_regions_tl_rec          AK_REGIONS_TL%ROWTYPE;
8367 l_isform_flag				VARCHAR2(1) := 'N';
8368 l_lang                    varchar2(30);
8369 l_last_update_date        date;
8370 l_last_update_login       number;
8371 l_last_updated_by         number;
8372 l_return_status           varchar2(1);
8373 l_file_version	number;
8374 begin
8375 IF NOT FND_API.Compatible_API_Call (
8376 l_api_version_number, p_api_version_number, l_api_name,
8377 G_PKG_NAME) then
8378 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8379 return;
8380 END IF;
8381 
8382 -- Initialize the message table if requested.
8383 
8384 if p_init_msg_tbl then
8385 FND_MSG_PUB.initialize;
8386 end if;
8387 
8388 savepoint start_update_region;
8389 
8390 select userenv('LANG') into l_lang
8391 from dual;
8392 
8393 --** retrieve ak_regions row if it exists **
8394 open l_get_row_csr;
8395 fetch l_get_row_csr into l_regions_rec;
8396 if (l_get_row_csr%notfound) then
8397 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
8398 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
8399 FND_MSG_PUB.Add;
8400 end if;
8401 --dbms_output.put_line(l_api_name || 'Error - Row does not exist');
8402 close l_get_row_csr;
8403 raise FND_API.G_EXC_ERROR;
8404 end if;
8405 close l_get_row_csr;
8406 
8407 --** retrieve ak_regions_tl row if it exists **
8408 open l_get_tl_row_csr(l_lang);
8409 fetch l_get_tl_row_csr into l_regions_tl_rec;
8410 if (l_get_tl_row_csr%notfound) then
8411 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) then
8412 FND_MESSAGE.SET_NAME('AK','AK_REGION_DOES_NOT_EXIST');
8413 FND_MSG_PUB.Add;
8414 end if;
8415 --dbms_output.put_line(l_api_name || 'Error - TL Row does not exist');
8416 close l_get_tl_row_csr;
8417 raise FND_API.G_EXC_ERROR;
8418 end if;
8419 close l_get_tl_row_csr;
8420 
8421 --** validate table columns passed in **
8422 if p_validation_level <> FND_API.G_VALID_LEVEL_NONE then
8423 if not AK_REGION_PVT.VALIDATE_REGION (
8424 p_validation_level => p_validation_level,
8425 p_api_version_number => 1.0,
8426 p_return_status => l_return_status,
8427 p_region_application_id => p_region_application_id,
8428 p_region_code => p_region_code,
8429 p_database_object_name => p_database_object_name,
8430 p_region_style => p_region_style,
8431 p_icx_custom_call => p_icx_custom_call,
8432 p_num_columns => p_num_columns,
8433 p_region_defaulting_api_pkg => p_region_defaulting_api_pkg,
8434 p_region_defaulting_api_proc => p_region_defaulting_api_proc,
8435 p_region_validation_api_pkg => p_region_validation_api_pkg,
8436 p_region_validation_api_proc => p_region_validation_api_proc,
8437 p_name => p_name,
8438 p_description => p_description,
8439 p_caller => AK_ON_OBJECTS_PVT.G_UPDATE,
8440 p_pass => p_pass
8441 ) then
8442 --dbms_output.put_line(l_api_name || 'validation failed');
8443 -- Do not raise an error if it's the first pass
8444 if (p_pass = 1) then
8445 p_copy_redo_flag := TRUE;
8446 else
8447 raise FND_API.G_EXC_ERROR;
8448 end if; -- /* if p_pass */
8449 end if;
8450 end if;
8451 
8452 --** Load record to be updated to the database **
8453 --** - first load nullable columns **
8454 
8455 if (p_icx_custom_call  <> FND_API.G_MISS_CHAR) or
8456 (p_icx_custom_call is null) then
8457 l_regions_rec.icx_custom_call := p_icx_custom_call;
8458 end if;
8459 
8460 if (p_description <> FND_API.G_MISS_CHAR) or
8461 (p_description is null) then
8462 l_regions_tl_rec.description := p_description;
8463 end if;
8464 if (p_num_columns <> FND_API.G_MISS_NUM) or
8465 (p_num_columns is null) then
8466 l_regions_rec.num_columns := p_num_columns;
8467 end if;
8468 if (p_region_defaulting_api_pkg <> FND_API.G_MISS_CHAR) then
8469 l_regions_rec.region_defaulting_api_pkg := p_region_defaulting_api_pkg;
8470 end if;
8471 if (p_region_defaulting_api_proc <> FND_API.G_MISS_CHAR) then
8472 l_regions_rec.region_defaulting_api_proc := p_region_defaulting_api_proc;
8473 end if;
8474 if (p_region_validation_api_pkg <> FND_API.G_MISS_CHAR) then
8475 l_regions_rec.region_validation_api_pkg := p_region_validation_api_pkg;
8476 end if;
8477 if (p_region_validation_api_proc <> FND_API.G_MISS_CHAR) then
8478 l_regions_rec.region_validation_api_proc := p_region_validation_api_proc;
8479 end if;
8480 -- * new jsp columns * --
8481 if (p_appmodule_object_type  <> FND_API.G_MISS_CHAR) or
8482 (p_appmodule_object_type is null) then
8483 l_regions_rec.applicationmodule_object_type := p_appmodule_object_type;
8484 end if;
8485 if (p_num_rows_display  <> FND_API.G_MISS_NUM) or
8486 (p_num_rows_display is null) then
8487 l_regions_rec.num_rows_display := p_num_rows_display;
8488 end if;
8489 if (p_region_object_type  <> FND_API.G_MISS_CHAR) or
8490 (p_region_object_type is null) then
8491 l_regions_rec.region_object_type := p_region_object_type;
8492 end if;
8493 if (p_image_file_name  <> FND_API.G_MISS_CHAR) or
8494 (p_image_file_name is null) then
8495 l_regions_rec.image_file_name := p_image_file_name;
8496 end if;
8497 if (p_isform_flag  <> FND_API.G_MISS_CHAR) and (p_isform_flag is not null) then
8498 l_regions_rec.isform_flag := p_isform_flag;
8499 else
8500 l_regions_rec.isform_flag := l_isform_flag;
8501 end if;
8502 if (p_help_target  <> FND_API.G_MISS_CHAR) or
8503 (p_help_target is null) then
8504 l_regions_rec.help_target := p_help_target;
8505 end if;
8506 if (p_style_sheet_filename  <> FND_API.G_MISS_CHAR) or
8507 (p_style_sheet_filename is null) then
8508 l_regions_rec.style_sheet_filename := p_style_sheet_filename;
8509 end if;
8510 if (p_version  <> FND_API.G_MISS_CHAR) or
8511 (p_version is null) then
8512 l_regions_rec.version := p_version;
8513 end if;
8514 if (p_applicationmodule_usage_name  <> FND_API.G_MISS_CHAR) or
8515 (p_applicationmodule_usage_name is null) then
8516 l_regions_rec.applicationmodule_usage_name := p_applicationmodule_usage_name;
8517 end if;
8518 if (p_add_indexed_children  <> FND_API.G_MISS_CHAR) or
8519 (p_add_indexed_children is null) then
8520 l_regions_rec.add_indexed_children := p_add_indexed_children;
8521 end if;
8522 if (p_stateful_flag  <> FND_API.G_MISS_CHAR) or
8523 (p_stateful_flag is null) then
8524 l_regions_rec.stateful_flag := p_stateful_flag;
8525 end if;
8526 if (p_function_name  <> FND_API.G_MISS_CHAR) or
8527 (p_function_name is null) then
8528 l_regions_rec.function_name := p_function_name;
8529 end if;
8530 if (p_children_view_usage_name  <> FND_API.G_MISS_CHAR) or
8531 (p_children_view_usage_name is null) then
8532 l_regions_rec.children_view_usage_name := p_children_view_usage_name;
8533 end if;
8534 if (p_search_panel <> FND_API.G_MISS_CHAR) or
8535 (p_search_panel is null) then
8536 l_regions_rec.search_panel := p_search_panel;
8537 end if;
8538 if (p_advanced_search_panel <> FND_API.G_MISS_CHAR) or
8539 (p_advanced_search_panel is null) then
8540 l_regions_rec.advanced_search_panel := p_advanced_search_panel;
8541 end if;
8542 if (p_customize_panel <> FND_API.G_MISS_CHAR) or
8543 (p_customize_panel is null) then
8544 l_regions_rec.customize_panel := p_customize_panel;
8545 end if;
8546 if (p_default_search_panel <> FND_API.G_MISS_CHAR) or
8547 (p_default_search_panel is null) then
8548 l_regions_rec.default_search_panel := p_default_search_panel;
8549 end if;
8550 if (p_results_based_search <> FND_API.G_MISS_CHAR) or
8551 (p_results_based_search is null) then
8552 l_regions_rec.results_based_search := p_results_based_search;
8553 end if;
8554 if (p_display_graph_table <> FND_API.G_MISS_CHAR) or
8555 (p_display_graph_table is null) then
8556 l_regions_rec.display_graph_table := p_display_graph_table;
8557 end if;
8558 if (p_disable_header <> FND_API.G_MISS_CHAR) or
8559 (p_disable_header is null) then
8560 l_regions_rec.disable_header := p_disable_header;
8561 end if;
8562 if (p_auto_customization_criteria <> FND_API.G_MISS_CHAR) or
8563 (p_auto_customization_criteria is null) then
8564 l_regions_rec.auto_customization_criteria := p_auto_customization_criteria;
8565 end if;
8566 
8567 --** non-null, non-key columns **
8568 if (p_standalone <> FND_API.G_MISS_CHAR) or
8569 (p_standalone is not null) then
8570 l_regions_rec.standalone := p_standalone;
8571 else
8572 l_regions_rec.standalone := 'Y';
8573 end if;
8574 
8575 
8576 -- * flex field columns * --
8577 if (p_attribute_category <> FND_API.G_MISS_CHAR) or
8578 (p_attribute_category is null) then
8579 l_regions_rec.attribute_category := p_attribute_category;
8580 end if;
8581 if (p_attribute1 <> FND_API.G_MISS_CHAR) or
8582 (p_attribute1 is null) then
8583 l_regions_rec.attribute1 := p_attribute1;
8584 end if;
8585 if (p_attribute2 <> FND_API.G_MISS_CHAR) or
8586 (p_attribute2 is null) then
8587 l_regions_rec.attribute2 := p_attribute2;
8588 end if;
8589 if (p_attribute3 <> FND_API.G_MISS_CHAR) or
8590 (p_attribute3 is null) then
8591 l_regions_rec.attribute3 := p_attribute3;
8592 end if;
8593 if (p_attribute4 <> FND_API.G_MISS_CHAR) or
8594 (p_attribute4 is null) then
8595 l_regions_rec.attribute4 := p_attribute4;
8596 end if;
8597 if (p_attribute5 <> FND_API.G_MISS_CHAR) or
8598 (p_attribute5 is null) then
8599 l_regions_rec.attribute5 := p_attribute5;
8600 end if;
8601 if (p_attribute6 <> FND_API.G_MISS_CHAR) or
8602 (p_attribute6 is null) then
8603 l_regions_rec.attribute6 := p_attribute6;
8604 end if;
8605 if (p_attribute7 <> FND_API.G_MISS_CHAR) or
8606 (p_attribute7 is null) then
8607 l_regions_rec.attribute7 := p_attribute7;
8608 end if;
8609 if (p_attribute8 <> FND_API.G_MISS_CHAR) or
8610 (p_attribute8 is null) then
8611 l_regions_rec.attribute8 := p_attribute8;
8612 end if;
8613 if (p_attribute9 <> FND_API.G_MISS_CHAR) or
8614 (p_attribute9 is null) then
8615 l_regions_rec.attribute9 := p_attribute9;
8616 end if;
8617 if (p_attribute10 <> FND_API.G_MISS_CHAR) or
8618 (p_attribute10 is null) then
8619 l_regions_rec.attribute10 := p_attribute10;
8620 end if;
8621 if (p_attribute11 <> FND_API.G_MISS_CHAR) or
8622 (p_attribute11 is null) then
8623 l_regions_rec.attribute11 := p_attribute11;
8624 end if;
8625 if (p_attribute12 <> FND_API.G_MISS_CHAR) or
8626 (p_attribute12 is null) then
8627 l_regions_rec.attribute12 := p_attribute12;
8628 end if;
8629 if (p_attribute13 <> FND_API.G_MISS_CHAR) or
8630 (p_attribute13 is null) then
8631 l_regions_rec.attribute13 := p_attribute13;
8632 end if;
8633 if (p_attribute14 <> FND_API.G_MISS_CHAR) or
8634 (p_attribute14 is null) then
8635 l_regions_rec.attribute14 := p_attribute14;
8636 end if;
8637 if (p_attribute15 <> FND_API.G_MISS_CHAR) or
8638 (p_attribute15 is null) then
8639 l_regions_rec.attribute15 := p_attribute15;
8640 end if;
8641 
8642 --** - next, load non-null, non-key columns **
8643 
8644 if (p_database_object_name <> FND_API.G_MISS_CHAR) then
8645 l_regions_rec.database_object_name := p_database_object_name;
8646 end if;
8647 if (p_region_style <> FND_API.G_MISS_CHAR) then
8648 l_regions_rec.region_style := p_region_style;
8649 end if;
8650 if (p_name <> FND_API.G_MISS_CHAR) then
8651 l_regions_tl_rec.name := p_name;
8652 end if;
8653 
8654   if (p_created_by <> FND_API.G_MISS_NUM) then
8655     l_created_by := p_created_by;
8656   end if;
8657   if (p_creation_date <> FND_API.G_MISS_DATE) then
8658     l_creation_date := p_creation_date;
8659   end if;
8660   if (p_last_updated_by <> FND_API.G_MISS_NUM) then
8661     l_last_updated_by := p_last_updated_by;
8662   end if;
8663   if (p_last_update_date <> FND_API.G_MISS_DATE) then
8664     l_last_update_date := p_last_update_date;
8665   end if;
8666   if (p_last_update_login <> FND_API.G_MISS_NUM) then
8667     l_last_update_login := p_last_update_login;
8668   end if;
8669 
8670 -- Set WHO columns
8671 
8672   if AK_ON_OBJECTS_PVT.IS_UPDATEABLE(
8673        p_loader_timestamp => p_loader_timestamp,
8674        p_created_by => l_created_by,
8675        p_creation_date => l_creation_date,
8676        p_last_updated_by => l_last_updated_by,
8677        p_db_last_updated_by => l_regions_rec.last_updated_by,
8678        p_last_update_date => l_last_update_date,
8679        p_db_last_update_date => l_regions_rec.last_update_date,
8680        p_last_update_login => l_last_update_login,
8681        p_create_or_update => 'UPDATE') then
8682 
8683 update AK_REGIONS set
8684 DATABASE_OBJECT_NAME = l_regions_rec.database_object_name,
8685 REGION_STYLE = l_regions_rec.region_style,
8686 ICX_CUSTOM_CALL = l_regions_rec.icx_custom_call,
8687 NUM_COLUMNS = l_regions_rec.num_columns,
8688 REGION_DEFAULTING_API_PKG = l_regions_rec.region_defaulting_api_pkg,
8689 REGION_DEFAULTING_API_PROC = l_regions_rec.region_defaulting_api_proc,
8690 REGION_VALIDATION_API_PKG = l_regions_rec.region_validation_api_pkg,
8691 REGION_VALIDATION_API_PROC = l_regions_rec.region_validation_api_proc,
8692 APPLICATIONMODULE_OBJECT_TYPE = l_regions_rec.applicationmodule_object_type,
8693 NUM_ROWS_DISPLAY = l_regions_rec.num_rows_display,
8694 REGION_OBJECT_TYPE = l_regions_rec.region_object_type,
8695 IMAGE_FILE_NAME = l_regions_rec.image_file_name,
8696 ISFORM_FLAG = l_regions_rec.isform_flag,
8697 HELP_TARGET = l_regions_rec.help_target,
8698 STYLE_SHEET_FILENAME = l_regions_rec.style_sheet_filename,
8699 VERSION = l_regions_rec.version,
8700 APPLICATIONMODULE_USAGE_NAME = l_regions_rec.applicationmodule_usage_name,
8701 ADD_INDEXED_CHILDREN = l_regions_rec.add_indexed_children,
8702 STATEFUL_FLAG = l_regions_rec.stateful_flag,
8703 FUNCTION_NAME = l_regions_rec.function_name,
8704 CHILDREN_VIEW_USAGE_NAME = l_regions_rec.children_view_usage_name,
8705 SEARCH_PANEL = l_regions_rec.search_panel,
8706 ADVANCED_SEARCH_PANEL = l_regions_rec.advanced_search_panel,
8707 CUSTOMIZE_PANEL = l_regions_rec.customize_panel,
8708 DEFAULT_SEARCH_PANEL = l_regions_rec.default_search_panel,
8709 RESULTS_BASED_SEARCH = l_regions_rec.results_based_search,
8710 DISPLAY_GRAPH_TABLE = l_regions_rec.display_graph_table,
8711 DISABLE_HEADER = l_regions_rec.disable_header,
8712 STANDALONE = l_regions_rec.standalone,
8713 AUTO_CUSTOMIZATION_CRITERIA = l_regions_rec.auto_customization_criteria,
8714 ATTRIBUTE_CATEGORY = l_regions_rec.attribute_category,
8715 ATTRIBUTE1 = l_regions_rec.attribute1,
8716 ATTRIBUTE2 = l_regions_rec.attribute2,
8717 ATTRIBUTE3 = l_regions_rec.attribute3,
8718 ATTRIBUTE4 = l_regions_rec.attribute4,
8719 ATTRIBUTE5 = l_regions_rec.attribute5,
8720 ATTRIBUTE6 = l_regions_rec.attribute6,
8721 ATTRIBUTE7 = l_regions_rec.attribute7,
8722 ATTRIBUTE8 = l_regions_rec.attribute8,
8723 ATTRIBUTE9 = l_regions_rec.attribute9,
8724 ATTRIBUTE10 = l_regions_rec.attribute10,
8725 ATTRIBUTE11 = l_regions_rec.attribute11,
8726 ATTRIBUTE12 = l_regions_rec.attribute12,
8727 ATTRIBUTE13 = l_regions_rec.attribute13,
8728 ATTRIBUTE14 = l_regions_rec.attribute14,
8729 ATTRIBUTE15 = l_regions_rec.attribute15,
8730 LAST_UPDATE_DATE = l_last_update_date,
8731 LAST_UPDATED_BY = l_last_updated_by,
8732 LAST_UPDATE_LOGIN = l_last_update_login
8733 where REGION_APPLICATION_ID = p_region_application_id
8734 and   REGION_CODE = p_region_code;
8735 if (sql%notfound) then
8736 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8737 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATE_FAILED');
8738 FND_MSG_PUB.Add;
8739 end if;
8740 raise FND_API.G_EXC_ERROR;
8741 end if;
8742 
8743 update AK_REGIONS_TL set
8744 NAME = l_regions_tl_rec.name,
8745 DESCRIPTION = l_regions_tl_rec.description,
8746 LAST_UPDATE_DATE = l_last_update_date,
8747 LAST_UPDATED_BY = l_last_updated_by,
8748 LAST_UPDATE_LOGIN = l_last_update_login,
8749 SOURCE_LANG = l_lang
8750 where REGION_APPLICATION_ID = p_region_application_id
8751 and   REGION_CODE = p_region_code
8752 and   l_lang in (LANGUAGE, SOURCE_LANG);
8753 
8754 if (sql%notfound) then
8755 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8756 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATE_FAILED');
8757 FND_MSG_PUB.Add;
8758 end if;
8759 raise FND_API.G_EXC_ERROR;
8760 end if;
8761 
8762 --  /** commit the update **/
8763  commit;
8764 
8765 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
8766 FND_MESSAGE.SET_NAME('AK','AK_REGION_UPDATED');
8767 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8768 ' ' || p_region_code);
8769 FND_MSG_PUB.Add;
8770 end if;
8771 
8772 end if;
8773 p_return_status := FND_API.G_RET_STS_SUCCESS;
8774 
8775 FND_MSG_PUB.Count_And_Get (
8776 p_count => p_msg_count,
8777 p_data => p_msg_data);
8778 
8779 EXCEPTION
8780 WHEN VALUE_ERROR THEN
8781 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8782 FND_MESSAGE.SET_NAME('AK','AK_REGION_VALUE_ERROR');
8783 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8784 ' ' || p_region_code);
8785 FND_MSG_PUB.Add;
8786 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8787 SUBSTR (SQLERRM, 1, 240));
8788 FND_MSG_PUB.Add;
8789 
8790 end if;
8791 rollback to start_update_region;
8792 p_return_status := FND_API.G_RET_STS_ERROR;
8793 FND_MSG_PUB.Count_And_Get (
8794 p_count => p_msg_count,
8795 p_data => p_msg_data);
8796 WHEN FND_API.G_EXC_ERROR THEN
8797 if FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8798 FND_MESSAGE.SET_NAME('AK','AK_REGION_NOT_UPDATED');
8799 FND_MESSAGE.SET_TOKEN('KEY', to_char(p_region_application_id) ||
8800 ' ' || p_region_code);
8801 FND_MSG_PUB.Add;
8802 end if;
8803 p_return_status := FND_API.G_RET_STS_ERROR;
8804 rollback to start_update_region;
8805 FND_MSG_PUB.Count_And_Get (
8806 p_count => p_msg_count,
8807 p_data => p_msg_data);
8808 WHEN OTHERS THEN
8809 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8810 rollback to start_update_region;
8811 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
8812 SUBSTR (SQLERRM, 1, 240) );
8813 FND_MSG_PUB.Add;
8814 FND_MSG_PUB.Count_And_Get (
8815 p_count => p_msg_count,
8816 p_data => p_msg_data);
8817 FND_MSG_PUB.Count_And_Get (
8818 p_count => p_msg_count,
8819 p_data => p_msg_data);
8820 end UPDATE_REGION;
8821 
8822 Function REGION_KEY_EXISTS (
8823 p_region_application_id	in	number,
8824 p_region_code				in	varchar2,
8825 p_region_pk_tbl			in 	ak_region_pub.region_pk_tbl_type
8826 ) return boolean is
8827 
8828 l_exist	boolean := true;
8829 
8830 begin
8831 if (p_region_pk_tbl.count = 0) then
8832 l_exist := false;
8833 end if;
8834 
8835 for l_index in p_region_pk_tbl.FIRST .. p_region_pk_tbl.LAST loop
8836 if (p_region_pk_tbl.exists(l_index)) then
8837 if (p_region_pk_tbl(l_index).region_appl_id = p_region_application_id)
8838 and
8839 (p_region_pk_tbl(l_index).region_code = p_region_code) then
8840 l_exist := true;
8841 exit;
8842 end if;
8843 end if;
8844 end loop;
8845 return l_exist;
8846 end;
8847 
8848 Procedure ADD_NESTED_REG_TO_REG_PK (
8849 p_region_application_id	IN	number,
8850 p_region_code		IN	varchar2,
8851 p_region_pk_tbl		IN OUT NOCOPY  AK_REGION_PUB.Region_PK_Tbl_Type
8852 ) IS
8853 cursor l_get_ri_nested_regions_csr (region_appl_id_param number,
8854 region_code_param varchar2) is
8855 select distinct nested_region_application_id, nested_region_code
8856 from   AK_REGION_ITEMS
8857 where  region_application_id = region_appl_id_param
8858 and    region_code = region_code_param
8859 and    nested_region_application_id is not null
8860 and    nested_region_code is not null;
8861 cursor l_get_non_train_region_csr(region_appl_id_param number,
8862 region_code_param varchar2) is
8863 select region_application_id, region_code
8864 from ak_regions_vl
8865 where region_application_id = region_appl_id_param
8866 and region_code = region_code_param
8867 and region_style <> 'TRAIN';
8868 l_return_status	varchar2(1);
8869 begin
8870 for l_region_rec in l_get_ri_nested_regions_csr (
8871 p_region_application_id, p_region_code) loop
8872 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
8873 if ( NOT REGION_KEY_EXISTS(l_region_rec.nested_region_application_id, l_region_rec.nested_region_code, p_region_pk_tbl) ) then
8874 -- drilling into the nested levels
8875 AK_REGION_PVT.ADD_NESTED_REG_TO_REG_PK(
8876 l_region_rec.nested_region_application_id,
8877 l_region_rec.nested_region_code,
8878 p_region_pk_tbl);
8879 end if;
8880 end loop; -- end l_get_non_train_region_csr
8881 AK_REGION_PVT.INSERT_REGION_PK_TABLE (
8882 p_return_status => l_return_status,
8883 p_region_application_id =>
8884 l_region_rec.nested_region_application_id,
8885 p_region_code => l_region_rec.nested_region_code,
8886 p_region_pk_tbl => p_region_pk_tbl);
8887 end loop;
8888 
8889 end ADD_NESTED_REG_TO_REG_PK;
8890 
8891 
8892 end AK_REGION_PVT;