DBA Data[Home] [Help]

PACKAGE BODY: APPS.PV_OFFER_PUB

Source


1 package body PV_OFFER_PUB as
2 /* $Header: pvxvoffb.pls 115.9 2004/08/09 21:34:50 amaram ship $*/
3 
4 /*************************************************************************************/
5 /*                                                                                   */
6 /*                                                                                   */
7 /*                                                                                   */
8 /*                    Global Variable Declaration                                    */
9 /*                                                                                   */
10 /*                                                                                   */
11 /*                                                                                   */
12 /*************************************************************************************/
13 g_pkg_name           VARCHAR2(30) := 'PV_OFFER_PUB';
14 g_api_name           VARCHAR2(30);
15 
16 PV_DEBUG_HIGH_ON boolean :=
17    FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH);
18 PV_DEBUG_LOW_ON boolean :=
19    FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW);
20 PV_DEBUG_MEDIUM_ON boolean :=
21    FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM);
22 PV_DEBUG_ERROR_ON boolean :=
23    FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_ERROR);
24 
25 
26 /*************************************************************************************/
27 /*                                                                                   */
28 /*                                                                                   */
29 /*                                                                                   */
30 /*                    private procedure declaration                                  */
31 /*                                                                                   */
32 /*                                                                                   */
33 /*                                                                                   */
34 /*************************************************************************************/
35 PROCEDURE Debug(
36    p_msg_string      IN VARCHAR2,
37    p_msg_type        IN VARCHAR2 := 'PV_DEBUG_MESSAGE',
38    p_token_type      IN VARCHAR2 := 'TEXT',
39    p_statement_level IN NUMBER   := FND_LOG.LEVEL_PROCEDURE
40 );
41 
42 PROCEDURE Set_Message(
43     p_msg_name      IN      VARCHAR2,
44     p_token1        IN      VARCHAR2 := NULL,
45     p_token1_value  IN      VARCHAR2 := NULL,
46     p_token2        IN      VARCHAR2 := NULL,
47     p_token2_value  IN      VARCHAR2 := NULL,
48     p_token3        IN      VARCHAR2 := NULL,
49     p_token3_value  IN      VARCHAR2 := NULL,
50     p_statement_level IN NUMBER   := FND_LOG.LEVEL_PROCEDURE
51 );
52 
53 
54 
55 --=============================================================================+
56 --| Public Procedure                                                           |
57 --|    Create_Offer                                                            |
58 --|                                                                            |
59 --| Parameters                                                                 |
60 --|    IN                                                                      |
61 --|    OUT                                                                     |
62 --|                                                                            |
63 --|                                                                            |
64 --| NOTES                                                                      |
65 --|                                                                            |
66 --| HISTORY                                                                    |
67 --|                                                                            |
68 --==============================================================================
69 PROCEDURE create_offer(
70    p_init_msg_list         IN  VARCHAR2,
71    p_api_version           IN  NUMBER,
72    p_commit                IN  VARCHAR2,
73    p_benefit_id            IN  NUMBER,
74    p_operation             IN  VARCHAR2,
75    p_offer_id              IN  NUMBER,
76    p_modifier_list_rec     IN  modifier_list_rec_type,
77    p_budget_tbl            IN  budget_tbl_type,
78    p_discount_tbl          IN  discount_line_tbl_type,
79    p_na_qualifier_tbl      IN  na_qualifier_tbl_type,
80    x_offer_id              OUT NOCOPY NUMBER,
81    x_qp_list_header_id     OUT NOCOPY NUMBER,
82    x_error_location        OUT NOCOPY NUMBER,
83    x_return_status         OUT NOCOPY VARCHAR2,
84    x_msg_count             OUT NOCOPY NUMBER,
85    x_msg_data              OUT NOCOPY VARCHAR2
86 )
87 IS
88    lp_budget_tbl          ozf_offer_pub.budget_tbl_type;
89    lp_discount_tbl        ozf_offer_pub.discount_line_tbl_type;
90    lp_na_qualifier_tbl    ozf_offer_pub.na_qualifier_tbl_type;
91 
92    l_modifier_line_tbl    ozf_offer_pub.modifier_line_tbl_type;
93    l_qualifier_tbl        ozf_offer_pub.qualifiers_tbl_type;
94    l_act_product_tbl      ozf_offer_pub.act_product_tbl_type;
95    l_excl_tbl             ozf_offer_pub.excl_rec_tbl_type;
96    l_offer_tier_tbl       ozf_offer_pub.offer_tier_tbl_type;
97    l_prod_tbl             ozf_offer_pub.prod_rec_tbl_type;
98 
99 
100    l_modifier_list_rec    ozf_offer_pub.modifier_list_rec_type;
101    l_empty_modifier_list_rec ozf_offer_pub.modifier_list_rec_type;
102    l_budget_tbl           ozf_offer_pub.budget_tbl_type;
103    l_discount_tbl         ozf_offer_pub.discount_line_tbl_type;
104    l_na_qualifier_tbl     ozf_offer_pub.na_qualifier_tbl_type;
105 
106    l_profile_value        VARCHAR2(50);
107 
108    -- ----------------------------------------------------------------
109    -- Used for deleting offer-related items.
110    -- ----------------------------------------------------------------
111    l_qp_list_header_id        NUMBER;
112    l_del_modifier_list_rec    ozf_offer_pub.modifier_list_rec_type;
113    l_del_budget_tbl           ozf_offer_pub.budget_tbl_type;
114    l_del_discount_tbl         ozf_offer_pub.discount_line_tbl_type;
115    l_del_na_qualifier_tbl     ozf_offer_pub.na_qualifier_tbl_type;
116    i                          NUMBER;
117 
118    ----------------------------
119    --used for bug# 3738487
120    --------------------------
121   j                         NUMBER;
122   l_budget_id_table			JTF_NUMBER_TABLE;
123   budget_id_found           VARCHAR2(1);
124   k                         NUMBER;
125 
126 BEGIN
127    g_api_name := 'Create_Offer';
128 
129    Debug('p_operation: ' || p_operation);
130 
131    IF (p_operation NOT IN ('UPDATE', 'CREATE')) THEN
132       Debug('Wrong p_operation type: ' || p_operation);
133       Debug('p_operation must be either ''UPDATE'' or ''CREATE''');
134       RAISE FND_API.G_EXC_ERROR;
135    END IF;
136 
137    -- ---------------------------------------------------------------
138    -- Check profile "OZF: Validate market and product eligibility
139    -- between object and budget". Referral offer must have budget
140    -- validation done.
141    -- The profile must have the value "Validate customer and products
142    -- by each budget"
143    -- ---------------------------------------------------------------
144    l_profile_value := FND_PROFILE.VALUE('OZF_CHECK_MKTG_PROD_ELIG');
145 
146    IF (l_profile_value <> 'PRODUCT_STRICT_CUSTOMER_STRICT') THEN
147       Set_Message(
148          p_msg_name      => 'PV_SET_BUDGET_VALIDATION'
149       );
150 
151       RAISE FND_API.G_EXC_ERROR;
152    END IF;
153 
154 
155    -- =============================================================== --
156    -- =============================================================== --
157    --                      UPDATE OPERATION                           --
158    -- =============================================================== --
159    -- =============================================================== --
160    -- ---------------------------------------------------------------
161    -- 'UPDATE' indicates that the offer already exists but some of
162    -- the items related to the offer (e.g. products, territories,
163    -- or budgets) require modification/addition.  The easiest way
164    -- to this is to just delete all the items related to the offer
165    -- and re-create them.
166    -- ---------------------------------------------------------------
167    IF (p_operation = 'UPDATE' AND p_offer_id IS NULL) THEN
168       Debug('Offer ID must be provided when the operation is UPDATE.');
169       RAISE FND_API.G_EXC_ERROR;
170    END IF;
171 
172    -- ---------------------------------------------------------------
173    -- 'UPDATE' indicates that the offer already exists but some of
174    -- the items related to the offer (e.g. products, territories,
175    -- or budgets) require modification/addition.  The easiest way
176    -- to this is to just delete all the items related to the offer
177    -- and re-create them.
178    -- ---------------------------------------------------------------
179    IF (p_operation = 'UPDATE') THEN
180       -- ----------------------------------------------------------
181       -- l_del_modifier_list_rec
182       -- ----------------------------------------------------------
183       FOR x IN (SELECT qp_list_header_id
184                 FROM   ozf_offers
185                 WHERE  offer_id = p_offer_id)
186       LOOP
187          l_qp_list_header_id                        := x.qp_list_header_id;
188          l_del_modifier_list_rec.QP_LIST_HEADER_ID  := x.qp_list_header_id;
189          l_del_modifier_list_rec.offer_operation    := 'DELETE';
190          l_del_modifier_list_rec.user_status_id     := 1600;
191       END LOOP;
192 
193       -- ----------------------------------------------------------
194       -- Deleting Discount/Product Lines
195       -- ----------------------------------------------------------
196       i := 1;
197       FOR x IN (SELECT a.offer_discount_line_id,
198                        a.object_version_number,
199                        b.off_discount_product_id
200                 FROM   ozf_offer_discount_lines  a,
201                        ozf_discount_product_reln b
202                 WHERE  a.offer_discount_line_id = b.offer_discount_line_id AND
203                        a.offer_id               = p_offer_id)
204       LOOP
205          l_del_discount_tbl(i).offer_discount_line_id  := x.offer_discount_line_id;
206          l_del_discount_tbl(i).operation               := 'DELETE';
207          l_del_discount_tbl(i).object_version_number   := x.object_version_number;
208          l_del_discount_tbl(i).off_discount_product_id := x.off_discount_product_id;
209          i := i + 1;
210       END LOOP;
211 
212       -- ----------------------------------------------------------
213       -- Deleting Territory/Marketing Eligibility Qualifiers
214       -- ----------------------------------------------------------
215       i := 1;
216       FOR x IN (SELECT qualifier_id, object_version_number
217                 FROM   ozf_offer_qualifiers
218                 WHERE  offer_id = p_offer_id)
219       LOOP
220          l_del_na_qualifier_tbl(i).Qualifier_id          := x.qualifier_id;
221          l_del_na_qualifier_tbl(i).operation             := 'DELETE';
222          l_del_na_qualifier_tbl(i).object_version_number := x.object_version_number;
223          i := i + 1;
224       END LOOP;
225 
226 
227       -- ----------------------------------------------------------
228       -- Deleting Budget Request
229       -- ----------------------------------------------------------
230 
231 	  -- If benefit failed validation and the user tries to re-activate it, delete
232 	  -- from ozf budget requests only records that are not in APPROVED status. when
233 	  -- recreating the offer, add only records from PV that are not in APPROVED status.
234 	  -- for bug# 3738487
235 
236 
237 	  l_budget_id_table  := JTF_NUMBER_TABLE();
238 
239       i := 1;
240 	  j := 1;
241       FOR x IN (SELECT activity_budget_id, status_code, budget_source_id
242                 FROM   ozf_act_budgets
243                 WHERE  arc_act_budget_used_by = 'OFFR' AND
244                        act_budget_used_by_id  = l_qp_list_header_id)
245       LOOP
246          if(x.status_code ='APPROVED' ) then
247 			l_budget_id_table.extend();
248 			l_budget_id_table(j) := x.budget_source_id;
249 			j := j + 1;
250 		 else
251 			l_del_budget_tbl(i).act_budget_id := x.activity_budget_id;
252 			l_del_budget_tbl(i).operation     := 'DELETE';
253 			i := i + 1;
254 		 end if;
255 
256       END LOOP;
257 
258       -- ----------------------------------------------------------
259       -- Delete Offer-related Items
260       -- ----------------------------------------------------------
261       Debug('Deleting offer-related items..........................');
262 
263       ozf_offer_pub.process_modifiers(
264          p_init_msg_list         => FND_API.g_false,
265          p_api_version           => 1.0,
266          p_commit                => FND_API.g_false,
267          x_return_status         => x_return_status,
268          x_msg_count             => x_msg_count,
269          x_msg_data              => x_msg_data,
270          p_offer_type            => 'NET_ACCRUAL',
271          p_modifier_list_rec     => l_del_modifier_list_rec,
272          p_modifier_line_tbl     => l_modifier_line_tbl,
273          p_qualifier_tbl         => l_qualifier_tbl,
274          p_budget_tbl            => l_del_budget_tbl,
275          p_act_product_tbl       => l_act_product_tbl,
276          p_discount_tbl          => l_del_discount_tbl,
277          p_excl_tbl              => l_excl_tbl,
278          p_offer_tier_tbl        => l_offer_tier_tbl,
279          p_prod_tbl              => l_prod_tbl,
280          p_na_qualifier_tbl      => l_del_na_qualifier_tbl,
281          x_qp_list_header_id     => l_qp_list_header_id,
282          x_error_location        => x_error_location
283       );
284 
285       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
286          RAISE FND_API.G_EXC_ERROR;
287 
288       ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
289          RAISE FND_API.g_exc_unexpected_error;
290       END IF;
291 
292    END IF;
293 
294    -- =============================================================== --
295    -- =============================================================== --
296    --                    END UPDATE OPERATION                         --
297    -- =============================================================== --
298    -- =============================================================== --
299 
300 
301    IF (p_operation = 'CREATE') THEN
302       l_modifier_list_rec.description        := p_modifier_list_rec.description;
303       l_modifier_list_rec.comments           := p_modifier_list_rec.comments;
304       l_modifier_list_rec.offer_code         := p_modifier_list_rec.offer_code;
305       l_modifier_list_rec.currency_code      := p_modifier_list_rec.currency_code;
306       l_modifier_list_rec.budget_amount_tc   := p_modifier_list_rec.budget_amount_tc;
307 
308       l_modifier_list_rec.offer_operation    := 'CREATE';
309       l_modifier_list_rec.modifier_operation := 'CREATE';
310       l_modifier_list_rec.tier_level         := 'LINE';
311       l_modifier_list_rec.status_code        := 'DRAFT';
312       l_modifier_list_rec.user_status_id     := 1600;
313       l_modifier_list_rec.offer_type         := 'NET_ACCRUAL';
314       l_modifier_list_rec.custom_setup_id    := 105;
315       l_modifier_list_rec.start_date_active  := SYSDATE;
316 
317       -- Feng Liu asked this be added 2/20/04
318       l_modifier_list_rec.reusable           := 'N';
319 
320    ELSIF (p_operation = 'UPDATE') THEN
321       Debug('l_qp_list_header_id: ' || l_qp_list_header_id);
322       l_modifier_list_rec.currency_code      := p_modifier_list_rec.currency_code;
323       l_modifier_list_rec.budget_amount_tc   := p_modifier_list_rec.budget_amount_tc;
324 
325       l_modifier_list_rec.offer_operation    := 'UPDATE';
326       l_modifier_list_rec.QP_LIST_HEADER_ID  := l_qp_list_header_id;
327       l_modifier_list_rec.user_status_id     := 1600;
328    END IF;
329 
330    --adding this if loop for bug# 3738487
331    k := 1;
332    IF (p_operation = 'UPDATE') THEN
333 		FOR i IN 1..p_budget_tbl.COUNT LOOP
334 			budget_id_found := 'N';
335 			FOR j IN 1..l_budget_id_table.COUNT LOOP
336 				if(p_budget_tbl(i).budget_id = l_budget_id_table(j)) then
337 					budget_id_found := 'Y';
338 					exit;
339 				end if;
340 
341 			END LOOP;
342 
343 			if (budget_id_found <> 'Y') then
344 
345 				lp_budget_tbl(k).act_budget_id := p_budget_tbl(i).act_budget_id;
346 				lp_budget_tbl(k).budget_id     := p_budget_tbl(i).budget_id;
347 				lp_budget_tbl(k).budget_amount := p_budget_tbl(i).budget_amount;
348 				lp_budget_tbl(k).operation     := p_budget_tbl(i).operation;
349 
350 				Debug('lp_budget_tbl(' || k || ').act_budget_id = ' || lp_budget_tbl(k).act_budget_id);
351 				Debug('lp_budget_tbl(' || k || ').budget_id = ' || lp_budget_tbl(k).budget_id);
352 				Debug('lp_budget_tbl(' || k || ').budget_amount = ' || lp_budget_tbl(k).budget_amount);
353 				Debug('lp_budget_tbl(' || k || ').operation = ' || lp_budget_tbl(k).operation);
354 				k := k +1 ;
355 		    end if;
356 			budget_id_found := 'N';
357 		END LOOP;
358 
359    ELSIF (p_operation = 'CREATE') THEN
360 
361 	   -- ---------------------------------------------------------------
362 	   -- Assign PV type variables to OZF type variables.
363 	   -- ---------------------------------------------------------------
364 	   Debug('Printing out budget request parameters.......................');
365 	   FOR i IN 1..p_budget_tbl.COUNT LOOP
366 		  lp_budget_tbl(i).act_budget_id := p_budget_tbl(i).act_budget_id;
367 		  lp_budget_tbl(i).budget_id     := p_budget_tbl(i).budget_id;
368 		  lp_budget_tbl(i).budget_amount := p_budget_tbl(i).budget_amount;
369 		  lp_budget_tbl(i).operation     := p_budget_tbl(i).operation;
370 
371 		  Debug('lp_budget_tbl(' || i || ').act_budget_id = ' || lp_budget_tbl(i).act_budget_id);
372 		  Debug('lp_budget_tbl(' || i || ').budget_id = ' || lp_budget_tbl(i).budget_id);
373 		  Debug('lp_budget_tbl(' || i || ').budget_amount = ' || lp_budget_tbl(i).budget_amount);
374 		  Debug('lp_budget_tbl(' || i || ').operation = ' || lp_budget_tbl(i).operation);
375 	   END LOOP;
376    END IF;
377 
378    FOR i IN 1..p_discount_tbl.COUNT LOOP
379       lp_discount_tbl(i).offer_discount_line_id  := p_discount_tbl(i).offer_discount_line_id;
380       lp_discount_tbl(i).parent_discount_line_id := p_discount_tbl(i).parent_discount_line_id;
381       lp_discount_tbl(i).discount                := p_discount_tbl(i).discount;
382       lp_discount_tbl(i).discount_type           := p_discount_tbl(i).discount_type;
383       lp_discount_tbl(i).tier_type               := p_discount_tbl(i).tier_type;
384       lp_discount_tbl(i).tier_level              := p_discount_tbl(i).tier_level;
385       lp_discount_tbl(i).object_version_number   := p_discount_tbl(i).object_version_number;
386       lp_discount_tbl(i).product_level           := p_discount_tbl(i).product_level;
387       lp_discount_tbl(i).product_id              := p_discount_tbl(i).product_id;
388       lp_discount_tbl(i).operation               := p_discount_tbl(i).operation;
389    END LOOP;
390 
391    FOR i IN 1..p_na_qualifier_tbl.COUNT LOOP
392       lp_na_qualifier_tbl(i).qualifier_id          := p_na_qualifier_tbl(i).qualifier_id;
393       lp_na_qualifier_tbl(i).qualifier_context     := p_na_qualifier_tbl(i).qualifier_context;
394       lp_na_qualifier_tbl(i).qualifier_attribute   := p_na_qualifier_tbl(i).qualifier_attribute;
395       lp_na_qualifier_tbl(i).qualifier_attr_value  := p_na_qualifier_tbl(i).qualifier_attr_value;
396       lp_na_qualifier_tbl(i).object_version_number := p_na_qualifier_tbl(i).object_version_number;
397       lp_na_qualifier_tbl(i).operation             := p_na_qualifier_tbl(i).operation;
398 
399       -- ---------------------------------------------------------------------------
400       -- Within an offer, if qualifier_grouping_no is the same for all qualifiers,
401       -- it's an AND condition. That is, it has to meet all qualifiers to be
402       -- considered qualifier_grouping_no is different, it's an OR condition.
403       -- ---------------------------------------------------------------------------
404       lp_na_qualifier_tbl(i).qualifier_grouping_no := i;
405    END LOOP;
406 
407 
408    -- ---------------------------------------------------------------
409    -- Create/Re-Create offer in DRAFT status.
410    -- ---------------------------------------------------------------
411    IF (p_operation = 'CREATE') THEN
412       Debug('Create offer in DRAFT status..............................');
413    ELSE
414       Debug('Re-create offer-related items.............................');
415    END IF;
416 
417    ozf_offer_pub.process_modifiers(
418       p_init_msg_list         => FND_API.g_false,
419       p_api_version           => 1.0,
420       p_commit                => FND_API.g_false,
421       x_return_status         => x_return_status,
422       x_msg_count             => x_msg_count,
423       x_msg_data              => x_msg_data,
424       p_offer_type            => 'NET_ACCRUAL',
425       p_modifier_list_rec     => l_modifier_list_rec,
426       p_modifier_line_tbl     => l_modifier_line_tbl,
427       p_qualifier_tbl         => l_qualifier_tbl,
428       p_budget_tbl            => lp_budget_tbl,
429       p_act_product_tbl       => l_act_product_tbl,
430       p_discount_tbl          => lp_discount_tbl,
431       p_excl_tbl              => l_excl_tbl,
432       p_offer_tier_tbl        => l_offer_tier_tbl,
433       p_prod_tbl              => l_prod_tbl,
434       p_na_qualifier_tbl      => lp_na_qualifier_tbl,
435       x_qp_list_header_id     => l_qp_list_header_id,
436       x_error_location        => x_error_location
437    );
438 
439 
440    IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
441       RAISE FND_API.G_EXC_ERROR;
442 
443    ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
444       RAISE FND_API.g_exc_unexpected_error;
445    END IF;
446 
447    x_qp_list_header_id := l_qp_list_header_id;
448 
449    -- ---------------------------------------------------------------
450    -- Retrieve offer_id.
451    -- ---------------------------------------------------------------
452    FOR x IN (SELECT offer_id
453              FROM   ozf_offers
454              WHERE  qp_list_header_id = l_qp_list_header_id)
455    LOOP
456       x_offer_id := x.offer_id;
457 
458       -- ------------------------------------------------------------
459       -- Update the benefit with this offer_id and set the benefit
460       -- status to 'PENDING'
461       -- ------------------------------------------------------------
462       /*IF (p_operation = 'CREATE') THEN
463          UPDATE pv_ge_benefits_b
464          SET    additional_info_1   = x_offer_id,
465                 benefit_status_code = 'PENDING'
466          WHERE  benefit_id          = p_benefit_id;
467 
468       ELSE
469          UPDATE pv_ge_benefits_b
470          SET    benefit_status_code = 'PENDING'
471          WHERE  benefit_id          = p_benefit_id;
472       END IF;
473 	  */
474    END LOOP;
475 
476    --commit;
477 
478    -- ---------------------------------------------------------------
479    -- Update offer to ACTIVE status.
480    -- ---------------------------------------------------------------
481    Debug('Update the offer to ACTIVE status..........................');
482    l_modifier_list_rec                    := l_empty_modifier_list_rec;
483    l_modifier_list_rec.QP_LIST_HEADER_ID  := l_qp_list_header_id;
484    l_modifier_list_rec.offer_operation    := 'UPDATE';
485    l_modifier_list_rec.modifier_operation := 'UPDATE';
486    l_modifier_list_rec.status_code        := 'ACTIVE';
487    l_modifier_list_rec.user_status_id     := 1604;     -- ACTIVE status
488 
489    Debug('l_modifier_list_rec.QP_LIST_HEADER_ID = ' ||
490          l_modifier_list_rec.QP_LIST_HEADER_ID);
491 
492    ozf_offer_pub.process_modifiers(
493       p_init_msg_list         => FND_API.g_false,
494       p_api_version           => 1.0,
495       p_commit                => FND_API.g_false,
496       x_return_status         => x_return_status,
497       x_msg_count             => x_msg_count,
498       x_msg_data              => x_msg_data,
499       p_offer_type            => 'NET_ACCRUAL',
500       p_modifier_list_rec     => l_modifier_list_rec,
501       p_modifier_line_tbl     => l_modifier_line_tbl,
502       p_qualifier_tbl         => l_qualifier_tbl,
503       p_budget_tbl            => l_budget_tbl,
504       p_act_product_tbl       => l_act_product_tbl,
505       p_discount_tbl          => l_discount_tbl,
506       p_excl_tbl              => l_excl_tbl,
507       p_offer_tier_tbl        => l_offer_tier_tbl,
508       p_prod_tbl              => l_prod_tbl,
509       p_na_qualifier_tbl      => l_na_qualifier_tbl,
510       x_qp_list_header_id     => l_qp_list_header_id,
511       x_error_location        => x_error_location
512    );
513 
514    IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
515       RAISE FND_API.G_EXC_ERROR;
516 
517    ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
518       RAISE FND_API.g_exc_unexpected_error;
519    END IF;
520 
521 
522    -------------------- Exception --------------------------
523    EXCEPTION
524       WHEN FND_API.G_EXC_ERROR THEN
525          x_return_status := FND_API.G_RET_STS_ERROR;
526          FND_MSG_PUB.Count_And_Get( p_encoded   =>  FND_API.G_FALSE,
527                                     p_count     =>  x_msg_count,
528                                     p_data      =>  x_msg_data);
529 
530       WHEN FND_API.g_exc_unexpected_error THEN
531          x_return_status := FND_API.g_ret_sts_unexp_error;
532          FND_MSG_PUB.count_and_get(
533                p_encoded => FND_API.g_false,
534                p_count   => x_msg_count,
535                p_data    => x_msg_data
536          );
537 
538       WHEN OTHERS THEN
539         IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
540            FND_MSG_PUB.add_exc_msg(g_pkg_name, g_api_name);
541         END IF;
542 
543         x_return_status := FND_API.G_RET_STS_ERROR;
544         FND_MSG_PUB.count_and_get(
545               p_encoded => FND_API.g_false,
546               p_count   => x_msg_count,
547               p_data    => x_msg_data
548         );
549 
550 END create_offer;
551 
552 
553 
554 --=============================================================================+
555 --|  Private Procedure                                                         |
556 --|                                                                            |
557 --|    Debug                                                                   |
558 --|                                                                            |
559 --|  Parameters                                                                |
560 --|  IN                                                                        |
561 --|  OUT                                                                       |
562 --|                                                                            |
563 --|                                                                            |
564 --| NOTES:                                                                     |
565 --|                                                                            |
566 --| HISTORY                                                                    |
567 --|                                                                            |
568 --==============================================================================
569 PROCEDURE Debug(
570    p_msg_string      IN VARCHAR2,
571    p_msg_type        IN VARCHAR2 := 'PV_DEBUG_MESSAGE',
572    p_token_type      IN VARCHAR2 := 'TEXT',
573    p_statement_level IN NUMBER   := FND_LOG.LEVEL_PROCEDURE
574 )
575 IS
576 BEGIN
577    IF (PV_DEBUG_LOW_ON) THEN
578       FND_MESSAGE.Set_Name('PV', p_msg_type);
579       FND_MESSAGE.Set_Token(p_token_type, p_msg_string);
580       FND_MSG_PUB.Add;
581    END IF;
582 
583    IF (p_statement_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
584       FND_LOG.STRING(p_statement_level,
585          'pv.plsql.' || g_pkg_name || '.' || g_api_name,
586          p_msg_string
587       );
588    END IF;
589 END Debug;
590 -- =================================End of Debug================================
591 
592 
593 --=============================================================================+
594 --|  Public Procedure                                                          |
595 --|                                                                            |
596 --|    Set_Message                                                             |
597 --|                                                                            |
598 --|  Parameters                                                                |
599 --|  IN                                                                        |
600 --|  OUT                                                                       |
601 --|                                                                            |
602 --|                                                                            |
603 --| NOTES:                                                                     |
604 --|                                                                            |
605 --| HISTORY                                                                    |
606 --|                                                                            |
607 --==============================================================================
608 PROCEDURE Set_Message(
609     p_msg_name      IN      VARCHAR2,
610     p_token1        IN      VARCHAR2 := NULL,
611     p_token1_value  IN      VARCHAR2 := NULL,
612     p_token2        IN      VARCHAR2 := NULL,
613     p_token2_value  IN      VARCHAR2 := NULL,
614     p_token3        IN      VARCHAR2 := NULL,
615     p_token3_value  IN      VARCHAR2 := NULL,
616     p_statement_level IN NUMBER   := FND_LOG.LEVEL_PROCEDURE
617 )
618 IS
619 BEGIN
620    FND_MESSAGE.Set_Name('PV', p_msg_name);
621 
622    IF (p_token1 IS NOT NULL) THEN
623       FND_MESSAGE.Set_Token(p_token1, p_token1_value);
624    END IF;
625 
626    IF (p_token2 IS NOT NULL) THEN
627       FND_MESSAGE.Set_Token(p_token2, p_token2_value);
628    END IF;
629 
630    IF (p_token3 IS NOT NULL) THEN
631       FND_MESSAGE.Set_Token(p_token3, p_token3_value);
632    END IF;
633 
634    IF (p_statement_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
635       FND_LOG.MESSAGE(
636          p_statement_level,
637          'pv.plsql.' || g_pkg_name || '.' || g_api_name,
638          FALSE
639       );
640    END IF;
641 
642    FND_MSG_PUB.Add;
643 
644 END Set_Message;
645 -- ==============================End of Set_Message==============================
646 
647 
648 END PV_OFFER_PUB;