DBA Data[Home] [Help]

PACKAGE BODY: APPS.GMP_RESOURCES_PUB

Source


1 PACKAGE BODY GMP_RESOURCES_PUB AS
2 /* $Header: GMPGRESB.pls 120.0.12010000.2 2008/11/05 18:50:46 rpatangy ship $ */
3 
4   /* =============================================================== */
5   /* Procedure:                                                      */
6   /*   insert_resources                                              */
7   /*                                                                 */
8   /* DESCRIPTION:                                                    */
9   /*                                                                 */
10   /* API returns (x_return_code) = 'S' if the insert into resources  */
11   /* header  (cr_rsrc_mst ) table is successfully.                   */
12   /*                                                                 */
13   /* History :                                                       */
14   /* Sridhar 03-SEP-2002  Initial implementation                     */
15   /* =============================================================== */
16   PROCEDURE insert_resources
17   ( p_api_version            IN   NUMBER                           :=  1
18   , p_init_msg_list          IN   BOOLEAN                          :=  TRUE
19   , p_commit                 IN   BOOLEAN                          :=  FALSE
20   , p_resources              IN   cr_rsrc_mst%ROWTYPE
21   , x_message_count          OUT  NOCOPY NUMBER
22   , x_message_list           OUT  NOCOPY VARCHAR2
23   , x_return_status          IN OUT  NOCOPY VARCHAR2
24   ) IS
25 
26   /* Local variable section */
27   l_api_name              CONSTANT VARCHAR2(30) := 'INSERT_RESOURCES';
28   l_row_id                         ROWID;
29   l_return_status                  VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
30 
31 
32   /* get a record type */
33   l_resources_rec   cr_rsrc_mst%ROWTYPE;
34 
35   /* Define Exceptions */
36   resource_creation_failure          EXCEPTION;
37   RESOURCE_REQUIRED                  EXCEPTION;
38   invalid_version                    EXCEPTION;
39   X_msg    varchar2(2000) := '';
40 
41   BEGIN
42     SAVEPOINT create_resources;
43     gmd_debug.log_initialize('CreateResourcesPub');
44 
45     /* Set the return status to success initially */
46     x_return_status  := FND_API.G_RET_STS_SUCCESS;
47     l_resources_rec  := p_resources;
48 
49     /* Initialize message list and count if needed */
50     IF p_init_msg_list THEN
51        fnd_msg_pub.initialize;
52     END IF;
53 
54     /* Make sure we are call compatible */
55     IF NOT FND_API.compatible_api_call ( GMP_RESOURCES_PUB.m_api_version
56                                         ,p_api_version
57                                         ,'INSERT_RESOURCES'
58                                         ,GMP_RESOURCES_PUB.m_pkg_name) THEN
59        x_return_status := FND_API.G_RET_STS_ERROR;
60        RAISE invalid_version;
61     END IF;
62 
63     v_insert_flag := 'Y';
64 
65     IF l_resources_rec.resources IS NOT NULL THEN
66        /* Validation 1.  Check if this resources that is created does not exists
67          in the database.
68        */
69        check_data(l_resources_rec.resources,
70                   l_resources_rec.resource_desc,
71                   l_resources_rec.std_usage_uom,
72                   l_resources_rec.resource_class,
73                   l_resources_rec.cost_cmpntcls_id,
74                   l_resources_rec.min_capacity,
75                   l_resources_rec.max_capacity,
76                   l_resources_rec.capacity_uom,
77                   l_resources_rec.capacity_constraint,
78                   l_resources_rec.capacity_tolerance,
79                   x_message_count,
80                   x_message_list,
81                   l_return_status);
82        IF l_return_status = 'E' THEN
83           RAISE resource_creation_failure;
84        ELSE
85        /* Insert the Resource Data now */
86        /* Making the Capacity Tolerance field NULL if
87           Capacity Constraint field has value = 0
88        */
89          IF l_resources_rec.capacity_constraint = 0
90          THEN
91             l_resources_rec.capacity_tolerance := NULL;
92          END IF;
93 --
94        CR_RSRC_MST_PKG.insert_row
95                  (  l_row_id,
96                     l_resources_rec.resources,
97                     l_resources_rec.resource_class,
98                     l_resources_rec.trans_cnt,
99                     l_resources_rec.delete_mark,
100                     l_resources_rec.text_code,
101                     l_resources_rec.min_capacity,
102                     l_resources_rec.max_capacity,
103                     l_resources_rec.capacity_constraint,
104                     l_resources_rec.capacity_uom,
105                     l_resources_rec.std_usage_uom,
106                     l_resources_rec.cost_cmpntcls_id,
107                     l_resources_rec.resource_desc,
108                     l_resources_rec.creation_date,
109                     l_resources_rec.created_by,
110                     l_resources_rec.last_update_date,
111                     l_resources_rec.last_updated_by,
112                     l_resources_rec.last_update_login,
113                     l_resources_rec.capacity_tolerance,
114                     l_resources_rec.utilization,
115                     l_resources_rec.efficiency
116                   );
117             v_insert_flag := 'N';
118        END IF;
119     ELSE
120        x_return_status := 'E';
121        X_msg := 'Resources';
122        RAISE RESOURCE_REQUIRED;
123        FND_MESSAGE.SET_TOKEN('ERROR', sqlerrm);
124        FND_MSG_PUB.ADD;
125     END IF; /* p_resources.resources IS NOT NULL */
126 
127     fnd_msg_pub.count_and_get (
128        p_count   => x_message_count
129       ,p_encoded => FND_API.g_false
130       ,p_data    => x_message_list);
131 
132     IF x_message_count = 0 THEN
133        gmd_debug.put_line('Resource Header was created successfully');
134     END IF;
135 
136     gmd_debug.put_line('Completed '||l_api_name ||' at '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
137    commit;
138 
139   EXCEPTION
140     WHEN resource_creation_failure OR invalid_version THEN
141          ROLLBACK TO SAVEPOINT create_resources;
142          fnd_msg_pub.count_and_get (
143             p_count => x_message_count
144            ,p_encoded => FND_API.g_false
145            ,p_data => x_message_list);
146          x_return_status := FND_API.G_RET_STS_ERROR;
147 
148     WHEN RESOURCE_REQUIRED THEN
149      x_return_status := FND_API.G_RET_STS_ERROR;
150      FND_MESSAGE.SET_NAME('GMP','GMP_VALUE_REQUIRED');
151      FND_MESSAGE.SET_TOKEN('VALUE_REQUIRED',X_msg);
152      FND_MSG_PUB.ADD;
153      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
154 
155     WHEN OTHERS THEN
156          ROLLBACK TO SAVEPOINT create_resources;
157          FND_MESSAGE.SET_NAME('GMD', 'GMD_UNEXPECTED_ERROR');
158          FND_MESSAGE.SET_TOKEN('ERROR', sqlerrm);
159          FND_MSG_PUB.ADD;
160          fnd_msg_pub.count_and_get (
161             p_count => x_message_count
162            ,p_encoded => FND_API.g_false
163            ,p_data => x_message_list);
164          x_return_status := FND_API.g_ret_sts_unexp_error;
165   END insert_resources;
166 
167   /* =============================================================== */
168   /* Procedure:                                                      */
169   /*   check_data                                                    */
170   /*                                                                 */
171   /* DESCRIPTION:                                                    */
172   /*                                                                 */
173   /* The following Procedure checks the Record and then Inserts      */
174   /* the row into cr_rsrc_mst table and Returns S code if inserted   */
175   /* Successfully                                                    */
176   /*                                                                 */
177   /* History :                                                       */
178   /* Sgidugu 09/03/2002   Initial implementation                     */
179   /* =============================================================== */
180    PROCEDURE  check_data(p_resources        IN VARCHAR2,
181                         p_resource_desc      IN VARCHAR2,
182                         p_std_usage_um       IN VARCHAR2,
183                         p_resource_class     IN VARCHAR2,
184                         p_cost_cmpntcls_id   IN NUMBER,
185                         p_min_capacity       IN NUMBER,
186                         p_max_capacity       IN NUMBER,
187                         p_capacity_uom       IN   VARCHAR2,
188                         p_capacity_constraint  IN   NUMBER,
189                         p_capacity_tolerance   IN   NUMBER,
190                         x_message_count          OUT  NOCOPY NUMBER,
191                         x_message_list           OUT  NOCOPY VARCHAR2,
192                         x_return_status      OUT  NOCOPY VARCHAR2) IS
193    CURSOR Cur_resources IS
194    SELECT COUNT(1)
195    FROM   cr_rsrc_mst
196    where  resources = p_resources
197    and    delete_mark = 0;
198 
199    CURSOR Cur_std_usage_um IS
200    SELECT COUNT(1)
201    FROM   sy_uoms_mst
202    WHERE  uom_code = p_std_usage_um
203    AND    delete_mark = 0;
204 
205    CURSOR Cur_resource_class IS
206    SELECT COUNT(1)
207    FROM   cr_rsrc_cls
208    WHERE  resource_class = p_resource_class
209    AND    delete_mark = 0;
210 
211    CURSOR Cur_cost_cmpntcls_code IS
212    SELECT COUNT(1)
213    FROM   cm_cmpt_mst
214    WHERE  cost_cmpntcls_id = p_cost_cmpntcls_id
215    AND delete_mark     = 0;
216 
217    l_return_val varchar2(16);
218    l_count1      number := 0;
219    l_count2      number := 0;
220    l_count3      number := 0;
221    l_count4      number := 0;
222 
223    INVALID_MIN_MAX  EXCEPTION;
224    INVALID_USAGE_UM  EXCEPTION;
225    PS_DUP_REC  EXCEPTION;
226    INVALID_RSRC_CLASS EXCEPTION;
227    INVALID_VALUE EXCEPTION;
228    RESOURCE_DESC_REQUIRED  EXCEPTION;
229    MIN_MAX_CAPACITY_REQUIRED  EXCEPTION;
230    x_temp number;
231    X_field  varchar2(2000) := '';
232    X_value  varchar2(2000) := '';
233    X_msg  varchar2(2000) := '';
234 
235    BEGIN
236         /* Check Resources if they already exist */
237 
238        IF v_insert_flag = 'Y' then
239           x_return_status := 'S';
240              OPEN Cur_resources;
241              FETCH Cur_resources INTO l_count1;
242              CLOSE Cur_resources;
243              IF l_count1 > 0  then
244                 x_return_status := 'E';
245                 RAISE PS_DUP_REC;
246              END IF;     /* End if for Duplicate Record */
247        END IF;          /* End if for Insert flag = 'Y' */
248 
249         /* Check Usage_um  if they already exist */
250 
251         IF p_std_usage_um is NOT NULL then
252            x_return_status := 'S';
253            OPEN Cur_std_usage_um;
254            FETCH Cur_std_usage_um INTO l_count2;
255            CLOSE Cur_std_usage_um;
256 --
257            IF l_count2 = 0 then
258              x_return_status := 'E';
259              RAISE INVALID_USAGE_UM;
260            END IF;
261         END IF; /* End if for std_usage_um */
262 
263         /* Check Resource Class  if they already exist and
264            if it is a valid entry */
265 
266         IF p_resource_class is NOT NULL then
267            x_return_status := 'S';
268            OPEN Cur_resource_class;
269            FETCH Cur_resource_class INTO l_count3;
270            CLOSE Cur_resource_class;
271 --
272            IF l_count3 = 0 then
273              x_return_status := 'E';
274              RAISE INVALID_RSRC_CLASS;
275            END IF;
276         END IF; /* End if for std_usage_um */
277 
278         /* Check Cost Component Id  if they already exist
279            and if it is a valid entry */
280 
281         IF p_cost_cmpntcls_id is NOT NULL then
282            x_return_status := 'S';
283            OPEN Cur_cost_cmpntcls_code;
284            FETCH Cur_cost_cmpntcls_code INTO l_count4;
285            CLOSE Cur_cost_cmpntcls_code;
286 --
287            IF l_count4 = 0 then
288              x_return_status := 'E';
289            END IF;
290         END IF; /* End if for std_usage_um */
291 --
292         IF p_resource_desc is NULL
293         THEN
294             x_return_status := 'E';
295             X_msg := 'Resource Description';
296             RAISE RESOURCE_DESC_REQUIRED;
297         END IF;
298        /* Check if Min Capacity is greater than Max Capacity */
299 
300        x_return_status := 'S';
301        IF nvl(p_min_capacity,0) > nvl(p_max_capacity,999999.99) THEN
302          x_return_status := 'E';
303          RAISE INVALID_MIN_MAX;
304        END IF ;
305 --
306        /* Check if Max Capacity is lesser than Min Capacity */
307        x_return_status := 'S';
308        IF nvl(p_min_capacity,0) > nvl(p_max_capacity,999999.99) THEN
309          x_return_status := 'E';
310          RAISE INVALID_MIN_MAX;
311        END IF ;
312 --
313       IF p_capacity_constraint NOT IN (0,1)
314       THEN
315              x_return_status := 'E';
316              X_field := 'Capacity Constraint';
317              X_value := p_capacity_constraint;
318              RAISE INVALID_VALUE;
319       END IF ;
320 --
321       IF (p_capacity_constraint = 1)
322       THEN
323          IF (p_min_capacity IS NULL) OR
324             (p_max_capacity IS NULL) OR (p_capacity_uom is NULL)
325          THEN
326              x_return_status := 'E';
327              X_msg := 'Min/Max/Capacity Uom';
328              RAISE MIN_MAX_CAPACITY_REQUIRED;
329          END IF ;
330       END IF ;
331 --
332    EXCEPTION
333     WHEN INVALID_MIN_MAX THEN
334      x_return_status := FND_API.G_RET_STS_ERROR;
335      FND_MESSAGE.SET_NAME('GMP','GMP_MIN_MAX_CAPACITY');
336      FND_MSG_PUB.ADD;
337      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
338 --
339     WHEN MIN_MAX_CAPACITY_REQUIRED THEN
340      x_return_status := FND_API.G_RET_STS_ERROR;
341      FND_MESSAGE.SET_NAME('GMP','GMP_VALUE_REQUIRED');
342      FND_MESSAGE.SET_TOKEN('VALUE_REQUIRED',X_msg);
343      FND_MSG_PUB.ADD;
344      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
345 --
346     WHEN PS_DUP_REC THEN
347      x_return_status := FND_API.G_RET_STS_ERROR;
348      FND_MESSAGE.SET_NAME('GMP','PS_DUP_REC');
349      FND_MSG_PUB.ADD;
350      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
351 --
352     WHEN INVALID_VALUE THEN
353      x_return_status := FND_API.G_RET_STS_ERROR;
354      FND_MESSAGE.SET_NAME('GMP','GMP_INVALID_VALUE');
355      FND_MESSAGE.SET_TOKEN('FIELD',X_field);
356      FND_MESSAGE.SET_TOKEN('VALUE',X_value);
357      FND_MSG_PUB.ADD;
358      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
359 --
360     WHEN RESOURCE_DESC_REQUIRED THEN
361      x_return_status := FND_API.G_RET_STS_ERROR;
362      FND_MESSAGE.SET_NAME('GMP','GMP_VALUE_REQUIRED');
363      FND_MESSAGE.SET_TOKEN('VALUE_REQUIRED',X_msg);
364      FND_MSG_PUB.ADD;
365      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
366 --
367     WHEN INVALID_USAGE_UM THEN
368      x_return_status := FND_API.G_RET_STS_ERROR;
369      FND_MESSAGE.SET_NAME('GMA','SY_INVALID_UM_CODE');
370      FND_MSG_PUB.ADD;
371      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
372 --
373     WHEN INVALID_RSRC_CLASS THEN
374      x_return_status := FND_API.G_RET_STS_ERROR;
375      FND_MESSAGE.SET_NAME('GMP','CR_INVALID_RSRC_CLASS');
376      FND_MSG_PUB.ADD;
377      FND_MSG_PUB.Count_And_Get(p_count=>x_message_count, p_data=>x_message_list);
378 
379    END check_data; /* End of Procedure check_resources */
380 
381   /* =============================================================== */
382   /* Procedure:                                                      */
383   /*   update_resources                                              */
384   /*                                                                 */
385   /* DESCRIPTION:                                                    */
386   /*                                                                 */
387   /* API returns (x_return_code) = 'S' if the update into Generic    */
388   /* Resource Table                                                  */
389   /*                                                                 */
390   /* History :                                                       */
391   /* Sgidugu 09/04/2002   Initial implementation                     */
392   /* =============================================================== */
393   PROCEDURE update_resources
394   ( p_api_version            IN   NUMBER                           :=  1
395   , p_init_msg_list          IN   BOOLEAN                          :=  TRUE
396   , p_commit                 IN   BOOLEAN                          :=  FALSE
397   , p_resources              IN   cr_rsrc_mst%ROWTYPE
398   , x_message_count          OUT  NOCOPY NUMBER
399   , x_message_list           OUT  NOCOPY VARCHAR2
400   , x_return_status          OUT  NOCOPY VARCHAR2
401   ) IS
402 
403   /* Local variable section */
404   l_api_name              CONSTANT VARCHAR2(30) := 'INSERT_RESOURCES';
405   l_row_id                         ROWID;
406   l_return_status                  VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
407 
408   /* Define Exceptions */
409   resource_update_failure          EXCEPTION;
410   invalid_version                  EXCEPTION;
411 
412   BEGIN
413     SAVEPOINT update_resources;
414     gmd_debug.log_initialize('UpdateResourcePub');
415 
416     /* Set the return status to success initially */
417     x_return_status := FND_API.G_RET_STS_SUCCESS;
418 
419     /* Initialize message list and count if needed */
420     IF p_init_msg_list THEN
421        fnd_msg_pub.initialize;
422     END IF;
423 
424     /* Make sure we are call compatible */
425     IF NOT FND_API.compatible_api_call ( GMP_RESOURCES_PUB.m_api_version
426                                         ,p_api_version
427                                         ,l_api_name
428                                         ,GMP_RESOURCES_PUB.m_pkg_name) THEN
429        x_return_status := FND_API.G_RET_STS_ERROR;
430        RAISE invalid_version;
431     END IF;
432 
433     IF p_resources.resources IS NOT NULL THEN
434        /* Validation 1.  Check if this resources that is created does not exists
435          in the the database.
436        */
437        check_data(p_resources.resources,
438                   p_resources.resource_desc,
439                   p_resources.std_usage_uom,
440                   p_resources.resource_class,
441                   p_resources.cost_cmpntcls_id,
442                   p_resources.min_capacity,
443                   p_resources.max_capacity,
444                   p_resources.capacity_uom,
445                   p_resources.capacity_constraint,
446                   p_resources.capacity_tolerance,
447                   x_message_count,
448                   x_message_list,
449                   l_return_status);
450 
451        IF l_return_status = 'E' THEN
452           FND_MESSAGE.SET_NAME('GMA', 'SY_INVALID_DUPLICATION');
453           FND_MSG_PUB.ADD;
454           RAISE resource_update_failure;
455        ELSE
456            /* Update the Resource Data now */
457            CR_RSRC_MST_PKG.update_row(
461                                      p_resources.delete_mark,
458                                      p_resources.resources,
459                                      p_resources.resource_class,
460                                      p_resources.trans_cnt,
462                                      p_resources.text_code,
463                                      p_resources.min_capacity,
464                                      p_resources.max_capacity,
465                                      p_resources.capacity_constraint,
466                                      p_resources.capacity_uom,
467                                      p_resources.std_usage_uom,
468                                      p_resources.cost_cmpntcls_id,
469                                      p_resources.resource_desc,
470                                      p_resources.last_update_date,
471                                      p_resources.last_updated_by,
472                                      p_resources.last_update_login,
473                                      p_resources.capacity_tolerance,
474                                      p_resources.utilization,
475                                      p_resources.efficiency
476                                      );
477        END IF;
478     END IF;
479 
480     /* Check if work was done */
481     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
482        RAISE resource_update_failure;
483     END IF;  /* IF x_return_status <> FND_API.G_RET_STS_SUCCESS */
484 
485     fnd_msg_pub.count_and_get (
486        p_count => x_message_count
487       ,p_encoded => FND_API.g_false
488       ,p_data => x_message_list);
489 
490     IF x_message_count = 0 THEN
491        gmd_debug.put_line('Resource was Updated successfullly');
492     END IF;
493 
494     gmd_debug.put_line('Completed '||l_api_name ||' at '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
495 
496   EXCEPTION
497     WHEN resource_update_failure OR invalid_version THEN
498          ROLLBACK TO SAVEPOINT update_resources;
499          gmd_debug.put_line (m_pkg_name||'.'||l_api_name||':'||'API not complete');
500          fnd_msg_pub.count_and_get (
501             p_count => x_message_count
502            ,p_encoded => FND_API.g_false
503            ,p_data => x_message_list);
504          x_return_status := FND_API.G_RET_STS_ERROR;
505     WHEN OTHERS THEN
506          ROLLBACK TO SAVEPOINT update_resources;
507          gmd_debug.put_line (m_pkg_name||'.'||l_api_name||':'||'When others exception:'||SQLERRM);
508          FND_MESSAGE.SET_NAME('GMD', 'GMD_UNEXPECTED_ERROR');
509          FND_MESSAGE.SET_TOKEN('ERROR', sqlerrm);
510          FND_MSG_PUB.ADD;
511          fnd_msg_pub.count_and_get (
512             p_count   => x_message_count
513            ,p_encoded => FND_API.g_false
514            ,p_data    => x_message_list);
515          x_return_status := FND_API.g_ret_sts_unexp_error;
516   END update_resources;
517 
518   /* =============================================================== */
519   /* Procedure:                                                      */
520   /*   delete_resources                                              */
521   /*                                                                 */
522   /* DESCRIPTION:                                                    */
523   /*                                                                 */
524   /* API returns (x_return_code) = 'S' if the delete Resources       */
525   /* was Successful                                                  */
526   /*                                                                 */
527   /* History :                                                       */
528   /* Sgidugu 09/04/2002   Initial implementation                     */
529   /* =============================================================== */
530   PROCEDURE delete_resources
531   ( p_api_version 	IN 	NUMBER 			        := 1
532   , p_init_msg_list 	IN 	BOOLEAN 			:= TRUE
533   , p_commit		IN 	BOOLEAN 			:= FALSE
534   , p_resources 	IN	cr_rsrc_mst.resources%TYPE
535   , x_message_count 	OUT 	NOCOPY NUMBER
536   , x_message_list 	OUT 	NOCOPY VARCHAR2
537   , x_return_status	OUT 	NOCOPY VARCHAR2
538   ) IS
539   CURSOR Cur_resources IS
540   SELECT count(1)
541   FROM cr_rsrc_mst
542   where resources = p_resources;
543 
544   l_counter number;
545 
546   /* Local variable section */
547   l_api_name              CONSTANT VARCHAR2(30) := 'DELETE_RESOURCES';
548   l_return_status                  VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
549 
550   /* Define Exceptions */
551   resource_delete_failure           EXCEPTION;
552   invalid_version                  EXCEPTION;
553   BEGIN
554     SAVEPOINT delete_resources;
555     gmd_debug.log_initialize('DeleteResourcePub');
556 
557     /* Set the return status to success initially */
558     x_return_status := FND_API.G_RET_STS_SUCCESS;
559 
560     /* Initialize message list and count if needed */
561     IF p_init_msg_list THEN
562        fnd_msg_pub.initialize;
563     END IF;
564 
565     /* Make sure we are call compatible */
566     IF NOT FND_API.compatible_api_call ( GMP_RESOURCES_PUB.m_api_version
567                                         ,p_api_version
568                                         ,l_api_name
569                                         ,GMP_RESOURCES_PUB.m_pkg_name) THEN
570        x_return_status := FND_API.G_RET_STS_ERROR;
571        RAISE invalid_version;
572     END IF;
573 
574     OPEN Cur_resources;
575     FETCH Cur_resources INTO l_counter;
576     CLOSE Cur_resources;
577 
578     IF (l_counter = 0 ) then
579         l_return_status := 'E';
580         GMD_DEBUG.PUT_LINE('Resource to be deleted Does Not Exist ');
581         FND_MSG_PUB.ADD;
582         RAISE resource_delete_failure;
583     ELSE
584         delete from cr_rsrc_mst_tl
585         where resources = p_resources;
586 --
587         delete from cr_rsrc_mst_b
588         where resources = p_resources;
589         l_return_status := 'S';
590     END IF;
591 --
592     fnd_msg_pub.count_and_get (
593        p_count   => x_message_count
594       ,p_encoded => FND_API.g_false
595       ,p_data    => x_message_list);
596 
597     IF x_message_count = 0 THEN
598        gmd_debug.put_line('Resource was deleted successfully');
599     END IF;
600 
601     gmd_debug.put_line('Completed '||l_api_name ||' at '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
602 
603   EXCEPTION
604     WHEN resource_delete_failure OR invalid_version THEN
605          ROLLBACK TO SAVEPOINT delete_resources;
606          gmd_debug.put_line (m_pkg_name||'.'||l_api_name||':'||'API not complete');
607          fnd_msg_pub.count_and_get (
608             p_count => x_message_count
609            ,p_encoded => FND_API.g_false
610            ,p_data => x_message_list);
611          x_return_status := FND_API.G_RET_STS_ERROR;
612     WHEN OTHERS THEN
613          ROLLBACK TO SAVEPOINT delete_resources;
614          gmd_debug.put_line (m_pkg_name||'.'||l_api_name||':'||'When others exception:'||SQLERRM);
615          FND_MESSAGE.SET_NAME('GMD', 'GMD_UNEXPECTED_ERROR');
616          FND_MESSAGE.SET_TOKEN('ERROR', sqlerrm);
617          FND_MSG_PUB.ADD;
618          fnd_msg_pub.count_and_get (
619             p_count => x_message_count
620            ,p_encoded => FND_API.g_false
621            ,p_data => x_message_list);
622          x_return_status := FND_API.g_ret_sts_unexp_error;
623   END delete_resources;
624 
625 END GMP_RESOURCES_PUB;