DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSM_DEBRIEF_EXPENSES_PKG

Source


1 PACKAGE BODY CSM_DEBRIEF_EXPENSES_PKG AS
2 /* $Header: csmudbeb.pls 120.4 2008/03/24 08:57:46 ptomar ship $ */
3 
4 -- MODIFICATION HISTORY
5 -- Person      Date    Comments
6 -- Anurag     06/10/02 Created
7 -- ---------   ------  ------------------------------------------
8    -- Enter procedure, function bodies as shown below
9 
10 
11 /*** Globals ***/
12 g_object_name  CONSTANT VARCHAR2(30) := 'CSM_DEBRIEF_EXPENSES_PKG';  -- package name
13 g_pub_name     CONSTANT VARCHAR2(30) := 'CSF_M_DEBRIEF_EXPENSES';  -- publication item name
14 g_debug_level           NUMBER; -- debug level
15 
16 CURSOR c_debrief_expenses( b_user_name VARCHAR2, b_tranid NUMBER) is
17   SELECT *
18   FROM  csf_m_debrief_expenses_inq
19   WHERE tranid$$ = b_tranid
20   AND   clid$$cs = b_user_name;
21 
22 /***
23   This procedure is called by APPLY_RECORD when an inserted record is to be processed.
24 ***/
25 PROCEDURE APPLY_INSERT
26          (
27            p_record        IN c_debrief_expenses%ROWTYPE,
28            p_error_msg     OUT NOCOPY    VARCHAR2,
29            x_return_status IN OUT NOCOPY VARCHAR2
30          ) IS
31 
32 cursor c_deb_head
33        ( b_task_assignment_id number
34        )
35 is
36 select debrief_header_id
37 ,      task_assignment_id
38 from   csf_debrief_headers
39 where  task_assignment_id = b_task_assignment_id;
40 
41 cursor c_task_obj_code
42        ( b_task_assignment_id number
43        )
44 is
45 select source_object_type_code
46 from   jtf_tasks_b jtb
47 ,      jtf_task_assignments jta
48 where  jtb.task_id = jta.task_id
49 and    jta.task_assignment_id = b_task_assignment_id;
50 
51 r_deb_head c_deb_head%rowtype;
52 r_task_obj_code c_task_obj_code%rowtype;
53 
54 -- Cursor to check if the Assignment Status is either of the
55 -- following rejected, on_hold, cancelled, closed or completed
56 CURSOR c_chk_task_status
57      (  p_debrief_header_id CSF_DEBRIEF_HEADERS.DEBRIEF_HEADER_ID%TYPE
58      ) IS
59 SELECT tst.rejected_flag, tst.on_hold_flag, tst.cancelled_flag,
60        tst.closed_flag, tst.completed_flag
61 FROM csf_debrief_headers dh, jtf_task_assignments tas,
62      jtf_task_statuses_b tst
63 WHERE dh.task_assignment_id = tas.task_assignment_id
64 AND tas.assignment_status_id = tst.task_status_id
65 AND dh.debrief_header_id = p_debrief_header_id;
66 
67 l_rejected_flag          VARCHAR2(1);
68 l_on_hold_flag           VARCHAR2(1);
69 l_cancelled_flag         VARCHAR2(1);
70 l_closed_flag            VARCHAR2(1);
71 l_completed_flag         VARCHAR2(1);
72 
73 l_deb_rec                csf_debrief_pub.debrief_rec_type;
74 
75 l_line_rec               csf_debrief_pub.debrief_line_rec_type;
76 l_line_tbl               csf_debrief_pub.debrief_line_tbl_type;
77 
78 
79 l_debrief_header_id      number;
80 l_date                   date           := sysdate;
81 
82 l_issuing_inventory_org_id   csf_debrief_lines.issuing_inventory_org_id%TYPE;
83 l_receiving_inventory_org_id   csf_debrief_lines.receiving_inventory_org_id%TYPE;
84 
85 l_msg_data               varchar2(1024);
86 l_msg_count              number;
87 
88 BEGIN
89 
90 x_return_status := FND_API.G_RET_STS_SUCCESS;
91 
92 -- Start with some initialization.
93 -- We need to know if a debrief header record has been made
94 -- form this task_assignment_id. In that case we have to
95 -- reuse it instead of creating one.
96 -- Prerequisite: at most one record exist with the
97 -- task_assignment_id we're looking for.
98 open c_deb_head
99      ( p_record.task_assignment_id
100      );
101 fetch c_deb_head into r_deb_head;
102 if c_deb_head%found
103 then
104    l_debrief_header_id := r_deb_head.debrief_header_id;
105 else
106    l_debrief_header_id := null;
107 end if;
108 close c_deb_head;
109 
110 
111 
112 -- Create a debrief header record.
113 l_deb_rec.debrief_date       := l_date;
114 --l_deb_rec.debrief_number     := To_Char( l_debrief_header_id );
115 
116 l_deb_rec.task_assignment_id := p_record.task_assignment_id;
117 l_deb_rec.debrief_header_id  := l_debrief_header_id;
118 l_deb_rec.debrief_status_id  := NULL;
119 l_deb_rec.last_update_date   := l_date;
120 l_deb_rec.last_updated_by    :=  NVL(p_record.last_updated_by,FND_GLOBAL.USER_ID);  --12.1
121 l_deb_rec.creation_date      := l_date;
122 l_deb_rec.created_by         := NVL(p_record.created_by,FND_GLOBAL.USER_ID); --12.1
123 l_deb_rec.last_update_login  := FND_GLOBAL.LOGIN_ID;
124 
125 if l_debrief_header_id is null
126 then
127    -- Create a debrief header.
128    l_deb_rec.debrief_number     := null ;
129 
130    csf_debrief_pub.create_debrief
131    ( p_api_version_number => 1.0
132    , p_init_msg_list      => FND_API.G_TRUE
133    , p_commit             => FND_API.G_FALSE
134    , p_debrief_rec        => l_deb_rec
135    , p_debrief_line_tbl   => l_line_tbl
136    , x_debrief_header_id  => l_debrief_header_id
137    , x_return_status      => x_return_status
138    , x_msg_count          => l_msg_count
139    , x_msg_data           => l_msg_data
140    );
141 
142    -- This could have failed, so we need to check.
143    if x_return_status <> FND_API.G_RET_STS_SUCCESS
144    THEN
145       csm_util_pkg.log('ABCD Test 03');
146       /*** exception occurred in API -> return errmsg ***/
147       p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
148       (
149         p_api_error      => TRUE
150       );
151       CSM_UTIL_PKG.log( 'Error in ' || g_object_name || '.APPLY_INSERT:'
152                || ' ROOT ERROR: csf_debrief_pub.create_debrief'
153                || ' for PK ' || p_record.DEBRIEF_LINE_ID,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_INSERT',FND_LOG.LEVEL_ERROR );
154       x_return_status := FND_API.G_RET_STS_ERROR;
155       return;
156    end if;
157 end if;
158 
159 -- Make the debrief line.
160 
161 -- Retrieve the issuing organization id.
162 -- We may have to replace this with another master_organization_id.
163 
164 l_line_rec.debrief_line_id          := p_record.debrief_line_id;
165 l_line_rec.debrief_header_id        := l_debrief_header_id;
166 l_line_rec.issuing_inventory_org_id := l_issuing_inventory_org_id;
167 l_line_rec.receiving_inventory_org_id := l_receiving_inventory_org_id;
168 l_line_rec.last_update_date         := l_date;
169 l_line_rec.last_updated_by          :=  NVL(p_record.last_updated_by,FND_GLOBAL.USER_ID); --12.1
170 l_line_rec.creation_date            := l_date;
171 l_line_rec.created_by               :=  NVL(p_record.created_by,FND_GLOBAL.USER_ID); --12.1
172 l_line_rec.last_update_login        := FND_GLOBAL.LOGIN_ID;
173 l_line_rec.inventory_item_id        := p_record.inventory_item_id;
174 l_line_rec.txn_billing_type_id      := p_record.txn_billing_type_id;
175 --l_line_rec.debrief_line_number      := To_Char( p_record.debrief_line_id );
176 l_line_rec.uom_code                 := p_record.uom_code;
177 l_line_rec.quantity                 := p_record.quantity;
178 l_line_rec.expense_amount           := p_record.expense_amount;
179 l_line_rec.currency_code            := p_record.currency_code;
180 l_line_rec.service_date             := nvl(p_record.service_date,l_date);
181 l_line_rec.business_process_id      := p_record.business_process_id;
182 l_line_rec.channel_code         := 'CSF_MFS';
183 l_line_rec.transaction_type_id      := p_record.transaction_type_id;
184 l_line_rec.expense_reason_code      := p_record.expense_reason_code;
185 l_line_rec.attribute1               := p_record.attribute1;
186 l_line_rec.attribute2               := p_record.attribute2;
187 l_line_rec.attribute3               := p_record.attribute3;
188 l_line_rec.attribute4               := p_record.attribute4;
189 l_line_rec.attribute5               := p_record.attribute5;
190 l_line_rec.attribute6               := p_record.attribute6;
191 l_line_rec.attribute7               := p_record.attribute7;
192 l_line_rec.attribute8               := p_record.attribute8;
193 l_line_rec.attribute9               := p_record.attribute9;
194 l_line_rec.attribute10              := p_record.attribute10;
195 l_line_rec.attribute11              := p_record.attribute11;
196 l_line_rec.attribute12              := p_record.attribute12;
197 l_line_rec.attribute13              := p_record.attribute13;
198 l_line_rec.attribute14              := p_record.attribute14;
199 l_line_rec.attribute15              := p_record.attribute15;
200 l_line_rec.attribute_category       := p_record.attribute_category;
201 
202 l_line_tbl(1) := l_line_rec;
203 
204 -- Fetch SOURCE_OBJECT_TYPE_CODE from task record
205 open c_task_obj_code
206      ( p_record.task_assignment_id
207      );
208 fetch c_task_obj_code into r_task_obj_code;
209 close c_task_obj_code;
210 
211 csf_debrief_pub.create_debrief_lines
212 ( p_api_version_number      => 1.0
213 , p_init_msg_list           => FND_API.G_TRUE
214 , p_commit                  => FND_API.G_FALSE
215 , x_return_status           => x_return_status
216 , x_msg_count               => l_msg_count
217 , x_msg_data                => l_msg_data
218 , p_debrief_header_id       => l_debrief_header_id
219 , p_debrief_line_tbl        => l_line_tbl
220 , p_source_object_type_code => r_task_obj_code.source_object_type_code
221 );
222 if x_return_status <> FND_API.G_RET_STS_SUCCESS
223 then
224     /*** exception occurred in API -> return errmsg ***/
225     p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
226     (
227         p_api_error      => TRUE
228     );
229     CSM_UTIL_PKG.log( 'Error in ' || g_object_name || '.APPLY_INSERT:'
230                || ' ROOT ERROR: csf_debrief_pub.create_debrief_lines'
231                || ' for PK ' || p_record.DEBRIEF_LINE_ID ,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_INSERT',FND_LOG.LEVEL_ERROR);
232    x_return_status := FND_API.G_RET_STS_ERROR;
233    return;
234 end if;
235 
236 -- For a given debrief header check the task Assignment status.
237 -- If it is one of the following -
238 -- rejected, on_hold, cancelled, closed or completed then call the api
239 --  csf_debrief_update_pkg.form_Call for processing charges
240 
241     OPEN c_chk_task_status ( l_debrief_header_id );
242     FETCH c_chk_task_status INTO l_rejected_flag, l_on_hold_flag,
243        l_cancelled_flag, l_closed_flag, l_completed_flag;
244 
245     IF c_chk_task_status%FOUND THEN
246        IF ( (l_rejected_flag='Y') OR (l_on_hold_flag='Y') OR (l_cancelled_flag='Y')
247           OR (l_closed_flag='Y') OR (l_completed_flag='Y') ) THEN
248           csf_debrief_update_pkg.form_Call (1.0, l_debrief_header_id );
249        END IF;
250     END IF;
251 
252     CLOSE c_chk_task_status;
253 
254 exception
255   when others then
256      fnd_msg_pub.Add_Exc_Msg( g_object_name, 'APPLY_INSERT', sqlerrm);
257      p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
258      (
259        p_api_error      => TRUE
260      );
261      CSM_UTIL_PKG.log( 'Exception in ' || g_object_name || '.APPLY_INSERT:'
262                || ' for PK ' || p_record.DEBRIEF_LINE_ID ,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_INSERT',FND_LOG.LEVEL_EXCEPTION);
263   x_return_status := FND_API.G_RET_STS_ERROR;
264 END APPLY_INSERT;
265 
266 /***
267   This procedure is called by APPLY_CLIENT_CHANGES when an inserted record is to be processed.
268 ***/
269 PROCEDURE APPLY_UPDATE
270          (
271            p_record        IN c_debrief_expenses%ROWTYPE,
272            p_error_msg     OUT NOCOPY    VARCHAR2,
273            x_return_status IN OUT NOCOPY VARCHAR2
274          ) IS
275 
276 CURSOR c_cdl
277     ( b_debrief_line_id csf_debrief_lines.debrief_line_id%TYPE
278     )
279 IS
280     SELECT cdl.debrief_header_id
281     ,      cdl.debrief_line_id
282     ,      cdl.last_update_date
283     ,      cdl.issuing_inventory_org_id
284     FROM   csf_debrief_lines cdl
285     WHERE  cdl.debrief_line_id = b_debrief_line_id;
286 
287 r_cdl c_cdl%ROWTYPE;
288 
289 l_line_rec               csf_debrief_pub.debrief_line_rec_type;
290 
291 l_debrief_header_id      number;
292 l_date                   date           := sysdate;
293 
294 l_msg_data               varchar2(1024);
295 l_msg_count              number;
296 
297 
298 BEGIN
299 
300 x_return_status := FND_API.G_RET_STS_SUCCESS;
301 
302 -- Lookup the debrief_header id. It must be there as this is an update
303 -- of a line.
304   OPEN c_cdl
305     (b_debrief_line_id => p_record.debrief_line_id
306     );
307   FETCH c_cdl
308   INTO r_cdl;
309   IF c_cdl%found
310   THEN
311     l_debrief_header_id := r_cdl.debrief_header_id;
312   ELSE
313     -- Let the API complain about it.
314     l_debrief_header_id := NULL;
315   END IF;
316   CLOSE c_cdl;
317 
318 -- Make the debrief line.
319 l_line_rec.issuing_inventory_org_id := r_cdl.issuing_inventory_org_id;
320 l_line_rec.debrief_line_id          := p_record.debrief_line_id;
321 l_line_rec.debrief_header_id        := l_debrief_header_id;
322 l_line_rec.last_update_date         := l_date;
323 l_line_rec.last_updated_by          :=  NVL(p_record.last_updated_by,FND_GLOBAL.USER_ID); --12.1
324 l_line_rec.last_update_login        := FND_GLOBAL.LOGIN_ID;
325 l_line_rec.inventory_item_id        := p_record.inventory_item_id;
326 l_line_rec.txn_billing_type_id      := p_record.txn_billing_type_id;
327 l_line_rec.service_date             := nvl(p_record.service_date,l_date);
328 --l_line_rec.debrief_line_number      := To_Char( p_record.debrief_line_id );
329 l_line_rec.uom_code                 := p_record.uom_code;
330 l_line_rec.quantity                 := p_record.quantity;
331 l_line_rec.expense_amount           := p_record.expense_amount;
332 l_line_rec.currency_code            := p_record.currency_code;
333 l_line_rec.business_process_id      := p_record.business_process_id;
334 l_line_rec.channel_code         := 'CSF_MFS';
335 l_line_rec.transaction_type_id      := p_record.transaction_type_id;
336 l_line_rec.expense_reason_code      := p_record.expense_reason_code;
337 l_line_rec.attribute1               := p_record.attribute1;
338 l_line_rec.attribute2               := p_record.attribute2;
339 l_line_rec.attribute3               := p_record.attribute3;
340 l_line_rec.attribute4               := p_record.attribute4;
341 l_line_rec.attribute5               := p_record.attribute5;
342 l_line_rec.attribute6               := p_record.attribute6;
343 l_line_rec.attribute7               := p_record.attribute7;
344 l_line_rec.attribute8               := p_record.attribute8;
345 l_line_rec.attribute9               := p_record.attribute9;
346 l_line_rec.attribute10              := p_record.attribute10;
347 l_line_rec.attribute11              := p_record.attribute11;
348 l_line_rec.attribute12              := p_record.attribute12;
349 l_line_rec.attribute13              := p_record.attribute13;
350 l_line_rec.attribute14              := p_record.attribute14;
351 l_line_rec.attribute15              := p_record.attribute15;
352 l_line_rec.attribute_category       := p_record.attribute_category;
353 
354 --check for the stale data
355   -- SERVER_WINS profile value
356   if(fnd_profile.value(csm_profile_pkg.g_JTM_APPL_CONFLICT_RULE)
357        = csm_profile_pkg.g_SERVER_WINS) then
358     if(r_cdl.last_update_date <> p_record.server_last_update_date) then
359        x_return_status := FND_API.G_RET_STS_ERROR;
360        p_error_msg := 'UPWARD SYNC CONFLICT: CLIENT LOST: CSM_DEBRIEF_EXPENSES_PKG.APPLY_UPDATE: P_KEY = '
361           || p_record.debrief_line_id;
362        csm_util_pkg.log(p_error_msg,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_UPDATE',FND_LOG.LEVEL_ERROR);
363        return;
364     end if;
365   end if;
366 
367   --CLIENT_WINS (or client is allowd to update the record)
368 
369 -- Update the debrief line
370 csf_debrief_pub.update_debrief_line
371 ( p_api_version_number      => 1.0
372 , p_init_msg_list           => FND_API.G_TRUE
373 , p_commit                  => FND_API.G_FALSE
374 , x_return_status           => x_return_status
375 , x_msg_count               => l_msg_count
376 , x_msg_data                => l_msg_data
377 , p_debrief_line_rec        => l_line_rec
378 );
379 if x_return_status <> FND_API.G_RET_STS_SUCCESS
380 then
381     /*** exception occurred in API -> return errmsg ***/
382     p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
383       (
384         p_api_error      => TRUE
385       );
386 
387     CSM_UTIL_PKG.log( 'Error in ' || g_object_name || '.APPLY_UPDATE:'
388                || ' ROOT ERROR: csf_debrief_pub.update_debrief_lines'
389                || ' for PK ' || p_record.DEBRIEF_LINE_ID,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_UPDATE',FND_LOG.LEVEL_ERROR );
390 
391    x_return_status := FND_API.G_RET_STS_ERROR;
392    return;
393 end if;
394 
395 exception
396   when others then
397      fnd_msg_pub.Add_Exc_Msg( g_object_name, 'APPLY_UPDATE', sqlerrm);
398      p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
399      (
400        p_api_error      => TRUE
401      );
402 
403      CSM_UTIL_PKG.log( 'Exception in ' || g_object_name || '.APPLY_UPDATE:'
404                || ' for PK ' || p_record.DEBRIEF_LINE_ID,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_UPDATE',FND_LOG.LEVEL_EXCEPTION );
405   x_return_status := FND_API.G_RET_STS_ERROR;
406 END APPLY_UPDATE;
407 
408 
409 
410 /***
411   This procedure is called by APPLY_CLIENT_CHANGES for every record in in-queue that needs to be processed.
412 ***/
413 PROCEDURE APPLY_RECORD
414          (
415            p_record        IN     c_debrief_expenses%ROWTYPE,
416            p_error_msg     OUT NOCOPY    VARCHAR2,
417            x_return_status IN OUT NOCOPY VARCHAR2
418          ) IS
419 BEGIN
420   /*** initialize return status and message list ***/
421   x_return_status := FND_API.G_RET_STS_SUCCESS;
422   FND_MSG_PUB.INITIALIZE;
423 
424   IF p_record.dmltype$$='I' THEN
425     -- Process insert
426     APPLY_INSERT
427       (
428         p_record,
429         p_error_msg,
430         x_return_status
431       );
432   ELSIF p_record.dmltype$$='U' THEN
433     -- Process update
434     APPLY_UPDATE
435       (
436         p_record,
437         p_error_msg,
438         x_return_status
439       );
440   ELSE
441     -- Process delete; not supported for this entity
442       CSM_UTIL_PKG.LOG
443         ( 'Delete is not supported for this entity'
444       || ' for PK ' || p_record.debrief_line_id ,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_RECORD',FND_LOG.LEVEL_ERROR);
445 
446     p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
447       (
448         p_message        => 'CSM_DML_OPERATION'
449       , p_token_name1    => 'DML'
450       , p_token_value1   => p_record.dmltype$$
451       );
452 
453     x_return_status := FND_API.G_RET_STS_ERROR;
454   END IF;
455 
456 EXCEPTION WHEN OTHERS THEN
457   /*** defer record when any process exception occurs ***/
458     CSM_UTIL_PKG.LOG
459     ( 'Exception occurred in CSM_DEBRIEF_EXPENSES_PKG.APPLY_RECORD:' || ' ' || sqlerrm
460       || ' for PK ' || p_record.debrief_line_id ,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_RECORD',FND_LOG.LEVEL_EXCEPTION );
461 
462   fnd_msg_pub.Add_Exc_Msg( g_object_name, 'APPLY_RECORD', sqlerrm);
463   p_error_msg := CSM_UTIL_PKG.GET_ERROR_MESSAGE_TEXT
464     (
465       p_api_error      => TRUE
466     );
467 
468   x_return_status := FND_API.G_RET_STS_ERROR;
469 END APPLY_RECORD;
470 
471 /***
472   This procedure is called by CSM_UTIL_PKG when publication item <replace>
473   is dirty. This happens when a mobile field service device executed DML on an updatable table and did
474   a fast sync. This procedure will insert the data that came from mobile into the backend tables using
475   public APIs.
476 ***/
477 PROCEDURE APPLY_CLIENT_CHANGES
478          (
479            p_user_name     IN VARCHAR2,
480            p_tranid        IN NUMBER,
481            p_debug_level   IN NUMBER,
482            x_return_status IN OUT NOCOPY VARCHAR2
483          ) IS
484 
485   l_process_status VARCHAR2(1);
486   l_error_msg      VARCHAR2(4000);
487 BEGIN
488   g_debug_level := p_debug_level;
489   x_return_status := FND_API.G_RET_STS_SUCCESS;
490 
491 
492 
493   /*** loop through debrief expenses records in inqueue ***/
494   FOR r_debrief_expenses IN c_debrief_expenses( p_user_name, p_tranid) LOOP
495 
496     SAVEPOINT save_rec;
497 
498     /*** apply record ***/
499     APPLY_RECORD
500       (
501         r_debrief_expenses
502       , l_error_msg
503       , l_process_status
504       );
505 
506     /*** was record processed successfully? ***/
507     IF l_process_status = FND_API.G_RET_STS_SUCCESS THEN
508       /*** Yes -> delete record from inqueue ***/
509 
510       CSM_UTIL_PKG.DELETE_RECORD
511         (
512           p_user_name,
513           p_tranid,
514           r_debrief_expenses.seqno$$,
515           r_debrief_expenses.debrief_line_id,
516           g_object_name,
517           g_pub_name,
518           l_error_msg,
519           l_process_status
520         );
521 
522       /*** was delete successful? ***/
523       IF l_process_status <> FND_API.G_RET_STS_SUCCESS THEN
524         /*** no -> rollback ***/
525           CSM_UTIL_PKG.LOG
526           ( 'Deleting from inqueue failed, rolling back to savepoint'
527       || ' for PK ' || r_debrief_expenses.debrief_line_id ,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_CLIENT_CHANGES',FND_LOG.LEVEL_ERROR ); -- put PK column here
528         ROLLBACK TO save_rec;
529         x_return_status := FND_API.G_RET_STS_ERROR;
530       END IF;
531     END IF;
532 
533     IF l_process_Status <> FND_API.G_RET_STS_SUCCESS THEN
534       /*** Record was not processed successfully or delete failed -> defer and reject record ***/
535         CSM_UTIL_PKG.LOG
536         ( 'Record not processed successfully, deferring and rejecting record'
537       || ' for PK ' || r_debrief_expenses.debrief_line_id,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_CLIENT_CHANGES',FND_LOG.LEVEL_ERROR ); -- put PK column here
538 
539       CSM_UTIL_PKG.DEFER_RECORD
540        (
541          p_user_name
542        , p_tranid
543        , r_debrief_expenses.seqno$$
544        , r_debrief_expenses.debrief_line_id
545        , g_object_name
546        , g_pub_name
547        , l_error_msg
548        , l_process_status
549        , r_debrief_expenses.dmltype$$
550        );
551 
552       /*** Was defer successful? ***/
553       IF l_process_status <> FND_API.G_RET_STS_SUCCESS THEN
554         /*** no -> rollback ***/
555           CSM_UTIL_PKG.LOG
556           ( 'Defer record failed, rolling back to savepoint'
557       || ' for PK ' || r_debrief_expenses.debrief_line_id,'CSM_DEBRIEF_EXPENSES_PKG.APPLY_CLIENT_CHANGES',FND_LOG.LEVEL_ERROR  ); -- put PK column here
558         ROLLBACK TO save_rec;
559         x_return_status := FND_API.G_RET_STS_ERROR;
560       END IF;
561     END IF;
562 
563   END LOOP;
564 
565 EXCEPTION WHEN OTHERS THEN
566   /*** catch and log exceptions ***/
567     CSM_UTIL_PKG.LOG
568     ( 'Exception occurred in APPLY_CLIENT_CHANGES:' || ' ' || SQLERRM,
569     'CSM_DEBRIEF_EXPENSES_PKG.APPLY_CLIENT_CHANGES',FND_LOG.LEVEL_EXCEPTION );
570   x_return_status := FND_API.G_RET_STS_ERROR;
571 END APPLY_CLIENT_CHANGES;
572 
573 END CSM_DEBRIEF_EXPENSES_PKG;