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