DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKS_QP_INT_PVT

Source


1 PACKAGE BODY oks_qp_int_pvt AS
2 /* $Header: OKSQPRQB.pls 120.20.12020000.3 2012/11/28 08:22:41 spingali ship $ */
3 
4 ------------------------------------------------------------------------------
5 -- GLOBAL CONSTANTS
6 ------------------------------------------------------------------------------
7    g_module                       CONSTANT VARCHAR2 (250)
8                                          := 'oks.plsql.pricing.' ||
9                                             g_pkg_name ||
10                                             '.';
11    l_api_version                  CONSTANT NUMBER := 1.0;
12    l_init_msg_list                CONSTANT VARCHAR2 (1) := 'F';
13 
14    /* added for Repricing in a bulk method skuchima Bug:7539977*/
15 g_req_line_tbl_blk                 qp_preq_grp.line_tbl_type;
16 g_req_line_detail_tbl_blk          qp_preq_grp.line_detail_tbl_type;
17 g_req_related_lines_tbl_blk        qp_preq_grp.related_lines_tbl_type;
18 g_req_qual_tbl_blk                 qp_preq_grp.qual_tbl_type;
19 g_req_line_attr_tbl_blk            qp_preq_grp.line_attr_tbl_type;
20 g_req_line_detail_qual_tbl_blk     qp_preq_grp.line_detail_qual_tbl_type;
21 g_req_line_detail_attr_tbl_blk     qp_preq_grp.line_detail_attr_tbl_type;
22 g_line_tbl_ctr                      NUMBER:=0;
23 g_qual_tbl_ctr                     NUMBER:=0;
24 g_line_attr_tbl_ctr                NUMBER:=0;
25 g_line_detail_tbl_ctr              NUMBER:=0;
26 g_related_lines_tbl_ctr          NUMBER:=0;
27 
28 gx_req_line_tbl                   qp_preq_grp.line_tbl_type;
29 gx_req_qual_tbl                   qp_preq_grp.qual_tbl_type;
30 gx_req_line_attr_tbl              qp_preq_grp.line_attr_tbl_type;
31 gx_req_line_detail_tbl            qp_preq_grp.line_detail_tbl_type;
32 gx_req_line_detail_qual_tbl       qp_preq_grp.line_detail_qual_tbl_type;
33 gx_req_line_detail_attr_tbl       qp_preq_grp.line_detail_attr_tbl_type;
34 gx_req_related_lines_tbl          qp_preq_grp.related_lines_tbl_type;
35 
36    FUNCTION get_line_no (
37       p_line_id                       IN       NUMBER
38    )
39       RETURN VARCHAR2
40    IS
41       l_api_name                     CONSTANT VARCHAR2 (30) := 'get_line_no';
42 
43       CURSOR l_line_details_csr (
44          p_line_id                                NUMBER
45       )
46       IS
47          SELECT lse_id,
48                 line_number
49            FROM okc_k_lines_b
50           WHERE ID = p_line_id;
51 
52       CURSOR l_line_no_csr (
53          p_subline_id                             NUMBER
54       )
55       IS
56          SELECT b.line_number ||
57                 '.' ||
58                 a.line_number line_no
59            FROM okc_k_lines_b a,
60                 okc_k_lines_b b
61           WHERE a.ID = p_subline_id
62             AND a.cle_id = b.ID;
63 
64       l_lse_id                                NUMBER;
65       l_line_number                           VARCHAR2 (300);
66    BEGIN
67       -- start debug log
68       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
69       THEN
70          fnd_log.STRING (fnd_log.level_procedure,
71                          g_module ||
72                          l_api_name,
73                          '100: Entered ' ||
74                          g_pkg_name ||
75                          '.' ||
76                          l_api_name
77                         );
78       END IF;
79 
80       OPEN l_line_details_csr (p_line_id);
81 
82       FETCH l_line_details_csr
83        INTO l_lse_id,
84             l_line_number;
85 
86       IF l_line_details_csr%NOTFOUND
87       THEN
88          CLOSE l_line_details_csr;
89 
90          -- end debug log
91          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
92          THEN
93             fnd_log.STRING (fnd_log.level_procedure,
94                             g_module ||
95                             l_api_name,
96                             '1000: Leaving ' ||
97                             g_pkg_name ||
98                             '.' ||
99                             l_api_name
100                            );
101          END IF;
102 
103          RETURN NULL;
104       END IF;
105 
106       CLOSE l_line_details_csr;
107 
108       IF l_lse_id = 46
109       THEN
110          -- end debug log
111          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
112          THEN
113             fnd_log.STRING (fnd_log.level_procedure,
114                             g_module ||
115                             l_api_name,
116                             '1000: Leaving ' ||
117                             g_pkg_name ||
118                             '.' ||
119                             l_api_name
120                            );
121          END IF;
122 
123          RETURN l_line_number;
124       ELSIF l_lse_id IN (7, 9, 25)
125       THEN
126          OPEN l_line_no_csr (p_line_id);
127 
128          FETCH l_line_no_csr
129           INTO l_line_number;
130 
131          IF l_line_no_csr%NOTFOUND
132          THEN
133             CLOSE l_line_no_csr;
134 
135             -- end debug log
136             IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
137             THEN
138                fnd_log.STRING (fnd_log.level_procedure,
139                                g_module ||
140                                l_api_name,
141                                '1000: Leaving ' ||
142                                g_pkg_name ||
143                                '.' ||
144                                l_api_name
145                               );
146             END IF;
147 
148             RETURN NULL;
149          END IF;
150 
151          CLOSE l_line_no_csr;
152 
153          -- end debug log
154          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
155          THEN
156             fnd_log.STRING (fnd_log.level_procedure,
157                             g_module ||
158                             l_api_name,
159                             '1000: Leaving ' ||
160                             g_pkg_name ||
161                             '.' ||
162                             l_api_name
163                            );
164          END IF;
165 
166          RETURN l_line_number;
167       ELSE
168          -- end debug log
169          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
170          THEN
171             fnd_log.STRING (fnd_log.level_procedure,
172                             g_module ||
173                             l_api_name,
174                             '1000: Leaving ' ||
175                             g_pkg_name ||
176                             '.' ||
177                             l_api_name
178                            );
179          END IF;
180 
181          RETURN NULL;
182       END IF;
183    END;
184 
185   -- Function to get discount amount for sublines or subscription lines
186   FUNCTION get_subline_discount(p_subline_id IN NUMBER) RETURN NUMBER IS
187     CURSOR cs_subline_discount (cp_subline_id IN NUMBER) IS
188       SELECT kle.lse_id,
189              (NVL(cleb.toplvl_adj_price,0) - NVL(kle.line_list_price,0)) * cleb.toplvl_price_qty discount
190       FROM okc_k_lines_b kle,
191            oks_k_lines_b cleb
192       WHERE kle.ID = cp_subline_id
193         AND kle.ID = cleb.cle_id
194         AND NVL(kle.line_list_price, 0) > NVL(cleb.toplvl_adj_price,0);
195     CURSOR cs_subline_qty (cp_subline_id IN NUMBER) IS
196       SELECT number_of_items subline_qty
197       FROM okc_k_items
198       WHERE cle_id = cp_subline_id;
199     l_api_name    CONSTANT VARCHAR2 (30) := 'get_subline_discount';
200     l_discount    NUMBER := 0;
201     l_subline_qty NUMBER := 0;
202     l_lse_id      NUMBER;
203   BEGIN
204     IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
205       fnd_log.string(fnd_log.level_procedure,
206                      g_module||l_api_name,
207                      'Entered '||g_pkg_name||'.'||l_api_name);
208     END IF;
209 
210     OPEN cs_subline_discount (p_subline_id);
211     FETCH cs_subline_discount INTO l_lse_id, l_discount;
212     CLOSE cs_subline_discount;
213     IF l_lse_id <> 46 THEN
214       OPEN cs_subline_qty (p_subline_id);
215       FETCH cs_subline_qty INTO l_subline_qty;
216       CLOSE cs_subline_qty;
217       l_discount  := l_discount * l_subline_qty;
218     END IF;
219 
220     IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
221       fnd_log.string(fnd_log.level_procedure,
222                      g_module||l_api_name,
223                      'Leaving '||g_pkg_name||'.'||l_api_name);
224     END IF;
225 
226     RETURN ROUND (l_discount, 29);
227   END get_subline_discount;
228 
229   -- Function to get surcharge amount for sublines or subscription lines
230   FUNCTION get_subline_surcharge(p_subline_id IN NUMBER) RETURN NUMBER IS
231     CURSOR cs_subline_surcharge(cp_subline_id IN NUMBER) IS
232       SELECT kle.lse_id,
233              (NVL(cleb.toplvl_adj_price,0) - NVL(kle.line_list_price,0)) * cleb.toplvl_price_qty surcharge
234       FROM okc_k_lines_b kle,
235            oks_k_lines_b cleb
236       WHERE kle.ID = cp_subline_id
237         AND kle.ID = cleb.cle_id
238         AND NVL (kle.line_list_price, 0) < NVL (cleb.toplvl_adj_price, 0);
239     CURSOR cs_subline_qty(cp_subline_id IN NUMBER) IS
240       SELECT number_of_items subline_qty
241       FROM okc_k_items
242       WHERE cle_id = cp_subline_id;
243     l_api_name    CONSTANT VARCHAR2(30):= 'get_subline_surcharge';
244     l_surcharge   NUMBER := 0;
245     l_subline_qty NUMBER := 0;
246     l_lse_id      NUMBER;
247   BEGIN
248     IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
249       fnd_log.STRING(fnd_log.level_procedure,
250                      g_module||l_api_name,
251                      'Entered '||g_pkg_name||'.'||l_api_name);
252     END IF;
253 
254     OPEN cs_subline_surcharge (p_subline_id);
255     FETCH cs_subline_surcharge INTO l_lse_id, l_surcharge;
256     CLOSE cs_subline_surcharge;
257     IF l_lse_id <> 46 THEN
258       OPEN cs_subline_qty (p_subline_id);
259       FETCH cs_subline_qty INTO l_subline_qty;
260       CLOSE cs_subline_qty;
261       l_surcharge := l_surcharge * l_subline_qty;
262     END IF;
263 
264     IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
265       fnd_log.STRING(fnd_log.level_procedure,
266                      g_module||l_api_name,
267                      'Leaving '||g_pkg_name ||'.' ||l_api_name);
268     END IF;
269 
270     RETURN ROUND (l_surcharge, 29);
271   END;
272 
273 -- function to get topline discount
274    FUNCTION get_topline_discount (
275       p_topline_id                    IN       NUMBER
276    )
277       RETURN NUMBER
278    IS
279       l_api_name                     CONSTANT VARCHAR2 (30)
280                                                     := 'GET_TOPLINE_DISCOUNT';
281 
282       CURSOR cs_subline (
283          cp_cle_id                                NUMBER
284       )
285       IS
286          SELECT ID,
287                 lse_id
288            FROM okc_k_lines_b
289           WHERE cle_id = cp_cle_id;
290 
291       l_lse_id                                NUMBER;
292       l_topline_discount                      NUMBER;
293       l_topline_yn                            VARCHAR2 (1) := 'N';
294    BEGIN
295       -- start debug log
296       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
297       THEN
298          fnd_log.STRING (fnd_log.level_procedure,
299                          g_module ||
300                          l_api_name,
301                          '100: Entered ' ||
302                          g_pkg_name ||
303                          '.' ||
304                          l_api_name
305                         );
306       END IF;
307 
308       --   open cs_topline(p_topline_id);
309       --   fetch cs_topline into l_lse_id;
310       --   if l_lse_id = '46' -- subcription line then
311       --   then
312       --     l_topline_discount := get_subscrp_discount(p_topline_id);
313       --   else -- calculate for it's subline.
314       l_topline_discount         := 0;
315 
316       FOR l_subline IN cs_subline (p_topline_id)
317       LOOP
318          l_topline_yn               := 'Y';
319          l_topline_discount         :=
320                      l_topline_discount +
321                      get_subline_discount (l_subline.ID);
322       END LOOP;
323 
324       IF l_topline_yn = 'N'
325       THEN
326          l_topline_discount         := get_subline_discount (p_topline_id);
327       END IF;
328 
329       --   end if;
330 
331       -- end debug log
332       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
333       THEN
334          fnd_log.STRING (fnd_log.level_procedure,
335                          g_module ||
336                          l_api_name,
337                          '1000: Leaving ' ||
338                          g_pkg_name ||
339                          '.' ||
340                          l_api_name
341                         );
342       END IF;
343 
344       RETURN ROUND (l_topline_discount, 29);
345    END;
346 
347 -- function to get topline surcharge
348    FUNCTION get_topline_surcharge (
349       p_topline_id                    IN       NUMBER
350    )
351       RETURN NUMBER
352    IS
353       l_api_name                     CONSTANT VARCHAR2 (30)
354                                                    := 'GET_TOPLINE_SURCHARGE';
355 
356       CURSOR cs_subline (
357          cp_cle_id                                NUMBER
358       )
359       IS
360          SELECT ID,
361                 lse_id
362            FROM okc_k_lines_b
363           WHERE cle_id = cp_cle_id;
364 
365       l_lse_id                                NUMBER;
366       l_topline_surcharge                     NUMBER;
367       l_topline_yn                            VARCHAR2 (1) := 'N';
368    BEGIN
369       -- start debug log
370       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
371       THEN
372          fnd_log.STRING (fnd_log.level_procedure,
373                          g_module ||
374                          l_api_name,
375                          '100: Entered ' ||
376                          g_pkg_name ||
377                          '.' ||
378                          l_api_name
379                         );
380       END IF;
381 
382       --   open cs_topline(p_topline_id);
383       --   fetch cs_topline into l_lse_id;
384       --   if l_lse_id = '46' -- subcription line then
385       --   then
386       --     l_topline_surcharge := get_subscrp_surcharge(p_topline_id);
387       --   else -- calculate for it's subline.
388       l_topline_surcharge        := 0;
389 
390       FOR l_subline IN cs_subline (p_topline_id)
391       LOOP
392          l_topline_yn               := 'Y';
393          l_topline_surcharge        :=
394                    l_topline_surcharge +
395                    get_subline_surcharge (l_subline.ID);
396       END LOOP;
397 
398       IF l_topline_yn = 'N'
399       THEN
400          l_topline_surcharge        := get_subline_surcharge (p_topline_id);
401       END IF;
402 
403       --   end if;
404               -- end debug log
405       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
406       THEN
407          fnd_log.STRING (fnd_log.level_procedure,
408                          g_module ||
409                          l_api_name,
410                          '1000: Leaving ' ||
411                          g_pkg_name ||
412                          '.' ||
413                          l_api_name
414                         );
415       END IF;
416 
417       RETURN ROUND (l_topline_surcharge, 29);
418    END;
419 
420 /** 3912685 **/
421    PROCEDURE check_pricing_eligibility (
422       p_line_id                       IN       NUMBER,
423       x_status                        OUT NOCOPY VARCHAR2,
424       x_return_status                 OUT NOCOPY VARCHAR2,
425       x_msg_count                     OUT NOCOPY NUMBER,
426       x_msg_data                      OUT NOCOPY VARCHAR2
427    )
428    IS
429       l_api_name                     CONSTANT VARCHAR2 (30)
430                                                := 'CHECK_PRICING_ELIGIBILITY';
431 
432       CURSOR l_line_csr (
433          p_line_id                                NUMBER
434       )
435       IS
436          SELECT lse_id,
437                 start_date,
438                 end_date,
439                 date_terminated,
440                 dnz_chr_id
441            FROM okc_k_lines_b
442           WHERE ID = p_line_id;
443 
444       l_line_rec                              l_line_csr%ROWTYPE;
445       l_kln_rec_in                            oks_contract_line_pub.klnv_rec_type;
446       l_kln_rec_out                           oks_contract_line_pub.klnv_rec_type;
447       l_k_det_rec                             k_details_rec;
448 --   l_rule_rec           OKC_RUL_PVT.rulv_rec_type;
449       l_billed_date                           DATE;
450    BEGIN
451       -- start debug log
452       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
453       THEN
454          fnd_log.STRING (fnd_log.level_procedure,
455                          g_module ||
456                          l_api_name,
457                          '100: Entered ' ||
458                          g_pkg_name ||
459                          '.' ||
460                          l_api_name
461                         );
462       END IF;
463 
464       x_return_status            := g_ret_sts_success;
465 
466       OPEN l_line_csr (p_line_id);
467 
468       FETCH l_line_csr
469        INTO l_line_rec;
470 
471       IF l_line_csr%NOTFOUND
472       THEN
473          CLOSE l_line_csr;
474 
475          x_return_status            := g_ret_sts_error;
476          RAISE g_exc_error;
477       END IF;
478 
479       CLOSE l_line_csr;
480 
481       IF l_line_rec.lse_id = g_subscription
482       THEN
483          l_billed_date              :=
484             oks_bill_util_pub.get_billed_upto (p_id                               => p_line_id,
485                                                p_level                            => 'T');
486       ELSE
487          l_billed_date              :=
488             oks_bill_util_pub.get_billed_upto (p_id                               => p_line_id,
489                                                p_level                            => 'S');
490       END IF;
491 
492       /** Bug 4194843 **/
493       x_status                   := g_oks_success;
494 
495       IF l_billed_date IS NOT NULL
496       THEN
497          /** Bug 4194843 **/
498          IF NVL (l_line_rec.date_terminated, l_line_rec.end_date) <
499                                    NVL (l_billed_date, l_line_rec.start_date)
500          THEN
501             x_status                   := g_partial_billed;
502             get_k_details (p_id                               => p_line_id,
503                            p_type                             => g_oks_line,
504                            x_k_det_rec                        => l_k_det_rec
505                           );
506             l_kln_rec_in.ID            := l_k_det_rec.ID;
507             l_kln_rec_in.status_text   := g_billed_line;
508             l_kln_rec_in.object_version_number :=
509                                              l_k_det_rec.object_version_number;
510             oks_contract_line_pub.update_line
511                                           (p_api_version                      => l_api_version,
512                                            p_init_msg_list                    => l_init_msg_list,
513                                            x_return_status                    => x_return_status,
514                                            x_msg_count                        => x_msg_count,
515                                            x_msg_data                         => x_msg_data,
516                                            p_klnv_rec                         => l_kln_rec_in,
517                                            x_klnv_rec                         => l_kln_rec_out,
518                                            p_validate_yn                      => 'N'
519                                           );
520 
521             IF x_return_status <> g_ret_sts_success
522             THEN
523                RAISE g_exc_error;
524             END IF;
525          ELSIF trunc(NVL (l_line_rec.date_terminated, l_line_rec.end_date)) =
526                                     trunc(NVL (l_billed_date, l_line_rec.start_date))
527          THEN
528             x_status                   := g_fully_billed;
529             get_k_details (p_id                               => p_line_id,
530                            p_type                             => g_oks_line,
531                            x_k_det_rec                        => l_k_det_rec
532                           );
533             l_kln_rec_in.ID            := l_k_det_rec.ID;
534             l_kln_rec_in.status_text   := g_billed_line;
535             l_kln_rec_in.object_version_number :=
536                                              l_k_det_rec.object_version_number;
537             oks_contract_line_pub.update_line
538                                           (p_api_version                      => l_api_version,
539                                            p_init_msg_list                    => l_init_msg_list,
540                                            x_return_status                    => x_return_status,
541                                            x_msg_count                        => x_msg_count,
542                                            x_msg_data                         => x_msg_data,
543                                            p_klnv_rec                         => l_kln_rec_in,
544                                            x_klnv_rec                         => l_kln_rec_out,
545                                            p_validate_yn                      => 'N'
546                                           );
547          ELSE
548             x_status                   := g_oks_success;
549          END IF;
550       /** Bug 4194843 **/
551       END IF;
552    /** Bug 4194843 **/
553    EXCEPTION
554       WHEN g_exc_error
555       THEN
556          -- end debug log
557          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
558          THEN
559             fnd_log.STRING (fnd_log.level_procedure,
560                             g_module ||
561                             l_api_name,
562                             '2000: Leaving ' ||
563                             g_pkg_name ||
564                             '.' ||
565                             l_api_name
566                            );
567          END IF;
568 
569          NULL;
570       WHEN OTHERS
571       THEN
572          -- end debug log
573          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
574          THEN
575             fnd_log.STRING (fnd_log.level_procedure,
576                             g_module ||
577                             l_api_name,
578                             '4000: Leaving ' ||
579                             g_pkg_name ||
580                             '.' ||
581                             l_api_name
582                            );
583          END IF;
584 
585          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
586          x_return_status            := g_ret_sts_error;
587 
588          -- end debug log
589          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
590          THEN
591             fnd_log.STRING (fnd_log.level_procedure,
592                             g_module ||
593                             l_api_name,
594                             '1000: Leaving ' ||
595                             g_pkg_name ||
596                             '.' ||
597                             l_api_name
598                            );
599          END IF;
600    END check_pricing_eligibility;
601 
602 /**  **/
603    PROCEDURE get_modifier_details (
604       p_api_version                   IN       NUMBER,
605       p_init_msg_list                 IN       VARCHAR2,
606       p_chr_id                        IN       NUMBER,
607       p_cle_id                        IN       VARCHAR2,
608       x_modifiers_tbl                 OUT NOCOPY price_modifiers_tbl,
609       x_return_status                 OUT NOCOPY VARCHAR2,
610       x_msg_count                     OUT NOCOPY NUMBER,
611       x_msg_data                      OUT NOCOPY VARCHAR2
612    )
613    IS
614       l_api_name                     CONSTANT VARCHAR2 (30)
615                                                     := 'GET_MODIFIER_DETAILS';
616 
617       CURSOR cs_hdr_line
618       IS
619          SELECT ID
620            FROM okc_k_lines_b
621           WHERE dnz_chr_id = p_chr_id
622             AND cle_id IS NULL;
623 
624       l_line_discount                         NUMBER;
625       l_line_surcharge                        NUMBER;
626       l_hdr_discount                          NUMBER;
627       l_hdr_surcharge                         NUMBER;
628    BEGIN
629       -- start debug log
630       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
631       THEN
632          fnd_log.STRING (fnd_log.level_procedure,
633                          g_module ||
634                          l_api_name,
635                          '100: Entered ' ||
636                          g_pkg_name ||
637                          '.' ||
638                          l_api_name
639                         );
640       END IF;
641 
642       x_return_status            := g_ret_sts_success;
643 
644       IF p_cle_id IS NOT NULL
645       THEN
646          x_modifiers_tbl (1).discount := get_topline_discount (p_cle_id);
647          x_modifiers_tbl (1).surcharge := get_topline_surcharge (p_cle_id);
648       ELSIF p_chr_id IS NOT NULL
649       THEN
650          l_hdr_discount             := 0;
651          l_hdr_surcharge            := 0;
652 
653          FOR l_hdr_line_rec IN cs_hdr_line
654          LOOP
655             l_hdr_discount             :=
656                     l_hdr_discount +
657                     get_topline_discount (l_hdr_line_rec.ID);
658             l_hdr_surcharge            :=
659                    l_hdr_surcharge +
660                    get_topline_surcharge (l_hdr_line_rec.ID);
661          END LOOP;
662 
663          x_modifiers_tbl (1).discount := l_hdr_discount;
664          x_modifiers_tbl (1).surcharge := l_hdr_surcharge;
665       ELSE
666          x_modifiers_tbl (1).discount := NULL;
667          x_modifiers_tbl (1).surcharge := NULL;
668          x_modifiers_tbl (1).total  := NULL;
669          x_return_status            := g_ret_sts_error;
670          RAISE g_exc_error;
671       END IF;
672 
673       x_modifiers_tbl (1).total  :=
674                   x_modifiers_tbl (1).surcharge +
675                   x_modifiers_tbl (1).discount;
676 
677       -- end debug log
678       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
679       THEN
680          fnd_log.STRING (fnd_log.level_procedure,
681                          g_module ||
682                          l_api_name,
683                          '1000: Leaving ' ||
684                          g_pkg_name ||
685                          '.' ||
686                          l_api_name
687                         );
688       END IF;
689    EXCEPTION
690       WHEN NO_DATA_FOUND
691       THEN
692          -- end debug log
693          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
694          THEN
695             fnd_log.STRING (fnd_log.level_procedure,
696                             g_module ||
697                             l_api_name,
698                             '5000: Leaving ' ||
699                             g_pkg_name ||
700                             '.' ||
701                             l_api_name
702                            );
703          END IF;
704 
705          x_modifiers_tbl (1).discount := 0;
706          x_modifiers_tbl (1).surcharge := 0;
707          x_modifiers_tbl (1).total  := 0;
708       WHEN g_exc_error
709       THEN
710          -- end debug log
711          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
712          THEN
713             fnd_log.STRING (fnd_log.level_procedure,
714                             g_module ||
715                             l_api_name,
716                             '2000: Leaving ' ||
717                             g_pkg_name ||
718                             '.' ||
719                             l_api_name
720                            );
721          END IF;
722 
723          NULL;
724       WHEN OTHERS
725       THEN
726          -- end debug log
727          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
728          THEN
729             fnd_log.STRING (fnd_log.level_procedure,
730                             g_module ||
731                             l_api_name,
732                             '4000: Leaving ' ||
733                             g_pkg_name ||
734                             '.' ||
735                             l_api_name
736                            );
737          END IF;
738 
739          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
740          x_return_status            := g_ret_sts_unexp_error;
741          okc_api.set_message (p_app_name                         => g_app_name,
742                               p_msg_name                         => g_unexpected_error,
743                               p_token1                           => g_sqlcode_token,
744                               p_token1_value                     => SQLCODE,
745                               p_token2                           => g_sqlerrm_token,
746                               p_token2_value                     => SQLERRM
747                              );
748    END get_modifier_details;
749 
750    PROCEDURE get_k_details (
751       p_id                            IN       NUMBER,
752       p_type                          IN       VARCHAR2,
753       x_k_det_rec                     OUT NOCOPY k_details_rec
754    )
755    IS
756       l_api_name                     CONSTANT VARCHAR2 (30)
757                                                            := 'GET_K_DETAILS';
758 
759       CURSOR l_okc_chr_csr (
760          p_id                                     NUMBER
761       )
762       IS
763          SELECT ID,
764                 object_version_number
765            FROM okc_k_headers_all_b
766           WHERE ID = p_id;
767 
768       CURSOR l_okc_cle_csr (
769          p_id                                     NUMBER
770       )
771       IS
772          SELECT ID,
773                 object_version_number
774            FROM okc_k_lines_b
775           WHERE ID = p_id;
776 
777       CURSOR l_oks_chr_csr (
778          p_id                                     NUMBER
779       )
780       IS
781          SELECT ID,
782                 object_version_number
783            FROM oks_k_headers_b
784           WHERE chr_id = p_id;
785 
786       CURSOR l_oks_cle_csr (
787          p_id                                     NUMBER
788       )
789       IS
790          SELECT ID,
791                 object_version_number
792            FROM oks_k_lines_b
793           WHERE cle_id = p_id;
794    BEGIN
795       -- start debug log
796       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
797       THEN
798          fnd_log.STRING (fnd_log.level_procedure,
799                          g_module ||
800                          l_api_name,
801                          '100: Entered ' ||
802                          g_pkg_name ||
803                          '.' ||
804                          l_api_name
805                         );
806       END IF;
807 
808       IF p_type = g_okc_hdr
809       THEN
810          OPEN l_okc_chr_csr (p_id);
811 
812          FETCH l_okc_chr_csr
813           INTO x_k_det_rec;
814 
815          IF l_okc_chr_csr%NOTFOUND
816          THEN
817             x_k_det_rec.ID             := NULL;
818             x_k_det_rec.object_version_number := NULL;
819          END IF;
820 
821          CLOSE l_okc_chr_csr;
822       ELSIF p_type = g_okc_line
823       THEN
824          OPEN l_okc_cle_csr (p_id);
825 
826          FETCH l_okc_cle_csr
827           INTO x_k_det_rec;
828 
829          IF l_okc_cle_csr%NOTFOUND
830          THEN
831             x_k_det_rec.ID             := NULL;
832             x_k_det_rec.object_version_number := NULL;
833          END IF;
834 
835          CLOSE l_okc_cle_csr;
836       ELSIF p_type = g_oks_hdr
837       THEN
838          OPEN l_oks_chr_csr (p_id);
839 
840          FETCH l_oks_chr_csr
841           INTO x_k_det_rec;
842 
843          IF l_oks_chr_csr%NOTFOUND
844          THEN
845             x_k_det_rec.ID             := NULL;
846             x_k_det_rec.object_version_number := NULL;
847          END IF;
848 
849          CLOSE l_oks_chr_csr;
850       ELSIF p_type = g_oks_line
851       THEN
852          OPEN l_oks_cle_csr (p_id);
853 
854          FETCH l_oks_cle_csr
855           INTO x_k_det_rec;
856 
857          IF l_oks_cle_csr%NOTFOUND
858          THEN
859             x_k_det_rec.ID             := NULL;
860             x_k_det_rec.object_version_number := NULL;
861          END IF;
862 
863          CLOSE l_oks_cle_csr;
864       END IF;
865 
866       -- end debug log
867       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
868       THEN
869          fnd_log.STRING (fnd_log.level_procedure,
870                          g_module ||
871                          l_api_name,
872                          '1000: Leaving ' ||
873                          g_pkg_name ||
874                          '.' ||
875                          l_api_name
876                         );
877       END IF;
878    END get_k_details;
879 
880    PROCEDURE get_id (
881       p_line_id                       IN       NUMBER,
882       x_chr_id                        OUT NOCOPY NUMBER,
883       x_topline_id                    OUT NOCOPY NUMBER,
884       x_return_status                 OUT NOCOPY VARCHAR2
885    )
886    IS
887       l_api_name                     CONSTANT VARCHAR2 (30) := 'GET_ID';
888 
889       CURSOR l_line_csr (
890          p_line_id                                NUMBER
891       )
892       IS
893          SELECT dnz_chr_id,
894                 cle_id
895            FROM okc_k_lines_b
896           WHERE ID = p_line_id;
897    BEGIN
898       -- start debug log
899       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
900       THEN
901          fnd_log.STRING (fnd_log.level_procedure,
902                          g_module ||
903                          l_api_name,
904                          '100: Entered ' ||
905                          g_pkg_name ||
906                          '.' ||
907                          l_api_name
908                         );
909       END IF;
910 
911       x_return_status            := g_ret_sts_success;
912 
913       OPEN l_line_csr (p_line_id);
914 
915       FETCH l_line_csr
916        INTO x_chr_id,
917             x_topline_id;
918 
919       IF l_line_csr%NOTFOUND
920       THEN
921          CLOSE l_line_csr;
922 
923          x_return_status            := g_ret_sts_error;
924       END IF;
925 
926       CLOSE l_line_csr;
927 
928       -- end debug log
929       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
930       THEN
931          fnd_log.STRING (fnd_log.level_procedure,
932                          g_module ||
933                          l_api_name,
934                          '1000: Leaving ' ||
935                          g_pkg_name ||
936                          '.' ||
937                          l_api_name
938                         );
939       END IF;
940    EXCEPTION
941       WHEN OTHERS
942       THEN
943          -- end debug log
944          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
945          THEN
946             fnd_log.STRING (fnd_log.level_procedure,
947                             g_module ||
948                             l_api_name,
949                             '4000: Leaving ' ||
950                             g_pkg_name ||
951                             '.' ||
952                             l_api_name
953                            );
954          END IF;
955 
956          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
957 
958          CLOSE l_line_csr;
959 
960          x_return_status            := okc_api.g_ret_sts_warning;
961    END;
962 
963    FUNCTION is_subs_item (
964       p_subline_id                             NUMBER
965    )
966       RETURN BOOLEAN
967    IS
968       l_api_name                     CONSTANT VARCHAR2 (30) := 'IS_SUBS_ITEM';
969 
970       CURSOR l_subscr_item_csr (
971          p_subline_id                             NUMBER
972       )
973       IS
974          SELECT 'x'
975            FROM okc_k_lines_b kl,
976                 okc_k_items ki,
977                 oks_subscr_header_b sh
978           WHERE kl.ID = p_subline_id
979             AND ki.cle_id = kl.ID
980             AND sh.instance_id = ki.object1_id1;
981 
982       l_dummy                                 VARCHAR2 (1);
983       l_return                                BOOLEAN;
984    BEGIN
985       -- start debug log
986       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
987       THEN
988          fnd_log.STRING (fnd_log.level_procedure,
989                          g_module ||
990                          l_api_name,
991                          '100: Entered ' ||
992                          g_pkg_name ||
993                          '.' ||
994                          l_api_name
995                         );
996       END IF;
997 
998       OPEN l_subscr_item_csr (p_subline_id);
999 
1000       FETCH l_subscr_item_csr
1001        INTO l_dummy;
1002 
1003       IF l_subscr_item_csr%FOUND
1004       THEN
1005          l_return                   := TRUE;
1006       ELSE
1007          l_return                   := FALSE;
1008       END IF;
1009 
1010       CLOSE l_subscr_item_csr;
1011 
1012       -- end debug log
1013       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1014       THEN
1015          fnd_log.STRING (fnd_log.level_procedure,
1016                          g_module ||
1017                          l_api_name,
1018                          '1000: Leaving ' ||
1019                          g_pkg_name ||
1020                          '.' ||
1021                          l_api_name
1022                         );
1023       END IF;
1024 
1025       RETURN (l_return);
1026    END is_subs_item;
1027 
1028    PROCEDURE get_line_details (
1029       p_line_id                       IN       NUMBER,
1030       x_name                          OUT NOCOPY VARCHAR2,
1031       x_description                   OUT NOCOPY VARCHAR2,
1032       x_return_status                 OUT NOCOPY VARCHAR2,
1033       x_msg_count                     OUT NOCOPY NUMBER,
1034       x_msg_data                      OUT NOCOPY VARCHAR2
1035    )
1036    IS
1037       l_api_name                     CONSTANT VARCHAR2 (30)
1038                                                         := 'GET_LINE_DETAILS';
1039 
1040       CURSOR l_line_csr
1041       IS
1042          SELECT cle_id,
1043                 lse_id,
1044                 dnz_chr_id
1045            FROM okc_k_lines_b
1046           WHERE ID = p_line_id;
1047 
1048       CURSOR l_item_csr (
1049          c_cle_id                                 NUMBER
1050       )
1051       IS
1052          SELECT object1_id1,
1053                 object1_id2
1054            FROM okc_k_items
1055           WHERE cle_id = c_cle_id;
1056 
1057       CURSOR l_cii_csr (
1058          c_instance_id                            NUMBER
1059       )
1060       IS
1061          SELECT inventory_item_id
1062            FROM csi_item_instances
1063           WHERE instance_id = c_instance_id;
1064 
1065       CURSOR l_hdr_csr (
1066          c_chr_id                                 NUMBER
1067       )
1068       IS
1069          SELECT inv_organization_id
1070            FROM okc_k_headers_all_b
1071           WHERE ID = c_chr_id;
1072 
1073       CURSOR l_mtl_csr (
1074          c_item_id                                NUMBER,
1075          c_inv_org_id                             NUMBER
1076       )
1077       IS
1078          SELECT concatenated_segments,
1079                 description
1080            FROM mtl_system_items_kfv
1081           WHERE inventory_item_id = c_item_id
1082             AND organization_id = c_inv_org_id;
1083 
1084       l_profile_value                         VARCHAR2 (240)
1085                           := fnd_profile.VALUE ('OKS_ITEM_DISPLAY_PREFERENCE');
1086       l_cle_id                                NUMBER;
1087       l_lse_id                                NUMBER;
1088       l_dnz_chr_id                            NUMBER;
1089       l_inv_org_id                            NUMBER;
1090       l_object1_id1                           okc_k_items.object1_id1%TYPE;
1091       l_object1_id2                           okc_k_items.object1_id2%TYPE;
1092       l_inventory_item_id                     NUMBER;
1093       l_item_cle_id                           NUMBER;
1094       l_name                                  VARCHAR2 (1000);
1095       l_description                           VARCHAR2 (1000);
1096    BEGIN
1097       -- start debug log
1098       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1099       THEN
1100          fnd_log.STRING (fnd_log.level_procedure,
1101                          g_module ||
1102                          l_api_name,
1103                          '100: Entered ' ||
1104                          g_pkg_name ||
1105                          '.' ||
1106                          l_api_name
1107                         );
1108       END IF;
1109 
1110       x_return_status            := g_ret_sts_success;
1111 
1112       OPEN l_line_csr;
1113 
1114       FETCH l_line_csr
1115        INTO l_cle_id,
1116             l_lse_id,
1117             l_dnz_chr_id;
1118 
1119       CLOSE l_line_csr;
1120 
1121       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1122       THEN
1123          fnd_log.STRING (fnd_log.level_statement,
1124                          g_module ||
1125                          l_api_name,
1126                          '200:l_cle_id: ' ||
1127                          l_cle_id
1128                         );
1129          fnd_log.STRING (fnd_log.level_statement,
1130                          g_module ||
1131                          l_api_name,
1132                          '201:l_lse_id: ' ||
1133                          l_lse_id
1134                         );
1135          fnd_log.STRING (fnd_log.level_statement,
1136                          g_module ||
1137                          l_api_name,
1138                          '202:l_dnz_chr_id: ' ||
1139                          l_dnz_chr_id
1140                         );
1141       END IF;
1142 
1143       -- errorout('l_cle_id: ' || l_cle_id);
1144       -- errorout('l_lse_id: ' || l_lse_id);
1145       -- errorout('l_dnz_chr_id: ' || l_dnz_chr_id);
1146       OPEN l_hdr_csr (l_dnz_chr_id);
1147 
1148       FETCH l_hdr_csr
1149        INTO l_inv_org_id;
1150 
1151       CLOSE l_hdr_csr;
1152 
1153       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1154       THEN
1155          fnd_log.STRING (fnd_log.level_statement,
1156                          g_module ||
1157                          l_api_name,
1158                          '203:l_inv_org_id: ' ||
1159                          l_inv_org_id
1160                         );
1161       END IF;
1162 
1163       -- errorout('l_inv_org_id: ' || l_inv_org_id);
1164       OPEN l_item_csr (p_line_id);
1165 
1166       FETCH l_item_csr
1167        INTO l_object1_id1,
1168             l_object1_id2;
1169 
1170       CLOSE l_item_csr;
1171 
1172       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1173       THEN
1174          fnd_log.STRING (fnd_log.level_statement,
1175                          g_module ||
1176                          l_api_name,
1177                          '204:object1_id1: ' ||
1178                          l_object1_id1
1179                         );
1180          fnd_log.STRING (fnd_log.level_statement,
1181                          g_module ||
1182                          l_api_name,
1183                          '205:object1_id2: ' ||
1184                          l_object1_id2
1185                         );
1186       END IF;
1187 
1188       -- errorout('object1_id1: ' || l_object1_id1);
1189       -- errorout('object1_id2: ' || l_object1_id2);
1190       IF    l_cle_id IS NULL
1191          OR l_lse_id = 7
1192       THEN
1193          OPEN l_mtl_csr (l_object1_id1, l_object1_id2);
1194 
1195          FETCH l_mtl_csr
1196           INTO l_name,
1197                l_description;
1198 
1199          CLOSE l_mtl_csr;
1200       ELSE
1201          OPEN l_cii_csr (l_object1_id1);
1202 
1203          FETCH l_cii_csr
1204           INTO l_inventory_item_id;
1205 
1206          CLOSE l_cii_csr;
1207 
1208          OPEN l_mtl_csr (l_inventory_item_id, l_inv_org_id);
1209 
1210          FETCH l_mtl_csr
1211           INTO l_name,
1212                l_description;
1213 
1214          CLOSE l_mtl_csr;
1215       END IF;
1216 
1217       IF l_cle_id IS NULL
1218       THEN
1219          x_name                     := l_name;
1220          x_description              := l_description;
1221       ELSE
1222          IF l_profile_value = 'DISPLAY_DESC'
1223          THEN
1224             x_name                     := l_description;
1225             x_description              := l_name;
1226          ELSIF l_profile_value = 'DISPLAY_NAME'
1227          THEN
1228             x_name                     := l_name;
1229             x_description              := l_description;
1230          END IF;
1231       END IF;
1232 
1233       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1234       THEN
1235          fnd_log.STRING (fnd_log.level_statement,
1236                          g_module ||
1237                          l_api_name,
1238                          '206:x_name: ' ||
1239                          x_name
1240                         );
1241          fnd_log.STRING (fnd_log.level_statement,
1242                          g_module ||
1243                          l_api_name,
1244                          '207:x_desc: ' ||
1245                          x_description
1246                         );
1247       END IF;
1248 
1249       -- errorout('x_name: ' || x_name);
1250       -- errorout('x_desc: ' || x_description);
1251 
1252       -- end debug log
1253       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1254       THEN
1255          fnd_log.STRING (fnd_log.level_procedure,
1256                          g_module ||
1257                          l_api_name,
1258                          '1000: Leaving ' ||
1259                          g_pkg_name ||
1260                          '.' ||
1261                          l_api_name
1262                         );
1263       END IF;
1264    EXCEPTION
1265       WHEN OTHERS
1266       THEN
1267          -- end debug log
1268          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1269          THEN
1270             fnd_log.STRING (fnd_log.level_procedure,
1271                             g_module ||
1272                             l_api_name,
1273                             '4000: Leaving ' ||
1274                             g_pkg_name ||
1275                             '.' ||
1276                             l_api_name
1277                            );
1278          END IF;
1279 
1280          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1281          x_return_status            := g_ret_sts_unexp_error;
1282          okc_api.set_message (p_app_name                         => g_app_name,
1283                               p_msg_name                         => g_unexpected_error,
1284                               p_token1                           => g_sqlcode_token,
1285                               p_token1_value                     => SQLCODE,
1286                               p_token2                           => g_sqlerrm_token,
1287                               p_token2_value                     => SQLERRM
1288                              );
1289    END get_line_details;
1290 
1291    FUNCTION get_pricing_messages
1292       RETURN pricing_status_tbl
1293    IS
1294       l_api_name                     CONSTANT VARCHAR2 (30)
1295                                                     := 'GET_PRICING_MESSAGES';
1296    BEGIN
1297       -- start debug log
1298       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1299       THEN
1300          fnd_log.STRING (fnd_log.level_procedure,
1301                          g_module ||
1302                          l_api_name,
1303                          '100: Entered ' ||
1304                          g_pkg_name ||
1305                          '.' ||
1306                          l_api_name
1307                         );
1308       END IF;
1309 
1310       -- end debug log
1311       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1312       THEN
1313          fnd_log.STRING (fnd_log.level_procedure,
1314                          g_module ||
1315                          l_api_name,
1316                          '1000: Leaving ' ||
1317                          g_pkg_name ||
1318                          '.' ||
1319                          l_api_name
1320                         );
1321       END IF;
1322 
1323       RETURN (g_pricing_status_tbl);
1324    END;
1325 
1326    FUNCTION get_amounts (
1327       p_id                            IN       NUMBER,
1328       p_level                         IN       VARCHAR2
1329    )
1330       RETURN NUMBER
1331    IS
1332       l_api_name                     CONSTANT VARCHAR2 (30) := 'GET_AMOUNTS';
1333 
1334       CURSOR l_line_csr (
1335          p_line_id                                NUMBER
1336       )
1337       IS
1338          SELECT SUM (price_negotiated) amount
1339            FROM okc_k_lines_b
1340           WHERE cle_id = p_line_id
1341             AND chr_id IS NULL
1342             AND lse_id IN (7, 8, 9, 10, 11, 18, 25, 35)
1343 	    AND date_cancelled IS NULL;  -- bug 4870602
1344 
1345       CURSOR l_hdr_csr (
1346          p_chr_id                                 NUMBER
1347       )
1348       IS
1349          SELECT SUM (price_negotiated) amount
1350            FROM okc_k_lines_b
1351           WHERE chr_id = p_chr_id
1352             AND cle_id IS NULL
1353             AND date_cancelled IS NULL;  -- bug 4870602
1354 
1355       l_amount                                NUMBER := 0;
1356    BEGIN
1357       -- start debug log
1358       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1359       THEN
1360          fnd_log.STRING (fnd_log.level_procedure,
1361                          g_module ||
1362                          l_api_name,
1363                          '100: Entered ' ||
1364                          g_pkg_name ||
1365                          '.' ||
1366                          l_api_name
1367                         );
1368       END IF;
1369 
1370       IF p_level = g_hdr_level
1371       THEN
1372          OPEN l_hdr_csr (p_id);
1373 
1374          FETCH l_hdr_csr
1375           INTO l_amount;
1376 
1377          IF l_hdr_csr%NOTFOUND
1378          THEN
1379             l_amount                   := 0;
1380          END IF;
1381 
1382          CLOSE l_hdr_csr;
1383       ELSIF p_level = g_line_level
1384       THEN
1385          OPEN l_line_csr (p_id);
1386 
1387          FETCH l_line_csr
1388           INTO l_amount;
1389 
1390          IF l_line_csr%NOTFOUND
1391          THEN
1392             l_amount                   := 0;
1393          END IF;
1394 
1395          CLOSE l_line_csr;
1396       ELSE
1397          l_amount                   := 0;
1398       END IF;
1399 
1400       -- end debug log
1401       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1402       THEN
1403          fnd_log.STRING (fnd_log.level_procedure,
1404                          g_module ||
1405                          l_api_name,
1406                          '1000: Leaving ' ||
1407                          g_pkg_name ||
1408                          '.' ||
1409                          l_api_name
1410                         );
1411       END IF;
1412 
1413       RETURN l_amount;
1414    END get_amounts;
1415 
1416    PROCEDURE qualifier_party_merge (
1417       p_from_fk_id                    IN       NUMBER,
1418       p_to_fk_id                      IN       NUMBER,
1419       x_return_status                 OUT NOCOPY VARCHAR2
1420    )
1421    IS
1422       l_api_name                     CONSTANT VARCHAR2 (30)
1423                                                    := 'QUALIFIER_PARTY_MERGE';
1424       l_count                                 NUMBER;
1425       l_proc_name                             VARCHAR2 (240)
1426                                                    := 'QUALIFIER_PARTY_MERGE';
1427    BEGIN
1428       -- start debug log
1429       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1430       THEN
1431          fnd_log.STRING (fnd_log.level_procedure,
1432                          g_module ||
1433                          l_api_name,
1434                          '100: Entered ' ||
1435                          g_pkg_name ||
1436                          '.' ||
1437                          l_api_name
1438                         );
1439       END IF;
1440 
1441       x_return_status            := okc_api.g_ret_sts_success;
1442 
1443       UPDATE oks_qualifiers
1444          SET qualifier_attr_value = TO_CHAR (p_to_fk_id),
1445              last_update_date = hz_utility_pub.last_update_date,
1446              last_updated_by = hz_utility_pub.user_id,
1447              last_update_login = hz_utility_pub.last_update_login,
1448              request_id = hz_utility_pub.request_id,
1449              program_application_id = hz_utility_pub.program_application_id,
1450              program_id = hz_utility_pub.program_id,
1451              program_update_date = SYSDATE
1452        WHERE qualifier_attr_value = TO_CHAR (p_from_fk_id);
1453 
1454       l_count                    := SQL%ROWCOUNT;
1455       arp_message.set_name ('AR', 'AR_ROWS_UPDATED');
1456       arp_message.set_token ('NUM_ROWS', TO_CHAR (l_count));
1457 
1458       -- end debug log
1459       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1460       THEN
1461          fnd_log.STRING (fnd_log.level_procedure,
1462                          g_module ||
1463                          l_api_name,
1464                          '1000: Leaving ' ||
1465                          g_pkg_name ||
1466                          '.' ||
1467                          l_api_name
1468                         );
1469       END IF;
1470    EXCEPTION
1471       WHEN OTHERS
1472       THEN
1473          -- end debug log
1474          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1475          THEN
1476             fnd_log.STRING (fnd_log.level_procedure,
1477                             g_module ||
1478                             l_api_name,
1479                             '4000: Leaving ' ||
1480                             g_pkg_name ||
1481                             '.' ||
1482                             l_api_name
1483                            );
1484          END IF;
1485 
1486          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1487          x_return_status            := fnd_api.g_ret_sts_error;
1488          arp_message.set_line (g_pkg_name ||
1489                                '.' ||
1490                                l_proc_name ||
1491                                ': ' ||
1492                                SQLERRM);
1493    END qualifier_party_merge;
1494 
1495    PROCEDURE qualifier_account_merge (
1496       req_id                                   NUMBER,
1497       set_num                                  NUMBER
1498    )
1499    IS
1500       l_api_name                     CONSTANT VARCHAR2 (30)
1501                                                  := 'QUALIFIER_ACCOUNT_MERGE';
1502 
1503       TYPE merge_header_id_list_type IS TABLE OF ra_customer_merge_headers.customer_merge_header_id%TYPE
1504          INDEX BY BINARY_INTEGER;
1505 
1506       merge_header_id_list                    merge_header_id_list_type;
1507 
1508       TYPE qualifier_id_list_type IS TABLE OF oks_qualifiers.qualifier_id%TYPE
1509          INDEX BY BINARY_INTEGER;
1510 
1511       primary_key_id1_list                    qualifier_id_list_type;
1512 
1513       TYPE qualifier_attr_value_list_type IS TABLE OF oks_qualifiers.qualifier_attr_value%TYPE
1514          INDEX BY BINARY_INTEGER;
1515 
1516       vchar_col1_orig_list                    qualifier_attr_value_list_type;
1517       vchar_col1_new_list                     qualifier_attr_value_list_type;
1518       l_profile_val                           VARCHAR2 (30);
1519 
1520       CURSOR merged_records
1521       IS
1522          SELECT DISTINCT customer_merge_header_id,
1523                          qualifier_id,
1524                          qualifier_attr_value
1525                     FROM oks_qualifiers yt,
1526                          ra_customer_merges m
1527                    WHERE (yt.qualifier_attr_value = m.duplicate_site_id)
1528                      AND m.process_flag = 'N'
1529                      AND m.request_id = req_id
1530                      AND m.set_number = set_num;
1531 
1532       l_last_fetch                            BOOLEAN := FALSE;
1533       l_count                                 NUMBER;
1534       l_proc_name                             VARCHAR2 (240)
1535                                                   := 'QUALIFIER_ACCOUNT_MERGE';
1536    BEGIN
1537       -- start debug log
1538       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1539       THEN
1540          fnd_log.STRING (fnd_log.level_procedure,
1541                          g_module ||
1542                          l_api_name,
1543                          '100: Entered ' ||
1544                          g_pkg_name ||
1545                          '.' ||
1546                          l_api_name
1547                         );
1548       END IF;
1549 
1550       arp_message.set_name ('AR', 'AR_UPDATING_TABLE');
1551       arp_message.set_token ('TABLE_NAME',
1552                              'OKS_QUALIFIERS',
1553                              FALSE
1554                             );
1555       hz_acct_merge_util.load_set (set_num, req_id);
1556       l_profile_val              := fnd_profile.VALUE ('HZ_AUDIT_ACCT_MERGE');
1557 
1558       OPEN merged_records;
1559 
1560       LOOP
1561          FETCH merged_records
1562          BULK COLLECT INTO merge_header_id_list,
1563                 primary_key_id1_list,
1564                 vchar_col1_orig_list;
1565 
1566          IF merged_records%NOTFOUND
1567          THEN
1568             l_last_fetch               := TRUE;
1569          END IF;
1570 
1571          IF     merge_header_id_list.COUNT = 0
1572             AND l_last_fetch
1573          THEN
1574             -- end debug log
1575             IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1576             THEN
1577                fnd_log.STRING (fnd_log.level_procedure,
1578                                g_module ||
1579                                l_api_name,
1580                                '1000: Leaving ' ||
1581                                g_pkg_name ||
1582                                '.' ||
1583                                l_api_name
1584                               );
1585             END IF;
1586 
1587             EXIT;
1588          END IF;
1589 
1590          FOR i IN 1 .. merge_header_id_list.COUNT
1591          LOOP
1592             vchar_col1_new_list (i)    :=
1593                 hz_acct_merge_util.getdup_site_use (vchar_col1_orig_list (i));
1594          END LOOP;
1595 
1596          IF     l_profile_val IS NOT NULL
1597             AND l_profile_val = 'Y'
1598          THEN
1599             FORALL i IN 1 .. merge_header_id_list.COUNT
1600                INSERT INTO hz_customer_merge_log
1601                            (merge_log_id,
1602                             table_name,
1603                             merge_header_id,
1604                             primary_key_id1,
1605                             vchar_col1_orig,
1606                             vchar_col1_new,
1607                             action_flag,
1608                             request_id,
1609                             created_by,
1610                             creation_date,
1611                             last_update_login,
1612                             last_update_date,
1613                             last_updated_by
1614                            )
1615                     VALUES (hz_customer_merge_log_s.NEXTVAL,
1616                             'OKS_QUALIFIERS',
1617                             merge_header_id_list (i),
1618                             primary_key_id1_list (i),
1619                             vchar_col1_orig_list (i),
1620                             vchar_col1_new_list (i),
1621                             'U',
1622                             req_id,
1623                             hz_utility_pub.created_by,
1624                             hz_utility_pub.creation_date,
1625                             hz_utility_pub.last_update_login,
1626                             hz_utility_pub.last_update_date,
1627                             hz_utility_pub.last_updated_by
1628                            );
1629          END IF;
1630 
1631          FORALL i IN 1 .. merge_header_id_list.COUNT
1632             UPDATE oks_qualifiers yt
1633                SET qualifier_attr_value = vchar_col1_new_list (i),
1634                    last_update_date = SYSDATE,
1635                    last_updated_by = arp_standard.PROFILE.user_id,
1636                    last_update_login = arp_standard.PROFILE.last_update_login,
1637                    request_id = req_id
1638              WHERE qualifier_id = primary_key_id1_list (i);
1639          l_count                    := l_count +
1640                                        SQL%ROWCOUNT;
1641 
1642          IF l_last_fetch
1643          THEN
1644             EXIT;
1645          END IF;
1646       END LOOP;
1647 
1648       arp_message.set_name ('AR', 'AR_ROWS_UPDATED');
1649       arp_message.set_token ('NUM_ROWS', TO_CHAR (l_count));
1650 
1651       -- end debug log
1652       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1653       THEN
1654          fnd_log.STRING (fnd_log.level_procedure,
1655                          g_module ||
1656                          l_api_name,
1657                          '1000: Leaving ' ||
1658                          g_pkg_name ||
1659                          '.' ||
1660                          l_api_name
1661                         );
1662       END IF;
1663    EXCEPTION
1664       WHEN OTHERS
1665       THEN
1666          -- end debug log
1667          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1668          THEN
1669             fnd_log.STRING (fnd_log.level_procedure,
1670                             g_module ||
1671                             l_api_name,
1672                             '4000: Leaving ' ||
1673                             g_pkg_name ||
1674                             '.' ||
1675                             l_api_name
1676                            );
1677          END IF;
1678 
1679          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1680          arp_message.set_line (g_pkg_name ||
1681                                '.' ||
1682                                l_proc_name ||
1683                                ': ' ||
1684                                SQLERRM);
1685          RAISE;
1686    END qualifier_account_merge;
1687 
1688    PROCEDURE calculate_subscription_price (
1689       p_detail_rec                    IN       oks_qp_pkg.input_details,
1690       x_price_details                 OUT NOCOPY oks_qp_pkg.price_details,
1691       x_modifier_details              OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
1692       x_price_break_details           OUT NOCOPY oks_qp_pkg.g_price_break_tbl_type,
1693       x_return_status                 OUT NOCOPY VARCHAR2,
1694       x_msg_count                     OUT NOCOPY NUMBER,
1695       x_msg_data                      OUT NOCOPY VARCHAR2
1696    )
1697    IS
1698       l_api_name                     CONSTANT VARCHAR2 (30)
1699                                             := 'CALCULATE_SUBSCRIPTION_PRICE';
1700 
1701       CURSOR l_currcode_csr (
1702          p_hdr_id                                 NUMBER
1703       )
1704       IS
1705          SELECT currency_code
1706            FROM okc_k_headers_all_b
1707           WHERE ID = p_hdr_id;
1708 
1709       CURSOR l_line_details_csr (
1710          p_cle_id                                 NUMBER
1711       )
1712       IS
1713          SELECT ID,
1714                 start_date,
1715                 end_date,
1716                 lse_id,
1717                 dnz_chr_id,
1718                 price_negotiated,
1719                 price_unit,
1720                 price_unit_percent,
1721                 price_list_line_id,
1722                 price_list_id,
1723                 line_list_price,
1724                 item_to_price_yn,
1725                 pricing_date,
1726                 price_basis_yn,
1727                 object_version_number
1728            FROM okc_k_lines_b
1729           WHERE ID = p_cle_id
1730             AND lse_id = 46;
1731 
1732       CURSOR l_subs_elements_csr (
1733          p_line_id                                NUMBER
1734       )
1735       IS
1736          SELECT ID,
1737                 osh_id,
1738                 dnz_chr_id,
1739                 dnz_cle_id,
1740                 linked_flag,
1741                 seq_no,
1742                 om_interface_date,
1743                 amount,
1744                 start_date,
1745                 end_date,
1746                 quantity,
1747                 uom_code,
1748                 order_header_id,
1749                 order_line_id,
1750                 object_version_number
1751            FROM oks_subscr_elements
1752           WHERE dnz_cle_id = p_line_id;
1753 
1754       l_line_details_rec                      l_line_details_csr%ROWTYPE;
1755       l_input_detail_rec                      oks_qp_pkg.input_details
1756                                                                := p_detail_rec;
1757       l_rail_rec                              oks_tax_util_pvt.ra_rec_type;
1758       l_k_det_rec                             k_details_rec;
1759       l_khdr_rec_in                           oks_contract_hdr_pub.khrv_rec_type;
1760       l_khdr_rec_out                          oks_contract_hdr_pub.khrv_rec_type;
1761       l_kln_rec_in                            oks_contract_line_pub.klnv_rec_type;
1762       l_kln_rec_out                           oks_contract_line_pub.klnv_rec_type;
1763       l_clev_rec_in                           okc_contract_pub.clev_rec_type;
1764       l_clev_rec_out                          okc_contract_pub.clev_rec_type;
1765       l_scev_rec_in                           oks_subscr_elems_pub.scev_rec_type;
1766       l_scev_rec_out                          oks_subscr_elems_pub.scev_rec_type;
1767       l_qpprod_quantity                       NUMBER;
1768       l_qpprod_uom_code                       VARCHAR2 (240);
1769       l_tlvl_name                             VARCHAR2 (800);
1770       l_tlvl_desc                             VARCHAR2 (1000);
1771       l_return_status                         VARCHAR2 (1);
1772       l_line_no                               VARCHAR2 (300);
1773       l_status                                VARCHAR2 (30);         --3912685
1774    BEGIN
1775       -- start debug log
1776       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1777       THEN
1778          fnd_log.STRING (fnd_log.level_procedure,
1779                          g_module ||
1780                          l_api_name,
1781                          '100: Entered ' ||
1782                          g_pkg_name ||
1783                          '.' ||
1784                          l_api_name
1785                         );
1786       END IF;
1787 
1788       x_return_status            := g_ret_sts_success;
1789 
1790       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1791       THEN
1792          fnd_log.STRING (fnd_log.level_statement,
1793                          g_module ||
1794                          l_api_name,
1795                          '300:********** Entered Subscription Price ********'
1796                         );
1797          fnd_log.STRING (fnd_log.level_statement,
1798                          g_module ||
1799                          l_api_name,
1800                          '301:CHR_ID            = ' ||
1801                          p_detail_rec.chr_id
1802                         );
1803          fnd_log.STRING (fnd_log.level_statement,
1804                          g_module ||
1805                          l_api_name,
1806                          '302:LINE_ID           = ' ||
1807                          p_detail_rec.line_id
1808                         );
1809          fnd_log.STRING (fnd_log.level_statement,
1810                          g_module ||
1811                          l_api_name,
1812                          '303:SUBLINE_ID        = ' ||
1813                          p_detail_rec.subline_id
1814                         );
1815          fnd_log.STRING (fnd_log.level_statement,
1816                          g_module ||
1817                          l_api_name,
1818                          '304:INTENT            = ' ||
1819                          p_detail_rec.intent
1820                         );
1821          fnd_log.STRING (fnd_log.level_statement,
1822                          g_module ||
1823                          l_api_name,
1824                          '305:CURRENCY          = ' ||
1825                          p_detail_rec.currency
1826                         );
1827          fnd_log.STRING (fnd_log.level_statement,
1828                          g_module ||
1829                          l_api_name,
1830                          '306:Usage Qty         = ' ||
1831                          p_detail_rec.usage_qty
1832                         );
1833          fnd_log.STRING (fnd_log.level_statement,
1834                          g_module ||
1835                          l_api_name,
1836                          '307:Usage UOM Code    = ' ||
1837                          p_detail_rec.usage_uom_code
1838                         );
1839       END IF;
1840 
1841       --errorout ('********** Entered Subscription Price ********');
1842       --errorout ('CHR_ID            = ' || p_detail_rec.chr_id);
1843       --errorout ('LINE_ID           = ' || p_detail_rec.line_id);
1844       --errorout ('SUBLINE_ID        = ' || p_detail_rec.subline_id);
1845       --errorout ('INTENT            = ' || p_detail_rec.intent);
1846       --errorout ('CURRENCY          = ' || p_detail_rec.currency);
1847       --errorout ('Usage Qty         = ' || p_detail_rec.usage_qty);
1848       --errorout ('Usage UOM Code    = ' || p_detail_rec.usage_uom_code);
1849 
1850       /** 3912685 **/
1851       check_pricing_eligibility (p_line_id                          => p_detail_rec.line_id,
1852                                  x_status                           => l_status,
1853                                  x_return_status                    => x_return_status,
1854                                  x_msg_count                        => x_msg_count,
1855                                  x_msg_data                         => x_msg_data
1856                                 );
1857 
1858       IF x_return_status <> g_ret_sts_success
1859       THEN
1860          RAISE g_exc_error;
1861       END IF;
1862 
1863       IF l_status <> g_oks_success
1864       THEN
1865          x_price_details.status_code := l_status;
1866          RAISE g_exc_cant_price;
1867       END IF;
1868 
1869       /** **/
1870       IF p_detail_rec.intent = g_subsc_ovr_pricing
1871       THEN
1872          -- Get Price negotiated amount
1873          OPEN l_line_details_csr (p_detail_rec.line_id);
1874 
1875          FETCH l_line_details_csr
1876           INTO l_line_details_rec;
1877 
1878          IF l_line_details_csr%NOTFOUND
1879          THEN
1880             CLOSE l_line_details_csr;
1881 
1882             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1883             THEN
1884                fnd_log.STRING
1885                      (fnd_log.level_statement,
1886                       g_module ||
1887                       l_api_name,
1888                       '308:Negotiated amount ERROR at Calc Subscription call'
1889                      );
1890             END IF;
1891 
1892             --errorout('Negotiated amount ERROR at Calc Subscription call');
1893             RAISE g_exc_error;
1894          END IF;
1895 
1896          CLOSE l_line_details_csr;
1897 
1898          oks_subscription_pub.get_subs_qty
1899                                           (p_cle_id                           => p_detail_rec.line_id,
1900                                            x_return_status                    => x_return_status,
1901                                            x_quantity                         => l_qpprod_quantity,
1902                                            x_uom_code                         => l_qpprod_uom_code
1903                                           );
1904 
1905          IF x_return_status <> g_ret_sts_success
1906          THEN
1907             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1908             THEN
1909                fnd_log.STRING (fnd_log.level_statement,
1910                                g_module ||
1911                                l_api_name,
1912                                '309:UOM/QTY ERROR at Calc Subscription call'
1913                               );
1914             END IF;
1915 
1916             --errorout('UOM/QTY ERROR at Calc Subscription call');
1917             RAISE g_exc_error;
1918          END IF;
1919 
1920          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1921          THEN
1922             fnd_log.STRING (fnd_log.level_statement,
1923                             g_module ||
1924                             l_api_name,
1925                             '310:QTY = ' ||
1926                             l_qpprod_quantity ||
1927                             ' UOM = ' ||
1928                             l_qpprod_uom_code
1929                            );
1930          END IF;
1931 
1932          --errorout('QTY = '||l_qpprod_quantity || ' UOM = ' || l_qpprod_uom_code);
1933          IF NVL (fnd_profile.VALUE ('OKS_USE_QP_FOR_MANUAL_ADJ'), 'NO') =
1934                                                                          'YES'
1935          THEN
1936             IF    l_qpprod_quantity IS NULL
1937                OR l_qpprod_quantity = 0
1938             THEN
1939                l_input_detail_rec.asking_unit_price :=
1940                                           l_line_details_rec.price_negotiated;
1941             ELSE
1942                l_input_detail_rec.asking_unit_price :=
1943                       l_line_details_rec.price_negotiated /
1944                       l_qpprod_quantity;
1945             END IF;
1946 
1947             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1948             THEN
1949                fnd_log.STRING (fnd_log.level_statement,
1950                                g_module ||
1951                                l_api_name,
1952                                '311:Asking price = ' ||
1953                                l_input_detail_rec.asking_unit_price
1954                               );
1955             END IF;
1956 
1957             --errorout('Asking price = '||l_input_detail_rec.asking_unit_price);
1958             oks_qp_pkg.calc_price
1959                               (p_detail_rec                       => l_input_detail_rec,
1960                                x_price_details                    => x_price_details,
1961                                x_modifier_details                 => x_modifier_details,
1962                                x_price_break_details              => x_price_break_details,
1963                                x_return_status                    => x_return_status,
1964                                x_msg_count                        => x_msg_count,
1965                                x_msg_data                         => x_msg_data
1966                               );
1967 
1968             IF x_return_status <> g_ret_sts_success
1969             THEN
1970                IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
1971                   )
1972                THEN
1973                   fnd_log.STRING (fnd_log.level_procedure,
1974                                   g_module ||
1975                                   l_api_name,
1976                                   '101:CALC PRICE ERROR at 2nd SAPI call'
1977                                  );
1978                END IF;
1979 
1980                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
1981                   )
1982                THEN
1983                   fnd_log.STRING (fnd_log.level_statement,
1984                                   g_module ||
1985                                   l_api_name,
1986                                   '312:CALC PRICE ERROR at 2nd SAPI call'
1987                                  );
1988                END IF;
1989 
1990                --dbms_output.put_line('CALC PRICE ERROR at 2nd SAPI call');
1991                RAISE g_exc_error;
1992             END IF;
1993 
1994             x_price_details.serv_ext_amount := x_price_details.prod_ext_amount;
1995             l_rail_rec.amount          :=
1996                                       NVL (x_price_details.serv_ext_amount, 0);
1997          -- x_price_details.status_text         := NVL(x_price_details.status_text,G_STS_TXT_SUCCESS);
1998          ELSE
1999             IF l_input_detail_rec.currency IS NULL
2000             THEN
2001                OPEN l_currcode_csr (l_line_details_rec.dnz_chr_id);
2002 
2003                FETCH l_currcode_csr
2004                 INTO l_input_detail_rec.currency;
2005 
2006                CLOSE l_currcode_csr;
2007             END IF;
2008 
2009 /*Added for GSI Bug 14102072 */
2010 If nvl(FND_PROFILE.value('OKS_PRICE_ROUNDING'),'N') ='N' THEN
2011 
2012             -- bug 5018782, don't round any amount that we get from QP
2013             l_line_details_rec.price_negotiated :=  ROUND (l_line_details_rec.price_negotiated, 29);
2014    Else
2015 
2016            l_line_details_rec.price_negotiated :=
2017                oks_extwar_util_pvt.round_currency_amt
2018                              (p_amount                           => l_line_details_rec.price_negotiated,
2019                               p_currency_code                    => l_input_detail_rec.currency);
2020   End If;
2021 /*Added for GSI Bug 14102072 */
2022 
2023     x_price_details.serv_ext_amount :=
2024                                   NVL (l_line_details_rec.price_negotiated, 0);
2025             l_rail_rec.amount          :=
2026                                   NVL (l_line_details_rec.price_negotiated, 0);
2027             x_price_details.status_text := g_manual_adj_price;
2028 
2029             IF     NVL (l_line_details_rec.price_negotiated, 0) > 0
2030                AND l_qpprod_quantity > 0
2031             THEN
2032                x_price_details.prod_adj_unit_price :=
2033                   NVL (l_line_details_rec.price_negotiated, 0) /
2034                   l_qpprod_quantity;
2035             ELSE
2036                x_price_details.prod_adj_unit_price :=
2037                                  NVL (l_line_details_rec.price_negotiated, 0);
2038             END IF;
2039 
2040             x_price_details.prod_qty   := NULL;
2041             x_price_details.prod_qty_uom := NULL;
2042             x_price_details.prod_price_list_id := NULL;
2043             x_price_details.prod_list_unit_price := NULL;
2044             x_price_details.prod_adj_unit_price := NULL;
2045             x_price_details.prod_priced_qty := NULL;
2046             x_price_details.prod_priced_uom := NULL;
2047          END IF;
2048       ELSE
2049          oks_qp_pkg.calc_price
2050                              (p_detail_rec                       => l_input_detail_rec,
2051                               x_price_details                    => x_price_details,
2052                               x_modifier_details                 => x_modifier_details,
2053                               x_price_break_details              => x_price_break_details,
2054                               x_return_status                    => x_return_status,
2055                               x_msg_count                        => x_msg_count,
2056                               x_msg_data                         => x_msg_data
2057                              );
2058 
2059          IF x_return_status <> g_ret_sts_success
2060          THEN
2061             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2062             THEN
2063                fnd_log.STRING (fnd_log.level_statement,
2064                                g_module ||
2065                                l_api_name,
2066                                '313:CALC Price ERROR after SAPI call'
2067                               );
2068             END IF;
2069 
2070             --errorout('CALC Price ERROR after SAPI call');
2071             RAISE g_exc_error;
2072          END IF;
2073 
2074          x_price_details.serv_ext_amount := x_price_details.prod_ext_amount;
2075          l_rail_rec.amount          :=
2076                                       NVL (x_price_details.serv_ext_amount, 0);
2077       -- x_price_details.status_text          := NVL(x_price_details.status_text,G_STS_TXT_SUCCESS);
2078       END IF;
2079 
2080       x_price_details.serv_qty   := x_price_details.prod_qty;
2081       x_price_details.serv_qty_uom := x_price_details.prod_qty_uom;
2082       x_price_details.serv_price_list_id := x_price_details.prod_price_list_id;
2083       x_price_details.serv_list_unit_price :=
2084                                           x_price_details.prod_list_unit_price;
2085       x_price_details.serv_adj_unit_price :=
2086                                            x_price_details.prod_adj_unit_price;
2087       x_price_details.serv_priced_qty := x_price_details.prod_priced_qty;
2088       x_price_details.serv_priced_uom := x_price_details.prod_priced_uom;
2089       x_price_details.prod_qty   := NULL;
2090       x_price_details.prod_qty_uom := NULL;
2091       x_price_details.prod_price_list_id := NULL;
2092       x_price_details.prod_list_unit_price := NULL;
2093       x_price_details.prod_adj_unit_price := NULL;
2094       x_price_details.prod_priced_qty := NULL;
2095       x_price_details.prod_priced_uom := NULL;
2096       x_price_details.prod_ext_amount := NULL;
2097 
2098       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2099       THEN
2100          fnd_log.STRING (fnd_log.level_statement,
2101                          g_module ||
2102                          l_api_name,
2103                          '314:x_price_details.PROD_QTY = ' ||
2104                          x_price_details.prod_qty
2105                         );
2106          fnd_log.STRING (fnd_log.level_statement,
2107                          g_module ||
2108                          l_api_name,
2109                          '315:x_price_details.PROD_QTY_UOM = ' ||
2110                          x_price_details.prod_qty_uom
2111                         );
2112          fnd_log.STRING (fnd_log.level_statement,
2113                          g_module ||
2114                          l_api_name,
2115                          '316:x_price_details.SERV_QTY = ' ||
2116                          x_price_details.serv_qty
2117                         );
2118          fnd_log.STRING (fnd_log.level_statement,
2119                          g_module ||
2120                          l_api_name,
2121                          '317:x_price_details.SERV_QTY_UOM = ' ||
2122                          x_price_details.serv_qty_uom
2123                         );
2124          fnd_log.STRING (fnd_log.level_statement,
2125                          g_module ||
2126                          l_api_name,
2127                          '318:x_price_details.PROD_PRICE_LIST_ID = ' ||
2128                          x_price_details.prod_price_list_id
2129                         );
2130          fnd_log.STRING (fnd_log.level_statement,
2131                          g_module ||
2132                          l_api_name,
2133                          '319:x_price_details.SERV_PRICE_LIST_ID = ' ||
2134                          x_price_details.serv_price_list_id
2135                         );
2136          fnd_log.STRING (fnd_log.level_statement,
2137                          g_module ||
2138                          l_api_name,
2139                          '320:x_price_details.PROD_LIST_UNIT_PRICE = ' ||
2140                          x_price_details.prod_list_unit_price
2141                         );
2142          fnd_log.STRING (fnd_log.level_statement,
2143                          g_module ||
2144                          l_api_name,
2145                          '321:x_price_details.SERV_LIST_UNIT_PRICE = ' ||
2146                          x_price_details.serv_list_unit_price
2147                         );
2148          fnd_log.STRING (fnd_log.level_statement,
2149                          g_module ||
2150                          l_api_name,
2151                          '322:x_price_details.PROD_ADJ_UNIT_PRICE = ' ||
2152                          x_price_details.prod_adj_unit_price
2153                         );
2154          fnd_log.STRING (fnd_log.level_statement,
2155                          g_module ||
2156                          l_api_name,
2157                          '323:x_price_details.SERV_ADJ_UNIT_PRICE = ' ||
2158                          x_price_details.serv_adj_unit_price
2159                         );
2160          fnd_log.STRING (fnd_log.level_statement,
2161                          g_module ||
2162                          l_api_name,
2163                          '324:x_price_details.PROD_PRICED_QTY = ' ||
2164                          x_price_details.prod_priced_qty
2165                         );
2166          fnd_log.STRING (fnd_log.level_statement,
2167                          g_module ||
2168                          l_api_name,
2169                          '325:x_price_details.PROD_PRICED_UOM = ' ||
2170                          x_price_details.prod_priced_uom
2171                         );
2172          fnd_log.STRING (fnd_log.level_statement,
2173                          g_module ||
2174                          l_api_name,
2175                          '326:x_price_details.PROD_EXT_AMOUNT = ' ||
2176                          x_price_details.prod_ext_amount
2177                         );
2178          fnd_log.STRING (fnd_log.level_statement,
2179                          g_module ||
2180                          l_api_name,
2181                          '327:x_price_details.SERV_PRICED_QTY = ' ||
2182                          x_price_details.serv_priced_qty
2183                         );
2184          fnd_log.STRING (fnd_log.level_statement,
2185                          g_module ||
2186                          l_api_name,
2187                          '328:x_price_details.SERV_PRICED_UOM = ' ||
2188                          x_price_details.serv_priced_uom
2189                         );
2190          fnd_log.STRING (fnd_log.level_statement,
2191                          g_module ||
2192                          l_api_name,
2193                          '329:x_price_details.SERV_EXT_AMOUNT = ' ||
2194                          x_price_details.serv_ext_amount
2195                         );
2196          fnd_log.STRING (fnd_log.level_statement,
2197                          g_module ||
2198                          l_api_name,
2199                          '330:x_price_details.SERV_OPERAND = ' ||
2200                          x_price_details.serv_operand
2201                         );
2202          fnd_log.STRING (fnd_log.level_statement,
2203                          g_module ||
2204                          l_api_name,
2205                          '331:x_price_details.SERV_OPERATOR = ' ||
2206                          x_price_details.serv_operator
2207                         );
2208          fnd_log.STRING (fnd_log.level_statement,
2209                          g_module ||
2210                          l_api_name,
2211                          '332:x_price_details.STATUS_TEXT = ' ||
2212                          x_price_details.status_text
2213                         );
2214          fnd_log.STRING (fnd_log.level_statement,
2215                          g_module ||
2216                          l_api_name,
2217                          '333:l_rail_rec.amount = ' ||
2218                          l_rail_rec.amount
2219                         );
2220       END IF;
2221 
2222 --errorout('x_price_details.PROD_QTY = '            || x_price_details.PROD_QTY );
2223 --errorout('x_pri'ce_details.PROD_QTY_UOM = '       || x_price_details.PROD_QTY_UOM );
2224 --errorout('x_price_details.SERV_QTY = '            || x_price_details.SERV_QTY );
2225 --errorout('x_price_details.SERV_QTY_UOM = '        || x_price_details.SERV_QTY_UOM );
2226 --errorout('x_price_details.PROD_PRICE_LIST_ID = '  || x_price_details.PROD_PRICE_LIST_ID );
2227 --errorout('x_price_details.SERV_PRICE_LIST_ID = '  || x_price_details.SERV_PRICE_LIST_ID );
2228 --errorout('x_price_details.PROD_LIST_UNIT_PRICE = '|| x_price_details.PROD_LIST_UNIT_PRICE );
2229 --errorout('x_price_details.SERV_LIST_UNIT_PRICE = '|| x_price_details.SERV_LIST_UNIT_PRICE );
2230 --errorout('x_price_details.PROD_ADJ_UNIT_PRICE = ' || x_price_details.PROD_ADJ_UNIT_PRICE );
2231 --errorout('x_price_details.SERV_ADJ_UNIT_PRICE = ' || x_price_details.SERV_ADJ_UNIT_PRICE );
2232 --errorout('x_price_details.PROD_PRICED_QTY = '     || x_price_details.PROD_PRICED_QTY );
2233 --errorout('x_price_details.PROD_PRICED_UOM = '     || x_price_details.PROD_PRICED_UOM );
2234 --errorout('x_price_details.PROD_EXT_AMOUNT = '     || x_price_details.PROD_EXT_AMOUNT );
2235 --errorout('x_price_details.SERV_PRICED_QTY = '     || x_price_details.SERV_PRICED_QTY );
2236 --errorout('x_price_details.SERV_PRICED_UOM = '     || x_price_details.SERV_PRICED_UOM );
2237 --errorout('x_price_details.SERV_EXT_AMOUNT = '     || x_price_details.SERV_EXT_AMOUNT );
2238 --errorout('x_price_details.SERV_OPERAND = '        || x_price_details.SERV_OPERAND );
2239 --errorout('x_price_details.SERV_OPERATOR = '       || x_price_details.SERV_OPERATOR );
2240 --errorout('x_price_details.STATUS_TEXT = '         || x_price_details.STATUS_TEXT );
2241 --errorout('l_rail_rec.amount = '                   || l_rail_rec.amount);
2242       l_rail_rec.tax_value       := NULL;
2243       l_rail_rec.amount_includes_tax_flag := NULL;
2244       -- Calculate Tax
2245       oks_tax_util_pvt.get_tax (p_api_version                      => l_api_version,
2246                                 p_init_msg_list                    => l_init_msg_list,
2247                                 p_chr_id                           => l_input_detail_rec.chr_id,
2248                                 p_cle_id                           => l_input_detail_rec.line_id,
2249                                 px_rail_rec                        => l_rail_rec,
2250                                 x_msg_count                        => x_msg_count,
2251                                 x_msg_data                         => x_msg_data,
2252                                 x_return_status                    => x_return_status
2253                                );
2254 
2255       IF x_return_status <> g_ret_sts_success
2256       THEN
2257          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2258          THEN
2259             fnd_log.STRING (fnd_log.level_statement,
2260                             g_module ||
2261                             l_api_name,
2262                             '334:Tax ERROR after GET_TAX call x_return_status '||x_return_status
2263                            );
2264             fnd_log.STRING (fnd_log.level_statement,
2265                             g_module ||
2266                             l_api_name,
2267                             '334:x_msg_data '||x_msg_data
2268                            );
2269          END IF;
2270 
2271          --errorout('Tax ERROR after GET_TAX call');
2272          -- bug 5001677, even if tax error continue
2273          -- RAISE g_exc_error;
2274          l_rail_rec.tax_value                :=  0;
2275          l_rail_rec.amount_includes_tax_flag := 'N';
2276       END IF;
2277 
2278       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2279       THEN
2280          fnd_log.STRING (fnd_log.level_statement,
2281                          g_module ||
2282                          l_api_name,
2283                          '336:l_rail_rec.TAX_VALUE = ' ||
2284                          l_rail_rec.tax_value
2285                         );
2286          fnd_log.STRING (fnd_log.level_statement,
2287                          g_module ||
2288                          l_api_name,
2289                          '337:l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = ' ||
2290                          l_rail_rec.amount_includes_tax_flag
2291                         );
2292       END IF;
2293 
2294 --errorout('l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = '||l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG );
2295 --errorout('l_rail_rec.TAX_VALUE = '||  l_rail_rec.TAX_VALUE );
2296 --errorout('l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = '||l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG );
2297       l_kln_rec_in.cle_id        := l_input_detail_rec.line_id;
2298       l_kln_rec_in.dnz_chr_id    := l_input_detail_rec.chr_id;
2299       l_kln_rec_in.tax_inclusive_yn := l_rail_rec.amount_includes_tax_flag;
2300 
2301       IF l_rail_rec.amount_includes_tax_flag = 'N'
2302       THEN
2303          l_kln_rec_in.tax_amount    := NVL (l_rail_rec.tax_value, 0);
2304       ELSE
2305          l_kln_rec_in.tax_amount    := 0;
2306       END IF;
2307 
2308       IF x_price_details.prod_price_list_id IS NOT NULL
2309       THEN
2310          l_kln_rec_in.prod_price    := x_price_details.prod_price_list_id;
2311       END IF;
2312 
2313       IF x_price_details.serv_price_list_id IS NOT NULL
2314       THEN
2315          l_kln_rec_in.service_price := x_price_details.serv_price_list_id;
2316       END IF;
2317 
2318       l_kln_rec_in.clvl_list_price := x_price_details.prod_list_unit_price;
2319       l_kln_rec_in.clvl_quantity := x_price_details.prod_priced_qty;
2320       l_kln_rec_in.clvl_extended_amt := x_price_details.prod_ext_amount;
2321       l_kln_rec_in.toplvl_operand_code := x_price_details.serv_operator;
2322       l_kln_rec_in.toplvl_operand_val := x_price_details.serv_operand;
2323       l_kln_rec_in.clvl_uom_code := x_price_details.prod_priced_uom;
2324       l_kln_rec_in.toplvl_quantity := x_price_details.serv_qty;
2325       l_kln_rec_in.toplvl_uom_code := x_price_details.serv_priced_uom;
2326       l_kln_rec_in.toplvl_adj_price := x_price_details.serv_adj_unit_price;
2327       -- GCHADHA --
2328       -- 17-NOV-2004 --
2329       -- BUG 4015739 --
2330       l_kln_rec_in.status_text   :=
2331          SUBSTR (NVL (x_price_details.status_text, g_sts_txt_success),
2332                  1,
2333                  450
2334                 );
2335       -- l_kln_rec_in.status_text         := NVL(x_price_details.status_text,G_STS_TXT_SUCCESS);
2336 
2337       -- END GCHADHA --
2338    --   l_kln_rec_in.toplvl_price_qty := x_price_details.serv_priced_qty;
2339 
2340    --VRM skuchima bug#14576343
2341         IF  x_price_details.serv_priced_qty IS NOT NULL THEN
2342 
2343           l_kln_rec_in.toplvl_price_qty := x_price_details.serv_priced_qty;
2344 
2345         END IF;
2346 
2347       get_k_details (p_id                               => l_input_detail_rec.line_id,
2348                      p_type                             => g_oks_line,
2349                      x_k_det_rec                        => l_k_det_rec
2350                     );
2351       l_kln_rec_in.ID            := l_k_det_rec.ID;
2352       l_kln_rec_in.object_version_number := l_k_det_rec.object_version_number;
2353       oks_contract_line_pub.update_line (p_api_version                      => l_api_version,
2354                                          p_init_msg_list                    => l_init_msg_list,
2355                                          x_return_status                    => x_return_status,
2356                                          x_msg_count                        => x_msg_count,
2357                                          x_msg_data                         => x_msg_data,
2358                                          p_klnv_rec                         => l_kln_rec_in,
2359                                          x_klnv_rec                         => l_kln_rec_out,
2360                                          p_validate_yn                      => 'N'
2361                                         );
2362 
2363       IF x_return_status <> g_ret_sts_success
2364       THEN
2365          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2366          THEN
2367             fnd_log.STRING (fnd_log.level_statement,
2368                             g_module ||
2369                             l_api_name,
2370                             '338:Update line details at Calc Subscription'
2371                            );
2372          END IF;
2373 
2374          -- errorout('Update line details at Calc Subscription');
2375          RAISE g_exc_error;
2376       END IF;
2377 
2378       l_clev_rec_in.ID           := l_input_detail_rec.line_id;
2379       l_clev_rec_in.line_list_price := x_price_details.serv_list_unit_price;
2380       l_clev_rec_in.price_negotiated := l_rail_rec.amount;
2381       get_k_details (p_id                               => l_input_detail_rec.line_id,
2382                      p_type                             => g_okc_line,
2383                      x_k_det_rec                        => l_k_det_rec
2384                     );
2385       l_clev_rec_in.object_version_number := l_k_det_rec.object_version_number;
2386       okc_contract_pub.update_contract_line
2387                                           (p_api_version                      => l_api_version,
2388                                            p_init_msg_list                    => l_init_msg_list,
2389                                            x_return_status                    => x_return_status,
2390                                            x_msg_count                        => x_msg_count,
2391                                            x_msg_data                         => x_msg_data,
2392                                            p_clev_rec                         => l_clev_rec_in,
2393                                            x_clev_rec                         => l_clev_rec_out
2394                                           );
2395 
2396       IF x_return_status <> g_ret_sts_success
2397       THEN
2398          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2399          THEN
2400             fnd_log.STRING
2401                        (fnd_log.level_statement,
2402                         g_module ||
2403                         l_api_name,
2404                         '339:Update Contract line ERROR at Calc Subscription'
2405                        );
2406          END IF;
2407 
2408          -- errorout('Update Contract line ERROR at Calc Subscription');
2409          RAISE g_exc_error;
2410       END IF;
2411 
2412       -- Update Subsciption elements
2413       FOR l_subs_elements_rec IN l_subs_elements_csr (p_detail_rec.line_id)
2414       LOOP
2415          l_scev_rec_in.ID           := l_subs_elements_rec.ID;
2416          l_scev_rec_in.amount       :=
2417             l_subs_elements_rec.quantity *
2418             x_price_details.serv_adj_unit_price;
2419          l_scev_rec_in.object_version_number :=
2420                                      l_subs_elements_rec.object_version_number;
2421 
2422          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2423          THEN
2424             fnd_log.STRING (fnd_log.level_statement,
2425                             g_module ||
2426                             l_api_name,
2427                             '340:Subscription element ID : ' ||
2428                             l_scev_rec_in.ID
2429                            );
2430             fnd_log.STRING (fnd_log.level_statement,
2431                             g_module ||
2432                             l_api_name,
2433                             '341:Subscription element Amt : ' ||
2434                             l_scev_rec_in.amount
2435                            );
2436          END IF;
2437 
2438          -- errorout('Subscription element ID : ' || l_scev_rec_in.id);
2439          -- errorout('Subscription element Amt : ' || l_scev_rec_in.amount);
2440          oks_subscr_elems_pub.update_row (p_api_version                      => l_api_version,
2441                                           p_init_msg_list                    => l_init_msg_list,
2442                                           x_return_status                    => x_return_status,
2443                                           x_msg_count                        => x_msg_count,
2444                                           x_msg_data                         => x_msg_data,
2445                                           p_scev_rec                         => l_scev_rec_in,
2446                                           x_scev_rec                         => l_scev_rec_out
2447                                          );
2448 
2449          IF x_return_status <> g_ret_sts_success
2450          THEN
2451             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2452             THEN
2453                fnd_log.STRING
2454                   (fnd_log.level_statement,
2455                    g_module ||
2456                    l_api_name,
2457                    '342:ERROR while updating Subscription elements at Calc Subscription'
2458                   );
2459             END IF;
2460 
2461             -- errorout('ERROR while updating Subscription elements at Calc Subscription');
2462             RAISE g_exc_error;
2463          END IF;
2464       END LOOP;
2465 
2466       -- If request coming from Header pricing, populate the message table
2467       IF p_detail_rec.intent = g_subsc_reg_pricing
2468       THEN
2469          -- Get subscription line details
2470          get_line_details (p_line_id                          => l_input_detail_rec.line_id,
2471                            x_name                             => l_tlvl_name,
2472                            x_description                      => l_tlvl_desc,
2473                            x_return_status                    => x_return_status,
2474                            x_msg_count                        => x_msg_count,
2475                            x_msg_data                         => x_msg_data
2476                           );
2477 
2478          IF x_return_status <> g_ret_sts_success
2479          THEN
2480             RAISE g_exc_error;
2481          END IF;
2482 
2483          g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
2484          g_pricing_status_tbl (g_index).coverage_level_name := l_tlvl_desc; -- bug 5014604
2485          g_pricing_status_tbl (g_index).status_code := g_sts_code_success;
2486          l_line_no                  :=
2487                                       get_line_no (l_input_detail_rec.line_id);
2488 
2489          IF l_line_no IS NULL
2490          THEN
2491             g_pricing_status_tbl (g_index).status_text :=
2492                          NVL (x_price_details.status_text, g_sts_txt_success);
2493          ELSE
2494             -- bug 4730011
2495             fnd_message.set_name ('OKS', 'OKS_LINE_REPRICE_SUCCESS');
2496             fnd_message.set_token ('LINENO', l_line_no);
2497             g_pricing_status_tbl (g_index).status_text := fnd_message.get;
2498               -- l_line_no ||' ' ||NVL (x_price_details.status_text, g_sts_txt_success);
2499          END IF;
2500 
2501          g_index                    := g_index +
2502                                        1;
2503       END IF;
2504 
2505       x_price_details.status_text :=
2506                           NVL (x_price_details.status_text, g_sts_txt_success);
2507 
2508       -- end debug log
2509       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
2510       THEN
2511          fnd_log.STRING (fnd_log.level_procedure,
2512                          g_module ||
2513                          l_api_name,
2514                          '1000: Leaving ' ||
2515                          g_pkg_name ||
2516                          '.' ||
2517                          l_api_name
2518                         );
2519       END IF;
2520    EXCEPTION
2521       WHEN g_exc_cant_price
2522       THEN
2523          -- end debug log
2524          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
2525          THEN
2526             fnd_log.STRING (fnd_log.level_procedure,
2527                             g_module ||
2528                             l_api_name,
2529                             '7000: Leaving ' ||
2530                             g_pkg_name ||
2531                             '.' ||
2532                             l_api_name
2533                            );
2534          END IF;
2535 
2536          IF p_detail_rec.intent = g_subsc_reg_pricing
2537          THEN
2538             -- Get subscription line details
2539             get_line_details (p_line_id                          => l_input_detail_rec.line_id,
2540                               x_name                             => l_tlvl_name,
2541                               x_description                      => l_tlvl_desc,
2542                               x_return_status                    => l_return_status,
2543                               x_msg_count                        => x_msg_count,
2544                               x_msg_data                         => x_msg_data
2545                              );
2546             g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
2547             g_pricing_status_tbl (g_index).coverage_level_name := l_tlvl_desc; -- bug 5014604
2548             g_pricing_status_tbl (g_index).status_code := g_sts_code_success;
2549 
2550             IF x_price_details.status_code = g_partial_billed
2551                              or
2552                x_price_details.status_code = g_fully_billed
2553             THEN
2554                g_pricing_status_tbl (g_index).status_text := g_billed_line;
2555             ELSE
2556                g_pricing_status_tbl (g_index).status_text :=
2557                                                             g_sts_txt_success;
2558             END IF;
2559 
2560             g_index                    := g_index +
2561                                           1;
2562          END IF;
2563 
2564          IF    l_status = g_fully_billed
2565             OR l_status = g_partial_billed
2566          THEN
2567             x_price_details.status_code := g_billed;
2568          END IF;
2569       WHEN g_exc_error
2570       THEN
2571          -- end debug log
2572          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
2573          THEN
2574             fnd_log.STRING (fnd_log.level_procedure,
2575                             g_module ||
2576                             l_api_name,
2577                             '2000: Leaving ' ||
2578                             g_pkg_name ||
2579                             '.' ||
2580                             l_api_name
2581                            );
2582          END IF;
2583 
2584          IF p_detail_rec.intent = g_subsc_reg_pricing
2585          THEN
2586             -- Get subscription line details
2587             get_line_details (p_line_id                          => l_input_detail_rec.line_id,
2588                               x_name                             => l_tlvl_name,
2589                               x_description                      => l_tlvl_desc,
2590                               x_return_status                    => l_return_status,
2591                               x_msg_count                        => x_msg_count,
2592                               x_msg_data                         => x_msg_data
2593                              );
2594             g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
2595             g_pricing_status_tbl (g_index).coverage_level_name := l_tlvl_desc; -- bug 5014604
2596             g_pricing_status_tbl (g_index).status_code := g_sts_code_error;
2597             l_line_no                  :=
2598                                       get_line_no (l_input_detail_rec.line_id);
2599 
2600             IF l_line_no IS NULL
2601             THEN
2602                g_pricing_status_tbl (g_index).status_text :=
2603                            NVL (x_price_details.status_text, g_sts_txt_error);
2604             ELSE
2605               -- bug 4730011
2606                fnd_message.set_name ('OKS', 'OKS_LINE_REPRICE_SUCCESS');
2607                fnd_message.set_token ('LINENO', l_line_no);
2608                g_pricing_status_tbl (g_index).status_text := fnd_message.get;
2609                  --   l_line_no ||' ' ||NVL (x_price_details.status_text, g_sts_txt_error);
2610             END IF;
2611 
2612             g_index                    := g_index +
2613                                           1;
2614          END IF;
2615       WHEN OTHERS
2616       THEN
2617          -- end debug log
2618          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
2619          THEN
2620             fnd_log.STRING (fnd_log.level_procedure,
2621                             g_module ||
2622                             l_api_name,
2623                             '4000: Leaving ' ||
2624                             g_pkg_name ||
2625                             '.' ||
2626                             l_api_name
2627                            );
2628          END IF;
2629 
2630          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
2631          x_return_status            := g_ret_sts_unexp_error;
2632          okc_api.set_message (p_app_name                         => g_app_name,
2633                               p_msg_name                         => g_unexpected_error,
2634                               p_token1                           => g_sqlcode_token,
2635                               p_token1_value                     => SQLCODE,
2636                               p_token2                           => g_sqlerrm_token,
2637                               p_token2_value                     => SQLERRM
2638                              );
2639    END calculate_subscription_price;
2640 
2641    PROCEDURE calculate_subline_price (
2642       p_detail_rec                    IN       oks_qp_pkg.input_details,
2643       x_price_details                 OUT NOCOPY oks_qp_pkg.price_details,
2644       x_modifier_details              OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
2645       x_price_break_details           OUT NOCOPY oks_qp_pkg.g_price_break_tbl_type,
2646       x_return_status                 OUT NOCOPY VARCHAR2,
2647       x_msg_count                     OUT NOCOPY NUMBER,
2648       x_msg_data                      OUT NOCOPY VARCHAR2
2649    )
2650    IS
2651       l_api_name                     CONSTANT VARCHAR2 (30)
2652                                                  := 'CALCULATE_SUBLINE_PRICE';
2653 
2654       CURSOR l_currcode_csr (
2655          p_hdr_id                                 NUMBER
2656       )
2657       IS
2658          SELECT currency_code
2659            FROM okc_k_headers_all_b
2660           WHERE ID = p_hdr_id;
2661 
2662       CURSOR l_line_details_csr (
2663          p_cle_id                                 NUMBER
2664       )
2665       IS
2666          SELECT ID,
2667                 start_date,
2668                 end_date,
2669                 cle_id,
2670                 dnz_chr_id,
2671                 lse_id,
2672                 price_negotiated,
2673                 price_unit,
2674                 price_unit_percent,
2675                 price_list_line_id,
2676                 price_list_id,
2677                 line_list_price,
2678                 item_to_price_yn,
2679                 pricing_date,
2680                 price_basis_yn
2681            FROM okc_k_lines_b
2682           WHERE ID = p_cle_id
2683             AND lse_id IN (7, 9, 25);
2684 
2685       CURSOR l_prodpriceuom_csr (
2686          p_id                                     NUMBER
2687       )
2688       IS
2689          SELECT price_uom
2690            FROM oks_k_lines_b
2691           WHERE cle_id = p_id;
2692 
2693       CURSOR l_get_hdrid_csr (
2694          p_cle_id                                 NUMBER
2695       )
2696       IS
2697          SELECT dnz_chr_id
2698            FROM okc_k_lines_b
2699           WHERE ID = p_cle_id;
2700 
2701       CURSOR l_numitems_csr (
2702          p_subline_id                             NUMBER
2703       )
2704       IS
2705          SELECT number_of_items
2706            FROM okc_k_items_v
2707           WHERE cle_id = p_subline_id;
2708 
2709       l_num_items                             NUMBER;
2710       l_duration_qty                          NUMBER;
2711       l_cpuom_code                            VARCHAR2 (200);
2712       l_line_details_rec                      l_line_details_csr%ROWTYPE;
2713       l_input_detail_rec                      oks_qp_pkg.input_details
2714                                                                := p_detail_rec;
2715       l_rail_rec                              oks_tax_util_pvt.ra_rec_type;
2716       l_k_det_rec                             k_details_rec;
2717       l_khdr_rec_in                           oks_contract_hdr_pub.khrv_rec_type;
2718       l_khdr_rec_out                          oks_contract_hdr_pub.khrv_rec_type;
2719       l_kln_rec_in                            oks_contract_line_pub.klnv_rec_type;
2720       l_kln_rec_out                           oks_contract_line_pub.klnv_rec_type;
2721       l_clev_rec_in                           okc_contract_pub.clev_rec_type;
2722       l_clev_rec_out                          okc_contract_pub.clev_rec_type;
2723       l_prod_qty                              NUMBER;
2724       l_serv_qty                              NUMBER;
2725       l_status                                VARCHAR2 (30);         --3912685
2726       --new variables for partial periods
2727       l_period_type                           VARCHAR2 (30);
2728       l_period_start                          VARCHAR2 (30);
2729       l_price_uom                             VARCHAR2 (30);
2730       l_chr_id                                NUMBER;
2731       invalid_hdr_id_exception                EXCEPTION;
2732    BEGIN
2733       -- start debug log
2734       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
2735       THEN
2736          fnd_log.STRING (fnd_log.level_procedure,
2737                          g_module ||
2738                          l_api_name,
2739                          '100: Entered ' ||
2740                          g_pkg_name ||
2741                          '.' ||
2742                          l_api_name
2743                         );
2744       END IF;
2745 
2746       x_return_status            := g_ret_sts_success;
2747 
2748       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2749       THEN
2750          fnd_log.STRING (fnd_log.level_statement,
2751                          g_module ||
2752                          l_api_name,
2753                          '343:********** Entered Sub line Price ********'
2754                         );
2755          fnd_log.STRING (fnd_log.level_statement,
2756                          g_module ||
2757                          l_api_name,
2758                          '344:CHR_ID            = ' ||
2759                          p_detail_rec.chr_id
2760                         );
2761          fnd_log.STRING (fnd_log.level_statement,
2762                          g_module ||
2763                          l_api_name,
2764                          '345:LINE_ID           = ' ||
2765                          p_detail_rec.line_id
2766                         );
2767          fnd_log.STRING (fnd_log.level_statement,
2768                          g_module ||
2769                          l_api_name,
2770                          '346:SUBLINE_ID        = ' ||
2771                          p_detail_rec.subline_id
2772                         );
2773          fnd_log.STRING (fnd_log.level_statement,
2774                          g_module ||
2775                          l_api_name,
2776                          '347:INTENT            = ' ||
2777                          p_detail_rec.intent
2778                         );
2779          fnd_log.STRING (fnd_log.level_statement,
2780                          g_module ||
2781                          l_api_name,
2782                          '348:CURRENCY          = ' ||
2783                          p_detail_rec.currency
2784                         );
2785          fnd_log.STRING (fnd_log.level_statement,
2786                          g_module ||
2787                          l_api_name,
2788                          '349:Usage Qty         = ' ||
2789                          p_detail_rec.usage_qty
2790                         );
2791          fnd_log.STRING (fnd_log.level_statement,
2792                          g_module ||
2793                          l_api_name,
2794                          '350:Usage UOM Code    = ' ||
2795                          p_detail_rec.usage_uom_code
2796                         );
2797       END IF;
2798 
2799       --errorout ('********** Entered Sub line Price ********');
2800       --errorout ('CHR_ID            = ' || p_detail_rec.chr_id);
2801       --errorout ('LINE_ID           = ' || p_detail_rec.line_id);
2802       --errorout ('SUBLINE_ID        = ' || p_detail_rec.subline_id);
2803       --errorout ('INTENT            = ' || p_detail_rec.intent);
2804       --errorout ('CURRENCY          = ' || p_detail_rec.currency);
2805       --errorout ('Usage Qty         = ' || p_detail_rec.usage_qty);
2806       --errorout ('Usage UOM Code    = ' || p_detail_rec.usage_uom_code);
2807 
2808       /** 3912685 **/
2809       check_pricing_eligibility (p_line_id                          => p_detail_rec.subline_id,
2810                                  x_status                           => l_status,
2811                                  x_return_status                    => x_return_status,
2812                                  x_msg_count                        => x_msg_count,
2813                                  x_msg_data                         => x_msg_data
2814                                 );
2815 
2816       IF x_return_status <> g_ret_sts_success
2817       THEN
2818          RAISE g_exc_error;
2819       END IF;
2820 
2821       IF l_status <> g_oks_success
2822       THEN
2823          x_price_details.status_code := l_status;
2824          RAISE g_exc_cant_price;
2825       END IF;
2826 
2827       /** 3912685 **/
2828       IF p_detail_rec.intent = g_override_pricing
2829       THEN
2830          OPEN l_line_details_csr (p_detail_rec.subline_id);
2831 
2832          FETCH l_line_details_csr
2833           INTO l_line_details_rec;
2834 
2835          IF l_line_details_csr%NOTFOUND
2836          THEN
2837             CLOSE l_line_details_csr;
2838 
2839             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2840             THEN
2841                fnd_log.STRING
2842                   (fnd_log.level_statement,
2843                    g_module ||
2844                    l_api_name,
2845                    '351:Override amount not present in Price Negotiated column'
2846                   );
2847             END IF;
2848 
2849             --errorout  ('Override amount not present in Price Negotiated column');
2850             okc_api.set_message (p_app_name                         => g_app_name,
2851                                  p_msg_name                         => g_required_value,
2852                                  p_token1                           => g_col_name_token,
2853                                  p_token1_value                     => 'PRICE_NEGOTIATED'
2854                                 );
2855             x_return_status            := g_ret_sts_error;
2856             RAISE g_exc_error;
2857          END IF;
2858 
2859          CLOSE l_line_details_csr;
2860 
2861          IF NVL (fnd_profile.VALUE ('OKS_USE_QP_FOR_MANUAL_ADJ'), 'NO') =
2862                                                                          'YES'
2863          THEN
2864             oks_qp_pkg.calc_price
2865                              (p_detail_rec                       => l_input_detail_rec,
2866                               x_price_details                    => x_price_details,
2867                               x_modifier_details                 => x_modifier_details,
2868                               x_price_break_details              => x_price_break_details,
2869                               x_return_status                    => x_return_status,
2870                               x_msg_count                        => x_msg_count,
2871                               x_msg_data                         => x_msg_data
2872                              );
2873 
2874             IF x_return_status <> g_ret_sts_success
2875             THEN
2876                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
2877                   )
2878                THEN
2879                   fnd_log.STRING (fnd_log.level_statement,
2880                                   g_module ||
2881                                   l_api_name,
2882                                   '352:CALC PRICE ERROR at 1st SAPI call'
2883                                  );
2884                END IF;
2885 
2886                --errorout('CALC PRICE ERROR at 1st SAPI call');
2887                RAISE g_exc_error;
2888             END IF;
2889 
2890             -- Now calculate the override unit price
2891             l_prod_qty                 :=
2892                                       NVL (x_price_details.prod_priced_qty, 1);
2893             l_serv_qty                 :=
2894                                       NVL (x_price_details.serv_priced_qty, 1);
2895             l_input_detail_rec.asking_unit_price :=
2896                l_line_details_rec.price_negotiated /
2897                (l_prod_qty *
2898                 l_serv_qty
2899                );
2900 
2901             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
2902             THEN
2903                fnd_log.STRING (fnd_log.level_statement,
2904                                g_module ||
2905                                l_api_name,
2906                                '353:Asking price : ' ||
2907                                l_input_detail_rec.asking_unit_price
2908                               );
2909             END IF;
2910 
2911             --errorout('Asking price : ' || l_input_detail_rec.asking_unit_price);
2912             oks_qp_pkg.calc_price
2913                               (p_detail_rec                       => l_input_detail_rec,
2914                                x_price_details                    => x_price_details,
2915                                x_modifier_details                 => x_modifier_details,
2916                                x_price_break_details              => x_price_break_details,
2917                                x_return_status                    => x_return_status,
2918                                x_msg_count                        => x_msg_count,
2919                                x_msg_data                         => x_msg_data
2920                               );
2921 
2922             IF x_return_status <> g_ret_sts_success
2923             THEN
2924                IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
2925                   )
2926                THEN
2927                   fnd_log.STRING (fnd_log.level_procedure,
2928                                   g_module ||
2929                                   l_api_name,
2930                                   '201:CALC PRICE ERROR at 2nd SAPI call'
2931                                  );
2932                END IF;
2933 
2934                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
2935                   )
2936                THEN
2937                   fnd_log.STRING (fnd_log.level_statement,
2938                                   g_module ||
2939                                   l_api_name,
2940                                   '354:CALC PRICE ERROR at 2nd SAPI call'
2941                                  );
2942                END IF;
2943 
2944                --dbms_output.put_line('CALC PRICE ERROR at 2nd SAPI call');
2945                RAISE g_exc_error;
2946             END IF;
2947 
2948             l_rail_rec.amount          :=
2949                                       NVL (x_price_details.serv_ext_amount, 0);
2950             x_price_details.status_text :=
2951                           NVL (x_price_details.status_text, g_sts_txt_success);
2952          ELSE
2953             OPEN l_prodpriceuom_csr (p_detail_rec.subline_id);
2954 
2955             FETCH l_prodpriceuom_csr
2956              INTO l_cpuom_code;
2957 
2958             CLOSE l_prodpriceuom_csr;
2959 
2960             --New logic for Partial Periods
2961             OPEN l_get_hdrid_csr (p_detail_rec.subline_id);
2962 
2963             FETCH l_get_hdrid_csr
2964              INTO l_chr_id;
2965 
2966             CLOSE l_get_hdrid_csr;
2967 
2968             IF l_chr_id IS NOT NULL
2969             THEN
2970                oks_renew_util_pub.get_period_defaults
2971                                           (p_hdr_id                           => l_chr_id,
2972                                            p_org_id                           => NULL,
2973                                            x_period_type                      => l_period_type,
2974                                            x_period_start                     => l_period_start,
2975                                            x_price_uom                        => l_price_uom,
2976                                            x_return_status                    => x_return_status
2977                                           );
2978 
2979                IF x_return_status <> g_ret_sts_success
2980                THEN
2981                   RAISE g_exc_error;
2982                END IF;
2983             ELSE
2984                RAISE invalid_hdr_id_exception;
2985             END IF;
2986 
2987             --End  logic for Partial Periods
2988             IF l_cpuom_code IS NOT NULL
2989             THEN
2990                l_duration_qty             :=
2991                   oks_time_measures_pub.get_quantity
2992                               (p_start_date                       => l_line_details_rec.start_date,
2993                                p_end_date                         => l_line_details_rec.end_date,
2994                                p_source_uom                       => l_cpuom_code,
2995                                p_period_type                      => l_period_type,
2996                                --new parameter
2997                                p_period_start                     => l_period_start
2998                               --new paramter
2999                               );
3000             ELSE
3001                okc_time_util_pub.get_duration
3002                               (p_start_date                       => l_line_details_rec.start_date,
3003                                p_end_date                         => l_line_details_rec.end_date,
3004                                x_duration                         => l_duration_qty,
3005                                x_timeunit                         => l_cpuom_code,
3006                                x_return_status                    => x_return_status
3007                               );
3008             END IF;
3009 
3010             OPEN l_numitems_csr (p_detail_rec.subline_id);
3011 
3012             FETCH l_numitems_csr
3013              INTO l_num_items;
3014 
3015             CLOSE l_numitems_csr;
3016 
3017             IF l_input_detail_rec.currency IS NULL
3018             THEN
3019                OPEN l_currcode_csr (l_line_details_rec.dnz_chr_id);
3020 
3021                FETCH l_currcode_csr
3022                 INTO l_input_detail_rec.currency;
3023 
3024                CLOSE l_currcode_csr;
3025             END IF;
3026 
3027 If nvl(FND_PROFILE.value('OKS_PRICE_ROUNDING'),'N') ='N' THEN
3028              -- bug 5018782, don't round any amount that we get from QP
3029             l_line_details_rec.price_negotiated := ROUND (l_line_details_rec.price_negotiated, 29) ;
3030              /*  bug 5018782 */
3031 Else
3032              l_line_details_rec.price_negotiated :=oks_extwar_util_pvt.round_currency_amt
3033                              (p_amount                           => l_line_details_rec.price_negotiated,
3034                               p_currency_code                    => l_input_detail_rec.currency);
3035 End If;
3036 
3037             l_rail_rec.amount          :=
3038                                   NVL (l_line_details_rec.price_negotiated, 0);
3039             x_price_details.status_text := g_manual_adj_price;
3040             x_price_details.serv_ext_amount :=
3041                                   NVL (l_line_details_rec.price_negotiated, 0);
3042 
3043             IF     NVL (l_line_details_rec.price_negotiated, 0) > 0
3044                AND l_duration_qty > 0
3045                AND l_num_items > 0
3046             THEN
3047                x_price_details.serv_adj_unit_price :=
3048                   NVL (l_line_details_rec.price_negotiated, 0) /
3049                   (l_duration_qty *
3050                    l_num_items
3051                   );
3052             ELSE
3053                x_price_details.serv_adj_unit_price :=
3054                                  NVL (l_line_details_rec.price_negotiated, 0);
3055             END IF;
3056 
3057             x_price_details.serv_adj_unit_price :=
3058                                ROUND (x_price_details.serv_adj_unit_price, 29);
3059             x_price_details.prod_list_unit_price := NULL;
3060             x_price_details.prod_priced_qty := NULL;
3061             x_price_details.prod_ext_amount := NULL;
3062             x_price_details.serv_list_unit_price := NULL;
3063             x_price_details.serv_operator := NULL;
3064             x_price_details.serv_operand := NULL;
3065             x_price_details.prod_priced_uom := NULL;
3066             x_price_details.serv_qty   := NULL;
3067             x_price_details.serv_priced_uom := NULL;
3068          END IF;
3069       ELSE
3070          oks_qp_pkg.calc_price
3071                              (p_detail_rec                       => l_input_detail_rec,
3072                               x_price_details                    => x_price_details,
3073                               x_modifier_details                 => x_modifier_details,
3074                               x_price_break_details              => x_price_break_details,
3075                               x_return_status                    => x_return_status,
3076                               x_msg_count                        => x_msg_count,
3077                               x_msg_data                         => x_msg_data
3078                              );
3079 
3080          IF x_return_status <> g_ret_sts_success
3081          THEN
3082             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3083             THEN
3084                fnd_log.STRING (fnd_log.level_statement,
3085                                g_module ||
3086                                l_api_name,
3087                                '355:CALC PRICE ERROR at 2nd SAPI call'
3088                               );
3089             END IF;
3090 
3091             -- errorout('CALC PRICE ERROR at 2nd SAPI call');
3092             RAISE g_exc_error;
3093          END IF;
3094 
3095          l_rail_rec.amount          :=
3096                                       NVL (x_price_details.serv_ext_amount, 0);
3097          x_price_details.status_text :=
3098                           NVL (x_price_details.status_text, g_sts_txt_success);
3099       END IF;
3100 
3101       l_rail_rec.tax_value       := NULL;
3102       l_rail_rec.amount_includes_tax_flag := NULL;
3103       -- Calculate Tax
3104       oks_tax_util_pvt.get_tax (p_api_version                      => l_api_version,
3105                                 p_init_msg_list                    => l_init_msg_list,
3106                                 p_chr_id                           => l_input_detail_rec.chr_id,
3107                                 p_cle_id                           => l_input_detail_rec.subline_id,
3108                                 px_rail_rec                        => l_rail_rec,
3109                                 x_msg_count                        => x_msg_count,
3110                                 x_msg_data                         => x_msg_data,
3111                                 x_return_status                    => x_return_status
3112                                );
3113 
3114       IF x_return_status <> g_ret_sts_success
3115       THEN
3116          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3117          THEN
3118             fnd_log.STRING (fnd_log.level_statement,
3119                             g_module ||
3120                             l_api_name,
3121                             '356:TAX ERROR in Subline Price x_return_status '||x_return_status
3122                            );
3123             fnd_log.STRING (fnd_log.level_statement,
3124                             g_module ||
3125                             l_api_name,
3126                             '356: x_msg_data '||x_msg_data
3127                            );
3128          END IF;
3129 
3130          --errorout('TAX ERROR in Subline Price');
3131          -- bug 5001677, even if tax error continue
3132          -- RAISE g_exc_error;
3133          l_rail_rec.tax_value                :=  0;
3134          l_rail_rec.amount_includes_tax_flag := 'N';
3135       END IF;
3136 
3137       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3138       THEN
3139          fnd_log.STRING (fnd_log.level_statement,
3140                          g_module ||
3141                          l_api_name,
3142                          '358:l_rail_rec.TAX_VALUE = ' ||
3143                          l_rail_rec.tax_value
3144                         );
3145          fnd_log.STRING (fnd_log.level_statement,
3146                          g_module ||
3147                          l_api_name,
3148                          '359:l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = ' ||
3149                          l_rail_rec.amount_includes_tax_flag
3150                         );
3151       END IF;
3152 
3153       --errorout('l_rail_rec.TAX_VALUE = '||l_rail_rec.TAX_VALUE);
3154       --errorout('l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = '||l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG );
3155       l_kln_rec_in.cle_id        := l_input_detail_rec.subline_id;
3156       l_kln_rec_in.dnz_chr_id    := l_input_detail_rec.chr_id;
3157       l_kln_rec_in.tax_inclusive_yn := l_rail_rec.amount_includes_tax_flag;
3158 
3159       IF l_rail_rec.amount_includes_tax_flag = 'N'
3160       THEN
3161          l_kln_rec_in.tax_amount    := NVL (l_rail_rec.tax_value, 0);
3162       ELSE
3163          l_kln_rec_in.tax_amount    := 0;
3164       END IF;
3165 
3166       IF x_price_details.prod_price_list_id IS NOT NULL
3167       THEN
3168          l_kln_rec_in.prod_price    := x_price_details.prod_price_list_id;
3169       END IF;
3170 
3171       IF x_price_details.serv_price_list_id IS NOT NULL
3172       THEN
3173          l_kln_rec_in.service_price := x_price_details.serv_price_list_id;
3174       END IF;
3175 
3176       l_kln_rec_in.clvl_list_price := x_price_details.prod_list_unit_price;
3177       l_kln_rec_in.clvl_quantity := x_price_details.prod_priced_qty;
3178       l_kln_rec_in.clvl_extended_amt := x_price_details.prod_ext_amount;
3179       l_kln_rec_in.toplvl_operand_code := x_price_details.serv_operator;
3180       l_kln_rec_in.toplvl_operand_val := x_price_details.serv_operand;
3181       l_kln_rec_in.clvl_uom_code := x_price_details.prod_priced_uom;
3182       l_kln_rec_in.toplvl_quantity := x_price_details.serv_qty;
3183       l_kln_rec_in.toplvl_uom_code := x_price_details.serv_priced_uom;
3184       l_kln_rec_in.toplvl_adj_price := x_price_details.serv_adj_unit_price;
3185       -- GCHADHA --
3186       -- BUG 4015739 --
3187       -- 17-NOV-2004 --
3188       --l_kln_rec_in.status_text         := NVL(x_price_details.status_text,G_STS_TXT_SUCCESS);
3189       l_kln_rec_in.status_text   :=
3190          SUBSTR (NVL (x_price_details.status_text, g_sts_txt_success),
3191                  1,
3192                  450
3193                 );
3194       -- END GCHADHA --
3195       l_kln_rec_in.toplvl_price_qty := x_price_details.serv_priced_qty;
3196       get_k_details (p_id                               => l_input_detail_rec.subline_id,
3197                      p_type                             => g_oks_line,
3198                      x_k_det_rec                        => l_k_det_rec
3199                     );
3200       l_kln_rec_in.ID            := l_k_det_rec.ID;
3201       l_kln_rec_in.object_version_number := l_k_det_rec.object_version_number;
3202       oks_contract_line_pub.update_line (p_api_version                      => l_api_version,
3203                                          p_init_msg_list                    => l_init_msg_list,
3204                                          x_return_status                    => x_return_status,
3205                                          x_msg_count                        => x_msg_count,
3206                                          x_msg_data                         => x_msg_data,
3207                                          p_klnv_rec                         => l_kln_rec_in,
3208                                          x_klnv_rec                         => l_kln_rec_out,
3209                                          p_validate_yn                      => 'N'
3210                                         );
3211 
3212       IF x_return_status <> g_ret_sts_success
3213       THEN
3214          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3215          THEN
3216             fnd_log.STRING (fnd_log.level_statement,
3217                             g_module ||
3218                             l_api_name,
3219                             '360:Update line details at Calc Subscription'
3220                            );
3221          END IF;
3222 
3223          --errorout('Update line details at Calc Subscription');
3224          RAISE g_exc_error;
3225       END IF;
3226 
3227       l_clev_rec_in.ID           := l_input_detail_rec.subline_id;
3228       l_clev_rec_in.line_list_price := x_price_details.serv_list_unit_price;
3229       l_clev_rec_in.price_negotiated := l_rail_rec.amount;
3230       l_clev_rec_in.price_unit   :=
3231          NVL (x_price_details.serv_adj_unit_price,
3232               x_price_details.serv_list_unit_price);
3233       --bug 3360423 list_unit_price will be stored in the database instead of adj_unit_price
3234       get_k_details (p_id                               => l_input_detail_rec.subline_id,
3235                      p_type                             => g_okc_line,
3236                      x_k_det_rec                        => l_k_det_rec
3237                     );
3238       l_clev_rec_in.object_version_number := l_k_det_rec.object_version_number;
3239       okc_contract_pub.update_contract_line
3240                                           (p_api_version                      => l_api_version,
3241                                            p_init_msg_list                    => l_init_msg_list,
3242                                            x_return_status                    => x_return_status,
3243                                            x_msg_count                        => x_msg_count,
3244                                            x_msg_data                         => x_msg_data,
3245                                            p_clev_rec                         => l_clev_rec_in,
3246                                            x_clev_rec                         => l_clev_rec_out
3247                                           );
3248 
3249       IF x_return_status <> g_ret_sts_success
3250       THEN
3251          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3252          THEN
3253             fnd_log.STRING
3254                          (fnd_log.level_statement,
3255                           g_module ||
3256                           l_api_name,
3257                           '361:Contract line updation ERROR in Subline Price'
3258                          );
3259          END IF;
3260 
3261          -- errorout('Contract line updation ERROR in Subline Price');
3262          RAISE g_exc_error;
3263       END IF;
3264 
3265       -- end debug log
3266       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3267       THEN
3268          fnd_log.STRING (fnd_log.level_procedure,
3269                          g_module ||
3270                          l_api_name,
3271                          '1000: Leaving ' ||
3272                          g_pkg_name ||
3273                          '.' ||
3274                          l_api_name
3275                         );
3276       END IF;
3277    EXCEPTION
3278       WHEN g_exc_cant_price
3279       THEN
3280          -- end debug log
3281          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3282          THEN
3283             fnd_log.STRING (fnd_log.level_procedure,
3284                             g_module ||
3285                             l_api_name,
3286                             '7000: Leaving ' ||
3287                             g_pkg_name ||
3288                             '.' ||
3289                             l_api_name
3290                            );
3291          END IF;
3292 
3293          IF    l_status = g_fully_billed
3294             OR l_status = g_partial_billed
3295          THEN
3296             x_price_details.status_code := g_billed;
3297          END IF;
3298 
3299          NULL;
3300       WHEN g_exc_error
3301       THEN
3302          -- end debug log
3303          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3304          THEN
3305             fnd_log.STRING (fnd_log.level_procedure,
3306                             g_module ||
3307                             l_api_name,
3308                             '2000: Leaving ' ||
3309                             g_pkg_name ||
3310                             '.' ||
3311                             l_api_name
3312                            );
3313          END IF;
3314 
3315          NULL;
3316       WHEN invalid_hdr_id_exception
3317       THEN
3318          -- end debug log
3319          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3320          THEN
3321             fnd_log.STRING (fnd_log.level_procedure,
3322                             g_module ||
3323                             l_api_name,
3324                             '8000: Leaving ' ||
3325                             g_pkg_name ||
3326                             '.' ||
3327                             l_api_name
3328                            );
3329          END IF;
3330 
3331          okc_api.set_message (p_app_name                         => g_app_name,
3332                               p_msg_name                         => g_invalid_value,
3333                               p_token1                           => g_col_name_token,
3334                               p_token1_value                     => 'Header ID'
3335                              );
3336       WHEN OTHERS
3337       THEN
3338          -- end debug log
3339          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3340          THEN
3341             fnd_log.STRING (fnd_log.level_procedure,
3342                             g_module ||
3343                             l_api_name,
3344                             '4000: Leaving ' ||
3345                             g_pkg_name ||
3346                             '.' ||
3347                             l_api_name
3348                            );
3349          END IF;
3350 
3351          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
3352          x_return_status            := g_ret_sts_unexp_error;
3353          okc_api.set_message (p_app_name                         => g_app_name,
3354                               p_msg_name                         => g_unexpected_error,
3355                               p_token1                           => g_sqlcode_token,
3356                               p_token1_value                     => SQLCODE,
3357                               p_token2                           => g_sqlerrm_token,
3358                               p_token2_value                     => SQLERRM
3359                              );
3360    END calculate_subline_price;
3361 
3362    PROCEDURE calculate_topline_price (
3363       p_detail_rec                    IN       oks_qp_pkg.input_details,
3364       x_price_details                 OUT NOCOPY oks_qp_pkg.price_details,
3365       x_modifier_details              OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
3366       x_price_break_details           OUT NOCOPY oks_qp_pkg.g_price_break_tbl_type,
3367       x_return_status                 OUT NOCOPY VARCHAR2,
3368       x_msg_count                     OUT NOCOPY NUMBER,
3369       x_msg_data                      OUT NOCOPY VARCHAR2
3370    )
3371    IS
3372       l_api_name                     CONSTANT VARCHAR2 (30)
3373                                                  := 'CALCULATE_TOPLINE_PRICE';
3374 
3375       CURSOR l_subline_csr (
3376          p_cle_id                                 NUMBER
3377       )
3378       IS
3379          SELECT   ID,
3380                   start_date,
3381                   end_date,
3382                   lse_id
3383              FROM okc_k_lines_b
3384             WHERE cle_id = p_cle_id
3385               AND lse_id IN (7, 9, 25)
3386               AND date_cancelled IS NULL                               --[llc]
3387               AND date_terminated IS NULL                  -- bug 5504157
3388          ORDER BY line_number;
3389 
3390       l_input_detail_rec                      oks_qp_pkg.input_details;
3391       l_rail_rec                              oks_tax_util_pvt.ra_rec_type;
3392       l_k_det_rec                             k_details_rec;
3393       l_khdr_rec_in                           oks_contract_hdr_pub.khrv_rec_type;
3394       l_khdr_rec_out                          oks_contract_hdr_pub.khrv_rec_type;
3395       l_kln_rec_in                            oks_contract_line_pub.klnv_rec_type;
3396       l_kln_rec_out                           oks_contract_line_pub.klnv_rec_type;
3397       l_clev_rec_in                           okc_contract_pub.clev_rec_type;
3398       l_clev_rec_out                          okc_contract_pub.clev_rec_type;
3399       l_subs_item                             BOOLEAN := FALSE;
3400       l_clvl_name                             VARCHAR2 (240);
3401       l_clvl_desc                             VARCHAR2 (1000);
3402       l_tlvl_name                             VARCHAR2 (800);
3403       l_tlvl_desc                             VARCHAR2 (1000);
3404       l_line_no                               VARCHAR2 (300);
3405       l_status                                VARCHAR2 (30);         --3912685
3406    BEGIN
3407       -- start debug log
3408       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3409       THEN
3410          fnd_log.STRING (fnd_log.level_procedure,
3411                          g_module ||
3412                          l_api_name,
3413                          '100: Entered ' ||
3414                          g_pkg_name ||
3415                          '.' ||
3416                          l_api_name
3417                         );
3418       END IF;
3419 
3420       x_return_status            := g_ret_sts_success;
3421       l_input_detail_rec         := p_detail_rec;
3422       -- Get top line details
3423       get_line_details (p_line_id                          => l_input_detail_rec.line_id,
3424                         x_name                             => l_tlvl_name,
3425                         x_description                      => l_tlvl_desc,
3426                         x_return_status                    => x_return_status,
3427                         x_msg_count                        => x_msg_count,
3428                         x_msg_data                         => x_msg_data
3429                        );
3430 
3431       IF x_return_status <> g_ret_sts_success
3432       THEN
3433          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
3434          THEN
3435             fnd_log.STRING (fnd_log.level_statement,
3436                             g_module ||
3437                             l_api_name,
3438                             '362:Get Line details ERROR in Topline'
3439                            );
3440          END IF;
3441 
3442          -- errorout('Get Line details ERROR in Topline');
3443          RAISE g_exc_error;
3444       END IF;
3445 
3446       FOR l_subline_rec IN l_subline_csr (l_input_detail_rec.line_id)
3447       LOOP
3448          BEGIN
3449             IF l_subline_rec.lse_id IN (9, 25)
3450             THEN
3451                l_subs_item                := is_subs_item (l_subline_rec.ID);
3452             ELSE
3453                l_subs_item                := FALSE;
3454             END IF;
3455 
3456             -- If its a Subscription item, skip iteration
3457             IF NOT l_subs_item
3458             THEN
3459                l_input_detail_rec.subline_id := l_subline_rec.ID;
3460                /** 3912685 **/
3461                check_pricing_eligibility
3462                                  (p_line_id                          => l_input_detail_rec.subline_id,
3463                                   x_status                           => l_status,
3464                                   x_return_status                    => x_return_status,
3465                                   x_msg_count                        => x_msg_count,
3466                                   x_msg_data                         => x_msg_data
3467                                  );
3468 
3469                IF x_return_status <> g_ret_sts_success
3470                THEN
3471                   RAISE g_exc_error;
3472                END IF;
3473 
3474                IF l_status <> g_oks_success
3475                THEN
3476                   x_price_details.status_code := l_status;
3477                   RAISE g_exc_cant_price;
3478                END IF;
3479 
3480                /** **/
3481                oks_qp_pkg.calc_price
3482                               (p_detail_rec                       => l_input_detail_rec,
3483                                x_price_details                    => x_price_details,
3484                                x_modifier_details                 => x_modifier_details,
3485                                x_price_break_details              => x_price_break_details,
3486                                x_return_status                    => x_return_status,
3487                                x_msg_count                        => x_msg_count,
3488                                x_msg_data                         => x_msg_data
3489                               );
3490 
3491                IF x_return_status <> g_ret_sts_success
3492                THEN
3493                   IF (fnd_log.level_statement >=
3494                                                fnd_log.g_current_runtime_level
3495                      )
3496                   THEN
3497                      fnd_log.STRING
3498                            (fnd_log.level_statement,
3499                             g_module ||
3500                             l_api_name,
3501                             '363:CALC PRICE ERROR after SAPI call in Topline'
3502                            );
3503                   END IF;
3504 
3505                   -- errorout('CALC PRICE ERROR after SAPI call in Topline');
3506                   RAISE g_skip_exception;
3507                END IF;
3508 
3509                l_rail_rec.amount          :=
3510                                       NVL (x_price_details.serv_ext_amount, 0);
3511                l_rail_rec.tax_value       := NULL;
3512                l_rail_rec.amount_includes_tax_flag := NULL;
3513                -- Calculate Tax
3514                oks_tax_util_pvt.get_tax
3515                                    (p_api_version                      => l_api_version,
3516                                     p_init_msg_list                    => l_init_msg_list,
3517                                     p_chr_id                           => l_input_detail_rec.chr_id,
3518                                     p_cle_id                           => l_input_detail_rec.subline_id,
3519                                     px_rail_rec                        => l_rail_rec,
3520                                     x_msg_count                        => x_msg_count,
3521                                     x_msg_data                         => x_msg_data,
3522                                     x_return_status                    => x_return_status
3523                                    );
3524 
3525                IF x_return_status <> g_ret_sts_success
3526                THEN
3527                   IF (fnd_log.level_statement >=
3528                                                fnd_log.g_current_runtime_level
3529                      )
3530                   THEN
3531                      fnd_log.STRING (fnd_log.level_statement,
3532                                      g_module ||
3533                                      l_api_name,
3534                                      '364:TAX CALC ERROR in Topline x_return_status '||x_return_status
3535                                     );
3536                      fnd_log.STRING (fnd_log.level_statement,
3537                                      g_module ||
3538                                      l_api_name,
3539                                      'x_msg_data '||x_msg_data
3540                                     );
3541                   END IF;
3542 
3543                   -- errorout('TAX CALC ERROR in Topline');
3544                   -- bug 5001677, even if tax error continue
3545                   -- RAISE g_skip_exception;
3546                     l_rail_rec.tax_value                :=  0;
3547                     l_rail_rec.amount_includes_tax_flag := 'N';
3548                END IF;
3549 
3550                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
3551                   )
3552                THEN
3553                   fnd_log.STRING (fnd_log.level_statement,
3554                                   g_module ||
3555                                   l_api_name,
3556                                   '366:l_rail_rec.TAX_VALUE = ' ||
3557                                   l_rail_rec.tax_value
3558                                  );
3559                   fnd_log.STRING
3560                               (fnd_log.level_statement,
3561                                g_module ||
3562                                l_api_name,
3563                                '367:l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = ' ||
3564                                l_rail_rec.amount_includes_tax_flag
3565                               );
3566                END IF;
3567 
3568                --errorout('l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = '||l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG );
3569                --errorout('l_rail_rec.TAX_VALUE = '||  l_rail_rec.TAX_VALUE );
3570                --errorout('l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG = '||l_rail_rec.AMOUNT_INCLUDES_TAX_FLAG );
3571                l_kln_rec_in.cle_id        := l_input_detail_rec.subline_id;
3572                l_kln_rec_in.dnz_chr_id    := l_input_detail_rec.chr_id;
3573                l_kln_rec_in.tax_inclusive_yn :=
3574                                            l_rail_rec.amount_includes_tax_flag;
3575 
3576                IF l_rail_rec.amount_includes_tax_flag = 'N'
3577                THEN
3578                   l_kln_rec_in.tax_amount    := NVL (l_rail_rec.tax_value, 0);
3579                ELSE
3580                   l_kln_rec_in.tax_amount    := 0;
3581                END IF;
3582 
3583                IF x_price_details.prod_price_list_id IS NOT NULL
3584                THEN
3585                   l_kln_rec_in.prod_price    :=
3586                                            x_price_details.prod_price_list_id;
3587                END IF;
3588 
3589                IF x_price_details.serv_price_list_id IS NOT NULL
3590                THEN
3591                   l_kln_rec_in.service_price :=
3592                                            x_price_details.serv_price_list_id;
3593                END IF;
3594 
3595                l_kln_rec_in.clvl_list_price :=
3596                                           x_price_details.prod_list_unit_price;
3597                l_kln_rec_in.clvl_quantity := x_price_details.prod_priced_qty;
3598                l_kln_rec_in.clvl_extended_amt :=
3599                                                x_price_details.prod_ext_amount;
3600                l_kln_rec_in.toplvl_operand_code :=
3601                                                  x_price_details.serv_operator;
3602                l_kln_rec_in.toplvl_operand_val := x_price_details.serv_operand;
3603                l_kln_rec_in.clvl_uom_code := x_price_details.prod_priced_uom;
3604                l_kln_rec_in.toplvl_quantity := x_price_details.serv_qty;
3605                l_kln_rec_in.toplvl_uom_code := x_price_details.serv_priced_uom;
3606                l_kln_rec_in.toplvl_adj_price :=
3607                                            x_price_details.serv_adj_unit_price;
3608                -- GCHADHA --
3609                -- BUG 4015739 --
3610                -- 17-NOV-2004 --
3611                l_kln_rec_in.status_text   :=
3612                   SUBSTR (NVL (x_price_details.status_text, g_sts_txt_success),
3613                           1,
3614                           450
3615                          );
3616                     --l_kln_rec_in.status_text         := NVL(x_price_details.status_text,G_STS_TXT_SUCCESS);
3617                -- END GCHADHA --
3618                l_kln_rec_in.toplvl_price_qty :=
3619                                                x_price_details.serv_priced_qty;
3620                get_k_details (p_id                               => l_input_detail_rec.subline_id,
3621                               p_type                             => g_oks_line,
3622                               x_k_det_rec                        => l_k_det_rec
3623                              );
3624                l_kln_rec_in.ID            := l_k_det_rec.ID;
3625                l_kln_rec_in.object_version_number :=
3626                                              l_k_det_rec.object_version_number;
3627                oks_contract_line_pub.update_line
3628                                           (p_api_version                      => l_api_version,
3629                                            p_init_msg_list                    => l_init_msg_list,
3630                                            x_return_status                    => x_return_status,
3631                                            x_msg_count                        => x_msg_count,
3632                                            x_msg_data                         => x_msg_data,
3633                                            p_klnv_rec                         => l_kln_rec_in,
3634                                            x_klnv_rec                         => l_kln_rec_out,
3635                                            p_validate_yn                      => 'N'
3636                                           );
3637 
3638                IF x_return_status <> g_ret_sts_success
3639                THEN
3640                   IF (fnd_log.level_statement >=
3641                                                fnd_log.g_current_runtime_level
3642                      )
3643                   THEN
3644                      fnd_log.STRING
3645                               (fnd_log.level_statement,
3646                                g_module ||
3647                                l_api_name,
3648                                '368:Update line details at Calc Subscription'
3649                               );
3650                   END IF;
3651 
3652                   --errorout('Update line details at Calc Subscription');
3653                   RAISE g_skip_exception;
3654                END IF;
3655 
3656                l_clev_rec_in.ID           := l_input_detail_rec.subline_id;
3657                l_clev_rec_in.line_list_price :=
3658                                           x_price_details.serv_list_unit_price;
3659                l_clev_rec_in.price_negotiated :=
3660                                                x_price_details.serv_ext_amount;
3661                l_clev_rec_in.price_unit   :=
3662                   NVL (x_price_details.serv_adj_unit_price,
3663                        x_price_details.serv_list_unit_price);
3664                --bug 3360423 list_unit_price will be stored in the database instead of adj_unit_price
3665                get_k_details (p_id                               => l_input_detail_rec.subline_id,
3666                               p_type                             => g_okc_line,
3667                               x_k_det_rec                        => l_k_det_rec
3668                              );
3669                l_clev_rec_in.object_version_number :=
3670                                              l_k_det_rec.object_version_number;
3671                okc_contract_pub.update_contract_line
3672                                           (p_api_version                      => l_api_version,
3673                                            p_init_msg_list                    => l_init_msg_list,
3674                                            x_return_status                    => x_return_status,
3675                                            x_msg_count                        => x_msg_count,
3676                                            x_msg_data                         => x_msg_data,
3677                                            p_clev_rec                         => l_clev_rec_in,
3678                                            x_clev_rec                         => l_clev_rec_out
3679                                           );
3680 
3681                IF x_return_status <> g_ret_sts_success
3682                THEN
3683                   IF (fnd_log.level_statement >=
3684                                                fnd_log.g_current_runtime_level
3685                      )
3686                   THEN
3687                      fnd_log.STRING
3688                         (fnd_log.level_statement,
3689                          g_module ||
3690                          l_api_name,
3691                          '369:Contract line updation ERROR in Subline Price - Topline Price'
3692                         );
3693                   END IF;
3694 
3695                   -- errorout ('Contract line updation ERROR in Subline Price - Topline Price');
3696                   RAISE g_skip_exception;
3697                END IF;
3698 
3699                -- Clear the record so as to reuse it
3700                l_clev_rec_in.ID           := okc_api.g_miss_num;
3701                --l_clev_rec_in.chr_id           := OKC_API.G_MISS_NUM;
3702                --l_clev_rec_in.cle_id           := OKC_API.G_MISS_NUM;
3703                l_clev_rec_in.price_negotiated := okc_api.g_miss_num;
3704                l_clev_rec_in.price_unit   := okc_api.g_miss_num;
3705                -- Get covered line details
3706                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
3707                                  x_name                             => l_clvl_name,
3708                                  x_description                      => l_clvl_desc,
3709                                  x_return_status                    => x_return_status,
3710                                  x_msg_count                        => x_msg_count,
3711                                  x_msg_data                         => x_msg_data
3712                                 );
3713                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
3714                g_pricing_status_tbl (g_index).coverage_level_name :=
3715                                                                    l_clvl_name;
3716                g_pricing_status_tbl (g_index).status_code :=
3717                                                             g_sts_code_success;
3718                l_line_no                  :=
3719                                    get_line_no (l_input_detail_rec.subline_id);
3720 
3721                IF l_line_no IS NULL
3722                THEN
3723                   g_pricing_status_tbl (g_index).status_text :=
3724                          NVL (x_price_details.status_text, g_sts_txt_success);
3725                ELSE
3726                    -- bug 4730011
3727                   fnd_message.set_name ('OKS', 'OKS_LINE_REPRICE_SUCCESS');
3728                   fnd_message.set_token ('LINENO', l_line_no);
3729                   g_pricing_status_tbl (g_index).status_text := fnd_message.get;
3730                      -- l_line_no ||' ' ||NVL (x_price_details.status_text, g_sts_txt_success);
3731                END IF;
3732 
3733                g_index                    := g_index +
3734                                              1;
3735             END IF;               -- Skip iteration if its a Subscription item
3736 
3737             -- end debug log
3738             IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3739             THEN
3740                fnd_log.STRING (fnd_log.level_procedure,
3741                                g_module ||
3742                                l_api_name,
3743                                '1000: Leaving ' ||
3744                                g_pkg_name ||
3745                                '.' ||
3746                                l_api_name
3747                               );
3748             END IF;
3749          EXCEPTION
3750             WHEN g_exc_cant_price
3751             THEN
3752                -- end debug log
3753                IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
3754                   )
3755                THEN
3756                   fnd_log.STRING (fnd_log.level_procedure,
3757                                   g_module ||
3758                                   l_api_name,
3759                                   '7000: Leaving ' ||
3760                                   g_pkg_name ||
3761                                   '.' ||
3762                                   l_api_name
3763                                  );
3764                END IF;
3765 
3766                -- Get covered line details
3767                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
3768                                  x_name                             => l_clvl_name,
3769                                  x_description                      => l_clvl_desc,
3770                                  x_return_status                    => x_return_status,
3771                                  x_msg_count                        => x_msg_count,
3772                                  x_msg_data                         => x_msg_data
3773                                 );
3774                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
3775                g_pricing_status_tbl (g_index).coverage_level_name :=
3776                                                                    l_clvl_name;
3777                g_pricing_status_tbl (g_index).status_code :=
3778                                                             g_sts_code_success;
3779 
3780                IF x_price_details.status_code = g_partial_billed
3781                                  or
3782                   x_price_details.status_code = g_fully_billed
3783                THEN
3784                   g_pricing_status_tbl (g_index).status_text := g_billed_line;
3785                ELSE
3786                   g_pricing_status_tbl (g_index).status_text :=
3787                                                             g_sts_txt_success;
3788                END IF;
3789 
3790                g_index                    := g_index +
3791                                              1;
3792 
3793                IF    l_status = g_fully_billed
3794                   OR l_status = g_partial_billed
3795                THEN
3796                   x_price_details.status_code := g_billed;
3797                END IF;
3798             WHEN g_skip_exception
3799             THEN
3800                -- end debug log
3801                IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
3802                   )
3803                THEN
3804                   fnd_log.STRING (fnd_log.level_procedure,
3805                                   g_module ||
3806                                   l_api_name,
3807                                   '9000: Leaving ' ||
3808                                   g_pkg_name ||
3809                                   '.' ||
3810                                   l_api_name
3811                                  );
3812                END IF;
3813 
3814                -- Get covered line details
3815                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
3816                                  x_name                             => l_clvl_name,
3817                                  x_description                      => l_clvl_desc,
3818                                  x_return_status                    => x_return_status,
3819                                  x_msg_count                        => x_msg_count,
3820                                  x_msg_data                         => x_msg_data
3821                                 );
3822                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
3823                g_pricing_status_tbl (g_index).coverage_level_name :=
3824                                                                    l_clvl_name;
3825                g_pricing_status_tbl (g_index).status_code := g_sts_code_error;
3826                l_line_no                  :=
3827                                    get_line_no (l_input_detail_rec.subline_id);
3828 
3829                IF l_line_no IS NULL
3830                THEN
3831                   g_pricing_status_tbl (g_index).status_text :=
3832                            NVL (x_price_details.status_text, g_sts_txt_error);
3833                ELSE
3834                  -- bug 4730011
3835                  fnd_message.set_name ('OKS', 'OKS_LINE_REPRICE_SUCCESS');
3836                  fnd_message.set_token ('LINENO', l_line_no);
3837                  g_pricing_status_tbl (g_index).status_text := fnd_message.get;
3838                   -- l_line_no ||' ' ||NVL (x_price_details.status_text, g_sts_txt_error);
3839                END IF;
3840 
3841                g_index                    := g_index +
3842                                              1;
3843          END;
3844       END LOOP;
3845 
3846       l_clev_rec_in.ID           := l_input_detail_rec.line_id;
3847       l_clev_rec_in.price_negotiated :=
3848          get_amounts (p_id                               => l_input_detail_rec.line_id,
3849                       p_level                            => g_line_level);
3850       get_k_details (p_id                               => l_input_detail_rec.line_id,
3851                      p_type                             => g_okc_line,
3852                      x_k_det_rec                        => l_k_det_rec
3853                     );
3854       l_clev_rec_in.object_version_number := l_k_det_rec.object_version_number;
3855       okc_contract_pub.update_contract_line
3856                                           (p_api_version                      => l_api_version,
3857                                            p_init_msg_list                    => l_init_msg_list,
3858                                            x_return_status                    => x_return_status,
3859                                            x_msg_count                        => x_msg_count,
3860                                            x_msg_data                         => x_msg_data,
3861                                            p_clev_rec                         => l_clev_rec_in,
3862                                            x_clev_rec                         => l_clev_rec_out
3863                                           );
3864 
3865       IF x_return_status <> g_ret_sts_success
3866       THEN
3867          RAISE g_exc_error;
3868       END IF;
3869 
3870       -- end debug log
3871       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3872       THEN
3873          fnd_log.STRING (fnd_log.level_procedure,
3874                          g_module ||
3875                          l_api_name,
3876                          '1000: Leaving ' ||
3877                          g_pkg_name ||
3878                          '.' ||
3879                          l_api_name
3880                         );
3881       END IF;
3882    EXCEPTION
3883       WHEN g_exc_error
3884       THEN
3885          -- end debug log
3886          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3887          THEN
3888             fnd_log.STRING (fnd_log.level_procedure,
3889                             g_module ||
3890                             l_api_name,
3891                             '2000: Leaving ' ||
3892                             g_pkg_name ||
3893                             '.' ||
3894                             l_api_name
3895                            );
3896          END IF;
3897 
3898          NULL;
3899       WHEN OTHERS
3900       THEN
3901          -- end debug log
3902          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
3903          THEN
3904             fnd_log.STRING (fnd_log.level_procedure,
3905                             g_module ||
3906                             l_api_name,
3907                             '4000: Leaving ' ||
3908                             g_pkg_name ||
3909                             '.' ||
3910                             l_api_name
3911                            );
3912          END IF;
3913 
3914          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
3915          x_return_status            := g_ret_sts_unexp_error;
3916          okc_api.set_message (p_app_name                         => g_app_name,
3917                               p_msg_name                         => g_unexpected_error,
3918                               p_token1                           => g_sqlcode_token,
3919                               p_token1_value                     => SQLCODE,
3920                               p_token2                           => g_sqlerrm_token,
3921                               p_token2_value                     => SQLERRM
3922                              );
3923    END calculate_topline_price;
3924 
3925      /* skuchima procedure changes the single input to bulk input bug:7539977*/
3926    PROCEDURE single_to_bulk_input(
3927           p_req_line_tbl IN qp_preq_grp.line_tbl_type,
3928           p_req_qual_tbl IN qp_preq_grp.qual_tbl_type,
3929           p_req_line_attr_tbl IN qp_preq_grp.line_attr_tbl_type,
3930           p_req_line_detail_tbl IN qp_preq_grp.line_detail_tbl_type,
3931           p_req_line_detail_qual_tbl IN qp_preq_grp.line_detail_qual_tbl_type,
3932           p_req_line_detail_attr_tbl IN qp_preq_grp.line_detail_attr_tbl_type,
3933           p_req_related_lines_tbl IN qp_preq_grp.related_lines_tbl_type  ,
3934           p_visit_cnt IN NUMBER
3935      )IS
3936 
3937        p NUMBER;
3938        q NUMBER;
3939 
3940    BEGIN
3941 
3942              --input parametr1
3943         if p_req_line_tbl.count > 0 then
3944 
3945             p := p_req_line_tbl.first;
3946 
3947              loop
3948 
3949                if(p_req_line_tbl(p).line_type_code<>'order' or p_visit_cnt=1) then
3950 
3951                   g_line_tbl_ctr:=g_line_tbl_ctr+1;
3952                   g_req_line_tbl_blk(g_line_tbl_ctr)  :=p_req_line_tbl(p);
3953                   g_req_line_tbl_blk(g_line_tbl_ctr).line_index:=g_line_tbl_ctr;
3954 
3955                               --input parametr2
3956                         if  p_req_qual_tbl.count > 0 then
3957 
3958                               q :=  p_req_qual_tbl.first;
3959 
3960                               loop
3961 
3962                                   if(p_req_qual_tbl(q).line_index=p_req_line_tbl(p).line_index) then
3963 
3964                                      g_qual_tbl_ctr:=g_qual_tbl_ctr+1;
3965                                      g_req_qual_tbl_blk(g_qual_tbl_ctr)  := p_req_qual_tbl(p);
3966                                      g_req_qual_tbl_blk(g_qual_tbl_ctr).line_index:=  g_line_tbl_ctr;
3967                                   end if;
3968 
3969                               exit when p_req_qual_tbl.last = q;
3970                                   q := p_req_qual_tbl.next(q);
3971 
3972                               end loop;
3973 
3974 
3975                       end if;
3976 
3977 
3978                           --input parametr3
3979                       if  p_req_line_attr_tbl.count > 0 then
3980 
3981                             q :=  p_req_line_attr_tbl.first;
3982 
3983                             loop
3984 
3985                                   if(p_req_line_attr_tbl(q).line_index=p_req_line_tbl(p).line_index) then
3986 
3987                                     g_line_attr_tbl_ctr:=g_line_attr_tbl_ctr+1;
3988                                     g_req_line_attr_tbl_blk(g_line_attr_tbl_ctr)  := p_req_line_attr_tbl(q);
3989                                     g_req_line_attr_tbl_blk(g_line_attr_tbl_ctr).line_index:=g_line_tbl_ctr  ;
3990 
3991                                   end if;
3992 
3993 
3994                             exit when p_req_line_attr_tbl.last = q;
3995                                 q := p_req_line_attr_tbl.next(q);
3996 
3997                             end loop;
3998 
3999 
4000                     end if;
4001 
4002 
4003 
4004                               --input parametr4
4005                   if  p_req_line_detail_tbl.count > 0 then
4006 
4007                       q :=  p_req_line_detail_tbl.first;
4008 
4009                       loop
4010 
4011                           if(p_req_line_detail_tbl(q).line_index=p_req_line_tbl(p).line_index) then
4012 
4013                              g_line_detail_tbl_ctr:=g_line_detail_tbl_ctr+1;
4014                              g_req_line_detail_tbl_blk(g_line_detail_tbl_ctr)  := p_req_line_detail_tbl(q);
4015                              g_req_line_detail_tbl_blk(g_line_detail_tbl_ctr).line_detail_index  :=g_line_detail_tbl_ctr;
4016                              g_req_line_detail_tbl_blk(g_line_detail_tbl_ctr).line_index:=  g_line_tbl_ctr;
4017 
4018                           end if;
4019 
4020 
4021                       exit when p_req_line_detail_tbl.last = q;
4022                           q:= p_req_line_detail_tbl.next(q);
4023 
4024                       end loop;
4025 
4026 
4027               end if;
4028 
4029 
4030 
4031                     --input parametr7
4032                   if  p_req_related_lines_tbl.count > 0 then
4033 
4034                       q :=  p_req_related_lines_tbl.first;
4035 
4036                       loop
4037 
4038 
4039 
4040 
4041                             if(p_req_related_lines_tbl(q).line_index=p_req_line_tbl(p).line_index) then
4042 
4043                              g_related_lines_tbl_ctr:=g_related_lines_tbl_ctr+1;
4044                              g_req_related_lines_tbl_blk(g_related_lines_tbl_ctr)  := p_req_related_lines_tbl(q);
4045                              g_req_related_lines_tbl_blk(g_related_lines_tbl_ctr).related_line_index :=g_line_tbl_ctr+1;
4046                              g_req_related_lines_tbl_blk(g_related_lines_tbl_ctr).line_index:=  g_line_tbl_ctr;
4047 
4048                            end if;
4049 
4050                       exit when p_req_related_lines_tbl.last = q;
4051                           q := p_req_related_lines_tbl.next(q);
4052 
4053                       END LOOP;
4054 
4055 
4056               END IF;
4057 
4058 
4059 
4060 
4061                END IF;
4062 
4063                EXIT WHEN p_req_line_tbl.last = p;
4064                 p := p_req_line_tbl.next(p);
4065 
4066 
4067             END LOOP;
4068 
4069 
4070        END IF;
4071 
4072 
4073 
4074 
4075        --ignore g_req_line_detail_qual_tbl_blk
4076        --ignore g_req_line_detail_attr_tbl_blk
4077 
4078 
4079   END  single_to_bulk_input;
4080 
4081  /* skuchima Procedure changes the bulk output to single output for post processing of the data Bug:7539977*/
4082   PROCEDURE bulk_to_single_output(
4083          p_sub_line_id                 IN  NUMBER,
4084          lx_req_line_tbl               OUT NOCOPY qp_preq_grp.line_tbl_type,
4085          lx_req_qual_tbl               OUT NOCOPY qp_preq_grp.qual_tbl_type,
4086          lx_req_line_attr_tbl          OUT NOCOPY qp_preq_grp.line_attr_tbl_type,
4087          lx_req_line_detail_tbl        OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
4088          lx_req_line_detail_qual_tbl   OUT NOCOPY qp_preq_grp.line_detail_qual_tbl_type,
4089          lx_req_line_detail_attr_tbl   OUT NOCOPY qp_preq_grp.line_detail_attr_tbl_type,
4090          lx_req_related_lines_tbl      OUT NOCOPY qp_preq_grp.related_lines_tbl_type
4091                                 ) is
4092      p NUMBER;
4093      q NUMBER;
4094      l_sub_line_index        NUMBER;
4095      l_line_tbl_ctr          NUMBER:=0;
4096      l_qual_tbl_ctr          NUMBER:=0;
4097      l_line_attr_tbl_ctr     NUMBER:=0;
4098      l_line_detail_tbl_ctr   NUMBER:=0;
4099      l_line_detail_attr_tbl_ctr     NUMBER:=0;
4100      l_related_lines_tbl_ctr        NUMBER:=0;
4101      l_api_name                     CONSTANT VARCHAR2 (30)
4102                                                  := 'BULK_TO_SINGLE_OUTPUT';
4103 
4104 BEGIN
4105 
4106 
4107         --output parametr1
4108         if gx_req_line_tbl.count > 0 then
4109 
4110             p := gx_req_line_tbl.first;
4111 
4112              loop
4113 
4114                   if(gx_req_line_tbl(p).line_id=p_sub_line_id) then
4115                      l_line_tbl_ctr:=l_line_tbl_ctr+1;
4116                      lx_req_line_tbl(l_line_tbl_ctr):=gx_req_line_tbl(p);
4117                      lx_req_line_tbl(l_line_tbl_ctr).line_index:=1;
4118                      l_line_tbl_ctr:=l_line_tbl_ctr+1;
4119                      lx_req_line_tbl(l_line_tbl_ctr):=gx_req_line_tbl(gx_req_line_tbl(p).line_index+1);
4120                      l_sub_line_index:= gx_req_line_tbl(p).line_index;
4121 
4122                    end if;
4123                  exit when gx_req_line_tbl.last = p;
4124                 p := gx_req_line_tbl.next(p);
4125 
4126             end loop;
4127 
4128 
4129        end if;
4130 
4131 
4132 
4133 
4134 
4135        --output parametr2
4136         if gx_req_qual_tbl.count > 0 then
4137 
4138             p := gx_req_qual_tbl.first;
4139 
4140              loop
4141 
4142                   if(gx_req_qual_tbl(p).line_index = l_sub_line_index) then
4143 
4144                      l_qual_tbl_ctr:=l_qual_tbl_ctr+1;
4145                      lx_req_qual_tbl(l_qual_tbl_ctr):=gx_req_qual_tbl(p);
4146                      lx_req_qual_tbl(l_qual_tbl_ctr).line_index:=1;
4147                   end if;
4148 
4149                    if(gx_req_qual_tbl(p).line_index = l_sub_line_index+1) then
4150 
4151                      l_qual_tbl_ctr:=l_qual_tbl_ctr+1;
4152                      lx_req_qual_tbl(l_qual_tbl_ctr):=gx_req_qual_tbl(p);
4153                      lx_req_qual_tbl(l_qual_tbl_ctr).line_index:=2;
4154                   end if;
4155 
4156                  exit when gx_req_qual_tbl.last = p;
4157                 p := gx_req_qual_tbl.next(p);
4158 
4159             end loop;
4160 
4161 
4162        end if;
4163 
4164 
4165         --output parametr3
4166         if gx_req_line_attr_tbl.count > 0 then
4167 
4168             p := gx_req_line_attr_tbl.first;
4169 
4170              loop
4171 
4172                   if(gx_req_line_attr_tbl(p).line_index = l_sub_line_index) then
4173 
4174                      l_line_attr_tbl_ctr:=l_line_attr_tbl_ctr+1;
4175                      lx_req_line_attr_tbl(l_line_attr_tbl_ctr):=gx_req_line_attr_tbl(p);
4176                      lx_req_line_attr_tbl(l_line_attr_tbl_ctr).line_index:=1;
4177 
4178 
4179                   end if;
4180 
4181                    if(gx_req_line_attr_tbl(p).line_index = l_sub_line_index+1) then
4182 
4183                       l_line_attr_tbl_ctr:=l_line_attr_tbl_ctr+1;
4184                       lx_req_line_attr_tbl(l_line_attr_tbl_ctr):=gx_req_line_attr_tbl(p);
4185                      lx_req_line_attr_tbl(l_line_attr_tbl_ctr).line_index:=2;
4186 
4187 
4188                   end if;
4189 
4190                  exit when gx_req_line_attr_tbl.last = p;
4191                 p := gx_req_line_attr_tbl.next(p);
4192 
4193             end loop;
4194 
4195 
4196        end if;
4197 
4198 
4199 
4200         --output parametr4
4201         if gx_req_line_detail_tbl.count > 0 then
4202 
4203             p := gx_req_line_detail_tbl.first;
4204 
4205 
4206 
4207              loop
4208 
4209 
4210                   if(gx_req_line_detail_tbl(p).line_index = l_sub_line_index) then
4211 
4212                      l_line_detail_tbl_ctr:=l_line_detail_tbl_ctr+1;
4213                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr):=gx_req_line_detail_tbl(p);
4214                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr).line_index:=1;
4215                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr).line_detail_index:=l_line_detail_tbl_ctr;
4216 
4217                       --output parameter
4218                   if  gx_req_line_detail_attr_tbl.count>0 then
4219 
4220                        q:=  gx_req_line_detail_attr_tbl.first;
4221 
4222                         loop
4223 
4224                            if(gx_req_line_detail_attr_tbl(q).line_detail_index=p) then
4225 
4226                               l_line_detail_attr_tbl_ctr:=l_line_detail_attr_tbl_ctr+1;
4227                               lx_req_line_detail_attr_tbl(l_line_detail_attr_tbl_ctr) :=  gx_req_line_detail_attr_tbl(q);
4228                               lx_req_line_detail_attr_tbl(l_line_detail_attr_tbl_ctr).line_detail_index:= l_line_detail_tbl_ctr;
4229 
4230 
4231                             end if;
4232 
4233                            exit when gx_req_line_detail_attr_tbl.last = q;
4234                             q := gx_req_line_detail_attr_tbl.next(q);
4235 
4236 
4237                         end loop;
4238 
4239                   end if;  --req_line_detail_attr_tbl_cnt
4240 
4241 
4242                   end if;  --line_index
4243 
4244                    if(gx_req_line_detail_tbl(p).line_index = l_sub_line_index+1) then
4245 
4246                      l_line_detail_tbl_ctr:=l_line_detail_tbl_ctr+1;
4247                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr):=gx_req_line_detail_tbl(p);
4248                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr).line_index:=2;
4249                      lx_req_line_detail_tbl(l_line_detail_tbl_ctr).line_detail_index:=l_line_detail_tbl_ctr;
4250 
4251 
4252 
4253                       --output parameter
4254                    if  gx_req_line_detail_attr_tbl.count>0 then
4255 
4256                        q:=  gx_req_line_detail_attr_tbl.first;
4257 
4258 
4259 
4260                         loop
4261 
4262 
4263 
4264 
4265                            if(gx_req_line_detail_attr_tbl(q).line_detail_index=p) then
4266 
4267                               l_line_detail_attr_tbl_ctr:=l_line_detail_attr_tbl_ctr+1;
4268                               lx_req_line_detail_attr_tbl(l_line_detail_attr_tbl_ctr) :=  gx_req_line_detail_attr_tbl(q);
4269                               lx_req_line_detail_attr_tbl(l_line_detail_attr_tbl_ctr).line_detail_index:= l_line_detail_tbl_ctr;
4270 
4271 
4272 
4273                             end if;
4274 
4275 
4276                            exit when gx_req_line_detail_attr_tbl.last = q;
4277                             q := gx_req_line_detail_attr_tbl.next(q);
4278 
4279 
4280                         end loop;
4281 
4282                   end if;  --req_line_detail_attr_tbl_cnt
4283 
4284 
4285                   end if;
4286 
4287                 exit when gx_req_line_detail_tbl.last = p;
4288                 p := gx_req_line_detail_tbl.next(p);
4289 
4290             end loop;
4291 
4292 
4293        end if;
4294 
4295 
4296              --output parametr7
4297         if gx_req_related_lines_tbl.count > 0 then
4298 
4299             p := gx_req_related_lines_tbl.first;
4300 
4301              loop
4302 
4303                   if(gx_req_related_lines_tbl(p).line_index = l_sub_line_index) then
4304 
4305                      l_related_lines_tbl_ctr:=l_related_lines_tbl_ctr+1;
4306                      lx_req_related_lines_tbl(l_related_lines_tbl_ctr):=gx_req_related_lines_tbl(p);
4307                      lx_req_related_lines_tbl(l_related_lines_tbl_ctr).line_index:=1;
4308                      lx_req_related_lines_tbl(l_related_lines_tbl_ctr).related_line_index:=2;
4309 
4310                   end if;
4311 
4312 
4313 
4314                  exit when gx_req_related_lines_tbl.last = p;
4315                 p := gx_req_related_lines_tbl.next(p);
4316 
4317             end loop;
4318 
4319 
4320        end if;
4321 
4322 
4323 
4324  END bulk_to_single_output;
4325 
4326 /*skuchima :Bug:7539977 --Copied the CALCULATE_TOPLINE_PRICE Procedure to make changes to call the QP in bulk mode*/
4327  PROCEDURE calculate_topline_price_bulk (
4328       p_detail_rec                    in         oks_qp_pkg.input_details,
4329       x_price_details                 out nocopy oks_qp_pkg.price_details,
4330       x_modifier_details              out nocopy qp_preq_grp.line_detail_tbl_type,
4331       x_price_break_details           out nocopy oks_qp_pkg.g_price_break_tbl_type,
4332       x_return_status                 out nocopy varchar2,
4333       x_msg_count                     out nocopy number,
4334       x_msg_data                      out nocopy varchar2
4335    )
4336    is
4337       l_api_name                     constant varchar2 (30)
4338                                                  := 'CALCULATE_TOPLINE_PRICE_BULK';
4339 
4340       cursor l_subline_csr (
4341          p_cle_id                                 number
4342       )
4343       is
4344          select   id,
4345                   start_date,
4346                   end_date,
4347                   lse_id
4348              from okc_k_lines_b
4349             where cle_id = p_cle_id
4350               and lse_id in (7, 9, 25)
4351               and date_cancelled is null                               --[llc]
4352               and date_terminated is null                  -- bug 5504157
4353          order by line_number;
4354 
4355       l_input_detail_rec                      oks_qp_pkg.input_details;
4356       l_rail_rec                              oks_tax_util_pvt.ra_rec_type;
4357       l_k_det_rec                             k_details_rec;
4358       l_khdr_rec_in                           oks_contract_hdr_pub.khrv_rec_type;
4359       l_khdr_rec_out                          oks_contract_hdr_pub.khrv_rec_type;
4360       l_kln_rec_in                            oks_contract_line_pub.klnv_rec_type;
4361       l_kln_rec_out                           oks_contract_line_pub.klnv_rec_type;
4362       l_clev_rec_in                           okc_contract_pub.clev_rec_type;
4363       l_clev_rec_out                          okc_contract_pub.clev_rec_type;
4364       l_subs_item                             boolean := false;
4365       l_clvl_name                             varchar2 (240);
4366       l_clvl_desc                             varchar2 (1000);
4367       l_tlvl_name                             varchar2 (800);
4368       l_tlvl_desc                             varchar2 (1000);
4369       l_line_no                               varchar2 (300);
4370       l_status                                varchar2 (30);         --3912685
4371 
4372 
4373       l_control_rec                           qp_preq_grp.control_record_type;
4374       l_req_line_tbl                          qp_preq_grp.line_tbl_type;
4375       l_req_line_detail_tbl                   qp_preq_grp.line_detail_tbl_type;
4376       l_req_related_lines_tbl                 qp_preq_grp.related_lines_tbl_type;
4377       l_req_qual_tbl                          qp_preq_grp.qual_tbl_type;
4378       l_req_line_attr_tbl                     qp_preq_grp.line_attr_tbl_type;
4379       l_req_line_detail_qual_tbl              qp_preq_grp.line_detail_qual_tbl_type;
4380       l_req_line_detail_attr_tbl              qp_preq_grp.line_detail_attr_tbl_type;
4381 
4382       lx_req_line_tbl                         qp_preq_grp.line_tbl_type;
4383       lx_req_qual_tbl                         qp_preq_grp.qual_tbl_type;
4384       lx_req_line_attr_tbl                    qp_preq_grp.line_attr_tbl_type;
4385       lx_req_line_detail_tbl                  qp_preq_grp.line_detail_tbl_type;
4386       lx_req_line_detail_qual_tbl             qp_preq_grp.line_detail_qual_tbl_type;
4387       lx_req_line_detail_attr_tbl             qp_preq_grp.line_detail_attr_tbl_type;
4388       lx_req_related_lines_tbl                qp_preq_grp.related_lines_tbl_type;
4389       lx_return_status                        varchar2 (1);
4390       lx_return_status_text                   varchar2 (2000);
4391 
4392        p number;
4393 
4394 
4395        l_visit_cnt number:=0;
4396 
4397    begin
4398       -- start debug log
4399       if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
4400       then
4401          fnd_log.string (fnd_log.level_procedure,
4402                          g_module ||
4403                          l_api_name,
4404                          '100: entered ' ||
4405                          g_pkg_name ||
4406                          '.' ||
4407                          l_api_name
4408                         );
4409       end if;
4410 
4411           --empty the global tables
4412 
4413 
4414       g_req_line_tbl_blk.delete;
4415       g_req_line_detail_tbl_blk.delete;
4416       g_req_related_lines_tbl_blk.delete;
4417       g_req_qual_tbl_blk.delete;
4418       g_req_line_attr_tbl_blk.delete;
4419       g_req_line_detail_qual_tbl_blk.delete;
4420       g_req_line_detail_attr_tbl_blk.delete;
4421 
4422 
4423       g_line_tbl_ctr :=0;
4424       g_qual_tbl_ctr :=0;
4425       g_line_attr_tbl_ctr :=0;
4426       g_line_detail_tbl_ctr:=0;
4427       g_related_lines_tbl_ctr:=0;
4428 
4429       gx_req_line_tbl.delete;
4430       gx_req_qual_tbl.delete;
4431       gx_req_line_attr_tbl.delete;
4432       gx_req_line_detail_tbl.delete;
4433       gx_req_line_detail_qual_tbl.delete;
4434       gx_req_line_detail_attr_tbl.delete;
4435       gx_req_related_lines_tbl.delete;
4436 
4437 
4438 
4439 
4440       x_return_status            := g_ret_sts_success;
4441       l_input_detail_rec         := p_detail_rec;
4442       -- get top line details
4443       get_line_details (p_line_id                          => l_input_detail_rec.line_id,
4444                         x_name                             => l_tlvl_name,
4445                         x_description                      => l_tlvl_desc,
4446                         x_return_status                    => x_return_status,
4447                         x_msg_count                        => x_msg_count,
4448                         x_msg_data                         => x_msg_data
4449                        );
4450 
4451       if x_return_status <> g_ret_sts_success
4452       then
4453          if (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
4454          then
4455             fnd_log.string (fnd_log.level_statement,
4456                             g_module ||
4457                             l_api_name,
4458                             '362:get line details error in topline'
4459                            );
4460          end if;
4461 
4462          -- errorout('get line details error in topline');
4463          raise g_exc_error;
4464       end if;
4465 
4466       --loop through the cursor for pre processing
4467 
4468       for l_subline_rec in l_subline_csr (l_input_detail_rec.line_id)
4469       loop
4470          begin
4471             if l_subline_rec.lse_id in (9, 25)
4472             then
4473                l_subs_item                := is_subs_item (l_subline_rec.id);
4474             else
4475                l_subs_item                := false;
4476             end if;
4477 
4478             -- if its a subscription item, skip iteration
4479             if not l_subs_item
4480             then
4481                l_input_detail_rec.subline_id := l_subline_rec.id;
4482                /** 3912685 **/
4483                check_pricing_eligibility
4484                                  (p_line_id                          => l_input_detail_rec.subline_id,
4485                                   x_status                           => l_status,
4486                                   x_return_status                    => x_return_status,
4487                                   x_msg_count                        => x_msg_count,
4488                                   x_msg_data                         => x_msg_data
4489                                  );
4490 
4491                if x_return_status <> g_ret_sts_success
4492                then
4493                   raise g_exc_error;
4494                end if;
4495 
4496                if l_status <> g_oks_success
4497                then
4498                   x_price_details.status_code := l_status;
4499                   raise g_exc_cant_price;
4500                end if;
4501 
4502 
4503                  ---call oks_qp_pkg.calc_price_pre to populate input bulk table
4504                   oks_qp_pkg.calc_price_pre
4505                       (p_detail_rec                       => l_input_detail_rec,
4506                        l_control_rec                      => l_control_rec      ,
4507                        l_req_line_tbl                     => l_req_line_tbl      ,
4508                        l_req_qual_tbl                     => l_req_qual_tbl       ,
4509                        l_req_line_attr_tbl                => l_req_line_attr_tbl   ,
4510                        l_req_line_detail_tbl              => l_req_line_detail_tbl  ,
4511                        l_req_line_detail_qual_tbl         => l_req_line_detail_qual_tbl,
4512                        l_req_line_detail_attr_tbl         => l_req_line_detail_attr_tbl ,
4513                        l_req_related_lines_tbl            => l_req_related_lines_tbl    ,
4514                        x_return_status                    => x_return_status
4515                       );
4516 
4517 
4518                       l_visit_cnt:=l_visit_cnt+1;
4519                   --call procedure to capture the input into bulk table
4520 
4521                    single_to_bulk_input
4522                           (
4523                           p_req_line_tbl =>l_req_line_tbl,
4524                           p_req_qual_tbl =>l_req_qual_tbl,
4525                           p_req_line_attr_tbl => l_req_line_attr_tbl,
4526                           p_req_line_detail_tbl =>l_req_line_detail_tbl,
4527                           p_req_line_detail_qual_tbl => l_req_line_detail_qual_tbl,
4528                           p_req_line_detail_attr_tbl =>l_req_line_detail_attr_tbl,
4529                           p_req_related_lines_tbl =>l_req_related_lines_tbl,
4530                           p_visit_cnt=>l_visit_cnt
4531                         );
4532 
4533 
4534 
4535             end if;               -- skip iteration if its a subscription item
4536           exception
4537             when g_exc_cant_price
4538             then
4539                -- end debug log
4540                if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
4541                   )
4542                then
4543                   fnd_log.string (fnd_log.level_procedure,
4544                                   g_module ||
4545                                   l_api_name,
4546                                   '7000: leaving ' ||
4547                                   g_pkg_name ||
4548                                   '.' ||
4549                                   l_api_name
4550                                  );
4551                end if;
4552 
4553                -- get covered line details
4554                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
4555                                  x_name                             => l_clvl_name,
4556                                  x_description                      => l_clvl_desc,
4557                                  x_return_status                    => x_return_status,
4558                                  x_msg_count                        => x_msg_count,
4559                                  x_msg_data                         => x_msg_data
4560                                 );
4561                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
4562                g_pricing_status_tbl (g_index).coverage_level_name :=
4563                                                                    l_clvl_name;
4564                g_pricing_status_tbl (g_index).status_code :=
4565                                                             g_sts_code_success;
4566 
4567                if x_price_details.status_code = g_partial_billed
4568                                  or
4569                   x_price_details.status_code = g_fully_billed
4570                then
4571                   g_pricing_status_tbl (g_index).status_text := g_billed_line;
4572                else
4573                   g_pricing_status_tbl (g_index).status_text :=
4574                                                             g_sts_txt_success;
4575                end if;
4576 
4577                g_index                    := g_index +
4578                                              1;
4579 
4580                if    l_status = g_fully_billed
4581                   or l_status = g_partial_billed
4582                then
4583                   x_price_details.status_code := g_billed;
4584                end if;
4585             end;
4586          end loop; --l_subline_rec
4587 
4588   if (fnd_log.level_statement >= fnd_log.g_current_runtime_level)   then
4589     --
4590     -- input parameter 1: l_control_rec
4591     --
4592                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************'
4593                                );
4594                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* input parameter l_control_rec *************'
4595                                 );
4596                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************'
4597                                );
4598                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.pricing_event : '|| l_control_rec.pricing_event
4599                                 );
4600                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.calculate_flag : '|| l_control_rec.calculate_flag
4601                                 );
4602                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.simulation_flag : '|| l_control_rec.simulation_flag
4603                                 );
4604                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.rounding_flag : '|| l_control_rec.rounding_flag
4605                                 );
4606                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.gsa_check_flag : '|| l_control_rec.gsa_check_flag
4607                                 );
4608                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.gsa_dup_check_flag : '|| l_control_rec.gsa_dup_check_flag
4609                                 );
4610                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.temp_table_insert_flag : '|| l_control_rec.temp_table_insert_flag
4611                                 );
4612                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.manual_discount_flag : '|| l_control_rec.manual_discount_flag
4613                                 );
4614                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.debug_flag : '|| l_control_rec.debug_flag
4615                                 );
4616                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.source_order_amount_flag : '|| l_control_rec.source_order_amount_flag
4617                                 );
4618                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.public_api_call_flag : '|| l_control_rec.public_api_call_flag
4619                                 );
4620                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.manual_adjustments_call_flag : '|| l_control_rec.manual_adjustments_call_flag
4621                                 );
4622                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.get_freight_flag : '|| l_control_rec.get_freight_flag
4623                                 );
4624                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.request_type_code : '|| l_control_rec.request_type_code
4625                                 );
4626                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.view_code : '|| l_control_rec.view_code
4627                                 );
4628                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.check_cust_view_flag : '|| l_control_rec.check_cust_view_flag
4629                                 );
4630                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.full_pricing_call : '|| l_control_rec.full_pricing_call
4631                                 );
4632                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.use_multi_currency : '|| l_control_rec.use_multi_currency
4633                                 );
4634                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.user_conversion_rate : '|| l_control_rec.user_conversion_rate
4635                                 );
4636                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.user_conversion_type : '|| l_control_rec.user_conversion_type
4637                                 );
4638                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.function_currency : '|| l_control_rec.function_currency
4639                                 );
4640                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: l_control_rec.org_id : '|| l_control_rec.org_id
4641                                 );
4642 
4643     --
4644     -- input parameter 2: g_req_line_tbl_blk
4645     --
4646         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4647         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ********** input parameter 2: g_req_line_tbl_blk ****************');
4648         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk.count '|| g_req_line_tbl_blk.count
4649                         );
4650         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4651         if g_req_line_tbl_blk.count > 0 then
4652             p := g_req_line_tbl_blk.first;
4653                 loop
4654                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_line_tbl_blk('|| p ||') *************'
4655                                 );
4656                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').request_type_code : '|| g_req_line_tbl_blk(p).request_type_code
4657                                 );
4658                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').pricing_event : '|| g_req_line_tbl_blk(p).pricing_event
4659                                 );
4660                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').header_id : '|| g_req_line_tbl_blk(p).header_id
4661                                 );
4662                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_index : '|| g_req_line_tbl_blk(p).line_index
4663                                 );
4664                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_id : '|| g_req_line_tbl_blk(p).line_id
4665                                 );
4666                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_type_code : '|| g_req_line_tbl_blk(p).line_type_code
4667                                 );
4668                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').pricing_effective_date : '|| g_req_line_tbl_blk(p).pricing_effective_date
4669                                 );
4670                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_first : '|| g_req_line_tbl_blk(p).active_date_first
4671                                 );
4672                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_first_type : '|| g_req_line_tbl_blk(p).active_date_first_type
4673                                 );
4674                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_second : '|| g_req_line_tbl_blk(p).active_date_second
4675                                 );
4676                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_first_type : '|| g_req_line_tbl_blk(p).active_date_first_type
4677                                 );
4678                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_second : '|| g_req_line_tbl_blk(p).active_date_second
4679                                 );
4680                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').active_date_second_type : '|| g_req_line_tbl_blk(p).active_date_second_type
4681                                 );
4682                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_quantity : '|| g_req_line_tbl_blk(p).line_quantity
4683                                 );
4684                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_uom_code : '|| g_req_line_tbl_blk(p).line_uom_code
4685                                 );
4686                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').uom_quantity : '|| g_req_line_tbl_blk(p).uom_quantity
4687                                 );
4688                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').priced_quantity : '|| g_req_line_tbl_blk(p).priced_quantity
4689                                 );
4690                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').priced_uom_code : '|| g_req_line_tbl_blk(p).priced_uom_code
4691                                 );
4692                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').currency_code : '|| g_req_line_tbl_blk(p).currency_code
4693                                 );
4694                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').unit_price : '|| g_req_line_tbl_blk(p).unit_price
4695                                 );
4696                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').percent_price : '|| g_req_line_tbl_blk(p).percent_price
4697                                 );
4698                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').adjusted_unit_price : '|| g_req_line_tbl_blk(p).adjusted_unit_price
4699                                 );
4700                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').updated_adjusted_unit_price : '|| g_req_line_tbl_blk(p).updated_adjusted_unit_price
4701                                 );
4702                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').parent_price : '|| g_req_line_tbl_blk(p).parent_price
4703                                 );
4704                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').parent_quantity : '|| g_req_line_tbl_blk(p).parent_quantity
4705                                 );
4706                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').rounding_factor : '|| g_req_line_tbl_blk(p).rounding_factor
4707                                 );
4708                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').parent_uom_code : '|| g_req_line_tbl_blk(p).parent_uom_code
4709                                 );
4710                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').pricing_phase_id : '|| g_req_line_tbl_blk(p).pricing_phase_id
4711                                 );
4712                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').price_flag : '|| g_req_line_tbl_blk(p).price_flag
4713                                 );
4714                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').processed_code : '|| g_req_line_tbl_blk(p).processed_code
4715                                 );
4716                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').price_request_code : '|| g_req_line_tbl_blk(p).price_request_code
4717                                 );
4718                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').hold_code : '|| g_req_line_tbl_blk(p).hold_code
4719                                 );
4720                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').hold_text : '|| g_req_line_tbl_blk(p).hold_text
4721                                 );
4722                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').status_code : '|| g_req_line_tbl_blk(p).status_code
4723                                 );
4724                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').status_text : '|| g_req_line_tbl_blk(p).status_text
4725                                 );
4726                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').usage_pricing_type : '|| g_req_line_tbl_blk(p).usage_pricing_type
4727                                 );
4728                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_category : '|| g_req_line_tbl_blk(p).line_category
4729                                 );
4730                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').contract_start_date : '|| g_req_line_tbl_blk(p).contract_start_date
4731                                 );
4732                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').contract_end_date : '|| g_req_line_tbl_blk(p).contract_end_date
4733                                 );
4734                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').line_unit_price : '|| g_req_line_tbl_blk(p).line_unit_price
4735                                 );
4736                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').extended_price : '|| g_req_line_tbl_blk(p).extended_price
4737                                 );
4738                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').list_price_override_flag : '|| g_req_line_tbl_blk(p).list_price_override_flag
4739                                 );
4740                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_tbl_blk('|| p ||').charge_periodicity_code : '|| g_req_line_tbl_blk(p).charge_periodicity_code
4741                                 );
4742                 exit when g_req_line_tbl_blk.last = p;
4743                 p := g_req_line_tbl_blk.next(p);
4744             end loop;
4745         end if; -- g_req_line_tbl_blk.count > 0
4746 
4747     --
4748     -- input parameter 3: g_req_qual_tbl_blk
4749     --
4750         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4751         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************** input parameter 3: g_req_qual_tbl_blk ******************');
4752         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk.count '|| g_req_qual_tbl_blk.count
4753                         );
4754         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4755         if g_req_qual_tbl_blk.count > 0 then
4756             p := g_req_qual_tbl_blk.first;
4757                 loop
4758                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_qual_tbl_blk('|| p ||') *************'
4759                                 );
4760                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').line_index : '|| g_req_qual_tbl_blk(p).line_index
4761                                 );
4762                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').qualifier_context : '|| g_req_qual_tbl_blk(p).qualifier_context
4763                                 );
4764                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').qualifier_attribute : '|| g_req_qual_tbl_blk(p).qualifier_attribute
4765                                 );
4766                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').qualifier_attr_value_from : '|| g_req_qual_tbl_blk(p).qualifier_attr_value_from
4767                                 );
4768                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').qualifier_attr_value_to : '|| g_req_qual_tbl_blk(p).qualifier_attr_value_to
4769                                 );
4770                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').comparison_operator_code : '|| g_req_qual_tbl_blk(p).comparison_operator_code
4771                                 );
4772                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').validated_flag : '|| g_req_qual_tbl_blk(p).validated_flag
4773                                 );
4774                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').status_code : '|| g_req_qual_tbl_blk(p).status_code
4775                                 );
4776                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_qual_tbl_blk('|| p ||').status_text : '|| g_req_qual_tbl_blk(p).status_text
4777                                 );
4778                 exit when g_req_qual_tbl_blk.last = p;
4779                 p := g_req_qual_tbl_blk.next(p);
4780             end loop;
4781         end if; -- l_req_qual_tbl.count > 0
4782     --
4783     -- input parameter 4: g_req_line_attr_tbl_blk
4784     --
4785         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4786         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** input parameter 4: g_req_line_attr_tbl_blk ******************');
4787         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk.count '|| g_req_line_attr_tbl_blk.count
4788                         );
4789         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4790         if g_req_line_attr_tbl_blk.count > 0 then
4791            p := g_req_line_attr_tbl_blk.first;
4792                 loop
4793                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_line_attr_tbl_blk('|| p ||') *************'
4794                                 );
4795                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').line_index : '|| g_req_line_attr_tbl_blk(p).line_index
4796                                 );
4797                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').pricing_context : '|| g_req_line_attr_tbl_blk(p).pricing_context
4798                                 );
4799                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').pricing_attribute : '|| g_req_line_attr_tbl_blk(p).pricing_attribute
4800                                 );
4801                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').pricing_attr_value_from : '|| g_req_line_attr_tbl_blk(p).pricing_attr_value_from
4802                                 );
4803                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').pricing_attr_value_to : '|| g_req_line_attr_tbl_blk(p).pricing_attr_value_to
4804                                 );
4805                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').validated_flag : '|| g_req_line_attr_tbl_blk(p).validated_flag
4806                                 );
4807                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').status_code : '|| g_req_line_attr_tbl_blk(p).status_code
4808                                 );
4809                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_attr_tbl_blk('|| p ||').status_text : '|| g_req_line_attr_tbl_blk(p).status_text
4810                                 );
4811                 exit when g_req_line_attr_tbl_blk.last = p;
4812                 p := g_req_line_attr_tbl_blk.next(p);
4813             end loop;
4814         end if; -- l_req_line_attr_tbl.count > 0
4815 
4816     --
4817     -- input parameter 5: g_req_line_detail_tbl_blk
4818     --
4819         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4820         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** input parameter 5: g_req_line_detail_tbl_blk ******************');
4821             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk.count '|| g_req_line_detail_tbl_blk.count
4822                         );
4823         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4824 
4825         if g_req_line_detail_tbl_blk.count > 0 then
4826             p := g_req_line_detail_tbl_blk.first;
4827                 loop
4828                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_line_detail_tbl_blk('|| p ||') *************'
4829                                 );
4830                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').line_detail_index : '|| g_req_line_detail_tbl_blk(p).line_detail_index
4831                                 );
4832                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').line_detail_id : '|| g_req_line_detail_tbl_blk(p).line_detail_id
4833                                 );
4834                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').line_detail_type_code : '|| g_req_line_detail_tbl_blk(p).line_detail_type_code
4835                                 );
4836                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').line_index : '|| g_req_line_detail_tbl_blk(p).line_index
4837                                 );
4838                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').list_header_id : '|| g_req_line_detail_tbl_blk(p).list_header_id
4839                                 );
4840                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').list_line_id : '|| g_req_line_detail_tbl_blk(p).list_line_id
4841                                 );
4842                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').list_line_type_code : '|| g_req_line_detail_tbl_blk(p).list_line_type_code
4843                                 );
4844                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').substitution_type_code : '|| g_req_line_detail_tbl_blk(p).substitution_type_code
4845                                 );
4846                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').substitution_from : '|| g_req_line_detail_tbl_blk(p).substitution_from
4847                                 );
4848                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').substitution_to : '|| g_req_line_detail_tbl_blk(p).substitution_to
4849                                 );
4850                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').automatic_flag : '|| g_req_line_detail_tbl_blk(p).automatic_flag
4851                                 );
4852                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').operand_calculation_code : '|| g_req_line_detail_tbl_blk(p).operand_calculation_code
4853                                 );
4854                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').operand_value : '|| g_req_line_detail_tbl_blk(p).operand_value
4855                                 );
4856                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').pricing_group_sequence : '|| g_req_line_detail_tbl_blk(p).pricing_group_sequence
4857                                 );
4858                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').price_break_type_code : '|| g_req_line_detail_tbl_blk(p).price_break_type_code
4859                                 );
4860                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').created_from_list_type_code : '|| g_req_line_detail_tbl_blk(p).created_from_list_type_code
4861                                 );
4862                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').pricing_phase_id : '|| g_req_line_detail_tbl_blk(p).pricing_phase_id
4863                                 );
4864                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').list_price : '|| g_req_line_detail_tbl_blk(p).list_price
4865                                 );
4866                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').line_quantity : '|| g_req_line_detail_tbl_blk(p).line_quantity
4867                                 );
4868                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').adjustment_amount : '|| g_req_line_detail_tbl_blk(p).adjustment_amount
4869                                 );
4870                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').applied_flag : '|| g_req_line_detail_tbl_blk(p).applied_flag
4871                                 );
4872                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').modifier_level_code : '|| g_req_line_detail_tbl_blk(p).modifier_level_code
4873                                 );
4874                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').status_code : '|| g_req_line_detail_tbl_blk(p).status_code
4875                                 );
4876                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').status_text : '|| g_req_line_detail_tbl_blk(p).status_text
4877                                 );
4878                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').substitution_attribute : '|| g_req_line_detail_tbl_blk(p).substitution_attribute
4879                                 );
4880                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').accrual_flag : '|| g_req_line_detail_tbl_blk(p).accrual_flag
4881                                 );
4882                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').list_line_no : '|| g_req_line_detail_tbl_blk(p).list_line_no
4883                                 );
4884                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').estim_gl_value : '|| g_req_line_detail_tbl_blk(p).estim_gl_value
4885                                 );
4886                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').accrual_conversion_rate : '|| g_req_line_detail_tbl_blk(p).accrual_conversion_rate
4887                                 );
4888                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').override_flag : '|| g_req_line_detail_tbl_blk(p).override_flag
4889                                 );
4890                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').print_on_invoice_flag : '|| g_req_line_detail_tbl_blk(p).print_on_invoice_flag
4891                                 );
4892                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').inventory_item_id : '|| g_req_line_detail_tbl_blk(p).inventory_item_id
4893                                 );
4894                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').organization_id : '|| g_req_line_detail_tbl_blk(p).organization_id
4895                                 );
4896                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').related_item_id : '|| g_req_line_detail_tbl_blk(p).related_item_id
4897                                 );
4898                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').relationship_type_id : '|| g_req_line_detail_tbl_blk(p).relationship_type_id
4899                                 );
4900                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').estim_accrual_rate : '|| g_req_line_detail_tbl_blk(p).estim_accrual_rate
4901                                 );
4902                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').expiration_date : '|| g_req_line_detail_tbl_blk(p).expiration_date
4903                                 );
4904                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').benefit_price_list_line_id : '|| g_req_line_detail_tbl_blk(p).benefit_price_list_line_id
4905                                 );
4906                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').recurring_flag : '|| g_req_line_detail_tbl_blk(p).recurring_flag
4907                                 );
4908                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').recurring_value : '|| g_req_line_detail_tbl_blk(p).recurring_value
4909                                 );
4910                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').benefit_limit : '|| g_req_line_detail_tbl_blk(p).benefit_limit
4911                                 );
4912                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').charge_type_code : '|| g_req_line_detail_tbl_blk(p).charge_type_code
4913                                 );
4914                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').charge_subtype_code : '|| g_req_line_detail_tbl_blk(p).charge_subtype_code
4915                                 );
4916                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').include_on_returns_flag : '|| g_req_line_detail_tbl_blk(p).include_on_returns_flag
4917                                 );
4918                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').benefit_qty : '|| g_req_line_detail_tbl_blk(p).benefit_qty
4919                                 );
4920                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').benefit_uom_code : '|| g_req_line_detail_tbl_blk(p).benefit_uom_code
4921                                 );
4922                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').proration_type_code : '|| g_req_line_detail_tbl_blk(p).proration_type_code
4923                                 );
4924                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').source_system_code : '|| g_req_line_detail_tbl_blk(p).source_system_code
4925                                 );
4926                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').rebate_transaction_type_code : '|| g_req_line_detail_tbl_blk(p).rebate_transaction_type_code
4927                                 );
4928                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').secondary_pricelist_ind : '|| g_req_line_detail_tbl_blk(p).secondary_pricelist_ind
4929                                 );
4930                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').group_value : '|| g_req_line_detail_tbl_blk(p).group_value
4931                                 );
4932                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').comments : '|| g_req_line_detail_tbl_blk(p).comments
4933                                 );
4934                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').updated_flag : '|| g_req_line_detail_tbl_blk(p).updated_flag
4935                                 );
4936                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').process_code : '|| g_req_line_detail_tbl_blk(p).process_code
4937                                 );
4938                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').limit_code : '|| g_req_line_detail_tbl_blk(p).limit_code
4939                                 );
4940                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').limit_text : '|| g_req_line_detail_tbl_blk(p).limit_text
4941                                 );
4942                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').formula_id : '|| g_req_line_detail_tbl_blk(p).formula_id
4943                                 );
4944                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').calculation_code : '|| g_req_line_detail_tbl_blk(p).calculation_code
4945                                 );
4946                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').rounding_factor : '|| g_req_line_detail_tbl_blk(p).rounding_factor
4947                                 );
4948                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').currency_detail_id : '|| g_req_line_detail_tbl_blk(p).currency_detail_id
4949                                 );
4950                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').currency_header_id : '|| g_req_line_detail_tbl_blk(p).currency_header_id
4951                                 );
4952                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').selling_rounding_factor : '|| g_req_line_detail_tbl_blk(p).selling_rounding_factor
4953                                 );
4954                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').order_currency : '|| g_req_line_detail_tbl_blk(p).order_currency
4955                                 );
4956                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').pricing_effective_date : '|| g_req_line_detail_tbl_blk(p).pricing_effective_date
4957                                 );
4958                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').base_currency_code : '|| g_req_line_detail_tbl_blk(p).base_currency_code
4959                                 );
4960                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').change_reason_code : '|| g_req_line_detail_tbl_blk(p).change_reason_code
4961                                 );
4962                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').change_reason_text : '|| g_req_line_detail_tbl_blk(p).change_reason_text
4963                                 );
4964                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').break_uom_code : '|| g_req_line_detail_tbl_blk(p).break_uom_code
4965                                 );
4966                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').break_uom_context : '|| g_req_line_detail_tbl_blk(p).break_uom_context
4967                                 );
4968                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_tbl_blk('|| p ||').break_uom_attribute : '|| g_req_line_detail_tbl_blk(p).break_uom_attribute
4969                                 );
4970                 exit when g_req_line_detail_tbl_blk.last = p;
4971                 p := g_req_line_detail_tbl_blk.next(p);
4972             end loop;
4973         end if; -- g_req_line_detail_tbl_blk.count > 0
4974     --
4975     -- input parameter 6: g_req_line_detail_qual_tbl_blk
4976     --
4977         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4978         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** input parameter 6: g_req_line_detail_qual_tbl_blk ******************');
4979             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk.count '|| g_req_line_detail_qual_tbl_blk.count
4980                         );
4981         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
4982 
4983         if g_req_line_detail_qual_tbl_blk.count > 0 then
4984            p := g_req_line_detail_qual_tbl_blk.first;
4985                 loop
4986                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_line_detail_qual_tbl_blk('|| p ||') *************'
4987                                 );
4988                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').line_detail_index : '|| g_req_line_detail_qual_tbl_blk(p).line_detail_index
4989                                 );
4990                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').qualifier_context : '|| g_req_line_detail_qual_tbl_blk(p).qualifier_context
4991                                 );
4992                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').qualifier_attribute : '|| g_req_line_detail_qual_tbl_blk(p).qualifier_attribute
4993                                 );
4994                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').qualifier_attr_value_from : '|| g_req_line_detail_qual_tbl_blk(p).qualifier_attr_value_from
4995                                 );
4996                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').qualifier_attr_value_to : '|| g_req_line_detail_qual_tbl_blk(p).qualifier_attr_value_to
4997                                 );
4998                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').comparison_operator_code : '|| g_req_line_detail_qual_tbl_blk(p).comparison_operator_code
4999                                 );
5000                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').validated_flag : '|| g_req_line_detail_qual_tbl_blk(p).validated_flag
5001                                 );
5002                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').status_code : '|| g_req_line_detail_qual_tbl_blk(p).status_code
5003                                 );
5004                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_qual_tbl_blk('|| p ||').status_text : '|| g_req_line_detail_qual_tbl_blk(p).status_text
5005                                 );
5006                 exit when g_req_line_detail_qual_tbl_blk.last = p;
5007                 p := g_req_line_detail_qual_tbl_blk.next(p);
5008             end loop;
5009         end if; -- g_req_line_detail_qual_tbl_blk.count > 0
5010     --
5011     -- input parameter 7: g_req_line_detail_attr_tbl_blk
5012     --
5013         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5014         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** input parameter 7: g_req_line_detail_attr_tbl_blk ******************');
5015             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk.count '|| g_req_line_detail_attr_tbl_blk.count
5016                         );
5017         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5018 
5019         if g_req_line_detail_attr_tbl_blk.count > 0 then
5020            p := g_req_line_detail_attr_tbl_blk.first;
5021                 loop
5022                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_line_detail_attr_tbl_blk('|| p ||') *************'
5023                                 );
5024                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').line_detail_index : '|| g_req_line_detail_attr_tbl_blk(p).line_detail_index
5025                                 );
5026                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').line_index : '|| g_req_line_detail_attr_tbl_blk(p).line_index
5027                                 );
5028                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').pricing_context : '|| g_req_line_detail_attr_tbl_blk(p).pricing_context
5029                                 );
5030                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').pricing_attribute : '|| g_req_line_detail_attr_tbl_blk(p).pricing_attribute
5031                                 );
5032                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').pricing_attr_value_from : '|| g_req_line_detail_attr_tbl_blk(p).pricing_attr_value_from
5033                                 );
5034                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').pricing_attr_value_to : '|| g_req_line_detail_attr_tbl_blk(p).pricing_attr_value_to
5035                                 );
5036                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').validated_flag : '|| g_req_line_detail_attr_tbl_blk(p).validated_flag
5037                                 );
5038                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').status_code : '|| g_req_line_detail_attr_tbl_blk(p).status_code
5039                                 );
5040                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_line_detail_attr_tbl_blk('|| p ||').status_text : '|| g_req_line_detail_attr_tbl_blk(p).status_text
5041                                 );
5042                 exit when g_req_line_detail_attr_tbl_blk.last = p;
5043                 p := g_req_line_detail_attr_tbl_blk.next(p);
5044             end loop;
5045         end if; -- g_req_line_detail_attr_tbl_blk.count > 0
5046 
5047     --
5048     -- input parameter 8: g_req_related_lines_tbl_blk
5049     --
5050         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5051         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** input parameter 8: g_req_related_lines_tbl_blk ******************');
5052         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk.count '|| g_req_related_lines_tbl_blk.count
5053                         );
5054         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5055 
5056         if g_req_related_lines_tbl_blk.count > 0 then
5057            p := g_req_related_lines_tbl_blk.first;
5058                 loop
5059                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter g_req_related_lines_tbl_blk('|| p ||') *************'
5060                                 );
5061                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').line_index : '|| g_req_related_lines_tbl_blk(p).line_index
5062                                 );
5063                  fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').line_detail_index : '|| g_req_related_lines_tbl_blk(p).line_detail_index
5064                                 );
5065                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').relationship_type_code : '|| g_req_related_lines_tbl_blk(p).relationship_type_code
5066                                 );
5067                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').related_line_index : '|| g_req_related_lines_tbl_blk(p).related_line_index
5068                                 );
5069                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').related_line_detail_index : '|| g_req_related_lines_tbl_blk(p).related_line_detail_index
5070                                 );
5071                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').status_code : '|| g_req_related_lines_tbl_blk(p).status_code
5072                                 );
5073                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: g_req_related_lines_tbl_blk('|| p ||').status_text : '|| g_req_related_lines_tbl_blk(p).status_text
5074                                 );
5075                 exit when g_req_related_lines_tbl_blk.last = p;
5076                 p := g_req_related_lines_tbl_blk.next(p);
5077             end loop;
5078         end if; -- g_req_related_lines_tbl_blk.count > 0
5079 
5080     end if; -- skekkar end added debug statements to print all the parameters bug 5069673
5081 
5082 
5083       if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
5084        then
5085 
5086          fnd_log.string (fnd_log.level_procedure,g_module ||l_api_name,
5087                          '19014: qp_preq_pub.price_request start time : '||to_char(sysdate,'dd-mon-yyyy hh24:mi:ssss')
5088                         );
5089 
5090        end if;
5091  --call the qp package for pricing
5092 
5093              --pricing engine call
5094       qp_preq_pub.price_request
5095                        (p_control_rec                      => l_control_rec,
5096                         p_line_tbl                         => g_req_line_tbl_blk,
5097                         p_qual_tbl                         => g_req_qual_tbl_blk,
5098                         p_line_attr_tbl                    => g_req_line_attr_tbl_blk,
5099                         p_line_detail_tbl                  => g_req_line_detail_tbl_blk,
5100                         p_line_detail_qual_tbl             => g_req_line_detail_qual_tbl_blk,
5101                         p_line_detail_attr_tbl             => g_req_line_detail_attr_tbl_blk,
5102                         p_related_lines_tbl                => g_req_related_lines_tbl_blk,
5103                         x_line_tbl                         => gx_req_line_tbl,
5104                         x_line_qual                        => gx_req_qual_tbl,
5105                         x_line_attr_tbl                    => gx_req_line_attr_tbl,
5106                         x_line_detail_tbl                  => gx_req_line_detail_tbl,
5107                         x_line_detail_qual_tbl             => gx_req_line_detail_qual_tbl,
5108                         x_line_detail_attr_tbl             => gx_req_line_detail_attr_tbl,
5109                         x_related_lines_tbl                => gx_req_related_lines_tbl,
5110                         x_return_status                    => lx_return_status,
5111                         x_return_status_text               => lx_return_status_text
5112                        );
5113 
5114       if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
5115       then
5116          fnd_log.string (fnd_log.level_procedure,g_module ||l_api_name,
5117                          '19014: **** after calling qp_preq_pub.price_request ***** status : '||lx_return_status
5118                         );
5119          fnd_log.string (fnd_log.level_procedure,g_module ||l_api_name,
5120                          '19014: qp_preq_pub.price_request end time : '||to_char(sysdate,'dd-mon-yyyy hh24:mi:ssss')
5121                         );
5122 
5123          fnd_log.string (fnd_log.level_procedure,
5124                          g_module ||
5125                          l_api_name,
5126                          '19014:*** after qp call status **** ' ||
5127                          lx_return_status
5128                         );
5129          fnd_log.string (fnd_log.level_procedure,
5130                          g_module ||
5131                          l_api_name,
5132                          '19014:*** after qp call status text **** ' ||
5133                          lx_return_status_text
5134                         );
5135       end if;
5136 
5137 
5138       if (fnd_log.level_statement >= fnd_log.g_current_runtime_level)   then
5139     --
5140     -- output parameter 1: gx_req_line_tbl
5141     --
5142         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5143         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl.count '|| gx_req_line_tbl.count
5144                         );
5145         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5146         if gx_req_line_tbl.count > 0 then
5147             p := gx_req_line_tbl.first;
5148                 loop
5149                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_line_tbl('|| p ||') *************'
5150                                 );
5151                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').request_type_code : '|| gx_req_line_tbl(p).request_type_code
5152                                 );
5153                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').pricing_event : '|| gx_req_line_tbl(p).pricing_event
5154                                 );
5155                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').header_id : '|| gx_req_line_tbl(p).header_id
5156                                 );
5157                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_index : '|| gx_req_line_tbl(p).line_index
5158                                 );
5159                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_id : '|| gx_req_line_tbl(p).line_id
5160                                 );
5161                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_type_code : '|| gx_req_line_tbl(p).line_type_code
5162                                 );
5163                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').pricing_effective_date : '|| gx_req_line_tbl(p).pricing_effective_date
5164                                 );
5165                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_first : '|| gx_req_line_tbl(p).active_date_first
5166                                 );
5167                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_first_type : '|| gx_req_line_tbl(p).active_date_first_type
5168                                 );
5169                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_second : '|| gx_req_line_tbl(p).active_date_second
5170                                 );
5171                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_first_type : '|| gx_req_line_tbl(p).active_date_first_type
5172                                 );
5173                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_second : '|| gx_req_line_tbl(p).active_date_second
5174                                 );
5175                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').active_date_second_type : '|| gx_req_line_tbl(p).active_date_second_type
5176                                 );
5177                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_quantity : '|| gx_req_line_tbl(p).line_quantity
5178                                 );
5179                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_uom_code : '|| gx_req_line_tbl(p).line_uom_code
5180                                 );
5181                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').uom_quantity : '|| gx_req_line_tbl(p).uom_quantity
5182                                 );
5183                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').priced_quantity : '|| gx_req_line_tbl(p).priced_quantity
5184                                 );
5185                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').priced_uom_code : '|| gx_req_line_tbl(p).priced_uom_code
5186                                 );
5187                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').currency_code : '|| gx_req_line_tbl(p).currency_code
5188                                 );
5189                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').unit_price : '|| gx_req_line_tbl(p).unit_price
5190                                 );
5191                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').percent_price : '|| gx_req_line_tbl(p).percent_price
5192                                 );
5193                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').adjusted_unit_price : '|| gx_req_line_tbl(p).adjusted_unit_price
5194                                 );
5195                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').updated_adjusted_unit_price : '|| gx_req_line_tbl(p).updated_adjusted_unit_price
5196                                 );
5197                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').parent_price : '|| gx_req_line_tbl(p).parent_price
5198                                 );
5199                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').parent_quantity : '|| gx_req_line_tbl(p).parent_quantity
5200                                 );
5201                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').rounding_factor : '|| gx_req_line_tbl(p).rounding_factor
5202                                 );
5203                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').parent_uom_code : '|| gx_req_line_tbl(p).parent_uom_code
5204                                 );
5205                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').pricing_phase_id : '|| gx_req_line_tbl(p).pricing_phase_id
5206                                 );
5207                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').price_flag : '|| gx_req_line_tbl(p).price_flag
5208                                 );
5209                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').processed_code : '|| gx_req_line_tbl(p).processed_code
5210                                 );
5211                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').price_request_code : '|| gx_req_line_tbl(p).price_request_code
5212                                 );
5213                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').hold_code : '|| gx_req_line_tbl(p).hold_code
5214                                 );
5215                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').hold_text : '|| gx_req_line_tbl(p).hold_text
5216                                 );
5217                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').status_code : '|| gx_req_line_tbl(p).status_code
5218                                 );
5219                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').status_text : '|| gx_req_line_tbl(p).status_text
5220                                 );
5221                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').usage_pricing_type : '|| gx_req_line_tbl(p).usage_pricing_type
5222                                 );
5223                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_category : '|| gx_req_line_tbl(p).line_category
5224                                 );
5225                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').contract_start_date : '|| gx_req_line_tbl(p).contract_start_date
5226                                 );
5227                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').contract_end_date : '|| gx_req_line_tbl(p).contract_end_date
5228                                 );
5229                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').line_unit_price : '|| gx_req_line_tbl(p).line_unit_price
5230                                 );
5231                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').extended_price : '|| gx_req_line_tbl(p).extended_price
5232                                 );
5233                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').list_price_override_flag : '|| gx_req_line_tbl(p).list_price_override_flag
5234                                 );
5235                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_tbl('|| p ||').charge_periodicity_code : '|| gx_req_line_tbl(p).charge_periodicity_code
5236                                 );
5237                 exit when gx_req_line_tbl.last = p;
5238                 p := gx_req_line_tbl.next(p);
5239             end loop;
5240         end if; -- gx_req_line_tbl.count > 0
5241 
5242     --
5243     -- output parameter 2: gx_req_qual_tbl
5244     --
5245         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5246         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* output parameter 2: gx_req_qual_tbl ************');
5247         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl.count '|| gx_req_qual_tbl.count
5248                         );
5249         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5250         if gx_req_qual_tbl.count > 0 then
5251             p := gx_req_qual_tbl.first;
5252                 loop
5253                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_qual_tbl('|| p ||') *************'
5254                                 );
5255                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').line_index : '|| gx_req_qual_tbl(p).line_index
5256                                 );
5257                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').qualifier_context : '|| gx_req_qual_tbl(p).qualifier_context
5258                                 );
5259                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').qualifier_attribute : '|| gx_req_qual_tbl(p).qualifier_attribute
5260                                 );
5261                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').qualifier_attr_value_from : '|| gx_req_qual_tbl(p).qualifier_attr_value_from
5262                                 );
5263                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').qualifier_attr_value_to : '|| gx_req_qual_tbl(p).qualifier_attr_value_to
5264                                 );
5265                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').comparison_operator_code : '|| gx_req_qual_tbl(p).comparison_operator_code
5266                                 );
5267                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').validated_flag : '|| gx_req_qual_tbl(p).validated_flag
5268                                 );
5269                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').status_code : '|| gx_req_qual_tbl(p).status_code
5270                                 );
5271                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_qual_tbl('|| p ||').status_text : '|| gx_req_qual_tbl(p).status_text
5272                                 );
5273                 exit when gx_req_qual_tbl.last = p;
5274                 p := gx_req_qual_tbl.next(p);
5275             end loop;
5276         end if; -- gx_req_qual_tbl.count > 0
5277     --
5278     -- output parameter 3: gx_req_line_attr_tbl
5279     --
5280         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5281         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ****************** output parameter 3: gx_req_line_attr_tbl ************');
5282         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl.count '|| gx_req_qual_tbl.count
5283                         );
5284         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5285         if gx_req_line_attr_tbl.count > 0 then
5286             p := gx_req_line_attr_tbl.first;
5287                 loop
5288                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_line_attr_tbl('|| p ||') *************'
5289                                 );
5290                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').line_index : '|| gx_req_line_attr_tbl(p).line_index
5291                                 );
5292                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').pricing_context : '|| gx_req_line_attr_tbl(p).pricing_context
5293                                 );
5294                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').pricing_attribute : '|| gx_req_line_attr_tbl(p).pricing_attribute
5295                                 );
5296                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').pricing_attr_value_from : '|| gx_req_line_attr_tbl(p).pricing_attr_value_from
5297                                 );
5298                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').pricing_attr_value_to : '|| gx_req_line_attr_tbl(p).pricing_attr_value_to
5299                                 );
5300                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').validated_flag : '|| gx_req_line_attr_tbl(p).validated_flag
5301                                 );
5302                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').status_code : '|| gx_req_line_attr_tbl(p).status_code
5303                                 );
5304                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_attr_tbl('|| p ||').status_text : '|| gx_req_line_attr_tbl(p).status_text
5305                                 );
5306                 exit when gx_req_line_attr_tbl.last = p;
5307                 p := gx_req_line_attr_tbl.next(p);
5308             end loop;
5309         end if; -- gx_req_line_attr_tbl.count > 0
5310 
5311     --
5312     -- output parameter 4: gx_req_line_detail_tbl
5313     --
5314         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5315         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ****************** output parameter 4: gx_req_line_detail_tbl ************');
5316             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl.count '|| gx_req_line_detail_tbl.count
5317                         );
5318         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5319 
5320         if gx_req_line_detail_tbl.count > 0 then
5321             p := gx_req_line_detail_tbl.first;
5322                 loop
5323                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_line_detail_tbl('|| p ||') *************'
5324                                 );
5325                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').line_detail_index : '|| gx_req_line_detail_tbl(p).line_detail_index
5326                                 );
5327                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').line_detail_id : '|| gx_req_line_detail_tbl(p).line_detail_id
5328                                 );
5329                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').line_detail_type_code : '|| gx_req_line_detail_tbl(p).line_detail_type_code
5330                                 );
5331                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').line_index : '|| gx_req_line_detail_tbl(p).line_index
5332                                 );
5333                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').list_header_id : '|| gx_req_line_detail_tbl(p).list_header_id
5334                                 );
5335                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').list_line_id : '|| gx_req_line_detail_tbl(p).list_line_id
5336                                 );
5337                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').list_line_type_code : '|| gx_req_line_detail_tbl(p).list_line_type_code
5338                                 );
5339                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').substitution_type_code : '|| gx_req_line_detail_tbl(p).substitution_type_code
5340                                 );
5341                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').substitution_from : '|| gx_req_line_detail_tbl(p).substitution_from
5342                                 );
5343                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').substitution_to : '|| gx_req_line_detail_tbl(p).substitution_to
5344                                 );
5345                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').automatic_flag : '|| gx_req_line_detail_tbl(p).automatic_flag
5346                                 );
5347                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').operand_calculation_code : '|| gx_req_line_detail_tbl(p).operand_calculation_code
5348                                 );
5349                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').operand_value : '|| gx_req_line_detail_tbl(p).operand_value
5350                                 );
5351                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').pricing_group_sequence : '|| gx_req_line_detail_tbl(p).pricing_group_sequence
5352                                 );
5353                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').price_break_type_code : '|| gx_req_line_detail_tbl(p).price_break_type_code
5354                                 );
5355                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').created_from_list_type_code : '|| gx_req_line_detail_tbl(p).created_from_list_type_code
5356                                 );
5357                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').pricing_phase_id : '|| gx_req_line_detail_tbl(p).pricing_phase_id
5358                                 );
5359                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').list_price : '|| gx_req_line_detail_tbl(p).list_price
5360                                 );
5361                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').line_quantity : '|| gx_req_line_detail_tbl(p).line_quantity
5362                                 );
5363                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').adjustment_amount : '|| gx_req_line_detail_tbl(p).adjustment_amount
5364                                 );
5365                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').applied_flag : '|| gx_req_line_detail_tbl(p).applied_flag
5366                                 );
5367                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').modifier_level_code : '|| gx_req_line_detail_tbl(p).modifier_level_code
5368                                 );
5369                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').status_code : '|| gx_req_line_detail_tbl(p).status_code
5370                                 );
5371                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').status_text : '|| gx_req_line_detail_tbl(p).status_text
5372                                 );
5373                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').substitution_attribute : '|| gx_req_line_detail_tbl(p).substitution_attribute
5374                                 );
5375                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').accrual_flag : '|| gx_req_line_detail_tbl(p).accrual_flag
5376                                 );
5377                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').list_line_no : '|| gx_req_line_detail_tbl(p).list_line_no
5378                                 );
5379                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').estim_gl_value : '|| gx_req_line_detail_tbl(p).estim_gl_value
5380                                 );
5381                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').accrual_conversion_rate : '|| gx_req_line_detail_tbl(p).accrual_conversion_rate
5382                                 );
5383                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').override_flag : '|| gx_req_line_detail_tbl(p).override_flag
5384                                 );
5385                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').print_on_invoice_flag : '|| gx_req_line_detail_tbl(p).print_on_invoice_flag
5386                                 );
5387                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').inventory_item_id : '|| gx_req_line_detail_tbl(p).inventory_item_id
5388                                 );
5389                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').organization_id : '|| gx_req_line_detail_tbl(p).organization_id
5390                                 );
5391                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').related_item_id : '|| gx_req_line_detail_tbl(p).related_item_id
5392                                 );
5393                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').relationship_type_id : '|| gx_req_line_detail_tbl(p).relationship_type_id
5394                                 );
5395                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').estim_accrual_rate : '|| gx_req_line_detail_tbl(p).estim_accrual_rate
5396                                 );
5397                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').expiration_date : '|| gx_req_line_detail_tbl(p).expiration_date
5398                                 );
5399                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').benefit_price_list_line_id : '|| gx_req_line_detail_tbl(p).benefit_price_list_line_id
5400                                 );
5401                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').recurring_flag : '|| gx_req_line_detail_tbl(p).recurring_flag
5402                                 );
5403                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').recurring_value : '|| gx_req_line_detail_tbl(p).recurring_value
5404                                 );
5405                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').benefit_limit : '|| gx_req_line_detail_tbl(p).benefit_limit
5406                                 );
5407                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').charge_type_code : '|| gx_req_line_detail_tbl(p).charge_type_code
5408                                 );
5409                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').charge_subtype_code : '|| gx_req_line_detail_tbl(p).charge_subtype_code
5410                                 );
5411                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').include_on_returns_flag : '|| gx_req_line_detail_tbl(p).include_on_returns_flag
5412                                 );
5413                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').benefit_qty : '|| gx_req_line_detail_tbl(p).benefit_qty
5414                                 );
5415                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').benefit_uom_code : '|| gx_req_line_detail_tbl(p).benefit_uom_code
5416                                 );
5417                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').proration_type_code : '|| gx_req_line_detail_tbl(p).proration_type_code
5418                                 );
5419                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').source_system_code : '|| gx_req_line_detail_tbl(p).source_system_code
5420                                 );
5421                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').rebate_transaction_type_code : '|| gx_req_line_detail_tbl(p).rebate_transaction_type_code
5422                                 );
5423                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').secondary_pricelist_ind : '|| gx_req_line_detail_tbl(p).secondary_pricelist_ind
5424                                 );
5425                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').group_value : '|| gx_req_line_detail_tbl(p).group_value
5426                                 );
5427                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').comments : '|| gx_req_line_detail_tbl(p).comments
5428                                 );
5429                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').updated_flag : '|| gx_req_line_detail_tbl(p).updated_flag
5430                                 );
5431                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').process_code : '|| gx_req_line_detail_tbl(p).process_code
5432                                 );
5433                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').limit_code : '|| gx_req_line_detail_tbl(p).limit_code
5434                                 );
5435                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').limit_text : '|| gx_req_line_detail_tbl(p).limit_text
5436                                 );
5437                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').formula_id : '|| gx_req_line_detail_tbl(p).formula_id
5438                                 );
5439                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').calculation_code : '|| gx_req_line_detail_tbl(p).calculation_code
5440                                 );
5441                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').rounding_factor : '|| gx_req_line_detail_tbl(p).rounding_factor
5442                                 );
5443                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').currency_detail_id : '|| gx_req_line_detail_tbl(p).currency_detail_id
5444                                 );
5445                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').currency_header_id : '|| gx_req_line_detail_tbl(p).currency_header_id
5446                                 );
5447                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').selling_rounding_factor : '|| gx_req_line_detail_tbl(p).selling_rounding_factor
5448                                 );
5449                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').order_currency : '|| gx_req_line_detail_tbl(p).order_currency
5450                                 );
5451                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').pricing_effective_date : '|| gx_req_line_detail_tbl(p).pricing_effective_date
5452                                 );
5453                         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').base_currency_code : '|| gx_req_line_detail_tbl(p).base_currency_code
5454                                 );
5455                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').change_reason_code : '|| gx_req_line_detail_tbl(p).change_reason_code
5456                                 );
5457                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').change_reason_text : '|| gx_req_line_detail_tbl(p).change_reason_text
5458                                 );
5459                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').break_uom_code : '|| gx_req_line_detail_tbl(p).break_uom_code
5460                                 );
5461                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').break_uom_context : '|| gx_req_line_detail_tbl(p).break_uom_context
5462                                 );
5463                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_tbl('|| p ||').break_uom_attribute : '|| gx_req_line_detail_tbl(p).break_uom_attribute
5464                                 );
5465                 exit when gx_req_line_detail_tbl.last = p;
5466                 p := gx_req_line_detail_tbl.next(p);
5467             end loop;
5468         end if; -- gx_req_line_detail_tbl.count > 0
5469 
5470     --
5471     -- output parameter 5: gx_req_line_detail_qual_tbl
5472     --
5473         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5474         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** output parameter 5: gx_req_line_detail_qual_tbl ******************');
5475             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl.count '|| gx_req_line_detail_qual_tbl.count
5476                         );
5477         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5478 
5479         if gx_req_line_detail_qual_tbl.count > 0 then
5480             p := gx_req_line_detail_qual_tbl.first;
5481                 loop
5482                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_line_detail_qual_tbl('|| p ||') *************'
5483                                 );
5484                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').line_detail_index : '|| gx_req_line_detail_qual_tbl(p).line_detail_index
5485                                 );
5486                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').qualifier_context : '|| gx_req_line_detail_qual_tbl(p).qualifier_context
5487                                 );
5488                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').qualifier_attribute : '|| gx_req_line_detail_qual_tbl(p).qualifier_attribute
5489                                 );
5490                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').qualifier_attr_value_from : '|| gx_req_line_detail_qual_tbl(p).qualifier_attr_value_from
5491                                 );
5492                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').qualifier_attr_value_to : '|| gx_req_line_detail_qual_tbl(p).qualifier_attr_value_to
5493                                 );
5494                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').comparison_operator_code : '|| gx_req_line_detail_qual_tbl(p).comparison_operator_code
5495                                 );
5496                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').validated_flag : '|| gx_req_line_detail_qual_tbl(p).validated_flag
5497                                 );
5498                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').status_code : '|| gx_req_line_detail_qual_tbl(p).status_code
5499                                 );
5500                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_qual_tbl('|| p ||').status_text : '|| gx_req_line_detail_qual_tbl(p).status_text
5501                                 );
5502                 exit when gx_req_line_detail_qual_tbl.last = p;
5503                 p := gx_req_line_detail_qual_tbl.next(p);
5504             end loop;
5505         end if; -- gx_req_line_detail_qual_tbl.count > 0
5506  --
5507     -- output parameter 6: gx_req_line_detail_attr_tbl
5508     --
5509         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5510         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** output parameter 6: gx_req_line_detail_attr_tbl ******************');
5511             fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl.count '|| gx_req_line_detail_attr_tbl.count
5512                         );
5513         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5514 
5515         if gx_req_line_detail_attr_tbl.count > 0 then
5516             p := gx_req_line_detail_attr_tbl.first;
5517                 loop
5518                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_line_detail_attr_tbl('|| p ||') *************'
5519                                 );
5520                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').line_detail_index : '|| gx_req_line_detail_attr_tbl(p).line_detail_index
5521                                 );
5522                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').line_index : '|| gx_req_line_detail_attr_tbl(p).line_index
5523                                 );
5524                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').pricing_context : '|| gx_req_line_detail_attr_tbl(p).pricing_context
5525                                 );
5526                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').pricing_attribute : '|| gx_req_line_detail_attr_tbl(p).pricing_attribute
5527                                 );
5528                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').pricing_attr_value_from : '|| gx_req_line_detail_attr_tbl(p).pricing_attr_value_from
5529                                 );
5530                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').pricing_attr_value_to : '|| gx_req_line_detail_attr_tbl(p).pricing_attr_value_to
5531                                 );
5532                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').validated_flag : '|| gx_req_line_detail_attr_tbl(p).validated_flag
5533                                 );
5534                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').status_code : '|| gx_req_line_detail_attr_tbl(p).status_code
5535                                 );
5536                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_line_detail_attr_tbl('|| p ||').status_text : '|| gx_req_line_detail_attr_tbl(p).status_text
5537                                 );
5538                 exit when gx_req_line_detail_attr_tbl.last = p;
5539                 p := gx_req_line_detail_attr_tbl.next(p);
5540             end loop;
5541         end if; -- gx_req_line_detail_attr_tbl.count > 0
5542 
5543     --
5544     -- output parameter 7: gx_req_related_lines_tbl
5545     --
5546         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5547         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ***************** output parameter 7: gx_req_related_lines_tbl ******************');
5548         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl.count '|| gx_req_related_lines_tbl.count
5549                         );
5550         fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: *********************************************************');
5551 
5552         if gx_req_related_lines_tbl.count > 0 then
5553             p := gx_req_related_lines_tbl.first;
5554                 loop
5555                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: ************* parameter gx_req_related_lines_tbl('|| p ||') *************'
5556                                 );
5557                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').line_index : '|| gx_req_related_lines_tbl(p).line_index
5558                                 );
5559                  fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').line_detail_index : '|| gx_req_related_lines_tbl(p).line_detail_index
5560                                 );
5561                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').relationship_type_code : '|| gx_req_related_lines_tbl(p).relationship_type_code
5562                                 );
5563                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').related_line_index : '|| gx_req_related_lines_tbl(p).related_line_index
5564                                 );
5565                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').related_line_detail_index : '|| gx_req_related_lines_tbl(p).related_line_detail_index
5566                                 );
5567                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').status_code : '|| gx_req_related_lines_tbl(p).status_code
5568                                 );
5569                 fnd_log.string (fnd_log.level_statement, g_module || l_api_name,'qp_call: gx_req_related_lines_tbl('|| p ||').status_text : '|| gx_req_related_lines_tbl(p).status_text
5570                                 );
5571                 exit when gx_req_related_lines_tbl.last = p;
5572                 p := gx_req_related_lines_tbl.next(p);
5573             end loop;
5574         end if; -- gx_req_related_lines_tbl.count > 0
5575        end if; -- skekkar end added debug statements to print all the parameters bug 5069673
5576 
5577 
5578 
5579 
5580 
5581         --loop through the cursor for post processing
5582       for l_subline_rec in l_subline_csr (l_input_detail_rec.line_id)
5583       loop
5584          begin
5585             if l_subline_rec.lse_id in (9, 25)
5586             then
5587                l_subs_item                := is_subs_item (l_subline_rec.id);
5588             else
5589                l_subs_item                := false;
5590             end if;
5591 
5592             -- if its a subscription item, skip iteration
5593             if not l_subs_item
5594             then
5595                l_input_detail_rec.subline_id := l_subline_rec.id;
5596                /** 3912685 **/
5597                check_pricing_eligibility
5598                                  (p_line_id                          => l_input_detail_rec.subline_id,
5599                                   x_status                           => l_status,
5600                                   x_return_status                    => x_return_status,
5601                                   x_msg_count                        => x_msg_count,
5602                                   x_msg_data                         => x_msg_data
5603                                  );
5604 
5605                if x_return_status <> g_ret_sts_success
5606                then
5607                   raise g_exc_error;
5608                end if;
5609 
5610                if l_status <> g_oks_success
5611                then
5612                   x_price_details.status_code := l_status;
5613                   raise g_exc_cant_price;
5614                end if;
5615 
5616                --qp call status if return error through exception for every line
5617                if lx_return_status <> g_ret_sts_success
5618                then
5619                   if (fnd_log.level_statement >=
5620                                                fnd_log.g_current_runtime_level
5621                      )
5622                   then
5623                      fnd_log.string
5624                            (fnd_log.level_statement,
5625                             g_module ||
5626                             l_api_name,
5627                             '363:calc price error after sapi call in topline'
5628                            );
5629                   end if;
5630 
5631                   -- errorout('calc price error after sapi call in topline');
5632                   raise g_skip_exception;
5633                end if;
5634 
5635 
5636                 --call bulk to single output
5637                bulk_to_single_output( l_input_detail_rec.subline_id,
5638                                       lx_req_line_tbl ,
5639                                       lx_req_qual_tbl ,
5640                                       lx_req_line_attr_tbl  ,
5641                                       lx_req_line_detail_tbl,
5642                                       lx_req_line_detail_qual_tbl,
5643                                       lx_req_line_detail_attr_tbl,
5644                                       lx_req_related_lines_tbl);
5645 
5646                --call the procedure calc_price_post for post processing
5647 
5648                         oks_qp_pkg.calc_price_post
5649                        (
5650                         p_detail_rec                       => l_input_detail_rec,
5651                         lx_req_line_tbl                    => lx_req_line_tbl,
5652                         lx_req_qual_tbl                    => lx_req_qual_tbl,
5653                         lx_req_line_attr_tbl               => lx_req_line_attr_tbl,
5654                         lx_req_line_detail_tbl             => lx_req_line_detail_tbl,
5655                         lx_req_line_detail_qual_tbl        => lx_req_line_detail_qual_tbl,
5656                         lx_req_line_detail_attr_tbl        => lx_req_line_detail_attr_tbl,
5657                         lx_req_related_lines_tbl           => lx_req_related_lines_tbl,
5658                         x_price_details                    => x_price_details,
5659                         x_modifier_details                 => x_modifier_details,
5660                         x_price_break_details              => x_price_break_details,
5661                         x_return_status                    => x_return_status,
5662                         x_msg_count                        => x_msg_count,
5663                         x_msg_data                         => x_msg_data
5664                        );
5665 
5666               l_rail_rec.amount          :=
5667                                       nvl (x_price_details.serv_ext_amount, 0);
5668                l_rail_rec.tax_value       := null;
5669                l_rail_rec.amount_includes_tax_flag := null;
5670                -- calculate tax
5671                oks_tax_util_pvt.get_tax
5672                                    (p_api_version                      => l_api_version,
5673                                     p_init_msg_list                    => l_init_msg_list,
5674                                     p_chr_id                           => l_input_detail_rec.chr_id,
5675                                     p_cle_id                           => l_input_detail_rec.subline_id,
5676                                     px_rail_rec                        => l_rail_rec,
5677                                     x_msg_count                        => x_msg_count,
5678                                     x_msg_data                         => x_msg_data,
5679                                     x_return_status                    => x_return_status
5680                                    );
5681 
5682                if x_return_status <> g_ret_sts_success
5683                then
5684                   if (fnd_log.level_statement >=
5685                                                fnd_log.g_current_runtime_level
5686                      )
5687                   then
5688                      fnd_log.string (fnd_log.level_statement,
5689                                      g_module ||
5690                                      l_api_name,
5691                                      '364:tax calc error in topline x_return_status '||x_return_status
5692                                     );
5693                      fnd_log.string (fnd_log.level_statement,
5694                                      g_module ||
5695                                      l_api_name,
5696                                      'x_msg_data '||x_msg_data
5697                                     );
5698                   end if;
5699 
5700                   -- errorout('tax calc error in topline');
5701                   -- bug 5001677, even if tax error continue
5702                   -- raise g_skip_exception;
5703                     l_rail_rec.tax_value                :=  0;
5704                     l_rail_rec.amount_includes_tax_flag := 'N';
5705                end if;
5706 
5707                if (fnd_log.level_statement >= fnd_log.g_current_runtime_level
5708                   )
5709                then
5710                   fnd_log.string (fnd_log.level_statement,
5711                                   g_module ||
5712                                   l_api_name,
5713                                   '366:l_rail_rec.tax_value = ' ||
5714                                   l_rail_rec.tax_value
5715                                  );
5716                   fnd_log.string
5717                               (fnd_log.level_statement,
5718                                g_module ||
5719                                l_api_name,
5720                                '367:l_rail_rec.amount_includes_tax_flag = ' ||
5721                                l_rail_rec.amount_includes_tax_flag
5722                               );
5723                end if;
5724 
5725                --errorout('l_rail_rec.amount_includes_tax_flag = '||l_rail_rec.amount_includes_tax_flag );
5726                --errorout('l_rail_rec.tax_value = '||  l_rail_rec.tax_value );
5727                --errorout('l_rail_rec.amount_includes_tax_flag = '||l_rail_rec.amount_includes_tax_flag );
5728                l_kln_rec_in.cle_id        := l_input_detail_rec.subline_id;
5729                l_kln_rec_in.dnz_chr_id    := l_input_detail_rec.chr_id;
5730                l_kln_rec_in.tax_inclusive_yn :=
5731                                            l_rail_rec.amount_includes_tax_flag;
5732 
5733                if l_rail_rec.amount_includes_tax_flag = 'N'
5734                then
5735                   l_kln_rec_in.tax_amount    := nvl (l_rail_rec.tax_value, 0);
5736                else
5737                   l_kln_rec_in.tax_amount    := 0;
5738                end if;
5739 
5740                if x_price_details.prod_price_list_id is not null
5741                then
5742                   l_kln_rec_in.prod_price    :=
5743                                            x_price_details.prod_price_list_id;
5744                end if;
5745 
5746                if x_price_details.serv_price_list_id is not null
5747                then
5748                   l_kln_rec_in.service_price :=
5749                                            x_price_details.serv_price_list_id;
5750                end if;
5751 
5752                l_kln_rec_in.clvl_list_price :=
5753                                           x_price_details.prod_list_unit_price;
5754                l_kln_rec_in.clvl_quantity := x_price_details.prod_priced_qty;
5755                l_kln_rec_in.clvl_extended_amt :=
5756                                                x_price_details.prod_ext_amount;
5757                l_kln_rec_in.toplvl_operand_code :=
5758                                                  x_price_details.serv_operator;
5759                l_kln_rec_in.toplvl_operand_val := x_price_details.serv_operand;
5760                l_kln_rec_in.clvl_uom_code := x_price_details.prod_priced_uom;
5761                l_kln_rec_in.toplvl_quantity := x_price_details.serv_qty;
5762                l_kln_rec_in.toplvl_uom_code := x_price_details.serv_priced_uom;
5763                l_kln_rec_in.toplvl_adj_price :=
5764                                            x_price_details.serv_adj_unit_price;
5765                -- gchadha --
5766                -- bug 4015739 --
5767                -- 17-nov-2004 --
5768                l_kln_rec_in.status_text   :=
5769                   substr (nvl (x_price_details.status_text, g_sts_txt_success),
5770                           1,
5771                           450
5772                          );
5773                     --l_kln_rec_in.status_text         := nvl(x_price_details.status_text,g_sts_txt_success);
5774                -- end gchadha --
5775                l_kln_rec_in.toplvl_price_qty :=
5776                                                x_price_details.serv_priced_qty;
5777                get_k_details (p_id                               => l_input_detail_rec.subline_id,
5778                               p_type                             => g_oks_line,
5779                               x_k_det_rec                        => l_k_det_rec
5780                              );
5781                l_kln_rec_in.id            := l_k_det_rec.id;
5782                l_kln_rec_in.object_version_number :=
5783                                              l_k_det_rec.object_version_number;
5784                oks_contract_line_pub.update_line
5785                                           (p_api_version                      => l_api_version,
5786                                            p_init_msg_list                    => l_init_msg_list,
5787                                            x_return_status                    => x_return_status,
5788                                            x_msg_count                        => x_msg_count,
5789                                            x_msg_data                         => x_msg_data,
5790                                            p_klnv_rec                         => l_kln_rec_in,
5791                                            x_klnv_rec                         => l_kln_rec_out,
5792                                            p_validate_yn                      => 'N'
5793                                           );
5794 
5795                if x_return_status <> g_ret_sts_success
5796                then
5797                   if (fnd_log.level_statement >=
5798                                                fnd_log.g_current_runtime_level
5799                      )
5800                   then
5801                      fnd_log.string
5802                               (fnd_log.level_statement,
5803                                g_module ||
5804                                l_api_name,
5805                                '368:update line details at calc subscription'
5806                               );
5807                   end if;
5808 
5809                   --errorout('update line details at calc subscription');
5810                   raise g_skip_exception;
5811                end if;
5812 
5813                l_clev_rec_in.id           := l_input_detail_rec.subline_id;
5814                l_clev_rec_in.line_list_price :=
5815                                           x_price_details.serv_list_unit_price;
5816                l_clev_rec_in.price_negotiated :=
5817                                                x_price_details.serv_ext_amount;
5818                l_clev_rec_in.price_unit   :=
5819                   nvl (x_price_details.serv_adj_unit_price,
5820                        x_price_details.serv_list_unit_price);
5821                --bug 3360423 list_unit_price will be stored in the database instead of adj_unit_price
5822                get_k_details (p_id                               => l_input_detail_rec.subline_id,
5823                               p_type                             => g_okc_line,
5824                               x_k_det_rec                        => l_k_det_rec
5825                              );
5826                l_clev_rec_in.object_version_number :=
5827                                              l_k_det_rec.object_version_number;
5828                okc_contract_pub.update_contract_line
5829                                           (p_api_version                      => l_api_version,
5830                                            p_init_msg_list                    => l_init_msg_list,
5831                                            x_return_status                    => x_return_status,
5832                                            x_msg_count                        => x_msg_count,
5833                                            x_msg_data                         => x_msg_data,
5834                                            p_clev_rec                         => l_clev_rec_in,
5835                                            x_clev_rec                         => l_clev_rec_out
5836                                           );
5837 
5838                if x_return_status <> g_ret_sts_success
5839                then
5840                   if (fnd_log.level_statement >=
5841                                                fnd_log.g_current_runtime_level
5842                      )
5843                   then
5844                      fnd_log.string
5845                         (fnd_log.level_statement,
5846                          g_module ||
5847                          l_api_name,
5848                          '369:contract line updation error in subline price - topline price'
5849                         );
5850                   end if;
5851 
5852                   -- errorout ('contract line updation error in subline price - topline price');
5853                   raise g_skip_exception;
5854                end if;
5855 
5856                -- clear the record so as to reuse it
5857                l_clev_rec_in.id           := okc_api.g_miss_num;
5858                --l_clev_rec_in.chr_id           := okc_api.g_miss_num;
5859                --l_clev_rec_in.cle_id           := okc_api.g_miss_num;
5860                l_clev_rec_in.price_negotiated := okc_api.g_miss_num;
5861                l_clev_rec_in.price_unit   := okc_api.g_miss_num;
5862                -- get covered line details
5863                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
5864                                  x_name                             => l_clvl_name,
5865                                  x_description                      => l_clvl_desc,
5866                                  x_return_status                    => x_return_status,
5867                                  x_msg_count                        => x_msg_count,
5868                                  x_msg_data                         => x_msg_data
5869                                 );
5870                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
5871                g_pricing_status_tbl (g_index).coverage_level_name :=
5872                                                                    l_clvl_name;
5873                g_pricing_status_tbl (g_index).status_code :=
5874                                                             g_sts_code_success;
5875                l_line_no                  :=
5876                                    get_line_no (l_input_detail_rec.subline_id);
5877 
5878                if l_line_no is null
5879                then
5880                   g_pricing_status_tbl (g_index).status_text :=
5881                          nvl (x_price_details.status_text, g_sts_txt_success);
5882                else
5883                    -- bug 4730011
5884                   fnd_message.set_name ('oks', 'oks_line_reprice_success');
5885                   fnd_message.set_token ('lineno', l_line_no);
5886                   g_pricing_status_tbl (g_index).status_text := fnd_message.get;
5887                      -- l_line_no ||' ' ||nvl (x_price_details.status_text, g_sts_txt_success);
5888                end if;
5889 
5890                g_index                    := g_index +
5891                                              1;
5892 
5893 
5894 
5895 
5896             end if; -- skip iteration if its a subscription item
5897 
5898                 -- end debug log
5899             if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
5900             then
5901                fnd_log.string (fnd_log.level_procedure,
5902                                g_module ||
5903                                l_api_name,
5904                                '1000: leaving ' ||
5905                                g_pkg_name ||
5906                                '.' ||
5907                                l_api_name
5908                               );
5909             end if;
5910 
5911 
5912           EXCEPTION
5913             when g_exc_cant_price
5914             then
5915                -- end debug log
5916                if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
5917                   )
5918                then
5919                   fnd_log.string (fnd_log.level_procedure,
5920                                   g_module ||
5921                                   l_api_name,
5922                                   '7000: leaving ' ||
5923                                   g_pkg_name ||
5924                                   '.' ||
5925                                   l_api_name
5926                                  );
5927                end if;
5928 
5929                -- get covered line details
5930                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
5931                                  x_name                             => l_clvl_name,
5932                                  x_description                      => l_clvl_desc,
5933                                  x_return_status                    => x_return_status,
5934                                  x_msg_count                        => x_msg_count,
5935                                  x_msg_data                         => x_msg_data
5936                                 );
5937                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
5938                g_pricing_status_tbl (g_index).coverage_level_name :=
5939                                                                    l_clvl_name;
5940                g_pricing_status_tbl (g_index).status_code :=
5941                                                             g_sts_code_success;
5942 
5943                if x_price_details.status_code = g_partial_billed
5944                                  or
5945                   x_price_details.status_code = g_fully_billed
5946                then
5947                   g_pricing_status_tbl (g_index).status_text := g_billed_line;
5948                else
5949                   g_pricing_status_tbl (g_index).status_text :=
5950                                                             g_sts_txt_success;
5951                end if;
5952 
5953                g_index                    := g_index +
5954                                              1;
5955 
5956                if    l_status = g_fully_billed
5957                   or l_status = g_partial_billed
5958                then
5959                   x_price_details.status_code := g_billed;
5960                end if;
5961             when g_skip_exception
5962             then
5963                -- end debug log
5964                if (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
5965                   )
5966                then
5967                   fnd_log.string (fnd_log.level_procedure,
5968                                   g_module ||
5969                                   l_api_name,
5970                                   '9000: leaving ' ||
5971                                   g_pkg_name ||
5972                                   '.' ||
5973                                   l_api_name
5974                                  );
5975                end if;
5976 
5977                -- get covered line details
5978                get_line_details (p_line_id                          => l_input_detail_rec.subline_id,
5979                                  x_name                             => l_clvl_name,
5980                                  x_description                      => l_clvl_desc,
5981                                  x_return_status                    => x_return_status,
5982                                  x_msg_count                        => x_msg_count,
5983                                  x_msg_data                         => x_msg_data
5984                                 );
5985                g_pricing_status_tbl (g_index).service_name := l_tlvl_name;
5986                g_pricing_status_tbl (g_index).coverage_level_name :=
5987                                                                    l_clvl_name;
5988                g_pricing_status_tbl (g_index).status_code := g_sts_code_error;
5989                l_line_no                  :=
5990                                    get_line_no (l_input_detail_rec.subline_id);
5991 
5992                if l_line_no is null
5993                then
5994                   g_pricing_status_tbl (g_index).status_text :=
5995                            nvl (x_price_details.status_text, g_sts_txt_error);
5996                else
5997                  -- bug 4730011
5998                  fnd_message.set_name ('oks', 'oks_line_reprice_success');
5999                  fnd_message.set_token ('lineno', l_line_no);
6000                  g_pricing_status_tbl (g_index).status_text := fnd_message.get;
6001                   -- l_line_no ||' ' ||nvl (x_price_details.status_text, g_sts_txt_error);
6002                end if;
6003 
6004                g_index                    := g_index +
6005                                              1;
6006          END;
6007 
6008        END LOOP;--l_subline_csr
6009 
6010         l_clev_rec_in.id           := l_input_detail_rec.line_id;
6011        l_clev_rec_in.price_negotiated :=
6012          get_amounts (p_id                               => l_input_detail_rec.line_id,
6013                       p_level                            => g_line_level);
6014       get_k_details (p_id                               => l_input_detail_rec.line_id,
6015                      p_type                             => g_okc_line,
6016                      x_k_det_rec                        => l_k_det_rec
6017                     );
6018       l_clev_rec_in.object_version_number := l_k_det_rec.object_version_number;
6019       okc_contract_pub.update_contract_line
6020                                           (p_api_version                      => l_api_version,
6021                                            p_init_msg_list                    => l_init_msg_list,
6022                                            x_return_status                    => x_return_status,
6023                                            x_msg_count                        => x_msg_count,
6024                                            x_msg_data                         => x_msg_data,
6025                                            p_clev_rec                         => l_clev_rec_in,
6026                                            x_clev_rec                         => l_clev_rec_out
6027                                           );
6028 
6029       IF x_return_status <> g_ret_sts_success
6030       THEN
6031          raise g_exc_error;
6032       END IF;
6033 
6034       -- end debug log
6035       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6036       THEN
6037          fnd_log.string (fnd_log.level_procedure,
6038                          g_module ||
6039                          l_api_name,
6040                          '1000: leaving ' ||
6041                          g_pkg_name ||
6042                          '.' ||
6043                          l_api_name
6044                         );
6045       END IF;
6046    EXCEPTION
6047       WHEN g_exc_error
6048       THEN
6049          -- end debug log
6050          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6051          THEN
6052             fnd_log.string (fnd_log.level_procedure,
6053                             g_module ||
6054                             l_api_name,
6055                             '2000: leaving ' ||
6056                             g_pkg_name ||
6057                             '.' ||
6058                             l_api_name
6059                            );
6060          END IF;
6061 
6062          null;
6063       WHEN OTHERS
6064       THEN
6065          -- end debug log
6066          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6067          THEN
6068             fnd_log.string (fnd_log.level_procedure,
6069                             g_module ||
6070                             l_api_name,
6071                             '4000: leaving ' ||
6072                             g_pkg_name ||
6073                             '.' ||
6074                             l_api_name
6075                            );
6076          END IF;
6077 
6078          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
6079          x_return_status            := g_ret_sts_unexp_error;
6080          okc_api.set_message (p_app_name                         => g_app_name,
6081                               p_msg_name                         => g_unexpected_error,
6082                               p_token1                           => g_sqlcode_token,
6083                               p_token1_value                     => sqlcode,
6084                               p_token2                           => g_sqlerrm_token,
6085                               p_token2_value                     => sqlerrm
6086                              );
6087  END calculate_topline_price_bulk;
6088 
6089 
6090    PROCEDURE calculate_hdr_price (
6091       p_detail_rec                    IN       oks_qp_pkg.input_details,
6092       x_price_details                 OUT NOCOPY oks_qp_pkg.price_details,
6093       x_modifier_details              OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
6094       x_price_break_details           OUT NOCOPY oks_qp_pkg.g_price_break_tbl_type,
6095       x_return_status                 OUT NOCOPY VARCHAR2,
6096       x_msg_count                     OUT NOCOPY NUMBER,
6097       x_msg_data                      OUT NOCOPY VARCHAR2
6098    )
6099    IS
6100       l_api_name                     CONSTANT VARCHAR2 (30)
6101                                                      := 'CALCULATE_HDR_PRICE';
6102 
6103       CURSOR l_topline_csr (
6104          p_chr_id                                 NUMBER
6105       )
6106       IS
6107          SELECT   ID,
6108                   start_date,
6109                   end_date,
6110                   lse_id
6111              FROM okc_k_lines_b
6112             WHERE chr_id = p_chr_id
6113               AND lse_id IN (1, 14, 19, 46)
6114               AND date_cancelled IS NULL                   --[llc] bug 4653406
6115               AND date_terminated IS NULL                  -- bug 5504157
6116          ORDER BY line_number;
6117 
6118       l_input_details                         oks_qp_pkg.input_details;
6119       l_chrv_rec_in                           okc_contract_pub.chrv_rec_type;
6120       l_chrv_rec_out                          okc_contract_pub.chrv_rec_type;
6121       l_k_det_rec                             k_details_rec;
6122    BEGIN
6123       -- start debug log
6124       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6125       THEN
6126          fnd_log.STRING (fnd_log.level_procedure,
6127                          g_module ||
6128                          l_api_name,
6129                          '100: Entered ' ||
6130                          g_pkg_name ||
6131                          '.' ||
6132                          l_api_name
6133                         );
6134       END IF;
6135 
6136       x_return_status            := g_ret_sts_success;
6137 
6138       FOR l_topline_rec IN l_topline_csr (p_detail_rec.chr_id)
6139       LOOP
6140          BEGIN
6141             IF l_topline_rec.lse_id = g_subscription
6142             THEN
6143                l_input_details.chr_id     := p_detail_rec.chr_id;
6144                l_input_details.line_id    := l_topline_rec.ID;
6145                l_input_details.subline_id := NULL;
6146                l_input_details.intent     := g_subsc_reg_pricing;
6147                l_input_details.currency   := p_detail_rec.currency;
6148                l_input_details.usage_qty  := NULL;
6149                l_input_details.usage_uom_code := NULL;
6150                l_input_details.asking_unit_price := NULL;
6151                calculate_subscription_price
6152                              (p_detail_rec                       => l_input_details,
6153                               x_price_details                    => x_price_details,
6154                               x_modifier_details                 => x_modifier_details,
6155                               x_price_break_details              => x_price_break_details,
6156                               x_return_status                    => x_return_status,
6157                               x_msg_count                        => x_msg_count,
6158                               x_msg_data                         => x_msg_data
6159                              );
6160 
6161                IF x_return_status <> g_ret_sts_success
6162                THEN
6163                   IF (fnd_log.level_statement >=
6164                                                fnd_log.g_current_runtime_level
6165                      )
6166                   THEN
6167                      fnd_log.STRING
6168                               (fnd_log.level_statement,
6169                                g_module ||
6170                                l_api_name,
6171                                '370:CALC SUBSCRIPTION ERROR at Calc Hdr call'
6172                               );
6173                   END IF;
6174 
6175                   -- errorout('CALC SUBSCRIPTION ERROR at Calc Hdr call');
6176                   RAISE g_skip_exception;
6177                END IF;
6178             ELSE
6179                l_input_details.chr_id     := p_detail_rec.chr_id;
6180                l_input_details.line_id    := l_topline_rec.ID;
6181                l_input_details.subline_id := NULL;
6182                l_input_details.intent     := g_top_line_pricing;
6183                l_input_details.currency   := p_detail_rec.currency;
6184                l_input_details.usage_qty  := NULL;
6185                l_input_details.usage_uom_code := NULL;
6186                l_input_details.asking_unit_price := NULL;
6187 
6188 
6189     /* skuchima: Check the profile to whether to call the Line Reprice Bulk mode or the Normal mode Bug:7539977  */
6190                IF  nvl(fnd_profile.value ('OKS_USE_BULK_FOR_LINE_REPRICE'), 'NO')='YES'
6191                   THEN
6192 
6193                   calculate_topline_price_bulk
6194                                    (p_detail_rec                       => l_input_details,
6195                                     x_price_details                    => x_price_details,
6196                                     x_modifier_details                 => x_modifier_details,
6197                                     x_price_break_details              => x_price_break_details,
6198                                     x_return_status                    => x_return_status,
6199                                     x_msg_count                        => x_msg_count,
6200                                     x_msg_data                         => x_msg_data
6201                                     );
6202 
6203                ELSE
6204                   calculate_topline_price
6205                                     (p_detail_rec                      => l_input_details,
6206                                     x_price_details                    => x_price_details,
6207                                     x_modifier_details                 => x_modifier_details,
6208                                     x_price_break_details              => x_price_break_details,
6209                                     x_return_status                    => x_return_status,
6210                                     x_msg_count                        => x_msg_count,
6211                                     x_msg_data                         => x_msg_data
6212                                     );
6213               END IF;
6214 
6215 
6216 
6217 
6218                IF x_return_status <> g_ret_sts_success
6219                THEN
6220                   IF (fnd_log.level_statement >=
6221                                                fnd_log.g_current_runtime_level
6222                      )
6223                   THEN
6224                      fnd_log.STRING
6225                                    (fnd_log.level_statement,
6226                                     g_module ||
6227                                     l_api_name,
6228                                     '371:CALC TOPLINE ERROR at Calc Hdr call'
6229                                    );
6230                   END IF;
6231 
6232                   -- errorout('CALC TOPLINE ERROR at Calc Hdr call');
6233                   RAISE g_skip_exception;
6234                END IF;
6235             END IF;
6236 
6237             -- end debug log
6238             IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6239             THEN
6240                fnd_log.STRING (fnd_log.level_procedure,
6241                                g_module ||
6242                                l_api_name,
6243                                '1000: Leaving ' ||
6244                                g_pkg_name ||
6245                                '.' ||
6246                                l_api_name
6247                               );
6248             END IF;
6249          EXCEPTION
6250             WHEN g_skip_exception
6251             THEN
6252                -- end debug log
6253                IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level
6254                   )
6255                THEN
6256                   fnd_log.STRING (fnd_log.level_procedure,
6257                                   g_module ||
6258                                   l_api_name,
6259                                   '9000: Leaving ' ||
6260                                   g_pkg_name ||
6261                                   '.' ||
6262                                   l_api_name
6263                                  );
6264                END IF;
6265 
6266                NULL;
6267          END;
6268       END LOOP;
6269 
6270       l_chrv_rec_in.ID           := p_detail_rec.chr_id;
6271       l_chrv_rec_in.estimated_amount :=
6272              get_amounts (p_id                               => p_detail_rec.chr_id,
6273                           p_level                            => g_hdr_level);
6274       get_k_details (p_id                               => p_detail_rec.chr_id,
6275                      p_type                             => g_okc_hdr,
6276                      x_k_det_rec                        => l_k_det_rec
6277                     );
6278       l_chrv_rec_in.object_version_number := l_k_det_rec.object_version_number;
6279       okc_contract_pub.update_contract_header
6280                                       (p_api_version                      => l_api_version,
6281                                        p_init_msg_list                    => l_init_msg_list,
6282                                        x_return_status                    => x_return_status,
6283                                        x_msg_count                        => x_msg_count,
6284                                        x_msg_data                         => x_msg_data,
6285                                        p_restricted_update                => okc_api.g_false,
6286                                        p_chrv_rec                         => l_chrv_rec_in,
6287                                        x_chrv_rec                         => l_chrv_rec_out
6288                                       );
6289 
6290       IF x_return_status <> g_ret_sts_success
6291       THEN
6292          RAISE g_exc_error;
6293       END IF;
6294 
6295       -- end debug log
6296       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6297       THEN
6298          fnd_log.STRING (fnd_log.level_procedure,
6299                          g_module ||
6300                          l_api_name,
6301                          '1000: Leaving ' ||
6302                          g_pkg_name ||
6303                          '.' ||
6304                          l_api_name
6305                         );
6306       END IF;
6307    EXCEPTION
6308       WHEN g_exc_error
6309       THEN
6310          -- end debug log
6311          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6312          THEN
6313             fnd_log.STRING (fnd_log.level_procedure,
6314                             g_module ||
6315                             l_api_name,
6316                             '2000: Leaving ' ||
6317                             g_pkg_name ||
6318                             '.' ||
6319                             l_api_name
6320                            );
6321          END IF;
6322 
6323          NULL;
6324       WHEN OTHERS
6325       THEN
6326          -- end debug log
6327          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6328          THEN
6329             fnd_log.STRING (fnd_log.level_procedure,
6330                             g_module ||
6331                             l_api_name,
6332                             '4000: Leaving ' ||
6333                             g_pkg_name ||
6334                             '.' ||
6335                             l_api_name
6336                            );
6337          END IF;
6338 
6339          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
6340          x_return_status            := g_ret_sts_unexp_error;
6341          okc_api.set_message (p_app_name                         => g_app_name,
6342                               p_msg_name                         => g_unexpected_error,
6343                               p_token1                           => g_sqlcode_token,
6344                               p_token1_value                     => SQLCODE,
6345                               p_token2                           => g_sqlerrm_token,
6346                               p_token2_value                     => SQLERRM
6347                              );
6348    END calculate_hdr_price;
6349 
6350    PROCEDURE compute_price (
6351       p_api_version                   IN       NUMBER,
6352       p_init_msg_list                 IN       VARCHAR2,
6353       p_detail_rec                    IN       oks_qp_pkg.input_details,
6354       x_price_details                 OUT NOCOPY oks_qp_pkg.price_details,
6355       x_modifier_details              OUT NOCOPY qp_preq_grp.line_detail_tbl_type,
6356       x_price_break_details           OUT NOCOPY oks_qp_pkg.g_price_break_tbl_type,
6357       x_return_status                 OUT NOCOPY VARCHAR2,
6358       x_msg_count                     OUT NOCOPY NUMBER,
6359       x_msg_data                      OUT NOCOPY VARCHAR2
6360    )
6361    IS
6362       l_api_name                     CONSTANT VARCHAR2 (30)
6363                                                            := 'compute_price';
6364       l_input_detail_rec                      oks_qp_pkg.input_details
6365                                                               := p_detail_rec;
6366       l_k_det_rec                             k_details_rec;
6367       l_chrv_rec_in                           okc_contract_pub.chrv_rec_type;
6368       l_chrv_rec_out                          okc_contract_pub.chrv_rec_type;
6369       l_clev_rec_in                           okc_contract_pub.clev_rec_type;
6370       l_clev_rec_out                          okc_contract_pub.clev_rec_type;
6371    BEGIN
6372       -- start debug log
6373       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
6374       THEN
6375          fnd_log.STRING (fnd_log.level_procedure,
6376                          g_module ||
6377                          l_api_name,
6378                          '100: Entered ' ||
6379                          g_pkg_name ||
6380                          '.' ||
6381                          l_api_name
6382                         );
6383          fnd_log.STRING
6384                      (fnd_log.level_procedure,
6385                       g_module ||
6386                       l_api_name,
6387                       '100: ***************** Parameters : ******************'
6388                      );
6389          fnd_log.STRING (fnd_log.level_procedure,
6390                          g_module ||
6391                          l_api_name,
6392                          '100:CHR_ID            = ' ||
6393                          p_detail_rec.chr_id
6394                         );
6395          fnd_log.STRING (fnd_log.level_procedure,
6396                          g_module ||
6397                          l_api_name,
6398                          '100:LINE_ID           = ' ||
6399                          p_detail_rec.line_id
6400                         );
6401          fnd_log.STRING (fnd_log.level_procedure,
6402                          g_module ||
6403                          l_api_name,
6404                          '100:SUBLINE_ID        = ' ||
6405                          p_detail_rec.subline_id
6406                         );
6407          fnd_log.STRING (fnd_log.level_procedure,
6408                          g_module ||
6409                          l_api_name,
6410                          '100:INTENT            = ' ||
6411                          p_detail_rec.intent
6412                         );
6413          fnd_log.STRING (fnd_log.level_procedure,
6414                          g_module ||
6415                          l_api_name,
6416                          '100:CURRENCY          = ' ||
6417                          p_detail_rec.currency
6418                         );
6419          fnd_log.STRING (fnd_log.level_procedure,
6420                          g_module ||
6421                          l_api_name,
6422                          '100:Usage Qty         = ' ||
6423                          p_detail_rec.usage_qty
6424                         );
6425          fnd_log.STRING (fnd_log.level_procedure,
6426                          g_module ||
6427                          l_api_name,
6428                          '100:Usage UOM Code    = ' ||
6429                          p_detail_rec.usage_uom_code
6430                         );
6431          fnd_log.STRING (fnd_log.level_procedure,
6432                          g_module ||
6433                          l_api_name,
6434                          '100:Asking Unit Price  = ' ||
6435                          p_detail_rec.asking_unit_price
6436                         );
6437       END IF;
6438 
6439       --errorout ('********** Entered Compute Price ********');
6440       --errorout ('CHR_ID            = ' || p_detail_rec.chr_id);
6441       --errorout ('LINE_ID           = ' || p_detail_rec.line_id);
6442       --errorout ('SUBLINE_ID        = ' || p_detail_rec.subline_id);
6443       --errorout ('INTENT            = ' || p_detail_rec.intent);
6444       --errorout ('CURRENCY          = ' || p_detail_rec.currency);
6445       --errorout ('Usage Qty         = ' || p_detail_rec.usage_qty);
6446       --errorout ('Usage UOM Code    = ' || p_detail_rec.usage_uom_code);
6447       --errorout ('AskingUnit Price  = ' || p_detail_rec.asking_unit_price);
6448 
6449       -- Make a save point, in case of error rollback
6450       DBMS_TRANSACTION.SAVEPOINT ('COMPUTE_PRICE');
6451 
6452       IF fnd_api.to_boolean (p_init_msg_list)
6453       THEN
6454          fnd_msg_pub.initialize;
6455       END IF;
6456 
6457       x_return_status            := g_ret_sts_success;
6458       -- Always initialize the Pricing message table
6459       g_pricing_status_tbl.DELETE;
6460       g_index                    := 0;
6461       fnd_message.set_name ('OKS', 'OKS_SUCCESS');
6462       g_sts_txt_success          := fnd_message.get;
6463       fnd_message.set_name ('OKS', 'OKS_ERROR');
6464       g_sts_txt_error            := fnd_message.get;
6465       fnd_message.set_name ('OKS', 'OKS_PRICE_STATUS_MAN_ADJ');
6466       g_manual_adj_price         := fnd_message.get;
6467       fnd_message.set_name ('OKS', 'OKS_BILLED_LINE');
6468       g_billed_line              := fnd_message.get;
6469 
6470       IF p_detail_rec.intent = g_header_pricing
6471       THEN
6472          IF p_detail_rec.chr_id IS NOT NULL
6473          THEN
6474             calculate_hdr_price
6475                              (p_detail_rec                       => p_detail_rec,
6476                               x_price_details                    => x_price_details,
6477                               x_modifier_details                 => x_modifier_details,
6478                               x_price_break_details              => x_price_break_details,
6479                               x_return_status                    => x_return_status,
6480                               x_msg_count                        => x_msg_count,
6481                               x_msg_data                         => x_msg_data
6482                              );
6483 
6484             IF x_return_status <> g_ret_sts_success
6485             THEN
6486                RAISE g_exc_error;
6487             END IF;
6488          ELSE
6489             okc_api.set_message (p_app_name                         => g_app_name,
6490                                  p_msg_name                         => g_required_value,
6491                                  p_token1                           => g_invalid_value,
6492                                  p_token1_value                     => 'CHR_ID'
6493                                 );
6494 
6495             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6496             THEN
6497                fnd_log.STRING (fnd_log.level_statement,
6498                                g_module ||
6499                                l_api_name,
6500                                '372:Contract header id is NULL'
6501                               );
6502             END IF;
6503 
6504             -- errorout ('Contract header id is NULL');
6505             x_return_status            := g_ret_sts_error;
6506             RAISE g_exc_error;
6507          END IF;
6508       ELSIF p_detail_rec.intent = g_top_line_pricing
6509       THEN
6510          IF p_detail_rec.line_id IS NOT NULL
6511          THEN
6512             IF p_detail_rec.chr_id IS NULL
6513             THEN
6514                get_id (p_line_id                          => p_detail_rec.line_id,
6515                        x_chr_id                           => l_input_detail_rec.chr_id,
6516                        x_topline_id                       => l_input_detail_rec.subline_id,
6517                        x_return_status                    => x_return_status
6518                       );
6519 
6520                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
6521                   )
6522                THEN
6523                   fnd_log.STRING (fnd_log.level_statement,
6524                                   g_module ||
6525                                   l_api_name,
6526                                   '373:Get_id chr_id in CompP = ' ||
6527                                   l_input_detail_rec.chr_id
6528                                  );
6529                   fnd_log.STRING (fnd_log.level_statement,
6530                                   g_module ||
6531                                   l_api_name,
6532                                   '374:Get_id topline_id in CompP = ' ||
6533                                   l_input_detail_rec.line_id
6534                                  );
6535                END IF;
6536 
6537                --errorout ('Get_id chr_id in CompP = ' || l_input_detail_rec.chr_id);
6538                --errorout ('Get_id topline_id in CompP = ' || l_input_detail_rec.line_id);
6539                IF x_return_status <> g_ret_sts_success
6540                THEN
6541                   IF (fnd_log.level_statement >=
6542                                                fnd_log.g_current_runtime_level
6543                      )
6544                   THEN
6545                      fnd_log.STRING (fnd_log.level_statement,
6546                                      g_module ||
6547                                      l_api_name,
6548                                      '375:Get_id return status = ' ||
6549                                      x_return_status
6550                                     );
6551                   END IF;
6552 
6553                   --errorout ('Get_id return status = ' || x_return_status);
6554                   RAISE g_exc_error;
6555                END IF;
6556             END IF;
6557 
6558              /* skuchima: Check the profile to whether to call the Line Reprice Bulk mode or the Normal mode  Bug:7539977*/
6559 
6560            IF  nvl(fnd_profile.value ('OKS_USE_BULK_FOR_LINE_REPRICE'), 'NO')='YES'
6561             THEN
6562 
6563              calculate_topline_price_bulk
6564                               (p_detail_rec                       => l_input_detail_rec,
6565                                x_price_details                    => x_price_details,
6566                                x_modifier_details                 => x_modifier_details,
6567                                x_price_break_details              => x_price_break_details,
6568                                x_return_status                    => x_return_status,
6569                                x_msg_count                        => x_msg_count,
6570                                x_msg_data                         => x_msg_data
6571                               );
6572 
6573            ELSE
6574             calculate_topline_price
6575                               (p_detail_rec                       => l_input_detail_rec,
6576                                x_price_details                    => x_price_details,
6577                                x_modifier_details                 => x_modifier_details,
6578                                x_price_break_details              => x_price_break_details,
6579                                x_return_status                    => x_return_status,
6580                                x_msg_count                        => x_msg_count,
6581                                x_msg_data                         => x_msg_data
6582                               );
6583            END IF;
6584 
6585 
6586             IF x_return_status <> g_ret_sts_success
6587             THEN
6588                RAISE g_exc_error;
6589             END IF;
6590 
6591             l_chrv_rec_in.ID           := l_input_detail_rec.chr_id;
6592             l_chrv_rec_in.estimated_amount :=
6593                get_amounts (p_id                               => l_input_detail_rec.chr_id,
6594                             p_level                            => g_hdr_level);
6595             get_k_details (p_id                               => l_input_detail_rec.chr_id,
6596                            p_type                             => g_okc_hdr,
6597                            x_k_det_rec                        => l_k_det_rec
6598                           );
6599             l_chrv_rec_in.object_version_number :=
6600                                              l_k_det_rec.object_version_number;
6601             okc_contract_pub.update_contract_header
6602                                       (p_api_version                      => l_api_version,
6603                                        p_init_msg_list                    => l_init_msg_list,
6604                                        x_return_status                    => x_return_status,
6605                                        x_msg_count                        => x_msg_count,
6606                                        x_msg_data                         => x_msg_data,
6607                                        p_restricted_update                => okc_api.g_false,
6608                                        p_chrv_rec                         => l_chrv_rec_in,
6609                                        x_chrv_rec                         => l_chrv_rec_out
6610                                       );
6611 
6612             IF x_return_status <> g_ret_sts_success
6613             THEN
6614                RAISE g_exc_error;
6615             END IF;
6616          ELSE
6617             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6618             THEN
6619                fnd_log.STRING (fnd_log.level_statement,
6620                                g_module ||
6621                                l_api_name,
6622                                '376:Top Line id is NULL'
6623                               );
6624             END IF;
6625 
6626             --errorout ('Top Line id is NULL');
6627             okc_api.set_message (p_app_name                         => g_app_name,
6628                                  p_msg_name                         => g_required_value,
6629                                  p_token1                           => g_invalid_value,
6630                                  p_token1_value                     => 'CLE_ID'
6631                                 );
6632             x_return_status            := g_ret_sts_error;
6633             RAISE g_exc_error;
6634          END IF;
6635       ELSIF p_detail_rec.intent = g_sub_line_pricing
6636       THEN
6637          IF p_detail_rec.subline_id IS NOT NULL
6638          THEN
6639             IF (   p_detail_rec.line_id IS NULL
6640                 OR p_detail_rec.chr_id IS NULL
6641                )
6642             THEN
6643                get_id (p_line_id                          => p_detail_rec.subline_id,
6644                        x_chr_id                           => l_input_detail_rec.chr_id,
6645                        x_topline_id                       => l_input_detail_rec.line_id,
6646                        x_return_status                    => x_return_status
6647                       );
6648 
6649                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
6650                   )
6651                THEN
6652                   fnd_log.STRING (fnd_log.level_statement,
6653                                   g_module ||
6654                                   l_api_name,
6655                                   '377:Get_id topline_id = ' ||
6656                                   l_input_detail_rec.line_id
6657                                  );
6658                END IF;
6659 
6660                --errorout ('Get_id topline_id = ' || l_input_detail_rec.line_id);
6661                IF x_return_status <> g_ret_sts_success
6662                THEN
6663                   IF (fnd_log.level_statement >=
6664                                                fnd_log.g_current_runtime_level
6665                      )
6666                   THEN
6667                      fnd_log.STRING (fnd_log.level_statement,
6668                                      g_module ||
6669                                      l_api_name,
6670                                      '378:Get_id return status = ' ||
6671                                      x_return_status
6672                                     );
6673                   END IF;
6674 
6675                   --errorout ('Get_id return status = ' || x_return_status);
6676                   RAISE g_exc_error;
6677                END IF;
6678             END IF;
6679 
6680             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6681             THEN
6682                fnd_log.STRING (fnd_log.level_statement,
6683                                g_module ||
6684                                l_api_name,
6685                                '379:here is Sub line'
6686                               );
6687             END IF;
6688 
6689             --errorout ('here is Sub line');
6690             calculate_subline_price
6691                               (p_detail_rec                       => l_input_detail_rec,
6692                                x_price_details                    => x_price_details,
6693                                x_modifier_details                 => x_modifier_details,
6694                                x_price_break_details              => x_price_break_details,
6695                                x_return_status                    => x_return_status,
6696                                x_msg_count                        => x_msg_count,
6697                                x_msg_data                         => x_msg_data
6698                               );
6699 
6700             IF x_return_status <> g_ret_sts_success
6701             THEN
6702                RAISE g_exc_error;
6703             END IF;
6704 
6705             l_clev_rec_in.ID           := l_input_detail_rec.line_id;
6706             l_clev_rec_in.price_negotiated :=
6707                get_amounts (p_id                               => l_input_detail_rec.line_id,
6708                             p_level                            => g_line_level);
6709             get_k_details (p_id                               => l_input_detail_rec.line_id,
6710                            p_type                             => g_okc_line,
6711                            x_k_det_rec                        => l_k_det_rec
6712                           );
6713             l_clev_rec_in.object_version_number :=
6714                                              l_k_det_rec.object_version_number;
6715             okc_contract_pub.update_contract_line
6716                                           (p_api_version                      => l_api_version,
6717                                            p_init_msg_list                    => l_init_msg_list,
6718                                            x_return_status                    => x_return_status,
6719                                            x_msg_count                        => x_msg_count,
6720                                            x_msg_data                         => x_msg_data,
6721                                            p_clev_rec                         => l_clev_rec_in,
6722                                            x_clev_rec                         => l_clev_rec_out
6723                                           );
6724 
6725             IF x_return_status <> g_ret_sts_success
6726             THEN
6727                RAISE g_exc_error;
6728             END IF;
6729 
6730             l_chrv_rec_in.ID           := l_input_detail_rec.chr_id;
6731             l_chrv_rec_in.estimated_amount :=
6732                get_amounts (p_id                               => l_input_detail_rec.chr_id,
6733                             p_level                            => g_hdr_level);
6734             get_k_details (p_id                               => l_input_detail_rec.chr_id,
6735                            p_type                             => g_okc_hdr,
6736                            x_k_det_rec                        => l_k_det_rec
6737                           );
6738             l_chrv_rec_in.object_version_number :=
6739                                              l_k_det_rec.object_version_number;
6740             okc_contract_pub.update_contract_header
6741                                       (p_api_version                      => l_api_version,
6742                                        p_init_msg_list                    => l_init_msg_list,
6743                                        x_return_status                    => x_return_status,
6744                                        x_msg_count                        => x_msg_count,
6745                                        x_msg_data                         => x_msg_data,
6746                                        p_restricted_update                => okc_api.g_false,
6747                                        p_chrv_rec                         => l_chrv_rec_in,
6748                                        x_chrv_rec                         => l_chrv_rec_out
6749                                       );
6750 
6751             IF x_return_status <> g_ret_sts_success
6752             THEN
6753                RAISE g_exc_error;
6754             END IF;
6755          ELSE
6756             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6757             THEN
6758                fnd_log.STRING (fnd_log.level_statement,
6759                                g_module ||
6760                                l_api_name,
6761                                '380:Sub line id is NULL'
6762                               );
6763             END IF;
6764 
6765             --errorout ('Sub line id is NULL');
6766             okc_api.set_message (p_app_name                         => g_app_name,
6767                                  p_msg_name                         => g_required_value,
6768                                  p_token1                           => g_invalid_value,
6769                                  p_token1_value                     => 'LINE_ID'
6770                                 );
6771             x_return_status            := g_ret_sts_error;
6772             RAISE g_exc_error;
6773          END IF;
6774       ELSIF p_detail_rec.intent IN (g_subsc_reg_pricing, g_subsc_ovr_pricing)
6775       THEN
6776          IF p_detail_rec.line_id IS NOT NULL
6777          THEN
6778             IF p_detail_rec.chr_id IS NULL
6779             THEN
6780                get_id (p_line_id                          => p_detail_rec.line_id,
6781                        x_chr_id                           => l_input_detail_rec.chr_id,
6782                        x_topline_id                       => l_input_detail_rec.subline_id,
6783                        x_return_status                    => x_return_status
6784                       );
6785 
6786                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
6787                   )
6788                THEN
6789                   fnd_log.STRING (fnd_log.level_statement,
6790                                   g_module ||
6791                                   l_api_name,
6792                                   '381:Get_id chr_id in CompP = ' ||
6793                                   l_input_detail_rec.chr_id
6794                                  );
6795                   fnd_log.STRING (fnd_log.level_statement,
6796                                   g_module ||
6797                                   l_api_name,
6798                                   '382:Get_id topline_id in CompP = ' ||
6799                                   l_input_detail_rec.line_id
6800                                  );
6801                END IF;
6802 
6803                --errorout ('Get_id chr_id in CompP = ' || l_input_detail_rec.chr_id);
6804                --errorout ('Get_id topline_id in CompP = ' || l_input_detail_rec.line_id);
6805                IF x_return_status <> g_ret_sts_success
6806                THEN
6807                   IF (fnd_log.level_statement >=
6808                                                fnd_log.g_current_runtime_level
6809                      )
6810                   THEN
6811                      fnd_log.STRING (fnd_log.level_statement,
6812                                      g_module ||
6813                                      l_api_name,
6814                                      '383:Get_id return status = ' ||
6815                                      x_return_status
6816                                     );
6817                   END IF;
6818 
6819                   --errorout ('Get_id return status = ' || x_return_status);
6820                   RAISE g_exc_error;
6821                END IF;
6822             END IF;
6823 
6824             calculate_subscription_price
6825                               (p_detail_rec                       => l_input_detail_rec,
6826                                x_price_details                    => x_price_details,
6827                                x_modifier_details                 => x_modifier_details,
6828                                x_price_break_details              => x_price_break_details,
6829                                x_return_status                    => x_return_status,
6830                                x_msg_count                        => x_msg_count,
6831                                x_msg_data                         => x_msg_data
6832                               );
6833 
6834             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6835             THEN
6836                fnd_log.STRING
6837                   (fnd_log.level_statement,
6838                    g_module ||
6839                    l_api_name,
6840                    '384:after CSUBS - In compute price - return status = ' ||
6841                    x_return_status
6842                   );
6843             END IF;
6844 
6845             -- errorout ('after CSUBS - In compute price - return status = ' || x_return_status);
6846             IF x_return_status <> g_ret_sts_success
6847             THEN
6848                RAISE g_exc_error;
6849             END IF;
6850 
6851             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6852             THEN
6853                fnd_log.STRING (fnd_log.level_statement,
6854                                g_module ||
6855                                l_api_name,
6856                                '385:Chr_id = ' ||
6857                                l_input_detail_rec.chr_id
6858                               );
6859             END IF;
6860 
6861             -- errorout ('Chr_id = ' || l_input_detail_rec.chr_id);
6862             l_chrv_rec_in.ID           := l_input_detail_rec.chr_id;
6863             l_chrv_rec_in.estimated_amount :=
6864                get_amounts (p_id                               => l_input_detail_rec.chr_id,
6865                             p_level                            => g_hdr_level);
6866             get_k_details (p_id                               => l_input_detail_rec.chr_id,
6867                            p_type                             => g_okc_hdr,
6868                            x_k_det_rec                        => l_k_det_rec
6869                           );
6870             l_chrv_rec_in.object_version_number :=
6871                                              l_k_det_rec.object_version_number;
6872 
6873             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6874             THEN
6875                fnd_log.STRING (fnd_log.level_statement,
6876                                g_module ||
6877                                l_api_name,
6878                                '386:Amount  = ' ||
6879                                l_chrv_rec_in.estimated_amount
6880                               );
6881             END IF;
6882 
6883             -- errorout ('Amount  = ' || l_chrv_rec_in.estimated_amount);
6884             okc_contract_pub.update_contract_header
6885                                       (p_api_version                      => l_api_version,
6886                                        p_init_msg_list                    => l_init_msg_list,
6887                                        x_return_status                    => x_return_status,
6888                                        x_msg_count                        => x_msg_count,
6889                                        x_msg_data                         => x_msg_data,
6890                                        p_restricted_update                => okc_api.g_false,
6891                                        p_chrv_rec                         => l_chrv_rec_in,
6892                                        x_chrv_rec                         => l_chrv_rec_out
6893                                       );
6894 
6895             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6896             THEN
6897                fnd_log.STRING
6898                   (fnd_log.level_statement,
6899                    g_module ||
6900                    l_api_name,
6901                    '387:after hdr updation - In compute price - return status = ' ||
6902                    x_return_status
6903                   );
6904             END IF;
6905 
6906             -- errorout ('after hdr updation - In compute price - return status = ' || x_return_status);
6907             IF x_return_status <> g_ret_sts_success
6908             THEN
6909                RAISE g_exc_error;
6910             END IF;
6911          ELSE
6912             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6913             THEN
6914                fnd_log.STRING (fnd_log.level_statement,
6915                                g_module ||
6916                                l_api_name,
6917                                '388:Line id is NULL'
6918                               );
6919             END IF;
6920 
6921             -- errorout ('Line id is NULL');
6922             okc_api.set_message (p_app_name                         => g_app_name,
6923                                  p_msg_name                         => g_required_value,
6924                                  p_token1                           => g_invalid_value,
6925                                  p_token1_value                     => 'CLE_ID'
6926                                 );
6927             x_return_status            := g_ret_sts_error;
6928             RAISE g_exc_error;
6929          END IF;
6930       ELSIF p_detail_rec.intent = g_override_pricing
6931       THEN
6932          IF p_detail_rec.subline_id IS NOT NULL
6933          THEN
6934             IF (   p_detail_rec.line_id IS NULL
6935                 OR p_detail_rec.chr_id IS NULL
6936                )
6937             THEN
6938                get_id (p_line_id                          => p_detail_rec.subline_id,
6939                        x_chr_id                           => l_input_detail_rec.chr_id,
6940                        x_topline_id                       => l_input_detail_rec.line_id,
6941                        x_return_status                    => x_return_status
6942                       );
6943 
6944                IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level
6945                   )
6946                THEN
6947                   fnd_log.STRING (fnd_log.level_statement,
6948                                   g_module ||
6949                                   l_api_name,
6950                                   '389:Get_id topline_id = ' ||
6951                                   l_input_detail_rec.line_id
6952                                  );
6953                END IF;
6954 
6955                --errorout ('Get_id topline_id = ' || l_input_detail_rec.line_id);
6956                IF x_return_status <> g_ret_sts_success
6957                THEN
6958                   --errorout ('Get_id return status = ' || x_return_status);
6959                   RAISE g_exc_error;
6960                END IF;
6961             END IF;
6962 
6963             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
6964             THEN
6965                fnd_log.STRING (fnd_log.level_statement,
6966                                g_module ||
6967                                l_api_name,
6968                                '390:here is Sub line'
6969                               );
6970             END IF;
6971 
6972             -- errorout ('here is Sub line');
6973             calculate_subline_price
6974                               (p_detail_rec                       => l_input_detail_rec,
6975                                x_price_details                    => x_price_details,
6976                                x_modifier_details                 => x_modifier_details,
6977                                x_price_break_details              => x_price_break_details,
6978                                x_return_status                    => x_return_status,
6979                                x_msg_count                        => x_msg_count,
6980                                x_msg_data                         => x_msg_data
6981                               );
6982 
6983             IF x_return_status <> g_ret_sts_success
6984             THEN
6985                RAISE g_exc_error;
6986             END IF;
6987 
6988             l_clev_rec_in.ID           := l_input_detail_rec.line_id;
6989             l_clev_rec_in.price_negotiated :=
6990                get_amounts (p_id                               => l_input_detail_rec.line_id,
6991                             p_level                            => g_line_level);
6992             get_k_details (p_id                               => l_input_detail_rec.line_id,
6993                            p_type                             => g_okc_line,
6994                            x_k_det_rec                        => l_k_det_rec
6995                           );
6996             l_clev_rec_in.object_version_number :=
6997                                              l_k_det_rec.object_version_number;
6998             okc_contract_pub.update_contract_line
6999                                           (p_api_version                      => l_api_version,
7000                                            p_init_msg_list                    => l_init_msg_list,
7001                                            x_return_status                    => x_return_status,
7002                                            x_msg_count                        => x_msg_count,
7003                                            x_msg_data                         => x_msg_data,
7004                                            p_clev_rec                         => l_clev_rec_in,
7005                                            x_clev_rec                         => l_clev_rec_out
7006                                           );
7007 
7008             IF x_return_status <> g_ret_sts_success
7009             THEN
7010                RAISE g_exc_error;
7011             END IF;
7012 
7013             l_chrv_rec_in.ID           := l_input_detail_rec.chr_id;
7014             l_chrv_rec_in.estimated_amount :=
7015                get_amounts (p_id                               => l_input_detail_rec.chr_id,
7016                             p_level                            => g_hdr_level);
7017             get_k_details (p_id                               => l_input_detail_rec.chr_id,
7018                            p_type                             => g_okc_hdr,
7019                            x_k_det_rec                        => l_k_det_rec
7020                           );
7021             l_chrv_rec_in.object_version_number :=
7022                                              l_k_det_rec.object_version_number;
7023             okc_contract_pub.update_contract_header
7024                                       (p_api_version                      => l_api_version,
7025                                        p_init_msg_list                    => l_init_msg_list,
7026                                        x_return_status                    => x_return_status,
7027                                        x_msg_count                        => x_msg_count,
7028                                        x_msg_data                         => x_msg_data,
7029                                        p_restricted_update                => okc_api.g_false,
7030                                        p_chrv_rec                         => l_chrv_rec_in,
7031                                        x_chrv_rec                         => l_chrv_rec_out
7032                                       );
7033 
7034             IF x_return_status <> g_ret_sts_success
7035             THEN
7036                RAISE g_exc_error;
7037             END IF;
7038          ELSE
7039             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
7040             THEN
7041                fnd_log.STRING (fnd_log.level_statement,
7042                                g_module ||
7043                                l_api_name,
7044                                '391:Sub line id is NULL'
7045                               );
7046             END IF;
7047 
7048             -- errorout ('Sub line id is NULL');
7049             okc_api.set_message (p_app_name                         => g_app_name,
7050                                  p_msg_name                         => g_required_value,
7051                                  p_token1                           => g_invalid_value,
7052                                  p_token1_value                     => 'LINE_ID'
7053                                 );
7054             x_return_status            := g_ret_sts_error;
7055             RAISE g_exc_error;
7056          END IF;
7057       ELSE
7058          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
7059          THEN
7060             fnd_log.STRING (fnd_log.level_statement,
7061                             g_module ||
7062                             l_api_name,
7063                             '392:********** Invalid Intent ********'
7064                            );
7065          END IF;
7066 
7067          -- errorout ('********** Invalid Intent ********');
7068          okc_api.set_message (p_app_name                         => g_app_name,
7069                               p_msg_name                         => g_required_value,
7070                               p_token1                           => g_invalid_value,
7071                               p_token1_value                     => 'INTENT'
7072                              );
7073          x_return_status            := g_ret_sts_error;
7074          RAISE g_exc_error;
7075       END IF;
7076 
7077       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
7078       THEN
7079          fnd_log.STRING (fnd_log.level_statement,
7080                          g_module ||
7081                          l_api_name,
7082                          '393:********** Exiting Compute Price ********'
7083                         );
7084       END IF;
7085 
7086       -- errorout ('********** Exiting Compute Price ********');
7087 
7088       -- end debug log
7089       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
7090       THEN
7091          fnd_log.STRING (fnd_log.level_procedure,
7092                          g_module ||
7093                          l_api_name,
7094                          '1000: Leaving ' ||
7095                          g_pkg_name ||
7096                          '.' ||
7097                          l_api_name
7098                         );
7099       END IF;
7100    EXCEPTION
7101       WHEN g_exc_error
7102       THEN
7103          -- end debug log
7104          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
7105          THEN
7106             fnd_log.STRING (fnd_log.level_procedure,
7107                             g_module ||
7108                             l_api_name,
7109                             '2000: Leaving ' ||
7110                             g_pkg_name ||
7111                             '.' ||
7112                             l_api_name
7113                            );
7114          END IF;
7115 
7116          DBMS_TRANSACTION.rollback_savepoint ('COMPUTE_PRICE');
7117       WHEN OTHERS
7118       THEN
7119          -- end debug log
7120          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
7121          THEN
7122             fnd_log.STRING (fnd_log.level_procedure,
7123                             g_module ||
7124                             l_api_name,
7125                             '4000: Leaving ' ||
7126                             g_pkg_name ||
7127                             '.' ||
7128                             l_api_name
7129                            );
7130          END IF;
7131 
7132          fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
7133          DBMS_TRANSACTION.rollback_savepoint ('COMPUTE_PRICE');
7134          x_return_status            := g_ret_sts_unexp_error;
7135          okc_api.set_message (p_app_name                         => g_app_name,
7136                               p_msg_name                         => g_unexpected_error,
7137                               p_token1                           => g_sqlcode_token,
7138                               p_token1_value                     => SQLCODE,
7139                               p_token2                           => g_sqlerrm_token,
7140                               p_token2_value                     => SQLERRM
7141                              );
7142    END compute_price;
7143 /* Added by sjanakir */
7144 
7145    PROCEDURE reprice_conc (
7146          errbuf          OUT NOCOPY VARCHAR2,
7147          retcode         OUT NOCOPY NUMBER,
7148          p_intent        IN VARCHAR2,
7149          p_chr_id        IN NUMBER,
7150          p_cle_id        IN NUMBER
7151 
7152    )
7153    IS
7154        l_input_details  OKS_QP_PKG.INPUT_DETAILS;
7155        l_output_details OKS_QP_PKG.PRICE_DETAILS;
7156        l_modif_details  QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
7157        l_pb_details     OKS_QP_PKG.G_PRICE_BREAK_TBL_TYPE;
7158        l_return_status  VARCHAR2(20);
7159        l_msg_count      NUMBER;
7160        l_msg_data       VARCHAR2(2000);
7161        l_post           Boolean;
7162        l_action           Boolean := TRUE;
7163        l_request_id     NUMBER;
7164        l_subline_count  NUMBER;
7165    BEGIN
7166     IF p_cle_id IS NOT NULL
7167     THEN
7168        l_input_details.line_id := p_cle_id;
7169        l_input_details.intent :=  p_intent;
7170     ELSE
7171        l_input_details.chr_id := p_chr_id;
7172        l_input_details.intent := p_intent;
7173     END IF;
7174 
7175     oks_qp_int_pvt.compute_price
7176       (
7177 	p_api_version         => 1.0,
7178 	p_init_msg_list       => 'T',
7179 	p_detail_rec          => l_input_details,
7180 	x_price_details       => l_output_details,
7181 	x_modifier_details    => l_modif_details,
7182 	x_price_break_details => l_pb_details,
7183 	x_return_status       => l_return_status,
7184 	x_msg_count           => l_msg_count,
7185 	x_msg_data            => l_msg_data
7186       );
7187 
7188     IF l_return_status <> OKC_API.G_RET_STS_SUCCESS
7189     THEN
7190        retcode := 2;
7191     ELSE
7192        retcode := 0;
7193     END IF;
7194 
7195     errbuf := l_msg_data;
7196 
7197    END reprice_conc;
7198 END oks_qp_int_pvt;