[Home] [Help]
PACKAGE BODY: APPS.WSH_DELIVERY_DETAILS_GRP
Source
1 PACKAGE BODY WSH_DELIVERY_DETAILS_GRP as
2 /* $Header: WSHDDGPB.pls 120.28.12010000.2 2008/09/15 12:58:13 gbhargav ship $ */
3
4 -- standard global constants
5 G_PKG_NAME CONSTANT VARCHAR2(30) := 'WSH_DELIVERY_DETAILS_GRP';
6 p_message_type CONSTANT VARCHAR2(1) := 'E';
7 c_wms_code_present VARCHAR2(1) := 'Y';
8
9 -- anxsharm for Load Tender
10 -- add delivery id and parent_delivery_detail_id
11 CURSOR c_original_detail_cur(p_detail_id NUMBER) IS
12 SELECT wdd.source_line_id,
13 wdd.organization_id,
14 wdd.inventory_item_id,
15 wdd.serial_number,
16 wdd.to_serial_number, -- Bug fix 2652300
17 wdd.top_model_line_id, -- Bug fix 2652300
18 wdd.transaction_temp_id,
19 wdd.locator_id,
20 wdd.revision,
21 wdd.subinventory,
22 wdd.lot_number,
23 wdd.released_status,
24 wdd.requested_quantity_uom,
25 wdd.gross_weight,
26 wdd.net_weight,
27 wdd.weight_uom_code,
28 wdd.volume,
29 wdd.volume_uom_code,
30 wdd.container_name,
31 wdd.container_flag,
32 wdd.master_serial_number,
33 wdd.inspection_flag,
34 wdd.cycle_count_quantity,
35 wdd.shipped_quantity,
36 wdd.requested_quantity,
37 wdd.picked_quantity,
38 -- PK added for Bug 3055126 qty2's
39 wdd.cycle_count_quantity2,
40 wdd.shipped_quantity2,
41 wdd.requested_quantity2,
42 wdd.picked_quantity2,
43 wdd.pickable_flag,
44 wda.delivery_id,
45 wda.parent_delivery_detail_id
46 FROM wsh_delivery_details wdd,
47 wsh_delivery_assignments_v wda
48 WHERE wdd.delivery_detail_id = p_detail_id
49 AND wdd.delivery_detail_id = wda.delivery_detail_id;
50
51
52 -- Forward Declarations for local procedures
53 PROCEDURE Create_Delivery_Detail(
54 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
55 p_detail_IN_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
56 p_valid_index_tab IN wsh_util_core.id_tab_type,
57 x_detail_OUT_rec OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.detailOutRecType,
58 x_return_status OUT NOCOPY VARCHAR2,
59 x_msg_count OUT NOCOPY NUMBER,
60 x_msg_data OUT NOCOPY VARCHAR2
61 );
62
63 PROCEDURE Validate_Delivery_Detail(
64 x_detail_info_tab IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
65 p_in_detail_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
66 p_action IN VARCHAR2,
67 p_validation_tab IN wsh_util_core.Id_Tab_Type,
68 p_caller IN varchar2,
69 x_valid_index_tab OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
70 x_details_marked OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
71 x_detail_tender_tab OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
72 x_return_status OUT NOCOPY VARCHAR2,
73 x_msg_count OUT NOCOPY NUMBER,
74 x_msg_data OUT NOCOPY VARCHAR2,
75 p_in_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
76 p_serial_range_tab IN WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType
77 );
78
79 PROCEDURE Update_Delivery_Detail(
80 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
81 p_valid_index_tab IN wsh_util_core.id_tab_type,
82 x_return_status OUT NOCOPY varchar2,
83 x_msg_count OUT NOCOPY NUMBER,
84 x_msg_data OUT NOCOPY VARCHAR2,
85 p_caller IN VARCHAR2 DEFAULT NULL
86 );
87
88 -- ---------------------------------------------------------------------
89 -- Procedure: Cancel_Delivery_Detail
90 --
91 -- Parameters:
92 --
93 -- Description: This local procedure is the new API for wrapping the logic of CANCEL of delivery details
94 -- Created: Harmonization Project. Patchset I
95 -- -----------------------------------------------------------------------
96
97 PROCEDURE Cancel_Delivery_Detail(
98 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
99 x_return_status OUT NOCOPY VARCHAR2,
100 x_msg_count OUT NOCOPY NUMBER,
101 x_msg_data OUT NOCOPY VARCHAR2,
102 p_caller IN VARCHAR2 DEFAULT NULL
103 );
104
105
106
107 PROCEDURE Validate_Detail_Line(
108 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
109 p_in_detail_rec IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
110 p_original_rec IN c_original_detail_cur%ROWTYPE,
111 p_validation_tab IN WSH_UTIL_CORE.id_tab_type,
112 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
113 x_return_status OUT NOCOPY VARCHAR2,
114 x_msg_count OUT NOCOPY NUMBER,
115 x_msg_data OUT NOCOPY VARCHAR2,
116 p_in_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
117 p_serial_range_tab IN WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType
118 );
119
120 PROCEDURE Validate_Detail_Container(
121 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
122 p_original_rec IN c_original_detail_cur%ROWTYPE,
123 p_validation_tab IN WSH_UTIL_CORE.id_tab_type,
124 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
125 x_return_status OUT NOCOPY VARCHAR2,
126 x_msg_count OUT NOCOPY NUMBER,
127 x_msg_data OUT NOCOPY VARCHAR2
128 );
129
130 PROCEDURE Validate_Detail_Common(
131 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
132 p_original_rec IN c_original_detail_cur%ROWTYPE,
133 p_validation_tab IN wsh_util_core.id_tab_type,
134 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
135 x_return_status OUT NOCOPY VARCHAR2,
136 x_msg_count OUT NOCOPY NUMBER,
137 x_msg_data OUT NOCOPY VARCHAR2
138 );
139
140 PROCEDURE get_serial_quantity(
141 p_transaction_temp_id IN NUMBER,
142 p_serial_number IN VARCHAR2,
143 p_to_serial_number IN VARCHAR2,
144 p_shipped_quantity IN VARCHAR2,
145 x_serial_qty OUT NOCOPY NUMBER,
146 x_return_status OUT NOCOPY VARCHAR2);
147
148 -- -----------------------------------------------------------------------
149 -- Procedure: detail_to_delivery
150 --
151 -- Parameters: 1) table of delivery_detail_ids
152 -- 2) action: assign/unassign
153 -- 3) delivery_id: need to specify delivery id or delivery name
154 -- if the action is 'ASSIGN'
155 -- 4) delivery_name: need to specify delivery id or delivery
156 -- name if the action is 'ASSIGN'
157 -- 5) other standard parameters
158 --
159 --
160 -- Description: This procedure assign/unassign delivery_details to
161 -- a delivery.
162 -- Parameters: p_TabOfDelDets: required
163 -- p_action: required
164 -- p_delivery_id: required if action='ASSIGN'
165 -- -----------------------------------------------------------------------
166 PROCEDURE detail_to_delivery(
167 -- Standard parameters
168 p_api_version IN NUMBER,
169 p_init_msg_list IN VARCHAR2,
170 p_commit IN VARCHAR2,
171 p_validation_level IN NUMBER,
172 x_return_status OUT NOCOPY VARCHAR2,
173 x_msg_count OUT NOCOPY NUMBER,
174 x_msg_data OUT NOCOPY VARCHAR2,
175 -- procedure specific parameters
176 p_tabofdeldets IN WSH_UTIL_CORE.id_tab_type,
177 p_action IN VARCHAR2,
178 p_delivery_id IN NUMBER,
179 p_delivery_name IN VARCHAR2,
180 p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type -- J-IB-NPARIKH
181 ) IS
182 -- Standard call to check for call compatibility
183 l_api_version CONSTANT NUMBER := 1.0;
184 l_api_name CONSTANT VARCHAR2(30) := 'delivery_detail_to_delivery';
185 l_return_status VARCHAR2(30) := NULL;
186 l_delivery_id NUMBER := NULL;
187 l_cont_ins_id NUMBER := NULL;
188 l_tabofdeldets wsh_util_core.id_tab_type;
189 l_msg_summary VARCHAR2(2000) := NULL;
190 l_msg_details VARCHAR2(4000) := NULL;
191 l_del_params wsh_delivery_autocreate.grp_attr_tab_type;
192 wsh_no_del_det_tbl EXCEPTION;
193 wsh_no_delivery_id EXCEPTION;
194 wsh_no_delivery EXCEPTION; /*2777869*/
195 wsh_invalid_delivery_id EXCEPTION; /*2777869*/
196 wsh_invalid_action EXCEPTION;
197
198 CURSOR c_delivery_record IS
199 SELECT delivery_id
200 FROM wsh_new_deliveries
201 WHERE NAME = p_delivery_name;
202
203 /*2777869*/
204 CURSOR c_delivery_id is
205 SELECT delivery_id
206 FROM wsh_new_deliveries
207 WHERE delivery_id = p_delivery_id;
208
209 -- deliveryMerge
210 CURSOR c_get_assigned_delivery (c_delivery_detail_id NUMBER) IS
211 SELECT wda.delivery_id
212 FROM wsh_delivery_assignments_v wda,
213 wsh_delivery_details wdd
214 WHERE wda.delivery_detail_id = c_delivery_detail_id
215 AND wda.delivery_detail_id = wdd.delivery_detail_id
216 AND wdd.container_flag = 'N'
217 AND NVL(wdd.line_direction,'O') in ('O','IO');
218 --
219 l_debug_on BOOLEAN;
220 --
221 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || g_pkg_name || '.' || 'DETAIL_TO_DELIVERY';
222
223 -- Patchset I: Harmonization Project
224 l_pack_status_dummy VARCHAR2(100);
225 l_msg_data VARCHAR2(32767);
226
227 -- anxsharm for Load Tender
228 l_trip_id_tab wsh_util_core.id_tab_type;
229 l_det_tab wsh_util_core.id_tab_type;
230 l_number_of_errors NUMBER := 0;
231 l_number_of_warnings NUMBER := 0;
232 --
233 l_cnt NUMBER;
234 i number;
235
236 -- deliveryMerge
237 l_adjust_planned_del_tab wsh_util_core.id_tab_type;
238 l_delivery_already_included boolean;
239 --LPN Convergence
240 e_invalid_quantity EXCEPTION;
241
242 BEGIN
243 --
244 l_debug_on := wsh_debug_interface.g_debug;
245
246 --
247 IF l_debug_on IS NULL THEN
248 l_debug_on := wsh_debug_sv.is_debug_enabled;
249 END IF;
250
251 --
252 SAVEPOINT detail_to_delivery_grp;
253
254 -- Standard begin of API savepoint
255 --
256 -- Debug Statements
257 --
258 IF l_debug_on THEN
259 wsh_debug_sv.push(l_module_name);
260 --
261 wsh_debug_sv.LOG(l_module_name, 'P_API_VERSION', p_api_version);
262 wsh_debug_sv.LOG(l_module_name, 'P_INIT_MSG_LIST', p_init_msg_list);
263 wsh_debug_sv.LOG(l_module_name, 'P_COMMIT', p_commit);
264 wsh_debug_sv.LOG(l_module_name, 'P_VALIDATION_LEVEL', p_validation_level);
265 wsh_debug_sv.LOG(l_module_name, 'P_ACTION', p_action);
266 wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_ID', p_delivery_id);
267 wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_NAME', p_delivery_name);
268 wsh_debug_sv.LOG(l_module_name, 'P_TABOFDELDETS.COUNT', p_tabofdeldets.COUNT);
269 END IF;
270
271 --
272 l_adjust_planned_del_tab.delete;
273
274 IF NOT fnd_api.compatible_api_call(
275 l_api_version,
276 p_api_version,
277 l_api_name,
278 g_pkg_name
279 ) THEN
280 RAISE fnd_api.g_exc_unexpected_error;
281 END IF;
282
283 -- Check p_init_msg_list
284 IF fnd_api.to_boolean(p_init_msg_list) THEN
285 fnd_msg_pub.initialize;
286 END IF;
287
288 x_return_status := wsh_util_core.g_ret_sts_success;
289
290 IF (p_tabofdeldets.COUNT = 0) THEN
291 RAISE wsh_no_del_det_tbl;
292 END IF;
293
294 /* check action */
295 IF UPPER(NVL(p_action, 'N')) NOT IN('ASSIGN', 'UNASSIGN') THEN
296 RAISE wsh_invalid_action;
297 END IF;
298
299 i := p_tabofdeldets.FIRST;
300 l_cnt := 0;
301 --
302 WHILE i IS NOT NULL
303 LOOP
304 l_cnt := l_cnt + 1;
305 --
306 l_tabofdeldets(l_cnt) := p_tabofdeldets(i);
307 --
308 i := p_tabofdeldets.NEXT(i);
309 --
310 END LOOP;
311
312
313 IF UPPER(NVL(p_action, 'N')) = 'ASSIGN' THEN
314 IF (
315 (p_delivery_id IS NOT NULL)
316 AND (p_delivery_id <> fnd_api.g_miss_num)
317 OR (p_delivery_name IS NOT NULL)
318 AND (p_delivery_name <> fnd_api.g_miss_char)
319 ) THEN
320 IF (p_delivery_id IS NULL OR p_delivery_id = fnd_api.g_miss_num) THEN
321 /* convert delivery_name to delivery_id */
322 OPEN c_delivery_record;
323 FETCH c_delivery_record INTO l_delivery_id;
324
325 IF c_delivery_record%NOTFOUND THEN
326 CLOSE c_delivery_record;
327 -- RAISE wsh_no_delivery_id; /*2777869*/
328 RAISE wsh_no_delivery;
329 END IF;
330
331 CLOSE c_delivery_record;
332 ELSE
333 OPEN c_delivery_id; /*2777869*/
334 FETCH c_delivery_id into l_delivery_id;
335 IF c_delivery_id%NOTFOUND THEN
336 CLOSE c_delivery_id;
337 RAISE wsh_invalid_delivery_id;
338 END IF;
339 -- l_delivery_id := p_delivery_id;
340 END IF;
341
342 IF l_debug_on THEN
343 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DLVB_COMMON_ACTIONS.ASSIGN_DETAILS', wsh_debug_sv.c_proc_level);
344 END IF;
345
346 --
347
348 /* Patchset I : Harmonization Project Begin
349 Instead of the old call to Assign_Multiple_Details
350 We now have call to wsh_dlvb_common_actions.assign_details */
351 IF l_debug_on THEN
352 wsh_debug_sv.logmsg(l_module_name, ' befor assign_details');
353 END IF;
354 wsh_dlvb_common_actions.assign_details(
355 p_detail_tab => l_tabofdeldets,
356 p_parent_detail_id => NULL,
357 p_delivery_id => p_delivery_id,
358 x_pack_status => l_pack_status_dummy,
359 x_return_status => l_return_status
360 );
361 wsh_util_core.api_post_call(
362 p_return_status => l_return_status,
363 x_num_warnings => l_number_of_warnings,
364 x_num_errors => l_number_of_errors);
365 /* Patchset I : Harmonization Project End */
366 l_det_tab(1) := p_delivery_id;
367 wsh_tp_release.calculate_cont_del_tpdates(
368 p_entity => 'DLVY',
369 p_entity_ids =>l_det_tab,
370 x_return_status => x_return_status);
371
372 wsh_util_core.api_post_call(
373 p_return_status => l_return_status,
374 x_num_warnings => l_number_of_warnings,
375 x_num_errors => l_number_of_errors);
376
377 -- deliveryMerge, collect the delivery ids for adjust_planned_flag call
378
379 l_adjust_planned_del_tab(l_adjust_planned_del_tab.count+1) := p_delivery_id;
380 IF l_debug_on THEN
381 wsh_debug_sv.logmsg(l_module_name, ' added delivery '||p_delivery_id ||' for adjustment');
382 END IF;
383
384 ELSE
385 /* no delivery id is passed for action assign */
386 RAISE wsh_no_delivery_id;
387 END IF;
388 ELSE
389 /* unassign */
390 IF l_debug_on THEN
391 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_UNASSIGN_FROM_DELIVERY', wsh_debug_sv.c_proc_level);
392 END IF;
393
394 wsh_details_validations.check_unassign_from_delivery(
395 p_detail_rows => l_tabofdeldets,
396 x_return_status => l_return_status);
397
398 wsh_util_core.api_post_call(
399 p_return_status => l_return_status,
400 x_num_warnings => l_number_of_warnings,
401 x_num_errors => l_number_of_errors);
402
403 IF l_debug_on THEN
404 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DLVB_COMMON_ACTIONS.UNASSIGN_DETAILS', wsh_debug_sv.c_proc_level);
405 END IF;
406
407 /* Patchset I : Harmonization Project Begin
408 Instead of the old call to WSH_DELIVERY_DETAILS_ACTIONS.Unassign_Multiple_Details We now have call to wsh_dlvb_common_actions.unassign_details */
409 -- deliveryMerge
410
411 i := l_tabofdeldets.FIRST;
412 WHILE i is not NULL LOOP
413 OPEN c_get_assigned_delivery(l_tabofdeldets(i));
414 FETCH c_get_assigned_delivery INTO l_delivery_id;
415 IF c_get_assigned_delivery%NOTFOUND THEN
416 goto end_of_loop;
417 ELSE
418 --
419 l_delivery_already_included := false;
420
421 IF l_adjust_planned_del_tab.count > 0 THEN
422 FOR i in l_adjust_planned_del_tab.FIRST .. l_adjust_planned_del_tab.LAST LOOP
423 IF l_adjust_planned_del_tab(i) = l_delivery_id THEN
424 l_delivery_already_included := true;
425 END IF;
426 END LOOP;
427 END IF;
428
429 IF NOT l_delivery_already_included THEN
430 l_adjust_planned_del_tab(l_adjust_planned_del_tab.count+1) := l_delivery_id;
431 END IF;
432
433 --
434 END IF;
435 <<end_of_loop>>
436 CLOSE c_get_assigned_delivery;
437 i := l_tabofdeldets.next(i);
438 END LOOP;
439
440 wsh_dlvb_common_actions.unassign_details(
441 p_detail_tab => l_tabofdeldets,
442 p_parent_detail_flag => 'N',
443 p_delivery_flag => 'Y',
444 x_return_status => l_return_status,
445 p_action_prms => p_action_prms
446 );
447 wsh_util_core.api_post_call(
448 p_return_status => l_return_status,
449 x_num_warnings => l_number_of_warnings,
450 x_num_errors => l_number_of_errors);
451 /* Patchset I : Harmonization Project End */
452 END IF;
453 -- deliveryMerge
454 IF l_adjust_planned_del_tab.count > 0 and WSH_PICK_LIST.G_BATCH_ID is NULL THEN
455 WSH_NEW_DELIVERY_ACTIONS.Adjust_Planned_Flag(
456 p_delivery_ids => l_adjust_planned_del_tab,
457 p_caller => 'WSH_DLMG',
458 p_force_appending_limit => 'N',
459 p_call_lcss => 'Y',
460 x_return_status => l_return_status);
461
462 IF l_debug_on THEN
463 WSH_DEBUG_SV.log(l_module_name,'Adjust_Planned_Flag returns ',l_return_status);
464 END IF;
465
466 wsh_util_core.api_post_call(
467 p_return_status => l_return_status,
468 x_num_warnings => l_number_of_warnings,
469 x_num_errors => l_number_of_errors);
470
471 END IF;
472
473 IF l_number_of_warnings > 0 THEN
474 IF l_debug_on THEN
475 wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
476 END IF;
477
478 RAISE wsh_util_core.g_exc_warning;
479 END IF;
480
481 fnd_msg_pub.count_and_get(
482 p_count => x_msg_count,
483 p_data => x_msg_data,
484 p_encoded => fnd_api.g_false);
485
486 IF fnd_api.to_boolean(p_commit) THEN
487 -- dbms_output.put_line('commit');
488 COMMIT WORK;
489 END IF;
490
491 IF l_debug_on THEN
492 wsh_debug_sv.pop(l_module_name);
493 END IF;
494 --
495 EXCEPTION
496 WHEN fnd_api.g_exc_error THEN
497 ROLLBACK TO detail_to_delivery_grp;
498 x_return_status := fnd_api.g_ret_sts_error;
499 fnd_msg_pub.count_and_get(
500 p_count => x_msg_count,
501 p_data => x_msg_data,
502 p_encoded => fnd_api.g_false);
503
504 --
505 IF l_debug_on THEN
506 wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
507 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
508 END IF;
509 --
510 WHEN fnd_api.g_exc_unexpected_error THEN
511 ROLLBACK TO detail_to_delivery_grp;
512 x_return_status := fnd_api.g_ret_sts_unexp_error;
513 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
514 p_encoded => fnd_api.g_false);
515
516 --
517 IF l_debug_on THEN
518 wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
519 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
520 END IF;
521 --
522 WHEN wsh_util_core.g_exc_warning THEN
523 x_return_status := wsh_util_core.g_ret_sts_warning;
524 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
525 p_encoded => fnd_api.g_false);
526
527 --
528 IF l_debug_on THEN
529 wsh_debug_sv.logmsg(l_module_name, 'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ', wsh_debug_sv.c_excep_level);
530 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
531 END IF;
532
533 WHEN wsh_invalid_action THEN
534 ROLLBACK TO detail_to_delivery_grp;
535 x_return_status := wsh_util_core.g_ret_sts_error;
536 fnd_message.set_name('WSH', 'WSH_PUB_INVALID_ACTION');
537 wsh_util_core.add_message(x_return_status);
538 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
539 p_encoded => fnd_api.g_false);
540
541 IF l_debug_on THEN
542 wsh_debug_sv.logmsg(l_module_name, 'WSH_INVALID_ACTION exception has occured.', wsh_debug_sv.c_excep_level);
543 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_INVALID_ACTION');
544 END IF;
545
546 WHEN wsh_no_del_det_tbl THEN
547 ROLLBACK TO detail_to_delivery_grp;
548 x_return_status := wsh_util_core.g_ret_sts_error;
549 fnd_message.set_name('WSH', 'WSH_PUB_NO_DEL_DET_TBL');
550 wsh_util_core.add_message(x_return_status);
551 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
552 p_encoded => fnd_api.g_false);
553
554 IF l_debug_on THEN
555 wsh_debug_sv.logmsg(l_module_name, 'WSH_NO_DEL_DET_TBL exception has occured.', wsh_debug_sv.c_excep_level);
556 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_NO_DEL_DET_TBL');
557 END IF;
558 --
559 WHEN wsh_no_delivery_id THEN
560 ROLLBACK TO detail_to_delivery_grp;
561 x_return_status := wsh_util_core.g_ret_sts_error;
562 fnd_message.set_name('WSH', 'WSH_PUB_NO_DELIVERY');
563 wsh_util_core.add_message(x_return_status);
564 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
565 p_encoded => fnd_api.g_false);
566
567 IF l_debug_on THEN
568 wsh_debug_sv.logmsg(l_module_name, 'WSH_NO_DELIVERY_ID exception has occured.', wsh_debug_sv.c_excep_level);
569 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_NO_DELIVERY_ID');
570 END IF;
571 --
572
573 /*Start of 2777869*/
574
575 WHEN wsh_no_delivery THEN
576 ROLLBACK TO detail_to_delivery_grp;
577 x_return_status := wsh_util_core.g_ret_sts_error;
578 fnd_message.set_name('WSH', 'WSH_DELIVERY_NOT_EXIST');
579 fnd_message.set_token('DELIVERY_NAME', p_delivery_name);
580 wsh_util_core.add_message(x_return_status);
581 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
582 p_encoded => fnd_api.g_false);
583
584 IF l_debug_on THEN
585 wsh_debug_sv.logmsg(l_module_name, 'WSH_NO_DELIVERY exception has occured.', wsh_debug_sv.c_excep_level);
586 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_NO_DELIVERY');
587 END IF;
588 --
589 WHEN wsh_invalid_delivery_id THEN
590 ROLLBACK TO detail_to_delivery_grp;
591 x_return_status := wsh_util_core.g_ret_sts_error;
592 fnd_message.set_name('WSH', 'WSH_INVALID_DELIVERY');
593 fnd_message.set_token('DELIVERY', p_delivery_id);
594 wsh_util_core.add_message(x_return_status);
595 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
596 p_encoded => fnd_api.g_false);
597
598 IF l_debug_on THEN
599 wsh_debug_sv.logmsg(l_module_name, 'WSH_INVALID_DELIVERY_ID exception has occured.', wsh_debug_sv.c_excep_level);
600 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_INVALID_DELIVERY_ID');
601 END IF;
602
603 /* End of 2777869*/
604 --
605
606 WHEN OTHERS THEN
607 ROLLBACK TO detail_to_delivery_grp;
608 x_return_status := wsh_util_core.g_ret_sts_unexp_error;
609 wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_GRP.DETAIL_TO_DELIVERY');
610 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
611 p_encoded => fnd_api.g_false);
612
613 IF l_debug_on THEN
614 wsh_debug_sv.logmsg(l_module_name, 'Unexpected error has occured. Oracle error message is ' || SQLERRM, wsh_debug_sv.c_unexpec_err_level);
615 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:OTHERS');
616 END IF;
617 --
618 END detail_to_delivery;
619
620
621 --This procedure is for backward compatibility only. Do not use this.
622 PROCEDURE detail_to_delivery(
623 -- Standard parameters
624 p_api_version IN NUMBER,
625 p_init_msg_list IN VARCHAR2,
626 p_commit IN VARCHAR2,
627 p_validation_level IN NUMBER,
628 x_return_status OUT NOCOPY VARCHAR2,
629 x_msg_count OUT NOCOPY NUMBER,
630 x_msg_data OUT NOCOPY VARCHAR2,
631 -- procedure specific parameters
632 p_tabofdeldets IN WSH_UTIL_CORE.id_tab_type,
633 p_action IN VARCHAR2,
634 p_delivery_id IN NUMBER,
635 p_delivery_name IN VARCHAR2
636 ) IS
637
638 --
639 l_debug_on BOOLEAN;
640 --
641 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || g_pkg_name || '.' || 'DETAIL_TO_DELIVERY';
642 --
643 l_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type; -- J-IB-NPARIKH
644 BEGIN
645 --
646 l_debug_on := wsh_debug_interface.g_debug;
647
648 --
649 IF l_debug_on IS NULL THEN
650 l_debug_on := wsh_debug_sv.is_debug_enabled;
651 END IF;
652
653
654 -- Debug Statements
655 --
656 IF l_debug_on THEN
657 wsh_debug_sv.push(l_module_name);
658 --
659 wsh_debug_sv.LOG(l_module_name, 'P_API_VERSION', p_api_version);
660 wsh_debug_sv.LOG(l_module_name, 'P_INIT_MSG_LIST', p_init_msg_list);
661 wsh_debug_sv.LOG(l_module_name, 'P_COMMIT', p_commit);
662 wsh_debug_sv.LOG(l_module_name, 'P_VALIDATION_LEVEL', p_validation_level);
663 wsh_debug_sv.LOG(l_module_name, 'P_ACTION', p_action);
664 wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_ID', p_delivery_id);
665 wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_NAME', p_delivery_name);
666 wsh_debug_sv.LOG(l_module_name, 'P_TABOFDELDETS.COUNT', p_tabofdeldets.COUNT);
667 END IF;
668
669
670 IF l_debug_on THEN
671 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_GRP.DETAIL_TO_DELIVERY', wsh_debug_sv.c_proc_level);
672 END IF;
673
674 DETAIL_TO_DELIVERY
675 (
676 p_api_version ,
677 p_init_msg_list ,
678 p_commit ,
679 p_validation_level,
680 x_return_status ,
681 x_msg_count ,
682 x_msg_data ,
683 p_tabofdeldets,
684 p_action ,
685 p_delivery_id ,
686 p_delivery_name ,
687 l_action_prms
688 );
689 IF l_debug_on THEN
690 wsh_debug_sv.pop(l_module_name);
691 END IF;
692 --
693 EXCEPTION
694
695 WHEN OTHERS THEN
696 x_return_status := wsh_util_core.g_ret_sts_unexp_error;
697 wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_GRP.DETAIL_TO_DELIVERY');
698 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
699 p_encoded => fnd_api.g_false);
700
701 IF l_debug_on THEN
702 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:OTHERS');
703 END IF;
704 --
705 END detail_to_delivery;
706
707 -- ----------------------------------------------------------------------
708 -- Procedure: split_line
709 -- Parameters: p_from_detail_id: The delivery detail ID to be split
710 -- x_new_detail_id: The new delivery detail ID
711 -- p_source_quantity:
712 -- split_quantity:
713 --
714 -- Description: This procedure split a delivery_deatil line
715 -- 03/19/01 OPM changes. Added split_quantity2
716 -- ----------------------------------------------------------------------
717 PROCEDURE split_line(
718 -- Standard parameters
719 p_api_version IN NUMBER,
720 p_init_msg_list IN VARCHAR2,
721 p_commit IN VARCHAR2,
722 p_validation_level IN NUMBER,
723 x_return_status OUT NOCOPY VARCHAR2,
724 x_msg_count OUT NOCOPY NUMBER,
725 x_msg_data OUT NOCOPY VARCHAR2,
726 -- Procedure specific parameters
727 p_from_detail_id IN NUMBER,
728 x_new_detail_id OUT NOCOPY NUMBER,
729 x_split_quantity IN OUT NOCOPY NUMBER,
730 x_split_quantity2 IN OUT NOCOPY NUMBER,
731 p_manual_split IN VARCHAR2 DEFAULT NULL,
732 p_converted_flag IN VARCHAR2 DEFAULT NULL
733 ) IS
734 l_msg_summary VARCHAR2(2000);
735 l_msg_details VARCHAR2(4000);
736 l_requested_quantity NUMBER := NULL;
737 l_requested_quantity2 NUMBER := NULL;/* OPM changes NC 03/19/01 */
738 l_received_quantity NUMBER := NULL;
739 l_received_quantity2 NUMBER := NULL;
740 l_line_direction VARCHAR2(30);
741 -- Standard call to check for call compatibility.
742 l_api_version CONSTANT NUMBER := 1.0;
743 l_api_name CONSTANT VARCHAR2(30) := 'Split_Line';
744
745 /* OPM changes NC . Added requsted_quantity2 in the select */
746 CURSOR c_find_delivery_detail(c_delivery_detail_id NUMBER) IS
747 SELECT NVL(LINE_DIRECTION,'O'),
748 NVL(received_quantity, shipped_quantity),
749 NVL(received_quantity2, shipped_quantity2),
750 NVL(picked_quantity, requested_quantity),
751 NVL(picked_quantity2, requested_quantity2)
752 FROM wsh_delivery_details
753 WHERE delivery_detail_id = c_delivery_detail_id;
754
755 wsh_invalid_split_qty EXCEPTION;
756 wsh_invalid_split_qty2 EXCEPTION; /* Added for OPM. NC - 03/19/01 */
757 wsh_inalid_detail_id EXCEPTION;
758 --
759 l_debug_on BOOLEAN;
760 --
761 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || g_pkg_name || '.' || 'SPLIT_LINE';
762 --
763 -- Patchset I : Harmonization Project
764 --
765 l_number_of_errors NUMBER := 0;
766 l_number_of_warnings NUMBER := 0;
767 l_msg_data VARCHAR2(32767);
768 l_inv_item_id NUMBER;
769 l_organization_id NUMBER;
770 l_requested_quantity_uom VARCHAR2(32767);
771 l_return_status VARCHAR2(32767);
772 l_output_quantity NUMBER;
773 l_validation_level_tab wsh_util_core.id_tab_type;
774
775 -- bug 3524851
776 l_top_model_line_id NUMBER;
777
778 --
779 CURSOR det_cur(p_del_det_id NUMBER) IS
780 SELECT inventory_item_id, organization_id, requested_quantity_uom, top_model_line_id
781 FROM wsh_delivery_details
782 WHERE delivery_detail_id = p_del_det_id;
783 BEGIN
784 --
785 l_debug_on := wsh_debug_interface.g_debug;
786
787 --
788 IF l_debug_on IS NULL THEN
789 l_debug_on := wsh_debug_sv.is_debug_enabled;
790 END IF;
791
792 --
793 SAVEPOINT split_line_grp;
794
795 -- Standard begin of API savepoint
796 IF l_debug_on THEN
797 wsh_debug_sv.push(l_module_name);
798 --
799 wsh_debug_sv.LOG(l_module_name, 'P_API_VERSION', p_api_version);
800 wsh_debug_sv.LOG(l_module_name, 'P_INIT_MSG_LIST', p_init_msg_list);
801 wsh_debug_sv.LOG(l_module_name, 'P_COMMIT', p_commit);
802 wsh_debug_sv.LOG(l_module_name, 'P_VALIDATION_LEVEL', p_validation_level);
803 wsh_debug_sv.LOG(l_module_name, 'P_FROM_DETAIL_ID', p_from_detail_id);
804 wsh_debug_sv.LOG(l_module_name, 'X_SPLIT_QUANTITY', x_split_quantity);
805 wsh_debug_sv.LOG(l_module_name, 'X_SPLIT_QUANTITY2', x_split_quantity2);
806 END IF;
807
808 --
809
810 IF NOT fnd_api.compatible_api_call(
811 l_api_version,
812 p_api_version,
813 l_api_name,
814 g_pkg_name
815 ) THEN
816 RAISE fnd_api.g_exc_unexpected_error;
817 END IF;
818
819 -- Check p_init_msg_list
820 IF fnd_api.to_boolean(p_init_msg_list) THEN
821 fnd_msg_pub.initialize;
822 END IF;
823
824 x_return_status := wsh_util_core.g_ret_sts_success;
825 --
826 /* Patchset I : Harmonization Project */
827 l_validation_level_tab := wsh_actions_levels.g_validation_level_tab;
828 /* OPM changes NC - added l_requested_quantity2 */
829 OPEN c_find_delivery_detail(p_from_detail_id);
830 FETCH c_find_delivery_detail INTO l_line_direction, l_received_quantity,
831 l_received_quantity2, l_requested_quantity,
832 l_requested_quantity2;
833
834 IF c_find_delivery_detail%NOTFOUND THEN
835 RAISE wsh_inalid_detail_id;
836 END IF;
837
838 CLOSE c_find_delivery_detail;
839
840 -- J-IB-NPARIKH-{
841 IF l_line_direction NOT IN ('O','IO')
842 THEN
843 --{
844 --
845 -- For inbound/drop-ship lines,
846 -- qty. to be split cannot be greater than
847 -- NVL(RCV,SHP,PICK,REQ).
848 -- Hence, setting variables l_requested_quantity(2) to
849 -- NVL(RCV,SHP,PICK,REQ).
850 --
851 l_requested_quantity := NVL(l_received_quantity,l_requested_quantity);
852 l_requested_quantity2 := NVL(l_received_quantity2,l_requested_quantity2);
853 --}
854 END IF;
855 -- J-IB-NPARIKH-}
856
857
858
859 IF l_requested_quantity < x_split_quantity THEN
860 RAISE wsh_invalid_split_qty;
861 END IF;
862
863 /* OPM changes NC - added */
864 IF l_requested_quantity2 < x_split_quantity2 THEN
865 RAISE wsh_invalid_split_qty2;
866 END IF;
867
868 /* PATCHSET I: Harmonization Project. validate decimal quantity */
869
870 IF (l_validation_level_tab(wsh_actions_levels.c_decimal_quantity_lvl) = 1) THEN
871 OPEN det_cur(p_from_detail_id);
872 FETCH det_cur INTO l_inv_item_id, l_organization_id,
873 l_requested_quantity_uom, l_top_model_line_id;
874 CLOSE det_cur;
875
876 -- HW Harmonization project. Added p_organization_id
877 -- HW OPMCONV - Removed branching
878
879 IF l_debug_on THEN
880 wsh_debug_sv.LOG(l_module_name, 'Inv item id', l_inv_item_id);
881 wsh_debug_sv.LOG(l_module_name, 'Org id', l_organization_id);
882 wsh_debug_sv.LOG(l_module_name, 'Req qty uom', l_requested_quantity_uom);
883 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_DECIMAL_QUANTITY', wsh_debug_sv.c_proc_level);
884 END IF;
885
886 wsh_details_validations.check_decimal_quantity(
887 p_item_id => l_inv_item_id,
888 p_organization_id => l_organization_id,
889 p_input_quantity => x_split_quantity,
890 p_uom_code => l_requested_quantity_uom, -- :split_line.quantity_UOM,
891 x_output_quantity => l_output_quantity,
892 x_return_status => l_return_status,
893 p_top_model_line_id => l_top_model_line_id -- bug 3524851
894 );
895
896 IF l_debug_on THEN
897 wsh_debug_sv.LOG(l_module_name, 'Return Status after check decimal', l_return_status);
898 wsh_debug_sv.LOG(l_module_name, 'Output qty after check decimal', l_output_quantity);
899 END IF;
900
901 -- UT Bug fix 2650839
902 --IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
903 -- RAISE fnd_api.g_exc_error;
904 --END IF;
905 -- Reverting the fix made in 2650839 as we need to return warning instead of
906 -- error to public API users.
907 wsh_util_core.api_post_call(
908 p_return_status => l_return_status,
909 x_num_warnings => l_number_of_warnings,
910 x_num_errors => l_number_of_errors);
911
912 END IF;
913
914 IF l_debug_on THEN
915 wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_ACTIONS.SPLIT_DELIVERY_DETAILS', wsh_debug_sv.c_proc_level);
916 END IF;
917
918 --
919 -- HW added p_converted_flag
920 wsh_delivery_details_actions.split_delivery_details(
921 p_from_detail_id => p_from_detail_id,
922 p_req_quantity => x_split_quantity,
923 p_req_quantity2 => x_split_quantity2,
924 p_manual_split => p_manual_split,
925 p_converted_flag => p_converted_flag,
926 x_new_detail_id => x_new_detail_id,
927 x_return_status => l_return_status
928 );
929 wsh_util_core.api_post_call(
930 p_return_status => l_return_status,
931 x_num_warnings => l_number_of_warnings,
932 x_num_errors => l_number_of_errors);
933
934 IF l_number_of_warnings > 0 THEN
935 IF l_debug_on THEN
936 wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
937 END IF;
938
939 RAISE wsh_util_core.g_exc_warning;
940 END IF;
941
942 fnd_msg_pub.count_and_get(
943 p_count => x_msg_count,
944 p_data => x_msg_data,
945 p_encoded => fnd_api.g_false);
946
947 IF l_debug_on THEN
948 wsh_debug_sv.LOG(l_module_name, 'X_NEW_DETAIL_ID', x_new_detail_id);
949 wsh_debug_sv.LOG(l_module_name, 'X_SPLIT_QUANTITY', x_split_quantity);
950 wsh_debug_sv.pop(l_module_name);
951 END IF;
952 --
953 EXCEPTION
954 WHEN fnd_api.g_exc_error THEN
955 ROLLBACK TO split_line_grp;
956 x_return_status := fnd_api.g_ret_sts_error;
957 fnd_msg_pub.count_and_get(
958 p_count => x_msg_count,
959 p_data => x_msg_data,
960 p_encoded => fnd_api.g_false);
961
962 --
963 IF l_debug_on THEN
964 wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
965 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
966 END IF;
967 --
968 WHEN fnd_api.g_exc_unexpected_error THEN
969 ROLLBACK TO split_line_grp;
970 x_return_status := fnd_api.g_ret_sts_unexp_error;
971 fnd_msg_pub.count_and_get(
972 p_count => x_msg_count,
973 p_data => x_msg_data,
974 p_encoded => fnd_api.g_false);
975
976 --
977 IF l_debug_on THEN
978 wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
979 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
980 END IF;
981 --
982 WHEN wsh_util_core.g_exc_warning THEN
983 x_return_status := wsh_util_core.g_ret_sts_warning;
984 fnd_msg_pub.count_and_get(
985 p_count => x_msg_count,
986 p_data => x_msg_data,
987 p_encoded => fnd_api.g_false);
988
989 --
990 IF l_debug_on THEN
991 wsh_debug_sv.logmsg(l_module_name, 'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ', wsh_debug_sv.c_excep_level);
992 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
993 END IF;
994 WHEN wsh_inalid_detail_id THEN
995 ROLLBACK TO split_line_grp;
996 x_return_status := wsh_util_core.g_ret_sts_error;
997
998 /* Bug 2777869 : Instead of message "WSH_PUB_INALID_DETAIL_ID",now we are using
999 "WSH_DET_INVALID_DETAIL".*/
1000
1001 fnd_message.set_name('WSH', 'WSH_DET_INVALID_DETAIL');
1002 fnd_message.set_token('DETAIL_ID',p_from_detail_id);
1003 wsh_util_core.add_message(x_return_status);
1004
1005 fnd_msg_pub.count_and_get(
1006 p_count => x_msg_count,
1007 p_data => x_msg_data,
1008 p_encoded => fnd_api.g_false);
1009
1010 IF l_debug_on THEN
1011 wsh_debug_sv.logmsg(l_module_name, 'WSH_INALID_DETAIL_ID exception has occured.', wsh_debug_sv.c_excep_level);
1012 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_INALID_DETAIL_ID');
1013 END IF;
1014 --
1015 WHEN wsh_invalid_split_qty THEN
1016 ROLLBACK TO split_line_grp;
1017 x_return_status := wsh_util_core.g_ret_sts_error;
1018 fnd_message.set_name('WSH', 'WSH_DET_SPLIT_EXCEED');
1019 wsh_util_core.add_message(x_return_status);
1020
1021 fnd_msg_pub.count_and_get(
1022 p_count => x_msg_count,
1023 p_data => x_msg_data,
1024 p_encoded => fnd_api.g_false);
1025
1026 IF l_debug_on THEN
1027 wsh_debug_sv.logmsg(l_module_name, 'WSH_INVALID_SPLIT_QTY exception has occured.', wsh_debug_sv.c_excep_level);
1028 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_INVALID_SPLIT_QTY');
1029 END IF;
1030 --
1031 WHEN wsh_invalid_split_qty2 THEN /* OPM changes. NC - Added */
1032 ROLLBACK TO split_line_grp;
1033 x_return_status := wsh_util_core.g_ret_sts_error;
1034 fnd_message.set_name('WSH', 'WSH_PUB_INVALID_SPLIT_QTY');
1035 wsh_util_core.add_message(x_return_status);
1036
1037 fnd_msg_pub.count_and_get(
1038 p_count => x_msg_count,
1039 p_data => x_msg_data,
1040 p_encoded => fnd_api.g_false);
1041
1042 IF l_debug_on THEN
1043 wsh_debug_sv.logmsg(l_module_name, 'WSH_INVALID_SPLIT_QTY2 exception has occured.', wsh_debug_sv.c_excep_level);
1044 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_INVALID_SPLIT_QTY2');
1045 END IF;
1046 --
1047 WHEN OTHERS THEN
1048 ROLLBACK TO split_line_grp;
1049 x_return_status := fnd_api.g_ret_sts_unexp_error;
1050 wsh_util_core.add_message(x_return_status, l_module_name);
1051 wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_GRP.Split_Line');
1052
1053 fnd_msg_pub.count_and_get(
1054 p_count => x_msg_count,
1055 p_data => x_msg_data,
1056 p_encoded => fnd_api.g_false);
1057 --
1058 IF l_debug_on THEN
1059 wsh_debug_sv.logmsg(l_module_name, 'Unexpected error has occured. Oracle error message is ' || SQLERRM, wsh_debug_sv.c_unexpec_err_level);
1060 wsh_debug_sv.pop(l_module_name, 'EXCEPTION:OTHERS');
1061 END IF;
1062 --
1063 END split_line;
1064
1065
1066
1067
1068
1069 --===================
1070 -- PROCEDURES
1071 --===================
1072
1073
1074
1075
1076
1077
1078
1079 --========================================================================
1080 -- PROCEDURE : Update_Shipping_Attributes
1081 --
1082 -- PARAMETERS: p_api_version_number known api versionerror buffer
1083 -- p_init_msg_list initialize message stack
1084 -- x_return_status return status
1085 -- x_msg_count number of messages in the list
1086 -- x_msg_data text of messages
1087 -- p_changed_attributes changed attributes for delivery details
1088 -- p_source_code source system
1089 --
1090 --
1091 -- COMMENT : Validates Organization_id and Organization_code against view
1092 -- org_organization_definitions. If both values are
1093 -- specified then only Org_Id is used
1094 --========================================================================
1095
1096 PROCEDURE Update_Shipping_Attributes (
1097 -- Standard parameters
1098 p_api_version_number IN NUMBER
1099 , p_init_msg_list IN VARCHAR2
1100 , p_commit IN VARCHAR2
1101 , x_return_status OUT NOCOPY VARCHAR2
1102 , x_msg_count OUT NOCOPY NUMBER
1103 , x_msg_data OUT NOCOPY VARCHAR2
1104
1105 -- Procedure specific parameters
1106 , p_changed_attributes IN OUT NOCOPY WSH_INTERFACE.ChangedAttributeTabType
1107 , p_source_code IN VARCHAR2
1108 , p_container_flag IN VARCHAR2 DEFAULT NULL
1109 )
1110 IS
1111
1112 --
1113 l_number_of_errors NUMBER := 0;
1114 l_number_of_warnings NUMBER := 0;
1115 l_return_status VARCHAR2(30);
1116 l_counter NUMBER;
1117 l_index NUMBER;
1118 l_api_version_number NUMBER := 1.0;
1119 l_api_name VARCHAR2(30) := 'Update_Shipping_Attributes';
1120
1121 l_msg_count NUMBER;
1122 l_msg_data VARCHAR2(32767);
1123 l_detail_info_tab WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type;
1124 l_detail_in_rec WSH_GLBL_VAR_STRCT_GRP.detailInRecType;
1125 l_detail_out_rec WSH_GLBL_VAR_STRCT_GRP.detailOutRecType;
1126 l_dummy_ids wsh_util_core.id_Tab_type;
1127 invalid_source_code exception;
1128 mark_reprice_error exception;
1129 update_failed exception;
1130 detail_no_found EXCEPTION;
1131 invalid_released_status EXCEPTION; -- Bug fix 2154620
1132 l_error_detail_id NUMBER;
1133 l_error_attribute VARCHAR2(240);
1134 l_error_attribute_value VARCHAR2(360);
1135
1136 l_org NUMBER;
1137
1138 cursor get_org (p_detail_id in number)is
1139 select organization_id
1140 from wsh_delivery_details
1141 where delivery_detail_id = p_detail_id;
1142 --
1143 l_debug_on BOOLEAN;
1144 --
1145 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'UPDATE_SHIPPING_ATTRIBUTES';
1146 --
1147 BEGIN
1148 --
1149 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1150 --
1151 IF l_debug_on IS NULL
1152 THEN
1153 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1154 END IF;
1155 --
1156 SAVEPOINT UPDATE_SHIPPING_ATTR_GRP;
1157 --
1158 -- Debug Statements
1159 --
1160 IF l_debug_on THEN
1161 WSH_DEBUG_SV.push(l_module_name);
1162 --
1163 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
1164 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
1165 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
1166 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
1167 WSH_DEBUG_SV.log(l_module_name,'P_CONTAINER_FLAG',P_CONTAINER_FLAG);
1168 WSH_DEBUG_SV.log(l_module_name,'Table Count',p_changed_attributes.COUNT);
1169
1170 END IF;
1171 --
1172 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1173
1174 -- Standard call to check for call compatibility
1175 IF NOT FND_API.Compatible_API_Call(
1176 l_api_version_number,
1177 p_api_version_number,
1178 l_api_name,
1179 G_PKG_NAME) THEN
1180 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1181 END IF;
1182
1183 -- Initialize message stack if required
1184 IF FND_API.to_Boolean(p_init_msg_list) THEN
1185 FND_MSG_PUB.initialize;
1186 END IF;
1187
1188 -- sperera source_code has to be 'OE' or 'WSH'
1189 IF (NVL(p_source_code, FND_API.G_MISS_CHAR)) NOT IN ('WSH', 'OE') THEN
1190 RAISE invalid_source_code;
1191 END IF;
1192
1193 -- Patchset I : Harmonization Project.
1194 l_detail_in_rec.action_code := 'UPDATE';
1195
1196 l_index := p_changed_attributes.FIRST;
1197 WHILE l_index IS NOT NULL LOOP
1198
1199 OPEN get_org (p_changed_attributes(l_index).delivery_detail_id);
1200 FETCH get_org into l_org;
1201 IF get_org%notfound THEN
1202 CLOSE get_org;
1203 RAISE update_failed;
1204 END IF;
1205 CLOSE get_org;
1206
1207 IF (wsh_util_validate.Check_Wms_Org(l_org)='Y') THEN
1208 l_detail_in_rec.caller := 'WMS';
1209 ELSE
1210 l_detail_in_rec.caller := 'WSH_GRP';
1211 END IF;
1212
1213 l_detail_info_tab(l_index).arrival_set_id := p_changed_attributes(l_index).arrival_set_id;
1214 l_detail_info_tab(l_index).ato_line_id := p_changed_attributes(l_index).ato_line_id;
1215 l_detail_info_tab(l_index).attribute_category := p_changed_attributes(l_index).attribute_category;
1216 l_detail_info_tab(l_index).attribute1 := p_changed_attributes(l_index).attribute1;
1217 l_detail_info_tab(l_index).attribute10 := p_changed_attributes(l_index).attribute10;
1218 l_detail_info_tab(l_index).attribute11 := p_changed_attributes(l_index).attribute11;
1219 l_detail_info_tab(l_index).attribute12 := p_changed_attributes(l_index).attribute12;
1220 l_detail_info_tab(l_index).attribute13 := p_changed_attributes(l_index).attribute13;
1221 l_detail_info_tab(l_index).attribute14 := p_changed_attributes(l_index).attribute14;
1222 l_detail_info_tab(l_index).attribute15 := p_changed_attributes(l_index).attribute15;
1223 l_detail_info_tab(l_index).attribute2 := p_changed_attributes(l_index).attribute2;
1224 l_detail_info_tab(l_index).attribute3 := p_changed_attributes(l_index).attribute3;
1225 l_detail_info_tab(l_index).attribute4 := p_changed_attributes(l_index).attribute4;
1226 l_detail_info_tab(l_index).attribute5 := p_changed_attributes(l_index).attribute5;
1227 l_detail_info_tab(l_index).attribute6 := p_changed_attributes(l_index).attribute6;
1228 l_detail_info_tab(l_index).attribute7 := p_changed_attributes(l_index).attribute7;
1229 l_detail_info_tab(l_index).attribute8 := p_changed_attributes(l_index).attribute8;
1230 l_detail_info_tab(l_index).attribute9 := p_changed_attributes(l_index).attribute9;
1231 l_detail_info_tab(l_index).cancelled_quantity := p_changed_attributes(l_index).cancelled_quantity;
1232 l_detail_info_tab(l_index).cancelled_quantity2 := p_changed_attributes(l_index).cancelled_quantity2;
1233 l_detail_info_tab(l_index).carrier_id := p_changed_attributes(l_index).carrier_id;
1234 l_detail_info_tab(l_index).classification := p_changed_attributes(l_index).classification ;
1235 l_detail_info_tab(l_index).commodity_code_cat_id := p_changed_attributes(l_index).commodity_code_cat_id ;
1236 l_detail_info_tab(l_index).container_flag := p_changed_attributes(l_index).container_flag ;
1237 l_detail_info_tab(l_index).container_name := p_changed_attributes(l_index).container_name ;
1238 l_detail_info_tab(l_index).container_type_code := p_changed_attributes(l_index).container_type_code ;
1239 l_detail_info_tab(l_index).country_of_origin := p_changed_attributes(l_index).country_of_origin ;
1240 l_detail_info_tab(l_index).currency_code := p_changed_attributes(l_index).currency_code ;
1241 l_detail_info_tab(l_index).cust_model_serial_number := p_changed_attributes(l_index).cust_model_serial_number;
1242 l_detail_info_tab(l_index).cust_po_number := p_changed_attributes(l_index).cust_po_number;
1243 l_detail_info_tab(l_index).customer_dock_code := p_changed_attributes(l_index).customer_dock_code;
1244 l_detail_info_tab(l_index).customer_id := p_changed_attributes(l_index).customer_id ;
1245 l_detail_info_tab(l_index).customer_item_id := p_changed_attributes(l_index).customer_item_id ;
1246 l_detail_info_tab(l_index).customer_job := p_changed_attributes(l_index).customer_job ;
1247 l_detail_info_tab(l_index).customer_prod_seq := p_changed_attributes(l_index).customer_prod_seq;
1248 l_detail_info_tab(l_index).customer_production_line := p_changed_attributes(l_index).customer_production_line;
1249 l_detail_info_tab(l_index).customer_requested_lot_flag := p_changed_attributes(l_index).customer_requested_lot_flag;
1250 l_detail_info_tab(l_index).cycle_count_quantity := p_changed_attributes(l_index).cycle_count_quantity ;
1251 l_detail_info_tab(l_index).cycle_count_quantity2 := p_changed_attributes(l_index).cycle_count_quantity2 ;
1252 l_detail_info_tab(l_index).date_requested := p_changed_attributes(l_index).date_requested;
1253 l_detail_info_tab(l_index).date_scheduled := p_changed_attributes(l_index).date_scheduled;
1254 l_detail_info_tab(l_index).deliver_to_contact_id := p_changed_attributes(l_index).deliver_to_contact_id;
1255 l_detail_info_tab(l_index).delivered_quantity := p_changed_attributes(l_index).delivered_quantity;
1256 l_detail_info_tab(l_index).delivered_quantity2 := p_changed_attributes(l_index).delivered_quantity2 ;
1257 l_detail_info_tab(l_index).delivery_detail_id := p_changed_attributes(l_index).delivery_detail_id;
1258 l_detail_info_tab(l_index).dep_plan_required_flag := p_changed_attributes(l_index).dep_plan_required_flag;
1259 l_detail_info_tab(l_index).detail_container_item_id := p_changed_attributes(l_index).detail_container_item_id;
1260 l_detail_info_tab(l_index).fill_percent := p_changed_attributes(l_index).fill_percent;
1261 l_detail_info_tab(l_index).fob_code := p_changed_attributes(l_index).fob_code;
1262 l_detail_info_tab(l_index).freight_class_cat_id := p_changed_attributes(l_index).freight_class_cat_id;
1263 l_detail_info_tab(l_index).freight_terms_code := p_changed_attributes(l_index).freight_terms_code;
1264 l_detail_info_tab(l_index).gross_weight := p_changed_attributes(l_index).gross_weight;
1265 l_detail_info_tab(l_index).hazard_class_id := p_changed_attributes(l_index).hazard_class_id;
1266 l_detail_info_tab(l_index).hold_code := p_changed_attributes(l_index).hold_code;
1267 l_detail_info_tab(l_index).inspection_flag := p_changed_attributes(l_index).inspection_flag ;
1268 l_detail_info_tab(l_index).intmed_ship_to_contact_id := p_changed_attributes(l_index).intmed_ship_to_contact_id;
1269 l_detail_info_tab(l_index).inv_interfaced_flag := p_changed_attributes(l_index).inv_interfaced_flag ;
1270 l_detail_info_tab(l_index).inventory_item_id := p_changed_attributes(l_index).inventory_item_id ;
1271 l_detail_info_tab(l_index).item_description := p_changed_attributes(l_index).item_description ;
1272 l_detail_info_tab(l_index).load_seq_number := p_changed_attributes(l_index).load_seq_number ;
1273 l_detail_info_tab(l_index).lot_number := p_changed_attributes(l_index).lot_number;
1274 l_detail_info_tab(l_index).lpn_id := p_changed_attributes(l_index).lpn_id ;
1275 l_detail_info_tab(l_index).master_container_item_id := p_changed_attributes(l_index).master_container_item_id;
1276 l_detail_info_tab(l_index).master_serial_number := p_changed_attributes(l_index).master_serial_number ;
1277 l_detail_info_tab(l_index).maximum_load_weight := p_changed_attributes(l_index).maximum_load_weight ;
1278 l_detail_info_tab(l_index).maximum_volume := p_changed_attributes(l_index).maximum_volume ;
1279 l_detail_info_tab(l_index).minimum_fill_percent := p_changed_attributes(l_index).minimum_fill_percent ;
1280 l_detail_info_tab(l_index).move_order_line_id := p_changed_attributes(l_index).move_order_line_id;
1281 l_detail_info_tab(l_index).movement_id := p_changed_attributes(l_index).movement_id ;
1282 l_detail_info_tab(l_index).mvt_stat_status := p_changed_attributes(l_index).mvt_stat_status ;
1283 l_detail_info_tab(l_index).net_weight := p_changed_attributes(l_index).net_weight;
1284 l_detail_info_tab(l_index).oe_interfaced_flag := p_changed_attributes(l_index).oe_interfaced_flag;
1285 l_detail_info_tab(l_index).org_id := p_changed_attributes(l_index).org_id ;
1286 l_detail_info_tab(l_index).organization_id := p_changed_attributes(l_index).organization_id ;
1287 l_detail_info_tab(l_index).original_subinventory := p_changed_attributes(l_index).original_subinventory ;
1288 l_detail_info_tab(l_index).packing_instructions := p_changed_attributes(l_index).packing_instructions;
1289 l_detail_info_tab(l_index).pickable_flag := p_changed_attributes(l_index).pickable_flag ;
1290 l_detail_info_tab(l_index).picked_quantity := p_changed_attributes(l_index).picked_quantity;
1291 l_detail_info_tab(l_index).picked_quantity2 := p_changed_attributes(l_index).picked_quantity2;
1292 l_detail_info_tab(l_index).preferred_grade := p_changed_attributes(l_index).preferred_grade;
1293 l_detail_info_tab(l_index).project_id := p_changed_attributes(l_index).project_id;
1294 l_detail_info_tab(l_index).quality_control_quantity := p_changed_attributes(l_index).quality_control_quantity;
1295 l_detail_info_tab(l_index).quality_control_quantity2 := p_changed_attributes(l_index).quality_control_quantity2;
1296 l_detail_info_tab(l_index).received_quantity := p_changed_attributes(l_index).received_quantity;
1297 l_detail_info_tab(l_index).received_quantity2 := p_changed_attributes(l_index).received_quantity2;
1298 l_detail_info_tab(l_index).released_status := p_changed_attributes(l_index).released_status;
1299 l_detail_info_tab(l_index).request_id := p_changed_attributes(l_index).request_id;
1300 l_detail_info_tab(l_index).revision := p_changed_attributes(l_index).revision;
1301 l_detail_info_tab(l_index).seal_code := p_changed_attributes(l_index).seal_code;
1302
1303 l_detail_info_tab(l_index).ship_method_code := p_changed_attributes(l_index).shipping_method_code;
1304 l_detail_info_tab(l_index).ship_model_complete_flag := p_changed_attributes(l_index).ship_model_complete_flag;
1305 l_detail_info_tab(l_index).ship_set_id := p_changed_attributes(l_index).ship_set_id;
1306 l_detail_info_tab(l_index).ship_to_contact_id := p_changed_attributes(l_index).ship_to_contact_id;
1307 l_detail_info_tab(l_index).ship_to_site_use_id := p_changed_attributes(l_index).ship_to_site_use_id ;
1308 l_detail_info_tab(l_index).ship_tolerance_above := p_changed_attributes(l_index).ship_tolerance_above;
1309 l_detail_info_tab(l_index).ship_tolerance_below := p_changed_attributes(l_index).ship_tolerance_below;
1310 l_detail_info_tab(l_index).shipment_priority_code := p_changed_attributes(l_index).shipment_priority_code;
1311 l_detail_info_tab(l_index).shipped_quantity := p_changed_attributes(l_index).shipped_quantity ;
1312 l_detail_info_tab(l_index).shipped_quantity2 := p_changed_attributes(l_index).shipped_quantity2 ;
1313 l_detail_info_tab(l_index).shipping_instructions := p_changed_attributes(l_index).shipping_instructions;
1314 l_detail_info_tab(l_index).sold_to_contact_id := p_changed_attributes(l_index).sold_to_contact_id;
1315 l_detail_info_tab(l_index).source_code := p_changed_attributes(l_index).source_code;
1316 l_detail_info_tab(l_index).source_header_id := p_changed_attributes(l_index).source_header_id;
1317 l_detail_info_tab(l_index).source_header_number := p_changed_attributes(l_index).source_header_number ;
1318 l_detail_info_tab(l_index).source_header_type_id := p_changed_attributes(l_index).source_header_type_id ;
1319 l_detail_info_tab(l_index).source_header_type_name := p_changed_attributes(l_index).source_header_type_name ;
1320 l_detail_info_tab(l_index).source_line_id := p_changed_attributes(l_index).source_line_id;
1321 l_detail_info_tab(l_index).source_line_set_id := p_changed_attributes(l_index).source_line_set_id;
1322 l_detail_info_tab(l_index).split_from_detail_id := p_changed_attributes(l_index).split_from_delivery_detail_id ;
1323 l_detail_info_tab(l_index).src_requested_quantity := p_changed_attributes(l_index).src_requested_quantity ;
1324 l_detail_info_tab(l_index).src_requested_quantity_uom := p_changed_attributes(l_index).src_requested_quantity_uom;
1325 l_detail_info_tab(l_index).src_requested_quantity_uom2 := p_changed_attributes(l_index).src_requested_quantity_uom2 ;
1326 l_detail_info_tab(l_index).src_requested_quantity2 := p_changed_attributes(l_index).src_requested_quantity2 ;
1327 l_detail_info_tab(l_index).subinventory := p_changed_attributes(l_index).subinventory;
1328 -- HW OPMCONV - No need for sublot_number
1329 -- l_detail_info_tab(l_index).sublot_number := p_changed_attributes(l_index).sublot_number ;
1330 l_detail_info_tab(l_index).task_id := p_changed_attributes(l_index).task_id ;
1331 l_detail_info_tab(l_index).to_serial_number := p_changed_attributes(l_index).to_serial_number ;
1332 l_detail_info_tab(l_index).top_model_line_id := p_changed_attributes(l_index).top_model_line_id;
1333 l_detail_info_tab(l_index).tp_attribute_category := p_changed_attributes(l_index).tp_attribute_category ;
1334 l_detail_info_tab(l_index).tp_attribute1 := p_changed_attributes(l_index).tp_attribute1 ;
1335 l_detail_info_tab(l_index).tp_attribute10 := p_changed_attributes(l_index).tp_attribute10 ;
1336 l_detail_info_tab(l_index).tp_attribute11 := p_changed_attributes(l_index).tp_attribute11 ;
1337 l_detail_info_tab(l_index).tp_attribute12 := p_changed_attributes(l_index).tp_attribute12 ;
1338 l_detail_info_tab(l_index).tp_attribute13 := p_changed_attributes(l_index).tp_attribute13;
1339 l_detail_info_tab(l_index).tp_attribute14 := p_changed_attributes(l_index).tp_attribute14;
1340 l_detail_info_tab(l_index).tp_attribute15 := p_changed_attributes(l_index).tp_attribute15 ;
1341 l_detail_info_tab(l_index).tp_attribute2 := p_changed_attributes(l_index).tp_attribute2 ;
1342 l_detail_info_tab(l_index).tp_attribute3 := p_changed_attributes(l_index).tp_attribute3;
1343 l_detail_info_tab(l_index).tp_attribute4 := p_changed_attributes(l_index).tp_attribute4;
1344 l_detail_info_tab(l_index).tp_attribute5 := p_changed_attributes(l_index).tp_attribute5;
1345 l_detail_info_tab(l_index).tp_attribute6 := p_changed_attributes(l_index).tp_attribute6;
1346 l_detail_info_tab(l_index).tp_attribute7 := p_changed_attributes(l_index).tp_attribute7;
1347 l_detail_info_tab(l_index).tp_attribute8 := p_changed_attributes(l_index).tp_attribute8;
1348 l_detail_info_tab(l_index).tp_attribute9 := p_changed_attributes(l_index).tp_attribute9;
1349 l_detail_info_tab(l_index).tracking_number := p_changed_attributes(l_index).tracking_number;
1350
1351 -- jckwok Bug 3579965: must check whether transaction_temp_id <> FND_API.G_MISS_NUM also
1352 if (p_changed_attributes(l_index).transaction_temp_id is not null
1353 AND p_changed_attributes(l_index).transaction_temp_id <> FND_API.G_MISS_NUM) then
1354 l_detail_info_tab(l_index).transaction_temp_id := p_changed_attributes(l_index).transaction_temp_id;
1355 else
1356 l_detail_info_tab(l_index).serial_number := p_changed_attributes(l_index).serial_number;
1357 end if;
1358
1359 l_detail_info_tab(l_index).unit_price := p_changed_attributes(l_index).unit_price;
1360 l_detail_info_tab(l_index).volume := p_changed_attributes(l_index).volume;
1361 l_detail_info_tab(l_index).volume_uom_code := p_changed_attributes(l_index).volume_uom_code;
1362 l_detail_info_tab(l_index).weight_uom_code := p_changed_attributes(l_index).weight_uom_code;
1363
1364
1365 l_index := p_changed_attributes.NEXT(l_index);
1366 END LOOP;
1367
1368 IF l_debug_on THEN
1369 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTERFACE_GRP.CREATE_UPDATE_DELIVERY_DETAIL',WSH_DEBUG_SV.C_PROC_LEVEL);
1370 END IF;
1371
1372 wsh_interface_grp.Create_Update_Delivery_Detail
1373 (
1374 p_api_version_number => l_api_version_number,
1375 p_init_msg_list => FND_API.G_FALSE,
1376 p_commit => FND_API.G_FALSE,
1377 x_return_status => l_return_status,
1378 x_msg_count => l_msg_count,
1379 x_msg_data => l_msg_data,
1380 p_detail_info_tab => l_detail_info_tab,
1381 p_IN_rec => l_detail_in_rec,
1382 x_OUT_rec => l_detail_out_rec
1383 );
1384
1385 IF l_debug_on THEN
1386 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1387 END IF;
1388 --
1389 wsh_util_core.api_post_call(
1390 p_return_status => l_return_status,
1391 x_num_warnings => l_number_of_warnings,
1392 x_num_errors => l_number_of_errors,
1393 p_msg_data => l_msg_data
1394 );
1395
1396
1397 -- report success
1398 IF FND_API.TO_BOOLEAN(p_commit) THEN
1399 COMMIT WORK;
1400 END IF;
1401
1402 x_return_status := FND_API.G_RET_STS_SUCCESS;
1403 FND_MSG_PUB.Count_And_Get
1404 ( p_count => x_msg_count,
1405 p_data => x_msg_data,
1406 p_encoded => FND_API.G_FALSE
1407 );
1408 --
1409 -- Debug Statements
1410 --
1411 IF l_debug_on THEN
1412 WSH_DEBUG_SV.pop(l_module_name);
1413 END IF;
1414 --
1415 EXCEPTION
1416 WHEN mark_reprice_error then
1417 ROLLBACK TO UPDATE_SHIPPING_ATTR_GRP;
1418 FND_MESSAGE.Set_Name('WSH', 'WSH_REPRICE_REQUIRED_ERR');
1419 x_return_status := l_return_status;
1420 WSH_UTIL_CORE.add_message (x_return_status);
1421 FND_MSG_PUB.Count_And_Get
1422 ( p_count => x_msg_count,
1423 p_data => x_msg_data,
1424 p_encoded => FND_API.G_FALSE
1425 );
1426 --
1427 -- Debug Statements
1428 --
1429 IF l_debug_on THEN
1430 WSH_DEBUG_SV.logmsg(l_module_name,'MARK_REPRICE_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1431 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:MARK_REPRICE_ERROR');
1432 END IF;
1433 --
1434 WHEN invalid_source_code THEN
1435 ROLLBACK TO UPDATE_SHIPPING_ATTR_GRP;
1436 x_return_status := FND_API.G_RET_STS_ERROR;
1437 FND_MESSAGE.Set_Name('WSH', 'WSH_INVALID_SOURCE_CODE');
1438 WSH_UTIL_CORE.Add_Message(x_return_status);
1439 FND_MSG_PUB.Count_And_Get
1440 ( p_count => x_msg_count,
1441 p_data => x_msg_data,
1442 p_encoded => FND_API.G_FALSE
1443 );
1444 --
1445 -- Debug Statements
1446 --
1447 IF l_debug_on THEN
1448 WSH_DEBUG_SV.logmsg(l_module_name,'INVALID_SOURCE_CODE exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1449 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:INVALID_SOURCE_CODE');
1450 END IF;
1451 --
1452 WHEN update_failed THEN
1453 ROLLBACK TO UPDATE_SHIPPING_ATTR_GRP;
1454 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1455 FND_MESSAGE.SET_NAME('WSH', 'WSH_DETAIL_VALIDATION_FAILED');
1456 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', l_error_attribute);
1457 FND_MESSAGE.SET_TOKEN('ATTRB_VALUE', l_error_attribute_value);
1458 FND_MESSAGE.SET_TOKEN('DELIVERY_DETAIL', l_error_detail_id);
1459 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
1460 FND_MSG_PUB.Count_And_Get
1461 ( p_count => x_msg_count,
1462 p_data => x_msg_data,
1463 p_encoded => FND_API.G_FALSE
1464 );
1465
1466 -- Bug fix 2154602
1467 IF l_debug_on THEN
1468 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1469 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:UPDATE_FAILED');
1470 END IF;
1471 --
1472 WHEN invalid_released_status THEN
1473 ROLLBACK TO UPDATE_SHIPPING_ATTR_GRP;
1474 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1475 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
1476 FND_MSG_PUB.Count_And_Get
1477 ( p_count => x_msg_count,
1478 p_data => x_msg_data,
1479 p_encoded => FND_API.G_FALSE
1480 );
1481 -- End of Bug fix 2154602
1482
1483 IF l_debug_on THEN
1484 WSH_DEBUG_SV.logmsg(l_module_name,'INVALID_RELEASED_STATUS exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1485 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:INVALID_RELEASED_STATUS');
1486 END IF;
1487 --
1488 WHEN Others THEN
1489 IF get_org%isopen THEN
1490 close get_org;
1491 END IF;
1492 ROLLBACK TO UPDATE_SHIPPING_ATTR_GRP;
1493 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1494 WSH_UTIL_CORE.add_message (x_return_status);
1495 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Update_Shipping_Attributes');
1496 FND_MSG_PUB.Count_And_Get
1497 ( p_count => x_msg_count,
1498 p_data => x_msg_data,
1499 p_encoded => FND_API.G_FALSE
1500 );
1501 IF l_debug_on THEN
1502 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1503 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1504 END IF;
1505 --
1506 END Update_Shipping_Attributes;
1507
1508 PROCEDURE Get_Detail_Status(
1509 p_delivery_detail_id IN NUMBER
1510 , x_line_status OUT NOCOPY VARCHAR2
1511 , x_return_status OUT NOCOPY VARCHAR2
1512 )
1513 IS
1514 CURSOR del_assign IS
1515 SELECT delivery_id, parent_delivery_detail_id
1516 FROM wsh_delivery_assignments_v
1517 WHERE delivery_detail_id = p_delivery_detail_id;
1518 l_assign_rec del_assign%ROWTYPE;
1519
1520 CURSOR del_status(c_del_id NUMBER) IS
1521 SELECT status_code
1522 FROM wsh_new_deliveries
1523 WHERE delivery_id = c_del_id;
1524
1525 l_del_status VARCHAR2(100) := NULL;
1526 l_msg_summary VARCHAR2(3000);
1527 x_msg_count NUMBER;
1528 --
1529 l_debug_on BOOLEAN;
1530 --
1531 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_DETAIL_STATUS';
1532 --
1533 BEGIN
1534 --
1535 -- Debug Statements
1536 --
1537 --
1538 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1539 --
1540 IF l_debug_on IS NULL
1541 THEN
1542 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1543 END IF;
1544 --
1545 IF l_debug_on THEN
1546 WSH_DEBUG_SV.push(l_module_name);
1547 --
1548 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',P_DELIVERY_DETAIL_ID);
1549 END IF;
1550 --
1551 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1552
1553 -- get line status for delivery detail
1554 OPEN del_assign;
1555 FETCH del_assign INTO l_assign_rec;
1556 IF (l_assign_rec.delivery_id IS NOT NULL) THEN
1557 OPEN del_status(l_assign_rec.delivery_id);
1558 FETCH del_status INTO l_del_status;
1559 CLOSE del_status;
1560 END IF;
1561 CLOSE del_assign;
1562
1563 IF (l_del_status IN ('CO', 'IT', 'CL')) THEN
1564 x_line_status := 'SIC';
1565 ELSIF (l_assign_rec.parent_delivery_detail_id IS NOT NULL) THEN
1566 x_line_status := 'PK';
1567 ELSIF( l_assign_rec.parent_delivery_detail_id IS NULL) THEN
1568 x_line_status := 'OK';
1569 ELSE
1570 NULL;
1571 END IF;
1572
1573 /*
1574 EXCEPTION
1575 WHEN others then
1576 wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_GRP.Get_Detail_Status');
1577 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1578 WSH_UTIL_CORE.get_messages('Y', l_msg_summary, l_msg_details, x_msg_count);
1579 if x_msg_count > 1 then
1580 x_msg_data := l_msg_summary || l_msg_details;
1581 else
1582 x_msg_data := l_msg_summary;
1583 end if;
1584 */
1585 IF l_debug_on THEN
1586 WSH_DEBUG_SV.log(l_module_name,'X_LINE_STATUS',x_line_status);
1587 WSH_DEBUG_SV.pop(l_module_name);
1588 END IF;
1589 --
1590 END get_detail_status;
1591
1592 -- ---------------------------------------------------------------------
1593 -- Procedure: Autocreate_Deliveries
1594 --
1595 -- change on 8/24/2005 : p_caller is added
1596 -- refer to bug 4467032 (R12 Routing Guide)
1597 -- -----------------------------------------------------------------------
1598 PROCEDURE Autocreate_Deliveries(
1599 -- Standard parameters
1600 p_api_version_number IN NUMBER
1601 , p_init_msg_list IN VARCHAR2
1602 , p_commit IN VARCHAR2
1603 , p_caller IN VARCHAR2 DEFAULT NULL
1604 , x_return_status OUT NOCOPY VARCHAR2
1605 , x_msg_count OUT NOCOPY NUMBER
1606 , x_msg_data OUT NOCOPY VARCHAR2
1607 , p_line_rows IN WSH_UTIL_CORE.id_tab_type
1608 , p_group_by_header_flag IN VARCHAR2
1609 , x_del_rows OUT NOCOPY wsh_util_core.id_tab_type
1610 )
1611 IS
1612 l_dummy_rows WSH_UTIL_CORE.id_tab_type;
1613 l_api_version_number NUMBER := 1.0;
1614 l_api_name CONSTANT VARCHAR2(30):= 'Autocreate_Deliveries';
1615 l_return_status VARCHAR2(30);
1616 autocreate_delivery_failed EXCEPTION;
1617 l_msg_summary varchar2(2000) := NULL;
1618 l_msg_details varchar2(4000) := NULL;
1619 --
1620 l_number_of_errors NUMBER := 0;
1621 l_number_of_warnings NUMBER := 0;
1622 l_msg_data VARCHAR2(32767);
1623 l_debug_on BOOLEAN;
1624 --
1625 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'AUTOCREATE_DELIVERIES';
1626 --
1627
1628 --
1629 -- Following 4 variables are added for bugfix #4070732
1630 l_api_session_name CONSTANT VARCHAR2(150) := G_PKG_NAME ||'.' || l_module_name;
1631 l_reset_flags BOOLEAN;
1632 --
1633 BEGIN
1634 -- Bugfix 4070732
1635 IF WSH_UTIL_CORE.G_START_OF_SESSION_API is null
1636 THEN
1637 WSH_UTIL_CORE.G_START_OF_SESSION_API := l_api_session_name;
1638 WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API := FALSE;
1639 END IF;
1640 -- End of Code Bugfix 4070732
1641 --
1642 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1643 --
1644 IF l_debug_on IS NULL
1645 THEN
1646 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1647 END IF;
1648 --
1649 SAVEPOINT AUTOCREATE_DEL_GRP;
1650
1651 -- Standard begin of API savepoint
1652 IF l_debug_on THEN
1653 WSH_DEBUG_SV.push(l_module_name);
1654 --
1655 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
1656 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
1657 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
1658 WSH_DEBUG_SV.log(l_module_name,'P_LINE_ROWS.COUNT',P_LINE_ROWS.COUNT);
1659 END IF;
1660 --
1661
1662 IF NOT FND_API.compatible_api_call(
1663 l_api_version_number,
1664 p_api_version_number,
1665 l_api_name,
1666 G_PKG_NAME) THEN
1667 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1668 END IF;
1669
1670 -- Check p_init_msg_list
1671 IF FND_API.to_boolean(p_init_msg_list) THEN
1672 FND_MSG_PUB.initialize;
1673 END IF;
1674 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1675
1676 IF l_debug_on THEN
1677 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_AUTOCREATE.AUTOCREATE_DEL_ACROSS_ORGS',WSH_DEBUG_SV.C_PROC_LEVEL);
1678 END IF;
1679 --
1680 wsh_delivery_autocreate.autocreate_del_across_orgs(
1681 p_line_rows => p_line_rows,
1682 p_org_rows => l_dummy_rows, -- bug 1668578
1683 p_container_flag => 'N',
1684 p_check_flag => 'N',
1685 p_caller => p_caller,
1686 p_max_detail_commit => NULL,
1687 p_group_by_header_flag => p_group_by_header_flag,
1688 x_del_rows => x_del_rows,
1689 x_grouping_rows => l_dummy_rows,
1690 x_return_status => l_return_status);
1691
1692 wsh_util_core.api_post_call(
1693 p_return_status => l_return_status,
1694 x_num_warnings => l_number_of_warnings,
1695 x_num_errors => l_number_of_errors,
1696 p_msg_data => l_msg_data
1697 );
1698
1699 IF l_number_of_warnings > 0 THEN
1700 IF l_debug_on THEN
1701 wsh_debug_sv.log(l_module_name,'Number of warnings', l_number_of_warnings);
1702 END IF;
1703 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
1704 END IF;
1705
1706
1707 IF FND_API.TO_BOOLEAN(p_commit) THEN
1708 --
1709 -- Start code for Bugfix 4070732
1710 --
1711 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1712 IF l_debug_on THEN
1713 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1714 END IF;
1715 l_reset_flags := FALSE;
1716
1717 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => l_reset_flags,
1718 x_return_status => l_return_status);
1719
1720 IF l_debug_on THEN
1721 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1722 END IF;
1723
1724 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1725 RAISE FND_API.G_EXC_ERROR;
1726 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1727 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1728 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
1729 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
1730 END IF;
1731
1732 END IF;
1733 --
1734 -- End of code for Bugfix 4070732
1735 --
1736 COMMIT WORK;
1737 END IF;
1738
1739
1740 --bug 4070732
1741 --End of the API handling of calls to process_stops_for_load_tender
1742 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
1743 --{
1744 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1745 --{
1746
1747 IF FND_API.TO_BOOLEAN(p_commit) THEN
1748
1749 IF l_debug_on THEN
1750 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1751 END IF;
1752
1753 WSH_UTIL_CORE.reset_stops_for_load_tender(p_reset_flags => TRUE,
1754 x_return_status => l_return_status);
1755
1756 ELSE
1757
1758 IF l_debug_on THEN
1759 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1760 END IF;
1761
1762 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
1763 x_return_status => l_return_status);
1764 END IF;
1765
1766 IF l_debug_on THEN
1767 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1768 END IF;
1769
1770 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1771 x_return_status := l_return_status;
1772
1773 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
1774 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
1775 IF NOT(FND_API.TO_BOOLEAN(p_commit)) THEN
1776 ROLLBACK TO AUTOCREATE_DEL_GRP;
1777 end if;
1778 END IF;
1779 END IF;
1780 --}
1781 END IF;
1782 --}
1783 END IF;
1784
1785 --bug 4070732
1786 --
1787 FND_MSG_PUB.Count_And_Get
1788 (
1789 p_count => x_msg_count,
1790 p_data => x_msg_data,
1791 p_encoded => FND_API.G_FALSE
1792 );
1793
1794
1795 IF l_debug_on THEN
1796 WSH_DEBUG_SV.log(l_module_name,'X_DEL_ROWS.COUNT',x_del_rows.count);
1797 WSH_DEBUG_SV.pop(l_module_name);
1798 END IF;
1799 --
1800 EXCEPTION
1801 WHEN FND_API.G_EXC_ERROR THEN
1802 ROLLBACK TO AUTOCREATE_DEL_GRP;
1803 x_return_status := FND_API.G_RET_STS_ERROR ;
1804 --
1805 -- Start code for Bugfix 4070732
1806 --
1807 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
1808 THEN
1809 --{
1810 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1811 --{
1812 IF l_debug_on THEN
1813 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1814 END IF;
1815
1816 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
1817 x_return_status => l_return_status);
1818
1819 IF l_debug_on THEN
1820 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1821 END IF;
1822
1823 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
1824 x_return_status := l_return_status;
1825 END IF;
1826 --}
1827 END IF;
1828 --}
1829 END IF;
1830 --
1831 -- End of Code Bugfix 4070732
1832 --
1833 FND_MSG_PUB.Count_And_Get
1834 (
1835 p_count => x_msg_count,
1836 p_data => x_msg_data,
1837 p_encoded => FND_API.G_FALSE
1838 );
1839
1840
1841 IF l_debug_on THEN
1842 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1843 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1844 END IF;
1845 --
1846
1847 WHEN autocreate_delivery_failed THEN
1848 ROLLBACK TO AUTOCREATE_DEL_GRP;
1849 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1850 wsh_util_core.add_message(x_return_status, l_module_name);
1851 --
1852 -- Start code for Bugfix 4070732
1853 --
1854 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
1855 THEN
1856 --{
1857 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1858 --{
1859 IF l_debug_on THEN
1860 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1861 END IF;
1862
1863 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
1864 x_return_status => l_return_status);
1865
1866 IF l_debug_on THEN
1867 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1868 END IF;
1869
1870 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
1871 x_return_status := l_return_status;
1872 END IF;
1873 --}
1874 END IF;
1875 --}
1876 END IF;
1877 --
1878 -- End of Code Bugfix 4070732
1879 --
1880
1881 FND_MSG_PUB.Count_And_Get
1882 (
1883 p_count => x_msg_count,
1884 p_data => x_msg_data,
1885 p_encoded => FND_API.G_FALSE
1886 );
1887
1888
1889 IF l_debug_on THEN
1890 WSH_DEBUG_SV.logmsg(l_module_name,'AUTOCREATE_DELIVERY_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1891 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:AUTOCREATE_DELIVERY_FAILED');
1892 END IF;
1893
1894 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1895 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1896 --
1897 -- Start code for Bugfix 4070732
1898 --
1899 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
1900 THEN
1901 --{
1902 IF NOT (WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API)
1903 THEN
1904 --{
1905
1906 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
1907 x_return_status => l_return_status);
1908
1909 IF l_debug_on THEN
1910 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1911 END IF;
1912
1913 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1914 x_return_status := l_return_status;
1915
1916 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
1917 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
1918 ROLLBACK TO AUTOCREATE_DEL_GRP;
1919 END IF;
1920 END IF;
1921 --}
1922 END IF;
1923 ---}
1924 END IF;
1925 --
1926 -- End of Code Bugfix 4070732
1927 --
1928
1929 FND_MSG_PUB.Count_And_Get
1930 (
1931 p_count => x_msg_count,
1932 p_data => x_msg_data,
1933 p_encoded => FND_API.G_FALSE
1934 );
1935
1936
1937 IF l_debug_on THEN
1938 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1939 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1940 END IF;
1941 --
1942 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1943 ROLLBACK TO AUTOCREATE_DEL_GRP;
1944 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1945 --
1946 -- Start of code for Bugfix 4070732
1947 --
1948 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
1949 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1950 IF l_debug_on THEN
1951 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1952 END IF;
1953
1954 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
1955 x_return_status => l_return_status);
1956
1957
1958 IF l_debug_on THEN
1959 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1960 END IF;
1961
1962 END IF;
1963 END IF;
1964 --
1965 -- End of code for Bugfix 4070732
1966 --
1967 FND_MSG_PUB.Count_And_Get
1968 (
1969 p_count => x_msg_count,
1970 p_data => x_msg_data,
1971 p_encoded => FND_API.G_FALSE
1972 );
1973 --
1974 IF l_debug_on THEN
1975 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1976 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1977 END IF;
1978 --
1979 WHEN OTHERS THEN
1980 ROLLBACK TO AUTOCREATE_DEL_GRP;
1981 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1982 wsh_util_core.add_message(x_return_status, l_module_name);
1983 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Autocreate_Deliveries');
1984 --
1985 -- Start of code for Bugfix 4070732
1986 --
1987 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
1988 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
1989 IF l_debug_on THEN
1990 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
1991 END IF;
1992
1993 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
1994 x_return_status => l_return_status);
1995
1996
1997 IF l_debug_on THEN
1998 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1999 END IF;
2000
2001 END IF;
2002 END IF;
2003 --
2004 -- End of code for Bugfix 4070732
2005 --
2006 FND_MSG_PUB.Count_And_Get
2007 (
2008 p_count => x_msg_count,
2009 p_data => x_msg_data,
2010 p_encoded => FND_API.G_FALSE
2011 );
2012 --
2013 IF l_debug_on THEN
2014 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2015 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2016 END IF;
2017 --
2018 END Autocreate_Deliveries;
2019
2020 PROCEDURE Autocreate_del_trip(
2021 -- Standard parameters
2022 p_api_version_number IN NUMBER
2023 , p_init_msg_list IN VARCHAR2
2024 , p_commit IN VARCHAR2
2025 , x_return_status OUT NOCOPY VARCHAR2
2026 , x_msg_count OUT NOCOPY NUMBER
2027 , x_msg_data OUT NOCOPY VARCHAR2
2028 , p_line_rows IN WSH_UTIL_CORE.id_tab_type
2029 , x_del_rows OUT NOCOPY WSH_UTIL_CORE.id_tab_type
2030 , x_trip_rows OUT NOCOPY WSH_UTIL_CORE.id_tab_type
2031 )
2032 IS
2033 l_api_name CONSTANT VARCHAR2(30):= 'Autocreate_del_trip';
2034 l_api_version_number CONSTANT NUMBER := 1.0;
2035 l_return_status VARCHAR2(30);
2036 autocreate_trip_failed EXCEPTION;
2037 l_msg_summary varchar2(2000) := NULL;
2038 l_msg_details varchar2(4000) := NULL;
2039 l_org_rows wsh_util_core.id_tab_type; -- bug 1668578
2040 l_number_of_errors NUMBER := 0;
2041 l_number_of_warnings NUMBER := 0;
2042 l_msg_data VARCHAR2(32767);
2043 --
2044 l_debug_on BOOLEAN;
2045 --
2046 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'AUTOCREATE_DEL_TRIP';
2047 --
2048 BEGIN
2049 --
2050 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2051 --
2052 IF l_debug_on IS NULL
2053 THEN
2054 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2055 END IF;
2056 --
2057 SAVEPOINT AUTOCREATE_TRIP_GRP;
2058 -- Standard begin of API savepoint
2059
2060 IF l_debug_on THEN
2061 WSH_DEBUG_SV.push(l_module_name);
2062 --
2063 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
2064 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
2065 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
2066 WSH_DEBUG_SV.log(l_module_name,'P_LINE_ROWS.COUNT',P_LINE_ROWS.COUNT);
2067 END IF;
2068 --
2069
2070 IF NOT FND_API.compatible_api_call(
2071 l_api_version_number,
2072 p_api_version_number,
2073 l_api_name,
2074 G_PKG_NAME) THEN
2075 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2076 END IF;
2077
2078 -- Check p_init_msg_list
2079 IF FND_API.to_boolean(p_init_msg_list) THEN
2080 FND_MSG_PUB.initialize;
2081 END IF;
2082 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2083
2084 IF l_debug_on THEN
2085 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_TRIPS_ACTIONS.AUTOCREATE_DEL_TRIP',WSH_DEBUG_SV.C_PROC_LEVEL);
2086 END IF;
2087 --
2088 WSH_TRIPS_ACTIONS.autocreate_del_trip(
2089 p_line_rows => p_line_rows,
2090 p_org_rows => l_org_rows, -- bug 1668578
2091 x_del_rows => x_del_rows,
2092 x_trip_rows => x_trip_rows,
2093 x_return_status => l_return_status);
2094
2095 wsh_util_core.api_post_call(
2096 p_return_status => l_return_status,
2097 x_num_warnings => l_number_of_warnings,
2098 x_num_errors => l_number_of_errors,
2099 p_msg_data => l_msg_data
2100 );
2101
2102
2103 IF l_number_of_warnings > 0 THEN
2104 IF l_debug_on THEN
2105 wsh_debug_sv.log(l_module_name,'Number of warnings', l_number_of_warnings);
2106 END IF;
2107 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
2108 END IF;
2109
2110
2111 FND_MSG_PUB.Count_And_Get
2112 (
2113 p_count => x_msg_count,
2114 p_data => x_msg_data,
2115 p_encoded => FND_API.G_FALSE
2116 );
2117
2118 IF FND_API.TO_BOOLEAN(p_commit) THEN
2119 COMMIT WORK;
2120 END IF;
2121
2122 IF l_debug_on THEN
2123 WSH_DEBUG_SV.log(l_module_name,'X_DEL_ROWS.COUNT',x_del_rows.count);
2124 WSH_DEBUG_SV.log(l_module_name, 'X trip rows.count', x_trip_rows.count);
2125 WSH_DEBUG_SV.pop(l_module_name);
2126 END IF;
2127 --
2128 EXCEPTION
2129 WHEN FND_API.G_EXC_ERROR THEN
2130 ROLLBACK TO AUTOCREATE_TRIP_GRP;
2131 x_return_status := FND_API.G_RET_STS_ERROR ;
2132 FND_MSG_PUB.Count_And_Get
2133 (
2134 p_count => x_msg_count,
2135 p_data => x_msg_data,
2136 p_encoded => FND_API.G_FALSE
2137 );
2138
2139 IF l_debug_on THEN
2140 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2141 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2142 END IF;
2143 --
2144 WHEN autocreate_trip_failed THEN
2145 ROLLBACK TO AUTOCREATE_TRIP_GRP;
2146 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2147 wsh_util_core.add_message(x_return_status);
2148 FND_MSG_PUB.Count_And_Get
2149 (
2150 p_count => x_msg_count,
2151 p_data => x_msg_data,
2152 p_encoded => FND_API.G_FALSE
2153 );
2154 IF l_debug_on THEN
2155 WSH_DEBUG_SV.logmsg(l_module_name,'AUTOCREATE_TRIP_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2156 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:AUTOCREATE_TRIP_FAILED');
2157 END IF;
2158 --
2159 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2160 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2161 FND_MSG_PUB.Count_And_Get
2162 (
2163 p_count => x_msg_count,
2164 p_data => x_msg_data,
2165 p_encoded => FND_API.G_FALSE
2166 );
2167 --
2168 IF l_debug_on THEN
2169 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2170 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2171 END IF;
2172 --
2173 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2174 ROLLBACK TO AUTOCREATE_TRIP_GRP;
2175 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2176 FND_MSG_PUB.Count_And_Get
2177 (
2178 p_count => x_msg_count,
2179 p_data => x_msg_data,
2180 p_encoded => FND_API.G_FALSE
2181 );
2182 --
2183
2184 IF l_debug_on THEN
2185 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2186 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2187 END IF;
2188 --
2189 WHEN OTHERS THEN
2190 ROLLBACK TO AUTOCREATE_TRIP_GRP;
2191 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2192 wsh_util_core.add_message(x_return_status, l_module_name);
2193 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Autocreate_Del_Trip');
2194 FND_MSG_PUB.Count_And_Get
2195 (
2196 p_count => x_msg_count,
2197 p_data => x_msg_data,
2198 p_encoded => FND_API.G_FALSE
2199 );
2200 --
2201 IF l_debug_on THEN
2202 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2203 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2204 END IF;
2205
2206 --
2207 END Autocreate_del_trip;
2208
2209
2210 -- ---------------------------------------------------------------------
2211 -- Procedure: Delivery_Detail_Action
2212 --
2213 -- Parameters:
2214 --
2215 -- Description: This procedure is the core group API for the
2216 -- delivery_detail_action. This is for called by STF directly.
2217 -- Public API and other product APIs call the wrapper version.
2218 -- The wrapper version, in turn, calls this procedure.
2219 -- Created: Harmonization Project. Patchset I
2220 -- -----------------------------------------------------------------------
2221 PROCEDURE Delivery_Detail_Action(
2222 -- Standard Parameters
2223 p_api_version_number IN NUMBER,
2224 p_init_msg_list IN VARCHAR2,
2225 p_commit IN VARCHAR2,
2226 x_return_status OUT NOCOPY VARCHAR2,
2227 x_msg_count OUT NOCOPY NUMBER,
2228 x_msg_data OUT NOCOPY VARCHAR2,
2229
2230 -- Procedure specific Parameters
2231 p_rec_attr_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
2232 p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
2233 x_defaults OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_default_parameters_rec_type, -- defaults
2234 x_action_out_rec OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_out_rec_type
2235 ) IS
2236
2237 l_api_name CONSTANT VARCHAR2(30) := 'delivery_detail_action';
2238 l_api_version CONSTANT NUMBER := 1.0;
2239 --
2240 --
2241 l_return_status VARCHAR2(32767);
2242 l1_return_status VARCHAR2(32767);
2243 l_msg_count NUMBER;
2244 l_msg_data VARCHAR2(32767);
2245 l_program_name VARCHAR2(32767);
2246 l_validation_level NUMBER;
2247 --
2248 --
2249 --
2250 l_number_of_errors NUMBER := 0;
2251 l_number_of_warnings NUMBER := 0;
2252 l_counter NUMBER := 0;
2253 l_index NUMBER;
2254 check_status NUMBER;
2255
2256 -- Variables for pack, unpack, auto-pack
2257 l_group_id_tab WSH_UTIL_CORE.ID_TAB_TYPE;
2258 l_entity_type VARCHAR2(32767);
2259 l_cont_flag VARCHAR2(32767);
2260 l_container_name VARCHAR2(32767);
2261 l_delivery_flag VARCHAR2(32767);
2262 l_cont_instance_id NUMBER;
2263
2264
2265 -- Variables for cycle_count
2266 l_bo_rows WSH_UTIL_CORE.Id_Tab_Type;
2267 l_bo_qtys WSH_UTIL_CORE.Id_Tab_Type;
2268 l_req_qtys WSH_UTIL_CORE.Id_Tab_Type;
2269 l_bo_qtys2 WSH_UTIL_CORE.Id_Tab_Type;
2270 l_overpick_qtys WSH_UTIL_CORE.Id_Tab_Type;
2271 l_overpick_qtys2 WSH_UTIL_CORE.Id_Tab_Type;
2272
2273 --
2274 l_released_status VARCHAR2(32767);
2275 l_line_direction VARCHAR2(32767);
2276 l_inventory_item_id NUMBER;
2277 l_requested_quantity NUMBER;
2278 l_requested_quantity2 NUMBER;
2279 l_picked_quantity NUMBER;
2280 l_picked_quantity2 NUMBER;
2281 l_shipped_quantity NUMBER;
2282 l_shipped_quantity2 NUMBER;
2283 l_inv_item_id NUMBER;
2284 l_organization_id NUMBER;
2285 l_requested_quantity_uom VARCHAR2(32767);
2286 -- HW OPMCONV - Added variable uom2
2287 l_requested_quantity_uom2 VARCHAR2(32767);
2288 l_output_quantity NUMBER;
2289 l_split_quantity NUMBER;
2290 l_split_quantity2 NUMBER;
2291 l_manual_split VARCHAR2(1);
2292 l_converted_flag VARCHAR2(1); -- HW OPM
2293
2294 --
2295 l_validation_level_tab WSH_UTIL_CORE.Id_Tab_Type;
2296 l_id_tab WSH_UTIL_CORE.Id_Tab_Type;
2297 l_dummy_ids WSH_UTIL_CORE.Id_Tab_Type;
2298 l_request_ids WSH_UTIL_CORE.Id_Tab_Type;
2299 l_valid_ids WSH_UTIL_CORE.Id_Tab_Type;
2300 l_error_ids WSH_UTIL_CORE.Id_Tab_Type;
2301 l_valid_index_tab WSH_UTIL_CORE.Id_Tab_Type;
2302 l_valid_ids_tab WSH_UTIL_CORE.Id_Tab_Type;
2303 --
2304 --anxsharm for load tender
2305 l_trip_id_tab WSH_UTIL_CORE.Id_Tab_Type;
2306
2307 l_dlvy_organization_id NUMBER;
2308 l_dlvy_status_code VARCHAR2(32767);
2309 l_dlvy_planned_flag VARCHAR2(32767);
2310 l_dlvy_shipment_direction VARCHAR2(30);
2311 --
2312 l_detail_rec_tab WSH_DETAILS_VALIDATIONS.detail_rec_tab_type;
2313 l_dlvy_rec_tab WSH_DELIVERY_VALIDATIONS.dlvy_rec_tab_type;
2314 l_det_id_tab WSH_UTIL_CORE.ID_TAB_TYPE;
2315 l_detail_group_params wsh_delivery_autocreate.grp_attr_rec_type;
2316
2317 l_attr_tab wsh_delivery_autocreate.grp_attr_tab_type;
2318 l_group_info wsh_delivery_autocreate.grp_attr_tab_type;
2319 l_action_rec wsh_delivery_autocreate.action_rec_type;
2320 l_target_rec wsh_delivery_autocreate.grp_attr_rec_type;
2321 l_matched_entities wsh_util_core.id_tab_type;
2322 l_out_rec wsh_delivery_autocreate.out_rec_type;
2323
2324 -- Consolidation of BO Delivery details project
2325 l_line_ids WSH_UTIL_CORE.Id_Tab_Type;
2326 l_cons_flags WSH_UTIL_CORE.Column_Tab_Type;
2327 l_global_param_rec WSH_SHIPPING_PARAMS_PVT.Global_Parameters_Rec_Typ;
2328
2329 CURSOR det_cur(p_del_det_id NUMBER) IS
2330 SELECT inventory_item_id
2331 , organization_id
2332 , requested_quantity_uom
2333 , nvl(line_direction,'O') line_direction -- J-IB-NPARIKH
2334 , released_status
2335 FROM wsh_delivery_details
2336 WHERE delivery_detail_id = p_del_det_id;
2337
2338 -- HW Harmonization project for OPM. Need to get organization_id
2339 -- HW OPMCONV - 1) Added retrieval of UOM2 -
2340 -- - 2) Changed name to det_line
2341 CURSOR det_line(l_del_det_id NUMBER) IS
2342 SELECT nvl(line_direction,'O') line_direction, requested_quantity_uom2
2343 FROM wsh_delivery_details
2344 WHERE delivery_detail_id = l_del_det_id;
2345 -- HW OPM end
2346
2347 --
2348 CURSOR cycle_count_cur(p_del_det_id NUMBER) IS
2349 SELECT released_status, requested_quantity, requested_quantity2,
2350 picked_quantity, picked_quantity2 , shipped_quantity , shipped_quantity2,
2351 organization_id, inventory_item_id
2352 FROM wsh_delivery_details
2353 WHERE delivery_detail_id = p_del_det_id;
2354
2355 --
2356 CURSOR del_cur(p_dlvy_id NUMBER) IS
2357 SELECT organization_id,
2358 status_code,
2359 planned_flag,
2360 nvl(shipment_direction, 'O'), -- shipment_direction jckwok
2361 nvl(ignore_for_planning, 'N'), -- OTM R12 : WSHDEVLS record
2362 nvl(tms_interface_flag, WSH_NEW_DELIVERIES_PVT.C_TMS_NOT_TO_BE_SENT) -- OTM R12 : WSHDEVLS record
2363 FROM wsh_new_deliveries
2364 WHERE delivery_id = p_dlvy_id;
2365
2366 --
2367 -- deliveryMerge
2368
2369 CURSOR get_delivery(p_del_det_id NUMBER) IS
2370 SELECT wda.delivery_id
2371 FROM wsh_delivery_assignments_v wda, wsh_delivery_details wdd
2372 WHERE wdd.delivery_detail_id = p_del_det_id
2373 AND wdd.delivery_detail_id = wda.delivery_detail_id
2374 AND wdd.container_flag = 'N'
2375 AND wdd.source_code = 'OE'
2376 AND NVL(wdd.line_direction, 'O') in ('O', 'IO');
2377
2378 l_debug_on BOOLEAN;
2379 --
2380 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'DELIVERY_DETAIL_ACTION';
2381
2382
2383 --Compatibility Changes
2384 l_cc_validate_result VARCHAR2(1);
2385 l_cc_failed_records WSH_FTE_COMP_CONSTRAINT_PKG.failed_line_tab_type;
2386 l_cc_line_groups WSH_FTE_COMP_CONSTRAINT_PKG.line_group_tab_type;
2387 l_cc_group_info WSH_FTE_COMP_CONSTRAINT_PKG.cc_group_tab_type;
2388
2389
2390 b_cc_linefailed boolean;
2391 b_cc_groupidexists boolean;
2392 l_id_tab_temp wsh_util_core.id_tab_type;
2393 l_id_tab_t wsh_util_core.id_tab_type;
2394 l_cc_count_success NUMBER;
2395 l_cc_count_group_ids NUMBER;
2396 l_cc_count_rec NUMBER;
2397 l_cc_group_ids wsh_util_core.id_tab_type;
2398
2399 l_cc_upd_dlvy_intmed_ship_to VARCHAR2(1);
2400 l_cc_upd_dlvy_ship_method VARCHAR2(1);
2401 l_cc_dlvy_intmed_ship_to NUMBER;
2402 l_cc_dlvy_ship_method VARCHAR2(30);
2403
2404 l_cc_count_del_rows NUMBER;
2405 l_num_errors NUMBER;
2406 l_cc_del_rows wsh_util_core.id_tab_type;
2407 l_cc_grouping_rows wsh_util_core.id_tab_type;
2408 l_cc_return_status VARCHAR2(1);
2409 l_trip_id NUMBER;
2410
2411 --dummy tables for calling validate_constraint_mainper
2412 l_cc_del_attr_tab WSH_NEW_DELIVERIES_PVT.Delivery_Attr_Tbl_Type;
2413 l_cc_det_attr_tab WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type;
2414 l_cc_trip_attr_tab WSH_TRIPS_PVT.Trip_Attr_Tbl_Type;
2415 l_cc_stop_attr_tab WSH_TRIP_STOPS_PVT.Stop_Attr_Tbl_Type;
2416 l_cc_in_ids wsh_util_core.id_tab_type;
2417 l_cc_fail_ids wsh_util_core.id_tab_type;
2418
2419 l_delivery_detail_id NUMBER;
2420
2421 CURSOR c_delcur(p_dlvy_id NUMBER) IS
2422 SELECT SHIP_METHOD_CODE, INTMED_SHIP_TO_LOCATION_ID
2423 FROM wsh_new_deliveries
2424 WHERE delivery_id = p_dlvy_id;
2425
2426 --Compatibility Changes
2427
2428 l_action_code VARCHAR2(32767);
2429 --
2430 -- deliveryMerge
2431 l_delivery_ids wsh_util_core.id_tab_type;
2432 l_delivery_id NUMBER;
2433 l_delivery_already_included boolean;
2434 --
2435 --
2436 l_cnt NUMBER;
2437 l_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
2438 --
2439
2440 l_dummy_line_ids WSH_UTIL_CORE.Id_Tab_Type;
2441
2442 e_end_of_api EXCEPTION;
2443 --dcp
2444 l_check_dcp NUMBER;
2445 --Bugfix 4070732
2446 l_api_session_name CONSTANT VARCHAR2(150) := G_PKG_NAME ||'.' || l_module_name;
2447 l_reset_flags BOOLEAN;
2448
2449 -- K LPN CONV. rv
2450 l_lpn_in_sync_comm_rec WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_in_rec_type;
2451 l_lpn_out_sync_comm_rec WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_out_rec_type;
2452 -- K LPN CONV. rv
2453 --
2454
2455 -- OTM R12 : due to record changes in WSHDEVLS
2456 l_dlvy_ignore WSH_NEW_DELIVERIES.IGNORE_FOR_PLANNING%TYPE;
2457 l_tms_interface_flag WSH_NEW_DELIVERIES.TMS_INTERFACE_FLAG%TYPE;
2458 -- End of OTM R12 : due to record changes in WSHDEVLS
2459
2460 -- OTM R12 : packing ECO
2461 l_gc3_is_installed VARCHAR2(1);
2462 -- End of OTM R12 : packing ECO
2463
2464
2465 BEGIN
2466 --dcp
2467 <<api_start>>
2468
2469 -- Bugfix 4070732
2470 IF WSH_UTIL_CORE.G_START_OF_SESSION_API is null
2471 THEN
2472 WSH_UTIL_CORE.G_START_OF_SESSION_API := l_api_session_name;
2473 WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API := FALSE;
2474 END IF;
2475 -- End of Code Bugfix 4070732
2476
2477 -- Standard Start of API savepoint
2478 --
2479 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2480 --
2481 IF l_debug_on IS NULL
2482 THEN
2483 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2484 END IF;
2485 --
2486 SAVEPOINT DELIVERY_DETAIL_ACTION_GRP;
2487
2488 l_check_dcp := WSH_DCP_PVT.G_CHECK_DCP;
2489
2490 if l_check_dcp is null then
2491 l_check_dcp := wsh_dcp_pvt.is_dcp_enabled;
2492 end if;
2493
2494 --
2495 -- Debug Statements
2496 --
2497 IF l_debug_on THEN
2498 WSH_DEBUG_SV.push(l_module_name);
2499 --
2500 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
2501 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
2502 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
2503 WSH_DEBUG_SV.log(l_module_name, 'Caller', p_action_prms.caller);
2504 WSH_DEBUG_SV.log(l_module_name, 'Phase', p_action_prms.phase);
2505 WSH_DEBUG_SV.log(l_module_name, 'Action Code', p_action_prms.action_code);
2506 WSH_DEBUG_SV.log(l_module_name, 'Input Table count', p_rec_attr_tab.count);
2507 END IF;
2508 --
2509 -- Initialize message list if p_init_msg_list is set to TRUE.
2510 --
2511 IF FND_API.to_Boolean( p_init_msg_list )
2512 THEN
2513 FND_MSG_PUB.initialize;
2514 ELSE
2515 IF nvl(l_check_dcp, -99) IN (1,2) THEN
2516 WSH_DCP_PVT.G_INIT_MSG_COUNT := fnd_msg_pub.count_msg;
2517 END IF;
2518 END IF;
2519 --
2520 -- Initialize API return status to success
2521 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2522 l_number_of_errors := 0;
2523 l_number_of_warnings := 0;
2524
2525 -- deliveryMerge
2526 l_delivery_ids.delete;
2527
2528 -- Mandatory parameters check
2529 IF( p_action_prms.caller IS NULL) THEN
2530 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
2531 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CALLER');
2532 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2533 IF l_debug_on THEN
2534 wsh_debug_sv.logmsg(l_module_name,'Null Caller');
2535 END IF;
2536 RAISE FND_API.G_EXC_ERROR;
2537 ELSIF(p_action_prms.action_code IS NULL) THEN
2538 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
2539 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'ACTION_CODE');
2540 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2541 IF l_debug_on THEN
2542 wsh_debug_sv.logmsg(l_module_name,'WSH_INVALID_ACTION_CODE');
2543 END IF;
2544 RAISE FND_API.G_EXC_ERROR;
2545 END IF;
2546
2547 IF(p_rec_attr_tab.count = 0) THEN
2548 IF l_debug_on THEN
2549 wsh_debug_sv.logmsg(l_module_name,'Table count zero');
2550 END IF;
2551 RAISE FND_API.G_EXC_ERROR;
2552 END IF;
2553 --
2554 -- bug 2788946
2555 -- This condition is added so that we treat these actions
2556 -- as equivalent to "PICK-RELEASE" ONLY during
2557 -- setting the levels and validating the eligibility of the action
2558 IF p_action_prms.action_code IN ('PICK-SHIP', 'PICK-PACK-SHIP') THEN
2559 l_action_code := 'PICK-RELEASE';
2560 ELSE
2561 l_action_code := p_action_prms.action_code;
2562 END IF;
2563 --
2564 --
2565 -- J-IB-NPARIKH-{
2566 --
2567 IF l_action_code = 'SPLIT_DELIVERY'
2568 THEN
2569 --{
2570 l_action_prms := p_action_prms;
2571 --
2572 l_action_prms.caller := p_action_prms.caller || WSH_UTIL_CORE.C_SPLIT_DLVY_SUFFIX;
2573 l_action_prms.action_code := 'UNASSIGN';
2574 --
2575 Delivery_Detail_Action
2576 (
2577 p_api_version_number => p_api_version_number,
2578 p_init_msg_list => FND_API.G_FALSE,
2579 p_commit => FND_API.G_FALSE,
2580 x_return_status => l_return_status,
2581 x_msg_count => l_msg_count,
2582 x_msg_data => l_msg_data,
2583 p_rec_attr_tab => p_rec_attr_tab,
2584 p_action_prms => l_action_prms,
2585 x_defaults => x_defaults,
2586 x_action_out_rec => x_action_out_rec
2587 );
2588 --
2589 --
2590 wsh_util_core.api_post_call
2591 (
2592 p_return_status => l_return_status,
2593 x_num_warnings => l_number_of_warnings,
2594 x_num_errors => l_number_of_errors,
2595 p_msg_data => l_msg_data
2596 );
2597 --
2598 --
2599 l_action_prms.caller := p_action_prms.caller || WSH_UTIL_CORE.C_SPLIT_DLVY_SUFFIX;
2600 --
2601 --
2602 IF p_action_prms.delivery_id IS NULL
2603 AND p_action_prms.delivery_name IS NULL
2604 THEN
2605 l_action_prms.action_code := 'AUTOCREATE-DEL';
2606 ELSE
2607 l_action_prms.action_code := 'ASSIGN';
2608 END IF;
2609 --
2610 Delivery_Detail_Action
2611 (
2612 p_api_version_number => p_api_version_number,
2613 p_init_msg_list => FND_API.G_FALSE,
2614 p_commit => FND_API.G_FALSE,
2615 x_return_status => l_return_status,
2616 x_msg_count => l_msg_count,
2617 x_msg_data => l_msg_data,
2618 p_rec_attr_tab => p_rec_attr_tab,
2619 p_action_prms => l_action_prms,
2620 x_defaults => x_defaults,
2621 x_action_out_rec => x_action_out_rec
2622 );
2623 --
2624 --
2625 wsh_util_core.api_post_call
2626 (
2627 p_return_status => l_return_status,
2628 x_num_warnings => l_number_of_warnings,
2629 x_num_errors => l_number_of_errors,
2630 p_msg_data => l_msg_data
2631 );
2632 --
2633 RAISE e_end_of_api;
2634 --}
2635 END IF;
2636 --
2637 -- J-IB-NPARIKH-}
2638 --
2639 --
2640 --
2641 -- Set validation level
2642 IF l_debug_on THEN
2643 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ACTIONS_LEVELS.SET_VALIDATION_LEVEL',WSH_DEBUG_SV.C_PROC_LEVEL);
2644 WSH_DEBUG_SV.log(l_module_name,'l_action_code',l_action_code);
2645 END IF;
2646 --
2647 wsh_actions_levels.set_validation_level(
2648 p_entity => 'DLVB',
2649 p_caller => p_action_prms.caller,
2650 p_phase => nvl(p_action_prms.phase,1),
2651 p_action => l_action_code,
2652 x_return_status => l_return_status
2653 );
2654
2655 --
2656 IF l_debug_on THEN
2657 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2658 END IF;
2659 --
2660 wsh_util_core.api_post_call(
2661 p_return_status => l_return_status,
2662 x_num_warnings => l_number_of_warnings,
2663 x_num_errors => l_number_of_errors,
2664 p_msg_data => l_msg_data
2665 );
2666
2667 l_validation_level_tab := wsh_actions_levels.g_validation_level_tab;
2668
2669 -- Need to create l_detail_rec_tab to call Is_Action_Enabled
2670
2671 l_index := p_rec_attr_tab.FIRST;
2672 while l_index is not null
2673 loop
2674
2675 IF NVL(p_action_prms.phase,1) = 1 THEN
2676 l_detail_rec_tab(l_index).delivery_detail_id := p_rec_attr_tab(l_index).delivery_detail_id;
2677 l_detail_rec_tab(l_index).organization_id := p_rec_attr_tab(l_index).organization_id;
2678 l_detail_rec_tab(l_index).released_status := p_rec_attr_tab(l_index).released_status;
2679 l_detail_rec_tab(l_index).container_flag := p_rec_attr_tab(l_index).container_flag;
2680 l_detail_rec_tab(l_index).source_code := p_rec_attr_tab(l_index).source_code;
2681 l_detail_rec_tab(l_index).lpn_id := p_rec_attr_tab(l_index).lpn_id;
2682 -- J Inbound Logistics: need to populate line_direction,sf_locn_id before calling Is_Action_Enabled
2683 l_detail_rec_tab(l_index).line_direction := p_rec_attr_tab(l_index).line_direction;
2684 -- J-IB-NPARIKH
2685 --
2686 -- Populate ship from location from database
2687 -- so that it can be utlized to validate if actions
2688 -- are enabled/disabled.
2689 --
2690 l_detail_rec_tab(l_index).ship_from_location_id := p_rec_attr_tab(l_index).ship_from_location_id;
2691
2692 -- R12, X-dock
2693 l_detail_rec_tab(l_index).move_order_line_id := p_rec_attr_tab(l_index).move_order_line_id;
2694
2695 END IF;
2696 l_id_tab(l_index) := p_rec_attr_tab(l_index).delivery_detail_id;
2697 l_index := p_rec_attr_tab.NEXT(l_index);
2698 END LOOP;
2699
2700
2701 -- Call Is_Action_Enabled API depending on validation level
2702 IF l_validation_level_tab(wsh_actions_levels.C_ACTION_ENABLED_LVL) = 1 THEN
2703 --
2704 IF l_debug_on THEN
2705 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.IS_ACTION_ENABLED',WSH_DEBUG_SV.C_PROC_LEVEL);
2706 END IF;
2707 --
2708 WSH_DETAILS_VALIDATIONS.Is_Action_Enabled(
2709 p_del_detail_rec_tab => l_detail_rec_tab,
2710 p_action => l_action_code,
2711 p_caller => p_action_prms.caller,
2712 p_deliveryid => p_action_prms.delivery_id,
2713 x_return_status => l_return_status,
2714 x_valid_ids => l_valid_ids,
2715 x_error_ids => l_error_ids,
2716 x_valid_index_tab => l_valid_index_tab
2717 );
2718
2719 IF l_debug_on THEN
2720 wsh_debug_sv.log(l_module_name,'Is_Action_Enabled returns',
2721 l_return_status);
2722 END IF;
2723 --
2724 wsh_util_core.api_post_call(
2725 p_return_status => l_return_status,
2726 x_num_warnings => l_number_of_warnings,
2727 x_num_errors => l_number_of_errors,
2728 p_msg_data => l_msg_data,
2729 p_raise_error_flag => FALSE
2730 );
2731 END IF;
2732
2733 IF(l_number_of_errors >0 ) THEN
2734 --{
2735 IF p_action_prms.caller = 'WSH_FSTRX' THEN
2736 FND_MESSAGE.SET_NAME('WSH', 'WSH_DISABLE_ACTION');
2737 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2738 END IF;
2739 --
2740 IF l_debug_on THEN
2741 wsh_debug_sv.logmsg(l_module_name, 'WSH_DISABLE_ACTION');
2742 END IF;
2743 --
2744 raise FND_API.G_EXC_ERROR;
2745 --}
2746 END IF;
2747
2748 IF( l_validation_level_tab(wsh_actions_levels.C_DLVY_ACTION_ENABLED_LVL) = 1) THEN
2749
2750 --
2751 IF(p_action_prms.delivery_id IS NOT NULL) THEN
2752
2753 OPEN del_cur(p_action_prms.delivery_id);
2754 FETCH del_cur INTO l_dlvy_organization_id, l_dlvy_status_code,
2755 l_dlvy_planned_flag,
2756 l_dlvy_shipment_direction,
2757 l_dlvy_ignore, -- OTM R12 : WSHDEVLS
2758 l_tms_interface_flag; -- OTM R12 : WSHDEVLS
2759
2760 IF del_cur%NOTFOUND THEN
2761 CLOSE del_cur;
2762 FND_MESSAGE.SET_NAME('WSH', 'WSH_INVALID_DELIVERY');
2763 FND_MESSAGE.SET_TOKEN('DELIVERY', p_action_prms.delivery_id);
2764 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2765 IF l_debug_on THEN
2766 wsh_debug_sv.logmsg(l_module_name, 'Delivery does not exist');
2767 END IF;
2768 RAISE FND_API.G_EXC_ERROR;
2769 END IF;
2770 CLOSE del_cur;
2771 ELSE
2772 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
2773 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'DELIVERY_ID');
2774 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2775 IF l_debug_on THEN
2776 wsh_debug_sv.logmsg(l_module_name, 'Null Delivery Id');
2777 END IF;
2778 RAISE FND_API.G_EXC_ERROR;
2779 END IF;
2780
2781 l_dlvy_rec_tab(1).delivery_id := p_action_prms.delivery_id;
2782 l_dlvy_rec_tab(1).organization_id := l_dlvy_organization_id;
2783 l_dlvy_rec_tab(1).status_code := l_dlvy_status_code;
2784 l_dlvy_rec_tab(1).planned_flag := l_dlvy_planned_flag;
2785 -- J Inbound jckwok
2786 l_dlvy_rec_tab(1).shipment_direction := l_dlvy_shipment_direction;
2787 -- call dlvy's action enabled.
2788
2789 -- OTM R12 : due to record changes in WSHDEVLS
2790 l_dlvy_rec_tab(1).ignore_for_planning := l_dlvy_ignore;
2791 l_dlvy_rec_tab(1).tms_interface_flag := l_tms_interface_flag;
2792 -- End of OTM R12 : due to record changes in WSHDEVLS
2793
2794 --
2795
2796 IF l_debug_on THEN
2797 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_VALIDATIONS.IS_ACTION_ENABLED',WSH_DEBUG_SV.C_PROC_LEVEL);
2798 END IF;
2799 --
2800 wsh_delivery_validations.Is_Action_Enabled(
2801 p_dlvy_rec_tab => l_dlvy_rec_tab,
2802 p_action => p_action_prms.action_code,
2803 p_caller => p_action_prms.caller,
2804 x_return_status => l_return_status,
2805 x_valid_ids => l_valid_ids,
2806 x_error_ids => l_error_ids,
2807 x_valid_index_tab => l_valid_index_tab
2808 );
2809 --
2810 wsh_util_core.api_post_call(
2811 p_return_status => l_return_status,
2812 x_num_warnings => l_number_of_warnings,
2813 x_num_errors => l_number_of_errors,
2814 p_msg_data => l_msg_data,
2815 p_raise_error_flag => FALSE
2816 );
2817
2818 IF p_action_prms.caller = 'WSH_FSTRX' THEN
2819 x_action_out_rec.valid_id_tab := l_valid_index_tab;
2820 ELSE
2821 x_action_out_rec.valid_id_tab := l_valid_ids;
2822 END IF;
2823 --
2824 END IF;
2825
2826 -- Lock records
2827 IF l_validation_level_tab(wsh_actions_levels.C_LOCK_RECORDS_LVL) = 1 THEN
2828
2829 -- we need to send only the valid records to lock procedure
2830 -- Build the table using the valid index output from Is_Action_Enabled
2831 IF l_debug_on THEN
2832 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.LOCK_DELIVERY_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
2833 END IF;
2834 IF NOT ( p_action_prms.caller = 'WSH_FSTRX'
2835 AND p_action_prms.action_code = 'DELETE'
2836 ) THEN --BUG 4354579
2837 wsh_delivery_details_pkg.Lock_Delivery_Details(
2838 p_rec_attr_tab => p_rec_attr_tab,
2839 p_caller => p_action_prms.caller,
2840 p_valid_index_tab => l_valid_index_tab,
2841 x_valid_ids_tab => l_valid_ids_tab,
2842 x_return_status => l_return_status
2843 );
2844
2845 x_action_out_rec.valid_id_tab := l_valid_ids_tab;
2846
2847 --
2848 wsh_util_core.api_post_call(
2849 p_return_status => l_return_status,
2850 x_num_warnings => l_number_of_warnings,
2851 x_num_errors => l_number_of_errors,
2852 p_msg_data => l_msg_data,
2853 p_raise_error_flag => FALSE
2854 );
2855 END IF;
2856 END IF;
2857
2858 --
2859 IF(l_number_of_errors >0 ) THEN
2860 FND_MESSAGE.SET_NAME('WSH', 'WSH_DISABLE_ACTION');
2861 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2862 IF l_debug_on THEN
2863 wsh_debug_sv.logmsg(l_module_name, 'WSH_DISABLE_ACTION');
2864 END IF;
2865 RAISE FND_API.G_EXC_ERROR;
2866 END IF;
2867 --
2868 IF l_number_of_warnings > 0 THEN
2869
2870 FND_MESSAGE.SET_NAME('WSH', 'WSH_DISABLE_ACTION_WARN');
2871 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
2872 IF l_debug_on THEN
2873 wsh_debug_sv.logmsg(l_module_name, 'WSH_DISABLE_ACTION_WARN');
2874 END IF;
2875
2876 IF(p_action_prms.caller = 'WSH_FSTRX') THEN
2877 x_action_out_rec.selection_issue_flag := 'Y';
2878 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
2879 ELSE
2880 IF l_debug_on THEN
2881 wsh_debug_sv.log(l_module_name,'Number of warnings', l_number_of_warnings);
2882 END IF;
2883 RAISE FND_API.G_EXC_ERROR;
2884 END IF;
2885 END IF;
2886
2887
2888 IF l_validation_level_tab(wsh_actions_levels.C_VALIDATE_CONSTRAINTS_LVL) = 1
2889 THEN --{
2890
2891 --Compatibility Changes
2892 -- Autocreate trip calls autocreate del and then autocreate trip so the constraint validation
2893 -- will be done at that point (in private API)
2894 -- actions PACK, AUTO-PACK, AUTO-PACK-MASTER only post-I (constraints for these have not been implemented yet)
2895
2896 IF wsh_util_core.fte_is_installed = 'Y' THEN
2897
2898 WSH_FTE_COMP_CONSTRAINT_PKG.validate_constraint_main(
2899 p_api_version_number => 1.0,
2900 p_init_msg_list => FND_API.G_FALSE,
2901 p_entity_type => 'L',
2902 p_target_id => p_action_prms.DELIVERY_ID,
2903 p_action_code => p_action_prms.action_code,
2904 p_del_attr_tab => l_cc_del_attr_tab,
2905 p_det_attr_tab => p_rec_attr_tab,
2906 p_trip_attr_tab => l_cc_trip_attr_tab,
2907 p_stop_attr_tab => l_cc_stop_attr_tab,
2908 p_in_ids => l_cc_in_ids,
2909 x_fail_ids => l_cc_fail_ids,
2910 x_validate_result => l_cc_validate_result,
2911 x_failed_lines => l_cc_failed_records,
2912 x_line_groups => l_cc_line_groups,
2913 x_group_info => l_cc_group_info,
2914 x_msg_count => l_msg_count,
2915 x_msg_data => l_msg_data,
2916 x_return_status => l_return_status);
2917
2918 IF l_debug_on THEN
2919 wsh_debug_sv.log(l_module_name,'Return Status After Calling validate_constraint_main',l_return_status);
2920 wsh_debug_sv.log(l_module_name,'validate_result After Calling validate_constraint_main',l_cc_validate_result);
2921 wsh_debug_sv.log(l_module_name,'msg_count After Calling validate_constraint_main',l_msg_count);
2922 wsh_debug_sv.log(l_module_name,'msg_data After Calling validate_constraint_main',l_msg_data);
2923 wsh_debug_sv.log(l_module_name,'fail_ids count After Calling validate_constraint_main',l_cc_failed_records.COUNT);
2924 wsh_debug_sv.log(l_module_name,'l_cc_line_groups.count count After Calling validate_constraint_main',l_cc_line_groups.COUNT);
2925 wsh_debug_sv.log(l_module_name,'group_info count After Calling validate_constraint_main',l_cc_group_info.COUNT);
2926 END IF;
2927 --
2928
2929 IF l_return_status=wsh_util_core.g_ret_sts_error THEN
2930 --fix p_rec_attr_tab to have only successful records
2931 l_cc_count_success:=1;
2932
2933 IF l_debug_on THEN
2934 wsh_debug_sv.log(l_module_name,'p_rec_attr_tab count before removing failed lines',p_rec_attr_tab.COUNT);
2935 END IF;
2936
2937 IF l_cc_failed_records.COUNT>0 AND p_rec_attr_tab.COUNT>0 THEN
2938
2939 --set return_status as warning
2940 IF l_cc_failed_records.COUNT<>p_rec_attr_tab.COUNT THEN
2941 l_return_status:=wsh_util_core.g_ret_sts_warning;
2942 END IF;
2943
2944 FOR i in p_rec_attr_tab.FIRST..p_rec_attr_tab.LAST LOOP
2945 b_cc_linefailed:=FALSE;
2946 FOR j in l_cc_failed_records.FIRST..l_cc_failed_records.LAST LOOP
2947 IF (p_rec_attr_tab(i).delivery_detail_id=l_cc_failed_records(j).entity_line_id) THEN
2948 b_cc_linefailed:=TRUE;
2949 FND_MESSAGE.SET_NAME('WSH','WSH_DELDET_COMP_FAILED');
2950 FND_MESSAGE.SET_TOKEN('DELDET_ID',l_cc_failed_records(j).entity_line_id);
2951 wsh_util_core.add_message(l_return_status);
2952 END IF;
2953 END LOOP;
2954 IF (NOT(b_cc_linefailed)) THEN
2955 l_id_tab_t(l_cc_count_success):=p_rec_attr_tab(i).delivery_detail_id;
2956 l_cc_count_success:=l_cc_count_success+1;
2957 END IF;
2958 END LOOP;
2959
2960 --bsadri for assign, if one line fails, then fail all lines {
2961 IF l_action_code = 'ASSIGN'
2962 AND l_cc_failed_records.COUNT > 0 THEN
2963 l_id_tab_t.DELETE;
2964 l_return_status := wsh_util_core.g_ret_sts_error;
2965 END IF;
2966 --}
2967
2968 IF l_id_tab_t.COUNT>0 THEN
2969 l_id_tab:=l_id_tab_t;
2970 ELSE
2971 IF l_debug_on THEN
2972 wsh_debug_sv.logmsg(l_module_name,'all lines errored in compatibility check');
2973 END IF;
2974 wsh_util_core.api_post_call(
2975 p_return_status => l_return_status,
2976 x_num_warnings => l_number_of_warnings,
2977 x_num_errors => l_num_errors,
2978 p_msg_data => l_msg_data);
2979 END IF;
2980
2981 IF l_debug_on THEN
2982 wsh_debug_sv.log(l_module_name,'l_id_tab count after removing failed lines',l_id_tab.COUNT);
2983 END IF;
2984
2985 END IF;
2986
2987 ELSIF l_return_status=wsh_util_core.g_ret_sts_unexp_error THEN
2988 wsh_util_core.api_post_call(
2989 p_return_status => l_return_status,
2990 x_num_warnings => l_number_of_warnings,
2991 x_num_errors => l_num_errors,
2992 p_msg_data => l_msg_data);
2993 END IF;
2994
2995 wsh_util_core.api_post_call(
2996 p_return_status => l_return_status,
2997 x_num_warnings => l_number_of_warnings,
2998 x_num_errors => l_num_errors,
2999 p_msg_data => l_msg_data,
3000 p_raise_error_flag => FALSE);
3001
3002 END IF;
3003 --Compatibility Changes
3004 END IF; --}
3005
3006
3007
3008
3009 -- HW OPM BUG#:2677054
3010 -- Need this part to be used by form and public API
3011 IF ( nvl(p_action_prms.phase,1) = 1 ) AND (p_action_prms.action_code ='SPLIT-LINE' ) THEN
3012
3013 OPEN det_cur(l_id_tab(l_id_tab.first));
3014 FETCH det_cur
3015 INTO l_inv_item_id
3016 , l_organization_id
3017 , l_requested_quantity_uom
3018 , l_line_direction
3019 , l_released_status
3020 ;
3021 CLOSE det_cur;
3022
3023 -- Check for if line belongs to OPM
3024 -- HW OPMCONV - Removed checking for process
3025 IF (l_line_direction IN ('O','IO') -- J-IB-NPARIKH
3026 ) THEN
3027 -- Check if line is allocated , check is required only for outbound lines
3028 -- HW OPMCONV - Removed call to old OPM API is_line_allocated
3029 -- and replaced it with is_split_allowed
3030
3031 -- Check if split is allowed
3032 -- HW OPMCONV - New WSH API to check if split is allowed
3033 l_delivery_detail_id := l_id_tab(l_id_tab.first);
3034
3035 IF (NOT WSH_DETAILS_VALIDATIONS.is_split_allowed
3036 ( p_delivery_detail_id => l_delivery_detail_id,
3037 p_organization_id => l_organization_id,
3038 p_inventory_item_id => l_inv_item_id,
3039 p_released_status => l_released_status)
3040 ) THEN
3041 FND_MESSAGE.SET_NAME('WSH', 'WSH_OPM_LOT_INDIVISIBLE');
3042 IF p_action_prms.caller = 'WSH_FSTRX' THEN
3043 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3044 END IF;
3045 RAISE FND_API.G_EXC_ERROR;
3046 END IF;
3047 END IF;
3048
3049 -- If caller is form, return. We are done
3050 IF(p_action_prms.caller = 'WSH_FSTRX') THEN
3051 --Change made during Bugfix 4070732
3052 --Raise end of api so that handling of return status, reset flags are done there
3053 RAISE e_end_of_api;
3054 END IF;
3055
3056 END IF;
3057
3058
3059 IF(p_action_prms.caller = 'WSH_FSTRX' AND nvl(p_action_prms.phase,1) = 1 )AND
3060 (p_action_prms.action_code ='PACK') THEN
3061 --Change made during Bugfix 4070732
3062 --Raise end of api so that handling of return status, reset flags are done there
3063 RAISE e_end_of_api;
3064 END IF;
3065 -- HW end of BUG#:2677054
3066
3067 IF p_action_prms.action_code IN('SPLIT-LINE', 'CYCLE-COUNT', 'PICK-RELEASE-UI', 'RESOLVE-EXCEPTIONS-UI') THEN
3068 IF(p_rec_attr_tab.count > 1) THEN
3069 FND_MESSAGE.SET_NAME('WSH','WSH_UI_MULTI_SELECTION');
3070 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3071 IF l_debug_on THEN
3072 wsh_debug_sv.logmsg(l_module_name,'WSH_UI_MULTI_SELECTION');
3073 END IF;
3074 RAISE FND_API.G_EXC_ERROR;
3075 END IF;
3076 END IF;
3077
3078 IF l_debug_on THEN
3079 wsh_debug_sv.log(l_module_name, 'Id Tab Count', l_id_tab.count);
3080 END IF;
3081
3082 IF p_action_prms.action_code IN('ASSIGN', 'UNASSIGN') THEN
3083
3084 IF(p_action_prms.action_code = 'ASSIGN' AND nvl(p_action_prms.phase,1) = 1) THEN
3085 IF l_debug_on THEN
3086 WSH_DEBUG_SV.log(l_module_name, 'Delivery Id', p_action_prms.delivery_id);
3087 WSH_DEBUG_SV.log(l_module_name, 'Delivery Name', p_action_prms.delivery_name);
3088 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_ASSIGN_DEL_MULTI',WSH_DEBUG_SV.C_PROC_LEVEL);
3089 END IF;
3090
3091 wsh_details_validations.check_assign_del_multi(
3092 p_detail_rows => l_id_tab,
3093 x_del_params => l_detail_group_params,
3094 x_return_status => l_return_status);
3095
3096 IF l_debug_on THEN
3097 WSH_DEBUG_SV.log(l_module_name, 'return status after calling check_assign_del_multi', l_return_status);
3098 WSH_DEBUG_SV.log(l_module_name, 'group id', l_detail_group_params.group_id);
3099 END IF;
3100 wsh_util_core.api_post_call(
3101 p_return_status => l_return_status,
3102 x_num_warnings => l_number_of_warnings,
3103 x_num_errors => l_number_of_errors,
3104 p_msg_data => l_msg_data
3105 );
3106
3107 IF p_action_prms.caller = 'WSH_FSTRX' THEN
3108 x_defaults.detail_group_params := l_detail_group_params;
3109 l_attr_tab(1) := l_detail_group_params;
3110 l_attr_tab(1).entity_type := 'DELIVERY_DETAIL';
3111
3112 l_target_rec.entity_type := 'DELIVERY';
3113 l_action_rec.output_format_type := 'TEMP_TAB';
3114 l_action_rec.action := 'MATCH_GROUPS';
3115
3116
3117 wsh_delivery_autocreate.Find_Matching_Groups(
3118 p_attr_tab => l_attr_tab,
3119 p_action_rec => l_action_rec,
3120 p_target_rec => l_target_rec,
3121 p_group_tab => l_group_info,
3122 x_matched_entities => l_matched_entities,
3123 x_out_rec => l_out_rec,
3124 x_return_status => l_return_status);
3125
3126 wsh_util_core.api_post_call(
3127 p_return_status => l_return_status,
3128 x_num_warnings => l_number_of_warnings,
3129 x_num_errors => l_number_of_errors,
3130 p_msg_data => l_msg_data
3131 );
3132
3133 --Change made during Bugfix 4070732
3134 --Raise end of api so that handling of return status, reset flags are done there
3135 RAISE e_end_of_api;
3136 END IF;
3137 END IF; -- if check for phase
3138
3139 /*Since the existing procedure Detail_To_Delivery has its own id_tab_type, need to map the id tab */
3140 l_index := l_id_tab.FIRST;
3141 WHILE l_index IS NOT NULL LOOP
3142 l_det_id_tab(l_index) := l_id_tab(l_index);
3143 l_index := l_id_tab.NEXT(l_index);
3144 END LOOP;
3145 --
3146 IF l_debug_on THEN
3147 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_GRP.DETAIL_TO_DELIVERY',WSH_DEBUG_SV.C_PROC_LEVEL);
3148 END IF;
3149 --
3150 WSH_DELIVERY_DETAILS_GRP.detail_to_delivery(
3151 p_api_version => l_api_version,
3152 p_init_msg_list => FND_API.G_FALSE,
3153 p_commit => FND_API.G_FALSE,
3154 p_validation_level => l_validation_level,
3155 x_return_status => l_return_status,
3156 x_msg_count => l_msg_count,
3157 x_msg_data => l_msg_data,
3158 p_TabOfDelDets => l_det_id_tab,
3159 p_action => p_action_prms.action_code,
3160 p_delivery_id => p_action_prms.delivery_id,
3161 p_delivery_name => p_action_prms.delivery_name,
3162 p_action_prms => p_action_prms);
3163
3164
3165 --
3166 wsh_util_core.api_post_call(
3167 p_return_status => l_return_status,
3168 x_num_warnings => l_number_of_warnings,
3169 x_num_errors => l_number_of_errors,
3170 p_msg_data => l_msg_data
3171 );
3172
3173 IF (l_return_status in (WSH_UTIL_CORE.G_RET_STS_SUCCESS, WSH_UTIL_CORE.G_RET_STS_WARNING)
3174 AND p_action_prms.action_code = 'ASSIGN' ) THEN
3175 IF l_debug_on THEN
3176 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_NEW_DELIVERY_ACTIONS.ASSIGN_DELIVERY_UPDATE',WSH_DEBUG_SV.C_PROC_LEVEL);
3177 END IF;
3178
3179 wsh_new_delivery_actions.assign_delivery_update(
3180 p_delivery_id => p_action_prms.delivery_id,
3181 p_del_params => l_detail_group_params,
3182 x_return_status => l_return_status);
3183
3184 wsh_util_core.api_post_call(
3185 p_return_status => l_return_status,
3186 x_num_warnings => l_number_of_warnings,
3187 x_num_errors => l_number_of_errors,
3188 p_msg_data => l_msg_data
3189 );
3190
3191 -- deliveryMerge
3192 -- populate x_action_out_rec.result_id_tab with
3193 -- assigned delivery details
3194 x_action_out_rec.result_id_tab := l_det_id_tab ;
3195 END IF;
3196
3197 --
3198 ELSIF p_action_prms.action_code = 'SPLIT-LINE' THEN
3199 --
3200 --
3201 IF(nvl(p_action_prms.split_quantity,0) =0) THEN
3202 FND_MESSAGE.SET_NAME('WSH', 'WSH_NO_ZERO_NUM');
3203 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3204 IF l_debug_on THEN
3205 wsh_debug_sv.logmsg(l_module_name,'Zero or Null split quantity');
3206 END IF;
3207 RAISE FND_API.G_EXC_ERROR;
3208 END IF;
3209
3210 --
3211 IF l_debug_on THEN
3212 wsh_debug_sv.log(l_module_name, 'Split Quantity', p_action_prms.split_quantity);
3213 END IF;
3214
3215 l_split_quantity := p_action_prms.split_quantity;
3216 l_split_quantity2 := p_action_prms.split_quantity2;
3217 --
3218 --
3219 -- HW Harmonization project for OPM .Need to add converted_flag for OPM
3220 -- Need to check if caller is from STF or not. If call from STF, make l_converted_quantity ='Y'
3221
3222 -- HW OPMCONV - 1) Changed name of cursor
3223 -- - 2) Fetch requested_uom2
3224 OPEN det_line(l_id_tab(l_id_tab.first));
3225 FETCH det_line INTO l_line_direction,l_requested_quantity_uom2;
3226 CLOSE det_line;
3227
3228 -- HW OPMCONV - 1) No need to check for process_org
3229 -- - 2) check for value of UOM2 before calling the validation
3230 IF ( l_requested_quantity_uom2 IS NOT NULL
3231 AND l_requested_quantity_uom2 <> FND_API.G_MISS_CHAR) THEN
3232
3233 --{
3234 IF l_debug_on THEN
3235 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.validate_secondary_quantity',WSH_DEBUG_SV.C_PROC_LEVEL);
3236 END IF;
3237 --
3238 -- J-IB-NPARIKH-{
3239 --
3240 -- HW OPMCONV - Added p_caller to validate_secondary_quantity
3241 -- Check that secondary quantity is within tolerance of primary quantity
3242 --
3243 IF l_inventory_item_id is not null
3244 AND ( p_action_prms.caller like 'FTE%' or l_line_direction not in ('IO','O') )
3245 THEN
3246 --{
3247 WSH_DETAILS_VALIDATIONS.validate_secondary_quantity
3248 (
3249 p_delivery_detail_id => l_id_tab(l_id_tab.first),
3250 x_quantity => l_split_quantity,
3251 x_quantity2 => l_split_quantity2,
3252 p_caller => p_action_prms.caller,
3253 x_return_status => l_return_status,
3254 x_msg_count => l_msg_count,
3255 x_msg_data => l_msg_data
3256 );
3257 --
3258 wsh_util_core.api_post_call(
3259 p_return_status => l_return_status,
3260 x_num_warnings => l_number_of_warnings,
3261 x_num_errors => l_number_of_errors,
3262 p_msg_data => l_msg_data
3263 );
3264 --
3265 l_converted_flag := 'Y';
3266 --}
3267 -- J-IB-NPARIKH-}
3268 ELSIF(p_action_prms.caller = 'WSH_FSTRX' AND p_action_prms.phase = 2 )
3269 THEN
3270 l_converted_flag := 'Y';
3271 ELSE
3272 l_converted_flag := NULL;
3273 END IF;
3274 --}
3275
3276 END IF; -- of UOM2
3277
3278 -- HW Harmonization project forOPM. Added p_manual_split parameter
3279 -- HW added p_converted_flag
3280 IF l_debug_on THEN
3281 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_GRP.SPLIT_LINE',WSH_DEBUG_SV.C_PROC_LEVEL);
3282 END IF;
3283 WSH_DELIVERY_DETAILS_GRP.split_line(
3284 p_api_version => l_api_version,
3285 p_init_msg_list => FND_API.G_FALSE,
3286 p_commit => FND_API.G_FALSE,
3287 p_validation_level => l_validation_level,
3288 x_return_status => l_return_status,
3289 x_msg_count => l_msg_count,
3290 x_msg_data => l_msg_data,
3291 p_from_detail_id => l_id_tab(l_id_tab.first),
3292 x_new_detail_id => x_action_out_rec.result_id_tab(1),
3293 x_split_quantity => l_split_quantity,
3294 x_split_quantity2 => l_split_quantity2,
3295 p_manual_split => l_manual_split,
3296 p_converted_flag => l_converted_flag);
3297
3298 x_action_out_rec.split_quantity := l_split_quantity;
3299 x_action_out_rec.split_quantity2 := l_split_quantity2;
3300
3301 --
3302 wsh_util_core.api_post_call(
3303 p_return_status => l_return_status,
3304 x_num_warnings => l_number_of_warnings,
3305 x_num_errors => l_number_of_errors,
3306 p_msg_data => l_msg_data
3307 );
3308
3309 --
3310 ELSIF p_action_prms.action_code = 'AUTOCREATE-DEL' THEN
3311 --
3312 IF l_debug_on THEN
3313 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_GRP.AUTOCREATE_DELIVERIES',WSH_DEBUG_SV.C_PROC_LEVEL);
3314 END IF;
3315 --
3316 --Compatibility Changes
3317 IF wsh_util_core.fte_is_installed = 'Y' AND l_cc_line_groups.COUNT>0 THEN
3318
3319 --1. get the group ids by which the constraints API has grouped the lines
3320 l_cc_count_group_ids:=1;
3321 FOR i in l_cc_line_groups.FIRST..l_cc_line_groups.LAST LOOP
3322 b_cc_groupidexists:=FALSE;
3323
3324 IF l_cc_group_ids.COUNT>0 THEN
3325 FOR j in l_cc_group_ids.FIRST..l_cc_group_ids.LAST LOOP
3326 IF (l_cc_line_groups(i).line_group_id=l_cc_group_ids(j)) THEN
3327 b_cc_groupidexists:=TRUE;
3328 END IF;
3329 END LOOP;
3330 END IF;
3331 IF (NOT(b_cc_groupidexists)) THEN
3332 l_cc_group_ids(l_cc_count_group_ids):=l_cc_line_groups(i).line_group_id;
3333 l_cc_count_group_ids:=l_cc_count_group_ids+1;
3334 END IF;
3335 END LOOP;
3336
3337 --2. from the group id table above, loop thru lines table to get the lines which belong
3338 --to each group and call autocreate_del for each group
3339 FOR i in l_cc_group_ids.FIRST..l_cc_group_ids.LAST LOOP
3340 l_cc_count_rec:=1;
3341 FOR j in l_cc_line_groups.FIRST..l_cc_line_groups.LAST LOOP
3342 IF l_cc_line_groups(j).line_group_id=l_cc_group_ids(i) THEN
3343 l_id_tab_temp(l_cc_count_rec):=l_cc_line_groups(j).entity_line_id;
3344 l_cc_count_rec:=l_cc_count_rec+1;
3345 END IF;
3346 END LOOP;
3347
3348 IF l_debug_on THEN
3349 wsh_debug_sv.log(l_module_name,'id_tab_temp count ',l_id_tab_temp.COUNT);
3350 END IF;
3351
3352 WSH_DELIVERY_DETAILS_GRP.Autocreate_Deliveries(
3353 p_api_version_number => l_api_version,
3354 p_init_msg_list => FND_API.G_FALSE,
3355 p_commit => FND_API.G_FALSE,
3356 p_caller => p_action_prms.caller,
3357 x_return_status => l_return_status ,
3358 x_msg_count => l_msg_count,
3359 x_msg_data => l_msg_data,
3360 p_line_rows => l_id_tab_temp,
3361 p_group_by_header_flag => p_action_prms.group_by_header_flag,
3362 x_del_rows => x_action_out_rec.delivery_id_tab);
3363
3364
3365 --set the intermediate ship to, ship method to null if group rec from constraint validation has these as 'N'
3366 l_cc_upd_dlvy_intmed_ship_to:='Y';
3367 l_cc_upd_dlvy_ship_method:='Y';
3368 IF l_cc_group_info.COUNT>0 THEN
3369 FOR j in l_cc_group_info.FIRST..l_cc_group_info.LAST LOOP
3370 IF l_cc_group_info(j).line_group_id=l_cc_group_ids(i) THEN
3371 l_cc_upd_dlvy_intmed_ship_to:=l_cc_group_info(j).upd_dlvy_intmed_ship_to;
3372 l_cc_upd_dlvy_ship_method:=l_cc_group_info(j).upd_dlvy_ship_method;
3373 END IF;
3374 END LOOP;
3375 END IF;
3376
3377 IF l_debug_on THEN
3378 wsh_debug_sv.log(l_module_name,'l_cc_upd_dlvy_intmed_ship_to ',l_cc_upd_dlvy_intmed_ship_to);
3379 wsh_debug_sv.log(l_module_name,'l_cc_upd_dlvy_ship_method ',l_cc_upd_dlvy_ship_method);
3380 wsh_debug_sv.log(l_module_name,'x_action_out_rec.delivery_id_tab.COUNT ',x_action_out_rec.delivery_id_tab.COUNT);
3381 wsh_debug_sv.log(l_module_name,'l_return_status after calling autocreate_del in comp ',l_return_status);
3382 END IF;
3383
3384 IF l_cc_upd_dlvy_intmed_ship_to='N' OR l_cc_upd_dlvy_ship_method='N' THEN
3385 IF x_action_out_rec.delivery_id_tab.COUNT>0 THEN
3386
3387 FOR i in x_action_out_rec.delivery_id_tab.FIRST..x_action_out_rec.delivery_id_tab.LAST LOOP
3388 FOR delcurtemp in c_delcur(x_action_out_rec.delivery_id_tab(i)) LOOP
3389 l_cc_dlvy_intmed_ship_to:=delcurtemp.INTMED_SHIP_TO_LOCATION_ID;
3390 l_cc_dlvy_ship_method:=delcurtemp.SHIP_METHOD_CODE;
3391 IF l_cc_upd_dlvy_intmed_ship_to='N' and l_cc_dlvy_intmed_ship_to IS NOT NULL THEN
3392 update wsh_new_deliveries set INTMED_SHIP_TO_LOCATION_ID=null
3393 where delivery_id=x_action_out_rec.delivery_id_tab(i);
3394 END IF;
3395 --IF l_cc_upd_dlvy_ship_method='N' and l_cc_dlvy_ship_method IS NOT NULL THEN
3396 IF l_cc_upd_dlvy_ship_method='N' THEN
3397
3398 -- OTM R12 : update delivery
3399 -- no code changes are needed for the following update
3400 -- since it reaches here only when FTE is installed
3401
3402 update wsh_new_deliveries
3403 set SHIP_METHOD_CODE=null,
3404 CARRIER_ID = null,
3405 MODE_OF_TRANSPORT = null,
3406 SERVICE_LEVEL = null
3407 where delivery_id=x_action_out_rec.delivery_id_tab(i);
3408 END IF;
3409 END LOOP;
3410 END LOOP;
3411 END IF;
3412 END IF;
3413 --set the intermediate ship to, ship method to null if group rec from constraint validation has these as 'N'
3414 IF l_cc_del_rows.COUNT=0 THEN
3415 l_cc_del_rows:=x_action_out_rec.delivery_id_tab;
3416 ELSE
3417 l_cc_count_del_rows:=l_cc_del_rows.COUNT;
3418 IF x_action_out_rec.delivery_id_tab.COUNT>0 THEN
3419 FOR i in x_action_out_rec.delivery_id_tab.FIRST..x_action_out_rec.delivery_id_tab.LAST LOOP
3420 l_cc_del_rows(l_cc_count_del_rows+i):=x_action_out_rec.delivery_id_tab(i);
3421 END LOOP;
3422 END IF;
3423 END IF;
3424
3425 IF (l_cc_return_status is not null AND l_cc_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR, WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)) THEN
3426 l_return_status:=l_cc_return_status;
3427 ELSIF (l_cc_return_status is not null AND l_cc_return_status=WSH_UTIL_CORE.G_RET_STS_WARNING AND l_return_status=WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
3428 l_return_status:=l_cc_return_status;
3429 ELSE
3430 l_cc_return_status:=l_return_status;
3431 END IF;
3432
3433 END LOOP;
3434 l_return_status:=l_cc_return_status;
3435 x_action_out_rec.delivery_id_tab:=l_cc_del_rows;
3436
3437 IF l_debug_on THEN
3438 wsh_debug_sv.log(l_module_name,'x_action_out_rec.delivery_id_tab.COUNT after loop ',x_action_out_rec.delivery_id_tab.COUNT);
3439 END IF;
3440
3441 ELSE
3442
3443 WSH_DELIVERY_DETAILS_GRP.Autocreate_Deliveries(
3444 p_api_version_number => l_api_version,
3445 p_init_msg_list => FND_API.G_FALSE,
3446 p_commit => FND_API.G_FALSE,
3447 p_caller => p_action_prms.caller,
3448 x_return_status => l_return_status ,
3449 x_msg_count => l_msg_count,
3450 x_msg_data => l_msg_data,
3451 p_line_rows => l_id_tab,
3452 p_group_by_header_flag => p_action_prms.group_by_header_flag,
3453 x_del_rows => x_action_out_rec.delivery_id_tab);
3454
3455 END IF;
3456 --Compatibility Changes
3457
3458 --
3459 IF l_debug_on THEN
3460 wsh_debug_sv.log(l_module_name,'Return Status After Calling Autocreate_Deliveries',l_return_status);
3461 END IF;
3462
3463 --
3464 wsh_util_core.api_post_call(
3465 p_return_status => l_return_status,
3466 x_num_warnings => l_number_of_warnings,
3467 x_num_errors => l_number_of_errors,
3468 p_msg_data => l_msg_data
3469 );
3470
3471 -- deliveryMerge
3472 wsh_new_delivery_actions.Adjust_Planned_Flag(
3473 p_delivery_ids => x_action_out_rec.delivery_id_tab,
3474 p_caller => 'WSH_DLMG',
3475 p_force_appending_limit => 'N',
3476 p_call_lcss => 'Y',
3477 x_return_status => l_return_status);
3478
3479 wsh_util_core.api_post_call(
3480 p_return_status => l_return_status,
3481 x_num_warnings => l_number_of_warnings,
3482 x_num_errors => l_number_of_errors,
3483 p_msg_data => l_msg_data
3484 );
3485 --
3486 ELSIF p_action_prms.action_code = 'AUTOCREATE-TRIP' THEN
3487 --
3488 IF l_debug_on THEN
3489 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_GRP.AUTOCREATE_DEL_TRIP',WSH_DEBUG_SV.C_PROC_LEVEL);
3490 END IF;
3491 --
3492 WSH_DELIVERY_DETAILS_GRP.Autocreate_del_trip(
3493 p_api_version_number => l_api_version,
3494 p_init_msg_list => FND_API.G_FALSE,
3495 p_commit => FND_API.G_FALSE,
3496 x_return_status => l_return_status,
3497 x_msg_count => l_msg_count,
3498 x_msg_data => l_msg_data,
3499 p_line_rows => l_id_tab,
3500 x_del_rows => x_action_out_rec.delivery_id_tab,
3501 x_trip_rows => x_action_out_rec.result_id_tab);
3502
3503 --
3504 wsh_util_core.api_post_call(
3505 p_return_status => l_return_status,
3506 x_num_warnings => l_number_of_warnings,
3507 x_num_errors => l_number_of_errors,
3508 p_msg_data => l_msg_data
3509 );
3510 --
3511 ELSIF p_action_prms.action_code in ('IGNORE_PLAN', 'INCLUDE_PLAN') then
3512 Wsh_tp_release.change_ignoreplan_status
3513 (p_entity =>'DLVB',
3514 p_in_ids => l_id_tab,
3515 p_action_code => p_action_prms.action_code,
3516 x_return_status => l_return_status);
3517 --
3518 IF l_debug_on THEN
3519 wsh_debug_sv.log(l_module_name,'Return Status After Calling change_ignoreplan_status ',l_return_status);
3520 END IF;
3521 --
3522 wsh_util_core.api_post_call(
3523 p_return_status => l_return_status,
3524 x_num_warnings => l_number_of_warnings,
3525 x_num_errors => l_number_of_errors);
3526 --
3527
3528 ELSIF p_action_prms.action_code = 'PICK-RELEASE' THEN
3529 --
3530 IF l_debug_on THEN
3531 wsh_debug_sv.log(l_module_name, 'Id Tab Count', l_id_tab.count);
3532 END IF;
3533
3534 IF l_debug_on THEN
3535 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PICK_LIST.LAUNCH_PICK_RELEASE',WSH_DEBUG_SV.C_PROC_LEVEL);
3536 END IF;
3537 --
3538
3539 wsh_pick_list.launch_pick_release(
3540 p_trip_ids => l_dummy_ids,
3541 p_stop_ids => l_dummy_ids,
3542 p_delivery_ids => l_dummy_ids,
3543 p_detail_ids => l_id_tab,
3544 p_batch_id => p_action_prms.batch_id, -- bug# 6719369 (replenishment project)
3545 x_request_ids => l_request_ids,
3546 x_return_status => l_return_status);
3547
3548 --
3549 wsh_util_core.api_post_call(
3550 p_return_status => l_return_status,
3551 x_num_warnings => l_number_of_warnings,
3552 x_num_errors => l_number_of_errors,
3553 p_msg_data => l_msg_data
3554 );
3555 --
3556 ELSIF p_action_prms.action_code = 'PICK-PACK-SHIP' THEN
3557 --
3558 IF l_debug_on THEN
3559 wsh_debug_sv.log(l_module_name, 'Id Tab Count', l_id_tab.count);
3560 END IF;
3561
3562 IF l_debug_on THEN
3563 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PICK_LIST.LAUNCH_PICK_RELEASE',WSH_DEBUG_SV.C_PROC_LEVEL);
3564 END IF;
3565 --
3566 wsh_pick_list.launch_pick_release(
3567 p_trip_ids => l_dummy_ids,
3568 p_stop_ids => l_dummy_ids,
3569 p_delivery_ids => l_dummy_ids,
3570 p_detail_ids => l_id_tab,
3571 x_request_ids => l_request_ids,
3572 x_return_status => l_return_status,
3573 p_auto_pack_ship => 'PS');
3574
3575 --
3576 wsh_util_core.api_post_call(
3577 p_return_status => l_return_status,
3578 x_num_warnings => l_number_of_warnings,
3579 x_num_errors => l_number_of_errors,
3580 p_msg_data => l_msg_data
3581 );
3582 --
3583 ELSIF p_action_prms.action_code = 'PICK-SHIP' THEN
3584 --
3585 IF l_debug_on THEN
3586 wsh_debug_sv.log(l_module_name, 'Id Tab Count', l_id_tab.count);
3587 END IF;
3588
3589 IF l_debug_on THEN
3590 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PICK_LIST.LAUNCH_PICK_RELEASE',WSH_DEBUG_SV.C_PROC_LEVEL);
3591 END IF;
3592 --
3593 wsh_pick_list.launch_pick_release(
3594 p_trip_ids => l_dummy_ids,
3595 p_stop_ids => l_dummy_ids,
3596 p_delivery_ids => l_dummy_ids,
3597 p_detail_ids => l_id_tab,
3598 x_request_ids => l_request_ids,
3599 x_return_status => l_return_status,
3600 p_auto_pack_ship => 'SC');
3601
3602 --
3603 wsh_util_core.api_post_call(
3604 p_return_status => l_return_status,
3605 x_num_warnings => l_number_of_warnings,
3606 x_num_errors => l_number_of_errors,
3607 p_msg_data => l_msg_data
3608 );
3609 --
3610 ELSIF p_action_prms.action_code = 'WT-VOL' THEN
3611 --
3612
3613 -- OTM R12 : packing ECO
3614 -- This change was introduced to mark the G_RESET_WV flag
3615 -- before calling detail_weight_volume so the procedure will know
3616 -- to invoke update tms_interface_flag process.
3617
3618 l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
3619 IF l_gc3_is_installed IS NULL THEN
3620 l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
3621 END IF;
3622
3623 IF l_gc3_is_installed = 'Y' THEN
3624 WSH_WV_UTILS.G_RESET_WV := 'Y'; -- set to Y to enable the update
3625 END IF;
3626 -- End of OTM R12 : packing ECO
3627
3628 IF l_debug_on THEN
3629 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.DETAIL_WEIGHT_VOLUME',WSH_DEBUG_SV.C_PROC_LEVEL);
3630 END IF;
3631 --
3632 wsh_wv_utils.detail_weight_volume (
3633 p_detail_rows => l_id_tab ,
3634 p_override_flag => 'Y', -- Need to see if we can Use p_action_prms.wv_override_flag
3635 x_return_status => l_return_status);
3636
3637 --
3638 wsh_util_core.api_post_call(
3639 p_return_status => l_return_status,
3640 x_num_warnings => l_number_of_warnings,
3641 x_num_errors => l_number_of_errors,
3642 p_msg_data => l_msg_data
3643 );
3644
3645 -- OTM R12 : packing ECO
3646 IF l_gc3_is_installed = 'Y' THEN
3647 WSH_WV_UTILS.G_RESET_WV := 'N'; -- after call, set it back to 'N'
3648 END IF;
3649 -- End of OTM R12 : packing ECO
3650
3651 --
3652 ELSIF p_action_prms.action_code = 'PACK' THEN
3653 --
3654 -- we just have to call the container group api here
3655 l_cont_flag := 'N';
3656 l_delivery_flag := 'N';
3657
3658 --
3659 IF l_debug_on THEN
3660 WSH_DEBUG_SV.log(l_module_name, 'Container Name', p_action_prms.container_name);
3661 WSH_DEBUG_SV.log(l_module_name, 'Container Instance Id', p_action_prms.container_instance_id);
3662 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_GRP.CONTAINER_ACTIONS',WSH_DEBUG_SV.C_PROC_LEVEL);
3663 END IF;
3664
3665 wsh_container_grp.Container_Actions(
3666 p_api_version => l_api_version,
3667 p_init_msg_list => FND_API.G_FALSE,
3668 p_commit => FND_API.G_FALSE,
3669 p_validation_level => wsh_container_grp.C_DELIVERY_DETAIL_CALL,
3670 x_return_status => l_return_status,
3671 x_msg_count => l_msg_count,
3672 x_msg_data => l_msg_data,
3673 p_detail_tab => l_id_tab,
3674 p_container_name => p_action_prms.container_name,
3675 p_cont_instance_id => p_action_prms.container_instance_id,
3676 p_container_flag => l_cont_flag,
3677 p_delivery_flag => l_delivery_flag,
3678 p_action_code => 'PACK',
3679 p_caller => p_action_prms.caller);
3680
3681 --
3682 wsh_util_core.api_post_call(
3683 p_return_status => l_return_status,
3684 x_num_warnings => l_number_of_warnings,
3685 x_num_errors => l_number_of_errors,
3686 p_msg_data => l_msg_data
3687 );
3688 --
3689
3690 -- deliveryMerge add the call to Adjust_Planned_Flag with delivery detail ids
3691
3692 FOR i in l_id_tab.FIRST .. l_id_tab.LAST LOOP
3693 OPEN get_delivery(l_id_tab(i));
3694 FETCH get_delivery into l_delivery_id;
3695 IF get_delivery%NOTFOUND THEN
3696 CLOSE get_delivery;
3697 goto end_of_detail_loop_1;
3698 END IF;
3699 CLOSE get_delivery;
3700
3701 l_delivery_already_included := false;
3702 IF l_delivery_ids.count > 0 THEN
3703 FOR j in l_delivery_ids.FIRST .. l_delivery_ids.LAST LOOP
3704 IF l_delivery_ids(j) = l_delivery_id THEN
3705 l_delivery_already_included := true;
3706 END IF;
3707 END LOOP;
3708 END IF;
3709
3710 IF NOT l_delivery_already_included THEN
3711 l_delivery_ids(l_delivery_ids.count+1) := l_delivery_id;
3712 END IF;
3713 <<end_of_detail_loop_1>>
3714 null;
3715 END LOOP;
3716
3717 IF l_delivery_ids.count > 0 THEN
3718 WSH_NEW_DELIVERY_ACTIONS.Adjust_Planned_Flag(
3719 p_delivery_ids => l_delivery_ids,
3720 p_caller => 'WSH_DLMG',
3721 p_force_appending_limit => 'N',
3722 p_call_lcss => 'Y',
3723 x_return_status => l_return_status);
3724
3725 IF l_debug_on THEN
3726 WSH_DEBUG_SV.log(l_module_name,'Adjust_Planned_Flag returns ',l_return_status);
3727 END IF;
3728 END IF;
3729
3730 wsh_util_core.api_post_call(
3731 p_return_status => l_return_status,
3732 x_num_warnings => l_number_of_warnings,
3733 x_num_errors => l_number_of_errors,
3734 p_msg_data => l_msg_data
3735 );
3736
3737 ELSIF p_action_prms.action_code = 'AUTO-PACK' THEN
3738 --
3739 -- we just have to call the container group api here
3740 l_entity_type := 'L';
3741
3742 --
3743 IF l_debug_on THEN
3744 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_GRP.AUTO_PACK',WSH_DEBUG_SV.C_PROC_LEVEL);
3745 END IF;
3746 wsh_container_grp.Auto_Pack (
3747 p_api_version => l_api_version,
3748 p_init_msg_list => FND_API.G_FALSE,
3749 p_commit => FND_API.G_FALSE,
3750 p_validation_level => l_validation_level,
3751 x_return_status => l_return_status,
3752 x_msg_count => l_msg_count,
3753 x_msg_data => l_msg_data,
3754 p_entity_tab => l_id_tab,
3755 p_entity_type => l_entity_type,
3756 p_group_id_tab => l_group_id_tab,
3757 p_pack_cont_flag => 'N' ,
3758 x_cont_inst_tab => x_action_out_rec.result_id_tab);
3759
3760 --
3761 wsh_util_core.api_post_call(
3762 p_return_status => l_return_status,
3763 x_num_warnings => l_number_of_warnings,
3764 x_num_errors => l_number_of_errors,
3765 p_msg_data => l_msg_data
3766 );
3767
3768 --
3769 ELSIF p_action_prms.action_code = 'AUTO-PACK-MASTER' THEN
3770 --
3771 -- we just have to call the container group api here
3772 -- set the flag p_pack_cont_flagto Y to do auto-pack-master.
3773 l_entity_type := 'L';
3774
3775 --
3776 IF l_debug_on THEN
3777 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_GRP.AUTO_PACK',WSH_DEBUG_SV.C_PROC_LEVEL);
3778 END IF;
3779 wsh_container_grp.Auto_Pack (
3780 p_api_version => p_api_version_number,
3781 p_init_msg_list => FND_API.G_FALSE,
3782 p_commit => FND_API.G_FALSE,
3783 p_validation_level => l_validation_level,
3784 x_return_status => l_return_status,
3785 x_msg_count => l_msg_count,
3786 x_msg_data => l_msg_data ,
3787 p_entity_tab => l_id_tab,
3788 p_entity_type => l_entity_type,
3789 p_group_id_tab => l_group_id_tab,
3790 p_pack_cont_flag => 'Y',
3791 x_cont_inst_tab => x_action_out_rec.result_id_tab);
3792
3793 -- Handle return status
3794 --
3795 wsh_util_core.api_post_call(
3796 p_return_status => l_return_status,
3797 x_num_warnings => l_number_of_warnings,
3798 x_num_errors => l_number_of_errors,
3799 p_msg_data => l_msg_data
3800 );
3801 --
3802
3803 ELSIF p_action_prms.action_code = 'UNPACK' THEN
3804 --
3805 -- we just have to call the container group api here
3806 l_cont_flag := 'Y'; -- need to set this to Y if action is Unpack
3807
3808 -- deliveryMerge
3809 -- get the delivery associated with the delivery details
3810 FOR i in l_id_tab.FIRST .. l_id_tab.LAST LOOP
3811 OPEN get_delivery(l_id_tab(i));
3812 FETCH get_delivery into l_delivery_id;
3813 IF l_delivery_id is NULL OR get_delivery%NOTFOUND THEN
3814 CLOSE get_delivery;
3815 goto end_of_detail_loop_2;
3816 END IF;
3817 CLOSE get_delivery;
3818
3819 l_delivery_already_included := false;
3820
3821 IF l_delivery_ids.count > 0 THEN
3822 FOR j in l_delivery_ids.FIRST .. l_delivery_ids.LAST LOOP
3823 IF l_delivery_ids(j) = l_delivery_id THEN
3824 l_delivery_already_included := true;
3825 END IF;
3826 END LOOP;
3827 END IF;
3828
3829 IF NOT l_delivery_already_included THEN
3830 l_delivery_ids(l_delivery_ids.count+1) := l_delivery_id;
3831 END IF;
3832 <<end_of_detail_loop_2>>
3833 null;
3834 END LOOP;
3835
3836
3837 IF l_debug_on THEN
3838 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_GRP.CONTAINER_ACTIONS',WSH_DEBUG_SV.C_PROC_LEVEL);
3839 END IF;
3840 wsh_container_grp.Container_Actions(
3841 p_api_version => l_api_version,
3842 p_init_msg_list => FND_API.G_FALSE,
3843 p_commit => FND_API.G_FALSE,
3844 p_validation_level => wsh_container_grp.C_DELIVERY_DETAIL_CALL,
3845 x_return_status => l_return_status,
3846 x_msg_count => l_msg_count,
3847 x_msg_data => l_msg_data ,
3848 p_detail_tab => l_id_tab,
3849 p_container_name => p_action_prms.container_name,
3850 p_cont_instance_id => p_action_prms.container_instance_id,
3851 p_container_flag => l_cont_flag,
3852 p_delivery_flag => l_delivery_flag,
3853 p_action_code => 'UNPACK',
3854 p_caller => p_action_prms.caller);
3855
3856 --
3857 wsh_util_core.api_post_call(
3858 p_return_status => l_return_status,
3859 x_num_warnings => l_number_of_warnings,
3860 x_num_errors => l_number_of_errors,
3861 p_msg_data => l_msg_data
3862 );
3863
3864 -- deliveryMerge
3865 IF l_delivery_ids.count > 0 THEN
3866 WSH_NEW_DELIVERY_ACTIONS.Adjust_Planned_Flag(
3867 p_delivery_ids => l_delivery_ids,
3868 p_caller => 'WSH_DLMG',
3869 p_force_appending_limit => 'N',
3870 p_call_lcss => 'Y',
3871 x_return_status => l_return_status);
3872
3873 IF l_debug_on THEN
3874 WSH_DEBUG_SV.log(l_module_name,'Adjust_Planned_Flag returns ',l_return_status);
3875 END IF;
3876 END IF;
3877
3878 wsh_util_core.api_post_call(
3879 p_return_status => l_return_status,
3880 x_num_warnings => l_number_of_warnings,
3881 x_num_errors => l_number_of_errors,
3882 p_msg_data => l_msg_data);
3883
3884 --
3885 ELSIF p_action_prms.action_code = 'CYCLE-COUNT' THEN
3886
3887 --
3888 -- Note: This action is only for one record. It is enforced by STF.
3889 --
3890 OPEN cycle_count_cur(l_id_tab(l_id_tab.first));
3891 FETCH cycle_count_cur
3892 INTO l_released_status
3893 , l_requested_quantity
3894 , l_requested_quantity2
3895 , l_picked_quantity
3896 , l_picked_quantity2
3897 , l_shipped_quantity
3898 , l_shipped_quantity2
3899 , l_organization_id
3900 , l_inv_item_id
3901 ;
3902
3903 IF cycle_count_cur%NOTFOUND THEN
3904 CLOSE cycle_count_cur;
3905 IF l_debug_on THEN
3906 wsh_debug_sv.logmsg(l_module_name,'Detail not found');
3907 END IF;
3908 RAISE FND_API.G_EXC_ERROR;
3909 END IF;
3910
3911 CLOSE cycle_count_cur;
3912 --
3913 --
3914 IF l_released_status = 'Y' AND NVL(l_picked_quantity, l_requested_quantity) > NVL(l_shipped_quantity, 0) THEN
3915 NULL;
3916 ELSE
3917 IF l_debug_on THEN
3918 wsh_debug_sv.logmsg(l_module_name,'Incorrect Released status or incorrect quantities');
3919 END IF;
3920 fnd_message.set_name('WSH', 'WSH_CC_RSV_INSUFF');
3921 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3922 raise FND_API.G_EXC_ERROR;
3923 END IF;
3924 --
3925 --
3926
3927
3928 -- HW OPM BUG#:2677054
3929 -- HW OPMCONV - 1) No need to branch code
3930 -- - 2) Relace call is_line_allocated with new WSH API
3931 -- HW OPMCONV - New WSH API to check if split is allowed
3932
3933 l_delivery_detail_id := l_id_tab(l_id_tab.first);
3934
3935 IF (NOT WSH_DETAILS_VALIDATIONS.is_cycle_count_allowed
3936 ( p_delivery_detail_id => l_delivery_detail_id,
3937 p_organization_id => l_organization_id,
3938 p_inventory_item_id => l_inv_item_id,
3939 p_released_status => l_released_status,
3940 p_picked_qty => l_picked_quantity,
3941 p_cycle_qty => p_action_prms.quantity_to_split)
3942 ) THEN
3943 FND_MESSAGE.SET_NAME('WSH', 'WSH_NO_PARTIAL_CYCLE_COUNT');
3944
3945 IF p_action_prms.caller = 'WSH_FSTRX' THEN
3946 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3947 END IF;
3948 RAISE FND_API.G_EXC_ERROR;
3949 END IF;
3950
3951 -- HW end of 2677054
3952
3953
3954 IF p_action_prms.caller = 'WSH_FSTRX' AND p_action_prms.phase = 1 THEN
3955 -- return to Form so that the Cycle Count Dialog is shown to enter quantities
3956 --
3957 x_defaults.quantity_to_cc := nvl(l_picked_quantity, l_requested_quantity) - nvl(l_shipped_quantity,0);
3958 x_defaults.quantity2_to_cc := nvl(l_picked_quantity2, l_requested_quantity2) - nvl(l_shipped_quantity2,0);
3959
3960 IF l_debug_on THEN
3961 wsh_debug_sv.log(l_module_name, 'Default cc qty', x_defaults.quantity_to_cc);
3962 END IF;
3963 --
3964 --Change made during Bugfix 4070732
3965 --Raise end of api so that handling of return status, reset flags are done there
3966 RAISE e_end_of_api;
3967
3968 END IF;
3969 --
3970 -- Check if cycle-count quantity is less than (picked or requested qty) - shipped qty
3971 -- Check if cycle_count quantity is greater than zero
3972 --Bug 2650617, nvl(l_shipped_quantity,0)
3973 IF (( p_action_prms.quantity_to_split > (NVL(l_picked_quantity, l_requested_quantity) - nvl(l_shipped_quantity,0)))
3974 OR p_action_prms.quantity_to_split <= 0) THEN
3975
3976 IF l_debug_on THEN
3977 wsh_debug_sv.logmsg(l_module_name,'Incorrect quantities');
3978 END IF;
3979 FND_MESSAGE.SET_NAME('WSH', 'WSH_DET_SPLIT_EXCEED');
3980 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
3981 raise FND_API.G_EXC_ERROR;
3982
3983 END IF;
3984
3985 -- Calculate the quantities to be passed to backorder API
3986 --
3987 l_req_qtys(1) := l_requested_quantity;
3988 l_overpick_qtys(1) := LEAST(p_action_prms.quantity_to_split,
3989 NVL(l_picked_quantity, l_requested_quantity) - l_requested_quantity);
3990
3991 l_overpick_qtys2(1) := LEAST(p_action_prms.quantity2_to_split,
3992 NVL(l_picked_quantity2, l_requested_quantity2) - l_requested_quantity2);
3993
3994 l_bo_qtys(1) := p_action_prms.quantity_to_split - l_overpick_qtys(1);
3995 l_bo_qtys2(1) := p_action_prms.quantity2_to_split - l_overpick_qtys2(1);
3996
3997 IF l_debug_on THEN
3998 wsh_debug_sv.log(l_module_name, 'Overpick Qty' , l_overpick_qtys(1));
3999 wsh_debug_sv.log(l_module_name, 'BO qty', l_bo_qtys(1));
4000 END IF;
4001
4002
4003 IF l_validation_level_tab(wsh_actions_levels.C_DECIMAL_QUANTITY_LVL)= 1 THEN
4004 --
4005 --
4006 OPEN det_cur(l_id_tab(l_id_tab.first));
4007 FETCH det_cur
4008 INTO l_inv_item_id
4009 , l_organization_id
4010 , l_requested_quantity_uom
4011 , l_line_direction
4012 , l_released_status;
4013 CLOSE det_cur;
4014
4015 -- HW Harmonization project for OPM. Added p_organization_id
4016 -- HW OPMCONV - Removed branching
4017
4018 -- this needs to be called only for Discrete Org
4019 --
4020 IF l_debug_on THEN
4021 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_DECIMAL_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
4022 END IF;
4023 --
4024 WSH_DETAILS_VALIDATIONS.check_decimal_quantity(
4025 p_item_id => l_inv_item_id,
4026 p_organization_id => l_organization_id,
4027 p_input_quantity => p_action_prms.quantity_to_split,
4028 p_uom_code => l_requested_quantity_uom,
4029 x_output_quantity => l_output_quantity,
4030 x_return_status => l_return_status);
4031
4032 IF l_debug_on THEN
4033 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4034 END IF;
4035 --
4036
4037 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
4038 raise FND_API.G_EXC_ERROR;
4039 END IF;
4040
4041 --
4042 END IF;
4043
4044
4045 IF l_debug_on THEN
4046 wsh_debug_sv.log(l_module_name, 'BO rows count', l_id_tab.count);
4047 wsh_debug_sv.log(l_module_name, 'BO qtys count', l_bo_qtys.count);
4048 wsh_debug_sv.log(l_module_name, 'Req qtys count', l_req_qtys.count);
4049 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_SHIP_CONFIRM_ACTIONS2.BACKORDER',WSH_DEBUG_SV.C_PROC_LEVEL);
4050 END IF;
4051 --
4052 wsh_ship_confirm_actions2.Backorder(
4053 p_detail_ids => l_id_tab,
4054 p_line_ids => l_line_ids, -- Consolidation of BO Delivery details project
4055 p_bo_qtys => l_bo_qtys ,
4056 p_req_qtys => l_req_qtys ,
4057 p_bo_qtys2 => l_bo_qtys2 ,
4058 p_overpick_qtys => l_overpick_qtys ,
4059 p_overpick_qtys2 => l_overpick_qtys2 ,
4060 p_bo_mode => 'CYCLE_COUNT' ,
4061 x_out_rows => x_action_out_rec.result_id_tab ,
4062 x_cons_flags => l_cons_flags, -- Consolidation of BO Delivery details project
4063 x_return_status => l_return_status);
4064
4065 -- Handle return status
4066 -- set message if necessary
4067 wsh_util_core.api_post_call(
4068 p_return_status => l_return_status,
4069 x_num_warnings => l_number_of_warnings,
4070 x_num_errors => l_number_of_errors,
4071 p_msg_data => l_msg_data
4072 );
4073
4074 IF l_debug_on THEN
4075 WSH_DEBUG_SV.log(l_module_name, 'Backorder Result tab count', x_action_out_rec.result_id_tab.count);
4076 END IF;
4077
4078 --
4079 -- Consolidation of BO Delivery details project
4080 --
4081 -- Debug Statements
4082 --
4083 IF l_debug_on THEN
4084 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_SHIPPING_PARAMS_PVT.Get_Global_Parameters',WSH_DEBUG_SV.C_PROC_LEVEL);
4085 END IF;
4086 --
4087 WSH_SHIPPING_PARAMS_PVT.Get_Global_Parameters(l_global_param_rec, l_return_status);
4088
4089 -- Handle return status
4090 -- set message if necessary
4091 wsh_util_core.api_post_call(
4092 p_return_status => l_return_status,
4093 x_num_warnings => l_number_of_warnings,
4094 x_num_errors => l_number_of_errors,
4095 p_msg_data => l_msg_data
4096 );
4097
4098 -- x_action_out_rec.result_id_tab contains the original delivery_detail_id, for complete cycle-count.
4099 -- x_action_out_rec.result_id_tab contains the newly created delivery_detail_id, for
4100 -- partial cycle-count(split happens in this case).
4101 --
4102 -- Pass back the original delivery_detail_id, if it was merged into some other delivery detail
4103 IF (l_global_param_rec.consolidate_bo_lines = 'Y' AND l_cons_flags(1) = 'Y') THEN
4104 x_action_out_rec.result_id_tab(1) := l_id_tab(1);
4105 END IF;
4106 --
4107
4108 --
4109 ELSIF p_action_prms.action_code IN ('PACKING-WORKBENCH', 'PICK-RELEASE-UI', 'RESOLVE-EXCEPTIONS-UI', 'FREIGHT-COSTS-UI') AND p_action_prms.caller = 'WSH_FSTRX' THEN
4110 -- do nothing. return
4111 -- These actions are supported only for UI(STF).
4112 -- Not applicable for other callers
4113
4114 --Change made during Bugfix 4070732
4115 --Raise end of api so that handling of return status, reset flags are done there
4116 RAISE e_end_of_api;
4117
4118 --
4119 --Bug 3326794: Added code for the DELETE action.
4120 ELSIF p_action_prms.action_code = 'DELETE' THEN
4121 --{
4122 IF l_debug_on THEN
4123 --{
4124 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Delete',WSH_DEBUG_SV.C_PROC_LEVEL);
4125 --}
4126 END IF;
4127 --
4128 WSH_UTIL_CORE.Delete(
4129 p_type => 'DLVB',
4130 p_rows => l_id_tab,
4131 x_return_status => l_return_status);
4132 --
4133 IF l_debug_on THEN
4134 --{
4135 wsh_debug_sv.log(l_module_name,'Return Status After Calling Delete',l_return_status);
4136 --}
4137 END IF;
4138 --
4139 wsh_util_core.api_post_call(
4140 p_return_status => l_return_status,
4141 x_num_warnings => l_number_of_warnings,
4142 x_num_errors => l_number_of_errors);
4143
4144 --} -- End Bug 3326794
4145
4146 ELSE
4147 --
4148 FND_MESSAGE.SET_NAME('WSH','WSH_INVALID_ACTION_CODE');
4149 FND_MESSAGE.SET_TOKEN('ACT_CODE',p_action_prms.action_code );
4150 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
4151 IF l_debug_on THEN
4152 wsh_debug_sv.logmsg(l_module_name,'WSH_INVALID_ACTION_CODE');
4153 END IF;
4154 RAISE FND_API.G_EXC_ERROR;
4155 --
4156 END IF;
4157 --
4158 --
4159 --Call to DCP
4160 --If profile is turned on.
4161 BEGIN
4162 --{
4163 --
4164 IF l_debug_on THEN
4165 wsh_debug_sv.log(l_module_name, 'l_check_dcp', l_check_dcp);
4166 wsh_debug_sv.log(l_module_name, 'g_call_dcp_check', WSH_DCP_PVT.G_CALL_DCP_CHECK);
4167 END IF;
4168 --
4169 IF NVL(l_check_dcp, -99) IN (1,2)
4170 AND NVL(WSH_DCP_PVT.G_CALL_DCP_CHECK, 'Y') = 'Y'
4171 THEN
4172 --{
4173 IF p_action_prms.action_code IN ('SPLIT-LINE', 'CYCLE-COUNT', 'PACK', 'AUTO-PACK')
4174 THEN
4175 --{
4176 IF l_debug_on THEN
4177 WSH_DEBUG_SV.LOGMSG(L_MODULE_NAME, 'CALLING DCP ');
4178 END IF;
4179
4180 wsh_dcp_pvt.check_detail(
4181 p_action_code => p_action_prms.action_code,
4182 p_dtl_table => p_rec_attr_tab);
4183 --}
4184 END IF;
4185 --}
4186 END IF;
4187 EXCEPTION
4188 WHEN wsh_dcp_pvt.data_inconsistency_exception THEN
4189 if NOT l_debug_on OR l_debug_on is null then
4190 l_debug_on := wsh_debug_sv.is_debug_enabled;
4191 end if;
4192 IF l_debug_on THEN
4193 WSH_DEBUG_SV.logmsg(l_module_name,'data_inconsistency_exception');
4194 END IF;
4195 ROLLBACK TO DELIVERY_DETAIL_ACTION_GRP;
4196 GOTO api_start;
4197 WHEN OTHERS THEN
4198 IF l_debug_on THEN
4199 WSH_DEBUG_SV.logmsg(l_module_name,'When Others');
4200 END IF;
4201 null;
4202 --}
4203 END;
4204 --
4205 RAISE e_end_of_api; -- J-IB-NPARIKH
4206
4207
4208 EXCEPTION
4209 WHEN e_end_of_api THEN
4210
4211 IF del_cur%ISOPEN THEN
4212 CLOSE del_cur;
4213 END IF;
4214
4215 --
4216 -- K LPN CONV. rv
4217 --
4218 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
4219 THEN
4220 --{
4221 IF l_debug_on THEN
4222 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
4223 END IF;
4224
4225 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
4226 (
4227 p_in_rec => l_lpn_in_sync_comm_rec,
4228 x_return_status => l_return_status,
4229 x_out_rec => l_lpn_out_sync_comm_rec
4230 );
4231 --
4232 --
4233 IF l_debug_on THEN
4234 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
4235 END IF;
4236 --
4237 --
4238 WSH_UTIL_CORE.API_POST_CALL
4239 (
4240 p_return_status => l_return_status,
4241 x_num_warnings => l_number_of_warnings,
4242 x_num_errors => l_number_of_errors,
4243 p_raise_error_flag => false
4244 );
4245 --}
4246 END IF;
4247 --
4248 -- K LPN CONV. rv
4249 --
4250
4251 IF l_number_of_warnings > 0 THEN
4252 IF l_debug_on THEN
4253 wsh_debug_sv.log (l_module_name,'Number of warnings', l_number_of_warnings);
4254 END IF;
4255 -- RAISE WSH_UTIL_CORE.G_EXC_WARNING;
4256 l1_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4257 ELSE
4258 l1_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4259 END IF;
4260 --
4261 -- Standard check of p_commit.
4262 IF FND_API.To_Boolean( p_commit ) THEN
4263 IF(l_debug_on) THEN
4264 wsh_debug_sv.logmsg(l_module_name, 'Commit Work');
4265 END IF;
4266 --
4267 -- Start code for Bugfix 4070732
4268 --
4269 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
4270 IF l_debug_on THEN
4271 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4272 END IF;
4273
4274 l_reset_flags := FALSE;
4275 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => l_reset_flags,
4276 x_return_status => l_return_status);
4277
4278 IF l_debug_on THEN
4279 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4280 END IF;
4281
4282 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
4283 l1_return_status := l_return_status;
4284 END IF;
4285
4286 END IF;
4287 --
4288 -- End of code for Bugfix 4070732
4289 --
4290
4291 COMMIT WORK;
4292 END IF;
4293
4294 --bug 4070732
4295 --End of the API handling of calls to process_stops_for_load_tender
4296 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
4297 --{
4298 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
4299 --{
4300
4301 IF FND_API.To_Boolean( p_commit ) THEN
4302 IF l_debug_on THEN
4303 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4304 END IF;
4305
4306 WSH_UTIL_CORE.reset_stops_for_load_tender(p_reset_flags => TRUE,
4307 x_return_status => l_return_status);
4308
4309 ELSE
4310 IF l_debug_on THEN
4311 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4312 END IF;
4313
4314 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
4315 x_return_status => l_return_status);
4316
4317 END IF;
4318
4319 IF l_debug_on THEN
4320 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4321 END IF;
4322
4323 IF l1_return_status <> WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
4324 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
4325 IF l1_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
4326 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_WARNING THEN
4327 l1_return_status := l_return_status;
4328 END IF;
4329 ELSE
4330 l1_return_status := l_return_status;
4331 END IF;
4332 END IF;
4333 END IF;
4334 --}
4335 END IF;
4336 --}
4337 END IF;
4338
4339 x_return_status := l1_return_status;
4340 --bug 4070732
4341
4342 FND_MSG_PUB.Count_And_Get
4343 (
4344 p_count => x_msg_count,
4345 p_data => x_msg_data,
4346 p_encoded => FND_API.G_FALSE
4347 );
4348
4349
4350 IF l_debug_on THEN
4351 WSH_DEBUG_SV.pop(l_module_name);
4352 END IF;
4353 --
4354 WHEN FND_API.G_EXC_ERROR THEN
4355 -- ROLLBACK TO DELIVERY_DETAIL_ACTION_GRP;
4356 x_return_status := FND_API.G_RET_STS_ERROR ;
4357 --
4358 IF del_cur%ISOPEN THEN
4359 CLOSE del_cur;
4360 END IF;
4361 -- K LPN CONV. rv
4362 --
4363 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
4364 THEN
4365 --{
4366 IF l_debug_on THEN
4367 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
4368 END IF;
4369
4370 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
4371 (
4372 p_in_rec => l_lpn_in_sync_comm_rec,
4373 x_return_status => l_return_status,
4374 x_out_rec => l_lpn_out_sync_comm_rec
4375 );
4376 --
4377 --
4378 IF l_debug_on THEN
4379 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
4380 END IF;
4381 --
4382 --
4383 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
4384 x_return_status := l_return_status;
4385 END IF;
4386 --
4387 --}
4388 END IF;
4389 --
4390 -- K LPN CONV. rv
4391 --
4392 --
4393 -- Start code for Bugfix 4070732
4394 --
4395 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
4396 THEN
4397 --{
4398 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
4399 --{
4400 IF l_debug_on THEN
4401 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4402 END IF;
4403
4404 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
4405 x_return_status => l_return_status);
4406
4407 IF l_debug_on THEN
4408 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4409 END IF;
4410
4411 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
4412 x_return_status := l_return_status;
4413 END IF;
4414 --}
4415 END IF;
4416 --}
4417 END IF;
4418 --
4419 -- End of Code Bugfix 4070732
4420 --
4421 FND_MSG_PUB.Count_And_Get
4422 (
4423 p_count => x_msg_count,
4424 p_data => x_msg_data,
4425 p_encoded => FND_API.G_FALSE
4426 );
4427
4428
4429 IF l_debug_on THEN
4430 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4431 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
4432 END IF;
4433 --
4434 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4435 -- ROLLBACK TO DELIVERY_DETAIL_ACTION_GRP;
4436 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4437
4438 IF del_cur%ISOPEN THEN
4439 CLOSE del_cur;
4440 END IF;
4441
4442 --
4443 -- K LPN CONV. rv
4444 --
4445 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
4446 THEN
4447 --{
4448 IF l_debug_on THEN
4449 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
4450 END IF;
4451
4452 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
4453 (
4454 p_in_rec => l_lpn_in_sync_comm_rec,
4455 x_return_status => l_return_status,
4456 x_out_rec => l_lpn_out_sync_comm_rec
4457 );
4458 --
4459 --
4460 IF l_debug_on THEN
4461 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
4462 END IF;
4463 --
4464 --
4465 --}
4466 END IF;
4467 --
4468 -- K LPN CONV. rv
4469 --
4470 --
4471 -- Start code for Bugfix 4070732
4472 --
4473 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
4474 THEN
4475 --{
4476 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
4477 --{
4478 IF l_debug_on THEN
4479 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4480 END IF;
4481
4482 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
4483 x_return_status => l_return_status);
4484
4485 IF l_debug_on THEN
4486 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4487 END IF;
4488 --}
4489 END IF;
4490 --}
4491 END IF;
4492 --
4493 -- End of Code Bugfix 4070732
4494 --
4495 FND_MSG_PUB.Count_And_Get
4496 (
4497 p_count => x_msg_count,
4498 p_data => x_msg_data,
4499 p_encoded => FND_API.G_FALSE
4500 );
4501
4502
4503 IF l_debug_on THEN
4504 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4505 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
4506 END IF;
4507 --
4508 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
4509 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4510 IF del_cur%ISOPEN THEN
4511 CLOSE del_cur;
4512 END IF;
4513
4514 --
4515 -- K LPN CONV. rv
4516 --
4517 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
4518 THEN
4519 --{
4520 IF l_debug_on THEN
4521 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
4522 END IF;
4523
4524 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
4525 (
4526 p_in_rec => l_lpn_in_sync_comm_rec,
4527 x_return_status => l_return_status,
4528 x_out_rec => l_lpn_out_sync_comm_rec
4529 );
4530 --
4531 --
4532 IF l_debug_on THEN
4533 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
4534 END IF;
4535 --
4536 --
4537 IF (l_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR) and x_return_status <> WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
4538 x_return_status := l_return_status;
4539 END IF;
4540 --
4541 --}
4542 END IF;
4543 --
4544 -- K LPN CONV. rv
4545 --
4546 --
4547 -- Start code for Bugfix 4070732
4548 --
4549 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
4550 THEN
4551 --{
4552 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API)
4553 THEN
4554 --{
4555 IF l_debug_on THEN
4556 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4557 END IF;
4558
4559 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
4560 x_return_status => l_return_status);
4561
4562 IF l_debug_on THEN
4563 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4564 END IF;
4565
4566 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
4567 x_return_status := l_return_status;
4568 END IF;
4569 --}
4570 END IF;
4571 ---}
4572 END IF;
4573 --
4574 -- End of Code Bugfix 4070732
4575 --
4576 FND_MSG_PUB.Count_And_Get
4577 (
4578 p_count => x_msg_count,
4579 p_data => x_msg_data,
4580 p_encoded => FND_API.G_FALSE
4581 );
4582
4583 IF l_debug_on THEN
4584 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4585 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
4586 END IF;
4587 --
4588 WHEN OTHERS THEN
4589 IF del_cur%ISOPEN THEN
4590 CLOSE del_cur;
4591 END IF;
4592
4593 -- ROLLBACK TO DELIVERY_DETAIL_ACTION_GRP;
4594 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4595 IF cycle_count_cur%ISOPEN THEN
4596 Close cycle_count_cur;
4597 END IF;
4598 wsh_util_core.add_message(x_return_status, l_module_name);
4599 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Delivery_Detail_Action');
4600 --
4601 -- K LPN CONV. rv
4602 --
4603 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
4604 THEN
4605 --{
4606 IF l_debug_on THEN
4607 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
4608 END IF;
4609
4610 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
4611 (
4612 p_in_rec => l_lpn_in_sync_comm_rec,
4613 x_return_status => l_return_status,
4614 x_out_rec => l_lpn_out_sync_comm_rec
4615 );
4616 --
4617 --
4618 IF l_debug_on THEN
4619 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
4620 END IF;
4621 --
4622 --
4623 --}
4624 END IF;
4625 --
4626 -- K LPN CONV. rv
4627 --
4628 --
4629 -- Start code for Bugfix 4070732
4630 --
4631 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
4632 THEN
4633 --{
4634 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
4635 --{
4636 IF l_debug_on THEN
4637 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
4638 END IF;
4639
4640 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
4641 x_return_status => l_return_status);
4642
4643 IF l_debug_on THEN
4644 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4645 END IF;
4646 --}
4647 END IF;
4648 --}
4649 END IF;
4650 --
4651 -- End of Code Bugfix 4070732
4652 --
4653 FND_MSG_PUB.Count_And_Get
4654 (
4655 p_count => x_msg_count,
4656 p_data => x_msg_data,
4657 p_encoded => FND_API.G_FALSE
4658 );
4659 --
4660
4661 IF l_debug_on THEN
4662 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4663 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4664 END IF;
4665 --
4666 END Delivery_Detail_Action;
4667
4668
4669 -- ---------------------------------------------------------------------
4670 -- Procedure: Create_Update_Delivery_Detail
4671 --
4672 -- Parameters: --
4673 -- Description: This procedure is the new API for wrapping the logic of CREATE/UPDATE of delivery details
4674 -- Created: Harmonization Project. Patchset I
4675 -- -----------------------------------------------------------------------
4676
4677 PROCEDURE Create_Update_Delivery_Detail
4678 (
4679 -- Standard Parameters
4680 p_api_version_number IN NUMBER,
4681 p_init_msg_list IN VARCHAR2,
4682 p_commit IN VARCHAR2,
4683 x_return_status OUT NOCOPY VARCHAR2,
4684 x_msg_count OUT NOCOPY NUMBER,
4685 x_msg_data OUT NOCOPY VARCHAR2,
4686
4687 -- Procedure Specific Parameters
4688 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
4689 p_IN_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
4690 x_OUT_rec OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.detailOutRecType
4691 ) IS
4692
4693 l_api_name CONSTANT VARCHAR2(30) := 'Create_Update_Delivery_Detail';
4694 l_api_version CONSTANT NUMBER := 1.0;
4695 --
4696 --
4697 l_return_status VARCHAR2(32767);
4698 l_msg_count NUMBER;
4699 l_msg_data VARCHAR2(32767);
4700 l_program_name VARCHAR2(32767);
4701 --
4702 l_number_of_errors NUMBER := 0;
4703 l_number_of_warnings NUMBER := 0;
4704 --
4705 l_loop_num_error NUMBER := 0;
4706 l_loop_num_warn NUMBER := 0;
4707 --
4708 l_counter NUMBER := 0;
4709 l_index NUMBER;
4710
4711 l_detail_info_tab WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type;
4712 l_valid_index_tab wsh_util_core.id_tab_type;
4713 l_delivery_id NUMBER;
4714 l_delivery_detail_rec WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type;
4715 l_validation_tab wsh_util_core.id_tab_type;
4716 --
4717 l_details_marked WSH_UTIL_CORE.Id_Tab_Type;
4718 l_dummy_ser_range_tab WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType;
4719 mark_reprice_error EXCEPTION;
4720
4721 --
4722 CURSOR det_to_del_cur(p_detail_id NUMBER) IS
4723 SELECT wda.delivery_id
4724 FROM wsh_delivery_assignments_v wda
4725 WHERE wda.delivery_detail_id = p_detail_id;
4726
4727 -- anxsharm for Load Tender
4728 l_detail_tender_tab wsh_util_core.id_tab_type;
4729 l_trip_id_tab wsh_util_core.id_tab_type;
4730
4731 --
4732 l_debug_on BOOLEAN;
4733 --
4734 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_UPDATE_DELIVERY_DETAIL';
4735 --
4736
4737 BEGIN
4738
4739 -- Standard Start of API savepoint
4740 --
4741 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4742 --
4743 IF l_debug_on IS NULL
4744 THEN
4745 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4746 END IF;
4747 --
4748 SAVEPOINT CREATE_UPDATE_DEL_DETAIL_GRP;
4749 --
4750 -- Debug Statements
4751 --
4752 IF l_debug_on THEN
4753 WSH_DEBUG_SV.push(l_module_name);
4754 --
4755 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
4756 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
4757 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
4758 WSH_DEBUG_SV.log(l_module_name, 'Caller', p_In_rec.caller);
4759 WSH_DEBUG_SV.log(l_module_name, 'Action Code', p_In_rec.action_code);
4760 WSH_DEBUG_SV.log(l_module_name,'Input Table count', p_detail_info_tab.count);
4761 END IF;
4762 --
4763
4764 -- Initialize message list if p_init_msg_list is set to TRUE.
4765 IF FND_API.to_Boolean( p_init_msg_list )
4766 THEN
4767 FND_MSG_PUB.initialize;
4768 END IF;
4769
4770 -- Initialize API return status to success
4771 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4772 l_number_of_errors := 0;
4773 l_number_of_warnings := 0;
4774
4775 /* Call the New Overloaded API */
4776
4777 create_update_delivery_detail(
4778 p_api_version_number => p_api_version_number,
4779 p_init_msg_list => FND_API.G_FALSE,
4780 p_commit => FND_API.G_FALSE,
4781 x_return_status => l_return_status,
4782 x_msg_count => l_msg_count,
4783 x_msg_data => l_msg_data,
4784 p_detail_info_tab => p_detail_info_tab,
4785 p_IN_rec => p_in_rec,
4786 x_OUT_rec => x_out_rec,
4787 p_serial_range_tab => l_dummy_ser_range_tab
4788 );
4789
4790 wsh_util_core.api_post_call(
4791 p_return_status =>l_return_status,
4792 x_num_warnings =>l_number_of_warnings,
4793 x_num_errors =>l_number_of_errors);
4794
4795 IF l_number_of_warnings > 0 THEN
4796 IF l_debug_on THEN
4797 wsh_debug_sv.log(l_module_name,'Number of warnings', l_number_of_warnings);
4798 END IF;
4799 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
4800 END IF;
4801
4802
4803 -- Standard check of p_commit.
4804 IF FND_API.To_Boolean( p_commit ) THEN
4805 IF(l_debug_on) THEN
4806 wsh_debug_sv.logmsg(l_module_name, 'Commit Work');
4807 END IF;
4808 COMMIT WORK;
4809 END IF;
4810
4811 FND_MSG_PUB.Count_And_Get
4812 (
4813 p_count => x_msg_count,
4814 p_data => x_msg_data,
4815 p_encoded => FND_API.G_FALSE
4816 );
4817
4818 IF l_debug_on THEN
4819 WSH_DEBUG_SV.pop(l_module_name);
4820 END IF;
4821 --
4822 EXCEPTION
4823 WHEN FND_API.G_EXC_ERROR THEN
4824 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP;
4825 x_return_status := FND_API.G_RET_STS_ERROR ;
4826 FND_MSG_PUB.Count_And_Get
4827 (
4828 p_count => x_msg_count,
4829 p_data => x_msg_data,
4830 p_encoded => FND_API.G_FALSE
4831 );
4832 --
4833 IF l_debug_on THEN
4834 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4835 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
4836 END IF;
4837 --
4838 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4839 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP;
4840 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4841 FND_MSG_PUB.Count_And_Get
4842 (
4843 p_count => x_msg_count,
4844 p_data => x_msg_data,
4845 p_encoded => FND_API.G_FALSE
4846 );
4847
4848 --
4849 IF l_debug_on THEN
4850 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4851 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
4852 END IF;
4853 --
4854 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
4855 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4856 FND_MSG_PUB.Count_And_Get
4857 (
4858 p_count => x_msg_count,
4859 p_data => x_msg_data,
4860 p_encoded => FND_API.G_FALSE
4861 );
4862 --
4863 IF l_debug_on THEN
4864 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4865 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
4866 END IF;
4867 --
4868 WHEN mark_reprice_error then
4869 FND_MESSAGE.Set_Name('WSH', 'WSH_REPRICE_REQUIRED_ERR');
4870 wsh_util_core.add_message(x_return_status, l_module_name);
4871 x_return_status := l_return_status;
4872 FND_MSG_PUB.Count_And_Get
4873 (
4874 p_count => x_msg_count,
4875 p_data => x_msg_data,
4876 p_encoded => FND_API.G_FALSE
4877 );
4878 --
4879
4880 --
4881 IF l_debug_on THEN
4882 WSH_DEBUG_SV.logmsg(l_module_name,'MARK_REPRICE_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4883 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:MARK_REPRICE_ERROR');
4884 END IF;
4885 --
4886 WHEN OTHERS THEN
4887 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP;
4888 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4889 wsh_util_core.add_message(x_return_status, l_module_name);
4890 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Create_Update_Delivery_Detail');
4891 FND_MSG_PUB.Count_And_Get
4892 (
4893 p_count => x_msg_count,
4894 p_data => x_msg_data,
4895 p_encoded => FND_API.G_FALSE
4896 );
4897 --
4898
4899 IF l_debug_on THEN
4900 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4901 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4902 END IF;
4903 --
4904 END Create_Update_Delivery_Detail;
4905
4906
4907 /* ----------------------------------------------------
4908 PROCEDURE Create_containers
4909 ----------------------------------------------------*/
4910 -- lpn conv
4911 PROCEDURE Create_containers(
4912 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
4913 p_detail_IN_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
4914 x_container_ids OUT NOCOPY WSH_UTIL_CORE.ID_TAB_TYPE,
4915 x_return_status OUT NOCOPY varchar2
4916 )
4917 IS
4918 l_debug_on BOOLEAN;
4919 --
4920 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME ||
4921 '.' || 'CREATE_CONTAINERS';
4922 l_generate boolean := FALSE;
4923 l_create_for_wms boolean := FALSE;
4924 l_create_one_record boolean := FALSE;
4925 l_lpn_out_tab WMS_Data_Type_Definitions_pub.LPNTableType;
4926 l_gen_lpn_rec WMS_Data_Type_Definitions_pub.AutoCreateLPNRecordType;
4927 l_verify_org_level NUMBER;
4928 l_verify_cont_item NUMBER;
4929 l_organization_id NUMBER := NULL;
4930 l_organization_code VARCHAR2(240) := NULL;
4931 l_cont_item_id NUMBER := NULL;
4932 l_cont_item_seg FND_FLEX_EXT.SegmentArray;
4933 l_cont_item_name VARCHAR2(30) := NULL;
4934 l_wms_return_status VARCHAR2(10);
4935 l_wms_msg_count NUMBER;
4936 l_wms_msg_data VARCHAR2(2000);
4937 l_wms_organization_id NUMBER;
4938 l_total_length NUMBER;
4939 l_name_prefix VARCHAR2(30);
4940 l_name_suffix VARCHAR2(30);
4941 l_base_number NUMBER;
4942 l_base_number_dummy NUMBER;
4943 l_container_names WSH_GLBL_VAR_STRCT_GRP.v50_Tbl_Type;
4944 l_lpn_ids wsh_util_core.id_tab_type;
4945 i NUMBER;
4946 j NUMBER;
4947 l_orig_value varchar2(2);
4948 l_update_container_orig VARCHAR2(2) := WSH_WMS_LPN_GRP.g_update_to_container;
4949 -- bmso
4950 l_lpn_table WMS_Data_Type_Definitions_pub.LPNTableType;
4951 l_container_info_rec WSH_GLBL_VAR_STRCT_GRP.ContInfoRectype;
4952 l_container_rec WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type;
4953 l_cont_dummy_tab WSH_UTIL_CORE.id_tab_type;
4954 l_del_assg_rec WSH_DELIVERY_DETAILS_PKG.Delivery_Assignments_Rec_Type;
4955 l_assignment_dummy_tab WSH_UTIL_CORE.id_tab_type;
4956 l_wms_enabled BOOLEAN;
4957 l_return_status VARCHAR2(2);
4958 l_number_of_warnings NUMBER := 0;
4959 l_number_of_errors NUMBER := 0;
4960 l_suffix_length NUMBER;
4961 l_additional_cont_attr wsh_glbl_var_strct_grp.LPNRecordType;
4962
4963 l_new_session BOOLEAN := TRUE;
4964
4965 CURSOR c_get_default_parameters (v_organization_id NUMBER) IS
4966 SELECT LPN_STARTING_NUMBER
4967 FROM mtl_parameters
4968 WHERE ORGANIZATION_ID = v_organization_id;
4969
4970 CURSOR c_get_wms_next_seq IS
4971 SELECT WMS_LICENSE_PLATE_NUMBERS_S2.nextval
4972 FROM DUAL;
4973 CURSOR c_get_wms_curr_seq IS
4974 SELECT WMS_LICENSE_PLATE_NUMBERS_S2.currval
4975 FROM DUAL;
4976
4977 l_lpn_starting_num NUMBER;
4978 l_wms_sequence NUMBER;
4979
4980 e_lpn_count_invalid EXCEPTION;
4981 e_NO_INV_ITEM EXCEPTION;
4982
4983
4984
4985 BEGIN
4986 --
4987 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4988 --
4989 IF l_debug_on IS NULL
4990 THEN
4991 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4992 END IF;
4993 --
4994 IF l_debug_on THEN
4995 WSH_DEBUG_SV.push(l_module_name);
4996 WSH_DEBUG_SV.log(l_module_name, 'p_detail_info_tab.count',
4997 p_detail_info_tab.count);
4998 END IF;
4999
5000 SAVEPOINT s_create_containers_DDGPB;
5001
5002 l_orig_value := WSH_WMS_LPN_GRP.g_call_group_api;
5003
5004 IF p_detail_info_tab.COUNT > 0 THEN
5005 l_create_for_wms := TRUE;
5006 ELSIF p_detail_IN_rec.quantity = 1
5007 AND ( p_detail_IN_rec.container_name IS NOT NULL) THEN
5008 l_create_one_record := TRUE;
5009 ELSIF NVL(p_detail_IN_rec.quantity,0) <=0 THEN
5010 IF l_debug_on THEN
5011 WSH_DEBUG_SV.log(l_module_name,
5012 'Invalid quantity', p_detail_IN_rec.quantity);
5013 END IF;
5014 raise fnd_api.g_exc_error;
5015 ELSE
5016 l_generate := TRUE;
5017 END IF;
5018
5019 IF l_generate OR l_create_one_record THEN --{
5020
5021 -- This portion creates or generates containers for non-wms callers
5022
5023 --validate the container item, and org bmso
5024
5025 l_verify_org_level := WSH_ACTIONS_LEVELS.g_validation_level_tab(WSH_ACTIONS_LEVELS.C_CONTAINER_ORG_LVL);
5026
5027 l_verify_cont_item := WSH_ACTIONS_LEVELS.g_validation_level_tab(WSH_ACTIONS_LEVELS.C_CONT_ITEM_LVL);
5028
5029 l_organization_id := p_detail_IN_rec.organization_id;
5030 l_organization_code := p_detail_IN_rec.organization_code;
5031 --
5032 IF l_verify_org_level = 1 THEN --{
5033 --
5034 WSH_UTIL_VALIDATE.Validate_Org (l_organization_id,
5035 l_organization_code,
5036 l_return_status);
5037 IF l_return_status NOT IN ( wsh_util_core.g_ret_sts_success ,WSH_UTIL_CORE.G_RET_STS_WARNING)
5038 THEN
5039 fnd_message.set_name('WSH', 'WSH_OI_INVALID_ORG');
5040 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5041 END IF;
5042
5043 wsh_util_core.api_post_call(
5044 p_return_status => l_return_status,
5045 x_num_warnings => l_number_of_warnings,
5046 x_num_errors => l_number_of_errors
5047 );
5048
5049 END IF; --}
5050 --
5051 -- validate item
5052 l_cont_item_id := p_detail_IN_rec.container_item_id;
5053 l_cont_item_seg := p_detail_IN_rec.container_item_seg;
5054 l_cont_item_name := p_detail_IN_rec.container_item_name;
5055 --
5056 IF l_verify_cont_item = 1 THEN --{
5057 -- wms change: Validate Item check is to be skipped if the
5058 -- Org. is WMS enabled
5059
5060 IF l_debug_on THEN
5061 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WMS_INSTALL.CHECK_INSTALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5062 END IF;
5063
5064 l_wms_enabled := WMS_INSTALL.check_install(
5065 l_wms_return_status,
5066 l_wms_msg_count,
5067 l_wms_msg_data,
5068 l_organization_id);
5069
5070 wsh_util_core.api_post_call(
5071 p_return_status => l_wms_return_status,
5072 x_num_warnings => l_number_of_warnings,
5073 x_num_errors => l_number_of_errors
5074 );
5075
5076 IF l_debug_on THEN
5077 wsh_debug_sv.log(l_module_name, 'wms enabled',
5078 l_wms_enabled);
5079 END IF;
5080 IF (l_wms_enabled = FALSE) THEN --{
5081 IF (l_cont_item_id IS NULL
5082 AND l_cont_item_name IS NULL
5083 AND l_cont_item_seg.count = 0) then --{
5084 fnd_message.set_name('WSH', 'WSH_CONT_INVALID_ITEM');
5085 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
5086 RAISE e_NO_INV_ITEM;
5087 ELSE --}{
5088 --
5089 WSH_UTIL_VALIDATE.Validate_Item
5090 (p_inventory_item_id => l_cont_item_id,
5091 p_inventory_item => l_cont_item_name,
5092 p_organization_id => l_organization_id,
5093 p_seg_array => l_cont_item_seg,
5094 x_return_status => l_return_status,
5095 p_item_type => 'CONT_ITEM');
5096 IF l_return_status NOT IN ( WSH_UTIL_CORE.G_RET_STS_SUCCESS, WSH_UTIL_CORE.G_RET_STS_WARNING)
5097 THEN
5098 fnd_message.set_name('WSH', 'WSH_CONT_INVALID_ITEM');
5099 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
5100 wsh_util_core.api_post_call(
5101 p_return_status => l_return_status,
5102 x_num_warnings => l_number_of_warnings,
5103 x_num_errors => l_number_of_errors
5104 );
5105 END IF;
5106 END IF; --}
5107 ELSE --}{
5108 fnd_message.set_name('WSH', 'WSH_INCORRECT_ORG');
5109 fnd_message.set_token('ORG_CODE', l_organization_code);
5110 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5111 RAISE FND_API.G_EXC_ERROR;
5112 END IF; -- wms_enabled }
5113 END IF; -- verify item}
5114 --
5115
5116 IF l_generate THEN --{
5117 IF c_wms_code_present = 'Y' THEN --{
5118
5119 -- calculating the parameter needed to generate container name
5120
5121 IF (p_detail_IN_rec.name_suffix IS NOT NULL)
5122 AND (NVL(p_detail_IN_rec.ucc_128_suffix_flag,2) = 1)
5123 THEN
5124 IF l_debug_on THEN
5125 wsh_debug_sv.log(l_module_name, 'Error ucc_128_suffix_flag is set to 1 and name_suffix is set to ',p_detail_IN_rec.name_suffix);
5126 END IF;
5127 FND_MESSAGE.SET_NAME('WSH', 'WSH_UCC128_ERROR'); --bmso new
5128 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5129 RAISE FND_API.G_EXC_ERROR;
5130 END IF;
5131
5132 IF p_detail_IN_rec.ucc_128_suffix_flag = 1 THEN
5133 l_suffix_length := 1;
5134 -- Also the prefix should be integer
5135 BEGIN
5136 IF TRUNC(NVL(p_detail_IN_rec.name_prefix,0))
5137 <> NVL(p_detail_IN_rec.name_prefix,0)
5138 OR TRUNC(NVL(p_detail_IN_rec.name_prefix,0)) < 0
5139 THEN
5140 FND_MESSAGE.SET_NAME('WSH', 'WSH_UCC128_PREFIX_ERR'); --bmso new
5141 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5142
5143 END IF;
5144 EXCEPTION
5145 WHEN OTHERS THEN
5146 FND_MESSAGE.SET_NAME('WSH', 'WSH_UCC128_PREFIX_ERR'); --bmso new
5147 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5148 END;
5149 ELSE
5150 l_suffix_length := NVL(LENGTH(p_detail_IN_rec.name_suffix),0);
5151 END IF;
5152
5153 OPEN c_get_default_parameters(l_organization_id);
5154 FETCH c_get_default_parameters INTO l_lpn_starting_num;
5155 CLOSE c_get_default_parameters;
5156
5157 l_base_number_dummy := NVL(p_detail_IN_rec.base_number,
5158 l_lpn_starting_num);
5159 l_new_session := TRUE;
5160 IF l_base_number_dummy IS NULL THEN --{
5161 BEGIN
5162 OPEN c_get_wms_curr_seq ;
5163 fetch c_get_wms_curr_seq INTO l_wms_sequence;
5164 CLOSE c_get_wms_curr_seq;
5165 l_base_number_dummy := l_wms_sequence + 1;
5166 EXCEPTION
5167 WHEN OTHERS THEN
5168 l_new_session := FALSE;
5169 OPEN c_get_wms_next_seq ;
5170 fetch c_get_wms_next_seq INTO l_wms_sequence;
5171 CLOSE c_get_wms_next_seq;
5172 l_base_number_dummy := l_wms_sequence;
5173 END ;
5174 END IF; --}
5175
5176 IF l_new_session THEN
5177 l_base_number_dummy := l_base_number_dummy + p_detail_IN_rec.quantity - 1;
5178 ELSE
5179 l_base_number_dummy := l_base_number_dummy + p_detail_IN_rec.quantity ;
5180 END IF;
5181
5182
5183 IF l_debug_on THEN
5184 wsh_debug_sv.log(l_module_name, 'l_lpn_starting_num',l_lpn_starting_num);
5185 wsh_debug_sv.log(l_module_name, 'l_wms_sequence',l_wms_sequence);
5186 wsh_debug_sv.log(l_module_name, 'l_base_number_dummy',l_base_number_dummy);
5187 END IF;
5188
5189 IF p_detail_IN_rec.num_digits IS NOT NULL THEN
5190 l_total_length := NVL(length(p_detail_IN_rec.name_prefix),0)
5191 + l_suffix_length
5192 + GREATEST(p_detail_IN_rec.num_digits,NVL(LENGTH(l_base_number_dummy),0));
5193 END IF;
5194
5195
5196 l_total_length := NVL(l_total_length,FND_API.G_MISS_NUM);
5197 l_name_prefix := NVL(p_detail_IN_rec.name_prefix,FND_API.G_MISS_CHAR);
5198 l_name_suffix := NVL(p_detail_IN_rec.name_suffix,FND_API.G_MISS_CHAR);
5199
5200 l_gen_lpn_rec.container_item_id := l_cont_item_id;
5201 l_gen_lpn_rec.organization_id := l_organization_id;
5202 l_gen_lpn_rec.lpn_prefix:= l_name_prefix;
5203 l_gen_lpn_rec.lpn_suffix := l_name_suffix;
5204 l_gen_lpn_rec.starting_num := p_detail_IN_rec.base_number;
5205 IF p_detail_IN_rec.base_number IS NOT NULL THEN --{
5206 IF p_detail_IN_rec.base_number <> FND_API.G_MISS_NUM THEN
5207 IF l_lpn_starting_num = p_detail_IN_rec.base_number THEN
5208 l_gen_lpn_rec.starting_num := NULL;
5209 END IF;
5210 END IF;
5211 END IF ; --}
5212 l_gen_lpn_rec.total_lpn_length := l_total_length;
5213 l_gen_lpn_rec.quantity:= p_detail_IN_rec.quantity;
5214 --l_gen_lpn_rec.caller := p_detail_IN_rec.caller;
5215 l_gen_lpn_rec.ucc_128_suffix_flag := p_detail_IN_rec.ucc_128_suffix_flag;
5216
5217 WSH_WMS_LPN_GRP.g_call_group_api := 'N';
5218 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
5219
5220 IF l_debug_on THEN
5221 wsh_debug_sv.logmsg(l_module_name, 'Calling wms_container_grp.Auto_Create_LPNs');
5222 END IF;
5223 wms_container_grp.Auto_Create_LPNs (
5224 p_api_version => 1.0
5225 , p_init_msg_list => fnd_api.g_false
5226 , p_commit => fnd_api.g_false
5227 , x_return_status => l_return_status
5228 , x_msg_count => l_wms_msg_count
5229 , x_msg_data => l_wms_msg_data
5230 , p_caller => 'WSH_GENERATE'
5231 , p_gen_lpn_rec => l_gen_lpn_rec
5232 , p_lpn_table => l_lpn_out_tab
5233 );
5234
5235 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5236 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5237
5238 wsh_util_core.api_post_call(
5239 p_return_status => l_return_status,
5240 x_num_warnings => l_number_of_warnings,
5241 x_num_errors => l_number_of_errors,
5242 p_msg_data => l_wms_msg_data
5243 );
5244 --bms get the names
5245 i := l_lpn_out_tab.FIRST;
5246 --if i null then error out bmso
5247 j := 1;
5248 IF l_debug_on THEN
5249 wsh_debug_sv.log(l_module_name, 'l_lpn_out_tab.count',l_lpn_out_tab.count);
5250 END IF;
5251 WHILE i IS NOT NULL LOOP --{
5252 l_container_info_rec.lpn_ids(j) := l_lpn_out_tab(i).lpn_id;
5253 l_container_info_rec.container_names(j) :=
5254 l_lpn_out_tab(i).license_plate_number;
5255 IF l_debug_on THEN
5256 wsh_debug_sv.log(l_module_name, 'name',
5257 l_container_info_rec.container_names(j));
5258 wsh_debug_sv.log(l_module_name, 'lpn_id',
5259 l_container_info_rec.lpn_ids(j));
5260 END IF;
5261
5262 IF l_container_info_rec.lpn_ids(j) IS NULL THEN
5263 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5264 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'LPN_ID');
5265 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5266 RAISE FND_API.G_EXC_ERROR;
5267
5268 ELSIF l_container_info_rec.container_names(j) IS NULL THEN
5269 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5270 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CONTAINER_NAME');
5271 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5272 RAISE FND_API.G_EXC_ERROR;
5273
5274 END IF;
5275
5276 i := l_lpn_out_tab.NEXT(i);
5277 j := j + 1;
5278
5279 END LOOP; --}
5280
5281 l_container_rec.weight_uom_code :=
5282 l_lpn_out_tab(1).GROSS_WEIGHT_UOM_CODE;
5283 l_container_rec.gross_weight :=
5284 l_lpn_out_tab(1).GROSS_WEIGHT;
5285 l_additional_cont_attr.tare_weight :=
5286 l_lpn_out_tab(1).TARE_WEIGHT;
5287 l_additional_cont_attr.tare_weight_uom_code :=
5288 l_lpn_out_tab(1).TARE_WEIGHT_UOM_CODE;
5289 l_container_rec.volume_uom_code :=
5290 l_lpn_out_tab(1).CONTAINER_VOLUME_UOM;
5291 l_container_rec.volume := l_lpn_out_tab(1).CONTAINER_VOLUME;
5292 l_additional_cont_attr.filled_volume_uom_code :=
5293 l_lpn_out_tab(1).CONTENT_VOLUME_UOM_CODE;
5294 l_container_rec.filled_volume := l_lpn_out_tab(1).CONTENT_VOLUME;
5295 l_container_rec.locator_id := l_lpn_out_tab(1).locator_id;
5296 l_container_rec.subinventory := l_lpn_out_tab(1).SUBINVENTORY_CODE;
5297 l_container_rec.inventory_item_id := l_cont_item_id;
5298 l_container_rec.organization_id := l_organization_id;
5299
5300 -- uncomment when the column is there
5301 --l_container_rec.volume := l_lpn_out_tab(1).CONTAINER_VOLUME;
5302 ELSE --}{
5303 /* bmso comment out this protion when WMS code is there */
5304 wsh_container_actions.Create_Multiple_Cont_name (
5305 p_cont_name => p_detail_IN_rec.container_name,
5306 p_cont_name_pre => p_detail_IN_rec.name_prefix,
5307 p_cont_name_suf => p_detail_IN_rec.name_suffix,
5308 p_cont_name_num => p_detail_IN_rec.base_number,
5309 p_cont_name_dig => p_detail_IN_rec.num_digits,
5310 p_quantity => p_detail_IN_rec.quantity,
5311 x_cont_names => l_container_info_rec.container_names,
5312 x_return_status => l_return_status
5313 );
5314 wsh_util_core.api_post_call(
5315 p_return_status => l_return_status,
5316 x_num_warnings => l_number_of_warnings,
5317 x_num_errors => l_number_of_errors
5318 );
5319 i := l_container_info_rec.container_names.FIRST;
5320 WHILE i IS NOT NULL LOOP --{
5321 l_container_info_rec.lpn_ids(i) := NULL;
5322 i := l_container_info_rec.container_names.NEXT(i);
5323 END LOOP; --} comment out till here
5324 l_container_rec.inventory_item_id := l_cont_item_id;
5325 l_container_rec.organization_id := l_organization_id;
5326 END IF; --}
5327 IF l_container_info_rec.lpn_ids.COUNT <> p_detail_IN_rec.quantity
5328 THEN
5329 RAISE e_lpn_count_invalid;
5330 END IF;
5331
5332 ELSIF l_create_one_record THEN --}{
5333 --bmso
5334 IF c_wms_code_present = 'Y' THEN --{
5335 IF l_debug_on THEN
5336 wsh_debug_sv.logmsg(l_module_name, 'Calling wms_container_grp.create_lpns');
5337 END IF;
5338 l_lpn_table(1).license_plate_number :=
5339 p_detail_IN_rec.container_name;
5340 l_lpn_table(1).inventory_item_id := l_cont_item_id;
5341 l_lpn_table(1).organization_id := l_organization_id;
5342 --l_lpn_table(1).ucc_128_suffix_flag :=
5343 --p_detail_IN_rec.ucc_128_suffix_flag;
5344
5345 WSH_WMS_LPN_GRP.g_call_group_api := 'N';
5346 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
5347
5348 wms_container_grp.create_lpns(
5349 p_api_version => 1.0,
5350 p_init_msg_list => fnd_api.g_false,
5351 p_commit => fnd_api.g_false,
5352 x_return_status => l_return_status,
5353 x_msg_count => l_wms_msg_count,
5354 x_msg_data => l_wms_msg_data,
5355 p_caller => 'WSH_CREATE',
5356 p_lpn_table => l_lpn_table
5357 );
5358 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5359 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5360
5361 wsh_util_core.api_post_call(
5362 p_return_status => l_return_status,
5363 x_num_warnings => l_number_of_warnings,
5364 x_num_errors => l_number_of_errors,
5365 p_msg_data => l_wms_msg_data
5366 );
5367 l_container_info_rec.container_names(1) := l_lpn_table(1).license_plate_number;
5368 l_container_info_rec.lpn_ids(1) := l_lpn_table(1).lpn_id;
5369
5370 IF l_container_info_rec.lpn_ids(1) IS NULL THEN
5371 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5372 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'LPN_ID');
5373 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5374 RAISE FND_API.G_EXC_ERROR;
5375
5376 ELSIF l_container_info_rec.container_names(1) IS NULL THEN
5377 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5378 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CONTAINER_NAME');
5379 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5380 RAISE FND_API.G_EXC_ERROR;
5381
5382 END IF;
5383
5384 l_container_rec.weight_uom_code :=
5385 l_lpn_table(1).GROSS_WEIGHT_UOM_CODE;
5386 l_container_rec.gross_weight :=
5387 l_lpn_table(1).GROSS_WEIGHT;
5388 l_additional_cont_attr.tare_weight :=
5389 l_lpn_table(1).TARE_WEIGHT;
5390 l_additional_cont_attr.tare_weight_uom_code :=
5391 l_lpn_table(1).TARE_WEIGHT_UOM_CODE;
5392
5393 l_container_rec.locator_id := l_lpn_table(1).locator_id;
5394 l_container_rec.subinventory := l_lpn_table(1).SUBINVENTORY_CODE;
5395 l_container_rec.volume_uom_code :=
5396 l_lpn_table(1).CONTAINER_VOLUME_UOM;
5397 l_additional_cont_attr.filled_volume_uom_code :=
5398 l_lpn_table(1).CONTENT_VOLUME_UOM_CODE;
5399 l_container_rec.filled_volume := l_lpn_table(1).CONTENT_VOLUME;
5400 l_container_rec.volume := l_lpn_table(1).CONTAINER_VOLUME;
5401 l_container_rec.inventory_item_id := l_cont_item_id;
5402 l_container_rec.organization_id := l_organization_id;
5403
5404 ELSE --}{
5405 /* COMMENT THIS PART ONCE WMS CODE IS AVAILABLE */
5406 wsh_container_actions.Create_Multiple_Cont_name (
5407 p_cont_name => p_detail_IN_rec.container_name,
5408 p_cont_name_pre => NULL,
5409 p_cont_name_suf => NULL,
5410 p_cont_name_num => NULL,
5411 p_cont_name_dig => NULL,
5412 p_quantity => p_detail_IN_rec.quantity,
5413 x_cont_names => l_container_info_rec.container_names,
5414 x_return_status => l_return_status
5415 );
5416 wsh_util_core.api_post_call(
5417 p_return_status => l_return_status,
5418 x_num_warnings => l_number_of_warnings,
5419 x_num_errors => l_number_of_errors
5420 );
5421 l_container_info_rec.lpn_ids(1) := NULL;
5422 l_container_rec.inventory_item_id := l_cont_item_id;
5423 l_container_rec.organization_id := l_organization_id;
5424 END IF; --}
5425 END IF; --}
5426 wsh_container_actions.default_container_attr(l_container_rec,
5427 l_additional_cont_attr,
5428 p_detail_IN_rec.caller,
5429 l_return_status);
5430 wsh_util_core.api_post_call(
5431 p_return_status => l_return_status,
5432 x_num_warnings => l_number_of_warnings,
5433 x_num_errors => l_number_of_errors
5434 );
5435 WSH_DELIVERY_DETAILS_PKG.create_delivery_details_bulk
5436 ( p_delivery_details_info => l_container_rec,
5437 p_num_of_rec => p_detail_IN_rec.quantity,
5438 p_container_info_rec => l_container_info_rec,
5439 x_return_status => l_return_status,
5440 x_dd_id_tab => l_cont_dummy_tab
5441 );
5442
5443 IF l_return_status IN
5444 (WSH_UTIL_CORE.G_RET_STS_ERROR,
5445 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ) THEN
5446 --
5447 IF l_debug_on THEN
5448 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR CREATING CONTAINER');
5449 END IF;
5450 --
5451 FND_MESSAGE.SET_NAME('WSH','WSH_CONT_CREATE_ERROR');
5452 WSH_UTIL_CORE.Add_Message(l_return_status,l_module_name);
5453 RAISE FND_API.G_EXC_ERROR;
5454 END IF;
5455
5456 IF l_debug_on THEN
5457 WSH_DEBUG_SV.log(l_module_name,'COUNT OF WDD RECORDS',
5458 l_cont_dummy_tab.count);
5459 END IF;
5460
5461 wsh_util_core.api_post_call(
5462 p_return_status => l_return_status,
5463 x_num_warnings => l_number_of_warnings,
5464 x_num_errors => l_number_of_errors
5465 );
5466
5467 WSH_DELIVERY_DETAILS_PKG.create_deliv_assignment_bulk
5468 ( p_delivery_assignments_info => l_del_assg_rec,
5469 p_num_of_rec => p_detail_IN_rec.quantity,
5470 p_dd_id_tab => l_cont_dummy_tab,
5471 x_da_id_tab => l_assignment_dummy_tab,
5472 x_return_status => l_return_status
5473 );
5474
5475 IF l_debug_on THEN
5476 WSH_DEBUG_SV.log(l_module_name,'COUNT OF WDA RECORDS',
5477 l_assignment_dummy_tab.count);
5478 WSH_DEBUG_SV.log(l_module_name,'Return Status',l_return_status);
5479 END IF;
5480
5481 IF (l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
5482 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)) THEN
5483 FND_MESSAGE.SET_NAME('WSH','WSH_CONT_CREATE_ERROR');
5484 WSH_UTIL_CORE.Add_Message(l_return_status,l_module_name);
5485 RAISE FND_API.G_EXC_ERROR;
5486 END IF;
5487
5488
5489 wsh_util_core.api_post_call(
5490 p_return_status => l_return_status,
5491 x_num_warnings => l_number_of_warnings,
5492 x_num_errors => l_number_of_errors
5493 );
5494
5495 ELSIF l_create_for_wms THEN --}{
5496 -- Create container for WMS callers
5497 i := p_detail_info_tab.FIRST;
5498 WHILE i IS NOT NULL LOOP --{
5499 IF p_detail_info_tab(i).organization_id IS NULL THEN --{
5500 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5501 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'ORGANIZATION_ID');
5502 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5503 IF l_debug_on THEN
5504 wsh_debug_sv.log(l_module_name,'ERROR organization id is null for', p_detail_info_tab(i).lpn_id);
5505 END IF;
5506
5507 raise FND_API.G_EXC_ERROR;
5508
5509 END IF; --}
5510 IF p_detail_info_tab(i).lpn_id IS NULL THEN
5511 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5512 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'LPN_ID');
5513 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5514 RAISE FND_API.G_EXC_ERROR;
5515
5516 ELSIF p_detail_info_tab(i).container_name IS NULL THEN
5517 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5518 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CONTAINER_NAME');
5519 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5520 RAISE FND_API.G_EXC_ERROR;
5521
5522 END IF;
5523
5524 l_container_info_rec.lpn_ids(1) := p_detail_info_tab(i).lpn_id;
5525 l_container_info_rec.container_names(1) := p_detail_info_tab(i).container_name;
5526 l_container_rec := p_detail_info_tab(i);
5527 l_additional_cont_attr.filled_volume_uom_code := p_detail_info_tab(i).volume_uom_code;
5528
5529 /*IF l_container_rec.organization_id IS NULL THEN
5530
5531 IF l_debug_on THEN
5532 WSH_DEBUG_SV.logmsg(l_module_name,
5533 'organization is not passed');
5534 END IF;
5535 RAISE FND_API.G_EXC_ERROR;
5536 END IF; */
5537
5538 wsh_container_actions.default_container_attr(l_container_rec,
5539 l_additional_cont_attr,
5540 p_detail_IN_rec.caller,
5541 l_return_status);
5542 wsh_util_core.api_post_call(
5543 p_return_status => l_return_status,
5544 x_num_warnings => l_number_of_warnings,
5545 x_num_errors => l_number_of_errors
5546 );
5547 WSH_DELIVERY_DETAILS_PKG.create_delivery_details_bulk
5548 ( p_delivery_details_info => l_container_rec,
5549 p_num_of_rec => 1,
5550 p_container_info_rec => l_container_info_rec,
5551 x_return_status => l_return_status,
5552 x_dd_id_tab => l_cont_dummy_tab
5553 );
5554
5555 IF l_return_status IN
5556 (WSH_UTIL_CORE.G_RET_STS_ERROR,
5557 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ) THEN
5558 --
5559 IF l_debug_on THEN
5560 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR CREATING CONTAINER');
5561 END IF;
5562 --
5563 FND_MESSAGE.SET_NAME('WSH','WSH_CONT_CREATE_ERROR');
5564 WSH_UTIL_CORE.Add_Message(l_return_status,l_module_name);
5565 RAISE FND_API.G_EXC_ERROR;
5566 END IF;
5567
5568 IF l_debug_on THEN
5569 WSH_DEBUG_SV.log(l_module_name,'COUNT OF WDD RECORDS',
5570 l_cont_dummy_tab.count);
5571 END IF;
5572
5573 wsh_util_core.api_post_call(
5574 p_return_status => l_return_status,
5575 x_num_warnings => l_number_of_warnings,
5576 x_num_errors => l_number_of_errors
5577 );
5578
5579 WSH_DELIVERY_DETAILS_PKG.create_deliv_assignment_bulk
5580 ( p_delivery_assignments_info => l_del_assg_rec,
5581 p_num_of_rec => 1,
5582 p_dd_id_tab => l_cont_dummy_tab,
5583 x_da_id_tab => l_assignment_dummy_tab,
5584 x_return_status => l_return_status
5585 );
5586
5587 IF l_debug_on THEN
5588 WSH_DEBUG_SV.log(l_module_name,'COUNT OF WDA RECORDS',
5589 l_assignment_dummy_tab.count);
5590 WSH_DEBUG_SV.log(l_module_name,'Return Status',l_return_status);
5591 END IF;
5592
5593 IF (l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
5594 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)) THEN
5595 FND_MESSAGE.SET_NAME('WSH','WSH_CONT_CREATE_ERROR');
5596 WSH_UTIL_CORE.Add_Message(l_return_status,l_module_name);
5597 RAISE FND_API.G_EXC_ERROR;
5598 END IF;
5599 --
5600 wsh_util_core.api_post_call(
5601 p_return_status => l_return_status,
5602 x_num_warnings => l_number_of_warnings,
5603 x_num_errors => l_number_of_errors
5604 );
5605
5606 i:= p_detail_info_tab.NEXT(i);
5607
5608 END LOOP; --}
5609 END IF; --}
5610
5611
5612 x_container_ids := l_cont_dummy_tab;
5613
5614 IF l_number_of_errors > 0
5615 THEN
5616 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5617 ELSIF l_number_of_warnings > 0
5618 THEN
5619 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5620 ELSE
5621 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5622 END IF;
5623
5624 IF l_debug_on THEN
5625 WSH_DEBUG_SV.pop(l_module_name);
5626 END IF;
5627
5628 EXCEPTION
5629 WHEN e_NO_INV_ITEM then
5630 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5631 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5632
5633 rollback to s_create_containers_DDGPB;
5634 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5635 IF l_debug_on THEN
5636 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:e_NO_INV_ITEM');
5637 END IF;
5638 WHEN e_lpn_count_invalid then
5639 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5640 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5641
5642 rollback to s_create_containers_DDGPB;
5643 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5644 fnd_message.set_name('WSH', 'WSH_LPN_COUNT_INVALID');
5645 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
5646 IF l_debug_on THEN
5647 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:e_lpn_count_invalid');
5648 END IF;
5649 --
5650
5651 WHEN FND_API.G_EXC_ERROR THEN
5652 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5653 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5654
5655 rollback to s_create_containers_DDGPB;
5656 x_return_status := FND_API.G_RET_STS_ERROR ;
5657 IF l_debug_on THEN
5658 WSH_DEBUG_SV.logmsg(l_module_name,
5659 'FND_API.G_EXC_ERROR exception has occured.',
5660 WSH_DEBUG_SV.C_EXCEP_LEVEL);
5661 WSH_DEBUG_SV.pop(l_module_name,
5662 'EXCEPTION:FND_API.G_EXC_ERROR');
5663 END IF;
5664 --
5665 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5666 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5667 rollback to s_create_containers_DDGPB;
5668 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5669
5670 IF l_debug_on THEN
5671 WSH_DEBUG_SV.logmsg(l_module_name
5672 ,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.'
5673 ,WSH_DEBUG_SV.C_EXCEP_LEVEL);
5674 WSH_DEBUG_SV.pop(l_module_name
5675 ,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
5676 END IF;
5677 --
5678 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
5679 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5680 WSH_WMS_LPN_GRP.g_update_to_container := l_update_container_orig;
5681
5682 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5683 IF l_debug_on THEN
5684 WSH_DEBUG_SV.logmsg(l_module_name
5685 ,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured '
5686 ,WSH_DEBUG_SV.C_EXCEP_LEVEL);
5687 WSH_DEBUG_SV.pop(l_module_name
5688 ,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
5689 END IF;
5690 WHEN OTHERS THEN
5691 WSH_WMS_LPN_GRP.g_call_group_api := l_orig_value;
5692 rollback to s_create_containers_DDGPB;
5693 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5694 wsh_util_core.add_message(x_return_status, l_module_name);
5695 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Create_containers');
5696 IF l_debug_on THEN
5697 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5698 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5699 END IF;
5700
5701 END Create_containers;
5702
5703 -- ---------------------------------------------------------------------
5704 -- Procedure: Create_Delivery_Detail
5705 --
5706 -- Parameters:
5707 --
5708 -- Description: This local procedure is the new API for wrapping the logic of CREATE of delivery details
5709 -- Created: Harmonization Project. Patchset I
5710 -- -----------------------------------------------------------------------
5711
5712 PROCEDURE Create_Delivery_Detail(
5713 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
5714 p_detail_IN_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
5715 p_valid_index_tab IN wsh_util_core.id_tab_type,
5716 x_detail_OUT_rec OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.detailOutRecType,
5717 x_return_status OUT NOCOPY varchar2,
5718 x_msg_count OUT NOCOPY NUMBER,
5719 x_msg_data OUT NOCOPY VARCHAR2)
5720 IS
5721
5722 l_api_name CONSTANT VARCHAR2(30) := 'Create_Delivery_Detail';
5723 l_api_version CONSTANT NUMBER := 1.0;
5724 l_init_msg_list VARCHAR2(100);
5725 l_commit VARCHAR2(100);
5726
5727 --
5728 l_return_status VARCHAR2(32767);
5729 l_msg_count NUMBER;
5730 l_msg_data VARCHAR2(32767);
5731 l_program_name VARCHAR2(32767);
5732
5733 l_number_of_errors NUMBER := 0;
5734 l_number_of_warnings NUMBER := 0;
5735 --
5736 l_index NUMBER;
5737 l_new_detail_id NUMBER;
5738 l_dummy_rowid VARCHAR2(32767);
5739 l_dummy_assgn_rowid VARCHAR2(32767);
5740 l_delivery_assignment_id NUMBER;
5741 l_delivery_assignments_info WSH_DELIVERY_DETAILS_PKG.Delivery_Assignments_Rec_Type;
5742 l_item_type VARCHAR2(30);
5743
5744 l_validation_level NUMBER;
5745
5746 --OTM R12
5747 l_delivery_detail_tab WSH_ENTITY_INFO_TAB;
5748 l_delivery_detail_rec WSH_ENTITY_INFO_REC;
5749 l_item_quantity_uom_tab WSH_UTIL_CORE.COLUMN_TAB_TYPE;
5750 l_gc3_is_installed VARCHAR2(1);
5751 l_counter NUMBER;
5752 --
5753
5754 --
5755 l_debug_on BOOLEAN;
5756 --
5757 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_DELIVERY_DETAIL';
5758
5759 --
5760 BEGIN
5761 --
5762 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5763 --
5764 IF l_debug_on IS NULL
5765 THEN
5766 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5767 END IF;
5768 --
5769 SAVEPOINT CREATE_DEL_DETAIL_GRP;
5770
5771 IF l_debug_on THEN
5772 WSH_DEBUG_SV.push(l_module_name);
5773 WSH_DEBUG_SV.log(l_module_name, 'container_item_id',p_detail_IN_rec.container_item_id);
5774 WSH_DEBUG_SV.log(l_module_name, 'container_item_name',p_detail_IN_rec.container_item_name);
5775 WSH_DEBUG_SV.log(l_module_name, 'organization_id', p_detail_IN_rec.organization_id);
5776 WSH_DEBUG_SV.log(l_module_name, 'organization_code',p_detail_IN_rec.organization_code);
5777 WSH_DEBUG_SV.log(l_module_name, 'name_prefix', p_detail_IN_rec.name_prefix);
5778 WSH_DEBUG_SV.log(l_module_name, 'name_suffix', p_detail_IN_rec.name_suffix);
5779 WSH_DEBUG_SV.log(l_module_name, 'base number', p_detail_IN_rec.base_number);
5780 WSH_DEBUG_SV.log(l_module_name, 'Num Digits', p_detail_IN_rec.num_digits);
5781 WSH_DEBUG_SV.log(l_module_name, 'Quantity', p_detail_IN_rec.quantity);
5782 WSH_DEBUG_SV.log(l_module_name, 'Container Name', p_detail_IN_rec.container_name);
5783 WSH_DEBUG_SV.log(l_module_name, 'Lpn Ids Count', p_detail_In_rec.lpn_ids.count);
5784 WSH_DEBUG_SV.log(l_module_name, 'Caller', p_detail_in_rec.caller);
5785 END IF;
5786 --
5787
5788 -- Initialize API return status to success
5789 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5790 l_number_of_errors := 0;
5791 l_number_of_warnings := 0;
5792
5793 --OTM R12 initialize
5794 l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
5795
5796 IF (l_gc3_is_installed IS NULL) THEN
5797 l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
5798 END IF;
5799
5800 IF (l_gc3_is_installed = 'Y') THEN
5801 l_delivery_detail_tab := WSH_ENTITY_INFO_TAB();
5802 END IF;
5803 l_counter := 1;
5804 --
5805
5806 l_index := p_valid_index_tab.FIRST;
5807
5808 IF(l_index IS NULL) OR nvl(WSH_WMS_LPN_GRP.g_caller,'WSH') like 'WMS%' THEN --{
5809
5810 -- logic for creating containers
5811 IF nvl(WSH_WMS_LPN_GRP.g_caller,'WSH') NOT LIKE 'WMS%' THEN --{
5812 IF( p_detail_IN_rec.organization_id IS NULL and p_detail_IN_rec.organization_code IS NULL) THEN
5813 FND_MESSAGE.SET_NAME('WSH', 'WSH_CONT_ORG_NULL');
5814 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5815 IF l_debug_on THEN
5816 wsh_debug_sv.logmsg(l_module_name,'Null Organization');
5817 END IF;
5818 raise FND_API.G_EXC_ERROR;
5819 ELSIF(p_detail_IN_rec.container_item_id IS NULL
5820 AND p_detail_IN_rec.container_item_name IS NULL
5821 AND p_detail_IN_rec.container_item_seg.count = 0) THEN
5822 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
5823 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CONTAINER_ITEM');
5824 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5825 IF l_debug_on THEN
5826 wsh_debug_sv.logmsg(l_module_name,'Null Container item');
5827 END IF;
5828
5829 raise FND_API.G_EXC_ERROR;
5830
5831 END IF;
5832 END IF; --}
5833
5834 Create_containers(
5835 p_detail_info_tab => p_detail_info_tab,
5836 p_detail_IN_rec => p_detail_IN_rec,
5837 x_container_ids => x_detail_out_rec.detail_ids,
5838 x_return_status => l_return_status
5839 );
5840 wsh_util_core.api_post_call(
5841 p_return_status => l_return_status,
5842 x_num_warnings => l_number_of_warnings,
5843 x_num_errors => l_number_of_errors
5844 );
5845 ELSE --}{
5846 WHILE l_index IS NOT NULL
5847 LOOP --{
5848 --
5849 IF(p_detail_info_tab(l_index).container_flag in ('Y', 'C')) THEN
5850 IF l_debug_on THEN
5851 wsh_debug_sv.logmsg(l_module_name,'Container Flag Yes ');
5852 END IF;
5853 RAISE FND_API.G_EXC_ERROR;
5854 END IF;
5855
5856 IF p_detail_info_tab(l_index).inventory_item_id IS NOT NULL THEN --{
5857 -- Validate Item and see if this is container item
5858 -- Error out if this is a container item
5859
5860 IF l_debug_on THEN
5861 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.FIND_ITEM_TYPE',WSH_DEBUG_SV.C_PROC_LEVEL);
5862 END IF;
5863
5864 WSH_UTIL_VALIDATE.Find_Item_Type
5865 (
5866 p_inventory_item_id => p_detail_info_tab(l_index).inventory_item_id,
5867 p_organization_id => p_detail_info_tab(l_index).organization_id,
5868 x_item_type => l_item_type,
5869 x_return_status => l_return_status
5870 );
5871
5872 IF l_debug_on THEN
5873 wsh_debug_sv.log(l_module_name, 'Item Type', l_item_type);
5874 END IF;
5875 --
5876 wsh_util_core.api_post_call(
5877 p_return_status => l_return_status,
5878 x_num_warnings => l_number_of_warnings,
5879 x_num_errors => l_number_of_errors,
5880 p_msg_data => l_msg_data
5881 );
5882
5883 IF(nvl(l_item_type, 'FND_API.G_MISS_CHAR') = 'CONT_ITEM') THEN
5884 IF l_debug_on THEN
5885 wsh_debug_sv.logmsg(l_module_name,'Container Item');
5886 END IF;
5887 RAISE FND_API.G_EXC_ERROR;
5888 END IF;
5889 END IF; --}
5890
5891
5892 IF l_debug_on THEN
5893 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.CREATE_DELIVERY_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
5894 END IF;
5895 --
5896 WSH_DELIVERY_DETAILS_PKG.create_delivery_details(
5897 p_delivery_details_info => p_detail_info_tab(l_index),
5898 x_rowid => l_dummy_rowid,
5899 x_delivery_detail_id => l_new_detail_id,
5900 x_return_status => l_return_status);
5901
5902 IF l_debug_on THEN
5903 wsh_debug_sv.log(l_module_name, 'New Detail Created', l_new_detail_id);
5904 END IF;
5905
5906 --
5907 wsh_util_core.api_post_call(
5908 p_return_status => l_return_status,
5909 x_num_warnings => l_number_of_warnings,
5910 x_num_errors => l_number_of_errors,
5911 p_msg_data => l_msg_data,
5912 p_raise_error_flag => FALSE
5913 );
5914 --
5915 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
5916 FND_MESSAGE.SET_NAME('WSH', 'WSH_DET_CREATE_DET_FAILED');
5917 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5918 RAISE FND_API.G_EXC_ERROR;
5919 END IF;
5920 l_delivery_assignments_info.delivery_id := NULL;
5921 l_delivery_assignments_info.parent_delivery_id := NULL;
5922 l_delivery_assignments_info.delivery_detail_id := l_new_detail_id;
5923 l_delivery_assignments_info.parent_delivery_detail_id := NULL;
5924
5925
5926 IF l_debug_on THEN
5927 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.CREATE_DELIVERY_ASSIGNMENTS',WSH_DEBUG_SV.C_PROC_LEVEL);
5928 END IF;
5929 --
5930 WSH_DELIVERY_DETAILS_PKG.Create_Delivery_Assignments(
5931 p_delivery_assignments_info => l_delivery_assignments_info,
5932 x_rowid => l_dummy_assgn_rowid,
5933 x_delivery_assignment_id => l_delivery_assignment_id,
5934 x_return_status => l_return_status);
5935
5936 x_detail_out_Rec.detail_ids(l_index) := l_new_detail_id;
5937
5938 wsh_util_core.api_post_call(
5939 p_return_status => l_return_status,
5940 x_num_warnings => l_number_of_warnings,
5941 x_num_errors => l_number_of_errors,
5942 p_msg_data => l_msg_data,
5943 p_raise_error_flag => FALSE
5944 );
5945
5946 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
5947 FND_MESSAGE.SET_NAME('WSH', 'WSH_DET_CREATE_AS_FAILED');
5948 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
5949 RAISE FND_API.G_EXC_ERROR;
5950 END IF;
5951
5952 --OTM R12, calling delivery detail splitter
5953 IF (l_gc3_is_installed = 'Y') THEN
5954
5955 IF l_debug_on THEN
5956 WSH_DEBUG_SV.log(l_module_name,'Delivery detail number',l_index);
5957 WSH_DEBUG_SV.log(l_module_name,'Delivery detail count',l_counter);
5958 WSH_DEBUG_SV.log(l_module_name,'delivery detail id',l_new_detail_id);
5959 WSH_DEBUG_SV.log(l_module_name,'inventory item id',p_detail_info_tab(l_index).inventory_item_id);
5960 WSH_DEBUG_SV.log(l_module_name,'net weight',p_detail_info_tab(l_index).net_weight);
5961 WSH_DEBUG_SV.log(l_module_name,'organization id',p_detail_info_tab(l_index).organization_id);
5962 WSH_DEBUG_SV.log(l_module_name,'weight uom code',p_detail_info_tab(l_index).weight_uom_code);
5963 WSH_DEBUG_SV.log(l_module_name,'requested quantity',p_detail_info_tab(l_index).requested_quantity);
5964 WSH_DEBUG_SV.log(l_module_name,'ship from location id',p_detail_info_tab(l_index).ship_from_location_id);
5965 WSH_DEBUG_SV.log(l_module_name,'requested quantity uom',p_detail_info_tab(l_index).requested_quantity_uom);
5966 END IF;
5967
5968 --prepare table of delivery detail information to call splitter
5969 l_delivery_detail_tab.EXTEND;
5970 l_delivery_detail_tab(l_counter) := WSH_ENTITY_INFO_REC(l_new_detail_id,
5971 NULL,
5972 p_detail_info_tab(l_index).inventory_item_id,
5973 p_detail_info_tab(l_index).net_weight,
5974 0,
5975 p_detail_info_tab(l_index).organization_id,
5976 p_detail_info_tab(l_index).weight_uom_code,
5977 p_detail_info_tab(l_index).requested_quantity,
5978 p_detail_info_tab(l_index).ship_from_location_id,
5979 NULL);
5980 l_item_quantity_uom_tab(l_counter) := p_detail_info_tab(l_index).requested_quantity_uom;
5981 l_counter := l_counter + 1;
5982 END IF;
5983 --END OTM R12
5984
5985 l_index := p_valid_index_tab.NEXT(l_index);
5986 --
5987 END LOOP; -- while l_index is not null }
5988
5989 --OTM R12, after loop call split with all the data
5990 IF (l_counter > 1) THEN
5991
5992 IF l_debug_on THEN
5993 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_SPLITTER.tms_delivery_detail_split',WSH_DEBUG_SV.C_PROC_LEVEL);
5994 END IF;
5995
5996 WSH_DELIVERY_DETAILS_SPLITTER.tms_delivery_detail_split(
5997 p_detail_tab => l_delivery_detail_tab,
5998 p_item_quantity_uom_tab => l_item_quantity_uom_tab,
5999 x_return_status => l_return_status);
6000
6001 IF l_debug_on THEN
6002 WSH_DEBUG_SV.logmsg(l_module_name, 'return status from WSH_DELIVERY_DETAILS_SPLITTER.tms_delivery_detail_split: ' || l_return_status);
6003 END IF;
6004
6005 -- we will not fail based on l_return_status here because
6006 -- we do not want to stop the flow
6007 -- if the detail doesn't split, it will be caught later in
6008 -- delivery splitting and will have exception on the detail
6009 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6010 IF l_debug_on THEN
6011 WSH_DEBUG_SV.logmsg(l_module_name, 'Delivery detail split failed for ' || l_new_detail_id );
6012 END IF;
6013 END IF;
6014 END IF;
6015 --END OTM R12
6016 END IF; --}
6017 FND_MSG_PUB.Count_And_Get
6018 (
6019 p_count => x_msg_count,
6020 p_data => x_msg_data,
6021 p_encoded => FND_API.G_FALSE
6022 );
6023
6024 -- Debug Statements
6025 --
6026 IF l_debug_on THEN
6027 WSH_DEBUG_SV.pop(l_module_name);
6028 END IF;
6029 --
6030 EXCEPTION
6031 WHEN FND_API.G_EXC_ERROR THEN
6032 ROLLBACK to CREATE_DEL_DETAIL_GRP;
6033 x_return_status := FND_API.G_RET_STS_ERROR ;
6034 FND_MSG_PUB.Count_And_Get
6035 (
6036 p_count => x_msg_count,
6037 p_data => x_msg_data,
6038 p_encoded => FND_API.G_FALSE
6039 );
6040
6041 IF l_debug_on THEN
6042 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6043 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
6044 END IF;
6045 --
6046 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6047 ROLLBACK to CREATE_DEL_DETAIL_GRP;
6048 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6049 FND_MSG_PUB.Count_And_Get
6050 (
6051 p_count => x_msg_count,
6052 p_data => x_msg_data,
6053 p_encoded => FND_API.G_FALSE
6054 );
6055
6056 IF l_debug_on THEN
6057 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6058 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
6059 END IF;
6060 --
6061 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
6062 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6063 FND_MSG_PUB.Count_And_Get
6064 (
6065 p_count => x_msg_count,
6066 p_data => x_msg_data,
6067 p_encoded => FND_API.G_FALSE
6068 );
6069 --
6070 IF l_debug_on THEN
6071 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6072 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
6073 END IF;
6074 --
6075 WHEN OTHERS THEN
6076
6077 ROLLBACK to CREATE_DEL_DETAIL_GRP;
6078 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6079 wsh_util_core.add_message(x_return_status, l_module_name);
6080 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Create_Delivery_Detail');
6081 FND_MSG_PUB.Count_And_Get
6082 (
6083 p_count => x_msg_count,
6084 p_data => x_msg_data,
6085 p_encoded => FND_API.G_FALSE
6086 );
6087
6088 IF l_debug_on THEN
6089 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6090 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6091 END IF;
6092 --
6093 END Create_Delivery_Detail;
6094
6095 -- anxsharm for Load Tender
6096 -- added a new out parameter x_detail_tender_tab
6097 -- This table of id will have the delivery detail ids
6098 -- for which the weight or volume or delivery or parent_detail
6099 -- or picked/shipped quantity have changed.
6100 -- ---------------------------------------------------------------------
6101 -- Procedure: Validate_Delivery_Detail
6102 --
6103 -- Parameters:
6104 --
6105 -- Description: This local procedure is the new API for wrapping the logic of VALIDATE of delivery details
6106 -- Created: Harmonization Project. Patchset I
6107 -- -----------------------------------------------------------------------
6108
6109 -- frontport bug 5055682
6110 -- ---------------------------------------------------------------------
6111 -- Behavior for Serial Numbers :
6112 -- 1) If single serial number is passed as part of p_in_detail_rec, then
6113 -- serial number will be stamped on wdd table.
6114 -- 2) If single/multiple serial number(s) is passed as p_serial_range_tab,
6115 -- then serial number(s) will be inserted into msnt table and
6116 -- transaction_temp_id will be stamped on wdd table.
6117 -- 3) If multiple serial numbers are passed as part of p_in_detail_rec,
6118 -- then serial numbers will be inserted into msnt table and
6119 -- transaction_temp_id will be stamped on wdd table.
6120 -- -----------------------------------------------------------------------
6121
6122 PROCEDURE Validate_Delivery_Detail(
6123 x_detail_info_tab IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
6124 p_in_detail_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
6125 p_action IN VARCHAR2,
6126 p_validation_tab IN wsh_util_core.id_tab_type,
6127 p_caller IN VARCHAR2,
6128 x_valid_index_tab OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
6129 x_details_marked OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
6130 x_detail_tender_tab OUT NOCOPY wsh_util_core.id_tab_type,
6131 x_return_status OUT NOCOPY VARCHAR2,
6132 x_msg_count OUT NOCOPY NUMBER,
6133 x_msg_data OUT NOCOPY VARCHAR2,
6134 p_in_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
6135 p_serial_range_tab IN WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType
6136 ) IS
6137
6138
6139 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Delivery_Detail';
6140 l_api_version CONSTANT NUMBER := 1.0;
6141 l_init_msg_list VARCHAR2(32767);
6142 l_commit VARCHAR2(32767);
6143 --
6144 --
6145 l_return_status VARCHAR2(32767);
6146 l_msg_count NUMBER;
6147 l_msg_data VARCHAR2(32767);
6148 l_program_name VARCHAR2(32767);
6149 --
6150 l_number_of_errors NUMBER := 0;
6151 l_number_of_warnings NUMBER := 0;
6152 --
6153
6154 l_index NUMBER;
6155 l_new_detail_id NUMBER;
6156 l_dummy_rowid NUMBER;
6157 l_dummy_assgn_rowid NUMBER;
6158 l_delivery_assignment_id NUMBER;
6159 l_delivery_assignments_info WSH_DELIVERY_DETAILS_PKG.Delivery_Assignments_Rec_Type;
6160 l_required_field VARCHAR2(32767);
6161
6162 l_validation_level NUMBER;
6163 l_org_id NUMBER;
6164 l_isWshLocation BOOLEAN DEFAULT FALSE;
6165
6166 /* H projects: pricing integration csun */
6167 l_mark_reprice_flag VARCHAR2(1) := 'N';
6168 m NUMBER := 0;
6169 l_details_marked WSH_UTIL_CORE.Id_Tab_Type;
6170 mark_reprice_error EXCEPTION;
6171
6172 l_original_detail_rec c_original_detail_cur%ROWTYPE;
6173 --
6174 l_debug_on BOOLEAN;
6175 --
6176 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATE_DELIVERY_DETAIL';
6177 -- OPM Bug 3055126
6178 l_check_status NUMBER;
6179 --
6180
6181 --
6182 uom_conversion_failed EXCEPTION;
6183 e_required_field_null EXCEPTION;
6184 e_ib_create_error EXCEPTION;
6185 -- PK Bug 3055126 OPM Exceptions
6186 -- HW OPMCONV - Removed OPM variables
6187
6188 -- anxsharm for Load Tender
6189 -- remove this cursor not being used
6190
6191 CURSOR c_original_line(p_counter NUMBER)
6192 IS
6193 SELECT source_line_id,
6194 organization_id,
6195 inventory_item_id,
6196 serial_number,
6197 transaction_temp_id,
6198 locator_id,
6199 revision,
6200 subinventory,
6201 lot_number,
6202 released_status,
6203 requested_quantity_uom
6204 FROM wsh_delivery_details
6205 WHERE delivery_detail_id = x_detail_info_tab(p_counter).delivery_detail_id;
6206 -- AND source_code = p_source_code;
6207
6208 l_old_delivery_detail_rec c_original_line%ROWTYPE;
6209
6210 CURSOR c_inventory_item_info(p_inventory_item_id number, p_organization_id number) is
6211 SELECT primary_uom_code,
6212 description,
6213 hazard_class_id,
6214 weight_uom_code,
6215 unit_weight,
6216 volume_uom_code,
6217 unit_volume
6218 FROM mtl_system_items
6219 WHERE inventory_item_id = p_inventory_item_id
6220 AND organization_id = p_organization_id;
6221
6222 l_inventory_item_info c_inventory_item_info%ROWTYPE;
6223
6224 -- anxsharm for Load tender
6225 l_old_table wsh_interface.deliverydetailtab;
6226 l_new_table wsh_interface.deliverydetailtab;
6227 l_count_old NUMBER;
6228 l_count_new NUMBER;
6229 l_fte_installed VARCHAR2(1);
6230
6231 BEGIN
6232 --
6233 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6234 --
6235 IF l_debug_on IS NULL
6236 THEN
6237 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6238 END IF;
6239 --
6240 SAVEPOINT VALIDATE_DEL_DETAIL_GRP;
6241
6242 IF l_debug_on THEN
6243 WSH_DEBUG_SV.push(l_module_name);
6244 --
6245 WSH_DEBUG_SV.log(l_module_name,'P_ACTION',P_ACTION);
6246 WSH_DEBUG_SV.log(l_module_name,'p_caller',p_caller);
6247 END IF;
6248 --
6249 -- Initialize API return status to success
6250 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6251 l_number_of_errors := 0;
6252 l_number_of_warnings := 0;
6253
6254 IF p_caller IN ( 'WSH_FSTRX' , 'WSH_TPW_INBOUND')
6255 OR p_caller LIKE 'FTE%' THEN
6256 l_isWshLocation := TRUE;
6257 END IF;
6258
6259 l_index := x_detail_info_tab.FIRST;
6260
6261 IF wsh_util_core.fte_is_installed = 'Y' THEN
6262 l_fte_installed := 'Y';
6263 END IF;
6264
6265 --
6266 WHILE l_index IS NOT NULL
6267 LOOP
6268 --
6269 BEGIN
6270 SAVEPOINT validate_det_loop_grp;
6271 --
6272 IF l_debug_on THEN
6273 wsh_debug_sv.log(l_module_name, 'Index', l_index);
6274 END IF;
6275 IF(p_action = 'CREATE') THEN
6276 --
6277 -- J-IB-NPARIKH-{
6278 --
6279 IF NVL(x_detail_info_tab(l_index).line_direction,'O') NOT IN ('O','IO')
6280 THEN
6281 --
6282 -- Cannot create inbound lines through group APIs
6283 --
6284 RAISE e_ib_create_error;
6285 END IF;
6286 --
6287 -- J-IB-NPARIKH-}
6288 --
6289 IF (x_detail_info_tab(l_index).source_code is NULL) THEN
6290 l_required_field := 'SOURCE_CODE';
6291 RAISE e_required_field_null;
6292 ELSIF (x_detail_info_tab(l_index).source_header_id is NULL) THEN
6293 l_required_field := 'SOURCE_HEADER_ID';
6294 RAISE e_required_field_null;
6295 ELSIF (x_detail_info_tab(l_index).source_line_id is NULL) THEN
6296 l_required_field := 'SOURCE_LINE_ID';
6297 RAISE e_required_field_null;
6298 ELSIF (x_detail_info_tab(l_index).src_requested_quantity is NULL) THEN
6299 l_required_field := 'SRC_REQ_QTY';
6300 RAISE e_required_field_null;
6301 ELSIF (x_detail_info_tab(l_index).src_requested_quantity_uom is NULL) THEN
6302 l_required_field := 'SRC_REQ_QTY_UOM';
6303 RAISE e_required_field_null;
6304
6305 /* if item is not setup in the inventory system yet.
6306 The required fields
6307 Item_Description,
6308 Weight_UOM_Code,
6309 Volume_UOM_Code,
6310 Net_Weight,
6311 Volume */
6312 --
6313 ELSIF (x_detail_info_tab(l_index).inventory_item_id is NULL) THEN
6314
6315 if (x_detail_info_tab(l_index).item_description is NULL) THEN
6316 l_required_field := 'ITEM';
6317 raise e_required_field_null;
6318 end if;
6319
6320 /* you need to either have inventory_item_id or item_description */
6321 if (x_detail_info_tab(l_index).item_description is not NULL) then
6322
6323 -- bug 2398865
6324 IF ( nvl(x_detail_info_tab(l_index).requested_quantity,fnd_api.g_miss_num) = fnd_api.g_miss_num ) THEN
6325 x_detail_info_tab(l_index).requested_quantity_uom := x_detail_info_tab(l_index).src_requested_quantity_uom;
6326 x_detail_info_tab(l_index).requested_quantity := x_detail_info_tab(l_index).src_requested_quantity;
6327 END IF;
6328 -- bug 2398865
6329 if (x_detail_info_tab(l_index).weight_uom_code is NULL) THEN
6330 l_required_field := 'WEIGHT_UOM';
6331 raise e_required_field_null;
6332 end if;
6333
6334 if (x_detail_info_tab(l_index).volume_uom_code is NULL) THEN
6335 l_required_field := 'VOLUME_UOM';
6336 raise e_required_field_null;
6337 end if;
6338
6339 if (x_detail_info_tab(l_index).net_weight is NULL) THEN
6340 l_required_field := 'NET_WEIGHT';
6341 raise e_required_field_null;
6342 end if;
6343
6344 if (x_detail_info_tab(l_index).volume is NULL) THEN
6345 l_required_field := 'VOLUME';
6346 raise e_required_field_null;
6347 end if;
6348
6349 end if; -- if item_description is not null
6350
6351 /* Bug 2177410, skip inventory interface for non-item */
6352 x_detail_info_tab(l_index).inv_interfaced_flag := 'X';
6353 --
6354 ELSIF (x_detail_info_tab(l_index).organization_id is NULL) THEN
6355 l_required_field := 'ORGANIZATION_ID';
6356 raise e_required_field_null;
6357 ELSIF (x_detail_info_tab(l_index).source_header_number is NULL) THEN
6358 l_required_field := 'SOURCE_HEADER_NUMBER';
6359 raise e_required_field_null;
6360 ELSIF (x_detail_info_tab(l_index).org_id is NULL) THEN
6361 l_required_field := 'ORG_ID';
6362 raise e_required_field_null;
6363 ELSIF (x_detail_info_tab(l_index).source_line_number is NULL) THEN
6364 l_required_field := 'SOURCE_LINE_NUMBER';
6365 raise e_required_field_null;
6366 END IF;
6367
6368 IF x_detail_info_tab(l_index).ship_from_location_id is NULL THEN
6369 l_required_field := 'SHIP_FROM_LOCATION_ID';
6370 raise e_required_field_null;
6371 ELSE
6372 IF l_debug_on THEN
6373 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_LOCATION',WSH_DEBUG_SV.C_PROC_LEVEL);
6374 END IF;
6375 wsh_util_validate.validate_location(
6376 p_location_id => x_detail_info_tab(l_index).ship_from_location_id,
6377 x_return_status => l_return_status,
6378 p_isWshLocation => l_isWshLocation);
6379
6380 wsh_util_core.api_post_call(
6381 p_return_status => l_return_status,
6382 x_num_warnings => l_number_of_warnings,
6383 x_num_errors => l_number_of_errors,
6384 p_msg_data => l_msg_data
6385 );
6386 END IF;
6387
6388 IF x_detail_info_tab(l_index).ship_to_location_id is NULL THEN
6389 l_required_field := 'SHIP_TO_LOCATION_ID';
6390 raise e_required_field_null;
6391 ELSE
6392 IF l_debug_on THEN
6393 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_LOCATION',WSH_DEBUG_SV.C_PROC_LEVEL);
6394 END IF;
6395 wsh_util_validate.validate_location(
6396 p_location_id => x_detail_info_tab(l_index).ship_to_location_id,
6397 x_return_status => l_return_status,
6398 p_isWshLocation => l_isWshLocation);
6399
6400 wsh_util_core.api_post_call(
6401 p_return_status => l_return_status,
6402 x_num_warnings => l_number_of_warnings,
6403 x_num_errors => l_number_of_errors,
6404 p_msg_data => l_msg_data
6405 );
6406 END IF;
6407
6408 --
6409 IF (x_detail_info_tab(l_index).inventory_item_id is not null) THEN
6410 --
6411 open c_inventory_item_info(x_detail_info_tab(l_index).inventory_item_id, x_detail_info_tab(l_index).organization_id);
6412 fetch c_inventory_item_info into l_inventory_item_info;
6413 close c_inventory_item_info;
6414
6415 x_detail_info_tab(l_index).item_description := l_inventory_item_info.description;
6416 x_detail_info_tab(l_index).requested_quantity_uom := l_inventory_item_info.primary_uom_code;
6417
6418 --
6419 if (x_detail_info_tab(l_index).requested_quantity_uom is NULL) THEN
6420 l_required_field := 'PRIMARY_UOM';
6421 raise e_required_field_null;
6422 end if;
6423
6424 -- bug 2398865
6425 --
6426 IF ( nvl(x_detail_info_tab(l_index).requested_quantity,fnd_api.g_miss_num) = fnd_api.g_miss_num ) THEN
6427
6428 IF l_debug_on THEN
6429 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.CONVERT_UOM',WSH_DEBUG_SV.C_PROC_LEVEL);
6430 END IF;
6431
6432 x_detail_info_tab(l_index).requested_quantity := wsh_wv_utils.convert_uom(
6433 x_detail_info_tab(l_index).src_requested_quantity_uom,
6434 l_inventory_item_info.primary_uom_code,
6435 x_detail_info_tab(l_index).src_requested_quantity,
6436 x_detail_info_tab(l_index).inventory_item_id);
6437
6438 wsh_util_core.api_post_call(
6439 p_return_status => l_return_status,
6440 x_num_warnings => l_number_of_warnings,
6441 x_num_errors => l_number_of_errors,
6442 p_msg_data => l_msg_data
6443 );
6444 --
6445 END IF;
6446 -- bug 2398865
6447 --
6448 if (x_detail_info_tab(l_index).requested_quantity is NULL) THEN
6449 raise UOM_CONVERSION_FAILED;
6450 end if;
6451 --
6452 x_detail_info_tab(l_index).weight_uom_code := l_inventory_item_info.weight_uom_code;
6453 x_detail_info_tab(l_index).volume_uom_code := l_inventory_item_info.volume_uom_code;
6454
6455 END IF;
6456
6457 --
6458 /* make it not applicable for pick release */
6459 IF (x_detail_info_tab(l_index).source_code = 'OKE' ) THEN
6460 x_detail_info_tab(l_index).released_status := 'X';
6461 END IF;
6462 --
6463 IF (x_detail_info_tab(l_index).container_flag is NULL) THEN
6464 x_detail_info_tab(l_index).container_flag := 'N';
6465 END IF;
6466
6467 --
6468 /* Bug 2212025 default date_requested to date_scheduled */
6469 x_detail_info_tab(l_index).date_requested := NVL(x_detail_info_tab(l_index).date_requested, x_detail_info_tab(l_index).date_scheduled);
6470
6471 --
6472 ELSIF p_action = 'UPDATE' THEN
6473
6474 OPEN c_original_detail_cur(x_detail_info_tab(l_index).delivery_detail_id);
6475 FETCH c_original_detail_cur INTO l_original_detail_rec;
6476
6477 IF c_original_detail_cur%NOTFOUND THEN
6478 CLOSE c_original_detail_cur;
6479 IF l_debug_on THEN
6480 wsh_debug_sv.logmsg(l_module_name,'No Original Detail Record ');
6481 END IF;
6482 l_number_of_errors := l_number_of_errors + 1;
6483 FND_MESSAGE.SET_NAME('WSH', 'WSH_DET_INVALID_DETAIL');
6484 FND_MESSAGE.SET_TOKEN('DETAIL_ID', x_detail_info_tab(l_index).delivery_detail_id);
6485 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
6486 RAISE FND_API.G_EXC_ERROR;
6487 END IF;
6488
6489 CLOSE c_original_detail_cur;
6490
6491 -- Bug 3382932: If caller is WMS, default the shipped_quantity2 to be the picked_quantity2.
6492
6493 IF p_caller like 'WMS%' THEN
6494
6495 x_detail_info_tab(l_index).shipped_quantity2 := x_detail_info_tab(l_index).picked_quantity2;
6496
6497 END IF;
6498
6499
6500 Validate_Detail_Common(
6501 x_detail_rec => x_detail_info_tab(l_index),
6502 p_original_rec => l_original_detail_rec,
6503 p_validation_tab => p_validation_tab,
6504 x_mark_reprice_flag => l_mark_reprice_flag,
6505 x_return_status => l_return_status,
6506 x_msg_count => l_msg_count,
6507 x_msg_data => l_msg_data
6508 );
6509
6510 IF l_debug_on THEN
6511 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6512 END IF;
6513 --
6514 wsh_util_core.api_post_call(
6515 p_return_status => l_return_status,
6516 x_num_warnings => l_number_of_warnings,
6517 x_num_errors => l_number_of_errors,
6518 p_msg_data => l_msg_data
6519 );
6520
6521 IF(l_original_detail_rec.container_flag in ('Y', 'C')) THEN
6522
6523 Validate_Detail_Container(
6524 x_detail_rec => x_detail_info_tab(l_index),
6525 p_original_rec => l_original_detail_rec,
6526 p_validation_tab => p_validation_tab,
6527 x_mark_reprice_flag => l_mark_reprice_flag,
6528 x_return_status => l_return_status,
6529 x_msg_count => l_msg_count,
6530 x_msg_data => l_msg_data
6531 );
6532
6533 IF l_debug_on THEN
6534 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6535 END IF;
6536 --
6537 wsh_util_core.api_post_call(
6538 p_return_status => l_return_status,
6539 x_num_warnings => l_number_of_warnings,
6540 x_num_errors => l_number_of_errors,
6541 p_msg_data => l_msg_data
6542 );
6543
6544 ELSIF(l_original_detail_rec.container_flag = 'N') THEN
6545
6546 Validate_Detail_Line(
6547 x_detail_rec => x_detail_info_tab(l_index),
6548 p_in_detail_rec => p_in_detail_tab(l_index),
6549 p_original_rec => l_original_detail_rec,
6550 p_validation_tab => p_validation_tab,
6551 x_mark_reprice_flag => l_mark_reprice_flag,
6552 x_return_status => l_return_status,
6553 x_msg_count => l_msg_count,
6554 x_msg_data => l_msg_data,
6555 p_in_rec => p_in_rec,
6556 p_serial_range_tab => p_serial_range_tab
6557 );
6558
6559 IF l_debug_on THEN
6560 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6561 END IF;
6562 --
6563 wsh_util_core.api_post_call(
6564 p_return_status => l_return_status,
6565 x_num_warnings => l_number_of_warnings,
6566 x_num_errors => l_number_of_errors,
6567 p_msg_data => l_msg_data
6568 );
6569 END IF; -- if check for container_flag
6570
6571 IF(l_mark_reprice_flag = 'Y' ) THEN
6572 x_details_marked(x_details_marked.count+1) := x_detail_info_tab(l_index).delivery_detail_id;
6573 END IF;
6574
6575
6576 -- anxsharm for Load Tender
6577 IF l_fte_installed = 'Y' THEN
6578
6579 -- this is for action code of UPDATE only
6580 -- track changes to quantity or weight or volume
6581 -- do not pass delivery id and parent_delivery_detail_id from here
6582
6583 -- number of records already populated in table
6584 l_count_old := l_old_table.count + 1;
6585 l_count_new := l_new_table.count + 1;
6586
6587 --
6588 -- Current Values in Database
6589 --
6590 l_old_table(l_count_old).requested_quantity := l_original_detail_rec.requested_quantity;
6591 l_old_table(l_count_old).picked_quantity := l_original_detail_rec.picked_quantity;
6592 l_old_table(l_count_old).shipped_quantity := l_original_detail_rec.shipped_quantity;
6593 l_old_table(l_count_old).gross_weight := l_original_detail_rec.gross_weight;
6594 l_old_table(l_count_old).net_weight := l_original_detail_rec.net_weight;
6595 l_old_table(l_count_old).weight_uom_code := l_original_detail_rec.weight_uom_code;
6596 l_old_table(l_count_old).volume := l_original_detail_rec.volume;
6597 l_old_table(l_count_old).volume_uom_code := l_original_detail_rec.volume_uom_code;
6598 -- Old record must have delivery detail id, which is same
6599 -- as the new record
6600 l_old_table(l_count_old).delivery_detail_id := x_detail_info_tab(l_index).delivery_detail_id;
6601
6602 --
6603 -- New Record
6604 --
6605 l_new_table(l_count_new).requested_quantity := x_detail_info_tab(l_index).requested_quantity;
6606 l_new_table(l_count_new).picked_quantity := x_detail_info_tab(l_index).picked_quantity;
6607 l_new_table(l_count_new).shipped_quantity := x_detail_info_tab(l_index).shipped_quantity;
6608 l_new_table(l_count_new).gross_weight := x_detail_info_tab(l_index).gross_weight;
6609 l_new_table(l_count_new).net_weight := x_detail_info_tab(l_index).net_weight;
6610 l_new_table(l_count_new).weight_uom_code := x_detail_info_tab(l_index).weight_uom_code;
6611 l_new_table(l_count_new).volume := x_detail_info_tab(l_index).volume;
6612 l_new_table(l_count_new).volume_uom_code := x_detail_info_tab(l_index).volume_uom_code;
6613
6614 END IF; -- fte is installed
6615 -- anxsharm , end of code for Load Tender
6616
6617 END IF; -- if p_action = create
6618
6619 -- HW OPMCONV - Removed checking for process
6620 -- PK Bug 3055126 Begin OPM Changes for validation of quantities
6621 IF ( p_caller = 'WSH_PUB') THEN
6622 IF (nvl(x_detail_info_tab(l_index).shipped_quantity,fnd_api.g_miss_num) <> fnd_api.g_miss_num OR
6623 nvl(x_detail_info_tab(l_index).shipped_quantity2,fnd_api.g_miss_num) <> fnd_api.g_miss_num) THEN
6624
6625 -- HW OPMCONV - Use this API instead of GMI_RESERVATION_UTIL.validate_opm_quantities
6626
6627 WSH_DETAILS_VALIDATIONS.validate_secondary_quantity
6628 (
6629 p_delivery_detail_id => x_detail_info_tab(l_index).delivery_detail_id,
6630 x_quantity => x_detail_info_tab(l_index).shipped_quantity,
6631 x_quantity2 => x_detail_info_tab(l_index).shipped_quantity2,
6632 p_caller => p_caller,
6633 x_return_status => l_return_status,
6634 x_msg_count => l_msg_count,
6635 x_msg_data => l_msg_data
6636 );
6637 --
6638 wsh_util_core.api_post_call(
6639 p_return_status => l_return_status,
6640 x_num_warnings => l_number_of_warnings,
6641 x_num_errors => l_number_of_errors,
6642 p_msg_data => l_msg_data
6643 );
6644
6645
6646 END IF;
6647
6648 -- HW OPMCONV - Needed to add check for "0". Some cases cycle_count values
6649 -- had values of zeroes due to initialization issues
6650 IF ( ( nvl(x_detail_info_tab(l_index).cycle_count_quantity,fnd_api.g_miss_num) <> fnd_api.g_miss_num
6651 OR nvl(x_detail_info_tab(l_index).cycle_count_quantity2,fnd_api.g_miss_num) <> fnd_api.g_miss_num )
6652 AND ( x_detail_info_tab(l_index).cycle_count_quantity <> 0
6653 OR x_detail_info_tab(l_index).cycle_count_quantity2 <> 0) )
6654 THEN
6655
6656 IF l_debug_on THEN
6657 wsh_debug_sv.push(l_module_name);
6658 wsh_debug_sv.LOG(l_module_name, 'x_detail_info_tab(l_index).cycle_count_quantity', x_detail_info_tab(l_index).cycle_count_quantity);
6659 wsh_debug_sv.LOG(l_module_name, 'x_detail_info_tab(l_index).cycle_count_quantity2', x_detail_info_tab(l_index).cycle_count_quantity2);
6660
6661 END IF;
6662
6663 WSH_DETAILS_VALIDATIONS.validate_secondary_quantity
6664 (
6665 p_delivery_detail_id => x_detail_info_tab(l_index).delivery_detail_id,
6666 x_quantity => x_detail_info_tab(l_index).cycle_count_quantity,
6667 x_quantity2 => x_detail_info_tab(l_index).cycle_count_quantity2,
6668 p_caller => p_caller,
6669 x_return_status => l_return_status,
6670 x_msg_count => l_msg_count,
6671 x_msg_data => l_msg_data
6672 );
6673
6674
6675 wsh_util_core.api_post_call(
6676 p_return_status => l_return_status,
6677 x_num_warnings => l_number_of_warnings,
6678 x_num_errors => l_number_of_errors,
6679 p_msg_data => l_msg_data
6680 );
6681
6682 END IF;
6683
6684 END IF;
6685 -- PK Bug 3055126 End OPM Changes
6686
6687 -- Added for bug 4399278, 4418754
6688 x_valid_index_tab(l_index) := l_index;
6689
6690 --
6691 EXCEPTION -- for the local begin
6692 WHEN FND_API.G_EXC_ERROR THEN
6693 ROLLBACK TO validate_det_loop_grp;
6694 IF l_debug_on THEN
6695 wsh_debug_sv.log(l_module_name, 'Validation failure for detail', x_detail_info_tab(l_index).delivery_detail_id);
6696 END IF;
6697
6698 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6699 ROLLBACK TO validate_det_loop_grp;
6700 IF l_debug_on THEN
6701 wsh_debug_sv.logmsg(l_module_name, 'Unexpected error within loop');
6702 END IF;
6703 WHEN e_required_field_null THEN
6704 ROLLBACK TO validate_det_loop_grp;
6705 l_number_of_errors := l_number_of_errors + 1;
6706 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
6707 FND_MESSAGE.SET_TOKEN('FIELD_NAME', l_required_field);
6708 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
6709 IF l_debug_on THEN
6710 WSH_DEBUG_SV.logmsg(l_module_name,'E_REQUIRED_FIELD_NULL exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6711 END IF;
6712 -- J-IB-NPARIKH-{
6713 WHEN e_ib_create_error THEN
6714 ROLLBACK TO validate_det_loop_grp;
6715 l_number_of_errors := l_number_of_errors + 1;
6716 FND_MESSAGE.SET_NAME('WSH', 'WSH_IB_CREATE_LINE_ERROR');
6717 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
6718 IF l_debug_on THEN
6719 WSH_DEBUG_SV.logmsg(l_module_name,'e_ib_create_error exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6720 END IF;
6721 -- J-IB-NPARIKH-}
6722
6723 when uom_conversion_failed then
6724 FND_MESSAGE.SEt_NAME('WSH','UOM_CONVERSION_FAILED');
6725 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
6726
6727 IF l_debug_on THEN
6728 WSH_DEBUG_SV.logmsg(l_module_name,'UOM_CONVERSION_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6729 END IF;
6730
6731 WHEN OTHERS THEN
6732 ROLLBACK TO validate_det_loop_grp;
6733 IF l_debug_on THEN
6734 wsh_debug_sv.logmsg(l_module_name, 'Others exception within loop');
6735 END IF;
6736 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6737 END; -- for the local begin
6738
6739 -- Commented for bug 4399278, 4418754
6740 --x_valid_index_tab(l_index) := l_index;
6741 --
6742 l_index := x_detail_info_tab.NEXT(l_index);
6743 --
6744 END LOOP; -- while l_index is not null
6745
6746 -- anxsharm for Load Tender
6747 -- new API added for comparison of attributes
6748 -- but has different record structure.
6749 -- Use Compare_detail_attributes API
6750 IF l_fte_installed = 'Y' THEN
6751 WSH_DETAILS_VALIDATIONS.compare_detail_attributes
6752 (p_old_table => l_old_table,
6753 p_new_table => l_new_table,
6754 p_action_code => p_action,
6755 p_phase => 1,
6756 p_caller => 'WSH',
6757 x_changed_id_tab => x_detail_tender_tab,
6758 x_return_status => l_return_status
6759 );
6760 wsh_util_core.api_post_call(
6761 p_return_status => l_return_status,
6762 x_num_warnings => l_number_of_warnings,
6763 x_num_errors => l_number_of_errors,
6764 p_msg_data => l_msg_data
6765 );
6766 END IF; --l_fte_installed = 'Y'
6767 -- anxsharm end for Load Tender
6768
6769
6770 IF l_debug_on THEN
6771 wsh_debug_sv.log(l_module_name, 'Number of errors', l_number_of_errors);
6772 wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
6773 END IF;
6774
6775 IF x_detail_info_tab.count > 0 THEN
6776 IF l_number_of_errors >= x_detail_info_tab.count THEN
6777 RAISE FND_API.G_EXC_ERROR;
6778 ELSIF l_number_of_errors >0 THEN
6779 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
6780 ELSIF l_number_of_warnings > 0 THEN
6781 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
6782 END IF;
6783 END IF;
6784
6785 FND_MSG_PUB.Count_And_Get
6786 (
6787 p_count => x_msg_count,
6788 p_data => x_msg_data,
6789 p_encoded => FND_API.G_FALSE
6790 );
6791
6792 IF l_debug_on THEN
6793 WSH_DEBUG_SV.pop(l_module_name);
6794 END IF;
6795 --
6796 EXCEPTION
6797 WHEN FND_API.G_EXC_ERROR THEN
6798 ROLLBACK to VALIDATE_DEL_DETAIL_GRP;
6799 x_return_status := FND_API.G_RET_STS_ERROR ;
6800 FND_MSG_PUB.Count_And_Get
6801 (
6802 p_count => x_msg_count,
6803 p_data => x_msg_data,
6804 p_encoded => FND_API.G_FALSE
6805 );
6806 --
6807 IF l_debug_on THEN
6808 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6809 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
6810 END IF;
6811 --
6812 --
6813 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6814 ROLLBACK to VALIDATE_DEL_DETAIL_GRP;
6815 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6816 FND_MSG_PUB.Count_And_Get
6817 (
6818 p_count => x_msg_count,
6819 p_data => x_msg_data,
6820 p_encoded => FND_API.G_FALSE
6821 );
6822 --
6823 IF l_debug_on THEN
6824 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6825 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
6826 END IF;
6827 --
6828 --
6829 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
6830 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6831 FND_MSG_PUB.Count_And_Get
6832 (
6833 p_count => x_msg_count,
6834 p_data => x_msg_data,
6835 p_encoded => FND_API.G_FALSE
6836 );
6837 --
6838 IF l_debug_on THEN
6839 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6840 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
6841 END IF;
6842 --
6843
6844
6845 WHEN OTHERS THEN
6846
6847 ROLLBACK to VALIDATE_DEL_DETAIL_GRP;
6848 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6849 wsh_util_core.add_message(x_return_status, l_module_name);
6850 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Validate_Delivery_Detail');
6851
6852 FND_MSG_PUB.Count_And_Get
6853 (
6854 p_count => x_msg_count,
6855 p_data => x_msg_data,
6856 p_encoded => FND_API.G_FALSE
6857 );
6858 --
6859 IF l_debug_on THEN
6860 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6861 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6862 END IF;
6863 --
6864 END Validate_Delivery_Detail;
6865
6866 -- ---------------------------------------------------------------------
6867 -- Procedure: Update_Delivery_Detail
6868 --
6869 -- Parameters:
6870 --
6871 -- Description: This local procedure is the new API for wrapping the logic of UPDATE of delivery details
6872 -- Created: Harmonization Project. Patchset I
6873 -- -----------------------------------------------------------------------
6874
6875 PROCEDURE Update_Delivery_Detail(
6876 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
6877 p_valid_index_tab IN wsh_util_core.id_tab_type,
6878 x_return_status OUT NOCOPY VARCHAR2,
6879 x_msg_count OUT NOCOPY NUMBER,
6880 x_msg_data OUT NOCOPY VARCHAR2,
6881 p_caller IN VARCHAR2 DEFAULT NULL)
6882 IS
6883
6884 cursor lock_delivery_details(p_del_det IN NUMBER) is
6885 select delivery_detail_id
6886 from wsh_delivery_details
6887 where delivery_detail_id = p_del_det
6888 for update nowait;
6889
6890
6891 l_api_name CONSTANT VARCHAR2(30) := 'Update_Delivery_Detail';
6892 l_api_version CONSTANT NUMBER := 1.0;
6893 --
6894 --
6895 l_return_status VARCHAR2(32767);
6896 l_msg_count NUMBER;
6897 l_msg_data VARCHAR2(32767);
6898 l_program_name VARCHAR2(32767);
6899 --
6900 l_number_of_errors NUMBER := 0;
6901 l_number_of_warnings NUMBER := 0;
6902 --
6903 l_index NUMBER;
6904 l_delivery_detail NUMBER;
6905 --lpn conv
6906 l_in_rec WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_in_rec_type;
6907 l_out_rec WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_out_rec_type;
6908
6909 --
6910 l_debug_on BOOLEAN;
6911 --
6912 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'UPDATE_DELIVERY_DETAIL';
6913 delivery_detail_locked EXCEPTION;
6914 PRAGMA EXCEPTION_INIT(delivery_detail_locked, -00054);
6915
6916
6917
6918 BEGIN
6919 --
6920 --
6921 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6922 --
6923 IF l_debug_on IS NULL
6924 THEN
6925 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6926 END IF;
6927 --
6928 SAVEPOINT UPDATE_DEL_DETAIL_GRP;
6929 IF l_debug_on THEN
6930 WSH_DEBUG_SV.push(l_module_name);
6931 WSH_DEBUG_SV.log(l_module_name,'count of p_valid_index_tab is', p_valid_index_tab.count);
6932 WSH_DEBUG_SV.log(l_module_name,'count of p_detail_info_tab is', p_detail_info_tab.count);
6933 END IF;
6934 --
6935
6936 -- Initialize API return status to success
6937 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6938 l_number_of_errors := 0;
6939 l_number_of_warnings := 0;
6940
6941 l_index := p_valid_index_tab.FIRST;
6942
6943 IF l_debug_on THEN
6944 WSH_DEBUG_SV.log(l_module_name,'first index of p_detail_info_tab is', l_index);
6945 END IF;
6946
6947 WHILE l_index IS NOT NULL
6948 LOOP
6949 IF (p_caller like 'WMS%') OR (p_caller = 'WSH_USA') THEN
6950 -- Bug 3292364
6951 -- Lock the container being updated during OM changes.
6952 IF l_debug_on THEN
6953 WSH_DEBUG_SV.log(l_module_name, 'lock delivery detail '||p_detail_info_tab(l_index).delivery_detail_id);
6954 END IF;
6955
6956 OPEN lock_delivery_details(p_detail_info_tab(l_index).delivery_detail_id);
6957 FETCH lock_delivery_details into l_delivery_detail;
6958
6959 END IF;
6960
6961
6962 IF l_debug_on THEN
6963 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.UPDATE_DELIVERY_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
6964 END IF;
6965 --
6966 wsh_delivery_details_pkg.Update_Delivery_Details(
6967 p_rowid => p_detail_info_tab(l_index).rowid,
6968 p_delivery_details_info => p_detail_info_tab(l_index),
6969 x_return_status => l_return_status);
6970
6971 --
6972 IF l_debug_on THEN
6973 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6974 END IF;
6975 --
6976 wsh_util_core.api_post_call(
6977 p_return_status => l_return_status,
6978 x_num_warnings => l_number_of_warnings,
6979 x_num_errors => l_number_of_errors,
6980 p_msg_data => l_msg_data
6981 );
6982
6983 IF lock_delivery_details%isopen THEN
6984 CLOSE lock_delivery_details;
6985 END IF;
6986
6987
6988 l_index := p_valid_index_tab.NEXT(l_index);
6989
6990 END LOOP; -- while l_index is not null
6991
6992 --{ lpn conv
6993 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y' THEN
6994 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'N';
6995
6996 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS( --bmso dependency
6997 p_in_rec => l_in_rec,
6998 x_return_status => l_return_status,
6999 x_out_rec => l_out_rec
7000 );
7001
7002 wsh_util_core.api_post_call(
7003 p_return_status => l_return_status,
7004 x_num_warnings => l_number_of_warnings,
7005 x_num_errors => l_number_of_errors
7006 );
7007
7008 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7009 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7010
7011 END IF;
7012 --} lpn conv
7013
7014 FND_MSG_PUB.Count_And_Get
7015 (
7016 p_count => x_msg_count,
7017 p_data => x_msg_data,
7018 p_encoded => FND_API.G_FALSE
7019 );
7020
7021 --
7022 IF l_debug_on THEN
7023 WSH_DEBUG_SV.pop(l_module_name);
7024 END IF;
7025 --
7026 EXCEPTION
7027 WHEN FND_API.G_EXC_ERROR THEN
7028 ROLLBACK to UPDATE_DEL_DETAIL_GRP;
7029 x_return_status := FND_API.G_RET_STS_ERROR ;
7030 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7031 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7032 FND_MSG_PUB.Count_And_Get
7033 (
7034 p_count => x_msg_count,
7035 p_data => x_msg_data,
7036 p_encoded => FND_API.G_FALSE
7037 );
7038 --
7039
7040 IF l_debug_on THEN
7041 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7042 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
7043 END IF;
7044 --
7045 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7046 IF lock_delivery_details%isopen THEN
7047 CLOSE lock_delivery_details;
7048 END IF;
7049 ROLLBACK to UPDATE_DEL_DETAIL_GRP;
7050 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7051 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7052 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7053 FND_MSG_PUB.Count_And_Get
7054 (
7055 p_count => x_msg_count,
7056 p_data => x_msg_data,
7057 p_encoded => FND_API.G_FALSE
7058 );
7059 --
7060 --
7061 IF l_debug_on THEN
7062 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7063 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
7064 END IF;
7065 --
7066 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
7067 IF lock_delivery_details%isopen THEN
7068 CLOSE lock_delivery_details;
7069 END IF;
7070 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7071 --
7072 -- K LPN CONV. rv
7073 --
7074 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
7075 THEN
7076 --{
7077 IF l_debug_on THEN
7078 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
7079 END IF;
7080
7081 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
7082 (
7083 p_in_rec => l_in_rec,
7084 x_return_status => l_return_status,
7085 x_out_rec => l_out_rec
7086 );
7087 --
7088 --
7089 IF l_debug_on THEN
7090 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
7091 END IF;
7092 --
7093 --
7094 IF (l_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR) and x_return_status <> WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
7095 x_return_status := l_return_status;
7096 END IF;
7097 --
7098 --}
7099 END IF;
7100 --
7101 -- K LPN CONV. rv
7102 --
7103 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7104 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7105 FND_MSG_PUB.Count_And_Get
7106 (
7107 p_count => x_msg_count,
7108 p_data => x_msg_data,
7109 p_encoded => FND_API.G_FALSE
7110 );
7111 --
7112 IF l_debug_on THEN
7113 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7114 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
7115 END IF;
7116 --
7117 WHEN delivery_detail_locked THEN
7118 IF lock_delivery_details%isopen THEN
7119 CLOSE lock_delivery_details;
7120 END IF;
7121 --
7122 -- K LPN CONV. rv
7123 --
7124 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
7125 THEN
7126 --{
7127 IF l_debug_on THEN
7128 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',WSH_DEBUG_SV.C_PROC_LEVEL);
7129 END IF;
7130
7131 WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
7132 (
7133 p_in_rec => l_in_rec,
7134 x_return_status => l_return_status,
7135 x_out_rec => l_out_rec
7136 );
7137 --
7138 --
7139 IF l_debug_on THEN
7140 WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
7141 END IF;
7142 --
7143 --
7144 IF (l_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR) and x_return_status <> WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
7145 x_return_status := l_return_status;
7146 END IF;
7147 --
7148 --}
7149 END IF;
7150 --
7151 -- K LPN CONV. rv
7152 --
7153 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7154 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7155 l_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7156 FND_MESSAGE.Set_Name('WSH', 'WSH_NO_LOCK');
7157 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
7158 IF l_debug_on THEN
7159 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:delivery_detail_locked');
7160 END IF;
7161
7162 WHEN OTHERS THEN
7163 IF lock_delivery_details%isopen THEN
7164 CLOSE lock_delivery_details;
7165 END IF;
7166
7167 ROLLBACK to UPDATE_DEL_DETAIL_GRP;
7168 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7169 WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED := 'Y';
7170 WSH_WMS_LPN_GRP.g_update_to_container := 'N';
7171 wsh_util_core.add_message(x_return_status, l_module_name);
7172 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Update_Delivery_Detail');
7173
7174 FND_MSG_PUB.Count_And_Get
7175 (
7176 p_count => x_msg_count,
7177 p_data => x_msg_data,
7178 p_encoded => FND_API.G_FALSE
7179 );
7180
7181 IF l_debug_on THEN
7182 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7183 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7184 END IF;
7185 --
7186 END Update_Delivery_Detail;
7187
7188
7189
7190
7191 -- ---------------------------------------------------------------------
7192 -- Procedure: Cancel_Delivery_Detail
7193 --
7194 -- Parameters:
7195 --
7196 -- Description: This local procedure is the new API for wrapping the logic of CANCEL of delivery details
7197 -- Created: Harmonization Project. Patchset I
7198 -- -----------------------------------------------------------------------
7199
7200 PROCEDURE Cancel_Delivery_Detail(
7201 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type ,
7202 x_return_status OUT NOCOPY VARCHAR2,
7203 x_msg_count OUT NOCOPY NUMBER,
7204 x_msg_data OUT NOCOPY VARCHAR2,
7205 p_caller IN VARCHAR2 DEFAULT NULL)
7206 IS
7207
7208 l_api_name CONSTANT VARCHAR2(30) := 'Cancel_Delivery_Detail';
7209 l_api_version CONSTANT NUMBER := 1.0;
7210 --
7211 --
7212 l_return_status VARCHAR2(32767);
7213 l_msg_count NUMBER;
7214 l_msg_data VARCHAR2(32767);
7215 l_program_name VARCHAR2(32767);
7216 --
7217 l_number_of_errors NUMBER := 0;
7218 l_number_of_warnings NUMBER := 0;
7219 --
7220 l_index NUMBER;
7221
7222 --jckwok
7223 l_changed_attr_tab wsh_interface.ChangedAttributeTabType;
7224
7225 --
7226 l_debug_on BOOLEAN;
7227 --
7228 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CANCEL_DELIVERY_DETAIL';
7229
7230
7231
7232 BEGIN
7233 --
7234 --
7235 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7236 --
7237 IF l_debug_on IS NULL
7238 THEN
7239 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7240 END IF;
7241 --
7242 SAVEPOINT CANCEL_DEL_DETAIL_GRP;
7243 IF l_debug_on THEN
7244 WSH_DEBUG_SV.push(l_module_name);
7245 END IF;
7246 --
7247
7248 -- Initialize API return status to success
7249 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7250 l_number_of_errors := 0;
7251 l_number_of_warnings := 0;
7252
7253
7254 l_index := p_detail_info_tab.FIRST;
7255 WHILE l_index IS NOT NULL
7256 LOOP
7257 l_changed_attr_tab(l_index).action_flag := 'U';
7258 l_changed_attr_tab(l_index).source_code := p_detail_info_tab(l_index).source_code;
7259 l_changed_attr_tab(l_index).container_flag := p_detail_info_tab(l_index).container_flag;
7260 l_changed_attr_tab(l_index).delivery_detail_id := p_detail_info_tab(l_index).delivery_detail_id;
7261 l_changed_attr_tab(l_index).ordered_quantity := 0 ;
7262 l_changed_attr_tab(l_index).order_quantity_uom := p_detail_info_tab(l_index).requested_quantity_uom;
7263 l_changed_attr_tab(l_index).source_line_id := p_detail_info_tab(l_index).source_line_id;
7264 l_index := p_detail_info_tab.NEXT(l_index);
7265 END LOOP;
7266
7267
7268 --
7269 IF l_debug_on THEN
7270 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTERFACE.Update_Shipping_Attributes',WSH_DEBUG_SV.C_PROC_LEVEL);
7271 WSH_DEBUG_SV.log(l_module_name, 'l_changed_attr_tab.count', l_changed_attr_tab.count);
7272 WSH_DEBUG_SV.log(l_module_name, 'Delivery Detail Id', l_changed_attr_tab(1).delivery_detail_id);
7273
7274 WSH_DEBUG_SV.log(l_module_name, 'Ordered Quantity ', l_changed_attr_tab(1).ordered_quantity);
7275 WSH_DEBUG_SV.log(l_module_name, 'Ord qty uom ', l_changed_attr_tab(1).order_quantity_uom);
7276 WSH_DEBUG_SV.log(l_module_name, 'Source Line Id', l_changed_attr_tab(1).Source_Line_id);
7277 wsh_debug_sv.log(l_module_name, 'Source_Code', p_detail_info_tab(1).source_code);
7278 END IF;
7279 --
7280
7281
7282
7283 WSH_INTERFACE.Update_Shipping_Attributes(
7284 p_source_code => 'WSH',
7285 p_changed_attributes => l_changed_attr_tab,
7286 x_return_status => l_return_status
7287 );
7288
7289 --
7290 IF l_debug_on THEN
7291 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7292 END IF;
7293 --
7294 --
7295 wsh_util_core.api_post_call(
7296 p_return_status => l_return_status,
7297 x_num_warnings => l_number_of_warnings,
7298 x_num_errors => l_number_of_errors,
7299 p_msg_data => l_msg_data
7300 );
7301
7302 --
7303
7304 IF l_number_of_warnings > 0 THEN
7305 IF l_debug_on THEN
7306 wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
7307 END IF;
7308
7309 RAISE wsh_util_core.g_exc_warning;
7310 END IF;
7311
7312
7313
7314 FND_MSG_PUB.Count_And_Get
7315 (
7316 p_count => x_msg_count,
7317 p_data => x_msg_data,
7318 p_encoded => FND_API.G_FALSE
7319 );
7320
7321 --
7322 IF l_debug_on THEN
7323 WSH_DEBUG_SV.pop(l_module_name);
7324 END IF;
7325 --
7326
7327
7328
7329 --
7330 EXCEPTION
7331 WHEN FND_API.G_EXC_ERROR THEN
7332 ROLLBACK to CANCEL_DEL_DETAIL_GRP;
7333 x_return_status := FND_API.G_RET_STS_ERROR ;
7334 FND_MSG_PUB.Count_And_Get
7335 (
7336 p_count => x_msg_count,
7337 p_data => x_msg_data,
7338 p_encoded => FND_API.G_FALSE
7339 );
7340
7341 IF l_debug_on THEN
7342 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7343 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
7344 END IF;
7345 --
7346 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7347 ROLLBACK to CANCEL_DEL_DETAIL_GRP;
7348 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7349 FND_MSG_PUB.Count_And_Get
7350 (
7351 p_count => x_msg_count,
7352 p_data => x_msg_data,
7353 p_encoded => FND_API.G_FALSE
7354 );
7355
7356 IF l_debug_on THEN
7357 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7358 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
7359 END IF;
7360 --
7361 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
7362 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7363 FND_MSG_PUB.Count_And_Get
7364 (
7365 p_count => x_msg_count,
7366 p_data => x_msg_data,
7367 p_encoded => FND_API.G_FALSE
7368 );
7369 --
7370 IF l_debug_on THEN
7371 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7372 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
7373 END IF;
7374 --
7375 WHEN OTHERS THEN
7376
7377 ROLLBACK to CANCEL_DEL_DETAIL_GRP;
7378 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7379 wsh_util_core.add_message(x_return_status, l_module_name);
7380 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Delete_Delivery_Detail');
7381 FND_MSG_PUB.Count_And_Get
7382 (
7383 p_count => x_msg_count,
7384 p_data => x_msg_data,
7385 p_encoded => FND_API.G_FALSE
7386 );
7387
7388 IF l_debug_on THEN
7389 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7390 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7391 END IF;
7392 --
7393
7394
7395
7396
7397
7398
7399 END Cancel_Delivery_Detail;
7400
7401
7402
7403
7404
7405 -- ---------------------------------------------------------------------
7406 -- Procedure: Validate_Detail_Line
7407 --
7408 -- Parameters:
7409 --
7410 -- Description: This local procedure is the new API for wrapping the logic of VALIDATE of Non Containers
7411 -- Created: Harmonization Project. Patchset I
7412 -- -----------------------------------------------------------------------
7413 /*
7414 PLEASE READ BEFORE CHANGING THIS PROCEDURE
7415 For inbound lines, this procedure returns back to caller, right at the beginning.
7416 If you are adding any validation, which may be applicable for inbound line as well, please
7417 evaluate against that.
7418 */
7419 PROCEDURE validate_detail_line(
7420 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
7421 p_in_detail_rec IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
7422 p_original_rec IN c_original_detail_cur%ROWTYPE,
7423 p_validation_tab IN wsh_util_core.id_tab_type,
7424 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
7425 x_return_status OUT NOCOPY VARCHAR2,
7426 x_msg_count OUT NOCOPY NUMBER,
7427 x_msg_data OUT NOCOPY VARCHAR2,
7428 p_in_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
7429 p_serial_range_tab IN WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType
7430 ) IS
7431 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Detail_Line';
7432 l_api_version CONSTANT NUMBER := 1.0;
7433 --
7434 l_return_status VARCHAR2(32767);
7435 l_msg_count NUMBER;
7436 l_msg_data VARCHAR2(32767);
7437 l_program_name VARCHAR2(32767);
7438 --
7439 l_number_of_errors NUMBER := 0;
7440 l_number_of_warnings NUMBER := 0;
7441 --
7442 l_org_id NUMBER; /***Bug 1813496*/
7443 l_subinventory VARCHAR2(30); /***Bug 1813496*/
7444 l_locator NUMBER; /***Bug 1813496*/
7445 l_revision VARCHAR2(30);
7446 /***Bug 1813496*/
7447 -- HW OPMCONV - Increased length to 80
7448 l_lot VARCHAR2(80);
7449 l_result BOOLEAN;
7450 l_quantity NUMBER;
7451 l_inv_controls wsh_delivery_details_inv.inv_control_flag_rec;
7452 l_ship_method_name VARCHAR2(32767);
7453 -- HW Harmonization project for OPM. Added l_process flag variable
7454 -- HW OPMCONV - Removed OPM variables
7455
7456 l_det_qty_rec wsh_details_validations.validatequantityattrrectype;
7457 -- Bug fix 1578114
7458 l_transaction_id NUMBER;
7459 l_prefix VARCHAR2(240);
7460 v1 NUMBER;
7461 v2 DATE;
7462 v3 NUMBER;
7463 v4 DATE;
7464 v5 NUMBER;
7465 v6 NUMBER;
7466 v7 NUMBER;
7467 v8 NUMBER;
7468 v9 NUMBER;
7469 v10 DATE;
7470 v11 VARCHAR2(30);
7471 -- HW OPMCONV - Increased to 80 to hold lot_number
7472 v12 VARCHAR2(80);
7473 v13 VARCHAR2(30);
7474 v14 VARCHAR2(30);
7475 v15 VARCHAR2(30);
7476 v16 VARCHAR2(30);
7477 v17 NUMBER;
7478 v18 VARCHAR2(30);
7479 v19 VARCHAR2(30);
7480 v20 VARCHAR2(150);
7481 v21 VARCHAR2(150);
7482 v22 VARCHAR2(150);
7483 v23 VARCHAR2(150);
7484 v24 VARCHAR2(150);
7485 v25 VARCHAR2(150);
7486 v26 VARCHAR2(150);
7487 v27 VARCHAR2(150);
7488 v28 VARCHAR2(150);
7489 v29 VARCHAR2(150);
7490 v30 VARCHAR2(150);
7491 v31 VARCHAR2(150);
7492 v32 VARCHAR2(150);
7493 v33 VARCHAR2(150);
7494 v34 VARCHAR2(150);
7495 v35 VARCHAR2(3);
7496 l_index NUMBER;
7497 l_det_index NUMBER;
7498 l_detail_ser_count NUMBER;
7499 l_detail_ser_qty NUMBER;
7500 l_det_ser_range_tab WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType;
7501 l_update_attributes BOOLEAN;
7502 l_stamp_ser_wdd BOOLEAN; -- frontport bug 5055682
7503
7504 -- bug 4766908
7505 l_reservable_flag VARCHAR2(1);
7506 -- end bug 4766908
7507 l_trx_type_id NUMBER;
7508 CURSOR get_group_mark_id (v_serial_number IN VARCHAR2, v_item_id IN NUMBER) IS
7509 SELECT group_mark_id
7510 FROM mtl_serial_numbers
7511 WHERE serial_number = v_serial_number
7512 AND inventory_item_id = v_item_id;
7513 --
7514 l_debug_on BOOLEAN;
7515 --
7516 l_module_name CONSTANT VARCHAR2(100)
7517 := 'wsh.plsql.' || g_pkg_name || '.' || 'VALIDATE_DETAIL_LINE';
7518 --
7519 BEGIN
7520 --
7521 l_debug_on := wsh_debug_interface.g_debug;
7522
7523 --
7524 IF l_debug_on IS NULL THEN
7525 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7526 END IF;
7527
7528 --
7529 SAVEPOINT validate_det_line_grp;
7530
7531 IF l_debug_on THEN
7532 WSH_DEBUG_SV.push(l_module_name);
7533 WSH_DEBUG_SV.LOG(l_module_name, 'Delivery Detail Id', x_detail_rec.delivery_detail_id);
7534 WSH_DEBUG_SV.LOG(l_module_name, 'Serial table count', p_serial_range_tab.COUNT);
7535 WSH_DEBUG_SV.LOG(l_module_name, 'SQ', x_detail_rec.shipped_quantity);
7536 END IF;
7537
7538 -- Initialize API return status to success --
7539 x_return_status := wsh_util_core.g_ret_sts_success;
7540 l_number_of_errors := 0;
7541 l_number_of_warnings := 0;
7542
7543 --
7544 -- J-IB-NPARIKH-{
7545 IF NVL(x_detail_rec.line_direction,'O') NOT IN ('O','IO')
7546 THEN
7547 --{
7548 --
7549 -- None of the validations are applicable for inbound lines. So, return
7550 --
7551 IF l_debug_on
7552 THEN
7553 wsh_debug_sv.pop(l_module_name);
7554 END IF;
7555 --
7556 RETURN;
7557 --}
7558 END IF;
7559 -- J-IB-NPARIKH-}
7560 --
7561
7562 -- HW Harmonization project for OPM. Need to check if org is discrete or process
7563 -- HW OPMCONV - Removed checking for process org
7564
7565 IF (p_validation_tab(wsh_actions_levels.c_tol_above_lvl) = 1) THEN
7566 IF l_debug_on THEN
7567 WSH_DEBUG_SV.log(l_module_name, 'Ship Tolerance Above', x_detail_rec.ship_tolerance_above);
7568 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',
7569 WSH_DEBUG_SV.c_proc_level);
7570 END IF;
7571
7572 --Bug # 3266333
7573 wsh_util_validate.validate_negative(
7574 p_value => x_detail_rec.ship_tolerance_above,
7575 p_field_name => 'ship_tolerance_above',
7576 x_return_status => l_return_status );
7577 --
7578
7579 wsh_util_core.api_post_call(
7580 p_return_status => l_return_status,
7581 x_num_warnings => l_number_of_warnings,
7582 x_num_errors => l_number_of_errors,
7583 p_msg_data => l_msg_data
7584 );
7585 END IF;
7586
7587 IF (p_validation_tab(wsh_actions_levels.c_tol_below_lvl) = 1) THEN
7588 IF l_debug_on THEN
7589 WSH_DEBUG_SV.log(l_module_name, 'Ship Tolerance Below', x_detail_rec.ship_tolerance_below);
7590 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.c_proc_level);
7591 END IF;
7592
7593 --Bug # 3266333
7594 wsh_util_validate.validate_negative(
7595 p_value => x_detail_rec.ship_tolerance_below,
7596 p_field_name => 'ship_tolerance_below',
7597 x_return_status => l_return_status );
7598 --
7599
7600 wsh_util_core.api_post_call(
7601 p_return_status => l_return_status,
7602 x_num_warnings => l_number_of_warnings,
7603 x_num_errors => l_number_of_errors,
7604 p_msg_data => l_msg_data
7605 );
7606 END IF;
7607
7608 IF l_debug_on THEN
7609 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.org_id', x_detail_rec.org_id);
7610 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.locator_id', x_detail_rec.locator_id);
7611 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.revision', x_detail_rec.revision);
7612 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.subinventory', x_detail_rec.subinventory);
7613 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.lot_number', x_detail_rec.lot_number);
7614 END IF;
7615
7616 l_org_id := p_original_rec.organization_id;
7617
7618 /***************Material Status Impact***********/
7619 WSH_DELIVERY_DETAILS_INV.get_trx_type_id(
7620 p_source_line_id => p_in_detail_rec.source_line_id,
7621 p_source_code => p_in_detail_rec.source_code,
7622 x_transaction_type_id => l_trx_type_id,
7623 x_return_status => l_return_status);
7624 --
7625 wsh_util_core.api_post_call(
7626 p_return_status => l_return_status,
7627 x_num_warnings => l_number_of_warnings,
7628 x_num_errors => l_number_of_errors,
7629 p_msg_data => l_msg_data);
7630 /***************Material Status Impact***********/
7631
7632 IF x_detail_rec.locator_id <> fnd_api.g_miss_num THEN
7633 l_locator := x_detail_rec.locator_id;
7634 -- Modified Else condition for bug 4399278, 4418754
7635 ELSIF ( x_detail_rec.subinventory = p_original_rec.subinventory ) THEN
7636 l_locator := p_original_rec.locator_id;
7637 END IF;
7638
7639 IF x_detail_rec.revision <> fnd_api.g_miss_char THEN
7640 l_revision := x_detail_rec.revision;
7641 ELSE
7642 l_revision := p_original_rec.revision;
7643 END IF;
7644
7645 IF x_detail_rec.subinventory <> fnd_api.g_miss_char THEN
7646 l_subinventory := x_detail_rec.subinventory;
7647 ELSE
7648 l_subinventory := p_original_rec.subinventory;
7649 END IF;
7650
7651 IF x_detail_rec.lot_number <> fnd_api.g_miss_char THEN
7652 l_lot := x_detail_rec.lot_number;
7653 ELSE
7654 l_lot := p_original_rec.lot_number;
7655 END IF;
7656
7657 IF l_debug_on THEN
7658 WSH_DEBUG_SV.log(l_module_name, 'l_org_id', l_org_id);
7659 WSH_DEBUG_SV.log(l_module_name, 'l_locator', l_locator);
7660 WSH_DEBUG_SV.log(l_module_name, 'l_revision', l_revision);
7661 WSH_DEBUG_SV.log(l_module_name, 'l_subinventory', l_subinventory);
7662 WSH_DEBUG_SV.log(l_module_name, 'l_lot_number', l_lot);
7663 END IF;
7664
7665 -- UT bug fix 2657367
7666 IF p_validation_tab(wsh_actions_levels.c_ship_qty_lvl) = 1
7667 OR p_validation_tab(wsh_actions_levels.c_revision_lvl) = 1
7668 OR p_validation_tab(wsh_actions_levels.c_locator_lvl) = 1
7669 OR p_validation_tab(wsh_actions_levels.c_lot_number_lvl) = 1
7670 OR p_validation_tab(wsh_actions_levels.c_serial_num_lvl) = 1
7671 THEN
7672 --(
7673 IF l_debug_on THEN
7674 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.FETCH_INV_CONTROLS', WSH_DEBUG_SV.c_proc_level);
7675 END IF;
7676
7677 wsh_delivery_details_inv.fetch_inv_controls(
7678 p_delivery_detail_id => x_detail_rec.delivery_detail_id,
7679 p_inventory_item_id => p_original_rec.inventory_item_id,
7680 p_organization_id => l_org_id,
7681 p_subinventory => l_subinventory,
7682 x_inv_controls_rec => l_inv_controls,
7683 x_return_status => l_return_status
7684 );
7685
7686 IF l_debug_on THEN
7687 WSH_DEBUG_SV.log(l_module_name, 'Return Status', l_return_status);
7688 WSH_DEBUG_SV.log(l_module_name, 'Lot Flag', l_inv_controls.lot_flag);
7689 WSH_DEBUG_SV.log(l_module_name, 'Revision Flag', l_inv_controls.rev_flag);
7690 WSH_DEBUG_SV.log(l_module_name, 'Locator Flag', l_inv_controls.loc_flag);
7691 WSH_DEBUG_SV.log(l_module_name, 'Serial Control Code', l_inv_controls.serial_code);
7692 END IF;
7693
7694 wsh_util_core.api_post_call(
7695 p_return_status => l_return_status,
7696 x_num_warnings => l_number_of_warnings,
7697 x_num_errors => l_number_of_errors,
7698 p_msg_data => l_msg_data
7699 );
7700 --)
7701 END IF;
7702
7703 -- UT bug fix 2657367
7704
7705 IF (p_validation_tab(wsh_actions_levels.c_ship_qty_lvl) = 1) THEN
7706 IF l_debug_on THEN
7707 WSH_DEBUG_SV.log(l_module_name, 'Shipped Qty', x_detail_rec.shipped_quantity);
7708 WSH_DEBUG_SV.log(l_module_name, 'Existing Shipped Qty', p_original_rec.shipped_quantity);
7709 END IF;
7710 -- BugFix 4519867: Validate shipped qty only when it's not equal to fnd_api.g_miss_num.
7711 IF ((p_in_detail_rec.shipped_quantity IS NULL )
7712 OR (p_in_detail_rec.shipped_quantity <> fnd_api.g_miss_num))
7713 THEN
7714 l_det_qty_rec.delivery_detail_id := x_detail_rec.delivery_detail_id;
7715 l_det_qty_rec.requested_quantity := x_detail_rec.requested_quantity;
7716 l_det_qty_rec.requested_quantity2 := x_detail_rec.requested_quantity2;
7717 l_det_qty_rec.picked_quantity := x_detail_rec.picked_quantity;
7718 l_det_qty_rec.picked_quantity2 := x_detail_rec.picked_quantity2;
7719 l_det_qty_rec.shipped_quantity := x_detail_rec.shipped_quantity;
7720 l_det_qty_rec.shipped_quantity2 := x_detail_rec.shipped_quantity2;
7721 l_det_qty_rec.cycle_count_quantity := x_detail_rec.cycle_count_quantity;
7722 l_det_qty_rec.cycle_count_quantity2 :=
7723 x_detail_rec.cycle_count_quantity2;
7724 l_det_qty_rec.requested_quantity_uom :=
7725 x_detail_rec.requested_quantity_uom;
7726 l_det_qty_rec.requested_quantity_uom2 :=
7727 x_detail_rec.requested_quantity_uom2;
7728 l_det_qty_rec.ship_tolerance_above := x_detail_rec.ship_tolerance_above;
7729 l_det_qty_rec.inventory_item_id := x_detail_rec.inventory_item_id;
7730 l_det_qty_rec.organization_id := x_detail_rec.organization_id;
7731 l_det_qty_rec.serial_number := p_original_rec.serial_number;
7732 l_det_qty_rec.transaction_temp_id := p_original_rec.transaction_temp_id; -- Bug fix 2652300
7733 l_det_qty_rec.top_model_line_id := p_original_rec.top_model_line_id; -- Bug fix 2652300
7734 l_det_qty_rec.inv_ser_control_code := l_inv_controls.serial_code; -- Bug fix 2652300
7735 -- HW Harmonization for OPM. Use l_process_flag
7736 -- HW OPMCONV - Removed checking for process org and population of
7737 -- process org variable
7738
7739 get_serial_quantity(
7740 p_transaction_temp_id => p_original_rec.transaction_temp_id,
7741 p_serial_number => p_original_rec.serial_number,
7742 p_to_serial_number => p_original_rec.to_serial_number,
7743 p_shipped_quantity => x_detail_rec.shipped_quantity,
7744 x_serial_qty => l_det_qty_rec.serial_quantity,
7745 x_return_status => l_return_status
7746 );
7747
7748 IF l_debug_on THEN
7749 WSH_DEBUG_SV.log(l_module_name, 'get serial qty status', l_return_status);
7750 WSH_DEBUG_SV.log(l_module_name, 'Serial qty', l_det_qty_rec.serial_quantity);
7751 WSH_DEBUG_SV.log(l_module_name, 'Serial Number', l_det_qty_rec.serial_number);
7752 WSH_DEBUG_SV.log(l_module_name, 'Trans temp id', l_det_qty_rec.transaction_temp_id);
7753 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY', WSH_DEBUG_SV.c_proc_level);
7754 END IF;
7755
7756 --
7757 wsh_details_validations.validate_shipped_cc_quantity(
7758 p_flag => 'SQ',
7759 x_det_rec => l_det_qty_rec,
7760 x_return_status => l_return_status,
7761 x_msg_count => l_msg_count,
7762 x_msg_data => l_msg_data
7763 );
7764 x_detail_rec.shipped_quantity := l_det_qty_rec.shipped_quantity;
7765 -- x_detail_rec.cycle_count_quantity := l_det_qty_rec.cycle_count_quantity;
7766
7767 -- Bug 5466481: First consider the passed cycle count qty,
7768 -- If it is not passed then take the system calculated value.
7769 IF (p_in_detail_rec.cycle_count_quantity = fnd_api.g_miss_num) THEN
7770 --{
7771 x_detail_rec.cycle_count_quantity := l_det_qty_rec.cycle_count_quantity;
7772 ELSE
7773 x_detail_rec.cycle_count_quantity := p_in_detail_rec.cycle_count_quantity;
7774 --}
7775 END IF;
7776
7777 --
7778 wsh_util_core.api_post_call(
7779 p_return_status => l_return_status,
7780 x_num_warnings => l_number_of_warnings,
7781 x_num_errors => l_number_of_errors,
7782 p_msg_data => l_msg_data
7783 );
7784 END IF; -- End of code BugFix 4519867
7785 END IF;
7786
7787 -- HW Harmonization project for OPM.
7788 -- HW OPMCONV - Removed checking for process_flag
7789
7790 IF (p_validation_tab(wsh_actions_levels.c_ship_qty2_lvl) = 1) THEN
7791 IF (x_detail_rec.shipped_quantity2 <> fnd_api.g_miss_num) THEN
7792 l_det_qty_rec.delivery_detail_id :=
7793 x_detail_rec.delivery_detail_id;
7794 l_det_qty_rec.requested_quantity :=
7795 x_detail_rec.requested_quantity;
7796 l_det_qty_rec.requested_quantity2 :=
7797 x_detail_rec.requested_quantity2;
7798 l_det_qty_rec.picked_quantity := x_detail_rec.picked_quantity;
7799 l_det_qty_rec.picked_quantity2 := x_detail_rec.picked_quantity2;
7800 l_det_qty_rec.shipped_quantity := x_detail_rec.shipped_quantity;
7801 l_det_qty_rec.shipped_quantity2 := x_detail_rec.shipped_quantity2;
7802 l_det_qty_rec.cycle_count_quantity :=
7803 x_detail_rec.cycle_count_quantity;
7804 l_det_qty_rec.cycle_count_quantity2 :=
7805 x_detail_rec.cycle_count_quantity2;
7806 l_det_qty_rec.requested_quantity_uom :=
7807 x_detail_rec.requested_quantity_uom;
7808 l_det_qty_rec.requested_quantity_uom2 :=
7809 x_detail_rec.requested_quantity_uom2;
7810 l_det_qty_rec.ship_tolerance_above :=
7811 x_detail_rec.ship_tolerance_above;
7812 l_det_qty_rec.inventory_item_id := x_detail_rec.inventory_item_id;
7813 l_det_qty_rec.organization_id := x_detail_rec.organization_id;
7814 l_det_qty_rec.serial_number := x_detail_rec.serial_number;
7815 l_det_qty_rec.transaction_temp_id :=
7816 x_detail_rec.transaction_temp_id;
7817 l_det_qty_rec.top_model_line_id := x_detail_rec.top_model_line_id;
7818 -- HW use l_process_flag
7819 -- HW OPMCONV - Removed population of process_flag
7820
7821 IF l_debug_on THEN
7822 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY2', WSH_DEBUG_SV.c_proc_level);
7823 END IF;
7824
7825 --
7826
7827 wsh_details_validations.validate_shipped_cc_quantity2(
7828 p_flag => 'SQ',
7829 x_det_rec => l_det_qty_rec,
7830 x_return_status => l_return_status,
7831 x_msg_count => l_msg_count,
7832 x_msg_data => l_msg_data
7833 );
7834 x_detail_rec.shipped_quantity2 := l_det_qty_rec.shipped_quantity2;
7835 --PK added for Bug 3055126 Next line.
7836 x_detail_rec.cycle_count_quantity2 := l_det_qty_rec.cycle_count_quantity2;
7837 --
7838 wsh_util_core.api_post_call(
7839 p_return_status => l_return_status,
7840 x_num_warnings => l_number_of_warnings,
7841 x_num_errors => l_number_of_errors,
7842 p_msg_data => l_msg_data
7843 );
7844 END IF; -- of shipped_quantity2
7845 END IF; -- of C_SHIP_QTY2_LVL
7846
7847 -- HW OPM end of changes
7848
7849 IF (p_validation_tab(wsh_actions_levels.c_cc_qty_lvl) = 1) THEN
7850 IF l_debug_on THEN
7851 WSH_DEBUG_SV.log(l_module_name, 'Cycle_Count Qty', x_detail_rec.cycle_count_quantity);
7852 WSH_DEBUG_SV.log(l_module_name, 'Existing Cycle_Count Qty', p_original_rec.cycle_count_quantity);
7853 END IF;
7854 -- BugFix 4519867: Validate cycle count qty only when it's not equal to fnd_api.g_miss_num.
7855 IF ( (p_in_detail_rec.cycle_count_quantity IS NULL)
7856 OR (p_in_detail_rec.cycle_count_quantity <> fnd_api.g_miss_num))
7857 THEN
7858 l_det_qty_rec.delivery_detail_id := x_detail_rec.delivery_detail_id;
7859 l_det_qty_rec.requested_quantity := x_detail_rec.requested_quantity;
7860 l_det_qty_rec.requested_quantity2 := x_detail_rec.requested_quantity2;
7861 l_det_qty_rec.picked_quantity := x_detail_rec.picked_quantity;
7862 l_det_qty_rec.picked_quantity2 := x_detail_rec.picked_quantity2;
7863 l_det_qty_rec.shipped_quantity := x_detail_rec.shipped_quantity;
7864 l_det_qty_rec.shipped_quantity2 := x_detail_rec.shipped_quantity2;
7865 l_det_qty_rec.cycle_count_quantity := x_detail_rec.cycle_count_quantity;
7866 l_det_qty_rec.cycle_count_quantity2 :=
7867 x_detail_rec.cycle_count_quantity2;
7868 l_det_qty_rec.requested_quantity_uom :=
7869 x_detail_rec.requested_quantity_uom;
7870 l_det_qty_rec.requested_quantity_uom2 :=
7871 x_detail_rec.requested_quantity_uom2;
7872 l_det_qty_rec.ship_tolerance_above := x_detail_rec.ship_tolerance_above;
7873 l_det_qty_rec.inventory_item_id := x_detail_rec.inventory_item_id;
7874 l_det_qty_rec.organization_id := x_detail_rec.organization_id;
7875 l_det_qty_rec.serial_number := x_detail_rec.serial_number;
7876 l_det_qty_rec.transaction_temp_id := x_detail_rec.transaction_temp_id;
7877 l_det_qty_rec.top_model_line_id := x_detail_rec.top_model_line_id;
7878 -- HW Harmonization project for OPM.Use l_process_flag
7879 -- HW OPMCONV - Removed populatation of process_flag
7880
7881 --
7882 IF l_debug_on THEN
7883 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY', WSH_DEBUG_SV.c_proc_level);
7884 END IF;
7885
7886 --
7887 wsh_details_validations.validate_shipped_cc_quantity(
7888 p_flag => 'CCQ',
7889 x_det_rec => l_det_qty_rec,
7890 x_return_status => l_return_status,
7891 x_msg_count => l_msg_count,
7892 x_msg_data => l_msg_data
7893 );
7894 x_detail_rec.cycle_count_quantity := l_det_qty_rec.cycle_count_quantity;
7895
7896 --
7897 wsh_util_core.api_post_call(
7898 p_return_status => l_return_status,
7899 x_num_warnings => l_number_of_warnings,
7900 x_num_errors => l_number_of_errors,
7901 p_msg_data => l_msg_data
7902 );
7903 END IF; -- BugFix 4519867
7904 END IF;
7905
7906 -- HW Harmonization project for OPM. Added cycle_count_qty2
7907 -- HW OPMCONV - Removed checking for process_flag
7908
7909 IF (p_validation_tab(wsh_actions_levels.c_cc_qty2_lvl) = 1) THEN
7910 IF (x_detail_rec.cycle_count_quantity2 <> fnd_api.g_miss_num) THEN
7911 l_det_qty_rec.delivery_detail_id :=
7912 x_detail_rec.delivery_detail_id;
7913 l_det_qty_rec.requested_quantity :=
7914 x_detail_rec.requested_quantity;
7915 l_det_qty_rec.requested_quantity2 :=
7916 x_detail_rec.requested_quantity2;
7917 l_det_qty_rec.picked_quantity := x_detail_rec.picked_quantity;
7918 l_det_qty_rec.picked_quantity2 := x_detail_rec.picked_quantity2;
7919 l_det_qty_rec.shipped_quantity := x_detail_rec.shipped_quantity;
7920 l_det_qty_rec.shipped_quantity2 := x_detail_rec.shipped_quantity2;
7921 l_det_qty_rec.cycle_count_quantity :=
7922 x_detail_rec.cycle_count_quantity;
7923 l_det_qty_rec.cycle_count_quantity2 :=
7924 x_detail_rec.cycle_count_quantity2;
7925 l_det_qty_rec.requested_quantity_uom :=
7926 x_detail_rec.requested_quantity_uom;
7927 l_det_qty_rec.requested_quantity_uom2 :=
7928 x_detail_rec.requested_quantity_uom2;
7929 l_det_qty_rec.ship_tolerance_above :=
7930 x_detail_rec.ship_tolerance_above;
7931 l_det_qty_rec.inventory_item_id := x_detail_rec.inventory_item_id;
7932 l_det_qty_rec.organization_id := x_detail_rec.organization_id;
7933 l_det_qty_rec.serial_number := x_detail_rec.serial_number;
7934 l_det_qty_rec.transaction_temp_id :=
7935 x_detail_rec.transaction_temp_id;
7936 l_det_qty_rec.top_model_line_id := x_detail_rec.top_model_line_id;
7937 -- HW Harmonization project for OPM. Use l_process_flag
7938 -- HW OPMCONV - Removed population of process_flag
7939
7940 IF l_debug_on THEN
7941 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY2', WSH_DEBUG_SV.c_proc_level);
7942 END IF;
7943
7944 --
7945 wsh_details_validations.validate_shipped_cc_quantity2(
7946 p_flag => 'CCQ',
7947 x_det_rec => l_det_qty_rec,
7948 x_return_status => l_return_status,
7949 x_msg_count => l_msg_count,
7950 x_msg_data => l_msg_data
7951 );
7952 x_detail_rec.cycle_count_quantity2 :=
7953 l_det_qty_rec.cycle_count_quantity2;
7954 --
7955 wsh_util_core.api_post_call(
7956 p_return_status => l_return_status,
7957 x_num_warnings => l_number_of_warnings,
7958 x_num_errors => l_number_of_errors,
7959 p_msg_data => l_msg_data
7960 );
7961 END IF; -- of cycle_count_quantity2
7962 END IF; -- of C_CC_QTY2_LVL
7963
7964 -- HW OPM end of changes
7965
7966 IF (p_validation_tab(wsh_actions_levels.c_smc_lvl) = 1) THEN
7967 IF (x_detail_rec.ship_method_code <> fnd_api.g_miss_char) THEN
7968 IF l_debug_on THEN
7969 WSH_DEBUG_SV.log(l_module_name, 'Ship Method', x_detail_rec.ship_method_code);
7970 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_SHIP_METHOD', WSH_DEBUG_SV.c_proc_level);
7971 END IF;
7972
7973 --
7974 wsh_util_validate.validate_ship_method(
7975 p_ship_method_code => x_detail_rec.ship_method_code,
7976 p_ship_method_name => l_ship_method_name,
7977 x_return_status => l_return_status);
7978 --
7979 wsh_util_core.api_post_call(
7980 p_return_status => l_return_status,
7981 x_num_warnings => l_number_of_warnings,
7982 x_num_errors => l_number_of_errors,
7983 p_msg_data => l_msg_data
7984 );
7985 END IF;
7986 END IF;
7987
7988 IF (p_validation_tab(wsh_actions_levels.c_dep_plan_lvl) = 1) THEN
7989 IF (x_detail_rec.dep_plan_required_flag <> fnd_api.g_miss_char) THEN
7990 IF l_debug_on THEN
7991 WSH_DEBUG_SV.log(l_module_name, 'Departure Plan Flag', x_detail_rec.dep_plan_required_flag);
7992 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_BOOLEAN', WSH_DEBUG_SV.c_proc_level);
7993 END IF;
7994
7995 --
7996 wsh_util_validate.validate_boolean(
7997 p_flag => x_detail_rec.dep_plan_required_flag,
7998 x_return_status => l_return_status);
7999 --
8000 wsh_util_core.api_post_call(
8001 p_return_status => l_return_status,
8002 x_num_warnings => l_number_of_warnings,
8003 x_num_errors => l_number_of_errors,
8004 p_msg_data => l_msg_data
8005 );
8006 END IF;
8007 END IF;
8008
8009 IF (p_validation_tab(wsh_actions_levels.c_ship_mod_comp_lvl) = 1) THEN
8010 IF (x_detail_rec.ship_model_complete_flag <> fnd_api.g_miss_char) THEN
8011 IF l_debug_on THEN
8012 WSH_DEBUG_SV.log(l_module_name, 'Ship Model Complete Flag', x_detail_rec.ship_model_complete_flag);
8013 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_BOOLEAN', WSH_DEBUG_SV.c_proc_level);
8014 END IF;
8015
8016 --
8017 wsh_util_validate.validate_boolean(
8018 p_flag => x_detail_rec.ship_model_complete_flag,
8019 x_return_status => l_return_status);
8020 --
8021 wsh_util_core.api_post_call(
8022 p_return_status => l_return_status,
8023 x_num_warnings => l_number_of_warnings,
8024 x_num_errors => l_number_of_errors,
8025 p_msg_data => l_msg_data
8026 );
8027 END IF;
8028 END IF;
8029
8030 IF (p_validation_tab(wsh_actions_levels.c_sub_inv_lvl) = 1) THEN
8031 IF (x_detail_rec.subinventory <> fnd_api.g_miss_char) THEN
8032 IF l_debug_on THEN
8033 WSH_DEBUG_SV.log(l_module_name, 'Subinventory', x_detail_rec.subinventory);
8034 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_SUBINVENTORY', WSH_DEBUG_SV.c_proc_level);
8035 END IF;
8036
8037 --
8038 wsh_delivery_details_inv.validate_subinventory(
8039 p_subinventory => x_detail_rec.subinventory,
8040 p_organization_id => l_org_id,
8041 p_inventory_item_id => p_original_rec.inventory_item_id,
8042 p_transaction_type_id => l_trx_type_id,
8043 p_object_type => 'A',
8044 x_return_status => l_return_status,
8045 x_result => l_result
8046 );
8047 --
8048 IF l_debug_on THEN
8049 WSH_DEBUG_SV.log(l_module_name, 'Result after validate subinventory', l_result);
8050 WSH_DEBUG_SV.log(l_module_name, 'Return status after validate subinventory', l_return_status);
8051 END IF;
8052
8053 IF NOT l_result THEN
8054 IF l_debug_on THEN
8055 WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid subinventory');
8056 END IF;
8057
8058 l_return_status := wsh_util_core.g_ret_sts_error;
8059 END IF;
8060
8061 wsh_util_core.api_post_call(
8062 p_return_status => l_return_status,
8063 x_num_warnings => l_number_of_warnings,
8064 x_num_errors => l_number_of_errors,
8065 p_msg_data => l_msg_data
8066 );
8067 x_mark_reprice_flag := 'Y';
8068 END IF;
8069 END IF;
8070
8071 IF (p_validation_tab(wsh_actions_levels.c_revision_lvl) = 1)
8072 THEN
8073 -- {
8074 IF (x_detail_rec.revision <> fnd_api.g_miss_char)
8075 THEN
8076 -- {
8077 -- UT bug fix 2657367
8078 IF l_debug_on THEN
8079 wsh_debug_sv.log(l_module_name, 'Pickable Flag', p_original_rec.pickable_flag);
8080 wsh_debug_sv.log(l_module_name, 'Rev Flag', l_inv_controls.rev_flag);
8081 END IF;
8082 --
8083 IF p_original_rec.pickable_flag = 'N'
8084 THEN
8085 -- {
8086 IF l_inv_controls.rev_flag = 'N'
8087 AND x_detail_rec.revision IS NOT NULL
8088 THEN
8089 l_number_of_errors := l_number_of_errors + 1;
8090 RAISE FND_API.G_EXC_ERROR;
8091 END IF;
8092 ELSE
8093 IF l_debug_on THEN
8094 WSH_DEBUG_SV.log(l_module_name, 'Revision', x_detail_rec.revision);
8095 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_REVISION', WSH_DEBUG_SV.c_proc_level);
8096 END IF;
8097
8098 wsh_delivery_details_inv.validate_revision(
8099 p_revision => x_detail_rec.revision,
8100 p_organization_id => l_org_id,
8101 p_inventory_item_id => p_original_rec.inventory_item_id,
8102 x_return_status => l_return_status,
8103 x_result => l_result
8104 );
8105
8106 -- Bug fix 2657367. Need to check l_result
8107 IF l_debug_on THEN
8108 WSH_DEBUG_SV.log(l_module_name, 'Result after validate revision', l_result);
8109 WSH_DEBUG_SV.log(l_module_name, 'Return status after validate revision', l_return_status);
8110 END IF;
8111
8112 IF NOT l_result THEN
8113 IF l_debug_on THEN
8114 WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid Revision');
8115 END IF;
8116
8117 RAISE fnd_api.g_exc_error;
8118 END IF;
8119
8120 wsh_util_core.api_post_call(
8121 p_return_status => l_return_status,
8122 x_num_warnings => l_number_of_warnings,
8123 x_num_errors => l_number_of_errors,
8124 p_msg_data => l_msg_data
8125 );
8126 -- }
8127 END IF;
8128 -- }
8129 END IF;
8130 -- }
8131 END IF;
8132
8133 IF (p_validation_tab(wsh_actions_levels.c_locator_lvl) = 1) THEN
8134 IF (x_detail_rec.locator_id <> fnd_api.g_miss_num)
8135 THEN
8136 -- {
8137 -- UT bug fix 2657367
8138 IF l_debug_on THEN
8139 wsh_debug_sv.log(l_module_name, 'Pickable Flag', p_original_rec.pickable_flag);
8140 wsh_debug_sv.log(l_module_name, 'Locator Flag', l_inv_controls.loc_flag);
8141 END IF;
8142 --
8143 IF p_original_rec.pickable_flag = 'N'
8144 THEN
8145 -- {
8146 IF l_inv_controls.loc_flag = 'N'
8147 AND x_detail_rec.locator_id IS NOT NULL
8148 THEN
8149 l_number_of_errors := l_number_of_errors + 1;
8150 RAISE FND_API.G_EXC_ERROR;
8151 END IF;
8152 ELSE
8153
8154 IF l_debug_on THEN
8155 WSH_DEBUG_SV.log(l_module_name, 'Locator Id', x_detail_rec.locator_id);
8156 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_LOCATOR', WSH_DEBUG_SV.c_proc_level);
8157 END IF;
8158 wsh_delivery_details_inv.validate_locator(
8159 p_locator_id => x_detail_rec.locator_id,
8160 p_organization_id => l_org_id,
8161 p_inventory_item_id => p_original_rec.inventory_item_id,
8162 p_subinventory => l_subinventory,
8163 p_transaction_type_id => l_trx_type_id,
8164 p_object_type => 'A',
8165 x_return_status => l_return_status,
8166 x_result => l_result
8167 );
8168
8169 -- Bug fix 2657367. Need to check l_result
8170 IF l_debug_on THEN
8171 WSH_DEBUG_SV.log(l_module_name, 'Result after validate locator', l_result);
8172 WSH_DEBUG_SV.log(l_module_name, 'Return status after validate locator', l_return_status);
8173 END IF;
8174
8175 IF NOT l_result THEN
8176 IF l_debug_on THEN
8177 WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid Locator');
8178 END IF;
8179
8180 RAISE fnd_api.g_exc_error;
8181 END IF;
8182
8183 --
8184 wsh_util_core.api_post_call(
8185 p_return_status => l_return_status,
8186 x_num_warnings => l_number_of_warnings,
8187 x_num_errors => l_number_of_errors,
8188 p_msg_data => l_msg_data
8189 );
8190 -- }
8191 END IF;
8192 -- }
8193 END IF;
8194 END IF;
8195
8196 IF (p_validation_tab(wsh_actions_levels.c_lot_number_lvl) = 1) THEN
8197 IF (x_detail_rec.lot_number <> fnd_api.g_miss_char) THEN
8198 -- HW Harmonization project for OPM. Need to branch
8199 -- HW OPMCONV - Removed branching
8200
8201 -- UT bug fix 2657367
8202 IF l_debug_on THEN
8203 WSH_DEBUG_SV.log(l_module_name, 'Lot Number', x_detail_rec.lot_number);
8204 wsh_debug_sv.log(l_module_name, 'Pickable Flag', p_original_rec.pickable_flag);
8205 wsh_debug_sv.log(l_module_name, 'Lot Flag', l_inv_controls.lot_flag);
8206 END IF;
8207 --
8208 IF nvl(p_original_rec.pickable_flag, 'N') = 'N'
8209 THEN
8210 -- {
8211 IF l_inv_controls.lot_flag = 'N'
8212 AND x_detail_rec.lot_number IS NOT NULL
8213 THEN
8214 -- For non-transactable items, lot number cannot be updated if item is not under lot control
8215 l_number_of_errors := l_number_of_errors + 1;
8216 RAISE FND_API.G_EXC_ERROR;
8217 END IF;
8218 ELSE
8219 -- bug 4766908 get the reservable_flag
8220 IF p_original_rec.released_status = 'Y' THEN
8221 l_reservable_flag := WSH_DELIVERY_DETAILS_INV.get_reservable_flag(
8222 x_item_id => p_original_rec.inventory_item_id,
8223 x_organization_id => p_original_rec.organization_id,
8224 x_pickable_flag => p_original_rec.pickable_flag);
8225 END IF;
8226 IF (nvl(l_reservable_flag, 'Y') = 'Y') THEN
8227 IF l_debug_on THEN
8228 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_LOT_NUMBER', WSH_DEBUG_SV.c_proc_level);
8229 END IF;
8230
8231 wsh_delivery_details_inv.validate_lot_number(
8232 p_lot_number => x_detail_rec.lot_number,
8233 p_organization_id => l_org_id,
8234 p_inventory_item_id => p_original_rec.inventory_item_id,
8235 p_revision => l_revision,
8236 p_subinventory => l_subinventory,
8237 p_locator_id => l_locator,
8238 p_transaction_type_id => l_trx_type_id,
8239 p_object_type => 'A',
8240 x_return_status => l_return_status,
8241 x_result => l_result
8242 );
8243
8244 -- Bug fix 2657367. Need to check l_result
8245 IF l_debug_on THEN
8246 WSH_DEBUG_SV.log(l_module_name, 'Result after validate lot', l_result);
8247 WSH_DEBUG_SV.log(l_module_name, 'Return status after validate lot', l_return_status);
8248 END IF;
8249
8250 IF NOT l_result THEN
8251 IF l_debug_on THEN
8252 WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid Lot Number');
8253 END IF;
8254
8255 RAISE fnd_api.g_exc_error;
8256 END IF;
8257 END IF;
8258 -- }
8259 END IF;
8260 -- HW OPMCONV - Removed branching
8261
8262 -- HW OPM end of changes
8263
8264 --
8265 wsh_util_core.api_post_call(
8266 p_return_status => l_return_status,
8267 x_num_warnings => l_number_of_warnings,
8268 x_num_errors => l_number_of_errors,
8269 p_msg_data => l_msg_data
8270 );
8271 END IF;
8272 END IF;
8273
8274 /* Since we are updating by delivery_detail, make sure source_line_id is populated */
8275 x_detail_rec.source_line_id := p_original_rec.source_line_id;
8276
8277 IF (p_validation_tab(wsh_actions_levels.c_sold_contact_lvl) = 1) THEN
8278 IF (x_detail_rec.sold_to_contact_id <> fnd_api.g_miss_num) THEN
8279 IF l_debug_on THEN
8280 WSH_DEBUG_SV.log(l_module_name, 'Sold to Contact', x_detail_rec.sold_to_contact_id);
8281 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_CONTACT', WSH_DEBUG_SV.c_proc_level);
8282 END IF;
8283
8284 --
8285 wsh_util_validate.validate_contact(
8286 p_contact_id => x_detail_rec.sold_to_contact_id,
8287 x_return_status => l_return_status);
8288 wsh_util_core.api_post_call(
8289 p_return_status => l_return_status,
8290 x_num_warnings => l_number_of_warnings,
8291 x_num_errors => l_number_of_errors,
8292 p_msg_data => l_msg_data
8293 );
8294 END IF;
8295 END IF;
8296
8297 IF (p_validation_tab(wsh_actions_levels.c_ship_contact_lvl) = 1) THEN
8298 IF (x_detail_rec.ship_to_contact_id <> fnd_api.g_miss_num) THEN
8299 IF l_debug_on THEN
8300 WSH_DEBUG_SV.log(l_module_name, 'Ship to Contact Id', x_detail_rec.ship_to_contact_id);
8301 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_CONTACT', WSH_DEBUG_SV.c_proc_level);
8302 END IF;
8303
8304 --
8305 wsh_util_validate.validate_contact(
8306 p_contact_id => x_detail_rec.ship_to_contact_id,
8307 x_return_status => l_return_status);
8308 --
8309 wsh_util_core.api_post_call(
8310 p_return_status => l_return_status,
8311 x_num_warnings => l_number_of_warnings,
8312 x_num_errors => l_number_of_errors,
8313 p_msg_data => l_msg_data
8314 );
8315 END IF;
8316 END IF;
8317
8318 IF (p_validation_tab(wsh_actions_levels.c_deliver_contact_lvl) = 1) THEN
8319 IF (x_detail_rec.deliver_to_contact_id <> fnd_api.g_miss_num) THEN
8320 IF l_debug_on THEN
8321 WSH_DEBUG_SV.log(l_module_name, 'Deliver To Contact', x_detail_rec.deliver_to_contact_id);
8322 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_CONTACT', WSH_DEBUG_SV.c_proc_level);
8323 END IF;
8324
8325 --
8326 wsh_util_validate.validate_contact(
8327 p_contact_id => x_detail_rec.deliver_to_contact_id,
8328 x_return_status => l_return_status);
8329 --
8330 wsh_util_core.api_post_call(
8331 p_return_status => l_return_status,
8332 x_num_warnings => l_number_of_warnings,
8333 x_num_errors => l_number_of_errors,
8334 p_msg_data => l_msg_data
8335 );
8336 END IF;
8337 END IF;
8338
8339 IF (p_validation_tab(wsh_actions_levels.c_intmed_ship_contact_lvl) = 1) THEN
8340 IF (x_detail_rec.intmed_ship_to_contact_id <> fnd_api.g_miss_num) THEN
8341 IF l_debug_on THEN
8342 WSH_DEBUG_SV.log(l_module_name, 'Intmed Ship To Contact', x_detail_rec.intmed_ship_to_contact_id);
8343 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_CONTACT', WSH_DEBUG_SV.c_proc_level);
8344 END IF;
8345
8346 --
8347 wsh_util_validate.validate_contact(
8348 p_contact_id => x_detail_rec.intmed_ship_to_contact_id,
8349 x_return_status => l_return_status);
8350 --
8351 wsh_util_core.api_post_call(
8352 p_return_status => l_return_status,
8353 x_num_warnings => l_number_of_warnings,
8354 x_num_errors => l_number_of_errors,
8355 p_msg_data => l_msg_data
8356 );
8357 END IF;
8358 END IF;
8359
8360 -- HW Harmonization project for OPM. This is applicable for discrete only
8361 -- added a check for l_process_flag
8362 IF (p_validation_tab(wsh_actions_levels.c_serial_num_lvl) = 1) THEN
8363 l_detail_ser_count := 0;
8364 l_detail_ser_qty := 0;
8365 l_index := p_serial_range_tab.FIRST;
8366 l_det_index := 1;
8367 l_update_attributes := FALSE;
8368 l_stamp_ser_wdd := FALSE;
8369 WHILE l_index IS NOT NULL LOOP
8370 IF p_serial_range_tab(l_index).delivery_detail_id =
8371 x_detail_rec.delivery_detail_id THEN
8372
8373
8374 l_det_ser_range_tab(l_det_index).delivery_detail_id := p_serial_range_tab(l_index).delivery_detail_id;
8375 l_det_ser_range_tab(l_det_index).from_serial_number := p_serial_range_tab(l_index).from_serial_number;
8376
8377 -- If to_serial_number is null or is g_miss_char,
8378 -- then default it to from_serial_number
8379 IF ( p_serial_range_tab(l_index).to_serial_number IS NULL ) OR
8380 ( p_serial_range_tab(l_index).to_serial_number =
8381 fnd_api.g_miss_char ) THEN
8382 l_det_ser_range_tab(l_det_index).to_serial_number
8383 := p_serial_range_tab(l_index).from_serial_number;
8384 ELSE
8385 l_det_ser_range_tab(l_det_index).to_serial_number
8386 := p_serial_range_tab(l_index).to_serial_number;
8387 END IF;
8388
8389 l_det_ser_range_tab(l_det_index).quantity := p_serial_range_tab(l_index).quantity;
8390
8391 l_detail_ser_qty := l_detail_ser_qty + p_serial_range_tab(l_index).quantity;
8392 -- Bug 3628620, populate msnt flexfield attributes if the from/to serial numbers
8393 -- are the same.
8394 IF NVL(l_det_ser_range_tab(l_det_index).to_serial_number, l_det_ser_range_tab(l_det_index).from_serial_number) =
8395 l_det_ser_range_tab(l_det_index).from_serial_number
8396 THEN
8397 l_det_ser_range_tab(l_det_index).attribute_category := p_serial_range_tab(l_index).attribute_category;
8398 l_det_ser_range_tab(l_det_index).attribute1 := p_serial_range_tab(l_index).attribute1;
8399 l_det_ser_range_tab(l_det_index).attribute2 := p_serial_range_tab(l_index).attribute2;
8400 l_det_ser_range_tab(l_det_index).attribute3 := p_serial_range_tab(l_index).attribute3;
8401 l_det_ser_range_tab(l_det_index).attribute4 := p_serial_range_tab(l_index).attribute4;
8402 l_det_ser_range_tab(l_det_index).attribute5 := p_serial_range_tab(l_index).attribute5;
8403 l_det_ser_range_tab(l_det_index).attribute6 := p_serial_range_tab(l_index).attribute6;
8404 l_det_ser_range_tab(l_det_index).attribute7 := p_serial_range_tab(l_index).attribute7;
8405 l_det_ser_range_tab(l_det_index).attribute8 := p_serial_range_tab(l_index).attribute8;
8406 l_det_ser_range_tab(l_det_index).attribute9 := p_serial_range_tab(l_index).attribute9;
8407 l_det_ser_range_tab(l_det_index).attribute10 := p_serial_range_tab(l_index).attribute10;
8408 l_det_ser_range_tab(l_det_index).attribute11 := p_serial_range_tab(l_index).attribute11;
8409 l_det_ser_range_tab(l_det_index).attribute12 := p_serial_range_tab(l_index).attribute12;
8410 l_det_ser_range_tab(l_det_index).attribute13 := p_serial_range_tab(l_index).attribute13;
8411 l_det_ser_range_tab(l_det_index).attribute14 := p_serial_range_tab(l_index).attribute14;
8412 l_det_ser_range_tab(l_det_index).attribute15 := p_serial_range_tab(l_index).attribute15;
8413 END IF;
8414 l_det_index := l_det_index +1;
8415 END IF;
8416
8417 l_index := p_serial_range_tab.NEXT(l_index);
8418 END LOOP;
8419
8420 l_detail_ser_count := l_det_ser_range_tab.count;
8421
8422 IF l_debug_on THEN
8423 WSH_DEBUG_SV.log(l_module_name, 'Current detail count', l_detail_ser_count);
8424 WSH_DEBUG_SV.log(l_module_name, 'Total serial qty in table', l_detail_ser_qty);
8425 END IF;
8426
8427 IF l_detail_ser_count >= 1
8428 THEN
8429 -- (
8430 IF l_debug_on THEN
8431 WSH_DEBUG_SV.log(l_module_name, 'input from serial number', p_in_detail_rec.serial_number);
8432 WSH_DEBUG_SV.log(l_module_name, 'input to_serial_number', p_in_detail_rec.to_serial_number);
8433 END IF;
8434
8435 IF (
8436 p_in_detail_rec.serial_number IS NOT NULL
8437 AND p_in_detail_rec.serial_number <> fnd_api.g_miss_char
8438 )
8439 OR (
8440 p_in_detail_rec.to_serial_number IS NOT NULL
8441 AND p_in_detail_rec.to_serial_number <> fnd_api.g_miss_char
8442 )
8443 THEN
8444 -- (
8445 -- Error case. Inputs should be mutually exclusive
8446 IF l_debug_on THEN
8447 WSH_DEBUG_SV.logmsg(l_module_name, 'Serial number input not mutually exclusive');
8448 END IF;
8449
8450 RAISE fnd_api.g_exc_error;
8451 -- )
8452 END IF;
8453 ELSIF l_detail_ser_count = 0
8454 THEN
8455 IF p_in_detail_rec.serial_number IS NOT NULL
8456 AND p_in_detail_rec.serial_number <> fnd_api.g_miss_char
8457 THEN
8458 -- (
8459 l_det_ser_range_tab(1).delivery_detail_id := x_detail_rec.delivery_detail_id;
8460 l_det_ser_range_tab(1).from_serial_number := p_in_detail_rec.serial_number;
8461
8462 IF p_in_detail_rec.to_serial_number <> fnd_api.g_miss_char
8463 THEN
8464 -- (
8465 l_det_ser_range_tab(1).to_serial_number := p_in_detail_rec.to_serial_number;
8466 -- )
8467 END IF;
8468
8469 l_det_ser_range_tab(1).quantity := x_detail_rec.shipped_quantity;
8470 l_detail_ser_count := l_detail_ser_count + 1;
8471 l_detail_ser_qty := l_detail_ser_qty + x_detail_rec.shipped_quantity;
8472
8473 -- If From and To Serial Number is same,
8474 -- then stamp serial number on wdd and do not
8475 -- generate transaction_temp_id
8476 IF l_det_ser_range_tab(1).from_serial_number
8477 = NVL(l_det_ser_range_tab(1).to_serial_number,
8478 l_det_ser_range_tab(1).from_serial_number) THEN
8479 IF l_debug_on THEN
8480 WSH_DEBUG_SV.logmsg(l_module_name, 'Stamp serial number on wdd');
8481 END IF;
8482 l_stamp_ser_wdd := TRUE;
8483 END IF;
8484
8485 ELSE
8486 IF p_in_detail_rec.to_serial_number IS NOT NULL
8487 AND p_in_detail_rec.to_serial_number <> fnd_api.g_miss_char
8488 THEN
8489 -- (
8490 -- To serial number cannot exist with a from serial number
8491 IF l_debug_on THEN
8492 WSH_DEBUG_SV.logmsg(l_module_name, 'From serial number is null');
8493 END IF;
8494
8495 RAISE fnd_api.g_exc_error;
8496 -- )
8497 END IF;
8498 -- )
8499 END IF;
8500 -- )
8501 END IF;
8502
8503
8504 IF l_detail_ser_count >= 1
8505 THEN
8506 -- (
8507 --bug 4365589
8508 IF p_in_rec.caller = 'WSH_PUB'
8509 AND l_inv_controls.serial_code IN (2,5)
8510 THEN --{
8511 IF (wsh_util_validate.Check_Wms_Org(l_org_id)='Y') THEN --{
8512 IF l_debug_on THEN
8513 WSH_DEBUG_SV.logmsg(l_module_name, 'Cannot modify the serial numbers for WMS organizationx ');
8514 END IF;
8515
8516 RAISE fnd_api.g_exc_error;
8517 END IF; --}
8518 END IF;--}
8519
8520 -- Check 1: When serial number is input, Released Status should be Y or X
8521 IF p_original_rec.released_status NOT IN('Y', 'X')
8522 THEN
8523 -- (
8524 IF l_debug_on THEN
8525 WSH_DEBUG_SV.logmsg(l_module_name, 'Released Status Not in X,Y');
8526 END IF;
8527
8528 RAISE fnd_api.g_exc_error;
8529 -- )
8530 END IF;
8531
8532 -- Check 2: When serial number is input, Shipped Qty should not be null or Zero. Bug 2652300
8533 IF nvl(x_detail_rec.shipped_quantity, nvl(p_original_rec.shipped_quantity,0)) = 0
8534 THEN
8535 -- (
8536 -- Bug 2652300. Cannot update serial number if shipped qty is null or zero
8537 IF l_debug_on THEN
8538 WSH_DEBUG_SV.logmsg(l_module_name, 'Shipped qty zero or null. Not null serial number');
8539 END IF;
8540 raise FND_API.G_EXC_ERROR;
8541 ELSIF nvl(x_detail_rec.shipped_quantity, nvl(p_original_rec.shipped_quantity,0)) > 1
8542 THEN
8543 -- Check 3: If shipped qty is greater than one,
8544 -- if table count is one, then to_serial_number should exist. Bug 2652319
8545 IF l_detail_ser_count = 1
8546 AND l_det_ser_range_tab(l_det_ser_range_tab.first).to_serial_number IS NULL
8547 THEN
8548 -- (
8549 IF l_debug_on THEN
8550 WSH_DEBUG_SV.logmsg(l_module_name, 'Shipped qty greater than one. No to_serial_number');
8551 END IF;
8552 raise FND_API.G_EXC_ERROR;
8553 -- )
8554 END IF;
8555 -- )
8556 END IF;
8557
8558 -- Check 3: Sum of Serial number qty should not be greater than shipped qty
8559 IF l_detail_ser_qty > x_detail_rec.shipped_quantity
8560 THEN
8561 -- (
8562 -- Total quantity in serial table should not be greater than shipped qty
8563 -- Error case.
8564 IF l_debug_on THEN
8565 WSH_DEBUG_SV.logmsg(l_module_name, 'Serial table qty greater than shipped qty');
8566 END IF;
8567 RAISE fnd_api.g_exc_error;
8568 ELSIF l_detail_ser_qty = 1
8569 THEN
8570 IF l_debug_on THEN
8571 WSH_DEBUG_SV.log(l_module_name, 'table from serial num', l_det_ser_range_tab(1).from_serial_number);
8572 WSH_DEBUG_SV.log(l_module_name, 'table to seral num', l_det_ser_range_tab(1).to_serial_number);
8573 END IF;
8574
8575 IF l_det_ser_range_tab(1).from_serial_number IS NOT NULL
8576 THEN
8577 -- (
8578 x_detail_rec.serial_number := l_det_ser_range_tab(1).from_serial_number;
8579 ELSE
8580 -- Record cannot exist without a from serial number
8581 IF l_debug_on THEN
8582 WSH_DEBUG_SV.logmsg(l_module_name, 'From serial number is null');
8583 END IF;
8584
8585 RAISE fnd_api.g_exc_error;
8586 -- )
8587 END IF;
8588 ELSIF l_detail_ser_qty > 1
8589 THEN
8590 SELECT mtl_material_transactions_s.NEXTVAL
8591 INTO l_transaction_id
8592 FROM DUAL;
8593 END IF;
8594
8595 -- Bug 3628620. We allow update of serial number attributes only if the
8596 -- serial number exists (implies shipped qty = 1) in wdd and the user is
8597 -- not attempting to change the serial number.
8598 -- If the transaction temp id exists in wdd, then the record exists in
8599 -- msnt, and the user can update msnt using the INV API.
8600
8601 l_index := l_det_ser_range_tab.first;
8602 IF l_det_ser_range_tab.count = 1
8603 AND l_det_ser_range_tab(l_index).quantity = 1 THEN
8604 --{
8605 IF l_det_ser_range_tab(l_index).from_serial_number =
8606 NVL(l_det_ser_range_tab(l_index).to_serial_number,
8607 l_det_ser_range_tab(l_index).from_serial_number)
8608 AND (l_det_ser_range_tab(l_index).from_serial_number =
8609 p_original_rec.serial_number) THEN
8610 --{
8611 -- We are not changing the serial number, we are only updating
8612 -- the serial number attributes.
8613 -- create new record in msnt using the group_mark_id from msn.
8614 -- Bug 4016863 : We generate a new transaction_temp_id and call
8615 -- Update_Marked_serial API later
8616 --
8617 IF l_debug_on THEN
8618 WSH_DEBUG_SV.logmsg(l_module_name,
8619 'Generating txn temp ID for existing serial number');
8620 END IF;
8621 --
8622 SELECT mtl_material_transactions_s.NEXTVAL
8623 INTO l_transaction_id
8624 FROM DUAL;
8625 --
8626 l_update_attributes := TRUE;
8627 --}
8628 ELSE
8629 --{
8630 IF NOT l_stamp_ser_wdd THEN
8631 IF l_debug_on THEN
8632 WSH_DEBUG_SV.logmsg(l_module_name,
8633 'generate transaction temp id');
8634 END IF;
8635 SELECT mtl_material_transactions_s.NEXTVAL
8636 INTO l_transaction_id
8637 FROM DUAL;
8638 END IF;
8639 --}
8640 END IF;
8641 --}
8642 END IF;
8643
8644 -- )
8645 END IF; -- if l_detail_ser_count >=1
8646
8647 IF l_debug_on THEN
8648 WSH_DEBUG_SV.log(l_module_name, 'Transaction id created', l_transaction_id);
8649 END IF;
8650
8651 -- HW OPMCONV - Removed checking for l_process_flag
8652 IF (
8653 (
8654 (x_detail_rec.serial_number <> fnd_api.g_miss_char)
8655 OR x_detail_rec.serial_number IS NULL
8656 OR l_detail_ser_count > 0
8657 )
8658 -- AND l_process_flag = '0'
8659 )
8660 THEN
8661 -- (
8662
8663 IF l_debug_on THEN
8664 WSH_DEBUG_SV.log(l_module_name, 'Serial Number', x_detail_rec.serial_number);
8665 WSH_DEBUG_SV.log(l_module_name, 'To Serial Number', x_detail_rec.to_serial_number);
8666 END IF;
8667
8668 --
8669 IF l_debug_on THEN
8670 WSH_DEBUG_SV.log(l_module_name, 'inv control ser flag', l_inv_controls.ser_flag);
8671 END IF;
8672
8673 -- Fix added to check the serial number before setting the message.
8674 -- If Serial Flag is N, need to set the message only if serial numbers are populated
8675 IF x_detail_rec.serial_number IS NOT NULL
8676 OR x_detail_rec.to_serial_number IS NOT NULL
8677 OR l_detail_ser_count > 0
8678 THEN
8679 -- (
8680 IF l_inv_controls.ser_flag = 'N'
8681 THEN
8682 -- (
8683 l_return_status := wsh_util_core.g_ret_sts_error;
8684 fnd_message.set_name('WSH', 'WSH_INV_INVALID');
8685 fnd_message.set_token('INV_ATTRIBUTE', 'Serial Number Code');
8686 wsh_util_core.add_message(l_return_status);
8687 RAISE fnd_api.g_exc_error;
8688 -- )
8689 END IF;
8690 -- )
8691 END IF;
8692
8693 /* Bug fix: 2652300. Removed the code to call unmark serial numbers.
8694 Unmarking of serial numbers is now done in the api
8695 wsh_details_validations.validate_shipped_cc_qty , based on the shipped quantity and the serial quantity.
8696 It is no longer done here in the group API.*/
8697
8698 -- Bug 3628620
8699 -- Handle Unmark Serial Number for Public API
8700 IF p_in_rec.caller = 'WSH_PUB' THEN
8701
8702 -- Serial Number is being modified from Not null to Null/Not Null value,
8703 -- Unmark using serial number
8704 IF p_original_rec.serial_number IS NOT NULL AND
8705 l_detail_ser_qty = 1 AND l_update_attributes = FALSE AND
8706 x_detail_rec.serial_number <> fnd_api.g_miss_char
8707 -- AND (x_detail_rec.serial_number IS NULL OR
8708 -- x_detail_rec.serial_number <> p_original_rec.serial_number)
8709 THEN
8710
8711 IF l_debug_on THEN
8712 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.UNMARK_SERIAL_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
8713 WSH_DEBUG_SV.log(l_module_name,'Case1',p_original_rec.serial_number);
8714 END IF;
8715 wsh_delivery_details_inv.unmark_serial_number(
8716 p_delivery_detail_id => p_in_detail_rec.delivery_detail_id,
8717 p_serial_number_code => l_inv_controls.serial_code,
8718 p_serial_number => p_original_rec.serial_number,
8719 p_transaction_temp_id => NULL,
8720 x_return_status => l_return_status,
8721 p_inventory_item_id => p_original_rec.inventory_item_id);
8722
8723 IF l_debug_on THEN
8724 wsh_debug_sv.log(l_module_name, 'Return status after Unmark ', l_return_status);
8725 END IF;
8726
8727 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
8728 RAISE fnd_api.g_exc_error;
8729 END IF;
8730
8731 -- Transaction temp id exists in WDD,now 1 serial number is being
8732 -- specified, unmark using transaction temp id
8733 ELSIF (p_original_rec.transaction_temp_id IS NOT NULL AND
8734 x_detail_rec.serial_number <> fnd_api.g_miss_char AND
8735 l_detail_ser_qty = 1 AND l_update_attributes = FALSE)
8736 OR
8737 (p_original_rec.transaction_temp_id IS NOT NULL AND
8738 l_det_ser_range_tab.count > 0 AND
8739 l_detail_ser_qty > 1)
8740 THEN
8741 -- derive serial number from MSNT for this transaction temp id
8742 -- compare with x_detail_rec.serial_number
8743
8744 IF l_debug_on THEN
8745 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.UNMARK_SERIAL_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
8746 WSH_DEBUG_SV.log(l_module_name,'Case2',p_original_rec.transaction_temp_id);
8747 END IF;
8748 wsh_delivery_details_inv.unmark_serial_number(
8749 p_delivery_detail_id => p_in_detail_rec.delivery_detail_id,
8750 p_serial_number_code => l_inv_controls.serial_code,
8751 p_serial_number => NULL,
8752 p_transaction_temp_id => p_original_rec.transaction_temp_id,
8753 x_return_status => l_return_status,
8754 p_inventory_item_id => p_original_rec.inventory_item_id);
8755
8756 IF l_debug_on THEN
8757 wsh_debug_sv.log(l_module_name, 'Return status after Unmark ', l_return_status);
8758 END IF;
8759
8760 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
8761 RAISE fnd_api.g_exc_error;
8762 END IF;
8763
8764 END IF;
8765 END IF;
8766 -- End of Bug 3628620
8767
8768 l_det_index := l_det_ser_range_tab.FIRST;
8769
8770 WHILE l_det_index IS NOT NULL
8771 LOOP
8772 -- (
8773 --
8774 IF l_det_ser_range_tab(l_det_index).from_serial_number IS NOT NULL THEN
8775 -- Bug 3628620. Skip validation if we are only updating the serial number flexfield attributes.
8776 IF NOT l_update_attributes THEN
8777 IF l_inv_controls.ser_flag = 'Y' THEN
8778 IF l_det_ser_range_tab(l_det_index).to_serial_number IS NOT NULL THEN -- bug 1578114 condition added
8779 IF l_debug_on THEN
8780 WSH_DEBUG_SV.log(l_module_name, 'To Serial Number', l_det_ser_range_tab(l_det_index).to_serial_number);
8781 WSH_DEBUG_SV.log(l_module_name, 'Transaction Id', l_transaction_id);
8782 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_SERIAL_RANGE', WSH_DEBUG_SV.c_proc_level);
8783 END IF;
8784
8785 --
8786 -- Validates the Range of Serial Number
8787 wsh_delivery_details_inv.validate_serial_range(
8788 p_from_serial_number => l_det_ser_range_tab(l_det_index).from_serial_number,
8789 p_to_serial_number => l_det_ser_range_tab(l_det_index).to_serial_number,
8790 p_lot_number => l_lot,
8791 p_organization_id => l_org_id,
8792 p_inventory_item_id => p_original_rec.inventory_item_id,
8793 p_subinventory => l_subinventory,
8794 p_revision => l_revision,
8795 p_locator_id => l_locator,
8796 p_quantity => l_det_ser_range_tab(l_det_index).quantity,
8797 p_transaction_type_id => l_trx_type_id,
8798 p_object_type => 'A',
8799 x_prefix => l_prefix,
8800 x_return_status => l_return_status,
8801 x_result => l_result
8802 );
8803
8804 --
8805 IF l_debug_on THEN
8806 WSH_DEBUG_SV.log(l_module_name, 'Prefix',l_prefix);
8807 WSH_DEBUG_SV.log(l_module_name, 'Result',l_result);
8808 WSH_DEBUG_SV.log(l_module_name, 'Return Status',l_return_status);
8809 END IF;
8810
8811 IF NOT l_result THEN
8812 l_return_status := wsh_util_core.g_ret_sts_error;
8813 END IF;
8814
8815 wsh_util_core.api_post_call(
8816 p_return_status => l_return_status,
8817 x_num_warnings => l_number_of_warnings,
8818 x_num_errors => l_number_of_errors,
8819 p_msg_data => l_msg_data
8820 );
8821 ELSE
8822 IF l_debug_on THEN
8823 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.VALIDATE_SERIAL', WSH_DEBUG_SV.c_proc_level);
8824 END IF;
8825
8826 --
8827 wsh_delivery_details_inv.validate_serial(
8828 p_serial_number => l_det_ser_range_tab(l_det_index).from_serial_number,
8829 p_lot_number => l_lot,
8830 p_organization_id => l_org_id,
8831 p_inventory_item_id => p_original_rec.inventory_item_id,
8832 p_subinventory => l_subinventory,
8833 p_revision => l_revision,
8834 p_locator_id => l_locator,
8835 p_transaction_type_id => l_trx_type_id,
8836 p_object_type => 'A',
8837 x_return_status => l_return_status,
8838 x_result => l_result
8839 );
8840 --
8841 IF l_debug_on THEN
8842 WSH_DEBUG_SV.log(l_module_name, 'Result',l_result);
8843 WSH_DEBUG_SV.log(l_module_name, 'Return Status',l_return_status);
8844 END IF;
8845 --
8846 IF NOT l_result THEN
8847 l_return_status := wsh_util_core.g_ret_sts_error;
8848 END IF;
8849 --
8850 wsh_util_core.api_post_call(
8851 p_return_status => l_return_status,
8852 x_num_warnings => l_number_of_warnings,
8853 x_num_errors => l_number_of_errors,
8854 p_msg_data => l_msg_data
8855 );
8856 END IF; -- if to_serial_number is not null
8857
8858
8859 ELSIF l_inv_controls.ser_flag = 'D' THEN
8860 IF l_debug_on THEN
8861 WSH_DEBUG_SV.log(l_module_name, 'to serial number', l_det_ser_range_tab(l_det_index).to_serial_number);
8862 END IF;
8863
8864 IF (
8865 l_det_ser_range_tab(l_det_index).to_serial_number <>
8866 fnd_api.g_miss_char
8867 )
8868 AND l_det_ser_range_tab(l_det_index).to_serial_number IS NOT NULL THEN -- bug 1578114 condition added
8869 IF l_debug_on THEN
8870 WSH_DEBUG_SV.log(l_module_name, 'Transaction id created', l_transaction_id);
8871 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.CREATE_DYNAMIC_SERIAL_RANGE', WSH_DEBUG_SV.c_proc_level);
8872 END IF;
8873
8874 --
8875 -- Creates/Validates the Range of Serial Number
8876 wsh_delivery_details_inv.create_dynamic_serial_range(
8877 p_from_number => l_det_ser_range_tab(l_det_index).from_serial_number,
8878 p_to_number => l_det_ser_range_tab(l_det_index).to_serial_number,
8879 -- Earlier l_transaction_id was being passed to p_delivery_detail below (frontport from 1159) - jckwok
8880 p_delivery_detail_id => x_detail_rec.delivery_detail_id,
8881 p_source_line_id => p_original_rec.source_line_id,
8882 p_lot_number => l_lot,
8883 p_organization_id => l_org_id,
8884 p_inventory_item_id => p_original_rec.inventory_item_id,
8885 p_subinventory => l_subinventory,
8886 p_revision => l_revision,
8887 p_locator_id => l_locator,
8888 p_quantity => l_det_ser_range_tab(l_det_index).quantity,
8889 x_prefix => l_prefix,
8890 x_return_status => l_return_status
8891 );
8892 --
8893 wsh_util_core.api_post_call(
8894 p_return_status => l_return_status,
8895 x_num_warnings => l_number_of_warnings,
8896 x_num_errors => l_number_of_errors,
8897 p_msg_data => l_msg_data
8898 );
8899 ELSE
8900 IF l_debug_on THEN
8901 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.CREATE_DYNAMIC_SERIAL', WSH_DEBUG_SV.c_proc_level);
8902 END IF;
8903
8904 --
8905 wsh_delivery_details_inv.create_dynamic_serial(
8906 p_from_number => l_det_ser_range_tab(l_det_index).from_serial_number,
8907 p_to_number => l_det_ser_range_tab(l_det_index).from_serial_number,
8908 p_delivery_detail_id => x_detail_rec.delivery_detail_id,
8909 p_source_line_id => p_original_rec.source_line_id,
8910 p_lot_number => l_lot,
8911 p_organization_id => l_org_id,
8912 p_inventory_item_id => p_original_rec.inventory_item_id,
8913 p_subinventory => l_subinventory,
8914 p_revision => l_revision,
8915 p_locator_id => l_locator,
8916 x_return_status => l_return_status
8917 );
8918 --
8919 wsh_util_core.api_post_call(
8920 p_return_status => l_return_status,
8921 x_num_warnings => l_number_of_warnings,
8922 x_num_errors => l_number_of_errors,
8923 p_msg_data => l_msg_data
8924 );
8925 END IF; -- if to_serial_number is not null
8926 END IF; -- IF l_controls.ser_flag = 'D'/'Y'
8927
8928 END IF; -- IF NOT l_update_attributes THEN
8929
8930
8931 IF l_transaction_id IS NOT NULL
8932 AND l_det_ser_range_tab(l_det_index).to_serial_number IS NOT NULL THEN --bug 1578114 condition added
8933 v1 := l_transaction_id;
8934 v2 := SYSDATE;
8935 v3 := fnd_global.user_id;
8936 v4 := SYSDATE;
8937 v5 := fnd_global.user_id;
8938 v6 := fnd_global.login_id;
8939 v7 := NULL;
8940 v8 := NULL;
8941 v9 := NULL;
8942 v10 := SYSDATE;
8943 v11 := NULL;
8944 v12 := l_lot;
8945 v13 :=
8946 l_det_ser_range_tab(l_det_index).from_serial_number;
8947 v14 := l_det_ser_range_tab(l_det_index).to_serial_number;
8948 v15 := l_det_ser_range_tab(l_det_index).quantity;
8949 v16 := NULL;
8950 v17 := l_transaction_id;
8951 v18 := NULL;
8952 v19 := l_det_ser_range_tab(l_det_index).attribute_category;
8953 v20 := l_det_ser_range_tab(l_det_index).attribute1;
8954 v21 := l_det_ser_range_tab(l_det_index).attribute2;
8955 v22 := l_det_ser_range_tab(l_det_index).attribute3;
8956 v23 := l_det_ser_range_tab(l_det_index).attribute4;
8957 v24 := l_det_ser_range_tab(l_det_index).attribute5;
8958 v25 := l_det_ser_range_tab(l_det_index).attribute6;
8959 v26 := l_det_ser_range_tab(l_det_index).attribute7;
8960 v27 := l_det_ser_range_tab(l_det_index).attribute8;
8961 v28 := l_det_ser_range_tab(l_det_index).attribute9;
8962 v29 := l_det_ser_range_tab(l_det_index).attribute10;
8963 v30 := l_det_ser_range_tab(l_det_index).attribute11;
8964 v31 := l_det_ser_range_tab(l_det_index).attribute12;
8965 v32 := l_det_ser_range_tab(l_det_index).attribute13;
8966 v33 := l_det_ser_range_tab(l_det_index).attribute14;
8967 v34 := l_det_ser_range_tab(l_det_index).attribute15;
8968 -- Bug 3628620: INV wants DFF_UPDATED_FLAG to be populated
8969 -- to 'Y' if there are dff attributes in msnt
8970 IF v20 IS NOT NULL OR
8971 v21 IS NOT NULL OR
8972 v22 IS NOT NULL OR
8973 v23 IS NOT NULL OR
8974 v24 IS NOT NULL OR
8975 v25 IS NOT NULL OR
8976 v26 IS NOT NULL OR
8977 v27 IS NOT NULL OR
8978 v28 IS NOT NULL OR
8979 v29 IS NOT NULL OR
8980 v30 IS NOT NULL OR
8981 v31 IS NOT NULL OR
8982 v32 IS NOT NULL OR
8983 v33 IS NOT NULL OR
8984 v34 IS NOT NULL
8985 THEN
8986 v35 := 'Y';
8987 ELSE
8988 v35 := 'N';
8989 END IF;
8990
8991 IF l_debug_on THEN
8992 WSH_DEBUG_SV.logmsg(l_module_name, 'Inserting record into msnt');
8993 END IF;
8994
8995 INSERT INTO mtl_serial_numbers_temp
8996 (
8997 transaction_temp_id, last_update_date,
8998 last_updated_by, creation_date,
8999 created_by, last_update_login, request_id,
9000 program_application_id, program_id,
9001 program_update_date, vendor_serial_number,
9002 vendor_lot_number, fm_serial_number,
9003 to_serial_number, serial_prefix,
9004 ERROR_CODE, group_header_id,
9005 parent_serial_number,
9006 attribute_category,
9007 attribute1,
9008 attribute2,
9009 attribute3,
9010 attribute4,
9011 attribute5,
9012 attribute6,
9013 attribute7,
9014 attribute8,
9015 attribute9,
9016 attribute10,
9017 attribute11,
9018 attribute12,
9019 attribute13,
9020 attribute14,
9021 attribute15,
9022 dff_updated_flag
9023 )
9024 VALUES (
9025 v1, v2,
9026 v3, v4,
9027 v5, v6, v7,
9028 v8, v9,
9029 v10, v11,
9030 v12, v13,
9031 v14, v15,
9032 v16, v17,
9033 v18,
9034 v19,
9035 v20,
9036 v21,
9037 v22,
9038 v23,
9039 v24,
9040 v25,
9041 v26,
9042 v27,
9043 v28,
9044 v29,
9045 v30,
9046 v31,
9047 v32,
9048 v33,
9049 v34,
9050 v35
9051 );
9052 END IF; -- if l_transaction_id is not null
9053 END IF; -- If new serial number is not null
9054
9055 l_det_index := l_det_ser_range_tab.NEXT(l_det_index);
9056 -- )
9057 END LOOP; -- while l_det_index of serial_range_tab is not null
9058
9059 IF l_debug_on THEN
9060 WSH_DEBUG_SV.log(l_module_name, 'Transaction Id', l_transaction_id);
9061 END IF;
9062
9063 IF NOT l_update_attributes THEN
9064 --{
9065 IF l_transaction_id IS NOT NULL
9066 THEN
9067 -- (
9068 wsh_delivery_details_inv.mark_serial_number(
9069 p_delivery_detail_id => x_detail_rec.delivery_detail_id,
9070 p_serial_number => NULL,
9071 p_transaction_temp_id => l_transaction_id,
9072 x_return_status => l_return_status
9073 );
9074 wsh_util_core.api_post_call(
9075 p_return_status => l_return_status,
9076 x_num_warnings => l_number_of_warnings,
9077 x_num_errors => l_number_of_errors,
9078 p_msg_data => l_msg_data
9079 );
9080 ELSIF p_in_detail_rec.serial_number IS NOT NULL
9081 AND p_in_detail_rec.serial_number <> FND_API.G_MISS_CHAR
9082 THEN
9083 --
9084 IF l_debug_on THEN
9085 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_DELIVERY_DETAILS_INV.MARK_SERIAL_NUMBER', WSH_DEBUG_SV.c_proc_level);
9086 END IF;
9087
9088 --
9089 wsh_delivery_details_inv.mark_serial_number(
9090 p_delivery_detail_id => x_detail_rec.delivery_detail_id,
9091 p_serial_number => p_in_detail_rec.serial_number,
9092 p_transaction_temp_id => l_transaction_id,
9093 x_return_status => l_return_status
9094 );
9095 wsh_util_core.api_post_call(
9096 p_return_status => l_return_status,
9097 x_num_warnings => l_number_of_warnings,
9098 x_num_errors => l_number_of_errors,
9099 p_msg_data => l_msg_data
9100 );
9101 -- Since only single serial number exists, transaction_temp_id if exists, should be nulled
9102 x_detail_rec.transaction_temp_id := NULL;
9103 --)
9104 END IF;
9105 --}
9106 ELSE
9107 --{
9108 -- Bug 4016863 : Need to mark existing serial number with
9109 -- newly generated transaction_temp_id in the scenario where
9110 -- only the serial attributes are updated and not the serial #
9111 --
9112 IF l_debug_on THEN
9113 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.UPDATE_MARKED_SERIAL',WSH_DEBUG_SV.C_PROC_LEVEL);
9114 END IF;
9115 --
9116 WSH_DELIVERY_DETAILS_INV.Update_Marked_Serial(
9117 p_from_serial_number => p_original_rec.serial_number,
9118 p_to_serial_number => NULL, -- always pass NULL for single serial number
9119 p_inventory_item_id => p_original_rec.inventory_item_id,
9120 p_organization_id => l_org_id,
9121 p_transaction_temp_id => l_transaction_id,
9122 x_return_status => l_return_status);
9123 --
9124 IF l_debug_on THEN
9125 wsh_debug_sv.log(l_module_name, 'Return status after Update_Marked_Serial ', l_return_status);
9126 END IF;
9127 --
9128 IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
9129 RAISE fnd_api.g_exc_error;
9130 END IF;
9131 --}
9132 END IF; -- l_update_attributes;
9133 -- )
9134 END IF; -- serial number g_miss_num
9135
9136 IF l_transaction_id IS NOT NULL THEN
9137 x_detail_rec.transaction_temp_id := l_transaction_id;
9138 x_detail_rec.serial_number := NULL;
9139 x_detail_rec.to_serial_number := NULL;
9140 END IF;
9141
9142 IF NVL(x_detail_rec.shipped_quantity, 0) = 0 THEN
9143 IF l_debug_on THEN
9144 WSH_DEBUG_SV.logmsg(l_module_name, 'Zero or Null shipped qty');
9145 END IF;
9146
9147 x_detail_rec.serial_number := NULL;
9148 x_detail_rec.to_serial_number := NULL;
9149 x_detail_rec.transaction_temp_id := NULL;
9150 END IF;
9151
9152 -- If from serial number = to serial number, only from serial number should be populated
9153 IF x_detail_rec.serial_number = x_detail_rec.to_serial_number THEN
9154 x_detail_rec.to_serial_number := NULL;
9155 END IF;
9156
9157 IF l_debug_on THEN
9158 WSH_DEBUG_SV.log(l_module_name, 'transaction temp id', x_detail_rec.transaction_temp_id);
9159 WSH_DEBUG_SV.log(l_module_name, 'serial number', x_detail_rec.serial_number);
9160 WSH_DEBUG_SV.log(l_module_name, 'to_serial_number', x_detail_rec.to_serial_number);
9161 END IF;
9162 END IF; -- if check for validation level
9163
9164 fnd_msg_pub.count_and_get(
9165 p_count => x_msg_count,
9166 p_data => x_msg_data,
9167 p_encoded => fnd_api.g_false);
9168
9169 IF l_debug_on THEN
9170 WSH_DEBUG_SV.pop(l_module_name);
9171 END IF;
9172 --
9173 EXCEPTION
9174 WHEN fnd_api.g_exc_error THEN
9175 ROLLBACK TO validate_det_line_grp;
9176 x_return_status := fnd_api.g_ret_sts_error;
9177 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data,
9178 p_encoded => fnd_api.g_false);
9179
9180 --
9181 IF l_debug_on THEN
9182 WSH_DEBUG_SV.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', WSH_DEBUG_SV.c_excep_level);
9183 WSH_DEBUG_SV.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
9184 END IF;
9185 --
9186 WHEN fnd_api.g_exc_unexpected_error THEN
9187 ROLLBACK TO validate_det_line_grp;
9188 x_return_status := fnd_api.g_ret_sts_unexp_error;
9189 fnd_msg_pub.count_and_get(
9190 p_count => x_msg_count,
9191 p_data => x_msg_data,
9192 p_encoded => fnd_api.g_false);
9193
9194 --
9195 IF l_debug_on THEN
9196 WSH_DEBUG_SV.logmsg(l_module_name, 'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.', WSH_DEBUG_SV.c_excep_level);
9197 WSH_DEBUG_SV.pop(l_module_name,
9198 'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9199 END IF;
9200 --
9201 WHEN wsh_util_core.g_exc_warning THEN
9202 x_return_status := wsh_util_core.g_ret_sts_warning;
9203 fnd_msg_pub.count_and_get(
9204 p_count => x_msg_count,
9205 p_data => x_msg_data,
9206 p_encoded => fnd_api.g_false);
9207
9208 --
9209 IF l_debug_on THEN
9210 WSH_DEBUG_SV.logmsg(l_module_name,
9211 'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',
9212 WSH_DEBUG_SV.c_excep_level);
9213 WSH_DEBUG_SV.pop(l_module_name,
9214 'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9215 END IF;
9216 --
9217 WHEN OTHERS THEN
9218 ROLLBACK TO validate_det_line_grp;
9219 x_return_status := fnd_api.g_ret_sts_unexp_error;
9220 wsh_util_core.add_message(x_return_status, l_module_name);
9221 wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_GRP.Validate_Detail_Line');
9222 fnd_msg_pub.count_and_get(
9223 p_count => x_msg_count,
9224 p_data => x_msg_data,
9225 p_encoded => fnd_api.g_false);
9226
9227 --
9228
9229 IF l_debug_on THEN
9230 WSH_DEBUG_SV.logmsg(l_module_name,
9231 'Unexpected error has occured. Oracle error message is '
9232 || SQLERRM,
9233 WSH_DEBUG_SV.c_unexpec_err_level);
9234 WSH_DEBUG_SV.pop(l_module_name, 'EXCEPTION:OTHERS');
9235 END IF;
9236 --
9237 END validate_detail_line;
9238
9239
9240 -- ---------------------------------------------------------------------
9241 -- Procedure: Validate_Detail_Container
9242 --
9243 -- Parameters:
9244 --
9245 -- Description: This local procedure is the new API for wrapping the logic of VALIDATE of Containers
9246 -- Created: Harmonization Project. Patchset I
9247 -- -----------------------------------------------------------------------
9248 PROCEDURE Validate_Detail_Container(
9249 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
9250 p_original_rec IN c_original_detail_cur%ROWTYPE,
9251 p_validation_tab IN wsh_util_core.id_tab_type,
9252 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
9253 x_return_status OUT NOCOPY VARCHAR2,
9254 x_msg_count OUT NOCOPY NUMBER,
9255 x_msg_data OUT NOCOPY VARCHAR2
9256 ) IS
9257
9258 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Detail_Container';
9259 l_api_version CONSTANT NUMBER := 1.0;
9260
9261 --
9262 l_return_status VARCHAR2(32767);
9263 l_msg_count NUMBER;
9264 l_msg_data VARCHAR2(32767);
9265 l_program_name VARCHAR2(32767);
9266 --
9267 l_number_of_errors NUMBER := 0;
9268 l_number_of_warnings NUMBER := 0;
9269 --
9270 l_cont_item_seg FND_FLEX_EXT.SegmentArray;
9271 l_cont_item_name VARCHAR2(30) := NULL;
9272
9273 --
9274 l_debug_on BOOLEAN;
9275 --
9276 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATE_DETAIL_CONTAINER';
9277 --
9278 e_invalid_delivered_qty EXCEPTION; --lpn SyNCH uP samanna
9279 --
9280 BEGIN
9281 --
9282 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9283 --
9284 IF l_debug_on IS NULL
9285 THEN
9286 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9287 END IF;
9288 --
9289 SAVEPOINT VALIDATE_DET_CONTAINER_GRP;
9290 --
9291 IF l_debug_on THEN
9292 WSH_DEBUG_SV.push(l_module_name);
9293 WSH_DEBUG_SV.log(l_module_name, 'Delivery Detail Id', x_detail_rec.delivery_detail_id);
9294 END IF;
9295 -- Initialize API return status to success
9296 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
9297 l_number_of_errors := 0;
9298 l_number_of_warnings := 0;
9299
9300 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_CONT_ITEM_LVL) = 1 ) THEN
9301 IF (x_detail_rec.inventory_item_id <> FND_API.G_MISS_NUM) THEN
9302 --
9303 IF l_debug_on THEN
9304 WSH_DEBUG_SV.log(l_module_name, 'Inventory Item Id', x_detail_rec.inventory_item_id);
9305 WSH_DEBUG_SV.log(l_module_name, 'Organization Id', x_detail_rec.organization_id);
9306 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_ITEM',WSH_DEBUG_SV.C_PROC_LEVEL);
9307 END IF;
9308 --
9309 WSH_UTIL_VALIDATE.Validate_Item(
9310 p_inventory_item_id => x_detail_rec.inventory_item_id,
9311 p_inventory_item => l_cont_item_name,
9312 p_organization_id => p_original_rec.organization_id,
9313 p_seg_array => l_cont_item_seg,
9314 p_item_type => 'CONT_ITEM',
9315 x_return_status => l_return_status);
9316
9317 --
9318 wsh_util_core.api_post_call(
9319 p_return_status => l_return_status,
9320 x_num_warnings => l_number_of_warnings,
9321 x_num_errors => l_number_of_errors,
9322 p_msg_data => l_msg_data
9323 );
9324
9325 END IF;
9326 END IF;
9327 --
9328 --lpn CONV.. samanna
9329 IF (x_detail_rec.delivered_quantity <> FND_API.G_MISS_NUM) THEN
9330 IF p_original_rec.shipped_quantity IS NOT NULL THEN
9331 IF x_detail_rec.delivered_quantity > p_original_rec.shipped_quantity THEN
9332 RAISE e_invalid_delivered_qty;
9333 END IF;
9334 ELSE
9335 IF p_original_rec.picked_quantity IS NOT NULL THEN
9336 IF x_detail_rec.delivered_quantity > p_original_rec.picked_quantity THEN
9337 RAISE e_invalid_delivered_qty;
9338 END IF;
9339 ELSE
9340 IF p_original_rec.requested_quantity IS NOT NULL THEN
9341 IF x_detail_rec.delivered_quantity > p_original_rec.requested_quantity THEN
9342 RAISE e_invalid_delivered_qty;
9343 END IF;
9344 END IF;
9345 END IF;
9346 END IF;
9347 END IF;
9348 --
9349 FND_MSG_PUB.Count_And_Get
9350 (
9351 p_count => x_msg_count,
9352 p_data => x_msg_data,
9353 p_encoded => FND_API.G_FALSE
9354 );
9355
9356 IF l_debug_on THEN
9357 WSH_DEBUG_SV.pop(l_module_name);
9358 END IF;
9359
9360 EXCEPTION
9361 WHEN e_invalid_delivered_qty THEN
9362 ROLLBACK TO VALIDATE_DET_CONTAINER_GRP;
9363 x_return_status := FND_API.G_RET_STS_ERROR ;
9364 FND_MESSAGE.SET_NAME('WSH', 'WSH_INVALID_DELIVERED_QTY');
9365 WSH_UTIL_CORE.ADD_MESSAGE(wsh_util_core.g_ret_sts_error, l_module_name);
9366 FND_MSG_PUB.Count_And_Get
9367 (
9368 p_count => x_msg_count,
9369 p_data => x_msg_data,
9370 p_encoded => FND_API.G_FALSE
9371 );
9372 IF l_debug_on THEN
9373 WSH_DEBUG_SV.logmsg(l_module_name,'E_INVALID_DELIVERED_QTY exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9374 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION: E_INVALID_DELIVERED_QTY');
9375 END IF;
9376
9377
9378 WHEN FND_API.G_EXC_ERROR THEN
9379 ROLLBACK TO VALIDATE_DET_CONTAINER_GRP;
9380 x_return_status := FND_API.G_RET_STS_ERROR ;
9381 FND_MSG_PUB.Count_And_Get
9382 (
9383 p_count => x_msg_count,
9384 p_data => x_msg_data,
9385 p_encoded => FND_API.G_FALSE
9386 );
9387 --
9388
9389 IF l_debug_on THEN
9390 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9391 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
9392 END IF;
9393
9394 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9395 ROLLBACK TO VALIDATE_DET_CONTAINER_GRP;
9396 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
9397 FND_MSG_PUB.Count_And_Get
9398 (
9399 p_count => x_msg_count,
9400 p_data => x_msg_data,
9401 p_encoded => FND_API.G_FALSE
9402 );
9403 --
9404
9405 IF l_debug_on THEN
9406 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9407 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9408 END IF;
9409 --
9410 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
9411 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9412 FND_MSG_PUB.Count_And_Get
9413 (
9414 p_count => x_msg_count,
9415 p_data => x_msg_data,
9416 p_encoded => FND_API.G_FALSE
9417 );
9418 --
9419 IF l_debug_on THEN
9420 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9421 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9422 END IF;
9423 --
9424 WHEN OTHERS THEN
9425 ROLLBACK TO VALIDATE_DET_CONTAINER_GRP;
9426 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
9427 wsh_util_core.add_message(x_return_status, l_module_name);
9428 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Validate_Detail_Container');
9429 FND_MSG_PUB.Count_And_Get
9430 (
9431 p_count => x_msg_count,
9432 p_data => x_msg_data,
9433 p_encoded => FND_API.G_FALSE
9434 );
9435
9436 IF l_debug_on THEN
9437 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
9438 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
9439 END IF;
9440 --
9441 END Validate_Detail_Container;
9442
9443
9444 -- ---------------------------------------------------------------------
9445 -- Procedure: Validate_Detail_Common
9446 --
9447 -- Parameters:
9448 --
9449 -- Description: This local procedure is the new API for wrapping the logic of VALIDATE of both
9450 -- Containers and Non Containers(Lines)
9451 -- Created: Harmonization Project. Patchset I
9452 -- -----------------------------------------------------------------------
9453
9454 PROCEDURE Validate_Detail_Common(
9455 x_detail_rec IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type,
9456 p_original_rec IN c_original_detail_cur%ROWTYPE,
9457 p_validation_tab IN wsh_util_core.id_tab_type,
9458 x_mark_reprice_flag OUT NOCOPY VARCHAR2,
9459 x_return_status OUT NOCOPY VARCHAR2,
9460 x_msg_count OUT NOCOPY NUMBER,
9461 x_msg_data OUT NOCOPY VARCHAR2
9462 ) IS
9463
9464 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Detail_Common';
9465 l_api_version CONSTANT NUMBER := 1.0;
9466 --
9467 l_return_status VARCHAR2(32767);
9468 l_msg_count NUMBER;
9469 l_msg_data VARCHAR2(32767);
9470 l_program_name VARCHAR2(32767);
9471 --
9472 l_number_of_errors NUMBER := 0;
9473 l_number_of_warnings NUMBER := 0;
9474 --
9475 l_parent_detail_id NUMBER;
9476 l_cont_item_seg FND_FLEX_EXT.SegmentArray;
9477 l_cont_item_name VARCHAR2(30) := NULL;
9478 --
9479
9480 CURSOR parent_detail_cur(p_detail_id NUMBER) IS
9481 SELECT parent_delivery_detail_id
9482 FROM wsh_delivery_assignments_v
9483 WHERE delivery_detail_id = p_detail_id;
9484 --
9485 -- HW OPMCONV - Removed OPM variables
9486
9487 l_debug_on BOOLEAN;
9488 --
9489 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATE_DETAIL_COMMON';
9490 --
9491 BEGIN
9492 --
9493 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9494 --
9495 IF l_debug_on IS NULL
9496 THEN
9497 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9498 END IF;
9499 --
9500 SAVEPOINT VALIDATE_DET_COMMON_GRP;
9501
9502 IF l_debug_on THEN
9503 WSH_DEBUG_SV.push(l_module_name);
9504 WSH_DEBUG_SV.log(l_module_name, 'Delivery Detail Id', x_detail_rec.delivery_detail_id);
9505 END IF;
9506 --
9507
9508 -- Initialize API return status to success
9509 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
9510 l_number_of_errors := 0;
9511 l_number_of_warnings := 0;
9512
9513 --HW OPMCONV - Removed checking for process org
9514
9515 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_GROSS_WEIGHT_LVL) = 1 ) THEN
9516 IF l_debug_on THEN
9517 WSH_DEBUG_SV.log(l_module_name, 'Gross Weight', x_detail_rec.gross_weight);
9518 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.C_PROC_LEVEL);
9519 END IF;
9520 --Bug # 3266333
9521 wsh_util_validate.validate_negative(
9522 p_value => x_detail_rec.gross_weight,
9523 p_field_name => 'gross_weight',
9524 x_return_status => l_return_status );
9525 --
9526 wsh_util_core.api_post_call(
9527 p_return_status => l_return_status,
9528 x_num_warnings => l_number_of_warnings,
9529 x_num_errors => l_number_of_errors,
9530 p_msg_data => l_msg_data
9531 );
9532
9533 x_mark_reprice_flag := 'Y';
9534 END IF;
9535
9536 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_NET_WEIGHT_LVL) = 1 ) THEN
9537 --
9538 IF l_debug_on THEN
9539 WSH_DEBUG_SV.log(l_module_name, 'Net Weight', x_detail_rec.net_weight);
9540 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.C_PROC_LEVEL);
9541 END IF;
9542 --Bug # 3266333
9543 wsh_util_validate.validate_negative(
9544 p_value => x_detail_rec.net_weight,
9545 p_field_name => 'net_weight',
9546 x_return_status => l_return_status );
9547 --
9548 wsh_util_core.api_post_call(
9549 p_return_status => l_return_status,
9550 x_num_warnings => l_number_of_warnings,
9551 x_num_errors => l_number_of_errors,
9552 p_msg_data => l_msg_data
9553 );
9554
9555 x_mark_reprice_flag := 'Y';
9556 END IF;
9557
9558
9559 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_VOLUME_LVL) = 1 ) THEN
9560 --
9561 IF l_debug_on THEN
9562 WSH_DEBUG_SV.log(l_module_name, 'Volume', x_detail_rec.volume);
9563 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.C_PROC_LEVEL);
9564 END IF;
9565 --Bug # 3266333
9566 wsh_util_validate.validate_negative(
9567 p_value => x_detail_rec.volume,
9568 p_field_name => 'volume',
9569 x_return_status => l_return_status );
9570 --
9571 wsh_util_core.api_post_call(
9572 p_return_status => l_return_status,
9573 x_num_warnings => l_number_of_warnings,
9574 x_num_errors => l_number_of_errors,
9575 p_msg_data => l_msg_data
9576 );
9577
9578 x_mark_reprice_flag := 'Y';
9579 END IF;
9580
9581 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_MASTER_SER_NUM_LVL) = 1 ) THEN
9582 IF(x_detail_rec.master_serial_number IS NOT NULL) THEN
9583 IF l_debug_on THEN
9584 WSH_DEBUG_SV.log(l_module_name, 'Original container Flag', p_original_rec.container_flag);
9585 WSH_DEBUG_SV.log(l_module_name, 'Master Serial Number', x_detail_rec.master_serial_number);
9586 END IF;
9587
9588 -- Update of master serial number is allowed only if detail is a container
9589 -- And if the container is the top most container
9590
9591 -- R12 MDC: For container_flag 'C' does not need additional logic because
9592 -- it is always topmost container. Only replaced ELSE condition with ELSIF
9593 -- to skip check for container flag 'C'
9594
9595 IF(p_original_rec.container_flag = 'Y') THEN
9596 -- Verify if this is the top most container
9597 OPEN parent_detail_cur(x_detail_rec.delivery_detail_id);
9598 FETCH parent_detail_cur INTO l_parent_detail_id;
9599 CLOSE parent_detail_cur;
9600
9601 IF(l_parent_detail_id IS NOT NULL) THEN
9602 x_detail_rec.master_serial_number := p_original_rec.master_serial_number;
9603 FND_MESSAGE.SET_NAME('WSH', 'WSH_UPDATE_MASTER_SERIAL');
9604 wsh_util_core.add_message(wsh_util_core.g_ret_sts_warning, l_module_name);
9605 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
9606 END IF;
9607 ELSIF (p_original_rec.container_flag = 'N') THEN -- R12 MDC
9608 x_detail_rec.master_serial_number := p_original_rec.master_serial_number;
9609 FND_MESSAGE.SET_NAME('WSH', 'WSH_UPDATE_MASTER_SERIAL');
9610 wsh_util_core.add_message(wsh_util_core.g_ret_sts_warning, l_module_name);
9611 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
9612 END IF;
9613 END IF;
9614
9615 END IF;
9616
9617 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_DET_INSPECT_FLAG_LVL) = 1 ) THEN
9618 -- Cannot set the inspection_Flag to N if it is already I or R
9619
9620 IF x_detail_rec.inspection_flag IS NOT NULL THEN
9621 IF l_debug_on THEN
9622 WSH_DEBUG_SV.log(l_module_name, 'Original Inspec Flag', p_original_rec.inspection_flag);
9623 WSH_DEBUG_SV.log(l_module_name, 'Inspection Flag', x_detail_rec.inspection_flag);
9624 END IF;
9625
9626 IF(x_detail_rec.inspection_flag = 'N' AND p_original_rec.inspection_flag IN ('I', 'R')) THEN
9627 x_detail_rec.inspection_flag := p_original_rec.inspection_flag;
9628 FND_MESSAGE.SET_NAME('WSH', 'WSH_UPDATE_INSPECT_FLAG');
9629 wsh_util_core.add_message(wsh_util_core.g_ret_sts_warning, l_module_name);
9630 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
9631 END IF;
9632
9633 END IF;
9634
9635 END IF;
9636
9637 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_MASTER_LPN_ITEM_LVL) = 1) THEN
9638 IF x_detail_rec.master_container_item_id IS NOT NULL THEN
9639
9640 IF l_debug_on THEN
9641 WSH_DEBUG_SV.log(l_module_name, 'Master cont item id', x_detail_rec.master_container_item_id);
9642 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_ITEM',WSH_DEBUG_SV.C_PROC_LEVEL);
9643 END IF;
9644
9645 WSH_UTIL_VALIDATE.Validate_Item(
9646 p_inventory_item_id => x_detail_rec.master_container_item_id,
9647 p_inventory_item => l_cont_item_name,
9648 p_organization_id => p_original_rec.organization_id,
9649 p_seg_array => l_cont_item_seg,
9650 p_item_type => 'CONT_ITEM',
9651 x_return_status => l_return_status);
9652
9653 --
9654 wsh_util_core.api_post_call(
9655 p_return_status => l_return_status,
9656 x_num_warnings => l_number_of_warnings,
9657 x_num_errors => l_number_of_errors,
9658 p_msg_data => l_msg_data
9659 );
9660 END IF;
9661 END IF;
9662
9663 IF(p_validation_tab(WSH_ACTIONS_LEVELS.C_DETAIL_LPN_ITEM_LVL) = 1) THEN
9664 IF x_detail_rec.detail_container_item_id IS NOT NULL THEN
9665
9666 IF l_debug_on THEN
9667 WSH_DEBUG_SV.log(l_module_name, 'Detail cont item id', x_detail_rec.Detail_container_item_id);
9668 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_ITEM',WSH_DEBUG_SV.C_PROC_LEVEL);
9669 END IF;
9670
9671 WSH_UTIL_VALIDATE.Validate_Item(
9672 p_inventory_item_id => x_detail_rec.detail_container_item_id,
9673 p_inventory_item => l_cont_item_name,
9674 p_organization_id => p_original_rec.organization_id,
9675 p_seg_array => l_cont_item_seg,
9676 p_item_type => 'CONT_ITEM',
9677 x_return_status => l_return_status);
9678
9679 --
9680 wsh_util_core.api_post_call(
9681 p_return_status => l_return_status,
9682 x_num_warnings => l_number_of_warnings,
9683 x_num_errors => l_number_of_errors,
9684 p_msg_data => l_msg_data
9685 );
9686 END IF;
9687 END IF;
9688 IF l_debug_on THEN
9689 WSH_DEBUG_SV.log(l_module_name, 'x_detail_rec.delivered_quantity',x_detail_rec.delivered_quantity);
9690 END IF;
9691 -- HW OPMCONV - Removed branching
9692
9693 --{
9694 IF (nvl(x_detail_rec.delivered_quantity, FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM) THEN
9695 --{
9696 x_detail_rec.delivered_quantity := round(x_detail_rec.delivered_quantity,wsh_util_core.c_max_decimal_digits_inv);
9697 --}
9698 END IF;
9699 --}
9700
9701
9702
9703 FND_MSG_PUB.Count_And_Get
9704 (
9705 p_count => x_msg_count,
9706 p_data => x_msg_data,
9707 p_encoded => FND_API.G_FALSE
9708 );
9709
9710 IF l_debug_on THEN
9711 WSH_DEBUG_SV.pop(l_module_name);
9712 END IF;
9713
9714 EXCEPTION
9715 WHEN FND_API.G_EXC_ERROR THEN
9716 ROLLBACK TO VALIDATE_DET_COMMON_GRP;
9717 x_return_status := FND_API.G_RET_STS_ERROR ;
9718 FND_MSG_PUB.Count_And_Get
9719 (
9720 p_count => x_msg_count,
9721 p_data => x_msg_data,
9722 p_encoded => FND_API.G_FALSE
9723 );
9724 --
9725 IF l_debug_on THEN
9726 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9727 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
9728 END IF;
9729
9730 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9731 ROLLBACK TO VALIDATE_DET_COMMON_GRP;
9732 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
9733 FND_MSG_PUB.Count_And_Get
9734 (
9735 p_count => x_msg_count,
9736 p_data => x_msg_data,
9737 p_encoded => FND_API.G_FALSE
9738 );
9739 --
9740
9741 IF l_debug_on THEN
9742 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9743 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9744 END IF;
9745
9746 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
9747 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9748 FND_MSG_PUB.Count_And_Get
9749 (
9750 p_count => x_msg_count,
9751 p_data => x_msg_data,
9752 p_encoded => FND_API.G_FALSE
9753 );
9754 --
9755 IF l_debug_on THEN
9756 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9757 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9758 END IF;
9759
9760 WHEN OTHERS THEN
9761 ROLLBACK TO VALIDATE_DET_COMMON_GRP;
9762 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
9763 wsh_util_core.add_message(x_return_status, l_module_name);
9764 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Validate_Detail_Common');
9765 FND_MSG_PUB.Count_And_Get
9766 (
9767 p_count => x_msg_count,
9768 p_data => x_msg_data,
9769 p_encoded => FND_API.G_FALSE
9770 );
9771 --
9772
9773 IF l_debug_on THEN
9774 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
9775 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
9776 END IF;
9777
9778 END Validate_Detail_Common;
9779
9780 /* ---------------------------------------------------------------------
9781 Procedure: Get_Serial_Quantity
9782
9783 Parameters:
9784
9785 Description: This procedure is used to derive the serial quantity.
9786 Procedure is created based on the function get_serial_qty
9787 in WSHFSTRX.
9788 Created: Harmonization Project. Patchset I. Bug fix 2652300
9789 ----------------------------------------------------------------------- */
9790
9791 PROCEDURE get_serial_quantity(
9792 p_transaction_temp_id IN NUMBER,
9793 p_serial_number IN VARCHAR2,
9794 p_to_serial_number IN VARCHAR2,
9795 p_shipped_quantity IN VARCHAR2,
9796 x_serial_qty OUT NOCOPY NUMBER,
9797 x_return_status OUT NOCOPY VARCHAR2)
9798 IS
9799
9800 cursor c_serial_qty(p_transaction_temp_id number) is
9801 SELECT sum(nvl(msnt.serial_prefix, 0)) serial_qty
9802 FROM mtl_serial_numbers_temp msnt
9803 WHERE msnt.transaction_temp_id = p_transaction_temp_id
9804 GROUP BY msnt.transaction_temp_id;
9805
9806 l_serial_qty c_serial_qty%ROWTYPE;
9807
9808 l_debug_on Boolean;
9809
9810 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_SERIAL_QUANTITY';
9811
9812 begin
9813
9814 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9815 --
9816 IF l_debug_on IS NULL THEN
9817 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9818 END IF;
9819 --
9820 IF l_debug_on THEN
9821 WSH_DEBUG_SV.push(l_module_name);
9822 WSH_DEBUG_SV.log(l_module_name, 'Transaction Temp Id', p_transaction_temp_id);
9823 WSH_DEBUG_SV.log(l_module_name, 'Serial Number', p_serial_number);
9824 WSH_DEBUG_SV.log(l_module_name, 'To Serial Number', p_to_serial_number);
9825 WSH_DEBUG_SV.log(l_module_name, 'Shipped Qty', p_shipped_quantity);
9826 END IF;
9827 --
9828
9829 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
9830
9831 if p_transaction_temp_id is not null then
9832
9833 open c_serial_qty(p_transaction_temp_id);
9834 fetch c_serial_qty into l_serial_qty;
9835 if c_serial_qty%NOTFOUND then
9836 l_serial_qty.serial_qty := 0;
9837 end if;
9838 close c_serial_qty;
9839 elsif p_serial_number IS NOT NULL AND p_to_serial_number IS NOT NULL THEN
9840 l_serial_qty.serial_qty := p_shipped_quantity;
9841 elsif p_serial_number IS NOT NULL THEN
9842 l_serial_qty.serial_qty := 1;
9843 else
9844 l_serial_qty.serial_qty := 0;
9845 end if;
9846
9847 x_serial_qty := NVL(l_serial_qty.serial_qty, 0);
9848
9849 IF l_debug_on THEN
9850 wsh_debug_sv.log(l_module_name, 'Serial Qty', x_serial_qty);
9851 WSH_DEBUG_SV.pop(l_module_name);
9852 END IF;
9853
9854
9855 EXCEPTION
9856 WHEN FND_API.G_EXC_ERROR THEN
9857 x_return_status := FND_API.G_RET_STS_ERROR ;
9858 IF l_debug_on THEN
9859 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9860 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
9861 END IF;
9862
9863 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9864 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
9865 IF l_debug_on THEN
9866 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9867 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9868 END IF;
9869
9870 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
9871 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9872 IF l_debug_on THEN
9873 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9874 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9875 END IF;
9876
9877 WHEN OTHERS THEN
9878 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
9879 wsh_util_core.add_message(x_return_status, l_module_name);
9880 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Get_Serial_Quantity');
9881 --
9882
9883 IF l_debug_on THEN
9884 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
9885 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
9886 END IF;
9887
9888 END get_serial_quantity;
9889
9890 /* ---------------------------------------------------------------------
9891 Procedure: Create_Update_Delivery_Detail (OVERLOADED)
9892
9893 Parameters:
9894
9895 Description: This procedure is the new API for wrapping the logic of CREATE/UPDATE of delivery details
9896 This OVERLOADED procedure has the additional parameter 'p_serial_range_tab'
9897 Created : Patchset I
9898 ----------------------------------------------------------------------- */
9899
9900 PROCEDURE Create_Update_Delivery_Detail
9901 (
9902 -- Standard Parameters
9903 p_api_version_number IN NUMBER,
9904 p_init_msg_list IN VARCHAR2,
9905 p_commit IN VARCHAR2,
9906 x_return_status OUT NOCOPY VARCHAR2,
9907 x_msg_count OUT NOCOPY NUMBER,
9908 x_msg_data OUT NOCOPY VARCHAR2,
9909
9910 -- Procedure Specific Parameters
9911 p_detail_info_tab IN WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type,
9912 p_IN_rec IN WSH_GLBL_VAR_STRCT_GRP.detailInRecType,
9913 x_OUT_rec OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.detailOutRecType,
9914 p_serial_range_tab IN WSH_GLBL_VAR_STRCT_GRP.ddSerialRangeTabType
9915 ) IS
9916
9917 l_api_name CONSTANT VARCHAR2(30) := 'Create_Update_Delivery_Detail2';
9918 l_api_version CONSTANT NUMBER := 1.0;
9919 --
9920 --
9921 --
9922 l_return_status VARCHAR2(32767);
9923 l1_return_status VARCHAR2(32767);
9924 l_msg_count NUMBER;
9925 l_msg_data VARCHAR2(32767);
9926 l_program_name VARCHAR2(32767);
9927 --
9928 l_number_of_errors NUMBER := 0;
9929 l_number_of_warnings NUMBER := 0;
9930 --
9931 l_loop_num_error NUMBER := 0;
9932 l_loop_num_warn NUMBER := 0;
9933 --
9934 l_counter NUMBER := 0;
9935 l_index NUMBER;
9936
9937 l_detail_info_tab WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type;
9938 l_valid_index_tab wsh_util_core.id_tab_type;
9939 l_delivery_id NUMBER;
9940 l_delivery_detail_rec WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type;
9941 l_validation_tab wsh_util_core.id_tab_type;
9942 --
9943 l_details_marked WSH_UTIL_CORE.Id_Tab_Type;
9944 mark_reprice_error EXCEPTION;
9945
9946 --
9947 CURSOR det_to_del_cur(p_detail_id NUMBER) IS
9948 SELECT wda.delivery_id
9949 FROM wsh_delivery_assignments_v wda
9950 WHERE wda.delivery_detail_id = p_detail_id;
9951
9952 -- anxsharm for Load Tender
9953 l_detail_tender_tab wsh_util_core.id_tab_type;
9954 l_trip_id_tab wsh_util_core.id_tab_type;
9955
9956 --
9957 l_weight_uom_code VARCHAR2(10);
9958 l_volume_uom_code VARCHAR2(10);
9959 l_debug_on BOOLEAN;
9960 --
9961 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_UPDATE_DELIVERY_DETAIL2';
9962 --
9963 -- Following 4 variables are added for bugfix #4070732
9964 l_api_session_name CONSTANT VARCHAR2(150) := G_PKG_NAME ||'.' || l_module_name;
9965 l_reset_flags BOOLEAN;
9966 --
9967 BEGIN
9968 -- Bugfix 4070732
9969 IF WSH_UTIL_CORE.G_START_OF_SESSION_API is null
9970 THEN
9971 WSH_UTIL_CORE.G_START_OF_SESSION_API := l_api_session_name;
9972 WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API := FALSE;
9973 END IF;
9974 -- End of Code Bugfix 4070732
9975
9976 -- Standard Start of API savepoint
9977 SAVEPOINT CREATE_UPDATE_DEL_DETAIL_GRP2;
9978 --
9979 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9980 --
9981 IF l_debug_on IS NULL
9982 THEN
9983 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9984 END IF;
9985 --
9986
9987 --
9988 -- Debug Statements
9989 --
9990 IF l_debug_on THEN
9991 WSH_DEBUG_SV.push(l_module_name);
9992 --
9993 WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION_NUMBER',P_API_VERSION_NUMBER);
9994 WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
9995 WSH_DEBUG_SV.log(l_module_name,'P_COMMIT',P_COMMIT);
9996 WSH_DEBUG_SV.log(l_module_name, 'Caller', p_In_rec.caller);
9997 WSH_DEBUG_SV.log(l_module_name, 'Action Code', p_In_rec.action_code);
9998 WSH_DEBUG_SV.log(l_module_name,'Input Table count', p_detail_info_tab.count);
9999 END IF;
10000 --
10001
10002 -- Initialize message list if p_init_msg_list is set to TRUE.
10003 --
10004 --
10005 IF FND_API.to_Boolean( p_init_msg_list )
10006 THEN
10007 FND_MSG_PUB.initialize;
10008 END IF;
10009 --
10010 --
10011 -- Initialize API return status to success
10012 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
10013 l_number_of_errors := 0;
10014 l_number_of_warnings := 0;
10015
10016 -- Check for generic mandatory parameters
10017 IF p_In_rec.caller IS NULL THEN
10018 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
10019 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'CALLER');
10020 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
10021 IF l_debug_on THEN
10022 wsh_debug_sv.logmsg(l_module_name,'Null Caller');
10023 END IF;
10024 RAISE FND_API.G_EXC_ERROR;
10025 END IF;
10026
10027 IF p_In_rec.action_code IS NULL THEN
10028 FND_MESSAGE.SET_NAME('WSH', 'WSH_REQUIRED_FIELD_NULL');
10029 FND_MESSAGE.SET_TOKEN('FIELD_NAME', 'ACTION_CODE');
10030 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
10031 IF l_debug_on THEN
10032 wsh_debug_sv.logmsg(l_module_name,'Null Action Code');
10033 END IF;
10034 RAISE FND_API.G_EXC_ERROR;
10035 ELSIF(p_In_rec.action_code NOT IN('CREATE', 'UPDATE', 'CANCEL')
10036 OR (p_In_rec.action_code = 'CANCEL' AND p_In_rec.caller <> 'WSH_INBOUND')) THEN
10037 FND_MESSAGE.SET_NAME('WSH','WSH_INVALID_ACTION_CODE');
10038 FND_MESSAGE.SET_TOKEN('ACT_CODE',p_In_rec.action_code );
10039 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
10040 IF l_debug_on THEN
10041 wsh_debug_sv.logmsg(l_module_name,'WSH_INVALID_ACTION_CODE');
10042 END IF;
10043 RAISE FND_API.G_EXC_ERROR;
10044 END IF;
10045
10046 -- Set Validation Level
10047
10048 IF l_debug_on THEN
10049 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ACTIONS_LEVELS.SET_VALIDATION_LEVEL',WSH_DEBUG_SV.C_PROC_LEVEL);
10050 END IF;
10051 --
10052 wsh_actions_levels.set_validation_level(
10053 p_entity => 'DLVB',
10054 p_caller => p_In_rec.caller,
10055 p_phase => p_In_rec.phase,
10056 p_action => p_In_rec.action_code,
10057 x_return_status => l_return_status
10058 );
10059
10060 --
10061 wsh_util_core.api_post_call(
10062 p_return_status => l_return_status,
10063 x_num_warnings => l_number_of_warnings,
10064 x_num_errors => l_number_of_errors,
10065 p_msg_data => l_msg_data
10066 );
10067 --
10068 l_validation_tab := WSH_ACTIONS_LEVELS.G_VALIDATION_LEVEL_TAB;
10069
10070 -- Get Disabled List
10071 --
10072 IF(l_validation_tab(WSH_ACTIONS_LEVELS.C_DISABLED_LIST_LVL) = 1) THEN
10073 l_index := p_detail_info_tab.FIRST;
10074 WHILE l_index IS NOT NULL
10075 LOOP
10076 --
10077 BEGIN
10078 SAVEPOINT before_det_disabled_grp;
10079
10080 OPEN det_to_del_cur(p_detail_info_tab(l_index).delivery_detail_id);
10081 FETCH det_to_del_Cur INTO l_delivery_id;
10082 CLOSE det_to_del_Cur;
10083
10084 IF l_debug_on THEN
10085 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.GET_DISABLED_LIST',WSH_DEBUG_SV.C_PROC_LEVEL);
10086 END IF;
10087 --
10088
10089 IF p_In_rec.caller LIKE 'WMS%' AND p_in_rec.action_code ='UPDATE'
10090 THEN
10091 l_weight_uom_code := p_detail_info_tab(l_index).weight_uom_code;
10092 l_volume_uom_code := p_detail_info_tab(l_index).volume_uom_code;
10093 IF l_debug_on THEN
10094 WSH_DEBUG_SV.log(l_module_name,'l_weight_uom_code',
10095 l_weight_uom_code);
10096 WSH_DEBUG_SV.log(l_module_name,'l_volume_uom_code',
10097 l_volume_uom_code);
10098 END IF;
10099
10100 END IF;
10101
10102 wsh_details_validations.get_disabled_list(
10103 --
10104 p_delivery_detail_rec => p_detail_info_tab(l_index),
10105 p_delivery_id => l_delivery_id,
10106 p_in_rec => p_In_rec,
10107 x_return_status => l_return_status,
10108 x_msg_count => l_msg_count,
10109 x_msg_data => l_msg_data,
10110 x_delivery_detail_rec => l_delivery_detail_rec
10111 );
10112
10113
10114 --
10115 wsh_util_core.api_post_call(
10116 p_return_status => l_return_status,
10117 x_num_warnings => l_loop_num_warn,
10118 x_num_errors => l_loop_num_error,
10119 p_msg_data => l_msg_data
10120 );
10121
10122 -- lpn conv
10123 -- IF WMS passes different UOM then convert
10124 IF p_In_rec.caller LIKE 'WMS%'
10125 AND p_in_rec.action_code ='UPDATE'
10126 AND l_delivery_detail_rec.container_flag in ('Y', 'C')
10127 THEN
10128 IF l_weight_uom_code <>
10129 l_delivery_detail_rec.weight_uom_code
10130 AND l_weight_uom_code <> FND_API.G_MISS_CHAR
10131 THEN
10132 l_delivery_detail_rec.gross_weight :=
10133 WSH_WV_UTILS.Convert_Uom_core (
10134 from_uom => l_weight_uom_code,
10135 to_uom => l_delivery_detail_rec.weight_uom_code,
10136 quantity => l_delivery_detail_rec.gross_weight,
10137 item_id => l_delivery_detail_rec.inventory_item_id,
10138 x_return_status => l_return_status );
10139
10140 wsh_util_core.api_post_call(
10141 p_return_status => l_return_status,
10142 x_num_warnings => l_loop_num_warn,
10143 x_num_errors => l_loop_num_error
10144 );
10145
10146 l_delivery_detail_rec.net_weight :=
10147 WSH_WV_UTILS.Convert_Uom_core (
10148 from_uom => l_weight_uom_code,
10149 to_uom => l_delivery_detail_rec.weight_uom_code,
10150 quantity => l_delivery_detail_rec.net_weight,
10151 item_id => l_delivery_detail_rec.inventory_item_id,
10152 x_return_status => l_return_status);
10153
10154 wsh_util_core.api_post_call(
10155 p_return_status => l_return_status,
10156 x_num_warnings => l_loop_num_warn,
10157 x_num_errors => l_loop_num_error
10158 );
10159 IF l_debug_on THEN
10160 WSH_DEBUG_SV.log(l_module_name,'net_weight',
10161 l_delivery_detail_rec.net_weight);
10162 WSH_DEBUG_SV.log(l_module_name,'gross_weight',
10163 l_delivery_detail_rec.gross_weight);
10164 WSH_DEBUG_SV.log(l_module_name,'database uom',
10165 l_delivery_detail_rec.weight_uom_code);
10166 WSH_DEBUG_SV.log(l_module_name,'item_id',
10167 l_delivery_detail_rec.inventory_item_id);
10168 END IF;
10169
10170 END IF;
10171 IF l_volume_uom_code <>
10172 l_delivery_detail_rec.volume_uom_code
10173 AND l_volume_uom_code <> FND_API.G_MISS_CHAR
10174 THEN
10175
10176 l_delivery_detail_rec.volume :=
10177 WSH_WV_UTILS.Convert_Uom_core (
10178 from_uom => l_volume_uom_code,
10179 to_uom => l_delivery_detail_rec.volume_uom_code,
10180 quantity => l_delivery_detail_rec.volume,
10181 item_id => l_delivery_detail_rec.inventory_item_id,
10182 x_return_status => l_return_status);
10183
10184 wsh_util_core.api_post_call(
10185 p_return_status => l_return_status,
10186 x_num_warnings => l_loop_num_warn,
10187 x_num_errors => l_loop_num_error
10188 );
10189
10190 l_delivery_detail_rec.filled_volume :=
10191 WSH_WV_UTILS.Convert_Uom_core (
10192 from_uom => l_volume_uom_code,
10193 to_uom => l_delivery_detail_rec.volume_uom_code,
10194 quantity => l_delivery_detail_rec.filled_volume,
10195 item_id => l_delivery_detail_rec.inventory_item_id,
10196 x_return_status => l_return_status);
10197 wsh_util_core.api_post_call(
10198 p_return_status => l_return_status,
10199 x_num_warnings => l_loop_num_warn,
10200 x_num_errors => l_loop_num_error
10201 );
10202 IF l_debug_on THEN
10203 WSH_DEBUG_SV.log(l_module_name,'volume',
10204 l_delivery_detail_rec.volume);
10205 WSH_DEBUG_SV.log(l_module_name,'filled_volume',
10206 l_delivery_detail_rec.filled_volume);
10207 WSH_DEBUG_SV.log(l_module_name,'database uom',
10208 l_delivery_detail_rec.volume_uom_code);
10209 WSH_DEBUG_SV.log(l_module_name,'item_id',
10210 l_delivery_detail_rec.inventory_item_id);
10211 END IF;
10212 END IF;
10213
10214 END IF;
10215 l_detail_info_tab(l_index) := l_delivery_detail_rec;
10216 EXCEPTION
10217 WHEN FND_API.G_EXC_ERROR THEN
10218 ROLLBACK TO before_det_disabled_grp;
10219 IF l_debug_on THEN
10220 wsh_debug_sv.logmsg(l_module_name, 'g exc error');
10221 END IF;
10222 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10223 ROLLBACK TO before_det_disabled_grp;
10224 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10225 WHEN OTHERS THEN
10226 ROLLBACK TO before_det_disabled_grp;
10227 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10228
10229 END;
10230 l_weight_uom_code := NULL;
10231 l_volume_uom_code := NULL;
10232 l_index := p_detail_info_tab.NEXT(l_index);
10233 END LOOP;
10234
10235 IF l_debug_on THEN
10236 wsh_debug_sv.log(l_module_name, 'Number of errors after loop', l_loop_num_error);
10237 wsh_debug_sv.log(l_module_name, 'New table count', l_detail_info_tab.count);
10238 END IF;
10239
10240 -- For create container, the table count will be zero
10241 -- Should not set error for that container case
10242 --bmso check the case where container is created and the detail_info_tab > 0
10243 IF p_detail_info_tab.count > 0 THEN
10244 IF l_loop_num_error = p_detail_info_tab.count THEN
10245 IF l_debug_on THEN
10246 wsh_debug_sv.logmsg(l_module_name, 'get disabled list fail all records');
10247 END IF;
10248 RAISE FND_API.G_EXC_ERROR;
10249 ELSE
10250 l_number_of_warnings := l_loop_num_error;
10251 END IF;
10252 END IF;
10253
10254 ELSE
10255 -- if the validation level for disabled list is turned off
10256 -- then we initialize the local table using the input table directly
10257 -- this will be applicable when caller is WSHFSTRX.
10258 IF l_debug_on THEN
10259 wsh_debug_sv.logmsg(l_module_name, 'Get Disabled turned off');
10260 END IF;
10261 l_detail_info_tab := p_detail_info_tab;
10262 --
10263 END IF; -- if check for C_DISABLED_LIST_LVL
10264
10265 IF(p_in_rec.action_code ='UPDATE' AND l_detail_info_tab.count < 1) THEN
10266 -- Should not proceed further
10267 IF l_debug_on THEN
10268 wsh_debug_sv.logmsg(l_module_name,'Table Count Zero');
10269 END IF;
10270 RAISE FND_API.G_EXC_ERROR;
10271 END IF;
10272
10273 -- anxsharm for Load Tender
10274 IF(l_validation_tab(WSH_ACTIONS_LEVELS.C_WMS_CONTAINERS_LVL) = 1) THEN--{ lpn conv
10275 Validate_Delivery_Detail(
10276 x_detail_info_tab => l_detail_info_tab,
10277 p_in_detail_tab => p_detail_info_tab,
10278 p_action => p_In_rec.action_code,
10279 p_validation_tab => l_validation_tab,
10280 p_caller => p_In_rec.caller,
10281 x_valid_index_tab => l_valid_index_tab,
10282 x_details_marked => l_details_marked,
10283 x_detail_tender_tab =>l_detail_tender_tab,
10284 x_return_status => l_return_status,
10285 x_msg_count => l_msg_count,
10286 x_msg_data => l_msg_data,
10287 p_in_rec => p_in_rec,
10288 p_serial_range_tab => p_serial_range_tab);
10289
10290 --
10291 wsh_util_core.api_post_call(
10292 p_return_status => l_return_status,
10293 x_num_warnings => l_number_of_warnings,
10294 x_num_errors => l_number_of_errors,
10295 p_msg_data => l_msg_data
10296 );
10297 END IF; --} lpn conv
10298 IF(p_In_rec.action_code = 'CREATE') THEN
10299 --
10300 Create_Delivery_Detail(
10301 p_detail_info_tab => l_detail_info_tab,
10302 p_detail_IN_rec => p_in_rec ,
10303 p_valid_index_tab => l_valid_index_tab,
10304 x_detail_OUT_rec => x_out_rec,
10305 x_return_status => l_return_status,
10306 x_msg_count => l_msg_count,
10307 x_msg_data => l_msg_data);
10308
10309 --
10310 wsh_util_core.api_post_call(
10311 p_return_status => l_return_status,
10312 x_num_warnings => l_number_of_warnings,
10313 x_num_errors => l_number_of_errors,
10314 p_msg_data => l_msg_data
10315 );
10316
10317
10318 ELSIF(p_In_rec.action_code = 'UPDATE') THEN
10319
10320 IF( WSH_UTIL_CORE.FTE_Is_Installed = 'Y') THEN
10321 IF l_details_marked.count > 0 THEN
10322 --
10323 IF l_debug_on THEN
10324 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_LEGS_ACTIONS.MARK_REPRICE_REQUIRED',WSH_DEBUG_SV.C_PROC_LEVEL);
10325 END IF;
10326 --
10327 WSH_DELIVERY_LEGS_ACTIONS.Mark_Reprice_Required(
10328 p_entity_type => 'DELIVERY_DETAIL',
10329 p_entity_ids => l_details_marked,
10330 x_return_status => l_return_status);
10331
10332 --
10333 wsh_util_core.api_post_call(
10334 p_return_status => l_return_status,
10335 x_num_warnings => l_number_of_warnings,
10336 x_num_errors => l_number_of_errors,
10337 p_msg_data => l_msg_data
10338 );
10339
10340 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
10341 raise mark_reprice_error;
10342 END IF;
10343 END IF;
10344 END IF;
10345
10346 IF nvl(WSH_WMS_LPN_GRP.g_caller,'WSH') like 'WMS%' THEN --{
10347 --
10348 IF l_valid_index_tab.COUNT <> l_detail_info_tab.COUNT THEN
10349 --
10350 IF l_debug_on THEN
10351 --
10352 WSH_DEBUG_SV.logmsg(l_module_name,'ERROR not all line are validated successfully',WSH_DEBUG_SV.C_PROC_LEVEL);
10353 WSH_DEBUG_SV.log(l_module_name,'valid count',l_valid_index_tab.COUNT);
10354 WSH_DEBUG_SV.log(l_module_name,'total count',l_detail_info_tab.COUNT);
10355 --
10356 END IF;
10357 --
10358 RAISE FND_API.G_EXC_ERROR;
10359 --
10360 END IF;
10361 --
10362 END IF; --}
10363
10364 Update_Delivery_Detail(
10365 p_detail_info_tab => l_detail_info_tab,
10366 p_valid_index_tab => l_valid_index_tab,
10367 x_return_status => l_return_status,
10368 x_msg_count => l_msg_count,
10369 x_msg_data => l_msg_data,
10370 p_caller => p_in_rec.caller);
10371
10372 --
10373 wsh_util_core.api_post_call(
10374 p_return_status => l_return_status,
10375 x_num_warnings => l_number_of_warnings,
10376 x_num_errors => l_number_of_errors,
10377 p_msg_data => l_msg_data
10378 );
10379
10380 -- jckwok: code for action_code = 'CANCEL'
10381 ELSIF (p_in_rec.action_code = 'CANCEL') THEN
10382
10383 Cancel_Delivery_Detail(
10384 p_detail_info_tab => l_detail_info_tab,
10385 x_return_status => l_return_status,
10386 x_msg_count => l_msg_count,
10387 x_msg_data => l_msg_data,
10388 p_caller => p_in_rec.caller);
10389
10390 wsh_util_core.api_post_call(p_return_status =>l_return_status,
10391 x_num_warnings =>l_number_of_warnings,
10392 x_num_errors =>l_number_of_errors);
10393
10394 -- jckwok
10395
10396 END IF;
10397
10398 IF l_number_of_warnings > 0 THEN
10399 IF l_debug_on THEN
10400 wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
10401 END IF;
10402
10403 RAISE wsh_util_core.g_exc_warning;
10404 END IF;
10405
10406 -- Standard check of p_commit.
10407 IF FND_API.To_Boolean( p_commit ) THEN
10408 IF(l_debug_on) THEN
10409 wsh_debug_sv.logmsg(l_module_name, 'Commit Work');
10410 END IF;
10411 --
10412 -- Start code for Bugfix 4070732
10413 --
10414 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10415 IF l_debug_on THEN
10416 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10417 END IF;
10418
10419 l_reset_flags := FALSE;
10420
10421 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => l_reset_flags,
10422 x_return_status => l_return_status);
10423
10424 IF l_debug_on THEN
10425 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10426 END IF;
10427
10428 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
10429 RAISE FND_API.G_EXC_ERROR;
10430 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
10431 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10432 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
10433 RAISE WSH_UTIL_CORE.G_EXC_WARNING;
10434 END IF;
10435
10436 END IF;
10437 --
10438 -- End of code for Bugfix 4070732
10439 --
10440 COMMIT WORK;
10441 END IF;
10442
10443 --bug 4070732
10444 --End of the API handling of calls to process_stops_for_load_tender
10445 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
10446 --{
10447 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10448 --{
10449
10450 IF FND_API.TO_BOOLEAN(p_commit) THEN
10451
10452 IF l_debug_on THEN
10453 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10454 END IF;
10455
10456 WSH_UTIL_CORE.reset_stops_for_load_tender(p_reset_flags => TRUE,
10457 x_return_status => l_return_status);
10458 ELSE
10459
10460 IF l_debug_on THEN
10461 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10462 END IF;
10463
10464 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
10465 x_return_status => l_return_status);
10466 END IF;
10467
10468 IF l_debug_on THEN
10469 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10470 END IF;
10471
10472
10473 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
10474 x_return_status := l_return_status;
10475
10476 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
10477 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)
10478 THEN
10479 IF NOT(FND_API.TO_BOOLEAN(p_commit)) THEN
10480 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10481 END IF;
10482 END IF;
10483 END IF;
10484 --}
10485 END IF;
10486 --}
10487 END IF;
10488
10489 --bug 4070732
10490 FND_MSG_PUB.Count_And_Get
10491 (
10492 p_count => x_msg_count,
10493 p_data => x_msg_data,
10494 p_encoded => FND_API.G_FALSE
10495 );
10496
10497
10498 IF l_debug_on THEN
10499 WSH_DEBUG_SV.pop(l_module_name);
10500 END IF;
10501 --
10502 EXCEPTION
10503 WHEN FND_API.G_EXC_ERROR THEN
10504 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10505 x_return_status := FND_API.G_RET_STS_ERROR ;
10506 --
10507 -- Start code for Bugfix 4070732
10508 --
10509 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
10510 THEN
10511 --{
10512 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10513 --{
10514 IF l_debug_on THEN
10515 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10516 END IF;
10517
10518 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
10519 x_return_status => l_return_status);
10520
10521 IF l_debug_on THEN
10522 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10523 END IF;
10524
10525 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
10526 x_return_status := l_return_status;
10527 END IF;
10528 --}
10529 END IF;
10530 --}
10531 END IF;
10532 --
10533 -- End of Code Bugfix 4070732
10534 --
10535 FND_MSG_PUB.Count_And_Get
10536 (
10537 p_count => x_msg_count,
10538 p_data => x_msg_data,
10539 p_encoded => FND_API.G_FALSE
10540 );
10541
10542
10543
10544 --
10545 IF l_debug_on THEN
10546 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10547 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
10548 END IF;
10549 --
10550 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10551 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10552 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
10553 --
10554 -- Start code for Bugfix 4070732
10555 --
10556 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
10557 THEN
10558 --{
10559 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10560 --{
10561 IF l_debug_on THEN
10562 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10563 END IF;
10564
10565 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
10566 x_return_status => l_return_status);
10567
10568 IF l_debug_on THEN
10569 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10570 END IF;
10571 --}
10572 END IF;
10573 --}
10574 END IF;
10575 --
10576 -- End of Code Bugfix 4070732
10577 --
10578 FND_MSG_PUB.Count_And_Get
10579 (
10580 p_count => x_msg_count,
10581 p_data => x_msg_data,
10582 p_encoded => FND_API.G_FALSE
10583 );
10584
10585
10586
10587 --
10588 IF l_debug_on THEN
10589 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10590 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
10591 END IF;
10592 --
10593 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
10594 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
10595 --
10596 -- Start code for Bugfix 4070732
10597 --
10598 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
10599 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10600 IF l_debug_on THEN
10601 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10602 END IF;
10603
10604 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
10605 x_return_status => l_return_status);
10606
10607 IF l_debug_on THEN
10608 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10609 END IF;
10610
10611 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
10612 x_return_status := l_return_status;
10613
10614 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
10615 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)
10616 THEN
10617 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10618 END IF;
10619 END IF;
10620
10621 END IF;
10622 END IF;
10623 --
10624 -- End of Code Bugfix 4070732
10625 --
10626 FND_MSG_PUB.Count_And_Get
10627 (
10628 p_count => x_msg_count,
10629 p_data => x_msg_data,
10630 p_encoded => FND_API.G_FALSE
10631 );
10632
10633
10634
10635 --
10636 IF l_debug_on THEN
10637 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10638 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
10639 END IF;
10640 --
10641 WHEN mark_reprice_error then
10642 FND_MESSAGE.Set_Name('WSH', 'WSH_REPRICE_REQUIRED_ERR');
10643 wsh_util_core.add_message(x_return_status, l_module_name);
10644 x_return_status := l_return_status;
10645 --
10646 -- Start code for Bugfix 4070732
10647 --
10648 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name) THEN
10649 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10650 IF l_debug_on THEN
10651 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Process_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10652 END IF;
10653
10654 WSH_UTIL_CORE.Process_stops_for_load_tender(p_reset_flags => TRUE,
10655 x_return_status => l1_return_status);
10656
10657 IF l_debug_on THEN
10658 WSH_DEBUG_SV.log(l_module_name,'l1_return_status',l1_return_status);
10659 END IF;
10660
10661 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
10662 IF l1_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
10663 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
10664 IF l1_return_status <> WSH_UTIL_CORE.G_RET_STS_WARNING THEN
10665 l_return_status := l1_return_status;
10666 END IF;
10667 ELSE
10668 l_return_status := l1_return_status;
10669 END IF;
10670 END IF;
10671 END IF;
10672
10673 x_return_status := l_return_status;
10674 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,
10675 WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)
10676 THEN
10677 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10678 END IF;
10679
10680 END IF;
10681 END IF;
10682 --
10683 -- End of Code Bugfix 4070732
10684 --
10685 FND_MSG_PUB.Count_And_Get
10686 (
10687 p_count => x_msg_count,
10688 p_data => x_msg_data,
10689 p_encoded => FND_API.G_FALSE
10690 );
10691 --
10692
10693 --
10694 IF l_debug_on THEN
10695 WSH_DEBUG_SV.logmsg(l_module_name,'MARK_REPRICE_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10696 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:MARK_REPRICE_ERROR');
10697 END IF;
10698 --
10699 WHEN OTHERS THEN
10700 ROLLBACK TO CREATE_UPDATE_DEL_DETAIL_GRP2;
10701 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
10702 wsh_util_core.add_message(x_return_status, l_module_name);
10703 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Create_Update_Delivery_Detail');
10704 --
10705 -- Start code for Bugfix 4070732
10706 --
10707 IF upper(WSH_UTIL_CORE.G_START_OF_SESSION_API) = upper(l_api_session_name)
10708 THEN
10709 --{
10710 IF NOT(WSH_UTIL_CORE.G_CALL_FTE_LOAD_TENDER_API) THEN
10711 --{
10712 IF l_debug_on THEN
10713 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.Reset_stops_for_load_tender',WSH_DEBUG_SV.C_PROC_LEVEL);
10714 END IF;
10715
10716 WSH_UTIL_CORE.Reset_stops_for_load_tender(p_reset_flags => TRUE,
10717 x_return_status => l_return_status);
10718
10719 IF l_debug_on THEN
10720 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10721 END IF;
10722 --}
10723 END IF;
10724 --}
10725 END IF;
10726 --
10727 -- End of Code Bugfix 4070732
10728 --
10729 FND_MSG_PUB.Count_And_Get
10730 (
10731 p_count => x_msg_count,
10732 p_data => x_msg_data,
10733 p_encoded => FND_API.G_FALSE
10734 );
10735 --
10736
10737
10738 IF l_debug_on THEN
10739 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
10740 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
10741 END IF;
10742 --
10743 END Create_Update_Delivery_Detail;
10744
10745 -- ---------------------------------------------------------------------
10746 -- Procedure: Get_Carton_Grouping
10747 --
10748 -- Parameters:
10749 --
10750 -- Description: This procedure is the new API for wrapping the logic of autcreate_deliveries.
10751 -- Usage: Called by WMS code to return carton grouping table.
10752 -- Bug 6790938 :
10753 -- Calling Find_Matching_Groups api instead of calling Autocreate_deliveries
10754 -- -----------------------------------------------------------------------
10755 -- Added for Bug 4295161
10756 PROCEDURE Get_Carton_Grouping (p_line_rows IN WSH_UTIL_CORE.id_tab_type,
10757 x_grouping_rows OUT NOCOPY WSH_UTIL_CORE.id_tab_type,
10758 x_return_status OUT NOCOPY VARCHAR2) IS
10759
10760 l_attr_tab wsh_delivery_autocreate.grp_attr_tab_type;
10761 l_group_tab wsh_delivery_autocreate.grp_attr_tab_type;
10762 l_action_rec wsh_delivery_autocreate.action_rec_type;
10763 l_target_rec wsh_delivery_autocreate.grp_attr_rec_type;
10764 l_matched_entities wsh_util_core.id_tab_type;
10765 l_out_rec wsh_delivery_autocreate.out_rec_type;
10766
10767 l_debug_on Boolean;
10768
10769 --bug 7171766
10770 l_match_found BOOLEAN;
10771 l_group_match_seq_tbl WSH_PICK_LIST.group_match_seq_tab_type;
10772 K NUMBER ;
10773
10774 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_CARTON_GROUPING';
10775
10776 BEGIN
10777
10778 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
10779 --
10780 IF l_debug_on IS NULL THEN
10781 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
10782 END IF;
10783 --
10784 IF l_debug_on THEN
10785 WSH_DEBUG_SV.push(l_module_name);
10786 WSH_DEBUG_SV.LOG(l_module_name, 'Count of p_line_rows-', p_line_rows.count);
10787 END IF;
10788 --
10789 x_return_status := FND_API.G_RET_STS_SUCCESS;
10790
10791 FOR i in 1..p_line_rows.count
10792 LOOP
10793 l_attr_tab(i).entity_id := p_line_rows(i);
10794 l_attr_tab(i).entity_type := 'DELIVERY_DETAIL';
10795 END LOOP;
10796 l_action_rec.action := 'MATCH_GROUPS';
10797
10798 IF l_debug_on THEN
10799 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_AUTOCREATE.Find_Matching_Groups', WSH_DEBUG_SV.C_PROC_LEVEL);
10800 END IF;
10801 WSH_DELIVERY_AUTOCREATE.Find_Matching_Groups (
10802 p_attr_tab => l_attr_tab,
10803 p_action_rec => l_action_rec,
10804 p_target_rec => l_target_rec,
10805 p_group_tab => l_group_tab,
10806 x_matched_entities => l_matched_entities,
10807 x_out_rec => l_out_rec,
10808 x_return_status => x_return_status );
10809
10810 --bug 7171766
10811 l_group_match_seq_tbl.delete;
10812
10813 FOR i in 1.. l_attr_tab.count LOOP
10814 --{
10815 l_match_found :=FALSE;
10816 IF l_group_match_seq_tbl.count > 0 THEN
10817 --{
10818 FOR k in l_group_match_seq_tbl.FIRST..l_group_match_seq_tbl.LAST LOOP
10819 --{
10820 IF l_attr_tab(i).group_id = l_group_match_seq_tbl(k).match_group_id THEN
10821 --{
10822 l_group_match_seq_tbl(i).delivery_group_id := l_group_match_seq_tbl(k).delivery_group_id ;
10823 l_match_found := TRUE;
10824 EXIT;
10825 --}
10826 End IF;
10827 --}
10828 END LOOP;
10829 --}
10830 END IF ;
10831
10832 IF NOT l_match_found THEN
10833 --{
10834 l_group_match_seq_tbl(i).match_group_id :=l_attr_tab(i).group_id;
10835 select WSH_DELIVERY_GROUP_S.nextval into l_group_match_seq_tbl(i).delivery_group_id from dual;
10836 --}
10837 End IF;
10838
10839 x_grouping_rows(i) := l_group_match_seq_tbl(i).delivery_group_id;
10840 --}
10841 END LOOP;
10842 --bug 7171766 till here
10843
10844 IF l_debug_on THEN
10845 WSH_DEBUG_SV.LOG(l_module_name, 'Count of x_grouping_rows -', x_grouping_rows.count);
10846 WSH_DEBUG_SV.LOG(l_module_name, 'x_return_status', x_return_status);
10847 WSH_DEBUG_SV.pop(l_module_name);
10848 END IF;
10849
10850 EXCEPTION
10851 WHEN FND_API.G_EXC_ERROR THEN
10852 x_return_status := FND_API.G_RET_STS_ERROR ;
10853 IF l_debug_on THEN
10854 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10855 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
10856 END IF;
10857
10858 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10859 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
10860 IF l_debug_on THEN
10861 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10862 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
10863 END IF;
10864
10865 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
10866 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
10867 IF l_debug_on THEN
10868 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10869 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
10870 END IF;
10871
10872 WHEN OTHERS THEN
10873 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10874 wsh_util_core.add_message(x_return_status, l_module_name);
10875 WSH_UTIL_CORE.default_handler('WSH_DELIVERY_DETAILS_GRP.Get_Carton_Grouping');
10876 --
10877 IF l_debug_on THEN
10878 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
10879 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
10880 END IF;
10881 END Get_Carton_Grouping;
10882
10883 END WSH_DELIVERY_DETAILS_GRP;