DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSM_DEBRIEF_PARTS_PKG

Source


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