DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSD_GEN_ERRMSGS_PVT

Source


1 PACKAGE BODY csd_gen_errmsgs_pvt AS
2 /* $Header: csdvgemb.pls 120.1 2008/05/28 21:40:51 swai ship $ */
3 
4    -- ---------------------------------------------------------
5 -- Define global variables
6 -- ---------------------------------------------------------
7    g_pkg_name    CONSTANT VARCHAR2 (30) := 'CSD_GEN_ERRMSGS_PVT';
8    g_file_name   CONSTANT VARCHAR2 (12) := 'csdvgemb.pls';
9    g_debug_level          NUMBER        := csd_gen_utility_pvt.g_debug_level;
10    g_MSG_STATUS_OPEN  VARCHAR2(1)   := 'O';
11 
12    FUNCTION validate_module_code (p_module VARCHAR2)
13       RETURN BOOLEAN;
14 
15 
16 /*-----------------------------------------------------------------------------------------------------------*/
17 /* procedure name:    Save_Fnd_Msgs                                                                          */
18 /* description   : This api will take the messages on the stack and save them in the generic messages table  */
19 /* Called from   : */
20 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
21 /*                 p_module_code         VARCHAR2    Required module which is saving the message.            */
22 /*                 p_source_entity_id_1  NUMBER      Required source entity_id 1.                            */
23 /*                                                            This is usually the repair line id.            */
24 /*                 p_source_entity_type_code VARCHAR2 Required Seeded entity type code.                      */
25 /*                                                             Valid values are 'SERIAL_NUMBER',             */
26 /*                                                             'SERVICE_CODE',                               */
27 /*                                                             'SOLUTION',                                   */
28 /*                                                             'ESTIMATE',                                   */
29 /*                                                             'TASK',                                       */
30 /*                                                             'WIP',                                        */
31 /*                 p_source_entity_id_2  NUMBER      Required source entity_id 2.                            */
32 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
33 /*                                                            fnd_api.g_ret_sts_success (success)            */
34 /*                                                            fnd_api.g_ret_sts_error (error)                */
35 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
36 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
37 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
38 /*-----------------------------------------------------------------------------------------------------------*/
39    PROCEDURE save_fnd_msgs (
40       p_api_version               IN              NUMBER,
41       x_return_status             OUT NOCOPY      VARCHAR2,
42       x_msg_count                 OUT NOCOPY      NUMBER,
43       x_msg_data                  OUT NOCOPY      VARCHAR2,
44       p_module_code               IN              VARCHAR2,
45       p_source_entity_id1         IN              NUMBER,
46       p_source_entity_type_code   IN              VARCHAR2,
47       p_source_entity_id2         IN              NUMBER
48    )
49    IS
50       PRAGMA AUTONOMOUS_TRANSACTION;
51       l_api_version_number   CONSTANT NUMBER          := 1.0;
52       l_api_name             CONSTANT VARCHAR2 (30)   := 'Save_Fnd_Msgs';
53       l_tmp_char                      VARCHAR2 (1);
54       l_msg                           VARCHAR2 (2000) ;
55       l_msg_type                      VARCHAR2 (30);
56       l_msg_status                    VARCHAR2 (30);
57       l_msg_index                     NUMBER;
58       l_count                         NUMBER;
59       l_generic_errmsgs_id            NUMBER;
60       l_msg_dummy                     VARCHAR2(2000);
61       -- swai: bug 7122368 and 7119695
62       -- add variables to identify and supress cost message from service
63       l_app_short_name                VARCHAR2(30);
64       l_message_name                  VARCHAR2(30);
65    BEGIN
66 
67       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
68       THEN
69          fnd_log.STRING (fnd_log.level_procedure,
70                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS.BEGIN',
71                          'Entered SAVE_FND_MSGS'
72                         );
73       END IF;
74 
75 
76       -- Standard call to check for call compatibility.
77       IF NOT fnd_api.compatible_api_call (l_api_version_number,
78                                           p_api_version,
79                                           l_api_name,
80                                           g_pkg_name
81                                          )
82       THEN
83          RAISE fnd_api.g_exc_unexpected_error;
84       END IF;
85 
86       -- initialize return status
87       x_return_status := fnd_api.g_ret_sts_success;
88 
89       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
90       THEN
91          fnd_log.STRING (fnd_log.level_statement,
92                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
93                          'Checking required params'
94                         );
95       END IF;
96 
97       -- Check for required parameters
98       csd_process_util.check_reqd_param (p_param_value      => p_module_code,
99                                          p_param_name       => 'p_module_code',
100                                          p_api_name         => l_api_name
101                                         );
102 
103       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
104       THEN
105          fnd_log.STRING (fnd_log.level_statement,
106                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
107                          'module code is ok'
108                         );
109       END IF;
110 
111       csd_process_util.check_reqd_param
112                                        (p_param_value      => p_source_entity_id1,
113                                         p_param_name       => 'p_source_entity_id1',
114                                         p_api_name         => l_api_name
115                                        );
116 
117       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
118       THEN
119          fnd_log.STRING (fnd_log.level_statement,
120                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
121                          'p_source_entity_id1 is ok'
122                         );
123       END IF;
124 
125       csd_process_util.check_reqd_param
126                                  (p_param_value      => p_source_entity_type_code,
127                                   p_param_name       => 'p_source_entity_type_code',
128                                   p_api_name         => l_api_name
129                                  );
130 
131       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
132       THEN
133          fnd_log.STRING (fnd_log.level_statement,
134                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
135                          'p_source_entity_type_code is ok'
136                         );
137       END IF;
138 
139       csd_process_util.check_reqd_param
140                                        (p_param_value      => p_source_entity_id2,
141                                         p_param_name       => 'p_source_entity_id2',
142                                         p_api_name         => l_api_name
143                                        );
144 
145       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
146       THEN
147          fnd_log.STRING (fnd_log.level_statement,
148                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
149                          'p_source_entity_id2 is ok'
150                         );
151       END IF;
152 
153       IF (NOT validate_module_code (p_module => p_module_code))
154       THEN
155          fnd_message.set_name ('CSD', 'CSD_INVALID_MSG_MODULE');
156          fnd_msg_pub.ADD;
157          RAISE fnd_api.g_exc_error;
158       END IF;
159 
160       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
161       THEN
162          fnd_log.STRING (fnd_log.level_statement,
163                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
164                          'p_msg_module validation passed'
165                         );
166       END IF;
167 
168       fnd_msg_pub.RESET (p_mode => fnd_msg_pub.g_first);
169       l_count := fnd_msg_pub.count_msg;
170 
171       --Loop thru the message stack and insert into the generic error messages table.
172       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
173       THEN
174          fnd_log.STRING (fnd_log.level_statement,
175                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
176                          'Count of messages in the stack[' || l_count || ']'
177                         );
178       END IF;
179 
180       FOR l_index IN 1 .. l_count
181       LOOP
182 
183       -- To get the message type from the message in the stack we need
184       -- to use the get_detail api. The message type should have been
185       -- added by the add_detail API.
186          l_msg := fnd_msg_pub.get_detail (p_encoded => fnd_api.g_true);
187 
188          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
189          THEN
190             fnd_log.STRING (fnd_log.level_statement,
191                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
192                             'Encoded message[' || l_msg || ']'
193                            );
194          END IF;
195 
196          fnd_message.set_encoded (l_msg);
197 -- Get the fnd token for associated cols and ignore.
198          l_msg_type :=
199             fnd_message.get_token
200                               (token                    => fnd_msg_pub.G_associated_cols_token_name,
201                                remove_from_message      => 'Y'
202                               );
203 --Get the message type from the message type token
204          l_msg_type :=
205             fnd_message.get_token
206                               (token                    => fnd_msg_pub.g_message_type_token_name,
207                                remove_from_message      => 'Y'
208                               );
209 
210          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
211          THEN
212             fnd_log.STRING (fnd_log.level_statement,
213                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
214                             'Message type[' || l_msg_type || ']'
215                            );
216          END IF;
217 
218          IF (l_msg_type IS NULL)  --AAA verify
219          THEN
220             l_msg_type := fnd_msg_pub.g_error_msg;
221          END IF;
222 
223 
224          -- Message status is hard coded to OPEN.
225          l_msg_status := G_MSG_STATUS_OPEN;
226 
227          l_msg := fnd_message.get_encoded;
228         -- Call this to get the index of current message.
229          --FND_MSG_PUB.GET(p_data   => l_msg_dummy,
230                         --p_msg_index_out => l_msg_index);
231 
232          -- swai: bug 7122368 and 7119695
233          -- get the app short name and message name to identify and supress
234          -- cost message from service
235          fnd_message.PARSE_ENCODED(ENCODED_MESSAGE =>l_msg,
236                                    APP_SHORT_NAME=>l_app_short_name,
237                                    MESSAGE_NAME=>l_message_name);
238 
239          -- Delete the message from the stack.
240          --fnd_msg_pub.delete_msg (l_msg_index);
241 
242 
243          -- swai: bug 7122368 and 7119695
244          -- suppress the CS_COST_NO_CHARGE_EXIST message from charges
245          IF (l_msg IS NOT NULL)
246             AND NOT (l_app_short_name = 'CS' AND l_message_name = 'CS_COST_NO_CHARGE_EXIST')
247          THEN
248             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
249             THEN
250                fnd_log.STRING (fnd_log.level_statement,
251                                'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
252                                'Adding record into generic error messages'
253                               );
254             END IF;
255 
256             l_generic_errmsgs_id := NULL;
257             csd_generic_errmsgs_pkg.insert_row
258                       (px_generic_errmsgs_id          => l_generic_errmsgs_id,
259                        p_module_code                  => p_module_code,
260                        p_source_entity_id1            => p_source_entity_id1,
261                        p_source_entity_id2            => p_source_entity_id2,
262                        p_source_entity_type_code      => p_source_entity_type_code,
263                        p_msg_type_code                => l_msg_type,
264                        p_msg                          => l_msg,
265                        p_msg_status                   => l_msg_status,
266                        p_created_by                   => fnd_global.user_id,
267                        p_creation_date                => SYSDATE,
268                        p_last_updated_by              => fnd_global.user_id,
269                        p_last_update_date             => SYSDATE,
270                        p_last_update_login            => fnd_global.login_id,
271                        p_object_version_number        => 1 -- not needed
272                       );
273 
274             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
275             THEN
276                fnd_log.STRING (fnd_log.level_statement,
277                                'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
278                                   'Insert into generic error successful,id['
279                                || l_generic_errmsgs_id
280                                || ']'
281                               );
282             END IF;
283          END IF;
284       END LOOP;
285 
286      -- Delete all the messages from the stack.
287      fnd_msg_pub.initialize;
288 
289 
290 -- The commit happens everytime
291 -- in a separate transaction.
292       COMMIT;
293 
294       -- Standard call to get message count and IF count is  get message info.
295       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
296                                  p_data       => x_msg_data);
297 
298       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
299       THEN
300          fnd_log.STRING (fnd_log.level_procedure,
301                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS.END',
302                          'Leaving SAVE_FND_MSGS'
303                         );
304       END IF;
305    EXCEPTION
306       WHEN fnd_api.g_exc_error
307       THEN
308          x_return_status := fnd_api.g_ret_sts_error;
309          ROLLBACK;                                     --TO SP_Save_Fnd_Msgs;
310          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
311                                     p_data       => x_msg_data
312                                    );
313 
314          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
315          THEN
316             fnd_log.STRING (fnd_log.level_error,
317                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
318                             'EXC_ERROR[' || x_msg_data || ']'
319                            );
320          END IF;
321       WHEN fnd_api.g_exc_unexpected_error
322       THEN
323          x_return_status := fnd_api.g_ret_sts_unexp_error;
324          ROLLBACK;                                     --TO SP_Save_Fnd_Msgs;
325          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
326                                     p_data       => x_msg_data
327                                    );
328 
329          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
330          THEN
331             fnd_log.STRING (fnd_log.level_exception,
332                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
333                             'EXC_UNEXPECTED_ERROR[' || x_msg_data || ']'
334                            );
335          END IF;
336       WHEN OTHERS
337       THEN
338          x_return_status := fnd_api.g_ret_sts_unexp_error;
339          ROLLBACK;                                     --TO SP_Save_Fnd_Msgs;
340 
341          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
342          THEN
343             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
344          END IF;
345 
346          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
347                                     p_data       => x_msg_data
348                                    );
349 
350          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
351          THEN
352             fnd_log.STRING (fnd_log.level_exception,
353                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.SAVE_FND_MSGS',
354                             'SQL Message[' || SQLERRM || ']'
355                            );
356          END IF;
357    END save_fnd_msgs;
358 
359 /*-----------------------------------------------------------------------------------------------------------*/
360 /* procedure name: Purge_Msg                                                                                 */
361 /* description   : Deletes a singel generic message record                                                   */
362 /* Called from   : */
363 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
364 /*                 p_generic_errmsgs_id   NUMBER      Required  KEy field for the messages table             */
365 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
366 /*                                                            fnd_api.g_ret_sts_success (success)            */
367 /*                                                            fnd_api.g_ret_sts_error (error)                */
368 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
369 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
370 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
371 /*-----------------------------------------------------------------------------------------------------------*/
372    PROCEDURE purge_msg (
373       p_api_version          IN              NUMBER,
374       x_return_status        OUT NOCOPY      VARCHAR2,
375       x_msg_count            OUT NOCOPY      NUMBER,
376       x_msg_data             OUT NOCOPY      VARCHAR2,
377       p_generic_errmsgs_id   IN              NUMBER
378    )
379    IS
380       PRAGMA AUTONOMOUS_TRANSACTION;
381       l_api_version_number   CONSTANT NUMBER        := 1.0;
382       l_api_name             CONSTANT VARCHAR2 (30) := 'Purge_Msg';
383    BEGIN
384 
385 
386       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
387       THEN
388          fnd_log.STRING (fnd_log.level_procedure,
389                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_MSG.BEGIN',
390                          'Entered Purge_Msg'
391                         );
392       END IF;
393 
394       -- Standard call to check for call compatibility.
395       IF NOT fnd_api.compatible_api_call (l_api_version_number,
396                                           p_api_version,
397                                           l_api_name,
398                                           g_pkg_name
399                                          )
400       THEN
401          RAISE fnd_api.g_exc_unexpected_error;
402       END IF;
403 
404       -- initialize return status
405       x_return_status := fnd_api.g_ret_sts_success;
406 
407       BEGIN
408          DELETE FROM csd_generic_errmsgs
409                WHERE generic_errmsgs_id = p_generic_errmsgs_id;
410       EXCEPTION
411          WHEN NO_DATA_FOUND
412          THEN
413             fnd_message.set_name ('CSD', 'CSD_INVALID_ERRMSGS_ID');
414             fnd_msg_pub.ADD;
415             RAISE fnd_api.g_exc_error;
416          WHEN OTHERS
417          THEN
418             RAISE fnd_api.g_exc_unexpected_error;
419       END;
420 
421       COMMIT;
422 
423       -- Standard call to get message count and IF count is  get message info.
424       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
425                                  p_data       => x_msg_data);
426 
427       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
428       THEN
429          fnd_log.STRING (fnd_log.level_procedure,
430                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_MSG.END',
431                          'Leaving Purge_Msg'
432                         );
433       END IF;
434    EXCEPTION
435       WHEN fnd_api.g_exc_error
436       THEN
437          x_return_status := fnd_api.g_ret_sts_error;
438          ROLLBACK TO sp_purge_msg;
439          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
440                                     p_data       => x_msg_data
441                                    );
442 
443          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
444          THEN
445             fnd_log.STRING (fnd_log.level_error,
446                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_MSG',
447                             'EXC_ERROR[' || x_msg_data || ']'
448                            );
449          END IF;
450       WHEN fnd_api.g_exc_unexpected_error
451       THEN
452          x_return_status := fnd_api.g_ret_sts_unexp_error;
453          ROLLBACK TO sp_purge_msg;
454          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
455                                     p_data       => x_msg_data
456                                    );
457 
458          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
459          THEN
460             fnd_log.STRING (fnd_log.level_exception,
461                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_MSG',
462                             'EXC_UNEXPECTED_ERROR[' || x_msg_data || ']'
463                            );
464          END IF;
465       WHEN OTHERS
466       THEN
467          x_return_status := fnd_api.g_ret_sts_unexp_error;
468          ROLLBACK TO sp_purge_msg;
469 
470          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
471          THEN
472             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
473          END IF;
474 
475          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
476                                     p_data       => x_msg_data
477                                    );
478 
479          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
480          THEN
481             fnd_log.STRING (fnd_log.level_exception,
482                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_MSG',
483                             'SQL Message[' || SQLERRM || ']'
484                            );
485          END IF;
486    END purge_msg;
487 
488 /*-----------------------------------------------------------------------------------------------------------*/
489 /* procedure name: PURGE_ENTITY_MSGS                                                                         */
490 /* description   : This API will delete the messages for the given module,entity codes                       */
491 /* Called from   : */
492 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
493 /*                 p_module_code         VARCHAR2    Required module which is saving the message.            */
494 /*                 p_source_entity_id_1  NUMBER      optional source entity_id 1.                            */
495 /*                                                            This is usually the repair line id.            */
496 /*                 p_source_entity_type_code VARCHAR2 Optional Seeded entity type code.                      */
497 /*                                                             Valid values are 'SERIAL_NUMBER',             */
498 /*                                                             'SERVICE_CODE',                               */
499 /*                                                             'SOLUTION',                                   */
500 /*                                                             'ESTIMATE',                                   */
501 /*                                                             'TASK',                                       */
502 /*                                                             'WIP',                                        */
503 /*                 p_source_entity_id_2  NUMBER      Optional source entity_id 2.                            */
504 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
505 /*                                                            fnd_api.g_ret_sts_success (success)            */
506 /*                                                            fnd_api.g_ret_sts_error (error)                */
507 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
508 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
509 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
510 /*-----------------------------------------------------------------------------------------------------------*/
511    PROCEDURE purge_entity_msgs (
512       p_api_version               IN              NUMBER,
513       x_return_status             OUT NOCOPY      VARCHAR2,
514       x_msg_count                 OUT NOCOPY      NUMBER,
515       x_msg_data                  OUT NOCOPY      VARCHAR2,
516       p_module_code               IN              VARCHAR2,
517       p_source_entity_id1         IN              NUMBER,
518       p_source_entity_type_code   IN              VARCHAR2,
519       p_source_entity_id2         IN              NUMBER
520    )
521    IS
522       PRAGMA AUTONOMOUS_TRANSACTION;
523       l_api_version_number   CONSTANT NUMBER        := 1.0;
524       l_api_name             CONSTANT VARCHAR2 (30) := 'PURGE_ENTITY_MSGS';
525    BEGIN
526 
527       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
528       THEN
529          fnd_log.STRING
530                     (fnd_log.level_procedure,
531                      'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS.BEGIN',
532                      'Entered PURGE_ENTITY_MSGS'
533                     );
534       END IF;
535 
536       -- Standard call to check for call compatibility.
537       IF NOT fnd_api.compatible_api_call (l_api_version_number,
538                                           p_api_version,
539                                           l_api_name,
540                                           g_pkg_name
541                                          )
542       THEN
543          RAISE fnd_api.g_exc_unexpected_error;
544       END IF;
545 
546       -- initialize return status
547       x_return_status := fnd_api.g_ret_sts_success;
548       -- Check for required parameters
549       csd_process_util.check_reqd_param (p_param_value      => p_module_code,
550                                          p_param_name       => 'p_module_code',
551                                          p_api_name         => l_api_name
552                                         );
553 
554       BEGIN
555          DELETE FROM csd_generic_errmsgs
556                WHERE module_code = p_module_code
557                  AND (   source_entity_id1 = p_source_entity_id1
558                       OR p_source_entity_id1 IS NULL
559                      )
560                  AND (   source_entity_type_code = p_source_entity_type_code
561                       OR p_source_entity_type_code IS NULL
562                      )
563                  AND (   source_entity_id2 = p_source_entity_id2
564                       OR p_source_entity_id2 IS NULL
565                      );
566       EXCEPTION
567          WHEN NO_DATA_FOUND
568          THEN
569             NULL;
570          WHEN OTHERS
571          THEN
572             RAISE fnd_api.g_exc_unexpected_error;
573       END;
574 
575       COMMIT;
576 
577       -- Standard call to get message count and IF count is  get message info.
578       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
579                                  p_data       => x_msg_data);
580 
581       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
582       THEN
583          fnd_log.STRING
584                       (fnd_log.level_procedure,
585                        'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS.END',
586                        'Leaving PURGE_ENTITY_MSGS'
587                       );
588       END IF;
589    EXCEPTION
590       WHEN fnd_api.g_exc_error
591       THEN
592          x_return_status := fnd_api.g_ret_sts_error;
593          ROLLBACK;                                 --TO SP_PURGE_ENTITY_MSGS;
594          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
595                                     p_data       => x_msg_data
596                                    );
597 
598          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
599          THEN
600             fnd_log.STRING
601                           (fnd_log.level_error,
602                            'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS',
603                            'EXC_ERROR[' || x_msg_data || ']'
604                           );
605          END IF;
606       WHEN fnd_api.g_exc_unexpected_error
607       THEN
608          x_return_status := fnd_api.g_ret_sts_unexp_error;
609          ROLLBACK;                                 --TO SP_PURGE_ENTITY_MSGS;
610          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
611                                     p_data       => x_msg_data
612                                    );
613 
614          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
615          THEN
616             fnd_log.STRING
617                           (fnd_log.level_exception,
618                            'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS',
619                            'EXC_UNEXPECTED_ERROR[' || x_msg_data || ']'
620                           );
621          END IF;
622       WHEN OTHERS
623       THEN
624          x_return_status := fnd_api.g_ret_sts_unexp_error;
625          ROLLBACK;                                 --TO SP_PURGE_ENTITY_MSGS;
626 
627          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
628          THEN
629             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
630          END IF;
631 
632          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
633                                     p_data       => x_msg_data
634                                    );
635 
636          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
637          THEN
638             fnd_log.STRING
639                           (fnd_log.level_exception,
640                            'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS',
641                            'SQL Message[' || SQLERRM || ']'
642                           );
643          END IF;
644    END purge_entity_msgs;
645 
646 /*-----------------------------------------------------------------------------------------------------------*/
647 /* procedure name: GET_ERRMSGS                                                                               */
648 /* description   : This API will retrieve the messages from the table, populates the message data structure */
649 /*                 and returns the messages data structures.
650 /* Called from   : */
651 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
652 /*                 p_init_msg_list       VARCHAR2    Optional Initializes message stack if fnd_api.g_true,   */
653 /*                                                            default value is fnd_api.g_false               */
654 /*                 p_module_code         VARCHAR2    Required module which is saving the message.            */
655 /*                 p_source_entity_id_1  NUMBER      optional source entity_id 1.                            */
656 /*                                                            This is usually the repair line id.            */
657 /*                 p_source_entity_type_code VARCHAR2 Optional Seeded entity type code.                      */
658 /*                                                             Valid values are 'SERIAL_NUMBER',             */
659 /*                                                             'SERVICE_CODE',                               */
660 /*                                                             'SOLUTION',                                   */
661 /*                                                             'ESTIMATE',                                   */
662 /*                                                             'TASK',                                       */
663 /*                                                             'WIP',                                        */
664 /*                 p_source_entity_id_2  NUMBER      Optional source entity_id 2.                            */
665 /* Output Parm   : x_errmsgs_tbl         CSD_ERRMSGS_TBL       table of message records                      */
666 /*                 x_return_status       VARCHAR2             Return status after the call. The status can be*/
667 /*                                                            fnd_api.g_ret_sts_success (success)            */
668 /*                                                            fnd_api.g_ret_sts_error (error)                */
669 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
670 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
671 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
672 /*-----------------------------------------------------------------------------------------------------------*/
673    PROCEDURE get_errmsgs (
674       p_api_version               IN              NUMBER,
675       p_init_msg_list             IN              VARCHAR2,
676       x_return_status             OUT NOCOPY      VARCHAR2,
677       x_msg_count                 OUT NOCOPY      NUMBER,
678       x_msg_data                  OUT NOCOPY      VARCHAR2,
679       p_module_code               IN              VARCHAR2,
680       p_source_entity_id_1        IN              NUMBER,
681       p_source_entity_type_code   IN              VARCHAR2,
682       p_source_entity_id_2        IN              NUMBER,
683       x_errmsgs_tbl               OUT NOCOPY      csd_errmsgs_tbl
684    )
685    IS
686       l_api_version_number   CONSTANT NUMBER        := 1.0;
687       l_api_name             CONSTANT VARCHAR2 (30) := 'GET_ERRMSGS';
688       l_index                         NUMBER;
689       l_msg_index                     NUMBER;
690 
691       -- Fix for Bug 3824988, sragunat, 11/16/04, Bind Variable fix,
692 	 -- Introduced the following constants to use in Cursor cur_generic_errmsgs
693 	 -- query
694       lc_msg_entity_lkp_typ  CONSTANT VARCHAR2(24) := 'CSD_MSG_ENTITY_TYPE_CODE' ;
695 	 lc_msg_typ_lkp_typ     CONSTANT VARCHAR2(17)  := 'CSD_MSG_TYPE_CODE' ;
696 
697 
698       CURSOR cur_generic_errmsgs (
699          p_module        VARCHAR2,
700          p_entity_type   VARCHAR2,
701          p_entity_id1    NUMBER,
702          p_entity_id2    NUMBER
703       )
704       IS
705          SELECT b.repair_number, c.meaning source_entity_type,
706                 a.source_entity_type_code source_entity_type_code,
707                 d.meaning msg_type, a.msg, a.generic_errmsgs_id,
708                 a.source_entity_id2
709            FROM csd_generic_errmsgs a,
710                 csd_repairs_v b,
711                 fnd_lookups c,
712                 fnd_lookups d
713           WHERE b.repair_line_id = a.source_entity_id1
714             AND c.lookup_code = a.source_entity_type_code
715             AND c.lookup_type = lc_msg_entity_lkp_typ
716             AND d.lookup_code = a.msg_type_code
717             AND d.lookup_type = lc_msg_typ_lkp_typ
718             AND a.module_code = p_module
719             AND a.source_entity_id1 = p_entity_id1
720             AND (   a.source_entity_type_code = p_entity_type
721                  OR p_entity_type IS NULL
722                 )
723             AND (a.source_entity_id2 = p_entity_id2 OR p_entity_id2 IS NULL);
724 
725       CURSOR cur_serial_num (p_entity_id NUMBER)
726       IS
727          SELECT serial_number
728            FROM csd_mass_ro_sn
729           WHERE mass_ro_sn_id = p_entity_id;
730 
731       CURSOR cur_service_code (p_entity_id NUMBER)
732       IS
733          SELECT service_code
734            FROM csd_service_codes_vl
735           WHERE service_code_id = p_entity_id;
736 
737       CURSOR cur_solution_code (p_entity_id NUMBER)
738       IS
739          SELECT NVL (set_name, set_id)
740            FROM cs_kb_sets_vl
741           WHERE set_id = p_entity_id;
742 
743       CURSOR cur_estimate_desc (p_entity_id NUMBER)
744       IS
745          SELECT NVL (work_summary, repair_estimate_id)
746            FROM csd_repair_estimate
747           WHERE repair_estimate_id = p_entity_id;
748 
749       CURSOR cur_wip_name (p_entity_id NUMBER)
750       IS
751          SELECT NVL (wip_entity_name, wip_entity_id) --- AAA not required
752            FROM wip_entities
753           WHERE wip_entity_id = p_entity_id;
754 
755       CURSOR cur_task_name (p_entity_id NUMBER)
756       IS
757          SELECT NVL (task_name, task_number) ---AAA nvl not required
758            FROM csf_debrief_headers_v
759           WHERE task_id = p_entity_id;
760    BEGIN
761 
762 
763       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
764       THEN
765          fnd_log.STRING (fnd_log.level_procedure,
766                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS.BEGIN',
767                          'Entered GET_ERRMSGS'
768                         );
769       END IF;
770 
771       IF fnd_api.to_boolean (p_init_msg_list)
772       THEN
773          -- initialize message list
774          fnd_msg_pub.initialize;
775       END IF;
776 
777       -- Standard call to check for call compatibility.
778       IF NOT fnd_api.compatible_api_call (l_api_version_number,
779                                           p_api_version,
780                                           l_api_name,
781                                           g_pkg_name
782                                          )
783       THEN
784          RAISE fnd_api.g_exc_unexpected_error;
785       END IF;
786 
787       -- initialize return status
788       x_return_status := fnd_api.g_ret_sts_success;
789 
790       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
791       THEN
792          fnd_log.STRING (fnd_log.level_statement,
793                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
794                          'Checking for required parameters'
795                         );
796       END IF;
797 
798       -- Check for required parameters
799       csd_process_util.check_reqd_param (p_param_value      => p_module_code,
800                                          p_param_name       => 'p_module_code',
801                                          p_api_name         => l_api_name
802                                         );
803 
804       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
805       THEN
806          fnd_log.STRING (fnd_log.level_statement,
807                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
808                          'module code is ok'
809                         );
810       END IF;
811 
812       -- Check for required parameters
813       csd_process_util.check_reqd_param
814                                       (p_param_value      => p_source_entity_id_1,
815                                        p_param_name       => 'p_source_entity_id_1',
816                                        p_api_name         => l_api_name
817                                       );
818 
819       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
820       THEN
821          fnd_log.STRING (fnd_log.level_statement,
822                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
823                          'p_source_entity_id_1 is ok'
824                         );
825       END IF;
826 
827       l_index := 1;
828 
829       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
830       THEN
831          fnd_log.STRING (fnd_log.level_statement,
832                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
833                          'p_module_code=[' || p_module_code || ']'
834                         );
835          fnd_log.STRING (fnd_log.level_statement,
836                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
837                             'p_source_entity_type_code=['
838                          || p_source_entity_type_code
839                          || ']'
840                         );
841          fnd_log.STRING (fnd_log.level_statement,
842                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
843                          'p_source_entity_id_1=[' || p_source_entity_id_1
844                          || ']'
845                         );
846          fnd_log.STRING (fnd_log.level_statement,
847                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
848                          'p_source_entity_id_2=[' || p_source_entity_id_2
849                          || ']'
850                         );
851       END IF;
852 
853       FOR msg_rec IN cur_generic_errmsgs (p_module_code,
854                                           p_source_entity_type_code,
855                                           p_source_entity_id_1,
856                                           p_source_entity_id_2
857                                          )
858       LOOP
859          x_errmsgs_tbl (l_index).generic_errmsgs_id :=
860                                                    msg_rec.generic_errmsgs_id;
861          x_errmsgs_tbl (l_index).repair_number := msg_rec.repair_number;
862          x_errmsgs_tbl (l_index).source_entity_type :=
863                                                    msg_rec.source_entity_type;
864          x_errmsgs_tbl (l_index).msg_type := msg_rec.msg_type;
865 
866          --Case stmt to get the correct entity id
867          IF (msg_rec.source_entity_type_code = 'SERIAL_NUMBER')
868          THEN
869             OPEN cur_serial_num (msg_rec.source_entity_id2);
870 
871             FETCH cur_serial_num
872              INTO x_errmsgs_tbl (l_index).source_entity;
873 
874             IF (cur_serial_num%NOTFOUND)
875             THEN
876                x_errmsgs_tbl (l_index).source_entity := '';
877             END IF;
878 
879             CLOSE cur_serial_num;
880          ELSIF (msg_rec.source_entity_type_code = 'SERVICE_CODE')
881          THEN
882             OPEN cur_service_code (msg_rec.source_entity_id2);
883 
884             FETCH cur_service_code
885              INTO x_errmsgs_tbl (l_index).source_entity;
886 
887             IF (cur_service_code%NOTFOUND)
888             THEN
889                x_errmsgs_tbl (l_index).source_entity := '';
890             END IF;
891 
892             CLOSE cur_service_code;
893          ELSIF (msg_rec.source_entity_type_code = 'SOLUTION')
894          THEN
895             OPEN cur_solution_code (msg_rec.source_entity_id2);
896 
897             FETCH cur_solution_code
898              INTO x_errmsgs_tbl (l_index).source_entity;
899 
900             IF (cur_solution_code%NOTFOUND)
901             THEN
902                x_errmsgs_tbl (l_index).source_entity := '';
903             END IF;
904 
905             CLOSE cur_solution_code;
906          ELSIF (msg_rec.source_entity_type_code = 'ESTIMATE')
907          THEN
908             OPEN cur_estimate_desc (msg_rec.source_entity_id2);
909 
910             FETCH cur_estimate_desc
911              INTO x_errmsgs_tbl (l_index).source_entity;
912 
913             IF (cur_estimate_desc%NOTFOUND)
914             THEN
915                x_errmsgs_tbl (l_index).source_entity := '';
916             END IF;
917 
918             CLOSE cur_estimate_desc;
919          ELSIF (msg_rec.source_entity_type_code = 'TASK')
920          THEN
921             OPEN cur_task_name (msg_rec.source_entity_id2);
922 
923             FETCH cur_task_name
924              INTO x_errmsgs_tbl (l_index).source_entity;
925 
926             IF (cur_task_name%NOTFOUND)
927             THEN
928                x_errmsgs_tbl (l_index).source_entity := '';
929             END IF;
930 
931             CLOSE cur_task_name;
932          ELSIF (msg_rec.source_entity_type_code = 'WIP')
933          THEN
934             OPEN cur_wip_name (msg_rec.source_entity_id2);
935 
936             FETCH cur_wip_name
937              INTO x_errmsgs_tbl (l_index).source_entity;
938 
939             IF (cur_wip_name%NOTFOUND)
940             THEN
941                x_errmsgs_tbl (l_index).source_entity := '';
942             END IF;
943 
944             CLOSE cur_wip_name;
945          END IF;
946 
947          fnd_message.set_encoded (msg_rec.msg);
948          x_errmsgs_tbl (l_index).msg := fnd_message.get;
949          l_index := l_index + 1;
950       END LOOP;
951 
952       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
953       THEN
954          fnd_log.STRING (fnd_log.level_statement,
955                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
956                          'Populated errmsgs table'
957                         );
958       END IF;
959 
960       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
961       THEN
962          fnd_log.STRING (fnd_log.level_procedure,
963                          'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS.END',
964                          'Leaving GET_ERRMSGS'
965                         );
966       END IF;
967 
968       -- Standard call to get message count and IF count is  get message info.
969       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
970                                  p_data       => x_msg_data);
971    EXCEPTION
972       WHEN fnd_api.g_exc_error
973       THEN
974          x_return_status := fnd_api.g_ret_sts_error;
975          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
976                                     p_data       => x_msg_data
977                                    );
978 
979          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
980          THEN
981             fnd_log.STRING (fnd_log.level_error,
982                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
983                             'EXC_ERROR[' || x_msg_data || ']'
984                            );
985          END IF;
986       WHEN fnd_api.g_exc_unexpected_error
987       THEN
988          x_return_status := fnd_api.g_ret_sts_unexp_error;
989          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
990                                     p_data       => x_msg_data
991                                    );
992 
993          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
994          THEN
995             fnd_log.STRING (fnd_log.level_exception,
996                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
997                             'EXC_UNEXPECTED_ERROR[' || x_msg_data || ']'
998                            );
999          END IF;
1000       WHEN OTHERS
1001       THEN
1002          x_return_status := fnd_api.g_ret_sts_unexp_error;
1003 
1004          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
1005          THEN
1006             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1007          END IF;
1008 
1009          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
1010                                     p_data       => x_msg_data
1011                                    );
1012 
1013          IF (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level)
1014          THEN
1015             fnd_log.STRING (fnd_log.level_unexpected,
1016                             'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.GET_ERRMSGS',
1017                             'SQL Message[' || SQLERRM || ']'
1018                            );
1019          END IF;
1020    END get_errmsgs;
1021 
1022 /*-----------------------------------------------------------------------------------------------------------*/
1023 /* procedure name: PURGE_ENTITY_MSGS_CP                                                                        */
1024 /* description   : This API will delete the messages for the given module,entity codes                       */
1025 /* Called from   : */
1026 /* Input Parm    : p_module_code         VARCHAR2    Required module which is saving the message.            */
1027 /*                 p_source_entity_id_1  NUMBER      optional source entity_id 1.                            */
1028 /*                                                            This is usually the repair line id.            */
1029 /*                 p_source_entity_type_code VARCHAR2 Optional Seeded entity type code.                      */
1030 /*                                                             Valid values are 'SERIAL_NUMBER',             */
1031 /*                                                             'SERVICE_CODE',                               */
1032 /*                                                             'SOLUTION',                                   */
1033 /*                                                             'ESTIMATE',                                   */
1034 /*                                                             'TASK',                                       */
1035 /*                                                             'WIP',                                        */
1036 /*                 p_source_entity_id_2  NUMBER      Optional source entity_id 2.                            */
1037 /* Output Parm   : errbuf       VARCHAR2             Return status after the call. The status can be*/
1038 /*                                                            fnd_api.g_ret_sts_success (success)            */
1039 /*                                                            fnd_api.g_ret_sts_error (error)                */
1040 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
1041 /*                 retcode      NUMBER               Number of messages in the message stack        */
1042 /*-----------------------------------------------------------------------------------------------------------*/
1043    PROCEDURE purge_entity_msgs_cp (
1044       errbuf          OUT NOCOPY      VARCHAR2,
1045       retcode         OUT NOCOPY      NUMBER,
1046       p_module_code   IN              VARCHAR2
1047    )
1048    IS
1049       l_return_status   VARCHAR2 (30);
1050       l_msg_count       NUMBER;
1051       l_msg_data        VARCHAR2 (2000);
1052       l_msg_index_out   NUMBER;
1053       l_index           NUMBER;
1054    BEGIN
1055       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1056       THEN
1057          fnd_log.STRING
1058                  (fnd_log.level_procedure,
1059                   'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS_CP.BEGIN',
1060                   'Entered PURGE_ENTITY_MSGS_CP'
1061                  );
1062       END IF;
1063 
1064       errbuf := NULL;
1065       retcode := 0;
1066       -- Call the procedure to purge the messages.
1067       purge_entity_msgs (p_api_version                  => 1.0,
1068                          p_module_code                  => p_module_code,
1069                          p_source_entity_id1            => NULL,
1070                          p_source_entity_type_code      => NULL,
1071                          p_source_entity_id2            => NULL,
1072                          x_return_status                => l_return_status,
1073                          x_msg_count                    => l_msg_count,
1074                          x_msg_data                     => l_msg_data
1075                         );
1076 
1077       IF (l_return_status <> fnd_api.g_ret_sts_success)
1078       THEN
1079          FOR l_index IN 1 .. l_msg_count
1080          LOOP
1081              fnd_msg_pub.get (p_msg_index          => l_index,
1082                               p_encoded            => fnd_api.g_false,
1083                               p_data               => l_msg_data,
1084                               p_msg_index_out      => l_msg_index_out
1085                              );
1086              IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
1087              THEN
1088                  fnd_log.STRING
1089                           (fnd_log.level_exception,
1090                            'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS_CP',
1091                            'Error message [' || l_msg_data || ']'
1092                           );
1093              END IF;
1094              fnd_file.put_line (fnd_file.LOG, l_msg_data);
1095              fnd_file.put_line (fnd_file.output, l_msg_data);
1096          END LOOP;
1097          errbuf := l_msg_data;
1098          retcode := 1;
1099       END IF;
1100 
1101       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1102       THEN
1103          fnd_log.STRING
1104                    (fnd_log.level_procedure,
1105                     'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS_CP.END',
1106                     'Leaving PURGE_ENTITY_MSGS_CP'
1107                    );
1108       END IF;
1109    EXCEPTION
1110       WHEN OTHERS
1111       THEN
1112          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
1113          THEN
1114             fnd_log.STRING
1115                        (fnd_log.level_exception,
1116                         'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.PURGE_ENTITY_MSGS_CP',
1117                         'SQL Message[' || SQLERRM || ']'
1118                        );
1119          END IF;
1120    END purge_entity_msgs_cp;
1121 
1122 /******************************************************
1123 Funciton to validate module code
1124 *****************************************************/
1125    FUNCTION validate_module_code (p_module VARCHAR2)
1126       RETURN BOOLEAN
1127    IS
1128       -- Fix for Bug 3824988, sragunat, 11/16/04, Bind Variable fix,
1129 	 -- Introduced the following constants to use in Cursor cur_module_lookup
1130 	 -- query
1131       lc_module_code_lkp_typ CONSTANT VARCHAR2(19) := 'CSD_MSG_MODULE_CODE' ;
1132 	 lc_enabled             CONSTANT VARCHAR2(1)  := 'Y';
1133 
1134       CURSOR cur_module_lookup (p_module_code VARCHAR2)
1135       IS
1136          SELECT 'x'
1137            FROM fnd_lookups
1138           WHERE lookup_type = lc_module_code_lkp_typ
1139             AND lookup_code = p_module_code
1140             AND enabled_flag = lc_enabled
1141             AND (   TRUNC (SYSDATE) >= TRUNC (start_date_active)
1142                  OR start_date_active IS NULL
1143                 )
1144             AND (   TRUNC (SYSDATE) < TRUNC (end_date_active)
1145                  OR end_date_active IS NULL
1146                 );
1147 
1148       l_tmp_char   VARCHAR2 (1);
1149    BEGIN
1150       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1151       THEN
1152          fnd_log.STRING
1153                  (fnd_log.level_procedure,
1154                   'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.VALIDATE_MODULE_CODE.BEGIN',
1155                   'Entered VALIDATE_MODULE_CODE'
1156                  );
1157       END IF;
1158 
1159       OPEN cur_module_lookup (p_module);
1160 
1161       FETCH cur_module_lookup
1162        INTO l_tmp_char;
1163 
1164       IF (cur_module_lookup%FOUND)
1165       THEN
1166          RETURN TRUE;
1167       ELSE
1168          RETURN FALSE;
1169       END IF;
1170 
1171       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1172       THEN
1173          fnd_log.STRING
1174                    (fnd_log.level_procedure,
1175                     'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.VALIDATE_MODULE_CODE.END',
1176                     'Leaving VALIDATE_MODULE_CODE'
1177                    );
1178       END IF;
1179    EXCEPTION
1180       WHEN OTHERS
1181       THEN
1182          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
1183          THEN
1184             fnd_log.STRING
1185                        (fnd_log.level_exception,
1186                         'CSD.PLSQL.CSD_GEN_ERRMSGS_PVT.VALIDATE_MODULE_CODE',
1187                         'SQL Error[' || SQLERRM || ']'
1188                        );
1189          END IF;
1190 
1191          RETURN FALSE;
1192    END validate_module_code;
1193 
1194 -------------------------- Tremporary
1195    PROCEDURE save_fnd_msgs (
1196       p_api_version               IN              NUMBER,
1197       p_commit                 IN              VARCHAR2,
1198       p_init_msg_list          IN              VARCHAR2,
1199       p_validation_level       IN              NUMBER,
1200       x_return_status             OUT NOCOPY      VARCHAR2,
1201       x_msg_count                 OUT NOCOPY      NUMBER,
1202       x_msg_data                  OUT NOCOPY      VARCHAR2,
1203       p_module_code               IN              VARCHAR2,
1204       p_source_entity_id1         IN              NUMBER,
1205       p_source_entity_type_code   IN              VARCHAR2,
1206       p_source_entity_id2         IN              NUMBER
1207    ) IS
1208   BEGIN
1209 
1210        save_fnd_msgs( p_api_version => p_api_version,
1211                       x_return_status => x_return_Status,
1212                       x_msg_count     => x_msg_count,
1213                       x_msg_data      => x_msg_Data,
1214                       p_module_code   => p_module_code,
1215                       p_source_entity_id1 => p_source_entity_id1,
1216                       p_source_entity_type_code => p_source_entity_type_code,
1217                       p_source_entity_id2 => p_source_entity_id2);
1218 
1219   END save_fnd_msgs;
1220 
1221 
1222   PROCEDURE purge_entity_msgs (
1223       p_api_version               IN              NUMBER,
1224       p_commit                 IN              VARCHAR2,
1225       p_init_msg_list          IN              VARCHAR2,
1226       p_validation_level       IN              NUMBER,
1227       x_return_status             OUT NOCOPY      VARCHAR2,
1228       x_msg_count                 OUT NOCOPY      NUMBER,
1229       x_msg_data                  OUT NOCOPY      VARCHAR2,
1230       p_module_code               IN              VARCHAR2,
1231       p_source_entity_id1         IN              NUMBER,
1232       p_source_entity_type_code   IN              VARCHAR2,
1233       p_source_entity_id2         IN              NUMBER
1234    ) IS
1235    BEGIN
1236       purge_entity_msgs (p_api_version                  => p_api_version,
1237                          p_module_code                  => p_module_code,
1238                          p_source_entity_id1            => p_source_entity_id1,
1239                          p_source_entity_type_code      => p_source_entity_type_code,
1240                          p_source_entity_id2            => p_source_entity_id2,
1241                          x_return_status                => x_return_status,
1242                          x_msg_count                    => x_msg_count,
1243                          x_msg_data                     => x_msg_data
1244                         );
1245    END purge_entity_msgs;
1246 
1247 
1248 END csd_gen_errmsgs_pvt;