[Home] [Help]
PACKAGE BODY: APPS.WSH_TRANSACTIONS_FORM_PKG
Source
1 PACKAGE BODY WSH_TRANSACTIONS_FORM_PKG as
2 /* $Header: WSHINFMB.pls 120.1.12000000.2 2007/01/23 19:23:51 rvishnuv ship $ */
3 --
4 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_TRANSACTIONS_FORM_PKG';
5 --
6 PROCEDURE process_wf_status( p_item_type IN VARCHAR2,
7 p_event_key IN VARCHAR2,
8 X_Return_Status OUT NOCOPY VARCHAR2) IS
9
10
11 pragma AUTONOMOUS_TRANSACTION;
12
13 l_activity VARCHAR2(200);
14
15 l_debug_on BOOLEAN;
16 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'process_wf_status';
17 --
18 BEGIN
19 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
20 IF l_debug_on IS NULL THEN
21 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
22 END IF;
23
24 IF l_debug_on THEN
25 wsh_debug_sv.push(l_module_name);
26 wsh_debug_sv.log (l_module_name,'p_item_type',p_item_type);
27 wsh_debug_sv.log (l_module_name,'p_event_key',p_event_key);
28 END IF;
29
30 x_return_status := wsh_util_core.g_ret_sts_success;
31
32 IF (p_item_type = 'WSHTPWI' ) THEN
33 l_activity := 'WSH_TPW_PROCESS_WF:POPULATE_BASE_TABLES';
34 ELSIF (p_item_type = 'WSHSUPI' ) THEN
35 l_activity := 'WSH_SUPPLIER_WF:WSH_PROCESS_DELIVERY';
36 END IF;
37
38 IF l_debug_on THEN
39 wsh_debug_sv.log (l_module_name,'l_activity',l_activity);
40 END IF;
41
42 Savepoint l_wf_status;
43
44 wf_engine.HandleError(
45 itemtype => p_item_type,
46 itemkey => p_event_key,
47 activity => l_activity,
48 command => 'SKIP',
49 result => 'SUCCESS'
50 );
51
52 COMMIT;
53
54 IF l_debug_on THEN
55 wsh_debug_sv.pop(l_module_name);
56 END IF;
57
58 EXCEPTION
59 WHEN OTHERS THEN
60 Rollback to savepoint l_wf_status;
61 X_return_Status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
62 IF l_debug_on THEN
63 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,
64 WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
65 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
66 wsh_debug_sv.stop_debug;
67 END IF;
68 END process_wf_status;
69
70
71 /*=====================================================================================
72 PROCEDURE NAME : Process_form
73
74 This procedure looks at the Delivery ID , Trip id and Transaction Id and then call
75 Process_inbound for further processing.
76 =======================================================================================*/
77
78 PROCEDURE Process_form( P_delivery_id IN NUMBER,
79 P_trip_id IN NUMBER,
80 P_transaction_id IN NUMBER,
81 X_Return_Status OUT NOCOPY VARCHAR2) IS
82
83
84 L_return_status VARCHAR2(1);
85 l_wf_status varchar2(40);
86 l_wf_result varchar2(40);
87 l_result_code varchar2(40);
88
89 WSH_FAILED_PROCESS EXCEPTION;
90
91 CURSOR history_cur IS
92 SELECT document_type,document_number,orig_document_number,document_direction,transaction_status,
93 action_type,entity_number,entity_type,trading_partner_id,ecx_message_id,
94 event_name,event_key,internal_control_number,item_type
95 FROM WSH_TRANSACTIONS_HISTORY
96 WHERE transaction_id = P_transaction_id;
97
98 cursor c_get_status (v_trx_id NUMBER)
99 IS select TRANSACTION_STATUS
100 FROM wsh_transactions_history
101 WHERE transaction_id = v_trx_id;
102
103 l_trx_status wsh_transactions_history.transaction_status%TYPE;
104
105 --
106 l_debug_on BOOLEAN;
107 --
108 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PROCESS_FORM';
109 --
110 BEGIN
111 --
112 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
113 --
114 IF l_debug_on IS NULL
115 THEN
116 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
117 END IF;
118 --
119 IF l_debug_on THEN
120 WSH_DEBUG_SV.start_debug (P_transaction_id);
121 wsh_debug_sv.push(l_module_name, 'PROCESS_FORM');
122 wsh_debug_sv.log (l_module_name,'Transaction ID', P_Transaction_id);
123 wsh_debug_sv.log (l_module_name,'DELIVERY ID', P_delivery_id);
124 END IF;
125
126 IF (P_transaction_id IS NOT NULL ) THEN --{
127 FOR history_rec in history_cur
128 LOOP
129 IF l_debug_on THEN
130 wsh_debug_sv.log (l_module_name,'Document Number', history_rec.DOCUMENT_NUMBER);
131 END IF;
132
133 --bmso k proj
134 IF l_debug_on THEN
135 wsh_debug_sv.log (l_module_name,'transaction_status',
136 history_rec.transaction_status);
137 wsh_debug_sv.log (l_module_name,'document_type',
138 history_rec.document_type);
139 END IF;
140 --
141 IF history_rec.transaction_status = 'ER'
142 THEN --{
143 IF history_rec.document_type = 'SR' THEN --{
144 --
145 IF l_debug_on THEN
146 wsh_debug_sv.logmsg(l_module_name,
147 'Calling wf_engine.handleError');
148 END IF;
149 --
150 wf_engine.handleError(
151 itemType => history_rec.item_type,
152 itemKey => history_rec.event_key,
153 activity => 'WSH_TPW_PROCESS_WF:POPULATE_BASE_TABLES',
154 command => 'RETRY',
155 result => NULL
156 );
157 ELSE --}{
158 --
159 IF l_debug_on THEN
160 wsh_debug_sv.logmsg(l_module_name,
161 'Calling wf_engine.handleError');
162 END IF;
163 --
164 wf_engine.handleError(
165 itemType => history_rec.item_type,
166 itemKey => history_rec.event_key,
167 activity => 'WSH_SUPPLIER_WF:WSH_PROCESS_DELIVERY',
168 command => 'RETRY',
169 result => NULL
170 );
171 END IF; --}
172 --COMMIT; as per code review
173 ELSIF history_rec.transaction_status = 'AP'
174 THEN --}{
175 --
176 IF l_debug_on THEN
177 wsh_debug_sv.logmsg(l_module_name,
178 'Calling wf_engine.completeActivity');
179 END IF;
180 --
181 wf_engine.completeActivity (
182 itemtype => history_rec.item_type,
183 itemkey => history_rec.event_key,
184 activity => 'WSH_SUPPLIER_WF:CONTINUE_SHIPMENT_ADVICE',
185 result => l_result_code);
186 --COMMIT; as percode review
187 END IF; --}
188
189 --
190 IF l_debug_on THEN
191 wsh_debug_sv.logmsg(l_module_name,
192 'Calling wf_engine.itemStatus');
193 END IF;
194 --
195 OPEN c_get_status(P_transaction_id);
196 FETCH c_get_status INTO l_trx_status;
197 CLOSE c_get_status;
198
199 IF l_debug_on THEN
200 wsh_debug_sv.log (l_module_name,'l_trx_status'
201 , l_trx_status);
202 END IF;
203
204 IF l_trx_status <> 'SC' THEN --{
205 RAISE WSH_FAILED_PROCESS;
206 END IF;
207 /*
208 wf_engine.itemStatus(
209 itemType => history_rec.item_type,
210 itemKey => history_rec.event_key,
211 status => l_wf_status,
212 result => l_wf_result
213 );
214
215 IF l_debug_on THEN
216 wsh_debug_sv.log (l_module_name,'l_wf_status'
217 , l_wf_status);
218 END IF;
219
220 IF l_wf_status <> 'COMPLETE' THEN --{
221 RAISE WSH_FAILED_PROCESS;
222 END IF;
223 */
224
225 END LOOP;
226
227 IF l_debug_on THEN
228 wsh_debug_sv.log (l_module_name,'After loop');
229 END IF;
230 END IF; --}
231 IF l_debug_on THEN
232 wsh_debug_sv.pop(l_module_name);
233 wsh_debug_sv.stop_debug;
234 END IF;
235 EXCEPTION
236 WHEN WSH_FAILED_PROCESS THEN
237 x_return_status := wsh_util_core.g_ret_sts_error;
238 FND_MESSAGE.Set_Name('WSH', 'WSH_FAILED_PROCESS');
239 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
240 IF l_debug_on THEN
241 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_FAILED_PROCESS exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
242 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_FAILED_PROCESS');
243 wsh_debug_sv.stop_debug;
244 END IF;
245
246 WHEN OTHERS THEN
247 X_return_Status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
248 IF l_debug_on THEN
249 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,
250 WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
251 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
252 wsh_debug_sv.stop_debug;
253 END IF;
254 END process_form;
255 END WSH_TRANSACTIONS_FORM_PKG;