DBA Data[Home] [Help]

PACKAGE BODY: APPS.OZF_OFFER_ADJUSTMENT_PVT

Source


1 PACKAGE BODY OZF_OFFER_ADJUSTMENT_PVT as
2 /* $Header: ozfvoadb.pls 120.6.12010000.2 2009/12/03 08:42:41 nepanda ship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 --          OZF_Offer_Adjustment_PVT
7 -- Purpose
8 --
9 -- History
10 --   Thu Mar 30 2006:1/23 PM RSSHARMA New Adjustment changes. While activating, user offer_backdate api to get final status and budget updated flag.
11 --  Mon May 22 2006:12/1 PM RSSHARMA Fixed debug to print only on debug high
12 -- Tue Aug 15 2006:3/26 PM RSSHARMA Fixed bug # 5468261. Fixed query for if_lines_exist
13 -- Thu Dec 3rd 2009 NEPANDA : fix for bug 9149865
14 -- NOTE
15 --
16 -- This Api is generated with Latest version of
17 -- Rosetta, where g_miss indicates NULL and
18 -- NULL indicates missing value. Rosetta Version 1.55
19 -- End of Comments
20 -- ===============================================================
21 
22 
23 G_PKG_NAME CONSTANT VARCHAR2(30):= 'OZF_Offer_Adjustment_PVT';
24 G_FILE_NAME CONSTANT VARCHAR2(12) := 'ozfvoadb.pls';
25 
26 -- G_USER_ID         NUMBER := FND_GLOBAL.USER_ID;
27 -- G_LOGIN_ID        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
28 --
29 -- Foreward Procedure Declarations
30 --
31 
32 PROCEDURE Default_Offer_Adj_Items (
33    p_offer_adj_rec IN  offer_adj_rec_type ,
34    x_offer_adj_rec OUT NOCOPY offer_adj_rec_type
35 ) ;
36 
37 
38 
39 --   ==============================================================================
40 --    Start of Comments
41 --   ==============================================================================
42 --   API Name
43 --           get_budget_start_date
44 --   Type
45 --           Private
46 --   Pre-Req
47 --
48 --   Parameters
49 --
50 --   IN
51 --       p_qp_list_header_id      IN   NUMBER     Required
52 --
53 --   RETURNS
54 --       Min Start Date of all the budgets attached to the offer
55 --   History
56 --   Thu May 27 2004:2/29 PM RSSJARMA Created
57 --   NOTE
58 --      Concious decision to return min start date as this makes sure that all the budgets are active by the date of adjustment
59 --   End of Comments
60 --   ==============================================================================
61 FUNCTION get_budget_start_date
62 ( p_qp_list_header_id IN NUMBER)
63 RETURN DATE
64 IS
65 CURSOR c_budget_start_date(p_qp_list_header_id NUMBER) is
66 SELECT MIN(start_date_active) FROM ozf_funds_all_b
67 WHERE fund_id IN ( SELECT budget_source_id FROM ozf_act_budgets where arc_act_budget_used_by = 'OFFR' and act_budget_used_by_id = p_qp_list_header_id);
68 l_budget_start_date DATE;
69 BEGIN
70 OPEN c_budget_start_date(p_qp_list_header_id );
71 FETCH c_budget_start_date INTO l_budget_start_date;
72 CLOSE c_budget_start_date;
73 RETURN l_budget_start_date;
74 END get_budget_start_date;
75 
76 FUNCTION isBudgetOffer(p_listHeaderId NUMBER)
77 RETURN VARCHAR2
78 IS
79 CURSOR c_budgetOffer(cp_listHeaderId NUMBER) IS
80 SELECT nvl(budget_offer_yn,'N')
81 FROM ozf_offers
82 WHERE qp_list_header_id = cp_listHeaderId;
83 l_budgetOffer VARCHAR2(1);
84 BEGIN
85 OPEN c_budgetOffer(cp_listHeaderId => p_listHeaderId);
86 FETCH c_budgetOffer INTO l_budgetOffer;
87 IF c_budgetOffer%NOTFOUND THEN
88     l_budgetOffer := 'U';
89 END IF;
90 CLOSE c_budgetOffer;
91 return l_budgetOffer;
92 END isBudgetOffer;
93 
94 
95 PROCEDURE raise_event(p_id IN NUMBER)
96 IS
97 l_item_key varchar2(30);
98 l_parameter_list wf_parameter_list_t;
99 BEGIN
100   l_item_key := p_id ||'_'|| TO_CHAR(SYSDATE,'DDMMRRRRHH24MISS');
101   l_parameter_list := WF_PARAMETER_LIST_T();
102 
103 OZF_Offer_Adj_Line_PVT.debug_message('Id is :'||p_id );
104   wf_event.AddParameterToList(p_name           => 'P_ID',
105                               p_value          => p_id,
106                               p_parameterlist  => l_parameter_list);
107 OZF_Offer_Adj_Line_PVT.debug_message('Item Key is  :'||l_item_key);
108   wf_event.raise( p_event_name => 'oracle.apps.ozf.offer.OfferAdjApproval',
109                   p_event_key  => l_item_key,
110                   p_parameters => l_parameter_list);
111 EXCEPTION
112 WHEN OTHERS THEN
113 RAISE Fnd_Api.g_exc_error;
114 OZF_Offer_Adj_Line_PVT.debug_message('Exception in raising business event');
115 END;
116 
117 -- Hint: Primary key needs to be returned.
118 --   ==============================================================================
119 --    Start of Comments
120 --   ==============================================================================
121 --   API Name
122 --           Create_Offer_Adjustment
123 --   Type
124 --           Private
125 --   Pre-Req
126 --
127 --   Parameters
128 --
129 --   IN
130 --       p_api_version_number      IN   NUMBER     Required
131 --       p_init_msg_list           IN   VARCHAR2   Optional  Default = FND_API_G_FALSE
132 --       p_commit                  IN   VARCHAR2   Optional  Default = FND_API.G_FALSE
133 --       p_validation_level        IN   NUMBER     Optional  Default = FND_API.G_VALID_LEVEL_FULL
134 --       p_offer_adj_rec           IN   offer_adj_rec_type  Required
135 --
136 --   OUT
137 --       x_return_status           OUT  VARCHAR2
138 --       x_msg_count               OUT  NUMBER
139 --       x_msg_data                OUT  VARCHAR2
140 --   Version : Current version 1.0
141 --   Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
142 --         and basic operation, developer must manually add parameters and business logic as necessary.
143 --
144 --   History
145 --
146 --   NOTE
147 --
148 --   End of Comments
149 --   ==============================================================================
150 
151 PROCEDURE Create_Offer_Adjustment(
152     p_api_version_number         IN   NUMBER,
153     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
154     p_commit                     IN   VARCHAR2     := FND_API.G_FALSE,
155     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
156 
157     x_return_status              OUT NOCOPY  VARCHAR2,
158     x_msg_count                  OUT NOCOPY  NUMBER,
159     x_msg_data                   OUT NOCOPY  VARCHAR2,
160 
161     p_offer_adj_rec              IN   offer_adj_rec_type  := g_miss_offer_adj_rec,
162     x_offer_adjustment_id              OUT NOCOPY  NUMBER
163      )
164 
165  IS
166 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Create_Offer_Adjustment';
167 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
168    l_return_status_full        VARCHAR2(1);
169    l_object_version_number     NUMBER := 1;
170    l_org_id                    NUMBER := FND_API.G_MISS_NUM;
171    l_offer_adjustment_id       NUMBER;
172    l_dummy                     NUMBER;
173    CURSOR c_id IS
174       SELECT ozf_offer_adjustments_b_s.NEXTVAL
175       FROM dual;
176 
177    CURSOR c_id_exists (l_id IN NUMBER) IS
178       SELECT 1
179       FROM OZF_OFFER_ADJUSTMENTS_B
180       WHERE offer_adjustment_id = l_id;
181 BEGIN
182       -- Standard Start of API savepoint
183       SAVEPOINT create_offer_adjustment_pvt;
184 
185       -- Standard call to check for call compatibility.
186       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
187                                            p_api_version_number,
188                                            l_api_name,
189                                            G_PKG_NAME)
190       THEN
191           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
192       END IF;
193 
194 
195       -- Initialize message list if p_init_msg_list is set to TRUE.
196       IF FND_API.to_Boolean( p_init_msg_list )
197       THEN
198          FND_MSG_PUB.initialize;
199       END IF;
200 
201 
202 
203       -- Debug Message
204       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'start');
205 
206 
207 
208       -- Initialize API return status to SUCCESS
209       x_return_status := FND_API.G_RET_STS_SUCCESS;
210 
211    -- Local variable initialization
212 
213    IF p_offer_adj_rec.offer_adjustment_id IS NULL OR p_offer_adj_rec.offer_adjustment_id = FND_API.g_miss_num THEN
214       LOOP
215          l_dummy := NULL;
216          OPEN c_id;
217          FETCH c_id INTO l_offer_adjustment_id;
218          CLOSE c_id;
219 
220          OPEN c_id_exists(l_offer_adjustment_id);
221          FETCH c_id_exists INTO l_dummy;
222          CLOSE c_id_exists;
223          EXIT WHEN l_dummy IS NULL;
224       END LOOP;
225    ELSE
226          l_offer_adjustment_id := p_offer_adj_rec.offer_adjustment_id;
227    END IF;
228 
229 --  OZF_Offer_Adj_Line_PVT.debug_message('Private API: offer_adjustment_id: '  || p_offer_adj_rec.offer_adjustment_id || '::l_offer_adjustment_id: '||l_offer_adjustment_id);    -- sangara
230 
231       -- =========================================================================
232       -- Validate Environment
233       -- =========================================================================
234 
235       IF FND_GLOBAL.USER_ID IS NULL
236       THEN
237          OZF_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
238           RAISE FND_API.G_EXC_ERROR;
239       END IF;
240 
241 
242 
243       IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
244       THEN
245           -- Debug message
246           OZF_Offer_Adj_Line_PVT.debug_message('Private API: Validate_Offer_Adjustment');
247 
248           -- Invoke validation procedures
249           Validate_offer_adjustment(
250             p_api_version_number     => 1.0,
251             p_init_msg_list    => FND_API.G_FALSE,
252             p_validation_level => p_validation_level,
253             p_validation_mode => JTF_PLSQL_API.g_create,
254             p_offer_adj_rec  =>  p_offer_adj_rec,
255             x_return_status    => x_return_status,
256             x_msg_count        => x_msg_count,
257             x_msg_data         => x_msg_data);
258       END IF;
259 
260       IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
261           RAISE FND_API.G_EXC_ERROR;
262       END IF;
263 
264 
265       -- Debug Message
266       OZF_Offer_Adj_Line_PVT.debug_message( 'Private API: Calling create table handler ');
267 
268       -- Invoke table handler(OZF_Offer_Adjustment_Pkg.Insert_Row)
269       OZF_Offer_Adjustment_Pkg.Insert_Row(
270           px_offer_adjustment_id  => l_offer_adjustment_id,
271           p_effective_date  => p_offer_adj_rec.effective_date,
272           p_approved_date  => p_offer_adj_rec.approved_date,
273           p_settlement_code  => p_offer_adj_rec.settlement_code,
274           p_status_code  => p_offer_adj_rec.status_code,
275           p_list_header_id  => p_offer_adj_rec.list_header_id,
276           p_version  => p_offer_adj_rec.version,
277           p_budget_adjusted_flag  => p_offer_adj_rec.budget_adjusted_flag,
278           p_last_update_date  => SYSDATE,
279           p_last_updated_by  => FND_GLOBAL.USER_ID,
280           p_creation_date  => SYSDATE,
281           p_created_by  => FND_GLOBAL.USER_ID,
282           p_last_update_login  => FND_GLOBAL.conc_login_id,
283           px_object_version_number  => l_object_version_number,
284           p_attribute1  => p_offer_adj_rec.attribute1,
285           p_attribute2  => p_offer_adj_rec.attribute2,
286           p_attribute3  => p_offer_adj_rec.attribute3,
287           p_attribute4  => p_offer_adj_rec.attribute4,
288           p_attribute5  => p_offer_adj_rec.attribute5,
289           p_attribute6  => p_offer_adj_rec.attribute6,
290           p_attribute7  => p_offer_adj_rec.attribute7,
291           p_attribute8  => p_offer_adj_rec.attribute8,
292           p_attribute9  => p_offer_adj_rec.attribute9,
293           p_attribute10  => p_offer_adj_rec.attribute10,
294           p_attribute11  => p_offer_adj_rec.attribute11,
295           p_attribute12  => p_offer_adj_rec.attribute12,
296           p_attribute13  => p_offer_adj_rec.attribute13,
297           p_attribute14  => p_offer_adj_rec.attribute14,
298           p_attribute15  => p_offer_adj_rec.attribute15
299           ,p_offer_adjustment_name  => p_offer_adj_rec.offer_adjustment_name,
300           p_description  => p_offer_adj_rec.description
301 );
302 
303           x_offer_adjustment_id := l_offer_adjustment_id;
304       IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
305           RAISE FND_API.G_EXC_ERROR;
306       END IF;
307 --
308 -- End of API body
309 --
310 
311       -- Standard check for p_commit
312       IF FND_API.to_Boolean( p_commit )
313       THEN
314      --    OZF_Offer_Adj_Line_PVT.debug_message('Problemo hereo: ');
315       --    RAISE FND_API.G_EXC_ERROR;
316          COMMIT WORK;
317        END IF;
318 
319 
320       -- Debug Message
321       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'end');
322 
323 
324       -- Standard call to get message count and if count is 1, get message info.
325       FND_MSG_PUB.Count_And_Get
326         (p_count          =>   x_msg_count,
327          p_data           =>   x_msg_data
328       );
329 EXCEPTION
330 
331    WHEN OZF_Utility_PVT.resource_locked THEN
332      x_return_status := FND_API.g_ret_sts_error;
333          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
334 
335    WHEN FND_API.G_EXC_ERROR THEN
336      ROLLBACK TO CREATE_Offer_Adjustment_PVT;
337      x_return_status := FND_API.G_RET_STS_ERROR;
338      -- Standard call to get message count and if count=1, get the message
339      FND_MSG_PUB.Count_And_Get (
340             p_encoded => FND_API.G_FALSE,
341             p_count   => x_msg_count,
342             p_data    => x_msg_data
343      );
344 
345    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
346      ROLLBACK TO CREATE_Offer_Adjustment_PVT;
347      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
348      -- Standard call to get message count and if count=1, get the message
349      FND_MSG_PUB.Count_And_Get (
350             p_encoded => FND_API.G_FALSE,
351             p_count => x_msg_count,
352             p_data  => x_msg_data
353      );
354 
355    WHEN OTHERS THEN
356      ROLLBACK TO CREATE_Offer_Adjustment_PVT;
357      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
358      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
359      THEN
360         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
361      END IF;
362      -- Standard call to get message count and if count=1, get the message
363      FND_MSG_PUB.Count_And_Get (
364             p_encoded => FND_API.G_FALSE,
365             p_count => x_msg_count,
366             p_data  => x_msg_data
367      );
368 End Create_Offer_Adjustment;
369 
370 
371 --   ==============================================================================
372 --    Start of Comments
373 --   ==============================================================================
374 --   API Name
375 --           Update_Offer_Adjustment
376 --   Type
377 --           Private
378 --   Pre-Req
379 --
380 --   Parameters
381 --
382 --   IN
383 --       p_api_version_number      IN   NUMBER     Required
384 --       p_init_msg_list           IN   VARCHAR2   Optional  Default = FND_API_G_FALSE
385 --       p_commit                  IN   VARCHAR2   Optional  Default = FND_API.G_FALSE
386 --       p_validation_level        IN   NUMBER     Optional  Default = FND_API.G_VALID_LEVEL_FULL
387 --       p_offer_adj_rec            IN   offer_adj_rec_type  Required
388 --
389 --   OUT
390 --       x_return_status           OUT  VARCHAR2
391 --       x_msg_count               OUT  NUMBER
392 --       x_msg_data                OUT  VARCHAR2
393 --   Version : Current version 1.0
394 --   Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
395 --         and basic operation, developer must manually add parameters and business logic as necessary.
396 --
397 --   History
398 --
399 --   NOTE
400 --
401 --   End of Comments
402 --   ==============================================================================
403 
404 PROCEDURE Update_Offer_Adjustment(
405     p_api_version_number         IN   NUMBER,
406     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
407     p_commit                     IN   VARCHAR2     := FND_API.G_FALSE,
408     p_validation_level           IN  NUMBER       := FND_API.G_VALID_LEVEL_FULL,
409 
410     x_return_status              OUT NOCOPY  VARCHAR2,
411     x_msg_count                  OUT NOCOPY  NUMBER,
412     x_msg_data                   OUT NOCOPY  VARCHAR2,
413 
414     p_offer_adj_rec              IN    offer_adj_rec_type,
415     x_object_version_number      OUT NOCOPY  NUMBER
416     )
417 
418  IS
419 
420 
421 CURSOR c_get_offer_adjustment(offer_adjustment_id NUMBER) IS
422     SELECT *
423     FROM  OZF_OFFER_ADJUSTMENTS_B
424     WHERE  offer_adjustment_id = p_offer_adj_rec.offer_adjustment_id;
425     -- Hint: Developer need to provide Where clause
426 
427 
428 CURSOR c_if_lines_exist(p_offer_adjustment_id NUMBER) IS
429     select 1
430     from ozf_offer_adjustment_lines
431     where offer_adjustment_id = p_offer_adjustment_id
432     union
433     select 1
434     from ozf_offer_adjustment_tiers
435     where offer_adjustment_id=  p_offer_adjustment_id
436     union
437     SELECT 1
438     FROM ozf_offer_adj_new_lines
439     WHERE offer_adjustment_id = p_offer_adjustment_id
440     UNION
441     SELECT 1
442     FROM ozf_offer_adjustment_products
443     WHERE offer_adjustment_id = p_offer_adjustment_id;
444 
445 
446 -- code added by mthumu
447 CURSOR c_get_offer_status(p_offer_adjustment_id NUMBER) IS
448     SELECT status_code
449     FROM  ozf_offer_adjustments_b
450     WHERE  offer_adjustment_id = p_offer_adjustment_id ;
451 -- end mthumu
452 
453 CURSOR c_custom_setup_id(p_list_header_id NUMBER) IS
454      SELECT custom_setup_id ,NVL(budget_offer_yn, 'N')
455     FROM ozf_offers
456     WHERE qp_list_header_id=p_list_header_id;
457 -- code to get custom setup for approval
458 CURSOR c_attr_available_flag(p_custom_setup_id NUMBER) IS
459     SELECT attr_available_flag
460     FROM ams_custom_setup_attr
461     WHERE custom_setup_id = p_custom_setup_id
462       AND object_attribute = 'ADJA';
463 
464 CURSOR c_backdate_flag(p_list_header_id NUMBER, p_offer_adjustment_id NUMBER, p_effective_date DATE) IS
465     SELECT 1
466     FROM OZF_OFFER_ADJUSTMENTS_VL
467     WHERE (p_effective_date<SYSDATE)
468           AND list_header_id = p_list_header_id
469                 AND offer_adjustment_id = p_offer_adjustment_id;
470 
471 
472 -- end of code
473 
474 l_custom_setup_id    NUMBER;
475 l_budget_offer_yn    VARCHAR2(1);
476 l_attr_available_flag    VARCHAR2(1);
477 l_backdate_flag        VARCHAR2(1);
478 
479 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Update_Offer_Adjustment';
480 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
481 -- Local Variables
482 l_object_version_number     NUMBER;
483 l_offer_adjustment_id        NUMBER;
484 l_ref_offer_adj_rec  c_get_Offer_Adjustment%ROWTYPE ;
485 l_tar_offer_adj_rec  offer_adj_rec_type := P_offer_adj_rec;
486 l_rowid  ROWID;
487 l_if_lines_exist        NUMBER;
488 
489 
490 -- code added by mthumu
491 l_current_status_code VARCHAR2(30);
492 l_new_status_code     VARCHAR2(30);
493 l_approve_date          DATE;
494 l_budgetAdjFlag     VARCHAR2(1);
495 -- end mthumu
496 
497  BEGIN
498       -- Standard Start of API savepoint
499       SAVEPOINT update_offer_adjustment_pvt;
500 
501       -- Standard call to check for call compatibility.
502       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
503                                            p_api_version_number,
504                                            l_api_name,
505                                            G_PKG_NAME)
506       THEN
507           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
508       END IF;
509 
510 
511       -- Initialize message list if p_init_msg_list is set to TRUE.
512       IF FND_API.to_Boolean( p_init_msg_list )
513       THEN
514          FND_MSG_PUB.initialize;
515       END IF;
516 
517 
518 
519       -- Debug Message
520       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'start');
521 
522 
523       -- Initialize Object_Version_Number
524       l_object_version_number := p_offer_adj_rec.object_version_number ;
525 
526       -- Initialize API return status to SUCCESS
527       x_return_status := FND_API.G_RET_STS_SUCCESS;
528 
529       -- Debug Message
530       OZF_Offer_Adj_Line_PVT.debug_message('Private API: - Open Cursor to Select');
531 
532       OPEN c_get_Offer_Adjustment( l_tar_offer_adj_rec.offer_adjustment_id);
533 
534       FETCH c_get_Offer_Adjustment INTO l_ref_offer_adj_rec  ;
535 
536        If ( c_get_Offer_Adjustment%NOTFOUND) THEN
537        OZF_Utility_PVT.Error_Message(p_message_name => 'API_MISSING_UPDATE_TARGET',
538         p_token_name   => 'INFO',
539         p_token_value  => 'Offer_Adjustment') ;
540            RAISE FND_API.G_EXC_ERROR;
541        END IF;
542 
543        -- Debug Message
544        OZF_Offer_Adj_Line_PVT.debug_message('Private API: - Close Cursor');
545        CLOSE     c_get_Offer_Adjustment;
546 
547 
548       If (l_tar_offer_adj_rec.object_version_number is NULL or
549           l_tar_offer_adj_rec.object_version_number = FND_API.G_MISS_NUM ) Then
550     OZF_Utility_PVT.Error_Message(p_message_name => 'API_VERSION_MISSING',
551        p_token_name   => 'COLUMN',
552        p_token_value  => 'Last_Update_Date') ;
553         raise FND_API.G_EXC_ERROR;
554       End if;
555 
556 
557       -- Check Whether record has been changed by someone else
558 
559       If (l_tar_offer_adj_rec.object_version_number <> l_ref_offer_adj_rec.object_version_number) Then
560     OZF_Utility_PVT.Error_Message(p_message_name => 'API_RECORD_CHANGED',
561         p_token_name   => 'INFO',
562         p_token_value  => 'Offer_Adjustment') ;
563         raise FND_API.G_EXC_ERROR;
564       End if;
565 
566 
567       IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL)
568       THEN
569           -- Debug message
570           OZF_Offer_Adj_Line_PVT.debug_message('Private API: Validate_Offer_Adjustment');
571 
572           -- Invoke validation procedures
573           Validate_offer_adjustment(
574             p_api_version_number     => 1.0,
575             p_init_msg_list    => FND_API.G_FALSE,
576             p_validation_level => p_validation_level,
577             p_validation_mode => JTF_PLSQL_API.g_update,
578             p_offer_adj_rec  =>  p_offer_adj_rec,
579             x_return_status    => x_return_status,
580             x_msg_count        => x_msg_count,
581             x_msg_data         => x_msg_data);
582       END IF;
583 
584       IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
585           RAISE FND_API.G_EXC_ERROR;
586       END IF;
587 
588      -- code added by mthumu to call the budget approval
589     OPEN c_get_offer_status(p_offer_adj_rec.offer_adjustment_id);
590     FETCH c_get_offer_status INTO l_current_status_code;
591     CLOSE c_get_offer_status;
592 
593     l_new_status_code := p_offer_adj_rec.status_code;
594 
595     IF    ( l_current_status_code <> l_new_status_code )
596     THEN
597 
598        IF ( l_new_status_code = 'ACTIVE' )
599        THEN
600 
601         -- Submit
602         OPEN c_if_lines_exist( p_offer_adj_rec.offer_adjustment_id );
603         FETCH c_if_lines_exist INTO l_if_lines_exist;
604         CLOSE c_if_lines_exist;
605 
606         IF l_if_lines_exist IS NULL THEN
607             OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFRADJ_DISCRULE');
608 
609             RAISE FND_API.G_EXC_ERROR;
610         END IF;
611 
612         -- Call Approval Work Flow
613         -- Select attr_available_flag
614         -- from ams_custom_setup_attr
615         -- where custom_setup_id = 91
616         -- and object_attribute = 'ADJA';
617 
618         -- have to get the custom setup from offers table from another cursor
619 
620         -- IF attr_available_flag= 'Y' Then
621         --  call workflow;
622         -- else
623         --  call update offer discounts; ( API as shown below)
624         -- end if;
625 
626 
627         OPEN c_custom_setup_id( p_offer_adj_rec.list_header_id );
628         FETCH c_custom_setup_id INTO l_custom_setup_id, l_budget_offer_yn;
629         CLOSE c_custom_setup_id;
630 
631         OPEN c_attr_available_flag(l_custom_setup_id);
632         FETCH c_attr_available_flag INTO l_attr_available_flag;
633         CLOSE c_attr_available_flag;
634 
635       raise_event(p_id => p_offer_adj_rec.offer_adjustment_id );
636         OZF_Offer_Adj_Line_PVT.debug_message(' l_attr_available_flag ' || l_attr_available_flag);
637         -- mthumu approve date fix
638         l_new_status_code := 'ACTIVE';
639         l_approve_date := sysdate;
640 
641         IF l_budget_offer_yn = 'Y' THEN
642           AMS_GEN_APPROVAL_PVT.StartProcess
643           (p_activity_type  => 'FAB_ADJ'
644           ,p_activity_id    => p_offer_adj_rec.offer_adjustment_id
645           ,p_approval_type  => 'BUDGET'
646           ,p_object_version_number  =>p_offer_adj_rec.object_version_number
647           ,p_orig_stat_id           => 0
648           ,p_new_stat_id            => 0
649           ,p_reject_stat_id         => 0
650           ,p_requester_userid       => OZF_Utility_PVT.get_resource_id(NVL(FND_GLOBAL.user_id,-1))
651           ,p_notes_from_requester   => p_offer_adj_rec.description
652           ,p_workflowprocess        => 'AMSGAPP'
653           ,p_item_type              => 'AMSGAPP');
654 
655           l_new_status_code := 'PENDING';
656         ELSIF l_attr_available_flag = 'Y' THEN
657             AMS_GEN_APPROVAL_PVT.StartProcess
658              (p_activity_type  => 'OFFR'
659               ,p_activity_id    => p_offer_adj_rec.offer_adjustment_id
660               ,p_approval_type  => 'BUDGET'
661               ,p_object_version_number  =>p_offer_adj_rec.object_version_number
662               ,p_orig_stat_id           => 0
663               ,p_new_stat_id            => 0
664               ,p_reject_stat_id         => 0
665               ,p_requester_userid       => OZF_Utility_PVT.get_resource_id(NVL(FND_GLOBAL.user_id,-1))
666               ,p_notes_from_requester   => p_offer_adj_rec.description
667               ,p_workflowprocess        => 'AMSGAPP'
668               ,p_item_type              => 'AMSGAPP');
669 
670                l_new_status_code := 'PENDING';
671          ELSE
672             OZF_Offer_Backdate_PVT.Update_Offer_Discounts (
673                                                             p_init_msg_list => FND_API.G_FALSE
674                                                             ,p_api_version   => 1.0
675                                                             ,p_commit        =>  FND_API.G_FALSE
676                                                             ,x_return_status => x_return_status
677                                                             ,x_msg_count     => x_msg_count
678                                                             ,x_msg_data      => x_msg_data
679                                                             ,p_offer_adjustment_id  => p_offer_adj_rec.offer_adjustment_id
680 --                                                            ,p_close_adj     => 'Y'
681                                                             ) ;
682             IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
683                  RAISE FND_API.G_EXC_ERROR;
684             END IF;
685             OZF_Offer_Backdate_PVT.getCloseAdjustmentParams
686                 (
687                     p_offer_adjustment_id  => p_offer_adj_rec.offer_adjustment_id
688                     ,x_return_status => x_return_status
689                     ,x_msg_count     => x_msg_count
690                     ,x_msg_data      => x_msg_data
691                     ,x_newStatus     => l_new_status_code
692                     ,x_budgetAdjFlag => l_budgetAdjFlag
693                 );
694             IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
695                  RAISE FND_API.G_EXC_ERROR;
696             END IF;
697         END IF;
698        END IF;
699     END IF;
700      -- end of code mthumu
701       -- Debug Message
702       OZF_Offer_Adj_Line_PVT.debug_message(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW||'Private API: Calling update table handler');
703       -- Invoke table handler(OZF_Offer_Adjustment_Pkg.Update_Row)
704       OZF_Offer_Adjustment_Pkg.Update_Row(
705           p_offer_adjustment_id  => p_offer_adj_rec.offer_adjustment_id,
706           p_effective_date  => p_offer_adj_rec.effective_date,
707           p_approved_date  => l_approve_date,--p_offer_adj_rec.approved_date,
708           p_settlement_code  => p_offer_adj_rec.settlement_code,
709           p_status_code  => l_new_status_code,  -- p_offer_adj_rec.status_code,
710           p_list_header_id  => p_offer_adj_rec.list_header_id,
711           p_version  => p_offer_adj_rec.version,
712           p_budget_adjusted_flag  => l_budgetAdjFlag,
713           p_last_update_date  => SYSDATE,
714           p_last_updated_by  => FND_GLOBAL.USER_ID,
715           p_last_update_login  => FND_GLOBAL.conc_login_id,
716           px_object_version_number  => l_object_version_number,
717           p_attribute1  => p_offer_adj_rec.attribute1,
718           p_attribute2  => p_offer_adj_rec.attribute2,
719           p_attribute3  => p_offer_adj_rec.attribute3,
720           p_attribute4  => p_offer_adj_rec.attribute4,
721           p_attribute5  => p_offer_adj_rec.attribute5,
722           p_attribute6  => p_offer_adj_rec.attribute6,
723           p_attribute7  => p_offer_adj_rec.attribute7,
724           p_attribute8  => p_offer_adj_rec.attribute8,
725           p_attribute9  => p_offer_adj_rec.attribute9,
726           p_attribute10  => p_offer_adj_rec.attribute10,
727           p_attribute11  => p_offer_adj_rec.attribute11,
728           p_attribute12  => p_offer_adj_rec.attribute12,
729           p_attribute13  => p_offer_adj_rec.attribute13,
730           p_attribute14  => p_offer_adj_rec.attribute14,
731           p_attribute15  => p_offer_adj_rec.attribute15
732           ,p_offer_adjustment_name  => p_offer_adj_rec.offer_adjustment_name,
733           p_description  => p_offer_adj_rec.description
734 );
735 
736    x_object_version_number := l_object_version_number;
737       --
738       -- End of API body.
739       --
740       IF FND_API.to_Boolean( p_commit )
741       THEN
742          COMMIT WORK;
743       END IF;
744       -- Debug Message
745       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'end');
746 EXCEPTION
747    WHEN OZF_Utility_PVT.resource_locked THEN
748      x_return_status := FND_API.g_ret_sts_error;
749          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
750    WHEN FND_API.G_EXC_ERROR THEN
751      ROLLBACK TO UPDATE_Offer_Adjustment_PVT;
752      x_return_status := FND_API.G_RET_STS_ERROR;
753      -- Standard call to get message count and if count=1, get the message
754      FND_MSG_PUB.Count_And_Get (
755             p_encoded => FND_API.G_FALSE,
756             p_count   => x_msg_count,
757             p_data    => x_msg_data
758      );
759    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
760      ROLLBACK TO UPDATE_Offer_Adjustment_PVT;
761      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
762      -- Standard call to get message count and if count=1, get the message
763      FND_MSG_PUB.Count_And_Get (
764             p_encoded => FND_API.G_FALSE,
765             p_count => x_msg_count,
766             p_data  => x_msg_data
767      );
768 
769    WHEN OTHERS THEN
770      ROLLBACK TO UPDATE_Offer_Adjustment_PVT;
771      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
772      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
773      THEN
774         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
775      END IF;
776      -- Standard call to get message count and if count=1, get the message
777      FND_MSG_PUB.Count_And_Get (
778             p_encoded => FND_API.G_FALSE,
779             p_count => x_msg_count,
780             p_data  => x_msg_data
781      );
782 End Update_Offer_Adjustment;
783 
784 
785 --   ==============================================================================
786 --    Start of Comments
787 --   ==============================================================================
788 --   API Name
789 --           Delete_Offer_Adjustment
790 --   Type
791 --           Private
792 --   Pre-Req
793 --
794 --   Parameters
795 --
796 --   IN
797 --       p_api_version_number      IN   NUMBER     Required
798 --       p_init_msg_list           IN   VARCHAR2   Optional  Default = FND_API_G_FALSE
799 --       p_commit                  IN   VARCHAR2   Optional  Default = FND_API.G_FALSE
800 --       p_validation_level        IN   NUMBER     Optional  Default = FND_API.G_VALID_LEVEL_FULL
801 --       p_offer_adjustment_id                IN   NUMBER
802 --       p_object_version_number   IN   NUMBER     Optional  Default = NULL
803 --
804 --   OUT
805 --       x_return_status           OUT  VARCHAR2
806 --       x_msg_count               OUT  NUMBER
807 --       x_msg_data                OUT  VARCHAR2
808 --   Version : Current version 1.0
809 --   Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
810 --         and basic operation, developer must manually add parameters and business logic as necessary.
811 --
812 --   History
813 --
814 --   NOTE
815 --
816 --   End of Comments
817 --   ==============================================================================
818 
819 PROCEDURE Delete_Offer_Adjustment(
820     p_api_version_number         IN   NUMBER,
821     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
822     p_commit                     IN   VARCHAR2     := FND_API.G_FALSE,
823     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
824     x_return_status              OUT NOCOPY  VARCHAR2,
825     x_msg_count                  OUT NOCOPY  NUMBER,
826     x_msg_data                   OUT NOCOPY  VARCHAR2,
827     p_offer_adjustment_id                   IN  NUMBER,
828     p_object_version_number      IN   NUMBER
829     )
830 
831  IS
832 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Delete_Offer_Adjustment';
833 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
834 l_object_version_number     NUMBER;
835 
836  BEGIN
837       -- Standard Start of API savepoint
838       SAVEPOINT delete_offer_adjustment_pvt;
839 
840       -- Standard call to check for call compatibility.
841       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
842                                            p_api_version_number,
843                                            l_api_name,
844                                            G_PKG_NAME)
845       THEN
846           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
847       END IF;
848 
849 
850       -- Initialize message list if p_init_msg_list is set to TRUE.
851       IF FND_API.to_Boolean( p_init_msg_list )
852       THEN
853          FND_MSG_PUB.initialize;
854       END IF;
855 
856 
857 
858       -- Debug Message
859       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'start');
860 
861 
862 
863       -- Initialize API return status to SUCCESS
864       x_return_status := FND_API.G_RET_STS_SUCCESS;
865 
866       --
867       -- Api body
868       --
869       -- Debug Message
870       OZF_Offer_Adj_Line_PVT.debug_message( 'Private API: Calling delete table handler');
871 
872       -- Invoke table handler(OZF_Offer_Adjustment_Pkg.Delete_Row)
873       OZF_Offer_Adjustment_Pkg.Delete_Row(
874           p_offer_adjustment_id  => p_offer_adjustment_id,
875           p_object_version_number => p_object_version_number     );
876       --
877       -- End of API body
878       --
879 
880       -- Standard check for p_commit
881       IF FND_API.to_Boolean( p_commit )
882       THEN
883          COMMIT WORK;
884       END IF;
885 
886 
887       -- Debug Message
888       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'end');
889 
890 
891       -- Standard call to get message count and if count is 1, get message info.
892       FND_MSG_PUB.Count_And_Get
893         (p_count          =>   x_msg_count,
894          p_data           =>   x_msg_data
895       );
896 EXCEPTION
897 
898    WHEN OZF_Utility_PVT.resource_locked THEN
899      x_return_status := FND_API.g_ret_sts_error;
900          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
901 
902    WHEN FND_API.G_EXC_ERROR THEN
903      ROLLBACK TO DELETE_Offer_Adjustment_PVT;
904      x_return_status := FND_API.G_RET_STS_ERROR;
905      -- Standard call to get message count and if count=1, get the message
906      FND_MSG_PUB.Count_And_Get (
907             p_encoded => FND_API.G_FALSE,
908             p_count   => x_msg_count,
909             p_data    => x_msg_data
910      );
911 
912    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
913      ROLLBACK TO DELETE_Offer_Adjustment_PVT;
914      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
915      -- Standard call to get message count and if count=1, get the message
916      FND_MSG_PUB.Count_And_Get (
917             p_encoded => FND_API.G_FALSE,
918             p_count => x_msg_count,
919             p_data  => x_msg_data
920      );
921 
922    WHEN OTHERS THEN
923      ROLLBACK TO DELETE_Offer_Adjustment_PVT;
924      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
925      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
926      THEN
927         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
928      END IF;
929      -- Standard call to get message count and if count=1, get the message
930      FND_MSG_PUB.Count_And_Get (
931             p_encoded => FND_API.G_FALSE,
932             p_count => x_msg_count,
933             p_data  => x_msg_data
934      );
935 End Delete_Offer_Adjustment;
936 
937 
938 
939 -- Hint: Primary key needs to be returned.
940 --   ==============================================================================
941 --    Start of Comments
942 --   ==============================================================================
943 --   API Name
944 --           Lock_Offer_Adjustment
945 --   Type
946 --           Private
947 --   Pre-Req
948 --
949 --   Parameters
950 --
951 --   IN
952 --       p_api_version_number      IN   NUMBER     Required
953 --       p_init_msg_list           IN   VARCHAR2   Optional  Default = FND_API_G_FALSE
954 --       p_commit                  IN   VARCHAR2   Optional  Default = FND_API.G_FALSE
955 --       p_validation_level        IN   NUMBER     Optional  Default = FND_API.G_VALID_LEVEL_FULL
956 --       p_offer_adj_rec            IN   offer_adj_rec_type  Required
957 --
958 --   OUT
959 --       x_return_status           OUT  VARCHAR2
960 --       x_msg_count               OUT  NUMBER
961 --       x_msg_data                OUT  VARCHAR2
962 --   Version : Current version 1.0
963 --   Note: This automatic generated procedure definition, it includes standard IN/OUT parameters
964 --         and basic operation, developer must manually add parameters and business logic as necessary.
965 --
966 --   History
967 --
968 --   NOTE
969 --
970 --   End of Comments
971 --   ==============================================================================
972 
973 PROCEDURE Lock_Offer_Adjustment(
974     p_api_version_number         IN   NUMBER,
975     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
976 
977     x_return_status              OUT NOCOPY  VARCHAR2,
978     x_msg_count                  OUT NOCOPY  NUMBER,
979     x_msg_data                   OUT NOCOPY  VARCHAR2,
980 
981     p_offer_adjustment_id                   IN  NUMBER,
982     p_object_version             IN  NUMBER
983     )
984 
985  IS
986 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Lock_Offer_Adjustment';
987 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
988 L_FULL_NAME                 CONSTANT VARCHAR2(60) := g_pkg_name ||'.'|| l_api_name;
989 l_offer_adjustment_id                  NUMBER;
990 
991 BEGIN
992 
993       -- Debug Message
994       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'start');
995 
996 
997       -- Initialize message list if p_init_msg_list is set to TRUE.
998       IF FND_API.to_Boolean( p_init_msg_list )
999       THEN
1000          FND_MSG_PUB.initialize;
1001       END IF;
1002 
1003 
1004 
1005       -- Standard call to check for call compatibility.
1006       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1007                                            p_api_version_number,
1008                                            l_api_name,
1009                                            G_PKG_NAME)
1010       THEN
1011           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1012       END IF;
1013 
1014 
1015 
1016       -- Initialize API return status to SUCCESS
1017       x_return_status := FND_API.G_RET_STS_SUCCESS;
1018 
1019 
1020 ------------------------ lock -------------------------
1021 OZF_Offer_Adjustment_Pkg.Lock_Row(l_offer_adjustment_id,p_object_version);
1022 
1023 
1024  -------------------- finish --------------------------
1025   FND_MSG_PUB.count_and_get(
1026     p_encoded => FND_API.g_false,
1027     p_count   => x_msg_count,
1028     p_data    => x_msg_data);
1029   OZF_Offer_Adj_Line_PVT.debug_message(l_full_name ||': end');
1030 EXCEPTION
1031 
1032    WHEN OZF_Utility_PVT.resource_locked THEN
1033      x_return_status := FND_API.g_ret_sts_error;
1034          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1035 
1036    WHEN FND_API.G_EXC_ERROR THEN
1037      ROLLBACK TO LOCK_Offer_Adjustment_PVT;
1038      x_return_status := FND_API.G_RET_STS_ERROR;
1039      -- Standard call to get message count and if count=1, get the message
1040      FND_MSG_PUB.Count_And_Get (
1041             p_encoded => FND_API.G_FALSE,
1042             p_count   => x_msg_count,
1043             p_data    => x_msg_data
1044      );
1045 
1046    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1047      ROLLBACK TO LOCK_Offer_Adjustment_PVT;
1048      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1049      -- Standard call to get message count and if count=1, get the message
1050      FND_MSG_PUB.Count_And_Get (
1051             p_encoded => FND_API.G_FALSE,
1052             p_count => x_msg_count,
1053             p_data  => x_msg_data
1054      );
1055 
1056    WHEN OTHERS THEN
1057      ROLLBACK TO LOCK_Offer_Adjustment_PVT;
1058      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1059      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1060      THEN
1061         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1062      END IF;
1063      -- Standard call to get message count and if count=1, get the message
1064      FND_MSG_PUB.Count_And_Get (
1065             p_encoded => FND_API.G_FALSE,
1066             p_count => x_msg_count,
1067             p_data  => x_msg_data
1068      );
1069 End Lock_Offer_Adjustment;
1070 
1071 
1072 
1073 
1074 PROCEDURE check_Offer_Adj_Uk_Items(
1075     p_offer_adj_rec               IN   offer_adj_rec_type,
1076     p_validation_mode            IN  VARCHAR2 := JTF_PLSQL_API.g_create,
1077     x_return_status              OUT NOCOPY VARCHAR2)
1078 IS
1079                             -- Cursor to check, if 2 adjustments exist with same effective date
1080    CURSOR c_adj_exists_oncreate (l_objid IN NUMBER, l_effdt IN DATE) IS
1081       SELECT 1
1082       FROM OZF_OFFER_ADJUSTMENTS_B
1083       WHERE list_header_id  = l_objid
1084               AND effective_date = l_effdt
1085         AND status_code NOT IN ('CANCELLED' ,'CLOSED');
1086 
1087    CURSOR c_adj_exists_onupdate (l_objid IN NUMBER, l_adjid IN NUMBER, l_effdt IN DATE) IS
1088       SELECT 1
1089       FROM OZF_OFFER_ADJUSTMENTS_B
1090       WHERE  list_header_id  = l_objid
1091          AND offer_adjustment_id <>  l_adjid
1092               AND effective_date = l_effdt
1093          AND status_code NOT IN ('CANCELLED' ,'CLOSED');
1094 
1095    l_valid_flag  VARCHAR2(1);
1096    l_dup_effective_dt NUMBER;
1097    l_strClosed VARCHAR2(20) := ' ''CLOSED'' ';
1098    l_strTerminated VARCHAR2(20) := ' ''TERMINATED'' ';
1099 
1100 --nepanda : fix for bug 9149865
1101    CURSOR c_check_uniqeness_create
1102      IS
1103      SELECT 1 from ozf_offer_adjustments_vl
1104      WHERE offer_adjustment_name = p_offer_adj_rec.offer_adjustment_name
1105      AND list_header_id = p_offer_adj_rec.list_header_id;
1106 
1107    CURSOR c_check_uniqeness_update
1108       IS
1109       SELECT 1 from ozf_offer_adjustments_vl
1110       WHERE offer_adjustment_name = p_offer_adj_rec.offer_adjustment_name
1111       AND list_header_id = p_offer_adj_rec.list_header_id
1112       AND offer_adjustment_id <> p_offer_adj_rec.offer_adjustment_id;
1113 
1114 BEGIN
1115       x_return_status := FND_API.g_ret_sts_success;
1116       IF p_validation_mode = JTF_PLSQL_API.g_create THEN
1117         OZF_Offer_Adj_Line_PVT.debug_message('Inside Uk_Items::Create');
1118 	--nepanda : fix for bug 9149865
1119 	/*l_valid_flag := OZF_Utility_PVT.check_uniqueness(
1120             ' ozf_offer_adjustments_vl ',
1121             ' list_header_id = '||' '|| p_offer_adj_rec.list_header_id ||
1122             ' AND offer_adjustment_name  ='||' '|| p_offer_adj_rec.offer_adjustment_name||''
1123             );*/
1124 
1125 	    OPEN c_check_uniqeness_create;
1126 		FETCH c_check_uniqeness_create INTO l_valid_flag;
1127 	    CLOSE c_check_uniqeness_create;
1128                                         -- Check for, 2 adjustments with same effective date -sangara
1129 
1130         -- l_dup_effective_dt := OZF_Utility_PVT.check_uniqueness(
1131         --    'ozf_offer_adjustments_b',
1132         --    ' list_header_id  = '||' '|| p_offer_adj_rec.list_header_id ||''||
1133         --    ' AND status_code <> '||' '|| l_strTerminated ||''||
1134         --    ' OR  status_code <> '||' '|| l_strClosed ||''||
1135         --    ' AND effective_date = '||' '|| p_offer_adj_rec.effective_date
1136         --    );
1137 
1138         OPEN c_adj_exists_oncreate(p_offer_adj_rec.list_header_id, p_offer_adj_rec.effective_date);
1139         FETCH c_adj_exists_oncreate INTO l_dup_effective_dt ;
1140         CLOSE c_adj_exists_oncreate;
1141 
1142       ELSE
1143 	--nepanda : fix for bug 9149865
1144 	/* l_valid_flag := OZF_Utility_PVT.check_uniqueness(
1145             ' ozf_offer_adjustments_vl ',
1146             ' list_header_id = '||' '|| p_offer_adj_rec.list_header_id ||
1147             ' AND offer_adjustment_id  <> '||' '|| p_offer_adj_rec.offer_adjustment_id||' '||
1148             ' AND offer_adjustment_name  ='||' '|| p_offer_adj_rec.offer_adjustment_name||''
1149             );*/
1150 
1151     	    OPEN c_check_uniqeness_update;
1152 		FETCH c_check_uniqeness_update INTO l_valid_flag;
1153 	    CLOSE c_check_uniqeness_update;
1154 
1155                                         -- Check for, 2 adjustments with same effective date -sangara
1156         -- l_dup_effective_dt := OZF_Utility_PVT.check_uniqueness(
1157         --    'ozf_offer_adjustments_b',
1158         --    'list_header_id =' ||  p_offer_adj_rec.list_header_id ||
1159         --    ' AND offer_adjustment_id <>  '||' '|| p_offer_adj_rec.offer_adjustment_id||' '||
1160         --    ' AND status_code <> '||' '|| l_strTerminated ||''||
1161         --    ' OR status_code <> '||' '|| l_strClosed ||''||
1162         --    ' AND effective_date = '||' '|| p_offer_adj_rec.effective_date
1163         --    );
1164 
1165 
1166         OPEN c_adj_exists_onupdate(p_offer_adj_rec.list_header_id, p_offer_adj_rec.offer_adjustment_id, p_offer_adj_rec.effective_date);
1167         FETCH c_adj_exists_onupdate INTO l_dup_effective_dt ;
1168         CLOSE c_adj_exists_onupdate;
1169 
1170       END IF;
1171 
1172 
1173       IF l_valid_flag = 1 THEN --FND_API.g_false THEN
1174          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFER_ADJ_NAME_DUP');
1175          x_return_status := FND_API.g_ret_sts_error;
1176       END IF;
1177 
1178       OZF_Offer_Adj_Line_PVT.debug_message('check_Offer_Adj_Uk_Items :: l_dup_effective_dt ' || l_dup_effective_dt  );
1179 
1180       IF l_dup_effective_dt IS NOT NULL THEN
1181        IF l_dup_effective_dt  = 1 THEN                -- Show error, if 2 adjs. with same eff date exists. - sangara
1182         OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_OFFADJ_DUP_EFFDT');
1183         x_return_status := FND_API.g_ret_sts_error;
1184        END IF;
1185        END IF;
1186 
1187 END check_Offer_Adj_Uk_Items;
1188 
1189 
1190 
1191 PROCEDURE check_Offer_Adj_Req_Items(
1192     p_offer_adj_rec               IN  offer_adj_rec_type,
1193     p_validation_mode IN VARCHAR2 := JTF_PLSQL_API.g_create,
1194     x_return_status             OUT NOCOPY VARCHAR2
1195 )
1196 IS
1197 BEGIN
1198    x_return_status := FND_API.g_ret_sts_success;
1199 
1200    IF p_validation_mode = JTF_PLSQL_API.g_create THEN
1201 
1202 
1203   --    IF p_offer_adj_rec.offer_adjustment_id = FND_API.G_MISS_NUM OR p_offer_adj_rec.offer_adjustment_id IS NULL THEN
1204   --             OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_ADJUSTMENT_ID' );
1205   --            x_return_status := FND_API.g_ret_sts_error;
1206   --    END IF;
1207 
1208       -- List Header Id check
1209       IF p_offer_adj_rec.list_header_id = FND_API.G_MISS_NUM OR p_offer_adj_rec.list_header_id IS NULL THEN
1210                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'LIST_HEADER_ID' );
1211                x_return_status := FND_API.g_ret_sts_error;
1212       END IF;
1213 
1214       -- Adjustment Name check
1215       IF p_offer_adj_rec.offer_adjustment_name = FND_API.G_MISS_CHAR OR p_offer_adj_rec.offer_adjustment_name IS NULL THEN
1216                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_ADJUSTMENT_NAME' );
1217                x_return_status := FND_API.g_ret_sts_error;
1218       END IF;
1219 
1220       -- Status Code check
1221       IF p_offer_adj_rec.status_code = FND_API.G_MISS_CHAR OR p_offer_adj_rec.offer_adjustment_name IS NULL THEN
1222                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'STATUS_CODE' );
1223                x_return_status := FND_API.g_ret_sts_error;
1224       END IF;
1225 
1226       -- Effective Date check
1227       IF p_offer_adj_rec.effective_date = FND_API.G_MISS_DATE OR p_offer_adj_rec.effective_date IS NULL THEN
1228                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'EFFECTIVE_DATE' );
1229                x_return_status := FND_API.g_ret_sts_error;
1230       END IF;
1231 
1232    ELSE
1233 
1234       IF p_offer_adj_rec.offer_adjustment_id = FND_API.G_MISS_NUM THEN
1235                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'OFFER_ADJUSTMENT_ID' );
1236                x_return_status := FND_API.g_ret_sts_error;
1237       END IF;
1238 
1239 
1240       IF p_offer_adj_rec.list_header_id = FND_API.G_MISS_NUM THEN
1241                OZF_Utility_PVT.Error_Message('OZF_API_MISSING_FIELD', 'MISS_FIELD', 'LIST_HEADER_ID' );
1242                x_return_status := FND_API.g_ret_sts_error;
1243       END IF;
1244 
1245    END IF;
1246 
1247 END check_Offer_Adj_Req_Items;
1248 
1249 
1250 
1251 PROCEDURE check_Offer_Adj_Fk_Items(
1252     p_offer_adj_rec IN offer_adj_rec_type,
1253     x_return_status OUT NOCOPY VARCHAR2
1254 )
1255 IS
1256 BEGIN
1257    x_return_status := FND_API.g_ret_sts_success;
1258 
1259    -- Enter custom code here
1260 
1261 END check_Offer_Adj_Fk_Items;
1262 
1263 
1264 
1265 PROCEDURE check_Offer_Adj_Lookup_Items(
1266     p_offer_adj_rec IN offer_adj_rec_type,
1267     x_return_status OUT NOCOPY VARCHAR2
1268 )
1269 IS
1270 BEGIN
1271    x_return_status := FND_API.g_ret_sts_success;
1272 
1273    -- Enter custom code here
1274 
1275 END check_Offer_Adj_Lookup_Items;
1276 
1277 
1278 
1279 PROCEDURE Check_Offer_Adj_Items (
1280     P_offer_adj_rec    IN    offer_adj_rec_type,
1281     p_validation_mode  IN    VARCHAR2,
1282     x_return_status    OUT NOCOPY   VARCHAR2
1283     )
1284 IS
1285    l_return_status   VARCHAR2(1);
1286 BEGIN
1287 
1288     l_return_status := FND_API.g_ret_sts_success;
1289    -- Check Items Uniqueness API calls
1290 
1291    check_Offer_adj_Uk_Items(
1292       p_offer_adj_rec => p_offer_adj_rec,
1293       p_validation_mode => p_validation_mode,
1294       x_return_status => x_return_status);
1295    IF x_return_status <> FND_API.g_ret_sts_success THEN
1296       l_return_status := FND_API.g_ret_sts_error;
1297    END IF;
1298 
1299    -- Check Items Required/NOT NULL API calls
1300 
1301    check_offer_adj_req_items(
1302       p_offer_adj_rec => p_offer_adj_rec,
1303       p_validation_mode => p_validation_mode,
1304       x_return_status => x_return_status);
1305    IF x_return_status <> FND_API.g_ret_sts_success THEN
1306       l_return_status := FND_API.g_ret_sts_error;
1307    END IF;
1308    -- Check Items Foreign Keys API calls
1309 
1310    check_offer_adj_FK_items(
1311       p_offer_adj_rec => p_offer_adj_rec,
1312       x_return_status => x_return_status);
1313    IF x_return_status <> FND_API.g_ret_sts_success THEN
1314       l_return_status := FND_API.g_ret_sts_error;
1315    END IF;
1316    -- Check Items Lookups
1317 
1318    check_offer_adj_Lookup_items(
1319       p_offer_adj_rec => p_offer_adj_rec,
1320       x_return_status => x_return_status);
1321    IF x_return_status <> FND_API.g_ret_sts_success THEN
1322       l_return_status := FND_API.g_ret_sts_error;
1323    END IF;
1324 
1325    x_return_status := l_return_status;
1326 
1327 END Check_offer_adj_Items;
1328 
1329 
1330 
1331 
1332 
1333 PROCEDURE Complete_Offer_Adj_Rec (
1334    p_offer_adj_rec IN offer_adj_rec_type,
1335    x_complete_rec OUT NOCOPY offer_adj_rec_type)
1336 IS
1337    l_return_status  VARCHAR2(1);
1338 
1339    CURSOR c_complete IS
1340       SELECT *
1341       FROM ozf_offer_adjustments_b
1342       WHERE offer_adjustment_id = p_offer_adj_rec.offer_adjustment_id;
1343    l_offer_adj_rec c_complete%ROWTYPE;
1344 BEGIN
1345    x_complete_rec := p_offer_adj_rec;
1346 
1347 
1348    OPEN c_complete;
1349    FETCH c_complete INTO l_offer_adj_rec;
1350    CLOSE c_complete;
1351 
1352    -- offer_adjustment_id
1353    IF p_offer_adj_rec.offer_adjustment_id IS NULL THEN
1354       x_complete_rec.offer_adjustment_id := l_offer_adj_rec.offer_adjustment_id;
1355    END IF;
1356 
1357    -- effective_date
1358    IF p_offer_adj_rec.effective_date IS NULL THEN
1359       x_complete_rec.effective_date := l_offer_adj_rec.effective_date;
1360    END IF;
1361 
1362    -- approved_date
1363    IF p_offer_adj_rec.approved_date IS NULL THEN
1364       x_complete_rec.approved_date := l_offer_adj_rec.approved_date;
1365    END IF;
1366 
1367    -- settlement_code
1368    IF p_offer_adj_rec.settlement_code IS NULL THEN
1369       x_complete_rec.settlement_code := l_offer_adj_rec.settlement_code;
1370    END IF;
1371 
1372    -- status_code
1373    IF p_offer_adj_rec.status_code IS NULL THEN
1374       x_complete_rec.status_code := l_offer_adj_rec.status_code;
1375    END IF;
1376 
1377    -- list_header_id
1378    IF p_offer_adj_rec.list_header_id IS NULL THEN
1379       x_complete_rec.list_header_id := l_offer_adj_rec.list_header_id;
1380    END IF;
1381 
1382    -- version
1383    IF p_offer_adj_rec.version IS NULL THEN
1384       x_complete_rec.version := l_offer_adj_rec.version;
1385    END IF;
1386 
1387    -- budget_adjusted_flag
1388    IF p_offer_adj_rec.budget_adjusted_flag IS NULL THEN
1389       x_complete_rec.budget_adjusted_flag := l_offer_adj_rec.budget_adjusted_flag;
1390    END IF;
1391 
1392    -- last_update_date
1393    IF p_offer_adj_rec.last_update_date IS NULL THEN
1394       x_complete_rec.last_update_date := l_offer_adj_rec.last_update_date;
1395    END IF;
1396 
1397    -- last_updated_by
1398    IF p_offer_adj_rec.last_updated_by IS NULL THEN
1399       x_complete_rec.last_updated_by := l_offer_adj_rec.last_updated_by;
1400    END IF;
1401 
1402    -- creation_date
1403    IF p_offer_adj_rec.creation_date IS NULL THEN
1404       x_complete_rec.creation_date := l_offer_adj_rec.creation_date;
1405    END IF;
1406 
1407    -- created_by
1408    IF p_offer_adj_rec.created_by IS NULL THEN
1409       x_complete_rec.created_by := l_offer_adj_rec.created_by;
1410    END IF;
1411 
1412    -- last_update_login
1413    IF p_offer_adj_rec.last_update_login IS NULL THEN
1414       x_complete_rec.last_update_login := l_offer_adj_rec.last_update_login;
1415    END IF;
1416 
1417    -- object_version_number
1418    IF p_offer_adj_rec.object_version_number IS NULL THEN
1419       x_complete_rec.object_version_number := l_offer_adj_rec.object_version_number;
1420    END IF;
1421 
1422    -- attribute1
1423    IF p_offer_adj_rec.attribute1 IS NULL THEN
1424       x_complete_rec.attribute1 := l_offer_adj_rec.attribute1;
1425    END IF;
1426 
1427    -- attribute2
1428    IF p_offer_adj_rec.attribute2 IS NULL THEN
1429       x_complete_rec.attribute2 := l_offer_adj_rec.attribute2;
1430    END IF;
1431 
1432    -- attribute3
1433    IF p_offer_adj_rec.attribute3 IS NULL THEN
1434       x_complete_rec.attribute3 := l_offer_adj_rec.attribute3;
1435    END IF;
1436 
1437    -- attribute4
1438    IF p_offer_adj_rec.attribute4 IS NULL THEN
1439       x_complete_rec.attribute4 := l_offer_adj_rec.attribute4;
1440    END IF;
1441 
1442    -- attribute5
1443    IF p_offer_adj_rec.attribute5 IS NULL THEN
1444       x_complete_rec.attribute5 := l_offer_adj_rec.attribute5;
1445    END IF;
1446 
1447    -- attribute6
1448    IF p_offer_adj_rec.attribute6 IS NULL THEN
1449       x_complete_rec.attribute6 := l_offer_adj_rec.attribute6;
1450    END IF;
1451 
1452    -- attribute7
1453    IF p_offer_adj_rec.attribute7 IS NULL THEN
1454       x_complete_rec.attribute7 := l_offer_adj_rec.attribute7;
1455    END IF;
1456 
1457    -- attribute8
1458    IF p_offer_adj_rec.attribute8 IS NULL THEN
1459       x_complete_rec.attribute8 := l_offer_adj_rec.attribute8;
1460    END IF;
1461 
1462    -- attribute9
1463    IF p_offer_adj_rec.attribute9 IS NULL THEN
1464       x_complete_rec.attribute9 := l_offer_adj_rec.attribute9;
1465    END IF;
1466 
1467    -- attribute10
1468    IF p_offer_adj_rec.attribute10 IS NULL THEN
1469       x_complete_rec.attribute10 := l_offer_adj_rec.attribute10;
1470    END IF;
1471 
1472    -- attribute11
1473    IF p_offer_adj_rec.attribute11 IS NULL THEN
1474       x_complete_rec.attribute11 := l_offer_adj_rec.attribute11;
1475    END IF;
1476 
1477    -- attribute12
1478    IF p_offer_adj_rec.attribute12 IS NULL THEN
1479       x_complete_rec.attribute12 := l_offer_adj_rec.attribute12;
1480    END IF;
1481 
1482    -- attribute13
1483    IF p_offer_adj_rec.attribute13 IS NULL THEN
1484       x_complete_rec.attribute13 := l_offer_adj_rec.attribute13;
1485    END IF;
1486 
1487    -- attribute14
1488    IF p_offer_adj_rec.attribute14 IS NULL THEN
1489       x_complete_rec.attribute14 := l_offer_adj_rec.attribute14;
1490    END IF;
1491 
1492    -- attribute15
1493    IF p_offer_adj_rec.attribute15 IS NULL THEN
1494       x_complete_rec.attribute15 := l_offer_adj_rec.attribute15;
1495    END IF;
1496    -- Note: Developers need to modify the procedure
1497    -- to handle any business specific requirements.
1498 END Complete_Offer_Adj_Rec;
1499 
1500 
1501 
1502 
1503 PROCEDURE Default_Offer_Adj_Items ( p_offer_adj_rec IN offer_adj_rec_type ,
1504                                 x_offer_adj_rec OUT NOCOPY offer_adj_rec_type )
1505 IS
1506    l_offer_adj_rec offer_adj_rec_type := p_offer_adj_rec;
1507 BEGIN
1508    -- Developers should put their code to default the record type
1509    -- e.g. IF p_campaign_rec.status_code IS NULL
1510    --      OR p_campaign_rec.status_code = FND_API.G_MISS_CHAR THEN
1511    --         l_campaign_rec.status_code := 'NEW' ;
1512    --      END IF ;
1513    --
1514    NULL ;
1515 END;
1516 
1517 
1518 
1519 
1520 PROCEDURE Validate_Offer_Adjustment(
1521     p_api_version_number         IN   NUMBER,
1522     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
1523     p_validation_level           IN   NUMBER := FND_API.G_VALID_LEVEL_FULL,
1524     p_offer_adj_rec              IN   offer_adj_rec_type,
1525     p_validation_mode            IN    VARCHAR2,
1526     x_return_status              OUT NOCOPY  VARCHAR2,
1527     x_msg_count                  OUT NOCOPY  NUMBER,
1528     x_msg_data                   OUT NOCOPY  VARCHAR2
1529     )
1530  IS
1531 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Validate_Offer_Adjustment';
1532 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
1533 l_object_version_number     NUMBER;
1534 l_offer_adj_rec  offer_adj_rec_type;
1535 
1536  BEGIN
1537       -- Standard Start of API savepoint
1538       SAVEPOINT validate_offer_adjustment_;
1539 
1540       -- Standard call to check for call compatibility.
1541       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1542                                            p_api_version_number,
1543                                            l_api_name,
1544                                            G_PKG_NAME)
1545       THEN
1546           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1547       END IF;
1548 
1549 
1550       -- Initialize message list if p_init_msg_list is set to TRUE.
1551       IF FND_API.to_Boolean( p_init_msg_list )
1552       THEN
1553          FND_MSG_PUB.initialize;
1554       END IF;
1555 
1556 
1557       IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
1558               Check_offer_adj_Items(
1559                  p_offer_adj_rec        => p_offer_adj_rec,
1560                  p_validation_mode   => p_validation_mode,
1561                  x_return_status     => x_return_status
1562               );
1563 
1564               IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1565                   RAISE FND_API.G_EXC_ERROR;
1566               ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1567                   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1568               END IF;
1569       END IF;
1570 
1571       IF p_validation_mode = JTF_PLSQL_API.g_create THEN
1572          Default_Offer_Adj_Items (p_offer_adj_rec => p_offer_adj_rec ,
1573                                 x_offer_adj_rec => l_offer_adj_rec) ;
1574       END IF ;
1575 
1576 
1577       Complete_offer_adj_Rec(
1578          p_offer_adj_rec        => p_offer_adj_rec,
1579          x_complete_rec        => l_offer_adj_rec
1580       );
1581 
1582 -- If the Effective date is before the start date of any of the budgets dont create or update adjustments
1583       IF l_offer_adj_rec.effective_date < get_budget_start_date(l_offer_adj_rec.list_header_id) AND isBudgetOffer(p_listHeaderId => l_offer_adj_rec.list_header_id) = 'N' THEN
1584       ozf_utility_pvt.error_message('OZF_OFFR_ADJ_DT_LT_BUDGET_DT');
1585       RAISE FND_API.G_EXC_ERROR;
1586     END IF;
1587 
1588       IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
1589          Validate_offer_adj_Rec(
1590            p_api_version_number     => 1.0,
1591            p_init_msg_list          => FND_API.G_FALSE,
1592            x_return_status          => x_return_status,
1593            x_msg_count              => x_msg_count,
1594            x_msg_data               => x_msg_data,
1595            p_offer_adj_rec           =>    l_offer_adj_rec);
1596 
1597               IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1598                  RAISE FND_API.G_EXC_ERROR;
1599               ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1600                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1601               END IF;
1602       END IF;
1603 
1604 
1605       -- Debug Message
1606       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'start');
1607 
1608 
1609 
1610       -- Initialize API return status to SUCCESS
1611       x_return_status := FND_API.G_RET_STS_SUCCESS;
1612 
1613 
1614       -- Debug Message
1615       OZF_Offer_Adj_Line_PVT.debug_message('Private API: ' || l_api_name || 'end');
1616 
1617 
1618       -- Standard call to get message count and if count is 1, get message info.
1619       FND_MSG_PUB.Count_And_Get
1620         (p_count          =>   x_msg_count,
1621          p_data           =>   x_msg_data
1622       );
1623 EXCEPTION
1624 
1625    WHEN OZF_Utility_PVT.resource_locked THEN
1626      x_return_status := FND_API.g_ret_sts_error;
1627          OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1628 
1629    WHEN FND_API.G_EXC_ERROR THEN
1630      ROLLBACK TO VALIDATE_Offer_Adjustment_;
1631      x_return_status := FND_API.G_RET_STS_ERROR;
1632      -- Standard call to get message count and if count=1, get the message
1633      FND_MSG_PUB.Count_And_Get (
1634             p_encoded => FND_API.G_FALSE,
1635             p_count   => x_msg_count,
1636             p_data    => x_msg_data
1637      );
1638 
1639    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1640      ROLLBACK TO VALIDATE_Offer_Adjustment_;
1641      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1642      -- Standard call to get message count and if count=1, get the message
1643      FND_MSG_PUB.Count_And_Get (
1644             p_encoded => FND_API.G_FALSE,
1645             p_count => x_msg_count,
1646             p_data  => x_msg_data
1647      );
1648 
1649    WHEN OTHERS THEN
1650      ROLLBACK TO VALIDATE_Offer_Adjustment_;
1651      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1652      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1653      THEN
1654         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1655      END IF;
1656      -- Standard call to get message count and if count=1, get the message
1657      FND_MSG_PUB.Count_And_Get (
1658             p_encoded => FND_API.G_FALSE,
1659             p_count => x_msg_count,
1660             p_data  => x_msg_data
1661      );
1662 End Validate_Offer_Adjustment;
1663 
1664 
1665 PROCEDURE Validate_Offer_Adj_Rec (
1666     p_api_version_number         IN   NUMBER,
1667     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
1668     x_return_status              OUT NOCOPY  VARCHAR2,
1669     x_msg_count                  OUT NOCOPY  NUMBER,
1670     x_msg_data                   OUT NOCOPY  VARCHAR2,
1671     p_offer_adj_rec               IN    offer_adj_rec_type
1672     )
1673 IS
1674 BEGIN
1675       -- Initialize message list if p_init_msg_list is set to TRUE.
1676       IF FND_API.to_Boolean( p_init_msg_list )
1677       THEN
1678          FND_MSG_PUB.initialize;
1679       END IF;
1680 
1681 
1682 
1683       -- Initialize API return status to SUCCESS
1684       x_return_status := FND_API.G_RET_STS_SUCCESS;
1685 
1686       -- Hint: Validate data
1687       -- If data not valid
1688       -- THEN
1689       -- x_return_status := FND_API.G_RET_STS_ERROR;
1690 
1691       -- Debug Message
1692       OZF_Offer_Adj_Line_PVT.debug_message('Private API: Validate_dm_model_rec');
1693       -- Standard call to get message count and if count is 1, get message info.
1694       FND_MSG_PUB.Count_And_Get
1695         (p_count          =>   x_msg_count,
1696          p_data           =>   x_msg_data
1697       );
1698 END Validate_offer_adj_Rec;
1699 
1700 END OZF_Offer_Adjustment_PVT;