DBA Data[Home] [Help]

PACKAGE BODY: APPS.FV_FEDERAL_PAYMENT_FIELDS_PKG

Source


1 PACKAGE BODY FV_FEDERAL_PAYMENT_FIELDS_PKG AS
2 /* $Header: FVIBYPFB.pls 120.13 2006/11/07 21:31:27 dsadhukh noship $ */
3 
4 -- Declaring a global variable for the package name
5 G_PKG_NAME CONSTANT VARCHAR2(30):='FV_FEDERAL_PAYMENT_FIELDS_PKG';
6 
7 
8 -- --------------------------------------------------------------------------
9 --                    Payment instruction level functions
10 -- --------------------------------------------------------------------------
11 --      The following functions take the payment instruction ID as an input
12 --      and return Federal specific attributes needed in the Federal payment
13 --      formats at the payment instruction (header) level.
14 -- --------------------------------------------------------------------------
15 
16 -- --------------------------------------------------------------------------
17 --         Federal Employee Identification Number
18 -- --------------------------------------------------------------------------
19 --      This function will return the Federal Employee Identification
20 --      Number from fv_operating_units.
21 --
22 -- --------------------------------------------------------------------------
23 FUNCTION get_FEIN (p_payment_instruction_id IN number) return VARCHAR2 is
24 
25 	    l_fed_employer_number 	fv_operating_units_all.fed_employer_id_number%TYPE;
26 
27         BEGIN
28 		if (NOT fv_install.enabled) then
29 		       return null;
30 		end if;
31 
32 	    select fed_employer_id_number
33 	   	into l_fed_employer_number
34 	   	from fv_operating_units_all foua,
35 	             iby_pay_instructions_all ipia
36 	   	where ipia.payment_instruction_id = p_payment_instruction_id
37 	   	and   ipia.org_id = foua.org_id;
38 
39 	        return l_fed_employer_number;
40 	   EXCEPTION
41 	        when others then
42 	             return null;
43 	   END get_FEIN;
44 
45 
46 -- --------------------------------------------------------------------------
47 --         Abbreviated Agency Code
48 -- --------------------------------------------------------------------------
49 --      This function will return the Abbreviated Agency Code from profile
50 --      FV_AGENCY_ID_ABBREVIATION
51 --
52 -- --------------------------------------------------------------------------
53 
54 FUNCTION get_Abbreviated_Agency_Code (p_payment_instruction_id IN number)
55             return VARCHAR2 IS
56 
57          v_abbr_agency_code VARCHAR2(30);
58   BEGIN
59    if (NOT fv_install.enabled) then
60    return null;
61    end if;
62 
63    v_abbr_agency_code := FND_PROFILE.VALUE('FV_AGENCY_ID_ABBREVIATION');
64 
65    return v_abbr_agency_code;
66 
67    EXCEPTION
68    when others then
69    return null;
70   END get_abbreviated_agency_code;
71 
72 -- --------------------------------------------------------------------------
73 --                    Payment level functions
74 -- --------------------------------------------------------------------------
75 --      The following functions take the payment ID as an input and return
76 --      Federal specific attributes needed in the Federal payment formats
77 --      at the payment level.
78 -- --------------------------------------------------------------------------
79 
80 -- --------------------------------------------------------------------------
81 --                   Allotment Code
82 -- --------------------------------------------------------------------------
83 --      This function will return the allotment code.  This function will
84 --      return the allotment code for use in SPS PPD/PPD+ formats only.
85 --      This function will return a 'N' or null value.
86 -- --------------------------------------------------------------------------
87 
88   FUNCTION get_Allotment_Code (p_payment_id IN number) return VARCHAR2 is
89         l_payment_reason_code 	iby_payments_all.payment_reason_code%TYPE;
90   BEGIN
91 
92    if (NOT fv_install.enabled) then
93    return null;
94    end if;
95 
96 
97    select payment_reason_code
98    into l_payment_reason_code
99    from iby_payments_all
100    where payment_id = p_payment_id;
101 
102    if (l_payment_reason_code = 'US_FV_S') then
103    return 'N';
104    else
105    return '';
106    end if;
107 
108    EXCEPTION
109    when others then
110    return null;
111 
112   END get_allotment_code;
113 
114 -- --------------------------------------------------------------------------
115 --      TOP Offset Eligibility Flag
116 -- --------------------------------------------------------------------------
117 --      This function will return the TOP Offset Eligibility flag.  A value
118 --      of 'Y' or 'N' will be returned.
119 -- --------------------------------------------------------------------------
120 
121 FUNCTION TOP_Offset_Eligibility_Flag (p_payment_id IN number) return VARCHAR2
122  IS
123 
124 
125         l_payment_reason_code 	iby_payments_all.payment_reason_code%TYPE;
126         l_payment_date 		iby_payments_all.payment_date%TYPE;
127         l_org_id		iby_payments_all.org_id%TYPE;
128         l_ledger_id             gl_ledgers.ledger_id%TYPE;
129         l_ledger_name           gl_ledgers.name%TYPE;
130         l_coa			gl_ledgers.chart_of_accounts_id%TYPE;
131         l_delimiter   		VARCHAR2(1);
132         l_vendor_id             ap_suppliers.vendor_id%TYPE;
133         l_vendor_type           ap_suppliers.vendor_type_lookup_code%TYPE;
134         l_vendor_site_id        ap_invoices_all.vendor_site_id%TYPE;
135         l_offset_flag 		varchar2(1);
136 	l_acc_dist_tbl     	Fnd_Flex_Ext.segmentarray;
137   	l_fv_low_tbl	     	Fnd_Flex_Ext.segmentarray;
138   	l_fv_high_tbl	     	Fnd_Flex_Ext.segmentarray;
139   	l_breakup_seg		NUMBER;
140   	l_segment_nos		NUMBER;
141   	l_get_segments_flag   	BOOLEAN;
142   	l_ctr			NUMBER;
143 
144 
145         CURSOR offset_exclusion_csr(p_sob_id_csr 	        NUMBER
146   			     	   ,p_payment_reason_csr 	VARCHAR2
147   			           ,p_vendor_type_csr		VARCHAR2
148   			           ,p_vendor_id_csr		NUMBER
149   			           ,p_vendor_site_id_csr	NUMBER
150   			           ,p_payment_date_csr		DATE)
151   	IS
152   	SELECT '1'
153   	FROM   FV_TOP_EXCLUSION_CRITERIA_ALL FVTOPEC
154   	WHERE  FVTOPEC.set_of_books_id 	= p_sob_id_csr
155   	AND   (FVTOPEC.payment_reason_code  	= NVL(p_payment_reason_csr,'-999')
156   		OR FVTOPEC.vendor_type_code	= NVL(p_vendor_type_csr,'-999')
157   		OR (FVTOPEC.vendor_id		= p_vendor_id_csr
158   		   AND (FVTOPEC.vendor_site_id  	= p_vendor_site_id_csr
159   			OR FVTOPEC.vendor_site_code   = 'ALL')))
160   	AND (NVL(FVTOPEC.effective_start_date ,p_payment_date_csr) <= p_payment_date_csr
161   	AND NVL(FVTOPEC.effective_end_date ,p_payment_date_csr) >= p_payment_date_csr);
162 
163 
164         CURSOR invoice_dist_csr
165         IS
166         SELECT DISTINCT aid.dist_code_combination_id
167         FROM  iby_payments_all ipa,
168               iby_docs_payable_all idpa,
169               ap_invoice_distributions aid
170         WHERE ipa.payment_id = p_payment_id
171         and   ipa.payment_id = idpa.payment_id
172         and   idpa.calling_app_id = 200
173         and   idpa.document_type = 'INVOICE'
174         and   idpa.calling_app_doc_unique_ref2 = aid.invoice_id;
175 
176 
177         CURSOR accounts_criteria_csr(p_payment_date_csr DATE
178   			            ,p_sob_id_csr     NUMBER)
179   	IS
180   	SELECT concatenated_segments_low , concatenated_segments_high
181   	FROM   fv_top_exclusion_criteria
182   	WHERE  (concatenated_segments_low IS NOT NULL
183   	AND    concatenated_segments_high IS NOT NULL )
184   	AND    set_of_books_id = p_sob_id_csr
185   	AND    NVL(effective_start_date ,p_payment_date_csr) <= p_payment_date_csr
186   	AND    NVL(effective_end_date   ,p_payment_date_csr) >= p_payment_date_csr ;
187 
188 
189         invoice_dist_rec 	invoice_dist_csr%ROWTYPE ;
190         accounts_criteria_rec 	accounts_criteria_csr%ROWTYPE ;
191 	offset_exclusion_rec 	varchar2(1);
192 
193 
194 	BEGIN
195 
196             if (NOT fv_install.enabled) then
197 	       return null;
198     	    end if;
199 
200 
201         -- get the required data from payment_id
202 
203         select payment_reason_code, payment_date, org_id
204         into l_payment_reason_code, l_payment_date, l_org_id
205         from iby_payments_all
206         where payment_id = p_payment_id;
207 
208         mo_utils.get_Ledger_Info
209   		(p_operating_unit     	=>    l_org_id,
210 		 p_ledger_id 		=>    l_ledger_id,
211 	 	 p_ledger_name     	=>    l_ledger_name);
212 
213 
214 
215         select chart_of_accounts_id
216         into l_coa
217         from gl_ledgers
218         where ledger_id = l_ledger_id;
219 
220 
221         l_delimiter := fnd_flex_ext.get_delimiter('SQLGL'
222   					         ,'GL#'
223 					         ,l_coa);
224 
225 
226         select aia.vendor_id, aia.vendor_site_id, aps.vendor_type_lookup_code
227         into l_vendor_id, l_vendor_site_id, l_vendor_type
228         from iby_payments_all ipa,
229              iby_docs_payable_all idpa,
230              ap_invoices_all aia,
231              ap_suppliers aps
232         where ipa.payment_id = p_payment_id
233         and   ipa.payment_id = idpa.payment_id
234         and   idpa.calling_app_id = 200
235         and   idpa.document_type = 'STANDARD'
236         and   idpa.calling_app_doc_unique_ref2 = aia.invoice_id
237         and   aia.vendor_id = aps.vendor_id
238         and   rownum < 2;
239 
240    -- initialize l_offset_flag
241    l_offset_flag := 'Y';
242 
243    OPEN 	offset_exclusion_csr(l_ledger_id
244   				    ,l_payment_reason_code
245   				    ,l_vendor_type
246   				    ,l_vendor_id
247   				    ,l_vendor_site_id
248   				    ,l_payment_date) ;
249 
250    FETCH offset_exclusion_csr INTO offset_exclusion_rec;
251 
252    IF offset_exclusion_csr%FOUND THEN
253       l_offset_flag := 'N' ;
254       RETURN l_offset_flag;
255    END IF ;
256 
257    CLOSE offset_exclusion_csr ;
258 
259    -- check excluded accounts in fv_top_exclusion_criteria table
260 
261   OPEN invoice_dist_csr;
262   LOOP
263     FETCH invoice_dist_csr  INTO  invoice_dist_rec ;
264     EXIT WHEN invoice_dist_csr%NOTFOUND ;
265 
266 
267 
268      /*Determining the segment values and storing in a pl/sql table
269        l_acc_dist_tbl*/
270     l_get_segments_flag := fnd_flex_ext.get_segments
271     		    (application_short_name =>'SQLGL'
272 			   	,key_flex_code    => 'GL#'
273 			   	,structure_number => l_coa
274 			   	,combination_id   =>
275 			   	invoice_dist_rec.dist_code_combination_id
276 				,n_segments       => l_segment_nos
277 				,segments         => l_acc_dist_tbl) ;
278 
279     OPEN accounts_criteria_csr(l_payment_date, l_ledger_id) ;
280     LOOP
281       FETCH accounts_criteria_csr INTO accounts_criteria_rec ;
282       EXIT WHEN accounts_criteria_csr%NOTFOUND ;
283       /*Determining the segment values and storing in a pl/sql table
284        l_fv_low_tbl , l_fv_high_tbl based on the value in
285        CONCATENATED_SEGMENTS_LOW , CONCATENATED_SEGMENTS_HIGH    */
286 
287       l_breakup_seg := fnd_flex_ext.breakup_segments
288       	            (accounts_criteria_rec.CONCATENATED_SEGMENTS_LOW
289 					         ,l_delimiter
290 					         ,l_fv_low_tbl ) ;
291       l_breakup_seg := fnd_flex_ext.breakup_segments
292                     (accounts_criteria_rec.CONCATENATED_SEGMENTS_HIGH
293 						   ,l_delimiter
294 						   ,l_fv_high_tbl ) ;
295       l_ctr := 0 ;
296       IF (l_fv_low_tbl.COUNT <> 0 OR l_fv_high_tbl.COUNT <> 0 ) THEN
297 
298 	  FOR  i IN 1..l_acc_dist_tbl.COUNT
299 	  LOOP
300 	     IF
301 	        (l_acc_dist_tbl(i) >= NVL(l_fv_low_tbl(i) , l_acc_dist_tbl(i))
302 	        AND
303 	        l_acc_dist_tbl(i) <= NVL(l_fv_high_tbl(i) , l_acc_dist_tbl(i)) )
304 	        THEN
305                 l_ctr := l_ctr + 1 ;
306              ELSE
307                   EXIT;
308 	     END IF;
309           END LOOP;
310 
311           IF l_ctr = l_acc_dist_tbl.COUNT THEN
312 	      l_offset_flag := 'N' ;
313               RETURN l_offset_flag;
314           END IF ;
315 
316       END IF ;
317     END LOOP ;
318     /*  Check if no row exists for Accounting Criteria
319     Then close all cusrsor and Exit*/
320 
321     IF accounts_criteria_csr%ROWCOUNT = 0 THEN
322       CLOSE accounts_criteria_csr ;
323       EXIT ;
324     END IF ;
325     CLOSE accounts_criteria_csr ;
326 
327   END LOOP ;
328   CLOSE invoice_dist_csr ;
329 
330     RETURN l_offset_flag;
331 
332     EXCEPTION
333           when others then
334              return null;
335 END TOP_Offset_Eligibility_Flag;
336 
337 -- --------------------------------------------------------------------------
338 --    Payment Instruction Sequence Number
339 -- --------------------------------------------------------------------------
340 --    This function would accept org_id and payment_reason_code as input
341 --    parameters and output the sequence number for a payment Instruction.
342 -- --------------------------------------------------------------------------
343 
344 	FUNCTION GET_PAY_INSTR_SEQ_NUM (	p_org_id		in	number,
345 	 				p_payment_reason_code	in	varchar2)
346 	RETURN VARCHAR2
347 	IS
348 	  l_nextseq  		Fv_Pb_Seq_Assignments_All.next_seq_value%TYPE;
349 	  l_finalseq 		Fv_Pb_Seq_Assignments_All.next_seq_value%TYPE;
350 	  l_prefix   		Fv_Pb_Seq_Assignments_All.prefix%TYPE;
351 	  l_suffix   		Fv_Pb_Seq_Assignments_All.suffix%TYPE;
352 	  l_seq_assignment_id 	Fv_Pb_Seq_Assignments_All.seq_assignment_id%TYPE;
353 	  l_instruction_name 	iby_pay_instructions_all.pay_admin_assigned_ref_code%TYPE;
354 	  l_count    		NUMBER;
355 	  l_pi_count 		NUMBER;
356 	  l_module		varchar2(200)	:= G_PKG_NAME || '.GET_PAY_INSTR_SEQ_NUM';
357           l_message  	        VARCHAR2(1000);
358 
359           CURSOR assign_nextseq_cur(p_org_id_csr number) IS
360           SELECT seq_assignment_id, initial_seq_value, org_id
361 	  FROM Fv_Pb_Seq_Assignments_all FPSA
362 	  WHERE FPSA.org_id = p_org_id_csr
363           AND FPSA.next_seq_value IS NULL;
364 	BEGIN
365 
366           -- if Federal is not enabled return null
367 	   if (NOT fv_install.enabled) then
368                 l_message := 'FV: Federal Enabled profile is not turned on';
369                 log_error_messages(FND_LOG.LEVEL_STATEMENT, l_module, l_message);
370 	        return null;
371 	   end if;
372 
373 	   -- if Sequential Numbering is not turned on then return null
374 	   if (fnd_profile.value ('FV_PB_SEQ_NUMBERING') <> 'Y') then
375                 l_message := 'FV: Enable Automatic Numbering profile is not turned on';
376                 log_error_messages(FND_LOG.LEVEL_STATEMENT, l_module, l_message);
377 	        return null;
378 	   end if;
379 
380 	  -- Set the next sequence number for all the assignments in the table
381 	  -- where next_seq_value IS NULL
382 
383 	  FOR c_assign IN assign_nextseq_cur(p_org_id)
384           LOOP
385               UPDATE Fv_Pb_Seq_Assignments_all
386 	      SET next_seq_value = c_assign.initial_seq_value
387 	      WHERE org_id=c_assign.org_id
388               AND seq_assignment_id = c_assign.seq_assignment_id;
389 
390 	  END LOOP;
391 
392 
393           BEGIN
394 	  	-- Get the sequence information
395 	  	SELECT next_seq_value, final_seq_value, prefix, suffix, seq_assignment_id
396 	  	INTO l_nextseq, l_finalseq, l_prefix, l_suffix, l_seq_assignment_id
397 	  	FROM Fv_Pb_Seq_Assignments_all
398 	  	WHERE payment_reason_code = p_payment_reason_code
399 	  	AND     org_id = p_org_id
400 	  	AND TRUNC(SYSDATE) BETWEEN TRUNC(start_date) AND NVL(TRUNC(end_date),TRUNC(SYSDATE));
401           EXCEPTION
402              WHEN NO_DATA_FOUND THEN
403                 l_message := 'Payment Instruction Sequence Assignment not set for org_id = ' || p_org_id || ' and payment_reason_code ' || p_payment_reason_code;
404                 log_error_messages(FND_LOG.LEVEL_STATEMENT, l_module, l_message);
405 	        return null;
406           END;
407 
408 
409 	  -- Check if the next seq number exceeds the final number, as long as the
410 	  -- final number is not null. If it is null, then continue with the code.
411 	  if ((l_finalseq IS NOT NULL) AND (l_nextseq > l_finalseq)) THEN
412 	       return null;
413 	  end if;
414 	  -- Assign the payment batch name
415 	  l_instruction_name := l_prefix || l_nextseq || l_suffix;
416 	  -- Check for Uniqueness
417 	  LOOP
418 	  SELECT COUNT(*)
419 	  INTO l_pi_count
420 	  FROM iby_pay_instructions_all
421 	  WHERE org_id = p_org_id
422 	  AND pay_admin_assigned_ref_code = l_instruction_name;
423 
424            IF (l_pi_count = 0) THEN
425 	     EXIT;
426            ELSE
427 	     l_nextseq := l_nextseq + 1;
428              -- Check if the next seq number exceeds the final number
429              IF ((l_finalseq IS NOT NULL) AND (l_nextseq > l_finalseq)) THEN
430                 l_message := 'Maximum sequence number reached - returning NULL ...';
431                 log_error_messages(FND_LOG.LEVEL_STATEMENT, l_module, l_message);
432 	        return null;
433 	     END IF;
434             -- Assign the payment instruction name
435 	    l_instruction_name := l_prefix || l_nextseq || l_suffix;
436 	   END IF;
437           END LOOP;
438 
439           -- update table with next sequence to be used
440           l_nextseq := l_nextseq + 1;
441           update fv_pb_seq_assignments_all
442           set next_seq_value = l_nextseq
443           where seq_assignment_id = l_seq_assignment_id;
444           return l_instruction_name;
445       	EXCEPTION
446 	   WHEN OTHERS THEN
447               l_message := SQLERRM;
448               log_error_messages(FND_LOG.LEVEL_STATEMENT, l_module, l_message);
449 	      return null;
450 	END GET_PAY_INSTR_SEQ_NUM;
451 
452 -- --------------------------------------------------------------------------
453 
454 
455 -- --------------------------------------------------------------------------
456 --      Summary_Format_Prog_completed
457 -- --------------------------------------------------------------------------
458 --    This API will be called from IBY when the summary formats have completed
459 --    and will tell us the status of the payment instruction.  If the
460 --    payment instruction has completed successfully then the column
461 --    summary_schedule_flage in table fv_summary_consolidate_all will be
462 --    updated.
463 -- -------------------------------------------------------------------------
464 PROCEDURE Summary_Format_Prog_Completed
465 (p_api_version IN number,
466  p_init_msg_list IN varchar2,
467  p_commit IN varchar2,
468  x_return_status OUT NOCOPY  varchar2,
469  x_msg_count OUT  NOCOPY number,
470  x_msg_data OUT  NOCOPY varchar2,
471  p_payment_instruction_id IN number,
472  p_format_complete_status IN varchar2)
473 IS
474 BEGIN
475 
476  x_return_status :='S';
477  x_msg_data := null;
478  x_msg_count := 0;
479 
480 IF Fnd_Api.To_Boolean(p_init_msg_list) THEN
481 	         		Fnd_Msg_Pub.Initialize;
482 END IF;
483 
484 x_return_status :=Fnd_Api.G_Ret_Sts_Success;
485 x_msg_data := null;
486 x_msg_count := 0;
487 
488 IF (fv_install.enabled) AND (p_format_complete_status = 'SUMMARY_FORMAT_SUCCESS')  THEN
489 
490 			Update fv_summary_consolidate_all
491 			Set summary_schedule_flag = 'Y'
492 			Where payment_instruction_id = p_payment_instruction_id;
493 END IF;
494 
495 IF Fnd_Api.To_Boolean(p_commit) THEN
496 	         		COMMIT;
497 END IF;
498 
499 EXCEPTION
500   WHEN others THEN
501 	       		 x_return_status := Fnd_Api.G_Ret_Sts_Unexp_Error;
502 	        		Fnd_Msg_Pub.Add_Exc_Msg(
503 	            				p_pkg_name       => 'FV_FEDERAL_PAYMENT_FIELDS_PKG',
504 	           	 			p_procedure_name => 'SUMMARY_FORMAT_PROG_COMPLETED');
505 	         		Fnd_Msg_Pub.Count_And_Get(
506 	            				p_encoded => Fnd_Api.G_False,
507 	            				p_count   => x_msg_count,
508 	            				p_data    => x_msg_data);
509 
510 
511 END;
512 
513 -- ------------------------------------------------------------------------------
514 --        Submit Payment Instruction Treasury Symbol Listing Report
515 -- ------------------------------------------------------------------------------
516 --    This procedure will accept the payment_instruction_id and will submit the
517 --    Payment Instruction Treasury Symbol Listing Report as a concurrent program.
518 -- ------------------------------------------------------------------------------
519 
520 PROCEDURE submit_pay_instr_ts_report ( p_init_msg_list          IN         varchar2,
521                                        p_payment_instruction_id IN         number,
522 				       x_request_id             OUT NOCOPY number,
523 				       x_return_status          OUT NOCOPY varchar2,
524                                        x_msg_count              OUT NOCOPY number,
525 				       x_msg_data		OUT NOCOPY varchar2)
526 IS
527 l_api_name CONSTANT varchar2(30) := 'submit_pay_instr_ts_report';
528 l_org_id NUMBER;
529 BEGIN
530     IF FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) THEN
531         FND_MSG_PUB.initialize;
532     END IF;
533 
534     x_return_status := FND_API.G_RET_STS_SUCCESS;
535     x_msg_count     := 0;
536     x_msg_data      := NULL;
537     l_org_id        := MO_GLOBAL.get_current_org_id;
538 
539     IF (fv_install.enabled) THEN
540         fnd_request.set_org_id(l_org_id);
541         x_request_id := FND_REQUEST.submit_request('FV','FVIBYTSL',NULL,NULL,FALSE,p_payment_instruction_id);
542 
543         IF (x_request_id = 0) THEN
544             x_return_status := FND_API.G_RET_STS_ERROR;
545             FND_MESSAGE.set_name('FV', 'FV_TSL_REQUEST_FAILED');
546             FND_MSG_PUB.add;
547         ELSE
548             FND_MESSAGE.set_name('FV', 'FV_TSL_REQUEST_SUBMITTED');
549             FND_MESSAGE.set_token('REQUEST_ID',x_request_id);
550             FND_MSG_PUB.add;
551         END IF;
552 
553     END IF;
554 
555     FND_MSG_PUB.count_and_get( p_count => x_msg_count,
556                                p_data  => x_msg_data );
557 EXCEPTION
558     WHEN OTHERS THEN
559         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
560         FND_MSG_PUB.add_exc_msg( G_PKG_NAME,
561                                  l_api_name );
562         FND_MSG_PUB.count_and_get( p_count => x_msg_count,
563                                    p_data  => x_msg_data );
564 END submit_pay_instr_ts_report;
565 
566 ---------------------------------------------------------------------------
567 --	 submit_cash_pos_report
568 ---------------------------------------------------------------------------
569 -- This Procedure takes the org_id and checkrun_id as input parameters and
570 -- submits the cash position detail report.
571 ---------------------------------------------------------------------------
572 
573  PROCEDURE submit_cash_pos_report(
574 			p_init_msg_list		in		varchar2,
575             p_org_id		in		number,
576            	p_checkrun_id		in		number,
577            	x_request_id		out	nocopy	number,
578             x_return_status		out	nocopy  varchar2,
579 			x_msg_count		out	nocopy  number,
580 			x_msg_data		out	nocopy  varchar2) is
581 
582 l_api_name CONSTANT varchar2(30) := 'submit_cash_pos_report';
583 
584 	begin
585 		IF FND_API.to_Boolean( nvl(p_init_msg_list,FND_API.G_FALSE) ) THEN
586 			FND_MSG_PUB.initialize;
587 		END IF;
588 
589 	        	x_return_status := FND_API.G_RET_STS_SUCCESS;
590 	        	x_msg_count := 0;
591 		x_msg_data := null;
592 		if ((fv_install.enabled) AND (FND_PROFILE.VALUE('FV_ENABLE_CASH_POSITION_DETAIL_OPTION') = 'Y')) then
593 
594 	x_request_id := FND_REQUEST.SUBMIT_REQUEST('FV', 'FVAPCPDP', NULL, NULL, FALSE,p_checkrun_id,p_org_id);
595 
596                 		if (x_request_id = 0) then
597 	                  		x_return_status := FND_API.G_RET_STS_ERROR ;
598 	            		end if;
599 		end if;
600 	        FND_MSG_PUB.Count_And_Get
601 		(
602 			p_count         	=>      x_msg_count,
603 	        		p_data          	=>      x_msg_data
604 	 	);
605 	exception
606 		when others then
607 		       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
608 		       FND_MSG_PUB.Add_Exc_Msg
609 		    	    (	G_PKG_NAME,
610 		    	    	l_api_name
611 			    );
612 
613 		       FND_MSG_PUB.Count_And_Get
614 		    	    (  	p_count         	=>      x_msg_count,
615 		        		p_data          	=>      x_msg_data
616 		    	    );
617 	end submit_cash_pos_report;
618 
619 ----------------------------------------------------------------------------------------------------------
620        PROCEDURE LOG_ERROR_MESSAGES
621         (
622             p_level   IN NUMBER,
623             p_module  IN VARCHAR2,
624             p_message IN VARCHAR2
625         ) IS
626 
627         BEGIN
628 
629              IF (p_level >= fnd_log.g_current_runtime_level) THEN
630                       fnd_log.string (p_level, p_module, p_message);
631              END IF;
632 
633              -- log messages only if concurrent program
634              IF (FND_GLOBAL.conc_request_id <> -1) THEN
635                    FND_FILE.PUT_LINE(FND_FILE.LOG, p_module || ': ' || p_message);
636              END IF;
637 
638         END LOG_ERROR_MESSAGES;
639 
640 END fv_federal_payment_fields_pkg;