DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_PA_INTEGRATION_GRP

Source


1 PACKAGE BODY PO_PA_INTEGRATION_GRP AS
2 /* $Header: POXGPAVB.pls 120.4 2008/05/16 13:52:16 cvardia ship $ */
3 
4 G_PKG_NAME             CONSTANT VARCHAR2(30) := 'PO_PA_INTEGRATION_GRP';
5 
6 -------------------------------------------------------------------------------
7 --Start of Comments
8 --Name: validate_temp_labor_po
9 --Pre-reqs:
10 --  none
11 --Modifies:
12 --  None.
13 --Locks:
14 --  None.
15 --Function:
16 --  Validates the PO line/header and the project information
17 --  that is passed in . the following validattions are performed
18 --   - The project and task belong to a valid PO distribution
19 --   - The PO line/header is in a valid status
20 --   - The person id associated with the PO is valid
21 --   - The price type for the PO line is valid
22 --   - The PO line/header is in a proper OU
23 --  Returns the PO line price for the given price type and the header currency
24 --  information
25 --Parameters:
26 --IN:
27 --p_api_version
28 --  Initial API version : Expected value is 1.0
29 --p_project_id
30 --  Project id for which the validation needs to be done
31 --p_task_id
32 --  Task id for which the validation needs to be done
33 --p_po_line_id
34 --  Unique ID of the PO Line
35 --p_price_type
36 --  The price type
37 --p_po_number
38 --  The PO number - segment1
39 --p_org_id
40 --  Operating Unit
41 --p_person id
42 --  Person entering the time card
43 --p_effective_date
44 --  Person effective date
45 --IN OUT
46 --p_po_header_id
47 --  PO header id
48 --p_po_line_id
49 --  PO line id
50 --OUT:
51 --x_po_line_amt
52 --  Sum of the distribution amounts for the given project task
53 --x_po_rate
54 --  PO line price for a particular price time (line unit price multiplied
55 --  by the multiplier for the price type
56 --x_currency_code
57 --  PO header currency
58 --x_curr_rate_type
59 --  PO header rate type
60 --x_curr_rate_date
61 --  PO header rate date
62 --x_currency_rate
63 --  PO header currency rate
64 --x_ret_status
65 --  (a) FND_API.G_RET_STS_SUCCESS - 'S' if successful
66 --  (b) FND_API.G_RET_STS_ERROR - 'E' if known error occurs
67 --  (c) FND_API.G_RET_STS_UNEXP_ERROR - 'U' if unexpected error occurs
68 --x_message_code
69 --      The applicable error message code
70 --Testing:
71 --  None.
72 --End of Comments
73 -------------------------------------------------------------------------------
74 
75 PROCEDURE validate_temp_labor_po(p_api_version    IN NUMBER,
76                                  p_project_id     IN NUMBER,
77                                  p_task_id        IN NUMBER,
78                                  p_po_number      IN VARCHAR2,--bug 7003781
79                                  p_po_line_num    IN NUMBER,
80                                  p_price_type     IN VARCHAR2,
81                                  p_org_id         IN NUMBER,
82                                  p_person_id      IN NUMBER,
83                                  p_po_header_id   IN OUT NOCOPY NUMBER,
84                                  p_po_line_id     IN OUT NOCOPY NUMBER,
85                                  x_po_line_amt    OUT NOCOPY NUMBER,
86                                  x_po_rate        OUT NOCOPY NUMBER,
87                                  x_currency_code  OUT NOCOPY VARCHAR2,
88                                  x_curr_rate_type OUT NOCOPY VARCHAR2,
89                                  x_curr_rate_date OUT NOCOPY DATE,
90                                  x_currency_rate  OUT NOCOPY NUMBER,
91                                  x_vendor_id      OUT NOCOPY NUMBER,
92                                  x_return_status  OUT NOCOPY VARCHAR2,
93                                  x_message_code   OUT NOCOPY VARCHAR2,
94                                  p_effective_date IN DATE
95                                 ) IS
96 
97 l_api_name              CONSTANT VARCHAR2(30) := 'validate_temp_labor_po';
98 l_api_version           CONSTANT NUMBER := 1.0;
99 
100 l_line_location_id      PO_LINE_LOCATIONS_ALL.line_location_id%TYPE;
101 l_distribution_id       PO_DISTRIBUTIONS_ALL.po_distribution_id%TYPE; --BUG#7046429
102 l_person_id             PER_ALL_PEOPLE_F.person_id%TYPE;
103 l_assignment_id         NUMBER;
104 
105 l_status_rec            PO_STATUS_REC_TYPE;
106 l_rcv_close_prf         VARCHAR2(1);
107 
108 BEGIN
109     -- Initialise the return status
110     x_return_status := FND_API.G_RET_STS_SUCCESS;
111 
112     -- check for API version
113     IF ( NOT FND_API.compatible_api_call(l_api_version,p_api_version,l_api_name,G_PKG_NAME) )
114     THEN
115         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
116         x_message_code := to_char(sqlcode);
117         return;
118     END IF;
119 
120     -- Return if any of the required information is not provided
121     IF p_project_id is null OR
122        p_task_id is null  OR
123        p_price_type is null OR
124        (p_po_number is null and p_po_header_id is null) OR
125        (p_po_line_num is null and p_po_line_id is null) OR
126        p_org_id is null
127     THEN
128        x_return_status :=  FND_API.G_RET_STS_ERROR;
129        x_message_code := 'PO_SVC_INVALID_PARAMS';
130        return;
131     END IF;
132 
133     -- Derive the PO header and line id's if not provided
134     IF p_po_header_id is null THEN
135 
136       Begin
137 
138        -- Sql What : Gets the po header id for a given po number and OU
139        -- Sql Why :  To validate the PO number
140        SELECT po_header_id
141        INTO  p_po_header_id
142        FROM po_headers_all
143        WHERE segment1 = p_po_number
144        AND  org_id = p_org_id;
145 
146       Exception
147         when others then
148          x_return_status := FND_API.G_RET_STS_ERROR;
149          x_message_code := 'PO_SVC_INVALID_PO_NUM';
150          return;
151       End;
152 
153     END IF;
154 
155     IF p_po_line_id is null THEN
156 
157      Begin
158 
159        -- Sql What : Gets the po line id for a given po line number and OU
160        -- Sql Why :  To validate the PO line number
161        SELECT po_line_id
162        INTO  p_po_line_id
163        FROM po_lines_all
164        WHERE line_num = p_po_line_num
165        AND po_header_id = p_po_header_id
166        AND  org_id = p_org_id;
167 
168      Exception
169         when others then
170          x_return_status := FND_API.G_RET_STS_ERROR;
171          x_message_code := 'PO_SVC_INVALID_PO_LINE';
172          return;
173      End;
174 
175     END IF;
176 
177      -- Check if the line is a rate based line
178      IF not (PO_SERVICES_PVT.is_rate_based_line (p_po_line_id)) THEN
179         x_return_status := FND_API.G_RET_STS_ERROR;
180         x_message_code := 'PO_SVC_INVALID_PO_LINE';
181         return;
182      END IF;
183 
184     -- Derive the shipment if for status check. As we already checked for
185     -- rate based line we know that there will be a single shipment
186 
187        Begin
188 
189         -- Sql What : Gets the po line location id for a given po line id
190         -- Sql Why :  To check the shipment status
191         SELECT line_location_id
192         INTO l_line_location_id
193         FROM po_line_locations_all
194         WHERE po_line_id = p_po_line_id;
195 
196        Exception
197           When others then
198              x_return_status :=  FND_API.G_RET_STS_UNEXP_ERROR;
199              x_message_code := to_char(sqlcode);
200              return;
201        End;
202 
203       PO_DOCUMENT_CHECKS_GRP.po_status_check(
204           p_api_version => 1.0
205        ,  p_header_id => po_tbl_number( p_po_header_id )
206        ,  p_release_id => po_tbl_number(null)
207        ,  p_document_type => po_tbl_varchar30( null )
208        ,  p_document_subtype => po_tbl_varchar30( null )
209        ,  p_document_num => po_tbl_varchar30( NULL )
210        ,  p_vendor_order_num => po_tbl_varchar30( NULL )
211        ,  p_line_id => po_tbl_number( p_po_line_id )
212        ,  p_line_location_id => po_tbl_number( l_line_location_id )
213        ,  p_distribution_id => po_tbl_number( null )
214        ,  p_mode => 'G_GET_STATUS'
215        ,  p_lock_flag => 'N'
216        ,  x_po_status_rec => l_status_rec
217        ,  x_return_status => x_return_status
218        );
219 
220      l_rcv_close_prf := nvl(fnd_profile.value('RCV_CLOSED_PO_DEFAULT_OPTION'),'N');
221 
222       IF (l_status_rec.AUTHORIZATION_STATUS(1) <> 'APPROVED'  OR
223           l_status_rec.CANCEL_FLAG(1) = 'Y' OR
224           l_status_rec.CLOSED_CODE(1)  in ('CLOSED','FINALLY CLOSED') OR
225           l_status_rec.APPROVAL_FLAG(1) <> 'Y' OR
226           l_status_rec.HOLD_FLAG(1) = 'Y' OR
227           l_status_rec.FROZEN_FLAG(1) = 'Y'  OR
228           (l_status_rec.CLOSED_CODE(1) = 'CLOSED FOR RECEIVING' and
229            l_rcv_close_prf = 'N') )
230       THEN
231          x_return_status := FND_API.G_RET_STS_ERROR;
232          x_message_code := 'PO_SVC_INVALID_PO_STATUS';
233          return;
234       END IF;
235 
236 
237      -- Check if a valid distribution exists for the given project and task
238      Begin
239 
240        -- Sql What : Gets the number of distributions for the given project task
241        -- Sql Why :  To check the project task validity
242        -- BUG#7046429
243          SELECT  min(po_distribution_id)
244          INTO    l_distribution_id
245 	     FROM    po_distributions_all
246 	     WHERE   po_line_id = p_po_line_id
247   	         AND project_id = p_project_id
248                  AND task_id    = p_task_id;
249 
250 	   -- BUG#7046429
251 	   -- Get the first distribution from Purchase order which has a Dummy Project Associated.
252 	   -- This is used in the case when user select a Project on the Timecard which doesn't
253            -- matches with the projects in Purchase Order which was selected on  Time card.
254 
255            IF l_distribution_id IS NULL THEN
256               SELECT  MIN(psp.po_distribution_id)
257               INTO    l_distribution_id
258 	              FROM    PO_SP_VAL_V psp
259 	              WHERE   psp.po_line_id           = p_po_line_id
260 		          AND psp.project_id           IS NOT NULL
261 	                  AND psp.task_id              IS NOT NULL
262 	                  AND psp.VALIDATE_PROJECT_FLAG = 'Y';
263            END IF;
264 
265      if l_distribution_id IS NULL then
266          x_return_status := FND_API.G_RET_STS_ERROR;
267          x_message_code := 'PO_SVC_INVALID_PROJECT_TASK';
268          return;
269      end if;
270 
271      Exception
272         when others then
273          x_return_status := FND_API.G_RET_STS_ERROR;
274          x_message_code := 'PO_SVC_INVALID_PROJECT_TASK';
275          return;
276      End;
277 
278 
279      -- check if the price type is valid . skip the standard and fixed price types
280      IF  p_price_type not in ('FIXED PRICE','STANDARD') AND
281          not PO_PRICE_DIFFERENTIALS_PVT.is_price_type_enabled(p_price_type => p_price_type,
282                                                              p_entity_type => 'PO LINE',
283                                                              p_entity_id => p_po_line_id)
284      THEN
285         x_return_status := FND_API.G_RET_STS_ERROR;
286         x_message_code := 'PO_SVC_INVALID_PRICE_TYPE';
287         return;
288      END IF;
289 
290      -- Validate with the person on the PO line if person id is passed in
291      -- BUG#7046429
292      -- If Association can also be in the New Table po_cwk_association.
293      -- Which is verified by is_PO_active function.
294      IF p_person_id is not null THEN
295        HR_PO_INFO.get_person_for_po_line (p_po_line_id     => p_po_line_id,
296                                           p_effective_date => p_effective_date,
297                                           p_person_id      => l_person_id,
298                                           p_assignment_id  => l_assignment_id
299                                           );
300 
301 	IF (   (l_person_id is null OR p_person_id <> l_person_id)AND
302 	   NOT (PO_PA_INTEGRATION_GRP.is_PO_active(p_person_id, p_effective_date,p_po_header_id,p_po_line_id)) )
303        THEN
304           x_return_status := FND_API.G_RET_STS_ERROR;
305           x_message_code := 'PO_SVC_INVALID_PERSON';
306           return;
307        END IF;
308      END IF;
309 
310      -- If we have come this far that means all validations passed and
311      -- we now get the information from the PO to pass back to PA
312 
313      -- Get the line rate/currency info
314         get_line_rate_info(   p_api_version    => 1.0,
315                               p_price_type     => p_price_type,
316                               p_po_line_id     => p_po_line_id,
317                               p_project_id     => p_project_id,
318                               p_task_id        => p_task_id,
319                               x_po_rate        => x_po_rate,
320                               x_currency_code  => x_currency_code,
321                               x_curr_rate_type => x_curr_rate_type ,
322                               x_curr_rate_date => x_curr_rate_date,
323                               x_currency_rate  => x_currency_rate,
324                               x_vendor_id      => x_vendor_id,
325                               x_return_status  => x_return_status,
326                               x_message_code   => x_message_code
327                           );
328 
329      -- Get the total distribution amount for given project task
330 
331         Begin
332 
333            -- Sql What : Gets the total distribution amt for the given project task
334            -- Sql Why :  For projects to calculate the cost for the project
335            -- BUG#7046429
336 	   -- Get the Project/Task from the distribution which is relevant.
337 	   -- This Change is made because the Project selected by User on the Timecard might
338 	   -- match with the projects in Purchase Order and might doesn't matches.
339 
340            SELECT  sum(nvl(pod1.amount_ordered,0) - nvl(pod1.amount_cancelled,0))
341            INTO    x_po_line_amt
342            FROM    po_distributions_all pod1,
343 	           po_distributions_all pod2
344            WHERE   pod1.po_line_id = pod2.po_line_id
345                 AND pod1.project_id = pod2.project_id
346                 AND pod1.task_id    = pod2.task_id
347                 AND pod2.po_distribution_id = l_distribution_id;
348 
349        Exception
350           When others then
351              x_return_status :=  FND_API.G_RET_STS_UNEXP_ERROR;
352              x_message_code := to_char(sqlcode);
353              return;
354        End;
355 
356 
357 EXCEPTION
358 When Others then
359      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
360      x_message_code := to_char(sqlcode);
361 END;
362 
363 -------------------------------------------------------------------------------
364 --Start of Comments
365 --Name: is_rate_based_line
366 --Pre-reqs:
367 --  None.
368 --Modifies:
369 --  None.
370 --Locks:
371 --  None.
372 --Function:
373 --  Determines if a po line is rate based line
374 --Parameters:
375 --IN:
376 --p_po_line_id
377 --  Unique ID of the PO Line
378 --p_po_distribution_id
379 --  PO distribution id
380 --Returns:
381 --  TRUE if the PO line/distribution  is an rate based line. FALSE otherwise.
382 --Testing:
383 --  None.
384 --End of Comments
385 -------------------------------------------------------------------------------
386 
387 FUNCTION is_rate_based_line (p_po_line_id         IN NUMBER,
388                              p_po_distribution_id IN NUMBER)
389 RETURN BOOLEAN IS
390 
391 l_po_line_id  PO_LINES_ALL.po_line_id%TYPE;
392 
393 BEGIN
394 
395      IF p_po_line_id is null and p_po_distribution_id is null THEN
396        RETURN FALSE;
397      END IF;
398 
399      IF p_po_line_id is null THEN
400 
401       Begin
402 
403         -- Sql What : Gets the line id for the given distribution
404         -- Sql Why :  To check the line type
405         SELECT po_line_id
406         INTO  l_po_line_id
407         FROM  po_distributions_all
408         WHERE po_distribution_id = p_po_distribution_id;
409       Exception
410         When others then
411         RETURN FALSE;
412       End;
413 
414      ELSE
415 
416        l_po_line_id := p_po_line_id;
417 
418      END IF;
419 
420      -- Check if the line is a rate based line
421      IF  (PO_SERVICES_PVT.is_rate_based_line (l_po_line_id)) THEN
422         RETURN TRUE;
423      ELSE
424         RETURN FALSE;
425      END IF;
426 
427 EXCEPTION
428 When Others then
429     RETURN FALSE;
430 END;
431 
432 -------------------------------------------------------------------------------
433 --Start of Comments
434 --Name: get_line_rate_info
435 --Pre-reqs:
436 --  none
437 --Modifies:
438 --  None.
439 --Locks:
440 --  None.
441 --Function:
442 -- Returns the PO line price for the given price type and the header currency
443 -- information
444 --Parameters:
445 --IN:
446 --p_api_version
447 --  Initial API version : Expected value is 1.0
448 --p_po_line_id
449 --  Unique ID of the PO Line
450 --p_price_type
451 --  The price type
452 --OUT:
453 --x_po_rate
454 --  PO line price for a particular price time (line unit price multiplied
455 --  by the multiplier for the price type
456 --x_currency_code
457 --  PO header currency
458 --x_curr_rate_type
459 --  PO header rate type
460 --x_curr_rate_date
461 --  PO header rate date
462 --x_currency_rate
463 --  PO header currency rate
464 --x_ret_status
465 --  (a) FND_API.G_RET_STS_SUCCESS - 'S' if successful
466 --  (b) FND_API.G_RET_STS_ERROR - 'E' if known error occurs
467 --  (c) FND_API.G_RET_STS_UNEXP_ERROR - 'U' if unexpected error occurs
468 --x_message_code
469 --      The applicable error message code  - none in this case
470 --Testing:
471 --  None.
472 --End of Comments
473 -------------------------------------------------------------------------------
474 
475 PROCEDURE get_line_rate_info (p_api_version    IN NUMBER,
476                               p_price_type     IN VARCHAR2,
477                               p_po_line_id     IN NUMBER,
478                               p_project_id     IN NUMBER,
479                               p_task_id        IN NUMBER,
480                               x_po_rate        OUT NOCOPY NUMBER,
481                               x_currency_code  OUT NOCOPY VARCHAR2,
482                               x_curr_rate_type OUT NOCOPY VARCHAR2,
483                               x_curr_rate_date OUT NOCOPY DATE,
484                               x_currency_rate  OUT NOCOPY NUMBER,
485                               x_vendor_id      OUT NOCOPY NUMBER,
486                               x_return_status  OUT NOCOPY VARCHAR2,
487                               x_message_code   OUT NOCOPY VARCHAR2
488                              ) IS
489 
490 l_api_name              CONSTANT VARCHAR2(30) := 'get_line_rate_info';
491 l_api_version           CONSTANT NUMBER := 1.0;
492 
493 l_po_header_id          PO_HEADERS_ALL.po_header_id%TYPE;
494 l_price                 NUMBER := null;
495 l_distribution_id       PO_DISTRIBUTIONS_ALL.po_distribution_id%TYPE;
496 l_rate                  PO_DISTRIBUTIONS_ALL.rate%TYPE;
497 l_rate_date             PO_DISTRIBUTIONS_ALL.rate_date%TYPE;
498 l_base_currency_code    GL_SETS_OF_BOOKS.currency_code%TYPE;
499 
500 BEGIN
501     -- Initialise the return status
502     x_return_status := FND_API.G_RET_STS_SUCCESS;
503 
504     -- check for API version
505     IF ( NOT FND_API.compatible_api_call(l_api_version,p_api_version,l_api_name,G_PKG_NAME) )
506     THEN
507         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
508         x_message_code := to_char(sqlcode);
509     END IF;
510 
511     -- Get the price for the price type and line price
512     PO_PRICE_DIFFERENTIALS_PVT.get_price_for_price_type(p_entity_id   =>  p_po_line_id,
513                                                         p_entity_type =>  'PO LINE',
514                                                         p_price_type  =>  p_price_type,
515                                                         x_price       =>  l_price);
516 
517     x_po_rate := l_price;
518 
519     -- get the functional currency
520     l_base_currency_code := PO_CORE_S2.get_base_currency;
521 
522     -- Get the PO header id to derive the currency info
523     Begin
524 
525       -- Sql What : Gets the header id and the vendor id from the header
526       --            for the given line
527       -- Sql Why :  To get the currency info
528       SELECT poh.po_header_id,
529              poh.vendor_id
530       INTO   l_po_header_id,
531              x_vendor_id
532       FROM   po_lines_all pol,
533              po_headers_all poh
534       WHERE  pol.po_header_id = poh.po_header_id
535       AND    pol.po_line_id = p_po_line_id;
536 
537     Exception
538       When others then
539        x_return_status :=  FND_API.G_RET_STS_UNEXP_ERROR;
540        x_message_code := to_char(sqlcode);
541        return;
542     End;
543 
544     -- Get the currency Info from the PO
545     PO_CORE_S2.get_po_currency_info(p_po_header_id  => l_po_header_id,
546                                 x_currency_code => x_currency_code,
547                                 x_curr_rate_type => x_curr_rate_type,
548                                 x_curr_rate_date => x_curr_rate_date,
549                                 x_currency_rate => x_currency_rate);
550 
551     -- If the PO currency is different from the functional currency
552     -- get the rate and rate date from the distribution if available
553     IF x_currency_code <> l_base_currency_code THEN
554 
555      -- Get the minimam distribution id for the given project and task
556      Begin
557            -- Sql What : Gets the minimam distribution id for the give project/task
558            -- Sql Why :  To get the currency info
559            SELECT  min(po_distribution_id)
560            INTO    l_distribution_id
561            FROM    po_distributions_all
562            WHERE   po_line_id = p_po_line_id
563            AND     project_id = p_project_id
564            AND     task_id    = p_task_id;
565 
566 	   -- BUG#6972530
567 	   -- Get the first distribution from Purchase order which has a Dummp Project Associated.
568 	   -- This is used in the case when user select a Project on the Timecard which doesn't
569            -- matches with the projects in Purchase Order which was selected on  Time card.
570 
571            IF l_distribution_id IS NULL THEN
572               SELECT  MIN(psp.po_distribution_id)
573               INTO    l_distribution_id
574               FROM    PO_SP_VAL_V psp
575               WHERE   psp.po_line_id           = p_po_line_id
576                   AND psp.project_id           IS NOT NULL
577                   AND psp.task_id              IS NOT NULL
578                   AND psp.VALIDATE_PROJECT_FLAG = 'Y';
579            END IF;
580 
581      Exception
582           When others then
583              x_return_status :=  FND_API.G_RET_STS_UNEXP_ERROR;
584              x_message_code := to_char(sqlcode);
585              return;
586      End;
587 
588      -- Get the rate and rate date from the distribution and return them
589      -- if they are not null
590      Begin
591            -- Sql What : Gets the rate info for the min distribution
592            -- Sql Why :  To get the rate info
593            SELECT  rate_date,
594                    rate
595            INTO    l_rate_date,
596                    l_rate
597            FROM    po_distributions_all
598            WHERE   po_distribution_id = l_distribution_id;
599 
600      Exception
601           When others then
602              x_return_status :=  FND_API.G_RET_STS_UNEXP_ERROR;
603              x_message_code := to_char(sqlcode);
604              return;
605      End;
606 
607      if l_rate_date is not null then
608          x_curr_rate_date := l_rate_date;
609      end if;
610 
611      if l_rate is not null then
612          x_currency_rate := l_rate;
613      end if;
614 
615    END IF;  -- end if functional currency and base currency not equal
616 
617 
618 EXCEPTION
619 When Others then
620      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
621      x_message_code := to_char(sqlcode);
622 END;
623 
624 FUNCTION is_PO_active
625     (p_person_id            IN         NUMBER
626     ,p_effective_date       IN         DATE
627     ,p_po_header_id         IN         NUMBER
628     ,p_po_line_id           IN         NUMBER)
629   RETURN BOOLEAN IS
630 
631   l_api_name           CONSTANT VARCHAR2(30) := 'is_PO_active';
632   l_log_head           CONSTANT VARCHAR2(100) := G_PKG_NAME || l_api_name;
633   l_api_version        CONSTANT NUMBER := 1.0;
634   l_progress           VARCHAR2(3) := '000';
635   X_flag               VARCHAR2(1):='N';
636   l_effective_date DATE;
637 
638 BEGIN
639 
640     PO_DEBUG.debug_stmt(l_log_head,l_progress,'Start');
641     l_progress:=010;
642 
643     --BUG#7046429  p_effective data can be passed as NULL.
644     l_effective_date := nvl(p_effective_date,TRUNC(sysdate));
645 
646     IF p_person_id IS NOT NULL AND l_effective_date IS NOT NULL
647     AND p_po_header_id IS NOT NULL AND p_po_line_id IS NOT NULL
648     THEN
649 
650       BEGIN
651          select 'Y'
652          INTO X_flag
653          from dual
654          where exists(
655               SELECT po_header_id,po_line_id
656               FROM  po_sp_val_v
657               where person_id = p_person_id
658               AND fnd_date.canonical_to_date(fnd_date.date_to_canonical(l_effective_date)) >=
659                                fnd_date.canonical_to_date(fnd_date.date_to_canonical(pol_start_date))
660               AND fnd_date.canonical_to_date(fnd_date.date_to_canonical(l_effective_date)) <=
661                                fnd_date.canonical_to_date(fnd_date.date_to_canonical(pol_expiration_date))
662               AND fnd_date.canonical_to_date(fnd_date.date_to_canonical(l_effective_date)) >=
663                                fnd_date.canonical_to_date(fnd_date.date_to_canonical(assignmt_effective_start_date))
664               AND fnd_date.canonical_to_date(fnd_date.date_to_canonical(l_effective_date)) <=
665                                fnd_date.canonical_to_date(fnd_date.date_to_canonical(assignmt_effective_end_date))
666               AND po_header_id = p_po_header_id
667               AND po_line_id = p_po_line_id
668               );
669 
670 
671       EXCEPTION
672          when OTHERS THEN
673             PO_DEBUG.debug_stmt(l_log_head,l_progress,'No data found');
674             RETURN FALSE;
675       END;
676     END IF;
677           l_progress:=020;
678       IF X_flag='Y' THEN
679              PO_DEBUG.debug_stmt(l_log_head,l_progress,'Record found');
680              RETURN TRUE;
681       ELSE
682              PO_DEBUG.debug_stmt(l_log_head,l_progress,'No data found');
683              RETURN FALSE;
684       END IF;
685 END is_PO_active;
686 
687 
688 END PO_PA_INTEGRATION_GRP;