[Home] [Help]
PACKAGE BODY: APPS.WSMPLBMI
Source
1 PACKAGE BODY WSMPLBMI AS
2 /* $Header: WSMLBMIB.pls 120.97.12010000.2 2008/09/22 14:59:32 tbhande ship $ */
3
4 --mes
5 g_log_level_unexpected NUMBER := FND_LOG.LEVEL_UNEXPECTED ;
6 g_log_level_error number := FND_LOG.LEVEL_ERROR ;
7 g_log_level_exception number := FND_LOG.LEVEL_EXCEPTION ;
8 g_log_level_event number := FND_LOG.LEVEL_EVENT ;
9 g_log_level_procedure number := FND_LOG.LEVEL_PROCEDURE ;
10 g_log_level_statement number := FND_LOG.LEVEL_STATEMENT ;
11
12 g_msg_lvl_unexp_error NUMBER := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR ;
13 g_msg_lvl_error NUMBER := FND_MSG_PUB.G_MSG_LVL_ERROR ;
14 g_msg_lvl_success NUMBER := FND_MSG_PUB.G_MSG_LVL_SUCCESS ;
15 g_msg_lvl_debug_high NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH ;
16 g_msg_lvl_debug_medium NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM ;
17 g_msg_lvl_debug_low NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW ;
18
19 g_ret_success VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
20 g_ret_error VARCHAR2(1) := FND_API.G_RET_STS_ERROR;
21 g_ret_unexpected VARCHAR2(1) := FND_API.G_RET_STS_UNEXP_ERROR;
22 --mes end
23
24 /*-------------------------------------------------------------+
25 | CUSTOM_VALIDATION: |
26 ---------------------------------------------------------------*/
27
28 /* Project I : Jump_enh
29 This procedure assumes that it is a jump-from-queue transaction.
30 If there are no charges (material/resources/overheads) then
31 the jump should not consider the "from op" as completed and
32 no material/resource/overhead charges are applicable for the
33 'from op'.
34 This is a PRIVATE procedure */
35
36 Procedure val_jump_from_queue(p_wip_entity_id IN NUMBER,
37 p_org_id IN NUMBER,
38 p_fm_op_seq_num IN NUMBER,
39 p_wo_op_seq_id IN NUMBER,
40 x_return_code OUT NOCOPY NUMBER,
41 x_err_buf OUT NOCOPY VARCHAR2)
42 IS
43 l_charges_exist number;
44 l_manually_added_comp number;
45 l_issued_material number;
46 l_manually_added_resource number;
47 l_issued_resource number;
48 l_stmt_num number;
49
50 BEGIN
51 l_stmt_num := 10;
52 WSMPUTIL.check_charges_exist ( p_wip_entity_id,
53 p_org_id,
54 p_fm_op_seq_num,
55 p_wo_op_seq_id,
56 l_charges_exist,
57 l_manually_added_comp,
58 l_issued_material,
59 l_manually_added_resource,
60 l_issued_resource,
61 x_return_code,
62 x_err_buf);
63
64 /* The condition x_return_code <> 0 will be handled by the main WSMLBMIB
65 code */
66 If (x_return_code = 0) THEN
67 If l_debug = 'Y' Then
68 fnd_file.put_line(fnd_file.log, 'Returned success from check_charges_exist. l_charges_exist='||l_charges_exist);
69 End if;
70 if (l_charges_exist=1) then
71 if ((l_manually_added_resource = 1) or (l_issued_resource = 1)) then
72
73 fnd_message.set_name('WSM', 'WSM_MANUAL_CHARGES_EXIST');
74 fnd_message.set_token('ELEMENT', 'Resources');
75 x_err_buf := FND_MESSAGE.GET;
76 fnd_file.put_line(fnd_file.log, x_err_buf);
77 end if;
78
79 if (l_manually_added_comp = 2) then
80 FND_MESSAGE.Set_Name('WSM','WSM_PHANTOM_COMPONENTS_EXIST');
81 x_err_buf := FND_MESSAGE.GET;
82 fnd_file.put_line(fnd_file.log, x_err_buf);
83 end if;
84
85 if ((l_manually_added_comp = 1) or (l_issued_material = 1)) then
86 fnd_message.set_name('WSM', 'WSM_MANUAL_CHARGES_EXIST');
87 fnd_message.set_token('ELEMENT', 'Materials');
88 x_err_buf := FND_MESSAGE.GET;
89 fnd_file.put_line(fnd_file.log, x_err_buf);
90 end if;
91
92 end if;
93 end if;
94
95 EXCEPTION
96 WHEN OTHERS THEN
97 x_return_code := SQLCODE;
98 x_err_buf := 'WSMPLBMI.val_jump_from_queue' ||'(stmt_num='||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
99 fnd_file.put_line(fnd_file.log, x_err_buf);
100
101 END val_jump_from_queue;
102
103
104 FUNCTION custom_validation( p_header_id IN NUMBER,
105 p_txn_id IN NUMBER,
106 p_txn_qty IN NUMBER,
107 p_txn_date IN DATE,
108 p_txn_uom IN VARCHAR2,
109 p_primary_uom IN VARCHAR2,
110 p_txn_type IN NUMBER,
111 p_fm_op_seq_num IN OUT NOCOPY NUMBER,
112 p_fm_op_code IN VARCHAR2,
113 p_fm_intraop_step_type IN NUMBER,
114 p_to_op_seq_num IN NUMBER,
115 p_to_op_code IN VARCHAR2,
116 p_to_intraop_step_type IN NUMBER,
117 p_to_dept_id IN NUMBER,
118 p_wip_entity_name IN VARCHAR2,
119 p_org_id IN NUMBER,
120 p_jump_flag IN VARCHAR2,
121 -- ST : Serial Support Project --
122 x_serial_ctrl_code OUT NOCOPY NUMBER,
123 x_available_qty OUT NOCOPY NUMBER,
124 x_current_job_op_seq_num OUT NOCOPY NUMBER,
125 x_current_intraop_step OUT NOCOPY NUMBER,
126 x_current_rtg_op_seq_num OUT NOCOPY NUMBER,
127 x_old_scrap_transaction_id OUT NOCOPY NUMBER,
128 x_old_move_transaction_id OUT NOCOPY NUMBER,
129 -- ST : Serial Support Project --
130 x_err_buf OUT NOCOPY VARCHAR2,
131 x_undo_source_code OUT NOCOPY VARCHAR2
132 ) RETURN NUMBER IS
133
134 x_return_code NUMBER;
135 l_stmt_num NUMBER;
136 l_wip_entity_id NUMBER := 0;
137 l_entity_type NUMBER := 0;
138 l_status_type NUMBER := 0;
139 l_current_op_seq NUMBER := 0;
140 l_current_intraop_step NUMBER := 0;
141 l_std_operation_id NUMBER := 0;
142 l_intra_op_flag_value NUMBER := 0;
143 l_operation_qty NUMBER := 0;
144 l_converted_txn_qty NUMBER := 0;
145 l_uom VARCHAR2(5);
146 l_err_condition NUMBER := 0;
147 l_next_mand_step NUMBER := 0;
148 l_res_rows NUMBER := 0;
149 l_routing_seq_id NUMBER := 0;
150 l_retcode NUMBER := 0;
151 l_reason_id NUMBER := 0;
152 l_wlmti_wip_entity_id NUMBER := 0;
153 l_mtr_reason_name VARCHAR2(30);
154 l_reason_name VARCHAR2(30);
155 l_wlmti_org_code VARCHAR2(3);
156 l_org_code VARCHAR2(3);
157 l_wlmti_last_upd_by NUMBER := 0;
158 l_wlmti_last_upd_name VARCHAR2(100);
159 l_wlmti_created_by NUMBER := 0;
160 l_wlmti_created_by_name VARCHAR2(100);
161 l_user_name VARCHAR2(100);
162 l_wlmti_acct_period_id NUMBER := 0;
163
164 l_wo_op_seq_num NUMBER := 0;
165 l_wo_op_seq_id NUMBER := 0;
166 l_wo_std_op_id NUMBER := 0;
167 l_wo_dept_id NUMBER := 0;
168 l_wo_qty_scrap_step NUMBER := 0;
169 l_wo_qty_in_queue NUMBER := 0;
170 l_wo_qty_in_running NUMBER := 0;
171 l_wo_qty_in_tomove NUMBER := 0;
172 l_wo_qty_in_scrap NUMBER := 0;
173 l_wo_op_code VARCHAR2(4);
174 l_wo_qty_iop_step NUMBER := 0;
175 l_wo_qty NUMBER := 0;
176
177 l_end_op_seq_num NUMBER := 0;
178 l_end_op_code VARCHAR2(4);
179 l_end_op_seq_id NUMBER := 0;
180 l_end_std_op_id NUMBER := 0;
181 l_end_dept_id NUMBER := 0;
182
183 l_op_code VARCHAR2(4);
184 l_op_seq_id NUMBER := 0;
185 l_std_op_id NUMBER := 0;
186 l_dept_id NUMBER := 0;
187
188 l_jmp_op_code VARCHAR2(4);
189 l_jmp_op_seq_id NUMBER := 0;
190 l_jmp_std_op_id NUMBER := 0;
191 l_jmp_dept_id NUMBER := 0;
192
193 l_txn_type NUMBER := 0;
194 l_primary_item_id NUMBER := 0;
195 l_wlmti_primary_item_id NUMBER := 0;
196 l_bom_revision_date DATE;
197 l_rtg_revision_date DATE; --ADD: CZH.I_OED-1
198 l_alt_bom_desig VARCHAR2(10);
199 l_max_op_seq NUMBER := 0;
200 l_max_qty_op_seq_num NUMBER := 0;
201 l_max_txn_id NUMBER := 0;
202
203 l_cmp_primary_item_id NUMBER := 0;
204 l_cmp_subinv VARCHAR2(10);
205 l_cmp_loc_id NUMBER := 0;
206 --bug 4665604 OSFM-UT: OPMCONV: UNABLE TO RETURN A JOB WITH LENGTH 80 CHARS THRU INTERFACE
207 -- l_cmp_lot_number VARCHAR2(30);
208 l_cmp_lot_number VARCHAR2(240);
209 l_cmp_txn_qty NUMBER := 0;
210 l_cmp_fm_op_seq_num NUMBER := 0;
211 l_cmp_fm_op_code VARCHAR2(4);
212 l_cmp_fm_intra_op_step NUMBER := 0;
213 l_cmp_fm_dept_id NUMBER := 0;
214 l_cmp_to_op_seq_num NUMBER := 0;
215 l_cmp_to_op_code VARCHAR2(4);
216 l_cmp_to_dept_id NUMBER := 0;
217 l_onhand_qty NUMBER := 0;
218 l_kanban_card_id NUMBER := ''; --abbKanban
219 x_warning_mesg VARCHAR2(2000); --abbKanban
220 l_returnStatus VARCHAR2(1) := ''; --abbKanban
221 l_cur_supply_status NUMBER := ''; --abbKanban
222
223 l_fm_op_seq_num NUMBER := 0;
224 l_fm_op_code VARCHAR2(4);
225 l_fm_intraop_step NUMBER := 0;
226 l_fm_dept_id NUMBER := 0;
227 l_to_op_seq_num NUMBER := 0;
228 l_to_op_code VARCHAR2(4);
229 l_to_intraop_step NUMBER := 0;
230 l_to_dept_id NUMBER := 0;
231
232 l_txn_id NUMBER := 0;
233 l_wmt_txn_qty NUMBER := 0;
234 --bug 5349187 initialize l_wmt_scrap_acct_id as -1 found a related issue when fixing bug 5349187
235 --initialization of l_wmt_scrap_acct_id to 0 causes nvl to consider it as not null causing problems
236 --since scrap_account_id gets stamped as 0
237 --l_wmt_scrap_acct_id NUMBER := 0;
238 l_wmt_scrap_acct_id NUMBER := -1;
239 l_wlmti_scrap_acct_id NUMBER := 0;
240 l_allow_bkw_move NUMBER := 0;
241 l_qty_completed NUMBER := 0;
242 l_primary_uom VARCHAR2(3);
243 l_est_scrap_acc NUMBER := 0; -- abb H
244 l_job_type NUMBER := 0; -- abb H
245 l_bom_reference_id NUMBER := 0; -- abb H
246
247 l_iop_move_out_rtg BOOLEAN := FALSE;
248 l_group_id NUMBER := 0;
249 l_temp NUMBER := 0;
250 l_fm_op_code_temp VARCHAR2(4); -- Fix for bug #2081442
251 l_wip_entity_name_temp VARCHAR2(240); -- Fix for bug #2095035
252 l_error_msg VARCHAR2(2000) := NULL; -- CZH.BUG2135538
253 l_scrap_account number;
254 l_est_scrap_abs_account number;
255 p_est_scrap_account number;
256 p_est_scrap_var_account number;
257 l_jump_from_queue boolean:=FALSE;
258 l_class_code varchar2(10);
259 l_err_code number;
260 l_err_msg varchar2(2000);
261 l_yes number:=1;
262 --move enh
263 --bug 3387642 default to 0
264 l_scrap_qty NUMBER := 0;
265 l_cmp_batch_id NUMBER;
266 --bug 3385113 default to 0
267 l_scrap_at_operation_flag NUMBER := 0;
268 l_recommended VARCHAR2(1) := 'N';
269 l_scrap_acc_id NUMBER;
270 --bug 3571019
271 l_from_scrap_id NUMBER;
272 l_to_scrap_id NUMBER;
273 --end bug 3571019
274 l_jmp_to_dept_code VARCHAR2(10);
275 l_wmt_scrap_qty NUMBER;
276 l_wmt_pri_scrap_qty NUMBER;
277 l_wmt_pri_txn_qty NUMBER;
278 --bug 3387642 default to 0
279 l_converted_scrap_qty NUMBER := 0;
280 l_wmt_scrap_at_op_flag NUMBER;
281 l_to_dept_code VARCHAR2(10);
282 l_new_op_txn_qty NUMBER;
283 l_bk_move_chk_qty NUMBER;
284 l_fm_op_bkflsh_flag NUMBER;
285 l_to_op_bkflsh_flag NUMBER;
286 --bug 3370199
287 l_wo_rtg_op_seq_num NUMBER;
288 --bug 3615826
289 l_scrap_txn_id NUMBER;
290 --end move enh
291 l_wmt_scrap_acc NUMBER;
292 --mes
293 l_source_code WSM_LOT_MOVE_TXN_INTERFACE.source_code%type;
294 -- Logging variables.....
295 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
296 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
297 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.custom_validations';
298 l_param_tbl WSM_Log_PVT.param_tbl_type;
299 l_return_status VARCHAR2(1);
300 l_msg_count number;
301 l_msg_data varchar2(4000);
302 --mes end
303 -- ST : Serial Support Project --
304 l_serial_ctrl_code NUMBER;
305 -- ST : Serial Support Project --
306 p_fm_op_seq_num_orig number; -- bug 5349187
307 BEGIN
308 x_return_code := 0;
309 x_err_buf := '';
310 l_stmt_num := 10;
311
312 if (l_debug = 'Y') then
313 fnd_file.put_line(fnd_file.log, 'g_aps_wps_profile '||g_aps_wps_profile);
314 fnd_file.put_line(fnd_file.log, '*******************Parameters to WSMPLBMI*******************');
315
316 fnd_file.put_line(fnd_file.log, 'p_header_id='||p_header_id||
317 ', p_txn_id='||p_txn_id||
318 ', p_wip_entity_name='||p_wip_entity_name||
319 ', p_txn_qty='||p_txn_qty||
320 ', p_txn_date='||p_txn_date||
321 ', p_txn_uom='||p_txn_uom||
322 ', p_primary_uom='||p_primary_uom||
323 ', p_txn_type='||p_txn_type||
324 ', p_fm_op_seq_num='||p_fm_op_seq_num||
325 ', p_fm_op_code='||p_fm_op_code||
326 ', p_fm_intraop_step_type='||p_fm_intraop_step_type||
327 ', p_to_op_seq_num='||p_to_op_seq_num||
328 ', p_to_op_code='||p_to_op_code||
329 ', p_to_intraop_step_type='||p_to_intraop_step_type||
330 ', p_to_dept_id='||p_to_dept_id||
331 ', p_org_id='||p_org_id||
332 ', p_jump_flag='||p_jump_flag );
333 fnd_file.put_line(fnd_file.log, '');
334
335 fnd_file.put_line(fnd_file.log, 'g_prev_org_id='||g_prev_org_id||
336 ', g_prev_org_code='||g_prev_org_code||
337 ', g_prev_cr_user_id='||g_prev_cr_user_id||
338 ', g_prev_cr_user_name='||g_prev_cr_user_name||
339 ', g_prev_upd_user_id='||g_prev_upd_user_id||
340 ', g_prev_upd_user_name='||g_prev_upd_user_name||
341 ', g_prev_op_seq_incr='||g_prev_op_seq_incr||
342 ', g_acct_period_id='||g_acct_period_id||
343 ', g_prev_txn_date='||g_prev_txn_date);
344 fnd_file.put_line(fnd_file.log, '');
345 end if;
346
347 --***VJ Added for Performance Upgrade***--
348 IF (p_txn_type < 1) OR (p_txn_type > 4) THEN
349 x_return_code := 1;
350
351 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
352 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_type');
353 x_err_buf := FND_MESSAGE.GET;
354
355 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
356 return(x_return_code);
357 END IF;
358
359 -- Changed p_txn_type to l_txn_type in this procedure
360 l_txn_type := p_txn_type;
361 --***VJ End Additions***--
362
363 --***VJ Added for Performance Upgrade***--
364 if (g_prev_org_id <> p_org_id) THEN
365 --g_prev_org_id := p_org_id; -- bugfix 2363469 : Reset the prev_org_id later
366 --***VJ End Additions***--
367
368 BEGIN
369 /*****************Bug 5051836*******************************
370 select organization_code
371 into l_org_code
372 from org_organization_definitions
373 where organization_id = p_org_id;
374 *****************Bug 5051836*******************************/
375
376 select organization_code
377 into l_org_code
378 from mtl_parameters
379 where organization_id = p_org_id;
380 EXCEPTION
381 when no_data_found then
382 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
383 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'Organization_id');
384 x_err_buf := FND_MESSAGE.GET;
385
386 fnd_file.put_line(fnd_file.log,
387 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
388 x_return_code := 1;
389 return(x_return_code);
390 END;
391
392 x_return_code := WSMPUTIL.CHECK_WSM_ORG (p_org_id, l_retcode, x_err_buf);
393
394 IF ( (x_return_code = 0) OR (l_retcode<>0) ) THEN
395 x_return_code := 1;
396
397 FND_MESSAGE.SET_NAME('WSM', 'WSM_NON_WSM_ORG');
398 x_err_buf := FND_MESSAGE.GET;
399
400 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
401
402 return(x_return_code);
403 END IF;
404
405 l_stmt_num := 20;
406 g_prev_org_code := l_org_code;
407
408 --***VJ: Start changes for removal of 9999***--
409 -- SELECT nvl(last_operation_seq_num, 9999), nvl(op_seq_num_increment, 10)
410 -- INTO g_prev_last_op, g_prev_op_seq_incr
411
412 SELECT nvl(op_seq_num_increment, 10),
413 allow_backward_move_flag,
414 charge_jump_from_queue
415 INTO g_prev_op_seq_incr,
416 g_allow_bkw_move,
417 g_param_jump_fm_q
418 FROM wsm_parameters
419 WHERE organization_id = p_org_id;
420 --***VJ: End changes for removal of 9999***--
421
422 --
423 -- bugfix 2363469 : as part of this fix, we realized that the acct_prd check was being performed
424 -- only when there is an organization change which is incorrect.
425 -- When the txn_date changes within the same orgn, we should get the acct_period.
426 --
427 END IF; -- end of org_id check : g_prev_org_id <> p_org_id
428
429
430 l_stmt_num := 25;
431 -- IF (trunc(nvl(p_txn_date, sysdate)) <> trunc(nvl(g_prev_txn_date, sysdate))) THEN
432 -- Start fix for bug #2081464
433 IF (p_org_id <> g_prev_org_id) -- bugfix 2363469 : added orgn_id condn
434 -- g_prev_org_id has already been initialized before.
435 --AND -- CHG: BUG2644080/2762011, whenever org_id is different, fetch acct_period_id
436 OR -- CHG: BUG2644080/2762011
437 ( (g_prev_txn_date IS NOT NULL AND trunc(nvl(p_txn_date, sysdate)) <> trunc(nvl(g_prev_txn_date, sysdate)))
438 OR
439 (g_prev_txn_date IS NULL) )
440 THEN
441 --End fix for bug #2081464
442 --bug 3126650 changed from SQL to the following procedure
443 /* SELECT MAX(ACCT_PERIOD_ID)
444 INTO g_acct_period_id
445 FROM ORG_ACCT_PERIODS
446 WHERE PERIOD_CLOSE_DATE IS NULL
447 AND ORGANIZATION_ID = p_org_id
448 AND TRUNC(NVL(p_txn_date,SYSDATE))
449 BETWEEN PERIOD_START_DATE and SCHEDULE_CLOSE_DATE;*/
450
451 g_acct_period_id := WSMPUTIL.GET_INV_ACCT_PERIOD(x_err_code => l_err_code,
452 x_err_msg => l_err_msg,
453 p_organization_id => p_org_id,
454 p_date => p_txn_date);
455
456 IF (l_err_code <> 0) THEN
457 x_return_code := 1;
458 FND_MESSAGE.SET_NAME('WSM', 'WSM_INFO_NOT_FOUND');
459 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'acct_period_id');
460 x_err_buf := FND_MESSAGE.GET;
461
462 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
463 return(x_return_code);
464 END IF;
465
466 l_stmt_num := 30;
467 g_prev_txn_date := trunc(nvl(p_txn_date, sysdate));
468 END IF;
469 g_prev_org_id := p_org_id; --2363469 :set the prev_org_id here;
470
471 l_stmt_num := 31;
472
473 -- Start fix for bug #2095035
474 IF (p_wip_entity_name IS NULL) THEN -- if the user has passed wip_entity_id and not wip_entity_name
475 SELECT wip_entity_id
476 INTO l_wip_entity_id
477 FROM wsm_lot_move_txn_interface
478 WHERE header_id = p_header_id;
479
480 IF (l_wip_entity_id IS NULL) THEN
481 x_return_code := 1;
482 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
483 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_name/wip_entity_id');
484 x_err_buf := FND_MESSAGE.GET;
485 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
486 return(x_return_code);
487 END IF;
488
489 l_stmt_num := 32;
490
491 BEGIN
492
493 SELECT wip_entity_name, entity_type
494 INTO l_wip_entity_name_temp, l_entity_type
495 FROM wip_entities
496 WHERE organization_id = p_org_id
497 AND wip_entity_id = l_wip_entity_id;
498
499 IF (l_entity_type <> 5) THEN
500 x_return_code := 1;
501
502 FND_MESSAGE.SET_NAME('WSM', 'WSM_NOT_WSM_LOT_JOB');
503 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entities');
504 x_err_buf := FND_MESSAGE.GET;
505
506 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
507 return(x_return_code);
508 END IF;
509
510 l_stmt_num := 33;
511
512 UPDATE wsm_lot_move_txn_interface
513 SET wip_entity_name = l_wip_entity_name_temp
514 WHERE header_id = p_header_id;
515
516 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
517 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_name');
518 x_err_buf := FND_MESSAGE.GET;
519
520 EXCEPTION
521 WHEN NO_DATA_FOUND THEN
522 x_return_code := 1;
523 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
524 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_id');
525 x_err_buf := FND_MESSAGE.GET;
526 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
527 return(x_return_code);
528
529 WHEN OTHERS THEN
530 x_return_code := SQLCODE;
531 x_err_buf := 'WSMPLBMI.custom_validation' ||'(stmt_num='||l_stmt_num||') : '||substrb(sqlerrm,1,1000);
532 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
533 return(x_return_code);
534 END;
535
536 ELSE -- if the user has passed wip_entity_name and not wip_entity_id
537 -- End fix for bug #2095035
538 --***VJ Changed for Performance Upgrade***--
539 BEGIN
540
541 l_stmt_num := 34;
542
543 SELECT wip_entity_id, entity_type
544 INTO l_wip_entity_id, l_entity_type
545 FROM wip_entities
546 WHERE organization_id = p_org_id
547 -- AND wip_entity_name = p_wip_entity_name;
548 AND wip_entity_name = NVL(p_wip_entity_name, l_wip_entity_name_temp); -- Fix for bug #2095035
549
550 IF (l_entity_type <> 5) THEN
551 x_return_code := 1;
552
553 FND_MESSAGE.SET_NAME('WSM', 'WSM_NOT_WSM_LOT_JOB');
554 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entities');
555 x_err_buf := FND_MESSAGE.GET;
556
557 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
558 return(x_return_code);
559 END IF;
560
561 EXCEPTION
562 WHEN NO_DATA_FOUND THEN
563 x_return_code := 1;
564 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
565 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_name');
566 x_err_buf := FND_MESSAGE.GET;
567 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
568 return(x_return_code);
569 END;
570 --***VJ End Changes***--
571 END IF; -- Fix for bug #2095035
572
573 --bug 3512105
574 l_stmt_num := 34;
575 IF ((g_aps_wps_profile = 'Y')
576 AND (WSMPUTIL.get_internal_copy_type(l_wip_entity_id)=3)) THEN
577 fnd_message.set_name(
578 application => 'WSM',
579 name => 'WSM_NO_VALID_COPY');
580 x_err_buf := FND_MESSAGE.GET;
581
582 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
583 return(x_return_code);
584 END IF;
585 --bug 3512105 end
586
587 l_stmt_num := 35;
588 --***VJ Added for Performance Upgrade***--
589 SELECT status_type, primary_item_id
590 INTO l_status_type, l_primary_item_id
591 FROM wip_discrete_jobs
592 WHERE wip_entity_id = l_wip_entity_id
593 AND organization_id = p_org_id;
594 --***VJ End Additions***--
595
596 l_stmt_num := 40.1;
597 -- Start Fix for bug #2094358
598 IF (l_status_type = 4) THEN -- completed job
599 --bugfix 1667427
600 --if calling the following procedure returns l_current_intraop_step as 5,
601 --then it is a completed scrap,
602
603 wsmpoprn.get_current_op(p_wip_entity_id => l_wip_entity_id,
604 p_current_op_seq => l_current_op_seq,
605 p_current_op_step => l_current_intraop_step,
606 p_next_mand_step => l_next_mand_step,
607 x_error_code => x_return_code,
608 x_error_msg => x_err_buf);
609
610 --NO CHECK FOR RETURN VALUES HERE....-VJ--
611 -- ST : This procedure returns NULL l_current_intraop_step in case of completed jobs and
612 -- and returns l_current_intraop_step = 5 in case of completed scrap (all qty scrapped)
613
614 l_stmt_num := 43;
615 if (l_current_intraop_step <> 5) then
616 x_return_code := 1;
617
618 FND_MESSAGE.SET_NAME('WSM', 'WSM_NOT_RELEASED_JOB');
619 FND_MESSAGE.SET_TOKEN('FLD_NAME', p_wip_entity_name);
620 x_err_buf := FND_MESSAGE.GET;
621
622 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
623 return(x_return_code);
624 end if;
625 --end bug fix 1667427
626
627 ELSIF (l_status_type <> 3) THEN -- not a released job
628 l_stmt_num := 46;
629 x_return_code := 1;
630
631 -- ST : Bug fix : 4454300 : Instead of the message WSM_NOT_RELEASED_JOB use a new message
632 -- for assembly return transaction
633 IF p_txn_type = 3 THEN
634 -- Assembly return txn
635 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_RET_JOB_STATUS');
636 FND_MESSAGE.SET_TOKEN('JOB', p_wip_entity_name);
637 ELSE
638 FND_MESSAGE.SET_NAME('WSM', 'WSM_NOT_RELEASED_JOB');
639 FND_MESSAGE.SET_TOKEN('FLD_NAME', p_wip_entity_name);
640 END IF;
641 -- ST : Bug fix : 4454300 : End
642
643 x_err_buf := FND_MESSAGE.GET;
644
645 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
646 return(x_return_code);
647 END IF;
648 -- End Fix for bug #2094358
649
650 l_stmt_num := 50;
651
652 -- Validate/Populate wip_entity_id
653 SELECT nvl(wip_entity_id, -1)
654 INTO l_wlmti_wip_entity_id
655 FROM wsm_lot_move_txn_interface
656 WHERE header_id = p_header_id
657 AND wip_entity_name = NVL(p_wip_entity_name, l_wip_entity_name_temp); -- Fix for bug #2095035
658
659 l_stmt_num := 55;
660 IF (l_wlmti_wip_entity_id = -1) THEN
661
662 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
663 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_id');
664 x_err_buf := FND_MESSAGE.GET;
665 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
666 -- CZH.BUG2135538
667 update wsm_lot_move_txn_interface
668 set wip_entity_id = l_wip_entity_id,
669 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
670 error = l_error_msg -- CZH.BUG2135538
671 where header_id = p_header_id;
672
673 l_stmt_num := 60;
674 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
675
676 ELSIF (l_wlmti_wip_entity_id <> l_wip_entity_id) THEN
677
678 x_return_code := 1;
679
680 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
681 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_id');
682 x_err_buf := FND_MESSAGE.GET;
683
684 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
685 return(x_return_code);
686
687 END IF;
688
689 -- BA: CZH.I_OED-1, get job routing revision date after l_wip_entity_id is available
690 SELECT nvl(routing_revision_date, SYSDATE)
691 INTO l_rtg_revision_date
692 FROM wip_discrete_jobs
693 WHERE wip_entity_id = l_wip_entity_id;
694 -- EA: CZH.I_OED-1
695 --mes added source_code
696 --move enh added l_scrap_at_operation_flag, l_scrap_qty
697 --bug 3387642 added nvl to scrap_quantity
698 --***VJ Added for Performance Upgrade***--
699 SELECT group_id,
700 entity_type,
701 nvl(primary_item_id, -1),
702 organization_code,
703 nvl(last_updated_by, -1),
704 last_updated_by_name,
705 nvl(created_by, -1),
706 created_by_name,
707 nvl(acct_period_id, -1),
708 nvl(reason_id, -1),
709 reason_name,
710 nvl(scrap_account_id, -1),
711 scrap_at_operation_flag,
712 -- scrap_quantity
713 nvl(scrap_quantity, 0),
714 source_code
715 INTO l_group_id,
716 l_entity_type,
717 l_wlmti_primary_item_id,
718 l_wlmti_org_code,
719 l_wlmti_last_upd_by,
720 l_wlmti_last_upd_name,
721 l_wlmti_created_by,
722 l_wlmti_created_by_name,
723 l_wlmti_acct_period_id,
724 l_reason_id,
725 l_reason_name,
726 l_wlmti_scrap_acct_id,
727 l_scrap_at_operation_flag,
728 l_scrap_qty,
729 l_source_code
730 FROM wsm_lot_move_txn_interface
731 WHERE wip_entity_id = l_wip_entity_id
732 AND header_id = p_header_id;
733 --***VJ End Additions***--
734
735 l_stmt_num := 65;
736 if (l_debug = 'Y') then
737 fnd_file.put_line(fnd_file.log, 'l_entity_type='||l_entity_type||
738 ', l_wlmti_primary_item_id='||l_wlmti_primary_item_id||
739 ', l_wlmti_org_code='||l_wlmti_org_code||
740 ', l_wlmti_last_upd_by='||l_wlmti_last_upd_by||
741 ', l_wlmti_last_upd_name='||l_wlmti_last_upd_name||
742 ', l_wlmti_created_by='||l_wlmti_created_by||
743 ', l_wlmti_created_by_name='||l_wlmti_created_by_name||
744 ', l_wlmti_acct_period_id='||l_wlmti_acct_period_id||
745 ', l_reason_id='||l_reason_id||
746 ', l_reason_name='||l_reason_name||
747 ', l_wlmti_scrap_acct_id='||l_wlmti_scrap_acct_id);
748 fnd_file.put_line(fnd_file.log, '');
749 end if;
750
751 IF (l_entity_type <> 5) THEN
752 x_return_code := 1;
753
754 FND_MESSAGE.SET_NAME('WSM', 'WSM_NOT_WSM_LOT_JOB');
755 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wsm_lot_move_txn_interface');
756 x_err_buf := FND_MESSAGE.GET;
757
758 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
759 return(x_return_code);
760 END IF;
761
762 l_stmt_num := 70;
763 IF (l_wlmti_primary_item_id = -1) THEN
764 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
765 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'primary_item_id');
766 x_err_buf := FND_MESSAGE.GET;
767 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
768 -- CZH.BUG2135538
769 update wsm_lot_move_txn_interface
770 set primary_item_id = l_primary_item_id,
771 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
772 error = l_error_msg -- CZH.BUG2135538
773 where header_id = p_header_id;
774
775 l_stmt_num := 75;
776 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
777 ELSIF (l_wlmti_primary_item_id <> l_primary_item_id) THEN
778 x_return_code := 1;
779
780 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
781 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'primary_item_id');
782 x_err_buf := FND_MESSAGE.GET;
783
784 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
785 return(x_return_code);
786 END IF;
787
788 IF (l_wlmti_org_code IS NULL) THEN
789 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
790 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'organization_code');
791 x_err_buf := FND_MESSAGE.GET;
792 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
793 -- CZH.BUG2135538
794 update wsm_lot_move_txn_interface
795 set organization_code = g_prev_org_code, --l_org_code,
796 --***VJ Changed for Performance Upgrade***--
797 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
798 error = l_error_msg -- CZH.BUG2135538
799 where header_id = p_header_id;
800 l_stmt_num := 80;
801 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
802
803 ELSIF (l_wlmti_org_code <> g_prev_org_code) THEN --***VJ Changed for Performance Upgrade***--
804 x_return_code := 1;
805
806 FND_MESSAGE.SET_NAME('WSM', 'WSM_ORG_ID-CODE_COMB_INVALID');
807 x_err_buf := FND_MESSAGE.GET;
808
809 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
810 return(x_return_code);
811 END IF;
812
813 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
814 l_msg_tokens.delete;
815 WSM_log_PVT.logMessage (
816 p_module_name => l_module,
817 p_msg_text => 'B4 IF (l_wlmti_last_upd_name IS NULL) '||
818 ';l_wlmti_last_upd_by '||
819 l_wlmti_last_upd_by||
820 ';g_prev_upd_user_id '||
821 g_prev_upd_user_id,
822 p_stmt_num => l_stmt_num,
823 p_msg_tokens => l_msg_tokens,
824 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
825 p_run_log_level => l_log_level
826 );
827 END IF;
828
829 --mes added following if condition
830 IF (nvl(l_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'jump oa page',
831 'move to next op oa page', 'undo oa page'))
832 THEN
833 l_stmt_num := 85;
834 --***VJ Added for Performance Upgrade***--
835 IF (l_wlmti_last_upd_by <> -1) OR (l_wlmti_last_upd_by <> g_prev_upd_user_id) THEN
836 BEGIN
837 select user_name
838 into l_user_name
839 from fnd_user
840 where user_id = l_wlmti_last_upd_by
841 and sysdate between START_DATE and NVL(END_DATE,SYSDATE+1);
842 --***VJ Added for Performance Upgrade***--
843 EXCEPTION
844 WHEN NO_DATA_FOUND THEN
845 x_return_code := 1;
846
847 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
848 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'last_updated_by');
849 x_err_buf := FND_MESSAGE.GET;
850
851 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
852 return(x_return_code);
853 END;
854
855 l_stmt_num := 90;
856 g_prev_upd_user_id := l_wlmti_last_upd_by;
857 g_prev_upd_user_name := l_user_name;
858 --***VJ End Additions***--
859
860 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
861 l_msg_tokens.delete;
862 WSM_log_PVT.logMessage (
863 p_module_name => l_module,
864 p_msg_text => 'B4 IF (l_wlmti_last_upd_name IS NULL) '||
865 ';l_wlmti_last_upd_name '||
866 l_wlmti_last_upd_name||
867 ';g_prev_upd_user_name '||
868 g_prev_upd_user_name,
869 p_stmt_num => l_stmt_num,
870 p_msg_tokens => l_msg_tokens,
871 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
872 p_run_log_level => l_log_level
873 );
874 END IF;
875 IF (l_wlmti_last_upd_name IS NULL) THEN
876 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
877 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'last_updated_by_name');
878 x_err_buf := FND_MESSAGE.GET;
879 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
880 -- CZH.BUG2135538
881 update wsm_lot_move_txn_interface
882 set last_updated_by_name = g_prev_upd_user_name, --l_user_name,
883 --***VJ Changed for Performance Upgrade***--
884 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
885 error = l_error_msg -- CZH.BUG2135538
886 where header_id = p_header_id;
887
888 l_stmt_num := 95;
889 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
890 ELSIF (l_wlmti_last_upd_name <> g_prev_upd_user_name) THEN
891 --***VJ Changed for Performance Upgrade***--
892 x_return_code := 1;
893
894 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
895 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'last_updated_by_name');
896 x_err_buf := FND_MESSAGE.GET;
897
898 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
899 return(x_return_code);
900 END IF;
901 END IF;
902
903 l_stmt_num := 100;
904 --***VJ Added for Performance Upgrade***--
905 IF (l_wlmti_created_by <> -1) OR (l_wlmti_created_by <> g_prev_cr_user_id) THEN
906 IF (l_wlmti_last_upd_by <> l_wlmti_created_by) THEN
907 BEGIN
908 select user_name
909 into l_user_name
910 from fnd_user
911 where user_id = l_wlmti_created_by
912 and sysdate BETWEEN START_DATE and NVL(END_DATE,SYSDATE+1);
913 --***VJ Added for Performance Upgrade***--
914 EXCEPTION
915 WHEN NO_DATA_FOUND THEN
916 x_return_code := 1;
917
918 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
919 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'created_by');
920 x_err_buf := FND_MESSAGE.GET;
921
922 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
923 ||l_stmt_num||'): '||x_err_buf);
924 return(x_return_code);
925 END;
926 END IF;
927
928 g_prev_cr_user_id := l_wlmti_created_by;
929 g_prev_cr_user_name := l_user_name;
930 --***VJ End Additions***--
931
932 l_stmt_num := 105;
933
934 IF (l_wlmti_created_by_name IS NULL) THEN
935 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
936 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'created_by_name');
937 x_err_buf := FND_MESSAGE.GET;
938 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
939 -- CZH.BUG2135538
940 update wsm_lot_move_txn_interface
941 set created_by_name = g_prev_cr_user_name, --l_user_name,
942 --***VJ Changed for Performance Upgrade***--
943 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
944 error = l_error_msg -- CZH.BUG2135538
945 where header_id = p_header_id;
946
947 l_stmt_num := 110;
948 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
949 ELSIF (l_wlmti_created_by_name <> g_prev_cr_user_name) THEN
950 --***VJ Changed for Performance Upgrade***--
951 x_return_code := 1;
952
953 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
954 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'created_by_name');
955 x_err_buf := FND_MESSAGE.GET;
956
957 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
958 return(x_return_code);
959 END IF;
960 END IF;
961 END IF; --IF (l_source_code NOT IN ('move in oa page',
962 if (l_debug = 'Y') then
963 fnd_file.put_line(fnd_file.log, 'g_prev_org_id='||g_prev_org_id||
964 ', g_prev_org_code='||g_prev_org_code||
965 ', g_prev_cr_user_id='||g_prev_cr_user_id||
966 ', g_prev_cr_user_name='||g_prev_cr_user_name||
967 ', g_prev_upd_user_id='||g_prev_upd_user_id||
968 ', g_prev_upd_user_name='||g_prev_upd_user_name||
969 --** VJ: Deleted for removal of 9999** ', g_prev_last_op='||g_prev_last_op||
970 ', g_prev_op_seq_incr='||g_prev_op_seq_incr||
971 ', g_acct_period_id='||g_acct_period_id||
972 ', g_prev_txn_date='||g_prev_txn_date);
973 fnd_file.put_line(fnd_file.log, '');
974 end if;
975
976
977 -- Validate acct_period_id
978 l_stmt_num := 115;
979 --bug 3126650 changed the if condition and commented out the sql inside. Inv API has been called
980 --before to get the acct_period_id into g_acct_period_id
981 IF (l_wlmti_acct_period_id <> -1) AND (l_wlmti_acct_period_id <> 0) AND
982 (l_wlmti_acct_period_id <> g_acct_period_id) THEN
983 --***VJ Changed for Performance Upgrade***--
984 /*** BEGIN
985 SELECT acct_period_id
986 INTO l_temp
987 FROM org_acct_periods
988 WHERE acct_period_id = l_wlmti_acct_period_id
989 -- begin bugfix 1631484: check if the acct period is open.
990 AND open_flag = 'Y'
991 AND organization_id = p_org_id
992 AND period_start_date <= p_txn_date;
993 -- end bugfix 1631484
994
995 EXCEPTION
996 WHEN NO_DATA_FOUND THEN
997 ***/
998 x_return_code := 1;
999
1000 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1001 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'acct_period_id');
1002 x_err_buf := FND_MESSAGE.GET;
1003
1004 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1005 return(x_return_code);
1006 -- END;
1007 --***VJ End Changes***--
1008 END IF;
1009
1010 l_stmt_num := 120;
1011
1012 -- Begin Fix for bug #1497882
1013 IF( l_reason_id <> -1) THEN
1014 BEGIN
1015 SELECT reason_name
1016 INTO l_mtr_reason_name
1017 FROM mtl_transaction_reasons
1018 where reason_id = l_reason_id;
1019 EXCEPTION
1020 WHEN NO_DATA_FOUND THEN
1021 x_return_code := 1;
1022
1023 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1024 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'reason_id');
1025 x_err_buf := FND_MESSAGE.GET;
1026
1027 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1028 return(x_return_code);
1029 END;
1030 END IF;
1031
1032 l_stmt_num := 125;
1033
1034 -- Validate/Populate reason_name
1035 --***VJ Added for Performance Upgrade***--
1036 IF (l_reason_name IS NULL) THEN
1037
1038 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
1039 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'reason_name');
1040 x_err_buf := FND_MESSAGE.GET;
1041 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
1042 -- CZH.BUG2135538
1043 update wsm_lot_move_txn_interface
1044 set reason_name = l_mtr_reason_name,
1045 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
1046 error = l_error_msg -- CZH.BUG2135538
1047 where header_id = p_header_id;
1048
1049 l_stmt_num := 130;
1050 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1051 --***VJ End Additions***--
1052 ELSIF (l_reason_name <> l_mtr_reason_name) THEN
1053 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
1054 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'reason_name');
1055 x_err_buf := FND_MESSAGE.GET;
1056 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
1057 -- CZH.BUG2135538
1058 update wsm_lot_move_txn_interface
1059 set reason_name = l_mtr_reason_name,
1060 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
1061 error = l_error_msg -- CZH.BUG2135538
1062 where header_id = p_header_id;
1063
1064 l_stmt_num := 135;
1065 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1066 END IF;
1067 -- END Fix for bug #1497882
1068
1069
1070 l_stmt_num := 140;
1071
1072 --bug 3453139 removed CHECK_WMTI, CHECK_WSMT
1073 /* l_res_rows := WSMPUTIL.CHECK_WMTI (l_wip_entity_id,
1074 NVL(p_wip_entity_name, l_wip_entity_name_temp), -- Fix for bug #2095035
1075 p_txn_date,
1076 x_return_code,
1077 x_err_buf,
1078 p_org_id); -- ADD: CZH
1079 IF ( (l_res_rows > 0) OR (x_return_code <> 0) ) THEN
1080 x_return_code := 1;
1081
1082 FND_MESSAGE.SET_NAME('WSM', 'WSM_PENDING_TXN');
1083 FND_MESSAGE.SET_TOKEN('TABLE', 'wip_move_txn_interface');
1084 x_err_buf := FND_MESSAGE.GET;
1085
1086 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1087 return(x_return_code);
1088 END IF;
1089
1090 l_stmt_num := 145;
1091
1092 l_res_rows := WSMPUTIL.CHECK_WSMT (l_wip_entity_id,
1093 NVL(p_wip_entity_name, l_wip_entity_name_temp), -- Fix for bug #2095035
1094 p_txn_id,
1095 p_txn_date,
1096 x_return_code,
1097 x_err_buf,
1098 p_org_id); -- ADD: CZH
1099
1100 IF ( (l_res_rows > 0) OR (x_return_code <> 0) ) THEN
1101 x_return_code := 1;
1102
1103 FND_MESSAGE.SET_NAME('WSM', 'WSM_PENDING_TXN');
1104 FND_MESSAGE.SET_TOKEN('TABLE', 'wsm_split_merge_transactions');
1105 x_err_buf := FND_MESSAGE.GET;
1106
1107 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1108
1109 return(x_return_code);
1110 END IF;
1111
1112 */
1113 --***VJ End Changes***--
1114
1115 l_stmt_num := 150;
1116
1117 --**VJ: Start Deletion for 9999 Removal **--
1118 --IF(p_fm_intraop_step_type = 3 AND p_fm_op_seq_num = g_prev_last_op) THEN
1119 --***VJ Changed for Performance Upgrade***--
1120 -- x_return_code := 1;
1121
1122 -- FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_MOVE_FM_LAST_OP');
1123 -- x_err_buf := FND_MESSAGE.GET;
1124
1125 -- fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1126 -- return(x_return_code);
1127 --END IF;
1128 --**VJ: End Deletion for 9999 Removal **--
1129
1130 l_stmt_num := 151;
1131 --***VJ Added for Performance Upgrade***--
1132 IF (p_jump_flag IS NOT NULL) AND (p_jump_flag <> 'Y') AND (p_jump_flag <> 'N') THEN
1133 x_return_code := 1;
1134
1135 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1136 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'jump_flag');
1137 x_err_buf := FND_MESSAGE.GET;
1138
1139 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1140 return(x_return_code);
1141 END IF;
1142 --***VJ End Additions***--
1143
1144 l_stmt_num := 153;
1145 -- bugfix 1765389
1146 -- Validation of p_primary_uom.
1147 -- If p_primary_uom in WLMTI is null, then populate it from mtl_system_items.
1148 -- ST : Serial Support Project ---
1149 -- Query up the serial number control code also in this existing query...
1150 SELECT msi.primary_uom_code,
1151 msi.serial_number_control_code
1152 INTO l_primary_uom,
1153 l_serial_ctrl_code
1154 FROM mtl_system_items msi,
1155 wip_discrete_jobs wdj
1156 WHERE wdj.wip_entity_id = l_wip_entity_id
1157 AND wdj.primary_item_id = msi.inventory_item_id
1158 AND msi.organization_id = wdj.organization_id;
1159
1160 x_serial_ctrl_code := l_serial_ctrl_code;
1161 -- ST : Serial Support Project ---
1162 l_stmt_num := 155;
1163
1164 IF (p_primary_uom IS NULL) THEN
1165 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
1166 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'p_primary_uom');
1167 x_err_buf := FND_MESSAGE.GET;
1168 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
1169 -- CZH.BUG2135538
1170 update wsm_lot_move_txn_interface
1171 set primary_uom = l_primary_uom,
1172 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
1173 error = l_error_msg -- CZH.BUG2135538
1174 where header_id = p_header_id;
1175
1176 l_stmt_num := 160;
1177 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1178 ELSE
1179 IF (p_primary_uom <> l_primary_uom) THEN
1180 x_return_code := 1;
1181
1182 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_PRI_UOM');
1183 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'primary_uom');
1184 x_err_buf := FND_MESSAGE.GET;
1185
1186 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1187 return(x_return_code);
1188 END IF;
1189 END IF;
1190 -- end fix for bug1765389
1191
1192 -- begin bugfix 1840372
1193 -- Check Shop Floor Status for this job.
1194 -- Do not allow move transaction if a shop floor status of "allow no move"
1195 -- is assigned to this wip entity at a particular operation.
1196
1197 l_stmt_num := 162;
1198 declare
1199 l_dummy number := 0;
1200 l_err_buf varchar2(2000); -- to display the complete error in the log file.
1201 begin
1202 select max(1)
1203 into l_dummy
1204 from wip_shop_floor_statuses ws,
1205 wip_shop_floor_status_codes wsc
1206 where wsc.organization_id = p_org_id
1207 and ws.organization_id = p_org_id
1208 and ws.wip_entity_id = l_wip_entity_id
1209 and ws.line_id is null
1210 and ws.operation_seq_num = p_fm_op_seq_num
1211 and ws.intraoperation_step_type = p_fm_intraop_step_type
1212 and ws.shop_floor_status_code = wsc.shop_floor_status_code
1213 and wsc.status_move_flag = 2
1214 and nvl(wsc.disable_date, sysdate + 1) > sysdate;
1215
1216 if l_dummy = 1 then
1217 x_return_code := 1;
1218 fnd_message.set_name(
1219 application => 'WIP',
1220 name => 'WIP_STATUS_NO_TXN1');
1221 l_err_buf := fnd_message.get;
1222 x_err_buf := substrb(l_err_buf,1,150);
1223
1224 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):');
1225 fnd_file.put_line(fnd_file.log, 'ERROR :' ||l_err_buf);
1226 return(x_return_code);
1227 end if;
1228 end;
1229
1230 -- Check for no move statuses in between operations.
1231 -- If the WIP parameter "Allow Moves Over No Move Shop Floor Statuses"
1232 -- is on (checked)..
1233 -- only moves from intraoperation steps that have 'no move' statuses are prohibited.
1234 -- If the parameter is not checked
1235 -- is off (not checked)..
1236 -- system checks all autocharge operations and TO MOVE, RUN, QUEUE intraoperation steps
1237 -- between the From and To operations and intraoperation steps for 'no move' statuses.
1238 -- The system also checks the statuses of intervening intraoperation steps at the
1239 -- From and To operations if those operations are direct charge. If a staus that can
1240 -- prevent moves is found, the move is disallowed. Direct charge operations between the
1241 -- From and To operations and statuses at Scrap and Reject intraoperation steps do not
1242 -- prevent moves.
1243
1244 l_stmt_num := 164;
1245 declare
1246 l_err_buf varchar2(2000); -- to display the complete error in the log file.
1247 l_override_no_move_no_skip number;
1248 begin
1249 select moves_over_no_move_statuses
1250 into l_override_no_move_no_skip
1251 from wip_parameters
1252 where organization_id = p_org_id;
1253
1254 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1255 l_msg_tokens.delete;
1256 WSM_log_PVT.logMessage (
1257 p_module_name => l_module,
1258 p_msg_text => 'Check for no move statuses'||
1259 ';p_fm_op_seq_num '||
1260 p_fm_op_seq_num||
1261 ';p_fm_intraop_step_type '||
1262 p_fm_intraop_step_type||
1263 ';p_to_op_seq_num '||
1264 p_to_op_seq_num||
1265 ';p_to_intraop_step_type '||
1266 p_to_intraop_step_type||
1267 ';l_override_no_move_no_skip '||
1268 l_override_no_move_no_skip
1269 ,
1270 p_stmt_num => l_stmt_num,
1271 p_msg_tokens => l_msg_tokens,
1272 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
1273 p_run_log_level => l_log_level
1274 );
1275 WSM_log_PVT.logMessage (
1276 p_module_name => l_module,
1277 p_msg_text => 'Value returned by WIP_SF_STATUS.COUNT_NO_MOVE_STATUSES '||
1278 WIP_SF_STATUS.COUNT_NO_MOVE_STATUSES(
1279 p_org_id, /* organization_id */
1280 l_wip_entity_id, /* wip_entity_id */
1281 null, /* line_id */ -- for discrete/LBJ, this should be null
1282 null, /* first_schedule_id */ -- for discrete/LBJ, this should be null
1283 p_fm_op_seq_num, /* fm_operation_seq_num */
1284 p_fm_intraop_step_type, /* fm_intraoperation_step_type */
1285 p_to_op_seq_num, /* to_operation_seq_num */
1286 p_to_intraop_step_type /* to_intraoperation_step_type */
1287 ),
1288 p_stmt_num => l_stmt_num,
1289 p_msg_tokens => l_msg_tokens,
1290 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
1291 p_run_log_level => l_log_level
1292 );
1293
1294 END IF;
1295
1296 if (p_fm_op_seq_num is NOT NULL and
1297 p_fm_intraop_step_type is NOT NULL and
1298 p_to_op_seq_num is NOT NULL and
1299 p_to_intraop_step_type is NOT NULL and
1300 l_override_no_move_no_skip = 2 and /* No */
1301 WIP_SF_STATUS.COUNT_NO_MOVE_STATUSES(
1302 p_org_id, /* organization_id */
1303 l_wip_entity_id, /* wip_entity_id */
1304 null, /* line_id */ -- for discrete/LBJ, this should be null
1305 null, /* first_schedule_id */ -- for discrete/LBJ, this should be null
1306 p_fm_op_seq_num, /* fm_operation_seq_num */
1307 p_fm_intraop_step_type, /* fm_intraoperation_step_type */
1308 p_to_op_seq_num, /* to_operation_seq_num */
1309 p_to_intraop_step_type /* to_intraoperation_step_type */
1310 ) > 0)
1311 then
1312 x_return_code := 1;
1313 fnd_message.set_name(
1314 application => 'WIP',
1315 name => 'WIP_NO_MOVE_SF_STATUS_BETWEEN');
1316 l_err_buf := fnd_message.get;
1317 x_err_buf := substrb(l_err_buf,1,150);
1318
1319 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):');
1320 fnd_file.put_line(fnd_file.log, 'ERROR :' ||l_err_buf);
1321 return(x_return_code);
1322 end if;
1323 end;
1324 -- end bugfix 1840372
1325
1326 -------------------------------------------------------------------------------------
1327 ---------------------------------MOVE AND COMPLETION---------------------------------
1328 -------------------------------------------------------------------------------------
1329
1330 IF (l_txn_type IN (1,2)) THEN -- only for forward moves and completions
1331 --***VJ Changed for Performance Upgrade***--
1332
1333 l_stmt_num := 165;
1334
1335 -- Allow forward moves in the open interface, Returns are not allowed
1336 IF ( (l_txn_type = 2) AND -- Move and Completion
1337 (p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) ) THEN
1338 x_return_code := 1;
1339
1340 FND_MESSAGE.SET_NAME('WSM', 'WSM_TXN_FOR_SCR');
1341 x_err_buf := FND_MESSAGE.GET;
1342
1343 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1344 return(x_return_code);
1345 END IF;
1346
1347 --***VJ Changed for Performance Upgrade***--
1348 BEGIN
1349 select max(OPERATION_SEQ_NUM)
1350 into l_max_qty_op_seq_num
1351 from wip_operations
1352 where organization_id = p_org_id
1353 and wip_entity_id = l_wip_entity_id
1354 and ((QUANTITY_IN_QUEUE > 0) or
1355 (QUANTITY_RUNNING > 0) or
1356 (QUANTITY_WAITING_TO_MOVE > 0) or
1357 (QUANTITY_SCRAPPED > 0));
1358
1359 EXCEPTION
1360 WHEN NO_DATA_FOUND THEN
1361 x_return_code := 1;
1362
1363 -- CZH: this should be an invalid LBJ
1364 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1365 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'from_operation_seq_num/code/intraoperation_step');
1366 x_err_buf := FND_MESSAGE.GET;
1367
1368 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1369
1370 return(x_return_code);
1371 END;
1372 --***VJ End Changes***--
1373
1374 l_stmt_num := 170;
1375
1376 -- Find out at which operation/intra-op step the quantity lies in WIP_OPERATIONS table
1377 --bug 3370199 added wsm_op_seq_num
1378 select operation_seq_num,
1379 operation_sequence_id,
1380 standard_operation_id,
1381 department_id,
1382 decode(sign(QUANTITY_IN_QUEUE),1,QUANTITY_IN_QUEUE,0),
1383 decode(sign(QUANTITY_RUNNING),1,QUANTITY_RUNNING,0),
1384 decode(sign(QUANTITY_WAITING_TO_MOVE),1,QUANTITY_WAITING_TO_MOVE,0),
1385 decode(sign(QUANTITY_SCRAPPED),1,QUANTITY_SCRAPPED,0),
1386 nvl(wsm_op_seq_num, -1)
1387 into l_wo_op_seq_num,
1388 l_wo_op_seq_id,
1389 l_wo_std_op_id,
1390 l_wo_dept_id,
1391 l_wo_qty_in_queue,
1392 l_wo_qty_in_running,
1393 l_wo_qty_in_tomove,
1394 l_wo_qty_in_scrap,
1395 l_wo_rtg_op_seq_num
1396 from wip_operations
1397 where organization_id = p_org_id
1398 and wip_entity_id = l_wip_entity_id
1399 and OPERATION_SEQ_NUM = l_max_qty_op_seq_num; --***VJ Changed for Performance Upgrade***--
1400
1401
1402 IF (l_wo_std_op_id IS NOT NULL) THEN
1403 SELECT operation_code
1404 INTO l_wo_op_code
1405 FROM bom_standard_operations
1406 WHERE standard_operation_id = l_wo_std_op_id;
1407 ELSE
1408 l_wo_op_code := NULL;
1409 END IF;
1410
1411 l_stmt_num := 175;
1412
1413 if(l_wo_qty_in_queue <> 0) then
1414 l_wo_qty_iop_step := 1;
1415 l_wo_qty := l_wo_qty_in_queue;
1416 elsif(l_wo_qty_in_running <> 0) then
1417 l_wo_qty_iop_step := 2;
1418 l_wo_qty := l_wo_qty_in_running;
1419 elsif(l_wo_qty_in_tomove <> 0) then
1420 l_wo_qty_iop_step := 3;
1421 l_wo_qty := l_wo_qty_in_tomove;
1422 elsif(l_wo_qty_in_scrap <> 0) then
1423 --This will be executed only if the entire qty is scrapped.
1424 --A future scrap is not allowed, and if there is a scrap in the current op
1425 --then the remaining qty would exist in either Q/R/TM.
1426 l_wo_qty_iop_step := 5;
1427 l_wo_qty := l_wo_qty_in_scrap;
1428 end if;
1429
1430 -- ST : Serial Support Project --
1431 -- l_wo_qty is the quantity available.. set it to the OUT parameter...
1432 -- l_wo_qty_iop_step is the current intraop step .. add to the OUT parameter..
1433 -- l_wo_op_seq_num is the current job op seq num
1434 -- l_wo_rtg_op_seq_num is the current rtg op seq num
1435 x_available_qty := l_wo_qty ;
1436 x_current_job_op_seq_num := l_wo_op_seq_num ;
1437 x_current_intraop_step := l_wo_qty_iop_step ;
1438 x_current_rtg_op_seq_num := l_wo_rtg_op_seq_num ;
1439 -- ST : Serial Support Project --
1440
1441 if (l_debug = 'Y') then
1442 fnd_file.put_line(fnd_file.log, 'p_fm_op_seq_num='||p_fm_op_seq_num||'l_wo_op_seq_num='||l_wo_op_seq_num);
1443 end if;
1444
1445 -- p_fm_op_seq_num must be l_wo_op_seq_num
1446 IF (p_fm_op_seq_num <> l_wo_op_seq_num) THEN
1447 x_return_code := 1;
1448
1449 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1450 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_op_seq_num');
1451 x_err_buf := FND_MESSAGE.GET;
1452
1453 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1454 return(x_return_code);
1455 END IF;
1456
1457 l_stmt_num := 176;
1458
1459 -- Check if p_fm_op_code is l_wo_op_code --NSO Modification by abedajna
1460 --IF (p_fm_op_code <> l_wo_op_code) THEN --because p_fm_op_code can be NULL now that we are allowing NSO
1461
1462 -- begin 2363380 : Modified the cryptic logic and made it more readable.
1463 -- (for old code, checkout the previous version)
1464 -- Logic here is that If p_fm_op_code (populated in interface table)
1465 -- is not equal to l_wo_op_code (that in wip_operations table, we need
1466 -- to error out. If they have left it blank, populate it.
1467 if (p_fm_op_code is null and l_wo_op_code is null) then
1468 null; -- do nothing
1469
1470 elsif (p_fm_op_code is not null and l_wo_op_code is null) then
1471 x_return_code := 1;
1472 fnd_message.set_name('WSM', 'WSM_INVALID_FIELD');
1473 fnd_message.set_token('FLD_NAME', 'fm_op_code');
1474 x_err_buf := fnd_message.get;
1475 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1476 return(x_return_code);
1477
1478 elsif (p_fm_op_code is null and l_wo_op_code is not null) then
1479 UPDATE wsm_lot_move_txn_interface
1480 SET fm_operation_code = l_wo_op_code
1481 WHERE header_id = p_header_id;
1482
1483 fnd_message.set_name('WSM', 'WSM_MODIFIED_FIELD');
1484 fnd_message.set_token('FLD_NAME', 'fm_operation_code');
1485 x_err_buf := fnd_message.get;
1486
1487 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1488
1489 -- henceforth, if p_fm_op_code is NULL, use l_fm_op_code_temp instead.
1490 l_fm_op_code_temp := l_wo_op_code;
1491
1492 elsif ((p_fm_op_code is not null and l_wo_op_code is not null) and (p_fm_op_code <> l_wo_op_code) ) then
1493 x_return_code := 1;
1494 fnd_message.set_name('WSM', 'WSM_INVALID_FIELD');
1495 fnd_message.set_token('FLD_NAME', 'fm_op_code');
1496 x_err_buf := fnd_message.get;
1497 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1498 return(x_return_code);
1499
1500 end if;
1501 -- end bugfix 2363380
1502
1503 -- Check if p_fm_intraop_step_type is l_wo_qty_iop_step
1504 IF (p_fm_intraop_step_type <> l_wo_qty_iop_step) THEN
1505 x_return_code := 1;
1506
1507 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1508 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_intraop_step_type');
1509 x_err_buf := FND_MESSAGE.GET;
1510
1511 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1512 return(x_return_code);
1513 END IF;
1514
1515 -- p_fm_intraop_step_type should not be Scrap
1516 IF ( (p_fm_intraop_step_type = WIP_CONSTANTS.SCRAP) AND
1517 (l_txn_type <> 4) ) THEN -- Added condition as a part of fix for bug #2083671
1518 x_return_code := 1;
1519
1520 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_MOVE_FM_SCRAP');
1521 x_err_buf := FND_MESSAGE.GET;
1522
1523 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1524 return(x_return_code);
1525 END IF;
1526
1527
1528 -- to take care of intra-op move for an operation which is outside routing..
1529 -- NSO Modification by abedajna
1530 -- CZH: if l_iop_move_out_rtg = TURE, we are corrently in outside rtg, and want to move to the same op
1531 --bugfix 2969238 added condition for move after update WLT case. op_seq_id is not null and was from original routing
1532 --so should be treated as outside routing.
1533
1534 IF ( (nvl(p_to_op_seq_num, -1) = -1) AND
1535 (l_wo_op_code = p_to_op_code) AND
1536 ((p_jump_flag = 'N') OR (p_jump_flag is NULL))) THEN
1537 --AND (l_wo_op_seq_id is null ) )
1538
1539 if (l_wo_op_seq_id is null ) then
1540 l_iop_move_out_rtg := TRUE;
1541
1542 else
1543 begin
1544 select 1
1545 into l_temp
1546 from bom_operation_sequences
1547 where operation_sequence_id = l_wo_op_seq_id
1548 and routing_sequence_id = l_routing_seq_id;
1549
1550 exception
1551 when NO_DATA_FOUND then
1552 l_iop_move_out_rtg := TRUE;
1553 -- assign this as null, since validation for outside routing below all assume op_seq_id is null.
1554 -- otherwise might get validation error.
1555 l_wo_op_seq_id := '';
1556
1557 when others then
1558 l_iop_move_out_rtg := FALSE;
1559 end;
1560 end if;
1561 --end fix 2969238
1562
1563 ELSE
1564 l_iop_move_out_rtg := FALSE;
1565 END IF;
1566
1567 /************************************************************************************************************************
1568 MOVE ENH g_aps_wps_profile='N'
1569 ***********************************************************************************************************************
1570 ************************************************************************************************************************/
1571 IF (g_aps_wps_profile='N') THEN
1572
1573 l_stmt_num := 180;
1574 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
1575 SET (FM_DEPARTMENT_ID,
1576 FM_DEPARTMENT_CODE) =
1577 (SELECT bd.department_id,
1578 bd.department_code
1579 FROM BOM_DEPARTMENTS bd
1580 WHERE bd.department_id = l_wo_dept_id)
1581 WHERE WLMTI.header_id = p_header_id;
1582
1583 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
1584 x_return_code := 1;
1585
1586 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1587 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wo_dept_id'); --bugfix 1587295: changed the token
1588 x_err_buf := FND_MESSAGE.GET;
1589
1590 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1591 return(x_return_code);
1592 ELSE
1593 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
1594 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_department_id/fm_department_code');
1595 x_err_buf := FND_MESSAGE.GET;
1596
1597 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1598 END IF;
1599
1600 l_stmt_num := 185;
1601 SELECT nvl(common_routing_sequence_id, routing_reference_id)
1602 INTO l_routing_seq_id
1603 FROM wip_discrete_jobs
1604 WHERE wip_entity_id = l_wip_entity_id;
1605
1606 l_stmt_num := 190;
1607 l_op_seq_id := NULL;
1608
1609 l_stmt_num := 195;
1610 WSMPUTIL.find_routing_end(l_routing_seq_id,
1611 l_rtg_revision_date, -- Add: CZH.I_OED-1, use rtg rev date
1612 l_end_op_seq_id,
1613 x_return_code,
1614 x_err_buf);
1615 IF (x_return_code <> 0) THEN
1616 FND_MESSAGE.SET_NAME('WSM', 'WSM_CANNOT_GET_RTG_END');
1617 x_err_buf := FND_MESSAGE.GET;
1618
1619 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1620 return(x_return_code);
1621 ELSE
1622 if (l_debug = 'Y') then
1623 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
1624 ||'): Returned success from WSMPUTIL.find_routing_end');
1625 end if;
1626 END IF;
1627
1628 -- BA: CZH.I_OED-2, should consider operation replacement, will never get NULL since x_return_code = 0
1629 l_end_op_seq_id := WSMPUTIL.replacement_op_seq_id(
1630 l_end_op_seq_id,
1631 l_rtg_revision_date);
1632 --NO CHECK FOR RETURN VALUES HERE....-VJ--
1633 -- EA: CZH.I_OED-2
1634
1635 ----------------------------------
1636 -- MOVE (NOT JUMP) TRANSACTIONS --
1637 ----------------------------------
1638
1639 IF (upper(nvl(p_jump_flag, 'N')) = 'N') THEN -- If Jump Flag is not set
1640
1641 -- NSO Modification by abedajna
1642 l_stmt_num := 200;
1643
1644 -- must specify p_to_op_seq_num if outside_routing is FALSE
1645 IF ( ( l_iop_move_out_rtg = FALSE ) AND (nvl(p_to_op_seq_num, -1) = -1) ) THEN
1646 -- CZH: l_iop_move_out_rtg = FALSE means this is NOT an intraop move @ an op outside routing.
1647 -- AND this is not a JUMP, hence, p_to_op_seq_num must be specified
1648
1649 x_return_code := 1;
1650 FND_MESSAGE.SET_NAME('WSM', 'WSM_NULL_FIELD');
1651 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'p_to_op_seq_num');
1652 x_err_buf := FND_MESSAGE.GET;
1653 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1654 return(x_return_code);
1655
1656 END IF;
1657
1658 -- *** (NSO Modification by abedajna) -- begin addition
1659 if ( l_iop_move_out_rtg = FALSE ) then
1660
1661 -- BA: CZH.I_OED-1, give warning message if there is no effective next operation
1662 l_stmt_num := 202;
1663
1664 IF(WSMPUTIL.effective_next_op_exists(
1665 p_organization_id => p_org_id,
1666 p_wip_entity_id => l_wip_entity_id,
1667 p_wo_op_seq_num => p_fm_op_seq_num,
1668 p_end_op_seq_id => l_end_op_seq_id, -- CZH.I_9999
1669 x_err_code => x_return_code,
1670 x_err_msg => x_err_buf) = 0)
1671 THEN
1672 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_EFFECTIVE_NEXT_OP');
1673 x_err_buf := FND_MESSAGE.GET;
1674 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
1675 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1676 END IF;
1677 -- EA: CZH.I_OED-1
1678
1679 --NO CHECK FOR RETURN VALUES HERE....-VJ--
1680
1681 -- CZH: Not intraop move @ outside routing, hence, p_to_op_seq_num is rtg op seq num
1682 --***VJ Changed for Performance Upgrade***--
1683 BEGIN
1684 SELECT operation_sequence_id,
1685 department_id,
1686 standard_operation_id
1687 INTO l_op_seq_id, -- CZH.I_OED-2: since select from BOS, replacement is already considered!
1688 l_dept_id,
1689 l_std_op_id
1690 FROM bom_operation_sequences
1691 WHERE operation_seq_num = p_to_op_seq_num
1692 AND routing_sequence_id = l_routing_seq_id
1693 -- BC: CZH.I_OED-1, use wdj.routing_revision_date instead of SYSDATE
1694 --and nvl(disable_date, sysdate+1) > sysdate
1695 --and nvl(effectivity_date, sysdate) <= sysdate;
1696 and nvl(disable_date, l_rtg_revision_date) >= l_rtg_revision_date
1697 and nvl(effectivity_date, l_rtg_revision_date) <= l_rtg_revision_date;
1698 -- EC: CZH.I_OED-1
1699
1700 EXCEPTION
1701 WHEN NO_DATA_FOUND THEN
1702 x_return_code := 1;
1703 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1704 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
1705 x_err_buf := FND_MESSAGE.GET;
1706 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1707 return(x_return_code);
1708 END;
1709 --***VJ End Changes***--
1710
1711 --bug 3463128 give a message if the current operation has been replaced and the user is trying a
1712 --intraop move
1713 IF ((l_wo_rtg_op_seq_num = p_to_op_seq_num) AND (l_wo_op_seq_id <> l_op_seq_id)) THEN
1714 x_return_code := 1;
1715 FND_MESSAGE.SET_NAME('WSM', 'WSM_MOVE_CURR_OP_REPLACED');
1716 x_err_buf := FND_MESSAGE.GET;
1717 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1718 return(x_return_code);
1719 END IF;
1720 --end bug 3463128
1721
1722 if (l_std_op_id is NOT NULL) then -- it is a std op
1723 l_stmt_num := 205;
1724 SELECT operation_code
1725 INTO l_op_code
1726 FROM bom_standard_operations
1727 WHERE NVL(operation_type, 1) = 1 -- Standard operation
1728 AND organization_id = p_org_id
1729 AND standard_operation_id = l_std_op_id;
1730 else -- it is a non-std op
1731 l_stmt_num := 210;
1732 l_op_code := '';
1733 end if;
1734
1735 if (l_debug = 'Y') then
1736 fnd_file.put_line(fnd_file.log, 'p_to_op_code='||p_to_op_code||'l_op_code='||l_op_code);
1737 end if;
1738
1739 if (p_to_op_code is NULL) AND (l_op_code is not NULL) then
1740 l_stmt_num := 215;
1741 update wsm_lot_move_txn_interface
1742 set to_operation_code = l_op_code
1743 where header_id = p_header_id;
1744 elsif nvl(l_op_code, '@@**') <> nvl(p_to_op_code, '@@**') then
1745 x_return_code := 1;
1746 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1747 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
1748 x_err_buf := FND_MESSAGE.GET;
1749 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1750 return(x_return_code);
1751 end if;
1752
1753 else -- l_iop_move_out_rtg = TURE, intraop move @ outside rtg
1754
1755 l_op_seq_id := NULL; -- CZH: !!!!
1756 l_to_op_seq_num := NULL; -- CZH: !!!!
1757
1758 if (p_to_op_code is null) then
1759 x_return_code := 1;
1760 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1761 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
1762 x_err_buf := FND_MESSAGE.GET;
1763 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1764 return(x_return_code);
1765 else
1766 -- BA: CZH.bug 2362225, because we use l_op_code later on
1767 l_op_code := p_to_op_code;
1768 -- EA: CZH.bug 2362225
1769 l_stmt_num := 220;
1770 begin
1771 select standard_operation_id,
1772 department_id
1773 into l_std_op_id,
1774 l_dept_id
1775 from bom_standard_operations
1776 where nvl(operation_type, 1) = 1
1777 and organization_id = p_org_id
1778 and operation_code = p_to_op_code;
1779 exception
1780 when no_data_found then
1781 x_return_code := 1;
1782 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1783 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
1784 x_err_buf := FND_MESSAGE.GET;
1785 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
1786 ||l_stmt_num||'): ' ||x_err_buf);
1787 return(x_return_code);
1788 end;
1789 end if;
1790
1791 end if; -- l_iop_move_out_rtg is TRUE
1792
1793 -- *** (NSO Modification by abedajna) -- end addition
1794
1795 l_stmt_num := 225;
1796 IF ( nvl(p_to_dept_id, -1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_dept_id) THEN -- Fix bug #1501376
1797 -- Bugfix 1587295: added nvl since p_to_dept_id could be null. If null, derive it.
1798 x_return_code := 1;
1799
1800 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1801 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
1802 x_err_buf := FND_MESSAGE.GET;
1803
1804 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1805 return(x_return_code);
1806 END IF;
1807
1808 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
1809 SET ( TO_DEPARTMENT_ID, -- Fix bug #1501376
1810 TO_DEPARTMENT_CODE )=
1811 (SELECT bd.department_id, -- Fix bug #1501376
1812 bd.department_code
1813 FROM BOM_DEPARTMENTS bd
1814 WHERE bd.department_id = l_dept_id) -- Fix bug #1501376
1815 WHERE WLMTI.header_id = p_header_id;
1816
1817 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
1818 -- x_return_code := SQLCODE;
1819 x_return_code := 1; -- Bugfix 1587295: we should return 1 instead of SQLCODE since
1820 -- even if the above update updates 0 records, sqlcode will be 0.
1821
1822 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1823 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'dept_id');
1824 x_err_buf := FND_MESSAGE.GET;
1825
1826 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1827 return(x_return_code);
1828 ELSE
1829 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
1830 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_department_id/to_department_code');
1831 x_err_buf := FND_MESSAGE.GET;
1832
1833 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1834 END IF;
1835
1836
1837 l_stmt_num := 230;
1838 -- Fix bug #1501376
1839 l_to_dept_id := l_dept_id; -- l_to_dept_id is a local variable for p_to_dept_id, if NULL
1840
1841
1842 -- NSO Modification by abedajna begin
1843
1844 if l_op_seq_id <> l_wo_op_seq_id then -- CZH: move from inside rtg to inside rtg, to a diff op
1845 l_stmt_num := 235;
1846 l_temp := 0;
1847
1848 -- Here we are just checking that a intra-routing move is really possible
1849 -- from the operation user specifies to the operation inside the routing
1850 -- he specifies. This means that the from and the to ops should be a record
1851 -- in BON. The following sql thus suffices. The view is more suitable for the form.
1852
1853 begin
1854 --BC: CZH.I_OED-1, this sql doesn't suffice because the operation can be disabled
1855 --select 1
1856 --into l_temp
1857 --from bom_operation_networks
1858 --where from_op_seq_id = l_wo_op_seq_id
1859 --and to_op_seq_id = l_op_seq_id
1860 --and nvl(disable_date, sysdate) >= sysdate
1861 --and nvl(effectivity_date, sysdate) <= sysdate;
1862
1863 -- BC: CZH.I_OED-2, should consider op replacement
1864 --select 1
1865 --into l_temp
1866 --from bom_operation_networks bon,
1867 -- bom_operation_sequences bos
1868 --where bon.from_op_seq_id = l_wo_op_seq_id
1869 --and bon.to_op_seq_id = l_op_seq_id
1870 --and bos.operation_sequence_id = l_op_seq_id
1871 --and nvl(bos.disable_date, l_rtg_revision_date) >= l_rtg_revision_date
1872 --and nvl(bos.effectivity_date, l_rtg_revision_date) <= l_rtg_revision_date
1873 --and nvl(bon.disable_date, l_rtg_revision_date) >= l_rtg_revision_date -- not used
1874 --and nvl(bon.effectivity_date, l_rtg_revision_date) <= l_rtg_revision_date; -- not used
1875
1876 select 1
1877 into l_temp
1878 from bom_operation_networks
1879 --where WSMPUTIL.replacement_op_seq_id (
1880 -- from_op_seq_id,
1881 -- l_rtg_revision_date) = l_wo_op_seq_id
1882 where from_op_seq_id IN (
1883 select bos.operation_sequence_id
1884 from bom_operation_sequences bos,
1885 bom_operation_sequences bos2
1886 where bos.operation_seq_num = bos2.operation_seq_num
1887 AND bos.routing_sequence_id = bos2.routing_sequence_id
1888 AND bos2.operation_sequence_id = l_wo_op_seq_id
1889 )
1890 and WSMPUTIL.replacement_op_seq_id (
1891 to_op_seq_id,
1892 l_rtg_revision_date) = l_op_seq_id;
1893 -- EC: CZH.I_OED-2
1894 -- EC: CZH.I_OED-1
1895 exception
1896 when others then
1897 x_return_code := 1;
1898 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1899 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num/to_op_code');
1900 x_err_buf := FND_MESSAGE.GET;
1901 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
1902 ||l_stmt_num||'): '||x_err_buf);
1903 return(x_return_code);
1904 end;
1905 elsif l_op_seq_id = l_wo_op_seq_id then -- CZH: move from inside rtg to inside rtg, to the same op
1906
1907 l_stmt_num := 240;
1908 if p_to_intraop_step_type <= l_wo_qty_iop_step then
1909 x_return_code := -1;
1910 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1911 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_intraop_step_type');
1912 x_err_buf := FND_MESSAGE.GET;
1913 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
1914 return(x_return_code);
1915 end if;
1916
1917 end if;
1918
1919 -- NSO Modification by abedajna end
1920
1921
1922 --------------------
1923 -- JUMP OPERATION --
1924 --------------------
1925
1926 ELSE -- A Jump Operation
1927
1928 l_stmt_num := 245;
1929 IF ( nvl(p_to_op_seq_num, -1) <> -1) THEN -- JUMP to inside routing
1930
1931 --***VJ Changed for Performance Upgrade***--
1932 BEGIN
1933 SELECT nvl(standard_operation_id, -1),
1934 nvl(department_id, -1),
1935 operation_sequence_id
1936 INTO l_jmp_std_op_id,
1937 l_jmp_dept_id,
1938 l_jmp_op_seq_id
1939 FROM bom_operation_sequences
1940 WHERE operation_seq_num = p_to_op_seq_num
1941 AND routing_sequence_id = l_routing_seq_id
1942 -- BC: CZH.I_OED-1, use wdj.routing_revision_date instead of SYSDATE
1943 --and nvl(disable_date, sysdate+1) >= sysdate
1944 --and nvl(effectivity_date, sysdate) <= sysdate;
1945 and nvl(disable_date, l_rtg_revision_date) >= l_rtg_revision_date
1946 and nvl(effectivity_date, l_rtg_revision_date) <= l_rtg_revision_date;
1947 -- EC: CZH.I_OED-1
1948
1949 EXCEPTION
1950 WHEN NO_DATA_FOUND THEN
1951 x_return_code := 1;
1952 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1953 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
1954 x_err_buf := FND_MESSAGE.GET;
1955 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1956 return(x_return_code);
1957
1958 WHEN TOO_MANY_ROWS THEN
1959 x_return_code := 1;
1960 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
1961 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
1962 x_err_buf := FND_MESSAGE.GET;
1963 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
1964 return(x_return_code);
1965
1966 END;
1967 --***VJ End Changes***--
1968
1969 l_stmt_num := 250;
1970
1971 IF (l_jmp_std_op_id <> -1) THEN -- a standard op
1972
1973 -- Get corresponding op_code from BOS/BSO
1974 SELECT operation_code
1975 INTO l_jmp_op_code
1976 FROM bom_standard_operations
1977 WHERE standard_operation_id = l_jmp_std_op_id
1978 AND organization_id = p_org_id;
1979
1980 l_stmt_num := 255;
1981 ELSE
1982 l_jmp_op_code := '';
1983 END IF;
1984
1985 l_std_op_id := l_jmp_std_op_id;
1986 l_dept_id := l_jmp_dept_id;
1987 l_op_code := l_jmp_op_code;
1988 l_op_seq_id := l_jmp_op_seq_id;
1989
1990 -- NSO Modification by abedajna: additions begin
1991 if (p_to_op_code is NULL) AND (l_jmp_op_code is not NULL) then
1992
1993 update wsm_lot_move_txn_interface
1994 set to_operation_code = l_jmp_op_code
1995 where header_id = p_header_id;
1996
1997 l_stmt_num := 260;
1998 elsif (p_to_op_code <> nvl(l_jmp_op_code, '@@**')) THEN
1999 x_return_code := 1;
2000
2001 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2002 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2003 x_err_buf := FND_MESSAGE.GET;
2004
2005 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2006 return(x_return_code);
2007 end if;
2008 -- NSO Modification by abedajna: additions end
2009
2010 IF ( nvl(p_to_dept_id, -1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_jmp_dept_id) THEN
2011 x_return_code := 1;
2012 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2013 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2014 x_err_buf := FND_MESSAGE.GET;
2015 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2016 return(x_return_code);
2017 END IF;
2018
2019 ELSE -- p_to_op_seq_num is NULL, i.e. jump to outside routing
2020
2021 IF (p_to_op_code IS NOT NULL) THEN -- Jumping to a std-op
2022
2023 l_stmt_num := 270;
2024 --***VJ Changed for Performance Upgrade***--
2025 BEGIN
2026 SELECT nvl(standard_operation_id, -1),
2027 nvl(department_id, -1)
2028 INTO l_jmp_std_op_id,
2029 l_jmp_dept_id
2030 FROM bom_standard_operations
2031 WHERE operation_code = p_to_op_code
2032 AND organization_id = p_org_id;
2033
2034 EXCEPTION
2035 WHEN NO_DATA_FOUND THEN
2036 x_return_code := 1;
2037
2038 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2039 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2040 x_err_buf := FND_MESSAGE.GET;
2041
2042 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
2043 ||l_stmt_num||'):'||x_err_buf);
2044 return(x_return_code);
2045 END;
2046 --***VJ End Changes***--
2047
2048 l_stmt_num := 275;
2049 l_std_op_id := l_jmp_std_op_id;
2050 l_dept_id := l_jmp_dept_id;
2051 l_op_code := p_to_op_code;
2052 l_op_seq_id := NULL;
2053
2054 IF (l_jmp_std_op_id = -1) OR (l_jmp_dept_id = -1) THEN
2055 x_return_code := 1;
2056
2057 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2058 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2059 x_err_buf := FND_MESSAGE.GET;
2060
2061 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
2062 ||l_stmt_num||'):'||x_err_buf);
2063 return(x_return_code);
2064 END IF;
2065
2066
2067 IF (nvl(p_to_dept_id,-1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_jmp_dept_id) THEN
2068 x_return_code := 1;
2069
2070 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2071 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2072 x_err_buf := FND_MESSAGE.GET;
2073
2074 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2075 return(x_return_code);
2076 END IF;
2077
2078 ELSE -- IF p_to_op_code IS NULL
2079
2080 --CZH: one cannot jump to a non-std op outside routing !!!!
2081 --Added to remove non-std-ops functionality.
2082 x_return_code := 1;
2083
2084 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2085 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2086 x_err_buf := FND_MESSAGE.GET;
2087
2088 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2089 return(x_return_code);
2090 --End additions
2091
2092 END IF; -- p_to_op_code IS NULL/NOT NULL
2093
2094 END IF; -- p_to_op_seq_num is NULL/NOT NULL
2095
2096 /* JUMP_ENH:
2097 If the parameter is set not to charge jump_from_queue operations
2098 and the txn's from intraoperation step is 'Queue' then check to see
2099 if it qualifies for a jump_from_queue transaction without incurring
2100 any charges. */
2101 if (g_param_jump_fm_q = 2 and
2102 p_fm_intraop_step_type=1) then
2103
2104 if (l_wo_qty_in_scrap <> 0 ) then
2105 fnd_message.set_name('WSM', 'WSM_SCRAP_EXISTS');
2106 x_err_buf := FND_MESSAGE.GET;
2107 fnd_file.put_line(fnd_file.log, x_err_buf);
2108 if (l_debug = 'Y') then
2109 fnd_file.put_line(fnd_file.log, 'Jump from Queue is set to FALSE');
2110 end if;
2111 else
2112 WSMPLBMI.val_jump_from_queue(l_wip_entity_id,
2113 p_org_id,
2114 p_fm_op_seq_num,
2115 l_wo_op_seq_id,
2116 x_return_code,
2117 x_err_buf);
2118
2119 if (x_return_code <> 0) then
2120 fnd_file.put_line(fnd_file.log,
2121 'After calling WSMPLBMI.val_jump_from_queue ' || x_err_buf);
2122 return(x_return_code);
2123 end if;
2124 l_jump_from_queue := TRUE;
2125 if (l_debug = 'Y') then
2126 fnd_file.put_line(fnd_file.log,
2127 'Jump from Queue is set to TRUE');
2128 end if;
2129 end if; /* scrap <> 0 */
2130 end if; /* g_param_jump_fm_q = 2 */
2131
2132 l_stmt_num := 280;
2133 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2134 SET ( TO_DEPARTMENT_ID, -- Fix bug #1501376
2135 TO_DEPARTMENT_CODE )=
2136 (SELECT bd.department_id, -- Fix bug #1501376
2137 bd.department_code
2138 FROM BOM_DEPARTMENTS bd
2139 WHERE bd.department_id = l_jmp_dept_id)
2140 WHERE WLMTI.header_id = p_header_id;
2141
2142 l_stmt_num := 285;
2143 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
2144 --x_return_code := SQLCODE;
2145 x_return_code := 1; -- Bugfix 1587295: Set it to 1. Setting to SQLCODE is incorrect
2146 -- since it will have a value of 0 in this case.
2147
2148 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2149 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2150 x_err_buf := FND_MESSAGE.GET;
2151
2152 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2153 return(x_return_code);
2154 ELSE
2155 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2156 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_department_id/to_department_code');
2157 x_err_buf := FND_MESSAGE.GET;
2158
2159 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2160 END IF;
2161
2162 -- Fix bug #1501376
2163 l_to_dept_id := l_jmp_dept_id; -- l_to_dept_id is a local variable for p_to_dept_id, if NULL
2164
2165 END IF; -- Check for Jumps
2166 -----------------------------------------------------------------------------------
2167 -- End of Jump
2168 -----------------------------------------------------------------------------------
2169 /***********************************************************************************************************************
2170 ************************************************************************************************************************
2171 MOVE ENH g_aps_wps_profile='Y'
2172 ***********************************************************************************************************************
2173 ************************************************************************************************************************/
2174 ELSE --(g_aps_wps_profile='Y')
2175
2176 l_stmt_num := 180;
2177
2178 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2179 SET (FM_DEPARTMENT_ID,
2180 FM_DEPARTMENT_CODE) =
2181 (SELECT WCO.department_id,
2182 WCO.department_code
2183 FROM WSM_COPY_OPERATIONS WCO
2184 WHERE WCO.wip_entity_id = l_wip_entity_id
2185 AND WCO.operation_sequence_id = l_op_seq_id)
2186 WHERE WLMTI.header_id = p_header_id;
2187
2188 IF ((SQL%ROWCOUNT > 0) OR (SQL%NOTFOUND)) THEN
2189 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2190 SET (FM_DEPARTMENT_ID,
2191 FM_DEPARTMENT_CODE) =
2192 (SELECT bd.department_id,
2193 bd.department_code
2194 FROM BOM_DEPARTMENTS bd
2195 WHERE bd.department_id = l_wo_dept_id)
2196 WHERE WLMTI.header_id = p_header_id;
2197 END IF;
2198
2199 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
2200 x_return_code := 1;
2201
2202 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2203 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wo_dept_id'); --bugfix 1587295: changed the token
2204 x_err_buf := FND_MESSAGE.GET;
2205
2206 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2207 return(x_return_code);
2208 ELSE
2209 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2210 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_department_id/fm_department_code');
2211 x_err_buf := FND_MESSAGE.GET;
2212
2213 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2214 END IF;
2215
2216 l_stmt_num := 190;
2217 BEGIN
2218 SELECT operation_sequence_id,
2219 standard_operation_id,
2220 department_id,
2221 operation_seq_num,
2222 standard_operation_code
2223 INTO l_end_op_seq_id,
2224 l_end_std_op_id,
2225 l_end_dept_id,
2226 l_end_op_seq_num,
2227 l_end_op_code
2228 FROM WSM_COPY_OPERATIONS WCO
2229 WHERE WCO.wip_entity_id=l_wip_entity_id
2230 AND WCO.network_start_end='E';
2231 EXCEPTION
2232 WHEN no_data_found THEN
2233 x_return_code := 1;
2234 FND_MESSAGE.SET_NAME('WSM', 'WSM_CANNOT_GET_RTG_END');
2235 x_err_buf := FND_MESSAGE.GET;
2236
2237 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2238 return(x_return_code);
2239 END;
2240 if (l_debug = 'Y') then
2241 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): l_end_op_seq_id '||l_end_op_seq_id||' l_end_std_op_id '||l_end_std_op_id||' l_end_dept_id '||l_end_dept_id||' l_end_op_seq_num '||l_end_op_seq_num);
2242 end if;
2243
2244 l_op_seq_id := NULL;
2245
2246 ----------------------------------
2247 -- MOVE (NOT JUMP) TRANSACTIONS --
2248 ----------------------------------
2249
2250 IF (upper(nvl(p_jump_flag, 'N')) = 'N') THEN -- If Jump Flag is not set
2251
2252 -- NSO Modification by abedajna
2253 l_stmt_num := 200;
2254
2255 -- must specify p_to_op_seq_num if outside_routing is FALSE
2256 IF ( ( l_iop_move_out_rtg = FALSE ) AND (nvl(p_to_op_seq_num, -1) = -1) ) THEN
2257 -- CZH: l_iop_move_out_rtg = FALSE means this is NOT an intraop move @ an op outside routing.
2258 -- AND this is not a JUMP, hence, p_to_op_seq_num must be specified
2259
2260 x_return_code := 1;
2261 FND_MESSAGE.SET_NAME('WSM', 'WSM_NULL_FIELD');
2262 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'p_to_op_seq_num');
2263 x_err_buf := FND_MESSAGE.GET;
2264 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2265 return(x_return_code);
2266
2267 END IF;
2268
2269 if ( l_iop_move_out_rtg = FALSE ) then
2270 BEGIN
2271 SELECT operation_sequence_id,
2272 department_id,
2273 department_code,
2274 standard_operation_id,
2275 standard_operation_code,
2276 nvl(WCO.recommended, 'N'),
2277 scrap_account,
2278 backflush_flag
2279 INTO l_op_seq_id,
2280 l_dept_id,
2281 l_to_dept_code,
2282 l_std_op_id,
2283 l_op_code,
2284 l_recommended,
2285 --bug 3571019 changed l_scrap_acc_id to l_to_scrap_id for clarity
2286 -- l_scrap_acc_id,
2287 l_to_scrap_id,
2288 l_to_op_bkflsh_flag
2289 FROM WSM_COPY_OPERATIONS WCO
2290 WHERE WCO.wip_entity_id=l_wip_entity_id
2291 AND WCO.operation_seq_num = p_to_op_seq_num;
2292 EXCEPTION
2293 WHEN no_data_found THEN
2294 x_return_code := 1;
2295 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2296 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
2297 x_err_buf := FND_MESSAGE.GET;
2298 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2299 return(x_return_code);
2300 END;
2301
2302 --bug 3463128 give a message if the current operation has been replaced and the user is trying a
2303 --intraop move
2304 IF ((l_wo_rtg_op_seq_num = p_to_op_seq_num) AND (l_wo_op_seq_id <> l_op_seq_id)) THEN
2305 x_return_code := 1;
2306 FND_MESSAGE.SET_NAME('WSM', 'WSM_MOVE_CURR_OP_REPLACED');
2307 x_err_buf := FND_MESSAGE.GET;
2308 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2309 return(x_return_code);
2310 END IF;
2311 --end bug 3463128
2312
2313 if (l_debug = 'Y') then
2314 fnd_file.put_line(fnd_file.log, 'p_to_op_code='||p_to_op_code||'l_op_code='||l_op_code);
2315 end if;
2316
2317 if (p_to_op_code is NULL) AND (l_op_code is not NULL) then
2318 l_stmt_num := 215;
2319 update wsm_lot_move_txn_interface
2320 set to_operation_code = l_op_code
2321 where header_id = p_header_id;
2322 elsif nvl(l_op_code, '@@**') <> nvl(p_to_op_code, '@@**') then
2323 x_return_code := 1;
2324 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2325 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2326 x_err_buf := FND_MESSAGE.GET;
2327 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2328 return(x_return_code);
2329 end if;
2330
2331 else -- l_iop_move_out_rtg = TURE, intraop move @ outside rtg
2332
2333 l_op_seq_id := NULL; -- CZH: !!!!
2334 l_to_op_seq_num := NULL; -- CZH: !!!!
2335
2336 if (p_to_op_code is null) then
2337 x_return_code := 1;
2338 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2339 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2340 x_err_buf := FND_MESSAGE.GET;
2341 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2342 return(x_return_code);
2343 else
2344 -- BA: CZH.bug 2362225, because we use l_op_code later on
2345 l_op_code := p_to_op_code;
2346 -- EA: CZH.bug 2362225
2347 l_stmt_num := 220;
2348 begin
2349 select standard_operation_id,
2350 department_id
2351 into l_std_op_id,
2352 l_dept_id
2353 from bom_standard_operations
2354 where nvl(operation_type, 1) = 1
2355 and organization_id = p_org_id
2356 and operation_code = p_to_op_code;
2357 exception
2358 when no_data_found then
2359 x_return_code := 1;
2360 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2361 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2362 x_err_buf := FND_MESSAGE.GET;
2363 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
2364 ||l_stmt_num||'): ' ||x_err_buf);
2365 return(x_return_code);
2366 end;
2367 end if;
2368
2369 end if; -- l_iop_move_out_rtg is TRUE
2370
2371 -- *** (NSO Modification by abedajna) -- end addition
2372
2373 l_stmt_num := 225;
2374 IF ( nvl(p_to_dept_id, -1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_dept_id) THEN -- Fix bug #1501376
2375 -- Bugfix 1587295: added nvl since p_to_dept_id could be null. If null, derive it.
2376 x_return_code := 1;
2377
2378 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2379 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2380 x_err_buf := FND_MESSAGE.GET;
2381
2382 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2383 return(x_return_code);
2384 END IF;
2385
2386 --move enh
2387 IF (l_to_dept_code IS NULL) THEN
2388 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2389 SET ( TO_DEPARTMENT_ID, -- Fix bug #1501376
2390 TO_DEPARTMENT_CODE )=
2391 (SELECT bd.department_id, -- Fix bug #1501376
2392 bd.department_code
2393 FROM BOM_DEPARTMENTS bd
2394 WHERE bd.department_id = l_dept_id) -- Fix bug #1501376
2395 WHERE WLMTI.header_id = p_header_id
2396 RETURNING TO_DEPARTMENT_CODE
2397 INTO l_to_dept_code;
2398
2399 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
2400 -- x_return_code := SQLCODE;
2401 x_return_code := 1; -- Bugfix 1587295: we should return 1 instead of SQLCODE since
2402 -- even if the above update updates 0 records, sqlcode will be 0.
2403
2404 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2405 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'dept_id');
2406 x_err_buf := FND_MESSAGE.GET;
2407
2408 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2409 return(x_return_code);
2410 ELSE
2411 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2412 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_department_id/to_department_code');
2413 x_err_buf := FND_MESSAGE.GET;
2414
2415 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2416 END IF;
2417 ELSE --(l_to_dept_code IS NOT NULL)
2418 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2419 SET TO_DEPARTMENT_CODE=l_to_dept_code
2420 WHERE WLMTI.header_id = p_header_id;
2421 END IF;
2422
2423
2424 l_stmt_num := 230;
2425 -- Fix bug #1501376
2426 l_to_dept_id := l_dept_id; -- l_to_dept_id is a local variable for p_to_dept_id, if NULL
2427
2428 if l_op_seq_id <> l_wo_op_seq_id then -- CZH: move from inside rtg to i nside rtg, to a diff op
2429 l_stmt_num := 235;
2430 l_temp := 0;
2431
2432 --move enh? indices on op seq num
2433 --bug 3370199 introduced the if block after this SQL
2434 BEGIN
2435 SELECT 1
2436 INTO l_temp
2437 FROM WSM_COPY_OP_NETWORKS WCON
2438 WHERE WCON.wip_entity_id=l_wip_entity_id
2439 AND WCON.from_op_seq_id=l_wo_op_seq_id
2440 AND WCON.to_op_seq_num=p_to_op_seq_num;
2441 EXCEPTION
2442 WHEN others THEN
2443 l_temp := 0;
2444 END;
2445
2446 IF (l_temp = 0) THEN
2447 BEGIN
2448 SELECT 1
2449 INTO l_temp
2450 FROM WSM_COPY_OP_NETWORKS WCON
2451 WHERE WCON.wip_entity_id=l_wip_entity_id
2452 AND WCON.from_op_seq_num = l_wo_rtg_op_seq_num
2453 AND WCON.to_op_seq_num=p_to_op_seq_num;
2454
2455 exception
2456 when others then
2457 x_return_code := 1;
2458 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2459 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num/to_op_code');
2460 x_err_buf := FND_MESSAGE.GET;
2461 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation( stmt_num=' ||l_stmt_num||'): '||x_err_buf);
2462 return(x_return_code);
2463 end;
2464 END IF;
2465
2466 ELSIF l_op_seq_id = l_wo_op_seq_id then -- CZH: move from inside rtg to inside rtg, to the same op
2467
2468 l_stmt_num := 240;
2469 if p_to_intraop_step_type <= l_wo_qty_iop_step then
2470 x_return_code := -1;
2471 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2472 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_intraop_step_type');
2473 x_err_buf := FND_MESSAGE.GET;
2474 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2475 return(x_return_code);
2476 end if;
2477
2478 end if;
2479
2480 -- NSO Modification by abedajna end
2481
2482 --------------------
2483 -- JUMP OPERATION --
2484 --------------------
2485
2486 ELSE -- A Jump Operation
2487
2488 l_stmt_num := 245;
2489 IF ( nvl(p_to_op_seq_num, -1) <> -1) THEN -- JUMP to inside routing
2490 BEGIN
2491 SELECT operation_sequence_id,
2492 department_id,
2493 department_code,
2494 standard_operation_id,
2495 standard_operation_code,
2496 nvl(WCO.recommended, 'N'),
2497 scrap_account,
2498 backflush_flag
2499 INTO l_jmp_op_seq_id,
2500 l_jmp_dept_id,
2501 l_jmp_to_dept_code,
2502 l_jmp_std_op_id,
2503 l_jmp_op_code,
2504 l_recommended,
2505 --bug 3571019 changed l_scrap_acc_id to l_to_scrap_id for clarity
2506 -- l_scrap_acc_id,
2507 l_to_scrap_id,
2508 l_to_op_bkflsh_flag
2509 FROM WSM_COPY_OPERATIONS WCO
2510 WHERE WCO.wip_entity_id=l_wip_entity_id
2511 AND WCO.operation_seq_num = p_to_op_seq_num;
2512 EXCEPTION
2513 WHEN no_data_found THEN
2514 x_return_code := 1;
2515 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2516 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
2517 x_err_buf := FND_MESSAGE.GET;
2518 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2519 return(x_return_code);
2520
2521 WHEN TOO_MANY_ROWS THEN
2522 x_return_code := 1;
2523 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2524 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num');
2525 x_err_buf := FND_MESSAGE.GET;
2526 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2527 return(x_return_code);
2528 END;
2529
2530 l_std_op_id := l_jmp_std_op_id;
2531 l_dept_id := l_jmp_dept_id;
2532 l_op_code := l_jmp_op_code;
2533 l_op_seq_id := l_jmp_op_seq_id;
2534 l_to_dept_code :=l_jmp_to_dept_code;
2535
2536 -- NSO Modification by abedajna: additions begin
2537 if (p_to_op_code is NULL) AND (l_jmp_op_code is not NULL) then
2538
2539 update wsm_lot_move_txn_interface
2540 set to_operation_code = l_jmp_op_code
2541 where header_id = p_header_id;
2542
2543 l_stmt_num := 260;
2544 elsif (p_to_op_code <> nvl(l_jmp_op_code, '@@**')) THEN
2545 x_return_code := 1;
2546
2547 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2548 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2549 x_err_buf := FND_MESSAGE.GET;
2550
2551 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2552 return(x_return_code);
2553 end if;
2554 -- NSO Modification by abedajna: additions end
2555
2556 IF ( nvl(p_to_dept_id, -1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_jmp_dept_id) THEN
2557 x_return_code := 1;
2558 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2559 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2560 x_err_buf := FND_MESSAGE.GET;
2561 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2562 return(x_return_code);
2563 END IF;
2564
2565 ELSE -- p_to_op_seq_num is NULL, i.e. jump to outside routing
2566
2567 IF (p_to_op_code IS NOT NULL) THEN -- Jumping to a std-op
2568
2569 l_stmt_num := 270;
2570 --***VJ Changed for Performance Upgrade***--
2571 BEGIN
2572 SELECT nvl(standard_operation_id, -1),
2573 nvl(department_id, -1)
2574 INTO l_jmp_std_op_id,
2575 l_jmp_dept_id
2576 FROM bom_standard_operations
2577 WHERE operation_code = p_to_op_code
2578 AND organization_id = p_org_id;
2579
2580 EXCEPTION
2581 WHEN NO_DATA_FOUND THEN
2582 x_return_code := 1;
2583
2584 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2585 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2586 x_err_buf := FND_MESSAGE.GET;
2587
2588 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
2589 ||l_stmt_num||'):'||x_err_buf);
2590 return(x_return_code);
2591 END;
2592 --***VJ End Changes***--
2593
2594 l_stmt_num := 275;
2595 l_std_op_id := l_jmp_std_op_id;
2596 l_dept_id := l_jmp_dept_id;
2597 l_op_code := p_to_op_code;
2598 l_op_seq_id := NULL;
2599
2600 IF (l_jmp_std_op_id = -1) OR (l_jmp_dept_id = -1) THEN
2601 x_return_code := 1;
2602
2603 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2604 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2605 x_err_buf := FND_MESSAGE.GET;
2606
2607 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
2608 ||l_stmt_num||'):'||x_err_buf);
2609 return(x_return_code);
2610 END IF;
2611
2612
2613 IF (nvl(p_to_dept_id,-1) <> -1) AND (nvl(p_to_dept_id,-1) <> l_jmp_dept_id) THEN
2614 x_return_code := 1;
2615
2616 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2617 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2618 x_err_buf := FND_MESSAGE.GET;
2619
2620 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2621 return(x_return_code);
2622 END IF;
2623
2624 ELSE -- IF p_to_op_code IS NULL
2625
2626 --CZH: one cannot jump to a non-std op outside routing !!!!
2627 --Added to remove non-std-ops functionality.
2628 x_return_code := 1;
2629
2630 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2631 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_code');
2632 x_err_buf := FND_MESSAGE.GET;
2633
2634 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2635 return(x_return_code);
2636 --End additions
2637
2638 END IF; -- p_to_op_code IS NULL/NOT NULL
2639
2640 END IF; -- p_to_op_seq_num is NULL/NOT NULL
2641 /* JUMP_ENH:
2642 If the parameter is set not to charge jump_from_queue operations
2643 and the txn's from intraoperation step is 'Queue' then check to see
2644 if it qualifies for a jump_from_queue transaction without incurring
2645 any charges. */
2646 if (g_param_jump_fm_q = 2 and
2647 p_fm_intraop_step_type=1) then
2648
2649 if (l_wo_qty_in_scrap <> 0 ) then
2650 fnd_message.set_name('WSM', 'WSM_SCRAP_EXISTS');
2651 x_err_buf := FND_MESSAGE.GET;
2652 fnd_file.put_line(fnd_file.log, x_err_buf);
2653 if (l_debug = 'Y') then
2654 fnd_file.put_line(fnd_file.log, 'Jump from Queue is set to FALSE');
2655 end if;
2656 else
2657 WSMPLBMI.val_jump_from_queue(l_wip_entity_id,
2658 p_org_id,
2659 p_fm_op_seq_num,
2660 l_wo_op_seq_id,
2661 x_return_code,
2662 x_err_buf);
2663
2664 if (x_return_code <> 0) then
2665 fnd_file.put_line(fnd_file.log,
2666 'After calling WSMPLBMI.val_jump_from_queue ' || x_err_buf);
2667 return(x_return_code);
2668 end if;
2669 l_jump_from_queue := TRUE;
2670 if (l_debug = 'Y') then
2671 fnd_file.put_line(fnd_file.log,
2672 'Jump from Queue is set to TRUE');
2673 end if;
2674 end if; /* scrap <> 0 */
2675 end if; /* g_param_jump_fm_q = 2 */
2676
2677 l_stmt_num := 280;
2678 IF (l_to_dept_code IS NULL) THEN
2679 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
2680 SET ( TO_DEPARTMENT_ID, -- Fix bug #1501376
2681 TO_DEPARTMENT_CODE )=
2682 (SELECT bd.department_id, -- Fix bug #1501376
2683 bd.department_code
2684 FROM BOM_DEPARTMENTS bd
2685 WHERE bd.department_id = l_jmp_dept_id)
2686 WHERE WLMTI.header_id = p_header_id
2687 RETURNING TO_DEPARTMENT_CODE
2688 INTO l_to_dept_code;
2689
2690 l_stmt_num := 285;
2691 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
2692 --x_return_code := SQLCODE;
2693 x_return_code := 1; -- Bugfix 1587295: Set it to 1. Setting to SQLCODE is incorrect
2694 -- since it will have a value of 0 in this case.
2695
2696 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2697 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id');
2698 x_err_buf := FND_MESSAGE.GET;
2699
2700 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2701 return(x_return_code);
2702 ELSE
2703 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2704 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_department_id/to_department_code');
2705 x_err_buf := FND_MESSAGE.GET;
2706
2707 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2708 END IF;
2709 END IF; --l_to_dept_code IS NULL
2710
2711 -- Fix bug #1501376
2712 l_to_dept_id := l_jmp_dept_id; -- l_to_dept_id is a local variable for p_to_dept_id, if NULL
2713
2714 END IF; -- Check for Jumps
2715 -----------------------------------------------------------------------------------
2716 -- End of Jump
2717 -----------------------------------------------------------------------------------
2718 END IF; --(g_aps_wps_profile='Y')
2719 /***********************************************
2720 MOVE ENH END g_aps_wps_profile='Y'
2721 ******************************************************/
2722 --move enh end
2723 --move enh move and scrap
2724
2725 IF (l_scrap_qty < 0) THEN
2726 x_return_code := 1;
2727 -- FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2728 -- FND_MESSAGE.SET_TOKEN('FLD_NAME', 'SCRAP QUANTITY-CAP');
2729 /* fnd_message.set_name(
2730 application => 'WIP',
2731 name => 'WIP_GREATER_THAN');
2732 fnd_message.set_token(
2733 token => 'ENTITY1',
2734 value => 'SCRAP QUANTITY-CAP',
2735 translate => TRUE);
2736 fnd_message.set_token(
2737 token => 'ENTITY2',
2738 value => 'zero',
2739 translate => TRUE); */
2740 FND_MESSAGE.SET_NAME('WSM', 'WSM_SCRAP_NOT_LESS_THAN_ZERO');
2741 x_err_buf := FND_MESSAGE.GET;
2742 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2743 return(x_return_code);
2744 END IF;
2745
2746 IF (p_txn_qty < 0) THEN
2747 x_return_code := 1;
2748 -- FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2749 -- FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_quantity');
2750 fnd_message.set_name(
2751 application => 'WIP',
2752 name => 'WIP_GREATER_THAN');
2753 fnd_message.set_token(
2754 token => 'ENTITY1',
2755 value => 'TRANSACTION QUANTITY-CAP',
2756 translate => TRUE);
2757 fnd_message.set_token(
2758 token => 'ENTITY2',
2759 value => 'zero',
2760 translate => TRUE);
2761 x_err_buf := FND_MESSAGE.GET;
2762 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2763 return(x_return_code);
2764 END IF;
2765
2766 IF ((l_scrap_qty = 0) AND (p_txn_qty = 0)) THEN
2767 x_return_code := 1;
2768 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2769 --move enh? get the meaning of /
2770 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_quantity/transaction_quantity');
2771 x_err_buf := FND_MESSAGE.GET;
2772 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2773 return(x_return_code);
2774 END IF;
2775
2776 IF ((p_to_intraop_step_type = 5)) THEN
2777 IF ((l_scrap_qty > 0) AND (p_txn_qty > 0)) THEN
2778 x_return_code := 1;
2779 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2780 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_quantity/transaction_quantity');
2781 x_err_buf := FND_MESSAGE.GET;
2782 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2783 return(x_return_code);
2784
2785 END IF;
2786
2787 IF (l_scrap_at_operation_flag IS NOT NULL) THEN
2788 l_scrap_at_operation_flag := null;
2789 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2790 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_at_operation_flag');
2791 x_err_buf := FND_MESSAGE.GET;
2792
2793 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2794 END IF;
2795
2796 ELSIF (l_scrap_qty>0) THEN
2797 --bug 3385113 added nvls
2798 IF ((nvl(p_jump_flag, 'N')='Y') OR (nvl(l_wo_op_seq_id, -1) <> nvl(l_op_seq_id, -1))) THEN
2799
2800 IF (nvl(l_scrap_at_operation_flag, -1) NOT IN (1, 2)) THEN
2801 x_return_code := 1;
2802 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2803 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_at_operation_flag');
2804 x_err_buf := FND_MESSAGE.GET;
2805 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2806 return(x_return_code);
2807 END IF;
2808 ELSE
2809 IF (nvl(l_scrap_at_operation_flag, -1) <> 1) THEN
2810 l_scrap_at_operation_flag := null;
2811 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
2812 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_at_operation_flag');
2813 x_err_buf := FND_MESSAGE.GET;
2814
2815 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
2816 END IF;
2817 END IF;
2818 END IF;
2819
2820 --bug 3385113 added nvls
2821 -- IF ((p_jump_flag='Y') AND ((l_scrap_qty>0) AND (l_scrap_at_operation_flag=1)) AND (g_param_jump_fm_q = 2)) THEN
2822 IF ((nvl(p_jump_flag,'N')='Y') AND ((l_scrap_qty>0) AND (nvl(l_scrap_at_operation_flag, -1)=1))
2823 AND (g_param_jump_fm_q = 2)) THEN
2824 x_return_code := 1;
2825 FND_MESSAGE.SET_NAME('WSM', 'WSM_SCRAP_AT_TO_ONLY');
2826 x_err_buf := FND_MESSAGE.GET;
2827 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2828 return(x_return_code);
2829 END IF;
2830
2831 -- p_to_intraop_step_type should not be > 5 -- NSO Modification by abedajna
2832 IF ((p_to_intraop_step_type > 5) OR (p_to_intraop_step_type is NULL) OR
2833 (p_to_intraop_step_type = WIP_CONSTANTS.REJECT)) THEN
2834 x_return_code := 1;
2835
2836 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
2837 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_intraop_step_type');
2838 x_err_buf := FND_MESSAGE.GET;
2839
2840 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2841 return(x_return_code);
2842 END IF;
2843
2844 -- Cannot Scrap in a Future Op
2845 IF ( (p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) AND
2846 -- BC: CZH.bug2362225 need to consider NULL value
2847 --(l_wo_op_seq_id <> l_op_seq_id)
2848 ( nvl(l_wo_op_seq_id, -99) <> nvl(l_op_seq_id, -99)
2849 or -- ADD: CZH, jump will always add a new op, hence, cannot scrap
2850 upper(nvl(p_jump_flag, 'N')) <> 'N'
2851 )
2852 ) THEN
2853 -- EC: CZH.bug2362225
2854 x_return_code := 1;
2855
2856 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_FUTURE_SCR');
2857 x_err_buf := FND_MESSAGE.GET;
2858
2859 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2860 return(x_return_code);
2861 END IF;
2862
2863 --mes added following if condition
2864 IF (nvl(l_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'jump oa page',
2865 'move to next op oa page', 'undo oa page'))
2866 THEN
2867 -- Get the next mandatory step
2868 -- NSO Modification by abedajna begin
2869 -- we call this routine only if we are currently in a std op,
2870 -- since mandatory steps do not make sense for nso.
2871 l_stmt_num := 290;
2872 if l_wo_std_op_id is not null then
2873 WSMPOPRN.get_current_op(l_wip_entity_id,
2874 l_current_op_seq,
2875 l_current_intraop_step,
2876 l_next_mand_step,
2877 x_return_code,
2878 x_err_buf);
2879 IF (x_return_code <> 0) THEN
2880 FND_MESSAGE.SET_NAME('WSM', 'WSM_CANNOT_GET_NEXT_MAND_STEP');
2881 x_err_buf := FND_MESSAGE.GET;
2882 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2883 return(x_return_code);
2884 ELSE
2885 if (l_debug = 'Y') then
2886 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
2887 ||'): Returned success from WSMPOPRN.get_current_op');
2888 end if;
2889 END IF;
2890 else
2891 l_next_mand_step := null;
2892 end if;
2893
2894 if (l_debug = 'Y') then
2895 fnd_file.put_line(fnd_file.log, 'l_next_mand_step: '||l_next_mand_step);
2896 end if;
2897
2898 -- Cannot skip a mandatory intraop in the current op seq
2899 l_err_condition := 0;
2900
2901 IF (l_next_mand_step is not NULL) AND (l_next_mand_step > 0) THEN
2902 -- there is a mandatory intraop in the current op
2903
2904 -- CZH.DBG: WHAT IF l_wo_op_seq_id or l_op_seq_id IS NULL???
2905 IF (l_wo_op_seq_id <> l_op_seq_id) THEN -- Check if p_fm_op_seq_num = p_to_op_seq_num
2906 l_err_condition := 1;
2907 ELSE -- p_fm_op_seq_num = p_to_op_seq_num
2908 IF ( ( (p_to_intraop_step_type = WIP_CONSTANTS.SCRAP)
2909 OR
2910 ( (l_scrap_qty>0)
2911 AND
2912 --bug 3385113 add nvl
2913 (nvl(l_scrap_at_operation_flag, -1)=1)))
2914 AND
2915 ( (p_fm_intraop_step_type = WIP_CONSTANTS.QUEUE)
2916 AND
2917 (l_next_mand_step = WIP_CONSTANTS.RUN)
2918 )) THEN
2919
2920 l_err_condition := 1;
2921
2922 END IF;
2923 -- ELSE
2924 --move enh case 2100 added p_to_intraop_step_type <> WIP_CONSTANTS.SCRAP
2925 IF ((p_txn_qty > 0) AND (p_to_intraop_step_type <> WIP_CONSTANTS.SCRAP)
2926 AND (p_to_intraop_step_type > l_next_mand_step)) THEN
2927
2928 l_err_condition := 1;
2929
2930 END IF;
2931 END IF;
2932 ELSIF (l_next_mand_step is not NULL) THEN
2933 -- there is no mandatory intraop in the current op, for non-Jump moves
2934
2935 l_stmt_num := 295;
2936 IF (l_wo_op_seq_id <> l_op_seq_id) AND (l_op_code is not NULL) THEN
2937 -- Check if p_fm_op_seq_num = p_to_op_seq_num
2938 --move enh changed l_std_operation_id to l_std_op_id
2939 IF (l_std_op_id IS NULL) THEN
2940 SELECT standard_operation_id
2941 INTO l_std_op_id
2942 FROM bom_standard_operations
2943 WHERE operation_code = l_op_code
2944 AND organization_id = p_org_id;
2945
2946 END IF;
2947 l_std_operation_id := l_std_op_id;
2948
2949 l_stmt_num := 300;
2950
2951 l_intra_op_flag_value := WSMPOPRN.get_intra_operation_value
2952 (l_std_operation_id,
2953 x_return_code,
2954 x_err_buf);
2955 --move enh end
2956 IF (x_return_code <> 0) THEN
2957 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_INTRAOP_VALUE');
2958 x_err_buf := FND_MESSAGE.GET;
2959
2960 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2961 return(x_return_code);
2962 ELSE
2963 if (l_debug = 'Y') then
2964 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
2965 ||'): Returned success from WSMPOPRN.get_intra_operation_value');
2966 end if;
2967 END IF;
2968
2969 l_stmt_num := 305;
2970
2971 l_next_mand_step := WSMPOPRN.get_next_mandatory_step(0, l_intra_op_flag_value);
2972 -- l_next_mand_step is now the mandatory intra-op in p_to_op_seq_num
2973
2974 IF (l_next_mand_step > 0) THEN -- there is a mandatory intraop
2975 IF ((l_scrap_qty>0) AND (l_scrap_at_operation_flag=2) AND (l_next_mand_step IN (WIP_CONSTANTS.QUEUE,
2976 WIP_CONSTANTS.RUN))) THEN
2977 l_err_condition := 1;
2978 END IF;
2979 IF ((p_txn_qty > 0) AND (p_to_intraop_step_type > l_next_mand_step)) THEN
2980 l_err_condition := 1;
2981 END IF;
2982 END IF;
2983 END IF;
2984 END IF;
2985
2986 if (l_debug = 'Y') then
2987 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
2988 || ') l_err_condition: '||l_err_condition);
2989 end if;
2990
2991 IF (l_err_condition = 1) THEN
2992 l_err_condition := 0;
2993 x_return_code := 1;
2994
2995 FND_MESSAGE.SET_NAME('WSM', 'WSM_MAND_STEP');
2996 x_err_buf := FND_MESSAGE.GET;
2997
2998 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
2999 return(x_return_code);
3000 END IF;
3001 END IF; --IF (nvl(l_source_code, 'interface') NOT IN ('move in oa page'
3002
3003 IF (l_next_mand_step is NULL) then -- i.e. a nso
3004
3005 -- bugfix 4090905 added jump flag check, when user doing a same operation jump, which equivalent to rework
3006 -- it's not necessary to check the intro-op-step.
3007 if (l_wo_op_seq_id = l_op_seq_id) and (p_jump_flag <> 'Y') then -- i.e. intra op move
3008
3009 if (p_to_intraop_step_type <= p_fm_intraop_step_type) then
3010 x_return_code := 1;
3011 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3012 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_intraop_step_type/to_intraop_step_type');
3013 x_err_buf := FND_MESSAGE.GET;
3014 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3015 return(x_return_code);
3016 end if;
3017
3018 end if;
3019
3020 end if;
3021
3022 -- NSO Modification by abedajna end
3023
3024 l_operation_qty := l_wo_qty;
3025 if (l_debug = 'Y') then
3026 fnd_file.put_line(fnd_file.log, 'l_operation_qty='||l_operation_qty);
3027 end if;
3028
3029 -- Validate UOM and quantity
3030 l_stmt_num := 310;
3031 --move enh
3032 if (p_txn_qty>0) then
3033 l_converted_txn_qty := inv_convert.inv_um_convert(item_id => l_primary_item_id,
3034 precision => NULL,
3035 from_quantity => p_txn_qty,
3036 from_unit => p_txn_uom,
3037 to_unit => l_primary_uom,
3038 from_name => NULL,
3039 to_name => NULL);
3040 if (l_debug = 'Y') then
3041 fnd_file.put_line(fnd_file.log, 'l_converted_txn_qty='||l_converted_txn_qty);
3042 end if;
3043
3044 --bug 5496297 throw a message if api returns -99999 which means that no valid conversion exists
3045 if (l_converted_txn_qty = -99999) then
3046 x_return_code := 1;
3047 FND_MESSAGE.SET_NAME('INV', 'INV_INVALID_UOM_CONV');
3048 FND_MESSAGE.SET_TOKEN('VALUE1', p_txn_uom);
3049 FND_MESSAGE.SET_TOKEN('VALUE2', l_primary_uom);
3050 x_err_buf := FND_MESSAGE.GET;
3051 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3052 return(x_return_code);
3053 end if;
3054 --end bug 5496297
3055
3056 -- ST : Serial Support Project ---
3057 -- Validate the txn quantity and the converted qty here...
3058 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
3059 (
3060 -- ST : Demo issue Commenting out :floor(p_txn_qty) <> p_txn_qty OR
3061 floor(l_converted_txn_qty) <> l_converted_txn_qty
3062 )
3063 THEN
3064 x_return_code := 1;
3065 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
3066 x_err_buf := FND_MESSAGE.GET;
3067
3068 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3069 return(x_return_code);
3070
3071 END IF;
3072 -- ST : Serial Support Project ---
3073
3074 end if;
3075
3076
3077 if (l_scrap_qty>0) then
3078 l_converted_scrap_qty := inv_convert.inv_um_convert(item_id => l_primary_item_id,
3079 precision => NULL,
3080 from_quantity => l_scrap_qty,
3081 from_unit => p_txn_uom,
3082 to_unit => l_primary_uom,
3083 from_name => NULL,
3084 to_name => NULL);
3085 if (l_debug = 'Y') then
3086 fnd_file.put_line(fnd_file.log, 'l_converted_scrap_qty='||l_converted_scrap_qty);
3087 end if;
3088
3089 -- ST : Serial Support Project ---
3090 -- Validate the scrap quantity and the converted qty here...
3091 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
3092 (
3093 -- ST : Demo issue : Commenting out : floor(l_scrap_qty) <> l_scrap_qty OR
3094 floor(l_converted_scrap_qty) <> l_converted_scrap_qty
3095 )
3096 THEN
3097 x_return_code := 1;
3098 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
3099 x_err_buf := FND_MESSAGE.GET;
3100
3101 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3102 return(x_return_code);
3103
3104 END IF;
3105 -- ST : Serial Support Project ---
3106
3107 end if;
3108 IF (l_converted_txn_qty > l_operation_qty) THEN
3109 x_return_code := 1;
3110
3111 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3112 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_quantity');
3113 x_err_buf := FND_MESSAGE.GET;
3114
3115 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3116 return(x_return_code);
3117 END IF;
3118
3119 IF (l_converted_scrap_qty > l_operation_qty) THEN
3120 x_return_code := 1;
3121
3122 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3123 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_quantity');
3124 x_err_buf := FND_MESSAGE.GET;
3125
3126 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3127 return(x_return_code);
3128 END IF;
3129 --end move enh
3130
3131 l_stmt_num := 315;
3132 -- Must use entire operation qty as txn qty except for Scrap
3133 -- For Scrap txn qty must be <= operation qty
3134 --move enh added the condition OR (l_scrap_qty>0) to the if statement
3135 IF ((p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) OR (l_scrap_qty>0)) THEN
3136
3137 if (l_debug = 'Y') then
3138 fnd_file.put_line(fnd_file.log, 'IOP = SCRAP');
3139 end if;
3140
3141 -- abb H optional scap accounting begin
3142 /*******************************************************************************
3143 bug 3571019 rewriting the ESA validations for clarity
3144 l_est_scrap_acc := wsmputil.wsm_esa_enabled(l_wip_entity_id,
3145 x_return_code,
3146 x_err_buf);
3147
3148 IF (x_return_code <> 0) THEN
3149 return(x_return_code);
3150 END IF;
3151
3152 select job_type
3153 into l_job_type
3154 from wip_discrete_jobs
3155 where wip_entity_id = l_wip_entity_id;
3156
3157 if l_est_scrap_acc = 1 and l_job_type = 1 then
3158
3159 IF (l_wlmti_scrap_acct_id = -1) THEN
3160 -- get scrap_account from WCO
3161 -- if scrap_account is null then
3162 -- get scrap_account from BD
3163 -- end if
3164 bug 3571019 additionally we should try to get the scrap account from WCO for both the from op/to op
3165 and then try BD
3166 --bug 3571019 get the scrap account depending on the l_scrap_at_operation_flag
3167 --if intraop scrap or scrap at from or if l_scrap_acc_id is null
3168 -- IF (((p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) OR (nvl(l_scrap_at_operation_flag, 1)=1))
3169 -- OR (l_scrap_acc_id IS NULL)) THEN
3170 --move enh added the IF (l_scrap_acc_id IS NULL) condition
3171 -- IF (l_scrap_acc_id IS NULL) THEN
3172 -- SELECT nvl(scrap_account, -1)
3173 -- INTO l_wlmti_scrap_acct_id
3174 -- FROM BOM_DEPARTMENTS
3175 -- WHERE DEPARTMENT_ID=decode(l_scrap_at_operation_flag,
3176 -- 2, l_to_dept_id,
3177 -- l_wo_dept_id) --p_to_dept_id --Fixed bug #1928993
3178 -- WHERE DEPARTMENT_ID=l_to_dept_id --p_to_dept_id --Fixed bug #1928993
3179 -- AND ORGANIZATION_ID=p_org_id;
3180 -- ELSE
3181 -- l_wlmti_scrap_acct_id := l_scrap_acc_id;
3182 -- END IF;
3183
3184 --bug 3571019
3185 -- get scrap_account from WCO
3186 IF ((g_aps_wps_profile='Y') AND
3187 ((p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) OR (nvl(l_scrap_at_operation_flag, 1)=1)))
3188 THEN
3189 SELECT WCO.scrap_account
3190 INTO l_scrap_acc_id
3191 FROM WSM_COPY_OPERATIONS WCO
3192 WHERE WCO.wip_entity_id = l_wip_entity_id
3193 AND WCO.operation_seq_num = l_wo_rtg_op_seq_num;
3194 END IF;
3195
3196 IF l_scrap_acc_id IS NULL THEN
3197 -- get scrap_account from BD
3198 SELECT nvl(scrap_account, -1)
3199 INTO l_wlmti_scrap_acct_id
3200 FROM BOM_DEPARTMENTS
3201 WHERE DEPARTMENT_ID=decode(l_scrap_at_operation_flag,
3202 2, l_to_dept_id,
3203 l_wo_dept_id) --p_to_dept_id --Fixed bug #1928993
3204 AND ORGANIZATION_ID=p_org_id;
3205 ELSE
3206 l_wlmti_scrap_acct_id := l_scrap_acc_id;
3207 END IF;
3208 --end bug 3571019
3209 l_stmt_num := 320;
3210 IF (l_wlmti_scrap_acct_id <> -1) THEN
3211 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
3212 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3213 x_err_buf := FND_MESSAGE.GET;
3214 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
3215 -- CZH.BUG2135538
3216 update wsm_lot_move_txn_interface
3217 set scrap_account_id = l_wlmti_scrap_acct_id,
3218 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
3219 error = l_error_msg -- CZH.BUG2135538
3220 where header_id = p_header_id;
3221
3222 l_stmt_num := 325;
3223 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3224 ELSE
3225 x_return_code := 1;
3226 -- abb changed the message
3227 fnd_message.set_name('WSM','WSM_NO_SCRAP_ACC');
3228 fnd_message.set_token('DEPT_ID',to_char(l_to_dept_id));
3229 x_err_buf := FND_MESSAGE.GET;
3230 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3231 return(x_return_code);
3232 END IF;
3233 END IF;
3234
3235 --***VJ Added for Performance Upgrade***--
3236 --bug 3571019 added decode so that we get the scrap account depending on the l_scrap_at_operation_flag
3237 BEGIN
3238 SELECT bd.department_id
3239 INTO l_temp
3240 FROM gl_code_combinations gcc,
3241 bom_departments bd
3242 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id
3243 AND bd.scrap_account = l_wlmti_scrap_acct_id
3244 -- AND bd.department_id = l_dept_id;
3245 AND bd.department_id = decode(l_scrap_at_operation_flag,
3246 2, l_dept_id,
3247 l_wo_dept_id);
3248
3249 EXCEPTION
3250 WHEN NO_DATA_FOUND THEN
3251 x_return_code := 1;
3252
3253 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3254 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3255 x_err_buf := FND_MESSAGE.GET;
3256
3257 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||
3258 l_stmt_num||'): '||x_err_buf);
3259 return(x_return_code);
3260 END;
3261 --***VJ End Additions***--
3262
3263 elsif ((l_est_scrap_acc = 2 or l_job_type = 3) and l_wlmti_scrap_acct_id <> -1) then
3264
3265 BEGIN
3266
3267 SELECT code_combination_id
3268 INTO l_temp
3269 FROM gl_code_combinations gl
3270 WHERE gl.code_combination_id = l_wlmti_scrap_acct_id
3271 and gl.enabled_flag = 'Y'
3272 and gl.summary_flag = 'N'
3273 and NVL(gl.start_date_active, sysdate) <= sysdate
3274 and NVL(gl.end_date_active, sysdate) >= sysdate;
3275
3276 EXCEPTION
3277 WHEN NO_DATA_FOUND THEN
3278 x_return_code := 1;
3279 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3280 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3281 x_err_buf := FND_MESSAGE.GET;
3282 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='|| l_stmt_num||'): '||x_err_buf);
3283 return(x_return_code);
3284 END;
3285
3286 elsif ((l_est_scrap_acc = 2 or l_job_type = 3) and l_wlmti_scrap_acct_id = -1) then
3287
3288 l_wlmti_scrap_acct_id := '';
3289
3290 end if; -- org is scrap acc enabled.
3291 *******************************************************************************/
3292 l_est_scrap_acc := wsmputil.wsm_esa_enabled(l_wip_entity_id,
3293 x_return_code,
3294 x_err_buf);
3295
3296 IF (x_return_code <> 0) THEN
3297 return(x_return_code);
3298 END IF;
3299
3300 select job_type
3301 into l_job_type
3302 from wip_discrete_jobs
3303 where wip_entity_id = l_wip_entity_id;
3304
3305 if l_est_scrap_acc = 1 and l_job_type = 1 then
3306 IF (g_aps_wps_profile='Y') THEN
3307 IF (l_wlmti_scrap_acct_id = -1) THEN
3308
3309 IF ((p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) OR
3310 (nvl(l_scrap_at_operation_flag, 1)=1))
3311 THEN
3312 BEGIN
3313 SELECT WCO.scrap_account
3314 INTO l_from_scrap_id
3315 FROM WSM_COPY_OPERATIONS WCO
3316 WHERE WCO.wip_entity_id = l_wip_entity_id
3317 AND WCO.operation_seq_num = l_wo_rtg_op_seq_num;
3318 EXCEPTION
3319 WHEN no_data_found THEN
3320 fnd_file.put_line(fnd_file.log, 'in no data found after selecting from wco');
3321 END;
3322 END IF;
3323
3324 IF (((nvl(l_scrap_at_operation_flag, 1)=1) AND (l_from_scrap_id IS NULL)) OR
3325 ((nvl(l_scrap_at_operation_flag, 1)=2) AND (l_to_scrap_id IS NULL)))
3326 THEN
3327 SELECT nvl(scrap_account, -1)
3328 INTO l_wlmti_scrap_acct_id
3329 FROM BOM_DEPARTMENTS
3330 WHERE DEPARTMENT_ID=decode(l_scrap_at_operation_flag,
3331 2, l_to_dept_id,
3332 l_wo_dept_id)
3333 AND ORGANIZATION_ID=p_org_id;
3334 ELSE
3335 IF (nvl(l_scrap_at_operation_flag, 1) = 1) THEN
3336 l_wlmti_scrap_acct_id := l_from_scrap_id;
3337 ELSE
3338 l_wlmti_scrap_acct_id := l_to_scrap_id;
3339 END IF;
3340 END IF;
3341
3342 l_stmt_num := 320;
3343 IF (l_wlmti_scrap_acct_id <> -1) THEN
3344 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
3345 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3346 x_err_buf := FND_MESSAGE.GET;
3347 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
3348
3349 update wsm_lot_move_txn_interface
3350 set scrap_account_id = l_wlmti_scrap_acct_id,
3351 error = l_error_msg
3352 where header_id = p_header_id;
3353
3354 l_stmt_num := 325;
3355 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3356 ELSE
3357 x_return_code := 1;
3358 fnd_message.set_name('WSM','WSM_NO_SCRAP_ACC');
3359 IF (nvl(l_scrap_at_operation_flag, 1) = 1) THEN
3360 fnd_message.set_token('DEPT_ID',to_char(l_wo_dept_id));
3361 ELSE
3362 fnd_message.set_token('DEPT_ID',to_char(l_to_dept_id));
3363 END IF;
3364 x_err_buf := FND_MESSAGE.GET;
3365 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3366 return(x_return_code);
3367 END IF;
3368
3369 BEGIN
3370 SELECT gcc.code_combination_id
3371 INTO l_temp
3372 FROM gl_code_combinations gcc
3373 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id;
3374 EXCEPTION
3375 WHEN NO_DATA_FOUND THEN
3376 x_return_code := 1;
3377
3378 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3379 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3380 x_err_buf := FND_MESSAGE.GET;
3381
3382 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||
3383 l_stmt_num||'): '||x_err_buf);
3384 return(x_return_code);
3385 END;
3386 ELSE --(l_wlmti_scrap_acct_id <> -1)
3387 BEGIN
3388 --bug 4480248: If the current operation has been reached by jumping outside the routing then
3389 --record will not be there in WCO.
3390 IF (nvl(p_to_op_seq_num, -1) <> -1) THEN --regular move or jump inside rtg
3391 SELECT gcc.code_combination_id
3392 INTO l_temp
3393 FROM gl_code_combinations gcc,
3394 WSM_COPY_OPERATIONS WCO
3395 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id
3396 AND WCO.scrap_account = gcc.code_combination_id
3397 AND WCO.wip_entity_id = l_wip_entity_id
3398 AND WCO.operation_seq_num = decode(l_scrap_at_operation_flag,
3399 2, p_to_op_seq_num,
3400 l_wo_rtg_op_seq_num);
3401 ELSE --jump outside rtg
3402 SELECT gcc.code_combination_id
3403 INTO l_temp
3404 FROM gl_code_combinations gcc,
3405 bom_departments bd
3406 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id
3407 AND bd.scrap_account = gcc.code_combination_id
3408 AND bd.department_id = decode(l_scrap_at_operation_flag,
3409 2, l_dept_id,
3410 l_wo_dept_id);
3411 END IF;
3412 EXCEPTION
3413 WHEN NO_DATA_FOUND THEN
3414 x_return_code := 1;
3415
3416 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3417 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3418 x_err_buf := FND_MESSAGE.GET;
3419
3420 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||
3421 l_stmt_num||'): '||x_err_buf);
3422 return(x_return_code);
3423 END;
3424 END IF;
3425 ELSE --(g_aps_wps_profile='N')
3426 IF (l_wlmti_scrap_acct_id = -1) THEN
3427
3428 IF ((l_from_scrap_id IS NULL) OR
3429 (l_to_scrap_id IS NULL))
3430 THEN
3431 SELECT nvl(scrap_account, -1)
3432 INTO l_wlmti_scrap_acct_id
3433 FROM BOM_DEPARTMENTS
3434 WHERE DEPARTMENT_ID=decode(l_scrap_at_operation_flag,
3435 2, l_to_dept_id,
3436 l_wo_dept_id)
3437 AND ORGANIZATION_ID=p_org_id;
3438 ELSE
3439 IF (nvl(l_scrap_at_operation_flag, 1) = 1) THEN
3440 l_wlmti_scrap_acct_id := l_from_scrap_id;
3441 ELSE
3442 l_wlmti_scrap_acct_id := l_to_scrap_id;
3443 END IF;
3444 END IF;
3445
3446 l_stmt_num := 320;
3447 IF (l_wlmti_scrap_acct_id <> -1) THEN
3448 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
3449 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3450 x_err_buf := FND_MESSAGE.GET;
3451 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
3452
3453 update wsm_lot_move_txn_interface
3454 set scrap_account_id = l_wlmti_scrap_acct_id,
3455 error = l_error_msg
3456 where header_id = p_header_id;
3457
3458 l_stmt_num := 325;
3459 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3460 ELSE
3461 x_return_code := 1;
3462 fnd_message.set_name('WSM','WSM_NO_SCRAP_ACC');
3463 IF (nvl(l_scrap_at_operation_flag, 1) = 1) THEN
3464 fnd_message.set_token('DEPT_ID',to_char(l_wo_dept_id));
3465 ELSE
3466 fnd_message.set_token('DEPT_ID',to_char(l_to_dept_id));
3467 END IF;
3468 x_err_buf := FND_MESSAGE.GET;
3469 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3470 return(x_return_code);
3471 END IF;
3472
3473 BEGIN
3474 SELECT gcc.code_combination_id
3475 INTO l_temp
3476 FROM gl_code_combinations gcc
3477 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id;
3478 EXCEPTION
3479 WHEN NO_DATA_FOUND THEN
3480 x_return_code := 1;
3481
3482 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3483 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3484 x_err_buf := FND_MESSAGE.GET;
3485
3486 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||
3487 l_stmt_num||'): '||x_err_buf);
3488 return(x_return_code);
3489 END;
3490 ELSE --(l_wlmti_scrap_acct_id <> -1)
3491
3492 BEGIN
3493 SELECT gcc.code_combination_id
3494 INTO l_temp
3495 FROM gl_code_combinations gcc,
3496 bom_departments bd
3497 WHERE gcc.code_combination_id = l_wlmti_scrap_acct_id
3498 AND bd.scrap_account = gcc.code_combination_id
3499 AND bd.department_id = decode(l_scrap_at_operation_flag,
3500 2, l_dept_id,
3501 l_wo_dept_id);
3502 EXCEPTION
3503 WHEN NO_DATA_FOUND THEN
3504 x_return_code := 1;
3505
3506 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3507 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3508 x_err_buf := FND_MESSAGE.GET;
3509
3510 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||
3511 l_stmt_num||'): '||x_err_buf);
3512 return(x_return_code);
3513 END;
3514 END IF; --(l_wlmti_scrap_acct_id = -1)
3515 END IF; --(g_aps_wps_profile='Y')
3516
3517 elsif ((l_est_scrap_acc = 2 or l_job_type = 3) and l_wlmti_scrap_acct_id <> -1) then
3518
3519 BEGIN
3520
3521 SELECT code_combination_id
3522 INTO l_temp
3523 FROM gl_code_combinations gl
3524 WHERE gl.code_combination_id = l_wlmti_scrap_acct_id
3525 and gl.enabled_flag = 'Y'
3526 and gl.summary_flag = 'N'
3527 and NVL(gl.start_date_active, sysdate) <= sysdate
3528 and NVL(gl.end_date_active, sysdate) >= sysdate;
3529
3530 EXCEPTION
3531 WHEN NO_DATA_FOUND THEN
3532 x_return_code := 1;
3533 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3534 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3535 x_err_buf := FND_MESSAGE.GET;
3536 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='|| l_stmt_num||'): '||x_err_buf);
3537 return(x_return_code);
3538 END;
3539
3540 elsif ((l_est_scrap_acc = 2 or l_job_type = 3) and l_wlmti_scrap_acct_id = -1) then
3541
3542 l_wlmti_scrap_acct_id := '';
3543
3544 end if; -- org is scrap acc enabled.
3545
3546 -- abb H optional scap accounting end
3547
3548 END IF; --(p_to_intraop_step_type = WIP_CONSTANTS.SCRAP) OR (l_scrap_qty>0)
3549 l_stmt_num := 330;
3550 --move enh commenting out the following IF and adding the new checks for move and scrap qty
3551 /* IF ( (l_converted_txn_qty > l_operation_qty) OR
3552 (l_converted_txn_qty < 0) )
3553 THEN
3554 x_return_code := 1;
3555
3556 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3557 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'primary_quantity');
3558 x_err_buf := FND_MESSAGE.GET;
3559
3560 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3561 return(x_return_code);
3562 END IF;*/
3563
3564 --bug 3385113 added nvls
3565 IF ((p_to_intraop_step_type <> WIP_CONSTANTS.SCRAP)
3566 AND (nvl(l_converted_txn_qty, 0)+nvl(l_converted_scrap_qty, 0) <> l_operation_qty)) THEN
3567 x_return_code := 1;
3568
3569 FND_MESSAGE.SET_NAME('WSM', 'WSM_SCRAP_MOVE_QTY_INCORRECT');
3570 x_err_buf := FND_MESSAGE.GET;
3571
3572 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3573 return(x_return_code);
3574 END IF;
3575 --move enh commented out ELSE branch
3576
3577 /* ELSE -- intraop step <> Scrap
3578
3579 if (l_debug = 'Y') then
3580 fnd_file.put_line(fnd_file.log, 'IOP <>SCRAP');
3581 end if;
3582
3583 IF (l_converted_txn_qty <> l_operation_qty) THEN
3584
3585 x_return_code := 1;
3586
3587 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_TXN_QTY');
3588 x_err_buf := FND_MESSAGE.GET;
3589
3590 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3591 return(x_return_code);
3592 END IF;
3593
3594 END IF;
3595 END IF;*/
3596 --end move enh
3597
3598 l_stmt_num := 152;
3599
3600 --** VJ: Start Changes for removal of 9999 **--
3601 -- BC: CZH.I_9999, the following logic is not correct
3602 /**********************************************
3603 BEGIN
3604 SELECT operation_seq_num
3605 INTO l_temp -- <> 0, if moving from the last op
3606 FROM bom_operation_sequences
3607 WHERE operation_seq_num = p_fm_op_seq_num
3608 AND operation_sequence_id = l_end_op_seq_id;
3609 EXCEPTION
3610 WHEN OTHERS THEN
3611 l_temp := 0;
3612 END;
3613 ***********************************************/
3614 BEGIN
3615 SELECT operation_sequence_id, backflush_flag
3616 INTO l_temp, l_fm_op_bkflsh_flag
3617 FROM wip_operations
3618 WHERE operation_seq_num = p_fm_op_seq_num
3619 AND wip_entity_id = l_wip_entity_id
3620 AND ORGANIZATION_ID = p_org_id;
3621 EXCEPTION
3622 WHEN OTHERS THEN
3623 l_temp := 0;
3624 END;
3625 -- EC: CZH.I_9999
3626
3627 -- no jumping is allowed at the last operation.
3628 -- if (p_fm_op_seq_num = g_prev_last_op and (upper(nvl(p_jump_flag, 'N')) = 'Y')) then
3629 if (l_temp = l_end_op_seq_id and (upper(nvl(p_jump_flag, 'N')) = 'Y')) then
3630 --**VJ: End Changes for removal of 9999 **--
3631 --***VJ Changed for Performance Upgrade***--
3632 x_return_code := 1;
3633
3634 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
3635 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'jump_flag');
3636 x_err_buf := FND_MESSAGE.GET;
3637
3638 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3639
3640 return(x_return_code);
3641 end if;
3642
3643 l_stmt_num := 340;
3644 IF (g_aps_wps_profile='N') THEN
3645 SELECT standard_operation_id,
3646 department_id,
3647 operation_seq_num
3648 INTO l_end_std_op_id,
3649 l_end_dept_id,
3650 l_end_op_seq_num
3651 FROM bom_operation_sequences
3652 WHERE operation_sequence_id = l_end_op_seq_id;
3653 END IF; --(g_aps_wps_profile='N')
3654
3655 l_stmt_num := 342;
3656 -- bugfix 3632605 if there is no sub defined or for whatever reason completion sub is missing
3657 -- completion transaction should not be allowed.
3658
3659 select completion_subinventory
3660 into l_cmp_subinv
3661 from wip_discrete_jobs
3662 where wip_entity_id = l_wip_entity_id
3663 and organization_id = p_org_id;
3664
3665 l_stmt_num := 345;
3666 IF (l_end_std_op_id IS NOT NULL) THEN
3667 IF (g_aps_wps_profile='N') THEN
3668 SELECT operation_code
3669 INTO l_end_op_code
3670 FROM bom_standard_operations
3671 WHERE standard_operation_id = l_end_std_op_id;
3672 END IF; --(g_aps_wps_profile='N')
3673
3674 l_stmt_num := 350;
3675 --NSO Modification by abedajna begin
3676 -- Check if the to op_code is the last op_code in the routing
3677 IF ( (l_op_code = l_end_op_code) AND
3678 (p_to_op_seq_num = l_end_op_seq_num) AND
3679 (p_to_intraop_step_type = WIP_CONSTANTS.TOMOVE) )
3680 THEN
3681
3682 --bugfix 3632605
3683 if (l_cmp_subinv is NULL) then
3684 x_return_code := 1;
3685
3686 fnd_message.set_name('WIP', 'WIP_EZ_NO_SUBINV_DEFAULT1');
3687 x_err_buf := fnd_message.get;
3688
3689 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3690
3691 return(x_return_code);
3692 end if;
3693 --endfix
3694
3695 IF (l_txn_type <> 2) THEN -- Move and Completion
3696 --NSO Modification by abedajna end
3697 l_error_msg := substr(l_error_msg||'WARNING: Changing transaction_type to 2.| ', 1, 2000);
3698 -- CZH.BUG2135538
3699 UPDATE wsm_lot_move_txn_interface
3700 SET transaction_type = 2,
3701 --error = 'WARNING: Changing transaction_type to 2' -- CZH.BUG2135538
3702 error = l_error_msg -- CZH.BUG2135538
3703 WHERE header_id = p_header_id;
3704
3705 l_stmt_num := 355;
3706 l_txn_type := 2;
3707
3708 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
3709 ||l_stmt_num||'): WARNING: Changed transaction_type to 2 in WLMTI');
3710
3711 END IF;
3712 ELSE -- not the last operation
3713 IF (l_txn_type <> 1) THEN -- Move only
3714 l_error_msg := substr(l_error_msg||'WARNING: Changing transaction_type to 1.| ', 1, 2000);
3715 -- CZH.BUG2135538
3716 UPDATE wsm_lot_move_txn_interface
3717 SET transaction_type = 1,
3718 --error = 'WARNING: Changing transaction_type to 1' -- CZH.BUG2135538
3719 error = l_error_msg -- CZH.BUG2135538
3720 WHERE header_id = p_header_id;
3721
3722 l_stmt_num := 360;
3723 l_txn_type := 1;
3724
3725 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
3726 ||l_stmt_num||'): WARNING: Changed transaction_type to 1 in WLMTI');
3727 END IF;
3728 END IF;
3729
3730 ELSE -- l_end_std_op_id IS NULL -- CZH: non-std end op
3731
3732 -- Check if the to dept_id is the dept_id of the last operation in the routing
3733 IF ( (l_to_dept_id = l_end_dept_id) AND
3734 (p_to_op_seq_num = l_end_op_seq_num) AND
3735 (p_to_intraop_step_type = WIP_CONSTANTS.TOMOVE) )
3736 THEN
3737
3738 --bugfix 3632605
3739 if (l_cmp_subinv is NULL) then
3740 x_return_code := 1;
3741
3742 fnd_message.set_name('WIP', 'WIP_EZ_NO_SUBINV_DEFAULT1');
3743 x_err_buf := fnd_message.get;
3744
3745 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
3746
3747 return(x_return_code);
3748 end if;
3749 --endfix
3750
3751 IF (l_txn_type <> 2) THEN -- Move and Completion
3752 l_error_msg := substr(l_error_msg||'WARNING: Changing transaction_type to 2.| ', 1, 2000);
3753 -- CZH.BUG2135538
3754 UPDATE wsm_lot_move_txn_interface
3755 SET transaction_type = 2,
3756 --error = 'WARNING: Changing transaction_type to 2' -- CZH.BUG2135538
3757 error = l_error_msg -- CZH.BUG2135538
3758 WHERE header_id = p_header_id;
3759
3760 l_stmt_num := 365;
3761 l_txn_type := 2;
3762
3763 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
3764 ||l_stmt_num||'): WARNING: Changed transaction_type to 2 in WLMTI');
3765 END IF;
3766 ELSE -- not the last operation
3767 IF (l_txn_type <> 1) THEN -- Move only
3768 l_error_msg := substr(l_error_msg||'WARNING: Changing transaction_type to 1.| ', 1, 2000);
3769 -- CZH.BUG2135538
3770 UPDATE wsm_lot_move_txn_interface
3771 SET transaction_type = 1,
3772 --error = 'WARNING: Changing transaction_type to 1' -- CZH.BUG2135538
3773 error = l_error_msg -- CZH.BUG2135538
3774 WHERE header_id = p_header_id;
3775
3776 l_stmt_num := 370;
3777 l_txn_type := 1;
3778
3779 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
3780 ||l_stmt_num||'): WARNING: Changed transaction_type to 1 in WLMTI');
3781 END IF;
3782 END IF;
3783 END IF;
3784
3785 --move enh 115.135 check for backflush flag
3786 --bug 5905993 Replace the if condition with different cases for interface and MES transaction. In MES scrap can only
3787 --be performed at the from operation
3788 --IF (((l_fm_op_bkflsh_flag = 2) or (l_to_op_bkflsh_flag = 2)) AND
3789 --(l_scrap_at_operation_flag IS NOT NULL)) THEN
3790 IF (((nvl(l_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'jump oa page', 'move to next op oa page', 'undo oa page'))
3791 AND
3792 (((l_fm_op_bkflsh_flag = 2)
3793 OR
3794 (l_to_op_bkflsh_flag = 2))
3795 AND
3796 (l_scrap_at_operation_flag IS NOT NULL)))
3797 OR
3798 ((nvl(l_source_code, 'interface') = 'move out oa page')
3799 AND
3800 ((l_fm_op_bkflsh_flag = 2)
3801 AND
3802 (nvl(l_scrap_at_operation_flag, 0) = 1))))
3803 THEN
3804 l_stmt_num := 371;
3805 x_return_code := 1;
3806 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_SCRAP_BKFLSH_OFF');
3807 x_err_buf := FND_MESSAGE.GET;
3808 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3809 return(x_return_code);
3810 END IF;
3811
3812 END IF; -- for forward moves and completions
3813
3814 -------------------------------------------------------------------------------------
3815 -----------------------------END MOVE AND COMPLETION---------------------------------
3816 -------------------------------------------------------------------------------------
3817
3818 -------------------------------------------------------------------------------------
3819 ------------------------------------ASSEMBLY RETURNS---------------------------------
3820 -------------------------------------------------------------------------------------
3821 -- Assy returns are treated as undoing the last completion transaction.
3822 IF (l_txn_type = 3) then -- for Assy returns
3823
3824 -- Get the details of the last completion transaction for this job
3825 l_stmt_num := 375;
3826
3827 --***VJ Changed for Performance Upgrade***--
3828 BEGIN
3829 select max(transaction_id)
3830 into l_max_txn_id
3831 from wip_move_transactions
3832 where organization_id = p_org_id
3833 and wip_entity_id = l_wip_entity_id
3834 -- and to_operation_seq_num = g_prev_last_op -- l_wsm_last_op --**VJ: Deleted for removal of 9999**
3835 --***VJ Changed for Performance Upgrade***--
3836 and to_intraoperation_step_type = 3
3837 --move enh --FP bug 5178168 (base bug 5168406) changed the line below
3838 --and transaction_id = batch_id;
3839 and transaction_id = nvl(batch_id, transaction_id);
3840
3841 EXCEPTION
3842 WHEN NO_DATA_FOUND THEN
3843 x_return_code := 1;
3844 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_COMPLETION');
3845 x_err_buf := FND_MESSAGE.GET;
3846
3847 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3848 return(x_return_code);
3849 END;
3850 --***VJ End Changes***--
3851
3852 l_stmt_num := 377;
3853 IF (nvl(l_max_txn_id, -1) = -1) THEN
3854 x_return_code := 1;
3855 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_COMPLETION');
3856 x_err_buf := FND_MESSAGE.GET;
3857
3858 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3859 return(x_return_code);
3860 END IF;
3861
3862 l_stmt_num := 380;
3863 --move enh added batch_id to the list of columns
3864 --mes added source_code
3865 select FM_OPERATION_SEQ_NUM,
3866 FM_OPERATION_CODE,
3867 FM_INTRAOPERATION_STEP_TYPE,
3868 FM_DEPARTMENT_ID,
3869 TO_OPERATION_SEQ_NUM, --**VJ: Added for Removal of 9999**
3870 TO_OPERATION_CODE,
3871 TO_DEPARTMENT_ID,
3872 TRANSACTION_QUANTITY,
3873 --FP bug 5178168 (base bug 5168406) changed the line below
3874 --BATCH_ID,
3875 nvl(BATCH_ID, transaction_id),
3876 --bug 5185751 get scrap account id from scrap txn only
3877 --scrap_account_id,
3878 source_code
3879 into l_cmp_fm_op_seq_num,
3880 l_cmp_fm_op_code,
3881 l_cmp_fm_intra_op_step,
3882 l_cmp_fm_dept_id,
3883 l_cmp_to_op_seq_num, --**VJ: Added for Removal of 9999**
3884 l_cmp_to_op_code,
3885 l_cmp_to_dept_id,
3886 l_cmp_txn_qty,
3887 l_cmp_batch_id,
3888 --l_wmt_scrap_acc, --bug 4090866 get scrap_account_id from WMT
3889 x_undo_source_code
3890 from wip_move_transactions
3891 where transaction_id = l_max_txn_id; --***VJ Changed for Performance Upgrade***--
3892
3893 --mes
3894 IF ((nvl(x_undo_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'jump oa page',
3895 'move to next op oa page')) AND (nvl(l_source_code, 'interface') = 'interface'))
3896 THEN
3897 x_return_code := 1;
3898 FND_MESSAGE.SET_NAME('WSM', 'WSM_MES_UNDO_OA_FORMSINTERFACE');
3899 x_err_buf := FND_MESSAGE.GET;
3900 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3901 return(x_return_code);
3902 END IF;
3903 --mes end
3904
3905 IF (l_cmp_fm_op_seq_num <> l_cmp_to_op_seq_num) THEN
3906 UPDATE WSM_LOT_BASED_JOBS
3907 SET current_job_op_seq_num = l_cmp_fm_op_seq_num,
3908 current_rtg_op_seq_num =
3909 (SELECT wsm_op_seq_num
3910 FROM WIP_OPERATIONS WO
3911 WHERE WO.wip_entity_id = l_wip_entity_id
3912 AND WO.operation_seq_num = l_cmp_fm_op_seq_num)
3913 WHERE WIP_ENTITY_ID = l_wip_entity_id;
3914 END IF;
3915 --mes end
3916 -- ST : Serial Support Project --
3917 -- Copy the old move transaction id...
3918 x_old_move_transaction_id := l_max_txn_id;
3919 -- ST : Serial Support Project --
3920
3921 --bug 4090866 get scrap_account_id from WMT and update WLMTI
3922 --bug 5185751 get scrap account id from scrap txn only. Moved this validation after getting
3923 --scrap account id from scrap txn
3924 /*************
3925 IF (nvl(l_wmt_scrap_acc, -1) <> nvl(l_wlmti_scrap_acct_id, -1)) THEN
3926 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
3927 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
3928 x_err_buf := FND_MESSAGE.GET;
3929 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
3930
3931 update wsm_lot_move_txn_interface
3932 set scrap_account_id = l_wmt_scrap_acc,
3933 error = l_error_msg
3934 where header_id = p_header_id;
3935 END IF;
3936 *****/
3937 --bug 4090866 end
3938
3939 l_stmt_num := 385;
3940
3941 -- Check if WLMTI.to_op is null or not. If so, update it with the right op seq
3942
3943 --NSO modification by abedajna begin
3944
3945 /* if (
3946 ((nvl(p_to_op_seq_num,-1) <> -1) and (p_to_op_seq_num <> l_cmp_fm_op_seq_num)) or
3947 ((p_to_op_code is not null) and (p_to_op_code <> l_cmp_fm_op_code)) or
3948 ((p_to_intraop_step_type is not null) and (p_to_intraop_step_type <> l_cmp_fm_intra_op_step)) or
3949 ((p_txn_qty is not null) and (p_txn_qty <> l_cmp_txn_qty))
3950 ) then
3951 */
3952 --bug 3217724 modified the above if condition consistent with the OSFM interface manual
3953 if (
3954 ((nvl(p_to_op_seq_num,-1) <> -1) and (p_to_op_seq_num <> l_cmp_fm_op_seq_num)) or
3955 ((p_to_op_code is null) or (p_to_op_code <> l_cmp_fm_op_code)) or
3956 ((p_to_intraop_step_type is null) or (p_to_intraop_step_type <> l_cmp_fm_intra_op_step)) or
3957 ((p_txn_qty is null) or (p_txn_qty <> l_cmp_txn_qty))
3958 ) then
3959
3960 --NSO modification by abedajna end
3961
3962 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
3963 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_operation_seq_num/to_operation_code/to_intraoperation_step_type/transaction_quantity');
3964 x_err_buf := FND_MESSAGE.GET;
3965 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
3966 -- CZH.BUG2135538
3967 update wsm_lot_move_txn_interface
3968 set TO_OPERATION_SEQ_NUM = l_cmp_fm_op_seq_num,
3969 TO_OPERATION_CODE = l_cmp_fm_op_code,
3970 TO_INTRAOPERATION_STEP_TYPE = l_cmp_fm_intra_op_step,
3971 TRANSACTION_QUANTITY = l_cmp_txn_qty,
3972 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
3973 error = l_error_msg -- CZH.BUG2135538
3974 where header_id = p_header_id;
3975
3976 l_stmt_num := 390;
3977 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
3978 end if;
3979
3980 BEGIN
3981 -- ST : Serial Support Project ---
3982 -- Retrieve the old scrap transaction id by qurerying up the transaction id in this below sql...
3983 SELECT transaction_quantity,
3984 primary_quantity,
3985 decode(WMT.to_operation_seq_num, l_cmp_fm_op_seq_num, 1, 2),
3986 transaction_id,
3987 --bug 5185751 get scrap account id from scrap txn only
3988 scrap_account_id
3989 INTO l_wmt_scrap_qty,
3990 l_wmt_pri_scrap_qty,
3991 l_wmt_scrap_at_op_flag,
3992 x_old_scrap_transaction_id,
3993 l_wmt_scrap_acc
3994 FROM WIP_MOVE_TRANSACTIONS WMT
3995 WHERE organization_id = p_org_id
3996 and wip_entity_id = l_wip_entity_id
3997 --FP bug 5178168 (base bug 5168406) changed the line below
3998 --and WMT.batch_id=l_max_txn_id
3999 and nvl(WMT.batch_id, wmt.transaction_id)=l_max_txn_id
4000 AND WMT.transaction_id <> l_max_txn_id
4001 AND to_intraoperation_step_type = 5;
4002 -- ST : Serial Support Project ---
4003 EXCEPTION
4004 WHEN no_data_found THEN
4005 null;
4006 END;
4007
4008 --bug 4090866 get scrap_account_id from WMT and update WLMTI
4009 --bug 5185751 get scrap account id from scrap txn only. Moved this validation after getting
4010 --scrap account id from scrap txn
4011 IF (nvl(l_wmt_scrap_acc, -1) <> nvl(l_wlmti_scrap_acct_id, -1)) THEN
4012 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4013 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
4014 x_err_buf := FND_MESSAGE.GET;
4015 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
4016
4017 update wsm_lot_move_txn_interface
4018 set scrap_account_id = l_wmt_scrap_acc,
4019 error = l_error_msg
4020 where header_id = p_header_id;
4021 END IF;
4022 --bug 4090866 end
4023
4024 IF (g_aps_wps_profile = 'Y') THEN
4025 BEGIN
4026 SELECT nvl(WCO.recommended, 'N')
4027 INTO l_recommended
4028 FROM WSM_COPY_OPERATIONS WCO,
4029 WIP_OPERATIONS WO
4030 WHERE WO.wip_entity_id = l_wip_entity_id
4031 AND WO.organization_id = p_org_id
4032 AND WO.operation_seq_num = l_cmp_fm_op_seq_num
4033 AND WCO.wip_entity_id = WO.wip_entity_id
4034 AND WCO.operation_sequence_id = WO.operation_sequence_id;
4035 EXCEPTION
4036 WHEN no_data_found THEN
4037 l_recommended := 'N';
4038 END;
4039 END IF;
4040
4041 -- Update WLMTI.from_op to NULL. No need to validate.
4042 --move enh moved the update further down
4043 /* update wsm_lot_move_txn_interface
4044 set FM_OPERATION_SEQ_NUM = NULL,
4045 FM_OPERATION_CODE = NULL,
4046 FM_INTRAOPERATION_STEP_TYPE = NULL
4047 where header_id = p_header_id;*/
4048
4049 l_stmt_num := 395;
4050 -- Get the onhand quantity for the WDJ.lot_number, completion_subinventory, locator_id and
4051 -- compare it with p_txn_qty. If not equal, then error out
4052
4053
4054 select PRIMARY_ITEM_ID,
4055 COMPLETION_SUBINVENTORY,
4056 COMPLETION_LOCATOR_ID,
4057 LOT_NUMBER,
4058 class_code, --bug 2484294
4059 job_type, --bug 2484294
4060 kanban_card_id, -- abbKanban
4061 quantity_completed -- Fix for bug #2095267
4062 into l_cmp_primary_item_id,
4063 l_cmp_subinv,
4064 l_cmp_loc_id,
4065 l_cmp_lot_number,
4066 l_class_code,
4067 l_job_type,
4068 l_kanban_card_id,
4069 l_qty_completed -- Fix for bug #2095267
4070 from wip_discrete_jobs
4071 where organization_id = p_org_id
4072 and wip_entity_id = l_wip_entity_id;
4073
4074 l_stmt_num := 400;
4075
4076 -- Fix bug 1495104
4077 --select sum(transaction_quantity)
4078 -- Fix bug 1495104
4079 select nvl(sum(transaction_quantity),0)
4080 into l_onhand_qty
4081 --bug 3324825 change to mtl_onhand_quantities_detail
4082 -- from mtl_onhand_quantities
4083 from mtl_onhand_quantities_detail
4084 where organization_id = p_org_id
4085 and inventory_item_id = l_cmp_primary_item_id
4086 and subinventory_code = l_cmp_subinv
4087 and nvl(locator_id, -1) = nvl(l_cmp_loc_id, nvl(locator_id, -1)) --Fix for bug 1495104
4088 and lot_number = nvl(l_cmp_lot_number, lot_number);
4089
4090
4091 if (l_debug = 'Y') then
4092 fnd_file.put_line(fnd_file.log, 'l_onhand_qty='||l_onhand_qty
4093 ||', p_txn_qty='||p_txn_qty||', l_qty_completed='||l_qty_completed);
4094 end if;
4095
4096 --BA: CZH: BUG2154720
4097 l_stmt_num := 403;
4098 l_converted_txn_qty := inv_convert.inv_um_convert (item_id => l_primary_item_id,
4099 precision => NULL,
4100 from_quantity => p_txn_qty,
4101 from_unit => p_txn_uom,
4102 to_unit => l_primary_uom,
4103 from_name => NULL,
4104 to_name => NULL);
4105 if (l_debug = 'Y') then
4106 fnd_file.put_line(fnd_file.log, 'l_converted_txn_qty='||l_converted_txn_qty);
4107 end if;
4108
4109 -- ST : Serial Support ---
4110 -- Place validations here for the transaction quantity and the converted txn quantity,...
4111 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
4112 (
4113 -- ST : Demo issue : Commenting out : floor(p_txn_qty) <> p_txn_qty OR
4114 floor(l_converted_txn_qty) <> l_converted_txn_qty
4115 )
4116 THEN
4117 x_return_code := 1;
4118 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
4119 x_err_buf := FND_MESSAGE.GET;
4120
4121 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4122 return(x_return_code);
4123
4124 END IF;
4125 -- ST : Serial Support ---
4126
4127 --EA: CZH: BUG 2154720
4128 --move enh not needed since wmt already has pri scrap qty
4129 /* IF (l_scrap_qty > 0) THEN
4130 l_converted_scrap_qty := inv_convert.inv_um_convert (item_id => l_primary_item_id,
4131 precision => NULL,
4132 from_quantity => l_scrap_qty,
4133 from_unit => p_txn_uom,
4134 to_unit => l_primary_uom,
4135 from_name => NULL,
4136 to_name => NULL);
4137
4138 if (l_debug = 'Y') then
4139 fnd_file.put_line(fnd_file.log, 'l_converted_txn_qty='||l_converted_txn_qty);
4140 end if;
4141 END IF; --l_scrap_qty > 0 */
4142
4143 IF (nvl(l_scrap_qty, -1) <> nvl(l_wmt_scrap_qty, -1)) THEN
4144 l_scrap_qty := l_wmt_scrap_qty;
4145 l_converted_scrap_qty := l_wmt_pri_scrap_qty;
4146 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4147 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_quantity');
4148 x_err_buf := FND_MESSAGE.GET;
4149 END IF;
4150
4151 IF (nvl(l_scrap_at_operation_flag, -1) <> nvl(l_wmt_scrap_at_op_flag, -1)) THEN
4152 l_scrap_at_operation_flag := l_wmt_scrap_at_op_flag;
4153 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4154 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_at_operation_flag');
4155 x_err_buf := FND_MESSAGE.GET;
4156 END IF;
4157
4158 update wsm_lot_move_txn_interface
4159 set FM_OPERATION_SEQ_NUM = l_cmp_to_op_seq_num,
4160 FM_OPERATION_CODE = l_cmp_to_op_code,
4161 FM_INTRAOPERATION_STEP_TYPE = WIP_CONSTANTS.TOMOVE,
4162 SCRAP_QUANTITY = l_wmt_scrap_qty
4163 where header_id = p_header_id;
4164
4165 l_converted_scrap_qty := l_wmt_pri_scrap_qty;
4166
4167 --move enh
4168
4169
4170 l_stmt_num := 405;
4171
4172 -- if (l_onhand_qty <> p_txn_qty) OR -- CZH: BUG 2154720
4173 if (l_onhand_qty <> NVL(l_converted_txn_qty,0)) OR -- CZH: BUG 2154720
4174 ((l_onhand_qty) <> l_qty_completed) then -- Added 2nd condition to fix bug #2095267
4175 -- FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4176 -- FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction quantity');
4177 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_RETURN'); -- Fix for bug #2095267
4178 x_return_code := 1;
4179 x_err_buf := FND_MESSAGE.GET;
4180
4181 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4182 return(x_return_code);
4183 end if;
4184
4185 -- abbKanban begin
4186 l_stmt_num := 406;
4187
4188 -- when returning, if the job has a kanban reference, just provide a warning...
4189 if l_kanban_card_id is not null then
4190 FND_MESSAGE.set_name('WSM', 'WSM_KNBN_RET_ISSUES');
4191 x_warning_mesg := fnd_message.get;
4192 fnd_file.put_line(fnd_file.log, '******** WARNING *********');
4193 fnd_file.put_line(fnd_file.log, x_warning_mesg);
4194 fnd_file.put_line(fnd_file.log, '******** WARNING *********');
4195 end if; --kanban card is not null
4196
4197
4198
4199 /* if l_kanban_card_id is not null then
4200 **-- when you return, if the kanban is in InProcess status, do not allow the return
4201 **-- after return, the kanban status should be changed to InProcess
4202 ** select supply_status
4203 ** into l_cur_supply_status
4204 ** from mtl_kanban_card_activity
4205 ** where kanban_card_id = l_kanban_card_id
4206 ** and kanban_activity_id =
4207 ** (select max(kanban_activity_id)
4208 ** from mtl_kanban_card_activity
4209 ** where kanban_card_id = l_kanban_card_id);
4210 **
4211 **l_stmt_num := 406.1;
4212 ** if l_cur_supply_status = 5 then
4213 ** FND_MESSAGE.set_name('WSM', 'WSM_KNBN_RET_ISSUES');
4214 ** x_warning_mesg := fnd_message.get;
4215 ** fnd_file.put_line(fnd_file.log, '******** WARNING *********');
4216 ** fnd_file.put_line(fnd_file.log, x_warning_mesg);
4217 ** fnd_file.put_line(fnd_file.log, '******** WARNING *********');
4218 ** else
4219 ** inv_kanban_pvt.Update_Card_Supply_Status
4220 ** (X_Return_Status => l_returnStatus,
4221 ** p_Kanban_Card_Id => l_kanban_card_id,
4222 ** p_Supply_Status => inv_kanban_pvt.g_supply_status_InProcess);
4223 **
4224 ** if ( l_returnStatus <> fnd_api.g_ret_sts_success) then
4225 ** FND_MESSAGE.SET_NAME('WSM', 'WSM_KNBN_CARD_STS_FAIL');
4226 ** fnd_message.set_token('STATUS','InProcess');
4227 ** x_return_code := 1;
4228 ** x_err_buf := FND_MESSAGE.GET;
4229 ** fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4230 ** return(x_return_code);
4231 ** end if;
4232 ** end if;
4233 **
4234 ** end if; --kanban card is not null
4235 */
4236 -- abbKanban end
4237
4238
4239 l_stmt_num := 410;
4240 -- abb bugfix 2484294 begin
4241 -- check that the class code and the dept of the last operation have the relevant accounts defined.
4242 l_est_scrap_acc := wsmputil.WSM_ESA_ENABLED(
4243 p_wip_entity_id => l_wip_entity_id,
4244 err_code => l_err_code,
4245 err_msg => l_err_msg,
4246 p_org_id => p_org_id,
4247 p_job_type => l_job_type);
4248
4249 --NO CHECK FOR RETURN VALUES HERE....-VJ--
4250
4251 select est_scrap_account, est_scrap_var_account
4252 into p_est_scrap_account, p_est_scrap_var_account
4253 from wip_accounting_classes
4254 where class_code = l_class_code
4255 and organization_id = p_org_id;
4256
4257 if p_est_scrap_account is null or p_est_scrap_var_account is null then
4258 if l_est_scrap_acc = 1 then
4259 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_WAC_SCRAP_ACC');
4260 fnd_message.set_token('CC', l_class_code);
4261 x_return_code := 1;
4262 x_err_buf := FND_MESSAGE.GET;
4263 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4264 return(x_return_code);
4265 end if;
4266 end if;
4267
4268 update wip_discrete_jobs wdj
4269 set wdj.est_scrap_account = nvl(p_est_scrap_account, wdj.est_scrap_account),
4270 wdj.est_scrap_var_account = nvl(p_est_scrap_var_account, wdj.est_scrap_var_account)
4271 where wip_entity_id = l_wip_entity_id;
4272
4273 select scrap_account, est_absorption_account
4274 into l_scrap_account, l_est_scrap_abs_account
4275 from bom_departments
4276 where department_id = l_cmp_to_dept_id;
4277
4278 if l_scrap_account is null or l_est_scrap_abs_account is null then
4279 if l_est_scrap_acc = 1 then
4280 fnd_message.set_name('WSM','WSM_NO_SCRAP_ACC');
4281 fnd_message.set_token('DEPT_ID',to_char(l_cmp_to_dept_id));
4282 x_return_code := 1;
4283 x_err_buf := FND_MESSAGE.GET;
4284 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4285 return(x_return_code);
4286 end if;
4287 end if;
4288
4289 UPDATE WIP_OPERATION_YIELDS WOY
4290 SET SCRAP_ACCOUNT = nvl(l_scrap_account, WOY.SCRAP_ACCOUNT),
4291 EST_SCRAP_ABSORB_ACCOUNT = nvl(l_est_scrap_abs_account, WOY.EST_SCRAP_ABSORB_ACCOUNT)
4292 WHERE WIP_ENTITY_ID = l_wip_entity_id
4293 --** VJ: Start Changes for removal of 9999 **--
4294 -- and operation_seq_num = g_prev_last_op;
4295 and operation_seq_num = l_cmp_to_op_seq_num;
4296 --** VJ: End Changes for removal of 9999 **--
4297
4298 -- abb bugfix 2484294 end
4299
4300 END IF; -- for assy returns
4301
4302 -------------------------------------------------------------------------------------
4303 ------------------------------------END ASSEMBLY RETURNS-----------------------------
4304 -------------------------------------------------------------------------------------
4305
4306
4307 -------------------------------------------------------------------------------------
4308 ------------------------------------BACKWARD MOVES-----------------------------------
4309 -------------------------------------------------------------------------------------
4310 IF (l_txn_type = 4) then -- for Backward moves
4311 -- Find out whether there is an operation that has positive qty
4312
4313 l_stmt_num := 410;
4314 -- Check if Backward moves are allowed or not.
4315 /* JUMP_ENH: Commented the following because it's moved to the
4316 beginning and called only when the organization_id is changed
4317 select ALLOW_BACKWARD_MOVE_FLAG
4318 into l_allow_bkw_move
4319 from wsm_parameters
4320 where organization_id = p_org_id; */
4321
4322 if (g_allow_bkw_move <> 1) then
4323 x_return_code := 1;
4324 --bug 4202723
4325 --FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4326 --FND_MESSAGE.SET_TOKEN('FLD_NAME', 'Backward Move Flag');
4327 FND_MESSAGE.SET_NAME('WSM', 'WSM_UNDO_NOT_ENABLED');
4328 --end bug 4202723
4329 x_err_buf := FND_MESSAGE.GET;
4330
4331 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4332
4333 return(x_return_code);
4334 end if;
4335
4336
4337 --***VJ Changed for Performance Upgrade***--
4338 BEGIN
4339 select max(OPERATION_SEQ_NUM)
4340 into l_max_qty_op_seq_num
4341 from wip_operations
4342 where organization_id = p_org_id
4343 and wip_entity_id = l_wip_entity_id
4344 and ((QUANTITY_IN_QUEUE > 0) or
4345 (QUANTITY_RUNNING > 0) or
4346 (QUANTITY_WAITING_TO_MOVE > 0) or
4347 (QUANTITY_SCRAPPED > 0));
4348
4349 EXCEPTION
4350 WHEN NO_DATA_FOUND THEN
4351 x_return_code := 1;
4352
4353 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4354 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_name');
4355 x_err_buf := FND_MESSAGE.GET;
4356
4357 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4358 return(x_return_code);
4359 END;
4360 --***VJ End Changes***--
4361
4362 l_stmt_num := 420;
4363
4364 -- Find out at which operation/intra-op step the quantity lies in WIP
4365
4366 BEGIN
4367 select OPERATION_SEQ_NUM,
4368 decode(sign(QUANTITY_IN_QUEUE),1,QUANTITY_IN_QUEUE,0),
4369 decode(sign(QUANTITY_RUNNING),1,QUANTITY_RUNNING,0),
4370 decode(sign(QUANTITY_WAITING_TO_MOVE),1,QUANTITY_WAITING_TO_MOVE,0),
4371 decode(sign(QUANTITY_SCRAPPED),1,QUANTITY_SCRAPPED,0)
4372 into l_wo_op_seq_num,
4373 l_wo_qty_in_queue,
4374 l_wo_qty_in_running,
4375 l_wo_qty_in_tomove,
4376 l_wo_qty_in_scrap
4377 from wip_operations
4378 where organization_id = p_org_id
4379 and wip_entity_id = l_wip_entity_id
4380 and OPERATION_SEQ_NUM = l_max_qty_op_seq_num; --***VJ Changed for Performance Upgrade***--
4381
4382 p_fm_op_seq_num_orig := p_fm_op_seq_num; --bug 5349187: Store the original value of p_fm_op_seq_num
4383 -- OSP FP I added the next line
4384 p_fm_op_seq_num := l_wo_op_seq_num;
4385
4386 EXCEPTION
4387 WHEN NO_DATA_FOUND THEN
4388 x_return_code := 1;
4389
4390 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4391 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'wip_entity_name');
4392 x_err_buf := FND_MESSAGE.GET;
4393
4394 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4395 return(x_return_code);
4396 END;
4397
4398
4399 l_stmt_num := 425;
4400
4401
4402 -- Check if qty exists in 2 intraops in the same op (e.g. Run and Scrap)
4403
4404 l_wo_qty_iop_step := 0;
4405 l_wo_qty_scrap_step := 0;
4406
4407 if(l_wo_qty_in_queue <> 0) then
4408 l_wo_qty_iop_step := 1;
4409 l_wo_qty := l_wo_qty_in_queue;
4410 elsif(l_wo_qty_in_running <> 0) then
4411 l_wo_qty_iop_step := 2;
4412 l_wo_qty := l_wo_qty_in_running;
4413 elsif(l_wo_qty_in_tomove <> 0) then
4414 l_wo_qty_iop_step := 3;
4415 l_wo_qty := l_wo_qty_in_tomove;
4416 end if;
4417
4418 --bug 4380374
4419 x_available_qty := l_wo_qty;
4420 --end bug 4380374
4421
4422 if(l_wo_qty_in_scrap <> 0) then
4423 l_wo_qty_scrap_step := 5;
4424 end if;
4425
4426 -- Start fix for bug #2095253
4427 BEGIN
4428 SELECT max(transaction_id)
4429 INTO l_txn_id
4430 FROM wip_move_transactions
4431 WHERE organization_id = p_org_id
4432 AND wip_entity_id = l_wip_entity_id
4433 --move enh added transaction_id = batch_id --FP bug 5178168 (base bug 5168406) changed the line below
4434 --AND transaction_id = batch_id;
4435 AND transaction_id = nvl(batch_id, transaction_id);
4436
4437 IF (l_txn_id IS NULL) THEN
4438 x_return_code := 1;
4439
4440 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_MOVE_TXNS');
4441 x_err_buf := FND_MESSAGE.GET;
4442
4443 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4444
4445 return(x_return_code);
4446 END IF;
4447 EXCEPTION
4448 WHEN NO_DATA_FOUND THEN
4449 x_return_code := 1;
4450
4451 FND_MESSAGE.SET_NAME('WSM', 'WSM_NO_MOVE_TXNS');
4452 x_err_buf := FND_MESSAGE.GET;
4453
4454 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4455 return(x_return_code);
4456 END;
4457 -- End fix for bug #2095253
4458
4459 -- abb changes for bug 2427171 begins
4460 l_txn_id := null;
4461 -- abb changes for bug 2427171 ends
4462
4463 --***VJ Changed for Performance Upgrade***--
4464 BEGIN
4465 select max(transaction_id)
4466 into l_txn_id
4467 from wip_move_transactions
4468 where organization_id = p_org_id
4469 and wip_entity_id = l_wip_entity_id
4470 and to_operation_seq_num = l_wo_op_seq_num
4471 and to_intraoperation_step_type IN (l_wo_qty_iop_step, l_wo_qty_scrap_step)
4472 and (fm_operation_seq_num < to_operation_seq_num OR
4473 (fm_operation_seq_num = to_operation_seq_num AND
4474 fm_intraoperation_step_type < to_intraoperation_step_type)
4475 )
4476 --move enh added transaction_id = batch_id --FP bug 5178168 (base bug 5168406) changed the line below
4477 --AND transaction_id = batch_id;
4478 AND transaction_id = nvl(batch_id, transaction_id);
4479
4480 EXCEPTION
4481 WHEN NO_DATA_FOUND THEN
4482 x_return_code := 1;
4483
4484 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4485 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_operation_seq_num/transaction_quantity');
4486 x_err_buf := FND_MESSAGE.GET;
4487
4488 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4489 return(x_return_code);
4490 END;
4491
4492 -- abb changes for bug 2427171 begin
4493 if l_txn_id is null then
4494 x_return_code := 1;
4495 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_MOVE_CAND');
4496 x_err_buf := FND_MESSAGE.GET;
4497 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf) ;
4498 return(x_return_code);
4499 end if;
4500 -- abb changes for bug 2427171 end
4501 --***VJ End Changes***--
4502
4503
4504 l_stmt_num := 430;
4505
4506 -- Get the from_op_seq/code/iop from which the move was made to the above op_seq/iop
4507
4508 select FM_OPERATION_SEQ_NUM,
4509 FM_OPERATION_CODE,
4510 FM_INTRAOPERATION_STEP_TYPE,
4511 FM_DEPARTMENT_ID,
4512 TO_OPERATION_SEQ_NUM,
4513 TO_OPERATION_CODE,
4514 TO_INTRAOPERATION_STEP_TYPE,
4515 TO_DEPARTMENT_ID,
4516 TRANSACTION_QUANTITY,
4517 PRIMARY_QUANTITY,
4518 --bug 5349187 reversed part of the fix for bug 5185751 by uncommenting following line since
4519 --l_wmt_scrap_acct_id was not getting populated for undo of scrap only transaction
4520 NVL(SCRAP_ACCOUNT_ID, -1),
4521 source_code
4522 into l_fm_op_seq_num,
4523 l_fm_op_code,
4524 l_fm_intraop_step,
4525 l_fm_dept_id,
4526 l_to_op_seq_num,
4527 l_to_op_code,
4528 l_to_intraop_step,
4529 l_to_dept_id,
4530 l_wmt_txn_qty,
4531 l_wmt_pri_txn_qty,
4532 --bug 5349187 reversed part of the fix for bug 5185751 by uncommenting following line since
4533 --l_wmt_scrap_acct_id was not getting populated for undo of scrap only transaction
4534 l_wmt_scrap_acct_id,
4535 x_undo_source_code
4536 from wip_move_transactions
4537 where transaction_id = l_txn_id;
4538
4539 --mes
4540
4541 IF ((x_undo_source_code IN ('move in oa page', 'move out oa page', 'jump oa page',
4542 'move to next op oa page')) AND (nvl(l_source_code, 'interface') = 'interface'))
4543 THEN
4544 x_return_code := 1;
4545 FND_MESSAGE.SET_NAME('WSM', 'WSM_MES_UNDO_OA_FORMSINTERFACE');
4546 x_err_buf := FND_MESSAGE.GET;
4547 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4548 return(x_return_code);
4549 END IF;
4550
4551 IF (l_fm_op_seq_num <> l_to_op_seq_num) THEN
4552 UPDATE WSM_LOT_BASED_JOBS
4553 SET current_job_op_seq_num = l_fm_op_seq_num,
4554 current_rtg_op_seq_num =
4555 (SELECT wsm_op_seq_num
4556 FROM WIP_OPERATIONS WO
4557 WHERE WO.wip_entity_id = l_wip_entity_id
4558 AND WO.operation_seq_num = l_fm_op_seq_num)
4559 WHERE WIP_ENTITY_ID = l_wip_entity_id;
4560 END IF;
4561 --mes end
4562
4563 -- ST : Serial Support Project --
4564 -- Assign the old move transaction id...
4565 x_old_move_transaction_id := l_txn_id;
4566 -- ST : Serial Support Project --
4567
4568 l_stmt_num := 435;
4569 BEGIN
4570 -- ST : Serial Support ---
4571 -- Obtain the scrap txn id also...
4572 SELECT transaction_quantity,
4573 primary_quantity,
4574 decode(to_operation_seq_num,FM_OPERATION_SEQ_NUM, 1, 2),
4575 transaction_id,
4576 --bug 5185751 SCRAP_ACCOUNT_ID should be obtained from scrap txn only
4577 scrap_account_id
4578 INTO l_wmt_scrap_qty,
4579 l_wmt_pri_scrap_qty,
4580 l_wmt_scrap_at_op_flag,
4581 x_old_scrap_transaction_id,
4582 l_wmt_scrap_acct_id
4583 FROM WIP_MOVE_TRANSACTIONS
4584 --move enh 115.135 added wip_entity_id after perf check
4585 WHERE wip_entity_id = l_wip_entity_id
4586 --FP bug 5178168 (base bug 5168406) changed the line below
4587 --AND batch_id=l_txn_id
4588 AND nvl(batch_id, transaction_id) =l_txn_id
4589 AND transaction_id<>l_txn_id;
4590 -- ST : Serial Support ---
4591 EXCEPTION
4592 WHEN no_data_found THEN
4593 null;
4594 END;
4595
4596 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4597 l_msg_tokens.delete;
4598 WSM_log_PVT.logMessage (
4599 p_module_name => l_module,
4600 p_msg_text => 'After select on WIP_MOVE_TRANSACTIONS: '||
4601 'l_wmt_scrap_qty '||l_wmt_scrap_qty||
4602 '; l_wmt_pri_scrap_qty '||l_wmt_pri_scrap_qty||
4603 '; l_wmt_scrap_at_op_flag '||l_wmt_scrap_at_op_flag||
4604 '; l_wmt_pri_txn_qty '||l_wmt_pri_txn_qty||
4605 '; l_wmt_txn_qty '||l_wmt_txn_qty||
4606 '; l_wmt_scrap_acct_id '||l_wmt_scrap_acct_id,
4607 p_stmt_num => l_stmt_num,
4608 p_msg_tokens => l_msg_tokens,
4609 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
4610 p_run_log_level => l_log_level
4611 );
4612 END IF;
4613
4614 IF (x_undo_source_code IN ('move in oa page', 'move out oa page', 'jump oa page',
4615 'move to next op oa page'))
4616 THEN
4617 l_converted_scrap_qty := l_wmt_pri_scrap_qty;
4618 END IF;
4619
4620 IF (g_aps_wps_profile = 'Y') THEN
4621 BEGIN
4622 SELECT nvl(WCO.recommended, 'N')
4623 INTO l_recommended
4624 FROM WSM_COPY_OPERATIONS WCO,
4625 WIP_OPERATIONS WO
4626 WHERE WO.wip_entity_id = l_wip_entity_id
4627 AND WO.organization_id = p_org_id
4628 AND WO.operation_seq_num = l_fm_op_seq_num
4629 AND WCO.wip_entity_id = WO.wip_entity_id
4630 AND WCO.operation_sequence_id = WO.operation_sequence_id;
4631 EXCEPTION
4632 WHEN no_data_found THEN
4633 l_recommended := 'N';
4634 END;
4635 END IF;
4636 -- Verify if the given p_from_op_seq/code/iop is same as the above retrieved l_to_op_seq/code/iop.
4637 x_err_buf := NULL;
4638
4639 -- Bugfix 1587295: Added NVLs to the parameter variables
4640 /* bug 5349187: Use p_fm_op_seq_num_orig for finding out whether fm_op_se_num, fm_op_code,
4641 fm_intraop_step_type needs to be defaulted. This is because p_fm_op_seq_num
4642 might have been changed by the code at l_stmt_num := 420 for OSP enhancement.
4643 */
4644 --IF (( (nvl(p_fm_op_seq_num,-1) <> -1) AND
4645 -- (nvl(p_fm_op_seq_num,-1) <> l_to_op_seq_num) ) or
4646 IF (( (nvl(p_fm_op_seq_num_orig,-1) <> -1) AND -- bug 5349187
4647 (nvl(p_fm_op_seq_num_orig,-1) <> l_to_op_seq_num) ) or --bug 5349187
4648 --Bug# 2775819. Changed l_fm_op_code_temp to l_fm_op_code because for undo txn
4649 --the code never fetches values into l_fm_op_code_temp.
4650 ( (NVL(p_fm_op_code, l_fm_op_code) IS NOT NULL) AND -- Fix for bug #2081442
4651 (NVL(p_fm_op_code, l_fm_op_code) <> l_to_op_code) ) or -- Fix for bug #2081442
4652 ( (nvl(p_fm_intraop_step_type,-1) <> -1) AND
4653 (nvl(p_fm_intraop_step_type,-1) <> l_to_intraop_step) ) )
4654 THEN
4655 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4656 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_op_seq_num/fm_op_code/fm_intraop_step_type');
4657 x_err_buf := FND_MESSAGE.GET;
4658 --ELSIF( (nvl(p_fm_op_seq_num,-1) = -1) AND
4659 ELSIF( (nvl(p_fm_op_seq_num_orig,-1) = -1) AND --bug 5349187
4660 (NVL(p_fm_op_code, l_fm_op_code_temp) IS NULL) AND -- Fix for bug #2081442
4661 (nvl(p_fm_intraop_step_type,-1) = -1)
4662 ) THEN
4663
4664 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4665 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_op_seq_num,fm_op_code,fm_intraop_step_type');
4666 x_err_buf := FND_MESSAGE.GET;
4667 END IF;
4668
4669 --move enh 115.135 added the l_to_intraop_step condn after perf check
4670 IF ((l_to_intraop_step <> g_scrap) AND ((nvl(l_scrap_qty, -1)<>nvl(l_wmt_scrap_qty, -1))
4671 OR (nvl(l_scrap_at_operation_flag, -1)<>nvl(l_wmt_scrap_at_op_flag, -1)))) THEN
4672 l_scrap_qty := l_wmt_scrap_qty;
4673 l_converted_scrap_qty := l_wmt_pri_scrap_qty;
4674 l_scrap_at_operation_flag := l_wmt_scrap_at_op_flag;
4675 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4676 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_quantity/scrap_at_operation_flag');
4677 x_err_buf := x_err_buf || FND_MESSAGE.GET;
4678 END IF;
4679
4680 if (l_debug = 'Y') then
4681 fnd_file.put_line(fnd_file.log, 'VALUES FETCHED FROM WMT TABLE '||
4682 ' l_fm_op_seq_num='||l_fm_op_seq_num||
4683 ', l_fm_op_code='||l_fm_op_code||
4684 ', l_fm_dept_id='||l_fm_dept_id||
4685 ', l_fm_intraop_step_type='||l_fm_intraop_step ||
4686 ', l_to_op_seq_num='||l_to_op_seq_num||
4687 ', l_to_op_code='||l_to_op_code||
4688 ', l_to_intraop_step_type='|| l_to_intraop_step ||
4689 ', l_to_dept_id='||l_to_dept_id||
4690 ', error_msg ' || l_error_msg);
4691 end if;
4692
4693 fnd_file.put_line(fnd_file.log, 'x_err_buf '||x_err_buf);
4694 IF (x_err_buf IS NOT NULL) THEN
4695 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
4696 --move enh added SCRAP_QUANTITY, SCRAP_QUANTITY
4697 -- CZH.BUG2135538
4698
4699 update wsm_lot_move_txn_interface
4700 set FM_OPERATION_SEQ_NUM = l_to_op_seq_num,
4701 FM_OPERATION_CODE = l_to_op_code,
4702 FM_INTRAOPERATION_STEP_TYPE = l_to_intraop_step,
4703 FM_DEPARTMENT_ID = l_to_dept_id,
4704 SCRAP_QUANTITY = l_wmt_scrap_qty,
4705 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
4706 error = l_error_msg -- CZH.BUG2135538
4707 where header_id = p_header_id;
4708
4709 l_converted_scrap_qty := l_wmt_pri_scrap_qty;
4710 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4711 l_msg_tokens.delete;
4712 WSM_log_PVT.logMessage (
4713 p_module_name => l_module,
4714 p_msg_text => 'In IF (x_err_buf IS NOT NULL) THEN '||
4715 ';l_converted_scrap_qty '||
4716 l_converted_scrap_qty,
4717 p_stmt_num => l_stmt_num,
4718 p_msg_tokens => l_msg_tokens,
4719 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
4720 p_run_log_level => l_log_level
4721 );
4722 END IF;
4723 l_stmt_num := 440;
4724 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4725
4726 END IF;
4727
4728 -- Verify if the given p_to_op_seq/code/iop/dept_id is same as the above retrieved l_from_op_seq/code/iop/dept_id.
4729
4730 -- Bugfix 1587295: Added NVLs to the parameter variables
4731 x_err_buf := NULL;
4732 IF (( (nvl(p_to_op_seq_num,-1) <> -1) AND
4733 (nvl(p_to_op_seq_num,-1) <> l_fm_op_seq_num) ) or
4734 ( (p_to_op_code IS NOT NULL) AND
4735 (p_to_op_code <> l_fm_op_code) ) or
4736 ( (nvl(p_to_intraop_step_type,-1) <> -1) AND
4737 (nvl(p_to_intraop_step_type,-1) <> l_fm_intraop_step) ) or
4738 ( (nvl(p_to_dept_id,-1) <> -1) AND
4739 (nvl(p_to_dept_id,-1) <> l_fm_dept_id) )
4740 ) THEN
4741
4742 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4743 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num/to_op_code/to_intraop_step_type/to_dept_id');
4744 x_err_buf := FND_MESSAGE.GET;
4745
4746 ELSIF( (nvl(p_to_op_seq_num,-1) = -1) AND
4747 (p_to_op_code IS NULL) AND
4748 (nvl(p_to_intraop_step_type,-1) = -1) AND
4749 (nvl(p_to_dept_id,-1) = -1) ) THEN
4750
4751 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4752 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_op_seq_num,to_op_code,to_intraop_step_type,to_dept_id');
4753 x_err_buf := FND_MESSAGE.GET;
4754
4755 END IF;
4756
4757 IF (x_err_buf IS NOT NULL) THEN
4758 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
4759 -- CZH.BUG2135538
4760 update wsm_lot_move_txn_interface
4761 set TO_OPERATION_SEQ_NUM = l_fm_op_seq_num,
4762 TO_OPERATION_CODE = l_fm_op_code,
4763 TO_INTRAOPERATION_STEP_TYPE = l_fm_intraop_step,
4764 TO_DEPARTMENT_ID = l_fm_dept_id,
4765 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
4766 error = l_error_msg -- CZH.BUG2135538
4767 where header_id = p_header_id;
4768
4769 l_stmt_num := 445;
4770 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4771 END IF;
4772
4773 --BA: CZH:BUG2154720
4774 l_stmt_num := 447;
4775
4776 l_converted_txn_qty := inv_convert.inv_um_convert (item_id => l_primary_item_id,
4777 precision => NULL,
4778 from_quantity => p_txn_qty,
4779 from_unit => p_txn_uom,
4780 to_unit => l_primary_uom,
4781 from_name => NULL,
4782 to_name => NULL);
4783
4784
4785 if (l_debug = 'Y') then
4786 fnd_file.put_line(fnd_file.log, 'after converting @447 l_converted_txn_qty='||l_converted_txn_qty);
4787 end if;
4788
4789 -- ST : Serial Support ---
4790 -- Place the check for qty here...
4791 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
4792 (
4793 -- ST : Demo issue : Commenting out : floor(p_txn_qty) <> p_txn_qty OR
4794 floor(l_converted_txn_qty) <> l_converted_txn_qty
4795 )
4796 THEN
4797 x_return_code := 1;
4798 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
4799 x_err_buf := FND_MESSAGE.GET;
4800
4801 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4802 return(x_return_code);
4803
4804 END IF;
4805 -- ST : Serial Support ---
4806
4807 --move enh 115.135 modified the qty check after perf check
4808 --move enh 115.136 corrected the from_quantity
4809 if (l_debug = 'Y') then
4810 fnd_file.put_line(fnd_file.log, 'l_scrap_qty '||l_scrap_qty||' l_to_intraop_step '||l_to_intraop_step);
4811 end if;
4812
4813 IF ((l_to_intraop_step = 5) AND (l_scrap_qty > 0)) THEN
4814 l_converted_scrap_qty := inv_convert.inv_um_convert (item_id => l_primary_item_id,
4815 precision => NULL,
4816 from_quantity => l_scrap_qty,
4817 from_unit => p_txn_uom,
4818 to_unit => l_primary_uom,
4819 from_name => NULL,
4820 to_name => NULL);
4821 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4822 l_msg_tokens.delete;
4823 WSM_log_PVT.logMessage (
4824 p_module_name => l_module,
4825 p_msg_text => 'After inv_convert.inv_um_convert '||
4826 ';l_converted_scrap_qty '||
4827 l_converted_scrap_qty,
4828 p_stmt_num => l_stmt_num,
4829 p_msg_tokens => l_msg_tokens,
4830 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
4831 p_run_log_level => l_log_level
4832 );
4833 END IF;
4834 if (l_debug = 'Y') then
4835 fnd_file.put_line(fnd_file.log, 'l_converted_scrap_qty='||l_converted_scrap_qty);
4836 end if;
4837
4838 -- ST : Serial Support ---
4839 -- Place the check here for qty ...
4840 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
4841 (
4842 -- ST : Demo issue : Commenting out : floor(l_scrap_qty) <> l_scrap_qty OR
4843 floor(l_converted_scrap_qty) <> l_converted_scrap_qty
4844 )
4845 THEN
4846 x_return_code := 1;
4847 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
4848 x_err_buf := FND_MESSAGE.GET;
4849
4850 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4851 return(x_return_code);
4852
4853 END IF;
4854 -- ST : Serial Support ---
4855
4856 END IF;
4857
4858
4859
4860 --EA: CZH:BUG2154720
4861
4862 -- Verify if the p_txn_qty is the same as the l_wo_qty_in_scrap, if undoing a scrap,
4863 -- ELSE check if it is the same as l_wo_qty. If not error out.
4864 --move enh 115.135 this check not needed here after perf check
4865 /* IF ((l_to_intraop_step = 5) AND (nvl(l_converted_txn_qty, nvl(l_converted_scrap_qty, 0))
4866 <> l_wmt_pri_scrap_qty)) THEN
4867 -- OR ((l_to_intraop_step <> 5) AND (nvl(l_converted_scrap_qty, 0)) <> nvl(l_wmt_scrap_qty, 0))) THEN
4868 x_return_code := 1;
4869 FND_MESSAGE.SET_NAME('WSM', 'WSM_SCRAP_QTY_INCORRECT');
4870 x_err_buf := FND_MESSAGE.GET;
4871
4872 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):
4873 '||x_err_buf);
4874
4875 return(x_return_code);
4876 END IF;
4877 */
4878 --move enh changed the IF condition
4879 --move enh
4880 IF ((l_to_intraop_step <> 5) AND (nvl(l_converted_txn_qty, 0) <> l_wo_qty)) THEN
4881 x_return_code := 1;
4882 /* IF ((l_to_intraop_step <> 5) OR (NVL(l_converted_txn_qty,0) <> 0)) THEN
4883 --if (p_txn_qty <> l_wo_qty) then -- CZH: BUG 2154720
4884 if (NVL(l_converted_txn_qty,0) <> l_wo_qty) then -- CZH: BUG 2154720*/
4885 x_return_code := 1;
4886
4887 --FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4888 --FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_quantity');
4889 FND_MESSAGE.SET_NAME('WSM', 'WSM_LOT_INVALID_CANDIDATE'); -- Fix for bug #2095253
4890 x_err_buf := FND_MESSAGE.GET;
4891
4892 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4893 return(x_return_code);
4894 end if;
4895 -- END IF;
4896
4897
4898 l_stmt_num := 450;
4899 -- If we are undoing a scrap operation, then get the scrap account from WLMTI
4900 --if (l_fm_intraop_step = WIP_CONSTANTS.SCRAP) then
4901 --move enh added the condition nvl(l_scrap_qty, 0) <> 0
4902 if ((l_to_intraop_step = WIP_CONSTANTS.SCRAP) OR (nvl(l_converted_scrap_qty, 0) <> 0)) then -- Changed to fix bug #2083671
4903
4904 select nvl(scrap_account_id,-1)
4905 into l_wlmti_scrap_acct_id
4906 from wsm_lot_move_txn_interface
4907 where header_id = p_header_id;
4908 l_stmt_num := 455;
4909
4910 --abb H optional scrap acc begin
4911 l_est_scrap_acc := wsmputil.wsm_esa_enabled(l_wip_entity_id,
4912 x_return_code,
4913 x_err_buf);
4914
4915 IF (x_return_code <> 0) THEN
4916 return(x_return_code);
4917 END IF;
4918
4919 select job_type
4920 into l_job_type
4921 from wip_discrete_jobs
4922 where wip_entity_id = l_wip_entity_id;
4923
4924 if l_est_scrap_acc = 2 or l_job_type = 3 then
4925 if l_wmt_scrap_acct_id = -1 then
4926 l_wmt_scrap_acct_id := null;
4927 end if;
4928 end if;
4929
4930 --abb H optional scrap acc begin
4931 if (l_wlmti_scrap_acct_id = -1) then -- Changed to fix bug #2083671
4932
4933 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4934 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account_id');
4935 x_err_buf := FND_MESSAGE.GET;
4936 l_error_msg := substr(l_error_msg||'WARNING: '||x_err_buf||'| ', 1, 2000);
4937 -- CZH.BUG2135538
4938 update wsm_lot_move_txn_interface
4939 set scrap_account_id = l_wmt_scrap_acct_id,
4940 --ERROR = 'WARNING:'||x_err_buf -- CZH.BUG2135538
4941 error = l_error_msg -- CZH.BUG2135538
4942 where header_id = p_header_id;
4943
4944 l_stmt_num := 460;
4945 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4946 --bug 5185751 modify line below since l_wmt_scrap_acct_id may be null
4947 --elsif (l_wmt_scrap_acct_id <> l_wlmti_scrap_acct_id) then
4948 elsif (nvl(l_wmt_scrap_acct_id, -1) <> l_wlmti_scrap_acct_id) then
4949 x_return_code := 1;
4950
4951 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4952 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'scrap_account');
4953 x_err_buf := FND_MESSAGE.GET;
4954
4955 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4956
4957 return(x_return_code);
4958 end if;
4959
4960 end if;
4961
4962 l_stmt_num := 470;
4963
4964 --NSO Modification by abedajna addition begin
4965 --move enh? first look at copy table
4966 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
4967 SET FM_DEPARTMENT_CODE = (select department_code
4968 from bom_departments
4969 where department_id = l_to_dept_id)
4970 WHERE WLMTI.header_id = p_header_id;
4971
4972 --***VJ Added for Performance Upgrade***--
4973 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
4974 x_return_code := 1;
4975
4976 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
4977 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_dept_id'); --bugfix 1587295: changed the token
4978 x_err_buf := FND_MESSAGE.GET;
4979
4980 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
4981 return(x_return_code);
4982 ELSE
4983 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
4984 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_department_code');
4985 x_err_buf := FND_MESSAGE.GET;
4986
4987 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
4988 END IF;
4989 --***VJ End Additions***--
4990
4991 l_stmt_num := 475;
4992 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
4993 SET TO_DEPARTMENT_CODE = (select department_code
4994 from bom_departments
4995 where department_id = l_fm_dept_id)
4996 WHERE WLMTI.header_id = p_header_id;
4997
4998 --***VJ Added for Performance Upgrade***--
4999 IF (SQL%ROWCOUNT = 0) OR (SQL%NOTFOUND) THEN
5000 x_return_code := 1;
5001
5002 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
5003 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_dept_id'); --bugfix 1587295: changed the token
5004 x_err_buf := FND_MESSAGE.GET;
5005
5006 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5007 return(x_return_code);
5008 ELSE
5009 FND_MESSAGE.SET_NAME('WSM', 'WSM_MODIFIED_FIELD');
5010 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'to_department_code');
5011 x_err_buf := FND_MESSAGE.GET;
5012
5013 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'):'||x_err_buf);
5014 END IF;
5015 --***VJ End Additions***--
5016
5017 --NSO Modification by abedajna addition end
5018
5019 l_stmt_num := 480;
5020 /* Call to make sure that the bwd move is ok if there are lot transactions */
5021 --move enh 115.136 changed the l_fm_intraop_step to l_to_intraop_step
5022
5023 IF (l_to_intraop_step = WIP_CONSTANTS.SCRAP) THEN
5024 IF (l_converted_txn_qty > 0) THEN
5025 l_bk_move_chk_qty := l_converted_txn_qty;
5026 ELSE
5027 l_bk_move_chk_qty := l_converted_scrap_qty;
5028 END IF;
5029 ELSE
5030 l_bk_move_chk_qty := NVL(l_converted_txn_qty,0);
5031 END IF;
5032
5033 x_return_code := 0;
5034 x_err_buf := '';
5035 --move enh replaced NVL(l_converted_txn_qty,0) with l_bk_move_chk_qty
5036 x_return_code := WSMPLBMI.validate_lot_txn_for_bk_move(p_org_id,
5037 l_wip_entity_id,
5038 -- NVL(l_converted_txn_qty,0), -- CZH: BUG2154720
5039 l_bk_move_chk_qty,
5040 l_txn_type,
5041 l_to_op_seq_num,
5042 l_to_op_code,
5043 l_to_intraop_step,
5044 l_fm_op_seq_num,
5045 l_fm_op_code,
5046 l_fm_intraop_step,
5047 l_wlmti_scrap_acct_id,
5048 x_err_buf);
5049
5050 if (x_return_code = 1) then
5051 return (x_return_code);
5052 end if;
5053
5054 l_stmt_num := 485;
5055 END IF; -- for Backward moves
5056
5057 -------------------------------------------------------------------------------------
5058 ----------------------------------END BACKWARD MOVES---------------------------------
5059 -------------------------------------------------------------------------------------
5060
5061 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
5062 SET acct_period_id = g_acct_period_id --***VJ Changed for Performance Upgrade***--
5063 WHERE WLMTI.header_id = p_header_id;
5064
5065 l_stmt_num := 490;
5066 IF (SQL%ROWCOUNT = 0) THEN
5067 x_return_code := 1;
5068
5069 FND_MESSAGE.SET_NAME('WSM', 'WSM_INFO_NOT_FOUND');
5070 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'acct_period_id');
5071 x_err_buf := FND_MESSAGE.GET;
5072
5073 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5074 return(x_return_code);
5075 END IF;
5076
5077
5078 --Bugfix 1765389. Moved the following validation to the beginning so that
5079 -- this validation is done for all txn types.
5080
5081 -- Validate primary and transaction UOM
5082
5083
5084 --***VJ Changed for Performance Upgrade***--
5085 SELECT msi.primary_uom_code
5086 INTO l_uom
5087 FROM mtl_system_items msi
5088 WHERE msi.inventory_item_id = l_primary_item_id
5089 AND msi.organization_id = p_org_id;
5090 --***VJ End Changes***--
5091 l_stmt_num := 495;
5092
5093 IF l_uom <> p_primary_uom THEN
5094 x_return_code := 1;
5095
5096 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_PRI_UOM');
5097 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'fm_op_seq_num/fm_intraop_step_type');
5098 x_err_buf := FND_MESSAGE.GET;
5099
5100 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5101 return(x_return_code);
5102 END IF;
5103
5104
5105 l_stmt_num := 500;
5106 -- Validate UOM and quantity
5107 l_converted_txn_qty := inv_convert.inv_um_convert (item_id => l_primary_item_id,
5108 precision => NULL,
5109 from_quantity => p_txn_qty,
5110 from_unit => p_txn_uom,
5111 to_unit => l_primary_uom,
5112 from_name => NULL,
5113 to_name => NULL);
5114 if (l_debug = 'Y') then
5115 fnd_file.put_line(fnd_file.log, ' after converting l_converted_txn_qty='||l_converted_txn_qty);
5116 end if;
5117
5118 -- ST : Serial Support ---
5119 -- Place the check here for qty also ...
5120 -- Why is qty derived in so many places..?
5121 IF l_serial_ctrl_code = 2 AND -- Pre-defined Serial controlled assembly...
5122 (-- ST : Demo issue : Commenting out : floor(p_txn_qty) <> p_txn_qty OR
5123 floor(l_converted_txn_qty) <> l_converted_txn_qty)
5124 THEN
5125 x_return_code := 1;
5126 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_JOB_TXN_QTY');
5127 x_err_buf := FND_MESSAGE.GET;
5128
5129 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5130 return(x_return_code);
5131
5132 END IF;
5133 -- ST : Serial Support ---
5134
5135 l_stmt_num := 505;
5136
5137 --move enh
5138 --bug 3615826 added the internal_scrap_txn_id column in WLMTI
5139 IF ((l_converted_txn_qty > 0) AND (l_converted_scrap_qty > 0)) THEN
5140 SELECT wip_transactions_s.nextval INTO l_scrap_txn_id from dual;
5141 END IF;
5142
5143 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5144 l_msg_tokens.delete;
5145 WSM_log_PVT.logMessage (
5146 p_module_name => l_module,
5147 p_msg_text => 'B4 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI'||
5148 ';l_converted_scrap_qty '||
5149 l_converted_scrap_qty,
5150 p_stmt_num => l_stmt_num,
5151 p_msg_tokens => l_msg_tokens,
5152 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
5153 p_run_log_level => l_log_level
5154 );
5155 END IF;
5156
5157 UPDATE WSM_LOT_MOVE_TXN_INTERFACE WLMTI
5158 SET primary_quantity = NVL(l_converted_txn_qty,0),
5159 primary_scrap_quantity = NVL(l_converted_scrap_qty,0),
5160 scrap_at_operation_flag = l_scrap_at_operation_flag,
5161 internal_scrap_txn_id = l_scrap_txn_id
5162 WHERE WLMTI.header_id = p_header_id;
5163
5164 l_stmt_num := 510;
5165 IF (SQL%ROWCOUNT = 0) THEN
5166 x_return_code := 1;
5167
5168 FND_MESSAGE.SET_NAME('WSM', 'WSM_UPDATE_INVALID');
5169 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'primary_quantity');
5170 x_err_buf := FND_MESSAGE.GET;
5171
5172 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5173 return(x_return_code);
5174 END IF;
5175
5176
5177 -------------------------------------------------------------------------------------
5178 ---------------------------------MOVE AND COMPLETION---------------------------------
5179 -------------------------------------------------------------------------------------
5180
5181 IF (l_txn_type IN (1, 2) ) THEN
5182
5183 BEGIN
5184 SELECT operation_seq_num
5185 INTO l_temp -- <> 0, if moving to the last op
5186 FROM bom_operation_sequences
5187 WHERE operation_seq_num = p_to_op_seq_num
5188 AND operation_sequence_id = l_end_op_seq_id;
5189 EXCEPTION
5190 WHEN OTHERS THEN
5191 l_temp := 0;
5192 END;
5193
5194 -- Bug# 1475494. For jumps, l_op_seq_id can be NULL, hence added nvl() to l_op_seq_id
5195 -- so that the flow goes into this IF condition and adds the new operation
5196
5197 -- Bug# 1658301. Added the OR condition in the following IF clause
5198 -- so that the IF condition doesn't fail when a move/jump is done
5199 -- after jumping outside the routing.
5200
5201 if (l_debug = 'Y') then
5202 fnd_file.put_line(fnd_file.log, ' l_wo_op_seq_id=' ||l_wo_op_seq_id
5203 ||' l_op_seq_id=' ||l_op_seq_id
5204 ||' l_wo_op_code=' ||l_wo_op_code
5205 ||' l_op_code=' ||l_op_code
5206 || 'l_end_op_seq_num='||l_end_op_seq_num
5207 ||' p_to_op_seq_num=' ||p_to_op_seq_num
5208 ||' l_temp=' ||l_temp);
5209 end if;
5210
5211 --NSO modification by abedajna begin
5212
5213 --** VJ: Start Deletions for removal of 9999 **--
5214 -- BA: CZH.BUG2168828
5215 -- IF ( l_temp <> 0 ) THEN
5216 --l_stmt_num := 512;
5217 -- WSMPOPRN.disable_operations (l_wip_entity_id,
5218 -- p_org_id,
5219 -- p_fm_op_seq_num,
5220 -- x_return_code,
5221 -- x_err_buf);
5222 --
5223 -- IF (x_return_code <> 0) THEN
5224 -- FND_MESSAGE.SET_NAME('WSM', 'WSM_DISABLE_OPS_FAILED');
5225 -- x_err_buf := FND_MESSAGE.GET;
5226 --
5227 -- fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5228 -- return(x_return_code);
5229 -- ELSE
5230 -- if (l_debug = 'Y') then
5231 -- fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
5232 -- ||'): Returned success from WSMPOPRN.disable_operations');
5233 -- end if;
5234 -- END IF;
5235 -- EA: CZH.BUG2168828
5236 --** VJ: End Deletions for removal of 9999 **--
5237
5238 --IF ( ( l_temp <> 0 ) OR
5239 IF ( (p_jump_flag = 'Y') OR
5240 ( (l_wo_op_seq_id is not null AND l_wo_op_seq_id <> nvl(l_op_seq_id,-1))
5241 OR
5242 (l_wo_op_seq_id is NULL AND l_wo_op_code <> nvl(l_op_code,-99))
5243 ) --NSO modification by abedajna end
5244 ) THEN
5245 --AND (l_temp = 0) THEN -- Fix for bug #1524416
5246
5247 if (l_op_code is not NULL) then
5248 l_stmt_num := 515;
5249 SELECT standard_operation_id
5250 INTO l_std_operation_id
5251 FROM bom_standard_operations
5252 WHERE operation_code = l_op_code
5253 AND organization_id = p_org_id;
5254 end if;
5255
5256 l_stmt_num := 520;
5257 --Added to fix bug #1496147
5258 SELECT unique max(operation_seq_num)
5259 INTO l_max_op_seq
5260 FROM wip_operations
5261 WHERE WIP_ENTITY_ID = l_wip_entity_id;
5262 --***VJ: Start Deletion for removal of 9999 ***--
5263 -- AND operation_seq_num NOT IN
5264 -- ( SELECT nvl(last_operation_seq_num, 9999)
5265 -- FROM wsm_parameters
5266 -- WHERE organization_id = p_org_id ) ;
5267 --***VJ: End Deletion for removal of 9999 ***--
5268 --End additions to fix bug #1496147
5269
5270 l_stmt_num := 525;
5271 -- NSO Modification by abedajna begin
5272 -- Changed the signature of the procedure so that l_op_seq_id is passed with l_std_operation_id.
5273 --move enh
5274 IF (l_scrap_at_operation_flag=2) THEN
5275 l_new_op_txn_qty := l_converted_txn_qty + nvl(l_converted_scrap_qty, 0);
5276 ELSE
5277 l_new_op_txn_qty := l_converted_txn_qty;
5278 END IF;
5279
5280 WSMPOPRN.add_operation(l_txn_type,
5281 1,
5282 l_wip_entity_id,
5283 p_org_id,
5284 l_wo_op_seq_num,
5285 --l_max_op_seq+l_op_seq_incr,
5286 l_max_op_seq+g_prev_op_seq_incr,
5287 --***VJ Changed for Performance Upgrade***--
5288 l_std_operation_id,
5289 l_op_seq_id,
5290 x_return_code,
5291 x_err_buf,
5292 l_new_op_txn_qty,
5293 l_recommended,
5294 p_to_op_seq_num,
5295 p_txn_date,
5296 'N',
5297 p_jump_flag);
5298 --move enh end
5299 l_stmt_num := 530;
5300 --NSO Modification by abedajna end
5301
5302 -- OSP FP I begin chages : added if condition 'if x_err_buf is null'
5303
5304 IF (x_return_code <> 0) THEN
5305 if x_err_buf is null then
5306 FND_MESSAGE.SET_NAME('WSM', 'WSM_INS_TBL_FAILED');
5307 FND_MESSAGE.SET_TOKEN('TABLE', 'wip_operations');
5308 x_err_buf := FND_MESSAGE.GET;
5309 end if;
5310
5311 -- OSP FP I end changes
5312
5313 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): '||x_err_buf);
5314 return(x_return_code);
5315 ELSE
5316 if (l_debug = 'Y') then
5317 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
5318 ||'): Returned success from WSMPOPRN.add_operation');
5319 end if;
5320
5321 END IF;
5322
5323 /* JUMP_ENH: Set the skip_flag to 1 if jump_from_queue is set to TRUE */
5324 l_stmt_num:=532;
5325 IF (l_jump_from_queue) THEN
5326 l_stmt_num:=533;
5327 update wip_operations
5328 set skip_flag=l_yes, -- Set skip_flag to Yes
5329 disable_date =p_txn_date -- Added this line for bug 5367603
5330 where organization_id = p_org_id
5331 and wip_entity_id = l_wip_entity_id
5332 and operation_seq_num= p_fm_op_seq_num;
5333 END IF;
5334
5335 if (l_debug = 'Y') then
5336 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num||'): ');
5337 end if;
5338
5339 --abb H Non Std Jobs
5340 IF (g_aps_wps_profile='N') THEN
5341 select job_type
5342 into l_job_type
5343 from wip_discrete_jobs
5344 where wip_entity_id = l_wip_entity_id;
5345
5346 select bom_reference_id,
5347 bom_revision_date,
5348 alternate_bom_designator
5349 into l_bom_reference_id,
5350 l_bom_revision_date,
5351 l_alt_bom_desig
5352 from wip_discrete_jobs
5353 where organization_id = p_org_id
5354 and wip_entity_id = l_wip_entity_id;
5355
5356 if l_job_type = 3 then
5357 l_primary_item_id := l_bom_reference_id;
5358 end if;
5359
5360 l_stmt_num := 535;
5361
5362 -- BA: CZH.BUGFIX 2350705
5363 -- call WSMPWROT.POPULATE_WRO only if move/jump within routing
5364 if(l_op_seq_id IS NOT NULL) then
5365 -- EA: CZH.BUGFIX 2350705
5366 --move enh changed p_txn_qty to l_new_op_txn_qty
5367 WSMPWROT.POPULATE_WRO (
5368 p_first_flag => 0, --l_first_flag,
5369 p_wip_entity_id => l_wip_entity_id,
5370 p_organization_id => p_org_id,
5371 p_assembly_item_id => l_primary_item_id,
5372 p_bom_revision_date => l_bom_revision_date,
5373 p_alt_bom => l_alt_bom_desig,
5374 -- p_quantity => p_txn_qty, -- CZH: BUG2154720 we may need to change it to primary qty
5375 p_quantity => l_new_op_txn_qty,
5376 p_operation_sequence_id => l_op_seq_id,
5377 x_err_code => x_return_code,
5378 x_err_msg => x_err_buf);
5379
5380 l_stmt_num := 540;
5381 IF (x_return_code <> 0) THEN
5382 -- use the error message returned from WSMPWROT.POPULATE_WRO
5383
5384 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='
5385 ||l_stmt_num||') calling WSMPWROT.POPULATE_WRO: '||x_err_buf);
5386 return(x_return_code);
5387 ELSE
5388 if (l_debug = 'Y') then
5389 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation(stmt_num='||l_stmt_num
5390 ||'): Returned success from WSMPWROT.POPULATE_WRO');
5391 end if;
5392 END IF;
5393 -- BA: CZH.BUGFIX 2350705
5394 end if; -- if(l_op_seq_id IS NOT NULL)
5395 -- EA: CZH.BUGFIX 2350705
5396 END IF; --(g_aps_wps_profile='N')
5397 END IF; -- ELSIF ( (p_jump_flag = 'Y')
5398 END IF;
5399
5400 -------------------------------------------------------------------------------------
5401 ---------------------------------END MOVE AND COMPLETION-----------------------------
5402 -------------------------------------------------------------------------------------
5403 IF ((g_aps_wps_profile='Y') AND (l_txn_type IN (3, 4))) THEN
5404 l_stmt_num := 550;
5405
5406 UPDATE WSM_LOT_BASED_JOBS wlbj
5407 SET wlbj.on_rec_path = l_recommended
5408 WHERE wlbj.wip_entity_id = l_wip_entity_id
5409 AND wlbj.organization_id = p_org_id
5410 AND wlbj.on_rec_path <> l_recommended;
5411 END IF;
5412
5413 x_return_code := 0;
5414 x_err_buf := NULL;
5415 if (l_debug = 'Y') then
5416 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.custom_validation' ||': Returned Success');
5417 end if;
5418
5419 return x_return_code;
5420
5421 EXCEPTION
5422 WHEN OTHERS THEN
5423 x_return_code := SQLCODE;
5424 x_err_buf := 'WSMPLBMI.custom_validation' ||'(stmt_num='||l_stmt_num||') : '||substrb(sqlerrm,1,1000);
5425 fnd_file.put_line(fnd_file.log, x_err_buf);
5426
5427 return x_return_code;
5428 END custom_validation;
5429
5430
5431 /*-------------------------------------------------------------+
5432 | validate_lot_txn_for_bk_move: |
5433 ---------------------------------------------------------------*/
5434
5435 /* This function is called by the WSM lot move txn form as well as the
5436 interface custom validation routine for validating the backward moves
5437 w.r.t the lot transactions */
5438
5439
5440 FUNCTION validate_lot_txn_for_bk_move( p_org_id IN NUMBER,
5441 p_wip_entity_id IN NUMBER,
5442 p_txn_qty IN NUMBER,
5443 p_txn_type IN NUMBER,
5444 p_from_op_seq_num IN NUMBER,
5445 p_from_op_code IN VARCHAR2,
5446 p_from_intraop_step_type IN NUMBER,
5447 p_to_op_seq_num IN NUMBER,
5448 p_to_op_code IN VARCHAR2,
5449 p_to_intraop_step_type IN NUMBER,
5450 p_scrap_acct_id IN NUMBER,
5451 x_err_buf OUT NOCOPY VARCHAR2)
5452 RETURN NUMBER IS
5453
5454 x_return_code NUMBER := 0;
5455 l_stmt_num NUMBER := 0;
5456 l_first_rtg_seq_id NUMBER := 0;
5457 l_current_rtg_seq_id NUMBER := 0;
5458 l_first_pri_item_id NUMBER := 0;
5459 l_current_pri_item_id NUMBER := 0;
5460 l_orig_mv_txn_qty NUMBER := 0;
5461 l_temp NUMBER := 0;
5462 l_wmt_time DATE := NULL; -- ADD: BUG2804111 use txn time
5463 l_wlt_time DATE := NULL; -- ADD: BUG2804111 use txn time
5464
5465 BEGIN
5466
5467 x_return_code := 0;
5468 x_err_buf := '';
5469
5470 l_stmt_num := 10;
5471 -- Check if the transaction is a backward move, if not, error out
5472
5473 IF (p_txn_type <> 4) THEN
5474 x_return_code := 1;
5475 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
5476 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_type');
5477 x_err_buf := FND_MESSAGE.GET;
5478 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.validate_lot_txn_for_bk_move(stmt_num='
5479 ||l_stmt_num||'): '||x_err_buf);
5480 return(x_return_code);
5481 END IF;
5482
5483
5484 l_stmt_num := 20;
5485 -- Get the routing seq id and primary item id from WDJ.
5486
5487 select nvl(COMMON_ROUTING_SEQUENCE_ID, ROUTING_REFERENCE_ID),
5488 PRIMARY_ITEM_ID
5489 into l_current_rtg_seq_id,
5490 l_current_pri_item_id
5491 from wip_discrete_jobs
5492 where organization_id = p_org_id
5493 and wip_entity_id = p_wip_entity_id;
5494
5495
5496 l_stmt_num := 30;
5497 -- Check if there was a move between the two operations , if not, then error out
5498
5499 BEGIN
5500 select distinct(wip_entity_id)
5501 into l_temp
5502 from wip_move_transactions
5503 where organization_id = p_org_id
5504 and wip_entity_id = p_wip_entity_id
5505 and FM_OPERATION_SEQ_NUM = p_to_op_seq_num
5506 and nvl(FM_OPERATION_CODE, '&&!!@@') = nvl(p_to_op_code, '&&!!@@')
5507 --NSO modification by abedajna
5508 and FM_INTRAOPERATION_STEP_TYPE = p_to_intraop_step_type
5509 and TO_OPERATION_SEQ_NUM = p_from_op_seq_num
5510 and nvl(TO_OPERATION_CODE, '&&!!@@') = nvl(p_from_op_code, '&&!!@@')
5511 --NSO modification by abedajna
5512 and TO_INTRAOPERATION_STEP_TYPE = p_from_intraop_step_type;
5513 EXCEPTION
5514 WHEN NO_DATA_FOUND THEN
5515 x_return_code := 1;
5516 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
5517 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'move');
5518 x_err_buf := FND_MESSAGE.GET;
5519 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.validate_lot_txn_for_bk_move(stmt_num='
5520 || l_stmt_num||'): '||x_err_buf);
5521 return(x_return_code);
5522 END;
5523
5524
5525 l_stmt_num := 40;
5526 -- BA: CZH.JUMPENH
5527 -- since the logic for UNDO is changed, this needed to be changed
5528 select PRIMARY_QUANTITY, -- CZH: BUG2154720
5529 transaction_date -- ADD: BUG2804111 use txn time
5530 into l_orig_mv_txn_qty,
5531 l_wmt_time -- ADD: BUG2804111 use txn time
5532 from wip_move_transactions
5533 where transaction_id = ( select max(wmt1.transaction_id)
5534 from wip_move_transactions wmt1
5535 where wmt1.organization_id = p_org_id
5536 and wmt1.wip_entity_id = p_wip_entity_id
5537 and wmt1.wsm_undo_txn_id IS NULL
5538 --move enh --FP bug 5178168 (base bug 5168406) changed the line below
5539 --and wmt1.transaction_id = wmt1.batch_id);
5540 and wmt1.transaction_id = nvl(wmt1.batch_id, wmt1.transaction_id));
5541
5542 -- EA: CZH.JUMPENH
5543
5544 -- Check if the original move qty is the same as the given txn qty. If not, error out
5545
5546 IF (l_orig_mv_txn_qty <> p_txn_qty) THEN
5547 x_return_code := 1;
5548 --FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
5549 --FND_MESSAGE.SET_TOKEN('FLD_NAME', 'transaction_quantity');
5550 FND_MESSAGE.SET_NAME('WSM', 'WSM_LOT_INVALID_CANDIDATE'); -- Fix for bug #2095253
5551 x_err_buf := FND_MESSAGE.GET;
5552 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.validate_lot_txn_for_bk_move(stmt_num='
5553 ||l_stmt_num||'): '||x_err_buf);
5554 return(x_return_code);
5555 END IF;
5556
5557
5558 -- BD: BUG2804111 use txn time, hence the following code lines are removed.
5559 -- BD: BUG2804111 use txn time
5560
5561 l_stmt_num := 90;
5562
5563 -- BA: BUG2804111 use txn time
5564 -- check if WLT exists after this move transaction
5565 BEGIN
5566 select max(wsmt.transaction_date)
5567 into l_wlt_time
5568 from wsm_split_merge_transactions wsmt,
5569 wsm_sm_starting_jobs wssj
5570 where wsmt.organization_id = p_org_id
5571 and wsmt.transaction_id = wssj.transaction_id
5572 and wssj.wip_entity_id = p_wip_entity_id;
5573 EXCEPTION
5574 WHEN NO_DATA_FOUND THEN
5575 l_wlt_time := NULL;
5576 END;
5577
5578 if(l_wlt_time IS NOT NULL) then
5579 if(l_wlt_time > l_wmt_time) then
5580 x_return_code := 1;
5581 end if;
5582 end if;
5583 -- EA: BUG2804111 use txn time
5584
5585
5586 return(x_return_code);
5587
5588 EXCEPTION
5589 WHEN OTHERS THEN
5590 x_return_code := SQLCODE;
5591 x_err_buf := 'WSMPLBMI.validate_lot_txn_for_bk_move' ||'(stmt_num='||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
5592 fnd_file.put_line(fnd_file.log, x_err_buf);
5593 return x_return_code;
5594 END validate_lot_txn_for_bk_move;
5595
5596
5597
5598
5599 /*-------------------------------------------------------------+
5600 | set_undo_txn_id:
5601 ---------------------------------------------------------------*/
5602
5603
5604 -- BA: CZH.JUMPENH, new undo logic
5605 FUNCTION set_undo_txn_id( p_org_id IN NUMBER,
5606 p_wip_entity_id IN NUMBER,
5607 p_undo_txn_id IN NUMBER,
5608 x_err_buf OUT NOCOPY VARCHAR2
5609 )
5610 RETURN NUMBER IS
5611 -- x_undone_txn_id number;
5612 x_undone_batch_id number;
5613 l_stmt_num NUMBER;
5614 x_return_code NUMBER;
5615 -- Logging variables.....
5616 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5617 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5618 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.set_undo_txn_id';
5619 l_param_tbl WSM_Log_PVT.param_tbl_type;
5620 l_return_status VARCHAR2(1);
5621 l_msg_count number;
5622 l_msg_data varchar2(4000);
5623 BEGIN
5624 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5625 l_msg_tokens.delete;
5626 WSM_log_PVT.logMessage (
5627 p_module_name => l_module,
5628 p_msg_text => 'Begin set_undo_txn_id '
5629 ||';p_org_id '
5630 ||p_org_id
5631 ||';p_wip_entity_id '
5632 ||p_wip_entity_id
5633 ||';p_undo_txn_id '
5634 ||p_undo_txn_id,
5635 p_stmt_num => l_stmt_num,
5636 p_msg_tokens => l_msg_tokens,
5637 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
5638 p_run_log_level => l_log_level
5639 );
5640 END IF;
5641 x_return_code := 0;
5642
5643 l_stmt_num := 10;
5644 -- find the transaction id that is just undone
5645 --move enh? use the condition from_op <= to OR use batch_id to identify the undone txns
5646 --FP bug 5178168 (base bug 5168406) changed the line below
5647 --select max(batch_id)
5648 select max(nvl(batch_id, transaction_id))
5649 -- into x_undone_txn_id
5650 into x_undone_batch_id
5651 from wip_move_transactions
5652 where organization_id = p_org_id
5653 and wip_entity_id = p_wip_entity_id
5654 and wsm_undo_txn_id IS NULL
5655 --FP bug 5178168 (base bug 5168406) changed the line below
5656 --and batch_id < p_undo_txn_id;
5657 and nvl(batch_id, transaction_id) < p_undo_txn_id;
5658
5659 if (l_debug = 'Y') then
5660 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.set_undo_txn_id(stmt_num=' || l_stmt_num || '): p_undo_txn_id ' ||p_undo_txn_id||' x_undone_batch_id '||x_undone_batch_id);
5661 end if;
5662
5663 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5664 l_msg_tokens.delete;
5665 WSM_log_PVT.logMessage (
5666 p_module_name => l_module,
5667 p_msg_text => 'x_undone_batch_id '
5668 ||x_undone_batch_id,
5669 p_stmt_num => l_stmt_num,
5670 p_msg_tokens => l_msg_tokens,
5671 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
5672 p_run_log_level => l_log_level
5673 );
5674 END IF;
5675 -- update transaction idi, so that
5676 --move enh
5677 l_stmt_num := 20;
5678 update wip_move_transactions
5679 --FP bug 5178168 (base bug 5168406) changed the line below
5680 --set wsm_undo_txn_id = decode(batch_id,
5681 set wsm_undo_txn_id = decode(nvl(batch_id, transaction_id),
5682 p_undo_txn_id, x_undone_batch_id,
5683 p_undo_txn_id)
5684 where organization_id = p_org_id
5685 and wip_entity_id = p_wip_entity_id
5686 -- and transaction_id in (p_undo_txn_id, x_undone_txn_id);
5687 --FP bug 5178168 (base bug 5168406) changed the line below
5688 --and batch_id in (p_undo_txn_id, x_undone_batch_id);
5689 and nvl(batch_id, transaction_id) in (p_undo_txn_id, x_undone_batch_id);
5690
5691 /* update wip_move_transactions
5692 set wsm_undo_txn_id = x_undone_batch_id
5693 where organization_id = p_org_id
5694 and wip_entity_id = p_wip_entity_id
5695 -- and transaction_id in (p_undo_txn_id, x_undone_txn_id);
5696 and batch_id = p_undo_txn_id;
5697
5698 update wip_move_transactions
5699 set wsm_undo_txn_id = p_undo_txn_id
5700 where organization_id = p_org_id
5701 and wip_entity_id = p_wip_entity_id
5702 -- and transaction_id in (p_undo_txn_id, x_undone_txn_id);
5703 and batch_id = x_undone_batch_id;
5704 */
5705 return(x_return_code);
5706
5707 EXCEPTION
5708 WHEN NO_DATA_FOUND THEN
5709 x_return_code := 1;
5710 FND_MESSAGE.SET_NAME('WSM', 'WSM_SET_UNDO_TXN_ID_FAILED');
5711 x_err_buf := FND_MESSAGE.GET;
5712 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.set_undo_txn_id(stmt_num=' ||
5713 l_stmt_num || '): ' ||x_err_buf);
5714 return(x_return_code);
5715
5716 WHEN OTHERS THEN
5717 x_return_code := SQLCODE;
5718 x_err_buf := 'WSMPLBMI.set_undo_txn_id' ||'(stmt_num='||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
5719 fnd_file.put_line(fnd_file.log, x_err_buf);
5720 return x_return_code;
5721
5722 END set_undo_txn_id;
5723
5724 -- EA: CZH.JUMPENH
5725
5726 /* JUMP_ENH: Overloaded the following function so that the original
5727 set_undo_txn_id is called after resetting the skip_flag to 2 */
5728 FUNCTION set_undo_txn_id( p_org_id IN NUMBER,
5729 p_wip_entity_id IN NUMBER,
5730 p_undo_txn_id IN NUMBER,
5731 p_to_op_seq_num IN NUMBER,
5732 p_undo_jump_fromq IN BOOLEAN,
5733 x_err_buf OUT NOCOPY VARCHAR2
5734 )
5735 RETURN NUMBER IS
5736 l_yes NUMBER:=1;
5737 l_no NUMBER:=2;
5738 l_stmt_num NUMBER;
5739 x_return_code NUMBER := 0;
5740 BEGIN
5741 l_stmt_num := 30;
5742 if (p_undo_jump_fromq) then
5743 l_stmt_num := 40;
5744 update wip_operations
5745 set skip_flag=l_no,
5746 disable_date = null -- Added this line for bug 5367603
5747 where organization_id = p_org_id
5748 and wip_entity_id = p_wip_entity_id
5749 and operation_seq_num=p_to_op_seq_num
5750 and skip_flag=l_yes;
5751 end if;
5752
5753 x_return_code:=set_undo_txn_id(p_org_id,
5754 p_wip_entity_id,
5755 p_undo_txn_id,
5756 x_err_buf);
5757
5758 return(x_return_code);
5759
5760 EXCEPTION
5761 WHEN NO_DATA_FOUND THEN
5762 x_return_code := 1;
5763 FND_MESSAGE.SET_NAME('WSM', 'WSM_SET_UNDO_TXN_ID_FAILED');
5764 x_err_buf := FND_MESSAGE.GET;
5765 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.set_undo_txn_id(stmt_num=' ||
5766 l_stmt_num || '): ' ||x_err_buf);
5767 return(x_return_code);
5768
5769 WHEN OTHERS THEN
5770 x_return_code := SQLCODE;
5771 x_err_buf := 'WSMPLBMI.set_undo_txn_id' ||'(stmt_num='||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
5772 fnd_file.put_line(fnd_file.log, x_err_buf);
5773 return x_return_code;
5774
5775 END set_undo_txn_id;
5776
5777 /******************************
5778 * Move Enhancements *
5779 ******************************/
5780 --move enh
5781 PROCEDURE copy_WTIE_to_WIE(x_error_code OUT NOCOPY NUMBER,
5782 x_error_msg OUT NOCOPY VARCHAR2,
5783 p_header_id IN NUMBER,
5784 p_transaction_id IN NUMBER,
5785 p_error_message IN VARCHAR2)
5786
5787 IS
5788 PRAGMA autonomous_transaction;
5789 l_stmt_num NUMBER;
5790 l_wmt_group_id NUMBER;
5791 l_transaction_id NUMBER;
5792 BEGIN
5793 l_stmt_num := 10;
5794 fnd_file.put_line(fnd_file.log,'Inside copy_WTIE_to_WIE...');
5795
5796 l_stmt_num := 40;
5797 INSERT INTO WSM_INTERFACE_ERRORS (
5798 HEADER_ID,
5799 TRANSACTION_ID,
5800 MESSAGE,
5801 LAST_UPDATE_DATE,
5802 LAST_UPDATED_BY,
5803 CREATION_DATE,
5804 CREATED_BY,
5805 LAST_UPDATE_LOGIN,
5806 REQUEST_ID,
5807 PROGRAM_ID,
5808 PROGRAM_APPLICATION_ID,
5809 MESSAGE_TYPE )
5810 VALUES (p_header_id
5811 , p_transaction_id
5812 , p_error_message
5813 , SYSDATE
5814 , g_user_id
5815 , SYSDATE
5816 , g_user_id
5817 , g_login_id
5818 , g_request_id
5819 , g_program_id
5820 , g_program_application_id
5821 , 1);
5822
5823 COMMIT;
5824
5825 EXCEPTION
5826 WHEN OTHERS THEN
5827 x_error_code := SQLCODE;
5828 x_error_msg := substrb('WSMPLMTI.copy_WTIE_to_WIE' ||'(stmt_num='||l_stmt_num||') : '||sqlerrm, 1,4000);
5829 FND_FILE.PUT_LINE(FND_FILE.LOG, x_error_msg);
5830
5831 END copy_WTIE_to_WIE;
5832
5833 PROCEDURE update_txn_status(x_error_code OUT NOCOPY NUMBER
5834 , x_error_msg OUT NOCOPY VARCHAR2
5835 , p_group_id IN NUMBER
5836 , p_wmti_group_id IN NUMBER)
5837 IS
5838 l_stmt_num NUMBER;
5839 BEGIN
5840 l_stmt_num := 10;
5841 --move enh this logic is based on the fact that if even a single txn in WMTI errors out
5842 --WIP API will rollback all processing.
5843 UPDATE wsm_lot_move_txn_interface WLMTI
5844 SET status = 4
5845 WHERE WLMTI.internal_group_id=p_wmti_group_id
5846 AND WLMTI.group_id=p_group_id;
5847
5848 EXCEPTION
5849 WHEN OTHERS THEN
5850 x_error_code := SQLCODE;
5851 x_error_msg := substrb('WSMPLMTI.update_txn_status' ||'(stmt_num='||l_stmt_num||') : '||sqlerrm, 1,4000);
5852 FND_FILE.PUT_LINE(FND_FILE.LOG, x_error_msg);
5853 END update_txn_status;
5854
5855
5856 PROCEDURE error_handler(x_error_code OUT NOCOPY NUMBER,
5857 x_error_msg OUT NOCOPY VARCHAR2,
5858 p_header_id IN NUMBER,
5859 p_transaction_id IN NUMBER,
5860 p_error_msg IN VARCHAR2)
5861 IS
5862
5863 l_stmt_num NUMBER;
5864 l_transaction_id NUMBER;
5865 BEGIN
5866 l_stmt_num := 10;
5867 fnd_file.put_line(fnd_file.log, 'Inside error_handler '||'p_error_msg='||p_error_msg||' p_header_id='||' p_txn_id='||p_transaction_id);
5868 WSMPUTIL.AUTONOMOUS_TXN(p_user=> g_user_id,
5869 p_login=> g_login_id,
5870 p_header_id => p_header_id,
5871 p_message => p_error_msg,
5872 p_request_id => g_request_id,
5873 p_program_id => g_program_id,
5874 p_program_application_id => g_program_application_id,
5875 p_message_type => 1, --ERROR
5876 p_txn_id => p_transaction_id,
5877 x_err_code => x_error_code,
5878 x_err_msg => x_error_msg);
5879
5880 if (x_error_code <> 0) then
5881 x_error_msg := 'WSMPLMTI.error_handler' ||'(stmt_num='||l_stmt_num||') : '||substrb(x_error_msg, 1,4000);
5882 fnd_file.put_line(fnd_file.log, x_error_msg);
5883 return;
5884 end if;
5885
5886 l_stmt_num := 20;
5887 UPDATE wsm_lot_move_txn_interface
5888 SET status = 3,
5889 ERROR = g_fnd_generic_err_msg
5890 WHERE header_id = p_header_id;
5891
5892 fnd_file.put_line(fnd_file.log, 'Errors populated in wsm_interface_errors table');
5893 EXCEPTION
5894 WHEN OTHERS THEN
5895 x_error_code := SQLCODE;
5896 x_error_msg := substrb('WSMPLMTI.error_handler' ||'(stmt_num='||l_stmt_num||') : '||sqlerrm, 1,4000);
5897 FND_FILE.PUT_LINE(FND_FILE.LOG, x_error_msg);
5898 END error_handler;
5899
5900 Procedure update_int_grp_id(x_error_code OUT NOCOPY NUMBER,
5901 x_error_msg OUT NOCOPY VARCHAR2,
5902 p_header_id IN NUMBER,
5903 p_wmti_group_id IN NUMBER)
5904 IS
5905 BEGIN
5906 UPDATE wsm_lot_move_txn_interface
5907 SET internal_group_id = p_wmti_group_id
5908 WHERE header_id = p_header_id;
5909 END;
5910
5911 Procedure MoveTransaction (retcode OUT NOCOPY NUMBER,
5912 errbuf OUT NOCOPY VARCHAR2,
5913 p_group_id IN NUMBER)
5914 IS
5915 p_sec_uom_code_tbls t_sec_uom_code_tbls_type ;
5916 p_sec_move_out_qty_tbls t_sec_move_out_qty_tbls_type;
5917 p_jobop_scrap_serials_tbls t_scrap_serials_tbls_type;
5918 p_jobop_bonus_serials_tbls t_bonus_serials_tbls_type;
5919 p_scrap_codes_tbls t_scrap_codes_tbls_type;
5920 p_scrap_code_qty_tbls t_scrap_code_qty_tbls_type;
5921 p_bonus_codes_tbls t_bonus_codes_tbls_type;
5922 p_bonus_code_qty_tbls t_bonus_code_qty_tbls_type;
5923 p_jobop_resource_usages_tbls t_jobop_res_usages_tbls_type;
5924 x_wip_move_api_sucess_msg VARCHAR2(1);
5925 BEGIN
5926
5927 MoveTransaction(
5928 p_group_id => p_group_id,
5929 p_bonus_account_id => null,
5930 p_employee_id => null,
5931 p_operation_start_date => null,
5932 p_operation_completion_date => null,
5933 p_expected_completion_date => null,
5934 p_bonus_quantity => null,
5935 p_low_yield_trigger_limit => null,
5936 p_source_code => null,
5937 p_mtl_txn_hdr_id => null,
5938 p_sec_uom_code_tbls => p_sec_uom_code_tbls,
5939 p_sec_move_out_qty_tbls => p_sec_move_out_qty_tbls,
5940 p_jobop_scrap_serials_tbls => p_jobop_scrap_serials_tbls,
5941 p_jobop_bonus_serials_tbls => p_jobop_bonus_serials_tbls,
5942 p_scrap_codes_tbls => p_scrap_codes_tbls,
5943 p_scrap_code_qty_tbls => p_scrap_code_qty_tbls,
5944 p_bonus_codes_tbls => p_bonus_codes_tbls,
5945 p_bonus_code_qty_tbls => p_bonus_code_qty_tbls,
5946 p_jobop_resource_usages_tbls => p_jobop_resource_usages_tbls,
5947 x_wip_move_api_sucess_msg => x_wip_move_api_sucess_msg,
5948 retcode => retcode,
5949 errbuf => errbuf
5950 );
5951
5952 END;
5953
5954 Procedure add_Resource_error_info(
5955 p_resource_id IN NUMBER
5956 , p_resource_instance_id IN NUMBER
5957 , p_resource_serial_number IN VARCHAR2
5958 , p_organization_id IN NUMBER
5959 )
5960 IS
5961 l_resource_code VARCHAR2(10) := null;
5962 l_resource_instance VARCHAR2(4000) := null;
5963 l_stmt_num NUMBER := 0;
5964 BEGIN
5965 l_stmt_num := 110.192;
5966 SELECT resource_code
5967 INTO l_resource_code
5968 FROM BOM_RESOURCES
5969 WHERE resource_id = p_resource_id
5970 AND organization_id = p_organization_id;
5971
5972 l_stmt_num := 110.193;
5973 IF (p_resource_instance_id IS NOT NULL) THEN
5974 select decode(p_resource_serial_number,
5975 NULL, msik.concatenated_segments,
5976 msik.concatenated_segments||':'||p_resource_serial_number)
5977 into l_resource_instance
5978 from bom_resource_equipments bre, mtl_system_items_kfv msik
5979 where bre.inventory_item_id = msik.inventory_item_id
5980 and bre.organization_id = msik.organization_id
5981 and bre.resource_id = p_resource_id
5982 and bre.instance_id = p_resource_instance_id
5983 and bre.organization_id = p_organization_id;
5984
5985 FND_MESSAGE.SET_NAME('WSM','WSM_MES_INS_ERR_INFO');
5986 FND_MESSAGE.SET_TOKEN('RESOURCE', l_resource_code);
5987 FND_MESSAGE.SET_TOKEN('INSTANCE', l_resource_instance);
5988 ELSE
5989 FND_MESSAGE.SET_NAME('WSM','WSM_MES_RES_ERR_INFO');
5990 FND_MESSAGE.SET_TOKEN('RESOURCE', l_resource_code);
5991 END IF;
5992
5993 FND_MSG_PUB.add;
5994 END add_Resource_error_info;
5995
5996 Function reason_code_err_info(
5997 p_reason_code_num IN NUMBER
5998 , p_reason_code_type IN NUMBER
5999 )
6000 RETURN VARCHAR2
6001 IS
6002 x_reason_code VARCHAR2(80);
6003 BEGIN
6004 IF (p_reason_code_type = 1) THEN
6005 SELECT ML.meaning
6006 INTO x_reason_code
6007 FROM MFG_LOOKUPS ML
6008 WHERE ML.lookup_type = 'BOM_SCRAP_CODES'
6009 AND ML.lookup_code = p_reason_code_num;
6010 ELSE
6011 SELECT ML.meaning
6012 INTO x_reason_code
6013 FROM MFG_LOOKUPS ML
6014 WHERE ML.lookup_type = 'BOM_BONUS_CODES'
6015 AND ML.lookup_code = p_reason_code_num;
6016 END IF;
6017
6018 return x_reason_code;
6019 END reason_code_err_info;
6020
6021 Procedure MoveTransaction(
6022 p_group_id IN NUMBER,
6023 p_bonus_account_id IN NUMBER,
6024 p_employee_id IN NUMBER,
6025 p_operation_start_date IN DATE,
6026 p_operation_completion_date IN DATE,
6027 p_expected_completion_date IN DATE,
6028 p_bonus_quantity IN NUMBER,
6029 p_low_yield_trigger_limit IN NUMBER,
6030 p_source_code IN wsm_lot_move_txn_interface.source_code%type,
6031 p_mtl_txn_hdr_id IN NUMBER,
6032 p_sec_uom_code_tbls IN t_sec_uom_code_tbls_type,
6033 p_sec_move_out_qty_tbls IN t_sec_move_out_qty_tbls_type,
6034 p_jobop_scrap_serials_tbls IN t_scrap_serials_tbls_type,
6035 p_jobop_bonus_serials_tbls IN t_bonus_serials_tbls_type,
6036 p_scrap_codes_tbls IN t_scrap_codes_tbls_type,
6037 p_scrap_code_qty_tbls IN t_scrap_code_qty_tbls_type,
6038 p_bonus_codes_tbls IN t_bonus_codes_tbls_type,
6039 p_bonus_code_qty_tbls IN t_bonus_code_qty_tbls_type,
6040 p_jobop_resource_usages_tbls IN t_jobop_res_usages_tbls_type,
6041 x_wip_move_api_sucess_msg OUT NOCOPY VARCHAR2,
6042 retcode OUT NOCOPY NUMBER,
6043 errbuf OUT NOCOPY VARCHAR2
6044 )
6045 IS
6046
6047 l_count NUMBER;
6048 l_done NUMBER;
6049 l_header_id NUMBER;
6050 l_organization_id NUMBER;
6051 l_undo_txn_id NUMBER;
6052 l_transaction_id NUMBER;
6053 l_fm_op_seq_num NUMBER;
6054 l_to_op_seq_num NUMBER;
6055 l_transaction_type NUMBER;
6056 l_max_op_seq NUMBER;
6057 l_wip_entity_id NUMBER;
6058 l_to_dept_id NUMBER;
6059 l_txn_type NUMBER;
6060 l_dup_flag NUMBER;
6061 l_job_exists NUMBER;
6062 l_error_code NUMBER;
6063 l_wmti_group_id NUMBER;
6064 l_total_txns NUMBER :=0;
6065 l_charge_jump_from_queue NUMBER := 1;
6066 l_transaction_uom VARCHAR2(3);
6067 l_fm_operation_code VARCHAR2(4);
6068 l_to_operation_code VARCHAR2(4);
6069 l_jump_flag VARCHAR2(1);
6070 l_wip_entity_name VARCHAR2(240);
6071 l_primary_uom VARCHAR2(3);
6072 l_transaction_date DATE;
6073 l_error_msg VARCHAR2(4000);
6074 l_subinventory VARCHAR2(10);
6075 l_new_jobname VARCHAR2(240);
6076 l_rowid VARCHAR2(2000);
6077 l_rtg_revision_date VARCHAR2(30);
6078 l_transaction_quantity NUMBER := 0;
6079 l_txn_qty NUMBER;
6080 l_stmt_num NUMBER := 0;
6081 l_err_flag NUMBER := 0;
6082 --bug 3347485
6083 -- l_pre_org_id NUMBER := 0;
6084 l_pre_org_id NUMBER := -9999;
6085 --end bug 3347485
6086 l_ac_ar_exists NUMBER := 0;
6087 l_undo_exists NUMBER := 0;
6088 l_first_time NUMBER := 0;
6089 l_outer_loop NUMBER := 1;
6090 l_inserted_wmti NUMBER := 0;
6091 l_n_rows NUMBER := 0;
6092 i NUMBER := 0;
6093 l_scrap_at_operation_flag NUMBER := 0;
6094 l_scrap_qty NUMBER := 0;
6095 l_scrap_txn_id NUMBER := 0;
6096 x_scrap_move_txn_id NUMBER := 0;
6097 l_conc_status BOOLEAN;
6098 l_wro_op_seq_num NUMBER;
6099 l_batch_id NUMBER;
6100 l_op_flag NUMBER;
6101 l_end_op_seq_id NUMBER;
6102 l_converted_scrap_qty NUMBER := 0;
6103 l_fm_intraoperation_step_type NUMBER;
6104 l_to_intraoperation_step_type NUMBER;
6105 l_routing_seq_id NUMBER;
6106 l_to_op_seq_id NUMBER;
6107 l_fm_op_seq_id NUMBER;
6108 l_wmti_err_txns NUMBER := 0;
6109 l_success NUMBER := 0;
6110 x_returnStatus VARCHAR2(1);
6111 x_return_code NUMBER := 0;
6112 l_new_op_txn_qty NUMBER;
6113 l_primary_quantity NUMBER;
6114
6115 CURSOR C_TXNS IS
6116 SELECT rowid,
6117 header_id,
6118 transaction_id,
6119 transaction_quantity,
6120 transaction_date,
6121 transaction_uom,
6122 transaction_type,
6123 fm_operation_seq_num,
6124 fm_operation_code,
6125 fm_intraoperation_step_type,
6126 to_operation_seq_num,
6127 to_operation_code,
6128 to_intraoperation_step_type,
6129 to_department_id,
6130 primary_uom,
6131 wip_entity_id,
6132 wip_entity_name,
6133 organization_id,
6134 nvl(jump_flag, 'N'), --bug 5469479 added nvl
6135 scrap_at_operation_flag,
6136 scrap_quantity,
6137 serial_start_flag -- ST : Serial Support Project --
6138 FROM wsm_lot_move_txn_interface
6139 WHERE group_id = p_group_id
6140 AND status = g_running -- WIP_CONSTANTS.RUNNING --Added condition to fix bug #1815584
6141 ORDER BY transaction_date, organization_id, wip_entity_id, processing_order;
6142
6143 --move enh To be used when we switch to the new logging scheme
6144 /* l_current_runtime_level NUMBER := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6145 l_module := 'WSM.Plsql.WSMPLMTI.MoveTransactions';
6146 l_level_unexpected := FND_LOG.LEVEL_UNEXPECTED;
6147 l_level_error := FND_LOG.LEVEL_ERROR;
6148 l_level_exception := FND_LOG.LEVEL_EXCEPTION;
6149 l_level_event := FND_LOG.LEVEL_EVENT;
6150 l_level_procedure := FND_LOG.LEVEL_PROCEDURE;
6151 l_level_statement := FND_LOG.LEVEL_STATEMENT; */
6152 x_error_msg VARCHAR2(4000);
6153 x_err_code NUMBER;
6154 x_error_code NUMBER;
6155 e_proc_exception EXCEPTION;
6156 my_exception EXCEPTION;
6157 x_err_msg VARCHAR2(4000);
6158 l_no_txns NUMBER :=0;
6159 l_del_profile_value NUMBER;
6160 l_job_copy_flag NUMBER;
6161
6162 -- ST : Serial Support Project ---
6163 type t_number is table of number index by binary_integer;
6164
6165 l_header_id_tbl t_number;
6166 l_primary_item_id NUMBER;
6167 l_serial_ctrl_code NUMBER;
6168 l_available_qty NUMBER;
6169 l_current_job_op_seq_num NUMBER;
6170 l_current_intraop_step NUMBER;
6171 l_current_rtg_op_seq_num NUMBER;
6172 l_old_scrap_transaction_id NUMBER;
6173 l_old_move_transaction_id NUMBER;
6174 l_user_serial_tracking NUMBER;
6175 -- ST : Serial Support Project ---
6176
6177 --MES
6178 l_total_scrap_code_qty NUMBER := 0;
6179 l_total_bonus_code_qty NUMBER := 0;
6180 l_mtl_txn_profile NUMBER;
6181 l_cpl_txn_id NUMBER;
6182 l_return_status VARCHAR2(1);
6183 l_max_acceptable_scrap_qty NUMBER;
6184 l_put_job_on_hold NUMBER;
6185 l_reason_id wsm_lot_move_txn_interface.reason_id%TYPE;
6186 l_transaction_reference wsm_lot_move_txn_interface.reference%TYPE;
6187 l_job_to_op_seq_num wsm_lot_move_txn_interface.to_operation_seq_num%TYPE;
6188 x_return_status VARCHAR2(1);
6189 x_msg_count NUMBER;
6190
6191 l_wltx_transactions_rec WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE;
6192 l_wltx_starting_job_tbl WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE;
6193 l_wltx_resulting_job_tbl WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE;
6194 l_wltx_secondary_qty_tbl WSM_WIP_LOT_TXN_PVT.WSM_JOB_SECONDARY_QTY_TBL_TYPE;
6195 l_WSM_SERIAL_NUM_TBL WSM_SERIAL_SUPPORT_GRP.WSM_SERIAL_NUM_TBL;
6196 l_wip_include_comp_yield NUMBER;
6197 --Bug 5480482:Following variable declaration is commented.
6198 --l_wco_fm_op_network_start WSM_COPY_OPERATIONS.network_start_end%TYPE;
6199 --l_wco_to_op_network_end WSM_COPY_OPERATIONS.network_start_end%TYPE;
6200 --l_wo_min_op_seq_num NUMBER;
6201 l_undone_txn_source_code WIP_MOVE_TRANSACTIONS.source_code%type;
6202 l_mes_scrap_txn_id NUMBER; --bug 5446252
6203 --MES END
6204
6205 l_temp_txn_type NUMBER; --bug 4380374
6206 -- Logging variables.....
6207 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
6208 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6209 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.wsmplbmi.movetransaction.main';
6210 l_param_tbl WSM_Log_PVT.param_tbl_type;
6211 -- Logging variables...
6212
6213 BEGIN
6214 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
6215 l_msg_tokens.delete;
6216 WSM_log_PVT.logMessage (
6217 p_module_name => l_module ,
6218 p_msg_text => 'Begin MoveTransactions Main',
6219 p_stmt_num => l_stmt_num ,
6220 p_msg_tokens => l_msg_tokens ,
6221 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
6222 p_run_log_level => l_log_level
6223 );
6224 END IF;
6225
6226 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
6227
6228 l_param_tbl.delete;
6229 l_param_tbl(1).paramName := 'p_group_id';
6230 l_param_tbl(1).paramValue := p_group_id;
6231 l_param_tbl(2).paramName := 'p_bonus_account_id';
6232 l_param_tbl(2).paramValue := p_bonus_account_id;
6233 l_param_tbl(3).paramName := 'p_employee_id';
6234 l_param_tbl(3).paramValue := p_employee_id;
6235 l_param_tbl(4).paramName := 'p_operation_start_date';
6236 l_param_tbl(5).paramValue := p_operation_start_date;
6237 l_param_tbl(6).paramName := 'p_operation_completion_date';
6238 l_param_tbl(6).paramValue := p_operation_completion_date;
6239 l_param_tbl(7).paramName := 'p_expected_completion_date';
6240 l_param_tbl(7).paramValue := p_expected_completion_date;
6241 l_param_tbl(8).paramName := 'p_bonus_quantity';
6242 l_param_tbl(8).paramValue := p_bonus_quantity;
6243 l_param_tbl(9).paramName := 'p_low_yield_trigger_limit';
6244 l_param_tbl(9).paramValue := p_low_yield_trigger_limit;
6245 l_param_tbl(10).paramName := 'p_source_code';
6246 l_param_tbl(10).paramValue := p_source_code;
6247 l_param_tbl(11).paramName := 'p_mtl_txn_hdr_id';
6248 l_param_tbl(11).paramValue := p_mtl_txn_hdr_id;
6249
6250 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
6251 p_param_tbl => l_param_tbl,
6252 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE
6253 );
6254 END IF;
6255
6256
6257 l_stmt_num := 10;
6258 --move enh? to be removed
6259 IF (l_debug = 'Y') THEN
6260 fnd_file.put_line(fnd_file.log, 'Inside Move Worker....');
6261 --dmfut11i
6262 /* fnd_global.apps_initialize(user_id => 1006484,
6263 resp_id => 22435,
6264 resp_appl_id => 410);
6265 fnd_file.put_line(fnd_file.log, 'session ID = ' || fnd_global.session_id);
6266
6267 --dmfdv11i
6268 fnd_global.apps_initialize(user_id => 1005369,
6269 resp_id => 50511,
6270 resp_appl_id => 700);
6271 fnd_file.put_line(fnd_file.log, 'session ID = ' || fnd_global.session_id);*/
6272 END IF;
6273 --move enh 115.137 changed from WSMPCNST to WSMPUTIL
6274 IF WSMPUTIL.REFER_SITE_LEVEL_PROFILE = 'Y' THEN
6275 l_job_copy_flag := WSMPUTIL.CREATE_LBJ_COPY_RTG_PROFILE;
6276 END IF;
6277
6278 if (l_job_copy_flag = 1) then
6279 g_aps_wps_profile := 'Y';
6280 else
6281 g_aps_wps_profile := 'N';
6282 end if;
6283 /*--------------------------------------------------------------
6284 | Set the status to Running and Commit
6285 +--------------------------------------------------------------*/
6286 IF (p_group_id >0 ) THEN
6287 l_count := 0;
6288 l_stmt_num := 20;
6289 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6290 l_msg_tokens.delete;
6291 WSM_log_PVT.logMessage (
6292 p_module_name => l_module,
6293 p_msg_text => 'B4 UPDATE wsm_lot_move_txn_interface wlmti '||
6294 ';g_user_id '||
6295 g_user_id||
6296 ';g_login_id '||
6297 g_login_id,
6298 p_stmt_num => l_stmt_num,
6299 p_msg_tokens => l_msg_tokens,
6300 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
6301 p_run_log_level => l_log_level
6302 );
6303 END IF;
6304 UPDATE wsm_lot_move_txn_interface wlmti
6305 /* LOTATTR: Changed the following so that transaction_id is
6306 updated ONLY if it wasn't populated by the user */
6307 SET transaction_id=nvl(transaction_id,wip_transactions_s.nextval),
6308 wlmti.error = NULL,
6309 wlmti.status = WIP_CONSTANTS.RUNNING,
6310 wlmti.last_update_date = SYSDATE,
6311 wlmti.last_updated_by = decode(nvl(g_user_id, -1),
6312 -1, wlmti.last_updated_by,
6313 g_user_id),
6314 wlmti.last_update_login = decode(nvl(g_login_id, -1),
6315 -1, wlmti.last_update_login,
6316 g_login_id),
6317 wlmti.request_id = g_request_id,
6318 wlmti.program_id = g_program_id,
6319 wlmti.program_application_id = g_program_application_id
6320 WHERE group_id = p_group_id
6321 AND wlmti.status = WIP_CONSTANTS.PENDING
6322 AND wlmti.transaction_date <= SYSDATE+1;
6323
6324 IF (SQL%ROWCOUNT = 0) THEN
6325 FND_MESSAGE.SET_NAME('WSM', 'WSM_UPDATE_INVALID');
6326 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'STATUS');
6327 errbuf := FND_MESSAGE.GET;
6328 fnd_file.put_line(fnd_file.log, errbuf);
6329 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR', errbuf);
6330 return;
6331 ELSE
6332 IF (l_debug='Y') THEN
6333 fnd_file.put_line(fnd_file.log, 'updated status to running');
6334 END IF;
6335 --mes
6336 IF (nvl(p_source_code, 'interface') = 'interface') THEN
6337 COMMIT;
6338 END IF;
6339 END IF;
6340 ELSE
6341 FND_MESSAGE.SET_NAME('WSM', 'WSM_INVALID_FIELD');
6342 FND_MESSAGE.SET_TOKEN('FLD_NAME', 'GROUP_ID');
6343 errbuf := FND_MESSAGE.GET;
6344 fnd_file.put_line(fnd_file.log, errbuf);
6345 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR', errbuf);
6346 return;
6347 END IF;
6348
6349 l_stmt_num := 30;
6350
6351 --move enh getting the generic message to be used in all errors and warnings
6352 FND_MESSAGE.SET_NAME('WSM', 'WSM_ERRORS_IN_WIE');
6353 g_fnd_generic_err_msg := FND_MESSAGE.GET;
6354
6355 --move enh
6356 LOOP /* outer loop */
6357 IF (l_debug = 'Y') THEN
6358 fnd_file.put_line(fnd_file.log, 'begin outer loop');
6359 END IF;
6360
6361 l_ac_ar_exists := 0;
6362 l_inserted_wmti := 0;
6363 l_undo_exists := 0; /* CZH.JUMPENH, new UNDO logic */
6364 l_first_time := 1;
6365
6366 OPEN C_TXNS;
6367 LOOP /* inner loop */
6368 <<inner_loop>>
6369
6370 IF (l_debug = 'Y') THEN
6371 fnd_file.put_line(fnd_file.log, 'begin inner loop');
6372 END IF;
6373
6374 i := i+1;
6375
6376 l_stmt_num := 40;
6377
6378 l_header_id := -1;
6379 l_transaction_id := -1;
6380 l_transaction_quantity := -1;
6381 l_transaction_type := -1;
6382 l_fm_op_seq_num := -1;
6383 l_fm_intraoperation_step_type := -1;
6384 l_to_op_seq_num := -1;
6385 l_to_intraoperation_step_type := -1;
6386 l_to_dept_id := -1;
6387 l_organization_id := -1;
6388 l_scrap_qty :=-1;
6389 l_scrap_at_operation_flag :=-1;
6390
6391 FETCH C_TXNS INTO
6392 l_rowid,
6393 l_header_id,
6394 l_transaction_id,
6395 l_transaction_quantity,
6396 l_transaction_date,
6397 l_transaction_uom,
6398 l_transaction_type,
6399 l_fm_op_seq_num,
6400 l_fm_operation_code,
6401 l_fm_intraoperation_step_type,
6402 l_to_op_seq_num,
6403 l_to_operation_code,
6404 l_to_intraoperation_step_type,
6405 l_to_dept_id,
6406 l_primary_uom,
6407 l_wip_entity_id,
6408 l_wip_entity_name,
6409 l_organization_id,
6410 l_jump_flag,
6411 l_scrap_qty,
6412 l_scrap_at_operation_flag,
6413 l_user_serial_tracking; -- ST : Serial Support Project --
6414 --move enh 115.137 changed from WSMPCNST to WSMPUTIL
6415 IF WSMPUTIL.REFER_SITE_LEVEL_PROFILE = 'Y' THEN
6416 if (WSMPUTIL.CREATE_LBJ_COPY_RTG_PROFILE(l_organization_id) = 2) then
6417 g_aps_wps_profile := 'N';
6418 else
6419 g_aps_wps_profile := 'Y';
6420 end if;
6421 END IF;
6422
6423
6424 IF (l_debug = 'Y') THEN
6425 fnd_file.put_line(fnd_file.log, 'g_aps_wps_profile '||g_aps_wps_profile);
6426 END IF;
6427
6428 IF (C_TXNS%NOTFOUND) THEN
6429 /* if no row left, break inner loop; if first_time, break inner and outer loop */
6430 IF (g_mrp_debug='Y') THEN
6431 fnd_file.put_line(fnd_file.log, 'NO rows this round');
6432 END IF;
6433 --move enh
6434 IF (l_first_time=1) THEN
6435 IF (g_mrp_debug='Y') THEN
6436 fnd_file.put_line(fnd_file.log, 'NO more rows left, done!');
6437 END IF;
6438 GOTO outer_loop;
6439 END IF;
6440 EXIT;
6441 END IF;
6442
6443 IF (g_mrp_debug='Y') THEN
6444 fnd_file.put_line(fnd_file.log, 'Transaction_id ='||l_transaction_id||' header_id = '||l_header_id);
6445 END IF;
6446
6447 l_job_exists :=0;
6448 IF (l_first_time=1) THEN
6449 l_stmt_num := 60;
6450
6451 SELECT wip_transactions_s.nextval
6452 INTO l_wmti_group_id
6453 FROM dual;
6454
6455 ELSE
6456 l_stmt_num := 70;
6457 BEGIN
6458 SELECT 1
6459 INTO l_job_exists
6460 FROM wip_move_txn_interface
6461 WHERE group_id=l_wmti_group_id
6462 AND wip_entity_id=l_wip_entity_id
6463 AND process_status = g_running;
6464 EXCEPTION
6465 WHEN no_data_found THEN
6466 null;
6467 WHEN too_many_rows THEN
6468 l_job_exists := 1;
6469 END;
6470 END IF;
6471
6472 IF (l_job_exists=1) THEN/* If a move txn exists in WMTI for this job, Skip the remaining */
6473 /* processing for this job this time. This txn will be considered
6474 for processing next time when the cursor is re-opened
6475 by the outer loop */
6476 IF (l_debug = 'Y') THEN
6477 fnd_file.put_line(fnd_file.log, 'Skipped this row since txn of the same job exists in WMTI');
6478 END IF;
6479 GOTO inner_loop;
6480 END IF;
6481
6482 l_first_time :=0;
6483
6484 IF (l_debug='Y') THEN
6485 fnd_file.put_line(fnd_file.log, 'Calling custom_validation');
6486 END IF;
6487
6488 SAVEPOINT validation;
6489
6490 l_stmt_num := 80;
6491 /************************************************
6492 * call custom_validation to validate the entry *
6493 ************************************************/
6494
6495 x_error_code := WSMPLBMI.custom_validation(
6496 l_header_id,
6497 l_transaction_id,
6498 l_transaction_quantity,
6499 l_transaction_date,
6500 l_transaction_uom,
6501 l_primary_uom,
6502 l_transaction_type,
6503 l_fm_op_seq_num,
6504 l_fm_operation_code,
6505 l_fm_intraoperation_step_type,
6506 l_to_op_seq_num,
6507 l_to_operation_code,
6508 l_to_intraoperation_step_type,
6509 l_to_dept_id,
6510 l_wip_entity_name,
6511 l_organization_id,
6512 l_jump_flag,
6513 -- ST : Serial Support Project --
6514 l_serial_ctrl_code ,
6515 l_available_qty ,
6516 l_current_job_op_seq_num ,
6517 l_current_intraop_step ,
6518 l_current_rtg_op_seq_num ,
6519 l_old_scrap_transaction_id ,
6520 l_old_move_transaction_id ,
6521 -- ST : Serial Support Project --
6522 x_error_msg,
6523 l_undone_txn_source_code
6524 );
6525
6526 l_total_txns := l_total_txns+1;
6527
6528 IF (x_error_code<> 0) THEN
6529 l_error_msg := x_error_msg;
6530 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
6531 ROLLBACK TO validation;
6532 error_handler(p_header_id => l_header_id
6533 , p_transaction_id => l_transaction_id
6534 , p_error_msg => l_error_msg
6535 , x_error_code => x_err_code
6536 , x_error_msg => x_err_msg);
6537 IF (x_err_code <> 0) THEN
6538 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6539 l_msg_tokens.delete;
6540 WSM_log_PVT.logMessage (
6541 p_module_name => l_module ,
6542 p_msg_text => 'error_handler returned error '||l_error_msg,
6543 p_stmt_num => l_stmt_num ,
6544 p_msg_tokens => l_msg_tokens ,
6545 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6546 p_run_log_level => l_log_level
6547 );
6548 END IF;
6549 raise e_proc_exception;
6550 END IF;
6551 -- l_err_flag := 1; /*Added to fix bug #1815584*/
6552 IF (g_mrp_debug='Y') THEN
6553 fnd_file.put_line(fnd_file.log, 'custom_validation returned failure. Rolled back to validation');
6554 END IF;
6555 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6556 l_msg_tokens.delete;
6557 WSM_log_PVT.logMessage (
6558 p_module_name => l_module ,
6559 p_msg_text => 'custom_validation returned error '||l_error_msg,
6560 p_stmt_num => l_stmt_num ,
6561 p_msg_tokens => l_msg_tokens ,
6562 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6563 p_run_log_level => l_log_level
6564 );
6565 END IF;
6566 GOTO inner_loop; /* go to get next entry */
6567 ELSE
6568 IF (g_mrp_debug='Y') THEN
6569 fnd_file.put_line(fnd_file.log, 'custom_validation returned success');
6570 END IF;
6571 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6572 l_msg_tokens.delete;
6573 WSM_log_PVT.logMessage (
6574 p_module_name => l_module ,
6575 p_msg_text => 'custom_validation returned success',
6576 p_stmt_num => l_stmt_num ,
6577 p_msg_tokens => l_msg_tokens ,
6578 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6579 p_run_log_level => l_log_level
6580 );
6581 END IF;
6582 END IF;
6583
6584 IF (l_organization_id <> l_pre_org_id) THEN
6585 l_pre_org_id := l_organization_id;
6586
6587 /* Move this SQL from OSP so that this parameter is fetched
6588 ONLY when the current txn's organization is different
6589 from the previous txn's organization. -- Pons */
6590
6591 l_stmt_num := 90;
6592
6593 SELECT charge_jump_from_queue
6594 INTO l_charge_jump_from_queue
6595 FROM wsm_parameters
6596 WHERE organization_id = l_organization_id;
6597 END IF;
6598
6599 /* OSP Enhancement Changes Begin
6600 Enter a warning into the wsm_interface_errors table
6601 if there is a Purchase Requistion or Purchase Order linked
6602 to an operation under certain conditions */
6603 l_stmt_num := 100;
6604
6605 IF (( (l_fm_intraoperation_step_type = 1) AND
6606 ( (l_jump_flag = 'Y') AND (l_charge_jump_from_queue = 2) ) OR
6607 ( l_transaction_type = 4 ) )
6608 AND (wip_osp.PO_REQ_EXISTS(l_wip_entity_id,
6609 NULL,
6610 l_organization_id,
6611 l_fm_op_seq_num,
6612 5 ))) then
6613 fnd_message.set_name('WSM','WSM_OP_PURCHASE_REQ');
6614 l_error_msg := fnd_message.get;
6615 --move enh? consider warnings
6616 error_handler(p_header_id => l_header_id
6617 , p_transaction_id => l_transaction_id
6618 , p_error_msg => l_error_msg
6619 , x_error_code => x_err_code
6620 , x_error_msg => x_err_msg);
6621
6622 IF (x_err_code <> 0) THEN
6623 RAISE e_proc_exception;
6624 END IF;
6625 END IF;
6626 /* OSP Enchancement Changes End */
6627
6628
6629 /* LotAttr */
6630 l_stmt_num := 95;
6631 IF (g_mrp_debug='Y') THEN
6632 fnd_file.put_line(fnd_file.log,'p_wip_entity_id => ' || l_wip_entity_id || 'p_org_id =>' || l_organization_id || ' p_intf_txn_id =>' || l_transaction_id);
6633 fnd_file.put_line(fnd_file.log, 'Before Calling WSM_LotAttr_PVT.create_update_lotattr');
6634 END IF;
6635 WSM_LotAttr_PVT.create_update_lotattr(
6636 x_err_code => x_err_code,
6637 x_err_msg => x_error_msg,
6638 p_wip_entity_id => l_wip_entity_id,
6639 p_org_id => l_organization_id,
6640 p_intf_txn_id => l_header_id, /*l_transaction_id, Bug 5372863. Should pass header id for lot attributes package to upd lot attributes. */
6641 p_intf_src_code => 'WSM');
6642
6643 IF (x_err_code<> 0) THEN
6644 l_error_msg := x_error_msg;
6645 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
6646 ROLLBACK TO validation;
6647 error_handler(p_header_id => l_header_id
6648 , p_transaction_id => l_transaction_id
6649 , p_error_msg => l_error_msg
6650 , x_error_code => x_err_code
6651 , x_error_msg => x_error_msg);
6652 IF (x_err_code <> 0) THEN
6653 raise e_proc_exception;
6654 END IF;
6655 GOTO inner_loop; /* go to get next entry */
6656 END IF;
6657 IF (g_mrp_debug='Y') THEN
6658 fnd_file.put_line(fnd_file.log, 'No Error reported from WSM_LotAttr_PVT.create_update_lotattr');
6659 END IF;
6660 /* Fixed bug #1560345 */
6661
6662 l_stmt_num := 110;
6663 --move enh 115.135 removed extra wip_entity_id after perf check
6664 SELECT TRANSACTION_TYPE,
6665 wip_entity_id,
6666 transaction_quantity,
6667 fm_operation_seq_num,
6668 fm_intraoperation_step_type,
6669 to_intraoperation_step_type,
6670 organization_id,
6671 nvl(primary_quantity, 0),
6672 nvl(scrap_quantity, 0),
6673 nvl(primary_scrap_quantity, 0),
6674 scrap_at_operation_flag,
6675 fm_operation_code,
6676 reason_id,
6677 transaction_date,
6678 reference,
6679 internal_scrap_txn_id,
6680 to_operation_seq_num,
6681 wip_entity_name
6682 INTO l_transaction_type,
6683 l_wip_entity_id,
6684 l_txn_qty,
6685 l_fm_op_seq_num,
6686 l_fm_intraoperation_step_type,
6687 l_to_intraoperation_step_type,
6688 l_organization_id,
6689 l_primary_quantity,
6690 l_scrap_qty,
6691 l_converted_scrap_qty,
6692 l_scrap_at_operation_flag,
6693 l_fm_operation_code,
6694 l_reason_id,
6695 l_transaction_date,
6696 l_transaction_reference,
6697 l_scrap_txn_id,
6698 l_job_to_op_seq_num,
6699 l_wip_entity_name
6700 FROM wsm_lot_move_txn_interface
6701 WHERE rowid=l_rowid;
6702
6703 IF (l_debug = 'Y') THEN
6704 fnd_file.put_line(fnd_file.log, 'to_op_seq_num '||l_to_op_seq_num||' l_to_intraoperation_step_type '||l_to_intraoperation_step_type||
6705 ' l_fm_op_seq_num '||l_fm_op_seq_num||
6706 ' l_transaction_type '||l_transaction_type||
6707 ' l_scrap_qty '||l_scrap_qty||
6708 ' l_converted_scrap_qty '||l_converted_scrap_qty||
6709 ' l_scrap_at_operation_flag '||l_scrap_at_operation_flag);
6710 END IF;
6711
6712 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6713 l_msg_tokens.delete;
6714 WSM_log_PVT.logMessage (
6715 p_module_name => l_module ,
6716 p_msg_text => 'SELECT from WLMTI after custom_validations '||
6717 ';l_transaction_type '||
6718 l_transaction_type||
6719 ';l_wip_entity_id '||
6720 l_wip_entity_id||
6721 ';l_txn_qty '||
6722 l_txn_qty||
6723 ';l_fm_op_seq_num '||
6724 l_fm_op_seq_num||
6725 ';l_fm_intraoperation_step_type '||
6726 l_fm_intraoperation_step_type||
6727 ';l_to_intraoperation_step_type '||
6728 l_to_intraoperation_step_type||
6729 ';l_organization_id '||
6730 l_organization_id||
6731 ';l_primary_quantity '||
6732 l_primary_quantity||
6733 ';l_scrap_qty '||
6734 l_scrap_qty||
6735 ';l_converted_scrap_qty '||
6736 l_converted_scrap_qty||
6737 ';l_scrap_at_operation_flag '||
6738 l_scrap_at_operation_flag||
6739 ';l_fm_operation_code '||
6740 l_fm_operation_code||
6741 ';l_reason_id '||
6742 l_reason_id||
6743 ';l_transaction_date '||
6744 l_transaction_date||
6745 ';l_transaction_reference '||
6746 l_transaction_reference||
6747 ';l_scrap_txn_id '||
6748 l_scrap_txn_id||
6749 ';l_job_to_op_seq_num '||
6750 l_job_to_op_seq_num,
6751 p_stmt_num => l_stmt_num ,
6752 p_msg_tokens => l_msg_tokens ,
6753 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6754 p_run_log_level => l_log_level
6755 );
6756 END IF;
6757
6758 --MES
6759 IF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
6760 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6761 l_msg_tokens.delete;
6762 WSM_log_PVT.logMessage (
6763 p_module_name => l_module ,
6764 p_msg_text => 'Begin MES Validations',
6765 p_stmt_num => l_stmt_num ,
6766 p_msg_tokens => l_msg_tokens ,
6767 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6768 p_run_log_level => l_log_level
6769 );
6770 END IF;
6771
6772 l_stmt_num := 110.101;
6773 l_total_scrap_code_qty := 0;
6774 l_stmt_num := 110.102;
6775 l_total_bonus_code_qty := 0;
6776 l_stmt_num := 110.103;
6777 l_put_job_on_hold := 0;
6778 l_stmt_num := 110.104;
6779 --bug 5490644 perform this check only if the txn is move txn
6780 --bug 5185512 Changed '<=' to '<' below
6781 --IF ((l_primary_quantity/(l_converted_scrap_qty+l_primary_quantity)) <= nvl(p_low_yield_trigger_limit, -1)) THEN
6782 IF ((l_transaction_type = WIP_CONSTANTS.MOVE_TXN) AND ((l_primary_quantity/(l_converted_scrap_qty+l_primary_quantity)) < nvl(p_low_yield_trigger_limit, -1))) THEN
6783 l_stmt_num := 253.14;
6784 l_put_job_on_hold := 1;
6785 /*************************No need to throw error************************************
6786 l_msg_tokens.delete;
6787 WSM_LOG_PVT.LogMessage(
6788 p_module_name => l_module,
6789 p_msg_name => 'WSM_MES_SCRAP_YIELD_LIMIT',
6790 p_msg_appl_name => 'WSM',
6791 p_msg_text => NULL,
6792 p_stmt_num => l_stmt_num,
6793 p_msg_tokens => l_msg_tokens,
6794 p_wsm_warning => 1,
6795 p_fnd_log_level => G_LOG_LEVEL_ERROR,
6796 p_run_log_level => l_log_level
6797 );
6798
6799 FND_MESSAGE.SET_NAME('WSM','WSM_MES_SCRAP_YIELD_LIMIT');
6800 FND_MSG_PUB.add;
6801 *************************No need to throw error************************************/
6802 END IF;
6803
6804 l_stmt_num := 110.3;
6805 IF ((p_scrap_codes_tbls IS NOT NULL) AND p_scrap_codes_tbls.exists(l_header_id)
6806 AND (p_scrap_codes_tbls(l_header_id).count > 0))
6807 THEN
6808 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6809 l_msg_tokens.delete;
6810 WSM_log_PVT.logMessage (
6811 p_module_name => l_module ,
6812 p_msg_text => 'Begin Scrap code Validations',
6813 p_stmt_num => l_stmt_num ,
6814 p_msg_tokens => l_msg_tokens ,
6815 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6816 p_run_log_level => l_log_level
6817 );
6818 END IF;
6819
6820 l_stmt_num := 110.4;
6821 FOR i in 1..p_scrap_codes_tbls(l_header_id).last LOOP
6822 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6823 l_msg_tokens.delete;
6824 WSM_log_PVT.logMessage (
6825 p_module_name => l_module ,
6826 p_msg_text =>
6827 '; i '||
6828 i||
6829 '; p_scrap_codes_tbls(l_header_id)(i) '||
6830 p_scrap_codes_tbls(l_header_id)(i)||
6831 '; Scrap code '||
6832 reason_code_err_info(
6833 p_reason_code_num => to_number(p_scrap_codes_tbls(l_header_id)(i))
6834 , p_reason_code_type => 1
6835 )||
6836 '; Scrap code qty'||
6837 p_scrap_code_qty_tbls(l_header_id)(i),
6838 p_stmt_num => l_stmt_num ,
6839 p_msg_tokens => l_msg_tokens ,
6840 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6841 p_run_log_level => l_log_level
6842 );
6843 END IF;
6844 l_stmt_num := 110.5;
6845 IF nvl(p_scrap_code_qty_tbls(l_header_id)(i), 0) < 0 THEN
6846 l_msg_tokens.delete;
6847 l_msg_tokens(0).TokenName := 'FIELD_NAME';
6848 l_msg_tokens(0).TokenValue := reason_code_err_info(
6849 p_reason_code_num => to_number(p_scrap_codes_tbls(l_header_id)(i))
6850 , p_reason_code_type => 1
6851 );
6852 WSM_log_PVT.LogMessage(
6853 p_module_name => l_module,
6854 p_msg_name => 'WSM_MES_FIELD_NEGATIVE',
6855 p_msg_appl_name => 'WSM',
6856 p_msg_text => NULL,
6857 p_stmt_num => l_stmt_num,
6858 p_msg_tokens => l_msg_tokens,
6859 p_wsm_warning => NULL,
6860 p_fnd_log_level => G_LOG_LEVEL_ERROR,
6861 p_run_log_level => l_log_level
6862 );
6863 FND_MESSAGE.SET_NAME('WSM','WSM_MES_FIELD_NEGATIVE');
6864 FND_MESSAGE.SET_TOKEN('FIELD_NAME', l_msg_tokens(0).TokenValue);
6865 FND_MSG_PUB.add;
6866 ROLLBACK TO validation;
6867 RAISE FND_API.G_EXC_ERROR;
6868
6869 ELSE
6870
6871 l_stmt_num := 110.6;
6872 SELECT max_acceptable_scrap_qty
6873 INTO l_max_acceptable_scrap_qty
6874 FROM BOM_STD_OP_SCRAP_CODES BSOSC, BOM_STANDARD_OPERATIONS BSO
6875 WHERE BSO.operation_code = l_fm_operation_code
6876 AND BSO.organization_id = l_organization_id
6877 AND BSOSC.standard_operation_id = BSO.standard_operation_id
6878 AND BSOSC.scrap_code = p_scrap_codes_tbls(l_header_id)(i);
6879
6880 l_stmt_num := 110.7;
6881 --bug 5490644 perform this check only if the txn is move txn
6882 IF ((l_transaction_type = WIP_CONSTANTS.MOVE_TXN) AND ((l_max_acceptable_scrap_qty IS NOT NULL) AND (nvl(p_scrap_code_qty_tbls(l_header_id)(i), 0) > l_max_acceptable_scrap_qty)))
6883 THEN
6884 l_stmt_num := 253.14;
6885 l_put_job_on_hold := 1;
6886 /*************************No need to throw error************************************
6887 l_msg_tokens.delete;
6888 l_msg_tokens(0).TokenName := 'FIELD_NAME';
6889 l_msg_tokens(0).TokenValue := reason_code_err_info(
6890 p_reason_code_num => to_number(p_scrap_codes_tbls(l_header_id)(i))
6891 , p_reason_code_type => 1
6892 );
6893 WSM_LOG_PVT.LogMessage(
6894 p_module_name => l_module,
6895 p_msg_name => 'WSM_MES_SCRAP_CODE_MAX_QTY',
6896 p_msg_appl_name => 'WSM',
6897 p_msg_text => NULL,
6898 p_stmt_num => l_stmt_num,
6899 p_msg_tokens => l_msg_tokens,
6900 p_wsm_warning => 1,
6901 p_fnd_log_level => G_LOG_LEVEL_ERROR,
6902 p_run_log_level => l_log_level
6903 );
6904
6905 FND_MESSAGE.SET_NAME('WSM','WSM_MES_SCRAP_CODE_MAX_QTY');
6906 FND_MESSAGE.SET_TOKEN('FIELD_NAME', l_msg_tokens(0).TokenValue);
6907 FND_MSG_PUB.add;
6908 *************************No need to throw error***********************************/
6909 END IF;
6910 l_total_scrap_code_qty := l_total_scrap_code_qty + nvl(p_scrap_code_qty_tbls(l_header_id)(i), 0);
6911
6912 END IF;
6913 END LOOP;
6914
6915 IF (nvl(l_total_scrap_code_qty, 0) <> nvl(l_scrap_qty, 0)) THEN
6916 l_stmt_num := 110.801;
6917 l_msg_tokens.delete;
6918 WSM_log_PVT.LogMessage(
6919 p_module_name => l_module,
6920 p_msg_name => 'WSM_MES_SCRAPCODEQTY_MISMATCH',
6921 p_msg_appl_name => 'WSM',
6922 p_msg_text => NULL,
6923 p_stmt_num => l_stmt_num,
6924 p_msg_tokens => l_msg_tokens,
6925 p_wsm_warning => NULL,
6926 p_fnd_log_level => G_LOG_LEVEL_ERROR,
6927 p_run_log_level => l_log_level
6928 );
6929 FND_MESSAGE.SET_NAME('WSM','WSM_MES_SCRAPCODEQTY_MISMATCH');
6930 FND_MSG_PUB.add;
6931 ROLLBACK TO validation;
6932 RAISE FND_API.G_EXC_ERROR;
6933
6934 END IF;
6935 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6936 l_msg_tokens.delete;
6937 WSM_log_PVT.logMessage (
6938 p_module_name => l_module ,
6939 p_msg_text => 'Validated scrap codes successfully',
6940 p_stmt_num => l_stmt_num ,
6941 p_msg_tokens => l_msg_tokens ,
6942 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6943 p_run_log_level => l_log_level
6944 );
6945 END IF;
6946 END IF;
6947
6948 l_stmt_num := 110.9;
6949
6950 IF ((p_bonus_codes_tbls IS NOT NULL) AND (p_bonus_codes_tbls.exists(l_header_id))
6951 AND (p_bonus_codes_tbls(l_header_id).count > 0)) THEN
6952 l_stmt_num := 110.10;
6953 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6954 l_msg_tokens.delete;
6955 WSM_log_PVT.logMessage (
6956 p_module_name => l_module ,
6957 p_msg_text => 'Begin Bonus code Validations',
6958 p_stmt_num => l_stmt_num ,
6959 p_msg_tokens => l_msg_tokens ,
6960 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6961 p_run_log_level => l_log_level
6962 );
6963 END IF;
6964
6965 FOR i in p_bonus_codes_tbls(l_header_id).first..p_bonus_codes_tbls(l_header_id).last LOOP
6966 l_stmt_num := 110.11;
6967
6968 IF nvl(p_bonus_code_qty_tbls(l_header_id)(i), 0) < 0 THEN
6969 l_stmt_num := 110.1101;
6970 l_msg_tokens.delete;
6971 l_msg_tokens(0).TokenName := 'FIELD_NAME';
6972 l_msg_tokens(0).TokenValue := reason_code_err_info(
6973 p_reason_code_num => to_number(p_bonus_codes_tbls(l_header_id)(i))
6974 , p_reason_code_type => 2
6975 );
6976 WSM_log_PVT.LogMessage(
6977 p_module_name => l_module,
6978 p_msg_name => 'WSM_MES_FIELD_NEGATIVE',
6979 p_msg_appl_name => 'WSM',
6980 p_msg_text => NULL,
6981 p_stmt_num => l_stmt_num,
6982 p_msg_tokens => l_msg_tokens,
6983 p_wsm_warning => NULL,
6984 p_fnd_log_level => G_LOG_LEVEL_ERROR,
6985 p_run_log_level => l_log_level
6986 );
6987 FND_MESSAGE.SET_NAME('WSM','WSM_MES_FIELD_NEGATIVE');
6988 FND_MESSAGE.SET_TOKEN('FIELD_NAME', l_msg_tokens(0).TokenValue);
6989 FND_MSG_PUB.add;
6990 ROLLBACK TO validation;
6991 RAISE FND_API.G_EXC_ERROR;
6992
6993 ELSE
6994 l_stmt_num := 110.1102;
6995
6996 l_total_bonus_code_qty := l_total_bonus_code_qty + nvl(p_bonus_code_qty_tbls(l_header_id)(i), 0);
6997 END IF;
6998 END LOOP;
6999
7000 l_stmt_num := 110.12;
7001
7002 IF (nvl(l_total_bonus_code_qty, 0) <> nvl(p_bonus_quantity, 0)) THEN
7003 l_stmt_num := 110.121;
7004 l_msg_tokens.delete;
7005 WSM_log_PVT.LogMessage(
7006 p_module_name => l_module,
7007 p_msg_name => 'WSM_MES_BONUSCODEQTY_MISMATCH',
7008 p_msg_appl_name => 'WSM',
7009 p_msg_text => NULL,
7010 p_stmt_num => l_stmt_num,
7011 p_msg_tokens => l_msg_tokens,
7012 p_wsm_warning => NULL,
7013 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7014 p_run_log_level => l_log_level
7015 );
7016 FND_MESSAGE.SET_NAME('WSM','WSM_MES_BONUSCODEQTY_MISMATCH');
7017 FND_MSG_PUB.add;
7018 ROLLBACK TO validation;
7019 RAISE FND_API.G_EXC_ERROR;
7020
7021 END IF;
7022 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7023 l_msg_tokens.delete;
7024 WSM_log_PVT.logMessage (
7025 p_module_name => l_module ,
7026 p_msg_text => 'Validated bonus codes successfully',
7027 p_stmt_num => l_stmt_num ,
7028 p_msg_tokens => l_msg_tokens ,
7029 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7030 p_run_log_level => l_log_level
7031 );
7032 END IF;
7033 END IF;
7034
7035
7036 l_stmt_num := 110.13;
7037
7038
7039 IF ((p_jobop_scrap_serials_tbls IS NOT NULL) AND (p_jobop_scrap_serials_tbls.exists(l_header_id))
7040 AND (p_jobop_scrap_serials_tbls(l_header_id).count > 0))
7041 THEN
7042 l_stmt_num := 110.131;
7043 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7044 l_msg_tokens.delete;
7045 WSM_log_PVT.logMessage (
7046 p_module_name => l_module ,
7047 p_msg_text => 'Begin Scrap Serials Validations',
7048 p_stmt_num => l_stmt_num ,
7049 p_msg_tokens => l_msg_tokens ,
7050 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7051 p_run_log_level => l_log_level
7052 );
7053 FOR i in p_jobop_scrap_serials_tbls(l_header_id).first..p_jobop_scrap_serials_tbls(l_header_id).last LOOP
7054 l_msg_tokens.delete;
7055 WSM_log_PVT.logMessage (
7056 p_module_name => l_module ,
7057 p_msg_text => 'p_jobop_scrap_serials_tbls '
7058 ||';i '
7059 ||i
7060 ||';serial '
7061 ||p_jobop_scrap_serials_tbls(l_header_id)(i).Serial_Number,
7062 p_stmt_num => l_stmt_num ,
7063 p_msg_tokens => l_msg_tokens ,
7064 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7065 p_run_log_level => l_log_level
7066 );
7067 END LOOP;
7068 END IF;
7069
7070 IF (nvl(l_scrap_qty, 0) <> (nvl(p_jobop_scrap_serials_tbls(l_header_id).last, 0))) THEN
7071 l_msg_tokens.delete;
7072 WSM_log_PVT.LogMessage(
7073 p_module_name => l_module,
7074 p_msg_name => 'WSM_MES_SCRAPSERIAL_QTY',
7075 p_msg_appl_name => 'WSM',
7076 p_msg_text => NULL,
7077 p_stmt_num => l_stmt_num,
7078 p_msg_tokens => l_msg_tokens,
7079 p_wsm_warning => NULL,
7080 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7081 p_run_log_level => l_log_level
7082 );
7083 FND_MESSAGE.SET_NAME('WSM','WSM_MES_SCRAPSERIAL_QTY');
7084 FND_MSG_PUB.add;
7085 ROLLBACK TO validation;
7086 RAISE FND_API.G_EXC_ERROR;
7087 END IF;
7088
7089 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7090 l_msg_tokens.delete;
7091 WSM_log_PVT.logMessage (
7092 p_module_name => l_module,
7093 p_msg_text => 'Validated scrap serials successfully',
7094 p_stmt_num => l_stmt_num,
7095 p_msg_tokens => l_msg_tokens,
7096 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7097 p_run_log_level => l_log_level
7098 );
7099 END IF;
7100 END IF;
7101
7102 l_stmt_num := 110.14;
7103
7104 IF ((p_jobop_bonus_serials_tbls IS NOT NULL) AND p_jobop_bonus_serials_tbls.exists(l_header_id)
7105 AND (p_jobop_bonus_serials_tbls(l_header_id).count > 0)
7106 AND (nvl(p_bonus_quantity, 0) <> (nvl(p_jobop_bonus_serials_tbls(l_header_id).last, 0))))
7107 THEN
7108 l_stmt_num := 110.141;
7109 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7110 l_msg_tokens.delete;
7111 WSM_log_PVT.logMessage (
7112 p_module_name => l_module ,
7113 p_msg_text => 'Begin Bonus Serials Validations',
7114 p_stmt_num => l_stmt_num ,
7115 p_msg_tokens => l_msg_tokens ,
7116 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7117 p_run_log_level => l_log_level
7118 );
7119 FOR i in p_jobop_bonus_serials_tbls(l_header_id).first..p_jobop_bonus_serials_tbls(l_header_id).last LOOP
7120 l_msg_tokens.delete;
7121 WSM_log_PVT.logMessage (
7122 p_module_name => l_module ,
7123 p_msg_text => 'p_jobop_bonus_serials_tbls '
7124 ||';i '
7125 ||i
7126 ||';serial '
7127 ||p_jobop_bonus_serials_tbls(l_header_id)(i).Serial_Number,
7128 p_stmt_num => l_stmt_num ,
7129 p_msg_tokens => l_msg_tokens ,
7130 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7131 p_run_log_level => l_log_level
7132 );
7133 END LOOP;
7134 END IF;
7135
7136 l_msg_tokens.delete;
7137 WSM_log_PVT.LogMessage(
7138 p_module_name => l_module,
7139 p_msg_name => 'WSM_MES_BONUSSERIAL_QTY',
7140 p_msg_appl_name => 'WSM',
7141 p_msg_text => NULL,
7142 p_stmt_num => l_stmt_num,
7143 p_msg_tokens => l_msg_tokens,
7144 p_wsm_warning => NULL,
7145 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7146 p_run_log_level => l_log_level
7147 );
7148 FND_MESSAGE.SET_NAME('WSM','WSM_MES_BONUSSERIAL_QTY');
7149 FND_MSG_PUB.add;
7150 ROLLBACK TO validation;
7151 RAISE FND_API.G_EXC_ERROR;
7152
7153 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7154 l_msg_tokens.delete;
7155 WSM_log_PVT.logMessage (
7156 p_module_name => l_module,
7157 p_msg_text => 'Validated bonus serials successfully',
7158 p_stmt_num => l_stmt_num,
7159 p_msg_tokens => l_msg_tokens,
7160 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7161 p_run_log_level => l_log_level
7162 );
7163 END IF;
7164 END IF;
7165
7166 l_stmt_num := 110.15;
7167
7168 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
7169 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
7170
7171 l_stmt_num := 110.16;
7172 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7173 l_msg_tokens.delete;
7174 WSM_log_PVT.logMessage (
7175 p_module_name => l_module ,
7176 p_msg_text => 'Begin Resource Validations',
7177 p_stmt_num => l_stmt_num ,
7178 p_msg_tokens => l_msg_tokens ,
7179 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7180 p_run_log_level => l_log_level
7181 );
7182 END IF;
7183 FOR i in 1..p_jobop_resource_usages_tbls(l_header_id).last LOOP
7184 l_stmt_num := 110.17;
7185 --removed check on null start, comletion dates in
7186 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7187 l_msg_tokens.delete;
7188 WSM_log_PVT.logMessage (
7189 p_module_name => l_module,
7190 p_msg_text => 'Resource info '||
7191 ';i '||
7192 i||
7193 ';resource_seq_num '||
7194 p_jobop_resource_usages_tbls(l_header_id)(i).resource_seq_num||
7195 ';resource_id '||
7196 p_jobop_resource_usages_tbls(l_header_id)(i).resource_id||
7197 ';instance_id '||
7198 p_jobop_resource_usages_tbls(l_header_id)(i).instance_id||
7199 ';serial_number '||
7200 p_jobop_resource_usages_tbls(l_header_id)(i).serial_number||
7201 ';l_organization_id '||
7202 l_organization_id,
7203 p_stmt_num => l_stmt_num,
7204 p_msg_tokens => l_msg_tokens,
7205 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7206 p_run_log_level => l_log_level
7207 );
7208 END IF;
7209 l_stmt_num := 110.19;
7210
7211 IF (p_jobop_resource_usages_tbls(l_header_id)(i).start_date IS NOT NULL)
7212 AND (p_jobop_resource_usages_tbls(l_header_id)(i).start_date > sysdate) THEN
7213 l_stmt_num := 110.191;
7214 l_msg_tokens.delete;
7215 WSM_log_PVT.LogMessage(
7216 p_module_name => l_module,
7217 p_msg_name => 'WSM_MES_START>CURRENTDATE',
7218 p_msg_appl_name => 'WSM',
7219 p_msg_text => NULL,
7220 p_stmt_num => l_stmt_num,
7221 p_msg_tokens => l_msg_tokens,
7222 p_wsm_warning => NULL,
7223 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7224 p_run_log_level => l_log_level
7225 );
7226 add_Resource_error_info(
7227 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7228 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7229 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7230 , p_organization_id => l_organization_id
7231 );
7232 FND_MESSAGE.SET_NAME('WSM','WSM_MES_START>CURRENTDATE');
7233 FND_MSG_PUB.add;
7234 ROLLBACK TO validation;
7235 RAISE FND_API.G_EXC_ERROR;
7236
7237 END IF;
7238
7239 l_stmt_num := 110.20;
7240
7241 IF (p_jobop_resource_usages_tbls(l_header_id)(i).start_date IS NOT NULL)
7242 AND (p_jobop_resource_usages_tbls(l_header_id)(i).end_date IS NOT NULL)
7243 AND (p_jobop_resource_usages_tbls(l_header_id)(i).end_date <
7244 p_jobop_resource_usages_tbls(l_header_id)(i).start_date)
7245 THEN
7246 l_stmt_num := 110.201;
7247 l_msg_tokens.delete;
7248 WSM_log_PVT.LogMessage(
7249 p_module_name => l_module,
7250 p_msg_name => 'WSM_MES_RESCOMPL<RESSTARTDATE',
7251 p_msg_appl_name => 'WSM',
7252 p_msg_text => NULL,
7253 p_stmt_num => l_stmt_num,
7254 p_msg_tokens => l_msg_tokens,
7255 p_wsm_warning => NULL,
7256 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7257 p_run_log_level => l_log_level
7258 );
7259 add_Resource_error_info(
7260 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7261 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7262 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7263 , p_organization_id => l_organization_id
7264 );
7265 FND_MESSAGE.SET_NAME('WSM','WSM_MES_RESCOMPL<RESSTARTDATE');
7266 FND_MSG_PUB.add;
7267 ROLLBACK TO validation;
7268 RAISE FND_API.G_EXC_ERROR;
7269 END IF;
7270
7271 l_stmt_num := 110.21;
7272 /*****************This is needed only for multiple resource usage dates*******/
7273 FOR j in 1..p_jobop_resource_usages_tbls(l_header_id).last LOOP
7274
7275 l_stmt_num := 110.22;
7276 DECLARE
7277 l_i_start DATE := p_jobop_resource_usages_tbls(l_header_id)(i).start_date;
7278 l_i_end DATE := p_jobop_resource_usages_tbls(l_header_id)(i).end_date;
7279 l_j_start DATE := p_jobop_resource_usages_tbls(l_header_id)(j).start_date;
7280 l_j_end DATE := p_jobop_resource_usages_tbls(l_header_id)(j).end_date;
7281 BEGIN
7282 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7283 l_msg_tokens.delete;
7284 WSM_log_PVT.logMessage (
7285 p_module_name => l_module,
7286 p_msg_text => 'B4 move out overlap dates check '||
7287 ';i '||
7288 i||
7289 ';l_i_start '||
7290 to_char(l_i_start, 'DD-MON-YYYY HH24:MI:SS')||
7291 ';l_i_end '||
7292 to_char(l_i_end, 'DD-MON-YYYY HH24:MI:SS')||
7293 ';resource_seq_num '||
7294 p_jobop_resource_usages_tbls(l_header_id)(i).resource_seq_num||
7295 ';instance_id '||
7296 p_jobop_resource_usages_tbls(l_header_id)(i).instance_id||
7297 ';serial_number '||
7298 p_jobop_resource_usages_tbls(l_header_id)(i).serial_number||
7299 ';j '||
7300 j||
7301 ';l_j_start '||
7302 to_char(l_j_start, 'DD-MON-YYYY HH24:MI:SS')||
7303 ';l_j_end '||
7304 to_char(l_j_end, 'DD-MON-YYYY HH24:MI:SS')||
7305 ';resource_seq_num '||
7306 p_jobop_resource_usages_tbls(l_header_id)(j).resource_seq_num||
7307 ';instance_id '||
7308 p_jobop_resource_usages_tbls(l_header_id)(j).instance_id||
7309 ';serial_number '||
7310 p_jobop_resource_usages_tbls(l_header_id)(j).serial_number,
7311 p_stmt_num => l_stmt_num,
7312 p_msg_tokens => l_msg_tokens,
7313 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7314 p_run_log_level => l_log_level
7315 );
7316 END IF;
7317 IF (i <> j)
7318 AND (l_i_start IS NOT NULL)
7319 AND (l_j_start IS NOT NULL)
7320 AND (l_i_end IS NOT NULL)
7321 AND (l_j_end IS NOT NULL)
7322 AND (p_jobop_resource_usages_tbls(l_header_id)(i).resource_seq_num =
7323 p_jobop_resource_usages_tbls(l_header_id)(j).resource_seq_num)
7324 AND (p_jobop_resource_usages_tbls(l_header_id)(i).instance_id =
7325 p_jobop_resource_usages_tbls(l_header_id)(j).instance_id)
7326 AND (p_jobop_resource_usages_tbls(l_header_id)(i).serial_number =
7327 p_jobop_resource_usages_tbls(l_header_id)(j).serial_number)
7328 AND (
7329 ((l_i_start >= l_j_start) AND (l_i_start <= l_j_end))
7330 OR
7331 ((l_i_start <= l_j_start) AND (l_j_start <= l_i_end))
7332 OR
7333 ((l_i_start <= l_j_start) AND (l_j_end <= l_i_end))
7334 OR
7335 ((l_i_start >= l_j_start) AND (l_j_end >= l_i_end))
7336 )
7337 THEN
7338 l_stmt_num := 110.221;
7339 l_msg_tokens.delete;
7340 WSM_log_PVT.LogMessage(
7341 p_module_name => l_module,
7342 p_msg_name => 'WSM_MES_OVERLAP_RES_DATES',
7343 p_msg_appl_name => 'WSM',
7344 p_msg_text => NULL,
7345 p_stmt_num => l_stmt_num,
7346 p_msg_tokens => l_msg_tokens,
7347 p_wsm_warning => NULL,
7348 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7349 p_run_log_level => l_log_level
7350 );
7351 add_Resource_error_info(
7352 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7353 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7354 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7355 , p_organization_id => l_organization_id
7356 );
7357 FND_MESSAGE.SET_NAME('WSM','WSM_MES_OVERLAP_RES_DATES');
7358 FND_MSG_PUB.add;
7359 ROLLBACK TO validation;
7360 RAISE FND_API.G_EXC_ERROR;
7361
7362 END IF;
7363 END;
7364 END LOOP;
7365 /***************************************/
7366 l_stmt_num := 110.23;
7367
7368 IF (p_operation_start_date IS NOT NULL)
7369 AND (p_jobop_resource_usages_tbls(l_header_id)(i).start_date IS NOT NULL)
7370 AND (p_jobop_resource_usages_tbls(l_header_id)(i).start_date < p_operation_start_date) THEN
7371 l_stmt_num := 110.231;
7372 l_msg_tokens.delete;
7373 WSM_log_PVT.LogMessage(
7374 p_module_name => l_module,
7375 p_msg_name => 'WSM_MES_START>RESSTARTDATE',
7376 p_msg_appl_name => 'WSM',
7377 p_msg_text => NULL,
7378 p_stmt_num => l_stmt_num,
7379 p_msg_tokens => l_msg_tokens,
7380 p_wsm_warning => NULL,
7381 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7382 p_run_log_level => l_log_level
7383 );
7384 add_Resource_error_info(
7385 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7386 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7387 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7388 , p_organization_id => l_organization_id
7389 );
7390 FND_MESSAGE.SET_NAME('WSM','WSM_MES_START>RESSTARTDATE');
7391 FND_MSG_PUB.add;
7392 ROLLBACK TO validation;
7393 RAISE FND_API.G_EXC_ERROR;
7394
7395 END IF;
7396
7397 l_stmt_num := 110.24;
7398
7399 IF (p_operation_completion_date IS NOT NULL)
7400 AND (p_jobop_resource_usages_tbls(l_header_id)(i).end_date IS NOT NULL)
7401 AND (p_jobop_resource_usages_tbls(l_header_id)(i).end_date > p_operation_completion_date) THEN
7402 l_stmt_num := 110.241;
7403 l_msg_tokens.delete;
7404 WSM_log_PVT.LogMessage(
7405 p_module_name => l_module,
7406 p_msg_name => 'WSM_MES_COMPL<RESCOMPLDATE',
7407 p_msg_appl_name => 'WSM',
7408 p_msg_text => NULL,
7409 p_stmt_num => l_stmt_num,
7410 p_msg_tokens => l_msg_tokens,
7411 p_wsm_warning => NULL,
7412 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7413 p_run_log_level => l_log_level
7414 );
7415 add_Resource_error_info(
7416 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7417 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7418 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7419 , p_organization_id => l_organization_id
7420 );
7421 FND_MESSAGE.SET_NAME('WSM','WSM_MES_COMPL<RESCOMPLDATE');
7422 FND_MSG_PUB.add;
7423 ROLLBACK TO validation;
7424 RAISE FND_API.G_EXC_ERROR;
7425 END IF;
7426
7427 END LOOP;
7428 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7429 l_msg_tokens.delete;
7430 WSM_log_PVT.logMessage (
7431 p_module_name => l_module,
7432 p_msg_text => 'Validated resource usage successfully',
7433 p_stmt_num => l_stmt_num,
7434 p_msg_tokens => l_msg_tokens,
7435 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7436 p_run_log_level => l_log_level
7437 );
7438 END IF;
7439 END IF;
7440
7441 l_stmt_num := 110.25;
7442
7443 IF (p_operation_start_date IS NOT NULL) AND (p_operation_completion_date IS NOT NULL)
7444 AND (p_operation_start_date > p_operation_completion_date)
7445 THEN
7446 l_stmt_num := 110.251;
7447 l_msg_tokens.delete;
7448 WSM_log_PVT.LogMessage(
7449 p_module_name => l_module,
7450 p_msg_name => 'WSM_MES_COMPL<STARTDATE',
7451 p_msg_appl_name => 'WSM',
7452 p_msg_text => NULL,
7453 p_stmt_num => l_stmt_num,
7454 p_msg_tokens => l_msg_tokens,
7455 p_wsm_warning => NULL,
7456 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7457 p_run_log_level => l_log_level
7458 );
7459 FND_MESSAGE.SET_NAME('WSM','WSM_MES_COMPL<STARTDATE');
7460 FND_MSG_PUB.add;
7461 ROLLBACK TO validation;
7462 RAISE FND_API.G_EXC_ERROR;
7463
7464 END IF;
7465 l_stmt_num := 110.252;
7466 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7467 l_msg_tokens.delete;
7468 WSM_log_PVT.logMessage (
7469 p_module_name => l_module ,
7470 p_msg_text => 'End MES Move Out Validations',
7471 p_stmt_num => l_stmt_num ,
7472 p_msg_tokens => l_msg_tokens ,
7473 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7474 p_run_log_level => l_log_level
7475 );
7476 END IF;
7477 ELSIF (nvl(p_source_code, 'interface') = 'move in oa page') THEN
7478 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7479 l_msg_tokens.delete;
7480 WSM_log_PVT.logMessage (
7481 p_module_name => l_module ,
7482 p_msg_text => 'Begin MES Move In Validations '||
7483 'p_jobop_resource_usages_tbls(l_header_id).count '||
7484 p_jobop_resource_usages_tbls(l_header_id).count,
7485 p_stmt_num => l_stmt_num ,
7486 p_msg_tokens => l_msg_tokens ,
7487 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7488 p_run_log_level => l_log_level
7489 );
7490 END IF;
7491
7492 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
7493 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
7494 l_stmt_num := 110.19;
7495 --bug 5435687 corrected the variable j to i
7496 --FOR j in 1..p_jobop_resource_usages_tbls(l_header_id).last LOOP
7497 FOR i in 1..p_jobop_resource_usages_tbls(l_header_id).last LOOP
7498 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7499 l_msg_tokens.delete;
7500 WSM_log_PVT.logMessage (
7501 p_module_name => l_module ,
7502 p_msg_text => 'Begin MES Move In Validations '||
7503 'i '||
7504 i||
7505 ' p_jobop_resource_usages_tbls(l_header_id)(i).resource_id '||
7506 p_jobop_resource_usages_tbls(l_header_id)(i).resource_id||
7507 ' p_jobop_resource_usages_tbls(l_header_id)(i).instance_id '||
7508 p_jobop_resource_usages_tbls(l_header_id)(i).instance_id||
7509 ' p_jobop_resource_usages_tbls(l_header_id)(i).serial_number '||
7510 p_jobop_resource_usages_tbls(l_header_id)(i).serial_number||
7511 ' p_jobop_resource_usages_tbls(l_header_id)(i).instance_id '||
7512 p_jobop_resource_usages_tbls(l_header_id)(i).instance_id||
7513 ' l_organization_id '||
7514 l_organization_id||
7515 ';start_date '||
7516 p_jobop_resource_usages_tbls(l_header_id)(i).start_date||
7517 ';projected_completion_date '||
7518 p_jobop_resource_usages_tbls(l_header_id)(i).projected_completion_date,
7519 p_stmt_num => l_stmt_num ,
7520 p_msg_tokens => l_msg_tokens ,
7521 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7522 p_run_log_level => l_log_level
7523 );
7524 END IF;
7525 IF nvl(p_jobop_resource_usages_tbls(l_header_id)(i).start_date, sysdate) > sysdate THEN
7526 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7527 l_msg_tokens.delete;
7528 WSM_log_PVT.logMessage (
7529 p_module_name => l_module ,
7530 p_msg_text => 'inside IF nvl(p_jobop_resource_usages_tbls(l_header_id)(i).start_date, sysdate) > sysdate ',
7531 p_stmt_num => l_stmt_num ,
7532 p_msg_tokens => l_msg_tokens ,
7533 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7534 p_run_log_level => l_log_level
7535 );
7536 END IF;
7537 l_stmt_num := 110.191;
7538 l_msg_tokens.delete;
7539 WSM_log_PVT.LogMessage(
7540 p_module_name => l_module,
7541 p_msg_name => 'WSM_MES_START>CURRENTDATE',
7542 p_msg_appl_name => 'WSM',
7543 p_msg_text => NULL,
7544 p_stmt_num => l_stmt_num,
7545 p_msg_tokens => l_msg_tokens,
7546 p_wsm_warning => NULL,
7547 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7548 p_run_log_level => l_log_level
7549 );
7550
7551 add_Resource_error_info(
7552 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7553 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7554 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7555 , p_organization_id => l_organization_id
7556 );
7557 FND_MESSAGE.SET_NAME('WSM','WSM_MES_START>CURRENTDATE');
7558 FND_MSG_PUB.add;
7559 ROLLBACK TO validation;
7560 RAISE FND_API.G_EXC_ERROR;
7561 END IF;
7562
7563 IF nvl(p_jobop_resource_usages_tbls(l_header_id)(i).projected_completion_date, sysdate) <
7564 nvl(p_jobop_resource_usages_tbls(l_header_id)(i).start_date, sysdate) THEN
7565 l_stmt_num := 110.201;
7566 l_msg_tokens.delete;
7567 WSM_log_PVT.LogMessage(
7568 p_module_name => l_module,
7569 p_msg_name => 'WSM_MES_RESPROJCOMPL<STARTDATE',
7570 p_msg_appl_name => 'WSM',
7571 p_msg_text => NULL,
7572 p_stmt_num => l_stmt_num,
7573 p_msg_tokens => l_msg_tokens,
7574 p_wsm_warning => NULL,
7575 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7576 p_run_log_level => l_log_level
7577 );
7578 add_Resource_error_info(
7579 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7580 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7581 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7582 , p_organization_id => l_organization_id
7583 );
7584 FND_MESSAGE.SET_NAME('WSM','WSM_MES_RESPROJCOMPL<STARTDATE');
7585 FND_MSG_PUB.add;
7586 ROLLBACK TO validation;
7587 RAISE FND_API.G_EXC_ERROR;
7588 END IF;
7589
7590 IF (p_operation_start_date IS NOT NULL) AND (p_jobop_resource_usages_tbls(l_header_id)(i).start_date < p_operation_start_date) THEN
7591 l_stmt_num := 110.231;
7592 l_msg_tokens.delete;
7593 WSM_log_PVT.LogMessage(
7594 p_module_name => l_module,
7595 p_msg_name => 'WSM_MES_START>RESSTARTDATE',
7596 p_msg_appl_name => 'WSM',
7597 p_msg_text => NULL,
7598 p_stmt_num => l_stmt_num,
7599 p_msg_tokens => l_msg_tokens,
7600 p_wsm_warning => NULL,
7601 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7602 p_run_log_level => l_log_level
7603 );
7604 add_Resource_error_info(
7605 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7606 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7607 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7608 , p_organization_id => l_organization_id
7609 );
7610 FND_MESSAGE.SET_NAME('WSM','WSM_MES_START>RESSTARTDATE');
7611 FND_MSG_PUB.add;
7612 ROLLBACK TO validation;
7613 RAISE FND_API.G_EXC_ERROR;
7614 END IF;
7615
7616 l_stmt_num := 110.24;
7617
7618 IF nvl(p_jobop_resource_usages_tbls(l_header_id)(i).projected_completion_date, sysdate) > p_expected_completion_date THEN
7619 l_stmt_num := 110.241;
7620 l_msg_tokens.delete;
7621 WSM_log_PVT.LogMessage(
7622 p_module_name => l_module,
7623 p_msg_name => 'WSM_MES_PROJCOMPL<RESPROJCOMPL',
7624 p_msg_appl_name => 'WSM',
7625 p_msg_text => NULL,
7626 p_stmt_num => l_stmt_num,
7627 p_msg_tokens => l_msg_tokens,
7628 p_wsm_warning => NULL,
7629 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7630 p_run_log_level => l_log_level
7631 );
7632 add_Resource_error_info(
7633 p_resource_id => p_jobop_resource_usages_tbls(l_header_id)(i).resource_id
7634 , p_resource_instance_id => p_jobop_resource_usages_tbls(l_header_id)(i).instance_id
7635 , p_resource_serial_number => p_jobop_resource_usages_tbls(l_header_id)(i).serial_number
7636 , p_organization_id => l_organization_id
7637 );
7638 FND_MESSAGE.SET_NAME('WSM','WSM_MES_PROJCOMPL<RESPROJCOMPL');
7639 FND_MSG_PUB.add;
7640 ROLLBACK TO validation;
7641 RAISE FND_API.G_EXC_ERROR;
7642
7643 END IF;
7644
7645 END LOOP;
7646
7647 IF (p_operation_start_date IS NOT NULL) AND (p_expected_completion_date IS NOT NULL)
7648 AND (p_operation_start_date > p_expected_completion_date)
7649 THEN
7650 l_stmt_num := 110.251;
7651 l_msg_tokens.delete;
7652 WSM_log_PVT.LogMessage(
7653 p_module_name => l_module,
7654 p_msg_name => 'WSM_MES_PROJCOMPL<STARTDATE',
7655 p_msg_appl_name => 'WSM',
7656 p_msg_text => NULL,
7657 p_stmt_num => l_stmt_num,
7658 p_msg_tokens => l_msg_tokens,
7659 p_wsm_warning => NULL,
7660 p_fnd_log_level => G_LOG_LEVEL_ERROR,
7661 p_run_log_level => l_log_level
7662 );
7663
7664 FND_MESSAGE.SET_NAME('WSM','WSM_MES_PROJCOMPL<STARTDATE');
7665 FND_MSG_PUB.add;
7666 ROLLBACK TO validation;
7667 RAISE FND_API.G_EXC_ERROR;
7668
7669 END IF;
7670
7671 END IF;
7672
7673 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7674 l_msg_tokens.delete;
7675 WSM_log_PVT.logMessage (
7676 p_module_name => l_module ,
7677 p_msg_text => 'End MES Move In Validations',
7678 p_stmt_num => l_stmt_num ,
7679 p_msg_tokens => l_msg_tokens ,
7680 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7681 p_run_log_level => l_log_level
7682 );
7683 END IF;
7684 END IF;
7685 l_stmt_num := 110.253;
7686
7687 --MES END
7688
7689 l_stmt_num := 120;
7690
7691 -- ST : Serial Project --
7692 -- Obtain assembly item id
7693 SELECT nvl(common_routing_sequence_id, routing_reference_id),
7694 TO_CHAR(nvl(routing_revision_date, SYSDATE), 'YYYY/MM/DD HH24:MI:SS'), /* CHG: BUG2380517 add SS */
7695 /* ADD: CZH.I_OED-1 */
7696 primary_item_id
7697 INTO l_routing_seq_id,
7698 l_rtg_revision_date, /* ADD: CZH.I_OED-1 */
7699 l_primary_item_id
7700 FROM wip_discrete_jobs
7701 WHERE wip_entity_id = l_wip_entity_id;
7702 -- ST : Serial Project --
7703
7704 l_stmt_num := 130.2;
7705 WSMPUTIL.find_routing_end(l_routing_seq_id,
7706 /* BA: CZH.I_OED-1 */
7707 TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS'), /* CHG: BUG2380517 add SS */ /* EA: CZH.I_OED-1 */
7708 l_end_op_seq_id,
7709 x_error_code,
7710 x_error_msg);
7711
7712 IF (x_error_code=0) THEN
7713 FND_FILE.PUT_LINE(FND_FILE.LOG, 'find_routing_end returned success');
7714 ELSE
7715 l_error_msg := x_error_msg;
7716 FND_FILE.PUT_LINE(FND_FILE.LOG,'WSMPLBMI.custom_validation' ||'(stmt_num='||l_stmt_num||') : '||substrb(l_error_msg, 1,4000));
7717 ROLLBACK TO validation;
7718 error_handler(p_header_id => l_header_id
7719 , p_transaction_id => l_transaction_id
7720 , p_error_msg => l_error_msg
7721 , x_error_code => x_err_code
7722 , x_error_msg => x_err_msg);
7723 IF (x_err_code <> 0) THEN
7724 raise e_proc_exception;
7725 END IF;
7726 -- l_err_flag := 1; /*Added to fix bug #1815584*/
7727 GOTO inner_loop; /* go to get next entry */
7728 END IF;
7729
7730 /* BA: CZH.I_OED-2, should consider operation replacement */
7731 l_stmt_num := 140;
7732 l_end_op_seq_id := WSMPUTIL.replacement_op_seq_id(l_end_op_seq_id,
7733 TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS') ); /* CHG: BUG2380517 add SS */
7734 /* EA: CZH.I_OED-2 */
7735
7736 IF (l_transaction_type = 4) THEN
7737 l_undo_exists := 1;
7738 END IF;
7739
7740
7741 -- ST : Serial Support Project ---
7742 -- Place the call to the interface wrapper...
7743 IF l_serial_ctrl_code = 2 THEN
7744 DECLARE
7745 l_return_status VARCHAR2(1);
7746 l_error_msg VARCHAR2(2000);
7747 l_error_count NUMBER;
7748 l_serial_track_flag NUMBER;
7749 l_serial_tbl WSM_Serial_Support_Grp.wsm_serial_num_tbl;
7750 --Bug 5208097: Start of changes
7751 l_move_quantity NUMBER;
7752 l_scrap_quantity NUMBER;
7753 l_scrap_txn_id1 NUMBER;
7754 --Bug 5208097:End of changes
7755 BEGIN
7756
7757 -- Pass the serial numbers table only when the data exists..
7758 IF p_jobop_scrap_serials_tbls.exists(l_header_id)
7759 THEN
7760 l_serial_tbl := p_jobop_scrap_serials_tbls(l_header_id);
7761 END IF;
7762
7763 if l_to_intraoperation_step_type = 5 then
7764 l_move_quantity := 0;
7765 l_scrap_quantity := l_primary_quantity;
7766 l_scrap_txn_id1 := l_transaction_id;
7767 else
7768 l_move_quantity := l_primary_quantity;
7769 l_scrap_quantity := l_converted_scrap_qty;
7770 l_scrap_txn_id1 := l_scrap_txn_id;
7771 end if;
7772
7773 WSM_Serial_support_Pvt.Move_serial_intf_proc ( p_header_id => l_header_id ,
7774 -- p_wsm_serial_nums_tbl => p_jobop_scrap_serials_tbls(l_header_id),
7775 p_wsm_serial_nums_tbl => l_serial_tbl,
7776 p_move_txn_type => l_transaction_type ,
7777 p_wip_entity_id => l_wip_entity_id ,
7778 p_organization_id => l_organization_id ,
7779 p_inventory_item_id => l_primary_item_id ,
7780 --Bug 5208097: Start of changes
7781 --p_move_qty => l_primary_quantity ,
7782 --p_scrap_qty => l_converted_scrap_qty ,
7783 p_move_qty => l_move_quantity,
7784 p_scrap_qty => l_scrap_quantity,
7785 --Bug 5208097: End of changes
7786 p_available_qty => l_available_qty ,
7787 -- the following fields will be used for forward move/completion alone....
7788 p_curr_job_op_seq_num => l_current_job_op_seq_num ,
7789 p_curr_job_intraop_step => l_current_intraop_step ,
7790 p_from_rtg_op_seq_num => l_current_rtg_op_seq_num ,
7791 p_to_rtg_op_seq_num => l_to_op_seq_num ,
7792 p_to_intraoperation_step => l_to_intraoperation_step_type,
7793 ---------------------------------------------------------------------------
7794 p_user_serial_tracking => l_user_serial_tracking ,
7795 p_move_txn_id => l_transaction_id ,
7796 --Bug 5208097: End of changes
7797 --p_scrap_txn_id => l_scrap_txn_id ,
7798 p_scrap_txn_id => l_scrap_txn_id1 ,
7799 --Bug 5208097: End of changes
7800 p_old_move_txn_id => l_old_move_transaction_id ,
7801 p_old_scrap_txn_id => l_old_scrap_transaction_id ,
7802 p_jump_flag => l_jump_flag ,
7803 p_scrap_at_operation => l_scrap_at_operation_flag ,
7804 -- ST : Fix for bug 5140761 Addded the above parameter --
7805 x_serial_track_flag => l_serial_track_flag ,
7806 x_return_status => l_return_status ,
7807 x_error_msg => l_error_msg ,
7808 x_error_count => l_error_count
7809 );
7810
7811 if l_return_status = FND_API.G_RET_STS_SUCCESS then
7812 IF (l_debug='Y') THEN
7813 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Move_serial_intf_proc returned Success');
7814 END IF;
7815 ELSE
7816
7817 IF (l_error_count = 1) THEN
7818 fnd_file.put_line(fnd_file.log, l_error_msg);
7819 ELSIF (l_error_count > 1) THEN
7820 FOR i IN 1..l_error_count LOOP
7821 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
7822 p_encoded => FND_API.G_FALSE
7823 );
7824 fnd_file.put_line(fnd_file.log, l_error_msg);
7825 END LOOP;
7826 ELSE
7827 l_error_msg := 'WSM_Serial_support_PVT.LBJ_serial_intf_proc returned failure';
7828 END IF;
7829
7830 IF (l_debug='Y') THEN
7831 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Move_serial_intf_proc returned failure');
7832 END IF;
7833
7834 ROLLBACK TO validation;
7835 error_handler(p_header_id => l_header_id ,
7836 p_transaction_id => l_transaction_id ,
7837 p_error_msg => l_error_msg ,
7838 x_error_code => x_err_code ,
7839 x_error_msg => x_err_msg);
7840
7841 IF (x_err_code <> 0) THEN
7842 raise e_proc_exception;
7843 END IF;
7844
7845 GOTO inner_loop; -- go to get next interface record...
7846 END IF;
7847 END;
7848 END IF;
7849 -- ST : Serial Support Project ---
7850 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7851 l_msg_tokens.delete;
7852 WSM_log_PVT.logMessage (
7853 p_module_name => l_module,
7854 p_msg_text => 'B4 IF ((l_transaction_type=2) OR (l_transaction_type = 3))'||
7855 ';l_transaction_type '||
7856 l_transaction_type,
7857 p_stmt_num => l_stmt_num,
7858 p_msg_tokens => l_msg_tokens,
7859 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7860 p_run_log_level => l_log_level
7861 );
7862 END IF;
7863
7864 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7865 l_msg_tokens.delete;
7866 WSM_log_PVT.logMessage (
7867 p_module_name => l_module,
7868 p_msg_text => 'B4 IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
7869 ';l_transaction_type '||
7870 l_transaction_type,
7871 p_stmt_num => l_stmt_num,
7872 p_msg_tokens => l_msg_tokens,
7873 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7874 p_run_log_level => l_log_level
7875 );
7876 END IF;
7877
7878 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7879 l_msg_tokens.delete;
7880 WSM_log_PVT.logMessage (
7881 p_module_name => l_module,
7882 p_msg_text => 'B4 IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
7883 'l_scrap_qty '||l_scrap_qty||
7884 ' l_available_qty '||l_available_qty||
7885 ' l_primary_quantity '||l_primary_quantity,
7886 p_stmt_num => l_stmt_num,
7887 p_msg_tokens => l_msg_tokens,
7888 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7889 p_run_log_level => l_log_level
7890 );
7891 END IF;
7892
7893 IF ((l_transaction_type=2) OR (l_transaction_type = 3)) THEN
7894 l_ac_ar_exists := 1; /* Assy completion or Return exists */
7895 l_dup_flag := 0; /* Initialize dup flag */
7896
7897 DECLARE
7898 l_subinventory VARCHAR2(10);
7899 l_new_name VARCHAR2(240);
7900 l_dup_name VARCHAR2(240);
7901 l_update_flag BOOLEAN:=FALSE;
7902 BEGIN
7903 l_stmt_num := 150;
7904
7905 SELECT completion_subinventory
7906 INTO l_subinventory
7907 FROM wip_discrete_jobs
7908 WHERE wip_entity_id = l_wip_entity_id;
7909
7910 /* Call for Assy completion as well as Assy returns */
7911 IF (l_debug = 'Y') THEN
7912 fnd_file.put_line(fnd_file.log, 'l_wip_entity_id '||l_wip_entity_id||
7913 ' l_subinventory '||l_subinventory||
7914 ' l_organization_id '||l_organization_id||
7915 ' l_transaction_type '||l_transaction_type||
7916 ' l_dup_name '||l_dup_name);
7917 END IF;
7918
7919 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7920 l_msg_tokens.delete;
7921 WSM_log_PVT.logMessage (
7922 p_module_name => l_module,
7923 p_msg_text => 'In IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
7924 'l_wip_entity_id '||l_wip_entity_id||
7925 ' l_subinventory '||l_subinventory||
7926 ' l_organization_id '||l_organization_id||
7927 ' l_transaction_type '||l_transaction_type||
7928 ' l_dup_name '||l_dup_name,
7929 p_stmt_num => l_stmt_num,
7930 p_msg_tokens => l_msg_tokens,
7931 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7932 p_run_log_level => l_log_level
7933 );
7934 END IF;
7935
7936 l_stmt_num := 130.3;
7937 l_new_name := WSMPOPRN.update_job_name(l_wip_entity_id,
7938 l_subinventory,
7939 l_organization_id,
7940 l_transaction_type,
7941 l_update_flag,
7942 l_dup_name,
7943 x_error_code,
7944 x_error_msg);
7945
7946 IF (l_debug = 'Y') THEN
7947 fnd_file.put_line(fnd_file.log, 'x_error_code '||x_error_code||
7948 ' x_error_msg '||x_error_msg||
7949 ' l_new_name '||l_new_name);
7950 END IF;
7951
7952 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7953 l_msg_tokens.delete;
7954 WSM_log_PVT.logMessage (
7955 p_module_name => l_module,
7956 p_msg_text => 'In IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
7957 ' x_error_msg '||x_error_msg||
7958 ' l_new_name '||l_new_name,
7959 p_stmt_num => l_stmt_num,
7960 p_msg_tokens => l_msg_tokens,
7961 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
7962 p_run_log_level => l_log_level
7963 );
7964 END IF;
7965
7966 IF ((l_new_name IS NOT NULL) AND (l_new_name <> '-1')) THEN
7967 UPDATE wsm_lot_move_txn_interface
7968 SET new_wip_entity_name=l_new_name
7969 where rowid=l_rowid;
7970 ELSE
7971 l_error_msg := x_error_msg;
7972 FND_FILE.PUT_LINE(FND_FILE.LOG,'WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||substrb(l_error_msg, 1,4000));
7973 ROLLBACK TO validation;
7974 error_handler(p_header_id => l_header_id
7975 , p_transaction_id => l_transaction_id
7976 , p_error_msg => l_error_msg
7977 , x_error_code => x_err_code
7978 , x_error_msg => x_err_msg);
7979 IF (x_err_code <> 0) THEN
7980 raise e_proc_exception;
7981 END IF;
7982 -- l_err_flag := 1; /*Added to fix bug #1815584*/
7983 GOTO inner_loop; /* go to get next entry */
7984 END IF;
7985 END;
7986
7987 l_stmt_num := 205;
7988 IF (g_mrp_debug='Y') THEN
7989 fnd_file.put_line(fnd_file.log, 'update_job_name returned success');
7990 END IF;
7991 END IF;
7992
7993 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7994 l_msg_tokens.delete;
7995 WSM_log_PVT.logMessage (
7996 p_module_name => l_module,
7997 p_msg_text =>
7998 'l_transaction_type '||l_transaction_type||
7999 ' l_converted_scrap_qty '||l_converted_scrap_qty||
8000 ' l_available_qty '||l_available_qty||
8001 ' l_primary_quantity '||l_primary_quantity,
8002 p_stmt_num => l_stmt_num,
8003 p_msg_tokens => l_msg_tokens,
8004 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
8005 p_run_log_level => l_log_level
8006 );
8007 END IF;
8008 --bug 4380374
8009 IF ( ( (l_transaction_type = 1)
8010 AND
8011 ( (l_converted_scrap_qty = l_available_qty)
8012 OR
8013 ( (l_primary_quantity = l_available_qty)
8014 AND
8015 (l_to_intraoperation_step_type = WIP_CONSTANTS.SCRAP)
8016 )
8017 )
8018 )
8019 OR
8020 ( (l_transaction_type = 4)
8021 AND
8022 (l_available_qty = 0)
8023 )
8024 )
8025 THEN
8026 l_dup_flag := 0; /* Initialize dup flag */
8027
8028 DECLARE
8029 l_subinventory VARCHAR2(10);
8030 l_new_name VARCHAR2(240);
8031 l_dup_name VARCHAR2(240);
8032 l_update_flag BOOLEAN:=FALSE;
8033 BEGIN
8034 l_stmt_num := 150;
8035
8036 SELECT completion_subinventory
8037 INTO l_subinventory
8038 FROM wip_discrete_jobs
8039 WHERE wip_entity_id = l_wip_entity_id;
8040
8041 /* Call for Assy completion as well as Assy returns */
8042 IF (l_debug = 'Y') THEN
8043 fnd_file.put_line(fnd_file.log, 'l_wip_entity_id '||l_wip_entity_id||
8044 ' l_subinventory '||l_subinventory||
8045 ' l_organization_id '||l_organization_id||
8046 ' l_transaction_type '||l_transaction_type||
8047 ' l_dup_name '||l_dup_name);
8048 END IF;
8049
8050 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8051 l_msg_tokens.delete;
8052 WSM_log_PVT.logMessage (
8053 p_module_name => l_module,
8054 p_msg_text => 'In IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
8055 'l_wip_entity_id '||l_wip_entity_id||
8056 ' l_subinventory '||l_subinventory||
8057 ' l_organization_id '||l_organization_id||
8058 ' l_transaction_type '||l_transaction_type||
8059 ' l_dup_name '||l_dup_name||
8060 ' l_converted_scrap_qty '||l_converted_scrap_qty||
8061 ' l_available_qty '||l_available_qty||
8062 ' l_fm_intraoperation_step_type '||l_fm_intraoperation_step_type||
8063 ' l_to_intraoperation_step_type '||l_to_intraoperation_step_type||
8064 ' l_primary_quantity '||l_primary_quantity,
8065 p_stmt_num => l_stmt_num,
8066 p_msg_tokens => l_msg_tokens,
8067 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
8068 p_run_log_level => l_log_level
8069 );
8070 END IF;
8071
8072 l_stmt_num := 130.3;
8073 IF (l_transaction_type = 1) THEN
8074 l_temp_txn_type := 2;
8075 ELSIF (l_transaction_type = 4) THEN
8076 l_temp_txn_type := 3;
8077 END IF;
8078
8079 l_new_name := WSMPOPRN.update_job_name(l_wip_entity_id,
8080 l_subinventory,
8081 l_organization_id,
8082 l_temp_txn_type,
8083 l_update_flag,
8084 l_dup_name,
8085 x_error_code,
8086 x_error_msg);
8087
8088 IF (l_debug = 'Y') THEN
8089 fnd_file.put_line(fnd_file.log, 'x_error_code '||x_error_code||
8090 ' x_error_msg '||x_error_msg||
8091 ' l_new_name '||l_new_name);
8092 END IF;
8093
8094 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8095 l_msg_tokens.delete;
8096 WSM_log_PVT.logMessage (
8097 p_module_name => l_module,
8098 p_msg_text => 'In IF ((l_transaction_type=2) OR (l_transaction_type = 3)) '||
8099 ' x_error_msg '||x_error_msg||
8100 ' l_new_name '||l_new_name,
8101 p_stmt_num => l_stmt_num,
8102 p_msg_tokens => l_msg_tokens,
8103 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
8104 p_run_log_level => l_log_level
8105 );
8106 END IF;
8107
8108 IF ((l_new_name IS NOT NULL) AND (l_new_name <> '-1')) THEN
8109 UPDATE wip_entities
8110 SET wip_entity_name = l_new_name
8111 WHERE wip_entity_id = l_wip_entity_id;
8112
8113 UPDATE wsm_lot_move_txn_interface
8114 SET wip_entity_name=l_new_name
8115 where rowid=l_rowid;
8116 ELSE
8117 l_error_msg := x_error_msg;
8118 FND_FILE.PUT_LINE(FND_FILE.LOG,'WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||substrb(l_error_msg, 1,4000));
8119 ROLLBACK TO validation;
8120 error_handler(p_header_id => l_header_id
8121 , p_transaction_id => l_transaction_id
8122 , p_error_msg => l_error_msg
8123 , x_error_code => x_err_code
8124 , x_error_msg => x_err_msg);
8125 IF (x_err_code <> 0) THEN
8126 raise e_proc_exception;
8127 END IF;
8128 -- l_err_flag := 1; /*Added to fix bug #1815584*/
8129 GOTO inner_loop; /* go to get next entry */
8130 END IF;
8131 END;
8132
8133 l_stmt_num := 205;
8134 IF (g_mrp_debug='Y') THEN
8135 fnd_file.put_line(fnd_file.log, 'update_job_name returned success');
8136 END IF;
8137 END IF;
8138 --end bug 4380374
8139
8140 l_fm_operation_code := null;
8141 l_to_operation_code := null;
8142
8143 /* abb, NSO addition begin */
8144 /* BC: CZH.BUG2442776 if jumping outside routing, this should not be called */
8145 l_to_op_seq_id := -2; /* init it to 2 */
8146 /* EC: CZH.BUG2442776*/
8147
8148 IF (g_aps_wps_profile='N') THEN
8149 IF (l_debug='Y') THEN
8150 fnd_file.put_line(fnd_file.log, 'l_to_op_seq_num '||l_to_op_seq_num||' l_routing_seq_id '
8151 ||l_routing_seq_id||' l_rtg_revision_date '||l_rtg_revision_date);
8152 END IF;
8153
8154 -- Bug 4480248 Added the condition ( AND l_to_op_seq_num is NOT NULL) in the IF statement below
8155 IF (((l_jump_flag <> 'Y') AND (l_transaction_type NOT IN (3, 4))) AND l_to_op_seq_num is NOT NULL) THEN
8156 l_stmt_num := 160;
8157
8158 SELECT NVL(operation_sequence_id, -2)
8159 INTO l_to_op_seq_id
8160 FROM bom_operation_sequences
8161 WHERE operation_seq_num = l_to_op_seq_num
8162 AND routing_sequence_id = l_routing_seq_id
8163 /* BC: CZH.I_OED-1 compare against rtg_rev_date */
8164 AND nvl(disable_date, TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS')+1)
8165 >= TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS') /* CHG: BUG2380517 add SS, > to >= */
8166 AND nvl(effectivity_date, TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS')) <= TO_DATE(l_rtg_revision_date, 'YYYY/MM/DD HH24:MI:SS'); /* CHG: BUG2380517 add SS */
8167 /* EC: CZH.I_OED-1 */
8168 /* CZH: no exception will be thrown if no data found, l_to_op_seq_id remain unchanged */
8169 END IF;
8170 ELSE
8171 l_stmt_num := 170;
8172
8173 -- Bug 4480248 Added the condition ( AND l_to_op_seq_num is NOT NULL) in the IF statement below
8174 IF (((l_jump_flag <> 'Y') AND (l_transaction_type NOT IN (3, 4))) AND l_to_op_seq_num is NOT NULL) THEN
8175 SELECT nvl(operation_sequence_id, -2)
8176 INTO l_to_op_seq_id
8177 FROM WSM_COPY_OPERATIONS
8178 WHERE wip_entity_id=l_wip_entity_id
8179 AND operation_seq_num = l_to_op_seq_num;
8180 END IF;
8181 END IF;
8182
8183 l_stmt_num := 180;
8184 --move enh added IF condn
8185 IF (l_transaction_type <> 3) THEN
8186 select NVL(operation_sequence_id, -1) -- CZH.bug2393850 in op outside routing
8187 into l_fm_op_seq_id
8188 from wip_operations
8189 where wip_entity_id = l_wip_entity_id
8190 and operation_seq_num = l_fm_op_seq_num;
8191 END IF;
8192
8193 /*abb, NSO addition end*/
8194
8195 /* if( ( (l_to_op_seq_id == l_fm_op_seq_id) && (l_fm_op_seq_num == l_to_op_seq_num) ) */
8196 /* CHG: CZH, should not compare op_seq_num */
8197 --bug 4090905: added jump flag check.
8198 IF ( ((l_to_op_seq_id = l_fm_op_seq_id) and (l_jump_flag <> 'Y'))/* @ inside rtg */
8199 OR
8200 ( l_fm_op_seq_id = -1 /* @ outside routing */
8201 AND (l_fm_operation_code = l_to_operation_code))
8202 /*
8203 * CZH: added the following condition, this was a bug in OSFM code for a while.
8204 * user should be able to jump to the same op code @ outside routing
8205 */
8206 AND (l_jump_flag <> 'Y') ) THEN
8207 l_max_op_seq := l_fm_op_seq_num;
8208 else
8209 l_stmt_num := 190;
8210
8211 SELECT unique max(operation_seq_num)
8212 INTO l_max_op_seq -- will be the newly added row in WO
8213 FROM wip_operations
8214 WHERE WIP_ENTITY_ID = l_wip_entity_id;
8215
8216
8217 END IF;
8218
8219 /* End Fixed bug #1560345 */
8220
8221 l_stmt_num := 200;
8222 /******************************************************************
8223 * insert record into WMTI, will call WIP user_exit to process it *
8224 ******************************************************************/
8225
8226 --move enh To determine the WIP move txns we need to insert we need the data in the variables we pass into LBMIB.
8227 l_count := 0;
8228
8229 IF (l_scrap_qty>0) THEN
8230 IF (l_transaction_type in (1, 2)) THEN
8231 l_op_flag := 1;
8232 ELSE
8233 IF ((l_scrap_at_operation_flag=1) or (l_scrap_at_operation_flag IS NULL)) THEN
8234 l_op_flag := 2;
8235 ELSIF (l_scrap_at_operation_flag=2) THEN
8236 l_op_flag := 1;
8237 END IF;
8238 END IF;
8239 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8240 l_msg_tokens.delete;
8241 WSM_log_PVT.logMessage (
8242 p_module_name => l_module ,
8243 p_msg_text => 'Inserting WMTI row for scrap qty',
8244 p_stmt_num => l_stmt_num ,
8245 p_msg_tokens => l_msg_tokens ,
8246 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8247 p_run_log_level => l_log_level
8248 );
8249 END IF;
8250
8251 INSERT INTO wip_move_txn_interface(
8252 TRANSACTION_ID,
8253 LAST_UPDATE_DATE,
8254 LAST_UPDATED_BY,
8255 LAST_UPDATED_BY_NAME,
8256 CREATION_DATE,
8257 CREATED_BY,
8258 CREATED_BY_NAME,
8259 LAST_UPDATE_LOGIN,
8260 REQUEST_ID,
8261 PROGRAM_APPLICATION_ID,
8262 PROGRAM_ID,
8263 PROGRAM_UPDATE_DATE,
8264 GROUP_ID,
8265 SOURCE_CODE,
8266 SOURCE_LINE_ID,
8267 PROCESS_PHASE,
8268 PROCESS_STATUS ,
8269 TRANSACTION_TYPE,
8270 ORGANIZATION_ID,
8271 ORGANIZATION_CODE,
8272 WIP_ENTITY_ID,
8273 WIP_ENTITY_NAME,
8274 ENTITY_TYPE,
8275 PRIMARY_ITEM_ID,
8276 LINE_ID,
8277 LINE_CODE,
8278 REPETITIVE_SCHEDULE_ID,
8279 TRANSACTION_DATE,
8280 ACCT_PERIOD_ID,
8281 FM_OPERATION_SEQ_NUM,
8282 FM_OPERATION_CODE,
8283 FM_DEPARTMENT_ID,
8284 FM_DEPARTMENT_CODE,
8285 FM_INTRAOPERATION_STEP_TYPE,
8286 TO_OPERATION_SEQ_NUM,
8287 TO_OPERATION_CODE,
8288 TO_DEPARTMENT_ID,
8289 TO_DEPARTMENT_CODE,
8290 TO_INTRAOPERATION_STEP_TYPE,
8291 TRANSACTION_QUANTITY,
8292 TRANSACTION_UOM,
8293 PRIMARY_QUANTITY,
8294 PRIMARY_UOM ,
8295 SCRAP_ACCOUNT_ID,
8296 REASON_ID,
8297 REASON_NAME,
8298 REFERENCE,
8299 ATTRIBUTE_CATEGORY,
8300 ATTRIBUTE1,
8301 ATTRIBUTE2,
8302 ATTRIBUTE3,
8303 ATTRIBUTE4,
8304 ATTRIBUTE5,
8305 ATTRIBUTE6,
8306 ATTRIBUTE7,
8307 ATTRIBUTE8,
8308 ATTRIBUTE9,
8309 ATTRIBUTE10,
8310 ATTRIBUTE11,
8311 ATTRIBUTE12,
8312 ATTRIBUTE13,
8313 ATTRIBUTE14,
8314 ATTRIBUTE15,
8315 QA_COLLECTION_ID,
8316 KANBAN_CARD_ID,
8317 OVERCOMPLETION_TRANSACTION_QTY,
8318 OVERCOMPLETION_PRIMARY_QTY,
8319 OVERCOMPLETION_TRANSACTION_ID,
8320 PROCESSING_ORDER,
8321 BATCH_ID,
8322 EMPLOYEE_ID)
8323 (SELECT
8324 decode(l_transaction_quantity,
8325 0, l_transaction_id,
8326 --bug 3615826
8327 -- wip_transactions_s.nextval),
8328 internal_scrap_txn_id),
8329 LAST_UPDATE_DATE,
8330 LAST_UPDATED_BY,
8331 LAST_UPDATED_BY_NAME,
8332 CREATION_DATE,
8333 CREATED_BY,
8334 CREATED_BY_NAME,
8335 LAST_UPDATE_LOGIN,
8336 REQUEST_ID,
8337 PROGRAM_APPLICATION_ID,
8338 PROGRAM_ID,
8339 PROGRAM_UPDATE_DATE,
8340 decode(SOURCE_CODE,
8341 --bug 5446252 match transaction_id with group_id for WIP single move api
8342 --'move out oa page', internal_scrap_txn_id,
8343 'move out oa page', decode(l_transaction_quantity,
8344 0, l_transaction_id,
8345 internal_scrap_txn_id),
8346 --'undo oa page', internal_scrap_txn_id,
8347 'undo oa page', decode(l_transaction_quantity,
8348 0, l_transaction_id,
8349 internal_scrap_txn_id),
8350 l_wmti_group_id), -- GROUP_ID
8351 SOURCE_CODE,
8352 SOURCE_LINE_ID,
8353 decode(SOURCE_CODE,
8354 'move out oa page', WIP_CONSTANTS.MOVE_PROC,
8355 'undo oa page', WIP_CONSTANTS.MOVE_PROC,
8356 g_move_val), --1 Process_Phase, --2721366: Replaced 1 with constant
8357 g_running, --1 Process_Status , --2721366: Replaced 1 with constant
8358 g_move_txn,
8359 ORGANIZATION_ID,
8360 ORGANIZATION_CODE,
8361 WIP_ENTITY_ID,
8362 WIP_ENTITY_NAME,
8363 ENTITY_TYPE,
8364 PRIMARY_ITEM_ID,
8365 LINE_ID,
8366 LINE_CODE,
8367 REPETITIVE_SCHEDULE_ID,
8368 TRANSACTION_DATE,
8369 ACCT_PERIOD_ID,
8370 decode(l_op_flag,
8371 1, fm_operation_seq_num,
8372 2, to_operation_seq_num),
8373 decode(l_op_flag,
8374 1, fm_operation_code,
8375 2, to_operation_code),
8376 decode(l_op_flag,
8377 1, fm_department_id,
8378 2, to_department_id),
8379 decode(l_op_flag,
8380 1, fm_department_code,
8381 2, to_department_code),
8382 decode(TRANSACTION_TYPE,
8383 4, g_scrap,
8384 g_ret_txn, g_scrap,
8385 FM_INTRAOPERATION_STEP_TYPE),
8386 decode(TRANSACTION_TYPE,
8387 g_ret_txn, TO_OPERATION_SEQ_NUM,
8388 4, TO_OPERATION_SEQ_NUM,
8389 decode(SCRAP_AT_OPERATION_FLAG,
8390 1, fm_operation_seq_num,
8391 l_max_op_seq)),
8392 decode(TRANSACTION_TYPE,
8393 g_ret_txn, TO_OPERATION_CODE,
8394 4, TO_OPERATION_CODE,
8395 decode(SCRAP_AT_OPERATION_FLAG,
8396 1, fm_OPERATION_CODE,
8397 to_OPERATION_CODE)),
8398 decode(TRANSACTION_TYPE,
8399 g_ret_txn, TO_DEPARTMENT_ID,
8400 4, TO_DEPARTMENT_ID,
8401 decode(SCRAP_AT_OPERATION_FLAG,
8402 1, fm_DEPARTMENT_ID,
8403 to_DEPARTMENT_ID)),
8404 decode(TRANSACTION_TYPE,
8405 g_ret_txn, TO_DEPARTMENT_CODE,
8406 4, TO_DEPARTMENT_CODE,
8407 decode(SCRAP_AT_OPERATION_FLAG,
8408 1, fm_DEPARTMENT_CODE,
8409 TO_DEPARTMENT_CODE)),
8410 decode(TRANSACTION_TYPE,
8411 g_move_txn, g_scrap,
8412 g_comp_txn, g_scrap,
8413 TO_INTRAOPERATION_STEP_TYPE),
8414 SCRAP_QUANTITY,
8415 TRANSACTION_UOM,
8416 PRIMARY_SCRAP_QUANTITY,
8417 PRIMARY_UOM ,
8418 SCRAP_ACCOUNT_ID,
8419 REASON_ID,
8420 REASON_NAME,
8421 REFERENCE,
8422 ATTRIBUTE_CATEGORY,
8423 ATTRIBUTE1,
8424 ATTRIBUTE2,
8425 ATTRIBUTE3,
8426 ATTRIBUTE4,
8427 ATTRIBUTE5,
8428 ATTRIBUTE6,
8429 ATTRIBUTE7,
8430 ATTRIBUTE8,
8431 ATTRIBUTE9,
8432 ATTRIBUTE10,
8433 ATTRIBUTE11,
8434 ATTRIBUTE12,
8435 ATTRIBUTE13,
8436 ATTRIBUTE14,
8437 ATTRIBUTE15,
8438 QA_COLLECTION_ID,
8439 --move enh?
8440 KANBAN_CARD_ID, --move enh?
8441 OVERCOMPLETION_TRANSACTION_QTY,
8442 OVERCOMPLETION_PRIMARY_QTY,
8443 OVERCOMPLETION_TRANSACTION_ID,
8444 --The decode below is not required and is incorrect, but decided not to remove since code is stable
8445 decode(TRANSACTION_TYPE,
8446 g_comp_txn, g_ret_txn,
8447 1), /*processing_order*/
8448 TRANSACTION_ID,
8449 p_employee_id
8450 FROM wsm_lot_move_txn_interface
8451 WHERE header_id = l_header_id);
8452
8453 l_count := SQL%ROWCOUNT;
8454 IF (g_mrp_debug='Y') THEN
8455 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') :
8456 Inserted Scrap Txn');
8457 END IF;
8458
8459 --mes populate l_job_fm_op_seq_num, l_job_to_op_seq_num
8460 IF (l_transaction_quantity = 0) THEN
8461 SELECT fm_operation_seq_num, to_operation_seq_num
8462 INTO l_fm_op_seq_num, l_job_to_op_seq_num
8463 FROM WIP_MOVE_TXN_INTERFACE
8464 WHERE transaction_id = l_transaction_id;
8465 END IF;
8466 END IF;
8467
8468 l_stmt_num := 210;
8469
8470 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8471 l_msg_tokens.delete;
8472 WSM_log_PVT.logMessage (
8473 p_module_name => l_module ,
8474 p_msg_text => 'B4 IF (l_transaction_quantity>0) l_transaction_quantity '||l_transaction_quantity,
8475 p_stmt_num => l_stmt_num ,
8476 p_msg_tokens => l_msg_tokens ,
8477 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8478 p_run_log_level => l_log_level
8479 );
8480 END IF;
8481
8482 IF (l_transaction_quantity > 0) THEN
8483 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8484 l_msg_tokens.delete;
8485 WSM_log_PVT.logMessage (
8486 p_module_name => l_module ,
8487 p_msg_text => 'Inserting WMTI row for move qty',
8488 p_stmt_num => l_stmt_num ,
8489 p_msg_tokens => l_msg_tokens ,
8490 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8491 p_run_log_level => l_log_level
8492 );
8493 END IF;
8494
8495 INSERT INTO wip_move_txn_interface(
8496 TRANSACTION_ID,
8497 LAST_UPDATE_DATE,
8498 LAST_UPDATED_BY,
8499 LAST_UPDATED_BY_NAME,
8500 CREATION_DATE,
8501 CREATED_BY,
8502 CREATED_BY_NAME,
8503 LAST_UPDATE_LOGIN,
8504 REQUEST_ID,
8505 PROGRAM_APPLICATION_ID,
8506 PROGRAM_ID,
8507 PROGRAM_UPDATE_DATE,
8508 GROUP_ID,
8509 SOURCE_CODE,
8510 SOURCE_LINE_ID,
8511 PROCESS_PHASE,
8512 PROCESS_STATUS ,
8513 TRANSACTION_TYPE,
8514 ORGANIZATION_ID,
8515 ORGANIZATION_CODE,
8516 WIP_ENTITY_ID,
8517 WIP_ENTITY_NAME,
8518 ENTITY_TYPE,
8519 PRIMARY_ITEM_ID,
8520 LINE_ID,
8521 LINE_CODE,
8522 REPETITIVE_SCHEDULE_ID,
8523 TRANSACTION_DATE,
8524 ACCT_PERIOD_ID,
8525 FM_OPERATION_SEQ_NUM,
8526 FM_OPERATION_CODE,
8527 FM_DEPARTMENT_ID,
8528 FM_DEPARTMENT_CODE,
8529 FM_INTRAOPERATION_STEP_TYPE,
8530 TO_OPERATION_SEQ_NUM,
8531 TO_OPERATION_CODE,
8532 TO_DEPARTMENT_ID,
8533 TO_DEPARTMENT_CODE,
8534 TO_INTRAOPERATION_STEP_TYPE,
8535 TRANSACTION_QUANTITY,
8536 TRANSACTION_UOM,
8537 PRIMARY_QUANTITY,
8538 PRIMARY_UOM ,
8539 SCRAP_ACCOUNT_ID,
8540 REASON_ID,
8541 REASON_NAME,
8542 REFERENCE,
8543 ATTRIBUTE_CATEGORY,
8544 ATTRIBUTE1,
8545 ATTRIBUTE2,
8546 ATTRIBUTE3,
8547 ATTRIBUTE4,
8548 ATTRIBUTE5,
8549 ATTRIBUTE6,
8550 ATTRIBUTE7,
8551 ATTRIBUTE8,
8552 ATTRIBUTE9,
8553 ATTRIBUTE10,
8554 ATTRIBUTE11,
8555 ATTRIBUTE12,
8556 ATTRIBUTE13,
8557 ATTRIBUTE14,
8558 ATTRIBUTE15,
8559 QA_COLLECTION_ID,
8560 KANBAN_CARD_ID,
8561 OVERCOMPLETION_TRANSACTION_QTY,
8562 OVERCOMPLETION_PRIMARY_QTY,
8563 OVERCOMPLETION_TRANSACTION_ID,
8564 PROCESSING_ORDER,
8565 BATCH_ID,
8566 EMPLOYEE_ID)
8567 (SELECT
8568 TRANSACTION_ID,
8569 LAST_UPDATE_DATE,
8570 LAST_UPDATED_BY,
8571 LAST_UPDATED_BY_NAME,
8572 CREATION_DATE,
8573 CREATED_BY,
8574 CREATED_BY_NAME,
8575 LAST_UPDATE_LOGIN,
8576 REQUEST_ID,
8577 PROGRAM_APPLICATION_ID,
8578 PROGRAM_ID,
8579 PROGRAM_UPDATE_DATE,
8580 decode(SOURCE_CODE,
8581 'move in oa page', TRANSACTION_ID,
8582 'move out oa page', TRANSACTION_ID,
8583 'move to next op oa page', TRANSACTION_ID,
8584 'jump oa page', TRANSACTION_ID,
8585 'undo oa page', TRANSACTION_ID,
8586 l_wmti_group_id), -- GROUP_ID
8587 SOURCE_CODE,
8588 SOURCE_LINE_ID,
8589 decode(SOURCE_CODE,
8590 'move in oa page', WIP_CONSTANTS.MOVE_PROC,
8591 'move out oa page', WIP_CONSTANTS.MOVE_PROC,
8592 'move to next op oa page', WIP_CONSTANTS.MOVE_PROC,
8593 'jump oa page', WIP_CONSTANTS.MOVE_PROC,
8594 'undo oa page', WIP_CONSTANTS.MOVE_PROC,
8595 g_move_val), --1 Process_Phase, --2721366: Replaced 1 with constant
8596 g_running, --1 Process_Status , --2721366: Replaced 1 with constant
8597 decode(TRANSACTION_TYPE,4, 1, TRANSACTION_TYPE),
8598 ORGANIZATION_ID,
8599 ORGANIZATION_CODE,
8600 WIP_ENTITY_ID,
8601 WIP_ENTITY_NAME,
8602 ENTITY_TYPE,
8603 PRIMARY_ITEM_ID,
8604 LINE_ID,
8605 LINE_CODE,
8606 REPETITIVE_SCHEDULE_ID,
8607 TRANSACTION_DATE,
8608 ACCT_PERIOD_ID,
8609 FM_OPERATION_SEQ_NUM,
8610 FM_OPERATION_CODE,
8611 FM_DEPARTMENT_ID,
8612 FM_DEPARTMENT_CODE,
8613 FM_INTRAOPERATION_STEP_TYPE,
8614 decode(TRANSACTION_TYPE, 1, l_max_op_seq, 2, l_max_op_seq, TO_OPERATION_SEQ_NUM),
8615 TO_OPERATION_CODE,
8616 TO_DEPARTMENT_ID,
8617 TO_DEPARTMENT_CODE,
8618 TO_INTRAOPERATION_STEP_TYPE,
8619 TRANSACTION_QUANTITY,
8620 TRANSACTION_UOM,
8621 PRIMARY_QUANTITY,
8622 PRIMARY_UOM ,
8623 --bug 5092117 added decode statements
8624 decode(TO_INTRAOPERATION_STEP_TYPE,
8625 WIP_CONSTANTS.SCRAP, SCRAP_ACCOUNT_ID,
8626 decode(FM_INTRAOPERATION_STEP_TYPE,
8627 WIP_CONSTANTS.SCRAP, SCRAP_ACCOUNT_ID,
8628 NULL)
8629 ),
8630 REASON_ID,
8631 REASON_NAME,
8632 REFERENCE,
8633 ATTRIBUTE_CATEGORY,
8634 ATTRIBUTE1,
8635 ATTRIBUTE2,
8636 ATTRIBUTE3,
8637 ATTRIBUTE4,
8638 ATTRIBUTE5,
8639 ATTRIBUTE6,
8640 ATTRIBUTE7,
8641 ATTRIBUTE8,
8642 ATTRIBUTE9,
8643 ATTRIBUTE10,
8644 ATTRIBUTE11,
8645 ATTRIBUTE12,
8646 ATTRIBUTE13,
8647 ATTRIBUTE14,
8648 ATTRIBUTE15,
8649 QA_COLLECTION_ID,
8650 KANBAN_CARD_ID,
8651 OVERCOMPLETION_TRANSACTION_QTY,
8652 OVERCOMPLETION_PRIMARY_QTY,
8653 OVERCOMPLETION_TRANSACTION_ID,
8654 decode(TRANSACTION_TYPE, 3, 1, 2), /*processing_order*/
8655 TRANSACTION_ID,
8656 p_employee_id
8657 FROM wsm_lot_move_txn_interface
8658 WHERE header_id = l_header_id
8659 );
8660
8661 l_count := l_count+SQL%ROWCOUNT;
8662 IF (g_mrp_debug='Y') THEN
8663 fnd_file.put_line(fnd_file.log, 'Inserted '||l_count||' row(s) in WMTI, group_id '|| l_wmti_group_id||', txn_id '
8664 ||l_transaction_id||' scrap txn id '||l_scrap_txn_id);
8665 END IF;
8666
8667 --mes populate l_job_fm_op_seq_num, l_job_to_op_seq_num
8668 SELECT fm_operation_seq_num, to_operation_seq_num
8669 INTO l_fm_op_seq_num, l_job_to_op_seq_num
8670 FROM WIP_MOVE_TXN_INTERFACE
8671 WHERE transaction_id = l_transaction_id;
8672 END IF;
8673
8674
8675 IF (l_count = 0) THEN
8676 fnd_file.put_line(fnd_file.log, 'WARNING: Could not insert into WMTI');
8677
8678 l_stmt_num := 230;
8679 FND_MESSAGE.SET_NAME('WSM', 'WSM_INS_TBL_FAILED');
8680 FND_MESSAGE.SET_TOKEN('TABLE', 'wip_move_txn_interface');
8681 l_error_msg := FND_MESSAGE.GET;
8682 ROLLBACK TO VALIDATION;
8683
8684 error_handler(p_header_id => l_header_id
8685 , p_transaction_id => l_transaction_id
8686 , p_error_msg => l_error_msg
8687 , x_error_code => x_err_code
8688 , x_error_msg => x_err_msg);
8689 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg);
8690 IF (x_err_code <> 0) THEN
8691 raise e_proc_exception;
8692 END IF;
8693
8694 GOTO inner_loop;
8695 ELSE
8696 l_inserted_wmti := l_inserted_wmti + l_count;
8697 END IF;
8698 -- Code to handle sale order reservations.
8699 -- Modified for bug 5286219. Have code for transferring reservation from
8700 -- inv to LBJ during return txn before we call move processor code.
8701 IF (l_transaction_type in (2,3)) THEN
8702 declare
8703 l_rsv_exists BOOLEAN;
8704 l_net_quantity NUMBER;
8705 l_primary_item_id NUMBER;
8706 l_msg_count NUMBER;
8707 l_msg_data VARCHAR2(2000);
8708 begin
8709 l_rsv_exists:=FALSE;
8710 l_stmt_num := 230.1;
8711
8712 select net_quantity,primary_item_id
8713 into l_net_quantity,l_primary_item_id
8714 from wip_discrete_jobs
8715 where wip_entity_id=l_wip_entity_id
8716 and organization_id=l_organization_id;
8717
8718 if l_transaction_type = 2 then
8719 l_rsv_exists:= wsm_reservations_pvt.check_reservation_exists(
8720 p_wip_entity_id => l_wip_entity_id ,
8721 p_org_id => l_organization_id ,
8722 p_inventory_item_id => l_primary_item_id
8723 );
8724 end if;
8725
8726 if l_transaction_type = 3 then
8727 l_rsv_exists:=TRUE;
8728 end if;
8729
8730 If l_rsv_exists then
8731 --If l_transaction_type = 2 THEN --not normal move or undo
8732
8733 l_stmt_num := 251.2;
8734 wsm_reservations_pvt.modify_reservations_move (
8735 p_wip_entity_id => l_wip_entity_id,
8736 P_inventory_item_id => l_primary_item_id,
8737 P_org_id => l_organization_id,
8738 P_txn_type => l_transaction_type,--2,
8739 --Bug 5530944:Reserved qty should be compared
8740 --with completed qty.
8741 p_net_qty => l_primary_quantity,--l_net_quantity,
8742 x_return_status => l_return_status,
8743 x_msg_count => l_msg_count,
8744 x_msg_data => l_msg_data
8745 );
8746 IF(l_return_status <> 'S') THEN
8747 raise e_proc_exception;
8748 END IF;
8749 -- End if;--not normal move or undo
8750 End if ;
8751 END;
8752 END IF;--End of check on transaction type.
8753 WSMPLBMI.update_costed_qty_compl(
8754 p_transaction_type => l_transaction_type
8755 , p_job_fm_op_seq_num => l_fm_op_seq_num
8756 , p_job_to_op_seq_num => l_job_to_op_seq_num
8757 , p_wip_entity_id => l_wip_entity_id
8758 , p_fm_intraoperation_step_type => l_fm_intraoperation_step_type
8759 , p_to_intraoperation_step_type => l_to_intraoperation_step_type
8760 , p_primary_move_qty => l_primary_quantity
8761 , p_primary_scrap_qty => l_converted_scrap_qty
8762 , p_scrap_at_op => l_scrap_at_operation_flag
8763 );
8764
8765
8766 -- Start additions for Costing for WLTEnh
8767 --move enh? should we use primary qty?
8768 IF ( (l_to_intraoperation_step_type = 5) OR (l_fm_intraoperation_step_type = 5) /* if this is a scrap/unscrap transaction */
8769 OR (l_converted_scrap_qty>0)) THEN
8770 IF (l_fm_intraoperation_step_type = 5) THEN
8771 l_txn_qty := -1 * l_txn_qty;
8772 l_wro_op_seq_num := l_fm_op_seq_num;
8773 END IF;
8774 IF ((l_converted_scrap_qty>0) AND (l_transaction_type IN (3, 4)))THEN
8775 l_converted_scrap_qty := -1 * l_converted_scrap_qty;
8776 IF (l_scrap_at_operation_flag = 1) THEN
8777 l_wro_op_seq_num := l_to_op_seq_num;
8778 ELSE
8779 l_wro_op_seq_num := l_fm_op_seq_num;
8780 END IF;
8781 ELSIF ((l_converted_scrap_qty>0) AND (l_transaction_type IN (1, 2)))THEN
8782 IF (l_scrap_at_operation_flag = 1) THEN
8783 l_wro_op_seq_num := l_fm_op_seq_num;
8784 ELSE
8785 l_wro_op_seq_num := l_to_op_seq_num;
8786 END IF;
8787 END IF;
8788
8789
8790 l_stmt_num := 230;
8791 SELECT nvl(include_component_yield, 1)
8792 INTO l_wip_include_comp_yield
8793 FROM WIP_PARAMETERS
8794 WHERE organization_id = l_organization_id;
8795
8796 --LBM enh: Modified the expression for quantity_relieved
8797 UPDATE wip_requirement_operations wro
8798 SET QUANTITY_RELIEVED = NVL(wro.QUANTITY_RELIEVED, 0) +
8799 decode(l_converted_scrap_qty,
8800 0, decode(wro.basis_type, 2, 1, l_txn_qty),
8801 decode(wro.basis_type, 2, 1, l_converted_scrap_qty)) * decode(l_wip_include_comp_yield,
8802 2, wro.quantity_per_assembly,
8803 (wro.quantity_per_assembly / NVL(wro.component_yield_factor,1)))
8804 WHERE wro.wip_entity_id = l_wip_entity_id
8805 AND wro.organization_id = l_organization_id
8806 AND wro.operation_seq_num <= l_wro_op_seq_num
8807 -- since scrap can be done only at curr op
8808 AND wro.quantity_per_assembly <> 0
8809 AND wro.wip_supply_type <> 6
8810 AND wro.wip_supply_type <> 4
8811 AND wro.wip_supply_type <> 5
8812 AND NOT EXISTS
8813 (SELECT 1
8814 FROM wip_operations wo
8815 WHERE wo.organization_id = wro.organization_id
8816 AND wo.wip_entity_id = wro.wip_entity_id
8817 AND wo.operation_seq_num = wro.operation_seq_num
8818 AND wo.count_point_type = 3);
8819
8820 IF (g_mrp_debug='Y') THEN
8821 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') :
8822 Updated '||SQL%ROWCOUNT||' rows in WRO');
8823 END IF;
8824
8825 END IF;
8826 -- End additions for Costing for WLTEnh
8827 --MES
8828 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
8829 'jump oa page', 'undo oa page' )) THEN
8830 update_int_grp_id(x_error_code,
8831 x_error_msg,
8832 l_header_id,
8833 l_transaction_id);
8834 IF (x_err_code <> 0) THEN
8835 raise e_proc_exception;
8836 END IF;
8837 ELSE
8838 update_int_grp_id(x_error_code,
8839 x_error_msg,
8840 l_header_id,
8841 l_wmti_group_id);
8842 IF (x_err_code <> 0) THEN
8843 raise e_proc_exception;
8844 END IF;
8845 END IF;
8846
8847 l_stmt_num := 250;
8848 --move enh 115.135 changed WIP_CONSTANTS.MOVE_TXN to global variable after perf check
8849 IF ((l_transaction_type = g_move_txn) AND (l_fm_op_seq_num <> l_max_op_seq)
8850 and (g_aps_wps_profile='Y')) THEN
8851 IF (l_scrap_at_operation_flag = 2) THEN
8852 --bug 3385113 add nvl
8853 l_new_op_txn_qty := nvl(l_primary_quantity, 0) + nvl(l_converted_scrap_qty, 0);
8854 ELSE
8855 l_new_op_txn_qty := l_primary_quantity;
8856 END IF;
8857 l_stmt_num := 250.1;
8858 WSMPOPRN.call_infinite_scheduler(
8859 x_error_code => x_return_code,
8860 x_error_msg => l_error_msg,
8861 p_jump_flag => l_jump_flag,
8862 p_wip_entity_id => l_wip_entity_id,
8863 p_org_id => l_organization_id,
8864 p_to_op_seq_id => l_to_op_seq_id,
8865 p_fm_job_op_seq_num => l_fm_op_seq_num,
8866 p_to_job_op_seq_num => l_max_op_seq,
8867 p_scheQuantity => l_new_op_txn_qty);
8868 IF (x_return_code = 0) THEN
8869 IF (g_mrp_debug='Y') THEN
8870 FND_FILE.PUT_LINE(FND_FILE.LOG, 'WSMPOPRN.call_infinite_scheduler returned success');
8871 END IF;
8872 ELSE
8873 l_error_msg := x_error_msg;
8874 FND_FILE.PUT_LINE(FND_FILE.LOG,'WSMPLBMI.custom_validation' ||'(stmt_num='||l_stmt_num||') : '||substrb(l_error_msg, 1,4000));
8875 ROLLBACK TO validation;
8876 error_handler(p_header_id => l_header_id
8877 , p_transaction_id => l_transaction_id
8878 , p_error_msg => l_error_msg
8879 , x_error_code => x_err_code
8880 , x_error_msg => x_err_msg);
8881 IF (x_err_code <> 0) THEN
8882 raise e_proc_exception;
8883 END IF;
8884 GOTO inner_loop; /* go to get next entry */
8885 END IF;
8886 END IF;
8887
8888
8889 --MES
8890 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
8891 'jump oa page', 'undo oa page' )) THEN
8892 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8893 l_msg_tokens.delete;
8894 WSM_log_PVT.logMessage (
8895 p_module_name => l_module ,
8896 p_msg_text => 'Begin MES processing'||
8897 ';l_converted_scrap_qty '||
8898 l_converted_scrap_qty||
8899 ';l_primary_quantity '||
8900 l_primary_quantity||
8901 ';l_to_intraoperation_step_type '||
8902 l_to_intraoperation_step_type||
8903 ';l_fm_intraoperation_step_type '||
8904 l_fm_intraoperation_step_type,
8905 p_stmt_num => l_stmt_num ,
8906 p_msg_tokens => l_msg_tokens ,
8907 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8908 p_run_log_level => l_log_level
8909 );
8910 END IF;
8911
8912 --!! get l_mtl_txn_profile from inv profiles
8913 --MTL_TRANS_PROC 1 online, 2 immediate concurrent, 3 background, 4 form level
8914
8915 l_mtl_txn_profile := FND_PROFILE.value('TRANSACTION_PROCESS_MODE');
8916
8917 IF (l_mtl_txn_profile = WIP_CONSTANTS.FORM_LEVEL) THEN
8918 --l_mtl_txn_profile := FND_PROFILE.value('WIP_MOVE_TRANSACTION');
8919 l_mtl_txn_profile := FND_PROFILE.value('WIP_SHOP_FLOOR_MTL_TRANSACTION');
8920 END IF;
8921
8922 -- ST : Serial MES Fix : Start
8923 -- Have to store the attributes before invoking the Wip processor...
8924 -- Temporarily store the Serial Attributes of serial numbers from MSN and
8925 -- present in WMTI...(use the txn IDs) for completion and assembly return txns..
8926 DECLARE
8927 l_return_status VARCHAR2(1);
8928 l_error_msg VARCHAR2(2000);
8929 l_error_count NUMBER;
8930
8931 BEGIN
8932 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8933 l_msg_tokens.delete;
8934 WSM_log_PVT.logMessage ( p_module_name => l_module ,
8935 p_msg_text => 'B4 calling WSM_Serial_support_PVT.Insert_MOVE_attr',
8936 p_stmt_num => l_stmt_num ,
8937 p_msg_tokens => l_msg_tokens ,
8938 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8939 p_run_log_level => l_log_level
8940 );
8941 END IF;
8942
8943 l_stmt_num := 253.13;
8944 WSM_Serial_support_PVT.Insert_MOVE_attr ( p_group_id => null ,
8945 p_move_txn_id => l_transaction_id ,
8946 p_scrap_txn_id => l_scrap_txn_id ,
8947 x_return_status => l_return_status ,
8948 x_error_count => l_error_msg ,
8949 x_error_msg => l_error_count
8950 );
8951
8952 if l_return_status = FND_API.G_RET_STS_SUCCESS then
8953 IF (l_debug='Y') THEN
8954 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned Success');
8955 END IF;
8956
8957 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8958 l_msg_tokens.delete;
8959 WSM_log_PVT.logMessage (p_module_name => l_module ,
8960 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned successfully',
8961 p_stmt_num => l_stmt_num ,
8962 p_msg_tokens => l_msg_tokens ,
8963 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8964 p_run_log_level => l_log_level
8965 );
8966 END IF;
8967 ELSE
8968 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
8969 l_msg_tokens.delete;
8970 WSM_log_PVT.logMessage ( p_module_name => l_module ,
8971 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned error',
8972 p_stmt_num => l_stmt_num ,
8973 p_msg_tokens => l_msg_tokens ,
8974 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
8975 p_run_log_level => l_log_level
8976 );
8977 END IF;
8978 IF (l_error_count = 1) THEN
8979 fnd_file.put_line(fnd_file.log, l_error_msg);
8980 ELSIF (l_error_count > 1) THEN
8981 FOR i IN 1..l_error_count LOOP
8982 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
8983 p_encoded => FND_API.G_FALSE
8984 );
8985 fnd_file.put_line(fnd_file.log, l_error_msg);
8986 END LOOP;
8987 ELSE
8988 l_error_msg := 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure';
8989 END IF;
8990
8991 IF (l_debug='Y') THEN
8992 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure');
8993 END IF;
8994 -- This call is supposed to not return any error...
8995 raise e_proc_exception;
8996 END IF;
8997 END;
8998 -- ST : Serial MES Fix : end
8999 -- ST : Serial Support Project --
9000
9001 IF (l_scrap_qty > 0) THEN
9002 l_stmt_num := 251;
9003 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9004 l_msg_tokens.delete;
9005 WSM_log_PVT.logMessage (
9006 p_module_name => l_module ,
9007 p_msg_text => 'Calling wip move api for scrap qty',
9008 p_stmt_num => l_stmt_num ,
9009 p_msg_tokens => l_msg_tokens ,
9010 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9011 p_run_log_level => l_log_level
9012 );
9013 END IF;
9014
9015 --bug 5446252 since l_scrap_txn_id is not populated if l_primary_quantity = 0
9016 IF (l_primary_quantity > 0) THEN
9017 l_mes_scrap_txn_id := l_scrap_txn_id;
9018 ELSE
9019 l_mes_scrap_txn_id := l_transaction_id;
9020 END IF;
9021 --end bug 5446252
9022
9023 --bug 5446252 replace l_scrap_txn_id with l_mes_scrap_txn_id
9024 wip_movProc_grp.processInterface(
9025 p_movTxnID => l_mes_scrap_txn_id,
9026 p_procPhase => WIP_CONSTANTS.MOVE_PROC,
9027 p_txnHdrID => p_mtl_txn_hdr_id,
9028 p_mtlMode => l_mtl_txn_profile,
9029 p_cplTxnID => null,
9030 p_commit => null,
9031 x_returnStatus => l_return_status,
9032 x_errorMsg => l_error_msg);
9033
9034 IF(l_return_status <> 'S')THEN
9035 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
9036 ROLLBACK TO validation;
9037 error_handler(p_header_id => l_header_id
9038 , p_transaction_id => l_transaction_id
9039 , p_error_msg => l_error_msg
9040 , x_error_code => x_err_code
9041 , x_error_msg => x_error_msg);
9042 x_error_msg := l_error_msg;
9043 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9044 l_msg_tokens.delete;
9045 WSM_log_PVT.logMessage (
9046 p_module_name => l_module,
9047 p_msg_text => 'wip_movProc_grp.processInterface for scrap txn returned error: '||l_error_msg,
9048 p_stmt_num => l_stmt_num,
9049 p_msg_tokens => l_msg_tokens,
9050 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9051 p_run_log_level => l_log_level
9052 );
9053 END IF;
9054 raise e_proc_exception;
9055 ELSIF (l_return_status = 'S') THEN
9056 x_wip_move_api_sucess_msg := fnd_msg_pub.get;
9057 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9058 l_msg_tokens.delete;
9059 WSM_log_PVT.logMessage (
9060 p_module_name => l_module,
9061 p_msg_text => 'wip_movProc_grp.processInterface for scrap txn returned success: ',
9062 p_stmt_num => l_stmt_num,
9063 p_msg_tokens => l_msg_tokens,
9064 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9065 p_run_log_level => l_log_level
9066 );
9067 END IF;
9068 END IF;
9069 END IF;
9070
9071 IF (l_transaction_type = g_comp_txn) THEN
9072 SELECT mtl_material_transactions_s.nextval
9073 INTO l_cpl_txn_id
9074 FROM dual;
9075 END IF;
9076
9077 IF ((l_primary_quantity > 0) and (l_to_intraoperation_step_type <> WIP_CONSTANTS.SCRAP)
9078 and (l_fm_intraoperation_step_type <> WIP_CONSTANTS.SCRAP)) THEN
9079 l_stmt_num := 252;
9080 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9081 l_msg_tokens.delete;
9082 WSM_log_PVT.logMessage (
9083 p_module_name => l_module ,
9084 p_msg_text => 'Calling wip move api for move qty',
9085 p_stmt_num => l_stmt_num ,
9086 p_msg_tokens => l_msg_tokens ,
9087 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9088 p_run_log_level => l_log_level
9089 );
9090 END IF;
9091
9092 wip_movProc_grp.processInterface(
9093 p_movTxnID => l_transaction_id,
9094 p_procPhase => WIP_CONSTANTS.MOVE_PROC,
9095 p_txnHdrID => p_mtl_txn_hdr_id,
9096 p_mtlMode => l_mtl_txn_profile,
9097 p_cplTxnID => l_cpl_txn_id,
9098 p_commit => null,
9099 x_returnStatus => l_return_status,
9100 x_errorMsg => l_error_msg);
9101
9102 IF (l_return_status <> 'S') THEN
9103 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
9104 ROLLBACK TO validation;
9105 error_handler(p_header_id => l_header_id
9106 , p_transaction_id => l_transaction_id
9107 , p_error_msg => l_error_msg
9108 , x_error_code => x_err_code
9109 , x_error_msg => x_error_msg);
9110 x_error_msg := l_error_msg;
9111 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9112 l_msg_tokens.delete;
9113 WSM_log_PVT.logMessage (
9114 p_module_name => l_module,
9115 p_msg_text => 'wip_movProc_grp.processInterface for move txn returned error: '||l_error_msg,
9116 p_stmt_num => l_stmt_num,
9117 p_msg_tokens => l_msg_tokens,
9118 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9119 p_run_log_level => l_log_level
9120 );
9121 END IF;
9122 raise e_proc_exception;
9123 END IF;
9124 --l_mtl_txn_profile IN (WIP_CONSTANTS.BACKGROUND,
9125 -- WIP_CONSTANTS.IMMED_CONC)
9126
9127 x_wip_move_api_sucess_msg := fnd_msg_pub.get;
9128 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9129 IF (l_return_status = 'S') THEN
9130 l_msg_tokens.delete;
9131 WSM_log_PVT.logMessage (
9132 p_module_name => l_module,
9133 p_msg_text => 'wip_movProc_grp.processInterface for move txn returned success: '||x_wip_move_api_sucess_msg,
9134 p_stmt_num => l_stmt_num,
9135 p_msg_tokens => l_msg_tokens,
9136 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9137 p_run_log_level => l_log_level
9138 );
9139 END IF;
9140 END IF;
9141 END IF;
9142
9143 --bug 5210799 Update quantity_completed to null if jump from queue
9144 UPDATE (
9145 SELECT quantity_completed
9146 FROM WIP_OPERATIONS
9147 WHERE wip_entity_id = l_wip_entity_id
9148 AND operation_seq_num = l_fm_op_seq_num
9149 AND skip_flag = 1
9150 )
9151 SET quantity_completed = 0;
9152 --end bug 5210799
9153
9154 IF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9155 l_stmt_num := 253.1;
9156 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9157 l_msg_tokens.delete;
9158 WSM_log_PVT.logMessage (
9159 p_module_name => l_module ,
9160 p_msg_text => 'Begin inserting MES data',
9161 p_stmt_num => l_stmt_num ,
9162 p_msg_tokens => l_msg_tokens ,
9163 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9164 p_run_log_level => l_log_level
9165 );
9166 END IF;
9167 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9168 AND (p_sec_uom_code_tbls(l_header_id).count > 0)) THEN
9169
9170 l_stmt_num := 253.2;
9171 forall i in p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last
9172 update wsm_op_secondary_quantities
9173 set MOVE_OUT_QUANTITY = p_sec_move_out_qty_tbls(l_header_id)(i),
9174 LAST_UPDATE_DATE = sysdate,
9175 LAST_UPDATED_BY = g_user_id
9176 where wip_entity_id = l_wip_entity_id
9177 and operation_seq_num = l_fm_op_seq_num
9178 and uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9179
9180 l_stmt_num := 253.21;
9181 forall i in p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last
9182 update wsm_job_secondary_quantities
9183 set CURRENT_QUANTITY = p_sec_move_out_qty_tbls(l_header_id)(i),
9184 LAST_UPDATE_DATE = sysdate,
9185 LAST_UPDATED_BY = g_user_id
9186 where wip_entity_id = l_wip_entity_id
9187 and uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9188
9189 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9190 l_msg_tokens.delete;
9191 WSM_log_PVT.logMessage (
9192 p_module_name => l_module,
9193 p_msg_text => 'Updated secondary quantities successfully',
9194 p_stmt_num => l_stmt_num,
9195 p_msg_tokens => l_msg_tokens,
9196 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9197 p_run_log_level => l_log_level
9198 );
9199 END IF;
9200 END IF;
9201
9202 l_stmt_num := 253.3;
9203 IF ((p_scrap_codes_tbls IS NOT NULL) AND (p_scrap_codes_tbls.exists(l_header_id))
9204 AND (p_scrap_codes_tbls(l_header_id).count > 0)) THEN
9205
9206 l_stmt_num := 253.4;
9207 forall i in p_scrap_codes_tbls(l_header_id).first..p_scrap_codes_tbls(l_header_id).last
9208 update wsm_op_reason_codes
9209 set QUANTITY = p_scrap_code_qty_tbls(l_header_id)(i),
9210 LAST_UPDATE_DATE = sysdate,
9211 LAST_UPDATED_BY = g_user_id,
9212 LAST_UPDATED_LOGIN = g_login_id
9213 where wip_entity_id = l_wip_entity_id
9214 and operation_seq_num = l_fm_op_seq_num
9215 and CODE_TYPE = 1
9216 and REASON_CODE = p_scrap_codes_tbls(l_header_id)(i);
9217
9218 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9219 l_msg_tokens.delete;
9220 WSM_log_PVT.logMessage (
9221 p_module_name => l_module,
9222 p_msg_text => 'Updated scrap codes successfully',
9223 p_stmt_num => l_stmt_num,
9224 p_msg_tokens => l_msg_tokens,
9225 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9226 p_run_log_level => l_log_level
9227 );
9228 END IF;
9229 END IF;
9230
9231 l_stmt_num := 253.5;
9232 IF ((p_bonus_codes_tbls IS NOT NULL) AND (p_bonus_codes_tbls.exists(l_header_id))
9233 AND (p_bonus_codes_tbls(l_header_id).count > 0)) THEN
9234 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9235 FOR i in p_bonus_codes_tbls(l_header_id).first..p_bonus_codes_tbls(l_header_id).last
9236 LOOP
9237 l_msg_tokens.delete;
9238 WSM_log_PVT.logMessage (
9239 p_module_name => l_module,
9240 p_msg_text => 'i '||i||'; bonus code '||
9241 p_bonus_codes_tbls(l_header_id)(i)
9242 ||'; bonus code qty '
9243 ||p_bonus_code_qty_tbls(l_header_id)(i),
9244 p_stmt_num => l_stmt_num,
9245 p_msg_tokens => l_msg_tokens,
9246 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9247 p_run_log_level => l_log_level
9248 );
9249 END LOOP;
9250 END IF;
9251 l_stmt_num := 253.6;
9252 forall i in p_bonus_codes_tbls(l_header_id).first..p_bonus_codes_tbls(l_header_id).last
9253 update wsm_op_reason_codes
9254 set QUANTITY = p_bonus_code_qty_tbls(l_header_id)(i),
9255 LAST_UPDATE_DATE = sysdate,
9256 LAST_UPDATED_BY = g_user_id,
9257 LAST_UPDATED_LOGIN = g_login_id
9258 where wip_entity_id = l_wip_entity_id
9259 and operation_seq_num = l_fm_op_seq_num
9260 and CODE_TYPE = 2
9261 and REASON_CODE = p_bonus_codes_tbls(l_header_id)(i);
9262
9263 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9264 l_msg_tokens.delete;
9265 WSM_log_PVT.logMessage (
9266 p_module_name => l_module,
9267 p_msg_text => 'Updated bonus codes successfully',
9268 p_stmt_num => l_stmt_num,
9269 p_msg_tokens => l_msg_tokens,
9270 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9271 p_run_log_level => l_log_level
9272 );
9273 END IF;
9274 END IF;
9275 END IF;
9276
9277 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page')) THEN
9278 IF (nvl(p_source_code, 'interface') = 'move in oa page') THEN
9279 l_stmt_num := 253.6;
9280 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
9281 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
9282 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9283 FOR i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last
9284 LOOP
9285 l_msg_tokens.delete;
9286 WSM_log_PVT.logMessage (
9287 p_module_name => l_module,
9288 p_msg_text => 'i '||i||'; RESOURCE_ID '||
9289 p_jobop_resource_usages_tbls(l_header_id)(i).RESOURCE_ID
9290 ||'; INSTANCE_ID '
9291 ||p_jobop_resource_usages_tbls(l_header_id)(i).INSTANCE_ID
9292 ||'; SERIAL_NUMBER '
9293 ||p_jobop_resource_usages_tbls(l_header_id)(i).SERIAL_NUMBER,
9294 p_stmt_num => l_stmt_num,
9295 p_msg_tokens => l_msg_tokens,
9296 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9297 p_run_log_level => l_log_level
9298 );
9299 END LOOP;
9300 END IF;
9301 l_stmt_num := 253.7;
9302 DECLARE
9303 -- create an exception handler for ORA-24381
9304 errors NUMBER;
9305 dml_errors EXCEPTION;
9306 PRAGMA EXCEPTION_INIT(dml_errors, -24381);
9307 BEGIN
9308 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9309 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9310 -- If any errors occurred during the FORALL SAVE EXCEPTIONS,
9311 -- a single exception is raised when the statement completes.
9312
9313 EXCEPTION
9314 WHEN dml_errors THEN -- Now we figure out what failed and why.
9315 errors := SQL%BULK_EXCEPTIONS.COUNT;
9316 FOR i IN 1..errors LOOP
9317 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
9318 l_msg_tokens.delete;
9319 WSM_log_PVT.logMessage (
9320 p_module_name => l_module,
9321 p_msg_text => 'Number of statements that failed: ' || errors||'Error #' || i || ' occurred during '||
9322 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX,
9323 p_stmt_num => l_stmt_num,
9324 p_msg_tokens => l_msg_tokens,
9325 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9326 p_run_log_level => l_log_level
9327 );
9328
9329 WSM_log_PVT.logMessage (
9330 p_module_name => l_module,
9331 p_msg_text => 'Error message is ' ||
9332 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE),
9333 p_stmt_num => l_stmt_num,
9334 p_msg_tokens => l_msg_tokens,
9335 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9336 p_run_log_level => l_log_level
9337 );
9338 END IF;
9339
9340 END LOOP;
9341 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9342 END;
9343 /*
9344 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9345 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9346 */
9347 DECLARE
9348 cursor C_WOR is
9349 select resource_id
9350 from wip_operation_resources wor
9351 where wor.wip_entity_id = l_wip_entity_id
9352 and wor.operation_seq_num = l_fm_op_seq_num;
9353
9354 Type t_wor_resource_id is table of wip_operation_resources.resource_id%TYPE index by binary_integer;
9355 l_wor_resource_id t_wor_resource_id;
9356 BEGIN
9357 OPEN C_WOR;
9358 FETCH C_WOR BULK COLLECT INTO l_wor_resource_id;
9359 CLOSE C_WOR;
9360
9361 FORALL i in l_wor_resource_id.FIRST..l_wor_resource_id.LAST
9362 UPDATE WIP_OPERATION_RESOURCES
9363 SET actual_start_date =
9364 (SELECT min(start_date)
9365 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9366 WHERE wrat.wip_entity_id = l_wip_entity_id
9367 AND wrat.operation_seq_num = l_fm_op_seq_num
9368 AND wrat.resource_id = l_wor_resource_id(i)),
9369 projected_completion_date =
9370 (SELECT max(projected_completion_date)
9371 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9372 WHERE wrat.wip_entity_id = l_wip_entity_id
9373 AND wrat.operation_seq_num = l_fm_op_seq_num
9374 AND wrat.resource_id = l_wor_resource_id(i)),
9375 LAST_UPDATE_DATE = sysdate,
9376 LAST_UPDATED_BY = g_user_id
9377 WHERE wip_entity_id = l_wip_entity_id
9378 AND operation_seq_num = l_fm_op_seq_num
9379 AND resource_id = l_wor_resource_id(i);
9380
9381 END;
9382
9383 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9384 l_msg_tokens.delete;
9385 WSM_log_PVT.logMessage (
9386 p_module_name => l_module,
9387 p_msg_text => 'Updated resource usage successfully',
9388 p_stmt_num => l_stmt_num,
9389 p_msg_tokens => l_msg_tokens,
9390 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9391 p_run_log_level => l_log_level
9392 );
9393 END IF;
9394
9395 END IF;
9396
9397 l_stmt_num := 253.6121;
9398 UPDATE WIP_OPERATIONS
9399 SET actual_start_date = p_operation_start_date,
9400 projected_completion_date = p_expected_completion_date,
9401 employee_id = p_employee_id,
9402 wsm_bonus_quantity = p_bonus_quantity,
9403 LAST_UPDATE_DATE = sysdate,
9404 LAST_UPDATED_BY = g_user_id
9405 WHERE wip_entity_id = l_wip_entity_id
9406 AND operation_seq_num = l_fm_op_seq_num;
9407
9408 ELSIF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9409 l_stmt_num := 253.6;
9410 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
9411 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
9412 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9413 l_msg_tokens.delete;
9414 WSM_log_PVT.logMessage (
9415 p_module_name => l_module,
9416 p_msg_text => 'Begin inserting resource usage'
9417 ||'; l_wip_entity_id: '
9418 ||l_wip_entity_id
9419 ||'; l_fm_op_seq_num: '
9420 ||l_fm_op_seq_num,
9421 p_stmt_num => l_stmt_num,
9422 p_msg_tokens => l_msg_tokens,
9423 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9424 p_run_log_level => l_log_level
9425 );
9426 END IF;
9427
9428 l_stmt_num := 253.61;
9429 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9430 WHERE wip_entity_id = l_wip_entity_id
9431 AND operation_seq_num = l_fm_op_seq_num;
9432
9433 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9434 FOR i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last
9435 LOOP
9436 l_msg_tokens.delete;
9437 WSM_log_PVT.logMessage (
9438 p_module_name => l_module,
9439 p_msg_text => 'i '||i||'; RESOURCE_ID '||
9440 p_jobop_resource_usages_tbls(l_header_id)(i).RESOURCE_ID
9441 ||'; INSTANCE_ID '
9442 ||p_jobop_resource_usages_tbls(l_header_id)(i).INSTANCE_ID
9443 ||'; SERIAL_NUMBER '
9444 ||p_jobop_resource_usages_tbls(l_header_id)(i).SERIAL_NUMBER,
9445 p_stmt_num => l_stmt_num,
9446 p_msg_tokens => l_msg_tokens,
9447 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9448 p_run_log_level => l_log_level
9449 );
9450 END LOOP;
9451 END IF;
9452
9453 l_stmt_num := 253.7;
9454 DECLARE
9455 -- create an exception handler for ORA-24381
9456 errors NUMBER;
9457 dml_errors EXCEPTION;
9458 PRAGMA EXCEPTION_INIT(dml_errors, -24381);
9459 BEGIN
9460 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9461 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9462 -- If any errors occurred during the FORALL SAVE EXCEPTIONS,
9463 -- a single exception is raised when the statement completes.
9464
9465 EXCEPTION
9466 WHEN dml_errors THEN -- Now we figure out what failed and why.
9467 errors := SQL%BULK_EXCEPTIONS.COUNT;
9468 FOR i IN 1..errors LOOP
9469 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
9470 l_msg_tokens.delete;
9471 WSM_log_PVT.logMessage (
9472 p_module_name => l_module,
9473 p_msg_text => 'Number of statements that failed: ' || errors||'Error #' || i || ' occurred during '||
9474 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX,
9475 p_stmt_num => l_stmt_num,
9476 p_msg_tokens => l_msg_tokens,
9477 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9478 p_run_log_level => l_log_level
9479 );
9480
9481 WSM_log_PVT.logMessage (
9482 p_module_name => l_module,
9483 p_msg_text => 'Error message is ' ||
9484 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE),
9485 p_stmt_num => l_stmt_num,
9486 p_msg_tokens => l_msg_tokens,
9487 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9488 p_run_log_level => l_log_level
9489 );
9490 END IF;
9491
9492 END LOOP;
9493 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9494 END;
9495
9496 DECLARE
9497 cursor C_WOR is
9498 select resource_id
9499 from wip_operation_resources wor
9500 where wor.wip_entity_id = l_wip_entity_id
9501 and wor.operation_seq_num = l_fm_op_seq_num;
9502 BEGIN
9503 FOR rec in C_WOR LOOP
9504 UPDATE WIP_OPERATION_RESOURCES
9505 SET actual_start_date =
9506 (SELECT min(start_date)
9507 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9508 WHERE wrat.wip_entity_id = l_wip_entity_id
9509 AND wrat.operation_seq_num = l_fm_op_seq_num
9510 AND wrat.resource_id = rec.resource_id),
9511 actual_completion_date =
9512 (SELECT max(end_date)
9513 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9514 WHERE wrat.wip_entity_id = l_wip_entity_id
9515 AND wrat.operation_seq_num = l_fm_op_seq_num
9516 AND wrat.resource_id = rec.resource_id),
9517 LAST_UPDATE_DATE = sysdate,
9518 LAST_UPDATED_BY = g_user_id
9519 WHERE wip_entity_id = l_wip_entity_id
9520 AND operation_seq_num = l_fm_op_seq_num
9521 AND resource_id = rec.resource_id;
9522
9523 END LOOP;
9524 END;
9525
9526 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9527 l_msg_tokens.delete;
9528 WSM_log_PVT.logMessage (
9529 p_module_name => l_module,
9530 p_msg_text => 'Updated resource usage successfully',
9531 p_stmt_num => l_stmt_num,
9532 p_msg_tokens => l_msg_tokens,
9533 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9534 p_run_log_level => l_log_level
9535 );
9536 END IF;
9537
9538 END IF;--IF (p_jobop_resource_usages_tbls IS NOT NULL)
9539
9540 l_stmt_num := 253.611;
9541 UPDATE WIP_OPERATIONS
9542 SET actual_start_date = p_operation_start_date,
9543 actual_completion_date = p_operation_completion_date,
9544 employee_id = p_employee_id,
9545 wsm_bonus_quantity = p_bonus_quantity,
9546 LAST_UPDATE_DATE = sysdate,
9547 LAST_UPDATED_BY = g_user_id
9548 WHERE wip_entity_id = l_wip_entity_id
9549 AND operation_seq_num = l_fm_op_seq_num;
9550 --Bug 5480482:Variable l_wco_to_op_network_end is not needed.
9551 --Start of changes for bug 5480482
9552 --l_stmt_num := 253.612;
9553 --BEGIN
9554 --if last op update wdj.actual_completion_date
9555 --SELECT WCO.network_start_end
9556 --INTO l_wco_to_op_network_end
9557 --FROM WSM_COPY_OPERATIONS WCO, WIP_OPERATIONS WO
9558 -- WHERE WCO.wip_entity_id = WO.wip_entity_id
9559 -- AND WCO.operation_seq_num = WO.wsm_op_seq_num
9560 --AND WO.wip_entity_id = l_wip_entity_id
9561 -- AND WO.operation_seq_num = l_job_to_op_seq_num;
9562 -- EXCEPTION
9563 -- WHEN no_data_found THEN
9564 -- l_wco_to_op_network_end := null;
9565 -- END;
9566 --End of changes for bug 5480482
9567
9568 --bug 5057593
9569 IF (l_to_intraoperation_step_type = WIP_CONSTANTS.QUEUE) THEN
9570 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9571 AND (p_sec_uom_code_tbls(l_header_id).count > 0))
9572 THEN
9573 FORALL i in p_sec_uom_code_tbls(l_header_id).FIRST..p_sec_uom_code_tbls(l_header_id).LAST
9574 UPDATE WSM_OP_SECONDARY_QUANTITIES
9575 SET move_in_quantity = p_sec_move_out_qty_tbls(l_header_id)(i)
9576 WHERE wip_entity_id = l_wip_entity_id
9577 AND operation_seq_num = l_job_to_op_seq_num
9578 AND uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9579 END IF; --IF ((p_sec_uom_code_tbls IS NOT NULL)
9580 END IF; --(l_to_intraoperation_step_type = WIP_CONSTANTS.QUEUE)
9581 --bug 5057593 end
9582 END IF; --ELSIF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9583 --Bug 5480482:WDJ.actual_start_date should be update only if this is
9584 --the first move txn.
9585 --Start of changes for bug 5480482
9586 --l_stmt_num := 253.613;
9587 --BEGIN
9588 --if 1st op update wdj.actual_start_date
9589 --SELECT WCO.network_start_end
9590 --INTO l_wco_fm_op_network_start
9591 --FROM WSM_COPY_OPERATIONS WCO, WIP_OPERATIONS WO
9592 --WHERE WCO.wip_entity_id = WO.wip_entity_id
9593 --AND WCO.operation_seq_num = WO.wsm_op_seq_num
9594 --AND WO.wip_entity_id = l_wip_entity_id
9595 --AND WO.operation_seq_num = l_fm_op_seq_num;
9596 --EXCEPTION
9597 --WHEN no_data_found THEN
9598 --l_wco_fm_op_network_start := null;
9599 --END;
9600
9601 --IF (l_wco_fm_op_network_start = 'S') OR (l_wco_to_op_network_end = 'E') THEN
9602 --l_stmt_num := 253.614;
9603 --UPDATE WIP_DISCRETE_JOBS
9604 --SET actual_start_date = decode(l_wco_fm_op_network_start,
9605 -- 'S', p_operation_start_date,
9606 -- actual_start_date),
9607 --Bug 4485174: Following update is commented out
9608 /*
9609 actual_completion_date = decode(l_wco_to_op_network_end,
9610 'E', p_operation_completion_date,
9611 actual_completion_date),
9612 */
9613 -- LAST_UPDATE_DATE = sysdate,
9614 -- LAST_UPDATED_BY = g_user_id
9615 --WHERE wip_entity_id = l_wip_entity_id;
9616 --END IF;
9617 UPDATE WIP_DISCRETE_JOBS wdj
9618 SET actual_start_date = p_operation_start_date,
9619 LAST_UPDATE_DATE = sysdate,
9620 LAST_UPDATED_BY = g_user_id
9621 WHERE wip_entity_id = l_wip_entity_id
9622 and not exists (select 1 from wip_move_transactions wmt
9623 where wmt.wip_entity_id = wdj.wip_entity_id
9624 and wmt.organization_id = wdj.organization_id
9625 and wmt.transaction_id <> l_transaction_id
9626 and wmt.wsm_undo_txn_id is NULL);
9627 --End of changes for bug 5480482
9628 ELSIF (nvl(p_source_code, 'interface') ='undo oa page') THEN
9629
9630 --Undo of Move Out from 10R to 10TM, 10Q to 10TM, 10R to 20Q, 10Q to 20Q
9631 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9632 IF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9633 AND ((l_to_intraoperation_step_type = 1) OR (l_to_intraoperation_step_type = 2)))
9634 AND (l_undone_txn_source_code = 'move out oa page')
9635 THEN --Move Out
9636 update wsm_op_secondary_quantities
9637 set MOVE_OUT_QUANTITY = NULL,
9638 LAST_UPDATE_DATE = sysdate,
9639 LAST_UPDATED_BY = g_user_id
9640 where wip_entity_id = l_wip_entity_id
9641 and operation_seq_num = l_job_to_op_seq_num;
9642
9643 UPDATE WSM_JOB_SECONDARY_QUANTITIES WJSQ
9644 SET WJSQ.CURRENT_QUANTITY =
9645 (SELECT MOVE_IN_QUANTITY
9646 FROM WSM_OP_SECONDARY_QUANTITIES WOSC
9647 WHERE WJSQ.UOM_CODE = WOSC.UOM_CODE
9648 AND WJSQ.wip_entity_id = WOSC.wip_entity_id
9649 AND WOSC.wip_entity_id = l_wip_entity_id
9650 AND WOSC.operation_seq_num = l_job_to_op_seq_num),
9651 LAST_UPDATE_DATE = sysdate,
9652 LAST_UPDATED_BY = g_user_id
9653 WHERE WJSQ.wip_entity_id = l_wip_entity_id;
9654
9655 update wsm_op_reason_codes
9656 set QUANTITY = NULL,
9657 LAST_UPDATE_DATE = sysdate,
9658 LAST_UPDATED_BY = g_user_id,
9659 LAST_UPDATED_LOGIN = g_login_id
9660 where wip_entity_id = l_wip_entity_id
9661 and operation_seq_num = l_job_to_op_seq_num;
9662
9663 l_stmt_num := 253.612;
9664 --Bug 5480482:WDJ.actual_start_date should be update only if this is
9665 --undo of first move txn
9666 --Start of changes for 5480482
9667 --SELECT min(operation_seq_num)
9668 --INTO l_wo_min_op_seq_num
9669 -- FROM WIP_OPERATIONS WO
9670 -- WHERE WO.wip_entity_id = l_wip_entity_id;
9671
9672 --IF (l_job_to_op_seq_num = l_wo_min_op_seq_num) AND (l_to_intraoperation_step_type = 1) THEN
9673 --l_stmt_num := 253.614;
9674 -- UPDATE WIP_DISCRETE_JOBS wdj
9675 -- SET actual_start_date = null,
9676 -- LAST_UPDATE_DATE = sysdate,
9677 -- LAST_UPDATED_BY = g_user_id
9678 -- WHERE wip_entity_id = l_wip_entity_id
9679 -- and not exists (select 1 from wip_move_transactions wmt
9680 -- where wmt.wip_entity_id = wdj.wip_entity_id
9681 -- and wmt.organization_id = wdj.organization_id
9682 -- and wmt.wsm_undo_txn_id is NULL);
9683 --END IF;
9684 --End of changes for 5480482
9685 --Undo of Move Out from 10Q to 10TM, 10Q to 20Q
9686 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9687 IF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9688 AND (l_to_intraoperation_step_type = 1)) THEN
9689 --no Move In b4 Move Out
9690 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9691 where wip_entity_id = l_wip_entity_id
9692 and operation_seq_num = l_job_to_op_seq_num;
9693
9694 UPDATE WIP_OPERATIONS
9695 SET actual_start_date = null,
9696 actual_completion_date = null,
9697 employee_id = null,
9698 LAST_UPDATE_DATE = sysdate,
9699 LAST_UPDATED_BY = g_user_id
9700 WHERE wip_entity_id = l_wip_entity_id
9701 AND operation_seq_num = l_job_to_op_seq_num;
9702
9703 --bug 5158378
9704 UPDATE WIP_OPERATION_RESOURCES
9705 SET actual_start_date = null,
9706 actual_completion_date = null
9707 WHERE wip_entity_id = l_wip_entity_id
9708 AND operation_seq_num = l_job_to_op_seq_num;
9709 --end bug 5158378
9710
9711 --bug 5158378 - OSFMST1: UNDO MOVE TRANSACTION NOT CLEARING THE ACTUAL COMPLETION DATE
9712 --Added the following ELSIF branch
9713 --Undo of Move Out from 10R to 10TM, 10R to 20Q
9714 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9715 ELSIF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9716 AND (l_to_intraoperation_step_type = 2)) THEN
9717 --Move In b4 Move Out
9718
9719 UPDATE WIP_OPERATIONS
9720 SET actual_completion_date = null
9721 WHERE wip_entity_id = l_wip_entity_id
9722 AND operation_seq_num = l_job_to_op_seq_num;
9723
9724 UPDATE WIP_RESOURCE_ACTUAL_TIMES
9725 SET end_date = NULL
9726 where wip_entity_id = l_wip_entity_id
9727 and operation_seq_num = l_job_to_op_seq_num;
9728
9729 UPDATE WIP_OPERATION_RESOURCES
9730 SET actual_completion_date = null
9731 WHERE wip_entity_id = l_wip_entity_id
9732 AND operation_seq_num = l_job_to_op_seq_num;
9733
9734 /*
9735 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9736 where wip_entity_id = l_wip_entity_id
9737 and operation_seq_num = l_job_to_op_seq_num
9738 and projected_completion_date IS NULL;
9739 */
9740 END IF;
9741 ELSIF ((l_fm_intraoperation_step_type = 2) AND (l_to_intraoperation_step_type = 1))
9742 AND (l_undone_txn_source_code = 'move in oa page')
9743 THEN --Move In
9744
9745 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9746 where wip_entity_id = l_wip_entity_id
9747 and operation_seq_num = l_job_to_op_seq_num;
9748
9749 UPDATE WIP_OPERATIONS
9750 SET actual_start_date = null,
9751 projected_completion_date = null,
9752 employee_id = null,
9753 LAST_UPDATE_DATE = sysdate,
9754 LAST_UPDATED_BY = g_user_id
9755 WHERE wip_entity_id = l_wip_entity_id
9756 AND operation_seq_num = l_fm_op_seq_num;
9757
9758 --bug 5158378
9759 UPDATE WIP_OPERATION_RESOURCES
9760 SET actual_start_date = null
9761 WHERE wip_entity_id = l_wip_entity_id
9762 AND operation_seq_num = l_job_to_op_seq_num;
9763 --end bug 5158378
9764 END IF;
9765
9766 END IF; --(nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page'))
9767
9768 l_stmt_num := 253.7;
9769 UPDATE WSM_LOT_MOVE_TXN_INTERFACE
9770 SET status = 4,
9771 LAST_UPDATE_DATE = sysdate,
9772 LAST_UPDATED_BY = g_user_id
9773 WHERE header_id = l_header_id;
9774
9775 l_stmt_num := 253.8;
9776 IF nvl(p_bonus_quantity, 0) > 0 THEN
9777 l_stmt_num := 253.9;
9778
9779 l_wltx_transactions_rec.TRANSACTION_TYPE_ID := WSMPCNST.UPDATE_QUANTITY;
9780 l_wltx_transactions_rec.TRANSACTION_DATE := l_transaction_date;
9781 l_wltx_transactions_rec.TRANSACTION_REFERENCE := l_transaction_reference;
9782 l_wltx_transactions_rec.REASON_ID := l_reason_id;
9783 l_wltx_transactions_rec.EMPLOYEE_ID := p_employee_id;
9784 l_wltx_transactions_rec.ORGANIZATION_ID := l_organization_id;
9785
9786 select wsm_split_merge_transactions_s.nextval
9787 into l_wltx_transactions_rec.TRANSACTION_ID
9788 from dual;
9789
9790 l_wltx_starting_job_tbl(0).WIP_ENTITY_ID := l_wip_entity_id;
9791 l_wltx_starting_job_tbl(0).OPERATION_SEQ_NUM := l_job_to_op_seq_num;
9792
9793 l_wltx_resulting_job_tbl(0).WIP_ENTITY_ID := l_wip_entity_id;
9794 l_wltx_resulting_job_tbl(0).START_QUANTITY := l_primary_quantity + p_bonus_quantity;
9795 l_wltx_resulting_job_tbl(0).BONUS_ACCT_ID := p_bonus_account_id;
9796 l_wltx_resulting_job_tbl(0).STARTING_OPERATION_SEQ_NUM := l_fm_op_seq_num;
9797 l_wltx_resulting_job_tbl(0).SPLIT_HAS_UPDATE_ASSY := 0;
9798
9799 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9800 l_msg_tokens.delete;
9801 WSM_log_PVT.logMessage (
9802 p_module_name => l_module,
9803 p_msg_text => 'Populated l_wltx_transactions_rec'
9804 ||'; TRANSACTION_TYPE_ID '
9805 ||l_wltx_transactions_rec.TRANSACTION_TYPE_ID
9806 ||'; TRANSACTION_DATE '
9807 ||l_wltx_transactions_rec.TRANSACTION_DATE
9808 ||'; TRANSACTION_REFERENCE '
9809 ||l_wltx_transactions_rec.TRANSACTION_REFERENCE
9810 ||'; REASON_ID '
9811 ||l_wltx_transactions_rec.REASON_ID
9812 ||'; EMPLOYEE_ID '
9813 ||l_wltx_transactions_rec.EMPLOYEE_ID
9814 ||'; ORGANIZATION_ID '
9815 ||l_wltx_transactions_rec.ORGANIZATION_ID
9816 ||'; TRANSACTION_ID '
9817 ||l_wltx_transactions_rec.TRANSACTION_ID
9818 ||'; Populated l_wltx_starting_job_tbl'
9819 ||'; WIP_ENTITY_ID '
9820 ||l_wltx_starting_job_tbl(0).WIP_ENTITY_ID
9821 ||'; OPERATION_SEQ_NUM '
9822 ||l_wltx_starting_job_tbl(0).OPERATION_SEQ_NUM
9823 ||'; Populated l_wltx_resulting_job_tbl'
9824 ||l_wltx_resulting_job_tbl(0).WIP_ENTITY_ID
9825 ||'; START_QUANTITY '
9826 ||l_wltx_resulting_job_tbl(0).START_QUANTITY
9827 ||'; BONUS_ACCT_ID '
9828 ||l_wltx_resulting_job_tbl(0).BONUS_ACCT_ID,
9829 p_stmt_num => l_stmt_num,
9830 p_msg_tokens => l_msg_tokens,
9831 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9832 p_run_log_level => l_log_level
9833 );
9834 END IF;
9835 l_stmt_num := 253.10;
9836 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9837 AND (p_sec_uom_code_tbls(l_header_id).count > 0))
9838 THEN
9839 FOR i IN p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last LOOP
9840 l_wltx_secondary_qty_tbl(i).wip_entity_name := l_wip_entity_name;
9841 l_wltx_secondary_qty_tbl(i).wip_entity_id := l_wip_entity_id;
9842 l_wltx_secondary_qty_tbl(i).uom_code := p_sec_uom_code_tbls(l_header_id)(i);
9843 l_wltx_secondary_qty_tbl(i).current_quantity := p_sec_move_out_qty_tbls(l_header_id)(i);
9844 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9845 l_msg_tokens.delete;
9846 WSM_log_PVT.logMessage (
9847 p_module_name => l_module,
9848 p_msg_text => 'Populating l_wltx_secondary_qty_tbl',
9849 p_stmt_num => l_stmt_num,
9850 p_msg_tokens => l_msg_tokens,
9851 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9852 p_run_log_level => l_log_level
9853 );
9854 END IF;
9855 END LOOP;
9856 END IF; --IF ((p_sec_uom_code_tbls IS NOT NULL)
9857
9858 l_stmt_num := 253.11;
9859 IF ((p_jobop_bonus_serials_tbls IS NOT NULL) AND (p_jobop_bonus_serials_tbls.exists(l_header_id))
9860 AND (p_jobop_bonus_serials_tbls(l_header_id).count > 0))
9861 THEN
9862 FOR i in p_jobop_bonus_serials_tbls(l_header_id).first..p_jobop_bonus_serials_tbls(l_header_id).last LOOP
9863 l_WSM_SERIAL_NUM_TBL(i) := p_jobop_bonus_serials_tbls(l_header_id)(i);
9864 l_WSM_SERIAL_NUM_TBL(i).action_flag := 1;
9865 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9866 l_msg_tokens.delete;
9867 WSM_log_PVT.logMessage (
9868 p_module_name => l_module,
9869 p_msg_text => 'Populating l_WSM_SERIAL_NUM_TBL '||
9870 ';i '||
9871 i||
9872 ';serial_number '||
9873 p_jobop_bonus_serials_tbls(l_header_id)(i).serial_number||
9874 ';action_flag '||
9875 l_WSM_SERIAL_NUM_TBL(i).action_flag,
9876 p_stmt_num => l_stmt_num,
9877 p_msg_tokens => l_msg_tokens,
9878 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9879 p_run_log_level => l_log_level
9880 );
9881 END IF;
9882 END LOOP;
9883 END IF; --IF ((p_jobop_bonus_serials_tbls IS NOT NULL)
9884
9885 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9886 DECLARE
9887 l_start_qty NUMBER;
9888 BEGIN
9889 SELECT start_quantity
9890 INTO l_start_qty
9891 FROM WIP_DISCRETE_JOBS
9892 WHERE wip_entity_id = l_wip_entity_id;
9893
9894 l_msg_tokens.delete;
9895 WSM_log_PVT.logMessage (
9896 p_module_name => l_module,
9897 p_msg_text => 'B4 Calling WSM_WIP_LOT_TXN_PVT.invoke_txn_API '||
9898 ';wdj l_start_qty '||
9899 l_start_qty,
9900 p_stmt_num => l_stmt_num,
9901 p_msg_tokens => l_msg_tokens,
9902 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9903 p_run_log_level => l_log_level
9904 );
9905 EXCEPTION
9906 WHEN others THEN
9907 null;
9908 END;
9909 END IF;
9910
9911 l_stmt_num := 253.12;
9912 WSM_WIP_LOT_TXN_PVT.invoke_txn_API (
9913 p_api_version => 1.0,
9914 p_commit => FND_API.G_FALSE,
9915 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
9916 p_init_msg_list => FND_API.G_FALSE,
9917 p_calling_mode => 1,
9918 p_txn_header_rec => l_wltx_transactions_rec,
9919 p_starting_jobs_tbl => l_wltx_starting_job_tbl,
9920 p_resulting_jobs_tbl => l_wltx_resulting_job_tbl,
9921 p_wsm_serial_num_tbl => l_WSM_SERIAL_NUM_TBL,
9922 p_secondary_qty_tbl => l_wltx_secondary_qty_tbl,
9923 x_return_status => x_return_status,
9924 x_msg_count => x_msg_count,
9925 x_error_msg => x_error_msg
9926 );
9927
9928 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9929 IF (x_return_status = g_ret_success) THEN
9930 l_msg_tokens.delete;
9931 WSM_log_PVT.logMessage (
9932 p_module_name => l_module,
9933 p_msg_text => 'WSM_WIP_LOT_TXN_PVT.invoke_txn_API returned '||
9934 ';x_return_status '||
9935 x_return_status||
9936 ';x_msg_count '||
9937 x_msg_count||
9938 '; x_error_msg '||
9939 x_error_msg,
9940 p_stmt_num => l_stmt_num,
9941 p_msg_tokens => l_msg_tokens,
9942 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9943 p_run_log_level => l_log_level
9944 );
9945 END IF;
9946 END IF;
9947
9948 IF (x_return_status = g_ret_error) THEN
9949 RAISE FND_API.G_EXC_ERROR;
9950 ELSIF (x_return_status = g_ret_unexpected) THEN
9951 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9952 END IF;
9953
9954 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9955 IF (x_return_status = g_ret_success) THEN
9956 l_msg_tokens.delete;
9957 WSM_log_PVT.logMessage (
9958 p_module_name => l_module,
9959 p_msg_text => 'WSM_WIP_LOT_TXN_PVT.invoke_txn_API returned successfully',
9960 p_stmt_num => l_stmt_num,
9961 p_msg_tokens => l_msg_tokens,
9962 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9963 p_run_log_level => l_log_level
9964 );
9965 END IF;
9966 END IF;
9967 l_stmt_num := 253.61;
9968 UPDATE WIP_OPERATIONS
9969 SET WSM_UPDATE_QUANTITY_TXN_ID = l_wltx_transactions_rec.TRANSACTION_ID,
9970 LAST_UPDATE_DATE = sysdate,
9971 LAST_UPDATED_BY = g_user_id
9972 WHERE wip_entity_id = l_wip_entity_id
9973 AND operation_seq_num = l_fm_op_seq_num;
9974
9975 END IF; --IF nvl(p_bonus_quantity, 0) > 0
9976
9977 IF (l_put_job_on_hold = 1) THEN
9978 UPDATE WIP_DISCRETE_JOBS
9979 SET STATUS_TYPE = WIP_CONSTANTS.HOLD,
9980 LAST_UPDATE_DATE = sysdate,
9981 LAST_UPDATED_BY = g_user_id
9982 WHERE wip_entity_id = l_wip_entity_id;
9983 END IF;
9984 END IF; --IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page',
9985 --MES END
9986 --Bug 5368120:For MES txns,update attr move should be called inside the inner loop.
9987 -- as outside this loop, l_transaction_id and l_scrap_txn_id do not point
9988 -- to current transaction.
9989 DECLARE
9990 l_return_status VARCHAR2(1);
9991 l_error_msg VARCHAR2(2000);
9992 l_error_count NUMBER;
9993 l_move_txn_id NUMBER := null;
9994 l_scrap_id NUMBER := null;
9995 BEGIN
9996 IF nvl(p_source_code, 'interface') = 'undo oa page'
9997 THEN
9998 l_move_txn_id := l_transaction_id;
9999 l_scrap_id := l_scrap_txn_id ;
10000
10001
10002 WSM_Serial_support_PVT.Update_attr_move( p_group_id => NULL ,
10003 p_internal_group_id => NULL ,
10004 p_move_txn_id => l_move_txn_id ,
10005 p_scrap_txn_id => l_scrap_id ,
10006 p_organization_id => null ,
10007 x_return_status => l_return_status ,
10008 x_error_count => l_error_count ,
10009 x_error_msg => l_error_msg
10010 );
10011
10012 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10013 IF (l_debug='Y') THEN
10014 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned Success');
10015 END IF;
10016 ELSE
10017 IF (l_error_count = 1) THEN
10018 fnd_file.put_line(fnd_file.log, l_error_msg);
10019 ELSIF (l_error_count > 1) THEN
10020 FOR i IN 1..l_error_count LOOP
10021 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10022 p_encoded => FND_API.G_FALSE
10023 );
10024 fnd_file.put_line(fnd_file.log, l_error_msg);
10025 END LOOP;
10026 ELSE
10027 l_error_msg := 'WSM_Serial_support_PVT.Update_attr_move returned failure';
10028 END IF;
10029
10030 IF (l_debug='Y') THEN
10031 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned failure');
10032 END IF;
10033 -- This call is supposed to not return any error...
10034 raise e_proc_exception;
10035
10036 END IF;
10037 END IF; --End of check in source code.
10038 END;
10039 --Bug 5368120:End of changes.
10040
10041 END LOOP; /* end inner loop */
10042
10043 CLOSE C_TXNS;
10044
10045 IF (l_inserted_wmti=0) THEN
10046 IF (g_mrp_debug='Y') THEN
10047 fnd_file.put_line(fnd_file.log, 'No txns inserted in WMTI');
10048 END IF;
10049 EXIT;
10050 ELSE
10051 IF (g_mrp_debug='Y') THEN
10052 fnd_file.put_line(fnd_file.log, 'Inserted '||l_inserted_wmti||' row(s) in WMTI');
10053 END IF;
10054 END IF;
10055
10056 -- MES
10057 -- ST : Serial MES Fix :
10058 -- Moved this IF clause to encompass the Serial code as well...
10059 IF nvl(p_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10060 'jump oa page', 'undo oa page' )
10061 THEN
10062 -- ST : Serial Support Project --
10063 -- Temporarily store the Serial Attributes of serial numbers from MSN and
10064 -- present in WMTI...(use p_group_id)
10065 DECLARE
10066 l_return_status VARCHAR2(1);
10067 l_error_msg VARCHAR2(2000);
10068 l_error_count NUMBER;
10069
10070 BEGIN
10071 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10072 l_msg_tokens.delete;
10073 WSM_log_PVT.logMessage ( p_module_name => l_module ,
10074 p_msg_text => 'B4 calling WSM_Serial_support_PVT.Insert_MOVE_attr',
10075 p_stmt_num => l_stmt_num ,
10076 p_msg_tokens => l_msg_tokens ,
10077 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10078 p_run_log_level => l_log_level
10079 );
10080 END IF;
10081
10082 l_stmt_num := 253.13;
10083 WSM_Serial_support_PVT.Insert_MOVE_attr ( p_group_id => l_wmti_group_id ,
10084 x_return_status => l_return_status ,
10085 x_error_count => l_error_msg ,
10086 x_error_msg => l_error_count
10087 );
10088
10089 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10090 IF (l_debug='Y') THEN
10091 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned Success');
10092 END IF;
10093
10094 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10095 l_msg_tokens.delete;
10096 WSM_log_PVT.logMessage (p_module_name => l_module ,
10097 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned successfully',
10098 p_stmt_num => l_stmt_num ,
10099 p_msg_tokens => l_msg_tokens ,
10100 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10101 p_run_log_level => l_log_level
10102 );
10103 END IF;
10104 ELSE
10105 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
10106 l_msg_tokens.delete;
10107 WSM_log_PVT.logMessage ( p_module_name => l_module ,
10108 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned error',
10109 p_stmt_num => l_stmt_num ,
10110 p_msg_tokens => l_msg_tokens ,
10111 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
10112 p_run_log_level => l_log_level
10113 );
10114 END IF;
10115 IF (l_error_count = 1) THEN
10116 fnd_file.put_line(fnd_file.log, l_error_msg);
10117 ELSIF (l_error_count > 1) THEN
10118 FOR i IN 1..l_error_count LOOP
10119 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10120 p_encoded => FND_API.G_FALSE
10121 );
10122 fnd_file.put_line(fnd_file.log, l_error_msg);
10123 END LOOP;
10124 ELSE
10125 l_error_msg := 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure';
10126 END IF;
10127
10128 IF (l_debug='Y') THEN
10129 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure');
10130 END IF;
10131 -- This call is supposed to not return any error...
10132 raise e_proc_exception;
10133 END IF;
10134 END;
10135 -- ST : Serial Support Project --
10136
10137 -- ST : Serial MES Fix : Commented out the below clause and moved it forward..
10138 -- MES
10139 -- IF nvl(p_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10140 -- 'jump oa page', 'undo oa page' ) THEN
10141
10142 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10143 l_msg_tokens.delete;
10144 WSM_log_PVT.logMessage( p_module_name => l_module ,
10145 p_msg_text => 'B4 calling Wip_movProc_grp.processInterface',
10146 p_stmt_num => l_stmt_num ,
10147 p_msg_tokens => l_msg_tokens ,
10148 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10149 p_run_log_level => l_log_level
10150 );
10151 END IF;
10152 /*******
10153 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10154 DECLARE
10155 CURSOR C_WRO IS
10156 SELECT WRO.wip_entity_id,
10157 WRO.operation_seq_num,
10158 WRO.segment1,
10159 WRO.INVENTORY_ITEM_ID,
10160 WRO.REQUIRED_QUANTITY,
10161 WRO.QUANTITY_ISSUED,
10162 WRO.QUANTITY_PER_ASSEMBLY,
10163 WRO.QUANTITY_RELIEVED,
10164 WRO.COMPONENT_YIELD_FACTOR,
10165 WRO.basis_type
10166 FROM wsm_lot_move_txn_interface WLMTI,
10167 WIP_REQUIREMENT_OPERATIONS WRO
10168 WHERE WLMTI.group_id = p_group_id
10169 AND WLMTI.wip_entity_id = 1439883
10170 AND WLMTI.wip_entity_id = WRO.wip_entity_id
10171 AND WRO.operation_seq_num IN (10, 20)
10172 ORDER BY WRO.wip_entity_id,
10173 WRO.operation_seq_num,
10174 WRO.segment1;
10175 BEGIN
10176 FOR rec in C_WRO LOOP
10177 l_msg_tokens.delete;
10178 WSM_log_PVT.logMessage(
10179 p_module_name => l_module ,
10180 p_msg_text => 'B4 calling Wip_movProc_grp.processInterface '||
10181 '; wip_entity_id '||rec.wip_entity_id||
10182 '; operation_seq_num '||rec.operation_seq_num||
10183 '; segment1 '||rec.segment1||
10184 '; INVENTORY_ITEM_ID '||rec.INVENTORY_ITEM_ID||
10185 '; REQUIRED_QUANTITY '||rec.REQUIRED_QUANTITY||
10186 '; QUANTITY_ISSUED '||rec.QUANTITY_ISSUED||
10187 '; QUANTITY_PER_ASSEMBLY '||rec.QUANTITY_PER_ASSEMBLY||
10188 '; QUANTITY_RELIEVED '||rec.QUANTITY_RELIEVED||
10189 '; COMPONENT_YIELD_FACTOR '||rec.COMPONENT_YIELD_FACTOR||
10190 '; basis_type '||rec.basis_type
10191 ,
10192 p_stmt_num => l_stmt_num ,
10193 p_msg_tokens => l_msg_tokens ,
10194 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10195 p_run_log_level => l_log_level
10196 );
10197 END LOOP;
10198 END;
10199 END IF;
10200 *********/
10201
10202
10203
10204 l_stmt_num := 240;
10205 Wip_movProc_grp.processInterface(p_groupID => l_wmti_group_id,
10206 p_commit => null, --fnd_api.g_true,
10207 x_returnStatus => x_returnStatus);
10208 /***
10209 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10210 DECLARE
10211 CURSOR C_WRO IS
10212 SELECT WRO.wip_entity_id,
10213 WRO.operation_seq_num,
10214 WRO.segment1,
10215 WRO.INVENTORY_ITEM_ID,
10216 WRO.REQUIRED_QUANTITY,
10217 WRO.QUANTITY_ISSUED,
10218 WRO.QUANTITY_PER_ASSEMBLY,
10219 WRO.QUANTITY_RELIEVED,
10220 WRO.COMPONENT_YIELD_FACTOR,
10221 WRO.basis_type
10222 FROM wsm_lot_move_txn_interface WLMTI,
10223 WIP_REQUIREMENT_OPERATIONS WRO
10224 WHERE WLMTI.group_id = p_group_id
10225 AND WLMTI.wip_entity_id = WRO.wip_entity_id
10226 AND WRO.operation_seq_num IN (WLMTI.FM_OPERATION_SEQ_NUM, WLMTI.TO_OPERATION_SEQ_NUM)
10227 ORDER BY WRO.wip_entity_id,
10228 WRO.operation_seq_num,
10229 WRO.segment1;
10230 BEGIN
10231 FOR rec in C_WRO LOOP
10232 l_msg_tokens.delete;
10233 WSM_log_PVT.logMessage(
10234 p_module_name => l_module ,
10235 p_msg_text => 'After calling Wip_movProc_grp.processInterface '||
10236 '; wip_entity_id '||rec.wip_entity_id||
10237 '; operation_seq_num '||rec.operation_seq_num||
10238 '; segment1 '||rec.segment1||
10239 '; INVENTORY_ITEM_ID '||rec.INVENTORY_ITEM_ID||
10240 '; REQUIRED_QUANTITY '||rec.REQUIRED_QUANTITY||
10241 '; QUANTITY_ISSUED '||rec.QUANTITY_ISSUED||
10242 '; QUANTITY_PER_ASSEMBLY '||rec.QUANTITY_PER_ASSEMBLY||
10243 '; QUANTITY_RELIEVED '||rec.QUANTITY_RELIEVED||
10244 '; COMPONENT_YIELD_FACTOR '||rec.COMPONENT_YIELD_FACTOR||
10245 '; basis_type '||rec.basis_type
10246 ,
10247 p_stmt_num => l_stmt_num ,
10248 p_msg_tokens => l_msg_tokens ,
10249 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10250 p_run_log_level => l_log_level
10251 );
10252 END LOOP;
10253 END;
10254 END IF;
10255 **/
10256 IF (x_returnStatus=fnd_api.g_ret_sts_unexp_error) THEN
10257 --move enh? this logic is based on the fact that after going through osfm validations wip api
10258 --should not throw any errors and if errors are encountered we will rollback and exit the worker
10259 --Checks for such errors should be added to osfm validations.
10260 DECLARE
10261 cursor c_wtie is
10262 SELECT WLMTI.header_id
10263 , wtie.transaction_id
10264 , wtie.error_message
10265 FROM WIP_TXN_INTERFACE_ERRORS wtie,
10266 WSM_LOT_MOVE_TXN_INTERFACE WLMTI,
10267 WIP_MOVE_TXN_INTERFACE WMTI
10268 WHERE WTIE.transaction_id = WMTI.transaction_id
10269 --FP bug 5178168 (base bug 5168406) changed the line below
10270 --AND WMTI.batch_id = WLMTI.transaction_id
10271 AND nvl(WMTI.batch_id, wmti.transaction_id) = WLMTI.transaction_id
10272 AND WMTI.group_id = l_wmti_group_id
10273 AND WLMTI.group_id = p_group_id;
10274 BEGIN
10275 FOR rec in c_wtie LOOP
10276 copy_WTIE_to_WIE(x_error_code,
10277 x_error_msg,
10278 rec.header_id,
10279 rec.transaction_id,
10280 rec.error_message);
10281 END LOOP;
10282 END;
10283 l_success := 0;
10284 fnd_file.put_line(fnd_file.log, 'Returned unsuccessfully from Wip_movProc_grp.processInterface');
10285 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
10286 l_msg_tokens.delete;
10287 WSM_log_PVT.logMessage (
10288 p_module_name => l_module ,
10289 p_msg_text => 'Wip_movProc_grp.processInterface returned unexpected failure',
10290 p_stmt_num => l_stmt_num ,
10291 p_msg_tokens => l_msg_tokens ,
10292 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
10293 p_run_log_level => l_log_level
10294 );
10295 END IF;
10296 raise e_proc_exception;
10297 ELSIF (x_returnStatus=fnd_api.g_ret_sts_success) THEN
10298 l_wmti_err_txns := 0;
10299
10300 SELECT count(*)
10301 INTO l_wmti_err_txns
10302 FROM WIP_MOVE_TXN_INTERFACE
10303 WHERE GROUP_ID=l_wmti_group_id
10304 AND PROCESS_STATUS = 3;
10305
10306 IF (g_mrp_debug='Y') THEN
10307 fnd_file.put_line(fnd_file.log, 'Returned successfully from Wip_movProc_grp.processInterface');
10308 END IF;
10309 IF (l_wmti_err_txns > 0) THEN
10310 l_success := 0;
10311 ELSE
10312 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10313 l_msg_tokens.delete;
10314 WSM_log_PVT.logMessage (
10315 p_module_name => l_module ,
10316 p_msg_text => 'Wip_movProc_grp.processInterface returned successfully',
10317 p_stmt_num => l_stmt_num ,
10318 p_msg_tokens => l_msg_tokens ,
10319 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10320 p_run_log_level => l_log_level
10321 );
10322 END IF;
10323 l_success := 1;
10324 update_txn_status(x_error_code,
10325 x_error_msg,
10326 p_group_id,
10327 l_wmti_group_id);
10328 END IF;
10329 IF (l_success=0) THEN
10330 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
10331 l_msg_tokens.delete;
10332 WSM_log_PVT.logMessage (
10333 p_module_name => l_module ,
10334 p_msg_text => 'Wip_movProc_grp.processInterface returned failure',
10335 p_stmt_num => l_stmt_num ,
10336 p_msg_tokens => l_msg_tokens ,
10337 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
10338 p_run_log_level => l_log_level
10339 );
10340 END IF;
10341 fnd_file.put_line(fnd_file.log, 'Returned unsuccessfully from Wip_movProc_grp.processInterface');
10342 raise e_proc_exception;
10343 END IF;
10344
10345 END IF;
10346
10347 --bug 5210799 Update quantity_completed to null if jump from queue
10348 UPDATE WIP_OPERATIONS
10349 SET quantity_completed = 0
10350 WHERE rowid IN
10351 (
10352 SELECT WO.rowid
10353 FROM WIP_OPERATIONS WO,
10354 WSM_LOT_MOVE_TXN_INTERFACE WLMTI
10355 WHERE WLMTI.group_id = p_group_id
10356 AND WLMTI.internal_group_id = l_wmti_group_id
10357 AND WLMTI.status = 4
10358 AND WO.wip_entity_id = WLMTI.wip_entity_id
10359 AND WO.operation_seq_num = WLMTI.fm_operation_seq_num
10360 AND WO.skip_flag = 1
10361 );
10362 --end bug 5210799
10363
10364 END IF; --p_source_code NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10365
10366 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10367 l_msg_tokens.delete;
10368 WSM_log_PVT.logMessage (
10369 p_module_name => l_module,
10370 p_msg_text => 'B4 UPDATE WIP_OPERATION_YIELDS woy '
10371 ||';p_group_id '
10372 ||p_group_id
10373 ||';l_wmti_group_id '
10374 ||l_wmti_group_id ,
10375 p_stmt_num => l_stmt_num,
10376 p_msg_tokens => l_msg_tokens,
10377 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10378 p_run_log_level => l_log_level
10379 );
10380 END IF;
10381
10382 l_stmt_num := 270;
10383
10384 /* Bug Fix 5969857. Use UNION ALL for wmt.transaction_id instead of wmt.transaction_id in
10385 (wlmti.transaction_id, wlmti.internal_scrap_txn_id)*/
10386
10387 UPDATE WIP_OPERATION_YIELDS woy
10388 SET status = 1,
10389 last_update_date = sysdate,
10390 last_update_login = g_login_id,
10391 request_id = g_request_id,
10392 program_application_id= g_program_application_id,
10393 program_id = g_program_id,
10394 program_update_date = DECODE(g_request_id,NULL,NULL,SYSDATE)
10395 WHERE woy.rowid IN ((
10396 SELECT woy2.rowid
10397 FROM WIP_OPERATIONS wop2,
10398 WIP_OPERATION_YIELDS woy2,
10399 WSM_PARAMETERS wp, -- ESA
10400 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10401 WIP_MOVE_TRANSACTIONS wmt,
10402 WSM_LOT_MOVE_TXN_INTERFACE wlmti
10403 --bug 3615826
10404 -- WHERE wmt.group_id = l_wmti_group_id
10405 WHERE wlmti.group_id = p_group_id
10406 --mes commented out the following and added subsequent lines
10407 -- AND wlmti.internal_group_id = l_wmti_group_id;
10408 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10409 'move in oa page', wlmti.transaction_id,
10410 'move out oa page', wlmti.transaction_id,
10411 'move to next op oa page', wlmti.transaction_id,
10412 'jump oa page', wlmti.transaction_id,
10413 'undo oa page', wlmti.transaction_id,
10414 l_wmti_group_id)
10415 )
10416 OR
10417 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10418 'move in oa page', wlmti.internal_scrap_txn_id,
10419 'move out oa page', wlmti.internal_scrap_txn_id,
10420 'move to next op oa page', wlmti.internal_scrap_txn_id,
10421 'jump oa page', wlmti.internal_scrap_txn_id,
10422 'undo oa page', wlmti.internal_scrap_txn_id,
10423 l_wmti_group_id)
10424 )
10425 )
10426 AND (wmt.transaction_id =wlmti.transaction_id)
10427 --move enh not needed since we are looking at WMT
10428 -- AND wmt.process_phase = g_move_proc
10429 -- AND wmt.process_status = g_running
10430 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) /*bugfix 2856703*/
10431 AND wp.organization_id = wmt.organization_id -- ESA
10432 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10433 AND wdj.wip_entity_id = wmt.wip_entity_id -- NSLBJ
10434 AND wdj.job_type <>3 -- NSLBJ
10435 AND wop2.organization_id = wmt.organization_id
10436 AND wop2.wip_entity_id = wmt.wip_entity_id
10437 AND woy2.organization_id = wmt.organization_id
10438 AND woy2.wip_entity_id = wmt.wip_entity_id
10439 AND woy2.operation_seq_num= wop2.operation_seq_num
10440 AND ( /* Forward Move */
10441 ( wop2.operation_seq_num >= wmt.fm_operation_seq_num
10442 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10443 AND
10444 wop2.operation_seq_num < wmt.to_operation_seq_num
10445 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10446 AND
10447 ( wmt.to_operation_seq_num > wmt.fm_operation_seq_num
10448 OR
10449 (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
10450 AND wmt.fm_intraoperation_step_type<=g_run
10451 AND wmt.to_intraoperation_step_type>g_run)
10452 )
10453 AND
10454 ( wop2.count_point_type < g_no_manual
10455 OR wop2.operation_seq_num = wmt.fm_operation_seq_num
10456 OR (wop2.operation_seq_num = wmt.to_operation_seq_num
10457 AND wmt.to_intraoperation_step_type > g_run)
10458 )
10459 )
10460 OR /* Backward Move */
10461 ( wop2.operation_seq_num < wmt.fm_operation_seq_num
10462 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10463 AND
10464 wop2.operation_seq_num >= wmt.to_operation_seq_num
10465 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10466 AND
10467 ( wmt.fm_operation_seq_num > wmt.to_operation_seq_num
10468 OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
10469 AND wmt.to_intraoperation_step_type<=g_run
10470 AND wmt.fm_intraoperation_step_type>g_run)
10471 )
10472 AND
10473 ( wop2.count_point_type < g_no_manual
10474 OR(wop2.operation_seq_num = wmt.to_operation_seq_num
10475 AND wop2.count_point_type < g_no_manual)
10476 OR(wop2.operation_seq_num = wmt.fm_operation_seq_num
10477 AND wmt.fm_intraoperation_step_type > g_run)
10478 )
10479 )
10480 )
10481 )
10482 UNION ALL
10483 (
10484 SELECT woy2.rowid
10485 FROM WIP_OPERATIONS wop2,
10486 WIP_OPERATION_YIELDS woy2,
10487 WSM_PARAMETERS wp, -- ESA
10488 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10489 WIP_MOVE_TRANSACTIONS wmt,
10490 WSM_LOT_MOVE_TXN_INTERFACE wlmti
10491 --bug 3615826
10492 -- WHERE wmt.group_id = l_wmti_group_id
10493 WHERE wlmti.group_id = p_group_id
10494 --mes commented out the following and added subsequent lines
10495 -- AND wlmti.internal_group_id = l_wmti_group_id;
10496 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10497 'move in oa page', wlmti.transaction_id,
10498 'move out oa page', wlmti.transaction_id,
10499 'move to next op oa page', wlmti.transaction_id,
10500 'jump oa page', wlmti.transaction_id,
10501 'undo oa page', wlmti.transaction_id,
10502 l_wmti_group_id)
10503 )
10504 OR
10505 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10506 'move in oa page', wlmti.internal_scrap_txn_id,
10507 'move out oa page', wlmti.internal_scrap_txn_id,
10508 'move to next op oa page', wlmti.internal_scrap_txn_id,
10509 'jump oa page', wlmti.internal_scrap_txn_id,
10510 'undo oa page', wlmti.internal_scrap_txn_id,
10511 l_wmti_group_id)
10512 )
10513 )
10514 AND (wmt.transaction_id = wlmti.internal_scrap_txn_id)
10515 --move enh not needed since we are looking at WMT
10516 -- AND wmt.process_phase = g_move_proc
10517 -- AND wmt.process_status = g_running
10518 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) /*bugfix 2856703*/
10519 AND wp.organization_id = wmt.organization_id -- ESA
10520 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10521 AND wdj.wip_entity_id = wmt.wip_entity_id -- NSLBJ
10522 AND wdj.job_type <>3 -- NSLBJ
10523 AND wop2.organization_id = wmt.organization_id
10524 AND wop2.wip_entity_id = wmt.wip_entity_id
10525 AND woy2.organization_id = wmt.organization_id
10526 AND woy2.wip_entity_id = wmt.wip_entity_id
10527 AND woy2.operation_seq_num= wop2.operation_seq_num
10528 AND ( /* Forward Move */
10529 ( wop2.operation_seq_num >= wmt.fm_operation_seq_num
10530 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10531 AND
10532 wop2.operation_seq_num < wmt.to_operation_seq_num
10533 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10534 AND
10535 ( wmt.to_operation_seq_num > wmt.fm_operation_seq_num
10536 OR
10537 (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
10538 AND wmt.fm_intraoperation_step_type<=g_run
10539 AND wmt.to_intraoperation_step_type>g_run)
10540 )
10541 AND
10542 ( wop2.count_point_type < g_no_manual
10543 OR wop2.operation_seq_num = wmt.fm_operation_seq_num
10544 OR (wop2.operation_seq_num = wmt.to_operation_seq_num
10545 AND wmt.to_intraoperation_step_type > g_run)
10546 )
10547 )
10548 OR /* Backward Move */
10549 ( wop2.operation_seq_num < wmt.fm_operation_seq_num
10550 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10551 AND
10552 wop2.operation_seq_num >= wmt.to_operation_seq_num
10553 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10554 AND
10555 ( wmt.fm_operation_seq_num > wmt.to_operation_seq_num
10556 OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
10557 AND wmt.to_intraoperation_step_type<=g_run
10558 AND wmt.fm_intraoperation_step_type>g_run)
10559 )
10560 AND
10561 ( wop2.count_point_type < g_no_manual
10562 OR(wop2.operation_seq_num = wmt.to_operation_seq_num
10563 AND wop2.count_point_type < g_no_manual)
10564 OR(wop2.operation_seq_num = wmt.fm_operation_seq_num
10565 AND wmt.fm_intraoperation_step_type > g_run)
10566 )
10567 )
10568 )
10569 ));
10570
10571 IF (g_mrp_debug='Y') THEN
10572 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') :
10573 Updated '||SQL%ROWCOUNT||' rows in WOY');
10574 END IF;
10575 /**********************************
10576 UPDATE WIP_OPERATION_YIELDS woy
10577 SET status = 1,
10578 last_update_date = sysdate,
10579 last_update_login = g_login_id,
10580 request_id = g_request_id,
10581 program_application_id= g_program_application_id,
10582 program_id = g_program_id,
10583 program_update_date = DECODE(g_request_id,NULL,NULL,SYSDATE)
10584 WHERE woy.rowid IN (
10585 SELECT woy2.rowid
10586 FROM WIP_OPERATIONS wop2,
10587 WIP_OPERATION_YIELDS woy2,
10588 WSM_PARAMETERS wp, -- ESA
10589 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10590 WIP_MOVE_TXN_INTERFACE wti
10591 WHERE wti.group_id = l_wmti_group_id
10592 AND wti.process_phase = g_move_proc
10593 AND wti.process_status = g_running
10594 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) --bugfix 2856703
10595 AND wp.organization_id = wti.organization_id -- ESA
10596 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10597 AND wdj.wip_entity_id = wti.wip_entity_id -- NSLBJ
10598 AND wdj.job_type <>3 -- NSLBJ
10599 AND wop2.organization_id = wti.organization_id
10600 AND wop2.wip_entity_id = wti.wip_entity_id
10601 AND woy2.organization_id = wti.organization_id
10602 AND woy2.wip_entity_id = wti.wip_entity_id
10603 AND woy2.operation_seq_num= wop2.operation_seq_num
10604 AND ( -- Forward Move
10605 ( wop2.operation_seq_num >= wti.fm_operation_seq_num
10606 + DECODE(sign(wti.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10607 AND
10608 wop2.operation_seq_num < wti.to_operation_seq_num
10609 + DECODE(sign(wti.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10610 AND
10611 ( wti.to_operation_seq_num > wti.fm_operation_seq_num
10612 OR
10613 (wti.to_operation_seq_num = wti.fm_operation_seq_num
10614 AND wti.fm_intraoperation_step_type<=g_run
10615 AND wti.to_intraoperation_step_type>g_run)
10616 )
10617 AND
10618 ( wop2.count_point_type < g_no_manual
10619 OR wop2.operation_seq_num = wti.fm_operation_seq_num
10620 OR (wop2.operation_seq_num = wti.to_operation_seq_num
10621 AND wti.to_intraoperation_step_type > g_run)
10622 )
10623 )
10624 OR --Backward Move
10625 ( wop2.operation_seq_num < wti.fm_operation_seq_num
10626 + DECODE(sign(wti.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10627 AND
10628 wop2.operation_seq_num >= wti.to_operation_seq_num
10629 + DECODE(sign(wti.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10630 AND
10631 ( wti.fm_operation_seq_num > wti.to_operation_seq_num
10632 OR (wti.fm_operation_seq_num = wti.to_operation_seq_num
10633 AND wti.to_intraoperation_step_type<=g_run
10634 AND wti.fm_intraoperation_step_type>g_run)
10635 )
10636 AND
10637 ( wop2.count_point_type < g_no_manual
10638 OR(wop2.operation_seq_num = wti.to_operation_seq_num
10639 AND wop2.count_point_type < g_no_manual)
10640 OR(wop2.operation_seq_num = wti.fm_operation_seq_num
10641 AND wti.fm_intraoperation_step_type > g_run)
10642 )
10643 )
10644 )
10645 );
10646 *****************************/
10647
10648
10649 /* BA: CZH.JUMPENH, new UNDO logic */
10650 l_stmt_num := 280;
10651 if (l_undo_exists=1) THEN /* For undo transaction, set the wsm_undo_txn_id */
10652
10653 DECLARE
10654 CURSOR undo_txns IS
10655 SELECT wlmti.transaction_id,
10656 wlmti.organization_id,
10657 wlmti.wip_entity_id,
10658 wlmti.fm_operation_seq_num,
10659 wlmti.to_operation_seq_num,
10660 wlmti.to_intraoperation_step_type,
10661 wlmti.fm_intraoperation_step_type,
10662 wlmti.scrap_quantity,
10663 wlmti.source_code --Added for bug 5480482
10664 FROM wsm_lot_move_txn_interface wlmti
10665 WHERE wlmti.group_id = p_group_id
10666 AND wlmti.status = 4
10667 AND wlmti.transaction_type = 4
10668 --move enh 115.135 changed the AND clause for performance
10669 --mes commented out the following and added subsequent lines
10670 -- AND wlmti.internal_group_id = l_wmti_group_id;
10671 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10672 'move in oa page', wlmti.transaction_id,
10673 'move out oa page', wlmti.transaction_id,
10674 'move to next op oa page', wlmti.transaction_id,
10675 'jump oa page', wlmti.transaction_id,
10676 'undo oa page', wlmti.transaction_id,
10677 l_wmti_group_id)
10678 )
10679 /*********
10680 OR
10681 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10682 'move in oa page', wlmti.internal_scrap_txn_id,
10683 'move out oa page', wlmti.internal_scrap_txn_id,
10684 'move to next op oa page', wlmti.internal_scrap_txn_id,
10685 'jump oa page', wlmti.internal_scrap_txn_id,
10686 'undo oa page', wlmti.internal_scrap_txn_id,
10687 l_wmti_group_id)
10688 )
10689 *********/
10690 );
10691 -- AND wlmti.transaction_id IN (SELECT wmt.batch_id
10692 -- FROM wip_move_transactions wmt
10693 -- WHERE wmt.group_id = l_wmti_group_id);
10694
10695 l_dup_flag NUMBER :=0;
10696 undo_jump_from_queue BOOLEAN := FALSE;
10697 BEGIN
10698 --move enh
10699 FOR rec IN undo_txns LOOP
10700 IF (rec.fm_operation_seq_num <> rec.to_operation_seq_num
10701 AND rec.to_intraoperation_step_type=1
10702 AND l_charge_jump_from_queue=2) THEN
10703 undo_jump_from_queue:=TRUE;
10704 END IF;
10705
10706 x_return_code := WSMPLBMI.set_undo_txn_id(
10707 rec.organization_id,
10708 rec.wip_entity_id,
10709 --mes replacing l_undo_txn_id with rec.transaction_id
10710 --l_undo_txn_id,
10711 rec.transaction_id,
10712 rec.to_operation_seq_num,
10713 undo_jump_from_queue,
10714 x_err_msg);
10715 -- ST : Serial Support Project --
10716 -- Add code here to clear the WDJ if serialization is ended...
10717 UPDATE wip_discrete_jobs wdj
10718 SET wdj.serialization_start_op = null
10719 where wdj.wip_entity_id = rec.wip_entity_id
10720 and wdj.wip_entity_id IN (select wlbj.wip_entity_id
10721 from wsm_lot_based_jobs wlbj
10722 where wlbj.wip_entity_id = rec.wip_entity_id
10723 and first_serial_txn_id IS NULL);
10724 -- ST : Serial Support Project --
10725 --Bug 5480482:Start of changes
10726 if nvl(rec.source_code,'interface') = 'undo oa page' then
10727 UPDATE WIP_DISCRETE_JOBS wdj
10728 SET actual_start_date = null,
10729 LAST_UPDATE_DATE = sysdate,
10730 LAST_UPDATED_BY = g_user_id
10731 WHERE wip_entity_id = rec.wip_entity_id
10732 and not exists (select 1 from wip_move_transactions wmt
10733 where wmt.wip_entity_id = wdj.wip_entity_id
10734 and wmt.organization_id = wdj.organization_id
10735 and wmt.wsm_undo_txn_id is NULL);
10736 end if;--End of check on source_code.
10737 --Bug 5480482EndStart of changes
10738 END LOOP;
10739 END;
10740
10741 IF (g_mrp_debug='Y') THEN
10742 fnd_file.put_line(fnd_file.log, 'set_undo_txn_id undo_txn_id= '||l_undo_txn_id);
10743 END IF;
10744
10745 IF (x_return_code <> 0) THEN
10746 fnd_file.put_line(fnd_file.log, 'wip_move_transactions: set wsm_undo_txn_id failed');
10747 END IF;
10748
10749 END IF; /* End of if (undo_exists) */
10750 /* EA: CZH.JUMPENH */
10751
10752 l_stmt_num := 290;
10753 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10754 l_msg_tokens.delete;
10755 WSM_log_PVT.logMessage (
10756 p_module_name => l_module,
10757 p_msg_text => 'b4 IF (l_ac_ar_exists=1) '||
10758 ' l_ac_ar_exists '||l_ac_ar_exists,
10759 p_stmt_num => l_stmt_num,
10760 p_msg_tokens => l_msg_tokens,
10761 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10762 p_run_log_level => l_log_level
10763 );
10764 END IF;
10765
10766 IF (l_ac_ar_exists=1) THEN /* Assy completion/return exists */
10767 DECLARE
10768 CURSOR ac_ar_txns IS
10769 SELECT wlmti.new_wip_entity_name,
10770 wlmti.organization_id, -- CZH.BUG2282570
10771 wlmti.wip_entity_id,
10772 wlmti.header_id,
10773 wlmti.transaction_type, -- CZH.BUG2282570
10774 wlmti.transaction_id,
10775 wlmti.to_operation_seq_num,
10776 wlmti.fm_intraoperation_step_type,
10777 wlmti.scrap_quantity,
10778 wlmti.transaction_quantity,
10779 wlmti.source_code
10780 FROM wsm_lot_move_txn_interface wlmti
10781 WHERE wlmti.group_id = p_group_id
10782 AND wlmti.status = 4
10783 /* Added condition to fix bug #1815584 */
10784 AND wlmti.transaction_type in (2,3)
10785 /* Assy Completion/return */
10786 AND wlmti.new_wip_entity_name is NOT NULL
10787 --move enh 115.135 changed the AND clause for performance
10788 --mes commented out the following and added subsequent lines
10789 -- AND wlmti.internal_group_id = l_wmti_group_id;
10790 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10791 'move in oa page', wlmti.transaction_id,
10792 'move out oa page', wlmti.transaction_id,
10793 'move to next op oa page', wlmti.transaction_id,
10794 'jump oa page', wlmti.transaction_id,
10795 'undo oa page', wlmti.transaction_id,
10796 l_wmti_group_id)
10797 )
10798 OR
10799 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10800 'move in oa page', wlmti.internal_scrap_txn_id,
10801 'move out oa page', wlmti.internal_scrap_txn_id,
10802 'move to next op oa page', wlmti.internal_scrap_txn_id,
10803 'jump oa page', wlmti.internal_scrap_txn_id,
10804 'undo oa page', wlmti.internal_scrap_txn_id,
10805 l_wmti_group_id)
10806 )
10807 );
10808 -- AND wlmti.transaction_id IN (SELECT wmt.batch_id
10809 -- FROM wip_move_transactions wmt
10810 -- WHERE wmt.group_id = l_wmti_group_id);
10811 BEGIN
10812 FOR rec IN ac_ar_txns LOOP
10813
10814 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10815 l_msg_tokens.delete;
10816 WSM_log_PVT.logMessage (
10817 p_module_name => l_module,
10818 p_msg_text => 'b4 UPDATE wip_entities '||
10819 ' rec.new_wip_entity_name '||rec.new_wip_entity_name||
10820 ' rec.wip_entity_id '||rec.wip_entity_id,
10821 p_stmt_num => l_stmt_num,
10822 p_msg_tokens => l_msg_tokens,
10823 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10824 p_run_log_level => l_log_level
10825 );
10826 END IF;
10827
10828 l_dup_flag:=0;
10829
10830 UPDATE wip_entities
10831 SET wip_entity_name = rec.new_wip_entity_name
10832 WHERE wip_entity_id = rec.wip_entity_id;
10833
10834
10835
10836 IF (SQL%ROWCOUNT=0) THEN
10837 fnd_file.put_line(fnd_file.log, 'wip_entities : Update failed '||l_new_jobname);
10838 ELSE
10839 IF (g_mrp_debug='Y') THEN
10840 fnd_file.put_line(fnd_file.log, 'updated wip_entity_id= '||l_wip_entity_id||' with the new_job_name '||l_new_jobname);
10841 END IF;
10842 END IF;
10843
10844 l_stmt_num := 290;
10845 /* BA: CZH.BUG2282570 */
10846 /* for UNDO, set WMT.wsm_undo_txn_id */
10847 IF (rec.transaction_type = 3) THEN
10848 x_return_code := WSMPLBMI.set_undo_txn_id(rec.organization_id,
10849 rec.wip_entity_id,
10850 rec.transaction_id,
10851 x_err_msg);
10852
10853 -- ST : Serial Support Project --
10854 -- Add code here to clear the WDJ if serialization is ended...
10855 UPDATE wip_discrete_jobs wdj
10856 SET wdj.serialization_start_op = null
10857 where wdj.wip_entity_id = rec.wip_entity_id
10858 and wdj.wip_entity_id IN (select wlbj.wip_entity_id
10859 from wsm_lot_based_jobs wlbj
10860 where wlbj.wip_entity_id = rec.wip_entity_id
10861 and first_serial_txn_id IS NULL);
10862 -- ST : Serial Support Project --
10863 --Bug 5480482:Start of changes
10864 if nvl(rec.source_code,'interface') = 'undo oa page' then
10865 UPDATE WIP_DISCRETE_JOBS wdj
10866 SET actual_start_date = null,
10867 LAST_UPDATE_DATE = sysdate,
10868 LAST_UPDATED_BY = g_user_id
10869 WHERE wip_entity_id = rec.wip_entity_id
10870 and not exists (select 1 from wip_move_transactions wmt
10871 where wmt.wip_entity_id = wdj.wip_entity_id
10872 and wmt.organization_id = wdj.organization_id
10873 and wmt.wsm_undo_txn_id is NULL);
10874 end if;--End of check on source_code.
10875 --Bug 5480482EndStart of changes
10876
10877
10878 END IF;
10879
10880 IF (g_mrp_debug='Y') THEN
10881 fnd_file.put_line(fnd_file.log, 'set_undo_txn_id undo_txn_id= '||l_batch_id);
10882 END IF;
10883
10884 IF (x_return_code <> 0) THEN
10885 fnd_file.put_line(fnd_file.log, 'wip_move_transactions: set wsm_undo_txn_id failed');
10886 END IF;
10887 -- Commented for bug 5286219. Code for trf reservation during return txn will be present
10888 -- before we call move processor.
10889 /*
10890 IF (rec.transaction_type = 3)THEN --not normal move or undo
10891 declare
10892 l_rsv_exists BOOLEAN;
10893 l_net_quantity NUMBER;
10894 l_primary_item_id NUMBER;
10895 l_msg_count NUMBER;
10896 l_msg_data VARCHAR2(2000);
10897 begin
10898 select net_quantity,primary_item_id
10899 into l_net_quantity,l_primary_item_id
10900 from wip_discrete_jobs
10901 where wip_entity_id=rec.wip_entity_id
10902 and organization_id=rec.organization_id;
10903 l_stmt_num := 290.1;
10904 wsm_reservations_pvt.modify_reservations_move(
10905 p_wip_entity_id => rec.wip_entity_id,
10906 P_inventory_item_id => l_primary_item_id,
10907 P_org_id => rec.organization_id,
10908 P_txn_type => 3,
10909 p_net_qty => l_net_quantity,
10910 x_return_status => l_return_status,
10911 x_msg_count => l_msg_count,
10912 x_msg_data => l_msg_data
10913 );
10914 IF(l_return_status <> 'S') THEN
10915 raise e_proc_exception;
10916 END IF;
10917
10918 END;
10919 End if;
10920 */
10921
10922 -- END IF;
10923 /* EA: CZH.BUG2282570 */
10924
10925 END LOOP;/* End of While */
10926 END;
10927
10928 END IF; /* End if of Assy completion/return exists */
10929
10930 -- ST : Serial Project --
10931 -- Time to update the serial attributes back to the original value after being cleared by the WIP processor...
10932 if nvl(p_source_code, 'interface') = 'interface' then --Added for Bug 5368120
10933 DECLARE
10934 l_return_status VARCHAR2(1);
10935 l_error_msg VARCHAR2(2000);
10936 l_error_count NUMBER;
10937 l_move_txn_id NUMBER := null;
10938 l_group_id NUMBER := null;
10939 l_scrap_id NUMBER := null;
10940 l_internal_group_id NUMBER := null;
10941 BEGIN
10942 --Bug 5368120: For MES,call to update_attr_move is handled inside inner loop.
10943 -- Hence the following code is commented out.
10944 -- ST : Serial MES Fix : Added this code since p_group_id and l_wmti_group_id arent used for MES
10945 --IF nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10946 -- 'jump oa page', 'undo oa page' )
10947 --THEN
10948 -- l_move_txn_id := l_transaction_id;
10949 -- l_scrap_id := l_scrap_txn_id ;
10950 --ELSE
10951 -- normal interface code..
10952 l_group_id := p_group_id;
10953 l_internal_group_id := l_wmti_group_id;
10954 --END IF;
10955 -- ST : Serial MES Fix : End
10956
10957 WSM_Serial_support_PVT.Update_attr_move( p_group_id => l_group_id ,
10958 p_internal_group_id => l_internal_group_id ,
10959 p_move_txn_id => l_move_txn_id ,
10960 p_scrap_txn_id => l_scrap_id ,
10961 -- Pass the org as NULL since can process across orgs...
10962 p_organization_id => null ,
10963 x_return_status => l_return_status ,
10964 x_error_count => l_error_count ,
10965 x_error_msg => l_error_msg
10966 );
10967
10968 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10969 IF (l_debug='Y') THEN
10970 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned Success');
10971 END IF;
10972 ELSE
10973 IF (l_error_count = 1) THEN
10974 fnd_file.put_line(fnd_file.log, l_error_msg);
10975 ELSIF (l_error_count > 1) THEN
10976 FOR i IN 1..l_error_count LOOP
10977 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10978 p_encoded => FND_API.G_FALSE
10979 );
10980 fnd_file.put_line(fnd_file.log, l_error_msg);
10981 END LOOP;
10982 ELSE
10983 l_error_msg := 'WSM_Serial_support_PVT.Update_attr_move returned failure';
10984 END IF;
10985
10986 IF (l_debug='Y') THEN
10987 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned failure');
10988 END IF;
10989 -- This call is supposed to not return any error...
10990 raise e_proc_exception;
10991
10992 END IF;
10993 END;
10994 end if; --End of check on p_source_code added for bug 5368120.
10995 -- ST : Serial Project --
10996
10997 l_stmt_num := 300;
10998 l_del_profile_value := fnd_profile.value('WSM_INTERFACE_HISTORY_DAYS');
10999
11000 -- ST : Serial Support Project --
11001 -- User inserted records...
11002
11003 -- DELETE wsm_serial_txn_interface
11004 -- WHERE header_id in (SELECT header_id
11005 -- from wsm_lot_move_txn_interface wlmti
11006 -- WHERE group_id = l_wmti_group_id
11007 -- and status = WIP_CONSTANTS.COMPLETED
11008 -- AND transaction_date <= decode(l_del_profile_value, NULL,
11009 -- transaction_date-1, SYSDATE-l_del_profile_value)
11010 -- )
11011 -- AND action_flag in (1,2,3,4,5,6)
11012 -- and transaction_type_id = 2;
11013 --
11014 -- -- Delete the inserted records for Attributes...
11015 -- DELETE wsm_serial_txn_interface
11016 -- WHERE header_id IN (Select wmt.transaction_id
11017 -- from wip_move_transactions wmt,
11018 -- wsm_lot_move_txn_interface wlmti
11019 -- where wlmti.group_id = l_wmti_group_id
11020 -- and wlmti.wip_entity_id = wmt.wip_entity_id
11021 -- and wlmti.status = WIP_CONSTANTS.COMPLETED)
11022 -- AND transaction_type_id = 5;
11023 -- ST : Serial Support Project --
11024
11025 DELETE wsm_lot_move_txn_interface wlmti
11026 WHERE status = WIP_CONSTANTS.COMPLETED
11027 AND transaction_date <= decode(l_del_profile_value, NULL,
11028 transaction_date-1, SYSDATE-l_del_profile_value)
11029 RETURNING header_id BULK COLLECT INTO l_header_id_tbl;
11030
11031 -- ST : Serial Support Project --
11032 -- User inserted records...
11033 IF l_header_id_tbl.count > 0 THEN
11034 forall l_index in l_header_id_tbl.first..l_header_id_tbl.last
11035 DELETE wsm_serial_txn_interface
11036 WHERE header_id = l_header_id_tbl(l_index)
11037 AND transaction_type_id = 2;
11038 END IF;
11039 -- ST : Serial Support Project --
11040
11041 /* commit for every successful set of records in the inner loop */
11042 --mes
11043 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11044 COMMIT;
11045 END IF;
11046 END LOOP;/* end outer_loop */
11047 <<outer_loop>>
11048 /****************************
11049 --mes
11050 BEGIN
11051 UPDATE WIP_OPERATIONS
11052 SET wsm_costed_quantity_completed = quantity_completed
11053 WHERE ROWID IN
11054 (SELECT WO.ROWID
11055 FROM WIP_OPERATIONS WO, WIP_MOVE_TRANSACTIONS WMT, WSM_LOT_MOVE_TXN_INTERFACE WLMTI
11056 WHERE WLMTI.group_id = p_group_id
11057 AND WMT.transaction_id = WLMTI.transaction_id
11058 AND WO.wip_entity_id = WMT.wip_entity_id
11059 AND (WO.operation_seq_num IN (WMT.fm_operation_seq_num, WMT.to_operation_seq_num))
11060 AND NOT (
11061 (nvl(WO.quantity_waiting_to_move, 0) <> 0)
11062 AND
11063 (EXISTS (SELECT WSMT.ROWID
11064 FROM WSM_SPLIT_MERGE_TRANSACTIONS WSMT,
11065 WSM_SM_RESULTING_JOBS WSRJ
11066 WHERE WSRJ.wip_entity_id = WO.wip_entity_id
11067 AND WSRJ.starting_operation_seq_num = WO.operation_seq_num
11068 AND WSRJ.starting_intraoperation_step = g_tomove
11069 AND WSRJ.transaction_id = WSMT.transaction_id
11070 )
11071 )
11072 )
11073 );
11074
11075 END;
11076 *****************************/
11077 --mes
11078 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11079 COMMIT;
11080 END IF;
11081 --mes end
11082 l_stmt_num := 320;
11083
11084 DECLARE
11085 CONC_STATUS BOOLEAN;
11086 l_tot_count NUMBER := l_total_txns;
11087 l_err_count NUMBER;
11088
11089 BEGIN
11090 SELECT count(*)
11091 INTO l_err_count
11092 FROM wsm_lot_move_txn_interface
11093 WHERE group_id = p_group_id
11094 AND status = 3;
11095
11096 IF (l_debug = 'Y') THEN
11097 FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_err_count '||l_err_count);
11098 FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_total_txns '||l_total_txns);
11099 END IF;
11100
11101 IF (l_tot_count = l_err_count AND l_tot_count <>0) THEN
11102 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11103 'Errors encountered in interface txn, '
11104 || 'please check the log file.');
11105 -- Added to fix bug 1815584 - moved here from error_handler
11106 ELSIF (l_err_count > 0) THEN
11107 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('WARNING',
11108 'Errors encountered in interface txn, '
11109 || 'please check the log file.');
11110 -- End additions to fix bug 1815584
11111 ELSIF ((l_err_count = 0) AND (l_tot_count = 0)) THEN
11112 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('COMPLETE', null);
11113 END IF;
11114 END;
11115
11116 /*Changes for skaradib*/
11117 --move enh 115.135 added IF condn after perf check
11118 IF (g_aps_wps_profile='N') THEN
11119 l_stmt_num := 330;
11120 DECLARE
11121 x_group_id NUMBER;
11122 BEGIN
11123 x_group_id := WSMPWROT.GET_EXPLOSION_GROUP_ID;
11124 DELETE from BOM_EXPLOSION_TEMP
11125 WHERE group_id = x_group_id;
11126
11127 WSMPWROT.SET_EXPLOSION_GROUP_ID_NULL;
11128 COMMIT;
11129 END;
11130 END IF;
11131
11132 /*Changes for skaradib*/
11133
11134 l_stmt_num := 340;
11135 IF (g_mrp_debug='Y') THEN
11136 fnd_file.put_line(fnd_file.log,'WSMPLBMI.MoveTransaction Successful ');
11137 END IF;
11138
11139 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11140 l_msg_tokens.delete;
11141 WSM_log_PVT.logMessage (
11142 p_module_name => l_module ,
11143 p_msg_text => 'End MoveTransactions Main',
11144 p_stmt_num => l_stmt_num ,
11145 p_msg_tokens => l_msg_tokens ,
11146 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11147 p_run_log_level => l_log_level
11148 );
11149 END IF;
11150
11151 EXCEPTION
11152 WHEN FND_API.G_EXC_ERROR THEN
11153 IF (x_return_status = g_ret_success) THEN
11154 l_msg_tokens.delete;
11155 WSM_log_PVT.logMessage (
11156 p_module_name => l_module,
11157 p_msg_text => 'inside WHEN FND_API.G_EXC_ERROR THEN',
11158 p_stmt_num => l_stmt_num,
11159 p_msg_tokens => l_msg_tokens,
11160 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11161 p_run_log_level => l_log_level
11162 );
11163 END IF;
11164 retcode := 1;
11165 ROLLBACK;
11166 UPDATE wsm_lot_move_txn_interface WLMTI
11167 SET WLMTI.ERROR = 'Error WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||')',
11168 WLMTI.STATUS = g_error,
11169 WLMTI.LAST_UPDATE_DATE = SYSDATE
11170 WHERE WLMTI.GROUP_ID = p_group_id
11171 AND WLMTI.STATUS in (g_pending, g_running) ;
11172
11173 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11174 IF (x_return_status = g_ret_success) THEN
11175 l_msg_tokens.delete;
11176 WSM_log_PVT.logMessage (
11177 p_module_name => l_module,
11178 p_msg_text => 'inside WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN',
11179 p_stmt_num => l_stmt_num,
11180 p_msg_tokens => l_msg_tokens,
11181 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11182 p_run_log_level => l_log_level
11183 );
11184 END IF;
11185 retcode := -1;
11186 ROLLBACK;
11187 UPDATE wsm_lot_move_txn_interface WLMTI
11188 SET WLMTI.ERROR = 'Error WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||')',
11189 WLMTI.STATUS = g_error,
11190 WLMTI.LAST_UPDATE_DATE = SYSDATE
11191 WHERE WLMTI.GROUP_ID = p_group_id
11192 AND WLMTI.STATUS in (g_pending, g_running) ;
11193
11194 WHEN e_proc_exception THEN
11195
11196 retcode := -1;
11197 errbuf := 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') : '||x_error_msg;
11198 fnd_file.put_line(fnd_file.log, errbuf);
11199 ROLLBACK;
11200
11201 UPDATE wsm_lot_move_txn_interface WLMTI
11202 SET WLMTI.ERROR = substrb('Error:' ||errbuf, 1, 2000),
11203 WLMTI.STATUS = g_error,
11204 WLMTI.LAST_UPDATE_DATE = SYSDATE
11205 WHERE WLMTI.GROUP_ID = p_group_id
11206 AND WLMTI.STATUS in (g_pending, g_running) ;
11207
11208 IF (g_mrp_debug='Y') THEN
11209 fnd_file.put_line(fnd_file.log, 'Updated # of txns: '||SQL%ROWCOUNT||' (set WLMTI.error = ErrorMsg)'); /* bugfix 2721366 */
11210 END IF;
11211
11212 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11213 'errors encountered in interface txn, please check the log file.');
11214
11215 --mes
11216 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11217 COMMIT;
11218 END IF;
11219
11220 WHEN my_exception THEN
11221
11222 l_CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('COMPLETE', null);
11223 ROLLBACK;
11224 --COMMIT;
11225
11226 WHEN OTHERS THEN
11227 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
11228 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
11229 THEN
11230 WSM_log_PVT.handle_others(
11231 p_module_name => l_module ,
11232 p_stmt_num => l_stmt_num ,
11233 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
11234 p_run_log_level => l_log_level
11235 );
11236 END IF;
11237
11238 retcode := SQLCODE;
11239 errbuf :='WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') : '||sqlerrm;
11240 fnd_file.put_line(fnd_file.log, errbuf);
11241 ROLLBACK;
11242
11243 UPDATE wsm_lot_move_txn_interface WLMTI
11244 SET WLMTI.ERROR = substrb('Unexpected SQL Error:' ||errbuf, 1, 2000),
11245 WLMTI.STATUS = g_error,
11246 WLMTI.LAST_UPDATE_DATE = SYSDATE
11247 WHERE WLMTI.GROUP_ID = p_group_id
11248 AND WLMTI.STATUS in (g_pending, g_running) ;
11249
11250 IF (g_mrp_debug='Y') THEN
11251 fnd_file.put_line(fnd_file.log, 'Updated # of txns: '||SQL%ROWCOUNT||' (set WLMTI.error = ErrorMsg)'); /* bugfix 2721366 */
11252 END IF;
11253
11254 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11255 'errors encountered in interface txn, please check the log file.');
11256
11257 --mes
11258 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11259 COMMIT;
11260 END IF;
11261
11262 END MoveTransaction;
11263
11264 /****************************************************************************
11265 Called from Move Out page via Rosetta wrapper for processing Move Transaction. This in turn inserts
11266 the data into the interface table and calls the overloaded MoveTransaction procedure.
11267 ****************************************************************************/
11268
11269 Procedure MoveTransaction(
11270 p_group_id IN NUMBER,
11271 p_transaction_id IN NUMBER,
11272 p_source_code IN VARCHAR2,
11273 p_TRANSACTION_TYPE IN NUMBER,
11274 p_ORGANIZATION_ID IN NUMBER,
11275 p_WIP_ENTITY_ID IN NUMBER,
11276 p_WIP_ENTITY_NAME IN VARCHAR2,
11277 p_primary_item_id IN NUMBER,
11278 p_TRANSACTION_DATE IN DATE,
11279 p_FM_OPERATION_SEQ_NUM IN NUMBER,
11280 p_FM_OPERATION_CODE IN VARCHAR2,
11281 p_FM_DEPARTMENT_ID IN NUMBER,
11282 p_FM_DEPARTMENT_CODE IN VARCHAR2,
11283 p_FM_INTRAOPERATION_STEP_TYPE IN NUMBER,
11284 p_TO_OPERATION_SEQ_NUM IN NUMBER,
11285 p_TO_OPERATION_CODE IN VARCHAR2,
11286 p_TO_DEPARTMENT_ID IN NUMBER,
11287 p_TO_DEPARTMENT_CODE IN VARCHAR2,
11288 p_TO_INTRAOPERATION_STEP_TYPE IN NUMBER,
11289 p_PRIMARY_QUANTITY IN NUMBER,
11290 p_low_yield_trigger_limit IN NUMBER,
11291 p_primary_uom IN VARCHAR2,
11292 p_SCRAP_ACCOUNT_ID IN NUMBER,
11293 p_REASON_ID IN NUMBER,
11294 p_REASON_NAME IN VARCHAR2,
11295 p_REFERENCE IN VARCHAR2,
11296 p_QA_COLLECTION_ID IN NUMBER,
11297 p_JUMP_FLAG IN VARCHAR2,
11298 p_HEADER_ID IN NUMBER,
11299 p_PRIMARY_SCRAP_QUANTITY IN NUMBER,
11300 p_bonus_quantity IN NUMBER,
11301 p_SCRAP_AT_OPERATION_FLAG IN NUMBER,
11302 p_bonus_account_id IN NUMBER,
11303 p_employee_id IN NUMBER,
11304 p_operation_start_date IN DATE,
11305 p_operation_completion_date IN DATE,
11306 p_expected_completion_date IN DATE,
11307 p_mtl_txn_hdr_id IN NUMBER,
11308 p_sec_uom_code_tbl IN t_sec_uom_code_tbl_type,
11309 p_sec_move_out_qty_tbl IN t_sec_move_out_qty_tbl_type,
11310 p_jobop_scrap_serials_tbl IN WSM_Serial_support_GRP.WSM_SERIAL_NUM_TBL,
11311 p_jobop_bonus_serials_tbl IN WSM_Serial_support_GRP.WSM_SERIAL_NUM_TBL,
11312 p_scrap_codes_tbl IN t_scrap_codes_tbl_type,
11313 p_scrap_code_qty_tbl IN t_scrap_code_qty_tbl_type,
11314 p_bonus_codes_tbl IN t_bonus_codes_tbl_type,
11315 p_bonus_code_qty_tbl IN t_bonus_code_qty_tbl_type,
11316 p_jobop_resource_usages_tbl IN t_jobop_res_usages_tbl_type,
11317 x_wip_move_api_sucess_msg OUT NOCOPY VARCHAR2
11318 , x_return_status OUT NOCOPY VARCHAR2
11319 , x_msg_count OUT NOCOPY NUMBER
11320 , x_msg_data OUT NOCOPY VARCHAR2
11321 )
11322 IS
11323 l_sec_uom_code_tbls t_sec_uom_code_tbls_type;
11324 l_sec_move_out_qty_tbls t_sec_move_out_qty_tbls_type;
11325 l_scrap_codes_tbls t_scrap_codes_tbls_type;
11326 l_scrap_code_qty_tbls t_scrap_code_qty_tbls_type;
11327 l_bonus_codes_tbls t_bonus_codes_tbls_type;
11328 l_bonus_code_qty_tbls t_bonus_code_qty_tbls_type;
11329 l_jobop_scrap_serials_tbls t_scrap_serials_tbls_type ;
11330 l_jobop_bonus_serials_tbls t_bonus_serials_tbls_type ;
11331 l_jobop_resource_usages_tbls t_jobop_res_usages_tbls_type;
11332
11333 l_transaction_id NUMBER;
11334 l_group_id NUMBER;
11335 l_header_id NUMBER;
11336 TYPE t_err_msg_tbl_type IS TABLE OF VARCHAR2(240);
11337 l_err_msg_tbl t_err_msg_tbl_type;
11338 l_stmt_num NUMBER;
11339 retcode NUMBER;
11340 errbuf VARCHAR2(4000);
11341 x_message VARCHAR2(4000);
11342 x_msg_index NUMBER;
11343
11344 -- Logging variables.....
11345 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
11346 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
11347 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.MoveTransactions.html';
11348 l_param_tbl WSM_Log_PVT.param_tbl_type;
11349 x_error_count NUMBER;
11350 x_return_code NUMBER;
11351 x_error_msg VARCHAR2(4000);
11352 BEGIN
11353 x_return_status := G_RET_SUCCESS;
11354 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11355 l_msg_tokens.delete;
11356 WSM_log_PVT.logMessage (
11357 p_module_name => l_module ,
11358 p_msg_text => 'Begin MoveTransactions html',
11359 p_stmt_num => l_stmt_num ,
11360 p_msg_tokens => l_msg_tokens ,
11361 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11362 p_run_log_level => l_log_level
11363 );
11364 END IF;
11365
11366 IF G_LOG_LEVEL_PROCEDURE >= l_log_level THEN
11367
11368 l_param_tbl.delete;
11369 l_param_tbl(1).paramName := 'p_group_id';
11370 l_param_tbl(1).paramValue := p_group_id;
11371 l_param_tbl(2).paramName := 'p_transaction_id';
11372 l_param_tbl(2).paramValue := p_transaction_id;
11373 l_param_tbl(3).paramName := 'p_source_code';
11374 l_param_tbl(3).paramValue := p_source_code;
11375 l_param_tbl(4).paramName := 'p_transaction_type';
11376 l_param_tbl(4).paramValue := p_transaction_type;
11377 l_param_tbl(5).paramName := 'p_organization_id';
11378 l_param_tbl(5).paramValue := p_organization_id;
11379 l_param_tbl(6).paramName := 'p_wip_entity_id';
11380 l_param_tbl(6).paramValue := p_wip_entity_id;
11381 l_param_tbl(7).paramName := 'p_wip_entity_name';
11382 l_param_tbl(7).paramValue := p_wip_entity_name;
11383 l_param_tbl(8).paramName := 'p_primary_item_id';
11384 l_param_tbl(8).paramValue := p_primary_item_id;
11385 l_param_tbl(9).paramName := 'p_transaction_date';
11386 l_param_tbl(9).paramValue := p_transaction_date;
11387 l_param_tbl(10).paramName := 'p_fm_operation_seq_num';
11388 l_param_tbl(10).paramValue := p_fm_operation_seq_num;
11389 l_param_tbl(11).paramName := 'p_fm_operation_code';
11390 l_param_tbl(11).paramValue := p_fm_operation_code;
11391 l_param_tbl(12).paramName := 'p_fm_department_id';
11392 l_param_tbl(12).paramValue := p_fm_department_id;
11393 l_param_tbl(13).paramName := 'p_fm_department_code';
11394 l_param_tbl(13).paramValue := p_fm_department_code;
11395 l_param_tbl(14).paramName := 'p_fm_intraoperation_step_type';
11396 l_param_tbl(14).paramValue := p_fm_intraoperation_step_type;
11397 l_param_tbl(15).paramName := 'p_to_operation_seq_num';
11398 l_param_tbl(15).paramValue := p_to_operation_seq_num;
11399 l_param_tbl(16).paramName := 'p_to_operation_code';
11400 l_param_tbl(16).paramValue := p_to_operation_code;
11401 l_param_tbl(17).paramName := 'p_to_department_id';
11402 l_param_tbl(17).paramValue := p_to_department_id;
11403 l_param_tbl(18).paramName := 'p_to_department_code';
11404 l_param_tbl(18).paramValue := p_to_department_code;
11405 l_param_tbl(19).paramName := 'p_to_intraoperation_step_type';
11406 l_param_tbl(19).paramValue := p_to_intraoperation_step_type;
11407 l_param_tbl(20).paramName := 'p_primary_quantity';
11408 l_param_tbl(20).paramValue := p_primary_quantity;
11409 l_param_tbl(21).paramName := 'p_low_yield_trigger_limit';
11410 l_param_tbl(21).paramValue := p_low_yield_trigger_limit;
11411 l_param_tbl(22).paramName := 'p_primary_uom';
11412 l_param_tbl(22).paramValue := p_primary_uom;
11413 l_param_tbl(23).paramName := 'p_scrap_account_id';
11414 l_param_tbl(23).paramValue := p_scrap_account_id;
11415 l_param_tbl(24).paramName := 'p_reason_id';
11416 l_param_tbl(24).paramValue := p_reason_id;
11417 l_param_tbl(25).paramName := 'p_reason_name';
11418 l_param_tbl(25).paramValue := p_reason_name;
11419 l_param_tbl(26).paramName := 'p_reference';
11420 l_param_tbl(26).paramValue := p_reference;
11421 l_param_tbl(27).paramName := 'p_qa_collection_id';
11422 l_param_tbl(27).paramValue := p_qa_collection_id;
11423 l_param_tbl(28).paramName := 'p_jump_flag';
11424 l_param_tbl(28).paramValue := p_jump_flag;
11425 l_param_tbl(29).paramName := 'p_header_id';
11426 l_param_tbl(29).paramValue := p_header_id;
11427 l_param_tbl(30).paramName := 'p_primary_scrap_quantity';
11428 l_param_tbl(30).paramValue := p_primary_scrap_quantity;
11429 l_param_tbl(31).paramName := 'p_bonus_quantity';
11430 l_param_tbl(31).paramValue := p_bonus_quantity;
11431 l_param_tbl(32).paramName := 'p_scrap_at_operation_flag';
11432 l_param_tbl(32).paramValue := p_scrap_at_operation_flag;
11433 l_param_tbl(33).paramName := 'p_bonus_account_id';
11434 l_param_tbl(33).paramValue := p_bonus_account_id;
11435 l_param_tbl(34).paramName := 'p_employee_id';
11436 l_param_tbl(34).paramValue := p_employee_id;
11437 l_param_tbl(35).paramName := 'p_operation_start_date';
11438 l_param_tbl(35).paramValue := p_operation_start_date;
11439 l_param_tbl(36).paramName := 'p_operation_completion_date';
11440 l_param_tbl(36).paramValue := p_operation_completion_date;
11441 l_param_tbl(37).paramName := 'p_expected_completion_date';
11442 l_param_tbl(37).paramValue := p_expected_completion_date;
11443 l_param_tbl(38).paramName := 'p_mtl_txn_hdr_id';
11444 l_param_tbl(38).paramValue := p_mtl_txn_hdr_id;
11445
11446 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
11447 p_param_tbl => l_param_tbl,
11448 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE
11449 );
11450 END IF;
11451
11452 l_stmt_num := 10;
11453
11454 DELETE FROM WSM_INTERFACE_ERRORS WHERE header_id = p_header_id;
11455
11456 IF (p_transaction_type IN (1, 2)) THEN
11457 DECLARE
11458 l_mti_rows NUMBER;
11459 l_mtli_rows NUMBER;
11460 l_msni_rows NUMBER;
11461 l_numErrRows NUMBER;
11462 l_numTempRows NUMBER;
11463 x_trans_count NUMBER;
11464 type err_tbl_t is table of varchar2(240);
11465 type item_tbl_t is table of varchar2(2000);
11466 l_errExplTbl err_tbl_t;
11467 l_itemNameTbl item_tbl_t;
11468 BEGIN
11469 BEGIN
11470 select count(*)
11471 into l_mti_rows
11472 from MTL_TRANSACTIONS_INTERFACE
11473 where transaction_header_id = p_mtl_txn_hdr_id;
11474 EXCEPTION
11475 WHEN no_data_found THEN
11476 l_mti_rows := 0;
11477 END;
11478
11479 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11480 /*************
11481 BEGIN
11482 select count(*)
11483 into l_mtli_rows
11484 from mtl_serial_numbers_interface
11485 where transaction_header_id = p_mtl_txn_hdr_id;
11486 EXCEPTION
11487 WHEN no_data_found THEN
11488 l_mti_rows := 0;
11489 END;
11490
11491 BEGIN
11492 select count(*)
11493 into l_mti_rows
11494 from mtl_serial_numbers_interface
11495 where transaction_header_id = p_mtl_txn_hdr_id;
11496 EXCEPTION
11497 WHEN no_data_found THEN
11498 l_mti_rows := 0;
11499 END;
11500 **************/
11501 DECLARE
11502 CURSOR C_MTLI IS
11503 SELECT MTLI.TRANSACTION_INTERFACE_ID, MTLI.LOT_NUMBER, MTLI.TRANSACTION_QUANTITY,
11504 MTLI.PRIMARY_QUANTITY
11505 FROM mtl_transaction_lots_interface MTLI,
11506 mtl_transactions_interface MTI
11507 WHERE MTI.TRANSACTION_HEADER_ID = p_mtl_txn_hdr_id
11508 AND MTI.TRANSACTION_INTERFACE_ID = MTLI.TRANSACTION_INTERFACE_ID;
11509 BEGIN
11510 FOR rec in C_MTLI LOOP
11511 l_msg_tokens.delete;
11512 WSM_log_PVT.logMessage (
11513 p_module_name => l_module ,
11514 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11515 ||'p_mtl_txn_hdr_id: '
11516 ||p_mtl_txn_hdr_id
11517 ||'MTLI.TRANSACTION_INTERFACE_ID: '
11518 ||rec.TRANSACTION_INTERFACE_ID
11519 ||'MTLI.LOT_NUMBER: '
11520 ||rec.LOT_NUMBER
11521 ||'MTLI.TRANSACTION_QUANTITY: '
11522 ||rec.TRANSACTION_QUANTITY
11523 ||'MTLI.PRIMARY_QUANTITY: '
11524 ||rec.PRIMARY_QUANTITY,
11525 p_stmt_num => l_stmt_num ,
11526 p_msg_tokens => l_msg_tokens ,
11527 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11528 p_run_log_level => l_log_level
11529 );
11530 END LOOP;
11531 END;
11532 l_msg_tokens.delete;
11533 WSM_log_PVT.logMessage (
11534 p_module_name => l_module ,
11535 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11536 ||'Number of mti rows: '
11537 ||l_mti_rows,
11538 p_stmt_num => l_stmt_num ,
11539 p_msg_tokens => l_msg_tokens ,
11540 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11541 p_run_log_level => l_log_level
11542 );
11543 END IF;
11544
11545 IF (l_mti_rows > 0) THEN
11546
11547
11548 UPDATE MTL_TRANSACTIONS_INTERFACE MTL
11549 SET MTL.wip_entity_type = WIP_CONSTANTS.LOTBASED,
11550 --bug 5584140 operation_seq_num is already stamped in the UI and there could be multiple
11551 --operation seq nums so don't overwrite. Get department_id for each operation
11552 --operation_seq_num = p_fm_operation_seq_num,
11553 --department_id = p_fm_department_id
11554 MTL.department_id = (SELECT department_id
11555 FROM WIP_OPERATIONS WO
11556 WHERE WO.wip_entity_id = p_wip_entity_id
11557 AND WO.operation_seq_num = MTL.operation_seq_num)
11558 WHERE MTL.transaction_header_id = p_mtl_txn_hdr_id;
11559
11560 retcode := INV_TXN_MANAGER_GRP.Validate_Transactions(
11561 p_api_version => 1.0,
11562 p_init_msg_list => fnd_api.g_false,
11563 p_validation_level => fnd_api.g_valid_level_full,
11564 p_header_id => p_mtl_txn_hdr_id,
11565 x_return_status => x_return_status,
11566 x_msg_count => x_msg_count,
11567 x_msg_data => x_msg_data,
11568 x_trans_count => x_trans_count);
11569
11570 select count(*)
11571 into l_numErrRows
11572 from mtl_transactions_interface
11573 where transaction_header_id = p_mtl_txn_hdr_id;
11574
11575 select count(*)
11576 into l_numTempRows
11577 from mtl_material_transactions_temp
11578 where transaction_header_id = p_mtl_txn_hdr_id;
11579
11580 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11581 l_msg_tokens.delete;
11582 WSM_log_PVT.logMessage (
11583 p_module_name => l_module ,
11584 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11585 ||'Number of mti rows: '
11586 ||l_numErrRows
11587 ||'; Number of mmtt rows: '
11588 ||l_numTempRows,
11589 p_stmt_num => l_stmt_num ,
11590 p_msg_tokens => l_msg_tokens ,
11591 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11592 p_run_log_level => l_log_level
11593 );
11594 END IF;
11595
11596 IF (x_return_status = g_ret_success) THEN
11597 if(l_numErrRows <> 0) then
11598 select msik.concatenated_segments, mti.error_explanation
11599 bulk collect into l_itemNameTbl,l_errExplTbl
11600 from mtl_transactions_interface mti,
11601 mtl_system_items_kfv msik
11602 where mti.transaction_header_id = p_mtl_txn_hdr_id
11603 and mti.error_explanation is not null
11604 and mti.inventory_item_id = msik.inventory_item_id
11605 and mti.organization_id = msik.organization_id;
11606
11607 for i in 1..l_itemNameTbl.count loop
11608 fnd_message.set_name('WIP', 'WIP_TMPINSERT_ERR');
11609 fnd_message.set_token('ITEM_NAME', l_itemNameTbl(i));
11610 fnd_message.set_token('ERR_MSG', l_errExplTbl(i));
11611 fnd_msg_pub.add;
11612 fnd_msg_pub.get
11613 ( p_msg_index => fnd_msg_pub.G_NEXT - 1,
11614 p_encoded => 'T',
11615 p_data => x_message,
11616 p_msg_index_out => x_msg_index
11617 );
11618 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11619 l_msg_tokens.delete;
11620 WSM_log_PVT.logMessage (
11621 p_module_name => l_module ,
11622 p_msg_text => 'Error from INV_TXN_MANAGER_GRP.Validate_Transactions '||x_message,
11623 p_stmt_num => l_stmt_num ,
11624 p_msg_tokens => l_msg_tokens ,
11625 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11626 p_run_log_level => l_log_level
11627 );
11628 END IF;
11629 end loop;
11630
11631 RAISE FND_API.G_EXC_ERROR;
11632 END IF;
11633
11634 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11635 l_msg_tokens.delete;
11636 WSM_log_PVT.logMessage (
11637 p_module_name => l_module ,
11638 p_msg_text => 'After call to INV_TXN_MANAGER_GRP.Validate_Transactions: '||
11639 'x_return_status '||x_return_status||
11640 '; no of rows in mmtt '||l_numTempRows,
11641 p_stmt_num => l_stmt_num ,
11642 p_msg_tokens => l_msg_tokens ,
11643 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11644 p_run_log_level => l_log_level
11645 );
11646 END IF;
11647 ELSIF (x_return_status = g_ret_error) THEN
11648 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11649 l_msg_tokens.delete;
11650 WSM_log_PVT.logMessage (
11651 p_module_name => l_module ,
11652 p_msg_text => 'Error from INV_TXN_MANAGER_GRP.Validate_Transactions '
11653 ||x_msg_data,
11654 p_stmt_num => l_stmt_num ,
11655 p_msg_tokens => l_msg_tokens ,
11656 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11657 p_run_log_level => l_log_level
11658 );
11659 END IF;
11660 RAISE FND_API.G_EXC_ERROR;
11661 ELSIF (x_return_status = g_ret_unexpected) THEN
11662 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11663 END IF;
11664 END IF; --(l_mti_rows > 0)
11665 END;
11666 ELSE --p_transaction_type IN (g_undo_txn, g_ret_txn)
11667 WSM_Serial_support_GRP.populate_components(
11668 p_wip_entity_id => p_wip_entity_id,
11669 p_organization_id => p_organization_id,
11670 p_move_txn_id => p_transaction_id,
11671 p_move_txn_type => p_transaction_type,
11672 p_txn_date => p_transaction_date,
11673 p_mtl_txn_hdr_id => p_mtl_txn_hdr_id,
11674 p_compl_txn_id => null,
11675 x_return_status => x_return_status,
11676 x_error_count => x_msg_count,
11677 x_error_msg => x_msg_data
11678 );
11679
11680 IF (x_return_status = g_ret_error) THEN
11681 RAISE FND_API.G_EXC_ERROR;
11682 ELSIF (x_return_status = g_ret_unexpected) THEN
11683 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11684 END IF;
11685
11686 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11687
11688 DECLARE
11689 l_mmtt_rows NUMBER;
11690 l_mtlt_rows NUMBER;
11691 l_msnt_rows NUMBER;
11692 BEGIN
11693
11694 SELECT count(*)
11695 INTO l_mmtt_rows
11696 FROM mtl_material_transactions_temp
11697 WHERE transaction_header_id = p_mtl_txn_hdr_id;
11698
11699 SELECT count(*)
11700 INTO l_mtlt_rows
11701 FROM mtl_transaction_lots_temp mtlt, mtl_material_transactions_temp mmtt
11702 WHERE mmtt.transaction_header_id = p_mtl_txn_hdr_id
11703 AND mtlt.TRANSACTION_TEMP_ID = mmtt.TRANSACTION_TEMP_ID;
11704
11705 SELECT count(*)
11706 INTO l_msnt_rows
11707 FROM mtl_serial_numbers_temp msnt, mtl_material_transactions_temp mmtt
11708 WHERE mmtt.transaction_header_id = p_mtl_txn_hdr_id
11709 AND msnt.TRANSACTION_TEMP_ID = mmtt.TRANSACTION_TEMP_ID;
11710
11711 IF (x_return_status = g_ret_success) THEN
11712 l_msg_tokens.delete;
11713 WSM_log_PVT.logMessage (
11714 p_module_name => l_module ,
11715 p_msg_text => 'WSM_Serial_support_GRP.populate_components returned successfully '||
11716 ';l_mmtt_rows '||
11717 l_mmtt_rows||
11718 ';l_mtlt_rows '||
11719 l_mtlt_rows||
11720 ';l_msnt_rows '||
11721 l_msnt_rows,
11722 p_stmt_num => l_stmt_num ,
11723 p_msg_tokens => l_msg_tokens ,
11724 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11725 p_run_log_level => l_log_level
11726 );
11727 END IF;
11728 END;
11729 END IF;
11730
11731 END IF; --p_transaction_type IN (g_undo_txn, g_ret_txn)
11732
11733 DELETE FROM WSM_LOT_MOVE_TXN_INTERFACE WHERE header_id = p_header_id;
11734
11735 INSERT into WSM_LOT_MOVE_TXN_INTERFACE
11736 (
11737 -- INTERFACE_ID -- commented for bugfix 7194524
11738 TRANSACTION_ID
11739 , LAST_UPDATE_DATE
11740 , LAST_UPDATED_BY
11741 , LAST_UPDATED_BY_NAME
11742 , CREATION_DATE
11743 , CREATED_BY
11744 , CREATED_BY_NAME
11745 , LAST_UPDATE_LOGIN
11746 , GROUP_ID
11747 , SOURCE_CODE
11748 , STATUS
11749 , TRANSACTION_TYPE
11750 , ORGANIZATION_ID
11751 , ORGANIZATION_CODE
11752 , WIP_ENTITY_ID
11753 , WIP_ENTITY_NAME
11754 , ENTITY_TYPE
11755 , PRIMARY_ITEM_ID
11756 , TRANSACTION_DATE
11757 , FM_OPERATION_SEQ_NUM
11758 , FM_OPERATION_CODE
11759 , FM_DEPARTMENT_ID
11760 , FM_DEPARTMENT_CODE
11761 , FM_INTRAOPERATION_STEP_TYPE
11762 , TO_OPERATION_SEQ_NUM
11763 , TO_OPERATION_CODE
11764 , TO_DEPARTMENT_ID
11765 , TO_DEPARTMENT_CODE
11766 , TO_INTRAOPERATION_STEP_TYPE
11767 , TRANSACTION_QUANTITY
11768 , TRANSACTION_UOM
11769 , PRIMARY_QUANTITY
11770 , PRIMARY_UOM
11771 , SCRAP_ACCOUNT_ID
11772 , REASON_ID
11773 , REASON_NAME
11774 , REFERENCE
11775 , ATTRIBUTE_CATEGORY
11776 , ATTRIBUTE1
11777 , ATTRIBUTE2
11778 , ATTRIBUTE3
11779 , ATTRIBUTE4
11780 , ATTRIBUTE5
11781 , ATTRIBUTE6
11782 , ATTRIBUTE7
11783 , ATTRIBUTE8
11784 , ATTRIBUTE9
11785 , ATTRIBUTE10
11786 , ATTRIBUTE11
11787 , ATTRIBUTE12
11788 , ATTRIBUTE13
11789 , ATTRIBUTE14
11790 , ATTRIBUTE15
11791 , QA_COLLECTION_ID
11792 , JUMP_FLAG
11793 , HEADER_ID
11794 , PRIMARY_SCRAP_QUANTITY
11795 , SCRAP_QUANTITY
11796 , SCRAP_AT_OPERATION_FLAG
11797 )
11798 VALUES
11799 (
11800 -- NULL -- commented for bugfix 7194524
11801 p_transaction_id
11802 , sysdate --LAST_UPDATE_DATE
11803 , g_user_id --LAST_UPDATED_BY
11804 , fnd_global.user_name --LAST_UPDATED_BY_NAME
11805 , sysdate --CREATION_DATE
11806 , g_user_id --CREATED_BY
11807 , fnd_global.user_name--CREATED_BY_NAME
11808 , g_login_id --LAST_UPDATE_LOGIN
11809 , WIP_TRANSACTIONS_S.NEXTVAL --p_group_id --GROUP_ID
11810 , p_source_code --source_code
11811 , WIP_CONSTANTS.PENDING --STATUS
11812 , p_TRANSACTION_TYPE
11813 , p_ORGANIZATION_ID
11814 , null --!! ORGANIZATION_CODE
11815 , p_WIP_ENTITY_ID
11816 , p_WIP_ENTITY_NAME
11817 , WIP_CONSTANTS.LOTBASED --!!ENTITY_TYPE
11818 , null --PRIMARY_ITEM_ID
11819 , nvl(p_TRANSACTION_DATE, sysdate)
11820 , p_FM_OPERATION_SEQ_NUM
11821 , p_FM_OPERATION_CODE
11822 , p_FM_DEPARTMENT_ID
11823 , p_FM_DEPARTMENT_CODE
11824 , p_FM_INTRAOPERATION_STEP_TYPE
11825 , p_TO_OPERATION_SEQ_NUM
11826 , p_TO_OPERATION_CODE
11827 , p_TO_DEPARTMENT_ID
11828 , p_TO_DEPARTMENT_CODE
11829 , p_TO_INTRAOPERATION_STEP_TYPE
11830 , p_PRIMARY_QUANTITY --TRANSACTION_QUANTITY
11831 , p_PRIMARY_UOM --TRANSACTION_UOM
11832 , p_PRIMARY_QUANTITY
11833 , p_PRIMARY_UOM
11834 , p_SCRAP_ACCOUNT_ID
11835 , p_REASON_ID
11836 , p_REASON_NAME
11837 , p_REFERENCE
11838 , null --ATTRIBUTE_CATEGORY
11839 , null --ATTRIBUTE1
11840 , null --ATTRIBUTE2
11841 , null --ATTRIBUTE3
11842 , null --ATTRIBUTE4
11843 , null --ATTRIBUTE5
11844 , null --ATTRIBUTE6
11845 , null --ATTRIBUTE7
11846 , null --ATTRIBUTE8
11847 , null --ATTRIBUTE9
11848 , null --ATTRIBUTE10
11849 , null --ATTRIBUTE11
11850 , null --ATTRIBUTE12
11851 , null --ATTRIBUTE13
11852 , null --ATTRIBUTE14
11853 , null --ATTRIBUTE15
11854 , p_QA_COLLECTION_ID
11855 , p_JUMP_FLAG
11856 , nvl(p_HEADER_ID, wsm_lot_move_txn_interface_s.nextval) --HEADER_ID
11857 , p_PRIMARY_SCRAP_QUANTITY --PRIMARY_SCRAP_QUANTITY
11858 , p_PRIMARY_SCRAP_QUANTITY --SCRAP_QUANTITY
11859 , decode(p_primary_scrap_quantity, --bug 5584140 Added decode so that SCRAP_AT_OPERATION_FLAG=null when there is no scrap
11860 null, null,
11861 0, null,
11862 1) --SCRAP_AT_OPERATION_FLAG
11863 )
11864 RETURNING transaction_id, group_id, header_id INTO l_transaction_id, l_group_id, l_header_id;
11865
11866 l_stmt_num := 20;
11867 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11868 l_msg_tokens.delete;
11869 WSM_log_PVT.logMessage (
11870 p_module_name => l_module,
11871 p_msg_text => 'B4 UPDATE wsm_lot_move_txn_interface wlmti '||
11872 ';g_user_id '||
11873 g_user_id||
11874 ';fnd_global.user_name '||
11875 fnd_global.user_name,
11876 p_stmt_num => l_stmt_num,
11877 p_msg_tokens => l_msg_tokens,
11878 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
11879 p_run_log_level => l_log_level
11880 );
11881 END IF;
11882
11883 l_stmt_num := 30;
11884 l_sec_uom_code_tbls(l_header_id) := p_sec_uom_code_tbl;
11885 l_sec_move_out_qty_tbls(l_header_id) := p_sec_move_out_qty_tbl;
11886 l_scrap_codes_tbls(l_header_id) := p_scrap_codes_tbl;
11887 l_scrap_code_qty_tbls(l_header_id) := p_scrap_code_qty_tbl;
11888 l_bonus_codes_tbls(l_header_id) := p_bonus_codes_tbl;
11889 l_bonus_code_qty_tbls(l_header_id) := p_bonus_code_qty_tbl;
11890 l_jobop_scrap_serials_tbls(l_header_id) := p_jobop_scrap_serials_tbl ;
11891 l_jobop_bonus_serials_tbls(l_header_id) := p_jobop_bonus_serials_tbl ;
11892 l_jobop_resource_usages_tbls(l_header_id) := p_jobop_resource_usages_tbl;
11893 l_stmt_num := 40;
11894
11895 l_stmt_num := 50;
11896 MoveTransaction(
11897 p_group_id => l_group_id,
11898 p_bonus_account_id => p_bonus_account_id,
11899 p_employee_id => p_employee_id,
11900 p_operation_start_date => p_operation_start_date,
11901 p_operation_completion_date => p_operation_completion_date,
11902 p_expected_completion_date => p_expected_completion_date,
11903 p_bonus_quantity => p_bonus_quantity,
11904 p_low_yield_trigger_limit => p_low_yield_trigger_limit,
11905 p_source_code => p_source_code,
11906 p_mtl_txn_hdr_id => p_mtl_txn_hdr_id,
11907 p_sec_uom_code_tbls => l_sec_uom_code_tbls,
11908 p_sec_move_out_qty_tbls => l_sec_move_out_qty_tbls,
11909 p_jobop_scrap_serials_tbls => l_jobop_scrap_serials_tbls,
11910 p_jobop_bonus_serials_tbls => l_jobop_bonus_serials_tbls,
11911 p_scrap_codes_tbls => l_scrap_codes_tbls,
11912 p_scrap_code_qty_tbls => l_scrap_code_qty_tbls,
11913 p_bonus_codes_tbls => l_bonus_codes_tbls,
11914 p_bonus_code_qty_tbls => l_bonus_code_qty_tbls,
11915 p_jobop_resource_usages_tbls => l_jobop_resource_usages_tbls,
11916 x_wip_move_api_sucess_msg => x_wip_move_api_sucess_msg,
11917 retcode => retcode,
11918 errbuf => errbuf
11919 );
11920
11921 IF (x_return_status = g_ret_success) THEN
11922 l_msg_tokens.delete;
11923 WSM_log_PVT.logMessage (
11924 p_module_name => l_module,
11925 p_msg_text => 'WSMPLBMI.MoveTransaction returned '||
11926 ';x_wip_move_api_sucess_msg '||
11927 x_wip_move_api_sucess_msg||
11928 ';retcode '||
11929 retcode||
11930 ';errbuf '||
11931 errbuf,
11932 p_stmt_num => l_stmt_num,
11933 p_msg_tokens => l_msg_tokens,
11934 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11935 p_run_log_level => l_log_level
11936 );
11937 END IF;
11938
11939 l_stmt_num := 60;
11940 /*
11941 DECLARE
11942 cursor C_WIE IS
11943 SELECT message
11944 FROM WSM_INTERFACE_ERRORS
11945 WHERE transaction_id = l_transaction_id;
11946
11947 i INTEGER := 0;
11948 BEGIN
11949 OPEN C_WIE;
11950 FETCH C_WIE BULK COLLECT INTO l_err_msg_tbl;
11951 CLOSE C_WIE;
11952
11953 LOOP
11954 IF l_err_msg_tbl.exists(i) THEN
11955 FND_MESSAGE.set_encoded(l_err_msg_tbl(i));
11956 FND_MSG_PUB.add;
11957 i := i+1;
11958 ELSE
11959 EXIT;
11960 END IF;
11961 END LOOP;
11962 END;
11963 */
11964 IF retcode > 0 THEN
11965 RAISE FND_API.G_EXC_ERROR;
11966 ELSIF retcode < 0 THEN
11967 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11968 END IF;
11969
11970 FND_MSG_PUB.Count_And_Get
11971 ( p_count => x_msg_count ,
11972 p_data => x_msg_data
11973 );
11974
11975 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11976 l_msg_tokens.delete;
11977 WSM_log_PVT.logMessage (
11978 p_module_name => l_module ,
11979 p_msg_text => 'End MoveTransactions html',
11980 p_stmt_num => l_stmt_num ,
11981 p_msg_tokens => l_msg_tokens ,
11982 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11983 p_run_log_level => l_log_level
11984 );
11985 END IF;
11986
11987 EXCEPTION
11988 WHEN FND_API.G_EXC_ERROR THEN
11989 ROLLBACK;
11990 x_return_status := G_RET_ERROR;
11991 FND_MSG_PUB.Count_And_Get
11992 ( p_count => x_msg_count ,
11993 p_data => x_msg_data
11994 );
11995
11996
11997 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11998 ROLLBACK;
11999 x_return_status := G_RET_UNEXPECTED;
12000 FND_MSG_PUB.Count_And_Get
12001 ( p_count => x_msg_count ,
12002 p_data => x_msg_data
12003 );
12004
12005 WHEN OTHERS THEN
12006 ROLLBACK;
12007 x_return_status := G_RET_UNEXPECTED;
12008
12009 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12010 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12011 THEN
12012 WSM_log_PVT.handle_others( p_module_name => l_module ,
12013 p_stmt_num => l_stmt_num ,
12014 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
12015 p_run_log_level => l_log_level
12016 );
12017 END IF;
12018
12019 FND_MSG_PUB.Count_And_Get
12020 ( p_count => x_msg_count ,
12021 p_data => x_msg_data
12022 );
12023
12024 END;
12025
12026 /****************************************************************************
12027 Called from the Move Out page to set the page properties
12028 ****************************************************************************/
12029
12030 Procedure getMoveOutPageProperties(
12031 p_organization_id IN NUMBER
12032 , p_wip_entity_id IN NUMBER
12033 , p_operation_seq_num IN NUMBER
12034 , p_routing_operation IN NUMBER
12035 , p_job_type IN NUMBER
12036 , p_current_step IN NUMBER
12037 , p_user_id IN NUMBER
12038 , x_last_operation OUT NOCOPY NUMBER
12039 , x_estimated_scrap_accounting OUT NOCOPY NUMBER
12040 , x_show_next_op_by_default OUT NOCOPY NUMBER
12041 , x_multiple_res_usage_dates OUT NOCOPY NUMBER
12042 , x_show_scrap_codes OUT NOCOPY NUMBER
12043 , x_scrap_codes_defined OUT NOCOPY NUMBER
12044 , x_bonus_codes_defined OUT NOCOPY NUMBER
12045 , x_show_lot_attrib OUT NOCOPY NUMBER
12046 , x_show_scrap_serials OUT NOCOPY NUMBER
12047 , x_show_serial_region OUT NOCOPY NUMBER
12048 , x_show_secondary_quantities OUT NOCOPY NUMBER
12049 , x_transaction_type OUT NOCOPY NUMBER
12050 , x_quality_region OUT NOCOPY VARCHAR2
12051 , x_show_scrap_qty OUT NOCOPY NUMBER
12052 , x_show_next_op_choice OUT NOCOPY NUMBER
12053 , x_show_next_op OUT NOCOPY NUMBER
12054 , x_employee_id OUT NOCOPY NUMBER
12055 , x_operator OUT NOCOPY VARCHAR2
12056 , x_default_start_date OUT NOCOPY DATE
12057 , x_default_completion_date OUT NOCOPY DATE
12058 , x_return_status OUT NOCOPY VARCHAR2
12059 , x_msg_count OUT NOCOPY NUMBER
12060 , x_msg_data OUT NOCOPY VARCHAR2
12061 )
12062 IS
12063 l_bos_use_org_settings NUMBER;
12064 l_bos_show_next_op_by_default NUMBER;
12065 l_bos_show_scrap_codes NUMBER;
12066 l_bos_show_lot_attrib NUMBER;
12067 l_bos_mul_res_usage_dates NUMBER;
12068 l_bos_to_move_mandatory_flag NUMBER;
12069 l_bos_run_mandatory_flag NUMBER;
12070
12071 l_wsm_show_next_op_by_default NUMBER;
12072 l_wsm_mul_res_usage_dates NUMBER;
12073 l_wsm_move_in NUMBER;
12074 l_wsm_move_to_next_op NUMBER;
12075
12076 l_wip_queue_enabled_flag NUMBER;
12077 l_wip_run_enabled_flag NUMBER;
12078 l_wip_to_move_enabled_flag NUMBER;
12079 l_wip_scrap_enabled_flag NUMBER;
12080
12081 l_osfm_quality_txn_number NUMBER;
12082 l_serialization_start_op NUMBER;
12083 l_end_routing_operation NUMBER;
12084 l_stmt_num NUMBER;
12085 l_serialization_started NUMBER := 0; --bug 5444062 initialize to 0
12086 l_job_type NUMBER;
12087 l_first_serial_txn_id NUMBER; --bug 5444062
12088 -- Logging variables.....
12089 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12090 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12091 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.getMoveOutPageProperties';
12092 l_param_tbl WSM_Log_PVT.param_tbl_type;
12093 l_next_links_exist NUMBER := 0; --bug 5531107
12094 x_error_count NUMBER;
12095 x_return_code NUMBER;
12096 x_error_msg VARCHAR2(4000);
12097 BEGIN
12098 /*
12099 fnd_global.apps_initialize(user_id => 1008623,
12100 resp_id => 56236,
12101 resp_appl_id => 724);
12102 */
12103 -- delete from debug_sk;
12104 -- debug_pkg.ins('session_id '||fnd_global.session_id);
12105 x_return_status := g_ret_success;
12106 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
12107 l_msg_tokens.delete;
12108 WSM_log_PVT.logMessage (
12109 p_module_name => l_module ,
12110 p_msg_text => 'Begin getMoveOutPageProperties '||
12111 '; p_organization_id '||p_organization_id||
12112 ' ;p_wip_entity_id '||p_wip_entity_id||
12113 ' ;p_operation_seq_num '||p_operation_seq_num||
12114 ' ;p_routing_operation '||p_routing_operation||
12115 ' ;p_job_type '||p_job_type||
12116 ' ;p_current_step '||p_current_step||
12117 ' ;p_user_id '||p_user_id,
12118 p_stmt_num => l_stmt_num ,
12119 p_msg_tokens => l_msg_tokens ,
12120 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
12121 p_run_log_level => l_log_level
12122 );
12123 END IF;
12124
12125 l_stmt_num := 10;
12126 --SELECT queue_enabled_flag, run_enabled_flag, to_move_enabled_flag, scrap_enabled_flag
12127 --Bug 5051836:Replaced wip_parameters_v with wvis to fix the
12128 --share memory violation
12129 SELECT DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,1,1,0)),0,2,1),
12130 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,2,1,0)),0,2,1),
12131 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,3,
12132 DECODE(WVIS.RECORD_CREATOR,'USER',1,0),0)),0,2,1),
12133 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,5,1,0)),0,2,1)
12134 INTO l_wip_queue_enabled_flag, l_wip_run_enabled_flag, l_wip_to_move_enabled_flag, l_wip_scrap_enabled_flag
12135 --FROM WIP_PARAMETERS_V
12136 FROM WIP_VALID_INTRAOPERATION_STEPS WVIS
12137 WHERE organization_id = p_organization_id;
12138
12139 l_stmt_num := 20;
12140 SELECT nvl(show_next_op_by_default, 0),
12141 nvl(track_multi_usage_dates, 0), nvl(move_in_option, 2), nvl(move_to_next_op_option, 2)
12142 INTO l_wsm_show_next_op_by_default,
12143 l_wsm_mul_res_usage_dates, l_wsm_move_in, l_wsm_move_to_next_op
12144 FROM WSM_PARAMETERS
12145 WHERE organization_id = p_organization_id;
12146
12147 l_stmt_num := 30;
12148 /********bug 5463926 Always look at BSO instead of BOS. For the case of non standard operation
12149 trap the no data found exception and set the values
12150
12151 IF (p_routing_operation IS NOT NULL) THEN
12152 --bug 5300662 change the interpretation of NULL value for the column use_org_settings to YES
12153 --SELECT nvl(BOS.use_org_settings, 0), nvl(BOS.show_next_op_by_default, 0),
12154 --bug 5463926
12155 SELECT nvl(BOS.use_org_settings, 1), nvl(BOS.show_next_op_by_default, 0),
12156 nvl(BOS.show_scrap_code, 0), nvl(BOS.show_lot_attrib, 0),
12157 nvl(BOS.track_multiple_res_usage_dates, 0), nvl(BOS.to_move_mandatory_flag, 0),
12158 reference_flag
12159 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12160 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12161 l_bos_to_move_mandatory_flag, l_reference_flag
12162 FROM BOM_OPERATION_SEQUENCES BOS, WIP_OPERATIONS WO
12163 WHERE WO.wip_entity_id = p_wip_entity_id
12164 AND WO.operation_seq_num = p_operation_seq_num
12165 AND BOS.operation_sequence_id = WO.operation_sequence_id;
12166 ELSE
12167 --bug 5300662 change the interpretation of NULL value for the column use_org_settings to YES
12168 --SELECT nvl(BSO.use_org_settings, 0), nvl(BSO.show_next_op_by_default, 0),
12169 SELECT nvl(BSO.use_org_settings, 1), nvl(BSO.show_next_op_by_default, 0),
12170 nvl(BSO.show_scrap_code, 0), nvl(BSO.show_lot_attrib, 0),
12171 nvl(BSO.track_multiple_res_usage_dates, 0), nvl(BSO.to_move_mandatory_flag, 0)
12172 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12173 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12174 l_bos_to_move_mandatory_flag
12175 FROM BOM_STANDARD_OPERATIONS BSO, WIP_OPERATIONS WO
12176 WHERE WO.wip_entity_id = p_wip_entity_id
12177 AND WO.operation_seq_num = p_operation_seq_num
12178 AND BSO.standard_operation_id = WO.standard_operation_id
12179 AND BSO.organization_id = WO.organization_id;
12180 END IF;
12181 ********/
12182 BEGIN
12183 SELECT nvl(BSO.use_org_settings, 1), nvl(BSO.show_next_op_by_default, 0),
12184 nvl(BSO.show_scrap_code, 0), nvl(BSO.show_lot_attrib, 0),
12185 nvl(BSO.track_multiple_res_usage_dates, 0), nvl(BSO.to_move_mandatory_flag, 0)
12186 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12187 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12188 l_bos_to_move_mandatory_flag
12189 FROM BOM_STANDARD_OPERATIONS BSO, WIP_OPERATIONS WO
12190 WHERE WO.wip_entity_id = p_wip_entity_id
12191 AND WO.operation_seq_num = p_operation_seq_num
12192 AND BSO.standard_operation_id = WO.standard_operation_id
12193 AND BSO.organization_id = WO.organization_id;
12194 EXCEPTION
12195 WHEN no_data_found THEN
12196 l_bos_use_org_settings := 1;
12197 l_bos_show_next_op_by_default := 0;
12198 x_show_scrap_codes := 0;
12199 l_bos_show_lot_attrib := 0;
12200 l_bos_mul_res_usage_dates := 0;
12201 l_bos_to_move_mandatory_flag := 0;
12202 END;
12203 --bug 5463926 end
12204
12205 l_stmt_num := 40;
12206 SELECT operation_seq_num
12207 INTO l_end_routing_operation
12208 FROM WSM_COPY_OPERATIONS WCO
12209 WHERE WCO.wip_entity_id = p_wip_entity_id
12210 AND WCO.network_start_end = 'E';
12211
12212 l_stmt_num := 50;
12213 SELECT WO.actual_start_date, WO.employee_id, nvl(WO.actual_completion_date, sysdate)
12214 INTO x_default_start_date, x_employee_id, x_default_completion_date
12215 FROM WIP_OPERATIONS WO
12216 WHERE WO.wip_entity_id = p_wip_entity_id
12217 AND WO.operation_seq_num = p_operation_seq_num;
12218
12219 IF (l_end_routing_operation = p_routing_operation) THEN
12220 x_last_operation := 1;
12221 ELSE
12222 x_last_operation := 0;
12223 END IF;
12224
12225 /******* Moved to the Txn Validation API******
12226 l_stmt_num := 60;
12227 IF l_wip_to_move_enabled_flag = 2 THEN
12228 IF l_bos_use_org_settings = 1 THEN
12229 IF l_wsm_move_to_next_op = 1 THEN
12230 IF g_log_level_error >= l_log_level OR
12231 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12232 THEN
12233 l_msg_tokens.delete;
12234 WSM_log_PVT.logMessage(
12235 p_module_name => l_module,
12236 p_msg_name => 'WSM_MES_WIP_WSM_MOVE',
12237 p_msg_appl_name => 'WSM',
12238 p_msg_tokens => l_msg_tokens,
12239 p_stmt_num => l_stmt_num,
12240 p_fnd_msg_level => G_MSG_LVL_ERROR,
12241 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12242 p_run_log_level => l_log_level
12243 );
12244 END IF;
12245 RAISE FND_API.G_EXC_ERROR;
12246 END IF;
12247 ELSE
12248 IF l_bos_to_move_mandatory_flag = 1 THEN
12249 IF g_log_level_error >= l_log_level OR
12250 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12251 THEN
12252 l_msg_tokens.delete;
12253 WSM_log_PVT.logMessage(
12254 p_module_name => l_module,
12255 p_msg_name => 'WSM_MES_WIP_BOS_MOVE',
12256 p_msg_appl_name => 'WSM',
12257 p_msg_tokens => l_msg_tokens,
12258 p_stmt_num => l_stmt_num,
12259 p_fnd_msg_level => G_MSG_LVL_ERROR,
12260 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12261 p_run_log_level => l_log_level
12262 );
12263 END IF;
12264 RAISE FND_API.G_EXC_ERROR;
12265 END IF;
12266 END IF;
12267 END IF;
12268 ************************/
12269 /******* This should get trapped in the move txn allowed api******
12270 l_stmt_num := 70;
12271 IF (p_current_step = g_queue)
12272 AND (((l_bos_use_org_settings = 1) AND (l_bos_run_mandatory_flag = 1))
12273 OR
12274 ((l_bos_use_org_settings <> 1) AND (l_wsm_move_in = 1)))
12275 THEN
12276 IF g_log_level_error >= l_log_level OR
12277 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12278 THEN
12279 l_msg_tokens.delete;
12280 WSM_log_PVT.logMessage(
12281 p_module_name => l_module,
12282 p_msg_name => 'WSM_MES_MOVE_OUT_RUN_MAND',
12283 p_msg_appl_name => 'WSM',
12284 p_msg_tokens => l_msg_tokens,
12285 p_stmt_num => l_stmt_num,
12286 p_fnd_msg_level => G_MSG_LVL_ERROR,
12287 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12288 p_run_log_level => l_log_level
12289 );
12290 END IF;
12291 RAISE FND_API.G_EXC_ERROR;
12292 END IF;
12293 ********/
12294 IF l_wip_scrap_enabled_flag = 2 THEN
12295 x_show_scrap_qty := 0;
12296 ELSE
12297 x_show_scrap_qty := 1;
12298 END IF;
12299
12300 l_stmt_num := 80;
12301 x_estimated_scrap_accounting := wsmputil.wsm_esa_enabled(
12302 p_wip_entity_id => p_wip_entity_id,
12303 err_code => x_return_code,
12304 err_msg => x_error_msg,
12305 p_org_id => p_organization_id,
12306 p_job_type => p_job_type
12307 );
12308
12309 l_stmt_num := 90;
12310 BEGIN
12311 SELECT 1
12312 INTO x_show_secondary_quantities
12313 FROM dual
12314 WHERE EXISTS(
12315 SELECT 'secondary quantities exist'
12316 FROM WSM_OP_SECONDARY_QUANTITIES
12317 WHERE wip_entity_id = p_wip_entity_id
12318 AND operation_seq_num = p_operation_seq_num
12319
12320 );
12321 EXCEPTION
12322 WHEN no_data_found THEN
12323 x_show_secondary_quantities := 0;
12324 END;
12325
12326 l_stmt_num := 100;
12327 /********bug 5182689 modified the SELECT below to account for the case when serialization_start_op is null
12328 SELECT decode(first_serial_txn_id,
12329 null, decode(serialization_start_op,
12330 p_routing_operation, 1,
12331 0), 1)
12332 ************/
12333 /****bug 5444062 Replaced the sql below with a sql getting the values and logic in pl/sql for determining
12334 l_serialization_started
12335 SELECT decode(first_serial_txn_id,
12336 null, decode(serialization_start_op,
12337 null, 0,
12338 decode(serialization_start_op,
12339 p_routing_operation, 1,
12340 0)),
12341 1)
12342 INTO l_first_serial_txn_id
12343 FROM WSM_LOT_BASED_JOBS
12344 WHERE wip_entity_id = p_wip_entity_id;
12345 ******/
12346 SELECT first_serial_txn_id, serialization_start_op
12347 INTO l_first_serial_txn_id, l_serialization_start_op
12348 FROM WSM_LOT_BASED_JOBS
12349 WHERE wip_entity_id = p_wip_entity_id;
12350
12351 --serialization started
12352 IF (l_first_serial_txn_id IS NOT NULL) THEN
12353 l_serialization_started := 1;
12354 ELSE
12355 --job outside routing
12356 IF (p_routing_operation IS NULL) THEN
12357 l_serialization_started := 0;
12358 --assembly is serial controlled tracked and job is at last operation
12359 ELSIF (l_serialization_start_op IS NOT NULL) and (p_routing_operation = l_end_routing_operation) THEN
12360 l_serialization_started := 1;
12361 --job is at serialization op
12362 ELSIF (l_serialization_start_op = p_routing_operation) THEN
12363 l_serialization_started := 1;
12364 END IF;
12365 END IF;
12366 --end bug 5444062
12367
12368 IF (l_serialization_started = 0) OR (l_wip_scrap_enabled_flag = 2) THEN
12369 x_show_scrap_serials := 0;
12370 ELSE
12371 x_show_scrap_serials := 1;
12372 END IF;
12373
12374 x_show_serial_region := l_serialization_started;
12375
12376 l_stmt_num := 110;
12377 BEGIN
12378 SELECT 1
12379 INTO x_scrap_codes_defined
12380 FROM dual
12381 WHERE EXISTS(
12382 SELECT 'scrap codes exist'
12383 FROM WSM_OP_REASON_CODES
12384 WHERE wip_entity_id = p_wip_entity_id
12385 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12386 AND operation_seq_num = p_operation_seq_num
12387 AND code_type = 1
12388 );
12389 EXCEPTION
12390 WHEN no_data_found THEN
12391 x_scrap_codes_defined := 0;
12392 END;
12393
12394 l_stmt_num := 120;
12395 BEGIN
12396 SELECT 1
12397 INTO x_bonus_codes_defined
12398 FROM dual
12399 WHERE EXISTS(
12400 SELECT 'bonus codes exist'
12401 FROM WSM_OP_REASON_CODES
12402 WHERE wip_entity_id = p_wip_entity_id
12403 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12404 AND operation_seq_num = p_operation_seq_num
12405 AND code_type = 2
12406 );
12407 EXCEPTION
12408 WHEN no_data_found THEN
12409 x_bonus_codes_defined := 0;
12410 END;
12411
12412 IF l_bos_use_org_settings = 1 THEN
12413 x_multiple_res_usage_dates := l_wsm_mul_res_usage_dates;
12414 ELSE
12415 x_multiple_res_usage_dates := l_bos_mul_res_usage_dates;
12416 END IF;
12417 /********************
12418 IF l_wip_to_move_enabled_flag = 2 AND l_wsm_move_to_next_op = 1 THEN
12419 x_show_next_op_choice := 0;
12420 x_show_next_op := 1;
12421 x_show_next_op_by_default := 1;
12422 ELSE
12423 x_show_next_op_choice := 1;
12424 x_show_next_op := 1;
12425 IF (l_bos_use_org_settings = 1) AND (l_wsm_show_next_op_by_default = 1) THEN
12426 x_show_next_op_by_default := 1;
12427 ELSIF (l_bos_use_org_settings = 0) AND (l_bos_show_next_op_by_default = 1) THEN
12428 x_show_next_op_by_default := 1;
12429 ELSE
12430 x_show_next_op_by_default := 2;
12431 END IF;
12432 END IF;
12433 **********************/
12434 x_show_next_op_choice := 1;
12435 x_show_next_op := 1;
12436 x_show_next_op_by_default := 1;
12437
12438 IF (l_wip_to_move_enabled_flag = 2) THEN
12439 x_show_next_op_choice := 0;
12440 x_show_next_op := 1;
12441 x_show_next_op_by_default := 1;
12442 ELSE
12443 IF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 0) THEN
12444 x_show_next_op_choice := 1;
12445 IF (l_wsm_show_next_op_by_default = 1) THEN
12446 x_show_next_op := 1;
12447 x_show_next_op_by_default := 1;
12448 ELSE
12449 x_show_next_op := 0;
12450 x_show_next_op_by_default := 2;
12451 END IF;
12452 ELSIF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 1) THEN
12453 x_show_next_op_choice := 0;
12454 x_show_next_op_by_default := 2;
12455 x_show_next_op := 0;
12456 ELSIF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 2) THEN
12457 x_show_next_op_choice := 0;
12458 x_show_next_op_by_default := 1;
12459 x_show_next_op := 1;
12460 ELSIF (l_bos_use_org_settings <> 1) AND (l_bos_to_move_mandatory_flag = 1) THEN
12461 x_show_next_op_choice := 0;
12462 x_show_next_op_by_default := 2;
12463 x_show_next_op := 0;
12464 ELSIF (l_bos_use_org_settings <> 1) AND (l_bos_to_move_mandatory_flag <> 1) THEN
12465 x_show_next_op_choice := 1;
12466 IF (l_bos_show_next_op_by_default = 1) THEN
12467 x_show_next_op_by_default := 1;
12468 x_show_next_op := 1;
12469 ELSE
12470 x_show_next_op_by_default := 2;
12471 x_show_next_op := 0;
12472 END IF;
12473 END IF;
12474 END IF;
12475
12476 --bug 5531107 check if next operation links exist
12477 BEGIN
12478 SELECT 1
12479 INTO l_next_links_exist
12480 FROM dual
12481 WHERE EXISTS
12482 (SELECT 'next_links_exist'
12483 FROM wsm_copy_op_networks wcon
12484 WHERE wcon.wip_entity_id = p_wip_entity_id
12485 AND wcon.from_op_seq_num = p_routing_operation
12486 );
12487 EXCEPTION
12488 WHEN no_data_found THEN
12489 l_next_links_exist := 0;
12490 END;
12491
12492 --bug 5531107 Reset the values depending on the existence of next operation links
12493 IF (l_next_links_exist = 0) THEN
12494 IF (x_show_next_op_choice = 1) THEN
12495 x_show_next_op_choice := 0;
12496 END IF;
12497
12498 IF (x_show_next_op = 1) THEN
12499 x_show_next_op := 0;
12500 END IF;
12501
12502 IF (x_show_next_op_by_default = 1) THEN
12503 x_show_next_op_by_default := 2;
12504 END IF;
12505 END IF;
12506 --end bug 5531107
12507 x_show_lot_attrib := l_bos_show_lot_attrib;
12508
12509 l_stmt_num := 130;
12510 l_osfm_quality_txn_number := 23;
12511 x_quality_region := QA_TXN_GRP.qa_enabled(
12512 p_txn_number => l_osfm_quality_txn_number,
12513 p_org_id => p_organization_id
12514 );
12515 --!!hardcode
12516 -- x_quality_region := 'F';
12517
12518 IF (l_end_routing_operation = p_routing_operation) THEN
12519 x_transaction_type := WIP_CONSTANTS.COMP_TXN;
12520 x_show_next_op_choice := 0;
12521 x_show_next_op := 0;
12522 x_show_next_op_by_default := 2;
12523 ELSIF (p_routing_operation IS NULL) THEN
12524 x_transaction_type := WIP_CONSTANTS.MOVE_TXN;
12525 x_show_next_op_choice := 0;
12526 x_show_next_op := 0;
12527 x_show_next_op_by_default := 2;
12528 ELSE
12529 x_transaction_type := WIP_CONSTANTS.MOVE_TXN;
12530 END IF;
12531
12532 l_stmt_num := 140;
12533 IF x_employee_id IS NULL THEN
12534 SELECT FU.employee_id
12535 INTO x_employee_id
12536 FROM FND_USER FU
12537 WHERE FU.user_id = p_user_id;
12538 END IF;
12539
12540 l_stmt_num := 150;
12541 IF (x_employee_id is NOT NULL) THEN
12542 BEGIN
12543 SELECT DISTINCT(PPF.FULL_NAME) FULL_NAME
12544 INTO x_operator
12545 FROM PER_PEOPLE_F PPF
12546 WHERE PPF.person_id = x_employee_id;
12547 EXCEPTION
12548 WHEN no_data_found THEN
12549 x_operator := null;
12550 END;
12551 END IF;
12552
12553 FND_MSG_PUB.Count_And_Get
12554 ( p_count => x_msg_count ,
12555 p_data => x_msg_data
12556 );
12557
12558 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
12559 l_msg_tokens.delete;
12560 WSM_log_PVT.logMessage (
12561 p_module_name => l_module ,
12562 p_msg_text => 'End procedure getMoveOutPageProperties '
12563 ||';x_last_operation '
12564 ||x_last_operation
12565 ||';x_estimated_scrap_accounting '
12566 ||x_estimated_scrap_accounting
12567 ||';x_show_next_op_by_default '
12568 ||x_show_next_op_by_default
12569 ||';x_multiple_res_usage_dates '
12570 ||x_multiple_res_usage_dates
12571 ||';x_show_scrap_codes '
12572 ||x_show_scrap_codes
12573 ||';x_scrap_codes_defined '
12574 ||x_scrap_codes_defined
12575 ||';x_bonus_codes_defined '
12576 ||x_bonus_codes_defined
12577 ||';x_show_lot_attrib '
12578 ||x_show_lot_attrib
12579 ||';x_show_scrap_serials '
12580 ||x_show_scrap_serials
12581 ||';x_show_serial_region '
12582 ||x_show_serial_region
12583 ||';x_show_secondary_quantities '
12584 ||x_show_secondary_quantities
12585 ||';x_transaction_type '
12586 ||x_transaction_type
12587 ||';x_quality_region '
12588 ||x_quality_region
12589 ||';x_show_scrap_qty '
12590 ||x_show_scrap_qty
12591 ||';x_show_next_op_choice '
12592 ||x_show_next_op_choice
12593 ||';x_show_next_op '
12594 ||x_show_next_op
12595 ||';x_employee_id '
12596 ||x_employee_id
12597 ||';x_operator '
12598 ||x_operator
12599 ||';x_default_start_date '
12600 ||x_default_start_date
12601 ||';x_default_completion_date '
12602 ||x_default_completion_date
12603 ||';x_return_status '
12604 ||x_return_status
12605 ||';x_msg_count '
12606 ||x_msg_count
12607 ||';x_msg_data '
12608 ||x_msg_data,
12609 p_stmt_num => l_stmt_num ,
12610 p_msg_tokens => l_msg_tokens ,
12611 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
12612 p_run_log_level => l_log_level
12613 );
12614 END IF;
12615
12616 EXCEPTION
12617 WHEN FND_API.G_EXC_ERROR THEN
12618 x_return_status := G_RET_ERROR;
12619 FND_MSG_PUB.Count_And_Get
12620 ( p_count => x_msg_count ,
12621 p_data => x_msg_data
12622 );
12623
12624 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12625 x_return_status := G_RET_UNEXPECTED;
12626 FND_MSG_PUB.Count_And_Get
12627 ( p_count => x_msg_count ,
12628 p_data => x_msg_data
12629 );
12630
12631 WHEN OTHERS THEN
12632
12633 x_return_status := G_RET_UNEXPECTED;
12634
12635 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12636 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12637 THEN
12638 WSM_log_PVT.handle_others(
12639 p_module_name => l_module ,
12640 p_stmt_num => l_stmt_num ,
12641 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
12642 p_run_log_level => l_log_level
12643 );
12644 END IF;
12645
12646 FND_MSG_PUB.Count_And_Get
12647 ( p_count => x_msg_count ,
12648 p_data => x_msg_data
12649 );
12650
12651 END;
12652
12653 /****************************************************************************
12654 Called from Job Op page and Undo Move page to set the page properties
12655 ****************************************************************************/
12656
12657 Procedure getJobOpPageProperties(
12658 p_organization_id IN NUMBER
12659 , p_wip_entity_id IN NUMBER
12660 , p_operation_seq_num IN NUMBER
12661 , p_routing_operation IN NUMBER
12662 , p_responsibility_id IN NUMBER
12663 , p_standard_op_id IN NUMBER
12664 , p_current_step_type IN NUMBER
12665 , p_status_type IN NUMBER
12666 , x_show_move_in OUT NOCOPY NUMBER
12667 , x_show_move_out OUT NOCOPY NUMBER
12668 , x_show_move_to_next_op OUT NOCOPY NUMBER
12669 , x_show_serial_region OUT NOCOPY NUMBER
12670 , x_show_scrap_codes OUT NOCOPY NUMBER
12671 , x_show_bonus_codes OUT NOCOPY NUMBER
12672 , x_show_secondary_quantities OUT NOCOPY NUMBER
12673 , x_show_lot_attrib OUT NOCOPY NUMBER
12674 , x_return_status OUT NOCOPY VARCHAR2
12675 , x_msg_count OUT NOCOPY NUMBER
12676 , x_msg_data OUT NOCOPY VARCHAR2
12677 )
12678 IS
12679 l_stmt_num NUMBER := 0;
12680 l_serialization_started NUMBER;
12681 l_first_serial_txn_id NUMBER; --bug 5444062
12682 l_serialization_start_op NUMBER; --bug 5444062
12683 l_end_routing_operation NUMBER; --bug 5444062
12684 l_move_codemask NUMBER;
12685 l_current_job_op_seq_num NUMBER;
12686 -- Logging variables.....
12687 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12688 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12689 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.getJobOpPageProperties';
12690 l_param_tbl WSM_Log_PVT.param_tbl_type;
12691 x_error_count NUMBER;
12692 x_return_code NUMBER;
12693 x_error_msg VARCHAR2(4000);
12694 BEGIN
12695 l_stmt_num := 10;
12696 x_return_status := 'S';
12697 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
12698 l_msg_tokens.delete;
12699 WSM_log_PVT.logMessage (
12700 p_module_name => l_module ,
12701 p_msg_text => 'Begin getMoveOutPageProperties: '||
12702 'p_organization_id '||p_organization_id||
12703 '; p_wip_entity_id '||p_wip_entity_id||
12704 '; p_operation_seq_num '||p_operation_seq_num||
12705 '; p_routing_operation '||p_routing_operation||
12706 '; p_responsibility_id '||p_responsibility_id||
12707 '; p_standard_op_id '||p_standard_op_id||
12708 '; p_current_step_type '||p_current_step_type||
12709 '; p_status_type '||p_status_type,
12710 p_stmt_num => l_stmt_num ,
12711 p_msg_tokens => l_msg_tokens ,
12712 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
12713 p_run_log_level => l_log_level
12714 );
12715 END IF;
12716
12717 l_stmt_num := 40;
12718 /****bug 5444062 Replaced the sql below with a sql getting the values and logic in pl/sql for determining
12719 x_show_serial_region
12720 --bug 5236293 added the decode to check if p_routing_operation is null
12721 SELECT decode(first_serial_txn_id,
12722 null, decode(p_routing_operation,
12723 null, 0,
12724 decode(serialization_start_op,
12725 p_routing_operation, 1,
12726 0)
12727 ),
12728 1),
12729 current_job_op_seq_num
12730 INTO x_show_serial_region, l_current_job_op_seq_num
12731 FROM WSM_LOT_BASED_JOBS
12732 WHERE wip_entity_id = p_wip_entity_id;
12733 ******/
12734
12735 SELECT first_serial_txn_id, serialization_start_op, current_job_op_seq_num
12736 INTO l_first_serial_txn_id, l_serialization_start_op, l_current_job_op_seq_num
12737 FROM WSM_LOT_BASED_JOBS
12738 WHERE wip_entity_id = p_wip_entity_id;
12739
12740 x_show_serial_region := 0;
12741 --serialization started
12742 IF (l_first_serial_txn_id IS NOT NULL) THEN
12743 x_show_serial_region := 1;
12744 ELSE
12745 --job outside routing
12746 IF (p_routing_operation IS NULL) THEN
12747 x_show_serial_region := 0;
12748 --job is at serialization op
12749 ELSIF (l_serialization_start_op = p_routing_operation) THEN
12750 x_show_serial_region := 1;
12751 --assembly is serial controlled tracked and job is at last operation
12752 ELSIF (l_serialization_start_op IS NOT NULL) THEN
12753
12754 l_stmt_num := 40.1;
12755 SELECT operation_seq_num
12756 INTO l_end_routing_operation
12757 FROM WSM_COPY_OPERATIONS WCO
12758 WHERE WCO.wip_entity_id = p_wip_entity_id
12759 AND WCO.network_start_end = 'E';
12760
12761 IF (p_routing_operation = l_end_routing_operation) THEN
12762 x_show_serial_region := 1;
12763 END IF;
12764 END IF;
12765 END IF;
12766 --end bug 5444062
12767
12768 IF ((p_status_type = 3) AND (p_current_step_type IS NOT NULL) AND (l_current_job_op_seq_num = p_operation_seq_num)) THEN
12769 l_stmt_num := 20;
12770 l_move_codemask := WSM_MES_UTILITIES_PVT.move_txn_allowed(
12771 p_responsibility_id => fnd_global.resp_id,
12772 p_wip_entity_id => p_wip_entity_id,
12773 p_org_id => p_organization_id,
12774 p_job_op_seq_num => p_operation_seq_num,
12775 p_standard_op_id => p_standard_op_id,
12776 p_intraop_step => p_current_step_type,
12777 p_status_type => p_status_type
12778 );
12779 END IF;
12780
12781 l_stmt_num := 30;
12782 SELECT decode(bitand(l_move_codemask, 65536), 65536, 1, 0),
12783 decode(bitand(l_move_codemask, 131072), 131072, 1, 0),
12784 decode(bitand(l_move_codemask, 262144), 262144, 1, 0)
12785 INTO x_show_move_in, x_show_move_out, x_show_move_to_next_op
12786 FROM dual;
12787
12788 l_stmt_num := 50;
12789 BEGIN
12790 SELECT 1
12791 INTO x_show_scrap_codes
12792 FROM dual
12793 WHERE EXISTS(
12794 SELECT 'scrap codes exist'
12795 FROM WSM_OP_REASON_CODES
12796 WHERE wip_entity_id = p_wip_entity_id
12797 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12798 AND operation_seq_num = p_operation_seq_num
12799 AND code_type = 1
12800 );
12801 EXCEPTION
12802 WHEN no_data_found THEN
12803 x_show_scrap_codes := 0;
12804 END;
12805
12806 l_stmt_num := 60;
12807 BEGIN
12808 SELECT 1
12809 INTO x_show_bonus_codes
12810 FROM dual
12811 WHERE EXISTS(
12812 SELECT 'bonus codes exist'
12813 FROM WSM_OP_REASON_CODES
12814 WHERE wip_entity_id = p_wip_entity_id
12815 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12816 AND operation_seq_num = p_operation_seq_num
12817 AND code_type = 2
12818 );
12819 EXCEPTION
12820 WHEN no_data_found THEN
12821 x_show_bonus_codes := 0;
12822 END;
12823
12824 l_stmt_num := 70;
12825 BEGIN
12826 SELECT 1
12827 INTO x_show_secondary_quantities
12828 FROM dual
12829 WHERE EXISTS(
12830 SELECT 'secondary quantities exist'
12831 FROM WSM_OP_SECONDARY_QUANTITIES
12832 WHERE wip_entity_id = p_wip_entity_id
12833 AND operation_seq_num = p_operation_seq_num
12834
12835 );
12836 EXCEPTION
12837 WHEN no_data_found THEN
12838 x_show_secondary_quantities := 0;
12839 END;
12840
12841 l_stmt_num := 80;
12842 /*****bug 5192129 OSFMST1: LOT ATTRIBUTES TAB IS DISPLAYED EVEN WITH SHOW LOT ATTRIBUTES SET TO NO*****
12843 **show_lot_attrib is not applicable for job operation page - always set it to 1**
12844 IF (p_routing_operation IS NOT NULL) THEN
12845 SELECT nvl(BOS.show_lot_attrib, 0)
12846 INTO x_show_lot_attrib
12847 FROM BOM_OPERATION_SEQUENCES BOS, WIP_OPERATIONS WO
12848 WHERE WO.wip_entity_id = p_wip_entity_id
12849 AND WO.operation_seq_num = p_operation_seq_num
12850 AND BOS.operation_sequence_id = WO.operation_sequence_id;
12851 ELSE
12852 SELECT nvl(BSO.show_lot_attrib, 0)
12853 INTO x_show_lot_attrib
12854 FROM BOM_STANDARD_OPERATIONS BSO
12855 WHERE BSO.standard_operation_id = p_standard_op_id;
12856 END IF;
12857 ********************************************************************/
12858 x_show_lot_attrib := 1;
12859
12860 IF G_LOG_LEVEL_PROCEDURE >= l_log_level THEN
12861
12862 l_param_tbl.delete;
12863 l_param_tbl(1).paramName := 'x_show_move_in';
12864 l_param_tbl(1).paramValue := x_show_move_in;
12865 l_param_tbl(2).paramName := 'x_show_move_out';
12866 l_param_tbl(2).paramValue := x_show_move_out;
12867 l_param_tbl(3).paramName := 'x_show_move_to_next_op';
12868 l_param_tbl(3).paramValue := x_show_move_to_next_op;
12869 l_param_tbl(4).paramName := 'x_show_serial_region';
12870 l_param_tbl(4).paramValue := x_show_serial_region;
12871 l_param_tbl(5).paramName := 'x_show_scrap_codes';
12872 l_param_tbl(5).paramValue := x_show_scrap_codes;
12873 l_param_tbl(6).paramName := 'x_show_bonus_codes';
12874 l_param_tbl(6).paramValue := x_show_bonus_codes;
12875 l_param_tbl(7).paramName := 'x_show_secondary_quantities';
12876 l_param_tbl(7).paramValue := x_show_secondary_quantities;
12877 l_param_tbl(8).paramName := 'x_show_lot_attrib';
12878 l_param_tbl(8).paramValue := x_show_lot_attrib;
12879 l_param_tbl(9).paramName := 'x_return_status';
12880 l_param_tbl(9).paramValue := x_return_status;
12881 l_param_tbl(10).paramName := 'x_msg_count';
12882 l_param_tbl(10).paramValue := x_msg_count;
12883 l_param_tbl(11).paramName := 'x_msg_data';
12884 l_param_tbl(11).paramValue := x_msg_data;
12885 WSM_Log_PVT.logProcParams(
12886 p_module_name => l_module ,
12887 p_param_tbl => l_param_tbl,
12888 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE
12889 );
12890 END IF;
12891
12892
12893 FND_MSG_PUB.Count_And_Get
12894 ( p_count => x_msg_count ,
12895 p_data => x_msg_data
12896 );
12897
12898 EXCEPTION
12899 WHEN FND_API.G_EXC_ERROR THEN
12900 x_return_status := G_RET_ERROR;
12901 FND_MSG_PUB.Count_And_Get
12902 ( p_count => x_msg_count ,
12903 p_data => x_msg_data
12904 );
12905
12906
12907 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12908 x_return_status := G_RET_UNEXPECTED;
12909 FND_MSG_PUB.Count_And_Get
12910 ( p_count => x_msg_count ,
12911 p_data => x_msg_data
12912 );
12913
12914 WHEN OTHERS THEN
12915
12916 x_return_status := G_RET_UNEXPECTED;
12917
12918 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12919 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12920 THEN
12921 WSM_log_PVT.handle_others(
12922 p_module_name => l_module,
12923 p_stmt_num => l_stmt_num,
12924 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
12925 p_run_log_level => l_log_level
12926 );
12927 END IF;
12928
12929 FND_MSG_PUB.Count_And_Get
12930 ( p_count => x_msg_count ,
12931 p_data => x_msg_data
12932 );
12933
12934
12935 END;
12936
12937 /****************************************************************************
12938 Updates the WO.costed_quantity_completed column from Move form, interface and OA page
12939 ****************************************************************************/
12940 --mes
12941 Procedure update_costed_qty_compl(
12942 p_transaction_type NUMBER
12943 , p_job_fm_op_seq_num NUMBER
12944 , p_job_to_op_seq_num NUMBER
12945 , p_wip_entity_id NUMBER
12946 , p_fm_intraoperation_step_type NUMBER
12947 , p_to_intraoperation_step_type NUMBER
12948 , p_primary_move_qty NUMBER
12949 , p_primary_scrap_qty NUMBER
12950 , p_scrap_at_op NUMBER
12951 )
12952 IS
12953 l_costed_quantity_completed NUMBER := 0;
12954 l_fm_costed_quantity_completed NUMBER := 0;
12955 l_to_costed_quantity_completed NUMBER := 0;
12956 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12957 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12958 l_module VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.update_costed_qty_compl';
12959 l_stmt_num NUMBER := 0;
12960 BEGIN
12961 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
12962 l_msg_tokens.delete;
12963 WSM_log_PVT.logMessage (
12964 p_module_name => l_module,
12965 p_msg_text => 'Begin procedure update_costed_qty_compl'
12966 ||';p_transaction_type '
12967 ||p_transaction_type
12968 ||';p_job_fm_op_seq_num '
12969 ||p_job_fm_op_seq_num
12970 ||';p_job_to_op_seq_num '
12971 ||p_job_to_op_seq_num
12972 ||';p_wip_entity_id '
12973 ||p_wip_entity_id
12974 ||';p_fm_intraoperation_step_type '
12975 ||p_fm_intraoperation_step_type
12976 ||';p_to_intraoperation_step_type '
12977 ||p_to_intraoperation_step_type
12978 ||';p_primary_move_qty '
12979 ||p_primary_move_qty
12980 ||';p_primary_scrap_qty '
12981 ||p_primary_scrap_qty
12982 ||';p_scrap_at_op '
12983 ||p_scrap_at_op,
12984 p_stmt_num => l_stmt_num,
12985 p_msg_tokens => l_msg_tokens,
12986 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
12987 p_run_log_level => l_log_level
12988 );
12989 END IF;
12990
12991 IF (p_transaction_type IN (g_move_txn, g_comp_txn)) THEN
12992 IF (p_job_fm_op_seq_num <> p_job_to_op_seq_num) THEN
12993
12994 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
12995 AND (p_primary_scrap_qty = 0)) THEN
12996 l_fm_costed_quantity_completed := p_primary_move_qty;
12997 l_to_costed_quantity_completed := 0;
12998 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
12999 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13000 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13001 l_to_costed_quantity_completed := 0;
13002 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13003 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13004 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13005 l_to_costed_quantity_completed := p_primary_scrap_qty;
13006 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13007 AND (p_primary_scrap_qty = 0)) THEN
13008 l_fm_costed_quantity_completed := p_primary_move_qty;
13009 l_to_costed_quantity_completed := 0;
13010 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13011 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13012 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13013 l_to_costed_quantity_completed := 0;
13014 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13015 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13016 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13017 l_to_costed_quantity_completed := p_primary_scrap_qty;
13018 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13019 AND (p_primary_scrap_qty = 0)) THEN
13020 l_fm_costed_quantity_completed := p_primary_move_qty;
13021 l_to_costed_quantity_completed := p_primary_move_qty;
13022 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13023 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13024 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13025 l_to_costed_quantity_completed := p_primary_move_qty;
13026 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13027 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13028 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13029 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13030 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13031 AND (p_primary_scrap_qty = 0)) THEN
13032 l_fm_costed_quantity_completed := p_primary_move_qty;
13033 l_to_costed_quantity_completed := 0;
13034 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13035 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13036 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13037 l_to_costed_quantity_completed := 0;
13038 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13039 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13040 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13041 l_to_costed_quantity_completed := p_primary_scrap_qty;
13042 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13043 AND (p_primary_scrap_qty = 0)) THEN
13044 l_fm_costed_quantity_completed := p_primary_move_qty;
13045 l_to_costed_quantity_completed := 0;
13046 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13047 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13048 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13049 l_to_costed_quantity_completed := 0;
13050 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13051 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13052 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13053 l_to_costed_quantity_completed := p_primary_scrap_qty;
13054 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13055 AND (p_primary_scrap_qty = 0)) THEN
13056 l_fm_costed_quantity_completed := p_primary_move_qty;
13057 l_to_costed_quantity_completed := p_primary_move_qty;
13058 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13059 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13060 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13061 l_to_costed_quantity_completed := p_primary_move_qty;
13062 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13063 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13064 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13065 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13066 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13067 AND (p_primary_scrap_qty = 0)) THEN
13068 l_fm_costed_quantity_completed := 0;
13069 l_to_costed_quantity_completed := 0;
13070 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13071 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13072 l_fm_costed_quantity_completed := 0;
13073 l_to_costed_quantity_completed := 0;
13074 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13075 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13076 l_fm_costed_quantity_completed := 0;
13077 l_to_costed_quantity_completed := p_primary_scrap_qty;
13078 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13079 AND (p_primary_scrap_qty = 0)) THEN
13080 l_fm_costed_quantity_completed := 0;
13081 l_to_costed_quantity_completed := 0;
13082 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13083 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13084 l_fm_costed_quantity_completed := 0;
13085 l_to_costed_quantity_completed := 0;
13086 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13087 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13088 l_fm_costed_quantity_completed := 0;
13089 l_to_costed_quantity_completed := p_primary_scrap_qty;
13090 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13091 AND (p_primary_scrap_qty = 0)) THEN
13092 l_fm_costed_quantity_completed := 0;
13093 l_to_costed_quantity_completed := p_primary_move_qty;
13094 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13095 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13096 l_fm_costed_quantity_completed := 0;
13097 l_to_costed_quantity_completed := p_primary_move_qty;
13098 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13099 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13100 l_fm_costed_quantity_completed := 0;
13101 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13102 END IF;
13103
13104 IF (l_fm_costed_quantity_completed > 0) THEN
13105 UPDATE WIP_OPERATIONS
13106 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) +
13107 l_fm_costed_quantity_completed
13108 WHERE wip_entity_id = p_wip_entity_id
13109 AND operation_seq_num = p_job_fm_op_seq_num;
13110 END IF;
13111
13112 IF (l_to_costed_quantity_completed > 0) THEN
13113 UPDATE WIP_OPERATIONS
13114 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) +
13115 l_to_costed_quantity_completed
13116 WHERE wip_entity_id = p_wip_entity_id
13117 AND operation_seq_num = p_job_to_op_seq_num;
13118 END IF;
13119
13120 ELSE --(l_fm_op_seq_num <> l_job_to_op_seq_num)
13121 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13122 AND (p_primary_scrap_qty = 0)) THEN
13123 l_costed_quantity_completed := 0;
13124 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13125 AND (p_primary_scrap_qty > 0)) THEN
13126 l_costed_quantity_completed := p_primary_scrap_qty;
13127 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13128 AND (p_primary_scrap_qty = 0)) THEN
13129 l_costed_quantity_completed := p_primary_move_qty;
13130 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13131 AND (p_primary_scrap_qty > 0)) THEN
13132 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13133 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_scrap))
13134 THEN
13135 IF nvl(p_primary_move_qty, 0) > 0 THEN
13136 l_costed_quantity_completed := p_primary_move_qty;
13137 ELSE
13138 l_costed_quantity_completed := p_primary_scrap_qty;
13139 END IF;
13140 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13141 AND (p_primary_scrap_qty = 0)) THEN
13142 l_costed_quantity_completed := p_primary_move_qty;
13143 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13144 AND (p_primary_scrap_qty > 0)) THEN
13145 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13146 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_scrap))
13147 THEN
13148 IF nvl(p_primary_move_qty, 0) > 0 THEN
13149 l_costed_quantity_completed := p_primary_move_qty;
13150 ELSE
13151 l_costed_quantity_completed := p_primary_scrap_qty;
13152 END IF;
13153 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_scrap)) THEN
13154 l_costed_quantity_completed := 0;
13155 END IF;
13156
13157 IF (l_costed_quantity_completed > 0) THEN
13158 UPDATE WIP_OPERATIONS
13159 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) + l_costed_quantity_completed
13160 WHERE wip_entity_id = p_wip_entity_id
13161 AND operation_seq_num = p_job_fm_op_seq_num;
13162 END IF;
13163 END IF;
13164 ELSE --(l_transaction_type IN (g_move_txn, g_comp_txn))
13165 IF (p_job_fm_op_seq_num <> p_job_to_op_seq_num) THEN
13166
13167 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13168 AND (p_primary_scrap_qty = 0)) THEN
13169 l_to_costed_quantity_completed := p_primary_move_qty;
13170 l_fm_costed_quantity_completed := 0;
13171 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13172 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13173 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13174 l_fm_costed_quantity_completed := 0;
13175 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13176 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13177 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13178 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13179 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13180 AND (p_primary_scrap_qty = 0)) THEN
13181 l_to_costed_quantity_completed := p_primary_move_qty;
13182 l_fm_costed_quantity_completed := 0;
13183 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13184 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13185 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13186 l_fm_costed_quantity_completed := 0;
13187 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13188 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13189 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13190 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13191 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13192 AND (p_primary_scrap_qty = 0)) THEN
13193 l_to_costed_quantity_completed := 0;
13194 l_fm_costed_quantity_completed := 0;
13195 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13196 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13197 l_to_costed_quantity_completed := 0;
13198 l_fm_costed_quantity_completed := 0;
13199 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13200 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13201 l_to_costed_quantity_completed := 0;
13202 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13203 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13204 AND (p_primary_scrap_qty = 0)) THEN
13205 l_to_costed_quantity_completed := p_primary_move_qty;
13206 l_fm_costed_quantity_completed := 0;
13207 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13208 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13209 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13210 l_fm_costed_quantity_completed := 0;
13211 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13212 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13213 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13214 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13215 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13216 AND (p_primary_scrap_qty = 0)) THEN
13217 l_to_costed_quantity_completed := p_primary_move_qty;
13218 l_fm_costed_quantity_completed := 0;
13219 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13220 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13221 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13222 l_fm_costed_quantity_completed := 0;
13223 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13224 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13225 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13226 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13227 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13228 AND (p_primary_scrap_qty = 0)) THEN
13229 l_to_costed_quantity_completed := 0;
13230 l_fm_costed_quantity_completed := 0;
13231 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13232 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13233 l_to_costed_quantity_completed := 0;
13234 l_fm_costed_quantity_completed := 0;
13235 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13236 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13237 l_to_costed_quantity_completed := 0;
13238 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13239 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13240 AND (p_primary_scrap_qty = 0)) THEN
13241 l_to_costed_quantity_completed := p_primary_move_qty;
13242 l_fm_costed_quantity_completed := p_primary_move_qty;
13243 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13244 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13245 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13246 l_fm_costed_quantity_completed := p_primary_move_qty;
13247 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13248 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13249 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13250 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13251 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13252 AND (p_primary_scrap_qty = 0)) THEN
13253 l_to_costed_quantity_completed := p_primary_move_qty;
13254 l_fm_costed_quantity_completed := p_primary_move_qty;
13255 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13256 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13257 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13258 l_fm_costed_quantity_completed := p_primary_move_qty;
13259 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13260 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13261 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13262 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13263 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13264 AND (p_primary_scrap_qty = 0)) THEN
13265 l_to_costed_quantity_completed := 0;
13266 l_fm_costed_quantity_completed := p_primary_move_qty;
13267 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13268 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13269 l_to_costed_quantity_completed := 0;
13270 l_fm_costed_quantity_completed := p_primary_move_qty;
13271 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13272 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13273 l_to_costed_quantity_completed := 0;
13274 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13275 END IF;
13276
13277 IF (l_fm_costed_quantity_completed > 0) THEN
13278 UPDATE WIP_OPERATIONS
13279 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) -
13280 l_fm_costed_quantity_completed
13281 WHERE wip_entity_id = p_wip_entity_id
13282 AND operation_seq_num = p_job_fm_op_seq_num;
13283 END IF;
13284
13285 IF (l_to_costed_quantity_completed > 0) THEN
13286 UPDATE WIP_OPERATIONS
13287 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) -
13288 l_to_costed_quantity_completed
13289 WHERE wip_entity_id = p_wip_entity_id
13290 AND operation_seq_num = p_job_to_op_seq_num;
13291 END IF;
13292
13293 ELSE --(l_fm_op_seq_num <> l_job_to_op_seq_num)
13294 IF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13295 AND (p_primary_scrap_qty = 0)) THEN
13296 l_costed_quantity_completed := 0;
13297 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13298 AND (p_primary_scrap_qty > 0)) THEN
13299 l_costed_quantity_completed := p_primary_scrap_qty;
13300 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13301 AND (p_primary_scrap_qty = 0)) THEN
13302 l_costed_quantity_completed := p_primary_move_qty;
13303 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13304 AND (p_primary_scrap_qty > 0)) THEN
13305 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13306 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_queue))
13307 THEN
13308 IF nvl(p_primary_move_qty, 0) > 0 THEN
13309 l_costed_quantity_completed := p_primary_move_qty;
13310 ELSE
13311 l_costed_quantity_completed := p_primary_scrap_qty;
13312 END IF;
13313 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13314 AND (p_primary_scrap_qty = 0)) THEN
13315 l_costed_quantity_completed := p_primary_move_qty;
13316 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13317 AND (p_primary_scrap_qty > 0)) THEN
13318 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13319 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_run))
13320 THEN
13321 IF nvl(p_primary_move_qty, 0) > 0 THEN
13322 l_costed_quantity_completed := p_primary_move_qty;
13323 ELSE
13324 l_costed_quantity_completed := p_primary_scrap_qty;
13325 END IF;
13326 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_tomove)) THEN
13327 l_costed_quantity_completed := 0;
13328 END IF;
13329
13330 IF (l_costed_quantity_completed > 0) THEN
13331 UPDATE WIP_OPERATIONS
13332 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) - l_costed_quantity_completed
13333 WHERE wip_entity_id = p_wip_entity_id
13334 AND operation_seq_num = p_job_fm_op_seq_num;
13335 END IF;
13336 END IF;
13337 END IF; --(l_transaction_type IN (g_move_txn, g_comp_txn))
13338 END update_costed_qty_compl;
13339
13340 Function convert_uom(
13341 p_time_hours NUMBER, -- from_quantity
13342 p_to_uom VARCHAR2 -- to_unit
13343 ) RETURN NUMBER IS
13344 l_uom_rate NUMBER;
13345 l_hrUOM VARCHAR2(3) := fnd_profile.value('BOM:HOUR_UOM_CODE');
13346 l_hrUOM_class VARCHAR2(10);
13347 l_resUOM_class VARCHAR2(10);
13348 BEGIN
13349
13350 select uom_class
13351 into l_hrUOM_class
13352 from mtl_units_of_measure
13353 where uom_code = l_hrUOM;
13354
13355 select uom_class
13356 into l_resUOM_class
13357 from mtl_units_of_measure
13358 where uom_code = p_to_uom;
13359
13360 IF (l_hrUOM_class = l_resUOM_class) THEN
13361 l_uom_rate := inv_convert.inv_um_convert(
13362 0, -- item_id
13363 NULL, -- precision
13364 p_time_hours, -- from_quantity
13365 l_hrUOM, -- from_unit
13366 p_to_uom, -- to_unit
13367 NULL, -- from_name
13368 NULL); -- to_name
13369 ELSE
13370 l_uom_rate := NULL;
13371 END IF;
13372
13373 RETURN l_uom_rate;
13374
13375 EXCEPTION
13376 WHEN OTHERS THEN
13377 RETURN NULL;
13378 END convert_uom;
13379 --mes end
13380
13381 END WSMPLBMI;
13382