DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_BILLING_SETUP_PUB

Source


1 PACKAGE BODY PA_BILLING_SETUP_PUB AS
2 /* $Header: PABLSTPB.pls 120.3 2005/08/19 16:16:42 mwasowic noship $ */
3 
4    G_PKG_NAME       VARCHAR2(30) := 'PA_BILLING_SETUP_PUB';
5 
6 -- API name                      : update_revenue_and_billing
7 -- Type                          : Public procedure
8 -- Pre-reqs                      : None
9 -- Return Value                  : N/A
10 -- Prameters
11 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
12 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
13 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
14 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
15 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
16 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
17 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
18 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
19 -- p_project_id	         	 IN	 NUMBER     REQUIRED
20 -- p_distribution_rule         IN    VARCHAR2   REQUIRED
21 -- p_billing_cycle_id          IN    NUMBER     REQUIRED
22 -- p_first_bill_offset         IN    NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
23 -- p_next_billing_date         IN    DATE       OPTIONAL
24 -- p_output_tax_code           IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CHAR
25 -- p_billing_job_group_id         IN    NUMBER   REQUIRED
26 -- p_invoice_comment           IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CHAR
27 -- p_labor_id                     IN    NUMBER   REQUIRED
28 -- p_non_labor_id                 IN    NUMBER   OPTIONAL
29 -- p_retention_inv_format_id   IN    VARCHAR2   OPTIONAL
30 -- p_retention_inv_format_name IN    VARCHAR2   OPTIONAL
31 -- p_retention_percent         IN    NUMBER     OPTIONAL
32 -- p_retention_output_tax_code IN    VARCHAR2   OPTIONAL
33 -- p_record_version_number	 IN	 NUMBER     REQUIRED   DEFAULT=1
34 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
35 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
36 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
37 --
38 --  History
39 --
40 --  25-MAY-01   Majid Ansari             -Created
41 --
42 --
43 
44  PROCEDURE  update_revenue_and_billing(
45  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
46  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
47  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
48  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
49  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
50  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
51  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
52  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
53  p_project_id	       IN	 NUMBER    ,
54  p_distribution_rule         IN    VARCHAR2   ,
55  p_billing_cycle_id          IN    NUMBER   ,
56  p_first_bill_offset         IN    NUMBER     DEFAULT FND_API.G_MISS_NUM,
57  p_next_billing_date         OUT    NOCOPY DATE       , --File.Sql.39 bug 4440895
58  p_output_tax_code           IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
59  p_billing_job_group_id         IN    NUMBER   ,
60  p_invoice_comment           IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
61  p_labor_id                     IN    NUMBER   ,
62  p_non_labor_id                 IN    NUMBER   ,
63  p_retention_inv_format_id   IN    VARCHAR2   ,
64  p_retention_inv_format_name IN    VARCHAR2   ,
65  p_retention_percent         IN    NUMBER     ,
66  p_retention_output_tax_code IN    VARCHAR2   ,
67  p_record_version_number	 IN	 NUMBER     DEFAULT 1,
68  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
69  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
70  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
71  ) IS
72 
73   CURSOR cur_projects_all
74   IS
75     SELECT start_date
76       FROM pa_projects_all
77      WHERE project_id = p_project_id;
78 
79   l_api_name                CONSTANT VARCHAR(30) := 'update_revenue_and_billing';
80   l_api_version             CONSTANT NUMBER      := 1.0;
81 
82   l_return_status                    VARCHAR2(1);
83   l_msg_data                         VARCHAR2(250);
84   l_msg_count                        NUMBER;
85 
86   l_dummy_char                       VARCHAR2(1);
87   l_error_msg_code                   VARCHAR2(250);
88   l_data                             VARCHAR2(250);
89   l_msg_index_out                    NUMBER;
90 
91   l_task_id                         NUMBER;
92   l_first_bill_offset               NUMBER;
93   l_next_billing_date               DATE;
94   l_output_tax_code                 VARCHAR2(50);
95   l_invoice_comment                 VARCHAR2(240);
96   l_retention_inv_format_id         NUMBER(15);
97   l_retention_percent               PA_PROJECTS_ALL.RETENTION_PERCENTAGE%TYPE;
98   l_retention_output_tax_code       VARCHAR2(50);
99   l_start_date                      DATE;
100 
101 BEGIN
102    -- Standard call to check for call compatibility
103 
104    IF (p_debug_mode = 'Y')
105    THEN
106        pa_debug.debug('Update Revenue and Bill Info PUB : Checking the api version number.');
107    END IF;
108 
109    IF p_commit = FND_API.G_TRUE
110    THEN
111       SAVEPOINT revenue_and_billing;
112    END IF;
113 
114    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
115                                       p_api_version,
116                                       l_api_name,
117                                       g_pkg_name)
118    THEN
119       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
120    END IF;
121 
122    if (p_debug_mode = 'Y') then
123        pa_debug.debug('Update Revenue and Bill Info PUB : Initializing message stack.');
124    end if;
125 
126    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.update_revenue_and_billing');
127 
128    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
129       fnd_msg_pub.initialize;
130    end if;
131 
132    x_return_status := 'S';
133 
134    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
135    THEN
136       --Assign null to the variables that are passed as G_MISS....
137 
138       IF  p_first_bill_offset  = FND_API.G_MISS_NUM
139       THEN
140           l_first_bill_offset := null;
141       ELSE
142           l_first_bill_offset := p_first_bill_offset;
143       END IF;
144 
145       IF p_next_billing_date = FND_API.G_MISS_DATE
146       THEN
147          l_next_billing_date := null;
148       ELSE
149          l_next_billing_date := p_next_billing_date;
150       END IF;
151 
152       IF p_output_tax_code = FND_API.G_MISS_CHAR
153       THEN
154          l_output_tax_code := null;
155       ELSE
156          l_output_tax_code := p_output_tax_code;
157       END IF;
158 
159       IF p_invoice_comment = FND_API.G_MISS_CHAR
160       THEN
161          l_invoice_comment := null;
162       ELSE
163          l_invoice_comment := p_invoice_comment;
164       END IF;
165 
166       IF p_retention_percent = FND_API.G_MISS_NUM
167       THEN
168          l_retention_percent := null;
169       ELSE
170          l_retention_percent := p_retention_percent;
171       END IF;
172 
173       IF p_retention_output_tax_code = FND_API.G_MISS_CHAR
174       THEN
175          l_retention_output_tax_code := null;
176       ELSE
177          l_retention_output_tax_code := p_retention_output_tax_code;
178       END IF;
179 
180       IF NVl( p_first_bill_offset, 0 ) < 0
181       THEN
182           PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
183                                p_msg_name       => 'PA_PRJ_BILL_OFFSET_GR_ZR' );
184           x_msg_data := 'PA_PRJ_BILL_OFFSET_GR_ZR';
185           x_return_status := 'E';
186           RAISE  FND_API.G_EXC_ERROR;
187       END IF;
188 
189       IF NVL( p_retention_percent, 0 ) < 0
190       THEN
191           PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
192                                p_msg_name       => 'PA_PRJ_RETN_PERCENT_GR_ZR' );
193           x_msg_data := 'PA_PRJ_RETN_PERCENT_GR_ZR';
194           x_return_status := 'E';
195           RAISE  FND_API.G_EXC_ERROR;
196       END IF;
197 
198       --Validate and convert name to id for retention_inv_format.
199       IF ( p_retention_inv_format_id IS NOT NULL AND p_retention_inv_format_id <> FND_API.G_MISS_NUM ) OR
200          ( p_retention_inv_format_name IS NOT NULL AND p_retention_inv_format_name <> FND_API.G_MISS_CHAR )
201       THEN
202          if (p_debug_mode = 'Y') then
203              pa_debug.debug('Update rev and Billing Info PUB : Checking retention invoice format id');
204          end if;
205          PA_BILLING_SETUP_UTILS.Validate_Retn_Inv_Format
206             ( p_retention_inv_format_id     => p_retention_inv_format_id
207              ,p_retention_inv_format_name   => p_retention_inv_format_name
208              ,p_check_id_flag               => 'A'
209              ,x_retention_inv_format_id     => l_retention_inv_format_id
210              ,x_return_status               => l_return_status
211              ,x_error_msg_code              => l_error_msg_code);
212 
213          IF l_return_status = FND_API.G_RET_STS_ERROR
214          THEN
215             PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
216                                  p_msg_name       => l_error_msg_code);
217             x_msg_data := l_error_msg_code;
218             x_return_status := 'E';
219          END IF;
220       END IF;
221 
222       --Get the next billing cycle date
223       IF p_billing_cycle_id IS NOT NULL
224       THEN
225          OPEN cur_projects_all;
226          FETCH cur_projects_all INTO l_start_date;
227          CLOSE cur_projects_all;
228          l_next_billing_date := Pa_Billing_Cycles_pkg.Get_Next_billing_Date(
229                                         p_project_id,
230                                         l_start_date,
231                                         p_billing_cycle_id,
232                                         l_first_bill_offset,
233                                         null,
234                                         null );
235       END IF;
236 
237       PA_BILLING_SETUP_PVT.update_revenue_and_billing(
238                                p_commit                      =>  FND_API.G_FALSE,
239                                p_validate_only               =>  p_validate_only,
240                                p_validation_level            =>  p_validation_level,
241                                p_calling_module              =>  p_calling_module,
242                                p_debug_mode                  =>  p_debug_mode,
243                                p_max_msg_count	 	       =>  p_max_msg_count,
244                                p_project_id                  =>  p_project_id,
245                                p_distribution_rule           =>  p_distribution_rule,
246                                p_billing_cycle_id            =>  p_billing_cycle_id,
247                                p_first_bill_offset           =>  l_first_bill_offset,
248                                p_next_billing_date           =>  l_next_billing_date,
249                                p_output_tax_code             =>  l_output_tax_code,
250                                p_billing_job_group_id           =>  p_billing_job_group_id,
251                                p_invoice_comment             =>  l_invoice_comment,
252                                p_labor_id                       =>  p_labor_id,
253                                p_non_labor_id                   =>  p_non_labor_id,
254                                p_retention_inv_format_id     =>  l_retention_inv_format_id,
255                                p_retention_percent           =>  l_retention_percent,
256                                p_retention_output_tax_code   =>  l_retention_output_tax_code,
257                                p_record_version_number	 =>  p_record_version_number,
258                                x_return_status	             =>  l_return_status,
259                                x_msg_count	             =>  l_msg_count,
260                                x_msg_data	                   =>  l_msg_data
261                             );
262 
263       --return the next billing date to the calling program;
264       p_next_billing_date := l_next_billing_date;
265 
266    END IF;
267 
268    if (p_debug_mode = 'Y') then
269        pa_debug.debug('Update reve and Bill Info PUB : checking message count');
270    end if;
271    l_msg_count := FND_MSG_PUB.count_msg;
272    If l_msg_count > 0 THEN
273       x_msg_count := l_msg_count;
274       If l_msg_count = 1 THEN
275          pa_interface_utils_pub.get_messages
276              (p_encoded        => FND_API.G_TRUE ,
277               p_msg_index      => 1,
278               p_msg_count      => l_msg_count ,
279               p_msg_data       => l_msg_data,
280               p_data           => l_data,
281               p_msg_index_out  => l_msg_index_out );
282               x_msg_data := l_data;
283       End if;
284       RAISE  FND_API.G_EXC_ERROR;
285    End if;
286 
287    IF FND_API.TO_BOOLEAN(P_COMMIT)
288    THEN
289       COMMIT WORK;
290    END IF;
291 
292 EXCEPTION
293     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
294        IF p_commit = FND_API.G_TRUE
295        THEN
296           ROLLBACK TO revenue_and_billing;
297        END IF;
298        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
299        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
300                                p_procedure_name => 'update_revenue_and_Billing',
301                                p_error_text     => SUBSTRB(SQLERRM,1,240));
302        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
303 
304     WHEN FND_API.G_EXC_ERROR THEN
305        IF p_commit = FND_API.G_TRUE
306        THEN
307           ROLLBACK TO revenue_and_billing;
308        END IF;
309        x_return_status := 'E';
310 
311      WHEN OTHERS THEN
312        IF p_commit = FND_API.G_TRUE
313        THEN
314           ROLLBACK TO revenue_and_billing;
315        END IF;
316        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
317        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
318                                p_procedure_name => 'update_revenue_and_Billing',
319                                p_error_text     => SUBSTRB(SQLERRM,1,240));
320        RAISE;
321 
322 END update_revenue_and_billing;
323 
324 
325 -- API name                      : create_credit_receivers
326 -- Type                          : Public procedure
327 -- Pre-reqs                      : None
328 -- Return Value                  : N/A
329 -- Prameters
330 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
331 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
332 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
333 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
334 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
335 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
336 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
337 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
338 -- p_project_id	         	 IN	 NUMBER     REQUIRED
339 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
340 -- p_credit_type               IN    VARCHAR2   REQUIRED
341 -- p_person_id                 IN    NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
342 -- p_person_name               IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CAHR
343 -- p_emp_number                IN    VARCHAR2     OPTIONAL DEFAULT FND_API.G_MISS_CHAR,
344 -- p_credit_percentage         IN    NUMBER   REQUIRED
345 -- p_transfer_to_AR            IN    VARCHAR2   REQUIRED
346 -- p_effective_from_date       IN    DATE       REQUIRED
347 -- p_effective_to_date         IN    DATE       OPTIONAL   DEFAULT=FND_API.G_MISS_DATE
348 -- x_credit_receiver_id        OUT   NUMBER     REQUIRED
349 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
350 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
351 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
352 --
353 --  History
354 --
355 --  25-MAY-01   Majid Ansari             -Created
356 --
357 --
358 
359  PROCEDURE  create_credit_receivers(
360  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
361  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
362  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
363  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
364  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
365  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
366  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
367  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
368  p_project_id	       IN	 NUMBER    ,
369  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
370  p_credit_type               IN    VARCHAR2   ,
371  p_person_id                 IN    NUMBER     DEFAULT FND_API.G_MISS_NUM,
372  p_person_name               IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
373  p_emp_number                IN    VARCHAR2     DEFAULT FND_API.G_MISS_CHAR,
374  p_credit_percentage         IN    NUMBER   ,
375  p_transfer_to_AR            IN    VARCHAR2   ,
376  p_effective_from_date         IN    DATE       ,
377  p_effective_to_date           IN    DATE        DEFAULT FND_API.G_MISS_DATE,
378  x_credit_receiver_id          OUT   NOCOPY NUMBER, --File.Sql.39 bug 4440895
379  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
380  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
381  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
382  ) IS
383   l_api_name                CONSTANT VARCHAR(30) := 'create_credit_receivers';
384   l_api_version             CONSTANT NUMBER      := 1.0;
385 
386   l_return_status                    VARCHAR2(1);
387   l_msg_data                         VARCHAR2(250);
388   l_msg_count                        NUMBER;
389 
390   l_dummy_char                       VARCHAR2(1);
391   l_error_msg_code                   VARCHAR2(250);
392   l_data                             VARCHAR2(250);
393   l_msg_index_out                    NUMBER;
394 
395   l_task_id	         	  NUMBER;
396   l_credit_percentage     NUMBER;
397   l_effective_to_date     DATE;
398   l_person_id             NUMBER;
399 
400 BEGIN
401 
402    -- Standard call to check for call compatibility
403 
404    IF (p_debug_mode = 'Y')
405    THEN
406        pa_debug.debug('Update Revenue and Bill Info PUB : Checking the api version number.');
407    END IF;
408 
409    IF p_commit = FND_API.G_TRUE
410    THEN
411       SAVEPOINT credit_receivers;
412    END IF;
413 
414    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
415                                       p_api_version,
416                                       l_api_name,
417                                       g_pkg_name)
418    THEN
419       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
420    END IF;
421 
422    if (p_debug_mode = 'Y') then
423        pa_debug.debug('Update Revenue and Bill Info PUB : Initializing message stack.');
424    end if;
425 
426    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.update_revenue_and_billing');
427 
428    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
429       fnd_msg_pub.initialize;
430    end if;
431 
432    x_return_status := 'S';
433 
434    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
435    THEN
436        IF p_task_id = FND_API.G_MISS_NUM
437        THEN
438           l_task_id := null;
439        ELSE
440           l_task_id := p_task_id;
441        END IF;
442 
443        IF p_credit_percentage = FND_API.G_MISS_NUM
444        THEN
445           l_credit_percentage := null;
446        ELSE
447           l_credit_percentage := p_credit_percentage;
448        END IF;
449 
450        IF p_effective_to_date = FND_API.G_MISS_DATE
451        THEN
452           l_effective_to_date := null;
453        ELSE
454           l_effective_to_date := p_effective_to_date;
455        END IF;
456 
457 
458          --Validating employee or person id
459          IF ( p_person_id IS NOT NULL AND p_person_id <> FND_API.G_MISS_NUM ) OR
460             ( p_person_name IS NOT NULL AND p_person_name <> FND_API.G_MISS_CHAR ) OR
461             ( p_emp_number IS NOT NULL AND p_emp_number <> FND_API.G_MISS_CHAR )
462          THEN
463             if (p_debug_mode = 'Y') then
464                 pa_debug.debug('CREATE CREDIT RECEIVERS : Validating person id');
465             end if;
466             /*PA_BILLING_SETUP_UTILS.Validate_person_id_name
467                ( p_person_id               => p_person_id
468                 ,p_person_name             => p_person_name
469                 ,p_check_id_flag           => 'A'
470                 ,x_person_id               => l_person_id
471                 ,x_return_status           => l_return_status
472                 ,x_error_msg_code          => l_error_msg_code);*/
473 
474            PA_BILLING_SETUP_UTILS.VALIDATE_EMP_NO_NAME
475                ( p_person_id               => p_person_id
476                 ,p_person_name             => p_person_name
477                 ,p_emp_number              => p_emp_number
478                 ,p_check_id                => 'A'
479                 ,x_person_id               => l_person_id
480                 ,x_return_status           => l_return_status
481                 ,x_error_msg_code          => l_error_msg_code);
482 
483             IF l_return_status = FND_API.G_RET_STS_ERROR
484             THEN
485                PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
486                                     p_msg_name       => l_error_msg_code);
487                x_msg_data := l_error_msg_code;
488                x_return_status := 'E';
489                RAISE FND_API.G_EXC_ERROR;
490             END IF;
491          END IF;
492 
493          PA_BILLING_SETUP_PVT.create_credit_receivers(
494                                   p_commit	         	 =>    FND_API.G_FALSE,
495                                   p_validate_only	 	 =>    p_validate_only,
496                                   p_validation_level	       =>    p_validation_level,
497                                   p_calling_module	 	 =>    p_calling_module,
498                                   p_debug_mode	             =>    p_debug_mode,
499                                   p_max_msg_count	 	 =>    p_max_msg_count,
500                                   p_project_id	             =>    p_project_id,
501                                   p_task_id	         	 =>    l_task_id,
502                                   p_credit_type              =>    p_credit_type,
503                                   p_person_id                =>    l_person_id,
504                                   p_credit_percentage        =>    l_credit_percentage,
505                                   p_transfer_to_AR           =>    p_transfer_to_AR,
506                                   p_effective_from_date      =>    p_effective_from_date,
507                                   p_effective_to_date        =>    l_effective_to_date,
508                                   x_credit_receiver_id       =>    x_credit_receiver_id,
509                                   x_return_status	       =>    l_return_status,
510                                   x_msg_count	             =>    l_msg_count,
511                                   x_msg_data	             =>    l_msg_data
512                                 );
513    END IF;
514 
515    if (p_debug_mode = 'Y') then
516        pa_debug.debug('CREATE CREDIT RECEIVERS PUB : checking message count');
517    end if;
518    l_msg_count := FND_MSG_PUB.count_msg;
519    If l_msg_count > 0 THEN
520       x_msg_count := l_msg_count;
521       If l_msg_count = 1 THEN
522          pa_interface_utils_pub.get_messages
523              (p_encoded        => FND_API.G_TRUE ,
524               p_msg_index      => 1,
525               p_msg_count      => l_msg_count ,
526               p_msg_data       => l_msg_data,
527               p_data           => l_data,
528               p_msg_index_out  => l_msg_index_out );
529               x_msg_data := l_data;
530       End if;
531       RAISE  FND_API.G_EXC_ERROR;
532    End if;
533 
534    IF FND_API.TO_BOOLEAN(P_COMMIT)
535    THEN
536       COMMIT WORK;
537    END IF;
538 
539 EXCEPTION
540     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
541        IF p_commit = FND_API.G_TRUE
542        THEN
543           ROLLBACK TO credit_receivers;
544        END IF;
545        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
546        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
547                                p_procedure_name => 'CREATE_CREDIT_RECEIVERS',
548                                p_error_text     => SUBSTRB(SQLERRM,1,240));
549        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
550 
551        x_credit_receiver_id := null;
552 
553     WHEN FND_API.G_EXC_ERROR THEN
554        IF p_commit = FND_API.G_TRUE
555        THEN
556           ROLLBACK TO credit_receivers;
557        END IF;
558        x_return_status := 'E';
559 
560        x_credit_receiver_id := null;
561 
562      WHEN OTHERS THEN
563        IF p_commit = FND_API.G_TRUE
564        THEN
565           ROLLBACK TO credit_receivers;
566        END IF;
567        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
568        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
569                                p_procedure_name => 'CREATE_CREDIT_RECEIVERS',
570                                p_error_text     => SUBSTRB(SQLERRM,1,240));
571 
572        x_credit_receiver_id := null;
573        RAISE;
574 
575 END create_credit_receivers;
576 
577 -- API name                      : update_credit_receivers
578 -- Type                          : Public procedure
579 -- Pre-reqs                      : None
580 -- Return Value                  : N/A
581 -- Prameters
582 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
583 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
584 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
585 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
586 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
587 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
588 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
589 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
590 -- p_credit_receiver_id        IN    NUMBER     REQUIRED
591 -- p_project_id	         	 IN	 NUMBER     REQUIRED
592 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
593 -- p_credit_type               IN    VARCHAR2   REQUIRED
594 -- p_person_id                 IN    NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
595 -- p_person_name               IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CAHR
596 -- p_emp_number                IN    VARCHAR2     OPTIONAL DEFAULT FND_API.G_MISS_CHAR,
597 -- p_credit_percentage         IN    NUMBER   REQUIRED
598 -- p_transfer_to_AR            IN    VARCHAR2   REQUIRED
599 -- p_effective_from_date       IN    DATE       REQUIRED
600 -- p_effective_to_date         IN    DATE       OPTIONAL   DEFAULT=FND_API.G_MISS_DATE
601 -- p_record_version_number	 IN	 NUMBER     REQUIRED   DEFAULT=1
602 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
603 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
604 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
605 --
606 --  History
607 --
608 --  25-MAY-01   Majid Ansari             -Created
609 --
610 --
611 
612  PROCEDURE  update_credit_receivers(
613  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
614  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
615  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
616  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
617  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
618  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
619  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
620  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
621  p_credit_receiver_id        IN    NUMBER,
622  p_project_id	       IN	 NUMBER    ,
623  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
624  p_credit_type               IN    VARCHAR2   ,
625  p_person_id                 IN    NUMBER     DEFAULT FND_API.G_MISS_NUM,
626  p_person_name               IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
627  p_emp_number                IN    VARCHAR2     DEFAULT FND_API.G_MISS_CHAR,
628  p_credit_percentage         IN    NUMBER   DEFAULT FND_API.G_MISS_NUM,
629  p_transfer_to_AR            IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
630  p_effective_from_date         IN    DATE       ,
631  p_effective_to_date           IN    DATE        DEFAULT FND_API.G_MISS_DATE,
632  p_record_version_number	 IN	 NUMBER     DEFAULT 1,
633  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
634  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
635  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
636  ) AS
637   l_api_name                CONSTANT VARCHAR(30) := 'update_credit_receivers';
638   l_api_version             CONSTANT NUMBER      := 1.0;
639 
640   l_return_status                    VARCHAR2(1);
641   l_msg_data                         VARCHAR2(250);
642   l_msg_count                        NUMBER;
643 
644   l_dummy_char                       VARCHAR2(1);
645   l_error_msg_code                   VARCHAR2(250);
646   l_data                             VARCHAR2(250);
647   l_msg_index_out                    NUMBER;
648 
649   l_task_id	         	  NUMBER;
650   l_credit_percentage     NUMBER;
651   l_effective_to_date     DATE;
652   l_person_id             NUMBER;
653 BEGIN
654 
655    -- Standard call to check for call compatibility
656 
657    IF (p_debug_mode = 'Y')
658    THEN
659        pa_debug.debug('Update credit receivers PUB : Checking the api version number.');
660    END IF;
661 
662    IF p_commit = FND_API.G_TRUE
663    THEN
664       SAVEPOINT credit_receivers;
665    END IF;
666 
667    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
668                                       p_api_version,
669                                       l_api_name,
670                                       g_pkg_name)
671    THEN
672       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
673    END IF;
674 
675    if (p_debug_mode = 'Y') then
676        pa_debug.debug('Update credit receivers PUB : Initializing message stack.');
677    end if;
678 
679    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.update_credit receivers');
680 
681    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
682       fnd_msg_pub.initialize;
683    end if;
684 
685    x_return_status := 'S';
686 
687    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
688    THEN
689        IF p_task_id = FND_API.G_MISS_NUM
690        THEN
691           l_task_id := null;
692        ELSE
693           l_task_id := p_task_id;
694        END IF;
695 
696        IF p_credit_percentage = FND_API.G_MISS_NUM
697        THEN
698           l_credit_percentage := null;
699        ELSE
700           l_credit_percentage := p_credit_percentage;
701        END IF;
702 
703        IF p_effective_to_date = FND_API.G_MISS_DATE
704        THEN
705           l_effective_to_date := null;
706        ELSE
707           l_effective_to_date := p_effective_to_date;
708        END IF;
709 
710 
711          --Validating employee or person id
712          IF ( p_person_id IS NOT NULL AND p_person_id <> FND_API.G_MISS_NUM ) OR
713             ( p_person_name IS NOT NULL AND p_person_name <> FND_API.G_MISS_CHAR ) OR
714             ( p_emp_number IS NOT NULL AND p_emp_number <> FND_API.G_MISS_CHAR )
715          THEN
716             if (p_debug_mode = 'Y') then
717                 pa_debug.debug('UPDATE CREDIT RECEIVERS : Validating person id');
718             end if;
719             /*PA_BILLING_SETUP_UTILS.Validate_person_id_name
720                ( p_person_id               => p_person_id
721                 ,p_person_name             => p_person_name
722                 ,p_check_id_flag           => 'A'
723                 ,x_person_id               => l_person_id
724                 ,x_return_status           => l_return_status
725                 ,x_error_msg_code          => l_error_msg_code);*/
726 
727            PA_BILLING_SETUP_UTILS.VALIDATE_EMP_NO_NAME
728                ( p_person_id               => p_person_id
729                 ,p_person_name             => p_person_name
730                 ,p_emp_number              => p_emp_number
731                 ,p_check_id           => 'A'
732                 ,x_person_id               => l_person_id
733                 ,x_return_status           => l_return_status
734                 ,x_error_msg_code          => l_error_msg_code);
735 
736             IF l_return_status = FND_API.G_RET_STS_ERROR
737             THEN
738                PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
739                                     p_msg_name       => l_error_msg_code);
740                x_msg_data := l_error_msg_code;
741                x_return_status := 'E';
742                RAISE FND_API.G_EXC_ERROR;
743             END IF;
744          END IF;
745 
746          PA_BILLING_SETUP_PVT.update_credit_receivers(
747                                   p_commit	         	 =>    FND_API.G_FALSE,
748                                   p_validate_only	 	 =>    p_validate_only,
749                                   p_validation_level	       =>    p_validation_level,
750                                   p_calling_module	 	 =>    p_calling_module,
751                                   p_debug_mode	             =>    p_debug_mode,
752                                   p_max_msg_count	 	 =>    p_max_msg_count,
753                                   p_credit_receiver_id       =>    p_credit_receiver_id,
754                                   p_project_id	             =>    p_project_id,
755                                   p_task_id	         	 =>    l_task_id,
756                                   p_credit_type              =>    p_credit_type,
757                                   p_person_id                =>    l_person_id,
758                                   p_credit_percentage        =>    l_credit_percentage,
759                                   p_transfer_to_AR           =>    p_transfer_to_AR,
760                                   p_effective_from_date      =>    p_effective_from_date,
761                                   p_effective_to_date        =>    l_effective_to_date,
762                                   p_record_version_number    =>    p_record_version_number,
763                                   x_return_status	       =>    l_return_status,
764                                   x_msg_count	             =>    l_msg_count,
765                                   x_msg_data	             =>    l_msg_data
766                                 );
767    END IF;
768 
769    if (p_debug_mode = 'Y') then
770        pa_debug.debug('UPDATE CREDIT RECEIVERS PUB : checking message count');
771    end if;
772 
773    l_msg_count := FND_MSG_PUB.count_msg;
774    If l_msg_count > 0 THEN
775       x_msg_count := l_msg_count;
776       If l_msg_count = 1 THEN
777          pa_interface_utils_pub.get_messages
778              (p_encoded        => FND_API.G_TRUE ,
779               p_msg_index      => 1,
780               p_msg_count      => l_msg_count ,
781               p_msg_data       => l_msg_data,
782               p_data           => l_data,
783               p_msg_index_out  => l_msg_index_out );
784               x_msg_data := l_data;
785       End if;
786       RAISE  FND_API.G_EXC_ERROR;
787    End if;
788 
789    IF FND_API.TO_BOOLEAN(P_COMMIT)
790    THEN
791       COMMIT WORK;
792    END IF;
793 
794 EXCEPTION
795     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
796        IF p_commit = FND_API.G_TRUE
797        THEN
798           ROLLBACK TO credit_receivers;
799        END IF;
800        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
801        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
802                                p_procedure_name => 'UPDATE_CREDIT_RECEIVERS',
803                                p_error_text     => SUBSTRB(SQLERRM,1,240));
804        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
805 
806     WHEN FND_API.G_EXC_ERROR THEN
807        IF p_commit = FND_API.G_TRUE
808        THEN
809           ROLLBACK TO credit_receivers;
810        END IF;
811        x_return_status := 'E';
812 
813      WHEN OTHERS THEN
814        IF p_commit = FND_API.G_TRUE
815        THEN
816           ROLLBACK TO credit_receivers;
817        END IF;
818        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
819        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
820                                p_procedure_name => 'UPDATE_CREDIT_RECEIVERS',
821                                p_error_text     => SUBSTRB(SQLERRM,1,240));
822        RAISE;
823 
824 
825 END update_credit_receivers;
826 
827 
828 -- API name                      : delete_credit_receivers
829 -- Type                          : Public procedure
830 -- Pre-reqs                      : None
831 -- Return Value                  : N/A
832 -- Prameters
833 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
834 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
835 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
836 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
837 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
838 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
839 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
840 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
841 -- p_credit_receiver_id        IN    NUMBER     REQUIRED
842 -- p_project_id	         	 IN	 NUMBER     REQUIRED
843 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
844 -- p_credit_type               IN    VARCHAR2   REQUIRED
845 -- p_person_id                 IN    NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
846 -- p_person_name               IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CAHR
847 -- p_effective_from_date       IN    DATE       REQUIRED
848 -- p_record_version_number	 IN	 NUMBER     REQUIRED   DEFAULT=1
849 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
850 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
851 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
852 --
853 --  History
854 --
855 --  25-MAY-01   Majid Ansari             -Created
856 --
857 --
858 
859  PROCEDURE  delete_credit_receivers(
860  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
861  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
862  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
863  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
864  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
865  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
866  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
867  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
868  p_credit_receiver_id        IN    NUMBER,
869  p_project_id	       IN	 NUMBER    ,
870  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
871  p_credit_type           IN    VARCHAR2   ,
872  p_person_id             IN    NUMBER     DEFAULT FND_API.G_MISS_NUM,
873  p_person_name           IN    VARCHAR2   DEFAULT FND_API.G_MISS_CHAR,
874  p_effective_from_date   IN    DATE       ,
875  p_record_version_number	 IN	 NUMBER     DEFAULT 1,
876  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
877  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
878  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
879 
880  ) AS
881   l_api_name                CONSTANT VARCHAR(30) := 'delete_credit_receivers';
882   l_api_version             CONSTANT NUMBER      := 1.0;
883 
884   l_return_status                    VARCHAR2(1);
885   l_msg_data                         VARCHAR2(250);
886   l_msg_count                        NUMBER;
887 
888   l_dummy_char                       VARCHAR2(1);
889   l_error_msg_code                   VARCHAR2(250);
890   l_data                             VARCHAR2(250);
891   l_msg_index_out                    NUMBER;
892 
893   l_task_id	         	  NUMBER;
894   l_person_id             NUMBER;
895 BEGIN
896 
897    -- Standard call to check for call compatibility
898 
899    IF (p_debug_mode = 'Y')
900    THEN
901        pa_debug.debug('Delete credit receivers PUB : Checking the api version number.');
902    END IF;
903 
904    IF p_commit = FND_API.G_TRUE
905    THEN
906       SAVEPOINT credit_receivers;
907    END IF;
908 
909    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
910                                       p_api_version,
911                                       l_api_name,
912                                       g_pkg_name)
913    THEN
914       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
915    END IF;
916 
917    if (p_debug_mode = 'Y') then
918        pa_debug.debug('Delete credit receivers PUB : Initializing message stack.');
919    end if;
920 
921    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.Delete_credit receivers');
922 
923    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
924       fnd_msg_pub.initialize;
925    end if;
926 
927    x_return_status := 'S';
928 
929    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
930    THEN
931        IF p_task_id = FND_API.G_MISS_NUM
932        THEN
933           l_task_id := null;
934        ELSE
935           l_task_id := p_task_id;
936        END IF;
937 
938 
939          --Validating employee or person id
940          IF ( p_person_id IS NOT NULL AND p_person_id <> FND_API.G_MISS_NUM ) OR
941             ( p_person_name IS NOT NULL AND p_person_name <> FND_API.G_MISS_CHAR )
942          THEN
943             if (p_debug_mode = 'Y') then
944                 pa_debug.debug('UPDATE CREDIT RECEIVERS : Validating person id');
945             end if;
946             PA_BILLING_SETUP_UTILS.Validate_person_id_name
947                ( p_person_id               => p_person_id
948                 ,p_person_name             => p_person_name
949                 ,p_check_id_flag           => 'A'
950                 ,x_person_id               => l_person_id
951                 ,x_return_status           => l_return_status
952                 ,x_error_msg_code          => l_error_msg_code);
953 
954             IF l_return_status = FND_API.G_RET_STS_ERROR
955             THEN
956                PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
957                                     p_msg_name       => l_error_msg_code);
958                x_msg_data := l_error_msg_code;
959                x_return_status := 'E';
960             END IF;
961          END IF;
962 
963          PA_BILLING_SETUP_PVT.delete_credit_receivers(
964                                   p_commit	         	 =>    FND_API.G_FALSE,
965                                   p_validate_only	 	 =>    p_validate_only,
966                                   p_validation_level	       =>    p_validation_level,
967                                   p_calling_module	 	 =>    p_calling_module,
968                                   p_debug_mode	             =>    p_debug_mode,
969                                   p_max_msg_count	 	 =>    p_max_msg_count,
970                                   p_credit_receiver_id       =>    p_credit_receiver_id,
971                                   p_project_id	             =>    p_project_id,
972                                   p_task_id	         	 =>    l_task_id,
973                                   p_credit_type              =>    p_credit_type,
974                                   p_person_id                =>    l_person_id,
975                                   p_effective_from_date      =>    p_effective_from_date,
976                                   p_record_version_number    =>    p_record_version_number,
977                                   x_return_status	       =>    l_return_status,
978                                   x_msg_count	             =>    l_msg_count,
979                                   x_msg_data	             =>    l_msg_data
980                                 );
981    END IF;
982 
983    if (p_debug_mode = 'Y') then
984        pa_debug.debug('DELETE CREDIT RECEIVERS PUB : checking message count');
985    end if;
986    l_msg_count := FND_MSG_PUB.count_msg;
987    If l_msg_count > 0 THEN
988       x_msg_count := l_msg_count;
989       If l_msg_count = 1 THEN
990          pa_interface_utils_pub.get_messages
991              (p_encoded        => FND_API.G_TRUE ,
992               p_msg_index      => 1,
993               p_msg_count      => l_msg_count ,
994               p_msg_data       => l_msg_data,
995               p_data           => l_data,
996               p_msg_index_out  => l_msg_index_out );
997               x_msg_data := l_data;
998       End if;
999       RAISE  FND_API.G_EXC_ERROR;
1000    End if;
1001 
1002    IF FND_API.TO_BOOLEAN(P_COMMIT)
1003    THEN
1004       COMMIT WORK;
1005    END IF;
1006 
1007 EXCEPTION
1008     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
1009        IF p_commit = FND_API.G_TRUE
1010        THEN
1011           ROLLBACK TO credit_receivers;
1012        END IF;
1013        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1014        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1015                                p_procedure_name => 'DELETE_CREDIT_RECEIVERS',
1016                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1017        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1018 
1019     WHEN FND_API.G_EXC_ERROR THEN
1020        IF p_commit = FND_API.G_TRUE
1021        THEN
1022           ROLLBACK TO credit_receivers;
1023        END IF;
1024        x_return_status := 'E';
1025 
1026      WHEN OTHERS THEN
1027        IF p_commit = FND_API.G_TRUE
1028        THEN
1029           ROLLBACK TO credit_receivers;
1030        END IF;
1031        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1032        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1033                                p_procedure_name => 'DELETE_CREDIT_RECEIVERS',
1034                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1035        RAISE;
1036 END delete_credit_receivers;
1037 
1038 -- API name                      : create_billing_assignments
1039 -- Type                          : Public procedure
1040 -- Pre-reqs                      : None
1041 -- Return Value                  : N/A
1042 -- Prameters
1043 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
1044 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1045 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
1046 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1047 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
1048 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
1049 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
1050 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1051 -- p_project_id	         	 IN	 NUMBER     REQUIRED
1052 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1053 -- p_billing_extension_id    IN    NUMBER   REQUIRED
1054 -- p_amount                    IN    NUMBER     REQUIRED
1055 -- p_percent                   IN    NUMBER     REQUIRED
1056 -- p_active                    IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CHAR
1057 -- x_billing_assignment_id     OUT   NUMBER     REQUIRED
1058 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
1059 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
1060 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
1061 --
1062 --  History
1063 --
1064 --  25-MAY-01   Majid Ansari             -Created
1065 --
1066 --
1067 
1068  PROCEDURE  create_billing_assignments(
1069  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
1070  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1071  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
1072  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1073  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
1074  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
1075  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
1076  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1077  p_project_id	       IN	 NUMBER    ,
1078  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1079  p_billing_extension_id  IN    NUMBER   ,
1080  p_amount                IN    NUMBER      DEFAULT FND_API.G_MISS_NUM,
1081  p_percent               IN    NUMBER      DEFAULT FND_API.G_MISS_NUM,
1082  p_active                IN    VARCHAR2    ,
1083  x_billing_assignment_id     OUT   NOCOPY NUMBER, --File.Sql.39 bug 4440895
1084  x_return_status	       OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
1085  x_msg_count	       OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
1086  x_msg_data	             OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1087  ) IS
1088   l_api_name                CONSTANT VARCHAR(30) := 'create_billing_assignments';
1089   l_api_version             CONSTANT NUMBER      := 1.0;
1090 
1091   l_return_status                    VARCHAR2(1);
1092   l_msg_data                         VARCHAR2(250);
1093   l_msg_count                        NUMBER;
1094 
1095   l_dummy_char                       VARCHAR2(1);
1096   l_error_msg_code                   VARCHAR2(250);
1097   l_data                             VARCHAR2(250);
1098   l_msg_index_out                    NUMBER;
1099 
1100   l_task_id	           NUMBER;
1101   l_amount             NUMBER;
1102   l_percent            NUMBER;
1103 
1104 BEGIN
1105 
1106    -- Standard call to check for call compatibility
1107 
1108    IF (p_debug_mode = 'Y')
1109    THEN
1110        pa_debug.debug('create_billing_assignments PUB : Checking the api version number.');
1111    END IF;
1112 
1113    IF p_commit = FND_API.G_TRUE
1114    THEN
1115       SAVEPOINT billing_assignments;
1116    END IF;
1117 
1118    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
1119                                       p_api_version,
1120                                       l_api_name,
1121                                       g_pkg_name)
1122    THEN
1123       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1124    END IF;
1125 
1126    if (p_debug_mode = 'Y') then
1127        pa_debug.debug('create_billing_assignments PUB : Initializing message stack.');
1128    end if;
1129 
1130    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.create_billing_assignments');
1131 
1132    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
1133       fnd_msg_pub.initialize;
1134    end if;
1135 
1136    x_return_status := 'S';
1137 
1138    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
1139    THEN
1140        IF p_task_id = FND_API.G_MISS_NUM
1141        THEN
1142           l_task_id := null;
1143        ELSE
1144           l_task_id := p_task_id;
1145        END IF;
1146 
1147        IF p_amount = FND_API.G_MISS_NUM
1148        THEN
1149           l_amount := null;
1150        ELSE
1151           l_amount := p_amount;
1152        END IF;
1153 
1154        IF p_percent = FND_API.G_MISS_NUM
1155        THEN
1156           l_percent := null;
1157        ELSE
1158           l_percent := p_percent;
1159        END IF;
1160 
1161        PA_BILLING_SETUP_PVT.create_billing_assignments(
1162                                   p_commit	         	 =>    FND_API.G_FALSE,
1163                                   p_validate_only	 	 =>    p_validate_only,
1164                                   p_validation_level	       =>    p_validation_level,
1165                                   p_calling_module	 	 =>    p_calling_module,
1166                                   p_debug_mode	             =>    p_debug_mode,
1167                                   p_max_msg_count	 	 =>    p_max_msg_count,
1168                                   p_project_id	             =>    p_project_id,
1169                                   p_task_id	         	 =>    l_task_id,
1170                                   p_billing_extension_id     =>    p_billing_extension_id,
1171                                   x_billing_assignment_id    =>    x_billing_assignment_id,
1172                                   p_amount                   =>    l_amount ,
1173                                   p_percent                  =>    l_percent,
1174                                   p_active                   =>    p_active,
1175                                   x_return_status	       =>    l_return_status,
1176                                   x_msg_count	             =>    l_msg_count,
1177                                   x_msg_data	             =>    l_msg_data
1178                                 );
1179    END IF;
1180 
1181    if (p_debug_mode = 'Y') then
1182        pa_debug.debug('CREATEE BILLING ASSIGNMENTS PUB : checking message count');
1183    end if;
1184    l_msg_count := FND_MSG_PUB.count_msg;
1185    If l_msg_count > 0 THEN
1186       x_msg_count := l_msg_count;
1187       If l_msg_count = 1 THEN
1188          pa_interface_utils_pub.get_messages
1189              (p_encoded        => FND_API.G_TRUE ,
1190               p_msg_index      => 1,
1191               p_msg_count      => l_msg_count ,
1192               p_msg_data       => l_msg_data,
1193               p_data           => l_data,
1194               p_msg_index_out  => l_msg_index_out );
1195               x_msg_data := l_data;
1196       End if;
1197       RAISE  FND_API.G_EXC_ERROR;
1198    End if;
1199 
1200    IF FND_API.TO_BOOLEAN(P_COMMIT)
1201    THEN
1202       COMMIT WORK;
1203    END IF;
1204 
1205 EXCEPTION
1206     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
1207        IF p_commit = FND_API.G_TRUE
1208        THEN
1209           ROLLBACK TO billing_assignments;
1210        END IF;
1211        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1212        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1213                                p_procedure_name => 'create_billing_assignments',
1214                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1215        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1216 
1217        x_billing_assignment_id := null;
1218 
1219     WHEN FND_API.G_EXC_ERROR THEN
1220        IF p_commit = FND_API.G_TRUE
1221        THEN
1222           ROLLBACK TO billing_assignments;
1223        END IF;
1224        x_return_status := 'E';
1225 
1226        x_billing_assignment_id := null;
1227 
1228      WHEN OTHERS THEN
1229        IF p_commit = FND_API.G_TRUE
1230        THEN
1231           ROLLBACK TO billing_assignments;
1232        END IF;
1233        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1234        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1235                                p_procedure_name => 'create_billing_assignments',
1236                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1237 
1238        x_billing_assignment_id := null;
1239 
1240        RAISE;
1241 
1242 END create_billing_assignments;
1243 
1244 
1245 -- API name                      : update_billing_assignments
1246 -- Type                          : Public procedure
1247 -- Pre-reqs                      : None
1248 -- Return Value                  : N/A
1249 -- Prameters
1250 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
1251 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1252 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
1253 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1254 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
1255 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
1256 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
1257 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1258 -- p_project_id	         	 IN	 NUMBER     REQUIRED
1259 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1260 -- p_billing_extension_id    IN    NUMBER   REQUIRED
1261 -- p_amount                    IN    NUMBER     REQUIRED
1262 -- p_percent                   IN    NUMBER     REQUIRED
1263 -- p_active                    IN    VARCHAR2   OPTIONAL   DEFAULT=FND_API.G_MISS_CHAR
1264 -- p_record_version_number	 IN	 NUMBER     REQUIRED   DEFAULT=1
1265 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
1266 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
1267 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
1268 --
1269 --  History
1270 --
1271 --  25-MAY-01   Majid Ansari             -Created
1272 --
1273 --
1274 
1275  PROCEDURE  update_billing_assignments(
1276  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
1277  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1278  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
1279  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1280  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
1281  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
1282  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
1283  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1284  p_project_id	       IN	 NUMBER    ,
1285  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1286  p_billing_extension_id    IN    NUMBER   ,
1287  p_billing_assignment_id    IN    NUMBER   ,
1288  p_amount                    IN    NUMBER     ,
1289  p_percent                   IN    NUMBER     ,
1290  p_active                    IN    VARCHAR2    DEFAULT FND_API.G_MISS_CHAR,
1291  p_record_version_number	 IN	 NUMBER    DEFAULT 1,
1292  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
1293  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
1294  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1295  ) IS
1296   l_api_name                CONSTANT VARCHAR(30) := 'update_billing_assignments';
1297   l_api_version             CONSTANT NUMBER      := 1.0;
1298 
1299   l_return_status                    VARCHAR2(1);
1300   l_msg_data                         VARCHAR2(250);
1301   l_msg_count                        NUMBER;
1302 
1303   l_dummy_char                       VARCHAR2(1);
1304   l_error_msg_code                   VARCHAR2(250);
1305   l_data                             VARCHAR2(250);
1306   l_msg_index_out                    NUMBER;
1307 
1308   l_task_id	           NUMBER;
1309   l_amount             NUMBER;
1310   l_percent            NUMBER;
1311 
1312 BEGIN
1313 
1314    -- Standard call to check for call compatibility
1315 
1316    IF (p_debug_mode = 'Y')
1317    THEN
1318        pa_debug.debug('update_billing_assignments PUB : Checking the api version number.');
1319    END IF;
1320 
1321    IF p_commit = FND_API.G_TRUE
1322    THEN
1323       SAVEPOINT billing_assignments;
1324    END IF;
1325 
1326    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
1327                                       p_api_version,
1328                                       l_api_name,
1329                                       g_pkg_name)
1330    THEN
1331       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1332    END IF;
1333 
1334    if (p_debug_mode = 'Y') then
1335        pa_debug.debug('update_billing_assignments PUB : Initializing message stack.');
1336    end if;
1337 
1338    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.update_billing_assignments');
1339 
1340    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
1341       fnd_msg_pub.initialize;
1342    end if;
1343 
1344    x_return_status := 'S';
1345 
1346    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
1347    THEN
1348        IF p_task_id = FND_API.G_MISS_NUM
1349        THEN
1350           l_task_id := null;
1351        ELSE
1352           l_task_id := p_task_id;
1353        END IF;
1354 
1355        IF p_amount = FND_API.G_MISS_NUM
1356        THEN
1357           l_amount := null;
1358        ELSE
1359           l_amount := p_amount;
1360        END IF;
1361 
1362        IF p_percent = FND_API.G_MISS_NUM
1363        THEN
1364           l_percent := null;
1365        ELSE
1366           l_percent := p_percent;
1367        END IF;
1368 
1369        PA_BILLING_SETUP_PVT.update_billing_assignments(
1370                                   p_commit	         	 =>    FND_API.G_FALSE,
1371                                   p_validate_only	 	 =>    p_validate_only,
1372                                   p_validation_level	       =>    p_validation_level,
1373                                   p_calling_module	 	 =>    p_calling_module,
1374                                   p_debug_mode	             =>    p_debug_mode,
1375                                   p_max_msg_count	 	 =>    p_max_msg_count,
1376                                   p_project_id	             =>    p_project_id,
1377                                   p_task_id	         	 =>    l_task_id,
1378                                   p_billing_extension_id     =>    p_billing_extension_id,
1379                                   p_billing_assignment_id     =>   p_billing_assignment_id,
1380                                   p_record_version_number    =>    p_record_version_number,
1381                                   p_amount                   =>    l_amount ,
1382                                   p_percent                  =>    l_percent,
1383                                   p_active                   =>    p_active,
1384                                   x_return_status	       =>    l_return_status,
1385                                   x_msg_count	             =>    l_msg_count,
1386                                   x_msg_data	             =>    l_msg_data
1387                                 );
1388    END IF;
1389 
1390    if (p_debug_mode = 'Y') then
1391        pa_debug.debug('UPDATE BILLING ASSIGNMENTS PUB : checking message count');
1392    end if;
1393    l_msg_count := FND_MSG_PUB.count_msg;
1394    If l_msg_count > 0 THEN
1395       x_msg_count := l_msg_count;
1396       If l_msg_count = 1 THEN
1397          pa_interface_utils_pub.get_messages
1398              (p_encoded        => FND_API.G_TRUE ,
1399               p_msg_index      => 1,
1400               p_msg_count      => l_msg_count ,
1401               p_msg_data       => l_msg_data,
1402               p_data           => l_data,
1403               p_msg_index_out  => l_msg_index_out );
1404               x_msg_data := l_data;
1405       End if;
1406       RAISE  FND_API.G_EXC_ERROR;
1407    End if;
1408 
1409    IF FND_API.TO_BOOLEAN(P_COMMIT)
1410    THEN
1411       COMMIT WORK;
1412    END IF;
1413 
1414 EXCEPTION
1415     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
1416        IF p_commit = FND_API.G_TRUE
1417        THEN
1418           ROLLBACK TO billing_assignments;
1419        END IF;
1420        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1421        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1422                                p_procedure_name => 'update_billing_assignments',
1423                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1424        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1425 
1426     WHEN FND_API.G_EXC_ERROR THEN
1427        IF p_commit = FND_API.G_TRUE
1428        THEN
1429           ROLLBACK TO billing_assignments;
1430        END IF;
1431        x_return_status := 'E';
1432 
1433      WHEN OTHERS THEN
1434        IF p_commit = FND_API.G_TRUE
1435        THEN
1436           ROLLBACK TO billing_assignments;
1437        END IF;
1438        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1439        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1440                                p_procedure_name => 'update_billing_assignments',
1441                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1442        RAISE;
1443 END update_billing_assignments;
1444 
1445 
1446 -- API name                      : delete_billing_assignments
1447 -- Type                          : Public procedure
1448 -- Pre-reqs                      : None
1449 -- Return Value                  : N/A
1450 -- Prameters
1451 -- p_api_version	       	 IN	 NUMBER     REQUIRED   DEFAULT=1.0
1452 -- p_init_msg_list	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1453 -- p_commit	         	       IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_FALSE
1454 -- p_validate_only	 	 IN	 VARCHAR2   REQUIRED   DEFAULT=FND_API.G_TRUE
1455 -- p_validation_level	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_VALID_LEVEL_FULL
1456 -- p_calling_module	 	 IN 	 VARCHAR2   OPTIONAL   DEFAULT='SELF_SERVICE'
1457 -- p_debug_mode	         	 IN	 VARCHAR2   OPTIONAL   DEFAULT='N'
1458 -- p_max_msg_count	 	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1459 -- p_project_id	         	 IN	 NUMBER     REQUIRED
1460 -- p_task_id	         	 IN	 NUMBER     OPTIONAL   DEFAULT=FND_API.G_MISS_NUM
1461 -- p_billing_extension_id    IN    NUMBER   REQUIRED
1462 -- p_record_version_number	 IN	 NUMBER     REQUIRED   DEFAULT=1
1463 -- x_return_status	       OUT 	 VARCHAR2   REQUIRED
1464 -- x_msg_count	             OUT 	 VARCHAR2   REQUIRED
1465 -- x_msg_data	             OUT 	 VARCHAR2   REQUIRED
1466 --
1467 --  History
1468 --
1469 --  25-MAY-01   Majid Ansari             -Created
1470 --
1471 --
1472 
1473  PROCEDURE  delete_billing_assignments(
1474  p_api_version	       IN	 NUMBER     DEFAULT 1.0,
1475  p_init_msg_list	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1476  p_commit	         	 IN	 VARCHAR2   DEFAULT FND_API.G_FALSE,
1477  p_validate_only	 	 IN	 VARCHAR2   DEFAULT FND_API.G_TRUE,
1478  p_validation_level	 IN	 NUMBER     DEFAULT FND_API.G_VALID_LEVEL_FULL,
1479  p_calling_module	 	 IN 	 VARCHAR2   DEFAULT 'SELF_SERVICE',
1480  p_debug_mode	       IN	 VARCHAR2   DEFAULT 'N',
1481  p_max_msg_count	 	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1482  p_project_id	       IN	 NUMBER    ,
1483  p_task_id	         	 IN	 NUMBER     DEFAULT FND_API.G_MISS_NUM,
1484  p_billing_extension_id    IN    NUMBER   ,
1485  p_billing_assignment_id    IN    NUMBER   ,
1486  p_record_version_number	 IN	 NUMBER    DEFAULT 1,
1487  x_return_status	             OUT 	 NOCOPY VARCHAR2   , --File.Sql.39 bug 4440895
1488  x_msg_count	             OUT 	 NOCOPY VARCHAR2  , --File.Sql.39 bug 4440895
1489  x_msg_data	                   OUT 	 NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1490  ) IS
1491   l_api_name                CONSTANT VARCHAR(30) := 'delete_billing_assignments';
1492   l_api_version             CONSTANT NUMBER      := 1.0;
1493 
1494   l_return_status                    VARCHAR2(1);
1495   l_msg_data                         VARCHAR2(250);
1496   l_msg_count                        NUMBER;
1497 
1498   l_dummy_char                       VARCHAR2(1);
1499   l_error_msg_code                   VARCHAR2(250);
1500   l_data                             VARCHAR2(250);
1501   l_msg_index_out                    NUMBER;
1502 
1503   l_task_id	           NUMBER;
1504   l_amount             NUMBER;
1505   l_percent            NUMBER;
1506 
1507 BEGIN
1508 
1509    -- Standard call to check for call compatibility
1510 
1511    IF (p_debug_mode = 'Y')
1512    THEN
1513        pa_debug.debug('delete_billing_assignments PUB : Checking the api version number.');
1514    END IF;
1515 
1516    IF p_commit = FND_API.G_TRUE
1517    THEN
1518       SAVEPOINT billing_assignments;
1519    END IF;
1520 
1521    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
1522                                       p_api_version,
1523                                       l_api_name,
1524                                       g_pkg_name)
1525    THEN
1526       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1527    END IF;
1528 
1529    if (p_debug_mode = 'Y') then
1530        pa_debug.debug('delete_billing_assignments PUB : Initializing message stack.');
1531    end if;
1532 
1533    pa_debug.init_err_stack('PA_BILLING_SETUP_PUB.delete_billing_assignments');
1534 
1535    if FND_API.to_boolean(nvl(p_init_msg_list, FND_API.G_FALSE)) then
1536       fnd_msg_pub.initialize;
1537    end if;
1538 
1539    x_return_status := 'S';
1540 
1541    IF p_validate_only = FND_API.G_TRUE AND p_validation_level > 0
1542    THEN
1543        IF p_task_id = FND_API.G_MISS_NUM
1544        THEN
1545           l_task_id := null;
1546        ELSE
1547           l_task_id := p_task_id;
1548        END IF;
1549 
1550        PA_BILLING_SETUP_PVT.delete_billing_assignments(
1551                                   p_commit	         	 =>    FND_API.G_FALSE,
1552                                   p_validate_only	 	 =>    p_validate_only,
1553                                   p_validation_level	       =>    p_validation_level,
1554                                   p_calling_module	 	 =>    p_calling_module,
1555                                   p_debug_mode	             =>    p_debug_mode,
1556                                   p_max_msg_count	 	 =>    p_max_msg_count,
1557                                   p_project_id	             =>    p_project_id,
1558                                   p_task_id	         	 =>    l_task_id,
1559                                   p_billing_extension_id     =>    p_billing_extension_id,
1560                                   p_billing_assignment_id     =>    p_billing_assignment_id,
1561                                   p_record_version_number    =>    p_record_version_number,
1562                                   x_return_status	       =>    l_return_status,
1563                                   x_msg_count	             =>    l_msg_count,
1564                                   x_msg_data	             =>    l_msg_data
1565                                 );
1566    END IF;
1567 
1568    if (p_debug_mode = 'Y') then
1569        pa_debug.debug('DELETE BILLING ASSIGNMENTS PUB : checking message count');
1570    end if;
1571    l_msg_count := FND_MSG_PUB.count_msg;
1572    If l_msg_count > 0 THEN
1573       x_msg_count := l_msg_count;
1574       If l_msg_count = 1 THEN
1575          pa_interface_utils_pub.get_messages
1576              (p_encoded        => FND_API.G_TRUE ,
1577               p_msg_index      => 1,
1578               p_msg_count      => l_msg_count ,
1579               p_msg_data       => l_msg_data,
1580               p_data           => l_data,
1581               p_msg_index_out  => l_msg_index_out );
1582               x_msg_data := l_data;
1583       End if;
1584       RAISE  FND_API.G_EXC_ERROR;
1585    End if;
1586 
1587    IF FND_API.TO_BOOLEAN(P_COMMIT)
1588    THEN
1589       COMMIT WORK;
1590    END IF;
1591 
1592 EXCEPTION
1593     WHEN FND_API.G_EXC_UNEXPECTED_ERROR  THEN
1594        IF p_commit = FND_API.G_TRUE
1595        THEN
1596           ROLLBACK TO billing_assignments;
1597        END IF;
1598        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1599        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1600                                p_procedure_name => 'delete_billing_assignments',
1601                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1602        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1603 
1604     WHEN FND_API.G_EXC_ERROR THEN
1605        IF p_commit = FND_API.G_TRUE
1606        THEN
1607           ROLLBACK TO billing_assignments;
1608        END IF;
1609        x_return_status := 'E';
1610 
1611      WHEN OTHERS THEN
1612        IF p_commit = FND_API.G_TRUE
1613        THEN
1614           ROLLBACK TO billing_assignments;
1615        END IF;
1616        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1617        fnd_msg_pub.add_exc_msg(p_pkg_name       => 'PA_BILLING_SETUP_PUB',
1618                                p_procedure_name => 'delete_billing_assignments',
1619                                p_error_text     => SUBSTRB(SQLERRM,1,240));
1620        RAISE;
1621 END delete_billing_assignments;
1622 
1623 END PA_BILLING_SETUP_PUB;