[Home] [Help]
PACKAGE BODY: APPS.WSH_IB_TXN_MATCH_PKG
Source
1 PACKAGE BODY WSH_IB_TXN_MATCH_PKG as
2 /* $Header: WSHIBMAB.pls 120.2.12000000.2 2007/01/23 19:15:53 rvishnuv ship $ */
3 --
4 --
5 C_PROCESS_FLAG CONSTANT VARCHAR2(1) := 'Y';
6 C_NOT_PROCESS_FLAG CONSTANT VARCHAR2(1) := 'N';
7 C_ERROR_FLAG CONSTANT VARCHAR2(1) := 'E';
8 C_POTENTIAL_MATCH_FLAG CONSTANT VARCHAR2(1) := 'P';
9 C_DATE_FORMAT_MASK CONSTANT VARCHAR2(50) := 'MM/DD/YYYY HH24:MI:SS';
10 C_SEPARATOR CONSTANT VARCHAR2(1) := '-';
11 --
12 --
13 e_notMatched EXCEPTION;
14 e_fatalError EXCEPTION;
15 --
16
17 --
18 -- Local structure to bulk fetch delivery lines.
19 -- Qualifying(matching) lines are transfered to l_matchedLineRecTbl
20 -- which in turn gets passed to ASN/Receipt/Correction integration
21 -- code.
22 --
23 TYPE line_recTbl_type
24 IS
25 RECORD
26 (
27 delivery_detail_id_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
28 requested_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
29 picked_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
30 shipped_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
31 received_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
32 returned_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
33 requested_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
34 picked_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
35 shipped_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
36 received_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
37 returned_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
38 ship_from_location_id_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
39 earliest_dropoff_date_tbl WSH_BULK_TYPES_GRP.date_Nested_Tab_Type := WSH_BULK_TYPES_GRP.date_Nested_Tab_Type(),
40 delivery_id_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
41 rcv_shipment_line_id_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
42 requested_quantity_uom_tbl WSH_BULK_TYPES_GRP.char3_Nested_Tab_Type := WSH_BULK_TYPES_GRP.char3_Nested_Tab_Type(),
43 requested_quantity_uom2_tbl WSH_BULK_TYPES_GRP.char3_Nested_Tab_Type := WSH_BULK_TYPES_GRP.char3_Nested_Tab_Type(),
44 released_status_tbl WSH_BULK_TYPES_GRP.char30_Nested_Tab_Type := WSH_BULK_TYPES_GRP.char30_Nested_Tab_Type(),
45 src_requested_quantity_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
46 src_requested_quantity2_tbl WSH_BULK_TYPES_GRP.number_Nested_Tab_Type := WSH_BULK_TYPES_GRP.number_Nested_Tab_Type(),
47 last_update_date_tbl WSH_BULK_TYPES_GRP.date_Nested_Tab_Type := WSH_BULK_TYPES_GRP.date_Nested_Tab_Type()
48 );
49
50
51 TYPE message_tbl_type
52 IS
53 TABLE OF VARCHAR2(2000)
54 INDEX BY BINARY_INTEGER;
55
56 /*****************
57 PROCEDURE appendLinkTblDates
58 (
59 p_linerec
60 p_transactionType
61 x_matchedLineRecTbl
62 x_dlvytbl, x_dlvyexttbl,
63 x_linktbl, x_linkexttbl
64 p_start_index
65 p_end_index
66 p_txnUniqueSFLocnId
67 )
68 IS
69 --{
70 --
71 l_num_warnings NUMBER;
72 l_num_errors NUMBER;
73 l_return_status VARCHAR2(30);
74 --
75 l_linkRecString VARCHAR2(500);
76 --}
77 BEGIN
78 --{
79 wsh_util_core.get_cached_value
80 (
81 p_cache_tbl => p_linkTbl,
82 p_cache_ext_tbl => p_linkExtTbl,
83 p_key => p_poShipmentLineId,
84 p_value => l_linkRecString,
85 p_action => 'GET',
86 x_return_status => l_return_status
87 );
88 --
89 --
90 wsh_util_core.api_post_call
91 (
92 p_return_status => l_return_status,
93 x_num_warnings => l_num_warnings,
94 x_num_errors => l_num_errors
95 );
96 --
97 --
98 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
99 THEN
100 error
101 END IF;
102 --
103 --
104 l_linkRecString := l_linkRecString
105 || C_SEPARATOR
106 || TO_CHAR(p_min_date,C_DATE_FORMAT_MASK)
107 || C_SEPARATOR
108 || TO_CHAR(p_max_date,C_DATE_FORMAT_MASK);
109 --
110 --
111 wsh_util_core.get_cached_value
112 (
113 p_cache_tbl => p_linkTbl,
114 p_cache_ext_tbl => p_linkExtTbl,
115 p_key => p_poShipmentLineId,
116 p_value => l_linkRecString,
117 p_action => 'PUT',
118 x_return_status => l_return_status
119 );
120 --
121 --
122 wsh_util_core.api_post_call
123 (
124 p_return_status => l_return_status,
125 x_num_warnings => l_num_warnings,
126 x_num_errors => l_num_errors
127 );
128
129 --}
130 EXCEPTION
131 --{
132 --}
133 END;
134 ************/
135 --
136 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_IB_TXN_MATCH_PKG';
137 --
138 --
139 --========================================================================
140 -- PROCEDURE : validateMandatoryInfo
141 --
142 -- PARAMETERS: p_transactionType Transaction Type
143 -- p_index Index into x_line_rec
144 -- x_line_rec ASN/Receipt Lines
145 -- x_return_status Return status of the API
146 --
147 --
148 -- COMMENT : This procedure validates for mandatory fields for each record passed by
149 -- receiving transaction processor.
150 --
151 -- First, it validates PO related mandatory fields by
152 -- calling WSH_BULK_PROCESS_PVT.validate_mandatory_info
153 --
154 -- Next, it validates receiving related fields as follows:
155 -- - For ASN/Cancel ASN, following fields are mandatory.
156 -- - shipment_header_id
157 -- - shipment_line_id
158 -- - received_quantity
159 -- - received_quantity_uom
160 -- - shipment_num
161 -- - shipped_date
162 --
163 -- - For other transactions, following fields are mandatory.
164 -- - shipment_header_id
165 -- - shipment_line_id
166 -- - rcv_transaction_id
167 -- - received_quantity
168 -- - received_quantity_uom
169 -- - receipt_num
170 -- - expected_receipt_date
171 --
172 --========================================================================
173 --
174 PROCEDURE validateMandatoryInfo
175 (
176 p_transactionType IN VARCHAR2,
177 p_index IN NUMBER,
178 x_line_rec IN OUT NOCOPY OE_WSH_BULK_GRP.Line_rec_type,
179 x_return_status OUT NOCOPY VARCHAR2
180 )
181 IS
182 --{
183 l_num_warnings NUMBER := 0;
184 l_num_errors NUMBER := 0;
185 l_return_status VARCHAR2(30);
186 --
187 l_fieldName VARCHAR2(100);
188 --
189 l_debug_on BOOLEAN;
190 --
191 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATEMANDATORYINFO';
192 --
193 --}
194 BEGIN
195 --{
196 --
197 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
198 --
199 IF l_debug_on IS NULL
200 THEN
201 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
202 END IF;
203 --
204 --
205 -- Debug Statements
206 --
207 IF l_debug_on THEN
208 WSH_DEBUG_SV.push(l_module_name);
209 --
210 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
211 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
212 END IF;
213 --
214 --
215 -- Debug Statements
216 --
217 IF l_debug_on THEN
218 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_BULK_PROCESS_PVT.VALIDATE_MANDATORY_INFO',WSH_DEBUG_SV.C_PROC_LEVEL);
219 END IF;
220 --
221 WSH_BULK_PROCESS_PVT.validate_mandatory_info
222 (
223 p_line_rec => x_line_rec,
224 p_index => p_index,
225 x_return_status => l_return_status
226 );
227 --
228 --
229 -- Debug Statements
230 --
231 IF l_debug_on THEN
232 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
233 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
234 END IF;
235 --
236 wsh_util_core.api_post_call
237 (
238 p_return_status => l_return_status,
239 x_num_warnings => l_num_warnings,
240 x_num_errors => l_num_errors
241 );
242 --
243 --
244 IF x_line_rec.shipment_header_id(p_index) IS NULL
245 THEN
246 l_fieldName := 'shipment_header_id' || '(' || p_index || ')';
247 ELSIF x_line_rec.shipment_line_id(p_index) IS NULL
248 THEN
249 l_fieldName := 'shipment_line_id' || '(' || p_index || ')';
250 ELSIF x_line_rec.rcv_transaction_id(p_index) IS NULL
251 AND p_transactionType NOT IN (WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN)
252 THEN
253 l_fieldName := 'rcv_transaction_id' || '(' || p_index || ')';
254 ELSIF x_line_rec.received_quantity(p_index) IS NULL
255 THEN
256 l_fieldName := 'received_quantity' || '(' || p_index || ')';
257 ELSIF x_line_rec.received_quantity_uom(p_index) IS NULL
258 THEN
259 l_fieldName := 'received_quantity_uom' || '(' || p_index || ')';
260 ELSIF x_line_rec.shipment_num(p_index) IS NULL
261 AND p_transactionType IN (WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN)
262 THEN
263 l_fieldName := 'shipment_num' || '(' || p_index || ')';
264 ELSIF x_line_rec.shipped_date(p_index) IS NULL
265 AND p_transactionType IN (WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN)
266 THEN
267 l_fieldName := 'shipped_date' || '(' || p_index || ')';
268 ELSIF x_line_rec.receipt_num(p_index) IS NULL
269 AND p_transactionType NOT IN (WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN)
270 THEN
271 l_fieldName := 'receipt_num' || '(' || p_index || ')';
272 ELSIF x_line_rec.expected_receipt_date(p_index) IS NULL
273 AND p_transactionType NOT IN (WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN)
274 THEN
275 l_fieldName := 'expected_receipt_date' || '(' || p_index || ')';
276 END IF;
277 --
278 --
279 IF l_fieldName IS NOT NULL
280 THEN
281 --{
282 FND_MESSAGE.SET_NAME('WSH','WSH_REQUIRED_FIELD_NULL');
283 FND_MESSAGE.SET_TOKEN('FIELD_NAME',l_fieldName);
284 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
285 RAISE FND_API.G_EXC_ERROR;
286 --}
287 END IF;
288 --
289 --
290 --
291 --
292 IF l_debug_on THEN
293 WSH_DEBUG_SV.logmsg(l_module_name,
294 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
295 END IF;
296 --
297 IF l_num_errors > 0
298 THEN
299 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
300 ELSIF l_num_warnings > 0
301 THEN
302 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
303 ELSE
304 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
305 END IF;
306 --
307 -- Debug Statements
308 --
309 IF l_debug_on THEN
310 WSH_DEBUG_SV.pop(l_module_name);
311 END IF;
312 --
313 --}
314 EXCEPTION
315 --{
316 WHEN FND_API.G_EXC_ERROR THEN
317 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
318 --
319 -- Debug Statements
320 --
321 IF l_debug_on THEN
322 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
323 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
324 END IF;
325 --
326 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
327 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
328 --
329 -- Debug Statements
330 --
331 IF l_debug_on THEN
332 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
333 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
334 END IF;
335 --
336 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
337 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
338 --
339 -- Debug Statements
340 --
341 IF l_debug_on THEN
342 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
343 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
344 END IF;
345 --
346 WHEN OTHERS THEN
347 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
348 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.validateMandatoryInfo');
349 --
350 -- Debug Statements
351 --
352 IF l_debug_on THEN
353 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
354 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
355 END IF;
356 --
357 --}
358 END validateMandatoryInfo;
359 --
360 --
361 --
362 --========================================================================
363 -- PROCEDURE : retrieveMessages
364 --
365 -- PARAMETERS: p_startIndex Start Index on FND Message Stack.
366 -- p_endIndex End Index on FND Message Stack.
367 -- x_messageTbl Table of messages(retrieved from stack)
368 -- x_return_status Return status of the API
369 --
370 --
371 -- COMMENT : It retrieves messages from FND message stack between p_startIndex and p_endIndex.
372 -- This procedure is called in the event of matching algorithm failure before raising
373 -- business event. It extracts all messages (which inform the user reasons for failure)
374 -- which will be passed as business event parameter.
375 --========================================================================
376 --
377 --
378 PROCEDURE retrieveMessages
379 (
380 p_startIndex IN NUMBER,
381 p_endIndex IN NUMBER,
382 x_messageTbl OUT NOCOPY message_tbl_type,
383 x_return_status OUT NOCOPY VARCHAR2
384 )
385 IS
386 --{
387 l_num_warnings NUMBER := 0;
388 l_num_errors NUMBER := 0;
389 l_return_status VARCHAR2(30);
390 --
391 l_index NUMBER;
392 l_message VARCHAR2(2000);
393 l_messageStr VARCHAR2(2000);
394 --
395 l_messageLength NUMBER;
396 l_messageStrLength NUMBER;
397 --
398 l_debug_on BOOLEAN;
399 --
400 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'RETRIEVEMESSAGES';
401 --
402 --}
403 BEGIN
404 --{
405 --
406 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
407 --
408 IF l_debug_on IS NULL
409 THEN
410 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
411 END IF;
412 --
413 --
414 -- Debug Statements
415 --
416 IF l_debug_on THEN
417 WSH_DEBUG_SV.push(l_module_name);
418 --
419 WSH_DEBUG_SV.log(l_module_name,'P_STARTINDEX',P_STARTINDEX);
420 WSH_DEBUG_SV.log(l_module_name,'P_ENDINDEX',P_ENDINDEX);
421 END IF;
422 --
423 l_messageStrLength := 0;
424 --
425 FOR l_index IN p_startIndex..p_endIndex
426 LOOP
427 --{
428 l_message := FND_MSG_PUB.GET
429 (
430 p_msg_index => l_index,
431 p_encoded => 'F'
432 );
433 --
434 l_messageLength := LENGTHB(l_message);
435 --
436 --
437 IF l_debug_on THEN
438 WSH_DEBUG_SV.log(l_module_name,'l_index',l_index);
439 WSH_DEBUG_SV.log(l_module_name,'l_messageLength',l_messageLength);
440 WSH_DEBUG_SV.log(l_module_name,'l_messageStrLength',l_messageStrLength);
441 END IF;
442 --
443 IF l_messageStrLength = 0
444 THEN
445 l_messageStr := l_message;
446 ELSIF l_messageLength + l_messageStrLength < 2000
447 THEN
448 --{
449 l_messageStr := l_messageStr
450 || FND_GLOBAL.LOCAL_CHR(10)
451 || l_message;
452 --}
453 ELSE
454 --{
455 --
456 IF l_debug_on THEN
457 WSH_DEBUG_SV.log(l_module_name,'Adding l_messageStr to x_messageTbl',l_messageStr);
458 END IF;
459 --
460 x_messageTbl(x_messageTbl.COUNT+1) := l_messageStr;
461 --
462 l_messageStr := l_message;
463 --}
464 END IF;
465 --
466 l_messageStrLength := LENGTHB(l_messageStr);
467 --
468 IF l_index = p_endIndex
469 THEN
470 --{
471 --
472 IF l_debug_on THEN
473 WSH_DEBUG_SV.log(l_module_name,'Adding l_messageStr to x_messageTbl',l_messageStr);
474 END IF;
475 --
476 x_messageTbl(x_messageTbl.COUNT+1) := l_messageStr;
477 --}
478 END IF;
479 --}
480 END LOOP;
481 --
482 --
483 --
484 --
485 IF l_debug_on THEN
486 WSH_DEBUG_SV.logmsg(l_module_name,
487 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
488 END IF;
489 --
490 IF l_num_errors > 0
491 THEN
492 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
493 ELSIF l_num_warnings > 0
494 THEN
495 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
496 ELSE
497 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
498 END IF;
499 --
500 -- Debug Statements
501 --
502 IF l_debug_on THEN
503 WSH_DEBUG_SV.pop(l_module_name);
504 END IF;
505 --
506 --}
507 EXCEPTION
508 --{
509 WHEN FND_API.G_EXC_ERROR THEN
510 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
511 --
512 -- Debug Statements
513 --
514 IF l_debug_on THEN
515 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
516 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
517 END IF;
518 --
519 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
520 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
521 --
522 -- Debug Statements
523 --
524 IF l_debug_on THEN
525 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
526 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
527 END IF;
528 --
529 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
530 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
531 --
532 -- Debug Statements
533 --
534 IF l_debug_on THEN
535 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
536 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
537 END IF;
538 --
539 WHEN OTHERS THEN
540 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
541 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.retrieveMessages');
542 --
543 -- Debug Statements
544 --
545 IF l_debug_on THEN
546 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
547 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
548 END IF;
549 --
550 --}
551 END retrieveMessages;
552 --
553 --
554 --
555 --========================================================================
556 -- PROCEDURE : handleMatchFailure
557 --
558 -- PARAMETERS: p_transactionType Transaction Type
559 -- p_transactionMeaning Transaction Meaning
560 -- x_return_status Return status of the API
561 --
562 --
563 -- COMMENT : This procedure is called when matching algorithm fails.
564 -- It performs following steps:
565 --
566 -- 01. Update WSH_INBOUND_TXN_HISTORY status (Manual reconciliation required/Matchec,child pending)
567 -- 02. Retrieve all messages from FND message stack
568 -- 03. Raise business event with following parameters
569 -- - TRANSACTION_TYPE
570 -- - SHIPMENT_HEADER_ID
571 -- - SHIPMENT_NUMBER
572 -- - RECEIPT_NUMBER
573 -- - SUMMARY_MESSAGE (indicating matching algorithm failed)
574 -- - Upto 20 additional parameters DETAILED_MESSAGE_1..20 (detailed reasons for
575 -- failure as retrieved from message stack)
576 --========================================================================
577 --
578 --
579 PROCEDURE handleMatchFailure
580 (
581 p_transactionType IN VARCHAR2,
582 p_transactionMeaning IN VARCHAR2,
583 p_ReceiptAgainstASN IN VARCHAR2,
584 p_minFailedTransactionId IN NUMBER,
585 p_minMatchedTransactionId IN NUMBER,
586 p_maxRCVTransactionId IN NUMBER,
587 p_headerTransactionId IN NUMBER,
588 p_headerObjectVersionNumber IN NUMBER,
589 p_headerStatus IN VARCHAR2,
590 p_messageStartIndex IN NUMBER,
591 p_RCVShipmentHeaderId IN NUMBER,
592 p_shipmentNumber IN VARCHAR2,
593 p_receiptNumber IN VARCHAR2,
594 x_return_status OUT NOCOPY VARCHAR2
595 )
596 IS
597 --{
598 l_num_warnings NUMBER := 0;
599 l_num_errors NUMBER := 0;
600 l_return_status VARCHAR2(30);
601 --
602 l_headerObjectVersionNumber NUMBER;
603 l_headerStatus VARCHAR2(30);
604 l_maxRCVTransactionId NUMBER;
605 --
606 l_messageTbl message_tbl_type;
607 --
608 l_index NUMBER;
609 l_eventParameterList WF_PARAMETER_LIST_T;
610 l_eventKey NUMBER;
611 --
612 CURSOR eventKey_csr
613 IS
614 SELECT WSH_INBOUND_TXN_MATCH_KEY_S.NEXTVAL
615 FROM DUAL;
616 --
617 l_debug_on BOOLEAN;
618 --
619 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'HANDLEMATCHFAILURE';
620 --
621 --}
622 BEGIN
623 --{
624 --
625 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
626 --
627 IF l_debug_on IS NULL
628 THEN
629 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
630 END IF;
631 --
632 --
633 -- Debug Statements
634 --
635 IF l_debug_on THEN
636 WSH_DEBUG_SV.push(l_module_name);
637 --
638 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
639 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONMEANING',P_TRANSACTIONMEANING);
640 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
641 WSH_DEBUG_SV.log(l_module_name,'P_MINFAILEDTRANSACTIONID',P_MINFAILEDTRANSACTIONID);
642 WSH_DEBUG_SV.log(l_module_name,'P_MINMATCHEDTRANSACTIONID',P_MINMATCHEDTRANSACTIONID);
643 WSH_DEBUG_SV.log(l_module_name,'P_MAXRCVTRANSACTIONID',P_MAXRCVTRANSACTIONID);
644 WSH_DEBUG_SV.log(l_module_name,'P_HEADERTRANSACTIONID',P_HEADERTRANSACTIONID);
645 WSH_DEBUG_SV.log(l_module_name,'P_HEADEROBJECTVERSIONNUMBER',P_HEADEROBJECTVERSIONNUMBER);
646 WSH_DEBUG_SV.log(l_module_name,'P_HEADERSTATUS',P_HEADERSTATUS);
647 WSH_DEBUG_SV.log(l_module_name,'P_MESSAGESTARTINDEX',P_MESSAGESTARTINDEX);
648 WSH_DEBUG_SV.log(l_module_name,'P_RCVSHIPMENTHEADERID',P_RCVSHIPMENTHEADERID);
649 WSH_DEBUG_SV.log(l_module_name,'P_SHIPMENTNUMBER',P_SHIPMENTNUMBER);
650 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTNUMBER',P_RECEIPTNUMBER);
651 END IF;
652 --
653 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
654 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
655 THEN
656 --{
657 l_headerObjectVersionNumber := p_headerObjectVersionNumber;
658 l_headerStatus := p_headerStatus;
659 l_maxRCVTransactionId := p_maxRCVTransactionId;
660 --}
661 ELSE
662 --{
663 l_headerObjectVersionNumber := p_headerObjectVersionNumber;
664 l_headerStatus := p_headerStatus;
665 l_maxRCVTransactionId := p_maxRCVTransactionId;
666 --
667 --
668 IF LEAST(p_minFailedTransactionId,p_minMatchedTransactionId) < NVL(l_maxRCVTransactionId,1E38)
669 THEN
670 l_headerObjectVersionNumber := NVL(l_headerObjectVersionNumber,0) + 1;
671 END IF;
672 --
673 IF l_headerStatus = WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED
674 THEN
675 l_headerStatus := WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED_AND_CHILD_PENDING;
676 END IF;
677 --}
678 END IF;
679 --
680 --
681 IF l_debug_on THEN
682 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE WSH_INBOUND_TXN_HISTORY');
683 WSH_DEBUG_SV.log(l_module_name,'l_headerStatus',l_headerStatus);
684 WSH_DEBUG_SV.log(l_module_name,'l_headerObjectVersionNumber',l_headerObjectVersionNumber);
685 WSH_DEBUG_SV.log(l_module_name,'l_maxRCVTransactionId',l_maxRCVTransactionId);
686 END IF;
687 --
688 --
689 UPDATE WSH_INBOUND_TXN_HISTORY
690 SET STATUS = NVL(l_headerStatus,STATUS),
691 OBJECT_VERSION_NUMBER = NVL(l_headerObjectVersionNumber,OBJECT_VERSION_NUMBER),
692 MAX_RCV_TRANSACTION_ID = NVL(l_maxRCVTransactionId,MAX_RCV_TRANSACTION_ID),
693 LAST_UPDATE_DATE = SYSDATE,
694 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
695 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
696 WHERE TRANSACTION_ID = p_headerTransactionId;
697 --
698 IF SQL%ROWCOUNT = 0
699 THEN
700 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_UPDATE_ERROR');
701 FND_MESSAGE.SET_TOKEN('TRANSACTION_ID',p_headerTransactionId);
702 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
703 RAISE FND_API.G_EXC_ERROR;
704 END IF;
705 --
706 --
707 --
708 -- Debug Statements
709 --
710 IF l_debug_on THEN
711 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.RETRIEVEMESSAGES',WSH_DEBUG_SV.C_PROC_LEVEL);
712 END IF;
713 --
714 WSH_IB_TXN_MATCH_PKG.retrieveMessages
715 (
716 p_startIndex => p_messageStartIndex,
717 p_endIndex => FND_MSG_PUB.Count_Msg,
718 x_messageTbl => l_messageTbl,
719 x_return_status => l_return_status
720 );
721 --
722 --
723 -- Debug Statements
724 --
725 IF l_debug_on THEN
726 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
727 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
728 END IF;
729 --
730 wsh_util_core.api_post_call
731 (
732 p_return_status => l_return_status,
733 x_num_warnings => l_num_warnings,
734 x_num_errors => l_num_errors
735 );
736 --
737 --
738 OPEN eventKey_csr;
739 FETCH eventKey_csr INTO l_eventKey;
740 CLOSE eventKey_csr;
741 --
742 IF l_eventKey IS NULL
743 THEN
744 FND_MESSAGE.SET_NAME('WSH','WSH_IB_EVENT_KEY_ERROR');
745 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
746 RAISE FND_API.G_EXC_ERROR;
747 END IF;
748 --
749 --
750 --
751 -- Debug Statements
752 --
753 IF l_debug_on THEN
754 WSH_DEBUG_SV.log(l_module_name,'l_eventKey',l_eventKey);
755 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-TRANSACTION_TYPE',WSH_DEBUG_SV.C_PROC_LEVEL);
756 END IF;
757 --
758 WF_EVENT.AddParameterToList
759 (
760 p_name => 'TRANSACTION_TYPE',
761 p_value => p_transactionType,
762 p_parameterList => l_eventParameterList
763 );
764 --
765 --
766 -- Debug Statements
767 --
768 IF l_debug_on THEN
769 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-SHIPMENT_HEADER_ID',WSH_DEBUG_SV.C_PROC_LEVEL);
770 END IF;
771 --
772 WF_EVENT.AddParameterToList
773 (
774 p_name => 'SHIPMENT_HEADER_ID',
775 p_value => p_RCVShipmentHeaderId,
776 p_parameterList => l_eventParameterList
777 );
778 --
779 --
780 -- Debug Statements
781 --
782 IF l_debug_on THEN
783 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-SHIPMENT_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
784 END IF;
785 --
786 WF_EVENT.AddParameterToList
787 (
788 p_name => 'SHIPMENT_NUMBER',
789 p_value => p_shipmentNumber,
790 p_parameterList => l_eventParameterList
791 );
792 --
793 --
794 -- Debug Statements
795 --
796 IF l_debug_on THEN
797 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-RECEIPT_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
798 END IF;
799 --
800 WF_EVENT.AddParameterToList
801 (
802 p_name => 'RECEIPT_NUMBER',
803 p_value => p_receiptNumber,
804 p_parameterList => l_eventParameterList
805 );
806 --
807 --
808 FND_MESSAGE.SET_NAME('WSH','WSH_IB_MATCH_FAILURE');
809 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE', p_transactionMeaning);
810 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM', p_receiptNumber);
811 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM', p_shipmentNumber);
812
813 --
814 -- Debug Statements
815 --
816 IF l_debug_on THEN
817 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-SUMMARY_MESSAGE',WSH_DEBUG_SV.C_PROC_LEVEL);
818 END IF;
819 --
820 WF_EVENT.AddParameterToList
821 (
822 p_name => 'SUMMARY_MESSAGE',
823 p_value => FND_MESSAGE.GET,
824 p_parameterList => l_eventParameterList
825 );
826 --
827 --
828 l_index := l_messageTbl.FIRST;
829 --
830 WHILE l_index IS NOT NULL
831 AND l_index <= 20
832 LOOP
833 --{
834 --
835 -- Debug Statements
836 --
837 IF l_debug_on THEN
838 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.ADDPARAMETERTOLIST-detailed_message_'||l_index,WSH_DEBUG_SV.C_PROC_LEVEL);
839 END IF;
840 --
841 WF_EVENT.AddParameterToList
842 (
843 p_name => 'DETAILED_MESSAGE_' || TO_CHAR(l_index),
844 p_value => l_messageTbl(l_index),
845 p_parameterList => l_eventParameterList
846 );
847 --
848 l_index := l_messageTbl.NEXT(l_index);
849 --}
850 END LOOP;
851 --
852 --
853 --
854 -- Debug Statements
855 --
856 IF l_debug_on THEN
857 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WF_EVENT.RAISE',WSH_DEBUG_SV.C_PROC_LEVEL);
858 END IF;
859 --
860 WF_EVENT.RAISE
861 (
862 p_event_name => 'oracle.apps.fte.inbound.shipment.matchfailure',
863 p_event_key => l_eventKey,
864 p_parameters => l_eventParameterList
865 );
866 --
867 --
868 --
869 --
870 IF l_debug_on THEN
871 WSH_DEBUG_SV.logmsg(l_module_name,
872 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
873 END IF;
874 --
875 IF l_num_errors > 0
876 THEN
877 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
878 ELSIF l_num_warnings > 0
879 THEN
880 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
881 ELSE
882 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
883 END IF;
884 --
885 -- Debug Statements
886 --
887 IF l_debug_on THEN
888 WSH_DEBUG_SV.pop(l_module_name);
889 END IF;
890 --
891 --}
892 EXCEPTION
893 --{
894 WHEN FND_API.G_EXC_ERROR THEN
895 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
896 --
897 -- Debug Statements
898 --
899 IF l_debug_on THEN
900 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
901 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
902 END IF;
903 --
904 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
905 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
906 --
907 -- Debug Statements
908 --
909 IF l_debug_on THEN
910 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
911 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
912 END IF;
913 --
914 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
915 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
916 --
917 -- Debug Statements
918 --
919 IF l_debug_on THEN
920 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
921 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
922 END IF;
923 --
924 WHEN OTHERS THEN
925 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
926 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.handleMatchFailure');
927 --
928 -- Debug Statements
929 --
930 IF l_debug_on THEN
931 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
932 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
933 END IF;
934 --
935 --}
936 END handleMatchFailure;
937 --
938 --
939 --
940 --========================================================================
941 -- PROCEDURE : getTransactionKey
942 --
943 -- PARAMETERS: p_transactionType Transaction Type
944 -- p_line_rec ASN/Receipt Lines
945 -- x_return_status Return status of the API
946 --
947 --
948 -- COMMENT : This procedure is used to derive key(PLL/RSL ID) and transaction sub-type
949 -- for each input record in p_line_rec. (Please refer to appendix2 in DLD)
950 --========================================================================
951 --
952 --
953 PROCEDURE getTransactionKey
954 (
955 p_transactionType IN VARCHAR2,
956 p_ReceiptAgainstASN IN VARCHAR2,
957 p_index IN NUMBER,
958 p_line_rec IN OE_WSH_BULK_GRP.Line_rec_type,
959 x_key OUT NOCOPY NUMBER,
960 x_transactionSubType OUT NOCOPY VARCHAR2,
961 x_return_status OUT NOCOPY VARCHAR2
962 )
963 IS
964 --{
965 l_num_warnings NUMBER := 0;
966 l_num_errors NUMBER := 0;
967 l_return_status VARCHAR2(30);
968 --
969 l_debug_on BOOLEAN;
970 --
971 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GETTRANSACTIONKEY';
972 --
973 --}
974 BEGIN
975 --{
976 --
977 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
978 --
979 IF l_debug_on IS NULL
980 THEN
981 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
982 END IF;
983 --
984 --
985 -- Debug Statements
986 --
987 IF l_debug_on THEN
988 WSH_DEBUG_SV.push(l_module_name);
989 --
990 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
991 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
992 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
993 END IF;
994 --
995 --
996 x_transactionSubType := p_transactionType;
997 --
998 --
999 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
1000 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
1001 THEN
1002 x_key := p_line_rec.po_shipment_line_id(p_index);
1003 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1004 THEN
1005 IF p_ReceiptAgainstASN = 'Y'
1006 THEN
1007 x_key := p_line_rec.shipment_line_id(p_index);
1008 ELSE
1009 x_key := p_line_rec.po_shipment_line_id(p_index);
1010 END IF;
1011 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION
1012 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
1013 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
1014 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV
1015 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION
1016 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
1017 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
1018 THEN
1019 x_key := p_line_rec.shipment_line_id(p_index);
1020 --
1021 --
1022 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION
1023 THEN
1024 IF p_line_rec.received_quantity(p_index) > 0
1025 THEN
1026 x_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE;
1027 ELSE
1028 x_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE;
1029 END IF;
1030 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION
1031 THEN
1032 IF p_line_rec.received_quantity(p_index) > 0
1033 THEN
1034 x_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE;
1035 ELSE
1036 x_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE;
1037 END IF;
1038 END IF;
1039 ELSE
1040 --{
1041 FND_MESSAGE.SET_NAME('WSH','WSH_IB_INVALID_TXN_TYPE');
1042 FND_MESSAGE.SET_TOKEN('TXN_TYPE',p_transactionType);
1043 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
1044 RAISE FND_API.G_EXC_ERROR;
1045 --}
1046 END IF;
1047 --
1048 --
1049 IF l_debug_on THEN
1050 WSH_DEBUG_SV.logmsg(l_module_name,
1051 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
1052 END IF;
1053 --
1054 IF l_num_errors > 0
1055 THEN
1056 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1057 ELSIF l_num_warnings > 0
1058 THEN
1059 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1060 ELSE
1061 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1062 END IF;
1063 --
1064 -- Debug Statements
1065 --
1066 IF l_debug_on THEN
1067 WSH_DEBUG_SV.pop(l_module_name);
1068 END IF;
1069 --
1070 --}
1071 EXCEPTION
1072 --{
1073 WHEN FND_API.G_EXC_ERROR THEN
1074 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1075 --
1076 -- Debug Statements
1077 --
1078 IF l_debug_on THEN
1079 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1080 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1081 END IF;
1082 --
1083 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1084 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1085 --
1086 -- Debug Statements
1087 --
1088 IF l_debug_on THEN
1089 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1090 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1091 END IF;
1092 --
1093 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1094 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1095 --
1096 -- Debug Statements
1097 --
1098 IF l_debug_on THEN
1099 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1100 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1101 END IF;
1102 --
1103 WHEN OTHERS THEN
1104 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1105 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.getTransactionKey');
1106 --
1107 -- Debug Statements
1108 --
1109 IF l_debug_on THEN
1110 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1111 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1112 END IF;
1113 --
1114 --}
1115 END getTransactionKey;
1116 --
1117 --========================================================================
1118 -- PROCEDURE : addTransactionHistoryRecord
1119 --
1120 -- PARAMETERS: p_transactionType Transaction Type
1121 -- p_line_rec ASN/Receipt Lines
1122 -- x_return_status Return status of the API
1123 --
1124 --
1125 -- COMMENT : This procedure add a transaction history record to the pl/sql
1126 -- table specified by the parameter x_inboundTxnHistory_recTbl
1127 --========================================================================
1128 --
1129 --
1130 PROCEDURE addTransactionHistoryRecord
1131 (
1132 p_transactionType IN VARCHAR2,
1133 p_ReceiptAgainstASN IN VARCHAR2,
1134 p_index IN NUMBER,
1135 p_line_rec IN OE_WSH_BULK_GRP.Line_rec_type,
1136 p_ship_from_location_id IN NUMBER, -- IB-Phase-2
1137 x_inboundTxnHistory_recTbl IN OUT NOCOPY WSH_INBOUND_TXN_HISTORY_PKG.inboundTxnHistory_recTbl_type,
1138 x_return_status OUT NOCOPY VARCHAR2
1139 )
1140 IS
1141 --{
1142 l_count NUMBER := 0;
1143 --
1144 l_num_warnings NUMBER := 0;
1145 l_num_errors NUMBER := 0;
1146 l_return_status VARCHAR2(30);
1147 --
1148 l_txnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
1149 --
1150 l_debug_on BOOLEAN;
1151 --
1152 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'ADDTRANSACTIONHISTORYRECORD';
1153 --
1154 --}
1155 BEGIN
1156 --{
1157 --
1158 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1159 --
1160 IF l_debug_on IS NULL
1161 THEN
1162 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1163 END IF;
1164 --
1165 --
1166 -- Debug Statements
1167 --
1168 IF l_debug_on THEN
1169 WSH_DEBUG_SV.push(l_module_name);
1170 --
1171 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
1172 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
1173 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
1174 END IF;
1175 --
1176 l_count := x_inboundTxnHistory_recTbl.TRANSACTION_TYPE.COUNT + 1;
1177 --
1178 --
1179 IF l_debug_on THEN
1180 WSH_DEBUG_SV.log(l_module_name,'l_count',l_count);
1181 END IF;
1182 --
1183 --
1184 x_inboundTxnHistory_recTbl.RECEIPT_NUMBER(l_count) := p_line_rec.receipt_num(p_index);
1185 x_inboundTxnHistory_recTbl.SHIPMENT_NUMBER(l_count) := p_line_rec.shipment_num(p_index);
1186 x_inboundTxnHistory_recTbl.TRANSACTION_TYPE(l_count) := p_transactionType;
1187 x_inboundTxnHistory_recTbl.SHIPMENT_HEADER_ID(l_count) := p_line_rec.shipment_header_id(p_index);
1188 x_inboundTxnHistory_recTbl.ORGANIZATION_ID(l_count) := p_line_rec.organization_id(p_index);
1189 x_inboundTxnHistory_recTbl.SUPPLIER_ID(l_count) := p_line_rec.vendor_id(p_index);
1190 x_inboundTxnHistory_recTbl.SHIPPED_DATE(l_count) := p_line_rec.shipped_date(p_index);
1191 x_inboundTxnHistory_recTbl.RECEIPT_DATE(l_count) := p_line_rec.expected_receipt_date(p_index);
1192 x_inboundTxnHistory_recTbl.CARRIER_ID(l_count) := p_line_rec.rcv_carrier_id(p_index);
1193 x_inboundTxnHistory_recTbl.SHIP_FROM_LOCATION_ID(l_count):= p_ship_from_location_id; -- IB-Phase-2
1194 x_inboundTxnHistory_recTbl.REVISION_NUMBER(l_count) := NULL;
1195 x_inboundTxnHistory_recTbl.MATCH_REVERTED_BY(l_count) := NULL;
1196 x_inboundTxnHistory_recTbl.MATCHED_BY(l_count) := NULL;
1197 --
1198 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
1199 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1200 THEN
1201 x_inboundTxnHistory_recTbl.STATUS(l_count) := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING;
1202 x_inboundTxnHistory_recTbl.MAX_RCV_TRANSACTION_ID(l_count) := NULL;
1203 x_inboundTxnHistory_recTbl.SHIPMENT_LINE_ID(l_count) := NULL;
1204 ELSE
1205 x_inboundTxnHistory_recTbl.STATUS(l_count) := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING; --_PARENT_MATCHING;
1206 x_inboundTxnHistory_recTbl.MAX_RCV_TRANSACTION_ID(l_count) := p_line_rec.rcv_transaction_id(p_index);
1207 x_inboundTxnHistory_recTbl.SHIPMENT_LINE_ID(l_count) := p_line_rec.shipment_line_id(p_index);
1208 END IF;
1209 --
1210 IF p_ReceiptAgainstASN = 'Y'
1211 THEN
1212 x_inboundTxnHistory_recTbl.PARENT_SHIPMENT_HEADER_ID(l_count) := p_line_rec.shipment_header_id(p_index);
1213 ELSE
1214 x_inboundTxnHistory_recTbl.PARENT_SHIPMENT_HEADER_ID(l_count) := NULL;
1215 END IF;
1216 --
1217 --
1218 --
1219 --
1220 IF l_debug_on THEN
1221 WSH_DEBUG_SV.logmsg(l_module_name,
1222 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
1223 END IF;
1224 --
1225 IF l_num_errors > 0
1226 THEN
1227 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1228 ELSIF l_num_warnings > 0
1229 THEN
1230 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1231 ELSE
1232 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1233 END IF;
1234 --
1235 -- Debug Statements
1236 --
1237 IF l_debug_on THEN
1238 WSH_DEBUG_SV.pop(l_module_name);
1239 END IF;
1240 --
1241 --}
1242 EXCEPTION
1243 --{
1244 WHEN FND_API.G_EXC_ERROR THEN
1245 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1246 --
1247 -- Debug Statements
1248 --
1249 IF l_debug_on THEN
1250 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1251 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1252 END IF;
1253 --
1254 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1255 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1256 --
1257 -- Debug Statements
1258 --
1259 IF l_debug_on THEN
1260 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1261 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1262 END IF;
1263 --
1264 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1265 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1266 --
1267 -- Debug Statements
1268 --
1269 IF l_debug_on THEN
1270 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1271 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1272 END IF;
1273 --
1274 WHEN OTHERS THEN
1275 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1276 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.addTransactionHistoryRecord');
1277 --
1278 -- Debug Statements
1279 --
1280 IF l_debug_on THEN
1281 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1282 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1283 END IF;
1284 --
1285 --}
1286 END addTransactionHistoryRecord;
1287 --
1288 --
1289 --========================================================================
1290 -- PROCEDURE : insertTransactionHistory
1291 --
1292 -- PARAMETERS: p_transactionType Transaction Type
1293 -- p_autonomous Insert should be an Autonomous transaction or not.
1294 -- p_line_rec ASN/Receipt Lines
1295 -- x_return_status Return status of the API
1296 --
1297 --
1298 -- COMMENT : Inserts a record into WSH_INBOUND_TXN_HISTORY.
1299 --
1300 --========================================================================
1301 --
1302 PROCEDURE insertTransactionHistory
1303 (
1304 p_transactionType IN VARCHAR2,
1305 p_ReceiptAgainstASN IN VARCHAR2,
1306 p_autonomous IN BOOLEAN,
1307 p_index IN NUMBER,
1308 p_line_rec IN OE_WSH_BULK_GRP.Line_rec_type,
1309 p_ship_from_location_id IN NUMBER, -- IB-Phase-2
1310 x_transactionId OUT NOCOPY NUMBER,
1311 x_return_status OUT NOCOPY VARCHAR2
1312 )
1313 IS
1314 --{
1315 l_num_warnings NUMBER := 0;
1316 l_num_errors NUMBER := 0;
1317 l_return_status VARCHAR2(30);
1318 --
1319 l_txnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
1320 --
1321 l_debug_on BOOLEAN;
1322 --
1323 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'INSERTTRANSACTIONHISTORY';
1324 --
1325 --}
1326 BEGIN
1327 --{
1328 --
1329 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1330 --
1331 IF l_debug_on IS NULL
1332 THEN
1333 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1334 END IF;
1335 --
1336 --
1337 -- Debug Statements
1338 --
1339 IF l_debug_on THEN
1340 WSH_DEBUG_SV.push(l_module_name);
1341 --
1342 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
1343 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
1344 WSH_DEBUG_SV.log(l_module_name,'P_AUTONOMOUS',P_AUTONOMOUS);
1345 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
1346 END IF;
1347 --
1348 l_txnHistoryRec.RECEIPT_NUMBER := p_line_rec.receipt_num(p_index);
1349 l_txnHistoryRec.SHIPMENT_NUMBER := p_line_rec.shipment_num(p_index);
1350 l_txnHistoryRec.TRANSACTION_TYPE := p_transactionType;
1351 l_txnHistoryRec.SHIPMENT_HEADER_ID := p_line_rec.shipment_header_id(p_index);
1352 l_txnHistoryRec.ORGANIZATION_ID := p_line_rec.organization_id(p_index);
1353 l_txnHistoryRec.SUPPLIER_ID := p_line_rec.vendor_id(p_index);
1354 l_txnHistoryRec.SHIPPED_DATE := p_line_rec.shipped_date(p_index);
1355 l_txnHistoryRec.RECEIPT_DATE := p_line_rec.expected_receipt_date(p_index);
1356 l_txnHistoryRec.CARRIER_ID := p_line_rec.rcv_carrier_id(p_index);
1357 l_txnHistoryRec.SHIP_FROM_LOCATION_ID := p_ship_from_location_id; -- IB-Phase-2
1358 --
1359 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
1360 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1361 THEN
1362 l_txnHistoryRec.STATUS := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING;
1363 --
1364 l_txnHistoryRec.MAX_RCV_TRANSACTION_ID := GREATEST(
1365 p_line_rec.rcv_transaction_id(p_index),
1366 p_line_rec.rcv_transaction_id(p_line_rec.rcv_transaction_id.FIRST)
1367 );
1368 l_txnHistoryRec.MAX_RCV_TRANSACTION_ID := GREATEST(
1369 l_txnHistoryRec.MAX_RCV_TRANSACTION_ID,
1370 p_line_rec.rcv_transaction_id(p_line_rec.rcv_transaction_id.LAST)
1371 );
1372 ELSE
1373 l_txnHistoryRec.STATUS := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING; --_PARENT_MATCHING;
1374 l_txnHistoryRec.MAX_RCV_TRANSACTION_ID := p_line_rec.rcv_transaction_id(p_index);
1375 l_txnHistoryRec.SHIPMENT_LINE_ID := p_line_rec.shipment_line_id(p_index);
1376 END IF;
1377 --
1378 IF p_ReceiptAgainstASN = 'Y'
1379 THEN
1380 l_txnHistoryRec.PARENT_SHIPMENT_HEADER_ID := p_line_rec.shipment_header_id(p_index);
1381 END IF;
1382 --
1383 --
1384 IF p_autonomous
1385 THEN
1386 --{
1387 --
1388 -- Debug Statements
1389 --
1390 IF l_debug_on THEN
1391 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.AUTONOMOUS_CREATE',WSH_DEBUG_SV.C_PROC_LEVEL);
1392 END IF;
1393 --
1394 WSH_INBOUND_TXN_HISTORY_PKG.autonomous_Create
1395 (
1396 p_txn_history_rec => l_txnHistoryRec,
1397 x_txn_id => x_transactionId,
1398 x_return_status => l_return_status
1399 );
1400 --}
1401 ELSE
1402 --{
1403 --
1404 -- Debug Statements
1405 --
1406 IF l_debug_on THEN
1407 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.CREATE_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
1408 END IF;
1409 --
1410 WSH_INBOUND_TXN_HISTORY_PKG.create_txn_history
1411 (
1412 p_txn_history_rec => l_txnHistoryRec,
1413 x_txn_id => x_transactionId,
1414 x_return_status => l_return_status
1415 );
1416 --}
1417 END IF;
1418 --
1419 --
1420 -- Debug Statements
1421 --
1422 IF l_debug_on THEN
1423 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1424 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1425 END IF;
1426 --
1427 wsh_util_core.api_post_call
1428 (
1429 p_return_status => l_return_status,
1430 x_num_warnings => l_num_warnings,
1431 x_num_errors => l_num_errors
1432 );
1433 --
1434 --
1435 --
1436 --
1437 IF l_debug_on THEN
1438 WSH_DEBUG_SV.logmsg(l_module_name,
1439 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
1440 END IF;
1441 --
1442 IF l_num_errors > 0
1443 THEN
1444 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1445 ELSIF l_num_warnings > 0
1446 THEN
1447 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1448 ELSE
1449 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1450 END IF;
1451 --
1452 -- Debug Statements
1453 --
1454 IF l_debug_on THEN
1455 WSH_DEBUG_SV.pop(l_module_name);
1456 END IF;
1457 --
1458 --}
1459 EXCEPTION
1460 --{
1461 WHEN FND_API.G_EXC_ERROR THEN
1462 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1463 --
1464 -- Debug Statements
1465 --
1466 IF l_debug_on THEN
1467 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1468 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1469 END IF;
1470 --
1471 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1472 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1473 --
1474 -- Debug Statements
1475 --
1476 IF l_debug_on THEN
1477 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1478 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1479 END IF;
1480 --
1481 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1482 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1483 --
1484 -- Debug Statements
1485 --
1486 IF l_debug_on THEN
1487 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1488 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1489 END IF;
1490 --
1491 WHEN OTHERS THEN
1492 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1493 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.insertTransactionHistory');
1494 --
1495 -- Debug Statements
1496 --
1497 IF l_debug_on THEN
1498 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1499 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1500 END IF;
1501 --
1502 --}
1503 END insertTransactionHistory;
1504 --
1505 --
1506 --========================================================================
1507 -- PROCEDURE : checkShipmentHistory
1508 --
1509 -- PARAMETERS: p_transactionType Transaction Type
1510 -- p_line_rec ASN/Receipt Lines
1511 -- x_return_status Return status of the API
1512 --
1513 --
1514 -- COMMENT : Check shipment/receipt history.
1515 --
1516 -- For ASN/Receipt, check if same ASN/Receipt is being interfaced again
1517 -- - If so, raise error
1518 -- - If not, insert a record into WSH_INBOUND_TXN_HISTORY and lock it
1519 --
1520 -- For other transactions, obtain parent(ASN/Receipt) record from
1521 -- WSH_INBOUND_TXN_HISTORY and lock it.
1522 --========================================================================
1523 --
1524 PROCEDURE checkShipmentHistory
1525 (
1526 p_transactionType IN VARCHAR2,
1527 p_shipmentHeaderId IN NUMBER,
1528 p_ReceiptAgainstASN IN VARCHAR2,
1529 p_inboundTxnHistoryId IN NUMBER,
1530 p_line_rec IN OE_WSH_BULK_GRP.Line_rec_type,
1531 p_ship_from_location_id IN NUMBER, -- IB-Phase-2
1532 x_parentTxnHistoryRec OUT NOCOPY WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type,
1533 x_transactionId OUT NOCOPY NUMBER,
1534 x_transactionGroup OUT NOCOPY VARCHAR2,
1535 x_return_status OUT NOCOPY VARCHAR2
1536 )
1537 IS
1538 --{
1539 l_num_warnings NUMBER := 0;
1540 l_num_errors NUMBER := 0;
1541 l_return_status VARCHAR2(30);
1542 l_locked VARCHAR2(1);
1543 --
1544 l_txnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
1545 l_parentTxnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
1546 --
1547 l_parentShipmentHeaderId NUMBER;
1548 l_parentTransactionType VARCHAR2(30);
1549 l_on_noDataFound VARCHAR2(30);
1550 --
1551 l_debug_on BOOLEAN;
1552 --
1553 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECKSHIPMENTHISTORY';
1554 --
1555 --}
1556 BEGIN
1557 --{
1558 --
1559 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1560 --
1561 IF l_debug_on IS NULL
1562 THEN
1563 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1564 END IF;
1565 --
1566 --
1567 -- Debug Statements
1568 --
1569 IF l_debug_on THEN
1570 WSH_DEBUG_SV.push(l_module_name);
1571 --
1572 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
1573 WSH_DEBUG_SV.log(l_module_name,'P_SHIPMENTHEADERID',P_SHIPMENTHEADERID);
1574 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
1575 WSH_DEBUG_SV.log(l_module_name,'p_inboundTxnHistoryId',p_inboundTxnHistoryId);
1576 END IF;
1577 --
1578 IF p_transactionType IN (
1579 WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,
1580 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1581 )
1582 THEN
1583 --{
1584 --
1585 -- Debug Statements
1586 --
1587 IF l_debug_on THEN
1588 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GET_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
1589 END IF;
1590 --
1591 -- Check if record already exists in WSH_INBOUND_TXN_HISTORY
1592 --
1593 WSH_INBOUND_TXN_HISTORY_PKG.get_txn_history
1594 (
1595 p_shipment_header_id => p_shipmentHeaderId,
1596 p_transaction_type => p_transactionType,
1597 x_txn_history_rec => l_txnHistoryRec,
1598 x_return_status => l_return_status
1599 );
1600 --
1601 --
1602 --
1603 -- Debug Statements
1604 --
1605 IF l_debug_on THEN
1606 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1607 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1608 END IF;
1609 --
1610 wsh_util_core.api_post_call
1611 (
1612 p_return_status => l_return_status,
1613 x_num_warnings => l_num_warnings,
1614 x_num_errors => l_num_errors
1615 );
1616 --
1617 --
1618 IF l_txnHistoryRec.transaction_id IS NOT NULL
1619 THEN
1620 --{
1621 IF p_inboundTxnHistoryId IS NULL
1622 THEN
1623 --{
1624 -- Record already exists in WSH_INBOUND_TXN_HISTORY, raise error
1625 --
1626 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
1627 THEN
1628 FND_MESSAGE.SET_NAME('WSH','WSH_IB_DUP_ASN_ERROR');
1629 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUMBER',l_txnHistoryRec.SHIPMENT_NUMBER);
1630 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1631 THEN
1632 FND_MESSAGE.SET_NAME('WSH','WSH_IB_DUP_RECPT_ERROR');
1633 FND_MESSAGE.SET_TOKEN('RECEIPT_NUMBER',l_txnHistoryRec.RECEIPT_NUMBER);
1634 END IF;
1635 --
1636 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
1637 RAISE FND_API.G_EXC_ERROR;
1638 --}
1639 ELSE
1640 --{
1641 x_transactionId := l_txnHistoryRec.transaction_id;
1642 --}
1643 END IF;
1644 --}
1645 --ELSIF l_txnHistoryRec.transaction_id IS NULL
1646 --THEN
1647 ELSE
1648 --{
1649 --
1650 -- Debug Statements
1651 --
1652 IF l_debug_on THEN
1653 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.INSERTTRANSACTIONHISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
1654 END IF;
1655 --
1656 WSH_IB_TXN_MATCH_PKG.insertTransactionHistory
1657 (
1658 p_transactionType => p_transactionType,
1659 p_ReceiptAgainstASN => p_ReceiptAgainstASN,
1660 p_autonomous => TRUE,
1661 p_index => p_line_rec.shipment_line_id.FIRST,
1662 p_line_rec => p_line_rec,
1663 p_ship_from_location_id => p_ship_from_location_id, -- IB-Phase-2
1664 x_transactionId => x_transactionId,
1665 x_return_status => l_return_status
1666 );
1667 --
1668 --
1669 -- Debug Statements
1670 --
1671 IF l_debug_on THEN
1672 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1673 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1674 END IF;
1675 --
1676 wsh_util_core.api_post_call
1677 (
1678 p_return_status => l_return_status,
1679 x_num_warnings => l_num_warnings,
1680 x_num_errors => l_num_errors
1681 );
1682 --
1683 --
1684 --
1685 -- Debug Statements
1686 --
1687 IF l_debug_on THEN
1688 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.LOCK_ASN_RECEIPT_HEADER',WSH_DEBUG_SV.C_PROC_LEVEL);
1689 END IF;
1690 --
1691 WSH_INBOUND_TXN_HISTORY_PKG.lock_asn_receipt_header
1692 (
1693 p_shipment_header_id => p_shipmentHeaderId,
1694 p_transaction_type => p_transactionType,
1695 p_on_error => 'RETRY',
1696 p_on_noDataFound => WSH_UTIL_CORE.G_RET_STS_ERROR,
1697 x_txn_history_rec => l_txnHistoryRec,
1698 x_return_status => l_return_status,
1699 x_locked => l_locked
1700 );
1701 --
1702 --
1703 --
1704 -- Debug Statements
1705 --
1706 IF l_debug_on THEN
1707 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1708 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1709 END IF;
1710 --
1711 wsh_util_core.api_post_call
1712 (
1713 p_return_status => l_return_status,
1714 x_num_warnings => l_num_warnings,
1715 x_num_errors => l_num_errors
1716 );
1717 --}
1718 END IF;
1719 --}
1720 END IF;
1721 --
1722 --
1723 l_parentShipmentHeaderId := NULL;
1724 l_parentTransactionType := NULL;
1725 l_on_noDataFound := WSH_UTIL_CORE.G_RET_STS_ERROR;
1726 --
1727 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
1728 THEN
1729 x_transactionGroup := WSH_INBOUND_TXN_HISTORY_PKG.C_ASN;
1730 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN
1731 THEN
1732 --{
1733 l_parentShipmentHeaderId := p_shipmentHeaderId;
1734 l_parentTransactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_ASN;
1735 x_transactionGroup := WSH_INBOUND_TXN_HISTORY_PKG.C_ASN;
1736 l_on_noDataFound := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1737 --}
1738 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
1739 THEN
1740 --{
1741 x_transactionGroup := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
1742 --
1743 IF p_ReceiptAgainstASN = 'Y'
1744 THEN
1745 l_parentShipmentHeaderId := p_shipmentHeaderId;
1746 l_parentTransactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_ASN;
1747 END IF;
1748 --}
1749 ELSIF p_transactionType IN (
1750 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION,
1751 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE,
1752 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE,
1753 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV ,
1754 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION ,
1755 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE ,
1756 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE ,
1757 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD ,
1758 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_HEADER_UPD
1759 )
1760 THEN
1761 --{
1762 x_transactionGroup := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
1763 l_parentShipmentHeaderId := p_shipmentHeaderId;
1764 l_parentTransactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
1765 --
1766 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_HEADER_UPD
1767 THEN
1768 l_on_noDataFound := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1769 END IF;
1770 --}
1771 ELSE
1772 --{
1773 FND_MESSAGE.SET_NAME('WSH','WSH_IB_INVALID_TXN_TYPE');
1774 FND_MESSAGE.SET_TOKEN('TXN_TYPE',p_transactionType);
1775 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
1776 RAISE FND_API.G_EXC_ERROR;
1777 --}
1778 END IF;
1779 --
1780 --
1781 IF l_debug_on THEN
1782 WSH_DEBUG_SV.log(l_module_name,'l_parentShipmentHeaderId',l_parentShipmentHeaderId);
1783 WSH_DEBUG_SV.log(l_module_name,'l_parentTransactionType',l_parentTransactionType);
1784 WSH_DEBUG_SV.log(l_module_name,'l_on_noDataFound',l_on_noDataFound);
1785 END IF;
1786 --
1787 --
1788 IF l_parentShipmentHeaderId IS NOT NULL
1789 THEN
1790 --{
1791 --
1792 -- Debug Statements
1793 --
1794 IF l_debug_on THEN
1795 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.LOCK_ASN_RECEIPT_HEADER',WSH_DEBUG_SV.C_PROC_LEVEL);
1796 END IF;
1797 --
1798 WSH_INBOUND_TXN_HISTORY_PKG.lock_asn_receipt_header
1799 (
1800 p_shipment_header_id => l_parentShipmentHeaderId,
1801 p_transaction_type => l_parentTransactionType,
1802 p_on_error => 'RETRY',
1803 p_on_noDataFound => l_on_noDataFound,
1804 x_txn_history_rec => l_parentTxnHistoryRec,
1805 x_return_status => l_return_status,
1806 x_locked => l_locked
1807 );
1808 --
1809 --
1810 --
1811 -- Debug Statements
1812 --
1813 IF l_debug_on THEN
1814 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1815 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1816 END IF;
1817 --
1818 wsh_util_core.api_post_call
1819 (
1820 p_return_status => l_return_status,
1821 x_num_warnings => l_num_warnings,
1822 x_num_errors => l_num_errors
1823 );
1824 --}
1825 END IF;
1826 --
1827 x_parentTxnHistoryRec := l_parentTxnHistoryRec;
1828 --
1829 --
1830 --
1831 --
1832 IF l_debug_on THEN
1833 WSH_DEBUG_SV.logmsg(l_module_name,
1834 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
1835 END IF;
1836 --
1837 IF l_num_errors > 0
1838 THEN
1839 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1840 ELSIF l_num_warnings > 0
1841 THEN
1842 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1843 ELSE
1844 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1845 END IF;
1846 --
1847 -- Debug Statements
1848 --
1849 IF l_debug_on THEN
1850 WSH_DEBUG_SV.pop(l_module_name);
1851 END IF;
1852 --
1853 --}
1854 EXCEPTION
1855 --{
1856 WHEN FND_API.G_EXC_ERROR THEN
1857 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1858 --
1859 -- Debug Statements
1860 --
1861 IF l_debug_on THEN
1862 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1863 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1864 END IF;
1865 --
1866 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1867 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1868 --
1869 -- Debug Statements
1870 --
1871 IF l_debug_on THEN
1872 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1873 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1874 END IF;
1875 --
1876 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1877 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1878 --
1879 -- Debug Statements
1880 --
1881 IF l_debug_on THEN
1882 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1883 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1884 END IF;
1885 --
1886 WHEN OTHERS THEN
1887 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1888 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.checkShipmentHistory');
1889 --
1890 -- Debug Statements
1891 --
1892 IF l_debug_on THEN
1893 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1894 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1895 END IF;
1896 --
1897 --}
1898 END checkShipmentHistory;
1899 --
1900 --
1901 --========================================================================
1902 -- PROCEDURE : processCancelASN
1903 --
1904 -- PARAMETERS: x_parentTxnHistoryRec WSH_INBOUND_TXN_HISTORY record for ASN
1905 -- x_return_status Return status of the API
1906 --
1907 --
1908 -- COMMENT : Processes Cancel ASN transaction. It is called by matchTransaction API
1909 -- after locking the inbound transaction history record for ASN.
1910 --
1911 -- If ASN has already matched, call WSH_ASN_RECEIPT_PVT.Cancel_ASN to
1912 -- perform ASN cancel operation (revert delivery/line/trip/stop status,
1913 -- update shipped quantity to null etc.)
1914 --
1915 -- Update inbound transaction history record for ASN with Cancelled status.
1916 --
1917 --========================================================================
1918 --
1919 PROCEDURE processCancelASN
1920 (
1921 x_parentTxnHistoryRec IN OUT NOCOPY WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type,
1922 x_return_status OUT NOCOPY VARCHAR2
1923 )
1924 IS
1925 --{
1926 l_num_warnings NUMBER := 0;
1927 l_num_errors NUMBER := 0;
1928 l_return_status VARCHAR2(30);
1929 --
1930 l_action_prms wsh_glbl_var_strct_grp.dd_action_parameters_rec_type;
1931 --
1932 l_transactionMeaning VARCHAR2(80);
1933 --
1934 l_debug_on BOOLEAN;
1935 --
1936 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PROCESSCANCELASN';
1937 --
1938 --}
1939 BEGIN
1940 --{
1941 --
1942 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1943 --
1944 IF l_debug_on IS NULL
1945 THEN
1946 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1947 END IF;
1948 --
1949 --
1950 -- Debug Statements
1951 --
1952 IF l_debug_on THEN
1953 WSH_DEBUG_SV.push(l_module_name);
1954 WSH_DEBUG_SV.log(l_module_name,'x_parentTxnHistoryRec.transaction_id',x_parentTxnHistoryRec.transaction_id);
1955 WSH_DEBUG_SV.log(l_module_name,'x_parentTxnHistoryRec.status',x_parentTxnHistoryRec.status);
1956 END IF;
1957 --
1958 IF x_parentTxnHistoryRec.transaction_id IS NOT NULL
1959 THEN
1960 --{
1961 IF x_parentTxnHistoryRec.status = WSH_INBOUND_TXN_HISTORY_PKG.C_CANCELLED
1962 THEN
1963 --{
1964 FND_MESSAGE.SET_NAME('WSH','WSH_IB_DUP_CANCEL_ASN_ERROR');
1965 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUMBER',x_parentTxnHistoryRec.SHIPMENT_NUMBER);
1966 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
1967 RAISE FND_API.G_EXC_ERROR;
1968 --}
1969 END IF;
1970 --
1971 --
1972 IF x_parentTxnHistoryRec.status = WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED
1973 THEN
1974 --{
1975 l_action_prms.action_code := WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN;
1976 --
1977 --
1978 -- Debug Statements
1979 --
1980 IF l_debug_on THEN
1981 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.CANCEL_ASN',WSH_DEBUG_SV.C_PROC_LEVEL);
1982 END IF;
1983 --
1984 WSH_ASN_RECEIPT_PVT.Cancel_ASN
1985 (
1986 p_header_id => x_parentTxnHistoryRec.shipment_header_id,
1987 p_action_prms => l_action_prms,
1988 x_return_status => l_return_status
1989 );
1990 --
1991 --
1992 --
1993 -- Debug Statements
1994 --
1995 IF l_debug_on THEN
1996 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1997 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1998 END IF;
1999 --
2000 wsh_util_core.api_post_call
2001 (
2002 p_return_status => l_return_status,
2003 x_num_warnings => l_num_warnings,
2004 x_num_errors => l_num_errors
2005 );
2006 --}
2007 END IF;
2008 --
2009 --
2010 IF x_parentTxnHistoryRec.status = WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED
2011 OR x_parentTxnHistoryRec.status = WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING
2012 THEN
2013 --{
2014 x_parentTxnHistoryRec.status := WSH_INBOUND_TXN_HISTORY_PKG.C_CANCELLED;
2015 --
2016 --
2017 -- Debug Statements
2018 --
2019 IF l_debug_on THEN
2020 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.UPDATE_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
2021 END IF;
2022 --
2023 WSH_INBOUND_TXN_HISTORY_PKG.update_txn_history
2024 (
2025 p_txn_history_rec => x_parentTxnHistoryRec,
2026 x_return_status => l_return_status
2027 );
2028 --
2029 --
2030 --
2031 -- Debug Statements
2032 --
2033 IF l_debug_on THEN
2034 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2035 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2036 END IF;
2037 --
2038 wsh_util_core.api_post_call
2039 (
2040 p_return_status => l_return_status,
2041 x_num_warnings => l_num_warnings,
2042 x_num_errors => l_num_errors
2043 );
2044 --}
2045 ELSE
2046 --{
2047 --
2048 -- Debug Statements
2049 --
2050 IF l_debug_on THEN
2051 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GETTRANSACTIONTYPEMEANING',WSH_DEBUG_SV.C_PROC_LEVEL);
2052 END IF;
2053 --
2054 WSH_INBOUND_TXN_HISTORY_PKG.getTransactionTypeMeaning
2055 (
2056 p_transactionType => WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,
2057 x_transactionMeaning => l_transactionMeaning,
2058 x_return_status => l_return_status
2059 );
2060 --
2061 --
2062 --
2063 -- Debug Statements
2064 --
2065 IF l_debug_on THEN
2066 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2067 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2068 END IF;
2069 --
2070 wsh_util_core.api_post_call
2071 (
2072 p_return_status => l_return_status,
2073 x_num_warnings => l_num_warnings,
2074 x_num_errors => l_num_errors
2075 );
2076 --
2077 --
2078 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_INVALID_STATUS');
2079 FND_MESSAGE.SET_TOKEN('STATUS_CODE',x_parentTxnHistoryRec.status);
2080 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning);
2081 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',x_parentTxnHistoryRec.RECEIPT_NUMBER);
2082 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',x_parentTxnHistoryRec.SHIPMENT_NUMBER);
2083 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
2084 RAISE FND_API.G_EXC_ERROR;
2085 --}
2086 END IF;
2087 --}
2088 END IF;
2089 --
2090 --
2091 --
2092 --
2093 IF l_debug_on THEN
2094 WSH_DEBUG_SV.logmsg(l_module_name,
2095 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2096 END IF;
2097 --
2098 IF l_num_errors > 0
2099 THEN
2100 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2101 ELSIF l_num_warnings > 0
2102 THEN
2103 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2104 ELSE
2105 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2106 END IF;
2107 --
2108 -- Debug Statements
2109 --
2110 IF l_debug_on THEN
2111 WSH_DEBUG_SV.pop(l_module_name);
2112 END IF;
2113 --
2114 --}
2115 EXCEPTION
2116 --{
2117 WHEN FND_API.G_EXC_ERROR THEN
2118 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2119 --
2120 -- Debug Statements
2121 --
2122 IF l_debug_on THEN
2123 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2124 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2125 END IF;
2126 --
2127 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2128 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2129 --
2130 -- Debug Statements
2131 --
2132 IF l_debug_on THEN
2133 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2134 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2135 END IF;
2136 --
2137 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2138 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2139 --
2140 -- Debug Statements
2141 --
2142 IF l_debug_on THEN
2143 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2144 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2145 END IF;
2146 --
2147 WHEN OTHERS THEN
2148 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2149 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.processCancelASN');
2150 --
2151 -- Debug Statements
2152 --
2153 IF l_debug_on THEN
2154 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2155 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2156 END IF;
2157 --
2158 --}
2159 END processCancelASN;
2160
2161 PROCEDURE processReceiptHeaderUpdate
2162 (
2163 x_parentTxnHistoryRec IN OUT NOCOPY WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type,
2164 x_return_status OUT NOCOPY VARCHAR2
2165 )
2166 IS
2167 --{
2168 l_num_warnings NUMBER := 0;
2169 l_num_errors NUMBER := 0;
2170 l_return_status VARCHAR2(30);
2171 --
2172 --
2173 l_debug_on BOOLEAN;
2174 --
2175 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PROCESSRECEIPTHEADERUPDATE';
2176 --
2177 --}
2178 BEGIN
2179 --{
2180 --
2181 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2182 --
2183 IF l_debug_on IS NULL
2184 THEN
2185 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2186 END IF;
2187 --
2188 --
2189 -- Debug Statements
2190 --
2191 IF l_debug_on THEN
2192 WSH_DEBUG_SV.push(l_module_name);
2193 END IF;
2194 --
2195 NULL;
2196 --
2197 --
2198 --
2199 --
2200 IF l_debug_on THEN
2201 WSH_DEBUG_SV.logmsg(l_module_name,
2202 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2203 END IF;
2204 --
2205 IF l_num_errors > 0
2206 THEN
2207 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2208 ELSIF l_num_warnings > 0
2209 THEN
2210 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2211 ELSE
2212 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2213 END IF;
2214 --
2215 -- Debug Statements
2216 --
2217 IF l_debug_on THEN
2218 WSH_DEBUG_SV.pop(l_module_name);
2219 END IF;
2220 --
2221 --}
2222 EXCEPTION
2223 --{
2224 WHEN FND_API.G_EXC_ERROR THEN
2225 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2226 --
2227 -- Debug Statements
2228 --
2229 IF l_debug_on THEN
2230 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2231 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2232 END IF;
2233 --
2234 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2235 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2236 --
2237 -- Debug Statements
2238 --
2239 IF l_debug_on THEN
2240 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2241 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2242 END IF;
2243 --
2244 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2245 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2246 --
2247 -- Debug Statements
2248 --
2249 IF l_debug_on THEN
2250 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2251 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2252 END IF;
2253 --
2254 WHEN OTHERS THEN
2255 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2256 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.processReceiptHeaderUpdate');
2257 --
2258 -- Debug Statements
2259 --
2260 IF l_debug_on THEN
2261 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2262 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2263 END IF;
2264 --
2265 --}
2266 END processReceiptHeaderUpdate;
2267
2268 PROCEDURE extendLineRecTbl
2269 (
2270 p_extendBy IN NUMBER,
2271 x_lineRecTbl IN OUT NOCOPY line_recTbl_type,
2272 x_return_status OUT NOCOPY VARCHAR2
2273 )
2274 IS
2275 --{
2276 l_num_warnings NUMBER := 0;
2277 l_num_errors NUMBER := 0;
2278 l_return_status VARCHAR2(30);
2279 --
2280 l_debug_on BOOLEAN;
2281 --
2282 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'EXTENDLINERECTBL';
2283 --
2284 --}
2285 BEGIN
2286 --{
2287 --
2288 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2289 --
2290 IF l_debug_on IS NULL
2291 THEN
2292 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2293 END IF;
2294 --
2295 --
2296 -- Debug Statements
2297 --
2298 IF l_debug_on THEN
2299 WSH_DEBUG_SV.push(l_module_name);
2300 --
2301 WSH_DEBUG_SV.log(l_module_name,'P_EXTENDBY',P_EXTENDBY);
2302 END IF;
2303 --
2304 x_lineRecTbl.delivery_detail_id_tbl.EXTEND(p_extendBy);
2305 x_lineRecTbl.requested_quantity_tbl.EXTEND(p_extendBy);
2306 x_lineRecTbl.picked_quantity_tbl.EXTEND(p_extendBy);
2307 x_lineRecTbl.shipped_quantity_tbl.EXTEND(p_extendBy);
2308 x_lineRecTbl.received_quantity_tbl.EXTEND(p_extendBy);
2309 x_lineRecTbl.returned_quantity_tbl.EXTEND(p_extendBy);
2310 x_lineRecTbl.requested_quantity2_tbl.EXTEND(p_extendBy);
2311 x_lineRecTbl.picked_quantity2_tbl.EXTEND(p_extendBy);
2312 x_lineRecTbl.shipped_quantity2_tbl.EXTEND(p_extendBy);
2313 x_lineRecTbl.received_quantity2_tbl.EXTEND(p_extendBy);
2314 x_lineRecTbl.returned_quantity2_tbl.EXTEND(p_extendBy);
2315 x_lineRecTbl.ship_from_location_id_tbl.EXTEND(p_extendBy);
2316 x_lineRecTbl.earliest_dropoff_date_tbl.EXTEND(p_extendBy);
2317 x_lineRecTbl.delivery_id_tbl.EXTEND(p_extendBy);
2318 x_lineRecTbl.rcv_shipment_line_id_tbl.EXTEND(p_extendBy);
2319 x_lineRecTbl.requested_quantity_uom_tbl.EXTEND(p_extendBy);
2320 x_lineRecTbl.requested_quantity_uom2_tbl.EXTEND(p_extendBy);
2321 x_lineRecTbl.released_status_tbl.EXTEND(p_extendBy);
2322 x_lineRecTbl.src_requested_quantity_tbl.EXTEND(p_extendBy);
2323 x_lineRecTbl.src_requested_quantity2_tbl.EXTEND(p_extendBy);
2324 x_lineRecTbl.last_update_date_tbl.EXTEND(p_extendBy);
2325 --
2326 --
2327 --
2328 --
2329 IF l_debug_on THEN
2330 WSH_DEBUG_SV.logmsg(l_module_name,
2331 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2332 END IF;
2333 --
2334 IF l_num_errors > 0
2335 THEN
2336 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2337 ELSIF l_num_warnings > 0
2338 THEN
2339 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2340 ELSE
2341 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2342 END IF;
2343 --
2344 -- Debug Statements
2345 --
2346 IF l_debug_on THEN
2347 WSH_DEBUG_SV.pop(l_module_name);
2348 END IF;
2349 --
2350 --}
2351 EXCEPTION
2352 --{
2353 WHEN FND_API.G_EXC_ERROR THEN
2354 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2355 --
2356 -- Debug Statements
2357 --
2358 IF l_debug_on THEN
2359 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2360 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2361 END IF;
2362 --
2363 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2364 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2365 --
2366 -- Debug Statements
2367 --
2368 IF l_debug_on THEN
2369 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2370 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2371 END IF;
2372 --
2373 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2374 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2375 --
2376 -- Debug Statements
2377 --
2378 IF l_debug_on THEN
2379 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2380 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2381 END IF;
2382 --
2383 WHEN OTHERS THEN
2384 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2385 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.extendLineRecTbl');
2386 --
2387 -- Debug Statements
2388 --
2389 IF l_debug_on THEN
2390 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2391 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2392 END IF;
2393 --
2394 --}
2395 END extendLineRecTbl;
2396 --
2397 -- add a new delivery line (Ordered qty.=0)
2398 --
2399 PROCEDURE addNewLine
2400 (
2401 p_lineDate IN DATE,
2402 p_primaryUomCode IN VARCHAR2,
2403 p_secondaryUomCode IN VARCHAR2,
2404 x_lineRecTbl IN OUT NOCOPY line_recTbl_type,
2405 x_return_status OUT NOCOPY VARCHAR2
2406 )
2407 IS
2408 --{
2409 l_num_warnings NUMBER := 0;
2410 l_num_errors NUMBER := 0;
2411 l_return_status VARCHAR2(30);
2412 l_index NUMBER := 1;
2413 --
2414 l_debug_on BOOLEAN;
2415 --
2416 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'ADDNEWLINE';
2417 --
2418 --}
2419 BEGIN
2420 --{
2421 --
2422 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2423 --
2424 IF l_debug_on IS NULL
2425 THEN
2426 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2427 END IF;
2428 --
2429 --
2430 -- Debug Statements
2431 --
2432 IF l_debug_on THEN
2433 WSH_DEBUG_SV.push(l_module_name);
2434 --
2435 WSH_DEBUG_SV.log(l_module_name,'P_LINEDATE',P_LINEDATE);
2436 WSH_DEBUG_SV.log(l_module_name,'P_PRIMARYUOMCODE',P_PRIMARYUOMCODE);
2437 WSH_DEBUG_SV.log(l_module_name,'P_SECONDARYUOMCODE',P_SECONDARYUOMCODE);
2438 END IF;
2439 --
2440 IF NOT x_lineRecTbl.released_status_tbl.EXISTS(l_index)
2441 THEN
2442 --{
2443 --
2444 -- Debug Statements
2445 --
2446 IF l_debug_on THEN
2447 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.EXTENDLINERECTBL',WSH_DEBUG_SV.C_PROC_LEVEL);
2448 END IF;
2449 --
2450 WSH_IB_TXN_MATCH_PKG.extendLineRecTbl
2451 (
2452 p_extendBy => 1,
2453 x_lineRecTbl => x_lineRecTbl,
2454 x_return_status => l_return_status
2455 );
2456 --
2457 --
2458 -- Debug Statements
2459 --
2460 IF l_debug_on THEN
2461 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2462 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2463 END IF;
2464 --
2465 wsh_util_core.api_post_call
2466 (
2467 p_return_status => l_return_status,
2468 x_num_warnings => l_num_warnings,
2469 x_num_errors => l_num_errors
2470 );
2471 --}
2472 END IF;
2473 --
2474 x_lineRecTbl.delivery_detail_id_tbl(l_index) := NULL;
2475 x_lineRectbl.requested_quantity_tbl(l_index) := 0;
2476 x_lineRectbl.picked_quantity_tbl(l_index) := NULL;
2477 x_lineRectbl.shipped_quantity_tbl(l_index) := NULL;
2478 x_lineRectbl.received_quantity_tbl(l_index) := NULL;
2479 x_lineRectbl.returned_quantity_tbl(l_index) := NULL;
2480 x_lineRectbl.requested_quantity2_tbl(l_index) := 0;
2481 x_lineRectbl.picked_quantity2_tbl(l_index) := NULL;
2482 x_lineRectbl.shipped_quantity2_tbl(l_index) := NULL;
2483 x_lineRectbl.received_quantity2_tbl(l_index) := NULL;
2484 x_lineRectbl.returned_quantity2_tbl(l_index) := NULL;
2485 x_lineRectbl.ship_from_location_id_tbl(l_index) := WSH_UTIL_CORE.C_NULL_SF_LOCN_ID;
2486 x_lineRectbl.earliest_dropoff_date_tbl(l_index) := p_lineDate;
2487 x_lineRectbl.delivery_id_tbl(l_index) := NULL;
2488 x_lineRectbl.rcv_shipment_line_id_tbl(l_index) := NULL;
2489 x_lineRectbl.requested_quantity_uom_tbl(l_index) := p_primaryUomCode;
2490 x_lineRectbl.requested_quantity_uom2_tbl(l_index) := p_secondaryUomCode;
2491 x_lineRectbl.released_status_tbl(l_index) := 'X';
2492 x_lineRectbl.src_requested_quantity_tbl(l_index) := NULL;
2493 x_lineRectbl.src_requested_quantity2_tbl(l_index) := NULL;
2494 --
2495 --
2496 --
2497 IF l_debug_on THEN
2498 WSH_DEBUG_SV.logmsg(l_module_name,
2499 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2500 END IF;
2501 --
2502 IF l_num_errors > 0
2503 THEN
2504 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2505 ELSIF l_num_warnings > 0
2506 THEN
2507 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2508 ELSE
2509 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2510 END IF;
2511 --
2512 -- Debug Statements
2513 --
2514 IF l_debug_on THEN
2515 WSH_DEBUG_SV.pop(l_module_name);
2516 END IF;
2517 --
2518 --}
2519 EXCEPTION
2520 --{
2521 WHEN FND_API.G_EXC_ERROR THEN
2522 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2523 --
2524 -- Debug Statements
2525 --
2526 IF l_debug_on THEN
2527 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2528 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2529 END IF;
2530 --
2531 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2532 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2533 --
2534 -- Debug Statements
2535 --
2536 IF l_debug_on THEN
2537 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2538 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2539 END IF;
2540 --
2541 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2542 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2543 --
2544 -- Debug Statements
2545 --
2546 IF l_debug_on THEN
2547 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2548 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2549 END IF;
2550 --
2551 WHEN OTHERS THEN
2552 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2553 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.addNewLine');
2554 --
2555 -- Debug Statements
2556 --
2557 IF l_debug_on THEN
2558 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2559 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2560 END IF;
2561 --
2562 --}
2563 END addNewLine;
2564 --
2565 --
2566 PROCEDURE extendMatchedLineRecTbl
2567 (
2568 p_extendBy IN NUMBER,
2569 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
2570 x_return_status OUT NOCOPY VARCHAR2
2571 )
2572 IS
2573 --{
2574 l_num_warnings NUMBER := 0;
2575 l_num_errors NUMBER := 0;
2576 l_return_status VARCHAR2(30);
2577 --
2578 l_debug_on BOOLEAN;
2579 --
2580 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'EXTENDMATCHEDLINERECTBL';
2581 --
2582 --}
2583 BEGIN
2584 --{
2585 --
2586 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2587 --
2588 IF l_debug_on IS NULL
2589 THEN
2590 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2591 END IF;
2592 --
2593 --
2594 -- Debug Statements
2595 --
2596 IF l_debug_on THEN
2597 WSH_DEBUG_SV.push(l_module_name);
2598 --
2599 WSH_DEBUG_SV.log(l_module_name,'P_EXTENDBY',P_EXTENDBY);
2600 END IF;
2601 --
2602 x_matchedLineRecTbl.del_detail_id_tab.EXTEND(p_extendBy);
2603 x_matchedLineRecTbl.parent_delivery_detail_id_tab.EXTEND(p_extendBy);
2604 --
2605 x_matchedLineRecTbl.requested_qty_tab.EXTEND(p_extendBy);
2606 x_matchedLineRecTbl.picked_qty_tab.EXTEND(p_extendBy);
2607 x_matchedLineRecTbl.shipped_qty_tab.EXTEND(p_extendBy);
2608 x_matchedLineRecTbl.received_qty_tab.EXTEND(p_extendBy);
2609 x_matchedLineRecTbl.returned_qty_tab.EXTEND(p_extendBy);
2610 --
2611 x_matchedLineRecTbl.requested_qty2_tab.EXTEND(p_extendBy);
2612 x_matchedLineRecTbl.picked_qty2_tab.EXTEND(p_extendBy);
2613 x_matchedLineRecTbl.shipped_qty2_tab.EXTEND(p_extendBy);
2614 x_matchedLineRecTbl.received_qty2_tab.EXTEND(p_extendBy);
2615 x_matchedLineRecTbl.returned_qty2_tab.EXTEND(p_extendBy);
2616 --
2617 x_matchedLineRecTbl.requested_qty_db_tab.EXTEND(p_extendBy);
2618 x_matchedLineRecTbl.picked_qty_db_tab.EXTEND(p_extendBy);
2619 x_matchedLineRecTbl.shipped_qty_db_tab.EXTEND(p_extendBy);
2620 x_matchedLineRecTbl.received_qty_db_tab.EXTEND(p_extendBy);
2621 x_matchedLineRecTbl.returned_qty_db_tab.EXTEND(p_extendBy);
2622 --
2623 x_matchedLineRecTbl.requested_qty2_db_tab.EXTEND(p_extendBy);
2624 x_matchedLineRecTbl.picked_qty2_db_tab.EXTEND(p_extendBy);
2625 x_matchedLineRecTbl.shipped_qty2_db_tab.EXTEND(p_extendBy);
2626 x_matchedLineRecTbl.received_qty2_db_tab.EXTEND(p_extendBy);
2627 x_matchedLineRecTbl.returned_qty2_db_tab.EXTEND(p_extendBy);
2628 --
2629 x_matchedLineRecTbl.line_date_tab.EXTEND(p_extendBy);
2630 x_matchedLineRecTbl.ship_from_location_id_tab.EXTEND(p_extendBy);
2631 x_matchedLineRecTbl.released_status_tab.EXTEND(p_extendBy);
2632 x_matchedLineRecTbl.requested_qty_uom_tab.EXTEND(p_extendBy);
2633 x_matchedLineRecTbl.requested_qty_uom2_tab.EXTEND(p_extendBy);
2634 --
2635 x_matchedLineRecTbl.po_header_id_tab.EXTEND(p_extendBy);
2636 x_matchedLineRecTbl.po_line_location_id_tab.EXTEND(p_extendBy);
2637 x_matchedLineRecTbl.po_line_id_tab.EXTEND(p_extendBy);
2638 x_matchedLineRecTbl.delivery_id_tab.EXTEND(p_extendBy);
2639 x_matchedLineRecTbl.trip_id_tab.EXTEND(p_extendBy);
2640 --
2641 x_matchedLineRecTbl.shipment_line_id_db_tab.EXTEND(p_extendBy);
2642 x_matchedLineRecTbl.shipment_line_id_tab.EXTEND(p_extendBy);
2643 x_matchedLineRecTbl.child_index_tab.EXTEND(p_extendBy);
2644 x_matchedLineRecTbl.shpmt_line_id_idx_tab.EXTEND(p_extendBy);
2645 --
2646 x_matchedLineRecTbl.process_corr_rtv_flag_tab.EXTEND(p_extendBy);
2647 x_matchedLineRecTbl.process_asn_rcv_flag_tab.EXTEND(p_extendBy);
2648 x_matchedLineRecTbl.match_flag_tab.EXTEND(p_extendBy);
2649 x_matchedLineRecTbl.last_update_date_tab.EXTEND(p_extendBy);
2650 x_matchedLineRecTbl.lineCount_tab.EXTEND(p_extendBy);
2651 --
2652 --
2653 --
2654 --
2655 IF l_debug_on THEN
2656 WSH_DEBUG_SV.logmsg(l_module_name,
2657 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2658 END IF;
2659 --
2660 IF l_num_errors > 0
2661 THEN
2662 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2663 ELSIF l_num_warnings > 0
2664 THEN
2665 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2666 ELSE
2667 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2668 END IF;
2669 --
2670 -- Debug Statements
2671 --
2672 IF l_debug_on THEN
2673 WSH_DEBUG_SV.pop(l_module_name);
2674 END IF;
2675 --
2676 --}
2677 EXCEPTION
2678 --{
2679 WHEN FND_API.G_EXC_ERROR THEN
2680 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2681 --
2682 -- Debug Statements
2683 --
2684 IF l_debug_on THEN
2685 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2686 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2687 END IF;
2688 --
2689 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2690 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2691 --
2692 -- Debug Statements
2693 --
2694 IF l_debug_on THEN
2695 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2696 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2697 END IF;
2698 --
2699 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2700 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2701 --
2702 -- Debug Statements
2703 --
2704 IF l_debug_on THEN
2705 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2706 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2707 END IF;
2708 --
2709 WHEN OTHERS THEN
2710 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2711 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.extendMatchedLineRecTbl');
2712 --
2713 -- Debug Statements
2714 --
2715 IF l_debug_on THEN
2716 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2717 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2718 END IF;
2719 --
2720 --}
2721 END extendMatchedLineRecTbl;
2722 --
2723 --
2724 --
2725 --========================================================================
2726 -- PROCEDURE : copyMatchedLine
2727 --
2728 -- PARAMETERS: p_sourceindex Source Line Index
2729 -- p_destinationindex Destination Index
2730 -- x_matchedLineRecTbl Table of matched delivery lines.
2731 -- x_return_status Return status of the API
2732 --
2733 --
2734 -- COMMENT : Copies a line from p_sourceindex to p_destinationindex in x_matchedLineRecTbl
2735 --
2736 --========================================================================
2737 --
2738 --
2739 PROCEDURE copyMatchedLine
2740 (
2741 p_sourceindex IN NUMBER,
2742 p_destinationindex IN NUMBER,
2743 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
2744 x_return_status OUT NOCOPY VARCHAR2
2745 )
2746 IS
2747 --{
2748 l_num_warnings NUMBER := 0;
2749 l_num_errors NUMBER := 0;
2750 l_return_status VARCHAR2(30);
2751 --
2752 l_extendBy NUMBER;
2753 --
2754 l_debug_on BOOLEAN;
2755 --
2756 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'COPYMATCHEDLINE';
2757 --
2758 --}
2759 BEGIN
2760 --{
2761 --
2762 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2763 --
2764 IF l_debug_on IS NULL
2765 THEN
2766 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2767 END IF;
2768 --
2769 --
2770 -- Debug Statements
2771 --
2772 IF l_debug_on THEN
2773 WSH_DEBUG_SV.push(l_module_name);
2774 --
2775 WSH_DEBUG_SV.log(l_module_name,'P_SOURCEINDEX',P_SOURCEINDEX);
2776 WSH_DEBUG_SV.log(l_module_name,'P_DESTINATIONINDEX',P_DESTINATIONINDEX);
2777 WSH_DEBUG_SV.log(l_module_name,'x_matchedLineRecTbl.match_flag_tab.COUNT',x_matchedLineRecTbl.match_flag_tab.COUNT);
2778 END IF;
2779 --
2780 IF NOT x_matchedLineRecTbl.match_flag_tab.EXISTS(p_destinationIndex)
2781 THEN
2782 --{
2783 l_extendBy := p_destinationIndex - x_matchedLineRecTbl.match_flag_tab.COUNT;
2784 --
2785 IF l_extendBy > 0
2786 THEN
2787 --{
2788 --
2789 -- Debug Statements
2790 --
2791 IF l_debug_on THEN
2792 WSH_DEBUG_SV.log(l_module_name,'l_extendBy',l_extendBy);
2793 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.EXTENDMATCHEDLINERECTBL',WSH_DEBUG_SV.C_PROC_LEVEL);
2794 END IF;
2795 --
2796 WSH_IB_TXN_MATCH_PKG.extendMatchedLineRecTbl
2797 (
2798 p_extendBy => l_extendBy,
2799 x_matchedLineRecTbl => x_matchedLineRecTbl,
2800 x_return_status => l_return_status
2801 );
2802 --
2803 --
2804 -- Debug Statements
2805 --
2806 IF l_debug_on THEN
2807 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2808 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2809 END IF;
2810 --
2811 wsh_util_core.api_post_call
2812 (
2813 p_return_status => l_return_status,
2814 x_num_warnings => l_num_warnings,
2815 x_num_errors => l_num_errors
2816 );
2817 --}
2818 END IF;
2819 --}
2820 END IF;
2821 --
2822 --
2823 x_matchedLineRecTbl.del_detail_id_tab(p_destinationIndex) := x_matchedLineRecTbl.del_detail_id_tab(p_sourceIndex);
2824 -- --
2825 x_matchedLineRecTbl.requested_qty_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty_tab(p_sourceIndex);
2826 x_matchedLineRecTbl.picked_qty_tab(p_destinationIndex) := x_matchedLineRecTbl.picked_qty_tab(p_sourceIndex);
2827 x_matchedLineRecTbl.shipped_qty_tab(p_destinationIndex) := x_matchedLineRecTbl.shipped_qty_tab(p_sourceIndex);
2828 x_matchedLineRecTbl.received_qty_tab(p_destinationIndex) := x_matchedLineRecTbl.received_qty_tab(p_sourceIndex);
2829 x_matchedLineRecTbl.returned_qty_tab(p_destinationIndex) := x_matchedLineRecTbl.returned_qty_tab(p_sourceIndex);
2830 -- --
2831 x_matchedLineRecTbl.requested_qty2_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty2_tab(p_sourceIndex);
2832 x_matchedLineRecTbl.picked_qty2_tab(p_destinationIndex) := x_matchedLineRecTbl.picked_qty2_tab(p_sourceIndex);
2833 x_matchedLineRecTbl.shipped_qty2_tab(p_destinationIndex) := x_matchedLineRecTbl.shipped_qty2_tab(p_sourceIndex);
2834 x_matchedLineRecTbl.received_qty2_tab(p_destinationIndex) := x_matchedLineRecTbl.received_qty2_tab(p_sourceIndex);
2835 x_matchedLineRecTbl.returned_qty2_tab(p_destinationIndex) := x_matchedLineRecTbl.returned_qty2_tab(p_sourceIndex);
2836 -- --
2837 x_matchedLineRecTbl.requested_qty_db_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty_db_tab(p_sourceIndex);
2838 x_matchedLineRecTbl.picked_qty_db_tab(p_destinationIndex) := x_matchedLineRecTbl.picked_qty_db_tab(p_sourceIndex);
2839 x_matchedLineRecTbl.shipped_qty_db_tab(p_destinationIndex) := x_matchedLineRecTbl.shipped_qty_db_tab(p_sourceIndex);
2840 x_matchedLineRecTbl.received_qty_db_tab(p_destinationIndex) := x_matchedLineRecTbl.received_qty_db_tab(p_sourceIndex);
2841 x_matchedLineRecTbl.returned_qty_db_tab(p_destinationIndex) := x_matchedLineRecTbl.returned_qty_db_tab(p_sourceIndex);
2842 -- --
2843 x_matchedLineRecTbl.requested_qty2_db_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty2_db_tab(p_sourceIndex);
2844 x_matchedLineRecTbl.picked_qty2_db_tab(p_destinationIndex) := x_matchedLineRecTbl.picked_qty2_db_tab(p_sourceIndex);
2845 x_matchedLineRecTbl.shipped_qty2_db_tab(p_destinationIndex) := x_matchedLineRecTbl.shipped_qty2_db_tab(p_sourceIndex);
2846 x_matchedLineRecTbl.received_qty2_db_tab(p_destinationIndex) := x_matchedLineRecTbl.received_qty2_db_tab(p_sourceIndex);
2847 x_matchedLineRecTbl.returned_qty2_db_tab(p_destinationIndex) := x_matchedLineRecTbl.returned_qty2_db_tab(p_sourceIndex);
2848 -- --
2849 x_matchedLineRecTbl.line_date_tab(p_destinationIndex) := x_matchedLineRecTbl.line_date_tab(p_sourceIndex);
2850 x_matchedLineRecTbl.ship_from_location_id_tab(p_destinationIndex) := x_matchedLineRecTbl.ship_from_location_id_tab(p_sourceIndex);
2851 x_matchedLineRecTbl.released_status_tab(p_destinationIndex) := x_matchedLineRecTbl.released_status_tab(p_sourceIndex);
2852 x_matchedLineRecTbl.requested_qty_uom_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty_uom_tab(p_sourceIndex);
2853 x_matchedLineRecTbl.requested_qty_uom2_tab(p_destinationIndex) := x_matchedLineRecTbl.requested_qty_uom2_tab(p_sourceIndex);
2854 -- --
2855 x_matchedLineRecTbl.po_header_id_tab(p_destinationIndex) := x_matchedLineRecTbl.po_header_id_tab(p_sourceIndex);
2856 x_matchedLineRecTbl.po_line_location_id_tab(p_destinationIndex) := x_matchedLineRecTbl.po_line_location_id_tab(p_sourceIndex);
2857 x_matchedLineRecTbl.po_line_id_tab(p_destinationIndex) := x_matchedLineRecTbl.po_line_id_tab(p_sourceIndex);
2858 x_matchedLineRecTbl.delivery_id_tab(p_destinationIndex) := x_matchedLineRecTbl.delivery_id_tab(p_sourceIndex);
2859 x_matchedLineRecTbl.trip_id_tab(p_destinationIndex) := x_matchedLineRecTbl.trip_id_tab(p_sourceIndex);
2860 -- --
2861 x_matchedLineRecTbl.shipment_line_id_db_tab(p_destinationIndex) := x_matchedLineRecTbl.shipment_line_id_db_tab(p_sourceIndex);
2862 x_matchedLineRecTbl.shipment_line_id_tab(p_destinationIndex) := x_matchedLineRecTbl.shipment_line_id_tab(p_sourceIndex);
2863 x_matchedLineRecTbl.child_index_tab(p_destinationIndex) := x_matchedLineRecTbl.child_index_tab(p_sourceIndex);
2864 x_matchedLineRecTbl.shpmt_line_id_idx_tab(p_destinationIndex) := x_matchedLineRecTbl.shpmt_line_id_idx_tab(p_sourceIndex);
2865 -- --
2866 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_destinationIndex) := x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_sourceIndex);
2867 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_destinationIndex) := x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_sourceIndex);
2868 x_matchedLineRecTbl.match_flag_tab(p_destinationIndex) := x_matchedLineRecTbl.match_flag_tab(p_sourceIndex);
2869 x_matchedLineRecTbl.last_update_date_tab(p_destinationIndex) := x_matchedLineRecTbl.last_update_date_tab(p_sourceIndex);
2870 x_matchedLineRecTbl.lineCount_tab(p_destinationIndex) := x_matchedLineRecTbl.lineCount_tab(p_sourceIndex);
2871 --
2872 --
2873 --
2874 IF l_debug_on THEN
2875 WSH_DEBUG_SV.logmsg(l_module_name,
2876 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
2877 END IF;
2878 --
2879 IF l_num_errors > 0
2880 THEN
2881 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2882 ELSIF l_num_warnings > 0
2883 THEN
2884 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2885 ELSE
2886 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2887 END IF;
2888 --
2889 --
2890 -- Debug Statements
2891 --
2892 IF l_debug_on THEN
2893 WSH_DEBUG_SV.pop(l_module_name);
2894 END IF;
2895 --
2896 --}
2897 EXCEPTION
2898 --{
2899 WHEN FND_API.G_EXC_ERROR THEN
2900 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2901 --
2902 -- Debug Statements
2903 --
2904 IF l_debug_on THEN
2905 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2906 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
2907 END IF;
2908 --
2909 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2910 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2911 --
2912 -- Debug Statements
2913 --
2914 IF l_debug_on THEN
2915 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2916 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
2917 END IF;
2918 --
2919 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
2920 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2921 --
2922 -- Debug Statements
2923 --
2924 IF l_debug_on THEN
2925 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2926 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
2927 END IF;
2928 --
2929 WHEN OTHERS THEN
2930 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
2931 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.copyMatchedLine');
2932 --
2933 -- Debug Statements
2934 --
2935 IF l_debug_on THEN
2936 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2937 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2938 END IF;
2939 --
2940 --}
2941 END copyMatchedLine;
2942
2943
2944 PROCEDURE addNewMatchedLine
2945 (
2946 p_line_rec IN OE_WSH_BULK_GRP.Line_Rec_Type,
2947 p_sourceindex IN NUMBER,
2948 p_lineDate IN DATE,
2949 p_shipFromLocationId IN NUMBER,
2950 p_primaryUomCode IN VARCHAR2,
2951 p_secondaryUomCode IN VARCHAR2,
2952 p_destinationindex IN NUMBER,
2953 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
2954 x_return_status OUT NOCOPY VARCHAR2
2955 )
2956 IS
2957 --{
2958 l_num_warnings NUMBER := 0;
2959 l_num_errors NUMBER := 0;
2960 l_return_status VARCHAR2(30);
2961 --
2962 l_extendBy NUMBER;
2963 --
2964 l_debug_on BOOLEAN;
2965 --
2966 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'ADDNEWMATCHEDLINE';
2967 --
2968 --}
2969 BEGIN
2970 --{
2971 --
2972 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2973 --
2974 IF l_debug_on IS NULL
2975 THEN
2976 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2977 END IF;
2978 --
2979 --
2980 -- Debug Statements
2981 --
2982 IF l_debug_on THEN
2983 WSH_DEBUG_SV.push(l_module_name);
2984 --
2985 WSH_DEBUG_SV.log(l_module_name,'P_SOURCEINDEX',P_SOURCEINDEX);
2986 WSH_DEBUG_SV.log(l_module_name,'P_LINEDATE',P_LINEDATE);
2987 WSH_DEBUG_SV.log(l_module_name,'P_SHIPFROMLOCATIONID',P_SHIPFROMLOCATIONID);
2988 WSH_DEBUG_SV.log(l_module_name,'P_PRIMARYUOMCODE',P_PRIMARYUOMCODE);
2989 WSH_DEBUG_SV.log(l_module_name,'P_SECONDARYUOMCODE',P_SECONDARYUOMCODE);
2990 WSH_DEBUG_SV.log(l_module_name,'P_DESTINATIONINDEX',P_DESTINATIONINDEX);
2991 WSH_DEBUG_SV.log(l_module_name,'x_matchedLineRecTbl.match_flag_tab.COUNT',x_matchedLineRecTbl.match_flag_tab.COUNT);
2992 END IF;
2993 --
2994 IF NOT x_matchedLineRecTbl.match_flag_tab.EXISTS(p_destinationIndex)
2995 THEN
2996 --{
2997 l_extendBy := p_destinationIndex - x_matchedLineRecTbl.match_flag_tab.COUNT;
2998 --
2999 IF l_extendBy > 0
3000 THEN
3001 --{
3002 --
3003 -- Debug Statements
3004 --
3005 IF l_debug_on THEN
3006 WSH_DEBUG_SV.log(l_module_name,'l_extendBy',l_extendBy);
3007 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.EXTENDMATCHEDLINERECTBL',WSH_DEBUG_SV.C_PROC_LEVEL);
3008 END IF;
3009 --
3010 WSH_IB_TXN_MATCH_PKG.extendMatchedLineRecTbl
3011 (
3012 p_extendBy => l_extendBy,
3013 x_matchedLineRecTbl => x_matchedLineRecTbl,
3014 x_return_status => l_return_status
3015 );
3016 --
3017 --
3018 -- Debug Statements
3019 --
3020 IF l_debug_on THEN
3021 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
3022 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3023 END IF;
3024 --
3025 wsh_util_core.api_post_call
3026 (
3027 p_return_status => l_return_status,
3028 x_num_warnings => l_num_warnings,
3029 x_num_errors => l_num_errors
3030 );
3031 --}
3032 END IF;
3033 --}
3034 END IF;
3035 --
3036 x_matchedLineRecTbl.del_detail_id_tab(p_destinationIndex) := NULL;
3037 --
3038 x_matchedLineRecTbl.requested_qty_tab(p_destinationIndex) := 0;
3039 x_matchedLineRecTbl.picked_qty_tab(p_destinationIndex) := NULL;
3040 x_matchedLineRecTbl.shipped_qty_tab(p_destinationIndex) := NULL;
3041 x_matchedLineRecTbl.received_qty_tab(p_destinationIndex) := NULL;
3042 x_matchedLineRecTbl.returned_qty_tab(p_destinationIndex) := NULL;
3043 --
3044 x_matchedLineRecTbl.requested_qty2_tab(p_destinationIndex) := 0;
3045 x_matchedLineRecTbl.picked_qty2_tab(p_destinationIndex) := NULL;
3046 x_matchedLineRecTbl.shipped_qty2_tab(p_destinationIndex) := NULL;
3047 x_matchedLineRecTbl.received_qty2_tab(p_destinationIndex) := NULL;
3048 x_matchedLineRecTbl.returned_qty2_tab(p_destinationIndex) := NULL;
3049 --
3050 x_matchedLineRecTbl.requested_qty_db_tab(p_destinationIndex) := 0;
3051 x_matchedLineRecTbl.picked_qty_db_tab(p_destinationIndex) := NULL;
3052 x_matchedLineRecTbl.shipped_qty_db_tab(p_destinationIndex) := NULL;
3053 x_matchedLineRecTbl.received_qty_db_tab(p_destinationIndex) := NULL;
3054 x_matchedLineRecTbl.returned_qty_db_tab(p_destinationIndex) := NULL;
3055 --
3056 x_matchedLineRecTbl.requested_qty2_db_tab(p_destinationIndex) := 0;
3057 x_matchedLineRecTbl.picked_qty2_db_tab(p_destinationIndex) := NULL;
3058 x_matchedLineRecTbl.shipped_qty2_db_tab(p_destinationIndex) := NULL;
3059 x_matchedLineRecTbl.received_qty2_db_tab(p_destinationIndex) := NULL;
3060 x_matchedLineRecTbl.returned_qty2_db_tab(p_destinationIndex) := NULL;
3061 --
3062 x_matchedLineRecTbl.line_date_tab(p_destinationIndex) := p_lineDate;
3063 x_matchedLineRecTbl.ship_from_location_id_tab(p_destinationIndex) := p_shipFromLocationId;
3064 x_matchedLineRecTbl.released_status_tab(p_destinationIndex) := 'X';
3065 x_matchedLineRecTbl.requested_qty_uom_tab(p_destinationIndex) := p_primaryUomCode;
3066 x_matchedLineRecTbl.requested_qty_uom2_tab(p_destinationIndex) := p_secondaryUomCode;
3067 --
3068 x_matchedLineRecTbl.po_header_id_tab(p_destinationIndex) := p_line_rec.header_id(p_sourceIndex);
3069 x_matchedLineRecTbl.po_line_location_id_tab(p_destinationIndex) := p_line_rec.po_shipment_line_id(p_sourceIndex);
3070 x_matchedLineRecTbl.po_line_id_tab(p_destinationIndex) := p_line_rec.line_id(p_sourceIndex);
3071 x_matchedLineRecTbl.delivery_id_tab(p_destinationIndex) := NULL;
3072 x_matchedLineRecTbl.trip_id_tab(p_destinationIndex) := NULL;
3073 --
3074 x_matchedLineRecTbl.shipment_line_id_db_tab(p_destinationIndex) := NULL;
3075 x_matchedLineRecTbl.shipment_line_id_tab(p_destinationIndex) := p_line_rec.shipment_line_id(p_sourceIndex);
3076 x_matchedLineRecTbl.child_index_tab(p_destinationIndex) := NULL;
3077 x_matchedLineRecTbl.shpmt_line_id_idx_tab(p_destinationIndex) := p_sourceIndex;
3078 --
3079 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_destinationIndex) := C_NOT_PROCESS_FLAG;
3080 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_destinationIndex) := C_NOT_PROCESS_FLAG;
3081 x_matchedLineRecTbl.match_flag_tab(p_destinationIndex) := C_POTENTIAL_MATCH_FLAG;
3082 --
3083 --
3084 --
3085 IF l_debug_on THEN
3086 WSH_DEBUG_SV.logmsg(l_module_name,
3087 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
3088 END IF;
3089 --
3090 IF l_num_errors > 0
3091 THEN
3092 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3093 ELSIF l_num_warnings > 0
3094 THEN
3095 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3096 ELSE
3097 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3098 END IF;
3099 --
3100 -- Debug Statements
3101 --
3102 IF l_debug_on THEN
3103 WSH_DEBUG_SV.pop(l_module_name);
3104 END IF;
3105 --
3106 --}
3107 EXCEPTION
3108 --{
3109 WHEN FND_API.G_EXC_ERROR THEN
3110 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3111 --
3112 -- Debug Statements
3113 --
3114 IF l_debug_on THEN
3115 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3116 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
3117 END IF;
3118 --
3119 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3120 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3121 --
3122 -- Debug Statements
3123 --
3124 IF l_debug_on THEN
3125 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3126 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
3127 END IF;
3128 --
3129 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
3130 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3131 --
3132 -- Debug Statements
3133 --
3134 IF l_debug_on THEN
3135 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3136 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
3137 END IF;
3138 --
3139 WHEN OTHERS THEN
3140 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3141 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.addNewMatchedLine');
3142 --
3143 -- Debug Statements
3144 --
3145 IF l_debug_on THEN
3146 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3147 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3148 END IF;
3149 --
3150 --}
3151 END addNewMatchedLine;
3152 --
3153 --
3154 --========================================================================
3155 -- PROCEDURE : splitLines
3156 --
3157 -- PARAMETERS: p_transactionType Transaction Type
3158 -- p_line_rec ASN/Receipt Lines
3159 -- x_return_status Return status of the API
3160 --
3161 --
3162 -- COMMENT : Split or copy delivery lines corresponding to an ASN/Receipt line.
3163 -- This is required as there can be multiple ASN/Receipt lines in a transaction
3164 -- which corresponds to same PO shipment line.
3165 --
3166 -- For each delivery line, we check process_match_flag
3167 -- If 'Y' (already processed), then we need to split the line
3168 -- i.e. add a new line with requested quantity as REQ-SHP (ASN) or REQ-RCV(RECEIPT)
3169 -- , inheriting other attributes from original line
3170 -- If 'P' (not yet processed) then, we simply copy the line.
3171 --
3172 --========================================================================
3173 --
3174 --
3175 PROCEDURE splitLines
3176 (
3177 p_txnUniqueSFLocnId IN NUMBER,
3178 p_transactionType IN VARCHAR2,
3179 p_transactionDate IN DATE,
3180 p_line_rec IN OE_WSH_BULK_GRP.Line_Rec_Type,
3181 p_line_rec_index IN NUMBER,
3182 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
3183 x_lineStartIndex IN OUT NOCOPY NUMBER,
3184 x_lineEndIndex IN OUT NOCOPY NUMBER,
3185 x_return_status OUT NOCOPY VARCHAR2
3186 )
3187 IS
3188 --{
3189
3190 --
3191 l_num_warnings NUMBER := 0;
3192 l_num_errors NUMBER := 0;
3193 l_return_status VARCHAR2(30);
3194 --
3195 l_lastRCVShipmentLineId NUMBER := NULL;
3196 l_lastDeliveryId NUMBER := NULL;
3197 l_lastDeliveryRecString VARCHAR2(500) := NULL;
3198 l_min_date DATE := NULL;
3199 l_max_date DATE := NULL;
3200 l_matchedCount NUMBER := 0;
3201 --
3202 l_start_index NUMBER;
3203 l_end_index NUMBER;
3204 l_index NUMBER;
3205 l_RCVLineIndex NUMBER;
3206 l_lineIndex NUMBER;
3207 l_lineEndIndex NUMBER;
3208 --
3209 l_currentRCVShipmentLineId NUMBER;
3210 l_deliveryId NUMBER;
3211 l_DeliveryRecString VARCHAR2(500);
3212 l_transactionDate DATE;
3213 l_lineDate DATE;
3214 l_shipFromLocationId NUMBER;
3215 l_carrierId NUMBER;
3216 l_transactionCarrierId NUMBER;
3217 l_quantity NUMBER;
3218 l_quantity2 NUMBER;
3219 l_parentDeliveryDetailId NUMBER;
3220 --
3221 l_matchFlag VARCHAR2(10);
3222 --
3223 l_debug_on BOOLEAN;
3224 --
3225 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'SPLITLINES';
3226 --
3227 --}
3228 BEGIN
3229 --{
3230 --
3231 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3232 --
3233 IF l_debug_on IS NULL
3234 THEN
3235 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3236 END IF;
3237 --
3238 --
3239 -- Debug Statements
3240 --
3241 IF l_debug_on THEN
3242 WSH_DEBUG_SV.push(l_module_name);
3243 --
3244 WSH_DEBUG_SV.log(l_module_name,'P_TXNUNIQUESFLOCNID',P_TXNUNIQUESFLOCNID);
3245 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
3246 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONDATE',P_TRANSACTIONDATE);
3247 WSH_DEBUG_SV.log(l_module_name,'P_LINE_REC_INDEX',P_LINE_REC_INDEX);
3248 WSH_DEBUG_SV.log(l_module_name,'X_LINESTARTINDEX',X_LINESTARTINDEX);
3249 WSH_DEBUG_SV.log(l_module_name,'X_LINEENDINDEX',X_LINEENDINDEX);
3250 END IF;
3251 --
3252 l_lineIndex := x_lineStartIndex;
3253 l_lineEndIndex := x_lineEndIndex;
3254 --
3255 x_lineStartIndex := NULL;
3256 x_lineEndIndex := x_matchedLineRecTbl.match_flag_tab.COUNT;
3257 --
3258 --
3259 IF l_debug_on THEN
3260 WSH_DEBUG_SV.log(l_module_name,'l_lineIndex',l_lineIndex);
3261 WSH_DEBUG_SV.log(l_module_name,'l_lineEndIndex',l_lineEndIndex);
3262 WSH_DEBUG_SV.log(l_module_name,'x_lineStartIndex',x_lineStartIndex);
3263 WSH_DEBUG_SV.log(l_module_name,'x_lineEndIndex',x_lineEndIndex);
3264 END IF;
3265 --
3266 --
3267 WHILE l_lineIndex IS NOT NULL
3268 AND l_lineIndex <= l_lineEndIndex
3269 LOOP
3270 --{
3271 --
3272 IF l_debug_on THEN
3273 WSH_DEBUG_SV.log(l_module_name,'Processing record at l_lineIndex',l_lineIndex);
3274 END IF;
3275 --
3276 l_matchFlag := x_matchedLineRecTbl.match_flag_tab(l_lineIndex);
3277 --
3278 --
3279 IF l_debug_on THEN
3280 WSH_DEBUG_SV.log(l_module_name,'l_matchFlag',l_matchFlag);
3281 END IF;
3282 --
3283 IF l_matchFlag = C_PROCESS_FLAG
3284 THEN
3285 --{
3286 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
3287 THEN
3288 --{
3289 l_quantity := GREATEST
3290 (
3291 (
3292 NVL(x_matchedLineRecTbl.requested_qty_tab(l_lineIndex),0)
3293 - NVL(x_matchedLineRecTbl.shipped_qty_tab(l_lineIndex),0)
3294 ),
3295 0
3296 );
3297 --
3298 l_quantity2 := GREATEST
3299 (
3300 (
3301 NVL(x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex),0)
3302 - NVL(x_matchedLineRecTbl.shipped_qty2_tab(l_lineIndex),0)
3303 ),
3304 0
3305 );
3306 --}
3307 ELSE
3308 --{
3309 l_quantity := GREATEST
3310 (
3311 (
3312 NVL(x_matchedLineRecTbl.requested_qty_tab(l_lineIndex),0)
3313 - NVL(x_matchedLineRecTbl.received_qty_tab(l_lineIndex),0)
3314 ),
3315 0
3316 );
3317 --
3318 l_quantity2 := GREATEST
3319 (
3320 (
3321 NVL(x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex),0)
3322 - NVL(x_matchedLineRecTbl.received_qty2_tab(l_lineIndex),0)
3323 ),
3324 0
3325 );
3326 --}
3327 END IF;
3328 --
3329 IF x_matchedLineRecTbl.parent_delivery_detail_id_tab(l_lineIndex) IS NULL
3330 THEN
3331 l_parentDeliveryDetailId := x_matchedLineRecTbl.del_detail_id_tab(l_lineIndex);
3332 ELSE
3333 l_parentDeliveryDetailId := x_matchedLineRecTbl.parent_delivery_detail_id_tab(l_lineIndex);
3334 END IF;
3335 --
3336 IF l_debug_on THEN
3337 WSH_DEBUG_SV.log(l_module_name,'x_matchedLineRecTbl.parent_delivery_detail_id_tab(l_lineIndex)',x_matchedLineRecTbl.parent_delivery_detail_id_tab(l_lineIndex));
3338 WSH_DEBUG_SV.log(l_module_name,'x_matchedLineRecTbl.del_detail_id_tab(l_lineIndex)',x_matchedLineRecTbl.del_detail_id_tab(l_lineIndex));
3339 WSH_DEBUG_SV.log(l_module_name,'l_parentDeliveryDetailId',l_parentDeliveryDetailId);
3340 WSH_DEBUG_SV.log(l_module_name,'l_quantity',l_quantity);
3341 WSH_DEBUG_SV.log(l_module_name,'l_quantity2',l_quantity2);
3342 END IF;
3343 --
3344 --
3345 IF l_quantity > 0
3346 OR l_quantity2 > 0
3347 THEN
3348 --{
3349 x_lineEndIndex := x_lineEndIndex + 1;
3350 x_lineStartIndex := NVL(x_lineStartIndex,x_lineEndIndex);
3351 --
3352 --
3353 -- Debug Statements
3354 --
3355 IF l_debug_on THEN
3356 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.ADDNEWMATCHEDLINE',WSH_DEBUG_SV.C_PROC_LEVEL);
3357 END IF;
3358 --
3359 WSH_IB_TXN_MATCH_PKG.addNewMatchedLine
3360 (
3361 p_line_rec => p_line_rec,
3362 p_sourceindex => p_line_rec_index,
3363 p_lineDate => x_matchedLineRecTbl.line_date_tab(l_lineIndex),
3364 p_shipFromLocationId => x_matchedLineRecTbl.ship_from_location_id_tab(l_lineIndex),
3365 p_primaryUomCode => x_matchedLineRecTbl.requested_qty_uom_tab(l_lineIndex),
3366 p_secondaryUomCode => x_matchedLineRecTbl.requested_qty_uom2_tab(l_lineIndex),
3367 p_destinationindex => x_lineEndIndex,
3368 x_matchedLineRecTbl => x_matchedLineRecTbl,
3369 x_return_status => l_return_status
3370 );
3371 --
3372 --
3373 --
3374 -- Debug Statements
3375 --
3376 IF l_debug_on THEN
3377 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
3378 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3379 END IF;
3380 --
3381 wsh_util_core.api_post_call
3382 (
3383 p_return_status => l_return_status,
3384 x_num_warnings => l_num_warnings,
3385 x_num_errors => l_num_errors
3386 );
3387 --
3388 --
3389 --
3390 IF l_debug_on THEN
3391 WSH_DEBUG_SV.log(l_module_name,'Before Split-requested_qty_tab',x_matchedLineRecTbl.requested_qty_tab(l_lineIndex));
3392 WSH_DEBUG_SV.log(l_module_name,'Before Split-requested_qty2_tab',x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex) );
3393 END IF;
3394 --
3395 x_matchedLineRecTbl.requested_qty_tab(l_lineIndex)
3396 := NVL(x_matchedLineRecTbl.requested_qty_tab(l_lineIndex),0)
3397 - l_quantity;
3398 --
3399 x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex)
3400 := NVL(x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex),0)
3401 - l_quantity2;
3402 --
3403 --
3404 x_matchedLineRecTbl.child_index_tab(l_lineIndex) := x_lineEndIndex;
3405 --
3406 x_matchedLineRecTbl.requested_qty_tab(x_lineEndIndex) := l_quantity;
3407 --
3408 x_matchedLineRecTbl.requested_qty2_tab(x_lineEndIndex) := l_quantity2;
3409 x_matchedLineRecTbl.delivery_id_tab(x_lineEndIndex) := x_matchedLineRecTbl.delivery_id_tab(l_lineIndex);
3410 x_matchedLineRecTbl.parent_delivery_detail_id_tab(x_lineEndIndex) := l_parentDeliveryDetailId ;
3411 --
3412 --
3413 IF l_debug_on THEN
3414 WSH_DEBUG_SV.log(l_module_name,'After Split-requested_qty_tab',x_matchedLineRecTbl.requested_qty_tab(l_lineIndex));
3415 WSH_DEBUG_SV.log(l_module_name,'After Split-requested_qty2_tab',x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex) );
3416 WSH_DEBUG_SV.log(l_module_name,'child_index',x_matchedLineRecTbl.child_index_tab(l_lineIndex));
3417 WSH_DEBUG_SV.log(l_module_name,'New Line-requested_qty_tab',x_matchedLineRecTbl.requested_qty_tab(x_lineEndIndex));
3418 WSH_DEBUG_SV.log(l_module_name,'New Line-requested_qty2_tab',x_matchedLineRecTbl.requested_qty2_tab(x_lineEndIndex));
3419 WSH_DEBUG_SV.log(l_module_name,'New Line-delivery_id_tab',x_matchedLineRecTbl.delivery_id_tab(x_lineEndIndex));
3420 WSH_DEBUG_SV.log(l_module_name,'New Line-parent wdd id tab',x_matchedLineRecTbl.parent_delivery_detail_id_tab(x_lineEndIndex));
3421 END IF;
3422 --
3423 --}
3424 END IF;
3425 --}
3426 ELSIF l_matchFlag = C_POTENTIAL_MATCH_FLAG
3427 THEN
3428 --{
3429 x_lineEndIndex := x_lineEndIndex + 1;
3430 x_lineStartIndex := NVL(x_lineStartIndex,x_lineEndIndex);
3431 --
3432 --
3433 -- Debug Statements
3434 --
3435 IF l_debug_on THEN
3436 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.COPYMATCHEDLINE',WSH_DEBUG_SV.C_PROC_LEVEL);
3437 END IF;
3438 --
3439 WSH_IB_TXN_MATCH_PKG.copyMatchedLine
3440 (
3441 x_matchedLineRecTbl => x_matchedLineRecTbl,
3442 p_sourceIndex => l_lineIndex,
3443 p_destinationIndex => x_lineEndIndex,
3444 x_return_status => l_return_status
3445 );
3446 --
3447 --
3448 --
3449 -- Debug Statements
3450 --
3451 IF l_debug_on THEN
3452 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
3453 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3454 END IF;
3455 --
3456 wsh_util_core.api_post_call
3457 (
3458 p_return_status => l_return_status,
3459 x_num_warnings => l_num_warnings,
3460 x_num_errors => l_num_errors
3461 );
3462
3463 --}
3464 END IF;
3465 --
3466 l_lineIndex := x_matchedLineRecTbl.match_flag_tab.NEXT(l_lineIndex);
3467 --}
3468 END LOOP;
3469 --
3470 --
3471 IF l_debug_on THEN
3472 WSH_DEBUG_SV.log(l_module_name,'x_lineStartIndex',x_lineStartIndex);
3473 WSH_DEBUG_SV.log(l_module_name,'x_lineEndIndex',x_lineEndIndex);
3474 END IF;
3475 --
3476 --
3477 IF x_lineStartIndex IS NULL
3478 THEN
3479 --{
3480 x_lineEndIndex := x_lineEndIndex + 1;
3481 x_lineStartIndex := NVL(x_lineStartIndex,x_lineEndIndex);
3482 --
3483 --
3484 -- Debug Statements
3485 --
3486 IF l_debug_on THEN
3487 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.ADDNEWMATCHEDLINE',WSH_DEBUG_SV.C_PROC_LEVEL);
3488 END IF;
3489 --
3490 WSH_IB_TXN_MATCH_PKG.addNewMatchedLine
3491 (
3492 p_line_rec => p_line_rec,
3493 p_sourceindex => p_line_rec_index,
3494 p_lineDate => p_transactionDate,
3495 p_shipFromLocationId => NVL(p_txnUniqueSFLocnId,x_matchedLineRecTbl.ship_from_location_id_tab(l_lineEndIndex)),
3496 p_primaryUomCode => x_matchedLineRecTbl.requested_qty_uom_tab(l_lineEndIndex),
3497 p_secondaryUomCode => x_matchedLineRecTbl.requested_qty_uom2_tab(l_lineIndex),
3498 p_destinationindex => x_lineEndIndex,
3499 x_matchedLineRecTbl => x_matchedLineRecTbl,
3500 x_return_status => l_return_status
3501 );
3502 --
3503 --
3504 --
3505 -- Debug Statements
3506 --
3507 IF l_debug_on THEN
3508 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
3509 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3510 END IF;
3511 --
3512 wsh_util_core.api_post_call
3513 (
3514 p_return_status => l_return_status,
3515 x_num_warnings => l_num_warnings,
3516 x_num_errors => l_num_errors
3517 );
3518 --}
3519 END IF;
3520 --
3521 --
3522 --
3523 --
3524 IF l_debug_on THEN
3525 WSH_DEBUG_SV.logmsg(l_module_name,
3526 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
3527 END IF;
3528 --
3529 IF l_num_errors > 0
3530 THEN
3531 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3532 ELSIF l_num_warnings > 0
3533 THEN
3534 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3535 ELSE
3536 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3537 END IF;
3538 --
3539 -- Debug Statements
3540 --
3541 IF l_debug_on THEN
3542 WSH_DEBUG_SV.pop(l_module_name);
3543 END IF;
3544 --
3545 --}
3546 EXCEPTION
3547 --{
3548 WHEN FND_API.G_EXC_ERROR THEN
3549 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3550 --
3551 -- Debug Statements
3552 --
3553 IF l_debug_on THEN
3554 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3555 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
3556 END IF;
3557 --
3558 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3559 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3560 --
3561 -- Debug Statements
3562 --
3563 IF l_debug_on THEN
3564 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3565 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
3566 END IF;
3567 --
3568 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
3569 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3570 --
3571 -- Debug Statements
3572 --
3573 IF l_debug_on THEN
3574 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3575 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
3576 END IF;
3577 --
3578 WHEN OTHERS THEN
3579 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3580 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.splitLines');
3581 --
3582 -- Debug Statements
3583 --
3584 IF l_debug_on THEN
3585 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3586 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3587 END IF;
3588 --
3589 --}
3590 END splitLines;
3591
3592 PROCEDURE applyDelta
3593 (
3594 p_transactionType IN VARCHAR2,
3595 p_ReceiptAgainstASN IN VARCHAR2,
3596 p_quantity IN NUMBER,
3597 p_quantity2 IN NUMBER,
3598 p_index IN NUMBER,
3599 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
3600 x_return_status OUT NOCOPY VARCHAR2
3601 )
3602 IS
3603 --{
3604 l_num_warnings NUMBER := 0;
3605 l_num_errors NUMBER := 0;
3606 l_return_status VARCHAR2(30);
3607 --
3608 l_debug_on BOOLEAN;
3609 --
3610 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'applyDelta';
3611 --
3612 --}
3613 BEGIN
3614 --{
3615
3616 --
3617 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3618 --
3619 IF l_debug_on IS NULL
3620 THEN
3621 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3622 END IF;
3623 --
3624 --
3625 -- Debug Statements
3626 --
3627 IF l_debug_on THEN
3628 WSH_DEBUG_SV.push(l_module_name);
3629 --
3630 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
3631 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
3632 WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY',P_QUANTITY);
3633 WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY2',P_QUANTITY2);
3634 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
3635 --
3636 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
3637 x_matchedLineRecTbl.requested_qty_tab(p_index)
3638 || '|'
3639 || x_matchedLineRecTbl.picked_qty_tab(p_index)
3640 || '|'
3641 || x_matchedLineRecTbl.shipped_qty_tab(p_index)
3642 || '|'
3643 || x_matchedLineRecTbl.received_qty_tab(p_index)
3644 || '|'
3645 || x_matchedLineRecTbl.returned_qty_tab(p_index)
3646 );
3647 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
3648 x_matchedLineRecTbl.requested_qty2_tab(p_index)
3649 || '|'
3650 || x_matchedLineRecTbl.picked_qty2_tab(p_index)
3651 || '|'
3652 || x_matchedLineRecTbl.shipped_qty2_tab(p_index)
3653 || '|'
3654 || x_matchedLineRecTbl.received_qty2_tab(p_index)
3655 || '|'
3656 || x_matchedLineRecTbl.returned_qty2_tab(p_index)
3657 );
3658 WSH_DEBUG_SV.log(l_module_name,'Match Flag',x_matchedLineRecTbl.match_flag_tab(p_index) );
3659 WSH_DEBUG_SV.log(l_module_name,'Process ASN/RCV Flag',x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) );
3660 WSH_DEBUG_SV.log(l_module_name,'Process Corr/RTV Flag',x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) );
3661 END IF;
3662 --
3663 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
3664 THEN
3665 x_matchedLineRecTbl.shipped_qty_tab(p_index)
3666 :=
3667 NVL(x_matchedLineRecTbl.shipped_qty_tab(p_index),0) + NVL(p_quantity,0);
3668 --
3669 x_matchedLineRecTbl.shipped_qty2_tab(p_index)
3670 :=
3671 NVL(x_matchedLineRecTbl.shipped_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3672 --
3673 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3674 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3675 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
3676 THEN
3677 x_matchedLineRecTbl.received_qty_tab(p_index)
3678 :=
3679 NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) + NVL(p_quantity,0);
3680 --
3681 x_matchedLineRecTbl.received_qty2_tab(p_index)
3682 :=
3683 NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3684 --
3685 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3686 --
3687 IF p_ReceiptAgainstASN <> 'Y'
3688 THEN
3689 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3690 END IF;
3691 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
3692 THEN
3693 x_matchedLineRecTbl.received_qty_tab(p_index)
3694 :=
3695 NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) + NVL(p_quantity,0);
3696 --
3697 x_matchedLineRecTbl.received_qty2_tab(p_index)
3698 :=
3699 NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3700 --
3701 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3702 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3703 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
3704 THEN
3705 x_matchedLineRecTbl.received_qty_tab(p_index)
3706 := NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) + NVL(p_quantity,0);
3707 --
3708 x_matchedLineRecTbl.received_qty2_tab(p_index)
3709 := NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3710 --
3711 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3712 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
3713 THEN
3714 x_matchedLineRecTbl.received_qty_tab(p_index)
3715 := GREATEST(
3716 NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) - NVL(p_quantity,0)
3717 ,0
3718 );
3719 --
3720 x_matchedLineRecTbl.received_qty2_tab(p_index)
3721 := GREATEST(
3722 NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) - NVL(p_quantity2,0)
3723 ,0
3724 );
3725 --
3726 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3727 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV
3728 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
3729 THEN
3730 x_matchedLineRecTbl.returned_qty_tab(p_index)
3731 := NVL(x_matchedLineRecTbl.returned_qty_tab(p_index),0) + NVL(p_quantity,0);
3732 --
3733 x_matchedLineRecTbl.returned_qty2_tab(p_index)
3734 := NVL(x_matchedLineRecTbl.returned_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3735 --
3736 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3737 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
3738 THEN
3739 x_matchedLineRecTbl.returned_qty_tab(p_index)
3740 := GREATEST(
3741 NVL(x_matchedLineRecTbl.returned_qty_tab(p_index),0) - NVL(p_quantity,0)
3742 ,0
3743 );
3744 --
3745 x_matchedLineRecTbl.returned_qty2_tab(p_index)
3746 := GREATEST(
3747 NVL(x_matchedLineRecTbl.returned_qty2_tab(p_index),0) - NVL(p_quantity2,0)
3748 ,0
3749 );
3750 --
3751 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3752 END IF;
3753 --
3754 --
3755 --
3756 IF l_debug_on THEN
3757 WSH_DEBUG_SV.logmsg(l_module_name,'Result of Apply Qty');
3758 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
3759 x_matchedLineRecTbl.requested_qty_tab(p_index)
3760 || '|'
3761 || x_matchedLineRecTbl.picked_qty_tab(p_index)
3762 || '|'
3763 || x_matchedLineRecTbl.shipped_qty_tab(p_index)
3764 || '|'
3765 || x_matchedLineRecTbl.received_qty_tab(p_index)
3766 || '|'
3767 || x_matchedLineRecTbl.returned_qty_tab(p_index)
3768 );
3769 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
3770 x_matchedLineRecTbl.requested_qty2_tab(p_index)
3771 || '|'
3772 || x_matchedLineRecTbl.picked_qty2_tab(p_index)
3773 || '|'
3774 || x_matchedLineRecTbl.shipped_qty2_tab(p_index)
3775 || '|'
3776 || x_matchedLineRecTbl.received_qty2_tab(p_index)
3777 || '|'
3778 || x_matchedLineRecTbl.returned_qty2_tab(p_index)
3779 );
3780 WSH_DEBUG_SV.log(l_module_name,'Process ASN/RCV Flag',x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) );
3781 WSH_DEBUG_SV.log(l_module_name,'Process Corr/RTV Flag',x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) );
3782 END IF;
3783 --
3784 --
3785 IF l_debug_on THEN
3786 WSH_DEBUG_SV.logmsg(l_module_name,
3787 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
3788 END IF;
3789 --
3790 IF l_num_errors > 0
3791 THEN
3792 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3793 ELSIF l_num_warnings > 0
3794 THEN
3795 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3796 ELSE
3797 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3798 END IF;
3799 --
3800 --
3801 -- Debug Statements
3802 --
3803 IF l_debug_on THEN
3804 WSH_DEBUG_SV.pop(l_module_name);
3805 END IF;
3806 --
3807 --}
3808 EXCEPTION
3809 --{
3810 WHEN FND_API.G_EXC_ERROR THEN
3811 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3812 --
3813 -- Debug Statements
3814 --
3815 IF l_debug_on THEN
3816 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3817 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
3818 END IF;
3819 --
3820 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3821 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3822 --
3823 -- Debug Statements
3824 --
3825 IF l_debug_on THEN
3826 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3827 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
3828 END IF;
3829 --
3830 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
3831 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3832 --
3833 -- Debug Statements
3834 --
3835 IF l_debug_on THEN
3836 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3837 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
3838 END IF;
3839 --
3840 WHEN OTHERS THEN
3841 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3842 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.applyDelta');
3843 --
3844 -- Debug Statements
3845 --
3846 IF l_debug_on THEN
3847 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3848 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3849 END IF;
3850 --
3851 --}
3852 END applyDelta;
3853
3854 PROCEDURE applyQuantity
3855 (
3856 p_transactionType IN VARCHAR2,
3857 p_ReceiptAgainstASN IN VARCHAR2,
3858 p_quantity IN NUMBER,
3859 p_quantity2 IN NUMBER,
3860 p_index IN NUMBER,
3861 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
3862 x_return_status OUT NOCOPY VARCHAR2
3863 )
3864 IS
3865 --{
3866 l_num_warnings NUMBER := 0;
3867 l_num_errors NUMBER := 0;
3868 l_return_status VARCHAR2(30);
3869 --
3870 l_debug_on BOOLEAN;
3871 --
3872 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'APPLYQUANTITY';
3873 --
3874 --}
3875 BEGIN
3876 --{
3877
3878 --
3879 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3880 --
3881 IF l_debug_on IS NULL
3882 THEN
3883 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3884 END IF;
3885 --
3886 --
3887 -- Debug Statements
3888 --
3889 IF l_debug_on THEN
3890 WSH_DEBUG_SV.push(l_module_name);
3891 --
3892 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
3893 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
3894 WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY',P_QUANTITY);
3895 WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY2',P_QUANTITY2);
3896 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
3897 --
3898 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
3899 x_matchedLineRecTbl.requested_qty_tab(p_index)
3900 || '|'
3901 || x_matchedLineRecTbl.picked_qty_tab(p_index)
3902 || '|'
3903 || x_matchedLineRecTbl.shipped_qty_tab(p_index)
3904 || '|'
3905 || x_matchedLineRecTbl.received_qty_tab(p_index)
3906 || '|'
3907 || x_matchedLineRecTbl.returned_qty_tab(p_index)
3908 );
3909 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
3910 x_matchedLineRecTbl.requested_qty2_tab(p_index)
3911 || '|'
3912 || x_matchedLineRecTbl.picked_qty2_tab(p_index)
3913 || '|'
3914 || x_matchedLineRecTbl.shipped_qty2_tab(p_index)
3915 || '|'
3916 || x_matchedLineRecTbl.received_qty2_tab(p_index)
3917 || '|'
3918 || x_matchedLineRecTbl.returned_qty2_tab(p_index)
3919 );
3920 WSH_DEBUG_SV.log(l_module_name,'Match Flag',x_matchedLineRecTbl.match_flag_tab(p_index) );
3921 WSH_DEBUG_SV.log(l_module_name,'Process ASN/RCV Flag',x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) );
3922 WSH_DEBUG_SV.log(l_module_name,'Process Corr/RTV Flag',x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) );
3923 END IF;
3924 --
3925 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
3926 THEN
3927 x_matchedLineRecTbl.shipped_qty_tab(p_index) := p_quantity;
3928 x_matchedLineRecTbl.shipped_qty2_tab(p_index) := p_quantity2;
3929 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3930 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3931 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
3932 THEN
3933 x_matchedLineRecTbl.received_qty_tab(p_index) := p_quantity;
3934 x_matchedLineRecTbl.received_qty2_tab(p_index) := p_quantity2;
3935 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3936 --
3937 IF p_ReceiptAgainstASN <> 'Y'
3938 THEN
3939 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3940 END IF;
3941 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
3942 THEN
3943 x_matchedLineRecTbl.received_qty_tab(p_index) := p_quantity;
3944 x_matchedLineRecTbl.received_qty2_tab(p_index) := p_quantity2;
3945 x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) := C_PROCESS_FLAG;
3946 x_matchedLineRecTbl.match_flag_tab(p_index) := C_PROCESS_FLAG;
3947 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
3948 THEN
3949 x_matchedLineRecTbl.received_qty_tab(p_index)
3950 := NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) + NVL(p_quantity,0);
3951 --
3952 x_matchedLineRecTbl.received_qty2_tab(p_index)
3953 := NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3954 --
3955 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3956 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
3957 THEN
3958 x_matchedLineRecTbl.received_qty_tab(p_index)
3959 := GREATEST(
3960 NVL(x_matchedLineRecTbl.received_qty_tab(p_index),0) - NVL(p_quantity,0)
3961 ,0
3962 );
3963 --
3964 x_matchedLineRecTbl.received_qty2_tab(p_index)
3965 := GREATEST(
3966 NVL(x_matchedLineRecTbl.received_qty2_tab(p_index),0) - NVL(p_quantity2,0)
3967 ,0
3968 );
3969 --
3970 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3971 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV
3972 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
3973 THEN
3974 x_matchedLineRecTbl.returned_qty_tab(p_index)
3975 := NVL(x_matchedLineRecTbl.returned_qty_tab(p_index),0) + NVL(p_quantity,0);
3976 --
3977 x_matchedLineRecTbl.returned_qty2_tab(p_index)
3978 := NVL(x_matchedLineRecTbl.returned_qty2_tab(p_index),0) + NVL(p_quantity2,0);
3979 --
3980 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3981 ELSIF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
3982 THEN
3983 x_matchedLineRecTbl.returned_qty_tab(p_index)
3984 := GREATEST(
3985 NVL(x_matchedLineRecTbl.returned_qty_tab(p_index),0) - NVL(p_quantity,0)
3986 ,0
3987 );
3988 --
3989 x_matchedLineRecTbl.returned_qty2_tab(p_index)
3990 := GREATEST(
3991 NVL(x_matchedLineRecTbl.returned_qty2_tab(p_index),0) - NVL(p_quantity2,0)
3992 ,0
3993 );
3994 --
3995 x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) := C_PROCESS_FLAG;
3996 END IF;
3997 --
3998 --
3999 --
4000 IF l_debug_on THEN
4001 WSH_DEBUG_SV.logmsg(l_module_name,'Result of Apply Qty');
4002 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
4003 x_matchedLineRecTbl.requested_qty_tab(p_index)
4004 || '|'
4005 || x_matchedLineRecTbl.picked_qty_tab(p_index)
4006 || '|'
4007 || x_matchedLineRecTbl.shipped_qty_tab(p_index)
4008 || '|'
4009 || x_matchedLineRecTbl.received_qty_tab(p_index)
4010 || '|'
4011 || x_matchedLineRecTbl.returned_qty_tab(p_index)
4012 );
4013 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
4014 x_matchedLineRecTbl.requested_qty2_tab(p_index)
4015 || '|'
4016 || x_matchedLineRecTbl.picked_qty2_tab(p_index)
4017 || '|'
4018 || x_matchedLineRecTbl.shipped_qty2_tab(p_index)
4019 || '|'
4020 || x_matchedLineRecTbl.received_qty2_tab(p_index)
4021 || '|'
4022 || x_matchedLineRecTbl.returned_qty2_tab(p_index)
4023 );
4024 WSH_DEBUG_SV.log(l_module_name,'Process ASN/RCV Flag',x_matchedLineRecTbl.process_asn_rcv_flag_tab(p_index) );
4025 WSH_DEBUG_SV.log(l_module_name,'Process Corr/RTV Flag',x_matchedLineRecTbl.process_corr_rtv_flag_tab(p_index) );
4026 END IF;
4027 --
4028 --
4029 IF l_debug_on THEN
4030 WSH_DEBUG_SV.logmsg(l_module_name,
4031 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
4032 END IF;
4033 --
4034 IF l_num_errors > 0
4035 THEN
4036 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4037 ELSIF l_num_warnings > 0
4038 THEN
4039 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4040 ELSE
4041 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4042 END IF;
4043 --
4044 --
4045 -- Debug Statements
4046 --
4047 IF l_debug_on THEN
4048 WSH_DEBUG_SV.pop(l_module_name);
4049 END IF;
4050 --
4051 --}
4052 EXCEPTION
4053 --{
4054 WHEN FND_API.G_EXC_ERROR THEN
4055 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4056 --
4057 -- Debug Statements
4058 --
4059 IF l_debug_on THEN
4060 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4061 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
4062 END IF;
4063 --
4064 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4065 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
4066 --
4067 -- Debug Statements
4068 --
4069 IF l_debug_on THEN
4070 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4071 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
4072 END IF;
4073 --
4074 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
4075 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4076 --
4077 -- Debug Statements
4078 --
4079 IF l_debug_on THEN
4080 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4081 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
4082 END IF;
4083 --
4084 WHEN OTHERS THEN
4085 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
4086 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.applyQuantity');
4087 --
4088 -- Debug Statements
4089 --
4090 IF l_debug_on THEN
4091 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4092 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4093 END IF;
4094 --
4095 --}
4096 END applyQuantity;
4097 --
4098 --
4099 --========================================================================
4100 -- PROCEDURE : matchQuantity
4101 --
4102 -- PARAMETERS: p_transactionType Transaction Type
4103 -- p_line_rec ASN/Receipt Lines
4104 -- x_return_status Return status of the API
4105 --
4106 --
4107 -- COMMENT : This prcedure loops through all input ASN/Receipt lines
4108 -- For each line,
4109 -- - Check linkTable(x_linktbl) to get the status
4110 -- - If marked as error, skip the input line
4111 -- - If marked as processed, split the delivery lines
4112 -- - If marked as not processed, navigate to matching delivery line
4113 -- record in x_matchedLineRecTbl, using start and end indices obtained
4114 -- from linkTable.
4115 -- - Apply input line quantity to delivery line
4116 -- In general, quantity to be applied to delivery line is calculated as:
4117 -- - LEAST(input line qty, NVL(RCV,SHP,PICK,REQ)-RTV )
4118 -- except for Positive Receipt correction and Negative RTV correction
4119 -- - For positive receipt correction,entire input quantity is applied
4120 -- to first matched line.
4121 -- - For Negative RTV correction,calculation is:
4122 -- - LEAST(input line qty, RTV )
4123 -- - While applying, input line against delivery lines, we process in the
4124 -- increasing orders of line date (in x_matchedLineRecTbl).
4125 -- - We first apply quantity onto lines with p_min_date, then
4126 -- with next higher date and so on until lines with p_max_date.
4127 --========================================================================
4128 --
4129 --
4130 PROCEDURE matchQuantity
4131 (
4132 p_line_rec IN OE_WSH_BULK_GRP.Line_Rec_Type,
4133 p_transactionType IN VARCHAR2,
4134 p_transactionMeaning IN VARCHAR2,
4135 p_ReceiptAgainstASN IN VARCHAR2,
4136 p_transactionDate IN DATE,
4137 p_txnUniqueSFLocnId IN NUMBER,
4138 p_start_index IN NUMBER,
4139 p_end_index IN NUMBER,
4140 p_min_date IN DATE,
4141 p_max_date IN DATE,
4142 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
4143 x_linktbl IN OUT NOCOPY WSH_UTIL_CORE.char500_tab_type,
4144 x_linkExttbl IN OUT NOCOPY WSH_UTIL_CORE.char500_tab_type,
4145 x_return_status OUT NOCOPY VARCHAR2
4146 )
4147 IS
4148 --{
4149 l_num_warnings NUMBER := 0;
4150 l_num_errors NUMBER := 0;
4151 l_return_status VARCHAR2(30);
4152 --
4153 l_lastRCVShipmentLineId NUMBER := NULL;
4154 l_lastDeliveryId NUMBER := NULL;
4155 l_lastDeliveryRecString VARCHAR2(500) := NULL;
4156 l_min_date DATE := NULL;
4157 l_max_date DATE := NULL;
4158 l_matchedCount NUMBER := 0;
4159 l_transactionSubType VARCHAR2(50);
4160 --
4161 l_start_index NUMBER;
4162 l_end_index NUMBER;
4163 l_index NUMBER;
4164 l_RCVLineIndex NUMBER;
4165 l_position1 NUMBER;
4166 l_position2 NUMBER;
4167 l_lineIndex NUMBER;
4168 l_lineStartIndex NUMBER;
4169 l_lineEndIndex NUMBER;
4170 l_lastMatchedLineIndex NUMBER;
4171 --
4172 l_currentRCVShipmentLineId NUMBER;
4173 l_deliveryId NUMBER;
4174 l_DeliveryRecString VARCHAR2(500);
4175 l_transactionDate DATE;
4176 l_lineDate DATE;
4177 l_Date DATE;
4178 l_nextDate DATE;
4179 l_shipFromLocationId NUMBER;
4180 l_carrierId NUMBER;
4181 l_transactionCarrierId NUMBER;
4182 l_key NUMBER;
4183 l_linkRecString VARCHAR2(500) := NULL;
4184 --
4185 --
4186 l_totalTxnLineQty NUMBER;
4187 l_totalTxnLineQty2 NUMBER;
4188 l_remainingQty NUMBER;
4189 l_remainingQty2 NUMBER;
4190 l_lineQty NUMBER;
4191 l_lineQty2 NUMBER;
4192 l_leftOverQuantity2 NUMBER;
4193 --
4194 --
4195 l_poHeaderNumber VARCHAR2(150);
4196 l_poLineNumber VARCHAR2(150);
4197 l_poShipmentLineNumber NUMBER;
4198 l_poReleaseNumber NUMBER;
4199 l_shipmentNumber VARCHAR2(150);
4200 l_receiptNumber VARCHAR2(150);
4201 --
4202 e_continue EXCEPTION;
4203 --
4204 l_debug_on BOOLEAN;
4205 --
4206 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'MATCHQUANTITY';
4207 --
4208 --}
4209 BEGIN
4210 --{
4211 --
4212 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4213 --
4214 IF l_debug_on IS NULL
4215 THEN
4216 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4217 END IF;
4218 --
4219 --
4220 -- Debug Statements
4221 --
4222 IF l_debug_on THEN
4223 WSH_DEBUG_SV.push(l_module_name);
4224 --
4225 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
4226 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONMEANING',P_TRANSACTIONMEANING);
4227 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
4228 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONDATE',P_TRANSACTIONDATE);
4229 WSH_DEBUG_SV.log(l_module_name,'P_TXNUNIQUESFLOCNID',P_TXNUNIQUESFLOCNID);
4230 WSH_DEBUG_SV.log(l_module_name,'P_START_INDEX',P_START_INDEX);
4231 WSH_DEBUG_SV.log(l_module_name,'P_END_INDEX',P_END_INDEX);
4232 WSH_DEBUG_SV.log(l_module_name,'P_MIN_DATE',P_MIN_DATE);
4233 WSH_DEBUG_SV.log(l_module_name,'P_MAX_DATE',P_MAX_DATE);
4234 END IF;
4235 --
4236 l_index := p_line_rec.shipment_line_id.FIRST;
4237 --
4238 WHILE l_index IS NOT NULL
4239 LOOP
4240 --{
4241 --l_poShipmentLineId := p_line_rec.po_shipment_line_id(l_index);
4242 --
4243 l_poHeaderNumber := p_line_rec.source_header_number(l_index);
4244 l_poLineNumber := p_line_rec.source_line_number(l_index);
4245 l_poShipmentLineNumber := p_line_rec.po_shipment_line_number(l_index);
4246 l_poReleaseNumber := p_line_rec.source_blanket_reference_num(l_index);
4247 l_shipmentNumber := p_line_rec.shipment_num(l_index);
4248 l_receiptNumber := p_line_rec.receipt_num(l_index);
4249 --
4250 --
4251 -- Debug Statements
4252 --
4253 IF l_debug_on THEN
4254 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.GETTRANSACTIONKEY',WSH_DEBUG_SV.C_PROC_LEVEL);
4255 END IF;
4256 --
4257 WSH_IB_TXN_MATCH_PKG.getTransactionKey
4258 (
4259 p_transactionType => p_transactionType,
4260 p_ReceiptAgainstASN => p_ReceiptAgainstASN,
4261 p_index => l_index,
4262 p_line_rec => p_line_rec,
4263 x_key => l_key,
4264 x_transactionSubType => l_transactionSubType,
4265 x_return_status => l_return_status
4266 );
4267 --
4268 --
4269 -- Debug Statements
4270 --
4271 IF l_debug_on THEN
4272 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4273 WSH_DEBUG_SV.log(l_module_name,'l_key',l_key);
4274 WSH_DEBUG_SV.log(l_module_name,'l_transactionSubType',l_transactionSubType);
4275 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4276 END IF;
4277 --
4278 wsh_util_core.api_post_call
4279 (
4280 p_return_status => l_return_status,
4281 x_num_warnings => l_num_warnings,
4282 x_num_errors => l_num_errors
4283 );
4284 --
4285 --
4286 --
4287 -- Debug Statements
4288 --
4289 IF l_debug_on THEN
4290 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_linkTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
4291 END IF;
4292 --
4293 wsh_util_core.get_cached_value
4294 (
4295 p_cache_tbl => x_linkTbl,
4296 p_cache_ext_tbl => x_linkExtTbl,
4297 p_key => l_key, --??--l_poShipmentLineId,
4298 p_value => l_linkRecString,
4299 p_action => 'GET',
4300 x_return_status => l_return_status
4301 );
4302 --
4303 --
4304 --
4305 -- Debug Statements
4306 --
4307 IF l_debug_on THEN
4308 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4309 WSH_DEBUG_SV.log(l_module_name,'l_linkRecString',l_linkRecString);
4310 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4311 END IF;
4312 --
4313 wsh_util_core.api_post_call
4314 (
4315 p_return_status => l_return_status,
4316 x_num_warnings => l_num_warnings,
4317 x_num_errors => l_num_errors
4318 );
4319 --
4320 --
4321 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
4322 THEN
4323 FND_MESSAGE.SET_NAME('WSH','WSH_IB_PO_WDD_LINK_ERROR');
4324 FND_MESSAGE.SET_TOKEN('KEY',l_key);
4325 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
4326 RAISE FND_API.G_EXC_ERROR;
4327 --Should we raise some error insteaD?
4328 -- This may fail parent txn.....check again
4329 END IF;
4330 --
4331 l_position1 := INSTRB(l_linkRecString, C_SEPARATOR, 1,1) + 1;
4332 l_position2 := INSTRB(l_linkRecString, C_SEPARATOR, 1,2) + 1;
4333 l_lineStartIndex := SUBSTRB(l_linkRecString, l_position1, l_position2 - l_position1 - 1);
4334 l_lineEndIndex := SUBSTRB(l_linkRecString, l_position2);
4335 --
4336 --
4337 IF l_debug_on THEN
4338 WSH_DEBUG_SV.log(l_module_name,'l_position1',l_position1);
4339 WSH_DEBUG_SV.log(l_module_name,'l_position2',l_position2);
4340 WSH_DEBUG_SV.log(l_module_name,'l_lineStartIndex',l_lineStartIndex);
4341 WSH_DEBUG_SV.log(l_module_name,'l_lineEndIndex',l_lineEndIndex);
4342 END IF;
4343 --
4344 --
4345 IF SUBSTRB(l_linkRecString,1,1) = C_PROCESS_FLAG
4346 THEN
4347 --{
4348 --??how abt r-asn
4349 --
4350 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
4351 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
4352 OR (
4353 l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
4354 AND p_ReceiptAgainstASN <> 'Y'
4355 )
4356 THEN
4357 --{
4358 --
4359 -- Debug Statements
4360 --
4361 IF l_debug_on THEN
4362 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.SPLITLINES',WSH_DEBUG_SV.C_PROC_LEVEL);
4363 END IF;
4364 --
4365 WSH_IB_TXN_MATCH_PKG.splitLines
4366 (
4367 p_txnUniqueSFLocnId => p_txnUniqueSFLocnId,
4368 p_transactionType => p_transactionType,
4369 p_transactionDate => p_transactionDate,
4370 p_line_rec => p_line_rec,
4371 p_line_rec_index => l_index,
4372 x_matchedLineRecTbl => x_matchedLineRecTbl,
4373 x_lineStartIndex => l_lineStartIndex,
4374 x_lineEndIndex => l_lineEndIndex,
4375 x_return_status => l_return_status
4376 );
4377 --
4378 --
4379 --
4380 -- Debug Statements
4381 --
4382 IF l_debug_on THEN
4383 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4384 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4385 END IF;
4386 --
4387 wsh_util_core.api_post_call
4388 (
4389 p_return_status => l_return_status,
4390 x_num_warnings => l_num_warnings,
4391 x_num_errors => l_num_errors
4392 );
4393 --}
4394 END IF;
4395 --}
4396 END IF;
4397 --
4398 l_lineIndex := l_lineStartIndex;
4399 --
4400 IF SUBSTRB(l_linkRecString,1,1) <> C_ERROR_FLAG
4401 THEN
4402 --{
4403 --
4404 -- Debug Statements
4405 --
4406 IF l_debug_on THEN
4407 WSH_DEBUG_SV.log(l_module_name,'Item Id',p_line_rec.inventory_item_id(l_index));
4408 WSH_DEBUG_SV.log(l_module_name,'organization Id',p_line_rec.organization_id(l_index));
4409 WSH_DEBUG_SV.log(l_module_name,'Primary UOM',x_matchedLineRecTbl.requested_qty_uom_tab(l_lineIndex));
4410 WSH_DEBUG_SV.log(l_module_name,'Qty to Convert',p_line_rec.received_quantity(l_index));
4411 WSH_DEBUG_SV.log(l_module_name,'Qty UOM',p_line_rec.received_quantity_uom(l_index));
4412 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.CONVERT_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
4413 END IF;
4414 --
4415 WSH_INBOUND_UTIL_PKG.convert_quantity
4416 (
4417 p_inv_item_id => p_line_rec.inventory_item_id(l_index),
4418 p_organization_id => p_line_rec.organization_id(l_index),
4419 p_primary_uom_code => x_matchedLineRecTbl.requested_qty_uom_tab(l_lineIndex),
4420 p_quantity => p_line_rec.received_quantity(l_index),
4421 p_qty_uom_code => p_line_rec.received_quantity_uom(l_index),
4422 x_conv_qty => l_totalTxnLineQty,
4423 x_return_status => l_return_status
4424 );
4425 --
4426 --
4427 -- Debug Statements
4428 --
4429 IF l_debug_on THEN
4430 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4431 WSH_DEBUG_SV.log(l_module_name,'Converted Qty',l_totalTxnLineQty);
4432 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4433 END IF;
4434 --
4435 wsh_util_core.api_post_call
4436 (
4437 p_return_status => l_return_status,
4438 x_num_warnings => l_num_warnings,
4439 x_num_errors => l_num_errors
4440 );
4441 --
4442 --
4443 l_totalTxnLineQty2 := NVL(p_line_rec.received_quantity2(l_index),0);
4444 --
4445 l_remainingQty := ABS(l_totalTxnLineQty);
4446 l_remainingQty2 := ABS(l_totalTxnLineQty2);
4447 --
4448 l_date := p_min_date;
4449 --l_lineIndex := l_lineStartIndex;
4450 --
4451 --
4452 IF l_debug_on THEN
4453 WSH_DEBUG_SV.log(l_module_name,'l_totalTxnLineQty2',p_line_rec.received_quantity2(l_index));
4454 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty',l_remainingQty);
4455 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty2',l_remainingQty2);
4456 END IF;
4457 --
4458 WHILE l_remainingQty > 0
4459 AND l_Date <= p_max_date
4460 LOOP
4461 --{
4462 l_nextDate := p_max_date;
4463 l_lineIndex := l_lineStartIndex;
4464 --
4465 WHILE l_lineIndex IS NOT NULL
4466 AND l_lineIndex <= l_lineEndIndex
4467 AND ( l_remainingQty > 0 OR l_leftOverQuantity2 > 0 )
4468 LOOP
4469 --{
4470 BEGIN
4471 --{
4472 l_lineDate := x_matchedLineRecTbl.line_date_tab(l_lineIndex);
4473 --
4474 --
4475 IF l_debug_on THEN
4476 WSH_DEBUG_SV.log(l_module_name,'Line Date',x_matchedLineRecTbl.line_date_tab(l_lineIndex));
4477 WSH_DEBUG_SV.log(l_module_name,'WDD ID',x_matchedLineRecTbl.del_detail_id_tab(l_lineIndex));
4478 WSH_DEBUG_SV.log(l_module_name,'WND ID',x_matchedLineRecTbl.delivery_id_tab(l_lineIndex));
4479 WSH_DEBUG_SV.log(l_module_name,'SF Locn ID',x_matchedLineRecTbl.ship_from_location_id_tab(l_lineIndex));
4480 WSH_DEBUG_SV.log(l_module_name,'Match Flag',x_matchedLineRecTbl.match_flag_tab(l_lineIndex));
4481 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
4482 x_matchedLineRecTbl.requested_qty_tab(l_lineIndex)
4483 || '|'
4484 || x_matchedLineRecTbl.picked_qty_tab(l_lineIndex)
4485 || '|'
4486 || x_matchedLineRecTbl.shipped_qty_tab(l_lineIndex)
4487 || '|'
4488 || x_matchedLineRecTbl.received_qty_tab(l_lineIndex)
4489 || '|'
4490 || x_matchedLineRecTbl.returned_qty_tab(l_lineIndex)
4491 );
4492 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
4493 x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex)
4494 || '|'
4495 || x_matchedLineRecTbl.picked_qty2_tab(l_lineIndex)
4496 || '|'
4497 || x_matchedLineRecTbl.shipped_qty2_tab(l_lineIndex)
4498 || '|'
4499 || x_matchedLineRecTbl.received_qty2_tab(l_lineIndex)
4500 || '|'
4501 || x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex)
4502 );
4503 END IF;
4504 --
4505 IF x_matchedLineRecTbl.match_flag_tab(l_lineIndex) = C_POTENTIAL_MATCH_FLAG
4506 THEN
4507 --{
4508 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
4509 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
4510 OR (
4511 l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
4512 AND p_receiptAgainstASN <> 'Y'
4513 )
4514 THEN
4515 IF l_debug_on THEN
4516 WSH_DEBUG_SV.logmsg(l_module_name,'Txn is ASN/Receipt-add/Direct Receipt');
4517 END IF;
4518 --
4519 IF x_matchedLineRecTbl.ship_from_location_id_tab(l_lineIndex) <> p_txnUniqueSFLocnId
4520 THEN
4521 --{
4522 IF l_debug_on THEN
4523 WSH_DEBUG_SV.logmsg(l_module_name,'Line SF <> Txn SF');
4524 END IF;
4525 IF x_matchedLineRecTbl.ship_from_location_id_tab(l_lineIndex) = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
4526 THEN
4527 IF l_debug_on THEN
4528 WSH_DEBUG_SV.logmsg(l_module_name,'Line SF is -1');
4529 END IF;
4530 x_matchedLineRecTbl.ship_from_location_id_tab(l_lineIndex) := p_txnUniqueSFLocnId;
4531 ELSE
4532 RAISE e_continue;
4533 END IF;
4534 --}
4535 END IF;
4536 END IF;
4537 --
4538 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
4539 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
4540 OR (
4541 l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
4542 AND p_receiptAgainstASN <> 'Y'
4543 )
4544 THEN
4545 IF l_lineDate <> l_date
4546 THEN
4547 RAISE e_continue;
4548 END IF;
4549 END IF;
4550 --
4551 --
4552 IF l_leftOverQuantity2 > 0
4553 THEN
4554 --{
4555 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
4556 THEN
4557 x_matchedLineRecTbl.received_qty2_tab(l_lineIndex)
4558 := NVL(x_matchedLineRecTbl.received_qty2_tab(l_lineIndex),0)
4559 + l_leftOverQuantity2;
4560 ELSIF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
4561 THEN
4562 x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex)
4563 := NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0)
4564 + l_leftOverQuantity2;
4565 END IF;
4566 --
4567 x_matchedLineRecTbl.process_corr_rtv_flag_tab(l_lineIndex) := C_PROCESS_FLAG;
4568 l_leftOverQuantity2 := 0;
4569 --}
4570 END IF;
4571 --
4572 l_lineQty := NULL;
4573 l_lineQty2 := NULL;
4574 --
4575 --
4576 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
4577 THEN
4578 --{
4579 l_lineQty := l_remainingQty;
4580 --}
4581 ELSIF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
4582 THEN
4583 --{
4584 l_lineQty := LEAST(
4585 l_remainingQty,
4586 NVL(x_matchedLineRecTbl.returned_qty_tab(l_lineIndex),0)
4587 );
4588 --}
4589 ELSE
4590 --{
4591 l_lineQty := LEAST(
4592 l_remainingQty,
4593 NVL
4594 (
4595 x_matchedLineRecTbl.received_qty_tab(l_lineIndex),
4596 NVL
4597 (
4598 x_matchedLineRecTbl.shipped_qty_tab(l_lineIndex),
4599 NVL
4600 (
4601 x_matchedLineRecTbl.picked_qty_tab(l_lineIndex),
4602 x_matchedLineRecTbl.requested_qty_tab(l_lineIndex)
4603 )
4604 )
4605 )
4606 - NVL(x_matchedLineRecTbl.returned_qty_tab(l_lineIndex),0)
4607 );
4608
4609 --
4610 -- For newly added line
4611 --
4612 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
4613 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
4614 OR (
4615 l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
4616 AND p_receiptAgainstASN <> 'Y'
4617 )
4618 THEN
4619 --{
4620 IF NVL(x_matchedLineRecTbl.requested_qty_tab(l_lineIndex),0) = 0
4621 THEN
4622
4623 l_lineQty := l_remainingQty;
4624 END IF;
4625 --}
4626 END IF;
4627 --}
4628 END IF;
4629 --
4630 l_remainingQty := l_remainingQty - l_lineQty;
4631 --
4632 --
4633 IF l_remainingQty2 > 0
4634 THEN
4635 --{
4636
4637 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
4638 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
4639 OR (
4640 l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
4641 AND p_receiptAgainstASN <> 'Y'
4642 )
4643 THEN
4644 --{
4645 -- HW OPMCONV - Use C_MAX_DECIMAL_DIGITS_INV instead of C_MAX_DECIMAL_DIGITS_OPM
4646 l_lineQty2 := ROUND
4647 (
4648 (
4649 (l_lineQty * l_totalTxnLineQty2) / l_totalTxnLineQty
4650 ),
4651 WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV
4652 );
4653 --}
4654 ELSIF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
4655 THEN
4656 --{
4657 l_lineQty2 := l_remainingQty2;
4658 --}
4659 ELSIF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
4660 THEN
4661 --{
4662 l_lineQty2 := LEAST(
4663 l_remainingQty2,
4664 NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0)
4665 );
4666 --}
4667 ELSE
4668 --{
4669 l_lineQty2 := LEAST(
4670 l_remainingQty2,
4671
4672 NVL
4673 (
4674 x_matchedLineRecTbl.received_qty2_tab(l_lineIndex),
4675 NVL
4676 (
4677 x_matchedLineRecTbl.shipped_qty2_tab(l_lineIndex),
4678 NVL
4679 (
4680 x_matchedLineRecTbl.picked_qty2_tab(l_lineIndex),
4681 x_matchedLineRecTbl.requested_qty2_tab(l_lineIndex)
4682 )
4683 )
4684 )
4685 - NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0)
4686 );
4687 --}
4688 END IF;
4689 --
4690 l_remainingQty2 := l_remainingQty2 - l_lineQty2;
4691 --}
4692 END IF;
4693 --
4694 --
4695 IF l_debug_on THEN
4696 WSH_DEBUG_SV.log(l_module_name,'l_lineQty',l_lineQty);
4697 WSH_DEBUG_SV.log(l_module_name,'l_lineQty2',l_lineQty2);
4698 END IF;
4699 --
4700 --
4701 IF NVL(l_lineQty,0) > 0 -- IS NOT NULL
4702 OR NVL(l_lineQty2,0) > 0 -- IS NOT NULL
4703 THEN
4704 --{
4705 --
4706 -- Debug Statements
4707 --
4708 IF l_debug_on THEN
4709 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.APPLYQUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
4710 END IF;
4711 --
4712 WSH_IB_TXN_MATCH_PKG.applyQuantity
4713 (
4714 p_transactionType => l_transactionSubType,
4715 p_ReceiptAgainstASN => p_ReceiptAgainstASN,
4716 p_quantity => l_lineQty,
4717 p_quantity2 => l_lineQty2,
4718 p_index => l_lineIndex,
4719 x_matchedLineRecTbl => x_matchedLineRecTbl,
4720 x_return_status => l_return_status
4721 );
4722 --
4723 --
4724 --
4725 -- Debug Statements
4726 --
4727 IF l_debug_on THEN
4728 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4729 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4730 END IF;
4731 --
4732 wsh_util_core.api_post_call
4733 (
4734 p_return_status => l_return_status,
4735 x_num_warnings => l_num_warnings,
4736 x_num_errors => l_num_errors
4737 );
4738 --
4739 --
4740 IF x_matchedLineRecTbl.received_qty_tab(l_lineIndex) < 0
4741 OR x_matchedLineRecTbl.shipped_qty_tab(l_lineIndex) < 0
4742 OR x_matchedLineRecTbl.received_qty_tab(l_lineIndex)
4743 - x_matchedLineRecTbl.returned_qty_tab(l_lineIndex) < 0
4744 OR x_matchedLineRecTbl.received_qty2_tab(l_lineIndex) < 0
4745 OR x_matchedLineRecTbl.shipped_qty2_tab(l_lineIndex) < 0
4746 OR x_matchedLineRecTbl.received_qty2_tab(l_lineIndex)
4747 - x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex) < 0
4748 THEN
4749 --{
4750 FND_MESSAGE.SET_NAME('WSH','WSH_IB_MATCH_LINE_FATAL_ERROR');
4751 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',p_transactionMeaning); --p_action_prms.action_code);
4752 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
4753 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
4754 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
4755 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
4756 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
4757 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
4758 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
4759 --
4760 RAISE FND_API.G_EXC_ERROR;
4761 --}
4762 END IF;
4763 --
4764 --
4765 l_lastMatchedLineIndex := l_lineIndex;
4766 --
4767 --
4768 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
4769 THEN
4770 --{
4771 l_leftOverQuantity2 := x_matchedLineRecTbl.received_qty2_tab(l_lineIndex)
4772 - NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0);
4773 --
4774 --
4775 IF l_leftOverQuantity2 > 0
4776 THEN
4777 --{
4778 IF x_matchedLineRecTbl.received_qty_tab(l_lineIndex)
4779 - NVL(x_matchedLineRecTbl.returned_qty_tab(l_lineIndex),0)
4780 <> 0
4781 THEN
4782 l_leftOverQuantity2 := 0;
4783 ELSE
4784 x_matchedLineRecTbl.received_qty2_tab(l_lineIndex)
4785 := NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0);
4786 --
4787 x_matchedLineRecTbl.process_corr_rtv_flag_tab(l_lineIndex) := C_PROCESS_FLAG;
4788 END IF;
4789 --}
4790 END IF;
4791 --}
4792 END IF;
4793 --
4794 --
4795 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
4796 THEN
4797 --{
4798 l_leftOverQuantity2 := NVL(x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex),0);
4799 --
4800 --
4801 IF l_leftOverQuantity2 > 0
4802 THEN
4803 --{
4804 IF NVL(x_matchedLineRecTbl.returned_qty_tab(l_lineIndex),0) <> 0
4805 THEN
4806 l_leftOverQuantity2 := 0;
4807 ELSE
4808 x_matchedLineRecTbl.returned_qty2_tab(l_lineIndex) := 0;
4809 --
4810 x_matchedLineRecTbl.process_corr_rtv_flag_tab(l_lineIndex) := C_PROCESS_FLAG;
4811 END IF;
4812 --}
4813 END IF;
4814 --}
4815 END IF;
4816 --}
4817 END IF;
4818 --}
4819 END IF;
4820 --}
4821 EXCEPTION
4822 --{
4823 WHEN e_continue THEN
4824 IF l_debug_on THEN
4825 WSH_DEBUG_SV.logmsg(l_module_name,'WHEN e_continue ');
4826 END IF;
4827 --}
4828 END;
4829 --
4830 --
4831 IF l_lineDate > l_date
4832 THEN
4833 --{
4834 l_nextDate := LEAST( l_lineDate, l_nextDate );
4835 --}
4836 END IF;
4837 --
4838 l_lineIndex := x_matchedLineRecTbl.match_flag_tab.NEXT(l_lineIndex);
4839 --
4840 IF l_debug_on THEN
4841 WSH_DEBUG_SV.logmsg(l_module_name,'End of inner loop');
4842 WSH_DEBUG_SV.log(l_module_name,'l_lineIndex',l_lineIndex);
4843 WSH_DEBUG_SV.log(l_module_name,'l_nextDate',l_nextDate);
4844 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty',l_remainingQty);
4845 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty2',l_remainingQty2);
4846 WSH_DEBUG_SV.log(l_module_name,'l_leftOverQuantity2',l_leftOverQuantity2);
4847 END IF;
4848 --
4849 --}
4850 END LOOP;
4851 --
4852 EXIT WHEN l_date = p_max_date;
4853 --
4854 l_date := l_nextDate;
4855 --
4856 IF l_debug_on THEN
4857 WSH_DEBUG_SV.logmsg(l_module_name,'End of outer loop');
4858 WSH_DEBUG_SV.log(l_module_name,'l_date',l_date);
4859 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty',l_remainingQty);
4860 --
4861 --
4862 IF l_Date < p_max_date
4863 THEN
4864 WSH_DEBUG_SV.logmsg(l_module_name,'l_date < p_max_date');
4865 ELSIF l_Date = p_max_date
4866 THEN
4867 WSH_DEBUG_SV.logmsg(l_module_name,'l_date = p_max_date');
4868 ELSIF l_Date > p_max_date
4869 THEN
4870 WSH_DEBUG_SV.logmsg(l_module_name,'l_date > p_max_date');
4871 ELSE
4872 WSH_DEBUG_SV.logmsg(l_module_name,'l_date ??? p_max_date');
4873 END IF;
4874 END IF;
4875 --
4876 --}
4877 END LOOP;
4878 --
4879 --
4880 IF l_debug_on THEN
4881 WSH_DEBUG_SV.logmsg(l_module_name,'Outside Outer loop');
4882 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty',l_remainingQty);
4883 WSH_DEBUG_SV.log(l_module_name,'l_remainingQty2',l_remainingQty2);
4884 WSH_DEBUG_SV.log(l_module_name,'l_lastMatchedLineIndex',l_lastMatchedLineIndex);
4885 END IF;
4886 --
4887 --
4888 IF l_remainingQty > 0
4889 OR l_remainingQty2 > 0
4890 THEN
4891 --{
4892 IF l_lastMatchedLineIndex IS NOT NULL
4893 THEN
4894 --{
4895 --
4896 -- Debug Statements
4897 --
4898 IF l_debug_on THEN
4899 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.APPLYQUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
4900 END IF;
4901 --
4902 WSH_IB_TXN_MATCH_PKG.applyDelta
4903 (
4904 p_transactionType => l_transactionSubType,
4905 p_ReceiptAgainstASN => p_ReceiptAgainstASN,
4906 p_quantity => l_remainingQty,
4907 p_quantity2 => l_remainingQty2,
4908 --p_quantity => LEAST(l_remainingQty,0),
4909 --p_quantity2 => LEAST(l_remainingQty2,0),
4910 p_index => l_lastMatchedLineIndex,
4911 x_matchedLineRecTbl => x_matchedLineRecTbl,
4912 x_return_status => l_return_status
4913 );
4914 --
4915 --
4916 --
4917 -- Debug Statements
4918 --
4919 IF l_debug_on THEN
4920 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4921 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4922 END IF;
4923 --
4924 wsh_util_core.api_post_call
4925 (
4926 p_return_status => l_return_status,
4927 x_num_warnings => l_num_warnings,
4928 x_num_errors => l_num_errors
4929 );
4930 --
4931 --
4932 IF x_matchedLineRecTbl.received_qty_tab(l_lastMatchedLineIndex) < 0
4933 OR x_matchedLineRecTbl.shipped_qty_tab(l_lastMatchedLineIndex) < 0
4934 OR x_matchedLineRecTbl.received_qty_tab(l_lastMatchedLineIndex)
4935 - x_matchedLineRecTbl.returned_qty_tab(l_lastMatchedLineIndex) < 0
4936 OR x_matchedLineRecTbl.received_qty2_tab(l_lastMatchedLineIndex) < 0
4937 OR x_matchedLineRecTbl.shipped_qty2_tab(l_lastMatchedLineIndex) < 0
4938 OR x_matchedLineRecTbl.received_qty2_tab(l_lastMatchedLineIndex)
4939 - x_matchedLineRecTbl.returned_qty2_tab(l_lastMatchedLineIndex) < 0
4940 THEN
4941 --{
4942 FND_MESSAGE.SET_NAME('WSH','WSH_IB_MATCH_LINE_FATAL_ERROR');
4943 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',p_transactionMeaning); --p_action_prms.action_code);
4944 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
4945 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
4946 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
4947 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
4948 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
4949 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
4950 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
4951 --
4952 RAISE FND_API.G_EXC_ERROR;
4953 --}
4954 END IF;
4955 --}
4956 ELSE
4957 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_NO_MATCH_ERROR');
4958 FND_MESSAGE.SET_TOKEN('KEY',l_key);
4959 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
4960 RAISE FND_API.G_EXC_ERROR;
4961 END IF;
4962 --}
4963 END IF;
4964 --
4965 --
4966 l_linkRecString := C_PROCESS_FLAG
4967 || C_SEPARATOR
4968 || l_lineStartIndex
4969 || C_SEPARATOR
4970 || l_lineEndIndex; --l_lineStartIndex;
4971 --
4972 --
4973 --
4974 -- Debug Statements
4975 --
4976 IF l_debug_on THEN
4977 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_linkTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
4978 END IF;
4979 --
4980 wsh_util_core.get_cached_value
4981 (
4982 p_cache_tbl => x_linkTbl,
4983 p_cache_ext_tbl => x_linkExtTbl,
4984 p_key => l_key, --??--l_poShipmentLineId,
4985 p_value => l_linkRecString,
4986 p_action => 'PUT',
4987 x_return_status => l_return_status
4988 );
4989 --
4990 --
4991 --
4992 -- Debug Statements
4993 --
4994 IF l_debug_on THEN
4995 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
4996 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4997 END IF;
4998 --
4999 wsh_util_core.api_post_call
5000 (
5001 p_return_status => l_return_status,
5002 x_num_warnings => l_num_warnings,
5003 x_num_errors => l_num_errors
5004 );
5005 --}
5006 END IF;
5007 --
5008 --
5009 --
5010 l_index := p_line_rec.shipment_line_id.NEXT(l_index);
5011 --}
5012 END LOOP;
5013 --
5014 --
5015 --
5016 --
5017 IF l_debug_on THEN
5018 WSH_DEBUG_SV.logmsg(l_module_name,
5019 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
5020 END IF;
5021 --
5022 IF l_num_errors > 0
5023 THEN
5024 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5025 ELSIF l_num_warnings > 0
5026 THEN
5027 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5028 ELSE
5029 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5030 END IF;
5031 --
5032 -- Debug Statements
5033 --
5034 IF l_debug_on THEN
5035 WSH_DEBUG_SV.pop(l_module_name);
5036 END IF;
5037 --
5038 --}
5039 EXCEPTION
5040 --{
5041 --WHEN e_notMatched THEN
5042 --RAISE e_notMatched;
5043 WHEN FND_API.G_EXC_ERROR THEN
5044 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5045 --
5046 -- Debug Statements
5047 --
5048 IF l_debug_on THEN
5049 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5050 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
5051 END IF;
5052 --
5053 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5054 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5055 --
5056 -- Debug Statements
5057 --
5058 IF l_debug_on THEN
5059 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5060 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
5061 END IF;
5062 --
5063 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
5064 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5065 --
5066 -- Debug Statements
5067 --
5068 IF l_debug_on THEN
5069 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5070 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
5071 END IF;
5072 --
5073 WHEN OTHERS THEN
5074 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5075 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.matchQuantity');
5076 --
5077 -- Debug Statements
5078 --
5079 IF l_debug_on THEN
5080 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5081 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5082 END IF;
5083 --
5084 --}
5085 END matchQuantity;
5086
5087
5088 PROCEDURE matchLines
5089 (
5090 p_line_rec IN OE_WSH_BULK_GRP.Line_Rec_Type,
5091 p_transactionType IN VARCHAR2,
5092 p_transactionMeaning IN VARCHAR2,
5093 p_ReceiptAgainstASN IN VARCHAR2,
5094 p_transactionDate IN DATE,
5095 p_start_index IN NUMBER,
5096 p_end_index IN NUMBER,
5097 p_putMessages IN BOOLEAN,
5098 p_txnUniqueSFLocnId IN NUMBER,
5099 x_matchedLineRecTbl IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
5100 x_dlvytbl IN OUT NOCOPY WSH_UTIL_CORE.char500_tab_type,
5101 x_dlvyExttbl IN OUT NOCOPY WSH_UTIL_CORE.char500_tab_type,
5102 x_min_date IN OUT NOCOPY DATE,
5103 x_max_date IN OUT NOCOPY DATE,
5104 x_return_status OUT NOCOPY VARCHAR2
5105 )
5106 IS
5107 --{
5108 CURSOR dlvy_leg_csr
5109 (
5110 p_deliveryId IN NUMBER,
5111 p_transactionType IN VARCHAR2
5112 )
5113 IS
5114 SELECT 'DROPOFF' leg_type,
5115 NVL(wts1.actual_departure_date,wts1.planned_departure_date) planned_departure_date,
5116 NVL(wts.actual_arrival_date, wts.planned_arrival_date) planned_arrival_date,
5117 wt.carrier_id,
5118 NVL(wnd.ITINERARY_COMPLETE,'N') ITINERARY_COMPLETE
5119 FROM wsh_delivery_legs wdl,
5120 wsh_new_deliveries wnd,
5121 wsh_trip_stops wts,
5122 wsh_trip_stops wts1,
5123 wsh_trips wt
5124 WHERE wnd.delivery_id = p_deliveryId
5125 AND wdl.delivery_id = wnd.delivery_id
5126 AND wdl.drop_off_stop_id = wts.stop_id
5127 AND wts.stop_location_id = wnd.ultimate_dropoff_location_id
5128 AND wts.trip_id = wt.trip_id
5129 AND wdl.pick_up_stop_id = wts1.stop_id
5130 UNION ALL
5131 SELECT 'PICKUP' leg_type,
5132 NVL(wts.actual_departure_date,wts.planned_departure_date) planned_departure_date,
5133 NVL(wts1.actual_arrival_Date, wts1.planned_arrival_date) planned_arrival_date,
5134 wt.carrier_id,
5135 NVL(wnd.ITINERARY_COMPLETE,'N') ITINERARY_COMPLETE
5136 FROM wsh_delivery_legs wdl,
5137 wsh_new_deliveries wnd,
5138 wsh_trip_stops wts,
5139 wsh_trip_stops wts1,
5140 wsh_trips wt
5141 WHERE wnd.delivery_id = p_deliveryId
5142 AND wdl.delivery_id = wnd.delivery_id
5143 AND wdl.pick_up_stop_id = wts.stop_id
5144 AND wts.stop_location_id = wnd.initial_pickup_location_id
5145 AND wts.trip_id = wt.trip_id
5146 AND wdl.drop_off_stop_id = wts1.stop_id
5147 AND p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
5148 ORDER BY 1 ASC; --- order by leg_type--dropoff first then pickup
5149 --
5150 l_dlvy_leg_rec dlvy_leg_csr%ROWTYPE;
5151 --
5152 --
5153 CURSOR dlvy_csr
5154 (
5155 p_deliveryId IN NUMBER
5156 )
5157 IS
5158 SELECT
5159 NVL(wnd.initial_pickup_date,wnd.earliest_pickup_date) initial_pickup_date,
5160 NVL(wnd.ultimate_dropoff_date,wnd.latest_Dropoff_date) ultimate_dropoff_date,
5161 wnd.carrier_id,
5162 NVL(wnd.ITINERARY_COMPLETE,'N') ITINERARY_COMPLETE,
5163 wdl.delivery_leg_id
5164 FROM wsh_new_deliveries wnd,
5165 wsh_delivery_legs wdl
5166 WHERE wnd.delivery_id = p_deliveryId
5167 AND wnd.delivery_id = wdl.delivery_id (+);
5168 --
5169 l_dlvy_rec dlvy_csr%ROWTYPE;
5170 --
5171 --
5172 CURSOR carrier_csr
5173 (
5174 p_carrierId IN NUMBER
5175 )
5176 IS
5177 SELECT
5178 party_name
5179 FROM hz_parties
5180 WHERE party_id = p_carrierId;
5181 --
5182 --
5183 l_num_warnings NUMBER := 0;
5184 l_num_errors NUMBER := 0;
5185 l_return_status VARCHAR2(30);
5186 --
5187 l_lastRCVShipmentLineId NUMBER := NULL;
5188 l_lastDeliveryId NUMBER := NULL;
5189 l_lastDeliveryRecString VARCHAR2(500) := NULL;
5190 l_min_date DATE := NULL;
5191 l_max_date DATE := NULL;
5192 l_matchedCount NUMBER := 0;
5193 --
5194 l_start_index NUMBER;
5195 l_end_index NUMBER;
5196 l_index NUMBER;
5197 l_RCVLineIndex NUMBER;
5198 --
5199 l_currentRCVShipmentLineId NUMBER;
5200 l_deliveryId NUMBER;
5201 l_DeliveryRecString VARCHAR2(500);
5202 l_transactionDate DATE;
5203 l_lineDate DATE;
5204 l_shipFromLocationId NUMBER;
5205 l_carrierId NUMBER;
5206 l_transactionCarrierId NUMBER;
5207 l_carrierName VARCHAR2(500);
5208 l_deliveryItineraryComplete VARCHAR2(5);
5209 l_deliveryLegsExist BOOLEAN;
5210 --
5211 --
5212 l_firstShipFromLocationId NUMBER;
5213 l_shipmentNumber VARCHAR2(50);
5214 l_receiptNumber VARCHAR2(50);
5215 l_validFlag VARCHAR2(10);
5216 l_found BOOLEAN;
5217 --
5218 l_poHeaderNumber VARCHAR2(150);
5219 l_poLineNumber VARCHAR2(150);
5220 l_poShipmentLineNumber NUMBER;
5221 l_poReleaseNumber NUMBER;
5222
5223 e_notMatchedCarrierDates EXCEPTION;
5224 --
5225 l_debug_on BOOLEAN;
5226 --
5227 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'MATCHLINES';
5228 --
5229 --}
5230 BEGIN
5231 --{
5232 --
5233 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5234 --
5235 IF l_debug_on IS NULL
5236 THEN
5237 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5238 END IF;
5239 --
5240 --
5241 -- Debug Statements
5242 --
5243 IF l_debug_on THEN
5244 WSH_DEBUG_SV.push(l_module_name);
5245 --
5246 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONTYPE',P_TRANSACTIONTYPE);
5247 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONMEANING',P_TRANSACTIONMEANING);
5248 WSH_DEBUG_SV.log(l_module_name,'P_RECEIPTAGAINSTASN',P_RECEIPTAGAINSTASN);
5249 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTIONDATE',P_TRANSACTIONDATE);
5250 WSH_DEBUG_SV.log(l_module_name,'P_START_INDEX',P_START_INDEX);
5251 WSH_DEBUG_SV.log(l_module_name,'P_END_INDEX',P_END_INDEX);
5252 WSH_DEBUG_SV.log(l_module_name,'P_PUTMESSAGES',P_PUTMESSAGES);
5253 WSH_DEBUG_SV.log(l_module_name,'P_TXNUNIQUESFLOCNID',P_TXNUNIQUESFLOCNID);
5254 WSH_DEBUG_SV.log(l_module_name,'X_MIN_DATE',X_MIN_DATE);
5255 WSH_DEBUG_SV.log(l_module_name,'X_MAX_DATE',X_MAX_DATE);
5256 END IF;
5257 --
5258 l_index := p_start_index;
5259 l_start_index := p_start_index;
5260 l_firstShipFromLocationId := x_matchedLineRecTbl.ship_from_location_id_tab(l_index);
5261 --
5262 --
5263 WHILE l_index IS NOT NULL
5264 AND l_index <= p_end_index
5265 LOOP
5266 --{
5267
5268 l_currentRCVShipmentLineId := x_matchedLineRecTbl.shipment_line_id_tab(l_index);
5269 l_deliveryId := x_matchedLineRecTbl.delivery_id_tab(l_index);
5270 l_deliveryRecString := NULL;
5271 l_shipFromLocationId := x_matchedLineRecTbl.ship_from_location_id_tab(l_index);
5272 --l_firstShipFromLocationId := l_shipFromLocationId;
5273 --
5274 --
5275 IF l_debug_on THEN
5276 WSH_DEBUG_SV.log(l_module_name,'Matched Line Rec index',l_index);
5277 WSH_DEBUG_SV.log(l_module_name,'l_deliveryId',l_deliveryId);
5278 WSH_DEBUG_SV.log(l_module_name,'l_shipFromLocationId',l_shipFromLocationId);
5279 WSH_DEBUG_SV.log(l_module_name,'l_currentRCVShipmentLineId',l_currentRCVShipmentLineId);
5280 WSH_DEBUG_SV.log(l_module_name,'l_RCVLineIndex',x_matchedLineRecTbl.shpmt_line_id_idx_tab(l_index));
5281 END IF;
5282 --
5283 --
5284 l_RCVLineIndex := x_matchedLineRecTbl.shpmt_line_id_idx_tab(l_index);
5285 l_transactionCarrierId := p_line_rec.rcv_carrier_id(l_RCVLineIndex);
5286 l_shipmentNumber := p_line_rec.shipment_num(l_RCVLineIndex);
5287 l_receiptNumber := p_line_rec.receipt_num(l_RCVLineIndex);
5288 --
5289 --
5290 IF l_debug_on THEN
5291 WSH_DEBUG_SV.log(l_module_name,'l_transactionCarrierId',l_transactionCarrierId);
5292 WSH_DEBUG_SV.log(l_module_name,'l_lastRCVShipmentLineId',l_lastRCVShipmentLineId);
5293 END IF;
5294 --
5295 --
5296 IF l_currentRCVShipmentLineId <> l_lastRCVShipmentLineId
5297 THEN
5298 --{
5299 IF l_matchedCount = 0
5300 THEN
5301 --{
5302 RAISE e_notMatchedCarrierDates;
5303 --}
5304 --ELSE
5305 --{
5306 --match_qtys
5307 --}
5308 END IF;
5309 --
5310 l_start_index := l_index;
5311 l_firstShipFromLocationId := l_shipFromLocationId;
5312 --l_min_date := NULL;
5313 --l_max_date := NULL;
5314 l_matchedCount := 0;
5315 --}
5316 END IF;
5317 --
5318 --
5319 IF l_debug_on THEN
5320 WSH_DEBUG_SV.log(l_module_name,'l_start_index',l_start_index);
5321 WSH_DEBUG_SV.log(l_module_name,'l_firstShipFromLocationId',l_firstShipFromLocationId);
5322 WSH_DEBUG_SV.log(l_module_name,'l_lastDeliveryId',l_lastDeliveryId);
5323 END IF;
5324 --
5325 --
5326 IF (
5327 p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
5328 OR (
5329 p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
5330 AND p_ReceiptAgainstASN <> 'Y'
5331 )
5332 )
5333 AND p_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
5334 AND l_shipFromLocationId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
5335 THEN
5336 --{
5337 IF p_putMessages
5338 THEN
5339 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_UNIQUE_SF_LOCN');
5340 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',p_transactionMeaning); --p_action_prms.action_code);
5341 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
5342 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
5343 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
5344 END IF;
5345 --
5346 RAISE e_notMatched;
5347 --}
5348 END IF;
5349 --
5350 --
5351 IF l_shipFromLocationId = p_txnUniqueSFLocnId
5352 OR ( l_shipFromLocationId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
5353 AND l_shipFromLocationId = l_firstShipFromLocationId
5354 )
5355 --OR ( l_shipFromLocationId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID AND l_index = l_start_index )
5356 /*
5357 OR (
5358 p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
5359 AND p_receiptAgainstASN = 'Y'
5360 )
5361 */
5362 THEN
5363 --{
5364 IF l_deliveryId IS NULL
5365 THEN
5366 --{
5367 l_linedate := x_matchedLineRecTbl.line_date_tab(l_index);
5368 --l_latest_date := x_matchedLineRecTbl.latest_date_tab(l_index);
5369 l_validFlag := 'Y';
5370 --}
5371 ELSE
5372 --{
5373 IF l_lastDeliveryId = l_deliveryId
5374 THEN
5375 l_deliveryRecString := l_lastDeliveryRecString;
5376 ELSE
5377 --{
5378 --
5379 -- Debug Statements
5380 --
5381 IF l_debug_on THEN
5382 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_dlvyTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
5383 END IF;
5384 --
5385 wsh_util_core.get_cached_value
5386 (
5387 p_cache_tbl => x_dlvyTbl,
5388 p_cache_ext_tbl => x_dlvyExtTbl,
5389 p_key => l_deliveryId,
5390 p_value => l_deliveryRecString,
5391 p_action => 'GET',
5392 x_return_status => l_return_status
5393 );
5394 --
5395 --
5396 IF l_debug_on THEN
5397 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
5398 END IF;
5399 --
5400 --
5401 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
5402 THEN
5403 RAISE FND_API.G_EXC_ERROR;
5404 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
5405 THEN
5406 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5407 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
5408 THEN
5409 l_deliveryRecString := NULL;
5410 END IF;
5411 --}
5412 END IF;
5413 --
5414 IF l_deliveryRecString IS NULL
5415 THEN
5416 --{
5417 OPEN dlvy_leg_csr
5418 (
5419 p_deliveryId => l_deliveryId,
5420 p_transactionType => p_transactionType
5421 );
5422 --
5423 FETCH dlvy_leg_csr INTO l_dlvy_leg_rec;
5424 --
5425 IF dlvy_leg_csr%NOTFOUND
5426 THEN
5427 --{
5428 OPEN dlvy_csr(p_deliveryId => l_deliveryId);
5429 --
5430 FETCH dlvy_csr INTO l_dlvy_rec;
5431 --
5432 l_found := dlvy_csr%FOUND;
5433 --
5434 CLOSE dlvy_csr;
5435 --
5436 IF NOT(l_found)
5437 THEN
5438 --{
5439 FND_MESSAGE.SET_NAME('WSH','WSH_DLVY_NOT_EXIST');
5440 FND_MESSAGE.SET_TOKEN('DELIVERY_ID',l_deliveryId);
5441 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error,l_module_name);
5442 RAISE FND_API.G_EXC_ERROR;
5443 --}
5444 END IF;
5445 --
5446 --
5447 IF l_debug_on THEN
5448 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_rec.initial_pickup_date',l_dlvy_rec.initial_pickup_date);
5449 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_rec.ultimate_dropoff_date',l_dlvy_rec.ultimate_dropoff_date);
5450 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_rec.carrier_id',l_dlvy_rec.carrier_id);
5451 END IF;
5452 --
5453 --
5454 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
5455 THEN
5456 l_linedate := l_dlvy_rec.initial_pickup_date;
5457 ELSE
5458 l_linedate := l_dlvy_rec.ultimate_dropoff_date;
5459 END IF;
5460 --
5461 l_carrierId := l_dlvy_rec.carrier_id;
5462 l_deliveryItineraryComplete := l_dlvy_rec.ITINERARY_COMPLETE;
5463 --
5464 IF l_dlvy_rec.delivery_leg_id IS NULL
5465 THEN
5466 l_deliveryLegsExist := FALSE;
5467 ELSE
5468 l_deliveryLegsExist := TRUE;
5469 END IF;
5470 --}
5471 ELSE
5472 --{
5473 --
5474 IF l_debug_on THEN
5475 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_leg_rec.planned_departure_date',l_dlvy_leg_rec.planned_departure_date);
5476 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_leg_rec.planned_arrival_date',l_dlvy_leg_rec.planned_arrival_date);
5477 WSH_DEBUG_SV.log(l_module_name,'l_dlvy_leg_rec.carrier_id',l_dlvy_leg_rec.carrier_id);
5478 END IF;
5479 --
5480 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
5481 THEN
5482 l_linedate := l_dlvy_leg_rec.planned_departure_date;
5483 ELSE
5484 l_linedate := l_dlvy_leg_rec.planned_arrival_date;
5485 END IF;
5486 --
5487 l_carrierId := l_dlvy_leg_rec.carrier_id;
5488 l_deliveryItineraryComplete := l_dlvy_leg_rec.ITINERARY_COMPLETE;
5489 l_deliveryLegsExist := TRUE;
5490 --}
5491 END IF;
5492 --
5493 CLOSE dlvy_leg_csr;
5494 --
5495 l_validFlag := 'Y';
5496 --
5497 --IB-phase-2 : removed condition on Date
5498 IF ( l_carrierId <> l_transactionCarrierId AND nvl(x_matchedLineRecTbl.lineCount_tab(l_index),2) > 1 )
5499 OR (
5500 l_deliveryLegsExist AND l_deliveryItineraryComplete = 'N'
5501 )
5502 THEN
5503 --{
5504 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
5505 OR p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
5506 OR (
5507 p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
5508 AND p_receiptAgainstASN <> 'Y'
5509 )
5510 THEN
5511 l_validFlag := 'N';
5512 END IF;
5513 --}
5514 END IF;
5515 --
5516 --
5517 l_lineDate := NVL(l_lineDate,SYSDATE+2000);
5518 --
5519 --
5520 l_deliveryRecString := l_validFlag
5521 || C_SEPARATOR
5522 || TO_CHAR(l_lineDate, C_DATE_FORMAT_MASK);
5523 --
5524 --
5525 -- Debug Statements
5526 --
5527 IF l_debug_on THEN
5528 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_dlvyTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
5529 END IF;
5530 --
5531 wsh_util_core.get_cached_value
5532 (
5533 p_cache_tbl => x_dlvyTbl,
5534 p_cache_ext_tbl => x_dlvyExtTbl,
5535 p_key => l_deliveryId,
5536 p_value => l_deliveryRecString,
5537 p_action => 'PUT',
5538 x_return_status => l_return_status
5539 );
5540 --
5541 --
5542 --
5543 -- Debug Statements
5544 --
5545 IF l_debug_on THEN
5546 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
5547 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5548 END IF;
5549 --
5550 wsh_util_core.api_post_call
5551 (
5552 p_return_status => l_return_status,
5553 x_num_warnings => l_num_warnings,
5554 x_num_errors => l_num_errors
5555 );
5556 --}
5557 ELSE
5558 --{
5559 l_validFlag := SUBSTRB(l_deliveryRecString, 1,1);
5560 l_lineDate := TO_DATE( SUBSTRB(l_deliveryRecString, 3), C_DATE_FORMAT_MASK) ;
5561 --}
5562 END IF;
5563 --}
5564 END IF;
5565 --
5566 --
5567 IF l_debug_on THEN
5568 WSH_DEBUG_SV.log(l_module_name,'l_deliveryRecString',l_deliveryRecString);
5569 WSH_DEBUG_SV.log(l_module_name,'l_validFlag',l_validFlag);
5570 WSH_DEBUG_SV.log(l_module_name,'l_lineDate',l_lineDate);
5571 END IF;
5572 --
5573 IF l_validFlag = 'Y'
5574 THEN
5575 --{
5576 x_matchedLineRecTbl.line_date_tab(l_index) := l_lineDate;
5577 x_matchedLineRecTbl.match_flag_Tab(l_index) := C_POTENTIAL_MATCH_FLAG;
5578 --
5579 l_matchedCount := l_matchedCount + 1;
5580 --
5581 /*
5582 IF l_shipFromLocationId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
5583 THEN
5584 x_matchedLineRecTbl.ship_from_location_id_tab(l_index) := p_txnUniqueSFLocnId;
5585 END IF;
5586 */
5587 --
5588 x_min_date := LEAST ( NVL(x_min_date,l_lineDate), l_lineDate );
5589 x_max_date := GREATEST ( NVL(x_max_date,l_lineDate), l_lineDate );
5590 --}
5591 END IF;
5592 --
5593 --
5594 l_lastDeliveryId := l_deliveryId;
5595 l_lastDeliveryRecString := l_deliveryRecString;
5596 --l_lastRCVShipmentLineId := l_currentRCVShipmentLineId;
5597 l_end_index := l_index;
5598 --}
5599 END IF;
5600 --
5601 --
5602 l_lastRCVShipmentLineId := l_currentRCVShipmentLineId;
5603 l_poHeaderNumber := p_line_rec.source_header_number(l_RCVLineIndex);
5604 l_poLineNumber := p_line_rec.source_line_number(l_RCVLineIndex);
5605 l_poShipmentLineNumber := p_line_rec.po_shipment_line_number(l_RCVLineIndex);
5606 l_poReleaseNumber := p_line_rec.source_blanket_reference_num(l_RCVLineIndex);
5607 --
5608 l_index := x_matchedLineRecTbl.del_detail_id_tab.NEXT(l_index);
5609 --}
5610 END LOOP;
5611 --
5612 IF l_matchedCount = 0
5613 THEN
5614 --{
5615 RAISE e_notMatchedCarrierDates;
5616 --}
5617 END IF;
5618 --
5619 --
5620 --
5621 --
5622 IF l_debug_on THEN
5623 WSH_DEBUG_SV.log(l_module_name,'x_min_date',x_min_date);
5624 WSH_DEBUG_SV.log(l_module_name,'x_max_date',x_max_date);
5625 WSH_DEBUG_SV.logmsg(l_module_name,
5626 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
5627 END IF;
5628 --
5629 IF l_num_errors > 0
5630 THEN
5631 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5632 ELSIF l_num_warnings > 0
5633 THEN
5634 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5635 ELSE
5636 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5637 END IF;
5638 --
5639 -- Debug Statements
5640 --
5641 IF l_debug_on THEN
5642 WSH_DEBUG_SV.pop(l_module_name);
5643 END IF;
5644 --
5645 --}
5646 EXCEPTION
5647 --{
5648 WHEN e_notMatched THEN
5649 --
5650 -- Debug Statements
5651 --
5652 IF l_debug_on THEN
5653 WSH_DEBUG_SV.log(l_module_name,'x_min_date',x_min_date);
5654 WSH_DEBUG_SV.log(l_module_name,'x_max_date',x_max_date);
5655 WSH_DEBUG_SV.logmsg(l_module_name,'E_NOTMATCHED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5656 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:E_NOTMATCHED');
5657 END IF;
5658 --
5659 RAISE e_notMatched;
5660 WHEN e_notMatchedCarrierDates THEN
5661 --{
5662 IF p_putMessages
5663 THEN
5664 --{
5665 l_carrierName := NULL;
5666 --
5667 OPEN carrier_csr(l_transactionCarrierId);
5668 FETCH carrier_csr INTO l_carrierName;
5669 CLOSE carrier_csr;
5670 --
5671 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_MATCH_DATES');
5672 FND_MESSAGE.SET_TOKEN('TXN_DATE',p_transactionDate);
5673 FND_MESSAGE.SET_TOKEN('CARRIER_NAME',l_carrierName);
5674 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',p_transactionMeaning); --p_action_prms.action_code);
5675 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
5676 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
5677 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
5678 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
5679 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
5680 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
5681 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
5682 --}
5683 END IF;
5684 --
5685 --
5686 -- Debug Statements
5687 --
5688 IF l_debug_on THEN
5689 WSH_DEBUG_SV.log(l_module_name,'x_min_date',x_min_date);
5690 WSH_DEBUG_SV.log(l_module_name,'x_max_date',x_max_date);
5691 WSH_DEBUG_SV.logmsg(l_module_name,'E_NOTMATCHEDCARRIERDATES exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5692 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:E_NOTMATCHEDCARRIERDATES');
5693 END IF;
5694 --
5695 RAISE e_notMatched;
5696 --}
5697 WHEN FND_API.G_EXC_ERROR THEN
5698 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5699 --
5700 -- Debug Statements
5701 --
5702 IF l_debug_on THEN
5703 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5704 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
5705 END IF;
5706 --
5707 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5708 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5709 --
5710 -- Debug Statements
5711 --
5712 IF l_debug_on THEN
5713 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5714 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
5715 END IF;
5716 --
5717 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
5718 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5719 --
5720 -- Debug Statements
5721 --
5722 IF l_debug_on THEN
5723 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5724 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
5725 END IF;
5726 --
5727 WHEN OTHERS THEN
5728 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5729 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.matchLines');
5730 --
5731 -- Debug Statements
5732 --
5733 IF l_debug_on THEN
5734 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5735 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5736 END IF;
5737 --
5738 --}
5739 END matchLines;
5740
5741 --
5742 --========================================================================
5743 -- PROCEDURE : matchTransaction
5744 --
5745 -- PARAMETERS: p_action_prms Standard actions parameter.
5746 -- p_line_rec ASN/Receipt Lines
5747 -- x_return_status Return status of the API
5748 --
5749 --
5750 -- COMMENT : This procedure is the pre-processor for the Inbound ASN/Receiving transactions
5751 -- integration. (Receiving transaction processor calls this API via Group API).
5752 --
5753 -- This procedure handles following transactions (indicated by transaction type)
5754 -- 'ASN'
5755 -- 'CANCEL_ASN'
5756 -- 'RECEIPT'
5757 -- 'RECEIPT_CORRECTION'
5758 -- 'RTV'
5759 -- 'RTV_CORRECTION'
5760 -- 'RECEIPT_ADD'
5761 -- 'RECEIPT_HEADER_UPD'
5762 --
5763 -- Its main purpose is to apply matching algorithm(Please refer to HLD for
5764 -- description) i.e find unique ship-from location for the transaction
5765 -- interfaced. Once found, it tries to match lines with respect to dates/carrier
5766 -- and then applies transaction quantities onto delivery lines quantities
5767 -- (shipped/received/returned). If successful, it calls ASN/Receipt/Correction
5768 -- integration(processing) code. If unsuccessful, it raises a business event
5769 -- which can be subscribed to take some action e.g. notify concerned user.
5770 --========================================================================
5771 --
5772
5773
5774 PROCEDURE matchTransaction
5775 (
5776 p_action_prms IN WSH_BULK_TYPES_GRP.action_parameters_rectype,
5777 p_line_rec IN OUT NOCOPY OE_WSH_BULK_GRP.Line_rec_type,
5778 x_return_status OUT NOCOPY VARCHAR2
5779 )
5780 IS
5781 --{
5782 --
5783 -- This cursor tries to find delivery lines corresponding to each record in
5784 -- p_line_rec. (Please refer to appendix 2 of DLD for transaction-wise
5785 -- query conditions and order by clause )
5786 --
5787 CURSOR line_csr
5788 (
5789 p_source_header_id IN NUMBER,
5790 p_source_line_id IN NUMBER,
5791 p_po_shipment_line_id IN NUMBER,
5792 p_source_blanket_Reference_id IN NUMBER,
5793 p_released_status IN VARCHAR2,
5794 p_shipment_header_id IN NUMBER,
5795 p_ship_from_location_id IN NUMBER,
5796 p_rcvShipmentLineID IN NUMBER,
5797 p_transactionSubType IN VARCHAR2,
5798 p_orderByFlag IN VARCHAR2
5799 )
5800 IS
5801 SELECT wdd.delivery_detail_id,
5802 wdd.requested_quantity,
5803 wdd.picked_quantity,
5804 wdd.shipped_quantity,
5805 wdd.received_quantity,
5806 wdd.returned_quantity,
5807 wdd.requested_quantity2,
5808 wdd.picked_quantity2,
5809 wdd.shipped_quantity2,
5810 wdd.received_quantity2,
5811 wdd.returned_quantity2,
5812 wdd.ship_from_location_id,
5813 wdd.earliest_dropoff_date,
5814 wnd.delivery_id,
5815 wdd.rcv_shipment_line_id,
5816 wdd.requested_quantity_uom,
5817 wdd.requested_quantity_uom2,
5818 wdd.released_status,
5819 wdd.src_requested_quantity,
5820 wdd.src_requested_quantity2,
5821 wdd.last_update_date
5822 FROM wsh_delivery_details wdd,
5823 wsh_delivery_assignments_v wda,
5824 wsh_new_deliveries wnd
5825 WHERE wdd.source_code = 'PO'
5826 AND NVL(wdd.line_direction,'O') NOT IN ('O','IO')
5827 AND wdd.source_header_id = p_source_header_id
5828 AND wdd.source_line_id = p_source_line_id
5829 AND wdd.po_shipment_line_id = p_po_shipment_line_id
5830 AND wdd.released_status = p_released_status
5831 AND wdd.delivery_detail_id = wda.delivery_detail_id
5832 AND wda.delivery_id = wnd.delivery_id (+)
5833 AND (
5834 (
5835 p_source_blanket_Reference_id IS NULL
5836 AND wdd.source_blanket_Reference_id IS NULL
5837 )
5838 OR
5839 wdd.source_blanket_Reference_id = p_source_blanket_Reference_id
5840 )
5841 /* bug 3181963
5842 AND (
5843 (
5844 p_shipment_header_id IS NULL
5845 AND wnd.asn_shipment_header_id IS NULL
5846 )
5847 OR
5848 wnd.asn_shipment_header_id = p_shipment_header_id
5849 )
5850 */
5851 AND (
5852 (
5853 p_rcvShipmentLineID IS NULL
5854 AND wdd.rcv_Shipment_Line_ID IS NULL
5855 )
5856 OR
5857 wdd.rcv_Shipment_Line_ID = p_rcvShipmentLineID
5858 )
5859 AND (
5860 (
5861 p_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
5862 AND returned_quantity > 0
5863 )
5864 OR
5865 p_transactionSubType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
5866 )
5867 AND (
5868 (
5869 p_transactionSubType IN (
5870 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE,
5871 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV,
5872 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
5873 )
5874 AND (received_quantity - NVL(returned_quantity,0)) > 0
5875 )
5876 OR
5877 p_transactionSubType NOT IN (
5878 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE,
5879 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV,
5880 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
5881 )
5882 )
5883 -- { IB-Phase-2
5884 AND ( p_ship_from_location_id IS NULL
5885 OR
5886 ( wdd.ship_from_location_id = p_ship_from_location_id
5887 OR
5888 wdd.ship_from_location_id = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
5889 )
5890 )
5891 -- } IB-Phase-2
5892 ORDER BY DECODE
5893 (
5894 wdd.ship_from_location_id,
5895 p_ship_from_location_id, -999,
5896 WSH_UTIL_CORE.C_NULL_SF_LOCN_ID, 1E38,
5897 wdd.ship_from_location_id
5898 ),
5899 DECODE
5900 (
5901 p_orderByFlag,
5902 -1,
5903 wnd.delivery_id,
5904 -- -2,
5905 -- wnd.delivery_id,
5906 p_orderByFlag
5907 ),
5908 DECODE
5909 (
5910 p_orderByFlag,
5911 -1,
5912 NVL(picked_quantity,requested_quantity),
5913 -2,
5914 -1 * shipped_quantity,
5915 -3,
5916 -1 * NVL(returned_quantity,0),
5917 -5,
5918 NVL(returned_quantity,-1E38), --added nvl clause as NULLS LAST was commented
5919 p_orderByFlag
5920 ) DESC, -- NULLS LAST, -- commented nulls last due to pl/sql bug in 8.1.7.4
5921 DECODE
5922 (
5923 p_orderByFlag,
5924 -3,
5925 (received_quantity - NVL(returned_quantity,0)),
5926 -4,
5927 (received_quantity - NVL(returned_quantity,0)),
5928 -5,
5929 (received_quantity - NVL(returned_quantity,0)),
5930 p_orderByFlag
5931 ) DESC; -- NULLS LAST; -- commented nulls last due to pl/sql bug in 8.1.7.4
5932 --wdd.earliest_dropoff_date,
5933 --wnd.delivery_id;
5934 --???r-corr apply to diff of rcv-rtv
5935 --similarly rtv apply to diff of rcv-rtv. i.e. rcv >= rtv always
5936 --
5937 --
5938 -- Check if at least one delivery line exists corresponding to
5939 -- input PO shipment line
5940 --
5941 CURSOR po_line_csr
5942 (
5943 p_source_header_id IN NUMBER,
5944 p_source_line_id IN NUMBER,
5945 p_po_shipment_line_id IN NUMBER,
5946 p_source_blanket_Reference_id IN NUMBER
5947 )
5948 IS
5949 SELECT requested_quantity_uom, requested_quantity_uom2,
5950 src_requested_quantity,src_requested_quantity2
5951 FROM wsh_delivery_details wdd
5952 WHERE wdd.source_code = 'PO'
5953 AND NVL(wdd.line_direction,'O') NOT IN ('O','IO')
5954 AND wdd.source_header_id = p_source_header_id
5955 AND wdd.source_line_id = p_source_line_id
5956 AND wdd.po_shipment_line_id = p_po_shipment_line_id
5957 AND (
5958 (
5959 p_source_blanket_Reference_id IS NULL
5960 AND wdd.source_blanket_Reference_id IS NULL
5961 )
5962 OR
5963 wdd.source_blanket_Reference_id = p_source_blanket_Reference_id
5964 )
5965 --AND rownum = 1;
5966 ORDER BY DECODE(released_status,'D',10,'X',1,'L','2','C',3,4) ASC;
5967 --
5968 --
5969 -- Find initial pickup location of deliveries matched against the receipt
5970 --
5971 CURSOR receipt_locn_csr
5972 (
5973 p_shipment_header_id IN NUMBER
5974 )
5975 IS
5976 SELECT DISTINCT initial_pickup_location_id
5977 FROM wsh_new_deliveries
5978 WHERE rcv_shipment_header_id = p_shipment_header_id;
5979 --
5980 --
5981 -- Check receipt line's matching status
5982 --
5983 CURSOR txn_line_status_csr
5984 (
5985 p_shipment_header_id IN NUMBER,
5986 p_shipment_line_id IN NUMBER
5987 )
5988 IS
5989 SELECT 1
5990 FROM wsh_inbound_txn_history
5991 WHERE shipment_header_id = p_shipment_header_id
5992 AND shipment_line_id = p_shipment_line_id
5993 AND status = WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING;
5994 --
5995 --
5996 -- This cursor is not used
5997 --
5998 CURSOR rcv_line_csr
5999 (
6000 p_source_header_id IN NUMBER,
6001 p_source_line_id IN NUMBER,
6002 p_po_shipment_line_id IN NUMBER,
6003 p_source_blanket_Reference_id IN NUMBER,
6004 p_shipment_line_id IN NUMBER,
6005 p_transactionSubType IN VARCHAR2
6006 )
6007 IS
6008 SELECT COUNT(DISTINCT ship_from_location_id)
6009 FROM wsh_delivery_details wdd
6010 WHERE wdd.source_code = 'PO'
6011 AND NVL(wdd.line_direction,'O') NOT IN ('O','IO')
6012 AND wdd.source_header_id = p_source_header_id
6013 AND wdd.source_line_id = p_source_line_id
6014 AND wdd.po_shipment_line_id = p_po_shipment_line_id
6015 AND (
6016 (
6017 p_source_blanket_Reference_id IS NULL
6018 AND wdd.source_blanket_Reference_id IS NULL
6019 )
6020 OR
6021 wdd.source_blanket_Reference_id = p_source_blanket_Reference_id
6022 )
6023 AND rcv_shipment_line_id = p_shipment_line_id
6024 AND (
6025 (
6026 p_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
6027 AND returned_quantity > 0
6028 )
6029 OR
6030 p_transactionSubType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
6031 )
6032 AND (
6033 (
6034 p_transactionSubType IN (
6035 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE,
6036 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV,
6037 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
6038 )
6039 AND (received_quantity - NVL(returned_quantity,0)) > 0
6040 )
6041 OR
6042 p_transactionSubType NOT IN (
6043 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE,
6044 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV,
6045 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE
6046 )
6047 );
6048
6049 --
6050 --
6051 -- This cursor is not used
6052 --
6053 CURSOR rcv_line_check_csr
6054 (
6055 p_shipment_line_id IN NUMBER
6056 )
6057 IS
6058 SELECT quantity_received
6059 FROM rcv_shipment_lines
6060 WHERE shipment_line_id = p_shipment_line_id;
6061 --
6062 --
6063 --
6064 -- This cursor checks if there are shipped delivery lines corresponding to
6065 -- each record in
6066 -- p_line_rec.
6067 --
6068 CURSOR shipped_line_csr
6069 (
6070 p_source_header_id IN NUMBER,
6071 p_source_line_id IN NUMBER,
6072 p_po_shipment_line_id IN NUMBER,
6073 p_source_blanket_Reference_id IN NUMBER
6074 )
6075 IS
6076 SELECT 1
6077 FROM wsh_delivery_details wdd
6078 WHERE wdd.source_code = 'PO'
6079 AND NVL(wdd.line_direction,'O') NOT IN ('O','IO')
6080 AND wdd.source_header_id = p_source_header_id
6081 AND wdd.source_line_id = p_source_line_id
6082 AND wdd.po_shipment_line_id = p_po_shipment_line_id
6083 AND wdd.released_status = 'C'
6084 AND (
6085 (
6086 p_source_blanket_Reference_id IS NULL
6087 AND wdd.source_blanket_Reference_id IS NULL
6088 )
6089 OR
6090 wdd.source_blanket_Reference_id = p_source_blanket_Reference_id
6091 );
6092 --
6093 -- { IB-Phase-2
6094 CURSOR get_wsh_location_csr (p_hz_location_id NUMBER)
6095 IS
6096 SELECT wsh_location_id
6097 FROM wsh_locations
6098 WHERE source_location_id = p_hz_location_id
6099 AND location_source_code = 'HZ' ;
6100 -- } IB-Phase-2
6101 --
6102 l_num_warnings NUMBER;
6103 l_num_errors NUMBER;
6104 l_return_status VARCHAR2(30);
6105 l_msg_data VARCHAR2(4000);
6106 l_msg_count NUMBER;
6107 --
6108 --
6109 l_index NUMBER;
6110 l_firstIndex NUMBER;
6111 l_lineCount NUMBER;
6112 l_messageStartIndex NUMBER;
6113 l_start_Index NUMBER := 0;
6114 l_end_Index NUMBER := 0;
6115 --l_lastPOShipmentLineId NUMBER;
6116 l_actionCode VARCHAR2(200);
6117 --
6118 --
6119 l_shipmentNumber VARCHAR2(50);
6120 l_receiptNumber VARCHAR2(50);
6121 l_poHeaderNumber VARCHAR2(150);
6122 l_poLineNumber VARCHAR2(150);
6123 l_poShipmentLineNumber NUMBER;
6124 l_poReleaseNumber NUMBER;
6125 l_RCVShipmentHeaderId NUMBER;
6126 --
6127 --
6128 l_headerTransactionId NUMBER;
6129 l_headerObjectVersionNumber NUMBER;
6130 l_headerStatus VARCHAR2(30);
6131 --
6132 --
6133 l_released_status VARCHAR2(30);
6134 l_shipmentHeaderId NUMBER;
6135 l_rcvShipmentLineId NUMBER;
6136 l_transactionDate DATE;
6137 l_shipFromLocationId NUMBER;
6138 l_orderByFlag NUMBER;
6139 l_resetTxnUniqueSFLocn BOOLEAN;
6140 --
6141 --
6142 l_transactionId NUMBER;
6143 l_maxTransactionId NUMBER;
6144 l_minTransactionId NUMBER;
6145 l_minFailedTransactionId NUMBER;
6146 l_minMatchedTransactionId NUMBER;
6147 l_maxRCVTransactionId NUMBER;
6148 l_key NUMBER;
6149 l_count NUMBER;
6150 --
6151 --
6152 --
6153 l_parentTransactionMatched BOOLEAN;
6154 l_transactionMeaning VARCHAR2(100);
6155 --
6156 --
6157 l_txnUniqueSFLocnFound BOOLEAN;
6158 l_txnUniqueSFLocnId NUMBER;
6159 l_txnUniqueSFLocnCode VARCHAR2(100);
6160 --
6161 --
6162 l_lineUniqueSFLocnFound BOOLEAN;
6163 l_lineUniqueSFLocnId NUMBER;
6164 l_linePreviousSFLocnId NUMBER;
6165 l_lineSFLocnId NUMBER;
6166 l_poShipmentLineId NUMBER;
6167 --
6168 --
6169 l_lineRecTbl line_recTbl_type;
6170 l_matchedLineRecTbl WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type;
6171 --
6172 l_linkTbl WSH_UTIL_CORE.char500_tab_type;
6173 l_linkExtTbl WSH_UTIL_CORE.char500_tab_type;
6174 l_linkRecString VARCHAR2(500);
6175 --
6176 l_dlvyTbl WSH_UTIL_CORE.char500_tab_type;
6177 l_dlvyExtTbl WSH_UTIL_CORE.char500_tab_type;
6178 --
6179 --
6180 l_FailedTxnHistory_recTbl WSH_INBOUND_TXN_HISTORY_PKG.inboundTxnHistory_recTbl_type;
6181 l_MatchedTxnHistory_recTbl WSH_INBOUND_TXN_HISTORY_PKG.inboundTxnHistory_recTbl_type;
6182 --
6183 --
6184 l_uniqueShipFromLocationIdTbl WSH_UTIL_CORE.id_tab_type;
6185 --
6186 --
6187 l_min_date DATE;
6188 l_max_date DATE;
6189 l_dummy_min_date DATE;
6190 l_dummy_max_date DATE;
6191 --
6192 --
6193 l_shipFromLocationIdTbl WSH_UTIL_CORE.key_value_tab_type;
6194 l_shipFromLocationIdExtTbl WSH_UTIL_CORE.key_value_tab_type;
6195 l_shipFromLocationIdLineCount NUMBER;
6196 --
6197 --
6198 l_parentTxnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
6199 l_ReceiptAgainstASN VARCHAR2(10);
6200 l_transactionGroup VARCHAR2(50);
6201 l_transactionType VARCHAR2(50);
6202 l_transactionSubType VARCHAR2(50);
6203 --
6204 l_totalReceivedQuantity NUMBER;
6205 l_receiptShipFromLocationCount NUMBER;
6206 l_receiptShipFromLocationId NUMBER;
6207 l_dummy NUMBER;
6208 l_extendBy NUMBER;
6209 l_primaryUOMCode VARCHAR2(10);
6210 l_secondaryUOMCode VARCHAR2(10);
6211 l_src_requested_quantity NUMBER;
6212 l_src_requested_quantity2 NUMBER;
6213 l_messageName VARCHAR2(50);
6214 l_caller VARCHAR2(200);
6215 l_shipped_lines NUMBER;
6216 --
6217 --
6218 l_action_prms1 wsh_glbl_var_strct_grp.dd_action_parameters_rec_type;
6219 l_action_prms2 WSH_BULK_TYPES_GRP.action_parameters_rectype;
6220 l_rtv_corr_out_rec WSH_RCV_CORR_RTV_TXN_PKG.corr_rtv_out_rec_type;
6221 l_po_cancel_rec OE_WSH_BULK_GRP.line_rec_type;
6222 l_po_close_rec OE_WSH_BULK_GRP.line_rec_type;
6223 --
6224 --
6225 l_additional_line_info_rec WSH_BULK_PROCESS_PVT.additional_line_info_rec_type;
6226 l_txnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
6227 l_tab_count NUMBER;
6228 --
6229 l_trx_wsh_location_id NUMBER; -- IB-Phase-2
6230 --
6231 e_endOfAPI EXCEPTION;
6232 e_lineNotMatched EXCEPTION;
6233 --
6234 l_debug_on BOOLEAN;
6235 --
6236 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'MATCHTRANSACTION';
6237 --}
6238 BEGIN
6239 --{
6240 --
6241 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6242 --
6243 IF l_debug_on IS NULL
6244 THEN
6245 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6246 END IF;
6247 --
6248 --
6249 -- Debug Statements
6250 --
6251 IF l_debug_on THEN
6252 WSH_DEBUG_SV.push(l_module_name);
6253 END IF;
6254 --
6255 SAVEPOINT matchTransaction_sp;
6256 --
6257 --
6258 IF p_action_prms.action_code = 'MATCH'
6259 THEN
6260 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
6261 ELSIF p_action_prms.action_code = 'MATCH_ADD'
6262 THEN
6263 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD;
6264 ELSE
6265 l_transactionType := p_action_prms.action_code;
6266 END IF;
6267 --
6268 -- { IB-phase-2
6269 IF p_action_prms.action_code = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
6270 OR p_action_prms.action_code = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
6271 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
6272 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
6273 THEN
6274 WSH_INBOUND_UTIL_PKG.G_ASN_RECEIPT_MATCH_TYPE := 'AUTO';
6275 ELSE
6276 WSH_INBOUND_UTIL_PKG.G_ASN_RECEIPT_MATCH_TYPE := 'MANUAL';
6277 END IF;
6278 -- } IB-phase-2
6279 --
6280 -- { IB-Phase-2
6281 IF p_action_prms.ship_from_location_id IS NOT null
6282 THEN
6283 OPEN get_wsh_location_csr(p_action_prms.ship_from_location_id);
6284 FETCH get_wsh_location_csr INTO l_trx_wsh_location_id;
6285 CLOSE get_wsh_location_csr;
6286
6287 IF l_debug_on THEN
6288 WSH_DEBUG_SV.log(l_module_name,'l_trx_wsh_location_id',l_trx_wsh_location_id);
6289 END IF;
6290
6291 IF l_trx_wsh_location_id IS NULL
6292 THEN
6293 FND_MESSAGE.SET_NAME('WSH','WSH_IB_INVALID_WSH_LOC');
6294 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
6295 RAISE FND_API.G_EXC_ERROR;
6296 END IF;
6297 END IF;
6298 -- } IB-Phase-2
6299 --
6300 l_index := p_line_rec.shipment_line_id.FIRST;
6301 l_firstIndex := l_index;
6302 l_messageStartIndex := NVL(FND_MSG_PUB.COUNT_MSG,0) + 1;
6303 --
6304 --
6305 -- Debug Statements
6306 --
6307 IF l_debug_on THEN
6308 WSH_DEBUG_SV.log(l_module_name,'p_action_prms.action_code',p_action_prms.action_code);
6309 WSH_DEBUG_SV.log(l_module_name,'l_transactionType',l_transactionType);
6310 WSH_DEBUG_SV.log(l_module_name,'p_action_prms.ib_txn_history_id',p_action_prms.ib_txn_history_id);
6311 WSH_DEBUG_SV.log(l_module_name,'Total Input Records',p_line_rec.shipment_line_id.COUNT);
6312 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.VALIDATEMANDATORYINFO',WSH_DEBUG_SV.C_PROC_LEVEL);
6313 END IF;
6314 --
6315 -- Validate mandatory fields required to be passed by Receiving Module
6316 --
6317 WSH_IB_TXN_MATCH_PKG.validateMandatoryInfo
6318 (
6319 p_transactionType => l_transactionType,
6320 p_index => l_index,
6321 x_line_rec => p_line_rec,
6322 x_return_status => l_return_status
6323 );
6324 --
6325 --
6326 -- Debug Statements
6327 --
6328 IF l_debug_on THEN
6329 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6330 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6331 END IF;
6332 --
6333 wsh_util_core.api_post_call
6334 (
6335 p_return_status => l_return_status,
6336 x_num_warnings => l_num_warnings,
6337 x_num_errors => l_num_errors
6338 );
6339 --
6340 --
6341 l_shipmentNumber := p_line_rec.shipment_num(l_index);
6342 l_receiptNumber := p_line_rec.receipt_num(l_index);
6343 --l_receiptNumber := p_line_rec.receipt_num(l_index);
6344 l_RCVShipmentHeaderId := p_line_rec.shipment_header_id(l_index);
6345 --
6346 IF l_debug_on THEN
6347 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_BULK_PROCESS_PVT.Extend_tables',WSH_DEBUG_SV.C_PROC_LEVEL);
6348 END IF;
6349 --
6350 WSH_BULK_PROCESS_PVT.Extend_tables
6351 (
6352 p_line_rec => p_line_rec,
6353 p_action_prms => p_action_prms,
6354 x_table_count => l_tab_count,
6355 x_additional_line_info_rec => l_additional_line_info_rec,
6356 x_return_status => l_return_status
6357 );
6358 --
6359 IF l_debug_on THEN
6360 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6361 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6362 END IF;
6363 --
6364 wsh_util_core.api_post_call
6365 (
6366 p_return_status => l_return_status,
6367 x_num_warnings => l_num_warnings,
6368 x_num_errors => l_num_errors
6369 );
6370 --
6371 --
6372 IF p_line_rec.asn_type(l_index) IN ('ASN','ASBN')
6373 THEN
6374 l_ReceiptAgainstASN := 'Y'; -- Receipt against ASN
6375 ELSE
6376 l_ReceiptAgainstASN := 'N'; -- Direct Receipt
6377 END IF;
6378 --
6379 --
6380 --
6381 -- Debug Statements
6382 --
6383 IF l_debug_on THEN
6384 WSH_DEBUG_SV.log(l_module_name,'l_shipmentNumber',l_shipmentNumber);
6385 WSH_DEBUG_SV.log(l_module_name,'l_receiptNumber',l_receiptNumber);
6386 WSH_DEBUG_SV.log(l_module_name,'l_RCVShipmentHeaderId',l_RCVShipmentHeaderId);
6387 WSH_DEBUG_SV.log(l_module_name,'l_messageStartIndex',l_messageStartIndex);
6388 WSH_DEBUG_SV.log(l_module_name,'l_ReceiptAgainstASN',l_ReceiptAgainstASN);
6389 WSH_DEBUG_SV.log(l_module_name,'RCV TXN ID at FIRST',p_line_rec.rcv_transaction_id(p_line_rec.rcv_transaction_id.FIRST));
6390 WSH_DEBUG_SV.log(l_module_name,'RCV TXN ID at LAST',p_line_rec.rcv_transaction_id(p_line_rec.rcv_transaction_id.LAST));
6391 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GETTRANSACTIONTYPEMEANING',WSH_DEBUG_SV.C_PROC_LEVEL);
6392 END IF;
6393 --
6394 --
6395 --
6396 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
6397 THEN
6398 --{
6399 IF l_debug_on THEN
6400 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GET_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
6401 END IF;
6402 --
6403 -- Check if record already exists in WSH_INBOUND_TXN_HISTORY
6404 --
6405 WSH_INBOUND_TXN_HISTORY_PKG.get_txn_history
6406 (
6407 p_shipment_header_id => p_line_rec.shipment_header_id(l_index),
6408 p_transaction_type => WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT,
6409 x_txn_history_rec => l_txnHistoryRec,
6410 x_return_status => l_return_status
6411 );
6412 --
6413 --
6414 --
6415 -- Debug Statements
6416 --
6417 IF l_debug_on THEN
6418 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6419 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6420 END IF;
6421 --
6422 wsh_util_core.api_post_call
6423 (
6424 p_return_status => l_return_status,
6425 x_num_warnings => l_num_warnings,
6426 x_num_errors => l_num_errors
6427 );
6428 --
6429 IF l_txnHistoryRec.transaction_id IS NULL
6430 THEN
6431 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
6432 END IF;
6433 --}
6434 END IF;
6435 --
6436 --
6437 WSH_INBOUND_TXN_HISTORY_PKG.getTransactionTypeMeaning
6438 (
6439 p_transactionType => l_transactionType,
6440 x_transactionMeaning => l_transactionMeaning,
6441 x_return_status => l_return_status
6442 );
6443 --
6444 --
6445 --
6446 -- Debug Statements
6447 --
6448 IF l_debug_on THEN
6449 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6450 WSH_DEBUG_SV.log(l_module_name,'l_transactionType-Final',l_transactionType);
6451 WSH_DEBUG_SV.log(l_module_name,'l_transactionMeaning',l_transactionMeaning);
6452 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6453 END IF;
6454 --
6455 wsh_util_core.api_post_call
6456 (
6457 p_return_status => l_return_status,
6458 x_num_warnings => l_num_warnings,
6459 x_num_errors => l_num_errors
6460 );
6461 --
6462 --
6463 --
6464 -- Debug Statements
6465 --
6466 IF l_debug_on THEN
6467 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.CHECKSHIPMENTHISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
6468 END IF;
6469 --
6470 -- Check Shipment History
6471 -- In case of ASN/Receipt, check if same transaction is not being interfaced again.
6472 -- In case of child transactions, find out its parent transaction (and its status)
6473 --
6474 WSH_IB_TXN_MATCH_PKG.checkShipmentHistory
6475 (
6476 p_transactionType => l_transactionType,
6477 p_shipmentHeaderId => p_line_rec.shipment_header_id(l_index),
6478 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
6479 p_inboundTxnHistoryId => p_action_prms.ib_txn_history_id,
6480 p_line_rec => p_line_rec,
6481 p_ship_from_location_id => l_trx_wsh_location_id, -- IB-Phase-2
6482 x_parentTxnHistoryRec => l_parentTxnHistoryRec,
6483 x_transactionId => l_transactionId,
6484 x_transactionGroup => l_transactionGroup,
6485 x_return_status => l_return_status
6486 );
6487 --
6488 --
6489 --
6490 -- Debug Statements
6491 --
6492 IF l_debug_on THEN
6493 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6494 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6495 END IF;
6496 --
6497 wsh_util_core.api_post_call
6498 (
6499 p_return_status => l_return_status,
6500 x_num_warnings => l_num_warnings,
6501 x_num_errors => l_num_errors
6502 );
6503 --
6504 --
6505 IF l_transactionType IN (
6506 WSH_INBOUND_TXN_HISTORY_PKG.C_ASN,
6507 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
6508 )
6509 THEN
6510 l_headerTransactionId := l_transactionId;
6511 l_headerObjectVersionNumber := 1;
6512 l_headerStatus := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING;
6513 ELSE
6514 l_headerTransactionId := l_parentTxnHistoryRec.transaction_id;
6515 l_headerObjectVersionNumber := l_parentTxnHistoryRec.object_version_number;
6516 l_headerStatus := l_parentTxnHistoryRec.status;
6517 END IF;
6518 --
6519 IF NVL(l_parentTxnHistoryRec.status,'MATCHED') LIKE 'MATCHED%'
6520 THEN
6521 l_parentTransactionMatched := TRUE;
6522 ELSE
6523 l_parentTransactionMatched := FALSE;
6524 END IF;
6525 --
6526 --
6527 IF l_debug_on THEN
6528 WSH_DEBUG_SV.log(l_module_name,'l_headerTransactionId',l_headerTransactionId);
6529 WSH_DEBUG_SV.log(l_module_name,'l_headerObjectVersionNumber',l_headerObjectVersionNumber);
6530 WSH_DEBUG_SV.log(l_module_name,'l_headerStatus',l_headerStatus);
6531 WSH_DEBUG_SV.log(l_module_name,'l_parentTransactionMatched',l_parentTransactionMatched);
6532 END IF;
6533 --
6534 --
6535 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_CANCEL_ASN
6536 THEN
6537 --{
6538 --
6539 -- Debug Statements
6540 --
6541 IF l_debug_on THEN
6542 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.PROCESSCANCELASN',WSH_DEBUG_SV.C_PROC_LEVEL);
6543 END IF;
6544 --
6545 WSH_IB_TXN_MATCH_PKG.processCancelASN
6546 (
6547 x_parentTxnHistoryRec => l_parentTxnHistoryRec,
6548 x_return_status => l_return_status
6549 );
6550 --
6551 --
6552 --
6553 -- Debug Statements
6554 --
6555 IF l_debug_on THEN
6556 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6557 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6558 END IF;
6559 --
6560 wsh_util_core.api_post_call
6561 (
6562 p_return_status => l_return_status,
6563 x_num_warnings => l_num_warnings,
6564 x_num_errors => l_num_errors
6565 );
6566 --
6567 RAISE e_endOfAPI;
6568 --}
6569 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_HEADER_UPD
6570 THEN
6571 --{
6572 IF l_parentTxnHistoryRec.transaction_id IS NULL
6573 THEN
6574 --{
6575 --
6576 -- Debug Statements
6577 --
6578 IF l_debug_on THEN
6579 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.INSERTTRANSACTIONHISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
6580 END IF;
6581 --
6582 -- Insert record into WSH_INBOUND_TXN_HISTORY for the receipt
6583 -- It is possible that during earlier receipt interface processing
6584 -- some fatal error was encountered and transaction was lost
6585 -- So, now insert it and keep it pending
6586 --
6587 WSH_IB_TXN_MATCH_PKG.insertTransactionHistory
6588 (
6589 p_transactionType => WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT,
6590 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
6591 p_autonomous => TRUE,
6592 p_index => p_line_rec.shipment_line_id.FIRST,
6593 p_line_rec => p_line_rec,
6594 p_ship_from_location_id => l_trx_wsh_location_id, -- IB-Phase-2
6595 x_transactionId => l_transactionId,
6596 x_return_status => l_return_status
6597 );
6598 --
6599 --
6600 -- Debug Statements
6601 --
6602 IF l_debug_on THEN
6603 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6604 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6605 END IF;
6606 --
6607 wsh_util_core.api_post_call
6608 (
6609 p_return_status => l_return_status,
6610 x_num_warnings => l_num_warnings,
6611 x_num_errors => l_num_errors
6612 );
6613 --
6614 --
6615 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
6616 l_headerTransactionId := l_transactionId;
6617 --
6618 --
6619 --
6620 -- Debug Statements
6621 --
6622 IF l_debug_on THEN
6623 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GETTRANSACTIONTYPEMEANING',WSH_DEBUG_SV.C_PROC_LEVEL);
6624 END IF;
6625 --
6626 WSH_INBOUND_TXN_HISTORY_PKG.getTransactionTypeMeaning
6627 (
6628 p_transactionType => l_transactionType,
6629 x_transactionMeaning => l_transactionMeaning,
6630 x_return_status => l_return_status
6631 );
6632 --
6633 --
6634 --
6635 -- Debug Statements
6636 --
6637 IF l_debug_on THEN
6638 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6639 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6640 END IF;
6641 --
6642 wsh_util_core.api_post_call
6643 (
6644 p_return_status => l_return_status,
6645 x_num_warnings => l_num_warnings,
6646 x_num_errors => l_num_errors
6647 );
6648 --
6649 --
6650 RAISE e_notMatched;
6651 --}
6652 ELSE
6653 --{
6654 IF l_debug_on THEN
6655 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE WSH_INBOUND_TXN_HISTORY-R-HDR-UPD');
6656 WSH_DEBUG_SV.log(l_module_name,'l_RCVShipmentHeaderId',l_RCVShipmentHeaderId);
6657 END IF;
6658 --
6659 --
6660 UPDATE WSH_INBOUND_TXN_HISTORY
6661 SET OBJECT_VERSION_NUMBER = NVL(OBJECT_VERSION_NUMBER,0) + 1,
6662 SHIPMENT_NUMBER = l_shipmentNumber,
6663 RECEIPT_NUMBER = l_receiptNumber,
6664 LAST_UPDATE_DATE = SYSDATE,
6665 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
6666 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
6667 WHERE SHIPMENT_HEADER_ID = l_RCVShipmentHeaderId
6668 AND TRANSACTION_TYPE NOT IN ('ROUTING_RESPONSE','ROUTING_REQUEST');
6669 --
6670 IF SQL%ROWCOUNT = 0
6671 THEN
6672 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_HDR_UPD_ERROR');
6673 FND_MESSAGE.SET_TOKEN('SHIPMENT_HEADER_ID',l_RCVShipmentHeaderId);
6674 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
6675 RAISE FND_API.G_EXC_ERROR;
6676 END IF;
6677 --
6678 --
6679 IF l_parentTransactionMatched
6680 THEN
6681 NULL;
6682 --TODO LATER
6683 END IF;
6684 --}
6685 END IF;
6686 --
6687 RAISE e_endOfAPI;
6688 --}
6689 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
6690 AND l_ReceiptAgainstASN = 'Y'
6691 AND NOT(l_parentTransactionMatched)
6692 THEN
6693 --{
6694 --
6695 -- Cannot match receipt until parent ASN is matched
6696 --
6697 FND_MESSAGE.SET_NAME('WSH','WSH_IB_PENDING_ASN_MATCH');
6698 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
6699 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
6700 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
6701 --
6702 RAISE e_notMatched;
6703 --}
6704 END IF;
6705 /*
6706 if rcv-c,rtv,rtv-c,rcv-a
6707 check if rsl is pending
6708 if so set rsl_pend=true
6709 */
6710 --
6711 -- { IB-Phase-2
6712 -- ASN / Receipt has ShipFromLocation at Header Level.
6713 IF l_trx_wsh_location_id IS NOT NULL
6714 THEN
6715 l_txnUniqueSFLocnFound := TRUE;
6716 l_txnUniqueSFLocnId := l_trx_wsh_location_id;
6717 ELSE
6718 l_txnUniqueSFLocnFound := FALSE;
6719 l_txnUniqueSFLocnId := NULL;
6720 END IF;
6721 -- } IB-Phase-2
6722 l_maxTransactionId := -1;
6723 l_minTransactionId := 1E38;
6724 l_minFailedTransactionId := 1E38;--- tbe set in line fail excep
6725 l_minMatchedTransactionId := 1E38;
6726 --l_lastMatchedTransactionId := NULL; ??----to be set at end of loop
6727 --
6728 -- Loop through each input line
6729 --
6730 WHILE l_index IS NOT NULL
6731 LOOP
6732 --{
6733 IF l_debug_on THEN
6734 WSH_DEBUG_SV.log(l_module_name,'Processing p_line_rec at l_index',l_index);
6735 END IF;
6736 --
6737 --
6738 IF l_index <> l_firstIndex
6739 THEN
6740 --{
6741 --
6742 -- Debug Statements
6743 --
6744 IF l_debug_on THEN
6745 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.VALIDATEMANDATORYINFO',WSH_DEBUG_SV.C_PROC_LEVEL);
6746 END IF;
6747 --
6748 WSH_IB_TXN_MATCH_PKG.validateMandatoryInfo
6749 (
6750 p_transactionType => l_transactionType,
6751 p_index => l_index,
6752 x_line_rec => p_line_rec,
6753 x_return_status => l_return_status
6754 );
6755 --
6756 --
6757 -- Debug Statements
6758 --
6759 IF l_debug_on THEN
6760 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6761 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6762 END IF;
6763 --
6764 wsh_util_core.api_post_call
6765 (
6766 p_return_status => l_return_status,
6767 x_num_warnings => l_num_warnings,
6768 x_num_errors => l_num_errors
6769 );
6770 --}
6771 END IF;
6772 --
6773 --
6774 l_poShipmentLineId := p_line_rec.po_shipment_line_id(l_index);
6775 l_key := NULL;
6776 --
6777 l_poHeaderNumber := p_line_rec.source_header_number(l_index);
6778 l_poLineNumber := p_line_rec.source_line_number(l_index);
6779 l_poShipmentLineNumber := p_line_rec.po_shipment_line_number(l_index);
6780 l_poReleaseNumber := p_line_rec.source_blanket_reference_num(l_index);
6781 l_transactionId := p_line_rec.rcv_transaction_id(l_index);
6782 --
6783 l_maxTransactionId := GREATEST( l_maxTransactionId, l_transactionId);
6784 l_minTransactionId := LEAST( l_minTransactionId, l_transactionId);
6785 --
6786 --
6787 IF l_debug_on THEN
6788 WSH_DEBUG_SV.log(l_module_name,'l_poShipmentLineId',l_poShipmentLineId);
6789 WSH_DEBUG_SV.log(l_module_name,'l_transactionId',l_transactionId);
6790 WSH_DEBUG_SV.log(l_module_name,'MIN TxnID, Max TxnID',l_minTransactionId ||',' ||l_maxTransactionId);
6791 WSH_DEBUG_SV.log(l_module_name,'PO Ref.Numbers:HDR|REL|LINE|PSL',
6792 l_poHeaderNumber
6793 || '|'
6794 || l_poReleaseNumber
6795 || '|'
6796 || l_poLineNumber
6797 || '|'
6798 || l_poShipmentLineNumber
6799 );
6800 WSH_DEBUG_SV.log(l_module_name,'PO Ref.IDs:HDR|REL|LINE|PSL',
6801 p_line_rec.header_id(l_index)
6802 || '|'
6803 || p_line_rec.source_blanket_reference_id(l_index)
6804 || '|'
6805 || p_line_rec.line_id(l_index)
6806 || '|'
6807 || p_line_rec.po_shipment_line_id(l_index)
6808 );
6809
6810 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.shipment_header_id',p_line_rec.shipment_header_id(l_index));
6811 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.shipment_line_id',p_line_rec.shipment_line_id(l_index));
6812 END IF;
6813 --
6814 --
6815 BEGIN
6816 --{
6817 /*
6818 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
6819 AND l_ReceiptAgainstASN = 'Y'
6820 THEN
6821 --{
6822 OPEN rcv_line_check_csr( p_line_rec.shipment_line_id(l_index) );
6823 --
6824 FETCH rcv_line_check_csr INTO l_totalReceivedQuantity;
6825 --
6826 IF rcv_line_check_csr%NOTFOUND
6827 THEN
6828 --{
6829 FND_MESSAGE.SET_NAME('WSH','WSH_IB_RSL_NOT_FOUND');
6830 FND_MESSAGE.SET_TOKEN('RCV_SHIPMENT_LINE_ID',p_line_rec.shipment_line_id(l_index));
6831 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
6832 RAISE FND_API.G_EXC_ERROR;
6833 --}
6834 END IF;
6835 --
6836 --
6837 IF l_debug_on THEN
6838 WSH_DEBUG_SV.log(l_module_name,'l_totalReceivedQuantity',l_totalReceivedQuantity);
6839 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.received_quantity',p_line_rec.received_quantity(l_index));
6840 END IF;
6841 --
6842 --
6843 IF l_totalReceivedQuantity <> p_line_rec.received_quantity(l_index)
6844 THEN
6845 --{
6846 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION;
6847 --
6848 --
6849 --
6850 -- Debug Statements
6851 --
6852 IF l_debug_on THEN
6853 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GETTRANSACTIONTYPEMEANING',WSH_DEBUG_SV.C_PROC_LEVEL);
6854 END IF;
6855 --
6856 WSH_INBOUND_TXN_HISTORY_PKG.getTransactionTypeMeaning
6857 (
6858 p_transactionType => l_transactionType,
6859 x_transactionMeaning => l_transactionMeaning,
6860 x_return_status => l_return_status
6861 );
6862 --
6863 --
6864 --
6865 -- Debug Statements
6866 --
6867 IF l_debug_on THEN
6868 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6869 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6870 END IF;
6871 --
6872 wsh_util_core.api_post_call
6873 (
6874 p_return_status => l_return_status,
6875 x_num_warnings => l_num_warnings,
6876 x_num_errors => l_num_errors
6877 );
6878 --}
6879 END IF;
6880 --}
6881 END IF;
6882 */
6883 --
6884 --
6885 /*
6886 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION
6887 THEN
6888 IF p_line_rec.received_quantity(l_index) > 0
6889 THEN
6890 l_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE;
6891 ELSE
6892 l_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE;
6893 END IF;
6894 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION
6895 THEN
6896 IF p_line_rec.received_quantity(l_index) > 0
6897 THEN
6898 l_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_POSITIVE;
6899 ELSE
6900 l_transactionSubType := WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE;
6901 END IF;
6902 ELSE
6903 l_transactionSubType := l_transactionType;
6904 END IF;
6905 */
6906 --
6907 IF l_debug_on THEN
6908 WSH_DEBUG_SV.log(l_module_name,'l_transactionType',l_transactionType);
6909 --WSH_DEBUG_SV.log(l_module_name,'l_transactionSubType',l_transactionSubType);
6910 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.GETTRANSACTIONKEY',WSH_DEBUG_SV.C_PROC_LEVEL);
6911 END IF;
6912 --
6913 -- Key for each input line can be PLL/RSL ID
6914 --
6915 WSH_IB_TXN_MATCH_PKG.getTransactionKey
6916 (
6917 p_transactionType => l_transactionType,
6918 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
6919 p_index => l_index,
6920 p_line_rec => p_line_rec,
6921 x_key => l_key,
6922 x_transactionSubType => l_transactionSubType,
6923 x_return_status => l_return_status
6924 );
6925 --
6926 --
6927 -- Debug Statements
6928 --
6929 IF l_debug_on THEN
6930 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6931 WSH_DEBUG_SV.log(l_module_name,'l_key',l_key);
6932 WSH_DEBUG_SV.log(l_module_name,'l_transactionSubType',l_transactionSubType);
6933 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6934 END IF;
6935 --
6936 wsh_util_core.api_post_call
6937 (
6938 p_return_status => l_return_status,
6939 x_num_warnings => l_num_warnings,
6940 x_num_errors => l_num_errors
6941 );
6942 --
6943 --
6944 IF NOT(l_parentTransactionMatched)
6945 THEN
6946 --{
6947 --
6948 -- Cannot match child transaction until parent(receipt) transaction has matched
6949 --
6950 l_messageName := 'WSH_IB_PEND_PARENT_TXN_MATCH';
6951 RAISE e_lineNotMatched;
6952 --}
6953 END IF;
6954 --
6955 --
6956 --
6957 -- Debug Statements
6958 --
6959 IF l_debug_on THEN
6960 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_linkTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
6961 END IF;
6962 --
6963 -- Check if key is already processed in the current call(execution)
6964 --
6965 wsh_util_core.get_cached_value
6966 (
6967 p_cache_tbl => l_linkTbl,
6968 p_cache_ext_tbl => l_linkExtTbl,
6969 p_key => l_key, --l_poShipmentLineId,
6970 p_value => l_linkRecString,
6971 p_action => 'GET',
6972 x_return_status => l_return_status
6973 );
6974 --
6975 IF l_debug_on THEN
6976 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6977 END IF;
6978 --
6979 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
6980 THEN
6981 RAISE FND_API.G_EXC_ERROR;
6982 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
6983 THEN
6984 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6985 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
6986 THEN
6987 --{
6988 -- Since key is not already processed in the current call(execution),
6989 -- let's set the query conditions(depending on transaction type)
6990 -- to obtain corresponding lines from delivery details
6991 -- which can be further evaluated for matching
6992 --
6993 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
6994 THEN
6995 --{
6996 l_released_status := 'X';
6997 l_shipmentHeaderId := NULL;
6998 l_rcvShipmentLineId := NULL;
6999 --l_key := l_poShipmentLineId;
7000 l_transactionDate := p_line_rec.shipped_date(l_index);
7001 l_shipFromLocationId := l_trx_wsh_location_id; -- IB-Phase-2 NULL;
7002 l_orderByFlag := -1;
7003 l_resetTxnUniqueSFLocn := FALSE;
7004 --}
7005 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7006 THEN
7007 --{
7008 IF l_ReceiptAgainstASN = 'Y'
7009 THEN
7010 l_released_status := 'C';
7011 l_shipmentHeaderId := l_parentTxnHistoryRec.shipment_header_id;
7012 l_rcvShipmentLineId := p_line_rec.shipment_line_id(l_index);
7013 --l_key := l_rcvShipmentLineId;
7014 l_orderByFlag := -2;
7015 --IB-PHASE-2
7016 IF l_trx_wsh_location_id IS NULL
7017 THEN
7018 l_resetTxnUniqueSFLocn := TRUE;
7019 ELSE
7020 l_resetTxnUniqueSFLocn := FALSE;
7021 END IF;
7022 --IB-PHASE-2
7023 --
7024 --
7025 --l_txnUniqueSFLocnFound := TRUE;
7026 --l_txnUniqueSFLocnId := WSH_UTIL_CORE.C_NULL_SF_LOCN_ID;
7027 ELSE
7028 l_released_status := 'X';
7029 l_shipmentHeaderId := NULL;
7030 l_rcvShipmentLineId := NULL;
7031 --l_key := l_poShipmentLineId;
7032 l_orderByFlag := -1;
7033 l_resetTxnUniqueSFLocn := FALSE;
7034 END IF;
7035 --
7036 l_transactionDate := p_line_rec.expected_receipt_date(l_index);
7037 l_shipFromLocationId := l_trx_wsh_location_id; -- IB-Phase-2 NULL;
7038 --}
7039 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7040 THEN
7041 --{
7042 IF l_receiptShipFromLocationCount IS NULL
7043 THEN
7044 --{
7045 l_receiptShipFromLocationCount := 0;
7046 --
7047 -- For add to receipt case,
7048 -- find out if receipt matched against with all
7049 -- deliveries having same ship-from location
7050 -- or deliveries with different ship-from location
7051 --
7052 -- If receipt matched against only one ship-from
7053 -- location, then that is the unique ship-from
7054 -- location for add-to-receipt transaction as well
7055 -- and we need to find delivery lines with that particular
7056 -- ship-from location
7057 --
7058 FOR receipt_locn_rec IN receipt_locn_csr (p_line_rec.shipment_header_id(l_index))
7059 LOOP
7060 --{
7061 l_receiptShipFromLocationCount := l_receiptShipFromLocationCount + 1;
7062 l_receiptShipFromLocationId := receipt_locn_rec.initial_pickup_location_id;
7063 --}
7064 END LOOP;
7065 --}
7066 END IF;
7067 --
7068 --
7069 IF l_debug_on THEN
7070 WSH_DEBUG_SV.log(l_module_name,'l_receiptShipFromLocationId',l_receiptShipFromLocationId);
7071 END IF;
7072 --
7073 --
7074 IF l_receiptShipFromLocationCount = 0
7075 THEN
7076 --{
7077 l_messageName := 'WSH_IB_PARENT_MATCH_NOT_FOUND';
7078 RAISE e_lineNotMatched;---- exit of api as we should not continue for another line
7079 --}
7080 END IF;
7081 --
7082 --
7083 l_released_status := 'X';
7084 l_transactionDate := p_line_rec.expected_receipt_date(l_index);
7085 l_shipmentHeaderId := NULL;
7086 l_rcvShipmentLineId := NULL;
7087 --l_key := l_poShipmentLineId;
7088 l_orderByFlag := -1;
7089 l_shipFromLocationId := l_trx_wsh_location_id; -- IB-Phase-2 NULL;
7090 --IB-PHASE-2
7091 IF l_trx_wsh_location_id IS NULL
7092 THEN
7093 l_resetTxnUniqueSFLocn := TRUE;
7094 ELSE
7095 l_resetTxnUniqueSFLocn := FALSE;
7096 END IF;
7097 --IB-PHASE-2
7098 --
7099 IF l_receiptShipFromLocationCount = 1
7100 THEN
7101 --{
7102 l_txnUniqueSFLocnFound := TRUE;
7103 -- { IB-Phase-2
7104 IF l_trx_wsh_location_id IS NULL
7105 THEN
7106 l_txnUniqueSFLocnId := l_receiptShipFromLocationId;
7107 END IF;
7108 -- } IB-Phase-2
7109 --l_shipFromLocationId := l_receiptShipFromLocationId;
7110 l_resetTxnUniqueSFLocn := FALSE;
7111 --}
7112 END IF;
7113 --
7114 /*
7115 IF l_receiptShipFromLocationCount = 1
7116 THEN
7117 --{
7118 l_released_status := 'X';
7119 l_transactionDate := p_line_rec.expected_receipt_date(l_index);
7120 l_shipmentHeaderId := NULL;
7121 l_rcvShipmentLineId := NULL;
7122 l_key := l_poShipmentLineId;
7123 l_txnUniqueSFLocnFound := TRUE;
7124 l_txnUniqueSFLocnId := l_receiptShipFromLocationId;
7125 l_shipFromLocationId := l_receiptShipFromLocationId;
7126 --}
7127 ELSIF l_receiptShipFromLocationCount > 1
7128 THEN
7129 --{
7130 FND_MESSAGE.SET_NAME('WSH','WSH_IB_PARENT_MULTI_SF_MATCH');
7131 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',p_action_prms.action_code);
7132 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
7133 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
7134 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
7135 --
7136 RAISE e_lineNotMatched;
7137 --}
7138 END IF;
7139 */
7140 --}
7141 ELSIF l_transactionType IN (
7142 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION,
7143 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV ,
7144 WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION
7145 )
7146 THEN
7147 --{
7148 l_released_status := 'L';
7149 l_transactionDate := p_line_rec.expected_receipt_date(l_index);
7150 l_shipmentHeaderId := NULL;
7151 l_rcvShipmentLineId := p_line_rec.shipment_line_id(l_index);
7152 --l_key := l_rcvShipmentLineId;
7153 --IB-PHASE-2
7154 IF l_trx_wsh_location_id IS NULL
7155 THEN
7156 l_resetTxnUniqueSFLocn := TRUE;
7157 ELSE
7158 l_resetTxnUniqueSFLocn := FALSE;
7159 END IF;
7160 --IB-PHASE-2
7161 l_shipFromLocationId := l_trx_wsh_location_id; -- IB-Phase-2 NULL;
7162 --
7163 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
7164 OR l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RTV_CORRECTION_NEGATIVE
7165 THEN
7166 l_orderByFlag := -3;
7167 ELSIF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_NEGATIVE
7168 THEN
7169 l_orderByFlag := -4;
7170 ELSE
7171 l_orderByFlag := -5;
7172 END IF;
7173 --
7174 --
7175 l_dummy := 0;
7176 --
7177 -- Check if parent receipt line is pending matching
7178 --
7179 OPEN txn_line_status_csr
7180 (
7181 p_shipment_header_id => p_line_rec.shipment_header_id(l_index),
7182 p_shipment_line_id => l_rcvShipmentLineId
7183 );
7184 FETCH txn_line_status_csr INTO l_dummy;
7185 CLOSE txn_line_status_csr;
7186 --
7187 IF l_dummy = 1
7188 THEN
7189 --{
7190 -- Cannot match child transaction until parent receipt
7191 -- line has matched
7192 --
7193 l_messageName := 'WSH_IB_PEND_PARENT_LINE_MATCH';
7194 RAISE e_lineNotMatched;
7195 --}
7196 END IF;
7197 --
7198 --
7199 /*
7200 l_dummy := 0;
7201 --
7202 OPEN rcv_line_csr
7203 (
7204 p_source_header_id => p_line_rec.header_id(l_index),
7205 p_source_line_id => p_line_rec.line_id(l_index),
7206 p_po_shipment_line_id => p_line_rec.po_shipment_line_id(l_index),
7207 p_source_blanket_Reference_id => p_line_rec.source_blanket_reference_id(l_index),
7208 p_shipment_line_id => l_rcvShipmentLineId,
7209 p_transactionSubType => l_transactionSubType
7210 );
7211 FETCH rcv_line_csr INTO l_dummy;
7212 CLOSE rcv_line_csr;
7213 --
7214 IF l_dummy > 1
7215 THEN
7216 --{
7217 l_messageName := 'WSH_IB_PARNT_LIN_MULT_SF_MATCH';
7218
7219 RAISE e_lineNotMatched;
7220 --}
7221 ELSIF l_dummy = 0
7222 THEN
7223 RAISE e_lineFatalError;
7224 END IF;
7225 */
7226 --}
7227 END IF;
7228 --
7229 --
7230 IF l_debug_on THEN
7231 WSH_DEBUG_SV.log(l_module_name,'l_released_status',l_released_status);
7232 WSH_DEBUG_SV.log(l_module_name,'l_shipmentHeaderId',l_shipmentHeaderId);
7233 WSH_DEBUG_SV.log(l_module_name,'l_shipFromLocationId',l_shipFromLocationId);
7234 WSH_DEBUG_SV.log(l_module_name,'l_rcvShipmentLineId',l_rcvShipmentLineId);
7235 WSH_DEBUG_SV.log(l_module_name,'l_orderByFlag',l_orderByFlag);
7236 WSH_DEBUG_SV.log(l_module_name,'l_resetTxnUniqueSFLocn',l_resetTxnUniqueSFLocn);
7237 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnFound',l_txnUniqueSFLocnFound);
7238 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnId',l_txnUniqueSFLocnId);
7239 END IF;
7240 --
7241 --
7242 IF p_action_prms.action_code IN ( 'MATCH','MATCH_ADD')
7243 THEN
7244 --{
7245 l_shipped_lines := 0;
7246 --
7247 OPEN shipped_line_csr
7248 (
7249 p_source_header_id => p_line_rec.header_id(l_index),
7250 p_source_line_id => p_line_rec.line_id(l_index),
7251 p_po_shipment_line_id => p_line_rec.po_shipment_line_id(l_index),
7252 p_source_blanket_Reference_id => p_line_rec.source_blanket_reference_id(l_index)
7253 );
7254 --
7255 FETCH shipped_line_csr INTO l_shipped_lines;
7256 CLOSE shipped_line_csr;
7257 --
7258 IF l_shipped_lines > 0
7259 THEN
7260 --{
7261 IF p_action_prms.action_code = 'MATCH_ADD'
7262 THEN
7263 --{
7264 l_messageName := 'WSH_IB_NOT_MATCH_SHP_LINES';
7265 RAISE e_lineNotMatched;
7266 --}
7267 ELSE
7268 --{
7269 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_MATCH_SHP_LINES');
7270 --
7271 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
7272 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
7273 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
7274 --
7275 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
7276 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
7277 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
7278 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
7279 --
7280 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
7281 --
7282 RAISE e_NotMatched;
7283 --}
7284 END IF;
7285 --}
7286 END IF;
7287 --}
7288 END IF;
7289 --
7290 --
7291 -- Fetch delivery lines corresponding to input ASN/Receipt lines
7292 --
7293 OPEN line_csr
7294 (
7295 p_source_header_id => p_line_rec.header_id(l_index),
7296 p_source_line_id => p_line_rec.line_id(l_index),
7297 p_po_shipment_line_id => p_line_rec.po_shipment_line_id(l_index),
7298 p_source_blanket_Reference_id => p_line_rec.source_blanket_reference_id(l_index),
7299 p_released_status => l_released_status,
7300 p_shipment_header_id => l_shipmentHeaderId,
7301 p_ship_from_location_id => l_shipFromLocationId,
7302 p_rcvShipmentLineID => l_rcvShipmentLineId,
7303 p_transactionSubType => l_transactionSubType,
7304 p_orderByFlag => l_orderByFlag
7305 );
7306 --
7307 FETCH line_csr BULK COLLECT
7308 INTO --l_lineRecTbl; -- replaced due to 8.1.7.4 pl/sql bug
7309 l_lineRecTbl.delivery_detail_id_tbl,
7310 l_lineRecTbl.requested_quantity_tbl,
7311 l_lineRecTbl.picked_quantity_tbl,
7312 l_lineRecTbl.shipped_quantity_tbl,
7313 l_lineRecTbl.received_quantity_tbl,
7314 l_lineRecTbl.returned_quantity_tbl,
7315 l_lineRecTbl.requested_quantity2_tbl,
7316 l_lineRecTbl.picked_quantity2_tbl,
7317 l_lineRecTbl.shipped_quantity2_tbl,
7318 l_lineRecTbl.received_quantity2_tbl,
7319 l_lineRecTbl.returned_quantity2_tbl,
7320 l_lineRecTbl.ship_from_location_id_tbl,
7321 l_lineRecTbl.earliest_dropoff_date_tbl,
7322 l_lineRecTbl.delivery_id_tbl,
7323 l_lineRecTbl.rcv_shipment_line_id_tbl,
7324 l_lineRecTbl.requested_quantity_uom_tbl,
7325 l_lineRecTbl.requested_quantity_uom2_tbl,
7326 l_lineRecTbl.released_status_tbl,
7327 l_lineRecTbl.src_requested_quantity_tbl,
7328 l_lineRecTbl.src_requested_quantity2_tbl,
7329 l_lineRecTbl.last_update_date_tbl;
7330 --
7331 l_lineCount := line_csr%ROWCOUNT;
7332 --
7333 CLOSE line_csr;
7334 --
7335 --
7336 IF l_debug_on THEN
7337 WSH_DEBUG_SV.log(l_module_name,'l_lineCount',l_lineCount);
7338 END IF;
7339 --
7340 IF l_lineCount = 0
7341 THEN
7342 --{
7343 -- No eligible delivery lines found corresponding to input ASN/Receipt line
7344 -- Check if there is at least one line corresponding
7345 -- to PO shipment line
7346 -- If yes, it may be case of over-receipt and let's
7347 -- create a new line with ordered qty. of 0.
7348 -- If not, this may be an error
7349 --
7350 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
7351 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7352 OR (
7353 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7354 AND l_ReceiptAgainstASN <> 'Y'
7355 )
7356 THEN
7357 --{
7358 OPEN po_line_csr
7359 (
7360 p_source_header_id => p_line_rec.header_id(l_index),
7361 p_source_line_id => p_line_rec.line_id(l_index),
7362 p_po_shipment_line_id => p_line_rec.po_shipment_line_id(l_index),
7363 p_source_blanket_Reference_id => p_line_rec.source_blanket_reference_id(l_index)
7364 );
7365 --
7366 FETCH po_line_csr INTO l_primaryUOMCode, l_secondaryUOMCode,
7367 l_src_requested_quantity, l_src_requested_quantity2;
7368 --
7369 l_lineCount := po_line_csr%ROWCOUNT;
7370 --
7371 CLOSE po_line_csr;
7372 --
7373 IF l_lineCount = 1
7374 THEN
7375 --{
7376 --
7377 -- Debug Statements
7378 --
7379 IF l_debug_on THEN
7380 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.ADDNEWLINE',WSH_DEBUG_SV.C_PROC_LEVEL);
7381 END IF;
7382 --
7383 WSH_IB_TXN_MATCH_PKG.addNewLine
7384 (
7385 p_lineDate => l_transactionDate,
7386 p_primaryUomCode => l_primaryUOMCode,
7387 p_secondaryUOMCode => l_secondaryUOMCode,
7388 x_lineRecTbl => l_lineRecTbl,
7389 x_return_status => l_return_status
7390 );
7391 --
7392 --
7393 --
7394 -- Debug Statements
7395 --
7396 IF l_debug_on THEN
7397 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7398 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7399 END IF;
7400 --
7401 wsh_util_core.api_post_call
7402 (
7403 p_return_status => l_return_status,
7404 x_num_warnings => l_num_warnings,
7405 x_num_errors => l_num_errors
7406 );
7407 --}
7408 END IF;
7409 --}
7410 END IF;
7411 --
7412 --
7413 IF l_lineCount = 0
7414 THEN
7415 --{
7416 /*
7417 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
7418 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7419 OR (
7420 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7421 AND l_ReceiptAgainstASN <> 'Y'
7422 )
7423 THEN
7424 --{
7425 */
7426 --
7427 IF l_transactionSubType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_CORRECTION_POSITIVE
7428 THEN
7429 --{
7430 l_messageName := 'WSH_IB_INVALID_PO_LINE_ERROR';
7431 RAISE e_lineNotMatched;
7432 --}
7433 ELSE
7434 --{
7435 FND_MESSAGE.SET_NAME('WSH','WSH_IB_INVALID_PO_LINE_ERROR');
7436 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning);
7437 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
7438 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
7439 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
7440 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
7441 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
7442 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
7443 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
7444 RAISE FND_API.G_EXC_ERROR;
7445 --}
7446 END IF;
7447 --
7448 /*
7449 --}
7450 ELSIF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7451 AND l_ReceiptAgainstASN = 'Y'
7452 THEN
7453 --{
7454 --}
7455 ELSE
7456 --{
7457 message
7458 RAISE e_lineFatalError;
7459 --}
7460 END IF;
7461 */
7462 --}
7463 END IF;
7464 --}
7465 ELSE
7466 --{
7467 l_src_requested_quantity := l_lineRecTbl.src_requested_quantity_tbl(1);
7468 l_src_requested_quantity2 := l_lineRecTbl.src_requested_quantity2_tbl(1);
7469 --}
7470 END IF;
7471 --
7472 --
7473 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
7474 AND p_line_rec.received_quantity2(l_index) IS NULL
7475 AND l_src_requested_quantity2 IS NOT NULL
7476 THEN
7477 --{
7478 -- Calculate secondary shipped qty. for OPM cases (ASN does not support OPM)
7479 --
7480 -- HW OPMCONV - Use C_MAX_DECIMAL_DIGITS_INV instead of C_MAX_DECIMAL_DIGITS_OPM
7481 p_line_rec.received_quantity2(l_index)
7482 := ROUND
7483 (
7484 l_src_requested_quantity2 * p_line_rec.received_quantity(l_index)
7485 / l_src_requested_quantity,
7486 WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV
7487 );
7488 --}
7489 END IF;
7490 --
7491 --
7492 l_linePreviousSFLocnId := -2;
7493 l_lineUniqueSFLocnFound := TRUE;
7494 l_lineUniqueSFLocnId := NULL;
7495 l_start_Index := l_end_Index + 1;
7496 --
7497 -- Loop through delivery lines fetched
7498 --
7499 -- Main purpose is to find unique ship-from location
7500 -- i.e. if all delivery lines have same ship-from location
7501 --
7502 -- We set l_lineUniqueSFLocnId to first line's ship-from location
7503 -- Thereafter, whenever current line's ship-from location is not
7504 -- equal to l_lineUniqueSFLocnId, it implies delivery lines do not have
7505 -- unique ship-from location.
7506 --
7507 FOR i in 1..l_lineCount
7508 LOOP
7509 --{
7510 l_lineSFLocnId := l_lineRecTbl.ship_from_location_id_tbl(i);
7511 l_lineUniqueSFLocnId := NVL(l_lineUniqueSFLocnId, l_lineSFLocnId);
7512 --
7513 IF l_debug_on THEN
7514 WSH_DEBUG_SV.log(l_module_name,'i',i);
7515 WSH_DEBUG_SV.log(l_module_name,'l_lineSFLocnId',l_lineSFLocnId);
7516 WSH_DEBUG_SV.log(l_module_name,'l_lineUniqueSFLocnId',l_lineUniqueSFLocnId);
7517 WSH_DEBUG_SV.log(l_module_name,'l_linePreviousSFLocnId',l_linePreviousSFLocnId);
7518 END IF;
7519 --
7520 --
7521 IF l_lineSFLocnId <> l_lineUniqueSFLocnId
7522 THEN
7523 --{
7524 -- Line's ship-from location is different from unique ship-from
7525 -- location found so far
7526 -- As long as, line's ship-from location is not null, it implies
7527 -- a change and hence we conclude that delivery lines have different ship-from
7528 -- locations. This is applicable for ASN/Receipt
7529 -- (Refer to appendix1 in DLD for examples)
7530 --
7531 -- For child transactions(indicated by l_resetTxnUniqueSFLocn=TRUE), even when
7532 -- line's ship-from location is null,it is a change.
7533 --
7534 --
7535 IF l_lineSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7536 THEN
7537 l_lineUniqueSFLocnFound := FALSE;
7538 ELSE
7539 --IF (l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7540 --AND l_receiptShipFromLocationCount > 1)
7541 --or other child txns
7542 -- replaced by following
7543 IF l_resetTxnUniqueSFLocn
7544 THEN
7545 l_lineUniqueSFLocnFound := FALSE;
7546 END IF;
7547 END IF;
7548 --}
7549 END IF;
7550 --
7551 --
7552 IF l_debug_on THEN
7553 WSH_DEBUG_SV.log(l_module_name,'l_lineUniqueSFLocnFound',l_lineUniqueSFLocnFound);
7554 END IF;
7555 --
7556 --
7557 IF NOT(l_lineUniqueSFLocnFound)
7558 --AND l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7559 --AND l_receiptShipFromLocationCount > 1
7560 AND l_resetTxnUniqueSFLocn
7561 --AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7562 THEN
7563 -- Since delivery lines have different ship-from locations
7564 -- cannot match the input child transaction
7565 -- Raise line-level "not matched" exception
7566 -- to mark current receipt line as match failure
7567 --
7568 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7569 THEN
7570 l_messageName := 'WSH_IB_PARENT_MULTI_SF_MATCH';
7571 ELSE
7572 l_messageName := 'WSH_IB_PARNT_LIN_MULT_SF_MATCH';
7573 END IF;
7574 --
7575 IF l_ReceiptAgainstASN = 'Y'
7576 AND l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7577 THEN
7578 --{
7579 FND_MESSAGE.SET_NAME('WSH',l_messageName);
7580 --
7581 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
7582 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
7583 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
7584 --
7585 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
7586 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
7587 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
7588 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
7589 --
7590 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
7591 --
7592 RAISE e_NotMatched;
7593 --}
7594 ELSE
7595 RAISE e_lineNotMatched;
7596 END IF;
7597 END IF;
7598 --
7599 --
7600 IF (
7601 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
7602 OR (
7603 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
7604 AND l_ReceiptAgainstASN <> 'Y'
7605 )
7606 )
7607 --AND ( i = 1 OR l_lineSFLocnId <> l_lineUniqueSFLocnId )
7608 -- replaced with the following line
7609 AND ( l_lineSFLocnId <> l_linePreviousSFLocnId )
7610 AND l_lineSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7611 THEN
7612 --{
7613 --
7614 -- Debug Statements
7615 --
7616 IF l_debug_on THEN
7617 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_shipFromLocationIdTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
7618 END IF;
7619 --
7620 wsh_util_core.get_cached_value
7621 (
7622 p_cache_tbl => l_shipFromLocationIdTbl,
7623 p_cache_ext_tbl => l_shipFromLocationIdExtTbl,
7624 p_key => l_lineSFLocnId,
7625 p_value => l_shipFromLocationIdLineCount,
7626 p_action => 'GET',
7627 x_return_status => l_return_status
7628 );
7629 --
7630 IF l_debug_on THEN
7631 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7632 END IF;
7633 --
7634 --
7635 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
7636 THEN
7637 RAISE FND_API.G_EXC_ERROR;
7638 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
7639 THEN
7640 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7641 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
7642 THEN
7643 l_shipFromLocationIdLineCount := 1;
7644 ELSE
7645 l_shipFromLocationIdLineCount := NVL(l_shipFromLocationIdLineCount,0) + 1;
7646 END IF;
7647 --
7648 --
7649 --
7650 -- Debug Statements
7651 --
7652 IF l_debug_on THEN
7653 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_shipFromLocationIdTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
7654 END IF;
7655 --
7656 wsh_util_core.get_cached_value
7657 (
7658 p_cache_tbl => l_shipFromLocationIdTbl,
7659 p_cache_ext_tbl => l_shipFromLocationIdExtTbl,
7660 p_key => l_lineSFLocnId,
7661 p_value => l_shipFromLocationIdLineCount,
7662 p_action => 'PUT',
7663 x_return_status => l_return_status
7664 );
7665 --
7666 --
7667 --
7668 -- Debug Statements
7669 --
7670 IF l_debug_on THEN
7671 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7672 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7673 END IF;
7674 --
7675 wsh_util_core.api_post_call
7676 (
7677 p_return_status => l_return_status,
7678 x_num_warnings => l_num_warnings,
7679 x_num_errors => l_num_errors
7680 );
7681 --}
7682 END IF;
7683 --
7684 l_linePreviousSFLocnId := l_lineSFLocnId ;
7685 --
7686 IF l_debug_on THEN
7687 WSH_DEBUG_SV.log(l_module_name,'LineRecTbl-WDD ID',l_lineRecTbl.delivery_detail_id_tbl(i));
7688 WSH_DEBUG_SV.log(l_module_name,'LineRecTbl-WND ID',l_lineRecTbl.delivery_id_tbl(i));
7689 END IF;
7690 --
7691 IF NOT(l_txnUniqueSFLocnFound)
7692 OR l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7693 OR l_lineSFLocnId = l_txnUniqueSFLocnId
7694 OR ( l_lineSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7695 AND l_lineUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7696 )
7697 THEN
7698 --{
7699 l_end_Index := l_end_Index + 1;
7700 --
7701 --
7702 IF NOT l_matchedLineRecTbl.match_flag_tab.EXISTS(l_end_Index)
7703 THEN
7704 --{
7705 l_extendBy := l_end_Index - l_matchedLineRecTbl.match_flag_tab.COUNT;
7706 --
7707 --
7708 IF l_debug_on THEN
7709 WSH_DEBUG_SV.log(l_module_name,'l_end_Index',l_end_Index);
7710 WSH_DEBUG_SV.log(l_module_name,'l_matchedLineRecTbl.match_flag_tab.COUNT',l_matchedLineRecTbl.match_flag_tab.COUNT);
7711 END IF;
7712 --
7713 IF l_extendBy > 0
7714 THEN
7715 --{
7716 --
7717 -- Debug Statements
7718 --
7719 IF l_debug_on THEN
7720 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.EXTENDMATCHEDLINERECTBL',WSH_DEBUG_SV.C_PROC_LEVEL);
7721 END IF;
7722 --
7723 WSH_IB_TXN_MATCH_PKG.extendMatchedLineRecTbl
7724 (
7725 p_extendBy => l_extendBy,
7726 x_matchedLineRecTbl => l_matchedLineRecTbl,
7727 x_return_status => l_return_status
7728 );
7729 --
7730 --
7731 -- Debug Statements
7732 --
7733 IF l_debug_on THEN
7734 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7735 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7736 END IF;
7737 --
7738 wsh_util_core.api_post_call
7739 (
7740 p_return_status => l_return_status,
7741 x_num_warnings => l_num_warnings,
7742 x_num_errors => l_num_errors
7743 );
7744 --}
7745 END IF;
7746 --}
7747 END IF;
7748 --
7749 --
7750 l_matchedLineRecTbl.del_detail_id_tab(l_end_index) := l_lineRecTbl.delivery_detail_id_tbl(i);
7751 --
7752 l_matchedLineRecTbl.requested_qty_tab(l_end_index) := l_lineRecTbl.requested_quantity_tbl(i);
7753 l_matchedLineRecTbl.picked_qty_tab(l_end_index) := l_lineRecTbl.picked_quantity_tbl(i);
7754 l_matchedLineRecTbl.shipped_qty_tab(l_end_index) := l_lineRecTbl.shipped_quantity_tbl(i);
7755 l_matchedLineRecTbl.received_qty_tab(l_end_index) := l_lineRecTbl.received_quantity_tbl(i);
7756 l_matchedLineRecTbl.returned_qty_tab(l_end_index) := l_lineRecTbl.returned_quantity_tbl(i);
7757 --
7758 l_matchedLineRecTbl.requested_qty2_tab(l_end_index) := l_lineRecTbl.requested_quantity2_tbl(i);
7759 l_matchedLineRecTbl.picked_qty2_tab(l_end_index) := l_lineRecTbl.picked_quantity2_tbl(i);
7760 l_matchedLineRecTbl.shipped_qty2_tab(l_end_index) := l_lineRecTbl.shipped_quantity2_tbl(i);
7761 l_matchedLineRecTbl.received_qty2_tab(l_end_index) := l_lineRecTbl.received_quantity2_tbl(i);
7762 l_matchedLineRecTbl.returned_qty2_tab(l_end_index) := l_lineRecTbl.returned_quantity2_tbl(i);
7763 --
7764 l_matchedLineRecTbl.requested_qty_db_tab(l_end_index) := l_lineRecTbl.requested_quantity_tbl(i);
7765 l_matchedLineRecTbl.picked_qty_db_tab(l_end_index) := l_lineRecTbl.picked_quantity_tbl(i);
7766 l_matchedLineRecTbl.shipped_qty_db_tab(l_end_index) := l_lineRecTbl.shipped_quantity_tbl(i);
7767 l_matchedLineRecTbl.received_qty_db_tab(l_end_index) := l_lineRecTbl.received_quantity_tbl(i);
7768 l_matchedLineRecTbl.returned_qty_db_tab(l_end_index) := l_lineRecTbl.returned_quantity_tbl(i);
7769 --
7770 l_matchedLineRecTbl.requested_qty2_db_tab(l_end_index) := l_lineRecTbl.requested_quantity2_tbl(i);
7771 l_matchedLineRecTbl.picked_qty2_db_tab(l_end_index) := l_lineRecTbl.picked_quantity2_tbl(i);
7772 l_matchedLineRecTbl.shipped_qty2_db_tab(l_end_index) := l_lineRecTbl.shipped_quantity2_tbl(i);
7773 l_matchedLineRecTbl.received_qty2_db_tab(l_end_index) := l_lineRecTbl.received_quantity2_tbl(i);
7774 l_matchedLineRecTbl.returned_qty2_db_tab(l_end_index) := l_lineRecTbl.returned_quantity2_tbl(i);
7775 --
7776 l_matchedLineRecTbl.line_date_tab(l_end_index) := l_lineRecTbl.earliest_dropoff_date_tbl(i);
7777 l_matchedLineRecTbl.ship_from_location_id_tab(l_end_index) := l_lineRecTbl.ship_from_location_id_tbl(i);
7778 l_matchedLineRecTbl.released_status_tab(l_end_index) := l_lineRecTbl.released_status_tbl(i);
7779 l_matchedLineRecTbl.requested_qty_uom_tab(l_end_index) := l_lineRecTbl.requested_quantity_uom_tbl(i);
7780 l_matchedLineRecTbl.requested_qty_uom2_tab(l_end_index) := l_lineRecTbl.requested_quantity_uom2_tbl(i);
7781 --
7782 l_matchedLineRecTbl.po_header_id_tab(l_end_index) := p_line_rec.header_id(l_index);
7783 l_matchedLineRecTbl.po_line_location_id_tab(l_end_index) := l_poShipmentLineId;
7784 l_matchedLineRecTbl.po_line_id_tab(l_end_index) := p_line_rec.line_id(l_index);
7785 l_matchedLineRecTbl.delivery_id_tab(l_end_index) := l_lineRecTbl.delivery_id_tbl(i);
7786 l_matchedLineRecTbl.trip_id_tab(l_end_index) := NULL;
7787 --
7788 l_matchedLineRecTbl.shipment_line_id_db_tab(l_end_index) := l_lineRecTbl.rcv_shipment_line_id_tbl(i);
7789 l_matchedLineRecTbl.shipment_line_id_tab(l_end_index) := p_line_rec.shipment_line_id(l_index);
7790 l_matchedLineRecTbl.child_index_tab(l_end_index) := NULL;
7791 l_matchedLineRecTbl.shpmt_line_id_idx_tab(l_end_index) := l_index;
7792 --
7793 l_matchedLineRecTbl.process_corr_rtv_flag_tab(l_end_index) := C_NOT_PROCESS_FLAG;
7794 l_matchedLineRecTbl.process_asn_rcv_flag_tab(l_end_index) := C_NOT_PROCESS_FLAG;
7795 l_matchedLineRecTbl.match_flag_tab(l_end_index) := C_NOT_PROCESS_FLAG;
7796 l_matchedLineRecTbl.last_update_date_tab(l_end_index) := l_lineRecTbl.last_update_date_tbl(i);
7797 l_matchedLineRecTbl.lineCount_tab(l_end_index) := l_lineCount;
7798 --
7799 --
7800
7801 IF l_debug_on THEN
7802 WSH_DEBUG_SV.log(l_module_name,'Qty:REQ|PICK|SHP|RCV|RTV',
7803 l_matchedLineRecTbl.requested_qty_tab(l_end_index)
7804 || '|'
7805 || l_matchedLineRecTbl.picked_qty_tab(l_end_index)
7806 || '|'
7807 || l_matchedLineRecTbl.shipped_qty_tab(l_end_index)
7808 || '|'
7809 || l_matchedLineRecTbl.received_qty_tab(l_end_index)
7810 || '|'
7811 || l_matchedLineRecTbl.returned_qty_tab(l_end_index)
7812 );
7813 WSH_DEBUG_SV.log(l_module_name,'Qty2:REQ|PICK|SHP|RCV|RTV',
7814 l_matchedLineRecTbl.requested_qty2_tab(l_end_index)
7815 || '|'
7816 || l_matchedLineRecTbl.picked_qty2_tab(l_end_index)
7817 || '|'
7818 || l_matchedLineRecTbl.shipped_qty2_tab(l_end_index)
7819 || '|'
7820 || l_matchedLineRecTbl.received_qty2_tab(l_end_index)
7821 || '|'
7822 || l_matchedLineRecTbl.returned_qty2_tab(l_end_index)
7823 );
7824 WSH_DEBUG_SV.log(l_module_name,'LineDate|SFLocn|UOM|UOM2|RelSt',
7825 l_matchedLineRecTbl.line_date_tab(l_end_index)
7826 || '|'
7827 || l_matchedLineRecTbl.ship_from_location_id_tab(l_end_index)
7828 || '|'
7829 || l_matchedLineRecTbl.requested_qty_uom_tab(l_end_index)
7830 || '|'
7831 || l_matchedLineRecTbl.requested_qty_uom2_tab(l_end_index)
7832 || '|'
7833 || l_matchedLineRecTbl.released_status_tab(l_end_index)
7834 );
7835 WSH_DEBUG_SV.log(l_module_name,'SrcId:Hdr|Line|PLL|RCVSl-DB|RCV-SL-Input',
7836 l_matchedLineRecTbl.po_header_id_tab(l_end_index)
7837 || '|'
7838 || l_matchedLineRecTbl.po_line_id_tab(l_end_index)
7839 || '|'
7840 || l_matchedLineRecTbl.po_line_location_id_tab(l_end_index)
7841 || '|'
7842 || l_matchedLineRecTbl.shipment_line_id_db_tab(l_end_index)
7843 || '|'
7844 || l_matchedLineRecTbl.shipment_line_id_tab(l_end_index)
7845 );
7846 WSH_DEBUG_SV.log(l_module_name,'last_update_date', l_matchedLineRecTbl.last_update_date_tab(l_end_index));
7847 WSH_DEBUG_SV.log(l_module_name,'lineCount tab', l_matchedLineRecTbl.lineCount_tab(l_end_index));
7848 END IF;
7849 --}
7850 END IF;
7851 --
7852 --EXIT WHEN l_lineSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID;
7853 --
7854 --
7855 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7856 AND l_receiptShipFromLocationCount = 1
7857 AND l_txnUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7858 THEN
7859 l_lineUniqueSFLocnId := NULL;
7860 END IF;
7861 --}
7862 END LOOP;
7863 --
7864 --
7865 IF l_debug_on THEN
7866 WSH_DEBUG_SV.log(l_module_name,'l_start_index',l_start_index);
7867 WSH_DEBUG_SV.log(l_module_name,'l_end_index',l_end_index);
7868 WSH_DEBUG_SV.log(l_module_name,'l_lineUniqueSFLocnFound',l_lineUniqueSFLocnFound);
7869 WSH_DEBUG_SV.log(l_module_name,'l_lineUniqueSFLocnId',l_lineUniqueSFLocnId);
7870 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnId',l_txnUniqueSFLocnId);
7871 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnFound',l_txnUniqueSFLocnFound);
7872 END IF;
7873 --
7874 --
7875 IF l_end_index >= l_start_index
7876 AND l_start_index > 0
7877 THEN
7878 --{
7879 l_linkRecString := C_NOT_PROCESS_FLAG
7880 || C_SEPARATOR
7881 || l_start_index
7882 || C_SEPARATOR
7883 || l_end_index;
7884 --
7885 --
7886 --
7887 -- Debug Statements
7888 --
7889 IF l_debug_on THEN
7890 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_linkTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
7891 END IF;
7892 --
7893 wsh_util_core.get_cached_value
7894 (
7895 p_cache_tbl => l_linkTbl,
7896 p_cache_ext_tbl => l_linkExtTbl,
7897 p_key => l_key, --l_poShipmentLineId,
7898 p_value => l_linkRecString,
7899 p_action => 'PUT',
7900 x_return_status => l_return_status
7901 );
7902 --
7903 --
7904 --
7905 -- Debug Statements
7906 --
7907 IF l_debug_on THEN
7908 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7909 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7910 END IF;
7911 --
7912 wsh_util_core.api_post_call
7913 (
7914 p_return_status => l_return_status,
7915 x_num_warnings => l_num_warnings,
7916 x_num_errors => l_num_errors
7917 );
7918 --}
7919 END IF;
7920 --
7921 --
7922 IF l_lineUniqueSFLocnFound
7923 THEN
7924 --{
7925 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
7926 AND l_receiptShipFromLocationCount = 1
7927 AND l_lineUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7928 AND l_lineUniqueSFLocnId <> l_txnUniqueSFLocnId
7929 THEN
7930 l_messageName := 'WSH_IB_NOT_MATCH_NULL_SF_LOCN';
7931 RAISE e_lineNotMatched;
7932 END IF;
7933 --
7934 --
7935 IF NOT(l_txnUniqueSFLocnFound)
7936 OR l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7937 THEN
7938 --{
7939 l_txnUniqueSFLocnFound := TRUE;
7940 -- { IB-Phase-2
7941 IF l_trx_wsh_location_id IS NULL
7942 THEN
7943 l_txnUniqueSFLocnId := l_lineUniqueSFLocnId;
7944 END IF;
7945 -- } IB-Phase-2
7946 --
7947 IF l_txnUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7948 THEN
7949 --{
7950 IF NOT(l_resetTxnUniqueSFLocn)
7951 THEN
7952 l_start_index := l_matchedLineRecTbl.match_flag_tab.FIRST;
7953 END IF;
7954 --
7955 --
7956 -- Debug Statements
7957 --
7958 IF l_debug_on THEN
7959 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_LOCATION_DESCRIPTION',WSH_DEBUG_SV.C_PROC_LEVEL);
7960 END IF;
7961 --
7962 l_txnUniqueSFLocnCode := SUBSTRB
7963 (
7964 WSH_UTIL_CORE.get_location_description
7965 (
7966 l_txnUniqueSFLocnId,
7967 'NEW UI CODE'
7968 ),
7969 1,
7970 60
7971 );
7972 --}
7973 END IF;
7974 --}
7975 ELSIF l_lineUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
7976 AND l_lineUniqueSFLocnId <> l_txnUniqueSFLocnId
7977 THEN
7978 --{
7979 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_UNIQUE_SF_LOCN');
7980 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
7981 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
7982 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
7983 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error,l_module_name);
7984 RAISE e_notMatched;
7985 --}
7986 END IF;
7987 --}
7988 END IF;
7989 --
7990 --
7991 IF l_debug_on THEN
7992 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnFound',l_txnUniqueSFLocnFound);
7993 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnId',l_txnUniqueSFLocnId);
7994 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnCode',l_txnUniqueSFLocnCode);
7995 END IF;
7996 --
7997 --
7998 IF l_txnUniqueSFLocnFound
7999 --AND l_txnUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8000 THEN
8001 --{
8002 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8003 OR l_resetTxnUniqueSFLocn
8004 OR l_txnUniqueSFLocnId <> WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8005 THEN
8006 --{
8007 IF l_end_index >= l_start_index
8008 THEN
8009 --{
8010
8011 BEGIN
8012 --{
8013 --
8014 -- Debug Statements
8015 --
8016 IF l_debug_on THEN
8017 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.MATCHLINES',WSH_DEBUG_SV.C_PROC_LEVEL);
8018 END IF;
8019 --
8020 WSH_IB_TXN_MATCH_PKG.matchLines
8021 (
8022 p_line_rec => p_line_rec,
8023 p_transactionType => l_transactionSubType ,
8024 p_transactionMeaning => l_transactionMeaning,
8025 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8026 p_transactionDate => l_transactionDate,
8027 p_start_index => l_start_index,
8028 p_end_index => l_end_index,
8029 p_putMessages => TRUE,
8030 p_txnUniqueSFLocnId => l_txnUniqueSFLocnId,
8031 x_matchedLineRecTbl => l_matchedLineRecTbl,
8032 x_dlvytbl => l_dlvytbl,
8033 x_dlvyExttbl => l_dlvyExttbl,
8034 x_min_date => l_min_date,
8035 x_max_date => l_max_date,
8036 x_return_status => l_return_status
8037 );
8038 --
8039 --
8040 --
8041 -- Debug Statements
8042 --
8043 IF l_debug_on THEN
8044 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8045 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8046 END IF;
8047 --
8048 wsh_util_core.api_post_call
8049 (
8050 p_return_status => l_return_status,
8051 x_num_warnings => l_num_warnings,
8052 x_num_errors => l_num_errors
8053 );
8054 --}
8055 EXCEPTION
8056 --{
8057 WHEN e_notMatched THEN
8058 --{
8059 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8060 THEN
8061 l_messageName := NULL;
8062 RAISE e_lineNotMatched;
8063 ELSE
8064 RAISE e_notMatched;
8065 END IF;
8066 --}
8067 --}
8068 END;
8069 --}
8070 ELSE
8071 --{
8072 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8073 THEN
8074 l_messageName := 'WSH_IB_NOT_MATCH_SF_LOCN';
8075 RAISE e_lineNotMatched;
8076 ELSE
8077 --{
8078 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_MATCH_SF_LOCN');
8079 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
8080 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
8081 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
8082 FND_MESSAGE.SET_TOKEN('SHIP_FROM_LOCATION',l_txnUniqueSFLocnCode);
8083 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
8084 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
8085 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
8086 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
8087 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
8088 --
8089 RAISE e_notMatched;
8090 --}
8091 END IF;
8092 --}
8093 END IF;
8094 --}
8095 END IF;
8096 --}
8097 END IF;
8098 --}
8099 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS
8100 THEN
8101 --{
8102 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8103 AND SUBSTRB(l_linkRecString,1,1) = C_ERROR_FLAG
8104 THEN
8105 --{
8106 l_messageName := NULL;
8107 RAISE e_lineNotMatched;
8108 --}
8109 END IF;
8110 --Use link rec string, get the flag. if error then, l_messagename=null and raise e_linenot matched
8111 --}
8112 END IF;
8113 --
8114 --
8115 l_minMatchedTransactionId := LEAST(l_minMatchedTransactionId, l_transactionId);
8116 --
8117 --
8118 IF l_debug_on THEN
8119 WSH_DEBUG_SV.log(l_module_name,'l_minMatchedTransactionId',l_minMatchedTransactionId);
8120 END IF;
8121 --
8122 --
8123 IF l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8124 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8125 THEN
8126 --{
8127 --
8128 -- Debug Statements
8129 --
8130 IF l_debug_on THEN
8131 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.ADDTRANSACTIONHISTORYRECORD',WSH_DEBUG_SV.C_PROC_LEVEL);
8132 END IF;
8133 --
8134 WSH_IB_TXN_MATCH_PKG.addTransactionHistoryRecord
8135 (
8136 p_transactionType => l_transactionSubType,
8137 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8138 p_index => l_index,
8139 p_line_rec => p_line_rec,
8140 p_ship_from_location_id => l_trx_wsh_location_id, -- IB-Phase-2
8141 x_inboundTxnHistory_recTbl => l_MatchedTxnHistory_recTbl,
8142 x_return_status => l_return_status
8143 );
8144 --
8145 --
8146 --
8147 -- Debug Statements
8148 --
8149 IF l_debug_on THEN
8150 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8151 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8152 END IF;
8153 --
8154 wsh_util_core.api_post_call
8155 (
8156 p_return_status => l_return_status,
8157 x_num_warnings => l_num_warnings,
8158 x_num_errors => l_num_errors
8159 );
8160 --}
8161 END IF;
8162 --}
8163 EXCEPTION
8164 --{
8165 WHEN e_lineNotMatched THEN
8166 --{
8167 --ROLLBACK TO matchTransaction_sp;--???no
8168 --
8169 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8170 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8171 THEN
8172 --{
8173 RAISE e_notMatched;
8174 --}
8175 ELSE
8176 --{
8177 l_minFailedTransactionId := LEAST(l_minFailedTransactionId, l_transactionId);
8178 --
8179 --
8180 -- Debug Statements
8181 --
8182 IF l_debug_on THEN
8183 WSH_DEBUG_SV.log(l_module_name,'l_minFailedTransactionId',l_minFailedTransactionId);
8184 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.ADDTRANSACTIONHISTORYRECORD',WSH_DEBUG_SV.C_PROC_LEVEL);
8185 END IF;
8186 --
8187 WSH_IB_TXN_MATCH_PKG.addTransactionHistoryRecord
8188 (
8189 p_transactionType => l_transactionSubType,
8190 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8191 p_index => l_index,
8192 p_line_rec => p_line_rec,
8193 p_ship_from_location_id => l_trx_wsh_location_id, ---- IB-Phase-2
8194 x_inboundTxnHistory_recTbl => l_FailedTxnHistory_recTbl,
8195 x_return_status => l_return_status
8196 );
8197 --
8198 --
8199 --
8200 -- Debug Statements
8201 --
8202 IF l_debug_on THEN
8203 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8204 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8205 END IF;
8206 --
8207 wsh_util_core.api_post_call
8208 (
8209 p_return_status => l_return_status,
8210 x_num_warnings => l_num_warnings,
8211 x_num_errors => l_num_errors
8212 );
8213 --
8214 --
8215 IF l_key IS NOT NULL
8216 THEN
8217 --{
8218 l_linkRecString := C_ERROR_FLAG
8219 || C_SEPARATOR
8220 || l_start_index
8221 || C_SEPARATOR
8222 || l_end_index;
8223 --
8224 --
8225 --
8226 -- Debug Statements
8227 --
8228 IF l_debug_on THEN
8229 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_linkTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
8230 END IF;
8231 --
8232 wsh_util_core.get_cached_value
8233 (
8234 p_cache_tbl => l_linkTbl,
8235 p_cache_ext_tbl => l_linkExtTbl,
8236 p_key => l_key, --l_poShipmentLineId,
8237 p_value => l_linkRecString,
8238 p_action => 'PUT',
8239 x_return_status => l_return_status
8240 );
8241 --
8242 --
8243 --
8244 -- Debug Statements
8245 --
8246 IF l_debug_on THEN
8247 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8248 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8249 END IF;
8250 --
8251 wsh_util_core.api_post_call
8252 (
8253 p_return_status => l_return_status,
8254 x_num_warnings => l_num_warnings,
8255 x_num_errors => l_num_errors
8256 );
8257 --}
8258 END IF;
8259 --
8260 --
8261 IF l_debug_on THEN
8262 WSH_DEBUG_SV.log(l_module_name,'l_messageName',l_messageName);
8263 END IF;
8264 --
8265 --
8266 IF l_messageName IS NOT NULL
8267 THEN
8268 --{
8269 --FND_MESSAGE.SET_NAME('WSH','WSH_IB_MATCH_LINE_FATAL_ERROR');
8270 FND_MESSAGE.SET_NAME('WSH',l_messageName);
8271 --
8272 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
8273 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
8274 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
8275 --
8276 IF l_messageName IN (
8277 'WSH_IB_PEND_PARENT_TXN_MATCH',
8278 'WSH_IB_PEND_PARENT_LINE_MATCH',
8279 'WSH_IB_PARNT_LIN_MULT_SF_MATCH',
8280 'WSH_IB_PARENT_MULTI_SF_MATCH',
8281 'WSH_IB_NOT_MATCH_NULL_SF_LOCN',
8282 'WSH_IB_NOT_MATCH_SF_LOCN',
8283 'WSH_IB_INVALID_PO_LINE_ERROR',
8284 'WSH_IB_NOT_MATCH_SHP_LINES'
8285 )
8286 THEN
8287 --{
8288 FND_MESSAGE.SET_TOKEN('PO_HEADER_NUM',l_poHeaderNumber);
8289 FND_MESSAGE.SET_TOKEN('PO_LINE_NUM',l_poLineNumber);
8290 FND_MESSAGE.SET_TOKEN('PO_SHIPMENT_LINE_NUM',l_poShipmentLineNumber);
8291 FND_MESSAGE.SET_TOKEN('PO_RELEASE_NUM',l_poReleaseNumber);
8292 --}
8293 END IF;
8294 --
8295 --
8296 IF l_messageName = 'WSH_IB_NOT_MATCH_SF_LOCN'
8297 THEN
8298 FND_MESSAGE.SET_TOKEN('SHIP_FROM_LOCATION',l_txnUniqueSFLocnCode);
8299 END IF;
8300 --
8301 --
8302 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
8303 --x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
8304 --}
8305 END IF;
8306 --}
8307 END IF;
8308 --}
8309 --}
8310 END;
8311 --
8312 --
8313 IF l_resetTxnUniqueSFLocn
8314 THEN
8315 --{
8316 l_txnUniqueSFLocnFound := FALSE;
8317 l_txnUniqueSFLocnId := NULL;
8318 l_txnUniqueSFLocnCode := NULL;
8319 --}
8320 END IF;
8321 --
8322 IF l_debug_on THEN
8323 WSH_DEBUG_SV.logmsg(l_module_name,'End of outer loop');
8324 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnFound',l_txnUniqueSFLocnFound);
8325 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnId',l_txnUniqueSFLocnId);
8326 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnCode',l_txnUniqueSFLocnCode);
8327 END IF;
8328 --
8329 l_index := p_line_rec.shipment_line_id.NEXT(l_index);
8330 --}
8331 END LOOP;
8332 --
8333 --
8334 l_maxRCVTransactionId := l_maxTransactionId;
8335 --
8336 --
8337 IF l_debug_on THEN
8338 WSH_DEBUG_SV.log(l_module_name,'l_maxRCVTransactionId',l_maxRCVTransactionId);
8339 END IF;
8340 --
8341 --
8342 IF (
8343 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8344 OR (
8345 l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8346 AND l_ReceiptAgainstASN <> 'Y'
8347 )
8348 )
8349 THEN
8350 --{
8351 IF NOT(l_txnUniqueSFLocnFound)
8352 OR l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8353 THEN
8354 --{
8355 l_count := l_linkTbl.COUNT + l_linkExtTbl.COUNT;
8356 --
8357 --
8358 IF l_debug_on THEN
8359 WSH_DEBUG_SV.log(l_module_name,'Link Table Total Count',l_count);
8360 END IF;
8361 --
8362 IF l_shipFromLocationIdTbl.COUNT > 0
8363 OR l_shipFromLocationIdExtTbl.COUNT > 0
8364 THEN
8365 l_min_date := NULL;
8366 l_max_date := NULL;
8367 END IF;
8368 --
8369 --
8370 l_index := l_shipFromLocationIdTbl.FIRST;
8371 --
8372 WHILE l_index IS NOT NULL
8373 LOOP
8374 --{
8375 BEGIN
8376 --{
8377 IF l_debug_on THEN
8378 WSH_DEBUG_SV.log(l_module_name,'SF Locn Id, Count',
8379 l_shipFromLocationIdTbl(l_index).key
8380 || ','
8381 || l_shipFromLocationIdTbl(l_index).value
8382 );
8383 END IF;
8384 --
8385 --
8386 IF l_shipFromLocationIdTbl(l_index).value = l_count
8387 OR l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8388 THEN
8389 --{
8390 l_dummy_min_date := NULL;
8391 l_dummy_max_date := NULL;
8392 --
8393 --
8394 -- Debug Statements
8395 --
8396 IF l_debug_on THEN
8397 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.MATCHLINES',WSH_DEBUG_SV.C_PROC_LEVEL);
8398 END IF;
8399 --
8400 WSH_IB_TXN_MATCH_PKG.matchLines
8401 (
8402 p_line_rec => p_line_rec,
8403 p_transactionType => l_transactionSubType ,
8404 p_transactionMeaning => l_transactionMeaning,
8405 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8406 p_transactionDate => l_transactionDate,
8407 p_start_index => l_matchedLineRecTbl.match_flag_tab.FIRST,
8408 p_end_index => l_matchedLineRecTbl.match_flag_tab.LAST,
8409 p_putMessages => FALSE,
8410 p_txnUniqueSFLocnId => l_shipFromLocationIdTbl(l_index).key,
8411 x_matchedLineRecTbl => l_matchedLineRecTbl,
8412 x_dlvytbl => l_dlvytbl,
8413 x_dlvyExttbl => l_dlvyExttbl,
8414 x_min_date => l_dummy_min_date,
8415 x_max_date => l_dummy_max_date,
8416 x_return_status => l_return_status
8417 );
8418 --
8419 --
8420 --
8421 -- Debug Statements
8422 --
8423 IF l_debug_on THEN
8424 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8425 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8426 END IF;
8427 --
8428 wsh_util_core.api_post_call
8429 (
8430 p_return_status => l_return_status,
8431 x_num_warnings => l_num_warnings,
8432 x_num_errors => l_num_errors
8433 );
8434 --
8435 --
8436 IF l_debug_on THEN
8437 WSH_DEBUG_SV.logmsg(l_module_name,'Adding to l_uniqueShipFromLocationIdTbl');
8438 END IF;
8439 --
8440 --
8441 l_uniqueShipFromLocationIdTbl(l_uniqueShipFromLocationIdTbl.COUNT+1)
8442 := l_shipFromLocationIdTbl(l_index).key;
8443 --
8444 --
8445 l_min_date := NVL(l_min_date,l_dummy_min_date);
8446 l_max_date := NVL(l_max_date,l_dummy_max_date);
8447 --
8448 --
8449 IF l_debug_on THEN
8450 WSH_DEBUG_SV.log(l_module_name,'l_min_date',l_min_date);
8451 WSH_DEBUG_SV.log(l_module_name,'l_max_date',l_max_date);
8452 END IF;
8453 --
8454 --
8455 --}
8456 END IF;
8457 --}
8458 EXCEPTION
8459 WHEN e_notMatched THEN
8460 NULL;
8461 END;
8462 --
8463 l_index := l_shipFromLocationIdTbl.NEXT(l_index);
8464 --}
8465 END LOOP;
8466 --
8467 --
8468 l_index := l_shipFromLocationIdExtTbl.FIRST;
8469 --
8470 WHILE l_index IS NOT NULL
8471 LOOP
8472 --{
8473 BEGIN
8474 --{
8475
8476 IF l_debug_on THEN
8477 WSH_DEBUG_SV.log(l_module_name,'SF Locn Id, Count',
8478 l_shipFromLocationIdExtTbl(l_index).key
8479 || ','
8480 || l_shipFromLocationIdExtTbl(l_index).value
8481 );
8482 END IF;
8483 --
8484 --
8485 IF l_shipFromLocationIdExtTbl(l_index).value = l_count
8486 OR l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8487 THEN
8488 --{
8489 l_dummy_min_date := NULL;
8490 l_dummy_max_date := NULL;
8491 --
8492 --
8493 -- Debug Statements
8494 --
8495 IF l_debug_on THEN
8496 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.MATCHLINES',WSH_DEBUG_SV.C_PROC_LEVEL);
8497 END IF;
8498 --
8499 WSH_IB_TXN_MATCH_PKG.matchLines
8500 (
8501 p_line_rec => p_line_rec,
8502 p_transactionType => l_transactionSubType ,
8503 p_transactionMeaning => l_transactionMeaning,
8504 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8505 p_transactionDate => l_transactionDate,
8506 p_start_index => l_matchedLineRecTbl.match_flag_tab.FIRST,
8507 p_end_index => l_matchedLineRecTbl.match_flag_tab.LAST,
8508 p_putMessages => FALSE,
8509 p_txnUniqueSFLocnId => l_shipFromLocationIdExtTbl(l_index).key,
8510 x_matchedLineRecTbl => l_matchedLineRecTbl,
8511 x_dlvytbl => l_dlvytbl,
8512 x_dlvyExttbl => l_dlvyExttbl,
8513 x_min_date => l_dummy_min_date,
8514 x_max_date => l_dummy_max_date,
8515 x_return_status => l_return_status
8516 );
8517 --
8518 --
8519 --
8520 -- Debug Statements
8521 --
8522 IF l_debug_on THEN
8523 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8524 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8525 END IF;
8526 --
8527 wsh_util_core.api_post_call
8528 (
8529 p_return_status => l_return_status,
8530 x_num_warnings => l_num_warnings,
8531 x_num_errors => l_num_errors
8532 );
8533 --
8534 --
8535 IF l_debug_on THEN
8536 WSH_DEBUG_SV.logmsg(l_module_name,'Adding to l_uniqueShipFromLocationIdTbl');
8537 END IF;
8538 --
8539 --
8540 l_uniqueShipFromLocationIdTbl(l_uniqueShipFromLocationIdTbl.COUNT+1)
8541 := l_shipFromLocationIdExtTbl(l_index).key;
8542 --
8543 --
8544 l_min_date := NVL(l_min_date,l_dummy_min_date);
8545 l_max_date := NVL(l_max_date,l_dummy_max_date);
8546 --
8547 --
8548 IF l_debug_on THEN
8549 WSH_DEBUG_SV.log(l_module_name,'l_min_date',l_min_date);
8550 WSH_DEBUG_SV.log(l_module_name,'l_max_date',l_max_date);
8551 END IF;
8552 --
8553 --
8554 --}
8555 END IF;
8556 --}
8557 EXCEPTION
8558 WHEN e_notMatched THEN
8559 NULL;
8560 END;
8561 --
8562 l_index := l_shipFromLocationIdExtTbl.NEXT(l_index);
8563 --}
8564 END LOOP;
8565 --
8566 --
8567 IF l_debug_on THEN
8568 WSH_DEBUG_SV.log(l_module_name,'l_uniqueShipFromLocationIdTbl.COUNT',l_uniqueShipFromLocationIdTbl.COUNT);
8569 END IF;
8570 --
8571 --
8572 IF l_uniqueShipFromLocationIdTbl.COUNT = 1
8573 THEN
8574 --{
8575 -- { IB-Phase-2
8576 IF l_trx_wsh_location_id IS NULL
8577 THEN --
8578 l_txnUniqueSFLocnId := l_uniqueShipFromLocationIdTbl(l_uniqueShipFromLocationIdTbl.FIRST);
8579 END IF;
8580 l_txnUniqueSFLocnFound := TRUE;
8581 -- } IB-Phase-2
8582 --}
8583 ELSIF NOT(l_txnUniqueSFLocnFound)
8584 THEN
8585 --{
8586 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_UNIQUE_SF_LOCN');
8587 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
8588 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
8589 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
8590 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error,l_module_name);
8591 RAISE e_notMatched;
8592 --}
8593 END IF;
8594 --}
8595 END IF;
8596 --
8597 --
8598 IF l_debug_on THEN
8599 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnFound',l_txnUniqueSFLocnFound);
8600 WSH_DEBUG_SV.log(l_module_name,'l_txnUniqueSFLocnId',l_txnUniqueSFLocnId);
8601 END IF;
8602 --
8603 --
8604 IF l_txnUniqueSFLocnFound
8605 AND l_txnUniqueSFLocnId = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
8606 THEN
8607 --{
8608 l_min_date := NULL;
8609 l_max_date := NULL;
8610 --
8611 --
8612 -- Debug Statements
8613 --
8614 IF l_debug_on THEN
8615 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.MATCHLINES',WSH_DEBUG_SV.C_PROC_LEVEL);
8616 END IF;
8617 --
8618 WSH_IB_TXN_MATCH_PKG.matchLines
8619 (
8620 p_line_rec => p_line_rec,
8621 p_transactionType => l_transactionSubType ,
8622 p_transactionMeaning => l_transactionMeaning,
8623 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8624 p_transactionDate => l_transactionDate,
8625 p_start_index => l_matchedLineRecTbl.match_flag_tab.FIRST,
8626 p_end_index => l_matchedLineRecTbl.match_flag_tab.LAST,
8627 p_putMessages => TRUE,
8628 p_txnUniqueSFLocnId => l_txnUniqueSFLocnId,
8629 x_matchedLineRecTbl => l_matchedLineRecTbl,
8630 x_dlvytbl => l_dlvytbl,
8631 x_dlvyExttbl => l_dlvyExttbl,
8632 x_min_date => l_min_date,
8633 x_max_date => l_max_date,
8634 x_return_status => l_return_status
8635 );
8636 --
8637 --
8638 --
8639 -- Debug Statements
8640 --
8641 IF l_debug_on THEN
8642 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8643 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8644 END IF;
8645 --
8646 wsh_util_core.api_post_call
8647 (
8648 p_return_status => l_return_status,
8649 x_num_warnings => l_num_warnings,
8650 x_num_errors => l_num_errors
8651 );
8652 --}
8653 END IF;
8654 --
8655 --
8656 IF NOT(l_txnUniqueSFLocnFound)
8657 THEN
8658 --{
8659 FND_MESSAGE.SET_NAME('WSH','WSH_IB_NOT_UNIQUE_SF_LOCN');
8660 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE',l_transactionMeaning); --p_action_prms.action_code);
8661 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
8662 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
8663 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error,l_module_name);
8664 RAISE e_notMatched;
8665 --}
8666 END IF;
8667 --}
8668 END IF;
8669 --
8670 --
8671 IF l_debug_on THEN
8672 WSH_DEBUG_SV.log(l_module_name,'l_FailedTxnHistory_recTbl.shipment_header_id.COUNT',l_FailedTxnHistory_recTbl.shipment_header_id.COUNT);
8673 WSH_DEBUG_SV.log(l_module_name,'l_MatchedTxnHistory_recTbl.shipment_header_id.COUNT',l_MatchedTxnHistory_recTbl.shipment_header_id.COUNT);
8674 END IF;
8675 --
8676 IF l_FailedTxnHistory_recTbl.shipment_header_id.COUNT > 0
8677 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8678 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8679 THEN
8680 --{
8681 --
8682 -- Debug Statements
8683 --
8684 IF l_debug_on THEN
8685 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.autonomous_Create_bulk',WSH_DEBUG_SV.C_PROC_LEVEL);
8686 END IF;
8687 --
8688 WSH_INBOUND_TXN_HISTORY_PKG.autonomous_Create_bulk
8689 (
8690 x_inboundTxnHistory_recTbl => l_FailedTxnHistory_recTbl,
8691 x_return_status => l_return_status
8692 );
8693 --
8694 --
8695 --
8696 -- Debug Statements
8697 --
8698 IF l_debug_on THEN
8699 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8700 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8701 END IF;
8702 --
8703 wsh_util_core.api_post_call
8704 (
8705 p_return_status => l_return_status,
8706 x_num_warnings => l_num_warnings,
8707 x_num_errors => l_num_errors
8708 );
8709 --}
8710 END IF;
8711 --
8712 --
8713 IF l_MatchedTxnHistory_recTbl.shipment_header_id.COUNT = 0
8714 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8715 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8716 THEN
8717 RAISE e_notMatched;
8718 END IF;
8719 --
8720 --
8721 BEGIN
8722 --{
8723 --
8724 -- Debug Statements
8725 --
8726 IF l_debug_on THEN
8727 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.MATCHQUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
8728 END IF;
8729 --
8730 WSH_IB_TXN_MATCH_PKG.matchQuantity
8731 (
8732 p_line_rec => p_line_rec,
8733 p_transactionType => l_transactionType, --l_transactionSubType ,
8734 p_transactionMeaning => l_transactionMeaning,
8735 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
8736 p_transactionDate => l_transactionDate,
8737 p_txnUniqueSFLocnId => l_txnUniqueSFLocnId,
8738 p_start_index => p_line_rec.line_id.FIRST,
8739 p_end_index => p_line_rec.line_id.LAST,
8740 p_min_date => l_min_date,
8741 p_max_date => l_max_date,
8742 x_matchedLineRecTbl => l_matchedLineRecTbl,
8743 x_linktbl => l_linktbl,
8744 x_linkExttbl => l_linkExttbl,
8745 x_return_status => l_return_status
8746 );
8747 --
8748 --
8749 --
8750 -- Debug Statements
8751 --
8752 IF l_debug_on THEN
8753 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8754 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8755 END IF;
8756 --
8757 wsh_util_core.api_post_call
8758 (
8759 p_return_status => l_return_status,
8760 x_num_warnings => l_num_warnings,
8761 x_num_errors => l_num_errors
8762 );
8763 --
8764 l_actionCode := l_transactionType; --l_transactionSubType;
8765 --
8766 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8767 THEN
8768 l_actionCode := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT;
8769 END IF;
8770 --
8771 l_matchedLineRecTbl.transaction_type := l_actionCode;
8772 l_matchedLineRecTbl.shipment_header_id := l_RCVShipmentHeaderId;
8773 l_matchedLineRecTbl.max_transaction_id := l_maxRCVTransactionId;
8774 l_matchedLineRecTbl.object_version_number := l_headerObjectVersionNumber;
8775 --
8776 l_caller := 'WSH_IB_MATCH';
8777 l_action_prms1.action_code := l_actionCode;
8778 l_action_prms1.caller := l_caller;
8779 l_action_prms2.action_code := l_actionCode;
8780 l_action_prms2.caller := l_caller;
8781 --
8782 --
8783 IF l_debug_on THEN
8784 WSH_DEBUG_SV.log(l_module_name,'l_caller',l_caller);
8785 WSH_DEBUG_SV.log(l_module_name,'l_actionCode',l_actionCode);
8786 END IF;
8787 --
8788 --
8789 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8790 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8791 OR l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8792 THEN
8793 --{
8794 --
8795 -- Debug Statements
8796 --
8797 IF l_debug_on THEN
8798 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.PROCESS_MATCHED_TXNS',WSH_DEBUG_SV.C_PROC_LEVEL);
8799 END IF;
8800 --
8801 WSH_ASN_RECEIPT_PVT.Process_Matched_Txns
8802 (
8803 p_dd_rec => l_matchedLineRecTbl,
8804 p_line_rec => p_line_rec,
8805 p_action_prms => l_action_prms1,
8806 p_shipment_header_id => l_RCVShipmentHeaderId,
8807 p_max_txn_id => l_maxRCVTransactionId,
8808 x_po_cancel_rec => l_po_cancel_rec,
8809 x_po_close_rec => l_po_close_rec,
8810 x_return_status => l_return_status
8811 );
8812 --
8813 --
8814 --
8815 -- Debug Statements
8816 --
8817 IF l_debug_on THEN
8818 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8819 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8820 END IF;
8821 --
8822 wsh_util_core.api_post_call
8823 (
8824 p_return_status => l_return_status,
8825 x_num_warnings => l_num_warnings,
8826 x_num_errors => l_num_errors
8827 );
8828 --
8829 --
8830 IF l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD
8831 THEN
8832 l_headerStatus := WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED;
8833 END IF;
8834 --}
8835 ELSE
8836 --{
8837 --
8838 -- Debug Statements
8839 --
8840 IF l_debug_on THEN
8841 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_RCV_CORR_RTV_TXN_PKG.PROCESS_CORRECTIONS_AND_RTV',WSH_DEBUG_SV.C_PROC_LEVEL);
8842 END IF;
8843 --
8844 WSH_RCV_CORR_RTV_TXN_PKG.process_corrections_and_rtv
8845 (
8846 p_rtv_corr_in_rec => p_line_rec,
8847 p_matched_detail_rec => l_matchedLineRecTbl,
8848 p_action_prms => l_action_prms2,
8849 p_rtv_corr_out_rec => l_rtv_corr_out_rec,
8850 x_po_cancel_rec => l_po_cancel_rec,
8851 x_po_close_rec => l_po_close_rec,
8852 x_msg_data => l_msg_data,
8853 x_msg_count => l_msg_count,
8854 x_return_status => l_return_status
8855 );
8856 --
8857 --
8858 --
8859 -- Debug Statements
8860 --
8861 IF l_debug_on THEN
8862 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8863 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8864 END IF;
8865 --
8866 wsh_util_core.api_post_call
8867 (
8868 p_return_status => l_return_status,
8869 x_num_warnings => l_num_warnings,
8870 x_num_errors => l_num_errors,
8871 p_msg_data => l_msg_data
8872 );
8873 --}
8874 END IF;
8875 --
8876 --
8877 IF l_debug_on THEN
8878 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE WSH_INBOUND_TXN_HISTORY');
8879 WSH_DEBUG_SV.log(l_module_name,'l_headerStatus',l_headerStatus);
8880 WSH_DEBUG_SV.log(l_module_name,'l_maxRCVTransactionId',l_maxRCVTransactionId);
8881 WSH_DEBUG_SV.log(l_module_name,'l_headerTransactionId',l_headerTransactionId);
8882 END IF;
8883 --
8884 --
8885 UPDATE WSH_INBOUND_TXN_HISTORY
8886 SET STATUS = l_headerStatus,
8887 OBJECT_VERSION_NUMBER = NVL(OBJECT_VERSION_NUMBER,0) + 1,
8888 MAX_RCV_TRANSACTION_ID = l_maxRCVTransactionId,
8889 SHIPMENT_NUMBER = l_shipmentNumber,
8890 RECEIPT_NUMBER = l_receiptNumber,
8891 LAST_UPDATE_DATE = SYSDATE,
8892 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
8893 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
8894 WHERE TRANSACTION_ID = l_headerTransactionId;
8895 --
8896 IF SQL%ROWCOUNT = 0
8897 THEN
8898 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_UPDATE_ERROR');
8899 FND_MESSAGE.SET_TOKEN('TRANSACTION_ID',l_headerTransactionId);
8900 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
8901 RAISE FND_API.G_EXC_ERROR;
8902 END IF;
8903 --
8904 --
8905 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8906 AND l_receiptAgainstASN = 'Y'
8907 THEN
8908 --{
8909 IF l_debug_on THEN
8910 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE WSH_INBOUND_TXN_HISTORY-ASN');
8911 WSH_DEBUG_SV.log(l_module_name,'l_parentTxnHistoryRec.transaction_id',l_parentTxnHistoryRec.transaction_id);
8912 END IF;
8913 --
8914 --
8915 UPDATE WSH_INBOUND_TXN_HISTORY
8916 SET OBJECT_VERSION_NUMBER = NVL(OBJECT_VERSION_NUMBER,0) + 1,
8917 SHIPMENT_NUMBER = l_shipmentNumber,
8918 RECEIPT_NUMBER = l_receiptNumber,
8919 LAST_UPDATE_DATE = SYSDATE,
8920 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
8921 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
8922 WHERE TRANSACTION_ID = l_parentTxnHistoryRec.transaction_id;
8923 --
8924 IF SQL%ROWCOUNT = 0
8925 THEN
8926 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_UPDATE_ERROR');
8927 FND_MESSAGE.SET_TOKEN('TRANSACTION_ID',l_parentTxnHistoryRec.transaction_id);
8928 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
8929 RAISE FND_API.G_EXC_ERROR;
8930 END IF;
8931 --}
8932 END IF;
8933 --
8934 --
8935 IF (
8936 l_po_cancel_rec.line_id.COUNT > 0
8937 OR l_po_close_rec.line_id.COUNT > 0
8938 )
8939 AND p_action_prms.ib_txn_history_id IS NULL
8940 THEN
8941 --{
8942 IF l_debug_on THEN
8943 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.cancel_close_pending_txns',WSH_DEBUG_SV.C_PROC_LEVEL);
8944 END IF;
8945 --
8946 WSH_ASN_RECEIPT_PVT.cancel_close_pending_txns
8947 (
8948 p_po_cancel_rec => l_po_cancel_rec,
8949 p_po_close_rec => l_po_close_rec,
8950 x_return_status => l_return_status
8951 );
8952 --
8953 --
8954 IF l_debug_on THEN
8955 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
8956 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8957 END IF;
8958 --
8959 wsh_util_core.api_post_call
8960 (
8961 p_return_status => l_return_status,
8962 x_num_warnings => l_num_warnings,
8963 x_num_errors => l_num_errors
8964 );
8965 --}
8966 END IF;
8967 --
8968 --
8969 /* Code moved outside this nested block
8970 --
8971 IF l_FailedTxnHistory_recTbl.shipment_header_id.COUNT > 0
8972 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8973 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8974 THEN
8975 l_minMatchedTransactionId := 1E38;
8976 RAISE e_notMatched;
8977 ELSE
8978 RAISE e_endOfAPI;
8979 END IF;
8980 --
8981 */
8982 --}
8983 EXCEPTION
8984 --{
8985 WHEN FND_API.G_EXC_ERROR
8986 OR FND_API.G_EXC_UNEXPECTED_ERROR
8987 OR e_NotMatched
8988 THEN
8989 --{
8990 IF l_MatchedTxnHistory_recTbl.shipment_header_id.COUNT > 0
8991 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
8992 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
8993 THEN
8994 --{
8995 --
8996 -- Debug Statements
8997 --
8998 IF l_debug_on THEN
8999 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.autonomous_Create_bulk',WSH_DEBUG_SV.C_PROC_LEVEL);
9000 END IF;
9001 --
9002 WSH_INBOUND_TXN_HISTORY_PKG.autonomous_Create_bulk
9003 (
9004 x_inboundTxnHistory_recTbl => l_MatchedTxnHistory_recTbl,
9005 x_return_status => l_return_status
9006 );
9007 --
9008 --
9009 --
9010 -- Debug Statements
9011 --
9012 IF l_debug_on THEN
9013 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9014 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9015 END IF;
9016 --
9017 wsh_util_core.api_post_call
9018 (
9019 p_return_status => l_return_status,
9020 x_num_warnings => l_num_warnings,
9021 x_num_errors => l_num_errors
9022 );
9023 --}
9024 END IF;
9025 --
9026 --
9027 RAISE e_notMatched;
9028 --}
9029 --}
9030 END;
9031 --
9032 IF l_FailedTxnHistory_recTbl.shipment_header_id.COUNT > 0
9033 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
9034 AND l_transactionType <> WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
9035 THEN
9036 l_minMatchedTransactionId := 1E38;
9037 RAISE e_notMatched;
9038 ELSE
9039 RAISE e_endOfAPI;
9040 END IF;
9041 --
9042 -- Debug Statements
9043 --
9044 IF l_debug_on THEN
9045 WSH_DEBUG_SV.pop(l_module_name);
9046 END IF;
9047 --}
9048 EXCEPTION
9049 --{
9050 WHEN e_endOfAPI THEN
9051 --{
9052 --
9053 --
9054 IF l_debug_on THEN
9055 WSH_DEBUG_SV.logmsg(l_module_name,
9056 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
9057 END IF;
9058 --
9059 IF l_num_errors > 0
9060 THEN
9061 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
9062 ELSIF l_num_warnings > 0
9063 THEN
9064 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9065 ELSE
9066 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
9067 END IF;
9068 --}
9069 --
9070 -- Debug Statements
9071 --
9072 IF l_debug_on THEN
9073 WSH_DEBUG_SV.logmsg(l_module_name,'E_ENDOFAPI exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9074 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:E_ENDOFAPI');
9075 END IF;
9076 --
9077 WHEN e_notMatched THEN
9078 --{
9079 IF l_MatchedTxnHistory_recTbl.shipment_header_id.COUNT = 0
9080 THEN
9081 ROLLBACK TO matchTransaction_sp;
9082 END IF;
9083 --
9084 --
9085 -- Debug Statements
9086 --
9087 IF l_debug_on THEN
9088 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.HANDLEMATCHFAILURE',WSH_DEBUG_SV.C_PROC_LEVEL);
9089 END IF;
9090 --
9091 WSH_IB_TXN_MATCH_PKG.handleMatchFailure
9092 (
9093 p_transactionType => l_transactionType, --l_transactionSubType,
9094 p_transactionMeaning => l_transactionMeaning,
9095 p_ReceiptAgainstASN => l_ReceiptAgainstASN,
9096 p_minFailedTransactionId => l_minFailedTransactionId,
9097 p_minMatchedTransactionId => l_minMatchedTransactionId,
9098 p_maxRCVTransactionId => l_maxRCVTransactionId,
9099 p_headerTransactionId => l_headerTransactionId,
9100 p_headerObjectVersionNumber => l_headerObjectVersionNumber,
9101 p_headerStatus => l_headerStatus,
9102 p_messageStartIndex => l_messageStartIndex,
9103 p_RCVShipmentHeaderId => l_RCVShipmentHeaderId,
9104 p_shipmentNumber => l_shipmentNumber,
9105 p_receiptNumber => l_receiptNumber,
9106 x_return_status => l_return_status
9107 );
9108 --
9109 x_return_status := l_return_status;
9110 --}
9111 /*---We do not need this
9112
9113 WHEN e_fatalError THEN
9114 ROLLBACK TO matchTransaction_sp;
9115 --
9116 FND_MESSAGE.SET_NAME('WSH','WSH_IB_MATCH_FATAL_ERROR');
9117 FND_MESSAGE.SET_TOKEN('TRANSACTION_CODE',p_action_prms.action_code);
9118 FND_MESSAGE.SET_TOKEN('SHIPMENT_NUM',l_shipmentNumber);
9119 FND_MESSAGE.SET_TOKEN('RECEIPT_NUM',l_receiptNumber);
9120 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
9121 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
9122 */
9123 --
9124 -- Debug Statements
9125 --
9126 IF l_debug_on THEN
9127 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9128 WSH_DEBUG_SV.logmsg(l_module_name,'E_NOTMATCHED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9129 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:E_NOTMATCHED');
9130 END IF;
9131 --
9132 WHEN FND_API.G_EXC_ERROR THEN
9133 ROLLBACK TO matchTransaction_sp;
9134 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
9135 --
9136 -- Debug Statements
9137 --
9138 IF l_debug_on THEN
9139 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9140 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
9141 END IF;
9142 --
9143 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9144 ROLLBACK TO matchTransaction_sp;
9145 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
9146 --
9147 -- Debug Statements
9148 --
9149 IF l_debug_on THEN
9150 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9151 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9152 END IF;
9153 --
9154 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
9155 --ROLLBACK TO matchTransaction_sp;
9156 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9157 --
9158 -- Debug Statements
9159 --
9160 IF l_debug_on THEN
9161 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9162 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9163 END IF;
9164 --
9165 WHEN OTHERS THEN
9166 ROLLBACK TO matchTransaction_sp;
9167 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
9168 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.matchTransaction');
9169 --
9170 -- Debug Statements
9171 --
9172 IF l_debug_on THEN
9173 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
9174 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
9175 END IF;
9176 --
9177 --}
9178 END matchTransaction;
9179
9180 PROCEDURE processPriorReceipts
9181 (
9182 p_shipmentHeaderId IN NUMBER,
9183 p_transactionType IN VARCHAR2,
9184 p_MAtransactionType IN VARCHAR2,
9185 p_inboundTxnHistoryId IN NUMBER,
9186 p_maxRcvTxnId IN NUMBER,
9187 p_poHeaderId IN NUMBER,
9188 p_hzShipFromLocationId IN NUMBER, -- IB-Phase-2
9189 x_return_status OUT NOCOPY VARCHAR2
9190 )
9191 IS
9192 --{
9193 l_shpmt_lines_out_rec WSH_IB_SHPMT_LINE_REC_TYPE;
9194 l_line_rec OE_WSH_BULK_GRP.Line_rec_type;
9195 l_action_prms WSH_BULK_TYPES_GRP.action_parameters_rectype;
9196 l_rslId_cache_tbl WSH_UTIL_CORE.key_value_tab_type;
9197 l_rslId_cache_ext_tbl WSH_UTIL_CORE.key_value_tab_type;
9198 --
9199 l_poHeaderId NUMBER;
9200 l_poShipmentLineId NUMBER;
9201 l_rcvShipmentLineId NUMBER;
9202 l_max_rcv_txn_id NUMBER;
9203 l_index NUMBER;
9204 l_lineRecIndex NUMBER;
9205 l_processRTVFlag BOOLEAN := FALSE;
9206 --
9207 l_return_status VARCHAR2(1);
9208 l_num_errors NUMBER := 0;
9209 l_num_warnings NUMBER := 0;
9210 l_msg_count NUMBER;
9211 l_msg_data VARCHAR2(32767);
9212 --
9213 l_debug_on BOOLEAN;
9214 --
9215 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PROCESSPRIORRECEIPTS';
9216 --}
9217 BEGIN
9218 --{
9219 --
9220 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9221 --
9222 IF l_debug_on IS NULL
9223 THEN
9224 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9225 END IF;
9226 --
9227 --
9228 -- Debug Statements
9229 --
9230 IF l_debug_on THEN
9231 WSH_DEBUG_SV.push(l_module_name);
9232 WSH_DEBUG_SV.log(l_module_name,'p_shipmentHeaderId',p_shipmentHeaderId);
9233 WSH_DEBUG_SV.log(l_module_name,'p_transactionType',p_transactionType);
9234 WSH_DEBUG_SV.log(l_module_name,'p_MAtransactionType',p_MAtransactionType);
9235 WSH_DEBUG_SV.log(l_module_name,'p_inboundTxnHistoryId',p_inboundTxnHistoryId);
9236 WSH_DEBUG_SV.log(l_module_name,'p_maxRcvTxnId',p_maxRcvTxnId);
9237 WSH_DEBUG_SV.log(l_module_name,'p_poHeaderId',p_poHeaderId);
9238 END IF;
9239 --
9240 IF l_debug_on THEN
9241 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_UI_RECON_GRP.get_shipment_lines',WSH_DEBUG_SV.C_PROC_LEVEL);
9242 END IF;
9243 --
9244 WSH_IB_UI_RECON_GRP.get_shipment_lines
9245 (
9246 p_api_version_number => 1.0 ,
9247 p_init_msg_list => FND_API.G_FALSE ,
9248 p_commit => FND_API.G_FALSE ,
9249 p_shipment_header_id => p_shipmentHeaderId ,
9250 p_transaction_type => p_transactionType ,
9251 p_view_only_flag => 'Y' ,
9252 x_shpmt_lines_out_rec => l_shpmt_lines_out_rec ,
9253 x_max_rcv_txn_id => l_max_rcv_txn_id ,
9254 x_msg_count => l_msg_count ,
9255 x_msg_data => l_msg_data ,
9256 x_return_status => l_return_status
9257 );
9258 --
9259 -- Debug Statements
9260 --
9261 IF l_debug_on THEN
9262 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9263 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9264 END IF;
9265 --
9266 wsh_util_core.api_post_call
9267 (
9268 p_return_status => l_return_status,
9269 x_num_warnings => l_num_warnings,
9270 x_num_errors => l_num_errors,
9271 p_msg_data => l_msg_data
9272 );
9273 --
9274 --
9275 l_index := l_shpmt_lines_out_rec.shipment_line_id_tab.FIRST;
9276 --
9277 WHILE l_index IS NOT NULL
9278 LOOP
9279 --{
9280 IF l_debug_on
9281 THEN
9282 WSH_DEBUG_SV.log(l_module_name,'l_index',l_index);
9283 END IF;
9284 --
9285 --
9286 l_poShipmentLineId := l_shpmt_lines_out_rec.po_line_location_id_tab(l_index);
9287 l_poHeaderId := l_shpmt_lines_out_rec.po_header_id_tab(l_index);
9288 l_rcvShipmentLineId := l_shpmt_lines_out_rec.shipment_line_id_tab(l_index);
9289 --
9290 --
9291 IF l_debug_on THEN
9292 WSH_DEBUG_SV.log(l_module_name,'l_poShipmentLineId',l_poShipmentLineId);
9293 WSH_DEBUG_SV.log(l_module_name,'l_poHeaderId',l_poHeaderId);
9294 WSH_DEBUG_SV.log(l_module_name,'l_rcvShipmentLineId',l_rcvShipmentLineId);
9295 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.get_po_rcv_attributess',WSH_DEBUG_SV.C_PROC_LEVEL);
9296 END IF;
9297 --
9298 --
9299 IF l_poHeaderId = p_poHeaderId
9300 THEN
9301 --{
9302 WSH_INBOUND_UTIL_PKG.get_po_rcv_attributes
9303 (
9304 p_po_line_location_id => l_poShipmentLineId,
9305 p_rcv_shipment_line_id => l_rcvShipmentLineId,
9306 x_line_rec => l_line_rec,
9307 x_return_status => l_return_status
9308 );
9309 --
9310 --
9311 --
9312 IF l_debug_on THEN
9313 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9314 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9315 END IF;
9316 --
9317 wsh_util_core.api_post_call
9318 (
9319 p_return_status => l_return_status,
9320 x_num_warnings => l_num_warnings,
9321 x_num_errors => l_num_errors
9322 );
9323 --
9324 --
9325 l_lineRecIndex := l_line_rec.shipment_line_id.LAST;
9326 --
9327 IF l_debug_on THEN
9328 WSH_DEBUG_SV.log(l_module_name,'l_lineRecIndex',l_lineRecIndex);
9329 END IF;
9330 --
9331 --
9332 l_line_rec.received_quantity_uom.EXTEND;
9333 l_line_rec.received_quantity2_uom.EXTEND;
9334 l_line_rec.rcv_transaction_id.EXTEND;
9335 --
9336 --
9337 IF l_debug_on THEN
9338 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.get_cached_value-l_rslId_cache_tbl',WSH_DEBUG_SV.C_PROC_LEVEL);
9339 END IF;
9340 --
9341 WSH_UTIL_CORE.get_cached_value
9342 (
9343 p_cache_tbl => l_rslId_cache_tbl,
9344 p_cache_ext_tbl => l_rslId_cache_ext_tbl,
9345 p_action => 'PUT',
9346 p_key => l_index,
9347 p_value => l_lineRecIndex,
9348 x_return_status => l_return_status
9349 );
9350 --
9351 --
9352 IF l_debug_on THEN
9353 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9354 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9355 END IF;
9356 --
9357 wsh_util_core.api_post_call
9358 (
9359 p_return_status => l_return_status,
9360 x_num_warnings => l_num_warnings,
9361 x_num_errors => l_num_errors
9362 );
9363 --
9364 --
9365 IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
9366 THEN
9367 --{
9368 l_line_rec.received_quantity(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_qty_shipped_tab(l_index);
9369 l_line_rec.received_quantity_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_uom_code_tab(l_index);
9370 l_line_rec.received_quantity2(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_qty_shipped_tab(l_index);
9371 l_line_rec.received_quantity2_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_uom_code_tab(l_index);
9372 l_line_rec.rcv_transaction_id(l_lineRecIndex) := l_shpmt_lines_out_rec.max_txn_id_tab(l_index);
9373 --}
9374 ELSE --IF p_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
9375 --{
9376 l_line_rec.received_quantity(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_qty_received_tab(l_index);
9377 l_line_rec.received_quantity_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_uom_code_tab(l_index);
9378 l_line_rec.received_quantity2(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_qty_received_tab(l_index);
9379 l_line_rec.received_quantity2_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_uom_code_tab(l_index);
9380 l_line_rec.rcv_transaction_id(l_lineRecIndex) := NVL(l_shpmt_lines_out_rec.max_txn_id_tab(l_index),p_maxRcvTxnId);
9381 --
9382 IF NOT(l_processRTVFlag)
9383 AND l_shpmt_lines_out_rec.primary_qty_returned_tab(l_index) > 0
9384 THEN
9385 --{
9386 l_processRTVFlag := TRUE;
9387 --}
9388 END IF;
9389 --}
9390 END IF;
9391 --}
9392 END IF;
9393 --
9394 l_index := l_shpmt_lines_out_rec.shipment_line_id_tab.NEXT(l_index);
9395 --}
9396 END LOOP;
9397 --
9398 --
9399 l_action_prms.action_code := p_MAtransactionType;
9400 l_action_prms.caller := 'WSH_IB_PO_INTG_PRIOR_RECEIPT';
9401 l_action_prms.ib_txn_history_id := p_inboundTxnHistoryId;
9402 l_action_prms.ship_from_location_id := p_hzShipFromLocationId; --IB-Phase-2
9403 --
9404 --
9405 IF l_debug_on THEN
9406 WSH_DEBUG_SV.log(l_module_name,'l_processRTVFlag',l_processRTVFlag);
9407 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.matchTransaction',WSH_DEBUG_SV.C_PROC_LEVEL);
9408 END IF;
9409 --
9410 WSH_IB_TXN_MATCH_PKG.matchTransaction
9411 (
9412 p_action_prms => l_action_prms,
9413 p_line_rec => l_line_rec,
9414 x_return_status => l_return_status
9415 );
9416 --
9417 --
9418 IF l_debug_on THEN
9419 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9420 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9421 END IF;
9422 --
9423 wsh_util_core.api_post_call
9424 (
9425 p_return_status => l_return_status,
9426 x_num_warnings => l_num_warnings,
9427 x_num_errors => l_num_errors
9428 );
9429 --
9430 --
9431 IF l_processRTVFlag
9432 THEN
9433 --{
9434 IF l_debug_on
9435 THEN
9436 WSH_DEBUG_SV.logmsg(l_module_name,'Processing RTV');
9437 END IF;
9438 --
9439 l_index := l_shpmt_lines_out_rec.shipment_line_id_tab.FIRST;
9440 --
9441 WHILE l_index IS NOT NULL
9442 LOOP
9443 --{
9444 l_poHeaderId := l_shpmt_lines_out_rec.po_header_id_tab(l_index);
9445 --
9446 --
9447 IF l_debug_on
9448 THEN
9449 WSH_DEBUG_SV.log(l_module_name,'l_index',l_index);
9450 WSH_DEBUG_SV.log(l_module_name,'l_poHeaderId',l_poHeaderId);
9451 END IF;
9452 --
9453 --
9454 IF l_poHeaderId = p_poHeaderId
9455 THEN
9456 --{
9457 IF l_debug_on THEN
9458 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.get_cached_value-l_rslId_cache_tbl',WSH_DEBUG_SV.C_PROC_LEVEL);
9459 END IF;
9460 --
9461 WSH_UTIL_CORE.get_cached_value
9462 (
9463 p_cache_tbl => l_rslId_cache_tbl,
9464 p_cache_ext_tbl => l_rslId_cache_ext_tbl,
9465 p_action => 'GET',
9466 p_key => l_index,
9467 p_value => l_lineRecIndex,
9468 x_return_status => l_return_status
9469 );
9470 --
9471 --
9472 IF l_debug_on THEN
9473 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9474 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9475 END IF;
9476 --
9477 wsh_util_core.api_post_call
9478 (
9479 p_return_status => l_return_status,
9480 x_num_warnings => l_num_warnings,
9481 x_num_errors => l_num_errors
9482 );
9483 --
9484 --
9485 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
9486 THEN
9487 IF l_debug_on THEN
9488 WSH_DEBUG_SV.logmsg(l_module_name,'Entry not found in l_rslId_cache');
9489 END IF;
9490 RAISE FND_API.G_EXC_ERROR;
9491 END IF;
9492 --
9493 --
9494 IF l_debug_on THEN
9495 WSH_DEBUG_SV.log(l_module_name,'l_lineRecIndex',l_lineRecIndex);
9496 END IF;
9497 --
9498 --
9499 l_line_rec.received_quantity_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_uom_code_tab(l_index);
9500 l_line_rec.received_quantity2_uom(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_uom_code_tab(l_index);
9501 l_line_rec.rcv_transaction_id(l_lineRecIndex) := NVL(l_shpmt_lines_out_rec.max_txn_id_tab(l_index),p_maxRcvTxnId);
9502 --
9503 IF l_shpmt_lines_out_rec.primary_qty_returned_tab(l_index) > 0
9504 THEN
9505 l_line_rec.received_quantity(l_lineRecIndex) := l_shpmt_lines_out_rec.primary_qty_returned_tab(l_index);
9506 l_line_rec.received_quantity2(l_lineRecIndex) := l_shpmt_lines_out_rec.secondary_qty_returned_tab(l_index);
9507 ELSE
9508 l_line_rec.received_quantity(l_lineRecIndex) := 0;
9509 l_line_rec.received_quantity2(l_lineRecIndex) := 0;
9510 END IF;
9511 --
9512 --}
9513 END IF;
9514 --
9515 l_index := l_shpmt_lines_out_rec.shipment_line_id_tab.NEXT(l_index);
9516 --}
9517 END LOOP;
9518 --
9519 --
9520 l_action_prms.action_code := WSH_INBOUND_TXN_HISTORY_PKG.C_RTV;
9521 l_action_prms.ib_txn_history_id := p_inboundTxnHistoryId;
9522 l_action_prms.caller := 'WSH_IB_PO_INTG_PRIOR_RECEIPT';
9523 l_action_prms.ship_from_location_id := p_hzShipFromLocationId; --IB-Phase-2
9524 --
9525 --
9526 IF l_debug_on THEN
9527 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.matchTransaction',WSH_DEBUG_SV.C_PROC_LEVEL);
9528 END IF;
9529 --
9530 WSH_IB_TXN_MATCH_PKG.matchTransaction
9531 (
9532 p_action_prms => l_action_prms,
9533 p_line_rec => l_line_rec,
9534 x_return_status => l_return_status
9535 );
9536 --
9537 --
9538 IF l_debug_on THEN
9539 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9540 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9541 END IF;
9542 --
9543 wsh_util_core.api_post_call
9544 (
9545 p_return_status => l_return_status,
9546 x_num_warnings => l_num_warnings,
9547 x_num_errors => l_num_errors
9548 );
9549 --}
9550 END IF;
9551 --
9552 IF l_debug_on THEN
9553 WSH_DEBUG_SV.logmsg(l_module_name,
9554 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
9555 END IF;
9556 --
9557 IF l_num_errors > 0
9558 THEN
9559 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
9560 ELSIF l_num_warnings > 0
9561 THEN
9562 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9563 ELSE
9564 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
9565 END IF;
9566 --
9567 -- Debug Statements
9568 --
9569 IF l_debug_on THEN
9570 WSH_DEBUG_SV.pop(l_module_name);
9571 END IF;
9572 --}
9573 EXCEPTION
9574 --{
9575 WHEN FND_API.G_EXC_ERROR THEN
9576 --ROLLBACK TO matchTransaction_sp;
9577 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
9578 --
9579 -- Debug Statements
9580 --
9581 IF l_debug_on THEN
9582 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9583 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
9584 END IF;
9585 --
9586 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9587 --ROLLBACK TO matchTransaction_sp;
9588 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
9589 --
9590 -- Debug Statements
9591 --
9592 IF l_debug_on THEN
9593 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9594 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
9595 END IF;
9596 --
9597 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
9598 --ROLLBACK TO matchTransaction_sp;
9599 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
9600 --
9601 -- Debug Statements
9602 --
9603 IF l_debug_on THEN
9604 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
9605 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
9606 END IF;
9607 --
9608 WHEN OTHERS THEN
9609 --ROLLBACK TO matchTransaction_sp;
9610 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
9611 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.processPriorReceipts');
9612 --
9613 -- Debug Statements
9614 --
9615 IF l_debug_on THEN
9616 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
9617 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
9618 END IF;
9619 --
9620 --}
9621 END processPriorReceipts;
9622
9623 PROCEDURE handlePriorReceipts
9624 (
9625 p_action_prms IN WSH_BULK_TYPES_GRP.action_parameters_rectype,
9626 x_line_rec IN OUT NOCOPY OE_WSH_BULK_GRP.Line_rec_type,
9627 x_return_status OUT NOCOPY VARCHAR2
9628 )
9629 IS
9630 --{
9631 -- bug 5639624
9632 -- Added po_release_id condition to the cursor
9633 CURSOR rcv_headers_csr (p_po_header_id NUMBER, p_po_release_id NUMBER)
9634 IS
9635 SELECT rsl.shipment_header_id,
9636 WSH_INBOUND_TXN_HISTORY_PKG.C_ASN txn_type,
9637 sum(nvl(DECODE(rsh.asn_type,'ASN',quantity_shipped,'ASBN',quantity_shipped,0),0)) shp_rcv_qty,
9638 1 max_rcv_txn_id
9639 FROM rcv_shipment_lines rsl, rcv_shipment_headers rsh
9640 WHERE po_header_id = p_po_header_id
9641 AND po_release_id = nvl(p_po_release_id,po_release_id) -- bug 5639624
9642 AND rsl.shipment_header_id = rsh.shipment_header_id
9643 GROUP BY rsl.shipment_header_id
9644 UNION ALL
9645 SELECT shipment_header_id,
9646 WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT txn_type,
9647 sum(nvl(quantity,0)) shp_rcv_qty,
9648 max(transaction_id) max_rcv_txn_id
9649 FROM rcv_transactions
9650 WHERE po_header_id = p_po_header_id
9651 AND po_release_id = nvl(p_po_release_id,po_release_id) -- bug 5639624
9652 AND transaction_type IN ( 'RECEIVE','MATCH')
9653 GROUP BY shipment_header_id
9654 ORDER BY 1;
9655 --
9656 --
9657 CURSOR rcv_txns_csr (p_po_header_id NUMBER, p_rcv_header_id NUMBER, p_po_release_id NUMBER)
9658 IS
9659 SELECT 1
9660 FROM rcv_transactions
9661 WHERE po_header_id = p_po_header_id
9662 AND po_release_id = nvl(p_po_release_id,po_release_id) -- bug 5639624
9663 AND shipment_header_id = p_rcv_header_id
9664 AND transaction_type = 'MATCH'
9665 AND rownum = 1;
9666 --
9667 --
9668 CURSOR rcv_header_csr (p_rcv_header_id NUMBER)
9669 IS
9670 select rsh.SHIPMENT_NUM,
9671 rsh.RECEIPT_NUM,
9672 rsh.CARRIER_ID,
9673 rsh.EXPECTED_RECEIPT_DATE,
9674 rsh.SHIPPED_DATE,
9675 rsh.VENDOR_ID,
9676 rsh.ORGANIZATION_ID,
9677 rsh.asn_type,
9678 wloc.wsh_location_id -- IB-Phase-2
9679 FROM rcv_fte_headers_v rsh,
9680 wsh_locations wloc
9681 WHERE rsh.shipment_header_id = p_rcv_header_id
9682 AND rsh.ship_from_location_id = wloc.source_location_id(+); -- IB-Phase-2
9683 --
9684 rcv_header_rec rcv_header_csr%ROWTYPE;
9685 --
9686 --
9687 CURSOR asn_csr (p_rcv_header_id NUMBER)
9688 IS
9689 select 1
9690 FROM rcv_shipment_lines rsl
9691 WHERE rsl.shipment_header_id = p_rcv_header_id
9692 AND rsl.shipment_line_status_code = 'CANCELLED'
9693 AND rownum = 1;
9694 --
9695 --IB-Phase-2
9696 CURSOR get_hz_location_csr(p_rcv_header_id NUMBER)
9697 IS
9698 select rsh.ship_from_location_id
9699 FROM rcv_shipment_headers rsh
9700 WHERE rsh.shipment_header_id = p_rcv_header_id;
9701 --
9702 l_hzShipFromLocationId NUMBER; --IB-Phase-2
9703 l_po_header_id NUMBER;
9704 l_po_release_id NUMBER; -- bug 5639624
9705 l_locked VARCHAR2(10);
9706 l_TransactionType VARCHAR2(30);
9707 l_transactionId NUMBER;
9708 l_txnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
9709 l_asnHistoryRec WSH_INBOUND_TXN_HISTORY_PKG.ib_txn_history_rec_type;
9710 --
9711 --
9712 l_po_cancel_rec OE_WSH_BULK_GRP.line_rec_type;
9713 l_po_close_rec OE_WSH_BULK_GRP.line_rec_type;
9714 l_index NUMBER;
9715 l_processedTxns BOOLEAN := FALSE;
9716 --
9717 l_return_status VARCHAR2(1);
9718 l_num_errors NUMBER := 0;
9719 l_num_warnings NUMBER := 0;
9720 --
9721 l_debug_on BOOLEAN;
9722 --
9723 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'HANDLEPRIORRECEIPTS';
9724 --}
9725 BEGIN
9726 --{
9727 --
9728 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
9729 --
9730 IF l_debug_on IS NULL
9731 THEN
9732 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
9733 END IF;
9734 --
9735 --
9736 -- Debug Statements
9737 --
9738 IF l_debug_on THEN
9739 WSH_DEBUG_SV.push(l_module_name);
9740 END IF;
9741 --
9742 l_po_header_id := x_line_rec.header_id(x_line_rec.header_id.FIRST);
9743 l_po_release_id := x_line_rec.header_id(x_line_rec.source_blanket_reference_id.FIRST);
9744 --
9745 IF l_debug_on THEN
9746 WSH_DEBUG_SV.log(l_module_name,'l_po_header_id',l_po_header_id);
9747 END IF;
9748 --
9749 --
9750 -- Check if any receiving transactions
9751 --
9752 FOR rcv_headers_rec IN rcv_headers_csr
9753 ( p_po_header_id => l_po_header_id,
9754 p_po_release_id => l_po_release_id )
9755 LOOP
9756 --{
9757 --
9758 IF l_debug_on THEN
9759 WSH_DEBUG_SV.log(l_module_name,'rcv_headers_rec.shipment_header_id',rcv_headers_rec.shipment_header_id);
9760 WSH_DEBUG_SV.log(l_module_name,'rcv_headers_rec.shp_rcv_qty',rcv_headers_rec.shp_rcv_qty);
9761 WSH_DEBUG_SV.log(l_module_name,'rcv_headers_rec.txn_type',rcv_headers_rec.txn_type);
9762 WSH_DEBUG_SV.log(l_module_name,'rcv_headers_rec.max_rcv_txn_id',rcv_headers_rec.max_rcv_txn_id);
9763 END IF;
9764 --
9765 --
9766 IF (
9767 (
9768 rcv_headers_rec.txn_type = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
9769 AND rcv_headers_rec.shp_rcv_qty > 0
9770 )
9771 OR
9772 rcv_headers_rec.txn_type = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
9773 )
9774 THEN
9775 --{
9776 IF l_debug_on THEN
9777 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.GET_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
9778 END IF;
9779 --
9780 l_transactionType := rcv_headers_rec.txn_type;
9781 l_txnHistoryRec.transaction_id := NULL;
9782 l_txnHistoryRec.status := NULL;
9783 l_txnHistoryRec.object_version_number := NULL;
9784 --
9785 -- Check if record already exists in WSH_INBOUND_TXN_HISTORY
9786 --
9787 IF l_debug_on THEN
9788 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.LOCK_ASN_RECEIPT_HEADER',WSH_DEBUG_SV.C_PROC_LEVEL);
9789 END IF;
9790 --
9791 WSH_INBOUND_TXN_HISTORY_PKG.lock_asn_receipt_header
9792 (
9793 p_shipment_header_id => rcv_headers_rec.shipment_header_id,
9794 p_transaction_type => rcv_headers_rec.txn_type,
9795 p_on_error => 'RETRY',
9796 p_on_noDataFound => WSH_UTIL_CORE.G_RET_STS_SUCCESS,
9797 x_txn_history_rec => l_txnHistoryRec,
9798 x_return_status => l_return_status,
9799 x_locked => l_locked
9800 );
9801 --
9802 --
9803 --
9804 -- Debug Statements
9805 --
9806 IF l_debug_on THEN
9807 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9808 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9809 END IF;
9810 --
9811 wsh_util_core.api_post_call
9812 (
9813 p_return_status => l_return_status,
9814 x_num_warnings => l_num_warnings,
9815 x_num_errors => l_num_errors
9816 );
9817 --
9818 --
9819 IF l_debug_on THEN
9820 WSH_DEBUG_SV.log(l_module_name,'l_txnHistoryRec.transaction_id',l_txnHistoryRec.transaction_id);
9821 WSH_DEBUG_SV.log(l_module_name,'l_txnHistoryRec.status',l_txnHistoryRec.status);
9822 WSH_DEBUG_SV.log(l_module_name,'l_txnHistoryRec.object_version_number',l_txnHistoryRec.object_version_number);
9823 END IF;
9824 --
9825 --
9826 IF l_txnHistoryRec.transaction_id IS NULL
9827 THEN
9828 --{
9829 OPEN rcv_header_csr(p_rcv_header_id => rcv_headers_rec.shipment_header_id);
9830 FETCH rcv_header_csr INTO rcv_header_rec;
9831 CLOSE rcv_header_csr;
9832 --
9833 --
9834 l_asnHistoryRec.RECEIPT_NUMBER := rcv_header_rec.receipt_num;
9835 l_asnHistoryRec.SHIPMENT_NUMBER := rcv_header_rec.shipment_num;
9836 l_asnHistoryRec.TRANSACTION_TYPE := l_transactionType;
9837 l_asnHistoryRec.SHIPMENT_HEADER_ID := rcv_headers_rec.shipment_header_id;
9838 l_asnHistoryRec.ORGANIZATION_ID := rcv_header_rec.ORGANIZATION_ID;
9839 l_asnHistoryRec.SUPPLIER_ID := rcv_header_rec.VENDOR_ID;
9840 l_asnHistoryRec.SHIPPED_DATE := rcv_header_rec.SHIPPED_DATE;
9841 l_asnHistoryRec.RECEIPT_DATE := rcv_header_rec.EXPECTED_RECEIPT_DATE;
9842 l_asnHistoryRec.CARRIER_ID := rcv_header_rec.CARRIER_ID;
9843 l_asnHistoryRec.STATUS := WSH_INBOUND_TXN_HISTORY_PKG.C_PENDING;
9844 l_asnHistoryRec.SHIP_FROM_LOCATION_ID := rcv_header_rec.wsh_location_id; -- IB-Phase-2
9845 l_asnHistoryRec.MAX_RCV_TRANSACTION_ID := NULL;
9846 l_asnHistoryRec.parent_shipment_header_id := NULL;
9847 --
9848 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
9849 THEN
9850 --{
9851 l_asnHistoryRec.MAX_RCV_TRANSACTION_ID := rcv_headers_rec.max_rcv_txn_id;
9852 --
9853 IF rcv_header_rec.asn_type IN ('ASN','ASBN')
9854 THEN
9855 l_asnHistoryRec.parent_shipment_header_id := rcv_headers_rec.shipment_header_id;
9856 END IF;
9857 --}
9858 END IF;
9859 --
9860 --
9861 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_ASN
9862 THEN
9863 --{
9864 FOR asn_rec IN asn_csr(p_rcv_header_id => rcv_headers_rec.shipment_header_id)
9865 LOOP
9866 --{
9867 l_txnHistoryRec.STATUS := WSH_INBOUND_TXN_HISTORY_PKG.C_CANCELLED;
9868 --}
9869 END LOOP;
9870 --}
9871 END IF;
9872 --
9873 IF l_debug_on THEN
9874 WSH_DEBUG_SV.log(l_module_name,'l_asnHistoryRec.SHIPMENT_HEADER_ID',l_asnHistoryRec.SHIPMENT_HEADER_ID);
9875 WSH_DEBUG_SV.log(l_module_name,'l_asnHistoryRec.status',l_asnHistoryRec.status);
9876 WSH_DEBUG_SV.log(l_module_name,'l_txnHistoryRec.status',l_txnHistoryRec.status);
9877 END IF;
9878 --
9879 --
9880 IF l_asnHistoryRec.SHIPMENT_HEADER_ID = rcv_headers_rec.shipment_header_id
9881 THEN
9882 --{
9883 IF l_debug_on THEN
9884 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.CREATE_TXN_HISTORY',WSH_DEBUG_SV.C_PROC_LEVEL);
9885 END IF;
9886 --
9887 WSH_INBOUND_TXN_HISTORY_PKG.create_txn_history
9888 (
9889 p_txn_history_rec => l_asnHistoryRec,
9890 x_txn_id => l_transactionId,
9891 x_return_status => l_return_status
9892 );
9893 --
9894 -- Debug Statements
9895 --
9896 IF l_debug_on THEN
9897 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9898 WSH_DEBUG_SV.log(l_module_name,'l_transactionId',l_transactionId);
9899 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9900 END IF;
9901 --
9902 wsh_util_core.api_post_call
9903 (
9904 p_return_status => l_return_status,
9905 x_num_warnings => l_num_warnings,
9906 x_num_errors => l_num_errors
9907 );
9908 --
9909 --
9910 l_txnHistoryRec.transaction_id := l_transactionId;
9911 --}
9912 END IF;
9913 --}
9914 END IF;
9915 --
9916 --
9917 IF l_txnHistoryRec.status IN (
9918 WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED,
9919 WSH_INBOUND_TXN_HISTORY_PKG.C_MATCHED_AND_CHILD_PENDING
9920 )
9921 OR l_txnHistoryRec.status IS NULL
9922 THEN
9923 --{
9924 IF l_transactionType = WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT
9925 THEN
9926 --{
9927 --IF l_txnHistoryRec.transaction_id IS NOT NULL
9928 IF l_txnHistoryRec.status IS NOT NULL
9929 THEN
9930 l_transactionType := WSH_INBOUND_TXN_HISTORY_PKG.C_RECEIPT_ADD;
9931 END IF;
9932 --
9933 --
9934 FOR rcv_txns_rec IN rcv_txns_csr
9935 (
9936 p_po_header_id => l_po_header_id,
9937 p_rcv_header_id => rcv_headers_rec.shipment_header_id,
9938 p_po_release_id => l_po_release_id
9939 )
9940 LOOP
9941 --{
9942 IF l_txnHistoryRec.transaction_id IS NULL
9943 THEN
9944 l_transactionType := 'MATCH';
9945 ELSE
9946 l_transactionType := 'MATCH_ADD';
9947 END IF;
9948 --}
9949 END LOOP;
9950 --}
9951 END IF;
9952 --
9953 --IF l_txnHistoryRec.transaction_id IS NULL
9954 --OR l_objectVersionNumber = l_txnHistoryRec.object_version_number
9955 --THEN
9956 --{
9957 IF l_debug_on THEN
9958 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_IB_TXN_MATCH_PKG.processPriorReceipts',WSH_DEBUG_SV.C_PROC_LEVEL);
9959 END IF;
9960 --
9961 l_processedTxns := TRUE;
9962 --
9963 --IB-Phase-2
9964 OPEN get_hz_location_csr(rcv_headers_rec.shipment_header_id);
9965 FETCH get_hz_location_csr INTO l_hzShipFromLocationId;
9966 CLOSE get_hz_location_csr;
9967 --
9968
9969 WSH_IB_TXN_MATCH_PKG.processPriorReceipts
9970 (
9971 p_shipmentHeaderId => rcv_headers_rec.shipment_header_id ,
9972 p_transactionType => rcv_headers_rec.txn_type,
9973 p_MAtransactionType => l_transactionType,
9974 p_inboundTxnHistoryId => l_txnHistoryRec.transaction_id,
9975 p_maxRcvTxnId => rcv_headers_rec.max_rcv_txn_id,
9976 p_poHeaderId => l_po_header_id,
9977 p_hzShipFromLocationId => l_hzShipFromLocationId, --IB-Phase-2
9978 x_return_status => l_return_status
9979 );
9980 --
9981 -- Debug Statements
9982 --
9983 IF l_debug_on THEN
9984 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
9985 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
9986 END IF;
9987 --
9988 wsh_util_core.api_post_call
9989 (
9990 p_return_status => l_return_status,
9991 x_num_warnings => l_num_warnings,
9992 x_num_errors => l_num_errors
9993 );
9994 --}
9995 --END IF;
9996 --}
9997 ELSIF l_txnHistoryRec.transaction_id IS NOT NULL
9998 THEN
9999 --{
10000 IF l_debug_on THEN
10001 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE WSH_INBOUND_TXN_HISTORY-PENDING');
10002 WSH_DEBUG_SV.log(l_module_name,'l_txnHistoryRec.transaction_id',l_txnHistoryRec.transaction_id);
10003 END IF;
10004 --
10005 --
10006 UPDATE WSH_INBOUND_TXN_HISTORY
10007 SET OBJECT_VERSION_NUMBER = NVL(OBJECT_VERSION_NUMBER,0) + 1,
10008 LAST_UPDATE_DATE = SYSDATE,
10009 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
10010 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
10011 WHERE TRANSACTION_ID = l_txnHistoryRec.transaction_id;
10012 --
10013 IF SQL%ROWCOUNT = 0
10014 THEN
10015 FND_MESSAGE.SET_NAME('WSH','WSH_IB_TXN_UPDATE_ERROR');
10016 FND_MESSAGE.SET_TOKEN('TRANSACTION_ID',l_txnHistoryRec.transaction_id);
10017 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
10018 RAISE FND_API.G_EXC_ERROR;
10019 END IF;
10020 --}
10021 END IF;
10022 --}
10023 END IF;
10024 --}
10025 END LOOP;
10026 --
10027 --
10028 l_index := x_line_rec.header_id.FIRST;
10029 --
10030 --
10031 WHILE l_index IS NOT NULL
10032 AND l_processedTxns
10033 LOOP
10034 --{
10035 IF l_debug_on THEN
10036 WSH_DEBUG_SV.log(l_module_name,'Processing x_line_rec:l_index',l_index);
10037 WSH_DEBUG_SV.log(l_module_name,'x_line_rec.closed_flag(l_index)',x_line_rec.closed_flag(l_index));
10038 WSH_DEBUG_SV.log(l_module_name,'x_line_rec.closed_code(l_index)',x_line_rec.closed_code(l_index));
10039 WSH_DEBUG_SV.log(l_module_name,'x_line_rec.cancelled_flag(l_index)',x_line_rec.cancelled_flag(l_index));
10040 END IF;
10041 --
10042 -- If PO has done a cancel/close operation on a particular record, and due to
10043 -- the fact that the corresponding transaction was in pending status, it could not
10044 -- be updated at that point of time, for such records, once the matching has been done,
10045 -- the recrods need to be updated to the status of the corresponding po record.
10046
10047 /* For cancelled recrods also the closed code is populated as CLOSED.
10048 So instead of populating the cancel rec, the close rec is getting populated
10049 and the open lines are getting closed instead of cancelled.Putting additional
10050 check on the cancelled_flag to avoid this.*/
10051 --
10052 IF NVL(x_line_rec.closed_code(l_index), 'N') IN ('CLOSED', 'CLOSED FOR RECEIVING', 'FINALLY CLOSED')
10053 AND NVL(x_line_rec.cancelled_flag(l_index), 'N') <> 'Y'
10054 THEN
10055 --{
10056 l_po_close_rec.header_id.EXTEND;
10057 l_po_close_rec.line_id.EXTEND;
10058 l_po_close_rec.po_shipment_line_id.EXTEND;
10059 l_po_close_rec.source_blanket_reference_id.EXTEND;
10060 --
10061 l_po_close_rec.header_id(l_po_close_rec.header_id.COUNT) := x_line_rec.header_id(l_index);
10062 l_po_close_rec.line_id(l_po_close_rec.header_id.COUNT ) := x_line_rec.line_id(l_index);
10063 l_po_close_rec.po_shipment_line_id(l_po_close_rec.header_id.COUNT) := x_line_rec.po_shipment_line_id(l_index);
10064 l_po_close_rec.source_blanket_reference_id(l_po_close_rec.header_id.COUNT) := x_line_rec.source_blanket_reference_id(l_index);
10065 ELSIF NVL(x_line_rec.cancelled_flag(l_index), 'N') = 'Y'
10066 THEN
10067 --{
10068 l_po_cancel_rec.header_id.EXTEND;
10069 l_po_cancel_rec.line_id.EXTEND;
10070 l_po_cancel_rec.po_shipment_line_id.EXTEND;
10071 l_po_cancel_rec.source_blanket_reference_id.EXTEND;
10072 --
10073 l_po_cancel_rec.header_id(l_po_cancel_rec.header_id.COUNT) := x_line_rec.header_id(l_index);
10074 l_po_cancel_rec.line_id(l_po_cancel_rec.header_id.COUNT ) := x_line_rec.line_id(l_index);
10075 l_po_cancel_rec.po_shipment_line_id(l_po_cancel_rec.header_id.COUNT ) := x_line_rec.po_shipment_line_id(l_index);
10076 l_po_cancel_rec.source_blanket_reference_id(l_po_cancel_rec.header_id.COUNT) := x_line_rec.source_blanket_reference_id(l_index);
10077 --}
10078 END IF;
10079 --
10080 l_index := x_line_rec.header_id.NEXT(l_index);
10081 --}
10082 END LOOP;
10083 --
10084 --
10085 --
10086 --
10087 IF l_po_cancel_rec.line_id.COUNT > 0
10088 OR l_po_close_rec.line_id.COUNT > 0
10089 THEN
10090 --{
10091 IF l_debug_on THEN
10092 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.cancel_close_pending_txns',WSH_DEBUG_SV.C_PROC_LEVEL);
10093 END IF;
10094 --
10095 WSH_ASN_RECEIPT_PVT.cancel_close_pending_txns
10096 (
10097 p_po_cancel_rec => l_po_cancel_rec,
10098 p_po_close_rec => l_po_close_rec,
10099 x_return_status => l_return_status
10100 );
10101 --
10102 --
10103 IF l_debug_on THEN
10104 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
10105 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
10106 END IF;
10107 --
10108 wsh_util_core.api_post_call
10109 (
10110 p_return_status => l_return_status,
10111 x_num_warnings => l_num_warnings,
10112 x_num_errors => l_num_errors
10113 );
10114 --}
10115 END IF;
10116 --
10117 --
10118 IF l_debug_on THEN
10119 WSH_DEBUG_SV.logmsg(l_module_name,
10120 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
10121 END IF;
10122 --
10123 IF l_num_errors > 0
10124 THEN
10125 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
10126 ELSIF l_num_warnings > 0
10127 THEN
10128 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
10129 ELSE
10130 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
10131 END IF;
10132 --
10133 -- Debug Statements
10134 --
10135 IF l_debug_on THEN
10136 WSH_DEBUG_SV.pop(l_module_name);
10137 END IF;
10138 --}
10139 EXCEPTION
10140 --{
10141 WHEN FND_API.G_EXC_ERROR THEN
10142 --ROLLBACK TO matchTransaction_sp;
10143 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
10144 --
10145 -- Debug Statements
10146 --
10147 IF l_debug_on THEN
10148 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10149 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
10150 END IF;
10151 --
10152 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10153 --ROLLBACK TO matchTransaction_sp;
10154 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
10155 --
10156 -- Debug Statements
10157 --
10158 IF l_debug_on THEN
10159 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10160 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
10161 END IF;
10162 --
10163 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
10164 --ROLLBACK TO matchTransaction_sp;
10165 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
10166 --
10167 -- Debug Statements
10168 --
10169 IF l_debug_on THEN
10170 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
10171 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
10172 END IF;
10173 --
10174 WHEN OTHERS THEN
10175 --ROLLBACK TO matchTransaction_sp;
10176 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
10177 wsh_util_core.default_handler('WSH_IB_TXN_MATCH_PKG.handlePriorReceipts');
10178 --
10179 -- Debug Statements
10180 --
10181 IF l_debug_on THEN
10182 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
10183 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
10184 END IF;
10185 --
10186 --}
10187 END handlePriorReceipts;
10188
10189
10190
10191 END WSH_IB_TXN_MATCH_PKG;