DBA Data[Home] [Help]

PACKAGE BODY: APPS.OZF_CLAIMS_HISTORY_PVT

Source


1 PACKAGE BODY OZF_claims_history_PVT as
2 /* $Header: ozfvchib.pls 120.2.12020000.3 2013/02/01 17:15:26 bkunjan ship $ */
3 -- Start of Comments
4 -- Package name     : OZF_claims_history_PVT
5 -- Purpose          :
6 -- History          :
7 -- NOTE             :
8 -- End of Comments
9 
10 G_PKG_NAME  CONSTANT VARCHAR2(30):= 'OZF_claims_history_PVT';
11 G_FILE_NAME CONSTANT VARCHAR2(12) := 'ozfvchib.pls';
12 
13 G_UPDATE_EVENT       CONSTANT VARCHAR2(30) := 'UPDATE';
14 G_LINE_EVENT         CONSTANT VARCHAR2(30) := 'LINE';
15 G_LINE_EVENT_DESC    CONSTANT VARCHAR2(30) := 'LINE';
16 G_SPLIT_EVENT        CONSTANT VARCHAR2(30) := 'SPLIT';
17 G_SETTLEMENT_EVENT   CONSTANT VARCHAR2(30) := 'SETL';
18 G_NEW_EVENT          CONSTANT VARCHAR2(30) := 'NEW';
19 G_NO_CHANGE_EVENT  CONSTANT VARCHAR2(30) := 'NOCHANGE';
20 
21 --Start Bug:2781186
22 G_SUBSEQUENT_APPLY_EVENT       CONSTANT VARCHAR2(30) := 'SUBSEQUENT_APPLY';
23 G_SUBSEQUENT_UNAPPLY_EVENT     CONSTANT VARCHAR2(30) := 'SUBSEQUENT_UNAPPLY';
24 --End Bug:2781186
25 
26 G_CHANGE_EVENT       CONSTANT VARCHAR2(30) :='CHANGES';  -- This event is returned to the caller.
27 --Start Bug:2781186
28 G_SUBSEQUENT_APPLY_CHG_EVENT   CONSTANT VARCHAR2(30) :='APPLY';    -- This event is returned to the caller.
29 G_SUBSEQUENT_UNAPPLY_CHG_EVENT CONSTANT VARCHAR2(30) :='UNAPPLY';  -- This event is returned to the caller.
30 --End Bug:2781186
31 
32 G_NEW_STATUS        CONSTANT VARCHAR2(30) :='NEW';
33 G_CLAIM_TYPE         CONSTANT VARCHAR2(30) :='OZF_CLAM';
34 G_CLAIM_HIST_OBJ_TYPE CONSTANT VARCHAR2(30) :='CLAMHIST';
35 
36 OZF_DEBUG_LOW_ON BOOLEAN := FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_debug_low);
37 
38 -- define types private to this package.
39 
40 ---------------------------------------------------------------------
41 -- PROCEDURE
42 --    Complete_Claim_History_Rec
43 --
44 -- PURPOSE
45 --    For Update_Claim_history, some attributes may be passed in as
46 --    FND_API.g_miss_char/num/date if the user doesn't want to
47 --    update those attributes. This procedure will replace the
48 --    "g_miss" attributes with current database values.
49 --
50 -- PARAMETERS
51 --    p_claim_history_rec  : the record which may contain attributes as
52 --                    FND_API.g_miss_char/num/date
53 --    x_complete_rec: the complete record after all "g_miss" items
54 --                    have been replaced by current database values
55 ---------------------------------------------------------------------
56 PROCEDURE Complete_Claim_History_Rec (
57    p_claim_history_rec  IN   claims_history_rec_type
58   ,x_complete_rec     OUT NOCOPY  claims_history_rec_type
59   ,x_return_status    OUT NOCOPY  varchar2
60 )
61 IS
62 CURSOR c_claim_history_csr (p_id in NUMBER) IS
63 SELECT * FROM ozf_claims_history_all
64 WHERE claim_history_id = p_id;
65 
66 l_claim_history_rec    c_claim_history_csr%ROWTYPE;
67 l_api_name  varchar2(30) := 'Complete_Claim_History_Rec';
68 BEGIN
69 --	letter_id                       NUMBER := FND_API.G_MISS_NUM,
70 --       letter_date                     DATE := FND_API.G_MISS_DATE,
71 
72    -- Initialize API return status to sucess
73    x_return_status := FND_API.G_RET_STS_SUCCESS;
74 
75    -- Api body
76    --
77    -- Debug Message
78    IF OZF_DEBUG_LOW_ON THEN
82    END IF;
79       FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
80       FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
81       FND_MSG_PUB.Add;
83 
84    x_complete_rec  := p_claim_history_rec;
85 
86   OPEN c_claim_history_csr(p_claim_history_rec.claim_history_id);
87   FETCH c_claim_history_csr INTO l_claim_history_rec;
88      IF c_claim_history_csr%NOTFOUND THEN
89         CLOSE c_claim_history_csr;
90         IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
91            FND_MESSAGE.set_name('OZF','OZF_API_RECORD_NOT_FOUND');
92            FND_MSG_PUB.add;
93         END IF;
94         RAISE FND_API.g_exc_error;
95      END IF;
96   CLOSE c_claim_history_csr;
97 
98   IF p_claim_history_rec.claim_history_id         = FND_API.G_MISS_NUM  THEN
99      x_complete_rec.claim_history_id       := NULL;
100   END IF;
101   IF p_claim_history_rec.claim_history_id         IS NULL THEN
102      x_complete_rec.claim_history_id       := l_claim_history_rec.claim_history_id;
103   END IF;
104   IF p_claim_history_rec.object_version_number  = FND_API.G_MISS_NUM  THEN
105      x_complete_rec.object_version_number       := NULL;
106   END IF;
107   IF p_claim_history_rec.object_version_number  IS NULL THEN
108      x_complete_rec.object_version_number       := l_claim_history_rec.object_version_number;
109   END IF;
110   IF p_claim_history_rec.claim_id         = FND_API.G_MISS_NUM  THEN
111      x_complete_rec.claim_id       := NULL;
112   END IF;
113   IF p_claim_history_rec.claim_id         IS NULL THEN
114      x_complete_rec.claim_id       := l_claim_history_rec.claim_id;
115   END IF;
116   IF p_claim_history_rec.batch_id         = FND_API.G_MISS_NUM  THEN
117      x_complete_rec.batch_id       := NULL;
118   END IF;
119   IF p_claim_history_rec.batch_id         IS NULL THEN
120      x_complete_rec.batch_id       := l_claim_history_rec.batch_id;
121   END IF;
122   IF p_claim_history_rec.claim_number         = FND_API.G_MISS_CHAR  THEN
123      x_complete_rec.claim_number       := NULL;
124   END IF;
125   IF p_claim_history_rec.claim_number         IS NULL THEN
126      x_complete_rec.claim_number       := l_claim_history_rec.claim_number;
127   END IF;
128   IF p_claim_history_rec.claim_type_id         = FND_API.G_MISS_NUM  THEN
129      x_complete_rec.claim_type_id       := NULL;
130   END IF;
131   IF p_claim_history_rec.claim_type_id         IS NULL THEN
132      x_complete_rec.claim_type_id       := l_claim_history_rec.claim_type_id;
133   END IF;
134   IF p_claim_history_rec.claim_class         = FND_API.G_MISS_CHAR  THEN
135      x_complete_rec.claim_class       := NULL;
136   END IF;
137   IF p_claim_history_rec.claim_class         IS NULL THEN
138      x_complete_rec.claim_class       := l_claim_history_rec.claim_class;
139   END IF;
140   IF p_claim_history_rec.claim_date         = FND_API.G_MISS_DATE  THEN
141      x_complete_rec.claim_date       := NULL;
142   END IF;
143   IF p_claim_history_rec.claim_date         IS NULL THEN
144      x_complete_rec.claim_date       := l_claim_history_rec.claim_date;
145   END IF;
146   IF p_claim_history_rec.due_date         = FND_API.G_MISS_DATE  THEN
147      x_complete_rec.due_date       := NULL;
148   END IF;
149   IF p_claim_history_rec.due_date         IS NULL THEN
150      x_complete_rec.due_date       := l_claim_history_rec.due_date;
151   END IF;
152   IF p_claim_history_rec.owner_id  = FND_API.G_MISS_NUM  THEN
153      x_complete_rec.owner_id := NULL;
154   END IF;
155   IF p_claim_history_rec.owner_id  IS NULL THEN
156      x_complete_rec.owner_id := l_claim_history_rec.owner_id;
157   END IF;
158   IF p_claim_history_rec.history_event  = FND_API.G_MISS_CHAR  THEN
159      x_complete_rec.history_event := NULL;
160   END IF;
161   IF p_claim_history_rec.history_event  IS NULL THEN
162      x_complete_rec.history_event := l_claim_history_rec.history_event;
163   END IF;
164   IF p_claim_history_rec.history_event_date  = FND_API.G_MISS_DATE  THEN
165      x_complete_rec.history_event_date := NULL;
166   END IF;
167   IF p_claim_history_rec.history_event_date  IS NULL THEN
168      x_complete_rec.history_event_date := l_claim_history_rec.history_event_date;
169   END IF;
170   IF p_claim_history_rec.history_event_description  = FND_API.G_MISS_CHAR  THEN
171      x_complete_rec.history_event_description := NULL;
172   END IF;
173   IF p_claim_history_rec.history_event_description  IS NULL THEN
174      x_complete_rec.history_event_description := l_claim_history_rec.history_event_description;
175   END IF;
176   IF p_claim_history_rec.split_from_claim_id  = FND_API.G_MISS_NUM  THEN
177      x_complete_rec.split_from_claim_id       := NULL;
178   END IF;
179   IF p_claim_history_rec.split_from_claim_id  IS NULL THEN
180      x_complete_rec.split_from_claim_id       := l_claim_history_rec.split_from_claim_id;
181   END IF;
182   IF p_claim_history_rec.duplicate_claim_id  = FND_API.G_MISS_NUM  THEN
183      x_complete_rec.duplicate_claim_id       := NULL;
184   END IF;
185   IF p_claim_history_rec.duplicate_claim_id  IS NULL THEN
186      x_complete_rec.duplicate_claim_id       := l_claim_history_rec.duplicate_claim_id;
187   END IF;
188   IF p_claim_history_rec.split_date  = FND_API.G_MISS_DATE  THEN
189      x_complete_rec.split_date := NULL;
190   END IF;
191   IF p_claim_history_rec.split_date  IS NULL THEN
192      x_complete_rec.split_date := l_claim_history_rec.split_date;
193   END IF;
194   IF p_claim_history_rec.root_claim_id  = FND_API.G_MISS_NUM  THEN
195      x_complete_rec.root_claim_id       := NULL;
196   END IF;
197   IF p_claim_history_rec.root_claim_id  IS NULL THEN
201      x_complete_rec.amount       := NULL;
198      x_complete_rec.root_claim_id       := l_claim_history_rec.root_claim_id;
199   END IF;
200   IF p_claim_history_rec.amount  = FND_API.G_MISS_NUM  THEN
202   END IF;
203   IF p_claim_history_rec.amount  IS NULL THEN
204      x_complete_rec.amount       := l_claim_history_rec.amount;
205   END IF;
206   IF p_claim_history_rec.amount_adjusted  = FND_API.G_MISS_NUM  THEN
207      x_complete_rec.amount_adjusted       := NULL;
208   END IF;
209   IF p_claim_history_rec.amount_adjusted  IS NULL THEN
210      x_complete_rec.amount_adjusted       := l_claim_history_rec.amount_adjusted;
211   END IF;
212   IF p_claim_history_rec.amount_remaining  = FND_API.G_MISS_NUM  THEN
213      x_complete_rec.amount_remaining       := NULL;
214   END IF;
215   IF p_claim_history_rec.amount_remaining  IS NULL THEN
216      x_complete_rec.amount_remaining       := l_claim_history_rec.amount_remaining;
217   END IF;
218   IF p_claim_history_rec.amount_settled  = FND_API.G_MISS_NUM  THEN
219      x_complete_rec.amount_settled       := NULL;
220   END IF;
221   IF p_claim_history_rec.amount_settled  IS NULL THEN
222      x_complete_rec.amount_settled       := l_claim_history_rec.amount_settled;
223   END IF;
224   IF p_claim_history_rec.acctd_amount  = FND_API.G_MISS_NUM  THEN
225      x_complete_rec.acctd_amount       := NULL;
226   END IF;
227   IF p_claim_history_rec.acctd_amount  IS NULL THEN
228      x_complete_rec.acctd_amount       := l_claim_history_rec.acctd_amount;
229   END IF;
230   IF p_claim_history_rec.acctd_amount_remaining   = FND_API.G_MISS_NUM  THEN
231      x_complete_rec.acctd_amount_remaining        := NULL;
232   END IF;
233   IF p_claim_history_rec.acctd_amount_remaining   IS NULL THEN
234      x_complete_rec.acctd_amount_remaining        := l_claim_history_rec.acctd_amount_remaining ;
235   END IF;
236   IF p_claim_history_rec.acctd_amount_adjusted  = FND_API.G_MISS_NUM  THEN
237      x_complete_rec.acctd_amount_adjusted       := NULL;
238   END IF;
239   IF p_claim_history_rec.acctd_amount_adjusted  IS NULL THEN
240      x_complete_rec.acctd_amount_adjusted       := l_claim_history_rec.acctd_amount_adjusted;
241   END IF;
242   IF p_claim_history_rec.acctd_amount_settled  = FND_API.G_MISS_NUM  THEN
243      x_complete_rec.acctd_amount_settled       := NULL;
244   END IF;
245   IF p_claim_history_rec.acctd_amount_settled  IS NULL THEN
246      x_complete_rec.acctd_amount_settled       := l_claim_history_rec.acctd_amount_settled;
247   END IF;
248   IF p_claim_history_rec.tax_amount   = FND_API.G_MISS_NUM  THEN
249      x_complete_rec.tax_amount        := NULL;
250   END IF;
251   IF p_claim_history_rec.tax_amount   IS NULL THEN
252      x_complete_rec.tax_amount        := l_claim_history_rec.tax_amount ;
253   END IF;
254   IF p_claim_history_rec.tax_code   = FND_API.G_MISS_CHAR  THEN
255      x_complete_rec.tax_code        := NULL;
256   END IF;
257   IF p_claim_history_rec.tax_code   IS NULL THEN
258      x_complete_rec.tax_code        := l_claim_history_rec.tax_code ;
259   END IF;
260   IF p_claim_history_rec.tax_calculation_flag   = FND_API.G_MISS_CHAR  THEN
261      x_complete_rec.tax_calculation_flag        := NULL;
262   END IF;
263   IF p_claim_history_rec.tax_calculation_flag   IS NULL THEN
264      x_complete_rec.tax_calculation_flag        := l_claim_history_rec.tax_calculation_flag ;
265   END IF;
266   IF p_claim_history_rec.currency_code         = FND_API.G_MISS_CHAR  THEN
267      x_complete_rec.currency_code       := NULL;
268   END IF;
269   IF p_claim_history_rec.currency_code         IS NULL THEN
270      x_complete_rec.currency_code       := l_claim_history_rec.currency_code;
271   END IF;
272   IF p_claim_history_rec.exchange_rate_type         = FND_API.G_MISS_CHAR  THEN
273      x_complete_rec.exchange_rate_type       := NULL;
274   END IF;
275   IF p_claim_history_rec.exchange_rate_type         IS NULL THEN
276      x_complete_rec.exchange_rate_type       := l_claim_history_rec.exchange_rate_type;
277   END IF;
278   IF p_claim_history_rec.exchange_rate_date         = FND_API.G_MISS_DATE  THEN
279      x_complete_rec.exchange_rate_date       := NULL;
280   END IF;
281   IF p_claim_history_rec.exchange_rate_date         IS NULL THEN
282      x_complete_rec.exchange_rate_date       := l_claim_history_rec.exchange_rate_date;
283   END IF;
284   IF p_claim_history_rec.exchange_rate  = FND_API.G_MISS_NUM  THEN
285      x_complete_rec.exchange_rate       := NULL;
286   END IF;
287   IF p_claim_history_rec.exchange_rate  IS NULL THEN
288      x_complete_rec.exchange_rate       := l_claim_history_rec.exchange_rate;
289   END IF;
290   IF p_claim_history_rec.set_of_books_id  = FND_API.G_MISS_NUM  THEN
291      x_complete_rec.set_of_books_id       := NULL;
292   END IF;
293   IF p_claim_history_rec.set_of_books_id  IS NULL THEN
294      x_complete_rec.set_of_books_id       := l_claim_history_rec.set_of_books_id;
295   END IF;
296   IF p_claim_history_rec.original_claim_date         = FND_API.G_MISS_DATE  THEN
297      x_complete_rec.original_claim_date       := NULL;
298   END IF;
299   IF p_claim_history_rec.original_claim_date         IS NULL THEN
300      x_complete_rec.original_claim_date       := l_claim_history_rec.original_claim_date;
301   END IF;
302   IF p_claim_history_rec.source_object_id  = FND_API.G_MISS_NUM  THEN
303      x_complete_rec.source_object_id       := NULL;
304   END IF;
305   IF p_claim_history_rec.source_object_id  IS NULL THEN
306      x_complete_rec.source_object_id       := l_claim_history_rec.source_object_id;
307   END IF;
308   IF p_claim_history_rec.source_object_class  = FND_API.G_MISS_CHAR  THEN
309      x_complete_rec.source_object_class       := NULL;
310   END IF;
311   IF p_claim_history_rec.source_object_class  IS NULL THEN
315      x_complete_rec.source_object_type_id       := NULL;
312      x_complete_rec.source_object_class       := l_claim_history_rec.source_object_class;
313   END IF;
314   IF p_claim_history_rec.source_object_type_id  = FND_API.G_MISS_NUM  THEN
316   END IF;
317   IF p_claim_history_rec.source_object_type_id  IS NULL THEN
318      x_complete_rec.source_object_type_id       := l_claim_history_rec.source_object_type_id;
319   END IF;
320   IF p_claim_history_rec.source_object_number  = FND_API.G_MISS_CHAR  THEN
321      x_complete_rec.source_object_number       := NULL;
322   END IF;
323   IF p_claim_history_rec.source_object_number  IS NULL THEN
324      x_complete_rec.source_object_number       := l_claim_history_rec.source_object_number;
325   END IF;
326   IF p_claim_history_rec.cust_account_id  = FND_API.G_MISS_NUM  THEN
327      x_complete_rec.cust_account_id       := NULL;
328   END IF;
329   IF p_claim_history_rec.cust_account_id  IS NULL THEN
330      x_complete_rec.cust_account_id       := l_claim_history_rec.cust_account_id;
331   END IF;
332   IF p_claim_history_rec.cust_billto_acct_site_id  = FND_API.G_MISS_NUM  THEN
333      x_complete_rec.cust_billto_acct_site_id       := NULL;
334   END IF;
335   IF p_claim_history_rec.cust_billto_acct_site_id  IS NULL THEN
336      x_complete_rec.cust_billto_acct_site_id       := l_claim_history_rec.cust_billto_acct_site_id;
337   END IF;
338   IF p_claim_history_rec.cust_shipto_acct_site_id  = FND_API.G_MISS_NUM  THEN
339      x_complete_rec.cust_shipto_acct_site_id := NULL;
340   END IF;
341   IF p_claim_history_rec.cust_shipto_acct_site_id  IS NULL THEN
342      x_complete_rec.cust_shipto_acct_site_id := l_claim_history_rec.cust_shipto_acct_site_id;
343   END IF;
344   IF p_claim_history_rec.location_id  = FND_API.G_MISS_NUM  THEN
345      x_complete_rec.location_id       := NULL;
346   END IF;
347   IF p_claim_history_rec.location_id  IS NULL THEN
348      x_complete_rec.location_id       := l_claim_history_rec.location_id;
349   END IF;
350   IF p_claim_history_rec.pay_related_account_flag  = FND_API.G_MISS_CHAR  THEN
351      x_complete_rec.pay_related_account_flag := NULL;
352   END IF;
353   IF p_claim_history_rec.pay_related_account_flag  IS NULL THEN
354      x_complete_rec.pay_related_account_flag := l_claim_history_rec.pay_related_account_flag;
355   END IF;
356   IF p_claim_history_rec.related_cust_account_id  = FND_API.G_MISS_NUM  THEN
357      x_complete_rec.related_cust_account_id := NULL;
358   END IF;
359   IF p_claim_history_rec.related_cust_account_id  IS NULL THEN
360      x_complete_rec.related_cust_account_id := l_claim_history_rec.related_cust_account_id;
361   END IF;
362   IF p_claim_history_rec.related_site_use_id  = FND_API.G_MISS_NUM  THEN
363      x_complete_rec.related_site_use_id := NULL;
364   END IF;
365   IF p_claim_history_rec.related_site_use_id  IS NULL THEN
366      x_complete_rec.related_site_use_id := l_claim_history_rec.related_site_use_id;
367   END IF;
368   IF p_claim_history_rec.relationship_type = FND_API.G_MISS_CHAR  THEN
369      x_complete_rec.relationship_type := NULL;
370   END IF;
371   IF p_claim_history_rec.relationship_type IS NULL THEN
372      x_complete_rec.relationship_type := l_claim_history_rec.relationship_type;
373   END IF;
374   IF p_claim_history_rec.vendor_id   = FND_API.G_MISS_NUM  THEN
375      x_complete_rec.vendor_id := NULL;
376   END IF;
377   IF p_claim_history_rec.vendor_id   IS NULL THEN
378      x_complete_rec.vendor_id := l_claim_history_rec.vendor_id;
379   END IF;
380   IF p_claim_history_rec.vendor_site_id = FND_API.G_MISS_NUM  THEN
381      x_complete_rec.vendor_site_id := NULL;
382   END IF;
383   IF p_claim_history_rec.vendor_site_id IS NULL THEN
384      x_complete_rec.vendor_site_id := l_claim_history_rec.vendor_site_id;
385   END IF;
386   IF p_claim_history_rec.reason_type  = FND_API.G_MISS_CHAR  THEN
387      x_complete_rec.reason_type       := NULL;
388   END IF;
389   IF p_claim_history_rec.reason_type  IS NULL THEN
390      x_complete_rec.reason_type       := l_claim_history_rec.reason_type;
391   END IF;
392   IF p_claim_history_rec.reason_code_id  = FND_API.G_MISS_NUM  THEN
393      x_complete_rec.reason_code_id       := NULL;
394   END IF;
395   IF p_claim_history_rec.reason_code_id  IS NULL THEN
396      x_complete_rec.reason_code_id       := l_claim_history_rec.reason_code_id;
397   END IF;
398   IF p_claim_history_rec.task_template_group_id  = FND_API.G_MISS_NUM  THEN
399      x_complete_rec.task_template_group_id       := NULL;
400   END IF;
401   IF p_claim_history_rec.task_template_group_id  IS NULL THEN
402      x_complete_rec.task_template_group_id       := l_claim_history_rec.task_template_group_id;
403   END IF;
404   IF p_claim_history_rec.status_code  = FND_API.G_MISS_CHAR  THEN
405      x_complete_rec.status_code       := NULL;
406   END IF;
407   IF p_claim_history_rec.status_code  IS NULL THEN
408      x_complete_rec.status_code       := l_claim_history_rec.status_code;
409   END IF;
410   IF p_claim_history_rec.user_status_id  = FND_API.G_MISS_NUM  THEN
411      x_complete_rec.user_status_id       := NULL;
412   END IF;
413   IF p_claim_history_rec.user_status_id  IS NULL THEN
414      x_complete_rec.user_status_id       := l_claim_history_rec.user_status_id;
415   END IF;
416   IF p_claim_history_rec.sales_rep_id  = FND_API.G_MISS_NUM  THEN
417      x_complete_rec.sales_rep_id       := NULL;
418   END IF;
419   IF p_claim_history_rec.sales_rep_id  IS NULL THEN
420      x_complete_rec.sales_rep_id       := l_claim_history_rec.sales_rep_id;
421   END IF;
422   IF p_claim_history_rec.collector_id  = FND_API.G_MISS_NUM  THEN
423      x_complete_rec.collector_id       := NULL;
424   END IF;
425   IF p_claim_history_rec.collector_id  IS NULL THEN
429      x_complete_rec.contact_id       := NULL;
426      x_complete_rec.collector_id       := l_claim_history_rec.collector_id;
427   END IF;
428   IF p_claim_history_rec.contact_id  = FND_API.G_MISS_NUM  THEN
430   END IF;
431   IF p_claim_history_rec.contact_id  IS NULL THEN
432      x_complete_rec.contact_id       := l_claim_history_rec.contact_id;
433   END IF;
434   IF p_claim_history_rec.broker_id  = FND_API.G_MISS_NUM  THEN
435      x_complete_rec.broker_id       := NULL;
436   END IF;
437   IF p_claim_history_rec.broker_id  IS NULL THEN
438      x_complete_rec.broker_id       := l_claim_history_rec.broker_id;
439   END IF;
440   IF p_claim_history_rec.territory_id  = FND_API.G_MISS_NUM  THEN
441      x_complete_rec.territory_id       := NULL;
442   END IF;
443   IF p_claim_history_rec.territory_id  IS NULL THEN
444      x_complete_rec.territory_id       := l_claim_history_rec.territory_id;
445   END IF;
446   IF p_claim_history_rec.customer_ref_date         = FND_API.G_MISS_DATE  THEN
447      x_complete_rec.customer_ref_date       := NULL;
448   END IF;
449   IF p_claim_history_rec.customer_ref_date         IS NULL THEN
450      x_complete_rec.customer_ref_date       := l_claim_history_rec.customer_ref_date;
451   END IF;
452   IF p_claim_history_rec.customer_ref_number  = FND_API.G_MISS_CHAR  THEN
453      x_complete_rec.customer_ref_number       := NULL;
454   END IF;
455   IF p_claim_history_rec.customer_ref_number  IS NULL THEN
456      x_complete_rec.customer_ref_number       := l_claim_history_rec.customer_ref_number;
457   END IF;
458   IF p_claim_history_rec.receipt_id  = FND_API.G_MISS_NUM  THEN
459      x_complete_rec.receipt_id       := NULL;
460   END IF;
461   IF p_claim_history_rec.receipt_id  IS NULL THEN
462      x_complete_rec.receipt_id       := l_claim_history_rec.receipt_id;
463   END IF;
464   IF p_claim_history_rec.receipt_number  = FND_API.G_MISS_CHAR  THEN
465      x_complete_rec.receipt_number       := NULL;
466   END IF;
467   IF p_claim_history_rec.receipt_number  IS NULL THEN
468      x_complete_rec.receipt_number       := l_claim_history_rec.receipt_number;
469   END IF;
470   IF p_claim_history_rec.doc_sequence_id  = FND_API.G_MISS_NUM  THEN
471      x_complete_rec.doc_sequence_id       := NULL;
472   END IF;
473   IF p_claim_history_rec.doc_sequence_id  IS NULL THEN
474      x_complete_rec.doc_sequence_id       := l_claim_history_rec.doc_sequence_id;
475   END IF;
476   IF p_claim_history_rec.doc_sequence_value  = FND_API.G_MISS_NUM  THEN
477      x_complete_rec.doc_sequence_value       := NULL;
478   END IF;
479   IF p_claim_history_rec.doc_sequence_value  IS NULL THEN
480      x_complete_rec.doc_sequence_value       := l_claim_history_rec.doc_sequence_value;
481   END IF;
482   IF p_claim_history_rec.gl_date  = FND_API.G_MISS_DATE  THEN
483      x_complete_rec.gl_date       := NULL;
484   END IF;
485   IF p_claim_history_rec.gl_date  IS NULL THEN
486      x_complete_rec.gl_date       := l_claim_history_rec.gl_date;
487   END IF;
488   IF p_claim_history_rec.payment_method  = FND_API.G_MISS_CHAR  THEN
489      x_complete_rec.payment_method       := NULL;
490   END IF;
491   IF p_claim_history_rec.payment_method  IS NULL THEN
492      x_complete_rec.payment_method       := l_claim_history_rec.payment_method;
493   END IF;
494   IF p_claim_history_rec.voucher_id  = FND_API.G_MISS_NUM  THEN
495      x_complete_rec.voucher_id       := NULL;
496   END IF;
497   IF p_claim_history_rec.voucher_id  IS NULL THEN
498      x_complete_rec.voucher_id       := l_claim_history_rec.voucher_id;
499   END IF;
500   IF p_claim_history_rec.voucher_number  = FND_API.G_MISS_CHAR  THEN
501      x_complete_rec.voucher_number       := NULL;
502   END IF;
503   IF p_claim_history_rec.voucher_number  IS NULL THEN
504      x_complete_rec.voucher_number       := l_claim_history_rec.voucher_number;
505   END IF;
506   IF p_claim_history_rec.payment_reference_id  = FND_API.G_MISS_NUM  THEN
507      x_complete_rec.payment_reference_id       := NULL;
508   END IF;
509   IF p_claim_history_rec.payment_reference_id  IS NULL THEN
510      x_complete_rec.payment_reference_id       := l_claim_history_rec.payment_reference_id;
511   END IF;
512   IF p_claim_history_rec.payment_reference_number  = FND_API.G_MISS_CHAR  THEN
513      x_complete_rec.payment_reference_number := NULL;
514   END IF;
515   IF p_claim_history_rec.payment_reference_number  IS NULL THEN
516      x_complete_rec.payment_reference_number := l_claim_history_rec.payment_reference_number;
517   END IF;
518   IF p_claim_history_rec.payment_reference_date  = FND_API.G_MISS_DATE  THEN
519      x_complete_rec.payment_reference_date := NULL;
520   END IF;
521   IF p_claim_history_rec.payment_reference_date  IS NULL THEN
522      x_complete_rec.payment_reference_date := l_claim_history_rec.payment_reference_date;
523   END IF;
524   IF p_claim_history_rec.payment_status  = FND_API.G_MISS_CHAR  THEN
525      x_complete_rec.payment_status := NULL;
526   END IF;
527   IF p_claim_history_rec.payment_status  IS NULL THEN
528      x_complete_rec.payment_status := l_claim_history_rec.payment_status;
529   END IF;
530   IF p_claim_history_rec.approved_flag  = FND_API.G_MISS_CHAR  THEN
531      x_complete_rec.approved_flag := NULL;
532   END IF;
533   IF p_claim_history_rec.approved_flag  IS NULL THEN
534      x_complete_rec.approved_flag := l_claim_history_rec.approved_flag;
535   END IF;
536   IF p_claim_history_rec.approved_date  = FND_API.G_MISS_DATE  THEN
537      x_complete_rec.approved_date := NULL;
538   END IF;
539   IF p_claim_history_rec.approved_date  IS NULL THEN
540      x_complete_rec.approved_date := l_claim_history_rec.approved_date;
541   END IF;
545   IF p_claim_history_rec.approved_by  IS NULL THEN
542   IF p_claim_history_rec.approved_by  = FND_API.G_MISS_NUM  THEN
543      x_complete_rec.approved_by := NULL;
544   END IF;
546      x_complete_rec.approved_by := l_claim_history_rec.approved_by;
547   END IF;
548   IF p_claim_history_rec.settled_date  = FND_API.G_MISS_DATE  THEN
549      x_complete_rec.settled_date := NULL;
550   END IF;
551   IF p_claim_history_rec.settled_date  IS NULL THEN
552      x_complete_rec.settled_date := l_claim_history_rec.settled_date;
553   END IF;
554   IF p_claim_history_rec.settled_by  = FND_API.G_MISS_NUM  THEN
555      x_complete_rec.settled_by := NULL;
556   END IF;
557   IF p_claim_history_rec.settled_by  IS NULL THEN
558      x_complete_rec.settled_by := l_claim_history_rec.settled_by;
559   END IF;
560   IF p_claim_history_rec.effective_date  = FND_API.G_MISS_DATE  THEN
561      x_complete_rec.effective_date := NULL;
562   END IF;
563   IF p_claim_history_rec.effective_date  IS NULL THEN
564      x_complete_rec.effective_date := l_claim_history_rec.effective_date;
565   END IF;
566   IF p_claim_history_rec.custom_setup_id = FND_API.G_MISS_NUM  THEN
567      x_complete_rec.custom_setup_id := NULL;
568   END IF;
569   IF p_claim_history_rec.custom_setup_id IS NULL THEN
570      x_complete_rec.custom_setup_id := l_claim_history_rec.custom_setup_id;
571   END IF;
572   IF p_claim_history_rec.task_id  = FND_API.G_MISS_NUM  THEN
573      x_complete_rec.task_id := NULL;
574   END IF;
575   IF p_claim_history_rec.task_id  IS NULL THEN
576      x_complete_rec.task_id := l_claim_history_rec.task_id;
577   END IF;
578   IF p_claim_history_rec.country_id = FND_API.G_MISS_NUM  THEN
579      x_complete_rec.country_id := NULL;
580   END IF;
581   IF p_claim_history_rec.country_id IS NULL THEN
582      x_complete_rec.country_id := l_claim_history_rec.country_id;
583   END IF;
584   IF p_claim_history_rec.order_type_id = FND_API.G_MISS_NUM  THEN
585      x_complete_rec.order_type_id := NULL;
586   END IF;
587   IF p_claim_history_rec.order_type_id IS NULL THEN
588      x_complete_rec.order_type_id := l_claim_history_rec.order_type_id;
589   END IF;
590   IF p_claim_history_rec.comments  = FND_API.G_MISS_CHAR  THEN
591      x_complete_rec.comments := NULL;
592   END IF;
593   IF p_claim_history_rec.comments  IS NULL THEN
594      x_complete_rec.comments := l_claim_history_rec.comments;
595   END IF;
596   IF p_claim_history_rec.task_source_object_id = FND_API.G_MISS_NUM  THEN
597      x_complete_rec.task_source_object_id := NULL;
598   END IF;
599   IF p_claim_history_rec.task_source_object_id IS NULL THEN
600      x_complete_rec.task_source_object_id := l_claim_history_rec.task_source_object_id;
601   END IF;
602   IF p_claim_history_rec.task_source_object_type_code  = FND_API.G_MISS_CHAR  THEN
603      x_complete_rec.task_source_object_type_code := NULL;
604   END IF;
605   IF p_claim_history_rec.task_source_object_type_code  IS NULL THEN
606      x_complete_rec.task_source_object_type_code := l_claim_history_rec.task_source_object_type_code;
607   END IF;
608   IF p_claim_history_rec.attribute_category  = FND_API.G_MISS_CHAR  THEN
609      x_complete_rec.attribute_category := NULL;
610   END IF;
611   IF p_claim_history_rec.attribute_category  IS NULL THEN
612      x_complete_rec.attribute_category := l_claim_history_rec.attribute_category;
613   END IF;
614   IF p_claim_history_rec.attribute1  = FND_API.G_MISS_CHAR  THEN
615      x_complete_rec.attribute1 := NULL;
616   END IF;
617   IF p_claim_history_rec.attribute1  IS NULL THEN
618      x_complete_rec.attribute1 := l_claim_history_rec.attribute1;
619   END IF;
620   IF p_claim_history_rec.attribute2  = FND_API.G_MISS_CHAR  THEN
621      x_complete_rec.attribute2 := NULL;
622   END IF;
623   IF p_claim_history_rec.attribute2  IS NULL THEN
624      x_complete_rec.attribute2 := l_claim_history_rec.attribute2;
625   END IF;
626   IF p_claim_history_rec.attribute3  = FND_API.G_MISS_CHAR  THEN
627      x_complete_rec.attribute3 := NULL;
628   END IF;
629   IF p_claim_history_rec.attribute3  IS NULL THEN
630      x_complete_rec.attribute3 := l_claim_history_rec.attribute3;
631   END IF;
632   IF p_claim_history_rec.attribute4  = FND_API.G_MISS_CHAR  THEN
633      x_complete_rec.attribute4 := NULL;
634   END IF;
635   IF p_claim_history_rec.attribute4  IS NULL THEN
636      x_complete_rec.attribute4 := l_claim_history_rec.attribute4;
637   END IF;
638   IF p_claim_history_rec.attribute5  = FND_API.G_MISS_CHAR  THEN
639      x_complete_rec.attribute5 := NULL;
640   END IF;
641   IF p_claim_history_rec.attribute5  IS NULL THEN
642      x_complete_rec.attribute5 := l_claim_history_rec.attribute5;
643   END IF;
644   IF p_claim_history_rec.attribute6  = FND_API.G_MISS_CHAR  THEN
645      x_complete_rec.attribute6 := NULL;
646   END IF;
647   IF p_claim_history_rec.attribute6  IS NULL THEN
648      x_complete_rec.attribute6 := l_claim_history_rec.attribute6;
649   END IF;
650   IF p_claim_history_rec.attribute7  = FND_API.G_MISS_CHAR  THEN
651      x_complete_rec.attribute7 := NULL;
652   END IF;
653   IF p_claim_history_rec.attribute7  IS NULL THEN
654      x_complete_rec.attribute7 := l_claim_history_rec.attribute7;
655   END IF;
656   IF p_claim_history_rec.attribute8  = FND_API.G_MISS_CHAR  THEN
657      x_complete_rec.attribute8 := NULL;
658   END IF;
659   IF p_claim_history_rec.attribute8  IS NULL THEN
660      x_complete_rec.attribute8 := l_claim_history_rec.attribute8;
661   END IF;
662   IF p_claim_history_rec.attribute9  = FND_API.G_MISS_CHAR  THEN
663      x_complete_rec.attribute9 := NULL;
664   END IF;
665   IF p_claim_history_rec.attribute9  IS NULL THEN
669      x_complete_rec.attribute10 := NULL;
666      x_complete_rec.attribute9 := l_claim_history_rec.attribute9;
667   END IF;
668   IF p_claim_history_rec.attribute10  = FND_API.G_MISS_CHAR  THEN
670   END IF;
671   IF p_claim_history_rec.attribute10  IS NULL THEN
672      x_complete_rec.attribute10 := l_claim_history_rec.attribute10;
673   END IF;
674   IF p_claim_history_rec.attribute11  = FND_API.G_MISS_CHAR  THEN
675      x_complete_rec.attribute11 := NULL;
676   END IF;
677   IF p_claim_history_rec.attribute11  IS NULL THEN
678      x_complete_rec.attribute11 := l_claim_history_rec.attribute11;
679   END IF;
680   IF p_claim_history_rec.attribute12  = FND_API.G_MISS_CHAR  THEN
681      x_complete_rec.attribute12 := NULL;
682   END IF;
683   IF p_claim_history_rec.attribute12  IS NULL THEN
684      x_complete_rec.attribute12 := l_claim_history_rec.attribute12;
685   END IF;
686   IF p_claim_history_rec.attribute13  = FND_API.G_MISS_CHAR  THEN
687      x_complete_rec.attribute13 := NULL;
688   END IF;
689   IF p_claim_history_rec.attribute13  IS NULL THEN
690      x_complete_rec.attribute13 := l_claim_history_rec.attribute13;
691   END IF;
692   IF p_claim_history_rec.attribute14  = FND_API.G_MISS_CHAR  THEN
693      x_complete_rec.attribute14 := NULL;
694   END IF;
695   IF p_claim_history_rec.attribute14  IS NULL THEN
696      x_complete_rec.attribute14 := l_claim_history_rec.attribute14;
697   END IF;
698   IF p_claim_history_rec.attribute15  = FND_API.G_MISS_CHAR  THEN
699      x_complete_rec.attribute15 := NULL;
700   END IF;
701   IF p_claim_history_rec.attribute15  IS NULL THEN
702      x_complete_rec.attribute15 := l_claim_history_rec.attribute15;
703   END IF;
704   IF p_claim_history_rec.deduction_attribute_category  = FND_API.G_MISS_CHAR  THEN
705      x_complete_rec.deduction_attribute_category := NULL;
706   END IF;
707   IF p_claim_history_rec.deduction_attribute_category  IS NULL THEN
708      x_complete_rec.deduction_attribute_category := l_claim_history_rec.deduction_attribute_category;
709   END IF;
710   IF p_claim_history_rec.deduction_attribute1  = FND_API.G_MISS_CHAR  THEN
711      x_complete_rec.deduction_attribute1 := NULL;
712   END IF;
713   IF p_claim_history_rec.deduction_attribute1  IS NULL THEN
714      x_complete_rec.deduction_attribute1 := l_claim_history_rec.deduction_attribute1;
715   END IF;
716   IF p_claim_history_rec.deduction_attribute2  = FND_API.G_MISS_CHAR  THEN
717      x_complete_rec.deduction_attribute2 := NULL;
718   END IF;
719   IF p_claim_history_rec.deduction_attribute2  IS NULL THEN
720      x_complete_rec.deduction_attribute2 := l_claim_history_rec.deduction_attribute2;
721   END IF;
722   IF p_claim_history_rec.deduction_attribute3  = FND_API.G_MISS_CHAR  THEN
723      x_complete_rec.deduction_attribute3 := NULL;
724   END IF;
725   IF p_claim_history_rec.deduction_attribute3  IS NULL THEN
726      x_complete_rec.deduction_attribute3 := l_claim_history_rec.deduction_attribute3;
727   END IF;
728   IF p_claim_history_rec.deduction_attribute4  = FND_API.G_MISS_CHAR  THEN
729      x_complete_rec.deduction_attribute4 := NULL;
730   END IF;
731   IF p_claim_history_rec.deduction_attribute4  IS NULL THEN
732      x_complete_rec.deduction_attribute4 := l_claim_history_rec.deduction_attribute4;
733   END IF;
734   IF p_claim_history_rec.deduction_attribute5  = FND_API.G_MISS_CHAR  THEN
735      x_complete_rec.deduction_attribute5 := NULL;
736   END IF;
737   IF p_claim_history_rec.deduction_attribute5  IS NULL THEN
738      x_complete_rec.deduction_attribute5 := l_claim_history_rec.deduction_attribute5;
739   END IF;
740   IF p_claim_history_rec.attribute6  = FND_API.G_MISS_CHAR  THEN
741      x_complete_rec.deduction_attribute6 := NULL;
742   END IF;
743   IF p_claim_history_rec.attribute6  IS NULL THEN
744      x_complete_rec.deduction_attribute6 := l_claim_history_rec.deduction_attribute6;
745   END IF;
746   IF p_claim_history_rec.deduction_attribute7  = FND_API.G_MISS_CHAR  THEN
747      x_complete_rec.deduction_attribute7 := NULL;
748   END IF;
749   IF p_claim_history_rec.deduction_attribute7  IS NULL THEN
750      x_complete_rec.deduction_attribute7 := l_claim_history_rec.deduction_attribute7;
751   END IF;
752   IF p_claim_history_rec.deduction_attribute8  = FND_API.G_MISS_CHAR  THEN
753      x_complete_rec.deduction_attribute8 := NULL;
754   END IF;
755   IF p_claim_history_rec.deduction_attribute8  IS NULL THEN
756      x_complete_rec.deduction_attribute8 := l_claim_history_rec.deduction_attribute8;
757   END IF;
758   IF p_claim_history_rec.deduction_attribute9  = FND_API.G_MISS_CHAR  THEN
759      x_complete_rec.deduction_attribute9 := NULL;
760   END IF;
761   IF p_claim_history_rec.deduction_attribute9  IS NULL THEN
762      x_complete_rec.deduction_attribute9 := l_claim_history_rec.deduction_attribute9;
763   END IF;
764   IF p_claim_history_rec.deduction_attribute10  = FND_API.G_MISS_CHAR  THEN
765      x_complete_rec.deduction_attribute10 := NULL;
766   END IF;
767   IF p_claim_history_rec.deduction_attribute10  IS NULL THEN
768      x_complete_rec.deduction_attribute10 := l_claim_history_rec.deduction_attribute10;
769   END IF;
770   IF p_claim_history_rec.deduction_attribute11  = FND_API.G_MISS_CHAR  THEN
771      x_complete_rec.deduction_attribute11 := NULL;
772   END IF;
773   IF p_claim_history_rec.deduction_attribute11  IS NULL THEN
774      x_complete_rec.deduction_attribute11 := l_claim_history_rec.deduction_attribute11;
775   END IF;
776   IF p_claim_history_rec.deduction_attribute12  = FND_API.G_MISS_CHAR  THEN
777      x_complete_rec.deduction_attribute12 := NULL;
778   END IF;
779   IF p_claim_history_rec.deduction_attribute12  IS NULL THEN
780      x_complete_rec.deduction_attribute12 := l_claim_history_rec.deduction_attribute12;
784   END IF;
781   END IF;
782   IF p_claim_history_rec.deduction_attribute13  = FND_API.G_MISS_CHAR  THEN
783      x_complete_rec.deduction_attribute13 := NULL;
785   IF p_claim_history_rec.deduction_attribute13  IS NULL THEN
786      x_complete_rec.deduction_attribute13 := l_claim_history_rec.deduction_attribute13;
787   END IF;
788   IF p_claim_history_rec.deduction_attribute14  = FND_API.G_MISS_CHAR  THEN
789      x_complete_rec.deduction_attribute14 := NULL;
790   END IF;
791   IF p_claim_history_rec.deduction_attribute14  IS NULL THEN
792      x_complete_rec.deduction_attribute14 := l_claim_history_rec.deduction_attribute14;
793   END IF;
794   IF p_claim_history_rec.deduction_attribute15  = FND_API.G_MISS_CHAR  THEN
795      x_complete_rec.deduction_attribute15 := NULL;
796   END IF;
797   IF p_claim_history_rec.deduction_attribute15  IS NULL THEN
798      x_complete_rec.deduction_attribute15 := l_claim_history_rec.deduction_attribute15;
799   END IF;
800   IF p_claim_history_rec.org_id  = FND_API.G_MISS_NUM  THEN
801      x_complete_rec.org_id := NULL;
802   END IF;
803   IF p_claim_history_rec.org_id  IS NULL THEN
804      x_complete_rec.org_id := l_claim_history_rec.org_id;
805   END IF;
806 
807   IF p_claim_history_rec.write_off_flag  = FND_API.G_MISS_CHAR  THEN
808      x_complete_rec.write_off_flag := NULL;
809   END IF;
810   IF p_claim_history_rec.write_off_flag  IS NULL THEN
811      x_complete_rec.write_off_flag := l_claim_history_rec.write_off_flag;
812   END IF;
813 
814   IF p_claim_history_rec.write_off_threshold_amount  = FND_API.G_MISS_NUM  THEN
815      x_complete_rec.write_off_threshold_amount := NULL;
816   END IF;
817   IF p_claim_history_rec.write_off_threshold_amount  IS NULL THEN
818      x_complete_rec.write_off_threshold_amount := l_claim_history_rec.write_off_threshold_amount;
819   END IF;
820 
821   IF p_claim_history_rec.under_write_off_threshold  = FND_API.G_MISS_CHAR  THEN
822      x_complete_rec.under_write_off_threshold := NULL;
823   END IF;
824   IF p_claim_history_rec.under_write_off_threshold  IS NULL THEN
825      x_complete_rec.under_write_off_threshold := l_claim_history_rec.under_write_off_threshold;
826   END IF;
827 
828   IF p_claim_history_rec.customer_reason  = FND_API.G_MISS_CHAR  THEN
829      x_complete_rec.customer_reason := NULL;
830   END IF;
831   IF p_claim_history_rec.customer_reason  IS NULL THEN
832      x_complete_rec.customer_reason := l_claim_history_rec.customer_reason;
833   END IF;
834 
835   IF p_claim_history_rec.ship_to_cust_account_id  = FND_API.G_MISS_NUM  THEN
836      x_complete_rec.ship_to_cust_account_id       := NULL;
837   END IF;
838   IF p_claim_history_rec.ship_to_cust_account_id  IS NULL THEN
839      x_complete_rec.ship_to_cust_account_id       := l_claim_history_rec.ship_to_cust_account_id;
840   END IF;
841 
842   -- Start Bug:2781186
843   IF p_claim_history_rec.amount_applied  = FND_API.G_MISS_NUM  THEN
844      x_complete_rec.amount_applied := NULL;
845   END IF;
846   IF p_claim_history_rec.amount_applied  IS NULL THEN
847      x_complete_rec.amount_applied := l_claim_history_rec.amount_applied;
848   END IF;
849 
850   IF p_claim_history_rec.applied_receipt_id  = FND_API.G_MISS_NUM  THEN
851      x_complete_rec.applied_receipt_id := NULL;
852   END IF;
853   IF p_claim_history_rec.applied_receipt_id  IS NULL THEN
854      x_complete_rec.applied_receipt_id := l_claim_history_rec.applied_receipt_id;
855   END IF;
856 
857   IF p_claim_history_rec.applied_receipt_number  = FND_API.G_MISS_CHAR  THEN
858      x_complete_rec.applied_receipt_number := NULL;
859   END IF;
860   IF p_claim_history_rec.applied_receipt_number  IS NULL THEN
861      x_complete_rec.applied_receipt_number := l_claim_history_rec.applied_receipt_number;
862   END IF;
863 
864   IF p_claim_history_rec.wo_rec_trx_id  = FND_API.G_MISS_NUM  THEN
865      x_complete_rec.wo_rec_trx_id := NULL;
866   END IF;
867   IF p_claim_history_rec.wo_rec_trx_id  IS NULL THEN
868      x_complete_rec.wo_rec_trx_id := l_claim_history_rec.wo_rec_trx_id;
869   END IF;
870   -- End Bug:2781186
871 
872   IF p_claim_history_rec.group_claim_id  = FND_API.G_MISS_NUM  THEN
873      x_complete_rec.group_claim_id := NULL;
874   END IF;
875   IF p_claim_history_rec.group_claim_id  IS NULL  THEN
876      x_complete_rec.group_claim_id := l_claim_history_rec.group_claim_id;
877   END IF;
878   IF p_claim_history_rec.appr_wf_item_key  = FND_API.G_MISS_CHAR  THEN
879      x_complete_rec.appr_wf_item_key := NULL;
880   END IF;
881   IF p_claim_history_rec.appr_wf_item_key  IS NULL  THEN
882      x_complete_rec.appr_wf_item_key := l_claim_history_rec.appr_wf_item_key;
883   END IF;
884   IF p_claim_history_rec.cstl_wf_item_key  = FND_API.G_MISS_CHAR  THEN
885      x_complete_rec.cstl_wf_item_key := NULL;
886   END IF;
887   IF p_claim_history_rec.cstl_wf_item_key  IS NULL  THEN
888      x_complete_rec.cstl_wf_item_key := l_claim_history_rec.cstl_wf_item_key;
889   END IF;
890   IF p_claim_history_rec.batch_type  = FND_API.G_MISS_CHAR  THEN
891      x_complete_rec.batch_type := NULL;
892   END IF;
893   IF p_claim_history_rec.batch_type  IS NULL  THEN
894      x_complete_rec.batch_type := l_claim_history_rec.batch_type;
895   END IF;
896 
897    -- Debug Message
898    IF OZF_DEBUG_LOW_ON THEN
899       FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
900       FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
901       FND_MSG_PUB.Add;
902    END IF;
903  EXCEPTION
904    WHEN FND_API.G_EXC_ERROR THEN
905       x_return_status := FND_API.G_RET_STS_ERROR;
906    WHEN OTHERS THEN
907       IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
911       x_return_status := FND_API.g_ret_sts_unexp_error;
908          FND_MESSAGE.set_name('OZF', 'OZF_CLAIM_HIST_COMPLETE_ERR');
909          FND_MSG_PUB.add;
910       END IF;
912 END Complete_Claim_History_Rec;
913 
914 ---------------------------------------------------------------------
915 -- PROCEDURE
916 --    Create_Claims_History
917 --
918 -- PURPOSE
919 --    This procedure inserts a record in ozf_claims_history_all table by calling
920 --    the table handler package.
921 --
922 -- PARAMETERS
923 --    p_CLAIMS_HISTORY_Rec: The record that you want to insert.
924 --    x_CLAIM_HISTORY_ID:   Primary key of the new record in the table.
925 --
926 -- NOTES:
927 --
928 ---------------------------------------------------------------------
929 
930 PROCEDURE Create_Claims_History(
931     p_Api_Version_Number         IN   NUMBER,
932     p_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
933     p_Commit                     IN   VARCHAR2     := FND_API.G_FALSE,
934     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
935 
936     x_Return_Status              OUT NOCOPY  VARCHAR2,
937     x_Msg_Count                  OUT NOCOPY  NUMBER,
938     x_Msg_Data                   OUT NOCOPY  VARCHAR2,
939 
940     p_CLAIMS_HISTORY_Rec         IN   CLAIMS_HISTORY_Rec_Type  := G_MISS_CLAIMS_HISTORY_REC,
941     x_CLAIM_HISTORY_ID           OUT NOCOPY  NUMBER
942     )
943 IS
944 l_api_name                CONSTANT VARCHAR2(30) := 'Create_claims_history';
945 l_api_version_number      CONSTANT NUMBER   := 1.0;
946 l_return_status_full      VARCHAR2(1);
947 l_object_version_number   NUMBER := 1;
948 l_org_id                  NUMBER;
949 l_CLAIM_HISTORY_ID        NUMBER;
950 
951 l_return_status           varchar2(30);
952 l_msg_data                varchar2(2000);
953 l_msg_count               number;
954 
955 BEGIN
956       -- Standard Start of API savepoint
957       SAVEPOINT CREATE_CLAIMS_HISTORY_PVT;
958       -- Standard call to check for call compatibility.
959       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
960                                            p_api_version_number,
961                                            l_api_name,
962                                            G_PKG_NAME)
963       THEN
964           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
965       END IF;
966 
967       -- Initialize message list if p_init_msg_list is set to TRUE.
968       IF FND_API.to_Boolean( p_init_msg_list )
969       THEN
970           FND_MSG_PUB.initialize;
971       END IF;
972 
973       IF OZF_DEBUG_LOW_ON THEN
974          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
975          FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
976          FND_MSG_PUB.Add;
977       END IF;
978 
979       -- Initialize API return status to SUCCESS
980       x_return_status := FND_API.G_RET_STS_SUCCESS;
981 
982       -- ******************************************************************
983       -- Validate Environment
984       -- ******************************************************************
985       IF (FND_GLOBAL.User_Id IS NULL) THEN
986           IF (FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR)) THEN
987              FND_MESSAGE.Set_Name('OZF', 'USER_PROFILE_MISSING');
988              FND_MSG_PUB.ADD;
989           END IF;
990           RAISE FND_API.G_EXC_ERROR;
991       END IF;
992 
993       IF (P_validation_level >= FND_API.G_VALID_LEVEL_FULL) THEN
994 
995 	  -- Invoke validation procedures
996           Validate_claims_history(
997              p_api_version_number  => 1.0,
998              p_init_msg_list       => FND_API.G_FALSE,
999              p_validation_level    => p_validation_level,
1000              P_CLAIMS_HISTORY_Rec  => p_CLAIMS_HISTORY_Rec,
1001              x_return_status       => l_return_status,
1002              x_msg_count           => l_msg_count,
1003              x_msg_data            => l_msg_data
1004 	  );
1005       END IF;
1006       IF l_return_status = FND_API.g_ret_sts_error THEN
1007          RAISE FND_API.g_exc_error;
1008       ELSIF l_return_status = FND_API.g_ret_sts_unexp_error THEN
1009          RAISE FND_API.g_exc_unexpected_error;
1010       END IF;
1011 
1012       -- Check whether claim_history_id exists
1013       IF (p_claims_history_rec.claim_history_id is NOT NULL AND
1014           p_claims_history_rec.claim_history_id <> FND_API.G_MISS_NUM) THEN
1015          l_claim_history_id := p_claims_history_rec.claim_history_id;
1016       END IF;
1017 
1018       l_org_id :=   p_claims_history_rec.org_id;
1019 
1020       -- Invoke table handler(OZF_claims_history_PKG.Insert_Row)
1021       BEGIN
1022         OZF_claims_history_PKG.Insert_Row(
1023           px_CLAIM_HISTORY_ID       => l_claim_history_id,
1024           px_OBJECT_VERSION_NUMBER  => l_object_version_number,
1025           p_LAST_UPDATE_DATE        => SYSDATE,
1026           p_LAST_UPDATED_BY         => FND_GLOBAL.USER_ID,
1027           p_CREATION_DATE           => SYSDATE,
1028           p_CREATED_BY              => FND_GLOBAL.USER_ID,
1029           p_LAST_UPDATE_LOGIN       => FND_GLOBAL.CONC_LOGIN_ID,
1030           p_REQUEST_ID              => p_CLAIMS_HISTORY_rec.REQUEST_ID,
1031           p_PROGRAM_APPLICATION_ID  => p_CLAIMS_HISTORY_rec.PROGRAM_APPLICATION_ID,
1032           p_PROGRAM_UPDATE_DATE     => p_CLAIMS_HISTORY_rec.PROGRAM_UPDATE_DATE,
1033           p_PROGRAM_ID              => p_CLAIMS_HISTORY_rec.PROGRAM_ID,
1034           p_CREATED_FROM            => p_CLAIMS_HISTORY_rec.CREATED_FROM,
1035           p_BATCH_ID                => p_CLAIMS_HISTORY_rec.BATCH_ID,
1039           p_CLAIM_CLASS             => p_CLAIMS_HISTORY_REC.CLAIM_CLASS,
1036           p_CLAIM_ID                => p_CLAIMS_HISTORY_rec.CLAIM_ID,
1037           p_CLAIM_NUMBER            => p_CLAIMS_HISTORY_rec.CLAIM_NUMBER,
1038           p_CLAIM_TYPE_ID           => p_CLAIMS_HISTORY_rec.CLAIM_TYPE_ID,
1040 	       p_CLAIM_DATE              => p_CLAIMS_HISTORY_rec.CLAIM_DATE,
1041           p_DUE_DATE                => p_CLAIMS_HISTORY_rec.DUE_DATE,
1042           p_OWNER_ID                => p_CLAIMS_HISTORY_rec.OWNER_ID,
1043           p_HISTORY_EVENT           => p_CLAIMS_HISTORY_rec.HISTORY_EVENT,
1044           p_HISTORY_EVENT_DATE      => p_CLAIMS_HISTORY_rec.HISTORY_EVENT_DATE,
1045           p_HISTORY_EVENT_DESCRIPTION => p_CLAIMS_HISTORY_rec.HISTORY_EVENT_DESCRIPTION,
1046           p_SPLIT_FROM_CLAIM_ID     => p_CLAIMS_HISTORY_rec.SPLIT_FROM_CLAIM_ID,
1047           p_duplicate_claim_id  => p_claims_history_rec.duplicate_claim_id,
1048 	       p_SPLIT_DATE              => p_CLAIMS_HISTORY_rec.SPLIT_DATE,
1049           p_ROOT_CLAIM_ID           => p_claims_history_rec.ROOT_CLAIM_ID,
1050           p_AMOUNT                  => p_CLAIMS_HISTORY_rec.AMOUNT,
1051           p_AMOUNT_ADJUSTED         => p_CLAIMS_HISTORY_rec.AMOUNT_ADJUSTED,
1052           p_AMOUNT_REMAINING        => p_CLAIMS_HISTORY_rec.AMOUNT_REMAINING,
1053           p_AMOUNT_SETTLED          => p_CLAIMS_HISTORY_rec.AMOUNT_SETTLED,
1054           p_ACCTD_AMOUNT            => p_CLAIMS_HISTORY_rec.ACCTD_AMOUNT,
1055 	       p_acctd_amount_remaining  => p_claims_history_rec.acctd_amount_remaining,
1056           p_acctd_AMOUNT_ADJUSTED   => p_CLAIMS_HISTORY_rec.acctd_AMOUNT_ADJUSTED,
1057           p_acctd_AMOUNT_SETTLED    => p_CLAIMS_HISTORY_rec.acctd_AMOUNT_SETTLED,
1058           p_tax_amount  => p_claims_history_rec.tax_amount,
1059           p_tax_code  => p_claims_history_rec.tax_code,
1060           p_tax_calculation_flag  => p_claims_history_rec.tax_calculation_flag,
1061           p_CURRENCY_CODE           => p_CLAIMS_HISTORY_rec.CURRENCY_CODE,
1062           p_EXCHANGE_RATE_TYPE      => p_CLAIMS_HISTORY_rec.EXCHANGE_RATE_TYPE,
1063           p_EXCHANGE_RATE_DATE      => p_CLAIMS_HISTORY_rec.EXCHANGE_RATE_DATE,
1064           p_EXCHANGE_RATE           => p_CLAIMS_HISTORY_rec.EXCHANGE_RATE,
1065           p_SET_OF_BOOKS_ID         => p_CLAIMS_HISTORY_rec.SET_OF_BOOKS_ID,
1066           p_ORIGINAL_CLAIM_DATE     => p_CLAIMS_HISTORY_rec.ORIGINAL_CLAIM_DATE,
1067           p_SOURCE_OBJECT_ID        => p_CLAIMS_HISTORY_rec.SOURCE_OBJECT_ID,
1068           p_SOURCE_OBJECT_CLASS     => p_CLAIMS_HISTORY_rec.SOURCE_OBJECT_CLASS,
1069           p_SOURCE_OBJECT_TYPE_ID   => p_CLAIMS_HISTORY_rec.SOURCE_OBJECT_TYPE_ID,
1070           p_SOURCE_OBJECT_NUMBER    => p_CLAIMS_HISTORY_rec.SOURCE_OBJECT_NUMBER,
1071           p_CUST_ACCOUNT_ID         => p_CLAIMS_HISTORY_rec.CUST_ACCOUNT_ID,
1072           p_CUST_BILLTO_ACCT_SITE_ID=> p_CLAIMS_HISTORY_rec.CUST_BILLTO_ACCT_SITE_ID,
1073           p_cust_shipto_acct_site_id  => p_claims_history_rec.cust_shipto_acct_site_id,
1074           p_LOCATION_ID              => p_CLAIMS_HISTORY_rec.LOCATION_ID,
1075           p_PAY_RELATED_ACCOUNT_FLAG => p_claims_history_rec.PAY_RELATED_ACCOUNT_FLAG,
1076           p_RELATED_CUST_ACCOUNT_ID  => p_claims_history_rec.RELATED_CUST_ACCOUNT_ID,
1077           p_RELATED_SITE_USE_ID      => p_claims_history_rec.RELATED_SITE_USE_ID,
1078           p_RELATIONSHIP_TYPE        => p_claims_history_rec.RELATIONSHIP_TYPE,
1079           p_VENDOR_ID                => p_claims_history_rec.VENDOR_ID,
1080           p_VENDOR_SITE_ID           => p_claims_history_rec.VENDOR_SITE_ID,
1081 	       p_REASON_TYPE             => p_CLAIMS_HISTORY_rec.REASON_TYPE,
1082           p_REASON_CODE_ID          => p_CLAIMS_HISTORY_rec.REASON_CODE_ID,
1083           p_TASK_TEMPLATE_GROUP_ID  => p_claims_history_rec.TASK_TEMPLATE_GROUP_ID,
1084           p_STATUS_CODE             => p_CLAIMS_HISTORY_rec.STATUS_CODE,
1085           p_USER_STATUS_ID          => p_CLAIMS_HISTORY_rec.USER_STATUS_ID,
1086           p_SALES_REP_ID            => p_CLAIMS_HISTORY_rec.SALES_REP_ID,
1087           p_COLLECTOR_ID            => p_CLAIMS_HISTORY_rec.COLLECTOR_ID,
1088           p_CONTACT_ID              => p_CLAIMS_HISTORY_rec.CONTACT_ID,
1089           p_BROKER_ID               => p_CLAIMS_HISTORY_rec.BROKER_ID,
1090           p_TERRITORY_ID            => p_CLAIMS_HISTORY_rec.TERRITORY_ID,
1091           p_CUSTOMER_REF_DATE       => p_CLAIMS_HISTORY_rec.CUSTOMER_REF_DATE,
1092           p_CUSTOMER_REF_NUMBER     => p_CLAIMS_HISTORY_rec.CUSTOMER_REF_NUMBER,
1093           p_ASSIGNED_TO             => p_CLAIMS_HISTORY_rec.ASSIGNED_TO,
1094           p_RECEIPT_ID              => p_CLAIMS_HISTORY_rec.RECEIPT_ID,
1095           p_RECEIPT_NUMBER          => p_CLAIMS_HISTORY_rec.RECEIPT_NUMBER,
1096           p_DOC_SEQUENCE_ID         => p_CLAIMS_HISTORY_rec.DOC_SEQUENCE_ID,
1097           p_DOC_SEQUENCE_VALUE      => p_CLAIMS_HISTORY_rec.DOC_SEQUENCE_VALUE,
1098           p_GL_DATE                 => p_CLAIMS_HISTORY_rec.GL_DATE,
1099           p_PAYMENT_METHOD          => p_CLAIMS_HISTORY_rec.PAYMENT_METHOD,
1100           p_VOUCHER_ID              => p_CLAIMS_HISTORY_rec.VOUCHER_ID,
1101           p_VOUCHER_NUMBER          => p_CLAIMS_HISTORY_rec.VOUCHER_NUMBER,
1102           p_PAYMENT_REFERENCE_ID    => p_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_ID,
1103           p_PAYMENT_REFERENCE_NUMBER => p_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_NUMBER,
1104           p_PAYMENT_REFERENCE_DATE  => p_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_DATE,
1105           p_PAYMENT_STATUS          => p_CLAIMS_HISTORY_rec.PAYMENT_STATUS,
1106           p_APPROVED_FLAG           => p_CLAIMS_HISTORY_rec.APPROVED_FLAG,
1107           p_APPROVED_DATE           => p_CLAIMS_HISTORY_rec.APPROVED_DATE,
1108           p_APPROVED_BY             => p_CLAIMS_HISTORY_rec.APPROVED_BY,
1109           p_SETTLED_DATE            => p_CLAIMS_HISTORY_rec.SETTLED_DATE,
1110           p_SETTLED_BY              => p_CLAIMS_HISTORY_rec.SETTLED_BY,
1111           p_effective_date  => p_claims_history_rec.effective_date,
1112           p_CUSTOM_SETUP_ID         => p_claims_history_rec.CUSTOM_SETUP_ID,
1113           p_TASK_ID                 => p_claims_history_rec.TASK_ID,
1114           p_COUNTRY_ID              => p_claims_history_rec.COUNTRY_ID,
1115 	       p_ORDER_TYPE_ID              => p_claims_history_rec.ORDER_TYPE_ID,
1116           p_COMMENTS                => p_CLAIMS_HISTORY_rec.COMMENTS,
1117           p_LETTER_ID               => p_CLAIMS_HISTORY_rec.LETTER_ID,
1118           p_LETTER_DATE             => p_CLAIMS_HISTORY_rec.LETTER_DATE,
1119           p_TASK_SOURCE_OBJECT_ID   => p_CLAIMS_HISTORY_rec.TASK_SOURCE_OBJECT_ID,
1120           p_TASK_SOURCE_OBJECT_TYPE_CODE => p_CLAIMS_HISTORY_rec.TASK_SOURCE_OBJECT_TYPE_CODE,
1121           p_ATTRIBUTE_CATEGORY      => p_CLAIMS_HISTORY_rec.ATTRIBUTE_CATEGORY,
1122           p_ATTRIBUTE1              => p_CLAIMS_HISTORY_rec.ATTRIBUTE1,
1123           p_ATTRIBUTE2              => p_CLAIMS_HISTORY_rec.ATTRIBUTE2,
1124           p_ATTRIBUTE3              => p_CLAIMS_HISTORY_rec.ATTRIBUTE3,
1125           p_ATTRIBUTE4              => p_CLAIMS_HISTORY_rec.ATTRIBUTE4,
1126           p_ATTRIBUTE5              => p_CLAIMS_HISTORY_rec.ATTRIBUTE5,
1127           p_ATTRIBUTE6              => p_CLAIMS_HISTORY_rec.ATTRIBUTE6,
1128           p_ATTRIBUTE7              => p_CLAIMS_HISTORY_rec.ATTRIBUTE7,
1129           p_ATTRIBUTE8              => p_CLAIMS_HISTORY_rec.ATTRIBUTE8,
1130           p_ATTRIBUTE9              => p_CLAIMS_HISTORY_rec.ATTRIBUTE9,
1131           p_ATTRIBUTE10             => p_CLAIMS_HISTORY_rec.ATTRIBUTE10,
1132           p_ATTRIBUTE11             => p_CLAIMS_HISTORY_rec.ATTRIBUTE11,
1133           p_ATTRIBUTE12             => p_CLAIMS_HISTORY_rec.ATTRIBUTE12,
1134           p_ATTRIBUTE13             => p_CLAIMS_HISTORY_rec.ATTRIBUTE13,
1135           p_ATTRIBUTE14             => p_CLAIMS_HISTORY_rec.ATTRIBUTE14,
1136           p_ATTRIBUTE15             => p_CLAIMS_HISTORY_rec.ATTRIBUTE15,
1137           p_DEDUCTION_ATTRIBUTE_CATEGORY  => p_claims_history_rec.DEDUCTION_ATTRIBUTE_CATEGORY,
1138           p_DEDUCTION_ATTRIBUTE1  => p_claims_history_rec.DEDUCTION_ATTRIBUTE1,
1139           p_DEDUCTION_ATTRIBUTE2  => p_claims_history_rec.DEDUCTION_ATTRIBUTE2,
1140           p_DEDUCTION_ATTRIBUTE3  => p_claims_history_rec.DEDUCTION_ATTRIBUTE3,
1141           p_DEDUCTION_ATTRIBUTE4  => p_claims_history_rec.DEDUCTION_ATTRIBUTE4,
1142           p_DEDUCTION_ATTRIBUTE5  => p_claims_history_rec.DEDUCTION_ATTRIBUTE5,
1143           p_DEDUCTION_ATTRIBUTE6  => p_claims_history_rec.DEDUCTION_ATTRIBUTE6,
1144           p_DEDUCTION_ATTRIBUTE7  => p_claims_history_rec.DEDUCTION_ATTRIBUTE7,
1145           p_DEDUCTION_ATTRIBUTE8  => p_claims_history_rec.DEDUCTION_ATTRIBUTE8,
1146           p_DEDUCTION_ATTRIBUTE9  => p_claims_history_rec.DEDUCTION_ATTRIBUTE9,
1147           p_DEDUCTION_ATTRIBUTE10  => p_claims_history_rec.DEDUCTION_ATTRIBUTE10,
1148           p_DEDUCTION_ATTRIBUTE11  => p_claims_history_rec.DEDUCTION_ATTRIBUTE11,
1149           p_DEDUCTION_ATTRIBUTE12  => p_claims_history_rec.DEDUCTION_ATTRIBUTE12,
1150           p_DEDUCTION_ATTRIBUTE13  => p_claims_history_rec.DEDUCTION_ATTRIBUTE13,
1151           p_DEDUCTION_ATTRIBUTE14  => p_claims_history_rec.DEDUCTION_ATTRIBUTE14,
1152           p_DEDUCTION_ATTRIBUTE15  => p_claims_history_rec.DEDUCTION_ATTRIBUTE15,
1153 	       px_ORG_ID                 => l_org_id,
1154           p_WRITE_OFF_FLAG  => p_claims_history_rec.WRITE_OFF_FLAG,
1155           p_WRITE_OFF_THRESHOLD_AMOUNT  => p_claims_history_rec.WRITE_OFF_THRESHOLD_AMOUNT,
1156           p_UNDER_WRITE_OFF_THRESHOLD  => p_claims_history_rec.UNDER_WRITE_OFF_THRESHOLD,
1157           p_CUSTOMER_REASON  => p_claims_history_rec.CUSTOMER_REASON,
1158           p_SHIP_TO_CUST_ACCOUNT_ID         => p_CLAIMS_HISTORY_rec.SHIP_TO_CUST_ACCOUNT_ID,
1159           p_AMOUNT_APPLIED             => p_claims_history_rec.AMOUNT_APPLIED,              --BUG:2781186
1160           p_APPLIED_RECEIPT_ID         => p_claims_history_rec.APPLIED_RECEIPT_ID,          --BUG:2781186
1161           p_APPLIED_RECEIPT_NUMBER     => p_claims_history_rec.APPLIED_RECEIPT_NUMBER,      --BUG:2781186
1162           p_WO_REC_TRX_ID              => p_claims_history_rec.WO_REC_TRX_ID,
1163           p_GROUP_CLAIM_ID             => p_claims_history_rec.GROUP_CLAIM_ID,
1164           p_APPR_WF_ITEM_KEY           => p_claims_history_rec.APPR_WF_ITEM_KEY,
1165           p_CSTL_WF_ITEM_KEY           => p_claims_history_rec.CSTL_WF_ITEM_KEY,
1166           p_BATCH_TYPE                 => p_claims_history_rec.BATCH_TYPE
1167 
1168       );
1169       EXCEPTION
1170         WHEN OTHERS THEN
1171            IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
1172               FND_MESSAGE.set_name('OZF', 'OZF_TABLE_HANDLER_ERROR');
1173               FND_MSG_PUB.add;
1174            END IF;
1175            RAISE FND_API.g_exc_error;
1176       END;
1177 
1178       x_claim_history_id := l_claim_history_id;
1179 
1180       -- Standard check for p_commit
1181       IF FND_API.to_Boolean( p_commit ) THEN
1182          COMMIT WORK;
1183       END IF;
1184 
1185       IF OZF_DEBUG_LOW_ON THEN
1186          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
1187          FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
1188          FND_MSG_PUB.Add;
1189       END IF;
1190 
1191       -- Standard call to get message count and if count is 1, get message info.
1192       FND_MSG_PUB.Count_And_Get(
1193          p_count          =>   x_msg_count,
1194          p_data           =>   x_msg_data
1195       );
1196 EXCEPTION
1197    WHEN OZF_Utility_PVT.resource_locked THEN
1198       x_return_status := FND_API.g_ret_sts_error;
1199       OZF_Utility_PVT.Error_Message(p_message_name => 'OZF_API_RESOURCE_LOCKED');
1200    WHEN FND_API.G_EXC_ERROR THEN
1201       ROLLBACK TO CREATE_Claims_History_PVT;
1202       x_return_status := FND_API.G_RET_STS_ERROR;
1203       -- Standard call to get message count and if count=1, get the message
1204       FND_MSG_PUB.Count_And_Get (
1205          p_encoded => FND_API.G_FALSE,
1206          p_count   => x_msg_count,
1207          p_data    => x_msg_data
1208       );
1209    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1210       ROLLBACK TO CREATE_Claims_History_PVT;
1211       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1212       -- Standard call to get message count and if count=1, get the message
1213       FND_MSG_PUB.Count_And_Get (
1214          p_encoded => FND_API.G_FALSE,
1215          p_count => x_msg_count,
1216          p_data  => x_msg_data
1217       );
1218    WHEN OTHERS THEN
1219       ROLLBACK TO CREATE_Claims_History_PVT;
1220       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1221       IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1222          FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1223       END IF;
1224       -- Standard call to get message count and if count=1, get the message
1225       FND_MSG_PUB.Count_And_Get (
1226          p_encoded => FND_API.G_FALSE,
1227          p_count => x_msg_count,
1228          p_data  => x_msg_data
1229       );
1230 End Create_Claims_History;
1231 ---------------------------------------------------------------------
1232 -- PROCEDURE
1233 --    change_description
1234 --
1235 -- PURPOSE
1236 --    This procedure creates a description of an event.
1237 --
1238 -- PARAMETERS
1239 --    px_description:  description that has been generated.
1240 --    p_column_name:  column name that you want to add to the event description
1241 --
1242 -- NOTES:
1243 --
1244 ---------------------------------------------------------------------
1245 PROCEDURE change_description (px_description   IN OUT NOCOPY VARCHAR2,
1246                               p_column_desc   IN  VARCHAR2)
1247 IS
1248 l_description varchar2(2000);
1249 BEGIN
1250    IF px_description is null THEN
1251       l_description := p_column_desc;
1252    ELSE
1253       l_description := px_description || ',' || p_column_desc;
1254    END IF;
1255    px_description := l_description;
1256 
1257 End change_description;
1258 ---------------------------------------------------------------------
1259 -- PROCEDURE
1260 --    Check_Create_History
1261 --
1262 -- PURPOSE
1263 --    This procedure check whether we should create a history snapshot
1264 --    of a claim.
1265 --
1266 -- PARAMETERS
1267 --    p_claim   :  claim record.
1268 --    p_event   :  Indicator to show whether the current caller is from
1269 --                 a claim update, which is "UPDATE" OR
1270 --                 a claim line update which is "LINE"
1271 --    x_history_event : This is the event that will be recorded in the
1272 --                      database.
1273 --    x_history_event_description : Event description based on what happend.
1274 --    x_needed_to_create : Whether we need to create a snapshot or not.
1275 --
1276 -- NOTES:
1277 --
1278 ---------------------------------------------------------------------
1279 /*
1280 PROCEDURE Check_Create_History_test(p_claim            IN  OZF_CLAIM_PVT.claim_rec_type,
1281                                p_event            IN  VARCHAR2,
1282                                x_history_event    OUT NOCOPY VARCHAR2,
1283                                x_history_event_description OUT NOCOPY VARCHAR2,
1284                                x_needed_to_create OUT NOCOPY VARCHAR2,
1285 			       x_return_status    OUT NOCOPY VARCHAR2
1286 )
1287 IS
1288 CURSOR column_names_csr
1289 SELECT db_table_name, db_column_name, ak_attribute_code
1290 FROM ams_column_rules
1291 WHERE rule_type = 'HISTORY';
1292 
1293 TYPE column_names_table_tye is table of column_names_csr%rowtype;
1294 l_column_names_tbl column_names_table_type;
1295 
1296 l_index number = 0;
1297 l_count number = null;
1298 l_select varchar2(500);
1299 l_from  varchar2(100);
1300 l_where varchar2(500);
1301 l_stmt varchar2(1200);
1302 
1303 l_count number;
1304 BEGIN
1305 
1306   OPEN column_names_csr;
1307   LOOP
1308     FETCH column_names_csr INTO l_column_names_tbl(l_index);
1309     EXIT WHEN column_names_crs%NOTFOUND;
1310     l_index := l_index +1;
1311   END LOOP;
1312   CLOSE column_names_csr;
1313 
1314   FOR i in l..l_column_names_tbl.COUNT LOOP
1315   l_str := 'p_claim'.db_column_name;
1316 
1317     l_column_name_table(i).db_column_name
1318     l_stmt :=          'SELECT count(claim_id) ';
1319     l_stmt := l_stmt ||' from ' || l_column_names_tbl(i).db_table_name;
1320     l_stmt := l_stmt ||' where '|| l_column_name_table(i).db_column_name ||'= :1';
1321     l_stmt := l_stmt ||' AND '  || 'claim_id = '|| p_claim.claim_id;
1322 
1323     EXECUTE IMMEDIATE l_stmt USING p_claim.amount OUT NOCOPY l_count;
1324 
1325 
1326   END LOOP;
1327 
1328  change_description (
1329 	        p_description => l_event_description,
1330                 p_column_name => 'reason_type',
1331                 x_description => l_event_description
1332 	     );
1333 
1334 EXCEPTION
1335    WHEN FND_API.G_EXC_ERROR THEN
1336       x_return_status := FND_API.G_RET_STS_ERROR;
1337    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1338       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1339    WHEN OTHERS THEN
1340       IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
1341          FND_MESSAGE.set_name('OZF', 'OZF_CLAIM_CHK_CRT_HIST_ERR');
1342          FND_MSG_PUB.add;
1343       END IF;
1344       x_return_status := FND_API.g_ret_sts_unexp_error;
1345 END check_create_history;
1346 */
1347 
1348 ---------------------------------------------------------------------
1349 PROCEDURE Check_Create_History(p_claim            IN  OZF_CLAIM_PVT.claim_rec_type,
1350                                p_event            IN  VARCHAR2,
1351                                x_history_event    OUT NOCOPY VARCHAR2,
1352                                x_history_event_description OUT NOCOPY VARCHAR2,
1353                                x_needed_to_create OUT NOCOPY VARCHAR2,
1354 			       x_return_status    OUT NOCOPY VARCHAR2
1355 )
1356 IS
1357 l_system_status     varchar2(30);
1358 l_claim_hist_id     number;
1359 l_event_description varchar2(2000) := null;
1360 l_history_event     varchar2(30)   := null;
1361 l_return            boolean := FALSE; -- return value default to be FLASE.
1362                                       -- Its value will be changed to TRUE if we need to create history
1363 
1364 l_return_status  varchar2(30);
1365 l_msg_data       varchar2(2000);
1366 l_msg_count      number;
1367 
1368 --Variables to track the repetitions of the column rules.
1369 l_payment_method_rule   boolean := false;
1370 l_user_status_id_rule   boolean := false;
1371 --l_claim_number_rule     boolean := false;
1372 --l_tax_code_rule         boolean := false;
1373 l_amount_rule           boolean := false;
1374 l_claim_type_id_rule    boolean := false;
1375 l_reason_code_id_rule   boolean := false;
1376 l_duplicate_claim_id_rule    boolean := false;
1377 l_currency_code_rule         boolean := false;
1378 l_claim_date_rule            boolean := false;
1379 l_due_date_rule              boolean := false;
1380 l_task_template_group_id_rule boolean := false;
1381 l_owner_id_rule               boolean := false;
1382 
1383 
1384 CURSOR  user_selected_columns_csr IS
1385 SELECT  db_column_name, ak_attribute_code
1389 AND     rule_type = 'HISTORY'
1386 FROM    ams_column_rules
1387 WHERE   object_type = 'CLAM'
1388 AND db_table_name = 'OZF_CLAIMS_ALL'
1390 UNION ALL
1391 SELECT 'GL_DATE','OZF_GL_DATE' FROM DUAL;
1392 
1393 l_column_info user_selected_columns_csr%rowtype;
1394 
1395 CURSOR claim_rec_csr(p_id in number) IS
1396 SELECT claim_type_id,
1397        claim_date,
1398        due_date,
1399        task_template_group_id,
1400        reason_code_id,
1401        owner_id,
1402        sales_rep_id,
1403        broker_id,
1404        status_code,
1405        user_status_id,
1406        cust_account_id,
1407        cust_billto_acct_site_id,
1408        cust_shipto_acct_site_id,
1409        contact_id,
1410        customer_ref_number,
1411        customer_ref_date,
1412        amount,
1413        currency_code,
1414        exchange_rate_type,
1415        exchange_rate,
1416        exchange_rate_date,
1417        duplicate_claim_id,
1418        order_type_id,
1419        comments,
1420        effective_date,
1421        gl_date,
1422        payment_method,
1423        pay_related_account_flag,
1424        related_cust_account_id,
1425        related_site_use_id,
1426        relationship_type,
1427        vendor_id,
1428        vendor_site_id
1429 FROM   ozf_claims_history_all
1430 WHERE  claim_id = p_id
1431 order by claim_history_id desc;
1432 
1433 l_claim_rec claim_rec_csr%rowtype;
1434 
1435 CURSOR history_exists_csr(p_id in number) IS
1436 SELECT claim_history_id
1437 FROM   ozf_claims_history_all
1438 WHERE  claim_id = p_id;
1439 
1440 l_api_name varchar2(30):='Check_Create_history';
1441 l_status_changed boolean := false;
1442 BEGIN
1443    -- Initialize API return status to sucess
1444    x_return_status := FND_API.G_RET_STS_SUCCESS;
1445 
1446    IF OZF_DEBUG_LOW_ON THEN
1447       FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
1448       FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
1449       FND_MSG_PUB.Add;
1450    END IF;
1451 
1452    -- First based on event, we check history
1453    IF (p_event = G_NEW_EVENT) THEN
1454       l_history_event := G_NEW_EVENT;
1455       change_description (
1456          px_description => l_event_description,
1457          p_column_desc =>  'OZF_CLAIM_CREATE'
1458       );
1459       l_return := TRUE;
1460    ELSIF (p_event = G_LINE_EVENT) THEN
1461       l_history_event := G_LINE_EVENT;
1462       change_description (
1463          px_description => l_event_description,
1464          p_column_desc => 'OZF_CLAIM_LINES'
1465       );
1466       l_return := TRUE;
1467    ELSIF (p_event = G_SPLIT_EVENT)  THEN
1468       l_history_event := G_SPLIT_EVENT;
1469       change_description (
1470          px_description => l_event_description,
1471          p_column_desc => 'OZF_CLAIM_SPLIT'
1472       );
1473      l_return := TRUE;
1474    ELSIF (p_event = G_NO_CHANGE_EVENT) THEN
1475      l_history_event := null;
1476      l_event_description := null;
1477      l_return := FALSE;
1478    -- -------------------------------------------------------------------------------------------
1479    -- Bug        : 2781186
1480    -- Changed by : (Uday Poluri)  Date: 03-Jun-2003
1481    -- Comments   : Follwing two ELSEIF are added to create history incase of APPLY/UNAPPLY
1482    --              Subsequent receipt application.
1483    -- -------------------------------------------------------------------------------------------
1484    ELSIF (p_event = G_SUBSEQUENT_APPLY_EVENT)  THEN
1485       l_history_event := G_SUBSEQUENT_APPLY_CHG_EVENT;
1486       change_description (
1487          px_description => l_event_description,
1488          p_column_desc => 'OZF_CLAIM_SUBSEQUENT_APPN'
1489       );
1490      l_return := TRUE;
1491    ELSIF (p_event = G_SUBSEQUENT_UNAPPLY_EVENT)  THEN
1492       l_history_event := G_SUBSEQUENT_UNAPPLY_CHG_EVENT;
1493       change_description (
1494          px_description => l_event_description,
1495          p_column_desc => 'OZF_CLAIM_SUBSEQUENT_UNAPPN'
1496       );
1497      l_return := TRUE;
1498    -- End Bug: 2781186 --------------------------------------------------------------------------
1499    ELSIF (p_event = G_UPDATE_EVENT) THEN
1500    -- If it is an update event and the claim is in NEW status
1501    -- then no need to create/update the history record (uday)
1502      IF p_claim.status_code = 'NEW' THEN
1503         l_history_event := null;
1504          l_event_description := null;
1505          l_return := FALSE;
1506      ELSE
1507          -- If event is change, we need to check each column
1508          OPEN CLAIM_REC_CSR(p_claim.claim_id);
1509          FETCH CLAIM_REC_CSR INTO l_claim_rec;
1510          CLOSE CLAIM_REC_CSR;
1511 
1512          OPEN user_selected_columns_csr;
1513          LOOP
1514              FETCH user_selected_columns_csr INTO l_column_info;
1515              EXIT WHEN user_selected_columns_csr%NOTFOUND;
1516              IF l_column_info.db_column_name = 'CLAIM_TYPE_ID' AND l_claim_type_id_rule = false
1517              AND
1518             ((p_claim.claim_type_id is null      and  l_claim_rec.claim_type_id is not null) OR
1519             (p_claim.claim_type_id is not null  and  l_claim_rec.claim_type_id is null) OR
1520             (p_claim.claim_type_id is not null  and  l_claim_rec.claim_type_id is not null AND
1521              p_claim.claim_type_id <> l_claim_rec.claim_type_id))
1522              THEN
1523                  l_history_event := G_CHANGE_EVENT;
1524                  change_description (
1525                 px_description => l_event_description,
1526                      p_column_desc => l_column_info.ak_attribute_code
1527              );
1531                 AND ((p_claim.claim_date is null     and  l_claim_rec.claim_date is not null) OR
1528                  l_claim_type_id_rule := TRUE;
1529                  l_return := TRUE;
1530              ELSIF l_column_info.db_column_name = 'CLAIM_DATE' AND l_claim_date_rule = false
1532                (p_claim.claim_date is not null and  l_claim_rec.claim_date is null) OR
1533                (p_claim.claim_date is not null and  l_claim_rec.claim_date is not null AND
1534                 to_char(p_claim.claim_date,'DD-MM-YYYY') <>  to_char(l_claim_rec.claim_date,'DD-MM-YYYY'))) THEN
1535                    l_history_event := G_CHANGE_EVENT;
1536                    change_description (
1537                 px_description => l_event_description,
1538                      p_column_desc => l_column_info.ak_attribute_code
1539               );
1540                    l_claim_date_rule := true;
1541                    l_return := TRUE;
1542              ELSIF l_column_info.db_column_name = 'DUE_DATE' AND l_due_date_rule = false
1543                 AND ((p_claim.due_date is null     and  l_claim_rec.due_date is not null) OR
1544                (p_claim.due_date is not null and  l_claim_rec.due_date is null) OR
1545                (p_claim.due_date is not null and  l_claim_rec.due_date is not null AND
1546                 to_char(p_claim.due_date,'DD-MM-YYYY') <> to_char(l_claim_rec.due_date,'DD-MM-YYYY'))) THEN
1547                    l_history_event := G_CHANGE_EVENT;
1548                    change_description (
1549                 px_description => l_event_description,
1550                      p_column_desc => l_column_info.ak_attribute_code
1551               );
1552                    l_due_date_rule := true;
1553                    l_return := TRUE;
1554              ELSIF l_column_info.db_column_name = 'TASK_TEMPLATE_GROUP_ID' AND  l_task_template_group_id_rule = false
1555               AND ((p_claim.task_template_group_id is null     and  l_claim_rec.task_template_group_id is not null) OR
1556                (p_claim.task_template_group_id is not null and  l_claim_rec.task_template_group_id is null) OR
1557                (p_claim.task_template_group_id is not null and  l_claim_rec.task_template_group_id is not null AND
1558                 p_claim.task_template_group_id <> l_claim_rec.task_template_group_id)) THEN
1559               l_history_event := G_CHANGE_EVENT;
1560                    change_description (
1561                 px_description => l_event_description,
1562                      p_column_desc => l_column_info.ak_attribute_code
1563               );
1564                    l_task_template_group_id_rule := true;
1565                    l_return := TRUE;
1566              ELSIF l_column_info.db_column_name = 'REASON_CODE_ID' AND l_reason_code_id_rule = false
1567              AND
1568               ((p_claim.reason_code_id is null     and  l_claim_rec.reason_code_id is not null) OR
1569                (p_claim.reason_code_id is not null and  l_claim_rec.reason_code_id is null) OR
1570                (p_claim.reason_code_id is not null and  l_claim_rec.reason_code_id is not null AND
1571                 p_claim.reason_code_id <> l_claim_rec.reason_code_id))
1572                 THEN
1573                    l_history_event := G_CHANGE_EVENT;
1574                    change_description (
1575                 px_description => l_event_description,
1576                      p_column_desc => l_column_info.ak_attribute_code
1577               );
1578                    l_reason_code_id_rule := TRUE;
1579                    l_return := TRUE;
1580              ELSIF l_column_info.db_column_name = 'OWNER_ID' AND l_owner_id_rule = false
1581               AND ((p_claim.owner_id is null     and  l_claim_rec.owner_id is not null) OR
1582                (p_claim.owner_id is not null and  l_claim_rec.owner_id is null) OR
1583                (p_claim.owner_id is not null and  l_claim_rec.owner_id is not null AND
1584                 p_claim.owner_id <> l_claim_rec.owner_id))  THEN
1585                    l_history_event := G_CHANGE_EVENT;
1586                    change_description (
1587                 px_description => l_event_description,
1588                      p_column_desc => l_column_info.ak_attribute_code
1589               );
1590                    l_owner_id_rule := true;
1591                    l_return := TRUE;
1592              ELSIF l_column_info.db_column_name = 'SALES_REP_ID' AND
1593               ((p_claim.sales_rep_id is null     and  l_claim_rec.sales_rep_id is not null) OR
1594                (p_claim.sales_rep_id is not null and  l_claim_rec.sales_rep_id is null) OR
1595                (p_claim.sales_rep_id is not null and  l_claim_rec.sales_rep_id is not null AND
1596                 p_claim.sales_rep_id <> l_claim_rec.sales_rep_id)) THEN
1597                    l_history_event := G_CHANGE_EVENT;
1598                    change_description (
1599                 px_description => l_event_description,
1600                      p_column_desc => l_column_info.ak_attribute_code
1601               );
1602                    l_return := TRUE;
1603              ELSIF l_column_info.db_column_name = 'BROKER_ID' AND
1604                    ((p_claim.broker_id is null     and  l_claim_rec.broker_id is not null) OR
1605                (p_claim.broker_id is not null and  l_claim_rec.broker_id is null) OR
1606                (p_claim.broker_id is not null and  l_claim_rec.broker_id is not null AND
1607                 p_claim.broker_id <> l_claim_rec.broker_id)) THEN
1608                    l_history_event := G_CHANGE_EVENT;
1609                    change_description (
1610                 px_description => l_event_description,
1611                      p_column_desc => l_column_info.ak_attribute_code
1612               );
1613                    l_return := TRUE;
1614         /*     ELSIF l_column_info.db_column_name = 'STATUS_CODE' AND
1615                    (p_claim.status_code <> FND_API.G_MISS_CHAR AND p_claim.status_code <> l_claim_rec.status_code)THEN
1616                    l_history_event := G_CHANGE_EVENT;
1617                    change_description (
1618                 px_description => l_event_description,
1622              ELSIF l_column_info.db_column_name = 'USER_STATUS_ID' AND
1619                      p_column_desc => l_column_info.ak_attribute_code
1620               );
1621                    l_return := TRUE;
1623                    ((p_claim.user_status_id <> FND_API.G_MISS_NUM AND p_claim.user_status_id is not null)
1624                    AND p_claim.user_status_id <> l_claim_rec.user_status_id) AND
1625                    l_status_changed = false THEN
1626                    l_history_event := G_CHANGE_EVENT;
1627                    change_description (
1628                 px_description => l_event_description,
1629                      p_column_desc => l_column_info.ak_attribute_code
1630               );
1631               l_status_changed := true;
1632                    l_return := TRUE;*/
1633              ELSIF l_column_info.db_column_name = 'CUST_ACCOUNT_ID' AND
1634                    ((p_claim.cust_account_id <> FND_API.G_MISS_NUM AND p_claim.cust_account_id is not null)
1635                    AND p_claim.cust_account_id <> l_claim_rec.cust_account_id) THEN
1636                    l_history_event := G_CHANGE_EVENT;
1637                    change_description (
1638                 px_description => l_event_description,
1639                      p_column_desc => l_column_info.ak_attribute_code
1640               );
1641                    l_return := TRUE;
1642              ELSIF l_column_info.db_column_name = 'CUST_BILLTO_ACCT_SITE_ID' AND
1643               ((p_claim.cust_billto_acct_site_id is null     and  l_claim_rec.cust_billto_acct_site_id is not null) OR
1644                (p_claim.cust_billto_acct_site_id is not null and  l_claim_rec.cust_billto_acct_site_id is null) OR
1645                (p_claim.cust_billto_acct_site_id is not null and  l_claim_rec.cust_billto_acct_site_id is not null AND
1646                 p_claim.cust_billto_acct_site_id <> l_claim_rec.cust_billto_acct_site_id)) THEN
1647                    l_history_event := G_CHANGE_EVENT;
1648                    change_description (
1649                 px_description => l_event_description,
1650                      p_column_desc => l_column_info.ak_attribute_code
1651               );
1652                    l_return := TRUE;
1653              ELSIF l_column_info.db_column_name = 'CUST_SHIPTO_ACCT_SITE_ID' AND
1654               ((p_claim.cust_shipto_acct_site_id is null     and  l_claim_rec.cust_shipto_acct_site_id is not null) OR
1655                (p_claim.cust_shipto_acct_site_id is not null and  l_claim_rec.cust_shipto_acct_site_id is null) OR
1656                (p_claim.cust_shipto_acct_site_id is not null and  l_claim_rec.cust_shipto_acct_site_id is not null AND
1657                 p_claim.cust_shipto_acct_site_id <> l_claim_rec.cust_shipto_acct_site_id)) THEN
1658                    l_history_event := G_CHANGE_EVENT;
1659                    change_description (
1660                 px_description => l_event_description,
1661                      p_column_desc => l_column_info.ak_attribute_code
1662               );
1663                    l_return := TRUE;
1664              ELSIF l_column_info.db_column_name = 'CONTACT_ID' AND
1665                    ((p_claim.contact_id is null     and  l_claim_rec.contact_id is not null) OR
1666                (p_claim.contact_id is not null and  l_claim_rec.contact_id is null) OR
1667                (p_claim.contact_id is not null and  l_claim_rec.contact_id is not null AND
1668                 p_claim.contact_id <> l_claim_rec.contact_id)) THEN
1669               l_history_event := G_CHANGE_EVENT;
1670                    change_description (
1671                 px_description => l_event_description,
1672                      p_column_desc => l_column_info.ak_attribute_code
1673               );
1674                    l_return := TRUE;
1675              ELSIF l_column_info.db_column_name = 'CUSTOMER_REF_NUMBER' AND
1676                    ((p_claim.customer_ref_number is null     and  l_claim_rec.customer_ref_number is not null) OR
1677                (p_claim.customer_ref_number is not null and  l_claim_rec.customer_ref_number is null) OR
1678                (p_claim.customer_ref_number is not null and  l_claim_rec.customer_ref_number is not null AND
1679                 p_claim.customer_ref_number <> l_claim_rec.customer_ref_number)) THEN
1680                    l_history_event := G_CHANGE_EVENT;
1681                    change_description (
1682                 px_description => l_event_description,
1683                      p_column_desc => l_column_info.ak_attribute_code
1684               );
1685                    l_return := TRUE;
1686              ELSIF l_column_info.db_column_name = 'CUSTOMER_REF_DATE' AND
1687                    ((p_claim.customer_ref_date is null     and  l_claim_rec.customer_ref_date is not null) OR
1688                (p_claim.customer_ref_date is not null and  l_claim_rec.customer_ref_date is null) OR
1689                (p_claim.customer_ref_date is not null and  l_claim_rec.customer_ref_date is not null AND
1690                 to_char(p_claim.customer_ref_date,'DD-MM-YYYY') <> to_char(l_claim_rec.customer_ref_date,'DD-MM-YYYY'))) THEN
1691                    l_history_event := G_CHANGE_EVENT;
1692                    change_description (
1693                 px_description => l_event_description,
1694                      p_column_desc => l_column_info.ak_attribute_code
1695               );
1696                    l_return := TRUE;
1697              ELSIF l_column_info.db_column_name = 'AMOUNT' AND
1698                    ((p_claim.amount <>FND_API.G_MISS_NUM AND p_claim.amount is not null)
1699                    AND p_claim.amount <> l_claim_rec.amount)
1700                    AND l_amount_rule = false
1701                    THEN
1702                    l_history_event := G_CHANGE_EVENT;
1703                    change_description (
1704                 px_description => l_event_description,
1705                      p_column_desc => l_column_info.ak_attribute_code
1706                );
1707                     l_amount_rule := TRUE;
1708                     l_return := TRUE;
1709              ELSIF l_column_info.db_column_name = 'CURRENCY_CODE' AND l_currency_code_rule = false
1710                    AND ((p_claim.currency_code <> FND_API.G_MISS_CHAR  AND p_claim.currency_code is not null )
1711                    AND p_claim.currency_code <> l_claim_rec.currency_code) THEN
1712                    l_history_event := G_CHANGE_EVENT;
1713                    change_description (
1714                 px_description => l_event_description,
1715                      p_column_desc => l_column_info.ak_attribute_code
1716               );
1717                    l_currency_code_rule := true;
1718                    l_return := TRUE;
1719              ELSIF l_column_info.db_column_name = 'EXCHANGE_RATE_TYPE' AND
1720               ((p_claim.exchange_rate_type is null     and  l_claim_rec.exchange_rate_type is not null) OR
1721                (p_claim.exchange_rate_type is not null and  l_claim_rec.exchange_rate_type is null) OR
1722                (p_claim.exchange_rate_type is not null and  l_claim_rec.exchange_rate_type is not null AND
1723                 p_claim.exchange_rate_type <> l_claim_rec.exchange_rate_type)) THEN
1724                    l_history_event := G_CHANGE_EVENT;
1725                    change_description (
1726                 px_description => l_event_description,
1727                      p_column_desc => l_column_info.ak_attribute_code
1728               );
1729                    l_return := TRUE;
1730              ELSIF l_column_info.db_column_name = 'EXCHANGE_RATE' AND
1731                    ((p_claim.exchange_rate is null     and  l_claim_rec.exchange_rate is not null) OR
1732                (p_claim.exchange_rate is not null and  l_claim_rec.exchange_rate is null) OR
1733                (p_claim.exchange_rate is not null and  l_claim_rec.exchange_rate is not null AND
1734                 p_claim.exchange_rate <> l_claim_rec.exchange_rate)) THEN
1735                    l_history_event := G_CHANGE_EVENT;
1736                    change_description (
1737                 px_description => l_event_description,
1738                      p_column_desc => l_column_info.ak_attribute_code
1739               );
1740                    l_return := TRUE;
1741              ELSIF l_column_info.db_column_name = 'EXCHANGE_RATE_DATE' AND
1742                    ((p_claim.exchange_rate_date is null     and  l_claim_rec.exchange_rate_date is not null) OR
1743                (p_claim.exchange_rate_date is not null and  l_claim_rec.exchange_rate_date is null) OR
1744                (p_claim.exchange_rate_date is not null and  l_claim_rec.exchange_rate_date is not null AND
1745                 to_char(p_claim.exchange_rate_date,'DD-MM-YYYY') <> to_char(l_claim_rec.exchange_rate_date,'DD-MM-YYYY'))) THEN
1746                    l_history_event := G_CHANGE_EVENT;
1747                    change_description (
1748                 px_description => l_event_description,
1749                      p_column_desc => l_column_info.ak_attribute_code
1750               );
1751                    l_return := TRUE;
1752              ELSIF l_column_info.db_column_name = 'DUPLICATE_CLAIM_ID' AND l_duplicate_claim_id_rule = false
1753                 AND ((p_claim.duplicate_claim_id is null     and  l_claim_rec.duplicate_claim_id is not null) OR
1754                (p_claim.duplicate_claim_id is not null and  l_claim_rec.duplicate_claim_id is null) OR
1755                (p_claim.duplicate_claim_id is not null and  l_claim_rec.duplicate_claim_id is not null AND
1756                 p_claim.duplicate_claim_id <> l_claim_rec.duplicate_claim_id)) THEN
1757                    l_history_event := G_CHANGE_EVENT;
1758                    change_description (
1759                 px_description => l_event_description,
1760                      p_column_desc => l_column_info.ak_attribute_code
1761               );
1762                    l_duplicate_claim_id_rule := true;
1763                    l_return := TRUE;
1764              ELSIF l_column_info.db_column_name = 'ORDER_TYPE_ID' AND
1765                    ((p_claim.order_type_id is null     and  l_claim_rec.order_type_id is not null) OR
1766                (p_claim.order_type_id is not null and  l_claim_rec.order_type_id is null) OR
1767                (p_claim.order_type_id is not null and  l_claim_rec.order_type_id is not null AND
1768                 p_claim.order_type_id <> l_claim_rec.order_type_id)) THEN
1769                    l_history_event := G_CHANGE_EVENT;
1770                    change_description (
1771                 px_description => l_event_description,
1772                      p_column_desc => l_column_info.ak_attribute_code
1773               );
1777                (p_claim.comments is not null and  l_claim_rec.comments is null) OR
1774                    l_return := TRUE;
1775             ELSIF l_column_info.db_column_name = 'COMMENTS' AND
1776                    ((p_claim.comments is null     and  l_claim_rec.comments is not null) OR
1778                (p_claim.comments is not null and  l_claim_rec.comments is not null AND
1779                 p_claim.comments <> l_claim_rec.comments)) THEN
1780                    l_history_event := G_CHANGE_EVENT;
1781                    change_description (
1782                 px_description => l_event_description,
1783                      p_column_desc => l_column_info.ak_attribute_code
1784               );
1785                    l_return := TRUE;
1786             ELSIF l_column_info.db_column_name = 'EFFECTIVE_DATE' AND
1787                    ((p_claim.effective_date is null     and  l_claim_rec.effective_date is not null) OR
1788                (p_claim.effective_date is not null and  l_claim_rec.effective_date is null) OR
1789                (p_claim.effective_date is not null and  l_claim_rec.effective_date is not null AND
1790                 to_char(p_claim.effective_date,'DD-MM-YYYY') <> to_char(l_claim_rec.effective_date,'DD-MM-YYYY'))) THEN
1791                    l_history_event := G_CHANGE_EVENT;
1792                    change_description (
1793                 px_description => l_event_description,
1794                      p_column_desc => l_column_info.ak_attribute_code
1795               );
1796                    l_return := TRUE;
1797             ELSIF l_column_info.db_column_name = 'GL_DATE' AND
1798                    ((p_claim.gl_date is null     and  l_claim_rec.gl_date is not null) OR
1799                (p_claim.gl_date is not null and  l_claim_rec.gl_date is null) OR
1800                (p_claim.gl_date is not null and  l_claim_rec.gl_date is not null AND
1801                 to_char(p_claim.gl_date,'DD-MM-YYYY') <> to_char(l_claim_rec.gl_date,'DD-MM-YYYY'))) THEN
1802                    l_history_event := G_CHANGE_EVENT;
1803                    change_description (
1804                 px_description => l_event_description,
1805                      p_column_desc => l_column_info.ak_attribute_code
1806               );
1807                    l_return := TRUE;
1808             ELSIF l_column_info.db_column_name = 'PAYMENT_METHOD' AND
1809                    ((p_claim.payment_method is null     and  l_claim_rec.payment_method is not null) OR
1810                (p_claim.payment_method is not null and  l_claim_rec.payment_method is null) OR
1811                (p_claim.payment_method is not null and  l_claim_rec.payment_method is not null AND
1812                 p_claim.payment_method <> l_claim_rec.payment_method))
1813                 AND l_payment_method_rule = false
1814                 THEN
1815                    l_history_event := G_CHANGE_EVENT;
1816                    change_description (
1817                 px_description => l_event_description,
1818                      p_column_desc => l_column_info.ak_attribute_code
1819               );
1820                    l_payment_method_rule := TRUE;
1821                    l_return := TRUE;
1822             ELSIF l_column_info.db_column_name = 'PAY_RELATED_ACCOUNT_FLAG' AND
1823                    ((p_claim.pay_related_account_flag is null     and  l_claim_rec.pay_related_account_flag is not null) OR
1824                (p_claim.pay_related_account_flag is not null and  l_claim_rec.pay_related_account_flag is null) OR
1825                (p_claim.pay_related_account_flag is not null and  l_claim_rec.pay_related_account_flag is not null AND
1826                 p_claim.pay_related_account_flag <> l_claim_rec.pay_related_account_flag)) THEN
1827                    l_history_event := G_CHANGE_EVENT;
1828                    change_description (
1829                 px_description => l_event_description,
1830                      p_column_desc => l_column_info.ak_attribute_code
1831               );
1832                    l_return := TRUE;
1833             ELSIF l_column_info.db_column_name = 'RELATED_CUST_ACCOUNT_ID' AND
1834                    ((p_claim.related_cust_account_id is null     and  l_claim_rec.related_cust_account_id is not null) OR
1835                (p_claim.related_cust_account_id is not null and  l_claim_rec.related_cust_account_id is null) OR
1836                (p_claim.related_cust_account_id is not null and  l_claim_rec.related_cust_account_id is not null AND
1837                 p_claim.related_cust_account_id <> l_claim_rec.related_cust_account_id)) THEN
1838                    l_history_event := G_CHANGE_EVENT;
1839                    change_description (
1840                 px_description => l_event_description,
1841                      p_column_desc => l_column_info.ak_attribute_code
1842               );
1843                    l_return := TRUE;
1844             ELSIF l_column_info.db_column_name = 'RELATED_SITE_USE_ID' AND
1845                    ((p_claim.related_site_use_id is null     and  l_claim_rec.related_site_use_id is not null) OR
1846                (p_claim.related_site_use_id is not null and  l_claim_rec.related_site_use_id is null) OR
1847                (p_claim.related_site_use_id is not null and  l_claim_rec.related_site_use_id is not null AND
1848                 p_claim.related_site_use_id <> l_claim_rec.related_site_use_id)) THEN
1849                    l_history_event := G_CHANGE_EVENT;
1850                    change_description (
1851                 px_description => l_event_description,
1852                      p_column_desc => l_column_info.ak_attribute_code
1853               );
1854                    l_return := TRUE;
1855             ELSIF l_column_info.db_column_name = 'RELATIONSHIP_TYPE' AND
1856                    ((p_claim.relationship_type is null     and  l_claim_rec.relationship_type is not null) OR
1857                (p_claim.relationship_type is not null and  l_claim_rec.relationship_type is null) OR
1861                    change_description (
1858                (p_claim.relationship_type is not null and  l_claim_rec.relationship_type is not null AND
1859                 p_claim.relationship_type <> l_claim_rec.relationship_type)) THEN
1860                    l_history_event := G_CHANGE_EVENT;
1862                 px_description => l_event_description,
1863                      p_column_desc => l_column_info.ak_attribute_code
1864               );
1865                    l_return := TRUE;
1866             ELSIF l_column_info.db_column_name = 'USER_STATUS_ID' AND
1867                    ((p_claim.user_status_id is null     and  l_claim_rec.user_status_id is not null) OR
1868                (p_claim.user_status_id is not null and  l_claim_rec.user_status_id is null) OR
1869                (p_claim.user_status_id is not null and  l_claim_rec.user_status_id is not null AND
1870                 p_claim.user_status_id <> l_claim_rec.user_status_id))
1871                 AND l_user_status_id_rule = false
1872                 THEN
1873                    l_history_event := G_CHANGE_EVENT;
1874                    change_description (
1875                 px_description => l_event_description,
1876                      p_column_desc => l_column_info.ak_attribute_code
1877               );
1878                    l_return := TRUE;
1879                    l_user_status_id_rule := TRUE;
1880             ELSIF l_column_info.db_column_name = 'VENDOR_ID' AND
1881                    ((p_claim.vendor_id is null     and  l_claim_rec.vendor_id is not null) OR
1882                (p_claim.vendor_id is not null and  l_claim_rec.vendor_id is null) OR
1883                (p_claim.vendor_id is not null and  l_claim_rec.vendor_id is not null AND
1884                 p_claim.vendor_id <> l_claim_rec.vendor_id)) THEN
1885                    l_history_event := G_CHANGE_EVENT;
1886                    change_description (
1887                 px_description => l_event_description,
1888                      p_column_desc => l_column_info.ak_attribute_code
1889               );
1890                    l_return := TRUE;
1891             ELSIF l_column_info.db_column_name = 'VENDOR_SITE_ID' AND
1892                    ((p_claim.vendor_site_id is null     and  l_claim_rec.vendor_site_id is not null) OR
1893                (p_claim.vendor_site_id is not null and  l_claim_rec.vendor_site_id is null) OR
1894                (p_claim.vendor_site_id is not null and  l_claim_rec.vendor_site_id is not null AND
1895                 p_claim.vendor_site_id <> l_claim_rec.vendor_site_id)) THEN
1896                    l_history_event := G_CHANGE_EVENT;
1897                    change_description (
1898                 px_description => l_event_description,
1899                      p_column_desc => l_column_info.ak_attribute_code
1900               );
1901                    l_return := TRUE;
1902              END IF;
1903          END LOOP;
1904          CLOSE user_selected_columns_csr;
1905     END IF;
1906    --end (uday)
1907    END IF;
1908 
1909    x_history_event := l_history_event;
1910    x_history_event_description := l_event_description;
1911    IF l_return THEN
1912       x_needed_to_create := 'Y';
1913    ELSE
1914       x_needed_to_create := 'N';
1915    END IF;
1916    IF OZF_DEBUG_LOW_ON THEN
1917       FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
1918       FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
1919       FND_MSG_PUB.Add;
1920    END IF;
1921 
1922 EXCEPTION
1923    WHEN FND_API.G_EXC_ERROR THEN
1924       x_return_status := FND_API.G_RET_STS_ERROR;
1925    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1926       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1927    WHEN OTHERS THEN
1928       IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
1929          FND_MESSAGE.set_name('OZF', 'OZF_CLAIM_CHK_CREATE_HIST_ERR');
1930          FND_MSG_PUB.add;
1931       END IF;
1932       x_return_status := FND_API.g_ret_sts_unexp_error;
1933 END check_create_history;
1934 
1935 ---------------------------------------------------------------------
1936 -- PROCEDURE
1937 --    Create_History
1938 --
1939 -- PURPOSE
1940 --    This procedure checks whether if a history record of a claim is
1941 --    needed based on the previous event. If there is a need, it then
1942 --    creates a snapshot (or history) of claim. The snapshot includes
1943 --    claim detail information, claim line information and tasks information
1944 --
1945 -- PARAMETERS
1946 --    p_claim_id: Id to identify a claim
1947 --    x_claim_history_id:  Id of a claim history
1948 --
1949 -- NOTES:
1950 --
1951 ---------------------------------------------------------------------
1952 PROCEDURE Create_History(p_claim_id         IN  NUMBER,
1953                          p_history_event    IN  VARCHAR2,
1954 			                p_history_event_description IN VARCHAR2,
1955                          x_claim_history_id OUT NOCOPY NUMBER,
1956                          x_return_status    OUT NOCOPY VARCHAR2)
1957 IS
1958 l_msg_count       number;
1959 l_msg_data        varchar2(2000);
1960 l_return_status   varchar2(30);
1961 l_api_name        varchar2(30) := 'Create_History';
1962 
1963 l_claims_history_rec      OZF_claims_history_PVT.claims_history_rec_type;
1964 l_claim_history_id        number := null;
1965 
1966 l_claim_lines_hist_rec    OZF_claim_line_hist_PVT.claim_line_hist_rec_type;
1967 l_claim_line_history_id   number;
1968 l_claim_line_rec          OZF_Claim_Line_PVT.claim_line_rec_type;
1969 l_event_description       varchar2(2000);
1970 
1971 CURSOR custom_setup_id_csr (p_claim_class in varchar2) IS
1972 SELECT custom_setup_id
1976 
1973 FROM ams_custom_setups_vl
1974 WHERE object_type = G_CLAIM_HIST_OBJ_TYPE
1975 AND  activity_type_code = p_claim_class;
1977 CURSOR claim_csr(pid in number) IS
1978 SELECT *
1979 FROM ozf_claims_all
1980 WHERE claim_id = pid;
1981 l_claim_rec             claim_csr%ROWTYPE;
1982 
1983 CURSOR claim_line_csr(p_id in number) IS
1984 SELECT *
1985 FROM   ozf_claim_lines_all
1986 WHERE  claim_id = p_id;
1987 
1988 --CURSOR history_ids_csr(p_claim_id) IS
1989 --SELECT line_claim_history_id, task_claim_history_id
1990 --FROM ozf_claims_history
1991 --WHERE claim_id = p_claim_id
1992 --AND event_date = max(event_date);
1993 
1994 --CURSOR history_ids_csr(p_claim_id) IS
1995 --SELECT line_claim_history_id
1996 --FROM ozf_claims_history
1997 --WHERE claim_id = p_claim_id
1998 --AND event_date = max(event_date);
1999 
2000 CURSOR claim_history_sequence_cur IS
2001 SELECT ozf_claims_history_all_s.nextval
2002 FROM dual;
2003 
2004 CURSOR check_csr (pid in number)is
2005 select history_event, history_event_description
2006 from ozf_claims_all
2007 where claim_id = pid;
2008 
2009 CURSOR c_claim_hist_id_count(p_id in number) is
2010 select count(*)
2011 from ozf_claims_history
2012 where claim_history_id =p_id;
2013 l_claim_hist_id_count number:=0;
2014 
2015 l_history_event      varchar2(40);
2016 l_history_event_desc varchar2(60);
2017 
2018 BEGIN
2019     -- Initialize API return status to sucess
2020     x_return_status := FND_API.G_RET_STS_SUCCESS;
2021 
2022     IF OZF_DEBUG_LOW_ON THEN
2023          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2024          FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
2025          FND_MSG_PUB.Add;
2026     END IF;
2027 
2028     -- update the history related columns for the claim
2029     UPDATE ozf_claims_all
2030     SET history_event = p_history_event,
2031         history_event_date = SYSDATE,
2032         history_event_description = p_history_event_description
2033     WHERE claim_id = p_claim_id;
2034 
2035     OPEN claim_csr(p_claim_id);
2036     FETCH claim_csr INTO l_claim_rec;
2037     CLOSE claim_csr;
2038 
2039     -- Here we need to chang the custom_setup_id from CLAM to CLAMHIST
2040     OPEN custom_setup_id_csr(l_claim_rec.claim_class);
2041     FETCH custom_setup_id_csr INTO l_claim_rec.custom_setup_id;
2042     CLOSE custom_setup_id_csr;
2043 
2044     -- Get the value for claim_history_id
2045 
2046 
2047     LOOP
2048       -- Get the identifier
2049       OPEN claim_history_sequence_cur;
2050       FETCH claim_history_sequence_cur INTO l_claim_history_id;
2051       CLOSE claim_history_sequence_cur;
2052       -- Check the uniqueness of the identifier
2053       OPEN  c_claim_hist_id_count(l_claim_history_id);
2054       FETCH c_claim_hist_id_count INTO l_claim_hist_id_count;
2055       CLOSE c_claim_hist_id_count;
2056       -- Exit when the identifier uniqueness is established
2057       EXIT WHEN l_claim_hist_id_count = 0;
2058     END LOOP;
2059 
2060     --Construct claim history rec for the rest of the columns
2061     l_claims_history_rec.claim_history_id   := l_claim_history_id;
2062     l_claims_history_rec.batch_id            := l_claim_rec.batch_id;
2063     l_claims_history_rec.claim_id            := l_claim_rec.claim_id;
2064     l_claims_history_rec.claim_number        := l_claim_rec.claim_number;
2065     l_claims_history_rec.claim_type_id       := l_claim_rec.claim_type_id;
2066     l_claims_history_rec.claim_class         := l_claim_rec.claim_class;
2067     l_claims_history_rec.claim_date          := l_claim_rec.claim_date;
2068     l_claims_history_rec.due_date            := l_claim_rec.due_date;
2069     l_claims_history_rec.owner_id            := l_claim_rec.owner_id;
2070     l_claims_history_rec.history_event_date  := l_claim_rec.history_event_date;
2071     --Code changes (uday)
2072     l_claims_history_rec.history_event       := p_history_event;
2073     l_claims_history_rec.history_event_description   := p_history_event_description;
2074     --end (-uday)
2075 
2076     l_claims_history_rec.split_from_claim_id := l_claim_rec.split_from_claim_id;
2077     l_claims_history_rec.duplicate_claim_id  := l_claim_rec.duplicate_claim_id;
2078     l_claims_history_rec.split_date          := l_claim_rec.split_date;
2079     l_claims_history_rec.root_claim_id       := l_claim_rec.root_claim_id;
2080     l_claims_history_rec.amount              := l_claim_rec.amount;
2081     l_claims_history_rec.amount_adjusted     := l_claim_rec.amount_adjusted;
2082     l_claims_history_rec.amount_settled      := l_claim_rec.amount_settled;
2083     l_claims_history_rec.amount_remaining    := l_claim_rec.amount_remaining;
2084     l_claims_history_rec.acctd_amount        := l_claim_rec.acctd_amount;
2085     l_claims_history_rec.acctd_amount_remaining := l_claim_rec.acctd_amount_remaining;
2086     l_claims_history_rec.acctd_amount_adjusted  := l_claim_rec.acctd_amount_adjusted;
2087     l_claims_history_rec.acctd_amount_settled   := l_claim_rec.acctd_amount_settled;
2088     l_claims_history_rec.tax_amount          := l_claim_rec.tax_amount;
2089     l_claims_history_rec.tax_code            := l_claim_rec.tax_code;
2090     l_claims_history_rec.tax_calculation_flag := l_claim_rec.tax_calculation_flag;
2091     l_claims_history_rec.currency_code       := l_claim_rec.currency_code;
2092     l_claims_history_rec.exchange_rate_type  := l_claim_rec.exchange_rate_type;
2093     l_claims_history_rec.exchange_rate_date  := l_claim_rec.exchange_rate_date;
2094     l_claims_history_rec.exchange_rate       := l_claim_rec.exchange_rate;
2098     l_claims_history_rec.source_object_class := l_claim_rec.source_object_class;
2095     l_claims_history_rec.set_of_books_id     := l_claim_rec.set_of_books_id;
2096     l_claims_history_rec.original_claim_date := l_claim_rec.original_claim_date;
2097     l_claims_history_rec.source_object_id    := l_claim_rec.source_object_id;
2099     l_claims_history_rec.source_object_type_id := l_claim_rec.source_object_type_id;
2100     l_claims_history_rec.source_object_number:= l_claim_rec.source_object_number;
2101     l_claims_history_rec.cust_account_id     := l_claim_rec.cust_account_id;
2102     l_claims_history_rec.cust_billto_acct_site_id := l_claim_rec.cust_billto_acct_site_id;
2103     l_claims_history_rec.cust_shipto_acct_site_id := l_claim_rec.cust_shipto_acct_site_id;
2104     l_claims_history_rec.location_id         := l_claim_rec.location_id;
2105     l_claims_history_rec.pay_related_account_flag := l_claim_rec.pay_related_account_flag;
2106     l_claims_history_rec.related_cust_account_id:= l_claim_rec.related_cust_account_id;
2107     l_claims_history_rec.related_site_use_id := l_claim_rec.related_site_use_id;
2108     l_claims_history_rec.relationship_type   := l_claim_rec.relationship_type;
2109     l_claims_history_rec.vendor_id           := l_claim_rec.vendor_id;
2110     l_claims_history_rec.vendor_site_id      := l_claim_rec.vendor_site_id;
2111     l_claims_history_rec.reason_type         := l_claim_rec.reason_type;
2112     l_claims_history_rec.reason_code_id      := l_claim_rec.reason_code_id;
2113     l_claims_history_rec.task_template_group_id := l_claim_rec.task_template_group_id;
2114     l_claims_history_rec.status_code         := l_claim_rec.status_code;
2115     l_claims_history_rec.user_status_id      := l_claim_rec.user_status_id;
2116     l_claims_history_rec.sales_rep_id        := l_claim_rec.sales_rep_id;
2117     l_claims_history_rec.collector_id        := l_claim_rec.collector_id;
2118     l_claims_history_rec.contact_id          := l_claim_rec.contact_id;
2119     l_claims_history_rec.broker_id           := l_claim_rec.broker_id;
2120     l_claims_history_rec.territory_id        := l_claim_rec.territory_id;
2121     l_claims_history_rec.customer_ref_date   := l_claim_rec.customer_ref_date;
2122     l_claims_history_rec.customer_ref_number := l_claim_rec.customer_ref_number;
2123     l_claims_history_rec.assigned_to         := l_claim_rec.assigned_to;
2124     l_claims_history_rec.receipt_id          := l_claim_rec.receipt_id;
2125     l_claims_history_rec.receipt_number      := l_claim_rec.receipt_number;
2126     l_claims_history_rec.doc_sequence_id     := l_claim_rec.doc_sequence_id;
2127     l_claims_history_rec.doc_sequence_value  := l_claim_rec.doc_sequence_value;
2128     l_claims_history_rec.gl_date             := l_claim_rec.gl_date;
2129     l_claims_history_rec.payment_method      := l_claim_rec.payment_method;
2130     l_claims_history_rec.voucher_id          := l_claim_rec.voucher_id;
2131     l_claims_history_rec.voucher_number      := l_claim_rec.voucher_number;
2132     l_claims_history_rec.payment_reference_id:= l_claim_rec.payment_reference_id;
2133     l_claims_history_rec.payment_reference_number:= l_claim_rec.payment_reference_number;
2134     l_claims_history_rec.payment_reference_date  := l_claim_rec.payment_reference_date;
2135     l_claims_history_rec.payment_status      := l_claim_rec.payment_status;
2136     l_claims_history_rec.approved_flag       := l_claim_rec.approved_flag;
2137     l_claims_history_rec.approved_date       := l_claim_rec.approved_date;
2138     l_claims_history_rec.approved_by         := l_claim_rec.approved_by;
2139     l_claims_history_rec.settled_date        := l_claim_rec.settled_date;
2140     l_claims_history_rec.settled_by          := l_claim_rec.settled_by;
2141     l_claims_history_rec.effective_date      := l_claim_rec.effective_date;
2142     l_claims_history_rec.custom_setup_id     := l_claim_rec.custom_setup_id;
2143     l_claims_history_rec.task_id             := l_claim_rec.task_id;
2144     l_claims_history_rec.country_id          := l_claim_rec.country_id;
2145     l_claims_history_rec.order_type_id       := l_claim_rec.order_type_id;
2146     l_claims_history_rec.comments            := l_claim_rec.comments;
2147     l_claims_history_rec.task_source_object_id := l_claim_rec.claim_id;
2148     l_claims_history_rec.task_source_object_type_code := G_CLAIM_TYPE;
2149     l_claims_history_rec.attribute_category  := l_claim_rec.attribute_category;
2150     l_claims_history_rec.attribute1          := l_claim_rec.attribute1;
2151     l_claims_history_rec.attribute2          := l_claim_rec.attribute2;
2152     l_claims_history_rec.attribute3          := l_claim_rec.attribute3;
2153     l_claims_history_rec.attribute4          := l_claim_rec.attribute4;
2154     l_claims_history_rec.attribute5          := l_claim_rec.attribute5;
2155     l_claims_history_rec.attribute6          := l_claim_rec.attribute6;
2156     l_claims_history_rec.attribute7          := l_claim_rec.attribute7;
2157     l_claims_history_rec.attribute8          := l_claim_rec.attribute8;
2158     l_claims_history_rec.attribute9          := l_claim_rec.attribute9;
2159     l_claims_history_rec.attribute10         := l_claim_rec.attribute10;
2160     l_claims_history_rec.attribute11         := l_claim_rec.attribute11;
2161     l_claims_history_rec.attribute12         := l_claim_rec.attribute12;
2162     l_claims_history_rec.attribute13         := l_claim_rec.attribute13;
2163     l_claims_history_rec.attribute14         := l_claim_rec.attribute14;
2164     l_claims_history_rec.attribute15         := l_claim_rec.attribute15;
2165     l_claims_history_rec.deduction_attribute_category := l_claim_rec.deduction_attribute_category;
2166      l_claims_history_rec.deduction_attribute1 := l_claim_rec.deduction_attribute1;
2167     l_claims_history_rec.deduction_attribute2 := l_claim_rec.deduction_attribute2;
2168     l_claims_history_rec.deduction_attribute3 := l_claim_rec.deduction_attribute3;
2169     l_claims_history_rec.deduction_attribute4 := l_claim_rec.deduction_attribute4;
2170     l_claims_history_rec.deduction_attribute5 := l_claim_rec.deduction_attribute5;
2171     l_claims_history_rec.deduction_attribute6 := l_claim_rec.deduction_attribute6;
2172     l_claims_history_rec.deduction_attribute7 := l_claim_rec.deduction_attribute7;
2173     l_claims_history_rec.deduction_attribute8 := l_claim_rec.deduction_attribute8;
2174     l_claims_history_rec.deduction_attribute9 := l_claim_rec.deduction_attribute9;
2175     l_claims_history_rec.deduction_attribute10 := l_claim_rec.deduction_attribute10;
2176     l_claims_history_rec.deduction_attribute11 := l_claim_rec.deduction_attribute11;
2177     l_claims_history_rec.deduction_attribute12 := l_claim_rec.deduction_attribute12;
2178     l_claims_history_rec.deduction_attribute13 := l_claim_rec.deduction_attribute13;
2179     l_claims_history_rec.deduction_attribute14 := l_claim_rec.deduction_attribute14;
2180     l_claims_history_rec.deduction_attribute15 := l_claim_rec.deduction_attribute15;
2181     l_claims_history_rec.org_id                := l_claim_rec.org_id;
2182     l_claims_history_rec.write_off_flag              := l_claim_rec.write_off_flag;
2183     l_claims_history_rec.write_off_threshold_amount  := l_claim_rec.write_off_threshold_amount;
2184     l_claims_history_rec.under_write_off_threshold   := l_claim_rec.under_write_off_threshold;
2185     l_claims_history_rec.customer_reason             := l_claim_rec.customer_reason;
2186     l_claims_history_rec.ship_to_cust_account_id     := l_claim_rec.ship_to_cust_account_id;
2187     l_claims_history_rec.amount_applied              := l_claim_rec.amount_applied;
2188     l_claims_history_rec.applied_receipt_id          := l_claim_rec.applied_receipt_id;
2189     l_claims_history_rec.applied_receipt_number      := l_claim_rec.applied_receipt_number;
2190     l_claims_history_rec.wo_rec_trx_id               := l_claim_rec.wo_rec_trx_id;
2191 
2192     l_claims_history_rec.group_claim_id               := l_claim_rec.group_claim_id;
2193     l_claims_history_rec.appr_wf_item_key             := l_claim_rec.appr_wf_item_key;
2194     l_claims_history_rec.cstl_wf_item_key             := l_claim_rec.cstl_wf_item_key;
2195     l_claims_history_rec.batch_type                   := l_claim_rec.batch_type;
2196 
2197 
2198     OZF_claims_history_PVT.Create_claims_history(
2199        P_Api_Version_Number         => 1.0,
2200        P_Init_Msg_List              => FND_API.G_FALSE,
2201        P_Commit                     => FND_API.G_FALSE,
2202        P_Validation_Level           => FND_API.G_VALID_LEVEL_FULL,
2203        X_Return_Status              => l_return_status,
2204        X_Msg_Count                  => l_msg_count,
2205        X_Msg_Data                   => l_msg_data,
2206        P_CLAIMS_HISTORY_Rec         => l_CLAIMS_HISTORY_Rec,
2207        X_CLAIM_HISTORY_ID           => l_CLAIM_HISTORY_ID
2208     );
2209 
2210     IF l_return_status = FND_API.g_ret_sts_error THEN
2211        RAISE FND_API.g_exc_error;
2212     ELSIF l_return_status = FND_API.g_ret_sts_unexp_error THEN
2213        RAISE FND_API.g_exc_unexpected_error;
2214     END IF;
2215 
2216     -- Create a history for the lines.
2217     -- Get line detail
2218     FOR l_claim_line_rec IN claim_line_csr(p_claim_id) LOOP
2219  --       EXIT WHEN claim_line_csr%NOTFOUND;
2220 
2221 	--Construct claim history line rec
2222         l_claim_lines_hist_rec.claim_history_id          := l_claim_history_id;
2223         l_claim_lines_hist_rec.claim_id                  := p_claim_id;
2224         l_claim_lines_hist_rec.claim_line_id             := l_claim_line_rec.claim_line_id;
2225         l_claim_lines_hist_rec.line_number               := l_claim_line_rec.line_number;
2226         l_claim_lines_hist_rec.split_from_claim_line_id  := l_claim_line_rec.split_from_claim_line_id;
2227         l_claim_lines_hist_rec.amount                    := l_claim_line_rec.amount;
2228 	     l_claim_lines_hist_rec.acctd_amount              := l_claim_line_rec.acctd_amount;
2229         l_claim_lines_hist_rec.currency_code             := l_claim_line_rec.currency_code;
2230         l_claim_lines_hist_rec.exchange_rate_type        := l_claim_line_rec.exchange_rate_type;
2231         l_claim_lines_hist_rec.exchange_rate_date        := l_claim_line_rec.exchange_rate_date;
2232         l_claim_lines_hist_rec.exchange_rate             := l_claim_line_rec.exchange_rate;
2233         l_claim_lines_hist_rec.set_of_books_id           := l_claim_line_rec.set_of_books_id;
2234         l_claim_lines_hist_rec.valid_flag                := l_claim_line_rec.valid_flag;
2235         l_claim_lines_hist_rec.source_object_id          := l_claim_line_rec.source_object_id;
2236         l_claim_lines_hist_rec.source_object_class       := l_claim_line_rec.source_object_class;
2237         l_claim_lines_hist_rec.source_object_type_id     := l_claim_line_rec.source_object_type_id;
2238         l_claim_lines_hist_rec.source_object_line_id     := l_claim_line_rec.source_object_line_id;
2239         l_claim_lines_hist_rec.plan_id                   := l_claim_line_rec.plan_id;
2240         l_claim_lines_hist_rec.offer_id                  := l_claim_line_rec.offer_id;
2241         l_claim_lines_hist_rec.payment_method            := l_claim_line_rec.payment_method;
2242         l_claim_lines_hist_rec.payment_reference_id      := l_claim_line_rec.payment_reference_id;
2243         l_claim_lines_hist_rec.payment_reference_number  := l_claim_line_rec.payment_reference_number;
2244         l_claim_lines_hist_rec.payment_reference_date    := l_claim_line_rec.payment_reference_date;
2245         l_claim_lines_hist_rec.voucher_id                := l_claim_line_rec.voucher_id;
2246         l_claim_lines_hist_rec.voucher_number            := l_claim_line_rec.voucher_number;
2247         l_claim_lines_hist_rec.payment_status            := l_claim_line_rec.payment_status;
2248         l_claim_lines_hist_rec.approved_flag             := l_claim_line_rec.approved_flag;
2249         l_claim_lines_hist_rec.approved_date             := l_claim_line_rec.approved_date;
2250         l_claim_lines_hist_rec.approved_by               := l_claim_line_rec.approved_by;
2251         l_claim_lines_hist_rec.settled_date              := l_claim_line_rec.settled_date;
2252         l_claim_lines_hist_rec.settled_by                := l_claim_line_rec.settled_by;
2253         l_claim_lines_hist_rec.performance_complete_flag := l_claim_line_rec.performance_complete_flag;
2254         l_claim_lines_hist_rec.performance_attached_flag := l_claim_line_rec.performance_attached_flag;
2255         l_claim_lines_hist_rec.attribute_category        := l_claim_line_rec.attribute_category;
2256         l_claim_lines_hist_rec.attribute1                := l_claim_line_rec.attribute1;
2257         l_claim_lines_hist_rec.attribute2                := l_claim_line_rec.attribute2;
2258         l_claim_lines_hist_rec.attribute3                := l_claim_line_rec.attribute3;
2259         l_claim_lines_hist_rec.attribute4                := l_claim_line_rec.attribute4;
2260         l_claim_lines_hist_rec.attribute5                := l_claim_line_rec.attribute5;
2261         l_claim_lines_hist_rec.attribute6                := l_claim_line_rec.attribute6;
2262         l_claim_lines_hist_rec.attribute7                := l_claim_line_rec.attribute7;
2263         l_claim_lines_hist_rec.attribute8                := l_claim_line_rec.attribute8;
2264         l_claim_lines_hist_rec.attribute9                := l_claim_line_rec.attribute9;
2265         l_claim_lines_hist_rec.attribute10               := l_claim_line_rec.attribute10;
2266         l_claim_lines_hist_rec.attribute11               := l_claim_line_rec.attribute11;
2267         l_claim_lines_hist_rec.attribute12               := l_claim_line_rec.attribute12;
2268         l_claim_lines_hist_rec.attribute13               := l_claim_line_rec.attribute13;
2269         l_claim_lines_hist_rec.attribute14               := l_claim_line_rec.attribute14;
2270         l_claim_lines_hist_rec.attribute15               := l_claim_line_rec.attribute15;
2271         l_claim_lines_hist_rec.org_id                    := l_claim_line_rec.org_id;
2272         l_claim_lines_hist_rec.utilization_id            := l_claim_line_rec.utilization_id;
2273         l_claim_lines_hist_rec.claim_currency_amount     := l_claim_line_rec.claim_currency_amount;
2274         l_claim_lines_hist_rec.item_id                   := l_claim_line_rec.item_id;
2275        	l_claim_lines_hist_rec.item_description          := l_claim_line_rec.item_description;
2276          l_claim_lines_hist_rec.quantity                  := l_claim_line_rec.quantity;
2277        	l_claim_lines_hist_rec.quantity_uom              := l_claim_line_rec.quantity_uom;
2278        	l_claim_lines_hist_rec.rate                      := l_claim_line_rec.rate;
2279        	l_claim_lines_hist_rec.activity_type             := l_claim_line_rec.activity_type;
2280        	l_claim_lines_hist_rec.activity_id               := l_claim_line_rec.activity_id;
2281        	l_claim_lines_hist_rec.earnings_associated_flag  := l_claim_line_rec.earnings_associated_flag;
2282        	l_claim_lines_hist_rec.comments                  := l_claim_line_rec.comments;
2283        	l_claim_lines_hist_rec.related_cust_account_id   := l_claim_line_rec.related_cust_account_id;
2284        	l_claim_lines_hist_rec.relationship_type         := l_claim_line_rec.relationship_type;
2285         l_claim_lines_hist_rec.buy_group_cust_account_id := l_claim_line_rec.buy_group_cust_account_id;
2286         l_claim_lines_hist_rec.select_cust_children_flag := l_claim_line_rec.select_cust_children_flag;
2287         l_claim_lines_hist_rec.tax_code                  := l_claim_line_rec.tax_code;
2288         l_claim_lines_hist_rec.credit_to                 := l_claim_line_rec.credit_to;
2292         l_claim_lines_hist_rec.tax_amount                := l_claim_line_rec.tax_amount;
2289 
2290         l_claim_lines_hist_rec.sale_date                 := l_claim_line_rec.sale_date;
2291         l_claim_lines_hist_rec.item_type                 := l_claim_line_rec.item_type;
2293         l_claim_lines_hist_rec.claim_curr_tax_amount     := l_claim_line_rec.claim_curr_tax_amount;
2294         l_claim_lines_hist_rec.activity_line_id          := l_claim_line_rec.activity_line_id;
2295         l_claim_lines_hist_rec.offer_type                := l_claim_line_rec.offer_type;
2296         l_claim_lines_hist_rec.prorate_earnings_flag     := l_claim_line_rec.prorate_earnings_flag;
2297         l_claim_lines_hist_rec.earnings_end_date         := l_claim_line_rec.earnings_end_date;
2298 
2299 
2300 
2301         OZF_claim_line_hist_PVT.Create_claim_line_hist(
2302            P_Api_Version_Number         => 1.0,
2303            P_Init_Msg_List              => FND_API.G_FALSE,
2304            P_Commit                     => FND_API.G_FALSE,
2305            P_Validation_Level           => FND_API.G_VALID_LEVEL_FULL,
2306            X_Return_Status              => l_return_status,
2307            X_Msg_Count                  => l_msg_count,
2308            X_Msg_Data                   => l_msg_data,
2309            P_CLAIM_LINE_HIST_Rec       => l_CLAIM_LINES_HIST_Rec,
2310            X_CLAIM_LINE_HISTORY_ID      => l_CLAIM_LINE_HISTORY_ID
2311 	);
2312         IF l_return_status = FND_API.g_ret_sts_error THEN
2313            RAISE FND_API.g_exc_error;
2314         ELSIF l_return_status = FND_API.g_ret_sts_unexp_error THEN
2315            RAISE FND_API.g_exc_unexpected_error;
2316         END IF;
2317 
2318     END LOOP;
2319     x_claim_history_id := l_claim_history_id;
2320 
2321     IF OZF_DEBUG_LOW_ON THEN
2322          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2323          FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
2324          FND_MSG_PUB.Add;
2325     END IF;
2326 EXCEPTION
2327    WHEN FND_API.G_EXC_ERROR THEN
2328       x_return_status := FND_API.G_RET_STS_ERROR;
2329    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2330       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2331    WHEN OTHERS THEN
2332       IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
2333          FND_MESSAGE.set_name('OZF', 'OZF_CLAIM_CREATE_HIST_ERR');
2334          FND_MSG_PUB.add;
2335       END IF;
2336       x_return_status := FND_API.g_ret_sts_unexp_error;
2337 END create_history;
2338 
2339 ---------------------------------------------------------------------
2340 -- PROCEDURE
2341 --    Delete_Claims_History
2342 --
2343 -- PURPOSE
2344 --    This procedure deletes a record in ozf_claims_history_all table by calling
2345 --    the table handler package.
2346 --
2347 -- PARAMETERS
2348 --    p_CLAIMS_HISTORY_Rec: The record that you want to delete.
2349 --
2350 -- NOTES:
2351 --
2352 ---------------------------------------------------------------------
2353 PROCEDURE Delete_claims_history(
2354     P_Api_Version_Number         IN   NUMBER,
2355     P_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
2356     P_Commit                     IN   VARCHAR2     := FND_API.G_FALSE,
2357     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
2358     X_Return_Status              OUT NOCOPY  VARCHAR2,
2359     X_Msg_Count                  OUT NOCOPY  NUMBER,
2360     X_Msg_Data                   OUT NOCOPY  VARCHAR2,
2361     P_CLAIM_HISTORY_ID           IN  NUMBER,
2362     P_Object_Version_Number      IN   NUMBER
2363     )
2364 
2365  IS
2366 l_api_name                CONSTANT VARCHAR2(30) := 'Delete_claims_history';
2367 l_api_version_number      CONSTANT NUMBER   := 1.0;
2368 l_object_version_number     NUMBER;
2369 
2370 CURSOR version_csr (p_claim_history_id in number)IS
2371 SELECT object_version_number
2372 FROM   ozf_claims_history_all
2373 WHERE  claim_history_id = p_claim_history_id;
2374 
2375 BEGIN
2376       -- Standard Start of API savepoint
2377       SAVEPOINT DELETE_CLAIMS_HISTORY_PVT;
2378 
2379       -- Standard call to check for call compatibility.
2380       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2381                                         p_api_version_number,
2382                                            l_api_name,
2383                                            G_PKG_NAME)
2384       THEN
2385           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2386       END IF;
2387 
2388       -- Initialize message list if p_init_msg_list is set to TRUE.
2389       IF FND_API.to_Boolean( p_init_msg_list )
2390       THEN
2391           FND_MSG_PUB.initialize;
2392       END IF;
2393 
2394       -- Initialize API return status to SUCCESS
2395       x_return_status := FND_API.G_RET_STS_SUCCESS;
2396 
2397       --
2398       -- Api body
2399       --
2400       -- Debug Message
2401       IF OZF_DEBUG_LOW_ON THEN
2402          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2403          FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
2404          FND_MSG_PUB.Add;
2405       END IF;
2406 
2407       -- Invoke table handler(OZF_claims_history_PKG.Delete_Row)
2408       OPEN version_csr(p_claim_history_id);
2409       FETCH version_csr INTO l_object_version_number;
2410       CLOSE version_csr;
2411 
2412       IF p_object_version_number = l_object_version_number THEN
2413          BEGIN
2414            OZF_claims_history_PKG.Delete_Row(
2415               p_CLAIM_HISTORY_ID  => p_CLAIM_HISTORY_ID);
2416          EXCEPTION
2417            WHEN OTHERS THEN
2418              IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
2419                 FND_MESSAGE.set_name('OZF', 'OZF_API_RECORD_NOT_FOUND');
2420                 FND_MSG_PUB.add;
2421              END IF;
2422              RAISE FND_API.g_exc_error;
2423            END;
2424       ELSE
2425          IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_error) THEN
2426             FND_MESSAGE.set_name('OZF', 'OZF_API_RESOURCE_LOCKED');
2427             FND_MSG_PUB.add;
2428             END IF;
2429          RAISE FND_API.g_exc_error;
2430       END IF;
2431 
2432       --
2433       -- End of API body
2434       --
2435 
2436       -- Standard check for p_commit
2437       IF FND_API.to_Boolean( p_commit )
2438       THEN
2439           COMMIT WORK;
2440       END IF;
2441 
2442       -- Debug Message
2443       IF OZF_DEBUG_LOW_ON THEN
2444          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2445          FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
2446          FND_MSG_PUB.Add;
2447       END IF;
2448 
2449       -- Standard call to get message count and if count is 1, get message info.
2450       FND_MSG_PUB.Count_And_Get
2451         (p_count          =>   x_msg_count,
2452          p_data           =>   x_msg_data
2453       );
2454 EXCEPTION
2455    WHEN FND_API.G_EXC_ERROR THEN
2456     ROLLBACK TO DELETE_CLAIMS_HISTORY_PVT;
2457     x_return_status := FND_API.G_RET_STS_ERROR;
2458     -- Standard call to get message count and if count=1, get the message
2459     FND_MSG_PUB.Count_And_Get (
2460             p_encoded => FND_API.G_FALSE,
2461             p_count => x_msg_count,
2462             p_data  => x_msg_data
2463     );
2464    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2465     ROLLBACK TO DELETE_CLAIMS_HISTORY_PVT;
2466     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2467     -- Standard call to get message count and if count=1, get the message
2468     FND_MSG_PUB.Count_And_Get (
2469             p_encoded => FND_API.G_FALSE,
2470             p_count => x_msg_count,
2471              p_data  => x_msg_data
2472     );
2473    WHEN OTHERS THEN
2474     ROLLBACK TO DELETE_CLAIMS_HISTORY_PVT;
2475     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2476     IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2477     THEN
2478             FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2479     END IF;
2480     -- Standard call to get message count and if count=1, get the message
2481     FND_MSG_PUB.Count_And_Get (
2482             p_encoded => FND_API.G_FALSE,
2483             p_count => x_msg_count,
2484             p_data  => x_msg_data
2485     );
2486 End Delete_claims_history;
2487 
2488 ---------------------------------------------------------------------
2489 -- PROCEDURE
2490 --    Update_Claims_History
2491 --
2492 -- PURPOSE
2493 --    This procedure updates a record in ozf_claims_history_all table by calling
2494 --    the table handler package.
2495 --
2496 -- PARAMETERS
2497 --    p_CLAIMS_HISTORY_Rec: The record that you want to update.
2498 --
2499 -- NOTES:
2500 --
2501 ---------------------------------------------------------------------
2502 PROCEDURE Update_Claims_History(
2503     P_Api_Version_Number         IN   NUMBER,
2504     P_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
2505     P_Commit                     IN   VARCHAR2     := FND_API.G_FALSE,
2506     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
2507 
2508     X_Return_Status              OUT NOCOPY  VARCHAR2,
2509     X_Msg_Count                  OUT NOCOPY  NUMBER,
2510     X_Msg_Data                   OUT NOCOPY  VARCHAR2,
2511 
2512     P_CLAIMS_HISTORY_Rec         IN   CLAIMS_HISTORY_Rec_Type,
2513     X_Object_Version_Number      OUT NOCOPY  NUMBER
2514     )
2515 IS
2516 l_api_name                CONSTANT VARCHAR2(30) := 'Update_Claims_History';
2517 l_api_version_number      CONSTANT NUMBER   := 1.0;
2518 -- Local Variables
2519 l_object_version_number   NUMBER;
2520 l_CLAIM_HISTORY_ID        NUMBER;
2521 l_return_status           varchar2(30);
2522 l_claims_history_rec      claims_history_rec_type;
2523 
2524 CURSOR object_version_number_csr (p_id in number) is
2525 select object_version_number
2526 from ozf_claims_history_all
2527 where claim_history_id = p_id;
2528 
2529 
2530 BEGIN
2531       -- Standard Start of API savepoint
2532       SAVEPOINT UPDATE_CLAIMS_HISTORY_PVT;
2533 
2534       -- Standard call to check for call compatibility.
2535       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2536                                            p_api_version_number,
2537                                            l_api_name,
2538                                            G_PKG_NAME)
2539       THEN
2540           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2541       END IF;
2542 
2546           FND_MSG_PUB.initialize;
2543       -- Initialize message list if p_init_msg_list is set to TRUE.
2544       IF FND_API.to_Boolean( p_init_msg_list )
2545       THEN
2547       END IF;
2548 
2549       -- Debug Message
2550       IF OZF_DEBUG_LOW_ON THEN
2551          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2552          FND_MESSAGE.Set_Token('TEXT',l_api_name||': START');
2553          FND_MSG_PUB.Add;
2554       END IF;
2555 
2556       -- Initialize API return status to SUCCESS
2557       x_return_status := FND_API.G_RET_STS_SUCCESS;
2558 
2559       If (P_CLAIMS_HISTORY_Rec.object_version_number is NULL or
2560           P_CLAIMS_HISTORY_Rec.object_version_number = FND_API.G_MISS_NUM ) Then
2561           IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2562              FND_MESSAGE.Set_Name('OZF', 'OZF_API_NO_OBJ_VER_NUM');
2563              FND_MSG_PUB.ADD;
2564           END IF;
2565           raise FND_API.G_EXC_ERROR;
2566       End if;
2567 
2568       -- Check Whether record has been changed by someone else
2569       OPEN object_version_number_csr(P_CLAIMS_HISTORY_Rec.claim_history_id);
2570       FETCH object_version_number_csr INTO l_object_version_number;
2571       CLOSE object_version_number_csr;
2572 
2573       IF l_object_version_number <> P_CLAIMS_HISTORY_Rec.object_version_number THEN
2574          IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2575             FND_MESSAGE.Set_Name('OZF', 'OZF_API_RESOURCE_LOCKED');
2576             FND_MSG_PUB.ADD;
2577          END IF;
2578          RAISE FND_API.G_EXC_ERROR;
2579       END IF;
2580 
2581       Complete_Claim_History_Rec (
2582          p_claim_history_rec  => p_claims_history_rec
2583         ,x_complete_rec       => l_claims_history_rec
2584         ,x_return_status      => l_return_status
2585       );
2586 
2587       IF l_return_status = FND_API.g_ret_sts_error THEN
2588          RAISE FND_API.g_exc_error;
2589       ELSIF l_return_status = FND_API.g_ret_sts_unexp_error THEN
2590          RAISE FND_API.g_exc_unexpected_error;
2591       END IF;
2592 
2593       IF ( P_validation_level >= FND_API.G_VALID_LEVEL_FULL) THEN
2594 
2595 	  -- Invoke validation procedures
2596           Validate_claims_history(
2597             p_api_version_number     => 1.0,
2598             p_init_msg_list    => FND_API.G_FALSE,
2599             p_validation_level => p_validation_level,
2600             P_CLAIMS_HISTORY_Rec  =>  l_CLAIMS_HISTORY_Rec,
2601             x_return_status    => x_return_status,
2602             x_msg_count        => x_msg_count,
2603             x_msg_data         => x_msg_data);
2604           IF x_return_status<>FND_API.G_RET_STS_SUCCESS THEN
2605              RAISE FND_API.G_EXC_ERROR;
2606           END IF;
2607       END IF;
2608 
2609 
2610       -- Invoke table handler(OZF_claims_history_PKG.Update_Row)
2611       Begin
2612         OZF_claims_history_PKG.Update_Row(
2613           p_CLAIM_HISTORY_ID       => l_CLAIMS_HISTORY_rec.CLAIM_HISTORY_ID,
2614           p_OBJECT_VERSION_NUMBER  => l_CLAIMS_HISTORY_rec.OBJECT_VERSION_NUMBER +1 ,
2615           p_LAST_UPDATE_DATE       => SYSDATE,
2616           p_LAST_UPDATED_BY        => FND_GLOBAL.USER_ID,
2617           p_LAST_UPDATE_LOGIN      => FND_GLOBAL.CONC_LOGIN_ID,
2618           p_REQUEST_ID             => l_CLAIMS_HISTORY_rec.REQUEST_ID,
2619           p_PROGRAM_APPLICATION_ID => l_CLAIMS_HISTORY_rec.PROGRAM_APPLICATION_ID,
2620           p_PROGRAM_UPDATE_DATE    => l_CLAIMS_HISTORY_rec.PROGRAM_UPDATE_DATE,
2621           p_PROGRAM_ID             => l_CLAIMS_HISTORY_rec.PROGRAM_ID,
2622           p_CREATED_FROM           => l_CLAIMS_HISTORY_rec.CREATED_FROM,
2623           p_BATCH_ID               => l_CLAIMS_HISTORY_rec.BATCH_ID,
2624           p_CLAIM_ID               => l_CLAIMS_HISTORY_rec.CLAIM_ID,
2625           p_CLAIM_NUMBER           => l_CLAIMS_HISTORY_rec.CLAIM_NUMBER,
2626           p_CLAIM_TYPE_ID          => l_CLAIMS_HISTORY_rec.CLAIM_TYPE_ID,
2627           p_CLAIM_CLASS            => l_CLAIMS_HISTORY_REC.CLAIM_CLASS,
2628           p_CLAIM_DATE             => l_CLAIMS_HISTORY_rec.CLAIM_DATE,
2629           p_DUE_DATE               => l_CLAIMS_HISTORY_rec.DUE_DATE,
2630           p_OWNER_ID               => l_CLAIMS_HISTORY_rec.OWNER_ID,
2631           p_HISTORY_EVENT          => l_CLAIMS_HISTORY_rec.HISTORY_EVENT,
2632           p_HISTORY_EVENT_DATE     => l_CLAIMS_HISTORY_rec.HISTORY_EVENT_DATE,
2633           p_HISTORY_EVENT_DESCRIPTION  => l_CLAIMS_HISTORY_rec.HISTORY_EVENT_DESCRIPTION,
2634           p_SPLIT_FROM_CLAIM_ID    => l_CLAIMS_HISTORY_rec.SPLIT_FROM_CLAIM_ID,
2635           p_duplicate_claim_id     => l_claims_history_rec.duplicate_claim_id,
2636           p_SPLIT_DATE             => l_CLAIMS_HISTORY_rec.SPLIT_DATE,
2637           p_ROOT_CLAIM_ID          => l_claims_history_rec.ROOT_CLAIM_ID,
2638           p_AMOUNT                 => l_CLAIMS_HISTORY_rec.AMOUNT,
2639           p_AMOUNT_ADJUSTED        => l_CLAIMS_HISTORY_rec.AMOUNT_ADJUSTED,
2640           p_AMOUNT_REMAINING       => l_CLAIMS_HISTORY_rec.AMOUNT_REMAINING,
2641           p_AMOUNT_SETTLED         => l_CLAIMS_HISTORY_rec.AMOUNT_SETTLED,
2642           p_ACCTD_AMOUNT           => l_CLAIMS_HISTORY_rec.ACCTD_AMOUNT,
2643           p_acctd_amount_remaining => l_claims_history_rec.acctd_amount_remaining,
2644           p_acctd_AMOUNT_ADJUSTED  => l_CLAIMS_HISTORY_rec.acctd_AMOUNT_ADJUSTED,
2645           p_acctd_AMOUNT_SETTLED   => l_CLAIMS_HISTORY_rec.acctd_AMOUNT_SETTLED,
2646           p_tax_amount             => l_claims_history_rec.tax_amount,
2647           p_tax_code               => l_claims_history_rec.tax_code,
2648           p_tax_calculation_flag   => l_claims_history_rec.tax_calculation_flag,
2649           p_CURRENCY_CODE          => l_CLAIMS_HISTORY_rec.CURRENCY_CODE,
2650           p_EXCHANGE_RATE_TYPE     => l_CLAIMS_HISTORY_rec.EXCHANGE_RATE_TYPE,
2651           p_EXCHANGE_RATE_DATE     => l_CLAIMS_HISTORY_rec.EXCHANGE_RATE_DATE,
2655           p_SOURCE_OBJECT_ID       => l_CLAIMS_HISTORY_rec.SOURCE_OBJECT_ID,
2652           p_EXCHANGE_RATE          => l_CLAIMS_HISTORY_rec.EXCHANGE_RATE,
2653           p_SET_OF_BOOKS_ID        => l_CLAIMS_HISTORY_rec.SET_OF_BOOKS_ID,
2654           p_ORIGINAL_CLAIM_DATE    => l_CLAIMS_HISTORY_rec.ORIGINAL_CLAIM_DATE,
2656           p_SOURCE_OBJECT_CLASS    => l_CLAIMS_HISTORY_rec.SOURCE_OBJECT_CLASS,
2657           p_SOURCE_OBJECT_TYPE_ID  => l_CLAIMS_HISTORY_rec.SOURCE_OBJECT_TYPE_ID,
2658           p_SOURCE_OBJECT_NUMBER   => l_CLAIMS_HISTORY_rec.SOURCE_OBJECT_NUMBER,
2659           p_CUST_ACCOUNT_ID        => l_CLAIMS_HISTORY_rec.CUST_ACCOUNT_ID,
2660           p_CUST_BILLTO_ACCT_SITE_ID  => l_CLAIMS_HISTORY_rec.CUST_BILLTO_ACCT_SITE_ID,
2661           p_cust_shipto_acct_site_id  => l_claims_history_rec.cust_shipto_acct_site_id,
2662           p_LOCATION_ID            => l_CLAIMS_HISTORY_rec.LOCATION_ID,
2663           p_PAY_RELATED_ACCOUNT_FLAG => l_claims_history_rec.PAY_RELATED_ACCOUNT_FLAG,
2664           p_RELATED_CUST_ACCOUNT_ID  => l_claims_history_rec.RELATED_CUST_ACCOUNT_ID,
2665           p_RELATED_SITE_USE_ID      => l_claims_history_rec.RELATED_SITE_USE_ID,
2666           p_RELATIONSHIP_TYPE        => l_claims_history_rec.RELATIONSHIP_TYPE,
2667           p_VENDOR_ID                => l_claims_history_rec.VENDOR_ID,
2668           p_VENDOR_SITE_ID           => l_claims_history_rec.VENDOR_SITE_ID,
2669           p_REASON_TYPE              => l_CLAIMS_HISTORY_rec.REASON_TYPE,
2670           p_REASON_CODE_ID           => l_CLAIMS_HISTORY_rec.REASON_CODE_ID,
2671           p_TASK_TEMPLATE_GROUP_ID   => l_claims_history_rec.TASK_TEMPLATE_GROUP_ID,
2672           p_STATUS_CODE              => l_CLAIMS_HISTORY_rec.STATUS_CODE,
2673           p_USER_STATUS_ID           => l_CLAIMS_HISTORY_rec.USER_STATUS_ID,
2674           p_SALES_REP_ID             => l_CLAIMS_HISTORY_rec.SALES_REP_ID,
2675           p_COLLECTOR_ID             => l_CLAIMS_HISTORY_rec.COLLECTOR_ID,
2676           p_CONTACT_ID               => l_CLAIMS_HISTORY_rec.CONTACT_ID,
2677           p_BROKER_ID                => l_CLAIMS_HISTORY_rec.BROKER_ID,
2678           p_TERRITORY_ID             => l_CLAIMS_HISTORY_rec.TERRITORY_ID,
2679           p_CUSTOMER_REF_DATE        => l_CLAIMS_HISTORY_rec.CUSTOMER_REF_DATE,
2680           p_CUSTOMER_REF_NUMBER      => l_CLAIMS_HISTORY_rec.CUSTOMER_REF_NUMBER,
2681           p_ASSIGNED_TO              => l_CLAIMS_HISTORY_rec.ASSIGNED_TO,
2682           p_RECEIPT_ID               => l_CLAIMS_HISTORY_rec.RECEIPT_ID,
2683           p_RECEIPT_NUMBER           => l_CLAIMS_HISTORY_rec.RECEIPT_NUMBER,
2684           p_DOC_SEQUENCE_ID          => l_CLAIMS_HISTORY_rec.DOC_SEQUENCE_ID,
2685           p_DOC_SEQUENCE_VALUE       => l_CLAIMS_HISTORY_rec.DOC_SEQUENCE_VALUE,
2686           p_GL_DATE                  => l_CLAIMS_HISTORY_rec.GL_DATE,
2687           p_PAYMENT_METHOD           => l_CLAIMS_HISTORY_rec.PAYMENT_METHOD,
2688           p_VOUCHER_ID               => l_CLAIMS_HISTORY_rec.VOUCHER_ID,
2689           p_VOUCHER_NUMBER           => l_CLAIMS_HISTORY_rec.VOUCHER_NUMBER,
2690           p_PAYMENT_REFERENCE_ID     => l_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_ID,
2691           p_PAYMENT_REFERENCE_NUMBER => l_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_NUMBER,
2692           p_PAYMENT_REFERENCE_DATE   => l_CLAIMS_HISTORY_rec.PAYMENT_REFERENCE_DATE,
2693           p_PAYMENT_STATUS           => l_CLAIMS_HISTORY_rec.PAYMENT_STATUS,
2694           p_APPROVED_FLAG            => l_CLAIMS_HISTORY_rec.APPROVED_FLAG,
2695           p_APPROVED_DATE            => l_CLAIMS_HISTORY_rec.APPROVED_DATE,
2696           p_APPROVED_BY              => l_CLAIMS_HISTORY_rec.APPROVED_BY,
2697           p_SETTLED_DATE             => l_CLAIMS_HISTORY_rec.SETTLED_DATE,
2698           p_SETTLED_BY               => l_CLAIMS_HISTORY_rec.SETTLED_BY,
2699           p_CUSTOM_SETUP_ID          => l_claims_history_rec.CUSTOM_SETUP_ID,
2700           p_effective_date           => l_claims_history_rec.effective_date,
2701           p_TASK_ID                  => l_claims_history_rec.TASK_ID,
2702           p_COUNTRY_ID               => l_claims_history_rec.COUNTRY_ID,
2703           p_ORDER_TYPE_ID               => l_claims_history_rec.ORDER_TYPE_ID,
2704           p_COMMENTS                 => l_CLAIMS_HISTORY_rec.COMMENTS,
2705           p_LETTER_ID                => l_CLAIMS_HISTORY_rec.LETTER_ID,
2706           p_LETTER_DATE              => l_CLAIMS_HISTORY_rec.LETTER_DATE,
2707           p_TASK_SOURCE_OBJECT_ID    => l_CLAIMS_HISTORY_rec.TASK_SOURCE_OBJECT_ID,
2708           p_TASK_SOURCE_OBJECT_TYPE_CODE  => l_CLAIMS_HISTORY_rec.TASK_SOURCE_OBJECT_TYPE_CODE,
2709           p_ATTRIBUTE_CATEGORY       => l_CLAIMS_HISTORY_rec.ATTRIBUTE_CATEGORY,
2710           p_ATTRIBUTE1  => l_CLAIMS_HISTORY_rec.ATTRIBUTE1,
2711           p_ATTRIBUTE2  => l_CLAIMS_HISTORY_rec.ATTRIBUTE2,
2712           p_ATTRIBUTE3  => l_CLAIMS_HISTORY_rec.ATTRIBUTE3,
2713           p_ATTRIBUTE4  => l_CLAIMS_HISTORY_rec.ATTRIBUTE4,
2714           p_ATTRIBUTE5  => l_CLAIMS_HISTORY_rec.ATTRIBUTE5,
2715           p_ATTRIBUTE6  => l_CLAIMS_HISTORY_rec.ATTRIBUTE6,
2716           p_ATTRIBUTE7  => l_CLAIMS_HISTORY_rec.ATTRIBUTE7,
2717           p_ATTRIBUTE8  => l_CLAIMS_HISTORY_rec.ATTRIBUTE8,
2718           p_ATTRIBUTE9  => l_CLAIMS_HISTORY_rec.ATTRIBUTE9,
2719           p_ATTRIBUTE10  => l_CLAIMS_HISTORY_rec.ATTRIBUTE10,
2720           p_ATTRIBUTE11  => l_CLAIMS_HISTORY_rec.ATTRIBUTE11,
2721           p_ATTRIBUTE12  => l_CLAIMS_HISTORY_rec.ATTRIBUTE12,
2722           p_ATTRIBUTE13  => l_CLAIMS_HISTORY_rec.ATTRIBUTE13,
2723           p_ATTRIBUTE14  => l_CLAIMS_HISTORY_rec.ATTRIBUTE14,
2724           p_ATTRIBUTE15  => l_CLAIMS_HISTORY_rec.ATTRIBUTE15,
2725           p_DEDUCTION_ATTRIBUTE_CATEGORY  => l_claims_history_rec.DEDUCTION_ATTRIBUTE_CATEGORY,
2726           p_DEDUCTION_ATTRIBUTE1  => l_claims_history_rec.DEDUCTION_ATTRIBUTE1,
2727           p_DEDUCTION_ATTRIBUTE2  => l_claims_history_rec.DEDUCTION_ATTRIBUTE2,
2728           p_DEDUCTION_ATTRIBUTE3  => l_claims_history_rec.DEDUCTION_ATTRIBUTE3,
2729           p_DEDUCTION_ATTRIBUTE4  => l_claims_history_rec.DEDUCTION_ATTRIBUTE4,
2730           p_DEDUCTION_ATTRIBUTE5  => l_claims_history_rec.DEDUCTION_ATTRIBUTE5,
2731           p_DEDUCTION_ATTRIBUTE6  => l_claims_history_rec.DEDUCTION_ATTRIBUTE6,
2735           p_DEDUCTION_ATTRIBUTE10  => l_claims_history_rec.DEDUCTION_ATTRIBUTE10,
2732           p_DEDUCTION_ATTRIBUTE7  => l_claims_history_rec.DEDUCTION_ATTRIBUTE7,
2733           p_DEDUCTION_ATTRIBUTE8  => l_claims_history_rec.DEDUCTION_ATTRIBUTE8,
2734           p_DEDUCTION_ATTRIBUTE9  => l_claims_history_rec.DEDUCTION_ATTRIBUTE9,
2736           p_DEDUCTION_ATTRIBUTE11  => l_claims_history_rec.DEDUCTION_ATTRIBUTE11,
2737           p_DEDUCTION_ATTRIBUTE12  => l_claims_history_rec.DEDUCTION_ATTRIBUTE12,
2738           p_DEDUCTION_ATTRIBUTE13  => l_claims_history_rec.DEDUCTION_ATTRIBUTE13,
2739           p_DEDUCTION_ATTRIBUTE14  => l_claims_history_rec.DEDUCTION_ATTRIBUTE14,
2740           p_DEDUCTION_ATTRIBUTE15  => l_claims_history_rec.DEDUCTION_ATTRIBUTE15,
2741           p_ORG_ID                 => l_CLAIMS_HISTORY_rec.ORG_ID,
2742 	       p_WRITE_OFF_FLAG                => l_CLAIMS_HISTORY_rec.WRITE_OFF_FLAG,
2743 	       p_WRITE_OFF_THRESHOLD_AMOUNT    => l_CLAIMS_HISTORY_rec.WRITE_OFF_THRESHOLD_AMOUNT,
2744 	       p_UNDER_WRITE_OFF_THRESHOLD     => l_CLAIMS_HISTORY_rec.UNDER_WRITE_OFF_THRESHOLD,
2745 	       p_CUSTOMER_REASON               => l_CLAIMS_HISTORY_rec.CUSTOMER_REASON,
2746           p_SHIP_TO_CUST_ACCOUNT_ID   => l_CLAIMS_HISTORY_rec.SHIP_TO_CUST_ACCOUNT_ID,
2747           p_AMOUNT_APPLIED => l_claims_history_rec.AMOUNT_APPLIED,                          --Bug:2781186
2748           p_APPLIED_RECEIPT_ID => l_claims_history_rec.APPLIED_RECEIPT_ID,                  --Bug:2781186
2749           p_APPLIED_RECEIPT_NUMBER => l_claims_history_rec.APPLIED_RECEIPT_NUMBER,           --Bug:2781186
2750           p_WO_REC_TRX_ID          => l_CLAIMS_HISTORY_rec.WO_REC_TRX_ID,
2751           p_GROUP_CLAIM_ID          => l_CLAIMS_HISTORY_rec.GROUP_CLAIM_ID,
2752           p_APPR_WF_ITEM_KEY          => l_CLAIMS_HISTORY_rec.APPR_WF_ITEM_KEY,
2753           p_CSTL_WF_ITEM_KEY          => l_CLAIMS_HISTORY_rec.CSTL_WF_ITEM_KEY,
2754           p_BATCH_TYPE          => l_CLAIMS_HISTORY_rec.BATCH_TYPE
2755           );
2756       EXCEPTION
2757        WHEN OTHERS THEN
2758          IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
2759              FND_MESSAGE.set_name('OZF', 'OZF_TABLE_HANDLER_ERROR');
2760              FND_MSG_PUB.add;
2761          END IF;
2762          RAISE FND_API.g_exc_error;
2763       END;
2764 
2765       -- Standard check for p_commit
2766       IF FND_API.to_Boolean( p_commit )
2767       THEN
2768           COMMIT WORK;
2769       END IF;
2770 
2771 
2772       -- Debug Message
2773       IF OZF_DEBUG_LOW_ON THEN
2774         FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2775         FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
2776         FND_MSG_PUB.Add;
2777       END IF;
2778 
2779       -- Standard call to get message count and if count is 1, get message info.
2780       FND_MSG_PUB.Count_And_Get
2781         (p_count          =>   x_msg_count,
2782          p_data           =>   x_msg_data
2783       );
2784 EXCEPTION
2785    WHEN FND_API.G_EXC_ERROR THEN
2786     ROLLBACK TO UPDATE_CLAIMS_HISTORY_PVT;
2787     x_return_status := FND_API.G_RET_STS_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    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2795     ROLLBACK TO UPDATE_CLAIMS_HISTORY_PVT;
2796     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2797     -- Standard call to get message count and if count=1, get the message
2798     FND_MSG_PUB.Count_And_Get (
2799             p_encoded => FND_API.G_FALSE,
2800             p_count => x_msg_count,
2801              p_data  => x_msg_data
2802     );
2803    WHEN OTHERS THEN
2804     ROLLBACK TO UPDATE_CLAIMS_HISTORY_PVT;
2805     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2806     IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2807     THEN
2808             FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2809     END IF;
2810     -- Standard call to get message count and if count=1, get the message
2811     FND_MSG_PUB.Count_And_Get (
2812             p_encoded => FND_API.G_FALSE,
2813             p_count => x_msg_count,
2814             p_data  => x_msg_data
2815     );
2816 End Update_claims_history;
2817 
2818 ---------------------------------------------------------------------
2819 -- PROCEDURE
2820 --    Validate_Claims_History
2821 --
2822 -- PURPOSE
2823 --    This procedure validates a claim history record.
2824 --
2825 -- PARAMETERS
2826 --    p_CLAIMS_HISTORY_Rec: The record that you want to validate.
2827 --
2828 -- NOTES:
2829 --    Currently, there is no criteria that we need to check.
2830 --
2831 ---------------------------------------------------------------------
2832 PROCEDURE Validate_claims_history(
2833     P_Api_Version_Number         IN   NUMBER,
2834     P_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
2835     P_Validation_level           IN   NUMBER := FND_API.G_VALID_LEVEL_FULL,
2836     P_CLAIMS_HISTORY_Rec         IN    CLAIMS_HISTORY_Rec_Type,
2837     X_Return_Status              OUT NOCOPY  VARCHAR2,
2838     X_Msg_Count                  OUT NOCOPY  NUMBER,
2839     X_Msg_Data                   OUT NOCOPY  VARCHAR2
2840     )
2841  IS
2842 l_api_name                CONSTANT VARCHAR2(30) := 'Validate_claims_history';
2843 l_api_version_number      CONSTANT NUMBER   := 1.0;
2844 l_object_version_number   NUMBER;
2845 
2846  BEGIN
2847       -- Standard Start of API savepoint
2848       SAVEPOINT VALIDATE_CLAIMS_HISTORY_PVT;
2849 
2850       -- Standard call to check for call compatibility.
2851       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
2852                                         p_api_version_number,
2853                                            l_api_name,
2854                                            G_PKG_NAME)
2855       THEN
2856           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2857       END IF;
2858 
2859       -- Initialize message list if p_init_msg_list is set to TRUE.
2860       IF FND_API.to_Boolean( p_init_msg_list )
2861       THEN
2862           FND_MSG_PUB.initialize;
2863       END IF;
2864 
2865       -- Api body
2866       --
2867       -- Debug Message
2868       IF OZF_DEBUG_LOW_ON THEN
2869          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2870          FND_MESSAGE.Set_Token('TEXT',l_api_name||': Start');
2871          FND_MSG_PUB.Add;
2872       END IF;
2873 
2874       IF p_validation_level >= JTF_PLSQL_API.g_valid_level_item THEN
2875               IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2876                   RAISE FND_API.G_EXC_ERROR;
2877               ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2878                   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2879               END IF;
2880       END IF;
2881 
2882       -- Initialize API return status to SUCCESS
2883       x_return_status := FND_API.G_RET_STS_SUCCESS;
2884 
2885       -- Debug Message
2886       IF OZF_DEBUG_LOW_ON THEN
2887          FND_MESSAGE.Set_Name('OZF','OZF_API_DEBUG_MESSAGE');
2888          FND_MESSAGE.Set_Token('TEXT',l_api_name||': End');
2889          FND_MSG_PUB.Add;
2890       END IF;
2891 
2892       -- Standard call to get message count and if count is 1, get message info.
2893       FND_MSG_PUB.Count_And_Get
2894         (p_count          =>   x_msg_count,
2895          p_data           =>   x_msg_data
2896       );
2897 EXCEPTION
2898    WHEN FND_API.G_EXC_ERROR THEN
2899     ROLLBACK TO VALIDATE_CLAIMS_HISTORY_PVT;
2900     x_return_status := FND_API.G_RET_STS_ERROR;
2901     -- Standard call to get message count and if count=1, get the message
2902     FND_MSG_PUB.Count_And_Get (
2903             p_encoded => FND_API.G_FALSE,
2904             p_count => x_msg_count,
2905             p_data  => x_msg_data
2906     );
2907    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2908     ROLLBACK TO VALIDATE_CLAIMS_HISTORY_PVT;
2909     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2910     -- Standard call to get message count and if count=1, get the message
2911     FND_MSG_PUB.Count_And_Get (
2912             p_encoded => FND_API.G_FALSE,
2913             p_count => x_msg_count,
2914              p_data  => x_msg_data
2915     );
2916    WHEN OTHERS THEN
2917     ROLLBACK TO VALIDATE_CLAIMS_HISTORY_PVT;
2918     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2919     IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2920     THEN
2921             FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2922     END IF;
2923     -- Standard call to get message count and if count=1, get the message
2924     FND_MSG_PUB.Count_And_Get (
2925             p_encoded => FND_API.G_FALSE,
2926             p_count => x_msg_count,
2927             p_data  => x_msg_data
2928     );
2929 End Validate_claims_history;
2930 
2931 End OZF_claims_history_PVT;