DBA Data[Home] [Help]

PACKAGE BODY: APPS.BIS_VG_LOG

Source


1 PACKAGE BODY bis_vg_log AS
2 /* $Header: BISTLOGB.pls 115.8 2003/11/05 20:00:03 dbowles ship $ */
3 
4 --
5 --  Copyright (c) 1998 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      BISTLOGB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      body of package which writes the log for generated business views
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  21-Aug-1998 ANSINGHA created
21 --  08-Jan-2001 Walid.Nasrallah Modified to add write_error_to_string
22 --  11-DEC-01 Edited by DBOWLES  Added dr driver comments.
23 --
24 --
25 --=====================
26 --PRIVATE CONSTANTS
27 --=====================
28 g_line_length CONSTANT NUMBER := 80;
29 G_PKG_NAME CONSTANT VARCHAR2(30) := 'bis_vg_log';
30 G_newline CONSTANT varchar2(2) := '
31 ';
32 
33 --=====================
34 --PRIVATE TYPES
35 --=====================
36 --
37 -- ============================================================================
38 --TYPE : View_Generator_Result_Type
39 -- ============================================================================
40 
41 g_dummy_result VARCHAR2(10);
42 SUBTYPE generation_result IS g_dummy_result%TYPE;
43 
44 TYPE View_Gen_Success_Type IS  -- local type
45 RECORD
46   ( business_view_name bis_vg_types.view_name_type  -- original view name
47   , gen_view_name      bis_vg_types.view_name_type  -- generated view/message
48   );
49 --
50 -- ============================================================================
51 --TYPE : View_Generator_Success_Table_Type
52 -- ============================================================================
53 TYPE  View_Gen_success_Table_Type  IS  -- local type
54 TABLE OF View_Gen_Success_Type
55 INDEX BY BINARY_INTEGER;
56 --
57 --
58 g_gen_success_table view_gen_success_table_type;
59 --
60 --
61 --
62 TYPE View_Gen_Failure_Type IS  -- local type
63 RECORD
64 ( business_view_name bis_vg_types.view_name_type := FND_API.G_MISS_CHAR
65 , Error_Msg_ID       Number         := FND_API.G_MISS_NUM
66 , Error_Msg_Name     VARCHAR2(30)   := FND_API.G_MISS_CHAR
67 , Error_Description  VARCHAR2(2000) := FND_API.G_MISS_CHAR
68 , Error_Proc_Name    VARCHAR2(100)  := FND_API.G_MISS_CHAR
69 , Error_Type         VARCHAR2(1)
70 );
71 --
72 -- ============================================================================
73 --TYPE : View_Generator_Failure_Table_Type
74 -- ============================================================================
75 TYPE  View_Gen_failure_Table_Type  IS  -- local type
76 TABLE OF View_Gen_Failure_Type
77 INDEX BY BINARY_INTEGER;
78 --
79 --
80 g_gen_failure_table view_gen_failure_table_type;
81 --
82 -- ============================================================================
83 --PROCEDURE : Init_Log
84 --PARAMETERS
85 --  1. x_return_status    error or normal
86 --  2. x_error_Tbl        table of error messages
87 
88 --COMMENT   : Call this function to start logging the messages
89 --RETURN    : None
90 --EXCEPTION : None
91 -- ============================================================================
92 
93 PROCEDURE init_log
94     ( x_return_status       OUT VARCHAR2
95     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
96     )
97 IS
98 BEGIN
99   bis_debug_pub.Add('> init_log');
100   x_return_status := FND_API.G_RET_STS_SUCCESS;
101   g_gen_success_table.DELETE;
102   g_gen_failure_table.DELETE;
103   bis_debug_pub.Add('< init_log ');
104 
105 EXCEPTION
106    when FND_API.G_EXC_ERROR then
107       x_return_status := FND_API.G_RET_STS_ERROR ;
108       RAISE FND_API.G_EXC_ERROR;
109    when FND_API.G_EXC_UNEXPECTED_ERROR then
110       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
111       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
112    when others then
113       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
114       BIS_VG_UTIL.Add_Error_Message
115       ( p_error_msg_id      => SQLCODE
116       , p_error_description => SQLERRM
117       , p_error_proc_name   => G_PKG_NAME||'.init_log'
118       , p_error_table       => x_error_tbl
119       , x_error_table       => x_error_tbl
120       );
121       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
122 
123 END init_log;
124 
125 -- ============================================================================
126 --PROCEDURE : Update_Success_Log
127 --PARAMETERS: 1. p_OrigBV - Original business view  name
128 --            2. p_GenBV  - Generated Business View name
129 --            3. x_return_status    error or normal
130 --            4. x_error_Tbl        table of error messages
131 --COMMENT   : Call this function to log a successful generation
132 --RETURN    : None
133 --EXCEPTION : None
134 -- ============================================================================
135 PROCEDURE update_success_log
136     ( p_origbv IN bis_vg_types.view_name_type
137     , p_genbv  IN bis_vg_types.view_name_type
138     , x_return_status       OUT VARCHAR2
139     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
140     )
141 IS
142 l_result view_gen_success_type;
143 BEGIN
144 
145   bis_debug_pub.Add('> update_success_log');
146   x_return_status := FND_API.G_RET_STS_SUCCESS;
147   l_result.business_view_name := p_origbv;
148   l_result.gen_view_name      := p_genbv;
149   g_gen_success_table(g_gen_success_table.COUNT + 1) := l_result;
150   bis_debug_pub.Add('< update_success_log');
151 
152 EXCEPTION
153    when FND_API.G_EXC_ERROR then
154       x_return_status := FND_API.G_RET_STS_ERROR ;
155       RAISE FND_API.G_EXC_ERROR;
156    when FND_API.G_EXC_UNEXPECTED_ERROR then
157       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
158       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
159    when others then
160       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
161       BIS_VG_UTIL.Add_Error_Message
162       ( p_error_msg_id      => SQLCODE
163       , p_error_description => SQLERRM
164       , p_error_proc_name   => G_PKG_NAME||'.update_success_log'
165       , p_error_table       => x_error_tbl
166       , x_error_table       => x_error_tbl
167       );
168       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
169 
170 END update_success_log;
171 
172 
173 
174 -- ============================================================================
175 --PROCEDURE : Update_Failure_Log
176 --PARAMETERS: 1. p_OrigBV - Original business view  name
177 --            2. p_code   - code for the error message
178 --            3. p_errm   - error message
179 --            4. x_return_status    error or normal
180 --            5. x_error_Tbl        table of error messages
181 --COMMENT   : Call this function to log failed generation
182 --RETURN    : None
183 --EXCEPTION : None
184 -- ============================================================================
185 PROCEDURE update_failure_log
186     ( p_origbv IN bis_vg_types.view_name_type
187     , p_code   IN NUMBER
188     , p_errm   IN VARCHAR2
189     , x_return_status       OUT VARCHAR2
190     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
191     )
192 IS
193 l_result view_gen_failure_type;
194 l_str    VARCHAR2(100);
195 BEGIN
196   bis_debug_pub.Add('> update_failure_log');
197   x_return_status := FND_API.G_RET_STS_SUCCESS;
198 
199   l_result.business_view_name := p_origbv;
200   l_result.Error_Msg_ID       := p_code;
201   l_result.Error_Description  := p_errm;
202 
203   g_gen_failure_table(g_gen_failure_table.COUNT + 1) := l_result;
204 
205   bis_debug_pub.Add('< update_failure_log');
206 
207 EXCEPTION
208    when FND_API.G_EXC_ERROR then
209       x_return_status := FND_API.G_RET_STS_ERROR ;
210       RAISE FND_API.G_EXC_ERROR;
211    when FND_API.G_EXC_UNEXPECTED_ERROR then
212       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
213       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
214    when others then
215       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
216       BIS_VG_UTIL.Add_Error_Message
217       ( p_error_msg_id      => SQLCODE
218       , p_error_description => SQLERRM
219       , p_error_proc_name   => G_PKG_NAME||'.update_failure_log'
220       , p_error_table       => x_error_tbl
221       , x_error_table       => x_error_tbl
222       );
223       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
224 
225 END update_failure_log;
226 
227 -- ============================================================================
228 --PROCEDURE : Update_Failure_Log
229 --PARAMETERS: 1. p_error_Tbl - table containint one or more error messages
230 --            2. x_return_status    error or normal
231 --            3. x_error_Tbl        table of error messages
232 --COMMENT   : This overloaded version of Update_Failure_Log generates
233 --            a partiual log of failure at teh point where it occurs.
234 --RETURN    : None
235 --EXCEPTION : None
236 -- ============================================================================
237 
238 PROCEDURE update_failure_log
239     ( p_error_Tbl           IN BIS_VG_UTIL.Error_Tbl_Type
240     , x_return_status       OUT VARCHAR2
241     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
242     )
243 IS
244 l_result view_gen_failure_type;
245 l_str    VARCHAR2(100);
246 BEGIN
247   bis_debug_pub.Add('> update_failure_log');
248   bis_debug_pub.add('g_gen_failure_table.count = '||g_gen_failure_table.count);
249   bis_debug_pub.add('p_error_Tbl.count = '||p_error_Tbl.count);
250 
251   x_return_status := FND_API.G_RET_STS_SUCCESS;
252 
253   for i in 1 .. p_error_Tbl.count loop
254     l_result.Error_Msg_ID       := p_error_Tbl(i).Error_Msg_ID;
255     l_result.Error_Msg_Name     := p_error_Tbl(i).Error_Msg_Name;
256     l_result.Error_Description  := p_error_Tbl(i).Error_Description;
257     l_result.Error_Proc_Name    := p_error_Tbl(i).Error_Proc_Name;
258     l_result.Error_Type         := p_error_Tbl(i).Error_Type;
259 
260     g_gen_failure_table(g_gen_failure_table.COUNT + 1) := l_result;
261   end loop;
262 
263   bis_debug_pub.add('g_gen_failure_table.count = '||g_gen_failure_table.count);
264   bis_debug_pub.Add('< update_failure_log');
265   bis_debug_pub.debug_off;
266 
267 EXCEPTION
268    when FND_API.G_EXC_ERROR then
269       x_return_status := FND_API.G_RET_STS_ERROR ;
270       RAISE FND_API.G_EXC_ERROR;
271    when FND_API.G_EXC_UNEXPECTED_ERROR then
272       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
273       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
274    when others then
275       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
276       BIS_VG_UTIL.Add_Error_Message
277       ( p_error_msg_id      => SQLCODE
278       , p_error_description => SQLERRM
279       , p_error_proc_name   => G_PKG_NAME||'.update_failure_log'
280       , p_error_table       => x_error_tbl
281       , x_error_table       => x_error_tbl
282       );
283       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
284 
285 END update_failure_log;
286 
287 -- ============================================================================
288 --PROCEDURE : backpatch_failure_log
289 --PARAMETERS: 1. p_OrigBV - Original business view  name
290 --            2. x_return_status    error or normal
291 --            3. x_error_Tbl        table of error messages
292 --COMMENT   : Function fills in view name where missing.  Used in
293 --            conjunction with the short version of update_failure_log.
294 --RETURN    : None
295 --EXCEPTION : None
296 -- ============================================================================
297 PROCEDURE backpatch_failure_log
298   ( p_origbv IN bis_vg_types.view_name_type
299     , x_return_status       OUT VARCHAR2
300     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
301     )
302 IS
303    l_counter  NUMBER;
304 BEGIN
305    bis_debug_pub.Add('> backpatch_failure_log');
306 
307    FOR l_counter IN REVERSE 1..g_gen_failure_table.COUNT
308      LOOP
309 	-- Find missing view names starting from ther high end
310 	IF g_gen_failure_table(l_counter).business_view_name
311 	  = FND_API.G_MISS_CHAR
312 	  THEN
313           g_gen_failure_table(l_counter).business_view_name := p_origbv;
314 
315 
316 --- The following is deleted to allow back-patching of multiple entries
317 ---          ELSE
318 ---          -- We are done with the most recent portion of the table
319 ---          EXIT; -- from the loop
320          END IF;
321      END LOOP;
322   bis_debug_pub.Add('< backpatch_failure_log');
323 
324 EXCEPTION
325    when FND_API.G_EXC_ERROR then
326       x_return_status := FND_API.G_RET_STS_ERROR ;
327       RAISE FND_API.G_EXC_ERROR;
328    when FND_API.G_EXC_UNEXPECTED_ERROR then
329       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
330       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
331    when others then
332       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
333       BIS_VG_UTIL.Add_Error_Message
334       ( p_error_msg_id      => SQLCODE
335       , p_error_description => SQLERRM
336       , p_error_proc_name   => G_PKG_NAME||'.backpatch_failure_log'
337       , p_error_table       => x_error_tbl
338       , x_error_table       => x_error_tbl
339       );
340       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
341 
342 END backpatch_failure_log;
343 
344 -- ============================================================================
345 -- PROCEDURE : Write_string
346 -- PARAMETERS 1. p_mode    [production, test, ...]
347 --            2. p_string              IN  VARCHAR2
348 --            3. x_return_status    error or normal
349 --            4. x_error_Tbl        table of error messages
350 -- COMMENT   : Call this function to write string to the output
351 -- RETURN    : None
352 -- EXCEPTION : None
353 -- ============================================================================
354 PROCEDURE write_string
355     ( p_mode            IN  bis_vg_Types.view_generator_mode_type
356     , p_string          IN  VARCHAR2
357     , x_return_status       OUT VARCHAR2
358     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
359     )
360 IS
361 BEGIN
362 
363   bis_debug_pub.Add('> write_string');
364   x_return_status := FND_API.G_RET_STS_SUCCESS;
365   IF (p_mode = bis_vg_types.production_mode) THEN
366     fnd_file.put_line(fnd_file.OUTPUT, p_string);
367 --    fnd_file.new_line(fnd_file.OUTPUT);
368   ELSE
369      bis_debug_pub.debug_on;
370      bis_debug_pub.ADD(p_string);
371      bis_debug_pub.debug_off;
372   END IF;
373   bis_debug_pub.Add('< write_string');
374 
375 
376 EXCEPTION
377    when FND_API.G_EXC_ERROR then
378       x_return_status := FND_API.G_RET_STS_ERROR ;
379       RAISE FND_API.G_EXC_ERROR;
380    when FND_API.G_EXC_UNEXPECTED_ERROR then
381       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
382       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
383    when others then
384       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
385       BIS_VG_UTIL.Add_Error_Message
386       ( p_error_msg_id      => SQLCODE
387       , p_error_description => SQLERRM
388       , p_error_proc_name   => G_PKG_NAME||'.write_string'
389       , p_error_table       => x_error_tbl
390       , x_error_table       => x_error_tbl
391       );
392       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
393 
394 END write_string;
395 
396 -- ============================================================================
397 -- PROCEDURE : Write_blank_line
398 -- PARAMETERS 1. p_mode    [production, test, ...]
399 --            2. p_count   number of blank lines
400 --            3. x_return_status    error or normal
401 --            4. x_error_Tbl        table of error messages
402 -- COMMENT   : Call this function to write the list of success full conversion
403 -- RETURN    : None
404 -- EXCEPTION : None
405 -- ============================================================================
406 PROCEDURE write_blank_line
407     ( p_mode  IN bis_vg_Types.view_generator_mode_type
408     , p_count IN NUMBER
409     , x_return_status       OUT VARCHAR2
410     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
411     )
412 IS
413 BEGIN
414   bis_debug_pub.Add('> write_blank_line');
415   x_return_status := FND_API.G_RET_STS_SUCCESS;
416   FOR i IN 1 .. p_count LOOP
417     write_string ( p_mode
418                  , ' '
419 		 , x_return_status
420 		 , x_error_Tbl
421 		 );
422   END LOOP;
423   bis_debug_pub.Add('< write_blank_line');
424 
425 
426 EXCEPTION
427    when FND_API.G_EXC_ERROR then
428       x_return_status := FND_API.G_RET_STS_ERROR ;
429       RAISE FND_API.G_EXC_ERROR;
430    when FND_API.G_EXC_UNEXPECTED_ERROR then
431       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
432       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
433    when others then
434       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
435       BIS_VG_UTIL.Add_Error_Message
436       ( p_error_msg_id      => SQLCODE
437       , p_error_description => SQLERRM
438       , p_error_proc_name   => G_PKG_NAME||'.write_blank_line'
439       , p_error_table       => x_error_tbl
440       , x_error_table       => x_error_tbl
441       );
442       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
443 
444 END write_blank_line;
445 
446 -- ============================================================================
447 --PROCEDURE : Write_inputs
448 --PARAMETERS 1. p_mode    [production, test, ...]
449 --           2. p_all_flag            IN  VARCHAR2
450 --           3. p_App_Short_Name      IN  BIS_VG_TYPES.App_Short_Name_Type
451 --           4. p_KF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
452 --           5. p_Key_Flex_Code       IN  BIS_VG_TYPES.Key_Flex_Code_Type
453 --           6. p_DF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
454 --           7. p_Desc_Flex_Name      IN  BIS_VG_TYPES.Desc_Flex_Name_Type
455 --           8. p_Lookup_Table_Name   IN  VARCHAR2
456 --           9. p_Lookup_Type         IN  BIS_VG_TYPES.Lookup_Code_Type
457 --           10. p_View_Name          IN  BIS_VG_TYPES.View_Name_Type
458 --           11. x_return_status    error or normal
459 --           12. x_error_Tbl        table of error messages
460 --COMMENT   : Call this function to write inputs to the function
461 --RETURN    : None
462 --EXCEPTION : None
463 -- ============================================================================
464 PROCEDURE write_inputs
465     ( p_mode                IN  bis_vg_Types.view_generator_mode_type
466     , p_all_flag            IN  VARCHAR2
467     , p_App_Short_Name      IN  BIS_VG_TYPES.App_Short_Name_Type
468     , p_KF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
469     , p_Key_Flex_Code       IN  BIS_VG_TYPES.Key_Flex_Code_Type
470     , p_DF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
471     , p_Desc_Flex_Name      IN  BIS_VG_TYPES.Desc_Flex_Name_Type
472     , p_Lookup_Table_Name   IN  VARCHAR2
473     , p_Lookup_Type         IN  BIS_VG_TYPES.Lookup_Code_Type
474     , p_View_Name           IN  BIS_VG_TYPES.View_Name_Type
475     , x_return_status       OUT VARCHAR2
476     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
477     )
478 IS
479 l_str    VARCHAR2(100);
480 l_length NUMBER;
481 BEGIN
482 
483   bis_debug_pub.Add('> write_inputs');
484   x_return_status := FND_API.G_RET_STS_SUCCESS;
485 
486   l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
487                                  , 'BIS_VG_INPUT_PARAMETERS'
488                                  );
489 
490   write_string ( p_mode
491                , l_str
492 	       , x_return_status
493 	       , x_error_Tbl
494 	       );
495   l_length := Length(l_str);
496   l_str := '-';
497   l_str := Rpad(l_str, l_length, '-');
498   write_string ( p_mode
499                , l_str
500 	       , x_return_status
501 	       , x_error_Tbl
502 	       );
503 
504   write_blank_line ( p_mode
505                    , 1
506 		   , x_return_status
507 		   , x_error_Tbl
508 		   );
509 
510   IF (p_all_flag = fnd_api.g_true) THEN
511     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
512                                    , 'BIS_VG_INPUT_ALL_VIEWS'
513                                    );
514 
515     write_string ( p_mode
516                , l_str || ' ' || p_all_flag
517 	       , x_return_status
518 	       , x_error_Tbl
519 	       );
520 
521   ELSIF (p_view_name IS NOT  NULL) THEN
522     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
523                                    , 'BIS_VG_INPUT_VIEW_NAME'
524                                    );
525 
526     write_string ( p_mode
527                  , l_str || ' ' || p_view_name
528 		 , x_return_status
529 		 , x_error_Tbl
530 		 );
531 
532 
533   ELSIF (p_app_short_name IS NOT NULL) THEN
534     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
535                                    , 'BIS_VG_INPUT_APP'
536                                    );
537 
538     write_string ( p_mode
539                  , l_str || ' ' || p_app_short_name
540 		 , x_return_status
541 		 , x_error_Tbl
542 		 );
543   ELSIF (p_kf_appl_short_name IS NOT NULL) THEN
544     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
545                                    , 'BIS_VG_INPUT_APP'
546                                    );
547 
548     write_string ( p_mode
549                  , l_str || ' ' || p_kf_appl_short_name
550 		 , x_return_status
551 		 , x_error_Tbl
552 		 );
553     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
554                                    , 'BIS_VG_INPUT_KFX'
555                                    );
556 
557 
558     write_string ( p_mode
559                  , l_str || ' ' || p_Key_Flex_Code
560 		 , x_return_status
561 		 , x_error_Tbl
562 		 );
563 
564   ELSIF (p_df_appl_short_name IS NOT NULL) then
565     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
566                                    , 'BIS_VG_INPUT_APP'
567                                    );
568 
569     write_string ( p_mode
570                  , l_str || ' ' || p_df_appl_short_name
571 		 , x_return_status
572 		 , x_error_Tbl
573 		 );
574 
575     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
576                                    , 'BIS_VG_INPUT_DFX'
577                                    );
578 
579     write_string ( p_mode
580                  , l_str || ' ' || p_Desc_Flex_Name
581 		 , x_return_status
582 		 , x_error_Tbl
583 		 );
584 
585   ELSE
586     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
587                                    , 'BIS_VG_INPUT_LOOKUP_TABLE_NAME'
588                                    );
589 
590     write_string ( p_mode
591                  , l_str || ' ' || p_Lookup_Table_Name
592 		 , x_return_status
593 		 , x_error_Tbl
594 		 );
595 
596     l_str := fnd_message.get_string( BIS_VG_TYPES.message_application
597                                    , 'BIS_VG_INPUT_LOOKUP_TYPE'
598                                    );
599     write_string ( p_mode
600                  , l_str || ' ' || p_Lookup_Type
601 		 , x_return_status
602 		 , x_error_Tbl
603 		 );
604 
605   END IF;
606 
607   bis_debug_pub.Add('< write_inputs');
608 
609 EXCEPTION
610    when FND_API.G_EXC_ERROR then
611       x_return_status := FND_API.G_RET_STS_ERROR ;
612       RAISE FND_API.G_EXC_ERROR;
613    when FND_API.G_EXC_UNEXPECTED_ERROR then
614       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
615       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
616    when others then
617       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
618       BIS_VG_UTIL.Add_Error_Message
619       ( p_error_msg_id      => SQLCODE
620       , p_error_description => SQLERRM
621       , p_error_proc_name   => G_PKG_NAME||'.write_inputs'
622       , p_error_table       => x_error_tbl
623       , x_error_table       => x_error_tbl
624       );
625       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
626 
627 END write_inputs;
628 
629 -- ============================================================================
630 -- PROCEDURE : Write_header
631 -- PARAMETERS 1. p_mode    [production, test, ...]
632 --            2. x_return_status    error or normal
633 --            3. x_error_Tbl        table of error messages
634 -- COMMENT   : Call this function to write the report header
635 -- RETURN    : None
636 -- EXCEPTION : None
637 -- ============================================================================
638 PROCEDURE write_header
639     ( p_mode IN  bis_vg_Types.view_generator_mode_type
640     , x_return_status       OUT VARCHAR2
641     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type    )
642 IS
643 l_date VARCHAR2(80);
644 l_head VARCHAR2(80);
645 l_str  VARCHAR2(120);
646 BEGIN
647   bis_debug_pub.Add('> write_header');
648   x_return_status := FND_API.G_RET_STS_SUCCESS;
649 
650   l_head := fnd_message.get_string( BIS_VG_TYPES.message_application
651                                   , 'BIS_VG_GENERATOR_NAME'
652                                   );
653 
654   l_date := To_char(Sysdate, 'DD-MON-YYYY HH:MI');
655   l_str := Lpad(l_head, g_line_length/2 + Length(l_head)/2);
656   l_date := Lpad(l_date, g_line_length - Length(l_str));
657   l_str := l_str||l_date;
658   write_string ( p_mode
659                , l_str
660 	       , x_return_status
661 	       , x_error_Tbl
662 	       );
663   bis_debug_pub.Add('< write_header');
664 
665 
666 EXCEPTION
667    when FND_API.G_EXC_ERROR then
668       x_return_status := FND_API.G_RET_STS_ERROR ;
669       RAISE FND_API.G_EXC_ERROR;
670    when FND_API.G_EXC_UNEXPECTED_ERROR then
671       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
672       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
673    when others then
674       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
675       BIS_VG_UTIL.Add_Error_Message
676       ( p_error_msg_id      => SQLCODE
677       , p_error_description => SQLERRM
678       , p_error_proc_name   => G_PKG_NAME||'.write_header'
679       , p_error_table       => x_error_tbl
680       , x_error_table       => x_error_tbl
681       );
682       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
683 
684 END write_header;
685 
686 -- ============================================================================
687 -- PROCEDURE : Write_SUCCESS_views
688 -- PARAMETERS 1. p_mode    [production, test, ...]
689 --            2. p_gen_success_table IN view_gen_success_table_type
690 --            3. x_return_status    error or normal
691 --            4. x_error_Tbl        table of error messages
692 -- COMMENT   : Call this function to write the list of success full conversion
693 -- RETURN    : None
694 -- EXCEPTION : None
695 -- ============================================================================
696 PROCEDURE write_success_views
697     ( p_mode              IN bis_vg_Types.view_generator_mode_type
698     , p_gen_success_table IN view_gen_success_table_type
699     , x_return_status       OUT VARCHAR2
700     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
701     )
702 IS
703 l_src    VARCHAR2(100);
704 l_des    VARCHAR2(100);
705 l_pad    NUMBER;
706 l_result view_gen_success_type;
707 BEGIN
708 
709   bis_debug_pub.Add('> write_success_views');
710   x_return_status := FND_API.G_RET_STS_SUCCESS;
711 
712   l_src := fnd_message.get_string( BIS_VG_TYPES.message_application
713                                  , 'BIS_VG_SOURCE_VIEW_HEADING'
714                                  );
715 
716   l_des := fnd_message.get_string( BIS_VG_TYPES.message_application
717                                  , 'BIS_VG_GENERATED_VIEW_HEADING'
718                                  );
719 
720   l_src := Rpad(l_src, 30);
721   l_des := Rpad(l_des, 30);
722 
723   write_string ( p_mode
724                , l_src||' '||l_des
725 	       , x_return_status
726 	       , x_error_Tbl
727 	       );
728   write_string ( p_mode
729                , '------------------------------------------------------------'
730 	       , x_return_status
731 	       , x_error_Tbl
732 	       );
733 
734   FOR i IN 1 .. p_gen_success_table.COUNT LOOP
735     l_result := p_gen_success_table(i);
736 
737     l_src := l_result.business_view_name;
738     l_des := l_result.gen_view_name;
739 
740     l_src := Rpad(l_src, 30);
741     l_des := Rpad(l_des, 30);
742 
743     write_string ( p_mode
744                  , l_src||' '||l_des
745 		 , x_return_status
746 		 , x_error_Tbl
747 		 );
748   END LOOP;
749 
750   bis_debug_pub.Add('< write_success_views');
751 
752 EXCEPTION
753    when FND_API.G_EXC_ERROR then
754       x_return_status := FND_API.G_RET_STS_ERROR ;
755       RAISE FND_API.G_EXC_ERROR;
756    when FND_API.G_EXC_UNEXPECTED_ERROR then
757       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
758       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
759    when others then
760       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
761       BIS_VG_UTIL.Add_Error_Message
762       ( p_error_msg_id      => SQLCODE
763       , p_error_description => SQLERRM
764       , p_error_proc_name   => G_PKG_NAME||'.write_success_views'
765       , p_error_table       => x_error_tbl
766       , x_error_table       => x_error_tbl
767       );
768       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
769 
770 END write_success_views;
771 
772 -- ============================================================================
773 -- PROCEDURE : Write_FAILURE_views
774 -- PARAMETERS 1. p_mode    [production, test, ...]
775 --            2. p_gen_success_table IN view_gen_success_table_type
776 --            3. x_return_status    error or normal
777 --            4. x_error_Tbl        table of error messages
778 -- COMMENT   : Call this function to write the list of success full conversion
779 -- RETURN    : None
780 -- EXCEPTION : None
781 -- ============================================================================
782 PROCEDURE write_failure_views
783 ( p_mode              IN bis_vg_Types.view_generator_mode_type
784 , p_gen_failure_table IN view_gen_failure_table_type
785 , x_return_status       OUT VARCHAR2
786 , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
787 )
788 IS
789 l_result           view_gen_failure_type;
790 l_failure          BOOLEAN := FALSE;
791 l_start            NUMBER := 1;
792 l_view_name_prompt VARCHAR2(100);
793 l_err_code_prompt  VARCHAR2(100);
794 l_err_msg_prompt   VARCHAR2(100);
795 BEGIN
796   bis_debug_pub.Add('> write_failure_views');
797   x_return_status := FND_API.G_RET_STS_SUCCESS;
798 
799   FOR i IN l_start .. p_gen_failure_table.COUNT LOOP
800     l_result := p_gen_failure_table(i);
801 
802     write_blank_line ( p_mode
803                      , 1
804 		     , x_return_status
805 		     , x_error_Tbl
806 		     );
807     write_string ( p_mode
808 		   , l_result.business_view_name
809 		   , x_return_status
810 		   , x_error_Tbl
811 		   );
812     write_string ( p_mode
813 		   , l_result.error_proc_name
814 		   , x_return_status
815 		   , x_error_Tbl
816 		   );
817     write_string ( p_mode
818 		   , l_result.error_description
819 		   , x_return_status
820 		   , x_error_Tbl
821 		   );
822   END LOOP;
823 
824   bis_debug_pub.Add('< write_failure_views');
825 
826 EXCEPTION
827    when FND_API.G_EXC_ERROR then
828       x_return_status := FND_API.G_RET_STS_ERROR ;
829       RAISE FND_API.G_EXC_ERROR;
830    when FND_API.G_EXC_UNEXPECTED_ERROR then
831       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
832       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
833    when others then
834       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
835       BIS_VG_UTIL.Add_Error_Message
836       ( p_error_msg_id      => SQLCODE
837       , p_error_description => SQLERRM
838       , p_error_proc_name   => G_PKG_NAME||'.write_failure_views'
839       , p_error_table       => x_error_tbl
840       , x_error_table       => x_error_tbl
841       );
842       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
843 
844 END write_failure_views;
845 
846 -- ============================================================================
847 --PROCEDURE : Write_Log
848 --PARAMETERS 1. p_mode                IN  bis_vg_Types.view_generator_mode_type
849 --           2. p_all_flag            IN  VARCHAR2
850 --           3. p_App_Short_Name      IN  BIS_VG_TYPES.App_Short_Name_Type
851 --           4. p_KF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
852 --           5. p_Key_Flex_Code       IN  BIS_VG_TYPES.Key_Flex_Code_Type
853 --           6. p_DF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
854 --           7. p_Desc_Flex_Name      IN  BIS_VG_TYPES.Desc_Flex_Name_Type
855 --           8. p_Lookup_Table_Name   IN  VARCHAR2
856 --           9. p_Lookup_Type         IN  BIS_VG_TYPES.Lookup_Code_Type
857 --           10. p_View_Name          IN  BIS_VG_TYPES.View_Name_Type
858 --           11. x_return_status    error or normal
859 --           12. x_error_Tbl        table of error messages
860 --COMMENT   : Call this function to write the log to the out file in production
861 --RETURN    : None
862 --EXCEPTION : None
863 -- ============================================================================
864 PROCEDURE write_log
865     ( p_mode                IN  bis_vg_types.View_Generator_Mode_Type
866     , p_all_flag            IN  VARCHAR2
867     , p_App_Short_Name      IN  BIS_VG_TYPES.App_Short_Name_Type
868     , p_KF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
869     , p_Key_Flex_Code       IN  BIS_VG_TYPES.Key_Flex_Code_Type
870     , p_DF_Appl_Short_Name  IN  BIS_VG_TYPES.App_Short_Name_Type
871     , p_Desc_Flex_Name      IN  BIS_VG_TYPES.Desc_Flex_Name_Type
872     , p_Lookup_Table_Name   IN  VARCHAR2
873     , p_Lookup_Type         IN  BIS_VG_TYPES.Lookup_Code_Type
874     , p_View_Name           IN  BIS_VG_TYPES.View_Name_Type
875     , x_return_status       OUT VARCHAR2
876     , x_error_Tbl           OUT BIS_VG_UTIL.Error_Tbl_Type
877     )
878 IS
879 l_msg_str    VARCHAR2(2000);
880 BEGIN
881   bis_debug_pub.Add('> write_log');
882   x_return_status := FND_API.G_RET_STS_SUCCESS;
883   write_header ( p_mode, x_return_status, x_error_Tbl);
884   write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
885   write_inputs( p_mode
886               , p_all_flag
887               , p_App_Short_Name
888               , p_KF_Appl_Short_Name
889               , p_Key_Flex_Code
890               , p_DF_Appl_Short_Name
891               , p_Desc_Flex_Name
892               , p_Lookup_Table_Name
893               , p_Lookup_Type
894               , p_View_Name
895 	      , x_return_status
896 	      , x_error_Tbl
897               );
898   write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
899 
900   IF (g_gen_success_table.COUNT > 0) THEN
901     IF (g_gen_failure_table.COUNT <> 0) THEN
902       l_msg_str := fnd_message.get_string( BIS_VG_TYPES.message_application
903                                          , 'BIS_VG_SOME_VIEWS_SUCCESSFUL'
904                                          );
905     ELSE
906       l_msg_str := fnd_message.get_string( BIS_VG_TYPES.message_application
907                                          , 'BIS_VG_ALL_VIEWS_SUCCESSFUL'
908                                          );
909     END IF;
910     write_string(p_mode, l_msg_str, x_return_status, x_error_Tbl);
911     write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
912 
913     write_success_views ( p_mode
914                         , g_gen_success_table
915 			, x_return_status
916 			, x_error_Tbl
917 			);
918     write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
919   END IF;
920 
921     bis_debug_pub.add('g_gen_failure_table.count = '||g_gen_failure_table.count);
922   IF (g_gen_failure_table.COUNT > 0) THEN
923     IF (g_gen_success_table.COUNT = 0) THEN
924       l_msg_str := fnd_message.get_string( BIS_VG_TYPES.message_application
925                                          , 'BIS_VG_ALL_VIEWS_UNSUCCESSFUL'
926                                          );
927     ELSE
928       l_msg_str := fnd_message.get_string( BIS_VG_TYPES.message_application
929                                          , 'BIS_VG_SOME_VIEWS_UNSUCCESSFUL'
930                                          );
931     END IF;
932     write_string(p_mode, l_msg_str, x_return_status, x_error_Tbl);
933     write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
934     write_failure_views ( p_mode
935                         , g_gen_failure_table
936 			, x_return_status
937 			, x_error_Tbl
938 			);
939     write_blank_line(p_mode, 1, x_return_status, x_error_Tbl);
940   END IF;
941 
942   IF (p_mode = bis_vg_types.production_mode) THEN
943     fnd_file.CLOSE;
944   END IF;
945   bis_debug_pub.Add('< write_log');
946 
947 EXCEPTION
948    when FND_API.G_EXC_ERROR then
949       x_return_status := FND_API.G_RET_STS_ERROR ;
950       RAISE FND_API.G_EXC_ERROR;
951    when FND_API.G_EXC_UNEXPECTED_ERROR then
952       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
953       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
954    when others then
955       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
956       BIS_VG_UTIL.Add_Error_Message
957       ( p_error_msg_id      => SQLCODE
958       , p_error_description => SQLERRM
959       , p_error_proc_name   => G_PKG_NAME||'.write_log'
960       , p_error_table       => x_error_tbl
961       , x_error_table       => x_error_tbl
962       );
963       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
964 
965 END write_log;
966 
967 
968 -- ============================================================================
969 -- PROCEDURE : Write_Error_to_String
970 -- PARAMETERS 1. x_error_string        String to hold error messages
971 -- COMMENT   : Call this function to access the list of errors in g_failure_log
972 -- RETURN    : None
973 -- EXCEPTION : None
974 -- ============================================================================
975 PROCEDURE write_error_to_string
976 ( x_error_string       OUT VARCHAR2
977 )
978 IS
979 l_result           view_gen_failure_type;
980 l_start            NUMBER := 1;
981 BEGIN
982   bis_debug_pub.Add('> write_error_to_string');
983          x_error_string := x_error_string
984 	   || g_newline
985 	   || 'Error Count = '
986 	   || g_gen_failure_table.COUNT;
987 
988   FOR i IN l_start .. g_gen_failure_table.COUNT LOOP
989     l_result := g_gen_failure_table(i);
990     x_error_string :=
991          x_error_string
992       || g_newline
993       || 'Reported by Procedure: '
994       || l_result.error_proc_name
995       || g_newline
996       || 'Error Message: '
997       || l_result.error_description
998       || g_newline;
999   END LOOP;
1000 
1001   bis_debug_pub.Add('< write_error_to_string');
1002 
1003 EXCEPTION
1004 ---   WHEN numeric_or_value_error THEN
1005 ---      --- This might happen if the string becomes too long
1006 ---      x_error_string :=
1007 ---	x_error_string
1008 ---	|| g_newline
1009 ---	|| 'Error string too long - too many errors';
1010 
1011    WHEN FND_API.G_EXC_ERROR then
1012       x_error_string :=
1013 	x_error_string
1014 	|| g_newline
1015 	|| '***CAUTION: Error ''G_EXC_ERROR'' occurred in write_error_to_string';
1016 
1017    WHEN FND_API.G_EXC_UNEXPECTED_ERROR then
1018       x_error_string :=
1019 	x_error_string
1020 	|| g_newline
1021 	|| '***CAUTION: Error ''G_EXC_UNEXPECTED_ERROR'' occurred '
1022 	|| 'in Write_error_to_string';
1023 
1024    WHEN others then
1025       x_error_string :=
1026 	x_error_string
1027 	|| g_newline
1028 	|| '*** CAUTION: Error Code '
1029 	|| SQLCODE
1030 	|| g_newline
1031 	|| 'Relayed Error Message : '
1032 	|| SQLERRM
1033 	|| g_newline
1034 	|| ' occurred in write_error_to_string';
1035 
1036 END write_error_to_string;
1037 
1038 END BIS_VG_LOG;