[Home] [Help]
PACKAGE BODY: APPS.WSMPLBMI
Source
1 PACKAGE BODY WSMPLBMI AS
2 /* $Header: WSMLBMIB.pls 120.97.12010000.3 2009/12/23 12:02:50 sisankar 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 /* Bug 8835930 */
8775 IF (( (l_converted_scrap_qty>0) OR (l_converted_scrap_qty=0 and l_txn_qty >0)) AND (l_transaction_type IN (3, 4)))THEN
8776 l_converted_scrap_qty := -1 * l_converted_scrap_qty;
8777 IF (l_scrap_at_operation_flag = 1) THEN
8778 l_wro_op_seq_num := l_to_op_seq_num;
8779 ELSE
8780 l_wro_op_seq_num := l_fm_op_seq_num;
8781 END IF;
8782 /* Bug 8835930 */
8783 ELSIF (( (l_converted_scrap_qty>0) OR (l_converted_scrap_qty=0 and l_txn_qty >0)) AND (l_transaction_type IN (1, 2)))THEN
8784 IF (l_scrap_at_operation_flag = 1) THEN
8785 l_wro_op_seq_num := l_fm_op_seq_num;
8786 ELSE
8787 l_wro_op_seq_num := l_to_op_seq_num;
8788 END IF;
8789 END IF;
8790
8791
8792 l_stmt_num := 230;
8793 SELECT nvl(include_component_yield, 1)
8794 INTO l_wip_include_comp_yield
8795 FROM WIP_PARAMETERS
8796 WHERE organization_id = l_organization_id;
8797
8798 --LBM enh: Modified the expression for quantity_relieved
8799 UPDATE wip_requirement_operations wro
8800 SET QUANTITY_RELIEVED = NVL(wro.QUANTITY_RELIEVED, 0) +
8801 decode(l_converted_scrap_qty,
8802 0, decode(wro.basis_type, 2, 1, l_txn_qty),
8803 decode(wro.basis_type, 2, 1, l_converted_scrap_qty)) * decode(l_wip_include_comp_yield,
8804 2, wro.quantity_per_assembly,
8805 (wro.quantity_per_assembly / NVL(wro.component_yield_factor,1)))
8806 WHERE wro.wip_entity_id = l_wip_entity_id
8807 AND wro.organization_id = l_organization_id
8808 AND wro.operation_seq_num <= l_wro_op_seq_num
8809 -- since scrap can be done only at curr op
8810 AND wro.quantity_per_assembly <> 0
8811 AND wro.wip_supply_type <> 6
8812 AND wro.wip_supply_type <> 4
8813 AND wro.wip_supply_type <> 5
8814 AND NOT EXISTS
8815 (SELECT 1
8816 FROM wip_operations wo
8817 WHERE wo.organization_id = wro.organization_id
8818 AND wo.wip_entity_id = wro.wip_entity_id
8819 AND wo.operation_seq_num = wro.operation_seq_num
8820 AND wo.count_point_type = 3);
8821
8822 IF (g_mrp_debug='Y') THEN
8823 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') :
8824 Updated '||SQL%ROWCOUNT||' rows in WRO');
8825 END IF;
8826
8827 END IF;
8828 -- End additions for Costing for WLTEnh
8829 --MES
8830 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
8831 'jump oa page', 'undo oa page' )) THEN
8832 update_int_grp_id(x_error_code,
8833 x_error_msg,
8834 l_header_id,
8835 l_transaction_id);
8836 IF (x_err_code <> 0) THEN
8837 raise e_proc_exception;
8838 END IF;
8839 ELSE
8840 update_int_grp_id(x_error_code,
8841 x_error_msg,
8842 l_header_id,
8843 l_wmti_group_id);
8844 IF (x_err_code <> 0) THEN
8845 raise e_proc_exception;
8846 END IF;
8847 END IF;
8848
8849 l_stmt_num := 250;
8850 --move enh 115.135 changed WIP_CONSTANTS.MOVE_TXN to global variable after perf check
8851 IF ((l_transaction_type = g_move_txn) AND (l_fm_op_seq_num <> l_max_op_seq)
8852 and (g_aps_wps_profile='Y')) THEN
8853 IF (l_scrap_at_operation_flag = 2) THEN
8854 --bug 3385113 add nvl
8855 l_new_op_txn_qty := nvl(l_primary_quantity, 0) + nvl(l_converted_scrap_qty, 0);
8856 ELSE
8857 l_new_op_txn_qty := l_primary_quantity;
8858 END IF;
8859 l_stmt_num := 250.1;
8860 WSMPOPRN.call_infinite_scheduler(
8861 x_error_code => x_return_code,
8862 x_error_msg => l_error_msg,
8863 p_jump_flag => l_jump_flag,
8864 p_wip_entity_id => l_wip_entity_id,
8865 p_org_id => l_organization_id,
8866 p_to_op_seq_id => l_to_op_seq_id,
8867 p_fm_job_op_seq_num => l_fm_op_seq_num,
8868 p_to_job_op_seq_num => l_max_op_seq,
8869 p_scheQuantity => l_new_op_txn_qty);
8870 IF (x_return_code = 0) THEN
8871 IF (g_mrp_debug='Y') THEN
8872 FND_FILE.PUT_LINE(FND_FILE.LOG, 'WSMPOPRN.call_infinite_scheduler returned success');
8873 END IF;
8874 ELSE
8875 l_error_msg := x_error_msg;
8876 FND_FILE.PUT_LINE(FND_FILE.LOG,'WSMPLBMI.custom_validation' ||'(stmt_num='||l_stmt_num||') : '||substrb(l_error_msg, 1,4000));
8877 ROLLBACK TO validation;
8878 error_handler(p_header_id => l_header_id
8879 , p_transaction_id => l_transaction_id
8880 , p_error_msg => l_error_msg
8881 , x_error_code => x_err_code
8882 , x_error_msg => x_err_msg);
8883 IF (x_err_code <> 0) THEN
8884 raise e_proc_exception;
8885 END IF;
8886 GOTO inner_loop; /* go to get next entry */
8887 END IF;
8888 END IF;
8889
8890
8891 --MES
8892 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
8893 'jump oa page', 'undo oa page' )) THEN
8894 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8895 l_msg_tokens.delete;
8896 WSM_log_PVT.logMessage (
8897 p_module_name => l_module ,
8898 p_msg_text => 'Begin MES processing'||
8899 ';l_converted_scrap_qty '||
8900 l_converted_scrap_qty||
8901 ';l_primary_quantity '||
8902 l_primary_quantity||
8903 ';l_to_intraoperation_step_type '||
8904 l_to_intraoperation_step_type||
8905 ';l_fm_intraoperation_step_type '||
8906 l_fm_intraoperation_step_type,
8907 p_stmt_num => l_stmt_num ,
8908 p_msg_tokens => l_msg_tokens ,
8909 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8910 p_run_log_level => l_log_level
8911 );
8912 END IF;
8913
8914 --!! get l_mtl_txn_profile from inv profiles
8915 --MTL_TRANS_PROC 1 online, 2 immediate concurrent, 3 background, 4 form level
8916
8917 l_mtl_txn_profile := FND_PROFILE.value('TRANSACTION_PROCESS_MODE');
8918
8919 IF (l_mtl_txn_profile = WIP_CONSTANTS.FORM_LEVEL) THEN
8920 --l_mtl_txn_profile := FND_PROFILE.value('WIP_MOVE_TRANSACTION');
8921 l_mtl_txn_profile := FND_PROFILE.value('WIP_SHOP_FLOOR_MTL_TRANSACTION');
8922 END IF;
8923
8924 -- ST : Serial MES Fix : Start
8925 -- Have to store the attributes before invoking the Wip processor...
8926 -- Temporarily store the Serial Attributes of serial numbers from MSN and
8927 -- present in WMTI...(use the txn IDs) for completion and assembly return txns..
8928 DECLARE
8929 l_return_status VARCHAR2(1);
8930 l_error_msg VARCHAR2(2000);
8931 l_error_count NUMBER;
8932
8933 BEGIN
8934 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8935 l_msg_tokens.delete;
8936 WSM_log_PVT.logMessage ( p_module_name => l_module ,
8937 p_msg_text => 'B4 calling WSM_Serial_support_PVT.Insert_MOVE_attr',
8938 p_stmt_num => l_stmt_num ,
8939 p_msg_tokens => l_msg_tokens ,
8940 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8941 p_run_log_level => l_log_level
8942 );
8943 END IF;
8944
8945 l_stmt_num := 253.13;
8946 WSM_Serial_support_PVT.Insert_MOVE_attr ( p_group_id => null ,
8947 p_move_txn_id => l_transaction_id ,
8948 p_scrap_txn_id => l_scrap_txn_id ,
8949 x_return_status => l_return_status ,
8950 x_error_count => l_error_msg ,
8951 x_error_msg => l_error_count
8952 );
8953
8954 if l_return_status = FND_API.G_RET_STS_SUCCESS then
8955 IF (l_debug='Y') THEN
8956 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned Success');
8957 END IF;
8958
8959 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8960 l_msg_tokens.delete;
8961 WSM_log_PVT.logMessage (p_module_name => l_module ,
8962 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned successfully',
8963 p_stmt_num => l_stmt_num ,
8964 p_msg_tokens => l_msg_tokens ,
8965 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8966 p_run_log_level => l_log_level
8967 );
8968 END IF;
8969 ELSE
8970 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
8971 l_msg_tokens.delete;
8972 WSM_log_PVT.logMessage ( p_module_name => l_module ,
8973 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned error',
8974 p_stmt_num => l_stmt_num ,
8975 p_msg_tokens => l_msg_tokens ,
8976 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
8977 p_run_log_level => l_log_level
8978 );
8979 END IF;
8980 IF (l_error_count = 1) THEN
8981 fnd_file.put_line(fnd_file.log, l_error_msg);
8982 ELSIF (l_error_count > 1) THEN
8983 FOR i IN 1..l_error_count LOOP
8984 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
8985 p_encoded => FND_API.G_FALSE
8986 );
8987 fnd_file.put_line(fnd_file.log, l_error_msg);
8988 END LOOP;
8989 ELSE
8990 l_error_msg := 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure';
8991 END IF;
8992
8993 IF (l_debug='Y') THEN
8994 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure');
8995 END IF;
8996 -- This call is supposed to not return any error...
8997 raise e_proc_exception;
8998 END IF;
8999 END;
9000 -- ST : Serial MES Fix : end
9001 -- ST : Serial Support Project --
9002
9003 IF (l_scrap_qty > 0) THEN
9004 l_stmt_num := 251;
9005 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9006 l_msg_tokens.delete;
9007 WSM_log_PVT.logMessage (
9008 p_module_name => l_module ,
9009 p_msg_text => 'Calling wip move api for scrap qty',
9010 p_stmt_num => l_stmt_num ,
9011 p_msg_tokens => l_msg_tokens ,
9012 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9013 p_run_log_level => l_log_level
9014 );
9015 END IF;
9016
9017 --bug 5446252 since l_scrap_txn_id is not populated if l_primary_quantity = 0
9018 IF (l_primary_quantity > 0) THEN
9019 l_mes_scrap_txn_id := l_scrap_txn_id;
9020 ELSE
9021 l_mes_scrap_txn_id := l_transaction_id;
9022 END IF;
9023 --end bug 5446252
9024
9025 --bug 5446252 replace l_scrap_txn_id with l_mes_scrap_txn_id
9026 wip_movProc_grp.processInterface(
9027 p_movTxnID => l_mes_scrap_txn_id,
9028 p_procPhase => WIP_CONSTANTS.MOVE_PROC,
9029 p_txnHdrID => p_mtl_txn_hdr_id,
9030 p_mtlMode => l_mtl_txn_profile,
9031 p_cplTxnID => null,
9032 p_commit => null,
9033 x_returnStatus => l_return_status,
9034 x_errorMsg => l_error_msg);
9035
9036 IF(l_return_status <> 'S')THEN
9037 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
9038 ROLLBACK TO validation;
9039 error_handler(p_header_id => l_header_id
9040 , p_transaction_id => l_transaction_id
9041 , p_error_msg => l_error_msg
9042 , x_error_code => x_err_code
9043 , x_error_msg => x_error_msg);
9044 x_error_msg := l_error_msg;
9045 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9046 l_msg_tokens.delete;
9047 WSM_log_PVT.logMessage (
9048 p_module_name => l_module,
9049 p_msg_text => 'wip_movProc_grp.processInterface for scrap txn returned error: '||l_error_msg,
9050 p_stmt_num => l_stmt_num,
9051 p_msg_tokens => l_msg_tokens,
9052 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9053 p_run_log_level => l_log_level
9054 );
9055 END IF;
9056 raise e_proc_exception;
9057 ELSIF (l_return_status = 'S') THEN
9058 x_wip_move_api_sucess_msg := fnd_msg_pub.get;
9059 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9060 l_msg_tokens.delete;
9061 WSM_log_PVT.logMessage (
9062 p_module_name => l_module,
9063 p_msg_text => 'wip_movProc_grp.processInterface for scrap txn returned success: ',
9064 p_stmt_num => l_stmt_num,
9065 p_msg_tokens => l_msg_tokens,
9066 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9067 p_run_log_level => l_log_level
9068 );
9069 END IF;
9070 END IF;
9071 END IF;
9072
9073 IF (l_transaction_type = g_comp_txn) THEN
9074 SELECT mtl_material_transactions_s.nextval
9075 INTO l_cpl_txn_id
9076 FROM dual;
9077 END IF;
9078
9079 IF ((l_primary_quantity > 0) and (l_to_intraoperation_step_type <> WIP_CONSTANTS.SCRAP)
9080 and (l_fm_intraoperation_step_type <> WIP_CONSTANTS.SCRAP)) THEN
9081 l_stmt_num := 252;
9082 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9083 l_msg_tokens.delete;
9084 WSM_log_PVT.logMessage (
9085 p_module_name => l_module ,
9086 p_msg_text => 'Calling wip move api for move qty',
9087 p_stmt_num => l_stmt_num ,
9088 p_msg_tokens => l_msg_tokens ,
9089 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9090 p_run_log_level => l_log_level
9091 );
9092 END IF;
9093
9094 wip_movProc_grp.processInterface(
9095 p_movTxnID => l_transaction_id,
9096 p_procPhase => WIP_CONSTANTS.MOVE_PROC,
9097 p_txnHdrID => p_mtl_txn_hdr_id,
9098 p_mtlMode => l_mtl_txn_profile,
9099 p_cplTxnID => l_cpl_txn_id,
9100 p_commit => null,
9101 x_returnStatus => l_return_status,
9102 x_errorMsg => l_error_msg);
9103
9104 IF (l_return_status <> 'S') THEN
9105 FND_FILE.PUT_LINE(FND_FILE.LOG, substrb('WSMPLBMI.MoveTransactions' ||'(stmt_num='||l_stmt_num||') : '||l_error_msg, 1,4000));
9106 ROLLBACK TO validation;
9107 error_handler(p_header_id => l_header_id
9108 , p_transaction_id => l_transaction_id
9109 , p_error_msg => l_error_msg
9110 , x_error_code => x_err_code
9111 , x_error_msg => x_error_msg);
9112 x_error_msg := l_error_msg;
9113 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
9114 l_msg_tokens.delete;
9115 WSM_log_PVT.logMessage (
9116 p_module_name => l_module,
9117 p_msg_text => 'wip_movProc_grp.processInterface for move txn returned error: '||l_error_msg,
9118 p_stmt_num => l_stmt_num,
9119 p_msg_tokens => l_msg_tokens,
9120 p_fnd_log_level => G_LOG_LEVEL_ERROR,
9121 p_run_log_level => l_log_level
9122 );
9123 END IF;
9124 raise e_proc_exception;
9125 END IF;
9126 --l_mtl_txn_profile IN (WIP_CONSTANTS.BACKGROUND,
9127 -- WIP_CONSTANTS.IMMED_CONC)
9128
9129 x_wip_move_api_sucess_msg := fnd_msg_pub.get;
9130 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9131 IF (l_return_status = 'S') THEN
9132 l_msg_tokens.delete;
9133 WSM_log_PVT.logMessage (
9134 p_module_name => l_module,
9135 p_msg_text => 'wip_movProc_grp.processInterface for move txn returned success: '||x_wip_move_api_sucess_msg,
9136 p_stmt_num => l_stmt_num,
9137 p_msg_tokens => l_msg_tokens,
9138 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9139 p_run_log_level => l_log_level
9140 );
9141 END IF;
9142 END IF;
9143 END IF;
9144
9145 --bug 5210799 Update quantity_completed to null if jump from queue
9146 UPDATE (
9147 SELECT quantity_completed
9148 FROM WIP_OPERATIONS
9149 WHERE wip_entity_id = l_wip_entity_id
9150 AND operation_seq_num = l_fm_op_seq_num
9151 AND skip_flag = 1
9152 )
9153 SET quantity_completed = 0;
9154 --end bug 5210799
9155
9156 IF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9157 l_stmt_num := 253.1;
9158 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9159 l_msg_tokens.delete;
9160 WSM_log_PVT.logMessage (
9161 p_module_name => l_module ,
9162 p_msg_text => 'Begin inserting MES data',
9163 p_stmt_num => l_stmt_num ,
9164 p_msg_tokens => l_msg_tokens ,
9165 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9166 p_run_log_level => l_log_level
9167 );
9168 END IF;
9169 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9170 AND (p_sec_uom_code_tbls(l_header_id).count > 0)) THEN
9171
9172 l_stmt_num := 253.2;
9173 forall i in p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last
9174 update wsm_op_secondary_quantities
9175 set MOVE_OUT_QUANTITY = p_sec_move_out_qty_tbls(l_header_id)(i),
9176 LAST_UPDATE_DATE = sysdate,
9177 LAST_UPDATED_BY = g_user_id
9178 where wip_entity_id = l_wip_entity_id
9179 and operation_seq_num = l_fm_op_seq_num
9180 and uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9181
9182 l_stmt_num := 253.21;
9183 forall i in p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last
9184 update wsm_job_secondary_quantities
9185 set CURRENT_QUANTITY = p_sec_move_out_qty_tbls(l_header_id)(i),
9186 LAST_UPDATE_DATE = sysdate,
9187 LAST_UPDATED_BY = g_user_id
9188 where wip_entity_id = l_wip_entity_id
9189 and uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9190
9191 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9192 l_msg_tokens.delete;
9193 WSM_log_PVT.logMessage (
9194 p_module_name => l_module,
9195 p_msg_text => 'Updated secondary quantities successfully',
9196 p_stmt_num => l_stmt_num,
9197 p_msg_tokens => l_msg_tokens,
9198 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9199 p_run_log_level => l_log_level
9200 );
9201 END IF;
9202 END IF;
9203
9204 l_stmt_num := 253.3;
9205 IF ((p_scrap_codes_tbls IS NOT NULL) AND (p_scrap_codes_tbls.exists(l_header_id))
9206 AND (p_scrap_codes_tbls(l_header_id).count > 0)) THEN
9207
9208 l_stmt_num := 253.4;
9209 forall i in p_scrap_codes_tbls(l_header_id).first..p_scrap_codes_tbls(l_header_id).last
9210 update wsm_op_reason_codes
9211 set QUANTITY = p_scrap_code_qty_tbls(l_header_id)(i),
9212 LAST_UPDATE_DATE = sysdate,
9213 LAST_UPDATED_BY = g_user_id,
9214 LAST_UPDATED_LOGIN = g_login_id
9215 where wip_entity_id = l_wip_entity_id
9216 and operation_seq_num = l_fm_op_seq_num
9217 and CODE_TYPE = 1
9218 and REASON_CODE = p_scrap_codes_tbls(l_header_id)(i);
9219
9220 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9221 l_msg_tokens.delete;
9222 WSM_log_PVT.logMessage (
9223 p_module_name => l_module,
9224 p_msg_text => 'Updated scrap codes successfully',
9225 p_stmt_num => l_stmt_num,
9226 p_msg_tokens => l_msg_tokens,
9227 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9228 p_run_log_level => l_log_level
9229 );
9230 END IF;
9231 END IF;
9232
9233 l_stmt_num := 253.5;
9234 IF ((p_bonus_codes_tbls IS NOT NULL) AND (p_bonus_codes_tbls.exists(l_header_id))
9235 AND (p_bonus_codes_tbls(l_header_id).count > 0)) THEN
9236 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9237 FOR i in p_bonus_codes_tbls(l_header_id).first..p_bonus_codes_tbls(l_header_id).last
9238 LOOP
9239 l_msg_tokens.delete;
9240 WSM_log_PVT.logMessage (
9241 p_module_name => l_module,
9242 p_msg_text => 'i '||i||'; bonus code '||
9243 p_bonus_codes_tbls(l_header_id)(i)
9244 ||'; bonus code qty '
9245 ||p_bonus_code_qty_tbls(l_header_id)(i),
9246 p_stmt_num => l_stmt_num,
9247 p_msg_tokens => l_msg_tokens,
9248 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9249 p_run_log_level => l_log_level
9250 );
9251 END LOOP;
9252 END IF;
9253 l_stmt_num := 253.6;
9254 forall i in p_bonus_codes_tbls(l_header_id).first..p_bonus_codes_tbls(l_header_id).last
9255 update wsm_op_reason_codes
9256 set QUANTITY = p_bonus_code_qty_tbls(l_header_id)(i),
9257 LAST_UPDATE_DATE = sysdate,
9258 LAST_UPDATED_BY = g_user_id,
9259 LAST_UPDATED_LOGIN = g_login_id
9260 where wip_entity_id = l_wip_entity_id
9261 and operation_seq_num = l_fm_op_seq_num
9262 and CODE_TYPE = 2
9263 and REASON_CODE = p_bonus_codes_tbls(l_header_id)(i);
9264
9265 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9266 l_msg_tokens.delete;
9267 WSM_log_PVT.logMessage (
9268 p_module_name => l_module,
9269 p_msg_text => 'Updated bonus codes successfully',
9270 p_stmt_num => l_stmt_num,
9271 p_msg_tokens => l_msg_tokens,
9272 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9273 p_run_log_level => l_log_level
9274 );
9275 END IF;
9276 END IF;
9277 END IF;
9278
9279 IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page')) THEN
9280 IF (nvl(p_source_code, 'interface') = 'move in oa page') THEN
9281 l_stmt_num := 253.6;
9282 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
9283 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
9284 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9285 FOR i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last
9286 LOOP
9287 l_msg_tokens.delete;
9288 WSM_log_PVT.logMessage (
9289 p_module_name => l_module,
9290 p_msg_text => 'i '||i||'; RESOURCE_ID '||
9291 p_jobop_resource_usages_tbls(l_header_id)(i).RESOURCE_ID
9292 ||'; INSTANCE_ID '
9293 ||p_jobop_resource_usages_tbls(l_header_id)(i).INSTANCE_ID
9294 ||'; SERIAL_NUMBER '
9295 ||p_jobop_resource_usages_tbls(l_header_id)(i).SERIAL_NUMBER,
9296 p_stmt_num => l_stmt_num,
9297 p_msg_tokens => l_msg_tokens,
9298 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9299 p_run_log_level => l_log_level
9300 );
9301 END LOOP;
9302 END IF;
9303 l_stmt_num := 253.7;
9304 DECLARE
9305 -- create an exception handler for ORA-24381
9306 errors NUMBER;
9307 dml_errors EXCEPTION;
9308 PRAGMA EXCEPTION_INIT(dml_errors, -24381);
9309 BEGIN
9310 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9311 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9312 -- If any errors occurred during the FORALL SAVE EXCEPTIONS,
9313 -- a single exception is raised when the statement completes.
9314
9315 EXCEPTION
9316 WHEN dml_errors THEN -- Now we figure out what failed and why.
9317 errors := SQL%BULK_EXCEPTIONS.COUNT;
9318 FOR i IN 1..errors LOOP
9319 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
9320 l_msg_tokens.delete;
9321 WSM_log_PVT.logMessage (
9322 p_module_name => l_module,
9323 p_msg_text => 'Number of statements that failed: ' || errors||'Error #' || i || ' occurred during '||
9324 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX,
9325 p_stmt_num => l_stmt_num,
9326 p_msg_tokens => l_msg_tokens,
9327 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9328 p_run_log_level => l_log_level
9329 );
9330
9331 WSM_log_PVT.logMessage (
9332 p_module_name => l_module,
9333 p_msg_text => 'Error message is ' ||
9334 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE),
9335 p_stmt_num => l_stmt_num,
9336 p_msg_tokens => l_msg_tokens,
9337 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9338 p_run_log_level => l_log_level
9339 );
9340 END IF;
9341
9342 END LOOP;
9343 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9344 END;
9345 /*
9346 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9347 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9348 */
9349 DECLARE
9350 cursor C_WOR is
9351 select resource_id
9352 from wip_operation_resources wor
9353 where wor.wip_entity_id = l_wip_entity_id
9354 and wor.operation_seq_num = l_fm_op_seq_num;
9355
9356 Type t_wor_resource_id is table of wip_operation_resources.resource_id%TYPE index by binary_integer;
9357 l_wor_resource_id t_wor_resource_id;
9358 BEGIN
9359 OPEN C_WOR;
9360 FETCH C_WOR BULK COLLECT INTO l_wor_resource_id;
9361 CLOSE C_WOR;
9362
9363 FORALL i in l_wor_resource_id.FIRST..l_wor_resource_id.LAST
9364 UPDATE WIP_OPERATION_RESOURCES
9365 SET actual_start_date =
9366 (SELECT min(start_date)
9367 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9368 WHERE wrat.wip_entity_id = l_wip_entity_id
9369 AND wrat.operation_seq_num = l_fm_op_seq_num
9370 AND wrat.resource_id = l_wor_resource_id(i)),
9371 projected_completion_date =
9372 (SELECT max(projected_completion_date)
9373 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9374 WHERE wrat.wip_entity_id = l_wip_entity_id
9375 AND wrat.operation_seq_num = l_fm_op_seq_num
9376 AND wrat.resource_id = l_wor_resource_id(i)),
9377 LAST_UPDATE_DATE = sysdate,
9378 LAST_UPDATED_BY = g_user_id
9379 WHERE wip_entity_id = l_wip_entity_id
9380 AND operation_seq_num = l_fm_op_seq_num
9381 AND resource_id = l_wor_resource_id(i);
9382
9383 END;
9384
9385 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9386 l_msg_tokens.delete;
9387 WSM_log_PVT.logMessage (
9388 p_module_name => l_module,
9389 p_msg_text => 'Updated resource usage successfully',
9390 p_stmt_num => l_stmt_num,
9391 p_msg_tokens => l_msg_tokens,
9392 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9393 p_run_log_level => l_log_level
9394 );
9395 END IF;
9396
9397 END IF;
9398
9399 l_stmt_num := 253.6121;
9400 UPDATE WIP_OPERATIONS
9401 SET actual_start_date = p_operation_start_date,
9402 projected_completion_date = p_expected_completion_date,
9403 employee_id = p_employee_id,
9404 wsm_bonus_quantity = p_bonus_quantity,
9405 LAST_UPDATE_DATE = sysdate,
9406 LAST_UPDATED_BY = g_user_id
9407 WHERE wip_entity_id = l_wip_entity_id
9408 AND operation_seq_num = l_fm_op_seq_num;
9409
9410 ELSIF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9411 l_stmt_num := 253.6;
9412 IF (p_jobop_resource_usages_tbls IS NOT NULL) AND p_jobop_resource_usages_tbls.exists(l_header_id)
9413 AND (p_jobop_resource_usages_tbls(l_header_id).count > 0)THEN
9414 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9415 l_msg_tokens.delete;
9416 WSM_log_PVT.logMessage (
9417 p_module_name => l_module,
9418 p_msg_text => 'Begin inserting resource usage'
9419 ||'; l_wip_entity_id: '
9420 ||l_wip_entity_id
9421 ||'; l_fm_op_seq_num: '
9422 ||l_fm_op_seq_num,
9423 p_stmt_num => l_stmt_num,
9424 p_msg_tokens => l_msg_tokens,
9425 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9426 p_run_log_level => l_log_level
9427 );
9428 END IF;
9429
9430 l_stmt_num := 253.61;
9431 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9432 WHERE wip_entity_id = l_wip_entity_id
9433 AND operation_seq_num = l_fm_op_seq_num;
9434
9435 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9436 FOR i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last
9437 LOOP
9438 l_msg_tokens.delete;
9439 WSM_log_PVT.logMessage (
9440 p_module_name => l_module,
9441 p_msg_text => 'i '||i||'; RESOURCE_ID '||
9442 p_jobop_resource_usages_tbls(l_header_id)(i).RESOURCE_ID
9443 ||'; INSTANCE_ID '
9444 ||p_jobop_resource_usages_tbls(l_header_id)(i).INSTANCE_ID
9445 ||'; SERIAL_NUMBER '
9446 ||p_jobop_resource_usages_tbls(l_header_id)(i).SERIAL_NUMBER,
9447 p_stmt_num => l_stmt_num,
9448 p_msg_tokens => l_msg_tokens,
9449 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9450 p_run_log_level => l_log_level
9451 );
9452 END LOOP;
9453 END IF;
9454
9455 l_stmt_num := 253.7;
9456 DECLARE
9457 -- create an exception handler for ORA-24381
9458 errors NUMBER;
9459 dml_errors EXCEPTION;
9460 PRAGMA EXCEPTION_INIT(dml_errors, -24381);
9461 BEGIN
9462 forall i in p_jobop_resource_usages_tbls(l_header_id).first..p_jobop_resource_usages_tbls(l_header_id).last SAVE EXCEPTIONS
9463 insert into WIP_RESOURCE_ACTUAL_TIMES values p_jobop_resource_usages_tbls(l_header_id)(i);
9464 -- If any errors occurred during the FORALL SAVE EXCEPTIONS,
9465 -- a single exception is raised when the statement completes.
9466
9467 EXCEPTION
9468 WHEN dml_errors THEN -- Now we figure out what failed and why.
9469 errors := SQL%BULK_EXCEPTIONS.COUNT;
9470 FOR i IN 1..errors LOOP
9471 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
9472 l_msg_tokens.delete;
9473 WSM_log_PVT.logMessage (
9474 p_module_name => l_module,
9475 p_msg_text => 'Number of statements that failed: ' || errors||'Error #' || i || ' occurred during '||
9476 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX,
9477 p_stmt_num => l_stmt_num,
9478 p_msg_tokens => l_msg_tokens,
9479 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9480 p_run_log_level => l_log_level
9481 );
9482
9483 WSM_log_PVT.logMessage (
9484 p_module_name => l_module,
9485 p_msg_text => 'Error message is ' ||
9486 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE),
9487 p_stmt_num => l_stmt_num,
9488 p_msg_tokens => l_msg_tokens,
9489 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
9490 p_run_log_level => l_log_level
9491 );
9492 END IF;
9493
9494 END LOOP;
9495 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9496 END;
9497
9498 DECLARE
9499 cursor C_WOR is
9500 select resource_id
9501 from wip_operation_resources wor
9502 where wor.wip_entity_id = l_wip_entity_id
9503 and wor.operation_seq_num = l_fm_op_seq_num;
9504 BEGIN
9505 FOR rec in C_WOR LOOP
9506 UPDATE WIP_OPERATION_RESOURCES
9507 SET actual_start_date =
9508 (SELECT min(start_date)
9509 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9510 WHERE wrat.wip_entity_id = l_wip_entity_id
9511 AND wrat.operation_seq_num = l_fm_op_seq_num
9512 AND wrat.resource_id = rec.resource_id),
9513 actual_completion_date =
9514 (SELECT max(end_date)
9515 FROM WIP_RESOURCE_ACTUAL_TIMES wrat
9516 WHERE wrat.wip_entity_id = l_wip_entity_id
9517 AND wrat.operation_seq_num = l_fm_op_seq_num
9518 AND wrat.resource_id = rec.resource_id),
9519 LAST_UPDATE_DATE = sysdate,
9520 LAST_UPDATED_BY = g_user_id
9521 WHERE wip_entity_id = l_wip_entity_id
9522 AND operation_seq_num = l_fm_op_seq_num
9523 AND resource_id = rec.resource_id;
9524
9525 END LOOP;
9526 END;
9527
9528 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9529 l_msg_tokens.delete;
9530 WSM_log_PVT.logMessage (
9531 p_module_name => l_module,
9532 p_msg_text => 'Updated resource usage successfully',
9533 p_stmt_num => l_stmt_num,
9534 p_msg_tokens => l_msg_tokens,
9535 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9536 p_run_log_level => l_log_level
9537 );
9538 END IF;
9539
9540 END IF;--IF (p_jobop_resource_usages_tbls IS NOT NULL)
9541
9542 l_stmt_num := 253.611;
9543 UPDATE WIP_OPERATIONS
9544 SET actual_start_date = p_operation_start_date,
9545 actual_completion_date = p_operation_completion_date,
9546 employee_id = p_employee_id,
9547 wsm_bonus_quantity = p_bonus_quantity,
9548 LAST_UPDATE_DATE = sysdate,
9549 LAST_UPDATED_BY = g_user_id
9550 WHERE wip_entity_id = l_wip_entity_id
9551 AND operation_seq_num = l_fm_op_seq_num;
9552 --Bug 5480482:Variable l_wco_to_op_network_end is not needed.
9553 --Start of changes for bug 5480482
9554 --l_stmt_num := 253.612;
9555 --BEGIN
9556 --if last op update wdj.actual_completion_date
9557 --SELECT WCO.network_start_end
9558 --INTO l_wco_to_op_network_end
9559 --FROM WSM_COPY_OPERATIONS WCO, WIP_OPERATIONS WO
9560 -- WHERE WCO.wip_entity_id = WO.wip_entity_id
9561 -- AND WCO.operation_seq_num = WO.wsm_op_seq_num
9562 --AND WO.wip_entity_id = l_wip_entity_id
9563 -- AND WO.operation_seq_num = l_job_to_op_seq_num;
9564 -- EXCEPTION
9565 -- WHEN no_data_found THEN
9566 -- l_wco_to_op_network_end := null;
9567 -- END;
9568 --End of changes for bug 5480482
9569
9570 --bug 5057593
9571 IF (l_to_intraoperation_step_type = WIP_CONSTANTS.QUEUE) THEN
9572 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9573 AND (p_sec_uom_code_tbls(l_header_id).count > 0))
9574 THEN
9575 FORALL i in p_sec_uom_code_tbls(l_header_id).FIRST..p_sec_uom_code_tbls(l_header_id).LAST
9576 UPDATE WSM_OP_SECONDARY_QUANTITIES
9577 SET move_in_quantity = p_sec_move_out_qty_tbls(l_header_id)(i)
9578 WHERE wip_entity_id = l_wip_entity_id
9579 AND operation_seq_num = l_job_to_op_seq_num
9580 AND uom_code = p_sec_uom_code_tbls(l_header_id)(i);
9581 END IF; --IF ((p_sec_uom_code_tbls IS NOT NULL)
9582 END IF; --(l_to_intraoperation_step_type = WIP_CONSTANTS.QUEUE)
9583 --bug 5057593 end
9584 END IF; --ELSIF (nvl(p_source_code, 'interface') = 'move out oa page') THEN
9585 --Bug 5480482:WDJ.actual_start_date should be update only if this is
9586 --the first move txn.
9587 --Start of changes for bug 5480482
9588 --l_stmt_num := 253.613;
9589 --BEGIN
9590 --if 1st op update wdj.actual_start_date
9591 --SELECT WCO.network_start_end
9592 --INTO l_wco_fm_op_network_start
9593 --FROM WSM_COPY_OPERATIONS WCO, WIP_OPERATIONS WO
9594 --WHERE WCO.wip_entity_id = WO.wip_entity_id
9595 --AND WCO.operation_seq_num = WO.wsm_op_seq_num
9596 --AND WO.wip_entity_id = l_wip_entity_id
9597 --AND WO.operation_seq_num = l_fm_op_seq_num;
9598 --EXCEPTION
9599 --WHEN no_data_found THEN
9600 --l_wco_fm_op_network_start := null;
9601 --END;
9602
9603 --IF (l_wco_fm_op_network_start = 'S') OR (l_wco_to_op_network_end = 'E') THEN
9604 --l_stmt_num := 253.614;
9605 --UPDATE WIP_DISCRETE_JOBS
9606 --SET actual_start_date = decode(l_wco_fm_op_network_start,
9607 -- 'S', p_operation_start_date,
9608 -- actual_start_date),
9609 --Bug 4485174: Following update is commented out
9610 /*
9611 actual_completion_date = decode(l_wco_to_op_network_end,
9612 'E', p_operation_completion_date,
9613 actual_completion_date),
9614 */
9615 -- LAST_UPDATE_DATE = sysdate,
9616 -- LAST_UPDATED_BY = g_user_id
9617 --WHERE wip_entity_id = l_wip_entity_id;
9618 --END IF;
9619 UPDATE WIP_DISCRETE_JOBS wdj
9620 SET actual_start_date = p_operation_start_date,
9621 LAST_UPDATE_DATE = sysdate,
9622 LAST_UPDATED_BY = g_user_id
9623 WHERE wip_entity_id = l_wip_entity_id
9624 and not exists (select 1 from wip_move_transactions wmt
9625 where wmt.wip_entity_id = wdj.wip_entity_id
9626 and wmt.organization_id = wdj.organization_id
9627 and wmt.transaction_id <> l_transaction_id
9628 and wmt.wsm_undo_txn_id is NULL);
9629 --End of changes for bug 5480482
9630 ELSIF (nvl(p_source_code, 'interface') ='undo oa page') THEN
9631
9632 --Undo of Move Out from 10R to 10TM, 10Q to 10TM, 10R to 20Q, 10Q to 20Q
9633 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9634 IF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9635 AND ((l_to_intraoperation_step_type = 1) OR (l_to_intraoperation_step_type = 2)))
9636 AND (l_undone_txn_source_code = 'move out oa page')
9637 THEN --Move Out
9638 update wsm_op_secondary_quantities
9639 set MOVE_OUT_QUANTITY = NULL,
9640 LAST_UPDATE_DATE = sysdate,
9641 LAST_UPDATED_BY = g_user_id
9642 where wip_entity_id = l_wip_entity_id
9643 and operation_seq_num = l_job_to_op_seq_num;
9644
9645 UPDATE WSM_JOB_SECONDARY_QUANTITIES WJSQ
9646 SET WJSQ.CURRENT_QUANTITY =
9647 (SELECT MOVE_IN_QUANTITY
9648 FROM WSM_OP_SECONDARY_QUANTITIES WOSC
9649 WHERE WJSQ.UOM_CODE = WOSC.UOM_CODE
9650 AND WJSQ.wip_entity_id = WOSC.wip_entity_id
9651 AND WOSC.wip_entity_id = l_wip_entity_id
9652 AND WOSC.operation_seq_num = l_job_to_op_seq_num),
9653 LAST_UPDATE_DATE = sysdate,
9654 LAST_UPDATED_BY = g_user_id
9655 WHERE WJSQ.wip_entity_id = l_wip_entity_id;
9656
9657 update wsm_op_reason_codes
9658 set QUANTITY = NULL,
9659 LAST_UPDATE_DATE = sysdate,
9660 LAST_UPDATED_BY = g_user_id,
9661 LAST_UPDATED_LOGIN = g_login_id
9662 where wip_entity_id = l_wip_entity_id
9663 and operation_seq_num = l_job_to_op_seq_num;
9664
9665 l_stmt_num := 253.612;
9666 --Bug 5480482:WDJ.actual_start_date should be update only if this is
9667 --undo of first move txn
9668 --Start of changes for 5480482
9669 --SELECT min(operation_seq_num)
9670 --INTO l_wo_min_op_seq_num
9671 -- FROM WIP_OPERATIONS WO
9672 -- WHERE WO.wip_entity_id = l_wip_entity_id;
9673
9674 --IF (l_job_to_op_seq_num = l_wo_min_op_seq_num) AND (l_to_intraoperation_step_type = 1) THEN
9675 --l_stmt_num := 253.614;
9676 -- UPDATE WIP_DISCRETE_JOBS wdj
9677 -- SET actual_start_date = null,
9678 -- LAST_UPDATE_DATE = sysdate,
9679 -- LAST_UPDATED_BY = g_user_id
9680 -- WHERE wip_entity_id = l_wip_entity_id
9681 -- and not exists (select 1 from wip_move_transactions wmt
9682 -- where wmt.wip_entity_id = wdj.wip_entity_id
9683 -- and wmt.organization_id = wdj.organization_id
9684 -- and wmt.wsm_undo_txn_id is NULL);
9685 --END IF;
9686 --End of changes for 5480482
9687 --Undo of Move Out from 10Q to 10TM, 10Q to 20Q
9688 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9689 IF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9690 AND (l_to_intraoperation_step_type = 1)) THEN
9691 --no Move In b4 Move Out
9692 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9693 where wip_entity_id = l_wip_entity_id
9694 and operation_seq_num = l_job_to_op_seq_num;
9695
9696 UPDATE WIP_OPERATIONS
9697 SET actual_start_date = null,
9698 actual_completion_date = null,
9699 employee_id = null,
9700 LAST_UPDATE_DATE = sysdate,
9701 LAST_UPDATED_BY = g_user_id
9702 WHERE wip_entity_id = l_wip_entity_id
9703 AND operation_seq_num = l_job_to_op_seq_num;
9704
9705 --bug 5158378
9706 UPDATE WIP_OPERATION_RESOURCES
9707 SET actual_start_date = null,
9708 actual_completion_date = null
9709 WHERE wip_entity_id = l_wip_entity_id
9710 AND operation_seq_num = l_job_to_op_seq_num;
9711 --end bug 5158378
9712
9713 --bug 5158378 - OSFMST1: UNDO MOVE TRANSACTION NOT CLEARING THE ACTUAL COMPLETION DATE
9714 --Added the following ELSIF branch
9715 --Undo of Move Out from 10R to 10TM, 10R to 20Q
9716 --bug 5446252 added (l_fm_intraoperation_step_type = 5) for the case when undoing complete scrap
9717 ELSIF (((l_fm_intraoperation_step_type = 1) OR (l_fm_intraoperation_step_type = 3) OR (l_fm_intraoperation_step_type = 5))
9718 AND (l_to_intraoperation_step_type = 2)) THEN
9719 --Move In b4 Move Out
9720
9721 UPDATE WIP_OPERATIONS
9722 SET actual_completion_date = null
9723 WHERE wip_entity_id = l_wip_entity_id
9724 AND operation_seq_num = l_job_to_op_seq_num;
9725
9726 UPDATE WIP_RESOURCE_ACTUAL_TIMES
9727 SET end_date = NULL
9728 where wip_entity_id = l_wip_entity_id
9729 and operation_seq_num = l_job_to_op_seq_num;
9730
9731 UPDATE WIP_OPERATION_RESOURCES
9732 SET actual_completion_date = null
9733 WHERE wip_entity_id = l_wip_entity_id
9734 AND operation_seq_num = l_job_to_op_seq_num;
9735
9736 /*
9737 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9738 where wip_entity_id = l_wip_entity_id
9739 and operation_seq_num = l_job_to_op_seq_num
9740 and projected_completion_date IS NULL;
9741 */
9742 END IF;
9743 ELSIF ((l_fm_intraoperation_step_type = 2) AND (l_to_intraoperation_step_type = 1))
9744 AND (l_undone_txn_source_code = 'move in oa page')
9745 THEN --Move In
9746
9747 DELETE FROM WIP_RESOURCE_ACTUAL_TIMES
9748 where wip_entity_id = l_wip_entity_id
9749 and operation_seq_num = l_job_to_op_seq_num;
9750
9751 UPDATE WIP_OPERATIONS
9752 SET actual_start_date = null,
9753 projected_completion_date = null,
9754 employee_id = null,
9755 LAST_UPDATE_DATE = sysdate,
9756 LAST_UPDATED_BY = g_user_id
9757 WHERE wip_entity_id = l_wip_entity_id
9758 AND operation_seq_num = l_fm_op_seq_num;
9759
9760 --bug 5158378
9761 UPDATE WIP_OPERATION_RESOURCES
9762 SET actual_start_date = null
9763 WHERE wip_entity_id = l_wip_entity_id
9764 AND operation_seq_num = l_job_to_op_seq_num;
9765 --end bug 5158378
9766 END IF;
9767
9768 END IF; --(nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page'))
9769
9770 l_stmt_num := 253.7;
9771 UPDATE WSM_LOT_MOVE_TXN_INTERFACE
9772 SET status = 4,
9773 LAST_UPDATE_DATE = sysdate,
9774 LAST_UPDATED_BY = g_user_id
9775 WHERE header_id = l_header_id;
9776
9777 l_stmt_num := 253.8;
9778 IF nvl(p_bonus_quantity, 0) > 0 THEN
9779 l_stmt_num := 253.9;
9780
9781 l_wltx_transactions_rec.TRANSACTION_TYPE_ID := WSMPCNST.UPDATE_QUANTITY;
9782 l_wltx_transactions_rec.TRANSACTION_DATE := l_transaction_date;
9783 l_wltx_transactions_rec.TRANSACTION_REFERENCE := l_transaction_reference;
9784 l_wltx_transactions_rec.REASON_ID := l_reason_id;
9785 l_wltx_transactions_rec.EMPLOYEE_ID := p_employee_id;
9786 l_wltx_transactions_rec.ORGANIZATION_ID := l_organization_id;
9787
9788 select wsm_split_merge_transactions_s.nextval
9789 into l_wltx_transactions_rec.TRANSACTION_ID
9790 from dual;
9791
9792 l_wltx_starting_job_tbl(0).WIP_ENTITY_ID := l_wip_entity_id;
9793 l_wltx_starting_job_tbl(0).OPERATION_SEQ_NUM := l_job_to_op_seq_num;
9794
9795 l_wltx_resulting_job_tbl(0).WIP_ENTITY_ID := l_wip_entity_id;
9796 l_wltx_resulting_job_tbl(0).START_QUANTITY := l_primary_quantity + p_bonus_quantity;
9797 l_wltx_resulting_job_tbl(0).BONUS_ACCT_ID := p_bonus_account_id;
9798 l_wltx_resulting_job_tbl(0).STARTING_OPERATION_SEQ_NUM := l_fm_op_seq_num;
9799 l_wltx_resulting_job_tbl(0).SPLIT_HAS_UPDATE_ASSY := 0;
9800
9801 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9802 l_msg_tokens.delete;
9803 WSM_log_PVT.logMessage (
9804 p_module_name => l_module,
9805 p_msg_text => 'Populated l_wltx_transactions_rec'
9806 ||'; TRANSACTION_TYPE_ID '
9807 ||l_wltx_transactions_rec.TRANSACTION_TYPE_ID
9808 ||'; TRANSACTION_DATE '
9809 ||l_wltx_transactions_rec.TRANSACTION_DATE
9810 ||'; TRANSACTION_REFERENCE '
9811 ||l_wltx_transactions_rec.TRANSACTION_REFERENCE
9812 ||'; REASON_ID '
9813 ||l_wltx_transactions_rec.REASON_ID
9814 ||'; EMPLOYEE_ID '
9815 ||l_wltx_transactions_rec.EMPLOYEE_ID
9816 ||'; ORGANIZATION_ID '
9817 ||l_wltx_transactions_rec.ORGANIZATION_ID
9818 ||'; TRANSACTION_ID '
9819 ||l_wltx_transactions_rec.TRANSACTION_ID
9820 ||'; Populated l_wltx_starting_job_tbl'
9821 ||'; WIP_ENTITY_ID '
9822 ||l_wltx_starting_job_tbl(0).WIP_ENTITY_ID
9823 ||'; OPERATION_SEQ_NUM '
9824 ||l_wltx_starting_job_tbl(0).OPERATION_SEQ_NUM
9825 ||'; Populated l_wltx_resulting_job_tbl'
9826 ||l_wltx_resulting_job_tbl(0).WIP_ENTITY_ID
9827 ||'; START_QUANTITY '
9828 ||l_wltx_resulting_job_tbl(0).START_QUANTITY
9829 ||'; BONUS_ACCT_ID '
9830 ||l_wltx_resulting_job_tbl(0).BONUS_ACCT_ID,
9831 p_stmt_num => l_stmt_num,
9832 p_msg_tokens => l_msg_tokens,
9833 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9834 p_run_log_level => l_log_level
9835 );
9836 END IF;
9837 l_stmt_num := 253.10;
9838 IF ((p_sec_uom_code_tbls IS NOT NULL) AND (p_sec_uom_code_tbls.exists(l_header_id))
9839 AND (p_sec_uom_code_tbls(l_header_id).count > 0))
9840 THEN
9841 FOR i IN p_sec_uom_code_tbls(l_header_id).first..p_sec_uom_code_tbls(l_header_id).last LOOP
9842 l_wltx_secondary_qty_tbl(i).wip_entity_name := l_wip_entity_name;
9843 l_wltx_secondary_qty_tbl(i).wip_entity_id := l_wip_entity_id;
9844 l_wltx_secondary_qty_tbl(i).uom_code := p_sec_uom_code_tbls(l_header_id)(i);
9845 l_wltx_secondary_qty_tbl(i).current_quantity := p_sec_move_out_qty_tbls(l_header_id)(i);
9846 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9847 l_msg_tokens.delete;
9848 WSM_log_PVT.logMessage (
9849 p_module_name => l_module,
9850 p_msg_text => 'Populating l_wltx_secondary_qty_tbl',
9851 p_stmt_num => l_stmt_num,
9852 p_msg_tokens => l_msg_tokens,
9853 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9854 p_run_log_level => l_log_level
9855 );
9856 END IF;
9857 END LOOP;
9858 END IF; --IF ((p_sec_uom_code_tbls IS NOT NULL)
9859
9860 l_stmt_num := 253.11;
9861 IF ((p_jobop_bonus_serials_tbls IS NOT NULL) AND (p_jobop_bonus_serials_tbls.exists(l_header_id))
9862 AND (p_jobop_bonus_serials_tbls(l_header_id).count > 0))
9863 THEN
9864 FOR i in p_jobop_bonus_serials_tbls(l_header_id).first..p_jobop_bonus_serials_tbls(l_header_id).last LOOP
9865 l_WSM_SERIAL_NUM_TBL(i) := p_jobop_bonus_serials_tbls(l_header_id)(i);
9866 l_WSM_SERIAL_NUM_TBL(i).action_flag := 1;
9867 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9868 l_msg_tokens.delete;
9869 WSM_log_PVT.logMessage (
9870 p_module_name => l_module,
9871 p_msg_text => 'Populating l_WSM_SERIAL_NUM_TBL '||
9872 ';i '||
9873 i||
9874 ';serial_number '||
9875 p_jobop_bonus_serials_tbls(l_header_id)(i).serial_number||
9876 ';action_flag '||
9877 l_WSM_SERIAL_NUM_TBL(i).action_flag,
9878 p_stmt_num => l_stmt_num,
9879 p_msg_tokens => l_msg_tokens,
9880 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
9881 p_run_log_level => l_log_level
9882 );
9883 END IF;
9884 END LOOP;
9885 END IF; --IF ((p_jobop_bonus_serials_tbls IS NOT NULL)
9886
9887 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9888 DECLARE
9889 l_start_qty NUMBER;
9890 BEGIN
9891 SELECT start_quantity
9892 INTO l_start_qty
9893 FROM WIP_DISCRETE_JOBS
9894 WHERE wip_entity_id = l_wip_entity_id;
9895
9896 l_msg_tokens.delete;
9897 WSM_log_PVT.logMessage (
9898 p_module_name => l_module,
9899 p_msg_text => 'B4 Calling WSM_WIP_LOT_TXN_PVT.invoke_txn_API '||
9900 ';wdj l_start_qty '||
9901 l_start_qty,
9902 p_stmt_num => l_stmt_num,
9903 p_msg_tokens => l_msg_tokens,
9904 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9905 p_run_log_level => l_log_level
9906 );
9907 EXCEPTION
9908 WHEN others THEN
9909 null;
9910 END;
9911 END IF;
9912
9913 l_stmt_num := 253.12;
9914 WSM_WIP_LOT_TXN_PVT.invoke_txn_API (
9915 p_api_version => 1.0,
9916 p_commit => FND_API.G_FALSE,
9917 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
9918 p_init_msg_list => FND_API.G_FALSE,
9919 p_calling_mode => 1,
9920 p_txn_header_rec => l_wltx_transactions_rec,
9921 p_starting_jobs_tbl => l_wltx_starting_job_tbl,
9922 p_resulting_jobs_tbl => l_wltx_resulting_job_tbl,
9923 p_wsm_serial_num_tbl => l_WSM_SERIAL_NUM_TBL,
9924 p_secondary_qty_tbl => l_wltx_secondary_qty_tbl,
9925 x_return_status => x_return_status,
9926 x_msg_count => x_msg_count,
9927 x_error_msg => x_error_msg
9928 );
9929
9930 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9931 IF (x_return_status = g_ret_success) THEN
9932 l_msg_tokens.delete;
9933 WSM_log_PVT.logMessage (
9934 p_module_name => l_module,
9935 p_msg_text => 'WSM_WIP_LOT_TXN_PVT.invoke_txn_API returned '||
9936 ';x_return_status '||
9937 x_return_status||
9938 ';x_msg_count '||
9939 x_msg_count||
9940 '; x_error_msg '||
9941 x_error_msg,
9942 p_stmt_num => l_stmt_num,
9943 p_msg_tokens => l_msg_tokens,
9944 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9945 p_run_log_level => l_log_level
9946 );
9947 END IF;
9948 END IF;
9949
9950 IF (x_return_status = g_ret_error) THEN
9951 RAISE FND_API.G_EXC_ERROR;
9952 ELSIF (x_return_status = g_ret_unexpected) THEN
9953 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9954 END IF;
9955
9956 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
9957 IF (x_return_status = g_ret_success) THEN
9958 l_msg_tokens.delete;
9959 WSM_log_PVT.logMessage (
9960 p_module_name => l_module,
9961 p_msg_text => 'WSM_WIP_LOT_TXN_PVT.invoke_txn_API returned successfully',
9962 p_stmt_num => l_stmt_num,
9963 p_msg_tokens => l_msg_tokens,
9964 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
9965 p_run_log_level => l_log_level
9966 );
9967 END IF;
9968 END IF;
9969 l_stmt_num := 253.61;
9970 UPDATE WIP_OPERATIONS
9971 SET WSM_UPDATE_QUANTITY_TXN_ID = l_wltx_transactions_rec.TRANSACTION_ID,
9972 LAST_UPDATE_DATE = sysdate,
9973 LAST_UPDATED_BY = g_user_id
9974 WHERE wip_entity_id = l_wip_entity_id
9975 AND operation_seq_num = l_fm_op_seq_num;
9976
9977 END IF; --IF nvl(p_bonus_quantity, 0) > 0
9978
9979 IF (l_put_job_on_hold = 1) THEN
9980 UPDATE WIP_DISCRETE_JOBS
9981 SET STATUS_TYPE = WIP_CONSTANTS.HOLD,
9982 LAST_UPDATE_DATE = sysdate,
9983 LAST_UPDATED_BY = g_user_id
9984 WHERE wip_entity_id = l_wip_entity_id;
9985 END IF;
9986 END IF; --IF (nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page',
9987 --MES END
9988 --Bug 5368120:For MES txns,update attr move should be called inside the inner loop.
9989 -- as outside this loop, l_transaction_id and l_scrap_txn_id do not point
9990 -- to current transaction.
9991 DECLARE
9992 l_return_status VARCHAR2(1);
9993 l_error_msg VARCHAR2(2000);
9994 l_error_count NUMBER;
9995 l_move_txn_id NUMBER := null;
9996 l_scrap_id NUMBER := null;
9997 BEGIN
9998 IF nvl(p_source_code, 'interface') = 'undo oa page'
9999 THEN
10000 l_move_txn_id := l_transaction_id;
10001 l_scrap_id := l_scrap_txn_id ;
10002
10003
10004 WSM_Serial_support_PVT.Update_attr_move( p_group_id => NULL ,
10005 p_internal_group_id => NULL ,
10006 p_move_txn_id => l_move_txn_id ,
10007 p_scrap_txn_id => l_scrap_id ,
10008 p_organization_id => null ,
10009 x_return_status => l_return_status ,
10010 x_error_count => l_error_count ,
10011 x_error_msg => l_error_msg
10012 );
10013
10014 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10015 IF (l_debug='Y') THEN
10016 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned Success');
10017 END IF;
10018 ELSE
10019 IF (l_error_count = 1) THEN
10020 fnd_file.put_line(fnd_file.log, l_error_msg);
10021 ELSIF (l_error_count > 1) THEN
10022 FOR i IN 1..l_error_count LOOP
10023 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10024 p_encoded => FND_API.G_FALSE
10025 );
10026 fnd_file.put_line(fnd_file.log, l_error_msg);
10027 END LOOP;
10028 ELSE
10029 l_error_msg := 'WSM_Serial_support_PVT.Update_attr_move returned failure';
10030 END IF;
10031
10032 IF (l_debug='Y') THEN
10033 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned failure');
10034 END IF;
10035 -- This call is supposed to not return any error...
10036 raise e_proc_exception;
10037
10038 END IF;
10039 END IF; --End of check in source code.
10040 END;
10041 --Bug 5368120:End of changes.
10042
10043 END LOOP; /* end inner loop */
10044
10045 CLOSE C_TXNS;
10046
10047 IF (l_inserted_wmti=0) THEN
10048 IF (g_mrp_debug='Y') THEN
10049 fnd_file.put_line(fnd_file.log, 'No txns inserted in WMTI');
10050 END IF;
10051 EXIT;
10052 ELSE
10053 IF (g_mrp_debug='Y') THEN
10054 fnd_file.put_line(fnd_file.log, 'Inserted '||l_inserted_wmti||' row(s) in WMTI');
10055 END IF;
10056 END IF;
10057
10058 -- MES
10059 -- ST : Serial MES Fix :
10060 -- Moved this IF clause to encompass the Serial code as well...
10061 IF nvl(p_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10062 'jump oa page', 'undo oa page' )
10063 THEN
10064 -- ST : Serial Support Project --
10065 -- Temporarily store the Serial Attributes of serial numbers from MSN and
10066 -- present in WMTI...(use p_group_id)
10067 DECLARE
10068 l_return_status VARCHAR2(1);
10069 l_error_msg VARCHAR2(2000);
10070 l_error_count NUMBER;
10071
10072 BEGIN
10073 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10074 l_msg_tokens.delete;
10075 WSM_log_PVT.logMessage ( p_module_name => l_module ,
10076 p_msg_text => 'B4 calling WSM_Serial_support_PVT.Insert_MOVE_attr',
10077 p_stmt_num => l_stmt_num ,
10078 p_msg_tokens => l_msg_tokens ,
10079 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10080 p_run_log_level => l_log_level
10081 );
10082 END IF;
10083
10084 l_stmt_num := 253.13;
10085 WSM_Serial_support_PVT.Insert_MOVE_attr ( p_group_id => l_wmti_group_id ,
10086 x_return_status => l_return_status ,
10087 x_error_count => l_error_msg ,
10088 x_error_msg => l_error_count
10089 );
10090
10091 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10092 IF (l_debug='Y') THEN
10093 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned Success');
10094 END IF;
10095
10096 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10097 l_msg_tokens.delete;
10098 WSM_log_PVT.logMessage (p_module_name => l_module ,
10099 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned successfully',
10100 p_stmt_num => l_stmt_num ,
10101 p_msg_tokens => l_msg_tokens ,
10102 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10103 p_run_log_level => l_log_level
10104 );
10105 END IF;
10106 ELSE
10107 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
10108 l_msg_tokens.delete;
10109 WSM_log_PVT.logMessage ( p_module_name => l_module ,
10110 p_msg_text => 'WSM_Serial_support_PVT.Insert_MOVE_attr returned error',
10111 p_stmt_num => l_stmt_num ,
10112 p_msg_tokens => l_msg_tokens ,
10113 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
10114 p_run_log_level => l_log_level
10115 );
10116 END IF;
10117 IF (l_error_count = 1) THEN
10118 fnd_file.put_line(fnd_file.log, l_error_msg);
10119 ELSIF (l_error_count > 1) THEN
10120 FOR i IN 1..l_error_count LOOP
10121 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10122 p_encoded => FND_API.G_FALSE
10123 );
10124 fnd_file.put_line(fnd_file.log, l_error_msg);
10125 END LOOP;
10126 ELSE
10127 l_error_msg := 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure';
10128 END IF;
10129
10130 IF (l_debug='Y') THEN
10131 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Insert_attr_WSTI returned failure');
10132 END IF;
10133 -- This call is supposed to not return any error...
10134 raise e_proc_exception;
10135 END IF;
10136 END;
10137 -- ST : Serial Support Project --
10138
10139 -- ST : Serial MES Fix : Commented out the below clause and moved it forward..
10140 -- MES
10141 -- IF nvl(p_source_code, 'interface') NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10142 -- 'jump oa page', 'undo oa page' ) THEN
10143
10144 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10145 l_msg_tokens.delete;
10146 WSM_log_PVT.logMessage( p_module_name => l_module ,
10147 p_msg_text => 'B4 calling Wip_movProc_grp.processInterface',
10148 p_stmt_num => l_stmt_num ,
10149 p_msg_tokens => l_msg_tokens ,
10150 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10151 p_run_log_level => l_log_level
10152 );
10153 END IF;
10154 /*******
10155 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10156 DECLARE
10157 CURSOR C_WRO IS
10158 SELECT WRO.wip_entity_id,
10159 WRO.operation_seq_num,
10160 WRO.segment1,
10161 WRO.INVENTORY_ITEM_ID,
10162 WRO.REQUIRED_QUANTITY,
10163 WRO.QUANTITY_ISSUED,
10164 WRO.QUANTITY_PER_ASSEMBLY,
10165 WRO.QUANTITY_RELIEVED,
10166 WRO.COMPONENT_YIELD_FACTOR,
10167 WRO.basis_type
10168 FROM wsm_lot_move_txn_interface WLMTI,
10169 WIP_REQUIREMENT_OPERATIONS WRO
10170 WHERE WLMTI.group_id = p_group_id
10171 AND WLMTI.wip_entity_id = 1439883
10172 AND WLMTI.wip_entity_id = WRO.wip_entity_id
10173 AND WRO.operation_seq_num IN (10, 20)
10174 ORDER BY WRO.wip_entity_id,
10175 WRO.operation_seq_num,
10176 WRO.segment1;
10177 BEGIN
10178 FOR rec in C_WRO LOOP
10179 l_msg_tokens.delete;
10180 WSM_log_PVT.logMessage(
10181 p_module_name => l_module ,
10182 p_msg_text => 'B4 calling Wip_movProc_grp.processInterface '||
10183 '; wip_entity_id '||rec.wip_entity_id||
10184 '; operation_seq_num '||rec.operation_seq_num||
10185 '; segment1 '||rec.segment1||
10186 '; INVENTORY_ITEM_ID '||rec.INVENTORY_ITEM_ID||
10187 '; REQUIRED_QUANTITY '||rec.REQUIRED_QUANTITY||
10188 '; QUANTITY_ISSUED '||rec.QUANTITY_ISSUED||
10189 '; QUANTITY_PER_ASSEMBLY '||rec.QUANTITY_PER_ASSEMBLY||
10190 '; QUANTITY_RELIEVED '||rec.QUANTITY_RELIEVED||
10191 '; COMPONENT_YIELD_FACTOR '||rec.COMPONENT_YIELD_FACTOR||
10192 '; basis_type '||rec.basis_type
10193 ,
10194 p_stmt_num => l_stmt_num ,
10195 p_msg_tokens => l_msg_tokens ,
10196 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10197 p_run_log_level => l_log_level
10198 );
10199 END LOOP;
10200 END;
10201 END IF;
10202 *********/
10203
10204
10205
10206 l_stmt_num := 240;
10207 Wip_movProc_grp.processInterface(p_groupID => l_wmti_group_id,
10208 p_commit => null, --fnd_api.g_true,
10209 x_returnStatus => x_returnStatus);
10210 /***
10211 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10212 DECLARE
10213 CURSOR C_WRO IS
10214 SELECT WRO.wip_entity_id,
10215 WRO.operation_seq_num,
10216 WRO.segment1,
10217 WRO.INVENTORY_ITEM_ID,
10218 WRO.REQUIRED_QUANTITY,
10219 WRO.QUANTITY_ISSUED,
10220 WRO.QUANTITY_PER_ASSEMBLY,
10221 WRO.QUANTITY_RELIEVED,
10222 WRO.COMPONENT_YIELD_FACTOR,
10223 WRO.basis_type
10224 FROM wsm_lot_move_txn_interface WLMTI,
10225 WIP_REQUIREMENT_OPERATIONS WRO
10226 WHERE WLMTI.group_id = p_group_id
10227 AND WLMTI.wip_entity_id = WRO.wip_entity_id
10228 AND WRO.operation_seq_num IN (WLMTI.FM_OPERATION_SEQ_NUM, WLMTI.TO_OPERATION_SEQ_NUM)
10229 ORDER BY WRO.wip_entity_id,
10230 WRO.operation_seq_num,
10231 WRO.segment1;
10232 BEGIN
10233 FOR rec in C_WRO LOOP
10234 l_msg_tokens.delete;
10235 WSM_log_PVT.logMessage(
10236 p_module_name => l_module ,
10237 p_msg_text => 'After calling Wip_movProc_grp.processInterface '||
10238 '; wip_entity_id '||rec.wip_entity_id||
10239 '; operation_seq_num '||rec.operation_seq_num||
10240 '; segment1 '||rec.segment1||
10241 '; INVENTORY_ITEM_ID '||rec.INVENTORY_ITEM_ID||
10242 '; REQUIRED_QUANTITY '||rec.REQUIRED_QUANTITY||
10243 '; QUANTITY_ISSUED '||rec.QUANTITY_ISSUED||
10244 '; QUANTITY_PER_ASSEMBLY '||rec.QUANTITY_PER_ASSEMBLY||
10245 '; QUANTITY_RELIEVED '||rec.QUANTITY_RELIEVED||
10246 '; COMPONENT_YIELD_FACTOR '||rec.COMPONENT_YIELD_FACTOR||
10247 '; basis_type '||rec.basis_type
10248 ,
10249 p_stmt_num => l_stmt_num ,
10250 p_msg_tokens => l_msg_tokens ,
10251 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10252 p_run_log_level => l_log_level
10253 );
10254 END LOOP;
10255 END;
10256 END IF;
10257 **/
10258 IF (x_returnStatus=fnd_api.g_ret_sts_unexp_error) THEN
10259 --move enh? this logic is based on the fact that after going through osfm validations wip api
10260 --should not throw any errors and if errors are encountered we will rollback and exit the worker
10261 --Checks for such errors should be added to osfm validations.
10262 DECLARE
10263 cursor c_wtie is
10264 SELECT WLMTI.header_id
10265 , wtie.transaction_id
10266 , wtie.error_message
10267 FROM WIP_TXN_INTERFACE_ERRORS wtie,
10268 WSM_LOT_MOVE_TXN_INTERFACE WLMTI,
10269 WIP_MOVE_TXN_INTERFACE WMTI
10270 WHERE WTIE.transaction_id = WMTI.transaction_id
10271 --FP bug 5178168 (base bug 5168406) changed the line below
10272 --AND WMTI.batch_id = WLMTI.transaction_id
10273 AND nvl(WMTI.batch_id, wmti.transaction_id) = WLMTI.transaction_id
10274 AND WMTI.group_id = l_wmti_group_id
10275 AND WLMTI.group_id = p_group_id;
10276 BEGIN
10277 FOR rec in c_wtie LOOP
10278 copy_WTIE_to_WIE(x_error_code,
10279 x_error_msg,
10280 rec.header_id,
10281 rec.transaction_id,
10282 rec.error_message);
10283 END LOOP;
10284 END;
10285 l_success := 0;
10286 fnd_file.put_line(fnd_file.log, 'Returned unsuccessfully from Wip_movProc_grp.processInterface');
10287 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
10288 l_msg_tokens.delete;
10289 WSM_log_PVT.logMessage (
10290 p_module_name => l_module ,
10291 p_msg_text => 'Wip_movProc_grp.processInterface returned unexpected failure',
10292 p_stmt_num => l_stmt_num ,
10293 p_msg_tokens => l_msg_tokens ,
10294 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
10295 p_run_log_level => l_log_level
10296 );
10297 END IF;
10298 raise e_proc_exception;
10299 ELSIF (x_returnStatus=fnd_api.g_ret_sts_success) THEN
10300 l_wmti_err_txns := 0;
10301
10302 SELECT count(*)
10303 INTO l_wmti_err_txns
10304 FROM WIP_MOVE_TXN_INTERFACE
10305 WHERE GROUP_ID=l_wmti_group_id
10306 AND PROCESS_STATUS = 3;
10307
10308 IF (g_mrp_debug='Y') THEN
10309 fnd_file.put_line(fnd_file.log, 'Returned successfully from Wip_movProc_grp.processInterface');
10310 END IF;
10311 IF (l_wmti_err_txns > 0) THEN
10312 l_success := 0;
10313 ELSE
10314 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10315 l_msg_tokens.delete;
10316 WSM_log_PVT.logMessage (
10317 p_module_name => l_module ,
10318 p_msg_text => 'Wip_movProc_grp.processInterface returned successfully',
10319 p_stmt_num => l_stmt_num ,
10320 p_msg_tokens => l_msg_tokens ,
10321 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
10322 p_run_log_level => l_log_level
10323 );
10324 END IF;
10325 l_success := 1;
10326 update_txn_status(x_error_code,
10327 x_error_msg,
10328 p_group_id,
10329 l_wmti_group_id);
10330 END IF;
10331 IF (l_success=0) THEN
10332 IF (G_LOG_LEVEL_ERROR >= l_log_level) THEN
10333 l_msg_tokens.delete;
10334 WSM_log_PVT.logMessage (
10335 p_module_name => l_module ,
10336 p_msg_text => 'Wip_movProc_grp.processInterface returned failure',
10337 p_stmt_num => l_stmt_num ,
10338 p_msg_tokens => l_msg_tokens ,
10339 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
10340 p_run_log_level => l_log_level
10341 );
10342 END IF;
10343 fnd_file.put_line(fnd_file.log, 'Returned unsuccessfully from Wip_movProc_grp.processInterface');
10344 raise e_proc_exception;
10345 END IF;
10346
10347 END IF;
10348
10349 --bug 5210799 Update quantity_completed to null if jump from queue
10350 UPDATE WIP_OPERATIONS
10351 SET quantity_completed = 0
10352 WHERE rowid IN
10353 (
10354 SELECT WO.rowid
10355 FROM WIP_OPERATIONS WO,
10356 WSM_LOT_MOVE_TXN_INTERFACE WLMTI
10357 WHERE WLMTI.group_id = p_group_id
10358 AND WLMTI.internal_group_id = l_wmti_group_id
10359 AND WLMTI.status = 4
10360 AND WO.wip_entity_id = WLMTI.wip_entity_id
10361 AND WO.operation_seq_num = WLMTI.fm_operation_seq_num
10362 AND WO.skip_flag = 1
10363 );
10364 --end bug 5210799
10365
10366 END IF; --p_source_code NOT IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10367
10368 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10369 l_msg_tokens.delete;
10370 WSM_log_PVT.logMessage (
10371 p_module_name => l_module,
10372 p_msg_text => 'B4 UPDATE WIP_OPERATION_YIELDS woy '
10373 ||';p_group_id '
10374 ||p_group_id
10375 ||';l_wmti_group_id '
10376 ||l_wmti_group_id ,
10377 p_stmt_num => l_stmt_num,
10378 p_msg_tokens => l_msg_tokens,
10379 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10380 p_run_log_level => l_log_level
10381 );
10382 END IF;
10383
10384 l_stmt_num := 270;
10385
10386 /* Bug Fix 5969857. Use UNION ALL for wmt.transaction_id instead of wmt.transaction_id in
10387 (wlmti.transaction_id, wlmti.internal_scrap_txn_id)*/
10388
10389 UPDATE WIP_OPERATION_YIELDS woy
10390 SET status = 1,
10391 last_update_date = sysdate,
10392 last_update_login = g_login_id,
10393 request_id = g_request_id,
10394 program_application_id= g_program_application_id,
10395 program_id = g_program_id,
10396 program_update_date = DECODE(g_request_id,NULL,NULL,SYSDATE)
10397 WHERE woy.rowid IN ((
10398 SELECT woy2.rowid
10399 FROM WIP_OPERATIONS wop2,
10400 WIP_OPERATION_YIELDS woy2,
10401 WSM_PARAMETERS wp, -- ESA
10402 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10403 WIP_MOVE_TRANSACTIONS wmt,
10404 WSM_LOT_MOVE_TXN_INTERFACE wlmti
10405 --bug 3615826
10406 -- WHERE wmt.group_id = l_wmti_group_id
10407 WHERE wlmti.group_id = p_group_id
10408 --mes commented out the following and added subsequent lines
10409 -- AND wlmti.internal_group_id = l_wmti_group_id;
10410 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10411 'move in oa page', wlmti.transaction_id,
10412 'move out oa page', wlmti.transaction_id,
10413 'move to next op oa page', wlmti.transaction_id,
10414 'jump oa page', wlmti.transaction_id,
10415 'undo oa page', wlmti.transaction_id,
10416 l_wmti_group_id)
10417 )
10418 OR
10419 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10420 'move in oa page', wlmti.internal_scrap_txn_id,
10421 'move out oa page', wlmti.internal_scrap_txn_id,
10422 'move to next op oa page', wlmti.internal_scrap_txn_id,
10423 'jump oa page', wlmti.internal_scrap_txn_id,
10424 'undo oa page', wlmti.internal_scrap_txn_id,
10425 l_wmti_group_id)
10426 )
10427 )
10428 AND (wmt.transaction_id =wlmti.transaction_id)
10429 --move enh not needed since we are looking at WMT
10430 -- AND wmt.process_phase = g_move_proc
10431 -- AND wmt.process_status = g_running
10432 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) /*bugfix 2856703*/
10433 AND wp.organization_id = wmt.organization_id -- ESA
10434 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10435 AND wdj.wip_entity_id = wmt.wip_entity_id -- NSLBJ
10436 AND wdj.job_type <>3 -- NSLBJ
10437 AND wop2.organization_id = wmt.organization_id
10438 AND wop2.wip_entity_id = wmt.wip_entity_id
10439 AND woy2.organization_id = wmt.organization_id
10440 AND woy2.wip_entity_id = wmt.wip_entity_id
10441 AND woy2.operation_seq_num= wop2.operation_seq_num
10442 AND ( /* Forward Move */
10443 ( wop2.operation_seq_num >= wmt.fm_operation_seq_num
10444 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10445 AND
10446 wop2.operation_seq_num < wmt.to_operation_seq_num
10447 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10448 AND
10449 ( wmt.to_operation_seq_num > wmt.fm_operation_seq_num
10450 OR
10451 (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
10452 AND wmt.fm_intraoperation_step_type<=g_run
10453 AND wmt.to_intraoperation_step_type>g_run)
10454 )
10455 AND
10456 ( wop2.count_point_type < g_no_manual
10457 OR wop2.operation_seq_num = wmt.fm_operation_seq_num
10458 OR (wop2.operation_seq_num = wmt.to_operation_seq_num
10459 AND wmt.to_intraoperation_step_type > g_run)
10460 )
10461 )
10462 OR /* Backward Move */
10463 ( wop2.operation_seq_num < wmt.fm_operation_seq_num
10464 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10465 AND
10466 wop2.operation_seq_num >= wmt.to_operation_seq_num
10467 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10468 AND
10469 ( wmt.fm_operation_seq_num > wmt.to_operation_seq_num
10470 OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
10471 AND wmt.to_intraoperation_step_type<=g_run
10472 AND wmt.fm_intraoperation_step_type>g_run)
10473 )
10474 AND
10475 ( wop2.count_point_type < g_no_manual
10476 OR(wop2.operation_seq_num = wmt.to_operation_seq_num
10477 AND wop2.count_point_type < g_no_manual)
10478 OR(wop2.operation_seq_num = wmt.fm_operation_seq_num
10479 AND wmt.fm_intraoperation_step_type > g_run)
10480 )
10481 )
10482 )
10483 )
10484 UNION ALL
10485 (
10486 SELECT woy2.rowid
10487 FROM WIP_OPERATIONS wop2,
10488 WIP_OPERATION_YIELDS woy2,
10489 WSM_PARAMETERS wp, -- ESA
10490 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10491 WIP_MOVE_TRANSACTIONS wmt,
10492 WSM_LOT_MOVE_TXN_INTERFACE wlmti
10493 --bug 3615826
10494 -- WHERE wmt.group_id = l_wmti_group_id
10495 WHERE wlmti.group_id = p_group_id
10496 --mes commented out the following and added subsequent lines
10497 -- AND wlmti.internal_group_id = l_wmti_group_id;
10498 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10499 'move in oa page', wlmti.transaction_id,
10500 'move out oa page', wlmti.transaction_id,
10501 'move to next op oa page', wlmti.transaction_id,
10502 'jump oa page', wlmti.transaction_id,
10503 'undo oa page', wlmti.transaction_id,
10504 l_wmti_group_id)
10505 )
10506 OR
10507 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10508 'move in oa page', wlmti.internal_scrap_txn_id,
10509 'move out oa page', wlmti.internal_scrap_txn_id,
10510 'move to next op oa page', wlmti.internal_scrap_txn_id,
10511 'jump oa page', wlmti.internal_scrap_txn_id,
10512 'undo oa page', wlmti.internal_scrap_txn_id,
10513 l_wmti_group_id)
10514 )
10515 )
10516 AND (wmt.transaction_id = wlmti.internal_scrap_txn_id)
10517 --move enh not needed since we are looking at WMT
10518 -- AND wmt.process_phase = g_move_proc
10519 -- AND wmt.process_status = g_running
10520 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) /*bugfix 2856703*/
10521 AND wp.organization_id = wmt.organization_id -- ESA
10522 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10523 AND wdj.wip_entity_id = wmt.wip_entity_id -- NSLBJ
10524 AND wdj.job_type <>3 -- NSLBJ
10525 AND wop2.organization_id = wmt.organization_id
10526 AND wop2.wip_entity_id = wmt.wip_entity_id
10527 AND woy2.organization_id = wmt.organization_id
10528 AND woy2.wip_entity_id = wmt.wip_entity_id
10529 AND woy2.operation_seq_num= wop2.operation_seq_num
10530 AND ( /* Forward Move */
10531 ( wop2.operation_seq_num >= wmt.fm_operation_seq_num
10532 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10533 AND
10534 wop2.operation_seq_num < wmt.to_operation_seq_num
10535 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10536 AND
10537 ( wmt.to_operation_seq_num > wmt.fm_operation_seq_num
10538 OR
10539 (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
10540 AND wmt.fm_intraoperation_step_type<=g_run
10541 AND wmt.to_intraoperation_step_type>g_run)
10542 )
10543 AND
10544 ( wop2.count_point_type < g_no_manual
10545 OR wop2.operation_seq_num = wmt.fm_operation_seq_num
10546 OR (wop2.operation_seq_num = wmt.to_operation_seq_num
10547 AND wmt.to_intraoperation_step_type > g_run)
10548 )
10549 )
10550 OR /* Backward Move */
10551 ( wop2.operation_seq_num < wmt.fm_operation_seq_num
10552 + DECODE(sign(wmt.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10553 AND
10554 wop2.operation_seq_num >= wmt.to_operation_seq_num
10555 + DECODE(sign(wmt.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10556 AND
10557 ( wmt.fm_operation_seq_num > wmt.to_operation_seq_num
10558 OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
10559 AND wmt.to_intraoperation_step_type<=g_run
10560 AND wmt.fm_intraoperation_step_type>g_run)
10561 )
10562 AND
10563 ( wop2.count_point_type < g_no_manual
10564 OR(wop2.operation_seq_num = wmt.to_operation_seq_num
10565 AND wop2.count_point_type < g_no_manual)
10566 OR(wop2.operation_seq_num = wmt.fm_operation_seq_num
10567 AND wmt.fm_intraoperation_step_type > g_run)
10568 )
10569 )
10570 )
10571 ));
10572
10573 IF (g_mrp_debug='Y') THEN
10574 fnd_file.put_line(fnd_file.log, 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') :
10575 Updated '||SQL%ROWCOUNT||' rows in WOY');
10576 END IF;
10577 /**********************************
10578 UPDATE WIP_OPERATION_YIELDS woy
10579 SET status = 1,
10580 last_update_date = sysdate,
10581 last_update_login = g_login_id,
10582 request_id = g_request_id,
10583 program_application_id= g_program_application_id,
10584 program_id = g_program_id,
10585 program_update_date = DECODE(g_request_id,NULL,NULL,SYSDATE)
10586 WHERE woy.rowid IN (
10587 SELECT woy2.rowid
10588 FROM WIP_OPERATIONS wop2,
10589 WIP_OPERATION_YIELDS woy2,
10590 WSM_PARAMETERS wp, -- ESA
10591 WIP_DISCRETE_JOBS wdj, -- NSLBJ
10592 WIP_MOVE_TXN_INTERFACE wti
10593 WHERE wti.group_id = l_wmti_group_id
10594 AND wti.process_phase = g_move_proc
10595 AND wti.process_status = g_running
10596 -- AND TRUNC(wti.transaction_date) = to_date(:l_temp_date, WCD_CANONICAL_DATE) --bugfix 2856703
10597 AND wp.organization_id = wti.organization_id -- ESA
10598 AND nvl(wp.ESTIMATED_SCRAP_ACCOUNTING, 1) = 1 -- ESA
10599 AND wdj.wip_entity_id = wti.wip_entity_id -- NSLBJ
10600 AND wdj.job_type <>3 -- NSLBJ
10601 AND wop2.organization_id = wti.organization_id
10602 AND wop2.wip_entity_id = wti.wip_entity_id
10603 AND woy2.organization_id = wti.organization_id
10604 AND woy2.wip_entity_id = wti.wip_entity_id
10605 AND woy2.operation_seq_num= wop2.operation_seq_num
10606 AND ( -- Forward Move
10607 ( wop2.operation_seq_num >= wti.fm_operation_seq_num
10608 + DECODE(sign(wti.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10609 AND
10610 wop2.operation_seq_num < wti.to_operation_seq_num
10611 + DECODE(sign(wti.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10612 AND
10613 ( wti.to_operation_seq_num > wti.fm_operation_seq_num
10614 OR
10615 (wti.to_operation_seq_num = wti.fm_operation_seq_num
10616 AND wti.fm_intraoperation_step_type<=g_run
10617 AND wti.to_intraoperation_step_type>g_run)
10618 )
10619 AND
10620 ( wop2.count_point_type < g_no_manual
10621 OR wop2.operation_seq_num = wti.fm_operation_seq_num
10622 OR (wop2.operation_seq_num = wti.to_operation_seq_num
10623 AND wti.to_intraoperation_step_type > g_run)
10624 )
10625 )
10626 OR --Backward Move
10627 ( wop2.operation_seq_num < wti.fm_operation_seq_num
10628 + DECODE(sign(wti.fm_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10629 AND
10630 wop2.operation_seq_num >= wti.to_operation_seq_num
10631 + DECODE(sign(wti.to_intraoperation_step_type-g_run), 0,0,-1,0,1,1)
10632 AND
10633 ( wti.fm_operation_seq_num > wti.to_operation_seq_num
10634 OR (wti.fm_operation_seq_num = wti.to_operation_seq_num
10635 AND wti.to_intraoperation_step_type<=g_run
10636 AND wti.fm_intraoperation_step_type>g_run)
10637 )
10638 AND
10639 ( wop2.count_point_type < g_no_manual
10640 OR(wop2.operation_seq_num = wti.to_operation_seq_num
10641 AND wop2.count_point_type < g_no_manual)
10642 OR(wop2.operation_seq_num = wti.fm_operation_seq_num
10643 AND wti.fm_intraoperation_step_type > g_run)
10644 )
10645 )
10646 )
10647 );
10648 *****************************/
10649
10650
10651 /* BA: CZH.JUMPENH, new UNDO logic */
10652 l_stmt_num := 280;
10653 if (l_undo_exists=1) THEN /* For undo transaction, set the wsm_undo_txn_id */
10654
10655 DECLARE
10656 CURSOR undo_txns IS
10657 SELECT wlmti.transaction_id,
10658 wlmti.organization_id,
10659 wlmti.wip_entity_id,
10660 wlmti.fm_operation_seq_num,
10661 wlmti.to_operation_seq_num,
10662 wlmti.to_intraoperation_step_type,
10663 wlmti.fm_intraoperation_step_type,
10664 wlmti.scrap_quantity,
10665 wlmti.source_code --Added for bug 5480482
10666 FROM wsm_lot_move_txn_interface wlmti
10667 WHERE wlmti.group_id = p_group_id
10668 AND wlmti.status = 4
10669 AND wlmti.transaction_type = 4
10670 --move enh 115.135 changed the AND clause for performance
10671 --mes commented out the following and added subsequent lines
10672 -- AND wlmti.internal_group_id = l_wmti_group_id;
10673 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10674 'move in oa page', wlmti.transaction_id,
10675 'move out oa page', wlmti.transaction_id,
10676 'move to next op oa page', wlmti.transaction_id,
10677 'jump oa page', wlmti.transaction_id,
10678 'undo oa page', wlmti.transaction_id,
10679 l_wmti_group_id)
10680 )
10681 /*********
10682 OR
10683 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10684 'move in oa page', wlmti.internal_scrap_txn_id,
10685 'move out oa page', wlmti.internal_scrap_txn_id,
10686 'move to next op oa page', wlmti.internal_scrap_txn_id,
10687 'jump oa page', wlmti.internal_scrap_txn_id,
10688 'undo oa page', wlmti.internal_scrap_txn_id,
10689 l_wmti_group_id)
10690 )
10691 *********/
10692 );
10693 -- AND wlmti.transaction_id IN (SELECT wmt.batch_id
10694 -- FROM wip_move_transactions wmt
10695 -- WHERE wmt.group_id = l_wmti_group_id);
10696
10697 l_dup_flag NUMBER :=0;
10698 undo_jump_from_queue BOOLEAN := FALSE;
10699 BEGIN
10700 --move enh
10701 FOR rec IN undo_txns LOOP
10702 IF (rec.fm_operation_seq_num <> rec.to_operation_seq_num
10703 AND rec.to_intraoperation_step_type=1
10704 AND l_charge_jump_from_queue=2) THEN
10705 undo_jump_from_queue:=TRUE;
10706 END IF;
10707
10708 x_return_code := WSMPLBMI.set_undo_txn_id(
10709 rec.organization_id,
10710 rec.wip_entity_id,
10711 --mes replacing l_undo_txn_id with rec.transaction_id
10712 --l_undo_txn_id,
10713 rec.transaction_id,
10714 rec.to_operation_seq_num,
10715 undo_jump_from_queue,
10716 x_err_msg);
10717 -- ST : Serial Support Project --
10718 -- Add code here to clear the WDJ if serialization is ended...
10719 UPDATE wip_discrete_jobs wdj
10720 SET wdj.serialization_start_op = null
10721 where wdj.wip_entity_id = rec.wip_entity_id
10722 and wdj.wip_entity_id IN (select wlbj.wip_entity_id
10723 from wsm_lot_based_jobs wlbj
10724 where wlbj.wip_entity_id = rec.wip_entity_id
10725 and first_serial_txn_id IS NULL);
10726 -- ST : Serial Support Project --
10727 --Bug 5480482:Start of changes
10728 if nvl(rec.source_code,'interface') = 'undo oa page' then
10729 UPDATE WIP_DISCRETE_JOBS wdj
10730 SET actual_start_date = null,
10731 LAST_UPDATE_DATE = sysdate,
10732 LAST_UPDATED_BY = g_user_id
10733 WHERE wip_entity_id = rec.wip_entity_id
10734 and not exists (select 1 from wip_move_transactions wmt
10735 where wmt.wip_entity_id = wdj.wip_entity_id
10736 and wmt.organization_id = wdj.organization_id
10737 and wmt.wsm_undo_txn_id is NULL);
10738 end if;--End of check on source_code.
10739 --Bug 5480482EndStart of changes
10740 END LOOP;
10741 END;
10742
10743 IF (g_mrp_debug='Y') THEN
10744 fnd_file.put_line(fnd_file.log, 'set_undo_txn_id undo_txn_id= '||l_undo_txn_id);
10745 END IF;
10746
10747 IF (x_return_code <> 0) THEN
10748 fnd_file.put_line(fnd_file.log, 'wip_move_transactions: set wsm_undo_txn_id failed');
10749 END IF;
10750
10751 END IF; /* End of if (undo_exists) */
10752 /* EA: CZH.JUMPENH */
10753
10754 l_stmt_num := 290;
10755 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10756 l_msg_tokens.delete;
10757 WSM_log_PVT.logMessage (
10758 p_module_name => l_module,
10759 p_msg_text => 'b4 IF (l_ac_ar_exists=1) '||
10760 ' l_ac_ar_exists '||l_ac_ar_exists,
10761 p_stmt_num => l_stmt_num,
10762 p_msg_tokens => l_msg_tokens,
10763 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10764 p_run_log_level => l_log_level
10765 );
10766 END IF;
10767
10768 IF (l_ac_ar_exists=1) THEN /* Assy completion/return exists */
10769 DECLARE
10770 CURSOR ac_ar_txns IS
10771 SELECT wlmti.new_wip_entity_name,
10772 wlmti.organization_id, -- CZH.BUG2282570
10773 wlmti.wip_entity_id,
10774 wlmti.header_id,
10775 wlmti.transaction_type, -- CZH.BUG2282570
10776 wlmti.transaction_id,
10777 wlmti.to_operation_seq_num,
10778 wlmti.fm_intraoperation_step_type,
10779 wlmti.scrap_quantity,
10780 wlmti.transaction_quantity,
10781 wlmti.source_code
10782 FROM wsm_lot_move_txn_interface wlmti
10783 WHERE wlmti.group_id = p_group_id
10784 AND wlmti.status = 4
10785 /* Added condition to fix bug #1815584 */
10786 AND wlmti.transaction_type in (2,3)
10787 /* Assy Completion/return */
10788 AND wlmti.new_wip_entity_name is NOT NULL
10789 --move enh 115.135 changed the AND clause for performance
10790 --mes commented out the following and added subsequent lines
10791 -- AND wlmti.internal_group_id = l_wmti_group_id;
10792 AND ( (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10793 'move in oa page', wlmti.transaction_id,
10794 'move out oa page', wlmti.transaction_id,
10795 'move to next op oa page', wlmti.transaction_id,
10796 'jump oa page', wlmti.transaction_id,
10797 'undo oa page', wlmti.transaction_id,
10798 l_wmti_group_id)
10799 )
10800 OR
10801 (wlmti.internal_group_id = decode(wlmti.SOURCE_CODE,
10802 'move in oa page', wlmti.internal_scrap_txn_id,
10803 'move out oa page', wlmti.internal_scrap_txn_id,
10804 'move to next op oa page', wlmti.internal_scrap_txn_id,
10805 'jump oa page', wlmti.internal_scrap_txn_id,
10806 'undo oa page', wlmti.internal_scrap_txn_id,
10807 l_wmti_group_id)
10808 )
10809 );
10810 -- AND wlmti.transaction_id IN (SELECT wmt.batch_id
10811 -- FROM wip_move_transactions wmt
10812 -- WHERE wmt.group_id = l_wmti_group_id);
10813 BEGIN
10814 FOR rec IN ac_ar_txns LOOP
10815
10816 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
10817 l_msg_tokens.delete;
10818 WSM_log_PVT.logMessage (
10819 p_module_name => l_module,
10820 p_msg_text => 'b4 UPDATE wip_entities '||
10821 ' rec.new_wip_entity_name '||rec.new_wip_entity_name||
10822 ' rec.wip_entity_id '||rec.wip_entity_id,
10823 p_stmt_num => l_stmt_num,
10824 p_msg_tokens => l_msg_tokens,
10825 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
10826 p_run_log_level => l_log_level
10827 );
10828 END IF;
10829
10830 l_dup_flag:=0;
10831
10832 UPDATE wip_entities
10833 SET wip_entity_name = rec.new_wip_entity_name
10834 WHERE wip_entity_id = rec.wip_entity_id;
10835
10836
10837
10838 IF (SQL%ROWCOUNT=0) THEN
10839 fnd_file.put_line(fnd_file.log, 'wip_entities : Update failed '||l_new_jobname);
10840 ELSE
10841 IF (g_mrp_debug='Y') THEN
10842 fnd_file.put_line(fnd_file.log, 'updated wip_entity_id= '||l_wip_entity_id||' with the new_job_name '||l_new_jobname);
10843 END IF;
10844 END IF;
10845
10846 l_stmt_num := 290;
10847 /* BA: CZH.BUG2282570 */
10848 /* for UNDO, set WMT.wsm_undo_txn_id */
10849 IF (rec.transaction_type = 3) THEN
10850 x_return_code := WSMPLBMI.set_undo_txn_id(rec.organization_id,
10851 rec.wip_entity_id,
10852 rec.transaction_id,
10853 x_err_msg);
10854
10855 -- ST : Serial Support Project --
10856 -- Add code here to clear the WDJ if serialization is ended...
10857 UPDATE wip_discrete_jobs wdj
10858 SET wdj.serialization_start_op = null
10859 where wdj.wip_entity_id = rec.wip_entity_id
10860 and wdj.wip_entity_id IN (select wlbj.wip_entity_id
10861 from wsm_lot_based_jobs wlbj
10862 where wlbj.wip_entity_id = rec.wip_entity_id
10863 and first_serial_txn_id IS NULL);
10864 -- ST : Serial Support Project --
10865 --Bug 5480482:Start of changes
10866 if nvl(rec.source_code,'interface') = 'undo oa page' then
10867 UPDATE WIP_DISCRETE_JOBS wdj
10868 SET actual_start_date = null,
10869 LAST_UPDATE_DATE = sysdate,
10870 LAST_UPDATED_BY = g_user_id
10871 WHERE wip_entity_id = rec.wip_entity_id
10872 and not exists (select 1 from wip_move_transactions wmt
10873 where wmt.wip_entity_id = wdj.wip_entity_id
10874 and wmt.organization_id = wdj.organization_id
10875 and wmt.wsm_undo_txn_id is NULL);
10876 end if;--End of check on source_code.
10877 --Bug 5480482EndStart of changes
10878
10879
10880 END IF;
10881
10882 IF (g_mrp_debug='Y') THEN
10883 fnd_file.put_line(fnd_file.log, 'set_undo_txn_id undo_txn_id= '||l_batch_id);
10884 END IF;
10885
10886 IF (x_return_code <> 0) THEN
10887 fnd_file.put_line(fnd_file.log, 'wip_move_transactions: set wsm_undo_txn_id failed');
10888 END IF;
10889 -- Commented for bug 5286219. Code for trf reservation during return txn will be present
10890 -- before we call move processor.
10891 /*
10892 IF (rec.transaction_type = 3)THEN --not normal move or undo
10893 declare
10894 l_rsv_exists BOOLEAN;
10895 l_net_quantity NUMBER;
10896 l_primary_item_id NUMBER;
10897 l_msg_count NUMBER;
10898 l_msg_data VARCHAR2(2000);
10899 begin
10900 select net_quantity,primary_item_id
10901 into l_net_quantity,l_primary_item_id
10902 from wip_discrete_jobs
10903 where wip_entity_id=rec.wip_entity_id
10904 and organization_id=rec.organization_id;
10905 l_stmt_num := 290.1;
10906 wsm_reservations_pvt.modify_reservations_move(
10907 p_wip_entity_id => rec.wip_entity_id,
10908 P_inventory_item_id => l_primary_item_id,
10909 P_org_id => rec.organization_id,
10910 P_txn_type => 3,
10911 p_net_qty => l_net_quantity,
10912 x_return_status => l_return_status,
10913 x_msg_count => l_msg_count,
10914 x_msg_data => l_msg_data
10915 );
10916 IF(l_return_status <> 'S') THEN
10917 raise e_proc_exception;
10918 END IF;
10919
10920 END;
10921 End if;
10922 */
10923
10924 -- END IF;
10925 /* EA: CZH.BUG2282570 */
10926
10927 END LOOP;/* End of While */
10928 END;
10929
10930 END IF; /* End if of Assy completion/return exists */
10931
10932 -- ST : Serial Project --
10933 -- Time to update the serial attributes back to the original value after being cleared by the WIP processor...
10934 if nvl(p_source_code, 'interface') = 'interface' then --Added for Bug 5368120
10935 DECLARE
10936 l_return_status VARCHAR2(1);
10937 l_error_msg VARCHAR2(2000);
10938 l_error_count NUMBER;
10939 l_move_txn_id NUMBER := null;
10940 l_group_id NUMBER := null;
10941 l_scrap_id NUMBER := null;
10942 l_internal_group_id NUMBER := null;
10943 BEGIN
10944 --Bug 5368120: For MES,call to update_attr_move is handled inside inner loop.
10945 -- Hence the following code is commented out.
10946 -- ST : Serial MES Fix : Added this code since p_group_id and l_wmti_group_id arent used for MES
10947 --IF nvl(p_source_code, 'interface') IN ('move in oa page', 'move out oa page', 'move to next op oa page',
10948 -- 'jump oa page', 'undo oa page' )
10949 --THEN
10950 -- l_move_txn_id := l_transaction_id;
10951 -- l_scrap_id := l_scrap_txn_id ;
10952 --ELSE
10953 -- normal interface code..
10954 l_group_id := p_group_id;
10955 l_internal_group_id := l_wmti_group_id;
10956 --END IF;
10957 -- ST : Serial MES Fix : End
10958
10959 WSM_Serial_support_PVT.Update_attr_move( p_group_id => l_group_id ,
10960 p_internal_group_id => l_internal_group_id ,
10961 p_move_txn_id => l_move_txn_id ,
10962 p_scrap_txn_id => l_scrap_id ,
10963 -- Pass the org as NULL since can process across orgs...
10964 p_organization_id => null ,
10965 x_return_status => l_return_status ,
10966 x_error_count => l_error_count ,
10967 x_error_msg => l_error_msg
10968 );
10969
10970 if l_return_status = FND_API.G_RET_STS_SUCCESS then
10971 IF (l_debug='Y') THEN
10972 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned Success');
10973 END IF;
10974 ELSE
10975 IF (l_error_count = 1) THEN
10976 fnd_file.put_line(fnd_file.log, l_error_msg);
10977 ELSIF (l_error_count > 1) THEN
10978 FOR i IN 1..l_error_count LOOP
10979 l_error_msg := fnd_msg_pub.get( p_msg_index => l_error_count - i + 1,
10980 p_encoded => FND_API.G_FALSE
10981 );
10982 fnd_file.put_line(fnd_file.log, l_error_msg);
10983 END LOOP;
10984 ELSE
10985 l_error_msg := 'WSM_Serial_support_PVT.Update_attr_move returned failure';
10986 END IF;
10987
10988 IF (l_debug='Y') THEN
10989 fnd_file.put_line(fnd_file.log, 'WSM_Serial_support_PVT.Update_attr_move returned failure');
10990 END IF;
10991 -- This call is supposed to not return any error...
10992 raise e_proc_exception;
10993
10994 END IF;
10995 END;
10996 end if; --End of check on p_source_code added for bug 5368120.
10997 -- ST : Serial Project --
10998
10999 l_stmt_num := 300;
11000 l_del_profile_value := fnd_profile.value('WSM_INTERFACE_HISTORY_DAYS');
11001
11002 -- ST : Serial Support Project --
11003 -- User inserted records...
11004
11005 -- DELETE wsm_serial_txn_interface
11006 -- WHERE header_id in (SELECT header_id
11007 -- from wsm_lot_move_txn_interface wlmti
11008 -- WHERE group_id = l_wmti_group_id
11009 -- and status = WIP_CONSTANTS.COMPLETED
11010 -- AND transaction_date <= decode(l_del_profile_value, NULL,
11011 -- transaction_date-1, SYSDATE-l_del_profile_value)
11012 -- )
11013 -- AND action_flag in (1,2,3,4,5,6)
11014 -- and transaction_type_id = 2;
11015 --
11016 -- -- Delete the inserted records for Attributes...
11017 -- DELETE wsm_serial_txn_interface
11018 -- WHERE header_id IN (Select wmt.transaction_id
11019 -- from wip_move_transactions wmt,
11020 -- wsm_lot_move_txn_interface wlmti
11021 -- where wlmti.group_id = l_wmti_group_id
11022 -- and wlmti.wip_entity_id = wmt.wip_entity_id
11023 -- and wlmti.status = WIP_CONSTANTS.COMPLETED)
11024 -- AND transaction_type_id = 5;
11025 -- ST : Serial Support Project --
11026
11027 DELETE wsm_lot_move_txn_interface wlmti
11028 WHERE status = WIP_CONSTANTS.COMPLETED
11029 AND transaction_date <= decode(l_del_profile_value, NULL,
11030 transaction_date-1, SYSDATE-l_del_profile_value)
11031 RETURNING header_id BULK COLLECT INTO l_header_id_tbl;
11032
11033 -- ST : Serial Support Project --
11034 -- User inserted records...
11035 IF l_header_id_tbl.count > 0 THEN
11036 forall l_index in l_header_id_tbl.first..l_header_id_tbl.last
11037 DELETE wsm_serial_txn_interface
11038 WHERE header_id = l_header_id_tbl(l_index)
11039 AND transaction_type_id = 2;
11040 END IF;
11041 -- ST : Serial Support Project --
11042
11043 /* commit for every successful set of records in the inner loop */
11044 --mes
11045 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11046 COMMIT;
11047 END IF;
11048 END LOOP;/* end outer_loop */
11049 <<outer_loop>>
11050 /****************************
11051 --mes
11052 BEGIN
11053 UPDATE WIP_OPERATIONS
11054 SET wsm_costed_quantity_completed = quantity_completed
11055 WHERE ROWID IN
11056 (SELECT WO.ROWID
11057 FROM WIP_OPERATIONS WO, WIP_MOVE_TRANSACTIONS WMT, WSM_LOT_MOVE_TXN_INTERFACE WLMTI
11058 WHERE WLMTI.group_id = p_group_id
11059 AND WMT.transaction_id = WLMTI.transaction_id
11060 AND WO.wip_entity_id = WMT.wip_entity_id
11061 AND (WO.operation_seq_num IN (WMT.fm_operation_seq_num, WMT.to_operation_seq_num))
11062 AND NOT (
11063 (nvl(WO.quantity_waiting_to_move, 0) <> 0)
11064 AND
11065 (EXISTS (SELECT WSMT.ROWID
11066 FROM WSM_SPLIT_MERGE_TRANSACTIONS WSMT,
11067 WSM_SM_RESULTING_JOBS WSRJ
11068 WHERE WSRJ.wip_entity_id = WO.wip_entity_id
11069 AND WSRJ.starting_operation_seq_num = WO.operation_seq_num
11070 AND WSRJ.starting_intraoperation_step = g_tomove
11071 AND WSRJ.transaction_id = WSMT.transaction_id
11072 )
11073 )
11074 )
11075 );
11076
11077 END;
11078 *****************************/
11079 --mes
11080 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11081 COMMIT;
11082 END IF;
11083 --mes end
11084 l_stmt_num := 320;
11085
11086 DECLARE
11087 CONC_STATUS BOOLEAN;
11088 l_tot_count NUMBER := l_total_txns;
11089 l_err_count NUMBER;
11090
11091 BEGIN
11092 SELECT count(*)
11093 INTO l_err_count
11094 FROM wsm_lot_move_txn_interface
11095 WHERE group_id = p_group_id
11096 AND status = 3;
11097
11098 IF (l_debug = 'Y') THEN
11099 FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_err_count '||l_err_count);
11100 FND_FILE.PUT_LINE(FND_FILE.LOG, 'l_total_txns '||l_total_txns);
11101 END IF;
11102
11103 IF (l_tot_count = l_err_count AND l_tot_count <>0) THEN
11104 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11105 'Errors encountered in interface txn, '
11106 || 'please check the log file.');
11107 -- Added to fix bug 1815584 - moved here from error_handler
11108 ELSIF (l_err_count > 0) THEN
11109 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('WARNING',
11110 'Errors encountered in interface txn, '
11111 || 'please check the log file.');
11112 -- End additions to fix bug 1815584
11113 ELSIF ((l_err_count = 0) AND (l_tot_count = 0)) THEN
11114 CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('COMPLETE', null);
11115 END IF;
11116 END;
11117
11118 /*Changes for skaradib*/
11119 --move enh 115.135 added IF condn after perf check
11120 IF (g_aps_wps_profile='N') THEN
11121 l_stmt_num := 330;
11122 DECLARE
11123 x_group_id NUMBER;
11124 BEGIN
11125 x_group_id := WSMPWROT.GET_EXPLOSION_GROUP_ID;
11126 DELETE from BOM_EXPLOSION_TEMP
11127 WHERE group_id = x_group_id;
11128
11129 WSMPWROT.SET_EXPLOSION_GROUP_ID_NULL;
11130 COMMIT;
11131 END;
11132 END IF;
11133
11134 /*Changes for skaradib*/
11135
11136 l_stmt_num := 340;
11137 IF (g_mrp_debug='Y') THEN
11138 fnd_file.put_line(fnd_file.log,'WSMPLBMI.MoveTransaction Successful ');
11139 END IF;
11140
11141 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11142 l_msg_tokens.delete;
11143 WSM_log_PVT.logMessage (
11144 p_module_name => l_module ,
11145 p_msg_text => 'End MoveTransactions Main',
11146 p_stmt_num => l_stmt_num ,
11147 p_msg_tokens => l_msg_tokens ,
11148 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11149 p_run_log_level => l_log_level
11150 );
11151 END IF;
11152
11153 EXCEPTION
11154 WHEN FND_API.G_EXC_ERROR THEN
11155 IF (x_return_status = g_ret_success) THEN
11156 l_msg_tokens.delete;
11157 WSM_log_PVT.logMessage (
11158 p_module_name => l_module,
11159 p_msg_text => 'inside WHEN FND_API.G_EXC_ERROR THEN',
11160 p_stmt_num => l_stmt_num,
11161 p_msg_tokens => l_msg_tokens,
11162 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11163 p_run_log_level => l_log_level
11164 );
11165 END IF;
11166 retcode := 1;
11167 ROLLBACK;
11168 UPDATE wsm_lot_move_txn_interface WLMTI
11169 SET WLMTI.ERROR = 'Error WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||')',
11170 WLMTI.STATUS = g_error,
11171 WLMTI.LAST_UPDATE_DATE = SYSDATE
11172 WHERE WLMTI.GROUP_ID = p_group_id
11173 AND WLMTI.STATUS in (g_pending, g_running) ;
11174
11175 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11176 IF (x_return_status = g_ret_success) THEN
11177 l_msg_tokens.delete;
11178 WSM_log_PVT.logMessage (
11179 p_module_name => l_module,
11180 p_msg_text => 'inside WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN',
11181 p_stmt_num => l_stmt_num,
11182 p_msg_tokens => l_msg_tokens,
11183 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11184 p_run_log_level => l_log_level
11185 );
11186 END IF;
11187 retcode := -1;
11188 ROLLBACK;
11189 UPDATE wsm_lot_move_txn_interface WLMTI
11190 SET WLMTI.ERROR = 'Error WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||')',
11191 WLMTI.STATUS = g_error,
11192 WLMTI.LAST_UPDATE_DATE = SYSDATE
11193 WHERE WLMTI.GROUP_ID = p_group_id
11194 AND WLMTI.STATUS in (g_pending, g_running) ;
11195
11196 WHEN e_proc_exception THEN
11197
11198 retcode := -1;
11199 errbuf := 'WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') : '||x_error_msg;
11200 fnd_file.put_line(fnd_file.log, errbuf);
11201 ROLLBACK;
11202
11203 UPDATE wsm_lot_move_txn_interface WLMTI
11204 SET WLMTI.ERROR = substrb('Error:' ||errbuf, 1, 2000),
11205 WLMTI.STATUS = g_error,
11206 WLMTI.LAST_UPDATE_DATE = SYSDATE
11207 WHERE WLMTI.GROUP_ID = p_group_id
11208 AND WLMTI.STATUS in (g_pending, g_running) ;
11209
11210 IF (g_mrp_debug='Y') THEN
11211 fnd_file.put_line(fnd_file.log, 'Updated # of txns: '||SQL%ROWCOUNT||' (set WLMTI.error = ErrorMsg)'); /* bugfix 2721366 */
11212 END IF;
11213
11214 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11215 'errors encountered in interface txn, please check the log file.');
11216
11217 --mes
11218 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11219 COMMIT;
11220 END IF;
11221
11222 WHEN my_exception THEN
11223
11224 l_CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('COMPLETE', null);
11225 ROLLBACK;
11226 --COMMIT;
11227
11228 WHEN OTHERS THEN
11229 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
11230 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
11231 THEN
11232 WSM_log_PVT.handle_others(
11233 p_module_name => l_module ,
11234 p_stmt_num => l_stmt_num ,
11235 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
11236 p_run_log_level => l_log_level
11237 );
11238 END IF;
11239
11240 retcode := SQLCODE;
11241 errbuf :='WSMPLBMI.MoveTransaction' ||'(stmt_num='||l_stmt_num||') : '||sqlerrm;
11242 fnd_file.put_line(fnd_file.log, errbuf);
11243 ROLLBACK;
11244
11245 UPDATE wsm_lot_move_txn_interface WLMTI
11246 SET WLMTI.ERROR = substrb('Unexpected SQL Error:' ||errbuf, 1, 2000),
11247 WLMTI.STATUS = g_error,
11248 WLMTI.LAST_UPDATE_DATE = SYSDATE
11249 WHERE WLMTI.GROUP_ID = p_group_id
11250 AND WLMTI.STATUS in (g_pending, g_running) ;
11251
11252 IF (g_mrp_debug='Y') THEN
11253 fnd_file.put_line(fnd_file.log, 'Updated # of txns: '||SQL%ROWCOUNT||' (set WLMTI.error = ErrorMsg)'); /* bugfix 2721366 */
11254 END IF;
11255
11256 l_conc_status := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',
11257 'errors encountered in interface txn, please check the log file.');
11258
11259 --mes
11260 IF (nvl(p_source_code, 'interface') = 'interface') THEN
11261 COMMIT;
11262 END IF;
11263
11264 END MoveTransaction;
11265
11266 /****************************************************************************
11267 Called from Move Out page via Rosetta wrapper for processing Move Transaction. This in turn inserts
11268 the data into the interface table and calls the overloaded MoveTransaction procedure.
11269 ****************************************************************************/
11270
11271 Procedure MoveTransaction(
11272 p_group_id IN NUMBER,
11273 p_transaction_id IN NUMBER,
11274 p_source_code IN VARCHAR2,
11275 p_TRANSACTION_TYPE IN NUMBER,
11276 p_ORGANIZATION_ID IN NUMBER,
11277 p_WIP_ENTITY_ID IN NUMBER,
11278 p_WIP_ENTITY_NAME IN VARCHAR2,
11279 p_primary_item_id IN NUMBER,
11280 p_TRANSACTION_DATE IN DATE,
11281 p_FM_OPERATION_SEQ_NUM IN NUMBER,
11282 p_FM_OPERATION_CODE IN VARCHAR2,
11283 p_FM_DEPARTMENT_ID IN NUMBER,
11284 p_FM_DEPARTMENT_CODE IN VARCHAR2,
11285 p_FM_INTRAOPERATION_STEP_TYPE IN NUMBER,
11286 p_TO_OPERATION_SEQ_NUM IN NUMBER,
11287 p_TO_OPERATION_CODE IN VARCHAR2,
11288 p_TO_DEPARTMENT_ID IN NUMBER,
11289 p_TO_DEPARTMENT_CODE IN VARCHAR2,
11290 p_TO_INTRAOPERATION_STEP_TYPE IN NUMBER,
11291 p_PRIMARY_QUANTITY IN NUMBER,
11292 p_low_yield_trigger_limit IN NUMBER,
11293 p_primary_uom IN VARCHAR2,
11294 p_SCRAP_ACCOUNT_ID IN NUMBER,
11295 p_REASON_ID IN NUMBER,
11296 p_REASON_NAME IN VARCHAR2,
11297 p_REFERENCE IN VARCHAR2,
11298 p_QA_COLLECTION_ID IN NUMBER,
11299 p_JUMP_FLAG IN VARCHAR2,
11300 p_HEADER_ID IN NUMBER,
11301 p_PRIMARY_SCRAP_QUANTITY IN NUMBER,
11302 p_bonus_quantity IN NUMBER,
11303 p_SCRAP_AT_OPERATION_FLAG IN NUMBER,
11304 p_bonus_account_id IN NUMBER,
11305 p_employee_id IN NUMBER,
11306 p_operation_start_date IN DATE,
11307 p_operation_completion_date IN DATE,
11308 p_expected_completion_date IN DATE,
11309 p_mtl_txn_hdr_id IN NUMBER,
11310 p_sec_uom_code_tbl IN t_sec_uom_code_tbl_type,
11311 p_sec_move_out_qty_tbl IN t_sec_move_out_qty_tbl_type,
11312 p_jobop_scrap_serials_tbl IN WSM_Serial_support_GRP.WSM_SERIAL_NUM_TBL,
11313 p_jobop_bonus_serials_tbl IN WSM_Serial_support_GRP.WSM_SERIAL_NUM_TBL,
11314 p_scrap_codes_tbl IN t_scrap_codes_tbl_type,
11315 p_scrap_code_qty_tbl IN t_scrap_code_qty_tbl_type,
11316 p_bonus_codes_tbl IN t_bonus_codes_tbl_type,
11317 p_bonus_code_qty_tbl IN t_bonus_code_qty_tbl_type,
11318 p_jobop_resource_usages_tbl IN t_jobop_res_usages_tbl_type,
11319 x_wip_move_api_sucess_msg OUT NOCOPY VARCHAR2
11320 , x_return_status OUT NOCOPY VARCHAR2
11321 , x_msg_count OUT NOCOPY NUMBER
11322 , x_msg_data OUT NOCOPY VARCHAR2
11323 )
11324 IS
11325 l_sec_uom_code_tbls t_sec_uom_code_tbls_type;
11326 l_sec_move_out_qty_tbls t_sec_move_out_qty_tbls_type;
11327 l_scrap_codes_tbls t_scrap_codes_tbls_type;
11328 l_scrap_code_qty_tbls t_scrap_code_qty_tbls_type;
11329 l_bonus_codes_tbls t_bonus_codes_tbls_type;
11330 l_bonus_code_qty_tbls t_bonus_code_qty_tbls_type;
11331 l_jobop_scrap_serials_tbls t_scrap_serials_tbls_type ;
11332 l_jobop_bonus_serials_tbls t_bonus_serials_tbls_type ;
11333 l_jobop_resource_usages_tbls t_jobop_res_usages_tbls_type;
11334
11335 l_transaction_id NUMBER;
11336 l_group_id NUMBER;
11337 l_header_id NUMBER;
11338 TYPE t_err_msg_tbl_type IS TABLE OF VARCHAR2(240);
11339 l_err_msg_tbl t_err_msg_tbl_type;
11340 l_stmt_num NUMBER;
11341 retcode NUMBER;
11342 errbuf VARCHAR2(4000);
11343 x_message VARCHAR2(4000);
11344 x_msg_index NUMBER;
11345
11346 -- Logging variables.....
11347 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
11348 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
11349 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.MoveTransactions.html';
11350 l_param_tbl WSM_Log_PVT.param_tbl_type;
11351 x_error_count NUMBER;
11352 x_return_code NUMBER;
11353 x_error_msg VARCHAR2(4000);
11354 BEGIN
11355 x_return_status := G_RET_SUCCESS;
11356 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11357 l_msg_tokens.delete;
11358 WSM_log_PVT.logMessage (
11359 p_module_name => l_module ,
11360 p_msg_text => 'Begin MoveTransactions html',
11361 p_stmt_num => l_stmt_num ,
11362 p_msg_tokens => l_msg_tokens ,
11363 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11364 p_run_log_level => l_log_level
11365 );
11366 END IF;
11367
11368 IF G_LOG_LEVEL_PROCEDURE >= l_log_level THEN
11369
11370 l_param_tbl.delete;
11371 l_param_tbl(1).paramName := 'p_group_id';
11372 l_param_tbl(1).paramValue := p_group_id;
11373 l_param_tbl(2).paramName := 'p_transaction_id';
11374 l_param_tbl(2).paramValue := p_transaction_id;
11375 l_param_tbl(3).paramName := 'p_source_code';
11376 l_param_tbl(3).paramValue := p_source_code;
11377 l_param_tbl(4).paramName := 'p_transaction_type';
11378 l_param_tbl(4).paramValue := p_transaction_type;
11379 l_param_tbl(5).paramName := 'p_organization_id';
11380 l_param_tbl(5).paramValue := p_organization_id;
11381 l_param_tbl(6).paramName := 'p_wip_entity_id';
11382 l_param_tbl(6).paramValue := p_wip_entity_id;
11383 l_param_tbl(7).paramName := 'p_wip_entity_name';
11384 l_param_tbl(7).paramValue := p_wip_entity_name;
11385 l_param_tbl(8).paramName := 'p_primary_item_id';
11386 l_param_tbl(8).paramValue := p_primary_item_id;
11387 l_param_tbl(9).paramName := 'p_transaction_date';
11388 l_param_tbl(9).paramValue := p_transaction_date;
11389 l_param_tbl(10).paramName := 'p_fm_operation_seq_num';
11390 l_param_tbl(10).paramValue := p_fm_operation_seq_num;
11391 l_param_tbl(11).paramName := 'p_fm_operation_code';
11392 l_param_tbl(11).paramValue := p_fm_operation_code;
11393 l_param_tbl(12).paramName := 'p_fm_department_id';
11394 l_param_tbl(12).paramValue := p_fm_department_id;
11395 l_param_tbl(13).paramName := 'p_fm_department_code';
11396 l_param_tbl(13).paramValue := p_fm_department_code;
11397 l_param_tbl(14).paramName := 'p_fm_intraoperation_step_type';
11398 l_param_tbl(14).paramValue := p_fm_intraoperation_step_type;
11399 l_param_tbl(15).paramName := 'p_to_operation_seq_num';
11400 l_param_tbl(15).paramValue := p_to_operation_seq_num;
11401 l_param_tbl(16).paramName := 'p_to_operation_code';
11402 l_param_tbl(16).paramValue := p_to_operation_code;
11403 l_param_tbl(17).paramName := 'p_to_department_id';
11404 l_param_tbl(17).paramValue := p_to_department_id;
11405 l_param_tbl(18).paramName := 'p_to_department_code';
11406 l_param_tbl(18).paramValue := p_to_department_code;
11407 l_param_tbl(19).paramName := 'p_to_intraoperation_step_type';
11408 l_param_tbl(19).paramValue := p_to_intraoperation_step_type;
11409 l_param_tbl(20).paramName := 'p_primary_quantity';
11410 l_param_tbl(20).paramValue := p_primary_quantity;
11411 l_param_tbl(21).paramName := 'p_low_yield_trigger_limit';
11412 l_param_tbl(21).paramValue := p_low_yield_trigger_limit;
11413 l_param_tbl(22).paramName := 'p_primary_uom';
11414 l_param_tbl(22).paramValue := p_primary_uom;
11415 l_param_tbl(23).paramName := 'p_scrap_account_id';
11416 l_param_tbl(23).paramValue := p_scrap_account_id;
11417 l_param_tbl(24).paramName := 'p_reason_id';
11418 l_param_tbl(24).paramValue := p_reason_id;
11419 l_param_tbl(25).paramName := 'p_reason_name';
11420 l_param_tbl(25).paramValue := p_reason_name;
11421 l_param_tbl(26).paramName := 'p_reference';
11422 l_param_tbl(26).paramValue := p_reference;
11423 l_param_tbl(27).paramName := 'p_qa_collection_id';
11424 l_param_tbl(27).paramValue := p_qa_collection_id;
11425 l_param_tbl(28).paramName := 'p_jump_flag';
11426 l_param_tbl(28).paramValue := p_jump_flag;
11427 l_param_tbl(29).paramName := 'p_header_id';
11428 l_param_tbl(29).paramValue := p_header_id;
11429 l_param_tbl(30).paramName := 'p_primary_scrap_quantity';
11430 l_param_tbl(30).paramValue := p_primary_scrap_quantity;
11431 l_param_tbl(31).paramName := 'p_bonus_quantity';
11432 l_param_tbl(31).paramValue := p_bonus_quantity;
11433 l_param_tbl(32).paramName := 'p_scrap_at_operation_flag';
11434 l_param_tbl(32).paramValue := p_scrap_at_operation_flag;
11435 l_param_tbl(33).paramName := 'p_bonus_account_id';
11436 l_param_tbl(33).paramValue := p_bonus_account_id;
11437 l_param_tbl(34).paramName := 'p_employee_id';
11438 l_param_tbl(34).paramValue := p_employee_id;
11439 l_param_tbl(35).paramName := 'p_operation_start_date';
11440 l_param_tbl(35).paramValue := p_operation_start_date;
11441 l_param_tbl(36).paramName := 'p_operation_completion_date';
11442 l_param_tbl(36).paramValue := p_operation_completion_date;
11443 l_param_tbl(37).paramName := 'p_expected_completion_date';
11444 l_param_tbl(37).paramValue := p_expected_completion_date;
11445 l_param_tbl(38).paramName := 'p_mtl_txn_hdr_id';
11446 l_param_tbl(38).paramValue := p_mtl_txn_hdr_id;
11447
11448 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
11449 p_param_tbl => l_param_tbl,
11450 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE
11451 );
11452 END IF;
11453
11454 l_stmt_num := 10;
11455
11456 DELETE FROM WSM_INTERFACE_ERRORS WHERE header_id = p_header_id;
11457
11458 IF (p_transaction_type IN (1, 2)) THEN
11459 DECLARE
11460 l_mti_rows NUMBER;
11461 l_mtli_rows NUMBER;
11462 l_msni_rows NUMBER;
11463 l_numErrRows NUMBER;
11464 l_numTempRows NUMBER;
11465 x_trans_count NUMBER;
11466 type err_tbl_t is table of varchar2(240);
11467 type item_tbl_t is table of varchar2(2000);
11468 l_errExplTbl err_tbl_t;
11469 l_itemNameTbl item_tbl_t;
11470 BEGIN
11471 BEGIN
11472 select count(*)
11473 into l_mti_rows
11474 from MTL_TRANSACTIONS_INTERFACE
11475 where transaction_header_id = p_mtl_txn_hdr_id;
11476 EXCEPTION
11477 WHEN no_data_found THEN
11478 l_mti_rows := 0;
11479 END;
11480
11481 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11482 /*************
11483 BEGIN
11484 select count(*)
11485 into l_mtli_rows
11486 from mtl_serial_numbers_interface
11487 where transaction_header_id = p_mtl_txn_hdr_id;
11488 EXCEPTION
11489 WHEN no_data_found THEN
11490 l_mti_rows := 0;
11491 END;
11492
11493 BEGIN
11494 select count(*)
11495 into l_mti_rows
11496 from mtl_serial_numbers_interface
11497 where transaction_header_id = p_mtl_txn_hdr_id;
11498 EXCEPTION
11499 WHEN no_data_found THEN
11500 l_mti_rows := 0;
11501 END;
11502 **************/
11503 DECLARE
11504 CURSOR C_MTLI IS
11505 SELECT MTLI.TRANSACTION_INTERFACE_ID, MTLI.LOT_NUMBER, MTLI.TRANSACTION_QUANTITY,
11506 MTLI.PRIMARY_QUANTITY
11507 FROM mtl_transaction_lots_interface MTLI,
11508 mtl_transactions_interface MTI
11509 WHERE MTI.TRANSACTION_HEADER_ID = p_mtl_txn_hdr_id
11510 AND MTI.TRANSACTION_INTERFACE_ID = MTLI.TRANSACTION_INTERFACE_ID;
11511 BEGIN
11512 FOR rec in C_MTLI LOOP
11513 l_msg_tokens.delete;
11514 WSM_log_PVT.logMessage (
11515 p_module_name => l_module ,
11516 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11517 ||'p_mtl_txn_hdr_id: '
11518 ||p_mtl_txn_hdr_id
11519 ||'MTLI.TRANSACTION_INTERFACE_ID: '
11520 ||rec.TRANSACTION_INTERFACE_ID
11521 ||'MTLI.LOT_NUMBER: '
11522 ||rec.LOT_NUMBER
11523 ||'MTLI.TRANSACTION_QUANTITY: '
11524 ||rec.TRANSACTION_QUANTITY
11525 ||'MTLI.PRIMARY_QUANTITY: '
11526 ||rec.PRIMARY_QUANTITY,
11527 p_stmt_num => l_stmt_num ,
11528 p_msg_tokens => l_msg_tokens ,
11529 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11530 p_run_log_level => l_log_level
11531 );
11532 END LOOP;
11533 END;
11534 l_msg_tokens.delete;
11535 WSM_log_PVT.logMessage (
11536 p_module_name => l_module ,
11537 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11538 ||'Number of mti rows: '
11539 ||l_mti_rows,
11540 p_stmt_num => l_stmt_num ,
11541 p_msg_tokens => l_msg_tokens ,
11542 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11543 p_run_log_level => l_log_level
11544 );
11545 END IF;
11546
11547 IF (l_mti_rows > 0) THEN
11548
11549
11550 UPDATE MTL_TRANSACTIONS_INTERFACE MTL
11551 SET MTL.wip_entity_type = WIP_CONSTANTS.LOTBASED,
11552 --bug 5584140 operation_seq_num is already stamped in the UI and there could be multiple
11553 --operation seq nums so don't overwrite. Get department_id for each operation
11554 --operation_seq_num = p_fm_operation_seq_num,
11555 --department_id = p_fm_department_id
11556 MTL.department_id = (SELECT department_id
11557 FROM WIP_OPERATIONS WO
11558 WHERE WO.wip_entity_id = p_wip_entity_id
11559 AND WO.operation_seq_num = MTL.operation_seq_num)
11560 WHERE MTL.transaction_header_id = p_mtl_txn_hdr_id;
11561
11562 retcode := INV_TXN_MANAGER_GRP.Validate_Transactions(
11563 p_api_version => 1.0,
11564 p_init_msg_list => fnd_api.g_false,
11565 p_validation_level => fnd_api.g_valid_level_full,
11566 p_header_id => p_mtl_txn_hdr_id,
11567 x_return_status => x_return_status,
11568 x_msg_count => x_msg_count,
11569 x_msg_data => x_msg_data,
11570 x_trans_count => x_trans_count);
11571
11572 select count(*)
11573 into l_numErrRows
11574 from mtl_transactions_interface
11575 where transaction_header_id = p_mtl_txn_hdr_id;
11576
11577 select count(*)
11578 into l_numTempRows
11579 from mtl_material_transactions_temp
11580 where transaction_header_id = p_mtl_txn_hdr_id;
11581
11582 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11583 l_msg_tokens.delete;
11584 WSM_log_PVT.logMessage (
11585 p_module_name => l_module ,
11586 p_msg_text => 'B4 call to INV_TXN_MANAGER_GRP.Validate_Transactions: '
11587 ||'Number of mti rows: '
11588 ||l_numErrRows
11589 ||'; Number of mmtt rows: '
11590 ||l_numTempRows,
11591 p_stmt_num => l_stmt_num ,
11592 p_msg_tokens => l_msg_tokens ,
11593 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11594 p_run_log_level => l_log_level
11595 );
11596 END IF;
11597
11598 IF (x_return_status = g_ret_success) THEN
11599 if(l_numErrRows <> 0) then
11600 select msik.concatenated_segments, mti.error_explanation
11601 bulk collect into l_itemNameTbl,l_errExplTbl
11602 from mtl_transactions_interface mti,
11603 mtl_system_items_kfv msik
11604 where mti.transaction_header_id = p_mtl_txn_hdr_id
11605 and mti.error_explanation is not null
11606 and mti.inventory_item_id = msik.inventory_item_id
11607 and mti.organization_id = msik.organization_id;
11608
11609 for i in 1..l_itemNameTbl.count loop
11610 fnd_message.set_name('WIP', 'WIP_TMPINSERT_ERR');
11611 fnd_message.set_token('ITEM_NAME', l_itemNameTbl(i));
11612 fnd_message.set_token('ERR_MSG', l_errExplTbl(i));
11613 fnd_msg_pub.add;
11614 fnd_msg_pub.get
11615 ( p_msg_index => fnd_msg_pub.G_NEXT - 1,
11616 p_encoded => 'T',
11617 p_data => x_message,
11618 p_msg_index_out => x_msg_index
11619 );
11620 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11621 l_msg_tokens.delete;
11622 WSM_log_PVT.logMessage (
11623 p_module_name => l_module ,
11624 p_msg_text => 'Error from INV_TXN_MANAGER_GRP.Validate_Transactions '||x_message,
11625 p_stmt_num => l_stmt_num ,
11626 p_msg_tokens => l_msg_tokens ,
11627 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11628 p_run_log_level => l_log_level
11629 );
11630 END IF;
11631 end loop;
11632
11633 RAISE FND_API.G_EXC_ERROR;
11634 END IF;
11635
11636 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11637 l_msg_tokens.delete;
11638 WSM_log_PVT.logMessage (
11639 p_module_name => l_module ,
11640 p_msg_text => 'After call to INV_TXN_MANAGER_GRP.Validate_Transactions: '||
11641 'x_return_status '||x_return_status||
11642 '; no of rows in mmtt '||l_numTempRows,
11643 p_stmt_num => l_stmt_num ,
11644 p_msg_tokens => l_msg_tokens ,
11645 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11646 p_run_log_level => l_log_level
11647 );
11648 END IF;
11649 ELSIF (x_return_status = g_ret_error) THEN
11650 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11651 l_msg_tokens.delete;
11652 WSM_log_PVT.logMessage (
11653 p_module_name => l_module ,
11654 p_msg_text => 'Error from INV_TXN_MANAGER_GRP.Validate_Transactions '
11655 ||x_msg_data,
11656 p_stmt_num => l_stmt_num ,
11657 p_msg_tokens => l_msg_tokens ,
11658 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11659 p_run_log_level => l_log_level
11660 );
11661 END IF;
11662 RAISE FND_API.G_EXC_ERROR;
11663 ELSIF (x_return_status = g_ret_unexpected) THEN
11664 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11665 END IF;
11666 END IF; --(l_mti_rows > 0)
11667 END;
11668 ELSE --p_transaction_type IN (g_undo_txn, g_ret_txn)
11669 WSM_Serial_support_GRP.populate_components(
11670 p_wip_entity_id => p_wip_entity_id,
11671 p_organization_id => p_organization_id,
11672 p_move_txn_id => p_transaction_id,
11673 p_move_txn_type => p_transaction_type,
11674 p_txn_date => p_transaction_date,
11675 p_mtl_txn_hdr_id => p_mtl_txn_hdr_id,
11676 p_compl_txn_id => null,
11677 x_return_status => x_return_status,
11678 x_error_count => x_msg_count,
11679 x_error_msg => x_msg_data
11680 );
11681
11682 IF (x_return_status = g_ret_error) THEN
11683 RAISE FND_API.G_EXC_ERROR;
11684 ELSIF (x_return_status = g_ret_unexpected) THEN
11685 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11686 END IF;
11687
11688 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11689
11690 DECLARE
11691 l_mmtt_rows NUMBER;
11692 l_mtlt_rows NUMBER;
11693 l_msnt_rows NUMBER;
11694 BEGIN
11695
11696 SELECT count(*)
11697 INTO l_mmtt_rows
11698 FROM mtl_material_transactions_temp
11699 WHERE transaction_header_id = p_mtl_txn_hdr_id;
11700
11701 SELECT count(*)
11702 INTO l_mtlt_rows
11703 FROM mtl_transaction_lots_temp mtlt, mtl_material_transactions_temp mmtt
11704 WHERE mmtt.transaction_header_id = p_mtl_txn_hdr_id
11705 AND mtlt.TRANSACTION_TEMP_ID = mmtt.TRANSACTION_TEMP_ID;
11706
11707 SELECT count(*)
11708 INTO l_msnt_rows
11709 FROM mtl_serial_numbers_temp msnt, mtl_material_transactions_temp mmtt
11710 WHERE mmtt.transaction_header_id = p_mtl_txn_hdr_id
11711 AND msnt.TRANSACTION_TEMP_ID = mmtt.TRANSACTION_TEMP_ID;
11712
11713 IF (x_return_status = g_ret_success) THEN
11714 l_msg_tokens.delete;
11715 WSM_log_PVT.logMessage (
11716 p_module_name => l_module ,
11717 p_msg_text => 'WSM_Serial_support_GRP.populate_components returned successfully '||
11718 ';l_mmtt_rows '||
11719 l_mmtt_rows||
11720 ';l_mtlt_rows '||
11721 l_mtlt_rows||
11722 ';l_msnt_rows '||
11723 l_msnt_rows,
11724 p_stmt_num => l_stmt_num ,
11725 p_msg_tokens => l_msg_tokens ,
11726 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
11727 p_run_log_level => l_log_level
11728 );
11729 END IF;
11730 END;
11731 END IF;
11732
11733 END IF; --p_transaction_type IN (g_undo_txn, g_ret_txn)
11734
11735 DELETE FROM WSM_LOT_MOVE_TXN_INTERFACE WHERE header_id = p_header_id;
11736
11737 INSERT into WSM_LOT_MOVE_TXN_INTERFACE
11738 (
11739 -- INTERFACE_ID -- commented for bugfix 7163496
11740 TRANSACTION_ID
11741 , LAST_UPDATE_DATE
11742 , LAST_UPDATED_BY
11743 , LAST_UPDATED_BY_NAME
11744 , CREATION_DATE
11745 , CREATED_BY
11746 , CREATED_BY_NAME
11747 , LAST_UPDATE_LOGIN
11748 , GROUP_ID
11749 , SOURCE_CODE
11750 , STATUS
11751 , TRANSACTION_TYPE
11752 , ORGANIZATION_ID
11753 , ORGANIZATION_CODE
11754 , WIP_ENTITY_ID
11755 , WIP_ENTITY_NAME
11756 , ENTITY_TYPE
11757 , PRIMARY_ITEM_ID
11758 , TRANSACTION_DATE
11759 , FM_OPERATION_SEQ_NUM
11760 , FM_OPERATION_CODE
11761 , FM_DEPARTMENT_ID
11762 , FM_DEPARTMENT_CODE
11763 , FM_INTRAOPERATION_STEP_TYPE
11764 , TO_OPERATION_SEQ_NUM
11765 , TO_OPERATION_CODE
11766 , TO_DEPARTMENT_ID
11767 , TO_DEPARTMENT_CODE
11768 , TO_INTRAOPERATION_STEP_TYPE
11769 , TRANSACTION_QUANTITY
11770 , TRANSACTION_UOM
11771 , PRIMARY_QUANTITY
11772 , PRIMARY_UOM
11773 , SCRAP_ACCOUNT_ID
11774 , REASON_ID
11775 , REASON_NAME
11776 , REFERENCE
11777 , ATTRIBUTE_CATEGORY
11778 , ATTRIBUTE1
11779 , ATTRIBUTE2
11780 , ATTRIBUTE3
11781 , ATTRIBUTE4
11782 , ATTRIBUTE5
11783 , ATTRIBUTE6
11784 , ATTRIBUTE7
11785 , ATTRIBUTE8
11786 , ATTRIBUTE9
11787 , ATTRIBUTE10
11788 , ATTRIBUTE11
11789 , ATTRIBUTE12
11790 , ATTRIBUTE13
11791 , ATTRIBUTE14
11792 , ATTRIBUTE15
11793 , QA_COLLECTION_ID
11794 , JUMP_FLAG
11795 , HEADER_ID
11796 , PRIMARY_SCRAP_QUANTITY
11797 , SCRAP_QUANTITY
11798 , SCRAP_AT_OPERATION_FLAG
11799 )
11800 VALUES
11801 (
11802 -- NULL -- commented for bugfix 7163496
11803 p_transaction_id
11804 , sysdate --LAST_UPDATE_DATE
11805 , g_user_id --LAST_UPDATED_BY
11806 , fnd_global.user_name --LAST_UPDATED_BY_NAME
11807 , sysdate --CREATION_DATE
11808 , g_user_id --CREATED_BY
11809 , fnd_global.user_name--CREATED_BY_NAME
11810 , g_login_id --LAST_UPDATE_LOGIN
11811 , WIP_TRANSACTIONS_S.NEXTVAL --p_group_id --GROUP_ID
11812 , p_source_code --source_code
11813 , WIP_CONSTANTS.PENDING --STATUS
11814 , p_TRANSACTION_TYPE
11815 , p_ORGANIZATION_ID
11816 , null --!! ORGANIZATION_CODE
11817 , p_WIP_ENTITY_ID
11818 , p_WIP_ENTITY_NAME
11819 , WIP_CONSTANTS.LOTBASED --!!ENTITY_TYPE
11820 , null --PRIMARY_ITEM_ID
11821 , nvl(p_TRANSACTION_DATE, sysdate)
11822 , p_FM_OPERATION_SEQ_NUM
11823 , p_FM_OPERATION_CODE
11824 , p_FM_DEPARTMENT_ID
11825 , p_FM_DEPARTMENT_CODE
11826 , p_FM_INTRAOPERATION_STEP_TYPE
11827 , p_TO_OPERATION_SEQ_NUM
11828 , p_TO_OPERATION_CODE
11829 , p_TO_DEPARTMENT_ID
11830 , p_TO_DEPARTMENT_CODE
11831 , p_TO_INTRAOPERATION_STEP_TYPE
11832 , p_PRIMARY_QUANTITY --TRANSACTION_QUANTITY
11833 , p_PRIMARY_UOM --TRANSACTION_UOM
11834 , p_PRIMARY_QUANTITY
11835 , p_PRIMARY_UOM
11836 , p_SCRAP_ACCOUNT_ID
11837 , p_REASON_ID
11838 , p_REASON_NAME
11839 , p_REFERENCE
11840 , null --ATTRIBUTE_CATEGORY
11841 , null --ATTRIBUTE1
11842 , null --ATTRIBUTE2
11843 , null --ATTRIBUTE3
11844 , null --ATTRIBUTE4
11845 , null --ATTRIBUTE5
11846 , null --ATTRIBUTE6
11847 , null --ATTRIBUTE7
11848 , null --ATTRIBUTE8
11849 , null --ATTRIBUTE9
11850 , null --ATTRIBUTE10
11851 , null --ATTRIBUTE11
11852 , null --ATTRIBUTE12
11853 , null --ATTRIBUTE13
11854 , null --ATTRIBUTE14
11855 , null --ATTRIBUTE15
11856 , p_QA_COLLECTION_ID
11857 , p_JUMP_FLAG
11858 , nvl(p_HEADER_ID, wsm_lot_move_txn_interface_s.nextval) --HEADER_ID
11859 , p_PRIMARY_SCRAP_QUANTITY --PRIMARY_SCRAP_QUANTITY
11860 , p_PRIMARY_SCRAP_QUANTITY --SCRAP_QUANTITY
11861 , decode(p_primary_scrap_quantity, --bug 5584140 Added decode so that SCRAP_AT_OPERATION_FLAG=null when there is no scrap
11862 null, null,
11863 0, null,
11864 1) --SCRAP_AT_OPERATION_FLAG
11865 )
11866 RETURNING transaction_id, group_id, header_id INTO l_transaction_id, l_group_id, l_header_id;
11867
11868 l_stmt_num := 20;
11869 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
11870 l_msg_tokens.delete;
11871 WSM_log_PVT.logMessage (
11872 p_module_name => l_module,
11873 p_msg_text => 'B4 UPDATE wsm_lot_move_txn_interface wlmti '||
11874 ';g_user_id '||
11875 g_user_id||
11876 ';fnd_global.user_name '||
11877 fnd_global.user_name,
11878 p_stmt_num => l_stmt_num,
11879 p_msg_tokens => l_msg_tokens,
11880 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
11881 p_run_log_level => l_log_level
11882 );
11883 END IF;
11884
11885 l_stmt_num := 30;
11886 l_sec_uom_code_tbls(l_header_id) := p_sec_uom_code_tbl;
11887 l_sec_move_out_qty_tbls(l_header_id) := p_sec_move_out_qty_tbl;
11888 l_scrap_codes_tbls(l_header_id) := p_scrap_codes_tbl;
11889 l_scrap_code_qty_tbls(l_header_id) := p_scrap_code_qty_tbl;
11890 l_bonus_codes_tbls(l_header_id) := p_bonus_codes_tbl;
11891 l_bonus_code_qty_tbls(l_header_id) := p_bonus_code_qty_tbl;
11892 l_jobop_scrap_serials_tbls(l_header_id) := p_jobop_scrap_serials_tbl ;
11893 l_jobop_bonus_serials_tbls(l_header_id) := p_jobop_bonus_serials_tbl ;
11894 l_jobop_resource_usages_tbls(l_header_id) := p_jobop_resource_usages_tbl;
11895 l_stmt_num := 40;
11896
11897 l_stmt_num := 50;
11898 MoveTransaction(
11899 p_group_id => l_group_id,
11900 p_bonus_account_id => p_bonus_account_id,
11901 p_employee_id => p_employee_id,
11902 p_operation_start_date => p_operation_start_date,
11903 p_operation_completion_date => p_operation_completion_date,
11904 p_expected_completion_date => p_expected_completion_date,
11905 p_bonus_quantity => p_bonus_quantity,
11906 p_low_yield_trigger_limit => p_low_yield_trigger_limit,
11907 p_source_code => p_source_code,
11908 p_mtl_txn_hdr_id => p_mtl_txn_hdr_id,
11909 p_sec_uom_code_tbls => l_sec_uom_code_tbls,
11910 p_sec_move_out_qty_tbls => l_sec_move_out_qty_tbls,
11911 p_jobop_scrap_serials_tbls => l_jobop_scrap_serials_tbls,
11912 p_jobop_bonus_serials_tbls => l_jobop_bonus_serials_tbls,
11913 p_scrap_codes_tbls => l_scrap_codes_tbls,
11914 p_scrap_code_qty_tbls => l_scrap_code_qty_tbls,
11915 p_bonus_codes_tbls => l_bonus_codes_tbls,
11916 p_bonus_code_qty_tbls => l_bonus_code_qty_tbls,
11917 p_jobop_resource_usages_tbls => l_jobop_resource_usages_tbls,
11918 x_wip_move_api_sucess_msg => x_wip_move_api_sucess_msg,
11919 retcode => retcode,
11920 errbuf => errbuf
11921 );
11922
11923 IF (x_return_status = g_ret_success) THEN
11924 l_msg_tokens.delete;
11925 WSM_log_PVT.logMessage (
11926 p_module_name => l_module,
11927 p_msg_text => 'WSMPLBMI.MoveTransaction returned '||
11928 ';x_wip_move_api_sucess_msg '||
11929 x_wip_move_api_sucess_msg||
11930 ';retcode '||
11931 retcode||
11932 ';errbuf '||
11933 errbuf,
11934 p_stmt_num => l_stmt_num,
11935 p_msg_tokens => l_msg_tokens,
11936 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE,
11937 p_run_log_level => l_log_level
11938 );
11939 END IF;
11940
11941 l_stmt_num := 60;
11942 /*
11943 DECLARE
11944 cursor C_WIE IS
11945 SELECT message
11946 FROM WSM_INTERFACE_ERRORS
11947 WHERE transaction_id = l_transaction_id;
11948
11949 i INTEGER := 0;
11950 BEGIN
11951 OPEN C_WIE;
11952 FETCH C_WIE BULK COLLECT INTO l_err_msg_tbl;
11953 CLOSE C_WIE;
11954
11955 LOOP
11956 IF l_err_msg_tbl.exists(i) THEN
11957 FND_MESSAGE.set_encoded(l_err_msg_tbl(i));
11958 FND_MSG_PUB.add;
11959 i := i+1;
11960 ELSE
11961 EXIT;
11962 END IF;
11963 END LOOP;
11964 END;
11965 */
11966 IF retcode > 0 THEN
11967 RAISE FND_API.G_EXC_ERROR;
11968 ELSIF retcode < 0 THEN
11969 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11970 END IF;
11971
11972 FND_MSG_PUB.Count_And_Get
11973 ( p_count => x_msg_count ,
11974 p_data => x_msg_data
11975 );
11976
11977 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
11978 l_msg_tokens.delete;
11979 WSM_log_PVT.logMessage (
11980 p_module_name => l_module ,
11981 p_msg_text => 'End MoveTransactions html',
11982 p_stmt_num => l_stmt_num ,
11983 p_msg_tokens => l_msg_tokens ,
11984 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
11985 p_run_log_level => l_log_level
11986 );
11987 END IF;
11988
11989 EXCEPTION
11990 WHEN FND_API.G_EXC_ERROR THEN
11991 ROLLBACK;
11992 x_return_status := G_RET_ERROR;
11993 FND_MSG_PUB.Count_And_Get
11994 ( p_count => x_msg_count ,
11995 p_data => x_msg_data
11996 );
11997
11998
11999 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12000 ROLLBACK;
12001 x_return_status := G_RET_UNEXPECTED;
12002 FND_MSG_PUB.Count_And_Get
12003 ( p_count => x_msg_count ,
12004 p_data => x_msg_data
12005 );
12006
12007 WHEN OTHERS THEN
12008 ROLLBACK;
12009 x_return_status := G_RET_UNEXPECTED;
12010
12011 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12012 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12013 THEN
12014 WSM_log_PVT.handle_others( p_module_name => l_module ,
12015 p_stmt_num => l_stmt_num ,
12016 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
12017 p_run_log_level => l_log_level
12018 );
12019 END IF;
12020
12021 FND_MSG_PUB.Count_And_Get
12022 ( p_count => x_msg_count ,
12023 p_data => x_msg_data
12024 );
12025
12026 END;
12027
12028 /****************************************************************************
12029 Called from the Move Out page to set the page properties
12030 ****************************************************************************/
12031
12032 Procedure getMoveOutPageProperties(
12033 p_organization_id IN NUMBER
12034 , p_wip_entity_id IN NUMBER
12035 , p_operation_seq_num IN NUMBER
12036 , p_routing_operation IN NUMBER
12037 , p_job_type IN NUMBER
12038 , p_current_step IN NUMBER
12039 , p_user_id IN NUMBER
12040 , x_last_operation OUT NOCOPY NUMBER
12041 , x_estimated_scrap_accounting OUT NOCOPY NUMBER
12042 , x_show_next_op_by_default OUT NOCOPY NUMBER
12043 , x_multiple_res_usage_dates OUT NOCOPY NUMBER
12044 , x_show_scrap_codes OUT NOCOPY NUMBER
12045 , x_scrap_codes_defined OUT NOCOPY NUMBER
12046 , x_bonus_codes_defined OUT NOCOPY NUMBER
12047 , x_show_lot_attrib OUT NOCOPY NUMBER
12048 , x_show_scrap_serials OUT NOCOPY NUMBER
12049 , x_show_serial_region OUT NOCOPY NUMBER
12050 , x_show_secondary_quantities OUT NOCOPY NUMBER
12051 , x_transaction_type OUT NOCOPY NUMBER
12052 , x_quality_region OUT NOCOPY VARCHAR2
12053 , x_show_scrap_qty OUT NOCOPY NUMBER
12054 , x_show_next_op_choice OUT NOCOPY NUMBER
12055 , x_show_next_op OUT NOCOPY NUMBER
12056 , x_employee_id OUT NOCOPY NUMBER
12057 , x_operator OUT NOCOPY VARCHAR2
12058 , x_default_start_date OUT NOCOPY DATE
12059 , x_default_completion_date OUT NOCOPY DATE
12060 , x_return_status OUT NOCOPY VARCHAR2
12061 , x_msg_count OUT NOCOPY NUMBER
12062 , x_msg_data OUT NOCOPY VARCHAR2
12063 )
12064 IS
12065 l_bos_use_org_settings NUMBER;
12066 l_bos_show_next_op_by_default NUMBER;
12067 l_bos_show_scrap_codes NUMBER;
12068 l_bos_show_lot_attrib NUMBER;
12069 l_bos_mul_res_usage_dates NUMBER;
12070 l_bos_to_move_mandatory_flag NUMBER;
12071 l_bos_run_mandatory_flag NUMBER;
12072
12073 l_wsm_show_next_op_by_default NUMBER;
12074 l_wsm_mul_res_usage_dates NUMBER;
12075 l_wsm_move_in NUMBER;
12076 l_wsm_move_to_next_op NUMBER;
12077
12078 l_wip_queue_enabled_flag NUMBER;
12079 l_wip_run_enabled_flag NUMBER;
12080 l_wip_to_move_enabled_flag NUMBER;
12081 l_wip_scrap_enabled_flag NUMBER;
12082
12083 l_osfm_quality_txn_number NUMBER;
12084 l_serialization_start_op NUMBER;
12085 l_end_routing_operation NUMBER;
12086 l_stmt_num NUMBER;
12087 l_serialization_started NUMBER := 0; --bug 5444062 initialize to 0
12088 l_job_type NUMBER;
12089 l_first_serial_txn_id NUMBER; --bug 5444062
12090 -- Logging variables.....
12091 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12092 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12093 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.getMoveOutPageProperties';
12094 l_param_tbl WSM_Log_PVT.param_tbl_type;
12095 l_next_links_exist NUMBER := 0; --bug 5531107
12096 x_error_count NUMBER;
12097 x_return_code NUMBER;
12098 x_error_msg VARCHAR2(4000);
12099 BEGIN
12100 /*
12101 fnd_global.apps_initialize(user_id => 1008623,
12102 resp_id => 56236,
12103 resp_appl_id => 724);
12104 */
12105 -- delete from debug_sk;
12106 -- debug_pkg.ins('session_id '||fnd_global.session_id);
12107 x_return_status := g_ret_success;
12108 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
12109 l_msg_tokens.delete;
12110 WSM_log_PVT.logMessage (
12111 p_module_name => l_module ,
12112 p_msg_text => 'Begin getMoveOutPageProperties '||
12113 '; p_organization_id '||p_organization_id||
12114 ' ;p_wip_entity_id '||p_wip_entity_id||
12115 ' ;p_operation_seq_num '||p_operation_seq_num||
12116 ' ;p_routing_operation '||p_routing_operation||
12117 ' ;p_job_type '||p_job_type||
12118 ' ;p_current_step '||p_current_step||
12119 ' ;p_user_id '||p_user_id,
12120 p_stmt_num => l_stmt_num ,
12121 p_msg_tokens => l_msg_tokens ,
12122 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
12123 p_run_log_level => l_log_level
12124 );
12125 END IF;
12126
12127 l_stmt_num := 10;
12128 --SELECT queue_enabled_flag, run_enabled_flag, to_move_enabled_flag, scrap_enabled_flag
12129 --Bug 5051836:Replaced wip_parameters_v with wvis to fix the
12130 --share memory violation
12131 SELECT DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,1,1,0)),0,2,1),
12132 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,2,1,0)),0,2,1),
12133 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,3,
12134 DECODE(WVIS.RECORD_CREATOR,'USER',1,0),0)),0,2,1),
12135 DECODE(SUM(DECODE(WVIS.STEP_LOOKUP_TYPE,5,1,0)),0,2,1)
12136 INTO l_wip_queue_enabled_flag, l_wip_run_enabled_flag, l_wip_to_move_enabled_flag, l_wip_scrap_enabled_flag
12137 --FROM WIP_PARAMETERS_V
12138 FROM WIP_VALID_INTRAOPERATION_STEPS WVIS
12139 WHERE organization_id = p_organization_id;
12140
12141 l_stmt_num := 20;
12142 SELECT nvl(show_next_op_by_default, 0),
12143 nvl(track_multi_usage_dates, 0), nvl(move_in_option, 2), nvl(move_to_next_op_option, 2)
12144 INTO l_wsm_show_next_op_by_default,
12145 l_wsm_mul_res_usage_dates, l_wsm_move_in, l_wsm_move_to_next_op
12146 FROM WSM_PARAMETERS
12147 WHERE organization_id = p_organization_id;
12148
12149 l_stmt_num := 30;
12150 /********bug 5463926 Always look at BSO instead of BOS. For the case of non standard operation
12151 trap the no data found exception and set the values
12152
12153 IF (p_routing_operation IS NOT NULL) THEN
12154 --bug 5300662 change the interpretation of NULL value for the column use_org_settings to YES
12155 --SELECT nvl(BOS.use_org_settings, 0), nvl(BOS.show_next_op_by_default, 0),
12156 --bug 5463926
12157 SELECT nvl(BOS.use_org_settings, 1), nvl(BOS.show_next_op_by_default, 0),
12158 nvl(BOS.show_scrap_code, 0), nvl(BOS.show_lot_attrib, 0),
12159 nvl(BOS.track_multiple_res_usage_dates, 0), nvl(BOS.to_move_mandatory_flag, 0),
12160 reference_flag
12161 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12162 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12163 l_bos_to_move_mandatory_flag, l_reference_flag
12164 FROM BOM_OPERATION_SEQUENCES BOS, WIP_OPERATIONS WO
12165 WHERE WO.wip_entity_id = p_wip_entity_id
12166 AND WO.operation_seq_num = p_operation_seq_num
12167 AND BOS.operation_sequence_id = WO.operation_sequence_id;
12168 ELSE
12169 --bug 5300662 change the interpretation of NULL value for the column use_org_settings to YES
12170 --SELECT nvl(BSO.use_org_settings, 0), nvl(BSO.show_next_op_by_default, 0),
12171 SELECT nvl(BSO.use_org_settings, 1), nvl(BSO.show_next_op_by_default, 0),
12172 nvl(BSO.show_scrap_code, 0), nvl(BSO.show_lot_attrib, 0),
12173 nvl(BSO.track_multiple_res_usage_dates, 0), nvl(BSO.to_move_mandatory_flag, 0)
12174 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12175 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12176 l_bos_to_move_mandatory_flag
12177 FROM BOM_STANDARD_OPERATIONS BSO, WIP_OPERATIONS WO
12178 WHERE WO.wip_entity_id = p_wip_entity_id
12179 AND WO.operation_seq_num = p_operation_seq_num
12180 AND BSO.standard_operation_id = WO.standard_operation_id
12181 AND BSO.organization_id = WO.organization_id;
12182 END IF;
12183 ********/
12184 BEGIN
12185 SELECT nvl(BSO.use_org_settings, 1), nvl(BSO.show_next_op_by_default, 0),
12186 nvl(BSO.show_scrap_code, 0), nvl(BSO.show_lot_attrib, 0),
12187 nvl(BSO.track_multiple_res_usage_dates, 0), nvl(BSO.to_move_mandatory_flag, 0)
12188 INTO l_bos_use_org_settings, l_bos_show_next_op_by_default,
12189 x_show_scrap_codes, l_bos_show_lot_attrib, l_bos_mul_res_usage_dates,
12190 l_bos_to_move_mandatory_flag
12191 FROM BOM_STANDARD_OPERATIONS BSO, WIP_OPERATIONS WO
12192 WHERE WO.wip_entity_id = p_wip_entity_id
12193 AND WO.operation_seq_num = p_operation_seq_num
12194 AND BSO.standard_operation_id = WO.standard_operation_id
12195 AND BSO.organization_id = WO.organization_id;
12196 EXCEPTION
12197 WHEN no_data_found THEN
12198 l_bos_use_org_settings := 1;
12199 l_bos_show_next_op_by_default := 0;
12200 x_show_scrap_codes := 0;
12201 l_bos_show_lot_attrib := 0;
12202 l_bos_mul_res_usage_dates := 0;
12203 l_bos_to_move_mandatory_flag := 0;
12204 END;
12205 --bug 5463926 end
12206
12207 l_stmt_num := 40;
12208 SELECT operation_seq_num
12209 INTO l_end_routing_operation
12210 FROM WSM_COPY_OPERATIONS WCO
12211 WHERE WCO.wip_entity_id = p_wip_entity_id
12212 AND WCO.network_start_end = 'E';
12213
12214 l_stmt_num := 50;
12215 SELECT WO.actual_start_date, WO.employee_id, nvl(WO.actual_completion_date, sysdate)
12216 INTO x_default_start_date, x_employee_id, x_default_completion_date
12217 FROM WIP_OPERATIONS WO
12218 WHERE WO.wip_entity_id = p_wip_entity_id
12219 AND WO.operation_seq_num = p_operation_seq_num;
12220
12221 IF (l_end_routing_operation = p_routing_operation) THEN
12222 x_last_operation := 1;
12223 ELSE
12224 x_last_operation := 0;
12225 END IF;
12226
12227 /******* Moved to the Txn Validation API******
12228 l_stmt_num := 60;
12229 IF l_wip_to_move_enabled_flag = 2 THEN
12230 IF l_bos_use_org_settings = 1 THEN
12231 IF l_wsm_move_to_next_op = 1 THEN
12232 IF g_log_level_error >= l_log_level OR
12233 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12234 THEN
12235 l_msg_tokens.delete;
12236 WSM_log_PVT.logMessage(
12237 p_module_name => l_module,
12238 p_msg_name => 'WSM_MES_WIP_WSM_MOVE',
12239 p_msg_appl_name => 'WSM',
12240 p_msg_tokens => l_msg_tokens,
12241 p_stmt_num => l_stmt_num,
12242 p_fnd_msg_level => G_MSG_LVL_ERROR,
12243 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12244 p_run_log_level => l_log_level
12245 );
12246 END IF;
12247 RAISE FND_API.G_EXC_ERROR;
12248 END IF;
12249 ELSE
12250 IF l_bos_to_move_mandatory_flag = 1 THEN
12251 IF g_log_level_error >= l_log_level OR
12252 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12253 THEN
12254 l_msg_tokens.delete;
12255 WSM_log_PVT.logMessage(
12256 p_module_name => l_module,
12257 p_msg_name => 'WSM_MES_WIP_BOS_MOVE',
12258 p_msg_appl_name => 'WSM',
12259 p_msg_tokens => l_msg_tokens,
12260 p_stmt_num => l_stmt_num,
12261 p_fnd_msg_level => G_MSG_LVL_ERROR,
12262 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12263 p_run_log_level => l_log_level
12264 );
12265 END IF;
12266 RAISE FND_API.G_EXC_ERROR;
12267 END IF;
12268 END IF;
12269 END IF;
12270 ************************/
12271 /******* This should get trapped in the move txn allowed api******
12272 l_stmt_num := 70;
12273 IF (p_current_step = g_queue)
12274 AND (((l_bos_use_org_settings = 1) AND (l_bos_run_mandatory_flag = 1))
12275 OR
12276 ((l_bos_use_org_settings <> 1) AND (l_wsm_move_in = 1)))
12277 THEN
12278 IF g_log_level_error >= l_log_level OR
12279 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
12280 THEN
12281 l_msg_tokens.delete;
12282 WSM_log_PVT.logMessage(
12283 p_module_name => l_module,
12284 p_msg_name => 'WSM_MES_MOVE_OUT_RUN_MAND',
12285 p_msg_appl_name => 'WSM',
12286 p_msg_tokens => l_msg_tokens,
12287 p_stmt_num => l_stmt_num,
12288 p_fnd_msg_level => G_MSG_LVL_ERROR,
12289 p_fnd_log_level => G_LOG_LEVEL_ERROR,
12290 p_run_log_level => l_log_level
12291 );
12292 END IF;
12293 RAISE FND_API.G_EXC_ERROR;
12294 END IF;
12295 ********/
12296 IF l_wip_scrap_enabled_flag = 2 THEN
12297 x_show_scrap_qty := 0;
12298 ELSE
12299 x_show_scrap_qty := 1;
12300 END IF;
12301
12302 l_stmt_num := 80;
12303 x_estimated_scrap_accounting := wsmputil.wsm_esa_enabled(
12304 p_wip_entity_id => p_wip_entity_id,
12305 err_code => x_return_code,
12306 err_msg => x_error_msg,
12307 p_org_id => p_organization_id,
12308 p_job_type => p_job_type
12309 );
12310
12311 l_stmt_num := 90;
12312 BEGIN
12313 SELECT 1
12314 INTO x_show_secondary_quantities
12315 FROM dual
12316 WHERE EXISTS(
12317 SELECT 'secondary quantities exist'
12318 FROM WSM_OP_SECONDARY_QUANTITIES
12319 WHERE wip_entity_id = p_wip_entity_id
12320 AND operation_seq_num = p_operation_seq_num
12321
12322 );
12323 EXCEPTION
12324 WHEN no_data_found THEN
12325 x_show_secondary_quantities := 0;
12326 END;
12327
12328 l_stmt_num := 100;
12329 /********bug 5182689 modified the SELECT below to account for the case when serialization_start_op is null
12330 SELECT decode(first_serial_txn_id,
12331 null, decode(serialization_start_op,
12332 p_routing_operation, 1,
12333 0), 1)
12334 ************/
12335 /****bug 5444062 Replaced the sql below with a sql getting the values and logic in pl/sql for determining
12336 l_serialization_started
12337 SELECT decode(first_serial_txn_id,
12338 null, decode(serialization_start_op,
12339 null, 0,
12340 decode(serialization_start_op,
12341 p_routing_operation, 1,
12342 0)),
12343 1)
12344 INTO l_first_serial_txn_id
12345 FROM WSM_LOT_BASED_JOBS
12346 WHERE wip_entity_id = p_wip_entity_id;
12347 ******/
12348 SELECT first_serial_txn_id, serialization_start_op
12349 INTO l_first_serial_txn_id, l_serialization_start_op
12350 FROM WSM_LOT_BASED_JOBS
12351 WHERE wip_entity_id = p_wip_entity_id;
12352
12353 --serialization started
12354 IF (l_first_serial_txn_id IS NOT NULL) THEN
12355 l_serialization_started := 1;
12356 ELSE
12357 --job outside routing
12358 IF (p_routing_operation IS NULL) THEN
12359 l_serialization_started := 0;
12360 --assembly is serial controlled tracked and job is at last operation
12361 ELSIF (l_serialization_start_op IS NOT NULL) and (p_routing_operation = l_end_routing_operation) THEN
12362 l_serialization_started := 1;
12363 --job is at serialization op
12364 ELSIF (l_serialization_start_op = p_routing_operation) THEN
12365 l_serialization_started := 1;
12366 END IF;
12367 END IF;
12368 --end bug 5444062
12369
12370 IF (l_serialization_started = 0) OR (l_wip_scrap_enabled_flag = 2) THEN
12371 x_show_scrap_serials := 0;
12372 ELSE
12373 x_show_scrap_serials := 1;
12374 END IF;
12375
12376 x_show_serial_region := l_serialization_started;
12377
12378 l_stmt_num := 110;
12379 BEGIN
12380 SELECT 1
12381 INTO x_scrap_codes_defined
12382 FROM dual
12383 WHERE EXISTS(
12384 SELECT 'scrap codes exist'
12385 FROM WSM_OP_REASON_CODES
12386 WHERE wip_entity_id = p_wip_entity_id
12387 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12388 AND operation_seq_num = p_operation_seq_num
12389 AND code_type = 1
12390 );
12391 EXCEPTION
12392 WHEN no_data_found THEN
12393 x_scrap_codes_defined := 0;
12394 END;
12395
12396 l_stmt_num := 120;
12397 BEGIN
12398 SELECT 1
12399 INTO x_bonus_codes_defined
12400 FROM dual
12401 WHERE EXISTS(
12402 SELECT 'bonus codes exist'
12403 FROM WSM_OP_REASON_CODES
12404 WHERE wip_entity_id = p_wip_entity_id
12405 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12406 AND operation_seq_num = p_operation_seq_num
12407 AND code_type = 2
12408 );
12409 EXCEPTION
12410 WHEN no_data_found THEN
12411 x_bonus_codes_defined := 0;
12412 END;
12413
12414 IF l_bos_use_org_settings = 1 THEN
12415 x_multiple_res_usage_dates := l_wsm_mul_res_usage_dates;
12416 ELSE
12417 x_multiple_res_usage_dates := l_bos_mul_res_usage_dates;
12418 END IF;
12419 /********************
12420 IF l_wip_to_move_enabled_flag = 2 AND l_wsm_move_to_next_op = 1 THEN
12421 x_show_next_op_choice := 0;
12422 x_show_next_op := 1;
12423 x_show_next_op_by_default := 1;
12424 ELSE
12425 x_show_next_op_choice := 1;
12426 x_show_next_op := 1;
12427 IF (l_bos_use_org_settings = 1) AND (l_wsm_show_next_op_by_default = 1) THEN
12428 x_show_next_op_by_default := 1;
12429 ELSIF (l_bos_use_org_settings = 0) AND (l_bos_show_next_op_by_default = 1) THEN
12430 x_show_next_op_by_default := 1;
12431 ELSE
12432 x_show_next_op_by_default := 2;
12433 END IF;
12434 END IF;
12435 **********************/
12436 x_show_next_op_choice := 1;
12437 x_show_next_op := 1;
12438 x_show_next_op_by_default := 1;
12439
12440 IF (l_wip_to_move_enabled_flag = 2) THEN
12441 x_show_next_op_choice := 0;
12442 x_show_next_op := 1;
12443 x_show_next_op_by_default := 1;
12444 ELSE
12445 IF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 0) THEN
12446 x_show_next_op_choice := 1;
12447 IF (l_wsm_show_next_op_by_default = 1) THEN
12448 x_show_next_op := 1;
12449 x_show_next_op_by_default := 1;
12450 ELSE
12451 x_show_next_op := 0;
12452 x_show_next_op_by_default := 2;
12453 END IF;
12454 ELSIF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 1) THEN
12455 x_show_next_op_choice := 0;
12456 x_show_next_op_by_default := 2;
12457 x_show_next_op := 0;
12458 ELSIF (l_bos_use_org_settings = 1) AND (l_wsm_move_to_next_op = 2) THEN
12459 x_show_next_op_choice := 0;
12460 x_show_next_op_by_default := 1;
12461 x_show_next_op := 1;
12462 ELSIF (l_bos_use_org_settings <> 1) AND (l_bos_to_move_mandatory_flag = 1) THEN
12463 x_show_next_op_choice := 0;
12464 x_show_next_op_by_default := 2;
12465 x_show_next_op := 0;
12466 ELSIF (l_bos_use_org_settings <> 1) AND (l_bos_to_move_mandatory_flag <> 1) THEN
12467 x_show_next_op_choice := 1;
12468 IF (l_bos_show_next_op_by_default = 1) THEN
12469 x_show_next_op_by_default := 1;
12470 x_show_next_op := 1;
12471 ELSE
12472 x_show_next_op_by_default := 2;
12473 x_show_next_op := 0;
12474 END IF;
12475 END IF;
12476 END IF;
12477
12478 --bug 5531107 check if next operation links exist
12479 BEGIN
12480 SELECT 1
12481 INTO l_next_links_exist
12482 FROM dual
12483 WHERE EXISTS
12484 (SELECT 'next_links_exist'
12485 FROM wsm_copy_op_networks wcon
12486 WHERE wcon.wip_entity_id = p_wip_entity_id
12487 AND wcon.from_op_seq_num = p_routing_operation
12488 );
12489 EXCEPTION
12490 WHEN no_data_found THEN
12491 l_next_links_exist := 0;
12492 END;
12493
12494 --bug 5531107 Reset the values depending on the existence of next operation links
12495 IF (l_next_links_exist = 0) THEN
12496 IF (x_show_next_op_choice = 1) THEN
12497 x_show_next_op_choice := 0;
12498 END IF;
12499
12500 IF (x_show_next_op = 1) THEN
12501 x_show_next_op := 0;
12502 END IF;
12503
12504 IF (x_show_next_op_by_default = 1) THEN
12505 x_show_next_op_by_default := 2;
12506 END IF;
12507 END IF;
12508 --end bug 5531107
12509 x_show_lot_attrib := l_bos_show_lot_attrib;
12510
12511 l_stmt_num := 130;
12512 l_osfm_quality_txn_number := 23;
12513 x_quality_region := QA_TXN_GRP.qa_enabled(
12514 p_txn_number => l_osfm_quality_txn_number,
12515 p_org_id => p_organization_id
12516 );
12517 --!!hardcode
12518 -- x_quality_region := 'F';
12519
12520 IF (l_end_routing_operation = p_routing_operation) THEN
12521 x_transaction_type := WIP_CONSTANTS.COMP_TXN;
12522 x_show_next_op_choice := 0;
12523 x_show_next_op := 0;
12524 x_show_next_op_by_default := 2;
12525 ELSIF (p_routing_operation IS NULL) THEN
12526 x_transaction_type := WIP_CONSTANTS.MOVE_TXN;
12527 x_show_next_op_choice := 0;
12528 x_show_next_op := 0;
12529 x_show_next_op_by_default := 2;
12530 ELSE
12531 x_transaction_type := WIP_CONSTANTS.MOVE_TXN;
12532 END IF;
12533
12534 l_stmt_num := 140;
12535 IF x_employee_id IS NULL THEN
12536 SELECT FU.employee_id
12537 INTO x_employee_id
12538 FROM FND_USER FU
12539 WHERE FU.user_id = p_user_id;
12540 END IF;
12541
12542 l_stmt_num := 150;
12543 IF (x_employee_id is NOT NULL) THEN
12544 BEGIN
12545 SELECT DISTINCT(PPF.FULL_NAME) FULL_NAME
12546 INTO x_operator
12547 FROM PER_PEOPLE_F PPF
12548 WHERE PPF.person_id = x_employee_id;
12549 EXCEPTION
12550 WHEN no_data_found THEN
12551 x_operator := null;
12552 END;
12553 END IF;
12554
12555 FND_MSG_PUB.Count_And_Get
12556 ( p_count => x_msg_count ,
12557 p_data => x_msg_data
12558 );
12559
12560 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
12561 l_msg_tokens.delete;
12562 WSM_log_PVT.logMessage (
12563 p_module_name => l_module ,
12564 p_msg_text => 'End procedure getMoveOutPageProperties '
12565 ||';x_last_operation '
12566 ||x_last_operation
12567 ||';x_estimated_scrap_accounting '
12568 ||x_estimated_scrap_accounting
12569 ||';x_show_next_op_by_default '
12570 ||x_show_next_op_by_default
12571 ||';x_multiple_res_usage_dates '
12572 ||x_multiple_res_usage_dates
12573 ||';x_show_scrap_codes '
12574 ||x_show_scrap_codes
12575 ||';x_scrap_codes_defined '
12576 ||x_scrap_codes_defined
12577 ||';x_bonus_codes_defined '
12578 ||x_bonus_codes_defined
12579 ||';x_show_lot_attrib '
12580 ||x_show_lot_attrib
12581 ||';x_show_scrap_serials '
12582 ||x_show_scrap_serials
12583 ||';x_show_serial_region '
12584 ||x_show_serial_region
12585 ||';x_show_secondary_quantities '
12586 ||x_show_secondary_quantities
12587 ||';x_transaction_type '
12588 ||x_transaction_type
12589 ||';x_quality_region '
12590 ||x_quality_region
12591 ||';x_show_scrap_qty '
12592 ||x_show_scrap_qty
12593 ||';x_show_next_op_choice '
12594 ||x_show_next_op_choice
12595 ||';x_show_next_op '
12596 ||x_show_next_op
12597 ||';x_employee_id '
12598 ||x_employee_id
12599 ||';x_operator '
12600 ||x_operator
12601 ||';x_default_start_date '
12602 ||x_default_start_date
12603 ||';x_default_completion_date '
12604 ||x_default_completion_date
12605 ||';x_return_status '
12606 ||x_return_status
12607 ||';x_msg_count '
12608 ||x_msg_count
12609 ||';x_msg_data '
12610 ||x_msg_data,
12611 p_stmt_num => l_stmt_num ,
12612 p_msg_tokens => l_msg_tokens ,
12613 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
12614 p_run_log_level => l_log_level
12615 );
12616 END IF;
12617
12618 EXCEPTION
12619 WHEN FND_API.G_EXC_ERROR THEN
12620 x_return_status := G_RET_ERROR;
12621 FND_MSG_PUB.Count_And_Get
12622 ( p_count => x_msg_count ,
12623 p_data => x_msg_data
12624 );
12625
12626 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12627 x_return_status := G_RET_UNEXPECTED;
12628 FND_MSG_PUB.Count_And_Get
12629 ( p_count => x_msg_count ,
12630 p_data => x_msg_data
12631 );
12632
12633 WHEN OTHERS THEN
12634
12635 x_return_status := G_RET_UNEXPECTED;
12636
12637 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12638 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12639 THEN
12640 WSM_log_PVT.handle_others(
12641 p_module_name => l_module ,
12642 p_stmt_num => l_stmt_num ,
12643 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
12644 p_run_log_level => l_log_level
12645 );
12646 END IF;
12647
12648 FND_MSG_PUB.Count_And_Get
12649 ( p_count => x_msg_count ,
12650 p_data => x_msg_data
12651 );
12652
12653 END;
12654
12655 /****************************************************************************
12656 Called from Job Op page and Undo Move page to set the page properties
12657 ****************************************************************************/
12658
12659 Procedure getJobOpPageProperties(
12660 p_organization_id IN NUMBER
12661 , p_wip_entity_id IN NUMBER
12662 , p_operation_seq_num IN NUMBER
12663 , p_routing_operation IN NUMBER
12664 , p_responsibility_id IN NUMBER
12665 , p_standard_op_id IN NUMBER
12666 , p_current_step_type IN NUMBER
12667 , p_status_type IN NUMBER
12668 , x_show_move_in OUT NOCOPY NUMBER
12669 , x_show_move_out OUT NOCOPY NUMBER
12670 , x_show_move_to_next_op OUT NOCOPY NUMBER
12671 , x_show_serial_region OUT NOCOPY NUMBER
12672 , x_show_scrap_codes OUT NOCOPY NUMBER
12673 , x_show_bonus_codes OUT NOCOPY NUMBER
12674 , x_show_secondary_quantities OUT NOCOPY NUMBER
12675 , x_show_lot_attrib OUT NOCOPY NUMBER
12676 , x_return_status OUT NOCOPY VARCHAR2
12677 , x_msg_count OUT NOCOPY NUMBER
12678 , x_msg_data OUT NOCOPY VARCHAR2
12679 )
12680 IS
12681 l_stmt_num NUMBER := 0;
12682 l_serialization_started NUMBER;
12683 l_first_serial_txn_id NUMBER; --bug 5444062
12684 l_serialization_start_op NUMBER; --bug 5444062
12685 l_end_routing_operation NUMBER; --bug 5444062
12686 l_move_codemask NUMBER;
12687 l_current_job_op_seq_num NUMBER;
12688 -- Logging variables.....
12689 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12690 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12691 l_module CONSTANT VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.getJobOpPageProperties';
12692 l_param_tbl WSM_Log_PVT.param_tbl_type;
12693 x_error_count NUMBER;
12694 x_return_code NUMBER;
12695 x_error_msg VARCHAR2(4000);
12696 BEGIN
12697 l_stmt_num := 10;
12698 x_return_status := 'S';
12699 IF (G_LOG_LEVEL_PROCEDURE >= l_log_level) THEN
12700 l_msg_tokens.delete;
12701 WSM_log_PVT.logMessage (
12702 p_module_name => l_module ,
12703 p_msg_text => 'Begin getMoveOutPageProperties: '||
12704 'p_organization_id '||p_organization_id||
12705 '; p_wip_entity_id '||p_wip_entity_id||
12706 '; p_operation_seq_num '||p_operation_seq_num||
12707 '; p_routing_operation '||p_routing_operation||
12708 '; p_responsibility_id '||p_responsibility_id||
12709 '; p_standard_op_id '||p_standard_op_id||
12710 '; p_current_step_type '||p_current_step_type||
12711 '; p_status_type '||p_status_type,
12712 p_stmt_num => l_stmt_num ,
12713 p_msg_tokens => l_msg_tokens ,
12714 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE ,
12715 p_run_log_level => l_log_level
12716 );
12717 END IF;
12718
12719 l_stmt_num := 40;
12720 /****bug 5444062 Replaced the sql below with a sql getting the values and logic in pl/sql for determining
12721 x_show_serial_region
12722 --bug 5236293 added the decode to check if p_routing_operation is null
12723 SELECT decode(first_serial_txn_id,
12724 null, decode(p_routing_operation,
12725 null, 0,
12726 decode(serialization_start_op,
12727 p_routing_operation, 1,
12728 0)
12729 ),
12730 1),
12731 current_job_op_seq_num
12732 INTO x_show_serial_region, l_current_job_op_seq_num
12733 FROM WSM_LOT_BASED_JOBS
12734 WHERE wip_entity_id = p_wip_entity_id;
12735 ******/
12736
12737 SELECT first_serial_txn_id, serialization_start_op, current_job_op_seq_num
12738 INTO l_first_serial_txn_id, l_serialization_start_op, l_current_job_op_seq_num
12739 FROM WSM_LOT_BASED_JOBS
12740 WHERE wip_entity_id = p_wip_entity_id;
12741
12742 x_show_serial_region := 0;
12743 --serialization started
12744 IF (l_first_serial_txn_id IS NOT NULL) THEN
12745 x_show_serial_region := 1;
12746 ELSE
12747 --job outside routing
12748 IF (p_routing_operation IS NULL) THEN
12749 x_show_serial_region := 0;
12750 --job is at serialization op
12751 ELSIF (l_serialization_start_op = p_routing_operation) THEN
12752 x_show_serial_region := 1;
12753 --assembly is serial controlled tracked and job is at last operation
12754 ELSIF (l_serialization_start_op IS NOT NULL) THEN
12755
12756 l_stmt_num := 40.1;
12757 SELECT operation_seq_num
12758 INTO l_end_routing_operation
12759 FROM WSM_COPY_OPERATIONS WCO
12760 WHERE WCO.wip_entity_id = p_wip_entity_id
12761 AND WCO.network_start_end = 'E';
12762
12763 IF (p_routing_operation = l_end_routing_operation) THEN
12764 x_show_serial_region := 1;
12765 END IF;
12766 END IF;
12767 END IF;
12768 --end bug 5444062
12769
12770 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
12771 l_stmt_num := 20;
12772 l_move_codemask := WSM_MES_UTILITIES_PVT.move_txn_allowed(
12773 p_responsibility_id => fnd_global.resp_id,
12774 p_wip_entity_id => p_wip_entity_id,
12775 p_org_id => p_organization_id,
12776 p_job_op_seq_num => p_operation_seq_num,
12777 p_standard_op_id => p_standard_op_id,
12778 p_intraop_step => p_current_step_type,
12779 p_status_type => p_status_type
12780 );
12781 END IF;
12782
12783 l_stmt_num := 30;
12784 SELECT decode(bitand(l_move_codemask, 65536), 65536, 1, 0),
12785 decode(bitand(l_move_codemask, 131072), 131072, 1, 0),
12786 decode(bitand(l_move_codemask, 262144), 262144, 1, 0)
12787 INTO x_show_move_in, x_show_move_out, x_show_move_to_next_op
12788 FROM dual;
12789
12790 l_stmt_num := 50;
12791 BEGIN
12792 SELECT 1
12793 INTO x_show_scrap_codes
12794 FROM dual
12795 WHERE EXISTS(
12796 SELECT 'scrap codes exist'
12797 FROM WSM_OP_REASON_CODES
12798 WHERE wip_entity_id = p_wip_entity_id
12799 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12800 AND operation_seq_num = p_operation_seq_num
12801 AND code_type = 1
12802 );
12803 EXCEPTION
12804 WHEN no_data_found THEN
12805 x_show_scrap_codes := 0;
12806 END;
12807
12808 l_stmt_num := 60;
12809 BEGIN
12810 SELECT 1
12811 INTO x_show_bonus_codes
12812 FROM dual
12813 WHERE EXISTS(
12814 SELECT 'bonus codes exist'
12815 FROM WSM_OP_REASON_CODES
12816 WHERE wip_entity_id = p_wip_entity_id
12817 --bug 5191223 Added the condition operation_seq_num = p_operation_seq_num
12818 AND operation_seq_num = p_operation_seq_num
12819 AND code_type = 2
12820 );
12821 EXCEPTION
12822 WHEN no_data_found THEN
12823 x_show_bonus_codes := 0;
12824 END;
12825
12826 l_stmt_num := 70;
12827 BEGIN
12828 SELECT 1
12829 INTO x_show_secondary_quantities
12830 FROM dual
12831 WHERE EXISTS(
12832 SELECT 'secondary quantities exist'
12833 FROM WSM_OP_SECONDARY_QUANTITIES
12834 WHERE wip_entity_id = p_wip_entity_id
12835 AND operation_seq_num = p_operation_seq_num
12836
12837 );
12838 EXCEPTION
12839 WHEN no_data_found THEN
12840 x_show_secondary_quantities := 0;
12841 END;
12842
12843 l_stmt_num := 80;
12844 /*****bug 5192129 OSFMST1: LOT ATTRIBUTES TAB IS DISPLAYED EVEN WITH SHOW LOT ATTRIBUTES SET TO NO*****
12845 **show_lot_attrib is not applicable for job operation page - always set it to 1**
12846 IF (p_routing_operation IS NOT NULL) THEN
12847 SELECT nvl(BOS.show_lot_attrib, 0)
12848 INTO x_show_lot_attrib
12849 FROM BOM_OPERATION_SEQUENCES BOS, WIP_OPERATIONS WO
12850 WHERE WO.wip_entity_id = p_wip_entity_id
12851 AND WO.operation_seq_num = p_operation_seq_num
12852 AND BOS.operation_sequence_id = WO.operation_sequence_id;
12853 ELSE
12854 SELECT nvl(BSO.show_lot_attrib, 0)
12855 INTO x_show_lot_attrib
12856 FROM BOM_STANDARD_OPERATIONS BSO
12857 WHERE BSO.standard_operation_id = p_standard_op_id;
12858 END IF;
12859 ********************************************************************/
12860 x_show_lot_attrib := 1;
12861
12862 IF G_LOG_LEVEL_PROCEDURE >= l_log_level THEN
12863
12864 l_param_tbl.delete;
12865 l_param_tbl(1).paramName := 'x_show_move_in';
12866 l_param_tbl(1).paramValue := x_show_move_in;
12867 l_param_tbl(2).paramName := 'x_show_move_out';
12868 l_param_tbl(2).paramValue := x_show_move_out;
12869 l_param_tbl(3).paramName := 'x_show_move_to_next_op';
12870 l_param_tbl(3).paramValue := x_show_move_to_next_op;
12871 l_param_tbl(4).paramName := 'x_show_serial_region';
12872 l_param_tbl(4).paramValue := x_show_serial_region;
12873 l_param_tbl(5).paramName := 'x_show_scrap_codes';
12874 l_param_tbl(5).paramValue := x_show_scrap_codes;
12875 l_param_tbl(6).paramName := 'x_show_bonus_codes';
12876 l_param_tbl(6).paramValue := x_show_bonus_codes;
12877 l_param_tbl(7).paramName := 'x_show_secondary_quantities';
12878 l_param_tbl(7).paramValue := x_show_secondary_quantities;
12879 l_param_tbl(8).paramName := 'x_show_lot_attrib';
12880 l_param_tbl(8).paramValue := x_show_lot_attrib;
12881 l_param_tbl(9).paramName := 'x_return_status';
12882 l_param_tbl(9).paramValue := x_return_status;
12883 l_param_tbl(10).paramName := 'x_msg_count';
12884 l_param_tbl(10).paramValue := x_msg_count;
12885 l_param_tbl(11).paramName := 'x_msg_data';
12886 l_param_tbl(11).paramValue := x_msg_data;
12887 WSM_Log_PVT.logProcParams(
12888 p_module_name => l_module ,
12889 p_param_tbl => l_param_tbl,
12890 p_fnd_log_level => G_LOG_LEVEL_PROCEDURE
12891 );
12892 END IF;
12893
12894
12895 FND_MSG_PUB.Count_And_Get
12896 ( p_count => x_msg_count ,
12897 p_data => x_msg_data
12898 );
12899
12900 EXCEPTION
12901 WHEN FND_API.G_EXC_ERROR THEN
12902 x_return_status := G_RET_ERROR;
12903 FND_MSG_PUB.Count_And_Get
12904 ( p_count => x_msg_count ,
12905 p_data => x_msg_data
12906 );
12907
12908
12909 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12910 x_return_status := G_RET_UNEXPECTED;
12911 FND_MSG_PUB.Count_And_Get
12912 ( p_count => x_msg_count ,
12913 p_data => x_msg_data
12914 );
12915
12916 WHEN OTHERS THEN
12917
12918 x_return_status := G_RET_UNEXPECTED;
12919
12920 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
12921 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
12922 THEN
12923 WSM_log_PVT.handle_others(
12924 p_module_name => l_module,
12925 p_stmt_num => l_stmt_num,
12926 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED,
12927 p_run_log_level => l_log_level
12928 );
12929 END IF;
12930
12931 FND_MSG_PUB.Count_And_Get
12932 ( p_count => x_msg_count ,
12933 p_data => x_msg_data
12934 );
12935
12936
12937 END;
12938
12939 /****************************************************************************
12940 Updates the WO.costed_quantity_completed column from Move form, interface and OA page
12941 ****************************************************************************/
12942 --mes
12943 Procedure update_costed_qty_compl(
12944 p_transaction_type NUMBER
12945 , p_job_fm_op_seq_num NUMBER
12946 , p_job_to_op_seq_num NUMBER
12947 , p_wip_entity_id NUMBER
12948 , p_fm_intraoperation_step_type NUMBER
12949 , p_to_intraoperation_step_type NUMBER
12950 , p_primary_move_qty NUMBER
12951 , p_primary_scrap_qty NUMBER
12952 , p_scrap_at_op NUMBER
12953 )
12954 IS
12955 l_costed_quantity_completed NUMBER := 0;
12956 l_fm_costed_quantity_completed NUMBER := 0;
12957 l_to_costed_quantity_completed NUMBER := 0;
12958 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
12959 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
12960 l_module VARCHAR2(100) := 'wsm.plsql.WSMPLBMI.update_costed_qty_compl';
12961 l_stmt_num NUMBER := 0;
12962 BEGIN
12963 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
12964 l_msg_tokens.delete;
12965 WSM_log_PVT.logMessage (
12966 p_module_name => l_module,
12967 p_msg_text => 'Begin procedure update_costed_qty_compl'
12968 ||';p_transaction_type '
12969 ||p_transaction_type
12970 ||';p_job_fm_op_seq_num '
12971 ||p_job_fm_op_seq_num
12972 ||';p_job_to_op_seq_num '
12973 ||p_job_to_op_seq_num
12974 ||';p_wip_entity_id '
12975 ||p_wip_entity_id
12976 ||';p_fm_intraoperation_step_type '
12977 ||p_fm_intraoperation_step_type
12978 ||';p_to_intraoperation_step_type '
12979 ||p_to_intraoperation_step_type
12980 ||';p_primary_move_qty '
12981 ||p_primary_move_qty
12982 ||';p_primary_scrap_qty '
12983 ||p_primary_scrap_qty
12984 ||';p_scrap_at_op '
12985 ||p_scrap_at_op,
12986 p_stmt_num => l_stmt_num,
12987 p_msg_tokens => l_msg_tokens,
12988 p_fnd_log_level => G_LOG_LEVEL_STATEMENT,
12989 p_run_log_level => l_log_level
12990 );
12991 END IF;
12992
12993 IF (p_transaction_type IN (g_move_txn, g_comp_txn)) THEN
12994 IF (p_job_fm_op_seq_num <> p_job_to_op_seq_num) THEN
12995
12996 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
12997 AND (p_primary_scrap_qty = 0)) THEN
12998 l_fm_costed_quantity_completed := p_primary_move_qty;
12999 l_to_costed_quantity_completed := 0;
13000 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13001 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13002 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13003 l_to_costed_quantity_completed := 0;
13004 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13005 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13006 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13007 l_to_costed_quantity_completed := p_primary_scrap_qty;
13008 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13009 AND (p_primary_scrap_qty = 0)) THEN
13010 l_fm_costed_quantity_completed := p_primary_move_qty;
13011 l_to_costed_quantity_completed := 0;
13012 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13013 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13014 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13015 l_to_costed_quantity_completed := 0;
13016 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13017 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13018 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13019 l_to_costed_quantity_completed := p_primary_scrap_qty;
13020 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13021 AND (p_primary_scrap_qty = 0)) THEN
13022 l_fm_costed_quantity_completed := p_primary_move_qty;
13023 l_to_costed_quantity_completed := p_primary_move_qty;
13024 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13025 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13026 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13027 l_to_costed_quantity_completed := p_primary_move_qty;
13028 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13029 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13030 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13031 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13032 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13033 AND (p_primary_scrap_qty = 0)) THEN
13034 l_fm_costed_quantity_completed := p_primary_move_qty;
13035 l_to_costed_quantity_completed := 0;
13036 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13037 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13038 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13039 l_to_costed_quantity_completed := 0;
13040 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13041 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13042 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13043 l_to_costed_quantity_completed := p_primary_scrap_qty;
13044 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13045 AND (p_primary_scrap_qty = 0)) THEN
13046 l_fm_costed_quantity_completed := p_primary_move_qty;
13047 l_to_costed_quantity_completed := 0;
13048 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13049 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13050 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13051 l_to_costed_quantity_completed := 0;
13052 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13053 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13054 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13055 l_to_costed_quantity_completed := p_primary_scrap_qty;
13056 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13057 AND (p_primary_scrap_qty = 0)) THEN
13058 l_fm_costed_quantity_completed := p_primary_move_qty;
13059 l_to_costed_quantity_completed := p_primary_move_qty;
13060 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13061 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13062 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13063 l_to_costed_quantity_completed := p_primary_move_qty;
13064 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13065 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13066 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13067 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13068 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13069 AND (p_primary_scrap_qty = 0)) THEN
13070 l_fm_costed_quantity_completed := 0;
13071 l_to_costed_quantity_completed := 0;
13072 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13073 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13074 l_fm_costed_quantity_completed := 0;
13075 l_to_costed_quantity_completed := 0;
13076 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13077 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13078 l_fm_costed_quantity_completed := 0;
13079 l_to_costed_quantity_completed := p_primary_scrap_qty;
13080 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13081 AND (p_primary_scrap_qty = 0)) THEN
13082 l_fm_costed_quantity_completed := 0;
13083 l_to_costed_quantity_completed := 0;
13084 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13085 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13086 l_fm_costed_quantity_completed := 0;
13087 l_to_costed_quantity_completed := 0;
13088 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13089 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13090 l_fm_costed_quantity_completed := 0;
13091 l_to_costed_quantity_completed := p_primary_scrap_qty;
13092 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13093 AND (p_primary_scrap_qty = 0)) THEN
13094 l_fm_costed_quantity_completed := 0;
13095 l_to_costed_quantity_completed := p_primary_move_qty;
13096 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13097 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13098 l_fm_costed_quantity_completed := 0;
13099 l_to_costed_quantity_completed := p_primary_move_qty;
13100 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13101 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13102 l_fm_costed_quantity_completed := 0;
13103 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13104 END IF;
13105
13106 IF (l_fm_costed_quantity_completed > 0) THEN
13107 UPDATE WIP_OPERATIONS
13108 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) +
13109 l_fm_costed_quantity_completed
13110 WHERE wip_entity_id = p_wip_entity_id
13111 AND operation_seq_num = p_job_fm_op_seq_num;
13112 END IF;
13113
13114 IF (l_to_costed_quantity_completed > 0) THEN
13115 UPDATE WIP_OPERATIONS
13116 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) +
13117 l_to_costed_quantity_completed
13118 WHERE wip_entity_id = p_wip_entity_id
13119 AND operation_seq_num = p_job_to_op_seq_num;
13120 END IF;
13121
13122 ELSE --(l_fm_op_seq_num <> l_job_to_op_seq_num)
13123 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13124 AND (p_primary_scrap_qty = 0)) THEN
13125 l_costed_quantity_completed := 0;
13126 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13127 AND (p_primary_scrap_qty > 0)) THEN
13128 l_costed_quantity_completed := p_primary_scrap_qty;
13129 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13130 AND (p_primary_scrap_qty = 0)) THEN
13131 l_costed_quantity_completed := p_primary_move_qty;
13132 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13133 AND (p_primary_scrap_qty > 0)) THEN
13134 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13135 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_scrap))
13136 THEN
13137 IF nvl(p_primary_move_qty, 0) > 0 THEN
13138 l_costed_quantity_completed := p_primary_move_qty;
13139 ELSE
13140 l_costed_quantity_completed := p_primary_scrap_qty;
13141 END IF;
13142 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13143 AND (p_primary_scrap_qty = 0)) THEN
13144 l_costed_quantity_completed := p_primary_move_qty;
13145 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13146 AND (p_primary_scrap_qty > 0)) THEN
13147 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13148 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_scrap))
13149 THEN
13150 IF nvl(p_primary_move_qty, 0) > 0 THEN
13151 l_costed_quantity_completed := p_primary_move_qty;
13152 ELSE
13153 l_costed_quantity_completed := p_primary_scrap_qty;
13154 END IF;
13155 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_scrap)) THEN
13156 l_costed_quantity_completed := 0;
13157 END IF;
13158
13159 IF (l_costed_quantity_completed > 0) THEN
13160 UPDATE WIP_OPERATIONS
13161 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) + l_costed_quantity_completed
13162 WHERE wip_entity_id = p_wip_entity_id
13163 AND operation_seq_num = p_job_fm_op_seq_num;
13164 END IF;
13165 END IF;
13166 ELSE --(l_transaction_type IN (g_move_txn, g_comp_txn))
13167 IF (p_job_fm_op_seq_num <> p_job_to_op_seq_num) THEN
13168
13169 IF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13170 AND (p_primary_scrap_qty = 0)) THEN
13171 l_to_costed_quantity_completed := p_primary_move_qty;
13172 l_fm_costed_quantity_completed := 0;
13173 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13174 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13175 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13176 l_fm_costed_quantity_completed := 0;
13177 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_queue)
13178 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13179 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13180 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13181 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13182 AND (p_primary_scrap_qty = 0)) THEN
13183 l_to_costed_quantity_completed := p_primary_move_qty;
13184 l_fm_costed_quantity_completed := 0;
13185 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13186 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13187 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13188 l_fm_costed_quantity_completed := 0;
13189 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_run)
13190 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13191 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13192 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13193 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13194 AND (p_primary_scrap_qty = 0)) THEN
13195 l_to_costed_quantity_completed := 0;
13196 l_fm_costed_quantity_completed := 0;
13197 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13198 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13199 l_to_costed_quantity_completed := 0;
13200 l_fm_costed_quantity_completed := 0;
13201 ELSIF ((p_fm_intraoperation_step_type = g_queue) AND (p_to_intraoperation_step_type = g_tomove)
13202 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13203 l_to_costed_quantity_completed := 0;
13204 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13205 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13206 AND (p_primary_scrap_qty = 0)) THEN
13207 l_to_costed_quantity_completed := p_primary_move_qty;
13208 l_fm_costed_quantity_completed := 0;
13209 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13210 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13211 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13212 l_fm_costed_quantity_completed := 0;
13213 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13214 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13215 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13216 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13217 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13218 AND (p_primary_scrap_qty = 0)) THEN
13219 l_to_costed_quantity_completed := p_primary_move_qty;
13220 l_fm_costed_quantity_completed := 0;
13221 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13222 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13223 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13224 l_fm_costed_quantity_completed := 0;
13225 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_run)
13226 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13227 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13228 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13229 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13230 AND (p_primary_scrap_qty = 0)) THEN
13231 l_to_costed_quantity_completed := 0;
13232 l_fm_costed_quantity_completed := 0;
13233 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13234 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13235 l_to_costed_quantity_completed := 0;
13236 l_fm_costed_quantity_completed := 0;
13237 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_tomove)
13238 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13239 l_to_costed_quantity_completed := 0;
13240 l_fm_costed_quantity_completed := p_primary_scrap_qty;
13241 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13242 AND (p_primary_scrap_qty = 0)) THEN
13243 l_to_costed_quantity_completed := p_primary_move_qty;
13244 l_fm_costed_quantity_completed := p_primary_move_qty;
13245 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13246 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13247 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13248 l_fm_costed_quantity_completed := p_primary_move_qty;
13249 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13250 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13251 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13252 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13253 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13254 AND (p_primary_scrap_qty = 0)) THEN
13255 l_to_costed_quantity_completed := p_primary_move_qty;
13256 l_fm_costed_quantity_completed := p_primary_move_qty;
13257 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13258 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13259 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13260 l_fm_costed_quantity_completed := p_primary_move_qty;
13261 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13262 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13263 l_to_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13264 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13265 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13266 AND (p_primary_scrap_qty = 0)) THEN
13267 l_to_costed_quantity_completed := 0;
13268 l_fm_costed_quantity_completed := p_primary_move_qty;
13269 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13270 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 1)) THEN
13271 l_to_costed_quantity_completed := 0;
13272 l_fm_costed_quantity_completed := p_primary_move_qty;
13273 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_tomove)
13274 AND (p_primary_scrap_qty > 0) AND (p_scrap_at_op = 2)) THEN
13275 l_to_costed_quantity_completed := 0;
13276 l_fm_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13277 END IF;
13278
13279 IF (l_fm_costed_quantity_completed > 0) THEN
13280 UPDATE WIP_OPERATIONS
13281 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) -
13282 l_fm_costed_quantity_completed
13283 WHERE wip_entity_id = p_wip_entity_id
13284 AND operation_seq_num = p_job_fm_op_seq_num;
13285 END IF;
13286
13287 IF (l_to_costed_quantity_completed > 0) THEN
13288 UPDATE WIP_OPERATIONS
13289 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) -
13290 l_to_costed_quantity_completed
13291 WHERE wip_entity_id = p_wip_entity_id
13292 AND operation_seq_num = p_job_to_op_seq_num;
13293 END IF;
13294
13295 ELSE --(l_fm_op_seq_num <> l_job_to_op_seq_num)
13296 IF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13297 AND (p_primary_scrap_qty = 0)) THEN
13298 l_costed_quantity_completed := 0;
13299 ELSIF ((p_fm_intraoperation_step_type = g_run) AND (p_to_intraoperation_step_type = g_queue)
13300 AND (p_primary_scrap_qty > 0)) THEN
13301 l_costed_quantity_completed := p_primary_scrap_qty;
13302 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13303 AND (p_primary_scrap_qty = 0)) THEN
13304 l_costed_quantity_completed := p_primary_move_qty;
13305 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_queue)
13306 AND (p_primary_scrap_qty > 0)) THEN
13307 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13308 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_queue))
13309 THEN
13310 IF nvl(p_primary_move_qty, 0) > 0 THEN
13311 l_costed_quantity_completed := p_primary_move_qty;
13312 ELSE
13313 l_costed_quantity_completed := p_primary_scrap_qty;
13314 END IF;
13315 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13316 AND (p_primary_scrap_qty = 0)) THEN
13317 l_costed_quantity_completed := p_primary_move_qty;
13318 ELSIF ((p_fm_intraoperation_step_type = g_tomove) AND (p_to_intraoperation_step_type = g_run)
13319 AND (p_primary_scrap_qty > 0)) THEN
13320 l_costed_quantity_completed := p_primary_move_qty + p_primary_scrap_qty;
13321 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_run))
13322 THEN
13323 IF nvl(p_primary_move_qty, 0) > 0 THEN
13324 l_costed_quantity_completed := p_primary_move_qty;
13325 ELSE
13326 l_costed_quantity_completed := p_primary_scrap_qty;
13327 END IF;
13328 ELSIF ((p_fm_intraoperation_step_type = g_scrap) AND (p_to_intraoperation_step_type = g_tomove)) THEN
13329 l_costed_quantity_completed := 0;
13330 END IF;
13331
13332 IF (l_costed_quantity_completed > 0) THEN
13333 UPDATE WIP_OPERATIONS
13334 SET wsm_costed_quantity_completed = nvl(wsm_costed_quantity_completed, 0) - l_costed_quantity_completed
13335 WHERE wip_entity_id = p_wip_entity_id
13336 AND operation_seq_num = p_job_fm_op_seq_num;
13337 END IF;
13338 END IF;
13339 END IF; --(l_transaction_type IN (g_move_txn, g_comp_txn))
13340 END update_costed_qty_compl;
13341
13342 Function convert_uom(
13343 p_time_hours NUMBER, -- from_quantity
13344 p_to_uom VARCHAR2 -- to_unit
13345 ) RETURN NUMBER IS
13346 l_uom_rate NUMBER;
13347 l_hrUOM VARCHAR2(3) := fnd_profile.value('BOM:HOUR_UOM_CODE');
13348 l_hrUOM_class VARCHAR2(10);
13349 l_resUOM_class VARCHAR2(10);
13350 BEGIN
13351
13352 select uom_class
13353 into l_hrUOM_class
13354 from mtl_units_of_measure
13355 where uom_code = l_hrUOM;
13356
13357 select uom_class
13358 into l_resUOM_class
13359 from mtl_units_of_measure
13360 where uom_code = p_to_uom;
13361
13362 IF (l_hrUOM_class = l_resUOM_class) THEN
13363 l_uom_rate := inv_convert.inv_um_convert(
13364 0, -- item_id
13365 NULL, -- precision
13366 p_time_hours, -- from_quantity
13367 l_hrUOM, -- from_unit
13368 p_to_uom, -- to_unit
13369 NULL, -- from_name
13370 NULL); -- to_name
13371 ELSE
13372 l_uom_rate := NULL;
13373 END IF;
13374
13375 RETURN l_uom_rate;
13376
13377 EXCEPTION
13378 WHEN OTHERS THEN
13379 RETURN NULL;
13380 END convert_uom;
13381 --mes end
13382
13383 END WSMPLBMI;
13384