[Home] [Help]
PACKAGE BODY: APPS.OZF_DISC_LINE_PVT
Source
1 PACKAGE BODY OZF_Disc_Line_PVT as
2 /* $Header: ozfvodlb.pls 120.4 2006/05/04 15:25:35 julou noship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 -- OZF_Disc_Line_PVT
7 -- Purpose
8 --
9 -- History
10 --
11 -- NOTE
12 --
13 -- Wed Jan 14 2004:1/45 PM RSSHARMA Changed AMS_API_MISSING_FIELD messages to OZF_API_MISSING_FIELD
14 -- Thu Jan 29 2004:3/18 PM RSSHARMA Fixed bug # 3402308.
15 -- checkUOM did not initialize return so return status was initialized to null. This was fine in
16 -- dev and UT instances but in QA instance it errors out and rightly so.
17 -- So every function that is called which accepts x_return_status will initialize it as per standerds
18 -- ALso removed the validation on volume_break_type and Volume_operator as these are manully set every time
19 -- End of Comments
20 -- RSSHARMA Fixed Issue where unable to create Discount Tiers in MASS1R10 instance. The issue here was that
21 -- the SQL%NOTFOUND did not work properly. Worked around the issue by checking the value of tier level instead of SQL%NOTFOUND
22 -- Thu Feb 12 2004:5/23 PM RSSHARMA Fixed bug # 3429734. Dont allow adding duplicate Product to an Offer
23 -- Tue Feb 17 2004:1/58 PM RSSHARMA Fixed bug # 3429749. Error creating Exclusions as the Product relation was duplicate if the Tier Level is Offer.
24 -- Put the product relation check only if the Tier Leve = Product
25 -- Tue Feb 17 2004:5/45 PM RSSHARMA Added Delete Exclusions to delete exclusions for a discount line
26 -- ALso added validation to not delete lines if the Offer is not in draft status
27 -- Thu Feb 26 2004:12/3 PM RSSHARMA Fixed bug # 3468608.Default Excluder_flag to N if not passed in
28 -- Wed Oct 26 2005:5/47 PM RSSHARMA Fixed bug # 4673434. Disable duplicate validation exclusions
29 -- Thu Apr 06 2006:4/41 PM RSSHARMA Fixed bug # 5142859. Added Null Currency validation. DOnt allow amount discount if currency is null
30 -- ===============================================================
31 G_PKG_NAME CONSTANT VARCHAR2(30):= 'OZF_Disc_Line_PVT';
32 G_FILE_NAME CONSTANT VARCHAR2(12) := 'ozfvodlb.pls';
33 -- G_USER_ID NUMBER := FND_GLOBAL.USER_ID;
34 -- G_LOGIN_ID NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
35 --
36 --======================Discount Line Methods ========================================
37 -- Hint: Primary key needs to be returned.
38 -- ==============================================================================
39 -- Start of Comments
40 -- ==============================================================================
41 -- API Name
42 -- Lock_Ozf_Disc_Line
43 -- Type
44 -- Private
45 -- Pre-Req
46 --
47 -- Parameters
48 --
49 -- IN
50 -- p_api_version_number IN NUMBER Required
51 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
52 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
53 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
54 -- p_ozf_offer_line_rec IN ozf_offer_line_rec_type Required
55 --
56 -- OUT
57 -- x_return_status OUT VARCHAR2
58 -- x_msg_count OUT NUMBER
59 -- x_msg_data OUT VARCHAR2
60 -- Version : Current version 1.0
61 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
62 -- and basic operation, developer must manually add parameters and business logic as necessary.
63 --
64 -- History
65 --
66 -- NOTE
67 --
68 -- End of Comments
69 -- ==============================================================================
70 FUNCTION is_delete_valid(p_offer_id IN NUMBER)
71 RETURN VARCHAR2
72 IS
73 CURSOR c_offer_status(p_offer_id NUMBER) IS
74 SELECT status_code FROM ozf_offers where offer_id = p_offer_id;
75 l_offer_status VARCHAR2(30);
76 l_return VARCHAR2(1) := 'N';
77 BEGIN
78 OPEN c_offer_status(p_offer_id);
79 fetch c_offer_status INTO l_offer_status;
80 CLOSE c_offer_status;
81
82 IF l_offer_status = 'DRAFT' THEN
83 l_return := 'Y';
84 END IF;
85
86 return l_return;
87
88 END;
89
90 PROCEDURE Lock_Ozf_Disc_Line(
91 p_api_version_number IN NUMBER,
92 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
93
94 x_return_status OUT NOCOPY VARCHAR2,
95 x_msg_count OUT NOCOPY NUMBER,
96 x_msg_data OUT NOCOPY VARCHAR2,
97
98 p_offer_discount_line_id IN NUMBER,
99 p_object_version IN NUMBER
100 )
101
102 IS
103 L_API_NAME CONSTANT VARCHAR2(30) := 'Lock_Ozf_Disc_Line';
104 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
105 L_FULL_NAME CONSTANT VARCHAR2(60) := g_pkg_name ||'.'|| l_api_name;
106 l_offer_discount_line_id NUMBER;
107
108 BEGIN
109
110 -- Debug Message
111 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
112
113
114 -- Initialize message list if p_init_msg_list is set to TRUE.
115 IF FND_API.to_Boolean( p_init_msg_list )
116 THEN
117 FND_MSG_PUB.initialize;
118 END IF;
119
120
121
122 -- Standard call to check for call compatibility.
123 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
124 p_api_version_number,
125 l_api_name,
126 G_PKG_NAME)
127 THEN
128 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
129 END IF;
130
131
132
133 -- Initialize API return status to SUCCESS
134 x_return_status := FND_API.G_RET_STS_SUCCESS;
135
136
137 ------------------------ lock -------------------------
138 OZF_DISC_LINE_PKG.Lock_Row(l_offer_discount_line_id,p_object_version);
139
140
141 -------------------- finish --------------------------
142 FND_MSG_PUB.count_and_get(
143 p_encoded => FND_API.g_false,
144 p_count => x_msg_count,
145 p_data => x_msg_data);
146 OZF_Utility_PVT.debug_message(l_full_name ||': end');
147 EXCEPTION
148
149 WHEN OZF_Utility_PVT.resource_locked THEN
150 x_return_status := FND_API.g_ret_sts_error;
151 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
152
153 WHEN FND_API.G_EXC_ERROR THEN
154 ROLLBACK TO LOCK_Ozf_Disc_Line_PVT;
155 x_return_status := FND_API.G_RET_STS_ERROR;
156 -- Standard call to get message count and if count=1, get the message
157 FND_MSG_PUB.Count_And_Get (
158 p_encoded => FND_API.G_FALSE,
159 p_count => x_msg_count,
160 p_data => x_msg_data
161 );
162
163 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
164 ROLLBACK TO LOCK_Ozf_Disc_Line_PVT;
165 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
166 -- Standard call to get message count and if count=1, get the message
167 FND_MSG_PUB.Count_And_Get (
168 p_encoded => FND_API.G_FALSE,
169 p_count => x_msg_count,
170 p_data => x_msg_data
171 );
172
173 WHEN OTHERS THEN
174 ROLLBACK TO LOCK_Ozf_Disc_Line_PVT;
175 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
176 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
177 THEN
178 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
179 END IF;
180 -- Standard call to get message count and if count=1, get the message
181 FND_MSG_PUB.Count_And_Get (
182 p_encoded => FND_API.G_FALSE,
183 p_count => x_msg_count,
184 p_data => x_msg_data
185 );
186 End Lock_Ozf_Disc_Line;
187
188
189
190
191 PROCEDURE check_Ozf_Offer_Line_Uk_Items(
192 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
193 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
194 x_return_status OUT NOCOPY VARCHAR2)
195 IS
196 l_valid_flag VARCHAR2(1);
197
198 BEGIN
199 x_return_status := FND_API.g_ret_sts_success;
200 IF p_validation_mode = JTF_PLSQL_API.g_create
201 AND p_ozf_offer_line_rec.offer_discount_line_id IS NOT NULL
202 THEN
203 l_valid_flag := OZF_Utility_PVT.check_uniqueness(
204 'ozf_offer_discount_lines',
205 'offer_discount_line_id = ''' || p_ozf_offer_line_rec.offer_discount_line_id ||''''
206 );
207 END IF;
208
209 IF l_valid_flag = FND_API.g_false THEN
210 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_DISC_LINE_ID_DUP');
211 x_return_status := FND_API.g_ret_sts_error;
212 END IF;
213
214 END check_Ozf_Offer_Line_Uk_Items;
215
216 /**
217 Helper procedure to check Volume Items
218 Checks the following conditions
219 1)If Volume From is entered Volume Type is required
220 2)If Volume Type is entered Volume From is required
221 3)If Volume From and Volume Type are entered and if Volume Type = QUANTITY then UOM is required
222 4)If Tier Level is header then Volume To is required
223 */
224 PROCEDURE check_volume_req_items(
225 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
226 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
227 x_return_status OUT NOCOPY VARCHAR2
228 )
229 IS
230 CURSOR c_tier_level(p_offer_id NUMBER) IS
231 select tier_level FROM ozf_offers where offer_id = p_offer_id;
232
233 l_tier_level ozf_offers.tier_level%type;
234
235 BEGIN
236 open c_tier_level(p_ozf_offer_line_rec.offer_id);
237 fetch c_tier_level into l_tier_level;
238 close c_tier_level;
239 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
240 IF p_ozf_offer_line_rec.volume_from IS NOT NULL OR p_ozf_offer_line_rec.volume_from <> FND_API.G_MISS_NUM THEN
241 IF p_ozf_offer_line_rec.volume_type IS NULL OR p_ozf_offer_line_rec.volume_type = FND_API.G_MISS_CHAR THEN
242 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TYPE' );
243 x_return_status := FND_API.g_ret_sts_error;
244 return;
245 ELSE
246 IF p_ozf_offer_line_rec.volume_type = 'PRICING_ATTRIBUTE10' THEN
247 IF p_ozf_offer_line_rec.uom_code IS NULL OR p_ozf_offer_line_rec.uom_code = FND_API.G_MISS_CHAR THEN
248 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_ACT_PRD_NO_UOM');
249 x_return_status := FND_API.g_ret_sts_error;
250 return;
251 ELSE
252 null;
253 -- p_ozf_offer_line_rec.uom_code := null;
254 END IF;
255 END IF;
256 END IF;
257 ELSE IF p_ozf_offer_line_rec.volume_from IS NULL OR p_ozf_offer_line_rec.volume_from = FND_API.G_MISS_NUM THEN
258 IF p_ozf_offer_line_rec.volume_type IS NOT NULL OR p_ozf_offer_line_rec.volume_type <> FND_API.G_MISS_CHAR THEN
259 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_FROM' );
260 x_return_status := FND_API.g_ret_sts_error;
261 return;
262 ELSE
263 null;
264 -- p_ozf_offer_line_rec.uom_code := null;
265 END IF;
266 END IF;
267 END IF;
268 IF l_tier_level = 'HEADER' THEN
269 IF p_ozf_offer_line_rec.volume_to IS NULL OR p_ozf_offer_line_rec.volume_to = FND_API.G_MISS_NUM THEN
270 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TO' );
271 x_return_status := FND_API.g_ret_sts_error;
272 return;
273 END IF;
274 END IF;
275 ELSE
276 IF p_ozf_offer_line_rec.volume_from <> FND_API.G_MISS_NUM THEN
277 IF p_ozf_offer_line_rec.volume_type = FND_API.G_MISS_CHAR THEN
278 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TYPE' );
279 x_return_status := FND_API.g_ret_sts_error;
280 return;
281 ELSE
282 IF p_ozf_offer_line_rec.volume_type = 'PRICING_ATTRIBUTE10' THEN
283 IF p_ozf_offer_line_rec.uom_code = FND_API.G_MISS_CHAR THEN
284 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_ACT_PRD_NO_UOM');
285 x_return_status := FND_API.g_ret_sts_error;
286 return;
287 ELSE
288 null;
289 -- p_ozf_offer_line_rec.uom_code := null;
290 END IF;
291 END IF;
292 END IF;
293 ELSE IF p_ozf_offer_line_rec.volume_from = FND_API.G_MISS_NUM THEN
294 IF p_ozf_offer_line_rec.volume_type <> FND_API.G_MISS_CHAR THEN
295 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_FROM' );
296 x_return_status := FND_API.g_ret_sts_error;
297 return;
298 ELSE
299 null;
300 -- p_ozf_offer_line_rec.uom_code := null;
301 END IF;
302 END IF;
303 END IF;
304 IF l_tier_level = 'HEADER' THEN
305 IF p_ozf_offer_line_rec.volume_to = FND_API.G_MISS_NUM THEN
306 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TO' );
307 x_return_status := FND_API.g_ret_sts_error;
308 return;
309 END IF;
310 END IF;
311 END IF;
312 END check_volume_req_items;
313
314 PROCEDURE check_Ozf_Offer_Line_Req_Items(
315 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
316 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
317 x_return_status OUT NOCOPY VARCHAR2
318 )
319 IS
320 BEGIN
321 x_return_status := FND_API.g_ret_sts_success;
322
323 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
324
325
326 IF p_ozf_offer_line_rec.offer_discount_line_id = FND_API.G_MISS_NUM OR p_ozf_offer_line_rec.offer_discount_line_id IS NULL THEN
327 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_DISCOUNT_LINE_ID' );
328 x_return_status := FND_API.g_ret_sts_error;
329 return;
330 END IF;
331
332 IF p_ozf_offer_line_rec.offer_id = FND_API.G_MISS_NUM OR p_ozf_offer_line_rec.offer_id IS NULL THEN
333 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_ID' );
334 x_return_status := FND_API.g_ret_sts_error;
335 return;
336 END IF;
337
341 return;
338 IF p_ozf_offer_line_rec.discount = FND_API.G_MISS_NUM OR p_ozf_offer_line_rec.discount IS NULL THEN
339 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT' );
340 x_return_status := FND_API.g_ret_sts_error;
342 END IF;
343
344
345 IF p_ozf_offer_line_rec.discount_type = FND_API.g_miss_char OR p_ozf_offer_line_rec.discount_type IS NULL THEN
346 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT_TYPE' );
347 x_return_status := FND_API.g_ret_sts_error;
348 return;
349 END IF;
350
351
352 IF p_ozf_offer_line_rec.tier_type = FND_API.g_miss_char OR p_ozf_offer_line_rec.tier_type IS NULL THEN
353 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'TIER_TYPE' );
354 x_return_status := FND_API.g_ret_sts_error;
355 return;
356 END IF;
357
358
359 IF p_ozf_offer_line_rec.tier_level = FND_API.g_miss_char OR p_ozf_offer_line_rec.tier_level IS NULL THEN
360 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'TIER_LEVEL' );
361 x_return_status := FND_API.g_ret_sts_error;
362 return;
363 END IF;
364
365
366 ELSE
367
368
369 IF p_ozf_offer_line_rec.offer_discount_line_id = FND_API.G_MISS_NUM THEN
370 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_DISCOUNT_LINE_ID' );
371 x_return_status := FND_API.g_ret_sts_error;
372 return;
373 END IF;
374
375
376 IF p_ozf_offer_line_rec.discount = FND_API.G_MISS_NUM THEN
377 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT' );
378 x_return_status := FND_API.g_ret_sts_error;
379 return;
380 END IF;
381
382
383 IF p_ozf_offer_line_rec.discount_type = FND_API.g_miss_char THEN
384 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT_TYPE' );
385 x_return_status := FND_API.g_ret_sts_error;
386 return;
387 END IF;
388
389
390 IF p_ozf_offer_line_rec.tier_type = FND_API.g_miss_char THEN
391 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'TIER_TYPE' );
392 x_return_status := FND_API.g_ret_sts_error;
393 return;
394 END IF;
395
396
397 IF p_ozf_offer_line_rec.tier_level = FND_API.g_miss_char THEN
398 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'TIER_LEVEL' );
399 x_return_status := FND_API.g_ret_sts_error;
400 return;
401 END IF;
402 END IF;
403
404 check_volume_req_items(
405 p_ozf_offer_line_rec => p_ozf_offer_line_rec
406 ,p_validation_mode => p_validation_mode
407 ,x_return_status => x_return_status
408 );
409 END check_Ozf_Offer_Line_Req_Items;
410
411
412
413 PROCEDURE check_Ozf_Offer_Line_Fk_Items(
414 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
415 x_return_status OUT NOCOPY VARCHAR2
416 )
417 IS
418 BEGIN
419 x_return_status := FND_API.g_ret_sts_success;
420 -- Enter custom code here
421
422 IF p_ozf_offer_line_rec.offer_id IS NOT NULL AND p_ozf_offer_line_rec.offer_id <> FND_API.G_MISS_NUM
423 THEN
424 IF ozf_utility_pvt.check_fk_exists('OZF_OFFERS','OFFER_ID',to_char(p_ozf_offer_line_rec.offer_id)) = FND_API.g_false THEN
425 OZF_Utility_PVT.Error_Message('OZF_OFFER_ID_DUP' ); -- correct message
426 x_return_status := FND_API.g_ret_sts_error;
427 return;
428 END IF;
429 END IF;
430 END check_Ozf_Offer_Line_Fk_Items;
431
432
433
434 PROCEDURE check_Offer_Line_Lookup_Items(
435 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
436 x_return_status OUT NOCOPY VARCHAR2
437 )
438 IS
439 BEGIN
440 x_return_status := FND_API.g_ret_sts_success;
441
442 -- Enter custom code here
443
444 END check_Offer_Line_Lookup_Items;
445
446 /**
447 Does validation between offer attributes and the Discount line attributes
448 */
449 PROCEDURE checkNaInterEntity(
450 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
451 x_return_status OUT NOCOPY VARCHAR2
452 )
453 IS
454 CURSOR c_currency(cp_offerId NUMBER)
455 IS
456 SELECT transaction_currency_code
457 FROM ozf_offers
458 WHERE offer_id = cp_offerId;
459 l_currency ozf_offers.transaction_currency_code%TYPE;
460 BEGIN
461 x_return_status := FND_API.G_RET_STS_SUCCESS;
462 OPEN c_currency(cp_offerId => p_ozf_offer_line_rec.offer_id);
463 FETCH c_currency INTO l_currency;
464 IF c_currency%NOTFOUND THEN
465 l_currency := NULL;
466 END IF;
467 CLOSE C_currency;
468 IF l_currency IS NULL THEN
469 IF p_ozf_offer_line_rec.discount_type<> FND_API.G_MISS_CHAR AND p_ozf_offer_line_rec.discount_type IS NOT NULL
470 THEN
471 IF
472 (p_ozf_offer_line_rec.discount_type <> '%' )
473 THEN
477 END IF;
474 OZF_Utility_PVT.error_message('OZF_OFFR_OPT_CURR_PCNT');
475 x_return_status := FND_API.G_RET_STS_ERROR;
476 return;
478 END IF;
479 END IF;
480 END checkNaInterEntity;
481
482 PROCEDURE Check_Ozf_Offer_Line_Items (
483 P_ozf_offer_line_rec IN ozf_offer_line_rec_type,
484 p_validation_mode IN VARCHAR2,
485 x_return_status OUT NOCOPY VARCHAR2
486 )
487 IS
488 l_return_status VARCHAR2(1);
489 BEGIN
490
491 l_return_status := FND_API.g_ret_sts_success;
492 -- Check Items Uniqueness API calls
493 check_Ozf_offer_line_Uk_Items(
494 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
495 p_validation_mode => p_validation_mode,
496 x_return_status => x_return_status);
497 IF x_return_status <> FND_API.g_ret_sts_success THEN
498 l_return_status := FND_API.g_ret_sts_error;
499 END IF;
500
501 check_ozf_offer_line_req_items(
502 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
503 p_validation_mode => p_validation_mode,
504 x_return_status => x_return_status);
505 IF x_return_status <> FND_API.g_ret_sts_success THEN
506 l_return_status := FND_API.g_ret_sts_error;
507 END IF;
508 -- Check Items Foreign Keys API calls
509
510 check_ozf_offer_line_FK_items(
511 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
512 x_return_status => x_return_status);
513 IF x_return_status <> FND_API.g_ret_sts_success THEN
514 l_return_status := FND_API.g_ret_sts_error;
515 END IF;
516 -- Check Items Lookups
517
518 check_Offer_Line_Lookup_Items(
519 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
520 x_return_status => x_return_status);
521 IF x_return_status <> FND_API.g_ret_sts_success THEN
522 l_return_status := FND_API.g_ret_sts_error;
523 END IF;
524 checkNaInterEntity
525 (
526 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
527 x_return_status => x_return_status
528 );
529 IF x_return_status <> FND_API.g_ret_sts_success THEN
530 l_return_status := FND_API.g_ret_sts_error;
531 END IF;
532 x_return_status := l_return_status;
533
534 END Check_ozf_offer_line_Items;
535
536
537
538
539
540 PROCEDURE Complete_Ozf_Offer_Line_Rec (
541 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
542 x_complete_rec OUT NOCOPY ozf_offer_line_rec_type)
543 IS
544 l_return_status VARCHAR2(1);
545
546 CURSOR c_complete IS
547 SELECT *
548 FROM ozf_offer_discount_lines
549 WHERE offer_discount_line_id = p_ozf_offer_line_rec.offer_discount_line_id;
550 l_ozf_offer_line_rec c_complete%ROWTYPE;
551 BEGIN
552 x_complete_rec := p_ozf_offer_line_rec;
553
554
555 OPEN c_complete;
556 FETCH c_complete INTO l_ozf_offer_line_rec;
557 CLOSE c_complete;
558
559 -- offer_discount_line_id
560 IF p_ozf_offer_line_rec.offer_discount_line_id IS NULL THEN
561 x_complete_rec.offer_discount_line_id := l_ozf_offer_line_rec.offer_discount_line_id;
562 END IF;
563
564 -- parent_discount_line_id
565 IF p_ozf_offer_line_rec.parent_discount_line_id IS NULL THEN
566 x_complete_rec.parent_discount_line_id := l_ozf_offer_line_rec.parent_discount_line_id;
567 END IF;
568
569 -- volume_from
570 IF p_ozf_offer_line_rec.volume_from IS NULL THEN
571 x_complete_rec.volume_from := l_ozf_offer_line_rec.volume_from;
572 END IF;
573
574 -- volume_to
575 IF p_ozf_offer_line_rec.volume_to IS NULL THEN
576 x_complete_rec.volume_to := l_ozf_offer_line_rec.volume_to;
577 END IF;
578
579 -- volume_operator
580 IF p_ozf_offer_line_rec.volume_operator IS NULL THEN
581 x_complete_rec.volume_operator := l_ozf_offer_line_rec.volume_operator;
582 END IF;
583
584 -- volume_type
585 IF p_ozf_offer_line_rec.volume_type IS NULL THEN
586 x_complete_rec.volume_type := l_ozf_offer_line_rec.volume_type;
587 END IF;
588
589 -- volume_break_type
590 IF p_ozf_offer_line_rec.volume_break_type IS NULL THEN
591 x_complete_rec.volume_break_type := l_ozf_offer_line_rec.volume_break_type;
592 END IF;
593
594 -- discount
595 IF p_ozf_offer_line_rec.discount IS NULL THEN
596 x_complete_rec.discount := l_ozf_offer_line_rec.discount;
597 END IF;
598
599 -- discount_type
600 IF p_ozf_offer_line_rec.discount_type IS NULL THEN
601 x_complete_rec.discount_type := l_ozf_offer_line_rec.discount_type;
602 END IF;
603
604 -- tier_type
605 IF p_ozf_offer_line_rec.tier_type IS NULL THEN
606 x_complete_rec.tier_type := l_ozf_offer_line_rec.tier_type;
607 END IF;
608
609 -- tier_level
610 IF p_ozf_offer_line_rec.tier_level IS NULL THEN
614 -- incompatibility_group
611 x_complete_rec.tier_level := l_ozf_offer_line_rec.tier_level;
612 END IF;
613
615 IF p_ozf_offer_line_rec.incompatibility_group IS NULL THEN
616 x_complete_rec.incompatibility_group := l_ozf_offer_line_rec.incompatibility_group;
617 END IF;
618
619 -- precedence
620 IF p_ozf_offer_line_rec.precedence IS NULL THEN
621 x_complete_rec.precedence := l_ozf_offer_line_rec.precedence;
622 END IF;
623
624 -- bucket
625 IF p_ozf_offer_line_rec.bucket IS NULL THEN
626 x_complete_rec.bucket := l_ozf_offer_line_rec.bucket;
627 END IF;
628
629 -- scan_value
630 IF p_ozf_offer_line_rec.scan_value IS NULL THEN
631 x_complete_rec.scan_value := l_ozf_offer_line_rec.scan_value;
632 END IF;
633
634 -- scan_data_quantity
635 IF p_ozf_offer_line_rec.scan_data_quantity IS NULL THEN
636 x_complete_rec.scan_data_quantity := l_ozf_offer_line_rec.scan_data_quantity;
637 END IF;
638
639 -- scan_unit_forecast
640 IF p_ozf_offer_line_rec.scan_unit_forecast IS NULL THEN
641 x_complete_rec.scan_unit_forecast := l_ozf_offer_line_rec.scan_unit_forecast;
642 END IF;
643
644 -- channel_id
645 IF p_ozf_offer_line_rec.channel_id IS NULL THEN
646 x_complete_rec.channel_id := l_ozf_offer_line_rec.channel_id;
647 END IF;
648
649 -- adjustment_flag
650 IF p_ozf_offer_line_rec.adjustment_flag IS NULL THEN
651 x_complete_rec.adjustment_flag := l_ozf_offer_line_rec.adjustment_flag;
652 END IF;
653
654 -- start_date_active
655 IF p_ozf_offer_line_rec.start_date_active IS NULL THEN
656 x_complete_rec.start_date_active := l_ozf_offer_line_rec.start_date_active;
657 END IF;
658
659 -- end_date_active
660 IF p_ozf_offer_line_rec.end_date_active IS NULL THEN
661 x_complete_rec.end_date_active := l_ozf_offer_line_rec.end_date_active;
662 END IF;
663
664 -- uom_code
665 IF p_ozf_offer_line_rec.uom_code IS NULL THEN
666 x_complete_rec.uom_code := l_ozf_offer_line_rec.uom_code;
667 END IF;
668
669 -- creation_date
670 IF p_ozf_offer_line_rec.creation_date IS NULL THEN
671 x_complete_rec.creation_date := l_ozf_offer_line_rec.creation_date;
672 END IF;
673
674 -- created_by
675 IF p_ozf_offer_line_rec.created_by IS NULL THEN
676 x_complete_rec.created_by := l_ozf_offer_line_rec.created_by;
677 END IF;
678
679 -- last_update_date
680 IF p_ozf_offer_line_rec.last_update_date IS NULL THEN
681 x_complete_rec.last_update_date := l_ozf_offer_line_rec.last_update_date;
682 END IF;
683
684 -- last_updated_by
685 IF p_ozf_offer_line_rec.last_updated_by IS NULL THEN
686 x_complete_rec.last_updated_by := l_ozf_offer_line_rec.last_updated_by;
687 END IF;
688
689 -- last_update_login
690 IF p_ozf_offer_line_rec.last_update_login IS NULL THEN
691 x_complete_rec.last_update_login := l_ozf_offer_line_rec.last_update_login;
692 END IF;
693
694 -- object_version_number
695 IF p_ozf_offer_line_rec.object_version_number IS NULL THEN
696 x_complete_rec.object_version_number := l_ozf_offer_line_rec.object_version_number;
697 END IF;
698
699 -- offer_id
700 IF p_ozf_offer_line_rec.offer_id IS NULL THEN
701 x_complete_rec.offer_id := l_ozf_offer_line_rec.offer_id;
702 END IF;
703 -- Note: Developers need to modify the procedure
704 -- to handle any business specific requirements.
705 END Complete_Ozf_Offer_Line_Rec;
706
707
708
709
710 PROCEDURE Default_Ozf_Offer_Line_Items ( p_ozf_offer_line_rec IN ozf_offer_line_rec_type ,
711 x_ozf_offer_line_rec OUT NOCOPY ozf_offer_line_rec_type )
712 IS
713 l_ozf_offer_line_rec ozf_offer_line_rec_type := p_ozf_offer_line_rec;
714 BEGIN
715 -- Developers should put their code to default the record type
716 -- e.g. IF p_campaign_rec.status_code IS NULL
717 -- OR p_campaign_rec.status_code = FND_API.G_MISS_CHAR THEN
718 -- l_campaign_rec.status_code := 'NEW' ;
719 -- END IF ;
720 --
721 NULL ;
722 END;
723
724
725 PROCEDURE Validate_Ozf_Offer_Line_Rec (
726 p_api_version_number IN NUMBER,
727 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
728 x_return_status OUT NOCOPY VARCHAR2,
729 x_msg_count OUT NOCOPY NUMBER,
730 x_msg_data OUT NOCOPY VARCHAR2,
731 p_ozf_offer_line_rec IN ozf_offer_line_rec_type
732 )
733 IS
734 BEGIN
735 -- Initialize message list if p_init_msg_list is set to TRUE.
736 IF FND_API.to_Boolean( p_init_msg_list )
737 THEN
738 FND_MSG_PUB.initialize;
739 END IF;
740
741
742
743 -- Initialize API return status to SUCCESS
744 x_return_status := FND_API.G_RET_STS_SUCCESS;
745
746 -- Hint: Validate data
747 -- If data not valid
748 -- THEN
749 -- x_return_status := FND_API.G_RET_STS_ERROR;
750
751 -- Debug Message
755 (p_count => x_msg_count,
752 OZF_UTILITY_PVT.debug_message('Private API: Validate_dm_model_rec');
753 -- Standard call to get message count and if count is 1, get message info.
754 FND_MSG_PUB.Count_And_Get
756 p_data => x_msg_data
757 );
758 END Validate_ozf_offer_line_Rec;
759
760
761 PROCEDURE Validate_Ozf_Disc_Line(
762 p_api_version_number IN NUMBER,
763 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
764 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
765 p_ozf_offer_line_rec IN ozf_offer_line_rec_type,
766 p_validation_mode IN VARCHAR2,
767 x_return_status OUT NOCOPY VARCHAR2,
768 x_msg_count OUT NOCOPY NUMBER,
769 x_msg_data OUT NOCOPY VARCHAR2
770 )
771 IS
772 L_API_NAME CONSTANT VARCHAR2(30) := 'Validate_Ozf_Disc_Line';
773 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
774 l_object_version_number NUMBER;
775 l_ozf_offer_line_rec ozf_offer_line_rec_type;
776
777 BEGIN
778 -- Standard Start of API savepoint
779 SAVEPOINT validate_ozf_disc_line_;
780
781 -- Standard call to check for call compatibility.
782 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
783 p_api_version_number,
784 l_api_name,
785 G_PKG_NAME)
786 THEN
787 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
788 END IF;
789
790
791 -- Initialize message list if p_init_msg_list is set to TRUE.
792 IF FND_API.to_Boolean( p_init_msg_list )
793 THEN
794 FND_MSG_PUB.initialize;
795 END IF;
796
797 -- Debug Message
798 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
799
800 -- Initialize API return status to SUCCESS
801 x_return_status := FND_API.G_RET_STS_SUCCESS;
802
803 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
804 Check_ozf_offer_line_Items(
805 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
806 p_validation_mode => p_validation_mode,
807 x_return_status => x_return_status
808 );
809
810 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
811 RAISE FND_API.G_EXC_ERROR;
812 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
813 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
814 END IF;
815 END IF;
816 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
817 Default_Ozf_Offer_Line_Items (p_ozf_offer_line_rec => p_ozf_offer_line_rec ,
818 x_ozf_offer_line_rec => l_ozf_offer_line_rec) ;
819 END IF ;
820
821
822 -- IF p_validation_mode = JTF_PLSQL_API.g_update THEN
823 Complete_ozf_offer_line_Rec(
824 p_ozf_offer_line_rec => l_ozf_offer_line_rec,
825 x_complete_rec => l_ozf_offer_line_rec
826 );
827 -- END IF;
828 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
829 Validate_ozf_offer_line_Rec(
830 p_api_version_number => 1.0,
831 p_init_msg_list => FND_API.G_FALSE,
832 x_return_status => x_return_status,
833 x_msg_count => x_msg_count,
834 x_msg_data => x_msg_data,
835 p_ozf_offer_line_rec => l_ozf_offer_line_rec);
836
837 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
838 RAISE FND_API.G_EXC_ERROR;
839 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
840 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
841 END IF;
842 END IF;
843
844
845
846 -- Debug Message
847 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
848
849
850 -- Standard call to get message count and if count is 1, get message info.
851 FND_MSG_PUB.Count_And_Get
852 (p_count => x_msg_count,
853 p_data => x_msg_data
854 );
855 EXCEPTION
856
857 WHEN OZF_Utility_PVT.resource_locked THEN
858 x_return_status := FND_API.g_ret_sts_error;
859 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
860
861 WHEN FND_API.G_EXC_ERROR THEN
862 ROLLBACK TO VALIDATE_Ozf_Disc_Line_;
863 x_return_status := FND_API.G_RET_STS_ERROR;
864 -- Standard call to get message count and if count=1, get the message
865 FND_MSG_PUB.Count_And_Get (
866 p_encoded => FND_API.G_FALSE,
867 p_count => x_msg_count,
868 p_data => x_msg_data
869 );
870
871 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
872 ROLLBACK TO VALIDATE_Ozf_Disc_Line_;
873 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
874 -- Standard call to get message count and if count=1, get the message
875 FND_MSG_PUB.Count_And_Get (
876 p_encoded => FND_API.G_FALSE,
880
877 p_count => x_msg_count,
878 p_data => x_msg_data
879 );
881 WHEN OTHERS THEN
882 ROLLBACK TO VALIDATE_Ozf_Disc_Line_;
883 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
884 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
885 THEN
886 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
887 END IF;
888 -- Standard call to get message count and if count=1, get the message
889 FND_MSG_PUB.Count_And_Get (
890 p_encoded => FND_API.G_FALSE,
891 p_count => x_msg_count,
892 p_data => x_msg_data
893 );
894 End Validate_Ozf_Disc_Line;
895
896
897
898
899
900
901
902
903
904 -- Hint: Primary key needs to be returned.
905 -- ==============================================================================
906 -- Start of Comments
907 -- ==============================================================================
908 -- API Name
909 -- Create_Ozf_Disc_Line
910 -- Type
911 -- Private
912 -- Pre-Req
913 --
914 -- Parameters
915 --
916 -- IN
917 -- p_api_version_number IN NUMBER Required
918 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
919 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
920 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
921 -- p_ozf_offer_line_rec IN ozf_offer_line_rec_type Required
922 --
923 -- OUT
924 -- x_return_status OUT VARCHAR2
925 -- x_msg_count OUT NUMBER
926 -- x_msg_data OUT VARCHAR2
927 -- Version : Current version 1.0
928 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
929 -- and basic operation, developer must manually add parameters and business logic as necessary.
930 --
931 -- History
932 --
933 -- NOTE
934 --
935 -- End of Comments
936 -- ==============================================================================
937
938 PROCEDURE Create_Ozf_Disc_Line(
939 p_api_version_number IN NUMBER,
940 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
941 p_commit IN VARCHAR2 := FND_API.G_FALSE,
942 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
943
944 x_return_status OUT NOCOPY VARCHAR2,
945 x_msg_count OUT NOCOPY NUMBER,
946 x_msg_data OUT NOCOPY VARCHAR2,
947
948 p_ozf_offer_line_rec IN ozf_offer_line_rec_type := g_miss_ozf_offer_line_rec,
949 x_offer_discount_line_id OUT NOCOPY NUMBER
950 )
951
952 IS
953 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Ozf_Disc_Line';
954 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
955 l_return_status_full VARCHAR2(1);
956 l_object_version_number NUMBER := 1;
957 l_org_id NUMBER := FND_API.G_MISS_NUM;
958 l_offer_discount_line_id NUMBER;
959 l_dummy NUMBER;
960 l_ozf_offer_line_rec ozf_offer_line_rec_type;
961 CURSOR c_id IS
962 SELECT ozf_offer_discount_lines_s.NEXTVAL
963 FROM dual;
964
965 CURSOR c_id_exists (l_id IN NUMBER) IS
966 SELECT 1
967 FROM OZF_OFFER_DISCOUNT_LINES
968 WHERE offer_discount_line_id = l_id;
969 BEGIN
970 -- Standard Start of API savepoint
971 SAVEPOINT create_ozf_disc_line_pvt;
972
973 -- Standard call to check for call compatibility.
974 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
975 p_api_version_number,
976 l_api_name,
977 G_PKG_NAME)
978 THEN
979 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
980 END IF;
981
982
983 -- Initialize message list if p_init_msg_list is set to TRUE.
984 IF FND_API.to_Boolean( p_init_msg_list )
985 THEN
986 FND_MSG_PUB.initialize;
987 END IF;
988
989
990
991 -- Debug Message
992 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
993
994
995 -- Initialize API return status to SUCCESS
996 x_return_status := FND_API.G_RET_STS_SUCCESS;
997
998 -- =========================================================================
999 -- Validate Environment
1000 -- =========================================================================
1001
1002 IF FND_GLOBAL.USER_ID IS NULL
1003 THEN
1004 OZF_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
1005 RAISE FND_API.G_EXC_ERROR;
1006 END IF;
1007
1008
1009
1010
1011 -- Local variable initialization
1012 l_ozf_offer_line_rec := p_ozf_offer_line_rec;
1013 IF p_ozf_offer_line_rec.offer_discount_line_id IS NULL OR p_ozf_offer_line_rec.offer_discount_line_id = FND_API.g_miss_num THEN
1017 FETCH c_id INTO l_offer_discount_line_id;
1014 LOOP
1015 l_dummy := NULL;
1016 OPEN c_id;
1018 CLOSE c_id;
1019
1020 OPEN c_id_exists(l_offer_discount_line_id);
1021 FETCH c_id_exists INTO l_dummy;
1022 CLOSE c_id_exists;
1023 EXIT WHEN l_dummy IS NULL;
1024 END LOOP;
1025 ELSE
1026 l_offer_discount_line_id := p_ozf_offer_line_rec.offer_discount_line_id;
1027 END IF;
1028
1029
1030 l_ozf_offer_line_rec.offer_discount_line_id := l_offer_discount_line_id;
1031 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
1032 THEN
1033 -- Debug message
1034 OZF_UTILITY_PVT.debug_message('Private API: Validate_Ozf_Disc_Line');
1035
1036 -- Invoke validation procedures
1037 Validate_ozf_disc_line(
1038 p_api_version_number => 1.0,
1039 p_init_msg_list => FND_API.G_FALSE,
1040 p_validation_level => p_validation_level,
1041 p_validation_mode => JTF_PLSQL_API.g_create,
1042 p_ozf_offer_line_rec => l_ozf_offer_line_rec,
1043 x_return_status => x_return_status,
1044 x_msg_count => x_msg_count,
1045 x_msg_data => x_msg_data);
1046 END IF;
1047
1048 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
1049 RAISE FND_API.G_EXC_ERROR;
1050 END IF;
1051
1052 -- Debug Message
1053 OZF_UTILITY_PVT.debug_message( 'Private API: Calling create table handler');
1054 -- Invoke table handler(OZF_DISC_LINE_PKG.Insert_Row)
1055 OZF_DISC_LINE_PKG.Insert_Row(
1056 px_offer_discount_line_id => l_offer_discount_line_id,
1057 p_parent_discount_line_id => l_ozf_offer_line_rec.parent_discount_line_id,
1058 p_volume_from => l_ozf_offer_line_rec.volume_from,
1059 p_volume_to => l_ozf_offer_line_rec.volume_to,
1060 p_volume_operator => l_ozf_offer_line_rec.volume_operator,
1061 p_volume_type => l_ozf_offer_line_rec.volume_type,
1062 p_volume_break_type => l_ozf_offer_line_rec.volume_break_type,
1063 p_discount => l_ozf_offer_line_rec.discount,
1064 p_discount_type => l_ozf_offer_line_rec.discount_type,
1065 p_tier_type => l_ozf_offer_line_rec.tier_type,
1066 p_tier_level => l_ozf_offer_line_rec.tier_level,
1067 p_incompatibility_group => l_ozf_offer_line_rec.incompatibility_group,
1068 p_precedence => l_ozf_offer_line_rec.precedence,
1069 p_bucket => l_ozf_offer_line_rec.bucket,
1070 p_scan_value => l_ozf_offer_line_rec.scan_value,
1071 p_scan_data_quantity => l_ozf_offer_line_rec.scan_data_quantity,
1072 p_scan_unit_forecast => l_ozf_offer_line_rec.scan_unit_forecast,
1073 p_channel_id => l_ozf_offer_line_rec.channel_id,
1074 p_adjustment_flag => l_ozf_offer_line_rec.adjustment_flag,
1075 p_start_date_active => l_ozf_offer_line_rec.start_date_active,
1076 p_end_date_active => l_ozf_offer_line_rec.end_date_active,
1077 p_uom_code => l_ozf_offer_line_rec.uom_code,
1078 p_creation_date => SYSDATE,
1079 p_created_by => FND_GLOBAL.USER_ID,
1080 p_last_update_date => SYSDATE,
1081 p_last_updated_by => FND_GLOBAL.USER_ID,
1082 p_last_update_login => FND_GLOBAL.conc_login_id,
1083 px_object_version_number => l_object_version_number,
1084 p_context => l_ozf_offer_line_rec.context,
1085 p_attribute1 => l_ozf_offer_line_rec.attribute1,
1086 p_attribute2 => l_ozf_offer_line_rec.attribute2,
1087 p_attribute3 => l_ozf_offer_line_rec.attribute3,
1088 p_attribute4 => l_ozf_offer_line_rec.attribute4,
1089 p_attribute5 => l_ozf_offer_line_rec.attribute5,
1090 p_attribute6 => l_ozf_offer_line_rec.attribute6,
1091 p_attribute7 => l_ozf_offer_line_rec.attribute7,
1092 p_attribute8 => l_ozf_offer_line_rec.attribute8,
1093 p_attribute9 => l_ozf_offer_line_rec.attribute9,
1094 p_attribute10 => l_ozf_offer_line_rec.attribute10,
1095 p_attribute11 => l_ozf_offer_line_rec.attribute11,
1096 p_attribute12 => l_ozf_offer_line_rec.attribute12,
1097 p_attribute13 => l_ozf_offer_line_rec.attribute13,
1098 p_attribute14 => l_ozf_offer_line_rec.attribute14,
1099 p_attribute15 => l_ozf_offer_line_rec.attribute15,
1100 p_offer_id => l_ozf_offer_line_rec.offer_id
1101 );
1102
1103 x_offer_discount_line_id := l_offer_discount_line_id;
1104 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1105 RAISE FND_API.G_EXC_ERROR;
1106 END IF;
1107 --
1108 -- End of API body
1109 --
1110
1111 -- Standard check for p_commit
1112 IF FND_API.to_Boolean( p_commit )
1113 THEN
1114 COMMIT WORK;
1115 END IF;
1116
1117
1118 -- Debug Message
1119 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
1120
1121 -- Standard call to get message count and if count is 1, get message info.
1122 FND_MSG_PUB.Count_And_Get
1123 (p_count => x_msg_count,
1124 p_data => x_msg_data
1125 );
1126 EXCEPTION
1127
1128 WHEN OZF_Utility_PVT.resource_locked THEN
1132 WHEN FND_API.G_EXC_ERROR THEN
1129 x_return_status := FND_API.g_ret_sts_error;
1130 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1131
1133 ROLLBACK TO CREATE_Ozf_Disc_Line_PVT;
1134 x_return_status := FND_API.G_RET_STS_ERROR;
1135 -- Standard call to get message count and if count=1, get the message
1136 FND_MSG_PUB.Count_And_Get (
1137 p_encoded => FND_API.G_FALSE,
1138 p_count => x_msg_count,
1139 p_data => x_msg_data
1140 );
1141
1142 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1143 ROLLBACK TO CREATE_Ozf_Disc_Line_PVT;
1144 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1145 -- Standard call to get message count and if count=1, get the message
1146 FND_MSG_PUB.Count_And_Get (
1147 p_encoded => FND_API.G_FALSE,
1148 p_count => x_msg_count,
1149 p_data => x_msg_data
1150 );
1151
1152 WHEN OTHERS THEN
1153 ROLLBACK TO CREATE_Ozf_Disc_Line_PVT;
1154 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1155 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1156 THEN
1157 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1158 END IF;
1159 -- Standard call to get message count and if count=1, get the message
1160 FND_MSG_PUB.Count_And_Get (
1161 p_encoded => FND_API.G_FALSE,
1162 p_count => x_msg_count,
1163 p_data => x_msg_data
1164 );
1165 End Create_Ozf_Disc_Line;
1166
1167
1168 -- ==============================================================================
1169 -- Start of Comments
1170 -- ==============================================================================
1171 -- API Name
1172 -- Update_Ozf_Disc_Line
1173 -- Type
1174 -- Private
1175 -- Pre-Req
1176 --
1177 -- Parameters
1178 --
1179 -- IN
1180 -- p_api_version_number IN NUMBER Required
1181 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
1182 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
1183 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
1184 -- p_ozf_offer_line_rec IN ozf_offer_line_rec_type Required
1185 --
1186 -- OUT
1187 -- x_return_status OUT VARCHAR2
1188 -- x_msg_count OUT NUMBER
1189 -- x_msg_data OUT VARCHAR2
1190 -- Version : Current version 1.0
1191 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
1192 -- and basic operation, developer must manually add parameters and business logic as necessary.
1193 --
1194 -- History
1195 --
1196 -- NOTE
1197 --
1198 -- End of Comments
1199 -- ==============================================================================
1200
1201 PROCEDURE Update_Ozf_Disc_Line(
1202 p_api_version_number IN NUMBER,
1203 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1204 p_commit IN VARCHAR2 := FND_API.G_FALSE,
1205 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
1206
1207 x_return_status OUT NOCOPY VARCHAR2,
1208 x_msg_count OUT NOCOPY NUMBER,
1209 x_msg_data OUT NOCOPY VARCHAR2,
1210
1211 p_ozf_offer_line_rec IN ozf_offer_line_rec_type
1212 )
1213
1214 IS
1215
1216
1217 CURSOR c_get_ozf_disc_line(offer_discount_line_id NUMBER) IS
1218 SELECT *
1219 FROM OZF_OFFER_DISCOUNT_LINES
1220 WHERE offer_discount_line_id = p_ozf_offer_line_rec.offer_discount_line_id;
1221 -- Hint: Developer need to provide Where clause
1222
1223
1224 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_Ozf_Disc_Line';
1225 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1226 -- Local Variables
1227 l_object_version_number NUMBER;
1228 l_offer_discount_line_id NUMBER;
1229 l_ref_ozf_offer_line_rec c_get_Ozf_Disc_Line%ROWTYPE ;
1230 l_tar_ozf_offer_line_rec ozf_offer_line_rec_type := P_ozf_offer_line_rec;
1231 l_rowid ROWID;
1232
1233 BEGIN
1234 -- Standard Start of API savepoint
1235 SAVEPOINT update_ozf_disc_line_pvt;
1236
1237 -- Standard call to check for call compatibility.
1238 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1239 p_api_version_number,
1240 l_api_name,
1241 G_PKG_NAME)
1242 THEN
1243 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1244 END IF;
1245
1246
1247 -- Initialize message list if p_init_msg_list is set to TRUE.
1248 IF FND_API.to_Boolean( p_init_msg_list )
1249 THEN
1250 FND_MSG_PUB.initialize;
1251 END IF;
1252
1253
1254
1255 -- Debug Message
1256 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
1257
1258
1259
1260 -- Initialize API return status to SUCCESS
1261 x_return_status := FND_API.G_RET_STS_SUCCESS;
1262
1263 -- Debug Message
1267 FETCH c_get_Ozf_Disc_Line INTO l_ref_ozf_offer_line_rec ;
1264 OZF_UTILITY_PVT.debug_message('Private API: - Open Cursor to Select');
1265
1266 OPEN c_get_Ozf_Disc_Line( l_tar_ozf_offer_line_rec.offer_discount_line_id);
1268 If ( c_get_Ozf_Disc_Line%NOTFOUND) THEN
1269 OZF_Utility_PVT.Error_Message(p_message_name => 'API_MISSING_UPDATE_TARGET',
1270 p_token_name => 'INFO',
1271 p_token_value => 'Ozf_Disc_Line') ;
1272 RAISE FND_API.G_EXC_ERROR;
1273 END IF;
1274 -- Debug Message
1275 CLOSE c_get_Ozf_Disc_Line;
1276
1277
1278 If (l_tar_ozf_offer_line_rec.object_version_number is NULL or
1279 l_tar_ozf_offer_line_rec.object_version_number = FND_API.G_MISS_NUM ) Then
1280 OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
1281 p_token_name => 'COLUMN',
1282 p_token_value => 'Last_Update_Date') ;
1283 raise FND_API.G_EXC_ERROR;
1284 End if;
1285 -- Check Whether record has been changed by someone else
1286 If (l_tar_ozf_offer_line_rec.object_version_number <> l_ref_ozf_offer_line_rec.object_version_number) Then
1287 OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
1288 p_token_name => 'INFO',
1289 p_token_value => 'Ozf_Disc_Line') ;
1290 raise FND_API.G_EXC_ERROR;
1291 End if;
1292
1293
1294 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
1295 THEN
1296 -- Debug message
1297 OZF_UTILITY_PVT.debug_message('Private API: Validate_Ozf_Disc_Line');
1298
1299 -- Invoke validation procedures
1300 Validate_ozf_disc_line(
1301 p_api_version_number => 1.0,
1302 p_init_msg_list => FND_API.G_FALSE,
1303 p_validation_level => p_validation_level,
1304 p_validation_mode => JTF_PLSQL_API.g_update,
1305 p_ozf_offer_line_rec => p_ozf_offer_line_rec,
1306 x_return_status => x_return_status,
1307 x_msg_count => x_msg_count,
1308 x_msg_data => x_msg_data);
1309 END IF;
1310
1311 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
1312 RAISE FND_API.G_EXC_ERROR;
1313 END IF;
1314
1315 -- Debug Message
1316
1317 -- Invoke table handler(OZF_DISC_LINE_PKG.Update_Row)
1318 OZF_DISC_LINE_PKG.Update_Row(
1319 p_offer_discount_line_id => p_ozf_offer_line_rec.offer_discount_line_id,
1320 p_parent_discount_line_id => p_ozf_offer_line_rec.parent_discount_line_id,
1321 p_volume_from => p_ozf_offer_line_rec.volume_from,
1322 p_volume_to => p_ozf_offer_line_rec.volume_to,
1323 p_volume_operator => p_ozf_offer_line_rec.volume_operator,
1324 p_volume_type => p_ozf_offer_line_rec.volume_type,
1325 p_volume_break_type => p_ozf_offer_line_rec.volume_break_type,
1326 p_discount => p_ozf_offer_line_rec.discount,
1327 p_discount_type => p_ozf_offer_line_rec.discount_type,
1328 p_tier_type => p_ozf_offer_line_rec.tier_type,
1329 p_tier_level => p_ozf_offer_line_rec.tier_level,
1330 p_incompatibility_group => p_ozf_offer_line_rec.incompatibility_group,
1331 p_precedence => p_ozf_offer_line_rec.precedence,
1332 p_bucket => p_ozf_offer_line_rec.bucket,
1333 p_scan_value => p_ozf_offer_line_rec.scan_value,
1334 p_scan_data_quantity => p_ozf_offer_line_rec.scan_data_quantity,
1335 p_scan_unit_forecast => p_ozf_offer_line_rec.scan_unit_forecast,
1336 p_channel_id => p_ozf_offer_line_rec.channel_id,
1337 p_adjustment_flag => p_ozf_offer_line_rec.adjustment_flag,
1338 p_start_date_active => p_ozf_offer_line_rec.start_date_active,
1339 p_end_date_active => p_ozf_offer_line_rec.end_date_active,
1340 p_uom_code => p_ozf_offer_line_rec.uom_code,
1341 p_last_update_date => SYSDATE,
1342 p_last_updated_by => FND_GLOBAL.USER_ID,
1343 p_last_update_login => FND_GLOBAL.conc_login_id,
1344 p_object_version_number => p_ozf_offer_line_rec.object_version_number,
1345 p_context => p_ozf_offer_line_rec.context,
1346 p_attribute1 => p_ozf_offer_line_rec.attribute1,
1347 p_attribute2 => p_ozf_offer_line_rec.attribute2,
1348 p_attribute3 => p_ozf_offer_line_rec.attribute3,
1349 p_attribute4 => p_ozf_offer_line_rec.attribute4,
1350 p_attribute5 => p_ozf_offer_line_rec.attribute5,
1351 p_attribute6 => p_ozf_offer_line_rec.attribute6,
1352 p_attribute7 => p_ozf_offer_line_rec.attribute7,
1353 p_attribute8 => p_ozf_offer_line_rec.attribute8,
1354 p_attribute9 => p_ozf_offer_line_rec.attribute9,
1355 p_attribute10 => p_ozf_offer_line_rec.attribute10,
1356 p_attribute11 => p_ozf_offer_line_rec.attribute11,
1357 p_attribute12 => p_ozf_offer_line_rec.attribute12,
1358 p_attribute13 => p_ozf_offer_line_rec.attribute13,
1359 p_attribute14 => p_ozf_offer_line_rec.attribute14,
1360 p_attribute15 => p_ozf_offer_line_rec.attribute15,
1361 p_offer_id => p_ozf_offer_line_rec.offer_id
1362 );
1363
1364 --
1365 -- End of API body.
1366 --
1367
1368 -- Standard check for p_commit
1369 IF FND_API.to_Boolean( p_commit )
1370 THEN
1371 COMMIT WORK;
1375 -- Debug Message
1372 END IF;
1373
1374
1376 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
1377
1378
1379 -- Standard call to get message count and if count is 1, get message info.
1380 FND_MSG_PUB.Count_And_Get
1381 (p_count => x_msg_count,
1382 p_data => x_msg_data
1383 );
1384 EXCEPTION
1385
1386 WHEN OZF_Utility_PVT.resource_locked THEN
1387 x_return_status := FND_API.g_ret_sts_error;
1388 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1389
1390 WHEN FND_API.G_EXC_ERROR THEN
1391 ROLLBACK TO UPDATE_Ozf_Disc_Line_PVT;
1392 x_return_status := FND_API.G_RET_STS_ERROR;
1393 -- Standard call to get message count and if count=1, get the message
1394 FND_MSG_PUB.Count_And_Get (
1395 p_encoded => FND_API.G_FALSE,
1396 p_count => x_msg_count,
1397 p_data => x_msg_data
1398 );
1399
1400 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1401 ROLLBACK TO UPDATE_Ozf_Disc_Line_PVT;
1402 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1403 -- Standard call to get message count and if count=1, get the message
1404 FND_MSG_PUB.Count_And_Get (
1405 p_encoded => FND_API.G_FALSE,
1406 p_count => x_msg_count,
1407 p_data => x_msg_data
1408 );
1409
1410 WHEN OTHERS THEN
1411 ROLLBACK TO UPDATE_Ozf_Disc_Line_PVT;
1412 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1413 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1414 THEN
1415 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1416 END IF;
1417 -- Standard call to get message count and if count=1, get the message
1418 FND_MSG_PUB.Count_And_Get (
1419 p_encoded => FND_API.G_FALSE,
1420 p_count => x_msg_count,
1421 p_data => x_msg_data
1422 );
1423 End Update_Ozf_Disc_Line;
1424
1425
1426 -- ==============================================================================
1427 -- Start of Comments
1428 -- ==============================================================================
1429 -- API Name
1430 -- Delete_Ozf_Disc_Line
1431 -- Type
1432 -- Private
1433 -- Pre-Req
1434 --
1435 -- Parameters
1436 --
1437 -- IN
1438 -- p_api_version_number IN NUMBER Required
1439 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
1440 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
1441 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
1442 -- p_offer_discount_line_id IN NUMBER
1443 -- p_object_version_number IN NUMBER Optional Default = NULL
1444 --
1445 -- OUT
1446 -- x_return_status OUT VARCHAR2
1447 -- x_msg_count OUT NUMBER
1448 -- x_msg_data OUT VARCHAR2
1449 -- Version : Current version 1.0
1450 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
1451 -- and basic operation, developer must manually add parameters and business logic as necessary.
1452 --
1453 -- History
1454 --
1455 -- NOTE
1456 --
1457 -- End of Comments
1458 -- ==============================================================================
1459
1460 PROCEDURE Delete_Ozf_Disc_Line(
1461 p_api_version_number IN NUMBER,
1462 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1463 p_commit IN VARCHAR2 := FND_API.G_FALSE,
1464 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
1465 x_return_status OUT NOCOPY VARCHAR2,
1466 x_msg_count OUT NOCOPY NUMBER,
1467 x_msg_data OUT NOCOPY VARCHAR2,
1468 p_offer_discount_line_id IN NUMBER,
1469 p_object_version_number IN NUMBER
1470 )
1471
1472 IS
1473 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Ozf_Disc_Line';
1474 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1475 l_object_version_number NUMBER;
1476
1477 BEGIN
1478 -- Standard Start of API savepoint
1479 SAVEPOINT delete_ozf_disc_line_pvt;
1480
1481 -- Standard call to check for call compatibility.
1482 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1483 p_api_version_number,
1484 l_api_name,
1485 G_PKG_NAME)
1486 THEN
1487 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1488 END IF;
1489
1490
1491 -- Initialize message list if p_init_msg_list is set to TRUE.
1492 IF FND_API.to_Boolean( p_init_msg_list )
1493 THEN
1494 FND_MSG_PUB.initialize;
1495 END IF;
1496
1497
1498
1499 -- Debug Message
1500 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
1501
1502
1503
1504 -- Initialize API return status to SUCCESS
1505 x_return_status := FND_API.G_RET_STS_SUCCESS;
1506
1510 -- Debug Message
1507 --
1508 -- Api body
1509 --
1511 OZF_UTILITY_PVT.debug_message( 'Private API: Calling delete table handler');
1512
1513 -- Invoke table handler(OZF_DISC_LINE_PKG.Delete_Row)
1514 OZF_DISC_LINE_PKG.Delete_Row(
1515 p_offer_discount_line_id => p_offer_discount_line_id,
1516 p_object_version_number => p_object_version_number );
1517 --
1518 -- End of API body
1519 --
1520
1521 -- Standard check for p_commit
1522 IF FND_API.to_Boolean( p_commit )
1523 THEN
1524 COMMIT WORK;
1525 END IF;
1526
1527
1528 -- Debug Message
1529 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
1530
1531
1532 -- Standard call to get message count and if count is 1, get message info.
1533 FND_MSG_PUB.Count_And_Get
1534 (p_count => x_msg_count,
1535 p_data => x_msg_data
1536 );
1537 EXCEPTION
1538
1539 WHEN OZF_Utility_PVT.resource_locked THEN
1540 x_return_status := FND_API.g_ret_sts_error;
1541 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1542
1543 WHEN FND_API.G_EXC_ERROR THEN
1544 ROLLBACK TO DELETE_Ozf_Disc_Line_PVT;
1545 x_return_status := FND_API.G_RET_STS_ERROR;
1546 -- Standard call to get message count and if count=1, get the message
1547 FND_MSG_PUB.Count_And_Get (
1548 p_encoded => FND_API.G_FALSE,
1549 p_count => x_msg_count,
1550 p_data => x_msg_data
1551 );
1552
1553 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1554 ROLLBACK TO DELETE_Ozf_Disc_Line_PVT;
1555 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1556 -- Standard call to get message count and if count=1, get the message
1557 FND_MSG_PUB.Count_And_Get (
1558 p_encoded => FND_API.G_FALSE,
1559 p_count => x_msg_count,
1560 p_data => x_msg_data
1561 );
1562
1563 WHEN OTHERS THEN
1564 ROLLBACK TO DELETE_Ozf_Disc_Line_PVT;
1565 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1566 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1567 THEN
1568 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1569 END IF;
1570 -- Standard call to get message count and if count=1, get the message
1571 FND_MSG_PUB.Count_And_Get (
1572 p_encoded => FND_API.G_FALSE,
1573 p_count => x_msg_count,
1574 p_data => x_msg_data
1575 );
1576 End Delete_Ozf_Disc_Line;
1577
1578
1579 --==================================End Discount Line Methods ===============================
1580
1581
1582 -- ==============================================================================
1583 -- Start of Comments
1584 -- ==============================================================================
1585 -- API Name
1586 -- Lock_Ozf_Prod_Line
1587 -- Type
1588 -- Private
1589 -- Pre-Req
1590 --
1591 -- Parameters
1592 --
1593 -- IN
1594 -- p_api_version_number IN NUMBER Required
1595 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
1596 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
1597 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
1598 -- p_ozf_prod_rec IN ozf_prod_rec_type Required
1599 --
1600 -- OUT
1601 -- x_return_status OUT VARCHAR2
1602 -- x_msg_count OUT NUMBER
1603 -- x_msg_data OUT VARCHAR2
1604 -- Version : Current version 1.0
1605 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
1606 -- and basic operation, developer must manually add parameters and business logic as necessary.
1607 --
1608 -- History
1609 --
1610 -- NOTE
1611 --
1612 -- End of Comments
1613 -- ==============================================================================
1614
1615 PROCEDURE Lock_Ozf_Prod_Line(
1616 p_api_version_number IN NUMBER,
1617 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1618
1619 x_return_status OUT NOCOPY VARCHAR2,
1620 x_msg_count OUT NOCOPY NUMBER,
1621 x_msg_data OUT NOCOPY VARCHAR2,
1622
1623 p_off_discount_product_id IN NUMBER,
1624 p_object_version IN NUMBER
1625 )
1626
1627 IS
1628 L_API_NAME CONSTANT VARCHAR2(30) := 'Lock_Ozf_Prod_Line';
1629 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1630 L_FULL_NAME CONSTANT VARCHAR2(60) := g_pkg_name ||'.'|| l_api_name;
1631 l_off_discount_product_id NUMBER;
1632
1633 BEGIN
1634
1635 -- Debug Message
1636 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
1637
1638
1639 -- Initialize message list if p_init_msg_list is set to TRUE.
1640 IF FND_API.to_Boolean( p_init_msg_list )
1641 THEN
1642 FND_MSG_PUB.initialize;
1643 END IF;
1644
1645
1646
1650 l_api_name,
1647 -- Standard call to check for call compatibility.
1648 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1649 p_api_version_number,
1651 G_PKG_NAME)
1652 THEN
1653 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1654 END IF;
1655
1656
1657
1658 -- Initialize API return status to SUCCESS
1659 x_return_status := FND_API.G_RET_STS_SUCCESS;
1660
1661
1662 ------------------------ lock -------------------------
1663 Ozf_Create_Ozf_Prod_Line_Pkg.Lock_Row(l_off_discount_product_id,p_object_version);
1664
1665
1666 -------------------- finish --------------------------
1667 FND_MSG_PUB.count_and_get(
1668 p_encoded => FND_API.g_false,
1669 p_count => x_msg_count,
1670 p_data => x_msg_data);
1671 OZF_Utility_PVT.debug_message(l_full_name ||': end');
1672 EXCEPTION
1673
1674 WHEN OZF_Utility_PVT.resource_locked THEN
1675 x_return_status := FND_API.g_ret_sts_error;
1676 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1677
1678 WHEN FND_API.G_EXC_ERROR THEN
1679 ROLLBACK TO Lock_Ozf_Prod_Line_PVT;
1680 x_return_status := FND_API.G_RET_STS_ERROR;
1681 -- Standard call to get message count and if count=1, get the message
1682 FND_MSG_PUB.Count_And_Get (
1683 p_encoded => FND_API.G_FALSE,
1684 p_count => x_msg_count,
1685 p_data => x_msg_data
1686 );
1687
1688 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1689 ROLLBACK TO Lock_Ozf_Prod_Line_PVT;
1690 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1691 -- Standard call to get message count and if count=1, get the message
1692 FND_MSG_PUB.Count_And_Get (
1693 p_encoded => FND_API.G_FALSE,
1694 p_count => x_msg_count,
1695 p_data => x_msg_data
1696 );
1697
1698 WHEN OTHERS THEN
1699 ROLLBACK TO Lock_Ozf_Prod_Line_PVT;
1700 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1701 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1702 THEN
1703 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1704 END IF;
1705 -- Standard call to get message count and if count=1, get the message
1706 FND_MSG_PUB.Count_And_Get (
1707 p_encoded => FND_API.G_FALSE,
1708 p_count => x_msg_count,
1709 p_data => x_msg_data
1710 );
1711 End Lock_Ozf_Prod_Line;
1712
1713
1714 FUNCTION check_item_exists( p_product_level IN VARCHAR2
1715 ,p_product_id IN NUMBER
1716 ,p_offer_id IN NUMBER
1717 ,p_excluder_flag IN VARCHAR2)
1718 RETURN VARCHAR2
1719 IS
1720 CURSOR c_item_exists(p_item_level VARCHAR2,p_item_number NUMBER,p_excluder_flag VARCHAR2 , p_offer_id NUMBER) IS
1721 SELECT 1 from ozf_offer_discount_products
1722 WHERE product_level = p_item_level
1723 AND product_id = p_item_number
1724 AND excluder_flag = p_excluder_flag
1725 AND offer_id = p_offer_id ;
1726 l_item_exists NUMBER := 0;
1727 l_return VARCHAR2(1) := 'N';
1728 BEGIN
1729 OPEN c_item_exists(p_product_level,p_product_id,p_excluder_flag ,p_offer_id);
1730 FETCH c_item_exists INTO l_item_exists;
1731 CLOSE c_item_exists;
1732 IF l_item_exists <> 0 THEN
1733 l_return := 'Y';
1734 END IF;
1735 return l_return;
1736 END check_item_exists;
1737
1738 PROCEDURE check_Ozf_Prod_Uk_Items(
1739 p_ozf_prod_rec IN ozf_prod_rec_type,
1740 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
1741 x_return_status OUT NOCOPY VARCHAR2)
1742 IS
1743 l_valid_flag VARCHAR2(1);
1744 BEGIN
1745 x_return_status := FND_API.g_ret_sts_success;
1746 IF p_validation_mode = JTF_PLSQL_API.g_create
1747 AND p_ozf_prod_rec.off_discount_product_id IS NOT NULL
1748 THEN
1749 l_valid_flag := OZF_Utility_PVT.check_uniqueness(
1750 'ozf_offer_discount_products',
1751 'off_discount_product_id = ''' || p_ozf_prod_rec.off_discount_product_id ||''''
1752 );
1753 END IF;
1754 IF l_valid_flag = FND_API.g_false THEN
1755 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFF_DISC_PROD_ID_DUP');
1756 x_return_status := FND_API.g_ret_sts_error;
1757 END IF;
1758
1759 END check_Ozf_Prod_Uk_Items;
1760
1761
1762
1763 PROCEDURE check_Ozf_Prod_Req_Items(
1764 p_ozf_prod_rec IN ozf_prod_rec_type,
1765 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
1766 x_return_status OUT NOCOPY VARCHAR2
1767 )
1768 IS
1769 BEGIN
1770 x_return_status := FND_API.g_ret_sts_success;
1771
1772 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
1773
1774
1775 IF p_ozf_prod_rec.offer_id = FND_API.G_MISS_NUM OR p_ozf_prod_rec.offer_id IS NULL THEN
1776 OZF_Utility_PVT.Error_Message('OZF_API_MISSING' , 'MISS_FIELD','OFFER_ID');
1780 OZF_Utility_PVT.Error_Message('OZF_API_MISSING' , 'MISS_FIELD','OFFER_DISCOUNT_LINE_ID');
1777 x_return_status := FND_API.g_ret_sts_error;
1778 END IF;
1779 IF p_ozf_prod_rec.offer_discount_line_id = FND_API.G_MISS_NUM OR p_ozf_prod_rec.offer_discount_line_id IS NULL THEN
1781 x_return_status := FND_API.g_ret_sts_error;
1782 END IF;
1783 IF p_ozf_prod_rec.off_discount_product_id = FND_API.G_MISS_NUM OR p_ozf_prod_rec.off_discount_product_id IS NULL THEN
1784 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFF_DISCOUNT_PRODUCT_ID' );
1785 x_return_status := FND_API.g_ret_sts_error;
1786 END IF;
1787
1788
1789 IF p_ozf_prod_rec.product_level = FND_API.g_miss_char OR p_ozf_prod_rec.product_level IS NULL THEN
1790 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PRODUCT_LEVEL' );
1791 x_return_status := FND_API.g_ret_sts_error;
1792 END IF;
1793
1794
1795 IF p_ozf_prod_rec.product_id = FND_API.G_MISS_NUM OR p_ozf_prod_rec.product_id IS NULL THEN
1796 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PRODUCT_ID' );
1797 x_return_status := FND_API.g_ret_sts_error;
1798 END IF;
1799
1800
1801 IF p_ozf_prod_rec.excluder_flag = FND_API.g_miss_char OR p_ozf_prod_rec.excluder_flag IS NULL THEN
1802 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'EXCLUDER_FLAG' );
1803 x_return_status := FND_API.g_ret_sts_error;
1804 END IF;
1805
1806
1807 /* IF p_ozf_prod_rec.uom_code = FND_API.g_miss_char OR p_ozf_prod_rec.uom_code IS NULL THEN
1808 OZF_Utility_PVT.Error_Message('AMS_API_MISSING_FIELD', 'MISS_FIELD', 'UOM_CODE' );
1809 x_return_status := FND_API.g_ret_sts_error;
1810 END IF;
1811 */
1812
1813 ELSE
1814
1815 IF p_ozf_prod_rec.offer_id = FND_API.G_MISS_NUM THEN
1816 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD','MISS_FIELD','OFFER_ID');
1817 x_return_status := FND_API.g_ret_sts_error;
1818 END IF;
1819 IF p_ozf_prod_rec.offer_discount_line_id = FND_API.G_MISS_NUM THEN
1820 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD','MISS_FIELD','OFFER_DISCOUNT_LINE_ID');
1821 x_return_status := FND_API.g_ret_sts_error;
1822 END IF;
1823 IF p_ozf_prod_rec.off_discount_product_id = FND_API.G_MISS_NUM THEN
1824 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFF_DISCOUNT_PRODUCT_ID' );
1825 x_return_status := FND_API.g_ret_sts_error;
1826 END IF;
1827
1828
1829 IF p_ozf_prod_rec.product_level = FND_API.g_miss_char THEN
1830 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PRODUCT_LEVEL' );
1831 x_return_status := FND_API.g_ret_sts_error;
1832 END IF;
1833
1834
1835 IF p_ozf_prod_rec.product_id = FND_API.G_MISS_NUM THEN
1836 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PRODUCT_ID' );
1837 x_return_status := FND_API.g_ret_sts_error;
1838 END IF;
1839
1840
1841 IF p_ozf_prod_rec.excluder_flag = FND_API.g_miss_char THEN
1842 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'EXCLUDER_FLAG' );
1843 x_return_status := FND_API.g_ret_sts_error;
1844 END IF;
1845
1846
1847 /* IF p_ozf_prod_rec.uom_code = FND_API.g_miss_char THEN
1848 OZF_Utility_PVT.Error_Message('AMS_API_MISSING_FIELD', 'MISS_FIELD', 'UOM_CODE' );
1849 x_return_status := FND_API.g_ret_sts_error;
1850 END IF; */
1851 END IF;
1852
1853 END check_Ozf_Prod_Req_Items;
1854
1855
1856
1857 PROCEDURE check_Ozf_Prod_Fk_Items(
1858 p_ozf_prod_rec IN ozf_prod_rec_type,
1859 x_return_status OUT NOCOPY VARCHAR2
1860 )
1861 IS
1862 BEGIN
1863 x_return_status := FND_API.g_ret_sts_success;
1864
1865 -- Enter custom code here
1866 IF p_ozf_prod_rec.offer_id is not null AND p_ozf_prod_rec.offer_id <> FND_API.G_MISS_NUM THEN
1867 IF ozf_utility_pvt.check_fk_exists('OZF_OFFERS','OFFER_ID',to_char(p_ozf_prod_rec.offer_id)) = FND_API.g_false THEN
1868 OZF_Utility_PVT.Error_Message('OZF_PROD_OFFER_ID_FK_DUP' ); -- correct message
1869 x_return_status := FND_API.g_ret_sts_error;
1870 END IF;
1871 END IF;
1872
1873 IF p_ozf_prod_rec.offer_discount_line_id <> -1 THEN
1874 IF p_ozf_prod_rec.offer_discount_line_id is not null AND p_ozf_prod_rec.offer_discount_line_id <> fnd_api.g_miss_num THEN
1875 IF ozf_utility_pvt.check_fk_exists('OZF_OFFER_DISCOUNT_LINES','OFFER_DISCOUNT_LINE_ID',to_char(p_ozf_prod_rec.offer_discount_line_id)) = FND_API.g_false THEN
1876 OZF_Utility_PVT.Error_Message('OZF_DISC_LINE_FK_DUP' ); -- correct message
1877 x_return_status := FND_API.g_ret_sts_error;
1878 END IF;
1879 END IF;
1880 END IF;
1881
1882 END check_Ozf_Prod_Fk_Items;
1883
1884
1885
1886 PROCEDURE check_Ozf_Prod_Lookup_Items(
1887 p_ozf_prod_rec IN ozf_prod_rec_type,
1888 x_return_status OUT NOCOPY VARCHAR2
1889 )
1890 IS
1891 BEGIN
1892 x_return_status := FND_API.g_ret_sts_success;
1893
1894 -- Enter custom code here
1895
1896 END check_Ozf_Prod_Lookup_Items;
1897
1898
1902 )
1899 PROCEDURE check_Ozf_Prod_attr_Items(
1900 p_ozf_prod_rec IN ozf_prod_rec_type,
1901 x_return_status OUT NOCOPY VARCHAR2
1903 IS
1904 l_item_exists VARCHAR2(1) := NULL;
1905 BEGIN
1906 x_return_status := FND_API.g_ret_sts_success;
1907
1908 -- Enter custom code here
1909 IF p_ozf_prod_rec.excluder_flag = 'N' THEN
1910 l_item_exists := check_item_exists(p_ozf_prod_rec.product_level,p_ozf_prod_rec.product_id,p_ozf_prod_rec.offer_id,p_ozf_prod_rec.excluder_flag);
1911 IF l_item_exists = 'Y' THEN
1912 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFR_DUPL_ITEM');
1913 x_return_status := FND_API.g_ret_sts_error;
1914 return;
1915 END IF;
1916 END IF;
1917
1918 END check_Ozf_Prod_attr_Items;
1919
1920
1921 PROCEDURE Check_Ozf_Prod_Items (
1922 P_ozf_prod_rec IN ozf_prod_rec_type,
1923 p_validation_mode IN VARCHAR2,
1924 x_return_status OUT NOCOPY VARCHAR2
1925 )
1926 IS
1927 l_return_status VARCHAR2(1);
1928 BEGIN
1929
1930 l_return_status := FND_API.g_ret_sts_success;
1931 -- Check Items Uniqueness API calls
1932 check_Ozf_prod_Uk_Items(
1933 p_ozf_prod_rec => p_ozf_prod_rec,
1934 p_validation_mode => p_validation_mode,
1935 x_return_status => x_return_status);
1936 IF x_return_status <> FND_API.g_ret_sts_success THEN
1937 l_return_status := FND_API.g_ret_sts_error;
1938 END IF;
1939 -- Check Items Required/NOT NULL API calls
1940 check_ozf_prod_req_items(
1941 p_ozf_prod_rec => p_ozf_prod_rec,
1942 p_validation_mode => p_validation_mode,
1943 x_return_status => x_return_status);
1944 IF x_return_status <> FND_API.g_ret_sts_success THEN
1945 l_return_status := FND_API.g_ret_sts_error;
1946 END IF;
1947 -- Check Items Foreign Keys API calls
1948 check_ozf_prod_FK_items(
1949 p_ozf_prod_rec => p_ozf_prod_rec,
1950 x_return_status => x_return_status);
1951 IF x_return_status <> FND_API.g_ret_sts_success THEN
1952 l_return_status := FND_API.g_ret_sts_error;
1953 END IF;
1954 -- Check Items Lookups
1955 check_ozf_prod_Lookup_items(
1956 p_ozf_prod_rec => p_ozf_prod_rec,
1957 x_return_status => x_return_status);
1958 IF x_return_status <> FND_API.g_ret_sts_success THEN
1959 l_return_status := FND_API.g_ret_sts_error;
1960 END IF;
1961
1962 check_Ozf_Prod_attr_Items
1963 (
1964 p_ozf_prod_rec => p_ozf_prod_rec,
1965 x_return_status => x_return_status
1966 );
1967 IF x_return_status <> FND_API.g_ret_sts_success THEN
1968 l_return_status := FND_API.g_ret_sts_error;
1969 END IF;
1970
1971 x_return_status := l_return_status;
1972
1973 END Check_ozf_prod_Items;
1974
1975
1976
1977
1978
1979 PROCEDURE Complete_Ozf_Prod_Rec (
1980 p_ozf_prod_rec IN ozf_prod_rec_type,
1981 x_complete_rec OUT NOCOPY ozf_prod_rec_type)
1982 IS
1983 l_return_status VARCHAR2(1);
1984
1985 CURSOR c_complete IS
1986 SELECT *
1987 FROM ozf_offer_discount_products
1988 WHERE off_discount_product_id = p_ozf_prod_rec.off_discount_product_id;
1989 l_ozf_prod_rec c_complete%ROWTYPE;
1990 BEGIN
1991 x_complete_rec := p_ozf_prod_rec;
1992
1993
1994 OPEN c_complete;
1995 FETCH c_complete INTO l_ozf_prod_rec;
1996 CLOSE c_complete;
1997
1998 -- off_discount_product_id
1999 IF p_ozf_prod_rec.off_discount_product_id IS NULL THEN
2000 x_complete_rec.off_discount_product_id := l_ozf_prod_rec.off_discount_product_id;
2001 END IF;
2002
2003 -- product_level
2004 IF p_ozf_prod_rec.product_level IS NULL THEN
2005 x_complete_rec.product_level := l_ozf_prod_rec.product_level;
2006 END IF;
2007
2008 -- product_id
2009 IF p_ozf_prod_rec.product_id IS NULL THEN
2010 x_complete_rec.product_id := l_ozf_prod_rec.product_id;
2011 END IF;
2012
2013 -- excluder_flag
2014 IF p_ozf_prod_rec.excluder_flag IS NULL THEN
2015 x_complete_rec.excluder_flag := l_ozf_prod_rec.excluder_flag;
2016 END IF;
2017
2018 -- uom_code
2019 IF p_ozf_prod_rec.uom_code IS NULL THEN
2020 x_complete_rec.uom_code := l_ozf_prod_rec.uom_code;
2021 END IF;
2022
2023 -- start_date_active
2024 IF p_ozf_prod_rec.start_date_active IS NULL THEN
2025 x_complete_rec.start_date_active := l_ozf_prod_rec.start_date_active;
2026 END IF;
2027
2028 -- end_date_active
2029 IF p_ozf_prod_rec.end_date_active IS NULL THEN
2030 x_complete_rec.end_date_active := l_ozf_prod_rec.end_date_active;
2031 END IF;
2032
2033 -- offer_discount_line_id
2034 IF p_ozf_prod_rec.offer_discount_line_id IS NULL THEN
2035 x_complete_rec.offer_discount_line_id := l_ozf_prod_rec.offer_discount_line_id;
2036 END IF;
2037
2038 -- offer_id
2039 IF p_ozf_prod_rec.offer_id IS NULL THEN
2040 x_complete_rec.offer_id := l_ozf_prod_rec.offer_id;
2041 END IF;
2042
2043 -- creation_date
2044 IF p_ozf_prod_rec.creation_date IS NULL THEN
2045 x_complete_rec.creation_date := l_ozf_prod_rec.creation_date;
2046 END IF;
2047
2048 -- created_by
2049 IF p_ozf_prod_rec.created_by IS NULL THEN
2053 -- last_update_date
2050 x_complete_rec.created_by := l_ozf_prod_rec.created_by;
2051 END IF;
2052
2054 IF p_ozf_prod_rec.last_update_date IS NULL THEN
2055 x_complete_rec.last_update_date := l_ozf_prod_rec.last_update_date;
2056 END IF;
2057
2058 -- last_updated_by
2059 IF p_ozf_prod_rec.last_updated_by IS NULL THEN
2060 x_complete_rec.last_updated_by := l_ozf_prod_rec.last_updated_by;
2061 END IF;
2062
2063 -- last_update_login
2064 IF p_ozf_prod_rec.last_update_login IS NULL THEN
2065 x_complete_rec.last_update_login := l_ozf_prod_rec.last_update_login;
2066 END IF;
2067
2068 -- object_version_number
2069 /* IF p_ozf_prod_rec.object_version_number IS NULL THEN
2070 x_complete_rec.object_version_number := l_ozf_prod_rec.object_version_number;
2071 END IF;
2072 */
2073 -- Note: Developers need to modify the procedure
2074 -- to handle any business specific requirements.
2075 END Complete_Ozf_Prod_Rec;
2076
2077
2078
2079
2080 PROCEDURE Default_Ozf_Prod_Items ( p_ozf_prod_rec IN ozf_prod_rec_type ,
2081 x_ozf_prod_rec OUT NOCOPY ozf_prod_rec_type )
2082 IS
2083 l_ozf_prod_rec ozf_prod_rec_type := p_ozf_prod_rec;
2084 BEGIN
2085 -- Developers should put their code to default the record type
2086 -- e.g. IF p_campaign_rec.status_code IS NULL
2087 -- OR p_campaign_rec.status_code = FND_API.G_MISS_CHAR THEN
2088 -- l_campaign_rec.status_code := 'NEW' ;
2089 -- END IF ;
2090 --
2091 NULL ;
2092 END;
2093
2094
2095
2096
2097
2098
2099 PROCEDURE Validate_Ozf_Prod_Rec (
2100 p_api_version_number IN NUMBER,
2101 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2102 x_return_status OUT NOCOPY VARCHAR2,
2103 x_msg_count OUT NOCOPY NUMBER,
2104 x_msg_data OUT NOCOPY VARCHAR2,
2105 p_ozf_prod_rec IN ozf_prod_rec_type
2106 )
2107 IS
2108 BEGIN
2109 -- Initialize message list if p_init_msg_list is set to TRUE.
2110 IF FND_API.to_Boolean( p_init_msg_list )
2111 THEN
2112 FND_MSG_PUB.initialize;
2113 END IF;
2114
2115
2116
2117 -- Initialize API return status to SUCCESS
2118 x_return_status := FND_API.G_RET_STS_SUCCESS;
2119
2120 -- Hint: Validate data
2121 -- If data not valid
2122 -- THEN
2123 -- x_return_status := FND_API.G_RET_STS_ERROR;
2124
2125 -- Debug Message
2126 OZF_UTILITY_PVT.debug_message('Private API: Validate_dm_model_rec');
2127 -- Standard call to get message count and if count is 1, get message info.
2128 FND_MSG_PUB.Count_And_Get
2129 (p_count => x_msg_count,
2130 p_data => x_msg_data
2131 );
2132 END Validate_ozf_prod_Rec;
2133 PROCEDURE Validate_Create_Ozf_Prod_Line(
2134 p_api_version_number IN NUMBER,
2135 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2136 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
2137 p_ozf_prod_rec IN ozf_prod_rec_type,
2138 p_validation_mode IN VARCHAR2,
2139 x_return_status OUT NOCOPY VARCHAR2,
2140 x_msg_count OUT NOCOPY NUMBER,
2141 x_msg_data OUT NOCOPY VARCHAR2
2142 )
2143 IS
2144 L_API_NAME CONSTANT VARCHAR2(30) := 'Validate_Create_Ozf_Prod_Line';
2145 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2146 l_object_version_number NUMBER;
2147 l_ozf_prod_rec ozf_prod_rec_type;
2148
2149 BEGIN
2150 -- Standard Start of API savepoint
2151 SAVEPOINT validate_create_ozf_prod_line_;
2152
2153 -- Standard call to check for call compatibility.
2154 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2155 p_api_version_number,
2156 l_api_name,
2157 G_PKG_NAME)
2158 THEN
2159 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2160 END IF;
2161
2162
2163 -- Initialize message list if p_init_msg_list is set to TRUE.
2164 IF FND_API.to_Boolean( p_init_msg_list )
2165 THEN
2166 FND_MSG_PUB.initialize;
2167 END IF;
2168
2169 -- Debug Message
2170 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
2171
2172
2173
2174 -- Initialize API return status to SUCCESS
2175 x_return_status := FND_API.G_RET_STS_SUCCESS;
2176
2177
2178 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
2179 Check_ozf_prod_Items(
2180 p_ozf_prod_rec => p_ozf_prod_rec,
2181 p_validation_mode => p_validation_mode,
2182 x_return_status => x_return_status
2183 );
2184
2185 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2186 RAISE FND_API.G_EXC_ERROR;
2187 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2188 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2189 END IF;
2190 END IF;
2191 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
2195
2192 Default_Ozf_Prod_Items (p_ozf_prod_rec => p_ozf_prod_rec ,
2193 x_ozf_prod_rec => l_ozf_prod_rec) ;
2194 END IF ;
2196 Complete_ozf_prod_Rec(
2197 p_ozf_prod_rec => l_ozf_prod_rec,
2198 x_complete_rec => l_ozf_prod_rec
2199 );
2200 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
2201 Validate_ozf_prod_Rec(
2202 p_api_version_number => 1.0,
2203 p_init_msg_list => FND_API.G_FALSE,
2204 x_return_status => x_return_status,
2205 x_msg_count => x_msg_count,
2206 x_msg_data => x_msg_data,
2207 p_ozf_prod_rec => l_ozf_prod_rec);
2208 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2209 RAISE FND_API.G_EXC_ERROR;
2210 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2211 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2212 END IF;
2213 END IF;
2214 -- Debug Message
2215 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
2216
2217
2218 -- Standard call to get message count and if count is 1, get message info.
2219 FND_MSG_PUB.Count_And_Get
2220 (p_count => x_msg_count,
2221 p_data => x_msg_data
2222 );
2223 EXCEPTION
2224
2225 WHEN OZF_Utility_PVT.resource_locked THEN
2226 x_return_status := FND_API.g_ret_sts_error;
2227 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
2228
2229 WHEN FND_API.G_EXC_ERROR THEN
2230 ROLLBACK TO VALIDATE_Create_Ozf_Prod_Line_;
2231 x_return_status := FND_API.G_RET_STS_ERROR;
2232 -- Standard call to get message count and if count=1, get the message
2233 FND_MSG_PUB.Count_And_Get (
2234 p_encoded => FND_API.G_FALSE,
2235 p_count => x_msg_count,
2236 p_data => x_msg_data
2237 );
2238
2239 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2240 ROLLBACK TO VALIDATE_Create_Ozf_Prod_Line_;
2241 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2242 -- Standard call to get message count and if count=1, get the message
2243 FND_MSG_PUB.Count_And_Get (
2244 p_encoded => FND_API.G_FALSE,
2245 p_count => x_msg_count,
2246 p_data => x_msg_data
2247 );
2248
2249 WHEN OTHERS THEN
2250 ROLLBACK TO VALIDATE_Create_Ozf_Prod_Line_;
2251 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2252 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2253 THEN
2254 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2255 END IF;
2256 -- Standard call to get message count and if count=1, get the message
2257 FND_MSG_PUB.Count_And_Get (
2258 p_encoded => FND_API.G_FALSE,
2259 p_count => x_msg_count,
2260 p_data => x_msg_data
2261 );
2262 End Validate_Create_Ozf_Prod_Line;
2263
2264 --============================Product Line Methods ==========================================
2265 -- Hint: Primary key needs to be returned.
2266 -- ==============================================================================
2267 -- Start of Comments
2268 -- ==============================================================================
2269 -- API Name
2270 -- Create_Ozf_Prod_Line
2271 -- Type
2272 -- Private
2273 -- Pre-Req
2274 --
2275 -- Parameters
2276 --
2277 -- IN
2278 -- p_api_version_number IN NUMBER Required
2279 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
2280 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
2281 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
2282 -- p_ozf_prod_rec IN ozf_prod_rec_type Required
2283 --
2284 -- OUT
2285 -- x_return_status OUT VARCHAR2
2286 -- x_msg_count OUT NUMBER
2287 -- x_msg_data OUT VARCHAR2
2288 -- Version : Current version 1.0
2289 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
2290 -- and basic operation, developer must manually add parameters and business logic as necessary.
2291 --
2292 -- History
2293 --
2294 -- NOTE
2295 --
2296 -- End of Comments
2297 -- ==============================================================================
2298
2299 PROCEDURE Create_Ozf_Prod_Line(
2300 p_api_version_number IN NUMBER,
2301 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2302 p_commit IN VARCHAR2 := FND_API.G_FALSE,
2303 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
2304
2305 x_return_status OUT NOCOPY VARCHAR2,
2306 x_msg_count OUT NOCOPY NUMBER,
2307 x_msg_data OUT NOCOPY VARCHAR2,
2308
2309 p_ozf_prod_rec IN ozf_prod_rec_type,
2310 x_off_discount_product_id OUT NOCOPY NUMBER
2311 )
2312
2313 IS
2314 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Ozf_Prod_Line';
2318 l_org_id NUMBER := FND_API.G_MISS_NUM;
2315 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2316 l_return_status_full VARCHAR2(1);
2317 l_object_version_number NUMBER := 1;
2319 l_off_discount_product_id NUMBER;
2320 l_dummy NUMBER;
2321 l_ozf_prod_rec ozf_prod_rec_type := g_miss_ozf_prod_rec;
2322
2323 CURSOR c_id IS
2324 SELECT ozf_offer_discount_products_s.NEXTVAL
2325 FROM dual;
2326
2327 CURSOR c_id_exists (l_id IN NUMBER) IS
2328 SELECT 1
2329 FROM OZF_OFFER_DISCOUNT_PRODUCTS
2330 WHERE off_discount_product_id = l_id;
2331 BEGIN
2332 -- Standard Start of API savepoint
2333 SAVEPOINT Create_Ozf_Prod_Line_pvt;
2334
2335 -- Standard call to check for call compatibility.
2336 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2337 p_api_version_number,
2338 l_api_name,
2339 G_PKG_NAME)
2340 THEN
2341 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2342 END IF;
2343
2344
2345 -- Initialize message list if p_init_msg_list is set to TRUE.
2346 IF FND_API.to_Boolean( p_init_msg_list )
2347 THEN
2348 FND_MSG_PUB.initialize;
2349 END IF;
2350
2351
2352
2353 -- Debug Message
2354 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
2355
2356
2357
2358 -- Initialize API return status to SUCCESS
2359 x_return_status := FND_API.G_RET_STS_SUCCESS;
2360
2361 -- =========================================================================
2362 -- Validate Environment
2363 -- =========================================================================
2364
2365 IF FND_GLOBAL.USER_ID IS NULL
2366 THEN
2367 OZF_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
2368 RAISE FND_API.G_EXC_ERROR;
2369 END IF;
2370
2371
2372
2373 -- Local variable initialization
2374 l_ozf_prod_rec := p_ozf_prod_rec;
2375 IF p_ozf_prod_rec.off_discount_product_id IS NULL OR p_ozf_prod_rec.off_discount_product_id = FND_API.g_miss_num THEN
2376 LOOP
2377 l_dummy := NULL;
2378 OPEN c_id;
2379 FETCH c_id INTO l_off_discount_product_id;
2380 CLOSE c_id;
2381
2382 OPEN c_id_exists(l_off_discount_product_id);
2383 FETCH c_id_exists INTO l_dummy;
2384 CLOSE c_id_exists;
2385 EXIT WHEN l_dummy IS NULL;
2386 END LOOP;
2387 ELSE
2388 l_off_discount_product_id := p_ozf_prod_rec.off_discount_product_id;
2389 END IF;
2390 l_ozf_prod_rec.off_discount_product_id := l_off_discount_product_id;
2391 IF p_ozf_prod_rec.excluder_flag IS NOT NULL THEN
2392 l_ozf_prod_rec.excluder_flag := p_ozf_prod_rec.excluder_flag;
2393 ELSE
2394 l_ozf_prod_rec.excluder_flag := 'N';
2395 END IF;
2396
2397
2398 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
2399 THEN
2400 -- Debug message
2401 OZF_UTILITY_PVT.debug_message('Private API: Validate_Create_Ozf_Prod_Line');
2402
2403 -- Invoke validation procedures
2404 Validate_create_ozf_prod_line(
2405 p_api_version_number => 1.0,
2406 p_init_msg_list => FND_API.G_FALSE,
2407 p_validation_level => p_validation_level,
2408 p_validation_mode => JTF_PLSQL_API.g_create,
2409 p_ozf_prod_rec => l_ozf_prod_rec,
2410 x_return_status => x_return_status,
2411 x_msg_count => x_msg_count,
2412 x_msg_data => x_msg_data);
2413 END IF;
2414
2415 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
2416 RAISE FND_API.G_EXC_ERROR;
2417 END IF;
2418
2419 -- Debug Message
2420 OZF_UTILITY_PVT.debug_message( 'Private API: Calling create table handler');
2421
2422 -- Invoke table handler(Ozf_Create_Ozf_Prod_Line_Pkg.Insert_Row)
2423 Ozf_Create_Ozf_Prod_Line_Pkg.Insert_Row(
2424 px_off_discount_product_id => l_off_discount_product_id,
2425 p_parent_off_disc_prod_id => l_ozf_prod_rec.parent_off_disc_prod_id,
2426 p_product_level => l_ozf_prod_rec.product_level,
2430 p_start_date_active => l_ozf_prod_rec.start_date_active,
2427 p_product_id => l_ozf_prod_rec.product_id,
2428 p_excluder_flag => l_ozf_prod_rec.excluder_flag,
2429 p_uom_code => l_ozf_prod_rec.uom_code,
2431 p_end_date_active => l_ozf_prod_rec.end_date_active,
2432 p_offer_discount_line_id => l_ozf_prod_rec.offer_discount_line_id,
2433 p_offer_id => l_ozf_prod_rec.offer_id,
2434 p_creation_date => SYSDATE,
2435 p_created_by => FND_GLOBAL.USER_ID,
2436 p_last_update_date => SYSDATE,
2437 p_last_updated_by => FND_GLOBAL.USER_ID,
2438 p_last_update_login => FND_GLOBAL.conc_login_id,
2439 px_object_version_number => l_object_version_number
2440 );
2441
2442 x_off_discount_product_id := l_off_discount_product_id;
2443 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2444 RAISE FND_API.G_EXC_ERROR;
2445 END IF;
2446 --
2447 -- End of API body
2448 --
2449
2450 -- Standard check for p_commit
2451 IF FND_API.to_Boolean( p_commit )
2452 THEN
2453 COMMIT WORK;
2454 END IF;
2455
2456
2457 -- Debug Message
2458 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
2459
2460
2461 -- Standard call to get message count and if count is 1, get message info.
2462 FND_MSG_PUB.Count_And_Get
2463 (p_count => x_msg_count,
2464 p_data => x_msg_data
2465 );
2466 EXCEPTION
2467
2468 WHEN OZF_Utility_PVT.resource_locked THEN
2469 x_return_status := FND_API.g_ret_sts_error;
2470 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
2471
2472 WHEN FND_API.G_EXC_ERROR THEN
2473 ROLLBACK TO Create_Ozf_Prod_Line_PVT;
2474 x_return_status := FND_API.G_RET_STS_ERROR;
2475 -- Standard call to get message count and if count=1, get the message
2476 FND_MSG_PUB.Count_And_Get (
2477 p_encoded => FND_API.G_FALSE,
2478 p_count => x_msg_count,
2479 p_data => x_msg_data
2480 );
2481
2482 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2483 ROLLBACK TO Create_Ozf_Prod_Line_PVT;
2484 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2485 -- Standard call to get message count and if count=1, get the message
2486 FND_MSG_PUB.Count_And_Get (
2487 p_encoded => FND_API.G_FALSE,
2488 p_count => x_msg_count,
2489 p_data => x_msg_data
2490 );
2491
2492 WHEN OTHERS THEN
2493 ROLLBACK TO Create_Ozf_Prod_Line_PVT;
2494 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2495 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2496 THEN
2497 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2498 END IF;
2499 -- Standard call to get message count and if count=1, get the message
2500 FND_MSG_PUB.Count_And_Get (
2501 p_encoded => FND_API.G_FALSE,
2502 p_count => x_msg_count,
2503 p_data => x_msg_data
2504 );
2505 End Create_Ozf_Prod_Line;
2506
2507
2508 -- ==============================================================================
2509 -- Start of Comments
2510 -- ==============================================================================
2511 -- API Name
2512 -- Update_Create_Ozf_Prod_Line
2513 -- Type
2514 -- Private
2515 -- Pre-Req
2516 --
2517 -- Parameters
2518 --
2519 -- IN
2520 -- p_api_version_number IN NUMBER Required
2521 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
2522 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
2523 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
2524 -- p_ozf_prod_rec IN ozf_prod_rec_type Required
2525 --
2526 -- OUT
2527 -- x_return_status OUT VARCHAR2
2528 -- x_msg_count OUT NUMBER
2529 -- x_msg_data OUT VARCHAR2
2530 -- Version : Current version 1.0
2531 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
2532 -- and basic operation, developer must manually add parameters and business logic as necessary.
2533 --
2534 -- History
2535 --
2536 -- NOTE
2537 --
2538 -- End of Comments
2539 -- ==============================================================================
2540
2541 PROCEDURE Update_Ozf_Prod_Line(
2542 p_api_version_number IN NUMBER,
2543 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2544 p_commit IN VARCHAR2 := FND_API.G_FALSE,
2545 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
2546
2547 x_return_status OUT NOCOPY VARCHAR2,
2548 x_msg_count OUT NOCOPY NUMBER,
2549 x_msg_data OUT NOCOPY VARCHAR2,
2550
2551 p_ozf_prod_rec IN ozf_prod_rec_type
2552 )
2553
2554 IS
2555
2556
2557 CURSOR c_get_create_ozf_prod_line(off_discount_product_id NUMBER) IS
2558 SELECT *
2559 FROM OZF_OFFER_DISCOUNT_PRODUCTS
2563
2560 WHERE off_discount_product_id = p_ozf_prod_rec.off_discount_product_id;
2561 -- Hint: Developer need to provide Where clause
2562
2564 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_Ozf_Prod_Line';
2565 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2566 -- Local Variables
2567 l_object_version_number NUMBER;
2568 l_off_discount_product_id NUMBER;
2569 l_ref_ozf_prod_rec c_get_Create_Ozf_Prod_Line%ROWTYPE ;
2570 l_tar_ozf_prod_rec ozf_prod_rec_type := P_ozf_prod_rec;
2571 l_rowid ROWID;
2572
2573 BEGIN
2574 -- Standard Start of API savepoint
2575 SAVEPOINT Update_Ozf_Prod_Line_pvt;
2576
2577 -- Standard call to check for call compatibility.
2578 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2579 p_api_version_number,
2580 l_api_name,
2581 G_PKG_NAME)
2582 THEN
2583 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2584 END IF;
2585
2586
2587 -- Initialize message list if p_init_msg_list is set to TRUE.
2588 IF FND_API.to_Boolean( p_init_msg_list )
2589 THEN
2590 FND_MSG_PUB.initialize;
2591 END IF;
2592
2593
2594
2595 -- Debug Message
2596 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
2597
2598
2599
2600 -- Initialize API return status to SUCCESS
2601 x_return_status := FND_API.G_RET_STS_SUCCESS;
2602
2603 -- Debug Message
2604 OZF_UTILITY_PVT.debug_message('Private API: - Open Cursor to Select');
2605
2606 OPEN c_get_Create_Ozf_Prod_Line( l_tar_ozf_prod_rec.off_discount_product_id);
2607
2608 FETCH c_get_Create_Ozf_Prod_Line INTO l_ref_ozf_prod_rec ;
2609
2610 If ( c_get_Create_Ozf_Prod_Line%NOTFOUND) THEN
2611 OZF_Utility_PVT.Error_Message(p_message_name => 'API_MISSING_UPDATE_TARGET',
2612 p_token_name => 'INFO',
2613 p_token_value => 'Create_Ozf_Prod_Line') ;
2614 RAISE FND_API.G_EXC_ERROR;
2615 END IF;
2616 -- Debug Message
2617 OZF_UTILITY_PVT.debug_message('Private API: - Close Cursor');
2618 CLOSE c_get_Create_Ozf_Prod_Line;
2619
2620
2621 /* If (l_tar_ozf_prod_rec.object_version_number is NULL or
2622 l_tar_ozf_prod_rec.object_version_number = FND_API.G_MISS_NUM ) Then
2623 OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
2624 p_token_name => 'COLUMN',
2625 p_token_value => 'Last_Update_Date') ;
2626 raise FND_API.G_EXC_ERROR;
2627 End if;
2628 -- Check Whether record has been changed by someone else
2629 If (l_tar_ozf_prod_rec.object_version_number <> l_ref_ozf_prod_rec.object_version_number) Then
2630 OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
2631 p_token_name => 'INFO',
2632 p_token_value => 'Create_Ozf_Prod_Line') ;
2633 raise FND_API.G_EXC_ERROR;
2634 End if;
2635 */
2636
2637 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
2638 THEN
2639 -- Debug message
2640 OZF_UTILITY_PVT.debug_message('Private API: Validate_Create_Ozf_Prod_Line');
2641
2642 -- Invoke validation procedures
2643 Validate_create_ozf_prod_line(
2644 p_api_version_number => 1.0,
2645 p_init_msg_list => FND_API.G_FALSE,
2646 p_validation_level => p_validation_level,
2647 p_validation_mode => JTF_PLSQL_API.g_update,
2648 p_ozf_prod_rec => p_ozf_prod_rec,
2649 x_return_status => x_return_status,
2650 x_msg_count => x_msg_count,
2651 x_msg_data => x_msg_data);
2652 END IF;
2653
2654 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
2655 RAISE FND_API.G_EXC_ERROR;
2656 END IF;
2657
2658
2659 -- Debug Message
2660 -- OZF_UTILITY_PVT.debug_message(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW, 'Private API: Calling update table handler');
2661
2662 -- Invoke table handler(Ozf_Create_Ozf_Prod_Line_Pkg.Update_Row)
2663 Ozf_Create_Ozf_Prod_Line_Pkg.Update_Row(
2664 p_off_discount_product_id => p_ozf_prod_rec.off_discount_product_id,
2665 p_parent_off_disc_prod_id => p_ozf_prod_rec.parent_off_disc_prod_id,
2666 p_product_level => p_ozf_prod_rec.product_level,
2667 p_product_id => p_ozf_prod_rec.product_id,
2668 p_excluder_flag => p_ozf_prod_rec.excluder_flag,
2669 p_uom_code => p_ozf_prod_rec.uom_code,
2670 p_start_date_active => p_ozf_prod_rec.start_date_active,
2671 p_end_date_active => p_ozf_prod_rec.end_date_active,
2672 p_offer_discount_line_id => p_ozf_prod_rec.offer_discount_line_id,
2673 p_offer_id => p_ozf_prod_rec.offer_id,
2674 p_last_update_date => SYSDATE,
2675 p_last_updated_by => FND_GLOBAL.USER_ID,
2676 p_last_update_login => FND_GLOBAL.conc_login_id,
2677 p_object_version_number => p_ozf_prod_rec.object_version_number
2678 );
2679 --
2680 -- End of API body.
2681 --
2682
2683 -- Standard check for p_commit
2684 IF FND_API.to_Boolean( p_commit )
2685 THEN
2686 COMMIT WORK;
2690 -- Debug Message
2687 END IF;
2688
2689
2691 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
2692
2693
2694 -- Standard call to get message count and if count is 1, get message info.
2695 FND_MSG_PUB.Count_And_Get
2696 (p_count => x_msg_count,
2697 p_data => x_msg_data
2698 );
2699 EXCEPTION
2700
2701 WHEN OZF_Utility_PVT.resource_locked THEN
2702 x_return_status := FND_API.g_ret_sts_error;
2703 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
2704
2705 WHEN FND_API.G_EXC_ERROR THEN
2706 ROLLBACK TO Update_Ozf_Prod_Line_PVT;
2707 x_return_status := FND_API.G_RET_STS_ERROR;
2708 -- Standard call to get message count and if count=1, get the message
2709 FND_MSG_PUB.Count_And_Get (
2710 p_encoded => FND_API.G_FALSE,
2711 p_count => x_msg_count,
2712 p_data => x_msg_data
2713 );
2714
2715 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2716 ROLLBACK TO Update_Ozf_Prod_Line_PVT;
2717 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2718 -- Standard call to get message count and if count=1, get the message
2719 FND_MSG_PUB.Count_And_Get (
2720 p_encoded => FND_API.G_FALSE,
2721 p_count => x_msg_count,
2722 p_data => x_msg_data
2723 );
2724
2725 WHEN OTHERS THEN
2726 ROLLBACK TO Update_Ozf_Prod_Line_PVT;
2727 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2728 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2729 THEN
2730 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2731 END IF;
2732 -- Standard call to get message count and if count=1, get the message
2733 FND_MSG_PUB.Count_And_Get (
2734 p_encoded => FND_API.G_FALSE,
2735 p_count => x_msg_count,
2736 p_data => x_msg_data
2737 );
2738 End Update_Ozf_Prod_Line;
2739
2740 -- ==========================================================================================
2741 -- Description: deletes Product Lines for given discount line id.
2742 -- This method is basically used for deleting all the products (including exc;usion) rules
2743 -- for given discount Rule
2744 --==========================================================================================
2745 PROCEDURE DELETE_EXCLUSIONS(
2746 p_api_version_number IN NUMBER,
2747 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2748 p_commit IN VARCHAR2 := FND_API.G_FALSE,
2749 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
2750 x_return_status OUT NOCOPY VARCHAR2,
2751 x_msg_count OUT NOCOPY NUMBER,
2752 x_msg_data OUT NOCOPY VARCHAR2,
2753 p_parent_off_disc_prod_id IN NUMBER
2754 )
2755 IS
2756 CURSOR c_excl_id IS
2757 select * FROM ozf_offer_discount_products where parent_off_disc_prod_id = p_parent_off_disc_prod_id;
2758 L_API_NAME CONSTANT VARCHAR2(30) := 'DELETE_EXCLUSIONS';
2759 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2760
2761 BEGIN
2762 SAVEPOINT Delete_Exclusions_sp;
2763 x_return_status := FND_API.G_RET_STS_SUCCESS;
2764
2765 ozf_utility_pvt.debug_message('@# Parent Prod Id is '||p_parent_off_disc_prod_id);
2766 FOR excl_rec IN c_excl_id LOOP
2767 ozf_utility_pvt.debug_message('@# Prod id is '||excl_rec.off_discount_product_id);
2768 OZF_Create_Ozf_Prod_Line_PKG.Delete_row(
2769 p_off_discount_product_id => excl_rec.off_discount_product_id,
2770 p_object_version_number => excl_rec.object_version_number);
2771 END LOOP;
2772
2773 EXCEPTION
2774 WHEN FND_API.G_EXC_ERROR THEN
2775 ROLLBACK TO Delete_Exclusions_sp;
2776 x_return_status := FND_API.G_RET_STS_ERROR;
2777 -- Standard call to get message count and if count=1, get the message
2778 FND_MSG_PUB.Count_And_Get (
2779 p_encoded => FND_API.G_FALSE,
2780 p_count => x_msg_count,
2781 p_data => x_msg_data
2782 );
2783
2784 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2785 ROLLBACK TO Delete_Exclusions_sp;
2786 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2787 -- Standard call to get message count and if count=1, get the message
2788 FND_MSG_PUB.Count_And_Get (
2789 p_encoded => FND_API.G_FALSE,
2790 p_count => x_msg_count,
2791 p_data => x_msg_data
2792 );
2793
2794 WHEN OTHERS THEN
2795 ROLLBACK TO Delete_Exclusions_sp;
2796 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2797 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2798 THEN
2799 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2800 END IF;
2801 -- Standard call to get message count and if count=1, get the message
2802 FND_MSG_PUB.Count_And_Get (
2803 p_encoded => FND_API.G_FALSE,
2804 p_count => x_msg_count,
2805 p_data => x_msg_data
2806 );
2807
2808 END DELETE_EXCLUSIONS;
2809
2810
2811 -- ==============================================================================
2815 -- Delete_Ozf_Prod_Line
2812 -- Start of Comments
2813 -- ==============================================================================
2814 -- API Name
2816 -- Type
2817 -- Private
2818 -- Pre-Req
2819 --
2820 -- Parameters
2821 --
2822 -- IN
2823 -- p_api_version_number IN NUMBER Required
2824 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
2825 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
2826 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
2827 -- p_off_discount_product_id IN NUMBER
2828 -- p_object_version_number IN NUMBER Optional Default = NULL
2829 --
2830 -- OUT
2831 -- x_return_status OUT VARCHAR2
2832 -- x_msg_count OUT NUMBER
2833 -- x_msg_data OUT VARCHAR2
2834 -- Version : Current version 1.0
2835 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
2836 -- and basic operation, developer must manually add parameters and business logic as necessary.
2837 --
2838 -- History
2839 --
2840 -- NOTE
2841 --
2842 -- End of Comments
2843 -- ==============================================================================
2844
2845 PROCEDURE Delete_Ozf_Prod_Line(
2846 p_api_version_number IN NUMBER,
2847 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2848 p_commit IN VARCHAR2 := FND_API.G_FALSE,
2849 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
2850 x_return_status OUT NOCOPY VARCHAR2,
2851 x_msg_count OUT NOCOPY NUMBER,
2852 x_msg_data OUT NOCOPY VARCHAR2,
2853 p_off_discount_product_id IN NUMBER,
2854 p_object_version_number IN NUMBER
2855 )
2856
2857 IS
2858 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Ozf_Prod_Line';
2859 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2860 l_object_version_number NUMBER;
2861
2862 CURSOR c_offer_id (p_off_discount_product_id NUMBER) IS
2863 select offer_id FROM ozf_offer_discount_products where off_discount_product_id = p_off_discount_product_id;
2864 l_offer_id ozf_offers.offer_id%type;
2865
2866 BEGIN
2867 -- Standard Start of API savepoint
2868 SAVEPOINT Delete_Ozf_Prod_Line_pvt;
2869
2870 -- Standard call to check for call compatibility.
2871 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2872 p_api_version_number,
2873 l_api_name,
2874 G_PKG_NAME)
2875 THEN
2876 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2877 END IF;
2878
2879
2880 -- Initialize message list if p_init_msg_list is set to TRUE.
2881 IF FND_API.to_Boolean( p_init_msg_list )
2882 THEN
2883 FND_MSG_PUB.initialize;
2884 END IF;
2885
2886
2887
2888 -- Debug Message
2889 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
2890
2891
2892
2893 -- Initialize API return status to SUCCESS
2894 x_return_status := FND_API.G_RET_STS_SUCCESS;
2895
2896 --
2897 -- Api body
2898 --
2899 -- Debug Message
2900 OZF_UTILITY_PVT.debug_message( 'Private API: Calling delete table handler');
2901 -- Invoke table handler(Ozf_Create_Ozf_Prod_Line_Pkg.Delete_Row)
2902 open c_offer_id(p_off_discount_product_id);
2903 fetch c_offer_id INTO l_offer_id;
2904 close c_offer_id;
2905 IF is_delete_valid(l_offer_id) = 'N' THEN
2906 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFR_CANT_DELETE_LINE');
2907 RAISE FND_API.G_EXC_ERROR;
2908 END IF;
2909 DELETE_EXCLUSIONS(
2910 p_api_version_number => p_api_version_number,
2911 p_init_msg_list => p_init_msg_list,
2912 p_commit => p_commit,
2913 p_validation_level => p_validation_level,
2914 x_return_status => x_return_status,
2915 x_msg_count => x_msg_count,
2916 x_msg_data => x_msg_data,
2917 p_parent_off_disc_prod_id => p_off_discount_product_id
2918 );
2919
2920 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
2921 RAISE FND_API.G_EXC_ERROR;
2922 END IF;
2923 Ozf_Create_Ozf_Prod_Line_Pkg.Delete_Row(
2924 p_off_discount_product_id => p_off_discount_product_id,
2925 p_object_version_number => p_object_version_number );
2926 --
2927 -- End of API body
2928 --
2929
2930 -- Standard check for p_commit
2931 IF FND_API.to_Boolean( p_commit )
2932 THEN
2933 COMMIT WORK;
2934 END IF;
2935
2936
2937 -- Debug Message
2938 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
2939
2940
2941 -- Standard call to get message count and if count is 1, get message info.
2942 FND_MSG_PUB.Count_And_Get
2946 EXCEPTION
2943 (p_count => x_msg_count,
2944 p_data => x_msg_data
2945 );
2947
2948 WHEN OZF_Utility_PVT.resource_locked THEN
2949 x_return_status := FND_API.g_ret_sts_error;
2950 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
2951
2952 WHEN FND_API.G_EXC_ERROR THEN
2953 ROLLBACK TO Delete_Ozf_Prod_Line_PVT;
2954 x_return_status := FND_API.G_RET_STS_ERROR;
2955 -- Standard call to get message count and if count=1, get the message
2956 FND_MSG_PUB.Count_And_Get (
2957 p_encoded => FND_API.G_FALSE,
2958 p_count => x_msg_count,
2959 p_data => x_msg_data
2960 );
2961
2962 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2963 ROLLBACK TO Delete_Ozf_Prod_Line_PVT;
2964 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2965 -- Standard call to get message count and if count=1, get the message
2966 FND_MSG_PUB.Count_And_Get (
2967 p_encoded => FND_API.G_FALSE,
2968 p_count => x_msg_count,
2969 p_data => x_msg_data
2970 );
2971
2972 WHEN OTHERS THEN
2973 ROLLBACK TO Delete_Ozf_Prod_Line_PVT;
2974 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2975 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2976 THEN
2977 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2978 END IF;
2979 -- Standard call to get message count and if count=1, get the message
2980 FND_MSG_PUB.Count_And_Get (
2981 p_encoded => FND_API.G_FALSE,
2982 p_count => x_msg_count,
2983 p_data => x_msg_data
2984 );
2985 End Delete_Ozf_Prod_Line;
2986
2987
2988
2989 -- Hint: Primary key needs to be returned.
2990 --=========================End Product Line Methods ============================
2991 -- Hint: Primary key needs to be returned.
2992 -- ==============================================================================
2993 -- Start of Comments
2994 -- ==============================================================================
2995 -- API Name
2996 -- Lock_Prod_Reln
2997 -- Type
2998 -- Private
2999 -- Pre-Req
3000 --
3001 -- Parameters
3002 --
3003 -- IN
3004 -- p_api_version_number IN NUMBER Required
3005 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
3006 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
3007 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
3008 -- p_prod_reln_rec IN prod_reln_rec_type Required
3009 --
3010 -- OUT
3011 -- x_return_status OUT VARCHAR2
3012 -- x_msg_count OUT NUMBER
3013 -- x_msg_data OUT VARCHAR2
3014 -- Version : Current version 1.0
3015 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
3016 -- and basic operation, developer must manually add parameters and business logic as necessary.
3017 --
3018 -- History
3019 --
3020 -- NOTE
3021 --
3022 -- End of Comments
3023 -- ==============================================================================
3024
3025 PROCEDURE Lock_Prod_Reln(
3026 p_api_version_number IN NUMBER,
3027 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3028
3029 x_return_status OUT NOCOPY VARCHAR2,
3030 x_msg_count OUT NOCOPY NUMBER,
3031 x_msg_data OUT NOCOPY VARCHAR2,
3032
3033 p_discount_product_reln_id IN NUMBER,
3034 p_object_version IN NUMBER
3035 )
3036
3037 IS
3041 l_discount_product_reln_id NUMBER;
3038 L_API_NAME CONSTANT VARCHAR2(30) := 'Lock_Prod_Reln';
3039 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3040 L_FULL_NAME CONSTANT VARCHAR2(60) := g_pkg_name ||'.'|| l_api_name;
3042
3043 BEGIN
3044
3045 -- Debug Message
3046 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
3047
3048
3049 -- Initialize message list if p_init_msg_list is set to TRUE.
3050 IF FND_API.to_Boolean( p_init_msg_list )
3051 THEN
3052 FND_MSG_PUB.initialize;
3053 END IF;
3054
3055
3056
3057 -- Standard call to check for call compatibility.
3058 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
3059 p_api_version_number,
3060 l_api_name,
3061 G_PKG_NAME)
3062 THEN
3063 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3064 END IF;
3065
3066
3067
3068 -- Initialize API return status to SUCCESS
3069 x_return_status := FND_API.G_RET_STS_SUCCESS;
3070
3071
3072 ------------------------ lock -------------------------
3073 Ozf_Prod_Reln_Pkg.Lock_Row(l_discount_product_reln_id,p_object_version);
3074
3075
3076 -------------------- finish --------------------------
3077 FND_MSG_PUB.count_and_get(
3078 p_encoded => FND_API.g_false,
3079 p_count => x_msg_count,
3080 p_data => x_msg_data);
3081 OZF_Utility_PVT.debug_message(l_full_name ||': end');
3082 EXCEPTION
3083
3084 WHEN OZF_Utility_PVT.resource_locked THEN
3085 x_return_status := FND_API.g_ret_sts_error;
3086 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
3087
3088 WHEN FND_API.G_EXC_ERROR THEN
3089 ROLLBACK TO LOCK_Prod_Reln_PVT;
3090 x_return_status := FND_API.G_RET_STS_ERROR;
3091 -- Standard call to get message count and if count=1, get the message
3092 FND_MSG_PUB.Count_And_Get (
3093 p_encoded => FND_API.G_FALSE,
3094 p_count => x_msg_count,
3095 p_data => x_msg_data
3096 );
3097
3098 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3099 ROLLBACK TO LOCK_Prod_Reln_PVT;
3100 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3101 -- Standard call to get message count and if count=1, get the message
3102 FND_MSG_PUB.Count_And_Get (
3103 p_encoded => FND_API.G_FALSE,
3104 p_count => x_msg_count,
3105 p_data => x_msg_data
3106 );
3107
3108 WHEN OTHERS THEN
3109 ROLLBACK TO LOCK_Prod_Reln_PVT;
3110 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3111 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3112 THEN
3113 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
3114 END IF;
3115 -- Standard call to get message count and if count=1, get the message
3116 FND_MSG_PUB.Count_And_Get (
3117 p_encoded => FND_API.G_FALSE,
3118 p_count => x_msg_count,
3119 p_data => x_msg_data
3120 );
3121 End Lock_Prod_Reln;
3122
3123
3124 PROCEDURE check_Prod_Reln_Uk_Items(
3125 p_prod_reln_rec IN prod_reln_rec_type,
3126 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
3127 x_return_status OUT NOCOPY VARCHAR2)
3128 IS
3129 l_valid_flag VARCHAR2(10);
3130 BEGIN
3131 x_return_status := FND_API.g_ret_sts_success;
3132 IF p_validation_mode = JTF_PLSQL_API.g_create
3133 AND p_prod_reln_rec.discount_product_reln_id IS NOT NULL
3134 THEN
3135 IF OZF_Utility_PVT.check_uniqueness(
3136 'ozf_discount_product_reln',
3137 'discount_product_reln_id = ''' || p_prod_reln_rec.discount_product_reln_id ||''''
3138 ) = FND_API.g_false THEN
3139
3140 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_DISC_PROD_RELN_ID_DUP');
3141 x_return_status := FND_API.g_ret_sts_error;
3142 END IF;
3143 END IF;
3144 l_valid_flag := OZF_Utility_PVT.check_uniqueness('ozf_discount_product_reln'
3145 ,'offer_discount_line_id = '
3146 ||p_prod_reln_rec.offer_discount_line_id
3147 ||' AND off_discount_product_id = '
3148 ||p_prod_reln_rec.off_discount_product_id);
3149 IF l_valid_flag = FND_API.g_false THEN
3150 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_DISC_PROD_RELN_ID_DUP');
3154 END check_Prod_Reln_Uk_Items;
3151 x_return_status := FND_API.g_ret_sts_error; -- Correct Message
3152 END IF;
3153
3155
3156
3157
3158 PROCEDURE check_Prod_Reln_Req_Items(
3159 p_prod_reln_rec IN prod_reln_rec_type,
3160 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
3161 x_return_status OUT NOCOPY VARCHAR2
3162 )
3163 IS
3164 BEGIN
3165 x_return_status := FND_API.g_ret_sts_success;
3166
3167 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
3168
3169
3170 IF p_prod_reln_rec.discount_product_reln_id = FND_API.G_MISS_NUM OR p_prod_reln_rec.discount_product_reln_id IS NULL THEN
3171 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT_PRODUCT_RELN_ID' );
3172 x_return_status := FND_API.g_ret_sts_error;
3173 END IF;
3174
3175
3176 IF p_prod_reln_rec.offer_discount_line_id = FND_API.G_MISS_NUM OR p_prod_reln_rec.offer_discount_line_id IS NULL THEN
3177 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_DISCOUNT_LINE_ID' );
3178 x_return_status := FND_API.g_ret_sts_error;
3179 END IF;
3180
3181
3182 IF p_prod_reln_rec.off_discount_product_id = FND_API.G_MISS_NUM OR p_prod_reln_rec.off_discount_product_id IS NULL THEN
3183 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFF_DISCOUNT_PRODUCT_ID' );
3184 x_return_status := FND_API.g_ret_sts_error;
3185 END IF;
3186
3187
3188 ELSE
3189
3190
3191 IF p_prod_reln_rec.discount_product_reln_id = FND_API.G_MISS_NUM THEN
3192 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'DISCOUNT_PRODUCT_RELN_ID' );
3193 x_return_status := FND_API.g_ret_sts_error;
3194 END IF;
3195
3196
3197 IF p_prod_reln_rec.offer_discount_line_id = FND_API.G_MISS_NUM THEN
3198 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_DISCOUNT_LINE_ID' );
3199 x_return_status := FND_API.g_ret_sts_error;
3200 END IF;
3201
3202
3203 IF p_prod_reln_rec.off_discount_product_id = FND_API.G_MISS_NUM THEN
3204 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFF_DISCOUNT_PRODUCT_ID' );
3205 x_return_status := FND_API.g_ret_sts_error;
3206 END IF;
3207 END IF;
3208
3209 END check_Prod_Reln_Req_Items;
3210
3211
3212
3213 PROCEDURE check_Prod_Reln_Fk_Items(
3214 p_prod_reln_rec IN prod_reln_rec_type,
3215 x_return_status OUT NOCOPY VARCHAR2
3216 )
3217 IS
3218 BEGIN
3219 x_return_status := FND_API.g_ret_sts_success;
3220
3221 -- Enter custom code here
3222 IF p_prod_reln_rec.offer_discount_line_id <> -1 THEN
3223 IF ozf_utility_pvt.check_fk_exists('OZF_OFFER_DISCOUNT_LINES','OFFER_DISCOUNT_LINE_ID',to_char(p_prod_reln_rec.offer_discount_line_id)) = FND_API.g_false THEN
3224 OZF_Utility_PVT.Error_Message('OZF_PROD_RELN_FK_DUP' ); -- correct message
3225 x_return_status := FND_API.g_ret_sts_error;
3226 END IF;
3227 IF ozf_utility_pvt.check_fk_exists('OZF_OFFER_DISCOUNT_PRODUCTS','OFF_DISCOUNT_PRODUCT_ID',to_char(p_prod_reln_rec.off_discount_product_id)) = FND_API.g_false THEN
3228 OZF_Utility_PVT.Error_Message('Prod_ReL_FK_Dupliucate2' );--correct message
3229 x_return_status := FND_API.g_ret_sts_error;
3230 END IF;
3231 END IF;
3232
3233
3234 END check_Prod_Reln_Fk_Items;
3235
3236
3237
3238 PROCEDURE check_Prod_Reln_Lookup_Items(
3239 p_prod_reln_rec IN prod_reln_rec_type,
3240 x_return_status OUT NOCOPY VARCHAR2
3241 )
3242 IS
3243 BEGIN
3244 x_return_status := FND_API.g_ret_sts_success;
3245
3246 -- Enter custom code here
3247
3248 END check_Prod_Reln_Lookup_Items;
3249
3250
3251
3252 PROCEDURE Check_Prod_Reln_Items (
3253 P_prod_reln_rec IN prod_reln_rec_type,
3254 p_validation_mode IN VARCHAR2,
3255 x_return_status OUT NOCOPY VARCHAR2
3256 )
3257 IS
3258 l_return_status VARCHAR2(1);
3259 BEGIN
3260
3261 l_return_status := FND_API.g_ret_sts_success;
3262 -- Check Items Uniqueness API calls
3263
3264 check_Prod_reln_Uk_Items(
3265 p_prod_reln_rec => p_prod_reln_rec,
3266 p_validation_mode => p_validation_mode,
3267 x_return_status => x_return_status);
3268 IF x_return_status <> FND_API.g_ret_sts_success THEN
3269 l_return_status := FND_API.g_ret_sts_error;
3270 END IF;
3271
3272 -- Check Items Required/NOT NULL API calls
3273
3274 check_prod_reln_req_items(
3275 p_prod_reln_rec => p_prod_reln_rec,
3276 p_validation_mode => p_validation_mode,
3277 x_return_status => x_return_status);
3278 IF x_return_status <> FND_API.g_ret_sts_success THEN
3279 l_return_status := FND_API.g_ret_sts_error;
3280 END IF;
3281 -- Check Items Foreign Keys API calls
3282 check_prod_reln_FK_items(
3283 p_prod_reln_rec => p_prod_reln_rec,
3284 x_return_status => x_return_status);
3285 IF x_return_status <> FND_API.g_ret_sts_success THEN
3286 l_return_status := FND_API.g_ret_sts_error;
3287 END IF;
3288 -- Check Items Lookups
3289
3293 IF x_return_status <> FND_API.g_ret_sts_success THEN
3290 check_prod_reln_Lookup_items(
3291 p_prod_reln_rec => p_prod_reln_rec,
3292 x_return_status => x_return_status);
3294 l_return_status := FND_API.g_ret_sts_error;
3295 END IF;
3296
3297 x_return_status := l_return_status;
3298
3299 END Check_prod_reln_Items;
3300
3301
3302
3303
3304
3305 PROCEDURE Complete_Prod_Reln_Rec (
3306 p_prod_reln_rec IN prod_reln_rec_type,
3307 x_complete_rec OUT NOCOPY prod_reln_rec_type)
3308 IS
3309 l_return_status VARCHAR2(1);
3310
3311 CURSOR c_complete IS
3312 SELECT *
3313 FROM ozf_discount_product_reln
3314 WHERE discount_product_reln_id = p_prod_reln_rec.discount_product_reln_id;
3315 l_prod_reln_rec c_complete%ROWTYPE;
3316 BEGIN
3317 x_complete_rec := p_prod_reln_rec;
3318
3319
3320 OPEN c_complete;
3321 FETCH c_complete INTO l_prod_reln_rec;
3322 CLOSE c_complete;
3323
3324 -- discount_product_reln_id
3325 IF p_prod_reln_rec.discount_product_reln_id IS NULL THEN
3326 x_complete_rec.discount_product_reln_id := l_prod_reln_rec.discount_product_reln_id;
3327 END IF;
3328
3329 -- offer_discount_line_id
3330 IF p_prod_reln_rec.offer_discount_line_id IS NULL THEN
3331 x_complete_rec.offer_discount_line_id := l_prod_reln_rec.offer_discount_line_id;
3332 END IF;
3333
3334 -- off_discount_product_id
3335 IF p_prod_reln_rec.off_discount_product_id IS NULL THEN
3336 x_complete_rec.off_discount_product_id := l_prod_reln_rec.off_discount_product_id;
3337 END IF;
3338
3339 -- creation_date
3340 IF p_prod_reln_rec.creation_date IS NULL THEN
3341 x_complete_rec.creation_date := l_prod_reln_rec.creation_date;
3342 END IF;
3343
3344 -- created_by
3345 IF p_prod_reln_rec.created_by IS NULL THEN
3346 x_complete_rec.created_by := l_prod_reln_rec.created_by;
3347 END IF;
3348
3349 -- last_update_date
3350 IF p_prod_reln_rec.last_update_date IS NULL THEN
3351 x_complete_rec.last_update_date := l_prod_reln_rec.last_update_date;
3352 END IF;
3353
3354 -- last_updated_by
3355 IF p_prod_reln_rec.last_updated_by IS NULL THEN
3356 x_complete_rec.last_updated_by := l_prod_reln_rec.last_updated_by;
3357 END IF;
3358
3359 -- last_update_login
3360 IF p_prod_reln_rec.last_update_login IS NULL THEN
3361 x_complete_rec.last_update_login := l_prod_reln_rec.last_update_login;
3362 END IF;
3363
3364 -- object_version_number
3365 /* IF p_prod_reln_rec.object_version_number IS NULL THEN
3366 x_complete_rec.object_version_number := l_prod_reln_rec.object_version_number;
3367 END IF;
3368 */
3369 -- Note: Developers need to modify the procedure
3370 -- to handle any business specific requirements.
3371 END Complete_Prod_Reln_Rec;
3372
3373
3374
3375
3376 PROCEDURE Default_Prod_Reln_Items ( p_prod_reln_rec IN prod_reln_rec_type ,
3377 x_prod_reln_rec OUT NOCOPY prod_reln_rec_type )
3378 IS
3379 l_prod_reln_rec prod_reln_rec_type := p_prod_reln_rec;
3380 BEGIN
3381 -- Developers should put their code to default the record type
3382 -- e.g. IF p_campaign_rec.status_code IS NULL
3383 -- OR p_campaign_rec.status_code = FND_API.G_MISS_CHAR THEN
3384 -- l_campaign_rec.status_code := 'NEW' ;
3385 -- END IF ;
3386 --
3387 NULL ;
3388 END;
3389
3390 PROCEDURE Validate_Prod_Reln_Rec (
3391 p_api_version_number IN NUMBER,
3392 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3393 x_return_status OUT NOCOPY VARCHAR2,
3394 x_msg_count OUT NOCOPY NUMBER,
3395 x_msg_data OUT NOCOPY VARCHAR2,
3396 p_prod_reln_rec IN prod_reln_rec_type
3397 )
3398 IS
3399 BEGIN
3400 -- Initialize message list if p_init_msg_list is set to TRUE.
3401 IF FND_API.to_Boolean( p_init_msg_list )
3402 THEN
3403 FND_MSG_PUB.initialize;
3404 END IF;
3405
3406
3407
3408 -- Initialize API return status to SUCCESS
3409 x_return_status := FND_API.G_RET_STS_SUCCESS;
3410
3411 -- Hint: Validate data
3412 -- If data not valid
3413 -- THEN
3414 -- x_return_status := FND_API.G_RET_STS_ERROR;
3415
3416 -- Debug Message
3417 OZF_UTILITY_PVT.debug_message('Private API: Validate_dm_model_rec');
3418 -- Standard call to get message count and if count is 1, get message info.
3419 FND_MSG_PUB.Count_And_Get
3420 (p_count => x_msg_count,
3421 p_data => x_msg_data
3422 );
3423 END Validate_prod_reln_Rec;
3424
3425
3426
3427 PROCEDURE Validate_Prod_Reln(
3428 p_api_version_number IN NUMBER,
3429 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3430 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
3431 p_prod_reln_rec IN prod_reln_rec_type,
3432 p_validation_mode IN VARCHAR2,
3433 x_return_status OUT NOCOPY VARCHAR2,
3437 IS
3434 x_msg_count OUT NOCOPY NUMBER,
3435 x_msg_data OUT NOCOPY VARCHAR2
3436 )
3438 L_API_NAME CONSTANT VARCHAR2(30) := 'Validate_Prod_Reln';
3439 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3440 l_object_version_number NUMBER;
3441 l_prod_reln_rec prod_reln_rec_type;
3442
3443 BEGIN
3444 -- Standard Start of API savepoint
3445 SAVEPOINT validate_prod_reln_;
3446
3447 -- Standard call to check for call compatibility.
3448 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
3449 p_api_version_number,
3450 l_api_name,
3451 G_PKG_NAME)
3452 THEN
3453 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3454 END IF;
3455
3456
3457 -- Initialize message list if p_init_msg_list is set to TRUE.
3458 IF FND_API.to_Boolean( p_init_msg_list )
3459 THEN
3460 FND_MSG_PUB.initialize;
3461 END IF;
3462
3463 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
3464 Check_prod_reln_Items(
3465 p_prod_reln_rec => p_prod_reln_rec,
3466 p_validation_mode => p_validation_mode,
3467 x_return_status => x_return_status
3468 );
3469
3470 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3471 RAISE FND_API.G_EXC_ERROR;
3472 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3473 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3474 END IF;
3475 END IF;
3476
3477 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
3478 Default_Prod_Reln_Items (p_prod_reln_rec => p_prod_reln_rec ,
3479 x_prod_reln_rec => l_prod_reln_rec) ;
3480 END IF ;
3481
3482
3483 Complete_prod_reln_Rec(
3484 p_prod_reln_rec => l_prod_reln_rec,
3485 x_complete_rec => l_prod_reln_rec
3486 );
3487
3488 IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
3489 Validate_prod_reln_Rec(
3490 p_api_version_number => 1.0,
3491 p_init_msg_list => FND_API.G_FALSE,
3492 x_return_status => x_return_status,
3493 x_msg_count => x_msg_count,
3494 x_msg_data => x_msg_data,
3495 p_prod_reln_rec => l_prod_reln_rec);
3496
3497 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3498 RAISE FND_API.G_EXC_ERROR;
3499 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3500 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3501 END IF;
3502 END IF;
3503
3504
3505 -- Debug Message
3506 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
3507
3508
3509
3510 -- Initialize API return status to SUCCESS
3511 x_return_status := FND_API.G_RET_STS_SUCCESS;
3512
3513
3514 -- Debug Message
3515 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
3516
3517
3518 -- Standard call to get message count and if count is 1, get message info.
3519 FND_MSG_PUB.Count_And_Get
3520 (p_count => x_msg_count,
3521 p_data => x_msg_data
3522 );
3523 EXCEPTION
3524
3525 WHEN OZF_Utility_PVT.resource_locked THEN
3526 x_return_status := FND_API.g_ret_sts_error;
3527 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
3528
3529 WHEN FND_API.G_EXC_ERROR THEN
3530 ROLLBACK TO VALIDATE_Prod_Reln_;
3531 x_return_status := FND_API.G_RET_STS_ERROR;
3532 -- Standard call to get message count and if count=1, get the message
3533 FND_MSG_PUB.Count_And_Get (
3534 p_encoded => FND_API.G_FALSE,
3535 p_count => x_msg_count,
3536 p_data => x_msg_data
3537 );
3538
3539 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3543 FND_MSG_PUB.Count_And_Get (
3540 ROLLBACK TO VALIDATE_Prod_Reln_;
3541 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3542 -- Standard call to get message count and if count=1, get the message
3544 p_encoded => FND_API.G_FALSE,
3545 p_count => x_msg_count,
3546 p_data => x_msg_data
3547 );
3548
3549 WHEN OTHERS THEN
3550 ROLLBACK TO VALIDATE_Prod_Reln_;
3551 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3552 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3553 THEN
3554 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
3555 END IF;
3556 -- Standard call to get message count and if count=1, get the message
3557 FND_MSG_PUB.Count_And_Get (
3558 p_encoded => FND_API.G_FALSE,
3559 p_count => x_msg_count,
3560 p_data => x_msg_data
3561 );
3562 End Validate_Prod_Reln;
3563
3564
3565
3566
3567 --=======================Begin Product Discount Relation methods ==============
3568 -- Hint: Primary key needs to be returned.
3569 -- ==============================================================================
3570 -- Start of Comments
3571 -- ==============================================================================
3572 -- API Name
3573 -- Create_Prod_Reln
3574 -- Type
3575 -- Private
3576 -- Pre-Req
3577 --
3578 -- Parameters
3579 --
3580 -- IN
3581 -- p_api_version_number IN NUMBER Required
3582 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
3583 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
3584 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
3585 -- p_prod_reln_rec IN prod_reln_rec_type Required
3586 --
3587 -- OUT
3588 -- x_return_status OUT VARCHAR2
3589 -- x_msg_count OUT NUMBER
3590 -- x_msg_data OUT VARCHAR2
3591 -- Version : Current version 1.0
3592 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
3593 -- and basic operation, developer must manually add parameters and business logic as necessary.
3594 --
3595 -- History
3596 --
3597 -- NOTE
3598 --
3599 -- End of Comments
3600 -- ==============================================================================
3601
3602 PROCEDURE Create_Prod_Reln(
3603 p_api_version_number IN NUMBER,
3604 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3605 p_commit IN VARCHAR2 := FND_API.G_FALSE,
3606 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
3607
3608 x_return_status OUT NOCOPY VARCHAR2,
3609 x_msg_count OUT NOCOPY NUMBER,
3610 x_msg_data OUT NOCOPY VARCHAR2,
3611
3612 p_prod_reln_rec IN prod_reln_rec_type := g_miss_prod_reln_rec,
3613 x_discount_product_reln_id OUT NOCOPY NUMBER
3614 )
3615
3616 IS
3617 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Prod_Reln';
3618 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3619 l_return_status_full VARCHAR2(1);
3620 l_object_version_number NUMBER := 1;
3621 l_org_id NUMBER := FND_API.G_MISS_NUM;
3622 l_discount_product_reln_id NUMBER;
3623 l_dummy NUMBER;
3624 l_prod_reln_rec prod_reln_rec_type := g_miss_prod_reln_rec;
3625
3629
3626 CURSOR c_id IS
3627 SELECT ozf_discount_product_reln_s.NEXTVAL
3628 FROM dual;
3630 CURSOR c_id_exists (l_id IN NUMBER) IS
3631 SELECT 1
3632 FROM OZF_DISCOUNT_PRODUCT_RELN
3633 WHERE discount_product_reln_id = l_id;
3634 BEGIN
3635 -- Standard Start of API savepoint
3636 SAVEPOINT create_prod_reln_pvt;
3637
3638 -- Standard call to check for call compatibility.
3639 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
3640 p_api_version_number,
3641 l_api_name,
3642 G_PKG_NAME)
3643 THEN
3644 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3645 END IF;
3646
3647
3648 -- Initialize message list if p_init_msg_list is set to TRUE.
3649 IF FND_API.to_Boolean( p_init_msg_list )
3650 THEN
3651 FND_MSG_PUB.initialize;
3652 END IF;
3653
3654
3655
3656 -- Debug Message
3657 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
3658
3659
3660
3661 -- Initialize API return status to SUCCESS
3662 x_return_status := FND_API.G_RET_STS_SUCCESS;
3663
3664 -- =========================================================================
3665 -- Validate Environment
3666 -- =========================================================================
3667
3668 IF FND_GLOBAL.USER_ID IS NULL
3669 THEN
3670 OZF_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
3671 RAISE FND_API.G_EXC_ERROR;
3672 END IF;
3673
3674
3675
3676
3677 -- Local variable initialization
3678
3679 IF p_prod_reln_rec.discount_product_reln_id IS NULL OR p_prod_reln_rec.discount_product_reln_id = FND_API.g_miss_num THEN
3680 LOOP
3681 l_dummy := NULL;
3682 OPEN c_id;
3683 FETCH c_id INTO l_discount_product_reln_id;
3684 CLOSE c_id;
3685
3686 OPEN c_id_exists(l_discount_product_reln_id);
3687 FETCH c_id_exists INTO l_dummy;
3688 CLOSE c_id_exists;
3689 EXIT WHEN l_dummy IS NULL;
3690 END LOOP;
3691 ELSE
3692 l_discount_product_reln_id := p_prod_reln_rec.discount_product_reln_id;
3693 END IF;
3694
3695 l_prod_reln_rec := p_prod_reln_rec;
3696 l_prod_reln_rec.discount_product_reln_id := l_discount_product_reln_id;
3697
3698 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
3699 THEN
3700 -- Debug message
3701 OZF_UTILITY_PVT.debug_message('Private API: Validate_Prod_Reln');
3702 -- Invoke validation procedures
3703 Validate_prod_reln(
3704 p_api_version_number => 1.0,
3705 p_init_msg_list => FND_API.G_FALSE,
3706 p_validation_level => p_validation_level,
3707 p_validation_mode => JTF_PLSQL_API.g_create,
3708 p_prod_reln_rec => l_prod_reln_rec,
3712 END IF;
3709 x_return_status => x_return_status,
3710 x_msg_count => x_msg_count,
3711 x_msg_data => x_msg_data);
3713
3714 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
3715 RAISE FND_API.G_EXC_ERROR;
3716 END IF;
3717
3718 -- Debug Message
3719 OZF_UTILITY_PVT.debug_message( 'Private API: Calling create table handler');
3720
3721 -- Invoke table handler(Ozf_Prod_Reln_Pkg.Insert_Row)
3722 Ozf_Prod_Reln_Pkg.Insert_Row(
3723 px_discount_product_reln_id => l_discount_product_reln_id,
3724 p_offer_discount_line_id => l_prod_reln_rec.offer_discount_line_id,
3725 p_off_discount_product_id => l_prod_reln_rec.off_discount_product_id,
3726 p_creation_date => SYSDATE,
3727 p_created_by => FND_GLOBAL.USER_ID,
3728 p_last_update_date => SYSDATE,
3729 p_last_updated_by => FND_GLOBAL.USER_ID,
3730 p_last_update_login => FND_GLOBAL.conc_login_id,
3731 px_object_version_number => l_object_version_number
3732 );
3733
3734 x_discount_product_reln_id := l_discount_product_reln_id;
3735 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3736 RAISE FND_API.G_EXC_ERROR;
3737 END IF;
3738 --
3739 -- End of API body
3740 --
3741
3742 -- Standard check for p_commit
3743 IF FND_API.to_Boolean( p_commit )
3744 THEN
3745 COMMIT WORK;
3746 END IF;
3747
3748
3749 -- Debug Message
3750 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
3751
3752
3753 -- Standard call to get message count and if count is 1, get message info.
3754 FND_MSG_PUB.Count_And_Get
3755 (p_count => x_msg_count,
3756 p_data => x_msg_data
3757 );
3758 EXCEPTION
3759
3760 WHEN OZF_Utility_PVT.resource_locked THEN
3761 x_return_status := FND_API.g_ret_sts_error;
3762 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
3763
3764 WHEN FND_API.G_EXC_ERROR THEN
3765 ROLLBACK TO CREATE_Prod_Reln_PVT;
3766 x_return_status := FND_API.G_RET_STS_ERROR;
3767 -- Standard call to get message count and if count=1, get the message
3768 FND_MSG_PUB.Count_And_Get (
3769 p_encoded => FND_API.G_FALSE,
3770 p_count => x_msg_count,
3771 p_data => x_msg_data
3772 );
3773
3774 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3775 ROLLBACK TO CREATE_Prod_Reln_PVT;
3776 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3777 -- Standard call to get message count and if count=1, get the message
3778 FND_MSG_PUB.Count_And_Get (
3779 p_encoded => FND_API.G_FALSE,
3780 p_count => x_msg_count,
3781 p_data => x_msg_data
3782 );
3783
3787 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3784 WHEN OTHERS THEN
3785 ROLLBACK TO CREATE_Prod_Reln_PVT;
3786 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3788 THEN
3789 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
3790 END IF;
3791 -- Standard call to get message count and if count=1, get the message
3792 FND_MSG_PUB.Count_And_Get (
3793 p_encoded => FND_API.G_FALSE,
3794 p_count => x_msg_count,
3795 p_data => x_msg_data
3796 );
3797 End Create_Prod_Reln;
3798
3799
3800 -- ==============================================================================
3801 -- Start of Comments
3802 -- ==============================================================================
3803 -- API Name
3804 -- Update_Prod_Reln
3805 -- Type
3806 -- Private
3807 -- Pre-Req
3808 --
3809 -- Parameters
3810 --
3811 -- IN
3812 -- p_api_version_number IN NUMBER Required
3813 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
3814 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
3815 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
3816 -- p_prod_reln_rec IN prod_reln_rec_type Required
3817 --
3818 -- OUT
3819 -- x_return_status OUT VARCHAR2
3820 -- x_msg_count OUT NUMBER
3821 -- x_msg_data OUT VARCHAR2
3822 -- Version : Current version 1.0
3823 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
3824 -- and basic operation, developer must manually add parameters and business logic as necessary.
3825 --
3826 -- History
3827 --
3828 -- NOTE
3829 --
3830 -- End of Comments
3831 -- ==============================================================================
3832
3833 PROCEDURE Update_Prod_Reln(
3834 p_api_version_number IN NUMBER,
3835 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3836 p_commit IN VARCHAR2 := FND_API.G_FALSE,
3837 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
3838
3839 x_return_status OUT NOCOPY VARCHAR2,
3840 x_msg_count OUT NOCOPY NUMBER,
3841 x_msg_data OUT NOCOPY VARCHAR2,
3842
3843 p_prod_reln_rec IN prod_reln_rec_type
3844 )
3845
3846 IS
3847
3848
3849 CURSOR c_get_prod_reln(discount_product_reln_id NUMBER) IS
3850 SELECT *
3851 FROM OZF_DISCOUNT_PRODUCT_RELN
3852 WHERE discount_product_reln_id = p_prod_reln_rec.discount_product_reln_id;
3853 -- Hint: Developer need to provide Where clause
3854
3855
3856 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_Prod_Reln';
3857 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3858 -- Local Variables
3859 l_object_version_number NUMBER;
3860 l_discount_product_reln_id NUMBER;
3861 l_ref_prod_reln_rec c_get_Prod_Reln%ROWTYPE ;
3862 l_tar_prod_reln_rec prod_reln_rec_type := P_prod_reln_rec;
3863 l_rowid ROWID;
3864
3865 BEGIN
3866 -- Standard Start of API savepoint
3867 SAVEPOINT update_prod_reln_pvt;
3868
3869 -- Standard call to check for call compatibility.
3870 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
3874 THEN
3871 p_api_version_number,
3872 l_api_name,
3873 G_PKG_NAME)
3875 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3876 END IF;
3877
3878
3879 -- Initialize message list if p_init_msg_list is set to TRUE.
3880 IF FND_API.to_Boolean( p_init_msg_list )
3881 THEN
3882 FND_MSG_PUB.initialize;
3883 END IF;
3884
3885
3886
3887 -- Debug Message
3888 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
3889
3890
3891
3892 -- Initialize API return status to SUCCESS
3893 x_return_status := FND_API.G_RET_STS_SUCCESS;
3894
3895 -- Debug Message
3896 OZF_UTILITY_PVT.debug_message('Private API: - Open Cursor to Select');
3897
3898 OPEN c_get_Prod_Reln( l_tar_prod_reln_rec.discount_product_reln_id);
3899
3900 FETCH c_get_Prod_Reln INTO l_ref_prod_reln_rec ;
3901
3902 If ( c_get_Prod_Reln%NOTFOUND) THEN
3903 OZF_Utility_PVT.Error_Message(p_message_name => 'API_MISSING_UPDATE_TARGET',
3904 p_token_name => 'INFO',
3905 p_token_value => 'Prod_Reln') ;
3906 RAISE FND_API.G_EXC_ERROR;
3907 END IF;
3908 -- Debug Message
3909 OZF_UTILITY_PVT.debug_message('Private API: - Close Cursor');
3910 CLOSE c_get_Prod_Reln;
3911
3912
3913 /* If (l_tar_prod_reln_rec.object_version_number is NULL or
3914 l_tar_prod_reln_rec.object_version_number = FND_API.G_MISS_NUM ) Then
3915 OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
3916 p_token_name => 'COLUMN',
3917 p_token_value => 'Last_Update_Date') ;
3918 raise FND_API.G_EXC_ERROR;
3919 End if;
3920 -- Check Whether record has been changed by someone else
3921 If (l_tar_prod_reln_rec.object_version_number <> l_ref_prod_reln_rec.object_version_number) Then
3922 OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
3923 p_token_name => 'INFO',
3924 p_token_value => 'Prod_Reln') ;
3925 raise FND_API.G_EXC_ERROR;
3926 End if;
3927 */
3928
3929 IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
3930 THEN
3931 -- Debug message
3932 OZF_UTILITY_PVT.debug_message('Private API: Validate_Prod_Reln');
3933
3934 -- Invoke validation procedures
3935 Validate_prod_reln(
3936 p_api_version_number => 1.0,
3937 p_init_msg_list => FND_API.G_FALSE,
3938 p_validation_level => p_validation_level,
3939 p_validation_mode => JTF_PLSQL_API.g_update,
3940 p_prod_reln_rec => p_prod_reln_rec,
3941 x_return_status => x_return_status,
3942 x_msg_count => x_msg_count,
3943 x_msg_data => x_msg_data);
3944 END IF;
3945
3946 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
3947 RAISE FND_API.G_EXC_ERROR;
3948 END IF;
3949
3950
3951 -- Debug Message
3952 -- OZF_UTILITY_PVT.debug_message(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW, 'Private API: Calling update table handler');
3953
3954 -- Invoke table handler(Ozf_Prod_Reln_Pkg.Update_Row)
3955 Ozf_Prod_Reln_Pkg.Update_Row(
3956 p_discount_product_reln_id => p_prod_reln_rec.discount_product_reln_id,
3957 p_offer_discount_line_id => p_prod_reln_rec.offer_discount_line_id,
3958 p_off_discount_product_id => p_prod_reln_rec.off_discount_product_id,
3959 p_last_update_date => SYSDATE,
3960 p_last_updated_by => FND_GLOBAL.USER_ID,
3961 p_last_update_login => FND_GLOBAL.conc_login_id,
3962 p_object_version_number => p_prod_reln_rec.object_version_number
3963 );
3964 --
3965 -- End of API body.
3966 --
3967
3968 -- Standard check for p_commit
3969 IF FND_API.to_Boolean( p_commit )
3970 THEN
3971 COMMIT WORK;
3972 END IF;
3973
3974
3975 -- Debug Message
3976 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
3977
3978
3979 -- Standard call to get message count and if count is 1, get message info.
3980 FND_MSG_PUB.Count_And_Get
3981 (p_count => x_msg_count,
3982 p_data => x_msg_data
3983 );
3984 EXCEPTION
3985
3986 WHEN OZF_Utility_PVT.resource_locked THEN
3987 x_return_status := FND_API.g_ret_sts_error;
3988 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
3989
3990 WHEN FND_API.G_EXC_ERROR THEN
3991 ROLLBACK TO UPDATE_Prod_Reln_PVT;
3992 x_return_status := FND_API.G_RET_STS_ERROR;
3993 -- Standard call to get message count and if count=1, get the message
3994 FND_MSG_PUB.Count_And_Get (
3995 p_encoded => FND_API.G_FALSE,
3996 p_count => x_msg_count,
3997 p_data => x_msg_data
3998 );
3999
4000 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4001 ROLLBACK TO UPDATE_Prod_Reln_PVT;
4002 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4006 p_count => x_msg_count,
4003 -- Standard call to get message count and if count=1, get the message
4004 FND_MSG_PUB.Count_And_Get (
4005 p_encoded => FND_API.G_FALSE,
4007 p_data => x_msg_data
4008 );
4009
4010 WHEN OTHERS THEN
4011 ROLLBACK TO UPDATE_Prod_Reln_PVT;
4012 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4013 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4014 THEN
4015 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4016 END IF;
4017 -- Standard call to get message count and if count=1, get the message
4018 FND_MSG_PUB.Count_And_Get (
4019 p_encoded => FND_API.G_FALSE,
4020 p_count => x_msg_count,
4021 p_data => x_msg_data
4022 );
4023 End Update_Prod_Reln;
4024
4025
4026 -- ==============================================================================
4027 -- Start of Comments
4028 -- ==============================================================================
4029 -- API Name
4030 -- Delete_Prod_Reln
4031 -- Type
4032 -- Private
4033 -- Pre-Req
4034 --
4035 -- Parameters
4036 --
4037 -- IN
4038 -- p_api_version_number IN NUMBER Required
4039 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
4040 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
4041 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
4042 -- p_discount_product_reln_id IN NUMBER
4043 -- p_object_version_number IN NUMBER Optional Default = NULL
4044 --
4045 -- OUT
4046 -- x_return_status OUT VARCHAR2
4047 -- x_msg_count OUT NUMBER
4048 -- x_msg_data OUT VARCHAR2
4049 -- Version : Current version 1.0
4050 -- Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
4051 -- and basic operation, developer must manually add parameters and business logic as necessary.
4052 --
4053 -- History
4054 --
4055 -- NOTE
4056 --
4057 -- End of Comments
4058 -- ==============================================================================
4059
4060 PROCEDURE Delete_Prod_Reln(
4061 p_api_version_number IN NUMBER,
4062 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4063 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4064 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4065 x_return_status OUT NOCOPY VARCHAR2,
4066 x_msg_count OUT NOCOPY NUMBER,
4067 x_msg_data OUT NOCOPY VARCHAR2,
4068 p_discount_product_reln_id IN NUMBER,
4069 p_object_version_number IN NUMBER
4070 )
4071
4072 IS
4073 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Prod_Reln';
4074 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4075 l_object_version_number NUMBER;
4076
4077 BEGIN
4078 -- Standard Start of API savepoint
4079 SAVEPOINT delete_prod_reln_pvt;
4080
4081 -- Standard call to check for call compatibility.
4082 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
4083 p_api_version_number,
4084 l_api_name,
4085 G_PKG_NAME)
4086 THEN
4087 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4088 END IF;
4089
4090
4091 -- Initialize message list if p_init_msg_list is set to TRUE.
4092 IF FND_API.to_Boolean( p_init_msg_list )
4093 THEN
4094 FND_MSG_PUB.initialize;
4095 END IF;
4096
4097
4098
4099 -- Debug Message
4100 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4101
4102
4103
4104 -- Initialize API return status to SUCCESS
4105 x_return_status := FND_API.G_RET_STS_SUCCESS;
4106
4107 --
4108 -- Api body
4109 --
4110 -- Debug Message
4111 OZF_UTILITY_PVT.debug_message( 'Private API: Calling delete table handler');
4112
4113 -- Invoke table handler(Ozf_Prod_Reln_Pkg.Delete_Row)
4114 Ozf_Prod_Reln_Pkg.Delete_Row(
4115 p_discount_product_reln_id => p_discount_product_reln_id,
4116 p_object_version_number => p_object_version_number );
4117 --
4118 -- End of API body
4119 --
4120
4121 -- Standard check for p_commit
4122 IF FND_API.to_Boolean( p_commit )
4123 THEN
4124 COMMIT WORK;
4125 END IF;
4126
4127
4128 -- Debug Message
4129 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
4130
4131
4135 p_data => x_msg_data
4132 -- Standard call to get message count and if count is 1, get message info.
4133 FND_MSG_PUB.Count_And_Get
4134 (p_count => x_msg_count,
4136 );
4137 EXCEPTION
4138
4139 WHEN OZF_Utility_PVT.resource_locked THEN
4140 x_return_status := FND_API.g_ret_sts_error;
4141 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
4142
4143 WHEN FND_API.G_EXC_ERROR THEN
4144 ROLLBACK TO DELETE_Prod_Reln_PVT;
4145 x_return_status := FND_API.G_RET_STS_ERROR;
4146 -- Standard call to get message count and if count=1, get the message
4147 FND_MSG_PUB.Count_And_Get (
4148 p_encoded => FND_API.G_FALSE,
4149 p_count => x_msg_count,
4150 p_data => x_msg_data
4151 );
4152
4153 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4154 ROLLBACK TO DELETE_Prod_Reln_PVT;
4155 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4156 -- Standard call to get message count and if count=1, get the message
4157 FND_MSG_PUB.Count_And_Get (
4158 p_encoded => FND_API.G_FALSE,
4159 p_count => x_msg_count,
4160 p_data => x_msg_data
4161 );
4162
4163 WHEN OTHERS THEN
4164 ROLLBACK TO DELETE_Prod_Reln_PVT;
4165 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4166 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4167 THEN
4168 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4169 END IF;
4170 -- Standard call to get message count and if count=1, get the message
4171 FND_MSG_PUB.Count_And_Get (
4172 p_encoded => FND_API.G_FALSE,
4173 p_count => x_msg_count,
4174 p_data => x_msg_data
4175 );
4176 End Delete_Prod_Reln;
4177
4178
4179
4180 --=================End Product Discount relation methods =================================
4181
4182 --=================Begin Complete methods ================================================
4183
4184 PROCEDURE check_off_disc_prod(x_return_status IN OUT NOCOPY VARCHAR2
4185 , p_ozf_prod_rec IN ozf_prod_rec_type := g_miss_ozf_prod_rec
4186 )
4187 IS
4188 CURSOR C_SQL (p_offer_id NUMBER, p_offer_discount_line_id NUMBER) IS
4189 SELECT 1 FROM dual WHERE EXISTS
4190 (
4191 SELECT 1 FROM OZF_OFFER_DISCOUNT_LINES
4192 WHERE offer_id = p_offer_id
4193 AND offer_discount_line_id = p_offer_discount_line_id
4194 );
4195 l_count NUMBER:= 0;
4196 BEGIN
4197 --ozf_utility_pvt.debug_message('COunt is : '||l_count);
4198 IF p_ozf_prod_rec.offer_discount_line_id <> -1 THEN -- If creating complete disount line
4199 OPEN C_SQL( p_ozf_prod_rec.offer_id,p_ozf_prod_rec.offer_discount_line_id);
4200 fetch c_sql INTO l_count;
4201 CLOSE C_SQL;
4202
4203 IF l_count = 0 THEN
4204 x_return_status := FND_API.g_ret_sts_error;
4205 ELSE
4206 x_return_status := FND_API.G_RET_STS_SUCCESS;
4207 END IF;
4208
4209 ELSE -- if creating just prooducts
4210 x_return_status := FND_API.G_RET_STS_SUCCESS;
4211 END IF;
4212 END check_off_disc_prod;
4213
4214 -- ==============================================================================
4215 -- Start of Comments
4216 -- ==============================================================================
4217 -- API Name
4218 -- Create_Product
4219 -- Type
4220 -- Private
4221 -- Pre-Req
4222 -- Create_Ozf_Prod_Line,check_off_disc_prod,Create_Prod_Reln
4223 -- Parameters
4224 --
4225 -- IN
4226 -- p_api_version_number IN NUMBER Required
4227 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
4228 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
4229 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
4230 -- p_ozf_prod_rec IN ozf_prod_rec_type Required
4231 --
4232 -- OUT
4233 -- x_return_status OUT VARCHAR2
4234 -- x_msg_count OUT NUMBER
4235 -- x_msg_data OUT VARCHAR2
4236 -- x_off_discount_product_id OUT NUMBER
4237 -- Version : Current version 1.0
4238 --
4239 -- History
4240 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
4241 --
4242 -- Description
4243 -- : Helper method to create Products for Discount Lines.
4244 -- Does the following validations
4245 -- 1)If offer_discount_line_id should be a valid offer_discount_line_id for the same offer
4246 -- End of Comments
4247 -- ==============================================================================
4248
4249 PROCEDURE Create_Product
4250 (
4251 p_api_version_number IN NUMBER,
4252 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4253 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4254 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4255
4256 x_return_status OUT NOCOPY VARCHAR2,
4257 x_msg_count OUT NOCOPY NUMBER,
4261 x_off_discount_product_id OUT NOCOPY NUMBER
4258 x_msg_data OUT NOCOPY VARCHAR2,
4259
4260 p_ozf_prod_rec IN ozf_prod_rec_type := g_miss_ozf_prod_rec,
4262 )
4263 IS
4264 l_api_name CONSTANT VARCHAR2(30) := 'Create_Product';
4265 l_api_version_number CONSTANT NUMBER := 1.0;
4266
4267 -- l_return_status VARCHAR2(30);
4268 l_msg_count NUMBER;
4269 l_msg_data VARCHAR2(2000);
4270 l_off_discount_product_id NUMBER;
4271 l_prod_reln_id NUMBER;
4272 l_prod_reln_rec prod_reln_rec_type ;
4273
4274 BEGIN
4275 SAVEPOINT Create_Product_Pvt;
4276
4277 -- Standard call to check for call compatibility.
4278 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
4279 p_api_version_number,
4280 l_api_name,
4281 G_PKG_NAME)
4282 THEN
4283 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4284 END IF;
4285
4286
4287 -- Initialize message list if p_init_msg_list is set to TRUE.
4288 IF FND_API.to_Boolean( p_init_msg_list )
4289 THEN
4290 FND_MSG_PUB.initialize;
4291 END IF;
4292
4293
4294 -- Debug Message
4295 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4296
4297 -- Initialize API return status to SUCCESS
4298 x_return_status := FND_API.G_RET_STS_SUCCESS;
4299
4300
4301 check_off_disc_prod(x_return_status => x_return_status
4302 , p_ozf_prod_rec => p_ozf_prod_rec
4303 );
4304
4305 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4306 OZF_Utility_PVT.Error_Message('INVALID OFFER_ID:DISCOUNT ID' );-- CHANGE MESSAGE
4307 RAISE FND_API.G_EXC_ERROR;
4308 END IF;
4309
4310
4311 Create_Ozf_Prod_Line(
4312 p_api_version_number => p_api_version_number,
4313 p_init_msg_list => p_init_msg_list,
4314 p_commit => p_commit,
4315 p_validation_level => p_validation_level,
4316
4317 x_return_status => x_return_status,
4318 x_msg_count => l_msg_count,
4319 x_msg_data => l_msg_data,
4320
4321 p_ozf_prod_rec => p_ozf_prod_rec,
4322 x_off_discount_product_id => l_off_discount_product_id
4323 );
4324 l_prod_reln_rec.offer_discount_line_id := p_ozf_prod_rec.offer_discount_line_id;
4325 l_prod_reln_rec.off_discount_product_id := l_off_discount_product_id;
4326
4327 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4328 RAISE FND_API.G_EXC_ERROR;
4329 END IF;
4330
4331 Create_Prod_Reln(
4332 p_api_version_number => p_api_version_number,
4333 p_init_msg_list => p_init_msg_list,
4334 p_commit => p_commit,
4335 p_validation_level => p_validation_level,
4336
4337 x_return_status => x_return_status,
4338 x_msg_count => l_msg_count,
4339 x_msg_data => l_msg_data,
4340
4341 p_prod_reln_rec => l_prod_reln_rec,
4342 x_discount_product_reln_id => l_prod_reln_id
4343 );
4344
4345 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4346 RAISE FND_API.G_EXC_ERROR;
4347 END IF;
4348
4349 x_off_discount_product_id := l_off_discount_product_id;
4350 EXCEPTION
4351 WHEN FND_API.G_EXC_ERROR THEN
4352 ROLLBACK TO Create_Product_pvt;
4353 x_return_status := FND_API.G_RET_STS_ERROR;
4354 -- Standard call to get message count and if count=1, get the message
4355 FND_MSG_PUB.Count_And_Get (
4356 p_encoded => FND_API.G_FALSE,
4357 p_count => l_msg_count,
4358 p_data => l_msg_data
4359 );
4360
4361 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4362 ROLLBACK TO Create_Product_pvt;
4363 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4364 -- Standard call to get message count and if count=1, get the message
4365 FND_MSG_PUB.Count_And_Get (
4366 p_encoded => FND_API.G_FALSE,
4367 p_count => l_msg_count,
4368 p_data => l_msg_data
4369 );
4370
4371 WHEN OTHERS THEN
4372 ROLLBACK TO Create_Product_pvt;
4373 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4374 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4375 THEN
4376 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4377 END IF;
4378 -- Standard call to get message count and if count=1, get the message
4379 FND_MSG_PUB.Count_And_Get (
4380 p_encoded => FND_API.G_FALSE,
4381 p_count => l_msg_count,
4382 p_data => l_msg_data
4383 );
4384 END Create_Product;
4385
4386 -- ==============================================================================
4387 -- Start of Comments
4391 -- Type
4388 -- ==============================================================================
4389 -- API Name
4390 -- Create_offer_Line
4392 -- Private
4393 -- Pre-Req
4394 -- Create_Ozf_Disc_Line,Create Product
4395 -- Parameters
4396 --
4397 -- IN
4398 -- p_api_version_number IN NUMBER Required
4399 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
4400 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
4401 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
4402 -- p_ozf_offer_line_rec IN ozf_offer_line_rec_type Required Record containing Discount Line Data
4403 -- p_ozf_prod_rec IN ozf_prod_rec_type Required Record containing Product Data
4404 -- OUT
4405 -- x_return_status OUT VARCHAR2
4406 -- x_msg_count OUT NUMBER
4407 -- x_msg_data OUT VARCHAR2
4408 -- x_offer_discount_line_id OUT NUMBER. Discount Line Id of Discount Line Created
4409 -- Version : Current version 1.0
4410 --
4411 -- History
4412 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
4413 --
4414 -- Description
4415 -- : Method to Create New Discount Lines.
4416 -- End of Comments
4417 -- ==============================================================================
4418
4419 PROCEDURE Create_offer_line(
4420 p_api_version_number IN NUMBER,
4421 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4422 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4423 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4424
4425 x_return_status OUT NOCOPY VARCHAR2,
4426 x_msg_count OUT NOCOPY NUMBER,
4427 x_msg_data OUT NOCOPY VARCHAR2,
4428
4429 p_ozf_offer_line_rec IN ozf_offer_line_rec_type ,
4430 p_ozf_prod_rec IN ozf_prod_rec_type ,
4431 -- p_prod_reln_rec IN prod_reln_rec_type := g_miss_prod_reln_rec,
4432 x_offer_discount_line_id OUT NOCOPY NUMBER
4433 )
4434 IS
4435 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_offer_line';
4436 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4437
4438 l_offer_discount_line_id NUMBER ;
4439 l_off_dicount_product_id NUMBER;
4440 l_discount_product_reln_id NUMBER;
4441
4442 l_ozf_offer_line_rec ozf_offer_line_rec_type := g_miss_ozf_offer_line_rec;
4443 l_ozf_prod_rec ozf_prod_rec_type := g_miss_ozf_prod_rec;
4444 l_prod_reln_rec prod_reln_rec_type := g_miss_prod_reln_rec;
4445
4446 l_return_status VARCHAR2(30);
4447 l_msg_count NUMBER;
4448 l_msg_data VARCHAR2(2000);
4449
4450 BEGIN
4451 SAVEPOINT Create_offer_line_pvt;
4452 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4453
4454 -- Standard call to check for call compatibility.
4455 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
4456 p_api_version_number,
4457 l_api_name,
4458 G_PKG_NAME)
4459 THEN
4460 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4461 END IF;
4462
4463
4464 -- Initialize message list if p_init_msg_list is set to TRUE.
4465 IF FND_API.to_Boolean( p_init_msg_list )
4466 THEN
4467 FND_MSG_PUB.initialize;
4468 END IF;
4469
4470
4471
4472 -- Debug Message
4473 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4474
4475
4476
4477 -- Initialize API return status to SUCCESS
4478 x_return_status := FND_API.G_RET_STS_SUCCESS;
4479 Create_Ozf_Disc_Line(
4480 p_api_version_number => p_api_version_number,
4481 p_init_msg_list => p_init_msg_list,
4482 p_commit => p_commit,
4483 p_validation_level => p_validation_level,
4484 x_return_status => l_return_status,
4485 x_msg_count => l_msg_count,
4486 x_msg_data => l_msg_data,
4487 p_ozf_offer_line_rec =>p_ozf_offer_line_rec,
4488 x_offer_discount_line_id => l_offer_discount_line_id
4489 );
4490 l_ozf_prod_rec := p_ozf_prod_rec;
4491
4492 l_ozf_prod_rec.offer_discount_line_id := l_offer_discount_line_id;
4493
4494 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4495 RAISE FND_API.G_EXC_ERROR;
4496 END IF;
4497 Create_Product
4498 (
4499 p_api_version_number => p_api_version_number,
4500 p_init_msg_list => p_init_msg_list,
4501 p_commit => p_commit,
4502 p_validation_level => p_validation_level,
4503 x_return_status => x_return_status,
4504 x_msg_count => l_msg_count,
4505 x_msg_data => l_msg_data,
4506 p_ozf_prod_rec => l_ozf_prod_rec,
4507 x_off_discount_product_id => l_off_dicount_product_id
4508 );
4509
4510 --ozf_utility_pvt.debug_message('@ Done calling Create Reln, Reln Id is '||l_discount_product_reln_id);
4514 END IF;
4511
4512 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4513 RAISE FND_API.G_EXC_ERROR;
4515
4516 IF FND_API.to_Boolean( p_commit )
4517 THEN
4518 COMMIT WORK;
4519 END IF;
4520
4521
4522 -- Debug Message
4523 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
4524
4525
4526 -- Standard call to get message count and if count is 1, get message info.
4527 FND_MSG_PUB.Count_And_Get
4528 (p_count => x_msg_count,
4529 p_data => x_msg_data
4530 );
4531
4532 EXCEPTION
4533
4534
4535 WHEN FND_API.G_EXC_ERROR THEN
4536 ROLLBACK TO Create_offer_line_pvt;
4537 x_return_status := FND_API.G_RET_STS_ERROR;
4538 -- Standard call to get message count and if count=1, get the message
4539 FND_MSG_PUB.Count_And_Get (
4540 p_encoded => FND_API.G_FALSE,
4541 p_count => x_msg_count,
4542 p_data => x_msg_data
4543 );
4544
4545 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4546 ROLLBACK TO Create_offer_line_pvt;
4547 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4548 -- Standard call to get message count and if count=1, get the message
4549 FND_MSG_PUB.Count_And_Get (
4550 p_encoded => FND_API.G_FALSE,
4551 p_count => x_msg_count,
4552 p_data => x_msg_data
4553 );
4554
4555 WHEN OTHERS THEN
4556 ROLLBACK TO Create_offer_line_pvt;
4557 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4558 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4559 THEN
4560 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4561 END IF;
4562 -- Standard call to get message count and if count=1, get the message
4563 FND_MSG_PUB.Count_And_Get (
4564 p_encoded => FND_API.G_FALSE,
4565 p_count => x_msg_count,
4566 p_data => x_msg_data
4567 );
4568
4569 END Create_offer_line;
4570
4571
4572
4573
4574 --=========================================================================
4575 -- Name : default Disc rec
4576 -- Description : Helper method to populate fields which are not visible in the UI
4577 -- Defaults :
4578 -- Volume Operator - BETWEEN, Volume Break Type - POINT , Volume To
4579 -- If tier level = HEADER , OFFER DISCOUNT LINE I
4580 --=========================================================================
4581 procedure default_disc_rec(p_discount_rec IN OUT NOCOPY ozf_offer_line_rec_type)
4582 IS
4583 CURSOR c_tier_level(p_offer_id NUMBER) is
4584 SELECT tier_level FROM ozf_offers
4585 WHERE offer_id = p_offer_id;
4586
4587 l_tier_level ozf_offer_discount_lines.tier_level%type := 'HEADER';
4588
4589 BEGIN
4590 p_discount_rec.volume_operator := 'BETWEEN';
4591 p_discount_rec.volume_break_type := 'POINT';
4592 IF p_discount_rec.tier_type <> 'PBH' THEN
4593 p_discount_rec.volume_to := 999999999999999999;
4594 END IF;
4595 OPEN c_tier_level(p_discount_rec.offer_id);
4596 FETCH c_tier_level INTO l_tier_level;
4597 CLOSE c_tier_level;
4598 p_discount_rec.tier_level := l_tier_level;
4599 END default_disc_rec;
4600 PROCEDURE populate_discount_rec(p_discount_rec OUT NOCOPY ozf_offer_line_rec_type
4601 , p_offer_rec IN ozf_discount_line_rec_type)
4602 IS
4603
4604 BEGIN
4605 p_discount_rec.offer_discount_line_id := p_offer_rec.offer_discount_line_id;
4606 p_discount_rec.parent_discount_line_id := p_offer_rec.parent_discount_line_id;
4607 p_discount_rec.volume_from := p_offer_rec.volume_from;
4608 p_discount_rec.volume_to := p_offer_rec.volume_to;
4609 p_discount_rec.volume_operator := p_offer_rec.volume_operator;
4610 p_discount_rec.volume_type := p_offer_rec.volume_type;
4611 p_discount_rec.volume_break_type := p_offer_rec.volume_break_type;
4612 p_discount_rec.discount := p_offer_rec.discount;
4613 p_discount_rec.discount_type := p_offer_rec.discount_type;
4614 p_discount_rec.tier_type := p_offer_rec.tier_type;
4615 p_discount_rec.tier_level := p_offer_rec.tier_level;
4616 p_discount_rec.scan_value := p_offer_rec.scan_value;
4617 p_discount_rec.scan_data_quantity := p_offer_rec.scan_data_quantity;
4618 p_discount_rec.scan_unit_forecast := p_offer_rec.scan_unit_forecast;
4619 p_discount_rec.channel_id := p_offer_rec.channel_id;
4620 p_discount_rec.adjustment_flag := p_offer_rec.adjustment_flag;
4621 p_discount_rec.start_date_active := p_offer_rec.start_date_active;
4622 p_discount_rec.end_date_active := p_offer_rec.end_date_active;
4623 p_discount_rec.uom_code := p_offer_rec.uom_code;
4624 p_discount_rec.creation_date := p_offer_rec.creation_date;
4628 p_discount_rec.last_update_login := p_offer_rec.last_update_login;
4625 p_discount_rec.created_by := p_offer_rec.created_by;
4626 p_discount_rec.last_update_date := p_offer_rec.last_update_date;
4627 p_discount_rec.last_updated_by := p_offer_rec.last_updated_by;
4629 p_discount_rec.object_version_number := p_offer_rec.object_version_number;
4630 p_discount_rec.offer_id :=p_offer_rec.offer_id;
4631 default_disc_rec(p_discount_rec);
4632 END populate_discount_rec;
4633
4634
4635 PROCEDURE default_prod_rec(p_product_rec IN OUT NOCOPY ozf_prod_rec_type)
4636 is
4637 CURSOR c_tier_level(p_offer_id NUMBER) is
4638 SELECT tier_level FROM ozf_offers
4639 WHERE offer_id = p_offer_id;
4640 l_tier_level ozf_offer_discount_lines.tier_level%type := 'HEADER';
4641 BEGIN
4642 OPEN c_tier_level(p_product_rec.offer_id);
4643 FETCH c_tier_level INTO l_tier_level;
4644 CLOSE c_tier_level;
4645 IF(l_tier_level = 'HEADER') THEN
4646 p_product_rec.offer_discount_line_id := -1;
4647 END IF;
4648 END default_prod_rec;
4649 PROCEDURE populate_product_rec(p_product_rec IN OUT NOCOPY ozf_prod_rec_type
4650 , p_offer_rec IN ozf_discount_line_rec_type)
4651 IS
4652 BEGIN
4653 p_product_rec.off_discount_product_id := p_offer_rec.off_discount_product_id ;
4654 p_product_rec.parent_off_disc_prod_id := p_offer_rec.parent_off_disc_prod_id ;
4655 p_product_rec.product_level := p_offer_rec.product_level ;
4656 p_product_rec.product_id := p_offer_rec.product_id ;
4657 p_product_rec.excluder_flag := p_offer_rec.excluder_flag ;
4658 p_product_rec.uom_code := p_offer_rec.uom_code ;
4659 p_product_rec.start_date_active := p_offer_rec.start_date_active ;
4660 p_product_rec.end_date_active := p_offer_rec.end_date_active ;
4661 p_product_rec.offer_discount_line_id := p_offer_rec.offer_discount_line_id ;
4662 p_product_rec.offer_id := p_offer_rec.offer_id ;
4663 p_product_rec.creation_date := p_offer_rec.creation_date ;
4664 p_product_rec.created_by := p_offer_rec.created_by ;
4665 p_product_rec.last_update_date := p_offer_rec.last_update_date ;
4666 p_product_rec.last_updated_by := p_offer_rec.last_updated_by ;
4667 p_product_rec.last_update_login := p_offer_rec.last_update_login ;
4668 p_product_rec.object_version_number := p_offer_rec.object_version_number ;
4669 default_prod_rec(p_product_rec);
4670 END populate_product_rec;
4671
4672 PROCEDURE Create_discount_line(
4673 p_api_version_number IN NUMBER,
4674 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4675 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4676 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4677
4678 x_return_status OUT NOCOPY VARCHAR2,
4679 x_msg_count OUT NOCOPY NUMBER,
4680 x_msg_data OUT NOCOPY VARCHAR2,
4681
4682 p_ozf_discount_line_rec IN ozf_discount_line_rec_type ,
4683 x_offer_discount_line_id OUT NOCOPY NUMBER
4684 )
4685 IS
4686 l_api_name CONSTANT VARCHAR2(30) := 'Create_discount_line';
4687 l_api_version_number CONSTANT NUMBER := 1.0;
4688
4689 l_offer_discount_line_id NUMBER ;
4690 l_off_dicount_product_id NUMBER;
4691 l_discount_product_reln_id NUMBER;
4692
4693 l_ozf_offer_line_rec ozf_offer_line_rec_type := g_miss_ozf_offer_line_rec;
4694 l_ozf_prod_rec ozf_prod_rec_type := g_miss_ozf_prod_rec;
4695 l_prod_reln_rec prod_reln_rec_type := g_miss_prod_reln_rec;
4696
4697
4698 BEGIN
4699 SAVEPOINT Create_discount_line_pvt;
4700 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4701
4702 -- Standard call to check for call compatibility.
4703 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
4704 p_api_version_number,
4705 l_api_name,
4706 G_PKG_NAME)
4707 THEN
4708 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4709 END IF;
4710
4711
4712 -- Initialize message list if p_init_msg_list is set to TRUE.
4713 IF FND_API.to_Boolean( p_init_msg_list )
4714 THEN
4715 FND_MSG_PUB.initialize;
4716 END IF;
4717
4718
4719
4720 -- Debug Message
4724
4721 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4722
4723
4725 -- Initialize API return status to SUCCESS
4726 x_return_status := FND_API.G_RET_STS_SUCCESS;
4727 populate_discount_rec(p_discount_rec =>l_ozf_offer_line_rec
4728 , p_offer_rec =>p_ozf_discount_line_rec );
4729 --IF p_discount_rec.tier_type <> 'PBH' THEN
4730 populate_product_rec(p_product_rec =>l_ozf_prod_rec
4731 , p_offer_rec => p_ozf_discount_line_rec);
4732 --l_ozf_prod_rec.excluder_flag := 'N';
4733 --END IF;
4734 Create_offer_line(
4735 p_api_version_number => p_api_version_number,
4736 p_init_msg_list => p_init_msg_list,
4737 p_commit => p_commit,
4738 p_validation_level => p_validation_level,
4739
4740 x_return_status => x_return_status,
4741 x_msg_count => x_msg_count,
4742 x_msg_data => x_msg_data,
4743
4744 p_ozf_offer_line_rec => l_ozf_offer_line_rec,
4745 p_ozf_prod_rec => l_ozf_prod_rec,
4746 -- p_prod_reln_rec IN prod_reln_rec_type := g_miss_prod_reln_rec,
4747 x_offer_discount_line_id => x_offer_discount_line_id
4748 );
4749
4750
4751
4752
4753 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4754 RAISE FND_API.G_EXC_ERROR;
4755 END IF;
4756
4757 IF FND_API.to_Boolean( p_commit )
4758 THEN
4759 COMMIT WORK;
4760 END IF;
4761
4762
4763 -- Debug Message
4764 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
4765
4766
4767 -- Standard call to get message count and if count is 1, get message info.
4768 FND_MSG_PUB.Count_And_Get
4769 (p_count => x_msg_count,
4770 p_data => x_msg_data
4771 );
4772
4773 EXCEPTION
4774
4775 WHEN FND_API.G_EXC_ERROR THEN
4776 ROLLBACK TO Create_discount_line_pvt;
4777 x_return_status := FND_API.G_RET_STS_ERROR;
4778 -- Standard call to get message count and if count=1, get the message
4779 FND_MSG_PUB.Count_And_Get (
4780 p_encoded => FND_API.G_FALSE,
4781 p_count => x_msg_count,
4782 p_data => x_msg_data
4783 );
4784
4785 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4786 ROLLBACK TO Create_discount_line_pvt;
4787 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4788 -- Standard call to get message count and if count=1, get the message
4789 FND_MSG_PUB.Count_And_Get (
4790 p_encoded => FND_API.G_FALSE,
4791 p_count => x_msg_count,
4792 p_data => x_msg_data
4793 );
4794
4795 WHEN OTHERS THEN
4796 ROLLBACK TO Create_discount_line_pvt;
4797 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4798 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4799 THEN
4800 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4801 END IF;
4802 -- Standard call to get message count and if count=1, get the message
4803 FND_MSG_PUB.Count_And_Get (
4804 p_encoded => FND_API.G_FALSE,
4805 p_count => x_msg_count,
4806 p_data => x_msg_data
4807 );
4808
4809 END;
4810 -- ==============================================================================
4811 -- Start of Comments
4812 -- ==============================================================================
4813 -- API Name
4814 -- Update_Offer_line
4815 -- Type
4816 -- Private
4817 -- Pre-Req
4818 -- Update_Ozf_Prod_Line,Update_Ozf_Disc_Line
4819 -- Parameters
4820 --
4821 -- IN
4822 -- p_api_version_number IN NUMBER Required
4823 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
4824 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
4825 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
4826 -- p_ozf_offer_line_rec IN ozf_offer_line_rec_type Required Record containing Discount Line Data
4827 -- p_ozf_prod_rec IN ozf_prod_rec_type Required Record containing Product Data
4828 -- OUT
4829 -- x_return_status OUT VARCHAR2
4830 -- x_msg_count OUT NUMBER
4831 -- x_msg_data OUT VARCHAR2
4832 -- Version : Current version 1.0
4833 --
4834 -- History
4835 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
4836 --
4837 -- Description
4838 -- : Method to Update the Discount Lines.
4839 -- Since Discount and Product information is stored in separate tables
4840 -- and in separate records , thei method sallows selective update to
4841 -- each of the tables.
4842 -- If offer_discount_line_id in "p_ozf_offer_line_rec" is not null then
4843 -- UPdate to Discount Lines is called
4844 -- If off_discount_product_id in "p_ozf_prod_rec" is not null then Update to
4845 -- Products is called
4846 -- End of Comments
4850 p_api_version_number IN NUMBER,
4847 -- ==============================================================================
4848
4849 PROCEDURE Update_offer_line(
4851 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4852 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4853 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4854
4855 x_return_status OUT NOCOPY VARCHAR2,
4856 x_msg_count OUT NOCOPY NUMBER,
4857 x_msg_data OUT NOCOPY VARCHAR2,
4858
4859 p_ozf_offer_line_rec IN ozf_offer_line_rec_type ,
4860 p_ozf_prod_rec IN ozf_prod_rec_type
4861 )
4862 IS
4863 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_offer_line';
4864 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4865
4866
4867 l_return_status VARCHAR2(30);
4868 l_msg_count NUMBER;
4869 l_msg_data VARCHAR2(2000);
4870
4871 l_ozf_prod_rec ozf_prod_rec_type;
4872 l_ozf_offer_line_rec ozf_offer_line_rec_type ;
4873 BEGIN
4874 SAVEPOINT Update_offer_line_pvt;
4875
4876 -- Standard call to check for call compatibility.
4877 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
4878 p_api_version_number,
4879 l_api_name,
4880 G_PKG_NAME)
4881 THEN
4882 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4883 END IF;
4884
4885
4886 -- Initialize message list if p_init_msg_list is set to TRUE.
4887 IF FND_API.to_Boolean( p_init_msg_list )
4888 THEN
4889 FND_MSG_PUB.initialize;
4890 END IF;
4891
4892
4893 -- Debug Message
4894 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
4895
4896 -- Initialize API return status to SUCCESS
4897 x_return_status := FND_API.G_RET_STS_SUCCESS;
4898
4899 Update_Ozf_Disc_Line(
4900 p_api_version_number => p_api_version_number,
4901 p_init_msg_list => p_init_msg_list,
4902 p_commit => p_commit,
4903 p_validation_level => p_validation_level,
4904 x_return_status => l_return_status,
4905 x_msg_count => l_msg_count,
4906 x_msg_data => l_msg_data,
4907 p_ozf_offer_line_rec => p_ozf_offer_line_rec
4908 );
4909 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4910 RAISE FND_API.G_EXC_ERROR;
4911 END IF;
4912
4913 l_ozf_prod_rec := p_ozf_prod_rec;
4914 l_ozf_prod_rec.offer_id := p_ozf_offer_line_rec.offer_id;
4915 l_ozf_prod_rec.offer_discount_line_id := p_ozf_offer_line_rec.offer_discount_line_id;
4916
4917 --IF p_ozf_prod_rec.off_discount_product_id IS NOT NULL then
4918 Update_Ozf_Prod_Line(
4919 p_api_version_number => p_api_version_number,
4920 p_init_msg_list => p_init_msg_list,
4921 p_commit => p_commit,
4922 p_validation_level => p_validation_level,
4923 x_return_status => l_return_status,
4924 x_msg_count => l_msg_count,
4925 x_msg_data => l_msg_data,
4926 p_ozf_prod_rec =>l_ozf_prod_rec
4927 );
4928
4929 --end if;
4930 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
4931 RAISE FND_API.G_EXC_ERROR;
4932 END IF;
4933
4934 IF FND_API.to_Boolean( p_commit )
4935 THEN
4936 COMMIT WORK;
4937 END IF;
4938
4939
4940 -- Debug Message
4941 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
4942
4943
4944 -- Standard call to get message count and if count is 1, get message info.
4945 FND_MSG_PUB.Count_And_Get
4946 (p_count => x_msg_count,
4947 p_data => x_msg_data
4948 );
4949
4950 EXCEPTION
4951 WHEN FND_API.G_EXC_ERROR THEN
4952 ROLLBACK TO Update_offer_line_pvt;
4953 x_return_status := FND_API.G_RET_STS_ERROR;
4954 -- Standard call to get message count and if count=1, get the message
4955 FND_MSG_PUB.Count_And_Get (
4956 p_encoded => FND_API.G_FALSE,
4957 p_count => x_msg_count,
4958 p_data => x_msg_data
4959 );
4960
4961 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4962 ROLLBACK TO Update_offer_line_pvt;
4963 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4964 -- Standard call to get message count and if count=1, get the message
4965 FND_MSG_PUB.Count_And_Get (
4966 p_encoded => FND_API.G_FALSE,
4967 p_count => x_msg_count,
4968 p_data => x_msg_data
4969 );
4970
4971 WHEN OTHERS THEN
4972 ROLLBACK TO Update_offer_line_pvt;
4973 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4974 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4975 THEN
4979 FND_MSG_PUB.Count_And_Get (
4976 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
4977 END IF;
4978 -- Standard call to get message count and if count=1, get the message
4980 p_encoded => FND_API.G_FALSE,
4981 p_count => x_msg_count,
4982 p_data => x_msg_data
4983 );
4984
4985 END Update_offer_line;
4986
4987 PROCEDURE Update_discount_line(
4988 p_api_version_number IN NUMBER,
4989 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
4990 p_commit IN VARCHAR2 := FND_API.G_FALSE,
4991 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
4992
4993 x_return_status OUT NOCOPY VARCHAR2,
4994 x_msg_count OUT NOCOPY NUMBER,
4995 x_msg_data OUT NOCOPY VARCHAR2,
4996
4997 p_ozf_discount_line_rec IN ozf_discount_line_rec_type
4998 )
4999 IS
5000 l_api_name CONSTANT VARCHAR2(30) := 'Update_discount_line';
5001 l_api_version_number CONSTANT NUMBER := 1.0;
5002
5003 l_offer_discount_line_id NUMBER ;
5004 l_off_dicount_product_id NUMBER ;
5005 l_discount_product_reln_id NUMBER ;
5006
5007 l_ozf_offer_line_rec ozf_offer_line_rec_type := g_miss_ozf_offer_line_rec;
5008 l_ozf_prod_rec ozf_prod_rec_type := g_miss_ozf_prod_rec;
5009 l_prod_reln_rec prod_reln_rec_type := g_miss_prod_reln_rec;
5010
5011
5012 /*CURSOR c_get_ozf_disc_line(offer_discount_line_id NUMBER) IS
5013 SELECT *
5014 FROM OZF_OFFER_DISCOUNT_LINES
5015 WHERE offer_discount_line_id = p_ozf_offer_line_rec.offer_discount_line_id;
5016 l_rec c_get_ozf_disc_line%rowtype;
5017 */
5018 BEGIN
5019 SAVEPOINT Update_discount_line_pvt;
5020 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5021
5022 -- Standard call to check for call compatibility.
5023 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5024 p_api_version_number,
5025 l_api_name,
5026 G_PKG_NAME)
5027 THEN
5028 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5029 END IF;
5030
5031
5032 -- Initialize message list if p_init_msg_list is set to TRUE.
5033 IF FND_API.to_Boolean( p_init_msg_list )
5034 THEN
5035 FND_MSG_PUB.initialize;
5036 END IF;
5037
5038
5039
5040 -- Debug Message
5041 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5042
5043
5044
5045 -- Initialize API return status to SUCCESS
5046 x_return_status := FND_API.G_RET_STS_SUCCESS;
5047
5048 /*
5049 open c_get_ozf_disc_line(p_ozf_discount_line_rec.offer_discount_line_id);
5050 FETCH c_get_ozf_disc_line into l_rec;
5051 close c_get_ozf_disc_line;
5052
5053 If (p_ozf_discount_line_rec.object_version_number is NULL or
5054 p_ozf_discount_line_rec.object_version_number = FND_API.G_MISS_NUM ) Then
5055 OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
5056 p_token_name => 'COLUMN',
5057 p_token_value => 'Last_Update_Date') ;
5058 raise FND_API.G_EXC_ERROR;
5059 End if;
5060 -- Check Whether record has been changed by someone else
5061 If (p_ozf_discount_line_rec.object_version_number <> l_rec.object_version_number) Then
5062 OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
5063 p_token_name => 'INFO',
5064 p_token_value => 'Ozf_Disc_Line') ;
5065 raise FND_API.G_EXC_ERROR;
5066 End if;
5067 */
5068 --
5069 populate_discount_rec(p_discount_rec =>l_ozf_offer_line_rec
5073
5070 , p_offer_rec =>p_ozf_discount_line_rec );
5071 populate_product_rec(p_product_rec =>l_ozf_prod_rec
5072 , p_offer_rec => p_ozf_discount_line_rec);
5074 Update_offer_line(
5075 p_api_version_number => p_api_version_number,
5076 p_init_msg_list => p_init_msg_list,
5077 p_commit => p_commit,
5078 p_validation_level => p_validation_level,
5079
5080 x_return_status => x_return_status,
5081 x_msg_count => x_msg_count,
5082 x_msg_data => x_msg_data,
5083
5084 p_ozf_offer_line_rec => l_ozf_offer_line_rec,
5085 p_ozf_prod_rec => l_ozf_prod_rec
5086 );
5087
5088
5089 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5090 RAISE FND_API.G_EXC_ERROR;
5091 END IF;
5092
5093 IF FND_API.to_Boolean( p_commit )
5094 THEN
5095 COMMIT WORK;
5096 END IF;
5097
5098
5099 -- Debug Message
5100 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
5101
5102
5103 -- Standard call to get message count and if count is 1, get message info.
5104 FND_MSG_PUB.Count_And_Get
5105 (p_count => x_msg_count,
5106 p_data => x_msg_data
5107 );
5108
5109 EXCEPTION
5110
5111
5112 WHEN FND_API.G_EXC_ERROR THEN
5113 ROLLBACK TO Update_discount_line_pvt;
5114 x_return_status := FND_API.G_RET_STS_ERROR;
5115 -- Standard call to get message count and if count=1, get the message
5116 FND_MSG_PUB.Count_And_Get (
5117 p_encoded => FND_API.G_FALSE,
5118 p_count => x_msg_count,
5119 p_data => x_msg_data
5120 );
5121
5122 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5123 ROLLBACK TO Update_discount_line_pvt;
5124 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5125 -- Standard call to get message count and if count=1, get the message
5126 FND_MSG_PUB.Count_And_Get (
5127 p_encoded => FND_API.G_FALSE,
5128 p_count => x_msg_count,
5129 p_data => x_msg_data
5130 );
5131
5132 WHEN OTHERS THEN
5133 ROLLBACK TO Update_discount_line_pvt;
5134 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5135 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5136 THEN
5137 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
5138 END IF;
5139 -- Standard call to get message count and if count=1, get the message
5140 FND_MSG_PUB.Count_And_Get (
5141 p_encoded => FND_API.G_FALSE,
5142 p_count => x_msg_count,
5143 p_data => x_msg_data
5144 );
5145
5146 END;
5147
5148
5149 procedure Init_dl_rec ( p_ozf_offer_line_rec IN OUT NOCOPY ozf_offer_line_rec_type )
5150 IS
5151 BEGIN
5152 p_ozf_offer_line_rec.offer_discount_line_id := FND_API.G_MISS_NUM;
5153 p_ozf_offer_line_rec.parent_discount_line_id := FND_API.G_MISS_NUM;
5154 p_ozf_offer_line_rec.volume_from := FND_API.G_MISS_NUM;
5155 p_ozf_offer_line_rec.volume_to := FND_API.G_MISS_NUM;
5156 p_ozf_offer_line_rec.volume_operator := FND_API.G_MISS_CHAR;
5157 p_ozf_offer_line_rec.volume_type := FND_API.G_MISS_CHAR;
5158 p_ozf_offer_line_rec.volume_break_type := FND_API.G_MISS_CHAR;
5159 p_ozf_offer_line_rec.discount := FND_API.G_MISS_NUM;
5160 p_ozf_offer_line_rec.discount_type := FND_API.G_MISS_CHAR;
5161 p_ozf_offer_line_rec.tier_type := FND_API.G_MISS_CHAR;
5162 p_ozf_offer_line_rec.tier_level := FND_API.G_MISS_CHAR;
5163 p_ozf_offer_line_rec.scan_value := FND_API.G_MISS_NUM;
5164 p_ozf_offer_line_rec.scan_data_quantity := FND_API.G_MISS_NUM;
5165 p_ozf_offer_line_rec.scan_unit_forecast := FND_API.G_MISS_NUM;
5166 p_ozf_offer_line_rec.channel_id := FND_API.G_MISS_NUM;
5167 p_ozf_offer_line_rec.adjustment_flag := FND_API.G_MISS_CHAR;
5168 p_ozf_offer_line_rec.start_date_active := FND_API.G_MISS_DATE;
5169 p_ozf_offer_line_rec.end_date_active := FND_API.G_MISS_DATE;
5170 p_ozf_offer_line_rec.creation_date := FND_API.G_MISS_DATE;
5171 p_ozf_offer_line_rec.created_by := FND_API.G_MISS_NUM;
5172 p_ozf_offer_line_rec.last_update_date := FND_API.G_MISS_DATE;
5173 p_ozf_offer_line_rec.last_updated_by := FND_API.G_MISS_NUM;
5174 p_ozf_offer_line_rec.last_update_login := FND_API.G_MISS_NUM;
5175 p_ozf_offer_line_rec.object_version_number := FND_API.G_MISS_NUM;
5176 p_ozf_offer_line_rec.offer_id := FND_API.G_MISS_NUM;
5177 END Init_dl_rec;
5178
5179
5180
5184 -- API Name
5181 -- ==============================================================================
5182 -- Start of Comments
5183 -- ==============================================================================
5185 -- Update_Product
5186 -- Type
5187 -- Private
5188 -- Pre-Req
5189 -- Update_Ozf_Prod_Line,Update_Ozf_Disc_Line
5190 -- Parameters
5191 --
5192 -- IN
5193 -- p_api_version_number IN NUMBER Required
5194 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
5195 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
5196 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
5197 -- p_ozf_prod_rec IN ozf_prod_rec_type Required Record Used for Updating the Product
5198 -- OUT
5199 -- x_return_status OUT VARCHAR2
5200 -- x_msg_count OUT NUMBER
5201 -- x_msg_data OUT VARCHAR2
5202 -- Version : Current version 1.0
5203 --
5204 -- History
5205 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
5206 --
5207 -- Description
5208 -- : Helper method to Update the Product Details.Also Maintains the Object Version no of the Discount Line ID
5209 -- This methods makes the Discount Line Id as the Transaction Unit for all Updates related to Discount Lines
5210 -- Products , Exclusions.Updates Object Version number of Discount Line Id for every change to Products linked to Discount line id
5211 -- End of Comments
5212 -- ==============================================================================
5213
5214 PROCEDURE Update_Product
5215 (
5216 p_api_version_number IN NUMBER,
5217 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5218 p_commit IN VARCHAR2 := FND_API.G_FALSE,
5219 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
5220
5221 x_return_status OUT NOCOPY VARCHAR2,
5222 x_msg_count OUT NOCOPY NUMBER,
5223 x_msg_data OUT NOCOPY VARCHAR2,
5224 p_ozf_prod_rec IN ozf_prod_rec_type
5225
5226 )
5227 IS
5228 l_api_name CONSTANT VARCHAR2(30) := 'Update_Product';
5229 l_api_version_number CONSTANT NUMBER := 1.0;
5230 l_return_status VARCHAR2(30);
5231 l_msg_count NUMBER;
5232 l_msg_data VARCHAR2(2000);
5233
5234 l_ozf_offer_line_rec ozf_offer_line_rec_type ;
5235
5236 CURSOR C_DL_INFO (p_offer_discount_line_id NUMBER)is
5237 SELECT offer_discount_line_id,offer_id,object_version_number
5238 FROM ozf_offer_discount_lines
5239 WHERE offer_discount_line_id = p_offer_discount_line_id;
5240 l_dl_rec C_DL_INFO%rowtype;
5241
5242
5243 CURSOR c_discount_line_id(p_off_discount_product_id NUMBER) IS
5244 SELECT offer_discount_line_id FROM ozf_offer_discount_products
5245 WHERE off_discount_product_id = p_off_discount_product_id;
5246 l_discount_line_id NUMBER;
5247 BEGIN
5248 SAVEPOINT Update_product_Pvt;
5249
5250 -- Standard call to check for call compatibility.
5251 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5252 p_api_version_number,
5253 l_api_name,
5254 G_PKG_NAME)
5255 THEN
5256 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5257 END IF;
5258
5259
5260 -- Initialize message list if p_init_msg_list is set to TRUE.
5261 IF FND_API.to_Boolean( p_init_msg_list )
5262 THEN
5263 FND_MSG_PUB.initialize;
5264 END IF;
5265
5266
5267 -- Debug Message
5268 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5269
5270 -- Initialize API return status to SUCCESS
5271 x_return_status := FND_API.G_RET_STS_SUCCESS;
5272 -- Update Product Line
5273 Update_Ozf_Prod_Line(
5274 p_api_version_number => p_api_version_number,
5275 p_init_msg_list => p_init_msg_list,
5276 p_commit => p_commit,
5277 p_validation_level => p_validation_level,
5278 x_return_status => x_return_status,
5279 x_msg_count => l_msg_count,
5280 x_msg_data => l_msg_data,
5281 p_ozf_prod_rec =>p_ozf_prod_rec
5282 );
5283
5284 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5285 RAISE FND_API.G_EXC_ERROR;
5286 END IF;
5287
5288 -- get Discount Line Information
5289 OPEN c_discount_line_id(p_ozf_prod_rec.off_discount_product_id);
5290 FETCH c_discount_line_id into l_discount_line_id;
5291 CLOSE c_discount_line_id;
5292 OPEN C_DL_INFO(l_discount_line_id);
5293 fetch C_DL_INFO INTO l_dl_rec;
5294 CLOSE C_DL_INFO;
5295
5296 --Init_dl_rec ( p_ozf_offer_line_rec => l_ozf_offer_line_rec );
5297
5298 -- POpulate Discount Line Rec
5299 /*l_ozf_offer_line_rec.offer_discount_line_id := l_dl_rec.offer_discount_line_id;
5300 l_ozf_offer_line_rec.object_version_number := l_dl_rec.object_version_number;
5301 l_ozf_offer_line_rec.offer_id := l_dl_rec.offer_id;
5302
5303 -- Update Object version number for discount line
5304 Update_Ozf_Disc_Line(
5305 p_api_version_number => p_api_version_number,
5309 x_return_status => x_return_status,
5306 p_init_msg_list => p_init_msg_list,
5307 p_commit => p_commit,
5308 p_validation_level => p_validation_level,
5310 x_msg_count => l_msg_count,
5311 x_msg_data => l_msg_data,
5312 p_ozf_offer_line_rec => l_ozf_offer_line_rec
5313 );
5314 */
5315 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5316 RAISE FND_API.G_EXC_ERROR;
5317 END IF;
5318
5319 IF FND_API.to_Boolean( p_commit )
5320 THEN
5321 COMMIT WORK;
5322 END IF;
5323
5324
5325 -- Debug Message
5326 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
5327
5328
5329 -- Standard call to get message count and if count is 1, get message info.
5330 FND_MSG_PUB.Count_And_Get
5331 (p_count => l_msg_count,
5332 p_data => l_msg_data
5333 );
5334
5335 EXCEPTION
5336 WHEN FND_API.G_EXC_ERROR THEN
5337 ROLLBACK TO Update_product_Pvt;
5338 x_return_status := FND_API.G_RET_STS_ERROR;
5339 -- Standard call to get message count and if count=1, get the message
5340 FND_MSG_PUB.Count_And_Get (
5341 p_encoded => FND_API.G_FALSE,
5342 p_count => l_msg_count,
5343 p_data => l_msg_data
5344 );
5345
5346 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5347 ROLLBACK TO Update_product_Pvt;
5348 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5349 -- Standard call to get message count and if count=1, get the message
5350 FND_MSG_PUB.Count_And_Get (
5351 p_encoded => FND_API.G_FALSE,
5352 p_count => l_msg_count,
5353 p_data => l_msg_data
5354 );
5355
5356 WHEN OTHERS THEN
5357 ROLLBACK TO Update_product_Pvt;
5358 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5359 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5360 THEN
5361 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
5362 END IF;
5363 -- Standard call to get message count and if count=1, get the message
5364 FND_MSG_PUB.Count_And_Get (
5365 p_encoded => FND_API.G_FALSE,
5366 p_count => l_msg_count,
5367 p_data => l_msg_data
5368 );
5369
5370 END Update_Product;
5371
5372
5373
5374 -- ==============================================================================
5375 -- Start of Comments
5376 -- ==============================================================================
5377 -- API Name
5378 -- Delete_Relation
5379 -- Type
5380 -- Private
5381 -- Pre-Req
5382 -- Ozf_Prod_Reln_Pkg.Delete
5383 -- Parameters
5384 --
5385 -- IN
5386 -- p_api_version_number IN NUMBER Required
5387 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
5388 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
5389 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
5390 -- p_offer_discount_line_id IN NUMBER Required All the Relations attached to this discount line will be deleted
5391 --
5392 -- OUT
5393 -- x_return_status OUT VARCHAR2
5394 -- x_msg_count OUT NUMBER
5395 -- x_msg_data OUT VARCHAR2
5396 -- Version : Current version 1.0
5397 --
5398 -- History
5399 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
5400 --
5401 -- Description
5402 -- : Helper method to Hard Delete All the Relations for a given discount line
5403 -- End of Comments
5404 -- ==============================================================================
5405
5406 PROCEDURE Delete_Relation(
5407 p_api_version_number IN NUMBER,
5408 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5409 p_commit IN VARCHAR2 := FND_API.G_FALSE,
5410 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
5411 x_return_status OUT NOCOPY VARCHAR2,
5412 x_msg_count OUT NOCOPY NUMBER,
5413 x_msg_data OUT NOCOPY VARCHAR2,
5414 p_offer_discount_line_id IN NUMBER
5415 )
5416 IS
5417 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Relation';
5418 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5419 l_return_status VARCHAR2(30);
5420 l_msg_count NUMBER;
5421 l_msg_data VARCHAR2(2000);
5422
5423 BEGIN
5424 SAVEPOINT Delete_Relation_Pvt;
5425
5426 -- Standard call to check for call compatibility.
5427 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5428 p_api_version_number,
5429 l_api_name,
5430 G_PKG_NAME)
5431 THEN
5432 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5433 END IF;
5434
5435
5436 -- Initialize message list if p_init_msg_list is set to TRUE.
5437 IF FND_API.to_Boolean( p_init_msg_list )
5438 THEN
5439 FND_MSG_PUB.initialize;
5440 END IF;
5441
5445
5442
5443 -- Debug Message
5444 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5446 -- Initialize API return status to SUCCESS
5447 x_return_status := FND_API.G_RET_STS_SUCCESS;
5448
5449
5450 Ozf_Prod_Reln_Pkg.Delete(
5451 p_offer_discount_line_id => p_offer_discount_line_id
5452 );
5453
5454
5455 IF FND_API.to_Boolean( p_commit )
5456 THEN
5457 COMMIT WORK;
5458 END IF;
5459
5460
5461 -- Debug Message
5462 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
5463
5464
5465 -- Standard call to get message count and if count is 1, get message info.
5466 FND_MSG_PUB.Count_And_Get
5467 (p_count => l_msg_count,
5468 p_data => l_msg_data
5469 );
5470
5471 EXCEPTION
5472 WHEN FND_API.G_EXC_ERROR THEN
5473 ROLLBACK TO Delete_Relation_Pvt;
5474 x_return_status := FND_API.G_RET_STS_ERROR;
5475 -- Standard call to get message count and if count=1, get the message
5476 FND_MSG_PUB.Count_And_Get (
5477 p_encoded => FND_API.G_FALSE,
5478 p_count => l_msg_count,
5479 p_data => l_msg_data
5480 );
5481
5482 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5483 ROLLBACK TO Delete_Relation_Pvt;
5484 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5485 -- Standard call to get message count and if count=1, get the message
5486 FND_MSG_PUB.Count_And_Get (
5487 p_encoded => FND_API.G_FALSE,
5488 p_count => l_msg_count,
5489 p_data => l_msg_data
5490 );
5491
5492 WHEN OTHERS THEN
5493 ROLLBACK TO Delete_Relation_Pvt;
5494 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5495 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5496 THEN
5497 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
5498 END IF;
5499 -- Standard call to get message count and if count=1, get the message
5500 FND_MSG_PUB.Count_And_Get (
5501 p_encoded => FND_API.G_FALSE,
5502 p_count => l_msg_count,
5503 p_data => l_msg_data
5504 );
5505 END Delete_Relation;
5506
5507 -- ==============================================================================
5508 -- Start of Comments
5509 -- ==============================================================================
5510 -- API Name
5511 -- Delete_Product
5512 -- Type
5513 -- Private
5514 -- Pre-Req
5515 -- Delete_Relation,OZF_Create_Ozf_Prod_Line_PKG.Delete_product
5516 -- Parameters
5517 --
5518 -- IN
5519 -- p_api_version_number IN NUMBER Required
5520 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
5521 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
5522 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
5523 -- p_offer_discount_line_id IN NUMBER Required All the products attached to this discount line will be deleted
5524 --
5525 -- OUT
5526 -- x_return_status OUT VARCHAR2
5527 -- x_msg_count OUT NUMBER
5528 -- x_msg_data OUT VARCHAR2
5529 -- Version : Current version 1.0
5530 --
5531 -- History
5532 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
5533 --
5534 -- Description
5535 -- : Helper method to Hard Delete All the Products for a given discount line
5536 -- End of Comments
5537 -- ==============================================================================
5538
5539 PROCEDURE Delete_Product(
5540 p_api_version_number IN NUMBER,
5541 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5542 p_commit IN VARCHAR2 := FND_API.G_FALSE,
5546 x_msg_data OUT NOCOPY VARCHAR2,
5543 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
5544 x_return_status OUT NOCOPY VARCHAR2,
5545 x_msg_count OUT NOCOPY NUMBER,
5547 p_offer_discount_line_id IN NUMBER
5548 )
5549 IS
5550 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Product';
5551 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5552
5553 l_ozf_offer_line_rec ozf_offer_line_rec_type ;
5554 l_ozf_prod_rec ozf_prod_rec_type ;
5555
5556 l_return_status VARCHAR2(30);
5557 l_msg_count NUMBER;
5558 l_msg_data VARCHAR2(2000);
5559
5560
5561
5562 BEGIN
5563 SAVEPOINT Delete_Product_Pvt;
5564
5565 -- Standard call to check for call compatibility.
5566 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5567 p_api_version_number,
5568 l_api_name,
5569 G_PKG_NAME)
5570 THEN
5571 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5572 END IF;
5573
5574
5575 -- Initialize message list if p_init_msg_list is set to TRUE.
5576 IF FND_API.to_Boolean( p_init_msg_list )
5577 THEN
5578 FND_MSG_PUB.initialize;
5579 END IF;
5580
5581
5582 -- Debug Message
5583 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5584
5585 -- Initialize API return status to SUCCESS
5586 x_return_status := FND_API.G_RET_STS_SUCCESS;
5587
5588
5589 Delete_Relation(
5590 p_api_version_number => p_api_version_number,
5591 p_init_msg_list => p_init_msg_list,
5592 p_commit => p_commit,
5593 p_validation_level => p_validation_level,
5594 x_return_status => x_return_status,
5595 x_msg_count => l_msg_count,
5596 x_msg_data => l_msg_data,
5597 p_offer_discount_line_id => p_offer_discount_line_id
5598 );
5599 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5600 RAISE FND_API.G_EXC_ERROR;
5601 END IF;
5602 OZF_Create_Ozf_Prod_Line_PKG.Delete_product(p_offer_discount_line_id => p_offer_discount_line_id);
5603 IF l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5604 RAISE FND_API.G_EXC_ERROR;
5605 END IF;
5606
5607
5608 IF FND_API.to_Boolean( p_commit )
5609 THEN
5610 COMMIT WORK;
5611 END IF;
5612
5613
5614 -- Debug Message
5615 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
5616
5617
5618 -- Standard call to get message count and if count is 1, get message info.
5619 FND_MSG_PUB.Count_And_Get
5620 (p_count => l_msg_count,
5621 p_data => l_msg_data
5622 );
5623
5624 EXCEPTION
5625 WHEN FND_API.G_EXC_ERROR THEN
5626 ROLLBACK TO Delete_Product_Pvt;
5627 x_return_status := FND_API.G_RET_STS_ERROR;
5628 -- Standard call to get message count and if count=1, get the message
5629 FND_MSG_PUB.Count_And_Get (
5630 p_encoded => FND_API.G_FALSE,
5631 p_count => l_msg_count,
5632 p_data => l_msg_data
5633 );
5634
5635 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5636 ROLLBACK TO Delete_Product_Pvt;
5637 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5638 -- Standard call to get message count and if count=1, get the message
5639 FND_MSG_PUB.Count_And_Get (
5640 p_encoded => FND_API.G_FALSE,
5641 p_count => l_msg_count,
5642 p_data => l_msg_data
5643 );
5644
5645 WHEN OTHERS THEN
5646 ROLLBACK TO Delete_Product_Pvt;
5647 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5648 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5649 THEN
5650 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
5651 END IF;
5652 -- Standard call to get message count and if count=1, get the message
5653 FND_MSG_PUB.Count_And_Get (
5654 p_encoded => FND_API.G_FALSE,
5655 p_count => l_msg_count,
5659
5656 p_data => l_msg_data
5657 );
5658 END Delete_Product;
5660
5661
5662 -- ==============================================================================
5663 -- Start of Comments
5664 -- ==============================================================================
5665 -- API Name
5666 -- Delete_Offer_line
5667 -- Type
5668 -- Private
5669 -- Pre-Req
5670 -- Delete_Product,delete_Ozf_Disc_Line
5671 -- Parameters
5672 --
5673 -- IN
5674 -- p_api_version_number IN NUMBER Required
5675 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
5676 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
5677 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
5678 -- p_offer_discount_line_id IN NUMBER Required Discount Line id to be deleted
5679 -- p_object_version_number IN NUMBER Required Object Version No. Of Discount Line to be deleted
5680 --
5681 -- OUT
5682 -- x_return_status OUT VARCHAR2
5683 -- x_msg_count OUT NUMBER
5684 -- x_msg_data OUT VARCHAR2
5685 -- x_off_discount_product_id OUT NUMBER
5686 -- Version : Current version 1.0
5687 --
5688 -- History
5689 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
5690 --
5691 -- Description
5692 -- : Helper method to Hard Delete a Discount Line and all the Related Product Lines and relations.
5693 -- End of Comments
5694 -- ==============================================================================
5695
5696 PROCEDURE Delete_offer_line(
5697 p_api_version_number IN NUMBER,
5698 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5699 p_commit IN VARCHAR2 := FND_API.G_FALSE,
5700 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
5701
5702 x_return_status OUT NOCOPY VARCHAR2,
5703 x_msg_count OUT NOCOPY NUMBER,
5704 x_msg_data OUT NOCOPY VARCHAR2,
5705
5706 p_offer_discount_line_id IN NUMBER,
5707 p_object_version_number IN NUMBER
5708 )
5709 IS
5710 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_offer_line';
5711 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5712
5713 l_ozf_offer_line_rec ozf_offer_line_rec_type ;
5714 l_ozf_prod_rec ozf_prod_rec_type ;
5715
5716 /* l_return_status VARCHAR2(30);
5717 l_msg_count NUMBER;
5718 l_msg_data VARCHAR2(2000);
5719 */
5720 CURSOR C_PARENT_DISC_LINE(p_offer_discount_line_id NUMBER )IS
5721 SELECT * FROM ozf_offer_discount_lines
5722 WHERE offer_discount_line_id = p_offer_discount_line_id;
5723
5724 l_parent_disc_line C_PARENT_DISC_LINE%rowtype;
5725
5726 cursor c_offer_id(p_offer_discount_line_id NUMBER) IS
5727 select offer_id FROM ozf_offer_discount_lines where offer_discount_line_id = p_offer_discount_line_id;
5728
5729 l_offer_id NUMBER;
5730
5731 BEGIN
5732 SAVEPOINT Delete_offer_line_Pvt;
5733
5734 -- Standard call to check for call compatibility.
5735 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5736 p_api_version_number,
5737 l_api_name,
5738 G_PKG_NAME)
5739 THEN
5740 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5741 END IF;
5742
5743
5744 -- Initialize message list if p_init_msg_list is set to TRUE.
5745 IF FND_API.to_Boolean( p_init_msg_list )
5746 THEN
5747 FND_MSG_PUB.initialize;
5748 END IF;
5749
5750
5751 -- Debug Message
5752 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5753
5754 -- Initialize API return status to SUCCESS
5755 x_return_status := FND_API.G_RET_STS_SUCCESS;
5756
5757 open c_offer_id(p_offer_discount_line_id);
5758 fetch c_offer_id INTO l_offer_id;
5759 close c_offer_id;
5760 IF is_delete_valid(l_offer_id) = 'N' THEN
5761 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFR_CANT_DELETE_LINE');
5762 RAISE FND_API.G_EXC_ERROR;
5763 END IF;
5764
5765 OPEN C_PARENT_DISC_LINE(p_offer_discount_line_id);
5766 FETCH C_PARENT_DISC_LINE into l_parent_disc_line;
5767 CLOSE C_PARENT_DISC_LINE;
5768
5769 IF l_parent_disc_line.tier_type = 'PBH' THEN
5770 delete_disc_tiers(
5771 p_api_version_number => p_api_version_number,
5772 p_init_msg_list => p_init_msg_list,
5773 p_commit => p_commit,
5774 p_validation_level => p_validation_level,
5775 x_return_status => x_return_status,
5776 x_msg_count => x_msg_count,
5777 x_msg_data => x_msg_data,
5778 p_parent_discount_line_id => p_offer_discount_line_id
5779 );
5780 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5781 RAISE FND_API.G_EXC_ERROR;
5782 END IF;
5783 END IF;
5784
5785
5786
5787 Delete_Product(
5788 p_api_version_number => p_api_version_number,
5789 p_init_msg_list => p_init_msg_list,
5790 p_commit => p_commit,
5791 p_validation_level => p_validation_level,
5792 x_return_status => x_return_status,
5793 x_msg_count => x_msg_count,
5794 x_msg_data => x_msg_data,
5795 p_offer_discount_line_id => p_offer_discount_line_id
5796 );
5800
5797 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5798 RAISE FND_API.G_EXC_ERROR;
5799 END IF;
5801 delete_Ozf_Disc_Line
5802 (
5803 p_api_version_number => p_api_version_number,
5804 p_init_msg_list => p_init_msg_list,
5805 p_commit => p_commit,
5806 p_validation_level => p_validation_level,
5807 x_return_status => x_return_status,
5808 x_msg_count => x_msg_count,
5809 x_msg_data => x_msg_data,
5810 p_offer_discount_line_id => p_offer_discount_line_id,
5811 p_object_version_number => p_object_version_number
5812 );
5813
5814 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
5815 RAISE FND_API.G_EXC_ERROR;
5816 END IF;
5817
5818 IF FND_API.to_Boolean( p_commit )
5819 THEN
5820 COMMIT WORK;
5821 END IF;
5822
5823
5824 -- Debug Message
5825 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
5826
5827
5828 -- Standard call to get message count and if count is 1, get message info.
5829 FND_MSG_PUB.Count_And_Get
5830 (p_count => x_msg_count,
5831 p_data => x_msg_data
5832 );
5833
5834 EXCEPTION
5835 WHEN FND_API.G_EXC_ERROR THEN
5836 ROLLBACK TO Delete_offer_line_pvt;
5837 x_return_status := FND_API.G_RET_STS_ERROR;
5838 -- Standard call to get message count and if count=1, get the message
5839 FND_MSG_PUB.Count_And_Get (
5840 p_encoded => FND_API.G_FALSE,
5841 p_count => x_msg_count,
5842 p_data => x_msg_data
5843 );
5844
5845 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5846 ROLLBACK TO Delete_offer_line_pvt;
5847 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5848 -- Standard call to get message count and if count=1, get the message
5849 FND_MSG_PUB.Count_And_Get (
5850 p_encoded => FND_API.G_FALSE,
5851 p_count => x_msg_count,
5852 p_data => x_msg_data
5853 );
5854
5855 WHEN OTHERS THEN
5856 ROLLBACK TO Delete_offer_line_pvt;
5857 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5858 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5859 THEN
5860 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
5861 END IF;
5862 -- Standard call to get message count and if count=1, get the message
5863 FND_MSG_PUB.Count_And_Get (
5864 p_encoded => FND_API.G_FALSE,
5865 p_count => x_msg_count,
5866 p_data => x_msg_data
5867 );
5868 END Delete_offer_line;
5869
5870
5871
5872
5873
5874 PROCEDURE check_parent_off_disc_prod(x_return_status IN OUT NOCOPY VARCHAR2
5875 , p_ozf_prod_rec IN ozf_prod_rec_type := g_miss_ozf_prod_rec
5876 )
5877 IS
5878 CURSOR C_SQL (p_offer_id NUMBER, p_off_discount_product_id NUMBER,p_offer_discount_line_id NUMBER) IS
5879 SELECT 1 FROM dual WHERE EXISTS
5880 (
5881 SELECT 1 FROM OZF_OFFER_DISCOUNT_PRODUCTS
5882 WHERE offer_id = p_offer_id
5883 AND off_discount_product_id = p_off_discount_product_id
5884 -- AND offer_discount_line_id = p_offer_discount_line_id
5885 AND excluder_flag = 'N'
5886 );
5887 l_count NUMBER:= 0;
5888 BEGIN
5889 OPEN C_SQL( p_ozf_prod_rec.offer_id,p_ozf_prod_rec.parent_off_disc_prod_id,p_ozf_prod_rec.offer_discount_line_id);
5890 fetch c_sql INTO l_count;
5891 CLOSE C_SQL;
5892 IF l_count = 0 THEN
5893 x_return_status := FND_API.g_ret_sts_error;
5894 ELSE
5895 x_return_status := FND_API.G_RET_STS_SUCCESS;
5896 END IF;
5897
5898 END check_parent_off_disc_prod;
5899
5900
5901 -- ==============================================================================
5902 -- Start of Comments
5903 -- ==============================================================================
5904 -- API Name
5905 -- Create_Product_Exclusion
5906 -- Type
5907 -- Private
5908 -- Pre-Req
5909 -- Create_Product,check_parent_off_disc_prod
5910 -- Parameters
5911 --
5912 -- IN
5913 -- p_api_version_number IN NUMBER Required
5914 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
5915 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
5916 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
5917 -- p_ozf_prod_rec IN ozf_prod_rec_type Required
5918 --
5919 -- OUT
5920 -- x_return_status OUT VARCHAR2
5921 -- x_msg_count OUT NUMBER
5922 -- x_msg_data OUT VARCHAR2
5923 -- x_off_discount_product_id OUT NUMBER
5924 -- Version : Current version 1.0
5925 --
5926 -- History
5927 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
5928 --
5929 -- Description
5930 -- : Helper method to create Exclusions for Discount Lines.
5931 -- Does the following validations
5932 -- 1)if excluder flag is not Y then it is set to Y
5933 -- 2)If parent_off_disc_prod_id should not be null
5934 -- 3)If parent_off_disc_prod_id should be a valid off_discount_product_id for the same offer
5935 -- End of Comments
5936 -- ==============================================================================
5937
5938 PROCEDURE Create_Product_Exclusion
5939 (
5940 p_api_version_number IN NUMBER,
5941 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5945 x_return_status OUT NOCOPY VARCHAR2,
5942 p_commit IN VARCHAR2 := FND_API.G_FALSE,
5943 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
5944
5946 x_msg_count OUT NOCOPY NUMBER,
5947 x_msg_data OUT NOCOPY VARCHAR2,
5948
5949 p_ozf_excl_rec IN ozf_excl_rec_type,
5950 x_off_discount_product_id OUT NOCOPY NUMBER
5951 )
5952 IS
5953 l_api_name CONSTANT VARCHAR2(30) := 'Create_Product_Exclusion';
5954 l_api_version_number CONSTANT NUMBER := 1.0;
5955
5956 -- l_return_status VARCHAR2(30);
5957 l_msg_count NUMBER;
5958 l_msg_data VARCHAR2(2000);
5959 l_off_discount_product_id NUMBER;
5960 l_prod_reln_id NUMBER;
5961 l_prod_reln_rec prod_reln_rec_type ;
5962 l_ozf_prod_rec ozf_prod_rec_type ;
5963
5964 CURSOR c_prod_info(p_off_discount_product_id NUMBER) IS
5965 SELECT *
5966 FROM ozf_offer_discount_products
5967 WHERE off_discount_product_id = p_off_discount_product_id;
5968
5969 l_prod_rec c_prod_info%rowtype;
5970 BEGIN
5971 SAVEPOINT Create_Product_Exclusion_PVT;
5972
5973 -- Standard call to check for call compatibility.
5974 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
5975 p_api_version_number,
5976 l_api_name,
5977 G_PKG_NAME)
5978 THEN
5979 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5980 END IF;
5981
5982
5983 -- Initialize message list if p_init_msg_list is set to TRUE.
5984 IF FND_API.to_Boolean( p_init_msg_list )
5985 THEN
5986 FND_MSG_PUB.initialize;
5987 END IF;
5988
5989
5990 -- Debug Message
5991 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
5992
5993 -- Initialize API return status to SUCCESS
5994 x_return_status := FND_API.G_RET_STS_SUCCESS;
5995
5996 -- Validations for Exclusions
5997 -- 1)if excluder flag is not Y then it is set to Y
5998 -- 2)If parent_off_disc_prod_id should not be null
5999 -- 3)If parent_off_disc_prod_id should be a valid off_discount_product_id for the same offer
6000
6001 -- l_ozf_prod_rec := p_ozf_prod_rec;
6002
6003
6004 l_ozf_prod_rec.parent_off_disc_prod_id := p_ozf_excl_rec.parent_off_disc_prod_id;
6005 l_ozf_prod_rec.product_level := p_ozf_excl_rec.product_level;
6006 l_ozf_prod_rec.product_id := p_ozf_excl_rec.product_id;
6007 l_ozf_prod_rec.excluder_flag := 'Y';
6008
6009 open c_prod_info(p_ozf_excl_rec.parent_off_disc_prod_id);
6010 fetch c_prod_info into l_prod_rec;
6011 close c_prod_info;
6012 l_ozf_prod_rec.offer_id := l_prod_rec.offer_id;
6013 l_ozf_prod_rec.offer_discount_line_id := l_prod_rec.offer_discount_line_id;
6014
6015 IF l_ozf_prod_rec.parent_off_disc_prod_id = FND_API.G_MISS_NUM OR l_ozf_prod_rec.parent_off_disc_prod_id IS NULL THEN
6016 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PARENT_OFF_DISC_PROD_ID' );
6017 x_return_status := FND_API.g_ret_sts_error;
6018 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6019 RAISE FND_API.G_EXC_ERROR;
6020 END IF;
6021 END IF;
6022
6023 IF ozf_utility_pvt.check_fk_exists('OZF_OFFER_DISCOUNT_PRODUCTS','OFF_DISCOUNT_PRODUCT_ID',to_char(l_ozf_prod_rec.parent_off_disc_prod_id)) = FND_API.g_false THEN
6024 OZF_Utility_PVT.Error_Message('FK_Non_exist' ); -- correct message
6025 x_return_status := FND_API.g_ret_sts_error;
6026 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6027 RAISE FND_API.G_EXC_ERROR;
6028 END IF;
6029 END IF;
6030
6031
6032 check_parent_off_disc_prod(x_return_status , l_ozf_prod_rec );
6033
6034 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6035 RAISE FND_API.G_EXC_ERROR;
6036 END IF;
6037
6038
6039
6040 Create_Product
6041 (
6042 p_api_version_number => p_api_version_number,
6043 p_init_msg_list => p_init_msg_list,
6044 p_commit => p_commit,
6045 p_validation_level => p_validation_level,
6046
6047 x_return_status => x_return_status,
6048 x_msg_count => x_msg_count,
6049 x_msg_data => x_msg_data,
6050
6051 p_ozf_prod_rec => l_ozf_prod_rec,
6052 x_off_discount_product_id => x_off_discount_product_id
6053 );
6054
6055 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6056 RAISE FND_API.G_EXC_ERROR;
6057 END IF;
6058
6059
6060 -- Custom Code here
6061 EXCEPTION
6062 WHEN FND_API.G_EXC_ERROR THEN
6063 ROLLBACK TO Create_Product_Exclusion_PVT;
6064 x_return_status := FND_API.G_RET_STS_ERROR;
6065 -- Standard call to get message count and if count=1, get the message
6066 FND_MSG_PUB.Count_And_Get (
6067 p_encoded => FND_API.G_FALSE,
6068 p_count => x_msg_count,
6069 p_data => x_msg_data
6070 );
6071
6072 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6073 ROLLBACK TO Create_Product_Exclusion_PVT;
6074 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6075 -- Standard call to get message count and if count=1, get the message
6076 FND_MSG_PUB.Count_And_Get (
6077 p_encoded => FND_API.G_FALSE,
6078 p_count => x_msg_count,
6079 p_data => x_msg_data
6080 );
6081
6082 WHEN OTHERS THEN
6083 ROLLBACK TO Create_Product_Exclusion_PVT;
6087 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
6084 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6085 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6086 THEN
6088 END IF;
6089 -- Standard call to get message count and if count=1, get the message
6090 FND_MSG_PUB.Count_And_Get (
6091 p_encoded => FND_API.G_FALSE,
6092 p_count => x_msg_count,
6093 p_data => x_msg_data
6094 );
6095 END Create_product_exclusion;
6096
6097 PROCEDURE Update_Product_Exclusion(
6098 p_api_version_number IN NUMBER,
6099 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
6100 p_commit IN VARCHAR2 := FND_API.G_FALSE,
6101 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
6102
6103 x_return_status OUT NOCOPY VARCHAR2,
6104 x_msg_count OUT NOCOPY NUMBER,
6105 x_msg_data OUT NOCOPY VARCHAR2,
6106
6107 p_ozf_excl_rec IN ozf_excl_rec_type
6108 )
6109 IS
6110 l_api_name CONSTANT VARCHAR2(30) := 'Update_Product_Exclusion';
6111 l_api_version_number CONSTANT NUMBER := 1.0;
6112
6113 -- l_return_status VARCHAR2(30);
6114 l_msg_count NUMBER;
6115 l_msg_data VARCHAR2(2000);
6116 l_off_discount_product_id NUMBER;
6117 l_prod_reln_id NUMBER;
6118 l_prod_reln_rec prod_reln_rec_type ;
6119 l_ozf_prod_rec ozf_prod_rec_type ;
6120
6121 CURSOR C_ozf_prod_rec(p_off_discount_product_id NUMBER)IS
6122 SELECT * FROM ozf_offer_discount_products
6123 WHERE off_discount_product_id = p_off_discount_product_id;
6124
6125 l_ref_ozf_prod_rec C_ozf_prod_rec%rowtype;
6126
6127 BEGIN
6128 SAVEPOINT Update_Product_Exclusion_PVT;
6129
6130 -- Standard call to check for call compatibility.
6131 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
6132 p_api_version_number,
6133 l_api_name,
6134 G_PKG_NAME)
6135 THEN
6136 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6137 END IF;
6138
6139
6140 -- Initialize message list if p_init_msg_list is set to TRUE.
6141 IF FND_API.to_Boolean( p_init_msg_list )
6142 THEN
6143 FND_MSG_PUB.initialize;
6144 END IF;
6145
6146
6147 -- Debug Message
6148 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
6149
6150 -- Initialize API return status to SUCCESS
6151 x_return_status := FND_API.G_RET_STS_SUCCESS;
6152
6153 OPEN C_ozf_prod_rec(p_ozf_excl_rec.off_discount_product_id);
6154 FETCH C_ozf_prod_rec INTO l_ref_ozf_prod_rec;
6155 CLOSE C_ozf_prod_rec;
6156
6157 If (p_ozf_excl_rec.object_version_number is NULL or
6158 p_ozf_excl_rec.object_version_number = FND_API.G_MISS_NUM ) Then
6159 OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
6160 p_token_name => 'COLUMN',
6161 p_token_value => 'Last_Update_Date') ;
6162 raise FND_API.G_EXC_ERROR;
6163 End if;
6164 -- Check Whether record has been changed by someone else
6165 If (p_ozf_excl_rec.object_version_number <> l_ref_ozf_prod_rec.object_version_number) Then
6166 OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
6167 p_token_name => 'INFO',
6168 p_token_value => 'Create_Ozf_Prod_Line') ;
6169 raise FND_API.G_EXC_ERROR;
6170 End if;
6171
6172 /* If (p_ozf_prod_rec.excluder_flag <> 'Y' ) Then
6173 OZF_Utility_PVT.Error_Message(p_message_name => 'NOT EXCLUSION') ;
6174 raise FND_API.G_EXC_ERROR;
6175 End if;
6176 */
6177
6178
6179 l_ozf_prod_rec.off_discount_product_id := p_ozf_excl_rec.off_discount_product_id;
6180 l_ozf_prod_rec.product_level := p_ozf_excl_rec.product_level;
6181 l_ozf_prod_rec.product_id := p_ozf_excl_rec.product_id;
6182 l_ozf_prod_rec.object_version_number := p_ozf_excl_rec.object_version_number;
6183
6184 Update_Product
6185 (
6186 p_api_version_number => p_api_version_number,
6187 p_init_msg_list => p_init_msg_list,
6188 p_commit => p_commit,
6189 p_validation_level => p_validation_level,
6190
6191 x_return_status => x_return_status,
6192 x_msg_count => x_msg_count,
6193 x_msg_data => x_msg_data,
6194 p_ozf_prod_rec => l_ozf_prod_rec
6195 );
6196
6197
6198 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6199 RAISE FND_API.G_EXC_ERROR;
6200 END IF;
6201
6202 EXCEPTION
6203 WHEN FND_API.G_EXC_ERROR THEN
6204 ROLLBACK TO Update_Product_Exclusion_PVT;
6205 x_return_status := FND_API.G_RET_STS_ERROR;
6206 -- Standard call to get message count and if count=1, get the message
6207 FND_MSG_PUB.Count_And_Get (
6208 p_encoded => FND_API.G_FALSE,
6209 p_count => x_msg_count,
6210 p_data => x_msg_data
6211 );
6212
6213 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6214 ROLLBACK TO Update_Product_Exclusion_PVT;
6215 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6216 -- Standard call to get message count and if count=1, get the message
6217 FND_MSG_PUB.Count_And_Get (
6218 p_encoded => FND_API.G_FALSE,
6219 p_count => x_msg_count,
6220 p_data => x_msg_data
6221 );
6222
6223 WHEN OTHERS THEN
6224 ROLLBACK TO Update_Product_Exclusion_PVT;
6228 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
6225 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6226 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6227 THEN
6229 END IF;
6230 -- Standard call to get message count and if count=1, get the message
6231 FND_MSG_PUB.Count_And_Get (
6232 p_encoded => FND_API.G_FALSE,
6233 p_count => x_msg_count,
6234 p_data => x_msg_data
6235 );
6236
6237 END Update_Product_Exclusion;
6238
6239
6240
6241 PROCEDURE check_parent_disc(x_return_status OUT NOCOPY VARCHAR2
6242 , p_tier_rec IN ozf_offer_tier_rec_type
6243 )
6244 IS
6245 CURSOR c_tier_level(p_offer_id NUMBER) IS
6246 SELECT tier_level FROM ozf_offers
6247 WHERE offer_id = p_offer_id;
6248 l_tier_level ozf_offers.tier_level%type;
6249
6250 CURSOR C_SQL ( p_offer_discount_line_id NUMBER) IS
6251 SELECT 1 FROM dual WHERE EXISTS
6252 (
6253 SELECT 1 FROM OZF_OFFER_DISCOUNT_LINES
6254 WHERE offer_discount_line_id = p_offer_discount_line_id
6255 AND tier_type = 'PBH'
6256 );
6257 l_count NUMBER:= 0;
6258 BEGIN
6259 x_return_status := FND_API.G_RET_STS_SUCCESS;
6260 OPEN c_tier_level(p_tier_rec.offer_id);
6261 FETCH c_tier_level INTO l_tier_level;
6262 close c_tier_level;
6263
6264 IF l_tier_level <> 'HEADER' THEN
6265
6266 OPEN C_SQL( p_tier_rec.parent_discount_line_id);
6267 fetch c_sql INTO l_count;
6268 CLOSE C_SQL;
6269
6270 IF l_count = 0 THEN
6271 ozf_utility_pvt.error_message('INVALID_parent_disc_offer');
6272 x_return_status := FND_API.g_ret_sts_error;
6273 ELSE
6274 x_return_status := FND_API.G_RET_STS_SUCCESS;
6275 END IF;
6276 END IF;
6277 END check_parent_disc;
6278
6279
6280
6281 PROCEDURE populate_disc_rec(p_disc_rec IN OUT NOCOPY ozf_offer_line_rec_type,
6282 p_tier_rec IN ozf_offer_tier_rec_type )
6283 IS
6284 BEGIN
6285 p_disc_rec.offer_discount_line_id := p_tier_rec.offer_discount_line_id;
6286 p_disc_rec.parent_discount_line_id:= p_tier_rec.parent_discount_line_id;
6287 p_disc_rec.volume_from := p_tier_rec.volume_from;
6288 p_disc_rec.volume_to := p_tier_rec.volume_to ;
6289 p_disc_rec.volume_operator := 'BETWEEN';
6290 p_disc_rec.volume_type := p_tier_rec.volume_type ;
6291 p_disc_rec.volume_break_type := 'POINT';
6292 p_disc_rec.discount := p_tier_rec.discount ;
6293 p_disc_rec.discount_type := p_tier_rec.discount_type ;
6294 p_disc_rec.start_date_active := p_tier_rec.start_date_active ;
6295 p_disc_rec.end_date_active := p_tier_rec.end_date_active ;
6296 p_disc_rec.uom_code := p_tier_rec.uom_code ;
6297 p_disc_rec.object_version_number := p_tier_rec.object_version_number ;
6298 -- p_disc_rec.offer_id := p_tier_rec.offer_id;
6299 END;
6300
6301 PROCEDURE complete_disc_tier_rec(p_disc_rec IN OUT NOCOPY ozf_offer_line_rec_type
6302 ,p_tier_rec IN ozf_offer_tier_rec_type
6303 ,x_return_status OUT NOCOPY VARCHAR2
6304 )
6305 IS
6306 CURSOR c_tier_level (p_offer_id NUMBER)
6307 is
6308 SELECT tier_level FROM ozf_offers
6309 where offer_id = p_offer_id;
6310 l_tier_level ozf_offers.tier_level%type;
6311 BEGIN
6312 x_return_status := FND_API.g_ret_sts_success;
6313 p_disc_rec.tier_type := 'DIS';
6314 p_disc_rec.offer_id := p_tier_rec.offer_id;
6315 open c_tier_level(p_tier_rec.offer_id);
6316 fetch c_tier_level into l_tier_level;
6317 close c_tier_level;
6318 IF l_tier_level IS NULL THEN
6319 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6320 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6321 End If;
6322 p_disc_rec.tier_level := l_tier_level;
6323 -- If (SQL%NOTFOUND) then
6324 END complete_disc_tier_rec;
6325
6326
6327 PROCEDURE check_line_level_tiers(
6328 p_tier_rec IN ozf_offer_tier_rec_type,
6329 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
6330 x_return_status OUT NOCOPY VARCHAR2
6331 )
6332 IS
6333 CURSOR c_tier_level(p_offer_id NUMBER) IS
6334 SELECT tier_level FROM ozf_offers
6335 WHERE offer_id = p_offer_id;
6336 l_tier_level VARCHAR2(30);
6337
6338 BEGIN
6339 x_return_status := FND_API.g_ret_sts_success;
6340 OPEN c_tier_level(p_tier_rec.offer_id);
6341 fetch c_tier_level into l_tier_level;
6342 close c_tier_level;
6343
6344 If l_tier_level IS NULL then
6345 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6346 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6347 End If;
6348
6349 IF l_tier_level <> 'HEADER' THEN
6350 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
6351 IF p_tier_rec.parent_discount_line_id = FND_API.g_miss_num OR p_tier_rec.parent_discount_line_id IS NULL THEN -- change check for parent tiers
6352 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PARENT_DISCOUNT_LINE_ID' );
6353 x_return_status := FND_API.g_ret_sts_error;
6354 END IF;
6355 ELSE
6356 IF p_tier_rec.parent_discount_line_id = FND_API.g_miss_num THEN
6357 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'PARENT_DISCOUNT_LINE_ID' );
6358 x_return_status := FND_API.g_ret_sts_error;
6359 END IF;
6360 END IF;
6361 END IF;
6362
6363 END check_line_level_tiers;
6364
6368 x_return_status OUT NOCOPY VARCHAR2
6365 PROCEDURE check_tier_Req_Items(
6366 p_tier_rec IN ozf_offer_tier_rec_type,
6367 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
6369 )
6370 IS
6371 BEGIN
6372 x_return_status := FND_API.g_ret_sts_success;
6373
6374 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
6375
6376 IF p_tier_rec.volume_from = FND_API.g_miss_num OR p_tier_rec.volume_from IS NULL THEN
6377 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_FROM' );
6378 x_return_status := FND_API.g_ret_sts_error;
6379 END IF;
6380
6381
6382 IF p_tier_rec.volume_to = FND_API.g_miss_num OR p_tier_rec.volume_to IS NULL THEN
6383 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TO' );
6384 x_return_status := FND_API.g_ret_sts_error;
6385 END IF;
6386 /*
6387 IF p_tier_rec.volume_operator = FND_API.g_miss_char OR p_tier_rec.volume_operator IS NULL THEN
6388 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_OPERATOR' );
6389 x_return_status := FND_API.g_ret_sts_error;
6390 END IF;
6391 */
6392 IF p_tier_rec.volume_type = FND_API.g_miss_char OR p_tier_rec.volume_type IS NULL THEN
6393 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TYPE' );
6394 x_return_status := FND_API.g_ret_sts_error;
6395 END IF;
6396 /*
6397 IF p_tier_rec.volume_break_type = FND_API.g_miss_char OR p_tier_rec.volume_break_type IS NULL THEN
6398 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_BREAK_TYPE' );
6399 x_return_status := FND_API.g_ret_sts_error;
6400 END IF;
6401 */
6402 ELSE
6403 IF p_tier_rec.volume_from = FND_API.g_miss_num THEN
6404 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_FROM' );
6405 x_return_status := FND_API.g_ret_sts_error;
6406 END IF;
6407
6408
6409 IF p_tier_rec.volume_to = FND_API.g_miss_num THEN
6410 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TO' );
6411 x_return_status := FND_API.g_ret_sts_error;
6412 END IF;
6413 /*
6414 IF p_tier_rec.volume_operator = FND_API.g_miss_char THEN
6415 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_OPERATOR' );
6416 x_return_status := FND_API.g_ret_sts_error;
6417 END IF;
6418 */
6419 IF p_tier_rec.volume_type = FND_API.g_miss_char THEN
6420 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_TYPE' );
6421 x_return_status := FND_API.g_ret_sts_error;
6422 END IF;
6423 /*
6424 IF p_tier_rec.volume_break_type = FND_API.g_miss_char THEN
6425 OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'VOLUME_BREAK_TYPE' );
6426 x_return_status := FND_API.g_ret_sts_error;
6427 END IF; */
6428 END IF;
6429 ozf_utility_pvt.debug_message('@# Ending check tier req items : return status '||x_return_status);
6430 check_line_level_tiers( p_tier_rec , p_validation_mode , x_return_status);
6431 END check_tier_Req_Items;
6432
6433 PROCEDURE check_uom(
6434 p_tier_rec IN ozf_offer_tier_rec_type,
6435 p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
6436 x_return_status OUT NOCOPY VARCHAR2
6437 )
6438 IS
6439 g_qty VARCHAR2(30):= 'PRICING_ATTRIBUTE10';
6440 g_amt VARCHAR2(30):= 'PRICING_ATTRIBUTE12';
6441 BEGIN
6442 x_return_status := FND_API.G_RET_STS_SUCCESS;
6446 OZF_Utility_PVT.Error_Message('OZF_ACT_PRD_NO_UOM' );
6443 IF p_validation_mode = JTF_PLSQL_API.g_create THEN
6444 IF p_tier_rec.volume_type = g_qty THEN
6445 IF p_tier_rec.uom_code IS NULL OR p_tier_rec.uom_code = FND_API.G_MISS_CHAR THEN
6447 x_return_status := FND_API.g_ret_sts_error;
6448 END IF;
6449 END IF;
6450 ELSE
6451 IF p_tier_rec.volume_type = g_qty THEN
6452 IF p_tier_rec.uom_code = FND_API.G_MISS_CHAR THEN
6453 OZF_Utility_PVT.Error_Message('OZF_ACT_PRD_NO_UOM' );
6454 x_return_status := FND_API.g_ret_sts_error;
6455 END IF;
6456 END IF;
6457 END IF;
6458 END check_uom;
6459
6460
6461 PROCEDURE Create_Disc_Tiers(
6462 p_api_version_number IN NUMBER,
6463 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
6464 p_commit IN VARCHAR2 := FND_API.G_FALSE,
6465 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
6466
6467 x_return_status OUT NOCOPY VARCHAR2,
6468 x_msg_count OUT NOCOPY NUMBER,
6469 x_msg_data OUT NOCOPY VARCHAR2,
6470
6471 p_tier_rec IN ozf_offer_tier_rec_type ,
6472 x_offer_discount_line_id OUT NOCOPY NUMBER
6473 )
6474 IS
6475
6476 l_api_name CONSTANT VARCHAR2(30) := 'Create_Disc_tiers';
6477 l_api_version_number CONSTANT NUMBER := 1.0;
6478
6479 -- l_return_status VARCHAR2(30);
6483 SELECT * FROM ozf_offer_discount_lines
6480
6481 /* l_offer_line_rec ozf_offer_line_rec_type;
6482 CURSOR C_ozf_disc_rec(p_offer_discount_line_id NUMBER)IS
6484 WHERE offer_discount_line_id = p_offer_discount_line_id;
6485
6486 l_ozf_disc_rec C_ozf_disc_rec%rowtype;
6487 */
6488 l_disc_rec ozf_offer_line_rec_type;
6489 l_tier_rec ozf_offer_tier_rec_type := p_tier_rec;
6490 BEGIN
6491 SAVEPOINT Create_Disc_tiers_PVT;
6492
6493 -- Standard call to check for call compatibility.
6494 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
6495 p_api_version_number,
6496 l_api_name,
6497 G_PKG_NAME)
6498 THEN
6499 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6500 END IF;
6501
6502
6503 -- Initialize message list if p_init_msg_list is set to TRUE.
6504 IF FND_API.to_Boolean( p_init_msg_list )
6505 THEN
6506 FND_MSG_PUB.initialize;
6507 END IF;
6508
6509
6510 -- Debug Message
6511 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
6512
6513 -- Initialize API return status to SUCCESS
6514 x_return_status := FND_API.G_RET_STS_SUCCESS;
6515 -- bug 3402308 populate volume_operator and volume_break_type befoer checking required items
6516 l_tier_rec.volume_operator := 'BETWEEN';
6517 l_tier_rec.volume_break_type := 'POINT';
6518 -- end comment
6519 check_parent_disc(x_return_status => x_return_status -- not required for header tiers
6520 , p_tier_rec => l_tier_rec
6521 );
6522 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6523 RAISE FND_API.G_EXC_ERROR;
6524 END IF;
6525 check_tier_Req_Items(-- change for header level tiers
6526 p_tier_rec => l_tier_rec,
6527 p_validation_mode => JTF_PLSQL_API.g_create,
6528 x_return_status => x_return_status
6529 );
6530 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6531 RAISE FND_API.G_EXC_ERROR;
6532 END IF;
6533 check_uom(
6534 p_tier_rec => l_tier_rec,
6535 p_validation_mode => JTF_PLSQL_API.g_create,
6536 x_return_status => x_return_status
6537 );
6538
6539 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6540 RAISE FND_API.G_EXC_ERROR;
6541 END IF;
6542 ozf_utility_pvt.debug_message('@# After Calling Check UOM : '||x_return_status);
6543
6544 /* OPEN C_ozf_disc_rec(p_tier_rec.parent_discount_line_id);
6545 fetch C_ozf_disc_rec into l_ozf_disc_rec ;
6546 CLOSE C_ozf_disc_rec;
6547 */
6548 populate_disc_rec(p_disc_rec => l_disc_rec,p_tier_rec => l_tier_rec);
6549 complete_disc_tier_rec(p_disc_rec => l_disc_rec,p_tier_rec => l_tier_rec,x_return_status => x_return_status);
6550 ozf_utility_pvt.debug_message('#@Completed Rec'||x_return_status);
6551 Create_Ozf_Disc_Line(
6552 p_api_version_number => p_api_version_number,
6553 p_init_msg_list => p_init_msg_list,
6554 p_commit => p_commit,
6555 p_validation_level => p_validation_level,
6556 x_return_status => x_return_status,
6557 x_msg_count => x_msg_count,
6558 x_msg_data => x_msg_data,
6559 p_ozf_offer_line_rec =>l_disc_rec,
6560 x_offer_discount_line_id => x_offer_discount_line_id
6561 );
6562 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6563 RAISE FND_API.G_EXC_ERROR;
6564 END IF;
6565 ozf_utility_pvt.debug_message('@# After Calling Create Disc Line : '||x_return_status);
6566 EXCEPTION
6567 WHEN FND_API.G_EXC_ERROR THEN
6568 ROLLBACK TO Create_Disc_tiers_PVT;
6569 x_return_status := FND_API.G_RET_STS_ERROR;
6570 -- Standard call to get message count and if count=1, get the message
6571 FND_MSG_PUB.Count_And_Get (
6572 p_encoded => FND_API.G_FALSE,
6573 p_count => x_msg_count,
6574 p_data => x_msg_data
6575 );
6576
6577 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6578 ROLLBACK TO Create_Disc_tiers_PVT;
6579 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6580 -- Standard call to get message count and if count=1, get the message
6581 FND_MSG_PUB.Count_And_Get (
6582 p_encoded => FND_API.G_FALSE,
6583 p_count => x_msg_count,
6584 p_data => x_msg_data
6585 );
6586
6587 WHEN OTHERS THEN
6588 ROLLBACK TO Create_Disc_tiers_PVT;
6589 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6590 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6591 THEN
6592 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
6593 END IF;
6594 -- Standard call to get message count and if count=1, get the message
6595 FND_MSG_PUB.Count_And_Get (
6599 );
6596 p_encoded => FND_API.G_FALSE,
6597 p_count => x_msg_count,
6598 p_data => x_msg_data
6600
6601 END Create_Disc_Tiers;
6602
6603
6604 PROCEDURE Update_Disc_Tiers(
6605 p_api_version_number IN NUMBER,
6606 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
6607 p_commit IN VARCHAR2 := FND_API.G_FALSE,
6608 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
6609
6610 x_return_status OUT NOCOPY VARCHAR2,
6611 x_msg_count OUT NOCOPY NUMBER,
6612 x_msg_data OUT NOCOPY VARCHAR2,
6613
6614 p_tier_rec IN ozf_offer_tier_rec_type
6615 )
6616 IS
6617 l_api_name CONSTANT VARCHAR2(30) := 'Create_Disc_tiers';
6618 l_api_version_number CONSTANT NUMBER := 1.0;
6619
6620 -- l_return_status VARCHAR2(30);
6621
6622 /* l_offer_line_rec ozf_offer_line_rec_type;
6623 CURSOR C_ozf_disc_rec(p_offer_discount_line_id NUMBER)IS
6624 SELECT * FROM ozf_offer_discount_lines
6625 WHERE offer_discount_line_id = p_offer_discount_line_id;
6626
6627 l_ozf_disc_rec C_ozf_disc_rec%rowtype;
6628 */
6629 l_disc_rec ozf_offer_line_rec_type;
6630 l_tier_rec ozf_offer_tier_rec_type := p_tier_rec;
6631 BEGIN
6632 SAVEPOINT Create_Disc_tiers_PVT;
6633
6634 -- Standard call to check for call compatibility.
6635 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
6636 p_api_version_number,
6637 l_api_name,
6638 G_PKG_NAME)
6639 THEN
6640 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6641 END IF;
6642
6643
6644 -- Initialize message list if p_init_msg_list is set to TRUE.
6645 IF FND_API.to_Boolean( p_init_msg_list )
6646 THEN
6647 FND_MSG_PUB.initialize;
6648 END IF;
6649
6650
6651 -- Debug Message
6652 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
6653
6654 -- Initialize API return status to SUCCESS
6655 x_return_status := FND_API.G_RET_STS_SUCCESS;
6656
6657
6658 ---
6659 -- bug 3402308 populate volume_operator and volume_break_type befoer checking required items
6660 l_tier_rec.volume_operator := 'BETWEEN';
6661 l_tier_rec.volume_break_type := 'POINT';
6662 -- end comment
6663
6667 x_return_status => x_return_status
6664 check_tier_Req_Items(
6665 p_tier_rec => l_tier_rec,
6666 p_validation_mode => JTF_PLSQL_API.g_update,
6668 );
6669 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6670 RAISE FND_API.G_EXC_ERROR;
6671 END IF;
6672 check_uom(
6673 p_tier_rec => l_tier_rec,
6674 p_validation_mode => JTF_PLSQL_API.g_update,
6675 x_return_status => x_return_status
6676 );
6677
6678 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6679 RAISE FND_API.G_EXC_ERROR;
6680 END IF;
6681 populate_disc_rec(p_disc_rec => l_disc_rec,p_tier_rec => l_tier_rec);
6682 complete_disc_tier_rec(p_disc_rec => l_disc_rec,p_tier_rec => l_tier_rec , x_return_status => x_return_status);
6683
6684 Update_Ozf_Disc_Line(
6685 p_api_version_number => p_api_version_number,
6686 p_init_msg_list => p_init_msg_list,
6687 p_commit => p_commit,
6688 p_validation_level => p_validation_level,
6689 x_return_status => x_return_status,
6690 x_msg_count => x_msg_count,
6691 x_msg_data => x_msg_data,
6692 p_ozf_offer_line_rec =>l_disc_rec
6693 );
6694
6695 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6696 RAISE FND_API.G_EXC_ERROR;
6697 END IF;
6698
6699
6700
6701
6702 EXCEPTION
6703 WHEN FND_API.G_EXC_ERROR THEN
6704 ROLLBACK TO Create_Disc_tiers_PVT;
6705 x_return_status := FND_API.G_RET_STS_ERROR;
6706 -- Standard call to get message count and if count=1, get the message
6707 FND_MSG_PUB.Count_And_Get (
6708 p_encoded => FND_API.G_FALSE,
6709 p_count => x_msg_count,
6710 p_data => x_msg_data
6711 );
6712
6713 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6714 ROLLBACK TO Create_Disc_tiers_PVT;
6715 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6716 -- Standard call to get message count and if count=1, get the message
6717 FND_MSG_PUB.Count_And_Get (
6718 p_encoded => FND_API.G_FALSE,
6719 p_count => x_msg_count,
6720 p_data => x_msg_data
6721 );
6722
6723 WHEN OTHERS THEN
6724 ROLLBACK TO Create_Disc_tiers_PVT;
6725 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6726 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6727 THEN
6728 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
6729 END IF;
6730 -- Standard call to get message count and if count=1, get the message
6731 FND_MSG_PUB.Count_And_Get (
6732 p_encoded => FND_API.G_FALSE,
6733 p_count => x_msg_count,
6734 p_data => x_msg_data
6735 );
6736
6737 END Update_Disc_tiers;
6738
6739 PROCEDURE Delete_Disc_tiers(
6740 p_api_version_number IN NUMBER,
6741 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
6742 p_commit IN VARCHAR2 := FND_API.G_FALSE,
6743 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
6744
6745 x_return_status OUT NOCOPY VARCHAR2,
6746 x_msg_count OUT NOCOPY NUMBER,
6747 x_msg_data OUT NOCOPY VARCHAR2,
6748
6749 p_parent_discount_line_id IN NUMBER
6750 )
6751 IS
6752 l_api_name CONSTANT VARCHAR2(30) := 'Delete_Disc_tiers';
6753 l_api_version_number CONSTANT NUMBER := 1.0;
6754
6755 -- l_return_status VARCHAR2(30);
6756
6757 CURSOR C_PARENT_DISC_LINE(p_offer_discount_line_id NUMBER )IS
6758 SELECT * FROM ozf_offer_discount_lines
6759 WHERE offer_discount_line_id = p_offer_discount_line_id;
6760
6761 l_parent_disc_line C_PARENT_DISC_LINE%rowtype;
6762
6763 BEGIN
6764 SAVEPOINT Delete_Disc_tiers_PVT;
6765
6769 l_api_name,
6766 -- Standard call to check for call compatibility.
6767 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
6768 p_api_version_number,
6770 G_PKG_NAME)
6771 THEN
6772 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6773 END IF;
6774
6775
6776 -- Initialize message list if p_init_msg_list is set to TRUE.
6777 IF FND_API.to_Boolean( p_init_msg_list )
6778 THEN
6779 FND_MSG_PUB.initialize;
6780 END IF;
6781
6782
6786 -- Initialize API return status to SUCCESS
6783 -- Debug Message
6784 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
6785
6787 x_return_status := FND_API.G_RET_STS_SUCCESS;
6788
6789
6790 OPEN C_PARENT_DISC_LINE(p_parent_discount_line_id);
6791 FETCH C_PARENT_DISC_LINE INTO l_parent_disc_line;
6792 CLOSE C_PARENT_DISC_LINE;
6793
6794 IF l_parent_disc_line.tier_type <> 'PBH' THEN
6795 OZF_UTILITY_PVT.ERROR_MESSAGE('PARENT_NOT_PBH');
6796 RAISE FND_API.G_EXC_ERROR;
6797 END IF;
6798
6799 OZF_DISC_LINE_PKG.delete_tiers(p_parent_discount_line_id);
6800 --
6801 EXCEPTION
6802 WHEN FND_API.G_EXC_ERROR THEN
6803 ROLLBACK TO Delete_Disc_tiers_PVT;
6804 x_return_status := FND_API.G_RET_STS_ERROR;
6805 -- Standard call to get message count and if count=1, get the message
6806 FND_MSG_PUB.Count_And_Get (
6807 p_encoded => FND_API.G_FALSE,
6808 p_count => x_msg_count,
6809 p_data => x_msg_data
6810 );
6811
6812 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6813 ROLLBACK TO Delete_Disc_tiers_PVT;
6814 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6815 -- Standard call to get message count and if count=1, get the message
6816 FND_MSG_PUB.Count_And_Get (
6817 p_encoded => FND_API.G_FALSE,
6818 p_count => x_msg_count,
6819 p_data => x_msg_data
6820 );
6821
6822 WHEN OTHERS THEN
6823 ROLLBACK TO Delete_Disc_tiers_PVT;
6824 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6825 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6826 THEN
6827 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
6828 END IF;
6829 -- Standard call to get message count and if count=1, get the message
6830 FND_MSG_PUB.Count_And_Get (
6831 p_encoded => FND_API.G_FALSE,
6832 p_count => x_msg_count,
6833 p_data => x_msg_data
6834 );
6835
6836 END Delete_Disc_tiers;
6837
6838
6839
6840 -- ==============================================================================
6841 -- Start of Comments
6842 -- ==============================================================================
6843 -- API Name
6844 -- Delete_tier_line
6845 -- Type
6846 -- Private
6847 -- Pre-Req
6848 -- Delete_Product,delete_Ozf_Disc_Line
6849 -- Parameters
6850 --
6851 -- IN
6852 -- p_api_version_number IN NUMBER Required
6853 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API_G_FALSE
6854 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
6855 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
6856 -- p_offer_discount_line_id IN NUMBER Required Discount Line id to be deleted
6857 -- p_object_version_number IN NUMBER Required Object Version No. Of Discount Line to be deleted
6858 --
6859 -- OUT
6860 -- x_return_status OUT VARCHAR2
6861 -- x_msg_count OUT NUMBER
6862 -- x_msg_data OUT VARCHAR2
6863 -- x_off_discount_product_id OUT NUMBER
6864 -- Version : Current version 1.0
6865 --
6866 -- History
6867 -- Wed Oct 01 2003:5/21 PM RSSHARMA Created
6868 --
6869 -- Description
6870 -- : Helper method to Hard Delete a Discount Line and all the Related Product Lines and relations.
6871 -- End of Comments
6872 -- ==============================================================================
6873
6874 PROCEDURE Delete_Tier_line(
6875 p_api_version_number IN NUMBER,
6876 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
6877 p_commit IN VARCHAR2 := FND_API.G_FALSE,
6878 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
6879
6880 x_return_status OUT NOCOPY VARCHAR2,
6881 x_msg_count OUT NOCOPY NUMBER,
6882 x_msg_data OUT NOCOPY VARCHAR2,
6883
6884 p_offer_discount_line_id IN NUMBER,
6885 p_object_version_number IN NUMBER
6886 )
6887 IS
6888 l_api_name CONSTANT VARCHAR2(30) := 'Delete_tier_line';
6889 l_api_version_number CONSTANT NUMBER := 1.0;
6890
6891
6892 CURSOR c_tier_level(p_offer_discount_line_id NUMBER)
6893 is
6894 SELECT tier_level FROM ozf_offers where offer_id =
6895 (SELECT offer_id FROM ozf_offer_discount_lines
6896 WHERE offer_discount_line_id = p_offer_discount_line_id );
6897
6898 l_tier_level ozf_offers.tier_level%type;
6899
6900 BEGIN
6901 SAVEPOINT Delete_tier_line_Pvt;
6902
6903 -- Standard call to check for call compatibility.
6904 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
6905 p_api_version_number,
6906 l_api_name,
6907 G_PKG_NAME)
6908 THEN
6909 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6910 END IF;
6911
6912
6913 -- Initialize message list if p_init_msg_list is set to TRUE.
6914 IF FND_API.to_Boolean( p_init_msg_list )
6915 THEN
6916 FND_MSG_PUB.initialize;
6917 END IF;
6918
6919
6920 -- Debug Message
6921 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
6922
6923 -- Initialize API return status to SUCCESS
6924 x_return_status := FND_API.G_RET_STS_SUCCESS;
6925
6926 open c_tier_level(p_offer_discount_line_id);
6927 fetch c_tier_level into l_tier_level;
6931 If l_tier_level IS NULL then
6928 close c_tier_level;
6929
6930
6932 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6933 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6934 End If;
6935
6936 IF l_tier_level <> 'HEADER' THEN
6937 OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_NOT_HEADER_TIER');
6941 delete_Ozf_Disc_Line
6938 RAISE FND_API.G_EXC_ERROR;
6939 END IF;
6940
6942 (
6943 p_api_version_number => p_api_version_number,
6944 p_init_msg_list => p_init_msg_list,
6945 p_commit => p_commit,
6946 p_validation_level => p_validation_level,
6947 x_return_status => x_return_status,
6948 x_msg_count => x_msg_count,
6949 x_msg_data => x_msg_data,
6950 p_offer_discount_line_id => p_offer_discount_line_id,
6951 p_object_version_number => p_object_version_number
6952 );
6953
6954 IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
6955 RAISE FND_API.G_EXC_ERROR;
6956 END IF;
6957
6958 IF FND_API.to_Boolean( p_commit )
6959 THEN
6960 COMMIT WORK;
6961 END IF;
6962
6963
6964 -- Debug Message
6965 OZF_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'end');
6966
6967
6968 -- Standard call to get message count and if count is 1, get message info.
6969 FND_MSG_PUB.Count_And_Get
6970 (p_count => x_msg_count,
6971 p_data => x_msg_data
6972 );
6973
6974 EXCEPTION
6975 WHEN FND_API.G_EXC_ERROR THEN
6976 ROLLBACK TO Delete_tier_line_pvt;
6977 x_return_status := FND_API.G_RET_STS_ERROR;
6978 -- Standard call to get message count and if count=1, get the message
6979 FND_MSG_PUB.Count_And_Get (
6980 p_encoded => FND_API.G_FALSE,
6981 p_count => x_msg_count,
6982 p_data => x_msg_data
6983 );
6984
6985 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6986 ROLLBACK TO Delete_tier_line_pvt;
6987 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6988 -- Standard call to get message count and if count=1, get the message
6989 FND_MSG_PUB.Count_And_Get (
6993 );
6990 p_encoded => FND_API.G_FALSE,
6991 p_count => x_msg_count,
6992 p_data => x_msg_data
6994
6995 WHEN OTHERS THEN
6996 ROLLBACK TO Delete_tier_line_pvt;
6997 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6998 IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6999 THEN
7000 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
7001 END IF;
7002 -- Standard call to get message count and if count=1, get the message
7003 FND_MSG_PUB.Count_And_Get (
7004 p_encoded => FND_API.G_FALSE,
7005 p_count => x_msg_count,
7006 p_data => x_msg_data
7007 );
7008 END Delete_Tier_line;
7009
7010 --=================End Complete Methods ==================================================
7011 END OZF_Disc_Line_PVT;