[Home] [Help]
PACKAGE BODY: APPS.GME_CANCEL_STEP_PVT
Source
1 PACKAGE BODY gme_cancel_step_pvt AS
2 /* $Header: GMEVCCSB.pls 120.1 2005/06/03 12:26:37 appldev $ */
3 g_debug VARCHAR2 (5) := fnd_profile.VALUE ('AFLOG_LEVEL');
4 g_pkg_name VARCHAR2 (30) := 'GME_CANCEL_STEP_PVT';
5
6 /*
7 REM *********************************************************************
8 REM *
9 REM * FILE: GMEVCCSB.pls
10 REM * PURPOSE: Package Body for the GME step cancel api
11 REM * AUTHOR: Pawan Kumar, OPM Development
12 REM * DATE: 28-April-2005
13 REM * HISTORY:
14 REM * ========
15
16 REM *
17 REM *
18 REM *
19 REM *
20 REM **********************************************************************
21 */
22
23 /*======================================================================================
24 Procedure
25 Cancel_Step
26 Description
27 This particular procedure call close the batch steps.
28 Parameters
29 p_batch_step The batch step row to identify the step.
30 p_validation_level Errors to skip before returning - Default 100
31 x_message_count The number of messages in the message stack
32 x_message_list message stack where the api writes its messages
33 x_return_status outcome of the API call
34 S - Success
35 E - Error
36 U - Unexpected error
37 ======================================================================================*/
38 PROCEDURE cancel_step (
39 p_batch_step_rec IN gme_batch_steps%ROWTYPE
40 ,p_update_inventory_ind IN VARCHAR2
41 ,x_batch_step_rec OUT NOCOPY gme_batch_steps%ROWTYPE
42 ,x_return_status OUT NOCOPY VARCHAR2)
43 IS
44 /* Miscellaneous */
45 l_resource_tab gme_common_pvt.number_tab;
46 l_api_name VARCHAR2 (20) := 'Cancel_step';
47 /* Exception definitions */
48 invalid_step_status EXCEPTION;
49 batch_step_upd_err EXCEPTION;
50 resource_txns_gtmp_del_err EXCEPTION;
51 l_resource_txns gme_resource_txns_gtmp%ROWTYPE;
52 l_resource_txns_tab gme_common_pvt.resource_transactions_tab;
53
54 CURSOR cur_get_resource_ids (v_batchstep_id NUMBER)
55 IS
56 SELECT batchstep_resource_id
57 FROM gme_batch_step_resources
58 WHERE batchstep_id = v_batchstep_id;
59 BEGIN
60 /* Set the save point before processing */
61 SAVEPOINT cancel_batch_step;
62
63 IF (g_debug <= gme_debug.g_log_procedure) THEN
64 gme_debug.put_line (g_pkg_name || '.' || l_api_name || ':'
65 || 'Entering');
66 END IF;
67
68 -- Set the return status to success initially
69 x_return_status := fnd_api.g_ret_sts_success;
70 -- Initialize output batch step
71 x_batch_step_rec := p_batch_step_rec;
72
73 -- remove the resource information for the gme_batch_step_rsrc_summary table
74 IF p_update_inventory_ind = 'Y' THEN
75 /* Get all the resources associated with the step */
76 OPEN cur_get_resource_ids (x_batch_step_rec.batchstep_id);
77
78 FETCH cur_get_resource_ids
79 BULK COLLECT INTO l_resource_tab;
80
81 CLOSE cur_get_resource_ids;
82
83 FOR i IN 1 .. l_resource_tab.COUNT LOOP
84 l_resource_txns.line_id := l_resource_tab (i);
85 gme_resource_engine_pvt.fetch_active_resources
86 (p_resource_rec => l_resource_txns
87 ,x_resource_tbl => l_resource_txns_tab
88 ,x_return_status => x_return_status);
89
90 -- Delete the resource transactions
91 FOR j IN 1 .. l_resource_txns_tab.COUNT LOOP
92 l_resource_txns_tab (j).action_code := 'DEL';
93
94 IF (g_debug <= gme_debug.g_log_procedure) THEN
95 gme_debug.put_line ( g_pkg_name
96 || '.'
97 || l_api_name
98 || ':'
99 || ' Calling resource delete_row');
100 END IF;
101
102 IF NOT (gme_resource_txns_gtmp_dbl.update_row
103 (p_resource_txns => l_resource_txns_tab
104 (j) ) ) THEN
105 RAISE resource_txns_gtmp_del_err;
106 END IF;
107 END LOOP; /*end for l_resource_txns_tab */
108 END LOOP; /*end for l_resource_tab */
109 END IF; /* IF p_update_inventory_ind = 'Y' */
110
111 -- Update the Batch Step Status to Cancel
112 x_batch_step_rec.step_status := 5;
113
114 IF (g_debug <= gme_debug.g_log_procedure) THEN
115 gme_debug.put_line ( g_pkg_name
116 || '.'
117 || l_api_name
118 || ':'
119 || ' Calling step update_row');
120 END IF;
121
122 IF NOT (gme_batch_steps_dbl.update_row (p_batch_step => x_batch_step_rec) ) THEN
123 RAISE batch_step_upd_err;
124 END IF;
125
126 IF (g_debug <= gme_debug.g_log_procedure) THEN
127 gme_debug.put_line ('Exiting ' || g_pkg_name || '.' || l_api_name);
128 END IF;
129 EXCEPTION
130 WHEN resource_txns_gtmp_del_err THEN
131 IF (g_debug <= gme_debug.g_log_procedure) THEN
132 gme_debug.put_line
133 ( g_pkg_name
134 || '.'
135 || l_api_name
136 || ':'
137 || ' cancel_step, error : RESOURCE_TXNS_GTMP_DEL_ERR.');
138 END IF;
139
140 ROLLBACK TO SAVEPOINT cancel_batch_step;
141 WHEN batch_step_upd_err THEN
142 IF (g_debug <= gme_debug.g_log_procedure) THEN
143 gme_debug.put_line ( g_pkg_name
144 || '.'
145 || l_api_name
146 || ':'
147 || ' cancel_step, error : BATCH_STEP_UPD_ERR.');
148 END IF;
149
150 ROLLBACK TO SAVEPOINT cancel_batch_step;
151 WHEN OTHERS THEN
152 IF g_debug <= gme_debug.g_log_unexpected THEN
153 gme_debug.put_line ( 'When others exception in '
154 || g_pkg_name
155 || '.'
156 || l_api_name
157 || ' Error is '
158 || SQLERRM);
159 END IF;
160
161 ROLLBACK TO SAVEPOINT cancel_batch_step;
162 x_return_status := fnd_api.g_ret_sts_unexp_error;
163 fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
164 END cancel_step;
165 END gme_cancel_step_pvt;