DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_SHIPMENTS_SV8

Source


1 PACKAGE BODY PO_SHIPMENTS_SV8 as
2 /* $Header: POXPOS8B.pls 120.1 2005/07/03 02:21:50 manram noship $*/
3 
4 /*===========================================================================
5 
6   FUNCTION NAME:	val_start_dates()
7 
8 ===========================================================================*/
9 
10 FUNCTION val_start_dates(X_start_date	  IN	DATE,
11 			 X_po_header_id   IN	NUMBER) RETURN BOOLEAN IS
12 
13 /*  This procedure is used by RFQs and Quotations to verify the
14 **  START_DATE which has been entered on the header level is not
15 **  later than the earliest START_DATE of it's shipments.
16 */
17 
18 x_progress		VARCHAR2(3) := '';
19 x_start_date_count	NUMBER;
20 
21 BEGIN
22   x_progress := '010';
23   /*
24   ** Verify that the start date entered on the header is earlier than
25   ** the start dates of it's shipments.
26   */
27 
28   SELECT count(*)
29   INTO   x_start_date_count
30   FROM   po_line_locations
31   WHERE  start_date < X_start_date
32   AND    po_header_id = X_po_header_id;
33 
34   x_progress := '020';
35 
36   if x_start_date_count > 0 then
37     RETURN(FALSE);
38     -- dbms_output.put_line('FALSE: start date invalid');
39   else
40     RETURN(TRUE);
41     -- dbms_output.put_line('TRUE: start date valid');
42   end if;
43 
44 EXCEPTION
45     when no_data_found then
46          return(TRUE);
47     WHEN OTHERS THEN
48          po_message_s.sql_error('val_start_dates', x_progress, sqlcode);
49          raise;
50 END val_start_dates;
51 /*===========================================================================
52 
53   FUNCTION NAME:	val_end_dates()
54 
55 ===========================================================================*/
56 
57 FUNCTION val_end_dates(X_end_date	IN	DATE,
58 		       X_po_header_id	IN	NUMBER) RETURN BOOLEAN IS
59 
60 --  This procedure is used by RFQs and Quotations to verify the
61 --  END_DATE which has been entered on the header level is not
62 --  earlier than than the latest END_DATE of it's shipments.
63 
64 
65 x_progress 		VARCHAR2(3) 	:= '';
66 x_end_date_count	NUMBER;
67 
68 BEGIN
69   x_progress := '010';
70 
71   --
72   -- Verify that the end date entered on the header is later than
73   -- the end dates of it's shipments.
74 
75 
76   SELECT count(*)
77   INTO   x_end_date_count
78   FROM   po_line_locations
79   WHERE  end_date > X_end_date
80   AND    po_header_id = X_po_header_id;
81 
82   x_progress := '020';
83 
84   if x_end_date_count > 0 then
85     RETURN(FALSE);
86     -- dbms_output.put_line('FALSE: start date invalid');
87   else
88     RETURN(TRUE);
89     -- dbms_output.put_line('TRUE: start date valid');
90   end if;
91 
92 EXCEPTION
93     when no_data_found then
94          return(TRUE);
95   WHEN OTHERS THEN
96     po_message_s.sql_error('val_end_dates', x_progress, sqlcode);
97     raise;
98 
99 END val_end_dates;
100 
101  /*==============================================================================
102  ** PROCEDURE : autocreate_ship()
103  Modified        26-FEB-01       MCHANDAK(OPM-GML)
104                  Bug# 1548597.. Added 3 process related fields.
105                  X_secondary_unit_of_measure,X_secondary_quantity and
106                  X_preferred_grade.
107 
108  **=============================================================================*/
109 
110  procedure autocreate_ship ( X_line_location_id        IN OUT NOCOPY NUMBER,
111                              X_last_update_date               DATE,
112                              X_last_updated_by                NUMBER,
113                              X_creation_date                  DATE,
114                              X_created_by                     NUMBER,
115                              X_last_update_login              NUMBER,
116                              X_po_header_id                   NUMBER,
117                              X_po_line_id                     NUMBER,
118                              X_type_lookup_code               VARCHAR2,
119                              X_quantity                       NUMBER,
120                              X_ship_to_location_id            NUMBER,
121                              X_ship_org_id                    NUMBER,
122                              X_need_by_date                   DATE,
123                              X_promised_date                  DATE,
124                              X_unit_price                     NUMBER,
125                              X_tax_code_id		      NUMBER,
126                              X_taxable_flag                   VARCHAR2,
127                              X_enforce_ship_to_location       VARCHAR2,
128                              X_receiving_routing_id           NUMBER,
129                              X_inspection_required_flag       VARCHAR2,
130                              X_receipt_required_flag          VARCHAR2,
131                              X_qty_rcv_tolerance              NUMBER,
132                              X_qty_rcv_exception_code         VARCHAR2,
133                              X_days_early_receipt_allowed     NUMBER,
134                              X_days_late_receipt_allowed      NUMBER,
135                              X_allow_substitute_receipts      VARCHAR2,
136                              X_receipt_days_exception_code    VARCHAR2,
137                              X_invoice_close_tolerance        NUMBER,
138                              X_receive_close_tolerance        NUMBER,
139                              X_item_status                    VARCHAR2,
140                              X_outside_operation_flag         VARCHAR2,
141                              X_destination_type_code          VARCHAR2,
142                              X_expense_accrual_code           VARCHAR2,
143                              X_item_id                        NUMBER,
144 					     X_ussgl_transaction_code		  VARCHAR2,
145                              X_accrue_on_receipt_flag  IN OUT NOCOPY VARCHAR2,
146                              X_autocreated_ship        IN OUT NOCOPY BOOLEAN,
147                              X_unit_meas_lookup_code   IN     VARCHAR2, -- Added Bug 731564
148                              p_value_basis             IN     VARCHAR2, -- <Complex Work R12>
149                              p_matching_basis          IN     VARCHAR2, -- <Complex Work R12>
150 -- start of bug# 1548597
151                              X_secondary_unit_of_measure IN   VARCHAR2,
152                              X_secondary_quantity    IN   NUMBER,
153                              X_preferred_grade       IN   VARCHAR2,
154                              p_consigned_from_supplier_flag IN VARCHAR2 --bug 3523348
155 -- end of bug# 1548597
156                            ,p_org_id                     IN     NUMBER                  -- <R12.MOAC>
157 			   ,p_outsourced_assembly	IN NUMBER -- <R12 SHIKYU>
158 )
159   is
160 
161   X_Progress                 varchar2(3)  :=  '';
162   x_vendor_site_id           number;      -- Bug 880864
163   x_vendor_id                number;
164   X_invoice_match_option     VARCHAR2(25);
165   x_country_of_origin_code   VARCHAR2(2); -- bug 2350043 by jbalakri
166 
167   /* CONSIGNED FPI START */
168 
169   x_consigned_flag
170     po_line_locations.consigned_flag%TYPE               := NULL;
171 
172   -- OPEN is the default if the shipment line is not consigned
173   x_closed_code
174     po_line_locations.closed_code%TYPE                  := 'OPEN';
175 
176   x_closed_reason
177     po_line_locations.closed_reason%TYPE                := NULL;
178 
179   l_invoice_close_tolerance      number                 := X_invoice_close_tolerance;
180 
181   l_inspection_required_flag
182     po_line_locations.inspection_required_flag%TYPE     := X_inspection_required_flag;
183 
184   l_receipt_required_flag
185     po_line_locations.receipt_required_flag%TYPE        := X_receipt_required_flag;
186 
187   /* CONSIGNED FPI END */
188 
189   l_from_line_id number;   -- GA FPI
190   l_from_header_id number;  -- GA FPI
191   l_amount  number;
192   begin
193 
194               X_Progress := '010';
195 
196               if X_item_id is NULL then
197                  if X_destination_type_code = 'INVENTORY' then
198                     /* invalid Defaults */
199                     null;
200                  else
201                     /*copy expense to world and more */
202                     null;
203                  end if;
204               end if;
205 
206 
207               /* Algorithm for figuring out the value of accrue_on_receipt */
208 
209               if X_outside_operation_flag = 'Y' then
210 
211                  X_accrue_on_receipt_flag := 'Y';
212 
213               elsif X_item_status = 'E' then
214 
215                     if ( X_destination_type_code = '' OR
216                          X_destination_type_code = 'INVENTORY') then
217 
218                           X_accrue_on_receipt_flag := 'Y';
219 
220                     elsif (X_destination_type_code = 'EXPENSE') then
221 
222                           if  X_expense_accrual_code = 'RECEIPT' then
223 
224                               X_accrue_on_receipt_flag := X_receipt_required_flag;
225 
226                           elsif X_expense_accrual_code = 'PERIOD END' then
227 
228                                 X_accrue_on_receipt_flag := 'N';
229 
230                           end if;
231 
232                    end if;
233             end if;
234 
235 	    /** Bug 880864 , bgu, Apr. 28, 1999
236              *  Need to autocreate match_option into the shipment
237              */
238 	    X_Progress := '015';
239 
240             -- Get vendor site id from po header
241             select vendor_site_id, vendor_id
242             into   x_vendor_site_id, x_vendor_id
243             from   po_headers
244             where  po_header_id  =  x_po_header_id;
245 
246             -- The following code is copied from
247             -- PO_SHIPMENTS_C22.invoice_match_option, POXPOPOS.pld
248             if (X_vendor_site_id is not null) then
249               /* Retrieve Invoice Match Option from Vendor site*/
250               SELECT match_option
251               INTO   x_invoice_match_option
252               FROM   po_vendor_sites
253               WHERE  vendor_site_id = X_vendor_site_id;
254             end if;
255 
256             if(x_invoice_match_option is NULL) then
257               /* Retrieve Invoice Match option from Vendor */
258               if (X_vendor_id is not null) then
259                 SELECT match_option
260                 INTO   x_invoice_match_option
261                 FROM   po_vendors
262                 WHERE  vendor_id = X_vendor_id;
263               end if;
264             end if;
265 
266             if(x_invoice_match_option is NULL) then
267               /* Retrieve Invoice Match Option from Financial System
268                * Parameters */
269      	      SELECT fsp.match_option
270      	      INTO   x_invoice_match_option
271      	      FROM   financials_system_parameters fsp;
272    	    end if;
273 
274             X_Progress := '020';
275 
276             SELECT po_line_locations_s.nextval
277             INTO   X_line_location_id
278             FROM   sys.dual;
279 --   Added for bug 2350043 by jbalakri
280             X_Progress:= '025';
281 
282        po_coo_s.get_default_country_of_origin(x_item_id,
283                 x_ship_org_id,
284                 x_vendor_id,
285                 x_vendor_site_id,
286                 x_country_of_origin_code);
287 -- end of 2350043
288 
289             X_Progress := '030';
290 
291         --bug 3523348: move logic to POXPIPOL.pld so we can remove source doc
292         --             Now we pass p_consigned_from_supplier_flag parameter
293         /* CONSIGNED FPI START */
294              -- Set the new shipment as consigned if the corresponding
295 	         -- ASL entry is consigned and item is not expense
296        IF(p_consigned_from_supplier_flag = 'Y')
297              THEN
298                -- set shipment line as consigned
299                x_consigned_flag := 'Y';
300                X_accrue_on_receipt_flag := 'N';
301                l_invoice_close_tolerance := 100;
302 	           x_closed_code := 'CLOSED FOR INVOICE';
303 	           FND_MESSAGE.SET_NAME('PO', 'PO_SUP_CONS_CLOSED_REASON');
304                x_closed_reason := FND_MESSAGE.GET;
305                l_inspection_required_flag := 'N';
306                l_receipt_required_flag := 'N';
307                X_invoice_match_option := 'P';
308 	    END IF;
309 	     /* CONSIGNED FPI END */
310 
311          /* GA FPI start : we need to insert the source doc info from the lines to shipments */
312          /* SERVICES FPJ : We also need to insert the line amount to the shipments */
313          begin
314             select from_line_id,from_header_id,amount
315             into l_from_line_id, l_from_header_id,l_amount
316             from po_lines
317             where po_line_id = X_po_line_id ;
318          exception
319            when others then
320             l_from_line_id := null;
321             l_from_header_id := null;
322          end;
323 	 /* GA FPI end */
324 
325             INSERT into po_line_locations
326                        (line_location_id        ,
327                         last_update_date        ,
328                         last_updated_by         ,
329                         creation_date           ,
330                         created_by              ,
331                         last_update_login       ,
332                         po_header_id            ,
333                         po_line_id              ,
334                         shipment_num            ,
335                         shipment_type           ,
336                         quantity                ,
337                         quantity_received       ,
338                         quantity_accepted       ,
339                         quantity_rejected       ,
340                         quantity_billed         ,
341                         quantity_cancelled      ,
342                         ship_to_location_id     ,
343                         ship_to_organization_id ,
344                         need_by_date            ,
345                         promised_date           ,
346                         last_accept_date        ,
347                         cancel_flag             ,
348                         closed_code             ,
349                         approved_flag           ,
350                         price_override          ,
351                         encumbered_flag         ,
352                         tax_code_id             ,
353                         taxable_flag            ,
354                         enforce_ship_to_location_code,
355                         receiving_routing_id    ,
356                         inspection_required_flag,
357                         receipt_required_flag   ,
358                         qty_rcv_tolerance       ,
359                         qty_rcv_exception_code  ,
360                         days_early_receipt_allowed,
361                         days_late_receipt_allowed,
362                         allow_substitute_receipts_flag,
363                         receipt_days_exception_code,
364                         invoice_close_tolerance ,
365                         receive_close_tolerance,
366                         accrue_on_receipt_flag,
367 			tax_user_override_flag,
368 			calculate_tax_flag,
369                         unit_meas_lookup_code,    -- Added Bug 731564
370                         match_option,             -- Bug 880864
371 -- start of bug# 1548597
372                         secondary_unit_of_measure,
373                         secondary_quantity,
374                         preferred_grade,
375                         secondary_quantity_received,
376                         secondary_quantity_accepted,
377                         secondary_quantity_rejected,
378                         secondary_quantity_cancelled,
379                         country_of_origin_code, -- bug 2350043
380 -- end  of bug# 1548597
381 			consigned_flag,         /* CONSIGNED FPI */
382 			closed_reason  ,        /* CONSIGNED FPI */
383                         from_header_id,         -- GA FPI
384                         from_line_id ,           -- GA FPI
385                         amount
386                          --<DBI Req Fulfillment 11.5.11 Start >
387                          ,shipment_closed_date
388                          ,closed_for_receiving_date
389                          ,closed_for_invoice_date
390                          --<DBI Req Fulfillment 11.5.11 End >
391                         ,Org_Id                     -- <R12.MOAC>
392                         , value_basis               -- <Complex Work R12>
393                         , matching_basis            -- <Complex Work R12>
394 			,outsourced_assembly --<R12 SHIKYU>
395                         )
396            VALUES
397                       (X_line_location_id      ,
398                        X_last_update_date      ,
399                        X_last_updated_by       ,
400                        X_creation_date         ,
401                        X_created_by            ,
402                        X_last_update_login     ,
403                        X_po_header_id          ,
404                        X_po_line_id            ,
405                        '1'                     ,
406                        X_type_lookup_code      ,
407                        X_quantity              ,
408                        '0'     ,
409                        '0'     ,
410                        '0'     ,
411                        '0'     ,
412                        '0'     ,
413                        X_ship_to_location_id   ,
414                        X_ship_org_id           ,
415                        X_need_by_date          ,
416                        X_promised_date         ,
417                        ''      ,
418                        'N'     ,
419                        x_closed_code,   /* CONSIGNED FPI */ --'OPEN'  ,
420                        'N'     ,
421                        X_unit_price,
422                        'N'     ,
423                        X_tax_code_id                      ,
424                        X_taxable_flag                  ,
425                        X_enforce_ship_to_location         ,
426                        X_receiving_routing_id             ,
427                        l_inspection_required_flag         , /* CONSIGNED FPI */
428                        l_receipt_required_flag         ,    /* CONSIGNED FPI */
429                        X_qty_rcv_tolerance                ,
430                        X_qty_rcv_exception_code           ,
431                        X_days_early_receipt_allowed       ,
432                        X_days_late_receipt_allowed        ,
433                        X_allow_substitute_receipts        ,
434                        X_receipt_days_exception_code      ,
435                        l_invoice_close_tolerance       ,  /* CONSIGNED FPI */
436                        X_receive_close_tolerance       ,
437                        nvl(X_accrue_on_receipt_flag,'N'),
438 		       'N',
439 		       'Y',
440                        X_unit_meas_lookup_code,   -- Added Bug 731564
441 		       X_invoice_match_option,   -- Bug 880864
442 -- start of bug# 1548597
443                        X_secondary_unit_of_measure,
444                        X_secondary_quantity,
445                        X_preferred_grade,
446                        decode(X_secondary_unit_of_measure,NULL,NULL,0),
447                        decode(X_secondary_unit_of_measure,NULL,NULL,0),
448                        decode(X_secondary_unit_of_measure,NULL,NULL,0),
449                        decode(X_secondary_unit_of_measure,NULL,NULL,0),
450                        x_country_of_origin_code, -- bug 2350043
451 -- end  of bug# 1548597
452 		       x_consigned_flag,           /* CONSIGNED FPI */
453 		       x_closed_reason,            /* CONSIGNED FPI */
454                        l_from_header_id,           -- GA FPI
455                        l_from_line_id,             -- GA FPI
456                        l_amount                    -- SERVICES FPJ
457                        --<DBI Req Fulfillment 11.5.11 Start >
458                        ,decode(x_closed_code,'CLOSED',
459                                    sysdate, null)            -- Shipment_closed_date
460                        ,decode(x_closed_code,'CLOSED',sysdate,
461                                 'CLOSED FOR RECEIVING',sysdate,null)        -- Closed_for_receiving_date
462                         ,decode(x_closed_code,'CLOSED',sysdate,
463                                 'CLOSED FOR INVOICE',sysdate,null)          -- closed_for_invoice_date
464                         --<DBI Req Fulfillment 11.5.11 End >
465                        ,p_org_id                                 -- <R12.MOAC>
466                        , p_value_basis      -- <Complex Work R12>
467                        , p_matching_basis   -- <Complex Work R12>
468 		       , p_outsourced_assembly -- <R12 SHIKYU>
469                        );
470 
471            X_autocreated_ship := TRUE;
472 
473 
474   exception
475 
476            when others then
477                 po_message_s.sql_error('autocreate_ship', X_progress, sqlcode);
478                 raise;
479 
480   end autocreate_ship;
481 
482 PROCEDURE get_matching_controls(X_vendor_id    IN number,
483 			       X_line_type_id IN number,
484 			       X_item_id    IN number,
485 			       X_receipt_required_flag IN OUT NOCOPY VARCHAR2,
486 			       X_inspection_required_flag IN OUT NOCOPY VARCHAR2) IS
487 
488    x_progress 				VARCHAR2(3) := '';
489    X_receipt_required_flag_tmp 		VARCHAR2(1) := '';
490    X_inspection_required_flag_tmp 	VARCHAR2(1) := '';
491 
492 
493    BEGIN
494 
495       -- Get receipt required flag and inspection required flags
496       -- in the following order:
497       --	item
498       --	line type (only for receipt required)
499       --	vendor
500       --	system options
501 
502       x_progress := '010';
503 
504       -- bug 413511
505       -- Set default values from PO system options
506 
507       SELECT receiving_flag,
508 	     inspection_required_flag
509       INTO   X_receipt_required_flag,
510 	     X_inspection_required_flag
511       FROM   po_system_parameters;
512 
513       x_progress := '020';
514 
515       IF (X_vendor_id is NOT null) THEN
516 
517 	SELECT receipt_required_flag,
518 	       inspection_required_flag
519 	INTO   X_receipt_required_flag_tmp,
520 	       X_inspection_required_flag_tmp
521         FROM   po_vendors
522 	WHERE  vendor_id = X_vendor_id;
523 
524         -- bug 413511
525         -- If the flags are not null,take them; Otherwise, bypass them
526 
527         IF X_receipt_required_flag_tmp is not NULL AND
528            X_inspection_required_flag_tmp is not NULL THEN
529            X_receipt_required_flag := X_receipt_required_flag_tmp;
530 	   X_inspection_required_flag := X_inspection_required_flag_tmp;
531         END IF;
532 
533       END IF;
534 
535       x_progress := '030';
536 
537       IF (X_line_type_id is NOT null) THEN
538 
539          SELECT receiving_flag
540 	 INTO   X_receipt_required_flag_tmp
541 	 FROM   po_line_types
542 	 WHERE  line_type_id = X_line_type_id;
543 
544         -- bug 413511
545         -- If the flag is not null, take it; Otherwise bypass it
546 
547         IF X_receipt_required_flag_tmp is not NULL THEN
548            X_receipt_required_flag := X_receipt_required_flag_tmp;
549 
550      /* Bug 2174318 If the RR_flag is N then the IR_flag should
551      ** be made null to override the default from vendors
552      */
553             IF  X_receipt_required_flag_tmp = 'N' THEN
554              X_inspection_required_flag := null;
555             END IF;
556 
557         END IF;
558 
559       END IF;
560 
561       x_progress := '040';
562 
563       IF (X_item_id is NOT null) THEN
564 
565          SELECT receipt_required_flag,
566 	        inspection_required_flag
567          INTO   X_receipt_required_flag_tmp,
568 	        X_inspection_required_flag_tmp
569 	 FROM   mtl_system_items,
570 	        financials_system_parameters
571          WHERE  inventory_item_id = X_item_id
572          AND    organization_id = inventory_organization_id;
573 
574         -- bug 413511
575         -- If the flags are not null,take them; Otherwise, bypass them
576 
577  	-- Bug 475621
578  	-- INV Item forms allow user to set the RR_flag and IR_flag separately
579  	-- need to handle one null value, change AND to OR
580 
581         IF X_receipt_required_flag_tmp is not NULL OR
582            X_inspection_required_flag_tmp is not NULL THEN
583            X_receipt_required_flag := X_receipt_required_flag_tmp;
584 	   X_inspection_required_flag := X_inspection_required_flag_tmp;
585         END IF;
586 
587       END IF;
588 
589    EXCEPTION
590      when others then
591         po_message_s.sql_error('get_matching_controls', x_progress, sqlcode);
592         raise;
593 
594 END get_matching_controls;
595 
596 
597 
598 /* <TIMEPHASED FPI START> */
599 
600 /*
601    This procedure is used to perform the various validations on the price break
602    effective Start Date, End Date and the line level Expiration Date
603 */
604 PROCEDURE validate_effective_dates(p_start_date      IN         date,
605                                    p_end_date        IN         date,
606                                    p_from_date       IN         date,
607                                    p_to_date         IN         date,
608                                    p_expiration_date IN         date,
609                                    x_errormsg        OUT NOCOPY varchar2)
610 IS
611 l_progress VARCHAR2(3) := '';
612 
613    BEGIN
614       l_progress := '000';
615       /* Validation for expiration date */
616       if (p_expiration_date is not null) then
617          if (p_start_date > p_expiration_date OR p_end_date < p_expiration_date) then
618 
619 -- bug2735633
620 -- Error message to be returned here should be POX_EXPIRATION_DATES
621 -- instead of POX_EXPIRATION_DATES1
622 
623               --  x_errormsg := 'POX_EXPIRATION_DATES1';
624               x_errormsg := 'POX_EXPIRATION_DATES';
625             return;
626          end if;
627       end if;
628 
629       l_progress := '001';
630       /*
631          Pricebreak effective From Date cannot be earlier than Blanket Agreement header
632          start date
633       */
634       if (p_from_date is not null AND p_from_date < p_start_date) then
635          x_errormsg := 'POX_EFFECTIVE_DATES1';
636          return;
637       end if;
638 
639 
640       l_progress := '002';
641       /*
642          Pricebreak effective From Date cannot be later than Blanket Agreement header
643          end date
644       */
645       if (p_from_date is not null AND p_from_date > p_end_date) then
646          x_errormsg := 'POX_EFFECTIVE_DATES4';
647          return;
648       end if;
649 
650       l_progress := '003';
651       /* Pricebreak effective From Date cannot be later than Pricebreak effective To Date */
652       /* Bug 2691705
653        * Changed the message name to POX_EFFECTIVE_DATES3.
654       */
655       if (p_to_date is not null AND p_from_date is not null AND p_from_date > p_to_date ) then
656          x_errormsg := 'POX_EFFECTIVE_DATES3';
657          return;
658       end if;
659 
660       /* Bug 2691705.
661        * Price break from date cannot be greater than the blanket line
662        * expiration date.
663       */
664       l_progress := '035';
665 
666       if (p_from_date is not null and p_from_date > p_expiration_date ) then
667          x_errormsg := 'POX_EFFECTIVE_DATES6';
668          return;
669       end if;
670       l_progress := '004';
671       /*
672          Pricebreak effective To Date cannot be later than Expiration date, if Expiration
673          Date exists
674       */
675       /* Bug 2691705
676        * Changed the message name to POX_EFFECTIVE_DATES2.
677       */
678       if (p_expiration_date is not null AND p_to_date > p_expiration_date) then
679          x_errormsg := 'POX_EFFECTIVE_DATES2';
680          return;
681       end if;
682 
683       l_progress := '005';
684       /*
685          If expiration date does not exist and Pricebreak To Date is greater than Header End
686          date, raise an error message
687       */
688       if (p_expiration_date is null AND p_end_date is not null AND p_to_date > p_end_date) then
689          x_errormsg := 'POX_EFFECTIVE_DATES';
690          return;
691       end if;
692 
693       l_progress := '006';
694       /* Pricebreak To Date cannot be earlier than Header Start date */
695       if (p_start_date is not null AND p_to_date < p_start_date) then
696          x_errormsg := 'POX_EFFECTIVE_DATES5';
697          return;
698       end if;
699 
700       l_progress := '007';
701       /* Pricebreak effective To Date cannot be earlier than Pricebreak effective From Date */
702       /* Bug 2691705
703        * Changed the message name to POX_EFFECTIVE_DATES3.
704       */
705       if (p_to_date is not null AND p_from_date is not null AND p_to_date < p_from_date) then
706          x_errormsg := 'POX_EFFECTIVE_DATES3';
707          return;
708       end if;
709 
710    EXCEPTION
711       when others then
712          po_message_s.sql_error('validate_effective_dates', l_progress, sqlcode);
713          raise;
714 
715    END validate_effective_dates;
716 
717 
718 
719 PROCEDURE validate_pricebreak_attributes(p_from_date        IN         date,
720                                          p_to_date          IN         date,
721                                          p_quantity         IN         varchar2,
722                                          p_ship_to_org      IN         varchar2,
723                                          p_ship_to_location IN         varchar2,
724                                          x_errormsg_name    OUT NOCOPY varchar2)
725 IS
726 l_progress VARCHAR2(3) := '';
727 
728    BEGIN
729       l_progress := '001';
730       if (p_from_date is null AND p_to_date is null
731           AND (p_quantity is null OR (to_number(p_quantity) <= 0))
732           AND p_ship_to_org is null AND p_ship_to_location is null) then
733           x_errormsg_name := 'POX_PRICEBREAK_ITEM_FAILED';
734           return;
735       end if;
736 
737    EXCEPTION
738       when others then
739          po_message_s.sql_error('validate_pricebreak_attributes', l_progress, sqlcode);
740          raise;
741 
742    END validate_pricebreak_attributes;
743 
744 /* <TIMEPHASED FPI END> */
745 
746 
747 
748 END PO_SHIPMENTS_SV8;