DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_CFMPROC_PRIV

Source


1 package body wip_cfmProc_priv as
2 /* $Header: wipcfmpb.pls 120.2 2010/11/18 12:13:29 sisankar ship $ */
3 
4   /**
5    * This procedure process a single flow/work orderless transaction.
6    */
7   procedure processTemp(p_initMsgList  in  varchar2,
8                         p_txnTempID    in  number,
9                         x_returnStatus out nocopy varchar2) is
10     processing_exception exception;
11     l_txnHeaderID number;
12     l_cplTxnID number;
13     l_kanbanCardID number := null;
14     l_qaCollectionID number := null;
15     l_wipEntityID number;
16     l_success number;
17     l_primaryQty number;
18     l_lpnID number;
19     l_params wip_logger.param_tbl_t;
20     l_returnStatus varchar2(1);
21     l_msgCount number;
22     l_msgData varchar2(2000);
23     l_logLevel NUMBER := fnd_log.g_current_runtime_level;
24     l_txnActionID number;
25   begin
26 
27     x_returnStatus := fnd_api.g_ret_sts_success;
28 
29     if (l_logLevel <= wip_constants.trace_logging) then
30       l_params(1).paramName := 'p_initMsgList';
31       l_params(1).paramValue := p_initMsgList;
32       l_params(2).paramName := 'p_txnTempID';
33       l_params(2).paramValue := p_txnTempID;
34       wip_logger.entryPoint(p_procName => 'wip_cfmProc_priv.processTemp',
35                             p_params => l_params,
36                             x_returnStatus => x_returnStatus);
37       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
38         raise fnd_api.g_exc_unexpected_error;
39       end if;
40     end if;
41 
42     if(fnd_api.to_boolean(p_initMsgList)) then
43       fnd_msg_pub.initialize;
44     end if;
45 
46     -- set a save point
47     savepoint wip_cfmproc_s0;
48 
49     select completion_transaction_id,
50            transaction_source_id,
51            kanban_card_id,
52            qa_collection_id,
53            primary_quantity,
54            transaction_header_id,
55            nvl(lpn_id, content_lpn_id),
56            transaction_action_id
57       into l_cplTxnID,
58            l_wipEntityID,
59            l_kanbanCardID,
60            l_qaCollectionID,
61            l_primaryQty,
62            l_txnHeaderID,
63            l_lpnID,
64            l_txnActionID
65       from mtl_material_transactions_temp
66      where transaction_temp_id = p_txnTempID;
67 
68 /*
69     -- Step 1:
70     -- For unscheduled work orderless completion, we should create an entry
71     -- in wip_flow_schedules and wip_entities since that is needed for resource
72     -- transactions and material transactions.
73 
74     wip_flowUtil_priv.createFlowSchedule(p_txnTempID,
75                                          l_returnStatus);
76     if ( l_returnStatus <> fnd_api.g_ret_sts_success ) then
77       raise processing_exception;
78     end if;
79 */
80     -- Step 2:
81     -- Create reservation for the sales order
82     --if lpn completion, then sales order transfer is done at lpn the drop, not
83     --lpn completion time.
84     if(l_lpnID is null) then
85       /*Bug 5676680: Added one extra parameter p_txnTempID */
86       wip_so_reservations.complete_flow_sched_to_so(l_txnHeaderID,
87                                                     p_txnTempID,
88                                                     l_returnStatus,
89                                                     l_msgCount,
90                                                     l_msgData);
91       if ( l_returnStatus <> fnd_api.g_ret_sts_success ) then
92         fnd_message.set_name('FND', 'FND_GENERIC_MESSAGE');
93         fnd_message.set_token('MESSAGE', l_msgData);
94         fnd_msg_pub.add;
95         raise processing_exception;
96       end if;
97     end if;
98 
99     -- Step 3:
100     -- Explode the Routing and insert the resource and overhead charge
101     -- information into WCTI.
102     wip_flowResCharge.chargeResourceAndOverhead(p_txnTempID,
103                                                 l_returnStatus);
104     if ( l_returnStatus <> fnd_api.g_ret_sts_success ) then
105       raise processing_exception;
106     end if;
107 
108 
109     -- Step 4:
110     -- Update the flow schedule
111     wip_flowUtil_priv.updateFlowSchedule(p_txnTempID,
112                                          l_returnStatus);
113     if ( l_returnStatus <> fnd_api.g_ret_sts_success ) then
114       raise processing_exception;
115     end if;
116 
117 
118     -- Step 5:
119     -- Update the kanban card status to FULL
120     if ( l_kanbanCardID is not null and l_txnActionID  = wip_constants.cplassy_action) then
121       if (l_logLevel <= wip_constants.full_logging) then
122         wip_logger.log(p_msg => 'Calling inv_kanban_pvt.update_card_supply_status',
123                        x_returnStatus => l_returnStatus);
124       end if;
125 
126       inv_kanban_pvt.update_card_supply_status(
127         p_kanban_card_id     => l_kanbanCardID,
128         p_supply_status      => inv_kanban_pvt.g_supply_status_full,
129         p_document_type      => inv_kanban_pvt.g_doc_type_flow_schedule,
130         p_document_header_id => l_wipEntityID,
131         p_document_detail_id => null,
132         p_replenish_quantity => l_primaryQty,
133         x_return_status      => l_returnStatus);
134 
135       if (l_logLevel <= wip_constants.full_logging) then
136         wip_logger.log(p_msg => 'inv_kanban_pvt.update_card_supply_status returns ' ||
137                                 'with status ' || l_returnStatus,
138                        x_returnStatus => l_returnStatus);
139       end if;
140 
141       if ( l_returnStatus <> fnd_api.g_ret_sts_success ) then
142         raise processing_exception;
143       end if;
144     end if;
145 
146 
147     -- Step 6:
148     -- Enable the QA results
149     if ( l_qaCollectionID is not null ) then
150       if (l_logLevel <= wip_constants.full_logging) then
151         wip_logger.log(p_msg => 'Calling qa_result_grp.enable',
152                        x_returnStatus => l_returnStatus);
153       end if;
154 
155       qa_result_grp.enable(p_api_version => 1.0,
156                            p_init_msg_list => 'F',
157                            p_commit => 'F',
158                            p_validation_level => 0,
159                            p_collection_id => l_qaCollectionID,
160                            p_return_status => l_returnStatus,
161                            p_msg_count => l_msgCount,
162                            p_msg_data => l_msgData);
163 
164 
165       if ( l_returnStatus <> 'S' ) then
166         fnd_message.set_name('FND', 'FND_GENERIC_MESSAGE');
167         fnd_message.set_token('MESSAGE', l_msgData);
168         fnd_msg_pub.add;
169         if (l_logLevel <= wip_constants.full_logging) then
170           wip_logger.log(p_msg => 'qa_result_grp.enable returns return with error ' ||
171                                  l_msgData,
172                          x_returnStatus => l_returnStatus);
173         end if;
174         raise processing_exception;
175       end if;
176     end if;
177 
178     if (l_logLevel <= wip_constants.trace_logging) then
179       wip_logger.log(p_msg => 'qa_result_grp.enable returns ' ||
180                      'with status ' || l_returnStatus,
181                      x_returnStatus => l_returnStatus);
182     end if;
183 
184     if (l_logLevel <= wip_constants.trace_logging) then
185       wip_logger.exitPoint(p_procName => 'wip_cfmProc_priv.processTemp',
186                            p_procReturnStatus => x_returnStatus,
187                            p_msg => 'Request processed successfully!',
188                            x_returnStatus => l_returnStatus); --discard logging return status
189     end if;
190 
191   exception
192   when processing_exception then
193     x_returnStatus := fnd_api.g_ret_sts_error;
194     rollback to wip_cfmproc_s0;
195     wip_flowUtil_priv.setMmttError(p_txnTempID,
196                                    'Processing Error');
197     if (l_logLevel <= wip_constants.trace_logging) then
198       wip_logger.exitPoint(p_procName => 'wip_cfmProc_priv.processTemp',
199                            p_procReturnStatus => x_returnStatus,
200                            p_msg => 'Request failed!',
201                            x_returnStatus => l_returnStatus); --discard logging return status
202     end if;
203   when others then
204     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
205     rollback to wip_cfmproc_s0;
206     wip_flowUtil_priv.setMmttError(p_txnTempID,
207                                    'Unexpected Error');
208     if (l_logLevel <= wip_constants.trace_logging) then
209       wip_logger.exitPoint(p_procName => 'wip_cfmProc_priv.processTemp',
210                            p_procReturnStatus => x_returnStatus,
211                            p_msg => 'unexpected error: ' || SQLERRM,
212                            x_returnStatus => l_returnStatus); --discard logging return status
213     end if;
214   end processTemp;
215 
216 
217   /**
218    * This procedure processes a single flow/work orderless transaction inserted
219    * by the mobile application.
220    */
221   procedure processMobile(p_txnHdrID    in  number,
222                           p_txnTmpID    in number,
223                           p_processInv   in  varchar2,
224                           x_returnStatus out nocopy varchar2,
225                           x_errorMessage out nocopy varchar2) is
226     l_params wip_logger.param_tbl_t;
227     l_returnStatus varchar2(1);
228     l_txnHeaderID number;
229     l_cplTxnID number;
230     l_wipEntityID number;
231     l_logLevel NUMBER := to_number(fnd_log.g_current_runtime_level);
232   begin
233 
234     savepoint wip_cfmproc_s100;
235 
236     x_returnStatus := fnd_api.g_ret_sts_success;
237 
238     if (l_logLevel <= wip_constants.trace_logging) then
239       l_params(1).paramName := 'p_txnHdrID';
240       l_params(1).paramValue := p_txnHdrID;
241       l_params(2).paramName := 'p_txnTmpID';
242       l_params(2).paramValue := p_txnTmpID;
243       l_params(3).paramName := 'p_processInv';
244       l_params(3).paramValue := p_processInv;
245       wip_logger.entryPoint(p_procName => 'wip_cfmProc_priv.processMobile',
246                             p_params => l_params,
247                             x_returnStatus => x_returnStatus);
248       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
249         raise fnd_api.g_exc_unexpected_error;
250       end if;
251     end if;
252 
253     --need to create the flow schedule, this also updates component records
254     --so they have the proper transaction_source_id
255     if(fnd_api.to_boolean(p_processInv)) then
256        --create the flow schedule from MTI
257       wip_flowUtil_priv.createFlowSchedule(p_txnInterfaceID => p_txnTmpID,
258                                            x_returnStatus => x_returnStatus,
259                                            x_wipEntityID => l_wipEntityID);
260     else
261        --create the flow schedule from MMTT
262       wip_flowUtil_priv.createFlowSchedule(p_txnTmpID => p_txnTmpID,
263                                            x_returnStatus => x_returnStatus,
264                                            x_wipEntityID => l_wipEntityID);
265     end if;
266 
267     if(x_returnStatus = fnd_api.g_ret_sts_success) then
268        --move assy and component records to MMTT
269        wip_mtlTempProc_priv.validateInterfaceTxns(p_txnHdrID     => p_txnHdrID,
270                                                   p_initMsgList  => fnd_api.g_true,
271                                                   x_returnStatus => x_returnStatus);
272     end if;
273 
274     if(x_returnStatus = fnd_api.g_ret_sts_success) then
275       -- process the request
276       if(fnd_api.to_boolean(p_processInv)) then
277         wip_mtlTempProc_priv.processTemp(p_txnHdrID        => p_txnHdrID,
278                                          p_initMsgList     => fnd_api.g_true,
279                                          p_txnMode         => wip_constants.online,
280                                          p_destroyQtyTrees => fnd_api.g_true,
281                                          p_endDebug        => fnd_api.g_false,
282                                          x_returnStatus    => x_returnStatus,
283                                          x_errorMsg        => x_errorMessage);
284       else
285         --only do wip processing
286         wip_mtlTempProc_priv.processWIP(p_txnTmpID => p_txnTmpID,
287                                         p_processLpn => fnd_api.g_true,
288                                         x_returnStatus => x_returnStatus,
289                                         x_errorMsg => x_errorMessage);
290       end if;
291     end if;
292 
293     --if validateInterfaceTxns or processing errors...
294     if ( x_returnStatus <> fnd_api.g_ret_sts_success ) then
295       if(x_errorMessage is null) then
296         wip_utilities.get_message_stack(p_msg => x_errorMessage,
297                                         p_delete_stack => fnd_api.g_false);
298       end if;
299       if (l_logLevel <= wip_constants.trace_logging) then
300         wip_logger.exitPoint(p_procName => 'wip_cfmProc_priv.processMobile',
301                              p_procReturnStatus => x_returnStatus,
302                              p_msg => x_errorMessage,
303                              x_returnStatus => l_returnStatus); --discard logging return status
304         wip_logger.cleanUp(l_returnStatus);
305       end if;
306       return;
307     end if;
308 
309     if (l_logLevel <= wip_constants.trace_logging) then
310       wip_logger.exitPoint(p_procName => 'wip_cfmProc_priv.processMobile',
311                            p_procReturnStatus => x_returnStatus,
312                            p_msg => 'Finished processing successfully!',
313                            x_returnStatus => l_returnStatus); --discard logging return status
314       wip_logger.cleanUp(l_returnStatus);
315     end if;
316   end processMobile;
317 
318 
319 end wip_cfmProc_priv;