[Home] [Help]
PACKAGE BODY: APPS.WMS_TASK_DISPATCH_ENGINE
Source
1 PACKAGE BODY wms_task_dispatch_engine AS
2 /* $Header: WMSTDENB.pls 120.13.12010000.4 2008/10/23 06:37:43 avuppala 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 -- bug 4358107
168 -- APL procedure: Used since 11.5.10
169 PROCEDURE dispatch_task
170 (p_api_version IN NUMBER,
171 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
172 p_commit IN VARCHAR2 := fnd_api.g_false,
173 p_sign_on_emp_id IN NUMBER,
174 p_sign_on_org_id IN NUMBER,
175 p_sign_on_zone IN VARCHAR2 := NULL,
176 p_sign_on_equipment_id IN NUMBER := NULL, -- specific equip idNULL or -999. -999 stands for none
177 p_sign_on_equipment_srl IN VARCHAR2 := NULL, -- same as above
178 p_task_filter IN VARCHAR2,
179 p_task_method IN VARCHAR2,
180 x_grouping_document_type IN OUT nocopy VARCHAR2,
181 x_grouping_document_number IN OUT nocopy NUMBER,
182 x_grouping_source_type_id IN OUT nocopy NUMBER,
183 x_task_cur OUT NOCOPY task_rec_cur_tp,
184 x_return_status OUT NOCOPY VARCHAR2,
185 x_msg_count OUT NOCOPY NUMBER,
186 x_msg_data OUT NOCOPY VARCHAR2)
187 IS
188
189 l_cur_x NUMBER;
190 l_cur_y NUMBER;
191 l_cur_z NUMBER;
192
193 l_task_priority NUMBER;
194 l_sub_pick_order NUMBER;
195 l_loc_pick_order NUMBER;
196 l_x_coordinate NUMBER;
197 l_y_coordinate NUMBER;
198 l_z_coordinate NUMBER;
199 l_is_locked BOOLEAN := FALSE;
200
201 l_sign_on_equipment_id NUMBER;
202 l_sign_on_equipment_srl VARCHAR2(30);
203
204
205 l_last_loaded_time DATE;
206 l_last_loaded_task_id NUMBER;
207 l_last_loaded_task_type NUMBER;
208 l_last_dropoff_time DATE;
209 l_last_dropoff_task_id NUMBER;
210 l_last_dropoff_task_type NUMBER;
211 l_last_task_type NUMBER;
212 l_last_task_is_drop BOOLEAN := FALSE;
213 l_last_task_id NUMBER;
214 l_lpn_id NUMBER; --Added for bug# 3853837
215 l_wdt_count NUMBER; --Added for bug# 3853837
216 l_ordered_tasks_count NUMBER;
217 l_first_task_pick_slip_number NUMBER;
218 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
219 l_api_version CONSTANT NUMBER := 1.0;
220 l_progress VARCHAR2(10);
221 l_sequence_picks_across_waves NUMBER := 2;
222
223 l_so_allowed NUMBER := 0;
224 l_io_allowed NUMBER := 0;
225 l_wip_allowed NUMBER := 0;
226 l_mot_rep_allowed NUMBER := 0;
227 l_mot_allowed NUMBER := 0;
228 l_rep_allowed NUMBER := 0;
229 l_mot_moi_allowed NUMBER := 0;
230 l_moi_allowed NUMBER := 0;
231 l_cc_allowed NUMBER := 0;
232 l_non_cc_allowed NUMBER := 0;
233
234 l_task_id NUMBER;
235 l_subinventory_code VARCHAR2(10);
236 l_locator_id NUMBER;
237 l_task_type_id NUMBER;
238 l_cartonization_id NUMBER;
239 l_batch_id NUMBER;
240 l_pick_slip NUMBER := 0;
241 l_distance NUMBER;
242 l_task_status NUMBER;
243 l_transaction_quantity NUMBER;
244 l_transaction_uom VARCHAR2(3);
245 l_transaction_action_id NUMBER;
246 l_transaction_type_id NUMBER;
247 l_transaction_source_type_id NUMBER;
248 l_transaction_source_id NUMBER;
249 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
250 l_lot_number VARCHAR2(80);
251 l_revision VARCHAR2(3);
252 l_operation_plan_id NUMBER;
253 l_move_order_line_id NUMBER;
254 l_standard_operation_id NUMBER;
255 l_effective_start_date DATE;
256 l_effective_end_date DATE;
257 l_person_resource_id NUMBER;
258 l_machine_resource_id NUMBER;
259 -- bug 4358107
260 l_return_status VARCHAR2(1);
261 -- bug 4358107
262 l_q_sign_on_equipment_id NUMBER; --bug 6017284
263 l_ignore_equipment NUMBER; --bug 6017284
264
265 l_total_lpns NUMBER; --Bug 7254397
266 l_locked_lpns NUMBER; --Bug 7254397
267
268 /* Bug 3808770
269 Added condition in all the cursors selecting cycle count tasks to select
270 only those tasks whose cycle count have not been disabled by entering
271 an Inactive Date.
272 Added the table mtl_cycle_count_headers in the FROM clause and joined with
273 mtl_cycle_count_entries and checked for disable_date value with sysdate.
274 */
275
276 -- Cursor #1 for selecting the most optimal task
277 -- 1. Sub is passed (1)
278 -- 2. Non cycle count tasks (1)
279 -- 3. Cycle count tasks (1)
280 CURSOR l_curs_opt_task_111 IS
281 SELECT DISTINCT
282 qt.task_id task_num,
283 qt.pick_slip,
284 wdt.task_type wms_task_type_id,
285 nvl(wdt.priority, 0) task_priority,
286 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
287 sub.picking_order sub_picking_order,
288 loc.picking_order loc_picking_order,
289 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
290 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
291 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
292 wdt.status task_status, --bug 4310093
293 qt.transaction_type_id,
294 qt.transaction_action_id,
295 qt.transaction_source_id,
296 qt.transaction_source_type_id
297 FROM wms_dispatched_tasks wdt,
298 (SELECT
299 transaction_temp_id task_id,
300 pick_slip_number pick_slip,
301 cartonization_id,
302 organization_id,
303 subinventory_code,
304 locator_id,
305 move_order_line_id,
306 transaction_type_id,
307 transaction_action_id,
308 transaction_source_id,
309 transaction_source_type_id
310 FROM mtl_material_transactions_temp mmtt
311 WHERE wms_task_type IS NOT NULL
312 AND transaction_temp_id = Decode(p_task_method, 'BULK',
313 parent_line_id, transaction_temp_id)
314 AND Decode(transaction_source_type_id,
315 2, l_so_allowed,
316 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
317 5, Decode(transaction_type_id, 35, l_wip_allowed),
318 8, l_io_allowed,
319 13, Decode(transaction_type_id,
320 51, l_wip_allowed,
321 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
322 --7169220: USERS LOCKED
323 AND (mmtt.cartonization_id is null
324 or not exists
325 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
326 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
327 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
328 and wdt1.status = 9
329 and mmtt1.cartonization_id = mmtt.cartonization_id)
330 )
331 UNION ALL
332 SELECT
333 MIN(mcce.cycle_count_entry_id) task_id,
334 TO_NUMBER(NULL) pick_slip,
335 To_number(NULL) cartonization_id,
336 mcce.organization_id,
337 mcce.subinventory subinventory_code,
338 mcce.locator_id,
339 To_number(NULL) move_order_line_id,
340 4 transaction_type_id,
341 4 transaction_action_id,
342 mcce.cycle_count_header_id transaction_source_id,
343 9 transaction_source_type_id
344 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
345 WHERE mcce.entry_status_code IN(1, 3)
346 AND NVL(mcce.export_flag, 2) = 2
347 -- bug 3972076
348 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
349 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
350 AND NVL(mcch.disable_date,sysdate+1)> sysdate
351 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
352 mtl_txn_request_lines mol,
353 mtl_secondary_inventories sub,
354 mtl_item_locations loc,
355 (SELECT
356 bsor.standard_operation_id,
357 bre.resource_id,
358 bre.inventory_item_id equipment_id
359 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
360 WHERE bsor.resource_id = bre.resource_id
361 AND br.resource_type = 1
362 AND bsor.resource_id = br.resource_id) e
363 WHERE wdt.transaction_temp_id = qt.task_id
364 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
365 AND wdt.person_id = p_sign_on_emp_id
366 AND wdt.organization_id = p_sign_on_org_id
367 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
368 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
369 AND wdt.user_task_type = e.standard_operation_id(+)
370 AND qt.move_order_line_id = mol.line_id(+)
371 AND qt.subinventory_code = p_sign_on_zone
372 AND qt.organization_id = sub.organization_id
373 AND qt.subinventory_code = sub.secondary_inventory_name
374 AND qt.organization_id = loc.organization_id
375 AND qt.locator_id = loc.inventory_location_id
376 UNION ALL
377 SELECT DISTINCT
378 wdtv.task_id task_num,
379 NVL(wdtv.pick_slip_number, -1) pick_slip,
380 wdtv.wms_task_type_id,
381 nvl(wdtv.task_priority, 0),
382 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
383 sub.picking_order sub_picking_order,
384 loc.picking_order loc_picking_order,
385 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
386 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
387 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
388 task_status,
389 wdtv.transaction_type_id,
390 wdtv.transaction_action_id,
391 wdtv.transaction_source_id,
392 wdtv.transaction_source_type_id
393 FROM
394 -- inlined wms_dispatchable_tasks_v, bug 2648133
395 (SELECT
396 transaction_temp_id task_id,
397 standard_operation_id user_task_type_id,
398 wms_task_type wms_task_type_id,
399 organization_id,
400 subinventory_code zone,
401 locator_id,
402 task_priority,
403 revision,
404 lot_number,
405 transaction_uom,
406 transaction_quantity,
407 pick_rule_id,
408 pick_slip_number,
409 cartonization_id,
410 inventory_item_id,
411 move_order_line_id,
412 1 task_status,
413 transaction_type_id,
414 transaction_action_id,
415 transaction_source_id,
416 transaction_source_type_id
417 FROM mtl_material_transactions_temp mmtt
418 WHERE wms_task_type IS NOT NULL
419 AND transaction_status = 2
420 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
421 AND transaction_temp_id = Decode(p_task_method, 'BULK',
422 parent_line_id, transaction_temp_id)
423 AND Decode(transaction_source_type_id,
424 2, l_so_allowed,
425 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
426 5, Decode(transaction_type_id, 35, l_wip_allowed),
427 8, l_io_allowed,
428 13, Decode(transaction_type_id,
429 51, l_wip_allowed,
430 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
431 --7169220: USERS LOCKED
432 AND (mmtt.cartonization_id is null
433 or not exists
434 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
435 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
436 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
437 and wdt1.status = 9
438 and mmtt1.cartonization_id = mmtt.cartonization_id)
439 )
440
441 UNION ALL
442 SELECT
443 MIN(mcce.cycle_count_entry_id) task_id,
444 MIN(mcce.standard_operation_id) user_task_type_id,
445 3 wms_task_type_id,
446 mcce.organization_id,
447 mcce.subinventory zone,
448 mcce.locator_id,
449 MIN(mcce.task_priority) task_priority,
450 mcce.revision revision,
451 MIN(mcce.lot_number) lot_number,
452 '' transaction_uom,
453 TO_NUMBER(NULL) transaction_quantity,
454 TO_NUMBER(NULL) pick_rule_id,
455 TO_NUMBER(NULL) pick_slip_number,
456 TO_NUMBER(NULL) cartonization_id,
457 mcce.inventory_item_id,
458 TO_NUMBER(NULL) move_order_line_id,
459 1 task_status,
460 4 transaction_type_id,
461 4 transaction_action_id,
462 mcce.cycle_count_header_id transaction_source_id,
463 9 transaction_source_type_id
464 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
465 WHERE mcce.entry_status_code IN(1, 3)
466 AND NVL(mcce.export_flag, 2) = 2
467 -- bug 3972076
468 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
469 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
470
471 -----bug6903708---
472 AND mcce.organization_id = mcch.organization_id
473 AND mcch.organization_id = p_sign_on_org_id
474 ---------------------------
475
476 AND NVL(mcch.disable_date,sysdate+1)> sysdate
477 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
478 -- inlined wms_person_resource_utt_v, bug 2648133
479 (SELECT
480 utt_emp.standard_operation_id standard_operation_id,
481 utt_emp.resource_id role,
482 utt_eqp.resource_id equipment,
483 utt_emp.person_id emp_id,
484 utt_eqp.inventory_item_id eqp_id,
485 NULL eqp_srl /* removed for bug 2095237 */
486 FROM
487 (SELECT
488 x_utt_res1.standard_operation_id standard_operation_id,
489 x_utt_res1.resource_id resource_id,
490 x_emp_r.person_id
491 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
492 WHERE x_utt_res1.resource_id = r1.resource_id
493 AND r1.resource_type = 2
494 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
495 (SELECT
496 x_utt_res2.standard_operation_id standard_operation_id,
497 x_utt_res2.resource_id,
498 x_eqp_r.inventory_item_id
499 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
500 WHERE x_utt_res2.resource_id = r2.resource_id
501 AND r2.resource_type = 1
502 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
503 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
504 mtl_item_locations loc,
505 mtl_secondary_inventories sub,
506 mtl_txn_request_lines mol,
507 mtl_txn_request_headers moh
508 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
509 AND wdtv.organization_id = p_sign_on_org_id
510 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
511 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
512 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
513 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
514 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
515 AND wdtv.locator_id = loc.inventory_location_id(+)
516 AND wdtv.zone = sub.secondary_inventory_name
517 AND wdtv.organization_id = sub.organization_id
518 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
519 AND moh.header_id(+) = mol.header_id
520 AND Decode(Nvl(moh.move_order_type, -1),
521 2, l_rep_allowed,
522 1, l_mot_moi_allowed,
523 -1, 1,
524 1) = 1
525 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
526 -- bug 4358107
527 AND NOT EXISTS
528 ( SELECT 1
529 FROM WMS_DISPATCH_TASKS_GTMP
530 WHERE (p_task_method = 'DISCRETE'
531 and
532 grouping_document_number = wdtv.pick_slip_number
533 )
534 or
535 (
536 p_task_method = 'ORDERPICK'
537 and
538 grouping_document_number = wdtv.transaction_source_id
539 and
540 grouping_source_type_id = wdtv.transaction_source_type_id
541 )
542 or
543 (p_task_method = 'PICKBYLABEL'
544 and
545 grouping_document_number = wdtv.cartonization_id
546 )
547 or --6598260 start
548 ( grouping_document_number = wdtv.cartonization_id
549 and
550 grouping_document_type = 'CARTON_TASK'
551 ) --6598260 end
552 )
553 -- bug 4358107
554 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
555 (SELECT NULL
556 FROM mtl_material_transactions_temp mmtt
557 WHERE mmtt.transaction_temp_id = wdtv.task_id
558 AND mmtt.parent_line_id IS NOT NULL
559 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
560 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
561 AND NOT EXISTS -- exclude tasks already dispatched and queued
562 (SELECT NULL
563 FROM wms_dispatched_tasks wdt1
564 WHERE wdt1.transaction_temp_id = wdtv.task_id
565 AND wdt1.task_type = wdtv.wms_task_type_id)
566 -- excluded skipped tasks
567 AND wdtv.task_id NOT IN
568 (SELECT wdtv.task_id
569 FROM wms_skip_task_exceptions wste, mtl_parameters mp
570 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
571 AND wste.task_id = wdtv.task_id
572 AND wste.organization_id = mp.organization_id)
573 --J Addition
574 AND wdtv.zone not in (
575 SELECT wd.subinventory_code
576 FROM wms_devices_b wd
577 , wms_bus_event_devices wbed
578 WHERE 1 = 1
579 and wd.device_id = wbed.device_id
580 AND wbed.organization_id = wd.organization_id
581 AND wd.enabled_flag = 'Y'
582 AND wbed.enabled_flag = 'Y'
583 AND wbed.business_event_id = 10
584 AND wd.subinventory_code IS NOT NULL
585 AND wd.force_sign_on_flag = 'Y'
586 AND wd.device_id NOT IN (SELECT device_id
587 FROM wms_device_assignment_temp
588 WHERE employee_id = p_sign_on_emp_id)
589 )
590 ORDER BY
591 task_priority desc,
592 batch_id,
593 task_status DESC,
594 sub_picking_order,
595 loc_picking_order,
596 distance,
597 task_num;
598
599 -- Cursor #2 for selecting the most optimal task
600 -- 1. Sub is passed (1)
601 -- 2. Non cycle count tasks (1)
602 -- 3. Cycle count tasks (0)
603 CURSOR l_curs_opt_task_110 IS
604 SELECT DISTINCT
605 qt.task_id task_num,
606 qt.pick_slip,
607 wdt.task_type wms_task_type_id,
608 nvl(wdt.priority, 0) task_priority,
609 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
610 sub.picking_order sub_picking_order,
611 loc.picking_order loc_picking_order,
612 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
613 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
614 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
615 wdt.status task_status, --bug 4310093
616 qt.transaction_type_id,
617 qt.transaction_action_id,
618 qt.transaction_source_id,
619 qt.transaction_source_type_id
620 FROM wms_dispatched_tasks wdt,
621 (SELECT
622 transaction_temp_id task_id,
623 pick_slip_number pick_slip,
624 cartonization_id,
625 organization_id,
626 subinventory_code,
627 locator_id,
628 move_order_line_id,
629 transaction_type_id,
630 transaction_action_id,
631 transaction_source_id,
632 transaction_source_type_id
633 FROM mtl_material_transactions_temp mmtt
634 WHERE wms_task_type IS NOT NULL
635 AND transaction_temp_id = Decode(p_task_method, 'BULK',
636 parent_line_id, transaction_temp_id)
637 AND Decode(transaction_source_type_id,
638 2, l_so_allowed,
639 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
640 5, Decode(transaction_type_id, 35, l_wip_allowed),
641 8, l_io_allowed,
642 13, Decode(transaction_type_id,
643 51, l_wip_allowed,
644 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
645 --7169220: USERS LOCKED
646 AND (mmtt.cartonization_id is null
647 or not exists
648 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
649 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
650 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
651 and wdt1.status = 9
652 and mmtt1.cartonization_id = mmtt.cartonization_id)
653 )
654 ) qt,
655 mtl_txn_request_lines mol,
656 mtl_secondary_inventories sub,
657 mtl_item_locations loc,
658 (SELECT
659 bsor.standard_operation_id,
660 bre.resource_id,
661 bre.inventory_item_id equipment_id
662 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
663 WHERE bsor.resource_id = bre.resource_id
664 AND br.resource_type = 1
665 AND bsor.resource_id = br.resource_id) e
666 WHERE wdt.transaction_temp_id = qt.task_id
667 AND wdt.status = 2 --bug 6326482queued task only bug -- Queued and dispatched tasks only bug 4310093
668 AND wdt.person_id = p_sign_on_emp_id
669 AND wdt.organization_id = p_sign_on_org_id
670 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
671 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))--bug 6326482
672 AND wdt.user_task_type = e.standard_operation_id(+)
673 AND qt.move_order_line_id = mol.line_id(+)
674 AND qt.subinventory_code = p_sign_on_zone
675 AND qt.organization_id = sub.organization_id
676 AND qt.subinventory_code = sub.secondary_inventory_name
677 AND qt.organization_id = loc.organization_id
678 AND qt.locator_id = loc.inventory_location_id
679 UNION ALL
680 --bug 6326482 for dispatched tasks
681 SELECT DISTINCT
682 qt.task_id task_num,
683 qt.pick_slip,
684 wdt.task_type wms_task_type_id,
685 nvl(wdt.priority, 0) task_priority,
686 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
687 sub.picking_order sub_picking_order,
688 loc.picking_order loc_picking_order,
689 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
690 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
691 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
692 wdt.status task_status,
693 qt.transaction_type_id,
694 qt.transaction_action_id,
695 qt.transaction_source_id,
696 qt.transaction_source_type_id
697 FROM wms_dispatched_tasks wdt,
698 (SELECT
699 transaction_temp_id task_id,
700 wms_task_status task_status,--bug 6326482 added to know the previous state of dispatched tasks
701 pick_slip_number pick_slip,
702 cartonization_id,
703 organization_id,
704 subinventory_code,
705 locator_id,
706 move_order_line_id,
707 transaction_type_id,
708 transaction_action_id,
709 transaction_source_id,
710 transaction_source_type_id
711 FROM mtl_material_transactions_temp mmtt
712 WHERE wms_task_type IS NOT NULL
713 AND transaction_temp_id = Decode(p_task_method, 'BULK',
714 parent_line_id, transaction_temp_id)
715 AND Decode(transaction_source_type_id,
716 2, l_so_allowed,
717 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
718 5, Decode(transaction_type_id, 35, l_wip_allowed),
719 8, l_io_allowed,
720 13, Decode(transaction_type_id,
721 51, l_wip_allowed,
722 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
723 --7169220: USERS LOCKED
724 AND (mmtt.cartonization_id is null
725 or not exists
726 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
727 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
728 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
729 and wdt1.status = 9
730 and mmtt1.cartonization_id = mmtt.cartonization_id)
731 )
732 ) qt,
733 mtl_txn_request_lines mol,
734 mtl_secondary_inventories sub,
735 mtl_item_locations loc,
736 (SELECT
737 bsor.standard_operation_id,
738 bre.resource_id,
739 bre.inventory_item_id equipment_id
740 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
741 WHERE bsor.resource_id = bre.resource_id
742 AND br.resource_type = 1
743 AND bsor.resource_id = br.resource_id) e
744 WHERE wdt.transaction_temp_id = qt.task_id
745 AND wdt.status = 3 -- bug 6326482 dispatched tasks
746 AND wdt.person_id = p_sign_on_emp_id
747 AND wdt.organization_id = p_sign_on_org_id
748 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
749 --bug 6326482
750 AND ((qt.task_status is NULL
751 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
752 or
753 (qt.task_status = 1
754 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
755 AND wdt.user_task_type = e.standard_operation_id(+)
756 AND qt.move_order_line_id = mol.line_id(+)
757 AND qt.subinventory_code = p_sign_on_zone
758 AND qt.organization_id = sub.organization_id
759 AND qt.subinventory_code = sub.secondary_inventory_name
760 AND qt.organization_id = loc.organization_id
761 AND qt.locator_id = loc.inventory_location_id
762 UNION ALL
763 SELECT DISTINCT
764 wdtv.task_id task_num,
765 NVL(wdtv.pick_slip_number, -1) pick_slip,
766 wdtv.wms_task_type_id,
767 nvl(wdtv.task_priority, 0),
768 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
769 sub.picking_order sub_picking_order,
770 loc.picking_order loc_picking_order,
771 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
772 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
773 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
774 task_status,
775 wdtv.transaction_type_id,
776 wdtv.transaction_action_id,
777 wdtv.transaction_source_id,
778 wdtv.transaction_source_type_id
779 FROM
780 -- inlined wms_dispatchable_tasks_v, bug 2648133
781 (SELECT
782 transaction_temp_id task_id,
783 standard_operation_id user_task_type_id,
784 wms_task_type wms_task_type_id,
785 organization_id,
786 subinventory_code zone,
787 locator_id,
788 task_priority,
789 revision,
790 lot_number,
791 transaction_uom,
792 transaction_quantity,
793 pick_rule_id,
794 pick_slip_number,
795 cartonization_id,
796 inventory_item_id,
797 move_order_line_id,
798 1 task_status,
799 transaction_type_id,
800 transaction_action_id,
801 transaction_source_id,
802 transaction_source_type_id
803 FROM mtl_material_transactions_temp mmtt
804 WHERE wms_task_type IS NOT NULL
805 AND transaction_status = 2
806 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
807 AND transaction_temp_id = Decode(p_task_method, 'BULK',
808 parent_line_id, transaction_temp_id)
809 AND Decode(transaction_source_type_id,
810 2, l_so_allowed,
811 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
812 5, Decode(transaction_type_id, 35, l_wip_allowed),
813 8, l_io_allowed,
814 13, Decode(transaction_type_id,
815 51, l_wip_allowed,
816 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
817 --7169220: USERS LOCKED
818 AND (mmtt.cartonization_id is null
819 or not exists
820 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
821 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
822 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
823 and wdt1.status = 9
824 and mmtt1.cartonization_id = mmtt.cartonization_id)
825 )
826 ) wdtv,
827 -- inlined wms_person_resource_utt_v, bug 2648133
828 (SELECT
829 utt_emp.standard_operation_id standard_operation_id,
830 utt_emp.resource_id role,
831 utt_eqp.resource_id equipment,
832 utt_emp.person_id emp_id,
833 utt_eqp.inventory_item_id eqp_id,
834 NULL eqp_srl /* removed for bug 2095237 */
835 FROM
836 (SELECT
837 x_utt_res1.standard_operation_id standard_operation_id,
838 x_utt_res1.resource_id resource_id,
839 x_emp_r.person_id
840 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
841 WHERE x_utt_res1.resource_id = r1.resource_id
842 AND r1.resource_type = 2
843 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
844 (SELECT
845 x_utt_res2.standard_operation_id standard_operation_id,
846 x_utt_res2.resource_id,
847 x_eqp_r.inventory_item_id
848 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
849 WHERE x_utt_res2.resource_id = r2.resource_id
850 AND r2.resource_type = 1
851 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
852 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
853 mtl_item_locations loc,
854 mtl_secondary_inventories sub,
855 mtl_txn_request_lines mol,
856 mtl_txn_request_headers moh
857 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
858 AND wdtv.organization_id = p_sign_on_org_id
859 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
860 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
861 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
862 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
863 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
864 AND wdtv.locator_id = loc.inventory_location_id(+)
865 AND wdtv.zone = sub.secondary_inventory_name
866 AND wdtv.organization_id = sub.organization_id
867 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
868 AND moh.header_id(+) = mol.header_id
869 AND Decode(Nvl(moh.move_order_type, -1),
870 2, l_rep_allowed,
871 1, l_mot_moi_allowed,
872 -1, 1,
873 1) = 1
874 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
875 -- bug 4358107
876 AND NOT EXISTS
877 ( SELECT 1
878 FROM WMS_DISPATCH_TASKS_GTMP
879 WHERE (p_task_method = 'DISCRETE'
880 and
881 grouping_document_number = wdtv.pick_slip_number
882 )
883 or
884 (
885 p_task_method = 'ORDERPICK'
886 and
887 grouping_document_number = wdtv.transaction_source_id
888 and
889 grouping_source_type_id = wdtv.transaction_source_type_id
890 )
891 or
892 (p_task_method = 'PICKBYLABEL'
893 and
894 grouping_document_number = wdtv.cartonization_id
895 )
896 or --6598260 start
897 ( grouping_document_number = wdtv.cartonization_id
898 and
899 grouping_document_type = 'CARTON_TASK'
900 ) --6598260 end
901 )
902 -- bug 4358107
903 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
904 (SELECT NULL
905 FROM mtl_material_transactions_temp mmtt
906 WHERE mmtt.transaction_temp_id = wdtv.task_id
907 AND mmtt.parent_line_id IS NOT NULL
908 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
909 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
910 AND NOT EXISTS -- exclude tasks already dispatched and queued
911 (SELECT NULL
912 FROM wms_dispatched_tasks wdt1
913 WHERE wdt1.transaction_temp_id = wdtv.task_id
914 AND wdt1.task_type = wdtv.wms_task_type_id)
915 -- excluded skipped tasks
916 AND wdtv.task_id NOT IN
917 (SELECT wdtv.task_id
918 FROM wms_skip_task_exceptions wste, mtl_parameters mp
919 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
920 AND wste.task_id = wdtv.task_id
921 AND wste.organization_id = mp.organization_id)
922 --J Addition
923 AND wdtv.zone not in (
924 SELECT wd.subinventory_code
925 FROM wms_devices_b wd
926 , wms_bus_event_devices wbed
927 WHERE 1 = 1
928 and wd.device_id = wbed.device_id
929 AND wbed.organization_id = wd.organization_id
930 AND wd.enabled_flag = 'Y'
931 AND wbed.enabled_flag = 'Y'
932 AND wbed.business_event_id = 10
933 AND wd.subinventory_code IS NOT NULL
934 AND wd.force_sign_on_flag = 'Y'
935 AND wd.device_id NOT IN (SELECT device_id
936 FROM wms_device_assignment_temp
937 WHERE employee_id = p_sign_on_emp_id)
938 )
939 ORDER BY
940 task_priority desc,
941 batch_id,
942 task_status DESC,
943 sub_picking_order,
944 loc_picking_order,
945 distance,
946 task_num;
947
948 -- Cursor #3 for selecting the most optimal task
949 -- 1. Sub is passed (1)
950 -- 2. Non cycle count tasks (0)
951 -- 3. Cycle count tasks (1)
952 CURSOR l_curs_opt_task_101 IS
953 SELECT DISTINCT
954 qt.task_id task_num,
955 qt.pick_slip,
956 wdt.task_type wms_task_type_id,
957 nvl(wdt.priority, 0) task_priority,
958 To_number (NULL) batch_id,
959 sub.picking_order sub_picking_order,
960 loc.picking_order loc_picking_order,
961 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
962 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
963 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
964 wdt.status task_status, --bug 4310093
965 qt.transaction_type_id,
966 qt.transaction_action_id,
967 qt.transaction_source_id,
968 qt.transaction_source_type_id
969 FROM wms_dispatched_tasks wdt,
970 (SELECT
971 MIN(mcce.cycle_count_entry_id) task_id,
972 TO_NUMBER(NULL) pick_slip,
973 To_number(NULL) cartonization_id,
974 mcce.organization_id,
975 mcce.subinventory subinventory_code,
976 mcce.locator_id,
977 To_number(NULL) move_order_line_id,
978 4 transaction_type_id,
979 4 transaction_action_id,
980 mcce.cycle_count_header_id transaction_source_id,
981 9 transaction_source_type_id
982 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
983 WHERE mcce.entry_status_code IN(1, 3)
984 AND NVL(mcce.export_flag, 2) = 2
985 -- bug 3972076
986 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
987 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
988 -----bug6903708---
989
990 AND mcce.organization_id = mcch.organization_id
991 AND mcch.organization_id = p_sign_on_org_id
992
993 ---------------------------
994
995 AND NVL(mcch.disable_date,sysdate+1)> sysdate
996 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
997 mtl_secondary_inventories sub,
998 mtl_item_locations loc,
999 (SELECT
1000 bsor.standard_operation_id,
1001 bre.resource_id,
1002 bre.inventory_item_id equipment_id
1003 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1004 WHERE bsor.resource_id = bre.resource_id
1005 AND br.resource_type = 1
1006 AND bsor.resource_id = br.resource_id) e
1007 WHERE wdt.transaction_temp_id = qt.task_id
1008 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
1009 AND wdt.person_id = p_sign_on_emp_id
1010 AND wdt.organization_id = p_sign_on_org_id
1011 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1012 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1013 AND wdt.user_task_type = e.standard_operation_id(+)
1014 AND qt.organization_id = sub.organization_id
1015 AND qt.subinventory_code = p_sign_on_zone
1016 AND qt.subinventory_code = sub.secondary_inventory_name
1017 AND qt.organization_id = loc.organization_id
1018 AND qt.locator_id = loc.inventory_location_id
1019 UNION ALL
1020 SELECT DISTINCT
1021 wdtv.task_id task_num,
1022 NVL(wdtv.pick_slip_number, -1) pick_slip,
1023 wdtv.wms_task_type_id,
1024 nvl(wdtv.task_priority, 0),
1025 To_number(NULL) batch_id,
1026 sub.picking_order sub_picking_order,
1027 loc.picking_order loc_picking_order,
1028 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1029 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1030 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1031 task_status,
1032 wdtv.transaction_type_id,
1033 wdtv.transaction_action_id,
1034 wdtv.transaction_source_id,
1035 wdtv.transaction_source_type_id
1036 FROM
1037 -- inlined wms_dispatchable_tasks_v, bug 2648133
1038 (SELECT
1039 MIN(mcce.cycle_count_entry_id) task_id,
1040 MIN(mcce.standard_operation_id) user_task_type_id,
1041 3 wms_task_type_id,
1042 mcce.organization_id,
1043 mcce.subinventory zone,
1044 mcce.locator_id,
1045 MIN(mcce.task_priority) task_priority,
1046 mcce.revision revision,
1047 MIN(mcce.lot_number) lot_number,
1048 '' transaction_uom,
1049 TO_NUMBER(NULL) transaction_quantity,
1050 TO_NUMBER(NULL) pick_rule_id,
1051 TO_NUMBER(NULL) pick_slip_number,
1052 TO_NUMBER(NULL) cartonization_id,
1053 mcce.inventory_item_id,
1054 TO_NUMBER(NULL) move_order_line_id,
1055 1 task_status,
1056 4 transaction_type_id,
1057 4 transaction_action_id,
1058 mcce.cycle_count_header_id transaction_source_id,
1059 9 transaction_source_type_id
1060 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1061 WHERE mcce.entry_status_code IN(1, 3)
1062 AND NVL(mcce.export_flag, 2) = 2
1063 -- bug 3972076
1064 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1065 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1066 -----bug6903708---
1067 AND mcce.organization_id = mcch.organization_id
1068 AND mcch.organization_id = p_sign_on_org_id
1069 ---------------------------
1070
1071 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1072 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
1073 -- inlined wms_person_resource_utt_v, bug 2648133
1074 (SELECT
1075 utt_emp.standard_operation_id standard_operation_id,
1076 utt_emp.resource_id role,
1077 utt_eqp.resource_id equipment,
1078 utt_emp.person_id emp_id,
1079 utt_eqp.inventory_item_id eqp_id,
1080 NULL eqp_srl /* removed for bug 2095237 */
1081 FROM
1082 (SELECT
1083 x_utt_res1.standard_operation_id standard_operation_id,
1084 x_utt_res1.resource_id resource_id,
1085 x_emp_r.person_id
1086 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1087 WHERE x_utt_res1.resource_id = r1.resource_id
1088 AND r1.resource_type = 2
1089 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1090 (SELECT
1091 x_utt_res2.standard_operation_id standard_operation_id,
1092 x_utt_res2.resource_id,
1093 x_eqp_r.inventory_item_id
1094 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1095 WHERE x_utt_res2.resource_id = r2.resource_id
1096 AND r2.resource_type = 1
1097 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1098 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1099 mtl_item_locations loc,
1100 mtl_secondary_inventories sub
1101 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1102 AND wdtv.organization_id = p_sign_on_org_id
1103 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1104 AND wdtv.zone = p_sign_on_zone -- removed NVL, bug 2648133
1105 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1106 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1107 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1108 AND wdtv.locator_id = loc.inventory_location_id(+)
1109 AND wdtv.zone = sub.secondary_inventory_name
1110 AND wdtv.organization_id = sub.organization_id
1111 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1112 -- bug 4358107
1113 AND NOT EXISTS
1114 ( SELECT 1
1115 FROM WMS_DISPATCH_TASKS_GTMP
1116 WHERE (p_task_method = 'DISCRETE'
1117 and
1118 grouping_document_number = wdtv.pick_slip_number
1119 )
1120 or
1121 (
1122 p_task_method = 'ORDERPICK'
1123 and
1124 grouping_document_number = wdtv.transaction_source_id
1125 and
1126 grouping_source_type_id = wdtv.transaction_source_type_id
1127 )
1128 or
1129 (p_task_method = 'PICKBYLABEL'
1130 and
1131 grouping_document_number = wdtv.cartonization_id
1132 )
1133 )
1134 -- bug 4358107
1135 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1136 (SELECT NULL
1137 FROM mtl_material_transactions_temp mmtt
1138 WHERE mmtt.transaction_temp_id = wdtv.task_id
1139 AND mmtt.parent_line_id IS NOT NULL
1140 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1141 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1142 AND NOT EXISTS -- exclude tasks already dispatched and queued
1143 (SELECT NULL
1144 FROM wms_dispatched_tasks wdt1
1145 WHERE wdt1.transaction_temp_id = wdtv.task_id
1146 AND wdt1.task_type = wdtv.wms_task_type_id)
1147 -- excluded skipped tasks
1148 AND wdtv.task_id NOT IN
1149 (SELECT wdtv.task_id
1150 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1151 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1152 AND wste.task_id = wdtv.task_id
1153 AND wste.organization_id = mp.organization_id)
1154 --J Addition
1155 AND wdtv.zone not in (
1156 SELECT wd.subinventory_code
1157 FROM wms_devices_b wd
1158 , wms_bus_event_devices wbed
1159 WHERE 1 = 1
1160 and wd.device_id = wbed.device_id
1161 AND wbed.organization_id = wd.organization_id
1162 AND wd.enabled_flag = 'Y'
1163 AND wbed.enabled_flag = 'Y'
1164 AND wbed.business_event_id = 10
1165 AND wd.subinventory_code IS NOT NULL
1166 AND wd.force_sign_on_flag = 'Y'
1167 AND wd.device_id NOT IN (SELECT device_id
1168 FROM wms_device_assignment_temp
1169 WHERE employee_id = p_sign_on_emp_id)
1170 )
1171 ORDER BY
1172 task_priority desc,
1173 task_status DESC,
1174 sub_picking_order,
1175 loc_picking_order,
1176 distance,
1177 task_num;
1178
1179 -- Cursor #4 for selecting the most optimal task
1180 -- 1. Sub is not passed (0)
1181 -- 2. Non cycle count tasks (1)
1182 -- 3. Cycle count tasks (1)
1183 CURSOR l_curs_opt_task_011 IS
1184 SELECT DISTINCT
1185 qt.task_id task_num,
1186 qt.pick_slip,
1187 wdt.task_type wms_task_type_id,
1188 nvl(wdt.priority, 0) task_priority,
1189 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1190 sub.picking_order sub_picking_order,
1191 loc.picking_order loc_picking_order,
1192 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1193 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1194 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1195 wdt.status task_status, --bug 4310093
1196 qt.transaction_type_id,
1197 qt.transaction_action_id,
1198 qt.transaction_source_id,
1199 qt.transaction_source_type_id
1200 FROM wms_dispatched_tasks wdt,
1201 (SELECT
1202 transaction_temp_id task_id,
1203 pick_slip_number pick_slip,
1204 cartonization_id,
1205 organization_id,
1206 subinventory_code,
1207 locator_id,
1208 move_order_line_id,
1209 transaction_type_id,
1210 transaction_action_id,
1211 transaction_source_id,
1212 transaction_source_type_id
1213 FROM mtl_material_transactions_temp mmtt
1214 WHERE wms_task_type IS NOT NULL
1215 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1216 parent_line_id, transaction_temp_id)
1217 AND Decode(transaction_source_type_id,
1218 2, l_so_allowed,
1219 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1220 5, Decode(transaction_type_id, 35, l_wip_allowed),
1221 8, l_io_allowed,
1222 13, Decode(transaction_type_id,
1223 51, l_wip_allowed,
1224 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1225 --7169220: USERS LOCKED
1226 AND (mmtt.cartonization_id is null
1227 or not exists
1228 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1229 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1230 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1231 and wdt1.status = 9
1232 and mmtt1.cartonization_id = mmtt.cartonization_id)
1233 )
1234
1235 UNION ALL
1236 SELECT
1237 MIN(mcce.cycle_count_entry_id) task_id,
1238 TO_NUMBER(NULL) pick_slip,
1239 To_number(NULL) cartonization_id,
1240 mcce.organization_id,
1241 mcce.subinventory subinventory_code,
1242 mcce.locator_id,
1243 To_number(NULL) move_order_line_id,
1244 4 transaction_type_id,
1245 4 transaction_action_id,
1246 mcce.cycle_count_header_id transaction_source_id,
1247 9 transaction_source_type_id
1248 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1249 WHERE mcce.entry_status_code IN(1, 3)
1250 AND NVL(mcce.export_flag, 2) = 2
1251 -- bug 3972076
1252 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1253 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1254 -----bug6903708---
1255 AND mcce.organization_id = mcch.organization_id
1256 AND mcch.organization_id = p_sign_on_org_id
1257 ---------------------------
1258 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1259 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
1260 mtl_txn_request_lines mol,
1261 mtl_secondary_inventories sub,
1262 mtl_item_locations loc,
1263 (SELECT
1264 bsor.standard_operation_id,
1265 bre.resource_id,
1266 bre.inventory_item_id equipment_id
1267 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1268 WHERE bsor.resource_id = bre.resource_id
1269 AND br.resource_type = 1
1270 AND bsor.resource_id = br.resource_id) e
1271 WHERE wdt.transaction_temp_id = qt.task_id
1272 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
1273 AND wdt.person_id = p_sign_on_emp_id
1274 AND wdt.organization_id = p_sign_on_org_id
1275 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1276 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1277 AND wdt.user_task_type = e.standard_operation_id(+)
1278 AND qt.move_order_line_id = mol.line_id(+)
1279 AND qt.organization_id = sub.organization_id
1280 AND qt.subinventory_code = sub.secondary_inventory_name
1281 AND qt.organization_id = loc.organization_id
1282 AND qt.locator_id = loc.inventory_location_id
1283 UNION ALL
1284 SELECT DISTINCT
1285 wdtv.task_id task_num,
1286 NVL(wdtv.pick_slip_number, -1) pick_slip,
1287 wdtv.wms_task_type_id,
1288 nvl(wdtv.task_priority, 0),
1289 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1290 sub.picking_order sub_picking_order,
1291 loc.picking_order loc_picking_order,
1292 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1293 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1294 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1295 task_status,
1296 wdtv.transaction_type_id,
1297 wdtv.transaction_action_id,
1298 wdtv.transaction_source_id,
1299 wdtv.transaction_source_type_id
1300 FROM
1301 -- inlined wms_dispatchable_tasks_v, bug 2648133
1302 (SELECT
1303 transaction_temp_id task_id,
1304 standard_operation_id user_task_type_id,
1305 wms_task_type wms_task_type_id,
1306 organization_id,
1307 subinventory_code zone,
1308 locator_id,
1309 task_priority,
1310 revision,
1311 lot_number,
1312 transaction_uom,
1313 transaction_quantity,
1314 pick_rule_id,
1315 pick_slip_number,
1316 cartonization_id,
1317 inventory_item_id,
1318 move_order_line_id,
1319 1 task_status,
1320 transaction_type_id,
1321 transaction_action_id,
1322 transaction_source_id,
1323 transaction_source_type_id
1324 FROM mtl_material_transactions_temp mmtt
1325 WHERE wms_task_type IS NOT NULL
1326 AND transaction_status = 2
1327 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
1328 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1329 parent_line_id, transaction_temp_id)
1330 AND Decode(transaction_source_type_id,
1331 2, l_so_allowed,
1332 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1333 5, Decode(transaction_type_id, 35, l_wip_allowed),
1334 8, l_io_allowed,
1335 13, Decode(transaction_type_id,
1336 51, l_wip_allowed,
1337 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1338 --7169220: USERS LOCKED
1339 AND (mmtt.cartonization_id is null
1340 or not exists
1341 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1342 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1343 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1344 and wdt1.status = 9
1345 and mmtt1.cartonization_id = mmtt.cartonization_id)
1346 )
1347
1348 UNION ALL
1349 SELECT
1350 MIN(mcce.cycle_count_entry_id) task_id,
1351 MIN(mcce.standard_operation_id) user_task_type_id,
1352 3 wms_task_type_id,
1353 mcce.organization_id,
1354 mcce.subinventory zone,
1355 mcce.locator_id,
1356 MIN(mcce.task_priority) task_priority,
1357 mcce.revision revision,
1358 MIN(mcce.lot_number) lot_number,
1359 '' transaction_uom,
1360 TO_NUMBER(NULL) transaction_quantity,
1361 TO_NUMBER(NULL) pick_rule_id,
1362 TO_NUMBER(NULL) pick_slip_number,
1363 TO_NUMBER(NULL) cartonization_id,
1364 mcce.inventory_item_id,
1365 TO_NUMBER(NULL) move_order_line_id,
1366 1 task_status,
1367 4 transaction_type_id,
1368 4 transaction_action_id,
1369 mcce.cycle_count_header_id transaction_source_id,
1370 9 transaction_source_type_id
1371 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1372 WHERE mcce.entry_status_code IN(1, 3)
1373 AND NVL(mcce.export_flag, 2) = 2
1374 -- bug 3972076
1375 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1376 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1377 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1378
1379 -----bug6903708---
1380 AND mcce.organization_id = mcch.organization_id
1381 AND mcch.organization_id = p_sign_on_org_id
1382 ---------------------------
1383
1384 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
1385 -- inlined wms_person_resource_utt_v, bug 2648133
1386 (SELECT
1387 utt_emp.standard_operation_id standard_operation_id,
1388 utt_emp.resource_id role,
1389 utt_eqp.resource_id equipment,
1390 utt_emp.person_id emp_id,
1391 utt_eqp.inventory_item_id eqp_id,
1392 NULL eqp_srl /* removed for bug 2095237 */
1393 FROM
1394 (SELECT
1395 x_utt_res1.standard_operation_id standard_operation_id,
1396 x_utt_res1.resource_id resource_id,
1397 x_emp_r.person_id
1398 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1399 WHERE x_utt_res1.resource_id = r1.resource_id
1400 AND r1.resource_type = 2
1401 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1402 (SELECT
1403 x_utt_res2.standard_operation_id standard_operation_id,
1404 x_utt_res2.resource_id,
1405 x_eqp_r.inventory_item_id
1406 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1407 WHERE x_utt_res2.resource_id = r2.resource_id
1408 AND r2.resource_type = 1
1409 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1410 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1411 mtl_item_locations loc,
1412 mtl_secondary_inventories sub,
1413 mtl_txn_request_lines mol,
1414 mtl_txn_request_headers moh
1415 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1416 AND wdtv.organization_id = p_sign_on_org_id
1417 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1418 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1419 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1420 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1421 AND wdtv.locator_id = loc.inventory_location_id(+)
1422 AND wdtv.zone = sub.secondary_inventory_name
1423 AND wdtv.organization_id = sub.organization_id
1424 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
1425 AND moh.header_id(+) = mol.header_id
1426 AND Decode(Nvl(moh.move_order_type, -1),
1427 2, l_rep_allowed,
1428 1, l_mot_moi_allowed,
1429 -1, 1,
1430 1) = 1
1431 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1432 -- bug 4358107
1433 AND NOT EXISTS
1434 ( SELECT 1
1435 FROM WMS_DISPATCH_TASKS_GTMP
1436 WHERE (p_task_method = 'DISCRETE'
1437 and
1438 grouping_document_number = wdtv.pick_slip_number
1439 )
1440 or
1441 (
1442 p_task_method = 'ORDERPICK'
1443 and
1444 grouping_document_number = wdtv.transaction_source_id
1445 and
1446 grouping_source_type_id = wdtv.transaction_source_type_id
1447 )
1448 or
1449 (p_task_method = 'PICKBYLABEL'
1450 and
1451 grouping_document_number = wdtv.cartonization_id
1452 )
1453 or --6598260 start
1454 ( grouping_document_number = wdtv.cartonization_id
1455 and
1456 grouping_document_type = 'CARTON_TASK'
1457 ) --6598260 end
1458 )
1459 -- bug 4358107
1460 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1461 (SELECT NULL
1462 FROM mtl_material_transactions_temp mmtt
1463 WHERE mmtt.transaction_temp_id = wdtv.task_id
1464 AND mmtt.parent_line_id IS NOT NULL
1465 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1466 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1467 AND NOT EXISTS -- exclude tasks already dispatched and queued
1468 (SELECT NULL
1469 FROM wms_dispatched_tasks wdt1
1470 WHERE wdt1.transaction_temp_id = wdtv.task_id
1471 AND wdt1.task_type = wdtv.wms_task_type_id)
1472 -- excluded skipped tasks
1473 AND wdtv.task_id NOT IN
1474 (SELECT wdtv.task_id
1475 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1476 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1477 AND wste.task_id = wdtv.task_id
1478 AND wste.organization_id = mp.organization_id)
1479 --J Addition
1480 AND wdtv.zone not in (
1481 SELECT wd.subinventory_code
1482 FROM wms_devices_b wd
1483 , wms_bus_event_devices wbed
1484 WHERE 1 = 1
1485 and wd.device_id = wbed.device_id
1486 AND wbed.organization_id = wd.organization_id
1487 AND wd.enabled_flag = 'Y'
1488 AND wbed.enabled_flag = 'Y'
1489 AND wbed.business_event_id = 10
1490 AND wd.subinventory_code IS NOT NULL
1491 AND wd.force_sign_on_flag = 'Y'
1492 AND wd.device_id NOT IN (SELECT device_id
1493 FROM wms_device_assignment_temp
1494 WHERE employee_id = p_sign_on_emp_id)
1495 )
1496
1497 ORDER BY
1498 task_priority desc,
1499 batch_id,
1500 task_status DESC,
1501 sub_picking_order,
1502 loc_picking_order,
1503 distance,
1504 task_num;
1505
1506 -- Cursor #5 for selecting the most optimal task
1507 -- 1. Sub is not passed (0)
1508 -- 2. Non cycle count tasks (1)
1509 -- 3. Cycle count tasks (0)
1510 CURSOR l_curs_opt_task_010 IS
1511 SELECT DISTINCT
1512 qt.task_id task_num,
1513 qt.pick_slip,
1514 wdt.task_type wms_task_type_id,
1515 nvl(wdt.priority, 0) task_priority,
1516 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1517 sub.picking_order sub_picking_order,
1518 loc.picking_order loc_picking_order,
1519 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1520 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1521 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1522 wdt.status task_status, --bug 4310093
1523 qt.transaction_type_id,
1524 qt.transaction_action_id,
1525 qt.transaction_source_id,
1526 qt.transaction_source_type_id
1527 FROM wms_dispatched_tasks wdt,
1528 (SELECT
1529 transaction_temp_id task_id,
1530 pick_slip_number pick_slip,
1531 cartonization_id,
1532 organization_id,
1533 subinventory_code,
1534 locator_id,
1535 move_order_line_id,
1536 transaction_type_id,
1537 transaction_action_id,
1538 transaction_source_id,
1539 transaction_source_type_id
1540 FROM mtl_material_transactions_temp mmtt
1541 WHERE wms_task_type IS NOT NULL
1542 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1543 parent_line_id, transaction_temp_id)
1544 AND Decode(transaction_source_type_id,
1545 2, l_so_allowed,
1546 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1547 5, Decode(transaction_type_id, 35, l_wip_allowed),
1548 8, l_io_allowed,
1549 13, Decode(transaction_type_id,
1550 51, l_wip_allowed,
1551 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1552 --7169220: USERS LOCKED
1553 AND (mmtt.cartonization_id is null
1554 or not exists
1555 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1556 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1557 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1558 and wdt1.status = 9
1559 and mmtt1.cartonization_id = mmtt.cartonization_id)
1560 )
1561 ) qt,
1562 mtl_txn_request_lines mol,
1563 mtl_secondary_inventories sub,
1564 mtl_item_locations loc,
1565 (SELECT
1566 bsor.standard_operation_id,
1567 bre.resource_id,
1568 bre.inventory_item_id equipment_id
1569 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1570 WHERE bsor.resource_id = bre.resource_id
1571 AND br.resource_type = 1
1572 AND bsor.resource_id = br.resource_id) e
1573 WHERE wdt.transaction_temp_id = qt.task_id
1574 AND wdt.status = 2 -- bug 6326482 queued tasks only-- Queued and dispatched tasks only bug 4310093
1575 AND wdt.person_id = p_sign_on_emp_id
1576 AND wdt.organization_id = p_sign_on_org_id
1577 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1578 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))
1579 AND wdt.user_task_type = e.standard_operation_id(+)
1580 AND qt.move_order_line_id = mol.line_id(+)
1581 AND qt.organization_id = sub.organization_id
1582 AND qt.subinventory_code = sub.secondary_inventory_name
1583 AND qt.organization_id = loc.organization_id
1584 AND qt.locator_id = loc.inventory_location_id
1585 UNION ALL
1586 --bug 6326482 for dispatched tasks
1587 SELECT DISTINCT
1588 qt.task_id task_num,
1589 qt.pick_slip,
1590 wdt.task_type wms_task_type_id,
1591 nvl(wdt.priority, 0) task_priority,
1592 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1593 sub.picking_order sub_picking_order,
1594 loc.picking_order loc_picking_order,
1595 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1596 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1597 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1598 wdt.status task_status,
1599 qt.transaction_type_id,
1600 qt.transaction_action_id,
1601 qt.transaction_source_id,
1602 qt.transaction_source_type_id
1603 FROM wms_dispatched_tasks wdt,
1604 (SELECT
1605 transaction_temp_id task_id,
1606 wms_task_status task_status, -- bug 6326482 added to get the previous state of dispatched tasks
1607 pick_slip_number pick_slip,
1608 cartonization_id,
1609 organization_id,
1610 subinventory_code,
1611 locator_id,
1612 move_order_line_id,
1613 transaction_type_id,
1614 transaction_action_id,
1615 transaction_source_id,
1616 transaction_source_type_id
1617 FROM mtl_material_transactions_temp mmtt
1618 WHERE wms_task_type IS NOT NULL
1619 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1620 parent_line_id, transaction_temp_id)
1621 AND Decode(transaction_source_type_id,
1622 2, l_so_allowed,
1623 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
1624 5, Decode(transaction_type_id, 35, l_wip_allowed),
1625 8, l_io_allowed,
1626 13, Decode(transaction_type_id,
1627 51, l_wip_allowed,
1628 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1629 --7169220: USERS LOCKED
1630 AND (mmtt.cartonization_id is null
1631 or not exists
1632 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1633 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1634 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1635 and wdt1.status = 9
1636 and mmtt1.cartonization_id = mmtt.cartonization_id)
1637 )
1638 ) qt,
1639 mtl_txn_request_lines mol,
1640 mtl_secondary_inventories sub,
1641 mtl_item_locations loc,
1642 (SELECT
1643 bsor.standard_operation_id,
1644 bre.resource_id,
1645 bre.inventory_item_id equipment_id
1646 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1647 WHERE bsor.resource_id = bre.resource_id
1648 AND br.resource_type = 1
1649 AND bsor.resource_id = br.resource_id) e
1650 WHERE wdt.transaction_temp_id = qt.task_id
1651 AND wdt.status =3 -- bug 6326482 dispatched tasks only
1652 AND wdt.person_id = p_sign_on_emp_id
1653 AND wdt.organization_id = p_sign_on_org_id
1654 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1655 --bug 6326482
1656 AND ((qt.task_status is NULL
1657 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
1658 or
1659 (qt.task_status = 1
1660 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
1661 AND wdt.user_task_type = e.standard_operation_id(+)
1662 AND qt.move_order_line_id = mol.line_id(+)
1663 AND qt.organization_id = sub.organization_id
1664 AND qt.subinventory_code = sub.secondary_inventory_name
1665 AND qt.organization_id = loc.organization_id
1666 AND qt.locator_id = loc.inventory_location_id
1667 UNION ALL
1668 SELECT DISTINCT
1669 wdtv.task_id task_num,
1670 NVL(wdtv.pick_slip_number, -1) pick_slip,
1671 wdtv.wms_task_type_id,
1672 nvl(wdtv.task_priority, 0),
1673 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
1674 sub.picking_order sub_picking_order,
1675 loc.picking_order loc_picking_order,
1676 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1677 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1678 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1679 task_status,
1680 wdtv.transaction_type_id,
1681 wdtv.transaction_action_id,
1682 wdtv.transaction_source_id,
1683 wdtv.transaction_source_type_id
1684 FROM
1685 -- inlined wms_dispatchable_tasks_v, bug 2648133
1686 (SELECT
1687 transaction_temp_id task_id,
1688 standard_operation_id user_task_type_id,
1689 wms_task_type wms_task_type_id,
1690 organization_id,
1691 subinventory_code zone,
1692 locator_id,
1693 task_priority,
1694 revision,
1695 lot_number,
1696 transaction_uom,
1697 transaction_quantity,
1698 pick_rule_id,
1699 pick_slip_number,
1700 cartonization_id,
1701 inventory_item_id,
1702 move_order_line_id,
1703 1 task_status,
1704 transaction_type_id,
1705 transaction_action_id,
1706 transaction_source_id,
1707 transaction_source_type_id
1708 FROM mtl_material_transactions_temp mmtt
1709 WHERE wms_task_type IS NOT NULL
1710 AND transaction_status = 2
1711 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
1712 AND transaction_temp_id = Decode(p_task_method, 'BULK',
1713 parent_line_id, transaction_temp_id)
1714 AND Decode(transaction_source_type_id,
1715 2, l_so_allowed,
1716 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
1717 5, Decode(transaction_type_id, 35, l_wip_allowed),
1718 8, l_io_allowed,
1719 13, Decode(transaction_type_id,
1720 51, l_wip_allowed,
1721 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
1722 --7169220: USERS LOCKED
1723 AND (mmtt.cartonization_id is null
1724 or not exists
1725 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
1726 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
1727 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
1728 and wdt1.status = 9
1729 and mmtt1.cartonization_id = mmtt.cartonization_id)
1730 )
1731 ) wdtv,
1732 -- inlined wms_person_resource_utt_v, bug 2648133
1733 (SELECT
1734 utt_emp.standard_operation_id standard_operation_id,
1735 utt_emp.resource_id role,
1736 utt_eqp.resource_id equipment,
1737 utt_emp.person_id emp_id,
1738 utt_eqp.inventory_item_id eqp_id,
1739 NULL eqp_srl /* removed for bug 2095237 */
1740 FROM
1741 (SELECT
1742 x_utt_res1.standard_operation_id standard_operation_id,
1743 x_utt_res1.resource_id resource_id,
1744 x_emp_r.person_id
1745 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1746 WHERE x_utt_res1.resource_id = r1.resource_id
1747 AND r1.resource_type = 2
1748 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1749 (SELECT
1750 x_utt_res2.standard_operation_id standard_operation_id,
1751 x_utt_res2.resource_id,
1752 x_eqp_r.inventory_item_id
1753 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1754 WHERE x_utt_res2.resource_id = r2.resource_id
1755 AND r2.resource_type = 1
1756 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1757 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1758 mtl_item_locations loc,
1759 mtl_secondary_inventories sub,
1760 mtl_txn_request_lines mol,
1761 mtl_txn_request_headers moh
1762 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1763 AND wdtv.organization_id = p_sign_on_org_id
1764 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
1765 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
1766 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
1767 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
1768 AND wdtv.locator_id = loc.inventory_location_id(+)
1769 AND wdtv.zone = sub.secondary_inventory_name
1770 AND wdtv.organization_id = sub.organization_id
1771 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
1772 AND moh.header_id(+) = mol.header_id
1773 AND Decode(Nvl(moh.move_order_type, -1),
1774 2, l_rep_allowed,
1775 1, l_mot_moi_allowed,
1776 -1, 1,
1777 1) = 1
1778 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
1779 -- bug 4358107
1780 AND NOT EXISTS
1781 ( SELECT 1
1782 FROM WMS_DISPATCH_TASKS_GTMP
1783 WHERE (p_task_method = 'DISCRETE'
1784 and
1785 grouping_document_number = wdtv.pick_slip_number
1786 )
1787 or
1788 (
1789 p_task_method = 'ORDERPICK'
1790 and
1791 grouping_document_number = wdtv.transaction_source_id
1792 and
1793 grouping_source_type_id = wdtv.transaction_source_type_id
1794 )
1795 or
1796 (p_task_method = 'PICKBYLABEL'
1797 and
1798 grouping_document_number = wdtv.cartonization_id
1799 )
1800 or --6598260 start
1801 ( grouping_document_number = wdtv.cartonization_id
1802 and
1803 grouping_document_type = 'CARTON_TASK'
1804 ) --6598260 end
1805 )
1806 -- bug 4358107
1807 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
1808 (SELECT NULL
1809 FROM mtl_material_transactions_temp mmtt
1810 WHERE mmtt.transaction_temp_id = wdtv.task_id
1811 AND mmtt.parent_line_id IS NOT NULL
1812 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
1813 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
1814 AND NOT EXISTS -- exclude tasks already dispatched and queued
1815 (SELECT NULL
1816 FROM wms_dispatched_tasks wdt1
1817 WHERE wdt1.transaction_temp_id = wdtv.task_id
1818 AND wdt1.task_type = wdtv.wms_task_type_id)
1819 -- excluded skipped tasks
1820 AND wdtv.task_id NOT IN
1821 (SELECT wdtv.task_id
1822 FROM wms_skip_task_exceptions wste, mtl_parameters mp
1823 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
1824 AND wste.task_id = wdtv.task_id
1825 AND wste.organization_id = mp.organization_id)
1826 --J Addition
1827 AND wdtv.zone not in (
1828 SELECT wd.subinventory_code
1829 FROM wms_devices_b wd
1830 , wms_bus_event_devices wbed
1831 WHERE 1 = 1
1832 and wd.device_id = wbed.device_id
1833 AND wbed.organization_id = wd.organization_id
1834 AND wd.enabled_flag = 'Y'
1835 AND wbed.enabled_flag = 'Y'
1836 AND wbed.business_event_id = 10
1837 AND wd.subinventory_code IS NOT NULL
1838 AND wd.force_sign_on_flag = 'Y'
1839 AND wd.device_id NOT IN (SELECT device_id
1840 FROM wms_device_assignment_temp
1841 WHERE employee_id = p_sign_on_emp_id)
1842 )
1843 ORDER BY
1844 task_priority desc,
1845 batch_id,
1846 task_status DESC,
1847 sub_picking_order,
1848 loc_picking_order,
1849 distance,
1850 task_num;
1851
1852 -- Cursor #6 for selecting the most optimal task
1853 -- 1. Sub is not passed (0)
1854 -- 2. Non cycle count tasks (0)
1855 -- 3. Cycle count tasks (1)
1856 CURSOR l_curs_opt_task_001 IS
1857 SELECT DISTINCT
1858 qt.task_id task_num,
1859 qt.pick_slip,
1860 wdt.task_type wms_task_type_id,
1861 nvl(wdt.priority, 0) task_priority,
1862 To_number (NULL) batch_id,
1863 sub.picking_order sub_picking_order,
1864 loc.picking_order loc_picking_order,
1865 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1866 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1867 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1868 wdt.status task_status, --bug 4310093
1869 qt.transaction_type_id,
1870 qt.transaction_action_id,
1871 qt.transaction_source_id,
1872 qt.transaction_source_type_id
1873 FROM wms_dispatched_tasks wdt,
1874 (SELECT
1875 MIN(mcce.cycle_count_entry_id) task_id,
1876 TO_NUMBER(NULL) pick_slip,
1877 To_number(NULL) cartonization_id,
1878 mcce.organization_id,
1879 mcce.subinventory subinventory_code,
1880 mcce.locator_id,
1881 To_number(NULL) move_order_line_id,
1882 4 transaction_type_id,
1883 4 transaction_action_id,
1884 mcce.cycle_count_header_id transaction_source_id,
1885 9 transaction_source_type_id
1886 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1887 WHERE mcce.entry_status_code IN(1, 3)
1888 AND NVL(mcce.export_flag, 2) = 2
1889 -- bug 3972076
1890 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1891 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1892 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1893 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
1894 mtl_secondary_inventories sub,
1895 mtl_item_locations loc,
1896 (SELECT
1897 bsor.standard_operation_id,
1898 bre.resource_id,
1899 bre.inventory_item_id equipment_id
1900 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
1901 WHERE bsor.resource_id = bre.resource_id
1902 AND br.resource_type = 1
1903 AND bsor.resource_id = br.resource_id) e
1904 WHERE wdt.transaction_temp_id = qt.task_id
1905 AND wdt.status in (2,3) -- Queued and dispatched tasks only bug 4310093
1906 AND wdt.person_id = p_sign_on_emp_id
1907 AND wdt.organization_id = p_sign_on_org_id
1908 AND NVL(qt.cartonization_id, -999) = NVL(l_cartonization_id, NVL(qt.cartonization_id, -999))
1909 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
1910 AND wdt.user_task_type = e.standard_operation_id(+)
1911 AND qt.organization_id = sub.organization_id
1912 AND qt.subinventory_code = sub.secondary_inventory_name
1913 AND qt.organization_id = loc.organization_id
1914 AND qt.locator_id = loc.inventory_location_id
1915 UNION ALL
1916 SELECT DISTINCT
1917 wdtv.task_id task_num,
1918 NVL(wdtv.pick_slip_number, -1) pick_slip,
1919 wdtv.wms_task_type_id,
1920 nvl(wdtv.task_priority, 0),
1921 To_number(NULL) batch_id,
1922 sub.picking_order sub_picking_order,
1923 loc.picking_order loc_picking_order,
1924 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
1925 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
1926 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
1927 task_status,
1928 wdtv.transaction_type_id,
1929 wdtv.transaction_action_id,
1930 wdtv.transaction_source_id,
1931 wdtv.transaction_source_type_id
1932 FROM
1933 -- inlined wms_dispatchable_tasks_v, bug 2648133
1934 (SELECT
1935 MIN(mcce.cycle_count_entry_id) task_id,
1936 MIN(mcce.standard_operation_id) user_task_type_id,
1937 3 wms_task_type_id,
1938 mcce.organization_id,
1939 mcce.subinventory zone,
1940 mcce.locator_id,
1941 MIN(mcce.task_priority) task_priority,
1942 mcce.revision revision,
1943 MIN(mcce.lot_number) lot_number,
1944 '' transaction_uom,
1945 TO_NUMBER(NULL) transaction_quantity,
1946 TO_NUMBER(NULL) pick_rule_id,
1947 TO_NUMBER(NULL) pick_slip_number,
1948 TO_NUMBER(NULL) cartonization_id,
1949 mcce.inventory_item_id,
1950 TO_NUMBER(NULL) move_order_line_id,
1951 1 task_status,
1952 4 transaction_type_id,
1953 4 transaction_action_id,
1954 mcce.cycle_count_header_id transaction_source_id,
1955 9 transaction_source_type_id
1956 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
1957 WHERE mcce.entry_status_code IN(1, 3)
1958 AND NVL(mcce.export_flag, 2) = 2
1959 -- bug 3972076
1960 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
1961 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
1962
1963 -----bug6903708---
1964 AND mcce.organization_id = mcch.organization_id
1965 AND mcch.organization_id = p_sign_on_org_id
1966 ---------------------------
1967
1968 AND NVL(mcch.disable_date,sysdate+1)> sysdate
1969 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
1970 -- inlined wms_person_resource_utt_v, bug 2648133
1971 (SELECT
1972 utt_emp.standard_operation_id standard_operation_id,
1973 utt_emp.resource_id role,
1974 utt_eqp.resource_id equipment,
1975 utt_emp.person_id emp_id,
1976 utt_eqp.inventory_item_id eqp_id,
1977 NULL eqp_srl /* removed for bug 2095237 */
1978 FROM
1979 (SELECT
1980 x_utt_res1.standard_operation_id standard_operation_id,
1981 x_utt_res1.resource_id resource_id,
1982 x_emp_r.person_id
1983 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
1984 WHERE x_utt_res1.resource_id = r1.resource_id
1985 AND r1.resource_type = 2
1986 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
1987 (SELECT
1988 x_utt_res2.standard_operation_id standard_operation_id,
1989 x_utt_res2.resource_id,
1990 x_eqp_r.inventory_item_id
1991 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
1992 WHERE x_utt_res2.resource_id = r2.resource_id
1993 AND r2.resource_type = 1
1994 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
1995 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
1996 mtl_item_locations loc,
1997 mtl_secondary_inventories sub
1998 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
1999 AND wdtv.organization_id = p_sign_on_org_id
2000 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2001 AND NVL(wdtv.cartonization_id, -999) = NVL(l_cartonization_id, NVL(wdtv.cartonization_id, -999))
2002 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
2003 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2004 AND wdtv.locator_id = loc.inventory_location_id(+)
2005 AND wdtv.zone = sub.secondary_inventory_name
2006 AND wdtv.organization_id = sub.organization_id
2007 --AND Nvl(wdtv.pick_slip_number, -1) <> l_pick_slip -- bug 2832818
2008 -- bug 4358107
2009 AND NOT EXISTS
2010 ( SELECT 1
2011 FROM WMS_DISPATCH_TASKS_GTMP
2012 WHERE (p_task_method = 'DISCRETE'
2013 and
2014 grouping_document_number = wdtv.pick_slip_number
2015 )
2016 or
2017 (
2018 p_task_method = 'ORDERPICK'
2019 and
2020 grouping_document_number = wdtv.transaction_source_id
2021 and
2022 grouping_source_type_id = wdtv.transaction_source_type_id
2023 )
2024 or
2025 (p_task_method = 'PICKBYLABEL'
2026 and
2027 grouping_document_number = wdtv.cartonization_id
2028 )
2029 )
2030 -- bug 4358107
2031 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2032 (SELECT NULL
2033 FROM mtl_material_transactions_temp mmtt
2034 WHERE mmtt.transaction_temp_id = wdtv.task_id
2035 AND mmtt.parent_line_id IS NOT NULL
2036 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2037 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2038 AND NOT EXISTS -- exclude tasks already dispatched and queued
2039 (SELECT NULL
2040 FROM wms_dispatched_tasks wdt1
2041 WHERE wdt1.transaction_temp_id = wdtv.task_id
2042 AND wdt1.task_type = wdtv.wms_task_type_id)
2043 -- excluded skipped tasks
2044 AND wdtv.task_id NOT IN
2045 (SELECT wdtv.task_id
2046 FROM wms_skip_task_exceptions wste, mtl_parameters mp
2047 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
2048 AND wste.task_id = wdtv.task_id
2049 AND wste.organization_id = mp.organization_id)
2050 --J Addition
2051 AND wdtv.zone not in (
2052 SELECT wd.subinventory_code
2053 FROM wms_devices_b wd
2054 , wms_bus_event_devices wbed
2055 WHERE 1 = 1
2056 and wd.device_id = wbed.device_id
2057 AND wbed.organization_id = wd.organization_id
2058 AND wd.enabled_flag = 'Y'
2059 AND wbed.enabled_flag = 'Y'
2060 AND wbed.business_event_id = 10
2061 AND wd.subinventory_code IS NOT NULL
2062 AND wd.force_sign_on_flag = 'Y'
2063 AND wd.device_id NOT IN (SELECT device_id
2064 FROM wms_device_assignment_temp
2065 WHERE employee_id = p_sign_on_emp_id)
2066 )
2067 ORDER BY
2068 task_priority desc,
2069 task_status DESC,
2070 sub_picking_order,
2071 loc_picking_order,
2072 distance,
2073 task_num;
2074
2075
2076 -- Cursor #1 for selecting the ordered tasks
2077 -- 1. Non cycle count tasks (1)
2078 -- 2. Cycle count tasks (1)
2079 CURSOR l_curs_ordered_tasks_11(v_pick_slip_number NUMBER,
2080 v_task_id NUMBER,
2081 v_task_type NUMBER,
2082 v_transaction_source_id NUMBER) IS
2083 SELECT DISTINCT
2084 qt.task_id task_num,
2085 qt.subinventory_code,
2086 qt.locator_id,
2087 qt.pick_slip,
2088 qt.transaction_uom,
2089 qt.transaction_quantity,
2090 qt.lot_number,
2091 qt.operation_plan_id,
2092 qt.standard_operation_id,
2093 wdt.effective_start_date,
2094 wdt.effective_end_date,
2095 wdt.person_resource_id,
2096 wdt.machine_resource_id,
2097 wdt.task_type wms_task_type_id,
2098 nvl(wdt.priority, 0) task_priority,
2099 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2100 mol.line_id,
2101 sub.picking_order sub_picking_order,
2102 loc.picking_order loc_picking_order,
2103 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2104 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2105 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2106 wdt.status task_status, --bug 4310093
2107 qt.transaction_type_id,
2108 qt.transaction_action_id,
2109 qt.transaction_source_id,
2110 qt.transaction_source_type_id
2111 FROM wms_dispatched_tasks wdt,
2112 (SELECT
2113 transaction_temp_id task_id,
2114 pick_slip_number pick_slip,
2115 cartonization_id,
2116 organization_id,
2117 subinventory_code,
2118 locator_id,
2119 inventory_item_id,
2120 revision,
2121 transaction_uom,
2122 transaction_quantity,
2123 lot_number,
2124 operation_plan_id,
2125 standard_operation_id,
2126 move_order_line_id,
2127 transaction_type_id,
2128 transaction_action_id,
2129 transaction_source_id,
2130 transaction_source_type_id
2131 FROM mtl_material_transactions_temp mmtt
2132 WHERE wms_task_type IS NOT NULL
2133 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2134 parent_line_id, transaction_temp_id)
2135 AND Decode(transaction_source_type_id,
2136 2, l_so_allowed,
2137 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2138 5, Decode(transaction_type_id, 35, l_wip_allowed),
2139 8, l_io_allowed,
2140 13, Decode(transaction_type_id,
2141 51, l_wip_allowed,
2142 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2143 --7169220: USERS LOCKED
2144 AND (mmtt.cartonization_id is null
2145 or not exists
2146 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2147 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2148 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2149 and wdt1.status = 9
2150 and mmtt1.cartonization_id = mmtt.cartonization_id)
2151 )
2152
2153
2154 UNION ALL
2155 SELECT
2156 MIN(mcce.cycle_count_entry_id) task_id,
2157 TO_NUMBER(NULL) pick_slip,
2158 To_number(NULL) cartonization_id,
2159 mcce.organization_id,
2160 mcce.subinventory subinventory_code,
2161 mcce.locator_id,
2162 mcce.inventory_item_id,
2163 mcce.revision,
2164 To_char(NULL) transaction_uom,
2165 To_number(NULL) transaction_quantity,
2166 MIN(mcce.lot_number) lot_number,
2167 To_number(NULL) operation_plan_id,
2168 MIN(mcce.standard_operation_id) standard_operation_id,
2169 To_number(NULL) move_order_line_id,
2170 4 transaction_type_id,
2171 4 transaction_action_id,
2172 mcce.cycle_count_header_id transaction_source_id,
2173 9 transaction_source_type_id
2174 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
2175 WHERE mcce.entry_status_code IN(1, 3)
2176 AND NVL(mcce.export_flag, 2) = 2
2177 -- bug 3972076
2178 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2179 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2180
2181 -----bug6903708---
2182 AND mcce.organization_id = mcch.organization_id
2183 AND mcch.organization_id = p_sign_on_org_id
2184 ---------------------------
2185
2186 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2187 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
2188 mtl_txn_request_lines mol,
2189 mtl_secondary_inventories sub,
2190 mtl_item_locations loc,
2191 (SELECT
2192 bsor.standard_operation_id,
2193 bre.resource_id,
2194 bre.inventory_item_id equipment_id
2195 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2196 WHERE bsor.resource_id = bre.resource_id
2197 AND br.resource_type = 1
2198 AND bsor.resource_id = br.resource_id) e
2199 WHERE wdt.transaction_temp_id = qt.task_id
2200 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
2201 AND wdt.person_id = p_sign_on_emp_id
2202 AND wdt.organization_id = p_sign_on_org_id
2203 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2204 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2205 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2206 OR (p_task_method = 'ORDERPICK'
2207 AND Decode(qt.transaction_source_type_id,
2208 2, qt.transaction_source_id,
2209 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2210 8, qt.transaction_source_id,
2211 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2212 -1) = nvl(v_transaction_source_id, -1))
2213 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2214 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2215 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id))))
2216 -- Bug: 7254397
2217 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
2218 AND wdt.user_task_type = e.standard_operation_id(+)
2219 AND qt.move_order_line_id = mol.line_id(+)
2220 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2221 AND qt.organization_id = sub.organization_id
2222 AND qt.subinventory_code = sub.secondary_inventory_name
2223 AND qt.organization_id = loc.organization_id
2224 AND qt.locator_id = loc.inventory_location_id
2225 UNION ALL
2226 SELECT DISTINCT
2227 wdtv.task_id task_num,
2228 wdtv.subinventory_code,
2229 wdtv.locator_id,
2230 NVL(wdtv.pick_slip_number, -1) pick_slip,
2231 wdtv.transaction_uom,
2232 wdtv.transaction_quantity,
2233 wdtv.lot_number,
2234 wdtv.operation_plan_id,
2235 wdtv.user_task_type_id standard_operation_id,
2236 v.effective_start_date,
2237 v.effective_end_date,
2238 v.role person_resource_id,
2239 v.equipment machine_resource_id,
2240 wdtv.wms_task_type_id,
2241 nvl(wdtv.task_priority, 0),
2242 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2243 mol.line_id,
2244 sub.picking_order sub_picking_order,
2245 loc.picking_order loc_picking_order,
2246 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2247 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2248 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2249 task_status,
2250 wdtv.transaction_type_id,
2251 wdtv.transaction_action_id,
2252 wdtv.transaction_source_id,
2253 wdtv.transaction_source_type_id
2254 FROM
2255 -- inlined wms_dispatchable_tasks_v, bug 2648133
2256 (SELECT
2257 transaction_temp_id task_id,
2258 standard_operation_id user_task_type_id,
2259 wms_task_type wms_task_type_id,
2260 organization_id,
2261 subinventory_code,
2262 locator_id,
2263 task_priority,
2264 revision,
2265 lot_number,
2266 transaction_uom,
2267 transaction_quantity,
2268 pick_rule_id,
2269 pick_slip_number,
2270 cartonization_id,
2271 inventory_item_id,
2272 move_order_line_id,
2273 1 task_status,
2274 transaction_type_id,
2275 transaction_action_id,
2276 transaction_source_id,
2277 transaction_source_type_id,
2278 operation_plan_id
2279 FROM mtl_material_transactions_temp mmtt
2280 WHERE wms_task_type IS NOT NULL
2281 AND transaction_status = 2
2282 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
2283 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2284 parent_line_id, transaction_temp_id)
2285 AND Decode(transaction_source_type_id,
2286 2, l_so_allowed,
2287 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2288 5, Decode(transaction_type_id, 35, l_wip_allowed),
2289 8, l_io_allowed,
2290 13, Decode(transaction_type_id,
2291 51, l_wip_allowed,
2292 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2293 --7169220: USERS LOCKED
2294 AND (mmtt.cartonization_id is null
2295 or not exists
2296 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2297 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2298 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2299 and wdt1.status = 9
2300 and mmtt1.cartonization_id = mmtt.cartonization_id)
2301 )
2302
2303 UNION ALL
2304 SELECT
2305 MIN(mcce.cycle_count_entry_id) task_id,
2306 MIN(mcce.standard_operation_id) user_task_type_id,
2307 3 wms_task_type_id,
2308 mcce.organization_id,
2309 mcce.subinventory subinventory_code,
2310 mcce.locator_id,
2311 MIN(mcce.task_priority) task_priority,
2312 mcce.revision revision,
2313 MIN(mcce.lot_number) lot_number,
2314 '' transaction_uom,
2315 TO_NUMBER(NULL) transaction_quantity,
2316 TO_NUMBER(NULL) pick_rule_id,
2317 TO_NUMBER(NULL) pick_slip_number,
2318 TO_NUMBER(NULL) cartonization_id,
2319 mcce.inventory_item_id,
2320 TO_NUMBER(NULL) move_order_line_id,
2321 1 task_status,
2322 4 transaction_type_id,
2323 4 transaction_action_id,
2324 mcce.cycle_count_header_id transaction_source_id,
2325 9 transaction_source_type_id,
2326 To_number(NULL) operation_plan_id
2327 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
2328 WHERE mcce.entry_status_code IN(1, 3)
2329 AND NVL(mcce.export_flag, 2) = 2
2330 -- bug 3972076
2331 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2332 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2333 -----bug6903708---
2334 AND mcce.organization_id = mcch.organization_id
2335 AND mcch.organization_id = p_sign_on_org_id
2336 ---------------------------
2337
2338 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2339 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
2340 -- inlined wms_person_resource_utt_v, bug 2648133
2341 (SELECT
2342 utt_emp.standard_operation_id standard_operation_id,
2343 utt_emp.resource_id role,
2344 utt_eqp.resource_id equipment,
2345 utt_emp.person_id emp_id,
2346 utt_emp.effective_start_date,
2347 utt_emp.effective_end_date,
2348 utt_eqp.inventory_item_id eqp_id,
2349 NULL eqp_srl /* removed for bug 2095237 */
2350 FROM
2351 (SELECT
2352 x_utt_res1.standard_operation_id standard_operation_id,
2353 x_utt_res1.resource_id resource_id,
2354 x_emp_r.person_id,
2355 x_emp_r.effective_start_date,
2356 x_emp_r.effective_end_date
2357 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
2358 WHERE x_utt_res1.resource_id = r1.resource_id
2359 AND r1.resource_type = 2
2360 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
2361 (SELECT
2362 x_utt_res2.standard_operation_id standard_operation_id,
2363 x_utt_res2.resource_id,
2364 x_eqp_r.inventory_item_id
2365 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
2366 WHERE x_utt_res2.resource_id = r2.resource_id
2367 AND r2.resource_type = 1
2368 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
2369 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
2370 mtl_item_locations loc,
2371 mtl_secondary_inventories sub,
2372 mtl_txn_request_lines mol,
2373 mtl_txn_request_headers moh
2374 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
2375 AND ((wdtv.pick_slip_number = v_pick_slip_number AND p_task_method = 'DISCRETE')
2376 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2377 AND wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
2378 OR (p_task_method = 'ORDERPICK'
2379 AND Decode(wdtv.transaction_source_type_id,
2380 2, wdtv.transaction_source_id,
2381 5, Decode(wdtv.transaction_type_id, 35, wdtv.transaction_source_id),
2382 8, wdtv.transaction_source_id,
2383 13, Decode(wdtv.transaction_type_id, 51, wdtv.transaction_source_id),
2384 -1) = nvl(v_transaction_source_id, -1))
2385 OR (p_task_method = 'PICKBYLABEL' AND wdtv.cartonization_id = l_cartonization_id)
2386 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2387 wdtv.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id))))
2388 AND wdtv.organization_id = p_sign_on_org_id
2389 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2390 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))
2391 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
2392 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2393 AND wdtv.locator_id = loc.inventory_location_id(+)
2394 AND wdtv.subinventory_code = sub.secondary_inventory_name
2395 AND wdtv.organization_id = sub.organization_id
2396 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
2397 AND moh.header_id(+) = mol.header_id
2398 AND Decode(Nvl(moh.move_order_type, -1),
2399 2, l_rep_allowed,
2400 1, l_mot_moi_allowed,
2401 -1, 1,
2402 1) = 1
2403 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2404 (SELECT NULL
2405 FROM mtl_material_transactions_temp mmtt
2406 WHERE mmtt.transaction_temp_id = wdtv.task_id
2407 AND mmtt.parent_line_id IS NOT NULL
2408 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2409 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2410 AND NOT EXISTS -- exclude tasks already dispatched and queued
2411 (SELECT NULL
2412 FROM wms_dispatched_tasks wdt1
2413 WHERE wdt1.transaction_temp_id = wdtv.task_id
2414 AND wdt1.task_type = wdtv.wms_task_type_id)
2415 -- Bug 7254397: exclude tasks from locked cartons
2416 AND NOT EXISTS
2417 ( SELECT 1
2418 FROM WMS_DISPATCH_TASKS_GTMP
2419 WHERE p_task_method = 'CLUSTERPICKBYLABEL'
2420 AND
2421 grouping_document_number = wdtv.cartonization_id)
2422 -- excluded skipped tasks
2423 AND wdtv.task_id NOT IN
2424 (SELECT wdtv.task_id
2425 FROM wms_skip_task_exceptions wste, mtl_parameters mp
2426 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
2427 AND wste.task_id = wdtv.task_id
2428 AND wste.organization_id = mp.organization_id)
2429 --J Addition
2430 AND wdtv.subinventory_code not in (
2431 SELECT wd.subinventory_code
2432 FROM wms_devices_b wd
2433 , wms_bus_event_devices wbed
2434 WHERE 1 = 1
2435 and wd.device_id = wbed.device_id
2436 AND wbed.organization_id = wd.organization_id
2437 AND wd.enabled_flag = 'Y'
2438 AND wbed.enabled_flag = 'Y'
2439 AND wbed.business_event_id = 10
2440 AND wd.subinventory_code IS NOT NULL
2441 AND wd.force_sign_on_flag = 'Y'
2442 AND wd.device_id NOT IN (SELECT device_id
2443 FROM wms_device_assignment_temp
2444 WHERE employee_id = p_sign_on_emp_id)
2445 )
2446 ORDER BY
2447 sub_picking_order,
2448 loc_picking_order,
2449 distance,
2450 task_priority desc,
2451 batch_id,
2452 task_status DESC,
2453 task_num;
2454
2455
2456 -- Cursor #2 for selecting the ordered tasks
2457 -- 1. Non cycle count tasks (1)
2458 -- 2. Cycle count tasks (0)
2459 CURSOR l_curs_ordered_tasks_10(v_pick_slip_number NUMBER,
2460 v_task_id NUMBER,
2461 v_task_type NUMBER,
2462 v_transaction_source_id NUMBER) IS
2463 SELECT DISTINCT
2464 qt.task_id task_num,
2465 qt.subinventory_code,
2466 qt.locator_id,
2467 qt.pick_slip,
2468 qt.transaction_uom,
2469 qt.transaction_quantity,
2470 qt.lot_number,
2471 qt.operation_plan_id,
2472 qt.standard_operation_id,
2473 wdt.effective_start_date,
2474 wdt.effective_end_date,
2475 wdt.person_resource_id,
2476 wdt.machine_resource_id,
2477 wdt.task_type wms_task_type_id,
2478 nvl(wdt.priority, 0) task_priority,
2479 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2480 mol.line_id,
2481 sub.picking_order sub_picking_order,
2482 loc.picking_order loc_picking_order,
2483 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2484 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2485 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2486 wdt.status task_status, --bug 4310093
2487 qt.transaction_type_id,
2488 qt.transaction_action_id,
2489 qt.transaction_source_id,
2490 qt.transaction_source_type_id
2491 FROM wms_dispatched_tasks wdt,
2492 (SELECT
2493 transaction_temp_id task_id,
2494 pick_slip_number pick_slip,
2495 cartonization_id,
2496 organization_id,
2497 subinventory_code,
2498 locator_id,
2499 inventory_item_id,
2500 revision,
2501 transaction_uom,
2502 transaction_quantity,
2503 lot_number,
2504 operation_plan_id,
2505 standard_operation_id,
2506 move_order_line_id,
2507 transaction_type_id,
2508 transaction_action_id,
2509 transaction_source_id,
2510 transaction_source_type_id
2511 FROM mtl_material_transactions_temp mmtt
2512 WHERE wms_task_type IS NOT NULL
2513 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2514 parent_line_id, transaction_temp_id)
2515 AND Decode(transaction_source_type_id,
2516 2, l_so_allowed,
2517 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2518 5, Decode(transaction_type_id, 35, l_wip_allowed),
2519 8, l_io_allowed,
2520 13, Decode(transaction_type_id,
2521 51, l_wip_allowed,
2522 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2523 --7169220: USERS LOCKED
2524 AND (mmtt.cartonization_id is null
2525 or not exists
2526 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2527 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2528 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2529 and wdt1.status = 9
2530 and mmtt1.cartonization_id = mmtt.cartonization_id)
2531 )
2532 ) qt,
2533 mtl_txn_request_lines mol,
2534 mtl_secondary_inventories sub,
2535 mtl_item_locations loc,
2536 (SELECT
2537 bsor.standard_operation_id,
2538 bre.resource_id,
2539 bre.inventory_item_id equipment_id
2540 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2541 WHERE bsor.resource_id = bre.resource_id
2542 AND br.resource_type = 1
2543 AND bsor.resource_id = br.resource_id) e
2544 WHERE wdt.transaction_temp_id = qt.task_id
2545 AND wdt.status = 2 --bug 6326482 queued task only -- Queued and dispatched tasks only bug 4310093
2546 AND wdt.person_id = p_sign_on_emp_id
2547 AND wdt.organization_id = p_sign_on_org_id
2548 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2549 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2550 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2551 OR (p_task_method = 'ORDERPICK'
2552 AND Decode(qt.transaction_source_type_id,
2553 2, qt.transaction_source_id,
2554 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2555 8, qt.transaction_source_id,
2556 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2557 -1) = nvl(v_transaction_source_id, -1))
2558 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2559 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2560 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id))))
2561 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999))--bug 6326482
2562 AND wdt.user_task_type = e.standard_operation_id(+)
2563 AND qt.move_order_line_id = mol.line_id(+)
2564 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2565 AND qt.organization_id = sub.organization_id
2566 AND qt.subinventory_code = sub.secondary_inventory_name
2567 AND qt.organization_id = loc.organization_id
2568 AND qt.locator_id = loc.inventory_location_id
2569 UNION ALL
2570 --bug 6326482
2571 SELECT DISTINCT
2572 qt.task_id task_num,
2573 qt.subinventory_code,
2574 qt.locator_id,
2575 qt.pick_slip,
2576 qt.transaction_uom,
2577 qt.transaction_quantity,
2578 qt.lot_number,
2579 qt.operation_plan_id,
2580 qt.standard_operation_id,
2581 wdt.effective_start_date,
2582 wdt.effective_end_date,
2583 wdt.person_resource_id,
2584 wdt.machine_resource_id,
2585 wdt.task_type wms_task_type_id,
2586 nvl(wdt.priority, 0) task_priority,
2587 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2588 mol.line_id,
2589 sub.picking_order sub_picking_order,
2590 loc.picking_order loc_picking_order,
2591 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2592 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2593 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2594 wdt.status task_status,
2595 qt.transaction_type_id,
2596 qt.transaction_action_id,
2597 qt.transaction_source_id,
2598 qt.transaction_source_type_id
2599 FROM wms_dispatched_tasks wdt,
2600 (SELECT
2601 transaction_temp_id task_id,
2602 wms_task_status task_status, --bug 6326482 added to check for the previous state of dispatched tasks
2603 pick_slip_number pick_slip,
2604 cartonization_id,
2605 organization_id,
2606 subinventory_code,
2607 locator_id,
2608 inventory_item_id,
2609 revision,
2610 transaction_uom,
2611 transaction_quantity,
2612 lot_number,
2613 operation_plan_id,
2614 standard_operation_id,
2615 move_order_line_id,
2616 transaction_type_id,
2617 transaction_action_id,
2618 transaction_source_id,
2619 transaction_source_type_id
2620 FROM mtl_material_transactions_temp mmtt
2621 WHERE wms_task_type IS NOT NULL
2622 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2623 parent_line_id, transaction_temp_id)
2624 AND Decode(transaction_source_type_id,
2625 2, l_so_allowed,
2626 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5094839*/
2627 5, Decode(transaction_type_id, 35, l_wip_allowed),
2628 8, l_io_allowed,
2629 13, Decode(transaction_type_id,
2630 51, l_wip_allowed,
2631 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2632 --7169220: USERS LOCKED
2633 AND (mmtt.cartonization_id is null
2634 or not exists
2635 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2636 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2637 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2638 and wdt1.status = 9
2639 and mmtt1.cartonization_id = mmtt.cartonization_id)
2640 )
2641 ) qt,
2642 mtl_txn_request_lines mol,
2643 mtl_secondary_inventories sub,
2644 mtl_item_locations loc,
2645 (SELECT
2646 bsor.standard_operation_id,
2647 bre.resource_id,
2648 bre.inventory_item_id equipment_id
2649 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2650 WHERE bsor.resource_id = bre.resource_id
2651 AND br.resource_type = 1
2652 AND bsor.resource_id = br.resource_id) e
2653 WHERE wdt.transaction_temp_id = qt.task_id
2654 AND wdt.status = 3 -- bug 6326482 dispatched tasks
2655 AND wdt.person_id = p_sign_on_emp_id
2656 AND wdt.organization_id = p_sign_on_org_id
2657 AND ((qt.pick_slip = v_pick_slip_number AND p_task_method = 'DISCRETE')
2658 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2659 AND qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2660 OR (p_task_method = 'ORDERPICK'
2661 AND Decode(qt.transaction_source_type_id,
2662 2, qt.transaction_source_id,
2663 5, Decode(qt.transaction_type_id, 35, qt.transaction_source_id),
2664 8, qt.transaction_source_id,
2665 13, Decode(qt.transaction_type_id, 51, qt.transaction_source_id),
2666 -1) = nvl(v_transaction_source_id, -1))
2667 OR (p_task_method = 'PICKBYLABEL' AND qt.cartonization_id = l_cartonization_id)
2668 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2669 qt.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id))))
2670 -- -bug 6326482
2671 AND ((qt.task_status is NULL
2672 AND NVL(e.equipment_id, -999) = NVL(l_q_sign_on_equipment_id, NVL(e.equipment_id, -999)))
2673 or
2674 (qt.task_status = 1
2675 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))))--bug 6326482
2676 AND wdt.user_task_type = e.standard_operation_id(+)
2677 AND qt.move_order_line_id = mol.line_id(+)
2678 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2679 AND qt.organization_id = sub.organization_id
2680 AND qt.subinventory_code = sub.secondary_inventory_name
2681 AND qt.organization_id = loc.organization_id
2682 AND qt.locator_id = loc.inventory_location_id
2683 UNION ALL
2684 SELECT DISTINCT
2685 wdtv.task_id task_num,
2686 wdtv.subinventory_code,
2687 wdtv.locator_id,
2688 NVL(wdtv.pick_slip_number, -1) pick_slip,
2689 wdtv.transaction_uom,
2690 wdtv.transaction_quantity,
2691 wdtv.lot_number,
2692 wdtv.operation_plan_id,
2693 wdtv.user_task_type_id standard_operation_id,
2694 v.effective_start_date,
2695 v.effective_end_date,
2696 v.role person_resource_id,
2697 v.equipment machine_resource_id,
2698 wdtv.wms_task_type_id,
2699 nvl(wdtv.task_priority, 0),
2700 Decode(l_sequence_picks_across_waves, 2, mol.header_id, NULL) batch_id,
2701 mol.line_id,
2702 sub.picking_order sub_picking_order,
2703 loc.picking_order loc_picking_order,
2704 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2705 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2706 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2707 task_status,
2708 wdtv.transaction_type_id,
2709 wdtv.transaction_action_id,
2710 wdtv.transaction_source_id,
2711 wdtv.transaction_source_type_id
2712 FROM
2713 -- inlined wms_dispatchable_tasks_v, bug 2648133
2714 (SELECT
2715 transaction_temp_id task_id,
2716 standard_operation_id user_task_type_id,
2717 wms_task_type wms_task_type_id,
2718 organization_id,
2719 subinventory_code,
2720 locator_id,
2721 task_priority,
2722 revision,
2723 lot_number,
2724 transaction_uom,
2725 transaction_quantity,
2726 pick_rule_id,
2727 pick_slip_number,
2728 cartonization_id,
2729 inventory_item_id,
2730 move_order_line_id,
2731 1 task_status,
2732 transaction_type_id,
2733 transaction_action_id,
2734 transaction_source_id,
2735 transaction_source_type_id,
2736 operation_plan_id
2737 FROM mtl_material_transactions_temp mmtt
2738 WHERE wms_task_type IS NOT NULL
2739 AND transaction_status = 2
2740 AND(wms_task_status IS NULL OR wms_task_status = 1) --Added for task planning WB. bug#2651318
2741 AND transaction_temp_id = Decode(p_task_method, 'BULK',
2742 parent_line_id, transaction_temp_id)
2743 AND Decode(transaction_source_type_id,
2744 2, l_so_allowed,
2745 4, Decode(transaction_action_id, 1, l_moi_allowed, 2, decode(wms_task_type, 4, l_rep_allowed, l_mot_allowed)), /*Bug#5188179*/
2746 5, Decode(transaction_type_id, 35, l_wip_allowed),
2747 8, l_io_allowed,
2748 13, Decode(transaction_type_id,
2749 51, l_wip_allowed,
2750 Decode(transaction_action_id, 2, decode(wms_task_type, 4, l_rep_allowed)))) = 1
2751 --7169220: USERS LOCKED
2752 AND (mmtt.cartonization_id is null
2753 or not exists
2754 (select 1 from mtl_material_transactions_temp mmtt1 ,wms_dispatched_tasks wdt1
2755 where mmtt1.transaction_temp_id <> mmtt.transaction_temp_id
2756 and wdt1.transaction_temp_id = mmtt1.transaction_temp_id
2757 and wdt1.status = 9
2758 and mmtt1.cartonization_id = mmtt.cartonization_id)
2759 )
2760 ) wdtv,
2761 -- inlined wms_person_resource_utt_v, bug 2648133
2762 (SELECT
2763 utt_emp.standard_operation_id standard_operation_id,
2764 utt_emp.resource_id role,
2765 utt_eqp.resource_id equipment,
2766 utt_emp.person_id emp_id,
2767 utt_emp.effective_start_date,
2768 utt_emp.effective_end_date,
2769 utt_eqp.inventory_item_id eqp_id,
2770 NULL eqp_srl /* removed for bug 2095237 */
2771 FROM
2772 (SELECT
2773 x_utt_res1.standard_operation_id standard_operation_id,
2774 x_utt_res1.resource_id resource_id,
2775 x_emp_r.person_id,
2776 x_emp_r.effective_start_date,
2777 x_emp_r.effective_end_date
2778 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
2779 WHERE x_utt_res1.resource_id = r1.resource_id
2780 AND r1.resource_type = 2
2781 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
2782 (SELECT
2783 x_utt_res2.standard_operation_id standard_operation_id,
2784 x_utt_res2.resource_id,
2785 x_eqp_r.inventory_item_id
2786 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
2787 WHERE x_utt_res2.resource_id = r2.resource_id
2788 AND r2.resource_type = 1
2789 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
2790 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
2791 mtl_item_locations loc,
2792 mtl_secondary_inventories sub,
2793 mtl_txn_request_lines mol,
2794 mtl_txn_request_headers moh
2795 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
2796 AND ((wdtv.pick_slip_number = v_pick_slip_number AND p_task_method = 'DISCRETE')
2797 OR (p_task_method IN ('MANUAL', 'WAVE', 'BULK', 'DISCRETE')
2798 AND wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
2799 OR (p_task_method = 'ORDERPICK'
2800 AND Decode(wdtv.transaction_source_type_id,
2801 2, wdtv.transaction_source_id,
2802 5, Decode(wdtv.transaction_type_id, 35, wdtv.transaction_source_id),
2803 8, wdtv.transaction_source_id,
2804 13, Decode(wdtv.transaction_type_id, 51, wdtv.transaction_source_id),
2805 -1) = nvl(v_transaction_source_id, -1))
2806 OR (p_task_method = 'PICKBYLABEL' AND wdtv.cartonization_id = l_cartonization_id)
2807 OR (p_task_method = 'CLUSTERPICKBYLABEL' AND
2808 wdtv.cartonization_id IN (SELECT * FROM TABLE(wms_picking_pkg.list_cartonization_id))))
2809 AND wdtv.organization_id = p_sign_on_org_id
2810 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
2811 AND NVL(wdtv.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.subinventory_code, '@@@'))
2812 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
2813 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
2814 AND wdtv.locator_id = loc.inventory_location_id(+)
2815 AND wdtv.subinventory_code = sub.secondary_inventory_name
2816 AND wdtv.organization_id = sub.organization_id
2817 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
2818 AND moh.header_id(+) = mol.header_id
2819 AND Decode(Nvl(moh.move_order_type, -1),
2820 2, l_rep_allowed,
2821 1, l_mot_moi_allowed,
2822 -1, 1,
2823 1) = 1
2824 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
2825 (SELECT NULL
2826 FROM mtl_material_transactions_temp mmtt
2827 WHERE mmtt.transaction_temp_id = wdtv.task_id
2828 AND mmtt.parent_line_id IS NOT NULL
2829 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
2830 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
2831 AND NOT EXISTS -- exclude tasks already dispatched and queued
2832 (SELECT NULL
2833 FROM wms_dispatched_tasks wdt1
2834 WHERE wdt1.transaction_temp_id = wdtv.task_id
2835 AND wdt1.task_type = wdtv.wms_task_type_id)
2836 -- Bug 7254397: exclude tasks from locked cartons
2837 AND NOT EXISTS
2838 ( SELECT 1
2839 FROM WMS_DISPATCH_TASKS_GTMP
2840 WHERE p_task_method = 'CLUSTERPICKBYLABEL'
2841 AND
2842 grouping_document_number = wdtv.cartonization_id)
2843 -- excluded skipped taskS
2844 AND wdtv.task_id NOT IN
2845 (SELECT wdtv.task_id
2846 FROM wms_skip_task_exceptions wste, mtl_parameters mp
2847 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
2848 AND wste.task_id = wdtv.task_id
2849 AND wste.organization_id = mp.organization_id)
2850 --J Addition
2851 AND wdtv.subinventory_code not in (
2852 SELECT wd.subinventory_code
2853 FROM wms_devices_b wd
2854 , wms_bus_event_devices wbed
2855 WHERE 1 = 1
2856 and wd.device_id = wbed.device_id
2857 AND wbed.organization_id = wd.organization_id
2858 AND wd.enabled_flag = 'Y'
2859 AND wbed.enabled_flag = 'Y'
2860 AND wbed.business_event_id = 10
2861 AND wd.subinventory_code IS NOT NULL
2862 AND wd.force_sign_on_flag = 'Y'
2863 AND wd.device_id NOT IN (SELECT device_id
2864 FROM wms_device_assignment_temp
2865 WHERE employee_id = p_sign_on_emp_id)
2866 )
2867 ORDER BY
2868 sub_picking_order,
2869 loc_picking_order,
2870 distance,
2871 task_priority desc,
2872 batch_id,
2873 task_status DESC,
2874 task_num;
2875
2876 -- Cursor #3 for selecting the ordered tasks
2877 -- 1. Non cycle count tasks (0)
2878 -- 2. Cycle count tasks (1)
2879 CURSOR l_curs_ordered_tasks_01(v_task_id NUMBER,
2880 v_task_type NUMBER) IS
2881 SELECT DISTINCT
2882 qt.task_id task_num,
2883 qt.subinventory_code,
2884 qt.locator_id,
2885 qt.pick_slip,
2886 qt.transaction_uom,
2887 qt.transaction_quantity,
2888 qt.lot_number,
2889 qt.operation_plan_id,
2890 qt.standard_operation_id,
2891 wdt.effective_start_date,
2892 wdt.effective_end_date,
2893 wdt.person_resource_id,
2894 wdt.machine_resource_id,
2895 wdt.task_type wms_task_type_id,
2896 nvl(wdt.priority, 0) task_priority,
2897 To_number(NULL) batch_id,
2898 To_number(NULL) line_id,
2899 sub.picking_order sub_picking_order,
2900 loc.picking_order loc_picking_order,
2901 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2902 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2903 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2904 wdt.status task_status, --bug 4310093
2905 qt.transaction_type_id,
2906 qt.transaction_action_id,
2907 qt.transaction_source_id,
2908 qt.transaction_source_type_id
2909 FROM wms_dispatched_tasks wdt,
2910 (SELECT
2911 MIN(mcce.cycle_count_entry_id) task_id,
2912 TO_NUMBER(NULL) pick_slip,
2913 To_number(NULL) cartonization_id,
2914 mcce.organization_id,
2915 mcce.subinventory subinventory_code,
2916 mcce.locator_id,
2917 mcce.inventory_item_id,
2918 mcce.revision,
2919 To_char(NULL) transaction_uom,
2920 To_number(NULL) transaction_quantity,
2921 MIN(mcce.lot_number) lot_number,
2922 To_number(NULL) operation_plan_id,
2923 MIN(mcce.standard_operation_id) standard_operation_id,
2924 To_number(NULL) move_order_line_id,
2925 4 transaction_type_id,
2926 4 transaction_action_id,
2927 mcce.cycle_count_header_id transaction_source_id,
2928 9 transaction_source_type_id
2929 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
2930 WHERE mcce.entry_status_code IN(1, 3)
2931 AND NVL(mcce.export_flag, 2) = 2
2932 -- bug 3972076
2933 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
2934 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
2935
2936 -----bug6903708---
2937 AND mcce.organization_id = mcch.organization_id
2938 AND mcch.organization_id = p_sign_on_org_id
2939 ---------------------------
2940
2941 AND NVL(mcch.disable_date,sysdate+1)> sysdate
2942 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) qt,
2943 mtl_secondary_inventories sub,
2944 mtl_item_locations loc,
2945 (SELECT
2946 bsor.standard_operation_id,
2947 bre.resource_id,
2948 bre.inventory_item_id equipment_id
2949 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
2950 WHERE bsor.resource_id = bre.resource_id
2951 AND br.resource_type = 1
2952 AND bsor.resource_id = br.resource_id) e
2953 WHERE wdt.transaction_temp_id = qt.task_id
2954 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
2955 AND wdt.person_id = p_sign_on_emp_id
2956 AND wdt.organization_id = p_sign_on_org_id
2957 AND (qt.task_id = v_task_id AND wdt.task_type = v_task_type)
2958 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
2959 AND wdt.user_task_type = e.standard_operation_id(+)
2960 AND NVL(qt.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(qt.subinventory_code, '@@@'))
2961 AND qt.organization_id = sub.organization_id
2962 AND qt.subinventory_code = sub.secondary_inventory_name
2963 AND qt.organization_id = loc.organization_id
2964 AND qt.locator_id = loc.inventory_location_id
2965 UNION ALL
2966 SELECT DISTINCT
2967 wdtv.task_id task_num,
2968 wdtv.subinventory_code,
2969 wdtv.locator_id,
2970 NVL(wdtv.pick_slip_number, -1) pick_slip,
2971 wdtv.transaction_uom,
2972 wdtv.transaction_quantity,
2973 wdtv.lot_number,
2974 wdtv.operation_plan_id,
2975 wdtv.user_task_type_id standard_operation_id,
2976 v.effective_start_date,
2977 v.effective_end_date,
2978 v.role person_resource_id,
2979 v.equipment machine_resource_id,
2980 wdtv.wms_task_type_id,
2981 nvl(wdtv.task_priority, 0),
2982 To_number(NULL) batch_id,
2983 To_number(NULL) line_id,
2984 sub.picking_order sub_picking_order,
2985 loc.picking_order loc_picking_order,
2986 ((nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x) +
2987 (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y) +
2988 (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)) distance,
2989 task_status,
2990 wdtv.transaction_type_id,
2991 wdtv.transaction_action_id,
2992 wdtv.transaction_source_id,
2993 wdtv.transaction_source_type_id
2994 FROM
2995 -- inlined wms_dispatchable_tasks_v, bug 2648133
2996 (SELECT
2997 MIN(mcce.cycle_count_entry_id) task_id,
2998 MIN(mcce.standard_operation_id) user_task_type_id,
2999 3 wms_task_type_id,
3000 mcce.organization_id,
3001 mcce.subinventory subinventory_code,
3002 mcce.locator_id,
3003 MIN(task_priority) task_priority,
3004 mcce.revision revision,
3005 MIN(mcce.lot_number) lot_number,
3006 '' transaction_uom,
3007 TO_NUMBER(NULL) transaction_quantity,
3008 TO_NUMBER(NULL) pick_rule_id,
3009 TO_NUMBER(NULL) pick_slip_number,
3010 TO_NUMBER(NULL) cartonization_id,
3011 mcce.inventory_item_id,
3012 TO_NUMBER(NULL) move_order_line_id,
3013 1 task_status,
3014 4 transaction_type_id,
3015 4 transaction_action_id,
3016 mcce.cycle_count_header_id transaction_source_id,
3017 9 transaction_source_type_id,
3018 To_number(NULL) operation_plan_id
3019 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
3020 WHERE mcce.entry_status_code IN(1, 3)
3021 AND NVL(mcce.export_flag, 2) = 2
3022 -- bug 3972076
3023 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
3024 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
3025
3026 -----bug6903708---
3027 AND mcce.organization_id = mcch.organization_id
3028 AND mcch.organization_id = p_sign_on_org_id
3029 ---------------------------
3030
3031 AND NVL(mcch.disable_date,sysdate+1)> sysdate
3032 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv,
3033 -- inlined wms_person_resource_utt_v, bug 2648133
3034 (SELECT
3035 utt_emp.standard_operation_id standard_operation_id,
3036 utt_emp.resource_id role,
3037 utt_eqp.resource_id equipment,
3038 utt_emp.person_id emp_id,
3039 utt_emp.effective_start_date,
3040 utt_emp.effective_end_date,
3041 utt_eqp.inventory_item_id eqp_id,
3042 NULL eqp_srl /* removed for bug 2095237 */
3043 FROM
3044 (SELECT
3045 x_utt_res1.standard_operation_id standard_operation_id,
3046 x_utt_res1.resource_id resource_id,
3047 x_emp_r.person_id,
3048 x_emp_r.effective_start_date,
3049 x_emp_r.effective_end_date
3050 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
3051 WHERE x_utt_res1.resource_id = r1.resource_id
3052 AND r1.resource_type = 2
3053 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp,
3054 (SELECT
3055 x_utt_res2.standard_operation_id standard_operation_id,
3056 x_utt_res2.resource_id,
3057 x_eqp_r.inventory_item_id
3058 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
3059 WHERE x_utt_res2.resource_id = r2.resource_id
3060 AND r2.resource_type = 1
3061 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
3062 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v,
3063 mtl_item_locations loc,
3064 mtl_secondary_inventories sub
3065 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
3066 AND (wdtv.task_id = v_task_id AND wdtv.wms_task_type_id = v_task_type)
3067 AND wdtv.organization_id = p_sign_on_org_id
3068 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
3069 AND NVL(wdtv.subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.subinventory_code, '@@@'))
3070 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
3071 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
3072 AND wdtv.locator_id = loc.inventory_location_id(+)
3073 AND wdtv.subinventory_code = sub.secondary_inventory_name
3074 AND wdtv.organization_id = sub.organization_id
3075 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
3076 (SELECT NULL
3077 FROM mtl_material_transactions_temp mmtt
3078 WHERE mmtt.transaction_temp_id = wdtv.task_id
3079 AND mmtt.parent_line_id IS NOT NULL
3080 AND mmtt.parent_line_id <> mmtt.transaction_temp_id
3081 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
3082 AND NOT EXISTS -- exclude tasks already dispatched and queued
3083 (SELECT NULL
3084 FROM wms_dispatched_tasks wdt1
3085 WHERE wdt1.transaction_temp_id = wdtv.task_id
3086 AND wdt1.task_type = wdtv.wms_task_type_id)
3087 -- excluded skipped tasks
3088 AND wdtv.task_id NOT IN
3089 (SELECT wdtv.task_id
3090 FROM wms_skip_task_exceptions wste, mtl_parameters mp
3091 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
3092 AND wste.task_id = wdtv.task_id
3093 AND wste.organization_id = mp.organization_id)
3094 --J Addition
3095 AND wdtv.subinventory_code not in (
3096 SELECT wd.subinventory_code
3097 FROM wms_devices_b wd
3098 , wms_bus_event_devices wbed
3099 WHERE 1 = 1
3100 and wd.device_id = wbed.device_id
3101 AND wbed.organization_id = wd.organization_id
3102 AND wd.enabled_flag = 'Y'
3103 AND wbed.enabled_flag = 'Y'
3104 AND wbed.business_event_id = 10
3105 AND wd.subinventory_code IS NOT NULL
3106 AND wd.force_sign_on_flag = 'Y'
3107 AND wd.device_id NOT IN (SELECT device_id
3108 FROM wms_device_assignment_temp
3109 WHERE employee_id = p_sign_on_emp_id)
3110 )
3111 ORDER BY
3112 sub_picking_order,
3113 loc_picking_order,
3114 distance,
3115 task_priority desc,
3116 batch_id,
3117 task_status DESC,
3118 task_num;
3119
3120 CURSOR c_task_lock_check(v_transaction_temp_id NUMBER) IS
3121 SELECT transaction_temp_id
3122 FROM mtl_material_transactions_temp
3123 WHERE transaction_temp_id = v_transaction_temp_id
3124 FOR UPDATE nowait;
3125
3126 CURSOR c_pick_slip_lock_check(v_pick_slip_number NUMBER) IS
3127 SELECT transaction_temp_id
3128 FROM mtl_material_transactions_temp
3129 WHERE pick_slip_number = v_pick_slip_number
3130 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(subinventory_code, '@@@'))
3131 FOR UPDATE nowait;
3132
3133 CURSOR c_order_lock_check(v_order_header_id NUMBER,
3134 v_transaction_source_type_id NUMBER,
3135 v_transaction_action_id NUMBER,
3136 v_transaction_type_id NUMBER) IS
3137 SELECT transaction_temp_id
3138 FROM mtl_material_transactions_temp
3139 WHERE transaction_source_id = v_order_header_id
3140 AND transaction_source_type_id = v_transaction_source_type_id
3141 AND transaction_action_id = v_transaction_action_id
3142 AND transaction_type_id = v_transaction_type_id
3143 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(subinventory_code, '@@@'))
3144 FOR UPDATE nowait;
3145
3146 CURSOR c_carton_lock_check(v_cartonization_id NUMBER) IS
3147 SELECT transaction_temp_id
3148 FROM mtl_material_transactions_temp
3149 WHERE cartonization_id = v_cartonization_id
3150 AND NVL(subinventory_code, '@@@') = NVL(p_sign_on_zone, NVL(subinventory_code, '@@@'))
3151 FOR UPDATE nowait;
3152
3153 CURSOR c_cycle_count_lock_check(v_cycle_count_entry_id NUMBER) IS
3154 SELECT cycle_count_entry_id
3155 FROM mtl_cycle_count_entries
3156 WHERE cycle_count_entry_id = v_cycle_count_entry_id
3157 FOR UPDATE nowait;
3158
3159 CURSOR c_task_filter(v_filter_name VARCHAR2) IS
3160 SELECT task_filter_source, task_filter_value
3161 FROM wms_task_filter_b wtf, wms_task_filter_dtl wtfd
3162 WHERE task_filter_name = v_filter_name
3163 AND wtf.task_filter_id = wtfd.task_filter_id;
3164
3165 CURSOR lpn_ids_cur IS
3166 SELECT column_value LPN_ID FROM TABLE(wms_picking_pkg.list_cartonization_id);
3167
3168 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3169
3170 BEGIN
3171 IF (l_debug = 1) THEN
3172 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3173 END IF;
3174 IF (l_debug = 1) THEN
3175 -- Bug: 7254397
3176 for lpns_rec in lpn_ids_cur
3177 loop
3178 print_debug('LPNs: ' || To_char(lpns_rec.LPN_ID), 9);
3179 end loop;
3180 -- Bug: 7254397
3181 END IF;
3182
3183 l_progress := '10';
3184
3185 -- This API is query only, therefore does not create a save point
3186
3187 -- Initialize message list if p_init_msg_list is set to TRUE.
3188 IF fnd_api.to_boolean(p_init_msg_list) THEN
3189 fnd_msg_pub.initialize;
3190 END IF;
3191
3192 -- Initialize API return status to success
3193 x_return_status := fnd_api.g_ret_sts_success;
3194
3195 -- API body
3196 -- preprocess input parameters
3197
3198 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
3199
3200 IF l_sequence_picks_across_waves IS NULL OR p_task_method = 'WAVE' THEN
3201 l_sequence_picks_across_waves := 2;
3202 END IF;
3203 --bug 6326482
3204 l_ignore_equipment := NVL(fnd_profile.VALUE('WMS_IGNORE_EQUIPMENT'), 1);
3205 IF(l_ignore_equipment = 1) then
3206 l_q_sign_on_equipment_id := NULL;
3207 Else
3208 IF p_sign_on_equipment_srl = 'NONE' THEN
3209 l_q_sign_on_equipment_id := -999;
3210 ELSE
3211 l_q_sign_on_equipment_id := p_sign_on_equipment_id;
3212 END IF;
3213 END IF ;
3214 --bug 6326482
3215
3216 IF p_sign_on_equipment_srl = 'NONE' THEN
3217 l_sign_on_equipment_srl := NULL;
3218 l_sign_on_equipment_id := -999;
3219 ELSE
3220 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
3221 l_sign_on_equipment_id := p_sign_on_equipment_id;
3222 END IF;
3223
3224 -- APL
3225 IF x_grouping_document_type = 'CARTON' THEN
3226 l_cartonization_id := x_grouping_document_number;
3227 END IF;
3228
3229 -- Populate the task filter variables
3230 IF (l_debug = 1) THEN
3231 print_debug('Task Filter: ' || p_task_filter, 9);
3232 END IF;
3233
3234 FOR task_filter_rec IN c_task_filter(p_task_filter) LOOP
3235
3236 IF (l_debug = 1) THEN
3237 print_debug('Task Filter Source: ' || task_filter_rec.task_filter_source, 9);
3238 print_debug('Task Filter Value: ' || task_filter_rec.task_filter_value, 9);
3239 END IF;
3240
3241 IF task_filter_rec.task_filter_value = 'Y' THEN
3242 IF task_filter_rec.task_filter_source = 1 THEN -- Internal Order
3243 l_io_allowed := 1;
3244 l_non_cc_allowed := 1;
3245 ELSIF task_filter_rec.task_filter_source = 2 THEN -- Move Order Issue
3246 l_moi_allowed := 1;
3247 l_mot_moi_allowed := 1;
3248 l_non_cc_allowed := 1;
3249 ELSIF task_filter_rec.task_filter_source = 3 THEN -- Move Order Transfer
3250 l_mot_allowed := 1;
3251 l_mot_rep_allowed := 1;
3252 l_mot_moi_allowed := 1;
3253 l_non_cc_allowed := 1;
3254 ELSIF task_filter_rec.task_filter_source = 4 THEN -- Replenishment
3255 l_rep_allowed := 1;
3256 l_mot_rep_allowed := 1;
3257 l_non_cc_allowed := 1;
3258 ELSIF task_filter_rec.task_filter_source = 5 THEN -- Sales Order
3259 l_so_allowed := 1;
3260 l_non_cc_allowed := 1;
3261 ELSIF task_filter_rec.task_filter_source = 6 THEN -- Work Order
3262 l_wip_allowed := 1;
3263 l_non_cc_allowed := 1;
3264 ELSIF task_filter_rec.task_filter_source = 7 THEN -- Cycle Counting
3265 l_cc_allowed := 1;
3266 END IF;
3267 END IF;
3268
3269 END LOOP;
3270
3271
3272 IF (l_debug = 1) THEN
3273 print_debug('l_so_allowed: ' || l_so_allowed, 9);
3274 print_debug('l_io_allowed: ' || l_io_allowed, 9);
3275 print_debug('l_wip_allowed: ' || l_wip_allowed, 9);
3276 print_debug('l_mot_rep_allowed: ' || l_mot_rep_allowed, 9);
3277 print_debug('l_mot_allowed: ' || l_mot_allowed, 9);
3278 print_debug('l_rep_allowed: ' || l_rep_allowed, 9);
3279 print_debug('l_mot_moi_allowed: ' || l_mot_moi_allowed, 9);
3280 print_debug('l_moi_allowed: ' || l_moi_allowed, 9);
3281 print_debug('l_cc_allowed: ' || l_cc_allowed, 9);
3282 print_debug('l_non_cc_allowed: ' || l_non_cc_allowed, 9);
3283 END IF;
3284
3285 l_progress := '20';
3286
3287
3288 -- select last task this operator was working on
3289 BEGIN
3290 SELECT transaction_temp_id, task_type, loaded_time
3291 INTO l_last_loaded_task_id, l_last_loaded_task_type, l_last_loaded_time
3292 FROM (SELECT transaction_temp_id, task_type, loaded_time
3293 FROM wms_dispatched_tasks wdt
3294 WHERE wdt.person_id = p_sign_on_emp_id
3295 AND wdt.loaded_time = (SELECT MAX(loaded_time)
3296 FROM wms_dispatched_tasks
3297 WHERE person_id = p_sign_on_emp_id))
3298 WHERE ROWNUM = 1; -- make sure only one task selected
3299
3300 l_progress := '31';
3301 EXCEPTION
3302 WHEN OTHERS THEN
3303 l_last_loaded_task_id := -1;
3304 END;
3305
3306 IF (l_debug = 1) THEN
3307 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
3308 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
3309 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
3310 END IF;
3311
3312 -- select last task this operator completed
3313 BEGIN
3314 l_progress := '32';
3315
3316 SELECT transaction_id, task_type, loaded_time
3317 INTO l_last_dropoff_task_id, l_last_dropoff_task_type, l_last_dropoff_time
3318 FROM (SELECT transaction_id, task_type, loaded_time
3319 FROM wms_dispatched_tasks_history wdth
3320 WHERE wdth.person_id = p_sign_on_emp_id
3321 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
3322 FROM wms_dispatched_tasks_history
3323 WHERE person_id = p_sign_on_emp_id))
3324 WHERE ROWNUM = 1; -- make sure only one task selected
3325
3326 l_progress := '33';
3327 EXCEPTION
3328 WHEN OTHERS THEN
3329 l_last_dropoff_task_id := -1;
3330 END;
3331
3332 IF (l_debug = 1) THEN
3333 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
3334 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
3335 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
3336 END IF;
3337
3338 IF l_last_dropoff_task_id = -1 AND l_last_loaded_task_id = -1 THEN
3339 l_last_task_id := -1;
3340 ELSIF l_last_dropoff_task_id = -1 THEN
3341 l_last_task_id := l_last_loaded_task_id;
3342 l_last_task_type := l_last_loaded_task_type;
3343 l_last_task_is_drop := FALSE;
3344 ELSIF l_last_loaded_task_id = -1 THEN
3345 l_last_task_id := l_last_dropoff_task_id;
3346 l_last_task_type := l_last_dropoff_task_type;
3347 l_last_task_is_drop := TRUE;
3348 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
3349 l_last_task_id := l_last_dropoff_task_id;
3350 l_last_task_type := l_last_dropoff_task_type;
3351 l_last_task_is_drop := TRUE;
3352 END IF;
3353
3354 IF (l_debug = 1) THEN
3355 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
3356 END IF;
3357
3358 -- select locator coordinates of the the last task
3359 IF l_last_task_id <> -1 THEN -- make sure there is a last task
3360
3361 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
3362 -- get the location from wms_dispatchable_tasks_v
3363 BEGIN
3364 l_progress := '35';
3365
3366 -- use Nvl to make sure if coordinates not defined, use 0
3367 SELECT NVL(loc.x_coordinate, 0), NVL(loc.y_coordinate, 0), NVL(loc.z_coordinate, 0)
3368 INTO l_cur_x, l_cur_y, l_cur_z
3369 FROM mtl_item_locations loc,
3370 (SELECT
3371 transaction_temp_id task_id,
3372 standard_operation_id user_task_type_id,
3373 wms_task_type wms_task_type_id,
3374 organization_id organization_id,
3375 subinventory_code zone,
3376 locator_id locator_id,
3377 task_priority task_priority,
3378 revision revision,
3379 lot_number lot_number,
3380 transaction_uom transaction_uom,
3381 transaction_quantity transaction_quantity,
3382 pick_rule_id pick_rule_id,
3383 pick_slip_number pick_slip_number,
3384 cartonization_id cartonization_id,
3385 inventory_item_id,
3386 move_order_line_id
3387 FROM mtl_material_transactions_temp
3388 WHERE wms_task_type IS NOT NULL
3389 AND transaction_status = 2
3390 UNION ALL
3391 SELECT
3392 MIN(cycle_count_entry_id) task_id,
3393 MIN(standard_operation_id) user_task_type_id,
3394 3 wms_task_type_id,
3395 organization_id organization_id,
3396 subinventory zone,
3397 locator_id locator_id,
3398 MIN(task_priority) task_priority,
3399 revision revision,
3400 MIN(lot_number) lot_number,
3401 '' transaction_uom,
3402 TO_NUMBER(NULL) transaction_quantity,
3403 TO_NUMBER(NULL) pick_rule_id,
3404 TO_NUMBER(NULL) pick_slip_number,
3405 TO_NUMBER(NULL) cartonization_id,
3406 inventory_item_id,
3407 TO_NUMBER(NULL) move_order_line_id
3408 FROM mtl_cycle_count_entries
3409 WHERE entry_status_code IN(1, 3)
3410 AND NVL(export_flag, 2) = 2
3411 -- bug 3972076
3412 --AND NVL(TRUNC(count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
3413 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision) wdtv -- inlined wms_dispatchable_tasks_v, bug 2648133
3414 WHERE wdtv.locator_id = loc.inventory_location_id
3415 AND wdtv.organization_id = loc.organization_id
3416 AND wdtv.task_id = l_last_task_id
3417 AND wdtv.wms_task_type_id = l_last_task_type;
3418
3419 -- Added the previous line since the task_id in the view
3420 -- might not be unique since it is the transaction_temp_id
3421 -- if it comes from MMTT but the cycle_count_entry_id if
3422 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
3423 l_progress := '36';
3424 EXCEPTION
3425 WHEN OTHERS THEN
3426 -- locator definition descripency
3427 l_cur_x := 0;
3428 l_cur_y := 0;
3429 l_cur_z := 0;
3430 END;
3431 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
3432 IF l_last_task_type <> 3 THEN -- not cycle count task
3433 -- get the location from mtl_material_transactions
3434 BEGIN
3435 l_progress := '37';
3436
3437 -- use Nvl to make sure if coordinates not defined, use 0
3438 SELECT NVL(loc.x_coordinate, 0)
3439 , NVL(loc.y_coordinate, 0)
3440 , NVL(loc.z_coordinate, 0)
3441 INTO l_cur_x
3442 , l_cur_y
3443 , l_cur_z
3444 FROM mtl_item_locations loc, mtl_material_transactions mmt
3445 WHERE mmt.locator_id = loc.inventory_location_id
3446 AND mmt.organization_id = loc.organization_id
3447 AND mmt.transaction_set_id = l_last_task_id
3448 AND ROWNUM = 1;
3449
3450 l_progress := '38';
3451 EXCEPTION
3452 WHEN OTHERS THEN
3453 -- locator definition descripency
3454 l_cur_x := 0;
3455 l_cur_y := 0;
3456 l_cur_z := 0;
3457 END;
3458 ELSE -- l_last_task_type <> 3 (Cyclt Count task)
3459 -- get the location from mtl_cycle_count_entries
3460 BEGIN
3461 l_progress := '39';
3462
3463 -- use Nvl to make sure if coordinates not defined, use 0
3464 SELECT NVL(loc.x_coordinate, 0)
3465 , NVL(loc.y_coordinate, 0)
3466 , NVL(loc.z_coordinate, 0)
3467 INTO l_cur_x
3468 , l_cur_y
3469 , l_cur_z
3470 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
3471 WHERE mcce.locator_id = loc.inventory_location_id
3472 AND mcce.organization_id = loc.organization_id
3473 AND mcce.cycle_count_entry_id = l_last_task_id;
3474
3475 l_progress := '40';
3476 EXCEPTION
3477 WHEN OTHERS THEN -- adf
3478 -- locator definition descripency
3479 l_cur_x := 0;
3480 l_cur_y := 0;
3481 l_cur_z := 0;
3482 END;
3483 END IF; -- l_last_task_type <> 3
3484 END IF; -- l_last_task_is_drop <> TRUE
3485 ELSE -- there is not a previous task at all
3486 l_cur_x := 0;
3487 l_cur_y := 0;
3488 l_cur_z := 0;
3489 END IF; -- l_last_task_id <> -1
3490
3491 l_progress := '45';
3492
3493 -- Select the most optimal task
3494 -- first select eligible tasks according to employee sign on information
3495 -- order tasks by task priority, locator picking order and locator coordinates
3496 -- approximated to current locator
3497
3498 IF (l_debug = 1) THEN
3499 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
3500 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
3501 print_debug('l_cartonization_id => ' || l_cartonization_id, 4);
3502 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
3503 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
3504 print_debug('l_cur_x => ' || l_cur_x, 4);
3505 print_debug('l_cur_y => ' || l_cur_y, 4);
3506 print_debug('l_cur_z => ' || l_cur_z, 4);
3507 END IF;
3508 --Bug 7254397, added loop for detecting and storing
3509 IF p_task_method = 'CLUSTERPICKBYLABEL' THEN
3510 BEGIN
3511 l_total_lpns := wms_picking_pkg.get_total_lpns;
3512 l_locked_lpns := 0;
3513 FOR lpn_id_rec IN lpn_ids_cur
3514 LOOP
3515 IF l_debug = 1 THEN
3516 print_debug('Check carton ID '|| lpn_id_rec.LPN_ID || ' for locking.', 4);
3517 END IF;
3518
3519 BEGIN
3520 OPEN c_carton_lock_check(lpn_id_rec.LPN_ID);
3521 CLOSE c_carton_lock_check;
3522
3523 EXCEPTION
3524 WHEN OTHERS THEN
3525 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3526 l_locked_lpns := l_locked_lpns + 1;
3527 IF l_debug = 1 THEN
3528 print_debug('Carton ' || lpn_id_rec.LPN_ID ||' is locked by other user. ', 4);
3529 END IF;
3530 store_locked_tasks
3531 (p_grp_doc_type => p_task_method,
3532 p_grp_doc_num => lpn_id_rec.LPN_ID,
3533 p_grp_src_type_id => NULL,
3534 x_return_status => l_return_status);
3535
3536 IF l_debug = 1 THEN
3537 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
3538 END IF;
3539
3540 IF l_return_status = fnd_api.g_ret_sts_error THEN
3541 RAISE fnd_api.g_exc_error;
3542 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3543 RAISE fnd_api.g_exc_unexpected_error;
3544 END IF;
3545 IF l_locked_lpns = l_total_lpns THEN
3546 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
3547 fnd_msg_pub.ADD;
3548
3549 IF (l_debug = 1) THEN
3550 print_debug('dispatch_task - No eligible picking tasks ', 4);
3551 END IF;
3552 RAISE fnd_api.g_exc_error;
3553 END IF;
3554 l_return_status := fnd_api.g_ret_sts_success;
3555 END IF;
3556
3557 IF c_carton_lock_check%isopen THEN
3558 CLOSE c_carton_lock_check;
3559 END IF;
3560 END;
3561 END LOOP;
3562 END;
3563 END IF;
3564 -- Bug 7254397
3565 IF p_task_method = 'CLUSTERPICKBYLABEL' THEN
3566 GOTO end_loop;
3567 END IF;
3568 -- open and fetch appropriate cursor
3569 -- start bug 2832818
3570 LOOP -- added loop for detecting lock for a pick slip
3571 l_is_locked := FALSE;
3572 -- bug 4358107
3573 l_pick_slip := 0;
3574 l_transaction_source_id := NULL;
3575 l_transaction_source_type_id := NULL;
3576 l_transaction_action_id := NULL;
3577 l_transaction_type_id := NULL;
3578 l_task_id := NULL;
3579 l_task_type_id := NULL;
3580 l_task_priority := NULL;
3581 l_batch_id := NULL;
3582 l_loc_pick_order := NULL;
3583 l_distance := NULL;
3584 l_task_status := NULL;
3585 -- bug 4358107
3586 -- end bug 2832818
3587
3588 IF p_sign_on_zone IS NOT NULL THEN -- subinventory passed in
3589
3590 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3591
3592 IF (l_debug = 1) THEN
3593 print_debug('Opt task cursor: subinventory passed, both cycle count and non cycle count', 4);
3594 END IF;
3595
3596 OPEN l_curs_opt_task_111;
3597
3598 FETCH l_curs_opt_task_111
3599 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3600 l_sub_pick_order, l_loc_pick_order, l_distance,
3601 l_task_status, l_transaction_type_id,
3602 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3603
3604 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3605
3606 IF (l_debug = 1) THEN
3607 print_debug('Opt task cursor: subinventory passed, only non cycle count', 4);
3608 print_debug('Opt task cursor: l_curs_opt_task_110', 4);
3609 END IF;
3610
3611 OPEN l_curs_opt_task_110;
3612
3613 FETCH l_curs_opt_task_110
3614 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3615 l_sub_pick_order, l_loc_pick_order, l_distance,
3616 l_task_status, l_transaction_type_id,
3617 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3618
3619 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3620
3621 IF (l_debug = 1) THEN
3622 print_debug('Opt task cursor: subinventory passed, only non cycle count', 4);
3623 END IF;
3624
3625 OPEN l_curs_opt_task_101;
3626
3627 FETCH l_curs_opt_task_101
3628 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3629 l_sub_pick_order, l_loc_pick_order, l_distance,
3630 l_task_status, l_transaction_type_id,
3631 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3632
3633 END IF;
3634
3635 ELSE -- No subinventory passed in
3636
3637 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3638
3639 IF (l_debug = 1) THEN
3640 print_debug('Opt task cursor: subinventory not passed, both cycle count and non cycle count', 4);
3641 END IF;
3642
3643 OPEN l_curs_opt_task_011;
3644
3645 FETCH l_curs_opt_task_011
3646 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3647 l_sub_pick_order, l_loc_pick_order, l_distance,
3648 l_task_status, l_transaction_type_id,
3649 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3650
3651 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3652
3653 IF (l_debug = 1) THEN
3654 print_debug('Opt task cursor: subinventory not passed, only non cycle count', 4);
3655 print_debug('Opt task cursor: l_curs_opt_task_010', 4);
3656 END IF;
3657
3658 OPEN l_curs_opt_task_010;
3659
3660 FETCH l_curs_opt_task_010
3661 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3662 l_sub_pick_order, l_loc_pick_order, l_distance,
3663 l_task_status, l_transaction_type_id,
3664 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3665
3666 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3667
3668 IF (l_debug = 1) THEN
3669 print_debug('Opt task cursor: subinventory not passed, only non cycle count', 4);
3670 print_debug('Opt task cursor: l_curs_opt_task_001', 4);
3671 END IF;
3672
3673 OPEN l_curs_opt_task_001;
3674
3675 FETCH l_curs_opt_task_001
3676 INTO l_task_id, l_pick_slip, l_task_type_id, l_task_priority, l_batch_id,
3677 l_sub_pick_order, l_loc_pick_order, l_distance,
3678 l_task_status, l_transaction_type_id,
3679 l_transaction_action_id, l_transaction_source_id, l_transaction_source_type_id;
3680
3681 END IF;
3682
3683 END IF;
3684
3685 -- Wave, Discrete, Order, Cluster, Label, Manual, Bulk
3686 IF l_task_type_id <> 3 THEN -- Check the lock for non cycle count tasks
3687 IF p_task_method IN ('WAVE', 'BULK') THEN
3688 IF l_debug = 1 THEN
3689 print_debug('Check task '|| l_task_id || ' for locking.', 4);
3690 END IF;
3691
3692 BEGIN
3693 OPEN c_task_lock_check(l_task_id);
3694 CLOSE c_task_lock_check;
3695 EXCEPTION
3696 WHEN OTHERS THEN
3697 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3698 l_is_locked := TRUE;
3699
3700 IF l_debug = 1 THEN
3701 print_debug('Task ' || l_task_id ||' is locked by other user. ', 4);
3702 END IF;
3703
3704 ELSE
3705 l_is_locked := FALSE;
3706 END IF;
3707
3708 IF c_task_lock_check%isopen THEN
3709 CLOSE c_task_lock_check;
3710 END IF;
3711 END;
3712 ELSIF p_task_method = 'DISCRETE' THEN
3713 IF l_debug = 1 THEN
3714 print_debug('Check pick_slip_number'|| l_pick_slip || ' for locking.', 4);
3715 END IF;
3716
3717 BEGIN
3718 OPEN c_pick_slip_lock_check(l_pick_slip);
3719 CLOSE c_pick_slip_lock_check;
3720
3721 l_is_locked := FALSE;
3722 x_grouping_document_type := 'PICK_SLIP';
3723 x_grouping_document_number := l_pick_slip;
3724 x_grouping_source_type_id := l_transaction_source_type_id;
3725
3726 EXCEPTION
3727 WHEN OTHERS THEN
3728 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3729 l_is_locked := TRUE;
3730
3731 IF l_debug = 1 THEN
3732 print_debug('pick_slip_number ' || l_pick_slip ||' is locked by other user. ', 4);
3733 END IF;
3734 -- bug 4358107
3735 store_locked_tasks
3736 (p_grp_doc_type => p_task_method,
3737 p_grp_doc_num => l_pick_slip,
3738 p_grp_src_type_id => NULL,
3739 x_return_status => l_return_status);
3740
3741 IF l_debug = 1 THEN
3742 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
3743 END IF;
3744
3745 IF l_return_status = fnd_api.g_ret_sts_error THEN
3746 RAISE fnd_api.g_exc_error;
3747 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3748 RAISE fnd_api.g_exc_unexpected_error;
3749 END IF;
3750 l_return_status := fnd_api.g_ret_sts_success;
3751 -- bug 4358107
3752
3753 END IF;
3754
3755 IF c_pick_slip_lock_check%isopen THEN
3756 CLOSE c_pick_slip_lock_check;
3757 END IF;
3758 END;
3759 ELSIF p_task_method = 'ORDERPICK' THEN
3760 IF l_debug = 1 THEN
3761 print_debug('Check order '|| l_transaction_source_id || ' for locking.', 4);
3762 END IF;
3763
3764 BEGIN
3765 OPEN c_order_lock_check(l_transaction_source_id,
3766 l_transaction_source_type_id,
3767 l_transaction_action_id,
3768 l_transaction_type_id);
3769 CLOSE c_order_lock_check;
3770
3771 l_is_locked := FALSE;
3772 x_grouping_document_type := 'ORDER';
3773 x_grouping_document_number := l_transaction_source_id;
3774 x_grouping_source_type_id := l_transaction_source_type_id;
3775
3776 EXCEPTION
3777 WHEN OTHERS THEN
3778 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3779 l_is_locked := TRUE;
3780
3781 IF l_debug = 1 THEN
3782 print_debug('Order ' || l_transaction_source_id ||' is locked by other user. ', 4);
3783 END IF;
3784 -- bug 4358107
3785 store_locked_tasks
3786 (p_grp_doc_type => p_task_method,
3787 p_grp_doc_num => l_transaction_source_id,
3788 p_grp_src_type_id => l_transaction_source_type_id,
3789 x_return_status => l_return_status);
3790
3791 IF l_debug = 1 THEN
3792 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
3793 END IF;
3794
3795 IF l_return_status = fnd_api.g_ret_sts_error THEN
3796 RAISE fnd_api.g_exc_error;
3797 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3798 RAISE fnd_api.g_exc_unexpected_error;
3799 END IF;
3800 l_return_status := fnd_api.g_ret_sts_success;
3801 -- bug 4358107
3802
3803 END IF;
3804
3805 IF c_order_lock_check%isopen THEN
3806 CLOSE c_order_lock_check;
3807 END IF;
3808 END;
3809 ELSIF p_task_method = 'PICKBYLABEL' THEN
3810 IF l_debug = 1 THEN
3811 print_debug('Check carton ID '|| l_cartonization_id || ' for locking.', 4);
3812 END IF;
3813
3814 BEGIN
3815 OPEN c_carton_lock_check(l_cartonization_id);
3816 CLOSE c_carton_lock_check;
3817
3818 l_is_locked := FALSE;
3819 x_grouping_document_type := 'CARTON';
3820 x_grouping_document_number := l_cartonization_id;
3821 x_grouping_source_type_id := l_transaction_source_type_id;
3822
3823 EXCEPTION
3824 WHEN OTHERS THEN
3825 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3826 l_is_locked := TRUE;
3827
3828 IF l_debug = 1 THEN
3829 print_debug('Carton ' || l_cartonization_id ||' is locked by other user. ', 4);
3830 END IF;
3831 -- bug 4358107
3832 store_locked_tasks
3833 (p_grp_doc_type => p_task_method,
3834 p_grp_doc_num => l_cartonization_id,
3835 p_grp_src_type_id => NULL,
3836 x_return_status => l_return_status);
3837
3838 IF l_debug = 1 THEN
3839 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
3840 END IF;
3841
3842 IF l_return_status = fnd_api.g_ret_sts_error THEN
3843 RAISE fnd_api.g_exc_error;
3844 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3845 RAISE fnd_api.g_exc_unexpected_error;
3846 END IF;
3847 l_return_status := fnd_api.g_ret_sts_success;
3848 -- bug 4358107
3849
3850 END IF;
3851
3852 IF c_carton_lock_check%isopen THEN
3853 CLOSE c_carton_lock_check;
3854 END IF;
3855 END;
3856 END IF;
3857 ELSE -- Check the lock for cycle count tasks
3858 IF l_debug = 1 THEN
3859 print_debug('Check cycle count task '|| l_task_id || ' for locking.', 4);
3860 END IF;
3861
3862 BEGIN
3863 OPEN c_cycle_count_lock_check(l_task_id);
3864 CLOSE c_cycle_count_lock_check;
3865
3866 l_is_locked := FALSE;
3867 x_grouping_document_type := 'TASK';
3868 x_grouping_document_number := l_task_id;
3869 x_grouping_source_type_id := l_transaction_source_type_id;
3870 EXCEPTION
3871 WHEN OTHERS THEN
3872 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
3873 l_is_locked := TRUE;
3874
3875 IF l_debug = 1 THEN
3876 print_debug('Cycle count task ' || l_task_id ||' is locked by other user. ', 4);
3877 END IF;
3878
3879 END IF;
3880
3881 IF c_cycle_count_lock_check%isopen THEN
3882 CLOSE c_cycle_count_lock_check;
3883 END IF;
3884 END;
3885
3886 END IF;
3887
3888 IF p_sign_on_zone IS NOT NULL THEN -- subinventory passed in
3889 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3890 CLOSE l_curs_opt_task_111;
3891 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3892 CLOSE l_curs_opt_task_110;
3893 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3894 CLOSE l_curs_opt_task_101;
3895 END IF;
3896 ELSE -- No subinventory passed in
3897 IF l_cc_allowed = 1 AND l_non_cc_allowed = 1 THEN
3898 CLOSE l_curs_opt_task_011;
3899 ELSIF l_cc_allowed = 0 AND l_non_cc_allowed = 1 THEN
3900 CLOSE l_curs_opt_task_010;
3901 ELSIF l_cc_allowed = 1 AND l_non_cc_allowed = 0 THEN
3902 CLOSE l_curs_opt_task_001;
3903 END IF;
3904 END IF;
3905
3906 IF l_is_locked = TRUE THEN
3907 IF l_debug = 1 THEN
3908 print_debug('Continue looking for most optimal task since there is a lock for this pick slip.', 4);
3909 END IF;
3910 ELSE
3911 IF l_debug = 1 THEN
3912 print_debug('There is no lock, got the most optimal task.', 4);
3913 END IF;
3914 /* Fix for the bug 3837944 Bug 3853837 .
3915 The below block is to check whether any task has been dispatched to some other user
3916 for the same carton. If yes, this user will not get the task.Should not allow cyclecount task */
3917 --Bug 4078696
3918 IF (( l_task_id IS NOT NULL) AND (l_task_type_id <> 3)) THEN
3919 BEGIN
3920 IF l_debug = 1 THEN
3921 print_debug('The trx temp id :' || l_task_id , 4);
3922 END IF;
3923 /*Take the LPN_ID from MMTT*/
3924 l_lpn_id := NULL;
3925 SELECT cartonization_id INTO l_lpn_id
3926 FROM mtl_material_transactions_temp mmtt
3927 WHERE mmtt.transaction_temp_id= l_task_id;
3928
3929
3930
3931
3932 IF l_debug = 1 THEN
3933 print_debug('The carton id :' || l_lpn_id || 'Current employee id :'|| p_sign_on_emp_id, 4);
3934 END IF;
3935
3936 /*Check if any task has been dispatched to other users for the same LPN*/
3937 IF l_lpn_id IS NOT NULL THEN
3938 l_wdt_count := 0 ;
3939 SELECT count(1) INTO l_wdt_count FROM wms_dispatched_tasks wdt, mtl_material_transactions_temp mmtt
3940 WHERE mmtt.cartonization_id = l_lpn_id
3941 AND wdt.transaction_temp_id = mmtt.transaction_temp_id
3942 AND wdt.status in(3,9) AND wdt.person_id <> p_sign_on_emp_id ;
3943
3944 IF l_debug = 1 THEN
3945 print_debug('The tasks dispatched to other user :'|| l_wdt_count,4);
3946 END IF;
3947
3948 IF l_wdt_count > 0 then --There tasks dispatched to other users for this LPN
3949 l_task_id := NULL;
3950 -- 6598260 start
3951 IF l_debug = 1 THEN
3952 print_debug('cartonized tasks START',4);
3953 END IF;
3954
3955 store_locked_tasks (p_grp_doc_type =>'CARTON_TASK',
3956 p_grp_doc_num => l_lpn_id,
3957 p_grp_src_type_id => NULL,
3958 x_return_status => l_return_status);
3959 IF l_debug = 1 THEN
3960 print_debug('Return Status after the call to store_locked_tasks ' || l_return_status ||' l_lpn_id :- '|| l_lpn_id, 4);
3961 END IF;
3962
3963 IF l_return_status = fnd_api.g_ret_sts_error THEN
3964 RAISE fnd_api.g_exc_error;
3965 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3966 RAISE fnd_api.g_exc_unexpected_error;
3967 END IF;
3968 l_return_status := fnd_api.g_ret_sts_success;
3969
3970 IF l_debug = 1 THEN
3971 print_debug('cartonized tasks end',4);
3972 END IF;
3973 -- 6598260 end
3974 IF l_debug = 1 THEN
3975 print_debug('There are tasks dispatched to other users for this carton ',4);
3976 END IF;
3977
3978 ELSE --No tasks dispatched to other users for this carton.
3979 EXIT;
3980 END IF;
3981 ELSE --LPN id is NULL .This is not a cartonization task.
3982 EXIT;
3983 END IF;
3984 EXCEPTION
3985 WHEN OTHERS THEN
3986 IF l_debug = 1 THEN
3987 print_debug('Exception occured when checking for dispatched tasks to other users ',4);
3988 END IF;
3989 EXIT;--v1
3990 END;
3991 ELSE --l_opt_task_id is NULL.
3992 EXIT;
3993 END IF;
3994 /* End of fix fir bug 3837944 Bug3853837 */
3995 END IF;--l_is_locked
3996 END LOOP;
3997 <<end_loop>> -- Bug 7254397
3998 -- End bug fix 2832818
3999
4000 IF l_task_id IS NULL AND p_task_method <> 'CLUSTERPICKBYLABEL' THEN --Bug 7254397
4001 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
4002 fnd_msg_pub.ADD;
4003
4004 IF (l_debug = 1) THEN
4005 print_debug('dispatch_task - No eligible picking tasks ', 4);
4006 END IF;
4007
4008 RAISE fnd_api.g_exc_error;
4009 END IF;
4010
4011 IF p_task_method <> 'ORDERPICK' THEN
4012 l_transaction_source_id := NULL;
4013 END IF;
4014
4015 IF (l_debug = 1) THEN
4016 print_debug('Pick Slip: ' || l_pick_slip, 4);
4017 print_debug('Task Type: ' || l_task_type_id, 4);
4018 print_debug('Task ID: ' || l_task_id, 4);
4019 print_debug('Transaction Source ID: ' || l_transaction_source_id, 4);
4020 END IF;
4021
4022 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4023 OPEN l_curs_ordered_tasks_11(l_pick_slip, l_task_id, l_task_type_id, l_transaction_source_id);
4024 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4025 OPEN l_curs_ordered_tasks_10(l_pick_slip, l_task_id, l_task_type_id, l_transaction_source_id);
4026 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4027 OPEN l_curs_ordered_tasks_01(l_task_id, l_task_type_id);
4028 END IF;
4029
4030 l_progress := '50';
4031 l_first_task_pick_slip_number := -1;
4032 l_ordered_tasks_count := 0;
4033
4034 LOOP
4035
4036 IF (l_debug = 1) THEN
4037 print_debug('Start looping through ordered tasks: ', 4);
4038 END IF;
4039
4040 l_task_id := NULL;
4041
4042 l_is_locked := FALSE;
4043 l_progress := '60';
4044
4045 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4046 IF (l_debug = 1) THEN
4047 print_debug('Both cycle count and non cycle count tasks allowed: ', 4);
4048 END IF;
4049
4050 FETCH l_curs_ordered_tasks_11
4051 INTO
4052 l_task_id,
4053 l_subinventory_code,
4054 l_locator_id,
4055 l_pick_slip,
4056 l_transaction_uom,
4057 l_transaction_quantity,
4058 l_lot_number,
4059 l_operation_plan_id,
4060 l_standard_operation_id,
4061 l_effective_start_date,
4062 l_effective_end_date,
4063 l_person_resource_id,
4064 l_machine_resource_id,
4065 l_task_type_id,
4066 l_task_priority,
4067 l_batch_id,
4068 l_move_order_line_id,
4069 l_sub_pick_order,
4070 l_loc_pick_order,
4071 l_distance,
4072 l_task_status,
4073 l_transaction_type_id,
4074 l_transaction_action_id,
4075 l_transaction_source_id,
4076 l_transaction_source_type_id;
4077
4078 EXIT WHEN l_curs_ordered_tasks_11%notfound;
4079
4080 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4081
4082 IF (l_debug = 1) THEN
4083 print_debug('Only non cycle count tasks allowed: ', 4);
4084 END IF;
4085
4086 FETCH l_curs_ordered_tasks_10
4087 INTO
4088 l_task_id,
4089 l_subinventory_code,
4090 l_locator_id,
4091 l_pick_slip,
4092 l_transaction_uom,
4093 l_transaction_quantity,
4094 l_lot_number,
4095 l_operation_plan_id,
4096 l_standard_operation_id,
4097 l_effective_start_date,
4098 l_effective_end_date,
4099 l_person_resource_id,
4100 l_machine_resource_id,
4101 l_task_type_id,
4102 l_task_priority,
4103 l_batch_id,
4104 l_move_order_line_id,
4105 l_sub_pick_order,
4106 l_loc_pick_order,
4107 l_distance,
4108 l_task_status,
4109 l_transaction_type_id,
4110 l_transaction_action_id,
4111 l_transaction_source_id,
4112 l_transaction_source_type_id;
4113
4114 EXIT WHEN l_curs_ordered_tasks_10%notfound;
4115
4116 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4117
4118 IF (l_debug = 1) THEN
4119 print_debug('Only cycle count tasks allowed: ', 4);
4120 END IF;
4121
4122 FETCH l_curs_ordered_tasks_01
4123 INTO
4124 l_task_id,
4125 l_subinventory_code,
4126 l_locator_id,
4127 l_pick_slip,
4128 l_transaction_uom,
4129 l_transaction_quantity,
4130 l_lot_number,
4131 l_operation_plan_id,
4132 l_standard_operation_id,
4133 l_effective_start_date,
4134 l_effective_end_date,
4135 l_person_resource_id,
4136 l_machine_resource_id,
4137 l_task_type_id,
4138 l_task_priority,
4139 l_batch_id,
4140 l_move_order_line_id,
4141 l_sub_pick_order,
4142 l_loc_pick_order,
4143 l_distance,
4144 l_task_status,
4145 l_transaction_type_id,
4146 l_transaction_action_id,
4147 l_transaction_source_id,
4148 l_transaction_source_type_id;
4149
4150 EXIT WHEN l_curs_ordered_tasks_01%notfound;
4151
4152 END IF;
4153
4154 l_progress := '70';
4155
4156 IF (l_debug = 1) THEN
4157 print_debug('Task ID => ' || l_task_id, 4);
4158 print_debug('Pick Slip => ' || l_pick_slip, 4);
4159 print_debug('Task Type => ' || l_task_type_id, 4);
4160 print_debug('Trx Src => ' || l_transaction_source_id, 4);
4161 print_debug('Trx Srx Type => ' || l_transaction_source_type_id, 4);
4162 END IF;
4163
4164 l_ordered_tasks_count := l_ordered_tasks_count + 1;
4165
4166 IF (l_debug = 1) THEN
4167 print_debug('This is the first task in this group. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
4168 END IF;
4169
4170 l_progress := '72';
4171
4172 INSERT INTO wms_ordered_tasks
4173 (task_id,
4174 wms_task_type,
4175 task_sequence_id,
4176 subinventory_code,
4177 locator_id,
4178 revision,
4179 transaction_uom,
4180 transaction_quantity,
4181 lot_number,
4182 priority,
4183 operation_plan_id,
4184 standard_operation_id,
4185 effective_start_date,
4186 effective_end_date,
4187 person_resource_id,
4188 machine_resource_id,
4189 move_order_line_id)
4190 VALUES
4191 (l_task_id,
4192 l_task_type_id,
4193 l_ordered_tasks_count,
4194 l_subinventory_code,
4195 l_locator_id,
4196 l_revision,
4197 l_transaction_uom,
4198 l_transaction_quantity,
4199 l_lot_number,
4200 l_task_priority,
4201 l_operation_plan_id,
4202 l_standard_operation_id,
4203 l_effective_start_date,
4204 l_effective_end_date,
4205 l_person_resource_id,
4206 l_machine_resource_id,
4207 l_move_order_line_id);
4208
4209 l_progress := '73';
4210
4211 END LOOP;
4212
4213 --Bug 7254397: Clear ...GTMP table
4214 IF p_task_method = 'CLUSTERPICKBYLABEL' THEN
4215 remove_stored_cartons(x_return_status => l_return_status);
4216 IF l_debug = 1 THEN
4217 print_debug('Return Status after the call to remove_locked_tasks ' || l_return_status ||' p_task_method ' || p_task_method, 4);
4218 END IF;
4219 IF l_return_status = fnd_api.g_ret_sts_error THEN
4220 RAISE fnd_api.g_exc_error;
4221 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4222 RAISE fnd_api.g_exc_unexpected_error;
4223 END IF;
4224 l_return_status := fnd_api.g_ret_sts_success;
4225 END IF;--Bug 7254397: Clear ...GTMP table end
4226
4227 IF l_non_cc_allowed = 1 AND l_cc_allowed = 1 THEN
4228 CLOSE l_curs_ordered_tasks_11;
4229 ELSIF l_non_cc_allowed = 1 AND l_cc_allowed = 0 THEN
4230 CLOSE l_curs_ordered_tasks_10;
4231 ELSIF l_non_cc_allowed = 0 AND l_cc_allowed = 1 THEN
4232 CLOSE l_curs_ordered_tasks_01;
4233 END IF;
4234
4235 IF (l_debug = 1) THEN
4236 print_debug('Total number of tasks dispatched: => ' || l_ordered_tasks_count, 4);
4237 END IF;
4238
4239 IF l_ordered_tasks_count = 0 THEN
4240 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
4241 fnd_msg_pub.ADD;
4242
4243 IF (l_debug = 1) THEN
4244 print_debug('dispatch_task - No eligible picking tasks ', 4);
4245 END IF;
4246
4247 RAISE fnd_api.g_exc_error;
4248 END IF;
4249
4250 l_progress := '90';
4251
4252 -- open reference cursor for this statement
4253
4254 IF (l_debug = 1) THEN
4255 print_debug('Before opening reference cursor ', 4);
4256 END IF;
4257
4258 OPEN x_task_cur FOR
4259 SELECT
4260 task_id,
4261 subinventory_code,
4262 locator_id,
4263 revision,
4264 transaction_uom,
4265 transaction_quantity,
4266 lot_number,
4267 wms_task_type,
4268 priority,
4269 operation_plan_id,
4270 standard_operation_id,
4271 effective_start_date,
4272 effective_end_date,
4273 person_resource_id,
4274 machine_resource_id,
4275 move_order_line_id
4276 FROM wms_ordered_tasks
4277 ORDER BY task_sequence_id;
4278
4279 l_progress := '120';
4280 EXCEPTION
4281 WHEN fnd_api.g_exc_error THEN
4282 x_return_status := fnd_api.g_ret_sts_error;
4283
4284 IF l_curs_ordered_tasks_11%ISOPEN THEN
4285 CLOSE l_curs_ordered_tasks_11;
4286 END IF;
4287
4288 IF l_curs_ordered_tasks_01%ISOPEN THEN
4289 CLOSE l_curs_ordered_tasks_01;
4290 END IF;
4291
4292 IF l_curs_ordered_tasks_10%ISOPEN THEN
4293 CLOSE l_curs_ordered_tasks_10;
4294 END IF;
4295
4296 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4297
4298 IF (l_debug = 1) THEN
4299 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4300 END IF;
4301 WHEN fnd_api.g_exc_unexpected_error THEN
4302 x_return_status := fnd_api.g_ret_sts_unexp_error;
4303
4304 IF l_curs_ordered_tasks_11%ISOPEN THEN
4305 CLOSE l_curs_ordered_tasks_11;
4306 END IF;
4307
4308 IF l_curs_ordered_tasks_01%ISOPEN THEN
4309 CLOSE l_curs_ordered_tasks_01;
4310 END IF;
4311
4312 IF l_curs_ordered_tasks_10%ISOPEN THEN
4313 CLOSE l_curs_ordered_tasks_10;
4314 END IF;
4315
4316 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4317
4318 IF (l_debug = 1) THEN
4319 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4320 END IF;
4321 WHEN OTHERS THEN
4322 x_return_status := fnd_api.g_ret_sts_unexp_error;
4323
4324 IF l_curs_ordered_tasks_11%ISOPEN THEN
4325 CLOSE l_curs_ordered_tasks_11;
4326 END IF;
4327
4328 IF l_curs_ordered_tasks_01%ISOPEN THEN
4329 CLOSE l_curs_ordered_tasks_01;
4330 END IF;
4331
4332 IF l_curs_ordered_tasks_10%ISOPEN THEN
4333 CLOSE l_curs_ordered_tasks_10;
4334 END IF;
4335
4336 IF SQLCODE IS NOT NULL THEN
4337 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
4338 END IF;
4339
4340 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4341
4342 IF (l_debug = 1) THEN
4343 print_debug('dispatch_task: Other exception: ' || Sqlerrm || l_progress, 1);
4344 END IF;
4345 END dispatch_task;
4346
4347
4348 -- Old procedure: Not used from 11.5.10
4349
4350 PROCEDURE dispatch_task(
4351 p_api_version IN NUMBER
4352 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
4353 , p_commit IN VARCHAR2 := fnd_api.g_false
4354 , p_sign_on_emp_id IN NUMBER
4355 , p_sign_on_org_id IN NUMBER
4356 , p_sign_on_zone IN VARCHAR2 := NULL
4357 , p_sign_on_equipment_id IN NUMBER := NULL -- specific equip id, NULL or -999. -999 stands for none
4358 , p_sign_on_equipment_srl IN VARCHAR2 := NULL -- same as above
4359 , p_task_type IN VARCHAR2 -- 'PICKING' or 'ALL'
4360 , p_cartonization_id IN NUMBER := NULL
4361 , x_task_cur OUT NOCOPY task_rec_cur_tp
4362 , x_return_status OUT NOCOPY VARCHAR2
4363 , x_msg_count OUT NOCOPY NUMBER
4364 , x_msg_data OUT NOCOPY VARCHAR2
4365 ) IS
4366 l_cur_x NUMBER;
4367 l_cur_y NUMBER;
4368 l_cur_z NUMBER;
4369 l_opt_task_id NUMBER;
4370 l_opt_task_pick_slip NUMBER:= 0; -- bug 2832818 (init value to 0);
4371 l_opt_task_type NUMBER;
4372 l_task_priority NUMBER;
4373 l_mo_header_id NUMBER;
4374 l_sub_pick_order NUMBER;
4375 l_loc_pick_order NUMBER;
4376 l_x_coordinate NUMBER;
4377 l_y_coordinate NUMBER;
4378 l_z_coordinate NUMBER;
4379 l_is_locked BOOLEAN := FALSE;
4380 l_sys_task_type NUMBER;
4381 l_is_express_pick NUMBER := 0; -- 1 for express pick, 0 not
4382 l_sign_on_equipment_id NUMBER;
4383 l_sign_on_equipment_srl VARCHAR2(30);
4384 l_equipment_id_str VARCHAR2(30);
4385 l_last_loaded_time DATE;
4386 l_last_loaded_task_id NUMBER;
4387 l_last_loaded_task_type NUMBER;
4388 l_last_dropoff_time DATE;
4389 l_last_dropoff_task_id NUMBER;
4390 l_last_dropoff_task_type NUMBER;
4391 l_last_task_type NUMBER;
4392 l_last_task_is_drop BOOLEAN := FALSE;
4393 l_last_task_id NUMBER;
4394 l_ordered_tasks_count NUMBER;
4395 l_first_task_pick_slip_number NUMBER;
4396 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
4397 l_api_version CONSTANT NUMBER := 1.0;
4398 l_progress VARCHAR2(10);
4399 l_sequence_picks_across_waves NUMBER := 2;
4400
4401 /* Bug 3856227
4402 Added condition in all the cursors selecting cycle count tasks to select
4403 only those tasks whose cycle count have not been disabled by entering
4404 an Inactive Date.
4405 Added the table mtl_cycle_count_headers in the FROM clause and joined with
4406 mtl_cycle_count_entries and checked for disable_date value with sysdate.
4407 */
4408
4409 -- Cursor # 1 for selecting the most optimal task
4410 -- 1. sub is passed (1)
4411 -- 2. order by across wave (1)
4412 -- 3. not express pick (0)
4413
4414 CURSOR l_curs_opt_task_110 IS
4415 SELECT DISTINCT wdtv.task_id task_id
4416 , NVL(wdtv.pick_slip_number, -1) pick_slip
4417 , wdtv.wms_task_type_id
4418 , nvl(wdtv.task_priority, 0)
4419 , mol.header_id
4420 , sub.picking_order
4421 , loc.picking_order
4422 , nvl(loc.x_coordinate, 0)
4423 , nvl(loc.y_coordinate, 0)
4424 , nvl(loc.z_coordinate, 0)
4425 FROM (SELECT transaction_temp_id task_id
4426 , standard_operation_id user_task_type_id
4427 , wms_task_type wms_task_type_id
4428 , organization_id organization_id
4429 , subinventory_code ZONE
4430 , locator_id locator_id
4431 , task_priority task_priority
4432 , revision revision
4433 , lot_number lot_number
4434 , transaction_uom transaction_uom
4435 , transaction_quantity transaction_quantity
4436 , pick_rule_id pick_rule_id
4437 , pick_slip_number pick_slip_number
4438 , cartonization_id cartonization_id
4439 , inventory_item_id
4440 , move_order_line_id
4441 FROM mtl_material_transactions_temp
4442 WHERE wms_task_type IS NOT NULL
4443 AND transaction_status = 2
4444 AND(wms_task_status IS NULL
4445 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4446 UNION ALL
4447 SELECT MIN(mcce.cycle_count_entry_id) task_id
4448 , MIN(mcce.standard_operation_id) user_task_type_id
4449 , 3 wms_task_type_id
4450 , mcce.organization_id organization_id
4451 , mcce.subinventory ZONE
4452 , mcce.locator_id locator_id
4453 , MIN(mcce.task_priority) task_priority
4454 , mcce.revision revision
4455 , MIN(mcce.lot_number) lot_number
4456 , '' transaction_uom
4457 , TO_NUMBER(NULL) transaction_quantity
4458 , TO_NUMBER(NULL) pick_rule_id
4459 , TO_NUMBER(NULL) pick_slip_number
4460 , TO_NUMBER(NULL) cartonization_id
4461 , mcce.inventory_item_id
4462 , TO_NUMBER(NULL) move_order_line_id
4463 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4464 WHERE mcce.entry_status_code IN(1, 3)
4465 AND NVL(mcce.export_flag, 2) = 2
4466 -- bug 3972076
4467 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4468 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4469 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4470 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4471 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4472 (SELECT utt_emp.standard_operation_id standard_operation_id
4473 , utt_emp.resource_id ROLE
4474 , utt_eqp.resource_id equipment
4475 , utt_emp.person_id emp_id
4476 , utt_eqp.inventory_item_id eqp_id
4477 , NULL eqp_srl /* removed for bug 2095237 */
4478 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4479 , x_utt_res1.resource_id resource_id
4480 , x_emp_r.person_id
4481 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4482 WHERE x_utt_res1.resource_id = r1.resource_id
4483 AND r1.resource_type = 2
4484 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4485 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4486 , x_utt_res2.resource_id resource_id
4487 , x_eqp_r.inventory_item_id inventory_item_id
4488 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4489 WHERE x_utt_res2.resource_id = r2.resource_id
4490 AND r2.resource_type = 1
4491 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4492 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4493 , -- inlined wms_person_resource_utt_v, bug 2648133
4494 mtl_item_locations loc
4495 , mtl_secondary_inventories sub
4496 , mtl_txn_request_lines mol
4497 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4498 AND wdtv.organization_id = p_sign_on_org_id
4499 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4500 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4501 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
4502 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4503 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4504 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4505 AND wdtv.locator_id = loc.inventory_location_id(+)
4506 AND wdtv.ZONE = sub.secondary_inventory_name
4507 AND wdtv.organization_id = sub.organization_id
4508 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
4509 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
4510 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
4511 (
4512 SELECT NULL
4513 FROM mtl_material_transactions_temp mmtt
4514 WHERE mmtt.transaction_temp_id = wdtv.task_id
4515 AND mmtt.parent_line_id IS NOT NULL
4516 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
4517 AND NOT EXISTS -- exclude tasks already dispatched
4518 (SELECT NULL
4519 FROM wms_dispatched_tasks wdt1
4520 WHERE wdt1.transaction_temp_id = wdtv.task_id
4521 AND wdt1.task_type = wdtv.wms_task_type_id)
4522 --******************
4523 AND wdtv.task_id NOT IN -- excluded skipped tasks
4524 (
4525 SELECT wdtv.task_id
4526 FROM wms_skip_task_exceptions wste, mtl_parameters mp
4527 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
4528 AND wste.task_id = wdtv.task_id
4529 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
4530 AND wste.organization_id = mp.organization_id)
4531 --*****************
4532 --J Addition
4533 AND wdtv.ZONE not in (
4534 SELECT wd.subinventory_code
4535 FROM wms_devices_b wd
4536 , wms_bus_event_devices wbed
4537 WHERE 1 = 1
4538 and wd.device_id = wbed.device_id
4539 AND wbed.organization_id = wd.organization_id
4540 AND wd.enabled_flag = 'Y'
4541 AND wbed.enabled_flag = 'Y'
4542 AND wbed.business_event_id = 10
4543 AND wd.subinventory_code IS NOT NULL
4544 AND wd.force_sign_on_flag = 'Y'
4545 AND wd.device_id NOT IN (SELECT device_id
4546 FROM wms_device_assignment_temp
4547 WHERE employee_id = p_sign_on_emp_id)
4548 )
4549 ORDER BY nvl(wdtv.task_priority, 0)
4550 , -- removed order by segments for bug 2657909
4551 mol.header_id
4552 , sub.picking_order
4553 , loc.picking_order
4554 , (
4555 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
4556 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
4557 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
4558 )
4559 , wdtv.task_id;
4560
4561 -- Cursor # 2 for selecting the most optimal task
4562 -- 1. sub is passed (1)
4563 -- 2. order by across wave (1)
4564 -- 3. Express pick (1)
4565
4566 CURSOR l_curs_opt_task_111 IS
4567 SELECT DISTINCT wdtv.task_id task_id
4568 , -- added distinct for bug 2657909
4569 NVL(wdtv.pick_slip_number, -1) pick_slip
4570 , wdtv.wms_task_type_id
4571 , nvl(wdtv.task_priority, 0)
4572 , -- added following because of distinct for bug 2657909
4573 mol.header_id
4574 , sub.picking_order
4575 , loc.picking_order
4576 , nvl(loc.x_coordinate, 0)
4577 , nvl(loc.y_coordinate, 0)
4578 , nvl(loc.z_coordinate, 0)
4579 FROM (SELECT transaction_temp_id task_id
4580 , standard_operation_id user_task_type_id
4581 , wms_task_type wms_task_type_id
4582 , organization_id organization_id
4583 , subinventory_code ZONE
4584 , locator_id locator_id
4585 , task_priority task_priority
4586 , revision revision
4587 , lot_number lot_number
4588 , transaction_uom transaction_uom
4589 , transaction_quantity transaction_quantity
4590 , pick_rule_id pick_rule_id
4591 , pick_slip_number pick_slip_number
4592 , cartonization_id cartonization_id
4593 , inventory_item_id
4594 , move_order_line_id
4595 FROM mtl_material_transactions_temp
4596 WHERE wms_task_type IS NOT NULL
4597 AND transaction_status = 2
4598 AND(wms_task_status IS NULL
4599 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4600 UNION ALL
4601 SELECT MIN(mcce.cycle_count_entry_id) task_id
4602 , MIN(mcce.standard_operation_id) user_task_type_id
4603 , 3 wms_task_type_id
4604 , mcce.organization_id organization_id
4605 , mcce.subinventory ZONE
4606 , mcce.locator_id locator_id
4607 , MIN(mcce.task_priority) task_priority
4608 , mcce.revision revision
4609 , MIN(mcce.lot_number) lot_number
4610 , '' transaction_uom
4611 , TO_NUMBER(NULL) transaction_quantity
4612 , TO_NUMBER(NULL) pick_rule_id
4613 , TO_NUMBER(NULL) pick_slip_number
4614 , TO_NUMBER(NULL) cartonization_id
4615 , mcce.inventory_item_id
4616 , TO_NUMBER(NULL) move_order_line_id
4617 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4618 WHERE mcce.entry_status_code IN(1, 3)
4619 AND NVL(mcce.export_flag, 2) = 2
4620 -- bug 3972076
4621 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4622 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4623 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4624 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4625 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4626 (SELECT utt_emp.standard_operation_id standard_operation_id
4627 , utt_emp.resource_id ROLE
4628 , utt_eqp.resource_id equipment
4629 , utt_emp.person_id emp_id
4630 , utt_eqp.inventory_item_id eqp_id
4631 , NULL eqp_srl /* removed for bug 2095237 */
4632 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4633 , x_utt_res1.resource_id resource_id
4634 , x_emp_r.person_id
4635 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4636 WHERE x_utt_res1.resource_id = r1.resource_id
4637 AND r1.resource_type = 2
4638 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4639 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4640 , x_utt_res2.resource_id resource_id
4641 , x_eqp_r.inventory_item_id inventory_item_id
4642 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4643 WHERE x_utt_res2.resource_id = r2.resource_id
4644 AND r2.resource_type = 1
4645 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4646 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4647 , -- inlined wms_person_resource_utt_v, bug 2648133
4648 mtl_item_locations loc
4649 , mtl_secondary_inventories sub
4650 , mtl_txn_request_lines mol
4651 -- mtl_system_items msi -- bug 2648133
4652 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4653 AND wdtv.organization_id = p_sign_on_org_id
4654 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4655 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4656 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
4657 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4658 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4659 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4660 AND wdtv.locator_id = loc.inventory_location_id(+)
4661 AND wdtv.ZONE = sub.secondary_inventory_name
4662 AND wdtv.organization_id = sub.organization_id
4663 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
4664 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
4665 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
4666 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
4667 (
4668 SELECT NULL
4669 FROM mtl_material_transactions_temp mmtt
4670 WHERE mmtt.transaction_temp_id = wdtv.task_id
4671 AND mmtt.parent_line_id IS NOT NULL
4672 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
4673 AND NOT EXISTS -- exclude tasks already dispatched
4674 (SELECT NULL
4675 FROM wms_dispatched_tasks wdt1
4676 WHERE wdt1.transaction_temp_id = wdtv.task_id
4677 AND wdt1.task_type = wdtv.wms_task_type_id)
4678 --******************
4679 AND wdtv.task_id NOT IN -- excluded skipped tasks
4680 (
4681 SELECT wdtv.task_id
4682 FROM wms_skip_task_exceptions wste, mtl_parameters mp
4683 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
4684 AND wste.task_id = wdtv.task_id
4685 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
4686 AND wste.organization_id = mp.organization_id)
4687 --*****************
4688 --J Addition
4689 AND wdtv.ZONE not in (
4690 SELECT wd.subinventory_code
4691 FROM wms_devices_b wd
4692 , wms_bus_event_devices wbed
4693 WHERE 1 = 1
4694 and wd.device_id = wbed.device_id
4695 AND wbed.organization_id = wd.organization_id
4696 AND wd.enabled_flag = 'Y'
4697 AND wbed.enabled_flag = 'Y'
4698 AND wbed.business_event_id = 10
4699 AND wd.subinventory_code IS NOT NULL
4700 AND wd.force_sign_on_flag = 'Y'
4701 AND wd.device_id NOT IN (SELECT device_id
4702 FROM wms_device_assignment_temp
4703 WHERE employee_id = p_sign_on_emp_id)
4704 )
4705 ORDER BY nvl(wdtv.task_priority, 0)
4706 , -- removed order by segments for bug 2657909
4707 mol.header_id
4708 , sub.picking_order
4709 , loc.picking_order
4710 , (
4711 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
4712 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
4713 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
4714 )
4715 , wdtv.task_id;
4716
4717 -- Cursor # 3 for selecting the most optimal task
4718 -- 1. sub is NOT passed (0)
4719 -- 2. order by across wave (1)
4720 -- 3. not express pick (0)
4721
4722 CURSOR l_curs_opt_task_010 IS
4723 SELECT DISTINCT wdtv.task_id task_id
4724 , -- added distinct for bug 2657909
4725 NVL(wdtv.pick_slip_number, -1) pick_slip
4726 , wdtv.wms_task_type_id
4727 , nvl(wdtv.task_priority, 0)
4728 , -- added following because of distinct for bug 2657909
4729 mol.header_id
4730 , sub.picking_order
4731 , loc.picking_order
4732 , nvl(loc.x_coordinate, 0)
4733 , nvl(loc.y_coordinate, 0)
4734 , nvl(loc.z_coordinate, 0)
4735 FROM (SELECT transaction_temp_id task_id
4736 , standard_operation_id user_task_type_id
4737 , wms_task_type wms_task_type_id
4738 , organization_id organization_id
4739 , subinventory_code ZONE
4740 , locator_id locator_id
4741 , task_priority task_priority
4742 , revision revision
4743 , lot_number lot_number
4744 , transaction_uom transaction_uom
4745 , transaction_quantity transaction_quantity
4746 , pick_rule_id pick_rule_id
4747 , pick_slip_number pick_slip_number
4748 , cartonization_id cartonization_id
4749 , inventory_item_id
4750 , move_order_line_id
4751 FROM mtl_material_transactions_temp
4752 WHERE wms_task_type IS NOT NULL
4753 AND transaction_status = 2
4754 AND(wms_task_status IS NULL
4755 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4756 UNION ALL
4757 SELECT MIN(mcce.cycle_count_entry_id) task_id
4758 , MIN(mcce.standard_operation_id) user_task_type_id
4759 , 3 wms_task_type_id
4760 , mcce.organization_id organization_id
4761 , mcce.subinventory ZONE
4762 , mcce.locator_id locator_id
4763 , MIN(mcce.task_priority) task_priority
4764 , mcce.revision revision
4765 , MIN(mcce.lot_number) lot_number
4766 , '' transaction_uom
4767 , TO_NUMBER(NULL) transaction_quantity
4768 , TO_NUMBER(NULL) pick_rule_id
4769 , TO_NUMBER(NULL) pick_slip_number
4770 , TO_NUMBER(NULL) cartonization_id
4771 , mcce.inventory_item_id
4772 , TO_NUMBER(NULL) move_order_line_id
4773 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4774 WHERE mcce.entry_status_code IN(1, 3)
4775 AND NVL(mcce.export_flag, 2) = 2
4776 -- bug 3972076
4777 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4778 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4779 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4780 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4781 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4782 (SELECT utt_emp.standard_operation_id standard_operation_id
4783 , utt_emp.resource_id ROLE
4784 , utt_eqp.resource_id equipment
4785 , utt_emp.person_id emp_id
4786 , utt_eqp.inventory_item_id eqp_id
4787 , NULL eqp_srl /* removed for bug 2095237 */
4788 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4789 , x_utt_res1.resource_id resource_id
4790 , x_emp_r.person_id
4791 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4792 WHERE x_utt_res1.resource_id = r1.resource_id
4793 AND r1.resource_type = 2
4794 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4795 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4796 , x_utt_res2.resource_id resource_id
4797 , x_eqp_r.inventory_item_id inventory_item_id
4798 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4799 WHERE x_utt_res2.resource_id = r2.resource_id
4800 AND r2.resource_type = 1
4801 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4802 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4803 , -- inlined wms_person_resource_utt_v, bug 2648133
4804 mtl_item_locations loc
4805 , mtl_secondary_inventories sub
4806 , mtl_txn_request_lines mol
4807 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4808 AND wdtv.organization_id = p_sign_on_org_id
4809 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4810 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4811 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4812 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4813 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4814 AND wdtv.locator_id = loc.inventory_location_id(+)
4815 AND wdtv.ZONE = sub.secondary_inventory_name
4816 AND wdtv.organization_id = sub.organization_id
4817 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
4818 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
4819 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
4820 (
4821 SELECT NULL
4822 FROM mtl_material_transactions_temp mmtt
4823 WHERE mmtt.transaction_temp_id = wdtv.task_id
4824 AND mmtt.parent_line_id IS NOT NULL
4825 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
4826 AND NOT EXISTS -- exclude tasks already dispatched
4827 (SELECT NULL
4828 FROM wms_dispatched_tasks wdt1
4829 WHERE wdt1.transaction_temp_id = wdtv.task_id
4830 AND wdt1.task_type = wdtv.wms_task_type_id)
4831 --******************
4832 AND wdtv.task_id NOT IN -- excluded skipped tasks
4833 (
4834 SELECT wdtv.task_id
4835 FROM wms_skip_task_exceptions wste, mtl_parameters mp
4836 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
4837 AND wste.task_id = wdtv.task_id
4838 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
4839 AND wste.organization_id = mp.organization_id)
4840 --*****************
4841 --J Addition
4842 AND wdtv.ZONE not in (
4843 SELECT wd.subinventory_code
4844 FROM wms_devices_b wd
4845 , wms_bus_event_devices wbed
4846 WHERE 1 = 1
4847 and wd.device_id = wbed.device_id
4848 AND wbed.organization_id = wd.organization_id
4849 AND wd.enabled_flag = 'Y'
4850 AND wbed.enabled_flag = 'Y'
4851 AND wbed.business_event_id = 10
4852 AND wd.subinventory_code IS NOT NULL
4853 AND wd.force_sign_on_flag = 'Y'
4854 AND wd.device_id NOT IN (SELECT device_id
4855 FROM wms_device_assignment_temp
4856 WHERE employee_id = p_sign_on_emp_id)
4857 )
4858 ORDER BY nvl(wdtv.task_priority, 0)
4859 , -- removed order by segments for bug 2657909
4860 mol.header_id
4861 , sub.picking_order
4862 , loc.picking_order
4863 , (
4864 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
4865 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
4866 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
4867 )
4868 , wdtv.task_id;
4869
4870 -- Cursor # 4 for selecting the most optimal task
4871 -- 1. sub is NOT passed (0)
4872 -- 2. order by across wave (1)
4873 -- 3. express pick (1)
4874
4875 CURSOR l_curs_opt_task_011 IS
4876 SELECT DISTINCT wdtv.task_id task_id
4877 , -- added distinct for bug 2657909
4878 NVL(wdtv.pick_slip_number, -1) pick_slip
4879 , wdtv.wms_task_type_id
4880 , nvl(wdtv.task_priority, 0)
4881 , -- added following because of distinct for bug 2657909
4882 mol.header_id
4883 , sub.picking_order
4884 , loc.picking_order
4885 , nvl(loc.x_coordinate, 0)
4886 , nvl(loc.y_coordinate, 0)
4887 , nvl(loc.z_coordinate, 0)
4888 FROM (SELECT transaction_temp_id task_id
4889 , standard_operation_id user_task_type_id
4890 , wms_task_type wms_task_type_id
4891 , organization_id organization_id
4892 , subinventory_code ZONE
4893 , locator_id locator_id
4894 , task_priority task_priority
4895 , revision revision
4896 , lot_number lot_number
4897 , transaction_uom transaction_uom
4898 , transaction_quantity transaction_quantity
4899 , pick_rule_id pick_rule_id
4900 , pick_slip_number pick_slip_number
4901 , cartonization_id cartonization_id
4902 , inventory_item_id
4903 , move_order_line_id
4904 FROM mtl_material_transactions_temp
4905 WHERE wms_task_type IS NOT NULL
4906 AND transaction_status = 2
4907 AND(wms_task_status IS NULL
4908 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
4909 UNION ALL
4910 SELECT MIN(mcce.cycle_count_entry_id) task_id
4911 , MIN(mcce.standard_operation_id) user_task_type_id
4912 , 3 wms_task_type_id
4913 , mcce.organization_id organization_id
4914 , mcce.subinventory ZONE
4915 , mcce.locator_id locator_id
4916 , MIN(mcce.task_priority) task_priority
4917 , mcce.revision revision
4918 , MIN(mcce.lot_number) lot_number
4919 , '' transaction_uom
4920 , TO_NUMBER(NULL) transaction_quantity
4921 , TO_NUMBER(NULL) pick_rule_id
4922 , TO_NUMBER(NULL) pick_slip_number
4923 , TO_NUMBER(NULL) cartonization_id
4924 , mcce.inventory_item_id
4925 , TO_NUMBER(NULL) move_order_line_id
4926 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
4927 WHERE mcce.entry_status_code IN(1, 3)
4928 AND NVL(mcce.export_flag, 2) = 2
4929 -- bug 3972076
4930 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
4931 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
4932 AND NVL(mcch.disable_date,sysdate+1)> sysdate
4933 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
4934 , -- inlined wms_dispatchable_tasks_v, bug 2648133
4935 (SELECT utt_emp.standard_operation_id standard_operation_id
4936 , utt_emp.resource_id ROLE
4937 , utt_eqp.resource_id equipment
4938 , utt_emp.person_id emp_id
4939 , utt_eqp.inventory_item_id eqp_id
4940 , NULL eqp_srl /* removed for bug 2095237 */
4941 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
4942 , x_utt_res1.resource_id resource_id
4943 , x_emp_r.person_id
4944 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
4945 WHERE x_utt_res1.resource_id = r1.resource_id
4946 AND r1.resource_type = 2
4947 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
4948 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
4949 , x_utt_res2.resource_id resource_id
4950 , x_eqp_r.inventory_item_id inventory_item_id
4951 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
4952 WHERE x_utt_res2.resource_id = r2.resource_id
4953 AND r2.resource_type = 1
4954 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
4955 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
4956 , -- inlined wms_person_resource_utt_v, bug 2648133
4957 mtl_item_locations loc
4958 , mtl_secondary_inventories sub
4959 , mtl_txn_request_lines mol
4960 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
4961 AND wdtv.organization_id = p_sign_on_org_id
4962 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
4963 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
4964 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
4965 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
4966 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
4967 AND wdtv.locator_id = loc.inventory_location_id(+)
4968 AND wdtv.ZONE = sub.secondary_inventory_name
4969 AND wdtv.organization_id = sub.organization_id
4970 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
4971 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
4972 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
4973 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
4974 (
4975 SELECT NULL
4976 FROM mtl_material_transactions_temp mmtt
4977 WHERE mmtt.transaction_temp_id = wdtv.task_id
4978 AND mmtt.parent_line_id IS NOT NULL
4979 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
4980 AND NOT EXISTS -- exclude tasks already dispatched
4981 (SELECT NULL
4982 FROM wms_dispatched_tasks wdt1
4983 WHERE wdt1.transaction_temp_id = wdtv.task_id
4984 AND wdt1.task_type = wdtv.wms_task_type_id)
4985 --******************
4986 AND wdtv.task_id NOT IN -- excluded skipped tasks
4987 (
4988 SELECT wdtv.task_id
4989 FROM wms_skip_task_exceptions wste, mtl_parameters mp
4990 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
4991 AND wste.task_id = wdtv.task_id
4992 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
4993 AND wste.organization_id = mp.organization_id)
4994 --*****************
4995 --J Addition
4996 AND wdtv.ZONE not in (
4997 SELECT wd.subinventory_code
4998 FROM wms_devices_b wd
4999 , wms_bus_event_devices wbed
5000 WHERE 1 = 1
5001 and wd.device_id = wbed.device_id
5002 AND wbed.organization_id = wd.organization_id
5003 AND wd.enabled_flag = 'Y'
5004 AND wbed.enabled_flag = 'Y'
5005 AND wbed.business_event_id = 10
5006 AND wd.subinventory_code IS NOT NULL
5007 AND wd.force_sign_on_flag = 'Y'
5008 AND wd.device_id NOT IN (SELECT device_id
5009 FROM wms_device_assignment_temp
5010 WHERE employee_id = p_sign_on_emp_id)
5011 )
5012 ORDER BY nvl(wdtv.task_priority, 0)
5013 , -- removed order by segments for bug 2657909
5014 mol.header_id
5015 , sub.picking_order
5016 , loc.picking_order
5017 , (
5018 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5019 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5020 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5021 )
5022 , wdtv.task_id;
5023
5024 -- Cursor # 5 for selecting the most optimal task
5025 -- 1. sub is passed (1)
5026 -- 2. NOT order by across wave (0)
5027 -- 3. NOT express pick (0)
5028
5029 CURSOR l_curs_opt_task_100 IS
5030 SELECT DISTINCT wdtv.task_id task_id
5031 , -- added distinct for bug 2657909
5032 NVL(wdtv.pick_slip_number, -1) pick_slip
5033 , wdtv.wms_task_type_id
5034 , nvl(wdtv.task_priority, 0)
5035 , mol.header_id
5036 , sub.picking_order
5037 , loc.picking_order
5038 , nvl(loc.x_coordinate, 0)
5039 , nvl(loc.y_coordinate, 0)
5040 , nvl(loc.z_coordinate, 0)
5041 FROM (SELECT transaction_temp_id task_id
5042 , standard_operation_id user_task_type_id
5043 , wms_task_type wms_task_type_id
5044 , organization_id organization_id
5045 , subinventory_code ZONE
5046 , locator_id locator_id
5047 , task_priority task_priority
5048 , revision revision
5049 , lot_number lot_number
5050 , transaction_uom transaction_uom
5051 , transaction_quantity transaction_quantity
5052 , pick_rule_id pick_rule_id
5053 , pick_slip_number pick_slip_number
5054 , cartonization_id cartonization_id
5055 , inventory_item_id
5056 , move_order_line_id
5057 FROM mtl_material_transactions_temp
5058 WHERE wms_task_type IS NOT NULL
5059 AND transaction_status = 2
5060 AND(wms_task_status IS NULL
5061 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5062 UNION ALL
5063 SELECT MIN(mcce.cycle_count_entry_id) task_id
5064 , MIN(mcce.standard_operation_id) user_task_type_id
5065 , 3 wms_task_type_id
5066 , mcce.organization_id organization_id
5067 , mcce.subinventory ZONE
5068 , mcce.locator_id locator_id
5069 , MIN(mcce.task_priority) task_priority
5070 , mcce.revision revision
5071 , MIN(mcce.lot_number) lot_number
5072 , '' transaction_uom
5073 , TO_NUMBER(NULL) transaction_quantity
5074 , TO_NUMBER(NULL) pick_rule_id
5075 , TO_NUMBER(NULL) pick_slip_number
5076 , TO_NUMBER(NULL) cartonization_id
5077 , mcce.inventory_item_id
5078 , TO_NUMBER(NULL) move_order_line_id
5079 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5080 WHERE mcce.entry_status_code IN(1, 3)
5081 AND NVL(mcce.export_flag, 2) = 2
5082 -- bug 3972076
5083 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5084 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5085 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5086 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5087 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5088 (SELECT utt_emp.standard_operation_id standard_operation_id
5089 , utt_emp.resource_id ROLE
5090 , utt_eqp.resource_id equipment
5091 , utt_emp.person_id emp_id
5092 , utt_eqp.inventory_item_id eqp_id
5093 , NULL eqp_srl /* removed for bug 2095237 */
5094 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5095 , x_utt_res1.resource_id resource_id
5096 , x_emp_r.person_id
5097 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5098 WHERE x_utt_res1.resource_id = r1.resource_id
5099 AND r1.resource_type = 2
5100 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5101 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5102 , x_utt_res2.resource_id resource_id
5103 , x_eqp_r.inventory_item_id inventory_item_id
5104 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5105 WHERE x_utt_res2.resource_id = r2.resource_id
5106 AND r2.resource_type = 1
5107 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5108 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5109 , -- inlined wms_person_resource_utt_v, bug 2648133
5110 mtl_item_locations loc
5111 , mtl_secondary_inventories sub
5112 , mtl_txn_request_lines mol
5113 -- mtl_system_items msi -- bug 2648133
5114 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5115 AND wdtv.organization_id = p_sign_on_org_id
5116 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5117 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5118 AND wdtv.ZONE = p_sign_on_zone
5119 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5120 -- AND Nvl(v.eqp_srl, '@@@') = Nvl(l_sign_on_equipment_srl, Nvl(v.eqp_srl, '@@@')) removed for bug 2095237
5121 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5122 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5123 AND wdtv.locator_id = loc.inventory_location_id(+)
5124 AND wdtv.ZONE = sub.secondary_inventory_name
5125 AND wdtv.organization_id = sub.organization_id
5126 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5127 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5128 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5129 (
5130 SELECT NULL
5131 FROM mtl_material_transactions_temp mmtt
5132 WHERE mmtt.transaction_temp_id = wdtv.task_id
5133 AND mmtt.parent_line_id IS NOT NULL
5134 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5135 AND NOT EXISTS -- exclude tasks already dispatched
5136 (SELECT NULL
5137 FROM wms_dispatched_tasks wdt1
5138 WHERE wdt1.transaction_temp_id = wdtv.task_id
5139 AND wdt1.task_type = wdtv.wms_task_type_id)
5140 --******************
5141 AND wdtv.task_id NOT IN -- excluded skipped tasks
5142 (
5143 SELECT wdtv.task_id
5144 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5145 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5146 AND wste.task_id = wdtv.task_id
5147 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5148 AND wste.organization_id = mp.organization_id)
5149 --*****************
5150 --J Addition
5151 AND wdtv.ZONE not in (
5152 SELECT wd.subinventory_code
5153 FROM wms_devices_b wd
5154 , wms_bus_event_devices wbed
5155 WHERE 1 = 1
5156 and wd.device_id = wbed.device_id
5157 AND wbed.organization_id = wd.organization_id
5158 AND wd.enabled_flag = 'Y'
5159 AND wbed.enabled_flag = 'Y'
5160 AND wbed.business_event_id = 10
5161 AND wd.subinventory_code IS NOT NULL
5162 AND wd.force_sign_on_flag = 'Y'
5163 AND wd.device_id NOT IN (SELECT device_id
5164 FROM wms_device_assignment_temp
5165 WHERE employee_id = p_sign_on_emp_id)
5166 )
5167 ORDER BY nvl(wdtv.task_priority, 0)
5168 , -- removed order by segments for bug 2657909
5169 sub.picking_order
5170 , loc.picking_order
5171 , (
5172 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5173 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5174 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5175 )
5176 , wdtv.task_id;
5177
5178 -- Cursor # 6 for selecting the most optimal task
5179 -- 1. sub is passed (1)
5180 -- 2. NOT order by across wave (0)
5181 -- 3. express pick (1)
5182
5183 CURSOR l_curs_opt_task_101 IS
5184 SELECT DISTINCT wdtv.task_id task_id
5185 , -- added distinct for bug 2657909
5186 NVL(wdtv.pick_slip_number, -1) pick_slip
5187 , wdtv.wms_task_type_id
5188 , nvl(wdtv.task_priority, 0)
5189 , mol.header_id
5190 , sub.picking_order
5191 , loc.picking_order
5192 , nvl(loc.x_coordinate, 0)
5193 , nvl(loc.y_coordinate, 0)
5194 , nvl(loc.z_coordinate, 0)
5195 FROM (SELECT transaction_temp_id task_id
5196 , standard_operation_id user_task_type_id
5197 , wms_task_type wms_task_type_id
5198 , organization_id organization_id
5199 , subinventory_code ZONE
5200 , locator_id locator_id
5201 , task_priority task_priority
5202 , revision revision
5203 , lot_number lot_number
5204 , transaction_uom transaction_uom
5205 , transaction_quantity transaction_quantity
5206 , pick_rule_id pick_rule_id
5207 , pick_slip_number pick_slip_number
5208 , cartonization_id cartonization_id
5209 , inventory_item_id
5210 , move_order_line_id
5211 FROM mtl_material_transactions_temp
5212 WHERE wms_task_type IS NOT NULL
5213 AND transaction_status = 2
5214 AND(wms_task_status IS NULL
5215 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5216 UNION ALL
5217 SELECT MIN(mcce.cycle_count_entry_id) task_id
5218 , MIN(mcce.standard_operation_id) user_task_type_id
5219 , 3 wms_task_type_id
5220 , mcce.organization_id organization_id
5221 , mcce.subinventory ZONE
5222 , mcce.locator_id locator_id
5223 , MIN(mcce.task_priority) task_priority
5224 , mcce.revision revision
5225 , MIN(mcce.lot_number) lot_number
5226 , '' transaction_uom
5227 , TO_NUMBER(NULL) transaction_quantity
5228 , TO_NUMBER(NULL) pick_rule_id
5229 , TO_NUMBER(NULL) pick_slip_number
5230 , TO_NUMBER(NULL) cartonization_id
5231 , mcce.inventory_item_id
5232 , TO_NUMBER(NULL) move_order_line_id
5233 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5234 WHERE mcce.entry_status_code IN(1, 3)
5235 AND NVL(mcce.export_flag, 2) = 2
5236 -- bug 3972076
5237 -- AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5238 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5239 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5240 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5241 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5242 (SELECT utt_emp.standard_operation_id standard_operation_id
5243 , utt_emp.resource_id ROLE
5244 , utt_eqp.resource_id equipment
5245 , utt_emp.person_id emp_id
5246 , utt_eqp.inventory_item_id eqp_id
5247 , NULL eqp_srl /* removed for bug 2095237 */
5248 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5249 , x_utt_res1.resource_id resource_id
5250 , x_emp_r.person_id
5251 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5252 WHERE x_utt_res1.resource_id = r1.resource_id
5253 AND r1.resource_type = 2
5254 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5255 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5256 , x_utt_res2.resource_id resource_id
5257 , x_eqp_r.inventory_item_id inventory_item_id
5258 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5259 WHERE x_utt_res2.resource_id = r2.resource_id
5260 AND r2.resource_type = 1
5261 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5262 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5263 , -- inlined wms_person_resource_utt_v, bug 2648133
5264 mtl_item_locations loc
5265 , mtl_secondary_inventories sub
5266 , mtl_txn_request_lines mol
5267 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5268 AND wdtv.organization_id = p_sign_on_org_id
5269 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5270 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5271 AND wdtv.ZONE = p_sign_on_zone
5272 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5273 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5274 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5275 AND wdtv.locator_id = loc.inventory_location_id(+)
5276 AND wdtv.ZONE = sub.secondary_inventory_name
5277 AND wdtv.organization_id = sub.organization_id
5278 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5279 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5280 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5281 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5282 (
5283 SELECT NULL
5284 FROM mtl_material_transactions_temp mmtt
5285 WHERE mmtt.transaction_temp_id = wdtv.task_id
5286 AND mmtt.parent_line_id IS NOT NULL
5287 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5288 AND NOT EXISTS -- exclude tasks already dispatched
5289 (SELECT NULL
5290 FROM wms_dispatched_tasks wdt1
5291 WHERE wdt1.transaction_temp_id = wdtv.task_id
5292 AND wdt1.task_type = wdtv.wms_task_type_id)
5293 --******************
5294 AND wdtv.task_id NOT IN -- excluded skipped tasks
5295 (
5296 SELECT wdtv.task_id
5297 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5298 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5299 AND wste.task_id = wdtv.task_id
5300 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5301 AND wste.organization_id = mp.organization_id)
5302 --*****************
5303 --J Addition
5304 AND wdtv.ZONE not in (
5305 SELECT wd.subinventory_code
5306 FROM wms_devices_b wd
5307 , wms_bus_event_devices wbed
5308 WHERE 1 = 1
5309 and wd.device_id = wbed.device_id
5310 AND wbed.organization_id = wd.organization_id
5311 AND wd.enabled_flag = 'Y'
5312 AND wbed.enabled_flag = 'Y'
5313 AND wbed.business_event_id = 10
5314 AND wd.subinventory_code IS NOT NULL
5315 AND wd.force_sign_on_flag = 'Y'
5316 AND wd.device_id NOT IN (SELECT device_id
5317 FROM wms_device_assignment_temp
5318 WHERE employee_id = p_sign_on_emp_id)
5319 )
5320 ORDER BY nvl(wdtv.task_priority, 0)
5321 , -- removed order by segments for bug 2657909
5322 sub.picking_order
5323 , loc.picking_order
5324 , (
5325 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5326 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5327 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5328 )
5329 , wdtv.task_id;
5330
5331 -- Cursor # 7 for selecting the most optimal task
5332 -- 1. sub NOT passed (0)
5333 -- 2. NOT order by across wave (0)
5334 -- 3. NOT express pick (0)
5335
5336 CURSOR l_curs_opt_task_000 IS
5337 SELECT DISTINCT wdtv.task_id task_id
5338 , -- added distinct for bug 2657909
5339 NVL(wdtv.pick_slip_number, -1) pick_slip
5340 , wdtv.wms_task_type_id
5341 , nvl(wdtv.task_priority, 0)
5342 , mol.header_id
5343 , sub.picking_order
5344 , loc.picking_order
5345 , nvl(loc.x_coordinate, 0)
5346 , nvl(loc.y_coordinate, 0)
5347 , nvl(loc.z_coordinate, 0)
5348 FROM (SELECT transaction_temp_id task_id
5349 , standard_operation_id user_task_type_id
5350 , wms_task_type wms_task_type_id
5351 , organization_id organization_id
5352 , subinventory_code ZONE
5353 , locator_id locator_id
5354 , task_priority task_priority
5355 , revision revision
5356 , lot_number lot_number
5357 , transaction_uom transaction_uom
5358 , transaction_quantity transaction_quantity
5359 , pick_rule_id pick_rule_id
5360 , pick_slip_number pick_slip_number
5361 , cartonization_id cartonization_id
5362 , inventory_item_id
5363 , move_order_line_id
5364 FROM mtl_material_transactions_temp
5365 WHERE wms_task_type IS NOT NULL
5366 AND transaction_status = 2
5367 AND(wms_task_status IS NULL
5368 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5369 UNION ALL
5370 SELECT MIN(mcce.cycle_count_entry_id) task_id
5371 , MIN(mcce.standard_operation_id) user_task_type_id
5372 , 3 wms_task_type_id
5373 , mcce.organization_id organization_id
5374 , mcce.subinventory ZONE
5375 , mcce.locator_id locator_id
5376 , MIN(mcce.task_priority) task_priority
5377 , mcce.revision revision
5378 , MIN(mcce.lot_number) lot_number
5379 , '' transaction_uom
5380 , TO_NUMBER(NULL) transaction_quantity
5381 , TO_NUMBER(NULL) pick_rule_id
5382 , TO_NUMBER(NULL) pick_slip_number
5383 , TO_NUMBER(NULL) cartonization_id
5384 , mcce.inventory_item_id
5385 , TO_NUMBER(NULL) move_order_line_id
5386 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5387 WHERE mcce.entry_status_code IN(1, 3)
5388 AND NVL(mcce.export_flag, 2) = 2
5389 -- bug 3972076
5390 -- AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5391 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5392 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5393 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5394 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5395 (SELECT utt_emp.standard_operation_id standard_operation_id
5396 , utt_emp.resource_id ROLE
5397 , utt_eqp.resource_id equipment
5398 , utt_emp.person_id emp_id
5399 , utt_eqp.inventory_item_id eqp_id
5400 , NULL eqp_srl /* removed for bug 2095237 */
5401 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5402 , x_utt_res1.resource_id resource_id
5403 , x_emp_r.person_id
5404 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5405 WHERE x_utt_res1.resource_id = r1.resource_id
5406 AND r1.resource_type = 2
5407 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5408 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5409 , x_utt_res2.resource_id resource_id
5410 , x_eqp_r.inventory_item_id inventory_item_id
5411 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5412 WHERE x_utt_res2.resource_id = r2.resource_id
5413 AND r2.resource_type = 1
5414 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5415 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5416 , -- inlined wms_person_resource_utt_v, bug 2648133
5417 mtl_item_locations loc
5418 , mtl_secondary_inventories sub
5419 , mtl_txn_request_lines mol
5420 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5421 AND wdtv.organization_id = p_sign_on_org_id
5422 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5423 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5424 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5425 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5426 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5427 AND wdtv.locator_id = loc.inventory_location_id(+)
5428 AND wdtv.ZONE = sub.secondary_inventory_name
5429 AND wdtv.organization_id = sub.organization_id
5430 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5431 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5432 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5433 (
5434 SELECT NULL
5435 FROM mtl_material_transactions_temp mmtt
5436 WHERE mmtt.transaction_temp_id = wdtv.task_id
5437 AND mmtt.parent_line_id IS NOT NULL
5438 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5439 AND NOT EXISTS -- exclude tasks already dispatched
5440 (SELECT NULL
5441 FROM wms_dispatched_tasks wdt1
5442 WHERE wdt1.transaction_temp_id = wdtv.task_id
5443 AND wdt1.task_type = wdtv.wms_task_type_id)
5444 --******************
5445 AND wdtv.task_id NOT IN -- excluded skipped tasks
5446 (
5447 SELECT wdtv.task_id
5448 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5449 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5450 AND wste.task_id = wdtv.task_id
5451 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5452 AND wste.organization_id = mp.organization_id)
5453 --*****************
5454 --J Addition
5455 AND wdtv.ZONE not in (
5456 SELECT wd.subinventory_code
5457 FROM wms_devices_b wd
5458 , wms_bus_event_devices wbed
5459 WHERE 1 = 1
5460 and wd.device_id = wbed.device_id
5461 AND wbed.organization_id = wd.organization_id
5462 AND wd.enabled_flag = 'Y'
5463 AND wbed.enabled_flag = 'Y'
5464 AND wbed.business_event_id = 10
5465 AND wd.subinventory_code IS NOT NULL
5466 AND wd.force_sign_on_flag = 'Y'
5467 AND wd.device_id NOT IN (SELECT device_id
5468 FROM wms_device_assignment_temp
5469 WHERE employee_id = p_sign_on_emp_id)
5470 )
5471 ORDER BY nvl(wdtv.task_priority, 0)
5472 , -- removed order by segments for bug 2657909
5473 sub.picking_order
5474 , loc.picking_order
5475 , (
5476 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5477 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5478 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5479 )
5480 , wdtv.task_id;
5481
5482 -- Cursor # 8 for selecting the most optimal task
5483 -- 1. sub NOT passed (0)
5484 -- 2. NOT order by across wave (0)
5485 -- 3. express pick (1)
5486
5487 CURSOR l_curs_opt_task_001 IS
5488 SELECT DISTINCT wdtv.task_id task_id
5489 , -- added distinct for bug 2657909
5490 NVL(wdtv.pick_slip_number, -1) pick_slip
5491 , wdtv.wms_task_type_id
5492 , nvl(wdtv.task_priority, 0)
5493 , mol.header_id
5494 , sub.picking_order
5495 , loc.picking_order
5496 , nvl(loc.x_coordinate, 0)
5497 , nvl(loc.y_coordinate, 0)
5498 , nvl(loc.z_coordinate, 0)
5499 FROM (SELECT transaction_temp_id task_id
5500 , standard_operation_id user_task_type_id
5501 , wms_task_type wms_task_type_id
5502 , organization_id organization_id
5503 , subinventory_code ZONE
5504 , locator_id locator_id
5505 , task_priority task_priority
5506 , revision revision
5507 , lot_number lot_number
5508 , transaction_uom transaction_uom
5509 , transaction_quantity transaction_quantity
5510 , pick_rule_id pick_rule_id
5511 , pick_slip_number pick_slip_number
5512 , cartonization_id cartonization_id
5513 , inventory_item_id
5514 , move_order_line_id
5515 FROM mtl_material_transactions_temp
5516 WHERE wms_task_type IS NOT NULL
5517 AND transaction_status = 2
5518 AND(wms_task_status IS NULL
5519 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5520 UNION ALL
5521 SELECT MIN(mcce.cycle_count_entry_id) task_id
5522 , MIN(mcce.standard_operation_id) user_task_type_id
5523 , 3 wms_task_type_id
5524 , mcce.organization_id organization_id
5525 , mcce.subinventory ZONE
5526 , mcce.locator_id locator_id
5527 , MIN(mcce.task_priority) task_priority
5528 , mcce.revision revision
5529 , MIN(mcce.lot_number) lot_number
5530 , '' transaction_uom
5531 , TO_NUMBER(NULL) transaction_quantity
5532 , TO_NUMBER(NULL) pick_rule_id
5533 , TO_NUMBER(NULL) pick_slip_number
5534 , TO_NUMBER(NULL) cartonization_id
5535 , mcce.inventory_item_id
5536 , TO_NUMBER(NULL) move_order_line_id
5537 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5538 WHERE mcce.entry_status_code IN(1, 3)
5539 AND NVL(mcce.export_flag, 2) = 2
5540 -- bug 3972076
5541 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5542 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5543 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5544 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5545 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5546 (SELECT utt_emp.standard_operation_id standard_operation_id
5547 , utt_emp.resource_id ROLE
5548 , utt_eqp.resource_id equipment
5549 , utt_emp.person_id emp_id
5550 , utt_eqp.inventory_item_id eqp_id
5551 , NULL eqp_srl /* removed for bug 2095237 */
5552 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5553 , x_utt_res1.resource_id resource_id
5554 , x_emp_r.person_id
5555 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5556 WHERE x_utt_res1.resource_id = r1.resource_id
5557 AND r1.resource_type = 2
5558 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5559 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5560 , x_utt_res2.resource_id resource_id
5561 , x_eqp_r.inventory_item_id inventory_item_id
5562 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5563 WHERE x_utt_res2.resource_id = r2.resource_id
5564 AND r2.resource_type = 1
5565 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5566 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5567 , -- inlined wms_person_resource_utt_v, bug 2648133
5568 mtl_item_locations loc
5569 , mtl_secondary_inventories sub
5570 , mtl_txn_request_lines mol
5571 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5572 AND wdtv.organization_id = p_sign_on_org_id
5573 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5574 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5575 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5576 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5577 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5578 AND wdtv.locator_id = loc.inventory_location_id(+)
5579 AND wdtv.ZONE = sub.secondary_inventory_name
5580 AND wdtv.organization_id = sub.organization_id
5581 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5582 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5583 AND Nvl(wdtv.pick_slip_number, -1) <> l_opt_task_pick_slip -- bug 2832818
5584 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5585 (
5586 SELECT NULL
5587 FROM mtl_material_transactions_temp mmtt
5588 WHERE mmtt.transaction_temp_id = wdtv.task_id
5589 AND mmtt.parent_line_id IS NOT NULL
5590 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5591 AND NOT EXISTS -- exclude tasks already dispatched
5592 (SELECT NULL
5593 FROM wms_dispatched_tasks wdt1
5594 WHERE wdt1.transaction_temp_id = wdtv.task_id
5595 AND wdt1.task_type = wdtv.wms_task_type_id)
5596 --******************
5597 AND wdtv.task_id NOT IN -- excluded skipped tasks
5598 (
5599 SELECT wdtv.task_id
5600 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5601 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5602 AND wste.task_id = wdtv.task_id
5603 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5604 AND wste.organization_id = mp.organization_id)
5605 --*****************
5606 --J Addition
5607 AND wdtv.ZONE not in (
5608 SELECT wd.subinventory_code
5609 FROM wms_devices_b wd
5610 , wms_bus_event_devices wbed
5611 WHERE 1 = 1
5612 and wd.device_id = wbed.device_id
5613 AND wbed.organization_id = wd.organization_id
5614 AND wd.enabled_flag = 'Y'
5615 AND wbed.enabled_flag = 'Y'
5616 AND wbed.business_event_id = 10
5617 AND wd.subinventory_code IS NOT NULL
5618 AND wd.force_sign_on_flag = 'Y'
5619 AND wd.device_id NOT IN (SELECT device_id
5620 FROM wms_device_assignment_temp
5621 WHERE employee_id = p_sign_on_emp_id)
5622 )
5623 ORDER BY nvl(wdtv.task_priority, 0)
5624 , -- removed order by segments for bug 2657909
5625 sub.picking_order
5626 , loc.picking_order
5627 , (
5628 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5629 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5630 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5631 )
5632 , wdtv.task_id;
5633
5634 CURSOR l_curs_ordered_tasks(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
5635 SELECT DISTINCT wdtv.task_id task_id
5636 , -- added distinct for bug 2657909
5637 NVL(wdtv.pick_slip_number, -1) pick_slip
5638 , wdtv.wms_task_type_id
5639 , nvl(wdtv.task_priority, 0)
5640 , -- added following because of distinct for bug 2657909
5641 mol.header_id
5642 , sub.picking_order
5643 , loc.picking_order
5644 , nvl(loc.x_coordinate, 0)
5645 , nvl(loc.y_coordinate, 0)
5646 , nvl(loc.z_coordinate, 0)
5647 FROM (SELECT transaction_temp_id task_id
5648 , standard_operation_id user_task_type_id
5649 , wms_task_type wms_task_type_id
5650 , organization_id organization_id
5651 , subinventory_code ZONE
5652 , locator_id locator_id
5653 , task_priority task_priority
5654 , revision revision
5655 , lot_number lot_number
5656 , transaction_uom transaction_uom
5657 , transaction_quantity transaction_quantity
5658 , pick_rule_id pick_rule_id
5659 , pick_slip_number pick_slip_number
5660 , cartonization_id cartonization_id
5661 , inventory_item_id
5662 , move_order_line_id
5663 FROM mtl_material_transactions_temp
5664 WHERE wms_task_type IS NOT NULL
5665 AND transaction_status = 2
5666 AND(wms_task_status IS NULL
5667 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5668 UNION ALL
5669 SELECT MIN(mcce.cycle_count_entry_id) task_id
5670 , MIN(mcce.standard_operation_id) user_task_type_id
5671 , 3 wms_task_type_id
5672 , mcce.organization_id organization_id
5673 , mcce.subinventory ZONE
5674 , mcce.locator_id locator_id
5675 , MIN(mcce.task_priority) task_priority
5676 , mcce.revision revision
5677 , MIN(mcce.lot_number) lot_number
5678 , '' transaction_uom
5679 , TO_NUMBER(NULL) transaction_quantity
5680 , TO_NUMBER(NULL) pick_rule_id
5681 , TO_NUMBER(NULL) pick_slip_number
5682 , TO_NUMBER(NULL) cartonization_id
5683 , mcce.inventory_item_id
5684 , TO_NUMBER(NULL) move_order_line_id
5685 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5686 WHERE mcce.entry_status_code IN(1, 3)
5687 AND NVL(mcce.export_flag, 2) = 2
5688 -- bug 3972076
5689 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5690 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5691 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5692 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5693 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5694 (SELECT utt_emp.standard_operation_id standard_operation_id
5695 , utt_emp.resource_id ROLE
5696 , utt_eqp.resource_id equipment
5697 , utt_emp.person_id emp_id
5698 , utt_eqp.inventory_item_id eqp_id
5699 , NULL eqp_srl /* removed for bug 2095237 */
5700 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5701 , x_utt_res1.resource_id resource_id
5702 , x_emp_r.person_id
5703 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5704 WHERE x_utt_res1.resource_id = r1.resource_id
5705 AND r1.resource_type = 2
5706 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5707 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5708 , x_utt_res2.resource_id resource_id
5709 , x_eqp_r.inventory_item_id inventory_item_id
5710 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5711 WHERE x_utt_res2.resource_id = r2.resource_id
5712 AND r2.resource_type = 1
5713 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5714 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5715 , -- inlined wms_person_resource_utt_v, bug 2648133
5716 mtl_item_locations loc
5717 , mtl_secondary_inventories sub
5718 , mtl_txn_request_lines mol
5719 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5720 AND(wdtv.pick_slip_number = v_pick_slip_number
5721 OR(wdtv.task_id = v_task_id
5722 AND wdtv.wms_task_type_id = v_task_type))
5723 AND wdtv.organization_id = p_sign_on_org_id
5724 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5725 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5726 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
5727 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5728 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5729 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5730 AND wdtv.locator_id = loc.inventory_location_id(+)
5731 AND wdtv.ZONE = sub.secondary_inventory_name
5732 AND wdtv.organization_id = sub.organization_id
5733 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5734 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5735 (
5736 SELECT NULL
5737 FROM mtl_material_transactions_temp mmtt
5738 WHERE mmtt.transaction_temp_id = wdtv.task_id
5739 AND mmtt.parent_line_id IS NOT NULL
5740 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5741 AND NOT EXISTS -- exclude tasks already dispatched
5742 (SELECT NULL
5743 FROM wms_dispatched_tasks wdt1
5744 WHERE wdt1.transaction_temp_id = wdtv.task_id
5745 AND wdt1.task_type = wdtv.wms_task_type_id)
5746 --******************
5747 AND wdtv.task_id NOT IN -- excluded skipped tasks
5748 (
5749 SELECT wdtv.task_id
5750 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5751 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5752 AND wste.task_id = wdtv.task_id
5753 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5754 AND wste.organization_id = mp.organization_id)
5755 --*****************
5756 --J Addition
5757 AND wdtv.ZONE not in (
5758 SELECT wd.subinventory_code
5759 FROM wms_devices_b wd
5760 , wms_bus_event_devices wbed
5761 WHERE 1 = 1
5762 and wd.device_id = wbed.device_id
5763 AND wbed.organization_id = wd.organization_id
5764 AND wd.enabled_flag = 'Y'
5765 AND wbed.enabled_flag = 'Y'
5766 AND wbed.business_event_id = 10
5767 AND wd.subinventory_code IS NOT NULL
5768 AND wd.force_sign_on_flag = 'Y'
5769 AND wd.device_id NOT IN (SELECT device_id
5770 FROM wms_device_assignment_temp
5771 WHERE employee_id = p_sign_on_emp_id)
5772 )
5773 ORDER BY nvl(wdtv.task_priority, 0)
5774 , -- removed order by segments for bug 2657909
5775 mol.header_id
5776 , sub.picking_order
5777 , loc.picking_order
5778 , (
5779 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5780 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5781 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5782 )
5783 , wdtv.task_id;
5784
5785 CURSOR l_curs_ordered_tasks_exp(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS -- bug 2648133
5786 SELECT DISTINCT wdtv.task_id task_id
5787 , -- added distinct for bug 2657909
5788 NVL(wdtv.pick_slip_number, -1) pick_slip
5789 , wdtv.wms_task_type_id
5790 , nvl(wdtv.task_priority, 0)
5791 , -- added following because of distinct for bug 2657909
5792 mol.header_id
5793 , sub.picking_order
5794 , loc.picking_order
5795 , nvl(loc.x_coordinate, 0)
5796 , nvl(loc.y_coordinate, 0)
5797 , nvl(loc.z_coordinate, 0)
5798 FROM (SELECT transaction_temp_id task_id
5799 , standard_operation_id user_task_type_id
5800 , wms_task_type wms_task_type_id
5801 , organization_id organization_id
5802 , subinventory_code ZONE
5803 , locator_id locator_id
5804 , task_priority task_priority
5805 , revision revision
5806 , lot_number lot_number
5807 , transaction_uom transaction_uom
5808 , transaction_quantity transaction_quantity
5809 , pick_rule_id pick_rule_id
5810 , pick_slip_number pick_slip_number
5811 , cartonization_id cartonization_id
5812 , inventory_item_id
5813 , move_order_line_id
5814 FROM mtl_material_transactions_temp
5815 WHERE wms_task_type IS NOT NULL
5816 AND transaction_status = 2
5817 AND(wms_task_status IS NULL
5818 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5819 UNION ALL
5820 SELECT MIN(mcce.cycle_count_entry_id) task_id
5821 , MIN(mcce.standard_operation_id) user_task_type_id
5822 , 3 wms_task_type_id
5823 , mcce.organization_id organization_id
5824 , mcce.subinventory ZONE
5825 , mcce.locator_id locator_id
5826 , MIN(mcce.task_priority) task_priority
5827 , mcce.revision revision
5828 , MIN(mcce.lot_number) lot_number
5829 , '' transaction_uom
5830 , TO_NUMBER(NULL) transaction_quantity
5831 , TO_NUMBER(NULL) pick_rule_id
5832 , TO_NUMBER(NULL) pick_slip_number
5833 , TO_NUMBER(NULL) cartonization_id
5834 , mcce.inventory_item_id
5835 , TO_NUMBER(NULL) move_order_line_id
5836 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5837 WHERE mcce.entry_status_code IN(1, 3)
5838 AND NVL(mcce.export_flag, 2) = 2
5839 -- bug 3972076
5840 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5841 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
5842 AND NVL(mcch.disable_date,sysdate+1)> sysdate
5843 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5844 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5845 (SELECT utt_emp.standard_operation_id standard_operation_id
5846 , utt_emp.resource_id ROLE
5847 , utt_eqp.resource_id equipment
5848 , utt_emp.person_id emp_id
5849 , utt_eqp.inventory_item_id eqp_id
5850 , NULL eqp_srl /* removed for bug 2095237 */
5851 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
5852 , x_utt_res1.resource_id resource_id
5853 , x_emp_r.person_id
5854 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
5855 WHERE x_utt_res1.resource_id = r1.resource_id
5856 AND r1.resource_type = 2
5857 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
5858 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
5859 , x_utt_res2.resource_id resource_id
5860 , x_eqp_r.inventory_item_id inventory_item_id
5861 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
5862 WHERE x_utt_res2.resource_id = r2.resource_id
5863 AND r2.resource_type = 1
5864 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
5865 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
5866 , -- inlined wms_person_resource_utt_v, bug 2648133
5867 mtl_item_locations loc
5868 , mtl_secondary_inventories sub
5869 , mtl_txn_request_lines mol
5870 -- mtl_system_items msi -- bug 2648133
5871 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
5872 AND(wdtv.pick_slip_number = v_pick_slip_number
5873 OR(wdtv.task_id = v_task_id
5874 AND wdtv.wms_task_type_id = v_task_type))
5875 AND wdtv.organization_id = p_sign_on_org_id
5876 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
5877 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
5878 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
5879 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
5880 -- AND Nvl(v.eqp_srl, '@@@') = Nvl(l_sign_on_equipment_srl, Nvl(v.eqp_srl, '@@@')) removed for bug 2095237
5881 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
5882 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
5883 AND wdtv.locator_id = loc.inventory_location_id(+)
5884 AND wdtv.ZONE = sub.secondary_inventory_name
5885 AND wdtv.organization_id = sub.organization_id
5886 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
5887 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
5888 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
5889 (
5890 SELECT NULL
5891 FROM mtl_material_transactions_temp mmtt
5892 WHERE mmtt.transaction_temp_id = wdtv.task_id
5893 AND mmtt.parent_line_id IS NOT NULL
5894 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
5895 AND NOT EXISTS -- exclude tasks already dispatched
5896 (SELECT NULL
5897 FROM wms_dispatched_tasks wdt1
5898 WHERE wdt1.transaction_temp_id = wdtv.task_id
5899 AND wdt1.task_type = wdtv.wms_task_type_id)
5900 --******************
5901 AND wdtv.task_id NOT IN -- excluded skipped tasks
5902 (
5903 SELECT wdtv.task_id
5904 FROM wms_skip_task_exceptions wste, mtl_parameters mp
5905 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
5906 AND wste.task_id = wdtv.task_id
5907 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
5908 AND wste.organization_id = mp.organization_id)
5909 --*****************
5910 --J Addition
5911 AND wdtv.ZONE not in (
5912 SELECT wd.subinventory_code
5913 FROM wms_devices_b wd
5914 , wms_bus_event_devices wbed
5915 WHERE 1 = 1
5916 and wd.device_id = wbed.device_id
5917 AND wbed.organization_id = wd.organization_id
5918 AND wd.enabled_flag = 'Y'
5919 AND wbed.enabled_flag = 'Y'
5920 AND wbed.business_event_id = 10
5921 AND wd.subinventory_code IS NOT NULL
5922 AND wd.force_sign_on_flag = 'Y'
5923 AND wd.device_id NOT IN (SELECT device_id
5924 FROM wms_device_assignment_temp
5925 WHERE employee_id = p_sign_on_emp_id)
5926 )
5927 ORDER BY nvl(wdtv.task_priority, 0)
5928 , -- removed order by segments for bug 2657909
5929 mol.header_id
5930 , sub.picking_order
5931 , loc.picking_order
5932 , (
5933 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
5934 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
5935 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
5936 )
5937 , wdtv.task_id;
5938
5939 CURSOR l_curs_ordered_tasks_aw(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
5940 SELECT DISTINCT wdtv.task_id task_id
5941 , -- added distinct for bug 2657909
5942 NVL(wdtv.pick_slip_number, -1) pick_slip
5943 , wdtv.wms_task_type_id
5944 , nvl(wdtv.task_priority, 0)
5945 , mol.header_id
5946 , sub.picking_order
5947 , loc.picking_order
5948 , nvl(loc.x_coordinate, 0)
5949 , nvl(loc.y_coordinate, 0)
5950 , nvl(loc.z_coordinate, 0)
5951 FROM (SELECT transaction_temp_id task_id
5952 , standard_operation_id user_task_type_id
5953 , wms_task_type wms_task_type_id
5954 , organization_id organization_id
5955 , subinventory_code ZONE
5956 , locator_id locator_id
5957 , task_priority task_priority
5958 , revision revision
5959 , lot_number lot_number
5960 , transaction_uom transaction_uom
5961 , transaction_quantity transaction_quantity
5962 , pick_rule_id pick_rule_id
5963 , pick_slip_number pick_slip_number
5964 , cartonization_id cartonization_id
5965 , inventory_item_id
5966 , move_order_line_id
5967 FROM mtl_material_transactions_temp
5968 WHERE wms_task_type IS NOT NULL
5969 AND transaction_status = 2
5970 AND(wms_task_status IS NULL
5971 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
5972 UNION ALL
5973 SELECT MIN(mcce.cycle_count_entry_id) task_id
5974 , MIN(mcce.standard_operation_id) user_task_type_id
5975 , 3 wms_task_type_id
5976 , mcce.organization_id organization_id
5977 , mcce.subinventory ZONE
5978 , mcce.locator_id locator_id
5979 , MIN(mcce.task_priority) task_priority
5980 , mcce.revision revision
5981 , MIN(mcce.lot_number) lot_number
5982 , '' transaction_uom
5983 , TO_NUMBER(NULL) transaction_quantity
5984 , TO_NUMBER(NULL) pick_rule_id
5985 , TO_NUMBER(NULL) pick_slip_number
5986 , TO_NUMBER(NULL) cartonization_id
5987 , mcce.inventory_item_id
5988 , TO_NUMBER(NULL) move_order_line_id
5989 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
5990 WHERE mcce.entry_status_code IN(1, 3)
5991 AND NVL(mcce.export_flag, 2) = 2
5992 -- bug 3972076
5993 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
5994 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
5995 , -- inlined wms_dispatchable_tasks_v, bug 2648133
5996 (SELECT utt_emp.standard_operation_id standard_operation_id
5997 , utt_emp.resource_id ROLE
5998 , utt_eqp.resource_id equipment
5999 , utt_emp.person_id emp_id
6000 , utt_eqp.inventory_item_id eqp_id
6001 , NULL eqp_srl /* removed for bug 2095237 */
6002 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6003 , x_utt_res1.resource_id resource_id
6004 , x_emp_r.person_id
6005 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6006 WHERE x_utt_res1.resource_id = r1.resource_id
6007 AND r1.resource_type = 2
6008 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6009 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6010 , x_utt_res2.resource_id resource_id
6011 , x_eqp_r.inventory_item_id inventory_item_id
6012 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6013 WHERE x_utt_res2.resource_id = r2.resource_id
6014 AND r2.resource_type = 1
6015 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6016 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6017 , -- inlined wms_person_resource_utt_v, bug 2648133
6018 mtl_item_locations loc
6019 , mtl_secondary_inventories sub
6020 , mtl_txn_request_lines mol
6021 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6022 AND(wdtv.pick_slip_number = v_pick_slip_number
6023 OR(wdtv.task_id = v_task_id
6024 AND wdtv.wms_task_type_id = v_task_type))
6025 AND wdtv.organization_id = p_sign_on_org_id
6026 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6027 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6028 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@'))
6029 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6030 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6031 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6032 AND wdtv.locator_id = loc.inventory_location_id(+)
6033 AND wdtv.ZONE = sub.secondary_inventory_name
6034 AND wdtv.organization_id = sub.organization_id
6035 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6036 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6037 (
6038 SELECT NULL
6039 FROM mtl_material_transactions_temp mmtt
6040 WHERE mmtt.transaction_temp_id = wdtv.task_id
6041 AND mmtt.parent_line_id IS NOT NULL
6042 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6043 AND NOT EXISTS -- exclude tasks already dispatched
6044 (SELECT NULL
6045 FROM wms_dispatched_tasks wdt1
6046 WHERE wdt1.transaction_temp_id = wdtv.task_id
6047 AND wdt1.task_type = wdtv.wms_task_type_id)
6048 --******************
6049 AND wdtv.task_id NOT IN -- excluded skipped tasks
6050 (
6051 SELECT wdtv.task_id
6052 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6053 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6054 AND wste.task_id = wdtv.task_id
6055 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6056 AND wste.organization_id = mp.organization_id)
6057 --*****************
6058 --J Addition
6059 AND wdtv.ZONE not in (
6060 SELECT wd.subinventory_code
6061 FROM wms_devices_b wd
6062 , wms_bus_event_devices wbed
6063 WHERE 1 = 1
6064 and wd.device_id = wbed.device_id
6065 AND wbed.organization_id = wd.organization_id
6066 AND wd.enabled_flag = 'Y'
6067 AND wbed.enabled_flag = 'Y'
6068 AND wbed.business_event_id = 10
6069 AND wd.subinventory_code IS NOT NULL
6070 AND wd.force_sign_on_flag = 'Y'
6071 AND wd.device_id NOT IN (SELECT device_id
6072 FROM wms_device_assignment_temp
6073 WHERE employee_id = p_sign_on_emp_id)
6074 )
6075
6076 ORDER BY nvl(wdtv.task_priority, 0)
6077 , -- removed order by segments for bug 2657909
6078 sub.picking_order
6079 , loc.picking_order
6080 , (
6081 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6082 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6083 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6084 )
6085 , wdtv.task_id;
6086
6087 CURSOR l_curs_ordered_tasks_aw_exp(v_pick_slip_number NUMBER, v_task_id NUMBER, v_task_type NUMBER) IS
6088 SELECT DISTINCT wdtv.task_id task_id
6089 , -- added distinct for bug 2657909
6090 NVL(wdtv.pick_slip_number, -1) pick_slip
6091 , wdtv.wms_task_type_id
6092 , nvl(wdtv.task_priority, 0)
6093 , mol.header_id
6094 , sub.picking_order
6095 , loc.picking_order
6096 , nvl(loc.x_coordinate, 0)
6097 , nvl(loc.y_coordinate, 0)
6098 , nvl(loc.z_coordinate, 0)
6099 FROM (SELECT transaction_temp_id task_id
6100 , standard_operation_id user_task_type_id
6101 , wms_task_type wms_task_type_id
6102 , organization_id organization_id
6103 , subinventory_code ZONE
6104 , locator_id locator_id
6105 , task_priority task_priority
6106 , revision revision
6107 , lot_number lot_number
6108 , transaction_uom transaction_uom
6109 , transaction_quantity transaction_quantity
6110 , pick_rule_id pick_rule_id
6111 , pick_slip_number pick_slip_number
6112 , cartonization_id cartonization_id
6113 , inventory_item_id
6114 , move_order_line_id
6115 FROM mtl_material_transactions_temp
6116 WHERE wms_task_type IS NOT NULL
6117 AND transaction_status = 2
6118 AND(wms_task_status IS NULL
6119 OR wms_task_status = 1) --Added for task planning WB. bug#2651318
6120 UNION ALL
6121 SELECT MIN(mcce.cycle_count_entry_id) task_id
6122 , MIN(mcce.standard_operation_id) user_task_type_id
6123 , 3 wms_task_type_id
6124 , mcce.organization_id organization_id
6125 , mcce.subinventory ZONE
6126 , mcce.locator_id locator_id
6127 , MIN(mcce.task_priority) task_priority
6128 , mcce.revision revision
6129 , MIN(mcce.lot_number) lot_number
6130 , '' transaction_uom
6131 , TO_NUMBER(NULL) transaction_quantity
6132 , TO_NUMBER(NULL) pick_rule_id
6133 , TO_NUMBER(NULL) pick_slip_number
6134 , TO_NUMBER(NULL) cartonization_id
6135 , mcce.inventory_item_id
6136 , TO_NUMBER(NULL) move_order_line_id
6137 FROM mtl_cycle_count_entries mcce, mtl_cycle_count_headers mcch
6138 WHERE mcce.entry_status_code IN(1, 3)
6139 AND NVL(mcce.export_flag, 2) = 2
6140 -- bug 3972076
6141 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6142 AND mcce.cycle_count_header_id = mcch.cycle_count_header_id
6143 AND NVL(mcch.disable_date,sysdate+1)> sysdate
6144 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id, mcce.revision) wdtv
6145 , -- inlined wms_dispatchable_tasks_v, bug 2648133
6146 (SELECT utt_emp.standard_operation_id standard_operation_id
6147 , utt_emp.resource_id ROLE
6148 , utt_eqp.resource_id equipment
6149 , utt_emp.person_id emp_id
6150 , utt_eqp.inventory_item_id eqp_id
6151 , NULL eqp_srl /* removed for bug 2095237 */
6152 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
6153 , x_utt_res1.resource_id resource_id
6154 , x_emp_r.person_id
6155 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
6156 WHERE x_utt_res1.resource_id = r1.resource_id
6157 AND r1.resource_type = 2
6158 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
6159 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
6160 , x_utt_res2.resource_id resource_id
6161 , x_eqp_r.inventory_item_id inventory_item_id
6162 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
6163 WHERE x_utt_res2.resource_id = r2.resource_id
6164 AND r2.resource_type = 1
6165 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
6166 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
6167 , -- inlined wms_person_resource_utt_v, bug 2648133
6168 mtl_item_locations loc
6169 , mtl_secondary_inventories sub
6170 , mtl_txn_request_lines mol
6171 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
6172 AND(wdtv.pick_slip_number = v_pick_slip_number
6173 OR(wdtv.task_id = v_task_id
6174 AND wdtv.wms_task_type_id = v_task_type))
6175 AND wdtv.organization_id = p_sign_on_org_id
6176 AND wdtv.wms_task_type_id = NVL(l_sys_task_type, wdtv.wms_task_type_id) -- restrict to picking tasks or all tasks
6177 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
6178 AND NVL(wdtv.ZONE, '@@@') = NVL(p_sign_on_zone, NVL(wdtv.ZONE, '@@@')) -- bug 2648133
6179 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
6180 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
6181 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
6182 AND wdtv.locator_id = loc.inventory_location_id(+)
6183 AND wdtv.ZONE = sub.secondary_inventory_name
6184 AND wdtv.organization_id = sub.organization_id
6185 AND wdtv.move_order_line_id = mol.line_id(+) -- join task to MOL, outer join for tasks do not have MOL
6186 AND wms_express_pick_task.is_express_pick_task_eligible(wdtv.task_id) = 'S'
6187 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
6188 (
6189 SELECT NULL
6190 FROM mtl_material_transactions_temp mmtt
6191 WHERE mmtt.transaction_temp_id = wdtv.task_id
6192 AND mmtt.parent_line_id IS NOT NULL
6193 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
6194 AND NOT EXISTS -- exclude tasks already dispatched
6195 (SELECT NULL
6196 FROM wms_dispatched_tasks wdt1
6197 WHERE wdt1.transaction_temp_id = wdtv.task_id
6198 AND wdt1.task_type = wdtv.wms_task_type_id)
6199 --******************
6200 AND wdtv.task_id NOT IN -- excluded skipped tasks
6201 (
6202 SELECT wdtv.task_id
6203 FROM wms_skip_task_exceptions wste, mtl_parameters mp
6204 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
6205 AND wste.task_id = wdtv.task_id
6206 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
6207 AND wste.organization_id = mp.organization_id)
6208 --*****************
6209 --J Addition
6210 AND wdtv.ZONE not in (
6211 SELECT wd.subinventory_code
6212 FROM wms_devices_b wd
6213 , wms_bus_event_devices wbed
6214 WHERE 1 = 1
6215 and wd.device_id = wbed.device_id
6216 AND wbed.organization_id = wd.organization_id
6217 AND wd.enabled_flag = 'Y'
6218 AND wbed.enabled_flag = 'Y'
6219 AND wbed.business_event_id = 10
6220 AND wd.subinventory_code IS NOT NULL
6221 AND wd.force_sign_on_flag = 'Y'
6222 AND wd.device_id NOT IN (SELECT device_id
6223 FROM wms_device_assignment_temp
6224 WHERE employee_id = p_sign_on_emp_id)
6225 )
6226 ORDER BY nvl(wdtv.task_priority, 0)
6227 , -- removed order by segments for bug 2657909
6228 sub.picking_order
6229 , loc.picking_order
6230 , (
6231 (loc.x_coordinate - l_cur_x) *(loc.x_coordinate - l_cur_x)
6232 + (loc.y_coordinate - l_cur_y) *(loc.y_coordinate - l_cur_y)
6233 + (loc.z_coordinate - l_cur_z) *(loc.z_coordinate - l_cur_z)
6234 )
6235 , wdtv.task_id;
6236
6237
6238 CURSOR c_lock_check(v_pick_slip_number NUMBER) IS
6239
6240 SELECT transaction_temp_id
6241 FROM mtl_material_transactions_temp mmtt
6242 WHERE mmtt.pick_slip_number = v_pick_slip_number
6243 FOR UPDATE nowait;
6244
6245
6246 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
6247 BEGIN
6248 IF (l_debug = 1) THEN
6249 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6250 END IF;
6251
6252 l_progress := '10';
6253
6254 -- This API is query only, therefore does not create a save point
6255
6256 -- Initialize message list if p_init_msg_list is set to TRUE.
6257 IF fnd_api.to_boolean(p_init_msg_list) THEN
6258 fnd_msg_pub.initialize;
6259 END IF;
6260
6261 -- Initialize API return status to success
6262 x_return_status := fnd_api.g_ret_sts_success;
6263 -- API body
6264 -- preprocess input parameters
6265
6266 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
6267
6268 IF l_sequence_picks_across_waves IS NULL THEN
6269 l_sequence_picks_across_waves := 2;
6270 END IF;
6271
6272 IF p_sign_on_equipment_srl = 'NONE' THEN
6273 l_sign_on_equipment_srl := NULL;
6274 l_sign_on_equipment_id := -999;
6275 ELSE
6276 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
6277 l_sign_on_equipment_id := p_sign_on_equipment_id;
6278 END IF;
6279
6280 -- use l_equipment_id_str to concatenate sql statement
6281 IF l_sign_on_equipment_id IS NULL THEN
6282 l_equipment_id_str := 'NULL';
6283 ELSE
6284 l_equipment_id_str := TO_CHAR(l_sign_on_equipment_id);
6285 END IF;
6286
6287 IF p_task_type = 'PICKING' THEN
6288 l_sys_task_type := 1;
6289 ELSIF p_task_type = 'EXPPICK' THEN
6290 l_sys_task_type := 1;
6291 l_is_express_pick := 1;
6292
6293 IF (l_debug = 1) THEN
6294 print_debug('Express Pick Task', 4);
6295 END IF;
6296 ELSE
6297 l_sys_task_type := NULL;
6298 END IF;
6299
6300 -- check if this call is for picking tasks or for all tasks
6301 IF p_task_type = 'DISPLAY' THEN
6302 IF (l_debug = 1) THEN
6303 print_debug('dispatch_task - DISPLAY ', 4);
6304 END IF;
6305
6306 l_progress := '20';
6307 /*
6308 l_sql_stmt :=
6309 'SELECT wdtv.task_id, wdtv.zone, wdtv.locator_id,
6310 wdtv.revision, wdtv.transaction_uom,
6311 wdtv.transaction_quantity, wdtv.lot_number, wdtv.wms_task_type_id,wdtv.task_priority
6312 FROM wms_dispatchable_tasks_v wdtv
6313 WHERE
6314 wdtv.organization_id = ' || p_sign_on_org_id ||'
6315 AND Nvl(wdtv.zone, ''@@@'') = Nvl('''|| p_sign_on_zone || ''', Nvl(wdtv.zone, ''@@@''))
6316 AND wdtv.user_task_type_id IN
6317 (
6318 SELECT standard_operation_id
6319 FROM wms_person_resource_utt_v v
6320 WHERE v.emp_id = ' || p_sign_on_emp_id ||'
6321 AND Nvl(v.eqp_srl, ''@@@'') = Nvl(''' || l_sign_on_equipment_srl || ''', Nvl(v.eqp_srl, ''@@@''))
6322 AND Nvl(v.eqp_id, -999) = Nvl(' || l_equipment_id_str ||', Nvl(v.eqp_id, -999))
6323 )
6324 --***********
6325 AND wdtv.task_id NOT IN
6326 (SELECT wdtv.task_id FROM wms_skip_task_exceptions wste, mtl_parameters mp
6327 WHERE ((SYSDATE - wste.creation_date)*24*60) < mp.skip_task_waiting_minutes
6328 AND wste.task_id = wdtv.task_id
6329 AND wste.organization_id = mp.organization_id )
6330 --************
6331 AND wdtv.task_id NOT IN
6332 (SELECT wdt1.transaction_temp_id
6333 FROM wms_dispatched_tasks wdt1
6334 -- WHERE wdt1.status = 1
6335 UNION ALL
6336 SELECT wdt2.transaction_temp_id
6337 FROM wms_exceptions wms_except, wms_dispatched_tasks wdt2
6338 WHERE wms_except.person_id = ' || p_sign_on_emp_id || '
6339 AND wdt2.task_id = wms_except.task_id
6340 AND discrepancy_type = 1
6341 )
6342 ORDER BY wdtv.pick_slip_number, wdtv.task_priority, wdtv.task_id';
6343 */
6344 ELSIF(p_task_type = 'ALL'
6345 OR p_task_type = 'EXPPICK') THEN -- the call is for ALL taks
6346 IF (l_debug = 1) THEN
6347 print_debug('dispatch_task -' || p_task_type, 4);
6348 END IF;
6349
6350 l_progress := '30';
6351
6352 -- select last task this operator was working on
6353 BEGIN
6354 SELECT transaction_temp_id
6355 , task_type
6356 , loaded_time
6357 INTO l_last_loaded_task_id
6358 , l_last_loaded_task_type
6359 , l_last_loaded_time
6360 FROM (SELECT transaction_temp_id
6361 , task_type
6362 , loaded_time
6363 FROM wms_dispatched_tasks wdt
6364 WHERE wdt.person_id = p_sign_on_emp_id
6365 AND wdt.loaded_time = (SELECT MAX(loaded_time)
6366 FROM wms_dispatched_tasks
6367 WHERE person_id = p_sign_on_emp_id))
6368 WHERE ROWNUM = 1 -- make sure only one task selected
6369 ;
6370
6371 l_progress := '31';
6372 EXCEPTION
6373 WHEN OTHERS THEN
6374 l_last_loaded_task_id := -1;
6375 END;
6376
6377 IF (l_debug = 1) THEN
6378 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
6379 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
6380 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
6381 END IF;
6382
6383 -- select last task this operator completed
6384 BEGIN
6385 l_progress := '32';
6386
6387 SELECT transaction_id
6388 , task_type
6389 , loaded_time
6390 INTO l_last_dropoff_task_id
6391 , l_last_dropoff_task_type
6392 , l_last_dropoff_time
6393 FROM (SELECT transaction_id
6394 , task_type
6395 , loaded_time
6396 FROM wms_dispatched_tasks_history wdth
6397 WHERE wdth.person_id = p_sign_on_emp_id
6398 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
6399 FROM wms_dispatched_tasks_history
6400 WHERE person_id = p_sign_on_emp_id))
6401 WHERE ROWNUM = 1 -- make sure only one task selected
6402 ;
6403
6404 l_progress := '33';
6405 EXCEPTION
6406 WHEN OTHERS THEN
6407 l_last_dropoff_task_id := -1;
6408 END;
6409
6410 IF (l_debug = 1) THEN
6411 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
6412 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
6413 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
6414 END IF;
6415
6416 IF l_last_dropoff_task_id = -1
6417 AND l_last_loaded_task_id = -1 THEN
6418 l_last_task_id := -1;
6419 ELSIF l_last_dropoff_task_id = -1 THEN
6420 l_last_task_id := l_last_loaded_task_id;
6421 l_last_task_type := l_last_loaded_task_type;
6422 l_last_task_is_drop := FALSE;
6423 ELSIF l_last_loaded_task_id = -1 THEN
6424 l_last_task_id := l_last_dropoff_task_id;
6425 l_last_task_type := l_last_dropoff_task_type;
6426 l_last_task_is_drop := TRUE;
6427 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
6428 l_last_task_id := l_last_dropoff_task_id;
6429 l_last_task_type := l_last_dropoff_task_type;
6430 l_last_task_is_drop := TRUE;
6431 END IF;
6432
6433 IF (l_debug = 1) THEN
6434 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
6435 END IF;
6436
6437 -- select locator coordinates of the the last task
6438 IF l_last_task_id <> -1 -- make sure there is a last task
6439 THEN
6440 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
6441 -- get the location from wms_dispatchable_tasks_v
6442 BEGIN
6443 l_progress := '35';
6444
6445 -- use Nvl to make sure if coordinates not defined, use 0
6446 SELECT NVL(loc.x_coordinate, 0)
6447 , NVL(loc.y_coordinate, 0)
6448 , NVL(loc.z_coordinate, 0)
6449 INTO l_cur_x
6450 , l_cur_y
6451 , l_cur_z
6452 FROM mtl_item_locations loc
6453 , (SELECT transaction_temp_id task_id
6454 , standard_operation_id user_task_type_id
6455 , wms_task_type wms_task_type_id
6456 , organization_id organization_id
6457 , subinventory_code ZONE
6458 , locator_id locator_id
6459 , task_priority task_priority
6460 , revision revision
6461 , lot_number lot_number
6462 , transaction_uom transaction_uom
6463 , transaction_quantity transaction_quantity
6464 , pick_rule_id pick_rule_id
6465 , pick_slip_number pick_slip_number
6466 , cartonization_id cartonization_id
6467 , inventory_item_id
6468 , move_order_line_id
6469 FROM mtl_material_transactions_temp
6470 WHERE wms_task_type IS NOT NULL
6471 AND transaction_status = 2
6472 UNION ALL
6473 SELECT MIN(cycle_count_entry_id) task_id
6474 , MIN(standard_operation_id) user_task_type_id
6475 , 3 wms_task_type_id
6476 , organization_id organization_id
6477 , subinventory ZONE
6478 , locator_id locator_id
6479 , MIN(task_priority) task_priority
6480 , revision revision
6481 , MIN(lot_number) lot_number
6482 , '' transaction_uom
6483 , TO_NUMBER(NULL) transaction_quantity
6484 , TO_NUMBER(NULL) pick_rule_id
6485 , TO_NUMBER(NULL) pick_slip_number
6486 , TO_NUMBER(NULL) cartonization_id
6487 , inventory_item_id
6488 , TO_NUMBER(NULL) move_order_line_id
6489 FROM mtl_cycle_count_entries
6490 WHERE entry_status_code IN(1, 3)
6491 AND NVL(export_flag, 2) = 2
6492 -- bug 3972076
6493 --AND NVL(TRUNC(count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
6494 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision) wdtv -- inlined wms_dispatchable_tasks_v, bug 2648133
6495 WHERE wdtv.locator_id = loc.inventory_location_id
6496 AND wdtv.organization_id = loc.organization_id
6497 AND wdtv.task_id = l_last_task_id
6498 AND wdtv.wms_task_type_id = l_last_task_type;
6499
6500 -- Added the previous line since the task_id in the view
6501 -- might not be unique since it is the transaction_temp_id
6502 -- if it comes from MMTT but the cycle_count_entry_id if
6503 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
6504 l_progress := '36';
6505 EXCEPTION
6506 WHEN OTHERS THEN
6507 -- locator definition descripency
6508 l_cur_x := 0;
6509 l_cur_y := 0;
6510 l_cur_z := 0;
6511 END;
6512 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
6513 IF l_last_task_type <> 3 THEN -- not cycle count task
6514 -- get the location from mtl_material_transactions
6515 BEGIN
6516 l_progress := '37';
6517
6518 -- use Nvl to make sure if coordinates not defined, use 0
6519 SELECT NVL(loc.x_coordinate, 0)
6520 , NVL(loc.y_coordinate, 0)
6521 , NVL(loc.z_coordinate, 0)
6522 INTO l_cur_x
6523 , l_cur_y
6524 , l_cur_z
6525 FROM mtl_item_locations loc, mtl_material_transactions mmt
6526 WHERE mmt.locator_id = loc.inventory_location_id
6527 AND mmt.organization_id = loc.organization_id
6528 AND mmt.transaction_set_id = l_last_task_id
6529 AND ROWNUM = 1;
6530
6531 l_progress := '38';
6532 EXCEPTION
6533 WHEN OTHERS THEN
6534 -- locator definition descripency
6535 l_cur_x := 0;
6536 l_cur_y := 0;
6537 l_cur_z := 0;
6538 END;
6539 ELSE -- l_last_task_type <> 3 (Cyclt Count task)
6540 -- get the location from mtl_cycle_count_entries
6541 BEGIN
6542 l_progress := '39';
6543
6544 -- use Nvl to make sure if coordinates not defined, use 0
6545 SELECT NVL(loc.x_coordinate, 0)
6546 , NVL(loc.y_coordinate, 0)
6547 , NVL(loc.z_coordinate, 0)
6548 INTO l_cur_x
6549 , l_cur_y
6550 , l_cur_z
6551 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
6552 WHERE mcce.locator_id = loc.inventory_location_id
6553 AND mcce.organization_id = loc.organization_id
6554 AND mcce.cycle_count_entry_id = l_last_task_id;
6555
6556 l_progress := '40';
6557 EXCEPTION
6558 WHEN OTHERS THEN -- adf
6559 -- locator definition descripency
6560 l_cur_x := 0;
6561 l_cur_y := 0;
6562 l_cur_z := 0;
6563 END;
6564 END IF; -- l_last_task_type <> 3
6565 END IF; -- l_last_task_is_drop <> TRUE
6566 ELSE -- there is not a previous task at all
6567 l_cur_x := 0;
6568 l_cur_y := 0;
6569 l_cur_z := 0;
6570 END IF; -- l_last_task_id <> -1
6571
6572 l_progress := '45';
6573
6574 -- Select the most optimal task
6575 -- first select eligible tasks according to employee sign on information
6576 -- order tasks by task priority, locator picking order and locator coordinates
6577 -- approximated to current locator
6578
6579 IF (l_debug = 1) THEN
6580 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
6581 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
6582 print_debug('p_cartonization_id => ' || p_cartonization_id, 4);
6583 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
6584 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
6585 print_debug('l_cur_x => ' || l_cur_x, 4);
6586 print_debug('l_cur_y => ' || l_cur_y, 4);
6587 print_debug('l_cur_z => ' || l_cur_z, 4);
6588 END IF;
6589
6590 -- open and fetch appropriate cursor
6591
6592 -- start bug 2832818
6593 LOOP -- added loop for detecting lock for a pick slip
6594 l_is_locked := FALSE;
6595 -- end bug 2832818
6596
6597 IF l_sequence_picks_across_waves = 2 THEN -- order across wave
6598 IF p_sign_on_zone IS NOT NULL THEN -- zone passed in
6599 IF l_is_express_pick <> 1 THEN -- not express pick
6600 IF (l_debug = 1) THEN
6601 print_debug('Opt task cursor: zone passed, order across wave, not express pick (110) ', 4);
6602 END IF;
6603
6604 OPEN l_curs_opt_task_110;
6605 FETCH l_curs_opt_task_110 INTO l_opt_task_id
6606 , l_opt_task_pick_slip
6607 , l_opt_task_type
6608 , l_task_priority
6609 , l_mo_header_id
6610 , l_sub_pick_order
6611 , l_loc_pick_order
6612 , l_x_coordinate
6613 , l_y_coordinate
6614 , l_z_coordinate;
6615 CLOSE l_curs_opt_task_110;
6616 ELSE -- express pick
6617 IF (l_debug = 1) THEN
6618 print_debug('Opt task cursor: zone passed, order across wave, express pick (111)', 4);
6619 END IF;
6620
6621 OPEN l_curs_opt_task_111;
6622 FETCH l_curs_opt_task_111 INTO l_opt_task_id
6623 , l_opt_task_pick_slip
6624 , l_opt_task_type
6625 , l_task_priority
6626 , l_mo_header_id
6627 , l_sub_pick_order
6628 , l_loc_pick_order
6629 , l_x_coordinate
6630 , l_y_coordinate
6631 , l_z_coordinate;
6632 CLOSE l_curs_opt_task_111;
6633 END IF;
6634 ELSE -- zone NOT passed in
6635 IF l_is_express_pick <> 1 THEN -- not express pick
6636 IF (l_debug = 1) THEN
6637 print_debug('Opt task cursor: zone NOT passed, order across wave, NOT express pick (010) ', 4);
6638 END IF;
6639
6640 OPEN l_curs_opt_task_010;
6641 FETCH l_curs_opt_task_010 INTO l_opt_task_id
6642 , l_opt_task_pick_slip
6643 , l_opt_task_type
6644 , l_task_priority
6645 , l_mo_header_id
6646 , l_sub_pick_order
6647 , l_loc_pick_order
6648 , l_x_coordinate
6649 , l_y_coordinate
6650 , l_z_coordinate;
6651 CLOSE l_curs_opt_task_010;
6652 ELSE -- express pick
6653 IF (l_debug = 1) THEN
6654 print_debug('Opt task cursor: zone NOT passed, order across wave, express pick (011) ', 4);
6655 END IF;
6656
6657 OPEN l_curs_opt_task_011;
6658 FETCH l_curs_opt_task_011 INTO l_opt_task_id
6659 , l_opt_task_pick_slip
6660 , l_opt_task_type
6661 , l_task_priority
6662 , l_mo_header_id
6663 , l_sub_pick_order
6664 , l_loc_pick_order
6665 , l_x_coordinate
6666 , l_y_coordinate
6667 , l_z_coordinate;
6668 CLOSE l_curs_opt_task_011;
6669 END IF;
6670 END IF;
6671 ELSE -- NOT order across wave
6672 IF p_sign_on_zone IS NOT NULL THEN -- zone passed in
6673 IF l_is_express_pick <> 1 THEN -- not express pick
6674 IF (l_debug = 1) THEN
6675 print_debug('Opt task cursor: zone passed, NOT order across wave, NOT express pick (100) ', 4);
6676 END IF;
6677
6678 OPEN l_curs_opt_task_100;
6679 FETCH l_curs_opt_task_100 INTO l_opt_task_id
6680 , l_opt_task_pick_slip
6681 , l_opt_task_type
6682 , l_task_priority
6683 , l_mo_header_id
6684 , l_sub_pick_order
6685 , l_loc_pick_order
6686 , l_x_coordinate
6687 , l_y_coordinate
6688 , l_z_coordinate;
6689 CLOSE l_curs_opt_task_100;
6690 ELSE -- express pick
6691 IF (l_debug = 1) THEN
6692 print_debug('Opt task cursor: zone passed, NOT order across wave, express pick (101) ', 4);
6693 END IF;
6694
6695 OPEN l_curs_opt_task_101;
6696 FETCH l_curs_opt_task_101 INTO l_opt_task_id
6697 , l_opt_task_pick_slip
6698 , l_opt_task_type
6699 , l_task_priority
6700 , l_mo_header_id
6701 , l_sub_pick_order
6702 , l_loc_pick_order
6703 , l_x_coordinate
6704 , l_y_coordinate
6705 , l_z_coordinate;
6706 CLOSE l_curs_opt_task_101;
6707 END IF;
6708 ELSE -- zone NOT passed in
6709 IF l_is_express_pick <> 1 THEN -- not express pick
6710 IF (l_debug = 1) THEN
6711 print_debug('Opt task cursor: zone NOT passed, NOT order across wave, NOT express pick (000) ', 4);
6712 END IF;
6713
6714 OPEN l_curs_opt_task_000;
6715 FETCH l_curs_opt_task_000 INTO l_opt_task_id
6716 , l_opt_task_pick_slip
6717 , l_opt_task_type
6718 , l_task_priority
6719 , l_mo_header_id
6720 , l_sub_pick_order
6721 , l_loc_pick_order
6722 , l_x_coordinate
6723 , l_y_coordinate
6724 , l_z_coordinate;
6725 CLOSE l_curs_opt_task_000;
6726 ELSE -- express pick
6727 IF (l_debug = 1) THEN
6728 print_debug('Opt task cursor: zone NOT passed, NOT order across wave, express pick (001) ', 4);
6729 END IF;
6730
6731 OPEN l_curs_opt_task_001;
6732 FETCH l_curs_opt_task_001 INTO l_opt_task_id
6733 , l_opt_task_pick_slip
6734 , l_opt_task_type
6735 , l_task_priority
6736 , l_mo_header_id
6737 , l_sub_pick_order
6738 , l_loc_pick_order
6739 , l_x_coordinate
6740 , l_y_coordinate
6741 , l_z_coordinate;
6742 CLOSE l_curs_opt_task_001;
6743 END IF;
6744 END IF;
6745 END IF;
6746
6747 -- start bug fix 2832818
6748 IF l_opt_task_pick_slip IS NOT NULL THEN
6749
6750 IF l_debug = 1 THEN
6751 print_debug('Check pick_slip_number'|| l_opt_task_pick_slip || ' for locking.', 4);
6752 END IF;
6753
6754 BEGIN
6755 OPEN c_lock_check(l_opt_task_pick_slip);
6756 CLOSE c_lock_check;
6757 EXCEPTION
6758 WHEN OTHERS THEN
6759 IF SQLCODE = -54 THEN -- resource busy and acquire with NOWAIT specified
6760 l_is_locked := TRUE;
6761
6762 IF l_debug = 1 THEN
6763 print_debug('pick_slip_number ' || l_opt_task_pick_slip ||' is locked by other user. ', 4);
6764 END IF;
6765
6766 ELSE
6767 l_is_locked := FALSE;
6768
6769 END IF;
6770
6771 IF c_lock_check%isopen THEN
6772 CLOSE c_lock_check;
6773 END IF;
6774 END;
6775 END IF;
6776
6777 IF l_is_locked = TRUE THEN
6778 print_debug('Continue looking for most optimal task since there is a lock for this pick slip.', 4);
6779
6780 ELSE
6781 print_debug('There is no lock, got the most optimal task.', 4);
6782
6783 EXIT;
6784 END IF;
6785
6786
6787 END LOOP;
6788
6789 -- End bug fix 2832818
6790
6791 IF l_opt_task_id IS NULL THEN
6792 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
6793 fnd_msg_pub.ADD;
6794
6795 IF (l_debug = 1) THEN
6796 print_debug('dispatch_task - No eligible picking tasks ', 4);
6797 END IF;
6798
6799 RAISE fnd_api.g_exc_error;
6800 END IF;
6801
6802 IF l_sequence_picks_across_waves = 2 THEN
6803 IF l_is_express_pick <> 1 THEN
6804 OPEN l_curs_ordered_tasks(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
6805 ELSE
6806 OPEN l_curs_ordered_tasks_exp(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
6807 END IF;
6808 ELSE
6809 IF l_is_express_pick <> 1 THEN
6810 OPEN l_curs_ordered_tasks_aw(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
6811 ELSE
6812 OPEN l_curs_ordered_tasks_aw_exp(l_opt_task_pick_slip, l_opt_task_id, l_opt_task_type);
6813 END IF;
6814 END IF;
6815
6816 l_progress := '50';
6817 l_first_task_pick_slip_number := -1;
6818 l_ordered_tasks_count := 0;
6819
6820 LOOP
6821 IF (l_debug = 1) THEN
6822 print_debug('Start looping through ordered tasks: ', 4);
6823 END IF;
6824
6825 l_opt_task_id := NULL;
6826 l_opt_task_pick_slip := NULL;
6827 -- l_opt_task_type := NULL;
6828 l_is_locked := FALSE;
6829 l_progress := '60';
6830
6831 IF l_sequence_picks_across_waves = 2 THEN
6832 IF l_is_express_pick <> 1 THEN
6833 FETCH l_curs_ordered_tasks INTO l_opt_task_id
6834 , l_opt_task_pick_slip
6835 , l_opt_task_type
6836 , l_task_priority
6837 , l_mo_header_id
6838 , l_sub_pick_order
6839 , l_loc_pick_order
6840 , l_x_coordinate
6841 , l_y_coordinate
6842 , l_z_coordinate;
6843 EXIT WHEN l_curs_ordered_tasks%NOTFOUND;
6844 ELSE
6845 FETCH l_curs_ordered_tasks_exp INTO l_opt_task_id
6846 , l_opt_task_pick_slip
6847 , l_opt_task_type
6848 , l_task_priority
6849 , l_mo_header_id
6850 , l_sub_pick_order
6851 , l_loc_pick_order
6852 , l_x_coordinate
6853 , l_y_coordinate
6854 , l_z_coordinate;
6855 EXIT WHEN l_curs_ordered_tasks_exp%NOTFOUND;
6856 END IF;
6857 ELSE
6858 IF l_is_express_pick <> 1 THEN -- bug 2648133
6859 FETCH l_curs_ordered_tasks_aw INTO l_opt_task_id
6860 , l_opt_task_pick_slip
6861 , l_opt_task_type
6862 , l_task_priority
6863 , l_mo_header_id
6864 , l_sub_pick_order
6865 , l_loc_pick_order
6866 , l_x_coordinate
6867 , l_y_coordinate
6868 , l_z_coordinate;
6869 EXIT WHEN l_curs_ordered_tasks_aw%NOTFOUND;
6870 ELSE
6871 FETCH l_curs_ordered_tasks_aw_exp INTO l_opt_task_id
6872 , l_opt_task_pick_slip
6873 , l_opt_task_type
6874 , l_task_priority
6875 , l_mo_header_id
6876 , l_sub_pick_order
6877 , l_loc_pick_order
6878 , l_x_coordinate
6879 , l_y_coordinate
6880 , l_z_coordinate;
6881 EXIT WHEN l_curs_ordered_tasks_aw_exp%NOTFOUND;
6882 END IF;
6883 END IF;
6884
6885 l_progress := '70';
6886
6887 IF (l_debug = 1) THEN
6888 print_debug('l_opt_task_id => ' || l_opt_task_id, 4);
6889 print_debug('l_opt_task_pick_slip => ' || l_opt_task_pick_slip, 4);
6890 print_debug('l_opt_task_type => ' || l_opt_task_type, 4);
6891 END IF;
6892
6893 -- bug 2648133
6894 /*
6895 IF l_is_express_pick = 1 THEN
6896
6897 IF wms_express_pick_task.is_express_pick_task_eligible(l_opt_task_id) <> 'S' THEN
6898 EXIT;
6899 END IF;
6900
6901 END IF;
6902 */
6903 IF l_ordered_tasks_count = 0 THEN -- first task
6904
6905 -- Test if this task is locked by any other user
6906 IF (l_opt_task_type <> 3) THEN
6907 -- Picking, Putaway, or Replenishment tasks
6908 IF l_opt_task_pick_slip IS NULL THEN -- bug 2832818
6909 BEGIN
6910 SELECT mmtt.transaction_temp_id
6911 INTO l_opt_task_id
6912 FROM mtl_material_transactions_temp mmtt
6913 WHERE mmtt.transaction_temp_id = l_opt_task_id
6914 FOR UPDATE NOWAIT;
6915 EXCEPTION
6916 WHEN OTHERS THEN
6917 IF (l_debug = 1) THEN
6918 print_debug('This task is locked by other user. ', 4);
6919 END IF;
6920
6921 l_is_locked := TRUE;
6922 END;
6923
6924 END IF; -- bug 2832818
6925
6926 ELSE
6927 -- Cycle counting tasks
6928 BEGIN
6929 SELECT mcce.cycle_count_entry_id
6930 INTO l_opt_task_id
6931 FROM mtl_cycle_count_entries mcce
6932 WHERE mcce.cycle_count_entry_id = l_opt_task_id
6933 FOR UPDATE NOWAIT;
6934 EXCEPTION
6935 WHEN OTHERS THEN
6936 IF (l_debug = 1) THEN
6937 print_debug('This task is locked by other user. ', 4);
6938 END IF;
6939
6940 l_is_locked := TRUE;
6941 END;
6942 END IF;
6943
6944 IF l_is_locked <> TRUE THEN
6945 l_ordered_tasks_count := l_ordered_tasks_count + 1;
6946 l_first_task_pick_slip_number := l_opt_task_pick_slip;
6947
6948 IF (l_debug = 1) THEN
6949 print_debug('This is the first task in this group. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
6950 END IF;
6951
6952 l_progress := '72';
6953
6954 INSERT INTO wms_ordered_tasks
6955 (
6956 task_id
6957 , wms_task_type
6958 , task_sequence_id
6959 )
6960 VALUES (
6961 l_opt_task_id
6962 , l_opt_task_type
6963 , l_ordered_tasks_count
6964 );
6965
6966 l_progress := '73';
6967 END IF;
6968 ELSIF l_first_task_pick_slip_number = l_opt_task_pick_slip
6969 AND l_first_task_pick_slip_number <> -1
6970 AND l_opt_task_pick_slip <> -1 THEN -- task with the same pick slip number
6971 -- Test if this task is locked by any other user
6972 IF (l_opt_task_type <> 3) THEN
6973 -- Picking, Putaway, or Replenishment tasks
6974 IF l_opt_task_pick_slip IS NULL THEN -- bug 2832818
6975 BEGIN
6976 SELECT mmtt.transaction_temp_id
6977 INTO l_opt_task_id
6978 FROM mtl_material_transactions_temp mmtt
6979 WHERE mmtt.transaction_temp_id = l_opt_task_id
6980 FOR UPDATE NOWAIT;
6981 EXCEPTION
6982 WHEN OTHERS THEN
6983 IF (l_debug = 1) THEN
6984 print_debug('This task is locked by other user. ', 4);
6985 END IF;
6986
6987 l_is_locked := TRUE;
6988 END;
6989 END IF; -- bug 2832818
6990
6991 ELSE
6992 -- Cycle counting tasks
6993 BEGIN
6994 SELECT mcce.cycle_count_entry_id
6995 INTO l_opt_task_id
6996 FROM mtl_cycle_count_entries mcce
6997 WHERE mcce.cycle_count_entry_id = l_opt_task_id
6998 FOR UPDATE NOWAIT;
6999 EXCEPTION
7000 WHEN OTHERS THEN
7001 IF (l_debug = 1) THEN
7002 print_debug('This task is locked by other user. ', 4);
7003 END IF;
7004
7005 l_is_locked := TRUE;
7006 END;
7007 END IF;
7008
7009 IF l_is_locked <> TRUE THEN
7010 l_ordered_tasks_count := l_ordered_tasks_count + 1;
7011
7012 IF (l_debug = 1) THEN
7013 print_debug('This task has the same pick slip number. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
7014 END IF;
7015
7016 l_progress := '74';
7017
7018 INSERT INTO wms_ordered_tasks
7019 (
7020 task_id
7021 , wms_task_type
7022 , task_sequence_id
7023 )
7024 VALUES (
7025 l_opt_task_id
7026 , l_opt_task_type
7027 , l_ordered_tasks_count
7028 );
7029
7030 l_progress := '75';
7031 END IF;
7032 END IF;
7033 END LOOP;
7034
7035 IF l_sequence_picks_across_waves = 2 THEN
7036 IF l_curs_ordered_tasks%ISOPEN THEN
7037 CLOSE l_curs_ordered_tasks;
7038 END IF;
7039
7040 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7041 CLOSE l_curs_ordered_tasks_exp;
7042 END IF;
7043 ELSE
7044 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7045 CLOSE l_curs_ordered_tasks_aw;
7046 END IF;
7047
7048 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7049 CLOSE l_curs_ordered_tasks_aw_exp;
7050 END IF;
7051 END IF;
7052
7053 IF (l_debug = 1) THEN
7054 print_debug('Total task dispatched: l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
7055 END IF;
7056
7057 IF l_ordered_tasks_count = 0 THEN
7058 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
7059 fnd_msg_pub.ADD;
7060
7061 IF (l_debug = 1) THEN
7062 print_debug('dispatch_task - No eligible picking tasks ', 4);
7063 END IF;
7064
7065 RAISE fnd_api.g_exc_error;
7066 END IF;
7067
7068 l_progress := '90';
7069 -- bug 2648133, inlined wms_dispatchable_tasks_v
7070 -- removed l_sql_stmt
7071
7072 l_progress := '100';
7073 END IF; -- end task type check if
7074
7075
7076 -- open reference cursor for this statement
7077
7078 IF (l_debug = 1) THEN
7079 print_debug('dispatch_task 120 - before opeing ref cursor ', 4);
7080 END IF;
7081
7082 l_progress := '110';
7083
7084 -- bug 2648133, changed to static SQL and query against base tables
7085
7086 IF l_opt_task_type <> 3 THEN -- non cycle counting tasks
7087 OPEN x_task_cur FOR
7088 SELECT mmtt.transaction_temp_id task_id
7089 , mmtt.subinventory_code ZONE
7090 , mmtt.locator_id locator_id
7091 , mmtt.revision revision
7092 , mmtt.transaction_uom transaction_uom
7093 , mmtt.transaction_quantity transaction_quantity
7094 , '' lot_number
7095 , mmtt.wms_task_type wms_task_type_id
7096 , mmtt.task_priority task_priority
7097 FROM mtl_material_transactions_temp mmtt, wms_ordered_tasks wot
7098 WHERE mmtt.wms_task_type IS NOT NULL
7099 AND mmtt.transaction_status = 2
7100 AND mmtt.transaction_temp_id = wot.task_id
7101 AND mmtt.transaction_temp_id > 0
7102 ORDER BY wot.task_sequence_id;
7103 ELSE -- cycle counting tasks
7104 OPEN x_task_cur FOR
7105 SELECT MIN(mcce.cycle_count_entry_id) task_id
7106 , mcce.subinventory ZONE
7107 , mcce.locator_id locator_id
7108 , mcce.revision revision
7109 , '' transaction_uom
7110 , TO_NUMBER(NULL) transaction_quantity
7111 , MIN(mcce.lot_number) lot_number
7112 , 3 wms_task_type_id
7113 , MIN(mcce.task_priority) task_priority
7114 FROM mtl_cycle_count_entries mcce, wms_ordered_tasks wot
7115 WHERE mcce.entry_status_code IN(1, 3)
7116 AND NVL(mcce.export_flag, 2) = 2
7117 -- bug 3972076
7118 --AND NVL(TRUNC(mcce.count_due_date, 'DD'), TRUNC(SYSDATE, 'DD')) >= TRUNC(SYSDATE, 'DD')
7119 AND mcce.cycle_count_entry_id = wot.task_id
7120 GROUP BY mcce.cycle_count_header_id, mcce.organization_id, mcce.subinventory, mcce.locator_id, mcce.inventory_item_id
7121 , mcce.revision
7122 ORDER BY MIN(wot.task_sequence_id);
7123 END IF;
7124
7125 l_progress := '120';
7126 EXCEPTION
7127 WHEN fnd_api.g_exc_error THEN
7128 x_return_status := fnd_api.g_ret_sts_error;
7129
7130 IF l_curs_ordered_tasks%ISOPEN THEN
7131 CLOSE l_curs_ordered_tasks;
7132 END IF;
7133
7134 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7135 CLOSE l_curs_ordered_tasks_aw;
7136 END IF;
7137
7138 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7139 CLOSE l_curs_ordered_tasks_exp;
7140 END IF;
7141
7142 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7143 CLOSE l_curs_ordered_tasks_aw_exp;
7144 END IF;
7145
7146 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7147
7148 IF (l_debug = 1) THEN
7149 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7150 END IF;
7151 WHEN fnd_api.g_exc_unexpected_error THEN
7152 x_return_status := fnd_api.g_ret_sts_unexp_error;
7153
7154 IF l_curs_ordered_tasks%ISOPEN THEN
7155 CLOSE l_curs_ordered_tasks;
7156 END IF;
7157
7158 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7159 CLOSE l_curs_ordered_tasks_aw;
7160 END IF;
7161
7162 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7163 CLOSE l_curs_ordered_tasks_exp;
7164 END IF;
7165
7166 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7167 CLOSE l_curs_ordered_tasks_aw_exp;
7168 END IF;
7169
7170 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7171
7172 IF (l_debug = 1) THEN
7173 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7174 END IF;
7175 WHEN OTHERS THEN
7176 x_return_status := fnd_api.g_ret_sts_unexp_error;
7177
7178 IF l_curs_ordered_tasks%ISOPEN THEN
7179 CLOSE l_curs_ordered_tasks;
7180 END IF;
7181
7182 IF l_curs_ordered_tasks_aw%ISOPEN THEN
7183 CLOSE l_curs_ordered_tasks_aw;
7184 END IF;
7185
7186 IF l_curs_ordered_tasks_exp%ISOPEN THEN -- bug 2648133
7187 CLOSE l_curs_ordered_tasks_exp;
7188 END IF;
7189
7190 IF l_curs_ordered_tasks_aw_exp%ISOPEN THEN
7191 CLOSE l_curs_ordered_tasks_aw_exp;
7192 END IF;
7193
7194 IF SQLCODE IS NOT NULL THEN
7195 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
7196 END IF;
7197
7198 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7199
7200 IF (l_debug = 1) THEN
7201 print_debug('dispatch_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7202 END IF;
7203 END dispatch_task;
7204
7205 -- CP Enhancements
7206 -- This Method has been over-ridden for implementing the cluster picking task dispatch logic.
7207 PROCEDURE dispatch_task(
7208 p_api_version IN NUMBER
7209 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
7210 , p_commit IN VARCHAR2 := fnd_api.g_false
7211 , p_sign_on_emp_id IN NUMBER
7212 , p_sign_on_org_id IN NUMBER
7213 , p_sign_on_zone IN VARCHAR2 := NULL
7214 , p_sign_on_equipment_id IN NUMBER := NULL -- specific equip id, NULL or -999. -999 stands for none
7215 , p_sign_on_equipment_srl IN VARCHAR2 := NULL -- same as above
7216 , p_task_type IN VARCHAR2 -- 'PICKING' or 'ALL'
7217 , p_task_filter IN VARCHAR2 := NULL
7218 , p_cartonization_id IN NUMBER := NULL
7219 , x_task_cur OUT NOCOPY task_rec_cur_tp
7220 , x_return_status OUT NOCOPY VARCHAR2
7221 , x_msg_count OUT NOCOPY NUMBER
7222 , x_msg_data OUT NOCOPY VARCHAR2
7223 , p_max_clusters IN NUMBER := 0
7224 , x_deliveries_list OUT NOCOPY VARCHAR2
7225 , x_cartons_list OUT NOCOPY VARCHAR2
7226 ) IS
7227 l_cur_x NUMBER;
7228 l_cur_y NUMBER;
7229 l_cur_z NUMBER;
7230 l_is_locked BOOLEAN := FALSE;
7231 l_sys_task_type NUMBER;
7232 l_is_express_pick NUMBER := 0; -- 1 for express pick, 0 not
7233 l_sign_on_equipment_id NUMBER;
7234 l_sign_on_equipment_srl VARCHAR2(30);
7235 l_equipment_id_str VARCHAR2(30);
7236 l_last_loaded_time DATE;
7237 l_last_loaded_task_id NUMBER;
7238 l_last_loaded_task_type NUMBER;
7239 l_last_dropoff_time DATE;
7240 l_last_dropoff_task_id NUMBER;
7241 l_last_dropoff_task_type NUMBER;
7242 l_last_task_type NUMBER;
7243 l_last_task_is_drop BOOLEAN := FALSE;
7244 l_last_task_id NUMBER;
7245 l_ordered_tasks_count NUMBER;
7246 --l_first_task_pick_slip_number NUMBER;
7247
7248 l_api_name CONSTANT VARCHAR2(30) := 'dispatch_task';
7249 l_api_version CONSTANT NUMBER := 1.0;
7250 l_progress VARCHAR2(10);
7251 l_cluster_count NUMBER := 0;
7252
7253 -- the following is to used by task_filter
7254 l_so_allowed NUMBER := 0;
7255 l_io_allowed NUMBER := 0;
7256 l_wip_allowed NUMBER := 0;
7257
7258
7259 TYPE cluster_rec IS RECORD(
7260 cluster_id NUMBER
7261 , cluster_type VARCHAR2(1)
7262 );
7263
7264 TYPE cluster_tab IS TABLE OF cluster_rec
7265 INDEX BY BINARY_INTEGER;
7266
7267 cluster_table cluster_tab;
7268
7269 TYPE numtab IS TABLE OF NUMBER;
7270
7271 TYPE chrtab IS TABLE OF VARCHAR2(1);
7272
7273 TYPE loctab IS TABLE OF VARCHAR2(1000);
7274
7275 TYPE subtab IS TABLE OF VARCHAR2(10);
7276 TYPE datetab IS TABLE OF DATE;
7277
7278 idx NUMBER := 0;
7279 -- This variable will give the bulk collect limit. currenlty it is hardcoded
7280 -- This can be changed in future to get from a profile.
7281 blk_limit NUMBER := 200;
7282 t_opt_task_id numtab;
7283 t_carton_grouping_id numtab;
7284 t_opt_task_type numtab;
7285 l_cluster_exists BOOLEAN := FALSE;
7286 t_cluster_id numtab;
7287 t_cluster_type chrtab;
7288 t_task_priority numtab;
7289 t_sub_code subtab;
7290 t_sub_picking_order numtab;
7291 t_loc_picking_order numtab;
7292 t_xyz_distance numtab;
7293 t_loc_concat_segs loctab;
7294 t_task_status numtab;
7295 t_batch_id numtab;
7296 l_deliveries_list VARCHAR2(32000) := NULL;
7297 l_cartons_list VARCHAR2(32000) := NULL;
7298
7299 l_sequence_picks_across_waves number := 2;
7300 t_effective_start_date datetab;
7301 t_effective_end_date datetab;
7302 t_person_resource_id numtab;
7303 t_machine_resource_id numtab;
7304
7305
7306
7307
7308 CURSOR l_cp_curs_ordered_tasks IS
7309 SELECT DISTINCT wdtv.task_id task_id1
7310 , mol.carton_grouping_id
7311 , wdtv.wms_task_type_id
7312 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
7313 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
7314 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7315 , sub.secondary_inventory_name sub_secondary_inventory_name
7316 , sub.picking_order sub_picking_order
7317 , loc.picking_order loc_picking_order
7318 , (
7319 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7320 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7321 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7322 ) xyz_distance
7323 , loc.concatenated_segments loc_concat_segs
7324 FROM --wms_dispatchable_tasks_v wdtv,
7325 (SELECT transaction_temp_id task_id
7326 , standard_operation_id user_task_type_id
7327 , wms_task_type wms_task_type_id
7328 , organization_id organization_id
7329 , subinventory_code ZONE
7330 , locator_id locator_id
7331 , task_priority task_priority
7332 , revision revision
7333 , lot_number lot_number
7334 , transaction_uom transaction_uom
7335 , transaction_quantity transaction_quantity
7336 , pick_rule_id pick_rule_id
7337 , pick_slip_number pick_slip_number
7338 , cartonization_id cartonization_id
7339 , inventory_item_id
7340 , move_order_line_id
7341 FROM mtl_material_transactions_temp
7342 WHERE wms_task_type IS NOT NULL
7343 AND transaction_status = 2
7344 AND(
7345 wms_task_status IS NULL
7346 OR wms_task_status = 1
7347 ) --Added for task planning WB. bug#2651318
7348 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7349 /*UNION ALL
7350 SELECT MIN(cycle_count_entry_id) task_id,
7351 MIN(standard_operation_id) user_task_type_id,
7352 3 wms_task_type_id,
7353 organization_id organization_id,
7354 subinventory zone,
7355 locator_id locator_id,
7356 MIN(task_priority) task_priority,
7357 revision revision,
7358 MIN(lot_number) lot_number,
7359 '' transaction_uom,
7360 To_number(NULL) transaction_quantity,
7361 To_number(NULL) pick_rule_id,
7362 To_number(NULL) pick_slip_number,
7363 To_number(NULL) cartonization_id,
7364 inventory_item_id,
7365 To_number(NULL) move_order_line_id
7366 FROM mtl_cycle_count_entries
7367 WHERE entry_status_code IN (1,3)
7368 AND NVL(export_flag, 2) = 2
7369 -- bug 3972076
7370 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7371 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7372 */
7373 ) wdtv
7374 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7375 --wms_person_resource_utt_v v,
7376 (SELECT utt_emp.standard_operation_id standard_operation_id
7377 , utt_emp.resource_id ROLE
7378 , utt_eqp.resource_id equipment
7379 , utt_emp.person_id emp_id
7380 , utt_eqp.inventory_item_id eqp_id
7381 , NULL eqp_srl /* removed for bug 2095237 */
7382 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7383 , x_utt_res1.resource_id resource_id
7384 , x_emp_r.person_id
7385 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7386 WHERE x_utt_res1.resource_id = r1.resource_id
7387 AND r1.resource_type = 2
7388 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7389 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7390 , x_utt_res2.resource_id resource_id
7391 , x_eqp_r.inventory_item_id inventory_item_id
7392 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7393 WHERE x_utt_res2.resource_id = r2.resource_id
7394 AND r2.resource_type = 1
7395 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7396 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7397 , -- inlined wms_person_resource_utt_v, bug 2648133
7398 mtl_item_locations_kfv loc
7399 , --changed to kfv bug#2742611
7400 mtl_secondary_inventories sub
7401 , mtl_txn_request_lines mol
7402 , mtl_txn_request_headers moh
7403 , -- mtl_system_items msi -- bug 2648133
7404 wsh_delivery_details_ob_grp_v wdd
7405 , -- added
7406 wsh_delivery_assignments_v wda --added
7407 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7408 AND wdtv.organization_id = p_sign_on_org_id
7409 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7410 AND mol.header_id = moh.header_id
7411 AND moh.move_order_type = 3 -- only pick wave move orders are considered
7412 AND wdtv.user_task_type_id =
7413 v.standard_operation_id -- join task to resource view, check if user defined task type match
7414 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7415 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
7416 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7417 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7418 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7419 AND wdtv.locator_id = loc.inventory_location_id(+)
7420 AND wdtv.ZONE = sub.secondary_inventory_name
7421 AND wdtv.organization_id = sub.organization_id
7422 AND wdtv.move_order_line_id = mol.line_id
7423 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7424 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7425 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7426 (
7427 SELECT NULL
7428 FROM mtl_material_transactions_temp mmtt
7429 WHERE mmtt.transaction_temp_id = wdtv.task_id
7430 AND mmtt.parent_line_id IS NOT NULL
7431 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7432 AND NOT EXISTS -- exclude tasks already dispatched
7433 (SELECT NULL
7434 FROM wms_dispatched_tasks wdt1
7435 WHERE wdt1.transaction_temp_id = wdtv.task_id
7436 AND wdt1.task_type = wdtv.wms_task_type_id)
7437 -- Join with delivery details
7438 AND(wdd.move_order_line_id = wdtv.move_order_line_id
7439 AND wdd.delivery_detail_id = wda.delivery_detail_id)
7440 --******************
7441 AND wdtv.task_id NOT IN -- excluded skipped tasks
7442 (
7443 SELECT wdtv.task_id
7444 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7445 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7446 AND wste.task_id = wdtv.task_id
7447 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7448 AND wste.organization_id = mp.organization_id)
7449 --J Addition
7450 AND wdtv.ZONE not in (
7451 SELECT wd.subinventory_code
7452 FROM wms_devices_b wd
7453 , wms_bus_event_devices wbed
7454 WHERE 1 = 1
7455 and wd.device_id = wbed.device_id
7456 AND wbed.organization_id = wd.organization_id
7457 AND wd.enabled_flag = 'Y'
7458 AND wbed.enabled_flag = 'Y'
7459 AND wbed.business_event_id = 10
7460 AND wd.subinventory_code IS NOT NULL
7461 AND wd.force_sign_on_flag = 'Y'
7462 AND wd.device_id NOT IN (SELECT device_id
7463 FROM wms_device_assignment_temp
7464 WHERE employee_id = p_sign_on_emp_id)
7465 )
7466
7467 --*****************
7468 UNION ALL
7469 -- This will select the WIP Jobs alone
7470 SELECT wdtv.task_id task_id1
7471 , mol.carton_grouping_id
7472 , wdtv.wms_task_type_id
7473 , mol.carton_grouping_id cluster_id
7474 , 'C' cluster_type
7475 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7476 , sub.secondary_inventory_name sub_secondary_inventory_name
7477 , sub.picking_order sub_picking_order
7478 , loc.picking_order loc_picking_order
7479 , (
7480 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7481 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7482 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7483 ) xyz_distance
7484 , loc.concatenated_segments loc_concat_segs
7485 FROM --wms_dispatchable_tasks_v wdtv,
7486 (SELECT transaction_temp_id task_id
7487 , standard_operation_id user_task_type_id
7488 , wms_task_type wms_task_type_id
7489 , organization_id organization_id
7490 , subinventory_code ZONE
7491 , locator_id locator_id
7492 , task_priority task_priority
7493 , revision revision
7494 , lot_number lot_number
7495 , transaction_uom transaction_uom
7496 , transaction_quantity transaction_quantity
7497 , pick_rule_id pick_rule_id
7498 , pick_slip_number pick_slip_number
7499 , cartonization_id cartonization_id
7500 , inventory_item_id
7501 , move_order_line_id
7502 FROM mtl_material_transactions_temp
7503 WHERE wms_task_type IS NOT NULL
7504 AND transaction_status = 2
7505 AND(
7506 wms_task_status IS NULL
7507 OR wms_task_status = 1
7508 ) --Added for task planning WB. bug#2651318
7509 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7510 /*UNION ALL
7511 SELECT MIN(cycle_count_entry_id) task_id,
7512 MIN(standard_operation_id) user_task_type_id,
7513 3 wms_task_type_id,
7514 organization_id organization_id,
7515 subinventory zone,
7516 locator_id locator_id,
7517 MIN(task_priority) task_priority,
7518 revision revision,
7519 MIN(lot_number) lot_number,
7520 '' transaction_uom,
7521 To_number(NULL) transaction_quantity,
7522 To_number(NULL) pick_rule_id,
7523 To_number(NULL) pick_slip_number,
7524 To_number(NULL) cartonization_id,
7525 inventory_item_id,
7526 To_number(NULL) move_order_line_id
7527 FROM mtl_cycle_count_entries
7528 WHERE entry_status_code IN (1,3)
7529 AND NVL(export_flag, 2) = 2
7530 -- bug 3972076
7531 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7532 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7533 */
7534 ) wdtv
7535 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7536 --wms_person_resource_utt_v v,
7537 (SELECT utt_emp.standard_operation_id standard_operation_id
7538 , utt_emp.resource_id ROLE
7539 , utt_eqp.resource_id equipment
7540 , utt_emp.person_id emp_id
7541 , utt_eqp.inventory_item_id eqp_id
7542 , NULL eqp_srl /* removed for bug 2095237 */
7543 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7544 , x_utt_res1.resource_id resource_id
7545 , x_emp_r.person_id
7546 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7547 WHERE x_utt_res1.resource_id = r1.resource_id
7548 AND r1.resource_type = 2
7549 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7550 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7551 , x_utt_res2.resource_id resource_id
7552 , x_eqp_r.inventory_item_id inventory_item_id
7553 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7554 WHERE x_utt_res2.resource_id = r2.resource_id
7555 AND r2.resource_type = 1
7556 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7557 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7558 , -- inlined wms_person_resource_utt_v, bug 2648133
7559 mtl_item_locations_kfv loc
7560 , --changed to kfv bug#2742611
7561 mtl_secondary_inventories sub
7562 , mtl_txn_request_lines mol
7563 , mtl_txn_request_headers moh
7564 -- mtl_system_items msi -- bug 2648133
7565 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7566 AND wdtv.organization_id = p_sign_on_org_id
7567 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7568 AND mol.header_id = moh.header_id
7569 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
7570 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
7571 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7572 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
7573 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7574 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7575 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7576 AND wdtv.locator_id = loc.inventory_location_id(+)
7577 AND wdtv.ZONE = sub.secondary_inventory_name
7578 AND wdtv.organization_id = sub.organization_id
7579 AND wdtv.move_order_line_id = mol.line_id
7580 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7581 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7582 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7583 (
7584 SELECT NULL
7585 FROM mtl_material_transactions_temp mmtt
7586 WHERE mmtt.transaction_temp_id = wdtv.task_id
7587 AND mmtt.parent_line_id IS NOT NULL
7588 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7589 AND NOT EXISTS -- exclude tasks already dispatched
7590 (SELECT NULL
7591 FROM wms_dispatched_tasks wdt1
7592 WHERE wdt1.transaction_temp_id = wdtv.task_id
7593 AND wdt1.task_type = wdtv.wms_task_type_id)
7594 --******************
7595 AND wdtv.task_id NOT IN -- excluded skipped tasks
7596 (
7597 SELECT wdtv.task_id
7598 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7599 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7600 AND wste.task_id = wdtv.task_id
7601 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7602 AND wste.organization_id = mp.organization_id)
7603 --*****************
7604 --J Addition
7605 AND wdtv.ZONE not in (
7606 SELECT wd.subinventory_code
7607 FROM wms_devices_b wd
7608 , wms_bus_event_devices wbed
7609 WHERE 1 = 1
7610 and wd.device_id = wbed.device_id
7611 AND wbed.organization_id = wd.organization_id
7612 AND wd.enabled_flag = 'Y'
7613 AND wbed.enabled_flag = 'Y'
7614 AND wbed.business_event_id = 10
7615 AND wd.subinventory_code IS NOT NULL
7616 AND wd.force_sign_on_flag = 'Y'
7617 AND wd.device_id NOT IN (SELECT device_id
7618 FROM wms_device_assignment_temp
7619 WHERE employee_id = p_sign_on_emp_id)
7620 )
7621 ORDER BY wdtv_task_priority
7622 , sub_picking_order
7623 , sub_secondary_inventory_name
7624 , loc_picking_order
7625 , xyz_distance
7626 , loc_concat_segs
7627 , task_id1;
7628
7629 CURSOR l_cp_curs_ordered_tasks_no_sub IS -- bug 2648133
7630 SELECT DISTINCT wdtv.task_id task_id1
7631 , mol.carton_grouping_id
7632 , wdtv.wms_task_type_id
7633 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
7634 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
7635 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7636 , sub.secondary_inventory_name sub_secondary_inventory_name
7637 , sub.picking_order sub_picking_order
7638 , loc.picking_order loc_picking_order
7639 , (
7640 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7641 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7642 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7643 ) xyz_distance
7644 , loc.concatenated_segments loc_concat_segs
7645 FROM --wms_dispatchable_tasks_v wdtv,
7646 (SELECT transaction_temp_id task_id
7647 , standard_operation_id user_task_type_id
7648 , wms_task_type wms_task_type_id
7649 , organization_id organization_id
7650 , subinventory_code ZONE
7651 , locator_id locator_id
7652 , task_priority task_priority
7653 , revision revision
7654 , lot_number lot_number
7655 , transaction_uom transaction_uom
7656 , transaction_quantity transaction_quantity
7657 , pick_rule_id pick_rule_id
7658 , pick_slip_number pick_slip_number
7659 , cartonization_id cartonization_id
7660 , inventory_item_id
7661 , move_order_line_id
7662 FROM mtl_material_transactions_temp
7663 WHERE wms_task_type IS NOT NULL
7664 AND transaction_status = 2
7665 AND(
7666 wms_task_status IS NULL
7667 OR wms_task_status = 1
7668 ) --Added for task planning WB. bug#2651318
7669 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7670 /*UNION ALL
7671 SELECT MIN(cycle_count_entry_id) task_id,
7672 MIN(standard_operation_id) user_task_type_id,
7673 3 wms_task_type_id,
7674 organization_id organization_id,
7675 subinventory zone,
7676 locator_id locator_id,
7677 MIN(task_priority) task_priority,
7678 revision revision,
7679 MIN(lot_number) lot_number,
7680 '' transaction_uom,
7681 To_number(NULL) transaction_quantity,
7682 To_number(NULL) pick_rule_id,
7683 To_number(NULL) pick_slip_number,
7684 To_number(NULL) cartonization_id,
7685 inventory_item_id,
7686 To_number(NULL) move_order_line_id
7687 FROM mtl_cycle_count_entries
7688 WHERE entry_status_code IN (1,3)
7689 AND NVL(export_flag, 2) = 2
7690 -- bug 3972076
7691 -- AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7692 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7693 */
7694 ) wdtv
7695 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7696 --wms_person_resource_utt_v v,
7697 (SELECT utt_emp.standard_operation_id standard_operation_id
7698 , utt_emp.resource_id ROLE
7699 , utt_eqp.resource_id equipment
7700 , utt_emp.person_id emp_id
7701 , utt_eqp.inventory_item_id eqp_id
7702 , NULL eqp_srl /* removed for bug 2095237 */
7703 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7704 , x_utt_res1.resource_id resource_id
7705 , x_emp_r.person_id
7706 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7707 WHERE x_utt_res1.resource_id = r1.resource_id
7708 AND r1.resource_type = 2
7709 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7710 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7711 , x_utt_res2.resource_id resource_id
7712 , x_eqp_r.inventory_item_id inventory_item_id
7713 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7714 WHERE x_utt_res2.resource_id = r2.resource_id
7715 AND r2.resource_type = 1
7716 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7717 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7718 , -- inlined wms_person_resource_utt_v, bug 2648133
7719 mtl_item_locations_kfv loc
7720 , --changed to kfv bug#2742611
7721 mtl_secondary_inventories sub
7722 , mtl_txn_request_lines mol
7723 , mtl_txn_request_headers moh
7724 , -- mtl_system_items msi -- bug 2648133
7725 wsh_delivery_details_ob_grp_v wdd
7726 , -- added
7727 wsh_delivery_assignments_v wda --added
7728 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7729 AND wdtv.organization_id = p_sign_on_org_id
7730 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7731 AND mol.header_id = moh.header_id
7732 AND moh.move_order_type = 3 -- only pick wave move orders are considered
7733 AND wdtv.user_task_type_id =
7734 v.standard_operation_id -- join task to resource view, check if user defined task type match
7735 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7736 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7737 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7738 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7739 AND wdtv.locator_id = loc.inventory_location_id(+)
7740 AND wdtv.ZONE = sub.secondary_inventory_name
7741 AND wdtv.organization_id = sub.organization_id
7742 AND wdtv.move_order_line_id = mol.line_id
7743 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7744 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7745 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7746 (
7747 SELECT NULL
7748 FROM mtl_material_transactions_temp mmtt
7749 WHERE mmtt.transaction_temp_id = wdtv.task_id
7750 AND mmtt.parent_line_id IS NOT NULL
7751 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7752 AND NOT EXISTS -- exclude tasks already dispatched
7753 (SELECT NULL
7754 FROM wms_dispatched_tasks wdt1
7755 WHERE wdt1.transaction_temp_id = wdtv.task_id
7756 AND wdt1.task_type = wdtv.wms_task_type_id)
7757 -- Join with delivery details
7758 AND(wdd.move_order_line_id = wdtv.move_order_line_id
7759 AND wdd.delivery_detail_id = wda.delivery_detail_id)
7760 --******************
7761 AND wdtv.task_id NOT IN -- excluded skipped tasks
7762 (
7763 SELECT wdtv.task_id
7764 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7765 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7766 AND wste.task_id = wdtv.task_id
7767 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7768 AND wste.organization_id = mp.organization_id)
7769 --*****************
7770 --J Addition
7771 AND wdtv.ZONE not in (
7772 SELECT wd.subinventory_code
7773 FROM wms_devices_b wd
7774 , wms_bus_event_devices wbed
7775 WHERE 1 = 1
7776 and wd.device_id = wbed.device_id
7777 AND wbed.organization_id = wd.organization_id
7778 AND wd.enabled_flag = 'Y'
7779 AND wbed.enabled_flag = 'Y'
7780 AND wbed.business_event_id = 10
7781 AND wd.subinventory_code IS NOT NULL
7782 AND wd.force_sign_on_flag = 'Y'
7783 AND wd.device_id NOT IN (SELECT device_id
7784 FROM wms_device_assignment_temp
7785 WHERE employee_id = p_sign_on_emp_id)
7786 )
7787
7788 UNION ALL
7789 -- This will select the WIP Jobs alone
7790 SELECT wdtv.task_id task_id1
7791 , mol.carton_grouping_id
7792 , wdtv.wms_task_type_id
7793 , mol.carton_grouping_id cluster_id
7794 , 'C' cluster_type
7795 , nvl(wdtv.task_priority, 0) wdtv_task_priority
7796 , sub.secondary_inventory_name sub_secondary_inventory_name
7797 , sub.picking_order sub_picking_order
7798 , loc.picking_order loc_picking_order
7799 , (
7800 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7801 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7802 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7803 ) xyz_distance
7804 , loc.concatenated_segments loc_concat_segs
7805 FROM --wms_dispatchable_tasks_v wdtv,
7806 (SELECT transaction_temp_id task_id
7807 , standard_operation_id user_task_type_id
7808 , wms_task_type wms_task_type_id
7809 , organization_id organization_id
7810 , subinventory_code ZONE
7811 , locator_id locator_id
7812 , task_priority task_priority
7813 , revision revision
7814 , lot_number lot_number
7815 , transaction_uom transaction_uom
7816 , transaction_quantity transaction_quantity
7817 , pick_rule_id pick_rule_id
7818 , pick_slip_number pick_slip_number
7819 , cartonization_id cartonization_id
7820 , inventory_item_id
7821 , move_order_line_id
7822 FROM mtl_material_transactions_temp
7823 WHERE wms_task_type IS NOT NULL
7824 AND transaction_status = 2
7825 AND(
7826 wms_task_status IS NULL
7827 OR wms_task_status = 1
7828 ) --Added for task planning WB. bug#2651318
7829 -- Commented out the following lines because we won't consider cycle counting taks for cluster pick
7830 /*UNION ALL
7831 SELECT MIN(cycle_count_entry_id) task_id,
7832 MIN(standard_operation_id) user_task_type_id,
7833 3 wms_task_type_id,
7834 organization_id organization_id,
7835 subinventory zone,
7836 locator_id locator_id,
7837 MIN(task_priority) task_priority,
7838 revision revision,
7839 MIN(lot_number) lot_number,
7840 '' transaction_uom,
7841 To_number(NULL) transaction_quantity,
7842 To_number(NULL) pick_rule_id,
7843 To_number(NULL) pick_slip_number,
7844 To_number(NULL) cartonization_id,
7845 inventory_item_id,
7846 To_number(NULL) move_order_line_id
7847 FROM mtl_cycle_count_entries
7848 WHERE entry_status_code IN (1,3)
7849 AND NVL(export_flag, 2) = 2
7850 -- bug 3972076
7851 --AND NVL(Trunc(count_due_date, 'DD'), Trunc(Sysdate, 'DD')) >= Trunc(Sysdate, 'DD')
7852 GROUP BY cycle_count_header_id, organization_id, subinventory, locator_id, inventory_item_id, revision
7853 */
7854 ) wdtv
7855 , -- inlined wms_dispatchable_tasks_v, bug 2648133
7856 --wms_person_resource_utt_v v,
7857 (SELECT utt_emp.standard_operation_id standard_operation_id
7858 , utt_emp.resource_id ROLE
7859 , utt_eqp.resource_id equipment
7860 , utt_emp.person_id emp_id
7861 , utt_eqp.inventory_item_id eqp_id
7862 , NULL eqp_srl /* removed for bug 2095237 */
7863 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
7864 , x_utt_res1.resource_id resource_id
7865 , x_emp_r.person_id
7866 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
7867 WHERE x_utt_res1.resource_id = r1.resource_id
7868 AND r1.resource_type = 2
7869 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
7870 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
7871 , x_utt_res2.resource_id resource_id
7872 , x_eqp_r.inventory_item_id inventory_item_id
7873 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
7874 WHERE x_utt_res2.resource_id = r2.resource_id
7875 AND r2.resource_type = 1
7876 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
7877 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
7878 , -- inlined wms_person_resource_utt_v, bug 2648133
7879 mtl_item_locations_kfv loc
7880 , --changed to kfv bug#2742611
7881 mtl_secondary_inventories sub
7882 , mtl_txn_request_lines mol
7883 , mtl_txn_request_headers moh
7884 -- mtl_system_items msi -- bug 2648133
7885 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
7886 AND wdtv.organization_id = p_sign_on_org_id
7887 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
7888 AND mol.header_id = moh.header_id
7889 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
7890 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
7891 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
7892 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
7893 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
7894 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
7895 AND wdtv.locator_id = loc.inventory_location_id(+)
7896 AND wdtv.ZONE = sub.secondary_inventory_name
7897 AND wdtv.organization_id = sub.organization_id
7898 AND wdtv.move_order_line_id = mol.line_id
7899 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
7900 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
7901 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
7902 (
7903 SELECT NULL
7904 FROM mtl_material_transactions_temp mmtt
7905 WHERE mmtt.transaction_temp_id = wdtv.task_id
7906 AND mmtt.parent_line_id IS NOT NULL
7907 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
7908 AND NOT EXISTS -- exclude tasks already dispatched
7909 (SELECT NULL
7910 FROM wms_dispatched_tasks wdt1
7911 WHERE wdt1.transaction_temp_id = wdtv.task_id
7912 AND wdt1.task_type = wdtv.wms_task_type_id)
7913 --******************
7914 AND wdtv.task_id NOT IN -- excluded skipped tasks
7915 (
7916 SELECT wdtv.task_id
7917 FROM wms_skip_task_exceptions wste, mtl_parameters mp
7918 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
7919 AND wste.task_id = wdtv.task_id
7920 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
7921 AND wste.organization_id = mp.organization_id)
7922 --*****************
7923 --J Addition
7924 AND wdtv.ZONE not in ( SELECT wd.subinventory_code
7925 FROM wms_devices_b wd
7926 , wms_bus_event_devices wbed
7927 WHERE 1 = 1
7928 and wd.device_id = wbed.device_id
7929 AND wbed.organization_id = wd.organization_id
7930 AND wd.enabled_flag = 'Y'
7931 AND wbed.enabled_flag = 'Y'
7932 AND wbed.business_event_id = 10
7933 AND wd.subinventory_code IS NOT NULL
7934 AND wd.force_sign_on_flag = 'Y'
7935 AND wd.device_id NOT IN (SELECT device_id
7936 FROM wms_device_assignment_temp
7937 WHERE employee_id = p_sign_on_emp_id)
7938 )
7939 ORDER BY wdtv_task_priority
7940 , sub_picking_order
7941 , sub_secondary_inventory_name
7942 , loc_picking_order
7943 , xyz_distance
7944 , loc_concat_segs
7945 , task_id1;
7946
7947 ------------- the following cursors will be used for patchset J cluster picking from APL
7948
7949 -- following cursor for SO and IO and sub entered -----
7950 CURSOR l_cp_ordered_tasks_SI IS
7951 SELECT DISTINCT
7952 qt.task_id task_id1
7953 , mol.carton_grouping_id
7954 , qt.wms_task_type_id
7955 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
7956 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
7957 , nvl(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
7958 , sub.secondary_inventory_name sub_secondary_inventory_name
7959 , sub.picking_order sub_picking_order
7960 , loc.picking_order loc_picking_order
7961 , (
7962 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
7963 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
7964 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
7965 ) xyz_distance
7966 , loc.concatenated_segments loc_concat_segs
7967 ,wdt.status task_status --bug 4310093
7968 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
7969 , wdt.effective_start_date
7970 , wdt.effective_end_date
7971 , wdt.person_resource_id
7972 , wdt.machine_resource_id
7973 FROM wms_dispatched_tasks wdt,
7974 (SELECT transaction_temp_id task_id
7975 , standard_operation_id user_task_type_id
7976 , wms_task_type wms_task_type_id
7977 , organization_id organization_id
7978 , subinventory_code ZONE
7979 , locator_id locator_id
7980 , task_priority task_priority
7981 , revision revision
7982 , lot_number lot_number
7983 , transaction_uom transaction_uom
7984 , transaction_quantity transaction_quantity
7985 , pick_rule_id pick_rule_id
7986 , pick_slip_number pick_slip_number
7987 , cartonization_id cartonization_id
7988 , inventory_item_id
7989 , move_order_line_id
7990 FROM mtl_material_transactions_temp
7991 WHERE wms_task_type IS NOT NULL
7992 AND transaction_status = 2
7993 AND Decode(transaction_source_type_id, 2, l_so_allowed,
7994 8, l_io_allowed) = 1 -- filter out the request so or io
7995 AND(
7996 wms_task_status IS NULL
7997 OR wms_task_status = 1
7998 ) --Added for task planning WB. bug#2651318
7999 ) qt
8000 , (SELECT
8001 bsor.standard_operation_id,
8002 bre.resource_id,
8003 bre.inventory_item_id equipment_id
8004 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8005 WHERE bsor.resource_id = bre.resource_id
8006 AND br.resource_type = 1
8007 AND bsor.resource_id = br.resource_id) e
8008 , mtl_item_locations_kfv loc
8009 , --changed to kfv bug#2742611
8010 mtl_secondary_inventories sub
8011 , mtl_txn_request_lines mol
8012 , mtl_txn_request_headers moh
8013 , -- mtl_system_items msi -- bug 2648133
8014 wsh_delivery_details_ob_grp_v wdd
8015 , -- added
8016 wsh_delivery_assignments_v wda --added
8017 WHERE wdt.transaction_temp_id = qt.task_id
8018 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8019 AND wdt.person_id = p_sign_on_emp_id
8020 AND wdt.organization_id = p_sign_on_org_id
8021 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
8022 AND mol.header_id = moh.header_id
8023 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8024 AND qt.user_task_type_id =
8025 e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8026 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8027 AND qt.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8028 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
8029 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8030 AND qt.organization_id = loc.organization_id
8031 AND qt.locator_id = loc.inventory_location_id
8032 AND qt.ZONE = sub.secondary_inventory_name
8033 AND qt.organization_id = sub.organization_id
8034 AND qt.move_order_line_id = mol.line_id
8035 -- Join with delivery details
8036 AND(wdd.move_order_line_id = qt.move_order_line_id
8037 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8038 UNION ALL
8039 SELECT DISTINCT wdtv.task_id task_id1
8040 , mol.carton_grouping_id
8041 , wdtv.wms_task_type_id
8042 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8043 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8044 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8045 , sub.secondary_inventory_name sub_secondary_inventory_name
8046 , sub.picking_order sub_picking_order
8047 , loc.picking_order loc_picking_order
8048 , (
8049 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8050 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8051 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8052 ) xyz_distance
8053 , loc.concatenated_segments loc_concat_segs
8054 ,1 task_status
8055 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8056 ,v.effective_start_date
8057 ,v.effective_end_date
8058 ,v.role person_resource_id
8059 ,v.equipment machine_resource_id
8060 FROM --wms_dispatchable_tasks_v wdtv,
8061 (SELECT transaction_temp_id task_id
8062 , standard_operation_id user_task_type_id
8063 , wms_task_type wms_task_type_id
8064 , organization_id organization_id
8065 , subinventory_code ZONE
8066 , locator_id locator_id
8067 , task_priority task_priority
8068 , revision revision
8069 , lot_number lot_number
8070 , transaction_uom transaction_uom
8071 , transaction_quantity transaction_quantity
8072 , pick_rule_id pick_rule_id
8073 , pick_slip_number pick_slip_number
8074 , cartonization_id cartonization_id
8075 , inventory_item_id
8076 , move_order_line_id
8077 FROM mtl_material_transactions_temp
8078 WHERE wms_task_type IS NOT NULL
8079 AND transaction_status = 2
8080 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8081 8, l_io_allowed) = 1 -- filter out the request so or io
8082 AND(
8083 wms_task_status IS NULL
8084 OR wms_task_status = 1
8085 ) --Added for task planning WB. bug#2651318
8086 ) wdtv
8087 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8088 --wms_person_resource_utt_v v,
8089 (SELECT utt_emp.standard_operation_id standard_operation_id
8090 , utt_emp.resource_id ROLE
8091 , utt_eqp.resource_id equipment
8092 , utt_emp.person_id emp_id
8093 , utt_eqp.inventory_item_id eqp_id
8094 , NULL eqp_srl /* removed for bug 2095237 */
8095 , utt_emp.effective_start_date
8096 , utt_emp.effective_end_date
8097 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8098 , x_utt_res1.resource_id resource_id
8099 , x_emp_r.person_id
8100 , x_emp_r.effective_start_date
8101 , x_emp_r.effective_end_date
8102 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8103 WHERE x_utt_res1.resource_id = r1.resource_id
8104 AND r1.resource_type = 2
8105 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8106 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8107 , x_utt_res2.resource_id resource_id
8108 , x_eqp_r.inventory_item_id inventory_item_id
8109 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8110 WHERE x_utt_res2.resource_id = r2.resource_id
8111 AND r2.resource_type = 1
8112 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8113 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8114 , -- inlined wms_person_resource_utt_v, bug 2648133
8115 mtl_item_locations_kfv loc
8116 , --changed to kfv bug#2742611
8117 mtl_secondary_inventories sub
8118 , mtl_txn_request_lines mol
8119 , mtl_txn_request_headers moh
8120 , -- mtl_system_items msi -- bug 2648133
8121 wsh_delivery_details_ob_grp_v wdd
8122 , -- added
8123 wsh_delivery_assignments_v wda --added
8124 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8125 AND wdtv.organization_id = p_sign_on_org_id
8126 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8127 AND mol.header_id = moh.header_id
8128 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8129 AND wdtv.user_task_type_id =
8130 v.standard_operation_id -- join task to resource view, check if user defined task type match
8131 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8132 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8133 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8134 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8135 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8136 AND wdtv.locator_id = loc.inventory_location_id(+)
8137 AND wdtv.ZONE = sub.secondary_inventory_name
8138 AND wdtv.organization_id = sub.organization_id
8139 AND wdtv.move_order_line_id = mol.line_id
8140 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8141 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8142 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8143 (
8144 SELECT NULL
8145 FROM mtl_material_transactions_temp mmtt
8146 WHERE mmtt.transaction_temp_id = wdtv.task_id
8147 AND mmtt.parent_line_id IS NOT NULL
8148 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8149 AND NOT EXISTS -- exclude tasks already dispatched
8150 (SELECT NULL
8151 FROM wms_dispatched_tasks wdt1
8152 WHERE wdt1.transaction_temp_id = wdtv.task_id
8153 AND wdt1.task_type = wdtv.wms_task_type_id)
8154 -- Join with delivery details
8155 AND(wdd.move_order_line_id = wdtv.move_order_line_id
8156 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8157 --******************
8158 AND wdtv.task_id NOT IN -- excluded skipped tasks
8159 (
8160 SELECT wdtv.task_id
8161 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8162 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8163 AND wste.task_id = wdtv.task_id
8164 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8165 AND wste.organization_id = mp.organization_id)
8166 --J Addition
8167 AND wdtv.ZONE not in (
8168 SELECT wd.subinventory_code
8169 FROM wms_devices_b wd
8170 , wms_bus_event_devices wbed
8171 WHERE 1 = 1
8172 and wd.device_id = wbed.device_id
8173 AND wbed.organization_id = wd.organization_id
8174 AND wd.enabled_flag = 'Y'
8175 AND wbed.enabled_flag = 'Y'
8176 AND wbed.business_event_id = 10
8177 AND wd.subinventory_code IS NOT NULL
8178 AND wd.force_sign_on_flag = 'Y'
8179 AND wd.device_id NOT IN (SELECT device_id
8180 FROM wms_device_assignment_temp
8181 WHERE employee_id = p_sign_on_emp_id)
8182 )
8183
8184 ORDER BY wdtv_task_priority DESC
8185 , batch_id
8186 , task_status DESC
8187 , sub_picking_order
8188 , loc_picking_order
8189 , xyz_distance
8190 , task_id1;
8191
8192 -------------------------
8193 -- following cursor for WIP and sub entered -----
8194 CURSOR l_cp_ordered_tasks_W IS
8195 SELECT DISTINCT
8196 wdtv.task_id task_id1
8197 , mol.carton_grouping_id
8198 , wdtv.wms_task_type_id
8199 , mol.carton_grouping_id cluster_id
8200 , 'C' cluster_type
8201 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8202 , sub.secondary_inventory_name sub_secondary_inventory_name
8203 , sub.picking_order sub_picking_order
8204 , loc.picking_order loc_picking_order
8205 , (
8206 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8207 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8208 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8209 ) xyz_distance
8210 , loc.concatenated_segments loc_concat_segs
8211 ,wdt.status task_status --bug 4310093
8212 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8213 , wdt.effective_start_date
8214 , wdt.effective_end_date
8215 , wdt.person_resource_id
8216 , wdt.machine_resource_id
8217 FROM wms_dispatched_tasks wdt,
8218 (SELECT transaction_temp_id task_id
8219 , standard_operation_id user_task_type_id
8220 , wms_task_type wms_task_type_id
8221 , organization_id organization_id
8222 , subinventory_code ZONE
8223 , locator_id locator_id
8224 , task_priority task_priority
8225 , revision revision
8226 , lot_number lot_number
8227 , transaction_uom transaction_uom
8228 , transaction_quantity transaction_quantity
8229 , pick_rule_id pick_rule_id
8230 , pick_slip_number pick_slip_number
8231 , cartonization_id cartonization_id
8232 , inventory_item_id
8233 , move_order_line_id
8234 FROM mtl_material_transactions_temp
8235 WHERE wms_task_type IS NOT NULL
8236 AND transaction_status = 2
8237 AND(
8238 wms_task_status IS NULL
8239 OR wms_task_status = 1
8240 ) --Added for task planning WB. bug#2651318
8241 ) wdtv
8242 , (SELECT
8243 bsor.standard_operation_id,
8244 bre.resource_id,
8245 bre.inventory_item_id equipment_id
8246 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8247 WHERE bsor.resource_id = bre.resource_id
8248 AND br.resource_type = 1
8249 AND bsor.resource_id = br.resource_id) e
8250 , mtl_item_locations_kfv loc
8251 , --changed to kfv bug#2742611
8252 mtl_secondary_inventories sub
8253 , mtl_txn_request_lines mol
8254 , mtl_txn_request_headers moh
8255 -- mtl_system_items msi -- bug 2648133
8256 WHERE wdt.transaction_temp_id = wdtv.task_id
8257 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8258 AND wdt.person_id = p_sign_on_emp_id
8259 AND wdt.organization_id = p_sign_on_org_id
8260 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8261 AND mol.header_id = moh.header_id
8262 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8263 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8264 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8265 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8266 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8267 AND wdtv.organization_id = loc.organization_id
8268 AND wdtv.locator_id = loc.inventory_location_id
8269 AND wdtv.ZONE = sub.secondary_inventory_name
8270 AND wdtv.organization_id = sub.organization_id
8271 AND wdtv.move_order_line_id = mol.line_id
8272 UNION ALL
8273 SELECT wdtv.task_id task_id1
8274 , mol.carton_grouping_id
8275 , wdtv.wms_task_type_id
8276 , mol.carton_grouping_id cluster_id
8277 , 'C' cluster_type
8278 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8279 , sub.secondary_inventory_name sub_secondary_inventory_name
8280 , sub.picking_order sub_picking_order
8281 , loc.picking_order loc_picking_order
8282 , (
8283 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8284 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8285 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8286 ) xyz_distance
8287 , loc.concatenated_segments loc_concat_segs
8288 ,1 task_status
8289 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8290 ,v.effective_start_date
8291 ,v.effective_end_date
8292 ,v.role person_resource_id
8293 ,v.equipment machine_resource_id
8294 FROM --wms_dispatchable_tasks_v wdtv,
8295 (SELECT transaction_temp_id task_id
8296 , standard_operation_id user_task_type_id
8297 , wms_task_type wms_task_type_id
8298 , organization_id organization_id
8299 , subinventory_code ZONE
8300 , locator_id locator_id
8301 , task_priority task_priority
8302 , revision revision
8303 , lot_number lot_number
8304 , transaction_uom transaction_uom
8305 , transaction_quantity transaction_quantity
8306 , pick_rule_id pick_rule_id
8307 , pick_slip_number pick_slip_number
8308 , cartonization_id cartonization_id
8309 , inventory_item_id
8310 , move_order_line_id
8311 FROM mtl_material_transactions_temp
8312 WHERE wms_task_type IS NOT NULL
8313 AND transaction_status = 2
8314 AND(
8315 wms_task_status IS NULL
8316 OR wms_task_status = 1
8317 ) --Added for task planning WB. bug#2651318
8318 ) wdtv
8319 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8320 --wms_person_resource_utt_v v,
8321 (SELECT utt_emp.standard_operation_id standard_operation_id
8322 , utt_emp.resource_id ROLE
8323 , utt_eqp.resource_id equipment
8324 , utt_emp.person_id emp_id
8325 , utt_eqp.inventory_item_id eqp_id
8326 , NULL eqp_srl /* removed for bug 2095237 */
8327 , utt_emp.effective_start_date
8328 , utt_emp.effective_end_date
8329 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8330 , x_utt_res1.resource_id resource_id
8331 , x_emp_r.person_id
8332 , x_emp_r.effective_start_date
8333 , x_emp_r.effective_end_date
8334 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8335 WHERE x_utt_res1.resource_id = r1.resource_id
8336 AND r1.resource_type = 2
8337 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8338 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8339 , x_utt_res2.resource_id resource_id
8340 , x_eqp_r.inventory_item_id inventory_item_id
8341 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8342 WHERE x_utt_res2.resource_id = r2.resource_id
8343 AND r2.resource_type = 1
8344 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8345 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8346 , -- inlined wms_person_resource_utt_v, bug 2648133
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 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8354 AND wdtv.organization_id = p_sign_on_org_id
8355 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8356 AND mol.header_id = moh.header_id
8357 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8358 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
8359 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8360 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8361 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8362 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8363 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8364 AND wdtv.locator_id = loc.inventory_location_id(+)
8365 AND wdtv.ZONE = sub.secondary_inventory_name
8366 AND wdtv.organization_id = sub.organization_id
8367 AND wdtv.move_order_line_id = mol.line_id
8368 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8369 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8370 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8371 (
8372 SELECT NULL
8373 FROM mtl_material_transactions_temp mmtt
8374 WHERE mmtt.transaction_temp_id = wdtv.task_id
8375 AND mmtt.parent_line_id IS NOT NULL
8376 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8377 AND NOT EXISTS -- exclude tasks already dispatched
8378 (SELECT NULL
8379 FROM wms_dispatched_tasks wdt1
8380 WHERE wdt1.transaction_temp_id = wdtv.task_id
8381 AND wdt1.task_type = wdtv.wms_task_type_id)
8382 --******************
8383 AND wdtv.task_id NOT IN -- excluded skipped tasks
8384 (
8385 SELECT wdtv.task_id
8386 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8387 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8388 AND wste.task_id = wdtv.task_id
8389 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8390 AND wste.organization_id = mp.organization_id)
8391 --*****************
8392 --J Addition
8393 AND wdtv.ZONE not in (
8394 SELECT wd.subinventory_code
8395 FROM wms_devices_b wd
8396 , wms_bus_event_devices wbed
8397 WHERE 1 = 1
8398 and wd.device_id = wbed.device_id
8399 AND wbed.organization_id = wd.organization_id
8400 AND wd.enabled_flag = 'Y'
8401 AND wbed.enabled_flag = 'Y'
8402 AND wbed.business_event_id = 10
8403 AND wd.subinventory_code IS NOT NULL
8404 AND wd.force_sign_on_flag = 'Y'
8405 AND wd.device_id NOT IN (SELECT device_id
8406 FROM wms_device_assignment_temp
8407 WHERE employee_id = p_sign_on_emp_id)
8408 )
8409 ORDER BY wdtv_task_priority DESC
8410 , batch_id
8411 , task_status DESC
8412 , sub_picking_order
8413 , loc_picking_order
8414 , xyz_distance
8415 , task_id1;
8416
8417
8418
8419 ----------------------------------
8420 -- following cursor for SO, IO and WIP and sub entered -----
8421
8422 CURSOR l_cp_ordered_tasks_SIW IS
8423 SELECT DISTINCT
8424 qt.task_id task_id1
8425 , mol.carton_grouping_id
8426 , qt.wms_task_type_id
8427 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8428 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8429 , NVL(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
8430 , sub.secondary_inventory_name sub_secondary_inventory_name
8431 , sub.picking_order sub_picking_order
8432 , loc.picking_order loc_picking_order
8433 , (
8434 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8435 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8436 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8437 ) xyz_distance
8438 , loc.concatenated_segments loc_concat_segs
8439 ,wdt.status task_status --bug 4310093
8440 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8441 , wdt.effective_start_date
8442 , wdt.effective_end_date
8443 , wdt.person_resource_id
8444 , wdt.machine_resource_id
8445 FROM wms_dispatched_tasks wdt,
8446 (SELECT transaction_temp_id task_id
8447 , standard_operation_id user_task_type_id
8448 , wms_task_type wms_task_type_id
8449 , organization_id organization_id
8450 , subinventory_code ZONE
8451 , locator_id locator_id
8452 , task_priority task_priority
8453 , revision revision
8454 , lot_number lot_number
8455 , transaction_uom transaction_uom
8456 , transaction_quantity transaction_quantity
8457 , pick_rule_id pick_rule_id
8458 , pick_slip_number pick_slip_number
8459 , cartonization_id cartonization_id
8460 , inventory_item_id
8461 , move_order_line_id
8462 FROM mtl_material_transactions_temp
8463 WHERE wms_task_type IS NOT NULL
8464 AND transaction_status = 2
8465 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8466 8, l_io_allowed) = 1 -- filter out the request so or io
8467 AND(
8468 wms_task_status IS NULL
8469 OR wms_task_status = 1
8470 ) --Added for task planning WB. bug#2651318
8471 ) qt
8472 , (SELECT
8473 bsor.standard_operation_id,
8474 bre.resource_id,
8475 bre.inventory_item_id equipment_id
8476 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8477 WHERE bsor.resource_id = bre.resource_id
8478 AND br.resource_type = 1
8479 AND bsor.resource_id = br.resource_id) e
8480 , mtl_item_locations_kfv loc
8481 , --changed to kfv bug#2742611
8482 mtl_secondary_inventories sub
8483 , mtl_txn_request_lines mol
8484 , mtl_txn_request_headers moh
8485 , -- mtl_system_items msi -- bug 2648133
8486 wsh_delivery_details_ob_grp_v wdd
8487 , -- added
8488 wsh_delivery_assignments_v wda --added
8489 WHERE wdt.transaction_temp_id = qt.task_id
8490 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
8491 AND wdt.person_id = p_sign_on_emp_id
8492 AND wdt.organization_id = p_sign_on_org_id
8493 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
8494 AND mol.header_id = moh.header_id
8495 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8496 AND qt.user_task_type_id =
8497 e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8498 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8499 AND qt.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8500 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
8501 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8502 AND qt.organization_id = loc.organization_id
8503 AND qt.locator_id = loc.inventory_location_id
8504 AND qt.ZONE = sub.secondary_inventory_name
8505 AND qt.organization_id = sub.organization_id
8506 AND qt.move_order_line_id = mol.line_id
8507 -- Join with delivery details
8508 AND(wdd.move_order_line_id = qt.move_order_line_id
8509 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8510 UNION ALL
8511 SELECT DISTINCT wdtv.task_id task_id1
8512 , mol.carton_grouping_id
8513 , wdtv.wms_task_type_id
8514 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8515 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8516 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8517 , sub.secondary_inventory_name sub_secondary_inventory_name
8518 , sub.picking_order sub_picking_order
8519 , loc.picking_order loc_picking_order
8520 , (
8521 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8522 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8523 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8524 ) xyz_distance
8525 , loc.concatenated_segments loc_concat_segs
8526 ,1 task_status
8527 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8528 ,v.effective_start_date
8529 ,v.effective_end_date
8530 ,v.role person_resource_id
8531 ,v.equipment machine_resource_id
8532 FROM --wms_dispatchable_tasks_v wdtv,
8533 (SELECT transaction_temp_id task_id
8534 , standard_operation_id user_task_type_id
8535 , wms_task_type wms_task_type_id
8536 , organization_id organization_id
8537 , subinventory_code ZONE
8538 , locator_id locator_id
8539 , task_priority task_priority
8540 , revision revision
8541 , lot_number lot_number
8542 , transaction_uom transaction_uom
8543 , transaction_quantity transaction_quantity
8544 , pick_rule_id pick_rule_id
8545 , pick_slip_number pick_slip_number
8546 , cartonization_id cartonization_id
8547 , inventory_item_id
8548 , move_order_line_id
8549 FROM mtl_material_transactions_temp
8550 WHERE wms_task_type IS NOT NULL
8551 AND transaction_status = 2
8552 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8553 8, l_io_allowed) = 1 -- filter out the request so or io
8554 AND(
8555 wms_task_status IS NULL
8556 OR wms_task_status = 1
8557 ) --Added for task planning WB. bug#2651318
8558 ) wdtv
8559 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8560 --wms_person_resource_utt_v v,
8561 (SELECT utt_emp.standard_operation_id standard_operation_id
8562 , utt_emp.resource_id ROLE
8563 , utt_eqp.resource_id equipment
8564 , utt_emp.person_id emp_id
8565 , utt_eqp.inventory_item_id eqp_id
8566 , NULL eqp_srl /* removed for bug 2095237 */
8567 , utt_emp.effective_start_date
8568 , utt_emp.effective_end_date
8569 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8570 , x_utt_res1.resource_id resource_id
8571 , x_emp_r.person_id
8572 , x_emp_r.effective_start_date
8573 , x_emp_r.effective_end_date
8574 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8575 WHERE x_utt_res1.resource_id = r1.resource_id
8576 AND r1.resource_type = 2
8577 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8578 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8579 , x_utt_res2.resource_id resource_id
8580 , x_eqp_r.inventory_item_id inventory_item_id
8581 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8582 WHERE x_utt_res2.resource_id = r2.resource_id
8583 AND r2.resource_type = 1
8584 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8585 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8586 , -- inlined wms_person_resource_utt_v, bug 2648133
8587 mtl_item_locations_kfv loc
8588 , --changed to kfv bug#2742611
8589 mtl_secondary_inventories sub
8590 , mtl_txn_request_lines mol
8591 , mtl_txn_request_headers moh
8592 , -- mtl_system_items msi -- bug 2648133
8593 wsh_delivery_details_ob_grp_v wdd
8594 , -- added
8595 wsh_delivery_assignments_v wda --added
8596 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8597 AND wdtv.organization_id = p_sign_on_org_id
8598 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8599 AND mol.header_id = moh.header_id
8600 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8601 AND wdtv.user_task_type_id =
8602 v.standard_operation_id -- join task to resource view, check if user defined task type match
8603 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8604 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8605 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8606 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8607 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8608 AND wdtv.locator_id = loc.inventory_location_id(+)
8609 AND wdtv.ZONE = sub.secondary_inventory_name
8610 AND wdtv.organization_id = sub.organization_id
8611 AND wdtv.move_order_line_id = mol.line_id
8612 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8613 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8614 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8615 (
8616 SELECT NULL
8617 FROM mtl_material_transactions_temp mmtt
8618 WHERE mmtt.transaction_temp_id = wdtv.task_id
8619 AND mmtt.parent_line_id IS NOT NULL
8620 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8621 AND NOT EXISTS -- exclude tasks already dispatched
8622 (SELECT NULL
8623 FROM wms_dispatched_tasks wdt1
8624 WHERE wdt1.transaction_temp_id = wdtv.task_id
8625 AND wdt1.task_type = wdtv.wms_task_type_id)
8626 -- Join with delivery details
8627 AND(wdd.move_order_line_id = wdtv.move_order_line_id
8628 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8629 --******************
8630 AND wdtv.task_id NOT IN -- excluded skipped tasks
8631 (
8632 SELECT wdtv.task_id
8633 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8634 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8635 AND wste.task_id = wdtv.task_id
8636 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8637 AND wste.organization_id = mp.organization_id)
8638 --*****************
8639 --J Addition
8640 AND wdtv.ZONE not in (
8641 SELECT wd.subinventory_code
8642 FROM wms_devices_b wd
8643 , wms_bus_event_devices wbed
8644 WHERE 1 = 1
8645 and wd.device_id = wbed.device_id
8646 AND wbed.organization_id = wd.organization_id
8647 AND wd.enabled_flag = 'Y'
8648 AND wbed.enabled_flag = 'Y'
8649 AND wbed.business_event_id = 10
8650 AND wd.subinventory_code IS NOT NULL
8651 AND wd.force_sign_on_flag = 'Y'
8652 AND wd.device_id NOT IN (SELECT device_id
8653 FROM wms_device_assignment_temp
8654 WHERE employee_id = p_sign_on_emp_id)
8655 )
8656 UNION ALL
8657 SELECT DISTINCT
8658 wdtv.task_id task_id1
8659 , mol.carton_grouping_id
8660 , wdtv.wms_task_type_id
8661 , mol.carton_grouping_id cluster_id
8662 , 'C' cluster_type
8663 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8664 , sub.secondary_inventory_name sub_secondary_inventory_name
8665 , sub.picking_order sub_picking_order
8666 , loc.picking_order loc_picking_order
8667 , (
8668 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8669 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8670 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8671 ) xyz_distance
8672 , loc.concatenated_segments loc_concat_segs
8673 ,1 task_status
8674 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8675 , wdt.effective_start_date
8676 , wdt.effective_end_date
8677 , wdt.person_resource_id
8678 , wdt.machine_resource_id
8679 FROM wms_dispatched_tasks wdt,
8680 (SELECT transaction_temp_id task_id
8681 , standard_operation_id user_task_type_id
8682 , wms_task_type wms_task_type_id
8683 , organization_id organization_id
8684 , subinventory_code ZONE
8685 , locator_id locator_id
8686 , task_priority task_priority
8687 , revision revision
8688 , lot_number lot_number
8689 , transaction_uom transaction_uom
8690 , transaction_quantity transaction_quantity
8691 , pick_rule_id pick_rule_id
8692 , pick_slip_number pick_slip_number
8693 , cartonization_id cartonization_id
8694 , inventory_item_id
8695 , move_order_line_id
8696 FROM mtl_material_transactions_temp
8697 WHERE wms_task_type IS NOT NULL
8698 AND transaction_status = 2
8699 AND(
8700 wms_task_status IS NULL
8701 OR wms_task_status = 1
8702 ) --Added for task planning WB. bug#2651318
8703 ) wdtv
8704 , (SELECT
8705 bsor.standard_operation_id,
8706 bre.resource_id,
8707 bre.inventory_item_id equipment_id
8708 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8709 WHERE bsor.resource_id = bre.resource_id
8710 AND br.resource_type = 1
8711 AND bsor.resource_id = br.resource_id) e
8712 , mtl_item_locations_kfv loc
8713 , --changed to kfv bug#2742611
8714 mtl_secondary_inventories sub
8715 , mtl_txn_request_lines mol
8716 , mtl_txn_request_headers moh
8717 -- mtl_system_items msi -- bug 2648133
8718 WHERE wdt.transaction_temp_id = wdtv.task_id
8719 AND wdt.status = 2 -- Queued tasks only
8720 AND wdt.person_id = p_sign_on_emp_id
8721 AND wdt.organization_id = p_sign_on_org_id
8722 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8723 AND mol.header_id = moh.header_id
8724 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8725 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
8726 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8727 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8728 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8729 AND wdtv.organization_id = loc.organization_id
8730 AND wdtv.locator_id = loc.inventory_location_id
8731 AND wdtv.ZONE = sub.secondary_inventory_name
8732 AND wdtv.organization_id = sub.organization_id
8733 AND wdtv.move_order_line_id = mol.line_id
8734 UNION ALL
8735 -- This will select the WIP Jobs alone
8736 SELECT DISTINCT
8737 wdtv.task_id task_id1
8738 , mol.carton_grouping_id
8739 , wdtv.wms_task_type_id
8740 , mol.carton_grouping_id cluster_id
8741 , 'C' cluster_type
8742 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8743 , sub.secondary_inventory_name sub_secondary_inventory_name
8744 , sub.picking_order sub_picking_order
8745 , loc.picking_order loc_picking_order
8746 , (
8747 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8748 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8749 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8750 ) xyz_distance
8751 , loc.concatenated_segments loc_concat_segs
8752 ,1 task_status
8753 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8754 ,v.effective_start_date
8755 ,v.effective_end_date
8756 ,v.role person_resource_id
8757 ,v.equipment machine_resource_id
8758 FROM --wms_dispatchable_tasks_v wdtv,
8759 (SELECT transaction_temp_id task_id
8760 , standard_operation_id user_task_type_id
8761 , wms_task_type wms_task_type_id
8762 , organization_id organization_id
8763 , subinventory_code ZONE
8764 , locator_id locator_id
8765 , task_priority task_priority
8766 , revision revision
8767 , lot_number lot_number
8768 , transaction_uom transaction_uom
8769 , transaction_quantity transaction_quantity
8770 , pick_rule_id pick_rule_id
8771 , pick_slip_number pick_slip_number
8772 , cartonization_id cartonization_id
8773 , inventory_item_id
8774 , move_order_line_id
8775 FROM mtl_material_transactions_temp
8776 WHERE wms_task_type IS NOT NULL
8777 AND transaction_status = 2
8778 AND(
8779 wms_task_status IS NULL
8780 OR wms_task_status = 1
8781 ) --Added for task planning WB. bug#2651318
8782 ) wdtv
8783 , -- inlined wms_dispatchable_tasks_v, bug 2648133
8784 --wms_person_resource_utt_v v,
8785 (SELECT utt_emp.standard_operation_id standard_operation_id
8786 , utt_emp.resource_id ROLE
8787 , utt_eqp.resource_id equipment
8788 , utt_emp.person_id emp_id
8789 , utt_eqp.inventory_item_id eqp_id
8790 , NULL eqp_srl /* removed for bug 2095237 */
8791 , utt_emp.effective_start_date
8792 , utt_emp.effective_end_date
8793 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
8794 , x_utt_res1.resource_id resource_id
8795 , x_emp_r.person_id
8796 , x_emp_r.effective_start_date
8797 , x_emp_r.effective_end_date
8798 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
8799 WHERE x_utt_res1.resource_id = r1.resource_id
8800 AND r1.resource_type = 2
8801 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
8802 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
8803 , x_utt_res2.resource_id resource_id
8804 , x_eqp_r.inventory_item_id inventory_item_id
8805 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
8806 WHERE x_utt_res2.resource_id = r2.resource_id
8807 AND r2.resource_type = 1
8808 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
8809 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
8810 , -- inlined wms_person_resource_utt_v, bug 2648133
8811 mtl_item_locations_kfv loc
8812 , --changed to kfv bug#2742611
8813 mtl_secondary_inventories sub
8814 , mtl_txn_request_lines mol
8815 , mtl_txn_request_headers moh
8816 -- mtl_system_items msi -- bug 2648133
8817 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
8818 AND wdtv.organization_id = p_sign_on_org_id
8819 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
8820 AND mol.header_id = moh.header_id
8821 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
8822 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
8823 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
8824 AND wdtv.ZONE = p_sign_on_zone -- removed NVL, bug 2648133
8825 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
8826 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
8827 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
8828 AND wdtv.locator_id = loc.inventory_location_id(+)
8829 AND wdtv.ZONE = sub.secondary_inventory_name
8830 AND wdtv.organization_id = sub.organization_id
8831 AND wdtv.move_order_line_id = mol.line_id
8832 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
8833 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
8834 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
8835 (
8836 SELECT NULL
8837 FROM mtl_material_transactions_temp mmtt
8838 WHERE mmtt.transaction_temp_id = wdtv.task_id
8839 AND mmtt.parent_line_id IS NOT NULL
8840 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
8841 AND NOT EXISTS -- exclude tasks already dispatched
8842 (SELECT NULL
8843 FROM wms_dispatched_tasks wdt1
8844 WHERE wdt1.transaction_temp_id = wdtv.task_id
8845 AND wdt1.task_type = wdtv.wms_task_type_id)
8846 --******************
8847 AND wdtv.task_id NOT IN -- excluded skipped tasks
8848 (
8849 SELECT wdtv.task_id
8850 FROM wms_skip_task_exceptions wste, mtl_parameters mp
8851 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
8852 AND wste.task_id = wdtv.task_id
8853 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
8854 AND wste.organization_id = mp.organization_id)
8855 --*****************
8856 --J Addition
8857 AND wdtv.ZONE not in (
8858 SELECT wd.subinventory_code
8859 FROM wms_devices_b wd
8860 , wms_bus_event_devices wbed
8861 WHERE 1 = 1
8862 and wd.device_id = wbed.device_id
8863 AND wbed.organization_id = wd.organization_id
8864 AND wd.enabled_flag = 'Y'
8865 AND wbed.enabled_flag = 'Y'
8866 AND wbed.business_event_id = 10
8867 AND wd.subinventory_code IS NOT NULL
8868 AND wd.force_sign_on_flag = 'Y'
8869 AND wd.device_id NOT IN (SELECT device_id
8870 FROM wms_device_assignment_temp
8871 WHERE employee_id = p_sign_on_emp_id)
8872 )
8873 ORDER BY wdtv_task_priority DESC
8874 , batch_id
8875 , task_status DESC
8876 , sub_picking_order
8877 , loc_picking_order
8878 , xyz_distance
8879 , task_id1;
8880
8881
8882 --- ***************************************
8883 -- THE FOLLOWING 3 cursors are for no sub ----------------
8884 ---------------------------------------------------------
8885 -- following cursor for SO, IO and sub NOT entered -----
8886 CURSOR l_cp_ordered_tasks_no_sub_SI IS -- bug 2648133
8887 SELECT DISTINCT
8888 qt.task_id task_id1
8889 , mol.carton_grouping_id
8890 , qt.wms_task_type_id
8891 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8892 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8893 , NVL(qt.task_priority,0) wdtv_task_priority -- Bug 4599496
8894 , sub.secondary_inventory_name sub_secondary_inventory_name
8895 , sub.picking_order sub_picking_order
8896 , loc.picking_order loc_picking_order
8897 , (
8898 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8899 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8900 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8901 ) xyz_distance
8902 , loc.concatenated_segments loc_concat_segs
8903 ,wdt.status task_status --bug 4310093
8904 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8905 , wdt.effective_start_date
8906 , wdt.effective_end_date
8907 , wdt.person_resource_id
8908 , wdt.machine_resource_id
8909 FROM wms_dispatched_tasks wdt,
8910 (SELECT transaction_temp_id task_id
8911 , standard_operation_id user_task_type_id
8912 , wms_task_type wms_task_type_id
8913 , organization_id organization_id
8914 , subinventory_code ZONE
8915 , locator_id locator_id
8916 , task_priority task_priority
8917 , revision revision
8918 , lot_number lot_number
8919 , transaction_uom transaction_uom
8920 , transaction_quantity transaction_quantity
8921 , pick_rule_id pick_rule_id
8922 , pick_slip_number pick_slip_number
8923 , cartonization_id cartonization_id
8924 , inventory_item_id
8925 , move_order_line_id
8926 FROM mtl_material_transactions_temp
8927 WHERE wms_task_type IS NOT NULL
8928 AND transaction_status = 2
8929 AND Decode(transaction_source_type_id, 2, l_so_allowed,
8930 8, l_io_allowed) = 1 -- filter out the request so or io
8931 AND(
8932 wms_task_status IS NULL
8933 OR wms_task_status = 1
8934 ) --Added for task planning WB. bug#2651318
8935 ) qt
8936 , (SELECT
8937 bsor.standard_operation_id,
8938 bre.resource_id,
8939 bre.inventory_item_id equipment_id
8940 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
8941 WHERE bsor.resource_id = bre.resource_id
8942 AND br.resource_type = 1
8943 AND bsor.resource_id = br.resource_id) e
8944 , mtl_item_locations_kfv loc
8945 , --changed to kfv bug#2742611
8946 mtl_secondary_inventories sub
8947 , mtl_txn_request_lines mol
8948 , mtl_txn_request_headers moh
8949 , -- mtl_system_items msi -- bug 2648133
8950 wsh_delivery_details_ob_grp_v wdd
8951 , -- added
8952 wsh_delivery_assignments_v wda --added
8953 WHERE wdt.transaction_temp_id = qt.task_id
8954 AND wdt.status in( 2,3) -- Queued and dispatched tasks only bug 4310093
8955 AND wdt.person_id = p_sign_on_emp_id
8956 AND wdt.organization_id = p_sign_on_org_id
8957 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
8958 AND mol.header_id = moh.header_id
8959 AND moh.move_order_type = 3 -- only pick wave move orders are considered
8960 AND qt.user_task_type_id =
8961 e.standard_operation_id(+)
8962 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
8963 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
8964 AND qt.organization_id = loc.organization_id
8965 AND qt.locator_id = loc.inventory_location_id
8966 AND qt.ZONE = sub.secondary_inventory_name
8967 AND qt.organization_id = sub.organization_id
8968 AND qt.move_order_line_id = mol.line_id
8969 -- Join with delivery details
8970 AND(wdd.move_order_line_id = qt.move_order_line_id
8971 AND wdd.delivery_detail_id = wda.delivery_detail_id)
8972 UNION ALL
8973 SELECT DISTINCT wdtv.task_id task_id1
8974 , mol.carton_grouping_id
8975 , wdtv.wms_task_type_id
8976 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
8977 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
8978 , nvl(wdtv.task_priority, 0) wdtv_task_priority
8979 , sub.secondary_inventory_name sub_secondary_inventory_name
8980 , sub.picking_order sub_picking_order
8981 , loc.picking_order loc_picking_order
8982 , (
8983 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
8984 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
8985 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
8986 ) xyz_distance
8987 , loc.concatenated_segments loc_concat_segs
8988 ,1 task_status
8989 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
8990 ,v.effective_start_date
8991 ,v.effective_end_date
8992 ,v.role person_resource_id
8993 ,v.equipment machine_resource_id
8994 FROM --wms_dispatchable_tasks_v wdtv,
8995 (SELECT transaction_temp_id task_id
8996 , standard_operation_id user_task_type_id
8997 , wms_task_type wms_task_type_id
8998 , organization_id organization_id
8999 , subinventory_code ZONE
9000 , locator_id locator_id
9001 , task_priority task_priority
9002 , revision revision
9003 , lot_number lot_number
9004 , transaction_uom transaction_uom
9005 , transaction_quantity transaction_quantity
9006 , pick_rule_id pick_rule_id
9007 , pick_slip_number pick_slip_number
9008 , cartonization_id cartonization_id
9009 , inventory_item_id
9010 , move_order_line_id
9011 FROM mtl_material_transactions_temp
9012 WHERE wms_task_type IS NOT NULL
9013 AND transaction_status = 2
9014 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9015 8, l_io_allowed) = 1 -- filter out the request so or io
9016 AND(
9017 wms_task_status IS NULL
9018 OR wms_task_status = 1
9019 ) --Added for task planning WB. bug#2651318
9020 ) wdtv
9021 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9022 --wms_person_resource_utt_v v,
9023 (SELECT utt_emp.standard_operation_id standard_operation_id
9024 , utt_emp.resource_id ROLE
9025 , utt_eqp.resource_id equipment
9026 , utt_emp.person_id emp_id
9027 , utt_eqp.inventory_item_id eqp_id
9028 , NULL eqp_srl /* removed for bug 2095237 */
9029 , utt_emp.effective_start_date
9030 , utt_emp.effective_end_date
9031 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9032 , x_utt_res1.resource_id resource_id
9033 , x_emp_r.person_id
9034 , x_emp_r.effective_start_date
9035 , x_emp_r.effective_end_date
9036 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9037 WHERE x_utt_res1.resource_id = r1.resource_id
9038 AND r1.resource_type = 2
9039 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9040 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9041 , x_utt_res2.resource_id resource_id
9042 , x_eqp_r.inventory_item_id inventory_item_id
9043 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9044 WHERE x_utt_res2.resource_id = r2.resource_id
9045 AND r2.resource_type = 1
9046 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9047 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9048 , -- inlined wms_person_resource_utt_v, bug 2648133
9049 mtl_item_locations_kfv loc
9050 , --changed to kfv bug#2742611
9051 mtl_secondary_inventories sub
9052 , mtl_txn_request_lines mol
9053 , mtl_txn_request_headers moh
9054 , -- mtl_system_items msi -- bug 2648133
9055 wsh_delivery_details_ob_grp_v wdd
9056 , -- added
9057 wsh_delivery_assignments_v wda --added
9058 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9059 AND wdtv.organization_id = p_sign_on_org_id
9060 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9061 AND mol.header_id = moh.header_id
9062 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9063 AND wdtv.user_task_type_id =
9064 v.standard_operation_id -- join task to resource view, check if user defined task type match
9065 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9066 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9067 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9068 AND wdtv.locator_id = loc.inventory_location_id(+)
9069 AND wdtv.ZONE = sub.secondary_inventory_name
9070 AND wdtv.organization_id = sub.organization_id
9071 AND wdtv.move_order_line_id = mol.line_id
9072 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9073 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9074 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9075 (
9076 SELECT NULL
9077 FROM mtl_material_transactions_temp mmtt
9078 WHERE mmtt.transaction_temp_id = wdtv.task_id
9079 AND mmtt.parent_line_id IS NOT NULL
9080 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9081 AND NOT EXISTS -- exclude tasks already dispatched
9082 (SELECT NULL
9083 FROM wms_dispatched_tasks wdt1
9084 WHERE wdt1.transaction_temp_id = wdtv.task_id
9085 AND wdt1.task_type = wdtv.wms_task_type_id)
9086 -- Join with delivery details
9087 AND(wdd.move_order_line_id = wdtv.move_order_line_id
9088 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9089 --******************
9090 AND wdtv.task_id NOT IN -- excluded skipped tasks
9091 (
9092 SELECT wdtv.task_id
9093 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9094 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9095 AND wste.task_id = wdtv.task_id
9096 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9097 AND wste.organization_id = mp.organization_id)
9098
9099 --J Addition
9100 AND wdtv.ZONE not in (
9101 SELECT wd.subinventory_code
9102 FROM wms_devices_b wd
9103 , wms_bus_event_devices wbed
9104 WHERE 1 = 1
9105 and wd.device_id = wbed.device_id
9106 AND wbed.organization_id = wd.organization_id
9107 AND wd.enabled_flag = 'Y'
9108 AND wbed.enabled_flag = 'Y'
9109 AND wbed.business_event_id = 10
9110 AND wd.subinventory_code IS NOT NULL
9111 AND wd.force_sign_on_flag = 'Y'
9112 AND wd.device_id NOT IN (SELECT device_id
9113 FROM wms_device_assignment_temp
9114 WHERE employee_id = p_sign_on_emp_id)
9115 )
9116 ORDER BY wdtv_task_priority DESC
9117 , batch_id
9118 , task_status DESC
9119 , sub_picking_order
9120 , loc_picking_order
9121 , xyz_distance
9122 , task_id1;
9123
9124
9125 -- following cursor for WIP and sub NOT entered -----
9126 CURSOR l_cp_ordered_tasks_no_sub_W IS
9127 SELECT DISTINCT wdtv.task_id task_id1
9128 , mol.carton_grouping_id
9129 , wdtv.wms_task_type_id
9130 , mol.carton_grouping_id cluster_id
9131 , 'C' cluster_type
9132 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9133 , sub.secondary_inventory_name sub_secondary_inventory_name
9134 , sub.picking_order sub_picking_order
9135 , loc.picking_order loc_picking_order
9136 , (
9137 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9138 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9139 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9140 ) xyz_distance
9141 , loc.concatenated_segments loc_concat_segs
9142 ,wdt.status task_status --bug 4310093
9143 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9144 , wdt.effective_start_date
9145 , wdt.effective_end_date
9146 , wdt.person_resource_id
9147 , wdt.machine_resource_id
9148 FROM wms_dispatched_tasks wdt,
9149 (SELECT transaction_temp_id task_id
9150 , standard_operation_id user_task_type_id
9151 , wms_task_type wms_task_type_id
9152 , organization_id organization_id
9153 , subinventory_code ZONE
9154 , locator_id locator_id
9155 , task_priority task_priority
9156 , revision revision
9157 , lot_number lot_number
9158 , transaction_uom transaction_uom
9159 , transaction_quantity transaction_quantity
9160 , pick_rule_id pick_rule_id
9161 , pick_slip_number pick_slip_number
9162 , cartonization_id cartonization_id
9163 , inventory_item_id
9164 , move_order_line_id
9165 FROM mtl_material_transactions_temp
9166 WHERE wms_task_type IS NOT NULL
9167 AND transaction_status = 2
9168 AND(
9169 wms_task_status IS NULL
9170 OR wms_task_status = 1
9171 ) --Added for task planning WB. bug#2651318
9172 ) wdtv
9173 , (SELECT
9174 bsor.standard_operation_id,
9175 bre.resource_id,
9176 bre.inventory_item_id equipment_id
9177 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9178 WHERE bsor.resource_id = bre.resource_id
9179 AND br.resource_type = 1
9180 AND bsor.resource_id = br.resource_id) e
9181 , mtl_item_locations_kfv loc
9182 , --changed to kfv bug#2742611
9183 mtl_secondary_inventories sub
9184 , mtl_txn_request_lines mol
9185 , mtl_txn_request_headers moh
9186 -- mtl_system_items msi -- bug 2648133
9187 WHERE wdt.transaction_temp_id = wdtv.task_id
9188 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
9189 AND wdt.person_id = p_sign_on_emp_id
9190 AND wdt.organization_id = p_sign_on_org_id
9191 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9192 AND mol.header_id = moh.header_id
9193 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9194 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
9195 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9196 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9197 AND wdtv.organization_id = loc.organization_id
9198 AND wdtv.locator_id = loc.inventory_location_id
9199 AND wdtv.ZONE = sub.secondary_inventory_name
9200 AND wdtv.organization_id = sub.organization_id
9201 AND wdtv.move_order_line_id = mol.line_id
9202 UNION ALL
9203 -- This will select the WIP Jobs alone
9204 SELECT DISTINCT
9205 wdtv.task_id task_id1
9206 , mol.carton_grouping_id
9207 , wdtv.wms_task_type_id
9208 , mol.carton_grouping_id cluster_id
9209 , 'C' cluster_type
9210 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9211 , sub.secondary_inventory_name sub_secondary_inventory_name
9212 , sub.picking_order sub_picking_order
9213 , loc.picking_order loc_picking_order
9214 , (
9215 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9216 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9217 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9218 ) xyz_distance
9219 , loc.concatenated_segments loc_concat_segs
9220 ,1 task_status
9221 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9222 ,v.effective_start_date
9223 ,v.effective_end_date
9224 ,v.role person_resource_id
9225 ,v.equipment machine_resource_id
9226 FROM --wms_dispatchable_tasks_v wdtv,
9227 (SELECT transaction_temp_id task_id
9228 , standard_operation_id user_task_type_id
9229 , wms_task_type wms_task_type_id
9230 , organization_id organization_id
9231 , subinventory_code ZONE
9232 , locator_id locator_id
9233 , task_priority task_priority
9234 , revision revision
9235 , lot_number lot_number
9236 , transaction_uom transaction_uom
9237 , transaction_quantity transaction_quantity
9238 , pick_rule_id pick_rule_id
9239 , pick_slip_number pick_slip_number
9240 , cartonization_id cartonization_id
9241 , inventory_item_id
9242 , move_order_line_id
9243 FROM mtl_material_transactions_temp
9244 WHERE wms_task_type IS NOT NULL
9245 AND transaction_status = 2
9246 AND(
9247 wms_task_status IS NULL
9248 OR wms_task_status = 1
9249 ) --Added for task planning WB. bug#2651318
9250 ) wdtv
9251 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9252 --wms_person_resource_utt_v v,
9253 (SELECT utt_emp.standard_operation_id standard_operation_id
9254 , utt_emp.resource_id ROLE
9255 , utt_eqp.resource_id equipment
9256 , utt_emp.person_id emp_id
9257 , utt_eqp.inventory_item_id eqp_id
9258 , NULL eqp_srl /* removed for bug 2095237 */
9259 , utt_emp.effective_start_date
9260 , utt_emp.effective_end_date
9261 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9262 , x_utt_res1.resource_id resource_id
9263 , x_emp_r.person_id
9264 , x_emp_r.effective_start_date
9265 , x_emp_r.effective_end_date
9266 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9267 WHERE x_utt_res1.resource_id = r1.resource_id
9268 AND r1.resource_type = 2
9269 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9270 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9271 , x_utt_res2.resource_id resource_id
9272 , x_eqp_r.inventory_item_id inventory_item_id
9273 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9274 WHERE x_utt_res2.resource_id = r2.resource_id
9275 AND r2.resource_type = 1
9276 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9277 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9278 , -- inlined wms_person_resource_utt_v, bug 2648133
9279 mtl_item_locations_kfv loc
9280 , --changed to kfv bug#2742611
9281 mtl_secondary_inventories sub
9282 , mtl_txn_request_lines mol
9283 , mtl_txn_request_headers moh
9284 -- mtl_system_items msi -- bug 2648133
9285 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9286 AND wdtv.organization_id = p_sign_on_org_id
9287 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9288 AND mol.header_id = moh.header_id
9289 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9290 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
9291 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9292 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9293 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9294 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9295 AND wdtv.locator_id = loc.inventory_location_id(+)
9296 AND wdtv.ZONE = sub.secondary_inventory_name
9297 AND wdtv.organization_id = sub.organization_id
9298 AND wdtv.move_order_line_id = mol.line_id
9299 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9300 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9301 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9302 (
9303 SELECT NULL
9304 FROM mtl_material_transactions_temp mmtt
9305 WHERE mmtt.transaction_temp_id = wdtv.task_id
9306 AND mmtt.parent_line_id IS NOT NULL
9307 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9308 AND NOT EXISTS -- exclude tasks already dispatched
9309 (SELECT NULL
9310 FROM wms_dispatched_tasks wdt1
9311 WHERE wdt1.transaction_temp_id = wdtv.task_id
9312 AND wdt1.task_type = wdtv.wms_task_type_id)
9313 --******************
9314 AND wdtv.task_id NOT IN -- excluded skipped tasks
9315 (
9316 SELECT wdtv.task_id
9317 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9318 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9319 AND wste.task_id = wdtv.task_id
9320 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9321 AND wste.organization_id = mp.organization_id)
9322 --*****************
9323 --J Addition
9324 AND wdtv.ZONE not in (
9325 SELECT wd.subinventory_code
9326 FROM wms_devices_b wd
9327 , wms_bus_event_devices wbed
9328 WHERE 1 = 1
9329 and wd.device_id = wbed.device_id
9330 AND wbed.organization_id = wd.organization_id
9331 AND wd.enabled_flag = 'Y'
9332 AND wbed.enabled_flag = 'Y'
9333 AND wbed.business_event_id = 10
9334 AND wd.subinventory_code IS NOT NULL
9335 AND wd.force_sign_on_flag = 'Y'
9336 AND wd.device_id NOT IN (SELECT device_id
9337 FROM wms_device_assignment_temp
9338 WHERE employee_id = p_sign_on_emp_id)
9339 )
9340 ORDER BY wdtv_task_priority DESC
9341 , batch_id
9342 , task_status DESC
9343 , sub_picking_order
9344 , loc_picking_order
9345 , xyz_distance
9346 , task_id1;
9347
9348
9349 -- following cursor for SO, IO, WIP and sub NOT entered -----
9350 CURSOR l_cp_ordered_tasks_no_sub_SIW IS -- bug 2648133
9351 SELECT DISTINCT
9352 qt.task_id task_id1
9353 , mol.carton_grouping_id
9354 , qt.wms_task_type_id
9355 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9356 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9357 , NVL(qt.task_priority, 0) wdtv_task_priority -- Bug 4599496
9358 , sub.secondary_inventory_name sub_secondary_inventory_name
9359 , sub.picking_order sub_picking_order
9360 , loc.picking_order loc_picking_order
9361 , (
9362 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9363 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9364 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9365 ) xyz_distance
9366 , loc.concatenated_segments loc_concat_segs
9367 ,wdt.status task_status --bug 4310093
9368 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9369 , wdt.effective_start_date
9370 , wdt.effective_end_date
9371 , wdt.person_resource_id
9372 , wdt.machine_resource_id
9373 FROM wms_dispatched_tasks wdt,
9374 (SELECT transaction_temp_id task_id
9375 , standard_operation_id user_task_type_id
9376 , wms_task_type wms_task_type_id
9377 , organization_id organization_id
9378 , subinventory_code ZONE
9379 , locator_id locator_id
9380 , task_priority task_priority
9381 , revision revision
9382 , lot_number lot_number
9383 , transaction_uom transaction_uom
9384 , transaction_quantity transaction_quantity
9385 , pick_rule_id pick_rule_id
9386 , pick_slip_number pick_slip_number
9387 , cartonization_id cartonization_id
9388 , inventory_item_id
9389 , move_order_line_id
9390 FROM mtl_material_transactions_temp
9391 WHERE wms_task_type IS NOT NULL
9392 AND transaction_status = 2
9393 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9394 8, l_io_allowed) = 1 -- filter out the request so or io
9395 AND(
9396 wms_task_status IS NULL
9397 OR wms_task_status = 1
9398 ) --Added for task planning WB. bug#2651318
9399 ) qt
9400 , (SELECT
9401 bsor.standard_operation_id,
9402 bre.resource_id,
9403 bre.inventory_item_id equipment_id
9404 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9405 WHERE bsor.resource_id = bre.resource_id
9406 AND br.resource_type = 1
9407 AND bsor.resource_id = br.resource_id) e
9408 , mtl_item_locations_kfv loc
9409 , --changed to kfv bug#2742611
9410 mtl_secondary_inventories sub
9411 , mtl_txn_request_lines mol
9412 , mtl_txn_request_headers moh
9413 , -- mtl_system_items msi -- bug 2648133
9414 wsh_delivery_details_ob_grp_v wdd
9415 , -- added
9416 wsh_delivery_assignments_v wda --added
9417 WHERE wdt.transaction_temp_id = qt.task_id
9418 AND wdt.status in ( 2,3) -- Queued and dispatched tasks only bug 4310093
9419 AND wdt.person_id = p_sign_on_emp_id
9420 AND wdt.organization_id = p_sign_on_org_id
9421 AND qt.wms_task_type_id = 1 -- restrict to picking tasks
9422 AND mol.header_id = moh.header_id
9423 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9424 AND qt.user_task_type_id =
9425 e.standard_operation_id(+)
9426 AND NVL(qt.cartonization_id, -999) = NVL(p_cartonization_id, NVL(qt.cartonization_id, -999))
9427 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9428 AND qt.organization_id = loc.organization_id
9429 AND qt.locator_id = loc.inventory_location_id
9430 AND qt.ZONE = sub.secondary_inventory_name
9431 AND qt.organization_id = sub.organization_id
9432 AND qt.move_order_line_id = mol.line_id
9433 -- Join with delivery details
9434 AND(wdd.move_order_line_id = qt.move_order_line_id
9435 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9436 UNION ALL
9437 SELECT DISTINCT wdtv.task_id task_id1
9438 , mol.carton_grouping_id
9439 , wdtv.wms_task_type_id
9440 , NVL(wda.delivery_id, mol.carton_grouping_id) cluster_id
9441 , DECODE(wda.delivery_id, NULL, 'C', 'D') cluster_type
9442 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9443 , sub.secondary_inventory_name sub_secondary_inventory_name
9444 , sub.picking_order sub_picking_order
9445 , loc.picking_order loc_picking_order
9446 , (
9447 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9448 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9449 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9450 ) xyz_distance
9451 , loc.concatenated_segments loc_concat_segs
9452 ,1 task_status
9453 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9454 ,v.effective_start_date
9455 ,v.effective_end_date
9456 ,v.role person_resource_id
9457 ,v.equipment machine_resource_id
9458 FROM --wms_dispatchable_tasks_v wdtv,
9459 (SELECT transaction_temp_id task_id
9460 , standard_operation_id user_task_type_id
9461 , wms_task_type wms_task_type_id
9462 , organization_id organization_id
9463 , subinventory_code ZONE
9464 , locator_id locator_id
9465 , task_priority task_priority
9466 , revision revision
9467 , lot_number lot_number
9468 , transaction_uom transaction_uom
9469 , transaction_quantity transaction_quantity
9470 , pick_rule_id pick_rule_id
9471 , pick_slip_number pick_slip_number
9472 , cartonization_id cartonization_id
9473 , inventory_item_id
9474 , move_order_line_id
9475 FROM mtl_material_transactions_temp
9476 WHERE wms_task_type IS NOT NULL
9477 AND transaction_status = 2
9478 AND Decode(transaction_source_type_id, 2, l_so_allowed,
9479 8, l_io_allowed) = 1 -- filter out the request so or io
9480 AND(
9481 wms_task_status IS NULL
9482 OR wms_task_status = 1
9483 ) --Added for task planning WB. bug#2651318
9484 ) wdtv
9485 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9486 --wms_person_resource_utt_v v,
9487 (SELECT utt_emp.standard_operation_id standard_operation_id
9488 , utt_emp.resource_id ROLE
9489 , utt_eqp.resource_id equipment
9490 , utt_emp.person_id emp_id
9491 , utt_eqp.inventory_item_id eqp_id
9492 , NULL eqp_srl /* removed for bug 2095237 */
9493 , utt_emp.effective_start_date
9494 , utt_emp.effective_end_date
9495 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9496 , x_utt_res1.resource_id resource_id
9497 , x_emp_r.person_id
9498 , x_emp_r.effective_start_date
9499 , x_emp_r.effective_end_date
9500 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9501 WHERE x_utt_res1.resource_id = r1.resource_id
9502 AND r1.resource_type = 2
9503 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9504 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9505 , x_utt_res2.resource_id resource_id
9506 , x_eqp_r.inventory_item_id inventory_item_id
9507 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9508 WHERE x_utt_res2.resource_id = r2.resource_id
9509 AND r2.resource_type = 1
9510 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9511 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9512 , -- inlined wms_person_resource_utt_v, bug 2648133
9513 mtl_item_locations_kfv loc
9514 , --changed to kfv bug#2742611
9515 mtl_secondary_inventories sub
9516 , mtl_txn_request_lines mol
9517 , mtl_txn_request_headers moh
9518 , -- mtl_system_items msi -- bug 2648133
9519 wsh_delivery_details_ob_grp_v wdd
9520 , -- added
9521 wsh_delivery_assignments_v wda --added
9522 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9523 AND wdtv.organization_id = p_sign_on_org_id
9524 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9525 AND mol.header_id = moh.header_id
9526 AND moh.move_order_type = 3 -- only pick wave move orders are considered
9527 AND wdtv.user_task_type_id =
9528 v.standard_operation_id -- join task to resource view, check if user defined task type match
9529 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9530 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9531 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9532 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9533 AND wdtv.locator_id = loc.inventory_location_id(+)
9534 AND wdtv.ZONE = sub.secondary_inventory_name
9535 AND wdtv.organization_id = sub.organization_id
9536 AND wdtv.move_order_line_id = mol.line_id
9537 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9538 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9539 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9540 (
9541 SELECT NULL
9542 FROM mtl_material_transactions_temp mmtt
9543 WHERE mmtt.transaction_temp_id = wdtv.task_id
9544 AND mmtt.parent_line_id IS NOT NULL
9545 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9546 AND NOT EXISTS -- exclude tasks already dispatched
9547 (SELECT NULL
9548 FROM wms_dispatched_tasks wdt1
9549 WHERE wdt1.transaction_temp_id = wdtv.task_id
9550 AND wdt1.task_type = wdtv.wms_task_type_id)
9551 -- Join with delivery details
9552 AND(wdd.move_order_line_id = wdtv.move_order_line_id
9553 AND wdd.delivery_detail_id = wda.delivery_detail_id)
9554 --******************
9555 AND wdtv.task_id NOT IN -- excluded skipped tasks
9556 (
9557 SELECT wdtv.task_id
9558 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9559 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9560 AND wste.task_id = wdtv.task_id
9561 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9562 AND wste.organization_id = mp.organization_id)
9563 --*****************
9564 --J Addition
9565 AND wdtv.ZONE not in (
9566 SELECT wd.subinventory_code
9567 FROM wms_devices_b wd
9568 , wms_bus_event_devices wbed
9569 WHERE 1 = 1
9570 and wd.device_id = wbed.device_id
9571 AND wbed.organization_id = wd.organization_id
9572 AND wd.enabled_flag = 'Y'
9573 AND wbed.enabled_flag = 'Y'
9574 AND wbed.business_event_id = 10
9575 AND wd.subinventory_code IS NOT NULL
9576 AND wd.force_sign_on_flag = 'Y'
9577 AND wd.device_id NOT IN (SELECT device_id
9578 FROM wms_device_assignment_temp
9579 WHERE employee_id = p_sign_on_emp_id)
9580 )
9581 UNION ALL
9582 SELECT DISTINCT
9583 wdtv.task_id task_id1
9584 , mol.carton_grouping_id
9585 , wdtv.wms_task_type_id
9586 , mol.carton_grouping_id cluster_id
9587 , 'C' cluster_type
9588 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9589 , sub.secondary_inventory_name sub_secondary_inventory_name
9590 , sub.picking_order sub_picking_order
9591 , loc.picking_order loc_picking_order
9592 , (
9593 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9594 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9595 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9596 ) xyz_distance
9597 , loc.concatenated_segments loc_concat_segs
9598 ,1 task_status
9599 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9600 , wdt.effective_start_date
9601 , wdt.effective_end_date
9602 , wdt.person_resource_id
9603 , wdt.machine_resource_id
9604 FROM wms_dispatched_tasks wdt,
9605 (SELECT transaction_temp_id task_id
9606 , standard_operation_id user_task_type_id
9607 , wms_task_type wms_task_type_id
9608 , organization_id organization_id
9609 , subinventory_code ZONE
9610 , locator_id locator_id
9611 , task_priority task_priority
9612 , revision revision
9613 , lot_number lot_number
9614 , transaction_uom transaction_uom
9615 , transaction_quantity transaction_quantity
9616 , pick_rule_id pick_rule_id
9617 , pick_slip_number pick_slip_number
9618 , cartonization_id cartonization_id
9619 , inventory_item_id
9620 , move_order_line_id
9621 FROM mtl_material_transactions_temp
9622 WHERE wms_task_type IS NOT NULL
9623 AND transaction_status = 2
9624 AND(
9625 wms_task_status IS NULL
9626 OR wms_task_status = 1
9627 ) --Added for task planning WB. bug#2651318
9628 ) wdtv
9629 , (SELECT
9630 bsor.standard_operation_id,
9631 bre.resource_id,
9632 bre.inventory_item_id equipment_id
9633 FROM bom_std_op_resources bsor, bom_resources br, bom_resource_equipments bre
9634 WHERE bsor.resource_id = bre.resource_id
9635 AND br.resource_type = 1
9636 AND bsor.resource_id = br.resource_id) e
9637 , mtl_item_locations_kfv loc
9638 , --changed to kfv bug#2742611
9639 mtl_secondary_inventories sub
9640 , mtl_txn_request_lines mol
9641 , mtl_txn_request_headers moh
9642 -- mtl_system_items msi -- bug 2648133
9643 WHERE wdt.transaction_temp_id = wdtv.task_id
9644 AND wdt.status = 2 -- Queued tasks only
9645 AND wdt.person_id = p_sign_on_emp_id
9646 AND wdt.organization_id = p_sign_on_org_id
9647 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9648 AND mol.header_id = moh.header_id
9649 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9650 AND wdtv.user_task_type_id = e.standard_operation_id(+) -- join task to resource view, check if user defined task type match
9651 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9652 AND NVL(e.equipment_id, -999) = NVL(l_sign_on_equipment_id, NVL(e.equipment_id, -999))
9653 AND wdtv.organization_id = loc.organization_id
9654 AND wdtv.locator_id = loc.inventory_location_id
9655 AND wdtv.ZONE = sub.secondary_inventory_name
9656 AND wdtv.organization_id = sub.organization_id
9657 AND wdtv.move_order_line_id = mol.line_id
9658 UNION ALL
9659 -- This will select the WIP Jobs alone
9660 SELECT DISTINCT
9661 wdtv.task_id task_id1
9662 , mol.carton_grouping_id
9663 , wdtv.wms_task_type_id
9664 , mol.carton_grouping_id cluster_id
9665 , 'C' cluster_type
9666 , nvl(wdtv.task_priority, 0) wdtv_task_priority
9667 , sub.secondary_inventory_name sub_secondary_inventory_name
9668 , sub.picking_order sub_picking_order
9669 , loc.picking_order loc_picking_order
9670 , (
9671 (nvl(loc.x_coordinate, 0) - l_cur_x) *(nvl(loc.x_coordinate, 0) - l_cur_x)
9672 + (nvl(loc.y_coordinate, 0) - l_cur_y) *(nvl(loc.y_coordinate, 0) - l_cur_y)
9673 + (nvl(loc.z_coordinate, 0) - l_cur_z) *(nvl(loc.z_coordinate, 0) - l_cur_z)
9674 ) xyz_distance
9675 , loc.concatenated_segments loc_concat_segs
9676 ,1 task_status
9677 ,DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL) batch_id
9678 ,v.effective_start_date
9679 ,v.effective_end_date
9680 ,v.role person_resource_id
9681 ,v.equipment machine_resource_id
9682 FROM --wms_dispatchable_tasks_v wdtv,
9683 (SELECT transaction_temp_id task_id
9684 , standard_operation_id user_task_type_id
9685 , wms_task_type wms_task_type_id
9686 , organization_id organization_id
9687 , subinventory_code ZONE
9688 , locator_id locator_id
9689 , task_priority task_priority
9690 , revision revision
9691 , lot_number lot_number
9692 , transaction_uom transaction_uom
9693 , transaction_quantity transaction_quantity
9694 , pick_rule_id pick_rule_id
9695 , pick_slip_number pick_slip_number
9696 , cartonization_id cartonization_id
9697 , inventory_item_id
9698 , move_order_line_id
9699 FROM mtl_material_transactions_temp
9700 WHERE wms_task_type IS NOT NULL
9701 AND transaction_status = 2
9702 AND(
9703 wms_task_status IS NULL
9704 OR wms_task_status = 1
9705 ) --Added for task planning WB. bug#2651318
9706 ) wdtv
9707 , -- inlined wms_dispatchable_tasks_v, bug 2648133
9708 --wms_person_resource_utt_v v,
9709 (SELECT utt_emp.standard_operation_id standard_operation_id
9710 , utt_emp.resource_id ROLE
9711 , utt_eqp.resource_id equipment
9712 , utt_emp.person_id emp_id
9713 , utt_eqp.inventory_item_id eqp_id
9714 , NULL eqp_srl /* removed for bug 2095237 */
9715 , utt_emp.effective_start_date
9716 , utt_emp.effective_end_date
9717 FROM (SELECT x_utt_res1.standard_operation_id standard_operation_id
9718 , x_utt_res1.resource_id resource_id
9719 , x_emp_r.person_id
9720 , x_emp_r.effective_start_date
9721 , x_emp_r.effective_end_date
9722 FROM bom_std_op_resources x_utt_res1, bom_resources r1, bom_resource_employees x_emp_r
9723 WHERE x_utt_res1.resource_id = r1.resource_id
9724 AND r1.resource_type = 2
9725 AND x_utt_res1.resource_id = x_emp_r.resource_id) utt_emp
9726 , (SELECT x_utt_res2.standard_operation_id standard_operation_id
9727 , x_utt_res2.resource_id resource_id
9728 , x_eqp_r.inventory_item_id inventory_item_id
9729 FROM bom_std_op_resources x_utt_res2, bom_resources r2, bom_resource_equipments x_eqp_r
9730 WHERE x_utt_res2.resource_id = r2.resource_id
9731 AND r2.resource_type = 1
9732 AND x_utt_res2.resource_id = x_eqp_r.resource_id) utt_eqp
9733 WHERE utt_emp.standard_operation_id = utt_eqp.standard_operation_id(+)) v
9734 , -- inlined wms_person_resource_utt_v, bug 2648133
9735 mtl_item_locations_kfv loc
9736 , --changed to kfv bug#2742611
9737 mtl_secondary_inventories sub
9738 , mtl_txn_request_lines mol
9739 , mtl_txn_request_headers moh
9740 -- mtl_system_items msi -- bug 2648133
9741 WHERE v.emp_id = p_sign_on_emp_id -- restrict to sign on employee
9742 AND wdtv.organization_id = p_sign_on_org_id
9743 AND wdtv.wms_task_type_id = 1 -- restrict to picking tasks
9744 AND mol.header_id = moh.header_id
9745 AND moh.move_order_type = 5 -- only WIP jobs are considered : Bug 2666620 BackFlush Removed
9746 AND wdtv.user_task_type_id = v.standard_operation_id -- join task to resource view, check if user defined task type match
9747 --AND Nvl(wdtv.zone, '@@@') = Nvl(p_sign_on_zone, Nvl(wdtv.zone, '@@@'))
9748 AND NVL(wdtv.cartonization_id, -999) = NVL(p_cartonization_id, NVL(wdtv.cartonization_id, -999))
9749 AND NVL(v.eqp_id, -999) = NVL(l_sign_on_equipment_id, NVL(v.eqp_id, -999))
9750 AND wdtv.organization_id = loc.organization_id(+) -- join task to loc, outer join for tasks do not have locator
9751 AND wdtv.locator_id = loc.inventory_location_id(+)
9752 AND wdtv.ZONE = sub.secondary_inventory_name
9753 AND wdtv.organization_id = sub.organization_id
9754 AND wdtv.move_order_line_id = mol.line_id
9755 -- AND wdtv.organization_id = msi.organization_id -- bug 2648133
9756 -- AND wdtv.inventory_item_id = msi.inventory_item_id -- bug 2648133
9757 AND NOT EXISTS -- exclude child tasks for consolidated bulk tasks
9758 (
9759 SELECT NULL
9760 FROM mtl_material_transactions_temp mmtt
9761 WHERE mmtt.transaction_temp_id = wdtv.task_id
9762 AND mmtt.parent_line_id IS NOT NULL
9763 AND mmtt.wms_task_type = wdtv.wms_task_type_id)
9764 AND NOT EXISTS -- exclude tasks already dispatched
9765 (SELECT NULL
9766 FROM wms_dispatched_tasks wdt1
9767 WHERE wdt1.transaction_temp_id = wdtv.task_id
9768 AND wdt1.task_type = wdtv.wms_task_type_id)
9769 --******************
9770 AND wdtv.task_id NOT IN -- excluded skipped tasks
9771 (
9772 SELECT wdtv.task_id
9773 FROM wms_skip_task_exceptions wste, mtl_parameters mp
9774 WHERE ((SYSDATE - wste.creation_date) * 24 * 60) < mp.skip_task_waiting_minutes
9775 AND wste.task_id = wdtv.task_id
9776 AND wste.wms_task_type = NVL(l_sys_task_type, wste.wms_task_type)
9777 AND wste.organization_id = mp.organization_id)
9778 --*****************
9779 --J Addition
9780 AND wdtv.ZONE not in (
9781 SELECT wd.subinventory_code
9782 FROM wms_devices_b wd
9783 , wms_bus_event_devices wbed
9784 WHERE 1 = 1
9785 and wd.device_id = wbed.device_id
9786 AND wbed.organization_id = wd.organization_id
9787 AND wd.enabled_flag = 'Y'
9788 AND wbed.enabled_flag = 'Y'
9789 AND wbed.business_event_id = 10
9790 AND wd.subinventory_code IS NOT NULL
9791 AND wd.force_sign_on_flag = 'Y'
9792 AND wd.device_id NOT IN (SELECT device_id
9793 FROM wms_device_assignment_temp
9794 WHERE employee_id = p_sign_on_emp_id)
9795 )
9796 ORDER BY wdtv_task_priority DESC
9797 , batch_id -- DECODE (L_SEQUENCE_PICKS_ACROSS_WAVES, 2, MOL.HEADER_ID, NULL)
9798 , task_status DESC
9799 , sub_picking_order
9800 , loc_picking_order
9801 , xyz_distance
9802 , task_id1;
9803
9804 CURSOR c_task_filter(v_filter_name VARCHAR2) IS
9805 SELECT task_filter_source, task_filter_value
9806 FROM wms_task_filter_b wtf, wms_task_filter_dtl wtfd
9807 WHERE task_filter_name = v_filter_name
9808 AND wtf.task_filter_id = wtfd.task_filter_id;
9809
9810
9811 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9812 BEGIN
9813 IF (l_debug = 1) THEN
9814 print_debug('Enter dispatch_task ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
9815 END IF;
9816
9817 l_progress := '10';
9818
9819 -- This API is query only, therefore does not create a save point
9820 -- Initialize message list if p_init_msg_list is set to TRUE.
9821 IF fnd_api.to_boolean(p_init_msg_list) THEN
9822 fnd_msg_pub.initialize;
9823 END IF;
9824
9825 -- Initialize API return status to success
9826 x_return_status := fnd_api.g_ret_sts_success;
9827
9828 -- API body
9829 -- preprocess input parameters
9830
9831 IF p_sign_on_equipment_srl = 'NONE' THEN
9832 l_sign_on_equipment_srl := NULL;
9833 l_sign_on_equipment_id := -999;
9834 ELSE
9835 l_sign_on_equipment_srl := p_sign_on_equipment_srl;
9836 l_sign_on_equipment_id := p_sign_on_equipment_id;
9837 END IF;
9838
9839 -- use l_equipment_id_str to concatenate sql statement
9840 IF l_sign_on_equipment_id IS NULL THEN
9841 l_equipment_id_str := 'NULL';
9842 ELSE
9843 l_equipment_id_str := TO_CHAR(l_sign_on_equipment_id);
9844 END IF;
9845
9846 IF p_task_type = 'PICKING' THEN
9847 l_sys_task_type := 1;
9848 ELSIF p_task_type = 'EXPPICK' THEN
9849 l_sys_task_type := 1;
9850 l_is_express_pick := 1;
9851
9852 IF (l_debug = 1) THEN
9853 print_debug('Express Pick Task', 4);
9854 END IF;
9855 ELSE
9856 l_sys_task_type := NULL;
9857 END IF;
9858
9859 -- check if this call is for picking tasks or for all tasks
9860 IF p_task_type = 'DISPLAY' THEN
9861 IF (l_debug = 1) THEN
9862 print_debug('dispatch_task - DISPLAY ', 4);
9863 END IF;
9864
9865 l_progress := '20';
9866 /*
9867 l_sql_stmt :=
9868 'SELECT wdtv.task_id, wdtv.zone, wdtv.locator_id,
9869 wdtv.revision, wdtv.transaction_uom,
9870 wdtv.transaction_quantity, wdtv.lot_number, wdtv.wms_task_type_id,nvl(wdtv.task_priority, 0)
9871 FROM wms_dispatchable_tasks_v wdtv
9872 WHERE wdtv.organization_id = ' || p_sign_on_org_id ||'
9873 AND Nvl(wdtv.zone, ''@@@'') = Nvl('''|| p_sign_on_zone || ''', Nvl(wdtv.zone, ''@@@''))
9874 AND wdtv.user_task_type_id IN
9875 (
9876 SELECT standard_operation_id
9877 FROM wms_person_resource_utt_v v
9878 WHERE v.emp_id = ' || p_sign_on_emp_id ||'
9879 AND Nvl(v.eqp_srl, ''@@@'') = Nvl(''' || l_sign_on_equipment_srl || ''', Nvl(v.eqp_srl, ''@@@''))
9880 AND Nvl(v.eqp_id, -999) = Nvl(' || l_equipment_id_str ||', Nvl(v.eqp_id, -999))
9881 )
9882 --***********
9883 AND wdtv.task_id NOT IN
9884 (SELECT wdtv.task_id FROM wms_skip_task_exceptions wste, mtl_parameters mp
9885 WHERE ((SYSDATE - wste.creation_date)*24*60) < mp.skip_task_waiting_minutes
9886 AND wste.task_id = wdtv.task_id
9887 AND wste.organization_id = mp.organization_id )
9888 --************
9889 AND wdtv.task_id NOT IN
9890 (SELECT wdt1.transaction_temp_id
9891 FROM wms_dispatched_tasks wdt1
9892 -- WHERE wdt1.status = 1
9893 UNION ALL
9894 SELECT wdt2.transaction_temp_id
9895 FROM wms_exceptions wms_except, wms_dispatched_tasks wdt2
9896 WHERE wms_except.person_id = ' || p_sign_on_emp_id || '
9897 AND wdt2.task_id = wms_except.task_id
9898 AND discrepancy_type = 1
9899 )
9900 ORDER BY wdtv.pick_slip_number, nvl(wdtv.task_priority, 0), wdtv.task_id';
9901 */
9902 ELSIF(p_task_type = 'ALL'
9903 OR p_task_type = 'EXPPICK'
9904 OR p_task_type = 'PICKING') THEN -- the call is for ALL taks
9905 IF (l_debug = 1) THEN
9906 print_debug('dispatch_task -' || p_task_type, 4);
9907 END IF;
9908
9909 l_progress := '30';
9910
9911 -- select last task this operator was working on
9912 BEGIN
9913 SELECT transaction_temp_id
9914 , task_type
9915 , loaded_time
9916 INTO l_last_loaded_task_id
9917 , l_last_loaded_task_type
9918 , l_last_loaded_time
9919 FROM (SELECT transaction_temp_id
9920 , task_type
9921 , loaded_time
9922 FROM wms_dispatched_tasks wdt
9923 WHERE wdt.person_id = p_sign_on_emp_id
9924 AND wdt.loaded_time = (SELECT MAX(loaded_time)
9925 FROM wms_dispatched_tasks
9926 WHERE person_id = p_sign_on_emp_id))
9927 WHERE ROWNUM = 1; -- make sure only one task selected
9928
9929 l_progress := '31';
9930 EXCEPTION
9931 WHEN OTHERS THEN
9932 l_last_loaded_task_id := -1;
9933 END;
9934
9935 IF (l_debug = 1) THEN
9936 print_debug('dispatch_task - last loaded task : l_last_loaded_task_id => ' || l_last_loaded_task_id, 4);
9937 print_debug('dispatch_task => l_last_loaded_task_type' || l_last_loaded_task_type, 4);
9938 print_debug('dispatch_task => l_last_loaded_time' || l_last_loaded_time, 4);
9939 END IF;
9940
9941 -- select last task this operator completed
9942 BEGIN
9943 l_progress := '32';
9944
9945 SELECT transaction_id
9946 , task_type
9947 , loaded_time
9948 INTO l_last_dropoff_task_id
9949 , l_last_dropoff_task_type
9950 , l_last_dropoff_time
9951 FROM (SELECT transaction_id
9952 , task_type
9953 , loaded_time
9954 FROM wms_dispatched_tasks_history wdth
9955 WHERE wdth.person_id = p_sign_on_emp_id
9956 AND wdth.drop_off_time = (SELECT MAX(drop_off_time)
9957 FROM wms_dispatched_tasks_history
9958 WHERE person_id = p_sign_on_emp_id))
9959 WHERE ROWNUM = 1; -- make sure only one task selected
9960
9961 l_progress := '33';
9962 EXCEPTION
9963 WHEN OTHERS THEN
9964 l_last_dropoff_task_id := -1;
9965 END;
9966
9967 IF (l_debug = 1) THEN
9968 print_debug('dispatch_task - last dropoff task : l_last_dropoff_task_id => ' || l_last_dropoff_task_id, 4);
9969 print_debug('dispatch_task => l_last_dropoff_task_type' || l_last_dropoff_task_type, 4);
9970 print_debug('dispatch_task => l_last_dropoff_time' || l_last_dropoff_time, 4);
9971 END IF;
9972
9973 IF l_last_dropoff_task_id = -1
9974 AND l_last_loaded_task_id = -1 THEN
9975 l_last_task_id := -1;
9976 ELSIF l_last_dropoff_task_id = -1 THEN
9977 l_last_task_id := l_last_loaded_task_id;
9978 l_last_task_type := l_last_loaded_task_type;
9979 l_last_task_is_drop := FALSE;
9980 ELSIF l_last_loaded_task_id = -1 THEN
9981 l_last_task_id := l_last_dropoff_task_id;
9982 l_last_task_type := l_last_dropoff_task_type;
9983 l_last_task_is_drop := TRUE;
9984 ELSIF l_last_loaded_time < l_last_dropoff_time THEN
9985 l_last_task_id := l_last_dropoff_task_id;
9986 l_last_task_type := l_last_dropoff_task_type;
9987 l_last_task_is_drop := TRUE;
9988 END IF;
9989
9990 IF (l_debug = 1) THEN
9991 print_debug('dispatch_task - previous task - l_last_task_id = ' || l_last_task_id, 4);
9992 END IF;
9993
9994 -- select locator coordinates of the the last task
9995 IF l_last_task_id <> -1 THEN -- make sure there is a last task
9996 IF l_last_task_is_drop <> TRUE THEN -- task that has not been completed
9997 -- get the location from wms_dispatchable_tasks_v
9998 BEGIN
9999 l_progress := '35';
10000
10001 -- use Nvl to make sure if coordinates not defined, use 0
10002 SELECT NVL(loc.x_coordinate, 0)
10003 , NVL(loc.y_coordinate, 0)
10004 , NVL(loc.z_coordinate, 0)
10005 INTO l_cur_x
10006 , l_cur_y
10007 , l_cur_z
10008 FROM mtl_item_locations loc, wms_dispatchable_tasks_v wdtv
10009 WHERE wdtv.locator_id = loc.inventory_location_id
10010 AND wdtv.organization_id = loc.organization_id
10011 AND wdtv.task_id = l_last_task_id
10012 AND wdtv.wms_task_type_id = l_last_task_type;
10013
10014 -- Added the previous line since the task_id in the view
10015 -- might not be unique since it is the transaction_temp_id
10016 -- if it comes from MMTT but the cycle_count_entry_id if
10017 -- it comes from MTL_CYCLE_COUNT_ENTRIES for cycle counting tasks
10018 l_progress := '36';
10019 EXCEPTION
10020 WHEN OTHERS THEN
10021 -- locator definition descripency
10022 l_cur_x := 0;
10023 l_cur_y := 0;
10024 l_cur_z := 0;
10025 END;
10026 ELSE -- l_last_task_is_drop <> TRUE (completed tasks)
10027 IF l_last_task_type <> 3 THEN -- not cycle count task hence get the location from mtl_material_transactions
10028 BEGIN
10029 l_progress := '37';
10030
10031 -- use Nvl to make sure if coordinates not defined, use 0
10032 SELECT NVL(loc.x_coordinate, 0)
10033 , NVL(loc.y_coordinate, 0)
10034 , NVL(loc.z_coordinate, 0)
10035 INTO l_cur_x
10036 , l_cur_y
10037 , l_cur_z
10038 FROM mtl_item_locations loc, mtl_material_transactions mmt
10039 WHERE mmt.locator_id = loc.inventory_location_id
10040 AND mmt.organization_id = loc.organization_id
10041 AND mmt.transaction_set_id = l_last_task_id
10042 AND ROWNUM = 1;
10043
10044 l_progress := '38';
10045 EXCEPTION
10046 WHEN OTHERS THEN
10047 -- locator definition descripency
10048 l_cur_x := 0;
10049 l_cur_y := 0;
10050 l_cur_z := 0;
10051 END;
10052 ELSE -- l_last_task_type <> 3 (Cyclt Count task) hence get the location from mtl_cycle_count_entries
10053 BEGIN
10054 l_progress := '39';
10055
10056 -- use Nvl to make sure if coordinates not defined, use 0
10057 SELECT NVL(loc.x_coordinate, 0)
10058 , NVL(loc.y_coordinate, 0)
10059 , NVL(loc.z_coordinate, 0)
10060 INTO l_cur_x
10061 , l_cur_y
10062 , l_cur_z
10063 FROM mtl_item_locations loc, mtl_cycle_count_entries mcce
10064 WHERE mcce.locator_id = loc.inventory_location_id
10065 AND mcce.organization_id = loc.organization_id
10066 AND mcce.cycle_count_entry_id = l_last_task_id;
10067
10068 l_progress := '40';
10069 EXCEPTION
10070 WHEN OTHERS THEN -- adf
10071 -- locator definition descripency
10072 l_cur_x := 0;
10073 l_cur_y := 0;
10074 l_cur_z := 0;
10075 END;
10076 END IF; -- l_last_task_type <> 3
10077 END IF; -- l_last_task_is_drop <> TRUE
10078 ELSE -- there is not a previous task at all
10079 l_cur_x := 0;
10080 l_cur_y := 0;
10081 l_cur_z := 0;
10082 END IF; -- l_last_task_id <> -1
10083
10084 l_progress := '45';
10085
10086 -- Select the most optimal task
10087 -- first select eligible tasks according to employee sign on information
10088 -- order tasks by task priority, locator picking order and locator coordinates
10089 -- approximated to current locator
10090 IF (l_debug = 1) THEN
10091 print_debug('p_sign_on_emp_id => ' || p_sign_on_emp_id, 4);
10092 print_debug('p_sign_on_zone => ' || p_sign_on_zone, 4);
10093 print_debug('p_cartonization_id => ' || p_cartonization_id, 4);
10094 print_debug('l_sign_on_equipment_srl => ' || l_sign_on_equipment_srl, 4);
10095 print_debug('l_sign_on_equipment_id => ' || l_sign_on_equipment_id, 4);
10096 print_debug('l_cur_x => ' || l_cur_x, 4);
10097 print_debug('l_cur_y => ' || l_cur_y, 4);
10098 print_debug('l_cur_z => ' || l_cur_z, 4);
10099 END IF;
10100
10101 fnd_profile.get('WMS_SEQUENCE_PICKS_ACROSS_WAVES', l_sequence_picks_across_waves);
10102
10103 IF l_sequence_picks_across_waves IS NULL THEN
10104 l_sequence_picks_across_waves := 2;
10105 END IF;
10106
10107
10108 -----------------------------------
10109 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10110 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10111 -- Populate the task filter variables
10112 IF (l_debug = 1) THEN
10113 print_debug('Task Filter: ' || p_task_filter, 9);
10114 END IF;
10115
10116 FOR task_filter_rec IN c_task_filter(p_task_filter) LOOP
10117
10118 IF (l_debug = 1) THEN
10119 print_debug('Task Filter Source: ' || task_filter_rec.task_filter_source, 9);
10120 print_debug('Task Filter Value: ' || task_filter_rec.task_filter_value, 9);
10121 END IF;
10122
10123 IF task_filter_rec.task_filter_value = 'Y' THEN
10124 IF task_filter_rec.task_filter_source = 1 THEN -- Internal Order
10125 l_io_allowed := 1;
10126 ELSIF task_filter_rec.task_filter_source = 5 THEN -- Sales Order
10127 l_so_allowed := 1;
10128 ELSIF task_filter_rec.task_filter_source = 6 THEN -- Work Order
10129 l_wip_allowed := 1;
10130 END IF;
10131 END IF;
10132
10133 END LOOP;
10134
10135
10136 IF (l_debug = 1) THEN
10137 print_debug('l_so_allowed: ' || l_so_allowed, 9);
10138 print_debug('l_io_allowed: ' || l_io_allowed, 9);
10139 print_debug('l_wip_allowed: ' || l_wip_allowed, 9);
10140 END IF;
10141
10142 IF l_wip_allowed = 1 THEN
10143 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10144 IF p_sign_on_zone IS NOT NULL THEN
10145 open l_cp_ordered_tasks_SIW;
10146 ELSE OPEN l_cp_ordered_tasks_no_sub_SIW;
10147 END IF;
10148 ELSE -- only WIP
10149 IF p_sign_on_zone IS NOT NULL THEN
10150 open l_cp_ordered_tasks_W;
10151 ELSE OPEN l_cp_ordered_tasks_no_sub_W;
10152 END IF;
10153 END IF;
10154 ELSE -- only SO or IO
10155 IF p_sign_on_zone IS NOT NULL THEN
10156 open l_cp_ordered_tasks_SI;
10157 ELSE OPEN l_cp_ordered_tasks_no_sub_SI;
10158 END IF;
10159 END IF;
10160
10161 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10162 ELSE -- below patchset J
10163 ---------------------------------------
10164 -- END of patchset J APL
10165
10166 IF p_sign_on_zone IS NOT NULL THEN -- bug 2648133
10167 OPEN l_cp_curs_ordered_tasks;
10168 ELSE
10169 OPEN l_cp_curs_ordered_tasks_no_sub;
10170 END IF;
10171 END IF;
10172 l_progress := '50';
10173 --l_first_task_pick_slip_number := -1;
10174 l_ordered_tasks_count := 0;
10175
10176 LOOP -- Loop for looping through the pending eligible tasks
10177 IF (l_debug = 1) THEN
10178 print_debug('Start looping through ordered tasks: ', 4);
10179 END IF;
10180
10181 t_opt_task_id := NULL;
10182 --l_opt_task_pick_slip := NULL;
10183 t_opt_task_type := NULL;
10184 l_is_locked := FALSE;
10185 l_progress := '55';
10186
10187 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10188 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10189 IF l_wip_allowed = 1 THEN
10190 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10191 IF p_sign_on_zone IS NOT NULL THEN
10192 EXIT WHEN l_cp_ordered_tasks_SIW%NOTFOUND;
10193 FETCH l_cp_ordered_tasks_SIW BULK COLLECT INTO t_opt_task_id
10194 , t_carton_grouping_id
10195 , t_opt_task_type
10196 , t_cluster_id
10197 , t_cluster_type
10198 , t_task_priority
10199 , t_sub_code
10200 , t_sub_picking_order
10201 , t_loc_picking_order
10202 , t_xyz_distance
10203 , t_loc_concat_segs
10204 , t_task_Status
10205 , t_batch_id
10206 , t_effective_start_date
10207 , t_effective_end_date
10208 , t_person_resource_id
10209 , t_machine_resource_id LIMIT blk_limit;
10210
10211 ELSE
10212 EXIT WHEN l_cp_ordered_tasks_no_sub_SIW%NOTFOUND;
10213 FETCH l_cp_ordered_tasks_no_sub_SIW BULK COLLECT INTO t_opt_task_id
10214 , t_carton_grouping_id
10215 , t_opt_task_type
10216 , t_cluster_id
10217 , t_cluster_type
10218 , t_task_priority
10219 , t_sub_code
10220 , t_sub_picking_order
10221 , t_loc_picking_order
10222 , t_xyz_distance
10223 , t_loc_concat_segs
10224 , t_task_Status
10225 , t_batch_id
10226 , t_effective_start_date
10227 , t_effective_end_date
10228 , t_person_resource_id
10229 , t_machine_resource_id LIMIT blk_limit;
10230
10231 END IF;
10232 ELSE -- only WIP
10233 IF p_sign_on_zone IS NOT NULL THEN
10234 EXIT WHEN l_cp_ordered_tasks_W%NOTFOUND;
10235 FETCH l_cp_ordered_tasks_W BULK COLLECT INTO t_opt_task_id
10236 , t_carton_grouping_id
10237 , t_opt_task_type
10238 , t_cluster_id
10239 , t_cluster_type
10240 , t_task_priority
10241 , t_sub_code
10242 , t_sub_picking_order
10243 , t_loc_picking_order
10244 , t_xyz_distance
10245 , t_loc_concat_segs
10246 , t_task_Status
10247 , t_batch_id
10248 , t_effective_start_date
10249 , t_effective_end_date
10250 , t_person_resource_id
10251 , t_machine_resource_id LIMIT blk_limit;
10252
10253 ELSE
10254 EXIT WHEN l_cp_ordered_tasks_no_sub_W%NOTFOUND;
10255 FETCH l_cp_ordered_tasks_no_sub_W BULK COLLECT INTO t_opt_task_id
10256 , t_carton_grouping_id
10257 , t_opt_task_type
10258 , t_cluster_id
10259 , t_cluster_type
10260 , t_task_priority
10261 , t_sub_code
10262 , t_sub_picking_order
10263 , t_loc_picking_order
10264 , t_xyz_distance
10265 , t_loc_concat_segs
10266 , t_task_Status
10267 , t_batch_id
10268 , t_effective_start_date
10269 , t_effective_end_date
10270 , t_person_resource_id
10271 , t_machine_resource_id LIMIT blk_limit;
10272
10273 END IF;
10274 END IF;
10275 ELSE -- only SO or IO
10276 IF p_sign_on_zone IS NOT NULL THEN
10277 EXIT WHEN l_cp_ordered_tasks_SI%NOTFOUND;
10278 FETCH l_cp_ordered_tasks_SI BULK COLLECT INTO t_opt_task_id
10279 , t_carton_grouping_id
10280 , t_opt_task_type
10281 , t_cluster_id
10282 , t_cluster_type
10283 , t_task_priority
10284 , t_sub_code
10285 , t_sub_picking_order
10286 , t_loc_picking_order
10287 , t_xyz_distance
10288 , t_loc_concat_segs
10289 , t_task_Status
10290 , t_batch_id
10291 , t_effective_start_date
10292 , t_effective_end_date
10293 , t_person_resource_id
10294 , t_machine_resource_id LIMIT blk_limit;
10295
10296 ELSE
10297 EXIT WHEN l_cp_ordered_tasks_no_sub_SI%NOTFOUND;
10298 FETCH l_cp_ordered_tasks_no_sub_SI BULK COLLECT INTO t_opt_task_id
10299 , t_carton_grouping_id
10300 , t_opt_task_type
10301 , t_cluster_id
10302 , t_cluster_type
10303 , t_task_priority
10304 , t_sub_code
10305 , t_sub_picking_order
10306 , t_loc_picking_order
10307 , t_xyz_distance
10308 , t_loc_concat_segs
10309 , t_task_Status
10310 , t_batch_id
10311 , t_effective_start_date
10312 , t_effective_end_date
10313 , t_person_resource_id
10314 , t_machine_resource_id LIMIT blk_limit;
10315 END IF;
10316 END IF;
10317
10318 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10319 ELSE -- below patchset J
10320 IF p_sign_on_zone IS NOT NULL THEN -- bug 2648133
10321 EXIT WHEN l_cp_curs_ordered_tasks%NOTFOUND;
10322 FETCH l_cp_curs_ordered_tasks BULK COLLECT INTO t_opt_task_id
10323 , t_carton_grouping_id
10324 , t_opt_task_type
10325 , t_cluster_id
10326 , t_cluster_type
10327 , t_task_priority
10328 , t_sub_code
10329 , t_sub_picking_order
10330 , t_loc_picking_order
10331 , t_xyz_distance
10332 , t_loc_concat_segs LIMIT blk_limit;
10333 ELSE --sign on zone is null
10334 EXIT WHEN l_cp_curs_ordered_tasks_no_sub%NOTFOUND;
10335 FETCH l_cp_curs_ordered_tasks_no_sub BULK COLLECT INTO t_opt_task_id
10336 , t_carton_grouping_id
10337 , t_opt_task_type
10338 , t_cluster_id
10339 , t_cluster_type
10340 , t_task_priority
10341 , t_sub_code
10342 , t_sub_picking_order
10343 , t_loc_picking_order
10344 , t_xyz_distance
10345 , t_loc_concat_segs LIMIT blk_limit;
10346 END IF;
10347 END IF; -- end the patchset J checking
10348
10349 l_progress := '60';
10350
10351 FOR idx IN 1 .. t_opt_task_id.COUNT LOOP -- looping through the current batch of tasks
10352 IF (l_debug = 1) THEN
10353 print_debug('l_opt_task_id => ' || t_opt_task_id(idx), 4);
10354 print_debug('l_carton_grouping_id => ' || t_carton_grouping_id(idx), 4);
10355 print_debug('l_opt_task_type => ' || t_opt_task_type(idx), 4);
10356 print_debug('l_cluster_id => ' || t_cluster_id(idx), 4);
10357 print_debug('l_cluster_type => ' || t_cluster_type(idx), 4);
10358 END IF;
10359
10360 BEGIN
10361 l_cluster_exists := FALSE;
10362 l_progress := '61';
10363
10364 FOR i IN 1 .. cluster_table.COUNT LOOP -- Check whether the cluster exists already in the cluster table
10365 IF (cluster_table(i).cluster_id = t_cluster_id(idx)
10366 AND cluster_table(i).cluster_type = t_cluster_type(idx)) THEN
10367 -- This cluster had been already dispatched in this session
10368 l_cluster_exists := TRUE;
10369 EXIT;
10370 END IF;
10371 END LOOP;
10372
10373 l_progress := '62';
10374 END;
10375
10376 l_progress := '63';
10377
10378 IF t_cluster_id(idx) IS NOT NULL THEN -- dispatch tasks only if cluster exists
10379 IF l_cluster_exists THEN -- Cluster already exists so dispatch this task too.
10380 IF (l_debug = 1) THEN
10381 print_debug(' Cluster already exists so dispatching this task too', 4);
10382 END IF;
10383
10384 -- Test if this task is locked by any other user
10385 BEGIN
10386 SELECT mmtt.transaction_temp_id
10387 INTO t_opt_task_id(idx)
10388 FROM mtl_material_transactions_temp mmtt
10389 WHERE mmtt.transaction_temp_id = t_opt_task_id(idx)
10390 FOR UPDATE NOWAIT;
10391 EXCEPTION
10392 WHEN OTHERS THEN
10393 IF (l_debug = 1) THEN
10394 print_debug('This task is locked by other user. ', 4);
10395 END IF;
10396
10397 l_is_locked := TRUE;
10398 END;
10399
10400 IF l_is_locked <> TRUE THEN
10401 l_ordered_tasks_count := l_ordered_tasks_count + 1;
10402
10403 --l_first_task_pick_slip_number := l_opt_task_pick_slip;
10404
10405 IF (l_debug = 1) THEN
10406 print_debug(
10407 'This task has the same cluster details of already dispatched task. l_ordered_tasks_count => ' || l_ordered_tasks_count
10408 , 4
10409 );
10410 END IF;
10411
10412 l_progress := '72';
10413 -- check if this is queued task or not
10414 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10415 IF (l_debug = 1) THEN
10416 print_debug('Insert task '||t_opt_task_id(idx)||' Effective start date'||t_effective_start_date(idx),4);
10417 END IF;
10418 INSERT INTO wms_ordered_tasks
10419 (
10420 task_id
10421 , wms_task_type
10422 , task_sequence_id
10423 , effective_start_date
10424 , effective_end_date
10425 , person_resource_id
10426 , machine_resource_id
10427 )
10428 VALUES (
10429 t_opt_task_id(idx)
10430 , t_opt_task_type(idx)
10431 , l_ordered_tasks_count
10432 , t_effective_start_date(idx)
10433 , t_effective_end_date(idx)
10434 , t_person_resource_id(idx)
10435 , t_machine_resource_id(idx)
10436 );
10437 ELSE -- before patchset J
10438 INSERT INTO wms_ordered_tasks
10439 (
10440 task_id
10441 , wms_task_type
10442 , task_sequence_id
10443 )
10444 VALUES (
10445 t_opt_task_id(idx)
10446 , t_opt_task_type(idx)
10447 , l_ordered_tasks_count
10448 );
10449 END IF;
10450
10451 l_progress := '73';
10452 END IF;
10453 ELSE -- Cluster Doesn't Exist
10454 IF (l_debug = 1) THEN
10455 print_debug(' Cluster doesnot exists, so a new task', 4);
10456 END IF;
10457
10458 IF l_cluster_count < p_max_clusters THEN -- Maximum clusters not reached and hence can dispatch the task from this cluster
10459 IF (l_debug = 1) THEN
10460 print_debug(' Max Cluster not reached hence can dispatch this cluster ', 4);
10461 END IF;
10462
10463 -- Test if this task is locked by any other user
10464 BEGIN
10465 SELECT mmtt.transaction_temp_id
10466 INTO t_opt_task_id(idx)
10467 FROM mtl_material_transactions_temp mmtt
10468 WHERE mmtt.transaction_temp_id = t_opt_task_id(idx)
10469 FOR UPDATE NOWAIT;
10470 EXCEPTION
10471 WHEN OTHERS THEN
10472 IF (l_debug = 1) THEN
10473 print_debug('This task is locked by other user. ', 4);
10474 END IF;
10475
10476 l_is_locked := TRUE;
10477 END;
10478
10479 IF l_is_locked <> TRUE THEN
10480 l_ordered_tasks_count := l_ordered_tasks_count + 1;
10481
10482 IF (l_debug = 1) THEN
10483 print_debug('This task is from a new cluster. l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
10484 END IF;
10485
10486 l_progress := '74';
10487
10488 -- check if this is queued task or not
10489 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10490 IF (l_debug = 1) THEN
10491 print_debug('Insert task '||t_opt_task_id(idx)||' Effective start date'||
10492 t_effective_start_date(idx),4);
10493 END IF;
10494 INSERT INTO wms_ordered_tasks
10495 (
10496 task_id
10497 , wms_task_type
10498 , task_sequence_id
10499 , effective_start_date
10500 , effective_end_date
10501 , person_resource_id
10502 , machine_resource_id
10503 )
10504 VALUES (
10505 t_opt_task_id(idx)
10506 , t_opt_task_type(idx)
10507 , l_ordered_tasks_count
10508 , t_effective_start_date(idx)
10509 , t_effective_end_date(idx)
10510 , t_person_resource_id(idx)
10511 , t_machine_resource_id(idx)
10512 );
10513 ELSE -- before patchset J
10514 INSERT INTO wms_ordered_tasks
10515 (
10516 task_id
10517 , wms_task_type
10518 , task_sequence_id
10519 )
10520 VALUES (
10521 t_opt_task_id(idx)
10522 , t_opt_task_type(idx)
10523 , l_ordered_tasks_count
10524 );
10525 END IF;
10526
10527 l_progress := '75';
10528
10529 IF t_cluster_type(idx) = 'D' THEN
10530 l_deliveries_list := l_deliveries_list || ', ' || t_cluster_id(idx);
10531
10532 IF (l_debug = 1) THEN
10533 print_debug(' building deliveries list ' || l_deliveries_list, 4);
10534 END IF;
10535
10536 IF t_carton_grouping_id(idx) IS NOT NULL THEN
10537 l_cartons_list := l_cartons_list || ', ' || t_carton_grouping_id(idx);
10538
10539 IF (l_debug = 1) THEN
10540 print_debug(' deliveries exists still building cartons list ' || l_cartons_list, 4);
10541 END IF;
10542 END IF;
10543 ELSE
10544 l_cartons_list := l_cartons_list || ', ' || t_cluster_id(idx);
10545
10546 IF (l_debug = 1) THEN
10547 print_debug(' building cartons list ' || l_cartons_list, 4);
10548 END IF;
10549 END IF;
10550
10551 --Increase the clusters dispatched count
10552 l_cluster_count := l_cluster_count + 1;
10553 --Store this cluster details in the cluster_table
10554 cluster_table(l_cluster_count).cluster_id := t_cluster_id(idx);
10555 cluster_table(l_cluster_count).cluster_type := t_cluster_type(idx);
10556 END IF;
10557 ELSE -- Maxmimum Clusters reached, hence can't dispatch this task so ignore it.
10558 IF (l_debug = 1) THEN
10559 print_debug('Max Clusters reached and hence ignoring this task ', 4);
10560 END IF;
10561
10562 NULL;
10563 END IF;
10564 END IF;
10565 END IF;
10566 END LOOP; -- bulk collect loop
10567 END LOOP; -- task dispatching loop
10568
10569 IF l_deliveries_list IS NOT NULL THEN --append the starting and ending braces to deliveries list
10570 l_deliveries_list := '( -999 ' || l_deliveries_list || ' ) ';
10571
10572 IF (l_debug = 1) THEN
10573 print_debug(' final deliveries list ' || l_deliveries_list, 4);
10574 END IF;
10575
10576 x_deliveries_list := l_deliveries_list;
10577 END IF;
10578
10579 IF l_cartons_list IS NOT NULL THEN --append the starting and ending braces to cartons list
10580 l_cartons_list := '( -999 ' || l_cartons_list || ' ) ';
10581
10582 IF (l_debug = 1) THEN
10583 print_debug(' final cartons list ' || l_cartons_list, 4);
10584 END IF;
10585
10586 x_cartons_list := l_cartons_list;
10587 END IF;
10588
10589 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL THEN
10590 IF (l_debug = 1) THEN print_debug('PATCHSET J APL START',4); END IF;
10591 IF l_wip_allowed = 1 THEN
10592 If l_so_allowed = 1 or l_io_allowed = 1 then -- any of the three types
10593 IF p_sign_on_zone IS NOT NULL THEN
10594 close l_cp_ordered_tasks_SIW;
10595 ELSE close l_cp_ordered_tasks_no_sub_SIW;
10596 END IF;
10597 ELSE -- only WIP
10598 IF p_sign_on_zone IS NOT NULL THEN
10599 close l_cp_ordered_tasks_W;
10600 ELSE close l_cp_ordered_tasks_no_sub_W;
10601 END IF;
10602 END IF;
10603 ELSE -- only SO or IO
10604 IF p_sign_on_zone IS NOT NULL THEN
10605 close l_cp_ordered_tasks_SI;
10606 ELSE close l_cp_ordered_tasks_no_sub_SI;
10607 END IF;
10608 END IF;
10609
10610 IF (l_debug = 1) THEN print_debug('PATCHSET J APL END',4); END IF;
10611 END IF;
10612
10613 IF l_cp_curs_ordered_tasks%ISOPEN THEN
10614 CLOSE l_cp_curs_ordered_tasks;
10615 END IF;
10616
10617 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
10618 CLOSE l_cp_curs_ordered_tasks_no_sub;
10619 END IF;
10620
10621 IF (l_debug = 1) THEN
10622 print_debug('Total task dispatched: l_ordered_tasks_count => ' || l_ordered_tasks_count, 4);
10623 END IF;
10624
10625 IF l_ordered_tasks_count = 0 THEN
10626 fnd_message.set_name('WMS', 'WMS_TASK_NO_ELIGIBLE_TASKS');
10627 fnd_msg_pub.ADD;
10628
10629 IF (l_debug = 1) THEN
10630 print_debug('dispatch_task - No eligible picking tasks ', 4);
10631 END IF;
10632
10633 RAISE fnd_api.g_exc_error;
10634 END IF;
10635
10636 l_progress := '90';
10637 END IF; -- end task type check if
10638
10639 -- open reference cursor for this statement
10640
10641 IF (l_debug = 1) THEN
10642 print_debug('dispatch_task 120 - before opeing ref cursor ', 4);
10643 END IF;
10644
10645 l_progress := '110';
10646 -- bug 2648133, changed to static SQL and query against base tables
10647 --OPEN x_task_cur FOR l_sql_stmt;
10648 OPEN x_task_cur FOR
10649 SELECT mmtt.transaction_temp_id task_id
10650 , mmtt.subinventory_code ZONE
10651 , mmtt.locator_id locator_id
10652 , mmtt.revision revision
10653 , mmtt.transaction_uom transaction_uom
10654 , mmtt.transaction_quantity transaction_quantity
10655 , '' lot_number
10656 , mmtt.wms_task_type wms_task_type_id
10657 , mmtt.task_priority task_priority
10658 , mmtt.operation_plan_id,
10659 mmtt.standard_operation_id,
10660 wot.effective_start_date,
10661 wot.effective_end_date,
10662 wot.person_resource_id,
10663 wot.machine_resource_id,
10664 mmtt.move_order_line_id
10665 FROM mtl_material_transactions_temp mmtt, wms_ordered_tasks wot
10666 WHERE mmtt.wms_task_type IS NOT NULL
10667 AND mmtt.transaction_status = 2
10668 AND mmtt.transaction_temp_id = wot.task_id
10669 AND mmtt.transaction_temp_id > 0
10670 ORDER BY wot.task_sequence_id;
10671 l_progress := '120';
10672 EXCEPTION
10673 WHEN fnd_api.g_exc_error THEN
10674 x_return_status := fnd_api.g_ret_sts_error;
10675
10676 IF l_cp_curs_ordered_tasks%ISOPEN THEN
10677 CLOSE l_cp_curs_ordered_tasks;
10678 END IF;
10679
10680 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
10681 CLOSE l_cp_curs_ordered_tasks_no_sub;
10682 END IF;
10683
10684 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10685
10686 IF (l_debug = 1) THEN
10687 print_debug('dispatch_task: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10688 END IF;
10689 WHEN fnd_api.g_exc_unexpected_error THEN
10690 x_return_status := fnd_api.g_ret_sts_unexp_error;
10691
10692 IF l_cp_curs_ordered_tasks%ISOPEN THEN
10693 CLOSE l_cp_curs_ordered_tasks;
10694 END IF;
10695
10696 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
10697 CLOSE l_cp_curs_ordered_tasks_no_sub;
10698 END IF;
10699
10700 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10701
10702 IF (l_debug = 1) THEN
10703 print_debug('dispatch_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10704 END IF;
10705 WHEN OTHERS THEN
10706 x_return_status := fnd_api.g_ret_sts_unexp_error;
10707
10708 IF l_cp_curs_ordered_tasks%ISOPEN THEN
10709 CLOSE l_cp_curs_ordered_tasks;
10710 END IF;
10711
10712 IF l_cp_curs_ordered_tasks_no_sub%ISOPEN THEN -- bug 2648133
10713 CLOSE l_cp_curs_ordered_tasks_no_sub;
10714 END IF;
10715
10716 IF SQLCODE IS NOT NULL THEN
10717 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.dispatch_task', l_progress, SQLCODE);
10718 END IF;
10719
10720 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10721
10722 IF (l_debug = 1) THEN
10723 print_debug('dispatch_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10724 END IF;
10725 END dispatch_task; --overloaded dispatch_Task for cluster picking
10726
10727
10728 FUNCTION min_num(a NUMBER, b NUMBER)
10729 RETURN NUMBER IS
10730 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
10731 BEGIN
10732 IF (a <= b) THEN
10733 RETURN a;
10734 ELSE
10735 RETURN b;
10736 END IF;
10737 END min_num;
10738
10739 PROCEDURE split_tasks(
10740 p_api_version NUMBER
10741 , p_move_order_header_id NUMBER
10742 , p_commit VARCHAR2 := fnd_api.g_false
10743 , x_return_status OUT NOCOPY VARCHAR2
10744 , x_msg_count OUT NOCOPY NUMBER
10745 , x_msg_data OUT NOCOPY VARCHAR2
10746 ) IS
10747 l_api_name VARCHAR2(30) := 'split_tasks';
10748 l_transaction_temp_id NUMBER;
10749 l_return_status VARCHAR2(1);
10750 l_msg_count NUMBER;
10751 l_msg_data VARCHAR2(400);
10752 l_progress VARCHAR2(10);
10753 l_move_order_type NUMBER;
10754
10755 CURSOR task_list IS
10756 SELECT mmtt.transaction_temp_id
10757 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
10758 WHERE mmtt.move_order_line_id = mol.line_id
10759 AND mol.header_id = p_move_order_header_id;
10760
10761
10762 ---- Patchset J, bulk picking -------------
10763 CURSOR task_list_bulk IS
10764 SELECT mmtt.transaction_temp_id
10765 FROM wms_cartonization_temp mmtt
10766 WHERE
10767 mmtt.parent_line_id is null -- non bulked tasks
10768 OR mmtt.parent_line_id = mmtt.transaction_temp_id; -- parent line only
10769 ---- End of Patchset J, bulk picking -------------
10770
10771
10772 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
10773 BEGIN
10774 -- Initialize API return status to success
10775 x_return_status := fnd_api.g_ret_sts_success;
10776
10777 IF (l_debug = 1) THEN
10778 print_debug('Enter split_tasks 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10779 END IF;
10780
10781 -- changed for patchset J bulk picking -----------
10782 IF p_move_order_header_id <> -1 THEN
10783 SELECT move_order_type
10784 INTO l_move_order_type
10785 FROM mtl_txn_request_headers
10786 WHERE header_id = p_move_order_header_id;
10787
10788 if (l_debug = 1) then print_debug('Move order type:'||l_move_order_type,4);
10789 end if;
10790 ELSE
10791 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
10792 l_move_order_type := G_MOVE_ORDER_PICK_WAVE;
10793 if (l_debug = 1) then print_debug('calling from the conconcurrent program for so ...',4);
10794 -- print_debug('PATCHSET J-- BULK PICKING --END ',4);
10795 end if;
10796 END IF;
10797
10798 -- end of change for patchset J bulk picking ------------------
10799
10800 l_progress := '10';
10801 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
10802 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
10803 OPEN task_list_bulk;
10804 ELSE
10805 OPEN task_list;
10806 END IF;
10807 l_progress := '20';
10808
10809 LOOP
10810 l_progress := '30';
10811 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL and
10812 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
10813 FETCH task_list_bulk INTO l_transaction_temp_id;
10814 EXIT WHEN task_list_bulk%NOTFOUND;
10815 else
10816 FETCH task_list INTO l_transaction_temp_id;
10817 EXIT WHEN task_list%NOTFOUND;
10818 end if;
10819
10820 IF (l_debug = 1) THEN
10821 print_debug('split_tasks 20 split task with l_transaction_temp_id = ' || l_transaction_temp_id, 1);
10822 END IF;
10823
10824 l_progress := '40';
10825 split_task(
10826 p_api_version => 1.0
10827 , p_task_id => l_transaction_temp_id
10828 , x_return_status => l_return_status
10829 , x_msg_count => l_msg_count
10830 , x_msg_data => l_msg_data
10831 );
10832
10833 IF l_return_status = fnd_api.g_ret_sts_error THEN
10834 IF (l_debug = 1) THEN
10835 print_debug('split_tasks 30 - split_task RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
10836 END IF;
10837
10838 -- RAISE fnd_api.g_exc_error;
10839 -- in case of error for one task, should continue for another task
10840 END IF;
10841
10842 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
10843 IF (l_debug = 1) THEN
10844 print_debug('split_tasks 40 - split_task RAISE FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
10845 END IF;
10846
10847 RAISE fnd_api.g_exc_unexpected_error;
10848 END IF;
10849 END LOOP;
10850
10851 l_progress := '50';
10852 if task_list_bulk%ISOPEN then
10853 CLOSE task_list_bulk;
10854 else
10855 CLOSE task_list;
10856 end if;
10857 l_progress := '60';
10858
10859 IF (l_debug = 1) THEN
10860 print_debug('split_tasks 50 complete' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10861 END IF;
10862 EXCEPTION
10863 WHEN fnd_api.g_exc_error THEN
10864 x_return_status := fnd_api.g_ret_sts_error;
10865 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10866
10867 IF (l_debug = 1) THEN
10868 print_debug('split_tasks: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10869 END IF;
10870 WHEN fnd_api.g_exc_unexpected_error THEN
10871 x_return_status := fnd_api.g_ret_sts_unexp_error;
10872 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10873
10874 IF (l_debug = 1) THEN
10875 print_debug('split_tasks: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10876 END IF;
10877 WHEN OTHERS THEN
10878 x_return_status := fnd_api.g_ret_sts_unexp_error;
10879
10880 IF SQLCODE IS NOT NULL THEN
10881 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.split_tasks', l_progress, SQLCODE);
10882 END IF;
10883
10884 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
10885
10886 IF (l_debug = 1) THEN
10887 print_debug('split_tasks: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10888 END IF;
10889 END split_tasks;
10890
10891 FUNCTION is_equipment_cap_exceeded(
10892 p_standard_operation_id IN NUMBER
10893 , p_item_id IN NUMBER
10894 , p_organization_id IN NUMBER
10895 , p_txn_qty IN NUMBER
10896 , p_txn_uom_code IN VARCHAR2
10897 )
10898 RETURN VARCHAR2 IS
10899 l_item_prim_uom_code VARCHAR2(3);
10900 l_txn_pri_uom_ratio NUMBER;
10901 l_equip_vol NUMBER;
10902 l_equip_weight NUMBER;
10903 l_item_vol NUMBER;
10904 l_item_weight NUMBER;
10905 l_equip_v_uom VARCHAR2(3);
10906 l_equip_w_uom VARCHAR2(3);
10907 l_item_v_uom VARCHAR2(3);
10908 l_item_w_uom VARCHAR2(3);
10909 l_eq_it_v_uom_ratio NUMBER;
10910 l_eq_it_w_uom_ratio NUMBER;
10911 l_min_cap NUMBER := -1;
10912 l_min_cap_temp NUMBER;
10913 l_progress VARCHAR2(10);
10914
10915 CURSOR l_capcity_cur IS
10916 SELECT equip.internal_volume equip_vol
10917 , -- equipment volume capacity
10918 equip.maximum_load_weight equip_weight
10919 , -- equipment weight capacity
10920 item.unit_volume item_vol
10921 , -- item unit volume
10922 item.unit_weight item_weight
10923 , -- item unit weight
10924 equip.volume_uom_code equip_v_uom
10925 , -- equipment volumn UOM code
10926 equip.weight_uom_code equip_w_uom
10927 , -- equipment weight UOM code
10928 item.volume_uom_code item_v_uom
10929 , -- item volume UOM code
10930 item.weight_uom_code item_w_uom -- item weight UOM code
10931 FROM mtl_system_items equip
10932 , mtl_system_items item
10933 , bom_resource_equipments res_equip
10934 , bom_resources res
10935 , bom_std_op_resources tt_x_res
10936 WHERE tt_x_res.standard_operation_id = p_standard_operation_id --join task with task_type-resource x-ref
10937 AND tt_x_res.resource_id = res.resource_id -- join with resource
10938 AND res.resource_type = 1 -- resource type for equipment
10939 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
10940 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
10941 AND equip.organization_id = res_equip.organization_id
10942 AND item.inventory_item_id = p_item_id -- join with item for the item that is transfered
10943 AND item.organization_id = p_organization_id;
10944
10945 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
10946 BEGIN
10947 IF (l_debug = 1) THEN
10948 print_debug('Enter is_equipment_cap_exceeded 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
10949 END IF;
10950
10951 l_progress := '10';
10952
10953 SELECT primary_uom_code
10954 INTO l_item_prim_uom_code
10955 FROM mtl_system_items
10956 WHERE inventory_item_id = p_item_id
10957 AND organization_id = p_organization_id;
10958
10959 -- compute conversion rate between transaction UOM and item primary UOM
10960 inv_convert.inv_um_conversion(from_unit => p_txn_uom_code, to_unit => l_item_prim_uom_code, item_id => p_item_id
10961 , uom_rate => l_txn_pri_uom_ratio);
10962
10963 IF l_txn_pri_uom_ratio = -99999 THEN -- uom conversion failure
10964 IF (l_debug = 1) THEN
10965 print_debug('is_equipment_cap_exceeded 20 - txn/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
10966 END IF;
10967
10968 RETURN 'N';
10969 END IF;
10970
10971 IF (l_debug = 1) THEN
10972 print_debug('is_equipment_cap_exceeded 30 - UOM conversion data:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
10973 END IF;
10974
10975 IF (l_debug = 1) THEN
10976 print_debug('l_txn_pri_uom_ratio => ' || l_txn_pri_uom_ratio, 4);
10977 END IF;
10978
10979 -- Query minimum equipment capacity in terms of transaction UOM
10980 -- The minimum of the volumn and weight capacity is used
10981 -- If no equipment capacity or item unit volumn or weight defined,
10982 -- do not split
10983 -- NEED FURTHER consideration for container item:
10984 -- should check unit volume and content weight ???
10985
10986 l_progress := '20';
10987 OPEN l_capcity_cur;
10988 l_progress := '30';
10989
10990 LOOP
10991 l_progress := '40';
10992 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
10993 , l_item_w_uom;
10994 l_progress := '50';
10995 EXIT WHEN l_capcity_cur%NOTFOUND;
10996 -- get the conversion ratio between equipment and item volume UOM
10997 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);
10998
10999 IF l_eq_it_v_uom_ratio = -99999 THEN -- uom conversion failure
11000 IF (l_debug = 1) THEN
11001 print_debug('is_equipment_cap_exceeded 40 - eqp/item volume uom ratio calculation failed'
11002 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11003 , 4);
11004 END IF;
11005 END IF;
11006
11007 -- get the conversion ratio between equipment and item weight UOM
11008 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);
11009
11010 IF l_eq_it_w_uom_ratio = -99999 THEN -- uom conversion failure
11011 IF (l_debug = 1) THEN
11012 print_debug('is_equipment_cap_exceeded 50 - eqp/item weight uom ratio calculation failed'
11013 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11014 , 4);
11015 END IF;
11016 END IF;
11017
11018 IF (l_equip_vol IS NOT NULL
11019 AND l_item_vol IS NOT NULL
11020 AND l_eq_it_v_uom_ratio <> -99999)
11021 OR(l_equip_weight IS NOT NULL
11022 AND l_item_weight IS NOT NULL
11023 AND l_eq_it_w_uom_ratio <> -99999) THEN
11024 IF l_eq_it_v_uom_ratio = -99999 THEN -- invalid volume UOM conversion
11025 -- compute equipment capacity using weight
11026 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
11027 ELSIF l_eq_it_w_uom_ratio = -9999 THEN -- invalid weight conversion
11028 -- compute equipment capacity using volume
11029 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
11030 ELSE -- both weight and volume defined
11031 -- compute the minimum of volume capacity and weight capacity
11032 -- transfer the capacity to transaction UOM
11033 l_min_cap_temp :=
11034 TRUNC(
11035 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))
11036 / l_txn_pri_uom_ratio
11037 );
11038 END IF;
11039
11040 IF (l_min_cap = -1)
11041 OR(l_min_cap > l_min_cap_temp) THEN
11042 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
11043 END IF;
11044 ELSE -- neither of weight or volume capacity is properly defined
11045 IF (l_debug = 1) THEN
11046 print_debug('is_equipment_cap_exceeded 60 - invalid capacity for a particulcar equipment'
11047 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
11048 , 4);
11049 END IF;
11050 END IF;
11051 END LOOP;
11052
11053 l_progress := '60';
11054 CLOSE l_capcity_cur;
11055 l_progress := '70';
11056
11057 IF l_min_cap <= 0 THEN -- min capcity is not properly queried
11058 IF (l_debug = 1) THEN
11059 print_debug('is_equipment_cap_exceeded 70 - invalid capacity for a ALL equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11060 END IF;
11061
11062 RETURN 'N';
11063 ELSIF TRUNC(l_min_cap) < TRUNC(p_txn_qty) THEN
11064 IF (l_debug = 1) THEN
11065 print_debug('is_equipment_cap_exceeded 75 - equipment capacity exceeded' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11066 END IF;
11067
11068 RETURN 'Y';
11069 ELSE
11070 IF (l_debug = 1) THEN
11071 print_debug('is_equipment_cap_exceeded 80 - equipment capacity not exceeded' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
11072 END IF;
11073
11074 RETURN 'N';
11075 END IF;
11076 EXCEPTION
11077 WHEN OTHERS THEN
11078 IF SQLCODE IS NOT NULL THEN
11079 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.is_equipment_cap_exceeded', l_progress, SQLCODE);
11080 END IF;
11081
11082 IF (l_debug = 1) THEN
11083 print_debug('is_equipment_cap_exceeded: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
11084 END IF;
11085
11086 RETURN 'N';
11087 END is_equipment_cap_exceeded;
11088
11089
11090 PROCEDURE consolidate_bulk_tasks(
11091 p_api_version IN NUMBER
11092 , p_commit IN VARCHAR2 := fnd_api.g_false
11093 , x_return_status OUT NOCOPY VARCHAR2
11094 , x_msg_count OUT NOCOPY NUMBER
11095 , x_msg_data OUT NOCOPY VARCHAR2
11096 , p_move_order_header_id IN NUMBER
11097 ) IS
11098 l_new_txn_temp_id NUMBER;
11099 l_last_update_date DATE;
11100 l_last_updated_by NUMBER;
11101 l_creation_date DATE;
11102 l_created_by NUMBER;
11103 l_inventory_item_id NUMBER;
11104 l_revision VARCHAR2(30);
11105 l_organization_id NUMBER;
11106 l_subinventory_code VARCHAR2(30);
11107 l_locator_id NUMBER;
11108 l_transaction_quantity NUMBER;
11109 l_primary_quantity NUMBER;
11110 l_transaction_uom VARCHAR2(3);
11111 l_transaction_type_id NUMBER;
11112 l_transaction_action_id NUMBER;
11113 l_transaction_source_type_id NUMBER;
11114 l_transaction_date DATE;
11115 l_acct_period_id NUMBER;
11116 l_pick_slip_number NUMBER;
11117 l_move_order_line_id NUMBER;
11118 l_to_org_id NUMBER;
11119 l_to_sub VARCHAR2(30);
11120 l_to_loc_id NUMBER;
11121 l_wms_task_type NUMBER;
11122 l_standard_operation_id NUMBER;
11123 l_task_priority NUMBER;
11124 l_cost_group_id NUMBER;
11125 l_transaction_header_id NUMBER;
11126 l_container_item_id NUMBER;
11127 l_cartonization_id NUMBER;
11128 l_operation_plan_id NUMBER;
11129 l_carton_grouping_id NUMBER;
11130 l_wms_task_status NUMBER;
11131
11132 l_parent_task_count NUMBER := 0;
11133 l_move_order_type NUMBER;
11134 l_api_name VARCHAR2(30) := 'consolidate_bulk_tasks';
11135 l_primary_uom_code VARCHAR2(3);
11136 l_lot_control_code NUMBER;
11137 l_serial_control_code NUMBER;
11138 l_serial_allocated_flag VARCHAR2(1);
11139
11140 CURSOR task_list IS
11141 SELECT SYSDATE last_update_date
11142 , g_user_id last_updated_by
11143 , SYSDATE creation_date
11144 , g_user_id created_by
11145 , mmtt.inventory_item_id
11146 , mmtt.revision
11147 , mmtt.organization_id
11148 , mmtt.subinventory_code
11149 , mmtt.locator_id
11150 , SUM(mmtt.transaction_quantity)
11151 , SUM(mmtt.primary_quantity)
11152 , mmtt.transaction_uom
11153 , mmtt.transaction_type_id
11154 , mmtt.transaction_action_id
11155 , mmtt.transaction_source_type_id
11156 , MAX(mmtt.transaction_date)
11157 , MAX(mmtt.acct_period_id)
11158 , MIN(mmtt.pick_slip_number) -- the earliest created pick slip
11159 , MIN(mmtt.move_order_line_id) -- any line_id within this header
11160 , mmtt.transfer_organization
11161 , mmtt.transfer_subinventory
11162 , mmtt.transfer_to_location
11163 , mmtt.wms_task_type
11164 , mmtt.standard_operation_id
11165 , MAX(mmtt.task_priority)
11166 , mmtt.cost_group_id
11167 , MAX(mmtt.transaction_header_id)
11168 , mmtt.container_item_id
11169 , mmtt.cartonization_id
11170 , mmtt.operation_plan_id
11171 , mol.carton_grouping_id
11172 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11173 -- Bug 4584538
11174 , mmtt.item_primary_uom_code
11175 , mmtt.item_lot_control_code
11176 , mmtt.item_serial_control_code
11177 , mmtt.serial_allocated_flag
11178 -- Bug 4584538
11179 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
11180 WHERE mmtt.move_order_line_id = mol.line_id
11181 AND mol.header_id = p_move_order_header_id
11182 AND mmtt.wms_task_type NOT IN(5, 6)
11183 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11184 AND( EXISTS(SELECT 1
11185 FROM mtl_txn_request_headers moh, wsh_pick_grouping_rules spg
11186 WHERE spg.pick_grouping_rule_id = moh.grouping_rule_id
11187 AND spg.pick_method = '4'
11188 AND moh.header_id = mol.header_id)
11189 OR EXISTS(SELECT 1
11190 FROM mtl_system_items msi
11191 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11192 AND msi.bulk_picked_flag = 'Y')
11193 )
11194 AND EXISTS ( SELECT 1 -- Only Consolidate Tasks for Plain item
11195 FROM mtl_system_items msi2
11196 WHERE msi2.inventory_item_id = mmtt.inventory_item_id
11197 AND msi2.lot_control_code = 1
11198 AND(msi2.serial_number_control_code = 1
11199 OR msi2.serial_number_control_code = 6))
11200 GROUP BY mmtt.inventory_item_id
11201 , mmtt.revision
11202 , mmtt.organization_id
11203 , mmtt.subinventory_code
11204 , mmtt.locator_id
11205 , mmtt.transaction_uom
11206 , mmtt.transaction_type_id
11207 , mmtt.transaction_action_id
11208 , mmtt.transaction_source_type_id
11209 , mmtt.transfer_organization
11210 , mmtt.transfer_subinventory
11211 , mmtt.transfer_to_location
11212 , mmtt.wms_task_type
11213 , mmtt.standard_operation_id
11214 , mmtt.cost_group_id
11215 , mmtt.container_item_id
11216 , mmtt.cartonization_id
11217 , mmtt.operation_plan_id
11218 , mol.carton_grouping_id -- only consolidate tasks with the same carton_grouping_id (hense delivery)
11219 , mmtt.wms_task_status
11220 -- Bug 4584538
11221 , mmtt.item_primary_uom_code
11222 , mmtt.item_lot_control_code
11223 , mmtt.item_serial_control_code
11224 , mmtt.serial_allocated_flag
11225 -- Bug 4584538
11226 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11227 AND 'Y' <> is_equipment_cap_exceeded(
11228 mmtt.standard_operation_id
11229 , mmtt.inventory_item_id
11230 , mmtt.organization_id
11231 , SUM(mmtt.transaction_quantity)
11232 , mmtt.transaction_uom
11233 ); -- make sure the consolidated quantity does not exceed minimum equipment capacity, this is to make sure a consolidated task will not be splitted later
11234
11235 CURSOR task_list_wip IS
11236 SELECT SYSDATE last_update_date
11237 , g_user_id last_updated_by
11238 , SYSDATE creation_date
11239 , g_user_id created_by
11240 , mmtt.inventory_item_id
11241 , mmtt.revision
11242 , mmtt.organization_id
11243 , mmtt.subinventory_code
11244 , mmtt.locator_id
11245 , SUM(mmtt.transaction_quantity)
11246 , SUM(mmtt.primary_quantity)
11247 , mmtt.transaction_uom
11248 , mmtt.transaction_type_id
11249 , mmtt.transaction_action_id
11250 , mmtt.transaction_source_type_id
11251 , MAX(mmtt.transaction_date)
11252 , MAX(mmtt.acct_period_id)
11253 , MIN(mmtt.pick_slip_number) -- the earliest created pick slip
11254 , MIN(mmtt.move_order_line_id) -- any line_id within this header
11255 , mmtt.transfer_organization
11256 , ''
11257 , NULL
11258 , mmtt.wms_task_type
11259 , mmtt.standard_operation_id
11260 , MAX(mmtt.task_priority)
11261 , mmtt.cost_group_id
11262 , MAX(mmtt.transaction_header_id)
11263 , mmtt.container_item_id
11264 , mmtt.cartonization_id
11265 , mmtt.operation_plan_id
11266 , NULL
11267 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11268 -- Bug 4584538
11269 , mmtt.item_primary_uom_code
11270 , mmtt.item_lot_control_code
11271 , mmtt.item_serial_control_code
11272 , mmtt.serial_allocated_flag
11273 -- Bug 4584538
11274 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol
11275 WHERE mmtt.move_order_line_id = mol.line_id
11276 AND mol.header_id = p_move_order_header_id
11277 AND mmtt.wms_task_type NOT IN(5, 6)
11278 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11279 AND( EXISTS(SELECT 1
11280 FROM mtl_txn_request_headers moh, wsh_pick_grouping_rules spg
11281 WHERE spg.pick_grouping_rule_id = moh.grouping_rule_id
11282 AND spg.pick_method = '4'
11283 AND moh.header_id = mol.header_id)
11284 OR EXISTS(SELECT 1
11285 FROM mtl_system_items msi
11286 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11287 AND msi.bulk_picked_flag = 'Y')
11288 )
11289 AND EXISTS( SELECT 1 -- Only Consolidate Tasks for Plain item
11290 FROM mtl_system_items msi2
11291 WHERE msi2.inventory_item_id = mmtt.inventory_item_id
11292 AND msi2.lot_control_code = 1
11293 AND(msi2.serial_number_control_code = 1
11294 OR msi2.serial_number_control_code = 6))
11295 GROUP BY mmtt.inventory_item_id
11296 , mmtt.revision
11297 , mmtt.organization_id
11298 , mmtt.subinventory_code
11299 , mmtt.locator_id
11300 , mmtt.transaction_uom
11301 , mmtt.transaction_type_id
11302 , mmtt.transaction_action_id
11303 , mmtt.transaction_source_type_id
11304 , mmtt.transfer_organization
11305 , mmtt.wms_task_type
11306 , mmtt.standard_operation_id
11307 , mmtt.cost_group_id
11308 , mmtt.container_item_id
11309 , mmtt.cartonization_id
11310 , mmtt.operation_plan_id
11311 , mmtt.wms_task_status
11312 -- Bug 4584538
11313 , mmtt.item_primary_uom_code
11314 , mmtt.item_lot_control_code
11315 , mmtt.item_serial_control_code
11316 , mmtt.serial_allocated_flag
11317 -- Bug 4584538
11318 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11319 AND 'Y' <> is_equipment_cap_exceeded(
11320 mmtt.standard_operation_id
11321 , mmtt.inventory_item_id
11322 , mmtt.organization_id
11323 , SUM(mmtt.transaction_quantity)
11324 , mmtt.transaction_uom
11325 ); -- make sure the consolidated quantity does not exceed minimum equipment capacity, this is to make sure a consolidated task will not be splitted later
11326
11327 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11328
11329 BEGIN
11330 IF (l_debug = 1) THEN
11331 print_debug('Consolidating Tasks for MO Header ID = ' || p_move_order_header_id, 4);
11332 END IF;
11333
11334 SAVEPOINT sp_consolidate_bulk_task;
11335
11336 x_return_status := fnd_api.g_ret_sts_success;
11337
11338 SELECT move_order_type
11339 INTO l_move_order_type
11340 FROM mtl_txn_request_headers
11341 WHERE header_id = p_move_order_header_id;
11342
11343 IF l_move_order_type = g_move_order_mfg_pick THEN
11344 OPEN task_list_wip;
11345 ELSE
11346 OPEN task_list;
11347 END IF;
11348
11349 LOOP
11350 IF l_move_order_type = g_move_order_mfg_pick THEN
11351 FETCH task_list_wip INTO l_last_update_date
11352 , l_last_updated_by
11353 , l_creation_date
11354 , l_created_by
11355 , l_inventory_item_id
11356 , l_revision
11357 , l_organization_id
11358 , l_subinventory_code
11359 , l_locator_id
11360 , l_transaction_quantity
11361 , l_primary_quantity
11362 , l_transaction_uom
11363 , l_transaction_type_id
11364 , l_transaction_action_id
11365 , l_transaction_source_type_id
11366 , l_transaction_date
11367 , l_acct_period_id
11368 , l_pick_slip_number
11369 , l_move_order_line_id
11370 , l_to_org_id
11371 , l_to_sub
11372 , l_to_loc_id
11373 , l_wms_task_type
11374 , l_standard_operation_id
11375 , l_task_priority
11376 , l_cost_group_id
11377 , l_transaction_header_id
11378 , l_container_item_id
11379 , l_cartonization_id
11380 , l_operation_plan_id
11381 , l_carton_grouping_id
11382 , l_wms_task_status
11383 -- Bug 4584538
11384 , l_primary_uom_code
11385 , l_lot_control_code
11386 , l_serial_control_code
11387 , l_serial_allocated_flag;
11388 -- Bug 4584538
11389 EXIT WHEN task_list_wip%NOTFOUND;
11390 ELSE
11391 FETCH task_list INTO l_last_update_date
11392 , l_last_updated_by
11393 , l_creation_date
11394 , l_created_by
11395 , l_inventory_item_id
11396 , l_revision
11397 , l_organization_id
11398 , l_subinventory_code
11399 , l_locator_id
11400 , l_transaction_quantity
11401 , l_primary_quantity
11402 , l_transaction_uom
11403 , l_transaction_type_id
11404 , l_transaction_action_id
11405 , l_transaction_source_type_id
11406 , l_transaction_date
11407 , l_acct_period_id
11408 , l_pick_slip_number
11409 , l_move_order_line_id
11410 , l_to_org_id
11411 , l_to_sub
11412 , l_to_loc_id
11413 , l_wms_task_type
11414 , l_standard_operation_id
11415 , l_task_priority
11416 , l_cost_group_id
11417 , l_transaction_header_id
11418 , l_container_item_id
11419 , l_cartonization_id
11420 , l_operation_plan_id
11421 , l_carton_grouping_id
11422 , l_wms_task_status
11423 -- Bug 4584538
11424 , l_primary_uom_code
11425 , l_lot_control_code
11426 , l_serial_control_code
11427 , l_serial_allocated_flag;
11428 -- Bug 4584538
11429 EXIT WHEN task_list%NOTFOUND;
11430 END IF;
11431
11432 l_parent_task_count := l_parent_task_count + 1;
11433 --SELECT mtl_material_transactions_s.NEXTVAL INTO l_new_txn_temp_id FROM DUAL;
11434
11435 IF (l_debug = 1) THEN
11436 print_debug('Creating a Parent Line with the values...', 4);
11437 print_debug(' --> Txn Header ID => ' || l_transaction_header_id, 4);
11438 -- print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
11439 print_debug(' --> Inventory Item ID => ' || l_inventory_item_id, 4);
11440 print_debug(' --> Revision => ' || l_revision, 4);
11441 print_debug(' --> Organization ID => ' || l_organization_id, 4);
11442 print_debug(' --> SubInventory Code => ' || l_subinventory_code, 4);
11443 print_debug(' --> Locator ID => ' || l_locator_id, 4);
11444 print_debug(' --> To Organization ID => ' || l_to_org_id, 4);
11445 print_debug(' --> To SubInventory => ' || l_to_sub, 4);
11446 print_debug(' --> To Locator ID => ' || l_to_loc_id, 4);
11447 print_debug(' --> Transaction Qty => ' || l_transaction_quantity, 4);
11448 print_debug(' --> Primary Qty => ' || l_primary_quantity, 4);
11449 print_debug(' --> Transaction UOM => ' || l_transaction_uom, 4);
11450 print_debug(' --> Txn Type ID => ' || l_transaction_type_id, 4);
11451 print_debug(' --> Txn Action ID => ' || l_transaction_action_id, 4);
11452 print_debug(' --> Txn Source Type ID => ' || l_transaction_source_type_id, 4);
11453 print_debug(' --> Txn Date => ' || l_transaction_date, 4);
11454 print_debug(' --> Account Period => ' || l_acct_period_id, 4);
11455 print_debug(' --> Pick Slip Number => ' || l_pick_slip_number, 4);
11456 print_debug(' --> Move Order Line ID => ' || l_move_order_line_id, 4);
11457 print_debug(' --> Cost Group ID => ' || l_cost_group_id, 4);
11458 print_debug(' --> Container Item ID => ' || l_container_item_id, 4);
11459 print_debug(' --> Cartonization ID => ' || l_cartonization_id, 4);
11460 print_debug(' --> Operation Plan Id => ' || l_operation_plan_id, 4);
11461 print_debug(' --> Carton Grouping ID => ' || l_carton_grouping_id, 4);
11462 print_debug(' --> Task Status => ' || l_wms_task_status, 4);
11463 print_debug(' --> Primary UOM Code => ' || l_primary_uom_code, 4);
11464 print_debug(' --> Lot Control Code => ' || l_lot_control_code, 4);
11465 print_debug(' --> Serial Control Code => ' || l_serial_control_code, 4);
11466 print_debug(' --> Serial Allocated Flag => ' || l_serial_allocated_flag, 4);
11467 END IF;
11468
11469 INSERT INTO wms_cartonization_temp
11470 (
11471 transaction_header_id
11472 , transaction_temp_id
11473 , posting_flag
11474 , transaction_status
11475 , last_update_date
11476 , last_updated_by
11477 , creation_date
11478 , created_by
11479 , transaction_type_id
11480 , transaction_action_id
11481 , transaction_source_type_id
11482 , organization_id
11483 , inventory_item_id
11484 , revision
11485 , subinventory_code
11486 , locator_id
11487 , transfer_organization
11488 , transfer_subinventory
11489 , transfer_to_location
11490 , transaction_quantity
11491 , primary_quantity
11492 , transaction_uom
11493 , transaction_date
11494 , acct_period_id
11495 , cost_group_id
11496 -- , move_order_line_id keep same as patchset J
11497 , pick_slip_number
11498 , standard_operation_id
11499 , wms_task_type
11500 , task_priority
11501 , container_item_id
11502 , cartonization_id
11503 , operation_plan_id
11504 , wms_task_status
11505 , parent_line_id
11506 -- Bug 4584538
11507 , item_primary_uom_code
11508 , item_lot_control_code
11509 , item_serial_control_code
11510 , serial_allocated_flag
11511 -- Bug 4584538
11512 )
11513 VALUES (
11514 l_transaction_header_id
11515 --, l_new_txn_temp_id
11516 , mtl_material_transactions_s.NEXTVAL --Bug 5535030
11517 , 'N'
11518 , 2
11519 , l_last_update_date
11520 , l_last_updated_by
11521 , l_creation_date
11522 , l_created_by
11523 , l_transaction_type_id
11524 , l_transaction_action_id
11525 , l_transaction_source_type_id
11526 , l_organization_id
11527 , l_inventory_item_id
11528 , l_revision
11529 , l_subinventory_code
11530 , l_locator_id
11531 , l_to_org_id
11532 , l_to_sub
11533 , l_to_loc_id
11534 , l_transaction_quantity
11535 , l_primary_quantity
11536 , l_transaction_uom
11537 , l_transaction_date
11538 , l_acct_period_id
11539 , l_cost_group_id
11540 -- , l_move_order_line_id keep same as patchset J
11541 , l_pick_slip_number
11542 , l_standard_operation_id
11543 , l_wms_task_type
11544 , l_task_priority
11545 , l_container_item_id
11546 , l_cartonization_id
11547 , l_operation_plan_id
11548 , l_wms_task_status
11549 -- , l_new_txn_temp_id -- have the same as patchset J
11550 , mtl_material_transactions_s.CURRVAL
11551 -- Bug 4584538
11552 , l_primary_uom_code
11553 , l_lot_control_code
11554 , l_serial_control_code
11555 , l_serial_allocated_flag
11556 -- Bug 4584538
11557 ) RETURNING transaction_temp_id INTO l_new_txn_temp_id ;
11558
11559 print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
11560 IF (l_debug = 1) THEN
11561 print_debug('Updating the Parent Line ID of the Tasks Consolidated', 4);
11562 END IF;
11563
11564 UPDATE wms_cartonization_temp
11565 SET parent_line_id = l_new_txn_temp_id
11566 WHERE transaction_temp_id <> l_new_txn_temp_id
11567 AND inventory_item_id = l_inventory_item_id
11568 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
11569 AND organization_id = l_organization_id
11570 AND subinventory_code = l_subinventory_code
11571 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
11572 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
11573 AND NVL(transfer_to_location, -1) = NVL(l_to_loc_id, NVL(transfer_to_location, -1))
11574 AND NVL(transfer_subinventory, '#$%') = NVL(l_to_sub, NVL(transfer_subinventory, '#$%'))
11575 AND transaction_uom = l_transaction_uom
11576 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
11577 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
11578 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
11579 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1))
11580 AND NVL(container_item_id, -1) = NVL(l_container_item_id, NVL(container_item_id, -1))
11581 AND NVL(cartonization_id, -1) = NVL(l_cartonization_id, NVL(cartonization_id, -1))
11582 AND EXISTS(SELECT 1
11583 FROM mtl_txn_request_lines mol
11584 WHERE mol.line_id = move_order_line_id
11585 AND mol.header_id = p_move_order_header_id
11586 AND NVL(mol.carton_grouping_id,-1) = NVL(l_carton_grouping_id,NVL(mol.carton_grouping_id,-1)));
11587
11588 IF (l_debug = 1) THEN
11589 print_debug('Number of Tasks consolidated into 1 Parent Task = ' || SQL%ROWCOUNT, 4);
11590 END IF;
11591 END LOOP;
11592
11593 IF task_list%ISOPEN THEN
11594 CLOSE task_list;
11595 END IF;
11596
11597 IF task_list_wip%ISOPEN THEN
11598 CLOSE task_list_wip;
11599 END IF;
11600
11601 IF (l_debug = 1) THEN
11602 print_debug('Number of Parent Tasks = ' || l_parent_task_count, 4);
11603 END IF;
11604 EXCEPTION
11605 WHEN OTHERS THEN
11606 x_return_status := fnd_api.g_ret_sts_unexp_error;
11607 ROLLBACK TO sp_consolidate_bulk_task;
11608 IF l_debug = 1 THEN
11609 print_debug('Exception Occurred = ' || SQLERRM,4);
11610 END IF;
11611
11612 IF task_list%ISOPEN THEN
11613 CLOSE task_list;
11614 END IF;
11615 IF task_list_wip%ISOPEN THEN
11616 CLOSE task_list_wip;
11617 END IF;
11618 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
11619 END consolidate_bulk_tasks;
11620
11621
11622
11623 PROCEDURE consolidate_bulk_tasks_for_so(
11624 p_api_version IN NUMBER
11625 , p_commit IN VARCHAR2 := fnd_api.g_false
11626 , x_return_status OUT NOCOPY VARCHAR2
11627 , x_msg_count OUT NOCOPY NUMBER
11628 , x_msg_data OUT NOCOPY VARCHAR2
11629 , p_move_order_header_id IN NUMBER
11630 ) IS
11631 l_new_txn_temp_id NUMBER;
11632 l_last_update_date DATE;
11633 l_last_updated_by NUMBER;
11634 l_creation_date DATE;
11635 l_created_by NUMBER;
11636 l_inventory_item_id NUMBER;
11637 l_revision VARCHAR2(30);
11638 l_organization_id NUMBER;
11639 l_subinventory_code VARCHAR2(30);
11640 l_locator_id NUMBER;
11641 l_transaction_quantity NUMBER;
11642 l_primary_quantity NUMBER;
11643 l_transaction_uom VARCHAR2(3);
11644 l_transaction_type_id NUMBER;
11645 l_transaction_action_id NUMBER;
11646 l_transaction_source_type_id NUMBER;
11647 l_transaction_date DATE;
11648 l_acct_period_id NUMBER;
11649 l_pick_slip_number NUMBER;
11650 l_move_order_line_id NUMBER;
11651 l_to_org_id NUMBER;
11652 l_to_sub VARCHAR2(30);
11653 l_to_loc_id NUMBER;
11654 l_wms_task_type NUMBER;
11655 l_standard_operation_id NUMBER;
11656 l_task_priority NUMBER;
11657 l_cost_group_id NUMBER;
11658 l_transaction_header_id NUMBER;
11659 l_container_item_id NUMBER;
11660 l_cartonization_id NUMBER;
11661 l_operation_plan_id NUMBER;
11662 l_carton_grouping_id NUMBER;
11663 l_wms_task_status NUMBER;
11664
11665 l_parent_task_count NUMBER := 0;
11666 l_move_order_type NUMBER;
11667 l_api_name VARCHAR2(30) := 'consolidate_bulk_tasks_for_so';
11668 l_delivery_flag VARCHAR2(1);
11669 l_bulk_pick_control NUMBER;
11670
11671 -- *****************************
11672 -- the following cursor will be used when calling from pick release process for all items (plain, lot and lot/serial,serial...)
11673 -- task_list is to bulk the children within the delivery and task_list_cross_delivery is to bulk_task cross deliveries
11674 -- for performance purpose, two cursors are being defined here.
11675 --******************************
11676 CURSOR task_list IS
11677 SELECT SYSDATE last_update_date
11678 , g_user_id last_updated_by
11679 , SYSDATE creation_date
11680 , g_user_id created_by
11681 , mmtt.inventory_item_id
11682 , mmtt.revision
11683 , mmtt.organization_id
11684 , mmtt.subinventory_code
11685 , mmtt.locator_id
11686 , SUM(mmtt.transaction_quantity)
11687 , SUM(mmtt.primary_quantity)
11688 , mmtt.transaction_uom
11689 , mmtt.transaction_type_id
11690 , mmtt.transaction_action_id
11691 , mmtt.transaction_source_type_id
11692 , MAX(mmtt.transaction_date)
11693 , MAX(mmtt.acct_period_id)
11694 , mmtt.transfer_organization
11695 , mmtt.wms_task_type
11696 , MAX(mmtt.task_priority)
11697 , mmtt.cost_group_id
11698 , MAX(mmtt.transaction_header_id)
11699 , mmtt.container_item_id
11700 , mmtt.operation_plan_id
11701 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11702 , nvl(wda.delivery_id, mol.carton_grouping_id)
11703 , mmtt.item_primary_uom_code
11704 , mmtt.item_lot_control_code
11705 , mmtt.item_serial_control_code
11706 , mmtt.serial_allocated_flag
11707 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
11708 WHERE mmtt.move_order_line_id = mol.line_id
11709 -- AND mol.header_id = p_move_order_header_id -- no need since wct only have the records in concerns
11710 AND mol.line_id = wdd.move_ordeR_line_id
11711 AND wdd.delivery_detail_id = wda.delivery_detail_id
11712 AND mmtt.wms_task_type NOT IN(5, 6)
11713 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11714 AND mmtt.cartonization_id is null -- only bulk non_cartoned lines
11715 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
11716 or mmtt.serial_allocated_flag is null)
11717 AND(l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_ENTIRE_WAVE
11718 -- 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
11719 OR EXISTS(SELECT 1 -- sub is bulk picking enabled
11720 FROM mtl_secondary_inventories msi
11721 WHERE msi.secondary_inventory_name = mmtt.subinventory_code
11722 AND msi.organization_id = mmtt.organization_id
11723 AND msi.enable_bulk_pick= 'Y')
11724 OR EXISTS(SELECT 1 -- item is bulk picking enabled
11725 FROM mtl_system_items msi
11726 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11727 AND msi.bulk_picked_flag = 'Y')
11728 )
11729 GROUP BY mmtt.inventory_item_id
11730 , mmtt.revision
11731 , mmtt.organization_id
11732 , mmtt.subinventory_code
11733 , mmtt.locator_id
11734 , mmtt.transaction_uom
11735 , mmtt.transaction_type_id
11736 , mmtt.transaction_action_id
11737 , mmtt.transaction_source_type_id
11738 , mmtt.transfer_organization
11739 , mmtt.wms_task_type
11740 , mmtt.cost_group_id
11741 , mmtt.container_item_id
11742 , mmtt.operation_plan_id
11743 , 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
11744 , mmtt.wms_task_status
11745 , mmtt.item_primary_uom_code
11746 , mmtt.item_lot_control_code
11747 , mmtt.item_serial_control_code
11748 , mmtt.serial_allocated_flag
11749 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11750 ;
11751
11752 CURSOR task_list_cross_delivery IS
11753 SELECT SYSDATE last_update_date
11754 , g_user_id last_updated_by
11755 , SYSDATE creation_date
11756 , g_user_id created_by
11757 , mmtt.inventory_item_id
11758 , mmtt.revision
11759 , mmtt.organization_id
11760 , mmtt.subinventory_code
11761 , mmtt.locator_id
11762 , SUM(mmtt.transaction_quantity)
11763 , SUM(mmtt.primary_quantity)
11764 , mmtt.transaction_uom
11765 , mmtt.transaction_type_id
11766 , mmtt.transaction_action_id
11767 , mmtt.transaction_source_type_id
11768 , MAX(mmtt.transaction_date)
11769 , MAX(mmtt.acct_period_id)
11770 , mmtt.transfer_organization
11771 , mmtt.wms_task_type
11772 , MAX(mmtt.task_priority)
11773 , mmtt.cost_group_id
11774 , MAX(mmtt.transaction_header_id)
11775 , mmtt.container_item_id
11776 , mmtt.operation_plan_id
11777 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11778 , mmtt.item_primary_uom_code
11779 , mmtt.item_lot_control_code
11780 , mmtt.item_serial_control_code
11781 , mmtt.serial_allocated_flag
11782 FROM wms_cartonization_temp mmtt
11783 WHERE
11784 mmtt.wms_task_type NOT IN(5, 6)
11785 AND mmtt.allocated_lpn_id IS NULL -- if lpn allocated, no need to do consolidation
11786 AND mmtt.cartonization_id is null -- only bulk non_cartoned lines
11787 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
11788 or mmtt.serial_allocated_flag is null)
11789 AND(l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_ENTIRE_WAVE
11790 -- 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
11791 OR EXISTS(SELECT 1 -- sub is bulk picking enabled
11792 FROM mtl_secondary_inventories msi
11793 WHERE msi.secondary_inventory_name = mmtt.subinventory_code
11794 AND msi.organization_id = mmtt.organization_id
11795 AND msi.enable_bulk_pick= 'Y')
11796 OR EXISTS(SELECT 1 -- item is bulk picking enabled
11797 FROM mtl_system_items msi
11798 WHERE msi.inventory_item_id = mmtt.inventory_item_id
11799 AND msi.bulk_picked_flag = 'Y')
11800 )
11801 GROUP BY mmtt.inventory_item_id
11802 , mmtt.revision
11803 , mmtt.organization_id
11804 , mmtt.subinventory_code
11805 , mmtt.locator_id
11806 , mmtt.transaction_uom
11807 , mmtt.transaction_type_id
11808 , mmtt.transaction_action_id
11809 , mmtt.transaction_source_type_id
11810 , mmtt.transfer_organization
11811 , mmtt.wms_task_type
11812 , mmtt.cost_group_id
11813 , mmtt.container_item_id
11814 , mmtt.operation_plan_id
11815 , mmtt.wms_task_status
11816 , mmtt.item_primary_uom_code
11817 , mmtt.item_lot_control_code
11818 , mmtt.item_serial_control_code
11819 , mmtt.serial_allocated_flag
11820 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11821 ;
11822
11823 -- *****************************
11824 -- the following cursor will be used when calling from concurrent program for bulking
11825 -- task_list_con to bulk within delivery and task_list_con_cd to cross deliveries
11826 --******************************
11827 CURSOR task_list_con IS
11828 SELECT SYSDATE last_update_date
11829 , g_user_id last_updated_by
11830 , SYSDATE creation_date
11831 , g_user_id created_by
11832 , mmtt.inventory_item_id
11833 , mmtt.revision
11834 , mmtt.organization_id
11835 , mmtt.subinventory_code
11836 , mmtt.locator_id
11837 , SUM(mmtt.transaction_quantity)
11838 , SUM(mmtt.primary_quantity)
11839 , mmtt.transaction_uom
11840 , mmtt.transaction_type_id
11841 , mmtt.transaction_action_id
11842 , mmtt.transaction_source_type_id
11843 , MAX(mmtt.transaction_date)
11844 , MAX(mmtt.acct_period_id)
11845 , mmtt.transfer_organization
11846 , mmtt.wms_task_type
11847 , MAX(mmtt.task_priority)
11848 , mmtt.cost_group_id
11849 , MAX(mmtt.transaction_header_id)
11850 , mmtt.container_item_id
11851 , mmtt.operation_plan_id
11852 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11853 , nvl(wda.delivery_id, mol.carton_grouping_id)
11854 , mmtt.item_primary_uom_code
11855 , mmtt.item_lot_control_code
11856 , mmtt.item_serial_control_code
11857 , mmtt.serial_allocated_flag
11858 FROM wms_cartonization_temp mmtt, mtl_txn_request_lines mol,
11859 wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
11860 WHERE mmtt.move_order_line_id = mol.line_id
11861 AND ( mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
11862 or mmtt.serial_allocated_flag is null)
11863 AND mol.line_id = wdd.move_ordeR_line_id
11864 AND wdd.delivery_Detail_id = wda.delivery_detail_id
11865 GROUP BY mmtt.inventory_item_id
11866 , mmtt.revision
11867 , mmtt.organization_id
11868 , mmtt.subinventory_code
11869 , mmtt.locator_id
11870 , mmtt.transaction_uom
11871 , mmtt.transaction_type_id
11872 , mmtt.transaction_action_id
11873 , mmtt.transaction_source_type_id
11874 , mmtt.transfer_organization
11875 , mmtt.wms_task_type
11876 , mmtt.cost_group_id
11877 , mmtt.container_item_id
11878 , mmtt.operation_plan_id
11879 , 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
11880 , mmtt.wms_task_status
11881 , mmtt.item_primary_uom_code
11882 , mmtt.item_lot_control_code
11883 , mmtt.item_serial_control_code
11884 , mmtt.serial_allocated_flag
11885 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11886 ;
11887
11888 CURSOR task_list_con_cd IS
11889 SELECT SYSDATE last_update_date
11890 , g_user_id last_updated_by
11891 , SYSDATE creation_date
11892 , g_user_id created_by
11893 , mmtt.inventory_item_id
11894 , mmtt.revision
11895 , mmtt.organization_id
11896 , mmtt.subinventory_code
11897 , mmtt.locator_id
11898 , SUM(mmtt.transaction_quantity)
11899 , SUM(mmtt.primary_quantity)
11900 , mmtt.transaction_uom
11901 , mmtt.transaction_type_id
11902 , mmtt.transaction_action_id
11903 , mmtt.transaction_source_type_id
11904 , MAX(mmtt.transaction_date)
11905 , MAX(mmtt.acct_period_id)
11906 , mmtt.transfer_organization
11907 , mmtt.wms_task_type
11908 , MAX(mmtt.task_priority)
11909 , mmtt.cost_group_id
11910 , MAX(mmtt.transaction_header_id)
11911 , mmtt.container_item_id
11912 , mmtt.operation_plan_id
11913 , mmtt.wms_task_status -- carry forward task status also for unreleased/pending statuses
11914 , mmtt.item_primary_uom_code
11915 , mmtt.item_lot_control_code
11916 , mmtt.item_serial_control_code
11917 , mmtt.serial_allocated_flag
11918 FROM wms_cartonization_temp mmtt
11919 WHERE mmtt.serial_allocated_flag = 'N' -- do not bulk serial allocated lines
11920 or mmtt.serial_allocated_flag is null
11921 GROUP BY mmtt.inventory_item_id
11922 , mmtt.revision
11923 , mmtt.organization_id
11924 , mmtt.subinventory_code
11925 , mmtt.locator_id
11926 , mmtt.transaction_uom
11927 , mmtt.transaction_type_id
11928 , mmtt.transaction_action_id
11929 , mmtt.transaction_source_type_id
11930 , mmtt.transfer_organization
11931 , mmtt.wms_task_type
11932 , mmtt.cost_group_id
11933 , mmtt.container_item_id
11934 , mmtt.operation_plan_id
11935 , mmtt.wms_task_status
11936 , mmtt.item_primary_uom_code
11937 , mmtt.item_lot_control_code
11938 , mmtt.item_serial_control_code
11939 , mmtt.serial_allocated_flag
11940 HAVING SUM(mmtt.transaction_quantity) <> MIN(mmtt.transaction_quantity) -- make sure one line will not get consolidated
11941 ;
11942
11943 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11944 l_primary_uom_code VARCHAR2(3);
11945 l_lot_control_code NUMBER;
11946 l_serial_control_code NUMBER;
11947 l_serial_allocated_flag VARCHAR2(1);
11948 l_total_child_count NUMBER := 0;
11949
11950 BEGIN
11951 IF (l_debug = 1) THEN
11952 print_debug('START CREATING BULK TASKS....',4);
11953 print_debug('Consolidating Tasks for MO Header ID = ' || p_move_order_header_id, 4);
11954 END IF;
11955
11956 SAVEPOINT sp_consolidate_bulk_task;
11957
11958
11959 x_return_status := fnd_api.g_ret_sts_success;
11960
11961 -- check if the delivery is checked in the bulk picking rule-------------
11962 IF p_move_order_header_id <> -1 THEN
11963
11964 -- cache the move order header info first
11965 If NOT INV_CACHE.set_mtrh_rec(p_move_order_header_id) THEN
11966 Raise g_exc_unexpected_error;
11967 END IF;
11968
11969 IF p_move_order_header_id = g_move_order_header_id THEN
11970 l_delivery_flag := g_delivery_flag;
11971 l_bulk_pick_control := g_bulk_pick_control;
11972 ELSE
11973 IF (l_debug = 1) THEN
11974 print_debug('checking the delivery flag.',4);
11975 END IF;
11976
11977 Select DELIVERY_FLAG
11978 Into l_delivery_flag
11979 From WSH_PICK_GROUPING_RULES
11980 Where pick_method=WMS_GLOBALS.PICK_METHOD_BULK
11981 and user_defined_flag = 'N' -- bulk picking default rule
11982 and rownum <2; -- in case of psudo translation, multiple records are inserted for the seeded rule
11983
11984 -- check to see if the picking methodology is bulk picking disabled (including order picking)---
11985 SELECT spg.bulk_pick_control
11986 into l_bulk_pick_control
11987 FROM wsh_pick_grouping_rules spg
11988 WHERE spg.pick_grouping_rule_id = INV_CACHE.mtrh_rec.grouping_rule_id;
11989
11990 g_move_order_header_id := p_move_order_header_id;
11991 g_delivery_flag := l_delivery_flag;
11992 g_bulk_pick_control := l_bulk_pick_control;
11993
11994 IF l_bulk_pick_control is null THEN
11995 l_bulk_pick_control := WMS_GLOBALS.BULK_PICK_SUB_ITEM;
11996 ELSE
11997 IF (l_bulk_pick_control = WMS_GLOBALS.BULK_PICK_DISABLED ) THEN
11998 IF (l_debug = 1) THEN
11999 print_debug('Consolidating Tasks are not bulk picking enabled',4);
12000 END IF;
12001 return;
12002 END IF;
12003 END IF;
12004
12005 l_move_order_type := INV_CACHE.mtrh_rec.move_order_type;
12006
12007 IF l_move_order_type <> g_move_order_pick_wave THEN
12008 IF (l_debug = 1) THEN
12009 print_debug('Consolidating Tasks are not pick wave mo',4);
12010 END IF;
12011 RAISE g_exc_unexpected_error;
12012 END IF;
12013 END IF;
12014 ELSE -- calling from the concurrent program, always query
12015 Select DELIVERY_FLAG
12016 Into l_delivery_flag
12017 From WSH_PICK_GROUPING_RULES
12018 Where pick_method=WMS_GLOBALS.PICK_METHOD_BULK
12019 and user_defined_flag = 'N' -- default rule
12020 and rownum <2; -- in case of psudo translation, multiple records are inserted for the seeded rule
12021 END IF;
12022
12023 IF (l_debug = 1) THEN
12024 print_debug('Delivery flag for bulk picking is '||l_delivery_flag,4);
12025 print_debug('Consolidating Tasks, bulk task control '||l_bulk_pick_control,4);
12026 END IF;
12027
12028 -- open the non serial controlled items cursor -----------------------
12029 if p_move_order_header_id <> -1 then
12030 if l_delivery_flag = 'Y'then
12031 OPEN task_list;
12032 else OPEN task_list_cross_delivery;
12033 end if;
12034 else
12035 if l_delivery_flag = 'Y'then
12036 OPEN task_list_con;
12037 else OPEN task_list_con_cd;
12038 end if;
12039 end if;
12040
12041 LOOP
12042 if p_move_order_header_id <> -1 then
12043 IF l_delivery_flag = 'Y'THEN
12044 FETCH task_list INTO l_last_update_date
12045 , l_last_updated_by
12046 , l_creation_date
12047 , l_created_by
12048 , l_inventory_item_id
12049 , l_revision
12050 , l_organization_id
12051 , l_subinventory_code
12052 , l_locator_id
12053 , l_transaction_quantity
12054 , l_primary_quantity
12055 , l_transaction_uom
12056 , l_transaction_type_id
12057 , l_transaction_action_id
12058 , l_transaction_source_type_id
12059 , l_transaction_date
12060 , l_acct_period_id
12061 , l_to_org_id
12062 , l_wms_task_type
12063 , l_task_priority
12064 , l_cost_group_id
12065 , l_transaction_header_id
12066 , l_container_item_id
12067 , l_operation_plan_id
12068 , l_wms_task_status
12069 , l_carton_grouping_id
12070 , l_primary_uom_code
12071 , l_lot_control_code
12072 , l_serial_control_code
12073 , l_serial_allocated_flag;
12074 EXIT WHEN task_list%NOTFOUND;
12075 ELSE
12076 FETCH task_list_cross_delivery INTO l_last_update_date
12077 , l_last_updated_by
12078 , l_creation_date
12079 , l_created_by
12080 , l_inventory_item_id
12081 , l_revision
12082 , l_organization_id
12083 , l_subinventory_code
12084 , l_locator_id
12085 , l_transaction_quantity
12086 , l_primary_quantity
12087 , l_transaction_uom
12088 , l_transaction_type_id
12089 , l_transaction_action_id
12090 , l_transaction_source_type_id
12091 , l_transaction_date
12092 , l_acct_period_id
12093 , l_to_org_id
12094 , l_wms_task_type
12095 , l_task_priority
12096 , l_cost_group_id
12097 , l_transaction_header_id
12098 , l_container_item_id
12099 , l_operation_plan_id
12100 , l_wms_task_status
12101 , l_primary_uom_code
12102 , l_lot_control_code
12103 , l_serial_control_code
12104 , l_serial_allocated_flag;
12105 EXIT WHEN task_list_cross_delivery%NOTFOUND;
12106 END IF;
12107 else
12108 IF l_delivery_flag = 'Y'THEN
12109 FETCH task_list_con INTO l_last_update_date
12110 , l_last_updated_by
12111 , l_creation_date
12112 , l_created_by
12113 , l_inventory_item_id
12114 , l_revision
12115 , l_organization_id
12116 , l_subinventory_code
12117 , l_locator_id
12118 , l_transaction_quantity
12119 , l_primary_quantity
12120 , l_transaction_uom
12121 , l_transaction_type_id
12122 , l_transaction_action_id
12123 , l_transaction_source_type_id
12124 , l_transaction_date
12125 , l_acct_period_id
12126 , l_to_org_id
12127 , l_wms_task_type
12128 , l_task_priority
12129 , l_cost_group_id
12130 , l_transaction_header_id
12131 , l_container_item_id
12132 , l_operation_plan_id
12133 , l_wms_task_status
12134 , l_carton_grouping_id
12135 , l_primary_uom_code
12136 , l_lot_control_code
12137 , l_serial_control_code
12138 , l_serial_allocated_flag;
12139 EXIT WHEN task_list_con%NOTFOUND;
12140 ELSE
12141 FETCH task_list_con_cd INTO l_last_update_date
12142 , l_last_updated_by
12143 , l_creation_date
12144 , l_created_by
12145 , l_inventory_item_id
12146 , l_revision
12147 , l_organization_id
12148 , l_subinventory_code
12149 , l_locator_id
12150 , l_transaction_quantity
12151 , l_primary_quantity
12152 , l_transaction_uom
12153 , l_transaction_type_id
12154 , l_transaction_action_id
12155 , l_transaction_source_type_id
12156 , l_transaction_date
12157 , l_acct_period_id
12158 , l_to_org_id
12159 , l_wms_task_type
12160 , l_task_priority
12161 , l_cost_group_id
12162 , l_transaction_header_id
12163 , l_container_item_id
12164 , l_operation_plan_id
12165 , l_wms_task_status
12166 , l_primary_uom_code
12167 , l_lot_control_code
12168 , l_serial_control_code
12169 , l_serial_allocated_flag;
12170 EXIT WHEN task_list_con_cd%NOTFOUND;
12171 END IF;
12172 end if;
12173
12174 l_parent_task_count := l_parent_task_count + 1;
12175 -- SELECT mtl_material_transactions_s.NEXTVAL INTO l_new_txn_temp_id FROM DUAL;
12176
12177 IF (l_debug = 1) THEN
12178 print_debug('Creating a Parent Line with the values...', 4);
12179 print_debug(' --> Txn Header ID => ' || l_transaction_header_id, 4);
12180 -- print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
12181 print_debug(' --> Inventory Item ID => ' || l_inventory_item_id, 4);
12182 print_debug(' --> Revision => ' || l_revision, 4);
12183 print_debug(' --> Organization ID => ' || l_organization_id, 4);
12184 print_debug(' --> SubInventory Code => ' || l_subinventory_code, 4);
12185 print_debug(' --> Locator ID => ' || l_locator_id, 4);
12186 print_debug(' --> To Organization ID => ' || l_to_org_id, 4);
12187
12188 print_debug(' --> Transaction Qty => ' || l_transaction_quantity, 4);
12189 print_debug(' --> Primary Qty => ' || l_primary_quantity, 4);
12190 print_debug(' --> Transaction UOM => ' || l_transaction_uom, 4);
12191 print_debug(' --> Txn Type ID => ' || l_transaction_type_id, 4);
12192 print_debug(' --> Txn Action ID => ' || l_transaction_action_id, 4);
12193 print_debug(' --> Txn Source Type ID => ' || l_transaction_source_type_id, 4);
12194 print_debug(' --> Txn Date => ' || l_transaction_date, 4);
12195 print_debug(' --> Account Period => ' || l_acct_period_id, 4);
12196 print_debug(' --> Cost Group ID => ' || l_cost_group_id, 4);
12197 print_debug(' --> Container Item ID => ' || l_container_item_id, 4);
12198 print_debug(' --> Operation Plan Id => ' || l_operation_plan_id, 4);
12199 print_debug(' --> Task Status => ' || l_wms_task_status, 4);
12200 END IF;
12201
12202 INSERT INTO wms_cartonization_temp
12203 (
12204 transaction_header_id
12205 , transaction_temp_id
12206 , posting_flag
12207 , transaction_status
12208 , last_update_date
12209 , last_updated_by
12210 , creation_date
12211 , created_by
12212 , transaction_type_id
12213 , transaction_action_id
12214 , transaction_source_type_id
12215 , organization_id
12216 , inventory_item_id
12217 , revision
12218 , subinventory_code
12219 , locator_id
12220 , transfer_organization
12221 , transaction_quantity
12222 , primary_quantity
12223 , transaction_uom
12224 , transaction_date
12225 , acct_period_id
12226 , cost_group_id
12227 , wms_task_type
12228 , task_priority
12229 , container_item_id
12230 , operation_plan_id
12231 , wms_task_status
12232 , parent_line_id
12233 , item_primary_uom_code
12234 , item_lot_control_code
12235 , item_serial_control_code
12236 , serial_allocated_flag
12237 )
12238 VALUES (
12239 l_transaction_header_id
12240 --, l_new_txn_temp_id
12241 , mtl_material_transactions_s.NEXTVAL --Bug 5535030
12242 , 'N'
12243 , 2
12244 , l_last_update_date
12245 , l_last_updated_by
12246 , l_creation_date
12247 , l_created_by
12248 , l_transaction_type_id
12249 , l_transaction_action_id
12250 , l_transaction_source_type_id
12251 , l_organization_id
12252 , l_inventory_item_id
12253 , l_revision
12254 , l_subinventory_code
12255 , l_locator_id
12256 , l_to_org_id
12257 , l_transaction_quantity
12258 , l_primary_quantity
12259 , l_transaction_uom
12260 , l_transaction_date
12261 , l_acct_period_id
12262 , l_cost_group_id
12263 , l_wms_task_type
12264 , l_task_priority
12265 , l_container_item_id
12266 , l_operation_plan_id
12267 , l_wms_task_status
12268 --, l_new_txn_temp_id
12269 , mtl_material_transactions_s.CURRVAL
12270 , l_primary_uom_code
12271 , l_lot_control_code
12272 , l_serial_control_code
12273 , l_serial_allocated_flag
12274 )RETURNING transaction_temp_id INTO l_new_txn_temp_id ;
12275
12276 print_debug(' --> Txn Temp ID => ' || l_new_txn_temp_id, 4);
12277 IF (l_debug = 1) THEN
12278 print_debug('Updating the Parent Line ID of the Tasks Consolidated', 4);
12279 END IF;
12280
12281 IF l_delivery_flag = 'Y' THEN
12282 UPDATE wms_cartonization_temp wct
12283 SET parent_line_id = l_new_txn_temp_id
12284 WHERE transaction_temp_id <> l_new_txn_temp_id
12285 AND inventory_item_id = l_inventory_item_id
12286 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
12287 AND organization_id = l_organization_id
12288 AND subinventory_code = l_subinventory_code
12289 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
12290 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
12291 AND transaction_uom = l_transaction_uom
12292 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
12293 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
12294 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
12295 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1))
12296 AND EXISTS(SELECT 1
12297 FROM mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,wsh_delivery_assignments_v wda
12298 WHERE mol.line_id = wct.move_order_line_id
12299 AND mol.line_id = wdd.move_ordeR_line_id
12300 AND wdd.delivery_detail_id = wda.delivery_detail_id
12301 AND NVL(wda.delivery_id,mol.carton_grouping_id) = l_carton_grouping_id);
12302 ELSE
12303 UPDATE wms_cartonization_temp
12304 SET parent_line_id = l_new_txn_temp_id
12305 WHERE transaction_temp_id <> l_new_txn_temp_id
12306 AND inventory_item_id = l_inventory_item_id
12307 AND NVL(revision, '#$%') = NVL(l_revision, NVL(revision, '#$%'))
12308 AND organization_id = l_organization_id
12309 AND subinventory_code = l_subinventory_code
12310 AND NVL(locator_id, -1) = NVL(l_locator_id, NVL(locator_id, -1))
12311 AND NVL(transfer_organization, -1) = NVL(l_to_org_id, NVL(transfer_organization, -1))
12312 AND transaction_uom = l_transaction_uom
12313 AND NVL(transaction_type_id, -1) = NVL(l_transaction_type_id, NVL(transaction_type_id, -1))
12314 AND NVL(transaction_action_id, -1) = NVL(l_transaction_action_id, NVL(transaction_action_id, -1))
12315 AND NVL(transaction_source_type_id, -1) = NVL(l_transaction_source_type_id, NVL(transaction_source_type_id, -1))
12316 AND NVL(cost_group_id, -1) = NVL(l_cost_group_id, NVL(cost_group_id, -1));
12317
12318 END IF;
12319
12320
12321 IF (l_debug = 1) THEN
12322 print_debug('Number of Tasks consolidated into 1 Parent Task = ' || SQL%ROWCOUNT, 4);
12323 END IF;
12324 l_total_child_count := l_total_child_count + SQL%ROWCOUNT;
12325 END LOOP;
12326
12327 if p_move_order_header_id <> -1 then
12328 IF l_delivery_flag = 'Y' THEN
12329 CLOSE task_list;
12330 ELSE
12331 CLOSE task_list_cross_delivery;
12332 END IF;
12333 else
12334 IF l_delivery_flag = 'Y' THEN
12335 CLOSE task_list_con;
12336 ELSE
12337 CLOSE task_list_con_cd;
12338 END IF;
12339 end if;
12340
12341 IF (l_debug = 1) THEN
12342 print_debug('Number of Parent Tasks = ' || l_parent_task_count, 4);
12343 print_debug('Number of child lines processed = ' || l_total_child_count,4);
12344 END IF;
12345 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12346 EXCEPTION
12347 WHEN OTHERS THEN
12348 x_return_status := fnd_api.g_ret_sts_unexp_error;
12349 ROLLBACK TO sp_consolidate_bulk_task;
12350 IF l_debug = 1 THEN
12351 print_debug('Exception Occurred = ' || SQLERRM,4);
12352 END IF;
12353 IF task_list%ISOPEN THEN
12354 CLOSE task_list;
12355 END IF;
12356 IF task_list_con%ISOPEN THEN
12357 CLOSE task_list_con;
12358 END IF;
12359
12360
12361 IF task_list_cross_delivery%ISOPEN THEN
12362 CLOSE task_list_cross_Delivery;
12363 END IF;
12364 IF task_list_con_cd%ISOPEN THEN
12365 CLOSE task_list_con_cd;
12366 END IF;
12367
12368 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12369 END consolidate_bulk_tasks_for_so;
12370
12371 --------- patchset J bulk picking -----------------
12372 -- This procedure will be called inside the split_task API. It will be called after stamping the parent_line_id
12373 -- for all the child lines. ------
12374
12375 Procedure Duplicate_lot_serial_in_parent(
12376 p_parent_transaction_temp_id NUMBER
12377 , x_return_status OUT NOCOPY VARCHAR2
12378 , x_msg_count OUT NOCOPY NUMBER
12379 , x_msg_data OUT NOCOPY VARCHAR2) IS
12380
12381 l_serial_number_control_code NUMBER;
12382 l_lot_control_code NUMBER;
12383 l_mtlt_rec mtl_transaction_lots_temp%ROWTYPE;
12384 l_msnt_rec mtl_serial_numbers_temp%ROWTYPE;
12385 l_new_txn_temp_id NUMBER;
12386
12387
12388
12389 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
12390 BEGIN
12391 IF (l_debug = 1) THEN
12392 print_debug('Enter Duplicate_lot_serial_in_parent ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
12393 END IF;
12394
12395
12396 -- Initialize API return status to success
12397 x_return_status := fnd_api.g_ret_sts_success;
12398
12399 -- to get the serial control code
12400 select serial_number_control_code,lot_control_code
12401 into l_serial_number_control_code,l_lot_control_code
12402 from mtl_system_items_b msi,mtl_material_transactions_temp mmtt
12403 where mmtt.transaction_temp_id = p_parent_transaction_temp_id
12404 and mmtt.inventory_item_id = msi.inventory_item_id
12405 and mmtt.organization_id = msi.organization_id;
12406
12407 IF (l_debug = 1) THEN
12408 print_debug('lot control code:'||l_lot_control_code,4);
12409 print_debug('serial control code:'||l_serial_number_control_code,4);
12410 END IF;
12411
12412 IF (l_lot_control_code = 2) THEN
12413 -- insert the lot numbers for the parent line
12414 INSERT INTO mtl_transaction_lots_temp
12415 (transaction_temp_id
12416 , lot_number
12417 , transaction_quantity
12418 , primary_quantity
12419 , lot_expiration_date
12420 , last_update_date
12421 , last_updated_by
12422 , creation_date
12423 , created_by
12424 , serial_transaction_temp_id) -- always set to null since we don't bulk lines with allocated serial numbers
12425 (SELECT p_parent_transaction_temp_id, -- transaction_temp_id of parent line
12426 mtlt.lot_number,
12427 sum(mtlt.transaction_quantity) transaction_quantity,
12428 sum(mtlt.primary_quantity) primary_quantity,
12429 mtlt.lot_expiration_date
12430 ,SYSDATE
12431 ,g_user_id
12432 ,SYSDATE
12433 ,g_user_id
12434 ,null
12435 FROM mtl_transaction_lots_temp mtlt,mtl_material_transactions_temp mmtt
12436 WHERE
12437 mtlt.transaction_temp_id = mmtt.transaction_temp_id
12438 and mmtt.parent_line_id = p_parent_transaction_temp_id -- child task
12439 and mmtt.transaction_temp_id <> p_parent_transaction_temp_id -- not parent task
12440 group by mtlt.lot_number,mtlt.lot_expiration_date);
12441
12442 END IF;
12443
12444
12445 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12446
12447 EXCEPTION
12448 WHEN OTHERS THEN
12449 x_return_status := fnd_api.g_ret_sts_unexp_error;
12450
12451 IF l_debug = 1 THEN
12452 print_debug('Exception Occurred = ' || SQLERRM,4);
12453 END IF;
12454
12455 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
12456
12457 END Duplicate_lot_serial_in_parent;
12458
12459 ----- end of patchset J bulk picking ------------------------------------
12460
12461 PROCEDURE split_task(
12462 p_api_version NUMBER
12463 , p_task_id NUMBER
12464 , p_commit VARCHAR2 := fnd_api.g_false
12465 , x_return_status OUT NOCOPY VARCHAR2
12466 , x_msg_count OUT NOCOPY NUMBER
12467 , x_msg_data OUT NOCOPY VARCHAR2
12468 ) IS
12469 l_api_name VARCHAR2(20) := 'split_task';
12470 l_item_id NUMBER; -- item ID
12471 l_lot_control_code NUMBER;
12472 l_serial_number_control_code NUMBER;
12473 l_loc_uom_code VARCHAR2(3); -- locator uom code
12474 l_txn_uom_code VARCHAR2(3); -- transaction uom code
12475 l_item_prim_uom_code VARCHAR2(3); -- primary uom code
12476 l_txn_pri_uom_ratio NUMBER; -- conversion rate between transaction uom and item primary UOM
12477 l_loc_txn_uom_ratio NUMBER; -- conversion rate between locator uom and transaction uom
12478 l_equip_vol NUMBER; -- equipment volume capacity
12479 l_equip_weight NUMBER; -- equipment weight capacity
12480 l_item_vol NUMBER; -- item unit volume
12481 l_item_weight NUMBER; -- item unit weight
12482 l_equip_v_uom VARCHAR2(3); -- equipment volume UOM
12483 l_equip_w_uom VARCHAR2(3); -- equipment weight UOM
12484 l_item_v_uom VARCHAR2(3); -- item unit volume UOM
12485 l_item_w_uom VARCHAR2(3); -- item unit weight UOM
12486 l_eq_it_v_uom_ratio NUMBER := 1; -- conversion rate between equipment volume capacity and item unit volume UOM
12487 l_eq_it_w_uom_ratio NUMBER := 1; -- conversion rate between equipment weight capacity and item weight UOM
12488 l_task_rec_old_wct wms_cartonization_temp%ROWTYPE;
12489 l_task_rec_new_wct wms_cartonization_temp%ROWTYPE;
12490 l_task_rec_old_mmtt mtl_material_transactions_temp%ROWTYPE;
12491 l_task_rec_new_mmtt mtl_material_transactions_temp%ROWTYPE;
12492 l_child_rec_new mtl_material_transactions_temp%ROWTYPE;
12493 l_lot_split_rec inv_rcv_common_apis.trans_rec_tb_tp;
12494 l_min_cap NUMBER := -1; -- minimum equipment capacity for a task
12495 l_min_cap_temp NUMBER;
12496 l_split_factor NUMBER; -- split task to this size
12497 l_init_qty NUMBER;
12498 l_new_qty NUMBER;
12499 l_counter NUMBER := 0;
12500 l_new_temp_id NUMBER;
12501 l_progress VARCHAR2(10);
12502 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
12503 l_msg_count NUMBER;
12504 l_msg_data VARCHAR2(400);
12505
12506 -- capacity cursur for all the equipments that is eligible for one task
12507 -- also the item weight and volumn for the task
12508 CURSOR l_capcity_cur IS
12509 SELECT equip.internal_volume equip_vol
12510 , -- equipment volume capacity
12511 equip.maximum_load_weight equip_weight
12512 , -- equipment weight capacity
12513 item.unit_volume item_vol
12514 , -- item unit volume
12515 item.unit_weight item_weight
12516 , -- item unit weight
12517 equip.volume_uom_code equip_v_uom
12518 , -- equipment volumn UOM code
12519 equip.weight_uom_code equip_w_uom
12520 , -- equipment weight UOM code
12521 item.volume_uom_code item_v_uom
12522 , -- item volume UOM code
12523 item.weight_uom_code item_w_uom -- item weight UOM code
12524 FROM mtl_system_items equip
12525 , mtl_system_items item
12526 , wms_cartonization_temp mmtt
12527 , bom_resource_equipments res_equip
12528 , bom_resources res
12529 , bom_std_op_resources tt_x_res
12530 WHERE mmtt.transaction_temp_id = p_task_id -- the task in question
12531 AND mmtt.standard_operation_id = tt_x_res.standard_operation_id --join task with task_type-resource x-ref
12532 AND tt_x_res.resource_id = res.resource_id -- join with resource
12533 AND res.resource_type = 1 -- resource type for equipment
12534 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
12535 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
12536 AND equip.organization_id = res_equip.organization_id
12537 AND item.inventory_item_id = mmtt.inventory_item_id -- join with item for the item that is transfered
12538 AND item.organization_id = mmtt.organization_id;
12539
12540
12541 ---------- patchset J bulk picking -----------------------
12542 -- capacity cursur for all the equipments that is eligible for one task
12543 -- also the item weight and volumn for the task
12544 -- this cursor is used for the new flows introduced by bulk picking
12545 CURSOR l_capcity_cur_bulk IS
12546 SELECT equip.internal_volume equip_vol
12547 , -- equipment volume capacity
12548 equip.maximum_load_weight equip_weight
12549 , -- equipment weight capacity
12550 item.unit_volume item_vol
12551 , -- item unit volume
12552 item.unit_weight item_weight
12553 , -- item unit weight
12554 equip.volume_uom_code equip_v_uom
12555 , -- equipment volumn UOM code
12556 equip.weight_uom_code equip_w_uom
12557 , -- equipment weight UOM code
12558 item.volume_uom_code item_v_uom
12559 , -- item volume UOM code
12560 item.weight_uom_code item_w_uom -- item weight UOM code
12561 FROM mtl_system_items equip
12562 , mtl_system_items item
12563 , mtl_material_transactions_temp mmtt
12564 , bom_resource_equipments res_equip
12565 , bom_resources res
12566 , bom_std_op_resources tt_x_res
12567 WHERE mmtt.transaction_temp_id = p_task_id -- the task in question
12568 AND mmtt.standard_operation_id = tt_x_res.standard_operation_id --join task with task_type-resource x-ref
12569 AND tt_x_res.resource_id = res.resource_id -- join with resource
12570 AND res.resource_type = 1 -- resource type for equipment
12571 AND res_equip.resource_id = tt_x_res.resource_id -- join with resource-equip x-ref
12572 AND equip.inventory_item_id = res_equip.inventory_item_id -- join with equipment (mtl_system_items)
12573 AND equip.organization_id = res_equip.organization_id
12574 AND item.inventory_item_id = mmtt.inventory_item_id -- join with item for the item that is transfered
12575 AND item.organization_id = mmtt.organization_id;
12576
12577 -- A new cursor will be defined to find all the child tasks ordered by delivery
12578 Cursor c_child_tasks(p_parent_line_id NUMBER) is
12579 Select mmtt.transaction_temp_id,mmtt.transaction_quantity
12580 From wms_cartonization_temp mmtt,mtl_txn_request_lines mol,wsh_delivery_details_ob_grp_v wdd,
12581 wsh_delivery_assignments_v wda
12582 WHERE mmtt.parent_line_id = p_parent_line_id
12583 And mol.line_id = mmtt.move_order_line_id
12584 and mol.line_id = wdd.move_order_line_id
12585 and wdd.delivery_detail_id = wda.delivery_detail_id
12586 and mmtt.transaction_temp_id <> p_parent_line_id
12587 Order by nvl(wda.delivery_id,mol.carton_grouping_id), mmtt.transaction_quantity DESC;
12588
12589 l_child_remaining_qty NUMBER := 0;
12590 l_child_temp_id NUMBER := 0;
12591 l_child_rec c_child_tasks%ROWTYPE;
12592 l_child_total_qty NUMBER := 0;
12593 l_new_child_temp_id NUMBER;
12594 l_new_child_qty NUMBER;
12595 l_move_order_type NUMBER;
12596 ---------- end of patchset J bulk picking -----------------------
12597
12598 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
12599 BEGIN
12600 IF (l_debug = 1) THEN
12601 print_debug('Enter split_task 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
12602 END IF;
12603
12604 l_progress := '10';
12605 SAVEPOINT sp_task_split;
12606 l_progress := '20';
12607 -- Initialize API return status to success
12608 x_return_status := fnd_api.g_ret_sts_success;
12609 -- query locator picking UOM code, if NULL use subinventory picking UOM code
12610 -- query transaction UOM code, and primary UOM code
12611 -- query transacted item ID
12612 -- Also query the transaction quantity
12613 -- changed for patchset J bulk picking -----------
12614 SELECT *
12615 INTO l_task_rec_old_wct
12616 FROM wms_cartonization_temp
12617 WHERE transaction_temp_id = p_task_id;
12618
12619 -- get the mmtt rec too, will be used later on, the reason why both wct and mmtt are here is for branching
12620 SELECT *
12621 INTO l_task_rec_old_mmtt
12622 FROM mtl_material_transactions_temp
12623 WHERE transaction_temp_id = p_task_id;
12624
12625 IF (l_task_rec_old_wct.parent_line_id is null) THEN -- not bulk task
12626 -- cache the move order header info first
12627 If NOT INV_CACHE.set_mtrh_rec(l_task_rec_old_wct.move_order_header_id) THEN
12628 Raise g_exc_unexpected_error;
12629 END IF;
12630 l_move_order_type := INV_CACHE.mtrh_rec.move_order_type;
12631 if (l_debug = 1) then print_debug('Move order type:'||l_move_order_type,4); end if;
12632 ELSE
12633 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
12634 l_move_order_type := G_MOVE_ORDER_PICK_WAVE; -- calling for parent task, WIP doesn't call this for patchset J
12635 if (l_debug = 1) then print_debug('calling for bulk task (parent task line ....',4);
12636 -- print_debug('PATCHSET J-- BULK PICKING --END', 4);
12637 end if;
12638 END IF;
12639
12640 -- end of change for patchset J bulk picking ------------------
12641
12642
12643
12644
12645 -- Use subinventory locator pick_uom_code OR sub pick_uom_code
12646 l_progress := '30';
12647
12648 SELECT NVL(mil.pick_uom_code, msi.pick_uom_code)
12649 , mmtt.transaction_uom
12650 , mmtt.inventory_item_id
12651 , mmtt.transaction_quantity
12652 , item.primary_uom_code
12653 , item.lot_control_code
12654 , item.serial_number_control_code
12655 INTO l_loc_uom_code
12656 , l_txn_uom_code
12657 , l_item_id
12658 , l_init_qty
12659 , l_item_prim_uom_code
12660 , l_lot_control_code
12661 , l_serial_number_control_code
12662 FROM wms_cartonization_temp mmtt, mtl_item_locations mil, mtl_secondary_inventories msi, mtl_system_items item
12663 WHERE mmtt.transaction_temp_id = p_task_id
12664 AND mmtt.locator_id = mil.inventory_location_id(+)
12665 AND mmtt.organization_id = mil.organization_id(+)
12666 AND mmtt.subinventory_code = msi.secondary_inventory_name
12667 AND mmtt.organization_id = msi.organization_id
12668 AND mmtt.inventory_item_id = item.inventory_item_id
12669 AND mmtt.organization_id = item.organization_id;
12670
12671 l_progress := '40';
12672
12673 IF (l_debug = 1) THEN
12674 print_debug('split_task 20 - quried following information' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12675 print_debug('l_loc_uom_code => ' || l_loc_uom_code, 4);
12676 print_debug('l_txn_uom_code => ' || l_txn_uom_code, 4);
12677 print_debug('l_item_id => ' || l_item_id, 4);
12678 print_debug('l_init_qty => ' || l_init_qty, 4);
12679 print_debug('l_item_prim_uom_code => ' || l_item_prim_uom_code, 4);
12680 print_debug('l_lot_control_code => ' || l_lot_control_code, 4);
12681 print_debug('l_serial_number_control_code => ' || l_serial_number_control_code, 4);
12682 END IF;
12683
12684 -- bug fix 2123018
12685 IF l_loc_uom_code IS NULL THEN
12686 IF (l_debug = 1) THEN
12687 print_debug('l_loc_uom_code is NULL, default it to l_txn_uom_code.', 4);
12688 END IF;
12689
12690 l_loc_uom_code := l_txn_uom_code;
12691 END IF;
12692
12693 IF l_loc_uom_code IS NULL
12694 OR l_txn_uom_code IS NULL
12695 OR l_item_id IS NULL
12696 OR l_init_qty IS NULL
12697 OR l_item_prim_uom_code IS NULL THEN
12698 IF (l_debug = 1) THEN
12699 print_debug('split_task 30 - necessary UOM information missing' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12700 END IF;
12701
12702 RAISE fnd_api.g_exc_unexpected_error;
12703 END IF;
12704
12705 -- call UOM conversion API to compute the ratio between
12706 -- locator UOM and transcation UOM for given item
12707 inv_convert.inv_um_conversion(from_unit => l_loc_uom_code, to_unit => l_txn_uom_code, item_id => l_item_id
12708 , uom_rate => l_loc_txn_uom_ratio);
12709
12710 IF l_loc_txn_uom_ratio = -99999 THEN -- uom conversion failure
12711 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
12712 fnd_msg_pub.ADD;
12713
12714 IF (l_debug = 1) THEN
12715 print_debug('split_task 40 - loc/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12716 END IF;
12717
12718 RAISE fnd_api.g_exc_error;
12719 END IF;
12720
12721 -- compute conversion rate between transaction UOM and item primary UOM
12722 inv_convert.inv_um_conversion(from_unit => l_txn_uom_code, to_unit => l_item_prim_uom_code, item_id => l_item_id
12723 , uom_rate => l_txn_pri_uom_ratio);
12724
12725 IF l_txn_pri_uom_ratio = -99999 THEN -- uom conversion failure
12726 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
12727 fnd_msg_pub.ADD;
12728
12729 IF (l_debug = 1) THEN
12730 print_debug('split_task 50 - txn/item uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12731 END IF;
12732
12733 RAISE fnd_api.g_exc_error;
12734 END IF;
12735
12736 IF (l_debug = 1) THEN
12737 print_debug('split_task 60 - UOM conversion data:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12738 END IF;
12739
12740 IF (l_debug = 1) THEN
12741 print_debug('l_loc_txn_uom_ratio => ' || l_loc_txn_uom_ratio, 4);
12742 print_debug('l_txn_pri_uom_ratio => ' || l_txn_pri_uom_ratio, 4);
12743 END IF;
12744
12745 -- Query minimum equipment capacity in terms of transaction UOM
12746 -- The minimum of the volumn and weight capacity is used
12747 -- If no equipment capacity or item unit volumn or weight defined,
12748 -- do not split
12749 -- NEED FURTHER consideration for container item:
12750 -- should check unit volume and content weight ???
12751
12752 l_progress := '50';
12753 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12754 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12755 IF (l_debug = 1) THEN print_debug('open l_capcity_cur_bulk',4); END IF;
12756 OPEN l_capcity_cur_bulk;
12757 ELSE
12758 IF (l_debug = 1) THEN print_debug('open l_capcity_cur',4); END IF;
12759 OPEN l_capcity_cur;
12760 END IF;
12761 l_progress := '60';
12762
12763 LOOP
12764 l_progress := '70';
12765 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12766 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12767 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
12768 , l_item_w_uom;
12769 EXIT WHEN l_capcity_cur_bulk%NOTFOUND;
12770 else
12771 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
12772 , l_item_w_uom;
12773 EXIT WHEN l_capcity_cur%NOTFOUND;
12774 end if;
12775 l_progress := '80';
12776 -- get the conversion ratio between equipment and item volume UOM
12777 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);
12778 IF l_eq_it_v_uom_ratio = -99999 THEN -- uom conversion failure
12779 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
12780 fnd_msg_pub.ADD;
12781
12782 IF (l_debug = 1) THEN
12783 print_debug('split_task 70 - eqp/item volume uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12784 END IF;
12785 END IF;
12786 -- get the conversion ratio between equipment and item weight UOM
12787 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);
12788 IF l_eq_it_w_uom_ratio = -99999 THEN -- uom conversion failure
12789 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
12790 fnd_msg_pub.ADD;
12791
12792 IF (l_debug = 1) THEN
12793 print_debug('split_task 70 - eqp/item weight uom ratio calculation failed' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12794 END IF;
12795 END IF;
12796
12797 --
12798 -- Debugging Statements for FP bug 4634597
12799 --
12800 IF (l_debug = 1) THEN
12801 print_debug('l_equip_vol = ' || l_equip_vol, 4);
12802 print_debug('l_item_vol = ' || l_item_vol, 4);
12803 print_debug('l_eq_it_v_uom_ratio = ' || l_eq_it_v_uom_ratio, 4);
12804 print_debug('l_equip_weight = ' || l_equip_weight, 4);
12805 print_debug('l_item_weight = ' || l_item_weight, 4);
12806 print_debug('l_eq_it_w_uom_ratio = ' || l_eq_it_w_uom_ratio, 4);
12807 END IF;
12808 --
12809
12810 IF (l_equip_vol IS NOT NULL
12811 AND l_item_vol IS NOT NULL
12812 AND l_eq_it_v_uom_ratio <> -99999)
12813 OR(l_equip_weight IS NOT NULL
12814 AND l_item_weight IS NOT NULL
12815 AND l_eq_it_w_uom_ratio <> -99999) THEN
12816 IF l_eq_it_v_uom_ratio = -99999 THEN -- invalid volume UOM conversion
12817 -- compute equipment capacity using weight
12818 l_min_cap_temp := TRUNC((l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio);
12819 --
12820 -- Start FP Bug 4634597
12821 --
12822 IF (l_min_cap_temp = 0) THEN
12823 l_min_cap_temp := (l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight) / l_txn_pri_uom_ratio;
12824 END IF;
12825 --
12826 -- End FP Bug 4634597
12827 --
12828 ELSIF l_eq_it_w_uom_ratio = -9999 THEN -- invalid weight conversion
12829 -- compute equipment capacity using volume
12830 l_min_cap_temp := TRUNC((l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio);
12831 --
12832 -- Start FP Bug 4634597
12833 --
12834 IF (l_min_cap_temp = 0) THEN
12835 l_min_cap_temp := (l_equip_vol * l_eq_it_v_uom_ratio / l_item_vol) / l_txn_pri_uom_ratio;
12836 END IF;
12837 --
12838 -- End FP Bug 4634597
12839 --
12840 ELSE -- both weight and volume defined
12841 -- compute the minimum of volume capacity and weight capacity
12842 -- transfer the capacity to transaction UOM
12843 l_min_cap_temp :=
12844 TRUNC(
12845 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))
12846 / l_txn_pri_uom_ratio
12847 );
12848 --
12849 -- Start FP Bug 4634597
12850 --
12851 IF (l_min_cap_temp = 0) THEN
12852 l_min_cap_temp := min_num((l_equip_vol * l_eq_it_v_uom_ratio /
12853 l_item_vol),(l_equip_weight * l_eq_it_w_uom_ratio / l_item_weight))
12854 / l_txn_pri_uom_ratio;
12855 END IF;
12856 --
12857 -- End FP Bug 4634597
12858 --
12859 END IF;
12860 IF (l_debug = 1) THEN
12861 print_debug('split_task 1.6, l_min_cap'||l_min_cap,4);
12862 print_debug('split_task 1.6, l_min_cap_temp'|| l_min_cap_temp,4);
12863 END IF;
12864 IF (l_min_cap = -1)
12865 OR(l_min_cap > l_min_cap_temp) THEN
12866 l_min_cap := l_min_cap_temp; -- get minimum capacity of all possible equipment
12867 END IF;
12868 ELSE -- neither of weight or volume capacity is properly defined
12869 IF (l_debug = 1) THEN
12870 print_debug('split_task 80 - invalid capacity for a particulcar equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12871 END IF;
12872 END IF;
12873 END LOOP;
12874
12875 l_progress := '90';
12876 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12877 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12878 CLOSE l_capcity_cur_bulk;
12879 else
12880 CLOSE l_capcity_cur;
12881 end if;
12882 l_progress := '100';
12883
12884 IF l_min_cap = -1 THEN -- min capcity is not properly queried
12885 fnd_message.set_name('WMS', 'WMS_INVALID_CAP_DEF');
12886 fnd_msg_pub.ADD;
12887
12888 IF (l_debug = 1) THEN
12889 print_debug('split_task 90 - invalid capacity for a ALL equipment' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12890 END IF;
12891
12892 RAISE fnd_api.g_exc_error;
12893 END IF;
12894
12895 -- compute splitting factor, round down equipment capacity to multiple of locator uom ratio
12896 IF l_min_cap >= l_loc_txn_uom_ratio THEN
12897 l_split_factor := TRUNC(l_min_cap / l_loc_txn_uom_ratio) * l_loc_txn_uom_ratio;
12898 ELSE
12899 l_split_factor := l_min_cap;
12900 END IF;
12901
12902 IF (l_debug = 1) THEN
12903 print_debug('split_task 100 - l_split_factor = ' || l_split_factor, 4);
12904 END IF;
12905
12906 IF l_split_factor <= 0 THEN -- min capcity is not properly queried
12907 fnd_message.set_name('WMS', 'WMS_INVALID_CAP_DEF');
12908 fnd_msg_pub.ADD;
12909
12910 IF (l_debug = 1) THEN
12911 print_debug('split_task 95 - minimum capacity 0' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
12912 END IF;
12913
12914 RAISE fnd_api.g_exc_error;
12915 END IF;
12916
12917 -- query the inital task
12918
12919 l_progress := '110';
12920
12921 --- patchset J bulk picking ---
12922 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12923 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12924 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --START',4); END IF;
12925 if (l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id) then -- bulk picking
12926 IF (l_init_qty > l_split_factor AND l_split_factor > 0) THEN -- only open the child cursor when split is needed
12927 IF (l_debug = 1) THEN
12928 print_debug('Patchset J bulk picking,open the child tasks...',4);
12929 END IF;
12930 open c_child_tasks(p_task_id);
12931 END IF;
12932 end if;
12933 -- IF (l_debug = 1) THEN print_debug('PATCHSET J-- BULK PICKING --END',4); END IF;
12934 end if;
12935 --- end of patchset J bulk picking ---
12936 l_progress := '120';
12937
12938 -- split task based on splitting factor
12939 WHILE(l_init_qty > l_split_factor
12940 AND l_split_factor > 0) LOOP
12941 IF (l_debug = 1) THEN
12942 print_debug('split_task 110 - splitting task - l_init_qty = ' || l_init_qty, 4);
12943 END IF;
12944
12945 l_counter := l_counter + 1;
12946 l_init_qty := l_init_qty - l_split_factor;
12947
12948 IF l_init_qty >= 0 THEN
12949 l_new_qty := l_split_factor;
12950 ELSE
12951 l_new_qty := l_init_qty + l_split_factor;
12952 END IF;
12953
12954 -- generate new tasks
12955 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12956 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12957 l_task_rec_new_mmtt := l_task_rec_old_mmtt;
12958 else
12959 l_task_rec_new_wct := l_task_rec_old_wct;
12960 end if;
12961 l_progress := '130';
12962
12963 -- generate new transaction_temp_id primary key
12964 SELECT mtl_material_transactions_s.NEXTVAL
12965 INTO l_new_temp_id
12966 FROM DUAL;
12967
12968 l_progress := '140';
12969 /* Is it necessary to change transaction UOM to locator UOM here ???*/
12970 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12971 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12972 l_task_rec_new_mmtt.transaction_temp_id := l_new_temp_id;
12973 l_task_rec_new_mmtt.transaction_quantity := l_new_qty;
12974 l_task_rec_new_mmtt.primary_quantity := l_new_qty * l_txn_pri_uom_ratio;
12975 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
12976 l_task_rec_new_mmtt.parent_line_id := l_new_temp_id;
12977 END IF;
12978 ELSE
12979 l_task_rec_new_wct.transaction_temp_id := l_new_temp_id;
12980 l_task_rec_new_wct.transaction_quantity := l_new_qty;
12981 l_task_rec_new_wct.primary_quantity := l_new_qty * l_txn_pri_uom_ratio;
12982 END IF;
12983
12984 -- l_task_rec_new.transaction_uom := l_loc_uom_code;
12985
12986 IF (l_debug = 1) THEN
12987 print_debug('split_task 120 - new task: ', 4);
12988 print_debug('l_new_temp_id => ' || l_new_temp_id, 4);
12989 print_debug('l_new_qty => ' || l_new_qty, 4);
12990 IF G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
12991 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
12992 print_debug('primary_quantity => ' || l_task_rec_new_mmtt.primary_quantity, 4);
12993 ELSE
12994 print_debug('primary_quantity => ' || l_task_rec_new_wct.primary_quantity, 4);
12995 END IF;
12996 END IF;
12997
12998 -- insert reccord into mmtt
12999 l_progress := '150';
13000 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13001 l_move_order_type = inv_globals.G_MOVE_ORDER_PICK_WAVE THEN
13002 insert_mmtt(l_task_rec_new_mmtt);
13003 else
13004 insert_wct(l_task_rec_new_wct);
13005 end if;
13006
13007 -- Associate the child lines if it is bulk picking
13008 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13009 l_move_order_type = G_MOVE_ORDER_PICK_WAVE AND
13010 l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13011
13012 -- IF (l_debug = 1) THEN
13013 -- print_debug('PATCHSET J BULK PICKING:starting to split',4);
13014 -- END IF;
13015 l_child_total_qty := 0;
13016 loop
13017 IF (l_debug = 1) THEN
13018 print_debug('l_child_remaining_qty:'||l_child_remaining_qty,4);
13019 END IF;
13020 if (l_child_remaining_qty = 0) then
13021 fetch c_child_tasks into l_child_rec;
13022 EXIT WHEN c_child_tasks%NOTFOUND;
13023
13024 l_child_remaining_qty := l_child_rec.transaction_quantity;
13025 l_child_temp_id := l_child_rec.transaction_temp_id;
13026 l_child_total_qty := l_child_total_qty + l_child_rec.transaction_quantity;
13027 else
13028 l_child_rec.transaction_quantity := l_child_remaining_qty;
13029 l_child_total_qty := l_child_remaining_qty;
13030 end if;
13031 IF (l_debug = 1) THEN
13032 print_debug('l_child_total_qty '||l_child_total_qty,4);
13033 END IF;
13034 if l_child_total_qty <= l_new_qty then
13035 -- update the child records with the new parent line id
13036 update mtl_material_transactions_temp
13037 set parent_line_id = l_new_temp_id
13038 where transaction_Temp_id = l_child_rec.transaction_temp_id;
13039 l_child_remaining_qty := 0;
13040 -- if = which means fully satisfied the new parent, can exit
13041 exit when l_child_total_qty = l_new_qty;
13042 else
13043 l_child_remaining_qty := l_child_total_qty - l_new_qty;
13044 -- find the qty to split
13045 l_new_child_qty := l_child_rec.transaction_quantity - l_child_remaining_qty;
13046 IF (l_debug = 1) THEN
13047 print_debug('update transaction temp id '||l_child_rec.transaction_temp_id
13048 || ' with the remaining qty '||l_child_remaining_qty,4);
13049 END IF;
13050 -- update the child line with the remaining qty
13051 update mtl_material_transactions_temp
13052 set transaction_quantity = l_child_remaining_qty
13053 , primary_quantity = l_child_remaining_qty * l_txn_pri_uom_ratio
13054 where transaction_temp_id = l_child_rec.transaction_temp_id;
13055
13056 -- split the child task
13057 -- generate new transaction_temp_id primary key
13058 SELECT mtl_material_transactions_s.NEXTVAL
13059 INTO l_new_child_temp_id
13060 FROM DUAL;
13061
13062 l_progress := '140.1';
13063 select *
13064 into
13065 l_child_rec_new
13066 from mtl_material_transactions_temp
13067 where transaction_temp_id = l_child_rec.transaction_temp_id;
13068
13069 /* Is it necessary to change transaction UOM to locator UOM here ???*/
13070 l_child_rec_new.transaction_temp_id := l_new_child_temp_id;
13071 l_child_rec_new.transaction_quantity := l_new_child_qty;
13072 l_child_rec_new.primary_quantity := l_new_child_qty * l_txn_pri_uom_ratio;
13073 l_child_rec_new.parent_line_id := l_new_temp_id; -- update the new line with the correct parent
13074
13075
13076
13077 IF (l_debug = 1) THEN
13078 print_debug('split_task for child line - new child task: ', 4);
13079 print_debug('l_new_temp_id => ' || l_new_child_temp_id, 4);
13080 print_debug('l_new_qty => ' || l_new_child_qty, 4);
13081 print_debug('primary_quantity => ' || l_child_rec_new.primary_quantity, 4);
13082 print_debug('parent_line_id '||l_new_temp_id,4);
13083 END IF;
13084
13085 -- insert reccord into mmtt
13086 l_progress := '150.1';
13087 insert_mmtt(l_child_rec_new);
13088
13089
13090 -- split lot/serial temp table
13091
13092 l_lot_split_rec(1).transaction_id := l_new_child_temp_id;
13093 l_lot_split_rec(1).primary_quantity := l_child_rec_new.primary_quantity;
13094 IF (l_debug = 1) THEN
13095 print_debug('calling BREAK to insert the lot and serial',4);
13096 END IF;
13097 inv_rcv_common_apis.BREAK(
13098 p_original_tid => l_child_rec.transaction_temp_id
13099 , p_new_transactions_tb => l_lot_split_rec
13100 , p_lot_control_code => l_lot_control_code
13101 , p_serial_control_code => l_serial_number_control_code
13102 );
13103 IF (l_debug = 1) THEN print_debug('After insert the lot and serial for the split child',4);
13104 END IF;
13105 EXIT;
13106 end if;
13107 end loop;
13108 -- copy the lot and serial to the parents
13109 IF (l_debug = 1) THEN
13110 print_debug('calling duplicate_lot_serial_in_parent....',4);
13111 END IF;
13112 Duplicate_lot_serial_in_parent(l_new_temp_id,x_return_status,x_msg_count,x_msg_data);
13113
13114 if (x_return_status <> fnd_api.g_ret_sts_success) then
13115 IF (l_debug = 1) THEN
13116 print_debug('split_task 150.2 - error in duplicate_lot_serial_in_parent ', 4);
13117 END IF;
13118 raise fnd_api.g_exc_unexpected_error;
13119 end if;
13120 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13121 END IF;
13122
13123 --- end of patchset J bulk picking -----------------
13124
13125 -- split lot/serial temp table
13126 IF l_task_rec_old_wct.parent_line_id is null THEN -- bulk picking patchset J ---- this is only for non bulk task
13127 l_lot_split_rec(1).transaction_id := l_new_temp_id;
13128 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13129 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13130 l_lot_split_rec(1).primary_quantity := l_task_rec_new_mmtt.primary_quantity;
13131 else
13132 l_lot_split_rec(1).primary_quantity := l_task_rec_new_wct.primary_quantity;
13133 end if;
13134 inv_rcv_common_apis.BREAK(
13135 p_original_tid => p_task_id
13136 , p_new_transactions_tb => l_lot_split_rec
13137 , p_lot_control_code => l_lot_control_code
13138 , p_serial_control_code => l_serial_number_control_code
13139 );
13140 END IF;
13141 l_progress := '160';
13142 END LOOP;
13143
13144 IF (l_debug = 1) THEN
13145 print_debug('split_task 130 - remove original task: ', 4);
13146 END IF;
13147
13148 IF ((l_init_qty <= l_split_factor)) THEN
13149 UPDATE wms_cartonization_temp
13150 SET transaction_quantity = l_init_qty
13151 , primary_quantity = l_init_qty * l_txn_pri_uom_ratio
13152 WHERE transaction_temp_id = p_task_id;
13153 -- for patchset J bulk picking -----------
13154 -- the lot and serial info still need to be duplicated since consolidation didn't do it
13155 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13156 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13157 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- START',4); END IF;
13158 UPDATE mtl_material_transactions_temp
13159 SET transaction_quantity = l_init_qty
13160 , primary_quantity = l_init_qty * l_txn_pri_uom_ratio
13161 WHERE transaction_temp_id = p_task_id;
13162 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13163 -- copy the lot and serial to the parents
13164 IF (l_debug = 1) THEN
13165 print_debug('calling duplicate_lot_serial_in_parent for the last ....',4);
13166 END IF;
13167 Duplicate_lot_serial_in_parent(p_task_id,x_return_status,x_msg_count,x_msg_data);
13168 if (x_return_status <> fnd_api.g_ret_sts_success) then
13169 IF (l_debug = 1) THEN
13170 print_debug('split_task 150.2 - error in duplicate_lot_serial_in_parent ', 4);
13171 END IF;
13172 raise fnd_api.g_exc_unexpected_error;
13173 end if;
13174 END IF;
13175 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13176 end if; -- end of patchset J bulk picking ----------
13177 END IF;
13178
13179 /*
13180
13181 IF l_init_qty <= 0 THEN
13182 DELETE wms_cartonization_temp
13183 WHERE transaction_temp_id = p_task_id;
13184 END IF;
13185 */
13186 IF (l_debug = 1) THEN
13187 print_debug('split_task 140 - complete ', 4);
13188 END IF;
13189 EXCEPTION
13190 WHEN fnd_api.g_exc_error THEN
13191 x_return_status := fnd_api.g_ret_sts_error;
13192 ROLLBACK TO sp_task_split;
13193 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13194
13195 IF (l_debug = 1) THEN
13196 print_debug(
13197 'split_task: Raise expected exception. But the task generation process should continue processing, only that tasks are not split according to equipment capacity. '
13198 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
13199 , 1
13200 );
13201 END IF;
13202 -- for patchset J bulk picking -----------
13203 -- the lot and serial info still need to be duplicated since consolidation didn't do it
13204 if G_CURRENT_RELEASE_LEVEL >= G_J_RELEASE_LEVEL AND
13205 l_move_order_type = G_MOVE_ORDER_PICK_WAVE THEN
13206 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- START',4); END IF;
13207
13208 IF l_task_rec_old_mmtt.transaction_temp_id = l_task_rec_old_mmtt.parent_line_id THEN
13209 -- copy the lot and serial to the parents
13210 IF (l_debug = 1) THEN
13211 print_debug('calling duplicate_lot_serial_in_parent for the parent line ....',4);
13212 END IF;
13213 Duplicate_lot_serial_in_parent(p_task_id,x_return_status,x_msg_count,x_msg_data);
13214 if (x_return_status <> fnd_api.g_ret_sts_success) then
13215 IF (l_debug = 1) THEN
13216 print_debug('split_task 1000- error in duplicate_lot_serial_in_parent ', 4);
13217 END IF;
13218 -- change to unexpected error
13219 x_return_status := fnd_api.g_ret_sts_unexp_error;
13220 end if;
13221 END IF;
13222 -- IF (l_debug = 1) THEN print_debug('PATCHSET J -- BULK PICKING --- END',4); END IF;
13223 end if; -- end of patchset J bulk picking ----------
13224
13225 WHEN fnd_api.g_exc_unexpected_error THEN
13226 x_return_status := fnd_api.g_ret_sts_unexp_error;
13227 ROLLBACK TO sp_task_split;
13228 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13229
13230 IF (l_debug = 1) THEN
13231 print_debug('split_task: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
13232 END IF;
13233 WHEN OTHERS THEN
13234 x_return_status := fnd_api.g_ret_sts_unexp_error;
13235 ROLLBACK TO sp_task_split;
13236
13237 IF SQLCODE IS NOT NULL THEN
13238 inv_mobile_helper_functions.sql_error('WMS_Task_Dispatch_Engine.split_task', l_progress, SQLCODE);
13239 END IF;
13240
13241 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
13242
13243 IF (l_debug = 1) THEN
13244 print_debug('split_task: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
13245 END IF;
13246 END split_task;
13247
13248 PROCEDURE insert_mmtt(l_mmtt_rec mtl_material_transactions_temp%ROWTYPE) IS
13249 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
13250 BEGIN
13251 INSERT INTO mtl_material_transactions_temp
13252 (
13253 transaction_header_id
13254 , transaction_temp_id
13255 , source_code
13256 , source_line_id
13257 , transaction_mode
13258 , lock_flag
13259 , last_update_date
13260 , last_updated_by
13261 , creation_date
13262 , created_by
13263 , last_update_login
13264 , request_id
13265 , program_application_id
13266 , program_id
13267 , program_update_date
13268 , inventory_item_id
13269 , revision
13270 , organization_id
13271 , subinventory_code
13272 , locator_id
13273 , transaction_quantity
13274 , primary_quantity
13275 , transaction_uom
13276 , transaction_cost
13277 , transaction_type_id
13278 , transaction_action_id
13279 , transaction_source_type_id
13280 , transaction_source_id
13281 , transaction_source_name
13282 , transaction_date
13283 , acct_period_id
13284 , distribution_account_id
13285 , transaction_reference
13286 , requisition_line_id
13287 , requisition_distribution_id
13288 , reason_id
13289 , lot_number
13290 , lot_expiration_date
13291 , serial_number
13292 , receiving_document
13293 , demand_id
13294 , rcv_transaction_id
13295 , move_transaction_id
13296 , completion_transaction_id
13297 , wip_entity_type
13298 , schedule_id
13299 , repetitive_line_id
13300 , employee_code
13301 , primary_switch
13302 , schedule_update_code
13303 , setup_teardown_code
13304 , item_ordering
13305 , negative_req_flag
13306 , operation_seq_num
13307 , picking_line_id
13308 , trx_source_line_id
13309 , trx_source_delivery_id
13310 , physical_adjustment_id
13311 , cycle_count_id
13312 , rma_line_id
13313 , customer_ship_id
13314 , currency_code
13315 , currency_conversion_rate
13316 , currency_conversion_type
13317 , currency_conversion_date
13318 , ussgl_transaction_code
13319 , vendor_lot_number
13320 , encumbrance_account
13321 , encumbrance_amount
13322 , ship_to_location
13323 , shipment_number
13324 , transfer_cost
13325 , transportation_cost
13326 , transportation_account
13327 , freight_code
13328 , containers
13329 , waybill_airbill
13330 , expected_arrival_date
13331 , transfer_subinventory
13332 , transfer_organization
13333 , transfer_to_location
13334 , new_average_cost
13335 , value_change
13336 , percentage_change
13337 , material_allocation_temp_id
13338 , demand_source_header_id
13339 , demand_source_line
13340 , demand_source_delivery
13341 , item_segments
13342 , item_description
13343 , item_trx_enabled_flag
13344 , item_location_control_code
13345 , item_restrict_subinv_code
13346 , item_restrict_locators_code
13347 , item_revision_qty_control_code
13348 , item_primary_uom_code
13349 , item_uom_class
13350 , item_shelf_life_code
13351 , item_shelf_life_days
13352 , item_lot_control_code
13353 , item_serial_control_code
13354 , item_inventory_asset_flag
13355 , allowed_units_lookup_code
13356 , department_id
13357 , department_code
13358 , wip_supply_type
13359 , supply_subinventory
13360 , supply_locator_id
13361 , valid_subinventory_flag
13362 , valid_locator_flag
13363 , locator_segments
13364 , current_locator_control_code
13365 , number_of_lots_entered
13366 , wip_commit_flag
13367 , next_lot_number
13368 , lot_alpha_prefix
13369 , next_serial_number
13370 , serial_alpha_prefix
13371 , shippable_flag
13372 , posting_flag
13373 , required_flag
13374 , process_flag
13375 , ERROR_CODE
13376 , error_explanation
13377 , attribute_category
13378 , attribute1
13379 , attribute2
13380 , attribute3
13381 , attribute4
13382 , attribute5
13383 , attribute6
13384 , attribute7
13385 , attribute8
13386 , attribute9
13387 , attribute10
13388 , attribute11
13389 , attribute12
13390 , attribute13
13391 , attribute14
13392 , attribute15
13393 , movement_id
13394 , reservation_quantity
13395 , shipped_quantity
13396 , transaction_line_number
13397 , task_id
13398 , to_task_id
13399 , source_task_id
13400 , project_id
13401 , source_project_id
13402 , pa_expenditure_org_id
13403 , to_project_id
13404 , expenditure_type
13405 , final_completion_flag
13406 , transfer_percentage
13407 , transaction_sequence_id
13408 , material_account
13409 , material_overhead_account
13410 , resource_account
13411 , outside_processing_account
13412 , overhead_account
13413 , flow_schedule
13414 , cost_group_id
13415 , transfer_cost_group_id
13416 , demand_class
13417 , qa_collection_id
13418 , kanban_card_id
13419 , overcompletion_transaction_qty
13420 , overcompletion_primary_qty
13421 , overcompletion_transaction_id
13422 , end_item_unit_number
13423 , scheduled_payback_date
13424 , line_type_code
13425 , parent_transaction_temp_id
13426 , put_away_strategy_id
13427 , put_away_rule_id
13428 , pick_strategy_id
13429 , pick_rule_id
13430 , move_order_line_id
13431 , task_group_id
13432 , pick_slip_number
13433 , reservation_id
13434 , common_bom_seq_id
13435 , common_routing_seq_id
13436 , org_cost_group_id
13437 , cost_type_id
13438 , transaction_status
13439 , standard_operation_id
13440 , task_priority
13441 , wms_task_type
13442 , parent_line_id
13443 , lpn_id
13444 , transfer_lpn_id
13445 , wms_task_status
13446 , content_lpn_id
13447 , container_item_id
13448 , cartonization_id
13449 , pick_slip_date
13450 , rebuild_item_id
13451 , rebuild_serial_number
13452 , rebuild_activity_id
13453 , rebuild_job_name
13454 , organization_type
13455 , transfer_organization_type
13456 , owning_organization_id
13457 , owning_tp_type
13458 , xfr_owning_organization_id
13459 , transfer_owning_tp_type
13460 , planning_organization_id
13461 , planning_tp_type
13462 , xfr_planning_organization_id
13463 , transfer_planning_tp_type
13464 , secondary_uom_code
13465 , secondary_transaction_quantity
13466 , transaction_batch_id
13467 , transaction_batch_seq
13468 , allocated_lpn_id
13469 , schedule_number
13470 , scheduled_flag
13471 , class_code
13472 , schedule_group
13473 , build_sequence
13474 , bom_revision
13475 , routing_revision
13476 , bom_revision_date
13477 , routing_revision_date
13478 , alternate_bom_designator
13479 , alternate_routing_designator
13480 , operation_plan_id
13481 , serial_allocated_flag
13482 , move_order_header_id
13483 )
13484 VALUES (
13485 l_mmtt_rec.transaction_header_id
13486 , l_mmtt_rec.transaction_temp_id
13487 , l_mmtt_rec.source_code
13488 , l_mmtt_rec.source_line_id
13489 , l_mmtt_rec.transaction_mode
13490 , l_mmtt_rec.lock_flag
13491 , l_mmtt_rec.last_update_date
13492 , l_mmtt_rec.last_updated_by
13493 , l_mmtt_rec.creation_date
13494 , l_mmtt_rec.created_by
13495 , l_mmtt_rec.last_update_login
13496 , l_mmtt_rec.request_id
13497 , l_mmtt_rec.program_application_id
13498 , l_mmtt_rec.program_id
13499 , l_mmtt_rec.program_update_date
13500 , l_mmtt_rec.inventory_item_id
13501 , l_mmtt_rec.revision
13502 , l_mmtt_rec.organization_id
13503 , l_mmtt_rec.subinventory_code
13504 , l_mmtt_rec.locator_id
13505 , l_mmtt_rec.transaction_quantity
13506 , l_mmtt_rec.primary_quantity
13507 , l_mmtt_rec.transaction_uom
13508 , l_mmtt_rec.transaction_cost
13509 , l_mmtt_rec.transaction_type_id
13510 , l_mmtt_rec.transaction_action_id
13511 , l_mmtt_rec.transaction_source_type_id
13512 , l_mmtt_rec.transaction_source_id
13513 , l_mmtt_rec.transaction_source_name
13514 , l_mmtt_rec.transaction_date
13515 , l_mmtt_rec.acct_period_id
13516 , l_mmtt_rec.distribution_account_id
13517 , l_mmtt_rec.transaction_reference
13518 , l_mmtt_rec.requisition_line_id
13519 , l_mmtt_rec.requisition_distribution_id
13520 , l_mmtt_rec.reason_id
13521 , l_mmtt_rec.lot_number
13522 , l_mmtt_rec.lot_expiration_date
13523 , l_mmtt_rec.serial_number
13524 , l_mmtt_rec.receiving_document
13525 , l_mmtt_rec.demand_id
13526 , l_mmtt_rec.rcv_transaction_id
13527 , l_mmtt_rec.move_transaction_id
13528 , l_mmtt_rec.completion_transaction_id
13529 , l_mmtt_rec.wip_entity_type
13530 , l_mmtt_rec.schedule_id
13531 , l_mmtt_rec.repetitive_line_id
13532 , l_mmtt_rec.employee_code
13533 , l_mmtt_rec.primary_switch
13534 , l_mmtt_rec.schedule_update_code
13535 , l_mmtt_rec.setup_teardown_code
13536 , l_mmtt_rec.item_ordering
13537 , l_mmtt_rec.negative_req_flag
13538 , l_mmtt_rec.operation_seq_num
13539 , l_mmtt_rec.picking_line_id
13540 , l_mmtt_rec.trx_source_line_id
13541 , l_mmtt_rec.trx_source_delivery_id
13542 , l_mmtt_rec.physical_adjustment_id
13543 , l_mmtt_rec.cycle_count_id
13544 , l_mmtt_rec.rma_line_id
13545 , l_mmtt_rec.customer_ship_id
13546 , l_mmtt_rec.currency_code
13547 , l_mmtt_rec.currency_conversion_rate
13548 , l_mmtt_rec.currency_conversion_type
13549 , l_mmtt_rec.currency_conversion_date
13550 , l_mmtt_rec.ussgl_transaction_code
13551 , l_mmtt_rec.vendor_lot_number
13552 , l_mmtt_rec.encumbrance_account
13553 , l_mmtt_rec.encumbrance_amount
13554 , l_mmtt_rec.ship_to_location
13555 , l_mmtt_rec.shipment_number
13556 , l_mmtt_rec.transfer_cost
13557 , l_mmtt_rec.transportation_cost
13558 , l_mmtt_rec.transportation_account
13559 , l_mmtt_rec.freight_code
13560 , l_mmtt_rec.containers
13561 , l_mmtt_rec.waybill_airbill
13562 , l_mmtt_rec.expected_arrival_date
13563 , l_mmtt_rec.transfer_subinventory
13564 , l_mmtt_rec.transfer_organization
13565 , l_mmtt_rec.transfer_to_location
13566 , l_mmtt_rec.new_average_cost
13567 , l_mmtt_rec.value_change
13568 , l_mmtt_rec.percentage_change
13569 , l_mmtt_rec.material_allocation_temp_id
13570 , l_mmtt_rec.demand_source_header_id
13571 , l_mmtt_rec.demand_source_line
13572 , l_mmtt_rec.demand_source_delivery
13573 , l_mmtt_rec.item_segments
13574 , l_mmtt_rec.item_description
13575 , l_mmtt_rec.item_trx_enabled_flag
13576 , l_mmtt_rec.item_location_control_code
13577 , l_mmtt_rec.item_restrict_subinv_code
13578 , l_mmtt_rec.item_restrict_locators_code
13579 , l_mmtt_rec.item_revision_qty_control_code
13580 , l_mmtt_rec.item_primary_uom_code
13581 , l_mmtt_rec.item_uom_class
13582 , l_mmtt_rec.item_shelf_life_code
13583 , l_mmtt_rec.item_shelf_life_days
13584 , l_mmtt_rec.item_lot_control_code
13585 , l_mmtt_rec.item_serial_control_code
13586 , l_mmtt_rec.item_inventory_asset_flag
13587 , l_mmtt_rec.allowed_units_lookup_code
13588 , l_mmtt_rec.department_id
13589 , l_mmtt_rec.department_code
13590 , l_mmtt_rec.wip_supply_type
13591 , l_mmtt_rec.supply_subinventory
13592 , l_mmtt_rec.supply_locator_id
13593 , l_mmtt_rec.valid_subinventory_flag
13594 , l_mmtt_rec.valid_locator_flag
13595 , l_mmtt_rec.locator_segments
13596 , l_mmtt_rec.current_locator_control_code
13597 , l_mmtt_rec.number_of_lots_entered
13598 , l_mmtt_rec.wip_commit_flag
13599 , l_mmtt_rec.next_lot_number
13600 , l_mmtt_rec.lot_alpha_prefix
13601 , l_mmtt_rec.next_serial_number
13602 , l_mmtt_rec.serial_alpha_prefix
13603 , l_mmtt_rec.shippable_flag
13604 , l_mmtt_rec.posting_flag
13605 , l_mmtt_rec.required_flag
13606 , l_mmtt_rec.process_flag
13607 , l_mmtt_rec.ERROR_CODE
13608 , l_mmtt_rec.error_explanation
13609 , l_mmtt_rec.attribute_category
13610 , l_mmtt_rec.attribute1
13611 , l_mmtt_rec.attribute2
13612 , l_mmtt_rec.attribute3
13613 , l_mmtt_rec.attribute4
13614 , l_mmtt_rec.attribute5
13615 , l_mmtt_rec.attribute6
13616 , l_mmtt_rec.attribute7
13617 , l_mmtt_rec.attribute8
13618 , l_mmtt_rec.attribute9
13619 , l_mmtt_rec.attribute10
13620 , l_mmtt_rec.attribute11
13621 , l_mmtt_rec.attribute12
13622 , l_mmtt_rec.attribute13
13623 , l_mmtt_rec.attribute14
13624 , l_mmtt_rec.attribute15
13625 , l_mmtt_rec.movement_id
13626 , l_mmtt_rec.reservation_quantity
13627 , l_mmtt_rec.shipped_quantity
13628 , l_mmtt_rec.transaction_line_number
13629 , l_mmtt_rec.task_id
13630 , l_mmtt_rec.to_task_id
13631 , l_mmtt_rec.source_task_id
13632 , l_mmtt_rec.project_id
13633 , l_mmtt_rec.source_project_id
13634 , l_mmtt_rec.pa_expenditure_org_id
13635 , l_mmtt_rec.to_project_id
13636 , l_mmtt_rec.expenditure_type
13637 , l_mmtt_rec.final_completion_flag
13638 , l_mmtt_rec.transfer_percentage
13639 , l_mmtt_rec.transaction_sequence_id
13640 , l_mmtt_rec.material_account
13641 , l_mmtt_rec.material_overhead_account
13642 , l_mmtt_rec.resource_account
13643 , l_mmtt_rec.outside_processing_account
13644 , l_mmtt_rec.overhead_account
13645 , l_mmtt_rec.flow_schedule
13646 , l_mmtt_rec.cost_group_id
13647 , l_mmtt_rec.transfer_cost_group_id
13648 , l_mmtt_rec.demand_class
13649 , l_mmtt_rec.qa_collection_id
13650 , l_mmtt_rec.kanban_card_id
13651 , l_mmtt_rec.overcompletion_transaction_qty
13652 , l_mmtt_rec.overcompletion_primary_qty
13653 , l_mmtt_rec.overcompletion_transaction_id
13654 , l_mmtt_rec.end_item_unit_number
13655 , l_mmtt_rec.scheduled_payback_date
13656 , l_mmtt_rec.line_type_code
13657 , l_mmtt_rec.parent_transaction_temp_id
13658 , l_mmtt_rec.put_away_strategy_id
13659 , l_mmtt_rec.put_away_rule_id
13660 , l_mmtt_rec.pick_strategy_id
13661 , l_mmtt_rec.pick_rule_id
13662 , l_mmtt_rec.move_order_line_id
13663 , l_mmtt_rec.task_group_id
13664 , l_mmtt_rec.pick_slip_number
13665 , l_mmtt_rec.reservation_id
13666 , l_mmtt_rec.common_bom_seq_id
13667 , l_mmtt_rec.common_routing_seq_id
13668 , l_mmtt_rec.org_cost_group_id
13669 , l_mmtt_rec.cost_type_id
13670 , l_mmtt_rec.transaction_status
13671 , l_mmtt_rec.standard_operation_id
13672 , l_mmtt_rec.task_priority
13673 , l_mmtt_rec.wms_task_type
13674 , l_mmtt_rec.parent_line_id
13675 , l_mmtt_rec.lpn_id
13676 , l_mmtt_rec.transfer_lpn_id
13677 , l_mmtt_rec.wms_task_status
13678 , l_mmtt_rec.content_lpn_id
13679 , l_mmtt_rec.container_item_id
13680 , l_mmtt_rec.cartonization_id
13681 , l_mmtt_rec.pick_slip_date
13682 , l_mmtt_rec.rebuild_item_id
13683 , l_mmtt_rec.rebuild_serial_number
13684 , l_mmtt_rec.rebuild_activity_id
13685 , l_mmtt_rec.rebuild_job_name
13686 , l_mmtt_rec.organization_type
13687 , l_mmtt_rec.transfer_organization_type
13688 , l_mmtt_rec.owning_organization_id
13689 , l_mmtt_rec.owning_tp_type
13690 , l_mmtt_rec.xfr_owning_organization_id
13691 , l_mmtt_rec.transfer_owning_tp_type
13692 , l_mmtt_rec.planning_organization_id
13693 , l_mmtt_rec.planning_tp_type
13694 , l_mmtt_rec.xfr_planning_organization_id
13695 , l_mmtt_rec.transfer_planning_tp_type
13696 , l_mmtt_rec.secondary_uom_code
13697 , l_mmtt_rec.secondary_transaction_quantity
13698 , l_mmtt_rec.transaction_batch_id
13699 , l_mmtt_rec.transaction_batch_seq
13700 , l_mmtt_rec.allocated_lpn_id
13701 , l_mmtt_rec.schedule_number
13702 , l_mmtt_rec.scheduled_flag
13703 , l_mmtt_rec.class_code
13704 , l_mmtt_rec.schedule_group
13705 , l_mmtt_rec.build_sequence
13706 , l_mmtt_rec.bom_revision
13707 , l_mmtt_rec.routing_revision
13708 , l_mmtt_rec.bom_revision_date
13709 , l_mmtt_rec.routing_revision_date
13710 , l_mmtt_rec.alternate_bom_designator
13711 , l_mmtt_rec.alternate_routing_designator
13712 , l_mmtt_rec.operation_plan_id
13713 , l_mmtt_rec.serial_allocated_flag
13714 , l_mmtt_rec.move_order_header_id
13715 );
13716 END insert_mmtt;
13717
13718 PROCEDURE insert_wct(l_wct_rec wms_cartonization_temp%ROWTYPE) IS
13719 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
13720 BEGIN
13721 INSERT INTO wms_cartonization_temp
13722 (
13723 transaction_header_id
13724 , transaction_temp_id
13725 , source_code
13726 , source_line_id
13727 , transaction_mode
13728 , lock_flag
13729 , last_update_date
13730 , last_updated_by
13731 , creation_date
13732 , created_by
13733 , last_update_login
13734 , request_id
13735 , program_application_id
13736 , program_id
13737 , program_update_date
13738 , inventory_item_id
13739 , revision
13740 , organization_id
13741 , subinventory_code
13742 , locator_id
13743 , transaction_quantity
13744 , primary_quantity
13745 , transaction_uom
13746 , transaction_cost
13747 , transaction_type_id
13748 , transaction_action_id
13749 , transaction_source_type_id
13750 , transaction_source_id
13751 , transaction_source_name
13752 , transaction_date
13753 , acct_period_id
13754 , distribution_account_id
13755 , transaction_reference
13756 , requisition_line_id
13757 , requisition_distribution_id
13758 , reason_id
13759 , lot_number
13760 , lot_expiration_date
13761 , serial_number
13762 , receiving_document
13763 , demand_id
13764 , rcv_transaction_id
13765 , move_transaction_id
13766 , completion_transaction_id
13767 , wip_entity_type
13768 , schedule_id
13769 , repetitive_line_id
13770 , employee_code
13771 , primary_switch
13772 , schedule_update_code
13773 , setup_teardown_code
13774 , item_ordering
13775 , negative_req_flag
13776 , operation_seq_num
13777 , picking_line_id
13778 , trx_source_line_id
13779 , trx_source_delivery_id
13780 , physical_adjustment_id
13781 , cycle_count_id
13782 , rma_line_id
13783 , customer_ship_id
13784 , currency_code
13785 , currency_conversion_rate
13786 , currency_conversion_type
13787 , currency_conversion_date
13788 , ussgl_transaction_code
13789 , vendor_lot_number
13790 , encumbrance_account
13791 , encumbrance_amount
13792 , ship_to_location
13793 , shipment_number
13794 , transfer_cost
13795 , transportation_cost
13796 , transportation_account
13797 , freight_code
13798 , containers
13799 , waybill_airbill
13800 , expected_arrival_date
13801 , transfer_subinventory
13802 , transfer_organization
13803 , transfer_to_location
13804 , new_average_cost
13805 , value_change
13806 , percentage_change
13807 , material_allocation_temp_id
13808 , demand_source_header_id
13809 , demand_source_line
13810 , demand_source_delivery
13811 , item_segments
13812 , item_description
13813 , item_trx_enabled_flag
13814 , item_location_control_code
13815 , item_restrict_subinv_code
13816 , item_restrict_locators_code
13817 , item_revision_qty_control_code
13818 , item_primary_uom_code
13819 , item_uom_class
13820 , item_shelf_life_code
13821 , item_shelf_life_days
13822 , item_lot_control_code
13823 , item_serial_control_code
13824 , item_inventory_asset_flag
13825 , allowed_units_lookup_code
13826 , department_id
13827 , department_code
13828 , wip_supply_type
13829 , supply_subinventory
13830 , supply_locator_id
13831 , valid_subinventory_flag
13832 , valid_locator_flag
13833 , locator_segments
13834 , current_locator_control_code
13835 , number_of_lots_entered
13836 , wip_commit_flag
13837 , next_lot_number
13838 , lot_alpha_prefix
13839 , next_serial_number
13840 , serial_alpha_prefix
13841 , shippable_flag
13842 , posting_flag
13843 , required_flag
13844 , process_flag
13845 , ERROR_CODE
13846 , error_explanation
13847 , attribute_category
13848 , attribute1
13849 , attribute2
13850 , attribute3
13851 , attribute4
13852 , attribute5
13853 , attribute6
13854 , attribute7
13855 , attribute8
13856 , attribute9
13857 , attribute10
13858 , attribute11
13859 , attribute12
13860 , attribute13
13861 , attribute14
13862 , attribute15
13863 , movement_id
13864 , reservation_quantity
13865 , shipped_quantity
13866 , transaction_line_number
13867 , task_id
13868 , to_task_id
13869 , source_task_id
13870 , project_id
13871 , source_project_id
13872 , pa_expenditure_org_id
13873 , to_project_id
13874 , expenditure_type
13875 , final_completion_flag
13876 , transfer_percentage
13877 , transaction_sequence_id
13878 , material_account
13879 , material_overhead_account
13880 , resource_account
13881 , outside_processing_account
13882 , overhead_account
13883 , flow_schedule
13884 , cost_group_id
13885 , transfer_cost_group_id
13886 , demand_class
13887 , qa_collection_id
13888 , kanban_card_id
13889 , overcompletion_transaction_qty
13890 , overcompletion_primary_qty
13891 , overcompletion_transaction_id
13892 , end_item_unit_number
13893 , scheduled_payback_date
13894 , line_type_code
13895 , parent_transaction_temp_id
13896 , put_away_strategy_id
13897 , put_away_rule_id
13898 , pick_strategy_id
13899 , pick_rule_id
13900 , move_order_line_id
13901 , task_group_id
13902 , pick_slip_number
13903 , reservation_id
13904 , common_bom_seq_id
13905 , common_routing_seq_id
13906 , org_cost_group_id
13907 , cost_type_id
13908 , transaction_status
13909 , standard_operation_id
13910 , task_priority
13911 , wms_task_type
13912 , parent_line_id
13913 , lpn_id
13914 , transfer_lpn_id
13915 , wms_task_status
13916 , content_lpn_id
13917 , container_item_id
13918 , cartonization_id
13919 , pick_slip_date
13920 , rebuild_item_id
13921 , rebuild_serial_number
13922 , rebuild_activity_id
13923 , rebuild_job_name
13924 , organization_type
13925 , transfer_organization_type
13926 , owning_organization_id
13927 , owning_tp_type
13928 , xfr_owning_organization_id
13929 , transfer_owning_tp_type
13930 , planning_organization_id
13931 , planning_tp_type
13932 , xfr_planning_organization_id
13933 , transfer_planning_tp_type
13934 , secondary_uom_code
13935 , secondary_transaction_quantity
13936 , transaction_batch_id
13937 , transaction_batch_seq
13938 , allocated_lpn_id
13939 , schedule_number
13940 , scheduled_flag
13941 , class_code
13942 , schedule_group
13943 , build_sequence
13944 , bom_revision
13945 , routing_revision
13946 , bom_revision_date
13947 , routing_revision_date
13948 , alternate_bom_designator
13949 , alternate_routing_designator
13950 , operation_plan_id
13951 , serial_allocated_flag
13952 , move_order_header_id
13953 )
13954 VALUES (
13955 l_wct_rec.transaction_header_id
13956 , l_wct_rec.transaction_temp_id
13957 , l_wct_rec.source_code
13958 , l_wct_rec.source_line_id
13959 , l_wct_rec.transaction_mode
13960 , l_wct_rec.lock_flag
13961 , l_wct_rec.last_update_date
13962 , l_wct_rec.last_updated_by
13963 , l_wct_rec.creation_date
13964 , l_wct_rec.created_by
13965 , l_wct_rec.last_update_login
13966 , l_wct_rec.request_id
13967 , l_wct_rec.program_application_id
13968 , l_wct_rec.program_id
13969 , l_wct_rec.program_update_date
13970 , l_wct_rec.inventory_item_id
13971 , l_wct_rec.revision
13972 , l_wct_rec.organization_id
13973 , l_wct_rec.subinventory_code
13974 , l_wct_rec.locator_id
13975 , l_wct_rec.transaction_quantity
13976 , l_wct_rec.primary_quantity
13977 , l_wct_rec.transaction_uom
13978 , l_wct_rec.transaction_cost
13979 , l_wct_rec.transaction_type_id
13980 , l_wct_rec.transaction_action_id
13981 , l_wct_rec.transaction_source_type_id
13982 , l_wct_rec.transaction_source_id
13983 , l_wct_rec.transaction_source_name
13984 , l_wct_rec.transaction_date
13985 , l_wct_rec.acct_period_id
13986 , l_wct_rec.distribution_account_id
13987 , l_wct_rec.transaction_reference
13988 , l_wct_rec.requisition_line_id
13989 , l_wct_rec.requisition_distribution_id
13990 , l_wct_rec.reason_id
13991 , l_wct_rec.lot_number
13992 , l_wct_rec.lot_expiration_date
13993 , l_wct_rec.serial_number
13994 , l_wct_rec.receiving_document
13995 , l_wct_rec.demand_id
13996 , l_wct_rec.rcv_transaction_id
13997 , l_wct_rec.move_transaction_id
13998 , l_wct_rec.completion_transaction_id
13999 , l_wct_rec.wip_entity_type
14000 , l_wct_rec.schedule_id
14001 , l_wct_rec.repetitive_line_id
14002 , l_wct_rec.employee_code
14003 , l_wct_rec.primary_switch
14004 , l_wct_rec.schedule_update_code
14005 , l_wct_rec.setup_teardown_code
14006 , l_wct_rec.item_ordering
14007 , l_wct_rec.negative_req_flag
14008 , l_wct_rec.operation_seq_num
14009 , l_wct_rec.picking_line_id
14010 , l_wct_rec.trx_source_line_id
14011 , l_wct_rec.trx_source_delivery_id
14012 , l_wct_rec.physical_adjustment_id
14013 , l_wct_rec.cycle_count_id
14014 , l_wct_rec.rma_line_id
14015 , l_wct_rec.customer_ship_id
14016 , l_wct_rec.currency_code
14017 , l_wct_rec.currency_conversion_rate
14018 , l_wct_rec.currency_conversion_type
14019 , l_wct_rec.currency_conversion_date
14020 , l_wct_rec.ussgl_transaction_code
14021 , l_wct_rec.vendor_lot_number
14022 , l_wct_rec.encumbrance_account
14023 , l_wct_rec.encumbrance_amount
14024 , l_wct_rec.ship_to_location
14025 , l_wct_rec.shipment_number
14026 , l_wct_rec.transfer_cost
14027 , l_wct_rec.transportation_cost
14028 , l_wct_rec.transportation_account
14029 , l_wct_rec.freight_code
14030 , l_wct_rec.containers
14031 , l_wct_rec.waybill_airbill
14032 , l_wct_rec.expected_arrival_date
14033 , l_wct_rec.transfer_subinventory
14034 , l_wct_rec.transfer_organization
14035 , l_wct_rec.transfer_to_location
14036 , l_wct_rec.new_average_cost
14037 , l_wct_rec.value_change
14038 , l_wct_rec.percentage_change
14039 , l_wct_rec.material_allocation_temp_id
14040 , l_wct_rec.demand_source_header_id
14041 , l_wct_rec.demand_source_line
14042 , l_wct_rec.demand_source_delivery
14043 , l_wct_rec.item_segments
14044 , l_wct_rec.item_description
14045 , l_wct_rec.item_trx_enabled_flag
14046 , l_wct_rec.item_location_control_code
14047 , l_wct_rec.item_restrict_subinv_code
14048 , l_wct_rec.item_restrict_locators_code
14049 , l_wct_rec.item_revision_qty_control_code
14050 , l_wct_rec.item_primary_uom_code
14051 , l_wct_rec.item_uom_class
14052 , l_wct_rec.item_shelf_life_code
14053 , l_wct_rec.item_shelf_life_days
14054 , l_wct_rec.item_lot_control_code
14055 , l_wct_rec.item_serial_control_code
14056 , l_wct_rec.item_inventory_asset_flag
14057 , l_wct_rec.allowed_units_lookup_code
14058 , l_wct_rec.department_id
14059 , l_wct_rec.department_code
14060 , l_wct_rec.wip_supply_type
14061 , l_wct_rec.supply_subinventory
14062 , l_wct_rec.supply_locator_id
14063 , l_wct_rec.valid_subinventory_flag
14064 , l_wct_rec.valid_locator_flag
14065 , l_wct_rec.locator_segments
14066 , l_wct_rec.current_locator_control_code
14067 , l_wct_rec.number_of_lots_entered
14068 , l_wct_rec.wip_commit_flag
14069 , l_wct_rec.next_lot_number
14070 , l_wct_rec.lot_alpha_prefix
14071 , l_wct_rec.next_serial_number
14072 , l_wct_rec.serial_alpha_prefix
14073 , l_wct_rec.shippable_flag
14074 , l_wct_rec.posting_flag
14075 , l_wct_rec.required_flag
14076 , l_wct_rec.process_flag
14077 , l_wct_rec.ERROR_CODE
14078 , l_wct_rec.error_explanation
14079 , l_wct_rec.attribute_category
14080 , l_wct_rec.attribute1
14081 , l_wct_rec.attribute2
14082 , l_wct_rec.attribute3
14083 , l_wct_rec.attribute4
14084 , l_wct_rec.attribute5
14085 , l_wct_rec.attribute6
14086 , l_wct_rec.attribute7
14087 , l_wct_rec.attribute8
14088 , l_wct_rec.attribute9
14089 , l_wct_rec.attribute10
14090 , l_wct_rec.attribute11
14091 , l_wct_rec.attribute12
14092 , l_wct_rec.attribute13
14093 , l_wct_rec.attribute14
14094 , l_wct_rec.attribute15
14095 , l_wct_rec.movement_id
14096 , l_wct_rec.reservation_quantity
14097 , l_wct_rec.shipped_quantity
14098 , l_wct_rec.transaction_line_number
14099 , l_wct_rec.task_id
14100 , l_wct_rec.to_task_id
14101 , l_wct_rec.source_task_id
14102 , l_wct_rec.project_id
14103 , l_wct_rec.source_project_id
14104 , l_wct_rec.pa_expenditure_org_id
14105 , l_wct_rec.to_project_id
14106 , l_wct_rec.expenditure_type
14107 , l_wct_rec.final_completion_flag
14108 , l_wct_rec.transfer_percentage
14109 , l_wct_rec.transaction_sequence_id
14110 , l_wct_rec.material_account
14111 , l_wct_rec.material_overhead_account
14112 , l_wct_rec.resource_account
14113 , l_wct_rec.outside_processing_account
14114 , l_wct_rec.overhead_account
14115 , l_wct_rec.flow_schedule
14116 , l_wct_rec.cost_group_id
14117 , l_wct_rec.transfer_cost_group_id
14118 , l_wct_rec.demand_class
14119 , l_wct_rec.qa_collection_id
14120 , l_wct_rec.kanban_card_id
14121 , l_wct_rec.overcompletion_transaction_qty
14122 , l_wct_rec.overcompletion_primary_qty
14123 , l_wct_rec.overcompletion_transaction_id
14124 , l_wct_rec.end_item_unit_number
14125 , l_wct_rec.scheduled_payback_date
14126 , l_wct_rec.line_type_code
14127 , l_wct_rec.parent_transaction_temp_id
14128 , l_wct_rec.put_away_strategy_id
14129 , l_wct_rec.put_away_rule_id
14130 , l_wct_rec.pick_strategy_id
14131 , l_wct_rec.pick_rule_id
14132 , l_wct_rec.move_order_line_id
14133 , l_wct_rec.task_group_id
14134 , l_wct_rec.pick_slip_number
14135 , l_wct_rec.reservation_id
14136 , l_wct_rec.common_bom_seq_id
14137 , l_wct_rec.common_routing_seq_id
14138 , l_wct_rec.org_cost_group_id
14139 , l_wct_rec.cost_type_id
14140 , l_wct_rec.transaction_status
14141 , l_wct_rec.standard_operation_id
14142 , l_wct_rec.task_priority
14143 , l_wct_rec.wms_task_type
14144 , l_wct_rec.parent_line_id
14145 , l_wct_rec.lpn_id
14146 , l_wct_rec.transfer_lpn_id
14147 , l_wct_rec.wms_task_status
14148 , l_wct_rec.content_lpn_id
14149 , l_wct_rec.container_item_id
14150 , l_wct_rec.cartonization_id
14151 , l_wct_rec.pick_slip_date
14152 , l_wct_rec.rebuild_item_id
14153 , l_wct_rec.rebuild_serial_number
14154 , l_wct_rec.rebuild_activity_id
14155 , l_wct_rec.rebuild_job_name
14156 , l_wct_rec.organization_type
14157 , l_wct_rec.transfer_organization_type
14158 , l_wct_rec.owning_organization_id
14159 , l_wct_rec.owning_tp_type
14160 , l_wct_rec.xfr_owning_organization_id
14161 , l_wct_rec.transfer_owning_tp_type
14162 , l_wct_rec.planning_organization_id
14163 , l_wct_rec.planning_tp_type
14164 , l_wct_rec.xfr_planning_organization_id
14165 , l_wct_rec.transfer_planning_tp_type
14166 , l_wct_rec.secondary_uom_code
14167 , l_wct_rec.secondary_transaction_quantity
14168 , l_wct_rec.transaction_batch_id
14169 , l_wct_rec.transaction_batch_seq
14170 , l_wct_rec.allocated_lpn_id
14171 , l_wct_rec.schedule_number
14172 , l_wct_rec.scheduled_flag
14173 , l_wct_rec.class_code
14174 , l_wct_rec.schedule_group
14175 , l_wct_rec.build_sequence
14176 , l_wct_rec.bom_revision
14177 , l_wct_rec.routing_revision
14178 , l_wct_rec.bom_revision_date
14179 , l_wct_rec.routing_revision_date
14180 , l_wct_rec.alternate_bom_designator
14181 , l_wct_rec.alternate_routing_designator
14182 , l_wct_rec.operation_plan_id
14183 , l_wct_rec.serial_allocated_flag
14184 , l_wct_rec.move_order_header_id
14185 );
14186 END insert_wct;
14187 END wms_task_dispatch_engine;