[Home] [Help]
PACKAGE BODY: APPS.WMS_TASK_DISPATCH_ENGINE
Source
1 PACKAGE BODY wms_task_dispatch_engine AS
2 /* $Header: WMSTDENB.pls 120.34.12020000.8 2013/02/22 03:14:33 sahmahes ship $*/
3
4
5 --
6 -- File : WMSTDENB.pls
7 -- Content : WMS_task_schedule package body
8 -- Description : WMS task dispatching API for mobile application
9 -- Notes :
10 -- Modified : 05/01/2000 lezhang created
11
12
13
14 -- API name : taskdsp
15 -- Type : Private
16 -- Function : Return a group of tasks that a sign-on employee is eligible
17 -- to perform
18 -- Or return a group of picking tasks with the same picking
19 -- methodology and pick slip number. This group of tasks includes
20 -- the most optimal task based on priority, locator picking
21 -- sequence, coordinates approximation, etc.
22 -- or reservation input parameters and creates recommendations
23 -- Pre-reqs : 1. For each record in MTL_MATERIAL_TRANSACTIONS_TEMP, user
24 -- defined task type (standard_operation_id column ) has been
25 -- assigned,
26 -- 2. System task type (wms_task_type column) has been assigned
27 -- 3. Pick slip
28 -- number (pick_slip_number column) has been assigned
29 --
30 -- Parameters :
31 -- p_api_version Standard Input Parameter
32 -- p_init_msg_list Standard Input Parameter
33 -- p_commit Standard Input Parameter
34 -- p_validation_level Standard Input Parameter
35 -- p_sign_on_emp_id NUMBER, sign on emplployee ID, mandatory
36 -- p_sign_on_org_id NUMBER, org ID, mandatory
37 -- p_sign_on_zone VARCHAR2, sign on sub ID, optional
38 -- p_sign_on_equipment_id NUMBER, sign on equipment item ID, optional,
39 -- can be a specific number, NULL or -999,
40 -- -999 means none
41 -- p_sign_on_equipment_srl VARCHAR2, sign on equipment serial num, optional
42 -- can be a specific serial number, NULL or '@@@',
43 -- '@@@' means none
44 -- p_task_type VARCHAR2, system task type this API will return,
45 -- can be 'PICKING', 'ALL', 'DISPLAY'
46 --
47 --
48 -- Output Parameters
49 -- x_return_status Standard Output Parameter
50 -- x_msg_count Standard Output Parameter
51 -- x_msg_data Standard Output Parameter
52 -- x_task_cur Reference Cursor to deliver the queried tasks
53 -- It includes following fields:
54 -- mmtt.transaction_temp_id NUMBER
55 -- mmtt.subinventory_code VARCHAR2
56 -- mmtt.locator_id NUMBER
57 -- mmtt.revision VARCHAR2
58 -- mmtt.transaction_uom VARCHAR2
59 -- mmtt.transaction_quantity NUMBER
60 -- mmtt.lot_number NUMBER
61 --
62 --
63 -- Version
64 -- Currently version is 1.0
65 --
66
67
68 -- Global constant holding the package name
69 g_pkg_name CONSTANT VARCHAR2(30) := 'WMS_Task_Dispatch_Engine';
70 g_move_order_mfg_pick CONSTANT NUMBER := inv_globals.g_move_order_mfg_pick;
71 g_move_order_pick_wave CONSTANT NUMBER := inv_globals.g_move_order_pick_wave;
72 g_exc_unexpected_error EXCEPTION ;
73 g_current_release_level CONSTANT NUMBER := WMS_CONTROL.G_CURRENT_RELEASE_LEVEL;
74 g_j_release_level CONSTANT NUMBER := INV_RELEASE.G_J_RELEASE_LEVEL;
75 g_user_id CONSTANT NUMBER := fnd_global.user_id;
76
77 -- cached variables for each move order header
78 g_move_order_header_id NUMBER; -- used to decide if the g_delivery_flag need to be requeried or not
79 g_delivery_flag VARCHAR2(1) := 'N';
80 g_bulk_pick_control NUMBER;
81
82
83 PROCEDURE print_debug(p_err_msg VARCHAR2, p_level NUMBER) IS
84 BEGIN
85 -- dbms_output.put_line(p_err_msg);
86 inv_mobile_helper_functions.tracelog(p_err_msg => p_err_msg, p_module => 'WMS_Task_Dispatch_Engine', p_level => p_level);
87 END print_debug;
88
89 -- bug 4358107
90 PROCEDURE store_locked_tasks
91 (p_grp_doc_type IN VARCHAR2,
92 p_grp_doc_num IN NUMBER,
93 p_grp_src_type_id IN NUMBER,
94 x_return_status OUT NOCOPY VARCHAR2)
95 IS
96 --{
97 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
98 i NUMBER ;
99 --}
100 BEGIN
101 --{
102 IF (l_debug = 1) THEN
103 print_debug('Enter STORE_LOCKED_TASKS ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
104 print_debug(' grouping document type : ' || p_grp_doc_type, 9);
105 print_debug(' grouping document number : ' || p_grp_doc_num, 9);
106 print_debug(' grouping source type : ' || p_grp_src_type_id, 9);
107 END IF;
108
109 x_return_status := fnd_api.g_ret_sts_success;
110
111 savepoint store_locked_tasks;
112
113 -- Inserting the data into temp table
114 insert into WMS_DISPATCH_TASKS_GTMP
115 (
116 grouping_document_type,
117 grouping_document_number,
118 grouping_source_type_id
119 )
120 values
121 (
122 p_grp_doc_type,
123 p_grp_doc_num,
124 p_grp_src_type_id
125 );
126
127 IF (l_debug = 1) THEN
128 print_debug('Exit STORE_LOCKED_TASKS ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
129 END IF;
130 --}
131 EXCEPTION
132 --{
133 WHEN OTHERS THEN
134 IF (l_debug = 1) THEN
135 print_debug('STORE_LOCKED_TASKS : Exception Occured ' || substrb(SQLERRM,1,200), 1);
136 END IF;
137 rollback to store_locked_tasks;
138 x_return_status := fnd_api.g_ret_sts_unexp_error;
139 --}
140 END store_locked_tasks;
141
142 PROCEDURE remove_stored_cartons(x_return_status OUT NOCOPY VARCHAR2)
143 IS
144 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
145 i NUMBER ;
146 BEGIN
147 x_return_status := fnd_api.g_ret_sts_success;
148
149 savepoint remove_stored_cartons;
150
151 -- remove the data from temp table
152 DELETE FROM WMS_DISPATCH_TASKS_GTMP
153 WHERE GROUPING_DOCUMENT_NUMBER IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id));
154
155 IF (l_debug = 1) THEN
156 print_debug('Exit REMOVE_STORED_CARTONS ' , 1);
157 END IF;
158 EXCEPTION
159 WHEN OTHERS THEN
160 IF (l_debug = 1) THEN
161 print_debug('REMOVE_STORED_CARTONS : Exception Occured ' || substrb(SQLERRM,1,200), 1);
162 END IF;
163 rollback to remove_stored_cartons;
164 x_return_status := fnd_api.g_ret_sts_unexp_error;
165 END remove_stored_cartons;
166
167 --Added for Case Picking Project start
168 PROCEDURE remove_stored_order_num(x_return_status OUT NOCOPY VARCHAR2) IS
169 BEGIN
170 x_return_status := fnd_api.g_ret_sts_success;
171 savepoint remove_stored_order_numbers;
172 DELETE FROM WMS_DISPATCH_TASKS_GTMP WHERE
173 GROUPING_DOCUMENT_NUMBER IN (
174 SELECT MMTT.TRANSACTION_SOURCE_ID
175 FROM MTL_SALES_ORDERS MSO ,
176 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
177 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
178 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
179 );
180 EXCEPTION
181 WHEN OTHERS THEN
182 rollback to remove_stored_order_numbers;
183 x_return_status := fnd_api.g_ret_sts_unexp_error;
184 END remove_stored_order_num;
185
186 PROCEDURE remove_stored_pick_slip_num(x_return_status OUT NOCOPY VARCHAR2) IS
187 BEGIN
188 x_return_status := fnd_api.g_ret_sts_success;
189 savepoint remove_store_pick_slip_numbers;
190 DELETE FROM WMS_DISPATCH_TASKS_GTMP WHERE
191 GROUPING_DOCUMENT_NUMBER IN
192 (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers));
193 EXCEPTION
194 WHEN OTHERS THEN
195 rollback to remove_stored_pick_slip_number;
196 x_return_status := fnd_api.g_ret_sts_unexp_error;
197 END remove_stored_pick_slip_num;
198 --Added for Case Picking Project end
199
200
201 -- bug 4358107
202 -- APL procedure: Used since 11.5.10
203 PROCEDURE dispatch_task
204 (p_api_version IN NUMBER,
205 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
206 p_commit IN VARCHAR2 := fnd_api.g_false,
207 p_sign_on_emp_id IN NUMBER,
208 p_sign_on_org_id IN NUMBER,
209 p_sign_on_zone IN VARCHAR2 := NULL,
210 p_sign_on_equipment_id IN NUMBER := NULL, -- specific equip idNULL or -999. -999 stands for none
211 p_sign_on_equipment_srl IN VARCHAR2 := NULL, -- same as above
212 p_task_filter IN VARCHAR2,
213 p_task_method IN VARCHAR2,
214 x_grouping_document_type IN OUT nocopy VARCHAR2,
215 x_grouping_document_number IN OUT nocopy NUMBER,
216 x_grouping_source_type_id IN OUT nocopy NUMBER,
217 x_task_cur OUT NOCOPY task_rec_cur_tp,
218 x_return_status OUT NOCOPY VARCHAR2,
219 x_msg_count OUT NOCOPY NUMBER,
220 x_msg_data OUT NOCOPY VARCHAR2)
221 IS
222
223 l_cur_x NUMBER;
224 l_cur_y NUMBER;
225 l_cur_z NUMBER;
226
227 l_task_priority NUMBER;
228 l_sub_pick_order NUMBER;
229 l_loc_pick_order NUMBER;
230 l_x_coordinate NUMBER;
231 l_y_coordinate NUMBER;
232 l_z_coordinate NUMBER;
233 l_is_locked BOOLEAN := FALSE;
234
235 l_sign_on_equipment_id NUMBER;
236 l_sign_on_equipment_srl VARCHAR2(30);
237
238
239 l_last_loaded_time DATE;
240 l_last_loaded_task_id NUMBER;
241 l_last_loaded_task_type NUMBER;
242 l_last_dropoff_time DATE;
243 l_last_dropoff_task_id NUMBER;
244 l_last_dropoff_task_type NUMBER;
245 l_last_task_type NUMBER;
246 l_last_task_is_drop BOOLEAN := FALSE;
247 l_last_task_id NUMBER;
248 l_lpn_id NUMBER; --Added for bug# 3853837
249 l_wdt_count NUMBER; --Added for bug# 3853837
250 l_ordered_tasks_count NUMBER;
251 l_first_task_pick_slip_number NUMBER;
252 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
253 l_api_version CONSTANT NUMBER := 1.0;
254 l_progress VARCHAR2(10);
255 l_sequence_picks_across_waves NUMBER := 2;
256
257 l_so_allowed NUMBER := 0;
258 l_io_allowed NUMBER := 0;
259 l_wip_allowed NUMBER := 0;
260 l_mot_rep_allowed NUMBER := 0;
261 l_mot_allowed NUMBER := 0;
262 l_rep_allowed NUMBER := 0;
263 l_mot_moi_allowed NUMBER := 0;
264 l_moi_allowed NUMBER := 0;
265 l_cc_allowed NUMBER := 0;
266 l_non_cc_allowed NUMBER := 0;
267
268 l_task_id NUMBER;
269 l_subinventory_code VARCHAR2(10);
270 l_locator_id NUMBER;
271 l_task_type_id NUMBER;
272 l_cartonization_id NUMBER;
273 l_batch_id NUMBER;
274 l_pick_slip NUMBER := 0;
275 l_distance NUMBER;
276 l_task_status NUMBER;
277 l_transaction_quantity NUMBER;
278 l_transaction_uom VARCHAR2(3);
279 l_transaction_action_id NUMBER;
280 l_transaction_type_id NUMBER;
281 l_transaction_source_type_id NUMBER;
282 l_transaction_source_id NUMBER;
283 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
284 l_lot_number VARCHAR2(80);
285 l_revision VARCHAR2(3);
286 l_operation_plan_id NUMBER;
287 l_move_order_line_id NUMBER;
288 l_standard_operation_id NUMBER;
289 l_effective_start_date DATE;
290 l_effective_end_date DATE;
291 l_person_resource_id NUMBER;
292 l_machine_resource_id NUMBER;
293 -- bug 4358107
294 l_return_status VARCHAR2(1);
295 -- bug 4358107
296 l_q_sign_on_equipment_id NUMBER; --bug 6017284
297 l_ignore_equipment NUMBER; --bug 6017284
298
299 l_total_lpns NUMBER; --Bug 7254397
300 l_locked_lpns NUMBER; --Bug 7254397
301
302 l_wait_count NUMBER := 0; --Bug 14094713
303
304 /* Bug 3808770
305 Added condition in all the cursors selecting cycle count tasks to select
306 only those tasks whose cycle count have not been disabled by entering
307 an Inactive Date.
308 Added the table mtl_cycle_count_headers in the FROM clause and joined with
309 mtl_cycle_count_entries and checked for disable_date value with sysdate.
310 */
311
312 -- Cursor #1 for selecting the most optimal task
313 -- 1. Sub is passed (1)
314 -- 2. Non cycle count tasks (1)
315 -- 3. Cycle count tasks (1)
316 CURSOR l_curs_opt_task_111 IS
317 SELECT DISTINCT
318 qt.task_id task_num,
319 qt.pick_slip,
320 wdt.task_type wms_task_type_id,
321 nvl(wdt.priority, 0) task_priority,
322 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
323 sub.picking_order sub_picking_order,
324 loc.picking_order loc_picking_order,
325 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
326 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
327 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
328 wdt.status task_status, --bug 4310093
329 qt.transaction_type_id,
330 qt.transaction_action_id,
331 qt.transaction_source_id,
332 qt.transaction_source_type_id
333 FROM wms_dispatched_tasks wdt,
334 (SELECT
335 transaction_temp_id task_id,
336 pick_slip_number pick_slip,
337 cartonization_id,
338 organization_id,
339 subinventory_code,
340 locator_id,
341 move_order_line_id,
342 transaction_type_id,
343 transaction_action_id,
344 transaction_source_id,
345 transaction_source_type_id
346 FROM mtl_material_transactions_temp mmtt
347 WHERE wms_task_type IS NOT NULL
348 AND transaction_temp_id = Decode(p_task_method, 'BULK',
349 parent_line_id, transaction_temp_id)
350 AND Decode(transaction_source_type_id,
351 2, l_so_allowed,
352 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
353 5, Decode(transaction_type_id, 35, l_wip_allowed),
354 8, l_io_allowed,
355 13, Decode(transaction_type_id,
356 51, l_wip_allowed,
357 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
358 --7169220: USERS LOCKED
359 AND (mmtt.cartonization_id is null
360 or not exists
361 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
362 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
363 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
364 and wdt1.status = 9
365 and mmtt1.cartonization_id = mmtt.cartonization_id)
366 )
367 UNION ALL
368 SELECT
369 MIN(mcce.cycle_count_entry_id) task_id,
370 TO_NUMBER(NULL) pick_slip,
371 To_number(NULL) cartonization_id,
372 mcce.organization_id,
373 mcce.subinventory subinventory_code,
374 mcce.locator_id,
375 To_number(NULL) move_order_line_id,
376 4 transaction_type_id,
377 4 transaction_action_id,
378 mcce.cycle_count_header_id transaction_source_id,
379 9 transaction_source_type_id
380 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
381 WHERE mcce.entry_status_code IN(1, 3)
382 AND NVL(mcce.export_flag, 2) = 2
383 -- bug 3972076
384 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
385 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
386 AND mcce.organization_id = mcch.organization_id -- Bug 13796753
387 AND mcch.organization_id = p_sign_on_org_id -- Bug 13796753
388 AND NVL(mcch.disable_date,sysdate+1)> sysdate
389 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
390 mtl_txn_request_lines mol,
391 mtl_secondary_inventories sub,
392 mtl_item_locations loc,
393 (SELECT
394 bsor.standard_operation_id,
395 bre.resource_id,
396 bre.inventory_item_id equipment_id
397 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
398 WHERE bsor.resource_id = bre.resource_id
399 AND br.resource_type = 1
400 AND bsor.resource_id = br.resource_id) e
401 WHERE wdt.transaction_temp_id = qt.task_id
402 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
403 AND wdt.person_id = p_sign_on_emp_id
404 AND wdt.organization_id = p_sign_on_org_id
405 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
406 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
407 AND wdt.user_task_type = e.standard_operation_id(+)
408 AND qt.move_order_line_id = mol.line_id(+)
409 AND qt.subinventory_code = p_sign_on_zone
410 AND qt.organization_id = sub.organization_id
411 AND qt.subinventory_code = sub.secondary_inventory_name
412 AND qt.organization_id = loc.organization_id
413 AND qt.locator_id = loc.inventory_location_id
414 UNION ALL
415 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
416 wdtv.task_id task_num,
417 NVL(wdtv.pick_slip_number, -1) pick_slip,
418 wdtv.wms_task_type_id,
419 nvl(wdtv.task_priority, 0),
420 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
421 sub.picking_order sub_picking_order,
422 loc.picking_order loc_picking_order,
423 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
424 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
425 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
426 task_status,
427 wdtv.transaction_type_id,
428 wdtv.transaction_action_id,
429 wdtv.transaction_source_id,
430 wdtv.transaction_source_type_id
431 FROM
432 -- inlined wms_dispatchable_tasks_v, bug 2648133
433 (SELECT
434 transaction_temp_id task_id,
435 standard_operation_id user_task_type_id,
436 wms_task_type wms_task_type_id,
437 organization_id,
438 subinventory_code zone,
439 locator_id,
440 task_priority,
441 revision,
442 lot_number,
443 transaction_uom,
444 transaction_quantity,
445 pick_rule_id,
446 pick_slip_number,
447 cartonization_id,
448 inventory_item_id,
449 move_order_line_id,
450 1 task_status,
451 transaction_type_id,
452 transaction_action_id,
453 transaction_source_id,
454 transaction_source_type_id
455 FROM mtl_material_transactions_temp mmtt
456 WHERE wms_task_type IS NOT NULL
457 AND transaction_status = 2
458 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
459 AND transaction_temp_id = Decode(p_task_method, 'BULK',
460 parent_line_id, transaction_temp_id)
461 AND Decode(transaction_source_type_id,
462 2, l_so_allowed,
463 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
464 5, Decode(transaction_type_id, 35, l_wip_allowed),
465 8, l_io_allowed,
466 13, Decode(transaction_type_id,
467 51, l_wip_allowed,
468 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
469 --7169220: USERS LOCKED
470 AND (mmtt.cartonization_id is null
471 or not exists
472 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
473 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
474 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
475 and wdt1.status = 9
476 and mmtt1.cartonization_id = mmtt.cartonization_id)
477 )
478
479 UNION ALL
480 SELECT
481 MIN(mcce.cycle_count_entry_id) task_id,
482 MIN(mcce.standard_operation_id) user_task_type_id,
483 3 wms_task_type_id,
484 mcce.organization_id,
485 mcce.subinventory zone,
486 mcce.locator_id,
487 MIN(mcce.task_priority) task_priority,
488 mcce.revision revision,
489 MIN(mcce.lot_number) lot_number,
490 '' transaction_uom,
491 TO_NUMBER(NULL) transaction_quantity,
492 TO_NUMBER(NULL) pick_rule_id,
493 TO_NUMBER(NULL) pick_slip_number,
494 TO_NUMBER(NULL) cartonization_id,
495 mcce.inventory_item_id,
496 TO_NUMBER(NULL) move_order_line_id,
497 1 task_status,
498 4 transaction_type_id,
499 4 transaction_action_id,
500 mcce.cycle_count_header_id transaction_source_id,
501 9 transaction_source_type_id
502 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
503 WHERE mcce.entry_status_code IN(1, 3)
504 AND NVL(mcce.export_flag, 2) = 2
505 -- bug 3972076
506 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
507 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
508
509 -----bug6903708---
510 AND mcce.organization_id = mcch.organization_id
511 AND mcch.organization_id = p_sign_on_org_id
512 ---------------------------
513
514 AND NVL(mcch.disable_date,sysdate+1)> sysdate
515 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
516 -- inlined wms_person_resource_utt_v, bug 2648133
517 (SELECT
518 utt_emp.standard_operation_id standard_operation_id,
519 utt_emp.resource_id role,
520 utt_eqp.resource_id equipment,
521 utt_emp.person_id emp_id,
522 utt_eqp.inventory_item_id eqp_id,
523 NULL eqp_srl /* removed for bug 2095237 */
524 FROM
525 (SELECT
526 x_utt_res1.standard_operation_id standard_operation_id,
527 x_utt_res1.resource_id resource_id,
528 x_emp_r.person_id
529 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
530 WHERE x_utt_res1.resource_id = r1.resource_id
531 AND r1.resource_type = 2
532 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
533 (SELECT
534 x_utt_res2.standard_operation_id standard_operation_id,
535 x_utt_res2.resource_id,
536 x_eqp_r.inventory_item_id
537 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
538 WHERE x_utt_res2.resource_id = r2.resource_id
539 AND r2.resource_type = 1
540 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
541 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
542 mtl_item_locations loc,
543 mtl_secondary_inventories sub,
544 mtl_txn_request_lines mol,
545 mtl_txn_request_headers moh
546 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
547 AND wdtv.organization_id = p_sign_on_org_id
548 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
549 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
550 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
551 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
552 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
553 AND wdtv.locator_id = loc.inventory_location_id(+)
554 AND wdtv.zone = sub.secondary_inventory_name
555 AND wdtv.organization_id = sub.organization_id
556 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
557 AND moh.header_id(+) = mol.header_id
558 AND Decode(Nvl(moh.move_order_type, -1),
559 2, l_rep_allowed,
560 1, l_mot_moi_allowed,
561 -1, 1,
562 1) = 1
563 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
564 -- bug 4358107
565 AND NOT EXISTS
566 ( SELECT 1
567 FROM WMS_DISPATCH_TASKS_GTMP
568 WHERE (p_task_method = 'DISCRETE'
569 and
570 grouping_document_number = wdtv.pick_slip_number
571 )
572 or
573 (
574 p_task_method = 'ORDERPICK'
575 and
576 grouping_document_number = wdtv.transaction_source_id
577 and
578 grouping_source_type_id = wdtv.transaction_source_type_id
579 )
580 or
581 (p_task_method = 'PICKBYLABEL'
582 and
583 grouping_document_number = wdtv.cartonization_id
584 )
585 or --6598260 start
586 ( grouping_document_number = wdtv.cartonization_id
587 and
588 grouping_document_type = 'CARTON_TASK'
589 ) --6598260 end
590 )
591 -- bug 4358107
592 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
593 (SELECT NULL
594 FROM mtl_material_transactions_temp mmtt
595 WHERE mmtt.transaction_temp_id = wdtv.task_id
596 AND mmtt.parent_line_id IS NOT NULL
597 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
598 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
599 AND NOT EXISTS -- exclude tasks already dispatched and queued
600 (SELECT NULL
601 FROM wms_dispatched_tasks wdt1
602 WHERE wdt1.transaction_temp_id = wdtv.task_id
603 AND wdt1.task_type = wdtv.wms_task_type_id)
604 -- excluded skipped tasks
605 AND wdtv.task_id NOT IN
606 (SELECT wdtv.task_id
607 FROM wms_skip_task_exceptions wste, mtl_parameters mp
608 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
609 AND wste.task_id = wdtv.task_id
610 AND wste.organization_id = mp.organization_id)
611 --J Addition
612 AND wdtv.zone not in (
613 SELECT wd.subinventory_code
614 FROM wms_devices_b wd
615 , wms_bus_event_devices wbed
616 WHERE 1 = 1
617 and wd.device_id = wbed.device_id
618 AND wbed.organization_id = wd.organization_id
619 AND wd.enabled_flag = 'Y'
620 AND wbed.enabled_flag = 'Y'
621 AND wbed.business_event_id = 10
622 AND wd.subinventory_code IS NOT NULL
623 AND wd.force_sign_on_flag = 'Y'
624 AND wd.device_id NOT IN (SELECT device_id
625 FROM wms_device_assignment_temp
626 WHERE employee_id = p_sign_on_emp_id)
627 )
628 ORDER BY
629 task_priority desc,
630 batch_id,
631 task_status DESC,
632 sub_picking_order,
633 loc_picking_order,
634 distance,
635 task_num;
636
637 -- Cursor #2 for selecting the most optimal task
638 -- 1. Sub is passed (1)
639 -- 2. Non cycle count tasks (1)
640 -- 3. Cycle count tasks (0)
641 CURSOR l_curs_opt_task_110 IS
642 SELECT DISTINCT
643 qt.task_id task_num,
644 qt.pick_slip,
645 wdt.task_type wms_task_type_id,
646 nvl(wdt.priority, 0) task_priority,
647 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
648 sub.picking_order sub_picking_order,
649 loc.picking_order loc_picking_order,
650 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
651 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
652 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
653 wdt.status task_status, --bug 4310093
654 qt.transaction_type_id,
655 qt.transaction_action_id,
656 qt.transaction_source_id,
657 qt.transaction_source_type_id
658 FROM wms_dispatched_tasks wdt,
659 (SELECT
660 transaction_temp_id task_id,
661 pick_slip_number pick_slip,
662 cartonization_id,
663 organization_id,
664 subinventory_code,
665 locator_id,
666 move_order_line_id,
667 transaction_type_id,
668 transaction_action_id,
669 transaction_source_id,
670 transaction_source_type_id
671 FROM mtl_material_transactions_temp mmtt
672 WHERE wms_task_type IS NOT NULL
673 AND transaction_temp_id = Decode(p_task_method, 'BULK',
674 parent_line_id, transaction_temp_id)
675 AND Decode(transaction_source_type_id,
676 2, l_so_allowed,
677 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
678 5, Decode(transaction_type_id, 35, l_wip_allowed),
679 8, l_io_allowed,
680 13, Decode(transaction_type_id,
681 51, l_wip_allowed,
682 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
683 --7169220: USERS LOCKED
684 AND (mmtt.cartonization_id is null
685 or not exists
686 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
687 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
688 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
689 and wdt1.status = 9
690 and mmtt1.cartonization_id = mmtt.cartonization_id)
691 )
692 ) qt,
693 mtl_txn_request_lines mol,
694 mtl_secondary_inventories sub,
695 mtl_item_locations loc,
696 (SELECT
697 bsor.standard_operation_id,
698 bre.resource_id,
699 bre.inventory_item_id equipment_id
700 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
701 WHERE bsor.resource_id = bre.resource_id
702 AND br.resource_type = 1
703 AND bsor.resource_id = br.resource_id) e
704 WHERE wdt.transaction_temp_id = qt.task_id
705 AND wdt.status = 2 --bug 6326482queued task only bug -- Queued and dispatched tasks only bug 4310093
706 AND wdt.person_id = p_sign_on_emp_id
707 AND wdt.organization_id = p_sign_on_org_id
708 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
709 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))--bug 6326482
710 AND wdt.user_task_type = e.standard_operation_id(+)
711 AND qt.move_order_line_id = mol.line_id(+)
712 AND qt.subinventory_code = p_sign_on_zone
713 AND qt.organization_id = sub.organization_id
714 AND qt.subinventory_code = sub.secondary_inventory_name
715 AND qt.organization_id = loc.organization_id
716 AND qt.locator_id = loc.inventory_location_id
717 UNION ALL
718 --bug 6326482 for dispatched tasks
719 SELECT DISTINCT
720 qt.task_id task_num,
721 qt.pick_slip,
722 wdt.task_type wms_task_type_id,
723 nvl(wdt.priority, 0) task_priority,
724 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
725 sub.picking_order sub_picking_order,
726 loc.picking_order loc_picking_order,
727 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
728 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
729 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
730 wdt.status task_status,
731 qt.transaction_type_id,
732 qt.transaction_action_id,
733 qt.transaction_source_id,
734 qt.transaction_source_type_id
735 FROM wms_dispatched_tasks wdt,
736 (SELECT
737 transaction_temp_id task_id,
738 wms_task_status task_status,--bug 6326482 added to know the previous state of dispatched tasks
739 pick_slip_number pick_slip,
740 cartonization_id,
741 organization_id,
742 subinventory_code,
743 locator_id,
744 move_order_line_id,
745 transaction_type_id,
746 transaction_action_id,
747 transaction_source_id,
748 transaction_source_type_id
749 FROM mtl_material_transactions_temp mmtt
750 WHERE wms_task_type IS NOT NULL
751 AND transaction_temp_id = Decode(p_task_method, 'BULK',
752 parent_line_id, transaction_temp_id)
753 AND Decode(transaction_source_type_id,
754 2, l_so_allowed,
755 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
756 5, Decode(transaction_type_id, 35, l_wip_allowed),
757 8, l_io_allowed,
758 13, Decode(transaction_type_id,
759 51, l_wip_allowed,
760 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
761 --7169220: USERS LOCKED
762 AND (mmtt.cartonization_id is null
763 or not exists
764 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
765 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
766 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
767 and wdt1.status = 9
768 and mmtt1.cartonization_id = mmtt.cartonization_id)
769 )
770 ) qt,
771 mtl_txn_request_lines mol,
772 mtl_secondary_inventories sub,
773 mtl_item_locations loc,
774 (SELECT
775 bsor.standard_operation_id,
776 bre.resource_id,
777 bre.inventory_item_id equipment_id
778 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
779 WHERE bsor.resource_id = bre.resource_id
780 AND br.resource_type = 1
781 AND bsor.resource_id = br.resource_id) e
782 WHERE wdt.transaction_temp_id = qt.task_id
783 AND wdt.status = 3 -- bug 6326482 dispatched tasks
784 AND wdt.person_id = p_sign_on_emp_id
785 AND wdt.organization_id = p_sign_on_org_id
786 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
787 --bug 6326482
788 AND ((qt.task_status is NULL
789 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
790 or
791 (qt.task_status = 1
792 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
793 AND wdt.user_task_type = e.standard_operation_id(+)
794 AND qt.move_order_line_id = mol.line_id(+)
795 AND qt.subinventory_code = p_sign_on_zone
796 AND qt.organization_id = sub.organization_id
797 AND qt.subinventory_code = sub.secondary_inventory_name
798 AND qt.organization_id = loc.organization_id
799 AND qt.locator_id = loc.inventory_location_id
800 UNION ALL
801 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
802 wdtv.task_id task_num,
803 NVL(wdtv.pick_slip_number, -1) pick_slip,
804 wdtv.wms_task_type_id,
805 nvl(wdtv.task_priority, 0),
806 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
807 sub.picking_order sub_picking_order,
808 loc.picking_order loc_picking_order,
809 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
810 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
811 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
812 task_status,
813 wdtv.transaction_type_id,
814 wdtv.transaction_action_id,
815 wdtv.transaction_source_id,
816 wdtv.transaction_source_type_id
817 FROM
818 -- inlined wms_dispatchable_tasks_v, bug 2648133
819 (SELECT
820 transaction_temp_id task_id,
821 standard_operation_id user_task_type_id,
822 wms_task_type wms_task_type_id,
823 organization_id,
824 subinventory_code zone,
825 locator_id,
826 task_priority,
827 revision,
828 lot_number,
829 transaction_uom,
830 transaction_quantity,
831 pick_rule_id,
832 pick_slip_number,
833 cartonization_id,
834 inventory_item_id,
835 move_order_line_id,
836 1 task_status,
837 transaction_type_id,
838 transaction_action_id,
839 transaction_source_id,
840 transaction_source_type_id
841 FROM mtl_material_transactions_temp mmtt
842 WHERE wms_task_type IS NOT NULL
843 AND transaction_status = 2
844 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
845 AND transaction_temp_id = Decode(p_task_method, 'BULK',
846 parent_line_id, transaction_temp_id)
847 AND Decode(transaction_source_type_id,
848 2, l_so_allowed,
849 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
850 5, Decode(transaction_type_id, 35, l_wip_allowed),
851 8, l_io_allowed,
852 13, Decode(transaction_type_id,
853 51, l_wip_allowed,
854 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
855 --7169220: USERS LOCKED
856 AND (mmtt.cartonization_id is null
857 or not exists
858 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
859 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
860 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
861 and wdt1.status = 9
862 and mmtt1.cartonization_id = mmtt.cartonization_id)
863 )
864 ) wdtv,
865 -- inlined wms_person_resource_utt_v, bug 2648133
866 (SELECT
867 utt_emp.standard_operation_id standard_operation_id,
868 utt_emp.resource_id role,
869 utt_eqp.resource_id equipment,
870 utt_emp.person_id emp_id,
871 utt_eqp.inventory_item_id eqp_id,
872 NULL eqp_srl /* removed for bug 2095237 */
873 FROM
874 (SELECT
875 x_utt_res1.standard_operation_id standard_operation_id,
876 x_utt_res1.resource_id resource_id,
877 x_emp_r.person_id
878 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
879 WHERE x_utt_res1.resource_id = r1.resource_id
880 AND r1.resource_type = 2
881 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
882 (SELECT
883 x_utt_res2.standard_operation_id standard_operation_id,
884 x_utt_res2.resource_id,
885 x_eqp_r.inventory_item_id
886 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
887 WHERE x_utt_res2.resource_id = r2.resource_id
888 AND r2.resource_type = 1
889 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
890 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
891 mtl_item_locations loc,
892 mtl_secondary_inventories sub,
893 mtl_txn_request_lines mol,
894 mtl_txn_request_headers moh
895 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
896 AND wdtv.organization_id = p_sign_on_org_id
897 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
898 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
899 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
900 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
901 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
902 AND wdtv.locator_id = loc.inventory_location_id(+)
903 AND wdtv.zone = sub.secondary_inventory_name
904 AND wdtv.organization_id = sub.organization_id
905 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
906 AND moh.header_id(+) = mol.header_id
907 AND Decode(Nvl(moh.move_order_type, -1),
908 2, l_rep_allowed,
909 1, l_mot_moi_allowed,
910 -1, 1,
911 1) = 1
912 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
913 -- bug 4358107
914 AND NOT EXISTS
915 ( SELECT 1
916 FROM WMS_DISPATCH_TASKS_GTMP
917 WHERE (p_task_method = 'DISCRETE'
918 and
919 grouping_document_number = wdtv.pick_slip_number
920 )
921 or
922 (
923 p_task_method = 'ORDERPICK'
924 and
925 grouping_document_number = wdtv.transaction_source_id
926 and
927 grouping_source_type_id = wdtv.transaction_source_type_id
928 )
929 or
930 (p_task_method = 'PICKBYLABEL'
931 and
932 grouping_document_number = wdtv.cartonization_id
933 )
934 or --6598260 start
935 ( grouping_document_number = wdtv.cartonization_id
936 and
937 grouping_document_type = 'CARTON_TASK'
938 ) --6598260 end
939 )
940 -- bug 4358107
941 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
942 (SELECT NULL
943 FROM mtl_material_transactions_temp mmtt
944 WHERE mmtt.transaction_temp_id = wdtv.task_id
945 AND mmtt.parent_line_id IS NOT NULL
946 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
947 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
948 AND NOT EXISTS -- exclude tasks already dispatched and queued
949 (SELECT NULL
950 FROM wms_dispatched_tasks wdt1
951 WHERE wdt1.transaction_temp_id = wdtv.task_id
952 AND wdt1.task_type = wdtv.wms_task_type_id)
953 -- excluded skipped tasks
954 AND wdtv.task_id NOT IN
955 (SELECT wdtv.task_id
956 FROM wms_skip_task_exceptions wste, mtl_parameters mp
957 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
958 AND wste.task_id = wdtv.task_id
959 AND wste.organization_id = mp.organization_id)
960 --J Addition
961 AND wdtv.zone not in (
962 SELECT wd.subinventory_code
963 FROM wms_devices_b wd
964 , wms_bus_event_devices wbed
965 WHERE 1 = 1
966 and wd.device_id = wbed.device_id
967 AND wbed.organization_id = wd.organization_id
968 AND wd.enabled_flag = 'Y'
969 AND wbed.enabled_flag = 'Y'
970 AND wbed.business_event_id = 10
971 AND wd.subinventory_code IS NOT NULL
972 AND wd.force_sign_on_flag = 'Y'
973 AND wd.device_id NOT IN (SELECT device_id
974 FROM wms_device_assignment_temp
975 WHERE employee_id = p_sign_on_emp_id)
976 )
977 ORDER BY
978 task_priority desc,
979 batch_id,
980 task_status DESC,
981 sub_picking_order,
982 loc_picking_order,
983 distance,
984 task_num;
985
986 -- Cursor #3 for selecting the most optimal task
987 -- 1. Sub is passed (1)
988 -- 2. Non cycle count tasks (0)
989 -- 3. Cycle count tasks (1)
990 CURSOR l_curs_opt_task_101 IS
991 SELECT DISTINCT
992 qt.task_id task_num,
993 qt.pick_slip,
994 wdt.task_type wms_task_type_id,
995 nvl(wdt.priority, 0) task_priority,
996 To_number (NULL) batch_id,
997 sub.picking_order sub_picking_order,
998 loc.picking_order loc_picking_order,
999 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1000 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1001 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1002 wdt.status task_status, --bug 4310093
1003 qt.transaction_type_id,
1004 qt.transaction_action_id,
1005 qt.transaction_source_id,
1006 qt.transaction_source_type_id
1007 FROM wms_dispatched_tasks wdt,
1008 (SELECT
1009 MIN(mcce.cycle_count_entry_id) task_id,
1010 TO_NUMBER(NULL) pick_slip,
1011 To_number(NULL) cartonization_id,
1012 mcce.organization_id,
1013 mcce.subinventory subinventory_code,
1014 mcce.locator_id,
1015 To_number(NULL) move_order_line_id,
1016 4 transaction_type_id,
1017 4 transaction_action_id,
1018 mcce.cycle_count_header_id transaction_source_id,
1019 9 transaction_source_type_id
1020 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1021 WHERE mcce.entry_status_code IN(1, 3)
1022 AND NVL(mcce.export_flag, 2) = 2
1023 -- bug 3972076
1024 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1025 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1026 -----bug6903708---
1027
1028 AND mcce.organization_id = mcch.organization_id
1029 AND mcch.organization_id = p_sign_on_org_id
1030
1031 ---------------------------
1032
1033 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1034 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
1035 mtl_secondary_inventories sub,
1036 mtl_item_locations loc,
1037 (SELECT
1038 bsor.standard_operation_id,
1039 bre.resource_id,
1040 bre.inventory_item_id equipment_id
1041 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1042 WHERE bsor.resource_id = bre.resource_id
1043 AND br.resource_type = 1
1044 AND bsor.resource_id = br.resource_id) e
1045 WHERE wdt.transaction_temp_id = qt.task_id
1046 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
1047 AND wdt.person_id = p_sign_on_emp_id
1048 AND wdt.organization_id = p_sign_on_org_id
1049 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1050 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1051 AND wdt.user_task_type = e.standard_operation_id(+)
1052 AND qt.organization_id = sub.organization_id
1053 AND qt.subinventory_code = p_sign_on_zone
1054 AND qt.subinventory_code = sub.secondary_inventory_name
1055 AND qt.organization_id = loc.organization_id
1056 AND qt.locator_id = loc.inventory_location_id
1057 UNION ALL
1058 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
1059 wdtv.task_id task_num,
1060 NVL(wdtv.pick_slip_number, -1) pick_slip,
1061 wdtv.wms_task_type_id,
1062 nvl(wdtv.task_priority, 0),
1063 To_number(NULL) batch_id,
1064 sub.picking_order sub_picking_order,
1065 loc.picking_order loc_picking_order,
1066 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1067 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1068 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1069 task_status,
1070 wdtv.transaction_type_id,
1071 wdtv.transaction_action_id,
1072 wdtv.transaction_source_id,
1073 wdtv.transaction_source_type_id
1074 FROM
1075 -- inlined wms_dispatchable_tasks_v, bug 2648133
1076 (SELECT
1077 MIN(mcce.cycle_count_entry_id) task_id,
1078 MIN(mcce.standard_operation_id) user_task_type_id,
1079 3 wms_task_type_id,
1080 mcce.organization_id,
1081 mcce.subinventory zone,
1082 mcce.locator_id,
1083 MIN(mcce.task_priority) task_priority,
1084 mcce.revision revision,
1085 MIN(mcce.lot_number) lot_number,
1086 '' transaction_uom,
1087 TO_NUMBER(NULL) transaction_quantity,
1088 TO_NUMBER(NULL) pick_rule_id,
1089 TO_NUMBER(NULL) pick_slip_number,
1090 TO_NUMBER(NULL) cartonization_id,
1091 mcce.inventory_item_id,
1092 TO_NUMBER(NULL) move_order_line_id,
1093 1 task_status,
1094 4 transaction_type_id,
1095 4 transaction_action_id,
1096 mcce.cycle_count_header_id transaction_source_id,
1097 9 transaction_source_type_id
1098 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1099 WHERE mcce.entry_status_code IN(1, 3)
1100 AND NVL(mcce.export_flag, 2) = 2
1101 -- bug 3972076
1102 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1103 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1104 -----bug6903708---
1105 AND mcce.organization_id = mcch.organization_id
1106 AND mcch.organization_id = p_sign_on_org_id
1107 ---------------------------
1108
1109 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1110 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
1111 -- inlined wms_person_resource_utt_v, bug 2648133
1112 (SELECT
1113 utt_emp.standard_operation_id standard_operation_id,
1114 utt_emp.resource_id role,
1115 utt_eqp.resource_id equipment,
1116 utt_emp.person_id emp_id,
1117 utt_eqp.inventory_item_id eqp_id,
1118 NULL eqp_srl /* removed for bug 2095237 */
1119 FROM
1120 (SELECT
1121 x_utt_res1.standard_operation_id standard_operation_id,
1122 x_utt_res1.resource_id resource_id,
1123 x_emp_r.person_id
1124 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1125 WHERE x_utt_res1.resource_id = r1.resource_id
1126 AND r1.resource_type = 2
1127 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1128 (SELECT
1129 x_utt_res2.standard_operation_id standard_operation_id,
1130 x_utt_res2.resource_id,
1131 x_eqp_r.inventory_item_id
1132 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1133 WHERE x_utt_res2.resource_id = r2.resource_id
1134 AND r2.resource_type = 1
1135 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1136 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1137 mtl_item_locations loc,
1138 mtl_secondary_inventories sub
1139 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1140 AND wdtv.organization_id = p_sign_on_org_id
1141 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1142 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
1143 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1144 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1145 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1146 AND wdtv.locator_id = loc.inventory_location_id(+)
1147 AND wdtv.zone = sub.secondary_inventory_name
1148 AND wdtv.organization_id = sub.organization_id
1149 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1150 -- bug 4358107
1151 AND NOT EXISTS
1152 ( SELECT 1
1153 FROM WMS_DISPATCH_TASKS_GTMP
1154 WHERE (p_task_method = 'DISCRETE'
1155 and
1156 grouping_document_number = wdtv.pick_slip_number
1157 )
1158 or
1159 (
1160 p_task_method = 'ORDERPICK'
1161 and
1162 grouping_document_number = wdtv.transaction_source_id
1163 and
1164 grouping_source_type_id = wdtv.transaction_source_type_id
1165 )
1166 or
1167 (p_task_method = 'PICKBYLABEL'
1168 and
1169 grouping_document_number = wdtv.cartonization_id
1170 )
1171 )
1172 -- bug 4358107
1173 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1174 (SELECT NULL
1175 FROM mtl_material_transactions_temp mmtt
1176 WHERE mmtt.transaction_temp_id = wdtv.task_id
1177 AND mmtt.parent_line_id IS NOT NULL
1178 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1179 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1180 AND NOT EXISTS -- exclude tasks already dispatched and queued
1181 (SELECT NULL
1182 FROM wms_dispatched_tasks wdt1
1183 WHERE wdt1.transaction_temp_id = wdtv.task_id
1184 AND wdt1.task_type = wdtv.wms_task_type_id)
1185 -- excluded skipped tasks
1186 AND wdtv.task_id NOT IN
1187 (SELECT wdtv.task_id
1188 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1189 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1190 AND wste.task_id = wdtv.task_id
1191 AND wste.organization_id = mp.organization_id)
1192 --J Addition
1193 AND wdtv.zone not in (
1194 SELECT wd.subinventory_code
1195 FROM wms_devices_b wd
1196 , wms_bus_event_devices wbed
1197 WHERE 1 = 1
1198 and wd.device_id = wbed.device_id
1199 AND wbed.organization_id = wd.organization_id
1200 AND wd.enabled_flag = 'Y'
1201 AND wbed.enabled_flag = 'Y'
1202 AND wbed.business_event_id = 10
1203 AND wd.subinventory_code IS NOT NULL
1204 AND wd.force_sign_on_flag = 'Y'
1205 AND wd.device_id NOT IN (SELECT device_id
1206 FROM wms_device_assignment_temp
1207 WHERE employee_id = p_sign_on_emp_id)
1208 )
1209 ORDER BY
1210 task_priority desc,
1211 task_status DESC,
1212 sub_picking_order,
1213 loc_picking_order,
1214 distance,
1215 task_num;
1216
1217 -- Cursor #4 for selecting the most optimal task
1218 -- 1. Sub is not passed (0)
1219 -- 2. Non cycle count tasks (1)
1220 -- 3. Cycle count tasks (1)
1221 CURSOR l_curs_opt_task_011 IS
1222 SELECT DISTINCT
1223 qt.task_id task_num,
1224 qt.pick_slip,
1225 wdt.task_type wms_task_type_id,
1226 nvl(wdt.priority, 0) task_priority,
1227 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1228 sub.picking_order sub_picking_order,
1229 loc.picking_order loc_picking_order,
1230 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1231 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1232 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1233 wdt.status task_status, --bug 4310093
1234 qt.transaction_type_id,
1235 qt.transaction_action_id,
1236 qt.transaction_source_id,
1237 qt.transaction_source_type_id
1238 FROM wms_dispatched_tasks wdt,
1239 (SELECT
1240 transaction_temp_id task_id,
1241 pick_slip_number pick_slip,
1242 cartonization_id,
1243 organization_id,
1244 subinventory_code,
1245 locator_id,
1246 move_order_line_id,
1247 transaction_type_id,
1248 transaction_action_id,
1249 transaction_source_id,
1250 transaction_source_type_id
1251 FROM mtl_material_transactions_temp mmtt
1252 WHERE wms_task_type IS NOT NULL
1253 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1254 parent_line_id, transaction_temp_id)
1255 AND Decode(transaction_source_type_id,
1256 2, l_so_allowed,
1257 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1258 5, Decode(transaction_type_id, 35, l_wip_allowed),
1259 8, l_io_allowed,
1260 13, Decode(transaction_type_id,
1261 51, l_wip_allowed,
1262 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1263 --7169220: USERS LOCKED
1264 AND (mmtt.cartonization_id is null
1265 or not exists
1266 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1267 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1268 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1269 and wdt1.status = 9
1270 and mmtt1.cartonization_id = mmtt.cartonization_id)
1271 )
1272
1273 UNION ALL
1274 SELECT
1275 MIN(mcce.cycle_count_entry_id) task_id,
1276 TO_NUMBER(NULL) pick_slip,
1277 To_number(NULL) cartonization_id,
1278 mcce.organization_id,
1279 mcce.subinventory subinventory_code,
1280 mcce.locator_id,
1281 To_number(NULL) move_order_line_id,
1282 4 transaction_type_id,
1283 4 transaction_action_id,
1284 mcce.cycle_count_header_id transaction_source_id,
1285 9 transaction_source_type_id
1286 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1287 WHERE mcce.entry_status_code IN(1, 3)
1288 AND NVL(mcce.export_flag, 2) = 2
1289 -- bug 3972076
1290 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1291 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1292 -----bug6903708---
1293 AND mcce.organization_id = mcch.organization_id
1294 AND mcch.organization_id = p_sign_on_org_id
1295 ---------------------------
1296 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1297 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
1298 mtl_txn_request_lines mol,
1299 mtl_secondary_inventories sub,
1300 mtl_item_locations loc,
1301 (SELECT
1302 bsor.standard_operation_id,
1303 bre.resource_id,
1304 bre.inventory_item_id equipment_id
1305 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1306 WHERE bsor.resource_id = bre.resource_id
1307 AND br.resource_type = 1
1308 AND bsor.resource_id = br.resource_id) e
1309 WHERE wdt.transaction_temp_id = qt.task_id
1310 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
1311 AND wdt.person_id = p_sign_on_emp_id
1312 AND wdt.organization_id = p_sign_on_org_id
1313 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1314 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1315 AND wdt.user_task_type = e.standard_operation_id(+)
1316 AND qt.move_order_line_id = mol.line_id(+)
1317 AND qt.organization_id = sub.organization_id
1318 AND qt.subinventory_code = sub.secondary_inventory_name
1319 AND qt.organization_id = loc.organization_id
1320 AND qt.locator_id = loc.inventory_location_id
1321 UNION ALL
1322 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
1323 wdtv.task_id task_num,
1324 NVL(wdtv.pick_slip_number, -1) pick_slip,
1325 wdtv.wms_task_type_id,
1326 nvl(wdtv.task_priority, 0),
1327 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1328 sub.picking_order sub_picking_order,
1329 loc.picking_order loc_picking_order,
1330 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1331 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1332 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1333 task_status,
1334 wdtv.transaction_type_id,
1335 wdtv.transaction_action_id,
1336 wdtv.transaction_source_id,
1337 wdtv.transaction_source_type_id
1338 FROM
1339 -- inlined wms_dispatchable_tasks_v, bug 2648133
1340 (SELECT
1341 transaction_temp_id task_id,
1342 standard_operation_id user_task_type_id,
1343 wms_task_type wms_task_type_id,
1344 organization_id,
1345 subinventory_code zone,
1346 locator_id,
1347 task_priority,
1348 revision,
1349 lot_number,
1350 transaction_uom,
1351 transaction_quantity,
1352 pick_rule_id,
1353 pick_slip_number,
1354 cartonization_id,
1355 inventory_item_id,
1356 move_order_line_id,
1357 1 task_status,
1358 transaction_type_id,
1359 transaction_action_id,
1360 transaction_source_id,
1361 transaction_source_type_id
1362 FROM mtl_material_transactions_temp mmtt
1363 WHERE wms_task_type IS NOT NULL
1364 AND transaction_status = 2
1365 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
1366 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1367 parent_line_id, transaction_temp_id)
1368 AND Decode(transaction_source_type_id,
1369 2, l_so_allowed,
1370 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1371 5, Decode(transaction_type_id, 35, l_wip_allowed),
1372 8, l_io_allowed,
1373 13, Decode(transaction_type_id,
1374 51, l_wip_allowed,
1375 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1376 --7169220: USERS LOCKED
1377 AND (mmtt.cartonization_id is null
1378 or not exists
1379 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1380 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1381 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1382 and wdt1.status = 9
1383 and mmtt1.cartonization_id = mmtt.cartonization_id)
1384 )
1385
1386 UNION ALL
1387 SELECT
1388 MIN(mcce.cycle_count_entry_id) task_id,
1389 MIN(mcce.standard_operation_id) user_task_type_id,
1390 3 wms_task_type_id,
1391 mcce.organization_id,
1392 mcce.subinventory zone,
1393 mcce.locator_id,
1394 MIN(mcce.task_priority) task_priority,
1395 mcce.revision revision,
1396 MIN(mcce.lot_number) lot_number,
1397 '' transaction_uom,
1398 TO_NUMBER(NULL) transaction_quantity,
1399 TO_NUMBER(NULL) pick_rule_id,
1400 TO_NUMBER(NULL) pick_slip_number,
1401 TO_NUMBER(NULL) cartonization_id,
1402 mcce.inventory_item_id,
1403 TO_NUMBER(NULL) move_order_line_id,
1404 1 task_status,
1405 4 transaction_type_id,
1406 4 transaction_action_id,
1407 mcce.cycle_count_header_id transaction_source_id,
1408 9 transaction_source_type_id
1409 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1410 WHERE mcce.entry_status_code IN(1, 3)
1411 AND NVL(mcce.export_flag, 2) = 2
1412 -- bug 3972076
1413 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1414 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1415 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1416
1417 -----bug6903708---
1418 AND mcce.organization_id = mcch.organization_id
1419 AND mcch.organization_id = p_sign_on_org_id
1420 ---------------------------
1421
1422 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
1423 -- inlined wms_person_resource_utt_v, bug 2648133
1424 (SELECT
1425 utt_emp.standard_operation_id standard_operation_id,
1426 utt_emp.resource_id role,
1427 utt_eqp.resource_id equipment,
1428 utt_emp.person_id emp_id,
1429 utt_eqp.inventory_item_id eqp_id,
1430 NULL eqp_srl /* removed for bug 2095237 */
1431 FROM
1432 (SELECT
1433 x_utt_res1.standard_operation_id standard_operation_id,
1434 x_utt_res1.resource_id resource_id,
1435 x_emp_r.person_id
1436 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1437 WHERE x_utt_res1.resource_id = r1.resource_id
1438 AND r1.resource_type = 2
1439 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1440 (SELECT
1441 x_utt_res2.standard_operation_id standard_operation_id,
1442 x_utt_res2.resource_id,
1443 x_eqp_r.inventory_item_id
1444 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1445 WHERE x_utt_res2.resource_id = r2.resource_id
1446 AND r2.resource_type = 1
1447 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1448 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1449 mtl_item_locations loc,
1450 mtl_secondary_inventories sub,
1451 mtl_txn_request_lines mol,
1452 mtl_txn_request_headers moh
1453 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1454 AND wdtv.organization_id = p_sign_on_org_id
1455 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1456 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1457 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1458 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1459 AND wdtv.locator_id = loc.inventory_location_id(+)
1460 AND wdtv.zone = sub.secondary_inventory_name
1461 AND wdtv.organization_id = sub.organization_id
1462 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
1463 AND moh.header_id(+) = mol.header_id
1464 AND Decode(Nvl(moh.move_order_type, -1),
1465 2, l_rep_allowed,
1466 1, l_mot_moi_allowed,
1467 -1, 1,
1468 1) = 1
1469 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1470 -- bug 4358107
1471 AND NOT EXISTS
1472 ( SELECT 1
1473 FROM WMS_DISPATCH_TASKS_GTMP
1474 WHERE (p_task_method = 'DISCRETE'
1475 and
1476 grouping_document_number = wdtv.pick_slip_number
1477 )
1478 or
1479 (
1480 p_task_method = 'ORDERPICK'
1481 and
1482 grouping_document_number = wdtv.transaction_source_id
1483 and
1484 grouping_source_type_id = wdtv.transaction_source_type_id
1485 )
1486 or
1487 (p_task_method = 'PICKBYLABEL'
1488 and
1489 grouping_document_number = wdtv.cartonization_id
1490 )
1491 or --6598260 start
1492 ( grouping_document_number = wdtv.cartonization_id
1493 and
1494 grouping_document_type = 'CARTON_TASK'
1495 ) --6598260 end
1496 )
1497 -- bug 4358107
1498 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1499 (SELECT NULL
1500 FROM mtl_material_transactions_temp mmtt
1501 WHERE mmtt.transaction_temp_id = wdtv.task_id
1502 AND mmtt.parent_line_id IS NOT NULL
1503 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1504 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1505 AND NOT EXISTS -- exclude tasks already dispatched and queued
1506 (SELECT NULL
1507 FROM wms_dispatched_tasks wdt1
1508 WHERE wdt1.transaction_temp_id = wdtv.task_id
1509 AND wdt1.task_type = wdtv.wms_task_type_id)
1510 -- excluded skipped tasks
1511 AND wdtv.task_id NOT IN
1512 (SELECT wdtv.task_id
1513 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1514 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1515 AND wste.task_id = wdtv.task_id
1516 AND wste.organization_id = mp.organization_id)
1517 --J Addition
1518 AND wdtv.zone not in (
1519 SELECT wd.subinventory_code
1520 FROM wms_devices_b wd
1521 , wms_bus_event_devices wbed
1522 WHERE 1 = 1
1523 and wd.device_id = wbed.device_id
1524 AND wbed.organization_id = wd.organization_id
1525 AND wd.enabled_flag = 'Y'
1526 AND wbed.enabled_flag = 'Y'
1527 AND wbed.business_event_id = 10
1528 AND wd.subinventory_code IS NOT NULL
1529 AND wd.force_sign_on_flag = 'Y'
1530 AND wd.device_id NOT IN (SELECT device_id
1531 FROM wms_device_assignment_temp
1532 WHERE employee_id = p_sign_on_emp_id)
1533 )
1534
1535 ORDER BY
1536 task_priority desc,
1537 batch_id,
1538 task_status DESC,
1539 sub_picking_order,
1540 loc_picking_order,
1541 distance,
1542 task_num;
1543
1544 -- Cursor #5 for selecting the most optimal task
1545 -- 1. Sub is not passed (0)
1546 -- 2. Non cycle count tasks (1)
1547 -- 3. Cycle count tasks (0)
1548 CURSOR l_curs_opt_task_010 IS
1549 SELECT DISTINCT
1550 qt.task_id task_num,
1551 qt.pick_slip,
1552 wdt.task_type wms_task_type_id,
1553 nvl(wdt.priority, 0) task_priority,
1554 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1555 sub.picking_order sub_picking_order,
1556 loc.picking_order loc_picking_order,
1557 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1558 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1559 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1560 wdt.status task_status, --bug 4310093
1561 qt.transaction_type_id,
1562 qt.transaction_action_id,
1563 qt.transaction_source_id,
1564 qt.transaction_source_type_id
1565 FROM wms_dispatched_tasks wdt,
1566 (SELECT
1567 transaction_temp_id task_id,
1568 pick_slip_number pick_slip,
1569 cartonization_id,
1570 organization_id,
1571 subinventory_code,
1572 locator_id,
1573 move_order_line_id,
1574 transaction_type_id,
1575 transaction_action_id,
1576 transaction_source_id,
1577 transaction_source_type_id
1578 FROM mtl_material_transactions_temp mmtt
1579 WHERE wms_task_type IS NOT NULL
1580 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1581 parent_line_id, transaction_temp_id)
1582 AND Decode(transaction_source_type_id,
1583 2, l_so_allowed,
1584 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1585 5, Decode(transaction_type_id, 35, l_wip_allowed),
1586 8, l_io_allowed,
1587 13, Decode(transaction_type_id,
1588 51, l_wip_allowed,
1589 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1590 --7169220: USERS LOCKED
1591 AND (mmtt.cartonization_id is null
1592 or not exists
1593 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1594 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1595 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1596 and wdt1.status = 9
1597 and mmtt1.cartonization_id = mmtt.cartonization_id)
1598 )
1599 ) qt,
1600 mtl_txn_request_lines mol,
1601 mtl_secondary_inventories sub,
1602 mtl_item_locations loc,
1603 (SELECT
1604 bsor.standard_operation_id,
1605 bre.resource_id,
1606 bre.inventory_item_id equipment_id
1607 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1608 WHERE bsor.resource_id = bre.resource_id
1609 AND br.resource_type = 1
1610 AND bsor.resource_id = br.resource_id) e
1611 WHERE wdt.transaction_temp_id = qt.task_id
1612 AND wdt.status = 2 -- bug 6326482 queued tasks only-- Queued and dispatched tasks only bug 4310093
1613 AND wdt.person_id = p_sign_on_emp_id
1614 AND wdt.organization_id = p_sign_on_org_id
1615 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1616 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))
1617 AND wdt.user_task_type = e.standard_operation_id(+)
1618 AND qt.move_order_line_id = mol.line_id(+)
1619 AND qt.organization_id = sub.organization_id
1620 AND qt.subinventory_code = sub.secondary_inventory_name
1621 AND qt.organization_id = loc.organization_id
1622 AND qt.locator_id = loc.inventory_location_id
1623 UNION ALL
1624 --bug 6326482 for dispatched tasks
1625 SELECT DISTINCT
1626 qt.task_id task_num,
1627 qt.pick_slip,
1628 wdt.task_type wms_task_type_id,
1629 nvl(wdt.priority, 0) task_priority,
1630 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1631 sub.picking_order sub_picking_order,
1632 loc.picking_order loc_picking_order,
1633 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1634 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1635 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1636 wdt.status task_status,
1637 qt.transaction_type_id,
1638 qt.transaction_action_id,
1639 qt.transaction_source_id,
1640 qt.transaction_source_type_id
1641 FROM wms_dispatched_tasks wdt,
1642 (SELECT
1643 transaction_temp_id task_id,
1644 wms_task_status task_status, -- bug 6326482 added to get the previous state of dispatched tasks
1645 pick_slip_number pick_slip,
1646 cartonization_id,
1647 organization_id,
1648 subinventory_code,
1649 locator_id,
1650 move_order_line_id,
1651 transaction_type_id,
1652 transaction_action_id,
1653 transaction_source_id,
1654 transaction_source_type_id
1655 FROM mtl_material_transactions_temp mmtt
1656 WHERE wms_task_type IS NOT NULL
1657 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1658 parent_line_id, transaction_temp_id)
1659 AND Decode(transaction_source_type_id,
1660 2, l_so_allowed,
1661 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
1662 5, Decode(transaction_type_id, 35, l_wip_allowed),
1663 8, l_io_allowed,
1664 13, Decode(transaction_type_id,
1665 51, l_wip_allowed,
1666 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1667 --7169220: USERS LOCKED
1668 AND (mmtt.cartonization_id is null
1669 or not exists
1670 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1671 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1672 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1673 and wdt1.status = 9
1674 and mmtt1.cartonization_id = mmtt.cartonization_id)
1675 )
1676 ) qt,
1677 mtl_txn_request_lines mol,
1678 mtl_secondary_inventories sub,
1679 mtl_item_locations loc,
1680 (SELECT
1681 bsor.standard_operation_id,
1682 bre.resource_id,
1683 bre.inventory_item_id equipment_id
1684 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1685 WHERE bsor.resource_id = bre.resource_id
1686 AND br.resource_type = 1
1687 AND bsor.resource_id = br.resource_id) e
1688 WHERE wdt.transaction_temp_id = qt.task_id
1689 AND wdt.status =3 -- bug 6326482 dispatched tasks only
1690 AND wdt.person_id = p_sign_on_emp_id
1691 AND wdt.organization_id = p_sign_on_org_id
1692 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1693 --bug 6326482
1694 AND ((qt.task_status is NULL
1695 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
1696 or
1697 (qt.task_status = 1
1698 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
1699 AND wdt.user_task_type = e.standard_operation_id(+)
1700 AND qt.move_order_line_id = mol.line_id(+)
1701 AND qt.organization_id = sub.organization_id
1702 AND qt.subinventory_code = sub.secondary_inventory_name
1703 AND qt.organization_id = loc.organization_id
1704 AND qt.locator_id = loc.inventory_location_id
1705 UNION ALL
1706 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
1707 wdtv.task_id task_num,
1708 NVL(wdtv.pick_slip_number, -1) pick_slip,
1709 wdtv.wms_task_type_id,
1710 nvl(wdtv.task_priority, 0),
1711 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1712 sub.picking_order sub_picking_order,
1713 loc.picking_order loc_picking_order,
1714 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1715 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1716 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1717 task_status,
1718 wdtv.transaction_type_id,
1719 wdtv.transaction_action_id,
1720 wdtv.transaction_source_id,
1721 wdtv.transaction_source_type_id
1722 FROM
1723 -- inlined wms_dispatchable_tasks_v, bug 2648133
1724 (SELECT
1725 transaction_temp_id task_id,
1726 standard_operation_id user_task_type_id,
1727 wms_task_type wms_task_type_id,
1728 organization_id,
1729 subinventory_code zone,
1730 locator_id,
1731 task_priority,
1732 revision,
1733 lot_number,
1734 transaction_uom,
1735 transaction_quantity,
1736 pick_rule_id,
1737 pick_slip_number,
1738 cartonization_id,
1739 inventory_item_id,
1740 move_order_line_id,
1741 1 task_status,
1742 transaction_type_id,
1743 transaction_action_id,
1744 transaction_source_id,
1745 transaction_source_type_id
1746 FROM mtl_material_transactions_temp mmtt
1747 WHERE wms_task_type IS NOT NULL
1748 AND transaction_status = 2
1749 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
1750 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1751 parent_line_id, transaction_temp_id)
1752 AND Decode(transaction_source_type_id,
1753 2, l_so_allowed,
1754 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1755 5, Decode(transaction_type_id, 35, l_wip_allowed),
1756 8, l_io_allowed,
1757 13, Decode(transaction_type_id,
1758 51, l_wip_allowed,
1759 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1760 --7169220: USERS LOCKED
1761 AND (mmtt.cartonization_id is null
1762 or not exists
1763 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1764 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1765 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1766 and wdt1.status = 9
1767 and mmtt1.cartonization_id = mmtt.cartonization_id)
1768 )
1769 ) wdtv,
1770 -- inlined wms_person_resource_utt_v, bug 2648133
1771 (SELECT
1772 utt_emp.standard_operation_id standard_operation_id,
1773 utt_emp.resource_id role,
1774 utt_eqp.resource_id equipment,
1775 utt_emp.person_id emp_id,
1776 utt_eqp.inventory_item_id eqp_id,
1777 NULL eqp_srl /* removed for bug 2095237 */
1778 FROM
1779 (SELECT
1780 x_utt_res1.standard_operation_id standard_operation_id,
1781 x_utt_res1.resource_id resource_id,
1782 x_emp_r.person_id
1783 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1784 WHERE x_utt_res1.resource_id = r1.resource_id
1785 AND r1.resource_type = 2
1786 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1787 (SELECT
1788 x_utt_res2.standard_operation_id standard_operation_id,
1789 x_utt_res2.resource_id,
1790 x_eqp_r.inventory_item_id
1791 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1792 WHERE x_utt_res2.resource_id = r2.resource_id
1793 AND r2.resource_type = 1
1794 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1795 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1796 mtl_item_locations loc,
1797 mtl_secondary_inventories sub,
1798 mtl_txn_request_lines mol,
1799 mtl_txn_request_headers moh
1800 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1801 AND wdtv.organization_id = p_sign_on_org_id
1802 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1803 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1804 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1805 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1806 AND wdtv.locator_id = loc.inventory_location_id(+)
1807 AND wdtv.zone = sub.secondary_inventory_name
1808 AND wdtv.organization_id = sub.organization_id
1809 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
1810 AND moh.header_id(+) = mol.header_id
1811 AND Decode(Nvl(moh.move_order_type, -1),
1812 2, l_rep_allowed,
1813 1, l_mot_moi_allowed,
1814 -1, 1,
1815 1) = 1
1816 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1817 -- bug 4358107
1818 AND NOT EXISTS
1819 ( SELECT 1
1820 FROM WMS_DISPATCH_TASKS_GTMP
1821 WHERE (p_task_method = 'DISCRETE'
1822 and
1823 grouping_document_number = wdtv.pick_slip_number
1824 )
1825 or
1826 (
1827 p_task_method = 'ORDERPICK'
1828 and
1829 grouping_document_number = wdtv.transaction_source_id
1830 and
1831 grouping_source_type_id = wdtv.transaction_source_type_id
1832 )
1833 or
1834 (p_task_method = 'PICKBYLABEL'
1835 and
1836 grouping_document_number = wdtv.cartonization_id
1837 )
1838 or --6598260 start
1839 ( grouping_document_number = wdtv.cartonization_id
1840 and
1841 grouping_document_type = 'CARTON_TASK'
1842 ) --6598260 end
1843 )
1844 -- bug 4358107
1845 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1846 (SELECT NULL
1847 FROM mtl_material_transactions_temp mmtt
1848 WHERE mmtt.transaction_temp_id = wdtv.task_id
1849 AND mmtt.parent_line_id IS NOT NULL
1850 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1851 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1852 AND NOT EXISTS -- exclude tasks already dispatched and queued
1853 (SELECT NULL
1854 FROM wms_dispatched_tasks wdt1
1855 WHERE wdt1.transaction_temp_id = wdtv.task_id
1856 AND wdt1.task_type = wdtv.wms_task_type_id)
1857 -- excluded skipped tasks
1858 AND wdtv.task_id NOT IN
1859 (SELECT wdtv.task_id
1860 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1861 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1862 AND wste.task_id = wdtv.task_id
1863 AND wste.organization_id = mp.organization_id)
1864 --J Addition
1865 AND wdtv.zone not in (
1866 SELECT wd.subinventory_code
1867 FROM wms_devices_b wd
1868 , wms_bus_event_devices wbed
1869 WHERE 1 = 1
1870 and wd.device_id = wbed.device_id
1871 AND wbed.organization_id = wd.organization_id
1872 AND wd.enabled_flag = 'Y'
1873 AND wbed.enabled_flag = 'Y'
1874 AND wbed.business_event_id = 10
1875 AND wd.subinventory_code IS NOT NULL
1876 AND wd.force_sign_on_flag = 'Y'
1877 AND wd.device_id NOT IN (SELECT device_id
1878 FROM wms_device_assignment_temp
1879 WHERE employee_id = p_sign_on_emp_id)
1880 )
1881 ORDER BY
1882 task_priority desc,
1883 batch_id,
1884 task_status DESC,
1885 sub_picking_order,
1886 loc_picking_order,
1887 distance,
1888 task_num;
1889
1890 -- Cursor #6 for selecting the most optimal task
1891 -- 1. Sub is not passed (0)
1892 -- 2. Non cycle count tasks (0)
1893 -- 3. Cycle count tasks (1)
1894 CURSOR l_curs_opt_task_001 IS
1895 SELECT DISTINCT
1896 qt.task_id task_num,
1897 qt.pick_slip,
1898 wdt.task_type wms_task_type_id,
1899 nvl(wdt.priority, 0) task_priority,
1900 To_number (NULL) batch_id,
1901 sub.picking_order sub_picking_order,
1902 loc.picking_order loc_picking_order,
1903 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1904 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1905 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1906 wdt.status task_status, --bug 4310093
1907 qt.transaction_type_id,
1908 qt.transaction_action_id,
1909 qt.transaction_source_id,
1910 qt.transaction_source_type_id
1911 FROM wms_dispatched_tasks wdt,
1912 (SELECT
1913 MIN(mcce.cycle_count_entry_id) task_id,
1914 TO_NUMBER(NULL) pick_slip,
1915 To_number(NULL) cartonization_id,
1916 mcce.organization_id,
1917 mcce.subinventory subinventory_code,
1918 mcce.locator_id,
1919 To_number(NULL) move_order_line_id,
1920 4 transaction_type_id,
1921 4 transaction_action_id,
1922 mcce.cycle_count_header_id transaction_source_id,
1923 9 transaction_source_type_id
1924 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1925 WHERE mcce.entry_status_code IN(1, 3)
1926 AND NVL(mcce.export_flag, 2) = 2
1927 -- bug 3972076
1928 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1929 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1930 AND mcce.organization_id = mcch.organization_id -- Bug 13796753
1931 AND mcch.organization_id = p_sign_on_org_id -- Bug 13796753
1932 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1933 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
1934 mtl_secondary_inventories sub,
1935 mtl_item_locations loc,
1936 (SELECT
1937 bsor.standard_operation_id,
1938 bre.resource_id,
1939 bre.inventory_item_id equipment_id
1940 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1941 WHERE bsor.resource_id = bre.resource_id
1942 AND br.resource_type = 1
1943 AND bsor.resource_id = br.resource_id) e
1944 WHERE wdt.transaction_temp_id = qt.task_id
1945 AND wdt.status in (2,3) -- Queued and dispatched tasks only bug 4310093
1946 AND wdt.person_id = p_sign_on_emp_id
1947 AND wdt.organization_id = p_sign_on_org_id
1948 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1949 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1950 AND wdt.user_task_type = e.standard_operation_id(+)
1951 AND qt.organization_id = sub.organization_id
1952 AND qt.subinventory_code = sub.secondary_inventory_name
1953 AND qt.organization_id = loc.organization_id
1954 AND qt.locator_id = loc.inventory_location_id
1955 UNION ALL
1956 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
1957 wdtv.task_id task_num,
1958 NVL(wdtv.pick_slip_number, -1) pick_slip,
1959 wdtv.wms_task_type_id,
1960 nvl(wdtv.task_priority, 0),
1961 To_number(NULL) batch_id,
1962 sub.picking_order sub_picking_order,
1963 loc.picking_order loc_picking_order,
1964 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1965 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1966 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1967 task_status,
1968 wdtv.transaction_type_id,
1969 wdtv.transaction_action_id,
1970 wdtv.transaction_source_id,
1971 wdtv.transaction_source_type_id
1972 FROM
1973 -- inlined wms_dispatchable_tasks_v, bug 2648133
1974 (SELECT
1975 MIN(mcce.cycle_count_entry_id) task_id,
1976 MIN(mcce.standard_operation_id) user_task_type_id,
1977 3 wms_task_type_id,
1978 mcce.organization_id,
1979 mcce.subinventory zone,
1980 mcce.locator_id,
1981 MIN(mcce.task_priority) task_priority,
1982 mcce.revision revision,
1983 MIN(mcce.lot_number) lot_number,
1984 '' transaction_uom,
1985 TO_NUMBER(NULL) transaction_quantity,
1986 TO_NUMBER(NULL) pick_rule_id,
1987 TO_NUMBER(NULL) pick_slip_number,
1988 TO_NUMBER(NULL) cartonization_id,
1989 mcce.inventory_item_id,
1990 TO_NUMBER(NULL) move_order_line_id,
1991 1 task_status,
1992 4 transaction_type_id,
1993 4 transaction_action_id,
1994 mcce.cycle_count_header_id transaction_source_id,
1995 9 transaction_source_type_id
1996 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1997 WHERE mcce.entry_status_code IN(1, 3)
1998 AND NVL(mcce.export_flag, 2) = 2
1999 -- bug 3972076
2000 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2001 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2002
2003 -----bug6903708---
2004 AND mcce.organization_id = mcch.organization_id
2005 AND mcch.organization_id = p_sign_on_org_id
2006 ---------------------------
2007
2008 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2009 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
2010 -- inlined wms_person_resource_utt_v, bug 2648133
2011 (SELECT
2012 utt_emp.standard_operation_id standard_operation_id,
2013 utt_emp.resource_id role,
2014 utt_eqp.resource_id equipment,
2015 utt_emp.person_id emp_id,
2016 utt_eqp.inventory_item_id eqp_id,
2017 NULL eqp_srl /* removed for bug 2095237 */
2018 FROM
2019 (SELECT
2020 x_utt_res1.standard_operation_id standard_operation_id,
2021 x_utt_res1.resource_id resource_id,
2022 x_emp_r.person_id
2023 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
2024 WHERE x_utt_res1.resource_id = r1.resource_id
2025 AND r1.resource_type = 2
2026 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
2027 (SELECT
2028 x_utt_res2.standard_operation_id standard_operation_id,
2029 x_utt_res2.resource_id,
2030 x_eqp_r.inventory_item_id
2031 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
2032 WHERE x_utt_res2.resource_id = r2.resource_id
2033 AND r2.resource_type = 1
2034 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
2035 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
2036 mtl_item_locations loc,
2037 mtl_secondary_inventories sub
2038 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
2039 AND wdtv.organization_id = p_sign_on_org_id
2040 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2041 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
2042 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
2043 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2044 AND wdtv.locator_id = loc.inventory_location_id(+)
2045 AND wdtv.zone = sub.secondary_inventory_name
2046 AND wdtv.organization_id = sub.organization_id
2047 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
2048 -- bug 4358107
2049 AND NOT EXISTS
2050 ( SELECT 1
2051 FROM WMS_DISPATCH_TASKS_GTMP
2052 WHERE (p_task_method = 'DISCRETE'
2053 and
2054 grouping_document_number = wdtv.pick_slip_number
2055 )
2056 or
2057 (
2058 p_task_method = 'ORDERPICK'
2059 and
2060 grouping_document_number = wdtv.transaction_source_id
2061 and
2062 grouping_source_type_id = wdtv.transaction_source_type_id
2063 )
2064 or
2065 (p_task_method = 'PICKBYLABEL'
2066 and
2067 grouping_document_number = wdtv.cartonization_id
2068 )
2069 )
2070 -- bug 4358107
2071 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2072 (SELECT NULL
2073 FROM mtl_material_transactions_temp mmtt
2074 WHERE mmtt.transaction_temp_id = wdtv.task_id
2075 AND mmtt.parent_line_id IS NOT NULL
2076 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2077 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2078 AND NOT EXISTS -- exclude tasks already dispatched and queued
2079 (SELECT NULL
2080 FROM wms_dispatched_tasks wdt1
2081 WHERE wdt1.transaction_temp_id = wdtv.task_id
2082 AND wdt1.task_type = wdtv.wms_task_type_id)
2083 -- excluded skipped tasks
2084 AND wdtv.task_id NOT IN
2085 (SELECT wdtv.task_id
2086 FROM wms_skip_task_exceptions wste, mtl_parameters mp
2087 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
2088 AND wste.task_id = wdtv.task_id
2089 AND wste.organization_id = mp.organization_id)
2090 --J Addition
2091 AND wdtv.zone not in (
2092 SELECT wd.subinventory_code
2093 FROM wms_devices_b wd
2094 , wms_bus_event_devices wbed
2095 WHERE 1 = 1
2096 and wd.device_id = wbed.device_id
2097 AND wbed.organization_id = wd.organization_id
2098 AND wd.enabled_flag = 'Y'
2099 AND wbed.enabled_flag = 'Y'
2100 AND wbed.business_event_id = 10
2101 AND wd.subinventory_code IS NOT NULL
2102 AND wd.force_sign_on_flag = 'Y'
2103 AND wd.device_id NOT IN (SELECT device_id
2104 FROM wms_device_assignment_temp
2105 WHERE employee_id = p_sign_on_emp_id)
2106 )
2107 ORDER BY
2108 task_priority desc,
2109 task_status DESC,
2110 sub_picking_order,
2111 loc_picking_order,
2112 distance,
2113 task_num;
2114
2115
2116 -- Cursor #1 for selecting the ordered tasks
2117 -- 1. Non cycle count tasks (1)
2118 -- 2. Cycle count tasks (1)
2119 CURSOR l_curs_ordered_tasks_11(v_pick_slip_number NUMBER,
2120 v_task_id NUMBER,
2121 v_task_type NUMBER,
2122 v_transaction_source_id NUMBER) IS
2123 SELECT DISTINCT
2124 qt.task_id task_num,
2125 qt.subinventory_code,
2126 qt.locator_id,
2127 qt.pick_slip,
2128 qt.transaction_uom,
2129 qt.transaction_quantity,
2130 qt.lot_number,
2131 qt.operation_plan_id,
2132 qt.standard_operation_id,
2133 wdt.effective_start_date,
2134 wdt.effective_end_date,
2135 wdt.person_resource_id,
2136 wdt.machine_resource_id,
2137 wdt.task_type wms_task_type_id,
2138 nvl(wdt.priority, 0) task_priority,
2139 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2140 mol.line_id,
2141 sub.picking_order sub_picking_order,
2142 loc.picking_order loc_picking_order,
2143 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2144 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2145 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2146 wdt.status task_status, --bug 4310093
2147 qt.transaction_type_id,
2148 qt.transaction_action_id,
2149 qt.transaction_source_id,
2150 qt.transaction_source_type_id
2151 FROM wms_dispatched_tasks wdt,
2152 (SELECT
2153 transaction_temp_id task_id,
2154 pick_slip_number pick_slip,
2155 cartonization_id,
2156 organization_id,
2157 subinventory_code,
2158 locator_id,
2159 inventory_item_id,
2160 revision,
2161 transaction_uom,
2162 transaction_quantity,
2163 lot_number,
2164 operation_plan_id,
2165 standard_operation_id,
2166 move_order_line_id,
2167 transaction_type_id,
2168 transaction_action_id,
2169 transaction_source_id,
2170 transaction_source_type_id,
2171 parent_line_id --Added for Case Picking Project (Bulk Task check)
2172 FROM mtl_material_transactions_temp mmtt
2173 WHERE wms_task_type IS NOT NULL
2174 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2175 parent_line_id, transaction_temp_id)
2176 AND Decode(transaction_source_type_id,
2177 2, l_so_allowed,
2178 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2179 5, Decode(transaction_type_id, 35, l_wip_allowed),
2180 8, l_io_allowed,
2181 13, Decode(transaction_type_id,
2182 51, l_wip_allowed,
2183 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2184 --7169220: USERS LOCKED
2185 AND (mmtt.cartonization_id is null
2186 or not exists
2187 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2188 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2189 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2190 and wdt1.status = 9
2191 and mmtt1.cartonization_id = mmtt.cartonization_id)
2192 )
2193
2194
2195 UNION ALL
2196 SELECT
2197 MIN(mcce.cycle_count_entry_id) task_id,
2198 TO_NUMBER(NULL) pick_slip,
2199 To_number(NULL) cartonization_id,
2200 mcce.organization_id,
2201 mcce.subinventory subinventory_code,
2202 mcce.locator_id,
2203 mcce.inventory_item_id,
2204 mcce.revision,
2205 To_char(NULL) transaction_uom,
2206 To_number(NULL) transaction_quantity,
2207 MIN(mcce.lot_number) lot_number,
2208 To_number(NULL) operation_plan_id,
2209 MIN(mcce.standard_operation_id) standard_operation_id,
2210 To_number(NULL) move_order_line_id,
2211 4 transaction_type_id,
2212 4 transaction_action_id,
2213 mcce.cycle_count_header_id transaction_source_id,
2214 9 transaction_source_type_id,
2215 TO_NUMBER(NULL) parent_line_id --Added for Case Picking Project (Bulk Task check)
2216 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
2217 WHERE mcce.entry_status_code IN(1, 3)
2218 AND NVL(mcce.export_flag, 2) = 2
2219 -- bug 3972076
2220 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2221 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2222
2223 -----bug6903708---
2224 AND mcce.organization_id = mcch.organization_id
2225 AND mcch.organization_id = p_sign_on_org_id
2226 ---------------------------
2227
2228 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2229 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
2230 mtl_txn_request_lines mol,
2231 mtl_secondary_inventories sub,
2232 mtl_item_locations loc,
2233 (SELECT
2234 bsor.standard_operation_id,
2235 bre.resource_id,
2236 bre.inventory_item_id equipment_id
2237 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2238 WHERE bsor.resource_id = bre.resource_id
2239 AND br.resource_type = 1
2240 AND bsor.resource_id = br.resource_id) e
2241 WHERE wdt.transaction_temp_id = qt.task_id
2242 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
2243 AND wdt.person_id = p_sign_on_emp_id
2244 AND wdt.organization_id = p_sign_on_org_id
2245 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2246 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2247 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2248 OR (p_task_method = 'ORDERPICK'
2249 AND Decode(qt.transaction_source_type_id,
2250 2, qt.transaction_source_id,
2251 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2252 8, qt.transaction_source_id,
2253 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2254 -1) = nvl(v_transaction_source_id, -1))
2255 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2256 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2257 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id)))
2258 --Added for Case Picking Project start
2259 OR ( p_task_method = 'MANIFESTORDER' AND
2260 qt.transaction_source_id IN (
2261 SELECT MMTT.TRANSACTION_SOURCE_ID
2262 FROM MTL_SALES_ORDERS MSO ,
2263 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
2264 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
2265 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
2266 )
2267 and qt.parent_line_id IS NULL -- Added for bulk task
2268 )
2269 OR (p_task_method = 'MANIFESTPICKSLIP'
2270 AND qt.pick_slip IN (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers))
2271 and qt.parent_line_id IS NULL -- Added for bulk task
2272 )
2273 --Added for Case Picking Project end
2274 )
2275 -- Bug: 7254397
2276 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
2277 AND wdt.user_task_type = e.standard_operation_id(+)
2278 AND qt.move_order_line_id = mol.line_id(+)
2279 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2280 AND qt.organization_id = sub.organization_id
2281 AND qt.subinventory_code = sub.secondary_inventory_name
2282 AND qt.organization_id = loc.organization_id
2283 AND qt.locator_id = loc.inventory_location_id
2284 UNION ALL
2285 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
2286 wdtv.task_id task_num,
2287 wdtv.subinventory_code,
2288 wdtv.locator_id,
2289 NVL(wdtv.pick_slip_number, -1) pick_slip,
2290 wdtv.transaction_uom,
2291 wdtv.transaction_quantity,
2292 wdtv.lot_number,
2293 wdtv.operation_plan_id,
2294 wdtv.user_task_type_id standard_operation_id,
2295 v.effective_start_date,
2296 v.effective_end_date,
2297 v.role person_resource_id,
2298 v.equipment machine_resource_id,
2299 wdtv.wms_task_type_id,
2300 nvl(wdtv.task_priority, 0),
2301 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2302 mol.line_id,
2303 sub.picking_order sub_picking_order,
2304 loc.picking_order loc_picking_order,
2305 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2306 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2307 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2308 task_status,
2309 wdtv.transaction_type_id,
2310 wdtv.transaction_action_id,
2311 wdtv.transaction_source_id,
2312 wdtv.transaction_source_type_id
2313 FROM
2314 -- inlined wms_dispatchable_tasks_v, bug 2648133
2315 (SELECT
2316 transaction_temp_id task_id,
2317 standard_operation_id user_task_type_id,
2318 wms_task_type wms_task_type_id,
2319 organization_id,
2320 subinventory_code,
2321 locator_id,
2322 task_priority,
2323 revision,
2324 lot_number,
2325 transaction_uom,
2326 transaction_quantity,
2327 pick_rule_id,
2328 pick_slip_number,
2329 cartonization_id,
2330 inventory_item_id,
2331 move_order_line_id,
2332 1 task_status,
2333 transaction_type_id,
2334 transaction_action_id,
2335 transaction_source_id,
2336 transaction_source_type_id,
2337 operation_plan_id,
2338 parent_line_id --Added for Case Picking Project (Bulk Task check)
2339 FROM mtl_material_transactions_temp mmtt
2340 WHERE wms_task_type IS NOT NULL
2341 AND transaction_status = 2
2342 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
2343 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2344 parent_line_id, transaction_temp_id)
2345 AND Decode(transaction_source_type_id,
2346 2, l_so_allowed,
2347 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2348 5, Decode(transaction_type_id, 35, l_wip_allowed),
2349 8, l_io_allowed,
2350 13, Decode(transaction_type_id,
2351 51, l_wip_allowed,
2352 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2353 --7169220: USERS LOCKED
2354 AND (mmtt.cartonization_id is null
2355 or not exists
2356 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2357 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2358 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2359 and wdt1.status = 9
2360 and mmtt1.cartonization_id = mmtt.cartonization_id)
2361 )
2362
2363 UNION ALL
2364 SELECT
2365 MIN(mcce.cycle_count_entry_id) task_id,
2366 MIN(mcce.standard_operation_id) user_task_type_id,
2367 3 wms_task_type_id,
2368 mcce.organization_id,
2369 mcce.subinventory subinventory_code,
2370 mcce.locator_id,
2371 MIN(mcce.task_priority) task_priority,
2372 mcce.revision revision,
2373 MIN(mcce.lot_number) lot_number,
2374 '' transaction_uom,
2375 TO_NUMBER(NULL) transaction_quantity,
2376 TO_NUMBER(NULL) pick_rule_id,
2377 TO_NUMBER(NULL) pick_slip_number,
2378 TO_NUMBER(NULL) cartonization_id,
2379 mcce.inventory_item_id,
2380 TO_NUMBER(NULL) move_order_line_id,
2381 1 task_status,
2382 4 transaction_type_id,
2383 4 transaction_action_id,
2384 mcce.cycle_count_header_id transaction_source_id,
2385 9 transaction_source_type_id,
2386 To_number(NULL) operation_plan_id,
2387 TO_NUMBER(NULL) parent_line_id --Added for Case Picking Project (Bulk Task check)
2388 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
2389 WHERE mcce.entry_status_code IN(1, 3)
2390 AND NVL(mcce.export_flag, 2) = 2
2391 -- bug 3972076
2392 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2393 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2394 -----bug6903708---
2395 AND mcce.organization_id = mcch.organization_id
2396 AND mcch.organization_id = p_sign_on_org_id
2397 ---------------------------
2398
2399 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2400 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
2401 -- inlined wms_person_resource_utt_v, bug 2648133
2402 (SELECT
2403 utt_emp.standard_operation_id standard_operation_id,
2404 min(utt_emp.resource_id) role, --Modified for Case Picking Project + Picking ER (FP 7709357)
2405 min(utt_eqp.resource_id) equipment, --Modified for Case Picking Project + Picking ER (FP 7709357)
2406 utt_emp.person_id emp_id,
2407 utt_emp.effective_start_date,
2408 utt_emp.effective_end_date,
2409 --utt_eqp.inventory_item_id eqp_id, --Modified for Case Picking Project + Picking ER (FP 7709357)
2410 NULL eqp_srl /* removed for bug 2095237 */
2411 FROM
2412 (SELECT
2413 x_utt_res1.standard_operation_id standard_operation_id,
2414 x_utt_res1.resource_id resource_id,
2415 x_emp_r.person_id,
2416 x_emp_r.effective_start_date,
2417 x_emp_r.effective_end_date
2418 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
2419 WHERE x_utt_res1.resource_id = r1.resource_id
2420 AND r1.resource_type = 2
2421 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
2422 (SELECT
2423 x_utt_res2.standard_operation_id standard_operation_id,
2424 x_utt_res2.resource_id,
2425 x_eqp_r.inventory_item_id
2426 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
2427 WHERE x_utt_res2.resource_id = r2.resource_id
2428 AND r2.resource_type = 1
2429 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
2430 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)
2431 AND NVL(utt_eqp.inventory_item_id, -999) = NVL(l_sign_on_equipment_id, NVL(utt_eqp.inventory_item_id, -999)) --Modified for Case Picking Project + Picking ER (FP 7709357)
2432 GROUP BY utt_emp.standard_operation_id, utt_emp.person_id, utt_emp.effective_start_date, utt_emp.effective_end_date) v,
2433 mtl_item_locations loc,
2434 mtl_secondary_inventories sub,
2435 mtl_txn_request_lines mol,
2436 mtl_txn_request_headers moh
2437 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
2438 AND ((wdtv.pick_slip_number = v_pick_slip_number AND p_task_method = 'DISCRETE')
2439 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2440 AND wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
2441 OR (p_task_method = 'ORDERPICK'
2442 AND Decode(wdtv.transaction_source_type_id,
2443 2, wdtv.transaction_source_id,
2444 5, Decode(wdtv.transaction_type_id, 35, wdtv.transaction_source_id),
2445 8, wdtv.transaction_source_id,
2446 13, Decode(wdtv.transaction_type_id, 51, wdtv.transaction_source_id),
2447 -1) = nvl(v_transaction_source_id, -1))
2448 OR (p_task_method = 'PICKBYLABEL' AND wdtv.cartonization_id = l_cartonization_id)
2449 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2450 wdtv.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id)))
2451 --Added for Case Picking Project start
2452 OR ( p_task_method = 'MANIFESTORDER' AND
2453 wdtv.transaction_source_id IN (
2454 SELECT MMTT.TRANSACTION_SOURCE_ID
2455 FROM MTL_SALES_ORDERS MSO ,
2456 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
2457 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
2458 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
2459 )
2460 and wdtv.parent_line_id IS NULL -- Added for bulk task
2461 )
2462 OR (p_task_method = 'MANIFESTPICKSLIP'
2463 AND wdtv.pick_slip_number IN (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers))
2464 and wdtv.parent_line_id IS NULL -- Added for bulk task
2465 )
2466 --Added for Case Picking Project end
2467 )
2468 AND wdtv.organization_id = p_sign_on_org_id
2469 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2470 AND NVL(wdtv.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.subinventory_code, '@@@')) AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
2471 --AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999)) --Modified above for Case Picking Project + Picking ER (FP 7709357)
2472 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2473 AND wdtv.locator_id = loc.inventory_location_id(+)
2474 AND wdtv.subinventory_code = sub.secondary_inventory_name
2475 AND wdtv.organization_id = sub.organization_id
2476 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
2477 AND moh.header_id(+) = mol.header_id
2478 AND Decode(Nvl(moh.move_order_type, -1),
2479 2, l_rep_allowed,
2480 1, l_mot_moi_allowed,
2481 -1, 1,
2482 1) = 1
2483 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2484 (SELECT NULL
2485 FROM mtl_material_transactions_temp mmtt
2486 WHERE mmtt.transaction_temp_id = wdtv.task_id
2487 AND mmtt.parent_line_id IS NOT NULL
2488 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2489 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2490 AND NOT EXISTS -- exclude tasks already dispatched and queued
2491 (SELECT NULL
2492 FROM wms_dispatched_tasks wdt1
2493 WHERE wdt1.transaction_temp_id = wdtv.task_id
2494 AND wdt1.task_type = wdtv.wms_task_type_id)
2495 -- Bug 7254397: exclude tasks from locked cartons
2496 AND NOT EXISTS
2497 ( SELECT 1
2498 FROM WMS_DISPATCH_TASKS_GTMP
2499 WHERE p_task_method = 'CLUSTERPICKBYLABEL'
2500 AND
2501 grouping_document_number = wdtv.cartonization_id)
2502 --Added for Case Picking Project start
2503 AND NOT EXISTS
2504 ( SELECT 1
2505 FROM WMS_DISPATCH_TASKS_GTMP
2506 WHERE p_task_method = 'MANIFESTPICKSLIP'
2507 AND grouping_document_number = wdtv.pick_slip_number)
2508 AND NOT EXISTS
2509 ( SELECT 1
2510 FROM WMS_DISPATCH_TASKS_GTMP
2511 WHERE p_task_method = 'MANIFESTORDER'
2512 AND grouping_document_number = wdtv.transaction_source_id)
2513 --Added for Case Picking Project end
2514 -- excluded skipped tasks
2515 AND wdtv.task_id NOT IN
2516 (SELECT wdtv.task_id
2517 FROM wms_skip_task_exceptions wste, mtl_parameters mp
2518 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
2519 AND wste.task_id = wdtv.task_id
2520 AND wste.organization_id = mp.organization_id)
2521 --J Addition
2522 AND wdtv.subinventory_code not in (
2523 SELECT wd.subinventory_code
2524 FROM wms_devices_b wd
2525 , wms_bus_event_devices wbed
2526 WHERE 1 = 1
2527 and wd.device_id = wbed.device_id
2528 AND wbed.organization_id = wd.organization_id
2529 AND wd.enabled_flag = 'Y'
2530 AND wbed.enabled_flag = 'Y'
2531 AND wbed.business_event_id = 10
2532 AND wd.subinventory_code IS NOT NULL
2533 AND wd.force_sign_on_flag = 'Y'
2534 AND wd.device_id NOT IN (SELECT device_id
2535 FROM wms_device_assignment_temp
2536 WHERE employee_id = p_sign_on_emp_id)
2537 )
2538 ORDER BY
2539 sub_picking_order,
2540 loc_picking_order,
2541 distance,
2542 task_priority desc,
2543 batch_id,
2544 task_status DESC,
2545 task_num;
2546
2547
2548 -- Cursor #2 for selecting the ordered tasks
2549 -- 1. Non cycle count tasks (1)
2550 -- 2. Cycle count tasks (0)
2551 CURSOR l_curs_ordered_tasks_10(v_pick_slip_number NUMBER,
2552 v_task_id NUMBER,
2553 v_task_type NUMBER,
2554 v_transaction_source_id NUMBER) IS
2555 SELECT DISTINCT
2556 qt.task_id task_num,
2557 qt.subinventory_code,
2558 qt.locator_id,
2559 qt.pick_slip,
2560 qt.transaction_uom,
2561 qt.transaction_quantity,
2562 qt.lot_number,
2563 qt.operation_plan_id,
2564 qt.standard_operation_id,
2565 wdt.effective_start_date,
2566 wdt.effective_end_date,
2567 wdt.person_resource_id,
2568 wdt.machine_resource_id,
2569 wdt.task_type wms_task_type_id,
2570 nvl(wdt.priority, 0) task_priority,
2571 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2572 mol.line_id,
2573 sub.picking_order sub_picking_order,
2574 loc.picking_order loc_picking_order,
2575 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2576 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2577 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2578 wdt.status task_status, --bug 4310093
2579 qt.transaction_type_id,
2580 qt.transaction_action_id,
2581 qt.transaction_source_id,
2582 qt.transaction_source_type_id
2583 FROM wms_dispatched_tasks wdt,
2584 (SELECT
2585 transaction_temp_id task_id,
2586 pick_slip_number pick_slip,
2587 cartonization_id,
2588 organization_id,
2589 subinventory_code,
2590 locator_id,
2591 inventory_item_id,
2592 revision,
2593 transaction_uom,
2594 transaction_quantity,
2595 lot_number,
2596 operation_plan_id,
2597 standard_operation_id,
2598 move_order_line_id,
2599 transaction_type_id,
2600 transaction_action_id,
2601 transaction_source_id,
2602 transaction_source_type_id,
2603 parent_line_id --Added for Case Picking Project (Bulk Task check)
2604 FROM mtl_material_transactions_temp mmtt
2605 WHERE wms_task_type IS NOT NULL
2606 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2607 parent_line_id, transaction_temp_id)
2608 AND Decode(transaction_source_type_id,
2609 2, l_so_allowed,
2610 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2611 5, Decode(transaction_type_id, 35, l_wip_allowed),
2612 8, l_io_allowed,
2613 13, Decode(transaction_type_id,
2614 51, l_wip_allowed,
2615 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2616 --7169220: USERS LOCKED
2617 AND (mmtt.cartonization_id is null
2618 or not exists
2619 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2620 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2621 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2622 and wdt1.status = 9
2623 and mmtt1.cartonization_id = mmtt.cartonization_id)
2624 )
2625 ) qt,
2626 mtl_txn_request_lines mol,
2627 mtl_secondary_inventories sub,
2628 mtl_item_locations loc,
2629 (SELECT
2630 bsor.standard_operation_id,
2631 bre.resource_id,
2632 bre.inventory_item_id equipment_id
2633 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2634 WHERE bsor.resource_id = bre.resource_id
2635 AND br.resource_type = 1
2636 AND bsor.resource_id = br.resource_id) e
2637 WHERE wdt.transaction_temp_id = qt.task_id
2638 AND wdt.status = 2 --bug 6326482 queued task only -- Queued and dispatched tasks only bug 4310093
2639 AND wdt.person_id = p_sign_on_emp_id
2640 AND wdt.organization_id = p_sign_on_org_id
2641 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2642 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2643 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2644 OR (p_task_method = 'ORDERPICK'
2645 AND Decode(qt.transaction_source_type_id,
2646 2, qt.transaction_source_id,
2647 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2648 8, qt.transaction_source_id,
2649 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2650 -1) = nvl(v_transaction_source_id, -1))
2651 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2652 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2653 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id)))
2654 --Added for Case Picking Project start
2655 OR ( p_task_method = 'MANIFESTORDER' AND
2656 qt.transaction_source_id IN (
2657 SELECT MMTT.TRANSACTION_SOURCE_ID
2658 FROM MTL_SALES_ORDERS MSO ,
2659 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
2660 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
2661 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
2662 )
2663 and qt.parent_line_id IS NULL -- Added for bulk task
2664 )
2665 OR (p_task_method = 'MANIFESTPICKSLIP'
2666 AND qt.pick_slip IN (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers))
2667 and qt.parent_line_id IS NULL -- Added for bulk task
2668 )
2669 --Added for Case Picking Project end
2670 )
2671 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))--bug 6326482
2672 AND wdt.user_task_type = e.standard_operation_id(+)
2673 AND qt.move_order_line_id = mol.line_id(+)
2674 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2675 AND qt.organization_id = sub.organization_id
2676 AND qt.subinventory_code = sub.secondary_inventory_name
2677 AND qt.organization_id = loc.organization_id
2678 AND qt.locator_id = loc.inventory_location_id
2679 UNION ALL
2680 --bug 6326482
2681 SELECT DISTINCT
2682 qt.task_id task_num,
2683 qt.subinventory_code,
2684 qt.locator_id,
2685 qt.pick_slip,
2686 qt.transaction_uom,
2687 qt.transaction_quantity,
2688 qt.lot_number,
2689 qt.operation_plan_id,
2690 qt.standard_operation_id,
2691 wdt.effective_start_date,
2692 wdt.effective_end_date,
2693 wdt.person_resource_id,
2694 wdt.machine_resource_id,
2695 wdt.task_type wms_task_type_id,
2696 nvl(wdt.priority, 0) task_priority,
2697 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2698 mol.line_id,
2699 sub.picking_order sub_picking_order,
2700 loc.picking_order loc_picking_order,
2701 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2702 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2703 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2704 wdt.status task_status,
2705 qt.transaction_type_id,
2706 qt.transaction_action_id,
2707 qt.transaction_source_id,
2708 qt.transaction_source_type_id
2709 FROM wms_dispatched_tasks wdt,
2710 (SELECT
2711 transaction_temp_id task_id,
2712 wms_task_status task_status, --bug 6326482 added to check for the previous state of dispatched tasks
2713 pick_slip_number pick_slip,
2714 cartonization_id,
2715 organization_id,
2716 subinventory_code,
2717 locator_id,
2718 inventory_item_id,
2719 revision,
2720 transaction_uom,
2721 transaction_quantity,
2722 lot_number,
2723 operation_plan_id,
2724 standard_operation_id,
2725 move_order_line_id,
2726 transaction_type_id,
2727 transaction_action_id,
2728 transaction_source_id,
2729 transaction_source_type_id,
2730 parent_line_id --Added for Case Picking Project (Bulk Task check)
2731 FROM mtl_material_transactions_temp mmtt
2732 WHERE wms_task_type IS NOT NULL
2733 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2734 parent_line_id, transaction_temp_id)
2735 AND Decode(transaction_source_type_id,
2736 2, l_so_allowed,
2737 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
2738 5, Decode(transaction_type_id, 35, l_wip_allowed),
2739 8, l_io_allowed,
2740 13, Decode(transaction_type_id,
2741 51, l_wip_allowed,
2742 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2743 --7169220: USERS LOCKED
2744 AND (mmtt.cartonization_id is null
2745 or not exists
2746 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2747 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2748 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2749 and wdt1.status = 9
2750 and mmtt1.cartonization_id = mmtt.cartonization_id)
2751 )
2752 ) qt,
2753 mtl_txn_request_lines mol,
2754 mtl_secondary_inventories sub,
2755 mtl_item_locations loc,
2756 (SELECT
2757 bsor.standard_operation_id,
2758 bre.resource_id,
2759 bre.inventory_item_id equipment_id
2760 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2761 WHERE bsor.resource_id = bre.resource_id
2762 AND br.resource_type = 1
2763 AND bsor.resource_id = br.resource_id) e
2764 WHERE wdt.transaction_temp_id = qt.task_id
2765 AND wdt.status = 3 -- bug 6326482 dispatched tasks
2766 AND wdt.person_id = p_sign_on_emp_id
2767 AND wdt.organization_id = p_sign_on_org_id
2768 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2769 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2770 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2771 OR (p_task_method = 'ORDERPICK'
2772 AND Decode(qt.transaction_source_type_id,
2773 2, qt.transaction_source_id,
2774 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2775 8, qt.transaction_source_id,
2776 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2777 -1) = nvl(v_transaction_source_id, -1))
2778 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2779 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2780 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id)))
2781 --Added for Case Picking Project start
2782 OR ( p_task_method = 'MANIFESTORDER' AND
2783 qt.transaction_source_id IN (
2784 SELECT MMTT.TRANSACTION_SOURCE_ID
2785 FROM MTL_SALES_ORDERS MSO ,
2786 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
2787 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
2788 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
2789 )
2790 and qt.parent_line_id IS NULL -- Added for bulk task
2791 )
2792 OR (p_task_method = 'MANIFESTPICKSLIP' AND
2793 qt.pick_slip IN (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers))
2794 and qt.parent_line_id IS NULL -- Added for bulk task
2795 )
2796 --Added for Case Picking Project end
2797 )
2798 -- -bug 6326482
2799 AND ((qt.task_status is NULL
2800 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
2801 or
2802 (qt.task_status = 1
2803 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
2804 AND wdt.user_task_type = e.standard_operation_id(+)
2805 AND qt.move_order_line_id = mol.line_id(+)
2806 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2807 AND qt.organization_id = sub.organization_id
2808 AND qt.subinventory_code = sub.secondary_inventory_name
2809 AND qt.organization_id = loc.organization_id
2810 AND qt.locator_id = loc.inventory_location_id
2811 UNION ALL
2812 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
2813 wdtv.task_id task_num,
2814 wdtv.subinventory_code,
2815 wdtv.locator_id,
2816 NVL(wdtv.pick_slip_number, -1) pick_slip,
2817 wdtv.transaction_uom,
2818 wdtv.transaction_quantity,
2819 wdtv.lot_number,
2820 wdtv.operation_plan_id,
2821 wdtv.user_task_type_id standard_operation_id,
2822 v.effective_start_date,
2823 v.effective_end_date,
2824 v.role person_resource_id,
2825 v.equipment machine_resource_id,
2826 wdtv.wms_task_type_id,
2827 nvl(wdtv.task_priority, 0),
2828 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2829 mol.line_id,
2830 sub.picking_order sub_picking_order,
2831 loc.picking_order loc_picking_order,
2832 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2833 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2834 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2835 task_status,
2836 wdtv.transaction_type_id,
2837 wdtv.transaction_action_id,
2838 wdtv.transaction_source_id,
2839 wdtv.transaction_source_type_id
2840 FROM
2841 -- inlined wms_dispatchable_tasks_v, bug 2648133
2842 (SELECT
2843 transaction_temp_id task_id,
2844 standard_operation_id user_task_type_id,
2845 wms_task_type wms_task_type_id,
2846 organization_id,
2847 subinventory_code,
2848 locator_id,
2849 task_priority,
2850 revision,
2851 lot_number,
2852 transaction_uom,
2853 transaction_quantity,
2854 pick_rule_id,
2855 pick_slip_number,
2856 cartonization_id,
2857 inventory_item_id,
2858 move_order_line_id,
2859 1 task_status,
2860 transaction_type_id,
2861 transaction_action_id,
2862 transaction_source_id,
2863 transaction_source_type_id,
2864 operation_plan_id,
2865 parent_line_id --Added for Case Picking Project (Bulk Task check)
2866 FROM mtl_material_transactions_temp mmtt
2867 WHERE wms_task_type IS NOT NULL
2868 AND transaction_status = 2
2869 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
2870 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2871 parent_line_id, transaction_temp_id)
2872 AND Decode(transaction_source_type_id,
2873 2, l_so_allowed,
2874 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2875 5, Decode(transaction_type_id, 35, l_wip_allowed),
2876 8, l_io_allowed,
2877 13, Decode(transaction_type_id,
2878 51, l_wip_allowed,
2879 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2880 --7169220: USERS LOCKED
2881 AND (mmtt.cartonization_id is null
2882 or not exists
2883 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2884 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2885 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2886 and wdt1.status = 9
2887 and mmtt1.cartonization_id = mmtt.cartonization_id)
2888 )
2889 ) wdtv,
2890 -- inlined wms_person_resource_utt_v, bug 2648133
2891 (SELECT
2892 utt_emp.standard_operation_id standard_operation_id,
2893 min(utt_emp.resource_id) role, --Modified for Case Picking Project + Picking ER (FP 7709357)
2894 min(utt_eqp.resource_id) equipment, --Modified for Case Picking Project + Picking ER (FP 7709357)
2895 utt_emp.person_id emp_id,
2896 utt_emp.effective_start_date,
2897 utt_emp.effective_end_date,
2898 -- utt_eqp.inventory_item_id eqp_id, --Modified for Case Picking Project + Picking ER (FP 7709357)
2899 NULL eqp_srl /* removed for bug 2095237 */
2900 FROM
2901 (SELECT
2902 x_utt_res1.standard_operation_id standard_operation_id,
2903 x_utt_res1.resource_id resource_id,
2904 x_emp_r.person_id,
2905 x_emp_r.effective_start_date,
2906 x_emp_r.effective_end_date
2907 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
2908 WHERE x_utt_res1.resource_id = r1.resource_id
2909 AND r1.resource_type = 2
2910 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
2911 (SELECT
2912 x_utt_res2.standard_operation_id standard_operation_id,
2913 x_utt_res2.resource_id,
2914 x_eqp_r.inventory_item_id
2915 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
2916 WHERE x_utt_res2.resource_id = r2.resource_id
2917 AND r2.resource_type = 1
2918 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
2919 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)
2920 AND NVL(utt_eqp.inventory_item_id, -999) = NVL(l_sign_on_equipment_id, NVL(utt_eqp.inventory_item_id, -999)) --Modified for Case Picking Project + Picking ER (FP 7709357)
2921 GROUP BY utt_emp.standard_operation_id, utt_emp.person_id, utt_emp.effective_start_date, utt_emp.effective_end_date) v,
2922 mtl_item_locations loc,
2923 mtl_secondary_inventories sub,
2924 mtl_txn_request_lines mol,
2925 mtl_txn_request_headers moh
2926 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
2927 AND ((wdtv.pick_slip_number = v_pick_slip_number AND p_task_method = 'DISCRETE')
2928 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2929 AND wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
2930 OR (p_task_method = 'ORDERPICK'
2931 AND Decode(wdtv.transaction_source_type_id,
2932 2, wdtv.transaction_source_id,
2933 5, Decode(wdtv.transaction_type_id, 35, wdtv.transaction_source_id),
2934 8, wdtv.transaction_source_id,
2935 13, Decode(wdtv.transaction_type_id, 51, wdtv.transaction_source_id),
2936 -1) = nvl(v_transaction_source_id, -1))
2937 OR (p_task_method = 'PICKBYLABEL' AND wdtv.cartonization_id = l_cartonization_id)
2938 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2939 wdtv.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id)))
2940 --Added for Case Picking Project start
2941 OR ( p_task_method = 'MANIFESTORDER' AND
2942 wdtv.transaction_source_id IN (
2943 SELECT MMTT.TRANSACTION_SOURCE_ID
2944 FROM MTL_SALES_ORDERS MSO ,
2945 MTL_MATERIAL_TRANSACTIONS_TEMP MMTT
2946 WHERE MMTT.TRANSACTION_SOURCE_ID = MSO.SALES_ORDER_ID
2947 AND MSO.SEGMENT1 IN ( SELECT * FROM TABLE(WMS_PICKING_PKG.LIST_ORDER_NUMBERS))
2948 )
2949 and wdtv.parent_line_id IS NULL -- Added for bulk task
2950 )
2951 OR (p_task_method = 'MANIFESTPICKSLIP'
2952 AND wdtv.pick_slip_number IN (SELECT * FROM TABLE(wms_picking_pkg.list_pick_slip_numbers))
2953 and wdtv.parent_line_id IS NULL -- Added for bulk task
2954 )
2955 --Added for Case Picking Project end
2956 )
2957 AND wdtv.organization_id = p_sign_on_org_id
2958 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2959 AND NVL(wdtv.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.subinventory_code, '@@@'))
2960 --AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999)) --Modified for Case Picking Project + Picking ER (FP 7709357)
2961 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2962 AND wdtv.locator_id = loc.inventory_location_id(+)
2963 AND wdtv.subinventory_code = sub.secondary_inventory_name
2964 AND wdtv.organization_id = sub.organization_id
2965 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
2966 AND moh.header_id(+) = mol.header_id
2967 AND Decode(Nvl(moh.move_order_type, -1),
2968 2, l_rep_allowed,
2969 1, l_mot_moi_allowed,
2970 -1, 1,
2971 1) = 1
2972 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2973 (SELECT NULL
2974 FROM mtl_material_transactions_temp mmtt
2975 WHERE mmtt.transaction_temp_id = wdtv.task_id
2976 AND mmtt.parent_line_id IS NOT NULL
2977 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2978 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2979 AND NOT EXISTS -- exclude tasks already dispatched and queued
2980 (SELECT NULL
2981 FROM wms_dispatched_tasks wdt1
2982 WHERE wdt1.transaction_temp_id = wdtv.task_id
2983 AND wdt1.task_type = wdtv.wms_task_type_id)
2984 -- Bug 7254397: exclude tasks from locked cartons
2985 AND NOT EXISTS
2986 ( SELECT 1
2987 FROM WMS_DISPATCH_TASKS_GTMP
2988 WHERE p_task_method = 'CLUSTERPICKBYLABEL'
2989 AND
2990 grouping_document_number = wdtv.cartonization_id)
2991 --Added for Case Picking Project start
2992 AND NOT EXISTS
2993 ( SELECT 1
2994 FROM WMS_DISPATCH_TASKS_GTMP
2995 WHERE p_task_method = 'MANIFESTPICKSLIP'
2996 AND grouping_document_number = wdtv.pick_slip_number)
2997 AND NOT EXISTS
2998 ( SELECT 1
2999 FROM WMS_DISPATCH_TASKS_GTMP
3000 WHERE p_task_method = 'MANIFESTORDER'
3001 AND grouping_document_number = wdtv.transaction_source_id)
3002 --Added for Case Picking Project end
3003 -- excluded skipped taskS
3004 AND wdtv.task_id NOT IN
3005 (SELECT wdtv.task_id
3006 FROM wms_skip_task_exceptions wste, mtl_parameters mp
3007 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
3008 AND wste.task_id = wdtv.task_id
3009 AND wste.organization_id = mp.organization_id)
3010 --J Addition
3011 AND wdtv.subinventory_code not in (
3012 SELECT wd.subinventory_code
3013 FROM wms_devices_b wd
3014 , wms_bus_event_devices wbed
3015 WHERE 1 = 1
3016 and wd.device_id = wbed.device_id
3017 AND wbed.organization_id = wd.organization_id
3018 AND wd.enabled_flag = 'Y'
3019 AND wbed.enabled_flag = 'Y'
3020 AND wbed.business_event_id = 10
3021 AND wd.subinventory_code IS NOT NULL
3022 AND wd.force_sign_on_flag = 'Y'
3023 AND wd.device_id NOT IN (SELECT device_id
3024 FROM wms_device_assignment_temp
3025 WHERE employee_id = p_sign_on_emp_id)
3026 )
3027 ORDER BY
3028 sub_picking_order,
3029 loc_picking_order,
3030 distance,
3031 task_priority desc,
3032 batch_id,
3033 task_status DESC,
3034 task_num;
3035
3036 -- Cursor #3 for selecting the ordered tasks
3037 -- 1. Non cycle count tasks (0)
3038 -- 2. Cycle count tasks (1)
3039 CURSOR l_curs_ordered_tasks_01(v_task_id NUMBER,
3040 v_task_type NUMBER) IS
3041 SELECT DISTINCT
3042 qt.task_id task_num,
3043 qt.subinventory_code,
3044 qt.locator_id,
3045 qt.pick_slip,
3046 qt.transaction_uom,
3047 qt.transaction_quantity,
3048 qt.lot_number,
3049 qt.operation_plan_id,
3050 qt.standard_operation_id,
3051 wdt.effective_start_date,
3052 wdt.effective_end_date,
3053 wdt.person_resource_id,
3054 wdt.machine_resource_id,
3055 wdt.task_type wms_task_type_id,
3056 nvl(wdt.priority, 0) task_priority,
3057 To_number(NULL) batch_id,
3058 To_number(NULL) line_id,
3059 sub.picking_order sub_picking_order,
3060 loc.picking_order loc_picking_order,
3061 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
3062 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
3063 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
3064 wdt.status task_status, --bug 4310093
3065 qt.transaction_type_id,
3066 qt.transaction_action_id,
3067 qt.transaction_source_id,
3068 qt.transaction_source_type_id
3069 FROM wms_dispatched_tasks wdt,
3070 (SELECT
3071 MIN(mcce.cycle_count_entry_id) task_id,
3072 TO_NUMBER(NULL) pick_slip,
3073 To_number(NULL) cartonization_id,
3074 mcce.organization_id,
3075 mcce.subinventory subinventory_code,
3076 mcce.locator_id,
3077 mcce.inventory_item_id,
3078 mcce.revision,
3079 To_char(NULL) transaction_uom,
3080 To_number(NULL) transaction_quantity,
3081 MIN(mcce.lot_number) lot_number,
3082 To_number(NULL) operation_plan_id,
3083 MIN(mcce.standard_operation_id) standard_operation_id,
3084 To_number(NULL) move_order_line_id,
3085 4 transaction_type_id,
3086 4 transaction_action_id,
3087 mcce.cycle_count_header_id transaction_source_id,
3088 9 transaction_source_type_id
3089 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
3090 WHERE mcce.entry_status_code IN(1, 3)
3091 AND NVL(mcce.export_flag, 2) = 2
3092 -- bug 3972076
3093 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
3094 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
3095
3096 -----bug6903708---
3097 AND mcce.organization_id = mcch.organization_id
3098 AND mcch.organization_id = p_sign_on_org_id
3099 ---------------------------
3100
3101 AND NVL(mcch.disable_date,sysdate+1)> sysdate
3102 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
3103 mtl_secondary_inventories sub,
3104 mtl_item_locations loc,
3105 (SELECT
3106 bsor.standard_operation_id,
3107 bre.resource_id,
3108 bre.inventory_item_id equipment_id
3109 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
3110 WHERE bsor.resource_id = bre.resource_id
3111 AND br.resource_type = 1
3112 AND bsor.resource_id = br.resource_id) e
3113 WHERE wdt.transaction_temp_id = qt.task_id
3114 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
3115 AND wdt.person_id = p_sign_on_emp_id
3116 AND wdt.organization_id = p_sign_on_org_id
3117 AND (qt.task_id = v_task_id AND wdt.task_type = v_task_type)
3118 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
3119 AND wdt.user_task_type = e.standard_operation_id(+)
3120 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
3121 AND qt.organization_id = sub.organization_id
3122 AND qt.subinventory_code = sub.secondary_inventory_name
3123 AND qt.organization_id = loc.organization_id
3124 AND qt.locator_id = loc.inventory_location_id
3125 UNION ALL
3126 SELECT /*+ leading(V.UTT_EMP.X_EMP_R) */ DISTINCT --HW Performance Issue Bug#13439829
3127 wdtv.task_id task_num,
3128 wdtv.subinventory_code,
3129 wdtv.locator_id,
3130 NVL(wdtv.pick_slip_number, -1) pick_slip,
3131 wdtv.transaction_uom,
3132 wdtv.transaction_quantity,
3133 wdtv.lot_number,
3134 wdtv.operation_plan_id,
3135 wdtv.user_task_type_id standard_operation_id,
3136 v.effective_start_date,
3137 v.effective_end_date,
3138 v.role person_resource_id,
3139 v.equipment machine_resource_id,
3140 wdtv.wms_task_type_id,
3141 nvl(wdtv.task_priority, 0),
3142 To_number(NULL) batch_id,
3143 To_number(NULL) line_id,
3144 sub.picking_order sub_picking_order,
3145 loc.picking_order loc_picking_order,
3146 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
3147 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
3148 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
3149 task_status,
3150 wdtv.transaction_type_id,
3151 wdtv.transaction_action_id,
3152 wdtv.transaction_source_id,
3153 wdtv.transaction_source_type_id
3154 FROM
3155 -- inlined wms_dispatchable_tasks_v, bug 2648133
3156 (SELECT
3157 MIN(mcce.cycle_count_entry_id) task_id,
3158 MIN(mcce.standard_operation_id) user_task_type_id,
3159 3 wms_task_type_id,
3160 mcce.organization_id,
3161 mcce.subinventory subinventory_code,
3162 mcce.locator_id,
3163 MIN(task_priority) task_priority,
3164 mcce.revision revision,
3165 MIN(mcce.lot_number) lot_number,
3166 '' transaction_uom,
3167 TO_NUMBER(NULL) transaction_quantity,
3168 TO_NUMBER(NULL) pick_rule_id,
3169 TO_NUMBER(NULL) pick_slip_number,
3170 TO_NUMBER(NULL) cartonization_id,
3171 mcce.inventory_item_id,
3172 TO_NUMBER(NULL) move_order_line_id,
3173 1 task_status,
3174 4 transaction_type_id,
3175 4 transaction_action_id,
3176 mcce.cycle_count_header_id transaction_source_id,
3177 9 transaction_source_type_id,
3178 To_number(NULL) operation_plan_id
3179 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
3180 WHERE mcce.entry_status_code IN(1, 3)
3181 AND NVL(mcce.export_flag, 2) = 2
3182 -- bug 3972076
3183 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
3184 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
3185
3186 -----bug6903708---
3187 AND mcce.organization_id = mcch.organization_id
3188 AND mcch.organization_id = p_sign_on_org_id
3189 ---------------------------
3190
3191 AND NVL(mcch.disable_date,sysdate+1)> sysdate
3192 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
3193 -- inlined wms_person_resource_utt_v, bug 2648133
3194 (SELECT
3195 utt_emp.standard_operation_id standard_operation_id,
3196 min(utt_emp.resource_id) role, --Modified for Case Picking Project + Picking ER (FP 7709357)
3197 min(utt_eqp.resource_id) equipment, --Modified for Case Picking Project + Picking ER (FP 7709357)
3198 utt_emp.person_id emp_id,
3199 utt_emp.effective_start_date,
3200 utt_emp.effective_end_date,
3201 --utt_eqp.inventory_item_id eqp_id, --Modified for Case Picking Project + Picking ER (FP 7709357)
3202 NULL eqp_srl /* removed for bug 2095237 */
3203 FROM
3204 (SELECT
3205 x_utt_res1.standard_operation_id standard_operation_id,
3206 x_utt_res1.resource_id resource_id,
3207 x_emp_r.person_id,
3208 x_emp_r.effective_start_date,
3209 x_emp_r.effective_end_date
3210 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
3211 WHERE x_utt_res1.resource_id = r1.resource_id
3212 AND r1.resource_type = 2
3213 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
3214 (SELECT
3215 x_utt_res2.standard_operation_id standard_operation_id,
3216 x_utt_res2.resource_id,
3217 x_eqp_r.inventory_item_id
3218 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
3219 WHERE x_utt_res2.resource_id = r2.resource_id
3220 AND r2.resource_type = 1
3221 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
3222 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)
3223 AND NVL(utt_eqp.inventory_item_id, -999) = NVL(l_sign_on_equipment_id, NVL(utt_eqp.inventory_item_id, -999)) --Modified for Case Picking Project + Picking ER (FP 7709357)
3224 GROUP BY utt_emp.standard_operation_id, utt_emp.person_id, utt_emp.effective_start_date, utt_emp.effective_end_date) v,
3225 mtl_item_locations loc,
3226 mtl_secondary_inventories sub
3227 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
3228 AND (wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
3229 AND wdtv.organization_id = p_sign_on_org_id
3230 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
3231 AND NVL(wdtv.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.subinventory_code, '@@@'))
3232 -- AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999)) --Modified for Case Picking Project + Picking ER (FP 7709357)
3233 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
3234 AND wdtv.locator_id = loc.inventory_location_id(+)
3235 AND wdtv.subinventory_code = sub.secondary_inventory_name
3236 AND wdtv.organization_id = sub.organization_id
3237 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
3238 (SELECT NULL
3239 FROM mtl_material_transactions_temp mmtt
3240 WHERE mmtt.transaction_temp_id = wdtv.task_id
3241 AND mmtt.parent_line_id IS NOT NULL
3242 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
3243 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
3244 AND NOT EXISTS -- exclude tasks already dispatched and queued
3245 (SELECT NULL
3246 FROM wms_dispatched_tasks wdt1
3247 WHERE wdt1.transaction_temp_id = wdtv.task_id
3248 AND wdt1.task_type = wdtv.wms_task_type_id)
3249 -- excluded skipped tasks
3250 AND wdtv.task_id NOT IN
3251 (SELECT wdtv.task_id
3252 FROM wms_skip_task_exceptions wste, mtl_parameters mp
3253 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
3254 AND wste.task_id = wdtv.task_id
3255 AND wste.organization_id = mp.organization_id)
3256 --J Addition
3257 AND wdtv.subinventory_code not in (
3258 SELECT wd.subinventory_code
3259 FROM wms_devices_b wd
3260 , wms_bus_event_devices wbed
3261 WHERE 1 = 1
3262 and wd.device_id = wbed.device_id
3263 AND wbed.organization_id = wd.organization_id
3264 AND wd.enabled_flag = 'Y'
3265 AND wbed.enabled_flag = 'Y'
3266 AND wbed.business_event_id = 10
3267 AND wd.subinventory_code IS NOT NULL
3268 AND wd.force_sign_on_flag = 'Y'
3269 AND wd.device_id NOT IN (SELECT device_id
3270 FROM wms_device_assignment_temp
3271 WHERE employee_id = p_sign_on_emp_id)
3272 )
3273 ORDER BY
3274 sub_picking_order,
3275 loc_picking_order,
3276 distance,
3277 task_priority desc,
3278 batch_id,
3279 task_status DESC,
3280 task_num;
3281
3282 CURSOR c_task_lock_check(v_transaction_temp_id NUMBER) IS
3283 SELECT transaction_temp_id
3284 FROM mtl_material_transactions_temp
3285 WHERE transaction_temp_id = v_transaction_temp_id
3286 FOR UPDATE nowait;
3287
3288 CURSOR c_pick_slip_lock_check(v_pick_slip_number NUMBER) IS
3289 SELECT mmtt.transaction_temp_id
3290 FROM mtl_material_transactions_temp mmtt
3291 WHERE mmtt.pick_slip_number = v_pick_slip_number
3292 AND NVL(mmtt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(mmtt.subinventory_code, '@@@'))
3293 -- Bug 14094713 added to lock only the tasks queued to that particular user
3294 AND NOT EXISTS ( SELECT 1
3295 FROM wms_dispatched_tasks wdt
3296 WHERE wdt.transaction_temp_id = mmtt.transaction_temp_id
3297 AND wdt.person_id <> p_sign_on_emp_id
3298 )
3299 FOR UPDATE nowait;
3300
3301 CURSOR c_order_lock_check(v_order_header_id NUMBER,
3302 v_transaction_source_type_id NUMBER,
3303 v_transaction_action_id NUMBER,
3304 v_transaction_type_id NUMBER) IS
3305 SELECT transaction_temp_id
3306 FROM mtl_material_transactions_temp mmtt
3307 WHERE transaction_source_id = v_order_header_id
3308 AND transaction_source_type_id = v_transaction_source_type_id
3309 AND transaction_action_id = v_transaction_action_id
3310 AND transaction_type_id = v_transaction_type_id
3311 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(subinventory_code, '@@@'))
3312 -- Bug 14094713 added to lock only the tasks queued to that particular user
3313 AND NOT EXISTS ( SELECT 1
3314 FROM wms_dispatched_tasks wdt
3315 WHERE wdt.transaction_temp_id = mmtt.transaction_temp_id
3316 AND wdt.person_id <> p_sign_on_emp_id
3317 )
3318 FOR UPDATE nowait;
3319
3320 CURSOR c_carton_lock_check(v_cartonization_id NUMBER) IS
3321 SELECT transaction_temp_id
3322 FROM mtl_material_transactions_temp
3323 WHERE cartonization_id = v_cartonization_id
3324 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(subinventory_code, '@@@'))
3325 FOR UPDATE nowait;
3326
3327 CURSOR c_cycle_count_lock_check(v_cycle_count_entry_id NUMBER) IS
3328 SELECT cycle_count_entry_id
3329 FROM mtl_cycle_count_entries
3330 WHERE cycle_count_entry_id = v_cycle_count_entry_id
3331 FOR UPDATE nowait;
3332
3333 CURSOR c_task_filter(v_filter_name VARCHAR2) IS
3334 SELECT task_filter_source, task_filter_value
3335 FROM wms_task_filter_b wtf, wms_task_filter_dtl wtfd
3336 WHERE task_filter_name = v_filter_name
3337 AND wtf.task_filter_id = wtfd.task_filter_id;
3338
3339 --Added for Case Picking Project start
3340
3341 CURSOR c_pick_slip_numbers IS
3342 SELECT column_value pick_slip_number FROM TABLE(wms_picking_pkg.list_pick_slip_numbers);
3343
3344 CURSOR c_order_numbers IS
3345 SELECT mso.sales_order_id FROM TABLE(wms_picking_pkg.list_order_numbers) lon , mtl_sales_orders mso
3346 WHERE mso.segment1 = lon.column_value;
3347
3348
3349 CURSOR c_manifest_order_lock_check(v_sales_order_id NUMBER) IS
3350 SELECT transaction_temp_id FROM mtl_material_transactions_temp
3351 WHERE transaction_source_id = v_sales_order_id
3352 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone,NVL(subinventory_code, '@@@'))
3353 FOR UPDATE nowait;
3354
3355 --Added for Case Picking Project end
3356
3357
3358 CURSOR lpn_ids_cur IS
3359 SELECT column_value LPN_ID FROM TABLE(wms_picking_pkg.list_cartonization_id);
3360
3361 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3362
3363 BEGIN
3364 IF (l_debug = 1) THEN
3365 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3366 END IF;
3367 IF (l_debug = 1) THEN
3368 -- Bug: 7254397
3369 for lpns_rec in lpn_ids_cur
3370 loop
3371 print_debug('LPNs: ' || To_char(lpns_rec.LPN_ID), 9);
3372 end loop;
3373 -- Bug: 7254397
3374 END IF;
3375
3376 l_progress := '10';
3377
3378 -- This API is query only, therefore does not create a save point
3379
3380 -- Initialize message list if p_init_msg_list is set to TRUE.
3381 IF fnd_api.to_boolean(p_init_msg_list) THEN
3382 fnd_msg_pub.initialize;
3383 END IF;
3384
3385 -- Initialize API return status to success
3386 x_return_status := fnd_api.g_ret_sts_success;
3387
3388 -- API body
3389 -- preprocess input parameters
3390
3391 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
3392
3393 IF l_sequence_picks_across_waves IS NULL /*OR p_task_method = 'WAVE' */ THEN --Bug#8392581
3394 l_sequence_picks_across_waves := 2;
3395 END IF;
3396 --bug 6326482
3397 l_ignore_equipment := NVL(fnd_profile.VALUE('WMS_IGNORE_EQUIPMENT'), 1);
3398 IF(l_ignore_equipment = 1) then
3399 l_q_sign_on_equipment_id := NULL;
3400 Else
3401 IF p_sign_on_equipment_srl = 'NONE' THEN
3402 l_q_sign_on_equipment_id := -999;
3403 ELSE
3404 l_q_sign_on_equipment_id := p_sign_on_equipment_id;
3405 END IF;
3406 END IF ;
3407 --bug 6326482
3408
3409 IF p_sign_on_equipment_srl = 'NONE' THEN
3410 l_sign_on_equipment_srl := NULL;
3411 l_sign_on_equipment_id := -999;
3412 ELSE
3413 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
3414 l_sign_on_equipment_id := p_sign_on_equipment_id;
3415 END IF;
3416
3417 -- APL
3418 IF x_grouping_document_type = 'CARTON' THEN
3419 l_cartonization_id := x_grouping_document_number;
3420 END IF;
3421
3422 -- Populate the task filter variables
3423 IF (l_debug = 1) THEN
3424 print_debug('Task Filter: ' || p_task_filter, 9);
3425 END IF;
3426
3427 FOR task_filter_rec IN c_task_filter(p_task_filter) LOOP
3428
3429 IF (l_debug = 1) THEN
3430 print_debug('Task Filter Source: ' || task_filter_rec.task_filter_source, 9);
3431 print_debug('Task Filter Value: ' || task_filter_rec.task_filter_value, 9);
3432 END IF;
3433
3434 IF task_filter_rec.task_filter_value = 'Y' THEN
3435 IF task_filter_rec.task_filter_source = 1 THEN -- Internal Order
3436 l_io_allowed := 1;
3437 l_non_cc_allowed := 1;
3438 ELSIF task_filter_rec.task_filter_source = 2 THEN -- Move Order Issue
3439 l_moi_allowed := 1;
3440 l_mot_moi_allowed := 1;
3441 l_non_cc_allowed := 1;
3442 ELSIF task_filter_rec.task_filter_source = 3 THEN -- Move Order Transfer
3443 l_mot_allowed := 1;
3444 l_mot_rep_allowed := 1;
3445 l_mot_moi_allowed := 1;
3446 l_non_cc_allowed := 1;
3447 ELSIF task_filter_rec.task_filter_source = 4 THEN -- Replenishment
3448 l_rep_allowed := 1;
3449 l_mot_rep_allowed := 1;
3450 l_non_cc_allowed := 1;
3451 ELSIF task_filter_rec.task_filter_source = 5 THEN -- Sales Order
3452 l_so_allowed := 1;
3453 l_non_cc_allowed := 1;
3454 ELSIF task_filter_rec.task_filter_source = 6 THEN -- Work Order
3455 l_wip_allowed := 1;
3456 l_non_cc_allowed := 1;
3457 ELSIF task_filter_rec.task_filter_source = 7 THEN -- Cycle Counting
3458 l_cc_allowed := 1;
3459 END IF;
3460 END IF;
3461
3462 END LOOP;
3463
3464
3465 IF (l_debug = 1) THEN
3466 print_debug('l_so_allowed: ' || l_so_allowed, 9);
3467 print_debug('l_io_allowed: ' || l_io_allowed, 9);
3468 print_debug('l_wip_allowed: ' || l_wip_allowed, 9);
3469 print_debug('l_mot_rep_allowed: ' || l_mot_rep_allowed, 9);
3470 print_debug('l_mot_allowed: ' || l_mot_allowed, 9);
3471 print_debug('l_rep_allowed: ' || l_rep_allowed, 9);
3472 print_debug('l_mot_moi_allowed: ' || l_mot_moi_allowed, 9);
3473 print_debug('l_moi_allowed: ' || l_moi_allowed, 9);
3474 print_debug('l_cc_allowed: ' || l_cc_allowed, 9);
3475 print_debug('l_non_cc_allowed: ' || l_non_cc_allowed, 9);
3476 END IF;
3477
3478 l_progress := '20';
3479
3480
3481 -- select last task this operator was working on
3482 BEGIN
3483 SELECT transaction_temp_id, task_type, loaded_time
3484 INTO l_last_loaded_task_id, l_last_loaded_task_type, l_last_loaded_time
3485 FROM (SELECT transaction_temp_id, task_type, loaded_time
3486 FROM wms_dispatched_tasks wdt
3487 WHERE wdt.person_id = p_sign_on_emp_id
3488 AND wdt.loaded_time = (SELECT MAX(loaded_time)
3489 FROM wms_dispatched_tasks
3490 WHERE person_id = p_sign_on_emp_id))
3491 WHERE ROWNUM = 1; -- make sure only one task selected
3492
3493 l_progress := '31';
3494 EXCEPTION
3495 WHEN OTHERS THEN
3496 l_last_loaded_task_id := -1;
3497 END;
3498
3499 IF (l_debug = 1) THEN
3500 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
3501 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
3502 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
3503 END IF;
3504
3505 -- select last task this operator completed
3506 BEGIN
3507 l_progress := '32';
3508
3509 SELECT transaction_id, task_type, loaded_time
3510 INTO l_last_dropoff_task_id, l_last_dropoff_task_type, l_last_dropoff_time
3511 FROM (SELECT transaction_id, task_type, loaded_time
3512 FROM wms_dispatched_tasks_history wdth
3513 WHERE wdth.person_id = p_sign_on_emp_id
3514 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
3515 FROM wms_dispatched_tasks_history
3516 WHERE person_id = p_sign_on_emp_id))
3517 WHERE ROWNUM = 1; -- make sure only one task selected
3518
3519 l_progress := '33';
3520 EXCEPTION
3521 WHEN OTHERS THEN
3522 l_last_dropoff_task_id := -1;
3523 END;
3524
3525 IF (l_debug = 1) THEN
3526 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
3527 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
3528 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
3529 END IF;
3530
3531 IF l_last_dropoff_task_id = -1 AND l_last_loaded_task_id = -1 THEN
3532 l_last_task_id := -1;
3533 ELSIF l_last_dropoff_task_id = -1 THEN
3534 l_last_task_id := l_last_loaded_task_id;
3535 l_last_task_type := l_last_loaded_task_type;
3536 l_last_task_is_drop := FALSE;
3537 ELSIF l_last_loaded_task_id = -1 THEN
3538 l_last_task_id := l_last_dropoff_task_id;
3539 l_last_task_type := l_last_dropoff_task_type;
3540 l_last_task_is_drop := TRUE;
3541 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
3542 l_last_task_id := l_last_dropoff_task_id;
3543 l_last_task_type := l_last_dropoff_task_type;
3544 l_last_task_is_drop := TRUE;
3545 END IF;
3546
3547 IF (l_debug = 1) THEN
3548 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
3549 END IF;
3550
3551 -- select locator coordinates of the the last task
3552 IF l_last_task_id <> -1 THEN -- make sure there is a last task
3553
3554 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
3555 -- get the location from wms_dispatchable_tasks_v
3556 BEGIN
3557 l_progress := '35';
3558
3559 -- use Nvl to make sure if coordinates not defined, use 0
3560 SELECT NVL(loc.x_coordinate, 0), NVL(loc.y_coordinate, 0), NVL(loc.z_coordinate, 0)
3561 INTO l_cur_x, l_cur_y, l_cur_z
3562 FROM mtl_item_locations loc,
3563 (SELECT
3564 transaction_temp_id task_id,
3565 standard_operation_id user_task_type_id,
3566 wms_task_type wms_task_type_id,
3567 organization_id organization_id,
3568 subinventory_code zone,
3569 locator_id locator_id,
3570 task_priority task_priority,
3571 revision revision,
3572 lot_number lot_number,
3573 transaction_uom transaction_uom,
3574 transaction_quantity transaction_quantity,
3575 pick_rule_id pick_rule_id,
3576 pick_slip_number pick_slip_number,
3577 cartonization_id cartonization_id,
3578 inventory_item_id,
3579 move_order_line_id
3580 FROM mtl_material_transactions_temp
3581 WHERE wms_task_type IS NOT NULL
3582 AND transaction_status = 2
3583 UNION ALL
3584 SELECT
3585 MIN(cycle_count_entry_id) task_id,
3586 MIN(standard_operation_id) user_task_type_id,
3587 3 wms_task_type_id,
3588 organization_id organization_id,
3589 subinventory zone,
3590 locator_id locator_id,
3591 MIN(task_priority) task_priority,
3592 revision revision,
3593 MIN(lot_number) lot_number,
3594 '' transaction_uom,
3595 TO_NUMBER(NULL) transaction_quantity,
3596 TO_NUMBER(NULL) pick_rule_id,
3597 TO_NUMBER(NULL) pick_slip_number,
3598 TO_NUMBER(NULL) cartonization_id,
3599 inventory_item_id,
3600 TO_NUMBER(NULL) move_order_line_id
3601 FROM mtl_cycle_count_entries
3602 WHERE entry_status_code IN(1, 3)
3603 AND NVL(export_flag, 2) = 2
3604 -- bug 3972076
3605 --AND NVL(TRUNC(count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
3606 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision) wdtv -- inlined wms_dispatchable_tasks_v, bug 2648133
3607 WHERE wdtv.locator_id = loc.inventory_location_id
3608 AND wdtv.organization_id = loc.organization_id
3609 AND wdtv.task_id = l_last_task_id
3610 AND wdtv.wms_task_type_id = l_last_task_type;
3611
3612 -- Added the previous line since the task_id in the view
3613 -- might not be unique since it is the transaction_temp_id
3614 -- if it comes from MMTT but the cycle_count_entry_id if
3615 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
3616 l_progress := '36';
3617 EXCEPTION
3618 WHEN OTHERS THEN
3619 -- locator definition descripency
3620 l_cur_x := 0;
3621 l_cur_y := 0;
3622 l_cur_z := 0;
3623 END;
3624 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
3625 IF l_last_task_type <> 3 THEN -- not cycle count task
3626 -- get the location from mtl_material_transactions
3627 BEGIN
3628 l_progress := '37';
3629
3630 -- use Nvl to make sure if coordinates not defined, use 0
3631 SELECT NVL(loc.x_coordinate, 0)
3632 , NVL(loc.y_coordinate, 0)
3633 , NVL(loc.z_coordinate, 0)
3634 INTO l_cur_x
3635 , l_cur_y
3636 , l_cur_z
3637 FROM mtl_item_locations loc, mtl_material_transactions mmt
3638 WHERE mmt.locator_id = loc.inventory_location_id
3639 AND mmt.organization_id = loc.organization_id
3640 AND mmt.transaction_set_id = l_last_task_id
3641 AND ROWNUM = 1;
3642
3643 l_progress := '38';
3644 EXCEPTION
3645 WHEN OTHERS THEN
3646 -- locator definition descripency
3647 l_cur_x := 0;
3648 l_cur_y := 0;
3649 l_cur_z := 0;
3650 END;
3651 ELSE -- l_last_task_type <> 3 (Cyclt Count task)
3652 -- get the location from mtl_cycle_count_entries
3653 BEGIN
3654 l_progress := '39';
3655
3656 -- use Nvl to make sure if coordinates not defined, use 0
3657 SELECT NVL(loc.x_coordinate, 0)
3658 , NVL(loc.y_coordinate, 0)
3659 , NVL(loc.z_coordinate, 0)
3660 INTO l_cur_x
3661 , l_cur_y
3662 , l_cur_z
3663 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
3664 WHERE mcce.locator_id = loc.inventory_location_id
3665 AND mcce.organization_id = loc.organization_id
3666 AND mcce.cycle_count_entry_id = l_last_task_id;
3667
3668 l_progress := '40';
3669 EXCEPTION
3670 WHEN OTHERS THEN -- adf
3671 -- locator definition descripency
3672 l_cur_x := 0;
3673 l_cur_y := 0;
3674 l_cur_z := 0;
3675 END;
3676 END IF; -- l_last_task_type <> 3
3677 END IF; -- l_last_task_is_drop <> TRUE
3678 ELSE -- there is not a previous task at all
3679 l_cur_x := 0;
3680 l_cur_y := 0;
3681 l_cur_z := 0;
3682 END IF; -- l_last_task_id <> -1
3683
3684 l_progress := '45';
3685
3686 -- Select the most optimal task
3687 -- first select eligible tasks according to employee sign on information
3688 -- order tasks by task priority, locator picking order and locator coordinates
3689 -- approximated to current locator
3690
3691 IF (l_debug = 1) THEN
3692 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
3693 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
3694 print_debug('l_cartonization_id => ' || l_cartonization_id, 4);
3695 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
3696 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
3697 print_debug('l_cur_x => ' || l_cur_x, 4);
3698 print_debug('l_cur_y => ' || l_cur_y, 4);
3699 print_debug('l_cur_z => ' || l_cur_z, 4);
3700 END IF;
3701 --Bug 7254397, added loop for detecting and storing
3702 IF p_task_method = 'CLUSTERPICKBYLABEL' THEN
3703 BEGIN
3704 l_total_lpns := wms_picking_pkg.get_total_lpns;
3705 l_locked_lpns := 0;
3706 FOR lpn_id_rec IN lpn_ids_cur
3707 LOOP
3708 IF l_debug = 1 THEN
3709 print_debug('Check carton ID '|| lpn_id_rec.LPN_ID || ' for locking.', 4);
3710 END IF;
3711
3712 BEGIN
3713 OPEN c_carton_lock_check(lpn_id_rec.LPN_ID);
3714 CLOSE c_carton_lock_check;
3715
3716 EXCEPTION
3717 WHEN OTHERS THEN
3718 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3719 l_locked_lpns := l_locked_lpns + 1;
3720 IF l_debug = 1 THEN
3721 print_debug('Carton ' || lpn_id_rec.LPN_ID ||' is locked by other user. ', 4);
3722 END IF;
3723 store_locked_tasks
3724 (p_grp_doc_type => p_task_method,
3725 p_grp_doc_num => lpn_id_rec.LPN_ID,
3726 p_grp_src_type_id => NULL,
3727 x_return_status => l_return_status);
3728
3729 IF l_debug = 1 THEN
3730 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
3731 END IF;
3732
3733 IF l_return_status = fnd_api.g_ret_sts_error THEN
3734 RAISE fnd_api.g_exc_error;
3735 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3736 RAISE fnd_api.g_exc_unexpected_error;
3737 END IF;
3738 IF l_locked_lpns = l_total_lpns THEN
3739 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
3740 fnd_msg_pub.ADD;
3741
3742 IF (l_debug = 1) THEN
3743 print_debug('dispatch_task - No eligible picking tasks ', 4);
3744 END IF;
3745 RAISE fnd_api.g_exc_error;
3746 END IF;
3747 l_return_status := fnd_api.g_ret_sts_success;
3748 END IF;
3749
3750 IF c_carton_lock_check%isopen THEN
3751 CLOSE c_carton_lock_check;
3752 END IF;
3753 END;
3754 END LOOP;
3755 END;
3756 END IF;
3757 -- Bug 7254397
3758 --Added for Case Picking Project start
3759 IF p_task_method = 'MANIFESTORDER' THEN
3760 BEGIN
3761 FOR c_order_numbers_rec IN c_order_numbers
3762 LOOP
3763 BEGIN
3764 OPEN c_manifest_order_lock_check(c_order_numbers_rec.sales_order_id);
3765 CLOSE c_manifest_order_lock_check;
3766 IF l_debug = 1 THEN
3767 print_debug('c_order_lock_check ORDER ID ' ||c_order_numbers_rec.sales_order_id, 4);
3768 END IF;
3769 EXCEPTION
3770 WHEN OTHERS THEN
3771 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3772 IF l_debug = 1 THEN
3773 print_debug('Sales order id ' || c_order_numbers_rec.sales_order_id||'is locked by other user. ', 4);
3774 END IF;
3775 store_locked_tasks(p_grp_doc_type => p_task_method,
3776 p_grp_doc_num =>c_order_numbers_rec.sales_order_id ,
3777 p_grp_src_type_id => NULL,
3778 x_return_status => l_return_status);
3779 IF l_return_status = fnd_api.g_ret_sts_error THEN
3780 RAISE fnd_api.g_exc_error;
3781 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3782 RAISE fnd_api.g_exc_unexpected_error;
3783 END IF;
3784 l_return_status := fnd_api.g_ret_sts_success;
3785 END IF;
3786 IF c_manifest_order_lock_check%isopen THEN
3787 CLOSE c_manifest_order_lock_check;
3788 END IF;
3789 END;
3790 END LOOP;
3791 END;
3792 END IF;
3793 IF p_task_method = 'MANIFESTPICKSLIP' THEN
3794 BEGIN
3795 FOR c_pick_slip_numbers_rec IN c_pick_slip_numbers
3796 LOOP
3797 BEGIN
3798 OPEN c_pick_slip_lock_check(c_pick_slip_numbers_rec.pick_slip_number);
3799 CLOSE c_pick_slip_lock_check;
3800 IF l_debug = 1 THEN
3801 print_debug('c_pick_slip_lock_check Pick Slip ' ||c_pick_slip_numbers_rec.pick_slip_number, 4);
3802 END IF;
3803 EXCEPTION
3804 WHEN OTHERS THEN
3805 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3806 IF l_debug = 1 THEN
3807 print_debug('Pick Slip ' ||c_pick_slip_numbers_rec.pick_slip_number ||' is locked by other user. ', 4);
3808 END IF;
3809 store_locked_tasks(p_grp_doc_type => p_task_method,
3810 p_grp_doc_num => c_pick_slip_numbers_rec.pick_slip_number,
3811 p_grp_src_type_id => NULL,
3812 x_return_status => l_return_status);
3813 IF l_return_status = fnd_api.g_ret_sts_error THEN
3814 RAISE fnd_api.g_exc_error;
3815 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3816 RAISE fnd_api.g_exc_unexpected_error;
3817 END IF;
3818 l_return_status := fnd_api.g_ret_sts_success;
3819 END IF;
3820 IF c_pick_slip_lock_check%isopen THEN
3821 CLOSE c_pick_slip_lock_check;
3822 END IF;
3823 END;
3824 END LOOP;
3825 END;
3826 END IF;
3827 --Added for Case Picking Project end
3828 --Modified for Case Picking Project
3829 IF (p_task_method IN ('CLUSTERPICKBYLABEL','MANIFESTPICKSLIP','MANIFESTORDER')) THEN
3830 GOTO end_loop;
3831 END IF;
3832 -- open and fetch appropriate cursor
3833 -- start bug 2832818
3834 LOOP -- added loop for detecting lock for a pick slip
3835 l_is_locked := FALSE;
3836 -- bug 4358107
3837 l_pick_slip := 0;
3838 l_transaction_source_id := NULL;
3839 l_transaction_source_type_id := NULL;
3840 l_transaction_action_id := NULL;
3841 l_transaction_type_id := NULL;
3842 l_task_id := NULL;
3843 l_task_type_id := NULL;
3844 l_task_priority := NULL;
3845 l_batch_id := NULL;
3846 l_loc_pick_order := NULL;
3847 l_distance := NULL;
3848 l_task_status := NULL;
3849 -- bug 4358107
3850 -- end bug 2832818
3851
3852 IF p_sign_on_zone IS NOT NULL THEN -- subinventory passed in
3853
3854 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3855
3856 IF (l_debug = 1) THEN
3857 print_debug('Opt task cursor: subinventory passed, both cycle count and non cycle count', 4);
3858 END IF;
3859
3860 OPEN l_curs_opt_task_111;
3861
3862 FETCH l_curs_opt_task_111
3863 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3864 l_sub_pick_order, l_loc_pick_order, l_distance,
3865 l_task_status, l_transaction_type_id,
3866 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3867
3868 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3869
3870 IF (l_debug = 1) THEN
3871 print_debug('Opt task cursor: subinventory passed, only non cycle count', 4);
3872 print_debug('Opt task cursor: l_curs_opt_task_110', 4);
3873 END IF;
3874
3875 OPEN l_curs_opt_task_110;
3876
3877 FETCH l_curs_opt_task_110
3878 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3879 l_sub_pick_order, l_loc_pick_order, l_distance,
3880 l_task_status, l_transaction_type_id,
3881 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3882
3883 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3884
3885 IF (l_debug = 1) THEN
3886 print_debug('Opt task cursor: subinventory passed, only non cycle count', 4);
3887 END IF;
3888
3889 OPEN l_curs_opt_task_101;
3890
3891 FETCH l_curs_opt_task_101
3892 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3893 l_sub_pick_order, l_loc_pick_order, l_distance,
3894 l_task_status, l_transaction_type_id,
3895 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3896
3897 END IF;
3898
3899 ELSE -- No subinventory passed in
3900
3901 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3902
3903 IF (l_debug = 1) THEN
3904 print_debug('Opt task cursor: subinventory not passed, both cycle count and non cycle count', 4);
3905 END IF;
3906
3907 OPEN l_curs_opt_task_011;
3908
3909 FETCH l_curs_opt_task_011
3910 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3911 l_sub_pick_order, l_loc_pick_order, l_distance,
3912 l_task_status, l_transaction_type_id,
3913 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3914
3915 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3916
3917 IF (l_debug = 1) THEN
3918 print_debug('Opt task cursor: subinventory not passed, only non cycle count', 4);
3919 print_debug('Opt task cursor: l_curs_opt_task_010', 4);
3920 END IF;
3921
3922 OPEN l_curs_opt_task_010;
3923
3924 FETCH l_curs_opt_task_010
3925 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3926 l_sub_pick_order, l_loc_pick_order, l_distance,
3927 l_task_status, l_transaction_type_id,
3928 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3929
3930 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3931
3932 IF (l_debug = 1) THEN
3933 print_debug('Opt task cursor: subinventory not passed, only non cycle count', 4);
3934 print_debug('Opt task cursor: l_curs_opt_task_001', 4);
3935 END IF;
3936
3937 OPEN l_curs_opt_task_001;
3938
3939 FETCH l_curs_opt_task_001
3940 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3941 l_sub_pick_order, l_loc_pick_order, l_distance,
3942 l_task_status, l_transaction_type_id,
3943 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3944
3945 END IF;
3946
3947 END IF;
3948
3949 -- Wave, Discrete, Order, Cluster, Label, Manual, Bulk
3950 IF l_task_type_id <> 3 THEN -- Check the lock for non cycle count tasks
3951 IF p_task_method IN ('WAVE', 'BULK') THEN
3952 IF l_debug = 1 THEN
3953 print_debug('Check task '|| l_task_id || ' for locking.', 4);
3954 END IF;
3955
3956 BEGIN
3957 OPEN c_task_lock_check(l_task_id);
3958 CLOSE c_task_lock_check;
3959 EXCEPTION
3960 WHEN OTHERS THEN
3961 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3962 l_is_locked := TRUE;
3963
3964 IF l_debug = 1 THEN
3965 print_debug('Task ' || l_task_id ||' is locked by other user. ', 4);
3966 END IF;
3967
3968 ELSE
3969 l_is_locked := FALSE;
3970 END IF;
3971
3972 IF c_task_lock_check%isopen THEN
3973 CLOSE c_task_lock_check;
3974 END IF;
3975 END;
3976 ELSIF p_task_method = 'DISCRETE' THEN
3977 IF l_debug = 1 THEN
3978 print_debug('Check pick_slip_number'|| l_pick_slip || ' for locking.', 4);
3979 END IF;
3980
3981 BEGIN
3982 OPEN c_pick_slip_lock_check(l_pick_slip);
3983 CLOSE c_pick_slip_lock_check;
3984
3985 l_is_locked := FALSE;
3986 x_grouping_document_type := 'PICK_SLIP';
3987 x_grouping_document_number := l_pick_slip;
3988 x_grouping_source_type_id := l_transaction_source_type_id;
3989
3990 EXCEPTION
3991 WHEN OTHERS THEN
3992 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3993 l_is_locked := TRUE;
3994
3995 IF l_debug = 1 THEN
3996 print_debug('pick_slip_number ' || l_pick_slip ||' is locked by other user. ', 4);
3997 END IF;
3998 -- bug 4358107
3999 store_locked_tasks
4000 (p_grp_doc_type => p_task_method,
4001 p_grp_doc_num => l_pick_slip,
4002 p_grp_src_type_id => NULL,
4003 x_return_status => l_return_status);
4004
4005 IF l_debug = 1 THEN
4006 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
4007 END IF;
4008
4009 IF l_return_status = fnd_api.g_ret_sts_error THEN
4010 RAISE fnd_api.g_exc_error;
4011 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4012 RAISE fnd_api.g_exc_unexpected_error;
4013 END IF;
4014 l_return_status := fnd_api.g_ret_sts_success;
4015 -- bug 4358107
4016
4017 END IF;
4018
4019 IF c_pick_slip_lock_check%isopen THEN
4020 CLOSE c_pick_slip_lock_check;
4021 END IF;
4022 END;
4023 ELSIF p_task_method = 'ORDERPICK' THEN
4024 IF l_debug = 1 THEN
4025 print_debug('Check order '|| l_transaction_source_id || ' for locking.', 4);
4026 END IF;
4027
4028 BEGIN
4029 OPEN c_order_lock_check(l_transaction_source_id,
4030 l_transaction_source_type_id,
4031 l_transaction_action_id,
4032 l_transaction_type_id);
4033 CLOSE c_order_lock_check;
4034
4035 l_is_locked := FALSE;
4036 x_grouping_document_type := 'ORDER';
4037 x_grouping_document_number := l_transaction_source_id;
4038 x_grouping_source_type_id := l_transaction_source_type_id;
4039
4040 EXCEPTION
4041 WHEN OTHERS THEN
4042 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
4043 l_is_locked := TRUE;
4044
4045 IF l_debug = 1 THEN
4046 print_debug('Order ' || l_transaction_source_id ||' is locked by other user. ', 4);
4047 END IF;
4048 -- bug 4358107
4049 store_locked_tasks
4050 (p_grp_doc_type => p_task_method,
4051 p_grp_doc_num => l_transaction_source_id,
4052 p_grp_src_type_id => l_transaction_source_type_id,
4053 x_return_status => l_return_status);
4054
4055 IF l_debug = 1 THEN
4056 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
4057 END IF;
4058
4059 IF l_return_status = fnd_api.g_ret_sts_error THEN
4060 RAISE fnd_api.g_exc_error;
4061 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4062 RAISE fnd_api.g_exc_unexpected_error;
4063 END IF;
4064 l_return_status := fnd_api.g_ret_sts_success;
4065 -- bug 4358107
4066
4067 END IF;
4068
4069 IF c_order_lock_check%isopen THEN
4070 CLOSE c_order_lock_check;
4071 END IF;
4072 END;
4073 ELSIF p_task_method = 'PICKBYLABEL' THEN
4074 IF l_debug = 1 THEN
4075 print_debug('Check carton ID '|| l_cartonization_id || ' for locking.', 4);
4076 END IF;
4077
4078 BEGIN
4079 OPEN c_carton_lock_check(l_cartonization_id);
4080 CLOSE c_carton_lock_check;
4081
4082 l_is_locked := FALSE;
4083 x_grouping_document_type := 'CARTON';
4084 x_grouping_document_number := l_cartonization_id;
4085 x_grouping_source_type_id := l_transaction_source_type_id;
4086
4087 EXCEPTION
4088 WHEN OTHERS THEN
4089 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
4090 l_is_locked := TRUE;
4091
4092 IF l_debug = 1 THEN
4093 print_debug('Carton ' || l_cartonization_id ||' is locked by other user. ', 4);
4094 END IF;
4095 -- bug 4358107
4096 store_locked_tasks
4097 (p_grp_doc_type => p_task_method,
4098 p_grp_doc_num => l_cartonization_id,
4099 p_grp_src_type_id => NULL,
4100 x_return_status => l_return_status);
4101
4102 IF l_debug = 1 THEN
4103 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
4104 END IF;
4105
4106 IF l_return_status = fnd_api.g_ret_sts_error THEN
4107 RAISE fnd_api.g_exc_error;
4108 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4109 RAISE fnd_api.g_exc_unexpected_error;
4110 END IF;
4111 l_return_status := fnd_api.g_ret_sts_success;
4112 -- bug 4358107
4113
4114 END IF;
4115
4116 IF c_carton_lock_check%isopen THEN
4117 CLOSE c_carton_lock_check;
4118 END IF;
4119 END;
4120 END IF;
4121 ELSE -- Check the lock for cycle count tasks
4122 IF l_debug = 1 THEN
4123 print_debug('Check cycle count task '|| l_task_id || ' for locking.', 4);
4124 END IF;
4125
4126 BEGIN
4127 OPEN c_cycle_count_lock_check(l_task_id);
4128 CLOSE c_cycle_count_lock_check;
4129
4130 l_is_locked := FALSE;
4131 x_grouping_document_type := 'TASK';
4132 x_grouping_document_number := l_task_id;
4133 x_grouping_source_type_id := l_transaction_source_type_id;
4134 EXCEPTION
4135 WHEN OTHERS THEN
4136 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
4137 l_is_locked := TRUE;
4138
4139 IF l_debug = 1 THEN
4140 print_debug('Cycle count task ' || l_task_id ||' is locked by other user. ', 4);
4141 END IF;
4142
4143 END IF;
4144
4145 IF c_cycle_count_lock_check%isopen THEN
4146 CLOSE c_cycle_count_lock_check;
4147 END IF;
4148 END;
4149
4150 END IF;
4151
4152 IF p_sign_on_zone IS NOT NULL THEN -- subinventory passed in
4153 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
4154 CLOSE l_curs_opt_task_111;
4155 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
4156 CLOSE l_curs_opt_task_110;
4157 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
4158 CLOSE l_curs_opt_task_101;
4159 END IF;
4160 ELSE -- No subinventory passed in
4161 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
4162 CLOSE l_curs_opt_task_011;
4163 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
4164 CLOSE l_curs_opt_task_010;
4165 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
4166 CLOSE l_curs_opt_task_001;
4167 END IF;
4168 END IF;
4169
4170 IF l_is_locked = TRUE THEN
4171 l_wait_count := l_wait_count + 1; -- Bug 14094713
4172
4173 IF l_debug = 1 THEN
4174 print_debug('Continue looking for most optimal task since there is a lock for this pick slip..l_wait_count:' || l_wait_count, 4); -- Bug 14094713
4175 END IF;
4176 ELSE
4177 IF l_debug = 1 THEN
4178 print_debug('There is no lock, got the most optimal task..l_wait_count:' || l_wait_count, 4); -- Bug 14094713
4179 END IF;
4180 l_wait_count := 0; -- Bug 14094713
4181 /* Fix for the bug 3837944 Bug 3853837 .
4182 The below block is to check whether any task has been dispatched to some other user
4183 for the same carton. If yes, this user will not get the task.Should not allow cyclecount task */
4184 --Bug 4078696
4185 IF (( l_task_id IS NOT NULL) AND (l_task_type_id <> 3)) THEN
4186 BEGIN
4187 IF l_debug = 1 THEN
4188 print_debug('The trx temp id :' || l_task_id , 4);
4189 END IF;
4190 /*Take the LPN_ID from MMTT*/
4191 l_lpn_id := NULL;
4192 SELECT cartonization_id INTO l_lpn_id
4193 FROM mtl_material_transactions_temp mmtt
4194 WHERE mmtt.transaction_temp_id= l_task_id;
4195
4196
4197
4198
4199 IF l_debug = 1 THEN
4200 print_debug('The carton id :' || l_lpn_id || 'Current employee id :'|| p_sign_on_emp_id, 4);
4201 END IF;
4202
4203 /*Check if any task has been dispatched to other users for the same LPN*/
4204 IF l_lpn_id IS NOT NULL THEN
4205 l_wdt_count := 0 ;
4206 SELECT count(1) INTO l_wdt_count FROM wms_dispatched_tasks wdt, mtl_material_transactions_temp mmtt
4207 WHERE mmtt.cartonization_id = l_lpn_id
4208 AND wdt.transaction_temp_id = mmtt.transaction_temp_id
4209 AND wdt.status in(3,9) AND wdt.person_id <> p_sign_on_emp_id ;
4210
4211 IF l_debug = 1 THEN
4212 print_debug('The tasks dispatched to other user :'|| l_wdt_count,4);
4213 END IF;
4214
4215 IF l_wdt_count > 0 then --There tasks dispatched to other users for this LPN
4216 l_task_id := NULL;
4217 -- 6598260 start
4218 IF l_debug = 1 THEN
4219 print_debug('cartonized tasks START',4);
4220 END IF;
4221
4222 store_locked_tasks (p_grp_doc_type =>'CARTON_TASK',
4223 p_grp_doc_num => l_lpn_id,
4224 p_grp_src_type_id => NULL,
4225 x_return_status => l_return_status);
4226 IF l_debug = 1 THEN
4227 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' l_lpn_id :- '|| l_lpn_id, 4);
4228 END IF;
4229
4230 IF l_return_status = fnd_api.g_ret_sts_error THEN
4231 RAISE fnd_api.g_exc_error;
4232 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4233 RAISE fnd_api.g_exc_unexpected_error;
4234 END IF;
4235 l_return_status := fnd_api.g_ret_sts_success;
4236
4237 IF l_debug = 1 THEN
4238 print_debug('cartonized tasks end',4);
4239 END IF;
4240 -- 6598260 end
4241 IF l_debug = 1 THEN
4242 print_debug('There are tasks dispatched to other users for this carton ',4);
4243 END IF;
4244
4245 ELSE --No tasks dispatched to other users for this carton.
4246 EXIT;
4247 END IF;
4248 ELSE --LPN id is NULL .This is not a cartonization task.
4249 EXIT;
4250 END IF;
4251 EXCEPTION
4252 WHEN OTHERS THEN
4253 IF l_debug = 1 THEN
4254 print_debug('Exception occured when checking for dispatched tasks to other users ',4);
4255 END IF;
4256 EXIT;--v1
4257 END;
4258 ELSE --l_opt_task_id is NULL.
4259 EXIT;
4260 END IF;
4261 /* End of fix fir bug 3837944 Bug3853837 */
4262 END IF;--l_is_locked
4263 IF l_debug = 1 THEN -- Bug 14094713
4264 print_debug('l_wait_count:' || l_wait_count,4);
4265 END IF;
4266 IF l_wait_count >= 1000 THEN -- Bug 14094713
4267 IF l_debug = 1 THEN
4268 print_debug('Skipping the locked record after 1000 tries ..p_task_method:' || p_task_method,4);
4269 END IF;
4270 EXIT;
4271 END IF;
4272 END LOOP;
4273 <<end_loop>> -- Bug 7254397
4274 -- End bug fix 2832818
4275
4276 /* Bug 14094713 starts */
4277 IF ( l_wait_count >= 1000 AND p_task_method NOT IN ('CLUSTERPICKBYLABEL','MANIFESTORDER','MANIFESTPICKSLIP') )THEN
4278 l_wait_count := 0;
4279 IF p_task_method = 'DISCRETE' THEN
4280 IF l_debug = 1 THEN
4281 print_debug('Displaying WMS_LOCKED_PICKSLIP_TASK',4);
4282 END IF;
4283 FND_MESSAGE.set_name('WMS', 'WMS_LOCKED_PICKSLIP_TASK');
4284 FND_MESSAGE.set_token('ENTITY1',l_task_id);
4285 FND_MESSAGE.set_token('ENTITY2',l_pick_slip);
4286 fnd_msg_pub.ADD;
4287 RAISE fnd_api.g_exc_error;
4288 ELSIF p_task_method = 'ORDERPICK' THEN
4289 IF l_transaction_type_id = 52 THEN
4290 SELECT SEGMENT1 INTO l_transaction_source_id FROM mtl_sales_orders WHERE sales_order_id=l_transaction_source_id;
4291 END IF;
4292 FND_MESSAGE.set_name('WMS', 'WMS_LOCKED_ORDERPICK_TASK');
4293 FND_MESSAGE.set_token('ENTITY1',l_transaction_source_id);
4294 fnd_msg_pub.ADD;
4295 RAISE fnd_api.g_exc_error;
4296 IF l_debug = 1 THEN
4297 print_debug('Displaying WMS_LOCKED_ORDERPICK_TASK',4);
4298 END IF;
4299 END IF;
4300 END IF;
4301 /* Bug 14094713 ends */
4302
4303 --Modified for Case Picking Project
4304 IF ( l_task_id IS NULL AND p_task_method NOT IN ('CLUSTERPICKBYLABEL','MANIFESTORDER','MANIFESTPICKSLIP') ) THEN --Bug 7254397
4305 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
4306 fnd_msg_pub.ADD;
4307
4308 IF (l_debug = 1) THEN
4309 print_debug('dispatch_task - No eligible picking tasks ', 4);
4310 END IF;
4311
4312 RAISE fnd_api.g_exc_error;
4313 END IF;
4314
4315 IF p_task_method <> 'ORDERPICK' THEN
4316 l_transaction_source_id := NULL;
4317 END IF;
4318
4319 IF (l_debug = 1) THEN
4320 print_debug('Pick Slip: ' || l_pick_slip, 4);
4321 print_debug('Task Type: ' || l_task_type_id, 4);
4322 print_debug('Task ID: ' || l_task_id, 4);
4323 print_debug('Transaction Source ID: ' || l_transaction_source_id, 4);
4324 END IF;
4325
4326 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4327 OPEN l_curs_ordered_tasks_11(l_pick_slip, l_task_id, l_task_type_id, l_transaction_source_id);
4328 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4329 OPEN l_curs_ordered_tasks_10(l_pick_slip, l_task_id, l_task_type_id, l_transaction_source_id);
4330 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4331 OPEN l_curs_ordered_tasks_01(l_task_id, l_task_type_id);
4332 END IF;
4333
4334 l_progress := '50';
4335 l_first_task_pick_slip_number := -1;
4336 l_ordered_tasks_count := 0;
4337
4338 LOOP
4339
4340 IF (l_debug = 1) THEN
4341 print_debug('Start looping through ordered tasks: ', 4);
4342 END IF;
4343
4344 l_task_id := NULL;
4345
4346 l_is_locked := FALSE;
4347 l_progress := '60';
4348
4349 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4350 IF (l_debug = 1) THEN
4351 print_debug('Both cycle count and non cycle count tasks allowed: ', 4);
4352 END IF;
4353
4354 FETCH l_curs_ordered_tasks_11
4355 INTO
4356 l_task_id,
4357 l_subinventory_code,
4358 l_locator_id,
4359 l_pick_slip,
4360 l_transaction_uom,
4361 l_transaction_quantity,
4362 l_lot_number,
4363 l_operation_plan_id,
4364 l_standard_operation_id,
4365 l_effective_start_date,
4366 l_effective_end_date,
4367 l_person_resource_id,
4368 l_machine_resource_id,
4369 l_task_type_id,
4370 l_task_priority,
4371 l_batch_id,
4372 l_move_order_line_id,
4373 l_sub_pick_order,
4374 l_loc_pick_order,
4375 l_distance,
4376 l_task_status,
4377 l_transaction_type_id,
4378 l_transaction_action_id,
4379 l_transaction_source_id,
4380 l_transaction_source_type_id;
4381
4382 EXIT WHEN l_curs_ordered_tasks_11%notfound;
4383
4384 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4385
4386 IF (l_debug = 1) THEN
4387 print_debug('Only non cycle count tasks allowed: ', 4);
4388 END IF;
4389
4390 FETCH l_curs_ordered_tasks_10
4391 INTO
4392 l_task_id,
4393 l_subinventory_code,
4394 l_locator_id,
4395 l_pick_slip,
4396 l_transaction_uom,
4397 l_transaction_quantity,
4398 l_lot_number,
4399 l_operation_plan_id,
4400 l_standard_operation_id,
4401 l_effective_start_date,
4402 l_effective_end_date,
4403 l_person_resource_id,
4404 l_machine_resource_id,
4405 l_task_type_id,
4406 l_task_priority,
4407 l_batch_id,
4408 l_move_order_line_id,
4409 l_sub_pick_order,
4410 l_loc_pick_order,
4411 l_distance,
4412 l_task_status,
4413 l_transaction_type_id,
4414 l_transaction_action_id,
4415 l_transaction_source_id,
4416 l_transaction_source_type_id;
4417
4418 EXIT WHEN l_curs_ordered_tasks_10%notfound;
4419
4420 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4421
4422 IF (l_debug = 1) THEN
4423 print_debug('Only cycle count tasks allowed: ', 4);
4424 END IF;
4425
4426 FETCH l_curs_ordered_tasks_01
4427 INTO
4428 l_task_id,
4429 l_subinventory_code,
4430 l_locator_id,
4431 l_pick_slip,
4432 l_transaction_uom,
4433 l_transaction_quantity,
4434 l_lot_number,
4435 l_operation_plan_id,
4436 l_standard_operation_id,
4437 l_effective_start_date,
4438 l_effective_end_date,
4439 l_person_resource_id,
4440 l_machine_resource_id,
4441 l_task_type_id,
4442 l_task_priority,
4443 l_batch_id,
4444 l_move_order_line_id,
4445 l_sub_pick_order,
4446 l_loc_pick_order,
4447 l_distance,
4448 l_task_status,
4449 l_transaction_type_id,
4450 l_transaction_action_id,
4451 l_transaction_source_id,
4452 l_transaction_source_type_id;
4453
4454 EXIT WHEN l_curs_ordered_tasks_01%notfound;
4455
4456 END IF;
4457
4458 l_progress := '70';
4459
4460 IF (l_debug = 1) THEN
4461 print_debug('Task ID => ' || l_task_id, 4);
4462 print_debug('Pick Slip => ' || l_pick_slip, 4);
4463 print_debug('Task Type => ' || l_task_type_id, 4);
4464 print_debug('Trx Src => ' || l_transaction_source_id, 4);
4465 print_debug('Trx Srx Type => ' || l_transaction_source_type_id, 4);
4466 END IF;
4467
4468 l_ordered_tasks_count := l_ordered_tasks_count + 1;
4469
4470 IF (l_debug = 1) THEN
4471 print_debug('This is the first task in this group. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
4472 END IF;
4473
4474 l_progress := '72';
4475
4476 INSERT INTO wms_ordered_tasks
4477 (task_id,
4478 wms_task_type,
4479 task_sequence_id,
4480 subinventory_code,
4481 locator_id,
4482 revision,
4483 transaction_uom,
4484 transaction_quantity,
4485 lot_number,
4486 priority,
4487 operation_plan_id,
4488 standard_operation_id,
4489 effective_start_date,
4490 effective_end_date,
4491 person_resource_id,
4492 machine_resource_id,
4493 move_order_line_id)
4494 VALUES
4495 (l_task_id,
4496 l_task_type_id,
4497 l_ordered_tasks_count,
4498 l_subinventory_code,
4499 l_locator_id,
4500 l_revision,
4501 l_transaction_uom,
4502 l_transaction_quantity,
4503 l_lot_number,
4504 l_task_priority,
4505 l_operation_plan_id,
4506 l_standard_operation_id,
4507 l_effective_start_date,
4508 l_effective_end_date,
4509 l_person_resource_id,
4510 l_machine_resource_id,
4511 l_move_order_line_id);
4512
4513 l_progress := '73';
4514
4515 END LOOP;
4516
4517 --Bug 7254397: Clear ...GTMP table
4518 IF p_task_method = 'CLUSTERPICKBYLABEL' THEN
4519 remove_stored_cartons(x_return_status => l_return_status);
4520 IF l_debug = 1 THEN
4521 print_debug('Return Status after the call to remove_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
4522 END IF;
4523 IF l_return_status = fnd_api.g_ret_sts_error THEN
4524 RAISE fnd_api.g_exc_error;
4525 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4526 RAISE fnd_api.g_exc_unexpected_error;
4527 END IF;
4528 l_return_status := fnd_api.g_ret_sts_success;
4529 END IF;--Bug 7254397: Clear ...GTMP table end
4530
4531 --Added for Case Picking Project start
4532 IF p_task_method = 'MANIFESTORDER' THEN
4533 remove_stored_order_num(x_return_status => l_return_status);
4534 print_debug('dispatch_task - remove_stored_order_numbers l_return_status'||l_return_status, 4);
4535 --Adding below for Bug 13644087 - START - For manifest picking,there will be multiple order
4536 --numbers and the tasks of all the orders are considered as a single group and inserted into WDT
4537 --Tasks for manifest picking are not returned based on the x_grouping_document_number,they are based
4538 --on TABLE(list_order_numbers).Refer get_next_task_in_group for criteria used to return tasks for manifest picking.
4539 --So here just assigning the l_transaction_source_id returned from the l_curs_ordered_tasks_xx cursor
4540 --so as to just satisy the condition "p_task_method NOT IN ('MANUAL') AND x_grouping_document_number IS NOT NULL"
4541 --in WMS_PICKING_PKG.NEXT_TASK while returning the dispatched tasks.
4542 x_grouping_document_number := l_transaction_source_id;
4543 IF l_debug = 1 THEN
4544 print_debug('PRINTING x_grouping_document_number for MANIFEST ORDER Picking::'||x_grouping_document_number, 4);
4545 END IF;
4546 x_grouping_source_type_id := l_transaction_source_type_id;
4547 IF l_debug = 1 THEN
4548 print_debug('PRINTING x_grouping_source_type_id for MANIFEST ORDER Picking::'||x_grouping_source_type_id, 4);
4549 END IF;
4550 --Adding for Bug 13644087 - END
4551 ELSIF p_task_method = 'MANIFESTPICKSLIP' THEN
4552 remove_stored_pick_slip_num(x_return_status => l_return_status);
4553 print_debug('dispatch_task - remove_stored_pick_slip_numbers l_return_status'||l_return_status, 4);
4554 --Adding below for Bug 13644087 - START - Here not assigning the transaction source type id beacuse i)there may
4555 --different transaction source types ii)transaction source type is not a criteria in fetching the tasks in
4556 --WMS_PICKING_PKG.get_next_task_in_group for MANIFESTPICKSLIP task method.
4557 x_grouping_document_number := l_pick_slip;
4558 IF l_debug = 1 THEN
4559 print_debug('PRINTING x_grouping_document_number for MANIFEST PICK SLIP Picking::'||x_grouping_document_number, 4);
4560 END IF;
4561 --Adding for Bug 13644087 - END
4562 END IF;
4563 --Added for Case Picking Project end
4564
4565
4566 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4567 CLOSE l_curs_ordered_tasks_11;
4568 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4569 CLOSE l_curs_ordered_tasks_10;
4570 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4571 CLOSE l_curs_ordered_tasks_01;
4572 END IF;
4573
4574 IF (l_debug = 1) THEN
4575 print_debug('Total number of tasks dispatched: => ' || l_ordered_tasks_count, 4);
4576 END IF;
4577
4578 IF l_ordered_tasks_count = 0 THEN
4579 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
4580 fnd_msg_pub.ADD;
4581
4582 IF (l_debug = 1) THEN
4583 print_debug('dispatch_task - No eligible picking tasks ', 4);
4584 END IF;
4585
4586 RAISE fnd_api.g_exc_error;
4587 END IF;
4588
4589 l_progress := '90';
4590
4591 -- open reference cursor for this statement
4592
4593 IF (l_debug = 1) THEN
4594 print_debug('Before opening reference cursor ', 4);
4595 END IF;
4596
4597 OPEN x_task_cur FOR
4598 SELECT
4599 task_id,
4600 subinventory_code,
4601 locator_id,
4602 revision,
4603 transaction_uom,
4604 transaction_quantity,
4605 lot_number,
4606 wms_task_type,
4607 priority,
4608 operation_plan_id,
4609 standard_operation_id,
4610 effective_start_date,
4611 effective_end_date,
4612 person_resource_id,
4613 machine_resource_id,
4614 move_order_line_id
4615 FROM wms_ordered_tasks
4616 ORDER BY task_sequence_id;
4617
4618 l_progress := '120';
4619 EXCEPTION
4620 WHEN fnd_api.g_exc_error THEN
4621 x_return_status := fnd_api.g_ret_sts_error;
4622
4623 IF l_curs_ordered_tasks_11%ISOPEN THEN
4624 CLOSE l_curs_ordered_tasks_11;
4625 END IF;
4626
4627 IF l_curs_ordered_tasks_01%ISOPEN THEN
4628 CLOSE l_curs_ordered_tasks_01;
4629 END IF;
4630
4631 IF l_curs_ordered_tasks_10%ISOPEN THEN
4632 CLOSE l_curs_ordered_tasks_10;
4633 END IF;
4634
4635 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4636
4637 IF (l_debug = 1) THEN
4638 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4639 END IF;
4640 WHEN fnd_api.g_exc_unexpected_error THEN
4641 x_return_status := fnd_api.g_ret_sts_unexp_error;
4642
4643 IF l_curs_ordered_tasks_11%ISOPEN THEN
4644 CLOSE l_curs_ordered_tasks_11;
4645 END IF;
4646
4647 IF l_curs_ordered_tasks_01%ISOPEN THEN
4648 CLOSE l_curs_ordered_tasks_01;
4649 END IF;
4650
4651 IF l_curs_ordered_tasks_10%ISOPEN THEN
4652 CLOSE l_curs_ordered_tasks_10;
4653 END IF;
4654
4655 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4656
4657 IF (l_debug = 1) THEN
4658 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4659 END IF;
4660 WHEN OTHERS THEN
4661 x_return_status := fnd_api.g_ret_sts_unexp_error;
4662
4663 IF l_curs_ordered_tasks_11%ISOPEN THEN
4664 CLOSE l_curs_ordered_tasks_11;
4665 END IF;
4666
4667 IF l_curs_ordered_tasks_01%ISOPEN THEN
4668 CLOSE l_curs_ordered_tasks_01;
4669 END IF;
4670
4671 IF l_curs_ordered_tasks_10%ISOPEN THEN
4672 CLOSE l_curs_ordered_tasks_10;
4673 END IF;
4674
4675 IF SQLCODE IS NOT NULL THEN
4676 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
4677 END IF;
4678
4679 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4680
4681 IF (l_debug = 1) THEN
4682 print_debug('dispatch_task: Other exception: ' || Sqlerrm || l_progress, 1);
4683 END IF;
4684 END dispatch_task;
4685
4686
4687 -- Old procedure: Not used from 11.5.10
4688
4689 PROCEDURE dispatch_task(
4690 p_api_version IN NUMBER
4691 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
4692 , p_commit IN VARCHAR2 := fnd_api.g_false
4693 , p_sign_on_emp_id IN NUMBER
4694 , p_sign_on_org_id IN NUMBER
4695 , p_sign_on_zone IN VARCHAR2 := NULL
4696 , p_sign_on_equipment_id IN NUMBER := NULL -- specific equip id, NULL or -999. -999 stands for none
4697 , p_sign_on_equipment_srl IN VARCHAR2 := NULL -- same as above
4698 , p_task_type IN VARCHAR2 -- 'PICKING' or 'ALL'
4699 , p_cartonization_id IN NUMBER := NULL
4700 , x_task_cur OUT NOCOPY task_rec_cur_tp
4701 , x_return_status OUT NOCOPY VARCHAR2
4702 , x_msg_count OUT NOCOPY NUMBER
4703 , x_msg_data OUT NOCOPY VARCHAR2
4704 ) IS
4705 l_cur_x NUMBER;
4706 l_cur_y NUMBER;
4707 l_cur_z NUMBER;
4708 l_opt_task_id NUMBER;
4709 l_opt_task_pick_slip NUMBER:= 0; -- bug 2832818 (init value to 0);
4710 l_opt_task_type NUMBER;
4711 l_task_priority NUMBER;
4712 l_mo_header_id NUMBER;
4713 l_sub_pick_order NUMBER;
4714 l_loc_pick_order NUMBER;
4715 l_x_coordinate NUMBER;
4716 l_y_coordinate NUMBER;
4717 l_z_coordinate NUMBER;
4718 l_is_locked BOOLEAN := FALSE;
4719 l_sys_task_type NUMBER;
4720 l_is_express_pick NUMBER := 0; -- 1 for express pick, 0 not
4721 l_sign_on_equipment_id NUMBER;
4722 l_sign_on_equipment_srl VARCHAR2(30);
4723 l_equipment_id_str VARCHAR2(30);
4724 l_last_loaded_time DATE;
4725 l_last_loaded_task_id NUMBER;
4726 l_last_loaded_task_type NUMBER;
4727 l_last_dropoff_time DATE;
4728 l_last_dropoff_task_id NUMBER;
4729 l_last_dropoff_task_type NUMBER;
4730 l_last_task_type NUMBER;
4731 l_last_task_is_drop BOOLEAN := FALSE;
4732 l_last_task_id NUMBER;
4733 l_ordered_tasks_count NUMBER;
4734 l_first_task_pick_slip_number NUMBER;
4735 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
4736 l_api_version CONSTANT NUMBER := 1.0;
4737 l_progress VARCHAR2(10);
4738 l_sequence_picks_across_waves NUMBER := 2;
4739
4740 /* Bug 3856227
4741 Added condition in all the cursors selecting cycle count tasks to select
4742 only those tasks whose cycle count have not been disabled by entering
4743 an Inactive Date.
4744 Added the table mtl_cycle_count_headers in the FROM clause and joined with
4745 mtl_cycle_count_entries and checked for disable_date value with sysdate.
4746 */
4747
4748 -- Cursor # 1 for selecting the most optimal task
4749 -- 1. sub is passed (1)
4750 -- 2. order by across wave (1)
4751 -- 3. not express pick (0)
4752
4753 CURSOR l_curs_opt_task_110 IS
4754 SELECT DISTINCT wdtv.task_id task_id
4755 , NVL(wdtv.pick_slip_number, -1) pick_slip
4756 , wdtv.wms_task_type_id
4757 , nvl(wdtv.task_priority, 0)
4758 , mol.header_id
4759 , sub.picking_order
4760 , loc.picking_order
4761 , nvl(loc.x_coordinate, 0)
4762 , nvl(loc.y_coordinate, 0)
4763 , nvl(loc.z_coordinate, 0)
4764 FROM (SELECT transaction_temp_id task_id
4765 , standard_operation_id user_task_type_id
4766 , wms_task_type wms_task_type_id
4767 , organization_id organization_id
4768 , subinventory_code ZONE
4769 , locator_id locator_id
4770 , task_priority task_priority
4771 , revision revision
4772 , lot_number lot_number
4773 , transaction_uom transaction_uom
4774 , transaction_quantity transaction_quantity
4775 , pick_rule_id pick_rule_id
4776 , pick_slip_number pick_slip_number
4777 , cartonization_id cartonization_id
4778 , inventory_item_id
4779 , move_order_line_id
4780 FROM mtl_material_transactions_temp
4781 WHERE wms_task_type IS NOT NULL
4782 AND transaction_status = 2
4783 AND(wms_task_status IS NULL
4784 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4785 UNION ALL
4786 SELECT MIN(mcce.cycle_count_entry_id) task_id
4787 , MIN(mcce.standard_operation_id) user_task_type_id
4788 , 3 wms_task_type_id
4789 , mcce.organization_id organization_id
4790 , mcce.subinventory ZONE
4791 , mcce.locator_id locator_id
4792 , MIN(mcce.task_priority) task_priority
4793 , mcce.revision revision
4794 , MIN(mcce.lot_number) lot_number
4795 , '' transaction_uom
4796 , TO_NUMBER(NULL) transaction_quantity
4797 , TO_NUMBER(NULL) pick_rule_id
4798 , TO_NUMBER(NULL) pick_slip_number
4799 , TO_NUMBER(NULL) cartonization_id
4800 , mcce.inventory_item_id
4801 , TO_NUMBER(NULL) move_order_line_id
4802 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4803 WHERE mcce.entry_status_code IN(1, 3)
4804 AND NVL(mcce.export_flag, 2) = 2
4805 -- bug 3972076
4806 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4807 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4808 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4809 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4810 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4811 (SELECT utt_emp.standard_operation_id standard_operation_id
4812 , utt_emp.resource_id ROLE
4813 , utt_eqp.resource_id equipment
4814 , utt_emp.person_id emp_id
4815 , utt_eqp.inventory_item_id eqp_id
4816 , NULL eqp_srl /* removed for bug 2095237 */
4817 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4818 , x_utt_res1.resource_id resource_id
4819 , x_emp_r.person_id
4820 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4821 WHERE x_utt_res1.resource_id = r1.resource_id
4822 AND r1.resource_type = 2
4823 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4824 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4825 , x_utt_res2.resource_id resource_id
4826 , x_eqp_r.inventory_item_id inventory_item_id
4827 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4828 WHERE x_utt_res2.resource_id = r2.resource_id
4829 AND r2.resource_type = 1
4830 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4831 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4832 , -- inlined wms_person_resource_utt_v, bug 2648133
4833 mtl_item_locations loc
4834 , mtl_secondary_inventories sub
4835 , mtl_txn_request_lines mol
4836 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4837 AND wdtv.organization_id = p_sign_on_org_id
4838 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4839 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4840 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
4841 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4842 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4843 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4844 AND wdtv.locator_id = loc.inventory_location_id(+)
4845 AND wdtv.ZONE = sub.secondary_inventory_name
4846 AND wdtv.organization_id = sub.organization_id
4847 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
4848 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
4849 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
4850 (
4851 SELECT NULL
4852 FROM mtl_material_transactions_temp mmtt
4853 WHERE mmtt.transaction_temp_id = wdtv.task_id
4854 AND mmtt.parent_line_id IS NOT NULL
4855 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
4856 AND NOT EXISTS -- exclude tasks already dispatched
4857 (SELECT NULL
4858 FROM wms_dispatched_tasks wdt1
4859 WHERE wdt1.transaction_temp_id = wdtv.task_id
4860 AND wdt1.task_type = wdtv.wms_task_type_id)
4861 --******************
4862 AND wdtv.task_id NOT IN -- excluded skipped tasks
4863 (
4864 SELECT wdtv.task_id
4865 FROM wms_skip_task_exceptions wste, mtl_parameters mp
4866 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
4867 AND wste.task_id = wdtv.task_id
4868 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
4869 AND wste.organization_id = mp.organization_id)
4870 --*****************
4871 --J Addition
4872 AND wdtv.ZONE not in (
4873 SELECT wd.subinventory_code
4874 FROM wms_devices_b wd
4875 , wms_bus_event_devices wbed
4876 WHERE 1 = 1
4877 and wd.device_id = wbed.device_id
4878 AND wbed.organization_id = wd.organization_id
4879 AND wd.enabled_flag = 'Y'
4880 AND wbed.enabled_flag = 'Y'
4881 AND wbed.business_event_id = 10
4882 AND wd.subinventory_code IS NOT NULL
4883 AND wd.force_sign_on_flag = 'Y'
4884 AND wd.device_id NOT IN (SELECT device_id
4885 FROM wms_device_assignment_temp
4886 WHERE employee_id = p_sign_on_emp_id)
4887 )
4888 ORDER BY nvl(wdtv.task_priority, 0)
4889 , -- removed order by segments for bug 2657909
4890 mol.header_id
4891 , sub.picking_order
4892 , loc.picking_order
4893 , (
4894 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
4895 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
4896 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
4897 )
4898 , wdtv.task_id;
4899
4900 -- Cursor # 2 for selecting the most optimal task
4901 -- 1. sub is passed (1)
4902 -- 2. order by across wave (1)
4903 -- 3. Express pick (1)
4904
4905 CURSOR l_curs_opt_task_111 IS
4906 SELECT DISTINCT wdtv.task_id task_id
4907 , -- added distinct for bug 2657909
4908 NVL(wdtv.pick_slip_number, -1) pick_slip
4909 , wdtv.wms_task_type_id
4910 , nvl(wdtv.task_priority, 0)
4911 , -- added following because of distinct for bug 2657909
4912 mol.header_id
4913 , sub.picking_order
4914 , loc.picking_order
4915 , nvl(loc.x_coordinate, 0)
4916 , nvl(loc.y_coordinate, 0)
4917 , nvl(loc.z_coordinate, 0)
4918 FROM (SELECT transaction_temp_id task_id
4919 , standard_operation_id user_task_type_id
4920 , wms_task_type wms_task_type_id
4921 , organization_id organization_id
4922 , subinventory_code ZONE
4923 , locator_id locator_id
4924 , task_priority task_priority
4925 , revision revision
4926 , lot_number lot_number
4927 , transaction_uom transaction_uom
4928 , transaction_quantity transaction_quantity
4929 , pick_rule_id pick_rule_id
4930 , pick_slip_number pick_slip_number
4931 , cartonization_id cartonization_id
4932 , inventory_item_id
4933 , move_order_line_id
4934 FROM mtl_material_transactions_temp
4935 WHERE wms_task_type IS NOT NULL
4936 AND transaction_status = 2
4937 AND(wms_task_status IS NULL
4938 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4939 UNION ALL
4940 SELECT MIN(mcce.cycle_count_entry_id) task_id
4941 , MIN(mcce.standard_operation_id) user_task_type_id
4942 , 3 wms_task_type_id
4943 , mcce.organization_id organization_id
4944 , mcce.subinventory ZONE
4945 , mcce.locator_id locator_id
4946 , MIN(mcce.task_priority) task_priority
4947 , mcce.revision revision
4948 , MIN(mcce.lot_number) lot_number
4949 , '' transaction_uom
4950 , TO_NUMBER(NULL) transaction_quantity
4951 , TO_NUMBER(NULL) pick_rule_id
4952 , TO_NUMBER(NULL) pick_slip_number
4953 , TO_NUMBER(NULL) cartonization_id
4954 , mcce.inventory_item_id
4955 , TO_NUMBER(NULL) move_order_line_id
4956 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4957 WHERE mcce.entry_status_code IN(1, 3)
4958 AND NVL(mcce.export_flag, 2) = 2
4959 -- bug 3972076
4960 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4961 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4962 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4963 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4964 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4965 (SELECT utt_emp.standard_operation_id standard_operation_id
4966 , utt_emp.resource_id ROLE
4967 , utt_eqp.resource_id equipment
4968 , utt_emp.person_id emp_id
4969 , utt_eqp.inventory_item_id eqp_id
4970 , NULL eqp_srl /* removed for bug 2095237 */
4971 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4972 , x_utt_res1.resource_id resource_id
4973 , x_emp_r.person_id
4974 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4975 WHERE x_utt_res1.resource_id = r1.resource_id
4976 AND r1.resource_type = 2
4977 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4978 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4979 , x_utt_res2.resource_id resource_id
4980 , x_eqp_r.inventory_item_id inventory_item_id
4981 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4982 WHERE x_utt_res2.resource_id = r2.resource_id
4983 AND r2.resource_type = 1
4984 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4985 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4986 , -- inlined wms_person_resource_utt_v, bug 2648133
4987 mtl_item_locations loc
4988 , mtl_secondary_inventories sub
4989 , mtl_txn_request_lines mol
4990 -- mtl_system_items msi -- bug 2648133
4991 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4992 AND wdtv.organization_id = p_sign_on_org_id
4993 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4994 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4995 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
4996 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4997 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4998 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4999 AND wdtv.locator_id = loc.inventory_location_id(+)
5000 AND wdtv.ZONE = sub.secondary_inventory_name
5001 AND wdtv.organization_id = sub.organization_id
5002 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5003 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5004 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5005 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5006 (
5007 SELECT NULL
5008 FROM mtl_material_transactions_temp mmtt
5009 WHERE mmtt.transaction_temp_id = wdtv.task_id
5010 AND mmtt.parent_line_id IS NOT NULL
5011 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5012 AND NOT EXISTS -- exclude tasks already dispatched
5013 (SELECT NULL
5014 FROM wms_dispatched_tasks wdt1
5015 WHERE wdt1.transaction_temp_id = wdtv.task_id
5016 AND wdt1.task_type = wdtv.wms_task_type_id)
5017 --******************
5018 AND wdtv.task_id NOT IN -- excluded skipped tasks
5019 (
5020 SELECT wdtv.task_id
5021 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5022 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5023 AND wste.task_id = wdtv.task_id
5024 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5025 AND wste.organization_id = mp.organization_id)
5026 --*****************
5027 --J Addition
5028 AND wdtv.ZONE not in (
5029 SELECT wd.subinventory_code
5030 FROM wms_devices_b wd
5031 , wms_bus_event_devices wbed
5032 WHERE 1 = 1
5033 and wd.device_id = wbed.device_id
5034 AND wbed.organization_id = wd.organization_id
5035 AND wd.enabled_flag = 'Y'
5036 AND wbed.enabled_flag = 'Y'
5037 AND wbed.business_event_id = 10
5038 AND wd.subinventory_code IS NOT NULL
5039 AND wd.force_sign_on_flag = 'Y'
5040 AND wd.device_id NOT IN (SELECT device_id
5041 FROM wms_device_assignment_temp
5042 WHERE employee_id = p_sign_on_emp_id)
5043 )
5044 ORDER BY nvl(wdtv.task_priority, 0)
5045 , -- removed order by segments for bug 2657909
5046 mol.header_id
5047 , sub.picking_order
5048 , loc.picking_order
5049 , (
5050 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5051 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5052 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5053 )
5054 , wdtv.task_id;
5055
5056 -- Cursor # 3 for selecting the most optimal task
5057 -- 1. sub is NOT passed (0)
5058 -- 2. order by across wave (1)
5059 -- 3. not express pick (0)
5060
5061 CURSOR l_curs_opt_task_010 IS
5062 SELECT DISTINCT wdtv.task_id task_id
5063 , -- added distinct for bug 2657909
5064 NVL(wdtv.pick_slip_number, -1) pick_slip
5065 , wdtv.wms_task_type_id
5066 , nvl(wdtv.task_priority, 0)
5067 , -- added following because of distinct for bug 2657909
5068 mol.header_id
5069 , sub.picking_order
5070 , loc.picking_order
5071 , nvl(loc.x_coordinate, 0)
5072 , nvl(loc.y_coordinate, 0)
5073 , nvl(loc.z_coordinate, 0)
5074 FROM (SELECT transaction_temp_id task_id
5075 , standard_operation_id user_task_type_id
5076 , wms_task_type wms_task_type_id
5077 , organization_id organization_id
5078 , subinventory_code ZONE
5079 , locator_id locator_id
5080 , task_priority task_priority
5081 , revision revision
5082 , lot_number lot_number
5083 , transaction_uom transaction_uom
5084 , transaction_quantity transaction_quantity
5085 , pick_rule_id pick_rule_id
5086 , pick_slip_number pick_slip_number
5087 , cartonization_id cartonization_id
5088 , inventory_item_id
5089 , move_order_line_id
5090 FROM mtl_material_transactions_temp
5091 WHERE wms_task_type IS NOT NULL
5092 AND transaction_status = 2
5093 AND(wms_task_status IS NULL
5094 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5095 UNION ALL
5096 SELECT MIN(mcce.cycle_count_entry_id) task_id
5097 , MIN(mcce.standard_operation_id) user_task_type_id
5098 , 3 wms_task_type_id
5099 , mcce.organization_id organization_id
5100 , mcce.subinventory ZONE
5101 , mcce.locator_id locator_id
5102 , MIN(mcce.task_priority) task_priority
5103 , mcce.revision revision
5104 , MIN(mcce.lot_number) lot_number
5105 , '' transaction_uom
5106 , TO_NUMBER(NULL) transaction_quantity
5107 , TO_NUMBER(NULL) pick_rule_id
5108 , TO_NUMBER(NULL) pick_slip_number
5109 , TO_NUMBER(NULL) cartonization_id
5110 , mcce.inventory_item_id
5111 , TO_NUMBER(NULL) move_order_line_id
5112 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5113 WHERE mcce.entry_status_code IN(1, 3)
5114 AND NVL(mcce.export_flag, 2) = 2
5115 -- bug 3972076
5116 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5117 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5118 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5119 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5120 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5121 (SELECT utt_emp.standard_operation_id standard_operation_id
5122 , utt_emp.resource_id ROLE
5123 , utt_eqp.resource_id equipment
5124 , utt_emp.person_id emp_id
5125 , utt_eqp.inventory_item_id eqp_id
5126 , NULL eqp_srl /* removed for bug 2095237 */
5127 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5128 , x_utt_res1.resource_id resource_id
5129 , x_emp_r.person_id
5130 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5131 WHERE x_utt_res1.resource_id = r1.resource_id
5132 AND r1.resource_type = 2
5133 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5134 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5135 , x_utt_res2.resource_id resource_id
5136 , x_eqp_r.inventory_item_id inventory_item_id
5137 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5138 WHERE x_utt_res2.resource_id = r2.resource_id
5139 AND r2.resource_type = 1
5140 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5141 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5142 , -- inlined wms_person_resource_utt_v, bug 2648133
5143 mtl_item_locations loc
5144 , mtl_secondary_inventories sub
5145 , mtl_txn_request_lines mol
5146 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5147 AND wdtv.organization_id = p_sign_on_org_id
5148 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5149 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5150 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5151 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5152 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5153 AND wdtv.locator_id = loc.inventory_location_id(+)
5154 AND wdtv.ZONE = sub.secondary_inventory_name
5155 AND wdtv.organization_id = sub.organization_id
5156 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5157 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5158 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5159 (
5160 SELECT NULL
5161 FROM mtl_material_transactions_temp mmtt
5162 WHERE mmtt.transaction_temp_id = wdtv.task_id
5163 AND mmtt.parent_line_id IS NOT NULL
5164 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5165 AND NOT EXISTS -- exclude tasks already dispatched
5166 (SELECT NULL
5167 FROM wms_dispatched_tasks wdt1
5168 WHERE wdt1.transaction_temp_id = wdtv.task_id
5169 AND wdt1.task_type = wdtv.wms_task_type_id)
5170 --******************
5171 AND wdtv.task_id NOT IN -- excluded skipped tasks
5172 (
5173 SELECT wdtv.task_id
5174 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5175 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5176 AND wste.task_id = wdtv.task_id
5177 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5178 AND wste.organization_id = mp.organization_id)
5179 --*****************
5180 --J Addition
5181 AND wdtv.ZONE not in (
5182 SELECT wd.subinventory_code
5183 FROM wms_devices_b wd
5184 , wms_bus_event_devices wbed
5185 WHERE 1 = 1
5186 and wd.device_id = wbed.device_id
5187 AND wbed.organization_id = wd.organization_id
5188 AND wd.enabled_flag = 'Y'
5189 AND wbed.enabled_flag = 'Y'
5190 AND wbed.business_event_id = 10
5191 AND wd.subinventory_code IS NOT NULL
5192 AND wd.force_sign_on_flag = 'Y'
5193 AND wd.device_id NOT IN (SELECT device_id
5194 FROM wms_device_assignment_temp
5195 WHERE employee_id = p_sign_on_emp_id)
5196 )
5197 ORDER BY nvl(wdtv.task_priority, 0)
5198 , -- removed order by segments for bug 2657909
5199 mol.header_id
5200 , sub.picking_order
5201 , loc.picking_order
5202 , (
5203 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5204 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5205 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5206 )
5207 , wdtv.task_id;
5208
5209 -- Cursor # 4 for selecting the most optimal task
5210 -- 1. sub is NOT passed (0)
5211 -- 2. order by across wave (1)
5212 -- 3. express pick (1)
5213
5214 CURSOR l_curs_opt_task_011 IS
5215 SELECT DISTINCT wdtv.task_id task_id
5216 , -- added distinct for bug 2657909
5217 NVL(wdtv.pick_slip_number, -1) pick_slip
5218 , wdtv.wms_task_type_id
5219 , nvl(wdtv.task_priority, 0)
5220 , -- added following because of distinct for bug 2657909
5221 mol.header_id
5222 , sub.picking_order
5223 , loc.picking_order
5224 , nvl(loc.x_coordinate, 0)
5225 , nvl(loc.y_coordinate, 0)
5226 , nvl(loc.z_coordinate, 0)
5227 FROM (SELECT transaction_temp_id task_id
5228 , standard_operation_id user_task_type_id
5229 , wms_task_type wms_task_type_id
5230 , organization_id organization_id
5231 , subinventory_code ZONE
5232 , locator_id locator_id
5233 , task_priority task_priority
5234 , revision revision
5235 , lot_number lot_number
5236 , transaction_uom transaction_uom
5237 , transaction_quantity transaction_quantity
5238 , pick_rule_id pick_rule_id
5239 , pick_slip_number pick_slip_number
5240 , cartonization_id cartonization_id
5241 , inventory_item_id
5242 , move_order_line_id
5243 FROM mtl_material_transactions_temp
5244 WHERE wms_task_type IS NOT NULL
5245 AND transaction_status = 2
5246 AND(wms_task_status IS NULL
5247 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5248 UNION ALL
5249 SELECT MIN(mcce.cycle_count_entry_id) task_id
5250 , MIN(mcce.standard_operation_id) user_task_type_id
5251 , 3 wms_task_type_id
5252 , mcce.organization_id organization_id
5253 , mcce.subinventory ZONE
5254 , mcce.locator_id locator_id
5255 , MIN(mcce.task_priority) task_priority
5256 , mcce.revision revision
5257 , MIN(mcce.lot_number) lot_number
5258 , '' transaction_uom
5259 , TO_NUMBER(NULL) transaction_quantity
5260 , TO_NUMBER(NULL) pick_rule_id
5261 , TO_NUMBER(NULL) pick_slip_number
5262 , TO_NUMBER(NULL) cartonization_id
5263 , mcce.inventory_item_id
5264 , TO_NUMBER(NULL) move_order_line_id
5265 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5266 WHERE mcce.entry_status_code IN(1, 3)
5267 AND NVL(mcce.export_flag, 2) = 2
5268 -- bug 3972076
5269 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5270 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5271 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5272 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5273 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5274 (SELECT utt_emp.standard_operation_id standard_operation_id
5275 , utt_emp.resource_id ROLE
5276 , utt_eqp.resource_id equipment
5277 , utt_emp.person_id emp_id
5278 , utt_eqp.inventory_item_id eqp_id
5279 , NULL eqp_srl /* removed for bug 2095237 */
5280 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5281 , x_utt_res1.resource_id resource_id
5282 , x_emp_r.person_id
5283 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5284 WHERE x_utt_res1.resource_id = r1.resource_id
5285 AND r1.resource_type = 2
5286 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5287 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5288 , x_utt_res2.resource_id resource_id
5289 , x_eqp_r.inventory_item_id inventory_item_id
5290 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5291 WHERE x_utt_res2.resource_id = r2.resource_id
5292 AND r2.resource_type = 1
5293 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5294 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5295 , -- inlined wms_person_resource_utt_v, bug 2648133
5296 mtl_item_locations loc
5297 , mtl_secondary_inventories sub
5298 , mtl_txn_request_lines mol
5299 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5300 AND wdtv.organization_id = p_sign_on_org_id
5301 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5302 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5303 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5304 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5305 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5306 AND wdtv.locator_id = loc.inventory_location_id(+)
5307 AND wdtv.ZONE = sub.secondary_inventory_name
5308 AND wdtv.organization_id = sub.organization_id
5309 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5310 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5311 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5312 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5313 (
5314 SELECT NULL
5315 FROM mtl_material_transactions_temp mmtt
5316 WHERE mmtt.transaction_temp_id = wdtv.task_id
5317 AND mmtt.parent_line_id IS NOT NULL
5318 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5319 AND NOT EXISTS -- exclude tasks already dispatched
5320 (SELECT NULL
5321 FROM wms_dispatched_tasks wdt1
5322 WHERE wdt1.transaction_temp_id = wdtv.task_id
5323 AND wdt1.task_type = wdtv.wms_task_type_id)
5324 --******************
5325 AND wdtv.task_id NOT IN -- excluded skipped tasks
5326 (
5327 SELECT wdtv.task_id
5328 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5329 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5330 AND wste.task_id = wdtv.task_id
5331 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5332 AND wste.organization_id = mp.organization_id)
5333 --*****************
5334 --J Addition
5335 AND wdtv.ZONE not in (
5336 SELECT wd.subinventory_code
5337 FROM wms_devices_b wd
5338 , wms_bus_event_devices wbed
5339 WHERE 1 = 1
5340 and wd.device_id = wbed.device_id
5341 AND wbed.organization_id = wd.organization_id
5342 AND wd.enabled_flag = 'Y'
5343 AND wbed.enabled_flag = 'Y'
5344 AND wbed.business_event_id = 10
5345 AND wd.subinventory_code IS NOT NULL
5346 AND wd.force_sign_on_flag = 'Y'
5347 AND wd.device_id NOT IN (SELECT device_id
5348 FROM wms_device_assignment_temp
5349 WHERE employee_id = p_sign_on_emp_id)
5350 )
5351 ORDER BY nvl(wdtv.task_priority, 0)
5352 , -- removed order by segments for bug 2657909
5353 mol.header_id
5354 , sub.picking_order
5355 , loc.picking_order
5356 , (
5357 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5358 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5359 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5360 )
5361 , wdtv.task_id;
5362
5363 -- Cursor # 5 for selecting the most optimal task
5364 -- 1. sub is passed (1)
5365 -- 2. NOT order by across wave (0)
5366 -- 3. NOT express pick (0)
5367
5368 CURSOR l_curs_opt_task_100 IS
5369 SELECT DISTINCT wdtv.task_id task_id
5370 , -- added distinct for bug 2657909
5371 NVL(wdtv.pick_slip_number, -1) pick_slip
5372 , wdtv.wms_task_type_id
5373 , nvl(wdtv.task_priority, 0)
5374 , mol.header_id
5375 , sub.picking_order
5376 , loc.picking_order
5377 , nvl(loc.x_coordinate, 0)
5378 , nvl(loc.y_coordinate, 0)
5379 , nvl(loc.z_coordinate, 0)
5380 FROM (SELECT transaction_temp_id task_id
5381 , standard_operation_id user_task_type_id
5382 , wms_task_type wms_task_type_id
5383 , organization_id organization_id
5384 , subinventory_code ZONE
5385 , locator_id locator_id
5386 , task_priority task_priority
5387 , revision revision
5388 , lot_number lot_number
5389 , transaction_uom transaction_uom
5390 , transaction_quantity transaction_quantity
5391 , pick_rule_id pick_rule_id
5392 , pick_slip_number pick_slip_number
5393 , cartonization_id cartonization_id
5394 , inventory_item_id
5395 , move_order_line_id
5396 FROM mtl_material_transactions_temp
5397 WHERE wms_task_type IS NOT NULL
5398 AND transaction_status = 2
5399 AND(wms_task_status IS NULL
5400 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5401 UNION ALL
5402 SELECT MIN(mcce.cycle_count_entry_id) task_id
5403 , MIN(mcce.standard_operation_id) user_task_type_id
5404 , 3 wms_task_type_id
5405 , mcce.organization_id organization_id
5406 , mcce.subinventory ZONE
5407 , mcce.locator_id locator_id
5408 , MIN(mcce.task_priority) task_priority
5409 , mcce.revision revision
5410 , MIN(mcce.lot_number) lot_number
5411 , '' transaction_uom
5412 , TO_NUMBER(NULL) transaction_quantity
5413 , TO_NUMBER(NULL) pick_rule_id
5414 , TO_NUMBER(NULL) pick_slip_number
5415 , TO_NUMBER(NULL) cartonization_id
5416 , mcce.inventory_item_id
5417 , TO_NUMBER(NULL) move_order_line_id
5418 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5419 WHERE mcce.entry_status_code IN(1, 3)
5420 AND NVL(mcce.export_flag, 2) = 2
5421 -- bug 3972076
5422 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5423 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5424 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5425 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5426 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5427 (SELECT utt_emp.standard_operation_id standard_operation_id
5428 , utt_emp.resource_id ROLE
5429 , utt_eqp.resource_id equipment
5430 , utt_emp.person_id emp_id
5431 , utt_eqp.inventory_item_id eqp_id
5432 , NULL eqp_srl /* removed for bug 2095237 */
5433 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5434 , x_utt_res1.resource_id resource_id
5435 , x_emp_r.person_id
5436 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5437 WHERE x_utt_res1.resource_id = r1.resource_id
5438 AND r1.resource_type = 2
5439 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5440 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5441 , x_utt_res2.resource_id resource_id
5442 , x_eqp_r.inventory_item_id inventory_item_id
5443 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5444 WHERE x_utt_res2.resource_id = r2.resource_id
5445 AND r2.resource_type = 1
5446 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5447 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5448 , -- inlined wms_person_resource_utt_v, bug 2648133
5449 mtl_item_locations loc
5450 , mtl_secondary_inventories sub
5451 , mtl_txn_request_lines mol
5452 -- mtl_system_items msi -- bug 2648133
5453 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5454 AND wdtv.organization_id = p_sign_on_org_id
5455 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5456 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5457 AND wdtv.ZONE = p_sign_on_zone
5458 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5459 -- AND Nvl(v.eqp_srl, '@@@') = Nvl(l_sign_on_equipment_srl, Nvl(v.eqp_srl, '@@@')) removed for bug 2095237
5460 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5461 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5462 AND wdtv.locator_id = loc.inventory_location_id(+)
5463 AND wdtv.ZONE = sub.secondary_inventory_name
5464 AND wdtv.organization_id = sub.organization_id
5465 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5466 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5467 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5468 (
5469 SELECT NULL
5470 FROM mtl_material_transactions_temp mmtt
5471 WHERE mmtt.transaction_temp_id = wdtv.task_id
5472 AND mmtt.parent_line_id IS NOT NULL
5473 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5474 AND NOT EXISTS -- exclude tasks already dispatched
5475 (SELECT NULL
5476 FROM wms_dispatched_tasks wdt1
5477 WHERE wdt1.transaction_temp_id = wdtv.task_id
5478 AND wdt1.task_type = wdtv.wms_task_type_id)
5479 --******************
5480 AND wdtv.task_id NOT IN -- excluded skipped tasks
5481 (
5482 SELECT wdtv.task_id
5483 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5484 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5485 AND wste.task_id = wdtv.task_id
5486 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5487 AND wste.organization_id = mp.organization_id)
5488 --*****************
5489 --J Addition
5490 AND wdtv.ZONE not in (
5491 SELECT wd.subinventory_code
5492 FROM wms_devices_b wd
5493 , wms_bus_event_devices wbed
5494 WHERE 1 = 1
5495 and wd.device_id = wbed.device_id
5496 AND wbed.organization_id = wd.organization_id
5497 AND wd.enabled_flag = 'Y'
5498 AND wbed.enabled_flag = 'Y'
5499 AND wbed.business_event_id = 10
5500 AND wd.subinventory_code IS NOT NULL
5501 AND wd.force_sign_on_flag = 'Y'
5502 AND wd.device_id NOT IN (SELECT device_id
5503 FROM wms_device_assignment_temp
5504 WHERE employee_id = p_sign_on_emp_id)
5505 )
5506 ORDER BY nvl(wdtv.task_priority, 0)
5507 , -- removed order by segments for bug 2657909
5508 sub.picking_order
5509 , loc.picking_order
5510 , (
5511 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5512 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5513 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5514 )
5515 , wdtv.task_id;
5516
5517 -- Cursor # 6 for selecting the most optimal task
5518 -- 1. sub is passed (1)
5519 -- 2. NOT order by across wave (0)
5520 -- 3. express pick (1)
5521
5522 CURSOR l_curs_opt_task_101 IS
5523 SELECT DISTINCT wdtv.task_id task_id
5524 , -- added distinct for bug 2657909
5525 NVL(wdtv.pick_slip_number, -1) pick_slip
5526 , wdtv.wms_task_type_id
5527 , nvl(wdtv.task_priority, 0)
5528 , mol.header_id
5529 , sub.picking_order
5530 , loc.picking_order
5531 , nvl(loc.x_coordinate, 0)
5532 , nvl(loc.y_coordinate, 0)
5533 , nvl(loc.z_coordinate, 0)
5534 FROM (SELECT transaction_temp_id task_id
5535 , standard_operation_id user_task_type_id
5536 , wms_task_type wms_task_type_id
5537 , organization_id organization_id
5538 , subinventory_code ZONE
5539 , locator_id locator_id
5540 , task_priority task_priority
5541 , revision revision
5542 , lot_number lot_number
5543 , transaction_uom transaction_uom
5544 , transaction_quantity transaction_quantity
5545 , pick_rule_id pick_rule_id
5546 , pick_slip_number pick_slip_number
5547 , cartonization_id cartonization_id
5548 , inventory_item_id
5549 , move_order_line_id
5550 FROM mtl_material_transactions_temp
5551 WHERE wms_task_type IS NOT NULL
5552 AND transaction_status = 2
5553 AND(wms_task_status IS NULL
5554 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5555 UNION ALL
5556 SELECT MIN(mcce.cycle_count_entry_id) task_id
5557 , MIN(mcce.standard_operation_id) user_task_type_id
5558 , 3 wms_task_type_id
5559 , mcce.organization_id organization_id
5560 , mcce.subinventory ZONE
5561 , mcce.locator_id locator_id
5562 , MIN(mcce.task_priority) task_priority
5563 , mcce.revision revision
5564 , MIN(mcce.lot_number) lot_number
5565 , '' transaction_uom
5566 , TO_NUMBER(NULL) transaction_quantity
5567 , TO_NUMBER(NULL) pick_rule_id
5568 , TO_NUMBER(NULL) pick_slip_number
5569 , TO_NUMBER(NULL) cartonization_id
5570 , mcce.inventory_item_id
5571 , TO_NUMBER(NULL) move_order_line_id
5572 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5573 WHERE mcce.entry_status_code IN(1, 3)
5574 AND NVL(mcce.export_flag, 2) = 2
5575 -- bug 3972076
5576 -- AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5577 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5578 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5579 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5580 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5581 (SELECT utt_emp.standard_operation_id standard_operation_id
5582 , utt_emp.resource_id ROLE
5583 , utt_eqp.resource_id equipment
5584 , utt_emp.person_id emp_id
5585 , utt_eqp.inventory_item_id eqp_id
5586 , NULL eqp_srl /* removed for bug 2095237 */
5587 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5588 , x_utt_res1.resource_id resource_id
5589 , x_emp_r.person_id
5590 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5591 WHERE x_utt_res1.resource_id = r1.resource_id
5592 AND r1.resource_type = 2
5593 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5594 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5595 , x_utt_res2.resource_id resource_id
5596 , x_eqp_r.inventory_item_id inventory_item_id
5597 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5598 WHERE x_utt_res2.resource_id = r2.resource_id
5599 AND r2.resource_type = 1
5600 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5601 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5602 , -- inlined wms_person_resource_utt_v, bug 2648133
5603 mtl_item_locations loc
5604 , mtl_secondary_inventories sub
5605 , mtl_txn_request_lines mol
5606 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5607 AND wdtv.organization_id = p_sign_on_org_id
5608 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5609 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5610 AND wdtv.ZONE = p_sign_on_zone
5611 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5612 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5613 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5614 AND wdtv.locator_id = loc.inventory_location_id(+)
5615 AND wdtv.ZONE = sub.secondary_inventory_name
5616 AND wdtv.organization_id = sub.organization_id
5617 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5618 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5619 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5620 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5621 (
5622 SELECT NULL
5623 FROM mtl_material_transactions_temp mmtt
5624 WHERE mmtt.transaction_temp_id = wdtv.task_id
5625 AND mmtt.parent_line_id IS NOT NULL
5626 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5627 AND NOT EXISTS -- exclude tasks already dispatched
5628 (SELECT NULL
5629 FROM wms_dispatched_tasks wdt1
5630 WHERE wdt1.transaction_temp_id = wdtv.task_id
5631 AND wdt1.task_type = wdtv.wms_task_type_id)
5632 --******************
5633 AND wdtv.task_id NOT IN -- excluded skipped tasks
5634 (
5635 SELECT wdtv.task_id
5636 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5637 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5638 AND wste.task_id = wdtv.task_id
5639 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5640 AND wste.organization_id = mp.organization_id)
5641 --*****************
5642 --J Addition
5643 AND wdtv.ZONE not in (
5644 SELECT wd.subinventory_code
5645 FROM wms_devices_b wd
5646 , wms_bus_event_devices wbed
5647 WHERE 1 = 1
5648 and wd.device_id = wbed.device_id
5649 AND wbed.organization_id = wd.organization_id
5650 AND wd.enabled_flag = 'Y'
5651 AND wbed.enabled_flag = 'Y'
5652 AND wbed.business_event_id = 10
5653 AND wd.subinventory_code IS NOT NULL
5654 AND wd.force_sign_on_flag = 'Y'
5655 AND wd.device_id NOT IN (SELECT device_id
5656 FROM wms_device_assignment_temp
5657 WHERE employee_id = p_sign_on_emp_id)
5658 )
5659 ORDER BY nvl(wdtv.task_priority, 0)
5660 , -- removed order by segments for bug 2657909
5661 sub.picking_order
5662 , loc.picking_order
5663 , (
5664 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5665 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5666 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5667 )
5668 , wdtv.task_id;
5669
5670 -- Cursor # 7 for selecting the most optimal task
5671 -- 1. sub NOT passed (0)
5672 -- 2. NOT order by across wave (0)
5673 -- 3. NOT express pick (0)
5674
5675 CURSOR l_curs_opt_task_000 IS
5676 SELECT DISTINCT wdtv.task_id task_id
5677 , -- added distinct for bug 2657909
5678 NVL(wdtv.pick_slip_number, -1) pick_slip
5679 , wdtv.wms_task_type_id
5680 , nvl(wdtv.task_priority, 0)
5681 , mol.header_id
5682 , sub.picking_order
5683 , loc.picking_order
5684 , nvl(loc.x_coordinate, 0)
5685 , nvl(loc.y_coordinate, 0)
5686 , nvl(loc.z_coordinate, 0)
5687 FROM (SELECT transaction_temp_id task_id
5688 , standard_operation_id user_task_type_id
5689 , wms_task_type wms_task_type_id
5690 , organization_id organization_id
5691 , subinventory_code ZONE
5692 , locator_id locator_id
5693 , task_priority task_priority
5694 , revision revision
5695 , lot_number lot_number
5696 , transaction_uom transaction_uom
5697 , transaction_quantity transaction_quantity
5698 , pick_rule_id pick_rule_id
5699 , pick_slip_number pick_slip_number
5700 , cartonization_id cartonization_id
5701 , inventory_item_id
5702 , move_order_line_id
5703 FROM mtl_material_transactions_temp
5704 WHERE wms_task_type IS NOT NULL
5705 AND transaction_status = 2
5706 AND(wms_task_status IS NULL
5707 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5708 UNION ALL
5709 SELECT MIN(mcce.cycle_count_entry_id) task_id
5710 , MIN(mcce.standard_operation_id) user_task_type_id
5711 , 3 wms_task_type_id
5712 , mcce.organization_id organization_id
5713 , mcce.subinventory ZONE
5714 , mcce.locator_id locator_id
5715 , MIN(mcce.task_priority) task_priority
5716 , mcce.revision revision
5717 , MIN(mcce.lot_number) lot_number
5718 , '' transaction_uom
5719 , TO_NUMBER(NULL) transaction_quantity
5720 , TO_NUMBER(NULL) pick_rule_id
5721 , TO_NUMBER(NULL) pick_slip_number
5722 , TO_NUMBER(NULL) cartonization_id
5723 , mcce.inventory_item_id
5724 , TO_NUMBER(NULL) move_order_line_id
5725 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5726 WHERE mcce.entry_status_code IN(1, 3)
5727 AND NVL(mcce.export_flag, 2) = 2
5728 -- bug 3972076
5729 -- AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5730 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5731 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5732 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5733 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5734 (SELECT utt_emp.standard_operation_id standard_operation_id
5735 , utt_emp.resource_id ROLE
5736 , utt_eqp.resource_id equipment
5737 , utt_emp.person_id emp_id
5738 , utt_eqp.inventory_item_id eqp_id
5739 , NULL eqp_srl /* removed for bug 2095237 */
5740 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5741 , x_utt_res1.resource_id resource_id
5742 , x_emp_r.person_id
5743 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5744 WHERE x_utt_res1.resource_id = r1.resource_id
5745 AND r1.resource_type = 2
5746 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5747 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5748 , x_utt_res2.resource_id resource_id
5749 , x_eqp_r.inventory_item_id inventory_item_id
5750 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5751 WHERE x_utt_res2.resource_id = r2.resource_id
5752 AND r2.resource_type = 1
5753 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5754 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5755 , -- inlined wms_person_resource_utt_v, bug 2648133
5756 mtl_item_locations loc
5757 , mtl_secondary_inventories sub
5758 , mtl_txn_request_lines mol
5759 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5760 AND wdtv.organization_id = p_sign_on_org_id
5761 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5762 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5763 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5764 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5765 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5766 AND wdtv.locator_id = loc.inventory_location_id(+)
5767 AND wdtv.ZONE = sub.secondary_inventory_name
5768 AND wdtv.organization_id = sub.organization_id
5769 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5770 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5771 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5772 (
5773 SELECT NULL
5774 FROM mtl_material_transactions_temp mmtt
5775 WHERE mmtt.transaction_temp_id = wdtv.task_id
5776 AND mmtt.parent_line_id IS NOT NULL
5777 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5778 AND NOT EXISTS -- exclude tasks already dispatched
5779 (SELECT NULL
5780 FROM wms_dispatched_tasks wdt1
5781 WHERE wdt1.transaction_temp_id = wdtv.task_id
5782 AND wdt1.task_type = wdtv.wms_task_type_id)
5783 --******************
5784 AND wdtv.task_id NOT IN -- excluded skipped tasks
5785 (
5786 SELECT wdtv.task_id
5787 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5788 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5789 AND wste.task_id = wdtv.task_id
5790 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5791 AND wste.organization_id = mp.organization_id)
5792 --*****************
5793 --J Addition
5794 AND wdtv.ZONE not in (
5795 SELECT wd.subinventory_code
5796 FROM wms_devices_b wd
5797 , wms_bus_event_devices wbed
5798 WHERE 1 = 1
5799 and wd.device_id = wbed.device_id
5800 AND wbed.organization_id = wd.organization_id
5801 AND wd.enabled_flag = 'Y'
5802 AND wbed.enabled_flag = 'Y'
5803 AND wbed.business_event_id = 10
5804 AND wd.subinventory_code IS NOT NULL
5805 AND wd.force_sign_on_flag = 'Y'
5806 AND wd.device_id NOT IN (SELECT device_id
5807 FROM wms_device_assignment_temp
5808 WHERE employee_id = p_sign_on_emp_id)
5809 )
5810 ORDER BY nvl(wdtv.task_priority, 0)
5811 , -- removed order by segments for bug 2657909
5812 sub.picking_order
5813 , loc.picking_order
5814 , (
5815 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5816 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5817 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5818 )
5819 , wdtv.task_id;
5820
5821 -- Cursor # 8 for selecting the most optimal task
5822 -- 1. sub NOT passed (0)
5823 -- 2. NOT order by across wave (0)
5824 -- 3. express pick (1)
5825
5826 CURSOR l_curs_opt_task_001 IS
5827 SELECT DISTINCT wdtv.task_id task_id
5828 , -- added distinct for bug 2657909
5829 NVL(wdtv.pick_slip_number, -1) pick_slip
5830 , wdtv.wms_task_type_id
5831 , nvl(wdtv.task_priority, 0)
5832 , mol.header_id
5833 , sub.picking_order
5834 , loc.picking_order
5835 , nvl(loc.x_coordinate, 0)
5836 , nvl(loc.y_coordinate, 0)
5837 , nvl(loc.z_coordinate, 0)
5838 FROM (SELECT transaction_temp_id task_id
5839 , standard_operation_id user_task_type_id
5840 , wms_task_type wms_task_type_id
5841 , organization_id organization_id
5842 , subinventory_code ZONE
5843 , locator_id locator_id
5844 , task_priority task_priority
5845 , revision revision
5846 , lot_number lot_number
5847 , transaction_uom transaction_uom
5848 , transaction_quantity transaction_quantity
5849 , pick_rule_id pick_rule_id
5850 , pick_slip_number pick_slip_number
5851 , cartonization_id cartonization_id
5852 , inventory_item_id
5853 , move_order_line_id
5854 FROM mtl_material_transactions_temp
5855 WHERE wms_task_type IS NOT NULL
5856 AND transaction_status = 2
5857 AND(wms_task_status IS NULL
5858 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5859 UNION ALL
5860 SELECT MIN(mcce.cycle_count_entry_id) task_id
5861 , MIN(mcce.standard_operation_id) user_task_type_id
5862 , 3 wms_task_type_id
5863 , mcce.organization_id organization_id
5864 , mcce.subinventory ZONE
5865 , mcce.locator_id locator_id
5866 , MIN(mcce.task_priority) task_priority
5867 , mcce.revision revision
5868 , MIN(mcce.lot_number) lot_number
5869 , '' transaction_uom
5870 , TO_NUMBER(NULL) transaction_quantity
5871 , TO_NUMBER(NULL) pick_rule_id
5872 , TO_NUMBER(NULL) pick_slip_number
5873 , TO_NUMBER(NULL) cartonization_id
5874 , mcce.inventory_item_id
5875 , TO_NUMBER(NULL) move_order_line_id
5876 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5877 WHERE mcce.entry_status_code IN(1, 3)
5878 AND NVL(mcce.export_flag, 2) = 2
5879 -- bug 3972076
5880 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5881 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5882 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5883 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5884 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5885 (SELECT utt_emp.standard_operation_id standard_operation_id
5886 , utt_emp.resource_id ROLE
5887 , utt_eqp.resource_id equipment
5888 , utt_emp.person_id emp_id
5889 , utt_eqp.inventory_item_id eqp_id
5890 , NULL eqp_srl /* removed for bug 2095237 */
5891 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5892 , x_utt_res1.resource_id resource_id
5893 , x_emp_r.person_id
5894 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5895 WHERE x_utt_res1.resource_id = r1.resource_id
5896 AND r1.resource_type = 2
5897 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5898 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5899 , x_utt_res2.resource_id resource_id
5900 , x_eqp_r.inventory_item_id inventory_item_id
5901 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5902 WHERE x_utt_res2.resource_id = r2.resource_id
5903 AND r2.resource_type = 1
5904 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5905 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5906 , -- inlined wms_person_resource_utt_v, bug 2648133
5907 mtl_item_locations loc
5908 , mtl_secondary_inventories sub
5909 , mtl_txn_request_lines mol
5910 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5911 AND wdtv.organization_id = p_sign_on_org_id
5912 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5913 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5914 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5915 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5916 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5917 AND wdtv.locator_id = loc.inventory_location_id(+)
5918 AND wdtv.ZONE = sub.secondary_inventory_name
5919 AND wdtv.organization_id = sub.organization_id
5920 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5921 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5922 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5923 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5924 (
5925 SELECT NULL
5926 FROM mtl_material_transactions_temp mmtt
5927 WHERE mmtt.transaction_temp_id = wdtv.task_id
5928 AND mmtt.parent_line_id IS NOT NULL
5929 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5930 AND NOT EXISTS -- exclude tasks already dispatched
5931 (SELECT NULL
5932 FROM wms_dispatched_tasks wdt1
5933 WHERE wdt1.transaction_temp_id = wdtv.task_id
5934 AND wdt1.task_type = wdtv.wms_task_type_id)
5935 --******************
5936 AND wdtv.task_id NOT IN -- excluded skipped tasks
5937 (
5938 SELECT wdtv.task_id
5939 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5940 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5941 AND wste.task_id = wdtv.task_id
5942 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5943 AND wste.organization_id = mp.organization_id)
5944 --*****************
5945 --J Addition
5946 AND wdtv.ZONE not in (
5947 SELECT wd.subinventory_code
5948 FROM wms_devices_b wd
5949 , wms_bus_event_devices wbed
5950 WHERE 1 = 1
5951 and wd.device_id = wbed.device_id
5952 AND wbed.organization_id = wd.organization_id
5953 AND wd.enabled_flag = 'Y'
5954 AND wbed.enabled_flag = 'Y'
5955 AND wbed.business_event_id = 10
5956 AND wd.subinventory_code IS NOT NULL
5957 AND wd.force_sign_on_flag = 'Y'
5958 AND wd.device_id NOT IN (SELECT device_id
5959 FROM wms_device_assignment_temp
5960 WHERE employee_id = p_sign_on_emp_id)
5961 )
5962 ORDER BY nvl(wdtv.task_priority, 0)
5963 , -- removed order by segments for bug 2657909
5964 sub.picking_order
5965 , loc.picking_order
5966 , (
5967 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5968 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5969 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5970 )
5971 , wdtv.task_id;
5972
5973 CURSOR l_curs_ordered_tasks(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
5974 SELECT DISTINCT wdtv.task_id task_id
5975 , -- added distinct for bug 2657909
5976 NVL(wdtv.pick_slip_number, -1) pick_slip
5977 , wdtv.wms_task_type_id
5978 , nvl(wdtv.task_priority, 0)
5979 , -- added following because of distinct for bug 2657909
5980 mol.header_id
5981 , sub.picking_order
5982 , loc.picking_order
5983 , nvl(loc.x_coordinate, 0)
5984 , nvl(loc.y_coordinate, 0)
5985 , nvl(loc.z_coordinate, 0)
5986 FROM (SELECT transaction_temp_id task_id
5987 , standard_operation_id user_task_type_id
5988 , wms_task_type wms_task_type_id
5989 , organization_id organization_id
5990 , subinventory_code ZONE
5991 , locator_id locator_id
5992 , task_priority task_priority
5993 , revision revision
5994 , lot_number lot_number
5995 , transaction_uom transaction_uom
5996 , transaction_quantity transaction_quantity
5997 , pick_rule_id pick_rule_id
5998 , pick_slip_number pick_slip_number
5999 , cartonization_id cartonization_id
6000 , inventory_item_id
6001 , move_order_line_id
6002 FROM mtl_material_transactions_temp
6003 WHERE wms_task_type IS NOT NULL
6004 AND transaction_status = 2
6005 AND(wms_task_status IS NULL
6006 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
6007 UNION ALL
6008 SELECT MIN(mcce.cycle_count_entry_id) task_id
6009 , MIN(mcce.standard_operation_id) user_task_type_id
6010 , 3 wms_task_type_id
6011 , mcce.organization_id organization_id
6012 , mcce.subinventory ZONE
6013 , mcce.locator_id locator_id
6014 , MIN(mcce.task_priority) task_priority
6015 , mcce.revision revision
6016 , MIN(mcce.lot_number) lot_number
6017 , '' transaction_uom
6018 , TO_NUMBER(NULL) transaction_quantity
6019 , TO_NUMBER(NULL) pick_rule_id
6020 , TO_NUMBER(NULL) pick_slip_number
6021 , TO_NUMBER(NULL) cartonization_id
6022 , mcce.inventory_item_id
6023 , TO_NUMBER(NULL) move_order_line_id
6024 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
6025 WHERE mcce.entry_status_code IN(1, 3)
6026 AND NVL(mcce.export_flag, 2) = 2
6027 -- bug 3972076
6028 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6029 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
6030 AND NVL(mcch.disable_date,sysdate+1)> sysdate
6031 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
6032 , -- inlined wms_dispatchable_tasks_v, bug 2648133
6033 (SELECT utt_emp.standard_operation_id standard_operation_id
6034 , utt_emp.resource_id ROLE
6035 , utt_eqp.resource_id equipment
6036 , utt_emp.person_id emp_id
6037 , utt_eqp.inventory_item_id eqp_id
6038 , NULL eqp_srl /* removed for bug 2095237 */
6039 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6040 , x_utt_res1.resource_id resource_id
6041 , x_emp_r.person_id
6042 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6043 WHERE x_utt_res1.resource_id = r1.resource_id
6044 AND r1.resource_type = 2
6045 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6046 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6047 , x_utt_res2.resource_id resource_id
6048 , x_eqp_r.inventory_item_id inventory_item_id
6049 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6050 WHERE x_utt_res2.resource_id = r2.resource_id
6051 AND r2.resource_type = 1
6052 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6053 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6054 , -- inlined wms_person_resource_utt_v, bug 2648133
6055 mtl_item_locations loc
6056 , mtl_secondary_inventories sub
6057 , mtl_txn_request_lines mol
6058 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6059 AND(wdtv.pick_slip_number = v_pick_slip_number
6060 OR(wdtv.task_id = v_task_id
6061 AND wdtv.wms_task_type_id = v_task_type))
6062 AND wdtv.organization_id = p_sign_on_org_id
6063 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6064 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6065 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
6066 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6067 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6068 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6069 AND wdtv.locator_id = loc.inventory_location_id(+)
6070 AND wdtv.ZONE = sub.secondary_inventory_name
6071 AND wdtv.organization_id = sub.organization_id
6072 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6073 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6074 (
6075 SELECT NULL
6076 FROM mtl_material_transactions_temp mmtt
6077 WHERE mmtt.transaction_temp_id = wdtv.task_id
6078 AND mmtt.parent_line_id IS NOT NULL
6079 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6080 AND NOT EXISTS -- exclude tasks already dispatched
6081 (SELECT NULL
6082 FROM wms_dispatched_tasks wdt1
6083 WHERE wdt1.transaction_temp_id = wdtv.task_id
6084 AND wdt1.task_type = wdtv.wms_task_type_id)
6085 --******************
6086 AND wdtv.task_id NOT IN -- excluded skipped tasks
6087 (
6088 SELECT wdtv.task_id
6089 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6090 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6091 AND wste.task_id = wdtv.task_id
6092 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6093 AND wste.organization_id = mp.organization_id)
6094 --*****************
6095 --J Addition
6096 AND wdtv.ZONE not in (
6097 SELECT wd.subinventory_code
6098 FROM wms_devices_b wd
6099 , wms_bus_event_devices wbed
6100 WHERE 1 = 1
6101 and wd.device_id = wbed.device_id
6102 AND wbed.organization_id = wd.organization_id
6103 AND wd.enabled_flag = 'Y'
6104 AND wbed.enabled_flag = 'Y'
6105 AND wbed.business_event_id = 10
6106 AND wd.subinventory_code IS NOT NULL
6107 AND wd.force_sign_on_flag = 'Y'
6108 AND wd.device_id NOT IN (SELECT device_id
6109 FROM wms_device_assignment_temp
6110 WHERE employee_id = p_sign_on_emp_id)
6111 )
6112 ORDER BY nvl(wdtv.task_priority, 0)
6113 , -- removed order by segments for bug 2657909
6114 mol.header_id
6115 , sub.picking_order
6116 , loc.picking_order
6117 , (
6118 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6119 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6120 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6121 )
6122 , wdtv.task_id;
6123
6124 CURSOR l_curs_ordered_tasks_exp(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS -- bug 2648133
6125 SELECT DISTINCT wdtv.task_id task_id
6126 , -- added distinct for bug 2657909
6127 NVL(wdtv.pick_slip_number, -1) pick_slip
6128 , wdtv.wms_task_type_id
6129 , nvl(wdtv.task_priority, 0)
6130 , -- added following because of distinct for bug 2657909
6131 mol.header_id
6132 , sub.picking_order
6133 , loc.picking_order
6134 , nvl(loc.x_coordinate, 0)
6135 , nvl(loc.y_coordinate, 0)
6136 , nvl(loc.z_coordinate, 0)
6137 FROM (SELECT transaction_temp_id task_id
6138 , standard_operation_id user_task_type_id
6139 , wms_task_type wms_task_type_id
6140 , organization_id organization_id
6141 , subinventory_code ZONE
6142 , locator_id locator_id
6143 , task_priority task_priority
6144 , revision revision
6145 , lot_number lot_number
6146 , transaction_uom transaction_uom
6147 , transaction_quantity transaction_quantity
6148 , pick_rule_id pick_rule_id
6149 , pick_slip_number pick_slip_number
6150 , cartonization_id cartonization_id
6151 , inventory_item_id
6152 , move_order_line_id
6153 FROM mtl_material_transactions_temp
6154 WHERE wms_task_type IS NOT NULL
6155 AND transaction_status = 2
6156 AND(wms_task_status IS NULL
6157 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
6158 UNION ALL
6159 SELECT MIN(mcce.cycle_count_entry_id) task_id
6160 , MIN(mcce.standard_operation_id) user_task_type_id
6161 , 3 wms_task_type_id
6162 , mcce.organization_id organization_id
6163 , mcce.subinventory ZONE
6164 , mcce.locator_id locator_id
6165 , MIN(mcce.task_priority) task_priority
6166 , mcce.revision revision
6167 , MIN(mcce.lot_number) lot_number
6168 , '' transaction_uom
6169 , TO_NUMBER(NULL) transaction_quantity
6170 , TO_NUMBER(NULL) pick_rule_id
6171 , TO_NUMBER(NULL) pick_slip_number
6172 , TO_NUMBER(NULL) cartonization_id
6173 , mcce.inventory_item_id
6174 , TO_NUMBER(NULL) move_order_line_id
6175 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
6176 WHERE mcce.entry_status_code IN(1, 3)
6177 AND NVL(mcce.export_flag, 2) = 2
6178 -- bug 3972076
6179 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6180 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
6181 AND NVL(mcch.disable_date,sysdate+1)> sysdate
6182 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
6183 , -- inlined wms_dispatchable_tasks_v, bug 2648133
6184 (SELECT utt_emp.standard_operation_id standard_operation_id
6185 , utt_emp.resource_id ROLE
6186 , utt_eqp.resource_id equipment
6187 , utt_emp.person_id emp_id
6188 , utt_eqp.inventory_item_id eqp_id
6189 , NULL eqp_srl /* removed for bug 2095237 */
6190 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6191 , x_utt_res1.resource_id resource_id
6192 , x_emp_r.person_id
6193 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6194 WHERE x_utt_res1.resource_id = r1.resource_id
6195 AND r1.resource_type = 2
6196 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6197 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6198 , x_utt_res2.resource_id resource_id
6199 , x_eqp_r.inventory_item_id inventory_item_id
6200 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6201 WHERE x_utt_res2.resource_id = r2.resource_id
6202 AND r2.resource_type = 1
6203 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6204 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6205 , -- inlined wms_person_resource_utt_v, bug 2648133
6206 mtl_item_locations loc
6207 , mtl_secondary_inventories sub
6208 , mtl_txn_request_lines mol
6209 -- mtl_system_items msi -- bug 2648133
6210 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6211 AND(wdtv.pick_slip_number = v_pick_slip_number
6212 OR(wdtv.task_id = v_task_id
6213 AND wdtv.wms_task_type_id = v_task_type))
6214 AND wdtv.organization_id = p_sign_on_org_id
6215 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6216 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6217 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
6218 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6219 -- AND Nvl(v.eqp_srl, '@@@') = Nvl(l_sign_on_equipment_srl, Nvl(v.eqp_srl, '@@@')) removed for bug 2095237
6220 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6221 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6222 AND wdtv.locator_id = loc.inventory_location_id(+)
6223 AND wdtv.ZONE = sub.secondary_inventory_name
6224 AND wdtv.organization_id = sub.organization_id
6225 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6226 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
6227 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6228 (
6229 SELECT NULL
6230 FROM mtl_material_transactions_temp mmtt
6231 WHERE mmtt.transaction_temp_id = wdtv.task_id
6232 AND mmtt.parent_line_id IS NOT NULL
6233 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6234 AND NOT EXISTS -- exclude tasks already dispatched
6235 (SELECT NULL
6236 FROM wms_dispatched_tasks wdt1
6237 WHERE wdt1.transaction_temp_id = wdtv.task_id
6238 AND wdt1.task_type = wdtv.wms_task_type_id)
6239 --******************
6240 AND wdtv.task_id NOT IN -- excluded skipped tasks
6241 (
6242 SELECT wdtv.task_id
6243 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6244 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6245 AND wste.task_id = wdtv.task_id
6246 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6247 AND wste.organization_id = mp.organization_id)
6248 --*****************
6249 --J Addition
6250 AND wdtv.ZONE not in (
6251 SELECT wd.subinventory_code
6252 FROM wms_devices_b wd
6253 , wms_bus_event_devices wbed
6254 WHERE 1 = 1
6255 and wd.device_id = wbed.device_id
6256 AND wbed.organization_id = wd.organization_id
6257 AND wd.enabled_flag = 'Y'
6258 AND wbed.enabled_flag = 'Y'
6259 AND wbed.business_event_id = 10
6260 AND wd.subinventory_code IS NOT NULL
6261 AND wd.force_sign_on_flag = 'Y'
6262 AND wd.device_id NOT IN (SELECT device_id
6263 FROM wms_device_assignment_temp
6264 WHERE employee_id = p_sign_on_emp_id)
6265 )
6266 ORDER BY nvl(wdtv.task_priority, 0)
6267 , -- removed order by segments for bug 2657909
6268 mol.header_id
6269 , sub.picking_order
6270 , loc.picking_order
6271 , (
6272 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6273 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6274 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6275 )
6276 , wdtv.task_id;
6277
6278 CURSOR l_curs_ordered_tasks_aw(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
6279 SELECT DISTINCT wdtv.task_id task_id
6280 , -- added distinct for bug 2657909
6281 NVL(wdtv.pick_slip_number, -1) pick_slip
6282 , wdtv.wms_task_type_id
6283 , nvl(wdtv.task_priority, 0)
6284 , mol.header_id
6285 , sub.picking_order
6286 , loc.picking_order
6287 , nvl(loc.x_coordinate, 0)
6288 , nvl(loc.y_coordinate, 0)
6289 , nvl(loc.z_coordinate, 0)
6290 FROM (SELECT transaction_temp_id task_id
6291 , standard_operation_id user_task_type_id
6292 , wms_task_type wms_task_type_id
6293 , organization_id organization_id
6294 , subinventory_code ZONE
6295 , locator_id locator_id
6296 , task_priority task_priority
6297 , revision revision
6298 , lot_number lot_number
6299 , transaction_uom transaction_uom
6300 , transaction_quantity transaction_quantity
6301 , pick_rule_id pick_rule_id
6302 , pick_slip_number pick_slip_number
6303 , cartonization_id cartonization_id
6304 , inventory_item_id
6305 , move_order_line_id
6306 FROM mtl_material_transactions_temp
6307 WHERE wms_task_type IS NOT NULL
6308 AND transaction_status = 2
6309 AND(wms_task_status IS NULL
6310 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
6311 UNION ALL
6312 SELECT MIN(mcce.cycle_count_entry_id) task_id
6313 , MIN(mcce.standard_operation_id) user_task_type_id
6314 , 3 wms_task_type_id
6315 , mcce.organization_id organization_id
6316 , mcce.subinventory ZONE
6317 , mcce.locator_id locator_id
6318 , MIN(mcce.task_priority) task_priority
6319 , mcce.revision revision
6320 , MIN(mcce.lot_number) lot_number
6321 , '' transaction_uom
6322 , TO_NUMBER(NULL) transaction_quantity
6323 , TO_NUMBER(NULL) pick_rule_id
6324 , TO_NUMBER(NULL) pick_slip_number
6325 , TO_NUMBER(NULL) cartonization_id
6326 , mcce.inventory_item_id
6327 , TO_NUMBER(NULL) move_order_line_id
6328 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
6329 WHERE mcce.entry_status_code IN(1, 3)
6330 AND NVL(mcce.export_flag, 2) = 2
6331 -- bug 3972076
6332 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6333 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
6334 , -- inlined wms_dispatchable_tasks_v, bug 2648133
6335 (SELECT utt_emp.standard_operation_id standard_operation_id
6336 , utt_emp.resource_id ROLE
6337 , utt_eqp.resource_id equipment
6338 , utt_emp.person_id emp_id
6339 , utt_eqp.inventory_item_id eqp_id
6340 , NULL eqp_srl /* removed for bug 2095237 */
6341 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6342 , x_utt_res1.resource_id resource_id
6343 , x_emp_r.person_id
6344 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6345 WHERE x_utt_res1.resource_id = r1.resource_id
6346 AND r1.resource_type = 2
6347 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6348 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6349 , x_utt_res2.resource_id resource_id
6350 , x_eqp_r.inventory_item_id inventory_item_id
6351 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6352 WHERE x_utt_res2.resource_id = r2.resource_id
6353 AND r2.resource_type = 1
6354 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6355 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6356 , -- inlined wms_person_resource_utt_v, bug 2648133
6357 mtl_item_locations loc
6358 , mtl_secondary_inventories sub
6359 , mtl_txn_request_lines mol
6360 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6361 AND(wdtv.pick_slip_number = v_pick_slip_number
6362 OR(wdtv.task_id = v_task_id
6363 AND wdtv.wms_task_type_id = v_task_type))
6364 AND wdtv.organization_id = p_sign_on_org_id
6365 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6366 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6367 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
6368 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6369 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6370 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6371 AND wdtv.locator_id = loc.inventory_location_id(+)
6372 AND wdtv.ZONE = sub.secondary_inventory_name
6373 AND wdtv.organization_id = sub.organization_id
6374 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6375 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6376 (
6377 SELECT NULL
6378 FROM mtl_material_transactions_temp mmtt
6379 WHERE mmtt.transaction_temp_id = wdtv.task_id
6380 AND mmtt.parent_line_id IS NOT NULL
6381 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6382 AND NOT EXISTS -- exclude tasks already dispatched
6383 (SELECT NULL
6384 FROM wms_dispatched_tasks wdt1
6385 WHERE wdt1.transaction_temp_id = wdtv.task_id
6386 AND wdt1.task_type = wdtv.wms_task_type_id)
6387 --******************
6388 AND wdtv.task_id NOT IN -- excluded skipped tasks
6389 (
6390 SELECT wdtv.task_id
6391 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6392 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6393 AND wste.task_id = wdtv.task_id
6394 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6395 AND wste.organization_id = mp.organization_id)
6396 --*****************
6397 --J Addition
6398 AND wdtv.ZONE not in (
6399 SELECT wd.subinventory_code
6400 FROM wms_devices_b wd
6401 , wms_bus_event_devices wbed
6402 WHERE 1 = 1
6403 and wd.device_id = wbed.device_id
6404 AND wbed.organization_id = wd.organization_id
6405 AND wd.enabled_flag = 'Y'
6406 AND wbed.enabled_flag = 'Y'
6407 AND wbed.business_event_id = 10
6408 AND wd.subinventory_code IS NOT NULL
6409 AND wd.force_sign_on_flag = 'Y'
6410 AND wd.device_id NOT IN (SELECT device_id
6411 FROM wms_device_assignment_temp
6412 WHERE employee_id = p_sign_on_emp_id)
6413 )
6414
6415 ORDER BY nvl(wdtv.task_priority, 0)
6416 , -- removed order by segments for bug 2657909
6417 sub.picking_order
6418 , loc.picking_order
6419 , (
6420 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6421 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6422 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6423 )
6424 , wdtv.task_id;
6425
6426 CURSOR l_curs_ordered_tasks_aw_exp(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
6427 SELECT DISTINCT wdtv.task_id task_id
6428 , -- added distinct for bug 2657909
6429 NVL(wdtv.pick_slip_number, -1) pick_slip
6430 , wdtv.wms_task_type_id
6431 , nvl(wdtv.task_priority, 0)
6432 , mol.header_id
6433 , sub.picking_order
6434 , loc.picking_order
6435 , nvl(loc.x_coordinate, 0)
6436 , nvl(loc.y_coordinate, 0)
6437 , nvl(loc.z_coordinate, 0)
6438 FROM (SELECT transaction_temp_id task_id
6439 , standard_operation_id user_task_type_id
6440 , wms_task_type wms_task_type_id
6441 , organization_id organization_id
6442 , subinventory_code ZONE
6443 , locator_id locator_id
6444 , task_priority task_priority
6445 , revision revision
6446 , lot_number lot_number
6447 , transaction_uom transaction_uom
6448 , transaction_quantity transaction_quantity
6449 , pick_rule_id pick_rule_id
6450 , pick_slip_number pick_slip_number
6451 , cartonization_id cartonization_id
6452 , inventory_item_id
6453 , move_order_line_id
6454 FROM mtl_material_transactions_temp
6455 WHERE wms_task_type IS NOT NULL
6456 AND transaction_status = 2
6457 AND(wms_task_status IS NULL
6458 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
6459 UNION ALL
6460 SELECT MIN(mcce.cycle_count_entry_id) task_id
6461 , MIN(mcce.standard_operation_id) user_task_type_id
6462 , 3 wms_task_type_id
6463 , mcce.organization_id organization_id
6464 , mcce.subinventory ZONE
6465 , mcce.locator_id locator_id
6466 , MIN(mcce.task_priority) task_priority
6467 , mcce.revision revision
6468 , MIN(mcce.lot_number) lot_number
6469 , '' transaction_uom
6470 , TO_NUMBER(NULL) transaction_quantity
6471 , TO_NUMBER(NULL) pick_rule_id
6472 , TO_NUMBER(NULL) pick_slip_number
6473 , TO_NUMBER(NULL) cartonization_id
6474 , mcce.inventory_item_id
6475 , TO_NUMBER(NULL) move_order_line_id
6476 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
6477 WHERE mcce.entry_status_code IN(1, 3)
6478 AND NVL(mcce.export_flag, 2) = 2
6479 -- bug 3972076
6480 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6481 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
6482 AND NVL(mcch.disable_date,sysdate+1)> sysdate
6483 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
6484 , -- inlined wms_dispatchable_tasks_v, bug 2648133
6485 (SELECT utt_emp.standard_operation_id standard_operation_id
6486 , utt_emp.resource_id ROLE
6487 , utt_eqp.resource_id equipment
6488 , utt_emp.person_id emp_id
6489 , utt_eqp.inventory_item_id eqp_id
6490 , NULL eqp_srl /* removed for bug 2095237 */
6491 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6492 , x_utt_res1.resource_id resource_id
6493 , x_emp_r.person_id
6494 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6495 WHERE x_utt_res1.resource_id = r1.resource_id
6496 AND r1.resource_type = 2
6497 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6498 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6499 , x_utt_res2.resource_id resource_id
6500 , x_eqp_r.inventory_item_id inventory_item_id
6501 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6502 WHERE x_utt_res2.resource_id = r2.resource_id
6503 AND r2.resource_type = 1
6504 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6505 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6506 , -- inlined wms_person_resource_utt_v, bug 2648133
6507 mtl_item_locations loc
6508 , mtl_secondary_inventories sub
6509 , mtl_txn_request_lines mol
6510 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6511 AND(wdtv.pick_slip_number = v_pick_slip_number
6512 OR(wdtv.task_id = v_task_id
6513 AND wdtv.wms_task_type_id = v_task_type))
6514 AND wdtv.organization_id = p_sign_on_org_id
6515 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6516 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6517 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@')) -- bug 2648133
6518 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6519 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6520 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6521 AND wdtv.locator_id = loc.inventory_location_id(+)
6522 AND wdtv.ZONE = sub.secondary_inventory_name
6523 AND wdtv.organization_id = sub.organization_id
6524 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6525 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
6526 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6527 (
6528 SELECT NULL
6529 FROM mtl_material_transactions_temp mmtt
6530 WHERE mmtt.transaction_temp_id = wdtv.task_id
6531 AND mmtt.parent_line_id IS NOT NULL
6532 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6533 AND NOT EXISTS -- exclude tasks already dispatched
6534 (SELECT NULL
6535 FROM wms_dispatched_tasks wdt1
6536 WHERE wdt1.transaction_temp_id = wdtv.task_id
6537 AND wdt1.task_type = wdtv.wms_task_type_id)
6538 --******************
6539 AND wdtv.task_id NOT IN -- excluded skipped tasks
6540 (
6541 SELECT wdtv.task_id
6542 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6543 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6544 AND wste.task_id = wdtv.task_id
6545 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6546 AND wste.organization_id = mp.organization_id)
6547 --*****************
6548 --J Addition
6549 AND wdtv.ZONE not in (
6550 SELECT wd.subinventory_code
6551 FROM wms_devices_b wd
6552 , wms_bus_event_devices wbed
6553 WHERE 1 = 1
6554 and wd.device_id = wbed.device_id
6555 AND wbed.organization_id = wd.organization_id
6556 AND wd.enabled_flag = 'Y'
6557 AND wbed.enabled_flag = 'Y'
6558 AND wbed.business_event_id = 10
6559 AND wd.subinventory_code IS NOT NULL
6560 AND wd.force_sign_on_flag = 'Y'
6561 AND wd.device_id NOT IN (SELECT device_id
6562 FROM wms_device_assignment_temp
6563 WHERE employee_id = p_sign_on_emp_id)
6564 )
6565 ORDER BY nvl(wdtv.task_priority, 0)
6566 , -- removed order by segments for bug 2657909
6567 sub.picking_order
6568 , loc.picking_order
6569 , (
6570 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6571 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6572 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6573 )
6574 , wdtv.task_id;
6575
6576
6577 CURSOR c_lock_check(v_pick_slip_number NUMBER) IS
6578
6579 SELECT transaction_temp_id
6580 FROM mtl_material_transactions_temp mmtt
6581 WHERE mmtt.pick_slip_number = v_pick_slip_number
6582 FOR UPDATE nowait;
6583
6584
6585 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
6586 BEGIN
6587 IF (l_debug = 1) THEN
6588 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6589 END IF;
6590
6591 l_progress := '10';
6592
6593 -- This API is query only, therefore does not create a save point
6594
6595 -- Initialize message list if p_init_msg_list is set to TRUE.
6596 IF fnd_api.to_boolean(p_init_msg_list) THEN
6597 fnd_msg_pub.initialize;
6598 END IF;
6599
6600 -- Initialize API return status to success
6601 x_return_status := fnd_api.g_ret_sts_success;
6602 -- API body
6603 -- preprocess input parameters
6604
6605 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
6606
6607 IF l_sequence_picks_across_waves IS NULL THEN
6608 l_sequence_picks_across_waves := 2;
6609 END IF;
6610
6611 IF p_sign_on_equipment_srl = 'NONE' THEN
6612 l_sign_on_equipment_srl := NULL;
6613 l_sign_on_equipment_id := -999;
6614 ELSE
6615 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
6616 l_sign_on_equipment_id := p_sign_on_equipment_id;
6617 END IF;
6618
6619 -- use l_equipment_id_str to concatenate sql statement
6620 IF l_sign_on_equipment_id IS NULL THEN
6621 l_equipment_id_str := 'NULL';
6622 ELSE
6623 l_equipment_id_str := TO_CHAR(l_sign_on_equipment_id);
6624 END IF;
6625
6626 IF p_task_type = 'PICKING' THEN
6627 l_sys_task_type := 1;
6628 ELSIF p_task_type = 'EXPPICK' THEN
6629 l_sys_task_type := 1;
6630 l_is_express_pick := 1;
6631
6632 IF (l_debug = 1) THEN
6633 print_debug('Express Pick Task', 4);
6634 END IF;
6635 ELSE
6636 l_sys_task_type := NULL;
6637 END IF;
6638
6639 -- check if this call is for picking tasks or for all tasks
6640 IF p_task_type = 'DISPLAY' THEN
6641 IF (l_debug = 1) THEN
6642 print_debug('dispatch_task - DISPLAY ', 4);
6643 END IF;
6644
6645 l_progress := '20';
6646 /*
6647 l_sql_stmt :=
6648 'SELECT wdtv.task_id, wdtv.zone, wdtv.locator_id,
6649 wdtv.revision, wdtv.transaction_uom,
6650 wdtv.transaction_quantity, wdtv.lot_number, wdtv.wms_task_type_id,wdtv.task_priority
6651 FROM wms_dispatchable_tasks_v wdtv
6652 WHERE
6653 wdtv.organization_id = ' || p_sign_on_org_id ||'
6654 AND Nvl(wdtv.zone, ''@@@'') = Nvl('''|| p_sign_on_zone || ''', Nvl(wdtv.zone, ''@@@''))
6655 AND wdtv.user_task_type_id IN
6656 (
6657 SELECT standard_operation_id
6658 FROM wms_person_resource_utt_v v
6659 WHERE v.emp_id = ' || p_sign_on_emp_id ||'
6660 AND Nvl(v.eqp_srl, ''@@@'') = Nvl(''' || l_sign_on_equipment_srl || ''', Nvl(v.eqp_srl, ''@@@''))
6661 AND Nvl(v.eqp_id, -999) = Nvl(' || l_equipment_id_str ||', Nvl(v.eqp_id, -999))
6662 )
6663 --***********
6664 AND wdtv.task_id NOT IN
6665 (SELECT wdtv.task_id FROM wms_skip_task_exceptions wste, mtl_parameters mp
6666 WHERE ((SYSDATE - wste.creation_date)*24*60) < mp.skip_task_waiting_minutes
6667 AND wste.task_id = wdtv.task_id
6668 AND wste.organization_id = mp.organization_id )
6669 --************
6670 AND wdtv.task_id NOT IN
6671 (SELECT wdt1.transaction_temp_id
6672 FROM wms_dispatched_tasks wdt1
6673 -- WHERE wdt1.status = 1
6674 UNION ALL
6675 SELECT wdt2.transaction_temp_id
6676 FROM wms_exceptions wms_except, wms_dispatched_tasks wdt2
6677 WHERE wms_except.person_id = ' || p_sign_on_emp_id || '
6678 AND wdt2.task_id = wms_except.task_id
6679 AND discrepancy_type = 1
6680 )
6681 ORDER BY wdtv.pick_slip_number, wdtv.task_priority, wdtv.task_id';
6682 */
6683 ELSIF(p_task_type = 'ALL'
6684 OR p_task_type = 'EXPPICK') THEN -- the call is for ALL taks
6685 IF (l_debug = 1) THEN
6686 print_debug('dispatch_task -' || p_task_type, 4);
6687 END IF;
6688
6689 l_progress := '30';
6690
6691 -- select last task this operator was working on
6692 BEGIN
6693 SELECT transaction_temp_id
6694 , task_type
6695 , loaded_time
6696 INTO l_last_loaded_task_id
6697 , l_last_loaded_task_type
6698 , l_last_loaded_time
6699 FROM (SELECT transaction_temp_id
6700 , task_type
6701 , loaded_time
6702 FROM wms_dispatched_tasks wdt
6703 WHERE wdt.person_id = p_sign_on_emp_id
6704 AND wdt.loaded_time = (SELECT MAX(loaded_time)
6705 FROM wms_dispatched_tasks
6706 WHERE person_id = p_sign_on_emp_id))
6707 WHERE ROWNUM = 1 -- make sure only one task selected
6708 ;
6709
6710 l_progress := '31';
6711 EXCEPTION
6712 WHEN OTHERS THEN
6713 l_last_loaded_task_id := -1;
6714 END;
6715
6716 IF (l_debug = 1) THEN
6717 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
6718 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
6719 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
6720 END IF;
6721
6722 -- select last task this operator completed
6723 BEGIN
6724 l_progress := '32';
6725
6726 SELECT transaction_id
6727 , task_type
6728 , loaded_time
6729 INTO l_last_dropoff_task_id
6730 , l_last_dropoff_task_type
6731 , l_last_dropoff_time
6732 FROM (SELECT transaction_id
6733 , task_type
6734 , loaded_time
6735 FROM wms_dispatched_tasks_history wdth
6736 WHERE wdth.person_id = p_sign_on_emp_id
6737 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
6738 FROM wms_dispatched_tasks_history
6739 WHERE person_id = p_sign_on_emp_id))
6740 WHERE ROWNUM = 1 -- make sure only one task selected
6741 ;
6742
6743 l_progress := '33';
6744 EXCEPTION
6745 WHEN OTHERS THEN
6746 l_last_dropoff_task_id := -1;
6747 END;
6748
6749 IF (l_debug = 1) THEN
6750 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
6751 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
6752 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
6753 END IF;
6754
6755 IF l_last_dropoff_task_id = -1
6756 AND l_last_loaded_task_id = -1 THEN
6757 l_last_task_id := -1;
6758 ELSIF l_last_dropoff_task_id = -1 THEN
6759 l_last_task_id := l_last_loaded_task_id;
6760 l_last_task_type := l_last_loaded_task_type;
6761 l_last_task_is_drop := FALSE;
6762 ELSIF l_last_loaded_task_id = -1 THEN
6763 l_last_task_id := l_last_dropoff_task_id;
6764 l_last_task_type := l_last_dropoff_task_type;
6765 l_last_task_is_drop := TRUE;
6766 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
6767 l_last_task_id := l_last_dropoff_task_id;
6768 l_last_task_type := l_last_dropoff_task_type;
6769 l_last_task_is_drop := TRUE;
6770 END IF;
6771
6772 IF (l_debug = 1) THEN
6773 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
6774 END IF;
6775
6776 -- select locator coordinates of the the last task
6777 IF l_last_task_id <> -1 -- make sure there is a last task
6778 THEN
6779 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
6780 -- get the location from wms_dispatchable_tasks_v
6781 BEGIN
6782 l_progress := '35';
6783
6784 -- use Nvl to make sure if coordinates not defined, use 0
6785 SELECT NVL(loc.x_coordinate, 0)
6786 , NVL(loc.y_coordinate, 0)
6787 , NVL(loc.z_coordinate, 0)
6788 INTO l_cur_x
6789 , l_cur_y
6790 , l_cur_z
6791 FROM mtl_item_locations loc
6792 , (SELECT transaction_temp_id task_id
6793 , standard_operation_id user_task_type_id
6794 , wms_task_type wms_task_type_id
6795 , organization_id organization_id
6796 , subinventory_code ZONE
6797 , locator_id locator_id
6798 , task_priority task_priority
6799 , revision revision
6800 , lot_number lot_number
6801 , transaction_uom transaction_uom
6802 , transaction_quantity transaction_quantity
6803 , pick_rule_id pick_rule_id
6804 , pick_slip_number pick_slip_number
6805 , cartonization_id cartonization_id
6806 , inventory_item_id
6807 , move_order_line_id
6808 FROM mtl_material_transactions_temp
6809 WHERE wms_task_type IS NOT NULL
6810 AND transaction_status = 2
6811 UNION ALL
6812 SELECT MIN(cycle_count_entry_id) task_id
6813 , MIN(standard_operation_id) user_task_type_id
6814 , 3 wms_task_type_id
6815 , organization_id organization_id
6816 , subinventory ZONE
6817 , locator_id locator_id
6818 , MIN(task_priority) task_priority
6819 , revision revision
6820 , MIN(lot_number) lot_number
6821 , '' transaction_uom
6822 , TO_NUMBER(NULL) transaction_quantity
6823 , TO_NUMBER(NULL) pick_rule_id
6824 , TO_NUMBER(NULL) pick_slip_number
6825 , TO_NUMBER(NULL) cartonization_id
6826 , inventory_item_id
6827 , TO_NUMBER(NULL) move_order_line_id
6828 FROM mtl_cycle_count_entries
6829 WHERE entry_status_code IN(1, 3)
6830 AND NVL(export_flag, 2) = 2
6831 -- bug 3972076
6832 --AND NVL(TRUNC(count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6833 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision) wdtv -- inlined wms_dispatchable_tasks_v, bug 2648133
6834 WHERE wdtv.locator_id = loc.inventory_location_id
6835 AND wdtv.organization_id = loc.organization_id
6836 AND wdtv.task_id = l_last_task_id
6837 AND wdtv.wms_task_type_id = l_last_task_type;
6838
6839 -- Added the previous line since the task_id in the view
6840 -- might not be unique since it is the transaction_temp_id
6841 -- if it comes from MMTT but the cycle_count_entry_id if
6842 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
6843 l_progress := '36';
6844 EXCEPTION
6845 WHEN OTHERS THEN
6846 -- locator definition descripency
6847 l_cur_x := 0;
6848 l_cur_y := 0;
6849 l_cur_z := 0;
6850 END;
6851 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
6852 IF l_last_task_type <> 3 THEN -- not cycle count task
6853 -- get the location from mtl_material_transactions
6854 BEGIN
6855 l_progress := '37';
6856
6857 -- use Nvl to make sure if coordinates not defined, use 0
6858 SELECT NVL(loc.x_coordinate, 0)
6859 , NVL(loc.y_coordinate, 0)
6860 , NVL(loc.z_coordinate, 0)
6861 INTO l_cur_x
6862 , l_cur_y
6863 , l_cur_z
6864 FROM mtl_item_locations loc, mtl_material_transactions mmt
6865 WHERE mmt.locator_id = loc.inventory_location_id
6866 AND mmt.organization_id = loc.organization_id
6867 AND mmt.transaction_set_id = l_last_task_id
6868 AND ROWNUM = 1;
6869
6870 l_progress := '38';
6871 EXCEPTION
6872 WHEN OTHERS THEN
6873 -- locator definition descripency
6874 l_cur_x := 0;
6875 l_cur_y := 0;
6876 l_cur_z := 0;
6877 END;
6878 ELSE -- l_last_task_type <> 3 (Cyclt Count task)
6879 -- get the location from mtl_cycle_count_entries
6880 BEGIN
6881 l_progress := '39';
6882
6883 -- use Nvl to make sure if coordinates not defined, use 0
6884 SELECT NVL(loc.x_coordinate, 0)
6885 , NVL(loc.y_coordinate, 0)
6886 , NVL(loc.z_coordinate, 0)
6887 INTO l_cur_x
6888 , l_cur_y
6889 , l_cur_z
6890 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
6891 WHERE mcce.locator_id = loc.inventory_location_id
6892 AND mcce.organization_id = loc.organization_id
6893 AND mcce.cycle_count_entry_id = l_last_task_id;
6894
6895 l_progress := '40';
6896 EXCEPTION
6897 WHEN OTHERS THEN -- adf
6898 -- locator definition descripency
6899 l_cur_x := 0;
6900 l_cur_y := 0;
6901 l_cur_z := 0;
6902 END;
6903 END IF; -- l_last_task_type <> 3
6904 END IF; -- l_last_task_is_drop <> TRUE
6905 ELSE -- there is not a previous task at all
6906 l_cur_x := 0;
6907 l_cur_y := 0;
6908 l_cur_z := 0;
6909 END IF; -- l_last_task_id <> -1
6910
6911 l_progress := '45';
6912
6913 -- Select the most optimal task
6914 -- first select eligible tasks according to employee sign on information
6915 -- order tasks by task priority, locator picking order and locator coordinates
6916 -- approximated to current locator
6917
6918 IF (l_debug = 1) THEN
6919 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
6920 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
6921 print_debug('p_cartonization_id => ' || p_cartonization_id, 4);
6922 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
6923 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
6924 print_debug('l_cur_x => ' || l_cur_x, 4);
6925 print_debug('l_cur_y => ' || l_cur_y, 4);
6926 print_debug('l_cur_z => ' || l_cur_z, 4);
6927 END IF;
6928
6929 -- open and fetch appropriate cursor
6930
6931 -- start bug 2832818
6932 LOOP -- added loop for detecting lock for a pick slip
6933 l_is_locked := FALSE;
6934 -- end bug 2832818
6935
6936 IF l_sequence_picks_across_waves = 2 THEN -- order across wave
6937 IF p_sign_on_zone IS NOT NULL THEN -- zone passed in
6938 IF l_is_express_pick <> 1 THEN -- not express pick
6939 IF (l_debug = 1) THEN
6940 print_debug('Opt task cursor: zone passed, order across wave, not express pick (110) ', 4);
6941 END IF;
6942
6943 OPEN l_curs_opt_task_110;
6944 FETCH l_curs_opt_task_110 INTO l_opt_task_id
6945 , l_opt_task_pick_slip
6946 , l_opt_task_type
6947 , l_task_priority
6948 , l_mo_header_id
6949 , l_sub_pick_order
6950 , l_loc_pick_order
6951 , l_x_coordinate
6952 , l_y_coordinate
6953 , l_z_coordinate;
6954 CLOSE l_curs_opt_task_110;
6955 ELSE -- express pick
6956 IF (l_debug = 1) THEN
6957 print_debug('Opt task cursor: zone passed, order across wave, express pick (111)', 4);
6958 END IF;
6959
6960 OPEN l_curs_opt_task_111;
6961 FETCH l_curs_opt_task_111 INTO l_opt_task_id
6962 , l_opt_task_pick_slip
6963 , l_opt_task_type
6964 , l_task_priority
6965 , l_mo_header_id
6966 , l_sub_pick_order
6967 , l_loc_pick_order
6968 , l_x_coordinate
6969 , l_y_coordinate
6970 , l_z_coordinate;
6971 CLOSE l_curs_opt_task_111;
6972 END IF;
6973 ELSE -- zone NOT passed in
6974 IF l_is_express_pick <> 1 THEN -- not express pick
6975 IF (l_debug = 1) THEN
6976 print_debug('Opt task cursor: zone NOT passed, order across wave, NOT express pick (010) ', 4);
6977 END IF;
6978
6979 OPEN l_curs_opt_task_010;
6980 FETCH l_curs_opt_task_010 INTO l_opt_task_id
6981 , l_opt_task_pick_slip
6982 , l_opt_task_type
6983 , l_task_priority
6984 , l_mo_header_id
6985 , l_sub_pick_order
6986 , l_loc_pick_order
6987 , l_x_coordinate
6988 , l_y_coordinate
6989 , l_z_coordinate;
6990 CLOSE l_curs_opt_task_010;
6991 ELSE -- express pick
6992 IF (l_debug = 1) THEN
6993 print_debug('Opt task cursor: zone NOT passed, order across wave, express pick (011) ', 4);
6994 END IF;
6995
6996 OPEN l_curs_opt_task_011;
6997 FETCH l_curs_opt_task_011 INTO l_opt_task_id
6998 , l_opt_task_pick_slip
6999 , l_opt_task_type
7000 , l_task_priority
7001 , l_mo_header_id
7002 , l_sub_pick_order
7003 , l_loc_pick_order
7004 , l_x_coordinate
7005 , l_y_coordinate
7006 , l_z_coordinate;
7007 CLOSE l_curs_opt_task_011;
7008 END IF;
7009 END IF;
7010 ELSE -- NOT order across wave
7011 IF p_sign_on_zone IS NOT NULL THEN -- zone passed in
7012 IF l_is_express_pick <> 1 THEN -- not express pick
7013 IF (l_debug = 1) THEN
7014 print_debug('Opt task cursor: zone passed, NOT order across wave, NOT express pick (100) ', 4);
7015 END IF;
7016
7017 OPEN l_curs_opt_task_100;
7018 FETCH l_curs_opt_task_100 INTO l_opt_task_id
7019 , l_opt_task_pick_slip
7020 , l_opt_task_type
7021 , l_task_priority
7022 , l_mo_header_id
7023 , l_sub_pick_order
7024 , l_loc_pick_order
7025 , l_x_coordinate
7026 , l_y_coordinate
7027 , l_z_coordinate;
7028 CLOSE l_curs_opt_task_100;
7029 ELSE -- express pick
7030 IF (l_debug = 1) THEN
7031 print_debug('Opt task cursor: zone passed, NOT order across wave, express pick (101) ', 4);
7032 END IF;
7033
7034 OPEN l_curs_opt_task_101;
7035 FETCH l_curs_opt_task_101 INTO l_opt_task_id
7036 , l_opt_task_pick_slip
7037 , l_opt_task_type
7038 , l_task_priority
7039 , l_mo_header_id
7040 , l_sub_pick_order
7041 , l_loc_pick_order
7042 , l_x_coordinate
7043 , l_y_coordinate
7044 , l_z_coordinate;
7045 CLOSE l_curs_opt_task_101;
7046 END IF;
7047 ELSE -- zone NOT passed in
7048 IF l_is_express_pick <> 1 THEN -- not express pick
7049 IF (l_debug = 1) THEN
7050 print_debug('Opt task cursor: zone NOT passed, NOT order across wave, NOT express pick (000) ', 4);
7051 END IF;
7052
7053 OPEN l_curs_opt_task_000;
7054 FETCH l_curs_opt_task_000 INTO l_opt_task_id
7055 , l_opt_task_pick_slip
7056 , l_opt_task_type
7057 , l_task_priority
7058 , l_mo_header_id
7059 , l_sub_pick_order
7060 , l_loc_pick_order
7061 , l_x_coordinate
7062 , l_y_coordinate
7063 , l_z_coordinate;
7064 CLOSE l_curs_opt_task_000;
7065 ELSE -- express pick
7066 IF (l_debug = 1) THEN
7067 print_debug('Opt task cursor: zone NOT passed, NOT order across wave, express pick (001) ', 4);
7068 END IF;
7069
7070 OPEN l_curs_opt_task_001;
7071 FETCH l_curs_opt_task_001 INTO l_opt_task_id
7072 , l_opt_task_pick_slip
7073 , l_opt_task_type
7074 , l_task_priority
7075 , l_mo_header_id
7076 , l_sub_pick_order
7077 , l_loc_pick_order
7078 , l_x_coordinate
7079 , l_y_coordinate
7080 , l_z_coordinate;
7081 CLOSE l_curs_opt_task_001;
7082 END IF;
7083 END IF;
7084 END IF;
7085
7086 -- start bug fix 2832818
7087 IF l_opt_task_pick_slip IS NOT NULL THEN
7088
7089 IF l_debug = 1 THEN
7090 print_debug('Check pick_slip_number'|| l_opt_task_pick_slip || ' for locking.', 4);
7091 END IF;
7092
7093 BEGIN
7094 OPEN c_lock_check(l_opt_task_pick_slip);
7095 CLOSE c_lock_check;
7096 EXCEPTION
7097 WHEN OTHERS THEN
7098 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
7099 l_is_locked := TRUE;
7100
7101 IF l_debug = 1 THEN
7102 print_debug('pick_slip_number ' || l_opt_task_pick_slip ||' is locked by other user. ', 4);
7103 END IF;
7104
7105 ELSE
7106 l_is_locked := FALSE;
7107
7108 END IF;
7109
7110 IF c_lock_check%isopen THEN
7111 CLOSE c_lock_check;
7112 END IF;
7113 END;
7114 END IF;
7115
7116 IF l_is_locked = TRUE THEN
7117 print_debug('Continue looking for most optimal task since there is a lock for this pick slip.', 4);
7118
7119 ELSE
7120 print_debug('There is no lock, got the most optimal task.', 4);
7121
7122 EXIT;
7123 END IF;
7124
7125
7126 END LOOP;
7127
7128 -- End bug fix 2832818
7129
7130 IF l_opt_task_id IS NULL THEN
7131 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
7132 fnd_msg_pub.ADD;
7133
7134 IF (l_debug = 1) THEN
7135 print_debug('dispatch_task - No eligible picking tasks ', 4);
7136 END IF;
7137
7138 RAISE fnd_api.g_exc_error;
7139 END IF;
7140
7141 IF l_sequence_picks_across_waves = 2 THEN
7142 IF l_is_express_pick <> 1 THEN
7143 OPEN l_curs_ordered_tasks(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
7144 ELSE
7145 OPEN l_curs_ordered_tasks_exp(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
7146 END IF;
7147 ELSE
7148 IF l_is_express_pick <> 1 THEN
7149 OPEN l_curs_ordered_tasks_aw(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
7150 ELSE
7151 OPEN l_curs_ordered_tasks_aw_exp(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
7152 END IF;
7153 END IF;
7154
7155 l_progress := '50';
7156 l_first_task_pick_slip_number := -1;
7157 l_ordered_tasks_count := 0;
7158
7159 LOOP
7160 IF (l_debug = 1) THEN
7161 print_debug('Start looping through ordered tasks: ', 4);
7162 END IF;
7163
7164 l_opt_task_id := NULL;
7165 l_opt_task_pick_slip := NULL;
7166 -- l_opt_task_type := NULL;
7167 l_is_locked := FALSE;
7168 l_progress := '60';
7169
7170 IF l_sequence_picks_across_waves = 2 THEN
7171 IF l_is_express_pick <> 1 THEN
7172 FETCH l_curs_ordered_tasks INTO l_opt_task_id
7173 , l_opt_task_pick_slip
7174 , l_opt_task_type
7175 , l_task_priority
7176 , l_mo_header_id
7177 , l_sub_pick_order
7178 , l_loc_pick_order
7179 , l_x_coordinate
7180 , l_y_coordinate
7181 , l_z_coordinate;
7182 EXIT WHEN l_curs_ordered_tasks%NOTFOUND;
7183 ELSE
7184 FETCH l_curs_ordered_tasks_exp INTO l_opt_task_id
7185 , l_opt_task_pick_slip
7186 , l_opt_task_type
7187 , l_task_priority
7188 , l_mo_header_id
7189 , l_sub_pick_order
7190 , l_loc_pick_order
7191 , l_x_coordinate
7192 , l_y_coordinate
7193 , l_z_coordinate;
7194 EXIT WHEN l_curs_ordered_tasks_exp%NOTFOUND;
7195 END IF;
7196 ELSE
7197 IF l_is_express_pick <> 1 THEN -- bug 2648133
7198 FETCH l_curs_ordered_tasks_aw INTO l_opt_task_id
7199 , l_opt_task_pick_slip
7200 , l_opt_task_type
7201 , l_task_priority
7202 , l_mo_header_id
7203 , l_sub_pick_order
7204 , l_loc_pick_order
7205 , l_x_coordinate
7206 , l_y_coordinate
7207 , l_z_coordinate;
7208 EXIT WHEN l_curs_ordered_tasks_aw%NOTFOUND;
7209 ELSE
7210 FETCH l_curs_ordered_tasks_aw_exp INTO l_opt_task_id
7211 , l_opt_task_pick_slip
7212 , l_opt_task_type
7213 , l_task_priority
7214 , l_mo_header_id
7215 , l_sub_pick_order
7216 , l_loc_pick_order
7217 , l_x_coordinate
7218 , l_y_coordinate
7219 , l_z_coordinate;
7220 EXIT WHEN l_curs_ordered_tasks_aw_exp%NOTFOUND;
7221 END IF;
7222 END IF;
7223
7224 l_progress := '70';
7225
7226 IF (l_debug = 1) THEN
7227 print_debug('l_opt_task_id => ' || l_opt_task_id, 4);
7228 print_debug('l_opt_task_pick_slip => ' || l_opt_task_pick_slip, 4);
7229 print_debug('l_opt_task_type => ' || l_opt_task_type, 4);
7230 END IF;
7231
7232 -- bug 2648133
7233 /*
7234 IF l_is_express_pick = 1 THEN
7235
7236 IF wms_express_pick_task.is_express_pick_task_eligible(l_opt_task_id) <> 'S' THEN
7237 EXIT;
7238 END IF;
7239
7240 END IF;
7241 */
7242 IF l_ordered_tasks_count = 0 THEN -- first task
7243
7244 -- Test if this task is locked by any other user
7245 IF (l_opt_task_type <> 3) THEN
7246 -- Picking, Putaway, or Replenishment tasks
7247 IF l_opt_task_pick_slip IS NULL THEN -- bug 2832818
7248 BEGIN
7249 SELECT mmtt.transaction_temp_id
7250 INTO l_opt_task_id
7251 FROM mtl_material_transactions_temp mmtt
7252 WHERE mmtt.transaction_temp_id = l_opt_task_id
7253 FOR UPDATE NOWAIT;
7254 EXCEPTION
7255 WHEN OTHERS THEN
7256 IF (l_debug = 1) THEN
7257 print_debug('This task is locked by other user. ', 4);
7258 END IF;
7259
7260 l_is_locked := TRUE;
7261 END;
7262
7263 END IF; -- bug 2832818
7264
7265 ELSE
7266 -- Cycle counting tasks
7267 BEGIN
7268 SELECT mcce.cycle_count_entry_id
7269 INTO l_opt_task_id
7270 FROM mtl_cycle_count_entries mcce
7271 WHERE mcce.cycle_count_entry_id = l_opt_task_id
7272 FOR UPDATE NOWAIT;
7273 EXCEPTION
7274 WHEN OTHERS THEN
7275 IF (l_debug = 1) THEN
7276 print_debug('This task is locked by other user. ', 4);
7277 END IF;
7278
7279 l_is_locked := TRUE;
7280 END;
7281 END IF;
7282
7283 IF l_is_locked <> TRUE THEN
7284 l_ordered_tasks_count := l_ordered_tasks_count + 1;
7285 l_first_task_pick_slip_number := l_opt_task_pick_slip;
7286
7287 IF (l_debug = 1) THEN
7288 print_debug('This is the first task in this group. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
7289 END IF;
7290
7291 l_progress := '72';
7292
7293 INSERT INTO wms_ordered_tasks
7294 (
7295 task_id
7296 , wms_task_type
7297 , task_sequence_id
7298 )
7299 VALUES (
7300 l_opt_task_id
7301 , l_opt_task_type
7302 , l_ordered_tasks_count
7303 );
7304
7305 l_progress := '73';
7306 END IF;
7307 ELSIF l_first_task_pick_slip_number = l_opt_task_pick_slip
7308 AND l_first_task_pick_slip_number <> -1
7309 AND l_opt_task_pick_slip <> -1 THEN -- task with the same pick slip number
7310 -- Test if this task is locked by any other user
7311 IF (l_opt_task_type <> 3) THEN
7312 -- Picking, Putaway, or Replenishment tasks
7313 IF l_opt_task_pick_slip IS NULL THEN -- bug 2832818
7314 BEGIN
7315 SELECT mmtt.transaction_temp_id
7316 INTO l_opt_task_id
7317 FROM mtl_material_transactions_temp mmtt
7318 WHERE mmtt.transaction_temp_id = l_opt_task_id
7319 FOR UPDATE NOWAIT;
7320 EXCEPTION
7321 WHEN OTHERS THEN
7322 IF (l_debug = 1) THEN
7323 print_debug('This task is locked by other user. ', 4);
7324 END IF;
7325
7326 l_is_locked := TRUE;
7327 END;
7328 END IF; -- bug 2832818
7329
7330 ELSE
7331 -- Cycle counting tasks
7332 BEGIN
7333 SELECT mcce.cycle_count_entry_id
7334 INTO l_opt_task_id
7335 FROM mtl_cycle_count_entries mcce
7336 WHERE mcce.cycle_count_entry_id = l_opt_task_id
7337 FOR UPDATE NOWAIT;
7338 EXCEPTION
7339 WHEN OTHERS THEN
7340 IF (l_debug = 1) THEN
7341 print_debug('This task is locked by other user. ', 4);
7342 END IF;
7343
7344 l_is_locked := TRUE;
7345 END;
7346 END IF;
7347
7348 IF l_is_locked <> TRUE THEN
7349 l_ordered_tasks_count := l_ordered_tasks_count + 1;
7350
7351 IF (l_debug = 1) THEN
7352 print_debug('This task has the same pick slip number. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
7353 END IF;
7354
7355 l_progress := '74';
7356
7357 INSERT INTO wms_ordered_tasks
7358 (
7359 task_id
7360 , wms_task_type
7361 , task_sequence_id
7362 )
7363 VALUES (
7364 l_opt_task_id
7365 , l_opt_task_type
7366 , l_ordered_tasks_count
7367 );
7368
7369 l_progress := '75';
7370 END IF;
7371 END IF;
7372 END LOOP;
7373
7374 IF l_sequence_picks_across_waves = 2 THEN
7375 IF l_curs_ordered_tasks%ISOPEN THEN
7376 CLOSE l_curs_ordered_tasks;
7377 END IF;
7378
7379 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7380 CLOSE l_curs_ordered_tasks_exp;
7381 END IF;
7382 ELSE
7383 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7384 CLOSE l_curs_ordered_tasks_aw;
7385 END IF;
7386
7387 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7388 CLOSE l_curs_ordered_tasks_aw_exp;
7389 END IF;
7390 END IF;
7391
7392 IF (l_debug = 1) THEN
7393 print_debug('Total task dispatched: l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
7394 END IF;
7395
7396 IF l_ordered_tasks_count = 0 THEN
7397 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
7398 fnd_msg_pub.ADD;
7399
7400 IF (l_debug = 1) THEN
7401 print_debug('dispatch_task - No eligible picking tasks ', 4);
7402 END IF;
7403
7404 RAISE fnd_api.g_exc_error;
7405 END IF;
7406
7407 l_progress := '90';
7408 -- bug 2648133, inlined wms_dispatchable_tasks_v
7409 -- removed l_sql_stmt
7410
7411 l_progress := '100';
7412 END IF; -- end task type check if
7413
7414
7415 -- open reference cursor for this statement
7416
7417 IF (l_debug = 1) THEN
7418 print_debug('dispatch_task 120 - before opeing ref cursor ', 4);
7419 END IF;
7420
7421 l_progress := '110';
7422
7423 -- bug 2648133, changed to static SQL and query against base tables
7424
7425 IF l_opt_task_type <> 3 THEN -- non cycle counting tasks
7426 OPEN x_task_cur FOR
7427 SELECT mmtt.transaction_temp_id task_id
7428 , mmtt.subinventory_code ZONE
7429 , mmtt.locator_id locator_id
7430 , mmtt.revision revision
7431 , mmtt.transaction_uom transaction_uom
7432 , mmtt.transaction_quantity transaction_quantity
7433 , '' lot_number
7434 , mmtt.wms_task_type wms_task_type_id
7435 , mmtt.task_priority task_priority
7436 FROM mtl_material_transactions_temp mmtt, wms_ordered_tasks wot
7437 WHERE mmtt.wms_task_type IS NOT NULL
7438 AND mmtt.transaction_status = 2
7439 AND mmtt.transaction_temp_id = wot.task_id
7440 AND mmtt.transaction_temp_id > 0
7441 ORDER BY wot.task_sequence_id;
7442 ELSE -- cycle counting tasks
7443 OPEN x_task_cur FOR
7444 SELECT MIN(mcce.cycle_count_entry_id) task_id
7445 , mcce.subinventory ZONE
7446 , mcce.locator_id locator_id
7447 , mcce.revision revision
7448 , '' transaction_uom
7449 , TO_NUMBER(NULL) transaction_quantity
7450 , MIN(mcce.lot_number) lot_number
7451 , 3 wms_task_type_id
7452 , MIN(mcce.task_priority) task_priority
7453 FROM mtl_cycle_count_entries mcce, wms_ordered_tasks wot
7454 WHERE mcce.entry_status_code IN(1, 3)
7455 AND NVL(mcce.export_flag, 2) = 2
7456 -- bug 3972076
7457 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
7458 AND mcce.cycle_count_entry_id = wot.task_id
7459 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id
7460 , mcce.revision
7461 ORDER BY MIN(wot.task_sequence_id);
7462 END IF;
7463
7464 l_progress := '120';
7465 EXCEPTION
7466 WHEN fnd_api.g_exc_error THEN
7467 x_return_status := fnd_api.g_ret_sts_error;
7468
7469 IF l_curs_ordered_tasks%ISOPEN THEN
7470 CLOSE l_curs_ordered_tasks;
7471 END IF;
7472
7473 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7474 CLOSE l_curs_ordered_tasks_aw;
7475 END IF;
7476
7477 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7478 CLOSE l_curs_ordered_tasks_exp;
7479 END IF;
7480
7481 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7482 CLOSE l_curs_ordered_tasks_aw_exp;
7483 END IF;
7484
7485 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7486
7487 IF (l_debug = 1) THEN
7488 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7489 END IF;
7490 WHEN fnd_api.g_exc_unexpected_error THEN
7491 x_return_status := fnd_api.g_ret_sts_unexp_error;
7492
7493 IF l_curs_ordered_tasks%ISOPEN THEN
7494 CLOSE l_curs_ordered_tasks;
7495 END IF;
7496
7497 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7498 CLOSE l_curs_ordered_tasks_aw;
7499 END IF;
7500
7501 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7502 CLOSE l_curs_ordered_tasks_exp;
7503 END IF;
7504
7505 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7506 CLOSE l_curs_ordered_tasks_aw_exp;
7507 END IF;
7508
7509 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7510
7511 IF (l_debug = 1) THEN
7512 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7513 END IF;
7514 WHEN OTHERS THEN
7515 x_return_status := fnd_api.g_ret_sts_unexp_error;
7516
7517 IF l_curs_ordered_tasks%ISOPEN THEN
7518 CLOSE l_curs_ordered_tasks;
7519 END IF;
7520
7521 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7522 CLOSE l_curs_ordered_tasks_aw;
7523 END IF;
7524
7525 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7526 CLOSE l_curs_ordered_tasks_exp;
7527 END IF;
7528
7529 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7530 CLOSE l_curs_ordered_tasks_aw_exp;
7531 END IF;
7532
7533 IF SQLCODE IS NOT NULL THEN
7534 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
7535 END IF;
7536
7537 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7538
7539 IF (l_debug = 1) THEN
7540 print_debug('dispatch_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7541 END IF;
7542 END dispatch_task;
7543
7544 -- CP Enhancements
7545 -- This Method has been over-ridden for implementing the cluster picking task dispatch logic.
7546 PROCEDURE dispatch_task(
7547 p_api_version IN NUMBER
7548 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
7549 , p_commit IN VARCHAR2 := fnd_api.g_false
7550 , p_sign_on_emp_id IN NUMBER
7551 , p_sign_on_org_id IN NUMBER
7552 , p_sign_on_zone IN VARCHAR2 := NULL
7553 , p_sign_on_equipment_id IN NUMBER := NULL -- specific equip id, NULL or -999. -999 stands for none
7554 , p_sign_on_equipment_srl IN VARCHAR2 := NULL -- same as above
7555 , p_task_type IN VARCHAR2 -- 'PICKING' or 'ALL'
7556 , p_task_filter IN VARCHAR2 := NULL
7557 , p_cartonization_id IN NUMBER := NULL
7558 , x_task_cur OUT NOCOPY task_rec_cur_tp
7559 , x_return_status OUT NOCOPY VARCHAR2
7560 , x_msg_count OUT NOCOPY NUMBER
7561 , x_msg_data OUT NOCOPY VARCHAR2
7562 , p_max_clusters IN NUMBER := 0
7563 , x_deliveries_list OUT NOCOPY VARCHAR2
7564 , x_cartons_list OUT NOCOPY VARCHAR2
7565 ) IS
7566 l_cur_x NUMBER;
7567 l_cur_y NUMBER;
7568 l_cur_z NUMBER;
7569 l_is_locked BOOLEAN := FALSE;
7570 l_sys_task_type NUMBER;
7571 l_is_express_pick NUMBER := 0; -- 1 for express pick, 0 not
7572 l_sign_on_equipment_id NUMBER;
7573 l_sign_on_equipment_srl VARCHAR2(30);
7574 l_equipment_id_str VARCHAR2(30);
7575 l_last_loaded_time DATE;
7576 l_last_loaded_task_id NUMBER;
7577 l_last_loaded_task_type NUMBER;
7578 l_last_dropoff_time DATE;
7579 l_last_dropoff_task_id NUMBER;
7580 l_last_dropoff_task_type NUMBER;
7581 l_last_task_type NUMBER;
7582 l_last_task_is_drop BOOLEAN := FALSE;
7583 l_last_task_id NUMBER;
7584 l_ordered_tasks_count NUMBER;
7585 --l_first_task_pick_slip_number NUMBER;
7586
7587 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
7588 l_api_version CONSTANT NUMBER := 1.0;
7589 l_progress VARCHAR2(10);
7590 l_cluster_count NUMBER := 0;
7591
7592 -- the following is to used by task_filter
7593 l_so_allowed NUMBER := 0;
7594 l_io_allowed NUMBER := 0;
7595 l_wip_allowed NUMBER := 0;
7596
7597
7598 TYPE cluster_rec IS RECORD(
7599 cluster_id NUMBER
7600 , cluster_type VARCHAR2(1)
7601 );
7602
7603 TYPE cluster_tab IS TABLE OF cluster_rec
7604 INDEX BY BINARY_INTEGER;
7605
7606 cluster_table cluster_tab;
7607
7608 TYPE numtab IS TABLE OF NUMBER;
7609
7610 TYPE chrtab IS TABLE OF VARCHAR2(1);
7611
7612 TYPE loctab IS TABLE OF VARCHAR2(1000);
7613
7614 TYPE subtab IS TABLE OF VARCHAR2(10);
7615 TYPE datetab IS TABLE OF DATE;
7616
7617 idx NUMBER := 0;
7618 -- This variable will give the bulk collect limit. currenlty it is hardcoded
7619 -- This can be changed in future to get from a profile.
7620 blk_limit NUMBER := 200;
7621 t_opt_task_id numtab;
7622 t_carton_grouping_id numtab;
7623 t_opt_task_type numtab;
7624 l_cluster_exists BOOLEAN := FALSE;
7625 t_cluster_id numtab;
7626 t_cluster_type chrtab;
7627 t_task_priority numtab;
7628 t_sub_code subtab;
7629 t_sub_picking_order numtab;
7630 t_loc_picking_order numtab;
7631 t_xyz_distance numtab;
7632 t_loc_concat_segs loctab;
7633 t_task_status numtab;
7634 t_batch_id numtab;
7635 l_deliveries_list VARCHAR2(32000) := NULL;
7636 l_cartons_list VARCHAR2(32000) := NULL;
7637
7638 l_sequence_picks_across_waves number := 2;
7639 t_effective_start_date datetab;
7640 t_effective_end_date datetab;
7641 t_person_resource_id numtab;
7642 t_machine_resource_id numtab;
7643
7644
7645
7646
7647 CURSOR l_cp_curs_ordered_tasks IS
7648 SELECT DISTINCT wdtv.task_id task_id1
7649 , mol.carton_grouping_id
7650 , wdtv.wms_task_type_id
7651 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
7652 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
7653 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7654 , sub.secondary_inventory_name sub_secondary_inventory_name
7655 , sub.picking_order sub_picking_order
7656 , loc.picking_order loc_picking_order
7657 , (
7658 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7659 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7660 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7661 ) xyz_distance
7662 , loc.concatenated_segments loc_concat_segs
7663 FROM --wms_dispatchable_tasks_v wdtv,
7664 (SELECT transaction_temp_id task_id
7665 , standard_operation_id user_task_type_id
7666 , wms_task_type wms_task_type_id
7667 , organization_id organization_id
7668 , subinventory_code ZONE
7669 , locator_id locator_id
7670 , task_priority task_priority
7671 , revision revision
7672 , lot_number lot_number
7673 , transaction_uom transaction_uom
7674 , transaction_quantity transaction_quantity
7675 , pick_rule_id pick_rule_id
7676 , pick_slip_number pick_slip_number
7677 , cartonization_id cartonization_id
7678 , inventory_item_id
7679 , move_order_line_id
7680 FROM mtl_material_transactions_temp
7681 WHERE wms_task_type IS NOT NULL
7682 AND transaction_status = 2
7683 AND(
7684 wms_task_status IS NULL
7685 OR wms_task_status = 1
7686 ) --Added for task planning WB. bug#2651318
7687 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7688 /*UNION ALL
7689 SELECT MIN(cycle_count_entry_id) task_id,
7690 MIN(standard_operation_id) user_task_type_id,
7691 3 wms_task_type_id,
7692 organization_id organization_id,
7693 subinventory zone,
7694 locator_id locator_id,
7695 MIN(task_priority) task_priority,
7696 revision revision,
7697 MIN(lot_number) lot_number,
7698 '' transaction_uom,
7699 To_number(NULL) transaction_quantity,
7700 To_number(NULL) pick_rule_id,
7701 To_number(NULL) pick_slip_number,
7702 To_number(NULL) cartonization_id,
7703 inventory_item_id,
7704 To_number(NULL) move_order_line_id
7705 FROM mtl_cycle_count_entries
7706 WHERE entry_status_code IN (1,3)
7707 AND NVL(export_flag, 2) = 2
7708 -- bug 3972076
7709 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7710 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7711 */
7712 ) wdtv
7713 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7714 --wms_person_resource_utt_v v,
7715 (SELECT utt_emp.standard_operation_id standard_operation_id
7716 , utt_emp.resource_id ROLE
7717 , utt_eqp.resource_id equipment
7718 , utt_emp.person_id emp_id
7719 , utt_eqp.inventory_item_id eqp_id
7720 , NULL eqp_srl /* removed for bug 2095237 */
7721 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7722 , x_utt_res1.resource_id resource_id
7723 , x_emp_r.person_id
7724 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7725 WHERE x_utt_res1.resource_id = r1.resource_id
7726 AND r1.resource_type = 2
7727 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7728 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7729 , x_utt_res2.resource_id resource_id
7730 , x_eqp_r.inventory_item_id inventory_item_id
7731 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7732 WHERE x_utt_res2.resource_id = r2.resource_id
7733 AND r2.resource_type = 1
7734 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7735 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7736 , -- inlined wms_person_resource_utt_v, bug 2648133
7737 mtl_item_locations_kfv loc
7738 , --changed to kfv bug#2742611
7739 mtl_secondary_inventories sub
7740 , mtl_txn_request_lines mol
7741 , mtl_txn_request_headers moh
7742 , -- mtl_system_items msi -- bug 2648133
7743 wsh_delivery_details_ob_grp_v wdd
7744 , -- added
7745 wsh_delivery_assignments_v wda --added
7746 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7747 AND wdtv.organization_id = p_sign_on_org_id
7748 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7749 AND mol.header_id = moh.header_id
7750 AND moh.move_order_type = 3 -- only pick wave move orders are considered
7751 AND wdtv.user_task_type_id =
7752 v.standard_operation_id -- join task to resource view, check if user defined task type match
7753 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7754 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
7755 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7756 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7757 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7758 AND wdtv.locator_id = loc.inventory_location_id(+)
7759 AND wdtv.ZONE = sub.secondary_inventory_name
7760 AND wdtv.organization_id = sub.organization_id
7761 AND wdtv.move_order_line_id = mol.line_id
7762 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7763 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7764 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7765 (
7766 SELECT NULL
7767 FROM mtl_material_transactions_temp mmtt
7768 WHERE mmtt.transaction_temp_id = wdtv.task_id
7769 AND mmtt.parent_line_id IS NOT NULL
7770 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7771 AND NOT EXISTS -- exclude tasks already dispatched
7772 (SELECT NULL
7773 FROM wms_dispatched_tasks wdt1
7774 WHERE wdt1.transaction_temp_id = wdtv.task_id
7775 AND wdt1.task_type = wdtv.wms_task_type_id)
7776 -- Join with delivery details
7777 AND(wdd.move_order_line_id = wdtv.move_order_line_id
7778 AND wdd.delivery_detail_id = wda.delivery_detail_id)
7779 --******************
7780 AND wdtv.task_id NOT IN -- excluded skipped tasks
7781 (
7782 SELECT wdtv.task_id
7783 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7784 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7785 AND wste.task_id = wdtv.task_id
7786 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7787 AND wste.organization_id = mp.organization_id)
7788 --J Addition
7789 AND wdtv.ZONE not in (
7790 SELECT wd.subinventory_code
7791 FROM wms_devices_b wd
7792 , wms_bus_event_devices wbed
7793 WHERE 1 = 1
7794 and wd.device_id = wbed.device_id
7795 AND wbed.organization_id = wd.organization_id
7796 AND wd.enabled_flag = 'Y'
7797 AND wbed.enabled_flag = 'Y'
7798 AND wbed.business_event_id = 10
7799 AND wd.subinventory_code IS NOT NULL
7800 AND wd.force_sign_on_flag = 'Y'
7801 AND wd.device_id NOT IN (SELECT device_id
7802 FROM wms_device_assignment_temp
7803 WHERE employee_id = p_sign_on_emp_id)
7804 )
7805
7806 --*****************
7807 UNION ALL
7808 -- This will select the WIP Jobs alone
7809 SELECT wdtv.task_id task_id1
7810 , mol.carton_grouping_id
7811 , wdtv.wms_task_type_id
7812 , mol.carton_grouping_id cluster_id
7813 , 'C' cluster_type
7814 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7815 , sub.secondary_inventory_name sub_secondary_inventory_name
7816 , sub.picking_order sub_picking_order
7817 , loc.picking_order loc_picking_order
7818 , (
7819 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7820 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7821 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7822 ) xyz_distance
7823 , loc.concatenated_segments loc_concat_segs
7824 FROM --wms_dispatchable_tasks_v wdtv,
7825 (SELECT transaction_temp_id task_id
7826 , standard_operation_id user_task_type_id
7827 , wms_task_type wms_task_type_id
7828 , organization_id organization_id
7829 , subinventory_code ZONE
7830 , locator_id locator_id
7831 , task_priority task_priority
7832 , revision revision
7833 , lot_number lot_number
7834 , transaction_uom transaction_uom
7835 , transaction_quantity transaction_quantity
7836 , pick_rule_id pick_rule_id
7837 , pick_slip_number pick_slip_number
7838 , cartonization_id cartonization_id
7839 , inventory_item_id
7840 , move_order_line_id
7841 FROM mtl_material_transactions_temp
7842 WHERE wms_task_type IS NOT NULL
7843 AND transaction_status = 2
7844 AND(
7845 wms_task_status IS NULL
7846 OR wms_task_status = 1
7847 ) --Added for task planning WB. bug#2651318
7848 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7849 /*UNION ALL
7850 SELECT MIN(cycle_count_entry_id) task_id,
7851 MIN(standard_operation_id) user_task_type_id,
7852 3 wms_task_type_id,
7853 organization_id organization_id,
7854 subinventory zone,
7855 locator_id locator_id,
7856 MIN(task_priority) task_priority,
7857 revision revision,
7858 MIN(lot_number) lot_number,
7859 '' transaction_uom,
7860 To_number(NULL) transaction_quantity,
7861 To_number(NULL) pick_rule_id,
7862 To_number(NULL) pick_slip_number,
7863 To_number(NULL) cartonization_id,
7864 inventory_item_id,
7865 To_number(NULL) move_order_line_id
7866 FROM mtl_cycle_count_entries
7867 WHERE entry_status_code IN (1,3)
7868 AND NVL(export_flag, 2) = 2
7869 -- bug 3972076
7870 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7871 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7872 */
7873 ) wdtv
7874 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7875 --wms_person_resource_utt_v v,
7876 (SELECT utt_emp.standard_operation_id standard_operation_id
7877 , utt_emp.resource_id ROLE
7878 , utt_eqp.resource_id equipment
7879 , utt_emp.person_id emp_id
7880 , utt_eqp.inventory_item_id eqp_id
7881 , NULL eqp_srl /* removed for bug 2095237 */
7882 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7883 , x_utt_res1.resource_id resource_id
7884 , x_emp_r.person_id
7885 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7886 WHERE x_utt_res1.resource_id = r1.resource_id
7887 AND r1.resource_type = 2
7888 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7889 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7890 , x_utt_res2.resource_id resource_id
7891 , x_eqp_r.inventory_item_id inventory_item_id
7892 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7893 WHERE x_utt_res2.resource_id = r2.resource_id
7894 AND r2.resource_type = 1
7895 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7896 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7897 , -- inlined wms_person_resource_utt_v, bug 2648133
7898 mtl_item_locations_kfv loc
7899 , --changed to kfv bug#2742611
7900 mtl_secondary_inventories sub
7901 , mtl_txn_request_lines mol
7902 , mtl_txn_request_headers moh
7903 -- mtl_system_items msi -- bug 2648133
7904 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7905 AND wdtv.organization_id = p_sign_on_org_id
7906 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7907 AND mol.header_id = moh.header_id
7908 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
7909 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
7910 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7911 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
7912 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7913 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7914 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7915 AND wdtv.locator_id = loc.inventory_location_id(+)
7916 AND wdtv.ZONE = sub.secondary_inventory_name
7917 AND wdtv.organization_id = sub.organization_id
7918 AND wdtv.move_order_line_id = mol.line_id
7919 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7920 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7921 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7922 (
7923 SELECT NULL
7924 FROM mtl_material_transactions_temp mmtt
7925 WHERE mmtt.transaction_temp_id = wdtv.task_id
7926 AND mmtt.parent_line_id IS NOT NULL
7927 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7928 AND NOT EXISTS -- exclude tasks already dispatched
7929 (SELECT NULL
7930 FROM wms_dispatched_tasks wdt1
7931 WHERE wdt1.transaction_temp_id = wdtv.task_id
7932 AND wdt1.task_type = wdtv.wms_task_type_id)
7933 --******************
7934 AND wdtv.task_id NOT IN -- excluded skipped tasks
7935 (
7936 SELECT wdtv.task_id
7937 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7938 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7939 AND wste.task_id = wdtv.task_id
7940 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7941 AND wste.organization_id = mp.organization_id)
7942 --*****************
7943 --J Addition
7944 AND wdtv.ZONE not in (
7945 SELECT wd.subinventory_code
7946 FROM wms_devices_b wd
7947 , wms_bus_event_devices wbed
7948 WHERE 1 = 1
7949 and wd.device_id = wbed.device_id
7950 AND wbed.organization_id = wd.organization_id
7951 AND wd.enabled_flag = 'Y'
7952 AND wbed.enabled_flag = 'Y'
7953 AND wbed.business_event_id = 10
7954 AND wd.subinventory_code IS NOT NULL
7955 AND wd.force_sign_on_flag = 'Y'
7956 AND wd.device_id NOT IN (SELECT device_id
7957 FROM wms_device_assignment_temp
7958 WHERE employee_id = p_sign_on_emp_id)
7959 )
7960 ORDER BY wdtv_task_priority
7961 , sub_picking_order
7962 , sub_secondary_inventory_name
7963 , loc_picking_order
7964 , xyz_distance
7965 , loc_concat_segs
7966 , task_id1;
7967
7968 CURSOR l_cp_curs_ordered_tasks_no_sub IS -- bug 2648133
7969 SELECT DISTINCT wdtv.task_id task_id1
7970 , mol.carton_grouping_id
7971 , wdtv.wms_task_type_id
7972 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
7973 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
7974 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7975 , sub.secondary_inventory_name sub_secondary_inventory_name
7976 , sub.picking_order sub_picking_order
7977 , loc.picking_order loc_picking_order
7978 , (
7979 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7980 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7981 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7982 ) xyz_distance
7983 , loc.concatenated_segments loc_concat_segs
7984 FROM --wms_dispatchable_tasks_v wdtv,
7985 (SELECT transaction_temp_id task_id
7986 , standard_operation_id user_task_type_id
7987 , wms_task_type wms_task_type_id
7988 , organization_id organization_id
7989 , subinventory_code ZONE
7990 , locator_id locator_id
7991 , task_priority task_priority
7992 , revision revision
7993 , lot_number lot_number
7994 , transaction_uom transaction_uom
7995 , transaction_quantity transaction_quantity
7996 , pick_rule_id pick_rule_id
7997 , pick_slip_number pick_slip_number
7998 , cartonization_id cartonization_id
7999 , inventory_item_id
8000 , move_order_line_id
8001 FROM mtl_material_transactions_temp
8002 WHERE wms_task_type IS NOT NULL
8003 AND transaction_status = 2
8004 AND(
8005 wms_task_status IS NULL
8006 OR wms_task_status = 1
8007 ) --Added for task planning WB. bug#2651318
8008 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
8009 /*UNION ALL
8010 SELECT MIN(cycle_count_entry_id) task_id,
8011 MIN(standard_operation_id) user_task_type_id,
8012 3 wms_task_type_id,
8013 organization_id organization_id,
8014 subinventory zone,
8015 locator_id locator_id,
8016 MIN(task_priority) task_priority,
8017 revision revision,
8018 MIN(lot_number) lot_number,
8019 '' transaction_uom,
8020 To_number(NULL) transaction_quantity,
8021 To_number(NULL) pick_rule_id,
8022 To_number(NULL) pick_slip_number,
8023 To_number(NULL) cartonization_id,
8024 inventory_item_id,
8025 To_number(NULL) move_order_line_id
8026 FROM mtl_cycle_count_entries
8027 WHERE entry_status_code IN (1,3)
8028 AND NVL(export_flag, 2) = 2
8029 -- bug 3972076
8030 -- AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
8031 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
8032 */
8033 ) wdtv
8034 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8035 --wms_person_resource_utt_v v,
8036 (SELECT utt_emp.standard_operation_id standard_operation_id
8037 , utt_emp.resource_id ROLE
8038 , utt_eqp.resource_id equipment
8039 , utt_emp.person_id emp_id
8040 , utt_eqp.inventory_item_id eqp_id
8041 , NULL eqp_srl /* removed for bug 2095237 */
8042 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8043 , x_utt_res1.resource_id resource_id
8044 , x_emp_r.person_id
8045 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8046 WHERE x_utt_res1.resource_id = r1.resource_id
8047 AND r1.resource_type = 2
8048 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8049 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8050 , x_utt_res2.resource_id resource_id
8051 , x_eqp_r.inventory_item_id inventory_item_id
8052 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8053 WHERE x_utt_res2.resource_id = r2.resource_id
8054 AND r2.resource_type = 1
8055 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8056 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8057 , -- inlined wms_person_resource_utt_v, bug 2648133
8058 mtl_item_locations_kfv loc
8059 , --changed to kfv bug#2742611
8060 mtl_secondary_inventories sub
8061 , mtl_txn_request_lines mol
8062 , mtl_txn_request_headers moh
8063 , -- mtl_system_items msi -- bug 2648133
8064 wsh_delivery_details_ob_grp_v wdd
8065 , -- added
8066 wsh_delivery_assignments_v wda --added
8067 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8068 AND wdtv.organization_id = p_sign_on_org_id
8069 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8070 AND mol.header_id = moh.header_id
8071 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8072 AND wdtv.user_task_type_id =
8073 v.standard_operation_id -- join task to resource view, check if user defined task type match
8074 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8075 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8076 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8077 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8078 AND wdtv.locator_id = loc.inventory_location_id(+)
8079 AND wdtv.ZONE = sub.secondary_inventory_name
8080 AND wdtv.organization_id = sub.organization_id
8081 AND wdtv.move_order_line_id = mol.line_id
8082 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8083 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8084 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8085 (
8086 SELECT NULL
8087 FROM mtl_material_transactions_temp mmtt
8088 WHERE mmtt.transaction_temp_id = wdtv.task_id
8089 AND mmtt.parent_line_id IS NOT NULL
8090 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8091 AND NOT EXISTS -- exclude tasks already dispatched
8092 (SELECT NULL
8093 FROM wms_dispatched_tasks wdt1
8094 WHERE wdt1.transaction_temp_id = wdtv.task_id
8095 AND wdt1.task_type = wdtv.wms_task_type_id)
8096 -- Join with delivery details
8097 AND(wdd.move_order_line_id = wdtv.move_order_line_id
8098 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8099 --******************
8100 AND wdtv.task_id NOT IN -- excluded skipped tasks
8101 (
8102 SELECT wdtv.task_id
8103 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8104 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8105 AND wste.task_id = wdtv.task_id
8106 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8107 AND wste.organization_id = mp.organization_id)
8108 --*****************
8109 --J Addition
8110 AND wdtv.ZONE not in (
8111 SELECT wd.subinventory_code
8112 FROM wms_devices_b wd
8113 , wms_bus_event_devices wbed
8114 WHERE 1 = 1
8115 and wd.device_id = wbed.device_id
8116 AND wbed.organization_id = wd.organization_id
8117 AND wd.enabled_flag = 'Y'
8118 AND wbed.enabled_flag = 'Y'
8119 AND wbed.business_event_id = 10
8120 AND wd.subinventory_code IS NOT NULL
8121 AND wd.force_sign_on_flag = 'Y'
8122 AND wd.device_id NOT IN (SELECT device_id
8123 FROM wms_device_assignment_temp
8124 WHERE employee_id = p_sign_on_emp_id)
8125 )
8126
8127 UNION ALL
8128 -- This will select the WIP Jobs alone
8129 SELECT wdtv.task_id task_id1
8130 , mol.carton_grouping_id
8131 , wdtv.wms_task_type_id
8132 , mol.carton_grouping_id cluster_id
8133 , 'C' cluster_type
8134 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8135 , sub.secondary_inventory_name sub_secondary_inventory_name
8136 , sub.picking_order sub_picking_order
8137 , loc.picking_order loc_picking_order
8138 , (
8139 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8140 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8141 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8142 ) xyz_distance
8143 , loc.concatenated_segments loc_concat_segs
8144 FROM --wms_dispatchable_tasks_v wdtv,
8145 (SELECT transaction_temp_id task_id
8146 , standard_operation_id user_task_type_id
8147 , wms_task_type wms_task_type_id
8148 , organization_id organization_id
8149 , subinventory_code ZONE
8150 , locator_id locator_id
8151 , task_priority task_priority
8152 , revision revision
8153 , lot_number lot_number
8154 , transaction_uom transaction_uom
8155 , transaction_quantity transaction_quantity
8156 , pick_rule_id pick_rule_id
8157 , pick_slip_number pick_slip_number
8158 , cartonization_id cartonization_id
8159 , inventory_item_id
8160 , move_order_line_id
8161 FROM mtl_material_transactions_temp
8162 WHERE wms_task_type IS NOT NULL
8163 AND transaction_status = 2
8164 AND(
8165 wms_task_status IS NULL
8166 OR wms_task_status = 1
8167 ) --Added for task planning WB. bug#2651318
8168 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
8169 /*UNION ALL
8170 SELECT MIN(cycle_count_entry_id) task_id,
8171 MIN(standard_operation_id) user_task_type_id,
8172 3 wms_task_type_id,
8173 organization_id organization_id,
8174 subinventory zone,
8175 locator_id locator_id,
8176 MIN(task_priority) task_priority,
8177 revision revision,
8178 MIN(lot_number) lot_number,
8179 '' transaction_uom,
8180 To_number(NULL) transaction_quantity,
8181 To_number(NULL) pick_rule_id,
8182 To_number(NULL) pick_slip_number,
8183 To_number(NULL) cartonization_id,
8184 inventory_item_id,
8185 To_number(NULL) move_order_line_id
8186 FROM mtl_cycle_count_entries
8187 WHERE entry_status_code IN (1,3)
8188 AND NVL(export_flag, 2) = 2
8189 -- bug 3972076
8190 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
8191 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
8192 */
8193 ) wdtv
8194 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8195 --wms_person_resource_utt_v v,
8196 (SELECT utt_emp.standard_operation_id standard_operation_id
8197 , utt_emp.resource_id ROLE
8198 , utt_eqp.resource_id equipment
8199 , utt_emp.person_id emp_id
8200 , utt_eqp.inventory_item_id eqp_id
8201 , NULL eqp_srl /* removed for bug 2095237 */
8202 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8203 , x_utt_res1.resource_id resource_id
8204 , x_emp_r.person_id
8205 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8206 WHERE x_utt_res1.resource_id = r1.resource_id
8207 AND r1.resource_type = 2
8208 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8209 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8210 , x_utt_res2.resource_id resource_id
8211 , x_eqp_r.inventory_item_id inventory_item_id
8212 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8213 WHERE x_utt_res2.resource_id = r2.resource_id
8214 AND r2.resource_type = 1
8215 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8216 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8217 , -- inlined wms_person_resource_utt_v, bug 2648133
8218 mtl_item_locations_kfv loc
8219 , --changed to kfv bug#2742611
8220 mtl_secondary_inventories sub
8221 , mtl_txn_request_lines mol
8222 , mtl_txn_request_headers moh
8223 -- mtl_system_items msi -- bug 2648133
8224 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8225 AND wdtv.organization_id = p_sign_on_org_id
8226 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8227 AND mol.header_id = moh.header_id
8228 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8229 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
8230 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8231 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8232 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8233 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8234 AND wdtv.locator_id = loc.inventory_location_id(+)
8235 AND wdtv.ZONE = sub.secondary_inventory_name
8236 AND wdtv.organization_id = sub.organization_id
8237 AND wdtv.move_order_line_id = mol.line_id
8238 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8239 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8240 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8241 (
8242 SELECT NULL
8243 FROM mtl_material_transactions_temp mmtt
8244 WHERE mmtt.transaction_temp_id = wdtv.task_id
8245 AND mmtt.parent_line_id IS NOT NULL
8246 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8247 AND NOT EXISTS -- exclude tasks already dispatched
8248 (SELECT NULL
8249 FROM wms_dispatched_tasks wdt1
8250 WHERE wdt1.transaction_temp_id = wdtv.task_id
8251 AND wdt1.task_type = wdtv.wms_task_type_id)
8252 --******************
8253 AND wdtv.task_id NOT IN -- excluded skipped tasks
8254 (
8255 SELECT wdtv.task_id
8256 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8257 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8258 AND wste.task_id = wdtv.task_id
8259 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8260 AND wste.organization_id = mp.organization_id)
8261 --*****************
8262 --J Addition
8263 AND wdtv.ZONE not in ( SELECT wd.subinventory_code
8264 FROM wms_devices_b wd
8265 , wms_bus_event_devices wbed
8266 WHERE 1 = 1
8267 and wd.device_id = wbed.device_id
8268 AND wbed.organization_id = wd.organization_id
8269 AND wd.enabled_flag = 'Y'
8270 AND wbed.enabled_flag = 'Y'
8271 AND wbed.business_event_id = 10
8272 AND wd.subinventory_code IS NOT NULL
8273 AND wd.force_sign_on_flag = 'Y'
8274 AND wd.device_id NOT IN (SELECT device_id
8275 FROM wms_device_assignment_temp
8276 WHERE employee_id = p_sign_on_emp_id)
8277 )
8278 ORDER BY wdtv_task_priority
8279 , sub_picking_order
8280 , sub_secondary_inventory_name
8281 , loc_picking_order
8282 , xyz_distance
8283 , loc_concat_segs
8284 , task_id1;
8285
8286 ------------- the following cursors will be used for patchset J cluster picking from APL
8287
8288 -- following cursor for SO and IO and sub entered -----
8289 CURSOR l_cp_ordered_tasks_SI IS
8290 SELECT DISTINCT
8291 qt.task_id task_id1
8292 , mol.carton_grouping_id
8293 , qt.wms_task_type_id
8294 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8295 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8296 , nvl(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
8297 , sub.secondary_inventory_name sub_secondary_inventory_name
8298 , sub.picking_order sub_picking_order
8299 , loc.picking_order loc_picking_order
8300 , (
8301 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8302 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8303 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8304 ) xyz_distance
8305 , loc.concatenated_segments loc_concat_segs
8306 ,wdt.status task_status --bug 4310093
8307 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8308 , wdt.effective_start_date
8309 , wdt.effective_end_date
8310 , wdt.person_resource_id
8311 , wdt.machine_resource_id
8312 FROM wms_dispatched_tasks wdt,
8313 (SELECT transaction_temp_id task_id
8314 , standard_operation_id user_task_type_id
8315 , wms_task_type wms_task_type_id
8316 , organization_id organization_id
8317 , subinventory_code ZONE
8318 , locator_id locator_id
8319 , task_priority task_priority
8320 , revision revision
8321 , lot_number lot_number
8322 , transaction_uom transaction_uom
8323 , transaction_quantity transaction_quantity
8324 , pick_rule_id pick_rule_id
8325 , pick_slip_number pick_slip_number
8326 , cartonization_id cartonization_id
8327 , inventory_item_id
8328 , move_order_line_id
8329 FROM mtl_material_transactions_temp
8330 WHERE wms_task_type IS NOT NULL
8331 AND transaction_status = 2
8332 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8333 8, l_io_allowed) = 1 -- filter out the request so or io
8334 AND(
8335 wms_task_status IS NULL
8336 OR wms_task_status = 1
8337 ) --Added for task planning WB. bug#2651318
8338 ) qt
8339 , (SELECT
8340 bsor.standard_operation_id,
8341 bre.resource_id,
8342 bre.inventory_item_id equipment_id
8343 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8344 WHERE bsor.resource_id = bre.resource_id
8345 AND br.resource_type = 1
8346 AND bsor.resource_id = br.resource_id) e
8347 , mtl_item_locations_kfv loc
8348 , --changed to kfv bug#2742611
8349 mtl_secondary_inventories sub
8350 , mtl_txn_request_lines mol
8351 , mtl_txn_request_headers moh
8352 , -- mtl_system_items msi -- bug 2648133
8353 wsh_delivery_details_ob_grp_v wdd
8354 , -- added
8355 wsh_delivery_assignments_v wda --added
8356 WHERE wdt.transaction_temp_id = qt.task_id
8357 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8358 AND wdt.person_id = p_sign_on_emp_id
8359 AND wdt.organization_id = p_sign_on_org_id
8360 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
8361 AND mol.header_id = moh.header_id
8362 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8363 AND qt.user_task_type_id =
8364 e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8365 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8366 AND qt.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8367 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
8368 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8369 AND qt.organization_id = loc.organization_id
8370 AND qt.locator_id = loc.inventory_location_id
8371 AND qt.ZONE = sub.secondary_inventory_name
8372 AND qt.organization_id = sub.organization_id
8373 AND qt.move_order_line_id = mol.line_id
8374 -- Join with delivery details
8375 AND(wdd.move_order_line_id = qt.move_order_line_id
8376 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8377 UNION ALL
8378 SELECT DISTINCT wdtv.task_id task_id1
8379 , mol.carton_grouping_id
8380 , wdtv.wms_task_type_id
8381 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8382 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8383 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8384 , sub.secondary_inventory_name sub_secondary_inventory_name
8385 , sub.picking_order sub_picking_order
8386 , loc.picking_order loc_picking_order
8387 , (
8388 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8389 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8390 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8391 ) xyz_distance
8392 , loc.concatenated_segments loc_concat_segs
8393 ,1 task_status
8394 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8395 ,v.effective_start_date
8396 ,v.effective_end_date
8397 ,v.role person_resource_id
8398 ,v.equipment machine_resource_id
8399 FROM --wms_dispatchable_tasks_v wdtv,
8400 (SELECT transaction_temp_id task_id
8401 , standard_operation_id user_task_type_id
8402 , wms_task_type wms_task_type_id
8403 , organization_id organization_id
8404 , subinventory_code ZONE
8405 , locator_id locator_id
8406 , task_priority task_priority
8407 , revision revision
8408 , lot_number lot_number
8409 , transaction_uom transaction_uom
8410 , transaction_quantity transaction_quantity
8411 , pick_rule_id pick_rule_id
8412 , pick_slip_number pick_slip_number
8413 , cartonization_id cartonization_id
8414 , inventory_item_id
8415 , move_order_line_id
8416 FROM mtl_material_transactions_temp
8417 WHERE wms_task_type IS NOT NULL
8418 AND transaction_status = 2
8419 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8420 8, l_io_allowed) = 1 -- filter out the request so or io
8421 AND(
8422 wms_task_status IS NULL
8423 OR wms_task_status = 1
8424 ) --Added for task planning WB. bug#2651318
8425 ) wdtv
8426 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8427 --wms_person_resource_utt_v v,
8428 (SELECT utt_emp.standard_operation_id standard_operation_id
8429 , utt_emp.resource_id ROLE
8430 , utt_eqp.resource_id equipment
8431 , utt_emp.person_id emp_id
8432 , utt_eqp.inventory_item_id eqp_id
8433 , NULL eqp_srl /* removed for bug 2095237 */
8434 , utt_emp.effective_start_date
8435 , utt_emp.effective_end_date
8436 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8437 , x_utt_res1.resource_id resource_id
8438 , x_emp_r.person_id
8439 , x_emp_r.effective_start_date
8440 , x_emp_r.effective_end_date
8441 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8442 WHERE x_utt_res1.resource_id = r1.resource_id
8443 AND r1.resource_type = 2
8444 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8445 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8446 , x_utt_res2.resource_id resource_id
8447 , x_eqp_r.inventory_item_id inventory_item_id
8448 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8449 WHERE x_utt_res2.resource_id = r2.resource_id
8450 AND r2.resource_type = 1
8451 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8452 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8453 , -- inlined wms_person_resource_utt_v, bug 2648133
8454 mtl_item_locations_kfv loc
8455 , --changed to kfv bug#2742611
8456 mtl_secondary_inventories sub
8457 , mtl_txn_request_lines mol
8458 , mtl_txn_request_headers moh
8459 , -- mtl_system_items msi -- bug 2648133
8460 wsh_delivery_details_ob_grp_v wdd
8461 , -- added
8462 wsh_delivery_assignments_v wda --added
8463 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8464 AND wdtv.organization_id = p_sign_on_org_id
8465 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8466 AND mol.header_id = moh.header_id
8467 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8468 AND wdtv.user_task_type_id =
8469 v.standard_operation_id -- join task to resource view, check if user defined task type match
8470 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8471 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8472 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8473 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8474 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8475 AND wdtv.locator_id = loc.inventory_location_id(+)
8476 AND wdtv.ZONE = sub.secondary_inventory_name
8477 AND wdtv.organization_id = sub.organization_id
8478 AND wdtv.move_order_line_id = mol.line_id
8479 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8480 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8481 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8482 (
8483 SELECT NULL
8484 FROM mtl_material_transactions_temp mmtt
8485 WHERE mmtt.transaction_temp_id = wdtv.task_id
8486 AND mmtt.parent_line_id IS NOT NULL
8487 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8488 AND NOT EXISTS -- exclude tasks already dispatched
8489 (SELECT NULL
8490 FROM wms_dispatched_tasks wdt1
8491 WHERE wdt1.transaction_temp_id = wdtv.task_id
8492 AND wdt1.task_type = wdtv.wms_task_type_id)
8493 -- Join with delivery details
8494 AND(wdd.move_order_line_id = wdtv.move_order_line_id
8495 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8496 --******************
8497 AND wdtv.task_id NOT IN -- excluded skipped tasks
8498 (
8499 SELECT wdtv.task_id
8500 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8501 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8502 AND wste.task_id = wdtv.task_id
8503 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8504 AND wste.organization_id = mp.organization_id)
8505 --J Addition
8506 AND wdtv.ZONE not in (
8507 SELECT wd.subinventory_code
8508 FROM wms_devices_b wd
8509 , wms_bus_event_devices wbed
8510 WHERE 1 = 1
8511 and wd.device_id = wbed.device_id
8512 AND wbed.organization_id = wd.organization_id
8513 AND wd.enabled_flag = 'Y'
8514 AND wbed.enabled_flag = 'Y'
8515 AND wbed.business_event_id = 10
8516 AND wd.subinventory_code IS NOT NULL
8517 AND wd.force_sign_on_flag = 'Y'
8518 AND wd.device_id NOT IN (SELECT device_id
8519 FROM wms_device_assignment_temp
8520 WHERE employee_id = p_sign_on_emp_id)
8521 )
8522
8523 ORDER BY wdtv_task_priority DESC
8524 , batch_id
8525 , task_status DESC
8526 , sub_picking_order
8527 , loc_picking_order
8528 , xyz_distance
8529 , task_id1;
8530
8531 -------------------------
8532 -- following cursor for WIP and sub entered -----
8533 CURSOR l_cp_ordered_tasks_W IS
8534 SELECT DISTINCT
8535 wdtv.task_id task_id1
8536 , mol.carton_grouping_id
8537 , wdtv.wms_task_type_id
8538 , mol.carton_grouping_id cluster_id
8539 , 'C' cluster_type
8540 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8541 , sub.secondary_inventory_name sub_secondary_inventory_name
8542 , sub.picking_order sub_picking_order
8543 , loc.picking_order loc_picking_order
8544 , (
8545 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8546 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8547 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8548 ) xyz_distance
8549 , loc.concatenated_segments loc_concat_segs
8550 ,wdt.status task_status --bug 4310093
8551 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8552 , wdt.effective_start_date
8553 , wdt.effective_end_date
8554 , wdt.person_resource_id
8555 , wdt.machine_resource_id
8556 FROM wms_dispatched_tasks wdt,
8557 (SELECT transaction_temp_id task_id
8558 , standard_operation_id user_task_type_id
8559 , wms_task_type wms_task_type_id
8560 , organization_id organization_id
8561 , subinventory_code ZONE
8562 , locator_id locator_id
8563 , task_priority task_priority
8564 , revision revision
8565 , lot_number lot_number
8566 , transaction_uom transaction_uom
8567 , transaction_quantity transaction_quantity
8568 , pick_rule_id pick_rule_id
8569 , pick_slip_number pick_slip_number
8570 , cartonization_id cartonization_id
8571 , inventory_item_id
8572 , move_order_line_id
8573 FROM mtl_material_transactions_temp
8574 WHERE wms_task_type IS NOT NULL
8575 AND transaction_status = 2
8576 AND(
8577 wms_task_status IS NULL
8578 OR wms_task_status = 1
8579 ) --Added for task planning WB. bug#2651318
8580 ) wdtv
8581 , (SELECT
8582 bsor.standard_operation_id,
8583 bre.resource_id,
8584 bre.inventory_item_id equipment_id
8585 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8586 WHERE bsor.resource_id = bre.resource_id
8587 AND br.resource_type = 1
8588 AND bsor.resource_id = br.resource_id) e
8589 , mtl_item_locations_kfv loc
8590 , --changed to kfv bug#2742611
8591 mtl_secondary_inventories sub
8592 , mtl_txn_request_lines mol
8593 , mtl_txn_request_headers moh
8594 -- mtl_system_items msi -- bug 2648133
8595 WHERE wdt.transaction_temp_id = wdtv.task_id
8596 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8597 AND wdt.person_id = p_sign_on_emp_id
8598 AND wdt.organization_id = p_sign_on_org_id
8599 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8600 AND mol.header_id = moh.header_id
8601 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8602 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8603 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8604 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8605 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8606 AND wdtv.organization_id = loc.organization_id
8607 AND wdtv.locator_id = loc.inventory_location_id
8608 AND wdtv.ZONE = sub.secondary_inventory_name
8609 AND wdtv.organization_id = sub.organization_id
8610 AND wdtv.move_order_line_id = mol.line_id
8611 UNION ALL
8612 SELECT wdtv.task_id task_id1
8613 , mol.carton_grouping_id
8614 , wdtv.wms_task_type_id
8615 , mol.carton_grouping_id cluster_id
8616 , 'C' cluster_type
8617 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8618 , sub.secondary_inventory_name sub_secondary_inventory_name
8619 , sub.picking_order sub_picking_order
8620 , loc.picking_order loc_picking_order
8621 , (
8622 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8623 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8624 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8625 ) xyz_distance
8626 , loc.concatenated_segments loc_concat_segs
8627 ,1 task_status
8628 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8629 ,v.effective_start_date
8630 ,v.effective_end_date
8631 ,v.role person_resource_id
8632 ,v.equipment machine_resource_id
8633 FROM --wms_dispatchable_tasks_v wdtv,
8634 (SELECT transaction_temp_id task_id
8635 , standard_operation_id user_task_type_id
8636 , wms_task_type wms_task_type_id
8637 , organization_id organization_id
8638 , subinventory_code ZONE
8639 , locator_id locator_id
8640 , task_priority task_priority
8641 , revision revision
8642 , lot_number lot_number
8643 , transaction_uom transaction_uom
8644 , transaction_quantity transaction_quantity
8645 , pick_rule_id pick_rule_id
8646 , pick_slip_number pick_slip_number
8647 , cartonization_id cartonization_id
8648 , inventory_item_id
8649 , move_order_line_id
8650 FROM mtl_material_transactions_temp
8651 WHERE wms_task_type IS NOT NULL
8652 AND transaction_status = 2
8653 AND(
8654 wms_task_status IS NULL
8655 OR wms_task_status = 1
8656 ) --Added for task planning WB. bug#2651318
8657 ) wdtv
8658 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8659 --wms_person_resource_utt_v v,
8660 (SELECT utt_emp.standard_operation_id standard_operation_id
8661 , utt_emp.resource_id ROLE
8662 , utt_eqp.resource_id equipment
8663 , utt_emp.person_id emp_id
8664 , utt_eqp.inventory_item_id eqp_id
8665 , NULL eqp_srl /* removed for bug 2095237 */
8666 , utt_emp.effective_start_date
8667 , utt_emp.effective_end_date
8668 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8669 , x_utt_res1.resource_id resource_id
8670 , x_emp_r.person_id
8671 , x_emp_r.effective_start_date
8672 , x_emp_r.effective_end_date
8673 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8674 WHERE x_utt_res1.resource_id = r1.resource_id
8675 AND r1.resource_type = 2
8676 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8677 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8678 , x_utt_res2.resource_id resource_id
8679 , x_eqp_r.inventory_item_id inventory_item_id
8680 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8681 WHERE x_utt_res2.resource_id = r2.resource_id
8682 AND r2.resource_type = 1
8683 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8684 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8685 , -- inlined wms_person_resource_utt_v, bug 2648133
8686 mtl_item_locations_kfv loc
8687 , --changed to kfv bug#2742611
8688 mtl_secondary_inventories sub
8689 , mtl_txn_request_lines mol
8690 , mtl_txn_request_headers moh
8691 -- mtl_system_items msi -- bug 2648133
8692 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8693 AND wdtv.organization_id = p_sign_on_org_id
8694 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8695 AND mol.header_id = moh.header_id
8696 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8697 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
8698 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8699 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8700 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8701 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8702 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8703 AND wdtv.locator_id = loc.inventory_location_id(+)
8704 AND wdtv.ZONE = sub.secondary_inventory_name
8705 AND wdtv.organization_id = sub.organization_id
8706 AND wdtv.move_order_line_id = mol.line_id
8707 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8708 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8709 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8710 (
8711 SELECT NULL
8712 FROM mtl_material_transactions_temp mmtt
8713 WHERE mmtt.transaction_temp_id = wdtv.task_id
8714 AND mmtt.parent_line_id IS NOT NULL
8715 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8716 AND NOT EXISTS -- exclude tasks already dispatched
8717 (SELECT NULL
8718 FROM wms_dispatched_tasks wdt1
8719 WHERE wdt1.transaction_temp_id = wdtv.task_id
8720 AND wdt1.task_type = wdtv.wms_task_type_id)
8721 --******************
8722 AND wdtv.task_id NOT IN -- excluded skipped tasks
8723 (
8724 SELECT wdtv.task_id
8725 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8726 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8727 AND wste.task_id = wdtv.task_id
8728 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8729 AND wste.organization_id = mp.organization_id)
8730 --*****************
8731 --J Addition
8732 AND wdtv.ZONE not in (
8733 SELECT wd.subinventory_code
8734 FROM wms_devices_b wd
8735 , wms_bus_event_devices wbed
8736 WHERE 1 = 1
8737 and wd.device_id = wbed.device_id
8738 AND wbed.organization_id = wd.organization_id
8739 AND wd.enabled_flag = 'Y'
8740 AND wbed.enabled_flag = 'Y'
8741 AND wbed.business_event_id = 10
8742 AND wd.subinventory_code IS NOT NULL
8743 AND wd.force_sign_on_flag = 'Y'
8744 AND wd.device_id NOT IN (SELECT device_id
8745 FROM wms_device_assignment_temp
8746 WHERE employee_id = p_sign_on_emp_id)
8747 )
8748 ORDER BY wdtv_task_priority DESC
8749 , batch_id
8750 , task_status DESC
8751 , sub_picking_order
8752 , loc_picking_order
8753 , xyz_distance
8754 , task_id1;
8755
8756
8757
8758 ----------------------------------
8759 -- following cursor for SO, IO and WIP and sub entered -----
8760
8761 CURSOR l_cp_ordered_tasks_SIW IS
8762 SELECT DISTINCT
8763 qt.task_id task_id1
8764 , mol.carton_grouping_id
8765 , qt.wms_task_type_id
8766 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8767 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8768 , NVL(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
8769 , sub.secondary_inventory_name sub_secondary_inventory_name
8770 , sub.picking_order sub_picking_order
8771 , loc.picking_order loc_picking_order
8772 , (
8773 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8774 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8775 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8776 ) xyz_distance
8777 , loc.concatenated_segments loc_concat_segs
8778 ,wdt.status task_status --bug 4310093
8779 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8780 , wdt.effective_start_date
8781 , wdt.effective_end_date
8782 , wdt.person_resource_id
8783 , wdt.machine_resource_id
8784 FROM wms_dispatched_tasks wdt,
8785 (SELECT transaction_temp_id task_id
8786 , standard_operation_id user_task_type_id
8787 , wms_task_type wms_task_type_id
8788 , organization_id organization_id
8789 , subinventory_code ZONE
8790 , locator_id locator_id
8791 , task_priority task_priority
8792 , revision revision
8793 , lot_number lot_number
8794 , transaction_uom transaction_uom
8795 , transaction_quantity transaction_quantity
8796 , pick_rule_id pick_rule_id
8797 , pick_slip_number pick_slip_number
8798 , cartonization_id cartonization_id
8799 , inventory_item_id
8800 , move_order_line_id
8801 FROM mtl_material_transactions_temp
8802 WHERE wms_task_type IS NOT NULL
8803 AND transaction_status = 2
8804 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8805 8, l_io_allowed) = 1 -- filter out the request so or io
8806 AND(
8807 wms_task_status IS NULL
8808 OR wms_task_status = 1
8809 ) --Added for task planning WB. bug#2651318
8810 ) qt
8811 , (SELECT
8812 bsor.standard_operation_id,
8813 bre.resource_id,
8814 bre.inventory_item_id equipment_id
8815 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8816 WHERE bsor.resource_id = bre.resource_id
8817 AND br.resource_type = 1
8818 AND bsor.resource_id = br.resource_id) e
8819 , mtl_item_locations_kfv loc
8820 , --changed to kfv bug#2742611
8821 mtl_secondary_inventories sub
8822 , mtl_txn_request_lines mol
8823 , mtl_txn_request_headers moh
8824 , -- mtl_system_items msi -- bug 2648133
8825 wsh_delivery_details_ob_grp_v wdd
8826 , -- added
8827 wsh_delivery_assignments_v wda --added
8828 WHERE wdt.transaction_temp_id = qt.task_id
8829 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8830 AND wdt.person_id = p_sign_on_emp_id
8831 AND wdt.organization_id = p_sign_on_org_id
8832 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
8833 AND mol.header_id = moh.header_id
8834 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8835 AND qt.user_task_type_id =
8836 e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8837 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8838 AND qt.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8839 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
8840 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8841 AND qt.organization_id = loc.organization_id
8842 AND qt.locator_id = loc.inventory_location_id
8843 AND qt.ZONE = sub.secondary_inventory_name
8844 AND qt.organization_id = sub.organization_id
8845 AND qt.move_order_line_id = mol.line_id
8846 -- Join with delivery details
8847 AND(wdd.move_order_line_id = qt.move_order_line_id
8848 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8849 UNION ALL
8850 SELECT DISTINCT wdtv.task_id task_id1
8851 , mol.carton_grouping_id
8852 , wdtv.wms_task_type_id
8853 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8854 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8855 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8856 , sub.secondary_inventory_name sub_secondary_inventory_name
8857 , sub.picking_order sub_picking_order
8858 , loc.picking_order loc_picking_order
8859 , (
8860 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8861 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8862 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8863 ) xyz_distance
8864 , loc.concatenated_segments loc_concat_segs
8865 ,1 task_status
8866 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8867 ,v.effective_start_date
8868 ,v.effective_end_date
8869 ,v.role person_resource_id
8870 ,v.equipment machine_resource_id
8871 FROM --wms_dispatchable_tasks_v wdtv,
8872 (SELECT transaction_temp_id task_id
8873 , standard_operation_id user_task_type_id
8874 , wms_task_type wms_task_type_id
8875 , organization_id organization_id
8876 , subinventory_code ZONE
8877 , locator_id locator_id
8878 , task_priority task_priority
8879 , revision revision
8880 , lot_number lot_number
8881 , transaction_uom transaction_uom
8882 , transaction_quantity transaction_quantity
8883 , pick_rule_id pick_rule_id
8884 , pick_slip_number pick_slip_number
8885 , cartonization_id cartonization_id
8886 , inventory_item_id
8887 , move_order_line_id
8888 FROM mtl_material_transactions_temp
8889 WHERE wms_task_type IS NOT NULL
8890 AND transaction_status = 2
8891 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8892 8, l_io_allowed) = 1 -- filter out the request so or io
8893 AND(
8894 wms_task_status IS NULL
8895 OR wms_task_status = 1
8896 ) --Added for task planning WB. bug#2651318
8897 ) wdtv
8898 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8899 --wms_person_resource_utt_v v,
8900 (SELECT utt_emp.standard_operation_id standard_operation_id
8901 , utt_emp.resource_id ROLE
8902 , utt_eqp.resource_id equipment
8903 , utt_emp.person_id emp_id
8904 , utt_eqp.inventory_item_id eqp_id
8905 , NULL eqp_srl /* removed for bug 2095237 */
8906 , utt_emp.effective_start_date
8907 , utt_emp.effective_end_date
8908 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8909 , x_utt_res1.resource_id resource_id
8910 , x_emp_r.person_id
8911 , x_emp_r.effective_start_date
8912 , x_emp_r.effective_end_date
8913 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8914 WHERE x_utt_res1.resource_id = r1.resource_id
8915 AND r1.resource_type = 2
8916 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8917 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8918 , x_utt_res2.resource_id resource_id
8919 , x_eqp_r.inventory_item_id inventory_item_id
8920 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8921 WHERE x_utt_res2.resource_id = r2.resource_id
8922 AND r2.resource_type = 1
8923 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8924 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8925 , -- inlined wms_person_resource_utt_v, bug 2648133
8926 mtl_item_locations_kfv loc
8927 , --changed to kfv bug#2742611
8928 mtl_secondary_inventories sub
8929 , mtl_txn_request_lines mol
8930 , mtl_txn_request_headers moh
8931 , -- mtl_system_items msi -- bug 2648133
8932 wsh_delivery_details_ob_grp_v wdd
8933 , -- added
8934 wsh_delivery_assignments_v wda --added
8935 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8936 AND wdtv.organization_id = p_sign_on_org_id
8937 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8938 AND mol.header_id = moh.header_id
8939 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8940 AND wdtv.user_task_type_id =
8941 v.standard_operation_id -- join task to resource view, check if user defined task type match
8942 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8943 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8944 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8945 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8946 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8947 AND wdtv.locator_id = loc.inventory_location_id(+)
8948 AND wdtv.ZONE = sub.secondary_inventory_name
8949 AND wdtv.organization_id = sub.organization_id
8950 AND wdtv.move_order_line_id = mol.line_id
8951 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8952 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8953 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8954 (
8955 SELECT NULL
8956 FROM mtl_material_transactions_temp mmtt
8957 WHERE mmtt.transaction_temp_id = wdtv.task_id
8958 AND mmtt.parent_line_id IS NOT NULL
8959 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8960 AND NOT EXISTS -- exclude tasks already dispatched
8961 (SELECT NULL
8962 FROM wms_dispatched_tasks wdt1
8963 WHERE wdt1.transaction_temp_id = wdtv.task_id
8964 AND wdt1.task_type = wdtv.wms_task_type_id)
8965 -- Join with delivery details
8966 AND(wdd.move_order_line_id = wdtv.move_order_line_id
8967 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8968 --******************
8969 AND wdtv.task_id NOT IN -- excluded skipped tasks
8970 (
8971 SELECT wdtv.task_id
8972 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8973 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8974 AND wste.task_id = wdtv.task_id
8975 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8976 AND wste.organization_id = mp.organization_id)
8977 --*****************
8978 --J Addition
8979 AND wdtv.ZONE not in (
8980 SELECT wd.subinventory_code
8981 FROM wms_devices_b wd
8982 , wms_bus_event_devices wbed
8983 WHERE 1 = 1
8984 and wd.device_id = wbed.device_id
8985 AND wbed.organization_id = wd.organization_id
8986 AND wd.enabled_flag = 'Y'
8987 AND wbed.enabled_flag = 'Y'
8988 AND wbed.business_event_id = 10
8989 AND wd.subinventory_code IS NOT NULL
8990 AND wd.force_sign_on_flag = 'Y'
8991 AND wd.device_id NOT IN (SELECT device_id
8992 FROM wms_device_assignment_temp
8993 WHERE employee_id = p_sign_on_emp_id)
8994 )
8995 UNION ALL
8996 SELECT DISTINCT
8997 wdtv.task_id task_id1
8998 , mol.carton_grouping_id
8999 , wdtv.wms_task_type_id
9000 , mol.carton_grouping_id cluster_id
9001 , 'C' cluster_type
9002 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9003 , sub.secondary_inventory_name sub_secondary_inventory_name
9004 , sub.picking_order sub_picking_order
9005 , loc.picking_order loc_picking_order
9006 , (
9007 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9008 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9009 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9010 ) xyz_distance
9011 , loc.concatenated_segments loc_concat_segs
9012 ,1 task_status
9013 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9014 , wdt.effective_start_date
9015 , wdt.effective_end_date
9016 , wdt.person_resource_id
9017 , wdt.machine_resource_id
9018 FROM wms_dispatched_tasks wdt,
9019 (SELECT transaction_temp_id task_id
9020 , standard_operation_id user_task_type_id
9021 , wms_task_type wms_task_type_id
9022 , organization_id organization_id
9023 , subinventory_code ZONE
9024 , locator_id locator_id
9025 , task_priority task_priority
9026 , revision revision
9027 , lot_number lot_number
9028 , transaction_uom transaction_uom
9029 , transaction_quantity transaction_quantity
9030 , pick_rule_id pick_rule_id
9031 , pick_slip_number pick_slip_number
9032 , cartonization_id cartonization_id
9033 , inventory_item_id
9034 , move_order_line_id
9035 FROM mtl_material_transactions_temp
9036 WHERE wms_task_type IS NOT NULL
9037 AND transaction_status = 2
9038 AND(
9039 wms_task_status IS NULL
9040 OR wms_task_status = 1
9041 ) --Added for task planning WB. bug#2651318
9042 ) wdtv
9043 , (SELECT
9044 bsor.standard_operation_id,
9045 bre.resource_id,
9046 bre.inventory_item_id equipment_id
9047 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9048 WHERE bsor.resource_id = bre.resource_id
9049 AND br.resource_type = 1
9050 AND bsor.resource_id = br.resource_id) e
9051 , mtl_item_locations_kfv loc
9052 , --changed to kfv bug#2742611
9053 mtl_secondary_inventories sub
9054 , mtl_txn_request_lines mol
9055 , mtl_txn_request_headers moh
9056 -- mtl_system_items msi -- bug 2648133
9057 WHERE wdt.transaction_temp_id = wdtv.task_id
9058 AND wdt.status = 2 -- Queued tasks only
9059 AND wdt.person_id = p_sign_on_emp_id
9060 AND wdt.organization_id = p_sign_on_org_id
9061 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9062 AND mol.header_id = moh.header_id
9063 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9064 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
9065 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
9066 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9067 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9068 AND wdtv.organization_id = loc.organization_id
9069 AND wdtv.locator_id = loc.inventory_location_id
9070 AND wdtv.ZONE = sub.secondary_inventory_name
9071 AND wdtv.organization_id = sub.organization_id
9072 AND wdtv.move_order_line_id = mol.line_id
9073 UNION ALL
9074 -- This will select the WIP Jobs alone
9075 SELECT DISTINCT
9076 wdtv.task_id task_id1
9077 , mol.carton_grouping_id
9078 , wdtv.wms_task_type_id
9079 , mol.carton_grouping_id cluster_id
9080 , 'C' cluster_type
9081 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9082 , sub.secondary_inventory_name sub_secondary_inventory_name
9083 , sub.picking_order sub_picking_order
9084 , loc.picking_order loc_picking_order
9085 , (
9086 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9087 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9088 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9089 ) xyz_distance
9090 , loc.concatenated_segments loc_concat_segs
9091 ,1 task_status
9092 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9093 ,v.effective_start_date
9094 ,v.effective_end_date
9095 ,v.role person_resource_id
9096 ,v.equipment machine_resource_id
9097 FROM --wms_dispatchable_tasks_v wdtv,
9098 (SELECT transaction_temp_id task_id
9099 , standard_operation_id user_task_type_id
9100 , wms_task_type wms_task_type_id
9101 , organization_id organization_id
9102 , subinventory_code ZONE
9103 , locator_id locator_id
9104 , task_priority task_priority
9105 , revision revision
9106 , lot_number lot_number
9107 , transaction_uom transaction_uom
9108 , transaction_quantity transaction_quantity
9109 , pick_rule_id pick_rule_id
9110 , pick_slip_number pick_slip_number
9111 , cartonization_id cartonization_id
9112 , inventory_item_id
9113 , move_order_line_id
9114 FROM mtl_material_transactions_temp
9115 WHERE wms_task_type IS NOT NULL
9116 AND transaction_status = 2
9117 AND(
9118 wms_task_status IS NULL
9119 OR wms_task_status = 1
9120 ) --Added for task planning WB. bug#2651318
9121 ) wdtv
9122 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9123 --wms_person_resource_utt_v v,
9124 (SELECT utt_emp.standard_operation_id standard_operation_id
9125 , utt_emp.resource_id ROLE
9126 , utt_eqp.resource_id equipment
9127 , utt_emp.person_id emp_id
9128 , utt_eqp.inventory_item_id eqp_id
9129 , NULL eqp_srl /* removed for bug 2095237 */
9130 , utt_emp.effective_start_date
9131 , utt_emp.effective_end_date
9132 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9133 , x_utt_res1.resource_id resource_id
9134 , x_emp_r.person_id
9135 , x_emp_r.effective_start_date
9136 , x_emp_r.effective_end_date
9137 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9138 WHERE x_utt_res1.resource_id = r1.resource_id
9139 AND r1.resource_type = 2
9140 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9141 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9142 , x_utt_res2.resource_id resource_id
9143 , x_eqp_r.inventory_item_id inventory_item_id
9144 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9145 WHERE x_utt_res2.resource_id = r2.resource_id
9146 AND r2.resource_type = 1
9147 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9148 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9149 , -- inlined wms_person_resource_utt_v, bug 2648133
9150 mtl_item_locations_kfv loc
9151 , --changed to kfv bug#2742611
9152 mtl_secondary_inventories sub
9153 , mtl_txn_request_lines mol
9154 , mtl_txn_request_headers moh
9155 -- mtl_system_items msi -- bug 2648133
9156 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9157 AND wdtv.organization_id = p_sign_on_org_id
9158 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9159 AND mol.header_id = moh.header_id
9160 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9161 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
9162 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9163 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
9164 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9165 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9166 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9167 AND wdtv.locator_id = loc.inventory_location_id(+)
9168 AND wdtv.ZONE = sub.secondary_inventory_name
9169 AND wdtv.organization_id = sub.organization_id
9170 AND wdtv.move_order_line_id = mol.line_id
9171 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9172 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9173 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9174 (
9175 SELECT NULL
9176 FROM mtl_material_transactions_temp mmtt
9177 WHERE mmtt.transaction_temp_id = wdtv.task_id
9178 AND mmtt.parent_line_id IS NOT NULL
9179 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9180 AND NOT EXISTS -- exclude tasks already dispatched
9181 (SELECT NULL
9182 FROM wms_dispatched_tasks wdt1
9183 WHERE wdt1.transaction_temp_id = wdtv.task_id
9184 AND wdt1.task_type = wdtv.wms_task_type_id)
9185 --******************
9186 AND wdtv.task_id NOT IN -- excluded skipped tasks
9187 (
9188 SELECT wdtv.task_id
9189 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9190 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9191 AND wste.task_id = wdtv.task_id
9192 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9193 AND wste.organization_id = mp.organization_id)
9194 --*****************
9195 --J Addition
9196 AND wdtv.ZONE not in (
9197 SELECT wd.subinventory_code
9198 FROM wms_devices_b wd
9199 , wms_bus_event_devices wbed
9200 WHERE 1 = 1
9201 and wd.device_id = wbed.device_id
9202 AND wbed.organization_id = wd.organization_id
9203 AND wd.enabled_flag = 'Y'
9204 AND wbed.enabled_flag = 'Y'
9205 AND wbed.business_event_id = 10
9206 AND wd.subinventory_code IS NOT NULL
9207 AND wd.force_sign_on_flag = 'Y'
9208 AND wd.device_id NOT IN (SELECT device_id
9209 FROM wms_device_assignment_temp
9210 WHERE employee_id = p_sign_on_emp_id)
9211 )
9212 ORDER BY wdtv_task_priority DESC
9213 , batch_id
9214 , task_status DESC
9215 , sub_picking_order
9216 , loc_picking_order
9217 , xyz_distance
9218 , task_id1;
9219
9220
9221 --- ***************************************
9222 -- THE FOLLOWING 3 cursors are for no sub ----------------
9223 ---------------------------------------------------------
9224 -- following cursor for SO, IO and sub NOT entered -----
9225 CURSOR l_cp_ordered_tasks_no_sub_SI IS -- bug 2648133
9226 SELECT DISTINCT
9227 qt.task_id task_id1
9228 , mol.carton_grouping_id
9229 , qt.wms_task_type_id
9230 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9231 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9232 , NVL(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
9233 , sub.secondary_inventory_name sub_secondary_inventory_name
9234 , sub.picking_order sub_picking_order
9235 , loc.picking_order loc_picking_order
9236 , (
9237 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9238 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9239 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9240 ) xyz_distance
9241 , loc.concatenated_segments loc_concat_segs
9242 ,wdt.status task_status --bug 4310093
9243 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9244 , wdt.effective_start_date
9245 , wdt.effective_end_date
9246 , wdt.person_resource_id
9247 , wdt.machine_resource_id
9248 FROM wms_dispatched_tasks wdt,
9249 (SELECT transaction_temp_id task_id
9250 , standard_operation_id user_task_type_id
9251 , wms_task_type wms_task_type_id
9252 , organization_id organization_id
9253 , subinventory_code ZONE
9254 , locator_id locator_id
9255 , task_priority task_priority
9256 , revision revision
9257 , lot_number lot_number
9258 , transaction_uom transaction_uom
9259 , transaction_quantity transaction_quantity
9260 , pick_rule_id pick_rule_id
9261 , pick_slip_number pick_slip_number
9262 , cartonization_id cartonization_id
9263 , inventory_item_id
9264 , move_order_line_id
9265 FROM mtl_material_transactions_temp
9266 WHERE wms_task_type IS NOT NULL
9267 AND transaction_status = 2
9268 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9269 8, l_io_allowed) = 1 -- filter out the request so or io
9270 AND(
9271 wms_task_status IS NULL
9272 OR wms_task_status = 1
9273 ) --Added for task planning WB. bug#2651318
9274 ) qt
9275 , (SELECT
9276 bsor.standard_operation_id,
9277 bre.resource_id,
9278 bre.inventory_item_id equipment_id
9279 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9280 WHERE bsor.resource_id = bre.resource_id
9281 AND br.resource_type = 1
9282 AND bsor.resource_id = br.resource_id) e
9283 , mtl_item_locations_kfv loc
9284 , --changed to kfv bug#2742611
9285 mtl_secondary_inventories sub
9286 , mtl_txn_request_lines mol
9287 , mtl_txn_request_headers moh
9288 , -- mtl_system_items msi -- bug 2648133
9289 wsh_delivery_details_ob_grp_v wdd
9290 , -- added
9291 wsh_delivery_assignments_v wda --added
9292 WHERE wdt.transaction_temp_id = qt.task_id
9293 AND wdt.status in( 2,3) -- Queued and dispatched tasks only bug 4310093
9294 AND wdt.person_id = p_sign_on_emp_id
9295 AND wdt.organization_id = p_sign_on_org_id
9296 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
9297 AND mol.header_id = moh.header_id
9298 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9299 AND qt.user_task_type_id =
9300 e.standard_operation_id(+)
9301 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
9302 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9303 AND qt.organization_id = loc.organization_id
9304 AND qt.locator_id = loc.inventory_location_id
9305 AND qt.ZONE = sub.secondary_inventory_name
9306 AND qt.organization_id = sub.organization_id
9307 AND qt.move_order_line_id = mol.line_id
9308 -- Join with delivery details
9309 AND(wdd.move_order_line_id = qt.move_order_line_id
9310 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9311 UNION ALL
9312 SELECT DISTINCT wdtv.task_id task_id1
9313 , mol.carton_grouping_id
9314 , wdtv.wms_task_type_id
9315 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9316 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9317 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9318 , sub.secondary_inventory_name sub_secondary_inventory_name
9319 , sub.picking_order sub_picking_order
9320 , loc.picking_order loc_picking_order
9321 , (
9322 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9323 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9324 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9325 ) xyz_distance
9326 , loc.concatenated_segments loc_concat_segs
9327 ,1 task_status
9328 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9329 ,v.effective_start_date
9330 ,v.effective_end_date
9331 ,v.role person_resource_id
9332 ,v.equipment machine_resource_id
9333 FROM --wms_dispatchable_tasks_v wdtv,
9334 (SELECT transaction_temp_id task_id
9335 , standard_operation_id user_task_type_id
9336 , wms_task_type wms_task_type_id
9337 , organization_id organization_id
9338 , subinventory_code ZONE
9339 , locator_id locator_id
9340 , task_priority task_priority
9341 , revision revision
9342 , lot_number lot_number
9343 , transaction_uom transaction_uom
9344 , transaction_quantity transaction_quantity
9345 , pick_rule_id pick_rule_id
9346 , pick_slip_number pick_slip_number
9347 , cartonization_id cartonization_id
9348 , inventory_item_id
9349 , move_order_line_id
9350 FROM mtl_material_transactions_temp
9351 WHERE wms_task_type IS NOT NULL
9352 AND transaction_status = 2
9353 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9354 8, l_io_allowed) = 1 -- filter out the request so or io
9355 AND(
9356 wms_task_status IS NULL
9357 OR wms_task_status = 1
9358 ) --Added for task planning WB. bug#2651318
9359 ) wdtv
9360 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9361 --wms_person_resource_utt_v v,
9362 (SELECT utt_emp.standard_operation_id standard_operation_id
9363 , utt_emp.resource_id ROLE
9364 , utt_eqp.resource_id equipment
9365 , utt_emp.person_id emp_id
9366 , utt_eqp.inventory_item_id eqp_id
9367 , NULL eqp_srl /* removed for bug 2095237 */
9368 , utt_emp.effective_start_date
9369 , utt_emp.effective_end_date
9370 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9371 , x_utt_res1.resource_id resource_id
9372 , x_emp_r.person_id
9373 , x_emp_r.effective_start_date
9374 , x_emp_r.effective_end_date
9375 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9376 WHERE x_utt_res1.resource_id = r1.resource_id
9377 AND r1.resource_type = 2
9378 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9379 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9380 , x_utt_res2.resource_id resource_id
9381 , x_eqp_r.inventory_item_id inventory_item_id
9382 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9383 WHERE x_utt_res2.resource_id = r2.resource_id
9384 AND r2.resource_type = 1
9385 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9386 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9387 , -- inlined wms_person_resource_utt_v, bug 2648133
9388 mtl_item_locations_kfv loc
9389 , --changed to kfv bug#2742611
9390 mtl_secondary_inventories sub
9391 , mtl_txn_request_lines mol
9392 , mtl_txn_request_headers moh
9393 , -- mtl_system_items msi -- bug 2648133
9394 wsh_delivery_details_ob_grp_v wdd
9395 , -- added
9396 wsh_delivery_assignments_v wda --added
9397 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9398 AND wdtv.organization_id = p_sign_on_org_id
9399 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9400 AND mol.header_id = moh.header_id
9401 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9402 AND wdtv.user_task_type_id =
9403 v.standard_operation_id -- join task to resource view, check if user defined task type match
9404 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9405 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9406 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9407 AND wdtv.locator_id = loc.inventory_location_id(+)
9408 AND wdtv.ZONE = sub.secondary_inventory_name
9409 AND wdtv.organization_id = sub.organization_id
9410 AND wdtv.move_order_line_id = mol.line_id
9411 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9412 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9413 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9414 (
9415 SELECT NULL
9416 FROM mtl_material_transactions_temp mmtt
9417 WHERE mmtt.transaction_temp_id = wdtv.task_id
9418 AND mmtt.parent_line_id IS NOT NULL
9419 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9420 AND NOT EXISTS -- exclude tasks already dispatched
9421 (SELECT NULL
9422 FROM wms_dispatched_tasks wdt1
9423 WHERE wdt1.transaction_temp_id = wdtv.task_id
9424 AND wdt1.task_type = wdtv.wms_task_type_id)
9425 -- Join with delivery details
9426 AND(wdd.move_order_line_id = wdtv.move_order_line_id
9427 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9428 --******************
9429 AND wdtv.task_id NOT IN -- excluded skipped tasks
9430 (
9431 SELECT wdtv.task_id
9432 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9433 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9434 AND wste.task_id = wdtv.task_id
9435 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9436 AND wste.organization_id = mp.organization_id)
9437
9438 --J Addition
9439 AND wdtv.ZONE not in (
9440 SELECT wd.subinventory_code
9441 FROM wms_devices_b wd
9442 , wms_bus_event_devices wbed
9443 WHERE 1 = 1
9444 and wd.device_id = wbed.device_id
9445 AND wbed.organization_id = wd.organization_id
9446 AND wd.enabled_flag = 'Y'
9447 AND wbed.enabled_flag = 'Y'
9448 AND wbed.business_event_id = 10
9449 AND wd.subinventory_code IS NOT NULL
9450 AND wd.force_sign_on_flag = 'Y'
9451 AND wd.device_id NOT IN (SELECT device_id
9452 FROM wms_device_assignment_temp
9453 WHERE employee_id = p_sign_on_emp_id)
9454 )
9455 ORDER BY wdtv_task_priority DESC
9456 , batch_id
9457 , task_status DESC
9458 , sub_picking_order
9459 , loc_picking_order
9460 , xyz_distance
9461 , task_id1;
9462
9463
9464 -- following cursor for WIP and sub NOT entered -----
9465 CURSOR l_cp_ordered_tasks_no_sub_W IS
9466 SELECT DISTINCT wdtv.task_id task_id1
9467 , mol.carton_grouping_id
9468 , wdtv.wms_task_type_id
9469 , mol.carton_grouping_id cluster_id
9470 , 'C' cluster_type
9471 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9472 , sub.secondary_inventory_name sub_secondary_inventory_name
9473 , sub.picking_order sub_picking_order
9474 , loc.picking_order loc_picking_order
9475 , (
9476 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9477 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9478 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9479 ) xyz_distance
9480 , loc.concatenated_segments loc_concat_segs
9481 ,wdt.status task_status --bug 4310093
9482 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9483 , wdt.effective_start_date
9484 , wdt.effective_end_date
9485 , wdt.person_resource_id
9486 , wdt.machine_resource_id
9487 FROM wms_dispatched_tasks wdt,
9488 (SELECT transaction_temp_id task_id
9489 , standard_operation_id user_task_type_id
9490 , wms_task_type wms_task_type_id
9491 , organization_id organization_id
9492 , subinventory_code ZONE
9493 , locator_id locator_id
9494 , task_priority task_priority
9495 , revision revision
9496 , lot_number lot_number
9497 , transaction_uom transaction_uom
9498 , transaction_quantity transaction_quantity
9499 , pick_rule_id pick_rule_id
9500 , pick_slip_number pick_slip_number
9501 , cartonization_id cartonization_id
9502 , inventory_item_id
9503 , move_order_line_id
9504 FROM mtl_material_transactions_temp
9505 WHERE wms_task_type IS NOT NULL
9506 AND transaction_status = 2
9507 AND(
9508 wms_task_status IS NULL
9509 OR wms_task_status = 1
9510 ) --Added for task planning WB. bug#2651318
9511 ) wdtv
9512 , (SELECT
9513 bsor.standard_operation_id,
9514 bre.resource_id,
9515 bre.inventory_item_id equipment_id
9516 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9517 WHERE bsor.resource_id = bre.resource_id
9518 AND br.resource_type = 1
9519 AND bsor.resource_id = br.resource_id) e
9520 , mtl_item_locations_kfv loc
9521 , --changed to kfv bug#2742611
9522 mtl_secondary_inventories sub
9523 , mtl_txn_request_lines mol
9524 , mtl_txn_request_headers moh
9525 -- mtl_system_items msi -- bug 2648133
9526 WHERE wdt.transaction_temp_id = wdtv.task_id
9527 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
9528 AND wdt.person_id = p_sign_on_emp_id
9529 AND wdt.organization_id = p_sign_on_org_id
9530 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9531 AND mol.header_id = moh.header_id
9532 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9533 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
9534 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9535 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9536 AND wdtv.organization_id = loc.organization_id
9537 AND wdtv.locator_id = loc.inventory_location_id
9538 AND wdtv.ZONE = sub.secondary_inventory_name
9539 AND wdtv.organization_id = sub.organization_id
9540 AND wdtv.move_order_line_id = mol.line_id
9541 UNION ALL
9542 -- This will select the WIP Jobs alone
9543 SELECT DISTINCT
9544 wdtv.task_id task_id1
9545 , mol.carton_grouping_id
9546 , wdtv.wms_task_type_id
9547 , mol.carton_grouping_id cluster_id
9548 , 'C' cluster_type
9549 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9550 , sub.secondary_inventory_name sub_secondary_inventory_name
9551 , sub.picking_order sub_picking_order
9552 , loc.picking_order loc_picking_order
9553 , (
9554 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9555 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9556 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9557 ) xyz_distance
9558 , loc.concatenated_segments loc_concat_segs
9559 ,1 task_status
9560 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9561 ,v.effective_start_date
9562 ,v.effective_end_date
9563 ,v.role person_resource_id
9564 ,v.equipment machine_resource_id
9565 FROM --wms_dispatchable_tasks_v wdtv,
9566 (SELECT transaction_temp_id task_id
9567 , standard_operation_id user_task_type_id
9568 , wms_task_type wms_task_type_id
9569 , organization_id organization_id
9570 , subinventory_code ZONE
9571 , locator_id locator_id
9572 , task_priority task_priority
9573 , revision revision
9574 , lot_number lot_number
9575 , transaction_uom transaction_uom
9576 , transaction_quantity transaction_quantity
9577 , pick_rule_id pick_rule_id
9578 , pick_slip_number pick_slip_number
9579 , cartonization_id cartonization_id
9580 , inventory_item_id
9581 , move_order_line_id
9582 FROM mtl_material_transactions_temp
9583 WHERE wms_task_type IS NOT NULL
9584 AND transaction_status = 2
9585 AND(
9586 wms_task_status IS NULL
9587 OR wms_task_status = 1
9588 ) --Added for task planning WB. bug#2651318
9589 ) wdtv
9590 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9591 --wms_person_resource_utt_v v,
9592 (SELECT utt_emp.standard_operation_id standard_operation_id
9593 , utt_emp.resource_id ROLE
9594 , utt_eqp.resource_id equipment
9595 , utt_emp.person_id emp_id
9596 , utt_eqp.inventory_item_id eqp_id
9597 , NULL eqp_srl /* removed for bug 2095237 */
9598 , utt_emp.effective_start_date
9599 , utt_emp.effective_end_date
9600 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9601 , x_utt_res1.resource_id resource_id
9602 , x_emp_r.person_id
9603 , x_emp_r.effective_start_date
9604 , x_emp_r.effective_end_date
9605 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9606 WHERE x_utt_res1.resource_id = r1.resource_id
9607 AND r1.resource_type = 2
9608 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9609 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9610 , x_utt_res2.resource_id resource_id
9611 , x_eqp_r.inventory_item_id inventory_item_id
9612 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9613 WHERE x_utt_res2.resource_id = r2.resource_id
9614 AND r2.resource_type = 1
9615 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9616 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9617 , -- inlined wms_person_resource_utt_v, bug 2648133
9618 mtl_item_locations_kfv loc
9619 , --changed to kfv bug#2742611
9620 mtl_secondary_inventories sub
9621 , mtl_txn_request_lines mol
9622 , mtl_txn_request_headers moh
9623 -- mtl_system_items msi -- bug 2648133
9624 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9625 AND wdtv.organization_id = p_sign_on_org_id
9626 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9627 AND mol.header_id = moh.header_id
9628 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9629 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
9630 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9631 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9632 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9633 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9634 AND wdtv.locator_id = loc.inventory_location_id(+)
9635 AND wdtv.ZONE = sub.secondary_inventory_name
9636 AND wdtv.organization_id = sub.organization_id
9637 AND wdtv.move_order_line_id = mol.line_id
9638 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9639 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9640 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9641 (
9642 SELECT NULL
9643 FROM mtl_material_transactions_temp mmtt
9644 WHERE mmtt.transaction_temp_id = wdtv.task_id
9645 AND mmtt.parent_line_id IS NOT NULL
9646 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9647 AND NOT EXISTS -- exclude tasks already dispatched
9648 (SELECT NULL
9649 FROM wms_dispatched_tasks wdt1
9650 WHERE wdt1.transaction_temp_id = wdtv.task_id
9651 AND wdt1.task_type = wdtv.wms_task_type_id)
9652 --******************
9653 AND wdtv.task_id NOT IN -- excluded skipped tasks
9654 (
9655 SELECT wdtv.task_id
9656 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9657 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9658 AND wste.task_id = wdtv.task_id
9659 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9660 AND wste.organization_id = mp.organization_id)
9661 --*****************
9662 --J Addition
9663 AND wdtv.ZONE not in (
9664 SELECT wd.subinventory_code
9665 FROM wms_devices_b wd
9666 , wms_bus_event_devices wbed
9667 WHERE 1 = 1
9668 and wd.device_id = wbed.device_id
9669 AND wbed.organization_id = wd.organization_id
9670 AND wd.enabled_flag = 'Y'
9671 AND wbed.enabled_flag = 'Y'
9672 AND wbed.business_event_id = 10
9673 AND wd.subinventory_code IS NOT NULL
9674 AND wd.force_sign_on_flag = 'Y'
9675 AND wd.device_id NOT IN (SELECT device_id
9676 FROM wms_device_assignment_temp
9677 WHERE employee_id = p_sign_on_emp_id)
9678 )
9679 ORDER BY wdtv_task_priority DESC
9680 , batch_id
9681 , task_status DESC
9682 , sub_picking_order
9683 , loc_picking_order
9684 , xyz_distance
9685 , task_id1;
9686
9687
9688 -- following cursor for SO, IO, WIP and sub NOT entered -----
9689 CURSOR l_cp_ordered_tasks_no_sub_SIW IS -- bug 2648133
9690 SELECT DISTINCT
9691 qt.task_id task_id1
9692 , mol.carton_grouping_id
9693 , qt.wms_task_type_id
9694 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9695 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9696 , NVL(qt.task_priority, 0) wdtv_task_priority -- Bug 4599496
9697 , sub.secondary_inventory_name sub_secondary_inventory_name
9698 , sub.picking_order sub_picking_order
9699 , loc.picking_order loc_picking_order
9700 , (
9701 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9702 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9703 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9704 ) xyz_distance
9705 , loc.concatenated_segments loc_concat_segs
9706 ,wdt.status task_status --bug 4310093
9707 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9708 , wdt.effective_start_date
9709 , wdt.effective_end_date
9710 , wdt.person_resource_id
9711 , wdt.machine_resource_id
9712 FROM wms_dispatched_tasks wdt,
9713 (SELECT transaction_temp_id task_id
9714 , standard_operation_id user_task_type_id
9715 , wms_task_type wms_task_type_id
9716 , organization_id organization_id
9717 , subinventory_code ZONE
9718 , locator_id locator_id
9719 , task_priority task_priority
9720 , revision revision
9721 , lot_number lot_number
9722 , transaction_uom transaction_uom
9723 , transaction_quantity transaction_quantity
9724 , pick_rule_id pick_rule_id
9725 , pick_slip_number pick_slip_number
9726 , cartonization_id cartonization_id
9727 , inventory_item_id
9728 , move_order_line_id
9729 FROM mtl_material_transactions_temp
9730 WHERE wms_task_type IS NOT NULL
9731 AND transaction_status = 2
9732 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9733 8, l_io_allowed) = 1 -- filter out the request so or io
9734 AND(
9735 wms_task_status IS NULL
9736 OR wms_task_status = 1
9737 ) --Added for task planning WB. bug#2651318
9738 ) qt
9739 , (SELECT
9740 bsor.standard_operation_id,
9741 bre.resource_id,
9742 bre.inventory_item_id equipment_id
9743 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9744 WHERE bsor.resource_id = bre.resource_id
9745 AND br.resource_type = 1
9746 AND bsor.resource_id = br.resource_id) e
9747 , mtl_item_locations_kfv loc
9748 , --changed to kfv bug#2742611
9749 mtl_secondary_inventories sub
9750 , mtl_txn_request_lines mol
9751 , mtl_txn_request_headers moh
9752 , -- mtl_system_items msi -- bug 2648133
9753 wsh_delivery_details_ob_grp_v wdd
9754 , -- added
9755 wsh_delivery_assignments_v wda --added
9756 WHERE wdt.transaction_temp_id = qt.task_id
9757 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
9758 AND wdt.person_id = p_sign_on_emp_id
9759 AND wdt.organization_id = p_sign_on_org_id
9760 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
9761 AND mol.header_id = moh.header_id
9762 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9763 AND qt.user_task_type_id =
9764 e.standard_operation_id(+)
9765 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
9766 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9767 AND qt.organization_id = loc.organization_id
9768 AND qt.locator_id = loc.inventory_location_id
9769 AND qt.ZONE = sub.secondary_inventory_name
9770 AND qt.organization_id = sub.organization_id
9771 AND qt.move_order_line_id = mol.line_id
9772 -- Join with delivery details
9773 AND(wdd.move_order_line_id = qt.move_order_line_id
9774 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9775 UNION ALL
9776 SELECT DISTINCT wdtv.task_id task_id1
9777 , mol.carton_grouping_id
9778 , wdtv.wms_task_type_id
9779 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9780 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9781 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9782 , sub.secondary_inventory_name sub_secondary_inventory_name
9783 , sub.picking_order sub_picking_order
9784 , loc.picking_order loc_picking_order
9785 , (
9786 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9787 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9788 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9789 ) xyz_distance
9790 , loc.concatenated_segments loc_concat_segs
9791 ,1 task_status
9792 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9793 ,v.effective_start_date
9794 ,v.effective_end_date
9795 ,v.role person_resource_id
9796 ,v.equipment machine_resource_id
9797 FROM --wms_dispatchable_tasks_v wdtv,
9798 (SELECT transaction_temp_id task_id
9799 , standard_operation_id user_task_type_id
9800 , wms_task_type wms_task_type_id
9801 , organization_id organization_id
9802 , subinventory_code ZONE
9803 , locator_id locator_id
9804 , task_priority task_priority
9805 , revision revision
9806 , lot_number lot_number
9807 , transaction_uom transaction_uom
9808 , transaction_quantity transaction_quantity
9809 , pick_rule_id pick_rule_id
9810 , pick_slip_number pick_slip_number
9811 , cartonization_id cartonization_id
9812 , inventory_item_id
9813 , move_order_line_id
9814 FROM mtl_material_transactions_temp
9815 WHERE wms_task_type IS NOT NULL
9816 AND transaction_status = 2
9817 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9818 8, l_io_allowed) = 1 -- filter out the request so or io
9819 AND(
9820 wms_task_status IS NULL
9821 OR wms_task_status = 1
9822 ) --Added for task planning WB. bug#2651318
9823 ) wdtv
9824 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9825 --wms_person_resource_utt_v v,
9826 (SELECT utt_emp.standard_operation_id standard_operation_id
9827 , utt_emp.resource_id ROLE
9828 , utt_eqp.resource_id equipment
9829 , utt_emp.person_id emp_id
9830 , utt_eqp.inventory_item_id eqp_id
9831 , NULL eqp_srl /* removed for bug 2095237 */
9832 , utt_emp.effective_start_date
9833 , utt_emp.effective_end_date
9834 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9835 , x_utt_res1.resource_id resource_id
9836 , x_emp_r.person_id
9837 , x_emp_r.effective_start_date
9838 , x_emp_r.effective_end_date
9839 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9840 WHERE x_utt_res1.resource_id = r1.resource_id
9841 AND r1.resource_type = 2
9842 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9843 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9844 , x_utt_res2.resource_id resource_id
9845 , x_eqp_r.inventory_item_id inventory_item_id
9846 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9847 WHERE x_utt_res2.resource_id = r2.resource_id
9848 AND r2.resource_type = 1
9849 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9850 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9851 , -- inlined wms_person_resource_utt_v, bug 2648133
9852 mtl_item_locations_kfv loc
9853 , --changed to kfv bug#2742611
9854 mtl_secondary_inventories sub
9855 , mtl_txn_request_lines mol
9856 , mtl_txn_request_headers moh
9857 , -- mtl_system_items msi -- bug 2648133
9858 wsh_delivery_details_ob_grp_v wdd
9859 , -- added
9860 wsh_delivery_assignments_v wda --added
9861 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9862 AND wdtv.organization_id = p_sign_on_org_id
9863 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9864 AND mol.header_id = moh.header_id
9865 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9866 AND wdtv.user_task_type_id =
9867 v.standard_operation_id -- join task to resource view, check if user defined task type match
9868 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9869 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9870 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9871 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9872 AND wdtv.locator_id = loc.inventory_location_id(+)
9873 AND wdtv.ZONE = sub.secondary_inventory_name
9874 AND wdtv.organization_id = sub.organization_id
9875 AND wdtv.move_order_line_id = mol.line_id
9876 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9877 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9878 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9879 (
9880 SELECT NULL
9881 FROM mtl_material_transactions_temp mmtt
9882 WHERE mmtt.transaction_temp_id = wdtv.task_id
9883 AND mmtt.parent_line_id IS NOT NULL
9884 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9885 AND NOT EXISTS -- exclude tasks already dispatched
9886 (SELECT NULL
9887 FROM wms_dispatched_tasks wdt1
9888 WHERE wdt1.transaction_temp_id = wdtv.task_id
9889 AND wdt1.task_type = wdtv.wms_task_type_id)
9890 -- Join with delivery details
9891 AND(wdd.move_order_line_id = wdtv.move_order_line_id
9892 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9893 --******************
9894 AND wdtv.task_id NOT IN -- excluded skipped tasks
9895 (
9896 SELECT wdtv.task_id
9897 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9898 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9899 AND wste.task_id = wdtv.task_id
9900 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9901 AND wste.organization_id = mp.organization_id)
9902 --*****************
9903 --J Addition
9904 AND wdtv.ZONE not in (
9905 SELECT wd.subinventory_code
9906 FROM wms_devices_b wd
9907 , wms_bus_event_devices wbed
9908 WHERE 1 = 1
9909 and wd.device_id = wbed.device_id
9910 AND wbed.organization_id = wd.organization_id
9911 AND wd.enabled_flag = 'Y'
9912 AND wbed.enabled_flag = 'Y'
9913 AND wbed.business_event_id = 10
9914 AND wd.subinventory_code IS NOT NULL
9915 AND wd.force_sign_on_flag = 'Y'
9916 AND wd.device_id NOT IN (SELECT device_id
9917 FROM wms_device_assignment_temp
9918 WHERE employee_id = p_sign_on_emp_id)
9919 )
9920 UNION ALL
9921 SELECT DISTINCT
9922 wdtv.task_id task_id1
9923 , mol.carton_grouping_id
9924 , wdtv.wms_task_type_id
9925 , mol.carton_grouping_id cluster_id
9926 , 'C' cluster_type
9927 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9928 , sub.secondary_inventory_name sub_secondary_inventory_name
9929 , sub.picking_order sub_picking_order
9930 , loc.picking_order loc_picking_order
9931 , (
9932 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9933 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9934 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9935 ) xyz_distance
9936 , loc.concatenated_segments loc_concat_segs
9937 ,1 task_status
9938 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9939 , wdt.effective_start_date
9940 , wdt.effective_end_date
9941 , wdt.person_resource_id
9942 , wdt.machine_resource_id
9943 FROM wms_dispatched_tasks wdt,
9944 (SELECT transaction_temp_id task_id
9945 , standard_operation_id user_task_type_id
9946 , wms_task_type wms_task_type_id
9947 , organization_id organization_id
9948 , subinventory_code ZONE
9949 , locator_id locator_id
9950 , task_priority task_priority
9951 , revision revision
9952 , lot_number lot_number
9953 , transaction_uom transaction_uom
9954 , transaction_quantity transaction_quantity
9955 , pick_rule_id pick_rule_id
9956 , pick_slip_number pick_slip_number
9957 , cartonization_id cartonization_id
9958 , inventory_item_id
9959 , move_order_line_id
9960 FROM mtl_material_transactions_temp
9961 WHERE wms_task_type IS NOT NULL
9962 AND transaction_status = 2
9963 AND(
9964 wms_task_status IS NULL
9965 OR wms_task_status = 1
9966 ) --Added for task planning WB. bug#2651318
9967 ) wdtv
9968 , (SELECT
9969 bsor.standard_operation_id,
9970 bre.resource_id,
9971 bre.inventory_item_id equipment_id
9972 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9973 WHERE bsor.resource_id = bre.resource_id
9974 AND br.resource_type = 1
9975 AND bsor.resource_id = br.resource_id) e
9976 , mtl_item_locations_kfv loc
9977 , --changed to kfv bug#2742611
9978 mtl_secondary_inventories sub
9979 , mtl_txn_request_lines mol
9980 , mtl_txn_request_headers moh
9981 -- mtl_system_items msi -- bug 2648133
9982 WHERE wdt.transaction_temp_id = wdtv.task_id
9983 AND wdt.status = 2 -- Queued tasks only
9984 AND wdt.person_id = p_sign_on_emp_id
9985 AND wdt.organization_id = p_sign_on_org_id
9986 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9987 AND mol.header_id = moh.header_id
9988 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9989 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
9990 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9991 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9992 AND wdtv.organization_id = loc.organization_id
9993 AND wdtv.locator_id = loc.inventory_location_id
9994 AND wdtv.ZONE = sub.secondary_inventory_name
9995 AND wdtv.organization_id = sub.organization_id
9996 AND wdtv.move_order_line_id = mol.line_id
9997 UNION ALL
9998 -- This will select the WIP Jobs alone
9999 SELECT DISTINCT
10000 wdtv.task_id task_id1
10001 , mol.carton_grouping_id
10002 , wdtv.wms_task_type_id
10003 , mol.carton_grouping_id cluster_id
10004 , 'C' cluster_type
10005 , nvl(wdtv.task_priority, 0) wdtv_task_priority
10006 , sub.secondary_inventory_name sub_secondary_inventory_name
10007 , sub.picking_order sub_picking_order
10008 , loc.picking_order loc_picking_order
10009 , (
10010 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
10011 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
10012 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
10013 ) xyz_distance
10014 , loc.concatenated_segments loc_concat_segs
10015 ,1 task_status
10016 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
10017 ,v.effective_start_date
10018 ,v.effective_end_date
10019 ,v.role person_resource_id
10020 ,v.equipment machine_resource_id
10021 FROM --wms_dispatchable_tasks_v wdtv,
10022 (SELECT transaction_temp_id task_id
10023 , standard_operation_id user_task_type_id
10024 , wms_task_type wms_task_type_id
10025 , organization_id organization_id
10026 , subinventory_code ZONE
10027 , locator_id locator_id
10028 , task_priority task_priority
10029 , revision revision
10030 , lot_number lot_number
10031 , transaction_uom transaction_uom
10032 , transaction_quantity transaction_quantity
10033 , pick_rule_id pick_rule_id
10034 , pick_slip_number pick_slip_number
10035 , cartonization_id cartonization_id
10036 , inventory_item_id
10037 , move_order_line_id
10038 FROM mtl_material_transactions_temp
10039 WHERE wms_task_type IS NOT NULL
10040 AND transaction_status = 2
10041 AND(
10042 wms_task_status IS NULL
10043 OR wms_task_status = 1
10044 ) --Added for task planning WB. bug#2651318
10045 ) wdtv
10046 , -- inlined wms_dispatchable_tasks_v, bug 2648133
10047 --wms_person_resource_utt_v v,
10048 (SELECT utt_emp.standard_operation_id standard_operation_id
10049 , utt_emp.resource_id ROLE
10050 , utt_eqp.resource_id equipment
10051 , utt_emp.person_id emp_id
10052 , utt_eqp.inventory_item_id eqp_id
10053 , NULL eqp_srl /* removed for bug 2095237 */
10054 , utt_emp.effective_start_date
10055 , utt_emp.effective_end_date
10056 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
10057 , x_utt_res1.resource_id resource_id
10058 , x_emp_r.person_id
10059 , x_emp_r.effective_start_date
10060 , x_emp_r.effective_end_date
10061 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
10062 WHERE x_utt_res1.resource_id = r1.resource_id
10063 AND r1.resource_type = 2
10064 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
10065 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
10066 , x_utt_res2.resource_id resource_id
10067 , x_eqp_r.inventory_item_id inventory_item_id
10068 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
10069 WHERE x_utt_res2.resource_id = r2.resource_id
10070 AND r2.resource_type = 1
10071 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
10072 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
10073 , -- inlined wms_person_resource_utt_v, bug 2648133
10074 mtl_item_locations_kfv loc
10075 , --changed to kfv bug#2742611
10076 mtl_secondary_inventories sub
10077 , mtl_txn_request_lines mol
10078 , mtl_txn_request_headers moh
10079 -- mtl_system_items msi -- bug 2648133
10080 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
10081 AND wdtv.organization_id = p_sign_on_org_id
10082 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
10083 AND mol.header_id = moh.header_id
10084 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
10085 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
10086 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
10087 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
10088 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
10089 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
10090 AND wdtv.locator_id = loc.inventory_location_id(+)
10091 AND wdtv.ZONE = sub.secondary_inventory_name
10092 AND wdtv.organization_id = sub.organization_id
10093 AND wdtv.move_order_line_id = mol.line_id
10094 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
10095 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
10096 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
10097 (
10098 SELECT NULL
10099 FROM mtl_material_transactions_temp mmtt
10100 WHERE mmtt.transaction_temp_id = wdtv.task_id
10101 AND mmtt.parent_line_id IS NOT NULL
10102 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
10103 AND NOT EXISTS -- exclude tasks already dispatched
10104 (SELECT NULL
10105 FROM wms_dispatched_tasks wdt1
10106 WHERE wdt1.transaction_temp_id = wdtv.task_id
10107 AND wdt1.task_type = wdtv.wms_task_type_id)
10108 --******************
10109 AND wdtv.task_id NOT IN -- excluded skipped tasks
10110 (
10111 SELECT wdtv.task_id
10112 FROM wms_skip_task_exceptions wste, mtl_parameters mp
10113 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
10114 AND wste.task_id = wdtv.task_id
10115 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
10116 AND wste.organization_id = mp.organization_id)
10117 --*****************
10118 --J Addition
10119 AND wdtv.ZONE not in (
10120 SELECT wd.subinventory_code
10121 FROM wms_devices_b wd
10122 , wms_bus_event_devices wbed
10123 WHERE 1 = 1
10124 and wd.device_id = wbed.device_id
10125 AND wbed.organization_id = wd.organization_id
10126 AND wd.enabled_flag = 'Y'
10127 AND wbed.enabled_flag = 'Y'
10128 AND wbed.business_event_id = 10
10129 AND wd.subinventory_code IS NOT NULL
10130 AND wd.force_sign_on_flag = 'Y'
10131 AND wd.device_id NOT IN (SELECT device_id
10132 FROM wms_device_assignment_temp
10133 WHERE employee_id = p_sign_on_emp_id)
10134 )
10135 ORDER BY wdtv_task_priority DESC
10136 , batch_id -- DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL)
10137 , task_status DESC
10138 , sub_picking_order
10139 , loc_picking_order
10140 , xyz_distance
10141 , task_id1;
10142
10143 CURSOR c_task_filter(v_filter_name VARCHAR2) IS
10144 SELECT task_filter_source, task_filter_value
10145 FROM wms_task_filter_b wtf, wms_task_filter_dtl wtfd
10146 WHERE task_filter_name = v_filter_name
10147 AND wtf.task_filter_id = wtfd.task_filter_id;
10148
10149
10150 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
10151 BEGIN
10152 IF (l_debug = 1) THEN
10153 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10154 END IF;
10155
10156 l_progress := '10';
10157
10158 -- This API is query only, therefore does not create a save point
10159 -- Initialize message list if p_init_msg_list is set to TRUE.
10160 IF fnd_api.to_boolean(p_init_msg_list) THEN
10161 fnd_msg_pub.initialize;
10162 END IF;
10163
10164 -- Initialize API return status to success
10165 x_return_status := fnd_api.g_ret_sts_success;
10166
10167 -- API body
10168 -- preprocess input parameters
10169
10170 IF p_sign_on_equipment_srl = 'NONE' THEN
10171 l_sign_on_equipment_srl := NULL;
10172 l_sign_on_equipment_id := -999;
10173 ELSE
10174 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
10175 l_sign_on_equipment_id := p_sign_on_equipment_id;
10176 END IF;
10177
10178 -- use l_equipment_id_str to concatenate sql statement
10179 IF l_sign_on_equipment_id IS NULL THEN
10180 l_equipment_id_str := 'NULL';
10181 ELSE
10182 l_equipment_id_str := TO_CHAR(l_sign_on_equipment_id);
10183 END IF;
10184
10185 IF p_task_type = 'PICKING' THEN
10186 l_sys_task_type := 1;
10187 ELSIF p_task_type = 'EXPPICK' THEN
10188 l_sys_task_type := 1;
10189 l_is_express_pick := 1;
10190
10191 IF (l_debug = 1) THEN
10192 print_debug('Express Pick Task', 4);
10193 END IF;
10194 ELSE
10195 l_sys_task_type := NULL;
10196 END IF;
10197
10198 -- check if this call is for picking tasks or for all tasks
10199 IF p_task_type = 'DISPLAY' THEN
10200 IF (l_debug = 1) THEN
10201 print_debug('dispatch_task - DISPLAY ', 4);
10202 END IF;
10203
10204 l_progress := '20';
10205 /*
10206 l_sql_stmt :=
10207 'SELECT wdtv.task_id, wdtv.zone, wdtv.locator_id,
10208 wdtv.revision, wdtv.transaction_uom,
10209 wdtv.transaction_quantity, wdtv.lot_number, wdtv.wms_task_type_id,nvl(wdtv.task_priority, 0)
10210 FROM wms_dispatchable_tasks_v wdtv
10211 WHERE wdtv.organization_id = ' || p_sign_on_org_id ||'
10212 AND Nvl(wdtv.zone, ''@@@'') = Nvl('''|| p_sign_on_zone || ''', Nvl(wdtv.zone, ''@@@''))
10213 AND wdtv.user_task_type_id IN
10214 (
10215 SELECT standard_operation_id
10216 FROM wms_person_resource_utt_v v
10217 WHERE v.emp_id = ' || p_sign_on_emp_id ||'
10218 AND Nvl(v.eqp_srl, ''@@@'') = Nvl(''' || l_sign_on_equipment_srl || ''', Nvl(v.eqp_srl, ''@@@''))
10219 AND Nvl(v.eqp_id, -999) = Nvl(' || l_equipment_id_str ||', Nvl(v.eqp_id, -999))
10220 )
10221 --***********
10222 AND wdtv.task_id NOT IN
10223 (SELECT wdtv.task_id FROM wms_skip_task_exceptions wste, mtl_parameters mp
10224 WHERE ((SYSDATE - wste.creation_date)*24*60) < mp.skip_task_waiting_minutes
10225 AND wste.task_id = wdtv.task_id
10226 AND wste.organization_id = mp.organization_id )
10227 --************
10228 AND wdtv.task_id NOT IN
10229 (SELECT wdt1.transaction_temp_id
10230 FROM wms_dispatched_tasks wdt1
10231 -- WHERE wdt1.status = 1
10232 UNION ALL
10233 SELECT wdt2.transaction_temp_id
10234 FROM wms_exceptions wms_except, wms_dispatched_tasks wdt2
10235 WHERE wms_except.person_id = ' || p_sign_on_emp_id || '
10236 AND wdt2.task_id = wms_except.task_id
10237 AND discrepancy_type = 1
10238 )
10239 ORDER BY wdtv.pick_slip_number, nvl(wdtv.task_priority, 0), wdtv.task_id';
10240 */
10241 ELSIF(p_task_type = 'ALL'
10242 OR p_task_type = 'EXPPICK'
10243 OR p_task_type = 'PICKING') THEN -- the call is for ALL taks
10244 IF (l_debug = 1) THEN
10245 print_debug('dispatch_task -' || p_task_type, 4);
10246 END IF;
10247
10248 l_progress := '30';
10249
10250 -- select last task this operator was working on
10251 BEGIN
10252 SELECT transaction_temp_id
10253 , task_type
10254 , loaded_time
10255 INTO l_last_loaded_task_id
10256 , l_last_loaded_task_type
10257 , l_last_loaded_time
10258 FROM (SELECT transaction_temp_id
10259 , task_type
10260 , loaded_time
10261 FROM wms_dispatched_tasks wdt
10262 WHERE wdt.person_id = p_sign_on_emp_id
10263 AND wdt.loaded_time = (SELECT MAX(loaded_time)
10264 FROM wms_dispatched_tasks
10265 WHERE person_id = p_sign_on_emp_id))
10266 WHERE ROWNUM = 1; -- make sure only one task selected
10267
10268 l_progress := '31';
10269 EXCEPTION
10270 WHEN OTHERS THEN
10271 l_last_loaded_task_id := -1;
10272 END;
10273
10274 IF (l_debug = 1) THEN
10275 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
10276 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
10277 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
10278 END IF;
10279
10280 -- select last task this operator completed
10281 BEGIN
10282 l_progress := '32';
10283
10284 SELECT transaction_id
10285 , task_type
10286 , loaded_time
10287 INTO l_last_dropoff_task_id
10288 , l_last_dropoff_task_type
10289 , l_last_dropoff_time
10290 FROM (SELECT transaction_id
10291 , task_type
10292 , loaded_time
10293 FROM wms_dispatched_tasks_history wdth
10294 WHERE wdth.person_id = p_sign_on_emp_id
10295 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
10296 FROM wms_dispatched_tasks_history
10297 WHERE person_id = p_sign_on_emp_id))
10298 WHERE ROWNUM = 1; -- make sure only one task selected
10299
10300 l_progress := '33';
10301 EXCEPTION
10302 WHEN OTHERS THEN
10303 l_last_dropoff_task_id := -1;
10304 END;
10305
10306 IF (l_debug = 1) THEN
10307 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
10308 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
10309 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
10310 END IF;
10311
10312 IF l_last_dropoff_task_id = -1
10313 AND l_last_loaded_task_id = -1 THEN
10314 l_last_task_id := -1;
10315 ELSIF l_last_dropoff_task_id = -1 THEN
10316 l_last_task_id := l_last_loaded_task_id;
10317 l_last_task_type := l_last_loaded_task_type;
10318 l_last_task_is_drop := FALSE;
10319 ELSIF l_last_loaded_task_id = -1 THEN
10320 l_last_task_id := l_last_dropoff_task_id;
10321 l_last_task_type := l_last_dropoff_task_type;
10322 l_last_task_is_drop := TRUE;
10323 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
10324 l_last_task_id := l_last_dropoff_task_id;
10325 l_last_task_type := l_last_dropoff_task_type;
10326 l_last_task_is_drop := TRUE;
10327 END IF;
10328
10329 IF (l_debug = 1) THEN
10330 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
10331 END IF;
10332
10333 -- select locator coordinates of the the last task
10334 IF l_last_task_id <> -1 THEN -- make sure there is a last task
10335 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
10336 -- get the location from wms_dispatchable_tasks_v
10337 BEGIN
10338 l_progress := '35';
10339
10340 -- use Nvl to make sure if coordinates not defined, use 0
10341 SELECT NVL(loc.x_coordinate, 0)
10342 , NVL(loc.y_coordinate, 0)
10343 , NVL(loc.z_coordinate, 0)
10344 INTO l_cur_x
10345 , l_cur_y
10346 , l_cur_z
10347 FROM mtl_item_locations loc, wms_dispatchable_tasks_v wdtv
10348 WHERE wdtv.locator_id = loc.inventory_location_id
10349 AND wdtv.organization_id = loc.organization_id
10350 AND wdtv.task_id = l_last_task_id
10351 AND wdtv.wms_task_type_id = l_last_task_type;
10352
10353 -- Added the previous line since the task_id in the view
10354 -- might not be unique since it is the transaction_temp_id
10355 -- if it comes from MMTT but the cycle_count_entry_id if
10356 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
10357 l_progress := '36';
10358 EXCEPTION
10359 WHEN OTHERS THEN
10360 -- locator definition descripency
10361 l_cur_x := 0;
10362 l_cur_y := 0;
10363 l_cur_z := 0;
10364 END;
10365 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
10366 IF l_last_task_type <> 3 THEN -- not cycle count task hence get the location from mtl_material_transactions
10367 BEGIN
10368 l_progress := '37';
10369
10370 -- use Nvl to make sure if coordinates not defined, use 0
10371 SELECT NVL(loc.x_coordinate, 0)
10372 , NVL(loc.y_coordinate, 0)
10373 , NVL(loc.z_coordinate, 0)
10374 INTO l_cur_x
10375 , l_cur_y
10376 , l_cur_z
10377 FROM mtl_item_locations loc, mtl_material_transactions mmt
10378 WHERE mmt.locator_id = loc.inventory_location_id
10379 AND mmt.organization_id = loc.organization_id
10380 AND mmt.transaction_set_id = l_last_task_id
10381 AND ROWNUM = 1;
10382
10383 l_progress := '38';
10384 EXCEPTION
10385 WHEN OTHERS THEN
10386 -- locator definition descripency
10387 l_cur_x := 0;
10388 l_cur_y := 0;
10389 l_cur_z := 0;
10390 END;
10391 ELSE -- l_last_task_type <> 3 (Cyclt Count task) hence get the location from mtl_cycle_count_entries
10392 BEGIN
10393 l_progress := '39';
10394
10395 -- use Nvl to make sure if coordinates not defined, use 0
10396 SELECT NVL(loc.x_coordinate, 0)
10397 , NVL(loc.y_coordinate, 0)
10398 , NVL(loc.z_coordinate, 0)
10399 INTO l_cur_x
10400 , l_cur_y
10401 , l_cur_z
10402 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
10403 WHERE mcce.locator_id = loc.inventory_location_id
10404 AND mcce.organization_id = loc.organization_id
10405 AND mcce.cycle_count_entry_id = l_last_task_id;
10406
10407 l_progress := '40';
10408 EXCEPTION
10409 WHEN OTHERS THEN -- adf
10410 -- locator definition descripency
10411 l_cur_x := 0;
10412 l_cur_y := 0;
10413 l_cur_z := 0;
10414 END;
10415 END IF; -- l_last_task_type <> 3
10416 END IF; -- l_last_task_is_drop <> TRUE
10417 ELSE -- there is not a previous task at all
10418 l_cur_x := 0;
10419 l_cur_y := 0;
10420 l_cur_z := 0;
10421 END IF; -- l_last_task_id <> -1
10422
10423 l_progress := '45';
10424
10425 -- Select the most optimal task
10426 -- first select eligible tasks according to employee sign on information
10427 -- order tasks by task priority, locator picking order and locator coordinates
10428 -- approximated to current locator
10429 IF (l_debug = 1) THEN
10430 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
10431 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
10432 print_debug('p_cartonization_id => ' || p_cartonization_id, 4);
10433 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
10434 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
10435 print_debug('l_cur_x => ' || l_cur_x, 4);
10436 print_debug('l_cur_y => ' || l_cur_y, 4);
10437 print_debug('l_cur_z => ' || l_cur_z, 4);
10438 END IF;
10439
10440 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
10441
10442 IF l_sequence_picks_across_waves IS NULL THEN
10443 l_sequence_picks_across_waves := 2;
10444 END IF;
10445
10446
10447 -----------------------------------
10448 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10449 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10450 -- Populate the task filter variables
10451 IF (l_debug = 1) THEN
10452 print_debug('Task Filter: ' || p_task_filter, 9);
10453 END IF;
10454
10455 FOR task_filter_rec IN c_task_filter(p_task_filter) LOOP
10456
10457 IF (l_debug = 1) THEN
10458 print_debug('Task Filter Source: ' || task_filter_rec.task_filter_source, 9);
10459 print_debug('Task Filter Value: ' || task_filter_rec.task_filter_value, 9);
10460 END IF;
10461
10462 IF task_filter_rec.task_filter_value = 'Y' THEN
10463 IF task_filter_rec.task_filter_source = 1 THEN -- Internal Order
10464 l_io_allowed := 1;
10465 ELSIF task_filter_rec.task_filter_source = 5 THEN -- Sales Order
10466 l_so_allowed := 1;
10467 ELSIF task_filter_rec.task_filter_source = 6 THEN -- Work Order
10468 l_wip_allowed := 1;
10469 END IF;
10470 END IF;
10471
10472 END LOOP;
10473
10474
10475 IF (l_debug = 1) THEN
10476 print_debug('l_so_allowed: ' || l_so_allowed, 9);
10477 print_debug('l_io_allowed: ' || l_io_allowed, 9);
10478 print_debug('l_wip_allowed: ' || l_wip_allowed, 9);
10479 END IF;
10480
10481 IF l_wip_allowed = 1 THEN
10482 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10483 IF p_sign_on_zone IS NOT NULL THEN
10484 open l_cp_ordered_tasks_SIW;
10485 ELSE OPEN l_cp_ordered_tasks_no_sub_SIW;
10486 END IF;
10487 ELSE -- only WIP
10488 IF p_sign_on_zone IS NOT NULL THEN
10489 open l_cp_ordered_tasks_W;
10490 ELSE OPEN l_cp_ordered_tasks_no_sub_W;
10491 END IF;
10492 END IF;
10493 ELSE -- only SO or IO
10494 IF p_sign_on_zone IS NOT NULL THEN
10495 open l_cp_ordered_tasks_SI;
10496 ELSE OPEN l_cp_ordered_tasks_no_sub_SI;
10497 END IF;
10498 END IF;
10499
10500 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10501 ELSE -- below patchset J
10502 ---------------------------------------
10503 -- END of patchset J APL
10504
10505 IF p_sign_on_zone IS NOT NULL THEN -- bug 2648133
10506 OPEN l_cp_curs_ordered_tasks;
10507 ELSE
10508 OPEN l_cp_curs_ordered_tasks_no_sub;
10509 END IF;
10510 END IF;
10511 l_progress := '50';
10512 --l_first_task_pick_slip_number := -1;
10513 l_ordered_tasks_count := 0;
10514
10515 LOOP -- Loop for looping through the pending eligible tasks
10516 IF (l_debug = 1) THEN
10517 print_debug('Start looping through ordered tasks: ', 4);
10518 END IF;
10519
10520 t_opt_task_id := NULL;
10521 --l_opt_task_pick_slip := NULL;
10522 t_opt_task_type := NULL;
10523 l_is_locked := FALSE;
10524 l_progress := '55';
10525
10526 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10527 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10528 IF l_wip_allowed = 1 THEN
10529 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10530 IF p_sign_on_zone IS NOT NULL THEN
10531 EXIT WHEN l_cp_ordered_tasks_SIW%NOTFOUND;
10532 FETCH l_cp_ordered_tasks_SIW BULK COLLECT INTO t_opt_task_id
10533 , t_carton_grouping_id
10534 , t_opt_task_type
10535 , t_cluster_id
10536 , t_cluster_type
10537 , t_task_priority
10538 , t_sub_code
10539 , t_sub_picking_order
10540 , t_loc_picking_order
10541 , t_xyz_distance
10542 , t_loc_concat_segs
10543 , t_task_Status
10544 , t_batch_id
10545 , t_effective_start_date
10546 , t_effective_end_date
10547 , t_person_resource_id
10548 , t_machine_resource_id LIMIT blk_limit;
10549
10550 ELSE
10551 EXIT WHEN l_cp_ordered_tasks_no_sub_SIW%NOTFOUND;
10552 FETCH l_cp_ordered_tasks_no_sub_SIW BULK COLLECT INTO t_opt_task_id
10553 , t_carton_grouping_id
10554 , t_opt_task_type
10555 , t_cluster_id
10556 , t_cluster_type
10557 , t_task_priority
10558 , t_sub_code
10559 , t_sub_picking_order
10560 , t_loc_picking_order
10561 , t_xyz_distance
10562 , t_loc_concat_segs
10563 , t_task_Status
10564 , t_batch_id
10565 , t_effective_start_date
10566 , t_effective_end_date
10567 , t_person_resource_id
10568 , t_machine_resource_id LIMIT blk_limit;
10569
10570 END IF;
10571 ELSE -- only WIP
10572 IF p_sign_on_zone IS NOT NULL THEN
10573 EXIT WHEN l_cp_ordered_tasks_W%NOTFOUND;
10574 FETCH l_cp_ordered_tasks_W BULK COLLECT INTO t_opt_task_id
10575 , t_carton_grouping_id
10576 , t_opt_task_type
10577 , t_cluster_id
10578 , t_cluster_type
10579 , t_task_priority
10580 , t_sub_code
10581 , t_sub_picking_order
10582 , t_loc_picking_order
10583 , t_xyz_distance
10584 , t_loc_concat_segs
10585 , t_task_Status
10586 , t_batch_id
10587 , t_effective_start_date
10588 , t_effective_end_date
10589 , t_person_resource_id
10590 , t_machine_resource_id LIMIT blk_limit;
10591
10592 ELSE
10593 EXIT WHEN l_cp_ordered_tasks_no_sub_W%NOTFOUND;
10594 FETCH l_cp_ordered_tasks_no_sub_W BULK COLLECT INTO t_opt_task_id
10595 , t_carton_grouping_id
10596 , t_opt_task_type
10597 , t_cluster_id
10598 , t_cluster_type
10599 , t_task_priority
10600 , t_sub_code
10601 , t_sub_picking_order
10602 , t_loc_picking_order
10603 , t_xyz_distance
10604 , t_loc_concat_segs
10605 , t_task_Status
10606 , t_batch_id
10607 , t_effective_start_date
10608 , t_effective_end_date
10609 , t_person_resource_id
10610 , t_machine_resource_id LIMIT blk_limit;
10611
10612 END IF;
10613 END IF;
10614 ELSE -- only SO or IO
10615 IF p_sign_on_zone IS NOT NULL THEN
10616 EXIT WHEN l_cp_ordered_tasks_SI%NOTFOUND;
10617 FETCH l_cp_ordered_tasks_SI BULK COLLECT INTO t_opt_task_id
10618 , t_carton_grouping_id
10619 , t_opt_task_type
10620 , t_cluster_id
10621 , t_cluster_type
10622 , t_task_priority
10623 , t_sub_code
10624 , t_sub_picking_order
10625 , t_loc_picking_order
10626 , t_xyz_distance
10627 , t_loc_concat_segs
10628 , t_task_Status
10629 , t_batch_id
10630 , t_effective_start_date
10631 , t_effective_end_date
10632 , t_person_resource_id
10633 , t_machine_resource_id LIMIT blk_limit;
10634
10635 ELSE
10636 EXIT WHEN l_cp_ordered_tasks_no_sub_SI%NOTFOUND;
10637 FETCH l_cp_ordered_tasks_no_sub_SI BULK COLLECT INTO t_opt_task_id
10638 , t_carton_grouping_id
10639 , t_opt_task_type
10640 , t_cluster_id
10641 , t_cluster_type
10642 , t_task_priority
10643 , t_sub_code
10644 , t_sub_picking_order
10645 , t_loc_picking_order
10646 , t_xyz_distance
10647 , t_loc_concat_segs
10648 , t_task_Status
10649 , t_batch_id
10650 , t_effective_start_date
10651 , t_effective_end_date
10652 , t_person_resource_id
10653 , t_machine_resource_id LIMIT blk_limit;
10654 END IF;
10655 END IF;
10656
10657 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10658 ELSE -- below patchset J
10659 IF p_sign_on_zone IS NOT NULL THEN -- bug 2648133
10660 EXIT WHEN l_cp_curs_ordered_tasks%NOTFOUND;
10661 FETCH l_cp_curs_ordered_tasks BULK COLLECT INTO t_opt_task_id
10662 , t_carton_grouping_id
10663 , t_opt_task_type
10664 , t_cluster_id
10665 , t_cluster_type
10666 , t_task_priority
10667 , t_sub_code
10668 , t_sub_picking_order
10669 , t_loc_picking_order
10670 , t_xyz_distance
10671 , t_loc_concat_segs LIMIT blk_limit;
10672 ELSE --sign on zone is null
10673 EXIT WHEN l_cp_curs_ordered_tasks_no_sub%NOTFOUND;
10674 FETCH l_cp_curs_ordered_tasks_no_sub BULK COLLECT INTO t_opt_task_id
10675 , t_carton_grouping_id
10676 , t_opt_task_type
10677 , t_cluster_id
10678 , t_cluster_type
10679 , t_task_priority
10680 , t_sub_code
10681 , t_sub_picking_order
10682 , t_loc_picking_order
10683 , t_xyz_distance
10684 , t_loc_concat_segs LIMIT blk_limit;
10685 END IF;
10686 END IF; -- end the patchset J checking
10687
10688 l_progress := '60';
10689
10690 FOR idx IN 1 .. t_opt_task_id.COUNT LOOP -- looping through the current batch of tasks
10691 IF (l_debug = 1) THEN
10692 print_debug('l_opt_task_id => ' || t_opt_task_id(idx), 4);
10693 print_debug('l_carton_grouping_id => ' || t_carton_grouping_id(idx), 4);
10694 print_debug('l_opt_task_type => ' || t_opt_task_type(idx), 4);
10695 print_debug('l_cluster_id => ' || t_cluster_id(idx), 4);
10696 print_debug('l_cluster_type => ' || t_cluster_type(idx), 4);
10697 END IF;
10698
10699 BEGIN
10700 l_cluster_exists := FALSE;
10701 l_progress := '61';
10702
10703 FOR i IN 1 .. cluster_table.COUNT LOOP -- Check whether the cluster exists already in the cluster table
10704 IF (cluster_table(i).cluster_id = t_cluster_id(idx)
10705 AND cluster_table(i).cluster_type = t_cluster_type(idx)) THEN
10706 -- This cluster had been already dispatched in this session
10707 l_cluster_exists := TRUE;
10708 EXIT;
10709 END IF;
10710 END LOOP;
10711
10712 l_progress := '62';
10713 END;
10714
10715 l_progress := '63';
10716
10717 IF t_cluster_id(idx) IS NOT NULL THEN -- dispatch tasks only if cluster exists
10718 IF l_cluster_exists THEN -- Cluster already exists so dispatch this task too.
10719 IF (l_debug = 1) THEN
10720 print_debug(' Cluster already exists so dispatching this task too', 4);
10721 END IF;
10722
10723 -- Test if this task is locked by any other user
10724 BEGIN
10725 SELECT mmtt.transaction_temp_id
10726 INTO t_opt_task_id(idx)
10727 FROM mtl_material_transactions_temp mmtt
10728 WHERE mmtt.transaction_temp_id = t_opt_task_id(idx)
10729 FOR UPDATE NOWAIT;
10730 EXCEPTION
10731 WHEN OTHERS THEN
10732 IF (l_debug = 1) THEN
10733 print_debug('This task is locked by other user. ', 4);
10734 END IF;
10735
10736 l_is_locked := TRUE;
10737 END;
10738
10739 IF l_is_locked <> TRUE THEN
10740 l_ordered_tasks_count := l_ordered_tasks_count + 1;
10741
10742 --l_first_task_pick_slip_number := l_opt_task_pick_slip;
10743
10744 IF (l_debug = 1) THEN
10745 print_debug(
10746 'This task has the same cluster details of already dispatched task. l_ordered_tasks_count => ' || l_ordered_tasks_count
10747 , 4
10748 );
10749 END IF;
10750
10751 l_progress := '72';
10752 -- check if this is queued task or not
10753 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10754 IF (l_debug = 1) THEN
10755 print_debug('Insert task '||t_opt_task_id(idx)||' Effective start date'||t_effective_start_date(idx),4);
10756 END IF;
10757 INSERT INTO wms_ordered_tasks
10758 (
10759 task_id
10760 , wms_task_type
10761 , task_sequence_id
10762 , effective_start_date
10763 , effective_end_date
10764 , person_resource_id
10765 , machine_resource_id
10766 )
10767 VALUES (
10768 t_opt_task_id(idx)
10769 , t_opt_task_type(idx)
10770 , l_ordered_tasks_count
10771 , t_effective_start_date(idx)
10772 , t_effective_end_date(idx)
10773 , t_person_resource_id(idx)
10774 , t_machine_resource_id(idx)
10775 );
10776 ELSE -- before patchset J
10777 INSERT INTO wms_ordered_tasks
10778 (
10779 task_id
10780 , wms_task_type
10781 , task_sequence_id
10782 )
10783 VALUES (
10784 t_opt_task_id(idx)
10785 , t_opt_task_type(idx)
10786 , l_ordered_tasks_count
10787 );
10788 END IF;
10789
10790 l_progress := '73';
10791 END IF;
10792 ELSE -- Cluster Doesn't Exist
10793 IF (l_debug = 1) THEN
10794 print_debug(' Cluster doesnot exists, so a new task', 4);
10795 END IF;
10796
10797 IF l_cluster_count < p_max_clusters THEN -- Maximum clusters not reached and hence can dispatch the task from this cluster
10798 IF (l_debug = 1) THEN
10799 print_debug(' Max Cluster not reached hence can dispatch this cluster ', 4);
10800 END IF;
10801
10802 -- Test if this task is locked by any other user
10803 BEGIN
10804 SELECT mmtt.transaction_temp_id
10805 INTO t_opt_task_id(idx)
10806 FROM mtl_material_transactions_temp mmtt
10807 WHERE mmtt.transaction_temp_id = t_opt_task_id(idx)
10808 FOR UPDATE NOWAIT;
10809 EXCEPTION
10810 WHEN OTHERS THEN
10811 IF (l_debug = 1) THEN
10812 print_debug('This task is locked by other user. ', 4);
10813 END IF;
10814
10815 l_is_locked := TRUE;
10816 END;
10817
10818 IF l_is_locked <> TRUE THEN
10819 l_ordered_tasks_count := l_ordered_tasks_count + 1;
10820
10821 IF (l_debug = 1) THEN
10822 print_debug('This task is from a new cluster. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
10823 END IF;
10824
10825 l_progress := '74';
10826
10827 -- check if this is queued task or not
10828 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10829 IF (l_debug = 1) THEN
10830 print_debug('Insert task '||t_opt_task_id(idx)||' Effective start date'||
10831 t_effective_start_date(idx),4);
10832 END IF;
10833 INSERT INTO wms_ordered_tasks
10834 (
10835 task_id
10836 , wms_task_type
10837 , task_sequence_id
10838 , effective_start_date
10839 , effective_end_date
10840 , person_resource_id
10841 , machine_resource_id
10842 )
10843 VALUES (
10844 t_opt_task_id(idx)
10845 , t_opt_task_type(idx)
10846 , l_ordered_tasks_count
10847 , t_effective_start_date(idx)
10848 , t_effective_end_date(idx)
10849 , t_person_resource_id(idx)
10850 , t_machine_resource_id(idx)
10851 );
10852 ELSE -- before patchset J
10853 INSERT INTO wms_ordered_tasks
10854 (
10855 task_id
10856 , wms_task_type
10857 , task_sequence_id
10858 )
10859 VALUES (
10860 t_opt_task_id(idx)
10861 , t_opt_task_type(idx)
10862 , l_ordered_tasks_count
10863 );
10864 END IF;
10865
10866 l_progress := '75';
10867
10868 IF t_cluster_type(idx) = 'D' THEN
10869 l_deliveries_list := l_deliveries_list || ', ' || t_cluster_id(idx);
10870
10871 IF (l_debug = 1) THEN
10872 print_debug(' building deliveries list ' || l_deliveries_list, 4);
10873 END IF;
10874
10875 IF t_carton_grouping_id(idx) IS NOT NULL THEN
10876 l_cartons_list := l_cartons_list || ', ' || t_carton_grouping_id(idx);
10877
10878 IF (l_debug = 1) THEN
10879 print_debug(' deliveries exists still building cartons list ' || l_cartons_list, 4);
10880 END IF;
10881 END IF;
10882 ELSE
10883 l_cartons_list := l_cartons_list || ', ' || t_cluster_id(idx);
10884
10885 IF (l_debug = 1) THEN
10886 print_debug(' building cartons list ' || l_cartons_list, 4);
10887 END IF;
10888 END IF;
10889
10890 --Increase the clusters dispatched count
10891 l_cluster_count := l_cluster_count + 1;
10892 --Store this cluster details in the cluster_table
10893 cluster_table(l_cluster_count).cluster_id := t_cluster_id(idx);
10894 cluster_table(l_cluster_count).cluster_type := t_cluster_type(idx);
10895 END IF;
10896 ELSE -- Maxmimum Clusters reached, hence can't dispatch this task so ignore it.
10897 IF (l_debug = 1) THEN
10898 print_debug('Max Clusters reached and hence ignoring this task ', 4);
10899 END IF;
10900
10901 NULL;
10902 END IF;
10903 END IF;
10904 END IF;
10905 END LOOP; -- bulk collect loop
10906 END LOOP; -- task dispatching loop
10907
10908 IF l_deliveries_list IS NOT NULL THEN --append the starting and ending braces to deliveries list
10909 l_deliveries_list := '( -999 ' || l_deliveries_list || ' ) ';
10910
10911 IF (l_debug = 1) THEN
10912 print_debug(' final deliveries list ' || l_deliveries_list, 4);
10913 END IF;
10914
10915 x_deliveries_list := l_deliveries_list;
10916 END IF;
10917
10918 IF l_cartons_list IS NOT NULL THEN --append the starting and ending braces to cartons list
10919 l_cartons_list := '( -999 ' || l_cartons_list || ' ) ';
10920
10921 IF (l_debug = 1) THEN
10922 print_debug(' final cartons list ' || l_cartons_list, 4);
10923 END IF;
10924
10925 x_cartons_list := l_cartons_list;
10926 END IF;
10927
10928 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10929 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10930 IF l_wip_allowed = 1 THEN
10931 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10932 IF p_sign_on_zone IS NOT NULL THEN
10933 close l_cp_ordered_tasks_SIW;
10934 ELSE close l_cp_ordered_tasks_no_sub_SIW;
10935 END IF;
10936 ELSE -- only WIP
10937 IF p_sign_on_zone IS NOT NULL THEN
10938 close l_cp_ordered_tasks_W;
10939 ELSE close l_cp_ordered_tasks_no_sub_W;
10940 END IF;
10941 END IF;
10942 ELSE -- only SO or IO
10943 IF p_sign_on_zone IS NOT NULL THEN
10944 close l_cp_ordered_tasks_SI;
10945 ELSE close l_cp_ordered_tasks_no_sub_SI;
10946 END IF;
10947 END IF;
10948
10949 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10950 END IF;
10951
10952 IF l_cp_curs_ordered_tasks%ISOPEN THEN
10953 CLOSE l_cp_curs_ordered_tasks;
10954 END IF;
10955
10956 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
10957 CLOSE l_cp_curs_ordered_tasks_no_sub;
10958 END IF;
10959
10960 IF (l_debug = 1) THEN
10961 print_debug('Total task dispatched: l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
10962 END IF;
10963
10964 IF l_ordered_tasks_count = 0 THEN
10965 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
10966 fnd_msg_pub.ADD;
10967
10968 IF (l_debug = 1) THEN
10969 print_debug('dispatch_task - No eligible picking tasks ', 4);
10970 END IF;
10971
10972 RAISE fnd_api.g_exc_error;
10973 END IF;
10974
10975 l_progress := '90';
10976 END IF; -- end task type check if
10977
10978 -- open reference cursor for this statement
10979
10980 IF (l_debug = 1) THEN
10981 print_debug('dispatch_task 120 - before opeing ref cursor ', 4);
10982 END IF;
10983
10984 l_progress := '110';
10985 -- bug 2648133, changed to static SQL and query against base tables
10986 --OPEN x_task_cur FOR l_sql_stmt;
10987 OPEN x_task_cur FOR
10988 SELECT mmtt.transaction_temp_id task_id
10989 , mmtt.subinventory_code ZONE
10990 , mmtt.locator_id locator_id
10991 , mmtt.revision revision
10992 , mmtt.transaction_uom transaction_uom
10993 , mmtt.transaction_quantity transaction_quantity
10994 , '' lot_number
10995 , mmtt.wms_task_type wms_task_type_id
10996 , mmtt.task_priority task_priority
10997 , mmtt.operation_plan_id,
10998 mmtt.standard_operation_id,
10999 wot.effective_start_date,
11000 wot.effective_end_date,
11001 wot.person_resource_id,
11002 wot.machine_resource_id,
11003 mmtt.move_order_line_id
11004 FROM mtl_material_transactions_temp mmtt, wms_ordered_tasks wot
11005 WHERE mmtt.wms_task_type IS NOT NULL
11006 AND mmtt.transaction_status = 2
11007 AND mmtt.transaction_temp_id = wot.task_id
11008 AND mmtt.transaction_temp_id > 0
11009 ORDER BY wot.task_sequence_id;
11010 l_progress := '120';
11011 EXCEPTION
11012 WHEN fnd_api.g_exc_error THEN
11013 x_return_status := fnd_api.g_ret_sts_error;
11014
11015 IF l_cp_curs_ordered_tasks%ISOPEN THEN
11016 CLOSE l_cp_curs_ordered_tasks;
11017 END IF;
11018
11019 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
11020 CLOSE l_cp_curs_ordered_tasks_no_sub;
11021 END IF;
11022
11023 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11024
11025 IF (l_debug = 1) THEN
11026 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11027 END IF;
11028 WHEN fnd_api.g_exc_unexpected_error THEN
11029 x_return_status := fnd_api.g_ret_sts_unexp_error;
11030
11031 IF l_cp_curs_ordered_tasks%ISOPEN THEN
11032 CLOSE l_cp_curs_ordered_tasks;
11033 END IF;
11034
11035 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
11036 CLOSE l_cp_curs_ordered_tasks_no_sub;
11037 END IF;
11038
11039 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11040
11041 IF (l_debug = 1) THEN
11042 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11043 END IF;
11044 WHEN OTHERS THEN
11045 x_return_status := fnd_api.g_ret_sts_unexp_error;
11046
11047 IF l_cp_curs_ordered_tasks%ISOPEN THEN
11048 CLOSE l_cp_curs_ordered_tasks;
11049 END IF;
11050
11051 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
11052 CLOSE l_cp_curs_ordered_tasks_no_sub;
11053 END IF;
11054
11055 IF SQLCODE IS NOT NULL THEN
11056 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
11057 END IF;
11058
11059 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11060
11061 IF (l_debug = 1) THEN
11062 print_debug('dispatch_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11063 END IF;
11064 END dispatch_task; --overloaded dispatch_Task for cluster picking
11065
11066
11067 FUNCTION min_num(a NUMBER, b NUMBER)
11068 RETURN NUMBER IS
11069 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11070 BEGIN
11071 IF (a <= b) THEN
11072 RETURN a;
11073 ELSE
11074 RETURN b;
11075 END IF;
11076 END min_num;
11077
11078 PROCEDURE split_tasks(
11079 p_api_version NUMBER
11080 , p_move_order_header_id NUMBER
11081 , p_commit VARCHAR2 := fnd_api.g_false
11082 , x_return_status OUT NOCOPY VARCHAR2
11083 , x_msg_count OUT NOCOPY NUMBER
11084 , x_msg_data OUT NOCOPY VARCHAR2
11085 ) IS
11086 l_api_name VARCHAR2(30) := 'split_tasks';
11087 l_transaction_temp_id NUMBER;
11088 l_return_status VARCHAR2(1);
11089 l_msg_count NUMBER;
11090 l_msg_data VARCHAR2(400);
11091 l_progress VARCHAR2(10);
11092 l_move_order_type NUMBER;
11093
11094 CURSOR task_list IS
11095 SELECT mmtt.transaction_temp_id
11096 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
11097 WHERE mmtt.move_order_line_id = mol.line_id
11098 AND mol.header_id = p_move_order_header_id;
11099
11100
11101 ---- Patchset J, bulk picking -------------
11102 CURSOR task_list_bulk IS
11103 SELECT mmtt.transaction_temp_id
11104 FROM wms_cartonization_temp mmtt
11105 WHERE
11106 mmtt.parent_line_id is null -- non bulked tasks
11107 OR mmtt.parent_line_id = mmtt.transaction_temp_id; -- parent line only
11108 ---- End of Patchset J, bulk picking -------------
11109
11110
11111 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11112 BEGIN
11113 -- Initialize API return status to success
11114 x_return_status := fnd_api.g_ret_sts_success;
11115
11116 IF (l_debug = 1) THEN
11117 print_debug('Enter split_tasks 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11118 END IF;
11119
11120 -- changed for patchset J bulk picking -----------
11121 IF p_move_order_header_id <> -1 THEN
11122 SELECT move_order_type
11123 INTO l_move_order_type
11124 FROM mtl_txn_request_headers
11125 WHERE header_id = p_move_order_header_id;
11126
11127 if (l_debug = 1) then print_debug('Move order type:'||l_move_order_type,4);
11128 end if;
11129 ELSE
11130 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
11131 l_move_order_type := G_MOVE_ORDER_PICK_WAVE;
11132 if (l_debug = 1) then print_debug('calling from the conconcurrent program for so ...',4);
11133 -- print_debug('PATCHSET J-- BULK PICKING --END ',4);
11134 end if;
11135 END IF;
11136
11137 -- end of change for patchset J bulk picking ------------------
11138
11139 l_progress := '10';
11140 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
11141 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
11142 OPEN task_list_bulk;
11143 ELSE
11144 OPEN task_list;
11145 END IF;
11146 l_progress := '20';
11147
11148 LOOP
11149 l_progress := '30';
11150 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL and
11151 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
11152 FETCH task_list_bulk INTO l_transaction_temp_id;
11153 EXIT WHEN task_list_bulk%NOTFOUND;
11154 else
11155 FETCH task_list INTO l_transaction_temp_id;
11156 EXIT WHEN task_list%NOTFOUND;
11157 end if;
11158
11159 IF (l_debug = 1) THEN
11160 print_debug('split_tasks 20 split task with l_transaction_temp_id = ' || l_transaction_temp_id, 1);
11161 END IF;
11162
11163 l_progress := '40';
11164 split_task(
11165 p_api_version => 1.0
11166 , p_task_id => l_transaction_temp_id
11167 , x_return_status => l_return_status
11168 , x_msg_count => l_msg_count
11169 , x_msg_data => l_msg_data
11170 );
11171
11172 IF l_return_status = fnd_api.g_ret_sts_error THEN
11173 IF (l_debug = 1) THEN
11174 print_debug('split_tasks 30 - split_task RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11175 END IF;
11176
11177 -- RAISE fnd_api.g_exc_error;
11178 -- in case of error for one task, should continue for another task
11179 END IF;
11180
11181 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
11182 IF (l_debug = 1) THEN
11183 print_debug('split_tasks 40 - split_task RAISE FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11184 END IF;
11185
11186 RAISE fnd_api.g_exc_unexpected_error;
11187 END IF;
11188 END LOOP;
11189
11190 l_progress := '50';
11191 if task_list_bulk%ISOPEN then
11192 CLOSE task_list_bulk;
11193 else
11194 CLOSE task_list;
11195 end if;
11196 l_progress := '60';
11197
11198 IF (l_debug = 1) THEN
11199 print_debug('split_tasks 50 complete' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11200 END IF;
11201 EXCEPTION
11202 WHEN fnd_api.g_exc_error THEN
11203 x_return_status := fnd_api.g_ret_sts_error;
11204 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11205
11206 IF (l_debug = 1) THEN
11207 print_debug('split_tasks: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11208 END IF;
11209 WHEN fnd_api.g_exc_unexpected_error THEN
11210 x_return_status := fnd_api.g_ret_sts_unexp_error;
11211 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11212
11213 IF (l_debug = 1) THEN
11214 print_debug('split_tasks: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11215 END IF;
11216 WHEN OTHERS THEN
11217 x_return_status := fnd_api.g_ret_sts_unexp_error;
11218
11219 IF SQLCODE IS NOT NULL THEN
11220 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.split_tasks', l_progress, SQLCODE);
11221 END IF;
11222
11223 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11224
11225 IF (l_debug = 1) THEN
11226 print_debug('split_tasks: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11227 END IF;
11228 END split_tasks;
11229
11230 FUNCTION is_equipment_cap_exceeded(
11231 p_standard_operation_id IN NUMBER
11232 , p_item_id IN NUMBER
11233 , p_organization_id IN NUMBER
11234 , p_txn_qty IN NUMBER
11235 , p_txn_uom_code IN VARCHAR2
11236 )
11237 RETURN VARCHAR2 IS
11238 l_item_prim_uom_code VARCHAR2(3);
11239 l_txn_pri_uom_ratio NUMBER;
11240 l_equip_vol NUMBER;
11241 l_equip_weight NUMBER;
11242 l_item_vol NUMBER;
11243 l_item_weight NUMBER;
11244 l_equip_v_uom VARCHAR2(3);
11245 l_equip_w_uom VARCHAR2(3);
11246 l_item_v_uom VARCHAR2(3);
11247 l_item_w_uom VARCHAR2(3);
11248 l_eq_it_v_uom_ratio NUMBER;
11249 l_eq_it_w_uom_ratio NUMBER;
11250 l_min_cap NUMBER := -1;
11251 l_min_cap_temp NUMBER;
11252 l_progress VARCHAR2(10);
11253
11254 CURSOR l_capcity_cur IS
11255 SELECT equip.internal_volume equip_vol
11256 , -- equipment volume capacity
11257 equip.maximum_load_weight equip_weight
11258 , -- equipment weight capacity
11259 item.unit_volume item_vol
11260 , -- item unit volume
11261 item.unit_weight item_weight
11262 , -- item unit weight
11263 equip.volume_uom_code equip_v_uom
11264 , -- equipment volumn UOM code
11265 equip.weight_uom_code equip_w_uom
11266 , -- equipment weight UOM code
11267 item.volume_uom_code item_v_uom
11268 , -- item volume UOM code
11269 item.weight_uom_code item_w_uom -- item weight UOM code
11270 FROM mtl_system_items equip
11271 , mtl_system_items item
11272 , bom_resource_equipments res_equip
11273 , bom_resources res
11274 , bom_std_op_resources tt_x_res
11275 WHERE tt_x_res.standard_operation_id = p_standard_operation_id --join task with task_type-resource x-ref
11276 AND tt_x_res.resource_id = res.resource_id -- join with resource
11277 AND res.resource_type = 1 -- resource type for equipment
11278 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
11279 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
11280 AND equip.organization_id = res_equip.organization_id
11281 AND item.inventory_item_id = p_item_id -- join with item for the item that is transfered
11282 AND item.organization_id = p_organization_id;
11283
11284 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11285 BEGIN
11286 IF (l_debug = 1) THEN
11287 print_debug('Enter is_equipment_cap_exceeded 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11288 END IF;
11289
11290 l_progress := '10';
11291
11292 SELECT primary_uom_code
11293 INTO l_item_prim_uom_code
11294 FROM mtl_system_items
11295 WHERE inventory_item_id = p_item_id
11296 AND organization_id = p_organization_id;
11297
11298 -- compute conversion rate between transaction UOM and item primary UOM
11299 inv_convert.inv_um_conversion(from_unit => p_txn_uom_code, to_unit => l_item_prim_uom_code, item_id => p_item_id
11300 , uom_rate => l_txn_pri_uom_ratio);
11301
11302 IF l_txn_pri_uom_ratio = -99999 THEN -- uom conversion failure
11303 IF (l_debug = 1) THEN
11304 print_debug('is_equipment_cap_exceeded 20 - txn/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11305 END IF;
11306
11307 RETURN 'N';
11308 END IF;
11309
11310 IF (l_debug = 1) THEN
11311 print_debug('is_equipment_cap_exceeded 30 - UOM conversion data:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11312 END IF;
11313
11314 IF (l_debug = 1) THEN
11315 print_debug('l_txn_pri_uom_ratio => ' || l_txn_pri_uom_ratio, 4);
11316 END IF;
11317
11318 -- Query minimum equipment capacity in terms of transaction UOM
11319 -- The minimum of the volumn and weight capacity is used
11320 -- If no equipment capacity or item unit volumn or weight defined,
11321 -- do not split
11322 -- NEED FURTHER consideration for container item:
11323 -- should check unit volume and content weight ???
11324
11325 l_progress := '20';
11326 OPEN l_capcity_cur;
11327 l_progress := '30';
11328
11329 LOOP
11330 l_progress := '40';
11331 FETCH l_capcity_cur INTO l_equip_vol, l_equip_weight, l_item_vol, l_item_weight, l_equip_v_uom, l_equip_w_uom, l_item_v_uom
11332 , l_item_w_uom;
11333 l_progress := '50';
11334 EXIT WHEN l_capcity_cur%NOTFOUND;
11335 -- get the conversion ratio between equipment and item volume UOM
11336 inv_convert.inv_um_conversion(from_unit => l_equip_v_uom, to_unit => l_item_v_uom, item_id => 0, uom_rate => l_eq_it_v_uom_ratio);
11337
11338 IF l_eq_it_v_uom_ratio = -99999 THEN -- uom conversion failure
11339 IF (l_debug = 1) THEN
11340 print_debug('is_equipment_cap_exceeded 40 - eqp/item volume uom ratio calculation failed'
11341 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11342 , 4);
11343 END IF;
11344 END IF;
11345
11346 -- get the conversion ratio between equipment and item weight UOM
11347 inv_convert.inv_um_conversion(from_unit => l_equip_w_uom, to_unit => l_item_w_uom, item_id => 0, uom_rate => l_eq_it_w_uom_ratio);
11348
11349 IF l_eq_it_w_uom_ratio = -99999 THEN -- uom conversion failure
11350 IF (l_debug = 1) THEN
11351 print_debug('is_equipment_cap_exceeded 50 - eqp/item weight uom ratio calculation failed'
11352 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11353 , 4);
11354 END IF;
11355 END IF;
11356 --Bug 8800509 Start of code addition
11357 --volume for both item and equipment are defined
11358 IF (l_equip_vol IS NOT NULL AND l_item_vol IS NOT NULL AND l_eq_it_v_uom_ratio <> -99999) THEN
11359 --weight for both item and equip are defined
11360 IF (l_equip_weight IS NOT NULL AND l_item_weight IS NOT NULL AND l_eq_it_w_uom_ratio <> -99999) THEN
11361 --both weight and voulme are defined for item and equip
11362 --calculate based on both
11363
11364 IF (l_debug = 1) THEN
11365 print_debug('split_task 70.1, both weight and voulme are defined for item and equip, calculate equipment capacity based on both weight and volume',4);
11366 END IF;
11367
11368 l_min_cap_temp := TRUNC(min_num((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))/ l_txn_pri_uom_ratio);
11369 --
11370 -- Start FP Bug 4634596
11371 --
11372 IF (l_min_cap_temp = 0) THEN
11373 l_min_cap_temp := min_num((l_equip_vol * l_eq_it_v_uom_ratio /l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight)) / l_txn_pri_uom_ratio;
11374 END IF;
11375 ELSE
11376 --only volume is defined for item and equip
11377 --calculate equipment capacity based on volume only
11378 IF (l_debug = 1) THEN
11379 print_debug('split_task 70.1, only voulme defined for item and equip, calculate equipment capacity based on volume',4);
11380 END IF;
11381 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
11382 --
11383 -- Start FP Bug 4634596
11384 --
11385 IF (l_min_cap_temp = 0) THEN
11386 l_min_cap_temp := (l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio;
11387 END IF;
11388 --
11389 -- End FP Bug 4634596
11390 --
11391 END IF;
11392 --weight for both item and equipment are defined, but volume is not defined for one of them
11393 ELSIF (l_equip_weight IS NOT NULL AND l_item_weight IS NOT NULL AND l_eq_it_w_uom_ratio <> -99999) THEN
11394 --calculate based on weight only
11395
11396 IF (l_debug = 1) THEN
11397 print_debug('split_task 70.1, only weight defined for item and equip, calculate equipment capacity based on weight',4);
11398 END IF;
11399 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
11400 --
11401 -- Start FP Bug 4634596
11402 --
11403 IF (l_min_cap_temp = 0) THEN
11404 l_min_cap_temp := (l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio;
11405 END IF;
11406 --
11407 -- End FP Bug 4634596
11408 --
11409 ELSE
11410 --throw error, as no capicity definition
11411 IF (l_debug = 1) THEN
11412 print_debug('split_task 80 - invalid capacity for a particulcar equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11413 END IF;
11414 END IF;
11415
11416 IF (l_debug = 1) THEN
11417 print_debug('split_task 1.6, l_min_cap'||l_min_cap,4);
11418 print_debug('split_task 1.6, l_min_cap_temp'|| l_min_cap_temp,4);
11419 END IF;
11420
11421 IF (l_min_cap = -1)
11422 OR(l_min_cap > l_min_cap_temp) THEN
11423 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
11424 END IF;
11425 --Bug 8800509 End of code addition
11426
11427 --Bug 8800509 Start Commented out code
11428 /* IF (l_equip_vol IS NOT NULL
11429 AND l_item_vol IS NOT NULL
11430 AND l_eq_it_v_uom_ratio <> -99999)
11431 OR(l_equip_weight IS NOT NULL
11432 AND l_item_weight IS NOT NULL
11433 AND l_eq_it_w_uom_ratio <> -99999) THEN
11434 IF l_eq_it_v_uom_ratio = -99999 THEN -- invalid volume UOM conversion
11435 -- compute equipment capacity using weight
11436 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
11437 ELSIF l_eq_it_w_uom_ratio = -9999 THEN -- invalid weight conversion
11438 -- compute equipment capacity using volume
11439 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
11440 ELSE -- both weight and volume defined
11441 -- compute the minimum of volume capacity and weight capacity
11442 -- transfer the capacity to transaction UOM
11443 l_min_cap_temp :=
11444 TRUNC(
11445 min_num((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))
11446 / l_txn_pri_uom_ratio
11447 );
11448 END IF;
11449
11450 IF (l_min_cap = -1)
11451 OR(l_min_cap > l_min_cap_temp) THEN
11452 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
11453 END IF;
11454 ELSE -- neither of weight or volume capacity is properly defined
11455 IF (l_debug = 1) THEN
11456 print_debug('is_equipment_cap_exceeded 60 - invalid capacity for a particulcar equipment'
11457 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11458 , 4);
11459 END IF;
11460 END IF;*/
11461 --Bug 8800509 Start Commented out code
11462 END LOOP;
11463
11464 l_progress := '60';
11465 CLOSE l_capcity_cur;
11466 l_progress := '70';
11467
11468 IF l_min_cap <= 0 THEN -- min capcity is not properly queried
11469 IF (l_debug = 1) THEN
11470 print_debug('is_equipment_cap_exceeded 70 - invalid capacity for a ALL equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11471 END IF;
11472
11473 RETURN 'N';
11474 ELSIF TRUNC(l_min_cap) < TRUNC(p_txn_qty) THEN
11475 IF (l_debug = 1) THEN
11476 print_debug('is_equipment_cap_exceeded 75 - equipment capacity exceeded' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11477 END IF;
11478
11479 RETURN 'Y';
11480 ELSE
11481 IF (l_debug = 1) THEN
11482 print_debug('is_equipment_cap_exceeded 80 - equipment capacity not exceeded' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11483 END IF;
11484
11485 RETURN 'N';
11486 END IF;
11487 EXCEPTION
11488 WHEN OTHERS THEN
11489 IF SQLCODE IS NOT NULL THEN
11490 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.is_equipment_cap_exceeded', l_progress, SQLCODE);
11491 END IF;
11492
11493 IF (l_debug = 1) THEN
11494 print_debug('is_equipment_cap_exceeded: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11495 END IF;
11496
11497 RETURN 'N';
11498 END is_equipment_cap_exceeded;
11499
11500
11501 PROCEDURE consolidate_bulk_tasks(
11502 p_api_version IN NUMBER
11503 , p_commit IN VARCHAR2 := fnd_api.g_false
11504 , x_return_status OUT NOCOPY VARCHAR2
11505 , x_msg_count OUT NOCOPY NUMBER
11506 , x_msg_data OUT NOCOPY VARCHAR2
11507 , p_move_order_header_id IN NUMBER
11508 ) IS
11509 l_new_txn_temp_id NUMBER;
11510 l_last_update_date DATE;
11511 l_last_updated_by NUMBER;
11512 l_creation_date DATE;
11513 l_created_by NUMBER;
11514 l_inventory_item_id NUMBER;
11515 l_revision VARCHAR2(30);
11516 l_organization_id NUMBER;
11517 l_subinventory_code VARCHAR2(30);
11518 l_locator_id NUMBER;
11519 l_transaction_quantity NUMBER;
11520 l_primary_quantity NUMBER;
11521 l_sec_transaction_quantity NUMBER;
11522 l_transaction_uom VARCHAR2(3);
11523 l_transaction_type_id NUMBER;
11524 l_transaction_action_id NUMBER;
11525 l_transaction_source_type_id NUMBER;
11526 l_transaction_date DATE;
11527 l_acct_period_id NUMBER;
11528 l_pick_slip_number NUMBER;
11529 l_move_order_line_id NUMBER;
11530 l_to_org_id NUMBER;
11531 l_to_sub VARCHAR2(30);
11532 l_to_loc_id NUMBER;
11533 l_wms_task_type NUMBER;
11534 l_standard_operation_id NUMBER;
11535 l_task_priority NUMBER;
11536 l_cost_group_id NUMBER;
11537 l_transaction_header_id NUMBER;
11538 l_container_item_id NUMBER;
11539 l_cartonization_id NUMBER;
11540 l_operation_plan_id NUMBER;
11541 l_carton_grouping_id NUMBER;
11542 l_wms_task_status NUMBER;
11543
11544 l_parent_task_count NUMBER := 0;
11545 l_move_order_type NUMBER;
11546 l_api_name VARCHAR2(30) := 'consolidate_bulk_tasks';
11547 l_primary_uom_code VARCHAR2(3);
11548 l_sec_uom_code VARCHAR2(3);
11549 l_lot_control_code NUMBER;
11550 l_serial_control_code NUMBER;
11551 l_serial_allocated_flag VARCHAR2(1);
11552
11553 CURSOR task_list IS
11554 SELECT SYSDATE last_update_date
11555 , g_user_id last_updated_by
11556 , SYSDATE creation_date
11557 , g_user_id created_by
11558 , mmtt.inventory_item_id
11559 , mmtt.revision
11560 , mmtt.organization_id
11561 , mmtt.subinventory_code
11562 , mmtt.locator_id
11563 , SUM(mmtt.transaction_quantity)
11564 , SUM(mmtt.primary_quantity)
11565 , SUM(mmtt.secondary_transaction_quantity)
11566 , mmtt.transaction_uom
11567 , mmtt.transaction_type_id
11568 , mmtt.transaction_action_id
11569 , mmtt.transaction_source_type_id
11570 , MAX(mmtt.transaction_date)
11571 , MAX(mmtt.acct_period_id)
11572 , MIN(mmtt.pick_slip_number) -- the earliest created pick slip
11573 , MIN(mmtt.move_order_line_id) -- any line_id within this header
11574 , mmtt.transfer_organization
11575 , mmtt.transfer_subinventory
11576 , mmtt.transfer_to_location
11577 , mmtt.wms_task_type
11578 , mmtt.standard_operation_id
11579 , MAX(mmtt.task_priority)
11580 , mmtt.cost_group_id
11581 , MAX(mmtt.transaction_header_id)
11582 , mmtt.container_item_id
11583 , mmtt.cartonization_id
11584 , mmtt.operation_plan_id
11585 , mol.carton_grouping_id
11586 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11587 -- Bug 4584538
11588 , mmtt.item_primary_uom_code
11589 , mmtt.secondary_uom_code
11590 , mmtt.item_lot_control_code
11591 , mmtt.item_serial_control_code
11592 , mmtt.serial_allocated_flag
11593 -- Bug 4584538
11594 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
11595 WHERE mmtt.move_order_line_id = mol.line_id
11596 AND mol.header_id = p_move_order_header_id
11597 AND mmtt.wms_task_type NOT IN(5, 6)
11598 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11599 AND( EXISTS(SELECT 1
11600 FROM mtl_txn_request_headers moh, wsh_pick_grouping_rules spg
11601 WHERE spg.pick_grouping_rule_id = moh.grouping_rule_id
11602 AND spg.pick_method = '4'
11603 AND moh.header_id = mol.header_id)
11604 OR EXISTS(SELECT 1
11605 FROM mtl_system_items msi
11606 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11607 AND msi.organization_id = mmtt.organization_id --8715667
11608 AND msi.bulk_picked_flag = 'Y')
11609 )
11610 AND EXISTS ( SELECT 1 -- Only Consolidate Tasks for Plain item
11611 FROM mtl_system_items msi2
11612 WHERE msi2.inventory_item_id = mmtt.inventory_item_id
11613 AND msi2.organization_id = mmtt.organization_id --8715667
11614 AND msi2.lot_control_code = 1
11615 AND(msi2.serial_number_control_code = 1
11616 OR msi2.serial_number_control_code = 6))
11617 GROUP BY mmtt.inventory_item_id
11618 , mmtt.revision
11619 , mmtt.organization_id
11620 , mmtt.subinventory_code
11621 , mmtt.locator_id
11622 , mmtt.transaction_uom
11623 , mmtt.transaction_type_id
11624 , mmtt.transaction_action_id
11625 , mmtt.transaction_source_type_id
11626 , mmtt.transfer_organization
11627 , mmtt.transfer_subinventory
11628 , mmtt.transfer_to_location
11629 , mmtt.wms_task_type
11630 , mmtt.standard_operation_id
11631 , mmtt.cost_group_id
11632 , mmtt.container_item_id
11633 , mmtt.cartonization_id
11634 , mmtt.operation_plan_id
11635 , mol.carton_grouping_id -- only consolidate tasks with the same carton_grouping_id (hense delivery)
11636 , mmtt.wms_task_status
11637 -- Bug 4584538
11638 , mmtt.item_primary_uom_code
11639 , mmtt.secondary_uom_code
11640 , mmtt.item_lot_control_code
11641 , mmtt.item_serial_control_code
11642 , mmtt.serial_allocated_flag
11643 -- Bug 4584538
11644 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11645 AND 'Y' <> is_equipment_cap_exceeded(
11646 mmtt.standard_operation_id
11647 , mmtt.inventory_item_id
11648 , mmtt.organization_id
11649 , SUM(mmtt.transaction_quantity)
11650 , mmtt.transaction_uom
11651 ); -- make sure the consolidated quantity does not exceed minimum equipment capacity, this is to make sure a consolidated task will not be splitted later
11652
11653 CURSOR task_list_wip IS
11654 SELECT SYSDATE last_update_date
11655 , g_user_id last_updated_by
11656 , SYSDATE creation_date
11657 , g_user_id created_by
11658 , mmtt.inventory_item_id
11659 , mmtt.revision
11660 , mmtt.organization_id
11661 , mmtt.subinventory_code
11662 , mmtt.locator_id
11663 , SUM(mmtt.transaction_quantity)
11664 , SUM(mmtt.primary_quantity)
11665 , SUM(mmtt.secondary_transaction_quantity)
11666 , mmtt.transaction_uom
11667 , mmtt.transaction_type_id
11668 , mmtt.transaction_action_id
11669 , mmtt.transaction_source_type_id
11670 , MAX(mmtt.transaction_date)
11671 , MAX(mmtt.acct_period_id)
11672 , MIN(mmtt.pick_slip_number) -- the earliest created pick slip
11673 , MIN(mmtt.move_order_line_id) -- any line_id within this header
11674 , mmtt.transfer_organization
11675 , ''
11676 , NULL
11677 , mmtt.wms_task_type
11678 , mmtt.standard_operation_id
11679 , MAX(mmtt.task_priority)
11680 , mmtt.cost_group_id
11681 , MAX(mmtt.transaction_header_id)
11682 , mmtt.container_item_id
11683 , mmtt.cartonization_id
11684 , mmtt.operation_plan_id
11685 , NULL
11686 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11687 -- Bug 4584538
11688 , mmtt.item_primary_uom_code
11689 , mmtt.secondary_uom_code
11690 , mmtt.item_lot_control_code
11691 , mmtt.item_serial_control_code
11692 , mmtt.serial_allocated_flag
11693 -- Bug 4584538
11694 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
11695 WHERE mmtt.move_order_line_id = mol.line_id
11696 AND mol.header_id = p_move_order_header_id
11697 AND mmtt.wms_task_type NOT IN(5, 6)
11698 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11699 AND( EXISTS(SELECT 1
11700 FROM mtl_txn_request_headers moh, wsh_pick_grouping_rules spg
11701 WHERE spg.pick_grouping_rule_id = moh.grouping_rule_id
11702 AND spg.pick_method = '4'
11703 AND moh.header_id = mol.header_id)
11704 OR EXISTS(SELECT 1
11705 FROM mtl_system_items msi
11706 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11707 AND msi.organization_id = mmtt.organization_id --8715667
11708 AND msi.bulk_picked_flag = 'Y')
11709 )
11710 AND EXISTS( SELECT 1 -- Only Consolidate Tasks for Plain item
11711 FROM mtl_system_items msi2
11712 WHERE msi2.inventory_item_id = mmtt.inventory_item_id
11713 AND msi2.organization_id = mmtt.organization_id --8715667
11714 AND msi2.lot_control_code = 1
11715 AND(msi2.serial_number_control_code = 1
11716 OR msi2.serial_number_control_code = 6))
11717 GROUP BY mmtt.inventory_item_id
11718 , mmtt.revision
11719 , mmtt.organization_id
11720 , mmtt.subinventory_code
11721 , mmtt.locator_id
11722 , mmtt.transaction_uom
11723 , mmtt.transaction_type_id
11724 , mmtt.transaction_action_id
11725 , mmtt.transaction_source_type_id
11726 , mmtt.transfer_organization
11727 , mmtt.wms_task_type
11728 , mmtt.standard_operation_id
11729 , mmtt.cost_group_id
11730 , mmtt.container_item_id
11731 , mmtt.cartonization_id
11732 , mmtt.operation_plan_id
11733 , mmtt.wms_task_status
11734 -- Bug 4584538
11735 , mmtt.item_primary_uom_code
11736 , mmtt.secondary_uom_code
11737 , mmtt.item_lot_control_code
11738 , mmtt.item_serial_control_code
11739 , mmtt.serial_allocated_flag
11740 -- Bug 4584538
11741 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11742 AND 'Y' <> is_equipment_cap_exceeded(
11743 mmtt.standard_operation_id
11744 , mmtt.inventory_item_id
11745 , mmtt.organization_id
11746 , SUM(mmtt.transaction_quantity)
11747 , mmtt.transaction_uom
11748 ); -- make sure the consolidated quantity does not exceed minimum equipment capacity, this is to make sure a consolidated task will not be splitted later
11749
11750 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11751
11752 BEGIN
11753 IF (l_debug = 1) THEN
11754 print_debug('Consolidating Tasks for MO Header ID = ' || p_move_order_header_id, 4);
11755 END IF;
11756
11757 SAVEPOINT sp_consolidate_bulk_task;
11758
11759 x_return_status := fnd_api.g_ret_sts_success;
11760
11761 SELECT move_order_type
11762 INTO l_move_order_type
11763 FROM mtl_txn_request_headers
11764 WHERE header_id = p_move_order_header_id;
11765
11766 IF l_move_order_type = g_move_order_mfg_pick THEN
11767 OPEN task_list_wip;
11768 ELSE
11769 OPEN task_list;
11770 END IF;
11771
11772 LOOP
11773 IF l_move_order_type = g_move_order_mfg_pick THEN
11774 FETCH task_list_wip INTO l_last_update_date
11775 , l_last_updated_by
11776 , l_creation_date
11777 , l_created_by
11778 , l_inventory_item_id
11779 , l_revision
11780 , l_organization_id
11781 , l_subinventory_code
11782 , l_locator_id
11783 , l_transaction_quantity
11784 , l_primary_quantity
11785 , l_sec_transaction_quantity
11786 , l_transaction_uom
11787 , l_transaction_type_id
11788 , l_transaction_action_id
11789 , l_transaction_source_type_id
11790 , l_transaction_date
11791 , l_acct_period_id
11792 , l_pick_slip_number
11793 , l_move_order_line_id
11794 , l_to_org_id
11795 , l_to_sub
11796 , l_to_loc_id
11797 , l_wms_task_type
11798 , l_standard_operation_id
11799 , l_task_priority
11800 , l_cost_group_id
11801 , l_transaction_header_id
11802 , l_container_item_id
11803 , l_cartonization_id
11804 , l_operation_plan_id
11805 , l_carton_grouping_id
11806 , l_wms_task_status
11807 -- Bug 4584538
11808 , l_primary_uom_code
11809 , l_sec_uom_code
11810 , l_lot_control_code
11811 , l_serial_control_code
11812 , l_serial_allocated_flag;
11813 -- Bug 4584538
11814 EXIT WHEN task_list_wip%NOTFOUND;
11815 ELSE
11816 FETCH task_list INTO l_last_update_date
11817 , l_last_updated_by
11818 , l_creation_date
11819 , l_created_by
11820 , l_inventory_item_id
11821 , l_revision
11822 , l_organization_id
11823 , l_subinventory_code
11824 , l_locator_id
11825 , l_transaction_quantity
11826 , l_primary_quantity
11827 , l_sec_transaction_quantity
11828 , l_transaction_uom
11829 , l_transaction_type_id
11830 , l_transaction_action_id
11831 , l_transaction_source_type_id
11832 , l_transaction_date
11833 , l_acct_period_id
11834 , l_pick_slip_number
11835 , l_move_order_line_id
11836 , l_to_org_id
11837 , l_to_sub
11838 , l_to_loc_id
11839 , l_wms_task_type
11840 , l_standard_operation_id
11841 , l_task_priority
11842 , l_cost_group_id
11843 , l_transaction_header_id
11844 , l_container_item_id
11845 , l_cartonization_id
11846 , l_operation_plan_id
11847 , l_carton_grouping_id
11848 , l_wms_task_status
11849 -- Bug 4584538
11850 , l_primary_uom_code
11851 , l_sec_uom_code
11852 , l_lot_control_code
11853 , l_serial_control_code
11854 , l_serial_allocated_flag;
11855 -- Bug 4584538
11856 EXIT WHEN task_list%NOTFOUND;
11857 END IF;
11858
11859 l_parent_task_count := l_parent_task_count + 1;
11860 --SELECT mtl_material_transactions_s.NEXTVAL INTO l_new_txn_temp_id FROM DUAL;
11861
11862 IF (l_debug = 1) THEN
11863 print_debug('Creating a Parent Line with the values...', 4);
11864 print_debug(' --> Txn Header ID => ' || l_transaction_header_id, 4);
11865 -- print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
11866 print_debug(' --> Inventory Item ID => ' || l_inventory_item_id, 4);
11867 print_debug(' --> Revision => ' || l_revision, 4);
11868 print_debug(' --> Organization ID => ' || l_organization_id, 4);
11869 print_debug(' --> SubInventory Code => ' || l_subinventory_code, 4);
11870 print_debug(' --> Locator ID => ' || l_locator_id, 4);
11871 print_debug(' --> To Organization ID => ' || l_to_org_id, 4);
11872 print_debug(' --> To SubInventory => ' || l_to_sub, 4);
11873 print_debug(' --> To Locator ID => ' || l_to_loc_id, 4);
11874 print_debug(' --> Transaction Qty => ' || l_transaction_quantity, 4);
11875 print_debug(' --> Primary Qty => ' || l_primary_quantity, 4);
11876 print_debug(' --> Transaction UOM => ' || l_transaction_uom, 4);
11877 print_debug(' --> Txn Type ID => ' || l_transaction_type_id, 4);
11878 print_debug(' --> Txn Action ID => ' || l_transaction_action_id, 4);
11879 print_debug(' --> Txn Source Type ID => ' || l_transaction_source_type_id, 4);
11880 print_debug(' --> Txn Date => ' || l_transaction_date, 4);
11881 print_debug(' --> Account Period => ' || l_acct_period_id, 4);
11882 print_debug(' --> Pick Slip Number => ' || l_pick_slip_number, 4);
11883 print_debug(' --> Move Order Line ID => ' || l_move_order_line_id, 4);
11884 print_debug(' --> Cost Group ID => ' || l_cost_group_id, 4);
11885 print_debug(' --> Container Item ID => ' || l_container_item_id, 4);
11886 print_debug(' --> Cartonization ID => ' || l_cartonization_id, 4);
11887 print_debug(' --> Operation Plan Id => ' || l_operation_plan_id, 4);
11888 print_debug(' --> Carton Grouping ID => ' || l_carton_grouping_id, 4);
11889 print_debug(' --> Task Status => ' || l_wms_task_status, 4);
11890 print_debug(' --> Primary UOM Code => ' || l_primary_uom_code, 4);
11891 print_debug(' --> Lot Control Code => ' || l_lot_control_code, 4);
11892 print_debug(' --> Serial Control Code => ' || l_serial_control_code, 4);
11893 print_debug(' --> Serial Allocated Flag => ' || l_serial_allocated_flag, 4);
11894 END IF;
11895
11896 INSERT INTO wms_cartonization_temp
11897 (
11898 transaction_header_id
11899 , transaction_temp_id
11900 , posting_flag
11901 , transaction_status
11902 , last_update_date
11903 , last_updated_by
11904 , creation_date
11905 , created_by
11906 , transaction_type_id
11907 , transaction_action_id
11908 , transaction_source_type_id
11909 , organization_id
11910 , inventory_item_id
11911 , revision
11912 , subinventory_code
11913 , locator_id
11914 , transfer_organization
11915 , transfer_subinventory
11916 , transfer_to_location
11917 , transaction_quantity
11918 , primary_quantity
11919 , secondary_transaction_quantity
11920 , transaction_uom
11921 , transaction_date
11922 , acct_period_id
11923 , cost_group_id
11924 -- , move_order_line_id keep same as patchset J
11925 , pick_slip_number
11926 , standard_operation_id
11927 , wms_task_type
11928 , task_priority
11929 , container_item_id
11930 , cartonization_id
11931 , operation_plan_id
11932 , wms_task_status
11933 , parent_line_id
11934 -- Bug 4584538
11935 , item_primary_uom_code
11936 , secondary_uom_code
11937 , item_lot_control_code
11938 , item_serial_control_code
11939 , serial_allocated_flag
11940 -- Bug 4584538
11941 )
11942 VALUES (
11943 l_transaction_header_id
11944 --, l_new_txn_temp_id
11945 , mtl_material_transactions_s.NEXTVAL --Bug 5535030
11946 , 'N'
11947 , 2
11948 , l_last_update_date
11949 , l_last_updated_by
11950 , l_creation_date
11951 , l_created_by
11952 , l_transaction_type_id
11953 , l_transaction_action_id
11954 , l_transaction_source_type_id
11955 , l_organization_id
11956 , l_inventory_item_id
11957 , l_revision
11958 , l_subinventory_code
11959 , l_locator_id
11960 , l_to_org_id
11961 , l_to_sub
11962 , l_to_loc_id
11963 , l_transaction_quantity
11964 , l_primary_quantity
11965 , l_sec_transaction_quantity
11966 , l_transaction_uom
11967 , l_transaction_date
11968 , l_acct_period_id
11969 , l_cost_group_id
11970 -- , l_move_order_line_id keep same as patchset J
11971 , l_pick_slip_number
11972 , l_standard_operation_id
11973 , l_wms_task_type
11974 , l_task_priority
11975 , l_container_item_id
11976 , l_cartonization_id
11977 , l_operation_plan_id
11978 , l_wms_task_status
11979 -- , l_new_txn_temp_id -- have the same as patchset J
11980 , mtl_material_transactions_s.CURRVAL
11981 -- Bug 4584538
11982 , l_primary_uom_code
11983 , l_sec_uom_code
11984 , l_lot_control_code
11985 , l_serial_control_code
11986 , l_serial_allocated_flag
11987 -- Bug 4584538
11988 ) RETURNING transaction_temp_id INTO l_new_txn_temp_id ;
11989
11990 print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
11991 IF (l_debug = 1) THEN
11992 print_debug('Updating the Parent Line ID of the Tasks Consolidated', 4);
11993 END IF;
11994
11995 UPDATE wms_cartonization_temp
11996 SET parent_line_id = l_new_txn_temp_id
11997 WHERE transaction_temp_id <> l_new_txn_temp_id
11998 AND inventory_item_id = l_inventory_item_id
11999 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
12000 AND organization_id = l_organization_id
12001 AND subinventory_code = l_subinventory_code
12002 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
12003 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
12004 AND NVL(transfer_to_location, -1) = NVL(l_to_loc_id, NVL(transfer_to_location, -1))
12005 AND NVL(transfer_subinventory, '#$%') = NVL(l_to_sub, NVL(transfer_subinventory, '#$%'))
12006 AND transaction_uom = l_transaction_uom
12007 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
12008 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
12009 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
12010 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1))
12011 AND NVL(container_item_id, -1) = NVL(l_container_item_id, NVL(container_item_id, -1))
12012 AND NVL(cartonization_id, -1) = NVL(l_cartonization_id, NVL(cartonization_id, -1))
12013 AND EXISTS(SELECT 1
12014 FROM mtl_txn_request_lines mol
12015 WHERE mol.line_id = move_order_line_id
12016 AND mol.header_id = p_move_order_header_id
12017 AND NVL(mol.carton_grouping_id,-1) = NVL(l_carton_grouping_id,NVL(mol.carton_grouping_id,-1)));
12018
12019 IF (l_debug = 1) THEN
12020 print_debug('Number of Tasks consolidated into 1 Parent Task = ' || SQL%ROWCOUNT, 4);
12021 END IF;
12022 END LOOP;
12023
12024 IF task_list%ISOPEN THEN
12025 CLOSE task_list;
12026 END IF;
12027
12028 IF task_list_wip%ISOPEN THEN
12029 CLOSE task_list_wip;
12030 END IF;
12031
12032 IF (l_debug = 1) THEN
12033 print_debug('Number of Parent Tasks = ' || l_parent_task_count, 4);
12034 END IF;
12035 EXCEPTION
12036 WHEN OTHERS THEN
12037 x_return_status := fnd_api.g_ret_sts_unexp_error;
12038 ROLLBACK TO sp_consolidate_bulk_task;
12039 IF l_debug = 1 THEN
12040 print_debug('Exception Occurred = ' || SQLERRM,4);
12041 END IF;
12042
12043 IF task_list%ISOPEN THEN
12044 CLOSE task_list;
12045 END IF;
12046 IF task_list_wip%ISOPEN THEN
12047 CLOSE task_list_wip;
12048 END IF;
12049 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12050 END consolidate_bulk_tasks;
12051
12052
12053
12054 PROCEDURE consolidate_bulk_tasks_for_so(
12055 p_api_version IN NUMBER
12056 , p_commit IN VARCHAR2 := fnd_api.g_false
12057 , x_return_status OUT NOCOPY VARCHAR2
12058 , x_msg_count OUT NOCOPY NUMBER
12059 , x_msg_data OUT NOCOPY VARCHAR2
12060 , p_move_order_header_id IN NUMBER
12061 ) IS
12062 l_new_txn_temp_id NUMBER;
12063 l_last_update_date DATE;
12064 l_last_updated_by NUMBER;
12065 l_creation_date DATE;
12066 l_created_by NUMBER;
12067 l_inventory_item_id NUMBER;
12068 l_revision VARCHAR2(30);
12069 l_organization_id NUMBER;
12070 l_subinventory_code VARCHAR2(30);
12071 l_locator_id NUMBER;
12072 l_transaction_quantity NUMBER;
12073 l_primary_quantity NUMBER;
12074 l_sec_transaction_quantity NUMBER;
12075 l_transaction_uom VARCHAR2(3);
12076 l_transaction_type_id NUMBER;
12077 l_transaction_action_id NUMBER;
12078 l_transaction_source_type_id NUMBER;
12079 l_transaction_date DATE;
12080 l_acct_period_id NUMBER;
12081 l_pick_slip_number NUMBER;
12082 l_move_order_line_id NUMBER;
12083 l_to_org_id NUMBER;
12084 l_to_sub VARCHAR2(30);
12085 l_to_loc_id NUMBER;
12086 l_wms_task_type NUMBER;
12087 l_standard_operation_id NUMBER;
12088 l_task_priority NUMBER;
12089 l_cost_group_id NUMBER;
12090 l_transaction_header_id NUMBER;
12091 l_container_item_id NUMBER;
12092 l_cartonization_id NUMBER;
12093 l_operation_plan_id NUMBER;
12094 l_carton_grouping_id NUMBER;
12095 l_wms_task_status NUMBER;
12096
12097 l_parent_task_count NUMBER := 0;
12098 l_move_order_type NUMBER;
12099 l_api_name VARCHAR2(30) := 'consolidate_bulk_tasks_for_so';
12100 l_delivery_flag VARCHAR2(1);
12101 l_bulk_pick_control NUMBER;
12102
12103 -- *****************************
12104 -- the following cursor will be used when calling from pick release process for all items (plain, lot and lot/serial,serial...)
12105 -- task_list is to bulk the children within the delivery and task_list_cross_delivery is to bulk_task cross deliveries
12106 -- for performance purpose, two cursors are being defined here.
12107 --******************************
12108 CURSOR task_list IS
12109 SELECT SYSDATE last_update_date
12110 , g_user_id last_updated_by
12111 , SYSDATE creation_date
12112 , g_user_id created_by
12113 , mmtt.inventory_item_id
12114 , mmtt.revision
12115 , mmtt.organization_id
12116 , mmtt.subinventory_code
12117 , mmtt.locator_id
12118 , SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12119 , SUM(NVL(mtlt.primary_quantity, mmtt.primary_quantity)) primary_quantity -- Modified for 14699845 (Flexible lot allocation)
12120 , SUM(NVL(mtlt.secondary_quantity, mmtt.secondary_transaction_quantity)) secondary_transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12121 , mmtt.transaction_uom
12122 , mmtt.transaction_type_id
12123 , mmtt.transaction_action_id
12124 , mmtt.transaction_source_type_id
12125 , MAX(mmtt.transaction_date)
12126 , MAX(mmtt.acct_period_id)
12127 , mmtt.transfer_organization
12128 , mmtt.wms_task_type
12129 , MAX(mmtt.task_priority)
12130 , mmtt.cost_group_id
12131 , MAX(mmtt.transaction_header_id)
12132 , mmtt.container_item_id
12133 , mmtt.operation_plan_id
12134 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
12135 , nvl(wda.delivery_id, mol.carton_grouping_id)
12136 , mmtt.item_primary_uom_code
12137 , mmtt.secondary_uom_code
12138 , mmtt.item_lot_control_code
12139 , mmtt.item_serial_control_code
12140 , mmtt.serial_allocated_flag
12141 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') lot_allocated_flag -- Added for 14699845 (Flexible lot allocation)
12142 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
12143 , MTL_TRANSACTION_LOTS_TEMP mtlt -- Added for 14699845 (Flexible lot allocation)
12144 WHERE mmtt.move_order_line_id = mol.line_id
12145 -- AND mol.header_id = p_move_order_header_id -- no need since wct only have the records in concerns
12146 AND mol.line_id = wdd.move_ordeR_line_id
12147 AND wdd.delivery_detail_id = wda.delivery_detail_id
12148 AND mmtt.transaction_temp_id = mtlt.transaction_temp_id (+) -- Added for 14699845 (Flexible lot allocation)
12149 AND mmtt.wms_task_type NOT IN(5, 6)
12150 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
12151 AND mmtt.cartonization_id is null -- only bulk non_cartoned lines
12152 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
12153 or mmtt.serial_allocated_flag is null)
12154 AND NVL(mmtt.fulfillment_base,'P') = 'P'
12155 AND(l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_ENTIRE_WAVE
12156 -- if bulk picking is not disabled and not pick entire wave only the honor sub/item is left, so no need to check l_bulk_pick_control, only need to check the sub/item flag
12157 OR EXISTS(SELECT 1 -- sub is bulk picking enabled
12158 FROM mtl_secondary_inventories msi
12159 WHERE msi.secondary_inventory_name = mmtt.subinventory_code
12160 AND msi.organization_id = mmtt.organization_id
12161 AND msi.enable_bulk_pick= 'Y')
12162 OR EXISTS(SELECT 1 -- item is bulk picking enabled
12163 FROM mtl_system_items msi
12164 WHERE msi.inventory_item_id = mmtt.inventory_item_id
12165 AND msi.organization_id = mmtt.organization_id --8715667
12166 AND msi.bulk_picked_flag = 'Y')
12167 )
12168 GROUP BY mmtt.inventory_item_id
12169 , mmtt.revision
12170 , mmtt.organization_id
12171 , mmtt.subinventory_code
12172 , mmtt.locator_id
12173 , mmtt.transaction_uom
12174 , mmtt.transaction_type_id
12175 , mmtt.transaction_action_id
12176 , mmtt.transaction_source_type_id
12177 , mmtt.transfer_organization
12178 , mmtt.wms_task_type
12179 , mmtt.cost_group_id
12180 , mmtt.container_item_id
12181 , mmtt.operation_plan_id
12182 , nvl(wda.delivery_id, mol.carton_grouping_id) -- only consolidate tasks with the same carton_grouping_id (hense delivery) if the delivery is checked in the rule
12183 , mmtt.wms_task_status
12184 , mmtt.item_primary_uom_code
12185 , mmtt.secondary_uom_code
12186 , mmtt.item_lot_control_code
12187 , mmtt.item_serial_control_code
12188 , mmtt.serial_allocated_flag
12189 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') -- Added for 14699845 (Flexible lot allocation)
12190 HAVING SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) <> MIN(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) -- Modified for 14699845 (Flexible lot allocation) -- make sure one line will not get consolidated
12191 ;
12192
12193 CURSOR task_list_cross_delivery IS
12194 SELECT SYSDATE last_update_date
12195 , g_user_id last_updated_by
12196 , SYSDATE creation_date
12197 , g_user_id created_by
12198 , mmtt.inventory_item_id
12199 , mmtt.revision
12200 , mmtt.organization_id
12201 , mmtt.subinventory_code
12202 , mmtt.locator_id
12203 , SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12204 , SUM(NVL(mtlt.primary_quantity, mmtt.primary_quantity)) primary_quantity -- Modified for 14699845 (Flexible lot allocation)
12205 , SUM(NVL(mtlt.secondary_quantity, mmtt.secondary_transaction_quantity)) secondary_transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12206 , mmtt.transaction_uom
12207 , mmtt.transaction_type_id
12208 , mmtt.transaction_action_id
12209 , mmtt.transaction_source_type_id
12210 , MAX(mmtt.transaction_date)
12211 , MAX(mmtt.acct_period_id)
12212 , mmtt.transfer_organization
12213 , mmtt.wms_task_type
12214 , MAX(mmtt.task_priority)
12215 , mmtt.cost_group_id
12216 , MAX(mmtt.transaction_header_id)
12217 , mmtt.container_item_id
12218 , mmtt.operation_plan_id
12219 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
12220 , mmtt.item_primary_uom_code
12221 , mmtt.secondary_uom_code
12222 , mmtt.item_lot_control_code
12223 , mmtt.item_serial_control_code
12224 , mmtt.serial_allocated_flag
12225 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') lot_allocated_flag -- Added for 14699845 (Flexible lot allocation)
12226 FROM wms_cartonization_temp mmtt
12227 , MTL_TRANSACTION_LOTS_TEMP mtlt -- Added for 14699845 (Flexible lot allocation)
12228 WHERE
12229 mmtt.wms_task_type NOT IN(5, 6)
12230 AND mmtt.transaction_temp_id = mtlt.transaction_temp_id (+) -- Added for 14699845 (Flexible lot allocation)
12231 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
12232 AND mmtt.cartonization_id is null -- only bulk non_cartoned lines
12233 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
12234 or mmtt.serial_allocated_flag is null)
12235 AND NVL(mmtt.fulfillment_base,'P') = 'P'
12236 AND(l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_ENTIRE_WAVE
12237 -- if bulk picking is not disabled and not pick entire wave only the honor sub/item is left, so no need to check l_bulk_pick_control, only need to check the sub/item flag
12238 OR EXISTS(SELECT 1 -- sub is bulk picking enabled
12239 FROM mtl_secondary_inventories msi
12240 WHERE msi.secondary_inventory_name = mmtt.subinventory_code
12241 AND msi.organization_id = mmtt.organization_id
12242 AND msi.enable_bulk_pick= 'Y')
12243 OR EXISTS(SELECT 1 -- item is bulk picking enabled
12244 FROM mtl_system_items msi
12245 WHERE msi.inventory_item_id = mmtt.inventory_item_id
12246 AND msi.organization_id = mmtt.organization_id --8715667
12247 AND msi.bulk_picked_flag = 'Y')
12248 )
12249 GROUP BY mmtt.inventory_item_id
12250 , mmtt.revision
12251 , mmtt.organization_id
12252 , mmtt.subinventory_code
12253 , mmtt.locator_id
12254 , mmtt.transaction_uom
12255 , mmtt.transaction_type_id
12256 , mmtt.transaction_action_id
12257 , mmtt.transaction_source_type_id
12258 , mmtt.transfer_organization
12259 , mmtt.wms_task_type
12260 , mmtt.cost_group_id
12261 , mmtt.container_item_id
12262 , mmtt.operation_plan_id
12263 , mmtt.wms_task_status
12264 , mmtt.item_primary_uom_code
12265 , mmtt.secondary_uom_code
12266 , mmtt.item_lot_control_code
12267 , mmtt.item_serial_control_code
12268 , mmtt.serial_allocated_flag
12269 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') -- Added for 14699845 (Flexible lot allocation)
12270 HAVING SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) <> MIN(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)); -- Modified for 14699845 (Flexible lot allocation) -- make sure one line will not get consolidated
12271
12272
12273 -- *****************************
12274 -- the following cursor will be used when calling from concurrent program for bulking
12275 -- task_list_con to bulk within delivery and task_list_con_cd to cross deliveries
12276 --******************************
12277 CURSOR task_list_con IS
12278 SELECT SYSDATE last_update_date
12279 , g_user_id last_updated_by
12280 , SYSDATE creation_date
12281 , g_user_id created_by
12282 , mmtt.inventory_item_id
12283 , mmtt.revision
12284 , mmtt.organization_id
12285 , mmtt.subinventory_code
12286 , mmtt.locator_id
12287 , SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12288 , SUM(NVL(mtlt.primary_quantity, mmtt.primary_quantity)) primary_quantity -- Modified for 14699845 (Flexible lot allocation)
12289 , SUM(NVL(mtlt.secondary_quantity, mmtt.secondary_transaction_quantity)) secondary_transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12290 , mmtt.transaction_uom
12291 , mmtt.transaction_type_id
12292 , mmtt.transaction_action_id
12293 , mmtt.transaction_source_type_id
12294 , MAX(mmtt.transaction_date)
12295 , MAX(mmtt.acct_period_id)
12296 , mmtt.transfer_organization
12297 , mmtt.wms_task_type
12298 , MAX(mmtt.task_priority)
12299 , mmtt.cost_group_id
12300 , MAX(mmtt.transaction_header_id)
12301 , mmtt.container_item_id
12302 , mmtt.operation_plan_id
12303 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
12304 , nvl(wda.delivery_id, mol.carton_grouping_id)
12305 , mmtt.item_primary_uom_code
12306 , mmtt.secondary_uom_code
12307 , mmtt.item_lot_control_code
12308 , mmtt.item_serial_control_code
12309 , mmtt.serial_allocated_flag
12310 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') lot_allocated_flag -- Added for 14699845 (Flexible lot allocation)
12311 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol,
12312 wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
12313 , MTL_TRANSACTION_LOTS_TEMP mtlt -- Added for 14699845 (Flexible lot allocation)
12314 WHERE mmtt.move_order_line_id = mol.line_id
12315 AND mmtt.transaction_temp_id = mtlt.transaction_temp_id (+) -- Added for 14699845 (Flexible lot allocation)
12316 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
12317 or mmtt.serial_allocated_flag is null)
12318 AND NVL(mmtt.fulfillment_base,'P') = 'P'
12319 AND mol.line_id = wdd.move_ordeR_line_id
12320 AND wdd.delivery_Detail_id = wda.delivery_detail_id
12321 GROUP BY mmtt.inventory_item_id
12322 , mmtt.revision
12323 , mmtt.organization_id
12324 , mmtt.subinventory_code
12325 , mmtt.locator_id
12326 , mmtt.transaction_uom
12327 , mmtt.transaction_type_id
12328 , mmtt.transaction_action_id
12329 , mmtt.transaction_source_type_id
12330 , mmtt.transfer_organization
12331 , mmtt.wms_task_type
12332 , mmtt.cost_group_id
12333 , mmtt.container_item_id
12334 , mmtt.operation_plan_id
12335 , nvl(wda.delivery_id, mol.carton_grouping_id) -- only consolidate tasks with the same carton_grouping_id (hense delivery) if the delivery is checked in the rule
12336 , mmtt.wms_task_status
12337 , mmtt.item_primary_uom_code
12338 , mmtt.secondary_uom_code
12339 , mmtt.item_lot_control_code
12340 , mmtt.item_serial_control_code
12341 , mmtt.serial_allocated_flag
12342 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') -- Added for 14699845 (Flexible lot allocation)
12343 HAVING SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) <> MIN(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)); -- Modified for 14699845 (Flexible lot allocation) -- make sure one line will not get consolidated
12344
12345
12346 CURSOR task_list_con_cd IS
12347 SELECT SYSDATE last_update_date
12348 , g_user_id last_updated_by
12349 , SYSDATE creation_date
12350 , g_user_id created_by
12351 , mmtt.inventory_item_id
12352 , mmtt.revision
12353 , mmtt.organization_id
12354 , mmtt.subinventory_code
12355 , mmtt.locator_id
12356 , SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12357 , SUM(NVL(mtlt.primary_quantity, mmtt.primary_quantity)) primary_quantity -- Modified for 14699845 (Flexible lot allocation)
12358 , SUM(NVL(mtlt.secondary_quantity, mmtt.secondary_transaction_quantity)) secondary_transaction_quantity -- Modified for 14699845 (Flexible lot allocation)
12359 , mmtt.transaction_uom
12360 , mmtt.transaction_type_id
12361 , mmtt.transaction_action_id
12362 , mmtt.transaction_source_type_id
12363 , MAX(mmtt.transaction_date)
12364 , MAX(mmtt.acct_period_id)
12365 , mmtt.transfer_organization
12366 , mmtt.wms_task_type
12367 , MAX(mmtt.task_priority)
12368 , mmtt.cost_group_id
12369 , MAX(mmtt.transaction_header_id)
12370 , mmtt.container_item_id
12371 , mmtt.operation_plan_id
12372 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
12373 , mmtt.item_primary_uom_code
12374 , mmtt.secondary_uom_code
12375 , mmtt.item_lot_control_code
12376 , mmtt.item_serial_control_code
12377 , mmtt.serial_allocated_flag
12378 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') lot_allocated_flag -- Added for 14699845 (Flexible lot allocation)
12379 FROM wms_cartonization_temp mmtt
12380 , MTL_TRANSACTION_LOTS_TEMP mtlt -- Added for 14699845 (Flexible lot allocation)
12381 WHERE (mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
12382 or mmtt.serial_allocated_flag is null )
12383 AND NVL(mmtt.fulfillment_base,'P') = 'P'
12384 AND mmtt.transaction_temp_id = mtlt.transaction_temp_id (+) -- Added for 14699845 (Flexible lot allocation)
12385 GROUP BY mmtt.inventory_item_id
12386 , mmtt.revision
12387 , mmtt.organization_id
12388 , mmtt.subinventory_code
12389 , mmtt.locator_id
12390 , mmtt.transaction_uom
12391 , mmtt.transaction_type_id
12392 , mmtt.transaction_action_id
12393 , mmtt.transaction_source_type_id
12394 , mmtt.transfer_organization
12395 , mmtt.wms_task_type
12396 , mmtt.cost_group_id
12397 , mmtt.container_item_id
12398 , mmtt.operation_plan_id
12399 , mmtt.wms_task_status
12400 , mmtt.item_primary_uom_code
12401 , mmtt.secondary_uom_code
12402 , mmtt.item_lot_control_code
12403 , mmtt.item_serial_control_code
12404 , mmtt.serial_allocated_flag
12405 , Decode(Nvl(mmtt.lot_number, mtlt.LOT_NUMBER), NULL, 'N', 'Y') -- Added for 14699845 (Flexible lot allocation)
12406 HAVING SUM(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)) <> MIN(NVL(mtlt.transaction_quantity, mmtt.transaction_quantity)); -- Modified for 14699845 (Flexible lot allocation) -- make sure one line will not get consolidated
12407
12408
12409 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
12410 l_primary_uom_code VARCHAR2(3);
12411 l_sec_uom_code VARCHAR2(3);
12412 l_lot_control_code NUMBER;
12413 l_serial_control_code NUMBER;
12414 l_serial_allocated_flag VARCHAR2(1);
12415 l_total_child_count NUMBER := 0;
12416 l_lot_allocated_flag VARCHAR2(1); -- Added for 14699845 (Flexible lot allocation)
12417
12418 BEGIN
12419 IF (l_debug = 1) THEN
12420 print_debug('START CREATING BULK TASKS....',4);
12421 print_debug('Consolidating Tasks for MO Header ID = ' || p_move_order_header_id, 4);
12422 END IF;
12423
12424 SAVEPOINT sp_consolidate_bulk_task;
12425
12426
12427 x_return_status := fnd_api.g_ret_sts_success;
12428
12429 -- check if the delivery is checked in the bulk picking rule-------------
12430 IF p_move_order_header_id <> -1 THEN
12431
12432 -- cache the move order header info first
12433 If NOT INV_CACHE.set_mtrh_rec(p_move_order_header_id) THEN
12434 Raise g_exc_unexpected_error;
12435 END IF;
12436
12437 IF p_move_order_header_id = g_move_order_header_id THEN
12438 l_delivery_flag := g_delivery_flag;
12439 l_bulk_pick_control := g_bulk_pick_control;
12440 --Modified for bug#9381968
12441 IF (l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_DISABLED ) THEN
12442 IF (l_debug = 1) THEN
12443 print_debug('Consolidating Tasks are not bulk picking enabled',4);
12444 END IF;
12445 return;
12446 END IF;
12447
12448 ELSE
12449 IF (l_debug = 1) THEN
12450 print_debug('checking the delivery flag.',4);
12451 END IF;
12452
12453 Select DELIVERY_FLAG
12454 Into l_delivery_flag
12455 From WSH_PICK_GROUPING_RULES
12456 Where pick_method=WMS_GLOBALS.PICK_METHOD_BULK
12457 and user_defined_flag = 'N' -- bulk picking default rule
12458 and rownum <2; -- in case of psudo translation, multiple records are inserted for the seeded rule
12459
12460 -- check to see if the picking methodology is bulk picking disabled (including order picking)---
12461 SELECT spg.bulk_pick_control
12462 into l_bulk_pick_control
12463 FROM wsh_pick_grouping_rules spg
12464 WHERE spg.pick_grouping_rule_id = INV_CACHE.mtrh_rec.grouping_rule_id;
12465
12466 g_move_order_header_id := p_move_order_header_id;
12467 g_delivery_flag := l_delivery_flag;
12468 g_bulk_pick_control := l_bulk_pick_control;
12469
12470 IF l_bulk_pick_control is null THEN
12471 l_bulk_pick_control := WMS_GLOBALS.BULK_PICK_SUB_ITEM;
12472 ELSE
12473 IF (l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_DISABLED ) THEN
12474 IF (l_debug = 1) THEN
12475 print_debug('Consolidating Tasks are not bulk picking enabled',4);
12476 END IF;
12477 return;
12478 END IF;
12479 END IF;
12480
12481 l_move_order_type := INV_CACHE.mtrh_rec.move_order_type;
12482
12483 IF l_move_order_type <> g_move_order_pick_wave THEN
12484 IF (l_debug = 1) THEN
12485 print_debug('Consolidating Tasks are not pick wave mo',4);
12486 END IF;
12487 RAISE g_exc_unexpected_error;
12488 END IF;
12489 END IF;
12490 ELSE -- calling from the concurrent program, always query
12491 Select DELIVERY_FLAG
12492 Into l_delivery_flag
12493 From WSH_PICK_GROUPING_RULES
12494 Where pick_method=WMS_GLOBALS.PICK_METHOD_BULK
12495 and user_defined_flag = 'N' -- default rule
12496 and rownum <2; -- in case of psudo translation, multiple records are inserted for the seeded rule
12497 END IF;
12498
12499 IF (l_debug = 1) THEN
12500 print_debug('Delivery flag for bulk picking is '||l_delivery_flag,4);
12501 print_debug('Consolidating Tasks, bulk task control '||l_bulk_pick_control,4);
12502 END IF;
12503 /* Bug No.9549752 - Added the following condition (p_move_order_header_id = -1 and g_bulk_pick_control is NULL) */
12504 IF (g_bulk_pick_control <> WMS_GLOBALS.BULK_PICK_DISABLED) or
12505 (p_move_order_header_id = -1 and g_bulk_pick_control is NULL ) THEN -- Bug 7005328
12506
12507 -- open the non serial controlled items cursor -----------------------
12508 if p_move_order_header_id <> -1 then
12509 if l_delivery_flag = 'Y'then
12510 OPEN task_list;
12511 else OPEN task_list_cross_delivery;
12512 end if;
12513 else
12514 if l_delivery_flag = 'Y'then
12515 OPEN task_list_con;
12516 else OPEN task_list_con_cd;
12517 end if;
12518 end if;
12519
12520 LOOP
12521 if p_move_order_header_id <> -1 then
12522 IF l_delivery_flag = 'Y'THEN
12523 FETCH task_list INTO l_last_update_date
12524 , l_last_updated_by
12525 , l_creation_date
12526 , l_created_by
12527 , l_inventory_item_id
12528 , l_revision
12529 , l_organization_id
12530 , l_subinventory_code
12531 , l_locator_id
12532 , l_transaction_quantity
12533 , l_primary_quantity
12534 , l_sec_transaction_quantity
12535 , l_transaction_uom
12536 , l_transaction_type_id
12537 , l_transaction_action_id
12538 , l_transaction_source_type_id
12539 , l_transaction_date
12540 , l_acct_period_id
12541 , l_to_org_id
12542 , l_wms_task_type
12543 , l_task_priority
12544 , l_cost_group_id
12545 , l_transaction_header_id
12546 , l_container_item_id
12547 , l_operation_plan_id
12548 , l_wms_task_status
12549 , l_carton_grouping_id
12550 , l_primary_uom_code
12551 , l_sec_uom_code
12552 , l_lot_control_code
12553 , l_serial_control_code
12554 , l_serial_allocated_flag
12555 , l_lot_allocated_flag; -- Added for 14699845 (Flexible lot allocation)
12556 EXIT WHEN task_list%NOTFOUND;
12557 ELSE
12558 FETCH task_list_cross_delivery INTO l_last_update_date
12559 , l_last_updated_by
12560 , l_creation_date
12561 , l_created_by
12562 , l_inventory_item_id
12563 , l_revision
12564 , l_organization_id
12565 , l_subinventory_code
12566 , l_locator_id
12567 , l_transaction_quantity
12568 , l_primary_quantity
12569 , l_sec_transaction_quantity
12570 , l_transaction_uom
12571 , l_transaction_type_id
12572 , l_transaction_action_id
12573 , l_transaction_source_type_id
12574 , l_transaction_date
12575 , l_acct_period_id
12576 , l_to_org_id
12577 , l_wms_task_type
12578 , l_task_priority
12579 , l_cost_group_id
12580 , l_transaction_header_id
12581 , l_container_item_id
12582 , l_operation_plan_id
12583 , l_wms_task_status
12584 , l_primary_uom_code
12585 , l_sec_uom_code
12586 , l_lot_control_code
12587 , l_serial_control_code
12588 , l_serial_allocated_flag
12589 , l_lot_allocated_flag; -- Added for 14699845 (Flexible lot allocation)
12590 EXIT WHEN task_list_cross_delivery%NOTFOUND;
12591 END IF;
12592 else
12593 IF l_delivery_flag = 'Y'THEN
12594 FETCH task_list_con INTO l_last_update_date
12595 , l_last_updated_by
12596 , l_creation_date
12597 , l_created_by
12598 , l_inventory_item_id
12599 , l_revision
12600 , l_organization_id
12601 , l_subinventory_code
12602 , l_locator_id
12603 , l_transaction_quantity
12604 , l_primary_quantity
12605 , l_sec_transaction_quantity
12606 , l_transaction_uom
12607 , l_transaction_type_id
12608 , l_transaction_action_id
12609 , l_transaction_source_type_id
12610 , l_transaction_date
12611 , l_acct_period_id
12612 , l_to_org_id
12613 , l_wms_task_type
12614 , l_task_priority
12615 , l_cost_group_id
12616 , l_transaction_header_id
12617 , l_container_item_id
12618 , l_operation_plan_id
12619 , l_wms_task_status
12620 , l_carton_grouping_id
12621 , l_primary_uom_code
12622 , l_sec_uom_code
12623 , l_lot_control_code
12624 , l_serial_control_code
12625 , l_serial_allocated_flag
12626 , l_lot_allocated_flag; -- Added for 14699845 (Flexible lot allocation)
12627 EXIT WHEN task_list_con%NOTFOUND;
12628 ELSE
12629 FETCH task_list_con_cd INTO l_last_update_date
12630 , l_last_updated_by
12631 , l_creation_date
12632 , l_created_by
12633 , l_inventory_item_id
12634 , l_revision
12635 , l_organization_id
12636 , l_subinventory_code
12637 , l_locator_id
12638 , l_transaction_quantity
12639 , l_primary_quantity
12640 , l_sec_transaction_quantity
12641 , l_transaction_uom
12642 , l_transaction_type_id
12643 , l_transaction_action_id
12644 , l_transaction_source_type_id
12645 , l_transaction_date
12646 , l_acct_period_id
12647 , l_to_org_id
12648 , l_wms_task_type
12649 , l_task_priority
12650 , l_cost_group_id
12651 , l_transaction_header_id
12652 , l_container_item_id
12653 , l_operation_plan_id
12654 , l_wms_task_status
12655 , l_primary_uom_code
12656 , l_sec_uom_code
12657 , l_lot_control_code
12658 , l_serial_control_code
12659 , l_serial_allocated_flag
12660 , l_lot_allocated_flag; -- Added for 14699845 (Flexible lot allocation)
12661 EXIT WHEN task_list_con_cd%NOTFOUND;
12662 END IF;
12663 end if;
12664
12665 l_parent_task_count := l_parent_task_count + 1;
12666 -- SELECT mtl_material_transactions_s.NEXTVAL INTO l_new_txn_temp_id FROM DUAL;
12667
12668 IF (l_debug = 1) THEN
12669 print_debug('Creating a Parent Line with the values...', 4);
12670 print_debug(' --> Txn Header ID => ' || l_transaction_header_id, 4);
12671 -- print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
12672 print_debug(' --> Inventory Item ID => ' || l_inventory_item_id, 4);
12673 print_debug(' --> Revision => ' || l_revision, 4);
12674 print_debug(' --> Organization ID => ' || l_organization_id, 4);
12675 print_debug(' --> SubInventory Code => ' || l_subinventory_code, 4);
12676 print_debug(' --> Locator ID => ' || l_locator_id, 4);
12677 print_debug(' --> To Organization ID => ' || l_to_org_id, 4);
12678
12679 print_debug(' --> Transaction Qty => ' || l_transaction_quantity, 4);
12680 print_debug(' --> Primary Qty => ' || l_primary_quantity, 4);
12681 print_debug(' --> Transaction UOM => ' || l_transaction_uom, 4);
12682 print_debug(' --> Txn Type ID => ' || l_transaction_type_id, 4);
12683 print_debug(' --> Txn Action ID => ' || l_transaction_action_id, 4);
12684 print_debug(' --> Txn Source Type ID => ' || l_transaction_source_type_id, 4);
12685 print_debug(' --> Txn Date => ' || l_transaction_date, 4);
12686 print_debug(' --> Account Period => ' || l_acct_period_id, 4);
12687 print_debug(' --> Cost Group ID => ' || l_cost_group_id, 4);
12688 print_debug(' --> Container Item ID => ' || l_container_item_id, 4);
12689 print_debug(' --> Operation Plan Id => ' || l_operation_plan_id, 4);
12690 print_debug(' --> Task Status => ' || l_wms_task_status, 4);
12691 print_debug(' --> Lot Allocated Flag => ' || l_lot_allocated_flag, 4); -- Added for 14699845 (Flexible lot allocation)
12692 END IF;
12693
12694 INSERT INTO wms_cartonization_temp
12695 (
12696 transaction_header_id
12697 , transaction_temp_id
12698 , posting_flag
12699 , transaction_status
12700 , last_update_date
12701 , last_updated_by
12702 , creation_date
12703 , created_by
12704 , transaction_type_id
12705 , transaction_action_id
12706 , transaction_source_type_id
12707 , organization_id
12708 , inventory_item_id
12709 , revision
12710 , subinventory_code
12711 , locator_id
12712 , transfer_organization
12713 , transaction_quantity
12714 , primary_quantity
12715 , secondary_transaction_quantity
12716 , transaction_uom
12717 , transaction_date
12718 , acct_period_id
12719 , cost_group_id
12720 , wms_task_type
12721 , task_priority
12722 , container_item_id
12723 , operation_plan_id
12724 , wms_task_status
12725 , parent_line_id
12726 , item_primary_uom_code
12727 , secondary_uom_code
12728 , item_lot_control_code
12729 , item_serial_control_code
12730 , serial_allocated_flag
12731 )
12732 VALUES (
12733 l_transaction_header_id
12734 --, l_new_txn_temp_id
12735 , mtl_material_transactions_s.NEXTVAL --Bug 5535030
12736 , 'N'
12737 , 2
12738 , l_last_update_date
12739 , l_last_updated_by
12740 , l_creation_date
12741 , l_created_by
12742 , l_transaction_type_id
12743 , l_transaction_action_id
12744 , l_transaction_source_type_id
12745 , l_organization_id
12746 , l_inventory_item_id
12747 , l_revision
12748 , l_subinventory_code
12749 , l_locator_id
12750 , l_to_org_id
12751 , l_transaction_quantity
12752 , l_primary_quantity
12753 , l_sec_transaction_quantity
12754 , l_transaction_uom
12755 , l_transaction_date
12756 , l_acct_period_id
12757 , l_cost_group_id
12758 , l_wms_task_type
12759 , l_task_priority
12760 , l_container_item_id
12761 , l_operation_plan_id
12762 , l_wms_task_status
12763 --, l_new_txn_temp_id
12764 , mtl_material_transactions_s.CURRVAL
12765 , l_primary_uom_code
12766 , l_sec_uom_code
12767 , l_lot_control_code
12768 , l_serial_control_code
12769 , l_serial_allocated_flag
12770 )RETURNING transaction_temp_id INTO l_new_txn_temp_id ;
12771
12772 print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
12773 IF (l_debug = 1) THEN
12774 print_debug('Updating the Parent Line ID of the Tasks Consolidated', 4);
12775 END IF;
12776
12777 IF l_delivery_flag = 'Y' THEN
12778 UPDATE wms_cartonization_temp wct
12779 SET parent_line_id = l_new_txn_temp_id
12780 WHERE transaction_temp_id <> l_new_txn_temp_id
12781 AND inventory_item_id = l_inventory_item_id
12782 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
12783 AND organization_id = l_organization_id
12784 AND subinventory_code = l_subinventory_code
12785 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
12786 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
12787 AND transaction_uom = l_transaction_uom
12788 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
12789 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
12790 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
12791 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1))
12792 -- Added for 14699845 (Flexible lot allocation)
12793 AND ((l_lot_allocated_flag = 'Y' AND EXISTS (SELECT 1 FROM MTL_TRANSACTION_LOTS_TEMP mtlt WHERE mtlt.transaction_temp_id=wct.transaction_temp_id))
12794 OR (l_lot_allocated_flag = 'N' AND NOT EXISTS (SELECT 1 FROM MTL_TRANSACTION_LOTS_TEMP mtlt WHERE mtlt.transaction_temp_id=wct.transaction_temp_id)))
12795 AND EXISTS(SELECT 1
12796 FROM mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
12797 WHERE mol.line_id = wct.move_order_line_id
12798 AND mol.line_id = wdd.move_ordeR_line_id
12799 AND wdd.delivery_detail_id = wda.delivery_detail_id
12800 AND NVL(wda.delivery_id,mol.carton_grouping_id) = l_carton_grouping_id)
12801 AND wct.transaction_temp_id NOT IN ( -- added for bug 9309619 Vpedarla
12802 SELECT transaction_temp_id
12803 FROM mtl_material_transactions_temp mmtt
12804 WHERE mmtt.transaction_temp_id = wct.transaction_temp_id
12805 AND mmtt.allocated_lpn_id IS NOT NULL)
12806 AND wct.cartonization_id is NULL;--added for bug 9446937
12807 ELSE
12808 UPDATE wms_cartonization_temp wct
12809 SET parent_line_id = l_new_txn_temp_id
12810 WHERE transaction_temp_id <> l_new_txn_temp_id
12811 AND inventory_item_id = l_inventory_item_id
12812 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
12813 AND organization_id = l_organization_id
12814 AND subinventory_code = l_subinventory_code
12815 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
12816 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
12817 AND transaction_uom = l_transaction_uom
12818 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
12819 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
12820 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
12821 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1))
12822 -- Added for 14699845 (Flexible lot allocation)
12823 AND ((l_lot_allocated_flag = 'Y' AND EXISTS (SELECT 1 FROM MTL_TRANSACTION_LOTS_TEMP mtlt WHERE mtlt.transaction_temp_id=wct.transaction_temp_id))
12824 OR (l_lot_allocated_flag = 'N' AND NOT EXISTS (SELECT 1 FROM MTL_TRANSACTION_LOTS_TEMP mtlt WHERE mtlt.transaction_temp_id=wct.transaction_temp_id)))
12825 AND transaction_temp_id NOT IN ( -- added for bug 9309619 Vpedarla
12826 SELECT transaction_temp_id
12827 FROM mtl_material_transactions_temp mmtt
12828 WHERE mmtt.transaction_temp_id = wct.transaction_temp_id -- Modified for 14699845 (Flexible lot allocation)
12829 AND mmtt.allocated_lpn_id IS NOT NULL)
12830 AND cartonization_id is NULL;--added for bug 9446937
12831
12832 END IF;
12833
12834
12835 IF (l_debug = 1) THEN
12836 print_debug('Number of Tasks consolidated into 1 Parent Task = ' || SQL%ROWCOUNT, 4);
12837 END IF;
12838 l_total_child_count := l_total_child_count + SQL%ROWCOUNT;
12839 END LOOP;
12840
12841 if p_move_order_header_id <> -1 then
12842 IF l_delivery_flag = 'Y' THEN
12843 CLOSE task_list;
12844 ELSE
12845 CLOSE task_list_cross_delivery;
12846 END IF;
12847 else
12848 IF l_delivery_flag = 'Y' THEN
12849 CLOSE task_list_con;
12850 ELSE
12851 CLOSE task_list_con_cd;
12852 END IF;
12853 end if;
12854
12855 IF (l_debug = 1) THEN
12856 print_debug('Number of Parent Tasks = ' || l_parent_task_count, 4);
12857 print_debug('Number of child lines processed = ' || l_total_child_count,4);
12858 END IF;
12859 END IF; -- Bug 7005328
12860
12861 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12862 EXCEPTION
12863 WHEN OTHERS THEN
12864 x_return_status := fnd_api.g_ret_sts_unexp_error;
12865 ROLLBACK TO sp_consolidate_bulk_task;
12866 IF l_debug = 1 THEN
12867 print_debug('Exception Occurred = ' || SQLERRM,4);
12868 END IF;
12869 IF task_list%ISOPEN THEN
12870 CLOSE task_list;
12871 END IF;
12872 IF task_list_con%ISOPEN THEN
12873 CLOSE task_list_con;
12874 END IF;
12875
12876
12877 IF task_list_cross_delivery%ISOPEN THEN
12878 CLOSE task_list_cross_Delivery;
12879 END IF;
12880 IF task_list_con_cd%ISOPEN THEN
12881 CLOSE task_list_con_cd;
12882 END IF;
12883
12884 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12885 END consolidate_bulk_tasks_for_so;
12886
12887 --------- patchset J bulk picking -----------------
12888 -- This procedure will be called inside the split_task API. It will be called after stamping the parent_line_id
12889 -- for all the child lines. ------
12890
12891 Procedure Duplicate_lot_serial_in_parent(
12892 p_parent_transaction_temp_id NUMBER
12893 , x_return_status OUT NOCOPY VARCHAR2
12894 , x_msg_count OUT NOCOPY NUMBER
12895 , x_msg_data OUT NOCOPY VARCHAR2) IS
12896
12897 l_serial_number_control_code NUMBER;
12898 l_lot_control_code NUMBER;
12899 l_mtlt_rec mtl_transaction_lots_temp%ROWTYPE;
12900 l_msnt_rec mtl_serial_numbers_temp%ROWTYPE;
12901 l_new_txn_temp_id NUMBER;
12902
12903
12904
12905 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
12906 BEGIN
12907 IF (l_debug = 1) THEN
12908 print_debug('Enter Duplicate_lot_serial_in_parent ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
12909 END IF;
12910
12911
12912 -- Initialize API return status to success
12913 x_return_status := fnd_api.g_ret_sts_success;
12914
12915 -- to get the serial control code
12916 select serial_number_control_code,lot_control_code
12917 into l_serial_number_control_code,l_lot_control_code
12918 from mtl_system_items_b msi,mtl_material_transactions_temp mmtt
12919 where mmtt.transaction_temp_id = p_parent_transaction_temp_id
12920 and mmtt.inventory_item_id = msi.inventory_item_id
12921 and mmtt.organization_id = msi.organization_id;
12922
12923 IF (l_debug = 1) THEN
12924 print_debug('lot control code:'||l_lot_control_code,4);
12925 print_debug('serial control code:'||l_serial_number_control_code,4);
12926 END IF;
12927
12928 IF (l_lot_control_code = 2) THEN
12929 -- insert the lot numbers for the parent line
12930 INSERT INTO mtl_transaction_lots_temp
12931 (transaction_temp_id
12932 , lot_number
12933 , transaction_quantity
12934 , primary_quantity
12935 , secondary_quantity -- 8310896
12936 , secondary_unit_of_measure -- 8310896
12937 , lot_expiration_date
12938 , last_update_date
12939 , last_updated_by
12940 , creation_date
12941 , created_by
12942 , serial_transaction_temp_id) -- always set to null since we don't bulk lines with allocated serial numbers
12943 (SELECT p_parent_transaction_temp_id, -- transaction_temp_id of parent line
12944 mtlt.lot_number,
12945 sum(mtlt.transaction_quantity) transaction_quantity,
12946 sum(mtlt.primary_quantity) primary_quantity
12947 ,Sum(mtlt.secondary_quantity) secondary_quantity --8310896
12948 ,mtlt.secondary_unit_of_measure --8310896
12949 ,mtlt.lot_expiration_date
12950 ,SYSDATE
12951 ,g_user_id
12952 ,SYSDATE
12953 ,g_user_id
12954 ,null
12955 FROM mtl_transaction_lots_temp mtlt,mtl_material_transactions_temp mmtt
12956 WHERE
12957 mtlt.transaction_temp_id = mmtt.transaction_temp_id
12958 and mmtt.parent_line_id = p_parent_transaction_temp_id -- child task
12959 and mmtt.transaction_temp_id <> p_parent_transaction_temp_id -- not parent task
12960 group by mtlt.lot_number,mtlt.lot_expiration_date,mtlt.secondary_unit_of_measure); --8310896
12961
12962
12963 END IF;
12964
12965
12966 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12967
12968 EXCEPTION
12969 WHEN OTHERS THEN
12970 x_return_status := fnd_api.g_ret_sts_unexp_error;
12971
12972 IF l_debug = 1 THEN
12973 print_debug('Exception Occurred = ' || SQLERRM,4);
12974 END IF;
12975
12976 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12977
12978 END Duplicate_lot_serial_in_parent;
12979
12980 ----- end of patchset J bulk picking ------------------------------------
12981
12982 PROCEDURE split_task(
12983 p_api_version NUMBER
12984 , p_task_id NUMBER
12985 , p_commit VARCHAR2 := fnd_api.g_false
12986 , x_return_status OUT NOCOPY VARCHAR2
12987 , x_msg_count OUT NOCOPY NUMBER
12988 , x_msg_data OUT NOCOPY VARCHAR2
12989 ) IS
12990 l_api_name VARCHAR2(20) := 'split_task';
12991 l_item_id NUMBER; -- item ID
12992 l_lot_control_code NUMBER;
12993 l_serial_number_control_code NUMBER;
12994 l_loc_uom_code VARCHAR2(3); -- locator uom code
12995 l_txn_uom_code VARCHAR2(3); -- transaction uom code
12996 l_item_prim_uom_code VARCHAR2(3); -- primary uom code
12997 l_item_sec_uom_code VARCHAR2(3); -- secondary uom code
12998 l_txn_pri_uom_ratio NUMBER; -- conversion rate between transaction uom and item primary UOM
12999 l_txn_sec_uom_ratio NUMBER; -- conversion rate between transaction uom and secondary uom
13000 l_ch_txn_sec_uom_ratio NUMBER; -- conversion rate between transaction uom and secondary uom FOR child tasks
13001 l_loc_txn_uom_ratio NUMBER; -- conversion rate between locator uom and transaction uom
13002 l_sec_trans_qty NUMBER;
13003 l_equip_vol NUMBER; -- equipment volume capacity
13004 l_equip_weight NUMBER; -- equipment weight capacity
13005 l_item_vol NUMBER; -- item unit volume
13006 l_item_weight NUMBER; -- item unit weight
13007 l_equip_v_uom VARCHAR2(3); -- equipment volume UOM
13008 l_equip_w_uom VARCHAR2(3); -- equipment weight UOM
13009 l_item_v_uom VARCHAR2(3); -- item unit volume UOM
13010 l_item_w_uom VARCHAR2(3); -- item unit weight UOM
13011 l_eq_it_v_uom_ratio NUMBER := 1; -- conversion rate between equipment volume capacity and item unit volume UOM
13012 l_eq_it_w_uom_ratio NUMBER := 1; -- conversion rate between equipment weight capacity and item weight UOM
13013 l_task_rec_old_wct wms_cartonization_temp%ROWTYPE;
13014 l_task_rec_new_wct wms_cartonization_temp%ROWTYPE;
13015 l_task_rec_old_mmtt mtl_material_transactions_temp%ROWTYPE;
13016 l_task_rec_new_mmtt mtl_material_transactions_temp%ROWTYPE;
13017 l_child_rec_new mtl_material_transactions_temp%ROWTYPE;
13018 l_lot_split_rec inv_rcv_common_apis.trans_rec_tb_tp;
13019 l_min_cap NUMBER := -1; -- minimum equipment capacity for a task
13020 l_min_cap_temp NUMBER;
13021 l_split_factor NUMBER; -- split task to this size
13022 l_init_qty NUMBER;
13023 l_new_qty NUMBER;
13024 l_counter NUMBER := 0;
13025 l_new_temp_id NUMBER;
13026 l_progress VARCHAR2(10);
13027 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
13028 l_msg_count NUMBER;
13029 l_msg_data VARCHAR2(400);
13030
13031 -- capacity cursur for all the equipments that is eligible for one task
13032 -- also the item weight and volumn for the task
13033 CURSOR l_capcity_cur IS
13034 SELECT equip.internal_volume equip_vol
13035 , -- equipment volume capacity
13036 equip.maximum_load_weight equip_weight
13037 , -- equipment weight capacity
13038 item.unit_volume item_vol
13039 , -- item unit volume
13040 item.unit_weight item_weight
13041 , -- item unit weight
13042 equip.volume_uom_code equip_v_uom
13043 , -- equipment volumn UOM code
13044 equip.weight_uom_code equip_w_uom
13045 , -- equipment weight UOM code
13046 item.volume_uom_code item_v_uom
13047 , -- item volume UOM code
13048 item.weight_uom_code item_w_uom -- item weight UOM code
13049 FROM mtl_system_items equip
13050 , mtl_system_items item
13051 , wms_cartonization_temp mmtt
13052 , bom_resource_equipments res_equip
13053 , bom_resources res
13054 , bom_std_op_resources tt_x_res
13055 WHERE mmtt.transaction_temp_id = p_task_id -- the task in question
13056 AND mmtt.standard_operation_id = tt_x_res.standard_operation_id --join task with task_type-resource x-ref
13057 AND tt_x_res.resource_id = res.resource_id -- join with resource
13058 AND res.resource_type = 1 -- resource type for equipment
13059 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
13060 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
13061 AND equip.organization_id = res_equip.organization_id
13062 AND item.inventory_item_id = mmtt.inventory_item_id -- join with item for the item that is transfered
13063 AND item.organization_id = mmtt.organization_id;
13064
13065
13066 ---------- patchset J bulk picking -----------------------
13067 -- capacity cursur for all the equipments that is eligible for one task
13068 -- also the item weight and volumn for the task
13069 -- this cursor is used for the new flows introduced by bulk picking
13070 CURSOR l_capcity_cur_bulk IS
13071 SELECT equip.internal_volume equip_vol
13072 , -- equipment volume capacity
13073 equip.maximum_load_weight equip_weight
13074 , -- equipment weight capacity
13075 item.unit_volume item_vol
13076 , -- item unit volume
13077 item.unit_weight item_weight
13078 , -- item unit weight
13079 equip.volume_uom_code equip_v_uom
13080 , -- equipment volumn UOM code
13081 equip.weight_uom_code equip_w_uom
13082 , -- equipment weight UOM code
13083 item.volume_uom_code item_v_uom
13084 , -- item volume UOM code
13085 item.weight_uom_code item_w_uom -- item weight UOM code
13086 FROM mtl_system_items equip
13087 , mtl_system_items item
13088 , mtl_material_transactions_temp mmtt
13089 , bom_resource_equipments res_equip
13090 , bom_resources res
13091 , bom_std_op_resources tt_x_res
13092 WHERE mmtt.transaction_temp_id = p_task_id -- the task in question
13093 AND mmtt.standard_operation_id = tt_x_res.standard_operation_id --join task with task_type-resource x-ref
13094 AND tt_x_res.resource_id = res.resource_id -- join with resource
13095 AND res.resource_type = 1 -- resource type for equipment
13096 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
13097 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
13098 AND equip.organization_id = res_equip.organization_id
13099 AND item.inventory_item_id = mmtt.inventory_item_id -- join with item for the item that is transfered
13100 AND item.organization_id = mmtt.organization_id;
13101
13102 -- A new cursor will be defined to find all the child tasks ordered by delivery
13103 Cursor c_child_tasks(p_parent_line_id NUMBER) is
13104 Select mmtt.transaction_temp_id,mmtt.transaction_quantity,mmtt.secondary_transaction_quantity,mmtt.primary_quantity
13105 From wms_cartonization_temp mmtt,mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,
13106 wsh_delivery_assignments_v wda
13107 WHERE mmtt.parent_line_id = p_parent_line_id
13108 And mol.line_id = mmtt.move_order_line_id
13109 and mol.line_id = wdd.move_order_line_id
13110 and wdd.delivery_detail_id = wda.delivery_detail_id
13111 and mmtt.transaction_temp_id <> p_parent_line_id
13112 Order by nvl(wda.delivery_id,mol.carton_grouping_id), mmtt.transaction_quantity DESC;
13113
13114 l_child_remaining_qty NUMBER := 0;
13115 l_child_temp_id NUMBER := 0;
13116 l_child_rec c_child_tasks%ROWTYPE;
13117 l_child_total_qty NUMBER := 0;
13118 l_new_child_temp_id NUMBER;
13119 l_new_child_qty NUMBER;
13120 l_move_order_type NUMBER;
13121 ---------- end of patchset J bulk picking -----------------------
13122
13123 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
13124 BEGIN
13125 IF (l_debug = 1) THEN
13126 print_debug('Enter split_task 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
13127 END IF;
13128
13129 l_progress := '10';
13130 SAVEPOINT sp_task_split;
13131 l_progress := '20';
13132 -- Initialize API return status to success
13133 x_return_status := fnd_api.g_ret_sts_success;
13134 -- query locator picking UOM code, if NULL use subinventory picking UOM code
13135 -- query transaction UOM code, and primary UOM code
13136 -- query transacted item ID
13137 -- Also query the transaction quantity
13138 -- changed for patchset J bulk picking -----------
13139 SELECT *
13140 INTO l_task_rec_old_wct
13141 FROM wms_cartonization_temp
13142 WHERE transaction_temp_id = p_task_id;
13143
13144 -- get the mmtt rec too, will be used later on, the reason why both wct and mmtt are here is for branching
13145 SELECT *
13146 INTO l_task_rec_old_mmtt
13147 FROM mtl_material_transactions_temp
13148 WHERE transaction_temp_id = p_task_id;
13149
13150 IF (l_task_rec_old_wct.parent_line_id is null) THEN -- not bulk task
13151 -- cache the move order header info first
13152 If NOT INV_CACHE.set_mtrh_rec(l_task_rec_old_wct.move_order_header_id) THEN
13153 Raise g_exc_unexpected_error;
13154 END IF;
13155 l_move_order_type := INV_CACHE.mtrh_rec.move_order_type;
13156 if (l_debug = 1) then print_debug('Move order type:'||l_move_order_type,4); end if;
13157 ELSE
13158 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
13159 l_move_order_type := G_MOVE_ORDER_PICK_WAVE; -- calling for parent task, WIP doesn't call this for patchset J
13160 if (l_debug = 1) then print_debug('calling for bulk task (parent task line ....',4);
13161 -- print_debug('PATCHSET J-- BULK PICKING --END', 4);
13162 end if;
13163 END IF;
13164
13165 -- end of change for patchset J bulk picking ------------------
13166
13167
13168
13169
13170 -- Use subinventory locator pick_uom_code OR sub pick_uom_code
13171 l_progress := '30';
13172
13173 SELECT NVL(mil.pick_uom_code, msi.pick_uom_code)
13174 , mmtt.transaction_uom
13175 , mmtt.inventory_item_id
13176 , mmtt.transaction_quantity
13177 , mmtt.secondary_transaction_quantity
13178 , item.primary_uom_code
13179 , item.lot_control_code
13180 , item.serial_number_control_code
13181 , item.secondary_uom_code
13182 INTO l_loc_uom_code
13183 , l_txn_uom_code
13184 , l_item_id
13185 , l_init_qty
13186 , l_sec_trans_qty
13187 , l_item_prim_uom_code
13188 , l_lot_control_code
13189 , l_serial_number_control_code
13190 , l_item_sec_uom_code
13191 FROM wms_cartonization_temp mmtt, mtl_item_locations mil, mtl_secondary_inventories msi, mtl_system_items item
13192 WHERE mmtt.transaction_temp_id = p_task_id
13193 AND mmtt.locator_id = mil.inventory_location_id(+)
13194 AND mmtt.organization_id = mil.organization_id(+)
13195 AND mmtt.subinventory_code = msi.secondary_inventory_name
13196 AND mmtt.organization_id = msi.organization_id
13197 AND mmtt.inventory_item_id = item.inventory_item_id
13198 AND mmtt.organization_id = item.organization_id;
13199
13200 l_progress := '40';
13201
13202 /* bug8197523. The ratio is calculated here and is used in calcualting secondary qty for parent tasks */
13203 IF (l_sec_trans_qty IS NOT NULL AND l_sec_trans_qty <> 0) THEN
13204 l_txn_sec_uom_ratio := (l_init_qty/l_sec_trans_qty);
13205 ELSE
13206 l_txn_sec_uom_ratio := 0;
13207 END IF;
13208
13209 IF (l_debug = 1) THEN
13210 print_debug('l_txn_sec_uom_ratio => ' || l_txn_sec_uom_ratio, 4);
13211 END IF;
13212
13213
13214
13215 IF (l_debug = 1) THEN
13216 print_debug('split_task 20 - quried following information' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13217 print_debug('l_loc_uom_code => ' || l_loc_uom_code, 4);
13218 print_debug('l_txn_uom_code => ' || l_txn_uom_code, 4);
13219 print_debug('l_item_id => ' || l_item_id, 4);
13220 print_debug('l_init_qty => ' || l_init_qty, 4);
13221 print_debug('l_item_prim_uom_code => ' || l_item_prim_uom_code, 4);
13222 print_debug('l_lot_control_code => ' || l_lot_control_code, 4);
13223 print_debug('l_serial_number_control_code => ' || l_serial_number_control_code, 4);
13224 END IF;
13225
13226 -- bug fix 2123018
13227 IF l_loc_uom_code IS NULL THEN
13228 IF (l_debug = 1) THEN
13229 print_debug('l_loc_uom_code is NULL, default it to l_txn_uom_code.', 4);
13230 END IF;
13231
13232 l_loc_uom_code := l_txn_uom_code;
13233 END IF;
13234
13235 IF l_loc_uom_code IS NULL
13236 OR l_txn_uom_code IS NULL
13237 OR l_item_id IS NULL
13238 OR l_init_qty IS NULL
13239 OR l_item_prim_uom_code IS NULL THEN
13240 IF (l_debug = 1) THEN
13241 print_debug('split_task 30 - necessary UOM information missing' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13242 END IF;
13243
13244 RAISE fnd_api.g_exc_unexpected_error;
13245 END IF;
13246
13247 -- call UOM conversion API to compute the ratio between
13248 -- locator UOM and transcation UOM for given item
13249 inv_convert.inv_um_conversion(from_unit => l_loc_uom_code, to_unit => l_txn_uom_code, item_id => l_item_id
13250 , uom_rate => l_loc_txn_uom_ratio);
13251
13252 IF l_loc_txn_uom_ratio = -99999 THEN -- uom conversion failure
13253 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
13254 fnd_msg_pub.ADD;
13255
13256 IF (l_debug = 1) THEN
13257 print_debug('split_task 40 - loc/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13258 END IF;
13259
13260 RAISE fnd_api.g_exc_error;
13261 END IF;
13262
13263 -- compute conversion rate between transaction UOM and item primary UOM
13264 inv_convert.inv_um_conversion(from_unit => l_txn_uom_code, to_unit => l_item_prim_uom_code, item_id => l_item_id
13265 , uom_rate => l_txn_pri_uom_ratio);
13266
13267 IF l_txn_pri_uom_ratio = -99999 THEN -- uom conversion failure
13268 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
13269 fnd_msg_pub.ADD;
13270
13271 IF (l_debug = 1) THEN
13272 print_debug('split_task 50 - txn/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13273 END IF;
13274
13275 RAISE fnd_api.g_exc_error;
13276 END IF;
13277
13278 IF (l_debug = 1) THEN
13279 print_debug('split_task 60 - UOM conversion data:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13280 END IF;
13281
13282 IF (l_debug = 1) THEN
13283 print_debug('l_loc_txn_uom_ratio => ' || l_loc_txn_uom_ratio, 4);
13284 print_debug('l_txn_pri_uom_ratio => ' || l_txn_pri_uom_ratio, 4);
13285 END IF;
13286
13287 -- Query minimum equipment capacity in terms of transaction UOM
13288 -- The minimum of the volumn and weight capacity is used
13289 -- If no equipment capacity or item unit volumn or weight defined,
13290 -- do not split
13291 -- NEED FURTHER consideration for container item:
13292 -- should check unit volume and content weight ???
13293
13294 l_progress := '50';
13295 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13296 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13297 IF (l_debug = 1) THEN print_debug('open l_capcity_cur_bulk',4); END IF;
13298 OPEN l_capcity_cur_bulk;
13299 ELSE
13300 IF (l_debug = 1) THEN print_debug('open l_capcity_cur',4); END IF;
13301 OPEN l_capcity_cur;
13302 END IF;
13303 l_progress := '60';
13304
13305 LOOP
13306 l_progress := '70';
13307 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13308 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13309 FETCH l_capcity_cur_bulk INTO l_equip_vol, l_equip_weight, l_item_vol, l_item_weight, l_equip_v_uom, l_equip_w_uom, l_item_v_uom
13310 , l_item_w_uom;
13311 EXIT WHEN l_capcity_cur_bulk%NOTFOUND;
13312 else
13313 FETCH l_capcity_cur INTO l_equip_vol, l_equip_weight, l_item_vol, l_item_weight, l_equip_v_uom, l_equip_w_uom, l_item_v_uom
13314 , l_item_w_uom;
13315 EXIT WHEN l_capcity_cur%NOTFOUND;
13316 end if;
13317 l_progress := '80';
13318 --bug 8800509 added following debug statements
13319 IF (l_debug = 1) THEN
13320 print_debug('split_task 70 - l_equip_vol ' || l_equip_vol, 4);
13321 print_debug('split_task 70 - l_equip_weight ' || l_equip_weight, 4);
13322 print_debug('split_task 70 - l_item_vol ' || l_item_vol, 4);
13323 print_debug('split_task 70 - l_item_weight ' || l_item_weight, 4);
13324 print_debug('split_task 70 - l_equip_v_uom ' || l_equip_v_uom, 4);
13325 print_debug('split_task 70 - l_equip_w_uom ' || l_equip_w_uom, 4);
13326 print_debug('split_task 70 - l_item_v_uom ' || l_item_v_uom, 4);
13327 print_debug('split_task 70 - l_item_w_uom ' || l_item_w_uom, 4);
13328 END IF;
13329 -- get the conversion ratio between equipment and item volume UOM
13330 inv_convert.inv_um_conversion(from_unit => l_equip_v_uom, to_unit => l_item_v_uom, item_id => 0, uom_rate => l_eq_it_v_uom_ratio);
13331 IF l_eq_it_v_uom_ratio = -99999 THEN -- uom conversion failure
13332 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
13333 fnd_msg_pub.ADD;
13334
13335 IF (l_debug = 1) THEN
13336 print_debug('split_task 70 - eqp/item volume uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13337 END IF;
13338 END IF;
13339 -- get the conversion ratio between equipment and item weight UOM
13340 inv_convert.inv_um_conversion(from_unit => l_equip_w_uom, to_unit => l_item_w_uom, item_id => 0, uom_rate => l_eq_it_w_uom_ratio);
13341 IF l_eq_it_w_uom_ratio = -99999 THEN -- uom conversion failure
13342 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
13343 fnd_msg_pub.ADD;
13344
13345 IF (l_debug = 1) THEN
13346 print_debug('split_task 70 - eqp/item weight uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13347 END IF;
13348 END IF;
13349
13350 --
13351 -- Debugging Statements for FP bug 4634597
13352 --
13353 IF (l_debug = 1) THEN
13354 print_debug('l_equip_vol = ' || l_equip_vol, 4);
13355 print_debug('l_item_vol = ' || l_item_vol, 4);
13356 print_debug('l_eq_it_v_uom_ratio = ' || l_eq_it_v_uom_ratio, 4);
13357 print_debug('l_equip_weight = ' || l_equip_weight, 4);
13358 print_debug('l_item_weight = ' || l_item_weight, 4);
13359 print_debug('l_eq_it_w_uom_ratio = ' || l_eq_it_w_uom_ratio, 4);
13360 END IF;
13361 --
13362 --Bug 8800509 Start of code addition
13363 --volume for both item and equipment are defined
13364 IF (l_equip_vol IS NOT NULL AND l_item_vol IS NOT NULL AND l_eq_it_v_uom_ratio <> -99999) THEN
13365 --weight for both item and equip are defined
13366 IF (l_equip_weight IS NOT NULL AND l_item_weight IS NOT NULL AND l_eq_it_w_uom_ratio <> -99999) THEN
13367 --both weight and voulme are defined for item and equip
13368 --calculate based on both
13369
13370 IF (l_debug = 1) THEN
13371 print_debug('split_task 70.1, both weight and voulme are defined for item and equip, calculate equipment capacity based on both weight and volume',4);
13372 END IF;
13373
13374 l_min_cap_temp := TRUNC(min_num((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))/ l_txn_pri_uom_ratio);
13375 --
13376 -- Start FP Bug 4634596
13377 --
13378 IF (l_min_cap_temp = 0) THEN
13379 l_min_cap_temp := min_num((l_equip_vol * l_eq_it_v_uom_ratio /l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight)) / l_txn_pri_uom_ratio;
13380 END IF;
13381 ELSE
13382 --only volume is defined for item and equip
13383 --calculate equipment capacity based on volume only
13384 IF (l_debug = 1) THEN
13385 print_debug('split_task 70.1, only voulme defined for item and equip, calculate equipment capacity based on volume',4);
13386 END IF;
13387 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
13388 --
13389 -- Start FP Bug 4634596
13390 --
13391 IF (l_min_cap_temp = 0) THEN
13392 l_min_cap_temp := (l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio;
13393 END IF;
13394 --
13395 -- End FP Bug 4634596
13396 --
13397 END IF;
13398 --weight for both item and equipment are defined, but volume is not defined for one of them
13399 ELSIF (l_equip_weight IS NOT NULL AND l_item_weight IS NOT NULL AND l_eq_it_w_uom_ratio <> -99999) THEN
13400 --calculate based on weight only
13401
13402 IF (l_debug = 1) THEN
13403 print_debug('split_task 70.1, only weight defined for item and equip, calculate equipment capacity based on weight',4);
13404 END IF;
13405 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
13406 --
13407 -- Start FP Bug 4634596
13408 --
13409 IF (l_min_cap_temp = 0) THEN
13410 l_min_cap_temp := (l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio;
13411 END IF;
13412 --
13413 -- End FP Bug 4634596
13414 --
13415 ELSE
13416 --throw error, as no capicity definition
13417 IF (l_debug = 1) THEN
13418 print_debug('split_task 80 - invalid capacity for a particulcar equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13419 END IF;
13420 END IF;
13421
13422 IF (l_debug = 1) THEN
13423 print_debug('split_task 1.6, l_min_cap'||l_min_cap,4);
13424 print_debug('split_task 1.6, l_min_cap_temp'|| l_min_cap_temp,4);
13425 END IF;
13426
13427 IF (l_min_cap = -1)
13428 OR(l_min_cap > l_min_cap_temp) THEN
13429 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
13430 END IF;
13431 --Bug 8800509 End of code addition
13432
13433 --Bug 8800509 Start of commented out code
13434
13435 /* IF (l_equip_vol IS NOT NULL
13436 AND l_item_vol IS NOT NULL
13437 AND l_eq_it_v_uom_ratio <> -99999)
13438 OR(l_equip_weight IS NOT NULL
13439 AND l_item_weight IS NOT NULL
13440 AND l_eq_it_w_uom_ratio <> -99999) THEN
13441 IF l_eq_it_v_uom_ratio = -99999 THEN -- invalid volume UOM conversion
13442 -- compute equipment capacity using weight
13443 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
13444 --
13445 -- Start FP Bug 4634597
13446 --
13447 IF (l_min_cap_temp = 0) THEN
13448 l_min_cap_temp := (l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio;
13449 END IF;
13450 --
13451 -- End FP Bug 4634597
13452 --
13453 ELSIF l_eq_it_w_uom_ratio = -9999 THEN -- invalid weight conversion
13454 -- compute equipment capacity using volume
13455 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
13456 --
13457 -- Start FP Bug 4634597
13458 --
13459 IF (l_min_cap_temp = 0) THEN
13460 l_min_cap_temp := (l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio;
13461 END IF;
13462 --
13463 -- End FP Bug 4634597
13464 --
13465 ELSE -- both weight and volume defined
13466 -- compute the minimum of volume capacity and weight capacity
13467 -- transfer the capacity to transaction UOM
13468 l_min_cap_temp :=
13469 TRUNC(
13470 min_num((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))
13471 / l_txn_pri_uom_ratio
13472 );
13473 --
13474 -- Start FP Bug 4634597
13475 --
13476 IF (l_min_cap_temp = 0) THEN
13477 l_min_cap_temp := min_num((l_equip_vol * l_eq_it_v_uom_ratio /
13478 l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))
13479 / l_txn_pri_uom_ratio;
13480 END IF;
13481 --
13482 -- End FP Bug 4634597
13483 --
13484 END IF;
13485 IF (l_debug = 1) THEN
13486 print_debug('split_task 1.6, l_min_cap'||l_min_cap,4);
13487 print_debug('split_task 1.6, l_min_cap_temp'|| l_min_cap_temp,4);
13488 END IF;
13489 IF (l_min_cap = -1)
13490 OR(l_min_cap > l_min_cap_temp) THEN
13491 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
13492 END IF;
13493 ELSE -- neither of weight or volume capacity is properly defined
13494 IF (l_debug = 1) THEN
13495 print_debug('split_task 80 - invalid capacity for a particulcar equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13496 END IF;
13497 END IF;*/
13498 --Bug 8800509 End of commented out code
13499 END LOOP;
13500
13501 l_progress := '90';
13502 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13503 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13504 CLOSE l_capcity_cur_bulk;
13505 else
13506 CLOSE l_capcity_cur;
13507 end if;
13508 l_progress := '100';
13509
13510 IF l_min_cap = -1 THEN -- min capcity is not properly queried
13511 fnd_message.set_name('WMS', 'WMS_INVALID_CAP_DEF');
13512 fnd_msg_pub.ADD;
13513
13514 IF (l_debug = 1) THEN
13515 print_debug('split_task 90 - invalid capacity for a ALL equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13516 END IF;
13517
13518 RAISE fnd_api.g_exc_error;
13519 END IF;
13520
13521 -- compute splitting factor, round down equipment capacity to multiple of locator uom ratio
13522 IF l_min_cap >= l_loc_txn_uom_ratio THEN
13523 l_split_factor := TRUNC(l_min_cap / l_loc_txn_uom_ratio) * l_loc_txn_uom_ratio;
13524 ELSE
13525 l_split_factor := l_min_cap;
13526 END IF;
13527
13528 IF (l_debug = 1) THEN
13529 print_debug('split_task 100 - l_split_factor = ' || l_split_factor, 4);
13530 END IF;
13531
13532 IF (l_split_factor <= 0 OR l_split_factor IS NULL) THEN -- min capcity is not properly queried bug# 9479006
13533 fnd_message.set_name('WMS', 'WMS_INVALID_CAP_DEF');
13534 fnd_msg_pub.ADD;
13535
13536 IF (l_debug = 1) THEN
13537 print_debug('split_task 95 - minimum capacity 0' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
13538 END IF;
13539
13540 RAISE fnd_api.g_exc_error;
13541 END IF;
13542
13543 -- query the inital task
13544
13545 l_progress := '110';
13546
13547 --- patchset J bulk picking ---
13548 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13549 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13550 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
13551 if (l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id) then -- bulk picking
13552 IF (l_init_qty > l_split_factor AND l_split_factor > 0) THEN -- only open the child cursor when split is needed
13553 IF (l_debug = 1) THEN
13554 print_debug('Patchset J bulk picking,open the child tasks...',4);
13555 END IF;
13556 open c_child_tasks(p_task_id);
13557 END IF;
13558 end if;
13559 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --END',4); END IF;
13560 end if;
13561 --- end of patchset J bulk picking ---
13562 l_progress := '120';
13563
13564 -- split task based on splitting factor
13565 WHILE(l_init_qty > l_split_factor
13566 AND l_split_factor > 0) LOOP
13567 IF (l_debug = 1) THEN
13568 print_debug('split_task 110 - splitting task - l_init_qty = ' || l_init_qty, 4);
13569 END IF;
13570
13571 l_counter := l_counter + 1;
13572 l_init_qty := l_init_qty - l_split_factor;
13573
13574 IF l_init_qty >= 0 THEN
13575 l_new_qty := l_split_factor;
13576 ELSE
13577 l_new_qty := l_init_qty + l_split_factor;
13578 END IF;
13579
13580 -- generate new tasks
13581 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13582 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13583 l_task_rec_new_mmtt := l_task_rec_old_mmtt;
13584 else
13585 l_task_rec_new_wct := l_task_rec_old_wct;
13586 end if;
13587 l_progress := '130';
13588
13589 -- generate new transaction_temp_id primary key
13590 SELECT mtl_material_transactions_s.NEXTVAL
13591 INTO l_new_temp_id
13592 FROM DUAL;
13593
13594 l_progress := '140';
13595 /* Is it necessary to change transaction UOM to locator UOM here ???*/
13596 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13597 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13598 l_task_rec_new_mmtt.transaction_temp_id := l_new_temp_id;
13599 l_task_rec_new_mmtt.transaction_quantity := l_new_qty;
13600 l_task_rec_new_mmtt.primary_quantity := l_new_qty * l_txn_pri_uom_ratio;
13601 IF (l_txn_sec_uom_ratio<>0 AND l_txn_sec_uom_ratio IS NOT NULL) THEN
13602 l_task_rec_new_mmtt.secondary_transaction_quantity := Round((l_new_qty/l_txn_sec_uom_ratio),5);
13603 END IF;
13604 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13605 l_task_rec_new_mmtt.parent_line_id := l_new_temp_id;
13606 END IF;
13607 ELSE
13608 l_task_rec_new_wct.transaction_temp_id := l_new_temp_id;
13609 l_task_rec_new_wct.transaction_quantity := l_new_qty;
13610 l_task_rec_new_wct.primary_quantity := l_new_qty * l_txn_pri_uom_ratio;
13611 END IF;
13612
13613 -- l_task_rec_new.transaction_uom := l_loc_uom_code;
13614
13615 IF (l_debug = 1) THEN
13616 print_debug('split_task 120 - new task: ', 4);
13617 print_debug('l_new_temp_id => ' || l_new_temp_id, 4);
13618 print_debug('l_new_qty => ' || l_new_qty, 4);
13619 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13620 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13621 print_debug('primary_quantity => ' || l_task_rec_new_mmtt.primary_quantity, 4);
13622 ELSE
13623 print_debug('primary_quantity => ' || l_task_rec_new_wct.primary_quantity, 4);
13624 END IF;
13625 END IF;
13626
13627 -- insert reccord into mmtt
13628 l_progress := '150';
13629 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13630 l_move_order_type = inv_globals.G_MOVE_ORDER_PICK_WAVE THEN
13631 insert_mmtt(l_task_rec_new_mmtt);
13632 else
13633 insert_wct(l_task_rec_new_wct);
13634 end if;
13635
13636 -- Associate the child lines if it is bulk picking
13637 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13638 l_move_order_type = G_MOVE_ORDER_PICK_WAVE AND
13639 l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13640
13641 -- IF (l_debug = 1) THEN
13642 -- print_debug('PATCHSET J BULK PICKING:starting to split',4);
13643 -- END IF;
13644 l_child_total_qty := 0;
13645 loop
13646 IF (l_debug = 1) THEN
13647 print_debug('l_child_remaining_qty:'||l_child_remaining_qty,4);
13648 END IF;
13649 if (l_child_remaining_qty = 0) then
13650 fetch c_child_tasks into l_child_rec;
13651 EXIT WHEN c_child_tasks%NOTFOUND;
13652
13653 l_child_remaining_qty := l_child_rec.transaction_quantity;
13654 l_child_temp_id := l_child_rec.transaction_temp_id;
13655 l_child_total_qty := l_child_total_qty + l_child_rec.transaction_quantity;
13656 else
13657 l_child_rec.transaction_quantity := l_child_remaining_qty;
13658 l_child_total_qty := l_child_remaining_qty;
13659 end if;
13660 IF (l_debug = 1) THEN
13661 print_debug('l_child_total_qty '||l_child_total_qty,4);
13662 END IF;
13663 if l_child_total_qty <= l_new_qty then
13664 -- update the child records with the new parent line id
13665 update mtl_material_transactions_temp
13666 set parent_line_id = l_new_temp_id
13667 where transaction_Temp_id = l_child_rec.transaction_temp_id;
13668 l_child_remaining_qty := 0;
13669 -- if = which means fully satisfied the new parent, can exit
13670 exit when l_child_total_qty = l_new_qty;
13671 else
13672 l_child_remaining_qty := l_child_total_qty - l_new_qty;
13673 -- find the qty to split
13674 l_new_child_qty := l_child_rec.transaction_quantity - l_child_remaining_qty;
13675 IF (l_debug = 1) THEN
13676 print_debug('update transaction temp id '||l_child_rec.transaction_temp_id
13677 || ' with the remaining qty '||l_child_remaining_qty,4);
13678 END IF;
13679
13680 /* bug8197523. This ratio is for calculating the secondary qty for child tasks */
13681 IF (l_child_rec.secondary_transaction_quantity IS NOT NULL AND l_child_rec.secondary_transaction_quantity <> 0) THEN
13682 l_ch_txn_sec_uom_ratio := (l_child_rec.transaction_quantity/l_child_rec.secondary_transaction_quantity);
13683 ELSE
13684 l_ch_txn_sec_uom_ratio := 0;
13685 END IF;
13686
13687
13688 IF (l_debug = 1) THEN
13689 print_debug('81975 l_child_rec.transaction_temp_id => ' || l_child_rec.transaction_temp_id, 4);
13690 print_debug('81975 l_child_rec.transaction_quantity => ' || l_child_rec.transaction_quantity, 4);
13691 print_debug('81975 l_child_rec.primary_quantity => ' || l_child_rec.primary_quantity, 4);
13692 print_debug('81975 l_child_rec.secondary_transaction_quantity => ' || l_child_rec.secondary_transaction_quantity, 4);
13693 print_debug('81975 l_ch_txn_sec_uom_ratio=> ' || l_ch_txn_sec_uom_ratio, 4);
13694 END IF;
13695
13696
13697 -- update the child line with the remaining qty
13698 update mtl_material_transactions_temp
13699 set transaction_quantity = l_child_remaining_qty
13700 , primary_quantity = l_child_remaining_qty * l_txn_pri_uom_ratio
13701 , secondary_transaction_quantity = DECODE(l_ch_txn_sec_uom_ratio, NULL, NULL,0,NULL,Round((l_child_remaining_qty/l_ch_txn_sec_uom_ratio),5))
13702 where transaction_temp_id = l_child_rec.transaction_temp_id;
13703
13704 -- split the child task
13705 -- generate new transaction_temp_id primary key
13706 SELECT mtl_material_transactions_s.NEXTVAL
13707 INTO l_new_child_temp_id
13708 FROM DUAL;
13709
13710 l_progress := '140.1';
13711 select *
13712 into
13713 l_child_rec_new
13714 from mtl_material_transactions_temp
13715 where transaction_temp_id = l_child_rec.transaction_temp_id;
13716
13717 /* Is it necessary to change transaction UOM to locator UOM here ???*/
13718 l_child_rec_new.transaction_temp_id := l_new_child_temp_id;
13719 l_child_rec_new.transaction_quantity := l_new_child_qty;
13720 l_child_rec_new.primary_quantity := l_new_child_qty * l_txn_pri_uom_ratio;
13721 IF (l_ch_txn_sec_uom_ratio<>0 AND l_ch_txn_sec_uom_ratio IS NOT NULL) THEN
13722 l_child_rec_new.secondary_transaction_quantity := Round((l_new_child_qty/l_ch_txn_sec_uom_ratio),5);
13723 END IF;
13724 l_child_rec_new.parent_line_id := l_new_temp_id; -- update the new line with the correct parent
13725
13726
13727
13728 IF (l_debug = 1) THEN
13729 print_debug('split_task for child line - new child task: ', 4);
13730 print_debug('l_new_temp_id => ' || l_new_child_temp_id, 4);
13731 print_debug('l_new_qty => ' || l_new_child_qty, 4);
13732 print_debug('primary_quantity => ' || l_child_rec_new.primary_quantity, 4);
13733 print_debug('parent_line_id '||l_new_temp_id,4);
13734 END IF;
13735
13736 -- insert reccord into mmtt
13737 l_progress := '150.1';
13738 insert_mmtt(l_child_rec_new);
13739
13740
13741 -- split lot/serial temp table
13742
13743 l_lot_split_rec(1).transaction_id := l_new_child_temp_id;
13744 l_lot_split_rec(1).primary_quantity := l_child_rec_new.primary_quantity;
13745 IF (l_debug = 1) THEN
13746 print_debug('calling BREAK to insert the lot and serial',4);
13747 END IF;
13748 inv_rcv_common_apis.BREAK(
13749 p_original_tid => l_child_rec.transaction_temp_id
13750 , p_new_transactions_tb => l_lot_split_rec
13751 , p_lot_control_code => l_lot_control_code
13752 , p_serial_control_code => l_serial_number_control_code
13753 );
13754 IF (l_debug = 1) THEN print_debug('After insert the lot and serial for the split child',4);
13755 END IF;
13756 EXIT;
13757 end if;
13758 end loop;
13759 -- copy the lot and serial to the parents
13760 IF (l_debug = 1) THEN
13761 print_debug('calling duplicate_lot_serial_in_parent....',4);
13762 END IF;
13763 Duplicate_lot_serial_in_parent(l_new_temp_id,x_return_status,x_msg_count,x_msg_data);
13764
13765 if (x_return_status <> fnd_api.g_ret_sts_success) then
13766 IF (l_debug = 1) THEN
13767 print_debug('split_task 150.2 - error in duplicate_lot_serial_in_parent ', 4);
13768 END IF;
13769 raise fnd_api.g_exc_unexpected_error;
13770 end if;
13771 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13772 END IF;
13773
13774 --- end of patchset J bulk picking -----------------
13775
13776 -- split lot/serial temp table
13777 IF l_task_rec_old_wct.parent_line_id is null THEN -- bulk picking patchset J ---- this is only for non bulk task
13778 l_lot_split_rec(1).transaction_id := l_new_temp_id;
13779 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13780 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13781 l_lot_split_rec(1).primary_quantity := l_task_rec_new_mmtt.primary_quantity;
13782 else
13783 l_lot_split_rec(1).primary_quantity := l_task_rec_new_wct.primary_quantity;
13784 end if;
13785 inv_rcv_common_apis.BREAK(
13786 p_original_tid => p_task_id
13787 , p_new_transactions_tb => l_lot_split_rec
13788 , p_lot_control_code => l_lot_control_code
13789 , p_serial_control_code => l_serial_number_control_code
13790 );
13791 END IF;
13792 l_progress := '160';
13793 END LOOP;
13794
13795 IF (l_debug = 1) THEN
13796 print_debug('split_task 130 - remove original task: ', 4);
13797 END IF;
13798
13799 IF ((l_init_qty <= l_split_factor)) THEN
13800 UPDATE wms_cartonization_temp
13801 SET transaction_quantity = l_init_qty
13802 , primary_quantity = l_init_qty * l_txn_pri_uom_ratio
13803 , secondary_transaction_quantity = DECODE(l_txn_sec_uom_ratio, NULL, NULL,0,NULL,Round((l_init_qty/l_txn_sec_uom_ratio),5))
13804 WHERE transaction_temp_id = p_task_id;
13805 -- for patchset J bulk picking -----------
13806 -- the lot and serial info still need to be duplicated since consolidation didn't do it
13807 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13808 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13809 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- START',4); END IF;
13810 UPDATE mtl_material_transactions_temp
13811 SET transaction_quantity = l_init_qty
13812 , primary_quantity = l_init_qty * l_txn_pri_uom_ratio
13813 , secondary_transaction_quantity = DECODE(l_txn_sec_uom_ratio, NULL, NULL,0,NULL,Round((l_init_qty/l_txn_sec_uom_ratio),5))
13814
13815 WHERE transaction_temp_id = p_task_id;
13816 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13817 -- copy the lot and serial to the parents
13818 IF (l_debug = 1) THEN
13819 print_debug('calling duplicate_lot_serial_in_parent for the last ....',4);
13820 END IF;
13821 Duplicate_lot_serial_in_parent(p_task_id,x_return_status,x_msg_count,x_msg_data);
13822 if (x_return_status <> fnd_api.g_ret_sts_success) then
13823 IF (l_debug = 1) THEN
13824 print_debug('split_task 150.2 - error in duplicate_lot_serial_in_parent ', 4);
13825 END IF;
13826 raise fnd_api.g_exc_unexpected_error;
13827 end if;
13828 END IF;
13829 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13830 end if; -- end of patchset J bulk picking ----------
13831 END IF;
13832
13833 /*
13834
13835 IF l_init_qty <= 0 THEN
13836 DELETE wms_cartonization_temp
13837 WHERE transaction_temp_id = p_task_id;
13838 END IF;
13839 */
13840 IF (l_debug = 1) THEN
13841 print_debug('split_task 140 - complete ', 4);
13842 END IF;
13843 EXCEPTION
13844 WHEN fnd_api.g_exc_error THEN
13845 x_return_status := fnd_api.g_ret_sts_error;
13846 ROLLBACK TO sp_task_split;
13847 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13848
13849 IF (l_debug = 1) THEN
13850 print_debug(
13851 'split_task: Raise expected exception. But the task generation process should continue processing, only that tasks are not split according to equipment capacity. '
13852 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
13853 , 1
13854 );
13855 END IF;
13856 -- for patchset J bulk picking -----------
13857 -- the lot and serial info still need to be duplicated since consolidation didn't do it
13858 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13859 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13860 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- START',4); END IF;
13861
13862 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13863 -- copy the lot and serial to the parents
13864 IF (l_debug = 1) THEN
13865 print_debug('calling duplicate_lot_serial_in_parent for the parent line ....',4);
13866 END IF;
13867 Duplicate_lot_serial_in_parent(p_task_id,x_return_status,x_msg_count,x_msg_data);
13868 if (x_return_status <> fnd_api.g_ret_sts_success) then
13869 IF (l_debug = 1) THEN
13870 print_debug('split_task 1000- error in duplicate_lot_serial_in_parent ', 4);
13871 END IF;
13872 -- change to unexpected error
13873 x_return_status := fnd_api.g_ret_sts_unexp_error;
13874 end if;
13875 END IF;
13876 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13877 end if; -- end of patchset J bulk picking ----------
13878
13879 WHEN fnd_api.g_exc_unexpected_error THEN
13880 x_return_status := fnd_api.g_ret_sts_unexp_error;
13881 ROLLBACK TO sp_task_split;
13882 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13883
13884 IF (l_debug = 1) THEN
13885 print_debug('split_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
13886 END IF;
13887 WHEN OTHERS THEN
13888 x_return_status := fnd_api.g_ret_sts_unexp_error;
13889 ROLLBACK TO sp_task_split;
13890
13891 IF SQLCODE IS NOT NULL THEN
13892 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.split_task', l_progress, SQLCODE);
13893 END IF;
13894
13895 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13896
13897 IF (l_debug = 1) THEN
13898 print_debug('split_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
13899 END IF;
13900 END split_task;
13901
13902 PROCEDURE insert_mmtt(l_mmtt_rec mtl_material_transactions_temp%ROWTYPE) IS
13903 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
13904 BEGIN
13905 INSERT INTO mtl_material_transactions_temp
13906 (
13907 transaction_header_id
13908 , transaction_temp_id
13909 , source_code
13910 , source_line_id
13911 , transaction_mode
13912 , lock_flag
13913 , last_update_date
13914 , last_updated_by
13915 , creation_date
13916 , created_by
13917 , last_update_login
13918 , request_id
13919 , program_application_id
13920 , program_id
13921 , program_update_date
13922 , inventory_item_id
13923 , revision
13924 , organization_id
13925 , subinventory_code
13926 , locator_id
13927 , transaction_quantity
13928 , primary_quantity
13929 , transaction_uom
13930 , transaction_cost
13931 , transaction_type_id
13932 , transaction_action_id
13933 , transaction_source_type_id
13934 , transaction_source_id
13935 , transaction_source_name
13936 , transaction_date
13937 , acct_period_id
13938 , distribution_account_id
13939 , transaction_reference
13940 , requisition_line_id
13941 , requisition_distribution_id
13942 , reason_id
13943 , lot_number
13944 , lot_expiration_date
13945 , serial_number
13946 , receiving_document
13947 , demand_id
13948 , rcv_transaction_id
13949 , move_transaction_id
13950 , completion_transaction_id
13951 , wip_entity_type
13952 , schedule_id
13953 , repetitive_line_id
13954 , employee_code
13955 , primary_switch
13956 , schedule_update_code
13957 , setup_teardown_code
13958 , item_ordering
13959 , negative_req_flag
13960 , operation_seq_num
13961 , picking_line_id
13962 , trx_source_line_id
13963 , trx_source_delivery_id
13964 , physical_adjustment_id
13965 , cycle_count_id
13966 , rma_line_id
13967 , customer_ship_id
13968 , currency_code
13969 , currency_conversion_rate
13970 , currency_conversion_type
13971 , currency_conversion_date
13972 , ussgl_transaction_code
13973 , vendor_lot_number
13974 , encumbrance_account
13975 , encumbrance_amount
13976 , ship_to_location
13977 , shipment_number
13978 , transfer_cost
13979 , transportation_cost
13980 , transportation_account
13981 , freight_code
13982 , containers
13983 , waybill_airbill
13984 , expected_arrival_date
13985 , transfer_subinventory
13986 , transfer_organization
13987 , transfer_to_location
13988 , new_average_cost
13989 , value_change
13990 , percentage_change
13991 , material_allocation_temp_id
13992 , demand_source_header_id
13993 , demand_source_line
13994 , demand_source_delivery
13995 , item_segments
13996 , item_description
13997 , item_trx_enabled_flag
13998 , item_location_control_code
13999 , item_restrict_subinv_code
14000 , item_restrict_locators_code
14001 , item_revision_qty_control_code
14002 , item_primary_uom_code
14003 , item_uom_class
14004 , item_shelf_life_code
14005 , item_shelf_life_days
14006 , item_lot_control_code
14007 , item_serial_control_code
14008 , item_inventory_asset_flag
14009 , allowed_units_lookup_code
14010 , department_id
14011 , department_code
14012 , wip_supply_type
14013 , supply_subinventory
14014 , supply_locator_id
14015 , valid_subinventory_flag
14016 , valid_locator_flag
14017 , locator_segments
14018 , current_locator_control_code
14019 , number_of_lots_entered
14020 , wip_commit_flag
14021 , next_lot_number
14022 , lot_alpha_prefix
14023 , next_serial_number
14024 , serial_alpha_prefix
14025 , shippable_flag
14026 , posting_flag
14027 , required_flag
14028 , process_flag
14029 , ERROR_CODE
14030 , error_explanation
14031 , attribute_category
14032 , attribute1
14033 , attribute2
14034 , attribute3
14035 , attribute4
14036 , attribute5
14037 , attribute6
14038 , attribute7
14039 , attribute8
14040 , attribute9
14041 , attribute10
14042 , attribute11
14043 , attribute12
14044 , attribute13
14045 , attribute14
14046 , attribute15
14047 , movement_id
14048 , reservation_quantity
14049 , shipped_quantity
14050 , transaction_line_number
14051 , task_id
14052 , to_task_id
14053 , source_task_id
14054 , project_id
14055 , source_project_id
14056 , pa_expenditure_org_id
14057 , to_project_id
14058 , expenditure_type
14059 , final_completion_flag
14060 , transfer_percentage
14061 , transaction_sequence_id
14062 , material_account
14063 , material_overhead_account
14064 , resource_account
14065 , outside_processing_account
14066 , overhead_account
14067 , flow_schedule
14068 , cost_group_id
14069 , transfer_cost_group_id
14070 , demand_class
14071 , qa_collection_id
14072 , kanban_card_id
14073 , overcompletion_transaction_qty
14074 , overcompletion_primary_qty
14075 , overcompletion_transaction_id
14076 , end_item_unit_number
14077 , scheduled_payback_date
14078 , line_type_code
14079 , parent_transaction_temp_id
14080 , put_away_strategy_id
14081 , put_away_rule_id
14082 , pick_strategy_id
14083 , pick_rule_id
14084 , move_order_line_id
14085 , task_group_id
14086 , pick_slip_number
14087 , reservation_id
14088 , common_bom_seq_id
14089 , common_routing_seq_id
14090 , org_cost_group_id
14091 , cost_type_id
14092 , transaction_status
14093 , standard_operation_id
14094 , task_priority
14095 , wms_task_type
14096 , parent_line_id
14097 , lpn_id
14098 , transfer_lpn_id
14099 , wms_task_status
14100 , content_lpn_id
14101 , container_item_id
14102 , cartonization_id
14103 , pick_slip_date
14104 , rebuild_item_id
14105 , rebuild_serial_number
14106 , rebuild_activity_id
14107 , rebuild_job_name
14108 , organization_type
14109 , transfer_organization_type
14110 , owning_organization_id
14111 , owning_tp_type
14112 , xfr_owning_organization_id
14113 , transfer_owning_tp_type
14114 , planning_organization_id
14115 , planning_tp_type
14116 , xfr_planning_organization_id
14117 , transfer_planning_tp_type
14118 , secondary_uom_code
14119 , secondary_transaction_quantity
14120 , transaction_batch_id
14121 , transaction_batch_seq
14122 , allocated_lpn_id
14123 , schedule_number
14124 , scheduled_flag
14125 , class_code
14126 , schedule_group
14127 , build_sequence
14128 , bom_revision
14129 , routing_revision
14130 , bom_revision_date
14131 , routing_revision_date
14132 , alternate_bom_designator
14133 , alternate_routing_designator
14134 , operation_plan_id
14135 , serial_allocated_flag
14136 , move_order_header_id
14137 , fulfillment_base
14138 )
14139 VALUES (
14140 l_mmtt_rec.transaction_header_id
14141 , l_mmtt_rec.transaction_temp_id
14142 , l_mmtt_rec.source_code
14143 , l_mmtt_rec.source_line_id
14144 , l_mmtt_rec.transaction_mode
14145 , l_mmtt_rec.lock_flag
14146 , l_mmtt_rec.last_update_date
14147 , l_mmtt_rec.last_updated_by
14148 , l_mmtt_rec.creation_date
14149 , l_mmtt_rec.created_by
14150 , l_mmtt_rec.last_update_login
14151 , l_mmtt_rec.request_id
14152 , l_mmtt_rec.program_application_id
14153 , l_mmtt_rec.program_id
14154 , l_mmtt_rec.program_update_date
14155 , l_mmtt_rec.inventory_item_id
14156 , l_mmtt_rec.revision
14157 , l_mmtt_rec.organization_id
14158 , l_mmtt_rec.subinventory_code
14159 , l_mmtt_rec.locator_id
14160 , l_mmtt_rec.transaction_quantity
14161 , l_mmtt_rec.primary_quantity
14162 , l_mmtt_rec.transaction_uom
14163 , l_mmtt_rec.transaction_cost
14164 , l_mmtt_rec.transaction_type_id
14165 , l_mmtt_rec.transaction_action_id
14166 , l_mmtt_rec.transaction_source_type_id
14167 , l_mmtt_rec.transaction_source_id
14168 , l_mmtt_rec.transaction_source_name
14169 , l_mmtt_rec.transaction_date
14170 , l_mmtt_rec.acct_period_id
14171 , l_mmtt_rec.distribution_account_id
14172 , l_mmtt_rec.transaction_reference
14173 , l_mmtt_rec.requisition_line_id
14174 , l_mmtt_rec.requisition_distribution_id
14175 , l_mmtt_rec.reason_id
14176 , l_mmtt_rec.lot_number
14177 , l_mmtt_rec.lot_expiration_date
14178 , l_mmtt_rec.serial_number
14179 , l_mmtt_rec.receiving_document
14180 , l_mmtt_rec.demand_id
14181 , l_mmtt_rec.rcv_transaction_id
14182 , l_mmtt_rec.move_transaction_id
14183 , l_mmtt_rec.completion_transaction_id
14184 , l_mmtt_rec.wip_entity_type
14185 , l_mmtt_rec.schedule_id
14186 , l_mmtt_rec.repetitive_line_id
14187 , l_mmtt_rec.employee_code
14188 , l_mmtt_rec.primary_switch
14189 , l_mmtt_rec.schedule_update_code
14190 , l_mmtt_rec.setup_teardown_code
14191 , l_mmtt_rec.item_ordering
14192 , l_mmtt_rec.negative_req_flag
14193 , l_mmtt_rec.operation_seq_num
14194 , l_mmtt_rec.picking_line_id
14195 , l_mmtt_rec.trx_source_line_id
14196 , l_mmtt_rec.trx_source_delivery_id
14197 , l_mmtt_rec.physical_adjustment_id
14198 , l_mmtt_rec.cycle_count_id
14199 , l_mmtt_rec.rma_line_id
14200 , l_mmtt_rec.customer_ship_id
14201 , l_mmtt_rec.currency_code
14202 , l_mmtt_rec.currency_conversion_rate
14203 , l_mmtt_rec.currency_conversion_type
14204 , l_mmtt_rec.currency_conversion_date
14205 , l_mmtt_rec.ussgl_transaction_code
14206 , l_mmtt_rec.vendor_lot_number
14207 , l_mmtt_rec.encumbrance_account
14208 , l_mmtt_rec.encumbrance_amount
14209 , l_mmtt_rec.ship_to_location
14210 , l_mmtt_rec.shipment_number
14211 , l_mmtt_rec.transfer_cost
14212 , l_mmtt_rec.transportation_cost
14213 , l_mmtt_rec.transportation_account
14214 , l_mmtt_rec.freight_code
14215 , l_mmtt_rec.containers
14216 , l_mmtt_rec.waybill_airbill
14217 , l_mmtt_rec.expected_arrival_date
14218 , l_mmtt_rec.transfer_subinventory
14219 , l_mmtt_rec.transfer_organization
14220 , l_mmtt_rec.transfer_to_location
14221 , l_mmtt_rec.new_average_cost
14222 , l_mmtt_rec.value_change
14223 , l_mmtt_rec.percentage_change
14224 , l_mmtt_rec.material_allocation_temp_id
14225 , l_mmtt_rec.demand_source_header_id
14226 , l_mmtt_rec.demand_source_line
14227 , l_mmtt_rec.demand_source_delivery
14228 , l_mmtt_rec.item_segments
14229 , l_mmtt_rec.item_description
14230 , l_mmtt_rec.item_trx_enabled_flag
14231 , l_mmtt_rec.item_location_control_code
14232 , l_mmtt_rec.item_restrict_subinv_code
14233 , l_mmtt_rec.item_restrict_locators_code
14234 , l_mmtt_rec.item_revision_qty_control_code
14235 , l_mmtt_rec.item_primary_uom_code
14236 , l_mmtt_rec.item_uom_class
14237 , l_mmtt_rec.item_shelf_life_code
14238 , l_mmtt_rec.item_shelf_life_days
14239 , l_mmtt_rec.item_lot_control_code
14240 , l_mmtt_rec.item_serial_control_code
14241 , l_mmtt_rec.item_inventory_asset_flag
14242 , l_mmtt_rec.allowed_units_lookup_code
14243 , l_mmtt_rec.department_id
14244 , l_mmtt_rec.department_code
14245 , l_mmtt_rec.wip_supply_type
14246 , l_mmtt_rec.supply_subinventory
14247 , l_mmtt_rec.supply_locator_id
14248 , l_mmtt_rec.valid_subinventory_flag
14249 , l_mmtt_rec.valid_locator_flag
14250 , l_mmtt_rec.locator_segments
14251 , l_mmtt_rec.current_locator_control_code
14252 , l_mmtt_rec.number_of_lots_entered
14253 , l_mmtt_rec.wip_commit_flag
14254 , l_mmtt_rec.next_lot_number
14255 , l_mmtt_rec.lot_alpha_prefix
14256 , l_mmtt_rec.next_serial_number
14257 , l_mmtt_rec.serial_alpha_prefix
14258 , l_mmtt_rec.shippable_flag
14259 , l_mmtt_rec.posting_flag
14260 , l_mmtt_rec.required_flag
14261 , l_mmtt_rec.process_flag
14262 , l_mmtt_rec.ERROR_CODE
14263 , l_mmtt_rec.error_explanation
14264 , l_mmtt_rec.attribute_category
14265 , l_mmtt_rec.attribute1
14266 , l_mmtt_rec.attribute2
14267 , l_mmtt_rec.attribute3
14268 , l_mmtt_rec.attribute4
14269 , l_mmtt_rec.attribute5
14270 , l_mmtt_rec.attribute6
14271 , l_mmtt_rec.attribute7
14272 , l_mmtt_rec.attribute8
14273 , l_mmtt_rec.attribute9
14274 , l_mmtt_rec.attribute10
14275 , l_mmtt_rec.attribute11
14276 , l_mmtt_rec.attribute12
14277 , l_mmtt_rec.attribute13
14278 , l_mmtt_rec.attribute14
14279 , l_mmtt_rec.attribute15
14280 , l_mmtt_rec.movement_id
14281 , l_mmtt_rec.reservation_quantity
14282 , l_mmtt_rec.shipped_quantity
14283 , l_mmtt_rec.transaction_line_number
14284 , l_mmtt_rec.task_id
14285 , l_mmtt_rec.to_task_id
14286 , l_mmtt_rec.source_task_id
14287 , l_mmtt_rec.project_id
14288 , l_mmtt_rec.source_project_id
14289 , l_mmtt_rec.pa_expenditure_org_id
14290 , l_mmtt_rec.to_project_id
14291 , l_mmtt_rec.expenditure_type
14292 , l_mmtt_rec.final_completion_flag
14293 , l_mmtt_rec.transfer_percentage
14294 , l_mmtt_rec.transaction_sequence_id
14295 , l_mmtt_rec.material_account
14296 , l_mmtt_rec.material_overhead_account
14297 , l_mmtt_rec.resource_account
14298 , l_mmtt_rec.outside_processing_account
14299 , l_mmtt_rec.overhead_account
14300 , l_mmtt_rec.flow_schedule
14301 , l_mmtt_rec.cost_group_id
14302 , l_mmtt_rec.transfer_cost_group_id
14303 , l_mmtt_rec.demand_class
14304 , l_mmtt_rec.qa_collection_id
14305 , l_mmtt_rec.kanban_card_id
14306 , l_mmtt_rec.overcompletion_transaction_qty
14307 , l_mmtt_rec.overcompletion_primary_qty
14308 , l_mmtt_rec.overcompletion_transaction_id
14309 , l_mmtt_rec.end_item_unit_number
14310 , l_mmtt_rec.scheduled_payback_date
14311 , l_mmtt_rec.line_type_code
14312 , l_mmtt_rec.parent_transaction_temp_id
14313 , l_mmtt_rec.put_away_strategy_id
14314 , l_mmtt_rec.put_away_rule_id
14315 , l_mmtt_rec.pick_strategy_id
14316 , l_mmtt_rec.pick_rule_id
14317 , l_mmtt_rec.move_order_line_id
14318 , l_mmtt_rec.task_group_id
14319 , l_mmtt_rec.pick_slip_number
14320 , l_mmtt_rec.reservation_id
14321 , l_mmtt_rec.common_bom_seq_id
14322 , l_mmtt_rec.common_routing_seq_id
14323 , l_mmtt_rec.org_cost_group_id
14324 , l_mmtt_rec.cost_type_id
14325 , l_mmtt_rec.transaction_status
14326 , l_mmtt_rec.standard_operation_id
14327 , l_mmtt_rec.task_priority
14328 , l_mmtt_rec.wms_task_type
14329 , l_mmtt_rec.parent_line_id
14330 , l_mmtt_rec.lpn_id
14331 , l_mmtt_rec.transfer_lpn_id
14332 , l_mmtt_rec.wms_task_status
14333 , l_mmtt_rec.content_lpn_id
14334 , l_mmtt_rec.container_item_id
14335 , l_mmtt_rec.cartonization_id
14336 , l_mmtt_rec.pick_slip_date
14337 , l_mmtt_rec.rebuild_item_id
14338 , l_mmtt_rec.rebuild_serial_number
14339 , l_mmtt_rec.rebuild_activity_id
14340 , l_mmtt_rec.rebuild_job_name
14341 , l_mmtt_rec.organization_type
14342 , l_mmtt_rec.transfer_organization_type
14343 , l_mmtt_rec.owning_organization_id
14344 , l_mmtt_rec.owning_tp_type
14345 , l_mmtt_rec.xfr_owning_organization_id
14346 , l_mmtt_rec.transfer_owning_tp_type
14347 , l_mmtt_rec.planning_organization_id
14348 , l_mmtt_rec.planning_tp_type
14349 , l_mmtt_rec.xfr_planning_organization_id
14350 , l_mmtt_rec.transfer_planning_tp_type
14351 , l_mmtt_rec.secondary_uom_code
14352 , l_mmtt_rec.secondary_transaction_quantity
14353 , l_mmtt_rec.transaction_batch_id
14354 , l_mmtt_rec.transaction_batch_seq
14355 , l_mmtt_rec.allocated_lpn_id
14356 , l_mmtt_rec.schedule_number
14357 , l_mmtt_rec.scheduled_flag
14358 , l_mmtt_rec.class_code
14359 , l_mmtt_rec.schedule_group
14360 , l_mmtt_rec.build_sequence
14361 , l_mmtt_rec.bom_revision
14362 , l_mmtt_rec.routing_revision
14363 , l_mmtt_rec.bom_revision_date
14364 , l_mmtt_rec.routing_revision_date
14365 , l_mmtt_rec.alternate_bom_designator
14366 , l_mmtt_rec.alternate_routing_designator
14367 , l_mmtt_rec.operation_plan_id
14368 , l_mmtt_rec.serial_allocated_flag
14369 , l_mmtt_rec.move_order_header_id
14370 , l_mmtt_rec.fulfillment_base
14371 );
14372 END insert_mmtt;
14373
14374 PROCEDURE insert_wct(l_wct_rec wms_cartonization_temp%ROWTYPE) IS
14375 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
14376 BEGIN
14377 INSERT INTO wms_cartonization_temp
14378 (
14379 transaction_header_id
14380 , transaction_temp_id
14381 , source_code
14382 , source_line_id
14383 , transaction_mode
14384 , lock_flag
14385 , last_update_date
14386 , last_updated_by
14387 , creation_date
14388 , created_by
14389 , last_update_login
14390 , request_id
14391 , program_application_id
14392 , program_id
14393 , program_update_date
14394 , inventory_item_id
14395 , revision
14396 , organization_id
14397 , subinventory_code
14398 , locator_id
14399 , transaction_quantity
14400 , primary_quantity
14401 , transaction_uom
14402 , transaction_cost
14403 , transaction_type_id
14404 , transaction_action_id
14405 , transaction_source_type_id
14406 , transaction_source_id
14407 , transaction_source_name
14408 , transaction_date
14409 , acct_period_id
14410 , distribution_account_id
14411 , transaction_reference
14412 , requisition_line_id
14413 , requisition_distribution_id
14414 , reason_id
14415 , lot_number
14416 , lot_expiration_date
14417 , serial_number
14418 , receiving_document
14419 , demand_id
14420 , rcv_transaction_id
14421 , move_transaction_id
14422 , completion_transaction_id
14423 , wip_entity_type
14424 , schedule_id
14425 , repetitive_line_id
14426 , employee_code
14427 , primary_switch
14428 , schedule_update_code
14429 , setup_teardown_code
14430 , item_ordering
14431 , negative_req_flag
14432 , operation_seq_num
14433 , picking_line_id
14434 , trx_source_line_id
14435 , trx_source_delivery_id
14436 , physical_adjustment_id
14437 , cycle_count_id
14438 , rma_line_id
14439 , customer_ship_id
14440 , currency_code
14441 , currency_conversion_rate
14442 , currency_conversion_type
14443 , currency_conversion_date
14444 , ussgl_transaction_code
14445 , vendor_lot_number
14446 , encumbrance_account
14447 , encumbrance_amount
14448 , ship_to_location
14449 , shipment_number
14450 , transfer_cost
14451 , transportation_cost
14452 , transportation_account
14453 , freight_code
14454 , containers
14455 , waybill_airbill
14456 , expected_arrival_date
14457 , transfer_subinventory
14458 , transfer_organization
14459 , transfer_to_location
14460 , new_average_cost
14461 , value_change
14462 , percentage_change
14463 , material_allocation_temp_id
14464 , demand_source_header_id
14465 , demand_source_line
14466 , demand_source_delivery
14467 , item_segments
14468 , item_description
14469 , item_trx_enabled_flag
14470 , item_location_control_code
14471 , item_restrict_subinv_code
14472 , item_restrict_locators_code
14473 , item_revision_qty_control_code
14474 , item_primary_uom_code
14475 , item_uom_class
14476 , item_shelf_life_code
14477 , item_shelf_life_days
14478 , item_lot_control_code
14479 , item_serial_control_code
14480 , item_inventory_asset_flag
14481 , allowed_units_lookup_code
14482 , department_id
14483 , department_code
14484 , wip_supply_type
14485 , supply_subinventory
14486 , supply_locator_id
14487 , valid_subinventory_flag
14488 , valid_locator_flag
14489 , locator_segments
14490 , current_locator_control_code
14491 , number_of_lots_entered
14492 , wip_commit_flag
14493 , next_lot_number
14494 , lot_alpha_prefix
14495 , next_serial_number
14496 , serial_alpha_prefix
14497 , shippable_flag
14498 , posting_flag
14499 , required_flag
14500 , process_flag
14501 , ERROR_CODE
14502 , error_explanation
14503 , attribute_category
14504 , attribute1
14505 , attribute2
14506 , attribute3
14507 , attribute4
14508 , attribute5
14509 , attribute6
14510 , attribute7
14511 , attribute8
14512 , attribute9
14513 , attribute10
14514 , attribute11
14515 , attribute12
14516 , attribute13
14517 , attribute14
14518 , attribute15
14519 , movement_id
14520 , reservation_quantity
14521 , shipped_quantity
14522 , transaction_line_number
14523 , task_id
14524 , to_task_id
14525 , source_task_id
14526 , project_id
14527 , source_project_id
14528 , pa_expenditure_org_id
14529 , to_project_id
14530 , expenditure_type
14531 , final_completion_flag
14532 , transfer_percentage
14533 , transaction_sequence_id
14534 , material_account
14535 , material_overhead_account
14536 , resource_account
14537 , outside_processing_account
14538 , overhead_account
14539 , flow_schedule
14540 , cost_group_id
14541 , transfer_cost_group_id
14542 , demand_class
14543 , qa_collection_id
14544 , kanban_card_id
14545 , overcompletion_txn_qty
14546 , overcompletion_primary_qty
14547 , overcompletion_transaction_id
14548 , end_item_unit_number
14549 , scheduled_payback_date
14550 , line_type_code
14551 , parent_transaction_temp_id
14552 , put_away_strategy_id
14553 , put_away_rule_id
14554 , pick_strategy_id
14555 , pick_rule_id
14556 , move_order_line_id
14557 , task_group_id
14558 , pick_slip_number
14559 , reservation_id
14560 , common_bom_seq_id
14561 , common_routing_seq_id
14562 , org_cost_group_id
14563 , cost_type_id
14564 , transaction_status
14565 , standard_operation_id
14566 , task_priority
14567 , wms_task_type
14568 , parent_line_id
14569 , lpn_id
14570 , transfer_lpn_id
14571 , wms_task_status
14572 , content_lpn_id
14573 , container_item_id
14574 , cartonization_id
14575 , pick_slip_date
14576 , rebuild_item_id
14577 , rebuild_serial_number
14578 , rebuild_activity_id
14579 , rebuild_job_name
14580 , organization_type
14581 , transfer_organization_type
14582 , owning_organization_id
14583 , owning_tp_type
14584 , xfr_owning_organization_id
14585 , transfer_owning_tp_type
14586 , planning_organization_id
14587 , planning_tp_type
14588 , xfr_planning_organization_id
14589 , transfer_planning_tp_type
14590 , secondary_uom_code
14591 , secondary_transaction_quantity
14592 , transaction_batch_id
14593 , transaction_batch_seq
14594 , allocated_lpn_id
14595 , schedule_number
14596 , scheduled_flag
14597 , class_code
14598 , schedule_group
14599 , build_sequence
14600 , bom_revision
14601 , routing_revision
14602 , bom_revision_date
14603 , routing_revision_date
14604 , alternate_bom_designator
14605 , alternate_routing_designator
14606 , operation_plan_id
14607 , serial_allocated_flag
14608 , move_order_header_id
14609 , fulfillment_base
14610 )
14611 VALUES (
14612 l_wct_rec.transaction_header_id
14613 , l_wct_rec.transaction_temp_id
14614 , l_wct_rec.source_code
14615 , l_wct_rec.source_line_id
14616 , l_wct_rec.transaction_mode
14617 , l_wct_rec.lock_flag
14618 , l_wct_rec.last_update_date
14619 , l_wct_rec.last_updated_by
14620 , l_wct_rec.creation_date
14621 , l_wct_rec.created_by
14622 , l_wct_rec.last_update_login
14623 , l_wct_rec.request_id
14624 , l_wct_rec.program_application_id
14625 , l_wct_rec.program_id
14626 , l_wct_rec.program_update_date
14627 , l_wct_rec.inventory_item_id
14628 , l_wct_rec.revision
14629 , l_wct_rec.organization_id
14630 , l_wct_rec.subinventory_code
14631 , l_wct_rec.locator_id
14632 , l_wct_rec.transaction_quantity
14633 , l_wct_rec.primary_quantity
14634 , l_wct_rec.transaction_uom
14635 , l_wct_rec.transaction_cost
14636 , l_wct_rec.transaction_type_id
14637 , l_wct_rec.transaction_action_id
14638 , l_wct_rec.transaction_source_type_id
14639 , l_wct_rec.transaction_source_id
14640 , l_wct_rec.transaction_source_name
14641 , l_wct_rec.transaction_date
14642 , l_wct_rec.acct_period_id
14643 , l_wct_rec.distribution_account_id
14644 , l_wct_rec.transaction_reference
14645 , l_wct_rec.requisition_line_id
14646 , l_wct_rec.requisition_distribution_id
14647 , l_wct_rec.reason_id
14648 , l_wct_rec.lot_number
14649 , l_wct_rec.lot_expiration_date
14650 , l_wct_rec.serial_number
14651 , l_wct_rec.receiving_document
14652 , l_wct_rec.demand_id
14653 , l_wct_rec.rcv_transaction_id
14654 , l_wct_rec.move_transaction_id
14655 , l_wct_rec.completion_transaction_id
14656 , l_wct_rec.wip_entity_type
14657 , l_wct_rec.schedule_id
14658 , l_wct_rec.repetitive_line_id
14659 , l_wct_rec.employee_code
14660 , l_wct_rec.primary_switch
14661 , l_wct_rec.schedule_update_code
14662 , l_wct_rec.setup_teardown_code
14663 , l_wct_rec.item_ordering
14664 , l_wct_rec.negative_req_flag
14665 , l_wct_rec.operation_seq_num
14666 , l_wct_rec.picking_line_id
14667 , l_wct_rec.trx_source_line_id
14668 , l_wct_rec.trx_source_delivery_id
14669 , l_wct_rec.physical_adjustment_id
14670 , l_wct_rec.cycle_count_id
14671 , l_wct_rec.rma_line_id
14672 , l_wct_rec.customer_ship_id
14673 , l_wct_rec.currency_code
14674 , l_wct_rec.currency_conversion_rate
14675 , l_wct_rec.currency_conversion_type
14676 , l_wct_rec.currency_conversion_date
14677 , l_wct_rec.ussgl_transaction_code
14678 , l_wct_rec.vendor_lot_number
14679 , l_wct_rec.encumbrance_account
14680 , l_wct_rec.encumbrance_amount
14681 , l_wct_rec.ship_to_location
14682 , l_wct_rec.shipment_number
14683 , l_wct_rec.transfer_cost
14684 , l_wct_rec.transportation_cost
14685 , l_wct_rec.transportation_account
14686 , l_wct_rec.freight_code
14687 , l_wct_rec.containers
14688 , l_wct_rec.waybill_airbill
14689 , l_wct_rec.expected_arrival_date
14690 , l_wct_rec.transfer_subinventory
14691 , l_wct_rec.transfer_organization
14692 , l_wct_rec.transfer_to_location
14693 , l_wct_rec.new_average_cost
14694 , l_wct_rec.value_change
14695 , l_wct_rec.percentage_change
14696 , l_wct_rec.material_allocation_temp_id
14697 , l_wct_rec.demand_source_header_id
14698 , l_wct_rec.demand_source_line
14699 , l_wct_rec.demand_source_delivery
14700 , l_wct_rec.item_segments
14701 , l_wct_rec.item_description
14702 , l_wct_rec.item_trx_enabled_flag
14703 , l_wct_rec.item_location_control_code
14704 , l_wct_rec.item_restrict_subinv_code
14705 , l_wct_rec.item_restrict_locators_code
14706 , l_wct_rec.item_revision_qty_control_code
14707 , l_wct_rec.item_primary_uom_code
14708 , l_wct_rec.item_uom_class
14709 , l_wct_rec.item_shelf_life_code
14710 , l_wct_rec.item_shelf_life_days
14711 , l_wct_rec.item_lot_control_code
14712 , l_wct_rec.item_serial_control_code
14713 , l_wct_rec.item_inventory_asset_flag
14714 , l_wct_rec.allowed_units_lookup_code
14715 , l_wct_rec.department_id
14716 , l_wct_rec.department_code
14717 , l_wct_rec.wip_supply_type
14718 , l_wct_rec.supply_subinventory
14719 , l_wct_rec.supply_locator_id
14720 , l_wct_rec.valid_subinventory_flag
14721 , l_wct_rec.valid_locator_flag
14722 , l_wct_rec.locator_segments
14723 , l_wct_rec.current_locator_control_code
14724 , l_wct_rec.number_of_lots_entered
14725 , l_wct_rec.wip_commit_flag
14726 , l_wct_rec.next_lot_number
14727 , l_wct_rec.lot_alpha_prefix
14728 , l_wct_rec.next_serial_number
14729 , l_wct_rec.serial_alpha_prefix
14730 , l_wct_rec.shippable_flag
14731 , l_wct_rec.posting_flag
14732 , l_wct_rec.required_flag
14733 , l_wct_rec.process_flag
14734 , l_wct_rec.ERROR_CODE
14735 , l_wct_rec.error_explanation
14736 , l_wct_rec.attribute_category
14737 , l_wct_rec.attribute1
14738 , l_wct_rec.attribute2
14739 , l_wct_rec.attribute3
14740 , l_wct_rec.attribute4
14741 , l_wct_rec.attribute5
14742 , l_wct_rec.attribute6
14743 , l_wct_rec.attribute7
14744 , l_wct_rec.attribute8
14745 , l_wct_rec.attribute9
14746 , l_wct_rec.attribute10
14747 , l_wct_rec.attribute11
14748 , l_wct_rec.attribute12
14749 , l_wct_rec.attribute13
14750 , l_wct_rec.attribute14
14751 , l_wct_rec.attribute15
14752 , l_wct_rec.movement_id
14753 , l_wct_rec.reservation_quantity
14754 , l_wct_rec.shipped_quantity
14755 , l_wct_rec.transaction_line_number
14756 , l_wct_rec.task_id
14757 , l_wct_rec.to_task_id
14758 , l_wct_rec.source_task_id
14759 , l_wct_rec.project_id
14760 , l_wct_rec.source_project_id
14761 , l_wct_rec.pa_expenditure_org_id
14762 , l_wct_rec.to_project_id
14763 , l_wct_rec.expenditure_type
14764 , l_wct_rec.final_completion_flag
14765 , l_wct_rec.transfer_percentage
14766 , l_wct_rec.transaction_sequence_id
14767 , l_wct_rec.material_account
14768 , l_wct_rec.material_overhead_account
14769 , l_wct_rec.resource_account
14770 , l_wct_rec.outside_processing_account
14771 , l_wct_rec.overhead_account
14772 , l_wct_rec.flow_schedule
14773 , l_wct_rec.cost_group_id
14774 , l_wct_rec.transfer_cost_group_id
14775 , l_wct_rec.demand_class
14776 , l_wct_rec.qa_collection_id
14777 , l_wct_rec.kanban_card_id
14778 , l_wct_rec.overcompletion_txn_qty
14779 , l_wct_rec.overcompletion_primary_qty
14780 , l_wct_rec.overcompletion_transaction_id
14781 , l_wct_rec.end_item_unit_number
14782 , l_wct_rec.scheduled_payback_date
14783 , l_wct_rec.line_type_code
14784 , l_wct_rec.parent_transaction_temp_id
14785 , l_wct_rec.put_away_strategy_id
14786 , l_wct_rec.put_away_rule_id
14787 , l_wct_rec.pick_strategy_id
14788 , l_wct_rec.pick_rule_id
14789 , l_wct_rec.move_order_line_id
14790 , l_wct_rec.task_group_id
14791 , l_wct_rec.pick_slip_number
14792 , l_wct_rec.reservation_id
14793 , l_wct_rec.common_bom_seq_id
14794 , l_wct_rec.common_routing_seq_id
14795 , l_wct_rec.org_cost_group_id
14796 , l_wct_rec.cost_type_id
14797 , l_wct_rec.transaction_status
14798 , l_wct_rec.standard_operation_id
14799 , l_wct_rec.task_priority
14800 , l_wct_rec.wms_task_type
14801 , l_wct_rec.parent_line_id
14802 , l_wct_rec.lpn_id
14803 , l_wct_rec.transfer_lpn_id
14804 , l_wct_rec.wms_task_status
14805 , l_wct_rec.content_lpn_id
14806 , l_wct_rec.container_item_id
14807 , l_wct_rec.cartonization_id
14808 , l_wct_rec.pick_slip_date
14809 , l_wct_rec.rebuild_item_id
14810 , l_wct_rec.rebuild_serial_number
14811 , l_wct_rec.rebuild_activity_id
14812 , l_wct_rec.rebuild_job_name
14813 , l_wct_rec.organization_type
14814 , l_wct_rec.transfer_organization_type
14815 , l_wct_rec.owning_organization_id
14816 , l_wct_rec.owning_tp_type
14817 , l_wct_rec.xfr_owning_organization_id
14818 , l_wct_rec.transfer_owning_tp_type
14819 , l_wct_rec.planning_organization_id
14820 , l_wct_rec.planning_tp_type
14821 , l_wct_rec.xfr_planning_organization_id
14822 , l_wct_rec.transfer_planning_tp_type
14823 , l_wct_rec.secondary_uom_code
14824 , l_wct_rec.secondary_transaction_quantity
14825 , l_wct_rec.transaction_batch_id
14826 , l_wct_rec.transaction_batch_seq
14827 , l_wct_rec.allocated_lpn_id
14828 , l_wct_rec.schedule_number
14829 , l_wct_rec.scheduled_flag
14830 , l_wct_rec.class_code
14831 , l_wct_rec.schedule_group
14832 , l_wct_rec.build_sequence
14833 , l_wct_rec.bom_revision
14834 , l_wct_rec.routing_revision
14835 , l_wct_rec.bom_revision_date
14836 , l_wct_rec.routing_revision_date
14837 , l_wct_rec.alternate_bom_designator
14838 , l_wct_rec.alternate_routing_designator
14839 , l_wct_rec.operation_plan_id
14840 , l_wct_rec.serial_allocated_flag
14841 , l_wct_rec.move_order_header_id
14842 , l_wct_rec.fulfillment_base
14843 );
14844 END insert_wct;
14845
14846 PROCEDURE insert_mtlt --Bug 9473783 added procedure
14847 (p_transaction_temp_id NUMBER,
14848 x_return_status OUT NOCOPY VARCHAR2,
14849 x_msg_count OUT NOCOPY NUMBER,
14850 x_msg_data OUT NOCOPY VARCHAR2)
14851 IS
14852
14853 CURSOR mmtt IS
14854 SELECT * FROM mtl_material_transactions_temp
14855 WHERE transaction_temp_id = p_transaction_temp_id ;
14856
14857 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
14858 l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
14859 BEGIN
14860 x_return_status := fnd_api.g_ret_sts_success;
14861
14862 OPEN mmtt;
14863 FETCH mmtt INTO l_mmtt_rec;
14864
14865 CLOSE mmtt;
14866
14867 INSERT INTO mtl_transaction_lots_temp
14868 (
14869 transaction_temp_id
14870 , last_update_date
14871 , last_updated_by
14872 , creation_date
14873 , created_by
14874 , last_update_login
14875 , request_id
14876 , program_application_id
14877 , program_id
14878 , program_update_date
14879 , transaction_quantity
14880 , primary_quantity
14881 , secondary_quantity --INVCONV Mercy Thomas 09/24/2004
14882 , secondary_unit_of_measure --INVCONV Mercy Thomas 09/24/2004
14883 , lot_number
14884 , lot_expiration_date
14885 , group_header_id
14886 , reason_id
14887 )
14888 VALUES ( l_mmtt_rec.transaction_temp_id
14889 , l_mmtt_rec.last_update_date
14890 , l_mmtt_rec.last_updated_by
14891 , l_mmtt_rec.creation_date
14892 , l_mmtt_rec.created_by
14893 , l_mmtt_rec.last_update_login
14894 , l_mmtt_rec.request_id
14895 , l_mmtt_rec.program_application_id
14896 , l_mmtt_rec.program_id
14897 , l_mmtt_rec.program_update_date
14898 , DECODE(l_mmtt_rec.fulfillment_base, 'S', l_mmtt_rec.secondary_transaction_quantity, l_mmtt_rec.transaction_quantity) --muom:sk
14899 , l_mmtt_rec.primary_quantity
14900 , l_mmtt_rec.secondary_transaction_quantity
14901 , l_mmtt_rec.secondary_uom_code
14902 , l_mmtt_rec.lot_number
14903 , l_mmtt_rec.lot_expiration_date
14904 , l_mmtt_rec.transaction_header_id
14905 , l_mmtt_rec.reason_id );
14906
14907
14908 EXCEPTION
14909 WHEN OTHERS THEN
14910 IF (l_debug = 1) THEN
14911 print_debug('INSERT_MTLT : Exception Occured ' || substrb(SQLERRM,1,200), 1);
14912 END IF;
14913 x_return_status := fnd_api.g_ret_sts_unexp_error;
14914
14915 END insert_mtlt;
14916
14917 END wms_task_dispatch_engine;