DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_REQ_LINES_SV

Source


1 PACKAGE BODY PO_REQ_LINES_SV as
2 /* $Header: POXRQL1B.pls 120.10 2008/01/04 11:15:49 ppadilam ship $ */
3 /*==========================  po_req_lines_sv  ============================*/
4 
5 
6   -- Constants :
7   -- Read the profile option that enables/disables the debug log
8   g_fnd_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
9 
10 /*===========================================================================
11 
12   PROCEDURE NAME:	lock_row_for_status_update
13 
14 ===========================================================================*/
15 
16 PROCEDURE lock_row_for_buyer_update (x_rowid  IN  VARCHAR2)
17 IS
18     CURSOR C IS
19         SELECT 	*
20         FROM   	po_requisition_lines
21         WHERE   rowid = x_rowid
22         FOR UPDATE of requisition_line_id NOWAIT;
23     Recinfo C%ROWTYPE;
24 
25     x_progress	VARCHAR2(3) := '';
26 
27 BEGIN
28     x_progress := '010';
29     OPEN C;
30     FETCH C INTO Recinfo;
31     IF (C%NOTFOUND) then
32         CLOSE C;
33         FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
34         APP_EXCEPTION.Raise_Exception;
35     END IF;
36     CLOSE C;
37 
38 EXCEPTION
39     WHEN app_exception.record_lock_exception THEN
40         po_message_s.app_error ('PO_ALL_CANNOT_RESERVE_RECORD');
41 
42     WHEN OTHERS THEN
43 	-- dbms_output.put_line('In Exception');
44 	PO_MESSAGE_S.SQL_ERROR('LOCK_ROW_FOR_BUYER_UPDATE', x_progress, sqlcode);
45 	RAISE;
46 END;
47 
48 
49 /*===========================================================================
50 
51   PROCEDURE NAME:	delete_line
52 
53 ===========================================================================*/
54 
55 PROCEDURE delete_line(X_line_id  		IN  NUMBER,
56 		      X_mode	 		IN  VARCHAR2,
57 		      X_transferred_to_oe_flag	OUT NOCOPY VARCHAR2) IS
58 
59 x_progress VARCHAR2(3) := NULL;
60 x_rowid    VARCHAR2(30);
61 
62 BEGIN
63 
64    x_progress := '010';
65 
66    SELECT rowid
67    INTO   x_rowid
68    FROM   po_requisition_lines
69    WHERE  requisition_line_id = x_line_id;
70 
71    -- dbms_output.put_line('After selecting rowid');
72 
73    /*
74    ** DEBUG: We need to delete attachments.
75    */
76 
77    /*
78    ** Delete the children before deleting the line.
79    */
80 
81    x_progress := '020';
82 
83    po_req_lines_sv.delete_children(X_line_id, X_mode);
84 
85    -- dbms_output.put_line('After call to delete children');
86 
87    /*
88    ** Delete the requisition line.
89    */
90 
91    x_progress := '030';
92 
93    po_requisition_lines_pkg1.delete_row(x_rowid, x_transferred_to_oe_flag);
94 
95    -- dbms_output.put_line('After call to delete line');
96 
97    EXCEPTION
98    WHEN OTHERS THEN
99       -- dbms_output.put_line('In exception');
100       po_message_s.sql_error('delete_line', x_progress, sqlcode);
101       raise;
102 END delete_line;
103 
104 /*===========================================================================
105 
106   PROCEDURE NAME:	delete_children
107 
108 ===========================================================================*/
109 
110 PROCEDURE delete_children(X_line_id   IN NUMBER,
111 			  X_mode      IN VARCHAR2) IS
112 
113 x_progress VARCHAR2(3) := NULL;
114 
115 BEGIN
116 
117    x_progress := '010';
118 
119    /*
120    ** DEBUG. Call to delete attachments.
121    */
122 
123    -- dbms_output.put_line('After call to delete attachments');
124 
125    x_progress := '020';
126 
127    DELETE FROM po_req_distributions
128    WHERE  requisition_line_id = X_line_id;
129 
130    -- dbms_output.put_line('After call to delete distributions');
131 
132    EXCEPTION
133    WHEN OTHERS THEN
134       -- dbms_output.put_line('In exception');
135       po_message_s.sql_error('delete_children', x_progress, sqlcode);
136       raise;
137 END delete_children;
138 
139 
140 
141 /*===========================================================================
142 
143   FUNCTION NAME:	val_reqs_po_shipment
144 
145 ===========================================================================*/
146 
147  FUNCTION val_reqs_po_shipment
148                   (X_req_header_id           IN     NUMBER,
149                    X_req_line_id             IN     NUMBER) RETURN BOOLEAN IS
150 
151    X_progress                 VARCHAR2(3) := NULL;
152    X_row_exists               NUMBER := 0;
153 
154  BEGIN
155 
156   --  dbms_output.put_line('Enter val_reqs_po_shipment');
157 
158    IF X_req_header_id is NOT NULL OR
159       X_req_line_id is NOT NULL THEN
160 
161       /* Search for line exists.
162       ** The following SQL statement is optimized to search for either
163       ** 1. all document lines - if header_id is passed or,
164       ** 2. one document line  - if both header_id and line_id are passed.
165       */
166 
167       X_progress := '010';
168       SELECT COUNT(1)
169       INTO   X_row_exists
170       FROM   PO_REQUISITION_LINES PORL,
171              PO_LINE_LOCATIONS POLL
172       WHERE  PORL.requisition_header_id = X_req_header_id
173       AND    PORL.requisition_line_id = nvl(X_req_line_id, PORL.requisition_line_id)
174       AND    PORL.line_location_id = POLL.line_location_id
175       AND    PORL.line_location_id is NOT NULL
176       AND    (nvl(POLL.closed_code, 'OPEN') <> 'FINALLY CLOSED'
177               AND nvl(POLL.cancel_flag, 'N') = 'N');
178    ELSE
179       /* DEBUG - show error message */
180       X_progress := '015';
181       po_message_s.sql_error('val_reqs_po_shipment', X_progress, sqlcode);
182    END IF;
183 
184    IF X_row_exists > 0 THEN
185       RETURN (FALSE);
186    ELSE
187       RETURN (TRUE);
188    END IF;
189 
190    -- dbms_output.put_line('Exit val_reqs_po_shipment');
191 
192    EXCEPTION
193    WHEN OTHERS THEN
194       po_message_s.sql_error('val_reqs_po_shipment', X_progress, sqlcode);
195    RAISE;
196 
197  END val_reqs_po_shipment;
198 
199 
200 
201 /*===========================================================================
202 
203   FUNCTION NAME:	val_reqs_oe_shipment
204 
205 ===========================================================================*/
206 
207  FUNCTION val_reqs_oe_shipment
208                   (X_req_header_id           IN     NUMBER,
209                    X_req_line_id             IN     NUMBER) RETURN BOOLEAN IS
210 
211    X_progress                 VARCHAR2(3) := NULL;
212    X_row_exists               NUMBER := 0;
213    p_req_line_id	      NUMBER;
214 
215    Cursor get_req_lines_cur is
216    	Select requisition_line_id
217         From po_requisition_lines
218         Where requisition_line_id = nvl(X_req_line_id, requisition_line_id)
219         And requisition_header_id = X_req_header_id
220         And source_type_code = 'INVENTORY';
221 
222  BEGIN
223 
224    -- dbms_output.put_line('Enter val_reqs_oe_shipment');
225 
226    IF X_req_header_id is NOT NULL OR
227       X_req_line_id is NOT NULL THEN
228 
229       /* Search for line exists.
230       ** The following SQL statement is optimized to search for either
231       ** 1. all document lines - if header_id is passed or,
232       ** 2. one document line  - if both header_id and line_id are passed.
233       */
234 
235       X_progress := '010';
236 
237 --Bug# 1392077
238 --Toju George 08/31/2000
239 --Modified the call to procedure to replace req_num and line_num with ids.
240 /*      SELECT COUNT(1)
241       INTO   X_row_exists
242       FROM   PO_REQUISITION_HEADERS PORH, PO_REQUISITION_LINES PORL,
243              PO_SYSTEM_PARAMETERS POSP
244        WHERE  PORH.requisition_header_id = X_req_header_id
245        AND    PORL.requisition_line_id = nvl(X_req_line_id, PORL.requisition_line_id)
246        AND    PORH.requisition_header_id = PORL.requisition_header_id
247        AND    PORL.source_type_code = 'INVENTORY'
248        AND    OE_ORDER_IMPORT_INTEROP_PUB .Get_Open_Qty(POSP.order_source_id,
249                                                        PORH.segment1,
250                                                        PORL.line_num ) > 0 ;
251 */
252       SELECT COUNT(1)
253       INTO   X_row_exists
254       FROM   PO_REQUISITION_HEADERS PORH, PO_REQUISITION_LINES PORL,
255              PO_SYSTEM_PARAMETERS POSP
256        WHERE  PORH.requisition_header_id = X_req_header_id
257        AND    PORL.requisition_line_id = nvl(X_req_line_id, PORL.requisition_line_id)
258        AND    PORH.requisition_header_id = PORL.requisition_header_id
259        AND    PORL.source_type_code = 'INVENTORY'
260        AND    OE_ORDER_IMPORT_INTEROP_PUB .Get_Open_Qty(POSP.order_source_id,
261                                                        PORH.requisition_header_id,
262                                                        PORL.requisition_line_id ) > 0 ;
263    ELSE
264       /* DEBUG - show error message */
265       X_progress := '015';
266       po_message_s.sql_error('val_reqs_oe_shipment', X_progress, sqlcode);
267    END IF;
268 
269    IF X_row_exists > 0 THEN
270       RETURN (FALSE);
271    ELSE
272       /* Bug#2492314: kagarwal
273       ** Now call to check whether the SO shipments are still in process.
274       */
275 
276       OPEN get_req_lines_cur;
277       LOOP
278         Fetch get_req_lines_cur Into p_req_line_id;
279         Exit When get_req_lines_cur%NotFound;
280 
281       	If NOT (val_oe_shipment_in_proc(X_req_header_id, p_req_line_id)) Then
282            RETURN(FALSE);
283         End If;
284 
285       END LOOP;
286 
287       RETURN (TRUE);
288    END IF;
289 
290    -- dbms_output.put_line('Exit val_reqs_oe_shipment');
291 
292    EXCEPTION
293    WHEN OTHERS THEN
294       po_message_s.sql_error('val_reqs_oe_shipment', X_progress, sqlcode);
295    RAISE;
296 
297  END val_reqs_oe_shipment;
298 
299 
300 /*===========================================================================
301 
302   FUNCTION NAME:	val_reqs_qty_delivered
303 
304 ===========================================================================*/
305 
306  FUNCTION val_reqs_qty_delivered
307                   (X_req_header_id           IN     NUMBER,
308                    X_req_line_id             IN     NUMBER) RETURN BOOLEAN IS
309 
310    X_progress                 VARCHAR2(3) := NULL;
311    X_row_exists               NUMBER := 0;
312 
313  BEGIN
314 
315    -- dbms_output.put_line('Enter val_reqs_qty_delivered');
316 
317    IF X_req_header_id is NOT NULL OR
318       X_req_line_id is NOT NULL THEN
319 
320       /* Search for line exists.
321       ** The following SQL statement is optimized to search for either
322       ** 1. all document lines - if header_id is passed or,
323       ** 2. one document line  - if both header_id and line_id are passed.
324       */
325       /* Bug# 5414478, We were using RCV_SHIPMENT_LINES quantity_received
326          to compare with quantity_deliverd in po_requisition_lines.
327          But in certain cases the Req. line and rcv_shipment_line are
328          in different UOM and were not doing the quantity conversion while
329          comparing quantity. Since we store the quantity_received in
330          po_requisition_lines and it is in the same UOM as quantity_received
331          we are going on quantity_received of po_requisition_lines
332          to do the comparision. */
333       X_progress := '010';
334       SELECT COUNT(1)
335       INTO   X_row_exists
336       FROM   PO_REQUISITION_LINES PORL
337       WHERE  PORL.requisition_header_id = X_req_header_id
338       AND    PORL.requisition_line_id = nvl(X_req_line_id, PORL.requisition_line_id)
339       AND    PORL.source_type_code = 'INVENTORY'
340       AND    nvl(PORL.cancel_flag, 'N') = 'N'
341       AND    nvl(PORL.closed_code, 'OPEN') <> 'FINALLY CLOSED'
342       AND    PORL.quantity_delivered < nvl(PORL.quantity_received,0);
343 
344       /* Start Bug# 5414478, Commented the code below
345                       (select nvl(sum(quantity_received),0)
346                  from RCV_SHIPMENT_LINES RSL
347                  where RSL.requisition_line_id = PORL.requisition_line_id);
348       End Bug# 5414478*/
349    ELSE
350       /* DEBUG - show error message */
351       X_progress := '015';
352       po_message_s.sql_error('val_reqs_qty_delivered', X_progress, sqlcode);
353    END IF;
354 
355    IF X_row_exists > 0 THEN
356       RETURN (FALSE);
357    ELSE
358       RETURN (TRUE);
359    END IF;
360 
361    -- dbms_output.put_line('Exit val_reqs_qty_delivered');
362 
363    EXCEPTION
364    WHEN OTHERS THEN
365       po_message_s.sql_error('val_reqs_qty_delivered', X_progress, sqlcode);
366    RAISE;
367 
368  END val_reqs_qty_delivered;
369 
370 
371 /*===========================================================================
372 
373   PROCEDURE NAME:	update_reqs_lines_incomplete
374 
375 ===========================================================================*/
376 
377  PROCEDURE update_reqs_lines_incomplete
378                   (X_req_header_id           IN     NUMBER,
379                    X_req_line_id             IN     NUMBER,
380                    X_req_control_error_rc    IN OUT NOCOPY VARCHAR2,
381                    X_oe_installed_flag       IN     VARCHAR2) IS
382 
383    X_progress                 VARCHAR2(3) := NULL;
384    X_quantity_cancelled       PO_REQUISITION_LINES.quantity_cancelled%TYPE := NULL;
385    X_order_source_id          po_system_parameters.order_source_id%TYPE;
386 
387  BEGIN
388 
389    -- dbms_output.put_line('Enter update_reqs_lines_incomplete');
390 
391    X_req_control_error_rc := '';
392 
393    IF X_req_header_id is NOT NULL OR
394       X_req_line_id is NOT NULL THEN
395 
396        X_progress := '010';
397 
398        IF (X_oe_installed_flag = 'Y') THEN
399 
400 	X_progress := '020';
401 
402        /* Bug#2275686: kagarwal
403        ** Desc: When OM is installed, we need to get the cancelled qty and
404        ** update it on the Req line before calling the code to reverse
405        ** encumbrance.
406        */
407 
408 	BEGIN
409        		select order_source_id
410        		into   X_order_source_id
411        		from po_system_parameters;
412 
413 		X_quantity_cancelled := OE_ORDER_IMPORT_INTEROP_PUB.Get_Cancelled_Qty(
414                                                            X_order_source_id,
415                                                            to_char(X_req_header_id),
416                                                            to_char(X_req_line_id));
417 	EXCEPTION
418             	WHEN NO_DATA_FOUND THEN
419                    X_quantity_cancelled := NULL;
420 	END;
421 
422        ELSE
423            X_quantity_cancelled := NULL;
424        END IF;
425 
426       /* The following SQL statement is optimized to update either
427       ** 1. all document lines - if header_id is passed or,
428       ** 2. one document line  - if both header_id and line_id are passed.
429       */
430       X_progress := '010';
431       UPDATE PO_REQUISITION_LINES
432       SET    cancel_flag = 'I',
433              quantity_cancelled = NVL(X_quantity_cancelled, quantity_cancelled),
434              reqs_in_pool_flag = NULL,          -- <REQINPOOL>
435              last_update_login = fnd_global.login_id,
436              last_updated_by = fnd_global.user_id,
437              last_update_date = sysdate
438       WHERE  requisition_header_id = X_req_header_id
439       AND    requisition_line_id = nvl(X_req_line_id, requisition_line_id)
440       AND    nvl(cancel_flag, 'N') IN ('N', 'I')
441       AND    nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
442 
443    ELSE
444       /* DEBUG - show error message */
445       X_req_control_error_rc := 'Y';
446       X_progress := '015';
447       po_message_s.sql_error('update_reqs_lines_incomplete', X_progress, sqlcode);
448    END IF;
449 
450    -- dbms_output.put_line('Exit update_reqs_lines_incomplete');
451 
452    EXCEPTION
453 
454    WHEN OTHERS THEN
455       X_req_control_error_rc := 'Y';
456       po_message_s.sql_error('update_reqs_lines_incomplete', X_progress, sqlcode);
457    RAISE;
458 
459 
460  END update_reqs_lines_incomplete;
461 
462 
463 /*===========================================================================
464 
465   PROCEDURE NAME:	update_reqs_lines_status
466 
467 ===========================================================================*/
468 
469  PROCEDURE update_reqs_lines_status
470                   (X_req_header_id           IN     NUMBER,
471                    X_req_line_id             IN     NUMBER,
472                    X_req_control_action      IN     VARCHAR2,
473                    X_req_control_reason      IN     VARCHAR2,
474 		   X_req_action_date         IN     DATE,
475                    X_oe_installed_flag       IN     VARCHAR2,
476                    X_req_control_error_rc    IN OUT NOCOPY VARCHAR2) IS
477 
478    X_progress                 VARCHAR2(3) := NULL;
479    X_cancel_flag              PO_REQUISITION_LINES.cancel_flag%TYPE := NULL;
480    X_cancel_date              PO_REQUISITION_LINES.cancel_date%TYPE := NULL;
481    X_cancel_reason            PO_REQUISITION_LINES.cancel_reason%TYPE := NULL;
482    X_closed_code              PO_REQUISITION_LINES.closed_code%TYPE := NULL;
483    X_closed_reason            PO_REQUISITION_LINES.closed_reason%TYPE := NULL;
484    X_closed_date              PO_REQUISITION_LINES.closed_date%TYPE := NULL;
485    X_quantity_cancelled       PO_REQUISITION_LINES.quantity_cancelled%TYPE := NULL;
486    X_terminal_performed       NUMBER(1) := 0;     -- <REQINPOOL>
487    X_order_source_id          PO_SYSTEM_PARAMETERS.order_source_id%TYPE;
488 
489  BEGIN
490 
491    -- dbms_output.put_line('Enter update_reqs_lines_status');
492 
493    IF SubStr(X_req_control_action,1,6) = 'CANCEL' THEN
494       X_cancel_flag   := 'Y';
495       X_cancel_reason := X_req_control_reason;
496 
497       /* <Modified Action Date TZ FPJ 10-10-2003>
498       *  change: should set cancel date to current time
499       *  previous: set cancel date to action_date field
500       *  That field was intended for GL/encumbrance only.
501       */
502 
503       X_cancel_date := SYSDATE;
504 
505       -- <End Action Date TZ FPJ>
506 
507       X_terminal_performed := 1;     -- <REQINPOOL>
508 
509    ELSIF X_req_control_action = 'FINALLY CLOSE' THEN
510          X_closed_code   := 'FINALLY CLOSED';
511          X_closed_reason := X_req_control_reason;
512 
513          -- <Modified Action Date TZ FPJ 10-10-2003, similar to above>
514          X_closed_date := SYSDATE;
515          -- <End Action Date TZ FPJ>
516 
517          X_terminal_performed := 1;      -- <REQINPOOL>
518 
519    END IF;
520 
521    IF (X_oe_installed_flag = 'Y' AND
522        SubStr(X_req_control_action,1,6) = 'CANCEL' AND
523        X_req_line_id IS NOT NULL) THEN
524 
525        /* Bug#2275686: kagarwal
526        ** Desc: When OM is installed, we need to get the cancelled qty and
527        ** update it on the Req line.
528        */
529 
530         BEGIN
531                 select order_source_id
532                 into   X_order_source_id
533                 from po_system_parameters;
534 
535                 X_quantity_cancelled := OE_ORDER_IMPORT_INTEROP_PUB.Get_Cancelled_Qty(
536                                                            X_order_source_id,
537                                                            to_char(X_req_header_id),
538                                                            to_char(X_req_line_id));
539         EXCEPTION
540                 WHEN NO_DATA_FOUND THEN
541                    X_quantity_cancelled := NULL;
542         END;
543 
544 
545    ELSE
546        X_quantity_cancelled := NULL;
547    END IF;
548 
549 
550    X_progress := '015';
551 
552    /* The following SQL statement is optimized to update either
553    ** 1. all document lines - if only header_id is passed.
554    ** 2. one document line  - if line_id is also passed.
555    */
556    /* Bug 4036549 - changed the below sql assignment from
557       quantity_cancelled = nvl(X_quantity_cancelled, quantity_cancelled) to
558       quantity_cancelled = nvl(X_quantity_cancelled, decode(X_cancel_flag,'Y',quantity,quantity_cancelled))
559    */
560 
561    UPDATE PO_REQUISITION_LINES
562    SET    cancel_flag        = nvl(X_cancel_flag, cancel_flag),
563           cancel_date        = nvl(X_cancel_date, cancel_date),
564           cancel_reason      = nvl(X_cancel_reason, cancel_reason),
565           closed_code        = nvl(X_closed_code, closed_code),
566           closed_reason      = nvl(X_closed_reason, closed_reason),
567           closed_date        = nvl(X_closed_date, closed_date),
568           contractor_status  = decode(X_cancel_flag,'Y',null,contractor_status), -- Bug 3495679
569           reqs_in_pool_flag  = DECODE(X_terminal_performed,
570                                       1,NULL,
571                                       reqs_in_pool_flag), -- <REQINPOOL>
572           last_update_login  = fnd_global.login_id,
573           last_updated_by    = fnd_global.user_id,
574           last_update_date   = sysdate,
575           quantity_cancelled = nvl(X_quantity_cancelled,
576                                    decode(X_cancel_flag, 'Y', quantity, quantity_cancelled)
577                                   )
578    WHERE  requisition_header_id = X_req_header_id
579    AND    requisition_line_id   = nvl(X_req_line_id, requisition_line_id)
580    AND    nvl(cancel_flag, 'N') IN ('N', 'I')
581    AND    nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
582 
583    -- dbms_output.put_line('Exit update_reqs_lines_status');
584   /* Start Bug 4036549 - updating the req_line_quantity to 0  for 'Purchase Req'*/
585    UPDATE PO_REQ_DISTRIBUTIONS
586    SET    req_line_quantity = 0
587    WHERE  requisition_line_id IN
588              (SELECT requisition_line_id
589               FROM   po_requisition_lines PORL
590               WHERE  PORL.requisition_header_id = X_req_header_id
591         AND    nvl(PORL.cancel_flag,'N') = 'Y'
592         AND    PORL.source_type_code = 'VENDOR'
593         AND    PORL.requisition_line_id = nvl(X_req_line_id, PORL.requisition_line_id));
594   /* End Bug 4036549 */
595 
596    EXCEPTION
597 
598    WHEN OTHERS THEN
599        X_req_control_error_rc := 'Y';
600       po_message_s.sql_error('update_reqs_lines_status', X_progress, sqlcode);
601    RAISE;
602 
603  END update_reqs_lines_status;
604 
605 
606 /*===========================================================================
607 
608   PROCEDURE NAME:	remove_req_from_po
609 
610 ===========================================================================*/
611 
612 PROCEDURE remove_req_from_po(X_entity_id  IN NUMBER,
613 			     X_entity     IN VARCHAR2) IS
614 
615 x_progress VARCHAR2(3) := NULL;
616 
617 --<DropShip FPJ Start>
618 l_po_header_id  PO_TBL_NUMBER;
619 l_po_release_id PO_TBL_NUMBER;
620 l_po_line_id    PO_TBL_NUMBER;
621 l_line_location_id PO_TBL_NUMBER;
622 L_req_header_id PO_TBL_NUMBER;
623 l_req_line_id   PO_TBL_NUMBER;
624 l_return_status VARCHAR2(30);
625 l_msg_data VARCHAR2(3000);
626 l_msg_count NUMBER;
627 l_api_name    CONSTANT VARCHAR(60) := 'po.plsql.PO_REQ_LINES_SV.REMOVE_REQ_FROM_PO';
628 
629 --<DropShip FPJ End>
630 
631 BEGIN
632 
633     IF g_fnd_debug = 'Y' THEN
634         IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
635           FND_LOG.string(FND_LOG.LEVEL_STATEMENT, l_api_name||'.'
636           || x_progress, 'Entered Procedure. Entity ' || X_entity || ' ID:' || X_entity_id);
637         END IF;
638     END IF;
639 
640    IF (X_entity = 'PURCHASE ORDER') THEN
641      x_progress := '010';
642      -- dbms_output.put_line('In update for Purchase Order related req lines');
643 
644      --<DropShip FPJ Start>
645      --SQL What: Finds DropShip Req Lines for this Purchase Order Header ID
646      SELECT  s.po_header_id, s.po_release_id, s.po_line_id, s.line_location_id,
647        rl.requisition_header_id, rl.requisition_line_id
648      BULK COLLECT INTO l_po_header_id, l_po_release_id, l_po_line_id, l_line_location_id,
649        L_req_header_id, l_req_line_id
650      FROM    po_line_locations s, po_requisition_lines rl
651      WHERE   s.line_location_id = rl.line_location_id and nvl(rl.drop_ship_flag, 'N') = 'Y'
652        AND s.po_header_id = X_entity_id;
653      --<DropShip FPJ End>
654 
655      UPDATE po_requisition_lines_all  -- Bug 3592153
656      SET    line_location_id = NULL,
657             reqs_in_pool_flag = 'Y',  -- Bug 2781027 resetting the reqs in pool flag
658             last_update_login = fnd_global.login_id,  -- Bug5623016 (updating who column)
659             last_updated_by = fnd_global.user_id,  -- Bug5623016 (updating who column)
660             last_update_date = sysdate  -- Bug5623016 (updating who column)
661 
662      WHERE  line_location_id in (SELECT  line_location_id
663 				 FROM    po_line_locations
664 				 WHERE   po_header_id = X_entity_id);
665 
666    ELSIF (X_entity = 'RELEASE') THEN
667      x_progress := '020';
668      -- dbms_output.put_line('In update for Release related req lines');
669 
670      --<DropShip FPJ Start>
671      --SQL What: Finds Drop Ship Req Lines for this Release ID
672      SELECT  s.po_header_id, s.po_release_id, s.po_line_id, s.line_location_id,
673        rl.requisition_header_id, rl.requisition_line_id
674      BULK COLLECT INTO l_po_header_id, l_po_release_id, l_po_line_id, l_line_location_id,
675        L_req_header_id, l_req_line_id
676      FROM    po_line_locations s, po_requisition_lines rl
677      WHERE   s.line_location_id = rl.line_location_id and nvl(rl.drop_ship_flag, 'N') = 'Y'
678        AND s.po_release_id = X_entity_id;
679      --<DropShip FPJ End>
680 
681      UPDATE po_requisition_lines_all   -- Bug 3592153
682      SET    line_location_id = NULL,
683             reqs_in_pool_flag = 'Y',    -- Bug 2781027
684             last_update_login = fnd_global.login_id,  -- Bug5623016 (updating who column)
685             last_updated_by = fnd_global.user_id,  -- Bug5623016 (updating who column)
686             last_update_date = sysdate  -- Bug5623016 (updating who column)
687      WHERE  line_location_id in (SELECT  line_location_id
688 				 FROM    po_line_locations
689 				 WHERE   po_release_id = X_entity_id);
690 
691    ELSIF (X_entity = 'LINE') THEN
692      x_progress := '030';
693     -- dbms_output.put_line('In update for Line related req lines');
694 
695      --<DropShip FPJ Start>
696      --SQL What: Finds Drop Ship Req Lines for this Line ID
697      SELECT  s.po_header_id, s.po_release_id, s.po_line_id, s.line_location_id,
698        rl.requisition_header_id, rl.requisition_line_id
699      BULK COLLECT INTO l_po_header_id, l_po_release_id, l_po_line_id, l_line_location_id,
700        L_req_header_id, l_req_line_id
701      FROM    po_line_locations s, po_requisition_lines rl
702      WHERE   s.line_location_id = rl.line_location_id and nvl(rl.drop_ship_flag, 'N') = 'Y'
703        AND s.po_line_id = X_entity_id;
704      --<DropShip FPJ End>
705 
706      UPDATE po_requisition_lines_all   -- Bug 3592153
707      SET    line_location_id = NULL,
708             reqs_in_pool_flag = 'Y',   -- Bug 2781027
709             last_update_login = fnd_global.login_id,  -- Bug5623016 (updating who column)
710             last_updated_by = fnd_global.user_id,  -- Bug5623016 (updating who column)
711             last_update_date = sysdate  -- Bug5623016 (updating who column)
712      WHERE  line_location_id in (SELECT  line_location_id
713                                  FROM    po_line_locations
714                                  WHERE   po_line_id = X_entity_id);
715 
716    ELSIF (X_entity = 'SHIPMENT') THEN
717      x_progress := '040';
718      -- dbms_output.put_line('In update for Shipment related req lines');
719 
720      --<DropShip FPJ Start>
721      --SQL What: Finds Drop Ship Req Lines for this Line Location ID
722      SELECT  s.po_header_id, s.po_release_id, s.po_line_id, s.line_location_id,
723        rl.requisition_header_id, rl.requisition_line_id
724      BULK COLLECT INTO l_po_header_id, l_po_release_id, l_po_line_id, l_line_location_id,
725        L_req_header_id, l_req_line_id
726      FROM    po_line_locations s, po_requisition_lines rl
727      WHERE   s.line_location_id = rl.line_location_id and nvl(rl.drop_ship_flag, 'N') = 'Y'
728        AND s.line_location_id = X_entity_id;
729      --<DropShip FPJ End>
730 
731      UPDATE po_requisition_lines_all  -- Bug 3592153
732      SET    line_location_id = NULL,
733             reqs_in_pool_flag = 'Y',    -- Bug 2781027
734             last_update_login = fnd_global.login_id,  -- Bug5623016 (updating who column)
735             last_updated_by = fnd_global.user_id,  -- Bug5623016 (updating who column)
736             last_update_date = sysdate  -- Bug5623016 (updating who column)
737      WHERE  line_location_id in (SELECT  line_location_id
738                                  FROM    po_line_locations
739                                  WHERE   line_location_id = X_entity_id);
740 
741    END IF;
742 
743    --<DropShip FPJ Start>
744    -- Remove deleted PO References from Drop Ship Sources Table for all deleted Shipments
745    FOR I IN 1..l_line_location_id.count LOOP
746 
747        OE_DROP_SHIP_GRP.Update_Drop_Ship_links(
748          p_api_version => 1.0,
749          p_po_header_id => l_po_header_id(i),
750          p_po_release_id => l_po_release_id(i),
751          p_po_line_id => l_po_line_id(i),
752          p_po_line_location_id => l_line_location_id(i),
753          p_new_req_hdr_id => l_req_header_id(i),
754          p_new_req_line_id => l_req_line_id(i),
755          x_return_status  => l_return_status,
756          x_msg_data  => l_msg_data,
757          x_msg_count  => l_msg_count);
758 
759     IF g_fnd_debug = 'Y' THEN
760         IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
761           FND_LOG.string(FND_LOG.LEVEL_STATEMENT, l_api_name|| '.' || x_progress,
762         'After Call to OE_DROP_SHIP_GRP.Update_Drop_Ship_links RetStatus: ' || l_return_status
763         || 'POHeader:' || l_po_header_id(i) || ' Release:' || l_po_release_id(i)
764         || ' Line:' || l_po_line_id(i) || ' LineLoc:' || l_line_location_id(i)
765         || ' ReqHdr:' || l_req_header_id(i) || ' ReqLine:' || l_req_line_id(i));
766         END IF;
767     END IF;
768 
769     IF (l_return_status IS NULL) THEN
770         l_return_status := FND_API.g_ret_sts_success;
771     END IF;
772 
773        IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
774            po_message_s.sql_error('remove_req_from_po', x_progress, l_msg_data);
775        END IF;
776 
777    END LOOP;
778      --<DropShip FPJ End>
779 
780    EXCEPTION
781    WHEN OTHERS THEN
782     --  dbms_output.put_line('In exception');
783       po_message_s.sql_error('remove_req_from_po', x_progress, sqlcode);
784 
785 END remove_req_from_po;
786 
787 
788 /*===========================================================================
789 
790   PROCEDURE NAME:	val_dest_details()
791 
792 ===========================================================================*/
793 PROCEDURE val_dest_details (x_dest_org_id	IN OUT NOCOPY NUMBER,
794 			    x_item_id		IN NUMBER,
795 			    x_item_rev		IN VARCHAR,
796 			    x_location_id	IN OUT NOCOPY NUMBER,
797 			    x_dest_sub		IN OUT NOCOPY VARCHAR2,
798 			    x_dest_type		IN VARCHAR2,
799 			    x_val_code		IN VARCHAR2,
800 			    x_sob_id		IN NUMBER) IS
801 
802 x_progress VARCHAR2(3) := NULL;
803 x_error_type	VARCHAR2(50);
804 
805 BEGIN
806 
807    x_progress := '010';
808 
809    /*
810    ** Stop processing if the destination type
811    ** is null.
812    */
813 
814    IF (x_dest_type is null) THEN
815     x_dest_org_id := null;
816     x_location_id := null;
817     x_dest_sub    := null;
818 
819     return;
820 
821    END IF;
822 
823 
824    /*
825    ** Determine which set of fields are to
826    ** be validated, call the corresponding
827    ** validation functions.
828    */
829 
830    IF (x_dest_org_id is null) THEN
831      x_location_id := null;
832      x_dest_sub    := null;
833 
834      return;
835 
836    END IF;
837 
838    IF (x_val_code = 'ORG') THEN
839 
840      x_progress := '020';
841 
842      IF (po_orgs_sv2.val_dest_org (x_dest_org_id,
843 				  x_item_id,
844 				  x_item_rev,
845 				  x_dest_type,
846 				  x_sob_id,
847 				  '') = FALSE) THEN
848 
849        x_dest_org_id := null;
850        x_location_id := null;
851        x_dest_sub    := null;
852 
853        return;
854 
855     END IF;
856   END IF;
857 
858    IF ((x_val_code = 'ORG') OR
859        (x_val_code = 'LOC')) THEN
860 
861      IF (x_location_id is not null) THEN
862 
863 	x_progress := '030';
864 
865        IF (po_locations_sv2.val_location (x_location_id,
866 				     	  x_dest_org_id,
867 				          'N',
868 					  'N',
869 					  'N') = FALSE) THEN
870 
871          x_location_id := null;
872 
873        END IF;
874     END IF;
875    END IF;
876 
877   /*
878   ** We would like to continue with the
879   ** validation even if the deliver-to location
880   ** is null since the subinventory is not
881   ** dependent on the deliver-to location.
882   */
883 
884   IF ((x_val_code = 'ORG') OR
885       (x_val_code = 'LOC') OR
886       (x_val_code = 'SUB')) THEN
887 
888     IF (x_dest_sub is not null) THEN
889 
890       x_progress := '040';
891 
892       IF (po_subinventories_s2.val_subinventory (x_dest_sub,
893 						x_dest_org_id,
894 						null,
895 						null,
896 						null,
897 						trunc(sysdate),
898 						x_item_id,
899 						x_dest_type,
900 						'DESTINATION',
901 						x_error_type) = FALSE) THEN
902         x_dest_sub := null;
903 
904       END IF;
905    END IF;
906   END IF;
907 
908 
909    EXCEPTION
910    WHEN OTHERS THEN
911       po_message_s.sql_error('val_dest_details', x_progress, sqlcode);
912    RAISE;
913 
914 END val_dest_details;
915 
916 /*===========================================================================
917 
918  PROCEDURE NAME :  val_src_type()
919 
920 ===========================================================================*/
921 
922 FUNCTION val_src_type(   x_src_type		IN VARCHAR2,
923 			 x_item_id		IN NUMBER,
924 			 x_internal_orderable	IN VARCHAR2,
925 			 x_stock_enabled_flag   IN VARCHAR2,
926 			 x_purchasable		IN VARCHAR2,
927 			 x_customer_id		IN NUMBER,
928 			 x_outside_op_line_type IN VARCHAR2)
929 RETURN BOOLEAN IS
930 
931 x_progress 	varchar2(3) := '';
932 
933 
934 BEGIN
935 
936 
937   IF (x_src_type is null) THEN
938     return (FALSE);
939 
940   END IF;
941 
942  /*
943  ** Debug: Have this code
944  ** reviewed by either Liza or
945  ** Kevin.
946  */
947 
948   IF (x_src_type = 'INVENTORY') THEN
949     IF ((x_customer_id is null) OR
950 	(x_item_id is null) OR
951 	(x_internal_orderable = 'N') OR
952 	(x_stock_enabled_flag  = 'N') OR
953 	(x_outside_op_line_type = 'Y')) THEN
954 
955       -- Bug 5028505 , Added the Error message when deliver_to_location
956       -- does not have customer location association setup in src org OU
957 
958        IF (x_customer_id is null) then
959          fnd_message.set_name ('PO','PO_REQ_SRC_REQUIRES_CUST');
960        END IF;
961 
962       return (FALSE);
963 
964     ELSE
965 
966       return (TRUE);
967 
968     END IF;
969 
970   ELSIF (x_src_type = 'VENDOR') THEN
971        IF (x_purchasable = 'N') THEN
972 
973 	return (FALSE);
974 
975        ELSE
976 
977         return (TRUE);
978 
979        END IF;
980   END IF;
981 
982 exception
983    when others then
984       po_message_s.sql_error('val_src_type',x_progress,sqlcode);
985       raise;
986 
987 end val_src_type;
988 
989 
990 
991 /*===========================================================================
992 
993   PROCEDURE NAME:	update_transferred_to_oe_flag
994 
995 ===========================================================================*/
996 
997 PROCEDURE update_transferred_to_oe_flag(X_req_hdr_id   		 IN  NUMBER,
998 		           	     X_transferred_to_oe_flag    OUT NOCOPY VARCHAR2)
999 IS
1000 
1001 x_progress  VARCHAR2(3) := NULL;
1002 x_inv_count NUMBER      := 0;
1003 x_flag	    VARCHAR2(1) := NULL;
1004 
1005 BEGIN
1006 
1007 
1008    /*
1009    ** Verify that there is at least one
1010    ** inventory sourced line.
1011    */
1012 
1013    x_progress := '010';
1014 
1015    SELECT count(*)
1016    INTO   x_inv_count
1017    FROM   po_requisition_lines  prl
1018    WHERE  prl.requisition_header_id = x_req_hdr_id
1019    AND    prl.source_type_code = 'INVENTORY';
1020 
1021    -- dbms_output.put_line ('x_inv_count: ' ||to_char(x_inv_count));
1022 
1023    x_progress := '020';
1024 
1025    /*
1026    ** Set the appropriate value for the
1027    ** transferred_to_oe_flag.
1028    */
1029 
1030    IF (x_inv_count = 0) THEN
1031      x_flag := NULL;
1032 
1033    ELSE
1034 
1035      /* Bug: 689677 - transferred_to_oe_flag need to be set to 'N',
1036      only if it is NULL. Need not update the flag, if it is already 'Y'or 'N' */
1037 
1038      SELECT transferred_to_oe_flag
1039      INTO   x_flag
1040      FROM   po_requisition_headers
1041      WHERE  requisition_header_id = x_req_hdr_id;
1042 
1043      IF (x_flag = 'Y' or x_flag = 'N') then
1044         x_transferred_to_oe_flag := x_flag;
1045         return;
1046      END IF;
1047 
1048       IF x_flag is NULL then
1049         x_flag := 'N';
1050      END IF;
1051 
1052    END IF;
1053 
1054    x_transferred_to_oe_flag := x_flag;
1055 
1056    /*
1057    ** Update the flag on requisition headers.
1058    */
1059 
1060    x_progress := '030';
1061   --  dbms_output.put_line ('Before updating requisition headers');
1062 
1063    po_reqs_sv.update_oe_flag (X_req_hdr_id, X_flag);
1064 
1065   --  dbms_output.put_line ('After updating requisition headers');
1066 
1067 
1068 
1069    EXCEPTION
1070    WHEN OTHERS THEN
1071      --  dbms_output.put_line('In exception');
1072       po_message_s.sql_error('update_transferred_to_oe_flag',
1073 			      x_progress, sqlcode);
1074       raise;
1075 END update_transferred_to_oe_flag;
1076 
1077 -- <REQINPOOL BEGIN>
1078 
1079 
1080 /*===========================================================================
1081 
1082   PROCEDURE NAME:       update_reqs_in_pool_flag
1083 
1084 ===========================================================================*/
1085 
1086 PROCEDURE update_reqs_in_pool_flag
1087 (   x_req_line_id                 IN          NUMBER            ,
1088     x_req_header_id               IN          NUMBER            ,
1089     x_return_status               OUT NOCOPY  VARCHAR2
1090 )
1091 
1092 IS
1093     x_progress                  VARCHAR2(3)     := NULL;
1094 
1095 BEGIN
1096 
1097   x_progress := '010';
1098 
1099   IF ( x_req_line_id IS NOT NULL OR x_req_header_id IS NOT NULL ) THEN
1100 
1101     x_progress := '020';
1102 
1103     --SQL What: Update reqs_in_pool_flag for all lines on the passed-in
1104     --          requisition to be NULL where the line has been cancelled,
1105     --          finally closed, attached to a PO, modified since approval,
1106     --          sent to sourcing, or when the requisition is either
1107     --          internal or not approved.  If none of these conditions
1108     --          are met, set the flag to 'Y'.
1109     --
1110     --SQL Why:  Requisition lines where any of the above applies cannot
1111     --          be placed on a purchasing document; those that fail all
1112     --          the above criteria can.
1113     --
1114     --SQL Join: requisition_header_id from PO_REQUISITION_HEADERS_ALL
1115     UPDATE po_requisition_lines_all prl
1116     SET prl.reqs_in_pool_flag =
1117         CASE
1118           WHEN NVL(prl.cancel_flag,'N')             = 'Y'
1119             OR NVL(prl.closed_code,'OPEN')          = 'FINALLY CLOSED'
1120             OR NVL(prl.line_location_id,-999)       <> -999
1121             OR NVL(prl.modified_by_agent_flag,'N')  = 'Y'
1122             OR prl.at_sourcing_flag                 = 'Y'
1123             OR prl.source_type_code                 <> 'VENDOR'
1124             OR NVL((SELECT prh.authorization_status
1125                       FROM PO_REQUISITION_HEADERS_ALL prh
1126                      WHERE prh.requisition_header_id = prl.requisition_header_id)
1127                    , 'INCOMPLETE')                  <> 'APPROVED'
1128             OR NVL((SELECT prh.contractor_status
1129                       FROM PO_REQUISITION_HEADERS_ALL prh
1130                      WHERE prh.requisition_header_id = prl.requisition_header_id)
1131                    , 'NOT APPLICABLE')              = 'PENDING'
1132         THEN
1133           NULL
1134         ELSE
1135           'Y'
1136         END
1137       , prl.last_update_date   = SYSDATE
1138       , prl.last_updated_by    = FND_GLOBAL.USER_ID
1139       , prl.last_update_login  = FND_GLOBAL.LOGIN_ID
1140     WHERE
1141       PRL.Requisition_Line_ID in (
1142         SELECT  SUB.Requisition_Line_ID
1143         FROM    PO_REQUISITION_LINES_ALL SUB
1144         WHERE   SUB.Requisition_Header_Id = x_req_header_id
1145         AND     x_req_line_id IS NULL
1146        UNION ALL
1147         SELECT  SUB2.Requisition_Line_ID
1148         FROM    PO_REQUISITION_LINES_ALL SUB2
1149         WHERE   SUB2.Requisition_Line_Id = x_req_line_id
1150       );
1151 
1152   ELSE
1153     x_progress := '030';
1154 
1155   END IF; -- IF ( x_req_line_id IS NOT NULL OR x_req_header_id IS NOT NULL )
1156 
1157   x_progress := '040';
1158   x_return_status := FND_API.G_RET_STS_SUCCESS;
1159 
1160 EXCEPTION
1161 
1162   WHEN OTHERS THEN
1163     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1164     PO_MESSAGE_S.sql_error('UPDATE_REQS_IN_POOL_FLAG',x_progress,sqlcode);
1165 
1166 END update_reqs_in_pool_flag;
1167 
1168 -- <REQINPOOL END>
1169 
1170 /*===========================================================================
1171 
1172   FUNCTION NAME:        val_oe_shipment_in_proc
1173 
1174 ===========================================================================*/
1175 
1176 /* Bug# 2492314: kagarwal */
1177 
1178  FUNCTION val_oe_shipment_in_proc
1179                   (X_req_header_id           IN     NUMBER,
1180                    X_req_line_id             IN     NUMBER) RETURN BOOLEAN IS
1181 
1182    X_progress                 VARCHAR2(3) := NULL;
1183    X_order_source_id          po_system_parameters.order_source_id%TYPE;
1184    X_req_num                  po_requisition_headers_all.segment1%TYPE;
1185    X_oe_line_tbl              OE_ORDER_IMPORT_INTEROP_PUB.LineId_Tbl_Type;
1186    X_oe_return   	      VARCHAR2(30);
1187    X_oe_line_ctr              NUMBER := 0;
1188 
1189    X_in_rec_type    	      WSH_INTEGRATION.LineIntfInRecType;
1190    X_out_rec_type   	      WSH_INTEGRATION.LineIntfOutRecType;
1191    X_io_rec_type    	      WSH_INTEGRATION.LineIntfInOutRecType;
1192    X_wsh_return               VARCHAR2(200);
1193    X_msg_count                NUMBER;
1194    X_msg_data                 VARCHAR2(200);
1195 
1196  BEGIN
1197 
1198    IF X_req_header_id is NOT NULL AND
1199       X_req_line_id is NOT NULL THEN
1200 
1201       X_progress := '010';
1202 
1203       select order_source_id
1204       into   X_order_source_id
1205       from po_system_parameters;
1206 
1207       X_progress := '020';
1208 
1209       SELECT segment1
1210       INTO X_req_num
1211       FROM po_requisition_headers_all
1212       WHERE requisition_header_id = X_req_header_id;
1213 
1214       X_progress := '030';
1215 
1216       OE_ORDER_IMPORT_INTEROP_PUB.Get_Line_Id (
1217    		p_order_source_id        =>  X_order_source_id,
1218 		p_orig_sys_document_ref  =>  X_req_num,
1219   		p_requisition_header_id  =>  X_req_header_id,
1220   		p_line_num               =>  NULL,
1221   		p_requisition_line_id    =>  X_req_line_id,
1222   		x_line_id_tbl            =>  X_oe_line_tbl,
1223   		x_return_status          =>  X_oe_return);
1224 
1225       X_progress := '040';
1226 
1227       If X_oe_return = fnd_api.g_ret_sts_success then
1228 
1229         /* If the table X_oe_line_tbl is empty, return TRUE */
1230         If (X_oe_line_tbl.FIRST is NULL) Then
1231            return(TRUE);
1232         End If;
1233 
1234         FOR X_oe_line_ctr IN 1..X_oe_line_tbl.COUNT
1235         LOOP
1236            X_in_rec_type.api_version_number := 1.0;
1237            X_in_rec_type.source_code := 'PO';
1238            X_in_rec_type.line_id := X_oe_line_tbl(X_oe_line_ctr).line_id;
1239 
1240            WSH_INTEGRATION.Get_Nonintf_Shpg_line_qty
1241       		( p_in_attributes   => X_in_rec_type,
1242             	p_out_attributes    => X_out_rec_type,
1243             	p_inout_attributes  => X_io_rec_type,
1244             	x_return_status     => X_wsh_return,
1245             	x_msg_count         => X_msg_count,
1246             	x_msg_data          => X_msg_data);
1247 
1248            If X_wsh_return = fnd_api.g_ret_sts_success then
1249              If X_out_rec_type.nonintf_line_qty > 0 then
1250                return FALSE;
1251 
1252              End If; /* If X_out_rec_type.nonintf_line_qty */
1253 
1254            Else
1255              /* DEBUG - show error message */
1256              X_progress := '080';
1257              po_message_s.sql_error('val_oe_shipment_in_proc', X_progress, sqlcode);
1258            End If; /* If X_wsh_return */
1259 
1260         END LOOP;
1261 
1262      Else
1263         /* DEBUG - show error message */
1264         X_progress := '090';
1265         po_message_s.sql_error('val_oe_shipment_in_proc', X_progress, sqlcode);
1266 
1267      End If; /* If X_oe_return */
1268 
1269      /* Nothing stuck in mti */
1270      X_progress := '100';
1271      return TRUE;
1272 
1273    ELSE
1274       /* DEBUG - show error message */
1275       X_progress := '999';
1276       po_message_s.sql_error('val_oe_shipment_in_proc', X_progress, sqlcode);
1277    End IF; /* IF X_req_header_id */
1278 
1279    EXCEPTION
1280    WHEN OTHERS THEN
1281       po_message_s.sql_error('val_oe_shipment_in_proc', X_progress, sqlcode);
1282    RAISE;
1283 
1284  END val_oe_shipment_in_proc;
1285 
1286 /* Bug# 2607180: kagarwal
1287 ** Desc: Verify if internal requisition lines which are sourced from inventory,
1288 ** have been received or not. For this we will check if the 'SHIPMENT' supply
1289 ** exists for the requisition lines.
1290 **
1291 ** If 'SHIPMENT' supply exists return FALSE else TRUE
1292 */
1293 
1294 /*===========================================================================
1295 
1296   FUNCTION NAME:        val_reqs_qty_received
1297 
1298 ===========================================================================*/
1299 
1300  FUNCTION val_reqs_qty_received
1301                        (X_req_header_id       IN     NUMBER,
1302                         X_req_line_id         IN     NUMBER) RETURN BOOLEAN IS
1303 
1304    X_progress                 VARCHAR2(3) := NULL;
1305    X_row_exists               NUMBER := 0;
1306 
1307  BEGIN
1308    IF X_req_header_id is NOT NULL OR
1309       X_req_line_id is NOT NULL THEN
1310 
1311       X_progress := '010';
1312 
1313       SELECT COUNT(1)
1314       INTO   X_row_exists
1315       FROM   MTL_SUPPLY
1316       WHERE  req_header_id = X_req_header_id
1317       AND    req_line_id   = NVL(X_req_line_id, req_line_id)
1318       AND    supply_type_code = 'SHIPMENT'
1319       AND    quantity > 0;
1320 
1321    ELSE
1322       /* DEBUG - show error message */
1323       X_progress := '015';
1324       po_message_s.sql_error('val_reqs_qty_received', X_progress, sqlcode);
1325    END IF;
1326 
1327    IF X_row_exists > 0 THEN
1328       RETURN (FALSE);
1329    ELSE
1330       RETURN (TRUE);
1331    END IF;
1332 
1333    EXCEPTION
1334    WHEN OTHERS THEN
1335       po_message_s.sql_error('val_reqs_qty_received', X_progress, sqlcode);
1336    RAISE;
1337 
1338  END val_reqs_qty_received;
1339 
1340 END po_req_lines_sv;