DBA Data[Home] [Help]

PACKAGE BODY: APPS.GMS_AP_API2

Source


1 PACKAGE BODY GMS_AP_API2 AS
2 /* $Header: gmsapx2b.pls 120.1 2006/01/25 14:01:32 aaggarwa noship $ */
3 
4     -- Start of comments
5     -- -----------------
6     -- API Name         : check_award_funding
7     -- Type             : private
8     -- Pre Reqs         : None
9     -- BUG              : 3077074
10     -- Description      : EXECEPTION HANDLING TO GMS_AP_API TO SUPPORT CODE HOOK IN AP APPROVAL.
11     --
12     -- Function         : check award funding identifies the award funding the project.
13     -- Calling API      : verify_create_adl
14     -- End of comments
15     -- ----------------
16 
17 PROCEDURE check_award_funding ( p_project_id IN NUMBER,
18 				p_award_id   IN OUT NOCOPY NUMBER,
19 			        p_status out NOCOPY NUMBER ) is
20 
21     l_award_id  NUMBER ;
22     l_status    NUMBER ;
23 
24     -- =====================================================
25     -- Cursor : c_validate_award
26     -- Cursor verifies that award is funded by the
27     -- project.
28     -- =====================================================
29     cursor c_validate_award is
30            select ins.award_id
31              from gms_installments ins,
32                   gms_summary_project_fundings pf
33             where ins.installment_id = pf.installment_id
34 	      and pf.project_id      = p_project_id
35 	      and ins.award_id       = p_award_id ;
36 
37     -- =====================================================
38     -- Cursor : c_get_award
39     -- Cursor finds out if there is a award funding the
40     -- project charged to a transaction.
41     -- =====================================================
42     cursor c_get_award is
43            select ins.award_id
44              from gms_installments ins,
45                   gms_summary_project_fundings pf
46             where ins.installment_id = pf.installment_id
47 	      and pf.project_id      = p_project_id
48 	      and NOT EXISTS ( select 1 from gms_installments ins2,
49 					     gms_summary_project_fundings pf2
50 				       where ins2.installment_id = pf2.installment_id
51 					 and pf2.project_id      = pf.project_id
52 					 and ins2.award_id      <> ins.award_id ) ;
53 BEGIN
54     l_award_id := p_award_id ;
55     l_status   := 0 ;
56 
57     -- =================================
58     -- Validate award.
59     -- =================================
60     IF p_award_id is not NULL THEN
61        open c_validate_award ;
62        fetch c_validate_award into l_award_id ;
63        close c_validate_award ;
64     END IF ;
65 
66     -- There is no valid award yet.
67     -- checking to see if there
68 
69     IF l_award_id is NULL THEN
70        open c_get_award ;
71        fetch c_get_award into l_award_id ;
72        close c_get_award ;
73     END IF ;
74 
75     IF l_award_id is NULL THEN
76        l_status:= -1 ;
77     ELSE
78        p_award_id := l_award_id ;
79     END IF ;
80 
81     p_status := l_status ;
82 
83 END check_award_funding ;
84 -- End of check_award_funding
85 -- ----------------------------
86 
87     -- Start of comments
88     -- -----------------
89     -- API Name         : verify_create_adl
90     -- Type             : public
91     -- Pre Reqs         : None
92     -- BUG              : 2789359, 3046767
93     -- Description      : RECURRING INVOICES USING AP DISTRIBUTION SETS FAILING
94     --                    GL FUNDSCHECK F00
95     --                    GMS: ENHANCE GMS LOGIC FOR AWARD DISTRIBUTION LINE VALIDATIONS.
96     -- Function         : This is used to create award distribution lines
97     --                    using the bulk processing. This provides a
98     --                    interface with ap recurring invoice feature.
99     -- Logic            : Identify the newly created invoice distribution
100     --                    lines and create award distribution lines for
101     --                    sponsored project.
102     -- Parameters       :
103     -- IN               : p_invoice_id   IN     NUMBER
104     --                                  The invoice id created and that may
105     --                                  have distributions associated with
106     --                                  an award.
107     --                  : p_calling_sequence IN  varchar2
108     --                      calling sequence of the API for the debugging purpose.
109     -- Calling API      : AP_RECURRING_INVOICES_PKG.ap_create_recurring_invoices
110     --                    AP_APPROVAL_PKG.APPROVE
111     -- End of comments
112     -- ----------------
113 
114 PROCEDURE VERIFY_CREATE_ADLS( p_invoice_id IN NUMBER ,
115                               p_calling_sequence IN VARCHAR2 ) is
116 
117 type gms_ap_type_number is table of number index by binary_integer;
118 type gms_ap_type_date   is table of date   index by binary_integer;
119 
120 l_invoice_id                    gms_ap_type_number;
121 l_distribution_line_number	gms_ap_type_number;
122 l_invoice_distribution_id	gms_ap_type_number;
123 l_project_id                    gms_ap_type_number;
124 l_task_id                       gms_ap_type_number;
125 l_award_id                      gms_ap_type_number;
126 l_new_award_set_id              gms_ap_type_number;
127 l_last_update_date              gms_ap_type_date;
128 l_creation_date                 gms_ap_type_date;
129 l_last_updated_by               gms_ap_type_number;
130 l_created_by                    gms_ap_type_number;
131 l_last_update_login             gms_ap_type_number;
132 l_dummy_tab                     gms_ap_type_number;
133 
134 l_award_set_id                  gms_ap_type_number ;
135 l_award_set_idX                 NUMBER ;
136 l_count                         NUMBER ;
137 l_project_idX                   NUMBER ;
138 l_award_idX                     NUMBER ;
139 l_status                        NUMBER ;
140 AWARD_NOT_FOUND                 EXCEPTION ;
141 
142 l_invoice_num                   ap_invoices_all.invoice_num%TYPE ;
143 
144 cursor c_ap is
145 	  SELECT A.invoice_id 			    INVOICE_ID,
146 		 A.distribution_line_number	    distribution_line_number,
147 		 A.invoice_distribution_id	    invoice_distribution_id,
148 		 A.project_id			    PROJECT_ID,
149 		 A.task_id			    TASK_ID,
150                  A.award_id                         award_set_id,
151 		 A.last_update_date		    LAST_UPDATE_DATE,
152 		 A.creation_date		    CREATION_DATE,
153 		 A.last_updated_by		    LAST_UPDATED_BY,
154 		 A.created_by			    CREATED_BY,
155 		 NVL(A.last_update_login,0)	    LAST_UPDATE_LOGIN,
156                  inv.invoice_num                    invoice_num
157 	    from ap_invoice_distributions_all  	A,
158                  pa_projects_all                p,
159                  gms_project_types          gpt,
160                  ap_invoices_all                inv
161 	   where a.invoice_id          = p_invoice_id
162              and a.project_id          = p.project_id
163 	     and p.project_type       = gpt.project_type
164              and inv.invoice_id       = a.invoice_id
165 	     and gpt.sponsored_flag    = 'Y'  ;
166 
167 cursor c_adl is
168        select * from gms_award_distributions where award_set_id = l_award_set_idX
169                                                and adl_line_num = 1 ;
170 l_adl_rec c_adl%ROWTYPE ;
171 
172 cursor c2 is
173 	  SELECT 1
174 	    from ap_invoice_distributions_all  	A,
175                  pa_projects_all                p,
176                  gms_project_types          gpt
177 	   where a.invoice_id          = p_invoice_id
178              and a.project_id          = p.project_id
179 	     and p.project_type       = gpt.project_type
180 	     and gpt.sponsored_flag    = 'Y'
181 	     and not exists ( select 1 from gms_award_distributions adl
182 				where adl.invoice_id = p_invoice_id
183 				  and adl.distribution_line_number = A.distribution_line_number
184 				  and adl.document_type            = 'AP'
185 				  and adl.award_set_id             = NVL(a.award_id,0)
186 				  and adl.adl_line_num             = 1
187 				  and adl.adl_status               = 'A' ) ;
188 
189 
190 
191 BEGIN
192 
193  -- Start of comment
194  -- Verify that grants is enabled.
195  -- End of comments.
196  --
197  IF NOT gms_install.enabled THEN
198     return ;
199  END IF ;
200 
201  -- Load the collection with the AP inv dist data first.
202  -- The AP inv dist should have the invoice_id in parameters
203  -- value.
204  -- The AP inv dist should have award_id column populated.
205 
206 IF NVL(SUBSTR(p_calling_sequence, 1,15),'X') <> 'AP_APPROVAL_PKG' THEN
207 
208 	  SELECT A.invoice_id 			INVOICE_ID,
209 		 A.distribution_line_number	distribution_line_number,
210 		 A.invoice_distribution_id	invoice_distribution_id,
211 		 A.project_id			PROJECT_ID,
212 		 A.task_id			TASK_ID,
213          	 ADL.award_id         		AWARD_ID,
214 		 A.award_id                     award_set_id,
215 		 A.last_update_date		LAST_UPDATE_DATE,
216 		 A.creation_date		CREATION_DATE,
217 		 A.last_updated_by		LAST_UPDATED_BY,
218 		 A.created_by			CREATED_BY,
219 		 NVL(A.last_update_login,0)	LAST_UPDATE_LOGIN,
220                  gms_awards_dist_pkg.get_award_set_id NEW_AWARD_SET_ID
221             BULK COLLECT INTO l_invoice_id,
222                               l_distribution_line_number,
223                               l_invoice_distribution_id,
224                               l_project_id ,
225                               l_task_id ,
226                               l_award_id,
227 			      l_award_set_id,
228                               l_last_update_date ,
229                               l_creation_date ,
230                               l_last_updated_by ,
231                               l_created_by ,
232                               l_last_update_login  ,
233 			      l_new_award_set_id
234 	    from ap_invoice_distributions_all  	A,
235                  gms_award_distributions       adl
236 	   where a.invoice_id          = p_invoice_id
237              and adl.award_set_id      = a.award_id
238              and adl.adl_line_num      = 1
239              and a.award_id IS NOT NULL;
240 END IF ;
241 
242 -- 3046767 GMS: ENHANCE GMS LOGIC FOR AWARD DISTRIBUTION LINE VALIDATIONS. STARTS
243 IF NVL(SUBSTR(p_calling_sequence, 1,15),'X') = 'AP_APPROVAL_PKG' THEN
244     l_count := 0 ;
245 
246     -- 2308005 ( CLEARING INVOICE DIST. LINE AFTER CHANGING AWARD MAKES ADL STATUS 'I' )
247 
248      -- ==============================================================================================
249      -- BUG	       : 4953772
250      -- Description    : R12.PJ:XB2:DEV:GMS: APPSPERF:  PACKAGE:GMSAPX2B.PLS
251      -- Resolution     : Sql statement to update award id NULL on ap distribution was changed to bulk
252      --                 Processing. This has resolved the Share Memory Size 1,282,674
253      --                  SQL ID : 14724997 	Share Memory Size 1,282,722
254      --                  SQL ID : 14724976     Share Memory Size 452,386
255      --                  SQL ID : 14724956     Share Memory Size 444,106
256      -- ==============================================================================================
257 
258     l_dummy_tab.delete ;
259 
260     select adl2.award_set_id
261      bulk collect into l_dummy_tab
262      from gms_award_distributions      adl2,
263           ap_invoice_distributions_all apd
264     where apd.invoice_id         = p_invoice_id
265       and apd.award_id 		is not null
266       and adl2.award_set_id     = apd.award_id
267       and adl2.invoice_id       = apd.invoice_id
268       and adl2.document_type	= 'AP'
269       and adl2.distribution_line_number	= apd.distribution_line_number
270       and adl2.invoice_distribution_id  = apd.invoice_distribution_id
271       and adl2.adl_status	= 'I'  ;
272 
273     IF l_dummy_tab.count > 0 THEN
274 
275       FORALL i in l_dummy_tab.FIRST..l_dummy_tab.LAST
276        UPDATE gms_award_distributions
277           SET adl_status = 'A'
278         where  award_set_id = l_dummy_tab(i) ;
279 
280     END IF ;
281 
282     l_dummy_tab.delete ;
283 
284     -- Inactivate ADLS that belongs to the AP distribution line but
285     -- not tied up with award_id in ap_distribution line.
286     -- Inactivate dangling active adls.
287     -- ----
288 
289      -- ==============================================================================================
290      -- BUG	       : 4953772
291      -- Description    : R12.PJ:XB2:DEV:GMS: APPSPERF:  PACKAGE:GMSAPX2B.PLS
292      -- Resolution     : Sql statement to update award id NULL on ap distribution was changed to bulk
293      --                 Processing. This has resolved the Share Memory Size 1,282,674
294      --                  SQL ID : 14724997 	Share Memory Size 1,282,722
295      --                  SQL ID : 14724976     Share Memory Size 452,386
296      --                  SQL ID : 14724956     Share Memory Size 444,106
297      -- ==============================================================================================
298     select adl2.award_set_id
299      bulk collect into l_dummy_tab
300      from gms_award_distributions      adl2,
301           ap_invoice_distributions_all apd
302     where apd.invoice_id        = p_invoice_id
303       and apd.award_id 		is not null
304       and adl2.award_set_id     <> apd.award_id
305       and adl2.invoice_id	= apd.invoice_id
306       and adl2.document_type    = 'AP'
307       and adl2.distribution_line_number = apd.distribution_line_number
308       and adl2.invoice_distribution_id  = apd.invoice_distribution_id
309       and adl2.adl_status	= 'A'   ;
310 
311 
312     IF l_dummy_tab.count > 0 THEN
313 
314       FORALL i in l_dummy_tab.FIRST..l_dummy_tab.LAST
315        UPDATE gms_award_distributions
316           SET adl_status = 'I'
317         where  award_set_id = l_dummy_tab(i) ;
318 
319     END IF ;
320 
321     l_dummy_tab.delete ;
322 
323      -- ==================================================
324      -- Update award_id to NULL for non sponsored
325      -- projects.
326      -- =================================================
327      -- Bug : 4953772
328      -- R12.PJ:XB2:DEV:GMS: APPSPERF:  PACKAGE:GMSAPX2B.PLS
329      --
330      -- ==============================================================================================
331      -- BUG	       : 4953772
332      -- Description    : R12.PJ:XB2:DEV:GMS: APPSPERF:  PACKAGE:GMSAPX2B.PLS
333      -- Resolution     : Sql statement to update award id NULL on ap distribution was changed to bulk
334      --                 Processing. This has resolved the Share Memory Size 1,282,674
335      --                  SQL ID : 14724997 	Share Memory Size 1,282,722
336      --                  SQL ID : 14724976     Share Memory Size 452,386
337      --                  SQL ID : 14724956     Share Memory Size 444,106
338      -- ==============================================================================================
339     /* 25-jan-2006
340     ** Update statement was changed to bulk statement to resolve the share memory performance issue.
341     */
342     select a.invoice_distribution_id
343      bulk collect into l_dummy_tab
344      from ap_invoice_distributions_all  	A,
348       and a.project_id          = p.project_id
345           pa_projects_all                p,
346           gms_project_types          gpt
347     where a.invoice_id          = p_invoice_id
349       and a.award_id            is not NULL
350       and p.project_type        = gpt.project_type
351       and gpt.sponsored_flag    = 'N'  ;
352 
353     IF l_dummy_tab.count > 0 THEN
354 
355       FORALL i in l_dummy_tab.FIRST..l_dummy_tab.LAST
356        UPDATE ap_invoice_distributions_all apd
357           SET award_id = NULL
358         where apd.invoice_id = p_invoice_id
359 	  and apd.invoice_distribution_id = l_dummy_tab(i) ;
360 
361     END IF ;
362 
363     l_dummy_tab.delete ;
364 
365     FOR ap_rec in c_ap LOOP
366 
367 	l_award_set_idX := NVL(ap_rec.award_set_id,0) ;
368         l_invoice_num   := ap_rec.invoice_num ;
369 
370 	l_adl_rec := NULL ;
371 
372 	open c_adl ;
373 	fetch c_adl into l_adl_rec ;
374 	close c_adl ;
375 
376 	IF NOT (( NVL(l_adl_rec.adl_status,'I')  = 'A' ) and
377                ( NVL(l_adl_rec.document_type,'X') = 'AP' ) and
378                ( NVL(l_adl_rec.invoice_id,0)   = NVL( ap_rec.invoice_id,0) ) AND
379                ( NVL(l_adl_rec.distribution_line_number,0) = NVL(ap_rec.distribution_line_number,0) ) AND
380                ( NVL(l_adl_rec.invoice_distribution_id,0)  = NVL( ap_rec.invoice_distribution_id,0) )) THEN
381 
382                 l_count := l_count + 1 ;
383                 l_invoice_id(l_count)               := ap_rec.invoice_id ;
384                 l_distribution_line_number(l_count) := ap_rec.distribution_line_number;
385                 l_invoice_distribution_id(l_count)  := ap_rec.invoice_distribution_id;
386                 l_project_id(l_count)               := ap_rec.project_id;
387                 l_task_id(l_count)                  := ap_rec.task_id;
388 		l_project_idX                       := ap_rec.project_id;
389 		l_award_idX                         := l_adl_rec.award_id ;
390 
391 		check_award_funding( l_project_idX, l_award_idX, l_status ) ;
392 
393 		IF l_status = -1 THEN
394 		   raise AWARD_NOT_FOUND ;
395                 ELSE
396 		   l_award_id(l_count) := l_award_idX ;
397 		END IF ;
398 
399                 l_last_update_date(l_count)         := ap_rec.last_update_date;
400                 l_creation_date(l_count)            := ap_rec.creation_date;
401                 l_last_updated_by(l_count)          := ap_rec.last_updated_by;
402                 l_created_by(l_count)               := NVL(ap_rec.created_by,0);
403                 l_last_update_login(l_count)        := ap_rec.last_update_login;
404 		l_new_award_set_id(l_count)         := gms_awards_dist_pkg.get_award_set_id ;
405 
406 	END IF ;
407 
408     END LOOP ;
409 
410 END IF ;
411 -- 3046767 GMS: ENHANCE GMS LOGIC FOR AWARD DISTRIBUTION LINE VALIDATIONS. END
412 
413      -- Start of comments
414      -- Check if need to proceed.
415      -- End of comment.
416 
417      IF l_invoice_id.count = 0 then
418         -- bug 3772472 PJ.M:B5: QA:P11:OTH: DELETION OF ADLS  WHEN REQ,PO OR AP LINES
419         -- ARE DELETED.
420         -- delete orphan adls for a given invoice id.
421         -- scenarions : POETA ap distribution line was changed to gl related.
422         --              Distribution line is deleted but all other distributions
423         --              has correct adls.
424         --              ADLS are in sych so we can delete orphan adls now.
425         delete from gms_award_distributions
426          where invoice_id = p_invoice_id
427            and document_type = 'AP'
428            and award_set_id not in ( select award_id from ap_invoice_distributions_all
429                                       where invoice_id = p_invoice_id
430                                         and award_id is not NULL ) ;
431 
432         return ;
433      end if ;
434 
435      -- Start of comment.
436      -- Loop through all the collection and insert into the ADL table.
437      -- Update the ap inv dist record with the newly created ADLs award set id.
438      -- End of comment
439 
440 
441       FORALL i in l_invoice_distribution_id.FIRST..l_invoice_distribution_id.LAST
442       INSERT into gms_award_distributions ( award_set_id ,
443                                             adl_line_num,
444                                             document_type,
445                                             distribution_value,
446                                             project_id                 ,
447                                             task_id                    ,
448                                             award_id                   ,
449                                             request_id                 ,
450                                             adl_status                 ,
451                                             fc_status                  ,
452                                             line_type                  ,
453                                             capitalized_flag           ,
454                                             capitalizable_flag         ,
455                                             revenue_distributed_flag   ,
456                                             billed_flag                ,
457                                             bill_hold_flag             ,
458                                             invoice_distribution_id    ,
462                                             cost_distributed_flag      ,
459                                             invoice_id                 ,
460                                             distribution_line_number   ,
461                                             burdenable_raw_cost        ,
463                                             last_update_date           ,
464                                             last_updated_by            ,
465                                             created_by                 ,
466                                             creation_date              ,
467                                             last_update_login          ,
468                     			    billable_flag              )
469                                     VALUES ( l_new_award_set_id(i)  ,
470                                               1, --adl_line_num,
471                                             'AP' , --document_type,
472                                             100,
473                                             l_project_id(i)      ,
474                                             l_task_id(i)                    ,
475                                             l_award_id(i)                   ,
476                                             l_distribution_line_number(i)                 ,
477                                             'A', --adl_status                 ,
478                                             'N', --fc_status                  ,
479                                             'R', --line_type                  ,
480                                             'N'           ,
481                                             'N'         ,
482                                             'N'   ,
483                                             'N'                ,
484                                             'N'             ,
485                                             l_invoice_distribution_id(i), --invoice_distribution_id    ,
486                                             l_invoice_id(i), --invoice_id                 ,
487                                             l_distribution_line_number(i), --distribution_line_number   ,
488                                             NULL, --burdenable_raw_cost        ,
489                                             'N'      ,
490                                             l_last_update_date(i)           ,
491                                             l_last_updated_by(i)             ,
492                                             l_created_by(i)                 ,
493                                             l_creation_date(i)              ,
494                                             l_last_update_login(i)          ,
495 			         	    'N') ;
496 
497       -- Start of comment.
498       -- Update AP distribution with the award set id.
499       -- End of comment.
500 
501       FORALL k in  l_invoice_distribution_id.FIRST..l_invoice_distribution_id.LAST
502        	    update ap_invoice_distributions_all
503                set award_id = l_new_award_set_id(k)
504              where invoice_id 	= l_invoice_id(k)
505                and distribution_line_number 	=   l_distribution_line_number(k)
506                and invoice_distribution_id      = l_invoice_distribution_id(k)  ;
507 
508       -- bug 3772472 PJ.M:B5: QA:P11:OTH: DELETION OF ADLS  WHEN AP LINES
509       -- ARE DELETED.
510       -- delete orphan adls for a given invoice id.
514        where invoice_id = p_invoice_id
511       -- ADLS are in sych so we can delete orphan adls now.
512       --
513       delete from gms_award_distributions
515          and document_type = 'AP'
516          and award_set_id not in ( select award_id from ap_invoice_distributions_all
517                                     where invoice_id = p_invoice_id
518                                       and award_id is not NULL ) ;
519 
520 -- Bug 3077074
521 --     EXECEPTION HANDLING TO GMS_AP_API TO SUPPORT CODE HOOK IN AP APPROVAL.
522 --     Added exception handling routine.
523 EXCEPTION
524     WHEN AWARD_NOT_FOUND THEN
525        fnd_message.set_name('GMS','GMS_INVALID_AWARD_FOUND');
526        --
527        -- Message : Incorrect award is associated with the invoice id : ??? and
528        --	    distribution line number : ??????. Please change award information
529        --	    on the distribution line.
530 
531        fnd_message.set_token('INVNUM',l_invoice_num);
532        fnd_message.set_token('DISTLNO', l_distribution_line_number(l_count));
533        app_exception.raise_exception;
534 
535     WHEN OTHERS THEN
536        fnd_message.set_name('GMS','GMS_UNEXPECTED_ERROR');
537        fnd_message.set_token('PROGRAM_NAME',NVL(p_calling_sequence,' ')||'->gms_ap_api.verify_create_adls');
538        fnd_message.set_token('OERRNO',to_char(sqlcode));
539        fnd_message.set_token('OERRM',sqlerrm);
540        app_exception.raise_exception;
541 
542        -- EXECEPTION HANDLING TO GMS_AP_API TO SUPPORT CODE HOOK IN AP APPROVAL.
543        -- Bug 3077074 End here
544 
545  END VERIFY_CREATE_ADLS ;
546 
547 
548     -- Start of comments
549     -- -----------------
550     -- API Name         : validate_transaction
551     -- Type             : public
552     -- Pre Reqs         : None
553     -- BUG              : 2755183
554     -- Description      : INVOICE ENTRY DOES NOT VALIDATE EXP ITEM DATE W/ AWARD COPIED FROM DIST SET.
555     --
556     -- Function         : This function is called from AP_INVOICE_DISTRIBUTIONS_PKG.
557     --			  insert_from_dist_set to validate the award related
558     --			  information.
559     -- Logic            : Determine the award and call gms standard
560     --			  validation routine.
561     -- Parameters       :
562     -- IN               : x_project_id	IN Number
563     --					   Project ID value.
564     --                    x_task_id     IN Number
565     --					   Task Identifier.
566     --			  x_award_id	IN number
567     --					   ADL identifier, AWARD_SET_ID reference value.
568     --			  x_expenditure_type IN varchar2
569     --					   Expenditure type
570     --			  x_expenditure_item_date in date
571     --			                   Expenditure item date.
572     --                    x_calling_sequence      in varchar2
573     --				           calling api identifier.
574     --			  x_msg_application       in varchar2
575     --                                     application identifier = 'GMS'
576     --                    x_msg_type              out varchar2,
577     --                                     identify the message type.
578     --                    X_msg_count             out number
579     --                                     count of message
580     --                    X_msg_data              out varchar2
581     --                                     message label
582     -- Calling API      : AP_INVOICE_DISTRIBUTIONS_PKG.insert_from_dist_set
583     --
584     -- End of comments
585     -- ----------------
586 
587 PROCEDURE validate_transaction( x_project_id	        IN            NUMBER,
588 				x_task_id               IN            NUMBER,
589 				x_award_id              IN            NUMBER,
590 				x_expenditure_type      IN            varchar2,
591 				x_expenditure_item_date IN            DATE,
592 				x_calling_sequence      in            VARCHAR2,
593 				x_msg_application       in out nocopy VARCHAR2,
594 				x_msg_type              out nocopy    VARCHAR2,
595 				X_msg_count             OUT nocopy    NUMBER,
596 				X_msg_data              OUT nocopy    VARCHAR2 ) is
597    cursor c1 is
598           select award_id
599             from gms_award_distributions
600            where award_set_id = x_award_id
601              and adl_line_num = 1 ;
602 
603    l_award_id  number ;
604    l_outcome  varchar2(2000) ;
605 
606 begin
607 	open c1 ;
608         fetch c1 into l_award_id ;
609         IF c1%notfound then
610            raise no_data_found ;
611         end if ;
612         close c1 ;
613 
614 
615 	-- ===========================================================================
616 	-- inavlida parameter was passed to p_award_id argument. The correct value
617 	-- should have l_award_id. The previously x_award_id which holds award_set_id
618 	-- was passed.
619 	-- ===========================================================================
620 
621 	gms_transactions_pub.validate_transaction( p_project_id		=> x_project_id,
622 						  p_task_id		=> x_task_id,
623 						  p_award_id		=> l_award_id,
624 						  p_expenditure_type	=> x_expenditure_type,
625 						  P_expenditure_item_date=> x_expenditure_item_date,
626 						  P_calling_module	=> 'TXNVALID',
627 						  p_outcome		=> l_outcome ) ;
628 
629 
630 	IF l_outcome is not null then
631 	   x_msg_type        := 'E' ;
632 	   X_msg_count       := 1 ;
633 	   X_msg_data        := l_outcome ;
634 	   x_msg_application := 'GMS' ;
635 	end if ;
636 
637 EXCEPTION
638     WHEN no_data_found then
639 	 IF c1%isopen  then
640 	    close c1 ;
641          end if ;
642 
643 	 x_msg_type	   := 'E' ;
644 	 X_msg_count	   := 1 ;
645 	 X_msg_data	   := 'GMS_AWARD_REQUIRED' ;
646 	 x_msg_application := 'GMS' ;
647 
648 end validate_transaction ;
649 
650 END GMS_AP_API2;