[Home] [Help]
PACKAGE BODY: APPS.WMS_TASK_MGMT_PUB
Source
1 PACKAGE BODY WMS_TASK_MGMT_PUB AS
2 /*$Header: WMSTKMPB.pls 120.13 2008/05/05 07:35:55 pbonthu noship $ */
3 ------------------------------------------------------------------------------------------------------
4 g_pkg_name VARCHAR2(30) := 'WMS_TASK_MGMT_PUB';
5 g_debug NUMBER := nvl(fnd_profile.VALUE('INV_DEBUG_TRACE'),0);
6 ------------------------------------------------------------------------------------------------------
7 -- START OF QUERY TASKS
8 PROCEDURE initialize_main_table
9 IS
10 BEGIN
11 ---initialize the main table
12 ---this table will have all the parameters with default values that
13 ---need to be passed to wms_waveplan_tasks_pvt.query_tasks procedure
14 g_main_tab(1).field_name := 'ACTIVE';
15 g_main_tab(1).field_value := NULL;
16 g_main_tab(2).field_name := 'ASSEMBLY_ID';
17 g_main_tab(2).field_value := NULL;
18 g_main_tab(3).field_name := 'CARRIER_ID';
19 g_main_tab(3).field_value := NULL;
20 g_main_tab(4).field_name := 'CATEGORY_SET_ID';
21 g_main_tab(4).field_value := NULL;
22 g_main_tab(5).field_name := 'COMPLETED';
23 g_main_tab(5).field_value := FND_API.G_FALSE;
24 g_main_tab(6).field_name := 'CUSTOMER_CATEGORY';
25 g_main_tab(6).field_value := NULL;
26 g_main_tab(7).field_name := 'CUSTOMER_ID';
27 g_main_tab(7).field_value := NULL;
28 g_main_tab(8).field_name := 'CYCLE_COUNT_NAME';
29 g_main_tab(8).field_value := NULL;
30 g_main_tab(9).field_name := 'CYCLE_COUNT_TASKS';
31 g_main_tab(9).field_value := FND_API.G_TRUE;
32 g_main_tab(10).field_name := 'DELIVERY_ID';
33 g_main_tab(10).field_value := NULL;
34 g_main_tab(11).field_name := 'DEPARTMENT_ID';
35 g_main_tab(11).field_value := NULL;
36 g_main_tab(12).field_name := 'DISPATCHED';
37 g_main_tab(12).field_value := FND_API.G_FALSE;
38 g_main_tab(13).field_name := 'EMPLOYEE_ID';
39 g_main_tab(13).field_value := NULL;
40 ---add equipment
41 g_main_tab(14).field_name := 'EQUIPMENT';
42 g_main_tab(14).field_value := NULL;
43 g_main_tab(15).field_name := 'EQUIPMENT_TYPE_ID'; --14
44 g_main_tab(15).field_value := NULL;
45 g_main_tab(16).field_name := 'FROM_CREATION_DATE'; -- 15
46 g_main_tab(16).field_value := NULL;
47 g_main_tab(17).field_name := 'FROM_JOB'; --16
48 g_main_tab(17).field_value := NULL;
49 g_main_tab(18).field_name := 'FROM_LINE'; --17
50 g_main_tab(18).field_value := NULL;
51 g_main_tab(19).field_name := 'FROM_LINES_IN_SALES_ORDER'; --18
52 g_main_tab(19).field_value := NULL;
53 g_main_tab(20).field_name := 'FROM_PICK_SLIP'; --19
54 g_main_tab(20).field_value := NULL;
55 g_main_tab(21).field_name := 'FROM_PO_HEADER_ID'; --20
56 g_main_tab(21).field_value := NULL;
57 g_main_tab(22).field_name := 'FROM_PURCHASE_ORDER'; --21
58 g_main_tab(22).field_value := NULL;
59 g_main_tab(23).field_name := 'FROM_REPLENSIHMENT_MO'; --22
60 g_main_tab(23).field_value := NULL;
61 g_main_tab(24).field_name := 'FROM_REQUISITION'; --23
62 g_main_tab(24).field_value := NULL;
63 g_main_tab(25).field_name := 'FROM_REQUISITION_HEADER_ID'; --24
64 g_main_tab(25).field_value := NULL;
65 g_main_tab(26).field_name := 'FROM_RMA'; --25
66 g_main_tab(26).field_value := NULL;
67 g_main_tab(27).field_name := 'FROM_RMA_HEADER_ID'; --26
68 g_main_tab(27).field_value := NULL;
69 g_main_tab(28).field_name := 'FROM_SALES_ORDER_ID'; --27
70 g_main_tab(28).field_value := NULL;
71 g_main_tab(29).field_name := 'FROM_SHIPMENT'; --28
72 g_main_tab(29).field_value := NULL;
73 g_main_tab(30).field_name := 'FROM_SHIPMENT_DATE'; --29
74 g_main_tab(30).field_value := NULL;
75 g_main_tab(31).field_name := 'FROM_START_DATE'; --30
76 g_main_tab(31).field_value := NULL;
77 g_main_tab(32).field_name := 'FROM_TASK_PRIORITY'; --31
78 g_main_tab(32).field_value := NULL;
79 g_main_tab(33).field_name := 'FROM_TASK_QUANTITY'; --32
80 g_main_tab(33).field_value := NULL;
81 g_main_tab(34).field_name := 'FROM_TRANSFER_ISSUE_MO'; --33
82 g_main_tab(34).field_value := NULL;
83 g_main_tab(35).field_name := 'INBOUND'; --34
84 g_main_tab(35).field_value := FND_API.G_FALSE;
85 g_main_tab(36).field_name := 'INDEPENDENT_TASKS'; --35
86 g_main_tab(36).field_value := FND_API.G_TRUE;
87 g_main_tab(37).field_name := 'INVENTORY_ITEM_ID'; --36
88 g_main_tab(37).field_value := NULL;
89 g_main_tab(38).field_name := 'ITEM_CATEGORY_ID'; --37
90 g_main_tab(38).field_value := NULL;
91 g_main_tab(39).field_name := 'LOADED'; --38
92 g_main_tab(39).field_value := FND_API.G_FALSE;
93 g_main_tab(40).field_name := 'LOCATOR_ID'; --39
94 g_main_tab(40).field_value := NULL;
95 g_main_tab(41).field_name := 'LPN_PUTAWAY_TASKS'; --40
96 g_main_tab(41).field_value := FND_API.G_TRUE;
97 g_main_tab(42).field_name := 'MANUFACTURING'; --41
98 g_main_tab(42).field_value := FND_API.G_FALSE;
99 g_main_tab(43).field_name := 'MANUFACTURING_TYPE'; --42
100 g_main_tab(43).field_value := NULL;
101 g_main_tab(44).field_name := 'MO_ISSUE_TASKS'; --43
102 g_main_tab(44).field_value := FND_API.G_TRUE;
103 g_main_tab(45).field_name := 'MO_TRANSFER_TASKS'; --44
104 g_main_tab(45).field_value := FND_API.G_TRUE;
105 g_main_tab(46).field_name := 'OP_PLAN_ACTIVITY_ID'; --45
106 g_main_tab(46).field_value := NULL;
107 g_main_tab(47).field_name := 'OP_PLAN_ID'; --46
108 g_main_tab(47).field_value := NULL;
109 g_main_tab(48).field_name := 'OP_PLAN_TYPE_ID'; --47
110 g_main_tab(48).field_value := NULL;
111 ---add ORDER_TYPE
112 g_main_tab(49).field_name := 'ORDER_TYPE';
113 g_main_tab(49).field_value := NULL;
114 g_main_tab(50).field_name := 'OUTBOUND'; ---48
115 g_main_tab(50).field_value := FND_API.G_FALSE;
116 g_main_tab(51).field_name := 'PENDING'; --49
117 g_main_tab(51).field_value := FND_API.G_FALSE;
118 g_main_tab(52).field_name := 'PERSON_RESOURCE_ID'; --50
119 g_main_tab(52).field_value := NULL;
120 g_main_tab(53).field_name := 'PLAN_ABORTED'; --51
121 g_main_tab(53).field_value := FND_API.G_FALSE;
122 g_main_tab(54).field_name := 'PLAN_CANCELLED'; --52
123 g_main_tab(54).field_value := FND_API.G_FALSE;
124 g_main_tab(55).field_name := 'PLAN_COMPLETED'; --53
125 g_main_tab(55).field_value := FND_API.G_FALSE;
126 g_main_tab(56).field_name := 'PLAN_IN_PROGRESS'; --54
127 g_main_tab(56).field_value := FND_API.G_FALSE;
128 g_main_tab(57).field_name := 'PLAN_PENDING'; --55
129 g_main_tab(57).field_value := FND_API.G_FALSE;
130 g_main_tab(58).field_name := 'PLANNED_TASKS'; --56
131 g_main_tab(58).field_value := FND_API.G_TRUE;
132 g_main_tab(59).field_name := 'QUEUED'; --57
133 g_main_tab(59).field_value := FND_API.G_FALSE;
134 g_main_tab(60).field_name := 'REPLENISHMENT_TASKS'; --58
135 g_main_tab(60).field_value := FND_API.G_TRUE;
136 g_main_tab(61).field_name := 'SHIP_METHOD_CODE'; --59
137 g_main_tab(61).field_value := NULL;
138 g_main_tab(62).field_name := 'SHIP_TO_COUNTRY'; --60
139 g_main_tab(62).field_value := NULL;
140 g_main_tab(63).field_name := 'SHIP_TO_POSTAL_CODE'; --61
141 g_main_tab(63).field_value := NULL;
142 g_main_tab(64).field_name := 'SHIP_TO_STATE'; --62
143 g_main_tab(64).field_value := NULL;
144 g_main_tab(65).field_name := 'SHIPMENT_PRIORITY'; --63
145 g_main_tab(65).field_value := NULL;
146 g_main_tab(66).field_name := 'STAGING_MOVE'; --64
147 g_main_tab(66).field_value := FND_API.G_FALSE;
148 g_main_tab(67).field_name := 'SUBINVENTORY'; --65
149 g_main_tab(67).field_value := NULL;
150 g_main_tab(68).field_name := 'TO_CREATION_DATE'; --66
151 g_main_tab(68).field_value := NULL;
152 g_main_tab(69).field_name := 'TO_JOB'; --67
153 g_main_tab(69).field_value := NULL;
154 g_main_tab(70).field_name := 'TO_LINE'; --68
155 g_main_tab(70).field_value := NULL;
156 g_main_tab(71).field_name := 'TO_LINES_IN_SALES_ORDER'; --69
157 g_main_tab(71).field_value := NULL;
158 g_main_tab(72).field_name := 'TO_LOCATOR_ID'; --70
159 g_main_tab(72).field_value := NULL;
160 g_main_tab(73).field_name := 'TO_PICK_SLIP'; --71
161 g_main_tab(73).field_value := NULL;
162 g_main_tab(74).field_name := 'TO_PO_HEADER_ID'; --72
163 g_main_tab(74).field_value := NULL;
164 g_main_tab(75).field_name := 'TO_PURCHASE_ORDER'; --73
165 g_main_tab(75).field_value := NULL;
166 g_main_tab(76).field_name := 'TO_REPLENSIHMENT_MO'; --74
167 g_main_tab(76).field_value := NULL;
168 g_main_tab(77).field_name := 'TO_REQUISITION'; --75
169 g_main_tab(77).field_value := NULL;
170 g_main_tab(78).field_name := 'TO_REQUISITION_HEADER_ID';--76
171 g_main_tab(78).field_value := NULL;
172 g_main_tab(79).field_name := 'TO_RMA'; --77
173 g_main_tab(79).field_value := NULL;
174 g_main_tab(80).field_name := 'TO_RMA_HEADER_ID'; --78
175 g_main_tab(80).field_value := NULL;
176 g_main_tab(81).field_name := 'TO_SALES_ORDER_ID'; --79
177 g_main_tab(81).field_value := NULL;
178 g_main_tab(82).field_name := 'TO_SHIPMENT'; --80
179 g_main_tab(82).field_value := NULL;
180 g_main_tab(83).field_name := 'TO_SHIPMENT_DATE'; --81
181 g_main_tab(83).field_value := NULL;
182 g_main_tab(84).field_name := 'TO_START_DATE'; --82
183 g_main_tab(84).field_value := NULL;
184 g_main_tab(85).field_name := 'TO_SUBINVENTORY'; --83
185 g_main_tab(85).field_value := NULL;
186 g_main_tab(86).field_name := 'TO_TASK_PRIORITY'; --84
187 g_main_tab(86).field_value := NULL;
188 g_main_tab(87).field_name := 'TO_TASK_QUANTITY'; --85
189 g_main_tab(87).field_value := NULL;
190 g_main_tab(88).field_name := 'TO_TRANSFER_ISSUE_MO'; --86
191 g_main_tab(88).field_value := NULL;
192 g_main_tab(89).field_name := 'TRIP_ID'; --87
193 g_main_tab(89).field_value := NULL;
194 g_main_tab(90).field_name := 'UNRELEASED'; --88
195 g_main_tab(90).field_value := FND_API.G_FALSE;
196 g_main_tab(91).field_name := 'USER_TASK_TYPE_ID'; --89
197 g_main_tab(91).field_value := NULL;
198 g_main_tab(92).field_name := 'WAREHOUSING'; --90
199 g_main_tab(92).field_value := FND_API.G_FALSE;
200 g_main_tab(93).field_name := 'CROSSDOCK'; --91--Munish added column for crossdock
201 g_main_tab(93).field_value := FND_API.G_FALSE; --Munish initialized column value for crossdock
202 END initialize_main_table;
203
204 -------------------------------------------------------------------------------------------------------------------
205 /*Procedure to log error message to the x_updated_tasks rec*/
206 -------------------------------------------------------------------------------------------------------------------
207
208 PROCEDURE log_error(p_transaction_number IN NUMBER DEFAULT NULL ,
209 p_task_table IN WMS_TASK_MGMT_PUB.task_tab_type ,
210 p_error_msg IN VARCHAR2 ,
211 x_updated_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type) IS
212
213 BEGIN
214 IF p_transaction_number is NOT NULL THEN
215 x_updated_tasks(1).RESULT := 'E';
216 x_updated_tasks(1).ERROR := p_error_msg;
217 ELSIF p_task_table.COUNT > 0 THEN
218 FOR i in 1..p_task_table.COUNT
219 LOOP
220 x_updated_tasks(i).RESULT := 'E';
221 x_updated_tasks(i).ERROR := p_error_msg;
222 END LOOP;
223 END IF;
224 END log_error;
225 --------------------------------------------------------------------------------------------------------
226 /* Check Cartonization API checks if the cartonization_id can be stamped on the
227 set of input tasks.
228 Even if any one of the task fail validation, the API returns error.
229 */
230 --------------------------------------------------------------------------------------------------------
231 PROCEDURE check_cartonization ( p_task_table IN WMS_TASK_MGMT_PUB.task_tab_type ,
232 p_new_carton_lpn_id IN NUMBER DEFAULT NULL ,
233 x_error_msg OUT NOCOPY VARCHAR2 ,
234 x_return_status OUT NOCOPY VARCHAR2 )
235 IS
236 CURSOR carton_lpn_csr(c_lpn_id NUMBER)
237 IS
238 SELECT lpn_context,
239 organization_id,
240 inventory_item_id
241 FROM wms_license_plate_numbers wlpn
242 WHERE wlpn.lpn_id=c_lpn_id;
243
244 CURSOR carton_lpn_del_det (c_lpn_id NUMBER)
245 IS
246 SELECT wdd.delivery_detail_id,
247 wdd.move_order_line_id
248 FROM wsh_delivery_details wdd,
249 mtl_material_transactions_temp mmtt
250 WHERE wdd.move_order_line_id=mmtt.move_order_line_id
251 AND wdd.organization_id =mmtt.organization_id
252 AND (mmtt.transfer_lpn_id =c_lpn_id
253 OR mmtt.cartonization_id = c_lpn_id);
254
255 -- AND ROWNUM < 2;
256 /* CURSOR carton_lpn_del_det1 (c_lpn_id NUMBER)
257 IS
258 SELECT wdd.delivery_detail_id,
259 wdd.move_order_line_id
260 FROM wsh_delivery_details wdd,
261 mtl_material_transactions_temp mmtt
262 WHERE wdd.move_order_line_id=mmtt.move_order_line_id
263 AND wdd.organization_id =mmtt.organization_id
264 AND mmtt.cartonization_id = c_lpn_id
265 AND ROWNUM = 1;*/
266 CURSOR c_get_delivery_id(p_delivery_detail_id NUMBER)
267 IS
268 SELECT delivery_id
269 FROM wsh_delivery_assignments
270 WHERE delivery_detail_id = p_delivery_detail_id;
271 CURSOR c_bulk_task(p_transaction_number NUMBER)
272 IS
273 SELECT '1'
274 FROM mtl_material_transactions_temp
275 WHERE parent_line_id = p_transaction_number
276 AND rownum = 1;
277
278 l_carton_lpn_ctx NUMBER;
279 l_carton_lpn_org NUMBER;
280 l_carton_del_det_id NUMBER;
281 l_carton_del_id NUMBER;
282 l_carton_move_order_line_id NUMBER;
283 l_temp_carton_grp_id NUMBER;
284 l_carton_grp_id_tab WSH_UTIL_CORE.id_tab_type;
285 l_del_det_id_tab WSH_UTIL_CORE.id_tab_type;
286 l_del_det_id_no_del_tab WSH_UTIL_CORE.id_tab_type;
287 l_del_id_tab WSH_UTIL_CORE.id_tab_type;
288 l_move_order_line_id_tab WSH_UTIL_CORE.id_tab_type;
289 l_bulk_task VARCHAR2(2);
290 l_temp_del_detail_id NUMBER;
291 l_move_order_line_id NUMBER;
292 l_temp_del_id NUMBER;
293 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
294 l_api_name VARCHAR2(1000) := 'CHECK_CARTONIZATION';
295 l_error_msg VARCHAR2(2000);
296 l_msg_count NUMBER;
297 p_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
298 l_validation_level NUMBER;
299 l_grouping_rows WSH_UTIL_CORE.id_tab_type;
300 l_del_id_tab_new WSH_UTIL_CORE.id_tab_type;
301 l_return_status VARCHAR2(10);
302 l_msg_data varchar2(1000);
303 l_delivery_name VARCHAR2(30) := NULL;
307 BEGIN
304 l_delivery_id NUMBER;
305 l_carton_lpn_itm_id NUMBER;
306
308 x_return_status := fnd_api.g_ret_sts_success;
309 OPEN carton_lpn_csr(p_new_carton_lpn_id);
310 FETCH carton_lpn_csr INTO l_carton_lpn_ctx,l_carton_lpn_org,l_carton_lpn_itm_id;
311 CLOSE carton_lpn_csr;
312 --if carton lpn is passed and is not valid then no need to proceed further
313 IF(l_carton_lpn_ctx NOT IN (5,8)) THEN
314 x_return_status := fnd_api.g_ret_sts_error;
315 fnd_message.set_name('WMS', 'WMS_CARTON_LPN_CTX_ERR');
316 fnd_msg_pub.ADD;
317 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE, p_count => l_msg_count, p_data => x_error_msg );
318 l_error_msg :='Invalid context for Carton LPN:'||p_new_carton_lpn_id;
319 IF(l_debug = 1) THEN
320 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
321 END IF;
322 RETURN;
323 ELSIF (l_carton_lpn_itm_id is NULL) THEN
324 x_return_status := fnd_api.g_ret_sts_error;
325 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
326 fnd_msg_pub.ADD;
327 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE, p_count => l_msg_count, p_data => x_error_msg );
328 l_error_msg :='Inventory item id is not present in carton LPN';
329 IF(l_debug = 1) THEN
330 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
331 END IF;
332 RETURN;
333 END IF;
334
335 /* IF (l_carton_lpn_ctx = 5 ) THEN
336 OPEN carton_lpn_del_det1(p_new_carton_lpn_id);
337 FETCH carton_lpn_del_det1
338 INTO l_carton_del_det_id,
339 l_carton_move_order_line_id;
340 CLOSE carton_lpn_del_det1;
341 IF (l_carton_del_det_id is NOT NULL and l_carton_move_order_line_id is NOT NULL) THEN
342 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_carton_del_det_id;
343 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_carton_move_order_line_id;
344 END IF;
345 END IF;*/
346 IF (l_carton_lpn_ctx in (5,8) ) THEN
347 --get carton del_det_id and mover_oder_line_id
348 OPEN carton_lpn_del_det(p_new_carton_lpn_id);
349 LOOP
350 FETCH carton_lpn_del_det
351 INTO l_carton_del_det_id,
352 l_carton_move_order_line_id;
353
354 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_carton_del_det_id;
355 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_carton_move_order_line_id;
356 EXIT WHEN carton_lpn_del_det%NOTFOUND;
357 END LOOP;
358
359 CLOSE carton_lpn_del_det;
360
361 END IF;
362 FOR i IN 1..p_task_table.count
363 LOOP
364 IF (p_task_table(i).organization_id <> l_carton_lpn_org) THEN
365 x_return_status := fnd_api.g_ret_sts_error;
366 fnd_message.set_name('WMS', 'WMS_CARTON_LPN_ORG_ERR');
367 fnd_msg_pub.ADD;
368 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE, p_count => l_msg_count, p_data => x_error_msg );
369 l_error_msg :='Organization is not same for Carton LPN and Task';
370 IF(l_debug = 1) THEN
371 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
372 END IF;
373 RETURN;
374 END IF;
375 --Bulk tasks cannot be cartonized
376 OPEN c_bulk_task(p_task_table(i).transaction_number);
377 FETCH c_bulk_task INTO l_bulk_task;
378 IF c_bulk_task%NOTFOUND THEN
379 CLOSE c_bulk_task;
380 ELSE
381 x_return_status := fnd_api.g_ret_sts_error;
382 fnd_message.set_name('WMS', 'WMS_CARTON_BULK_ERR');
383 fnd_msg_pub.ADD;
384 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE, p_count => l_msg_count, p_data => x_error_msg );
385 l_error_msg :='Bulk Tasks cannot be cartonized';
386 IF(l_debug = 1) THEN
387 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
388 END IF;
389 CLOSE c_bulk_task;
390 RETURN;
391 END IF;
392 END LOOP;
393 --Fetch the delivery_detail_id's and move order line id's associated with the input task/tasks.
394 FOR i IN 1..p_task_table.count
395 LOOP
396 BEGIN
397 SELECT wdd.delivery_detail_id,
398 wdd.move_order_line_id
399 INTO l_temp_del_detail_id,
400 l_move_order_line_id
401 FROM wsh_delivery_details wdd,
402 mtl_material_transactions_temp mmtt
403 WHERE wdd.move_order_line_id = mmtt.move_order_line_id
404 AND mmtt.transaction_temp_id = p_task_table(i).transaction_number;
405 EXCEPTION
406 WHEN OTHERS THEN
407 l_temp_del_detail_id := NULL;
408 END;
409 IF (l_temp_del_detail_id IS NULL) THEN
410 x_return_status := fnd_api.g_ret_sts_error;
414 l_error_msg :='Data not present in WDD for the corresponding task :'||p_task_table(i).transaction_number;
411 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
412 fnd_msg_pub.ADD;
413 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
415 IF(l_debug = 1) THEN
416 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
417 END IF;
418 RETURN;
419 ELSE
420 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_temp_del_detail_id;
421 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_move_order_line_id;
422 END IF;
423 END LOOP;
424 --Fetch the delivery_id associated with the tasks.
425 FOR i IN 1..l_del_det_id_tab.COUNT
426 LOOP
427 BEGIN
428 SELECT delivery_id
429 INTO l_temp_del_id
430 FROM wsh_delivery_assignments
431 WHERE delivery_detail_id = l_del_det_id_tab(i);
432 EXCEPTION
433 WHEN OTHERS THEN
434 l_temp_del_id := NULL;
435 --fetch the dd id's with null delivery_id into l_del_det_id_no_del_tab.
436 l_del_det_id_no_del_tab(l_del_det_id_no_del_tab.count+1) := l_del_det_id_tab(i);
437 END;
438 l_del_id_tab(l_del_id_tab.count +1) := l_temp_del_id;
439 END LOOP;
440 --Need to check if all the deliveries are same or not.
441 --This needs to be done only if count of delivery_detail_id is >1.
442 IF l_del_det_id_tab.COUNT > 1 THEN
443 FOR i IN 1..l_del_id_tab.COUNT
444 LOOP
445 IF (l_del_id_tab(i) is NOT NULL) THEN
446 --copy the value to a new structure
447 l_del_id_tab_new(l_del_id_tab_new.count +1) := l_del_id_tab(i);
448 END IF;
449 END LOOP;
450
451 IF (l_del_id_tab_new.COUNT = 0) THEN
452 --all the delivery_id's are null,
453 --Call delivery_grouping API.
454
455 WSH_DELIVERY_DETAILS_GRP.Get_Carton_Grouping( p_line_rows => l_del_det_id_tab,
456 x_grouping_rows => l_grouping_rows,
457 x_return_status => l_return_status);
458
459 IF l_return_status = 'S' then
460 -- check if all the values in l_grouping_rows are same.
461 FOR i in 1..l_grouping_rows.COUNT LOOP
462 IF (l_grouping_rows(1) <> l_grouping_rows(i)) THEN
463 x_return_status := fnd_api.g_ret_sts_error;
464 fnd_message.set_name('WMS', 'WMS_CARTON_DEL_GP_ERR');
465 fnd_msg_pub.ADD;
466 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
467 l_error_msg :='Delivery grouping mismatch,cartonization cannot be done';
468 IF(l_debug = 1) THEN
469 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
470 END IF;
471 RETURN;
472 END IF;
473 END LOOP;
474
475 END IF;
476
477 ELSE --l_del_id_Tab_new.count > 0
478 --check if the delivery_id's that are present in l_del_id_tab_new are all same.
479 FOR i in 1..l_del_id_tab_new.COUNT LOOP
480 IF (l_del_id_tab_new(1) <> l_del_id_tab_new(i)) THEN
481 x_return_status := fnd_api.g_ret_sts_error;
482 fnd_message.set_name('WMS', 'WMS_CARTON_DEL_ERR');
483 fnd_msg_pub.ADD;
484 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
485 l_error_msg :='Delivery mismatch,cartonization cannot be done';
486 IF(l_debug = 1) THEN
487 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
488 END IF;
489 RETURN;
490 END IF;
491 END LOOP;
492 --del_id's present are all same.
493 --call WSH API by passing deliery_id from l_del_id_tab_new and l_del_det_id_no_del_tab
494 --and see if the same delivery_id can be stamped on the null delivery records.
495 --This needs to be done only if there are some delivery_detail_ids for which there is
496 --no delivery association.
497 IF (l_del_det_id_no_del_tab.COUNT > 0 ) THEN
498
499 l_delivery_id := l_del_id_tab_new(1);
500
501 wsh_delivery_details_grp.detail_to_delivery(
502 p_api_version => 1.0,
503 p_init_msg_list => FND_API.G_FALSE,
504 p_commit => FND_API.G_FALSE,
505 p_validation_level => l_validation_level,
506 x_return_status => l_return_status,
507 x_msg_count => l_msg_count,
508 x_msg_data => l_msg_data,
509 p_TabOfDelDets => l_del_det_id_no_del_tab,
510 p_action => 'ASSIGN',
511 p_delivery_id => l_delivery_id,
512 p_delivery_name => l_delivery_name,
513 p_action_prms => p_action_prms);
514
515 IF l_return_status <> 'S' THEN
516 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
517 fnd_msg_pub.ADD;
521 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
518 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
519 l_error_msg :='Error returned from WSH API';
520 IF(l_debug = 1) THEN
522 END IF;
523 RETURN;
524 END IF;
525 END IF;
526 END IF;
527 END IF;
528
529 END check_cartonization;
530 -------------------------------------------------------------------------------------------------------------------
531 /*This procedure checks if the various attributes that are passed can be updated
532 on the provided task*/
533 -------------------------------------------------------------------------------------------------------------------
534
535 PROCEDURE modify_single_task( p_task_rec IN WMS_TASK_MGMT_PUB.task_output_rectype,
536 P_new_task_status IN NUMBER DEFAULT NULL,
537 P_new_task_priority IN NUMBER DEFAULT NULL,
538 P_new_task_type IN VARCHAR2 DEFAULT NULL,
539 P_new_carton_lpn_id IN NUMBER DEFAULT NULL,
540 p_new_operation_plan_id IN NUMBER DEFAULT NULL,
541 p_output_task_rec OUT NOCOPY WMS_TASK_MGMT_PUB.task_output_rectype,
542 p_op_plan_rec IN WMS_TASK_MGMT_PUB.op_plan_rec)
543 IS
544 l_lpn VARCHAR2(30);
545 l_return_status VARCHAR2(10);
546 l_count NUMBER DEFAULT 0;
547 l_operation_plan_type_id NUMBER;
548 l_msg_data fnd_new_messages.MESSAGE_TEXT%TYPE;
549 l_msg_count NUMBER;
550 l_error_code NUMBER;
551 l_std_task_type NUMBER;
552 l_usr_task_type_id NUMBER;
553 l_err_msg VARCHAR2(240);
554 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
555 l_api_name VARCHAR2(1000) := 'MODIFY_SINGLE_TASK';
556 l_msg VARCHAR2(2000);
557
558 Cursor c_usr_task_type(p_std_task_type NUMBER,
559 p_operation_code VARCHAR2,
560 p_org_id NUMBER) IS
561 SELECT standard_operation_id
562 FROM BOM_STANDARD_OPERATIONS_V
563 WHERE wms_task_type = p_std_task_type
564 AND operation_code = p_operation_code
565 AND organization_id = p_org_id ;
566
567 --operation plan code changes start 6888354
568
569 CURSOR c_plan_detail(v_operation_plan_id NUMBER) IS
570 SELECT operation_plan_detail_id
571 , operation_sequence
572 , is_in_inventory
573 , operation_type
574 FROM WMS_OP_PLAN_DETAILS
575 WHERE operation_plan_id = v_operation_plan_id
576 AND operation_sequence = (SELECT MIN(operation_sequence)
577 FROM WMS_OP_PLAN_DETAILS
578 WHERE operation_plan_id=v_operation_plan_id);
579
580 CURSOR C_OP_PLANS_B(v_operation_plan_id NUMBER) IS
581 SELECT OPERATION_PLAN_ID,
582 SYSTEM_TASK_TYPE,
583 ACTIVITY_TYPE_ID,
584 PLAN_TYPE_ID
585 FROM WMS_OP_PLANS_B
586 WHERE operation_plan_id=v_operation_plan_id;
587
588 CURSOR C_OP_OPERATIONS_STATUS(v_source_task_id NUMBER) IS
589 SELECT STATUS FROM wms_op_plan_instances
590 WHERE ((
591 source_task_id in
592 (SELECT parent_line_id
593 FROM mtl_material_transactions_temp
594 WHERE transaction_temp_id =v_source_task_id
595 )) OR (source_task_id =v_source_task_id )); ---contains parent only
596
597 l_op_plan_b_rec C_OP_PLANS_B%ROWTYPE;
598 l_operation_plan_detail_rec c_plan_detail%ROWTYPE;
599 l_op_operation_status_rec C_OP_OPERATIONS_STATUS%ROWTYPE;
600 l_src_tran_id NUMBER;
601 l_src_parent_id NUMBER;
602
603 --operation plan code changes end 6888354
604
605
606 BEGIN
607 --6888354 START
608 IF (p_task_rec.status_id = 9 ) THEN
609 /*If the original task status is Active, check if the user whom the tasks
610 assigned is logged on to the system. If the user is logged on, updating the same is not allowed. */
611 BEGIN
612 SELECT COUNT(*)
613 INTO l_count
614 FROM WMS_DISPATCHED_TASKS wdt1
615 WHERE wdt1.status = 9
616 AND wdt1.TRANSACTION_TEMP_ID =p_task_rec.TRANSACTION_NUMBER
617 AND EXISTS
618 (SELECT 1
619 FROM MTL_MOBILE_LOGIN_HIST MMLH,
620 WMS_DISPATCHED_TASKS wdt
621 WHERE wdt1.TRANSACTION_TEMP_ID = wdt.TRANSACTION_TEMP_ID
622 AND MMLH.USER_ID = wdt1.LAST_UPDATED_BY
623 AND MMLH.LOGOFF_DATE IS NULL
624 AND MMLH.EVENT_MESSAGE IS NULL
625 );
626 EXCEPTION
627 WHEN OTHERS THEN
628 NULL;
629 l_msg := 'Error in querying Active tasks';
630 IF(l_debug = 1) THEN
631 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
632 END IF;
633 p_output_task_rec.RESULT := 'E';
634 p_output_task_rec.ERROR := l_err_msg;
635 RETURN;
636 END;
637 IF l_count > 0 THEN
638 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');--new message WMS_ATF_ACTIVE_TASK_EXP
639 fnd_msg_pub.ADD;
643 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
640 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
641 l_msg := 'Active task can be updated if tasks assigned to user is logged off the system';
642 IF(l_debug = 1) THEN
644 END IF;
645 p_output_task_rec.RESULT := 'E';
646 p_output_task_rec.ERROR := l_err_msg;
647 RETURN;
648 END IF;
649 ELSIF (p_task_rec.status_id = 3 ) THEN
650 /*A task can be in dispatched status when a group of tasks are dispatched to a mobile user
651 and one of the tasks in the group is in ACTIVE status and the rest in DISPATCHED status.
652 Updating such dispatched tasks to pending/unreleased status SHOULD NOT be allowed. */
653 BEGIN
654 SELECT COUNT(*)
655 INTO l_count
656 FROM mtl_material_transactions_temp mmtt,
657 WMS_DISPATCHED_TASKS wdt
658 WHERE mmtt.transaction_temp_id = wdt.transaction_temp_id
659 AND wdt.transaction_temp_id =p_task_rec.TRANSACTION_NUMBER
660 AND wdt.status = 3
661 AND EXISTS
662 (SELECT 1
663 FROM WMS_DISPATCHED_TASKS wdt2
664 WHERE wdt2.person_id = p_task_rec.PERSON_ID
665 AND wdt2.status = 9
666 AND wdt2.task_method IS NOT NULL
667 AND wdt2.transaction_temp_id IN
668 (SELECT transaction_temp_id
669 FROM mtl_material_transactions_temp mmtt1
670 WHERE
671 DECODE(wdt.TASK_METHOD, 'CARTON', mmtt1.cartonization_id, 'PICK_SLIP', mmtt1.pick_slip_number, 'DISCRETE', mmtt1.pick_slip_number, mmtt1.transaction_source_id) =
672 DECODE(wdt.TASK_METHOD, 'CARTON', mmtt.cartonization_id, 'PICK_SLIP', mmtt.pick_slip_number, 'DISCRETE', mmtt.pick_slip_number, mmtt.transaction_source_id)
673 )
674 );
675 EXCEPTION
676 WHEN OTHERS THEN
677 NULL;
678 l_msg := 'Error in querying Dispatched tasks';
679 IF(l_debug = 1) THEN
680 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
681 END IF;
682 p_output_task_rec.RESULT := 'E';
683 p_output_task_rec.ERROR := l_err_msg;
684 RETURN;
685 END;
686 IF (l_count > 0 ) THEN --ANY OF GROUP TASK IS active
687 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');--new message WMS_ATF_DISPATCH_TASK_EXP
688 fnd_msg_pub.ADD;
689 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
690 l_msg := 'Dispatcher task can be updated only if any of the task in group is not in Active status';
691 IF(l_debug = 1) THEN
692 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
693 END IF;
694 p_output_task_rec.RESULT := 'E';
695 p_output_task_rec.ERROR := l_err_msg;
696 RETURN;
697 END IF;
698 END IF;
699
700 IF (p_new_task_status IS NOT NULL) THEN
701 --check the current task status and then only do the updated.
702 --status_id = 1==>Pending,2==>Qued,8==>Unreleased,9==>Active.
703 IF (p_task_rec.status_id = 9 ) THEN
704 IF p_new_task_status in (1,8) THEN
705 p_output_task_rec.status_id := p_new_task_status;
706 ELSE
707 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
708 fnd_msg_pub.ADD;
709 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
710 l_msg := 'Active task can be moved only to Pending or Unreleased state';
711 IF(l_debug = 1) THEN
712 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
713 END IF;
714 p_output_task_rec.RESULT := 'E';
715 p_output_task_rec.ERROR := l_err_msg;
716 RETURN;
717 END IF;
718 ELSIF (p_task_rec.status_id = 3 ) THEN
719 IF p_new_task_status in (1,8) THEN
720 p_output_task_rec.status_id := p_new_task_status;
721 ELSE
722 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
723 fnd_msg_pub.ADD;
724 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
725 l_msg := 'Dispatcher task can be moved only to Pending or Unreleased state';
726 IF(l_debug = 1) THEN
727 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
728 END IF;
729 p_output_task_rec.RESULT := 'E';
730 p_output_task_rec.ERROR := l_err_msg;
731 RETURN;
732 END IF; --6888354 END
733 ELSIF (p_task_rec.status_id = 8 ) THEN
734 IF (p_new_task_status =1 OR (p_new_task_status = 2 AND p_task_rec.task_type_id <> 2 ))THEN
735 p_output_task_rec.status_id := p_new_task_status;
736 ELSE
737 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
738 fnd_msg_pub.ADD;
739 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
740 l_msg := 'Unreleased task can be moved only to Pending or Queued state';
741 IF(l_debug = 1) THEN
745 p_output_task_rec.ERROR := l_err_msg;
742 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
743 END IF;
744 p_output_task_rec.RESULT := 'E';
746 RETURN;
747 END IF;
748 ELSIF (p_task_rec.status_id = 1 ) THEN
749 IF ( p_new_task_status = 2 AND p_task_rec.task_type_id <> 2 )THEN
750 p_output_task_rec.status_id := p_new_task_status;
751 ELSE
752 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
753 fnd_msg_pub.ADD;
754 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
755 l_msg := 'Pending task can be moved only to Queued state';
756 IF(l_debug = 1) THEN
757 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
758 END IF;
759 p_output_task_rec.RESULT := 'E';
760 p_output_task_rec.ERROR := l_err_msg;
761 RETURN;
762 END IF;
763 ELSE
764 fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
765 fnd_msg_pub.ADD;
766 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
767 l_msg := 'Invalid task status';
768 IF(l_debug = 1) THEN
769 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
770 END IF;
771 p_output_task_rec.RESULT := 'E';
772 p_output_task_rec.ERROR := l_err_msg;
773 RETURN;
774 END IF;
775
776 END IF;
777
778 IF (P_new_task_priority IS NOT NULL) THEN
779 IF (p_task_rec.task_type_id <> 2) THEN
780 p_output_task_rec.priority := p_new_task_priority;
781 ELSE
782 fnd_message.set_name('WMS', 'WMS_INVALID_TASK');
783 fnd_msg_pub.ADD;
784 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
785 l_msg := 'Inbound task priority cannot be updated';
786 IF(l_debug = 1) THEN
787 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
788 END IF;
789 p_output_task_rec.RESULT := 'E';
790 p_output_task_rec.ERROR := l_err_msg;
791 RETURN;
792 END IF;
793 END IF;
794
795 IF (P_new_carton_lpn_id IS NOT NULL) THEN
796 SELECT license_plate_number
797 INTO l_lpn
798 FROM wms_license_plate_numbers
799 WHERE lpn_id =P_new_carton_lpn_id;
800 p_output_task_rec.cartonization_lpn := l_lpn;
801 p_output_task_rec.cartonization_id := P_new_carton_lpn_id;
802 END IF;
803 IF (P_new_task_type IS NOT NULL) THEN
804 OPEN c_usr_task_type(p_task_rec.task_type_id,p_new_task_type,p_task_rec.organization_id);
805 FETCH c_usr_task_type INTO l_usr_task_type_id;
806 IF c_usr_task_type%NOTFOUND THEN
807 fnd_message.set_name('WMS', 'WMS_INVALID_USER_TASK');--new message
808 fnd_msg_pub.ADD;
809 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
810 l_msg := 'Standard task type associated with the user task is different from the current standard task type';
811 IF(l_debug = 1) THEN
812 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
813 END IF;
814 p_output_task_rec.RESULT := 'E';
815 p_output_task_rec.ERROR := l_err_msg;
816 RETURN;
817 ELSE
818 p_output_task_rec.user_task_type_id := l_usr_task_type_id;
819 END IF;
820 CLOSE c_usr_task_type;
821 END IF;
822 IF (p_new_operation_plan_id IS NOT NULL) THEN
823 IF (p_op_plan_rec.organization_id IS NOT NULL) THEN
824 IF (p_task_rec.organization_id <> p_op_plan_rec.organization_id) THEN
825 IF(p_op_plan_rec.common_to_all_org <> 'Y') THEN
826 fnd_message.set_name('WMS', 'WMS_OPER_PLAN_ORG_INVALID');--new message
827 fnd_msg_pub.ADD;
828 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
829 p_output_task_rec.RESULT := 'E';
830 p_output_task_rec.ERROR := l_err_msg;
831 l_msg := 'Organization associated with the operation plan is different from that of the task';
832 IF(l_debug = 1) THEN
833 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
834 END IF;
835 RETURN;
836 END IF;
837 END IF;
838 END IF;
839
840 IF (p_task_rec.OPERATION_PLAN_ID IS NOT NULL AND p_op_plan_rec.plan_type_id IS NOT NULL) THEN
841 SELECT PLAN_TYPE_ID
842 INTO l_operation_plan_type_id
843 FROM wms_op_plans_b
844 WHERE OPERATION_PLAN_ID=p_task_rec.OPERATION_PLAN_ID;
848 like wise a standard operation plan can be replaced only with another Standard operation plan. */
845
846 IF (l_operation_plan_type_id IS NOT NULL ) THEN
847 /* An inspection operation plan can be replaced with another inspection operation plan and
849 /*only in case of cross dock tasks, a cross dock operation can be replaced with another cross dock operation plan or
850 it can also be replaced with a non-cross dock Operation plan */
851 IF ( l_operation_plan_type_id = 3 OR
852 ( p_op_plan_rec.plan_type_id = 1 AND l_operation_plan_type_id = 1) OR
853 ( p_op_plan_rec.plan_type_id = 2 AND l_operation_plan_type_id = 2 )) THEN
854 p_output_task_rec.operation_plan_id := p_new_operation_plan_id;
855 ELSE
856 fnd_message.set_name('WMS', 'WMS_OPERTN_PLAN_ID_INVALID');--new message
857 fnd_msg_pub.ADD;
858 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
859 p_output_task_rec.RESULT := 'E';
860 p_output_task_rec.ERROR := l_err_msg;
861 l_msg := 'Inspection/Standard operation plan can only be replaced with another Inspection/Standard operation plan
862 and cross dock operation can be replaced with another cross dock operation plan or non-cross dock Operation plan ';
863 IF(l_debug = 1) THEN
864 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
865 END IF;
866 RETURN;
867 END IF;
868 ELSE
869 fnd_message.set_name('WMS', 'WMS_OPERTN_PLAN_ID_INVALID');--new message
870 fnd_msg_pub.ADD;
871 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
872 p_output_task_rec.RESULT := 'E';
873 p_output_task_rec.ERROR := l_err_msg;
874 l_msg := 'Current or new operation plan type is NULL';
875 IF(l_debug = 1) THEN
876 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
877 END IF;
878 RETURN;
879 END IF;
880 END IF;
881
882
883 IF ( p_op_plan_rec.activity_type_id = 1) THEN --INBOUND CASE
884 IF(p_task_rec.task_type_id <> 2) THEN --putaway
885 fnd_message.set_name('WMS', 'WMS_INVALID_OP_PLAN_ACTIVITY');--new message
886 fnd_msg_pub.ADD;
887 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
888 p_output_task_rec.ERROR := l_err_msg;
889 p_output_task_rec.RESULT := 'E';
890 l_msg := 'Mismatch in the operation plan activity type and task type';
891 IF(l_debug = 1) THEN
892 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
893 END IF;
894 RETURN;
895 ELSE
896 --operation plan code changes start 6888354
897 BEGIN
898 SAVEPOINT inb_op_sp;
899 OPEN C_OP_OPERATIONS_STATUS(p_task_rec.transaction_number);
900 FETCH C_OP_OPERATIONS_STATUS
901 INTO l_op_operation_status_rec;
902 IF (l_op_operation_status_rec.STATUS=1) THEN
903 OPEN C_OP_PLANS_B(p_new_operation_plan_id);
904 FETCH C_OP_PLANS_B
905 INTO l_op_plan_b_rec;
906 IF (C_OP_PLANS_B%NOTFOUND) THEN
907 IF (l_debug=1) THEN
908 inv_trx_util_pub.trace('Records not found in WMS_OP_PLANS_B for given p_new_operation_plan_id');
909 fnd_message.set_name('WMS', ' WMS_INVALID_TASK');--new message
910 fnd_msg_pub.ADD;
911 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
912 l_msg := 'No of Records found in WMS_OP_PLANS_B for given operation plan id';
913 IF(l_debug = 1) THEN
914 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
915 END IF;
916 p_output_task_rec.RESULT := 'E';
917 p_output_task_rec.ERROR := l_err_msg;
918 RETURN;
919 END IF;
920 CLOSE C_OP_PLANS_B;
921 ELSE
922 inv_trx_util_pub.trace('updating wms_op_plan_instances.........');
923 UPDATE wms_op_plan_instances
924 SET OPERATION_PLAN_ID=l_op_plan_b_rec.OPERATION_PLAN_ID,
925 SYSTEM_TASK_TYPE =l_op_plan_b_rec.SYSTEM_TASK_TYPE ,
926 ACTIVITY_TYPE_ID =l_op_plan_b_rec.ACTIVITY_TYPE_ID ,
927 PLAN_TYPE_ID =l_op_plan_b_rec.PLAN_TYPE_ID
928 WHERE ((source_task_id IN
932 ))
929 (SELECT parent_line_id
930 FROM mtl_material_transactions_temp
931 WHERE transaction_temp_id=p_task_rec.transaction_number
933 OR (source_task_id = p_task_rec.transaction_number)); --update parent records only
934 OPEN c_plan_detail(p_new_operation_plan_id);
935 FETCH c_plan_detail
936 INTO l_operation_plan_detail_rec;
937 IF (c_plan_detail%NOTFOUND) THEN
938 IF (l_debug=1) THEN
939 inv_trx_util_pub.trace('Records not found in WMS_OP_PLAN_DETAILS for given operation plan id');
940 fnd_message.set_name('WMS', ' WMS_INVALID_TASK');--new message
941 fnd_msg_pub.ADD;
942 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
943 l_msg := 'No of Records found in WMS_OP_PLAN_DETAILS for given operation plan id';
944 IF(l_debug = 1) THEN
945 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
946 END IF;
947 p_output_task_rec.RESULT := 'E';
948 p_output_task_rec.ERROR := l_err_msg;
949 RETURN;
950 END IF;
951 CLOSE c_plan_detail;
952 ELSE
953 inv_trx_util_pub.trace('updating wms_op_operation_instances.........');
954 UPDATE wms_op_operation_instances
955 SET OPERATION_TYPE =l_operation_plan_detail_rec.OPERATION_TYPE ,
956 OPERATION_PLAN_DETAIL_ID=l_operation_plan_detail_rec.OPERATION_PLAN_DETAIL_ID ,
957 OPERATION_SEQUENCE =l_operation_plan_detail_rec.OPERATION_SEQUENCE ,
958 --ACTIVITY_TYPE=l_operation_plan_detail_rec.ACTIVITY_TYPE ,
959 IS_IN_INVENTORY =l_operation_plan_detail_rec.IS_IN_INVENTORY
960 WHERE ((source_task_id IN
961 (SELECT TRANSACTION_TEMP_ID
962 FROM mtl_material_transactions_temp
963 WHERE parent_line_id=p_task_rec.transaction_number
964 ))
965 OR ( source_task_id =p_task_rec.transaction_number));--update all the children records only
966 END IF;
967 END IF;
968
969 ELSE
970 fnd_message.set_name('WMS', ' WMS_INVALID_TASK');--new message
971 fnd_msg_pub.ADD;
972 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
973 l_msg := 'STATUS in wms_op_plan_instances is not pending';
974 IF(l_debug = 1) THEN
975 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
976 END IF;
977 p_output_task_rec.RESULT := 'E';
978 p_output_task_rec.ERROR := l_err_msg;
979 RETURN;
980 END IF; -- l_op_operation_status_rec.STATUS end
981
982 SELECT parent_line_id
983 INTO l_src_parent_id
984 FROM mtl_material_transactions_temp
985 WHERE TRANSACTION_TEMP_ID=p_task_rec.transaction_number;
986 IF (l_src_parent_id IS NULL) THEN
987 l_src_tran_id :=p_task_rec.transaction_number;
988 UPDATE mtl_material_transactions_temp mmtt
989 SET mmtt.OPERATION_PLAN_ID=p_new_operation_plan_id
990 WHERE mmtt.PARENT_LINE_ID = l_src_tran_id;--update child record
991 ELSE
992 l_src_tran_id:=l_src_parent_id;
993 UPDATE mtl_material_transactions_temp mmtt
994 SET mmtt.OPERATION_PLAN_ID =p_new_operation_plan_id
995 WHERE mmtt.TRANSACTION_TEMP_ID = l_src_tran_id;--update parent record
999 EXCEPTION
996 END IF; --parent if end
997 p_output_task_rec.operation_plan_id := p_new_operation_plan_id;
998
1000 WHEN OTHERS THEN
1001 ROLLBACK TO inb_op_sp;
1002 p_output_task_rec.RESULT := 'E';
1003 inv_trx_util_pub.trace('Exception Occured while updating operation plan');
1004 RETURN;
1005 END;
1006 --operation plan code changes end 6888354
1007
1008 END IF;
1009 ELSE --outbound case
1010 --for outbound case wopi , wooi is not impacted as I could observe by creating records.
1011 --just updating the plan id should be enough.needs to be investigated further
1012 IF (p_task_rec.task_type_id <> 1) THEN --if not a pick task then error out
1013 fnd_message.set_name('WMS', 'WMS_INVALID_OP_PLAN_ACTIVITY');--new message
1014 fnd_msg_pub.ADD;
1015 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_err_msg );
1016 l_msg := 'Mismatch in the operation plan activity type and task type';
1017 IF(l_debug = 1) THEN
1018 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
1019 END IF;
1020 p_output_task_rec.RESULT := 'E';
1021 p_output_task_rec.ERROR := l_err_msg;
1022 RETURN;
1023 ELSE --update the mmtt with new plan
1024 /*UPDATE mtl_material_transactions_temp
1025 SET operation_plan_id = p_new_operation_plan_id
1026 WHERE transaction_temp_id = p_task_rec.transaction_number;*/
1027 p_output_task_rec.operation_plan_id := p_new_operation_plan_id;
1028 END IF;
1029 END IF;
1030 END IF;
1031 EXCEPTION
1032 WHEN OTHERS THEN
1033 NULL;
1034 END modify_single_task;
1035
1036 -------------------------------------------------------------------------------------------------------------------
1037 /*This procedure is to create a dummy task table with only the task_idThis will be used if user gives the task_id as input.*/
1038 PROCEDURE Create_Task_Table ( p_transaction_number IN NUMBER DEFAULT NULL ,
1039 x_task_table OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type )IS
1040
1041 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
1042 l_task_rec WMS_TASK_MGMT_PUB.task_output_rectype;
1043 BEGIN
1044 l_task_rec.TRANSACTION_NUMBER := p_transaction_number;
1045 l_task_table(1) := l_task_rec ;
1046 x_task_table := l_task_table;
1047 END Create_Task_Table ;
1048 -------------------------------------------------------------------------------------------------------------------
1049
1050 /*This procedure will validate one task at a a time.*/
1051 PROCEDURE validate_task_id ( p_init_msg_list IN VARCHAR2 DEFAULT 'Y' ,
1052 p_transaction_number IN NUMBER DEFAULT NULL ,
1053 p_action IN VARCHAR2 DEFAULT NULL, --6850212
1054 x_validation_status OUT NOCOPY VARCHAR2 ,
1055 x_error_msg OUT NOCOPY VARCHAR2 ,
1056 x_return_status OUT NOCOPY VARCHAR2 )IS
1057
1058 l_wdt_status NUMBER := 0 ;
1059 l_task_exists NUMBER := 0;
1060 l_msg_count NUMBER ;
1061 l_task_type NUMBER ;
1062 l_parent_line_id NUMBER := 0 ;
1063 BEGIN
1064 --initialize output variables.
1065 x_validation_status := 'S';
1066 x_return_status := 'S';
1067 x_error_msg := NULL;
1068 --Initialize message pub
1069 IF p_init_msg_list ='Y' THEN
1070 fnd_msg_pub.initialize;
1071 END IF;
1072 BEGIN
1073 --Make sure there is a task with this Id
1074 SELECT 1 ,
1075 mmtt.wms_task_type ,
1076 parent_line_id
1077 INTO l_task_exists ,
1078 l_task_type ,
1079 l_parent_line_id
1080 FROM MTL_MATERIAL_TRANSACTIONS_TEMP mmtt
1081 WHERE mmtt.transaction_temp_id=p_transaction_number;
1082 EXCEPTION
1083 WHEN NO_DATA_FOUND THEN
1084 null;
1085 WHEN OTHERS THEN
1086 x_return_status := 'E';
1087 END ;
1088 IF (l_task_exists = 0 ) THEN
1089 --Checkif it is a cycle count task
1090 SELECT count(1)
1091 INTO l_task_exists
1092 FROM Mtl_Cycle_Count_Entries mcce
1093 WHERE mcce.cycle_count_entry_id = p_transaction_number
1094 AND mcce.entry_status_code IN( 1 , 3) ;
1095 l_task_type := 3 ; --cycle count.
1096 END IF ;
1097 IF (l_task_exists = 0 ) THEN
1098 --Still no task, this is invalid id.
1099 fnd_message.set_name('WMS', 'INVALID_TASK');
1100 fnd_msg_pub.ADD;
1101 x_validation_status:= 'E';
1102 END IF;
1103 --Need to check status in WDT .
1104 BEGIN
1105 SELECT wdt.status
1106 INTO l_wdt_status
1107 FROM Wms_Dispatched_Tasks wdt
1111 --No WDT, so task must bein status pending/unreleased.
1108 WHERE wdt.transaction_temp_id = p_transaction_number ;
1109 EXCEPTION
1110 WHEN NO_DATA_FOUND THEN
1112 l_wdt_status := 0 ;
1113 WHEN OTHERS THEN
1114 x_return_status := 'E';
1115 END;
1116 IF (l_wdt_status = 0 AND l_task_type= 2 ) THEN --Only for putaway tasks.
1117 SELECT MAX(wdt.status )
1118 INTO l_wdt_status
1119 FROM Wms_Dispatched_Tasks wdt
1120 WHERE wdt.transaction_temp_id in
1121 (SELECT transaction_temp_id --To check the child tasks
1122 FROM MTL_MATERIAL_TRANSACTIONS_TEMP mmtt
1123 WHERE mmtt.parent_line_id = p_transaction_number
1124 UNION SELECT mmtt2.transaction_temp_id --To check the siblings
1125 FROM MTL_MATERIAL_TRANSACTIONS_TEMP mmtt1 ,
1126 MTL_MATERIAL_TRANSACTIONS_TEMP mmtt2
1127 WHERE mmtt1.transaction_temp_id = p_transaction_number
1128 AND mmtt2.parent_line_id = mmtt1.parent_line_id
1129 UNION SELECT mmtt2.transaction_temp_id ---To check the parent task.
1130 FROM MTL_MATERIAL_TRANSACTIONS_TEMP mmtt1 ,
1131 MTL_MATERIAL_TRANSACTIONS_TEMP mmtt2
1132 WHERE mmtt1.transaction_temp_id = p_transaction_number
1133 AND mmtt2.transaction_temp_id = mmtt1.parent_line_id
1134 ) ;
1135 END IF;
1136 IF ( l_parent_line_id > 0 AND l_task_type = 1 ) THEN --This is nbulk pick
1137 IF (l_parent_line_id <> p_transaction_number ) THEN
1138 --The input is a child of bulk task.Fail validation.
1139 fnd_message.set_name('WMS', 'INVALID_TASK');
1140 fnd_msg_pub.ADD;
1141 x_validation_status:= 'E';
1142 END IF;
1143 END IF;
1144 -- 6850212 Start
1145 IF p_action = 'MODIFY' THEN
1146 IF (l_wdt_status NOT IN (0,2,3,9)) THEN
1147 --fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
1148 --fnd_msg_pub.ADD;
1149 x_validation_status:= 'E';
1150 END IF;
1151 ELSE
1152 IF( l_wdt_status NOT IN (0,2) ) THEN
1153 --fnd_message.set_name('WMS', 'WMS_ATF_INVALID_TASK_STATUS');
1154 --fnd_msg_pub.ADD;
1155 x_validation_status:= 'E';
1156 END IF;
1157 END IF;
1158 -- 6850212 End
1159 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1160 EXCEPTION
1161 WHEN OTHERS THEN
1162 x_return_status := 'E';
1163 END validate_task_id ;
1164 -------------------------------------------------------------------------------------------------------------------
1165
1166 /*Main procedure for task validation. */
1167 PROCEDURE validate_tasks ( p_init_msg_list IN VARCHAR2 DEFAULT 'Y' ,
1168 p_transaction_number IN NUMBER DEFAULT NULL ,
1169 p_task_table IN WMS_TASK_MGMT_PUB.task_tab_type ,
1170 p_action IN VARCHAR2 DEFAULT NULL, --6850212
1171 x_wms_task OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type ,
1172 x_return_status OUT NOCOPY VARCHAR2 ) IS
1173
1174 l_validate_task_ret VARCHAR2(1) ;
1175 l_error_msg VARCHAR2(240);
1176 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
1177 BEGIN
1178 x_return_status := 'S';
1179 IF ( p_transaction_number IS NOT NULL ) THEN
1180 Create_Task_Table (p_transaction_number => p_transaction_number, --create a dummy table
1181 x_task_table => l_task_table );
1182 ELSE
1183 l_task_table := p_task_table ;
1184 END IF;
1185 FOR i IN 1..l_task_table.count
1186 LOOP --Validate each task record individually.
1187 validate_task_id ( p_transaction_number => l_task_table(i).TRANSACTION_NUMBER,
1188 x_validation_status => l_validate_task_ret ,
1189 p_action=>p_action,--6850212
1190 x_error_msg => l_error_msg ,
1191 x_return_status => x_return_status );
1192 IF (l_validate_task_ret ='E' ) THEN
1193 l_task_table(i).result := 'E';
1194 l_task_table(i).error := l_error_msg;
1195 END IF;
1196 END LOOP;
1197 x_wms_task := l_task_table;
1198 EXCEPTION
1199 WHEN OTHERS THEN
1200 x_return_status := 'E';
1201 END validate_tasks ;
1202 ---------------------------------------------------------------------------------------------------------
1203
1204 /*This procedure checks if cartonization can be done on the taks.
1205 If the API returns success, then carton_lpn_id can be stamped on the tasks*/
1206 /*PROCEDURE check_cartonization ( p_task_table IN WMS_TASK_MGMT_PUB.task_tab_type ,
1207 p_new_carton_lpn_id IN NUMBER DEFAULT NULL ,
1208 x_error_msg OUT NOCOPY VARCHAR2 ,
1209 x_return_status OUT NOCOPY VARCHAR2 ) IS
1210
1211 CURSOR carton_lpn_csr(c_lpn_id NUMBER)
1212 IS
1213 SELECT lpn_context,
1214 organization_id
1215 FROM wms_license_plate_numbers wlpn
1216 WHERE wlpn.lpn_id=c_lpn_id;
1217 CURSOR carton_lpn_del_det (c_lpn_id NUMBER)
1218 IS
1219 SELECT wdd.delivery_detail_id,
1220 wdd.move_order_line_id
1221 FROM wsh_delivery_details wdd,
1222 mtl_material_transactions_temp mmtt
1223 WHERE wdd.move_order_line_id=mmtt.move_order_line_id
1224 AND wdd.organization_id =mmtt.organization_id
1225 AND mmtt.transfer_lpn_id =c_lpn_id
1229 SELECT wdd.delivery_detail_id,
1226 AND ROWNUM < 2;
1227 CURSOR carton_lpn_del_det1 (c_lpn_id NUMBER)
1228 IS
1230 wdd.move_order_line_id
1231 FROM wsh_delivery_details wdd,
1232 mtl_material_transactions_temp mmtt
1233 WHERE wdd.move_order_line_id=mmtt.move_order_line_id
1234 AND wdd.organization_id =mmtt.organization_id
1235 AND mmtt.cartonization_id = c_lpn_id
1236 AND ROWNUM = 1;
1237 CURSOR c_get_delivery_id(p_delivery_detail_id NUMBER)
1238 IS
1239 SELECT delivery_id
1240 FROM wsh_delivery_assignments
1241 WHERE delivery_detail_id = p_delivery_detail_id;
1242 CURSOR c_bulk_task(p_transaction_number NUMBER)
1243 IS
1244 SELECT '1'
1245 FROM mtl_material_transactions_temp
1246 WHERE parent_line_id = p_transaction_number
1247 AND rownum = 1;
1248 l_carton_lpn_ctx NUMBER;
1249 l_carton_lpn_org NUMBER;
1250 l_carton_del_det_id NUMBER;
1251 l_carton_del_id NUMBER;
1252 l_carton_move_order_line_id NUMBER;
1253 l_temp_carton_grp_id NUMBER;
1254 l_carton_grp_id_tab WSH_UTIL_CORE.id_tab_type;
1255 l_del_det_id_tab WSH_UTIL_CORE.id_tab_type;
1256 l_del_id_tab WSH_UTIL_CORE.id_tab_type;
1257 l_move_order_line_id_tab WSH_UTIL_CORE.id_tab_type;
1258 l_bulk_task VARCHAR2(2);
1259 l_temp_del_detail_id NUMBER;
1260 l_move_order_line_id NUMBER;
1261 l_temp_del_id NUMBER;
1262 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1263 l_api_name VARCHAR2(1000) := 'CHECK_CARTONIZATION';
1264 l_error_msg VARCHAR2(2000);
1265 l_msg_count NUMBER;
1266 BEGIN
1267 x_return_status := fnd_api.g_ret_sts_success;
1268 OPEN carton_lpn_csr(p_new_carton_lpn_id);
1269 FETCH carton_lpn_csr INTO l_carton_lpn_ctx,l_carton_lpn_org;
1270 CLOSE carton_lpn_csr;
1271 --if carton lpn is passed and is not valid then no need to proceed further
1272 IF(l_carton_lpn_ctx NOT IN (5,8)) THEN
1273 x_return_status := fnd_api.g_ret_sts_error;
1274 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1275 fnd_msg_pub.ADD;
1276 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1277 l_error_msg :='Invalid context for Carton LPN:'||p_new_carton_lpn_id;
1278 IF(l_debug = 1) THEN
1279 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1280 END IF;
1281 RETURN;
1282 END IF;
1283 IF (l_carton_lpn_ctx = 5 ) THEN
1284 OPEN carton_lpn_del_det1(p_new_carton_lpn_id);
1285 FETCH carton_lpn_del_det1
1286 INTO l_carton_del_det_id,
1287 l_carton_move_order_line_id;
1288 CLOSE carton_lpn_del_det1;
1289 IF (l_carton_del_det_id is NOT NULL and l_carton_move_order_line_id is NOT NULL) THEN
1290 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_carton_del_det_id;
1291 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_carton_move_order_line_id;
1292 END IF;
1293 END IF;
1294 IF (l_carton_lpn_ctx = 8 ) THEN
1295 --get carton del_det_id and mover_oder_line_id
1296 OPEN carton_lpn_del_det(p_new_carton_lpn_id);
1297 FETCH carton_lpn_del_det INTO l_carton_del_det_id,l_carton_move_order_line_id;
1298 CLOSE carton_lpn_del_det;
1299 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_carton_del_det_id;
1300 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_carton_move_order_line_id;
1301 END IF;
1302 FOR i IN 1..p_task_table.count
1303 LOOP
1304 IF (p_task_table(i).organization_id <> l_carton_lpn_org) THEN
1305 x_return_status := fnd_api.g_ret_sts_error;
1306 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1307 fnd_msg_pub.ADD;
1308 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1309 l_error_msg :='Organization is not same for Carton LPN and Task';
1310 IF(l_debug = 1) THEN
1311 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1312 END IF;
1313 RETURN;
1314 END IF;
1315 --Bulk tasks cannot be cartonized
1316 OPEN c_bulk_task(p_task_table(i).transaction_number);
1317 FETCH c_bulk_task INTO l_bulk_task;
1318 IF c_bulk_task%NOTFOUND THEN
1319 CLOSE c_bulk_task;
1320 ELSE
1321 x_return_status := fnd_api.g_ret_sts_error;
1322 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1323 fnd_msg_pub.ADD;
1324 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1325 l_error_msg :='Bulk Tasks cannot be cartonized';
1326 IF(l_debug = 1) THEN
1327 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1328 END IF;
1332 END LOOP;
1329 CLOSE c_bulk_task;
1330 RETURN;
1331 END IF;
1333 --Fetch the delivery_detail_id's and move order line id's associated with the input task/tasks.
1334 FOR i IN 1..p_task_table.count
1335 LOOP
1336 BEGIN
1337 SELECT wdd.delivery_detail_id,
1338 wdd.move_order_line_id
1339 INTO l_temp_del_detail_id,
1340 l_move_order_line_id
1341 FROM wsh_delivery_details wdd,
1342 mtl_material_transactions_temp mmtt
1343 WHERE wdd.move_order_line_id = mmtt.move_order_line_id
1344 AND mmtt.transaction_temp_id = p_task_table(i).transaction_number;
1345 EXCEPTION
1346 WHEN OTHERS THEN
1347 l_temp_del_detail_id := NULL;
1348 END;
1349 IF (l_temp_del_detail_id IS NULL) THEN
1350 x_return_status := fnd_api.g_ret_sts_error;
1351 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1352 fnd_msg_pub.ADD;
1353 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1354 l_error_msg :='Data not present in WDD for the corresponding task :'||p_task_table(i).transaction_number;
1355 IF(l_debug = 1) THEN
1356 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1357 END IF;
1358 RETURN;
1359 ELSE
1360 l_del_det_id_tab(l_del_det_id_tab.count +1) := l_temp_del_detail_id;
1361 l_move_order_line_id_tab(l_move_order_line_id_tab.count+1) := l_move_order_line_id;
1362 END IF;
1363 END LOOP;
1364 --Fetch the delivery_id associated with the tasks.
1365 FOR i IN 1..l_del_det_id_tab.COUNT
1366 LOOP
1367 BEGIN
1368 SELECT delivery_id
1369 INTO l_temp_del_id
1370 FROM wsh_delivery_assignments
1371 WHERE delivery_detail_id = l_del_det_id_tab(i);
1372 EXCEPTION
1373 WHEN OTHERS THEN
1374 l_temp_del_id := NULL;
1375 END;
1376 l_del_id_tab(l_del_id_tab.count +1) := l_temp_del_id;
1377 END LOOP;
1378 --Need to check if all the deliveries are same or not.
1379 --This needs to be done only if count of delivery_detail_id is >1.
1380 IF l_del_det_id_tab.COUNT > 1 THEN
1381 FOR i IN 1..l_del_id_tab.COUNT
1382 LOOP
1383 IF nvl(l_del_id_tab(1),-999) <> nvl(l_del_id_tab(i),-999) THEN
1384 x_return_status := fnd_api.g_ret_sts_error;
1385 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1386 fnd_msg_pub.ADD;
1387 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1388 l_error_msg :='Delivery mismatch,cartonization cannot be done';
1389 IF(l_debug = 1) THEN
1390 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1391 END IF;
1392 RETURN;
1393 END IF;
1394 END LOOP;
1395 END IF;
1396 --If delivery_id is null, then check for the carton_group_id
1397 --See if the delivery_id is null on the first record
1398 --If it is null, then it will be null on all the rest as per the above validation.
1399 IF ((l_del_id_tab(1) is NULL) AND (l_del_det_id_tab.COUNT > 1))THEN
1400 FOR i IN 1..l_move_order_line_id_tab.COUNT
1401 LOOP
1402 BEGIN
1403 SELECT mtrl.carton_grouping_id
1404 INTO l_temp_carton_grp_id
1405 FROM mtl_txn_request_lines mtrl
1406 WHERE line_id = l_move_order_line_id_tab(i);
1407 EXCEPTION
1408 WHEN OTHERS THEN
1409 l_temp_carton_grp_id := NULL;
1410 END;
1411 l_carton_grp_id_tab(l_carton_grp_id_tab.count+1) := l_temp_carton_grp_id;
1412 END LOOP;
1413 FOR i IN 1..l_carton_grp_id_tab.COUNT
1414 LOOP
1415 IF nvl(l_carton_grp_id_tab(1),-999) <> nvl(l_carton_grp_id_tab(i),-999) THEN
1416 x_return_status := fnd_api.g_ret_sts_error;
1417 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERR');
1418 fnd_msg_pub.ADD;
1419 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => x_error_msg );
1420 l_error_msg :='Carton group mismatch,cartonization cannot be done';
1421 IF(l_debug = 1) THEN
1422 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
1423 END IF;
1424 RETURN;
1425 END IF;
1426 END LOOP;
1427 END IF;
1428 END check_cartonization;*/
1429
1433 PROCEDURE print_msg(p_procedure IN VARCHAR2 ,
1430 -------------------------------------------------------------------------------------------------------------------
1431
1432 --START OF SPLIT TASK
1434 p_msg IN VARCHAR2) IS
1435
1436 BEGIN
1437 inv_log_util.trace(p_msg ,g_pkg_name || '.' || p_procedure || ': ' ,9);
1438 -- dbms_output.put_line(p_procedure||' : ' || p_msg);
1439 END print_msg;
1440
1441 -------------------------------------------------------------------------------------------------------------------
1442 /*PROCEDURE validate_quantities()
1443 This procedure performs all quantity and UOM validations based on the inputs in form of tasks and
1444 split quantity table passed
1445 */
1446 -------------------------------------------------------------------------------------------------------------------
1447 PROCEDURE validate_quantities( p_transaction_temp_id IN NUMBER ,
1448 p_split_quantities IN task_qty_tbl_type ,
1449 x_lot_control_code OUT NOCOPY NUMBER ,
1450 x_serial_control_code OUT NOCOPY NUMBER ,
1451 x_split_uom_quantities OUT NOCOPY qty_changed_tbl_type ,
1452 x_return_status OUT NOCOPY VARCHAR2 ,
1453 x_msg_data OUT NOCOPY VARCHAR2 ,
1454 x_msg_count OUT NOCOPY VARCHAR2 ) IS
1455
1456 l_mmtt_inventory_item_id NUMBER;
1457 l_mmtt_primary_quantity NUMBER;
1458 l_mmtt_transaction_quantity NUMBER;
1459 l_mmtt_transaction_uom_code NUMBER;
1460 l_mmtt_organization_id NUMBER;
1461 l_mmtt_transaction_uom VARCHAR2(3);
1462 l_mmtt_item_primary_uom_code VARCHAR2(3);
1463 l_lot_control_code NUMBER;
1464 l_serial_control_code NUMBER;
1465 l_decimal_precision CONSTANT NUMBER := 5;
1466 l_mtlt_transaction_qty NUMBER := 0;
1467 l_msnt_transaction_qty NUMBER := 0;
1468 l_task_tbl_transaction_qty NUMBER := 0;
1469 l_procedure_name VARCHAR2(20) := 'VALIDATE_QUANTITIES';
1470 l_task_tbl_primary_qty NUMBER := 0;
1471 l_sum_tbl_transaction_qty NUMBER := 0;
1472 l_sum_tbl_primary_qty NUMBER := 0;
1473 l_remaining_primary_qty NUMBER := 0;
1474 l_remaining_transaction_qty NUMBER := 0;
1475 BEGIN
1476 x_return_status := 'E';
1477 IF g_debug = 1 THEN
1478 print_msg(l_procedure_name, 'Entered');
1479 END IF;
1480 IF p_split_quantities.COUNT = 0 THEN
1481 x_return_status := 'E';
1482 IF g_debug = 1 THEN
1483 print_msg(l_procedure_name, 'Quantities table is empty, exiting');
1484 END IF;
1485 RETURN;
1486 END IF;
1487 SELECT transaction_uom ,
1488 inventory_item_id ,
1489 primary_quantity ,
1490 transaction_quantity ,
1491 item_primary_uom_code ,
1492 transaction_uom ,
1493 organization_id
1494 INTO l_mmtt_transaction_uom ,
1495 l_mmtt_inventory_item_id ,
1496 l_mmtt_primary_quantity ,
1497 l_mmtt_transaction_quantity ,
1498 l_mmtt_item_primary_uom_code ,
1499 l_mmtt_transaction_uom ,
1500 l_mmtt_organization_id
1501 FROM mtl_material_transactions_temp
1502 WHERE transaction_temp_id = p_transaction_temp_id;
1503 SELECT lot_control_code ,
1504 serial_number_control_code
1505 INTO l_lot_control_code ,
1506 l_serial_control_code
1507 FROM mtl_system_items_b
1508 WHERE inventory_item_id = l_mmtt_inventory_item_id
1509 AND organization_id = l_mmtt_organization_id;
1510 x_lot_control_code := l_lot_control_code;
1511 x_serial_control_code := l_serial_control_code;
1512 IF g_debug = 1 THEN
1513 FOR i IN p_split_quantities.FIRST .. p_split_quantities.LAST
1514 LOOP
1515 print_msg(l_procedure_name , ' Inside For loop i = ' || i ||
1516 ' Task :' || p_transaction_temp_id ||
1517 ' Quantity : ' ||p_split_quantities(i).quantity ||
1518 ' Suggested UOM :' ||p_split_quantities(i).uom ||
1519 ' MMTT transaction UOM :' ||l_mmtt_transaction_uom);
1520 END LOOP;
1521 END IF;
1522 FOR i IN p_split_quantities.FIRST .. p_split_quantities.LAST
1523 LOOP
1524 IF p_split_quantities(i).uom IS NULL THEN
1525 IF g_debug = 1 THEN
1526 print_msg(l_procedure_name , 'UOM cannot be passed as NULL');
1527 END IF;
1528 x_return_status := 'E';
1529 RETURN;
1530 END IF;
1531 IF RTRIM(LTRIM(p_split_quantities(i).uom)) NOT IN (l_mmtt_item_primary_uom_code,l_mmtt_transaction_uom) THEN
1532 x_return_status := 'E';
1533 IF g_debug = 1 THEN
1534 print_msg(l_procedure_name , 'UOM validation failed, only primary or transaction UOM allowed :');
1535 END IF;
1536 RETURN;
1537 END IF;
1538 -- All UOMs are same
1539 IF l_mmtt_transaction_uom = l_mmtt_item_primary_uom_code THEN
1540 x_split_uom_quantities(i).primary_quantity := p_split_quantities(i).quantity;
1541 x_split_uom_quantities(i).transaction_quantity := p_split_quantities(i).quantity;
1542 ELSE
1546 END IF;
1543 IF l_mmtt_transaction_uom = p_split_quantities(i).uom THEN
1544 IF g_debug = 1 THEN
1545 print_msg(l_procedure_name , ' mmtt transaction UOM is same as UOM in quantity table');
1547 l_task_tbl_transaction_qty := p_split_quantities(i).quantity;
1548 x_split_uom_quantities(i).transaction_quantity := p_split_quantities(i).quantity;
1549 ELSE
1550 IF g_debug = 1 THEN
1551 print_msg(l_procedure_name , ' mmtt transaction UOM quantity table UOM are not same, calling inv_convert.inv_um_convert with :');
1552 print_msg(l_procedure_name, ' item_id : '||l_mmtt_inventory_item_id);
1553 print_msg(l_procedure_name, ' PRECISION : '|| l_decimal_precision);
1554 print_msg(l_procedure_name, ' from_quantity :'|| p_split_quantities(i).quantity);
1555 print_msg(l_procedure_name, ' from_unit :'||p_split_quantities(i).uom);
1556 print_msg(l_procedure_name, ' to_unit :'||l_mmtt_transaction_uom);
1557 END IF;
1558 l_task_tbl_transaction_qty := inv_convert.inv_um_convert( item_id => l_mmtt_inventory_item_id ,
1559 PRECISION => l_decimal_precision ,
1560 from_quantity => p_split_quantities(i).quantity ,
1561 from_unit => p_split_quantities(i).uom ,
1562 to_unit => l_mmtt_transaction_uom ,
1563 from_name => NULL ,
1564 to_name => NULL );
1565 IF l_task_tbl_transaction_qty = -9999 THEN
1566 IF g_debug = 1 THEN
1567 print_msg(l_procedure_name, ' No conversion defined from :'||p_split_quantities(i).uom|| ' to :'|| l_mmtt_transaction_uom || ' , or UOM does not exist.');
1568 END IF;
1569 x_return_status := 'E';
1570 RETURN;
1571 END IF;
1572 x_split_uom_quantities(i).transaction_quantity := l_task_tbl_transaction_qty;
1573 END IF;
1574 IF l_mmtt_item_primary_uom_code = p_split_quantities(i).uom THEN
1575 IF g_debug = 1 THEN
1576 print_msg(l_procedure_name , ' primary UOM is same as UOM in quantity table');
1577 END IF;
1578 l_task_tbl_primary_qty := p_split_quantities(i).quantity;
1579 x_split_uom_quantities(i).primary_quantity := p_split_quantities(i).quantity;
1580 ELSE
1581 IF g_debug = 1 THEN
1582 print_msg(l_procedure_name , ' primary UOM not same as UOM in quantity table');
1583 print_msg(l_procedure_name, ' For primary quantity ');
1584 print_msg(l_procedure_name, ' item_id : '||l_mmtt_inventory_item_id);
1585 print_msg(l_procedure_name, ' PRECISION : '|| l_decimal_precision);
1586 print_msg(l_procedure_name, ' from_quantity :'|| p_split_quantities(i).quantity);
1587 print_msg(l_procedure_name, ' from_unit :'||p_split_quantities(i).uom);
1588 print_msg(l_procedure_name, ' to_unit :'||l_mmtt_transaction_uom);
1589 END IF;
1590 l_task_tbl_primary_qty := inv_convert.inv_um_convert(item_id => l_mmtt_inventory_item_id ,
1591 PRECISION => l_decimal_precision ,
1592 from_quantity => p_split_quantities(i).quantity ,
1593 from_unit => p_split_quantities(i).uom ,
1594 to_unit => l_mmtt_item_primary_uom_code ,
1595 from_name => NULL ,
1596 to_name => NULL);
1597 IF l_task_tbl_transaction_qty = -9999 THEN
1598 IF g_debug = 1 THEN
1599 print_msg(l_procedure_name, ' No conversion defined from :'||
1600 p_split_quantities(i).uom|| ' to :'||
1601 l_mmtt_transaction_uom || ' , or UOM does not exist.');
1602 END IF;
1603 x_return_status := 'E';
1604 RETURN;
1605 END IF;
1606 x_split_uom_quantities(i).primary_quantity := l_task_tbl_primary_qty;
1607 END IF;
1608 END IF;
1609 IF x_split_uom_quantities(i).transaction_quantity <= 0 OR x_split_uom_quantities(i).primary_quantity <= 0 THEN
1610 IF g_debug = 1 THEN
1611 print_msg(l_procedure_name ,'Negative and zero quantities are not allowed in quantities table, exiting.');
1612 END IF;
1613 x_return_status := 'E';
1614 RETURN;
1615 END IF;
1616 l_sum_tbl_transaction_qty := l_sum_tbl_transaction_qty + x_split_uom_quantities(i).transaction_quantity;
1617 l_sum_tbl_primary_qty := l_sum_tbl_primary_qty + x_split_uom_quantities(i).primary_quantity;
1618 END LOOP;
1619 IF g_debug = 1 THEN
1620 print_msg(l_procedure_name , 'l_sum_tbl_transaction_qty : '||l_sum_tbl_transaction_qty);
1621 print_msg(l_procedure_name , 'l_sum_tbl_primary_qty : '||l_sum_tbl_primary_qty);
1622 END IF;
1626 END IF;
1623 IF l_sum_tbl_transaction_qty >= l_mmtt_transaction_quantity THEN
1624 IF g_debug = 1 THEN
1625 print_msg(l_procedure_name ,'Sum of qty table :'|| l_sum_tbl_transaction_qty || 'should be less than the mmtt line quantity:'||l_mmtt_transaction_quantity );
1627 x_return_status := 'E';
1628 RETURN;
1629 END IF;
1630 --Validate lot/serial quantity
1631 IF g_debug = 1 THEN
1632 print_msg(l_procedure_name ,'Validating lot/serial if allocations are present');
1633 print_msg(l_procedure_name , 'lot_control_code : '|| l_lot_control_code);
1634 print_msg(l_procedure_name , 'serial_control_code : '|| l_serial_control_code);
1635 END IF;
1636 IF l_lot_control_code = 2 AND l_serial_control_code IN (2,5) THEN
1637 BEGIN
1638 --Lot quantity
1639 SELECT sum(transaction_quantity)
1640 INTO l_mtlt_transaction_qty
1641 FROM mtl_transaction_lots_temp
1642 WHERE transaction_temp_id = p_transaction_temp_id;
1643 IF g_debug = 1 THEN
1644 print_msg(l_procedure_name , 'l_mtlt_transaction_qty : '||l_mtlt_transaction_qty|| ' l_mmtt_transaction_quantity : '||l_mmtt_transaction_quantity);
1645 END IF;
1646 IF l_mtlt_transaction_qty <> l_mmtt_transaction_quantity THEN
1647 x_return_status := 'E';
1648 IF g_debug = 1 THEN
1649 print_msg(l_procedure_name ,'Mismatch in MMTT and MTLT quantity');
1650 END IF;
1651 RETURN;
1652 END IF;
1653 EXCEPTION
1654 WHEN NO_DATA_FOUND THEN
1655 x_return_status := 'E';
1656 IF g_debug = 1 THEN
1657 print_msg(l_procedure_name ,'No Data Found : Mismatch in MMTT and MTLT quantity');
1658 END IF;
1659 RETURN;
1660 END;
1661 BEGIN
1662 --serial quantity
1663 SELECT sum(1)
1664 INTO l_msnt_transaction_qty
1665 FROM mtl_serial_numbers_temp
1666 WHERE transaction_temp_id IN
1667 (SELECT serial_transaction_temp_id
1668 FROM mtl_transaction_lots_temp
1669 WHERE transaction_temp_id = p_transaction_temp_id
1670 );
1671 IF l_msnt_transaction_qty <> l_mmtt_transaction_quantity THEN
1672 x_return_status := 'E';
1673 IF g_debug = 1 THEN
1674 print_msg(l_procedure_name ,'Mismatch in MMTT and MSNT quantity');
1675 END IF;
1676 RETURN;
1677 END IF;
1678 EXCEPTION
1679 WHEN NO_DATA_FOUND THEN
1680 x_return_status := 'E';
1681 IF g_debug = 1 THEN
1682 print_msg(l_procedure_name ,'No Data Found :Mismatch in MMTT and MSNT quantity');
1683 END IF;
1684 RETURN;
1685 END;
1686 ELSIF l_lot_control_code = 2 AND l_serial_control_code NOT IN (2,5) THEN
1687 BEGIN
1688 --Lot quantity
1689 SELECT sum(transaction_quantity)
1690 INTO l_mtlt_transaction_qty
1691 FROM mtl_transaction_lots_temp
1692 WHERE transaction_temp_id = p_transaction_temp_id;
1693 IF l_mtlt_transaction_qty <> l_mmtt_transaction_quantity THEN
1694 x_return_status := 'E';
1695 IF g_debug = 1 THEN
1696 print_msg(l_procedure_name ,'Mismatch in MMTT and MTLT quantity');
1697 END IF;
1698 RETURN;
1699 END IF;
1700 EXCEPTION
1701 WHEN NO_DATA_FOUND THEN
1702 x_return_status := 'E';
1703 IF g_debug = 1 THEN
1704 print_msg(l_procedure_name ,'No Data Found :Mismatch in MMTT and MTLT quantity');
1705 END IF;
1706 RETURN;
1707 END;
1708 ELSIF l_lot_control_code = 1 AND l_serial_control_code IN (2,5) THEN
1709 BEGIN
1710 IF g_debug = 1 THEN
1711 print_msg(l_procedure_name ,'Checking for MMTT and MSNT quantity');
1712 END IF;
1713 --Serial quantity
1714 SELECT sum(1)
1715 INTO l_msnt_transaction_qty
1716 FROM mtl_serial_numbers_temp
1717 WHERE transaction_temp_id = p_transaction_temp_id;
1718 IF l_msnt_transaction_qty <> l_mmtt_transaction_quantity THEN
1719 x_return_status := 'E';
1720 IF g_debug = 1 THEN
1721 print_msg(l_procedure_name ,'Mismatch in MMTT and MSNT quantity');
1722 END IF;
1723 RETURN;
1724 END IF;
1725 EXCEPTION
1729 print_msg(l_procedure_name ,'No Data Found :Mismatch in MMTT and MSNT quantity');
1726 WHEN NO_DATA_FOUND THEN
1727 x_return_status := 'E';
1728 IF g_debug = 1 THEN
1730 END IF;
1731 RETURN;
1732 END;
1733 END IF;
1734 IF g_debug = 1 THEN
1735 print_msg(l_procedure_name , 'l_mmtt_primary_quantity - l_sum_tbl_primary_qty '||l_mmtt_primary_quantity || ' - '||l_sum_tbl_transaction_qty);
1736 END IF;
1737 x_return_status := 'S';
1738 EXCEPTION
1739 WHEN OTHERS THEN
1740 x_return_status := 'E';
1741 END validate_quantities;
1742
1743 -------------------------------------------------------------------------------------------------------------------
1744 /*PROCEDURE validate_task()
1745 This is the main procedure for all validations for the outbound task except quantity validations.
1746 It internally calls generic procedure validate_task_id.
1747 */
1748 -------------------------------------------------------------------------------------------------------------------
1749
1750 PROCEDURE validate_task( p_transaction_temp_id IN NUMBER ,
1751 x_return_status OUT NOCOPY VARCHAR2 ,
1752 x_error_msg OUT NOCOPY VARCHAR2 ,
1753 x_msg_data OUT NOCOPY VARCHAR2 ,
1754 x_msg_count OUT NOCOPY VARCHAR2 ) IS
1755
1756 l_mmtt_id NUMBER;
1757 l_mmtt_inventory_item_id NUMBER;
1758 l_mmtt_task_status NUMBER;
1759 l_mmtt_allocated_lpn_id NUMBER;
1760 l_mmtt_primary_quantity NUMBER;
1761 l_mmtt_transaction_quantity NUMBER;
1762 l_mmtt_transaction_uom_code NUMBER;
1763 l_orig_mol_id NUMBER;
1764 l_mmtt_mol_header_id NUMBER;
1765 l_mmtt_organization_id NUMBER;
1766 l_mmtt_transaction_uom VARCHAR2(3);
1767 l_mmtt_item_primary_uom_code VARCHAR2(3);
1768 l_task_type NUMBER;
1769 l_parent_line_id NUMBER := 0;
1770 l_validation_status VARCHAR2(10);
1771 l_error_msg VARCHAR2(1000);
1772 l_task_return_status VARCHAR2(10);
1773 l_procedure_name VARCHAR2(20) := 'VALIDATE_TASK';
1774 l_task_exists NUMBER;
1775 BEGIN
1776 x_return_status := 'S'; --6870528/6851036
1777 validate_task_id ( p_init_msg_list => 'Y' ,p_transaction_number=> p_transaction_temp_id ,x_validation_status => l_validation_status ,x_error_msg => l_error_msg , x_return_status =>x_return_status ); --6850212
1778 IF g_debug = 1 THEN
1779 print_msg(l_procedure_name , 'Task :' || p_transaction_temp_id || ' not valid.');
1780 END IF;
1781 IF NVL(l_validation_status,'E') <> 'S' OR NVL(x_return_status,'E') <> 'S' THEN
1782 IF g_debug = 1 THEN
1783 print_msg(l_procedure_name , 'Task :' || p_transaction_temp_id || ' not valid.');
1784 END IF;
1785 x_return_status := 'E';
1786 RETURN;
1787 END IF;
1788 IF p_transaction_temp_id IS NULL THEN
1789 x_return_status := 'E';
1790 IF g_debug = 1 THEN
1791 print_msg(l_procedure_name, 'No transaction_temp_id passed');
1792 END IF;
1793 RETURN;
1794 END IF;
1795 BEGIN
1796 -- Taking locks on the task
1797 SELECT transaction_temp_id ,
1798 wms_task_status ,
1799 allocated_lpn_id ,
1800 transaction_uom ,
1801 inventory_item_id ,
1802 primary_quantity ,
1803 transaction_quantity ,
1804 move_order_line_id ,
1805 move_order_header_id ,
1806 item_primary_uom_code ,
1807 transaction_uom ,
1808 organization_id ,
1809 wms_task_type ,
1810 parent_line_id
1811 INTO l_mmtt_id ,
1812 l_mmtt_task_status ,
1813 l_mmtt_allocated_lpn_id ,
1814 l_mmtt_transaction_uom ,
1815 l_mmtt_inventory_item_id ,
1816 l_mmtt_primary_quantity ,
1817 l_mmtt_transaction_quantity ,
1818 l_orig_mol_id ,
1819 l_mmtt_mol_header_id ,
1820 l_mmtt_item_primary_uom_code ,
1821 l_mmtt_transaction_uom ,
1822 l_mmtt_organization_id ,
1823 l_task_type ,
1824 l_parent_line_id
1825 FROM mtl_material_transactions_temp
1826 WHERE transaction_temp_id = p_transaction_temp_id FOR UPDATE NOWAIT;
1827 IF l_mmtt_allocated_lpn_id IS NOT NULL THEN
1828 x_return_status := 'E';
1829 IF g_debug = 1 THEN
1830 print_msg(l_procedure_name ,'Task :' || l_mmtt_id || ' has an allocated LPN. Split not allowed');
1831 END IF;
1832 RETURN;
1833 END IF;
1834 IF ( l_parent_line_id > 0 AND l_task_type = 1 AND l_parent_line_id = p_transaction_temp_id ) THEN -- This is bulk pick
1835 x_return_status := 'E';
1836 IF g_debug = 1 THEN
1840 END IF;
1837 print_msg(l_procedure_name ,'Task :' || l_mmtt_id || ' is a Bulk Pick task. Split not allowed');
1838 END IF;
1839 RETURN ;
1841 IF l_task_type <> 1 THEN
1842 x_return_status := 'E';
1843 IF g_debug = 1 THEN
1844 print_msg(l_procedure_name ,'Task :' || l_mmtt_id || ' is not an outbound task. Split not allowed');
1845 END IF;
1846 RETURN ;
1847 END IF;
1848 IF g_debug = 1 THEN
1849 print_msg(l_procedure_name , 'Calling validate_task_id for Task :' || p_transaction_temp_id);
1850 END IF;
1851 -- x_return_status := 'S'; --6870528/6851036
1852 EXCEPTION
1853 WHEN NO_DATA_FOUND THEN
1854 SELECT count(1)
1855 INTO l_task_exists
1856 FROM mtl_cycle_count_entries mcce
1857 WHERE mcce.cycle_count_entry_id = p_transaction_temp_id
1858 AND mcce.entry_status_code IN( 1 , 3) ;
1859 IF g_debug = 1 THEN
1860 IF l_task_exists > 0 THEN
1861 print_msg(l_procedure_name , 'Task :' || p_transaction_temp_id || ' is a cycle count task, split not allowed.');
1862 ELSE
1863 print_msg(l_procedure_name , 'Task :' || p_transaction_temp_id || ' does not exist.');
1864 END IF;
1865 END IF;
1866 x_return_status := 'E';
1867 WHEN OTHERS THEN
1868 x_return_status := 'E';
1869 IF g_debug = 1 THEN
1870 print_msg(l_procedure_name , 'Resource busy, was not able to acquire lock on mmtt:' || p_transaction_temp_id);
1871 END IF;
1872 END;
1873 -- x_return_status := 'S'; --6870528/6851036
1874 END validate_task;
1875
1876 -------------------------------------------------------------------------------------------------------------------
1877 /*PROCEDURE split_mtlt()
1878 This helper procedure performs the splitting for the lot records contained in mtl_transaction_lots_temp table
1879 */
1880 -------------------------------------------------------------------------------------------------------------------
1881 PROCEDURE split_mtlt ( p_new_transaction_temp_id IN NUMBER ,
1882 p_transaction_qty_to_split IN NUMBER ,
1883 p_primary_qty_to_split IN NUMBER ,
1884 p_row_id IN ROWID ,
1885 x_return_status OUT NOCOPY VARCHAR2 ,
1886 x_msg_data OUT NOCOPY VARCHAR2 ,
1887 x_msg_count OUT NOCOPY VARCHAR2 ) IS
1888
1889 BEGIN
1890 x_return_status := 'E';
1891 INSERT
1892 INTO mtl_transaction_lots_temp
1893 (
1894 TRANSACTION_TEMP_ID ,
1895 LAST_UPDATE_DATE ,
1896 LAST_UPDATED_BY ,
1897 CREATION_DATE ,
1898 CREATED_BY ,
1899 LAST_UPDATE_LOGIN ,
1900 REQUEST_ID ,
1901 PROGRAM_APPLICATION_ID ,
1902 PROGRAM_ID ,
1903 PROGRAM_UPDATE_DATE ,
1904 TRANSACTION_QUANTITY ,
1905 PRIMARY_QUANTITY ,
1906 LOT_NUMBER ,
1907 LOT_EXPIRATION_DATE ,
1908 ERROR_CODE ,
1909 SERIAL_TRANSACTION_TEMP_ID ,
1910 GROUP_HEADER_ID ,
1911 PUT_AWAY_RULE_ID ,
1912 PICK_RULE_ID ,
1913 DESCRIPTION ,
1914 VENDOR_NAME ,
1915 SUPPLIER_LOT_NUMBER ,
1916 ORIGINATION_DATE ,
1917 DATE_CODE ,
1918 GRADE_CODE ,
1919 CHANGE_DATE ,
1920 MATURITY_DATE ,
1921 STATUS_ID ,
1922 RETEST_DATE ,
1923 AGE ,
1924 ITEM_SIZE ,
1925 COLOR ,
1926 VOLUME ,
1927 VOLUME_UOM ,
1928 PLACE_OF_ORIGIN ,
1929 BEST_BY_DATE ,
1930 LENGTH ,
1931 LENGTH_UOM ,
1932 RECYCLED_CONTENT ,
1933 THICKNESS ,
1934 THICKNESS_UOM ,
1935 WIDTH ,
1936 WIDTH_UOM ,
1937 CURL_WRINKLE_FOLD ,
1938 LOT_ATTRIBUTE_CATEGORY ,
1939 C_ATTRIBUTE1 ,
1940 C_ATTRIBUTE2 ,
1941 C_ATTRIBUTE3 ,
1942 C_ATTRIBUTE4 ,
1943 C_ATTRIBUTE5 ,
1944 C_ATTRIBUTE6 ,
1945 C_ATTRIBUTE7 ,
1946 C_ATTRIBUTE8 ,
1950 C_ATTRIBUTE12 ,
1947 C_ATTRIBUTE9 ,
1948 C_ATTRIBUTE10 ,
1949 C_ATTRIBUTE11 ,
1951 C_ATTRIBUTE13 ,
1952 C_ATTRIBUTE14 ,
1953 C_ATTRIBUTE15 ,
1954 C_ATTRIBUTE16 ,
1955 C_ATTRIBUTE17 ,
1956 C_ATTRIBUTE18 ,
1957 C_ATTRIBUTE19 ,
1958 C_ATTRIBUTE20 ,
1959 D_ATTRIBUTE1 ,
1960 D_ATTRIBUTE2 ,
1961 D_ATTRIBUTE3 ,
1962 D_ATTRIBUTE4 ,
1963 D_ATTRIBUTE5 ,
1964 D_ATTRIBUTE6 ,
1965 D_ATTRIBUTE7 ,
1966 D_ATTRIBUTE8 ,
1967 D_ATTRIBUTE9 ,
1968 D_ATTRIBUTE10 ,
1969 N_ATTRIBUTE1 ,
1970 N_ATTRIBUTE2 ,
1971 N_ATTRIBUTE3 ,
1972 N_ATTRIBUTE4 ,
1973 N_ATTRIBUTE5 ,
1974 N_ATTRIBUTE6 ,
1975 N_ATTRIBUTE7 ,
1976 N_ATTRIBUTE8 ,
1977 N_ATTRIBUTE9 ,
1978 N_ATTRIBUTE10 ,
1979 VENDOR_ID ,
1980 TERRITORY_CODE ,
1981 SUBLOT_NUM ,
1982 SECONDARY_QUANTITY ,
1983 SECONDARY_UNIT_OF_MEASURE ,
1984 QC_GRADE ,
1985 REASON_CODE ,
1986 PRODUCT_CODE ,
1987 PRODUCT_TRANSACTION_ID ,
1988 ATTRIBUTE_CATEGORY ,
1989 ATTRIBUTE1 ,
1990 ATTRIBUTE2 ,
1991 ATTRIBUTE3 ,
1992 ATTRIBUTE4 ,
1993 ATTRIBUTE5 ,
1994 ATTRIBUTE6 ,
1995 ATTRIBUTE7 ,
1996 ATTRIBUTE8 ,
1997 ATTRIBUTE9 ,
1998 ATTRIBUTE10 ,
1999 ATTRIBUTE11 ,
2000 ATTRIBUTE12 ,
2001 ATTRIBUTE13 ,
2002 ATTRIBUTE14 ,
2003 ATTRIBUTE15
2004 )
2005 SELECT p_new_transaction_temp_id --TRANSACTION_TEMP_ID
2006 ,
2007 sysdate --LAST_UPDATE_DATE
2008 ,
2009 FND_GLOBAL.USER_ID ,
2010 sysdate --CREATION_DATE
2011 ,
2012 FND_GLOBAL.USER_ID ,
2013 LAST_UPDATE_LOGIN ,
2014 REQUEST_ID ,
2015 PROGRAM_APPLICATION_ID ,
2016 PROGRAM_ID ,
2017 PROGRAM_UPDATE_DATE ,
2018 p_transaction_qty_to_split --TRANSACTION_QUANTITY
2019 ,
2020 p_primary_qty_to_split --PRIMARY_QUANTITY
2021 ,
2022 LOT_NUMBER ,
2023 LOT_EXPIRATION_DATE ,
2024 ERROR_CODE ,
2025 SERIAL_TRANSACTION_TEMP_ID ,
2026 GROUP_HEADER_ID ,
2027 PUT_AWAY_RULE_ID ,
2028 PICK_RULE_ID ,
2029 DESCRIPTION ,
2030 VENDOR_NAME ,
2031 SUPPLIER_LOT_NUMBER ,
2032 ORIGINATION_DATE ,
2033 DATE_CODE ,
2034 GRADE_CODE ,
2035 CHANGE_DATE ,
2036 MATURITY_DATE ,
2037 STATUS_ID ,
2038 RETEST_DATE ,
2039 AGE ,
2040 ITEM_SIZE ,
2041 COLOR ,
2042 VOLUME ,
2043 VOLUME_UOM ,
2044 PLACE_OF_ORIGIN ,
2045 BEST_BY_DATE ,
2046 LENGTH ,
2047 LENGTH_UOM ,
2048 RECYCLED_CONTENT ,
2049 THICKNESS ,
2050 THICKNESS_UOM ,
2051 WIDTH ,
2052 WIDTH_UOM ,
2053 CURL_WRINKLE_FOLD ,
2054 LOT_ATTRIBUTE_CATEGORY ,
2055 C_ATTRIBUTE1 ,
2056 C_ATTRIBUTE2 ,
2057 C_ATTRIBUTE3 ,
2058 C_ATTRIBUTE4 ,
2059 C_ATTRIBUTE5 ,
2060 C_ATTRIBUTE6 ,
2061 C_ATTRIBUTE7 ,
2062 C_ATTRIBUTE8 ,
2066 C_ATTRIBUTE12 ,
2063 C_ATTRIBUTE9 ,
2064 C_ATTRIBUTE10 ,
2065 C_ATTRIBUTE11 ,
2067 C_ATTRIBUTE13 ,
2068 C_ATTRIBUTE14 ,
2069 C_ATTRIBUTE15 ,
2070 C_ATTRIBUTE16 ,
2071 C_ATTRIBUTE17 ,
2072 C_ATTRIBUTE18 ,
2073 C_ATTRIBUTE19 ,
2074 C_ATTRIBUTE20 ,
2075 D_ATTRIBUTE1 ,
2076 D_ATTRIBUTE2 ,
2077 D_ATTRIBUTE3 ,
2078 D_ATTRIBUTE4 ,
2079 D_ATTRIBUTE5 ,
2080 D_ATTRIBUTE6 ,
2081 D_ATTRIBUTE7 ,
2082 D_ATTRIBUTE8 ,
2083 D_ATTRIBUTE9 ,
2084 D_ATTRIBUTE10 ,
2085 N_ATTRIBUTE1 ,
2086 N_ATTRIBUTE2 ,
2087 N_ATTRIBUTE3 ,
2088 N_ATTRIBUTE4 ,
2089 N_ATTRIBUTE5 ,
2090 N_ATTRIBUTE6 ,
2091 N_ATTRIBUTE7 ,
2092 N_ATTRIBUTE8 ,
2093 N_ATTRIBUTE9 ,
2094 N_ATTRIBUTE10 ,
2095 VENDOR_ID ,
2096 TERRITORY_CODE ,
2097 SUBLOT_NUM ,
2098 SECONDARY_QUANTITY ,
2099 SECONDARY_UNIT_OF_MEASURE ,
2100 QC_GRADE ,
2101 REASON_CODE ,
2102 PRODUCT_CODE ,
2103 PRODUCT_TRANSACTION_ID ,
2104 ATTRIBUTE_CATEGORY ,
2105 ATTRIBUTE1 ,
2106 ATTRIBUTE2 ,
2107 ATTRIBUTE3 ,
2108 ATTRIBUTE4 ,
2109 ATTRIBUTE5 ,
2110 ATTRIBUTE6 ,
2111 ATTRIBUTE7 ,
2112 ATTRIBUTE8 ,
2113 ATTRIBUTE9 ,
2114 ATTRIBUTE10 ,
2115 ATTRIBUTE11 ,
2116 ATTRIBUTE12 ,
2117 ATTRIBUTE13 ,
2118 ATTRIBUTE14 ,
2119 ATTRIBUTE15
2120 FROM mtl_transaction_lots_temp
2121 WHERE rowid = p_row_id;
2122 x_return_status := 'S';
2123 EXCEPTION
2124 WHEN OTHERS THEN
2125 x_return_status := 'E';
2126 RETURN;
2127 END split_mtlt;
2128
2129 -------------------------------------------------------------------------------------------------------------------
2130 /*Procedure split_serial()
2131 This helper procedure performs the splitting for the serial records contained in mtl_serial_numbers_temp table
2132 */
2133 -------------------------------------------------------------------------------------------------------------------
2134
2135 PROCEDURE split_serial( p_orig_transaction_temp_id IN NUMBER ,
2136 p_new_transaction_temp_id IN NUMBER ,
2137 p_transaction_qty_to_split IN NUMBER ,
2138 p_primary_qty_to_split IN NUMBER ,
2139 p_inventory_item_id IN NUMBER ,
2140 p_organization_id IN NUMBER ,
2141 x_return_status OUT NOCOPY VARCHAR2 ,
2142 x_msg_data OUT NOCOPY VARCHAR2 ,
2143 x_msg_count OUT NOCOPY VARCHAR2 ) IS
2144
2145 CURSOR C_MSNT
2146 IS
2147 SELECT rowid,
2148 msnt.*
2149 FROM mtl_serial_numbers_temp msnt
2150 WHERE transaction_temp_id = p_orig_transaction_temp_id
2151 ORDER BY fm_serial_number;
2152 l_procedure_name VARCHAR2(20) := 'SPLIT_SERIAL';
2153 l_transaction_remaining_qty NUMBER;
2154 l_primary_remaining_qty NUMBER;
2155 BEGIN
2156 x_return_status := 'E';
2157 l_transaction_remaining_qty := p_transaction_qty_to_split;
2158 l_primary_remaining_qty := p_primary_qty_to_split;
2159 IF g_debug = 1 THEN
2160 print_msg(l_procedure_name, 'In for loop(cursor msnt) for transaction_temp_id : '||p_orig_transaction_temp_id || 'l_transaction_remaining_qty : '||l_transaction_remaining_qty|| 'l_primary_remaining_qty : '||l_primary_remaining_qty);
2161 END IF;
2162 FOR msnt IN C_MSNT
2163 LOOP
2164 l_transaction_remaining_qty := l_transaction_remaining_qty - 1;
2165 UPDATE mtl_serial_numbers_temp
2166 SET transaction_temp_id = p_new_transaction_temp_id ,
2167 last_updated_by = FND_GLOBAL.USER_ID
2168 WHERE rowid = msnt.rowid;
2169 UPDATE mtl_serial_numbers msn
2170 SET msn.group_mark_id = p_new_transaction_temp_id ,
2171 last_updated_by = FND_GLOBAL.USER_ID
2172 WHERE msn.inventory_item_id = p_inventory_item_id
2173 AND serial_number = msnt.fm_serial_number
2174 AND current_organization_id = p_organization_id;
2175 IF l_transaction_remaining_qty = 0 THEN
2176 print_msg(l_procedure_name,'All the quantity has been consumed, going back');
2177 EXIT;
2178 END IF;
2179 END LOOP;
2180 x_return_status := 'S';
2181 EXCEPTION
2182 WHEN OTHERS THEN
2186
2183 x_return_status := 'E';
2184 RETURN;
2185 END split_serial;
2187 -------------------------------------------------------------------------------------------------------------------
2188 /*PROCEDURE split_lot_serial()
2189 This is the procedure called for splitting in case an Item is either only Lot Controlled or both Lot and
2190 Serial Controlled. It internally calls procedures split_mtlt and split_serial.
2191 */
2192 -------------------------------------------------------------------------------------------------------------------
2193 PROCEDURE split_lot_serial( p_orig_transaction_temp_id IN NUMBER ,
2194 p_new_transaction_temp_id IN NUMBER ,
2195 p_transaction_qty_to_split IN NUMBER ,
2196 p_primary_qty_to_split IN NUMBER ,
2197 p_inventory_item_id IN NUMBER ,
2198 p_organization_id IN NUMBER ,
2199 x_return_status OUT NOCOPY VARCHAR2 ,
2200 x_msg_data OUT NOCOPY VARCHAR2 ,
2201 x_msg_count OUT NOCOPY VARCHAR2 ) IS
2202
2203 CURSOR C_MTLT
2204 IS
2205 SELECT rowid,
2206 mtlt.*
2207 FROM mtl_transaction_lots_temp mtlt
2208 WHERE transaction_temp_id = p_orig_transaction_temp_id
2209 ORDER BY lot_number;
2210
2211 l_transaction_remaining_qty NUMBER;
2212 l_primary_remaining_qty NUMBER;
2213 l_txn_remaining_qty_mtlt NUMBER;
2214 l_prim_remaining_qty_mtlt NUMBER;
2215 l_procedure_name VARCHAR2(30) := 'SPLIT_LOT_SERIAL';
2216 l_lot_control_code NUMBER;
2217 l_serial_control_code NUMBER;
2218 l_new_serial_txn_temp_id NUMBER;
2219 l_lot_control_code NUMBER;
2220 l_serial_control_code NUMBER;
2221 x_lot_return_status VARCHAR2(1);
2222 BEGIN
2223 x_return_status := 'E';
2224 IF g_debug = 1 THEN
2225 print_msg(l_procedure_name, 'Entered.');
2226 END IF;
2227 l_transaction_remaining_qty := p_transaction_qty_to_split;
2228 l_primary_remaining_qty := p_primary_qty_to_split;
2229
2230 FOR mtlt IN C_MTLT
2231 LOOP
2232 IF g_debug = 1 THEN
2233 print_msg(l_procedure_name, 'In for loop(cursor mtlt) for transaction_temp_id : '||
2234 p_orig_transaction_temp_id || 'l_transaction_remaining_qty : '||
2235 l_transaction_remaining_qty|| 'l_primary_remaining_qty : '||
2236 l_primary_remaining_qty);
2237 END IF;
2238 IF l_transaction_remaining_qty >= mtlt.transaction_quantity THEN
2239 -- Then this whole row can be consumed there is not need to split.
2240 -- Update the row with the new ttemp_id and transaction_quantity.
2241 -- Calculate remaining quantity.
2242 -- Update mtl_lot_number
2243 l_transaction_remaining_qty := l_transaction_remaining_qty - mtlt.transaction_quantity;
2244 l_primary_remaining_qty := l_primary_remaining_qty - mtlt.primary_quantity;
2245 UPDATE mtl_transaction_lots_temp
2246 SET transaction_temp_id = p_new_transaction_temp_id ,
2247 last_updated_by = FND_GLOBAL.USER_ID
2248 WHERE rowid = mtlt.rowid;
2249 IF l_transaction_remaining_qty = 0 THEN
2250 EXIT;
2251 END IF;
2252 ELSE
2253 -- Oops the mtlt quantity is bigger gotta split the row.
2254 -- Insert a new row with the transaction_quantity.
2255 -- Update the old row with the remaining quantity.
2256 -- Update mtl_lot_number
2257 split_mtlt ( p_new_transaction_temp_id ,
2258 l_transaction_remaining_qty ,
2259 l_primary_remaining_qty ,mtlt.rowid ,
2260 x_lot_return_status ,
2261 x_msg_data ,
2262 x_msg_count );
2263
2264 IF mtlt.serial_transaction_temp_id IS NOT NULL THEN
2265 SELECT mtl_material_transactions_s.NEXTVAL
2266 INTO l_new_serial_txn_temp_id
2267 FROM dual;
2268 UPDATE mtl_transaction_lots_temp
2269 SET serial_transaction_temp_id = l_new_serial_txn_temp_id ,
2270 last_updated_by = FND_GLOBAL.USER_ID
2271 WHERE transaction_temp_id = p_new_transaction_temp_id
2272 AND lot_number = mtlt.lot_number;
2273 split_serial( p_orig_transaction_temp_id => mtlt.serial_transaction_temp_id ,
2274 p_new_transaction_temp_id => l_new_serial_txn_temp_id ,
2275 p_transaction_qty_to_split => l_transaction_remaining_qty ,
2276 p_primary_qty_to_split => l_primary_remaining_qty ,
2277 p_inventory_item_id => p_inventory_item_id ,
2278 p_organization_id => p_organization_id ,
2279 x_return_status => x_return_status ,
2280 x_msg_data => x_msg_data ,
2281 x_msg_count => x_msg_count );
2282 END IF;
2283 l_txn_remaining_qty_mtlt := mtlt.transaction_quantity - l_transaction_remaining_qty;
2284 l_prim_remaining_qty_mtlt := mtlt.primary_quantity - l_primary_remaining_qty;
2285 -- Update the remaining qty in the mtlt after insert.
2286 UPDATE mtl_transaction_lots_temp
2287 SET transaction_quantity = l_txn_remaining_qty_mtlt ,
2291 -- As the remaining quantity is already consumed we can safely exit
2288 primary_quantity = l_prim_remaining_qty_mtlt ,
2289 last_updated_by = FND_GLOBAL.USER_ID
2290 WHERE rowid = mtlt.rowid;
2292 EXIT ;
2293 END IF;
2294 END LOOP;
2295 x_return_status := 'S';
2296 EXCEPTION
2297 WHEN OTHERS THEN
2298 IF g_debug = 1 THEN
2299 print_msg(l_procedure_name, 'Error occurred : '|| SQLERRM);
2300 END IF;
2301 x_return_status := 'E';
2302 RETURN;
2303 END split_lot_serial;
2304
2305 -------------------------------------------------------------------------------------------------------------------
2306 /*PROCEDURE split_wdt()
2307 This procedure is called to accordingly split the task record contained in wms_dispatched_tasks table
2308 */
2309 -------------------------------------------------------------------------------------------------------------------
2310 PROCEDURE split_wdt( p_new_task_id IN NUMBER ,
2311 p_new_transaction_temp_id IN NUMBER ,
2312 p_new_mol_id IN NUMBER ,
2313 p_orig_transaction_temp_id IN NUMBER ,
2314 x_return_status OUT NOCOPY VARCHAR2 ,
2315 x_msg_data OUT NOCOPY VARCHAR2 ,
2316 x_msg_count OUT NOCOPY VARCHAR2 ) IS
2317
2318 l_proceudre_name VARCHAR2(30) := 'SPLIT_WDT';
2319 l_sysdate DATE := SYSDATE;
2320 BEGIN
2321 x_return_status := 'E';
2322 IF g_debug = 1 THEN
2323 print_msg(l_proceudre_name, ' Entered ');
2324 END IF;
2325 INSERT
2326 INTO wms_dispatched_tasks
2327 (
2328 op_plan_instance_id ,
2329 task_method ,
2330 task_id ,
2331 transaction_temp_id ,
2332 organization_id ,
2333 user_task_type ,
2334 person_id ,
2335 effective_start_date ,
2336 effective_end_date ,
2337 equipment_id ,
2338 equipment_instance ,
2339 person_resource_id ,
2340 machine_resource_id ,
2341 status ,
2342 dispatched_time ,
2343 loaded_time ,
2344 drop_off_time ,
2345 last_update_date ,
2346 last_updated_by ,
2347 creation_date ,
2348 created_by ,
2349 last_update_login ,
2350 attribute_category ,
2351 attribute1 ,
2352 attribute2 ,
2353 attribute3 ,
2354 attribute4 ,
2355 attribute5 ,
2356 attribute6 ,
2357 attribute7 ,
2358 attribute8 ,
2359 attribute9 ,
2360 attribute10 ,
2361 attribute11 ,
2362 attribute12 ,
2363 attribute13 ,
2364 attribute14 ,
2365 attribute15 ,
2366 task_type ,
2367 priority ,
2368 task_group_id ,
2369 device_id ,
2370 device_invoked ,
2371 device_request_id ,
2372 suggested_dest_subinventory ,
2373 suggested_dest_locator_id ,
2374 operation_plan_id ,
2375 move_order_line_id ,
2376 transfer_lpn_id
2377 )
2378 SELECT op_plan_instance_id ,
2379 task_method ,
2380 p_new_task_id --task_id
2381 ,
2382 p_new_transaction_temp_id --transaction_temp_id
2383 ,
2384 organization_id ,
2385 user_task_type ,
2386 person_id ,
2387 effective_start_date ,
2388 effective_end_date ,
2389 equipment_id ,
2390 equipment_instance ,
2391 person_resource_id ,
2392 machine_resource_id ,
2393 status ,
2394 dispatched_time ,
2395 loaded_time ,
2396 drop_off_time ,
2397 l_sysdate --last_update_date
2398 ,
2399 FND_GLOBAL.USER_ID ,
2400 l_sysdate --creation_date
2401 ,
2402 FND_GLOBAL.USER_ID ,
2403 last_update_login ,
2404 attribute_category ,
2405 attribute1 ,
2406 attribute2 ,
2407 attribute3 ,
2411 attribute7 ,
2408 attribute4 ,
2409 attribute5 ,
2410 attribute6 ,
2412 attribute8 ,
2413 attribute9 ,
2414 attribute10 ,
2415 attribute11 ,
2416 attribute12 ,
2417 attribute13 ,
2418 attribute14 ,
2419 attribute15 ,
2420 task_type ,
2421 priority ,
2422 task_group_id ,
2423 device_id ,
2424 device_invoked ,
2425 device_request_id ,
2426 suggested_dest_subinventory ,
2427 suggested_dest_locator_id ,
2428 operation_plan_id ,
2429 p_new_mol_id ,
2430 transfer_lpn_id
2431 FROM wms_dispatched_tasks
2432 WHERE transaction_temp_id = p_orig_transaction_temp_id;
2433 x_return_status := 'S';
2434 EXCEPTION
2435 WHEN OTHERS THEN
2436 x_return_status := 'E';
2437 IF g_debug = 1 THEN
2438 print_msg(l_proceudre_name, ' Error Code : '|| SQLCODE || ' Error Message :'||SQLERRM);
2439 END IF;
2440 RETURN;
2441 END split_wdt;
2442
2443 -------------------------------------------------------------------------------------------------------------------
2444 /*PROCEDURE split_mmtt()
2445 This procedure performs the split for the Pending task record in mtl_material_transactions_temp table
2446 */
2447 -------------------------------------------------------------------------------------------------------------------
2448 PROCEDURE split_mmtt( p_orig_transaction_temp_id IN NUMBER ,
2449 p_new_transaction_temp_id IN NUMBER ,
2450 p_new_transaction_header_id IN NUMBER ,
2451 p_new_mol_id IN NUMBER ,
2452 p_transaction_qty_to_split IN NUMBER ,
2453 p_primary_qty_to_split IN NUMBER ,
2454 x_return_status OUT NOCOPY VARCHAR2 ,
2455 x_msg_data OUT NOCOPY VARCHAR2 ,
2456 x_msg_count OUT NOCOPY VARCHAR2 ) IS
2457
2458 l_procedure_name VARCHAR2(30) := 'WMS_TASK_SPLIT_API.SPLIT_MMTT';
2459 l_sysdate DATE := SYSDATE;
2460 BEGIN
2461 x_return_status := 'E';
2462 IF g_debug = 1 THEN
2463 print_msg(l_procedure_name, ' Entered ');
2464 END IF;
2465 INSERT
2466 INTO mtl_material_transactions_temp
2467 (
2468 currency_conversion_date ,
2469 shipment_number ,
2470 org_cost_group_id ,
2471 cost_type_id ,
2472 transaction_status ,
2473 standard_operation_id ,
2474 task_priority ,
2475 wms_task_type ,
2476 parent_line_id ,
2477 source_lot_number ,
2478 transfer_cost_group_id ,
2479 lpn_id ,
2480 transfer_lpn_id ,
2481 wms_task_status ,
2482 content_lpn_id ,
2483 container_item_id ,
2484 cartonization_id ,
2485 pick_slip_date ,
2486 rebuild_item_id ,
2487 rebuild_serial_number ,
2488 rebuild_activity_id ,
2489 rebuild_job_name ,
2490 organization_type ,
2491 transfer_organization_type ,
2492 owning_organization_id ,
2493 owning_tp_type ,
2494 xfr_owning_organization_id ,
2495 transfer_owning_tp_type ,
2496 planning_organization_id ,
2497 planning_tp_type ,
2498 xfr_planning_organization_id ,
2499 transfer_planning_tp_type ,
2500 secondary_uom_code ,
2501 secondary_transaction_quantity ,
2502 allocated_lpn_id ,
2503 schedule_number ,
2504 scheduled_flag ,
2505 class_code ,
2506 schedule_group ,
2507 build_sequence ,
2508 bom_revision ,
2509 routing_revision ,
2510 bom_revision_date ,
2511 routing_revision_date ,
2512 alternate_bom_designator ,
2513 alternate_routing_designator ,
2514 transaction_batch_id ,
2515 transaction_batch_seq ,
2516 operation_plan_id ,
2517 intransit_account ,
2518 fob_point ,
2519 transaction_header_id ,
2520 transaction_temp_id ,
2524 lock_flag ,
2521 source_code ,
2522 source_line_id ,
2523 transaction_mode ,
2525 last_update_date ,
2526 last_updated_by ,
2527 creation_date ,
2528 created_by ,
2529 last_update_login ,
2530 request_id ,
2531 program_application_id ,
2532 program_id ,
2533 program_update_date ,
2534 inventory_item_id ,
2535 revision ,
2536 organization_id ,
2537 subinventory_code ,
2538 locator_id ,
2539 transaction_quantity ,
2540 primary_quantity ,
2541 transaction_uom ,
2542 transaction_cost ,
2543 transaction_type_id ,
2544 transaction_action_id ,
2545 transaction_source_type_id ,
2546 transaction_source_id ,
2547 transaction_source_name ,
2548 transaction_date ,
2549 acct_period_id ,
2550 distribution_account_id ,
2551 transaction_reference ,
2552 requisition_line_id ,
2553 requisition_distribution_id ,
2554 reason_id ,
2555 lot_number ,
2556 lot_expiration_date ,
2557 serial_number ,
2558 receiving_document ,
2559 demand_id ,
2560 rcv_transaction_id ,
2561 move_transaction_id ,
2562 completion_transaction_id ,
2563 wip_entity_type ,
2564 schedule_id ,
2565 repetitive_line_id ,
2566 employee_code ,
2567 primary_switch ,
2568 schedule_update_code ,
2569 setup_teardown_code ,
2570 item_ordering ,
2571 negative_req_flag ,
2572 operation_seq_num ,
2573 picking_line_id ,
2574 trx_source_line_id ,
2575 trx_source_delivery_id ,
2576 physical_adjustment_id ,
2577 cycle_count_id ,
2578 rma_line_id ,
2579 customer_ship_id ,
2580 currency_code ,
2581 currency_conversion_rate ,
2582 currency_conversion_type ,
2583 ship_to_location ,
2584 move_order_header_id ,
2585 serial_allocated_flag ,
2586 trx_flow_header_id ,
2587 logical_trx_type_code ,
2588 original_transaction_temp_id ,
2589 vendor_lot_number ,
2590 encumbrance_account ,
2591 encumbrance_amount ,
2592 transfer_cost ,
2593 transportation_cost ,
2594 transportation_account ,
2595 freight_code ,
2596 containers ,
2597 waybill_airbill ,
2598 expected_arrival_date ,
2599 transfer_subinventory ,
2600 transfer_organization ,
2601 transfer_to_location ,
2602 new_average_cost ,
2603 value_change ,
2604 percentage_change ,
2605 material_allocation_temp_id ,
2606 demand_source_header_id ,
2607 demand_source_line ,
2608 demand_source_delivery ,
2609 item_segments ,
2610 item_description ,
2611 item_trx_enabled_flag ,
2612 item_location_control_code ,
2613 item_restrict_subinv_code ,
2614 item_restrict_locators_code ,
2615 item_revision_qty_control_code ,
2616 item_primary_uom_code ,
2617 item_uom_class ,
2618 item_shelf_life_code ,
2619 item_shelf_life_days ,
2620 item_lot_control_code ,
2621 item_serial_control_code ,
2625 department_code ,
2622 item_inventory_asset_flag ,
2623 allowed_units_lookup_code ,
2624 department_id ,
2626 wip_supply_type ,
2627 supply_subinventory ,
2628 supply_locator_id ,
2629 valid_subinventory_flag ,
2630 valid_locator_flag ,
2631 locator_segments ,
2632 current_locator_control_code ,
2633 number_of_lots_entered ,
2634 wip_commit_flag ,
2635 next_lot_number ,
2636 lot_alpha_prefix ,
2637 next_serial_number ,
2638 serial_alpha_prefix ,
2639 shippable_flag ,
2640 posting_flag ,
2641 required_flag ,
2642 process_flag ,
2643 ERROR_CODE ,
2644 error_explanation ,
2645 attribute_category ,
2646 attribute1 ,
2647 attribute2 ,
2648 attribute3 ,
2649 attribute4 ,
2650 attribute5 ,
2651 attribute6 ,
2652 attribute7 ,
2653 attribute8 ,
2654 attribute9 ,
2655 attribute10 ,
2656 attribute11 ,
2657 attribute12 ,
2658 attribute13 ,
2659 attribute14 ,
2660 attribute15 ,
2661 movement_id ,
2662 reservation_quantity ,
2663 shipped_quantity ,
2664 transaction_line_number ,
2665 task_id ,
2666 to_task_id ,
2667 source_task_id ,
2668 project_id ,
2669 source_project_id ,
2670 pa_expenditure_org_id ,
2671 to_project_id ,
2672 expenditure_type ,
2673 final_completion_flag ,
2674 transfer_percentage ,
2675 transaction_sequence_id ,
2676 material_account ,
2677 material_overhead_account ,
2678 resource_account ,
2679 outside_processing_account ,
2680 overhead_account ,
2681 flow_schedule ,
2682 cost_group_id ,
2683 demand_class ,
2684 qa_collection_id ,
2685 kanban_card_id ,
2686 overcompletion_transaction_qty ,
2687 overcompletion_primary_qty ,
2688 overcompletion_transaction_id ,
2689 end_item_unit_number ,
2690 scheduled_payback_date ,
2691 line_type_code ,
2692 parent_transaction_temp_id ,
2693 put_away_strategy_id ,
2694 put_away_rule_id ,
2695 pick_strategy_id ,
2696 pick_rule_id ,
2697 move_order_line_id ,
2698 task_group_id ,
2699 pick_slip_number ,
2700 reservation_id ,
2701 common_bom_seq_id ,
2702 common_routing_seq_id ,
2703 ussgl_transaction_code
2704 )
2705 SELECT currency_conversion_date ,
2706 shipment_number ,
2707 org_cost_group_id ,
2708 cost_type_id ,
2709 transaction_status ,
2710 standard_operation_id ,
2711 task_priority ,
2712 wms_task_type ,
2713 parent_line_id ,
2714 source_lot_number ,
2715 transfer_cost_group_id ,
2716 lpn_id ,
2717 transfer_lpn_id ,
2718 wms_task_status ,
2719 content_lpn_id ,
2720 container_item_id ,
2721 cartonization_id ,
2722 pick_slip_date ,
2723 rebuild_item_id ,
2724 rebuild_serial_number ,
2725 rebuild_activity_id ,
2726 rebuild_job_name ,
2727 organization_type ,
2728 transfer_organization_type ,
2729 owning_organization_id ,
2730 owning_tp_type ,
2731 xfr_owning_organization_id ,
2732 transfer_owning_tp_type ,
2733 planning_organization_id ,
2734 planning_tp_type ,
2735 xfr_planning_organization_id ,
2736 transfer_planning_tp_type ,
2737 secondary_uom_code ,
2738 secondary_transaction_quantity ,
2739 allocated_lpn_id ,
2740 schedule_number ,
2741 scheduled_flag ,
2742 class_code ,
2743 schedule_group ,
2744 build_sequence ,
2745 bom_revision ,
2746 routing_revision ,
2747 bom_revision_date ,
2748 routing_revision_date ,
2749 alternate_bom_designator ,
2750 alternate_routing_designator ,
2751 transaction_batch_id ,
2752 transaction_batch_seq ,
2753 operation_plan_id ,
2754 intransit_account ,
2755 fob_point ,
2756 p_new_transaction_header_id --TRANSACTION_HEADER_ID
2757 ,
2758 p_new_transaction_temp_id --TRANSACTION_TEMP_ID
2759 ,
2760 source_code ,
2761 source_line_id ,
2762 transaction_mode ,
2763 lock_flag ,
2764 l_sysdate --LAST_UPDATE_DATE
2765 ,
2766 FND_GLOBAL.USER_ID ,
2767 l_sysdate --CREATION_DATE
2768 ,
2769 FND_GLOBAL.USER_ID ,
2770 last_update_login ,
2771 request_id ,
2772 program_application_id ,
2773 program_id ,
2774 program_update_date ,
2775 inventory_item_id ,
2776 revision ,
2777 organization_id ,
2778 subinventory_code ,
2779 locator_id ,
2780 p_transaction_qty_to_split --TRANSACTION_QUANTITY
2781 ,
2782 p_primary_qty_to_split --PRIMARY_QUANTITY
2783 ,
2784 transaction_uom ,
2785 transaction_cost ,
2786 transaction_type_id ,
2787 transaction_action_id ,
2788 transaction_source_type_id ,
2789 transaction_source_id ,
2790 transaction_source_name ,
2791 transaction_date ,
2792 acct_period_id ,
2793 distribution_account_id ,
2794 transaction_reference ,
2795 requisition_line_id ,
2796 requisition_distribution_id ,
2797 reason_id ,
2798 lot_number ,
2799 lot_expiration_date ,
2800 serial_number ,
2801 receiving_document ,
2802 demand_id ,
2803 rcv_transaction_id ,
2804 move_transaction_id ,
2805 completion_transaction_id ,
2806 wip_entity_type ,
2807 schedule_id ,
2808 repetitive_line_id ,
2809 employee_code ,
2810 primary_switch ,
2811 schedule_update_code ,
2812 setup_teardown_code ,
2813 item_ordering ,
2814 negative_req_flag ,
2815 operation_seq_num ,
2816 picking_line_id ,
2817 trx_source_line_id ,
2818 trx_source_delivery_id ,
2819 physical_adjustment_id ,
2820 cycle_count_id ,
2821 rma_line_id ,
2822 customer_ship_id ,
2823 currency_code ,
2824 currency_conversion_rate ,
2825 currency_conversion_type ,
2826 ship_to_location ,
2827 move_order_header_id ,
2828 serial_allocated_flag ,
2829 trx_flow_header_id ,
2830 logical_trx_type_code ,
2831 original_transaction_temp_id ,
2832 vendor_lot_number ,
2833 encumbrance_account ,
2834 encumbrance_amount ,
2835 transfer_cost ,
2836 transportation_cost ,
2837 transportation_account ,
2838 freight_code ,
2839 containers ,
2840 waybill_airbill ,
2841 expected_arrival_date ,
2842 transfer_subinventory ,
2843 transfer_organization ,
2847 percentage_change ,
2844 transfer_to_location ,
2845 new_average_cost ,
2846 value_change ,
2848 material_allocation_temp_id ,
2849 demand_source_header_id ,
2850 demand_source_line ,
2851 demand_source_delivery ,
2852 item_segments ,
2853 item_description ,
2854 item_trx_enabled_flag ,
2855 item_location_control_code ,
2856 item_restrict_subinv_code ,
2857 item_restrict_locators_code ,
2858 item_revision_qty_control_code ,
2859 item_primary_uom_code ,
2860 item_uom_class ,
2861 item_shelf_life_code ,
2862 item_shelf_life_days ,
2863 item_lot_control_code ,
2864 item_serial_control_code ,
2865 item_inventory_asset_flag ,
2866 allowed_units_lookup_code ,
2867 department_id ,
2868 department_code ,
2869 wip_supply_type ,
2870 supply_subinventory ,
2871 supply_locator_id ,
2872 valid_subinventory_flag ,
2873 valid_locator_flag ,
2874 locator_segments ,
2875 current_locator_control_code ,
2876 number_of_lots_entered ,
2877 wip_commit_flag ,
2878 next_lot_number ,
2879 lot_alpha_prefix ,
2880 next_serial_number ,
2881 serial_alpha_prefix ,
2882 shippable_flag ,
2883 posting_flag ,
2884 required_flag ,
2885 process_flag ,
2886 ERROR_CODE ,
2887 error_explanation ,
2888 attribute_category ,
2889 attribute1 ,
2890 attribute2 ,
2891 attribute3 ,
2892 attribute4 ,
2893 attribute5 ,
2894 attribute6 ,
2895 attribute7 ,
2896 attribute8 ,
2897 attribute9 ,
2898 attribute10 ,
2899 attribute11 ,
2900 attribute12 ,
2901 attribute13 ,
2902 attribute14 ,
2903 attribute15 ,
2904 movement_id ,
2905 reservation_quantity ,
2906 shipped_quantity ,
2907 transaction_line_number ,
2908 task_id ,
2909 to_task_id ,
2910 source_task_id ,
2911 project_id ,
2912 source_project_id ,
2913 pa_expenditure_org_id ,
2914 to_project_id ,
2915 expenditure_type ,
2916 final_completion_flag ,
2917 transfer_percentage ,
2918 transaction_sequence_id ,
2919 material_account ,
2920 material_overhead_account ,
2921 resource_account ,
2922 outside_processing_account ,
2923 overhead_account ,
2924 flow_schedule ,
2925 cost_group_id ,
2926 demand_class ,
2927 qa_collection_id ,
2928 kanban_card_id ,
2929 overcompletion_transaction_qty ,
2930 overcompletion_primary_qty ,
2931 overcompletion_transaction_id ,
2932 end_item_unit_number ,
2933 scheduled_payback_date ,
2934 line_type_code ,
2935 parent_transaction_temp_id ,
2936 put_away_strategy_id ,
2937 put_away_rule_id ,
2938 pick_strategy_id ,
2939 pick_rule_id ,
2940 move_order_line_id ,
2941 task_group_id ,
2942 pick_slip_number ,
2943 reservation_id ,
2944 common_bom_seq_id ,
2945 common_routing_seq_id ,
2946 ussgl_transaction_code
2947 FROM mtl_material_transactions_temp
2948 WHERE transaction_temp_id = p_orig_transaction_temp_id;
2949 x_return_status := 'S';
2950 EXCEPTION
2951 WHEN OTHERS THEN
2952 x_return_status := 'E';
2953 IF g_debug = 1 THEN
2954 print_msg(l_procedure_name, ' Error Code : '|| SQLCODE || ' Error Message :'||SQLERRM);
2955 END IF;
2956 RETURN;
2957 END split_mmtt;
2958
2962 PROCEDURE debug_print (p_message IN VARCHAR2 ) IS
2959 -------------------------------------------------------------------------------------------------------------------
2960 --START OF DELETE TASK Process
2961
2963 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'), 0);
2964 BEGIN
2965 IF (l_debug = 1) THEN
2966 inv_mobile_helper_functions.tracelog (p_err_msg => p_message,
2967 p_module => 'wms_delete_tasks',
2968 p_level => 11);
2969 END IF;
2970 END debug_print;
2971 -------------------------------------------------------------------------------------------------------------------
2972 /*FUNCTION query_rows()
2973 This function gets the move order record for the move order line passed.
2974 */
2975 -------------------------------------------------------------------------------------------------------------------
2976 FUNCTION query_rows(p_line_id IN NUMBER := fnd_api.g_miss_num)
2977 RETURN inv_move_order_pub.trolin_tbl_type IS
2978
2979 l_trolin_rec inv_move_order_pub.trolin_rec_type;
2980 l_trolin_tbl inv_move_order_pub.trolin_tbl_type;
2981 CURSOR l_trolin_csr
2982 IS
2983 SELECT attribute1 ,
2984 attribute10 ,
2985 attribute11 ,
2986 attribute12 ,
2987 attribute13 ,
2988 attribute14 ,
2989 attribute15 ,
2990 attribute2 ,
2991 attribute3 ,
2992 attribute4 ,
2993 attribute5 ,
2994 attribute6 ,
2995 attribute7 ,
2996 attribute8 ,
2997 attribute9 ,
2998 attribute_category ,
2999 created_by ,
3000 creation_date ,
3001 date_required ,
3002 from_locator_id ,
3003 from_subinventory_code ,
3004 from_subinventory_id ,
3005 header_id ,
3006 inventory_item_id ,
3007 last_updated_by ,
3008 last_update_date ,
3009 last_update_login ,
3010 line_id ,
3011 line_number ,
3012 line_status ,
3013 lot_number ,
3014 organization_id ,
3015 program_application_id ,
3016 program_id ,
3017 program_update_date ,
3018 project_id ,
3019 quantity ,
3020 quantity_delivered ,
3021 quantity_detailed ,
3022 reason_id ,
3023 REFERENCE ,
3024 reference_id ,
3025 reference_type_code ,
3026 request_id ,
3027 revision ,
3028 serial_number_end ,
3029 serial_number_start ,
3030 status_date ,
3031 task_id ,
3032 to_account_id ,
3033 to_locator_id ,
3034 to_subinventory_code ,
3035 to_subinventory_id ,
3036 transaction_header_id ,
3037 uom_code ,
3038 transaction_type_id ,
3039 transaction_source_type_id ,
3040 txn_source_id ,
3041 txn_source_line_id ,
3042 txn_source_line_detail_id ,
3043 to_organization_id ,
3044 primary_quantity ,
3045 pick_strategy_id ,
3046 put_away_strategy_id ,
3047 unit_number ,
3048 ship_to_location_id ,
3049 from_cost_group_id ,
3050 to_cost_group_id ,
3051 lpn_id ,
3052 to_lpn_id ,
3053 inspection_status ,
3054 pick_methodology_id ,
3055 container_item_id ,
3056 carton_grouping_id ,
3057 wms_process_flag ,
3058 pick_slip_number ,
3059 pick_slip_date ,
3060 ship_set_id ,
3061 ship_model_id ,
3062 model_quantity ,
3063 required_quantity
3064 FROM mtl_txn_request_lines
3065 WHERE line_id = p_line_id;
3066 BEGIN
3067 debug_print( 'p_line_id ' || p_line_id);
3068 IF (p_line_id IS NOT NULL AND p_line_id <> fnd_api.g_miss_num ) THEN
3072 l_trolin_rec.attribute1 := l_implicit_rec.attribute1;
3069 -- Loop over fetched records
3070 FOR l_implicit_rec IN l_trolin_csr
3071 LOOP
3073 l_trolin_rec.attribute10 := l_implicit_rec.attribute10;
3074 l_trolin_rec.attribute11 := l_implicit_rec.attribute11;
3075 l_trolin_rec.attribute12 := l_implicit_rec.attribute12;
3076 l_trolin_rec.attribute13 := l_implicit_rec.attribute13;
3077 l_trolin_rec.attribute14 := l_implicit_rec.attribute14;
3078 l_trolin_rec.attribute15 := l_implicit_rec.attribute15;
3079 l_trolin_rec.attribute2 := l_implicit_rec.attribute2;
3080 l_trolin_rec.attribute3 := l_implicit_rec.attribute3;
3081 l_trolin_rec.attribute4 := l_implicit_rec.attribute4;
3082 l_trolin_rec.attribute5 := l_implicit_rec.attribute5;
3083 l_trolin_rec.attribute6 := l_implicit_rec.attribute6;
3084 l_trolin_rec.attribute7 := l_implicit_rec.attribute7;
3085 l_trolin_rec.attribute8 := l_implicit_rec.attribute8;
3086 l_trolin_rec.attribute9 := l_implicit_rec.attribute9;
3087 l_trolin_rec.attribute_category := l_implicit_rec.attribute_category;
3088 l_trolin_rec.created_by := l_implicit_rec.created_by;
3089 l_trolin_rec.creation_date := l_implicit_rec.creation_date;
3090 l_trolin_rec.date_required := l_implicit_rec.date_required;
3091 l_trolin_rec.from_locator_id := l_implicit_rec.from_locator_id;
3092 l_trolin_rec.from_subinventory_code := l_implicit_rec.from_subinventory_code;
3093 l_trolin_rec.from_subinventory_id := l_implicit_rec.from_subinventory_id;
3094 l_trolin_rec.header_id := l_implicit_rec.header_id;
3095 l_trolin_rec.inventory_item_id := l_implicit_rec.inventory_item_id;
3096 l_trolin_rec.last_updated_by := l_implicit_rec.last_updated_by;
3097 l_trolin_rec.last_update_date := l_implicit_rec.last_update_date;
3098 l_trolin_rec.last_update_login := l_implicit_rec.last_update_login;
3099 l_trolin_rec.line_id := l_implicit_rec.line_id;
3100 l_trolin_rec.line_number := l_implicit_rec.line_number;
3101 l_trolin_rec.line_status := l_implicit_rec.line_status;
3102 l_trolin_rec.lot_number := l_implicit_rec.lot_number;
3103 l_trolin_rec.organization_id := l_implicit_rec.organization_id;
3104 l_trolin_rec.program_application_id := l_implicit_rec.program_application_id;
3105 l_trolin_rec.program_id := l_implicit_rec.program_id;
3106 l_trolin_rec.program_update_date := l_implicit_rec.program_update_date;
3107 l_trolin_rec.project_id := l_implicit_rec.project_id;
3108 l_trolin_rec.quantity := l_implicit_rec.quantity;
3109 l_trolin_rec.quantity_delivered := l_implicit_rec.quantity_delivered;
3110 l_trolin_rec.quantity_detailed := l_implicit_rec.quantity_detailed;
3111 l_trolin_rec.reason_id := l_implicit_rec.reason_id;
3112 l_trolin_rec.REFERENCE := l_implicit_rec.REFERENCE;
3113 l_trolin_rec.reference_id := l_implicit_rec.reference_id;
3114 l_trolin_rec.reference_type_code := l_implicit_rec.reference_type_code;
3115 l_trolin_rec.request_id := l_implicit_rec.request_id;
3116 l_trolin_rec.revision := l_implicit_rec.revision;
3117 l_trolin_rec.serial_number_end := l_implicit_rec.serial_number_end;
3118 l_trolin_rec.serial_number_start := l_implicit_rec.serial_number_start;
3119 l_trolin_rec.status_date := l_implicit_rec.status_date;
3120 l_trolin_rec.task_id := l_implicit_rec.task_id;
3121 l_trolin_rec.to_account_id := l_implicit_rec.to_account_id;
3122 l_trolin_rec.to_locator_id := l_implicit_rec.to_locator_id;
3123 l_trolin_rec.to_subinventory_code := l_implicit_rec.to_subinventory_code;
3124 l_trolin_rec.to_subinventory_id := l_implicit_rec.to_subinventory_id;
3125 l_trolin_rec.transaction_header_id := l_implicit_rec.transaction_header_id;
3126 l_trolin_rec.uom_code := l_implicit_rec.uom_code;
3127 l_trolin_rec.transaction_type_id := l_implicit_rec.transaction_type_id;
3128 l_trolin_rec.transaction_source_type_id := l_implicit_rec.transaction_source_type_id;
3129 l_trolin_rec.txn_source_id := l_implicit_rec.txn_source_id;
3130 l_trolin_rec.txn_source_line_id := l_implicit_rec.txn_source_line_id;
3131 l_trolin_rec.txn_source_line_detail_id := l_implicit_rec.txn_source_line_detail_id;
3132 l_trolin_rec.to_organization_id := l_implicit_rec.to_organization_id;
3133 l_trolin_rec.primary_quantity := l_implicit_rec.primary_quantity;
3134 l_trolin_rec.pick_strategy_id := l_implicit_rec.pick_strategy_id;
3138 l_trolin_rec.from_cost_group_id := l_implicit_rec.from_cost_group_id;
3135 l_trolin_rec.put_away_strategy_id := l_implicit_rec.put_away_strategy_id;
3136 l_trolin_rec.unit_number := l_implicit_rec.unit_number;
3137 l_trolin_rec.ship_to_location_id := l_implicit_rec.ship_to_location_id;
3139 l_trolin_rec.to_cost_group_id := l_implicit_rec.to_cost_group_id;
3140 l_trolin_rec.lpn_id := l_implicit_rec.lpn_id;
3141 l_trolin_rec.to_lpn_id := l_implicit_rec.to_lpn_id;
3142 l_trolin_rec.inspection_status := l_implicit_rec.inspection_status;
3143 l_trolin_rec.pick_methodology_id := l_implicit_rec.pick_methodology_id;
3144 l_trolin_rec.container_item_id := l_implicit_rec.container_item_id;
3145 l_trolin_rec.carton_grouping_id := l_implicit_rec.carton_grouping_id;
3146 l_trolin_rec.wms_process_flag := l_implicit_rec.wms_process_flag;
3147 l_trolin_rec.pick_slip_number := l_implicit_rec.pick_slip_number;
3148 l_trolin_rec.pick_slip_date := l_implicit_rec.pick_slip_date;
3149 l_trolin_rec.ship_set_id := l_implicit_rec.ship_set_id;
3150 l_trolin_rec.ship_model_id := l_implicit_rec.ship_model_id;
3151 l_trolin_rec.model_quantity := l_implicit_rec.model_quantity;
3152 l_trolin_rec.required_quantity := l_implicit_rec.required_quantity;
3153 l_trolin_tbl(l_trolin_tbl.COUNT + 1) := l_trolin_rec;
3154 END LOOP;
3155 END IF;
3156 IF (p_line_id IS NOT NULL AND p_line_id <> fnd_api.g_miss_num ) AND (l_trolin_tbl.COUNT = 0) THEN
3157 debug_print('no data found');
3158 RAISE NO_DATA_FOUND;
3159 END IF;
3160 -- Return fetched table
3161 RETURN l_trolin_tbl;
3162 EXCEPTION
3163 WHEN fnd_api.g_exc_unexpected_error THEN
3164 RAISE fnd_api.g_exc_unexpected_error;
3165 WHEN OTHERS THEN
3166 RAISE fnd_api.g_exc_unexpected_error;
3167 END query_rows;
3168
3169 -------------------------------------------------------------------------------------------------------------------
3170 /*PROCEDURE delete_transaction()
3171 This procedure checks for lot/serial control-deletes MTLT, MSNT,
3172 Unmarks the serials, checks if a task record exists in wms_dispatched_tasks and deletes it.
3173 */
3174 -------------------------------------------------------------------------------------------------------------------
3175 PROCEDURE delete_transaction( x_return_status OUT NOCOPY VARCHAR2 ,
3176 x_msg_data OUT NOCOPY VARCHAR2 ,
3177 x_msg_count OUT NOCOPY NUMBER ,
3178 p_transaction_temp_id NUMBER ,
3179 p_update_parent BOOLEAN ) IS
3180
3181 l_inventory_item_id NUMBER;
3182 l_lot_control_code NUMBER;
3183 l_serial_control_code NUMBER;
3184 l_fm_serial_number VARCHAR2(30);
3185 l_to_serial_number VARCHAR2(30);
3186 l_unmarked_count NUMBER := 0;
3187 l_parent_line_id NUMBER;
3188 l_child_txn_qty NUMBER;
3189 l_child_pri_qty NUMBER;
3190 l_child_uom VARCHAR2(3);
3191 exc_not_deleted EXCEPTION;
3192 l_msnt_count NUMBER;
3193 l_wdt_count NUMBER;
3194 l_msn_count NUMBER;
3195 l_debug NUMBER;
3196 CURSOR c_item_info
3197 IS
3198 SELECT msi.inventory_item_id ,
3199 msi.lot_control_code ,
3200 msi.serial_number_control_code,
3201 mmtt.parent_line_id
3202 FROM mtl_system_items msi,
3203 mtl_material_transactions_temp mmtt
3204 WHERE mmtt.transaction_temp_id = p_transaction_temp_id
3205 AND msi.inventory_item_id = mmtt.inventory_item_id
3206 AND msi.organization_id = mmtt.organization_id;
3207 BEGIN
3208 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3209 x_return_status := fnd_api.g_ret_sts_success;
3210 SAVEPOINT deltxn;
3211 IF l_debug = 1 THEN
3212 debug_print( 'Cleaning up MMTT, MTLT and MSNT for Txn Temp ID = ' || p_transaction_temp_id);
3213 END IF;
3214 OPEN c_item_info;
3215 FETCH c_item_info
3216 INTO l_inventory_item_id ,
3217 l_lot_control_code ,
3218 l_serial_control_code,
3219 l_parent_line_id;
3220 CLOSE c_item_info;
3221 IF l_debug = 1 THEN
3222 debug_print( 'Item ID = ' || l_inventory_item_id);
3223 debug_print( 'Lot Control = ' || l_lot_control_code);
3224 debug_print( 'Serial Control = ' || l_serial_control_code);
3225 debug_print( 'Parent Line ID = ' || l_parent_line_id);
3226 END IF;
3227 IF l_parent_line_id IS NOT NULL AND p_update_parent THEN
3228 IF l_debug = 1 THEN
3229 debug_print( 'Child Record... Updating the Parent: TxnTempID = ' || l_parent_line_id);
3230 END IF;
3231 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3232 IF l_debug = 1 THEN
3233 debug_print('Error occurred while updating parent line in MMTT');
3234 END IF;
3235 ROLLBACK TO deltxn;
3236 RAISE exc_not_deleted;
3237 END IF;
3238 END IF;
3242 SELECT count (*)
3239 -- Unmarking and Deleting all the Serials associated with the Transaction
3240 IF l_serial_control_code IN(2, 5) THEN --If serial controlled
3241 IF l_lot_control_code = 2 THEN -- If lot controlled also
3243 INTO l_msn_count
3244 FROM mtl_serial_numbers
3245 WHERE group_mark_id IN
3246 (SELECT serial_transaction_temp_id
3247 FROM mtl_transaction_lots_temp
3248 WHERE transaction_temp_id = p_transaction_temp_id
3249 );
3250 IF l_msn_count > 0 THEN
3251 UPDATE mtl_serial_numbers
3252 SET group_mark_id = NULL,
3253 line_mark_id = NULL,
3254 lot_line_mark_id = NULL
3255 WHERE group_mark_id IN
3256 (SELECT serial_transaction_temp_id
3257 FROM mtl_transaction_lots_temp
3258 WHERE transaction_temp_id = p_transaction_temp_id
3259 );
3260 l_unmarked_count := SQL%ROWCOUNT;
3261 IF SQL%ROWCOUNT = 0 THEN
3262 IF l_debug = 1 THEN
3263 debug_print ( 'Error updating MSN ');
3264 END IF;
3265 ROLLBACK TO deltxn;
3266 RAISE exc_not_deleted;
3267 END IF;
3268 END IF;
3269 SELECT count(*)
3270 INTO l_msnt_count
3271 FROM mtl_serial_numbers_temp
3272 WHERE transaction_temp_id IN
3273 (SELECT serial_transaction_temp_id
3274 FROM mtl_transaction_lots_temp
3275 WHERE transaction_temp_id = p_transaction_temp_id
3276 );
3277 IF l_msnt_count > 0 THEN
3278 DELETE mtl_serial_numbers_temp
3279 WHERE transaction_temp_id IN
3280 (SELECT serial_transaction_temp_id
3281 FROM mtl_transaction_lots_temp
3282 WHERE transaction_temp_id = p_transaction_temp_id
3283 );
3284 IF SQL%ROWCOUNT = 0 THEN
3285 IF l_debug = 1 THEN
3286 debug_print ( 'Error deleting MSNT ');
3287 END IF;
3288 ROLLBACK TO deltxn;
3289 RAISE exc_not_deleted;
3290 END IF;
3291 END IF;
3292 ELSE -- only serial controlled but not lot controlled.
3293 SELECT count(*)
3294 INTO l_msn_count
3295 FROM mtl_serial_numbers
3296 WHERE group_mark_id = p_transaction_temp_id ;
3297 IF l_msn_count > 0 THEN
3298 UPDATE mtl_serial_numbers
3299 SET group_mark_id = NULL,
3300 line_mark_id = NULL,
3301 lot_line_mark_id = NULL
3302 WHERE group_mark_id = p_transaction_temp_id ;
3303 l_unmarked_count := SQL%ROWCOUNT;
3304 IF SQL%ROWCOUNT = 0 THEN
3305 IF l_debug = 1 THEN
3306 debug_print ( 'Error updating MSN ');
3307 END IF;
3308 ROLLBACK TO deltxn;
3309 RAISE exc_not_deleted;
3310 END IF;
3311 END IF;
3312 SELECT count (*)
3313 INTO l_msnt_count
3314 FROM mtl_serial_numbers_temp
3315 WHERE transaction_temp_id = p_transaction_temp_id;
3316 IF l_msnt_count > 0 THEN
3317 DELETE mtl_serial_numbers_temp
3318 WHERE transaction_temp_id = p_transaction_temp_id;
3319 IF SQL%ROWCOUNT = 0 THEN
3320 IF l_debug = 1 THEN
3321 debug_print ( 'Error deleting MSNT ');
3322 END IF;
3323 ROLLBACK TO deltxn;
3324 RAISE exc_not_deleted;
3325 END IF;
3326 END IF;
3327 END IF;
3328 IF l_debug = 1 THEN
3329 debug_print( 'Serials unmarked in MSN = ' || l_unmarked_count);
3330 debug_print( 'Records deleted in MSNT = ' || SQL%ROWCOUNT);
3331 END IF;
3332 END IF;
3333 -- Deleting all the Lots associated with the Transaction
3334 IF l_lot_control_code = 2 THEN
3335 DELETE mtl_transaction_lots_temp
3336 WHERE transaction_temp_id = p_transaction_temp_id;
3340 END IF;
3337 IF SQL%ROWCOUNT = 0 THEN
3338 IF l_debug = 1 THEN
3339 debug_print ( 'Error deleting MTLT ');
3341 ROLLBACK TO deltxn;
3342 RAISE exc_not_deleted;
3343 END IF;
3344 IF l_debug = 1 THEN
3345 debug_print( 'Records deleted in MTLT = ' || SQL%ROWCOUNT);
3346 END IF;
3347 END IF;
3348 SELECT count (*)
3349 INTO l_wdt_count
3350 FROM wms_dispatched_tasks
3351 WHERE transaction_temp_id = p_transaction_temp_id;
3352 IF l_wdt_count >0 THEN
3353 -- Deleting the Task
3354 DELETE wms_dispatched_tasks WHERE transaction_temp_id = p_transaction_temp_id;
3355 IF l_debug = 1 THEN
3356 debug_print( 'Records deleted in WDT = ' || SQL%ROWCOUNT);
3357 END IF;
3358 IF SQL%ROWCOUNT = 0 THEN
3359 debug_print ( 'Error deleting WDT ');
3360 ROLLBACK TO deltxn;
3361 RAISE exc_not_deleted;
3362 END IF;
3363 END IF;
3364 -- Deleting the Transaction
3365 DELETE mtl_material_transactions_temp
3366 WHERE transaction_temp_id = p_transaction_temp_id;
3367 IF SQL%ROWCOUNT = 0 THEN
3368 IF l_debug = 1 THEN
3369 debug_print ( 'Error deleting MMTT ');
3370 END IF;
3371 ROLLBACK TO deltxn;
3372 RAISE exc_not_deleted;
3373 END IF;
3374 IF l_debug = 1 THEN
3375 debug_print( 'Records deleted in MMTT = ' || SQL%ROWCOUNT);
3376 END IF;
3377 EXCEPTION
3378 WHEN exc_not_deleted THEN
3379 IF l_debug =1 THEN
3380 debug_print('In the exception for could not delete a record. Returning staus as E');
3381 END IF;
3382 x_return_status := 'E';
3383 WHEN OTHERS THEN
3384 x_return_status := fnd_api.g_ret_sts_unexp_error;
3385 IF l_debug = 1 THEN
3386 debug_print( 'Exception Occurred = ' || SQLERRM);
3387 END IF;
3388 ROLLBACK TO deltxn;
3389 END delete_transaction;
3390
3391 -------------------------------------------------------------------------------------------------------------------
3392 /*PROCEDURE delete_details()
3393 This procedure calls inv_reservation_pub.update_reservation() to udpate/delete reservation and subsequently
3394 calls delete_transactions.
3395 */
3396 -------------------------------------------------------------------------------------------------------------------
3397 PROCEDURE delete_details( p_transaction_temp_id IN NUMBER ,
3398 p_move_order_line_id IN NUMBER ,
3399 p_reservation_id IN NUMBER ,
3400 p_transaction_quantity IN NUMBER ,
3401 p_primary_trx_qty IN NUMBER ,
3402 x_return_status OUT NOCOPY VARCHAR2 ,
3403 x_msg_count OUT NOCOPY NUMBER ,
3404 x_msg_data OUT NOCOPY VARCHAR2 ) IS
3405
3406 l_mtl_reservation_tbl inv_reservation_global.mtl_reservation_tbl_type;
3407 l_mtl_reservation_rec inv_reservation_global.mtl_reservation_rec_type;
3408 l_mtl_reservation_tbl_count NUMBER;
3409 l_original_serial_number inv_reservation_global.serial_number_tbl_type;
3410 l_to_serial_number inv_reservation_global.serial_number_tbl_type;
3411 l_error_code NUMBER;
3412 l_count NUMBER;
3413 l_success BOOLEAN;
3414 l_umconvert_trans_quantity NUMBER := 0;
3415 l_mmtt_rec inv_mo_line_detail_util.g_mmtt_rec;
3416 l_primary_uom VARCHAR2(10);
3417 l_ato_item NUMBER := 0;
3418 l_debug NUMBER;
3419 l_rsv_detailed_qty NUMBER;
3420 l_rsv_reservation_qty NUMBER;
3421 l_rsv_pri_reservation_qty NUMBER;
3422 g_retain_ato_profile VARCHAR2(1) := fnd_profile.VALUE('WSH_RETAIN_ATO_RESERVATIONS');
3423 exc_not_deleted EXCEPTION;
3424 BEGIN
3425 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3426 x_return_status := fnd_api.g_ret_sts_success;
3427 SAVEPOINT delete_details;
3428 IF (l_debug = 1) THEN
3429 debug_print( 'Transaction Temp ID = ' || p_transaction_temp_id);
3430 debug_print( 'Move Order Line ID = ' || p_move_order_line_id);
3431 debug_print( 'Transaction Qty = ' || p_transaction_quantity);
3432 debug_print( 'Reservation ID = ' || p_reservation_id);
3433 END IF;
3434 IF p_reservation_id IS NOT NULL THEN
3435 l_mtl_reservation_rec.reservation_id := p_reservation_id;
3436 inv_reservation_pub.query_reservation( p_api_version_number => 1.0 ,
3437 x_return_status => x_return_status ,
3438 x_msg_count => x_msg_count ,
3439 x_msg_data => x_msg_data ,
3440 p_query_input => l_mtl_reservation_rec ,
3441 x_mtl_reservation_tbl => l_mtl_reservation_tbl ,
3442 x_mtl_reservation_tbl_count => l_mtl_reservation_tbl_count ,
3443 x_error_code => l_error_code );
3444
3445 IF l_debug = 1 THEN
3446 debug_print( 'x_return_status = ' || x_return_status);
3447 debug_print( 'l_error_code = ' || l_error_code);
3448 debug_print( 'l_mtl_reservation_tbl_count = ' || l_mtl_reservation_tbl_count);
3449 END IF;
3450 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3451 IF l_debug = 1 THEN
3455 RAISE exc_not_deleted ;
3452 debug_print('delete_mo: Error occurred while deleting MMTT');
3453 END IF;
3454 ROLLBACK TO delete_details;
3456 END IF;
3457 IF l_mtl_reservation_tbl_count > 0 THEN
3458 -- If reservations exist, check if the item is an ATO Item
3459 -- only if the profile WSH_RETAIN_ATO_RESERVATIONS = 'Y'
3460 IF g_retain_ato_profile = 'Y' THEN
3461 IF l_debug = 1 THEN
3462 debug_print('g_retain_ato_profile = Y');
3463 END IF;
3464 BEGIN
3465 SELECT 1,
3466 primary_uom_code
3467 INTO l_ato_item,
3468 l_primary_uom
3469 FROM mtl_system_items
3470 WHERE replenish_to_order_flag = 'Y'
3471 AND bom_item_type = 4
3472 AND inventory_item_id = l_mtl_reservation_tbl(1).inventory_item_id
3473 AND organization_id = l_mtl_reservation_tbl(1).organization_id;
3474 EXCEPTION
3475 WHEN OTHERS THEN
3476 l_ato_item := 0;
3477 END;
3478 END IF;
3479 IF l_debug = 1 THEN
3480 debug_print( 'l_ato_item = ' || l_ato_item);
3481 END IF;
3482 l_rsv_detailed_qty := NVL(l_mtl_reservation_tbl(1).detailed_quantity,0);
3483 l_rsv_reservation_qty := NVL(l_mtl_reservation_tbl(1).reservation_quantity,0);
3484 l_rsv_pri_reservation_qty := NVL(l_mtl_reservation_tbl(1).primary_reservation_quantity,0);
3485 IF l_ato_item = 1 THEN
3486 IF l_debug = 1 THEN
3487 debug_print('l_ato_item = 1');
3488 END IF;
3489 -- If item is ato item, reduce the detailed quantity by the transaction
3490 -- quantity and retain the reservation. Convert to primary uom before
3491 -- reducing detailed quantity.
3492 l_mmtt_rec := inv_mo_line_detail_util.query_row(p_transaction_temp_id);
3493 l_umconvert_trans_quantity:= p_transaction_quantity;
3494 IF l_mmtt_rec.inventory_item_id IS NOT NULL AND l_mmtt_rec.transaction_uom IS NOT NULL THEN
3495 IF l_debug = 1 THEN
3496 debug_print( 'UOM Convert = ');
3497 END IF;
3498 l_umconvert_trans_quantity := inv_convert.inv_um_convert( item_id => l_mmtt_rec.inventory_item_id ,
3499 PRECISION => NULL ,
3500 from_quantity => p_transaction_quantity ,
3501 from_unit => l_mmtt_rec.transaction_uom ,
3502 to_unit => l_primary_uom ,
3503 from_name => NULL ,
3504 to_name => NULL);
3505 END IF;
3506 l_mtl_reservation_rec := l_mtl_reservation_tbl(1);
3507 IF(l_rsv_detailed_qty > ABS(l_umconvert_trans_quantity)) THEN
3508 l_mtl_reservation_tbl(1).detailed_quantity := l_rsv_detailed_qty - ABS(l_umconvert_trans_quantity);
3509 ELSE
3510 l_mtl_reservation_tbl(1).detailed_quantity := 0;
3511 END IF;
3512 IF l_debug = 1 THEN
3513 debug_print( 'call inv_reservation_pub.update_reservation = ');
3514 END IF;
3515 inv_reservation_pub.update_reservation( p_api_version_number => 1.0 ,
3516 x_return_status => x_return_status ,
3517 x_msg_count => x_msg_count ,
3518 x_msg_data => x_msg_data ,
3519 p_original_rsv_rec => l_mtl_reservation_rec ,
3520 p_to_rsv_rec => l_mtl_reservation_tbl(1) ,
3521 p_original_serial_number => l_original_serial_number ,
3522 p_to_serial_number => l_to_serial_number);
3523 IF l_debug = 1 THEN
3524 debug_print('x_return_status' || x_return_status);
3525 END IF;
3526 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3527 IF l_debug = 1 THEN
3528 debug_print('delete_mo: Error occurred while updating reservations');
3529 END IF;
3530 ROLLBACK TO delete_details;
3531 RAISE exc_not_deleted ;
3532 END IF;
3533 ELSE
3534 l_mtl_reservation_rec := l_mtl_reservation_tbl(1);
3535 l_mmtt_rec := inv_mo_line_detail_util.query_row(p_transaction_temp_id);
3536 IF l_debug = 1 THEN
3537 debug_print( 'Allocation UOM = ' || l_mmtt_rec.transaction_uom);
3541 l_umconvert_trans_quantity := inv_convert.inv_um_convert( item_id => l_mmtt_rec.inventory_item_id ,
3538 debug_print( 'Reservation UOM = ' || l_mtl_reservation_rec.reservation_uom_code);
3539 END IF;
3540 IF l_mmtt_rec.transaction_uom <> l_mtl_reservation_rec.reservation_uom_code THEN
3542 PRECISION => NULL ,
3543 from_quantity => ABS(p_transaction_quantity) ,
3544 from_unit => l_mmtt_rec.transaction_uom ,
3545 to_unit => l_mtl_reservation_rec.reservation_uom_code ,
3546 from_name => NULL ,
3547 to_name => NULL);
3548 ELSE
3549 l_umconvert_trans_quantity := ABS(p_transaction_quantity);
3550 END IF;
3551 IF l_debug = 1 THEN
3552 debug_print( 'After UOM Conversion TxnQty = ' || l_umconvert_trans_quantity);
3553 END IF;
3554 IF(l_rsv_detailed_qty > ABS(p_transaction_quantity)) THEN
3555 l_mtl_reservation_tbl(1).detailed_quantity := l_rsv_detailed_qty - ABS(p_transaction_quantity);
3556 ELSE
3557 l_mtl_reservation_tbl(1).detailed_quantity := 0;
3558 END IF;
3559 IF(l_rsv_reservation_qty > ABS(l_umconvert_trans_quantity)) THEN
3560 l_mtl_reservation_tbl(1).reservation_quantity := l_rsv_reservation_qty - ABS(l_umconvert_trans_quantity);
3561 ELSE
3562 l_mtl_reservation_tbl(1).reservation_quantity := 0;
3563 END IF;
3564 IF(l_rsv_pri_reservation_qty > ABS(p_primary_trx_qty)) THEN
3565 l_mtl_reservation_tbl(1).primary_reservation_quantity := l_rsv_pri_reservation_qty - ABS(p_primary_trx_qty);
3566 ELSE
3567 l_mtl_reservation_tbl(1).primary_reservation_quantity := 0;
3568 END IF;
3569 inv_reservation_pub.update_reservation( p_api_version_number => 1.0 ,
3570 x_return_status => x_return_status ,
3571 x_msg_count => x_msg_count ,
3572 x_msg_data => x_msg_data ,
3573 p_original_rsv_rec => l_mtl_reservation_rec ,
3574 p_to_rsv_rec => l_mtl_reservation_tbl(1) ,
3575 p_original_serial_number => l_original_serial_number ,
3576 p_to_serial_number => l_to_serial_number);
3577
3578 IF l_debug = 1 THEN
3579 debug_print( 'x_return_status from inv_reservation_pub.update_reservation ' || x_return_status);
3580 END IF;
3581 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3582 IF l_debug = 1 THEN
3583 debug_print('delete_mo: Error occurred while updating reservations');
3584 END IF;
3585 ROLLBACK TO delete_details;
3586 RAISE exc_not_deleted ;
3587 END IF;
3588 END IF; -- reservation count > 0
3589 END IF; -- ato item check
3590 END IF;
3591 IF l_debug = 1 THEN
3592 debug_print( 'call delete_transaction ' );
3593 END IF;
3594 delete_transaction( x_return_status => x_return_status ,
3595 x_msg_data => x_msg_data ,
3596 x_msg_count => x_msg_count ,
3597 p_transaction_temp_id => p_transaction_temp_id ,
3598 p_update_parent => FALSE);
3599 IF l_debug = 1 THEN
3600 debug_print( 'x_return_status ' || x_return_status);
3601 END IF;
3602 IF x_return_status = fnd_api.g_ret_sts_error THEN
3603 IF l_debug = 1 THEN
3604 debug_print('delete_mo: Error occurred while deleting MMTT');
3605 END IF;
3606 ROLLBACK TO delete_details;
3607 RAISE exc_not_deleted ;
3608 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
3609 IF l_debug = 1 THEN
3610 debug_print('delete_mo: Error occurred while deleting MMTT');
3611 END IF;
3612 ROLLBACK TO delete_details;
3613 END IF;
3614 EXCEPTION
3615 WHEN exc_not_deleted THEN
3616 IF l_debug =1 THEN
3617 debug_print('In the exception for could not delete a record. Returning staus as E');
3618 END IF;
3619 x_return_status := 'E';
3620 WHEN OTHERS THEN
3621 x_return_status := fnd_api.g_ret_sts_unexp_error;
3622 ROLLBACK TO delete_details;
3623 END delete_details;
3624
3625 -------------------------------------------------------------------------------------------------------------------
3626
3627 PROCEDURE backorder_source( x_return_status OUT NOCOPY VARCHAR2 ,
3628 x_msg_count OUT NOCOPY NUMBER ,
3629 x_msg_data OUT NOCOPY VARCHAR2 ,
3630 p_move_order_type NUMBER ,
3631 p_mo_line_rec inv_move_order_pub.trolin_rec_type ,
3632 p_qty_to_backorder NUMBER ) IS
3633
3634 l_shipping_attr wsh_interface.changedattributetabtype;
3635 l_released_status VARCHAR2(1);
3636 l_delivery_detail_id NUMBER;
3637 l_source_header_id NUMBER;
3638 l_source_line_id NUMBER;
3642 CURSOR c_wsh_info
3639 l_qty_to_backorder NUMBER := 0;
3640 l_debug NUMBER;
3641 exc_not_deleted EXCEPTION;
3643 IS
3644 SELECT delivery_detail_id,
3645 oe_header_id ,
3646 oe_line_id ,
3647 released_status
3648 FROM wsh_inv_delivery_details_v
3649 WHERE move_order_line_id = p_mo_line_rec.line_id
3650 AND move_order_line_id IS NOT NULL
3651 AND released_status = 'S';
3652 BEGIN
3653 SAVEPOINT backorder_source;
3654 x_return_status := fnd_api.g_ret_sts_success;
3655 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3656 l_qty_to_backorder := p_qty_to_backorder;
3657 IF l_qty_to_backorder < 0 THEN
3658 l_qty_to_backorder := 0;
3659 END IF;
3660 IF l_debug = 1 THEN
3661 debug_print('l_qty_to_backorder' || l_qty_to_backorder);
3662 END IF;
3663 IF p_move_order_type = inv_globals.g_move_order_pick_wave THEN
3664 IF l_debug = 1 THEN
3665 debug_print('in mo type pick wave' );
3666 END IF;
3667 OPEN c_wsh_info;
3668 FETCH c_wsh_info
3669 INTO l_delivery_detail_id,
3670 l_source_header_id ,
3671 l_source_line_id ,
3672 l_released_status;
3673 IF c_wsh_info%NOTFOUND THEN
3674 CLOSE c_wsh_info;
3675 IF l_debug = 1 THEN
3676 debug_print('NOTFOUND c_wsh_info' );
3677 END IF;
3678 RAISE fnd_api.g_exc_error;
3679 END IF;
3680 CLOSE c_wsh_info;
3681 IF l_debug = 1 THEN
3682 debug_print('finished fetching' );
3683 END IF;
3684 --Call Update_Shipping_Attributes to backorder detail line
3685 l_shipping_attr(1).source_header_id := l_source_header_id;
3686 l_shipping_attr(1).source_line_id := l_source_line_id;
3687 l_shipping_attr(1).ship_from_org_id := p_mo_line_rec.organization_id;
3688 l_shipping_attr(1).released_status := l_released_status;
3689 l_shipping_attr(1).delivery_detail_id := l_delivery_detail_id;
3690 l_shipping_attr(1).action_flag := 'B';
3691 l_shipping_attr(1).cycle_count_quantity := l_qty_to_backorder;
3692 l_shipping_attr(1).subinventory := p_mo_line_rec.from_subinventory_code;
3693 l_shipping_attr(1).locator_id := p_mo_line_rec.from_locator_id;
3694 IF (l_debug = 1) THEN
3695 debug_print('Calling Update Shipping Attributes');
3696 debug_print( ' Source Header ID = ' || l_shipping_attr(1).source_header_id);
3697 debug_print( ' Source Line ID = ' || l_shipping_attr(1).source_line_id);
3698 debug_print( ' Ship From Org ID = ' || l_shipping_attr(1).ship_from_org_id);
3699 debug_print( ' Released Status = ' || l_shipping_attr(1).released_status);
3700 debug_print( ' Delivery Detail ID = ' || l_shipping_attr(1).delivery_detail_id);
3701 debug_print( ' Action Flag = ' || l_shipping_attr(1).action_flag);
3702 debug_print( ' Cycle Count Qty = ' || l_shipping_attr(1).cycle_count_quantity);
3703 debug_print( ' Subinventory = ' || l_shipping_attr(1).subinventory);
3704 debug_print( ' Locator ID = ' || l_shipping_attr(1).locator_id);
3705 END IF;
3706 wsh_interface.update_shipping_attributes( p_source_code => 'INV' ,
3707 p_changed_attributes => l_shipping_attr ,
3708 x_return_status => x_return_status );
3709 IF (l_debug = 1) THEN
3710 debug_print( 'Updated Shipping Attributes - Return Status = ' || x_return_status);
3711 END IF;
3712 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3713 ROLLBACK TO backorder_source;
3714 RAISE exc_not_deleted ;
3715 END IF;
3716 ELSIF p_move_order_type = inv_globals.g_move_order_mfg_pick THEN
3717 IF l_debug = 1 THEN
3718 debug_print('Calling Unallocate WIP Material');
3719 debug_print( ' WIP Entity ID = ' || p_mo_line_rec.txn_source_id);
3720 debug_print( ' Operation Seq Num = ' || p_mo_line_rec.txn_source_line_id);
3721 debug_print( ' Inventory Item ID = ' || p_mo_line_rec.inventory_item_id);
3722 debug_print( ' Repetitive Sch ID = ' || p_mo_line_rec.reference_id);
3723 debug_print( ' Primary Qty = ' || l_qty_to_backorder);
3724 END IF;
3725 wip_picking_pub.unallocate_material( x_return_status => x_return_status ,
3726 x_msg_data => x_msg_data ,
3727 p_wip_entity_id => p_mo_line_rec.txn_source_id ,
3728 p_operation_seq_num => p_mo_line_rec.txn_source_line_id ,
3729 p_inventory_item_id => p_mo_line_rec.inventory_item_id ,
3730 p_repetitive_schedule_id => p_mo_line_rec.reference_id ,
3731 p_primary_quantity => l_qty_to_backorder );
3732
3733 IF (l_debug = 1) THEN
3734 debug_print( 'Unallocated WIP Material - Return Status = ' || x_return_status);
3735 END IF;
3739 END IF;
3736 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3737 ROLLBACK TO backorder_source;
3738 RAISE exc_not_deleted ;
3740 END IF;
3741 EXCEPTION
3742 WHEN exc_not_deleted THEN
3743 IF l_debug =1 THEN
3744 debug_print('In the exception for could not delete a record. Returning staus as E');
3745 END IF;
3746 x_return_status := 'E';
3747 WHEN OTHERS THEN
3748 x_return_status := fnd_api.g_ret_sts_unexp_error;
3749 ROLLBACK TO backorder_source;
3750 END backorder_source;
3751
3752 -------------------------------------------------------------------------------------------------------------------
3753 /*PROCEDURE backorder()
3754 This procedure calls wsh_interface.update_shipping_attributes() for MO of type pick wave, else calls
3755 wip_picking_pub.unallocate_material for MO of type WIP
3756 */
3757 -------------------------------------------------------------------------------------------------------------------
3758 PROCEDURE backorder( p_line_id IN NUMBER ,
3759 p_transaction_temp_id IN NUMBER ,
3760 x_return_status OUT NOCOPY VARCHAR2 ,
3761 x_msg_count OUT NOCOPY NUMBER ,
3762 x_msg_data OUT NOCOPY VARCHAR2 ) IS
3763
3764 l_mo_line_rec inv_move_order_pub.trolin_rec_type;
3765 l_mold_tbl inv_mo_line_detail_util.g_mmtt_tbl_type;
3766 l_mo_type NUMBER;
3767 l_allow_backordering VARCHAR2(1) := 'Y';
3768 l_debug NUMBER;
3769 l_transaction_quantity NUMBER;
3770 exc_not_deleted EXCEPTION;
3771 CURSOR c_allow_backordering
3772 IS
3773 SELECT 'N'
3774 FROM DUAL
3775 WHERE EXISTS
3776 (SELECT 1
3777 FROM wms_dispatched_tasks wdt,
3778 mtl_material_transactions_temp mmtt
3779 WHERE mmtt.move_order_line_id = l_mo_line_rec.line_id
3780 AND wdt.transaction_temp_id = nvl(mmtt.parent_line_id, mmtt.transaction_temp_id)
3781 AND wdt.status IN (4,9)
3782 );
3783 CURSOR c_mo_type
3784 IS
3785 SELECT mtrh.move_order_type
3786 FROM mtl_txn_request_headers mtrh,
3787 mtl_txn_request_lines mtrl
3788 WHERE mtrl.line_id = l_mo_line_rec.line_id
3789 AND mtrh.header_id = mtrl.header_id;
3790 CURSOR c_mmtt_info
3791 IS
3792 SELECT mmtt.transaction_temp_id ,
3793 ABS(mmtt.primary_quantity) primary_quantity ,
3794 ABS(mmtt.transaction_quantity) transaction_quantity ,
3795 mmtt.reservation_id
3796 FROM mtl_material_transactions_temp mmtt
3797 WHERE mmtt.move_order_line_id = p_line_id
3798 AND NOT EXISTS
3799 (SELECT 1
3800 FROM mtl_material_transactions_temp t
3801 WHERE t.parent_line_id = mmtt.transaction_temp_id
3802 )
3803 FOR UPDATE NOWAIT;
3804 BEGIN
3805 x_return_status := fnd_api.g_ret_sts_success;
3806 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3807 -- Set savepoint
3808 SAVEPOINT backorder;
3809 IF (l_debug = 1) THEN
3810 debug_print( 'Backordering for MO Line ID = ' || p_line_id);
3811 END IF;
3812 l_mo_line_rec := query_rows(p_line_id)(1);
3813 -- Querying the Move Order Type of the Line.
3814 OPEN c_mo_type;
3815 FETCH c_mo_type INTO l_mo_type;
3816 CLOSE c_mo_type;
3817 IF l_debug = 1 THEN
3818 debug_print( 'l_mo_type = ' || l_mo_type);
3819 END IF;
3820 IF (inv_install.adv_inv_installed(l_mo_line_rec.organization_id)) THEN
3821 OPEN c_allow_backordering;
3822 FETCH c_allow_backordering INTO l_allow_backordering;
3823 CLOSE c_allow_backordering;
3824 END IF;
3825 IF (l_debug = 1) THEN
3826 debug_print( 'Allow BackOrdering = ' || l_allow_backordering);
3827 debug_print('p_transaction_temp_id' || p_transaction_temp_id);
3828 END IF;
3829 SELECT transaction_quantity
3830 INTO l_transaction_quantity
3831 FROM mtl_material_transactions_temp
3832 WHERE transaction_temp_id = p_transaction_temp_id;
3833 IF l_debug = 1 THEN
3834 debug_print('l_transaction_quantity' || l_transaction_quantity);
3835 END IF;
3836 IF (l_allow_backordering = 'Y') THEN
3837 IF NVL(l_mo_line_rec.quantity_detailed, 0) - NVL(l_mo_line_rec.quantity_delivered, 0) > 0 THEN
3838 IF l_debug = 1 THEN
3839 debug_print( 'Before for loop.. l_mmtt_info ' );
3840 END IF;
3841 FOR l_mmtt_info IN c_mmtt_info
3842 LOOP
3843 IF l_debug = 1 THEN
3844 debug_print( 'In for loop.. l_mmtt_info ' );
3845 debug_print( 'l_mmtt_info.transaction_temp_id.. ' || l_mmtt_info.transaction_temp_id );
3846 debug_print( 'p_line_id.. ' || p_line_id);
3847 debug_print( 'l_mmtt_info.reservation_id.. ' || l_mmtt_info.reservation_id);
3851 delete_details( x_return_status => x_return_status ,
3848 debug_print( 'l_mmtt_info.transaction_quantity.. ' || l_mmtt_info.transaction_quantity);
3849 debug_print( 'l_mmtt_info.primary_quantity.. ' || l_mmtt_info.primary_quantity);
3850 END IF;
3852 x_msg_data => x_msg_data ,
3853 x_msg_count => x_msg_count ,
3854 p_transaction_temp_id => l_mmtt_info.transaction_temp_id ,
3855 p_move_order_line_id => p_line_id ,
3856 p_reservation_id => l_mmtt_info.reservation_id ,
3857 p_transaction_quantity => l_mmtt_info.transaction_quantity ,
3858 p_primary_trx_qty => l_mmtt_info.primary_quantity );
3859
3860 IF l_debug = 1 THEN
3861 debug_print( 'x_return_status ' || x_return_status);
3862 END IF;
3863 IF x_return_status = fnd_api.g_ret_sts_error THEN
3864 IF l_debug = 1 THEN
3865 debug_print('Error occurred while back ordering');
3866 END IF;
3867 ROLLBACK TO backorder;
3868 RAISE exc_not_deleted ;
3869 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
3870 IF l_debug = 1 THEN
3871 debug_print('Unexpected error occurred while back ordering');
3872 END IF;
3873 ROLLBACK TO backorder;
3874 END IF;
3875 END LOOP;
3876 END IF;
3877 IF l_debug = 1 THEN
3878 debug_print( 'Before calling backorder_source ');
3879 debug_print('l_mo_type' || l_mo_type);
3880 END IF;
3881 backorder_source( x_return_status => x_return_status ,
3882 x_msg_data => x_msg_data ,
3883 x_msg_count => x_msg_count ,
3884 p_move_order_type => l_mo_type ,
3885 p_mo_line_rec => l_mo_line_rec ,
3886 p_qty_to_backorder => l_transaction_quantity );
3887
3888 IF l_debug = 1 THEN
3889 debug_print( 'x_return_status ' || x_return_status);
3890 END IF;
3891 IF x_return_status = fnd_api.g_ret_sts_error THEN
3892 IF l_debug = 1 THEN
3893 debug_print('Error occurred while back ordering');
3894 END IF;
3895 ROLLBACK TO backorder;
3896 RAISE exc_not_deleted ;
3897 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
3898 IF l_debug = 1 THEN
3899 debug_print('Unexpected Error occurred while back ordering');
3900 END IF;
3901 ROLLBACK TO backorder;
3902 END IF;
3903 IF l_debug = 1 THEN
3904 debug_print( 'Updating Move Order Line to set Status = 5 and Qty Detailed = '
3905 || l_mo_line_rec.quantity_delivered);
3906 debug_print( 'Updating Move Order Line Quantity = ' || l_mo_line_rec.quantity_delivered);
3907 END IF;
3908 UPDATE mtl_txn_request_lines
3909 SET line_status = 5 ,
3910 quantity_detailed = NVL(quantity_delivered,0) ,
3911 quantity = NVL(quantity_delivered,0)
3912 WHERE line_id = p_line_id;
3913 IF SQL%ROWCOUNT = 0 THEN
3914 IF l_debug = 1 THEN
3915 debug_print ( 'Error updating MTRL::: ');
3916 END IF;
3917 ROLLBACK TO backorder;
3918 RAISE exc_not_deleted ;
3919 END IF;
3920 END IF;
3921 IF l_debug = 1 THEN
3922 debug_print( 'check MO type ' || l_mo_type);
3923 END IF;
3924 IF l_mo_type = inv_globals.g_move_order_pick_wave THEN
3925 IF l_debug = 1 THEN
3926 debug_print( 'before calling inv_transfer_order_pvt.clean_reservations ' || l_mo_line_rec.txn_source_line_id);
3927 END IF;
3928 inv_transfer_order_pvt.clean_reservations( p_source_line_id => l_mo_line_rec.txn_source_line_id ,
3929 x_return_status => x_return_status ,
3930 x_msg_count => x_msg_count ,
3931 x_msg_data => x_msg_data );
3932
3933 IF l_debug = 1 THEN
3934 debug_print( 'x_return_status ' || x_return_status);
3935 END IF;
3936 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3937 IF l_debug = 1 THEN
3938 debug_print( 'Error occurred while cleaning reservation ');
3939 END IF;
3940 ROLLBACK TO backorder;
3941 RAISE exc_not_deleted ;
3942 END IF;
3943 END IF;
3944 EXCEPTION
3945 WHEN exc_not_deleted THEN
3946 IF l_debug =1 THEN
3947 debug_print('In the exception for could not delete a record. Returning staus as E');
3948 END IF;
3949 x_return_status := 'E';
3950 WHEN OTHERS THEN
3951 x_return_status := fnd_api.g_ret_sts_unexp_error;
3952 ROLLBACK TO backorder;
3953 END backorder;
3954
3958 Deletes Sales Orders, Internal Orders and WIP Pick tasks.
3955 -------------------------------------------------------------------------------------------------------------------
3956 /*PROCEDURE DELETE_OUTBOUND_TASKS()
3957 This is the proceudre called from the DELETE_TASKS API when the task is an Outbound task.
3959 */
3960 -------------------------------------------------------------------------------------------------------------------
3961 PROCEDURE DELETE_OUTBOUND_TASKS (p_task_rec IN task_record_type,
3962 x_task_rec OUT NOCOPY task_record_type,
3963 x_return_status OUT NOCOPY VARCHAR2) IS
3964
3965 l_transaction_number NUMBER ;
3966 l_other_mmtt_count NUMBER;
3967 l_progress VARCHAR2(30) := '100';
3968 l_update_parent BOOLEAN := FALSE ; -- No need to call update_parent_mmtt
3969 x_msg_count NUMBER;
3970 x_msg_data VARCHAR2(50);
3971 l_g_ret_sts_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_error;
3972 l_g_ret_sts_unexp_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_unexp_error;
3973 l_g_ret_sts_success CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_success;
3974 l_reservation_id NUMBER;
3975 l_pri_rsv_qty NUMBER;
3976 l_rsv_qty NUMBER;
3977 l_pri_rsv_uom VARCHAR2(3);
3978 l_rsv_uom VARCHAR2(3);
3979 l_old_upd_resv_rec inv_reservation_global.mtl_reservation_rec_type;
3980 l_new_upd_resv_rec inv_reservation_global.mtl_reservation_rec_type;
3981 l_upd_dummy_sn inv_reservation_global.serial_number_tbl_type;
3982 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
3983 l_task_rec WMS_TASK_MGMT_PUB.task_output_rectype;
3984 l_transaction_record mtl_material_transactions_temp%rowtype ; --MMTT rec
3985 l_move_order_rec mtl_txn_request_lines%rowtype ; --MTRL rec
3986 l_mo_line_rec inv_move_order_pub.trolin_rec_type;
3987 l_mo_type NUMBER;
3988 l_wdt_count NUMBER;
3989 l_debug NUMBER;
3990 exc_not_deleted EXCEPTION;
3991 CURSOR c_mmtt_info
3992 IS
3993 SELECT mmtt.transaction_temp_id ,
3994 mmtt.parent_line_id --For checking bulk task
3995 ,
3996 mmtt.inventory_item_id ,
3997 mmtt.move_order_line_id ,
3998 mmtt.transaction_uom ,
3999 mmtt.primary_quantity ,
4000 mmtt.transaction_quantity ,
4001 mmtt.wms_task_type
4002 FROM mtl_material_transactions_temp mmtt
4003 WHERE mmtt.transaction_temp_id = l_transaction_number
4004 AND NOT EXISTS
4005 (SELECT 1
4006 FROM mtl_material_transactions_temp t1
4007 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4008 )
4009 UNION ALL
4010 SELECT mmtt.transaction_temp_id ,
4011 mmtt.parent_line_id --For checking bulk task
4012 ,
4013 mmtt.inventory_item_id ,
4014 mmtt.move_order_line_id ,
4015 mmtt.transaction_uom ,
4016 mmtt.primary_quantity ,
4017 mmtt.transaction_quantity ,
4018 mmtt.wms_task_type
4019 FROM mtl_material_transactions_temp mmtt
4020 WHERE mmtt.parent_line_id = l_transaction_number
4021 AND mmtt.parent_line_id <> mmtt.transaction_temp_id;
4022 -- This union by will end up getting all PARENTS too *****
4023 CURSOR c_mo_line_info
4024 IS
4025 SELECT mtrl.uom_code ,
4026 mtrl.transaction_source_type_id ,
4027 mtrl.transaction_type_id
4028 FROM mtl_txn_request_lines mtrl
4029 WHERE mtrl.line_id = l_transaction_record.move_order_line_id;
4030 CURSOR c_get_other_mmtt
4031 IS
4032 SELECT COUNT(*)
4033 FROM mtl_material_transactions_temp mmtt
4034 WHERE mmtt.move_order_line_id = l_transaction_record.move_order_line_id
4035 AND mmtt.transaction_temp_id <> l_transaction_record.transaction_temp_id
4036 AND NOT EXISTS
4037 (SELECT 1
4038 FROM mtl_material_transactions_temp t1
4039 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4040 );
4041 CURSOR c_mo_type
4042 IS
4043 SELECT mtrh.move_order_type
4044 FROM mtl_txn_request_headers mtrh,
4045 mtl_txn_request_lines mtrl
4046 WHERE mtrl.line_id = l_transaction_record.move_order_line_id
4047 AND mtrh.header_id = mtrl.header_id;
4048 BEGIN
4049 x_return_status := fnd_api.g_ret_sts_success;
4050 l_progress := '110';
4051 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4052 IF (l_debug = 1) THEN
4053 debug_print('IN DELETE_OUTBOUND_TASKS');
4054 debug_print ( 'l_progress: ' || l_progress );
4055 END IF;
4056 SAVEPOINT delso;
4057 l_transaction_number := p_task_rec.transaction_number;
4058 IF l_debug = 1 THEN
4059 debug_print ( 'l_transaction_number ' || l_transaction_number );
4060 END IF;
4061 OPEN c_mmtt_info;
4062 LOOP
4063 FETCH c_mmtt_info
4064 INTO l_transaction_record.transaction_temp_id ,
4065 l_transaction_record.parent_line_id ,
4066 l_transaction_record.inventory_item_id ,
4067 l_transaction_record.move_order_line_id ,
4068 l_transaction_record.transaction_uom ,
4072 EXIT
4069 l_transaction_record.primary_quantity ,
4070 l_transaction_record.transaction_quantity ,
4071 l_transaction_record.wms_task_type;
4073 WHEN c_mmtt_info%NOTFOUND;
4074 l_progress := '120';
4075 IF (l_debug = 1) THEN
4076 debug_print ( 'delete_so: l_progress: ' || l_progress );
4077 debug_print ( 'delete_so: l_transaction_record.transaction_temp_id ' || l_transaction_record.transaction_temp_id );
4078 debug_print ( 'delete_so: l_transaction_record.parent_line_id ' || l_transaction_record.parent_line_id );
4079 debug_print ( 'delete_so: l_transaction_record.inventory_item_id ' || l_transaction_record.inventory_item_id );
4080 debug_print ( 'delete_so: l_transaction_record.move_order_line_id ' || l_transaction_record.move_order_line_id );
4081 debug_print ( 'delete_so: l_transaction_record.transaction_uom ' || l_transaction_record.transaction_uom );
4082 debug_print ( 'delete_so: l_transaction_record.primary_quantity ' || l_transaction_record.primary_quantity );
4083 debug_print ( 'delete_so: l_transaction_record.transaction_quantity ' || l_transaction_record.transaction_quantity );
4084 debug_print ( 'delete_so: l_transaction_record.wms_task_type ' || l_transaction_record.wms_task_type );
4085 END IF;
4086 OPEN c_mo_line_info;
4087 FETCH c_mo_line_info
4088 INTO l_move_order_rec.uom_code ,
4089 l_move_order_rec.transaction_source_type_id,
4090 l_move_order_rec.transaction_type_id;
4091 CLOSE c_mo_line_info;
4092 l_progress := '125';
4093 IF (l_debug = 1) THEN
4094 debug_print ( 'delete_so: l_progress: ' || l_progress );
4095 debug_print('delete_so: l_move_order_rec.uom_code :'|| l_move_order_rec.uom_code);
4096 debug_print('delete_so: l_move_order_rec.transaction_source_type_id :'|| l_move_order_rec.transaction_source_type_id);
4097 debug_print('delete_so: l_move_order_rec.transaction_type_id :'|| l_move_order_rec.transaction_type_id);
4098 END IF;
4099 l_progress := '135';
4100 OPEN c_get_other_mmtt;
4101 FETCH c_get_other_mmtt INTO l_other_mmtt_count;
4102 CLOSE c_get_other_mmtt;
4103 IF (l_debug = 1) THEN
4104 debug_print ( 'delete_so: l_progress: ' || l_progress );
4105 debug_print( 'delete_so: Number of MMTTs other than this MMTT : ' || l_other_mmtt_count);
4106 END IF;
4107 IF l_other_mmtt_count > 0 THEN
4108 IF (l_debug = 1) THEN
4109 debug_print('delete_so: Other MMTT lines exist too. So cant close MO Line');
4110 END IF;
4111 l_progress := '140';
4112 BEGIN
4113 IF (l_debug = 1) THEN
4114 debug_print ( 'delete_so: l_progress: ' || l_progress );
4115 debug_print( 'delete_so: Before we update MO and delete MMTT, we need to update reservation ');
4116 END IF;
4117 SELECT nvl(mmtt.reservation_id,-1) ,
4118 mr.primary_reservation_quantity ,
4119 mr.reservation_quantity ,
4120 mr.primary_uom_code ,
4121 mr.reservation_uom_code
4122 INTO l_reservation_id ,
4123 l_pri_rsv_qty ,
4124 l_rsv_qty ,
4125 l_pri_rsv_uom ,
4126 l_rsv_uom
4127 FROM mtl_material_transactions_temp mmtt ,
4128 mtl_reservations mr
4129 WHERE mmtt.transaction_temp_id = l_transaction_record.transaction_temp_id
4130 AND mr.reservation_id = mmtt.reservation_id ;
4131 IF (l_debug = 1) THEN
4132 debug_print('delete_so: l_reservation_id:'||l_reservation_id || ' ,l_pri_rsv_qty :' ||l_pri_rsv_qty||',l_rsv_qty :'||l_rsv_qty );
4133 debug_print('delete_so: MMTT.pri_qty:'||l_transaction_record.primary_quantity ||' ,l_pri_rsv_uom :'||l_pri_rsv_uom||',l_rsv_uom :'||l_rsv_uom );
4134 END IF;
4135 IF (l_rsv_qty > l_transaction_record.primary_quantity ) THEN
4136 l_old_upd_resv_rec.reservation_id := l_reservation_id ;
4137 l_new_upd_resv_rec.primary_reservation_quantity := l_pri_rsv_qty - l_transaction_record.primary_quantity ;
4138 IF (l_pri_rsv_uom <> l_rsv_uom ) THEN
4139 l_new_upd_resv_rec.reservation_quantity := l_rsv_qty - INV_Convert.inv_um_convert ( item_id => l_transaction_record.inventory_item_id,
4140 precision => null,
4141 from_quantity => l_transaction_record.primary_quantity ,
4142 from_unit => l_pri_rsv_uom,
4143 to_unit => l_rsv_uom,
4144 from_name => null,
4145 to_name => null );
4146 ELSE
4147 l_new_upd_resv_rec.reservation_quantity := l_rsv_qty - l_transaction_record.primary_quantity ;
4148 END IF;
4152 inv_reservation_pub.update_reservation( p_api_version_number => 1.0 ,
4149 IF (l_debug = 1) THEN
4150 debug_print( 'delete_so: Calling update_reservation api : ' );
4151 END IF;
4153 p_init_msg_lst => fnd_api.g_false ,
4154 x_return_status => x_return_status ,
4155 x_msg_count => x_msg_count ,
4156 x_msg_data => x_msg_data ,
4157 p_original_rsv_rec => l_old_upd_resv_rec ,
4158 p_to_rsv_rec => l_new_upd_resv_rec ,
4159 p_original_serial_number => l_upd_dummy_sn ,
4160 p_to_serial_number => l_upd_dummy_sn ,
4161 p_validation_flag => fnd_api.g_true );
4162
4163 IF (l_debug = 1) THEN
4164 debug_print( 'delete_so: return of update_reservation api : ' || x_return_status);
4165 END IF;
4166 IF x_return_status <> fnd_api.g_ret_sts_success THEN
4167 x_task_rec := p_task_rec;
4168 IF (l_debug = 1) THEN
4169 debug_print( 'delete_so: Error updating reservation ' );
4170 END IF;
4171 ROLLBACK TO delso;
4172 RAISE exc_not_deleted ;
4173 END IF;
4174 END IF;
4175 EXCEPTION
4176 WHEN NO_DATA_FOUND THEN
4177 IF (l_debug = 1) THEN
4178 debug_print( 'delete_so: There is no reservation for this MMTT ' );
4179 END IF;
4180 WHEN OTHERS THEN
4181 IF (l_debug = 1) THEN
4182 debug_print( 'delete_so: OTHERS EXCEPTION !!!! while Updating reservation ' );
4183 END IF;
4184 x_return_status:= fnd_api.g_ret_sts_unexp_error ;
4185 ROLLBACK TO delso;
4186 END;
4187 l_progress := '145';
4188 delete_transaction( x_return_status => x_return_status ,
4189 x_msg_data => x_msg_data ,
4190 x_msg_count => x_msg_count ,
4191 p_transaction_temp_id => l_transaction_record.transaction_temp_id ,
4192 p_update_parent => l_update_parent );
4193
4194 IF l_debug = 1 THEN
4195 debug_print( 'x_return_status ' || x_return_status);
4196 END IF;
4197 IF x_return_status = fnd_api.g_ret_sts_error THEN
4198 IF l_debug = 1 THEN
4199 debug_print ( 'delete_so: l_progress: ' || l_progress );
4200 debug_print('delete_so: Error occurred while deleting MMTT');
4201 END IF;
4202 x_task_rec := p_task_rec;
4203 ROLLBACK TO delso;
4204 RAISE exc_not_deleted ;
4205 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4206 IF l_debug = 1 THEN
4207 debug_print('delete_mo: Error occurred while deleting MMTT');
4208 END IF;
4209 ROLLBACK TO delso;
4210 END IF;
4211 IF l_debug = 1 THEN
4212 debug_print ( 'l_transaction_record.transaction_quantity ' || l_transaction_record.transaction_quantity);
4213 debug_print ( 'l_transaction_record.move_order_line_id ' || l_transaction_record.move_order_line_id);
4214 END IF;
4215 UPDATE mtl_txn_request_lines
4216 SET quantity_detailed = quantity_detailed - l_transaction_record.transaction_quantity
4217 WHERE line_id = l_transaction_record.move_order_line_id;
4218 IF SQL%ROWCOUNT = 0 THEN
4219 IF l_debug = 1 THEN
4220 debug_print ( 'delete_so: error updateing MTRL::: ');
4221 END IF;
4222 ROLLBACK TO delso;
4223 RAISE exc_not_deleted ;
4224 END IF;
4225 -- Querying the Move Order Type of the Line.
4226 OPEN c_mo_type;
4227 FETCH c_mo_type INTO l_mo_type;
4228 CLOSE c_mo_type;
4229 IF l_debug = 1 THEN
4230 debug_print ( 'delete_so: l_mo_type::: ' || l_mo_type);
4231 END IF;
4232 l_mo_line_rec := inv_trolin_util.query_row(l_transaction_record.move_order_line_id);
4233 backorder_source(x_return_status => x_return_status ,
4234 x_msg_data => x_msg_data ,
4235 x_msg_count => x_msg_count ,
4236 p_move_order_type => l_mo_type ,
4237 p_mo_line_rec => l_mo_line_rec ,
4238 p_qty_to_backorder => l_transaction_record.primary_quantity);
4239
4240 IF x_return_status = fnd_api.g_ret_sts_error THEN
4241 IF l_debug = 1 THEN
4242 debug_print('delete_so: Error occurred while backordering WDD');
4246 RAISE exc_not_deleted ;
4243 END IF;
4244 x_task_rec := p_task_rec;
4245 ROLLBACK TO delso;
4247 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4248 IF l_debug = 1 THEN
4249 debug_print('Unexpected Error occurred while backordering WDD');
4250 END IF;
4251 ROLLBACK TO delso;
4252 END IF;
4253 ELSE --IF l_other_mmtt_count > 0
4254 l_progress := '150';
4255 if (l_debug = 1) THEN
4256 debug_print ( 'delete_so: l_progress: ' || l_progress );
4257 debug_print('delete_so: Just one MMTT line exists. Close MO');
4258 END IF;
4259 l_progress := '155';
4260 SELECT count(*)
4261 INTO l_wdt_count
4262 FROM wms_dispatched_tasks
4263 WHERE transaction_temp_id = l_transaction_number;
4264 IF l_wdt_count > 0 THEN
4265 DELETE
4266 FROM wms_dispatched_tasks
4267 WHERE transaction_temp_id = l_transaction_number;
4268 IF SQL%ROWCOUNT = 0 THEN
4269 IF l_debug = 1 THEN
4270 debug_print ( 'delete_so: l_progress: ' || l_progress );
4271 debug_print ( 'delete_so: error deleting WDT::: ');
4272 END IF;
4273 x_task_rec := p_task_rec;
4274 ROLLBACK TO delso;
4275 RAISE exc_not_deleted ;
4276 END IF;
4277 END IF;
4278 backorder( p_line_id => l_transaction_record.move_order_line_id ,p_transaction_temp_id => l_transaction_record.transaction_temp_id , x_return_status => x_return_status , x_msg_count => x_msg_count , x_msg_data => x_msg_data );
4279 IF l_debug = 1 THEN
4280 debug_print( 'x_return_status ' || x_return_status);
4281 END IF;
4282 IF x_return_status = fnd_api.g_ret_sts_error THEN
4283 IF l_debug = 1 THEN
4284 debug_print('delete_so: Unexpected error occurrend while calling BackOrder API');
4285 END IF;
4286 x_task_rec := p_task_rec;
4287 ROLLBACK TO delso;
4288 RAISE exc_not_deleted ;
4289 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4290 IF l_debug = 1 THEN
4291 debug_print('delete_so: Unexpected error occurred while calling BackOrder API');
4292 END IF;
4293 ROLLBACK TO delso;
4294 END IF;
4295 END IF;
4296 END LOOP;
4297 l_progress := '160';
4298 -- For checking Bulk task.Check if l_transaction_number passed is also
4299 --parent line id.If it's bulk task then call delete transaction.
4300 IF l_transaction_record.parent_line_id = l_transaction_number THEN
4301 IF l_debug = 1 THEN
4302 debug_print('delete_so: Now calling delete transaction for parent line');
4303 END IF;
4304 delete_transaction( x_return_status => x_return_status ,
4305 x_msg_data => x_msg_data ,
4306 x_msg_count => x_msg_count ,
4307 p_transaction_temp_id => l_transaction_record.parent_line_id ,
4308 p_update_parent => l_update_parent );
4309
4310 IF l_debug = 1 THEN
4311 debug_print( 'x_return_status ' || x_return_status);
4312 END IF;
4313 IF x_return_status = fnd_api.g_ret_sts_error THEN
4314 IF l_debug = 1 THEN
4315 debug_print('delete_so: Error occurred while deleting parent line in MMTT');
4316 END IF;
4317 x_task_rec := p_task_rec;
4318 ROLLBACK TO delso;
4319 RAISE exc_not_deleted ;
4320 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4321 IF l_debug = 1 THEN
4322 debug_print('delete_so: Error occurred while deleting MMTT');
4323 END IF;
4324 ROLLBACK TO delso;
4325 END IF;
4326 END IF; --for parent line IF
4327 CLOSE c_mmtt_info;
4328 EXCEPTION
4329 WHEN exc_not_deleted THEN
4330 IF l_debug =1 THEN
4331 debug_print('In the exception, could not delete a record. Returning staus as E');
4332 END IF;
4333 x_task_rec.status :='E';
4334 x_task_rec.ERROR := 'Error while deleting Outbound Task';
4335 x_return_status := 'E';
4336 WHEN OTHERS THEN
4337 IF l_debug = 1 THEN
4338 debug_print('delete_so: In the When Others Exception, Rolling back.');
4339 END IF;
4340 x_task_rec := p_task_rec;
4341 x_task_rec.ERROR := 'Unexpected Error Occurred';
4342 x_task_rec.status :='E';
4343 x_return_status := l_g_ret_sts_unexp_error;
4344 ROLLBACK TO delso;
4345 END DELETE_OUTBOUND_TASKS;
4346
4350 Deletes Replenishment, MO Xfer, MO Issue tasks
4347 -------------------------------------------------------------------------------------------------------------------
4348 /*PROCEDURE DELETE_MO_TASKS()
4349 This is the proceudre called from the DELETE_TASKS API when the task is a Move Order.
4351 */
4352 -------------------------------------------------------------------------------------------------------------------
4353 PROCEDURE DELETE_MO_TASKS (p_task_rec IN task_record_type,
4354 x_task_rec OUT NOCOPY task_record_type,
4355 x_return_status OUT NOCOPY VARCHAR2) IS
4356
4357 l_transaction_number NUMBER ;
4358 l_other_mmtt_count NUMBER;
4359 l_progress VARCHAR2(30) := '200';
4360 l_update_parent BOOLEAN := FALSE ; -- No need to call update_parent_mmtt
4361 x_msg_count NUMBER;
4362 x_msg_data VARCHAR2(50);
4363 l_g_ret_sts_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_error;
4364 l_g_ret_sts_unexp_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_unexp_error;
4365 l_g_ret_sts_success CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_success;
4366 l_reservation_id NUMBER;
4367 l_pri_rsv_qty NUMBER;
4368 l_rsv_qty NUMBER;
4369 l_pri_rsv_uom VARCHAR2(3);
4370 l_rsv_uom VARCHAR2(3);
4371 l_old_upd_resv_rec inv_reservation_global.mtl_reservation_rec_type;
4372 l_new_upd_resv_rec inv_reservation_global.mtl_reservation_rec_type;
4373 l_upd_dummy_sn inv_reservation_global.serial_number_tbl_type;
4374 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
4375 l_task_rec WMS_TASK_MGMT_PUB.task_output_rectype;
4376 l_transaction_record mtl_material_transactions_temp%rowtype ; --MMTT rec
4377 l_move_order_rec mtl_txn_request_lines%rowtype ; --MTRL rec
4378 l_debug NUMBER;
4379 exc_not_deleted EXCEPTION;
4380 CURSOR c_mmtt_info
4381 IS
4382 SELECT mmtt.transaction_temp_id ,
4383 mmtt.parent_line_id --For checking bulk task
4384 ,
4385 mmtt.inventory_item_id ,
4386 mmtt.move_order_line_id ,
4387 mmtt.transaction_uom ,
4388 mmtt.primary_quantity ,
4389 mmtt.wms_task_type
4390 FROM mtl_material_transactions_temp mmtt
4391 WHERE mmtt.transaction_temp_id = l_transaction_number
4392 AND NOT EXISTS
4393 (SELECT 1
4394 FROM mtl_material_transactions_temp t1
4395 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4396 )
4397 UNION ALL
4398 SELECT mmtt.transaction_temp_id ,
4399 mmtt.parent_line_id --For checking bulk task
4400 ,
4401 mmtt.inventory_item_id ,
4402 mmtt.move_order_line_id ,
4403 mmtt.transaction_uom ,
4404 mmtt.primary_quantity ,
4405 mmtt.wms_task_type
4406 FROM mtl_material_transactions_temp mmtt
4407 WHERE mmtt.parent_line_id = l_transaction_number
4408 AND mmtt.parent_line_id <> mmtt.transaction_temp_id;
4409 -- This union by will end up getting all PARENTS too *****
4410 CURSOR c_mo_line_info
4411 IS
4412 SELECT mtrl.uom_code ,
4413 mtrl.transaction_source_type_id ,
4414 mtrl.transaction_type_id
4415 FROM mtl_txn_request_lines mtrl
4416 WHERE mtrl.line_id = l_transaction_record.move_order_line_id;
4417 CURSOR c_get_other_mmtt
4418 IS
4419 SELECT COUNT(*)
4420 FROM mtl_material_transactions_temp mmtt
4421 WHERE mmtt.move_order_line_id = l_transaction_record.move_order_line_id
4422 AND mmtt.transaction_temp_id <> l_transaction_record.transaction_temp_id
4423 AND NOT EXISTS
4424 (SELECT 1
4425 FROM mtl_material_transactions_temp t1
4426 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4427 );
4428 BEGIN
4429 x_return_status := fnd_api.g_ret_sts_success;
4430 l_progress := '210';
4431 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4432 IF (l_debug = 1) THEN
4433 debug_print('IN DELETE_MO_TASKS');
4434 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4435 END IF;
4436 SAVEPOINT delmo;
4437 l_transaction_number := p_task_rec.transaction_number;
4438 IF l_debug = 1 THEN
4439 debug_print ( 'l_transaction_number ' || l_transaction_number );
4440 END IF;
4441 OPEN c_mmtt_info;
4442 LOOP
4443 FETCH c_mmtt_info
4444 INTO l_transaction_record.transaction_temp_id ,
4445 l_transaction_record.parent_line_id ,
4446 l_transaction_record.inventory_item_id ,
4447 l_transaction_record.move_order_line_id ,
4448 l_transaction_record.transaction_uom ,
4449 l_transaction_record.primary_quantity ,
4450 l_transaction_record.wms_task_type;
4451 EXIT
4452 WHEN c_mmtt_info%NOTFOUND;
4453 l_progress := '220';
4454 IF (l_debug = 1) THEN
4455 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4456 debug_print ( 'delete_mo: l_transaction_record.transaction_temp_id ' || l_transaction_record.transaction_temp_id );
4457 debug_print ( 'delete_mo: l_transaction_record.parent_line_id ' || l_transaction_record.parent_line_id );
4461 debug_print ( 'delete_mo: l_transaction_record.primary_quantity ' || l_transaction_record.primary_quantity );
4458 debug_print ( 'delete_mo: l_transaction_record.inventory_item_id ' || l_transaction_record.inventory_item_id );
4459 debug_print ( 'delete_mo: l_transaction_record.move_order_line_id ' || l_transaction_record.move_order_line_id );
4460 debug_print ( 'delete_mo: l_transaction_record.transaction_uom ' || l_transaction_record.transaction_uom );
4462 debug_print ( 'delete_mo: l_transaction_record.wms_task_type ' || l_transaction_record.wms_task_type );
4463 END IF;
4464 OPEN c_mo_line_info;
4465 FETCH c_mo_line_info
4466 INTO l_move_order_rec.uom_code ,
4467 l_move_order_rec.transaction_source_type_id,
4468 l_move_order_rec.transaction_type_id;
4469 CLOSE c_mo_line_info;
4470 l_progress := '230';
4471 IF (l_debug = 1) THEN
4472 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4473 debug_print('delete_mo: l_move_order_rec.uom_code :'|| l_move_order_rec.uom_code);
4474 debug_print('delete_mo: l_move_order_rec.transaction_source_type_id :'|| l_move_order_rec.transaction_source_type_id);
4475 debug_print('delete_mo: l_move_order_rec.transaction_type_id :'|| l_move_order_rec.transaction_type_id);
4476 END IF;
4477 l_progress := '250';
4478 OPEN c_get_other_mmtt;
4479 FETCH c_get_other_mmtt INTO l_other_mmtt_count;
4480 CLOSE c_get_other_mmtt;
4481 IF (l_debug = 1) THEN
4482 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4483 debug_print( 'delete_mo: Number of MMTTs other than this MMTT : ' || l_other_mmtt_count);
4484 END IF;
4485 IF l_other_mmtt_count > 0 THEN
4486 IF (l_debug = 1) THEN
4487 debug_print('delete_mo: Other MMTT lines exist too. So cant close MO Line');
4488 END IF;
4489 l_progress := '260';
4490 delete_transaction( x_return_status => x_return_status ,
4491 x_msg_data => x_msg_data ,
4492 x_msg_count => x_msg_count ,
4493 p_transaction_temp_id => l_transaction_record.transaction_temp_id ,
4494 p_update_parent => l_update_parent );
4495
4496 IF l_debug = 1 THEN
4497 debug_print( 'x_return_status ' || x_return_status);
4498 END IF;
4499 IF x_return_status = fnd_api.g_ret_sts_error THEN
4500 IF l_debug = 1 THEN
4501 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4502 debug_print('delete_mo: Error occurred while deleting MMTT');
4503 END IF;
4504 x_task_rec := p_task_rec;
4505 ROLLBACK TO delmo;
4506 RAISE exc_not_deleted ;
4507 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4508 IF l_debug = 1 THEN
4509 debug_print('delete_mo: Error occurred while deleting MMTT');
4510 END IF;
4511 ROLLBACK TO delmo;
4512 END IF;
4513 ELSE --IF l_other_mmtt_count > 0
4514 l_progress := '280';
4515 IF (l_debug = 1) THEN
4516 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4517 debug_print ('delete_mo: l_transaction_record.move_order_line_id' || l_transaction_record.move_order_line_id );
4518 END IF;
4519 UPDATE mtl_txn_request_lines
4520 SET quantity_detailed = nvl(quantity_delivered,0),
4521 line_status = 5 ,
4522 last_update_date = SYSDATE
4523 WHERE line_id = l_transaction_record.move_order_line_id;
4524 IF SQL%ROWCOUNT = 0 THEN
4525 IF l_debug = 1 THEN
4526 debug_print ( 'delete_mo: error updating MTRL::: ');
4527 END IF;
4528 x_task_rec := p_task_rec;
4529 ROLLBACK TO delmo;
4530 RAISE exc_not_deleted ;
4531 END IF;
4532 IF l_debug = 1 THEN
4533 debug_print ( 'delete_mo: before calling delete transaction::: ');
4534 END IF;
4535 delete_transaction( x_return_status => x_return_status ,
4536 x_msg_data => x_msg_data ,
4537 x_msg_count => x_msg_count ,
4538 p_transaction_temp_id => l_transaction_record.transaction_temp_id ,
4539 p_update_parent => l_update_parent );
4540
4541 IF l_debug = 1 THEN
4542 debug_print( 'x_return_status ' || x_return_status);
4543 END IF;
4544 IF x_return_status = fnd_api.g_ret_sts_error THEN
4545 IF l_debug = 1 THEN
4546 debug_print('delete_mo: Error occurred while deleting MMTT');
4547 END IF;
4548 x_task_rec := p_task_rec;
4552 IF l_debug = 1 THEN
4549 ROLLBACK TO delmo;
4550 RAISE exc_not_deleted ;
4551 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4553 debug_print('delete_mo: Error occurred while deleting MMTT');
4554 END IF;
4555 ROLLBACK TO delmo;
4556 END IF;
4557 l_progress := '290';
4558 IF (l_debug = 1) THEN
4559 debug_print ( 'delete_mo: l_progress: ' || l_progress );
4560 END IF;
4561 END IF;
4562 END LOOP;
4563 CLOSE c_mmtt_info;
4564 EXCEPTION
4565 WHEN exc_not_deleted THEN
4566 IF l_debug =1 THEN
4567 debug_print('In the exception for could not delete a record. Returning staus as E');
4568 END IF;
4569 x_task_rec.status :='E';
4570 x_task_rec.ERROR := 'Error deleting Move order tasks';
4571 x_return_status := 'E';
4572 WHEN OTHERS THEN
4573 IF l_debug = 1 THEN
4574 debug_print('delete_mo: In the When Others Exception, Rolling back.');
4575 END IF;
4576 x_task_rec := p_task_rec;
4577 x_task_rec.ERROR := 'Unexpected Error Occurred';
4578 x_task_rec.status :='E';
4579 x_return_status := l_g_ret_sts_unexp_error;
4580 ROLLBACK TO delmo;
4581 END DELETE_MO_TASKS;
4582
4583 -------------------------------------------------------------------------------------------------------------------
4584 /*PROCEDURE DELETE_INBOUND_TASKS
4585 This is the proceudre called from the DELETE_TASKS API when the task is a Putaway Task.
4586 */
4587 -------------------------------------------------------------------------------------------------------------------
4588 PROCEDURE DELETE_INBOUND_TASKS ( p_task_rec IN task_record_type,
4589 x_task_rec OUT NOCOPY task_record_type,
4590 x_return_status OUT NOCOPY VARCHAR2) IS
4591
4592 l_other_mmtt_count NUMBER;
4593 l_debug NUMBER;
4594 l_progress VARCHAR2(30);
4595 l_update_parent BOOLEAN := FALSE ; -- No need to call update_parent_mmtt
4596 x_msg_count NUMBER;
4597 x_msg_data VARCHAR2(50);
4598 l_return_status VARCHAR2(1);
4599 l_transaction_number NUMBER ;
4600 l_transaction_record mtl_material_transactions_temp%rowtype ; --MMTT rec
4601 l_move_order_rec mtl_txn_request_lines%rowtype ; --MTRL rec
4602 l_op_plan_rec wms_op_plan_instances%rowtype ; --WOPI rec
4603 exc_not_deleted EXCEPTION;
4604 l_op_plan_status NUMBER ;
4605 l_g_ret_sts_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_error;
4606 l_g_ret_sts_unexp_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_unexp_error;
4607 l_g_ret_sts_success CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_success;
4608 CURSOR c_mmtt_info
4609 IS
4610 SELECT mmtt.transaction_temp_id ,
4611 mmtt.parent_line_id ,
4612 mmtt.organization_id ,
4613 mmtt.inventory_item_id ,
4614 mmtt.move_order_line_id ,
4615 mmtt.transaction_uom ,
4616 mmtt.primary_quantity ,
4617 mmtt.transaction_quantity
4618 FROM mtl_material_transactions_temp mmtt
4619 WHERE mmtt.transaction_temp_id = l_transaction_number
4620 AND NOT EXISTS
4621 (SELECT 1
4622 FROM mtl_material_transactions_temp t1
4623 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4624 )
4625 UNION ALL
4626 SELECT mmtt.transaction_temp_id ,
4627 mmtt.parent_line_id ,
4628 mmtt.organization_id ,
4629 mmtt.inventory_item_id ,
4630 mmtt.move_order_line_id ,
4631 mmtt.transaction_uom ,
4632 mmtt.primary_quantity ,
4633 mmtt.transaction_quantity
4634 FROM mtl_material_transactions_temp mmtt
4635 WHERE mmtt.parent_line_id = l_transaction_number
4636 AND mmtt.parent_line_id <> mmtt.transaction_temp_id;
4637 CURSOR c_mo_line_info
4638 IS
4639 SELECT mtrl.uom_code ,
4640 mtrl.transaction_source_type_id ,
4641 mtrl.transaction_type_id ,
4642 backorder_delivery_detail_id
4643 FROM mtl_txn_request_lines mtrl
4644 WHERE mtrl.line_id = l_transaction_record.move_order_line_id;
4645 CURSOR c_get_other_mmtt
4646 IS
4647 SELECT COUNT(*)
4648 FROM mtl_material_transactions_temp mmtt
4649 WHERE mmtt.move_order_line_id = l_transaction_record.move_order_line_id
4650 AND mmtt.transaction_temp_id <> l_transaction_record.transaction_temp_id
4651 AND NOT EXISTS
4652 (SELECT 1
4653 FROM mtl_material_transactions_temp t1
4654 WHERE t1.parent_line_id = mmtt.transaction_temp_id
4655 );
4656 CURSOR c_plan_instance
4657 IS
4658 SELECT status ,
4659 orig_dest_sub_code ,
4660 orig_dest_loc_id
4661 FROM WMS_OP_PLAN_INSTANCES
4662 WHERE source_task_id = l_transaction_record.parent_line_id;
4663 BEGIN
4664 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4665 x_return_status := fnd_api.g_ret_sts_success;
4666 l_progress := '300';
4667 IF (l_debug = 1) THEN
4671 SAVEPOINT delinb;
4668 debug_print('IN DELETE_INBOUND_TASKS');
4669 debug_print( 'l_progress: ' || l_progress );
4670 END IF;
4672 l_transaction_number := p_task_rec.transaction_number;
4673 IF (l_debug = 1) THEN
4674 debug_print( 'l_transaction_number ' || l_transaction_number );
4675 END IF;
4676 OPEN c_mmtt_info;
4677 LOOP
4678 FETCH c_mmtt_info
4679 INTO l_transaction_record.transaction_temp_id ,
4680 l_transaction_record.parent_line_id ,
4681 l_transaction_record.organization_id ,
4682 l_transaction_record.inventory_item_id ,
4683 l_transaction_record.move_order_line_id ,
4684 l_transaction_record.transaction_uom ,
4685 l_transaction_record.primary_quantity ,
4686 l_transaction_record.transaction_quantity;
4687 EXIT
4688 WHEN c_mmtt_info%NOTFOUND;
4689 l_progress := '310';
4690 IF (l_debug = 1) THEN
4691 debug_print ( 'delete_inbound_tasks: l_progress: ' || l_progress );
4692 debug_print ( 'delete_inbound_tasks: l_transaction_record.transaction_temp_id ' || l_transaction_record.transaction_temp_id );
4693 debug_print ( 'delete_inbound_tasks: l_transaction_record.parent_line_id ' || l_transaction_record.parent_line_id );
4694 debug_print ( 'delete_inbound_tasks: l_transaction_record.inventory_item_id ' || l_transaction_record.inventory_item_id );
4695 debug_print ( 'delete_inbound_tasks: l_transaction_record.move_order_line_id ' || l_transaction_record.move_order_line_id );
4696 debug_print ( 'delete_inbound_tasks: l_transaction_record.transaction_uom ' || l_transaction_record.transaction_uom );
4697 debug_print ( 'delete_inbound_tasks: l_transaction_record.primary_quantity ' || l_transaction_record.primary_quantity );
4698 debug_print ( 'delete_inbound_tasks: l_transaction_record.transaction_quantity ' || l_transaction_record.transaction_quantity );
4699 END IF;
4700 --Checking for the status of the Task(as per the operation plan, if Pending or In Progress)
4701 l_progress := '320';
4702 OPEN c_plan_instance;
4703 FETCH c_plan_instance
4704 INTO l_op_plan_rec.status ,
4705 l_op_plan_rec.orig_dest_sub_code,
4706 l_op_plan_rec.orig_dest_loc_id;
4707 CLOSE c_plan_instance;
4708 IF l_op_plan_rec.status IS NULL THEN
4709 IF l_debug =1 THEN
4710 debug_print('No Plan Instance record exists');
4711 END IF;
4712 x_task_rec := p_task_rec;
4713 ROLLBACK to delinb ;
4714 RAISE exc_not_deleted ;
4715 END IF;
4716 l_progress := '330';
4717 IF l_op_plan_rec.status = 1 THEN
4718 IF l_debug =1 THEN
4719 debug_print ( 'delete_inbound_tasks: l_progress: ' || l_progress );
4720 END IF;
4721 OPEN c_mo_line_info;
4722 FETCH c_mo_line_info
4723 INTO l_move_order_rec.uom_code ,
4724 l_move_order_rec.transaction_source_type_id,
4725 l_move_order_rec.transaction_type_id ,
4726 l_move_order_rec.backorder_delivery_detail_id;
4727 CLOSE c_mo_line_info;
4728 l_progress := '340';
4729 IF (l_debug = 1) THEN
4730 debug_print ( 'delete_inbound_tasks: l_progress: ' || l_progress );
4731 debug_print('delete_inbound_tasks: l_move_order_rec.uom_code :'|| l_move_order_rec.uom_code);
4732 debug_print('delete_inbound_tasks: l_move_order_rec.transaction_source_type_id :'|| l_move_order_rec.transaction_source_type_id);
4733 debug_print('delete_inbound_tasks: l_move_order_rec.transaction_type_id :'|| l_move_order_rec.transaction_type_id);
4734 debug_print('delete_inbound_tasks: l_move_order_rec.backorder_delivery_detail_id :'|| l_move_order_rec.backorder_delivery_detail_id);
4735 END IF;
4736 IF l_move_order_rec.backorder_delivery_detail_id IS NULL THEN
4737 l_progress := '350';
4738 --delete operation plan tables (wopi and wooi)
4739 DELETE
4740 FROM wms_op_plan_instances
4741 WHERE source_task_id = l_transaction_record.parent_line_id;
4742 IF SQL%ROWCOUNT =0 THEN
4743 IF l_debug =1 THEN
4744 debug_print('Count not delete the Plan Instance of this task');
4745 END IF;
4746 x_task_rec := p_task_rec;
4747 ROLLBACK to delinb ;
4748 RAISE exc_not_deleted ;
4749 END IF;
4750 DELETE
4751 FROM wms_op_operation_instances
4752 WHERE source_task_id = l_transaction_record.transaction_temp_id;
4753 IF SQL%ROWCOUNT =0 THEN
4754 IF l_debug =1 THEN
4758 ROLLBACK to delinb ;
4755 debug_print('Count not update the operation instance of this task');
4756 END IF;
4757 x_task_rec := p_task_rec;
4759 RAISE exc_not_deleted ;
4760 END IF;
4761 l_progress := '360';
4762 --call delete_transaction (deletes mmtt, mtlt, msnt and wdt)
4763 delete_transaction( x_return_status => l_return_status ,
4764 x_msg_data => x_msg_data ,
4765 x_msg_count => x_msg_count ,
4766 p_transaction_temp_id => l_transaction_record.transaction_temp_id ,p_update_parent => l_update_parent );
4767 IF l_debug = 1 THEN
4768 debug_print( 'x_return_status ' || x_return_status);
4769 END IF;
4770 IF x_return_status = fnd_api.g_ret_sts_error THEN
4771 IF l_debug = 1 THEN
4772 debug_print('delete_inbound_tasks: Error while deleting MMTT/MTLT/MSNT/WDT');
4773 END IF;
4774 x_task_rec := p_task_rec;
4775 ROLLBACK TO delinb;
4776 RAISE exc_not_deleted ;
4777 ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4778 IF l_debug = 1 THEN
4779 debug_print('delete_inbound_tasks: Error occurred while deleting MMTT');
4780 END IF;
4781 ROLLBACK TO delinb;
4782 END IF;
4783 l_progress := '370';
4784 --delete the parent mmtt
4785 DELETE
4786 FROM MTL_MATERIAL_TRANSACTIONS_TEMP
4787 WHERE transaction_temp_id = l_transaction_record.parent_line_id ;
4788 IF SQL%ROWCOUNT =0 THEN
4789 IF l_debug =1 THEN
4790 debug_print('Count not delete the parent mmtt');
4791 END IF;
4792 x_task_rec := p_task_rec;
4793 ROLLBACK to delinb ;
4794 RAISE exc_not_deleted ;
4795 END IF;
4796 --call update locator capacity
4797 inv_loc_wms_utils.revert_loc_suggested_cap_nauto ( x_return_status => l_return_status ,
4798 x_msg_count => x_msg_count ,
4799 x_msg_data => x_msg_data ,
4800 p_organization_id => l_transaction_record.organization_id ,
4801 p_inventory_location_id => l_op_plan_rec.orig_dest_loc_id ,
4802 p_inventory_item_id => l_transaction_record.inventory_item_id ,
4803 p_primary_uom_flag => 'Y' ,
4804 p_transaction_uom_code => NULL ,
4805 p_quantity => l_transaction_record.primary_quantity );
4806 IF l_debug = 1 THEN
4807 debug_print( 'Return status from revert_loc_suggested_capacity ' || x_return_status);
4808 END IF;
4809 IF l_return_status <> fnd_api.g_ret_sts_success THEN
4810 IF l_debug = 1 THEN
4811 debug_print('delete_inbound_tasks: Error while reverting locator capacity');
4812 END IF;
4813 x_task_rec := p_task_rec;
4814 ROLLBACK TO delinb;
4815 RAISE exc_not_deleted ;
4816 END IF;
4817 l_progress := '380';
4818 OPEN c_get_other_mmtt;
4819 FETCH c_get_other_mmtt INTO l_other_mmtt_count;
4820 CLOSE c_get_other_mmtt;
4821 IF (l_debug = 1) THEN
4822 debug_print( 'delete_inbound_tasks: Number of MMTTs other than this MMTT : ' || l_other_mmtt_count);
4823 END IF;
4824 IF l_other_mmtt_count > 0 THEN
4825 UPDATE mtl_txn_request_lines
4826 SET quantity_detailed = quantity_detailed - l_transaction_record.primary_quantity
4827 WHERE line_id = l_transaction_record.move_order_line_id;
4828 ELSE --IF l_other_mmtt_count > 0
4829 UPDATE mtl_txn_request_lines
4830 SET quantity_detailed = null
4831 WHERE line_id = l_transaction_record.move_order_line_id;
4832 END IF;
4833 IF SQL%ROWCOUNT =0 THEN
4834 IF l_debug =1 THEN
4835 debug_print('Could not update the move order line.');
4836 END IF;
4837 x_task_rec := p_task_rec;
4838 ROLLBACK to delinb ;
4839 RAISE exc_not_deleted ;
4840 END IF;
4844 x_return_status := 'E';
4841 ELSE
4842 x_task_rec := p_task_rec;
4843 x_task_rec.ERROR:= 'This is a crossdock task, not deleting';
4845 --anjana
4846 IF l_debug =1 THEN
4847 debug_print('This is a crossdock task, not deleting');
4848 END IF;
4849 END IF ;
4850 ELSE
4851 x_task_rec := p_task_rec;
4852 x_task_rec.ERROR:= 'Invalid status of Operation Plan';
4853 x_return_status := 'E';
4854 --anjana
4855 IF l_debug =1 THEN
4856 debug_print('Invalid status of Operation Plan');
4857 END IF;
4858 END IF;
4859 END LOOP;
4860 EXCEPTION
4861 WHEN exc_not_deleted THEN
4862 IF l_debug =1 THEN
4863 debug_print('In the exception for could not delete a record. Returning staus as E');
4864 END IF;
4865 x_task_rec.status :='E';
4866 x_task_rec.ERROR := 'Error deleting Inbound Tasks';
4867 x_return_status := 'E';
4868 WHEN OTHERS THEN
4869 IF l_debug = 1 THEN
4870 debug_print('delete_inbound_tasks:In the When Others Exception, Rolling back.' );
4871 END IF;
4872 x_task_rec := p_task_rec;
4873 x_task_rec.ERROR := 'Unexpected Error Occurred';
4874 x_task_rec.status :='E';
4875 x_return_status := l_g_ret_sts_unexp_error;
4876 ROLLBACK TO delinb;
4877 END DELETE_INBOUND_TASKS;
4878
4879 -------------------------------------------------------------------------------------------------------------------
4880 /*PROCEDURE DELETE_CC_TASKS
4881 This is the proceudre called from the DELETE_TASKS API when the task is a Cycle Count Entry.
4882 This update the entry to a Rejected Status and deletes the corresponding task record if it exists.
4883 */
4884 -------------------------------------------------------------------------------------------------------------------
4885 PROCEDURE DELETE_CC_TASKS ( p_task_rec IN task_record_type,
4886 x_task_rec OUT NOCOPY task_record_type,
4887 x_return_status OUT NOCOPY VARCHAR2) IS
4888
4889 l_cc_entry_id NUMBER ;
4890 l_cyc_header_id NUMBER;
4891 l_cyc_count_name mtl_cycle_count_headers.cycle_count_header_name%TYPE ;
4892 l_update_cyc NUMBER;
4893 l_cyc_task NUMBER;
4894 l_debug NUMBER;
4895 exc_not_deleted EXCEPTION;
4896 l_g_ret_sts_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_error;
4897 l_g_ret_sts_unexp_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_unexp_error;
4898 l_g_ret_sts_success CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_success;
4899 BEGIN
4900 x_return_status := fnd_api.g_ret_sts_success;
4901 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4902 l_cc_entry_id := p_task_rec.transaction_number ;
4903 SAVEPOINT delcyc;
4904 SELECT cycle_count_header_id
4905 INTO l_cyc_header_id
4906 FROM mtl_cycle_count_entries
4907 WHERE cycle_count_entry_id = l_cc_entry_id ;
4908 UPDATE mtl_cycle_count_entries
4909 SET entry_status_code = 4
4910 WHERE cycle_count_entry_id = l_cc_entry_id ;
4911 IF l_debug =1 THEN
4912 debug_print('delete_cc_tasks: In Delete Cycle Count Tasks');
4913 debug_print('delete_cc_tasks: Value of cycle count header:'||l_cyc_header_id);
4914 debug_print('delete_cc_tasks: Value of cycle count entry:'||l_cc_entry_id);
4915 END IF;
4916 IF SQL%ROWCOUNT =0 THEN
4917 IF l_debug =1 THEN
4918 debug_print('delete_cc_tasks: Could not update the cycle count entry.');
4919 END IF;
4920 x_task_rec := p_task_rec;
4921 ROLLBACK to delcyc ;
4922 RAISE exc_not_deleted ;
4923 END IF;
4924 SELECT count(task_id)
4925 INTO l_cyc_task
4926 FROM wms_dispatched_tasks
4927 WHERE transaction_temp_id = l_cc_entry_id
4928 AND task_type = 3;
4929 IF l_cyc_task <> 0 THEN
4930 DELETE
4931 FROM wms_dispatched_tasks
4932 WHERE transaction_temp_id = l_cc_entry_id
4933 AND task_type = 3;
4934 IF SQL%ROWCOUNT =0 THEN
4935 IF l_debug =1 THEN
4936 debug_print('delete_cc_tasks: Could not delete the cycle count task.');
4937 END IF;
4938 x_task_rec := p_task_rec;
4939 ROLLBACK to delcyc ;
4940 RAISE exc_not_deleted;
4941 END IF; --Rowcount for wdt delete
4942 END IF; --Exists cycle count tasks in wdt
4943 EXCEPTION
4944 WHEN exc_not_deleted THEN
4945 IF l_debug =1 THEN
4946 debug_print('delete_cc_tasks: In the exception for could not delete a record. Returning staus as E');
4947 END IF;
4948 x_task_rec.status :='E';
4949 x_task_rec.ERROR := 'Could not delete the cycle count task.';
4950 x_return_status := 'E';
4951 WHEN OTHERS THEN
4952 IF l_debug = 1 THEN
4953 debug_print('delete_cc_tasks: In the When Others Exception, Rolling back.' );
4954 END IF;
4955 x_task_rec := p_task_rec;
4956 x_task_rec.status :='E';
4957 x_task_rec.ERROR := 'Unexpected Error Occurred';
4958 x_return_status := l_g_ret_sts_unexp_error;
4959 ROLLBACK TO delcyc;
4960 END DELETE_CC_TASKS;
4961
4965 The types of tasks that this API handles include Inbound, Outbound, Warehouse and Manufacturing Tasks.
4962 -------------------------------------------------------------------------------------------------------------------
4963 --DELETE TASK
4964 /*This Public API takes care of deleting a single task or a table of tasks as is passed to the API.
4966
4967 PROCEDURE delete_tasks ( p_transaction_number IN NUMBER DEFAULT NULL ,
4968 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE ,
4969 p_wms_task IN WMS_TASK_MGMT_PUB.task_tab_type ,
4970 x_undeleted_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type ,
4971 x_return_status OUT NOCOPY VARCHAR2 ,
4972 x_msg_count OUT NOCOPY NUMBER ,
4973 x_msg_data OUT NOCOPY VARCHAR2 )
4974
4975 Parameter Description
4976
4977 p_transaction_number This corrsponds to the task_id that user is trying to delete.
4978 P_wms_task This correspinds to the set of tasks that user is trying to delete.
4979 P_Commit This parameter decides whether to commit the changes or not.
4980 X_undeleted_tasks This parameter contains the set of undeleted tasks.
4981 X_return_status This parameter gives the return status of delete_task API.
4982 'S' = Success, 'U' = Unexpected Error, 'E' = Error.
4983 X_msg_count This gives the count of messages logged during the task deletion process.
4984 X_msg_data This gives the descrption of the messages that got logged during the task deletion process.
4985 -------------------------------------------------------------------------------------------------------------------*/
4986
4987 PROCEDURE delete_tasks ( p_transaction_number IN NUMBER DEFAULT NULL ,
4988 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE ,
4989 p_wms_task IN WMS_TASK_MGMT_PUB.task_tab_type ,
4990 x_undeleted_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type ,
4991 x_return_status OUT NOCOPY VARCHAR2 ,
4992 x_msg_count OUT NOCOPY NUMBER ,
4993 x_msg_data OUT NOCOPY VARCHAR2 ) IS
4994
4995 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
4996 l_task_rec task_record_type ;
4997 x_task_rec task_record_type ;
4998 l_transaction_number NUMBER;
4999 l_transaction_record mtl_material_transactions_temp%rowtype ;
5000 /*Local variable for the validate_task API*/
5001 l_ret_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
5002 l_val_ret_status VARCHAR2(30);
5003 l_task_type NUMBER ;
5004 l_task_exists NUMBER :=0 ;
5005 l_g_ret_sts_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_error;
5006 l_g_ret_sts_unexp_error CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_unexp_error;
5007 l_g_ret_sts_success CONSTANT VARCHAR2(30) := fnd_api.g_ret_sts_success;
5008 exec_unexp EXCEPTION;
5009 l_lock_cyc_rec NUMBER;
5010 l_debug NUMBER;
5011 undel_task NUMBER;
5012 l_msg VARCHAR2(2000);--anjana
5013 BEGIN
5014 x_return_status := fnd_api.g_ret_sts_success;
5015 --anjana
5016 x_msg_count := 0;
5017 l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5018 l_val_ret_status :='S' ;
5019 l_transaction_number:= p_transaction_number ;
5020 l_task_table := p_wms_task;
5021 IF l_debug = 1 THEN
5022 debug_print('IN DELETE_TASKS' );
5023 END IF;
5024 IF l_debug = 1 THEN
5025 debug_print('Values passed to delete_tasks p_transaction_number:'|| p_transaction_number );
5026 END IF ;
5027 WMS_TASK_MGMT_PUB.validate_tasks( p_init_msg_list =>'Y' ,
5028 p_transaction_number => l_transaction_number ,
5029 p_task_table => l_task_table ,
5030 x_wms_task => l_ret_task_table ,
5031 x_return_status => l_val_ret_status );
5032 SAVEPOINT deltask ;
5033 IF l_val_ret_status ='S' THEN
5034 undel_task :=1;
5035 FOR i IN 1..l_ret_task_table.count
5036 LOOP
5037 IF (nvl(l_ret_task_table(i).result,'@@@') <> 'E') THEN
5038 BEGIN
5039 BEGIN
5040 l_task_exists:=0;
5041 --Intitalizin the record
5042 l_task_rec.transaction_number:= l_ret_task_table(i).transaction_number ;
5043 SELECT 1,
5044 wms_task_type
5045 INTO l_task_exists,
5046 l_task_type
5047 FROM mtl_material_transactions_temp
5048 WHERE transaction_temp_id = l_ret_task_table(i).transaction_number FOR UPDATE NOWAIT;
5049 EXCEPTION
5050 WHEN NO_DATA_FOUND THEN
5051 null;
5052 END;
5053 IF l_debug = 1 THEN
5054 debug_print('l_task_exists'|| l_task_exists );
5055 debug_print('l_task_type:'|| l_task_type );
5056 END IF;
5057 IF (l_task_exists = 0 ) THEN
5058 SELECT count(cycle_count_entry_id)
5059 INTO l_task_exists
5060 FROM mtl_cycle_count_entries
5061 WHERE cycle_count_entry_id = l_ret_task_table(i).transaction_number ;
5062 SELECT 1
5063 INTO l_lock_cyc_rec
5067 IF l_task_exists = 1 THEN
5064 FROM mtl_cycle_count_entries
5065 WHERE cycle_count_entry_id = l_ret_task_table(i).transaction_number FOR UPDATE NOWAIT;
5066 l_task_type := 3;
5068 IF l_debug = 1 THEN
5069 debug_print('Cycle Count Task');
5070 END IF ;
5071 DELETE_CC_TASKS(p_task_rec => l_task_rec, x_task_rec => x_task_rec, x_return_status => x_return_status);
5072 END IF;
5073 END IF;
5074 IF l_task_type = 1 THEN --SO, WIP
5075 IF l_debug = 1 THEN
5076 debug_print('SO/WIP');
5077 END IF ;
5078 DELETE_OUTBOUND_TASKS(p_task_rec => l_task_rec, x_task_rec => x_task_rec, x_return_status => x_return_status);
5079 ELSIF l_task_type = 2 THEN --Inbound
5080 IF l_debug = 1 THEN
5081 debug_print('Inbound Task');
5082 END IF ;
5083 DELETE_INBOUND_TASKS(p_task_rec => l_task_rec, x_task_rec => x_task_rec, x_return_status => x_return_status);
5084 ELSIF l_task_type IN (4, 5, 6) THEN --Replenishment, MO Xfer, MO Issue)
5085 IF l_debug = 1 THEN
5086 debug_print('MO Tasks');
5087 END IF ;
5088 DELETE_MO_TASKS(p_task_rec => l_task_rec, x_task_rec => x_task_rec, x_return_status => x_return_status);
5089 END IF;
5090 EXCEPTION
5091 WHEN OTHERS THEN
5092 x_return_status := l_g_ret_sts_unexp_error;
5093 IF l_debug = 1 THEN
5094 debug_print('In the When Others Exception in the Loop, Rolling back.' );
5095 END IF;
5096 ROLLBACK TO deltask;
5097 END;
5098 IF x_return_status = 'E' THEN
5099 IF l_debug = 1 THEN
5100 debug_print('The called program returned error' );
5101 END IF;
5102 --anjana
5103 FND_MESSAGE.SET_NAME('WMS', 'WMS_TASK_DELETE_ERROR');
5104 l_msg := fnd_message.get;
5105 x_msg_count := x_msg_count + 1;
5106 x_msg_data := x_msg_data || l_msg;
5107
5108 x_undeleted_tasks(undel_task).transaction_number:= x_task_rec.transaction_number;
5109 x_undeleted_tasks(undel_task).RESULT := x_task_rec.status;
5110 x_undeleted_tasks(undel_task).error := l_msg;
5111 undel_task :=undel_task+1;
5112 -- FND_MSG_PUB.ADD;
5113 -- fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
5114 END IF;
5115 IF x_return_status ='U' THEN
5116 IF l_debug = 1 THEN
5117 debug_print('The called program returned unexpected error status' );
5118 END IF;
5119 RAISE exec_unexp;
5120 END IF;
5121 ELSE
5122 IF l_debug = 1 THEN
5123 debug_print('Validate_task returned error for this record' );
5124 END IF;
5125 FND_MESSAGE.SET_NAME('WMS', 'WMS_INVALID_TASK');
5126 --anjana
5127 l_msg := fnd_message.get;
5128 x_msg_count := x_msg_count + 1;
5129 x_msg_data := x_msg_data || l_msg;
5130 -- FND_MSG_PUB.ADD;
5131 -- fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
5132
5133 x_undeleted_tasks(undel_task).transaction_number:= l_ret_task_table(i).transaction_number ; --6888354 Bug
5134 x_undeleted_tasks(undel_task).RESULT := l_ret_task_table(i).RESULT;
5135 x_undeleted_tasks(undel_task).error := l_msg;
5136 undel_task :=undel_task+1;
5137 END IF ;
5138 END LOOP; --Loop for task table
5139 ELSE
5140 IF l_debug = 1 THEN
5141 debug_print('Invalid status returned from Validate_Task' );
5142 END IF;
5143 RAISE exec_unexp;
5144 END IF; --End of Validation Status 'S'.
5145 IF p_commit = FND_API.G_TRUE THEN
5146 COMMIT;
5147 END IF ;
5148 EXCEPTION
5149 WHEN exec_unexp THEN
5150 IF l_debug = 1 THEN
5154 FND_MESSAGE.SET_NAME('WMS', 'WMS_UNEXPECTED_ERROR');
5151 debug_print('In the Unexpected Error of Delete_Tasks, Rolling back.' );
5152 END IF;
5153 x_return_status := l_g_ret_sts_unexp_error;
5155 FND_MSG_PUB.ADD;
5156 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
5157 ROLLBACK TO deltask;
5158 WHEN OTHERS THEN
5159 IF l_debug = 1 THEN
5160 debug_print('In the When Others Exception of Delete_Tasks, Rolling back.' );
5161 END IF;
5162 x_return_status := l_g_ret_sts_unexp_error;
5163 FND_MESSAGE.SET_NAME('WMS', 'WMS_UNEXPECTED_ERROR');
5164 FND_MSG_PUB.ADD;
5165 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
5166 ROLLBACK TO deltask;
5167 END DELETE_TASKS;
5168
5169 -------------------------------------------------------------------------------------------------------------------
5170 --QUERY_TASK
5171 /*
5172 This public API is used to query task based on the query_name or the transaction_number
5173 provided by the user.
5174
5175 PROCEDURE query_task (
5176 p_transaction_number IN NUMBER DEFAULT NULL
5177 , p_query_name IN WMS_SAVED_QUERIES.QUERY_NAME%TYPE
5178 , x_task_tab OUT NOCOPY WMS_TASKS_PUB.TASK_TABLE
5179 , x_return_status OUT NOCOPY VARCHAR2
5180 , x_msg_count OUT NOCOPY NUMBER
5181 , x_msg_data OUT NOCOPY VARCHAR2 );
5182
5183
5184 Parameter Description
5185
5186 p_transaction_number This corrsponds to the task_id that user is trying to update
5187 P_query_name This correspinds to name of any saved query from the WMS control board.
5188 This is used for querying multiple tasks
5189 P_Commit This parameter decides whether to commit the changes or not.
5190 X_task_tab PL/SQL table which contains the task/tasks queried by the user.
5191 X_return_status This parameter gives the return status of query_task API.
5192 'S' = Success, 'U' = Unexpected Error, 'E' = Error.
5193 X_msg_count This gives the count of messages logged during the query task process.
5194 X_msg_data This gives the descrption of the messages that got logged during the query task process.
5195 */
5196 -------------------------------------------------------------------------------------------------------------------
5197 PROCEDURE query_task( p_transaction_number IN NUMBER DEFAULT NULL
5198 ,p_query_name IN VARCHAR2
5199 ,x_task_tab OUT NOCOPY task_tab_type
5200 ,x_return_status OUT NOCOPY VARCHAR2
5201 ,x_msg_count OUT NOCOPY NUMBER
5202 ,x_msg_data OUT NOCOPY VARCHAR2
5203 )
5204 IS
5205
5206 l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
5207 l_mcce_rec mtl_cycle_count_entries%ROWTYPE;
5208 l_query_tab query_tab_type;
5209
5210
5211 l_organization_id NUMBER := NULL;
5212 l_record_count NUMBER := 0;
5213
5214 l_order_type VARCHAR2(10):= NULL;
5215 l_err_msg VARCHAR2(2000);
5216
5217 l_include_sales_orders BOOLEAN := FALSE;
5218 l_include_internal_orders BOOLEAN := FALSE;
5219 l_execute_qry BOOLEAN := TRUE;
5220
5221 l_invalid_org EXCEPTION;
5222 l_qry_fail EXCEPTION;
5223
5224 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5225 l_api_name VARCHAR2(1000) := 'QUERY_TASK';
5226
5227 v_cycle_count_name varchar2(30) := NULL;
5228
5229 c_cd_exist number;
5230
5231 CURSOR c_cd_task (p_transaction_number IN NUMBER) IS
5232 SELECT 1 FROM mtl_material_transactions_temp mmtt,mtl_txn_request_lines mtrl
5233 WHERE mtrl.backorder_delivery_detail_id IS NOT NULL
5234 AND mtrl.line_id = mmtt.move_order_line_id
5235 AND transaction_temp_id = p_transaction_number;
5236 --added for completed tasks under bug 6854145
5237 --start changes 6854145
5238 l_mmt_rec mtl_material_transactions%ROWTYPE;
5239 l_wdth_rec wms_dispatched_tasks_history%ROWTYPE;
5240 CURSOR c_cd_task1 (p_transaction_number IN NUMBER) IS
5241 SELECT 1 FROM wms_dispatched_tasks_history wdth,mtl_txn_request_lines mtrl
5242 WHERE mtrl.backorder_delivery_detail_id IS NOT NULL
5243 AND mtrl.line_id = wdth.move_order_line_id
5244 AND transaction_id = p_transaction_number;
5245 --end changes 6854145
5246 BEGIN
5247
5248 IF(p_transaction_number IS NOT NULL) THEN
5249 BEGIN
5250 SELECT *
5251 INTO l_mmtt_rec
5252 FROM mtl_material_transactions_temp
5253 WHERE transaction_temp_id = p_transaction_number;
5254
5255 IF(l_debug = 1) THEN
5256 l_err_msg := 'Calling API wms_waveplan_tasks_pvt.query_tasks for task: '||p_transaction_number;
5257 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5258 END IF;
5259
5260 --Munish
5261 OPEN c_cd_task (p_transaction_number);
5262 FETCH c_cd_task into c_cd_exist;
5263 CLOSE c_cd_task;
5264
5265 If (c_cd_exist = 1) THEN
5266 --CALLL wms_waveplan_tasks_pvt.query_tasks API WITH
5267 --p_crossdock_include=true and p_outbound_include=false and p_inbound_include=false
5268 wms_waveplan_tasks_pvt.query_tasks(
5269 p_add => FALSE
5270 ,p_organization_id => l_mmtt_rec.organization_id
5274 ,p_to_locator_id => l_mmtt_rec.transfer_to_location
5271 ,p_subinventory_code => l_mmtt_rec.subinventory_code
5272 ,p_locator_id => l_mmtt_rec.locator_id
5273 ,p_to_subinventory_code => l_mmtt_rec.transfer_subinventory
5275 ,p_inventory_item_id => l_mmtt_rec.inventory_item_id
5276 ,p_from_task_priority => l_mmtt_rec.task_priority
5277 ,p_to_task_priority => l_mmtt_rec.task_priority
5278 ,p_from_creation_date => l_mmtt_rec.creation_date
5279 ,p_to_creation_date => l_mmtt_rec.creation_date
5280 ,p_is_unreleased => TRUE
5281 ,p_is_pending => TRUE
5282 ,p_is_queued => TRUE
5283 ,p_is_dispatched => TRUE
5284 ,p_is_active => TRUE
5285 ,p_is_loaded => TRUE
5286 ,p_is_completed => TRUE
5287 ,p_include_inbound => FALSE
5288 ,p_include_outbound => FALSE
5289 ,p_include_crossdock => TRUE
5290 ,p_include_manufacturing => TRUE
5291 ,p_include_warehousing => TRUE
5292 ,p_from_shipment_number => l_mmtt_rec.shipment_number
5293 ,p_to_shipment_number => l_mmtt_rec.shipment_number
5294 ,p_from_pick_slip_number => l_mmtt_rec.pick_slip_number
5295 ,p_to_pick_slip_number => l_mmtt_rec.pick_slip_number
5296 ,p_delivery_id => l_mmtt_rec.trx_source_delivery_id
5297 ,p_manufacturing_type => 1
5298 ,p_include_staging_move => TRUE
5299 ,x_return_status => x_return_status
5300 ,x_msg_data => x_msg_data
5301 ,x_msg_count => x_msg_count
5302 ,x_record_count => l_record_count
5303 ,p_is_pending_plan => FALSE
5304 ,p_is_inprogress_plan => FALSE
5305 ,p_is_completed_plan => FALSE
5306 ,p_is_cancelled_plan => FALSE
5307 ,p_is_aborted_plan => FALSE
5308 );
5309 ELSE
5310 --CALLL wms_waveplan_tasks_pvt.query_tasks API WITH p_crossdock_include=false and
5311 --p_outbound_include=true and p_inbound_include=true
5312 --MKGUPTA2 6868286 Start
5313 IF l_mmtt_rec.parent_line_id IS NOT NULL THEN
5314 l_mmtt_rec.pick_slip_number:=NULL;
5315 ELSE
5316 l_mmtt_rec.subinventory_code:=NULL;
5317 l_mmtt_rec.locator_id:=NULL;
5318 END IF;
5319 -- 6868286 End
5320 wms_waveplan_tasks_pvt.query_tasks(
5321 p_add => FALSE
5322 ,p_organization_id => l_mmtt_rec.organization_id
5323 ,p_subinventory_code => l_mmtt_rec.subinventory_code
5324 ,p_locator_id => l_mmtt_rec.locator_id
5325 ,p_to_subinventory_code => l_mmtt_rec.transfer_subinventory
5326 ,p_to_locator_id => l_mmtt_rec.transfer_to_location
5327 ,p_inventory_item_id => l_mmtt_rec.inventory_item_id
5328 ,p_from_task_priority => l_mmtt_rec.task_priority
5329 ,p_to_task_priority => l_mmtt_rec.task_priority
5330 ,p_from_creation_date => Trunc(l_mmtt_rec.creation_date) -- 6868286
5331 ,p_to_creation_date => Trunc(l_mmtt_rec.creation_date) -- 6868286
5332 ,p_is_unreleased => TRUE
5333 ,p_is_pending => TRUE
5334 ,p_is_queued => TRUE
5335 ,p_is_dispatched => TRUE
5336 ,p_is_active => TRUE
5337 ,p_is_loaded => TRUE
5338 ,p_is_completed => FALSE
5339 ,p_include_inbound => TRUE
5340 ,p_include_outbound => TRUE
5341 ,p_include_crossdock => FALSE
5342 ,p_include_manufacturing => TRUE
5343 ,p_include_warehousing => TRUE
5344 ,p_from_shipment_number => l_mmtt_rec.shipment_number
5345 ,p_to_shipment_number => l_mmtt_rec.shipment_number
5346 ,p_from_pick_slip_number => l_mmtt_rec.pick_slip_number
5347 ,p_to_pick_slip_number => l_mmtt_rec.pick_slip_number
5348 ,p_delivery_id => l_mmtt_rec.trx_source_delivery_id
5349 ,p_manufacturing_type => 1
5350 ,p_include_staging_move => TRUE
5351 ,x_return_status => x_return_status
5352 ,x_msg_data => x_msg_data
5353 ,x_msg_count => x_msg_count
5354 ,x_record_count => l_record_count
5355 ,p_is_pending_plan =>TRUE
5356 ,p_is_inprogress_plan =>TRUE
5357 ,p_is_completed_plan =>TRUE
5358 ,p_is_cancelled_plan =>TRUE
5359 ,p_is_aborted_plan =>TRUE
5360 );
5361 END IF;
5362
5363 IF(l_debug = 1) THEN
5364 l_err_msg := 'Status returned by API wms_waveplan_tasks_pvt.query_tasks: '||x_return_status;
5365 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5366 END IF;
5367
5368 IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5369 /* SELECT * BULK COLLECT
5370 INTO x_task_tab
5371 FROM wms_waveplan_tasks_temp
5372 WHERE transaction_temp_id = p_transaction_number;*/
5373
5374 --Replacing the above by selecting columns from the table.
5375 SELECT
5376 TASK_ID,
5377 TRANSACTION_TEMP_ID,
5378 PARENT_LINE_ID,
5379 INVENTORY_ITEM_ID,
5380 ITEM,
5381 ITEM_DESCRIPTION,
5382 UNIT_WEIGHT,
5383 WEIGHT_UOM_CODE,
5384 DISPLAY_WEIGHT,
5385 UNIT_VOLUME,
5386 VOLUME_UOM_CODE,
5390 ORGANIZATION_CODE,
5387 DISPLAY_VOLUME,
5388 TIME_ESTIMATE,
5389 ORGANIZATION_ID,
5391 REVISION,
5392 SUBINVENTORY,
5393 LOCATOR_ID,
5394 LOCATOR,
5395 TRANSACTION_TYPE_ID,
5396 TRANSACTION_ACTION_ID,
5397 TRANSACTION_SOURCE_TYPE_ID,
5398 TRANSACTION_SOURCE_TYPE,
5399 TRANSACTION_SOURCE_ID,
5400 TRANSACTION_SOURCE_LINE_ID,
5401 TO_ORGANIZATION_ID,
5402 TO_ORGANIZATION_CODE,
5403 TO_SUBINVENTORY,
5404 TO_LOCATOR_ID,
5405 TO_LOCATOR,
5406 TRANSACTION_UOM,
5407 TRANSACTION_QUANTITY,
5408 USER_TASK_TYPE_ID,
5409 USER_TASK_TYPE,
5410 PERSON_ID,
5411 PERSON_ID_ORIGINAL,
5412 PERSON,
5413 EFFECTIVE_START_DATE,
5414 EFFECTIVE_END_DATE,
5415 PERSON_RESOURCE_ID,
5416 PERSON_RESOURCE_CODE,
5417 MACHINE_RESOURCE_ID,
5418 MACHINE_RESOURCE_CODE,
5419 EQUIPMENT_INSTANCE,
5420 STATUS_ID,
5421 STATUS_ID_ORIGINAL,
5422 STATUS,
5423 CREATION_TIME,
5424 DISPATCHED_TIME,
5425 LOADED_TIME,
5426 DROP_OFF_TIME,
5427 MMTT_LAST_UPDATE_DATE,
5428 MMTT_LAST_UPDATED_BY,
5429 WDT_LAST_UPDATE_DATE,
5430 WDT_LAST_UPDATED_BY,
5431 PRIORITY,
5432 PRIORITY_ORIGINAL,
5433 TASK_TYPE_ID,
5434 TASK_TYPE,
5435 MOVE_ORDER_LINE_ID,
5436 PICK_SLIP_NUMBER,
5437 CARTONIZATION_ID,
5438 ALLOCATED_LPN_ID,
5439 CONTAINER_ITEM_ID,
5440 CONTENT_LPN_ID,
5441 TO_LPN_ID,
5442 CONTAINER_ITEM ,
5443 CARTONIZATION_LPN,
5444 ALLOCATED_LPN ,
5445 CONTENT_LPN,
5446 TO_LPN,
5447 REFERENCE ,
5448 REFERENCE_ID,
5449 CUSTOMER_ID,
5450 CUSTOMER ,
5451 SHIP_TO_LOCATION_ID ,
5452 SHIP_TO_STATE ,
5453 SHIP_TO_COUNTRY,
5454 SHIP_TO_POSTAL_CODE,
5455 DELIVERY_ID ,
5456 DELIVERY ,
5457 SHIP_METHOD ,
5458 CARRIER_ID ,
5459 CARRIER ,
5460 SHIPMENT_DATE ,
5461 SHIPMENT_PRIORITY,
5462 WIP_ENTITY_TYPE,
5463 WIP_ENTITY_ID,
5464 ASSEMBLY_ID,
5465 ASSEMBLY ,
5466 LINE_ID,
5467 LINE,
5468 DEPARTMENT_ID,
5469 DEPARTMENT,
5470 SOURCE_HEADER,
5471 LINE_NUMBER,
5472 OPERATION_PLAN_ID,
5473 OPERATION_PLAN ,
5474 RESULT ,
5475 ERROR ,
5476 IS_MODIFIED ,
5477 EXPANSION_CODE ,
5478 FROM_LPN ,
5479 FROM_LPN_ID,
5480 NUM_OF_CHILD_TASKS,
5481 OPERATION_SEQUENCE,
5482 OP_PLAN_INSTANCE_ID,
5483 PLANS_TASKS ,
5484 TRANSACTION_SET_ID,
5485 PICKED_LPN_ID,
5486 PICKED_LPN,
5487 LOADED_LPN,
5488 LOADED_LPN_ID,
5489 DROP_LPN ,
5490 SECONDARY_TRANSACTION_QUANTITY,
5491 SECONDARY_TRANSACTION_UOM ,
5492 PRIMARY_PRODUCT,
5493 LOAD_SEQ_NUMBER
5494 BULK COLLECT
5495 INTO x_task_tab
5496 FROM wms_waveplan_tasks_temp
5497 WHERE transaction_temp_id = p_transaction_number;
5498
5499 END IF;
5500
5501 EXCEPTION
5502 WHEN NO_DATA_FOUND THEN
5503 BEGIN
5504 SELECT *
5505 INTO l_mcce_rec
5506 FROM mtl_cycle_count_entries
5507 WHERE cycle_count_entry_id = p_transaction_number;
5508
5509 BEGIN
5510 SELECT cycle_count_header_name
5511 INTO v_cycle_count_name
5512 FROM mtl_cycle_count_headers
5513 WHERE cycle_count_header_id = l_mcce_rec.cycle_count_header_id;
5514 EXCEPTION
5515 WHEN NO_DATA_FOUND THEN
5516 v_cycle_count_name := NULL;
5517 END;
5518
5519 IF(l_debug = 1) THEN
5520 l_err_msg := 'Calling API wms_waveplan_tasks_pvt.query_tasks for cycle count task: '||p_transaction_number;
5521 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5522 inv_trx_util_pub.trace('Cycle Count Name '||v_cycle_count_name);
5523 END IF;
5524
5525 wms_waveplan_tasks_pvt.query_tasks(
5526 p_add => FALSE
5527 ,p_organization_id => l_mcce_rec.organization_id
5528 ,p_subinventory_code => l_mcce_rec.subinventory
5529 ,p_locator_id => l_mcce_rec.locator_id
5530 ,p_inventory_item_id => l_mcce_rec.inventory_item_id
5531 ,p_from_creation_date => l_mcce_rec.creation_date
5532 ,p_to_creation_date => l_mcce_rec.creation_date
5533 ,p_is_unreleased => TRUE
5534 ,p_is_pending => TRUE
5535 ,p_is_queued => TRUE
5536 ,p_is_dispatched => TRUE
5537 ,p_is_active => TRUE
5538 ,p_is_loaded => TRUE
5539 ,p_is_completed => TRUE
5540 ,p_include_inbound => FALSE
5541 ,p_include_outbound => FALSE
5542 ,p_include_manufacturing => FALSE
5543 ,p_include_warehousing => TRUE
5544 ,p_manufacturing_type => 1
5545 ,p_include_replenishment => FALSE
5546 ,p_include_mo_transfer => FALSE
5547 ,p_include_mo_issue => FALSE
5548 ,p_include_lpn_putaway => FALSE
5549 ,p_include_staging_move => FALSE
5550 ,p_include_cycle_count => TRUE
5551 ,p_cycle_count_name => v_cycle_count_name
5552 ,x_return_status => x_return_status
5553 ,x_msg_data => x_msg_data
5554 ,x_msg_count => x_msg_count
5555 ,x_record_count => l_record_count
5556 ,p_is_pending_plan => FALSE
5560 ,p_is_aborted_plan => FALSE
5557 ,p_is_inprogress_plan => FALSE
5558 ,p_is_completed_plan => FALSE
5559 ,p_is_cancelled_plan => FALSE
5561 );
5562
5563
5564 IF(l_debug = 1) THEN
5565 l_err_msg := 'Status returned by API wms_waveplan_tasks_pvt.query_tasks for cycle count task: '||x_return_status;
5566 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5567 END IF;
5568
5569 IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5570 /* SELECT * BULK COLLECT
5571 INTO x_task_tab
5572 FROM wms_waveplan_tasks_temp
5573 WHERE transaction_temp_id = p_transaction_number;*/
5574
5575 --Replacing the above by selecting columns from the table.
5576 SELECT
5577 TASK_ID,
5578 TRANSACTION_TEMP_ID,
5579 PARENT_LINE_ID,
5580 INVENTORY_ITEM_ID,
5581 ITEM,
5582 ITEM_DESCRIPTION,
5583 UNIT_WEIGHT,
5584 WEIGHT_UOM_CODE,
5585 DISPLAY_WEIGHT,
5586 UNIT_VOLUME,
5587 VOLUME_UOM_CODE,
5588 DISPLAY_VOLUME,
5589 TIME_ESTIMATE,
5590 ORGANIZATION_ID,
5591 ORGANIZATION_CODE,
5592 REVISION,
5593 SUBINVENTORY,
5594 LOCATOR_ID,
5595 LOCATOR,
5596 TRANSACTION_TYPE_ID,
5597 TRANSACTION_ACTION_ID,
5598 TRANSACTION_SOURCE_TYPE_ID,
5599 TRANSACTION_SOURCE_TYPE,
5600 TRANSACTION_SOURCE_ID,
5601 TRANSACTION_SOURCE_LINE_ID,
5602 TO_ORGANIZATION_ID,
5603 TO_ORGANIZATION_CODE,
5604 TO_SUBINVENTORY,
5605 TO_LOCATOR_ID,
5606 TO_LOCATOR,
5607 TRANSACTION_UOM,
5608 TRANSACTION_QUANTITY,
5609 USER_TASK_TYPE_ID,
5610 USER_TASK_TYPE,
5611 PERSON_ID,
5612 PERSON_ID_ORIGINAL,
5613 PERSON,
5614 EFFECTIVE_START_DATE,
5615 EFFECTIVE_END_DATE,
5616 PERSON_RESOURCE_ID,
5617 PERSON_RESOURCE_CODE,
5618 MACHINE_RESOURCE_ID,
5619 MACHINE_RESOURCE_CODE,
5620 EQUIPMENT_INSTANCE,
5621 STATUS_ID,
5622 STATUS_ID_ORIGINAL,
5623 STATUS,
5624 CREATION_TIME,
5625 DISPATCHED_TIME,
5626 LOADED_TIME,
5627 DROP_OFF_TIME,
5628 MMTT_LAST_UPDATE_DATE,
5629 MMTT_LAST_UPDATED_BY,
5630 WDT_LAST_UPDATE_DATE,
5631 WDT_LAST_UPDATED_BY,
5632 PRIORITY,
5633 PRIORITY_ORIGINAL,
5634 TASK_TYPE_ID,
5635 TASK_TYPE,
5636 MOVE_ORDER_LINE_ID,
5637 PICK_SLIP_NUMBER,
5638 CARTONIZATION_ID,
5639 ALLOCATED_LPN_ID,
5640 CONTAINER_ITEM_ID,
5641 CONTENT_LPN_ID,
5642 TO_LPN_ID,
5643 CONTAINER_ITEM ,
5644 CARTONIZATION_LPN,
5645 ALLOCATED_LPN ,
5646 CONTENT_LPN,
5647 TO_LPN,
5648 REFERENCE ,
5649 REFERENCE_ID,
5650 CUSTOMER_ID,
5651 CUSTOMER ,
5652 SHIP_TO_LOCATION_ID ,
5653 SHIP_TO_STATE ,
5654 SHIP_TO_COUNTRY,
5655 SHIP_TO_POSTAL_CODE,
5656 DELIVERY_ID ,
5657 DELIVERY ,
5658 SHIP_METHOD ,
5659 CARRIER_ID ,
5660 CARRIER ,
5661 SHIPMENT_DATE ,
5662 SHIPMENT_PRIORITY,
5663 WIP_ENTITY_TYPE,
5664 WIP_ENTITY_ID,
5665 ASSEMBLY_ID,
5666 ASSEMBLY ,
5667 LINE_ID,
5668 LINE,
5669 DEPARTMENT_ID,
5670 DEPARTMENT,
5671 SOURCE_HEADER,
5672 LINE_NUMBER,
5673 OPERATION_PLAN_ID,
5674 OPERATION_PLAN ,
5675 RESULT ,
5676 ERROR ,
5677 IS_MODIFIED ,
5678 EXPANSION_CODE ,
5679 FROM_LPN ,
5680 FROM_LPN_ID,
5681 NUM_OF_CHILD_TASKS,
5682 OPERATION_SEQUENCE,
5683 OP_PLAN_INSTANCE_ID,
5684 PLANS_TASKS ,
5685 TRANSACTION_SET_ID,
5686 PICKED_LPN_ID,
5687 PICKED_LPN,
5688 LOADED_LPN,
5689 LOADED_LPN_ID,
5690 DROP_LPN ,
5691 SECONDARY_TRANSACTION_QUANTITY,
5692 SECONDARY_TRANSACTION_UOM ,
5693 PRIMARY_PRODUCT,
5694 LOAD_SEQ_NUMBER
5695 BULK COLLECT
5696 INTO x_task_tab
5697 FROM wms_waveplan_tasks_temp
5698 WHERE transaction_temp_id = p_transaction_number;
5699
5700 END IF;
5701
5702 EXCEPTION
5703 WHEN NO_DATA_FOUND THEN
5704 --start changes for completed tasks
5705 BEGIN
5706 inv_trx_util_pub.trace('checking in wdth for completed inbound or crossdock tasks');
5707 SELECT *
5708 INTO l_wdth_rec
5709 FROM wms_dispatched_tasks_history
5710 WHERE transaction_id = p_transaction_number;
5711
5712 IF(l_debug = 1) THEN
5713 l_err_msg := 'Calling API wms_waveplan_tasks_pvt.query_tasks for task: '||p_transaction_number;
5714 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5715 END IF;
5716
5717 --Munish checking completed crossdock task
5718 OPEN c_cd_task1 (p_transaction_number);
5719 FETCH c_cd_task1 into c_cd_exist;
5720 CLOSE c_cd_task1;
5721
5722 If (c_cd_exist = 1) THEN
5723 inv_trx_util_pub.trace('calling API wms_waveplan_tasks_pvt.query_tasks for completed crossdock task');
5724 --CALLL wms_waveplan_tasks_pvt.query_tasks API WITH
5725 --p_crossdock_include=true and p_outbound_include=false and p_inbound_include=false
5726 wms_waveplan_tasks_pvt.query_tasks(
5727 p_add => FALSE
5728 ,p_organization_id => l_wdth_rec.organization_id
5729 ,p_subinventory_code => l_wdth_rec.source_subinventory_code
5730 ,p_locator_id => l_wdth_rec.source_locator_id
5731 ,p_to_subinventory_code => l_wdth_rec.dest_subinventory_code
5732 ,p_to_locator_id => l_wdth_rec.dest_locator_id
5736 ,p_from_creation_date => TRUNC(l_wdth_rec.creation_date)
5733 ,p_inventory_item_id => l_wdth_rec.inventory_item_id
5734 ,p_from_task_priority => l_wdth_rec.priority
5735 ,p_to_task_priority => l_wdth_rec.priority
5737 ,p_to_creation_date => TRUNC(l_wdth_rec.creation_date)
5738 ,p_is_unreleased => FALSE
5739 ,p_is_pending => FALSE
5740 ,p_is_queued => FALSE
5741 ,p_is_dispatched => FALSE
5742 ,p_is_active => FALSE
5743 ,p_is_loaded => FALSE
5744 ,p_is_completed => TRUE
5745 ,p_include_inbound => FALSE
5746 ,p_include_outbound => FALSE
5747 ,p_include_crossdock => TRUE
5748 ,p_include_manufacturing => FALSE
5749 ,p_include_warehousing => FALSE
5750 ,p_from_shipment_number => NULL
5751 ,p_to_shipment_number => NULL
5752 ,p_from_pick_slip_number => NULL
5753 ,p_to_pick_slip_number => NULL
5754 ,p_delivery_id => NULL
5755 ,p_manufacturing_type => 1
5756 ,p_include_staging_move => FALSE
5757 ,x_return_status => x_return_status
5758 ,x_msg_data => x_msg_data
5759 ,x_msg_count => x_msg_count
5760 ,x_record_count => l_record_count
5761 ,p_is_pending_plan => FALSE
5762 ,p_is_inprogress_plan => FALSE
5763 ,p_is_completed_plan => FALSE
5764 ,p_is_cancelled_plan => FALSE
5765 ,p_is_aborted_plan => FALSE
5766 );
5767 ELSE
5768 --CALLL wms_waveplan_tasks_pvt.query_tasks API WITH p_crossdock_include=false and
5769 --p_outbound_include=true and p_inbound_include=true
5770 inv_trx_util_pub.trace('calling completed inbound task');--mkgupta2
5771 IF l_wdth_rec.is_parent ='Y' THEN
5772 inv_trx_util_pub.trace('checking if its a parent task completed inbound task');
5773 l_wdth_rec.source_subinventory_code:=NULL;
5774 l_wdth_rec.source_locator_id:=NULL;
5775 END IF;
5776 wms_waveplan_tasks_pvt.query_tasks(
5777 p_add => FALSE
5778 ,p_organization_id => l_wdth_rec.organization_id
5779 ,p_subinventory_code => l_wdth_rec.source_subinventory_code
5780 ,p_locator_id => l_wdth_rec.source_locator_id
5781 ,p_to_subinventory_code => l_wdth_rec.dest_subinventory_code
5782 ,p_to_locator_id => l_wdth_rec.dest_locator_id
5783 ,p_inventory_item_id => l_wdth_rec.inventory_item_id
5784 ,p_from_task_priority => NULL
5785 ,p_to_task_priority => NULL
5786 ,p_from_creation_date => TRUNC(l_wdth_rec.creation_date)
5787 ,p_to_creation_date => TRUNC(l_wdth_rec.creation_date)
5788 ,p_is_unreleased => FALSE
5789 ,p_is_pending => FALSE
5790 ,p_is_queued => FALSE
5791 ,p_is_dispatched => FALSE
5792 ,p_is_active => FALSE
5793 ,p_is_loaded => FALSE
5794 ,p_is_completed => TRUE
5795 ,p_include_inbound => TRUE
5796 ,p_include_outbound => FALSE
5797 ,p_include_crossdock => FALSE
5798 ,p_include_manufacturing => FALSE
5799 ,p_include_warehousing => FALSE
5800 ,p_from_shipment_number => NULL
5801 ,p_to_shipment_number => NULL
5802 ,p_from_pick_slip_number => NULL
5803 ,p_to_pick_slip_number => NULL
5804 ,p_delivery_id => NULL
5805 ,p_manufacturing_type => 1
5806 ,p_include_staging_move => FALSE
5807 ,x_return_status => x_return_status
5808 ,x_msg_data => x_msg_data
5809 ,x_msg_count => x_msg_count
5810 ,x_record_count => l_record_count
5811 ,p_is_pending_plan =>TRUE
5812 ,p_is_inprogress_plan =>TRUE
5813 ,p_is_completed_plan =>TRUE
5814 ,p_is_cancelled_plan =>TRUE
5815 ,p_is_aborted_plan =>TRUE
5816 );
5817 END IF;
5818
5819 IF(l_debug = 1) THEN
5820 l_err_msg := 'Status returned by API wms_waveplan_tasks_pvt.query_tasks: '||x_return_status;
5821 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5822 END IF;
5823
5824 IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5825 SELECT
5826 TASK_ID,
5827 TRANSACTION_TEMP_ID,
5828 PARENT_LINE_ID,
5829 INVENTORY_ITEM_ID,
5830 ITEM,
5831 ITEM_DESCRIPTION,
5832 UNIT_WEIGHT,
5833 WEIGHT_UOM_CODE,
5834 DISPLAY_WEIGHT,
5835 UNIT_VOLUME,
5836 VOLUME_UOM_CODE,
5837 DISPLAY_VOLUME,
5838 TIME_ESTIMATE,
5839 ORGANIZATION_ID,
5840 ORGANIZATION_CODE,
5841 REVISION,
5842 SUBINVENTORY,
5843 LOCATOR_ID,
5844 LOCATOR,
5845 TRANSACTION_TYPE_ID,
5846 TRANSACTION_ACTION_ID,
5847 TRANSACTION_SOURCE_TYPE_ID,
5848 TRANSACTION_SOURCE_TYPE,
5849 TRANSACTION_SOURCE_ID,
5850 TRANSACTION_SOURCE_LINE_ID,
5851 TO_ORGANIZATION_ID,
5852 TO_ORGANIZATION_CODE,
5853 TO_SUBINVENTORY,
5854 TO_LOCATOR_ID,
5855 TO_LOCATOR,
5856 TRANSACTION_UOM,
5857 TRANSACTION_QUANTITY,
5858 USER_TASK_TYPE_ID,
5859 USER_TASK_TYPE,
5860 PERSON_ID,
5861 PERSON_ID_ORIGINAL,
5862 PERSON,
5863 EFFECTIVE_START_DATE,
5867 MACHINE_RESOURCE_ID,
5864 EFFECTIVE_END_DATE,
5865 PERSON_RESOURCE_ID,
5866 PERSON_RESOURCE_CODE,
5868 MACHINE_RESOURCE_CODE,
5869 EQUIPMENT_INSTANCE,
5870 STATUS_ID,
5871 STATUS_ID_ORIGINAL,
5872 STATUS,
5873 CREATION_TIME,
5874 DISPATCHED_TIME,
5875 LOADED_TIME,
5876 DROP_OFF_TIME,
5877 MMTT_LAST_UPDATE_DATE,
5878 MMTT_LAST_UPDATED_BY,
5879 WDT_LAST_UPDATE_DATE,
5880 WDT_LAST_UPDATED_BY,
5881 PRIORITY,
5882 PRIORITY_ORIGINAL,
5883 TASK_TYPE_ID,
5884 TASK_TYPE,
5885 MOVE_ORDER_LINE_ID,
5886 PICK_SLIP_NUMBER,
5887 CARTONIZATION_ID,
5888 ALLOCATED_LPN_ID,
5889 CONTAINER_ITEM_ID,
5890 CONTENT_LPN_ID,
5891 TO_LPN_ID,
5892 CONTAINER_ITEM ,
5893 CARTONIZATION_LPN,
5894 ALLOCATED_LPN ,
5895 CONTENT_LPN,
5896 TO_LPN,
5897 REFERENCE ,
5898 REFERENCE_ID,
5899 CUSTOMER_ID,
5900 CUSTOMER ,
5901 SHIP_TO_LOCATION_ID ,
5902 SHIP_TO_STATE ,
5903 SHIP_TO_COUNTRY,
5904 SHIP_TO_POSTAL_CODE,
5905 DELIVERY_ID ,
5906 DELIVERY ,
5907 SHIP_METHOD ,
5908 CARRIER_ID ,
5909 CARRIER ,
5910 SHIPMENT_DATE ,
5911 SHIPMENT_PRIORITY,
5912 WIP_ENTITY_TYPE,
5913 WIP_ENTITY_ID,
5914 ASSEMBLY_ID,
5915 ASSEMBLY ,
5916 LINE_ID,
5917 LINE,
5918 DEPARTMENT_ID,
5919 DEPARTMENT,
5920 SOURCE_HEADER,
5921 LINE_NUMBER,
5922 OPERATION_PLAN_ID,
5923 OPERATION_PLAN ,
5924 RESULT ,
5925 ERROR ,
5926 IS_MODIFIED ,
5927 EXPANSION_CODE ,
5928 FROM_LPN ,
5929 FROM_LPN_ID,
5930 NUM_OF_CHILD_TASKS,
5931 OPERATION_SEQUENCE,
5932 OP_PLAN_INSTANCE_ID,
5933 PLANS_TASKS ,
5934 TRANSACTION_SET_ID,
5935 PICKED_LPN_ID,
5936 PICKED_LPN,
5937 LOADED_LPN,
5938 LOADED_LPN_ID,
5939 DROP_LPN ,
5940 SECONDARY_TRANSACTION_QUANTITY,
5941 SECONDARY_TRANSACTION_UOM ,
5942 PRIMARY_PRODUCT,
5943 LOAD_SEQ_NUMBER
5944 BULK COLLECT
5945 INTO x_task_tab
5946 FROM wms_waveplan_tasks_temp
5947 WHERE transaction_temp_id = p_transaction_number;
5948 END IF;
5949 EXCEPTION
5950 WHEN NO_DATA_FOUND THEN
5951 inv_trx_util_pub.trace('in the NO_DATA_FOUND exception block of inbound/crossdock completed task');
5952 BEGIN
5953 inv_trx_util_pub.trace('checking in mmt for outbound/warehouse/manufacturing completed task');
5954 SELECT *
5955 INTO l_mmt_rec
5956 FROM mtl_material_transactions
5957 WHERE transaction_id = p_transaction_number;
5958 inv_trx_util_pub.trace('task existing in mmt');
5959
5960 IF(l_debug = 1) THEN
5961 l_err_msg := 'Calling API wms_waveplan_tasks_pvt.query_tasks for task: '||p_transaction_number;
5962 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
5963 END IF;
5964
5965 inv_trx_util_pub.trace('checking for bulk task');
5966 IF l_mmt_rec.parent_transaction_id IS NOT NULL THEN
5967 l_mmt_rec.pick_slip_number:=NULL;
5968 END IF;
5969 wms_waveplan_tasks_pvt.query_tasks(
5970 p_add => FALSE
5971 ,p_organization_id => l_mmt_rec.organization_id
5972 ,p_subinventory_code => l_mmt_rec.subinventory_code
5973 ,p_locator_id => l_mmt_rec.locator_id
5974 ,p_to_subinventory_code => l_mmt_rec.transfer_subinventory
5975 ,p_to_locator_id => l_mmt_rec.transfer_locator_id
5976 ,p_inventory_item_id => l_mmt_rec.inventory_item_id
5977 ,p_from_task_priority => NULL
5978 ,p_to_task_priority => NULL
5979 ,p_from_creation_date => TRUNC(l_mmt_rec.creation_date)
5980 ,p_to_creation_date => TRUNC(l_mmt_rec.creation_date)
5981 ,p_is_unreleased => FALSE
5982 ,p_is_pending => FALSE
5983 ,p_is_queued => FALSE
5984 ,p_is_dispatched => FALSE
5985 ,p_is_active => FALSE
5986 ,p_is_loaded => FALSE
5987 ,p_is_completed => TRUE
5988 ,p_include_inbound => FALSE
5989 ,p_include_outbound => TRUE
5990 ,p_include_crossdock => FALSE
5991 ,p_include_manufacturing => TRUE
5992 ,p_include_warehousing => TRUE
5993 ,p_from_shipment_number => l_mmt_rec.shipment_number
5994 ,p_to_shipment_number => l_mmt_rec.shipment_number
5995 ,p_from_pick_slip_number => l_mmt_rec.pick_slip_number
5996 ,p_to_pick_slip_number => l_mmt_rec.pick_slip_number
5997 ,p_delivery_id => l_mmt_rec.trx_source_delivery_id
5998 ,p_manufacturing_type => 1
5999 ,p_include_staging_move => TRUE
6000 ,x_return_status => x_return_status
6001 ,x_msg_data => x_msg_data
6002 ,x_msg_count => x_msg_count
6003 ,x_record_count => l_record_count
6004 ,p_is_pending_plan =>FALSE
6005 ,p_is_inprogress_plan =>FALSE
6006 ,p_is_completed_plan =>FALSE
6007 ,p_is_cancelled_plan =>FALSE
6008 ,p_is_aborted_plan =>FALSE
6009 );
6010
6011 IF(l_debug = 1) THEN
6012 l_err_msg := 'Status returned by API wms_waveplan_tasks_pvt.query_tasks: '||x_return_status;
6013 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6014 END IF;
6015
6019 TRANSACTION_TEMP_ID,
6016 IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6017 SELECT
6018 TASK_ID,
6020 PARENT_LINE_ID,
6021 INVENTORY_ITEM_ID,
6022 ITEM,
6023 ITEM_DESCRIPTION,
6024 UNIT_WEIGHT,
6025 WEIGHT_UOM_CODE,
6026 DISPLAY_WEIGHT,
6027 UNIT_VOLUME,
6028 VOLUME_UOM_CODE,
6029 DISPLAY_VOLUME,
6030 TIME_ESTIMATE,
6031 ORGANIZATION_ID,
6032 ORGANIZATION_CODE,
6033 REVISION,
6034 SUBINVENTORY,
6035 LOCATOR_ID,
6036 LOCATOR,
6037 TRANSACTION_TYPE_ID,
6038 TRANSACTION_ACTION_ID,
6039 TRANSACTION_SOURCE_TYPE_ID,
6040 TRANSACTION_SOURCE_TYPE,
6041 TRANSACTION_SOURCE_ID,
6042 TRANSACTION_SOURCE_LINE_ID,
6043 TO_ORGANIZATION_ID,
6044 TO_ORGANIZATION_CODE,
6045 TO_SUBINVENTORY,
6046 TO_LOCATOR_ID,
6047 TO_LOCATOR,
6048 TRANSACTION_UOM,
6049 TRANSACTION_QUANTITY,
6050 USER_TASK_TYPE_ID,
6051 USER_TASK_TYPE,
6052 PERSON_ID,
6053 PERSON_ID_ORIGINAL,
6054 PERSON,
6055 EFFECTIVE_START_DATE,
6056 EFFECTIVE_END_DATE,
6057 PERSON_RESOURCE_ID,
6058 PERSON_RESOURCE_CODE,
6059 MACHINE_RESOURCE_ID,
6060 MACHINE_RESOURCE_CODE,
6061 EQUIPMENT_INSTANCE,
6062 STATUS_ID,
6063 STATUS_ID_ORIGINAL,
6064 STATUS,
6065 CREATION_TIME,
6066 DISPATCHED_TIME,
6067 LOADED_TIME,
6068 DROP_OFF_TIME,
6069 MMTT_LAST_UPDATE_DATE,
6070 MMTT_LAST_UPDATED_BY,
6071 WDT_LAST_UPDATE_DATE,
6072 WDT_LAST_UPDATED_BY,
6073 PRIORITY,
6074 PRIORITY_ORIGINAL,
6075 TASK_TYPE_ID,
6076 TASK_TYPE,
6077 MOVE_ORDER_LINE_ID,
6078 PICK_SLIP_NUMBER,
6079 CARTONIZATION_ID,
6080 ALLOCATED_LPN_ID,
6081 CONTAINER_ITEM_ID,
6082 CONTENT_LPN_ID,
6083 TO_LPN_ID,
6084 CONTAINER_ITEM ,
6085 CARTONIZATION_LPN,
6086 ALLOCATED_LPN ,
6087 CONTENT_LPN,
6088 TO_LPN,
6089 REFERENCE ,
6090 REFERENCE_ID,
6091 CUSTOMER_ID,
6092 CUSTOMER ,
6093 SHIP_TO_LOCATION_ID ,
6094 SHIP_TO_STATE ,
6095 SHIP_TO_COUNTRY,
6096 SHIP_TO_POSTAL_CODE,
6097 DELIVERY_ID ,
6098 DELIVERY ,
6099 SHIP_METHOD ,
6100 CARRIER_ID ,
6101 CARRIER ,
6102 SHIPMENT_DATE ,
6103 SHIPMENT_PRIORITY,
6104 WIP_ENTITY_TYPE,
6105 WIP_ENTITY_ID,
6106 ASSEMBLY_ID,
6107 ASSEMBLY ,
6108 LINE_ID,
6109 LINE,
6110 DEPARTMENT_ID,
6111 DEPARTMENT,
6112 SOURCE_HEADER,
6113 LINE_NUMBER,
6114 OPERATION_PLAN_ID,
6115 OPERATION_PLAN ,
6116 RESULT ,
6117 ERROR ,
6118 IS_MODIFIED ,
6119 EXPANSION_CODE ,
6120 FROM_LPN ,
6121 FROM_LPN_ID,
6122 NUM_OF_CHILD_TASKS,
6123 OPERATION_SEQUENCE,
6124 OP_PLAN_INSTANCE_ID,
6125 PLANS_TASKS ,
6126 TRANSACTION_SET_ID,
6127 PICKED_LPN_ID,
6128 PICKED_LPN,
6129 LOADED_LPN,
6130 LOADED_LPN_ID,
6131 DROP_LPN ,
6132 SECONDARY_TRANSACTION_QUANTITY,
6133 SECONDARY_TRANSACTION_UOM ,
6134 PRIMARY_PRODUCT,
6135 LOAD_SEQ_NUMBER
6136 BULK COLLECT
6137 INTO x_task_tab
6138 FROM wms_waveplan_tasks_temp
6139 WHERE transaction_temp_id = p_transaction_number;
6140
6141 END IF;
6142 EXCEPTION
6143 WHEN NO_DATA_FOUND THEN
6144 inv_trx_util_pub.trace('in the exception block of outbond/manufacturing/warehousing complete tasks');
6145 fnd_message.set_name('WMS', 'WMS_INVALID_TASK');
6146 fnd_msg_pub.ADD;
6147 x_return_status := fnd_api.g_ret_sts_unexp_error;
6148 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6149 l_err_msg := 'Failed to fetch data from MMTT,MCCE,MMT or WDTH tables for transaction number '||p_transaction_number;
6150 IF(l_debug = 1) THEN
6151 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6152 END IF;
6153 END;
6154 --end the begin block for outbond/manufacturing/warehousing complete tasks
6155 END;
6156 --end the begin block for inbound/crossdock complete tasks
6157 END;
6158 --end the begin block for cycle count tasks
6159 WHEN OTHERS THEN
6160 x_return_status := fnd_api.g_ret_sts_unexp_error;
6161 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6162 l_err_msg := substr(SQLERRM,1,1000);
6163 IF(l_debug = 1) THEN
6164 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6165 END IF;
6166 END;
6167 --end the begin block for uncompleted tasks
6168
6169 ELSIF (p_query_name IS NOT NULL) THEN
6170 ---initialize the main table
6171 initialize_main_table();
6172
6173 ---populate the l_query_tab table with cursor output
6174 BEGIN
6175 SELECT REPLACE(field_name,'FIND_TASKS.','') field_name,
6176 decode(field_value,'Y','T','N','F',field_value) field_value
6177 BULK COLLECT
6178 INTO l_query_tab
6179 FROM wms_saved_queries
6180 WHERE query_name = p_query_name
6181 ORDER BY 1;
6182 EXCEPTION
6183 WHEN OTHERS THEN
6184 fnd_message.set_name('WMS', 'WMS_INVALID_VALUE');
6185 fnd_msg_pub.ADD;
6186 l_err_msg := substr(SQLERRM,1,1000);
6187 RAISE l_qry_fail;
6188 END;
6189
6190 IF (l_query_tab.COUNT > 0) THEN
6191 ---pass the field_values from l_query_tab table
6192 ---to the field_values in g_main_tab table for
6193 ---matching field_names
6194 FOR i IN l_query_tab.FIRST..l_query_tab.LAST
6195 LOOP
6199 g_main_tab(j).field_value := l_query_tab(i).field_value;
6196 FOR j IN g_main_tab.FIRST..g_main_tab.LAST
6197 LOOP
6198 IF (g_main_tab(j).field_name = l_query_tab(i).field_name) THEN
6200 EXIT; -- exit the inner loop
6201 END IF;
6202 END LOOP; --- loop for j
6203 END LOOP; --- loop for i
6204 END IF; ----l_query_tab.COUNT > 0
6205
6206 --- check the credentials of the query_name passed as input
6207
6208 ---if 'inbound' task is queried then
6209 --Munish is adding (g_main_tab(93).field_value = FND_API.G_TRUE) to check crossdock task
6210 IF(g_main_tab(35).field_value = FND_API.G_TRUE) OR (g_main_tab(93).field_value = FND_API.G_TRUE) THEN
6211 -- IF(g_main_tab(35).field_value = FND_API.G_TRUE) THEN
6212 ---if its planned or independent task
6213 IF ((g_main_tab(36).field_value = FND_API.G_TRUE)
6214 OR (g_main_tab(58).field_value = FND_API.G_TRUE))
6215 THEN
6216 ---the status has to be either one of the following:
6217 ---unreleased, pending, queued, dispatched,active, loaded, completed
6218 IF((g_main_tab(1).field_value = FND_API.G_TRUE)
6219 OR (g_main_tab(5).field_value = FND_API.G_TRUE)
6220 OR (g_main_tab(12).field_value = FND_API.G_TRUE)
6221 OR (g_main_tab(39).field_value = FND_API.G_TRUE)
6222 OR (g_main_tab(51).field_value = FND_API.G_TRUE)
6223 OR (g_main_tab(59).field_value = FND_API.G_TRUE)
6224 OR (g_main_tab(90).field_value = FND_API.G_TRUE))
6225 THEN
6226 l_execute_qry := TRUE;
6227 END IF;
6228 --else if it's not planned or independent task then
6229 --it has to be either one of plan_pending, plan_in_progress, plan_completed
6230 --plan_cancelled or plan_aborted
6231 ELSIF((g_main_tab(53).field_value = FND_API.G_TRUE)
6232 OR (g_main_tab(54).field_value = FND_API.G_TRUE)
6233 OR (g_main_tab(55).field_value = FND_API.G_TRUE)
6234 OR (g_main_tab(56).field_value = FND_API.G_TRUE)
6235 OR (g_main_tab(57).field_value = FND_API.G_TRUE))
6236 THEN
6237 l_execute_qry := TRUE;
6238 ELSE
6239 l_execute_qry := FALSE;
6240 l_err_msg := 'Invalid query criteria';
6241 fnd_message.set_name('WMS', 'WMS_NO_SOURCE_ENTERED');
6242 fnd_msg_pub.ADD;
6243 RAISE l_qry_fail;
6244 END IF;
6245 END IF;
6246
6247 --If its either outbound, manufacturing or warehousing tasks
6248 IF ((g_main_tab(50).field_value = FND_API.G_TRUE)
6249 OR(g_main_tab(42).field_value = FND_API.G_TRUE)
6250 OR(g_main_tab(92).field_value = FND_API.G_TRUE))
6251 THEN
6252 ---the status has to be either one of the following:
6253 ---unreleased, pending, queued, dispatched,active, loaded, completed
6254 IF((g_main_tab(1).field_value = FND_API.G_TRUE)
6255 OR (g_main_tab(5).field_value = FND_API.G_TRUE)
6256 OR (g_main_tab(12).field_value = FND_API.G_TRUE)
6257 OR (g_main_tab(39).field_value = FND_API.G_TRUE)
6258 OR (g_main_tab(51).field_value = FND_API.G_TRUE)
6259 OR (g_main_tab(59).field_value = FND_API.G_TRUE)
6260 OR (g_main_tab(90).field_value = FND_API.G_TRUE))
6261 THEN
6262 l_execute_qry := TRUE;
6263 END IF;
6264 ---else if its neither one of the following tasks then generate error message
6265 ---outbound, inbound, manufacturing, warehousing
6266 ELSIF ((g_main_tab(50).field_value = FND_API.G_FALSE)
6267 AND(g_main_tab(42).field_value = FND_API.G_FALSE)
6268 AND(g_main_tab(92).field_value = FND_API.G_FALSE)
6269 AND(g_main_tab(35).field_value = FND_API.G_FALSE)
6270 AND (g_main_tab(93).field_value = FND_API.G_FALSE))
6271 THEN
6272 l_execute_qry := FALSE;
6273 l_err_msg := 'Invalid query criteria';
6274 fnd_message.set_name('WMS', 'WMS_NO_SOURCE_ENTERED');
6275 fnd_msg_pub.ADD;
6276 RAISE l_qry_fail;
6277 END IF;
6278
6279 --- Derive organization_id
6280 BEGIN
6281 SELECT DISTINCT organization_id
6282 INTO l_organization_id
6283 FROM wms_saved_queries
6284 WHERE query_name = p_query_name;
6285 EXCEPTION
6286 WHEN OTHERS THEN
6287 fnd_message.set_name('WMS', 'WMS_CONT_INVALID_ORG');
6288 fnd_msg_pub.ADD;
6289 l_err_msg := concat('Invalid Org: ',substr(SQLERRM,1,1000));
6290 RAISE l_invalid_org;
6291 NULL;
6292 END;
6293
6294 ---logic to initialize variables
6295 ---v_include_sales_orders, v_include_internal_orders
6296 l_order_type := g_main_tab(49).field_value;
6297
6298 IF (upper(l_order_type) = 'B') THEN
6299 l_include_sales_orders := TRUE;
6300 l_include_internal_orders := TRUE;
6301 ELSIF (upper(l_order_type) = 'S') THEN
6302 l_include_sales_orders := TRUE;
6303 ELSIF (upper(l_order_type) = 'I') THEN
6304 l_include_internal_orders := TRUE;
6305 END IF;
6306 ---end logic to initialize variables
6307 ---v_include_sales_orders , v_include_internal_orders
6308
6309 ---call the main API to find the queried tasks
6310 IF (l_execute_qry) THEN
6311
6312 IF(l_debug = 1) THEN
6313 l_err_msg := 'Calling API wms_waveplan_tasks_pvt.query_tasks for Query: '||p_query_name;
6314 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6315 END IF;
6316
6317 wms_waveplan_tasks_pvt.query_tasks (
6318 FALSE, ---p_add BOOLEAN DEFAULT FALSE,
6319 l_organization_id, ---p_organization_id NUMBER DEFAULT NULL,
6320 g_main_tab(67).field_value, ---p_subinventory_code VARCHAR2 DEFAULT NULL,
6321 g_main_tab(40).field_value, ---p_locator_id NUMBER DEFAULT NULL,
6322 g_main_tab(85).field_value, ---p_to_subinventory_code VARCHAR2 DEFAULT NULL,
6323 g_main_tab(72).field_value, ---p_to_locator_id NUMBER DEFAULT NULL,
6327 g_main_tab(13).field_value, ---p_person_id NUMBER DEFAULT NULL,
6324 g_main_tab(37).field_value, ---p_inventory_item_id NUMBER DEFAULT NULL,
6325 g_main_tab(4).field_value, ---p_category_set_id NUMBER DEFAULT NULL,
6326 g_main_tab(38).field_value, ---p_item_category_id NUMBER DEFAULT NULL,
6328 g_main_tab(52).field_value, ---p_person_resource_id NUMBER DEFAULT NULL,
6329 g_main_tab(15).field_value, ---p_equipment_type_id NUMBER DEFAULT NULL,
6330 NULL, ---p_machine_resource_id NUMBER DEFAULT NULL,
6331 g_main_tab(14).field_value, ---p_machine_instance VARCHAR2 DEFAULT NULL,
6332 g_main_tab(91).field_value, ---p_user_task_type_id NUMBER DEFAULT NULL,
6333 g_main_tab(33).field_value, ---p_from_task_quantity NUMBER DEFAULT NULL,
6334 g_main_tab(87).field_value, ---p_to_task_quantity NUMBER DEFAULT NULL,
6335 g_main_tab(32).field_value, ---p_from_task_priority NUMBER DEFAULT NULL,
6336 g_main_tab(86).field_value, ---p_to_task_priority NUMBER DEFAULT NULL,
6337 g_main_tab(16).field_value, ---p_from_creation_date DATE DEFAULT NULL,
6338 g_main_tab(68).field_value, ---p_to_creation_date DATE DEFAULT NULL,
6339 fnd_api.to_boolean(g_main_tab(90).field_value), ---p_is_unreleased BOOLEAN DEFAULT FALSE,
6340 fnd_api.to_boolean(g_main_tab(51).field_value), ---p_is_pending BOOLEAN DEFAULT FALSE,
6341 fnd_api.to_boolean(g_main_tab(59).field_value), ---p_is_queued BOOLEAN DEFAULT FALSE,
6342 fnd_api.to_boolean(g_main_tab(12).field_value), ---p_is_dispatched BOOLEAN DEFAULT FALSE,
6343 fnd_api.to_boolean(g_main_tab(1).field_value), ---p_is_active BOOLEAN DEFAULT FALSE,
6344 fnd_api.to_boolean(g_main_tab(39).field_value), ---p_is_loaded BOOLEAN DEFAULT FALSE,
6345 fnd_api.to_boolean(g_main_tab(5).field_value), ---p_is_completed BOOLEAN DEFAULT FALSE,
6346 fnd_api.to_boolean(g_main_tab(35).field_value), ---p_include_inbound BOOLEAN DEFAULT FALSE,
6347 fnd_api.to_boolean(g_main_tab(50).field_value), ---p_include_outbound BOOLEAN DEFAULT FALSE,
6348 fnd_api.to_boolean(g_main_tab(93).field_value), ---p_include_crossdock
6349 fnd_api.to_boolean(g_main_tab(42).field_value), ---p_include_manufacturing BOOLEAN DEFAULT FALSE,
6350 fnd_api.to_boolean(g_main_tab(92).field_value), ---p_include_warehousing BOOLEAN DEFAULT FALSE,
6351 g_main_tab(21).field_value, ---p_from_po_header_id NUMBER DEFAULT NULL,
6352 g_main_tab(74).field_value, ---p_to_po_header_id NUMBER DEFAULT NULL,
6353 g_main_tab(22).field_value, ---p_from_purchase_order VARCHAR2 DEFAULT NULL,
6354 g_main_tab(75).field_value, ---p_to_purchase_order VARCHAR2 DEFAULT NULL,
6355 g_main_tab(27).field_value, ---p_from_rma_header_id NUMBER DEFAULT NULL,
6356 g_main_tab(80).field_value, ---p_to_rma_header_id NUMBER DEFAULT NULL,
6357 g_main_tab(26).field_value, ---p_from_rma VARCHAR2 DEFAULT NULL,
6358 g_main_tab(79).field_value, ---p_to_rma VARCHAR2 DEFAULT NULL,
6359 g_main_tab(25).field_value, ---p_from_requisition_header_id NUMBER DEFAULT NULL,
6360 g_main_tab(78).field_value, ---p_to_requisition_header_id NUMBER DEFAULT NULL,
6361 g_main_tab(24).field_value, ---p_from_requisition VARCHAR2 DEFAULT NULL,
6362 g_main_tab(77).field_value, ---p_to_requisition VARCHAR2 DEFAULT NULL,
6363 g_main_tab(29).field_value, ---p_from_shipment_number VARCHAR2 DEFAULT NULL,
6364 g_main_tab(82).field_value, ---p_to_shipment_number VARCHAR2 DEFAULT NULL,
6365 l_include_sales_orders, ---p_include_sales_orders BOOLEAN DEFAULT TRUE,
6366 l_include_internal_orders, ---p_include_internal_orders BOOLEAN DEFAULT TRUE,
6367 g_main_tab(28).field_value, ---p_from_sales_order_id NUMBER DEFAULT NULL,
6368 g_main_tab(81).field_value, ---p_to_sales_order_id NUMBER DEFAULT NULL,
6369 g_main_tab(20).field_value, ---p_from_pick_slip_number NUMBER DEFAULT NULL,
6370 g_main_tab(73).field_value, ---p_to_pick_slip_number NUMBER DEFAULT NULL,
6371 g_main_tab(7).field_value, ---p_customer_id NUMBER DEFAULT NULL,
6372 g_main_tab(6).field_value, ---p_customer_category VARCHAR2 DEFAULT NULL,
6373 g_main_tab(10).field_value, ---p_delivery_id NUMBER DEFAULT NULL,
6374 g_main_tab(3).field_value, ---p_carrier_id NUMBER DEFAULT NULL,
6375 g_main_tab(61).field_value, ---p_ship_method VARCHAR2 DEFAULT NULL,
6376 g_main_tab(65).field_value, ---p_shipment_priority VARCHAR2 DEFAULT NULL,
6377 g_main_tab(89).field_value, ---p_trip_id NUMBER DEFAULT NULL,
6378 g_main_tab(30).field_value, ---p_from_shipment_date DATE DEFAULT NULL,
6379 g_main_tab(83).field_value, ---p_to_shipment_date DATE DEFAULT NULL,
6380 g_main_tab(64).field_value, ---p_ship_to_state VARCHAR2 DEFAULT NULL,
6381 g_main_tab(62).field_value, ---p_ship_to_country VARCHAR2 DEFAULT NULL,
6382 g_main_tab(63).field_value, ---p_ship_to_postal_code VARCHAR2 DEFAULT NULL,
6383 g_main_tab(19).field_value, ---p_from_number_of_order_lines NUMBER DEFAULT NULL,
6384 g_main_tab(71).field_value, ---p_to_number_of_order_lines NUMBER DEFAULT NULL,
6385 g_main_tab(43).field_value, ---p_manufacturing_type VARCHAR2 DEFAULT NULL,
6386 g_main_tab(17).field_value, ---p_from_job VARCHAR2 DEFAULT NULL,
6387 g_main_tab(69).field_value, ---p_to_job VARCHAR2 DEFAULT NULL,
6388 g_main_tab(2).field_value, ---p_assembly_id NUMBER DEFAULT NULL,
6389 g_main_tab(31).field_value, ---p_from_start_date DATE DEFAULT NULL,
6390 g_main_tab(84).field_value, ---p_to_start_date DATE DEFAULT NULL,
6391 g_main_tab(18).field_value, ---p_from_line VARCHAR2 DEFAULT NULL,
6392 g_main_tab(70).field_value, ---p_to_line VARCHAR2 DEFAULT NULL,
6396 g_main_tab(76).field_value, ---p_to_replenishment_mo VARCHAR2 DEFAULT NULL,
6393 g_main_tab(11).field_value, ---p_department_id NUMBER DEFAULT NULL,
6394 fnd_api.to_boolean(g_main_tab(60).field_value), ---p_include_replenishment BOOLEAN DEFAULT TRUE,
6395 g_main_tab(23).field_value, ---p_from_replenishment_mo VARCHAR2 DEFAULT NULL,
6397 fnd_api.to_boolean(g_main_tab(45).field_value), ---p_include_mo_transfer BOOLEAN DEFAULT TRUE,
6398 fnd_api.to_boolean(g_main_tab(44).field_value), ---p_include_mo_issue BOOLEAN DEFAULT TRUE,
6399 g_main_tab(34).field_value, ---p_from_transfer_issue_mo VARCHAR2 DEFAULT NULL,
6400 g_main_tab(88).field_value, ---p_to_transfer_issue_mo VARCHAR2 DEFAULT NULL,
6401 fnd_api.to_boolean(g_main_tab(41).field_value), ---p_include_lpn_putaway BOOLEAN DEFAULT TRUE,
6402 fnd_api.to_boolean(g_main_tab(66).field_value), ---p_include_staging_move BOOLEAN DEFAULT FALSE,
6403 fnd_api.to_boolean(g_main_tab(9).field_value), ---p_include_cycle_count BOOLEAN DEFAULT TRUE,
6404 g_main_tab(8).field_value, ---p_cycle_count_name VARCHAR2 DEFAULT NULL,
6405 l_record_count, ---OUT NOCOPY NUMBER,
6406 x_return_status, ---OUT NOCOPY VARCHAR2,
6407 x_msg_data, ---OUT NOCOPY VARCHAR2,
6408 x_msg_count, ---OUT NOCOPY NUMBER,
6409 fnd_api.to_boolean(g_main_tab(36).field_value), ---p_query_independent_tasks BOOLEAN DEFAULT TRUE,
6410 fnd_api.to_boolean(g_main_tab(58).field_value), ---p_query_planned_tasks BOOLEAN DEFAULT TRUE,
6411 fnd_api.to_boolean(g_main_tab(57).field_value), ---p_is_pending_plan BOOLEAN DEFAULT FALSE,
6412 fnd_api.to_boolean(g_main_tab(56).field_value), ---p_is_inprogress_plan BOOLEAN DEFAULT FALSE,
6413 fnd_api.to_boolean(g_main_tab(55).field_value), ---p_is_completed_plan BOOLEAN DEFAULT FALSE,
6414 fnd_api.to_boolean(g_main_tab(54).field_value), ---p_is_cancelled_plan BOOLEAN DEFAULT FALSE,
6415 fnd_api.to_boolean(g_main_tab(53).field_value), ---p_is_aborted_plan BOOLEAN DEFAULT FALSE,
6416 g_main_tab(46).field_value, ---p_activity_id NUMBER DEFAULT NULL,
6417 g_main_tab(48).field_value, ---p_plan_type_id NUMBER DEFAULT NULL,
6418 g_main_tab(47).field_value ---p_op_plan_id NUMBER DEFAULT NULL
6419 );
6420
6421 IF(l_debug = 1) THEN
6422 l_err_msg := 'Status returned by API wms_waveplan_tasks_pvt.query_tasks: '||x_return_status;
6423 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6424 END IF;
6425
6426 IF(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6427 /* SELECT * BULK COLLECT
6428 INTO x_task_tab
6429 FROM wms_waveplan_tasks_temp;*/
6430 --Replacing the above by selecting columns from the table.
6431 SELECT
6432 TASK_ID,
6433 TRANSACTION_TEMP_ID,
6434 PARENT_LINE_ID,
6435 INVENTORY_ITEM_ID,
6436 ITEM,
6437 ITEM_DESCRIPTION,
6438 UNIT_WEIGHT,
6439 WEIGHT_UOM_CODE,
6440 DISPLAY_WEIGHT,
6441 UNIT_VOLUME,
6442 VOLUME_UOM_CODE,
6443 DISPLAY_VOLUME,
6444 TIME_ESTIMATE,
6445 ORGANIZATION_ID,
6446 ORGANIZATION_CODE,
6447 REVISION,
6448 SUBINVENTORY,
6449 LOCATOR_ID,
6450 LOCATOR,
6451 TRANSACTION_TYPE_ID,
6452 TRANSACTION_ACTION_ID,
6453 TRANSACTION_SOURCE_TYPE_ID,
6454 TRANSACTION_SOURCE_TYPE,
6455 TRANSACTION_SOURCE_ID,
6456 TRANSACTION_SOURCE_LINE_ID,
6457 TO_ORGANIZATION_ID,
6458 TO_ORGANIZATION_CODE,
6459 TO_SUBINVENTORY,
6460 TO_LOCATOR_ID,
6461 TO_LOCATOR,
6462 TRANSACTION_UOM,
6463 TRANSACTION_QUANTITY,
6464 USER_TASK_TYPE_ID,
6465 USER_TASK_TYPE,
6466 PERSON_ID,
6467 PERSON_ID_ORIGINAL,
6468 PERSON,
6469 EFFECTIVE_START_DATE,
6470 EFFECTIVE_END_DATE,
6471 PERSON_RESOURCE_ID,
6472 PERSON_RESOURCE_CODE,
6473 MACHINE_RESOURCE_ID,
6474 MACHINE_RESOURCE_CODE,
6475 EQUIPMENT_INSTANCE,
6476 STATUS_ID,
6477 STATUS_ID_ORIGINAL,
6478 STATUS,
6479 CREATION_TIME,
6480 DISPATCHED_TIME,
6481 LOADED_TIME,
6482 DROP_OFF_TIME,
6483 MMTT_LAST_UPDATE_DATE,
6484 MMTT_LAST_UPDATED_BY,
6485 WDT_LAST_UPDATE_DATE,
6486 WDT_LAST_UPDATED_BY,
6487 PRIORITY,
6488 PRIORITY_ORIGINAL,
6489 TASK_TYPE_ID,
6490 TASK_TYPE,
6491 MOVE_ORDER_LINE_ID,
6492 PICK_SLIP_NUMBER,
6493 CARTONIZATION_ID,
6494 ALLOCATED_LPN_ID,
6495 CONTAINER_ITEM_ID,
6496 CONTENT_LPN_ID,
6497 TO_LPN_ID,
6498 CONTAINER_ITEM ,
6499 CARTONIZATION_LPN,
6500 ALLOCATED_LPN ,
6501 CONTENT_LPN,
6502 TO_LPN,
6503 REFERENCE ,
6504 REFERENCE_ID,
6505 CUSTOMER_ID,
6506 CUSTOMER ,
6507 SHIP_TO_LOCATION_ID ,
6508 SHIP_TO_STATE ,
6509 SHIP_TO_COUNTRY,
6510 SHIP_TO_POSTAL_CODE,
6511 DELIVERY_ID ,
6512 DELIVERY ,
6513 SHIP_METHOD ,
6514 CARRIER_ID ,
6515 CARRIER ,
6516 SHIPMENT_DATE ,
6517 SHIPMENT_PRIORITY,
6518 WIP_ENTITY_TYPE,
6519 WIP_ENTITY_ID,
6520 ASSEMBLY_ID,
6521 ASSEMBLY ,
6522 LINE_ID,
6523 LINE,
6524 DEPARTMENT_ID,
6525 DEPARTMENT,
6526 SOURCE_HEADER,
6527 LINE_NUMBER,
6528 OPERATION_PLAN_ID,
6529 OPERATION_PLAN ,
6530 RESULT ,
6531 ERROR ,
6532 IS_MODIFIED ,
6533 EXPANSION_CODE,
6534 FROM_LPN ,
6535 FROM_LPN_ID,
6536 NUM_OF_CHILD_TASKS,
6537 OPERATION_SEQUENCE,
6538 OP_PLAN_INSTANCE_ID,
6539 PLANS_TASKS ,
6540 TRANSACTION_SET_ID,
6541 PICKED_LPN_ID,
6542 PICKED_LPN,
6543 LOADED_LPN,
6547 SECONDARY_TRANSACTION_UOM ,
6544 LOADED_LPN_ID,
6545 DROP_LPN ,
6546 SECONDARY_TRANSACTION_QUANTITY,
6548 PRIMARY_PRODUCT,
6549 LOAD_SEQ_NUMBER
6550 BULK COLLECT
6551 INTO x_task_tab
6552 FROM wms_waveplan_tasks_temp;
6553 END IF;
6554
6555 END IF; --- if l_execute_qry then
6556
6557 ELSE
6558 x_return_status := fnd_api.g_ret_sts_unexp_error;
6559 fnd_message.set_name('WMS', 'WMS_INVALID_VALUE');
6560 fnd_msg_pub.ADD;
6561 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6562 inv_trx_util_pub.trace(l_api_name||': '||'Invalid Parameters Passed');
6563 END IF; ----if p_transaction_number is not null
6564
6565 EXCEPTION
6566 WHEN l_invalid_org THEN
6567 x_return_status := fnd_api.g_ret_sts_unexp_error;
6568 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6569 IF(l_debug = 1) THEN
6570 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6571 END IF;
6572 NULL;
6573
6574 WHEN l_qry_fail THEN
6575 x_return_status := fnd_api.g_ret_sts_unexp_error;
6576 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6577 IF(l_debug = 1) THEN
6578 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6579 END IF;
6580 NULL;
6581
6582 WHEN OTHERS THEN
6583 x_return_status := fnd_api.g_ret_sts_unexp_error;
6584 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
6585 l_err_msg := substr(SQLERRM,1,1000);
6586 IF(l_debug = 1) THEN
6587 inv_trx_util_pub.trace(l_api_name||': '||l_err_msg);
6588 END IF;
6589 NULL;
6590
6591 END query_task;
6592 -------------------------------------------------------------------------------------------------------------------
6593 --SPLIT TASK
6594 /*This Public API will take care of splitting the task(only outboung)provided by the user.
6595 The criterion to split is only based on the quantity.
6596
6597 PROCEDURE split task (p_source_transaction_number IN NUMBER DEFAULT NULL,
6598 p_split_quantities IN WMS_TASKS_PUB.TASK_QUANTITY_TABLE,
6599 p_commit IN VARCHAR2 DEFAULT G_FALSE,
6600 x_resultant_tasks OUT NOCOPY WMS_TASKS_PUB.TASK_TABLE,
6601 x_resultant_task_details OUT NOCOPY WMS_TASKS_PUB.TASK_DETAILS_TABLE,
6602 x_return_status OUT NOCOPY VARCHAR2,
6603 x_msg_count OUT NOCOPY NUMBER,
6604 x_msg_data OUT NOCOPY VARCHAR2 );
6605
6606
6607 Parameter Description
6608 p_transaction_number This corrsponds to the task_id that user is trying to split.
6609 P_split_quantities This correspinds to the The PL/SQL table of quantities to be splitted. This table will contain one or more entries with quantities to be splitted from the task.
6610 P_Commit This parameter decides whether to commit the changes or not.
6611 X_resultant_tasks PL/SQL table contains information about lot/serial allocation of the resultant tasks.
6612 X_Resultant_task_details PL/SQL table of type wms_query_tasks_pub.task_tab_type contains the details of the resultant tasks after the split.
6613 X_return_status This parameter gives the return status of split_task API. 'S' = Success, 'U' = Unexpected Error, 'E' = Error.
6614 X_msg_count This gives the count of messages logged during the split task process.
6615 X_msg_data This gives the descrption of the messages that got logged during the split task process.
6616 */
6617 -------------------------------------------------------------------------------------------------------------------
6618 PROCEDURE split_task( p_source_transaction_number IN NUMBER DEFAULT NULL ,
6619 p_split_quantities IN task_qty_tbl_type ,
6620 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE ,
6621 x_resultant_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type ,
6622 x_resultant_task_details OUT NOCOPY task_detail_tbl_type ,
6623 x_return_status OUT NOCOPY VARCHAR2 ,
6624 x_msg_count OUT NOCOPY NUMBER ,
6625 x_msg_data OUT NOCOPY VARCHAR2 ) IS
6626
6627 CURSOR mtlt_changed (p_ttemp_id IN NUMBER)
6628 IS
6629 SELECT *
6630 FROM mtl_transaction_lots_temp
6631 WHERE transaction_temp_id = p_ttemp_id
6632 ORDER BY lot_number;
6633
6634 --Bug 6766048
6635 CURSOR C_MMTT_ORG_ITM (p_txn_temp_id NUMBER)
6636 IS
6637 select inventory_item_id, organization_id
6638 from mtl_material_transactions_temp
6639 where transaction_temp_id = p_txn_temp_id;
6640
6641 CURSOR C_LOT_DIVISIBLE (p_item_id NUMBER,p_organization_id NUMBER )
6642 IS
6643 select lot_divisible_flag
6644 from mtl_system_items
6645 where inventory_item_id = p_item_id
6646 and organization_id = p_organization_id;
6647
6648 l_mtlt_row MTL_TRANSACTION_LOTS_TEMP%ROWTYPE;
6649 -- l_split_uom_quantities qty_changed_tbl_type;
6650 l_procedure_name VARCHAR2(30) := 'SPLIT_TASK';
6651 l_task_tbl_qty_count NUMBER := p_split_quantities.COUNT;
6652 g_debug NUMBER := nvl(fnd_profile.VALUE('INV_DEBUG_TRACE'),0);
6653 l_decimal_precision CONSTANT NUMBER := 5;
6654 l_task_tbl_primary_qty NUMBER;
6655 l_task_tbl_transaction_qty NUMBER;
6656 l_sum_tbl_transaction_qty NUMBER := 0;
6657 l_sum_tbl_primary_qty NUMBER := 0;
6658 l_new_mol_id NUMBER;
6659 l_orig_mol_id NUMBER;
6660 l_new_transaction_temp_id NUMBER;
6661 l_new_transaction_header_id NUMBER;
6662 l_new_task_id NUMBER;
6666 l_serial_control_code NUMBER;
6663 l_remaining_primary_qty NUMBER := 0;
6664 l_remaining_transaction_qty NUMBER := 0;
6665 l_mol_num NUMBER;
6667 l_lot_control_code NUMBER;
6668 l_index NUMBER;
6669 l_new_tasks_output WMS_TASK_MGMT_PUB.task_tab_type;
6670 l_new_tasks_tbl WMS_TASK_MGMT_PUB.task_tab_type;
6671 x_task_table WMS_TASK_MGMT_PUB.task_tab_type;
6672 l_return_status VARCHAR2(10);
6673 l_msg_count NUMBER;
6674 l_msg_data VARCHAR(200);
6675 l_validation_status VARCHAR2(10);
6676 l_error_msg VARCHAR2(1000);
6677 l_task_return_status VARCHAR2(10);
6678 l_mmtt_return_status VARCHAR2(1);
6679 l_wdt_return_status VARCHAR2(1);
6680 l_lot_ser_return_status VARCHAR2(1);
6681 l_serial_return_status VARCHAR2(1);
6682 l_mtlt_transaction_qty NUMBER;
6683 l_msnt_transaction_qty NUMBER;
6684 l_val_task_ret_status VARCHAR2(1);
6685 l_mmtt_inventory_item_id NUMBER;
6686 l_mmtt_task_status NUMBER;
6687 l_mmtt_organization_id NUMBER;
6688 l_split_uom_quantities QTY_CHANGED_TBL_TYPE;
6689 l_val_qty_ret_status VARCHAR2(1);
6690 l_invalid_task EXCEPTION;
6691 l_invalid_quantities EXCEPTION;
6692 l_unexpected_error EXCEPTION;
6693 l_query_task_exception EXCEPTION;
6694 l_invalid_lot EXCEPTION;
6695 --Bug 6766048
6696 l_lot_divisible VARCHAR2(1);
6697 l_mmtt_itm_id NUMBER;
6698 l_mmtt_org_id NUMBER;
6699
6700 BEGIN
6701 g_debug := 1;
6702 IF g_debug = 1 THEN
6703 print_msg(l_procedure_name, 'In Split Task ');
6704 END IF;
6705 x_return_status := 'S';
6706 new_task_table.delete;
6707 validate_task( p_transaction_temp_id => p_source_transaction_number ,
6708 x_return_status => x_return_status ,
6709 x_error_msg => l_error_msg ,
6710 x_msg_data => x_msg_data ,
6711 x_msg_count => x_msg_count );
6712 IF g_debug = 1 THEN
6713 print_msg(l_procedure_name, ' Validate task return status : '|| x_return_status);
6714 END IF;
6715 IF NVL(x_return_status,'E') <> 'S' THEN
6716 RAISE l_invalid_task;
6717 END IF;
6718 validate_quantities( p_transaction_temp_id => p_source_transaction_number ,
6719 p_split_quantities => p_split_quantities ,
6720 x_lot_control_code => l_lot_control_code ,
6721 x_serial_control_code => l_serial_control_code ,
6722 x_split_uom_quantities => l_split_uom_quantities ,
6723 x_return_status => x_return_status ,
6724 x_msg_data => x_msg_data ,
6725 x_msg_count => x_msg_count );
6726
6727 IF NVL(x_return_status,'E') <> 'S' THEN
6728 RAISE l_invalid_quantities;
6729 END IF;
6730 --Bug 6766048:Check if the lot item is divisble or not.If not, log error and exit.
6731 IF (l_lot_control_code = 2) THEN
6732 OPEN C_MMTT_ORG_ITM(p_source_transaction_number);
6733 FETCH C_MMTT_ORG_ITM into l_mmtt_itm_id,l_mmtt_org_id;
6734 CLOSE C_MMTT_ORG_ITM;
6735
6736 OPEN C_LOT_DIVISIBLE(l_mmtt_itm_id,l_mmtt_org_id);
6737 FETCH C_LOT_DIVISIBLE into l_lot_divisible;
6738 CLOSE C_LOT_DIVISIBLE;
6739
6740 IF (l_lot_divisible = 'N') THEN
6741 RAISE l_invalid_lot;
6742 END IF;
6743 END IF;
6744
6745 IF g_debug = 1 THEN
6746 FOR i in l_split_uom_quantities.FIRST .. l_split_uom_quantities.LAST
6747 LOOP
6748 print_msg(l_procedure_name, ' l_split_uom_quantities('||i|| ').primary_quantity: '||l_split_uom_quantities(i).primary_quantity);
6749 print_msg(l_procedure_name, ' l_split_uom_quantities('||i|| ').transaction_quantity: '||l_split_uom_quantities(i).transaction_quantity);
6750 END LOOP;
6751 END IF;
6752 SAVEPOINT wms_split_task;
6753 IF g_debug = 1 THEN
6754 print_msg(l_procedure_name, ' SAVEPOINT wms_split_task established');
6755 END IF;
6756 FOR i IN l_split_uom_quantities.FIRST .. l_split_uom_quantities.LAST
6757 LOOP
6758 SELECT mtl_material_transactions_s.NEXTVAL
6759 INTO l_new_transaction_header_id
6760 FROM dual;
6761 SELECT mtl_material_transactions_s.NEXTVAL
6762 INTO l_new_transaction_temp_id
6763 FROM dual;
6764 SELECT wms_dispatched_tasks_s.NEXTVAL INTO l_new_task_id FROM dual;
6765 IF g_debug = 1 THEN
6766 print_msg(l_procedure_name, ' Calling split_mmtt for Txn. temp id : '||p_source_transaction_number);
6767 END IF;
6768 split_mmtt( p_orig_transaction_temp_id => p_source_transaction_number ,
6769 p_new_transaction_temp_id => l_new_transaction_temp_id ,
6770 p_new_transaction_header_id => l_new_transaction_header_id ,
6771 p_new_mol_id => l_orig_mol_id ,
6772 p_transaction_qty_to_split => l_split_uom_quantities(i).transaction_quantity ,
6773 p_primary_qty_to_split => l_split_uom_quantities(i).primary_quantity ,
6774 x_return_status => x_return_status ,
6775 x_msg_data => x_msg_data ,
6776 x_msg_count => x_msg_count );
6777
6778 IF g_debug = 1 THEN
6779 print_msg(l_procedure_name, ' x_return_status : ' || x_return_status);
6780 END IF;
6781 IF NVL(x_return_status, 'E') <> 'S' THEN
6782 IF g_debug = 1 THEN
6786 END IF;
6783 print_msg(l_procedure_name, ' Unable to split MMTT, unexpected error has occurred');
6784 END IF;
6785 RAISE l_unexpected_error;
6787 BEGIN
6788 SELECT status
6789 INTO l_mmtt_task_status
6790 FROM wms_dispatched_tasks
6791 WHERE transaction_temp_id = p_source_transaction_number;
6792 EXCEPTION
6793 WHEN NO_DATA_FOUND THEN
6794 l_mmtt_task_status := -9999;
6795 NULL;
6796 END;
6797 IF g_debug = 1 THEN
6798 print_msg(l_procedure_name, 'l_mmtt_task_status : '|| l_mmtt_task_status);
6799 END IF;
6800 IF l_mmtt_task_status = 2 THEN
6801 split_wdt( p_new_task_id => l_new_task_id ,
6802 p_new_transaction_temp_id => l_new_transaction_temp_id ,
6803 p_new_mol_id => l_orig_mol_id ,
6804 p_orig_transaction_temp_id => p_source_transaction_number ,
6805 x_return_status => x_return_status ,
6806 x_msg_data => x_msg_data ,
6807 x_msg_count => x_msg_count );
6808
6809 IF g_debug = 1 THEN
6810 print_msg(l_procedure_name, ' x_return_status : '||x_return_status);
6811 END IF;
6812 IF NVL(x_return_status, 'E') <> 'S' THEN
6813 IF g_debug = 1 THEN
6814 print_msg(l_procedure_name, ' Unable to split WDT, unexpected error has occurred');
6815 END IF;
6816 RAISE l_unexpected_error;
6817 END IF;
6818 END IF;
6819 IF (l_lot_control_code = 2 AND l_serial_control_code IN (2,5)) OR (l_lot_control_code = 2 AND l_serial_control_code NOT IN (2,5)) THEN
6820 split_lot_serial( p_source_transaction_number ,
6821 l_new_transaction_temp_id ,
6822 l_split_uom_quantities(i).transaction_quantity ,
6823 l_split_uom_quantities(i).primary_quantity ,
6824 l_mmtt_inventory_item_id ,
6825 l_mmtt_organization_id ,
6826 x_return_status ,
6827 x_msg_data ,
6828 x_msg_count );
6829
6830 IF g_debug = 1 THEN
6831 print_msg(l_procedure_name, ' x_return_status : ' || x_return_status);
6832 END IF;
6833 IF NVL(x_return_status, 'E') <> 'S' THEN
6834 IF g_debug = 1 THEN
6835 print_msg(l_procedure_name, ' Was not able to split lot serial');
6836 END IF;
6837 RAISE l_unexpected_error;
6838 END IF;
6839 ELSIF l_lot_control_code = 1 AND l_serial_control_code IN (2,5) THEN
6840 split_serial( p_orig_transaction_temp_id => p_source_transaction_number ,
6841 p_new_transaction_temp_id => l_new_transaction_temp_id ,
6842 p_transaction_qty_to_split => l_split_uom_quantities(i).transaction_quantity ,
6843 p_primary_qty_to_split => l_split_uom_quantities(i).primary_quantity ,
6844 p_inventory_item_id => l_mmtt_inventory_item_id ,
6845 p_organization_id => l_mmtt_organization_id ,
6846 x_return_status => x_return_status ,
6847 x_msg_data => x_msg_data ,
6848 x_msg_count => x_msg_count );
6849 IF g_debug = 1 THEN
6850 print_msg(l_procedure_name, ' x_return_status : '||x_return_status);
6851 END IF;
6852 IF NVL(x_return_status, 'E') <> 'S' THEN
6853 IF g_debug = 1 THEN
6854 print_msg(l_procedure_name, ' Was not able to split serials');
6855 END IF;
6856 RAISE l_unexpected_error;
6857 END IF;
6858 END IF;
6859 -- Update the original row
6860 BEGIN
6861 UPDATE mtl_material_transactions_temp
6862 SET primary_quantity = primary_quantity - l_split_uom_quantities(i).primary_quantity ,
6863 transaction_quantity = transaction_quantity - l_split_uom_quantities(i).transaction_quantity ,
6864 last_updated_by = FND_GLOBAL.USER_ID
6865 WHERE transaction_temp_id = p_source_transaction_number;
6866 EXCEPTION
6867 WHEN OTHERS THEN
6868 IF g_debug = 1 THEN
6869 print_msg(l_procedure_name, ' Error Code : '|| SQLCODE || ' Error Message :'||SUBSTR(SQLERRM,1,100));
6870 END IF;
6871 RAISE l_unexpected_error;
6872 END;
6873 IF g_debug = 1 THEN
6874 print_msg(l_procedure_name, ' Updated original txn. temp id :'||p_source_transaction_number);
6875 END IF;
6876 l_index := new_task_table.count + 1;
6877 new_task_table(l_index).transaction_temp_id := l_new_transaction_temp_id;
6878 END LOOP;
6879 l_index := new_task_table.count + 1;
6880 new_task_table(l_index).transaction_temp_id := p_source_transaction_number;
6881 IF g_debug = 1 THEN
6882 print_msg(l_procedure_name, ' Split done sucessfully for txn. temp id :'||p_source_transaction_number);
6883 END IF;
6884 IF g_debug = 1 THEN
6888 print_msg(l_procedure_name, '***********New Task Table***********');
6885 print_msg(l_procedure_name, ' lot control code :'||l_lot_control_code || ' serial control code : '|| l_serial_control_code);
6886 END IF;
6887 IF g_debug = 1 THEN
6889 print_msg(l_procedure_name, '*** Transaction temp id ***');
6890 FOR i IN new_task_table.FIRST .. new_task_table.LAST
6891 LOOP
6892 print_msg(l_procedure_name, ' '|| new_task_table(i).transaction_temp_id);
6893 END LOOP;
6894 END IF;
6895 IF g_debug = 1 THEN
6896 print_msg(l_procedure_name, 'Inserting Lot/Serial details of the new tasks in X_RESULTANT_TASK_DETAILS');
6897 END IF;
6898 IF l_lot_control_code = 2 THEN
6899 FOR i IN new_task_table.FIRST .. new_task_table.LAST
6900 LOOP
6901 OPEN mtlt_changed(new_task_table(i).transaction_temp_id);
6902 LOOP
6903 FETCH mtlt_changed INTO l_mtlt_row;
6904 EXIT
6905 WHEN mtlt_changed%NOTFOUND;
6906 l_index := x_resultant_task_details.count + 1;
6907 x_resultant_task_details(l_index).parent_task_id := l_mtlt_row.transaction_temp_id;
6908 x_resultant_task_details(l_index).lot_number := l_mtlt_row.lot_number;
6909 x_resultant_task_details(l_index).lot_expiration_date := l_mtlt_row.lot_expiration_date;
6910 x_resultant_task_details(l_index).lot_primary_quantity := l_mtlt_row.primary_quantity;
6911 x_resultant_task_details(l_index).lot_transaction_quantity := l_mtlt_row.transaction_quantity;
6912 IF l_mtlt_row.serial_transaction_temp_id IS NOT NULL THEN
6913 x_resultant_task_details(l_index).number_of_serials := l_mtlt_row.primary_quantity;
6914 SELECT MIN(FM_SERIAL_NUMBER) ,
6915 MAX(FM_SERIAL_NUMBER) ,
6916 MAX(status_id)
6917 INTO x_resultant_task_details(l_index).from_serial_number ,
6918 x_resultant_task_details(l_index).to_serial_number ,
6919 x_resultant_task_details(l_index).serial_status_id
6920 FROM mtl_serial_numbers_temp
6921 WHERE transaction_temp_id = l_mtlt_row.serial_transaction_temp_id;
6922 END IF;
6923 END LOOP;
6924 CLOSE mtlt_changed;
6925 END LOOP;
6926 ELSIF l_serial_control_code IN (2,5) THEN
6927 FOR i IN new_task_table.FIRST .. new_task_table.LAST
6928 LOOP
6929 l_index := x_resultant_task_details.count + 1;
6930 x_resultant_task_details(l_index).parent_task_id := new_task_table(i).transaction_temp_id;
6931 SELECT MIN(FM_SERIAL_NUMBER) ,
6932 MAX(FM_SERIAL_NUMBER) ,
6933 MAX(status_id) ,
6934 COUNT(*)
6935 INTO x_resultant_task_details(l_index).from_serial_number ,
6936 x_resultant_task_details(l_index).to_serial_number ,
6937 x_resultant_task_details(l_index).serial_status_id ,
6938 x_resultant_task_details(l_index).number_of_serials
6939 FROM mtl_serial_numbers_temp
6940 WHERE transaction_temp_id = new_task_table(i).transaction_temp_id;
6941 END LOOP;
6942 END IF;
6943 IF g_debug = 1 THEN
6944 IF x_resultant_task_details.COUNT > 0 THEN
6945 print_msg(l_procedure_name, 'Task Id Lot quantity fm_serial to_serial num_of_serials');
6946 FOR i IN x_resultant_task_details.FIRST .. x_resultant_task_details.LAST
6947 LOOP
6948 print_msg(l_procedure_name,
6949 x_resultant_task_details(i).parent_task_id ||
6950 ' '||
6951 x_resultant_task_details(i).lot_number ||
6952 ' '||
6953 x_resultant_task_details(i).lot_primary_quantity||
6954 ' '||
6955 x_resultant_task_details(i).from_serial_number||
6956 ' '||
6957 x_resultant_task_details(i).to_serial_number||
6958 ' '||
6959 x_resultant_task_details(i).number_of_serials);
6960 END LOOP;
6961 ELSE
6962 print_msg(l_procedure_name,'Table x_resultant_task_details is empty, item is not serial or lot controlled');
6963 END IF;
6964 END IF;
6965 FOR i IN new_task_table.FIRST .. new_task_table.LAST
6966 LOOP
6967 IF g_debug = 1 THEN
6968 print_msg(l_procedure_name, 'Before calling WMS_TASK_MGMT_PUB.query_task');
6969 WMS_TASK_MGMT_PUB.query_task ( new_task_table(i).transaction_temp_id ,
6970 NULL ,
6971 l_new_tasks_tbl ,
6972 l_return_status ,
6973 l_msg_count ,
6974 l_msg_data );
6975
6976 IF NVL(l_return_status,'N') = 'S' OR l_new_tasks_tbl.COUNT > 0 THEN
6977 IF g_debug = 1 THEN
6981 x_resultant_tasks(i) := l_new_tasks_tbl(1);
6978 print_msg(l_procedure_name, 'WMS_TASK_MGMT_PUB.query_task returned success for task : ' || new_task_table(i).transaction_temp_id);
6979 END IF;
6980 IF l_new_tasks_tbl.COUNT > 0 THEN
6982 END IF;
6983 ELSE
6984 IF g_debug = 1 THEN
6985 print_msg(l_procedure_name, 'WMS_TASK_MGMT_PUB.query_task returned error');
6986 END IF;
6987 -- x_return_status := 'E';
6988 RAISE l_query_task_exception;
6989 END IF;
6990 END IF;
6991 END LOOP;
6992 IF g_debug = 1 THEN
6993 IF x_resultant_tasks.COUNT > 0 THEN
6994 print_msg(l_procedure_name, 'Task Id item_id sub locator Qty');
6995 FOR i IN x_resultant_tasks.FIRST .. x_resultant_tasks.LAST
6996 LOOP
6997 print_msg(l_procedure_name,
6998 x_resultant_tasks(i).task_id ||
6999 ' '||
7000 x_resultant_tasks(i).inventory_item_id||
7001 ' '||
7002 x_resultant_tasks(i).subinventory||
7003 ' '||
7004 x_resultant_tasks(i).locator||
7005 ' '||
7006 x_resultant_tasks(i).transaction_quantity);
7007 END LOOP;
7008 ELSE
7009 print_msg(l_procedure_name, 'Table x_resultant_tasks is empty');
7010 END IF;
7011 END IF;
7012 IF p_commit = FND_API.G_TRUE THEN
7013 IF g_debug = 1 THEN
7014 print_msg(l_procedure_name, ' p_commit is TRUE, so COMMITING the transactions.');
7015 END IF;
7016 COMMIT;
7017 ELSE
7018 IF g_debug = 1 THEN
7019 print_msg(l_procedure_name, ' p_commit is FALSE, so not COMMITING the transactions.');
7020 END IF;
7021 END IF;
7022 x_return_status := 'S';
7023 EXCEPTION
7024 WHEN L_INVALID_TASK THEN
7025 IF g_debug = 1 THEN
7026 print_msg(l_procedure_name,'EXCEPTION BLOCK : Validate task returned error');
7027 END IF;
7028 x_return_status := 'S';
7029 WMS_TASK_MGMT_PUB.query_task ( p_source_transaction_number ,
7030 NULL ,
7031 l_new_tasks_tbl ,
7032 l_return_status ,
7033 l_msg_count ,
7034 l_msg_data );
7035 fnd_message.set_name('WMS', 'WMS_INVALID_TASK');
7036 fnd_msg_pub.ADD;
7037 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7038
7039 IF l_new_tasks_tbl.COUNT > 0 THEN
7040 x_resultant_tasks(1) := l_new_tasks_tbl(1);
7041 x_resultant_tasks(1).RESULT := 'E';
7042 -- x_resultant_tasks(1).ERROR := 'Invalid Task';
7043 -- anjana
7044 x_resultant_tasks(1).ERROR := x_msg_data;
7045
7046 END IF;
7047 --Bug 6766048
7048 WHEN L_INVALID_LOT THEN
7049 IF g_debug = 1 THEN
7050 print_msg(l_procedure_name,'EXCEPTION BLOCK : Lot split error');
7051 END IF;
7052 x_return_status := 'S';
7053 WMS_TASK_MGMT_PUB.query_task ( p_source_transaction_number ,
7054 NULL ,
7055 l_new_tasks_tbl ,
7056 l_return_status ,
7057 l_msg_count ,
7058 l_msg_data );
7059 fnd_message.set_name('INV', 'INV_LOT_INDIVISIBLE');
7060 fnd_msg_pub.ADD;
7061 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7062
7063 IF l_new_tasks_tbl.COUNT > 0 THEN
7064 x_resultant_tasks(1) := l_new_tasks_tbl(1);
7065 x_resultant_tasks(1).RESULT := 'E';
7066 x_resultant_tasks(1).ERROR := x_msg_data;
7067 END IF;
7068
7069 WHEN L_INVALID_QUANTITIES THEN
7070 IF g_debug = 1 THEN
7071 print_msg(l_procedure_name,'EXCEPTION BLOCK : Validate quantities returned error');
7072 END IF;
7073 x_return_status := 'S';
7074 WMS_TASK_MGMT_PUB.query_task ( p_source_transaction_number ,
7075 NULL ,
7076 l_new_tasks_tbl ,
7077 l_return_status ,
7078 l_msg_count ,
7079 l_msg_data );
7080 fnd_message.set_name('WMS', 'WMS_INVALID_SPLIT_QUANTITY');
7081 fnd_msg_pub.ADD;
7082 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7083
7084 IF l_new_tasks_tbl.COUNT > 0 THEN
7085 x_resultant_tasks(1) := l_new_tasks_tbl(1);
7086 x_resultant_tasks(1).RESULT := 'E';
7087 -- x_resultant_tasks(1).ERROR := 'Invalid Quantities';
7088 -- anjana
7089 x_resultant_tasks(1).ERROR := x_msg_data;
7090 END IF;
7091
7092 WHEN L_QUERY_TASK_EXCEPTION THEN
7093 IF g_debug = 1 THEN
7094 print_msg(l_procedure_name,'EXCEPTION BLOCK : Query task returned error, ROLLING BACK THE TRANSACTIONS');
7095 END IF;
7096 x_return_status := 'S';
7097 ROLLBACK TO wms_split_task;
7098 WMS_TASK_MGMT_PUB.query_task ( p_source_transaction_number ,
7099 NULL ,
7100 l_new_tasks_tbl ,
7101 l_return_status ,
7102 l_msg_count ,
7103 l_msg_data );
7104 fnd_message.set_name('WMS', 'WMS_QUERY_ELIG_MATRL');
7108 IF l_new_tasks_tbl.COUNT > 0 THEN
7105 fnd_msg_pub.ADD;
7106 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7107
7109 x_resultant_tasks(1) := l_new_tasks_tbl(1);
7110 x_resultant_tasks(1).RESULT := 'E';
7111 -- x_resultant_tasks(1).ERROR := 'Query Task returned error or no rows';
7112 -- anjana
7113 x_resultant_tasks(1).ERROR := x_msg_data;
7114 END IF;
7115
7116 WHEN L_UNEXPECTED_ERROR THEN
7117 IF g_debug = 1 THEN
7118 print_msg(l_procedure_name,'EXCEPTION BLOCK : Unexpected error has occured, ROLLING BACK THE TRANSACTIONS');
7119 END IF;
7120 x_return_status := 'E';
7121 ROLLBACK TO wms_split_task;
7122 fnd_message.set_name('WMS', 'WMS_UNEXPECTED_ERROR');
7123 fnd_msg_pub.ADD;
7124 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7125 WHEN OTHERS THEN
7126 IF g_debug = 1 THEN
7127 print_msg(l_procedure_name,'EXCEPTION BLOCK : Unexpected error has occured, ROLLING BACK THE TRANSACTIONS');
7128 END IF;
7129 x_return_status := 'E';
7130 ROLLBACK TO wms_split_task;
7131 fnd_message.set_name('WMS', 'WMS_UNEXPECTED_ERROR');
7132 fnd_msg_pub.ADD;
7133 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7134 x_return_status := 'E';
7135 IF g_debug = 1 THEN
7136 print_msg(l_procedure_name, 'EXCEPTION BLOCK : Error Code : '|| SQLCODE || 'EXCEPTION BLOCK : Error Message :'||SQLERRM);
7137 END IF;
7138 END split_task;
7139
7140 -------------------------------------------------------------------------------------------------------------------
7141 --MODIFY TASK
7142 /*This Public API takes care of modifying the following attributes of a task or set of tasks:
7143 1.Task Status
7144 2.Task Priority
7145 3.Operation Plan
7146 4.Cartonization LPN
7147 5.Task Type
7148
7149 PROCEDURE modify_task (p_transaction_number IN NUMBER DEFAULT NULL
7150 , p_task_table IN WMS_TASKS_PUB.TASK_TABLE
7151 , p_new_task_status IN NUMBER DEFAULT NULL
7152 , p_new_task_priority IN NUMBER DEFAULT NULL
7153 , p_new_task_type IN VARCHAR2 DEFAULT NULL
7154 , p_new_carton_lpn_id IN NUMBER DEFAULT NULL
7155 , p_new_operation_plan_id IN NUMBER DEFAILUT NULL
7156 , p_person_id IN NUMBER DEFAULT NULL
7157 , p_commit IN VARCHAR2 DEFAULT G_FALSE
7158 , x_updated_tasks OUT NOCOPY WMS_TASKS_PUB.TASK_TABLE
7159 , x_return_status OUT NOCOPY VARCHAR2
7160 , x_msg_count OUT NOCOPY NUMBER
7161 , x_msg_data OUT NOCOPY VARCHAR2 );
7162
7163 Parameter Description
7164
7165 p_transaction_number This corresponds to the task_id that user is trying to update
7166 P_task_table This corresponds to the set of tasks that user is trying to update
7167 P_new_task_status This corresponds to the new status to which user wants to update the task/set of tasks
7168 P_new_task_priority This corresponds to new task priority which user wants to assign to the tasks/set of tasks.
7169 P_new_task_tyoe This corresponds to the new task type which user wants to update on the task/set of tasks.
7170 P_new_carton_lpn_id This is the carton_lpn_id which user wants to update on task/set of tasks.
7171 P_new_operation_plan_id This is the new operation plan id which user wants to update on task/set of tasks.
7172 P_person_id This the user to which task will be queued, if the task status is getting changed to 'Queued' state.
7173 P_Commit This parameter decides whether to commit the changes or not.
7174 X_updated_tasks This is a table of records, which contain the updated tasks. If the tasks could not be updated, the Result column in the table is updated with 'E' and the Error column is updated with the error message
7175 X_return_status This parameter gives the return status of Modify_task API. 'S' = Success, 'U' = Unexpected Error, 'E' = Error.
7176 X_msg_count This gives the count of messages logged during the task updation process.
7177 X_msg_data This gives the description of the messages that got logged during the task updation process.
7178
7179 */
7180 -------------------------------------------------------------------------------------------------------------------
7181 PROCEDURE modify_task ( p_transaction_number IN NUMBER DEFAULT NULL ,
7182 p_task_table IN WMS_TASK_MGMT_PUB.task_tab_type ,
7183 p_new_task_status IN NUMBER DEFAULT NULL ,
7184 p_new_task_priority IN NUMBER DEFAULT NULL ,
7185 p_new_task_type IN VARCHAR2 DEFAULT NULL ,
7186 p_new_carton_lpn_id IN NUMBER DEFAULT NULL ,
7187 p_new_operation_plan_id IN NUMBER DEFAULT NULL ,
7188 p_person_id IN NUMBER DEFAULT NULL ,
7189 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE ,
7190 x_updated_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type ,
7191 x_return_status OUT NOCOPY VARCHAR2 ,
7192 x_msg_count OUT NOCOPY NUMBER ,
7193 x_msg_data OUT NOCOPY VARCHAR2 ) IS
7194
7195 temp_task_tab WMS_TASK_MGMT_PUB.task_tab_type;
7196 CURSOR op_plan_cur(c_op_plan_id NUMBER)
7197 IS
7198 SELECT system_task_type ,
7199 organization_id ,
7200 enabled_flag ,
7201 activity_type_id ,
7202 common_to_all_org,
7203 plan_type_id
7204 FROM wms_op_plans_b
7205 WHERE operation_plan_id=c_op_plan_id;
7206 --Cursor to lock the mmtt record before updation.
7207 Cursor c_lock_mmtt (p_transaction_number NUMBER)
7208 IS
7209 SELECT '1'
7210 FROM mtl_material_transactions_temp
7214 IS
7211 WHERE transaction_temp_id = p_transaction_number FOR UPDATE NOWAIT;
7212 --Cursor to lock the mcce record before updation.
7213 Cursor c_lock_mcce (p_transaction_number NUMBER)
7215 SELECT '1'
7216 FROM mtl_cycle_count_entries
7217 WHERE cycle_count_entry_id = p_transaction_number FOR UPDATE NOWAIT;
7218 p_return_sts VARCHAR2(30);
7219 P_msg_count NUMBER;
7220 l_msg_count NUMBER;
7221 P_msg_data VARCHAR2(30);
7222 l_valid_task_counter NUMBER;
7223 p_temp_task_rec WMS_TASK_MGMT_PUB.task_output_rectype;
7224 l_op_plan_rec WMS_TASK_MGMT_PUB.op_plan_rec;
7225 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
7226 l_api_name VARCHAR2(1000) := 'MODIFY_TASK';
7227 l_msg VARCHAR2(2000);
7228 l_err_msg VARCHAR2(2000);
7229 l_error_msg VARCHAR2(2000);
7230 l_lock VARCHAR2(2);
7231 l_updated_tasks WMS_TASK_MGMT_PUB.task_tab_type;
7232
7233
7234 TYPE TransactionNumber IS TABLE OF NUMBER
7235 INDEX BY BINARY_INTEGER;
7236 TYPE OrganizationId IS TABLE OF NUMBER
7237 INDEX BY BINARY_INTEGER;
7238 TYPE UserTaskTypeId IS TABLE OF NUMBER
7239 INDEX BY BINARY_INTEGER;
7240 TYPE PersonId IS TABLE OF NUMBER
7241 INDEX BY BINARY_INTEGER;
7242 TYPE PersonResourceId IS TABLE OF NUMBER
7243 INDEX BY BINARY_INTEGER;
7244 TYPE MachineResourceId IS TABLE OF NUMBER
7245 INDEX BY BINARY_INTEGER;
7246 TYPE StatusId IS TABLE OF NUMBER
7247 INDEX BY BINARY_INTEGER;
7248 TYPE Priority IS TABLE OF NUMBER
7249 INDEX BY BINARY_INTEGER;
7250 TYPE TaskTypeId IS TABLE OF NUMBER
7251 INDEX BY BINARY_INTEGER;
7252 TYPE MoveOrderLineId IS TABLE OF NUMBER
7253 INDEX BY BINARY_INTEGER;
7254 TYPE ToLpnId IS TABLE OF NUMBER
7255 INDEX BY BINARY_INTEGER;
7256 TYPE OperationPlanId IS TABLE OF NUMBER
7257 INDEX BY BINARY_INTEGER;
7258 TYPE CartonizationId IS TABLE OF NUMBER
7259 INDEX BY BINARY_INTEGER;
7260 TYPE DispatchedTime is TABLE OF DATE;
7261
7262 l_transaction_num_table TransactionNumber;
7263 l_organization_id_table OrganizationId;
7264 l_usertask_type_id_table UserTaskTypeId;
7265 l_person_id_tabke PersonId;
7266 l_person_resource_id_tabe PersonResourceId;
7267 l_machine_resource_id_table MachineResourceId;
7268 l_status_id_table StatusId;
7269 l_priority_table Priority;
7270 l_task_type_id_table TaskTypeId;
7271 l_move_order_line_id_table MoveOrderLineId;
7272 l_to_lpn_id_table ToLpnId;
7273 l_operation_plan_id_table OperationPlanId;
7274 l_dispatched_time_table DispatchedTime;
7275
7276 l_mmtt_cartonization_id_table CartonizationId;
7277 l_mmtt_transaction_num_table TransactionNumber;
7278 l_mmtt_usertask_type_id_table UserTaskTypeId;
7279 l_mmtt_status_id_table StatusId;
7280 l_mmtt_priority_table Priority;
7281 l_mmtt_operation_plan_id_table OperationPlanId;
7282
7283 l_mcce_transaction_num_table TransactionNumber;
7284 l_mcce_usertask_type_id_table UserTaskTypeId;
7285 l_mcce_priority_table Priority;
7286
7287 l_wdt_transaction_num_table TransactionNumber;
7288 l_wdt_usertask_type_id_table UserTaskTypeId;
7289 l_wdt_status_id_table StatusId;
7290 l_wdt_priority_table Priority;
7291 l_wdt_operation_plan_id_table OperationPlanId;
7292
7293 l_wdt_del_trns_num_table TransactionNumber;
7294 l_action VARCHAR2(20) := 'MODIFY'; -- 6850212
7295
7296
7297 BEGIN
7298 x_return_status := fnd_api.g_ret_sts_success;
7299 --anjana
7300 x_msg_count := 0;
7301 --1.Tasks status can be updated only to to Pending or queued or unreleased state.
7302 IF (p_new_task_status IS NOT NULL) THEN
7303 IF(p_new_task_status NOT IN (1,2,8)) THEN
7304 --6850212:Return status should not be set to error.
7305 --x_return_status := fnd_api.g_ret_sts_error;
7306 fnd_message.set_name('WMS', 'WMS_INVALID_TASK_STATUS');--new message
7307 fnd_msg_pub.ADD;
7308 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg );
7309 x_msg_data := l_msg;
7310 x_msg_count := l_msg_count;
7311 l_err_msg :='New task status not in Pending or Queued state or Unreleased state';
7312 IF(l_debug = 1) THEN
7313 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7314 END IF;
7315 log_error(p_transaction_number => p_transaction_number, p_task_table => p_task_table, p_error_msg => l_msg, x_updated_tasks => x_updated_tasks);
7316 RETURN;
7317 END IF;
7318 END IF;
7319 --2.If operation Plan is send, then check if it is enabled in the org or not.
7320 IF (p_new_operation_plan_id IS NOT NULL) THEN
7321 OPEN op_plan_cur(p_new_operation_plan_id);
7322 FETCH op_plan_cur
7323 INTO l_op_plan_rec.system_task_type ,
7324 l_op_plan_rec.organization_id ,
7325 l_op_plan_rec.eabled_flag ,
7326 l_op_plan_rec.activity_type_id ,
7327 l_op_plan_rec.common_to_all_org,
7328 l_op_plan_rec.plan_type_id;
7329 IF (l_op_plan_rec.eabled_flag <> 'Y') THEN--op_plan passed is not enabled
7330 --6850212:Return status should not be set to error.
7331 --x_return_status := fnd_api.g_ret_sts_error;
7332 fnd_message.set_name('WMS', 'WMS_OPERTN_PLAN_ID_INVALID');--new message
7333 fnd_msg_pub.ADD;
7337 l_err_msg :='Operation Plan is not enabled';
7334 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg );
7335 x_msg_data := l_msg;
7336 x_msg_count := l_msg_count;
7338 IF(l_debug = 1) THEN
7339 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7340 END IF;
7341 log_error(p_transaction_number => p_transaction_number,
7342 p_task_table => p_task_table,
7343 p_error_msg => l_msg,
7344 x_updated_tasks => x_updated_tasks);
7345 RETURN;
7346 END IF;
7347 CLOSE op_plan_cur;
7348 END IF;
7349 --3.Perform Validation,Query,Check cartonization on taks/tasks.
7350 -- If transaction_number and task_table are both passed, honour transaction_number.
7351 --Call Validate task API
7352 validate_tasks(p_transaction_number => p_transaction_number,
7353 p_task_table => p_task_table,
7354 p_action => l_action, --6850212
7355 x_wms_task => l_updated_tasks,
7356 x_return_status => p_return_sts);
7357
7358 IF (p_return_sts = fnd_api.g_ret_sts_success) THEN
7359 l_valid_task_counter := l_updated_tasks.count;
7360 FOR i IN 1..l_updated_tasks.count
7361 LOOP--Loop starts
7362 IF (nvl(l_updated_tasks(i).RESULT,'X')<> 'E') THEN
7363 temp_task_tab.delete;-- := NULL; --flush the temporary table
7364 WMS_TASK_MGMT_PUB.query_task( p_transaction_number => l_updated_tasks(i).transaction_number,
7365 p_query_name => NULL,
7366 x_task_tab => temp_task_tab,
7367 x_return_status => p_return_sts,
7368 x_msg_count => p_msg_count,
7369 x_msg_data => p_msg_data);
7370
7371 --if quey was not successfull then populate output table with passed values with error
7372 IF ((p_return_sts <> fnd_api.g_ret_sts_success) OR ( temp_task_tab.count = 0)) THEN
7373 fnd_message.set_name('WMS', 'WMS_QUERY_ELIG_MATRL');--new message
7374 -- fnd_msg_pub.ADD;
7375 -- fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg);
7376 --anjana
7377 l_msg := fnd_message.get;
7378 x_msg_data := x_msg_data || l_msg;
7379 x_msg_count := x_msg_count + 1;
7380
7381 l_err_msg :='Error in querying task from Query_task API for transaction_number :'||p_task_table(i).transaction_number ||'This task will be skipped';
7382 IF(l_debug = 1) THEN
7383 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7384 END IF;
7385 x_updated_tasks(i) := l_updated_tasks(i);
7386 x_updated_tasks(i).RESULT := 'E';
7387 x_updated_tasks(i).ERROR := l_msg;
7388 l_valid_task_counter := l_valid_task_counter - 1;
7389 ELSE --if query success
7390 x_updated_tasks(i) := temp_task_tab(1);--assigning the queried results to output table
7391 END IF;
7392 ELSE
7393 fnd_message.set_name('WMS', 'WMS_INVALID_TASK');
7394 -- fnd_msg_pub.ADD;
7395 -- fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg );
7396 --anjana
7397 l_msg := fnd_message.get;
7398 x_msg_data := x_msg_data || l_msg;
7399 x_msg_count := x_msg_count + 1;
7400
7401 x_updated_tasks(i) := l_updated_tasks(i);
7402 x_updated_tasks(i).RESULT := 'E';
7403 x_updated_tasks(i).ERROR := l_msg;
7404 l_valid_task_counter := l_valid_task_counter - 1;
7405 END IF;
7406 END LOOP;--Loop ends
7407 ELSE
7408 x_return_status := fnd_api.g_ret_sts_unexp_error;
7409 fnd_message.set_name('WMS', 'WMS_UNEXPECTED_ERROR');
7410 fnd_msg_pub.ADD;
7411 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg );
7412 x_msg_data := l_msg;
7413 x_msg_count := l_msg_count;
7414 -- l_err_msg :='Task Validation Failed';
7415 IF(l_debug = 1) THEN
7416 inv_trx_util_pub.trace(l_api_name|| ': '||l_msg);
7417 END IF;
7418 RETURN;
7419 END IF;
7420 IF (l_valid_task_counter <=0 ) THEN
7421 --all the tasks are invalid.Dont proceed
7422 --6850212:Return status should not be set to error.
7423 --x_return_status := fnd_api.g_ret_sts_error;
7424 RETURN;
7425 END IF;
7426 --Cartonization needs to be done only if all the tasks passed are valid and the task is an outboud task(SO/WIP)
7427 IF (p_new_carton_lpn_id IS NOT NULL) THEN
7428 IF (l_updated_tasks.count = l_valid_task_counter)THEN
7429 FOR i in 1..l_updated_tasks.count
7430 LOOP
7431 IF ((l_updated_tasks(1).task_type_id <> 1) OR (l_updated_tasks(i).task_type_id <> l_updated_tasks(1).task_type_id )) THEN
7432 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERROR');--new message
7433 fnd_msg_pub.ADD;
7434 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => l_msg_count, p_data => l_msg );
7435 l_err_msg :='Cartonization can be done only on Outbound tasks(Sales order/WIP)';
7436 x_msg_data := l_msg;
7437 x_msg_count := l_msg_count;
7438 log_error(p_transaction_number => p_transaction_number,
7439 p_task_table => l_updated_tasks,
7440 p_error_msg => l_msg,
7441 x_updated_tasks => x_updated_tasks);
7442 RETURN;
7443 END IF;
7444 END LOOP;
7445 check_cartonization(p_task_table => l_updated_tasks,
7446 p_new_carton_lpn_id => p_new_carton_lpn_id,
7447 x_error_msg => l_error_msg,
7448 x_return_status => p_return_sts);
7449
7450 IF (p_return_sts <> fnd_api.g_ret_sts_success) THEN
7451 x_return_status := fnd_api.g_ret_sts_error;
7455 x_updated_tasks(i).RESULT := 'E';
7452 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data );
7453 FOR i IN 1..l_updated_tasks.count
7454 LOOP
7456 x_updated_tasks(i).ERROR := l_error_msg;
7457 END LOOP;
7458 IF(l_debug = 1) THEN
7459 inv_trx_util_pub.trace(l_api_name|| ': '||l_error_msg);
7460 END IF;
7461 RETURN;
7462 END IF;
7463 ELSE
7464 x_return_status := fnd_api.g_ret_sts_error;
7465 fnd_message.set_name('WMS', 'WMS_CARTONIZATION_ERROR');--new message
7466 fnd_msg_pub.ADD;
7467 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data );
7468 l_err_msg := 'Some tasks have failed validation,cartonization cannot be done';
7469 IF(l_debug = 1) THEN
7470 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7471 END IF;
7472 RETURN;
7473 END IF;
7474 END IF;
7475 FOR i in 1..x_updated_tasks.count
7476 LOOP
7477 IF (nvl(x_updated_tasks(i).RESULT,'X')<> 'E') THEN
7478 --Lock the mmtt/mcee record
7479 BEGIN
7480 IF (x_updated_tasks(i).task_type_id <> 3) THEN
7481 OPEN c_lock_mmtt(x_updated_tasks(i).transaction_number);
7482 FETCH c_lock_mmtt INTO l_lock;
7483 CLOSE c_lock_mmtt;
7484 ELSE
7485 OPEN c_lock_mcce(x_updated_tasks(i).transaction_number);
7486 FETCH c_lock_mcce INTO l_lock;
7487 CLOSE c_lock_mcce;
7488 END IF;
7489 EXCEPTION
7490 WHEN OTHERS THEN
7491 l_err_msg := substr(SQLERRM,1,1000);
7492 x_updated_tasks(i).RESULT := 'E';
7493 x_updated_tasks(i).ERROR := l_err_msg;
7494 IF(l_debug = 1) THEN
7495 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7496 END IF;
7497 END;
7498 p_temp_task_rec := x_updated_tasks(i);
7499
7500 modify_single_task(p_task_rec => p_temp_task_rec,
7501 p_new_task_status => p_new_task_status,
7502 P_new_task_priority => P_new_task_priority,
7503 P_new_task_type => P_new_task_type,
7504 P_new_carton_lpn_id => P_new_carton_lpn_id,
7505 p_new_operation_plan_id => p_new_operation_plan_id,
7506 p_output_task_rec => l_updated_tasks(i),
7507 p_op_plan_rec => l_op_plan_rec);
7508
7509 --Copy values from l_updated_tasks to x_updated_tasks
7510 x_updated_tasks(i).RESULT := nvl(l_updated_tasks(i).RESULT,x_updated_tasks(i).RESULT);
7511 x_updated_tasks(i).ERROR := nvl(l_updated_tasks(i).ERROR,x_updated_tasks(i).ERROR);
7512 x_updated_tasks(i).status_id := nvl(l_updated_tasks(i).status_id,x_updated_tasks(i).status_id);
7513 x_updated_tasks(i).operation_plan_id := nvl(l_updated_tasks(i).operation_plan_id,x_updated_tasks(i).operation_plan_id);
7514 x_updated_tasks(i).cartonization_id := nvl(l_updated_tasks(i).cartonization_id,x_updated_tasks(i).cartonization_id);
7515 x_updated_tasks(i).priority := nvl(l_updated_tasks(i).priority,x_updated_tasks(i).priority);
7516 x_updated_tasks(i).user_task_type_id := nvl(l_updated_tasks(i).user_task_type_id,x_updated_tasks(i).user_task_type_id);
7517 --anjana
7518 IF (nvl(x_updated_tasks(i).RESULT,'X') = 'E') THEN
7519 x_msg_count:= x_msg_count + 1;
7520 x_msg_data := x_msg_data || x_updated_tasks(i).ERROR ;
7521 END IF;
7522 END IF;
7523 END LOOP;
7524
7525
7526 FOR i IN 1..x_updated_tasks.count
7527 LOOP
7528 IF (nvl(x_updated_tasks(i).RESULT,'X')<> 'E') THEN
7529 IF p_new_task_status = 2 THEN
7530 l_transaction_num_table(l_transaction_num_table.COUNT+1) := x_updated_tasks(i).transaction_number;
7531 l_organization_id_table(l_organization_id_table.COUNT+1) := x_updated_tasks(i).organization_id;
7532 l_usertask_type_id_table(l_usertask_type_id_table.COUNt+1) := x_updated_tasks(i).user_task_type_id;
7533 l_person_resource_id_tabe(l_person_resource_id_tabe.COUNt+1) := x_updated_tasks(i).person_resource_id;
7534 l_machine_resource_id_table(l_machine_resource_id_table.COUNT+1) := x_updated_tasks(i).machine_resource_id;
7535 l_status_id_table(l_status_id_table.COUNT+1) := x_updated_tasks(i).status_id;
7536 l_priority_table(l_priority_table.COUNT+1) := x_updated_tasks(i).priority;
7537 l_task_type_id_table(l_task_type_id_table.COUNT+1) := x_updated_tasks(i).task_type_id;
7538 l_move_order_line_id_table(l_move_order_line_id_table.COUNt+1) := x_updated_tasks(i).move_order_line_id;
7539 l_to_lpn_id_table(l_to_lpn_id_table.COUNT+1) := x_updated_tasks(i).to_lpn_id;
7540 l_operation_plan_id_table(l_operation_plan_id_table.COUNT+1) := x_updated_tasks(i).operation_plan_id;
7541 -- l_dispatched_time_table(l_dispatched_time_table.COUNt+1) := x_updated_tasks(i).dispatched_time;
7542 END IF;
7543 IF x_updated_tasks(i).task_type_id <> 3 then
7544 --for inbound and outbound tasks,update mmtt
7545 l_mmtt_cartonization_id_table(l_mmtt_cartonization_id_table.COUNt+1) := x_updated_tasks(i).cartonization_id;
7546 l_mmtt_transaction_num_table(l_mmtt_transaction_num_table.COUNT+1) := x_updated_tasks(i).transaction_number;
7547 l_mmtt_usertask_type_id_table(l_mmtt_usertask_type_id_table.COUNt+1) := x_updated_tasks(i).user_task_type_id;
7548 l_mmtt_status_id_table(l_mmtt_status_id_table.COUNT+1) := x_updated_tasks(i).status_id;
7549 l_mmtt_priority_table(l_mmtt_priority_table.COUNT+1) := x_updated_tasks(i).priority;
7550 l_mmtt_operation_plan_id_table(l_mmtt_operation_plan_id_table.COUNT+1):= x_updated_tasks(i).operation_plan_id;
7551 ELSE
7552 l_mcce_transaction_num_table(l_mcce_transaction_num_table.COUNT+1) := x_updated_tasks(i).transaction_number;
7553 l_mcce_usertask_type_id_table(l_mcce_usertask_type_id_table.COUNt+1) := x_updated_tasks(i).user_task_type_id;
7554 l_mcce_priority_table(l_mcce_priority_table.COUNT+1) := x_updated_tasks(i).priority;
7555 END IF;
7556
7557 --If the x_updated_tasks(i).status_id is 2 ,then update wdt also.
7558 --wdt does not have cartonization_id.
7562 l_wdt_usertask_type_id_table(l_wdt_usertask_type_id_table.COUNt+1) := x_updated_tasks(i).user_task_type_id;
7559 --Also this needs to be done only if wdt was existing before.
7560 IF (x_updated_tasks(i).status_id = 2 AND (nvl(p_new_task_status,-99) <> 2) )THEN
7561 l_wdt_transaction_num_table(l_wdt_transaction_num_table.COUNT+1) := x_updated_tasks(i).transaction_number;
7563 l_wdt_status_id_table(l_wdt_status_id_table.COUNT+1) := x_updated_tasks(i).status_id;
7564 l_wdt_priority_table(l_wdt_priority_table.COUNT+1) := x_updated_tasks(i).priority;
7565 l_wdt_operation_plan_id_table(l_wdt_operation_plan_id_table.COUNT+1) := x_updated_tasks(i).operation_plan_id;
7566 END IF;
7567
7568 IF (nvl(p_new_task_status,-99) in (1,8)) THEN
7569 l_wdt_del_trns_num_table(l_wdt_del_trns_num_table.COUNT+1) := x_updated_tasks(i).transaction_number;
7570 END IF;
7571
7572 END IF;
7573 END LOOP;
7574
7575 --Do BULK INSERT,UPDATE
7576 IF (l_transaction_num_table.COUNT > 0) THEN
7577 FORALL i in 1..l_transaction_num_table.COUNT
7578 INSERT
7579 INTO wms_dispatched_tasks
7580 (
7581 task_id ,
7582 transaction_temp_id ,
7583 organization_id ,
7584 user_task_type ,
7585 person_id ,
7586 effective_start_date,
7587 effective_end_date ,
7588 person_resource_id ,
7589 machine_resource_id ,
7590 status ,
7591 dispatched_time ,
7592 last_update_date ,
7593 last_updated_by ,
7594 creation_date ,
7595 created_by ,
7596 task_type ,
7597 priority ,
7598 move_order_line_id ,
7599 operation_plan_id ,
7600 transfer_lpn_id
7601 )
7602 VALUES
7603 (
7604 wms_dispatched_tasks_s.NEXTVAL ,
7605 l_transaction_num_table(i) ,
7606 l_organization_id_table(i) ,
7607 l_usertask_type_id_table(i) ,
7608 p_person_id ,
7609 sysdate ,
7610 sysdate ,
7611 l_person_resource_id_tabe(i) ,
7612 l_machine_resource_id_table(i) ,
7613 l_status_id_table(i) ,
7614 sysdate ,
7615 sysdate ,
7616 FND_GLOBAL.USER_ID ,
7617 sysdate ,
7618 FND_GLOBAL.USER_ID ,
7619 l_task_type_id_table(i) ,
7620 l_priority_table(i) ,
7621 l_move_order_line_id_table(i) ,
7622 l_operation_plan_id_table(i) ,
7623 l_to_lpn_id_table(i) );
7624 END IF;
7625
7626 IF (l_mmtt_transaction_num_table.COUNT > 0) THEN
7627 FORALL i in 1..l_mmtt_transaction_num_table.COUNT
7628 UPDATE mtl_material_transactions_temp
7629 SET wms_task_status = l_mmtt_status_id_table(i) ,
7630 operation_plan_id = l_mmtt_operation_plan_id_table(i),
7631 cartonization_id = l_mmtt_cartonization_id_table(i) ,
7632 task_priority = l_mmtt_priority_table(i) ,
7633 standard_operation_id = l_mmtt_usertask_type_id_table(i)
7634 WHERE transaction_temp_id = l_mmtt_transaction_num_table(i);
7635 END IF;
7636
7637 IF (l_mcce_transaction_num_table.COUNT > 0) THEN
7638 FORALL i in 1..l_mcce_transaction_num_table.COUNT
7639 UPDATE mtl_cycle_count_entries
7640 SET task_priority = l_mcce_priority_table(i) ,
7641 standard_operation_id = l_mcce_usertask_type_id_table(i)
7642 WHERE cycle_count_entry_id = l_mcce_transaction_num_table(i);
7643 END IF;
7644
7645 IF (l_wdt_transaction_num_table.COUNT > 0) THEN
7646 FORALL i in 1..l_wdt_transaction_num_table.COUNT
7647 UPDATE wms_dispatched_tasks
7648 SET status = l_wdt_status_id_table(i) ,
7649 operation_plan_id = l_wdt_operation_plan_id_table(i),
7650 priority = l_wdt_priority_table(i) ,
7651 user_task_type = l_wdt_usertask_type_id_table(i)
7652 WHERE transaction_temp_id = l_wdt_transaction_num_table(i);
7653 END IF;
7654
7655 IF (l_wdt_del_trns_num_table.COUNT > 0) THEN
7656 FORALL i in 1..l_wdt_del_trns_num_table.COUNT
7657 DELETE from wms_dispatched_tasks
7658 WHERE transaction_temp_id = l_wdt_del_trns_num_table(i);
7659 END IF;
7660
7661 IF (p_commit = FND_API.G_TRUE) THEN
7662 COMMIT;
7663 END IF;
7664 EXCEPTION
7665 WHEN OTHERS THEN
7666 x_return_status := fnd_api.g_ret_sts_unexp_error;
7667 fnd_msg_pub.count_and_get(p_encoded => FND_API.G_FALSE,p_count => x_msg_count, p_data => x_msg_data);
7668 l_err_msg := substr(SQLERRM,1,1000);
7669 IF(l_debug = 1) THEN
7670 inv_trx_util_pub.trace(l_api_name|| ': '||l_err_msg);
7671 END IF;
7672
7673 END modify_task;
7674
7675 -------------------------------------------------------------------------------------------------------------
7676
7677 /*This Public API takes care of cancelling a single or a set of crossdock tasks.
7678
7679 PROCEDURE cancel_task (p_transaction_number IN NUMBER DEFAULT NULL
7680 , p_task_table IN WMS_TASKS_PUB.TASK_TABLE
7681 , p_commit IN VARCHAR2 DEFAULT G_FALSE
7682 , x_undeleted_tasks OUT NOCOPY WMS_TASKS_PUB.TASK_TABLE
7683 , x_unprocessed_crossdock_tasks
7684 OUT NOCOPY WMS_TASKS_PUB.TASK_TABLE
7685 , x_return_status OUT NOCOPY VARCHAR2
7686 , x_msg_count OUT NOCOPY NUMBER
7687 , x_msg_data OUT NOCOPY VARCHAR2 );
7688
7689
7690 Parameter Description
7691
7692 p_transaction_number This corrsponds to the task_id that user is trying to cancel
7693 P_task_table This correspinds to the set of tasks that user is trying to cancel
7694 P_Commit This parameter decides whether to commit the changes or not.
7695 X_unprocessed_crossdockdeleted_tasks
7696 This parameter contains the set of tasks that could not be cancelled.
7697 X_return_status This parameter gives the return status of cancel_task API. 'S' = Success, 'U' = Unexpected Error, 'E' = Error.
7698 X_msg_count This gives the count of messages logged during the task deletion process.
7699 X_msg_data This gives the descrption of the messages that got logged during the task deletion process.
7700 */
7701 -------------------------------------------------------------------------------------------------------------
7702
7703 PROCEDURE cancel_task(
7704 p_transaction_number IN NUMBER DEFAULT NULL,
7705 p_commit IN VARCHAR2 DEFAULT fnd_api.g_false,
7706 p_wms_task IN WMS_TASK_MGMT_PUB.task_tab_type,
7707 x_unprocessed_crossdock_tasks OUT NOCOPY WMS_TASK_MGMT_PUB.task_tab_type,
7708 x_return_status OUT NOCOPY VARCHAR2,
7709 x_msg_count OUT NOCOPY NUMBER,
7710 x_msg_data OUT NOCOPY VARCHAR2
7711 )
7712 IS
7713
7714 l_val_ret_status VARCHAR2(10) ;
7715 l_task_table WMS_TASK_MGMT_PUB.task_tab_type ;
7716 l_transaction_number NUMBER ;
7717 l_ret_task_table WMS_TASK_MGMT_PUB.task_tab_type;
7718 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
7719 l_unprocessed_crossdock_count NUMBER := 1;
7720 l_msg VARCHAR2(2000);
7721
7722 BEGIN
7723
7724 x_return_status := fnd_api.g_ret_sts_success;
7725 --anjana
7726 x_msg_count := 0;
7727 l_transaction_number:= p_transaction_number ;
7728 l_task_table := p_wms_task;
7729
7730
7731 IF l_debug = 1 THEN
7732 inv_trx_util_pub.trace('CANCEL_TASK: Enter...');
7733 END IF;
7734
7735 WMS_TASK_MGMT_PUB.validate_tasks( p_transaction_number => l_transaction_number ,
7736 p_task_table => l_task_table ,
7737 x_wms_task => l_ret_task_table ,
7738 x_return_status => l_val_ret_status );
7739 IF l_debug = 1 THEN
7740 inv_trx_util_pub.trace('cancel_task l_val_ret_status is : '||l_val_ret_status);
7741 END IF;
7742
7743 IF (l_val_ret_status = fnd_api.g_ret_sts_success) THEN
7744 IF l_debug = 1 THEN
7745 inv_trx_util_pub.trace('l_ret_task_table.count : '||l_ret_task_table.count);
7746 END IF;
7747
7748 FOR i in 1..l_ret_task_table.count LOOP
7749 IF l_debug = 1 THEN
7750 inv_trx_util_pub.trace('cancel_task l_ret_task_table(i).RESULT '||l_ret_task_table(i).RESULT);
7751 END IF;
7752 IF ( nvl(l_ret_task_table(i).RESULT,'X')<> FND_API.G_RET_STS_ERROR)THEN
7753 IF l_debug = 1 THEN
7754 inv_trx_util_pub.trace('cancel_task transaction_number '||l_ret_task_table(i).transaction_number);
7755 END IF;
7756 SAVEPOINT SAVEPOINT1;
7757 WMS_CROSS_DOCK_PVT.cancel_crossdock_task(p_transaction_temp_id => l_ret_task_table(i).transaction_number
7758 ,x_return_status => x_return_status
7759 ,x_msg_data => x_msg_data
7760 ,x_msg_count => x_msg_count);
7761 IF l_debug = 1 THEN
7762 inv_trx_util_pub.trace('cancel_task CANCEL_TASK: x_return_status: ' || x_return_status);
7763 END IF;
7764
7765 IF (x_return_status<>FND_API.G_RET_STS_SUCCESS) THEN
7766 FND_MESSAGE.SET_NAME('WMS', 'WMS_CANCEL_FAILED');
7767 l_msg := fnd_message.get;
7768 x_msg_count := x_msg_count + 1;
7769 x_msg_data := x_msg_data || l_msg;
7770
7771 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).transaction_number := l_transaction_number;
7772 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).result := x_return_status;
7773 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).error := l_msg;
7774 l_unprocessed_crossdock_count :=l_unprocessed_crossdock_count+1;
7775 ROLLBACK TO SAVEPOINT1;
7776 END IF;
7777 ELSE
7778 FND_MESSAGE.SET_NAME('WMS', 'WMS_INVALID_TASK');
7779 l_msg := fnd_message.get;
7780 x_msg_count := x_msg_count + 1;
7781 x_msg_data := x_msg_data || l_msg;
7782 IF l_debug = 1 THEN
7783 inv_trx_util_pub.trace('Validate_task returned error for this record');
7784 END IF;
7785 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).transaction_number := l_transaction_number;
7786 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).result := l_ret_task_table(i).RESULT;
7787 x_unprocessed_crossdock_tasks(l_unprocessed_crossdock_count).error := l_msg;
7788 l_unprocessed_crossdock_count := l_unprocessed_crossdock_count+1;
7789 END IF;
7790 END LOOP;
7791 IF l_debug = 1 THEN
7792 inv_trx_util_pub.trace('CANCEL_TASK: x_unprocessed_crossdock_tasks: ' || x_unprocessed_crossdock_tasks.count);
7793 inv_trx_util_pub.trace('CANCEL_TASK: Exiting...');
7794 END IF;
7795 ELSE
7796 IF l_debug = 1 THEN
7797 inv_trx_util_pub.trace('CANCEL_TASK: Error occured while validating the transaction_number or table of transaction_number...');
7798 END IF;
7799 x_return_status:=FND_API.G_RET_STS_UNEXP_ERROR;
7800 RETURN;
7801 END IF;
7802
7803 IF (p_commit= FND_API.G_TRUE ) THEN
7804 COMMIT;
7805 END IF;
7806 EXCEPTION
7807 WHEN fnd_api.g_exc_error THEN
7808 IF l_debug = 1 THEN
7809 inv_trx_util_pub.trace('CANCEL_TASK: Expected Error occurred while performing cancel cross dock task:'|| SQLCODE);
7810 END IF;
7811 x_return_status:=FND_API.G_RET_STS_ERROR;
7812 ROLLBACK TO SAVEPOINT1;
7813 RETURN;
7814 WHEN OTHERS THEN
7815 IF l_debug = 1 THEN
7816 inv_trx_util_pub.trace('CANCEL_TASK: Unknown Error occurred while performing cancel cross dock task:'|| SQLCODE);
7817 END IF;
7818 x_return_status:=FND_API.G_RET_STS_UNEXP_ERROR;
7819 ROLLBACK TO SAVEPOINT1;
7820 RETURN;
7821 END cancel_task;
7822
7823 END WMS_TASK_MGMT_PUB;