DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_MTLTEMPPROC_PRIV

Source


1 package body wip_mtlTempProc_priv as
2  /* $Header: wiptmpvb.pls 120.3.12010000.2 2008/08/12 19:00:19 kboonyap ship $ */
3 
4   non_txactable_value CONSTANT VARCHAR2(1) := 'N';
5 
6   g_pkgName VARCHAR2(30) := 'wip_mtlTempProc_priv';
7 
8   procedure processTemp(p_initMsgList IN VARCHAR2,
9                         p_txnHdrID IN NUMBER,
10                         p_txnMode IN NUMBER,
11                         p_destroyQtyTrees IN VARCHAR2 := null,
12                         p_endDebug IN VARCHAR2 := null,
13                         x_returnStatus OUT NOCOPY VARCHAR2,
14                         x_errorMsg OUT NOCOPY VARCHAR2) IS
15   l_errMsg VARCHAR2(2000);
16   l_errCode VARCHAR2(2000);
17   l_params wip_logger.param_tbl_t;
18   l_retStatus VARCHAR2(1);
19   l_logRetStatus VARCHAR2(1);
20   l_retCode NUMBER;
21   l_logLevel NUMBER := to_number(fnd_log.g_current_runtime_level);
22   l_flowSchedCount NUMBER;
23   l_invStatus NUMBER;
24   l_count NUMBER;
25   cursor c_rows is
26     select transaction_temp_id
27       from mtl_material_transactions_temp
28      where transaction_header_id = p_txnHdrID;
29 
30   begin
31 -------------------------------------------------------------
32 --Initial Preprocessing
33 -------------------------------------------------------------
34 
35     savepoint wiptmpvb0;
36     if (l_logLevel <= wip_constants.trace_logging) then
37       l_params(1).paramName := 'p_initMsgList';
38       l_params(1).paramValue := p_initMsgList;
39       l_params(2).paramName := 'p_txnHdrID';
40       l_params(2).paramValue := p_txnHdrID;
41       l_params(3).paramName := 'p_txnMode';
42       l_params(3).paramValue := p_txnMode;
43       l_params(4).paramName := 'p_destroyQtyTrees';
44       l_params(4).paramValue := p_destroyQtyTrees;
45       wip_logger.entryPoint(p_procName     => 'wip_mtlTempProc_priv.processTemp',
46                             p_params       => l_params,
47                             x_returnStatus => x_returnStatus);
48       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
49         raise fnd_api.g_exc_unexpected_error;
50       end if;
51     end if;
52     x_returnStatus := fnd_api.g_ret_sts_success;
53 
54     if(fnd_api.to_boolean(p_initMsgList)) then
55       fnd_msg_pub.initialize;
56     end if;
57 
58     l_retCode := inv_lpn_trx_pub.process_lpn_trx(p_trx_hdr_id => p_txnHdrID,
59                                                  p_proc_mode => p_txnMode,
60                                                  x_proc_msg => l_errMsg);
61 
62     if(l_logLevel <= wip_constants.full_logging) then
63       wip_logger.log('inv returned:' || l_retCode, l_retStatus);
64       wip_logger.log('inv errmsg:' || l_errMsg, l_retStatus);
65     end if;
66 
67     --for some reason TM errors clear the stack so we must put the
68     --error message back, but successful txns do not clear the stack
69     if(l_retCode <> 0) then
70       fnd_message.set_name('FND', 'FND_GENERIC_MESSAGE');
71       fnd_message.set_token('MESSAGE', l_errMsg);
72       fnd_msg_pub.add;
73       wip_utilities.get_message_stack(p_msg => x_errorMsg,
74                                       p_delete_stack => fnd_api.g_false);
75       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
76     else
77       wip_utilities.get_message_stack(p_msg => x_errorMsg,
78                                       p_delete_stack => fnd_api.g_false);
79     end if;
80 
81 
82 -------------------------------------------------------------
83 --Cleanup Processing
84 -------------------------------------------------------------
85     if(fnd_api.to_boolean(nvl(p_destroyQtyTrees, fnd_api.g_false))) then
86       inv_quantity_tree_pub.clear_quantity_cache;
87     end if;
88 
89     if (l_logLevel <= wip_constants.trace_logging) then
90       wip_logger.exitPoint(p_procName         => 'wip_mtlTempProc_priv.processTemp',
91                            p_procReturnStatus => x_returnStatus,
92                            p_msg              => 'success',
93                            x_returnStatus     => l_retStatus);
94       if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
95         wip_logger.cleanup(l_retStatus);
96       end if;
97     end if;
98   exception
99     when fnd_api.g_exc_unexpected_error then
100       rollback to wiptmpvb0;
101       wip_utilities.get_message_stack(p_msg => x_errorMsg,
102                                      p_delete_stack => fnd_api.g_false,
103                                      p_separator => ' ');
104       if (l_logLevel <= wip_constants.trace_logging) then
105         wip_logger.exitPoint(p_procName         => 'wip_mtlTempProc_priv.processTemp',
106                              p_procReturnStatus => x_returnStatus,
107                              p_msg              => 'unhandled exception: ' || SQLERRM,
108                              x_returnStatus     => l_retStatus);
109         if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
110           wip_logger.cleanup(l_retStatus);
111         end if;
112       end if;
113     when others then
114       rollback to wiptmpvb0;
115       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
116       fnd_msg_pub.add_exc_msg(p_pkg_name       => 'wip_mtlTempProc_priv',
117                               p_procedure_name => 'processTemp',
118                               p_error_text     => SQLERRM);
119       wip_utilities.get_message_stack(p_msg => x_errorMsg,
120                                      p_delete_stack => fnd_api.g_false,
121                                      p_separator => ' ');
122       fnd_message.set_name('WIP', 'MTL_PROC_FAIL');
123       l_errCode := fnd_message.get;
124 
125       update mtl_material_transactions_temp
126          set process_flag = 'E',
127              error_code = substr(l_errCode,1,240),
128              error_explanation = substr(x_errorMsg,1,240)
129        where transaction_header_id = p_txnHdrID
130          and process_flag in ('Y', 'W')
131          and transaction_source_type_id = 5
132          and transaction_action_id in (wip_constants.isscomp_action,
133                                        wip_constants.retcomp_action,
134                                        wip_constants.issnegc_action,
135                                        wip_constants.retnegc_action);
136 
137       if (l_logLevel <= wip_constants.trace_logging) then
138         wip_logger.exitPoint(p_procName         => 'wip_mtlTempProc_priv.processTemp',
139                              p_procReturnStatus => x_returnStatus,
140                              p_msg              => 'unhandled exception: ' || SQLERRM,
141                              x_returnStatus     => l_retStatus);
142         if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
143           wip_logger.cleanup(l_retStatus);
144         end if;
145       end if;
146   end processTemp;
147 
148   procedure processWIP(p_txnTmpID IN NUMBER,
149                        p_processLpn IN VARCHAR2,
150                        p_endDebug in VARCHAR2 := null,
151                        x_returnStatus OUT NOCOPY VARCHAR2,
152                        x_errorMsg OUT NOCOPY VARCHAR2) is
153     l_retStatus VARCHAR2(1);
154     l_params wip_logger.param_tbl_t;
155     l_logLevel NUMBER := fnd_log.g_current_runtime_level;
156     l_procName VARCHAR2(20) := 'processWIP';
157     l_txnActionID NUMBER;
158     l_wipEntityType NUMBER;
159     l_orgID NUMBER;
160     l_wipEntityID NUMBER;
161     l_lpnID NUMBER;
162     l_repLineID NUMBER;
163     l_postingFlag VARCHAR2(1);
164     l_flowSchedule VARCHAR2(1);
165     l_opSeq number;
166     l_supplyType number;
167     /*Bug 6417742 (FP of 6342851): Added following variables*/
168     l_transaction_header_id number;
169     l_transaction_type_id number;
170     returnStatus varchar2(1);
171     l_msg_count number;
172     error varchar2(241);
173     labelStatus varchar2(1);
174     l_msg_stack VARCHAR2(2000);
175     dummyErrCode VARCHAR2(1);
176   begin
177     savepoint wiptmpvb100;
178 
179     if (l_logLevel <= wip_constants.trace_logging) then
180       l_params(1).paramName := 'p_txnTmpID';
181       l_params(1).paramValue := p_txnTmpID;
182       l_params(2).paramName := 'p_processLpn';
183       l_params(2).paramValue := p_processLpn;
184       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
185                             p_params       => l_params,
186                             x_returnStatus => x_returnStatus);
187       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
188         raise fnd_api.g_exc_unexpected_error;
189       end if;
190     end if;
191 
192     x_returnStatus := fnd_api.g_ret_sts_success;
193 
194     select transaction_action_id,
195            transaction_header_id,   /*Added for bug 6417742(FP of 6342851)*/
196            transaction_type_id,     /*Added for bug 6417742(FP of 6342851)*/
197            decode(flow_schedule, --treat wol cpls as flow
198                   'Y', wip_constants.flow,
199                   wip_entity_type),
200            nvl(content_lpn_id, lpn_id),
201            transaction_source_id,
202            organization_id,
203            posting_flag,
204            flow_schedule,
205            operation_seq_num,
206            wip_supply_type
207       into l_txnActionID,
208            l_transaction_header_id,   /*Added for bug 6417742(FP of 6342851)*/
209            l_transaction_type_id,     /*Added for bug 6417742(FP of 6342851)*/
210            l_wipEntityType,
211            l_lpnID,
212            l_wipEntityID,
213            l_orgID,
214            l_postingFlag,
215            l_flowSchedule,
216            l_opSeq,
217            l_supplyType
218       from mtl_material_transactions_temp
219      where transaction_temp_id = p_txnTmpID
220        and transaction_source_type_id = 5;
221 
222     -- delete the record if it is for phantom
223     if ( l_opSeq < 0 and l_supplyType = 6 ) then
224 
225         delete mtl_material_transactions_temp
226         where transaction_temp_id = p_txnTmpID;
227 
228         if(l_logLevel <= wip_constants.trace_logging) then
229           wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
230                              p_procReturnStatus => x_returnStatus,
231                              p_msg              => 'success: phantom record deleted without any action',
232                              x_returnStatus     => l_retStatus);
233           if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
234             wip_logger.cleanup(l_retStatus);
235           end if;
236         end if;
237       return;
238     end if;
239 
240     --wip entity type should be populated. do this as an added check
241     if(l_wipEntityType is null) then
242       select entity_type
243         into l_wipEntityType
244         from wip_entities
245        where wip_entity_id = l_wipEntityID
246          and organization_id = l_orgID;
247     end if;
248 
249     if(l_logLevel <= wip_constants.full_logging) then
250       wip_logger.log('txnActID: ' || l_txnActionID, l_retStatus);
251       wip_logger.log('wipEntityType: ' || l_wipEntityType, l_retStatus);
252       wip_logger.log('lpnID: ' || l_lpnID, l_retStatus);
253       wip_logger.log('wipEntityID: ' || l_wipEntityID, l_retStatus);
254       wip_logger.log('orgID: ' || l_orgID, l_retStatus);
255       wip_logger.log('postingFlag: ' || l_postingFlag, l_retStatus);
256       wip_logger.log('FlowSchedule: ' || l_flowSchedule, l_retStatus);
257     end if;
258 
259     --component issues
260     if(l_txnActionID in (wip_constants.isscomp_action, wip_constants.retcomp_action,
261                          wip_constants.issnegc_action, wip_constants.retnegc_action)) then
262       --no action is necessary for flow txns
263       if(l_wipEntityType <> wip_constants.flow) then
264         if(l_logLevel <= wip_constants.full_logging) then
265           wip_logger.log('calling component processor', l_retStatus);
266         end if;
267         wip_mtlProc_priv.processTemp(p_initMsgList => fnd_api.g_false,
268                                      p_endDebug => fnd_api.g_false,
269                                      p_txnTmpID => p_txnTmpID,
270                                      x_returnStatus => x_returnStatus);
271       end if;
272 
273     elsif(l_txnActionID in (wip_constants.cplassy_action, wip_constants.retassy_action)) then
274       --no action is necessary for lpn completions
275       if(l_lpnID is null or fnd_api.to_boolean(p_processLpn)) then
276         if(l_wipEntityType = wip_constants.flow) then
277           if(l_logLevel <= wip_constants.full_logging) then
278             wip_logger.log('calling flow/wol processor', l_retStatus);
279           end if;
280           wip_cfmProc_priv.processTemp(p_initMsgList => fnd_api.g_false,
281                                        p_txnTempID => p_txnTmpID,
282                                        x_returnStatus => x_returnStatus);
283         else --non flow completion
284           if(l_logLevel <= wip_constants.full_logging) then
285             wip_logger.log('calling cpl processor', l_retStatus);
286           end if;
287           wip_cplProc_priv.processTemp(p_txnTmpID => p_txnTmpID,
288                                        p_initMsgList => fnd_api.g_false,
289                                        p_endDebug => fnd_api.g_false,
290                                        x_returnStatus => x_returnStatus);
291         end if;
292       end if;
293     elsif(l_txnActionID = wip_constants.scrassy_action) then
294       --for repetitive, must do allocation
295       if(l_wipEntityType = wip_constants.repetitive) then
296         if(l_logLevel <= wip_constants.full_logging) then
297           wip_logger.log('calling rep scrap processor', l_retStatus);
298         end if;
299         wip_movProc_priv.repetitive_scrap(p_tmp_id => p_txnTmpID,
300                                           x_returnStatus => x_returnStatus);
301       elsif (l_wipEntityType = wip_constants.flow) then
302         if(l_logLevel <= wip_constants.full_logging) then
303           wip_logger.log('calling flow/wol processor', l_retStatus);
304         end if;
305         wip_cfmProc_priv.processTemp(p_initMsgList => fnd_api.g_false,
306                                      p_txnTempID => p_txnTmpID,
307                                      x_returnStatus => x_returnStatus);
308       end if;
309     end if;
310 
311     if(x_returnStatus <> fnd_api.g_ret_sts_success) then
312       raise fnd_api.g_exc_unexpected_error;
313     end if;
314 
315     if(l_logLevel <= wip_constants.trace_logging) then
316       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
317                            p_procReturnStatus => x_returnStatus,
318                            p_msg              => 'success',
319                            x_returnStatus     => l_retStatus);
320       if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
321         wip_logger.cleanup(l_retStatus);
322       end if;
323     end if;
324 
325     /*Start - Bug 6417742(FP of 6342851): Added call label printing*/
326           if ( l_txnActionID = 31  and l_transaction_type_id=44 and l_flowSchedule = 'Y') then
327              -- print label
328               wip_utilities.print_label(p_txn_id => l_transaction_header_id,  -- should be transaction header id
329                                         p_table_type => 2, --MMTT
330                                         p_ret_status => returnStatus,
331                                         p_msg_count  => l_msg_count,
332                                         p_msg_data   => error,
333                                         p_label_status => labelStatus,
334                                         p_business_flow_code => 33); -- discrete business flow code
335 
336               -- do not error out if label printing, only put warning message in log
337           if(returnStatus <> fnd_api.g_ret_sts_success) then
338                WIP_UTILITIES.get_message_stack(p_msg => l_msg_stack);
339                if (l_logLevel <= wip_constants.full_logging) then
340                  wip_logger.log(p_msg => 'An error has occurred with label printing.\n' ||
341                                          'The following error has occurred during ' ||
342                                          'printing: ' || l_msg_stack || '\n' ||
343                                          'Please check the Inventory log file for more ' ||
344                                          'information.',
345                                 x_returnStatus =>dummyErrCode);
346                end if;
347              end if;
348               if (l_logLevel <= wip_constants.full_logging) then
349                 wip_logger.log(p_msg => 'Label printing returned with status ' ||
350                                         returnStatus,
351                                x_returnStatus => dummyErrCode);
352               end if;
353          end if;
354     /*End - Bug 6417742(FP of 6342851): Added call label printing*/
355 
356   exception
357     when fnd_api.g_exc_unexpected_error then
358       rollback to wiptmpvb100;
359       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
360       wip_utilities.get_message_stack(p_msg => x_errorMsg,
361                                        p_delete_stack => fnd_api.g_false);
362       if(l_logLevel <= wip_constants.trace_logging) then
363         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
364                              p_procReturnStatus => x_returnStatus,
365                              p_msg              => 'error:' || x_errorMsg,
366                              x_returnStatus     => l_retStatus);
367         if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
368           wip_logger.cleanup(l_retStatus);
369         end if;
370       end if;
371     when others then
372       rollback to wiptmpvb100;
373       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
374       fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkgName,
375                               p_procedure_name => l_procName,
376                               p_error_text => SQLERRM);
377       wip_utilities.get_message_stack(p_msg => x_errorMsg,
378                                       p_delete_stack => fnd_api.g_false);
379       if(l_logLevel <= wip_constants.trace_logging) then
380         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
381                              p_procReturnStatus => x_returnStatus,
382                              p_msg              => 'unexp error:' || x_errorMsg,
383                              x_returnStatus     => l_retStatus);
384         if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_false))) then
385           wip_logger.cleanup(l_retStatus);
386         end if;
387       end if;
388   end processWIP;
389 
390   procedure validateInterfaceTxns(p_txnHdrID in NUMBER,
391                                   p_initMsgList in VARCHAR2 := null,
392                                   p_endDebug in VARCHAR2 := null,
393                                   p_numRows IN NUMBER := null,
394                                   p_addMsgToStack IN VARCHAR2 := null,
395                                   p_rollbackOnErr IN VARCHAR2 := null,
396                                   x_returnStatus out nocopy VARCHAR2) is
397     l_retCode NUMBER;
398     l_numIntRows NUMBER := p_numRows;
399     l_numTempRows NUMBER;
400     l_numErrRows NUMBER;
401     l_msgCount NUMBER;
402     l_msgData VARCHAR2(2000);
403     l_logLevel NUMBER := fnd_log.g_current_runtime_level;
404     l_params wip_logger.param_tbl_t;
405     type err_tbl_t is table of varchar2(240);
406     type item_tbl_t is table of varchar2(2000);
407     l_errExplTbl err_tbl_t;
408     l_itemNameTbl item_tbl_t;
409     l_procName VARCHAR2(30) := 'validateInterfaceTxns';
410     l_endDebug VARCHAR2(1) := nvl(p_endDebug, fnd_api.g_false);
411     l_retStatus VARCHAR2(1);
412   begin
413     savepoint wiptmpvb200;
414     x_returnStatus := fnd_api.g_ret_sts_success;
415 
416     if (l_logLevel <= wip_constants.trace_logging) then
417       l_params(1).paramName := 'p_txnHdrID';
418       l_params(1).paramValue := p_txnHdrID;
419 
420       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
421                             p_params       => l_params,
422                             x_returnStatus => x_returnStatus);
423       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
424         raise fnd_api.g_exc_unexpected_error;
425       end if;
426     end if;
427 
428     if(fnd_api.to_boolean(nvl(p_initMsgList, fnd_api.g_false))) then
429       fnd_msg_pub.initialize;
430     end if;
431 
432     if(l_numIntRows is null) then
433       select count(*)
434         into l_numIntRows
435         from mtl_transactions_interface
436        where transaction_header_id = p_txnHdrID
437          and process_flag = wip_constants.mti_inventory;
438     end if;
439 
440     if(l_numIntRows = 0) then
441       if(l_logLevel <= wip_constants.trace_logging) then
442         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
443                              p_procReturnStatus => x_returnStatus,
444                              p_msg              => 'no rows to backflush',
445                              x_returnStatus     => l_retStatus);
446         if(fnd_api.to_boolean(l_endDebug)) then
447           wip_logger.cleanup(l_retStatus);
448         end if;
449       end if;
450       return;
451     end if;
452 
453     l_retCode := inv_txn_manager_grp.validate_transactions(p_api_version => 1.0,
454                                                            p_init_msg_list => nvl(p_initMsgList, fnd_api.g_false),
455                                                            p_validation_level => fnd_api.g_valid_level_none,
456                                                            p_header_id => p_txnHdrID,
457                                                            x_trans_count => l_numTempRows,
458                                                            x_return_status => x_returnStatus,
459                                                            x_msg_count => l_msgCount,
460                                                            x_msg_data => l_msgData);
461 
462     --x_trans_count out param is not supported yet
463     select count(*)
464       into l_numErrRows
465       from mtl_transactions_interface
466      where transaction_header_id = p_txnHdrID;
467 
468     select count(*)
469       into l_numTempRows
470       from mtl_material_transactions_temp
471      where transaction_header_id = p_txnHdrID;
472 
473     --after inv supports x_trans_count, change if below
474 --    if(l_numTempRows = l_numIntRows) then
475     if(l_numErrRows = 0) then
476       if(fnd_api.to_boolean(nvl(p_initMsgList, fnd_api.g_false))) then
477         fnd_msg_pub.initialize;
478       end if;
479       if(l_logLevel <= wip_constants.trace_logging) then
480         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
481                              p_procReturnStatus => x_returnStatus,
482                              p_msg              => 'normal completion. ' || l_numTempRows || ' rows processed.',
483                              x_returnStatus     => l_retStatus);
484         if(fnd_api.to_boolean(l_endDebug)) then
485           wip_logger.cleanup(l_retStatus);
486         end if;
487       end if;
488       return;
489     end if;
490 
491     --if any rows errored...
492     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
493 
494     if(fnd_api.to_boolean(nvl(p_addMsgToStack, fnd_api.g_true))) then
495       --re-initialize message stack
496       if(fnd_api.to_boolean(nvl(p_initMsgList, fnd_api.g_false))) then
497         fnd_msg_pub.initialize;
498       end if;
499 
500       select msik.concatenated_segments,
501              mti.error_explanation
502         bulk collect into l_itemNameTbl,
503                           l_errExplTbl
504         from mtl_transactions_interface mti,
505              mtl_system_items_kfv msik
506        where mti.transaction_header_id = p_txnHdrID
507          and mti.error_explanation is not null
508          and mti.inventory_item_id = msik.inventory_item_id
509          and mti.organization_id = msik.organization_id;
510 
511       for i in 1..l_itemNameTbl.count loop
512         fnd_message.set_name('WIP', 'WIP_TMPINSERT_ERR');
513         fnd_message.set_token('ITEM_NAME', l_itemNameTbl(i));
514         fnd_message.set_token('ERR_MSG', l_errExplTbl(i));
515         if(l_logLevel <= wip_constants.trace_logging) then
516           wip_logger.log('item ' || l_itemNameTbl(i) || ': ' || l_errExplTbl(i), l_retStatus);
517         end if;
518         fnd_msg_pub.add;
519       end loop;
520     end if;
521 
522     if(fnd_api.to_boolean(nvl(p_rollBackOnErr, fnd_api.g_true))) then
523       rollback to wiptmpvb200;
524     end if;
525 
526     if(l_logLevel <= wip_constants.trace_logging) then
527       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
528                            p_procReturnStatus => x_returnStatus,
529                            p_msg              => to_char(l_numIntRows - l_numTempRows) || ' records errored',
530                            x_returnStatus     => l_retStatus);
531       if(fnd_api.to_boolean(l_endDebug)) then
532         wip_logger.cleanup(l_retStatus);
533       end if;
534     end if;
535 
536    exception
537     when fnd_api.g_exc_unexpected_error then
538       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
539       if(fnd_api.to_boolean(nvl(p_rollBackOnErr, fnd_api.g_true))) then
540         rollback to wiptmpvb200;
541       else --caller wants error in MTI
542         wip_utilities.get_message_stack(p_msg => l_msgData,
543                                         p_delete_stack => fnd_api.g_false);
544 
545         update mtl_transactions_interface
546            set last_update_date = sysdate,
547                last_update_login = fnd_global.login_id,
548                program_application_id = fnd_global.prog_appl_id,
549                program_id = fnd_global.conc_program_id,
550                program_update_date = sysdate,
551                request_id = fnd_global.conc_request_id,
552                process_flag = wip_constants.mti_error,
553                error_code = substrb(g_pkgName || '.' || l_procName, 1, 240),
554                error_explanation = substrb(l_msgData, 1, 240)
555          where transaction_header_id = p_txnHdrID;
556       end if;
557 
558       if(l_msgData is not null) then
559         fnd_message.set_name('FND', 'FND_GENERIC_MESSAGE');
560         fnd_message.set_token('MESSAGE', l_msgData);
561         fnd_msg_pub.add;
562       end if;
563       if(l_logLevel <= wip_constants.trace_logging) then
564         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
565                              p_procReturnStatus => x_returnStatus,
566                              p_msg              => 'error:' || l_msgData,
567                              x_returnStatus     => l_retStatus);
568         if(fnd_api.to_boolean(l_endDebug)) then
569           wip_logger.cleanup(l_retStatus);
570         end if;
571       end if;
572     when others then
573       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
574       fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkgName,
575                               p_procedure_name => l_procName,
576                               p_error_text => SQLERRM);
577 
578       if(fnd_api.to_boolean(nvl(p_rollBackOnErr, fnd_api.g_true))) then
579         rollback to wiptmpvb200;
580       else
581         wip_utilities.get_message_stack(p_msg => l_msgData,
582                                         p_delete_stack => fnd_api.g_false);
583 
584         update mtl_transactions_interface
585            set last_update_date = sysdate,
586                last_update_login = fnd_global.login_id,
587                program_application_id = fnd_global.prog_appl_id,
588                program_id = fnd_global.conc_program_id,
589                program_update_date = sysdate,
590                request_id = fnd_global.conc_request_id,
591                process_flag = wip_constants.mti_error,
592                error_code = substrb(g_pkgName || '.' || l_procName, 1, 240),
593                error_explanation = substrb(l_msgData, 1, 240)
594          where transaction_header_id = p_txnHdrID;
595       end if;
596 
597       if(l_logLevel <= wip_constants.trace_logging) then
598         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
599                              p_procReturnStatus => x_returnStatus,
600                              p_msg              => 'unexp error:' || l_msgData,
601                              x_returnStatus     => l_retStatus);
602         if(fnd_api.to_boolean(l_endDebug)) then
603           wip_logger.cleanup(l_retStatus);
604         end if;
605       end if;
606     end validateInterfaceTxns;
607 
608 end wip_mtlTempProc_priv;