[Home] [Help]
PACKAGE BODY: APPS.AP_APXAPRVL_XMLP_PKG
Source
1 PACKAGE BODY AP_APXAPRVL_XMLP_PKG AS
2 /* $Header: APXAPRVLB.pls 120.0 2007/12/27 07:13:08 vjaganat noship $ */
3
4 function BeforeReport return boolean is
5 begin
6
7
8
9 DECLARE
10
11 init_failure EXCEPTION;
12
13 BEGIN
14
15
16
17
18 /*SRW.USER_EXIT('FND SRWINIT');*/null;
19
20 IF (p_debug_switch in ('y','Y')) THEN
21 /*SRW.MESSAGE('1','After SRWINIT');*/null;
22
23 END IF;
24
25
26
27 IF (get_company_name <> TRUE) THEN
28 RAISE init_failure;
29 END IF;
30 IF (p_debug_switch in ('y', 'Y')) THEN
31 /*SRW.MESSAGE('2', 'After Get Company Name');*/null;
32
33 END IF;
34
35
36 IF (get_nls_strings <> TRUE) THEN
37 RAISE init_failure;
38 END IF;
39 IF (p_debug_switch in ('y','Y') )THEN
40 /*SRW.MESSAGE('3','After Get NLS Strings');*/null;
41
42 END IF;
43
44
45 IF (get_operating_unit <> TRUE) THEN
46 RAISE init_failure;
47 END IF;
48 IF (p_debug_switch in ('y','Y') )THEN
49 /*SRW.MESSAGE('24','After Get Operating Unit');*/null;
50
51 END IF;
52
53
54 IF (get_user_name <> TRUE) THEN
55 RAISE init_failure;
56 END IF;
57 IF (p_debug_switch in ('y','Y') )THEN
58 /*SRW.MESSAGE('24','After Get User Name');*/null;
59
60 END IF;
61
62
63
64 IF (batch_approval <> TRUE) THEN RAISE init_failure;
65 END IF;
66 IF (p_debug_switch in ('y','Y')) THEN
67 /*SRW.MESSAGE('30','After Batch Validation');*/null;
68
69 END IF;
70
71
72
73
74 IF (p_inv_batch_id IS NOT NULL) THEN
75
76 IF (p_debug_switch in ('y','Y')) THEN
77 /*SRW.MESSAGE('31','After Batch Validation: Get Batch Name');*/null;
78
79 END IF;
80
81 BEGIN
82 SELECT batch_name
83 INTO c_batch_name
84 FROM ap_batches
85 WHERE batch_id = p_inv_batch_id;
86
87 EXCEPTION
88 WHEN NO_DATA_FOUND THEN
89 NULL;
90 END;
91 END IF;
92
93 If (p_invoice_id is Not Null) Then
94
95 IF (p_debug_switch in ('y','Y')) THEN
96 /*SRW.MESSAGE('31','After Batch Validation: Get Invoice Num');*/null;
97
98 END IF;
99
100 Begin
101
102 Select invoice_num
103 into cp_invoice_number
104 from ap_invoices
105 where invoice_id = p_invoice_id;
106
107 Exception
108 When No_data_found Then
109 null;
110 End;
111
112 End If;
113
114
115 If (p_vendor_id IS NOT NULL) Then
116
117 IF (p_debug_switch in ('y','Y')) THEN
118 /*SRW.MESSAGE('31','After Batch Validation: Get Supplier Name');*/null;
119
120 END IF;
121
122 Begin
123 SELECT vendor_name
124 INTO cp_supplier_name
125 FROM po_vendors
126 WHERE vendor_id = p_vendor_id;
127
128 Exception
129 When No_data_found Then
130 null;
131
132 End;
133
134 End If;
135
136
137
138
139
140
141 IF (p_debug_switch in ('y','Y')) THEN
142 /*SRW.BREAK;*/null;
143
144 END IF;
145
146
147
148
149
150
151 RETURN (TRUE);
152
153
154
155 EXCEPTION
156
157 WHEN OTHERS THEN
158
159 /*SRW.MESSAGE('0','When Others:'||SQLERRM);*/null;
160
161
162 RAISE_application_error(-20101,null);/*SRW.PROGRAM_ABORT;*/null;
163
164
165 END;
166 return (TRUE);
167 end;
168
169 function AfterReport return boolean is
170 begin
171
172 BEGIN
173 /*SRW.USER_EXIT('FND SRWEXIT');*/null;
174
175 IF (P_DEBUG_SWITCH = 'Y') THEN
176 /*SRW.MESSAGE('40','After SRWEXIT');*/null;
177
178 END IF;
179 EXCEPTION
180 WHEN OTHERS THEN
181 RAISE_application_error(-20101,null);/*SRW.PROGRAM_ABORT;*/null;
182
183 END; return (TRUE);
184 end;
185
186 FUNCTION batch_approval RETURN BOOLEAN
187 IS
188 BEGIN
189
190 IF (AP_APPROVAL_PKG.BATCH_APPROVAL
191 (p_run_option => P_OPTION,
192 p_sob_id => P_SOB_ID,
193 p_inv_start_date => P_INV_START_DATE,
194 p_inv_end_date => P_INV_END_DATE,
195 p_inv_batch_id => P_INV_BATCH_ID,
196 p_vendor_id => P_VENDOR_ID,
197 p_pay_group => P_PAY_GROUP,
198 p_invoice_id => P_INVOICE_ID,
199 p_entered_by => P_ENTERED_BY,
200 p_debug_switch => P_DEBUG_SWITCH,
201 p_conc_request_id => P_CONC_REQUEST_ID,
202 p_commit_size => P_COMMIT_SIZE,
203 p_org_id => P_ORG_ID,
204 p_report_holds_count => C_REP_COUNT) <> TRUE) THEN
205
206 RETURN FALSE;
207
208 END IF;
209
210 RETURN TRUE;
211
212 EXCEPTION
213 WHEN OTHERS THEN
214 /*SRW.MESSAGE('101','Error occured in BATCH_APPROVAL()');*/null;
215
216 /*SRW.MESSAGE('102','Error Code : '||SQLCODE);*/null;
217
218 /*SRW.MESSAGE('103','Error Message : '||SQLERRM);*/null;
219
220 RETURN FALSE;
221 END;
222
223 FUNCTION GET_COMPANY_NAME RETURN BOOLEAN IS
224 c_name VARCHAR2(30);
225 BEGIN
226
227 null;
228
229
230
231 c_company_name := c_name;
232 RETURN (TRUE);
233
234 RETURN NULL; EXCEPTION
235
236 WHEN OTHERS THEN
237 RETURN (FALSE);
238
239 END;
240
241 FUNCTION get_nls_strings RETURN BOOLEAN IS
242
243 BEGIN
244
245 /*SRW.USER_EXIT('FND MESSAGE_NAME APPL="SQLAP" NAME="AP_APPRVL_NO_HOLDS_RELEASES"');*/null;
246
247 /*SRW.USER_EXIT('FND MESSAGE_GET OUTPUT_FIELD=":c_nls_no_data_exists"');*/null;
248
249 c_nls_no_data_exists := '*** '||c_nls_no_data_exists||' ***';
250
251 /*SRW.USER_EXIT('FND MESSAGE_NAME APPL="SQLAP" NAME="AP_ALL_END_OF_REPORT"');*/null;
252
253 /*SRW.USER_EXIT('FND MESSAGE_GET OUTPUT_FIELD=":c_nls_end_of_report"');*/null;
254
255 c_nls_end_of_report := '*** '||c_nls_end_of_report||' ***';
256
257 RETURN (TRUE);
258
259 RETURN NULL; EXCEPTION
260 WHEN OTHERS THEN
261 RETURN (FALSE);
262 END;
263
264 function validate_period (p_invoice_id in number) return boolean is
265 CURSOR get_gl_date IS
266 SELECT distinct accounting_date acc_date
267 FROM ap_invoice_distributions
268 WHERE invoice_id = p_invoice_id
269 and NVL(match_status_flag,'N') = 'N';
270 CURSOR get_inv_source IS
271 SELECT upper(nvl(source, 'X'))
272 FROM ap_invoices
273 WHERE invoice_id = p_invoice_id;
274
275 l_source ap_invoices.source%TYPE;
276 BEGIN
277 OPEN get_inv_source;
278 FETCH get_inv_source INTO l_source;
279 CLOSE get_inv_source;
280 IF l_source <> 'RECURRING INVOICE' THEN
281 return true;
282 END IF;
283
284 FOR gl_date IN get_gl_date LOOP
285 IF ap_utilities_pkg.get_current_gl_date(gl_date.acc_date) is null THEN
286 return false;
287
288
289 END IF;
290 END LOOP;
291 return true;
292
293 END;
294
295 FUNCTION GET_OPERATING_UNIT RETURN BOOLEAN IS
296
297 l_operating_unit varchar2(240);
298
299 BEGIN
300 IF p_org_id is not NULL THEN
301 l_operating_unit := substrb(mo_global.get_ou_name(P_ORG_ID),1, 240);
302 cp_operating_unit := l_operating_unit;
303 ELSE
304 null;
305 END IF;
306 RETURN (TRUE);
307 RETURN (NULL);
308 Exception
309 When Others then
310 return (FALSE);
311 End;
312
313 FUNCTION GET_USER_NAME RETURN BOOLEAN IS
314
315 l_user_name varchar2(240);
316
317 BEGIN
318
319 IF p_entered_by is not NULL THEN
320
321 Select user_name
322 Into l_user_name
323 From fnd_user
324 Where user_id = p_entered_by;
325
326 cp_user_name := l_user_name;
327
328 ELSE
329 null;
330 END IF;
331
332 RETURN (TRUE);
333 RETURN (NULL);
334 Exception
335 When Others then
336 return (FALSE);
337 End;
338
339 --Functions to refer Oracle report placeholders--
340
341 Function CP_sob_name_p return varchar2 is
342 Begin
343 return CP_sob_name;
344 END;
345 Function C_COMPANY_NAME_p return varchar2 is
346 Begin
347 return C_COMPANY_NAME;
348 END;
349 Function c_nls_no_data_exists_p return varchar2 is
350 Begin
351 return c_nls_no_data_exists;
352 END;
353 Function c_nls_end_of_report_p return varchar2 is
354 Begin
355 return c_nls_end_of_report;
356 END;
357 Function C_rep_count_p return number is
358 Begin
359 return C_rep_count;
360 END;
361 Function CP_Invoice_Number_p return varchar2 is
362 Begin
363 return CP_Invoice_Number;
364 END;
365 Function CP_SUPPLIER_NAME_p return varchar2 is
366 Begin
367 return CP_SUPPLIER_NAME;
368 END;
369 Function C_batch_name_p return varchar2 is
370 Begin
371 return C_batch_name;
372 END;
373 Function CP_OPERATING_UNIT_p return varchar2 is
374 Begin
375 return CP_OPERATING_UNIT;
376 END;
377 Function CP_USER_NAME_p return varchar2 is
378 Begin
379 return CP_USER_NAME;
380 END;
381 END AP_APXAPRVL_XMLP_PKG ;
382