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