[Home] [Help]
PACKAGE BODY: APPS.WSM_WLT_VALIDATE_PVT
Source
1 package body WSM_WLT_VALIDATE_PVT as
2 /* $Header: WSMVVLDB.pls 120.28 2006/09/19 07:28:21 nlal noship $ */
3
4 -- Package name
5 g_pkg_name VARCHAR2(20) := 'WSM_WLT_VALIDATE_PVT';
6
7 --logging variables
8 g_log_level_unexpected NUMBER := FND_LOG.LEVEL_UNEXPECTED ;
9 g_log_level_error number := FND_LOG.LEVEL_ERROR ;
10 g_log_level_exception number := FND_LOG.LEVEL_EXCEPTION ;
11 g_log_level_event number := FND_LOG.LEVEL_EVENT ;
12 g_log_level_procedure number := FND_LOG.LEVEL_PROCEDURE ;
13 g_log_level_statement number := FND_LOG.LEVEL_STATEMENT ;
14
15 g_msg_lvl_unexp_error NUMBER := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR ;
16 g_msg_lvl_error NUMBER := FND_MSG_PUB.G_MSG_LVL_ERROR ;
17 g_msg_lvl_success NUMBER := FND_MSG_PUB.G_MSG_LVL_SUCCESS ;
18 g_msg_lvl_debug_high NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH ;
19 g_msg_lvl_debug_medium NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM ;
20 g_msg_lvl_debug_low NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW ;
21
22 g_ret_success varchar2(1) := FND_API.G_RET_STS_SUCCESS;
23 g_ret_error varchar2(1) := FND_API.G_RET_STS_ERROR;
24 g_ret_unexpected varchar2(1) := FND_API.G_RET_STS_UNEXP_ERROR;
25
26 type t_wip_entity_name_tbl is table of NUMBER index by WIP_ENTITIES.wip_entity_name%TYPE;
27
28 -- Derives the routing sequence information...
29 PROCEDURE routing_seq ( p_job_type IN NUMBER,
30 p_org_id IN NUMBER,
31 p_item_id IN NUMBER,
32 p_alt_rtg IN OUT NOCOPY VARCHAR2,
33 p_common_rtg_seq_id IN OUT NOCOPY NUMBER, --VJ: Added
34 p_rtg_ref_id IN OUT NOCOPY NUMBER,
35 p_default_subinv OUT NOCOPY VARCHAR2,
36 p_default_loc_id OUT NOCOPY NUMBER,
37 x_rtg_seq_id OUT NOCOPY NUMBER,
38 --x_common_rtg_seq_id OUT NOCOPY NUMBER, --VJ: Deleted
39 x_return_status OUT NOCOPY VARCHAR2,
40 x_error_msg OUT NOCOPY VARCHAR2,
41 x_error_count OUT NOCOPY NUMBER
42 ) IS
43
44
45 l_rtg_item_id number;
46 l_err_code NUMBER;
47 -- Logging variables.....
48 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
49 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
50
51 l_stmt_num NUMBER;
52 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.routing_seq';
53 l_param_tbl WSM_Log_PVT.param_tbl_type;
54 -- Logging variables...
55
56
57 BEGIN
58 x_return_status := G_RET_SUCCESS;
59 x_error_msg := NULL;
60 x_error_count := 0;
61
62 l_stmt_num := 10;
63 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
64
65 l_stmt_num := 15;
66 l_param_tbl.delete;
67
68 l_param_tbl(1).paramName := 'p_job_type';
69 l_param_tbl(1).paramValue := p_job_type;
70
71 l_param_tbl(2).paramName := 'p_org_id';
72 l_param_tbl(2).paramValue := p_org_id;
73
74 l_param_tbl(3).paramName := 'p_item_id';
75 l_param_tbl(3).paramValue := p_item_id;
76
77 l_param_tbl(4).paramName := 'p_default_loc_id';
78 l_param_tbl(4).paramValue := p_default_loc_id;
79
80 l_param_tbl(5).paramName := 'p_alt_rtg';
81 l_param_tbl(5).paramValue := p_alt_rtg;
82
83 l_param_tbl(6).paramName := 'p_rtg_ref_id';
84 l_param_tbl(6).paramValue := p_rtg_ref_id;
85
86 l_param_tbl(7).paramName := 'p_default_subinv';
87 l_param_tbl(7).paramValue := p_default_subinv;
88
89
90 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
91 p_param_tbl => l_param_tbl,
92 p_fnd_log_level => l_log_level
93 );
94 END IF;
95
96 if(p_job_type = 1) then -- std job
97 -- ignore p_rtg_ref_id
98 p_rtg_ref_id := null;
99 l_rtg_item_id := p_item_id;
100 else -- non-std job
101 if p_rtg_ref_id is null then
102
103 IF g_log_level_error >= l_log_level OR
104 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
105 THEN
106 l_msg_tokens.delete;
107 WSM_log_PVT.logMessage(p_module_name => l_module ,
108 p_msg_name => 'WSM_NS_RTNG_REF_NULL' ,
109 p_msg_appl_name => 'WSM' ,
110 p_msg_tokens => l_msg_tokens ,
111 p_fnd_msg_level => G_MSG_LVL_ERROR ,
112 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
113 p_run_log_level => l_log_level
114 );
115 END IF;
116 RAISE FND_API.G_EXC_ERROR;
117
118 end if;
119 l_rtg_item_id := p_rtg_ref_id;
120
121 end if;
122
123 -- CZHDBG only creation/std-job is here now
124 l_stmt_num := 20;
125 IF p_common_rtg_seq_id IS NULL --VJ: Added
126 THEN
127 BEGIN
128 select bor.routing_sequence_id,
129 bor.completion_subinventory,
130 bor.completion_locator_id
131 into x_rtg_seq_id,
132 p_default_subinv,
133 p_default_loc_id
134 from bom_routing_alternates_v bor
135 where bor.organization_id = p_org_id
136 and bor.assembly_item_id = l_rtg_item_id
137 and NVL(bor.alternate_routing_designator, '##@@')
138 = NVL(p_alt_rtg, '##@@')
139 and bor.routing_type = 1
140 and bor.cfm_routing_flag = 3;
141 EXCEPTION
142 WHEN no_data_found then
143 IF g_log_level_error >= l_log_level OR
144 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
145 THEN
146 l_msg_tokens.delete;
147 l_msg_tokens(1).TokenName := 'FLD_NAME';
148 IF (p_job_type = 1) THEN -- std job
149 l_msg_tokens(1).TokenValue := 'PRIMARY_ITEM_ID/ALTERNATE_ROUTING_DESIGNATOR';
150 ELSE
151 l_msg_tokens(1).TokenValue := 'ROUTING_REFERENCE_ID/ALTERNATE_ROUTING_DESIGNATOR';
152 END IF;
153
154 WSM_log_PVT.logMessage(p_module_name => l_module ,
155 p_msg_name => 'WSM_INVALID_FIELD' ,
156 p_msg_appl_name => 'WSM' ,
157 p_msg_tokens => l_msg_tokens ,
158 p_fnd_msg_level => G_MSG_LVL_ERROR ,
159 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
160 p_run_log_level => l_log_level
161 );
162 END IF;
163 RAISE FND_API.G_EXC_ERROR;
164 END;
165
166 l_stmt_num := 30;
167 -- Get common routing seq id
168 -- No error code is set in find_common_routing... so compare based on x_msg_data..
169 wsmputil.find_common_routing( p_routing_sequence_id => x_rtg_seq_id,
170 p_common_routing_sequence_id => p_common_rtg_seq_id, --x_common_rtg_seq_id -- VJ: Changed
171 x_err_code => l_err_code,
172 x_err_msg => x_error_msg
173 );
174 if x_error_msg IS NOT NULL then
175 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
176 end if;
177
178 --VJ: Start additions --
179 ELSIF p_common_rtg_seq_id IS NOT NULL
180 THEN
181
182 BEGIN
183 SELECT routing_sequence_id,
184 alternate_routing_designator,
185 completion_subinventory,
186 completion_locator_id
187 INTO x_rtg_seq_id,
188 p_alt_rtg,
189 p_default_subinv,
190 p_default_loc_id
191 FROM BOM_OPERATIONAL_ROUTINGS
192 WHERE common_routing_sequence_id = p_common_rtg_seq_id
193 AND organization_id = p_org_id
194 AND assembly_item_id = l_rtg_item_id
195 AND routing_type = 1
196 AND cfm_routing_flag = 3;
197
198 EXCEPTION
199 WHEN no_data_found then
200 IF g_log_level_error >= l_log_level OR
201 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
202 THEN
203 l_msg_tokens.delete;
204 l_msg_tokens(1).TokenName := 'FLD_NAME';
205 IF (p_job_type = 1) THEN -- std job
206 l_msg_tokens(1).TokenValue := 'PRIMARY_ITEM_ID/COMMON_ROUTING_SEQUENCE_ID';
207 ELSE
208 l_msg_tokens(1).TokenValue := 'ROUTING_REFERENCE_ID/COMMON_ROUTING_SEQUENCE_ID';
209 END IF;
210
211 WSM_log_PVT.logMessage(p_module_name => l_module ,
212 p_msg_name => 'WSM_INVALID_FIELD' ,
213 p_msg_appl_name => 'WSM' ,
214 p_msg_tokens => l_msg_tokens ,
215 p_fnd_msg_level => G_MSG_LVL_ERROR ,
216 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
217 p_run_log_level => l_log_level
218 );
219 END IF;
220 RAISE FND_API.G_EXC_ERROR;
221 END;
222 END IF; -- end elsif p_common_rtg_seq_id IS NOT NULL
223 --VJ: End additions --
224
225 EXCEPTION
226 WHEN FND_API.G_EXC_ERROR THEN
227 x_return_status := G_RET_ERROR;
228 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
229 p_count => x_error_count ,
230 p_data => x_error_msg
231 );
232
233 WHEN OTHERS THEN
234 x_return_status := G_RET_UNEXPECTED;
235
236 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
237 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
238 THEN
239 WSM_log_PVT.handle_others( p_module_name => l_module ,
240 p_stmt_num => l_stmt_num ,
241 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
242 p_run_log_level => l_log_level
243 );
244 END IF;
245 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
246 p_count => x_error_count ,
247 p_data => x_error_msg
248 );
249 END routing_seq;
250
251
252 -- Procedure to derive the bom information fields
253 PROCEDURE bom_seq ( p_job_type IN NUMBER,
254 p_org_id IN NUMBER,
255 p_item_id IN NUMBER,
256 p_alt_bom IN OUT NOCOPY VARCHAR2,
257 p_common_bom_seq_id IN OUT NOCOPY VARCHAR2, -- VJ: Added
258 p_bom_ref_id IN OUT NOCOPY NUMBER,
259 x_bom_seq_id OUT NOCOPY NUMBER,
260 --x_alt_bom OUT NOCOPY NUMBER, -- VJ: Deleted
261 --x_common_bom_seq_id OUT NOCOPY NUMBER, -- VJ: Deleted
262 x_return_status OUT NOCOPY VARCHAR2,
263 x_error_msg OUT NOCOPY VARCHAR2,
264 x_error_count OUT NOCOPY NUMBER
265 ) IS
266
267
268 l_temp_num number;
269 l_bom_item_id number;
270
271 -- Logging variables.....
272 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
273 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
274
275 l_stmt_num NUMBER;
276 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.bom_seq';
277 l_param_tbl WSM_Log_PVT.param_tbl_type;
278 -- Logging variables...
279
280 BEGIN
281 x_return_status := G_RET_SUCCESS;
282 x_error_msg := NULL;
283 x_error_count := 0;
284
285 l_stmt_num := 10;
286 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
287
288 l_stmt_num := 15;
289 l_param_tbl.delete;
290
291 l_param_tbl(1).paramName := 'p_job_type';
292 l_param_tbl(1).paramValue := p_job_type;
293
294 l_param_tbl(2).paramName := 'p_org_id';
295 l_param_tbl(2).paramValue := p_org_id;
296
297 l_param_tbl(3).paramName := 'p_item_id';
298 l_param_tbl(3).paramValue := p_item_id;
299
300 l_param_tbl(4).paramName := 'p_alt_bom';
301 l_param_tbl(4).paramValue := p_alt_bom;
302
303 l_param_tbl(5).paramName := 'p_common_bom_seq_id';
304 l_param_tbl(5).paramValue := p_common_bom_seq_id;
305
306 l_param_tbl(6).paramName := 'p_bom_ref_id';
307 l_param_tbl(6).paramValue := p_bom_ref_id;
308
309 l_param_tbl(7).paramName := 'x_bom_seq_id';
310 l_param_tbl(7).paramValue := x_bom_seq_id;
311
312 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
313 p_param_tbl => l_param_tbl,
314 p_fnd_log_level => l_log_level
315 );
316 END IF;
317
318 l_stmt_num := 20;
319
320 if(p_job_type = 1) then -- std job
321 -- ignore p_bom_ref_id
322 p_bom_ref_id := null;
323 l_bom_item_id := p_item_id;
324 else -- non-std job
325 l_bom_item_id := p_bom_ref_id;
326 IF (l_bom_item_id IS NOT NULL) THEN
327 BEGIN
328 SELECT 1
329 INTO l_temp_num
330 FROM mtl_system_items_kfv msi
331 WHERE msi.inventory_item_id = l_bom_item_id
332 AND msi.organization_id = p_org_id;
333 EXCEPTION
334 WHEN too_many_rows THEN
335 null;
336 WHEN no_data_found THEN
337 IF g_log_level_error >= l_log_level OR
338 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
339 THEN
340 l_msg_tokens.delete;
341 l_msg_tokens(1).TokenName := 'FLD_NAME';
342 l_msg_tokens(1).TokenValue := 'Bom Reference Id';
343 WSM_log_PVT.logMessage(p_module_name => l_module ,
344 p_msg_name => 'WSM_INVALID_FIELD' ,
345 p_msg_appl_name => 'WSM' ,
346 p_msg_tokens => l_msg_tokens ,
347 p_fnd_msg_level => G_MSG_LVL_ERROR ,
348 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
349 p_run_log_level => l_log_level
350 );
351 END IF;
352 RAISE FND_API.G_EXC_ERROR;
353 END;
354 END IF;
355 END IF; -- end non-std job
356
357 -- l_bom_item_id can be null for non-std job, cannot be null for std job
358 if l_bom_item_id is not null then
359 -- Get common_bom_seq_id
360 -- if the alternate_bom_designator is NULL, bill_seq_id can have either NULL
361 -- when there is no bill defined for the item or the primary bom value. But if
362 -- the designator has ALT, then there must be a bill id for the alternate bom.
363 if (p_alt_bom is null and
364 p_common_bom_seq_id is null) --VJ: Added
365 then
366 l_stmt_num := 30;
367 begin
368 select bom.bill_sequence_id,
369 bom.common_bill_sequence_id
370 into x_bom_seq_id,
371 p_common_bom_seq_id --x_common_bom_seq_id --VJ: Changed
372 from bom_bill_of_materials bom
373 where bom.alternate_bom_designator is null
374 and bom.assembly_item_id = l_bom_item_id
375 and bom.organization_id = p_org_id;
376 EXCEPTION
377 WHEN no_data_found then
378 -- this item does not have a primary bill
379 IF (p_job_type = 1) THEN -- std job
380 x_bom_seq_id := null;
381 p_common_bom_seq_id := null; --VJ: Changed
382 --x_common_bom_seq_id := null; --VJ: Deleted
383 ELSE -- non-std job
384 IF g_log_level_error >= l_log_level OR
385 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
386 THEN
387 l_msg_tokens.delete;
388 WSM_log_PVT.logMessage(p_module_name => l_module ,
389 p_msg_name => 'WIP_BILL_DOES_NOT_EXIST',
390 p_msg_appl_name => 'WIP' ,
391 p_msg_tokens => l_msg_tokens ,
392 p_fnd_msg_level => G_MSG_LVL_ERROR ,
393 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
394 p_run_log_level => l_log_level
395 );
396 END IF;
397 RAISE FND_API.G_EXC_ERROR;
398 END IF;
399 END;
400
401 ELSIF (p_alt_bom is NOT null and p_common_bom_seq_id is null) THEN --VJ: Added
402 l_stmt_num := 40;
403 BEGIN
404 SELECT bom.bill_sequence_id,
405 bom.common_bill_sequence_id
406 INTO x_bom_seq_id,
407 p_common_bom_seq_id --x_common_bom_seq_id --VJ: Changed
408 FROM bom_bill_of_materials bom,
409 bom_alternate_designators bad
410 WHERE ((bom.alternate_bom_designator is null and
411 bad.alternate_designator_code is null and
412 bad.organization_id = -1) or
413 (bom.alternate_bom_designator
414 = bad.alternate_designator_code and
415 bom.organization_id = bad.organization_id))
416 AND bom.alternate_bom_designator = p_alt_bom
417 AND bom.assembly_item_id = l_bom_item_id
418 AND bom.organization_id = p_org_id;
419 -- ST : Bug fix 5107339 : Commented out the validation on bom_alternate_designators.disable_date
420 -- AND trunc(nvl(bad.disable_date, sysdate + 1)) > trunc(sysdate);
421 EXCEPTION
422 WHEN no_data_found then
423 IF g_log_level_error >= l_log_level OR
424 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
425 THEN
426 l_msg_tokens.delete;
427 l_msg_tokens(1).TokenName := 'FLD_NAME';
428 l_msg_tokens(1).TokenValue := 'ALTERNATE_BOM_DESIGNATOR';
429 WSM_log_PVT.logMessage(p_module_name => l_module ,
430 p_msg_name => 'WSM_INVALID_FIELD' ,
431 p_msg_appl_name => 'WSM' ,
432 p_msg_tokens => l_msg_tokens ,
433 p_fnd_msg_level => G_MSG_LVL_ERROR ,
434 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
435 p_run_log_level => l_log_level
436 );
437 END IF;
438 RAISE FND_API.G_EXC_ERROR;
439 END;
440
441 -- VJ : Start Additions --
442 ELSIF (p_alt_bom is null and p_common_bom_seq_id is NOT null) THEN
443 l_stmt_num := 50;
444 BEGIN
445 SELECT bom.bill_sequence_id,
446 bom.alternate_bom_designator
447 INTO x_bom_seq_id,
448 p_alt_bom
449 FROM bom_bill_of_materials bom
450 WHERE bom.common_bill_sequence_id = p_common_bom_seq_id
451 AND bom.assembly_item_id = l_bom_item_id
452 AND bom.organization_id = p_org_id;
453
454 EXCEPTION
455 WHEN no_data_found then
456 IF g_log_level_error >= l_log_level OR
457 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
458 THEN
459 l_msg_tokens.delete;
460 l_msg_tokens(1).TokenName := 'FLD_NAME';
461 l_msg_tokens(1).TokenValue := 'COMMON_BOM_SEQUENCE_ID';
462 WSM_log_PVT.logMessage(p_module_name => l_module ,
463 p_msg_name => 'WSM_INVALID_FIELD' ,
464 p_msg_appl_name => 'WSM' ,
465 p_msg_tokens => l_msg_tokens ,
466 p_fnd_msg_level => G_MSG_LVL_ERROR ,
467 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
468 p_run_log_level => l_log_level
469 );
470 END IF;
471 RAISE FND_API.G_EXC_ERROR;
472 END;
473 ELSE --if p_alt_bom is NOT null
474 -- and p_common_bom_seq_id is NOT null
475 l_stmt_num := 60;
476 BEGIN
477 SELECT 1
478 INTO l_temp_num
479 FROM bom_bill_of_materials bom
480 WHERE bom.common_bill_sequence_id = p_common_bom_seq_id
481 AND bom.alternate_bom_designator = p_alt_bom
482 AND bom.assembly_item_id = l_bom_item_id
483 AND bom.organization_id = p_org_id;
484
485 EXCEPTION
486 WHEN no_data_found then
487 IF g_log_level_error >= l_log_level OR
488 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
489 THEN
490 l_msg_tokens.delete;
491 l_msg_tokens(1).TokenName := 'FLD_NAME';
492 l_msg_tokens(1).TokenValue := 'COMMON_BOM_SEQUENCE_ID';
493 WSM_log_PVT.logMessage(p_module_name => l_module ,
494 p_msg_name => 'WSM_INVALID_FIELD' ,
495 p_msg_appl_name => 'WSM' ,
496 p_msg_tokens => l_msg_tokens ,
497 p_fnd_msg_level => G_MSG_LVL_ERROR ,
498 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
499 p_run_log_level => l_log_level
500 );
501 END IF;
502 RAISE FND_API.G_EXC_ERROR;
503 END;
504 -- VJ : End Additions --
505 END IF; -- end (p_alt_bom is null)
506 ELSE -- non-std job without bom reference
507 x_bom_seq_id := null;
508 p_common_bom_seq_id := null; -- x_common_bom_seq_id --VJ: Changed
509
510 IF p_alt_bom IS NOT NULL THEN
511 p_alt_bom := null; -- ignored
512 END IF;
513 END IF;
514
515 l_stmt_num := 70;
516
517 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
518 l_msg_tokens.delete;
519 WSM_log_PVT.logMessage (p_module_name => l_module ,
520 p_msg_text => l_module || ' completed sucessfully',
521 p_stmt_num => l_stmt_num ,
522 p_msg_tokens => l_msg_tokens ,
523 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
524 p_run_log_level => l_log_level
525 );
526 END IF;
527
528 EXCEPTION
529 WHEN FND_API.G_EXC_ERROR THEN
530 x_return_status := G_RET_ERROR;
531 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
532 p_count => x_error_count ,
533 p_data => x_error_msg
534 );
535
536 WHEN OTHERS THEN
537 x_return_status := G_RET_UNEXPECTED;
538
539 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
540 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
541 THEN
542 WSM_log_PVT.handle_others( p_module_name => l_module ,
543 p_stmt_num => l_stmt_num ,
544 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
545 p_run_log_level => l_log_level
546 );
547 END IF;
548 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
549 p_count => x_error_count ,
550 p_data => x_error_msg
551 );
552 END;
553
554 ----------------------------------------------------------------------------------
555 -- For job creation, wip_entity_id will be ignored, if job_name is NULL, will default
556 -- Will validate whether the job_name is used or not in the organization
557 --
558 -- For job update, wip_entity_id and job_name cannot be NULL together.
559 -- Wip_entity_id is the driven information, only when wip_entity_id is NULL will
560 -- job_name be used to get wip_entity_id
561 -- Will validate the status of the job
562 --
563
564 PROCEDURE wip_entity ( p_load_type IN VARCHAR2, -- C job creation, U job update
565 p_org_id IN NUMBER ,
566 p_wip_entity_id IN OUT NOCOPY NUMBER ,
567 p_job_name IN OUT NOCOPY VARCHAR2,
568 x_return_status OUT NOCOPY VARCHAR2,
569 x_error_msg OUT NOCOPY VARCHAR2,
570 x_error_count OUT NOCOPY NUMBER
571 ) is
572
573 l_temp_num number;
574 l_exists boolean;
575 l_job_name_hash number;
576
577 -- Logging variables.....
578 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
579 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
580
581 l_stmt_num NUMBER;
582 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.wip_entity';
583 l_param_tbl WSM_Log_PVT.param_tbl_type;
584
585 BEGIN
586
587 x_return_status := G_RET_SUCCESS;
588 x_error_msg := NULL;
589 x_error_count := 0;
590
591 l_stmt_num := 10;
592
593 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
594 l_stmt_num := 15;
595
596 l_param_tbl.delete;
597 l_param_tbl(1).paramName := 'p_org_id';
598 l_param_tbl(1).paramValue := p_org_id;
599
600 l_param_tbl(2).paramName := 'p_load_type';
601 l_param_tbl(2).paramValue := p_load_type;
602
603 l_param_tbl(3).paramName := 'p_wip_entity_id';
604 l_param_tbl(3).paramValue := p_wip_entity_id;
605
606 l_param_tbl(4).paramName := 'p_job_name';
607 l_param_tbl(4).paramValue := p_job_name;
608
609 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
610 p_param_tbl => l_param_tbl,
611 p_fnd_log_level => l_log_level
612 );
613 END IF;
614
615 l_stmt_num := 20;
616
617 -- job name should be less than 80 chars
618 IF LENGTH(p_job_name) > 80 THEN
619 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
620 l_msg_tokens.delete;
621 WSM_log_PVT.logMessage(p_module_name=> l_module ,
622 p_msg_name => 'WSM_JOB_NAME_THIRTY_CHAR',
623 p_msg_appl_name => 'WSM',
624 p_msg_tokens => l_msg_tokens ,
625 p_stmt_num => l_stmt_num ,
626 p_fnd_msg_level => G_MSG_LVL_ERROR ,
627 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
628 p_run_log_level => l_log_level
629 );
630 END IF;
631 RAISE FND_API.G_EXC_ERROR;
632 END IF;
633
634 IF p_load_type = 'C' then -- Job creation
635
636 p_wip_entity_id := null; -- Ignore wip_entity_id
637 IF p_job_name IS NULL THEN -- Derive Job_Name.
638 l_stmt_num := 20;
639 SELECT FND_Profile.value('WIP_JOB_PREFIX') || wip_job_number_s.nextval
640 INTO p_job_name
641 FROM dual;
642 END IF;
643
644 -- Be sure the provided Job_Name is not already in use.
645 l_temp_num := 0;
646 BEGIN
647 l_stmt_num := 30;
648 SELECT 1
649 INTO l_temp_num
650 FROM wip_entities
651 WHERE wip_entity_name = p_job_name
652 AND organization_id = p_org_id;
653
654 IF l_temp_num = 1 then
655 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
656 l_msg_tokens.delete;
657 WSM_log_PVT.logMessage(p_module_name=> l_module ,
658 p_msg_name => 'WIP_ML_JOB_NAME',
659 p_msg_appl_name => 'WIP',
660 p_msg_tokens => l_msg_tokens ,
661 p_stmt_num => l_stmt_num ,
662 p_fnd_msg_level => G_MSG_LVL_ERROR ,
663 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
664 p_run_log_level => l_log_level
665 );
666 END IF;
667 RAISE FND_API.G_EXC_ERROR;
668 END IF;
669 EXCEPTION
670 WHEN no_data_found THEN
671 null;
672
673 WHEN OTHERS THEN
674 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
675 l_msg_tokens.delete;
676 WSM_log_PVT.logMessage(p_module_name=> l_module ,
677 p_msg_name => 'WIP_ML_JOB_NAME',
678 p_msg_appl_name => 'WIP',
679 p_msg_tokens => l_msg_tokens ,
680 p_stmt_num => l_stmt_num ,
681 p_fnd_msg_level => G_MSG_LVL_ERROR ,
682 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
683 p_run_log_level => l_log_level
684 );
685 END IF;
686 RAISE FND_API.G_EXC_ERROR;
687 END;
688 END IF; -- Job update
689
690 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
691 l_msg_tokens.delete;
692 WSM_log_PVT.logMessage (p_module_name => l_module ,
693 p_msg_text => l_module || ' completed sucessfully',
694 p_stmt_num => l_stmt_num ,
695 p_msg_tokens => l_msg_tokens ,
696 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
697 p_run_log_level => l_log_level
698 );
699 END IF;
700
701 EXCEPTION
702 WHEN FND_API.G_EXC_ERROR THEN
703 x_return_status := G_RET_ERROR;
704 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
705 p_count => x_error_count ,
706 p_data => x_error_msg
707 );
708
709 WHEN OTHERS THEN
710 x_return_status := G_RET_UNEXPECTED;
711
712 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
713 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
714 THEN
715 WSM_log_PVT.handle_others( p_module_name => l_module ,
716 p_stmt_num => l_stmt_num ,
717 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
718 p_run_log_level => l_log_level
719 );
720 END IF;
721 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
722 p_count => x_error_count ,
723 p_data => x_error_msg
724 );
725 END wip_entity;
726
727 -- Validate the txn header details passed
728 -- Validate organization, transaction date
729 Procedure validate_txn_header ( p_wltx_header IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
730 x_return_status OUT NOCOPY VARCHAR2,
731 x_msg_count OUT NOCOPY NUMBER,
732 x_msg_data OUT NOCOPY VARCHAR2
733 ) IS
734
735 -- Status variables
736 l_return_status VARCHAR2(1);
737 l_msg_count NUMBER;
738 l_msg_data VARCHAR2(2000);
739
740 -- Other locals
741 l_dummy NUMBER;
742 l_txn_org_id NUMBER;
743 l_txn_type NUMBER;
744 l_err_num NUMBER;
745 l_err_msg VARCHAR2(1000);
746 l_acct_period_id NUMBER;
747
748 l_field_name VARCHAR2(100);
749
750 -- logging variables
751 l_msg_tokens WSM_log_PVT.token_rec_tbl;
752 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
753 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.validate_txn_header';
754 l_stmt_num NUMBER := 0;
755 BEGIN
756
757 l_stmt_num := 10;
758
759 x_return_status := G_RET_SUCCESS;
760 x_msg_data := NULL;
761 x_msg_count := 0;
762
763 -- Log the Procedure entry point....
764 if( g_log_level_statement >= l_log_level ) then
765 l_msg_tokens.delete;
766 WSM_log_PVT.logMessage(p_module_name => l_module ,
767 p_msg_text => 'Entered validate_txn_header',
768 p_stmt_num => l_stmt_num ,
769 p_msg_tokens => l_msg_tokens ,
770 p_fnd_log_level => g_log_level_statement,
771 p_run_log_level => l_log_level
772 );
773 End if;
774
775 l_stmt_num := 50;
776
777 -- validate organization_id
778 BEGIN
779
780 IF p_wltx_header.organization_id is NULL and p_wltx_header.organization_code is NULL THEN
781
782 -- Both organization code and id cant be NULL
783 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
784 l_msg_tokens.delete;
785 l_msg_tokens(1).TokenName := 'FLD_NAME';
786 l_msg_tokens(1).TokenValue := 'Both Organization_id and organization_code in Split Merge Transactions';
787 WSM_log_PVT.logMessage(p_module_name => l_module ,
788 p_msg_name => 'WSM_NULL_FIELD',
789 p_msg_appl_name => 'WSM' ,
790 p_stmt_num => l_stmt_num ,
791 p_msg_tokens => l_msg_tokens ,
792 p_fnd_msg_level => G_MSG_LVL_ERROR ,
793 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
794 p_run_log_level => l_log_level
795 );
796 END IF;
797 RAISE FND_API.G_EXC_ERROR;
798
799 ELSE
800 -- If organization code is not NULL then derive ID
801 IF p_wltx_header.organization_code is NULL then
802
803 l_stmt_num := 60;
804 l_field_name := 'organization_id';
805
806 -- ST : Performance bug fix 4914162 : Remove the use of org_organization_definitions.
807 select organization_code
808 into p_wltx_header.organization_code
809 -- from org_organization_definitions
810 from mtl_parameters
811 where (organization_id = p_wltx_header.organization_id );
812
813 if( g_log_level_statement >= l_log_level ) then
814 l_msg_tokens.delete;
815 WSM_log_PVT.logMessage(p_module_name => l_module ,
816 p_msg_text => ' Modified the organization_code in the txn header record to : ' || p_wltx_header.organization_code,
817 p_stmt_num => l_stmt_num ,
818 p_msg_tokens => l_msg_tokens ,
819 p_fnd_log_level => g_log_level_statement,
820 p_run_log_level => l_log_level
821 );
822 End if;
823 ELSE -- p_wltx_header.organization_code is not NULL
824 l_stmt_num := 70;
825 l_field_name := 'organization_code';
826
827 -- ST : Performance bug fix 4914162 : Remove the use of org_organization_definitions.
828 select organization_id
829 into p_wltx_header.organization_id
830 -- from org_organization_definitions
831 from mtl_parameters
832 -- where (organization_name = p_wltx_header.organization_code)
833 where organization_code = p_wltx_header.organization_code
834 and organization_id = nvl(p_wltx_header.organization_id,organization_id);
835
836 IF( g_log_level_statement >= l_log_level ) THEN
837 l_msg_tokens.delete;
838 WSM_log_PVT.logMessage(p_module_name => l_module ,
839 p_msg_text => ' Modified the organization_id in the txn header record to : ' || p_wltx_header.organization_id,
840 p_stmt_num => l_stmt_num ,
841 p_msg_tokens => l_msg_tokens ,
842 p_fnd_log_level => g_log_level_statement,
843 p_run_log_level => l_log_level
844 );
845 END IF;
846 END IF;
847
848 l_stmt_num := 80;
849
850 END IF;
851
852 EXCEPTION
853 WHEN NO_DATA_FOUND THEN
854 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
855 l_msg_tokens.delete;
856 l_msg_tokens(1).TokenName := 'FLD_NAME';
857 l_msg_tokens(1).TokenValue := 'value for field ' || l_field_name || ' in the txn header record ';
858 WSM_log_PVT.logMessage(p_module_name => l_module ,
859 p_msg_name => 'WSM_INVALID_FIELD',
860 p_msg_appl_name => 'WSM' ,
861 p_msg_tokens => l_msg_tokens ,
862 p_stmt_num => l_stmt_num ,
863 p_fnd_msg_level => G_MSG_LVL_ERROR ,
864 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
865 p_run_log_level => l_log_level
866 );
867 END IF;
868 RAISE FND_API.G_EXC_ERROR;
869 END;
870
871 l_stmt_num := 90;
872
873 -- validate transaction_type
874 BEGIN
875 IF p_wltx_header.transaction_type_id IS NULL THEN
876
877 l_stmt_num := 100;
878 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
879 l_msg_tokens.delete;
880 l_msg_tokens(1).TokenName := 'FLD_NAME';
881 l_msg_tokens(1).TokenValue := 'Transaction Type in Split Merge Transactions';
882 WSM_log_PVT.logMessage(p_module_name => l_module ,
883 p_msg_name => 'WSM_NULL_FIELD',
884 p_msg_appl_name => 'WSM' ,
885 p_msg_tokens => l_msg_tokens ,
886 p_stmt_num => l_stmt_num ,
887 p_fnd_msg_level => G_MSG_LVL_ERROR ,
888 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
889 p_run_log_level => l_log_level
890 );
891 END IF;
892 RAISE FND_API.G_EXC_ERROR;
893 ELSE --p_wltx_header.transaction_type_id IS NOT NULL
894
895 l_stmt_num := 110;
896
897 select 1
898 into l_dummy
899 from mfg_lookups mfg
900 where mfg.lookup_code = p_wltx_header.transaction_type_id
901 and mfg.lookup_type = 'WSM_WIP_LOT_TXN_TYPE';
902
903 l_txn_type := p_wltx_header.transaction_type_id;
904
905 IF( g_log_level_statement >= l_log_level ) THEN
906 l_msg_tokens.delete;
907 WSM_log_PVT.logMessage(p_module_name => l_module ,
908 p_msg_text => 'Valid transaction type' ,
909 p_stmt_num => l_stmt_num ,
910 p_msg_tokens => l_msg_tokens,
911 p_fnd_log_level => g_log_level_statement,
912 p_run_log_level => l_log_level
913 );
914 END IF;
915 END IF;
916
917 EXCEPTION
918 WHEN no_data_found then
919 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
920 l_msg_tokens.delete;
921 l_msg_tokens(1).TokenName := 'FLD_NAME';
922 l_msg_tokens(1).TokenValue := ' value for field transaction_type_id in the txn header record ';
923 WSM_log_PVT.logMessage(p_module_name => l_module ,
924 p_msg_name => 'WSM_INVALID_FIELD',
925 p_msg_appl_name => 'WSM' ,
926 p_msg_tokens => l_msg_tokens ,
927 p_stmt_num => l_stmt_num ,
928 p_fnd_msg_level => G_MSG_LVL_ERROR ,
929 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
930 p_run_log_level => l_log_level
931 );
932 END IF;
933 RAISE FND_API.G_EXC_ERROR;
934 END;
935
936 -- validate transaction date
937 l_stmt_num := 120;
938
939 IF p_wltx_header.transaction_date IS NULL THEN
940 p_wltx_header.transaction_date := SYSDATE;
941 IF( g_log_level_statement >= l_log_level ) THEN
942 l_msg_tokens.delete;
943 WSM_log_PVT.logMessage(p_module_name => l_module ,
944 p_msg_text => 'Modified the transaction_date in the txn header record to : ' || p_wltx_header.transaction_date ,
945 p_stmt_num => l_stmt_num ,
946 p_msg_tokens => l_msg_tokens,
947 p_fnd_log_level => g_log_level_statement,
948 p_run_log_level => l_log_level
949 );
950 End if;
951
952 ELSIF p_wltx_header.transaction_date > SYSDATE THEN
953 -- error out...(Transaction date cant be greater than current date)
954 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
955 l_msg_tokens.delete;
956 l_msg_tokens(1).TokenName := 'FLD_NAME';
957 l_msg_tokens(1).TokenValue := 'value for the transaction date in the txn header record . Transaction date cannot be greater than current date';
958 WSM_log_PVT.logMessage(p_module_name => l_module ,
959 p_msg_name => 'WSM_INVALID_FIELD',
960 p_msg_appl_name => 'WSM' ,
961 p_msg_tokens => l_msg_tokens ,
962 p_stmt_num => l_stmt_num ,
963 p_fnd_msg_level => G_MSG_LVL_ERROR ,
964 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
965 p_run_log_level => l_log_level
966 );
967 END IF;
968 RAISE FND_API.G_EXC_ERROR;
969 END IF;
970
971 -- validate reason_id in wsm_split_merge_txn_interface table
972 IF p_wltx_header.reason_id is not null then
973 BEGIN
974 l_stmt_num := 130;
975 select 1
976 into l_dummy
977 from mtl_transaction_reasons mtl
978 where mtl.reason_id = p_wltx_header.reason_id
979 and nvl(mtl.disable_date, sysdate+1) > sysdate;
980
981 EXCEPTION
982 WHEN NO_DATA_FOUND THEN
983 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
984 l_msg_tokens.delete;
985 l_msg_tokens(1).TokenName := 'FLD_NAME';
986 l_msg_tokens(1).TokenValue := 'value for field reason_id in the txn header record ';
987 WSM_log_PVT.logMessage(p_module_name => l_module ,
988 p_msg_name => 'WSM_INVALID_FIELD',
989 p_msg_appl_name => 'WSM' ,
990 p_msg_tokens => l_msg_tokens ,
991 p_stmt_num => l_stmt_num ,
992 p_fnd_msg_level => G_MSG_LVL_ERROR ,
993 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
994 p_run_log_level => l_log_level
995 );
996 END IF;
997 RAISE FND_API.G_EXC_ERROR;
998 END;
999 END IF;
1000
1001 -- validate acct_period
1002 BEGIN
1003 l_stmt_num := 140;
1004 l_err_num := 0;
1005 l_err_msg := null;
1006
1007 -- Invoke the UTIL procedure to check for an open period...
1008 l_acct_period_id := WSMPUTIL.GET_INV_ACCT_PERIOD(x_err_code => l_err_num,
1009 x_err_msg => l_err_msg,
1010 p_organization_id => p_wltx_header.organization_id,
1011 p_date => p_wltx_header.transaction_date);
1012
1013 l_stmt_num := 150;
1014 IF (l_err_num <> 0) THEN
1015
1016 l_stmt_num := 160;
1017 -- Log the Procedure exit point....
1018 if( g_log_level_statement >= l_log_level ) then
1019 l_msg_tokens.delete;
1020 WSM_log_PVT.logMessage(p_module_name => l_module ,
1021 p_msg_text => 'WSMPUTIL.GET_INV_ACCT_PERIOD returned failure : ' || l_msg_data ,
1022 p_stmt_num => l_stmt_num ,
1023 p_msg_tokens => l_msg_tokens,
1024 p_fnd_log_level => g_log_level_statement,
1025 p_run_log_level => l_log_level
1026 );
1027 End if;
1028
1029 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
1030 l_msg_tokens.delete;
1031 WSM_log_PVT.logMessage(p_module_name=> l_module ,
1032 p_msg_name => 'WSM_ACCT_PERIOD_NOT_OPEN',
1033 p_msg_appl_name => 'WSM',
1034 p_msg_tokens => l_msg_tokens ,
1035 p_stmt_num => l_stmt_num ,
1036 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1037 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1038 p_run_log_level => l_log_level
1039 );
1040 END IF;
1041 raise FND_API.G_EXC_ERROR;
1042 END IF; -- end IF (l_err_num <> 0)
1043 END;
1044
1045 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1046 l_msg_tokens.delete;
1047 WSM_log_PVT.logMessage (p_module_name => l_module ,
1048 p_msg_text => 'Validation of transaction header success',
1049 p_stmt_num => l_stmt_num ,
1050 p_msg_tokens => l_msg_tokens ,
1051 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1052 p_run_log_level => l_log_level
1053 );
1054 END IF;
1055
1056 EXCEPTION
1057
1058 WHEN FND_API.G_EXC_ERROR THEN
1059
1060 x_return_status := G_RET_ERROR;
1061 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1062 p_count => x_msg_count ,
1063 p_data => x_msg_data
1064 );
1065
1066 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1067
1068 x_return_status := G_RET_UNEXPECTED;
1069
1070 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1071 p_count => x_msg_count ,
1072 p_data => x_msg_data
1073 );
1074 WHEN OTHERS THEN
1075
1076 x_return_status := G_RET_UNEXPECTED;
1077
1078 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1079 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1080 THEN
1081 WSM_log_PVT.handle_others( p_module_name => l_module ,
1082 p_stmt_num => l_stmt_num ,
1083 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1084 p_run_log_level => l_log_level
1085 );
1086 END IF;
1087
1088 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1089 p_count => x_msg_count ,
1090 p_data => x_msg_data
1091 );
1092 END;
1093
1094 -- ST : Fix for bug 4351071 --
1095 -- Added this procedure to validate the date information..
1096 -- i) Txn date >= released_date
1097 -- ii) Txn date > last wip lot txn performed on this job...
1098 Procedure validate_sj_txn_date ( p_txn_date IN DATE ,
1099 p_sj_wip_entity_id IN NUMBER ,
1100 p_sj_wip_entity_name IN VARCHAR2,
1101 p_sj_date_released IN DATE ,
1102 x_return_status OUT NOCOPY VARCHAR2,
1103 x_msg_count OUT NOCOPY NUMBER ,
1104 x_msg_data OUT NOCOPY VARCHAR2
1105 ) IS
1106
1107 l_later_txn_exists NUMBER := 0;
1108
1109 -- local variable for debug purpose
1110 l_stmt_num NUMBER := 0;
1111 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1112 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1113 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.validate_sj_txn_date';
1114 l_param_tbl WSM_Log_PVT.param_tbl_type;
1115
1116 BEGIN
1117
1118 l_stmt_num := 10;
1119
1120 x_return_status := G_RET_SUCCESS;
1121 x_msg_data := NULL;
1122 x_msg_count := 0;
1123
1124 -- Initialize API return status to success
1125 x_return_status := FND_API.G_RET_STS_SUCCESS;
1126
1127 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
1128 l_param_tbl.delete;
1129
1130 l_param_tbl(1).paramName := 'p_txn_date';
1131 l_param_tbl(1).paramValue := p_txn_date;
1132
1133 l_param_tbl(2).paramName := 'p_sj_wip_entity_id';
1134 l_param_tbl(2).paramValue := p_sj_wip_entity_id;
1135
1136 l_param_tbl(3).paramName := 'p_sj_date_released';
1137 l_param_tbl(3).paramValue := p_sj_date_released;
1138
1139 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
1140 p_param_tbl => l_param_tbl,
1141 p_fnd_log_level => l_log_level
1142 );
1143 END IF;
1144
1145 l_stmt_num := 20;
1146 -- First validate the txn date and the date released..
1147 IF (p_txn_date < p_sj_date_released) THEN
1148 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
1149 l_msg_tokens.delete;
1150 l_msg_tokens(1).TokenName := 'JOB';
1151 l_msg_tokens(1).TokenValue := p_sj_wip_entity_name;
1152 WSM_log_PVT.logMessage(p_module_name => l_module ,
1153 p_msg_name => 'WSM_INVALID_TXN_REL_DATE',
1154 p_msg_appl_name => 'WSM' ,
1155 p_msg_tokens => l_msg_tokens ,
1156 p_stmt_num => l_stmt_num ,
1157 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1158 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1159 p_run_log_level => l_log_level
1160 );
1161 END IF;
1162 RAISE FND_API.G_EXC_ERROR;
1163 END IF;
1164
1165 -- Next validation is on the max txn date.. should be greater than the last txn performed on the job..
1166 l_stmt_num := 30;
1167 BEGIN
1168 l_later_txn_exists := 0;
1169
1170 SELECT 1
1171 INTO l_later_txn_exists
1172 FROM wsm_split_merge_transactions wsmt,
1173 wsm_sm_starting_jobs wst
1174 WHERE wsmt.transaction_id = wst.transaction_id
1175 AND wst.wip_entity_id = p_sj_wip_entity_id
1176 AND wsmt.transaction_date > p_txn_date
1177 AND rownum = 1;
1178
1179 -- Error our in this case...
1180 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
1181 l_msg_tokens.delete;
1182 l_msg_tokens(1).TokenName := 'JOB';
1183 l_msg_tokens(1).TokenValue := p_sj_wip_entity_name;
1184 WSM_log_PVT.logMessage(p_module_name => l_module ,
1185 p_msg_name => 'WSM_INVALID_WLT_TXN_DATE',
1186 p_msg_appl_name => 'WSM' ,
1187 p_msg_tokens => l_msg_tokens ,
1188 p_stmt_num => l_stmt_num ,
1189 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1190 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1191 p_run_log_level => l_log_level
1192 );
1193 END IF;
1194 RAISE FND_API.G_EXC_ERROR;
1195 EXCEPTION
1196 WHEN NO_DATA_FOUND THEN
1197 null;
1198 END;
1199
1200 EXCEPTION
1201 WHEN FND_API.G_EXC_ERROR THEN
1202
1203 x_return_status := G_RET_ERROR;
1204 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1205 p_count => x_msg_count ,
1206 p_data => x_msg_data
1207 );
1208
1209 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1210 x_return_status := G_RET_UNEXPECTED;
1211 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1212 p_count => x_msg_count ,
1213 p_data => x_msg_data
1214 );
1215
1216 WHEN OTHERS THEN
1217 x_return_status := G_RET_UNEXPECTED;
1218 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1219 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1220 THEN
1221 WSM_log_PVT.handle_others( p_module_name => l_module ,
1222 p_stmt_num => l_stmt_num ,
1223 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1224 p_run_log_level => l_log_level
1225 );
1226 END IF;
1227
1228 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1229 p_count => x_msg_count ,
1230 p_data => x_msg_data
1231 );
1232
1233 END validate_sj_txn_date;
1234
1235 -- derive Validate the starting job info provided by the user
1236 -- Once validation is successful, the non-specified information is filled by the code
1237 Procedure derive_val_st_job_details( p_txn_org_id IN NUMBER,
1238 p_txn_type IN NUMBER,
1239 -- ST : Added Txn date for bug 4351071
1240 p_txn_date IN DATE,
1241 p_starting_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_REC_TYPE,
1242 x_return_status OUT NOCOPY VARCHAR2,
1243 x_msg_count OUT NOCOPY NUMBER,
1244 x_msg_data OUT NOCOPY VARCHAR2
1245 ) IS
1246
1247 l_wip_entity_id WIP_ENTITIES.wip_entity_id%TYPE ;
1248
1249 -- Cursor to obtain the job specific information
1250 cursor c_wdj_details_name is
1251 -- Job specific details
1252 select we.wip_entity_id ,
1253 we.wip_entity_name ,
1254 wdj.description ,
1255 wdj.status_type ,
1256 wdj.primary_item_id ,
1257 wdj.job_type ,
1258 wdj.class_code ,
1259 wdj.date_released ,
1260 wdj.scheduled_completion_date ,
1261 wdj.scheduled_start_date ,
1262 wdj.start_quantity ,
1263 wdj.net_quantity ,
1264 wdj.bom_reference_id ,
1265 wdj.routing_reference_id ,
1266 wdj.common_bom_sequence_id ,
1267 wdj.common_routing_sequence_id ,
1268 wdj.bom_revision ,
1269 wdj.routing_revision ,
1270 wdj.bom_revision_date ,
1271 wdj.routing_revision_date ,
1272 wdj.alternate_bom_designator ,
1273 wdj.alternate_routing_designator ,
1274 wdj.completion_subinventory ,
1275 wdj.completion_locator_id ,
1276 wdj.kanban_card_id ,
1277 wdj.coproducts_supply ,
1278 we.organization_id ,
1279 wdj.serialization_start_op ,
1280 wdj.wip_supply_type
1281 from wip_discrete_jobs wdj,
1282 wip_entities we
1283 where we.wip_entity_id = nvl(p_starting_job_rec.wip_entity_id,we.wip_entity_id)
1284 and we.wip_entity_name = p_starting_job_rec.wip_entity_name
1285 and wdj.wip_entity_id = we.wip_entity_id
1286 and we.organization_id = p_txn_org_id;
1287
1288 -- Cursor to obtain the job specific information
1289 cursor c_wdj_details_id is
1290 -- Job specific details
1291 select we.wip_entity_id ,
1292 we.wip_entity_name ,
1293 wdj.description ,
1294 wdj.status_type ,
1295 wdj.primary_item_id ,
1296 wdj.job_type ,
1297 wdj.class_code ,
1298 wdj.date_released ,
1299 wdj.scheduled_completion_date ,
1300 wdj.scheduled_start_date ,
1301 wdj.start_quantity ,
1302 wdj.net_quantity ,
1303 wdj.bom_reference_id ,
1304 wdj.routing_reference_id ,
1305 wdj.common_bom_sequence_id ,
1306 wdj.common_routing_sequence_id ,
1307 wdj.bom_revision ,
1308 wdj.routing_revision ,
1309 wdj.bom_revision_date ,
1310 wdj.routing_revision_date ,
1311 wdj.alternate_bom_designator ,
1312 wdj.alternate_routing_designator ,
1313 wdj.completion_subinventory ,
1314 wdj.completion_locator_id ,
1315 wdj.kanban_card_id ,
1316 wdj.coproducts_supply ,
1317 we.organization_id ,
1318 wdj.serialization_start_op ,
1319 wdj.wip_supply_type
1320 from wip_discrete_jobs wdj,
1321 wip_entities we
1322 where wdj.wip_entity_id = p_starting_job_rec.wip_entity_id
1323 and we.wip_entity_name = nvl(p_starting_job_rec.wip_entity_name,we.wip_entity_name)
1324 and wdj.wip_entity_id = we.wip_entity_id
1325 and we.organization_id = p_txn_org_id;
1326
1327 -- This cursor will be used if the current op seq num is provided.
1328 cursor c_curr_job_info_op is
1329 select wo.operation_seq_num,
1330 wo.quantity_in_queue,
1331 wo.quantity_waiting_to_move,
1332 standard_operation_id,
1333 operation_sequence_id,
1334 department_id,
1335 description,
1336 nvl(quantity_in_queue,0)+nvl(quantity_waiting_to_move,0) qty_available
1337 from wip_operations wo
1338 where wo.organization_id = p_txn_org_id
1339 and wo.wip_entity_id = l_wip_entity_id
1340 and wo.operation_seq_num = p_starting_job_rec.operation_seq_num
1341 and (nvl(wo.quantity_in_queue,0) > 0 or nvl(wo.quantity_waiting_to_move,0) > 0);
1342
1343 -- This cursor will be used if the current op seq num is not provided...
1344 cursor c_curr_job_info is
1345 select wo.operation_seq_num,
1346 wo.quantity_in_queue,
1347 wo.quantity_waiting_to_move,
1348 standard_operation_id,
1349 operation_sequence_id,
1350 department_id,
1351 description,
1352 nvl(quantity_in_queue,0)+nvl(quantity_waiting_to_move,0) qty_available
1353 from wip_operations wo
1354 where wo.organization_id = p_txn_org_id
1355 and wo.wip_entity_id = l_wip_entity_id
1356 and wo.operation_seq_num = operation_seq_num
1357 and (nvl(wo.quantity_in_queue,0) > 0 or nvl(wo.quantity_waiting_to_move,0) > 0);
1358
1359 l_wip_entity_name WIP_ENTITIES.wip_entity_name%TYPE ;
1360 l_description WIP_DISCRETE_JOBS.description%TYPE ;
1361 l_status_type WIP_DISCRETE_JOBS.status_type%TYPE ;
1362 l_primary_item_id WIP_DISCRETE_JOBS.primary_item_id%TYPE ;
1363 l_job_type WIP_DISCRETE_JOBS.job_type%TYPE ;
1364 l_class_code WIP_DISCRETE_JOBS.class_code%TYPE ;
1365 l_date_released WIP_DISCRETE_JOBS.date_released%TYPE ;
1366 l_scheduled_completion_date WIP_DISCRETE_JOBS.scheduled_completion_date%TYPE ;
1367 l_scheduled_start_date WIP_DISCRETE_JOBS.scheduled_start_date%TYPE ;
1368 l_start_quantity WIP_DISCRETE_JOBS.start_quantity%TYPE ;
1369 l_net_quantity WIP_DISCRETE_JOBS.net_quantity%TYPE ;
1370 l_bom_reference_id WIP_DISCRETE_JOBS.bom_reference_id%TYPE ;
1371 l_routing_reference_id WIP_DISCRETE_JOBS.routing_reference_id%TYPE ;
1372 l_common_bom_sequence_id WIP_DISCRETE_JOBS.common_bom_sequence_id%TYPE ;
1373 l_common_routing_sequence_id WIP_DISCRETE_JOBS.common_routing_sequence_id %TYPE ;
1374 l_bom_revision WIP_DISCRETE_JOBS.bom_revision%TYPE ;
1375 l_routing_revision WIP_DISCRETE_JOBS.routing_revision%TYPE ;
1376 l_bom_revision_date WIP_DISCRETE_JOBS.bom_revision_date%TYPE ;
1377 l_routing_revision_date WIP_DISCRETE_JOBS.routing_revision_date%TYPE ;
1378 l_alternate_bom_designator WIP_DISCRETE_JOBS.alternate_bom_designator%TYPE ;
1379 l_alternate_routing_designator WIP_DISCRETE_JOBS.alternate_routing_designator%TYPE ;
1380 l_completion_subinventory WIP_DISCRETE_JOBS.completion_subinventory%TYPE ;
1381 l_completion_locator_id WIP_DISCRETE_JOBS.completion_locator_id%TYPE ;
1382 l_kanban_card_id WIP_DISCRETE_JOBS.kanban_card_id%TYPE ;
1383 l_coproducts_supply WIP_DISCRETE_JOBS.coproducts_supply%TYPE ;
1384 l_organization_id WIP_ENTITIES.organization_id%TYPE ;
1385 l_wip_supply_type NUMBER ;
1386 l_serial_track_flag NUMBER ;
1387
1388 l_operation_seq_num NUMBER;
1389 l_quantity_in_queue NUMBER;
1390 l_quantity_waiting_to_move NUMBER;
1391 l_standard_operation_id NUMBER;
1392 l_operation_sequence_id NUMBER;
1393 l_department_id NUMBER;
1394 l_op_description WIP_OPERATIONS.DESCRIPTION%TYPE;
1395 l_qty_available NUMBER;
1396
1397 -- Status variables
1398 l_return_status VARCHAR2(1);
1399 l_msg_count NUMBER;
1400 l_msg_data VARCHAR2(2000);
1401
1402 -- Other locals
1403 l_qty_in_queue NUMBER;
1404 l_qty_to_move NUMBER;
1405
1406 l_valid boolean := false;
1407 l_field_name VARCHAR2(100);
1408 e_invalid_field exception;
1409
1410 -- local variable for debug purpose
1411 l_stmt_num NUMBER := 0;
1412 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1413 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1414 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_st_job_details';
1415 l_param_tbl WSM_Log_PVT.param_tbl_type;
1416
1417 BEGIN
1418 SAVEPOINT start_def_start_job;
1419
1420 l_stmt_num := 10;
1421
1422 x_return_status := G_RET_SUCCESS;
1423 x_msg_data := NULL;
1424 x_msg_count := 0;
1425
1426 -- Initialize API return status to success
1427 x_return_status := FND_API.G_RET_STS_SUCCESS;
1428
1429
1430 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
1431
1432 l_stmt_num := 15;
1433 l_param_tbl.delete;
1434
1435 l_param_tbl(1).paramName := 'p_txn_org_id';
1436 l_param_tbl(1).paramValue := p_txn_org_id;
1437
1438 l_param_tbl(2).paramName := 'p_txn_type';
1439 l_param_tbl(2).paramValue := p_txn_type;
1440
1441 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
1442 p_param_tbl => l_param_tbl,
1443 p_fnd_log_level => l_log_level
1444 );
1445 END IF;
1446 -- what we'll be doing here is select all the required fields use cursors... and then.... compare....
1447 -- atleast wip_entity_id/ wip_entity_name is a must.....
1448 IF p_starting_job_rec.wip_entity_name IS NULL AND p_starting_job_rec.wip_entity_id IS NULL THEN
1449 -- error out....
1450 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
1451 l_msg_tokens.delete;
1452 l_msg_tokens(1).TokenName := 'FLD_NAME';
1453 l_msg_tokens(1).TokenValue := 'Entity id and Entity name';
1454 WSM_log_PVT.logMessage(p_module_name => l_module ,
1455 p_msg_name => 'WSM_NULL_FIELD',
1456 p_msg_appl_name => 'WSM' ,
1457 p_msg_tokens => l_msg_tokens ,
1458 p_stmt_num => l_stmt_num ,
1459 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1460 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1461 p_run_log_level => l_log_level
1462 );
1463 END IF;
1464 RAISE FND_API.G_EXC_ERROR;
1465 END IF;
1466
1467 l_stmt_num := 115;
1468 IF (p_starting_job_rec.wip_entity_name IS NULL) THEN
1469 l_field_name := ' Wip Entity ID : ' || p_starting_job_rec.wip_entity_id;
1470 FOR l_wdj_details in c_wdj_details_id LOOP
1471 l_valid := true;
1472
1473 l_wip_entity_id := l_wdj_details.wip_entity_id ;
1474 l_wip_entity_name := l_wdj_details.wip_entity_name ;
1475 l_description := l_wdj_details.description ;
1476 l_status_type := l_wdj_details.status_type ;
1477 l_primary_item_id := l_wdj_details.primary_item_id ;
1478 l_job_type := l_wdj_details.job_type ;
1479 l_class_code := l_wdj_details.class_code ;
1480 l_date_released := l_wdj_details.date_released ;
1481 l_scheduled_completion_date := l_wdj_details.scheduled_completion_date ;
1482 l_scheduled_start_date := l_wdj_details.scheduled_start_date ;
1483 l_start_quantity := l_wdj_details.start_quantity ;
1484 l_net_quantity := l_wdj_details.net_quantity ;
1485 l_bom_reference_id := l_wdj_details.bom_reference_id ;
1486 l_routing_reference_id := l_wdj_details.routing_reference_id ;
1487 l_common_bom_sequence_id := l_wdj_details.common_bom_sequence_id ;
1488 l_common_routing_sequence_id := l_wdj_details.common_routing_sequence_id ;
1489 l_bom_revision := l_wdj_details.bom_revision ;
1490 l_routing_revision := l_wdj_details.routing_revision ;
1491 l_bom_revision_date := l_wdj_details.bom_revision_date ;
1492 l_routing_revision_date := l_wdj_details.routing_revision_date ;
1493 l_alternate_bom_designator := l_wdj_details.alternate_bom_designator ;
1494 l_alternate_routing_designator := l_wdj_details.alternate_routing_designator ;
1495 l_completion_subinventory := l_wdj_details.completion_subinventory ;
1496 l_completion_locator_id := l_wdj_details.completion_locator_id ;
1497 l_kanban_card_id := l_wdj_details.kanban_card_id ;
1498 l_coproducts_supply := l_wdj_details.coproducts_supply ;
1499 l_organization_id := l_wdj_details.organization_id ;
1500 l_serial_track_flag := l_wdj_details.serialization_start_op ;
1501 l_wip_supply_type := l_wdj_details.wip_supply_type ;
1502 END LOOP;
1503 ELSE -- (p_starting_job_rec.wip_entity_name IS not null
1504 l_field_name := 'Wip Entity ID/Wip Entity Name';
1505 FOR l_wdj_details in c_wdj_details_name LOOP
1506 l_valid := true;
1507
1508 l_wip_entity_id := l_wdj_details.wip_entity_id ;
1509 l_wip_entity_name := l_wdj_details.wip_entity_name ;
1510 l_description := l_wdj_details.description ;
1511 l_status_type := l_wdj_details.status_type ;
1512 l_primary_item_id := l_wdj_details.primary_item_id ;
1513 l_job_type := l_wdj_details.job_type ;
1514 l_class_code := l_wdj_details.class_code ;
1515 l_date_released := l_wdj_details.date_released ;
1516 l_scheduled_completion_date := l_wdj_details.scheduled_completion_date ;
1517 l_scheduled_start_date := l_wdj_details.scheduled_start_date ;
1518 l_start_quantity := l_wdj_details.start_quantity ;
1519 l_net_quantity := l_wdj_details.net_quantity ;
1520 l_bom_reference_id := l_wdj_details.bom_reference_id ;
1521 l_routing_reference_id := l_wdj_details.routing_reference_id ;
1522 l_common_bom_sequence_id := l_wdj_details.common_bom_sequence_id ;
1523 l_common_routing_sequence_id := l_wdj_details.common_routing_sequence_id ;
1524 l_bom_revision := l_wdj_details.bom_revision ;
1525 l_routing_revision := l_wdj_details.routing_revision ;
1526 l_bom_revision_date := l_wdj_details.bom_revision_date ;
1527 l_routing_revision_date := l_wdj_details.routing_revision_date ;
1528 l_alternate_bom_designator := l_wdj_details.alternate_bom_designator ;
1529 l_alternate_routing_designator := l_wdj_details.alternate_routing_designator ;
1530 l_completion_subinventory := l_wdj_details.completion_subinventory ;
1531 l_completion_locator_id := l_wdj_details.completion_locator_id ;
1532 l_kanban_card_id := l_wdj_details.kanban_card_id ;
1533 l_coproducts_supply := l_wdj_details.coproducts_supply ;
1534 l_organization_id := l_wdj_details.organization_id ;
1535 l_serial_track_flag := l_wdj_details.serialization_start_op ;
1536 l_wip_supply_type := l_wdj_details.wip_supply_type ;
1537 END LOOP;
1538 END IF;
1539 -- end (p_starting_job_rec.wip_entity_name IS NULL)
1540
1541 l_stmt_num := 118.1;
1542 IF l_valid = FALSE THEN
1543 -- error out...
1544 raise e_invalid_field;
1545 END IF;
1546
1547 -- Currently the below are the Job-related columns that the user can provide through interface...
1548 --- WIP_ENTITY_ID
1549 --- OPERATION_SEQ_NUM
1550 --- INTRAOPERATION_STEP
1551 --- ROUTING_SEQ_ID
1552 --- PRIMARY_ITEM_ID
1553 --- ORGANIZATION_ID
1554
1555 -- The validation code below is written to validate the above columns...
1556 -- Add code to validate as and when new columns get exposed to the user to provide more
1557 -- information about the state of the job prior to a transaction..
1558 -- Validate the obtained info...
1559 IF (p_starting_job_rec.primary_item_id IS NOT NULL AND l_primary_item_id <> p_starting_job_rec.primary_item_id)
1560 THEN
1561 l_valid := false;
1562 l_field_name := 'Primary Item Identifier';
1563 raise e_invalid_field;
1564
1565 ELSIF (p_starting_job_rec.organization_id IS NOT NULL AND l_organization_id <> p_starting_job_rec.organization_id )
1566 THEN
1567 l_valid := false;
1568 l_field_name := 'Organization Id';
1569 raise e_invalid_field;
1570 ELSIF (l_status_type <> WIP_CONSTANTS.RELEASED) THEN
1571 l_valid := false;
1572 l_field_name := 'Job Status : Job has to be released to perform WIP Lot Transactions';
1573 raise e_invalid_field;
1574 END IF;
1575
1576 -- ST : Fix for bug 4351071 --
1577 -- Validate the Txn date information with respect to the job data...
1578 validate_sj_txn_date ( p_txn_date => p_txn_date ,
1579 p_sj_wip_entity_id => l_wip_entity_id ,
1580 p_sj_wip_entity_name => l_wip_entity_name ,
1581 p_sj_date_released => l_date_released ,
1582 x_return_status => x_return_status ,
1583 x_msg_count => x_msg_count ,
1584 x_msg_data => x_msg_data
1585 );
1586
1587 IF x_return_status <> G_RET_SUCCESS THEN
1588 IF x_return_status = G_RET_ERROR THEN
1589 RAISE FND_API.G_EXC_ERROR;
1590 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1591 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1592 END IF;
1593 END IF;
1594 -- ST : Fix for bug 4351071 end --
1595
1596 -- Populate the starting Job record with the obtained information
1597 p_starting_job_rec.wip_entity_id := l_wip_entity_id ;
1598 p_starting_job_rec.wip_entity_name := l_wip_entity_name ;
1599 p_starting_job_rec.description := l_description ;
1600 p_starting_job_rec.status_type := l_status_type ;
1601 p_starting_job_rec.primary_item_id := l_primary_item_id ;
1602 p_starting_job_rec.job_type := l_job_type ;
1603 p_starting_job_rec.class_code := l_class_code ;
1604 p_starting_job_rec.organization_id := l_organization_id ;
1605
1606 -- Date information
1607 p_starting_job_rec.date_released := l_date_released ;
1608 p_starting_job_rec.scheduled_completion_date := l_scheduled_completion_date ;
1609 p_starting_job_rec.scheduled_start_date := l_scheduled_start_date ;
1610
1611 -- Quantity data
1612 p_starting_job_rec.start_quantity := l_start_quantity ;
1613 p_starting_job_rec.net_quantity := l_net_quantity ;
1614
1615 -- Bom and routing data
1616 p_starting_job_rec.bom_reference_id := l_bom_reference_id ;
1617 p_starting_job_rec.routing_reference_id := l_routing_reference_id ;
1618 p_starting_job_rec.common_bill_sequence_id := l_common_bom_sequence_id ;
1619 p_starting_job_rec.common_routing_sequence_id := l_common_routing_sequence_id ;
1620 p_starting_job_rec.bom_revision := l_bom_revision ;
1621 p_starting_job_rec.routing_revision := l_routing_revision ;
1622 p_starting_job_rec.bom_revision_date := l_bom_revision_date ;
1623 p_starting_job_rec.routing_revision_date := l_routing_revision_date ;
1624 p_starting_job_rec.alternate_bom_designator := l_alternate_bom_designator ;
1625 p_starting_job_rec.alternate_routing_designator := l_alternate_routing_designator ;
1626
1627 -- Subinv information
1628 p_starting_job_rec.completion_subinventory := l_completion_subinventory ;
1629 p_starting_job_rec.completion_locator_id := l_completion_locator_id ;
1630
1631 -- Other parameters
1632 p_starting_job_rec.kanban_card_id := l_kanban_card_id ;
1633 p_starting_job_rec.coproducts_supply := l_coproducts_supply ;
1634 p_starting_job_rec.wip_supply_type := l_wip_supply_type ;
1635 -- ST : Serial Support Project --
1636 p_starting_job_rec.serial_track_flag := l_serial_track_flag ;
1637
1638
1639 l_stmt_num := 120;
1640 l_valid := false;
1641 l_field_name := 'Job Operation Sequence Number';
1642
1643 -- should validate the current op info.....
1644 IF (p_starting_job_rec.operation_seq_num IS NULL) THEN
1645
1646 FOR l_curr_job_info in c_curr_job_info LOOP
1647 l_valid := true;
1648 l_operation_seq_num := l_curr_job_info.operation_seq_num ;
1649 l_quantity_in_queue := l_curr_job_info.quantity_in_queue ;
1650 l_quantity_waiting_to_move := l_curr_job_info.quantity_waiting_to_move ;
1651 l_standard_operation_id := l_curr_job_info.standard_operation_id ;
1652 l_operation_sequence_id := l_curr_job_info.operation_sequence_id ;
1653 l_department_id := l_curr_job_info.department_id ;
1654 l_op_description := l_curr_job_info.description ;
1655 l_qty_available := l_curr_job_info.qty_available ;
1656 END LOOP;
1657 ELSE -- Starting op seq num not null
1658 FOR l_curr_job_info in c_curr_job_info_op LOOP
1659 l_valid := true;
1660 l_operation_seq_num := l_curr_job_info.operation_seq_num ;
1661 l_quantity_in_queue := l_curr_job_info.quantity_in_queue ;
1662 l_quantity_waiting_to_move := l_curr_job_info.quantity_waiting_to_move ;
1663 l_standard_operation_id := l_curr_job_info.standard_operation_id ;
1664 l_operation_sequence_id := l_curr_job_info.operation_sequence_id ;
1665 l_department_id := l_curr_job_info.department_id ;
1666 l_op_description := l_curr_job_info.description ;
1667 l_qty_available := l_curr_job_info.qty_available ;
1668 END LOOP;
1669 END IF;
1670
1671 -- Validate the op info....
1672 IF l_valid = TRUE THEN
1673 if nvl(l_quantity_in_queue,0) > 0 then
1674 -- Validate the current intraperation step provided
1675 if nvl(p_starting_job_rec.intraoperation_step,wip_constants.queue) <> wip_constants.queue then
1676 l_valid :=false;
1677 l_field_name := 'Job Intraoperation Step';
1678 raise e_invalid_field;
1679 end if;
1680
1681 p_starting_job_rec.intraoperation_step := WIP_CONSTANTS.QUEUE;
1682 elsif nvl(l_quantity_waiting_to_move,0) > 0 then
1683
1684 if nvl(p_starting_job_rec.intraoperation_step,wip_constants.tomove) <> wip_constants.tomove then
1685 l_valid :=false;
1686 l_field_name := 'Job Intraoperation Step';
1687 raise e_invalid_field;
1688 END IF;
1689 p_starting_job_rec.intraoperation_step := WIP_CONSTANTS.TOMOVE;
1690 END IF;
1691 ELSE
1692 RAISE e_invalid_field;
1693 END IF;
1694
1695 -- Fill the starting job record with the operation information
1696 p_starting_job_rec.standard_operation_id := l_standard_operation_id ;
1697 p_starting_job_rec.OPERATION_SEQ_ID := l_operation_sequence_id ;
1698 p_starting_job_rec.department_id := l_department_id ;
1699 p_starting_job_rec.OPERATION_DESCRIPTION := l_op_description ;
1700 p_starting_job_rec.quantity_available := l_qty_available ;
1701 p_starting_job_rec.operation_seq_num := l_operation_seq_num ;
1702
1703 if p_starting_job_rec.standard_operation_id is not null then
1704
1705 l_stmt_num := 130;
1706 -- get the standard op code in this case ....
1707 select operation_code
1708 into p_starting_job_rec.operation_code
1709 from bom_standard_operations
1710 where STANDARD_OPERATION_ID = p_starting_job_rec.standard_operation_id;
1711
1712 end if;
1713
1714 if p_txn_type <> WSMPCNST.MERGE THEN
1715
1716 l_stmt_num := 140;
1717 p_starting_job_rec.representative_flag := 'Y';
1718 --'Modified the representative flag to : ' || p_starting_job_rec.representative_flag );
1719
1720 end if;
1721
1722 l_stmt_num := 150;
1723
1724 -- Check for OSP resource.........................................
1725 if( g_log_level_statement >= l_log_level ) then
1726 l_msg_tokens.delete;
1727 WSM_log_PVT.logMessage(p_module_name => l_module ,
1728 p_msg_text => 'Check for OSP resource' ,
1729 p_stmt_num => l_stmt_num ,
1730 p_msg_tokens => l_msg_tokens,
1731 p_fnd_log_level => g_log_level_statement,
1732 p_run_log_level => l_log_level
1733 );
1734 End if;
1735
1736 l_stmt_num := 155;
1737 -- add update BOM also
1738 IF (p_txn_type in (WSMPCNST.SPLIT,WSMPCNST.UPDATE_ROUTING,WSMPCNST.UPDATE_ASSEMBLY) ) THEN
1739
1740 l_stmt_num := 160;
1741 -- change the code to call by name
1742 IF wip_osp.po_req_exists(p_starting_job_rec.wip_entity_id,
1743 NULL,
1744 p_txn_org_id,
1745 p_starting_job_rec.operation_seq_num,
1746 5
1747 )
1748 THEN
1749 -- Populate a warning message..........................event
1750 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
1751 l_msg_tokens.delete;
1752 WSM_log_PVT.logMessage(p_module_name => l_module ,
1753 p_msg_name => 'WSM_OP_PURCHASE_REQ',
1754 p_msg_appl_name => 'WSM' ,
1755 p_msg_tokens => l_msg_tokens ,
1756 p_stmt_num => l_stmt_num ,
1757 p_fnd_msg_level => G_MSG_LVL_SUCCESS ,
1758 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1759 p_run_log_level => l_log_level ,
1760 p_wsm_warning => 1
1761 );
1762 END IF;
1763 END IF;
1764 END IF;
1765
1766 l_stmt_num := 170;
1767 IF( g_log_level_statement >= l_log_level ) THEN
1768 l_msg_tokens.delete;
1769 WSM_log_PVT.logMessage(p_module_name => l_module ,
1770 p_msg_text => 'Derive validate Starting job success' ,
1771 p_stmt_num => l_stmt_num ,
1772 p_msg_tokens => l_msg_tokens ,
1773 p_fnd_log_level => g_log_level_statement ,
1774 p_run_log_level => l_log_level
1775 );
1776 END IF;
1777 -- the end...
1778
1779 EXCEPTION
1780 WHEN e_invalid_field THEN
1781
1782 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
1783 l_msg_tokens.delete;
1784 l_msg_tokens(1).TokenName := 'FLD_NAME';
1785 l_msg_tokens(1).TokenValue := l_field_name;
1786
1787 WSM_log_PVT.logMessage(p_module_name => l_module ,
1788 p_msg_name => 'WSM_INVALID_FIELD' ,
1789 p_msg_appl_name => 'WSM' ,
1790 p_msg_tokens => l_msg_tokens ,
1791 p_stmt_num => l_stmt_num ,
1792 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1793 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1794 p_run_log_level => l_log_level
1795 );
1796 l_msg_tokens.delete;
1797 l_msg_tokens(1).TokenName := 'FLD_NAME';
1798 l_msg_tokens(1).TokenValue := 'Job State : Verify Starting Job Information provided';
1799
1800 WSM_log_PVT.logMessage(p_module_name => l_module ,
1801 p_msg_name => 'WSM_INVALID_FIELD' ,
1802 p_msg_appl_name => 'WSM' ,
1803 p_msg_tokens => l_msg_tokens ,
1804 p_stmt_num => l_stmt_num ,
1805 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1806 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1807 p_run_log_level => l_log_level
1808 );
1809 END IF;
1810 RAISE FND_API.G_EXC_ERROR;
1811
1812 x_return_status := G_RET_ERROR;
1813 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1814 p_count => x_msg_count ,
1815 p_data => x_msg_data
1816 );
1817 WHEN FND_API.G_EXC_ERROR THEN
1818 ROLLBACK TO start_def_start_job;
1819 x_return_status := G_RET_ERROR;
1820 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1821 p_count => x_msg_count ,
1822 p_data => x_msg_data
1823 );
1824
1825 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1826 ROLLBACK TO start_def_start_job;
1827
1828 x_return_status := G_RET_UNEXPECTED;
1829
1830 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1831 p_count => x_msg_count ,
1832 p_data => x_msg_data
1833 );
1834
1835 WHEN OTHERS THEN
1836 ROLLBACK TO start_def_start_job;
1837 x_return_status := G_RET_UNEXPECTED;
1838
1839 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1840 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1841 THEN
1842 WSM_log_PVT.handle_others( p_module_name => l_module ,
1843 p_stmt_num => l_stmt_num ,
1844 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1845 p_run_log_level => l_log_level
1846 );
1847 END IF;
1848
1849 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1850 p_count => x_msg_count ,
1851 p_data => x_msg_data
1852 );
1853
1854 END;
1855
1856 -- derive Validate the starting job info ( overloaded for merge )
1857 -- This procedure wuill invoke the derive_val_st_job_details for each of the starting jobs
1858 Procedure derive_val_st_job_details( p_txn_org_id IN NUMBER,
1859 p_txn_type IN NUMBER,
1860 -- ST : Added Txn date for bug 4351071
1861 p_txn_date IN DATE,
1862 p_starting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
1863 p_rep_job_index OUT NOCOPY NUMBER,
1864 p_total_avail_quantity OUT NOCOPY NUMBER,
1865 p_total_net_quantity OUT NOCOPY NUMBER,
1866 -- Added For serial...
1867 x_job_serial_code OUT NOCOPY NUMBER,
1868 x_return_status OUT NOCOPY VARCHAR2,
1869 x_msg_count OUT NOCOPY NUMBER,
1870 x_msg_data OUT NOCOPY VARCHAR2
1871 ) IS
1872 -- Status variables
1873 l_return_status VARCHAR2(1);
1874 l_msg_count NUMBER;
1875 l_msg_data VARCHAR2(2000);
1876
1877 -- Other locals
1878 l_wip_entity_name t_wip_entity_name_tbl;
1879
1880 l_job_type NUMBER;
1881 l_std_op_id NUMBER;
1882 l_dept_id NUMBER;
1883 l_intraop_step NUMBER;
1884 l_serial_track NUMBER := null;
1885 l_code NUMBER;
1886
1887 -- local variable for logging purpose
1888 l_stmt_num NUMBER := 0;
1889 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1890 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1891 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.DERIVE_VAL_ST_JOB_DETAILS';
1892
1893 -- Loop Variable
1894 l_counter NUMBER;
1895
1896
1897 BEGIN
1898 -- Have a starting point
1899 savepoint start_val_start_job_merge;
1900
1901 l_stmt_num := 10;
1902 -- Initialize API return status to success
1903 x_return_status := FND_API.G_RET_STS_SUCCESS;
1904
1905 -- Log the Procedure entry point....
1906 if( g_log_level_statement >= l_log_level ) then
1907 l_msg_tokens.delete;
1908 WSM_log_PVT.logMessage(p_module_name => l_module,
1909 p_msg_text => 'Entering the Derive Validate Starting Job procedure for Merge',
1910 p_stmt_num => l_stmt_num,
1911 p_msg_tokens => l_msg_tokens,
1912 p_fnd_log_level => g_log_level_statement,
1913 p_run_log_level => l_log_level
1914 );
1915 End if;
1916
1917 l_stmt_num := 60;
1918 p_rep_job_index := -1;
1919 p_total_avail_quantity := 0;
1920 p_total_net_quantity := 0;
1921
1922 l_counter := p_starting_jobs_tbl.first;
1923 -- Just loop on one job and compare the first job with all...
1924 while l_counter is not null loop
1925
1926 l_stmt_num := 70;
1927
1928 if( g_log_level_statement >= l_log_level ) then
1929 l_msg_tokens.delete;
1930 WSM_log_PVT.logMessage(p_module_name => l_module,
1931 p_msg_text => 'Calling WSM_WIP_LOT_TXN_PVT.derive_val_st_job_details ',
1932 p_stmt_num => l_stmt_num,
1933 p_msg_tokens => l_msg_tokens,
1934 p_fnd_log_level => g_log_level_statement,
1935 p_run_log_level => l_log_level
1936 );
1937 End if;
1938
1939 -- Invoke the derive_val_st_job_details for the starting job
1940 derive_val_st_job_details( p_txn_org_id => p_txn_org_id,
1941 p_txn_type => WSMPCNST.MERGE,
1942 -- ST : Added Txn date for bug 4351071
1943 p_txn_date => p_txn_date,
1944 p_starting_job_rec => p_starting_jobs_tbl(l_counter),
1945 x_return_status => l_return_status,
1946 x_msg_count => l_msg_count,
1947 x_msg_data => l_msg_data
1948 );
1949
1950 l_stmt_num := 71;
1951
1952 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
1953 l_stmt_num := 72;
1954 -- Log the Procedure exit point....
1955 if( g_log_level_statement >= l_log_level ) then
1956
1957 l_msg_tokens.delete;
1958 WSM_log_PVT.logMessage(p_module_name => l_module ,
1959 p_msg_text => 'WSM_WIP_LOT_TXN_PVT.derive_val_st_job_details returned failure' ,
1960 p_stmt_num => l_stmt_num ,
1961 p_msg_tokens => l_msg_tokens,
1962 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1963 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1964 p_run_log_level => l_log_level
1965 );
1966 END IF;
1967
1968 if l_return_status <> G_RET_SUCCESS then
1969 IF l_return_status = G_RET_ERROR THEN
1970 raise FND_API.G_EXC_ERROR;
1971 ELSIF l_return_status = G_RET_UNEXPECTED THEN
1972 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1973 END IF;
1974 end if;
1975
1976 end if;
1977
1978
1979 l_stmt_num := 73;
1980
1981 -- ST : Serial Support --
1982 select nvl(serial_number_control_code,1)
1983 into l_code
1984 from mtl_system_items msi
1985 where inventory_item_id = p_starting_jobs_tbl(l_counter).primary_item_id
1986 and organization_id = p_txn_org_id;
1987
1988 IF x_job_serial_code IS NULL THEN
1989 x_job_serial_code := l_code;
1990 END IF;
1991
1992 IF x_job_serial_code <> l_code THEN
1993 -- error out..
1994 -- Cannot merge jobs with different item ctrl...
1995 IF g_log_level_error >= l_log_level OR
1996 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1997 THEN
1998
1999 l_msg_tokens.delete;
2000 WSM_log_PVT.logMessage(p_module_name => l_module ,
2001 p_msg_name => 'WSM_INVALID_MERGE_TXN' ,
2002 p_msg_appl_name => 'WSM' ,
2003 p_stmt_num => l_stmt_num ,
2004 p_msg_tokens => l_msg_tokens ,
2005 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2006 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2007 p_run_log_level => l_log_level
2008 );
2009 END IF;
2010 RAISE FND_API.G_EXC_ERROR;
2011 END IF;
2012 -- ST : Serial Support --
2013
2014 -- All the starting jobs should be of same job type, and should
2015 -- have the quantity at the same standard operation and same intraoperation step.
2016 -- Store these values from the first job and compare for each of the jobs
2017 if l_job_type is NULL then
2018 l_job_type := p_starting_jobs_tbl(l_counter).job_type;
2019 end if;
2020
2021 if l_std_op_id is NULL and p_starting_jobs_tbl(l_counter).standard_operation_id is NOT NULL then
2022 l_std_op_id := p_starting_jobs_tbl(l_counter).standard_operation_id;
2023 end if;
2024
2025 if l_dept_id is NULL then
2026 l_dept_id := p_starting_jobs_tbl(l_counter).department_id;
2027 end if;
2028
2029 if l_intraop_step is NULL then
2030 l_intraop_step := p_starting_jobs_tbl(l_counter).intraoperation_step;
2031 end if;
2032
2033 -- ST : Serial Support --
2034 IF l_serial_track IS NULL THEN
2035 l_serial_track := nvl(p_starting_jobs_tbl(l_counter).serial_track_flag,-1);
2036 ELSIF l_serial_track <> nvl(p_starting_jobs_tbl(l_counter).serial_track_flag,-1) THEN
2037 -- Error out ... cannot managed serial and non-serial tracked jobs.
2038
2039 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2040 l_msg_tokens.delete;
2041 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2042 p_msg_name => 'WSM_INVALID_TRACK_MERGE',
2043 p_msg_appl_name => 'WSM',
2044 p_msg_tokens => l_msg_tokens ,
2045 p_stmt_num => l_stmt_num ,
2046 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2047 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2048 p_run_log_level => l_log_level
2049 );
2050 END IF;
2051
2052 RAISE FND_API.G_EXC_ERROR;
2053 END IF;
2054 -- ST : Serial Support --
2055
2056 -- check for duplicate job name
2057 If l_wip_entity_name.exists(p_starting_jobs_tbl(l_counter).wip_entity_name) THEN
2058
2059 l_stmt_num := 75;
2060 --error msg
2061 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2062
2063 l_msg_tokens.delete;
2064 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2065 p_msg_name => 'WSM_CHECK_STLOT_WHILE_MERGE',
2066 p_msg_appl_name => 'WSM',
2067 p_msg_tokens => l_msg_tokens ,
2068 p_stmt_num => l_stmt_num ,
2069 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2070 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2071 p_run_log_level => l_log_level
2072 );
2073 END IF;
2074 RAISE FND_API.G_EXC_ERROR;
2075 ELSE
2076 l_wip_entity_name(p_starting_jobs_tbl(l_counter).wip_entity_name) := 1;
2077 END IF;
2078
2079 -- All the jobs must be of same type
2080 if p_starting_jobs_tbl(l_counter).job_type <> l_job_type then
2081
2082 l_stmt_num := 80;
2083 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2084
2085 l_msg_tokens.delete;
2086 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2087 p_msg_name => 'WSM_DIFF_JOB_TYP_ST',
2088 p_msg_appl_name => 'WSM',
2089 p_stmt_num => l_stmt_num ,
2090 p_msg_tokens => l_msg_tokens ,
2091 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2092 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2093 p_run_log_level => l_log_level
2094 );
2095 END IF;
2096 RAISE FND_API.G_EXC_ERROR;
2097
2098 end if;
2099
2100 -- Merge possible only at standard operation
2101 IF p_starting_jobs_tbl(l_counter).standard_operation_id is NULL then
2102 l_stmt_num := 85;
2103 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) then
2104 l_msg_tokens.delete;
2105 WSM_log_PVT.logMessage(p_module_name => l_module ,
2106 p_msg_name => 'WSM_NO_MERGE_AT_NSO',
2107 p_msg_appl_name => 'WSM' ,
2108 p_msg_tokens => l_msg_tokens ,
2109 p_stmt_num => l_stmt_num ,
2110 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2111 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2112 p_run_log_level => l_log_level
2113 );
2114 END IF;
2115 RAISE FND_API.G_EXC_ERROR;
2116 END IF;
2117
2118 l_stmt_num := 90;
2119 -- Also check for the std_op_id, dept id checks.....
2120 IF (l_std_op_id <> nvl(p_starting_jobs_tbl(l_counter).standard_operation_id,-1))
2121 OR
2122 (l_dept_id <> nvl(p_starting_jobs_tbl(l_counter).department_id,-1))
2123 OR
2124 (l_intraop_step <> nvl(p_starting_jobs_tbl(l_counter).intraoperation_step,-1))
2125 THEN
2126 l_stmt_num := 100;
2127 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2128 l_msg_tokens.delete;
2129 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2130 p_msg_name => 'WSM_MERGE_SL_STD_OP_ID',
2131 p_msg_appl_name => 'WSM',
2132 p_msg_tokens => l_msg_tokens ,
2133 p_stmt_num => l_stmt_num ,
2134 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2135 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2136 p_run_log_level => l_log_level
2137 );
2138 END IF;
2139 RAISE FND_API.G_EXC_ERROR;
2140 END IF;
2141
2142 -- Store the representative job index...
2143 if p_starting_jobs_tbl(l_counter).representative_flag = 'Y' THEN
2144 IF p_rep_job_index = -1 THEN
2145 -- assign the rep job index
2146 p_rep_job_index := l_counter;
2147 ELSE
2148 -- error out .. only one rep job
2149 l_stmt_num := 110;
2150 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2151 l_msg_tokens.delete;
2152 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2153 p_msg_name => 'WSM_REPRESENTATIVE_LOT',
2154 p_msg_appl_name => 'WSM',
2155 p_msg_tokens => l_msg_tokens ,
2156 p_stmt_num => l_stmt_num ,
2157 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2158 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2159 p_run_log_level => l_log_level
2160 );
2161 END IF;
2162 RAISE FND_API.G_EXC_ERROR;
2163 END IF;
2164 END IF;
2165
2166 p_total_avail_quantity := p_total_avail_quantity + p_starting_jobs_tbl(l_counter).quantity_available;
2167 p_total_net_quantity := p_total_net_quantity + p_starting_jobs_tbl(l_counter).net_quantity;
2168
2169 l_counter := p_starting_jobs_tbl.next(l_counter);
2170 END LOOP;
2171
2172 IF p_rep_job_index = -1 THEN
2173
2174 l_stmt_num := 120;
2175 -- error out as atleast one rep job needed....log error
2176 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2177 l_msg_tokens.delete;
2178 WSM_log_PVT.logMessage(p_module_name=> l_module ,
2179 p_msg_name => 'WSM_REPRESENTATIVE_LOT',
2180 p_msg_appl_name => 'WSM',
2181 p_msg_tokens => l_msg_tokens ,
2182 p_stmt_num => l_stmt_num ,
2183 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2184 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2185 p_run_log_level => l_log_level
2186 );
2187 END IF;
2188 RAISE FND_API.G_EXC_ERROR;
2189
2190 END IF;
2191
2192 l_stmt_num := 130;
2193 x_return_status := FND_API.G_RET_STS_SUCCESS;
2194
2195 EXCEPTION
2196 WHEN FND_API.G_EXC_ERROR THEN
2197 ROLLBACK TO start_val_start_job_merge;
2198 x_return_status := G_RET_ERROR;
2199 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
2200 p_count => x_msg_count ,
2201 p_data => x_msg_data
2202 );
2203
2204 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2205 ROLLBACK TO start_val_start_job_merge;
2206 x_return_status := G_RET_UNEXPECTED;
2207
2208 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
2209 p_count => x_msg_count ,
2210 p_data => x_msg_data
2211 );
2212 WHEN OTHERS THEN
2213 ROLLBACK TO start_val_start_job_merge;
2214 x_return_status := G_RET_UNEXPECTED;
2215
2216 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2217 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2218 THEN
2219 WSM_log_PVT.handle_others( p_module_name => l_module ,
2220 p_stmt_num => l_stmt_num ,
2221 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2222 p_run_log_level => l_log_level
2223 );
2224 END IF;
2225
2226 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
2227 p_count => x_msg_count ,
2228 p_data => x_msg_data
2229 );
2230 END;
2231
2232 -- Default resulting job details from the starting job for appropriate fields depending on txn and also validate the appropriate fields
2233 Procedure derive_val_res_job_details( p_txn_type IN NUMBER,
2234 p_txn_org_id IN NUMBER,
2235 p_transaction_date IN DATE,
2236 p_starting_job_rec IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_REC_TYPE,
2237 p_resulting_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
2238 x_return_status OUT NOCOPY VARCHAR2,
2239 x_msg_count OUT NOCOPY NUMBER,
2240 x_msg_data OUT NOCOPY VARCHAR2
2241 ) IS
2242 -- Status variables
2243 l_return_status VARCHAR2(1);
2244 l_msg_count NUMBER;
2245 l_msg_data VARCHAR2(2000);
2246
2247 -- Other locals
2248 l_wip_entity_id number;
2249 l_exists number;
2250 l_costed_flag boolean;
2251
2252 l_start_serial_code NUMBER;
2253 l_res_serial_code NUMBER;
2254
2255 l_start_op_seq_id NUMBER;
2256 l_end_op_seq_id NUMBER;
2257 l_error_code NUMBER;
2258
2259 -- local variable for logging purpose
2260 l_stmt_num NUMBER := 0;
2261 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2262 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2263 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.DERIVE_VAL_RES_JOB_DETAILS';
2264
2265 -- G_MISS_NUM and G_MISS_CHAR (now use G_NULL_CHAR and equivalents..
2266 l_null_num NUMBER := FND_API.G_NULL_NUM;
2267 l_null_char VARCHAR2(1) := FND_API.G_NULL_CHAR;
2268 l_null_date date;
2269 --e_exception EXCEPTION;
2270
2271 BEGIN
2272
2273 -- Have a starting point
2274 l_stmt_num := 10;
2275
2276 -- Initialize API return status to success
2277 x_return_status := FND_API.G_RET_STS_SUCCESS;
2278
2279 -- Log the Procedure entry point....
2280 if( g_log_level_statement >= l_log_level ) then
2281 l_msg_tokens.delete;
2282 WSM_log_PVT.logMessage(p_module_name => l_module ,
2283 p_msg_text => 'Entering the Default validate resulting Jobs' ,
2284 p_stmt_num => l_stmt_num ,
2285 p_msg_tokens => l_msg_tokens,
2286 p_fnd_log_level => g_log_level_statement,
2287 p_run_log_level => l_log_level
2288 );
2289 End if;
2290 l_stmt_num := 40;
2291
2292 if p_txn_type = WSMPCNST.UPDATE_ASSEMBLY then
2293
2294 -- Copy all the non-txn related fields
2295
2296 -- Job name and description
2297 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
2298 p_resulting_job_rec.description := p_starting_job_rec.description;
2299
2300 -- Primary info .....
2301 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
2302 p_resulting_job_rec.status_type := p_starting_job_rec.status_type;
2303 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
2304 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
2305 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
2306 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
2307
2308 -- Quantity info
2309 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
2310 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
2311
2312 -- Date info....
2313 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
2314 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
2315
2316 -- Other parameters....
2317 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
2318 p_resulting_job_rec.wip_supply_type := p_starting_job_rec.wip_supply_type;
2319
2320 -- Obtain item information....
2321 derive_val_primary_item ( p_txn_org_id => p_resulting_job_rec.organization_id,
2322 p_old_item_id => p_starting_job_rec.primary_item_id,
2323 p_new_item_name => p_resulting_job_rec.item_name,
2324 p_new_item_id => p_resulting_job_rec.primary_item_id,
2325 x_return_status => l_return_status,
2326 x_msg_count => l_msg_count,
2327 x_msg_data => l_msg_data
2328 );
2329
2330 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
2331 if( g_log_level_statement >= l_log_level ) then
2332
2333 l_msg_tokens.delete;
2334 WSM_log_PVT.logMessage(p_module_name => l_module ,
2335 p_msg_text => 'derive_val_primary_item returned failure',
2336 p_stmt_num => l_stmt_num ,
2337 p_msg_tokens => l_msg_tokens,
2338 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2339 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2340 p_run_log_level => l_log_level
2341 );
2342 END IF;
2343 raise FND_API.G_EXC_ERROR;
2344 end if ;
2345
2346 -- ST : Serial Support --
2347 select nvl(serial_number_control_code,1)
2348 into l_start_serial_code
2349 from mtl_system_items msi
2350 where inventory_item_id = p_starting_job_rec.primary_item_id
2351 and organization_id = p_txn_org_id;
2352
2353 select nvl(serial_number_control_code,1)
2354 into l_res_serial_code
2355 from mtl_system_items msi
2356 where inventory_item_id = p_resulting_job_rec.primary_item_id
2357 and organization_id = p_txn_org_id;
2358
2359 IF l_start_serial_code <> l_res_serial_code then
2360 -- error out..
2361 -- Cannot do an update assembly txn as the serial control code differs for the two items..(of starting and resulting job)
2362 IF g_log_level_error >= l_log_level OR
2363 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
2364 THEN
2365
2366 l_msg_tokens.delete;
2367 WSM_log_PVT.logMessage(p_module_name => l_module ,
2368 p_msg_name => 'WSM_INVALID_UPD_ASSY' ,
2369 p_msg_appl_name => 'WSM' ,
2370 p_msg_tokens => l_msg_tokens ,
2371 p_stmt_num => l_stmt_num ,
2372 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2373 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2374 p_run_log_level => l_log_level
2375 );
2376 END IF;
2377 RAISE FND_API.G_EXC_ERROR;
2378 END IF;
2379 -- ST : Serial Support --
2380
2381 -- call derive_val_bom_info
2382 derive_val_bom_info ( p_txn_org_id => p_resulting_job_rec.organization_id,
2383 p_sj_job_type => p_starting_job_rec.job_type,
2384 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
2385 p_rj_bom_reference_item => p_resulting_job_rec.bom_reference_item,
2386 p_rj_bom_reference_id => p_resulting_job_rec.bom_reference_id,
2387 p_rj_alternate_bom_desig => p_resulting_job_rec.alternate_bom_designator,
2388 p_rj_common_bom_seq_id => p_resulting_job_rec.common_bom_sequence_id,
2389 p_rj_bom_revision => p_resulting_job_rec.bom_revision,
2390 p_rj_bom_revision_date => p_resulting_job_rec.bom_revision_date,
2391 x_return_status => l_return_status,
2392 x_msg_count => l_msg_count,
2393 x_msg_data => l_msg_data
2394 );
2395
2396 IF l_return_status <> G_RET_SUCCESS THEN
2397 if( g_log_level_statement >= l_log_level ) then
2398 l_msg_tokens.delete;
2399 WSM_log_PVT.logMessage(p_module_name => l_module ,
2400 p_msg_text => 'derive_val_bom_info returned failure',
2401 p_stmt_num => l_stmt_num ,
2402 p_msg_tokens => l_msg_tokens,
2403 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2404 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2405 p_run_log_level => l_log_level
2406 );
2407 END IF;
2408 IF l_return_status = G_RET_ERROR THEN
2409 raise FND_API.G_EXC_ERROR;
2410 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2411 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2412 END IF;
2413 end if;
2414
2415 -- call derive_val_routing_info
2416 derive_val_routing_info ( p_txn_org_id => p_resulting_job_rec.organization_id,
2417 p_sj_job_type => p_starting_job_rec.job_type,
2418 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
2419 p_rj_rtg_reference_item => p_resulting_job_rec.routing_reference_item,
2420 p_rj_rtg_reference_id => p_resulting_job_rec.routing_reference_id,
2421 p_rj_alternate_rtg_desig => p_resulting_job_rec.alternate_routing_designator,
2422 p_rj_common_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2423 p_rj_rtg_revision => p_resulting_job_rec.routing_revision,
2424 p_rj_rtg_revision_date => p_resulting_job_rec.routing_revision_date,
2425 x_return_status => l_return_status,
2426 x_msg_count => l_msg_count,
2427 x_msg_data => l_msg_data
2428 );
2429
2430 IF l_return_status <> G_RET_SUCCESS THEN
2431 if( g_log_level_statement >= l_log_level ) then
2432 l_msg_tokens.delete;
2433 WSM_log_PVT.logMessage(p_module_name => l_module ,
2434 p_msg_text => 'derive_val_routing_info returned failure',
2435 p_stmt_num => l_stmt_num ,
2436 p_msg_tokens => l_msg_tokens,
2437 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2438 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2439 p_run_log_level => l_log_level
2440 );
2441 END IF;
2442 IF l_return_status = G_RET_ERROR THEN
2443 raise FND_API.G_EXC_ERROR;
2444 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2445 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2446 END IF;
2447 end if;
2448
2449 -- call WSMPUTIL.find_routing_start to validate first operation in N/W.
2450 -- added for bug 5386675.
2451
2452 wsmputil.find_routing_start (p_routing_sequence_id => p_resulting_job_rec.common_routing_sequence_id,
2453 p_routing_rev_date => p_resulting_job_rec.routing_revision_date,
2454 start_op_seq_id => l_start_op_seq_id,
2455 x_err_code => l_error_code,
2456 x_err_msg => l_msg_data);
2457
2458 IF l_error_code < 0 THEN
2459 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
2460 l_msg_tokens.delete;
2461 WSM_log_PVT.logMessage(p_module_name => l_module ,
2462 p_msg_text => l_msg_data,
2463 p_stmt_num => l_stmt_num ,
2464 p_msg_tokens => l_msg_tokens,
2465 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2466 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2467 p_run_log_level => l_log_level
2468 );
2469 END IF;
2470
2471 raise FND_API.G_EXC_ERROR;
2472
2473 end if;
2474
2475 -- call WSMPUTIL.find_routing_end to validate last operation in N/W.
2476 -- added for bug 5386675.
2477
2478 wsmputil.find_routing_end (p_routing_sequence_id => p_resulting_job_rec.common_routing_sequence_id,
2479 p_routing_rev_date => p_resulting_job_rec.routing_revision_date,
2480 end_op_seq_id => l_end_op_seq_id,
2481 x_err_code => l_error_code,
2482 x_err_msg => l_msg_data);
2483
2484 IF l_error_code < 0 THEN
2485 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
2486 l_msg_tokens.delete;
2487 WSM_log_PVT.logMessage(p_module_name => l_module ,
2488 p_msg_text => l_msg_data,
2489 p_stmt_num => l_stmt_num ,
2490 p_msg_tokens => l_msg_tokens,
2491 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2492 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2493 p_run_log_level => l_log_level
2494 );
2495 END IF;
2496
2497 raise FND_API.G_EXC_ERROR;
2498
2499 end if;
2500
2501 -- call for the starting op....
2502 derive_val_starting_op ( p_txn_org_id => p_resulting_job_rec.organization_id,
2503 p_curr_op_seq_id => p_starting_job_rec.operation_seq_id,
2504 p_curr_op_code => p_starting_job_rec.operation_code,
2505 p_curr_std_op_id => p_starting_job_rec.standard_operation_id,
2506 p_curr_intra_op_step => p_starting_job_rec.intraoperation_step,
2507 p_new_comm_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2508 p_new_rtg_rev_date => p_resulting_job_rec.routing_revision_date ,
2509 p_new_op_seq_num => p_resulting_job_rec.starting_operation_seq_num,
2510 p_new_op_seq_id => p_resulting_job_rec.starting_operation_seq_id,
2511 p_new_std_op_id => p_resulting_job_rec.starting_std_op_id,
2512 p_new_op_seq_code => p_resulting_job_rec.starting_operation_code,
2513 p_new_dept_id => p_resulting_job_rec.department_id,
2514 x_return_status => l_return_status,
2515 x_msg_count => l_msg_count,
2516 x_msg_data => l_msg_data
2517 );
2518
2519 IF l_return_status <> G_RET_SUCCESS THEN
2520 if( g_log_level_statement >= l_log_level ) then
2521 l_msg_tokens.delete;
2522 WSM_log_PVT.logMessage(p_module_name => l_module ,
2523 p_msg_text => 'derive_val_starting_op returned failure',
2524 p_stmt_num => l_stmt_num ,
2525 p_msg_tokens => l_msg_tokens,
2526 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2527 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2528 p_run_log_level => l_log_level
2529 );
2530 END IF;
2531 IF l_return_status = G_RET_ERROR THEN
2532 raise FND_API.G_EXC_ERROR;
2533 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2534 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2535 END IF;
2536 end if;
2537
2538 -- Always overwrite the starting intraop step for Update Assy txn..
2539 p_resulting_job_rec.starting_intraoperation_step := WIP_CONSTANTS.QUEUE;
2540
2541 -- Completion subinv derivation....
2542 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
2543 p_old_rtg_seq_id => p_starting_job_rec.common_routing_sequence_id,
2544 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2545 p_organization_id => p_resulting_job_rec.organization_id,
2546 p_primary_item_id => p_resulting_job_rec.primary_item_id,
2547 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
2548 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
2549 -- ST : Bug fix 5094555 start
2550 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
2551 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
2552 -- ST : Bug fix 5094555 end
2553 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
2554 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
2555 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
2556 x_return_status => l_return_status,
2557 x_msg_count => l_msg_count,
2558 x_msg_data => l_msg_data
2559 );
2560
2561 IF l_return_status <> G_RET_SUCCESS THEN
2562 if( g_log_level_statement >= l_log_level ) then
2563 l_msg_tokens.delete;
2564 WSM_log_PVT.logMessage(p_module_name => l_module ,
2565 p_msg_text => 'derive_val_compl_subinv returned failure',
2566 p_stmt_num => l_stmt_num ,
2567 p_msg_tokens => l_msg_tokens,
2568 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2569 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2570 p_run_log_level => l_log_level
2571 );
2572 END IF;
2573 IF l_return_status = G_RET_ERROR THEN
2574 raise FND_API.G_EXC_ERROR;
2575 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2576 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2577 END IF;
2578 END IF;
2579
2580 l_stmt_num := 50;
2581
2582 elsif p_txn_type = WSMPCNST.UPDATE_ROUTING then
2583
2584 -- Job name and description
2585 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
2586 p_resulting_job_rec.description := p_starting_job_rec.description;
2587
2588 -- Primary info .....
2589 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
2590 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
2591 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
2592 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
2593 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
2594 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
2595 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
2596
2597 -- Quantity info
2598 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
2599 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
2600
2601 -- Date info....
2602 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
2603 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
2604
2605 -- Other parameters....
2606 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
2607 p_resulting_job_rec.wip_supply_type := p_starting_job_rec.wip_supply_type;
2608
2609 -- call derive_val_bom_info
2610 l_stmt_num := 60;
2611 derive_val_bom_info ( p_txn_org_id => p_txn_org_id,
2612 p_sj_job_type => p_resulting_job_rec.job_type,
2613 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
2614 p_rj_bom_reference_item => p_resulting_job_rec.bom_reference_item,
2615 p_rj_bom_reference_id => p_resulting_job_rec.bom_reference_id,
2616 p_rj_alternate_bom_desig => p_resulting_job_rec.alternate_bom_designator,
2617 p_rj_common_bom_seq_id => p_resulting_job_rec.common_bom_sequence_id,
2618 p_rj_bom_revision => p_resulting_job_rec.bom_revision,
2619 p_rj_bom_revision_date => p_resulting_job_rec.bom_revision_date,
2620 x_return_status => l_return_status,
2621 x_msg_count => l_msg_count,
2622 x_msg_data => l_msg_data
2623 );
2624
2625
2626 IF l_return_status <> G_RET_SUCCESS THEN
2627 if( g_log_level_statement >= l_log_level ) then
2628 l_msg_tokens.delete;
2629 WSM_log_PVT.logMessage(p_module_name => l_module ,
2630 p_msg_text => 'derive_val_bom_info returned failure',
2631 p_stmt_num => l_stmt_num ,
2632 p_msg_tokens => l_msg_tokens,
2633 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2634 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2635 p_run_log_level => l_log_level
2636 );
2637 END IF;
2638 IF l_return_status = G_RET_ERROR THEN
2639 raise FND_API.G_EXC_ERROR;
2640 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2641 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2642 END IF;
2643 END IF;
2644
2645 l_stmt_num := 70;
2646 l_return_status := null;
2647 l_msg_count := 0;
2648 l_msg_data := null;
2649
2650 -- call derive_val_routing_info
2651 derive_val_routing_info ( p_txn_org_id => p_resulting_job_rec.organization_id,
2652 p_sj_job_type => p_starting_job_rec.job_type,
2653 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
2654 p_rj_rtg_reference_item => p_resulting_job_rec.routing_reference_item,
2655 p_rj_rtg_reference_id => p_resulting_job_rec.routing_reference_id,
2656 p_rj_alternate_rtg_desig => p_resulting_job_rec.alternate_routing_designator,
2657 p_rj_common_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2658 p_rj_rtg_revision => p_resulting_job_rec.routing_revision,
2659 p_rj_rtg_revision_date => p_resulting_job_rec.routing_revision_date,
2660 x_return_status => l_return_status,
2661 x_msg_count => l_msg_count,
2662 x_msg_data => l_msg_data
2663 );
2664 IF l_return_status <> G_RET_SUCCESS THEN
2665 if( g_log_level_statement >= l_log_level ) then
2666 l_msg_tokens.delete;
2667 WSM_log_PVT.logMessage(p_module_name => l_module ,
2668 p_msg_text => 'derive_val_routing_info returned failure',
2669 p_stmt_num => l_stmt_num ,
2670 p_msg_tokens => l_msg_tokens,
2671 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2672 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2673 p_run_log_level => l_log_level
2674 );
2675 END IF;
2676 IF l_return_status = G_RET_ERROR THEN
2677 raise FND_API.G_EXC_ERROR;
2678 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2679 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2680 END IF;
2681 END IF;
2682
2683 -- Atleast one of the routing fields must change.. or else error out..
2684 if (nvl(p_resulting_job_rec.routing_reference_id,-1) = nvl(p_starting_job_rec.routing_reference_id,-1)) and
2685 (p_resulting_job_rec.common_routing_sequence_id = p_starting_job_rec.common_routing_sequence_id) and
2686 (p_resulting_job_rec.alternate_routing_designator = p_starting_job_rec.alternate_routing_designator) and
2687 (p_resulting_job_rec.routing_revision = p_starting_job_rec.routing_revision ) and
2688 (p_resulting_job_rec.routing_revision_date = p_starting_job_rec.routing_revision_date)
2689 then
2690 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2691 l_msg_tokens.delete;
2692 WSM_log_PVT.logMessage(p_module_name=> l_module,
2693 p_msg_name => 'WSM_NO_ROUTING_CHANGE',
2694 p_msg_appl_name => 'WSM',
2695 p_msg_tokens => l_msg_tokens,
2696 p_stmt_num => l_stmt_num,
2697 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2698 p_fnd_log_level => G_LOG_LEVEL_ERROR,
2699 p_run_log_level => l_log_level
2700 );
2701 END IF;
2702 raise FND_API.G_EXC_ERROR;
2703 end if;
2704
2705 -- call WSMPUTIL.find_routing_start to validate first operation in N/W.
2706 -- added for bug 5386675.
2707
2708 wsmputil.find_routing_start (p_routing_sequence_id => p_resulting_job_rec.common_routing_sequence_id,
2709 p_routing_rev_date => p_resulting_job_rec.routing_revision_date,
2710 start_op_seq_id => l_start_op_seq_id,
2711 x_err_code => l_error_code,
2712 x_err_msg => l_msg_data);
2713
2714 IF l_error_code < 0 THEN
2715 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
2716 l_msg_tokens.delete;
2717 WSM_log_PVT.logMessage(p_module_name => l_module ,
2718 p_msg_text => l_msg_data,
2719 p_stmt_num => l_stmt_num ,
2720 p_msg_tokens => l_msg_tokens,
2721 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2722 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2723 p_run_log_level => l_log_level
2724 );
2725 END IF;
2726
2727 raise FND_API.G_EXC_ERROR;
2728
2729 end if;
2730
2731 -- call WSMPUTIL.find_routing_end to validate last operation in N/W.
2732 -- added for bug 5386675.
2733
2734 wsmputil.find_routing_end (p_routing_sequence_id => p_resulting_job_rec.common_routing_sequence_id,
2735 p_routing_rev_date => p_resulting_job_rec.routing_revision_date,
2736 end_op_seq_id => l_end_op_seq_id,
2737 x_err_code => l_error_code,
2738 x_err_msg => l_msg_data);
2739
2740 IF l_error_code < 0 THEN
2741 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
2742 l_msg_tokens.delete;
2743 WSM_log_PVT.logMessage(p_module_name => l_module ,
2744 p_msg_text => l_msg_data,
2745 p_stmt_num => l_stmt_num ,
2746 p_msg_tokens => l_msg_tokens,
2747 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2748 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2749 p_run_log_level => l_log_level
2750 );
2751 END IF;
2752
2753 raise FND_API.G_EXC_ERROR;
2754
2755 end if;
2756
2757 -- call for the starting op....
2758 derive_val_starting_op ( p_txn_org_id => p_resulting_job_rec.organization_id,
2759 p_curr_op_seq_id => p_starting_job_rec.operation_seq_id,
2760 p_curr_op_code => p_starting_job_rec.operation_code,
2761 p_curr_std_op_id => p_starting_job_rec.standard_operation_id,
2762 p_curr_intra_op_step => p_starting_job_rec.intraoperation_step,
2763 p_new_comm_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2764 p_new_rtg_rev_date => p_resulting_job_rec.routing_revision_date ,
2765 p_new_op_seq_num => p_resulting_job_rec.starting_operation_seq_num,
2766 p_new_op_seq_id => p_resulting_job_rec.starting_operation_seq_id,
2767 p_new_std_op_id => p_resulting_job_rec.starting_std_op_id,
2768 p_new_op_seq_code => p_resulting_job_rec.starting_operation_code,
2769 p_new_dept_id => p_resulting_job_rec.department_id,
2770 x_return_status => l_return_status,
2771 x_msg_count => l_msg_count,
2772 x_msg_data => l_msg_data
2773 );
2774
2775 IF l_return_status <> G_RET_SUCCESS THEN
2776 if( g_log_level_statement >= l_log_level ) then
2777 l_msg_tokens.delete;
2778 WSM_log_PVT.logMessage(p_module_name => l_module ,
2779 p_msg_text => 'derive_val_starting_op returned failure',
2780 p_stmt_num => l_stmt_num ,
2781 p_msg_tokens => l_msg_tokens,
2782 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2783 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2784 p_run_log_level => l_log_level
2785 );
2786 END IF;
2787 IF l_return_status = G_RET_ERROR THEN
2788 raise FND_API.G_EXC_ERROR;
2789 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2790 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2791 END IF;
2792 END IF;
2793
2794 -- Always overwrite the starting intraop step for Update Rtg txn..
2795 p_resulting_job_rec.starting_intraoperation_step := WIP_CONSTANTS.QUEUE;
2796
2797 -- Completion subinv derivation....
2798 l_return_status := null;
2799 l_msg_count := 0;
2800 l_msg_data := null;
2801
2802 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
2803 p_old_rtg_seq_id => p_starting_job_rec.common_routing_sequence_id,
2804 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
2805 p_organization_id => p_resulting_job_rec.organization_id,
2806 p_primary_item_id => p_resulting_job_rec.primary_item_id,
2807 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
2808 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
2809 -- ST : Bug fix 5094555 start
2810 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
2811 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
2812 -- ST : Bug fix 5094555 end
2813 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
2814 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
2815 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
2816 x_return_status => l_return_status,
2817 x_msg_count => l_msg_count,
2818 x_msg_data => l_msg_data
2819 );
2820
2821 IF l_return_status <> G_RET_SUCCESS THEN
2822 if( g_log_level_statement >= l_log_level ) then
2823 l_msg_tokens.delete;
2824 WSM_log_PVT.logMessage(p_module_name => l_module ,
2825 p_msg_text => 'derive_val_compl_subinv returned failure',
2826 p_stmt_num => l_stmt_num ,
2827 p_msg_tokens => l_msg_tokens,
2828 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2829 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2830 p_run_log_level => l_log_level
2831 );
2832 END IF;
2833 IF l_return_status = G_RET_ERROR THEN
2834 raise FND_API.G_EXC_ERROR;
2835 ELSIF l_return_status = G_RET_UNEXPECTED THEN
2836 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2837 END IF;
2838 END IF;
2839
2840 -- update routing done.....
2841 l_stmt_num := 60;
2842
2843 elsif p_txn_type = WSMPCNST.UPDATE_QUANTITY then
2844
2845 -- Copy all the non-txn related fields
2846 -- Job name and description
2847 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
2848 p_resulting_job_rec.description := p_starting_job_rec.description;
2849
2850 -- Primary info .....
2851 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
2852 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
2853 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
2854 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
2855 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
2856 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
2857 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
2858
2859 -- BOM details ....
2860 p_resulting_job_rec.bom_reference_id := p_starting_job_rec.bom_reference_id;
2861 p_resulting_job_rec.common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
2862 p_resulting_job_rec.bom_revision := p_starting_job_rec.bom_revision;
2863 p_resulting_job_rec.bom_revision_date := p_starting_job_rec.bom_revision_date;
2864 p_resulting_job_rec.alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
2865
2866 -- Routing details
2867 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
2868 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
2869 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
2870 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
2871 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
2872
2873 -- Starting operation details....
2874 p_resulting_job_rec.starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
2875 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
2876 p_resulting_job_rec.starting_operation_code := p_starting_job_rec.operation_code;
2877 p_resulting_job_rec.starting_std_op_id := p_starting_job_rec.standard_operation_id;
2878 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
2879 p_resulting_job_rec.department_id := p_starting_job_rec.department_id;
2880 p_resulting_job_rec.department_code := p_starting_job_rec.department_code;
2881 p_resulting_job_rec.operation_description := p_starting_job_rec.operation_description;
2882
2883 -- Date info....
2884 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
2885 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
2886
2887 -- Other parameters....
2888 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
2889 p_resulting_job_rec.wip_supply_type := p_starting_job_rec.wip_supply_type;
2890
2891 if (p_resulting_job_rec.start_quantity is null) then
2892 -- error out as qty info is needed....
2893 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2894 l_msg_tokens.delete;
2895 WSM_log_PVT.logMessage(p_module_name => l_module ,
2896 p_msg_name => 'WSM_QTY_INFO_REQUIRED',
2897 p_msg_appl_name => 'WSM',
2898 p_msg_tokens => l_msg_tokens,
2899 p_stmt_num => l_stmt_num ,
2900 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2901 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2902 p_run_log_level => l_log_level
2903 );
2904 END IF;
2905 RAISE FND_API.G_EXC_ERROR;
2906 end if;
2907
2908 IF (p_resulting_job_rec.start_quantity = l_null_num) OR
2909 (p_resulting_job_rec.start_quantity <=0 ) OR
2910 (p_resulting_job_rec.start_quantity <= p_starting_job_rec.quantity_available)
2911 then
2912 -- error out....
2913 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
2914 l_msg_tokens.delete;
2915 WSM_log_PVT.logMessage(p_module_name => l_module ,
2916 p_msg_name => 'WSM_QUANTITY_GREATER',
2917 p_msg_appl_name => 'WSM',
2918 p_msg_tokens => l_msg_tokens,
2919 p_stmt_num => l_stmt_num ,
2920 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2921 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2922 p_run_log_level => l_log_level
2923 );
2924 END IF;
2925 raise FND_API.G_EXC_ERROR;
2926 end if;
2927
2928 -- ST : Serial Support Project --
2929 select nvl(serial_number_control_code,1)
2930 into l_start_serial_code
2931 from mtl_system_items msi
2932 where inventory_item_id = p_starting_job_rec.primary_item_id
2933 and organization_id = p_txn_org_id;
2934 -- ST : Serial Support Project --
2935
2936 -- Now comes the net qty funda....
2937 if (p_resulting_job_rec.net_quantity is null) then
2938 -- have to derive it,.....
2939 p_resulting_job_rec.net_quantity := round(( (p_resulting_job_rec.start_quantity/p_starting_job_rec.quantity_available)*p_starting_job_rec.net_quantity ),6);
2940
2941 if p_resulting_job_rec.net_quantity > p_resulting_job_rec.start_quantity then
2942 p_resulting_job_rec.net_quantity := p_resulting_job_rec.start_quantity;
2943 end if;
2944 -- ST : Serial Support Project --
2945 IF l_start_serial_code = 2 THEN
2946 p_resulting_job_rec.net_quantity := floor(p_resulting_job_rec.net_quantity);
2947 END IF;
2948 -- ST : Serial Support Project --
2949
2950 elsif (p_resulting_job_rec.net_quantity = l_null_num) or
2951 (p_resulting_job_rec.net_quantity < 0 ) or
2952 (p_resulting_job_rec.net_quantity > p_resulting_job_rec.start_quantity)
2953 then
2954 -- error out...
2955 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
2956 l_msg_tokens.delete;
2957 l_msg_tokens(1).TokenName := 'FLD_NAME';
2958 l_msg_tokens(1).TokenValue := ' Net Quantity';
2959 WSM_log_PVT.logMessage(p_module_name => l_module ,
2960 p_msg_name => 'WSM_INVALID_FIELD',
2961 p_msg_appl_name => 'WSM' ,
2962 p_msg_tokens => l_msg_tokens ,
2963 p_stmt_num => l_stmt_num ,
2964 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2965 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2966 p_run_log_level => l_log_level
2967 );
2968 END IF;
2969 raise FND_API.G_EXC_ERROR;
2970 end if;
2971
2972 IF (l_start_serial_code = 2) AND
2973 ( p_resulting_job_rec.start_quantity <> floor(p_resulting_job_rec.start_quantity) OR
2974 p_resulting_job_rec.net_quantity <> floor(p_resulting_job_rec.net_quantity)
2975 )
2976 THEN
2977 -- error out...-- has to be an integer...
2978 IF g_log_level_error >= l_log_level OR
2979 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
2980 THEN
2981 l_msg_tokens.delete;
2982 WSM_log_PVT.logMessage(p_module_name => l_module ,
2983 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
2984 p_msg_appl_name => 'WSM' ,
2985 p_msg_tokens => l_msg_tokens ,
2986 p_stmt_num => l_stmt_num ,
2987 p_fnd_msg_level => G_MSG_LVL_ERROR ,
2988 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2989 p_run_log_level => l_log_level
2990 );
2991 END IF;
2992 RAISE FND_API.G_EXC_ERROR;
2993 END IF;
2994 -- ST : Serial Support Project --
2995
2996 -- account information......
2997 if (p_resulting_job_rec.BONUS_ACCT_ID is null) then
2998 -- error out... has to be provided...
2999 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3000 l_msg_tokens.delete;
3001 l_msg_tokens(1).TokenName := 'FLD_NAME';
3002 l_msg_tokens(1).TokenValue := 'BONUS_ACCT_ID';
3003 WSM_log_PVT.logMessage(p_module_name => l_module ,
3004 p_msg_name => 'WSM_NULL_FIELD',
3005 p_msg_appl_name => 'WSM' ,
3006 p_stmt_num => l_stmt_num ,
3007 p_msg_tokens => l_msg_tokens ,
3008 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3009 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3010 p_run_log_level => l_log_level
3011 );
3012 END IF;
3013 raise FND_API.G_EXC_ERROR;
3014 else
3015 -- validate the account passed,,,,,
3016 BEGIN
3017 select 1
3018 into l_exists
3019 from gl_code_combinations gcc,
3020 -- ST : Performance bug fix 4914162 : Remove the use of org_organization_definitions.
3021 -- org_organization_definitions ood
3022 hr_organization_information hoi,
3023 gl_sets_of_books gsob
3024 -- where p_resulting_job_rec.organization_id = ood.organization_id
3025 where p_resulting_job_rec.organization_id = hoi.organization_id
3026 -- and ood.chart_of_accounts_id = gcc.chart_of_accounts_id
3027 and gsob.chart_of_accounts_id = gcc.chart_of_accounts_id
3028 and nvl (p_resulting_job_rec.bonus_acct_id, -1) = gcc.code_combination_id
3029 and gcc.enabled_flag = 'Y'
3030 and p_transaction_date between nvl(gcc.start_date_active, p_transaction_date)
3031 and nvl(gcc.end_date_active, p_transaction_date)
3032 and gsob.set_of_books_id = TO_NUMBER(DECODE(RTRIM(TRANSLATE(hoi.org_information1,'0123456789',' ')),
3033 NULL,
3034 hoi.org_information1,
3035 -99999))
3036 and hoi.org_information_context || '' = 'Accounting Information';
3037
3038 EXCEPTION
3039 when no_data_found then
3040 -- error out.... --
3041 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3042
3043 l_msg_tokens.delete;
3044 l_msg_tokens(1).TokenName := 'FLD_NAME';
3045 l_msg_tokens(1).TokenValue := 'BONUS_ACCT_ID';
3046 WSM_log_PVT.logMessage(p_module_name=> l_module ,
3047 p_msg_name => 'WSM_INVALID_FIELD' ,
3048 p_msg_appl_name => 'WSM' ,
3049 p_msg_tokens => l_msg_tokens ,
3050 p_stmt_num => l_stmt_num ,
3051 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3052 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3053 p_run_log_level => l_log_level
3054 );
3055 END IF;
3056 RAISE FND_API.G_EXC_ERROR;
3057
3058 END;
3059
3060 end if;
3061
3062 -- Completion subinv derivation....
3063 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
3064 p_old_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3065 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3066 p_organization_id => p_resulting_job_rec.organization_id,
3067 p_primary_item_id => p_resulting_job_rec.primary_item_id,
3068 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
3069 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
3070 -- ST : Bug fix 5094555 start
3071 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
3072 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
3073 -- ST : Bug fix 5094555 end
3074 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
3075 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
3076 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
3077 x_return_status => l_return_status,
3078 x_msg_count => l_msg_count,
3079 x_msg_data => l_msg_data
3080 );
3081
3082 IF l_return_status <> G_RET_SUCCESS THEN
3083 if( g_log_level_statement >= l_log_level ) then
3084 l_msg_tokens.delete;
3085 WSM_log_PVT.logMessage(p_module_name => l_module ,
3086 p_msg_text => 'derive_val_compl_subinv returned failure',
3087 p_stmt_num => l_stmt_num ,
3088 p_msg_tokens => l_msg_tokens,
3089 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3090 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3091 p_run_log_level => l_log_level
3092 );
3093 END IF;
3094 IF l_return_status = G_RET_ERROR THEN
3095 raise FND_API.G_EXC_ERROR;
3096 ELSIF l_return_status = G_RET_UNEXPECTED THEN
3097 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3098 END IF;
3099 END IF;
3100
3101 -- update qty is done..... */
3102 l_stmt_num := 70;
3103
3104 elsif p_txn_type = WSMPCNST.UPDATE_LOT_NAME then
3105
3106 -- The only fields that the user can specify is Job name and Description */
3107
3108 -- Primary info ..... --
3109 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
3110 p_resulting_job_rec.status_type := p_starting_job_rec.status_type;
3111 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
3112 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
3113 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
3114 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
3115 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
3116 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
3117
3118 -- BOM details .... --
3119 p_resulting_job_rec.bom_reference_id := p_starting_job_rec.bom_reference_id;
3120 p_resulting_job_rec.common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
3121 p_resulting_job_rec.bom_revision := p_starting_job_rec.bom_revision;
3122 p_resulting_job_rec.bom_revision_date := p_starting_job_rec.bom_revision_date;
3123 p_resulting_job_rec.alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
3124
3125 -- Routing details --
3126 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
3127 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
3128 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
3129 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
3130 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
3131
3132 -- Quantity info --
3133 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
3134 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
3135
3136 /* Bugfix 5531371 CSI/locator can be updated */
3137 -- Completion sub inv details.... --
3138 --p_resulting_job_rec.completion_subinventory := p_starting_job_rec.completion_subinventory;
3139 --p_resulting_job_rec.completion_locator_id := p_starting_job_rec.completion_locator_id;
3140 /* End Bugfix 5531371 */
3141
3142 -- Starting operation details....--
3143 p_resulting_job_rec.starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
3144 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
3145 p_resulting_job_rec.starting_operation_code := p_starting_job_rec.operation_code;
3146 p_resulting_job_rec.starting_std_op_id := p_starting_job_rec.standard_operation_id;
3147 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
3148 p_resulting_job_rec.department_id := p_starting_job_rec.department_id;
3149 p_resulting_job_rec.department_code := p_starting_job_rec.department_code;
3150 p_resulting_job_rec.operation_description := p_starting_job_rec.operation_description;
3151
3152 -- Date info....--
3153 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
3154 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
3155
3156 -- Other parameters....--
3157 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3158 p_resulting_job_rec.wip_supply_type := p_starting_job_rec.wip_supply_type;
3159
3160 -- Job name and description --
3161 p_resulting_job_rec.wip_entity_name := nvl(p_resulting_job_rec.wip_entity_name,p_starting_job_rec.wip_entity_name);
3162 p_resulting_job_rec.description := nvl(p_resulting_job_rec.description,p_starting_job_rec.description);
3163
3164 if (p_resulting_job_rec.wip_entity_name = l_null_char) OR
3165 (p_resulting_job_rec.wip_entity_name IS NULL)
3166 then
3167 -- error out.... --
3168 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3169 l_msg_tokens.delete;
3170 l_msg_tokens(1).TokenName := 'FLD_NAME';
3171 l_msg_tokens(1).TokenValue := 'wip_entity_name';
3172 WSM_log_PVT.logMessage(p_module_name => l_module ,
3173 p_msg_name => 'WSM_NULL_FIELD',
3174 p_msg_appl_name => 'WSM' ,
3175 p_stmt_num => l_stmt_num ,
3176 p_msg_tokens => l_msg_tokens ,
3177 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3178 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3179 p_run_log_level => l_log_level
3180 );
3181 END IF;
3182 RAISE FND_API.G_EXC_ERROR;
3183 end if;
3184
3185 -- if the user intends to NULL out the field null it..
3186 if p_resulting_job_rec.description = l_null_char then
3187 p_resulting_job_rec.description := null;
3188 end if;
3189
3190 -- check if atleast one has changed ..... --
3191 if (p_resulting_job_rec.wip_entity_name = p_starting_job_rec.wip_entity_name) and
3192 (nvl(p_resulting_job_rec.description,'-1') = nvl(p_starting_job_rec.description,'-1'))
3193 then
3194 -- error out as atleast one has to change --
3195 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3196 l_msg_tokens.delete;
3197 WSM_log_PVT.logMessage(p_module_name=> l_module ,
3198 p_msg_name => 'WSM_NO_JOB_CHANGE',
3199 p_msg_appl_name => 'WSM',
3200 p_msg_tokens => l_msg_tokens ,
3201 p_stmt_num => l_stmt_num ,
3202 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3203 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3204 p_run_log_level => l_log_level
3205 );
3206 END IF;
3207 RAISE FND_API.G_EXC_ERROR;
3208
3209 end if;
3210
3211 if (p_resulting_job_rec.wip_entity_name <> p_starting_job_rec.wip_entity_name) then
3212 -- check for the validity of the job name,,, --
3213 l_wip_entity_id := p_resulting_job_rec.wip_entity_id;
3214 wip_entity( p_load_type => 'U',
3215 p_org_id => p_resulting_job_rec.organization_id,
3216 p_wip_entity_id => l_wip_entity_id,
3217 p_job_name => p_resulting_job_rec.wip_entity_name,
3218 x_return_status => l_return_status,
3219 x_error_msg => l_msg_data,
3220 x_error_count => l_msg_count
3221 );
3222 -- add check for the return status...
3223 if l_return_status <> G_RET_SUCCESS then
3224 IF l_return_status = G_RET_ERROR THEN
3225 raise FND_API.G_EXC_ERROR;
3226 ELSIF l_return_status = G_RET_UNEXPECTED THEN
3227 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3228 END IF;
3229 end if;
3230 end if;
3231
3232 /* Start Bugfix 5531371 validate csi/locator updation during upd lot name */
3233 -- Completion subinv derivation....
3234 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
3235 p_old_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3236 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3237 p_organization_id => p_resulting_job_rec.organization_id,
3238 p_primary_item_id => p_resulting_job_rec.primary_item_id,
3239 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
3240 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
3241 -- ST : Bug fix 5094555 start
3242 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
3243 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
3244 -- ST : Bug fix 5094555 end
3245 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
3246 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
3247 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
3248 x_return_status => l_return_status,
3249 x_msg_count => l_msg_count,
3250 x_msg_data => l_msg_data
3251 );
3252
3253 IF l_return_status <> G_RET_SUCCESS THEN
3254 if( g_log_level_statement >= l_log_level ) then
3255 l_msg_tokens.delete;
3256 WSM_log_PVT.logMessage(p_module_name => l_module ,
3257 p_msg_text => 'derive_val_compl_subinv returned failure',
3258 p_stmt_num => l_stmt_num ,
3259 p_msg_tokens => l_msg_tokens,
3260 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3261 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3262 p_run_log_level => l_log_level
3263 );
3264 END IF;
3265 IF l_return_status = G_RET_ERROR THEN
3266 raise FND_API.G_EXC_ERROR;
3267 ELSIF l_return_status = G_RET_UNEXPECTED THEN
3268 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3269 END IF;
3270 END IF;
3271 /* End Bugfix 5531371 */
3272
3273 -- update lot name complete.....--
3274 l_stmt_num := 90;
3275
3276 elsif (p_txn_type = 8) then -- WSMPCNST.UPDATE_COMPL_SUBINV
3277
3278 -- The only fields that the user can specify is completion subinv. locator, locator id
3279
3280 -- Job name and description --
3281 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
3282 p_resulting_job_rec.description := p_starting_job_rec.description;
3283
3284 -- Primary info ..... --
3285 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
3286 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
3287 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
3288 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
3289 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
3290 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
3291 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
3292
3293 -- BOM details .... --
3294 p_resulting_job_rec.bom_reference_id := p_starting_job_rec.bom_reference_id;
3295 p_resulting_job_rec.common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
3296 p_resulting_job_rec.bom_revision := p_starting_job_rec.bom_revision;
3297 p_resulting_job_rec.bom_revision_date := p_starting_job_rec.bom_revision_date;
3298 p_resulting_job_rec.alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
3299
3300 -- Routing details --
3301 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
3302 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
3303 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
3304 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
3305 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
3306
3307 -- Quantity info --
3308 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
3309 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
3310
3311 -- Starting operation details....--
3312 p_resulting_job_rec.starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
3313 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
3314 p_resulting_job_rec.starting_operation_code := p_starting_job_rec.operation_code;
3315 p_resulting_job_rec.starting_std_op_id := p_starting_job_rec.standard_operation_id;
3316 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
3317 p_resulting_job_rec.department_id := p_starting_job_rec.department_id;
3318 p_resulting_job_rec.department_code := p_starting_job_rec.department_code;
3319 p_resulting_job_rec.operation_description := p_starting_job_rec.operation_description;
3320
3321 -- Date info....--
3322 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
3323 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
3324
3325 -- Other parameters....--
3326 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3327
3328 if (p_resulting_job_rec.completion_subinventory is null) and
3329 (p_resulting_job_rec.completion_locator_id is null) and
3330 (p_resulting_job_rec.completion_locator is null)
3331 then
3332 -- error out,,
3333 null;
3334 end if;
3335
3336 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
3337 p_old_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3338 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3339 p_organization_id => p_resulting_job_rec.organization_id,
3340 p_primary_item_id => p_resulting_job_rec.primary_item_id,
3341 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
3342 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
3343 -- ST : Bug fix 5094555 start
3344 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
3345 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
3346 -- ST : Bug fix 5094555 end
3347 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
3348 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
3349 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
3350 x_return_status => l_return_status,
3351 x_msg_count => l_msg_count,
3352 x_msg_data => l_msg_data
3353 );
3354
3355
3356 if (nvl(p_resulting_job_rec.completion_subinventory,'-1') = nvl(p_resulting_job_rec.completion_subinventory,'-1')) and
3357 (nvl(p_resulting_job_rec.completion_locator_id,-10) = nvl(p_starting_job_rec.completion_locator_id,-10))
3358 then
3359 -- error out..
3360 null;
3361 end if;
3362
3363 ELSIF p_txn_type = 9 THEN --WSMPCNST.UPDATE_STATUS--
3364 --- copy all fields except for status type...
3365 -- Job name and description --
3366 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
3367 p_resulting_job_rec.description := p_starting_job_rec.description;
3368
3369 -- Primary info ..... --
3370 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
3371 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
3372 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
3373 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
3374 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
3375 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
3376 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
3377
3378 -- BOM details .... --
3379 p_resulting_job_rec.bom_reference_id := p_starting_job_rec.bom_reference_id;
3380 p_resulting_job_rec.common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
3381 p_resulting_job_rec.bom_revision := p_starting_job_rec.bom_revision;
3382 p_resulting_job_rec.bom_revision_date := p_starting_job_rec.bom_revision_date;
3383 p_resulting_job_rec.alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
3384
3385 -- Routing details --
3386 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
3387 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
3388 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
3389 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
3390 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
3391
3392 -- Quantity info --
3393 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
3394 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
3395
3396 -- Completion sub inv details.... Non Updatable.... --
3397 p_resulting_job_rec.completion_subinventory := p_starting_job_rec.completion_subinventory;
3398 p_resulting_job_rec.completion_locator_id := p_starting_job_rec.completion_locator_id;
3399
3400 -- Starting operation details....--
3401 p_resulting_job_rec.starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
3402 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
3403 p_resulting_job_rec.starting_operation_code := p_starting_job_rec.operation_code;
3404 p_resulting_job_rec.starting_std_op_id := p_starting_job_rec.standard_operation_id;
3405 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
3406 p_resulting_job_rec.department_id := p_starting_job_rec.department_id;
3407 p_resulting_job_rec.department_code := p_starting_job_rec.department_code;
3408 p_resulting_job_rec.operation_description := p_starting_job_rec.operation_description;
3409
3410 -- Date info....--
3411 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
3412 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
3413
3414 -- Other parameters....--
3415 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3416
3417 -- different status_type values
3418 -- 7 Cancelled
3419 -- 8 Pending Bill Load
3420 -- 9 Failed Bill Load
3421 -- 10 Pending Routing Load
3422 -- 11 Failed Routing Load
3423 -- 12 Closed
3424 -- 13 Pending - Mass Loaded
3425 -- 14 Pending Close
3426 -- 15 Failed Close
3427 -- 1 Unreleased
3428 -- 3 Released
3429 -- 4 Complete
3430 -- 5 Complete - No Charges
3431 -- 6 On Hold
3432
3433 -- Jobs that are On Hold, Cancelled, Failed To Close will be considered 'released' if they have a non-null date_released field --
3434
3435 if (p_resulting_job_rec.status_type is null) or
3436 (p_resulting_job_rec.status_type = l_null_num)
3437 then
3438 -- error out..... --
3439 null;
3440 end if;
3441
3442 if p_resulting_job_rec.status_type = p_starting_job_rec.status_type then
3443 -- error out.... --
3444 null;
3445 end if;
3446
3447 l_costed_flag := WSM_LBJ_Interface_PVT.discrete_charges_exist( p_wip_entity_id => p_resulting_job_rec.wip_entity_id,
3448 p_organization_id => p_resulting_job_rec.organization_id,
3449 p_check_mode => 0
3450 );
3451
3452 -- allowed changes.... --
3453 if p_starting_job_rec.status_type = 3 then
3454 -- Job is released..... --
3455 if p_resulting_job_rec.status_type not in (1, 6, 7 ) then
3456 -- error out... --
3457 null;
3458 end if;
3459
3460 if l_costed_flag and p_resulting_job_rec.status_type = 1 then
3461 -- error out.... --
3462 null;
3463 end if;
3464
3465 elsif p_starting_job_rec.status_type = 6 then
3466
3467 -- Job onhold --
3468 if p_resulting_job_rec.status_type not in (1,3,7) then
3469 -- error out... --
3470 null;
3471 end if;
3472
3473 -- Now also check based on the date_released.... --
3474 if (p_resulting_job_rec.status_type in (1,7) and p_starting_job_rec.date_released is null)
3475 or
3476 (p_resulting_job_rec.status_type=3 and l_costed_flag = false and p_starting_job_rec.date_released is null)
3477 then
3478 -- error out.... --
3479 null;
3480 end if;
3481
3482 elsif p_starting_job_rec.status_type = 7 then
3483
3484 -- Job Cancelled --
3485 if p_resulting_job_rec.status_type not in (1,3,6) then
3486 -- error out... --
3487 null;
3488 end if;
3489
3490 -- Now also check based on the date_released.... --
3491 if (p_resulting_job_rec.status_type in (1,6) and p_starting_job_rec.date_released is null)
3492 or
3493 (p_resulting_job_rec.status_type=3 and l_costed_flag = false and p_starting_job_rec.date_released is null)
3494 then
3495 -- error out.... --
3496 null;
3497 end if;
3498
3499 elsif p_starting_job_rec.status_type = 15 then
3500
3501 -- Job Failedtoclose --
3502 if p_resulting_job_rec.status_type not in (1,3,4,6,7) then
3503 -- error out... --
3504 null;
3505 end if;
3506
3507 -- Now also check based on the date_released.... --
3508 if (p_resulting_job_rec.status_type in (1,6,7) and p_starting_job_rec.date_released is null)
3509 or
3510 (p_resulting_job_rec.status_type=3 and l_costed_flag = false and p_starting_job_rec.date_released is null)
3511 then
3512 -- error out.... --
3513 null;
3514 end if;
3515
3516 else
3517 -- error out,..... --
3518 null;
3519 end if;
3520
3521 elsif p_txn_type = 10 then -- WSMPCNST.UPDATE_BOM*
3522
3523 -- this section is incomplete... will update it at the end.... --
3524
3525 -- copy all fields except for bom related ...
3526 -- Job name and description --
3527 p_resulting_job_rec.wip_entity_name := p_starting_job_rec.wip_entity_name;
3528 p_resulting_job_rec.description := p_starting_job_rec.description;
3529
3530 -- Primary info ..... --
3531 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
3532 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
3533 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
3534 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
3535 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
3536 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
3537 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
3538
3539 -- Routing details --
3540 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
3541 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
3542 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
3543 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
3544 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
3545
3546 -- Quantity info --
3547 p_resulting_job_rec.start_quantity := p_starting_job_rec.start_quantity;
3548 p_resulting_job_rec.net_quantity := p_starting_job_rec.net_quantity;
3549
3550 -- Date info....
3551 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
3552 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
3553
3554 -- Other parameters....
3555 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3556
3557
3558
3559 if (p_resulting_job_rec.bom_reference_id = l_null_num ) and
3560 (p_resulting_job_rec.bom_reference_item = l_null_char) and
3561 (p_resulting_job_rec.common_bom_sequence_id = l_null_num) and
3562 (p_resulting_job_rec.bom_revision = l_null_char) and
3563 (p_resulting_job_rec.bom_revision_date = l_null_date) and
3564 (p_resulting_job_rec.alternate_bom_designator = l_null_char)
3565 then
3566 -- user wants to detach the BOM....
3567 null;
3568 else
3569
3570 -- call derive_val_BOM procedure
3571 derive_val_bom_info ( p_txn_org_id => p_resulting_job_rec.organization_id,
3572 p_sj_job_type => p_starting_job_rec.job_type,
3573 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
3574 p_rj_bom_reference_item => p_resulting_job_rec.bom_reference_item,
3575 p_rj_bom_reference_id => p_resulting_job_rec.bom_reference_id,
3576 p_rj_alternate_bom_desig => p_resulting_job_rec.alternate_bom_designator,
3577 p_rj_common_bom_seq_id => p_resulting_job_rec.common_bom_sequence_id,
3578 p_rj_bom_revision => p_resulting_job_rec.bom_revision,
3579 p_rj_bom_revision_date => p_resulting_job_rec.bom_revision_date,
3580 x_return_status => l_return_status,
3581 x_msg_count => l_msg_count,
3582 x_msg_data => l_msg_data
3583 );
3584
3585 if (nvl(p_resulting_job_rec.bom_reference_id,-1) = nvl(p_resulting_job_rec.bom_reference_id,-1)) and
3586 (nvl(p_resulting_job_rec.common_bom_sequence_id,-1) = nvl(p_resulting_job_rec.common_bom_sequence_id,-1) ) and
3587 (nvl(p_resulting_job_rec.alternate_bom_designator,'-1') = nvl(p_resulting_job_rec.alternate_bom_designator,'-1')) and
3588 (nvl(p_resulting_job_rec.bom_revision,'-1') = nvl(p_resulting_job_rec.bom_revision,'-1') ) and
3589 (nvl(p_resulting_job_rec.bom_revision_date,l_null_date) = nvl(p_resulting_job_rec.bom_revision_date,l_null_date))
3590 then
3591 -- error out....
3592 null;
3593 end if;
3594
3595 p_resulting_job_rec.starting_operation_seq_num := null;
3596 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
3597 p_resulting_job_rec.starting_operation_code := null;
3598 p_resulting_job_rec.starting_std_op_id := null;
3599 p_resulting_job_rec.department_id := null;
3600 p_resulting_job_rec.department_code := null;
3601 p_resulting_job_rec.operation_description := null;
3602
3603 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
3604
3605 -- call for the starting op....
3606 derive_val_starting_op ( p_txn_org_id => p_resulting_job_rec.organization_id,
3607 p_curr_op_seq_id => p_starting_job_rec.operation_seq_id,
3608 p_curr_op_code => p_starting_job_rec.operation_code,
3609 p_curr_std_op_id => p_starting_job_rec.standard_operation_id,
3610 p_curr_intra_op_step => p_starting_job_rec.intraoperation_step,
3611 p_new_comm_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3612 p_new_rtg_rev_date => p_resulting_job_rec.routing_revision_date ,
3613 p_new_op_seq_num => p_resulting_job_rec.starting_operation_seq_num,
3614 p_new_op_seq_id => p_resulting_job_rec.starting_operation_seq_id,
3615 p_new_std_op_id => p_resulting_job_rec.starting_std_op_id,
3616 p_new_op_seq_code => p_resulting_job_rec.starting_operation_code,
3617 p_new_dept_id => p_resulting_job_rec.department_id,
3618 x_return_status => l_return_status,
3619 x_msg_count => l_msg_count,
3620 x_msg_data => l_msg_data
3621 );
3622
3623 -- Completion subinv derivation....
3624 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
3625 p_old_rtg_seq_id => p_starting_job_rec.common_routing_sequence_id,
3626 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3627 p_organization_id => p_resulting_job_rec.organization_id,
3628 p_primary_item_id => p_resulting_job_rec.primary_item_id,
3629 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
3630 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
3631 -- ST : Bug fix 5094555 start
3632 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
3633 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
3634 -- ST : Bug fix 5094555 end
3635 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
3636 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
3637 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
3638 x_return_status => l_return_status,
3639 x_msg_count => l_msg_count,
3640 x_msg_data => l_msg_data
3641 );
3642 end if;
3643
3644 end if;
3645
3646 x_return_status := FND_API.G_RET_STS_SUCCESS;
3647
3648 EXCEPTION
3649 WHEN FND_API.G_EXC_ERROR THEN
3650
3651 x_return_status := G_RET_ERROR;
3652 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3653 p_count => x_msg_count ,
3654 p_data => x_msg_data
3655 );
3656
3657 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3658
3659 x_return_status := G_RET_UNEXPECTED;
3660
3661 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
3662 p_count => x_msg_count ,
3663 p_data => x_msg_data
3664 );
3665
3666 WHEN OTHERS THEN
3667
3668 x_return_status := G_RET_UNEXPECTED;
3669
3670 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3671 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3672 THEN
3673 WSM_log_PVT.handle_others( p_module_name => l_module ,
3674 p_stmt_num => l_stmt_num ,
3675 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3676 p_run_log_level => l_log_level
3677 );
3678 END IF;
3679
3680 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
3681 p_count => x_msg_count ,
3682 p_data => x_msg_data
3683 );
3684
3685 END;
3686
3687 -- Default resulting job details for merge txn --
3688 Procedure derive_val_res_job_details( p_txn_type IN NUMBER,
3689 p_txn_org_id IN NUMBER,
3690 p_starting_job_rec IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_REC_TYPE,
3691 p_job_quantity IN NUMBER,
3692 p_job_net_quantity IN NUMBER,
3693 -- ST : Serial Support : Added the below parameter..
3694 p_job_serial_code IN NUMBER,
3695 p_resulting_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
3696 x_return_status OUT NOCOPY VARCHAR2,
3697 x_msg_count OUT NOCOPY NUMBER,
3698 x_msg_data OUT NOCOPY VARCHAR2
3699 ) is
3700
3701 l_return_status varchar2(1);
3702 l_msg_count number;
3703 l_msg_data varchar2(2000);
3704 --logging variables--
3705 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_res_job_details';
3706 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3707 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3708 l_stmt_num NUMBER := 0;
3709
3710 l_null_char varchar2(10) := FND_API.G_NULL_CHAR;
3711
3712 begin
3713 l_stmt_num := 10;
3714 if p_txn_type <> WSMPCNST.MERGE then
3715 --error out... --
3716 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3717 l_msg_tokens.delete;
3718 l_msg_tokens(1).TokenName := 'FLD_NAME';
3719 l_msg_tokens(1).TokenValue := 'Transaction Type not Merge';
3720 WSM_log_PVT.logMessage(p_module_name => l_module ,
3721 p_msg_name => 'WSM_INVALID_FIELD',
3722 p_msg_appl_name => 'WSM' ,
3723 p_stmt_num => l_stmt_num ,
3724 p_msg_tokens => l_msg_tokens ,
3725 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3726 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3727 p_run_log_level => l_log_level
3728 );
3729 END IF;
3730 RAISE FND_API.G_EXC_ERROR;
3731 end if;
3732
3733 -- Primary info ..... --
3734 p_resulting_job_rec.wip_entity_id := p_starting_job_rec.wip_entity_id;
3735 p_resulting_job_rec.status_type := p_starting_job_rec.status_type;
3736 p_resulting_job_rec.item_name := p_starting_job_rec.item_name;
3737 p_resulting_job_rec.primary_item_id := p_starting_job_rec.primary_item_id;
3738 p_resulting_job_rec.class_code := p_starting_job_rec.class_code;
3739 p_resulting_job_rec.job_type := p_starting_job_rec.job_type;
3740 p_resulting_job_rec.organization_id := p_starting_job_rec.organization_id;
3741 p_resulting_job_rec.organization_code := p_starting_job_rec.organization_code;
3742 p_resulting_job_rec.wip_supply_type := p_starting_job_rec.wip_supply_type;
3743
3744 -- BOM details .... --
3745 p_resulting_job_rec.bom_reference_id := p_starting_job_rec.bom_reference_id;
3746 p_resulting_job_rec.common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
3747 p_resulting_job_rec.bom_revision := p_starting_job_rec.bom_revision;
3748 p_resulting_job_rec.bom_revision_date := p_starting_job_rec.bom_revision_date;
3749 p_resulting_job_rec.alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
3750
3751 -- Routing details --
3752 p_resulting_job_rec.routing_reference_id := p_starting_job_rec.routing_reference_id;
3753 p_resulting_job_rec.common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
3754 p_resulting_job_rec.routing_revision := p_starting_job_rec.routing_revision;
3755 p_resulting_job_rec.routing_revision_date := p_starting_job_rec.routing_revision_date;
3756 p_resulting_job_rec.alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
3757
3758 -- Starting operation details....--
3759 p_resulting_job_rec.starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
3760 p_resulting_job_rec.starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
3761 p_resulting_job_rec.starting_operation_code := p_starting_job_rec.operation_code;
3762 p_resulting_job_rec.starting_std_op_id := p_starting_job_rec.standard_operation_id;
3763 p_resulting_job_rec.starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
3764 p_resulting_job_rec.department_id := p_starting_job_rec.department_id;
3765 p_resulting_job_rec.department_code := p_starting_job_rec.department_code;
3766 p_resulting_job_rec.operation_description := p_starting_job_rec.operation_description;
3767
3768 -- Date info....--
3769 p_resulting_job_rec.scheduled_start_date := p_starting_job_rec.scheduled_start_date;
3770 p_resulting_job_rec.scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
3771
3772 -- Other parameters....--
3773 -- ST : Commenting out for bug 5122500 --
3774 -- p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3775
3776 -- Job name and description --
3777 p_resulting_job_rec.wip_entity_name := nvl(p_resulting_job_rec.wip_entity_name,p_starting_job_rec.wip_entity_name);
3778 p_resulting_job_rec.description := nvl(p_resulting_job_rec.description,p_starting_job_rec.description);
3779
3780 if (p_resulting_job_rec.wip_entity_name = l_null_char)
3781 then
3782 -- error out.... --
3783 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3784 l_msg_tokens.delete;
3785 l_msg_tokens(1).TokenName := 'FLD_NAME';
3786 l_msg_tokens(1).TokenValue := 'wip_entity_name';
3787 WSM_log_PVT.logMessage(p_module_name => l_module ,
3788 p_msg_name => 'WSM_NULL_FIELD',
3789 p_msg_appl_name => 'WSM' ,
3790 p_stmt_num => l_stmt_num ,
3791 p_msg_tokens => l_msg_tokens ,
3792 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3793 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3794 p_run_log_level => l_log_level
3795 );
3796 END IF;
3797 RAISE FND_API.G_EXC_ERROR;
3798 end if;
3799
3800 -- description....... --
3801 if p_resulting_job_rec.description = l_null_char then
3802 p_resulting_job_rec.description := null;
3803 end if;
3804
3805 l_stmt_num := 20;
3806 if (p_resulting_job_rec.wip_entity_name <> p_starting_job_rec.wip_entity_name) then
3807
3808 -- Validate the Job name...
3809 wip_entity(p_load_type => 'C',
3810 p_org_id => p_resulting_job_rec.organization_id,
3811 p_wip_entity_id => p_resulting_job_rec.wip_entity_id, -- will make it null....
3812 p_job_name => p_resulting_job_rec.wip_entity_name,
3813 x_return_status => l_return_status,
3814 x_error_msg => l_msg_data,
3815 x_error_count => l_msg_count
3816 );
3817 p_resulting_job_rec.wip_entity_id := null;
3818
3819 if l_return_status <> G_RET_SUCCESS then
3820 IF l_return_status = G_RET_ERROR THEN
3821 raise FND_API.G_EXC_ERROR;
3822 ELSIF l_return_status = G_RET_UNEXPECTED THEN
3823 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3824 END IF;
3825 end if;
3826 end if;
3827
3828 l_stmt_num := 21;
3829 -- ST : Fix for bug 5122500 start --
3830 -- Co products supply start --
3831 IF p_resulting_job_rec.wip_entity_name = p_starting_job_rec.wip_entity_name THEN
3832
3833 IF p_resulting_job_rec.coproducts_supply IS NULL THEN
3834 p_resulting_job_rec.coproducts_supply := p_starting_job_rec.coproducts_supply;
3835 END IF;
3836
3837 ELSE -- new job.....---
3838 IF p_resulting_job_rec.coproducts_supply IS NULL THEN
3839 -- Query up the co-products supply..... --
3840 SELECT decode(coproducts_supply_default, NULL, 2
3841 , coproducts_supply_default)
3842 INTO p_resulting_job_rec.coproducts_supply
3843 FROM wsm_parameters
3844 WHERE organization_id = p_txn_org_id;
3845 END IF;
3846 END IF;
3847
3848 l_stmt_num := 25;
3849 IF NVL(p_resulting_job_rec.coproducts_supply,0) NOT IN(1,2) THEN
3850 --error out.... --
3851 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3852
3853 l_msg_tokens.delete;
3854 l_msg_tokens(1).TokenName := 'FLD_NAME';
3855 l_msg_tokens(1).TokenName := 'CoProducts Supply';
3856
3857 WSM_log_PVT.logMessage(p_module_name => l_module ,
3858 p_msg_name => 'WSM_INVALID_FIELD' ,
3859 p_msg_appl_name => 'WSM' ,
3860 p_msg_tokens => l_msg_tokens ,
3861 p_stmt_num => l_stmt_num ,
3862 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3863 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3864 p_run_log_level => l_log_level
3865 );
3866 END IF;
3867 raise FND_API.G_EXC_ERROR;
3868 END IF;
3869 --- Co products supply end --
3870 -- ST : Fix for bug 5122500 end --
3871
3872 l_stmt_num := 30;
3873 -- quantity stuff... --
3874 p_resulting_job_rec.start_quantity := p_job_quantity;
3875 --Bug 5375741: Before defaulting the net quantity,user supplied value should be validated.
3876 --p_resulting_job_rec.net_quantity := nvl(p_resulting_job_rec.net_quantity,p_job_net_quantity);
3877
3878 if p_resulting_job_rec.net_quantity > p_resulting_job_rec.start_quantity then
3879 -- error out,.,,,, --
3880 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3881
3882 l_msg_tokens.delete;
3883 WSM_log_PVT.logMessage(p_module_name=> l_module ,
3884 p_msg_name => 'WSM_NET_QTY_MORE_START_QTY',
3885 p_msg_appl_name => 'WSM',
3886 p_msg_tokens => l_msg_tokens ,
3887 p_stmt_num => l_stmt_num ,
3888 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3889 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3890 p_run_log_level => l_log_level
3891 );
3892 END IF;
3893 raise FND_API.G_EXC_ERROR;
3894 end if;
3895 --Bug 5375741: If user has not supplied net quantity,default it to total net qty of the starting jobs.
3896 --If total net quantity is greater than available qty of the resulting job,default net qty to
3897 --available quantity.
3898 p_resulting_job_rec.net_quantity := nvl(p_resulting_job_rec.net_quantity,p_job_net_quantity);
3899 if p_resulting_job_rec.net_quantity > p_resulting_job_rec.start_quantity then
3900 p_resulting_job_rec.net_quantity := p_resulting_job_rec.start_quantity;
3901 end if;
3902
3903 -- ST : Serial Support Project --
3904 IF p_job_serial_code = 2 AND
3905 (p_resulting_job_rec.net_quantity <> floor(p_resulting_job_rec.net_quantity))
3906 THEN
3907 -- error out...
3908 -- has to be an integer...
3909 IF g_log_level_error >= l_log_level OR
3910 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3911 THEN
3912
3913 l_msg_tokens.delete;
3914 WSM_log_PVT.logMessage(p_module_name => l_module ,
3915 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
3916 p_msg_appl_name => 'WSM' ,
3917 p_msg_tokens => l_msg_tokens ,
3918 p_stmt_num => l_stmt_num ,
3919 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3920 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3921 p_run_log_level => l_log_level
3922 );
3923 END IF;
3924 RAISE FND_API.G_EXC_ERROR;
3925 END IF;
3926 -- ST : Serial Support Project --
3927
3928 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
3929 p_old_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3930 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
3931 p_organization_id => p_resulting_job_rec.organization_id,
3932 p_primary_item_id => p_resulting_job_rec.primary_item_id,
3933 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
3934 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
3935 -- ST : Bug fix 5094555 start
3936 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
3937 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
3938 -- ST : Bug fix 5094555 end
3939 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
3940 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
3941 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
3942 x_return_status => l_return_status,
3943 x_msg_count => l_msg_count,
3944 x_msg_data => l_msg_data
3945 );
3946
3947 IF l_return_status <> G_RET_SUCCESS THEN
3948 if( g_log_level_statement >= l_log_level ) then
3949 l_msg_tokens.delete;
3950 WSM_log_PVT.logMessage(p_module_name => l_module ,
3951 p_msg_text => 'derive_val_compl_subinv returned failure',
3952 p_stmt_num => l_stmt_num ,
3953 p_msg_tokens => l_msg_tokens ,
3954 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3955 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3956 p_run_log_level => l_log_level
3957 );
3958 END IF;
3959 IF l_return_status = G_RET_ERROR THEN
3960 raise FND_API.G_EXC_ERROR;
3961 ELSIF l_return_status = G_RET_UNEXPECTED THEN
3962 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3963 END IF;
3964 END IF;
3965
3966 x_return_status := FND_API.G_RET_STS_SUCCESS;
3967 exception
3968 WHEN FND_API.G_EXC_ERROR THEN
3969
3970 x_return_status := G_RET_ERROR;
3971 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
3972 p_count => x_msg_count ,
3973 p_data => x_msg_data
3974 );
3975
3976 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3977
3978 x_return_status := G_RET_UNEXPECTED;
3979
3980 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
3981 p_count => x_msg_count ,
3982 p_data => x_msg_data
3983 );
3984
3985 WHEN OTHERS THEN
3986
3987 x_return_status := G_RET_UNEXPECTED;
3988
3989 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3990 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3991 THEN
3992 WSM_log_PVT.handle_others( p_module_name => l_module ,
3993 p_stmt_num => l_stmt_num ,
3994 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3995 p_run_log_level => l_log_level
3996 );
3997 END IF;
3998
3999 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
4000 p_count => x_msg_count ,
4001 p_data => x_msg_data
4002 );
4003 END;
4004
4005
4006
4007 -- Default resulting job details from the starting job for appropriate fields depending on txn ( overloaded for split) --
4008 Procedure derive_val_res_job_details( p_txn_type IN NUMBER,
4009 p_txn_org_id IN NUMBER,
4010 p_starting_job_rec IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_REC_TYPE,
4011 p_resulting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
4012 x_return_status OUT NOCOPY VARCHAR2,
4013 x_msg_count OUT NOCOPY NUMBER,
4014 x_msg_data OUT NOCOPY VARCHAR2
4015 ) is
4016
4017 l_return_status varchar2(1);
4018 l_msg_count number;
4019 l_msg_data varchar2(2000);
4020 l_module_name VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_res_job_details';
4021 l_null_char varchar2(10) := FND_API.G_NULL_CHAR;
4022
4023 l_counter number;
4024 l_job_name_tbl t_wip_entity_name_tbl;
4025
4026 l_total_quantity number := 0;
4027 l_coproducts_supply number;
4028 l_start_serial_code NUMBER;
4029 l_res_serial_code NUMBER;
4030
4031 l_start_op_seq_id NUMBER;
4032 l_end_op_seq_id NUMBER;
4033 l_error_code NUMBER;
4034
4035 -- Variable indicating the index of the starting job is also a resulting job.. --
4036 l_start_as_result NUMBER := -1;
4037
4038 --logging variables --
4039 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_res_job_details';
4040 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4041 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4042 l_stmt_num NUMBER := 0;
4043
4044 begin
4045 l_stmt_num := 10;
4046 if( g_log_level_statement >= l_log_level ) then
4047 l_msg_tokens.delete;
4048 WSM_log_PVT.logMessage(p_module_name => l_module ,
4049 p_msg_text => 'Entered derive_val_res_job_details for split' ,
4050 p_stmt_num => l_stmt_num ,
4051 p_msg_tokens => l_msg_tokens,
4052 p_fnd_log_level => g_log_level_statement,
4053 p_run_log_level => l_log_level
4054 );
4055 End if;
4056
4057 if p_txn_type <> WSMPCNST.SPLIT then
4058 -- error out....--
4059 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
4060 l_msg_tokens.delete;
4061 l_msg_tokens(1).TokenName := 'FLD_NAME';
4062 l_msg_tokens(1).TokenValue := 'Transaction Type Not Split';
4063 WSM_log_PVT.logMessage(p_module_name => l_module ,
4064 p_msg_name => 'WSM_INVALID_FIELD',
4065 p_msg_appl_name => 'WSM' ,
4066 p_stmt_num => l_stmt_num ,
4067 p_msg_tokens => l_msg_tokens ,
4068 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4069 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4070 p_run_log_level => l_log_level
4071 );
4072 END IF;
4073 RAISE FND_API.G_EXC_ERROR;
4074 end if;
4075
4076 l_stmt_num := 20;
4077 -- Query up the co-products supply..... --
4078 SELECT decode(coproducts_supply_default, NULL, 2
4079 , coproducts_supply_default)
4080 INTO l_coproducts_supply
4081 FROM wsm_parameters
4082 WHERE organization_id = p_txn_org_id;
4083 l_stmt_num := 25;
4084
4085 -- ST : Serial Support Project --
4086 select nvl(serial_number_control_code,1)
4087 into l_start_serial_code
4088 from mtl_system_items msi
4089 where inventory_item_id = p_starting_job_rec.primary_item_id
4090 and organization_id = p_txn_org_id;
4091 -- ST : Serial Support Project --
4092
4093 l_stmt_num := 30;
4094
4095 if( g_log_level_statement >= l_log_level ) then
4096 l_msg_tokens.delete;
4097 WSM_log_PVT.logMessage(p_module_name => l_module ,
4098 p_msg_text => 'Before loop on resulting jobs' ,
4099 p_stmt_num => l_stmt_num ,
4100 p_msg_tokens => l_msg_tokens,
4101 p_fnd_log_level => g_log_level_statement,
4102 p_run_log_level => l_log_level
4103 );
4104 End if;
4105 -- loop on the resulting records,,,, --
4106 l_counter := p_resulting_jobs_tbl.first;
4107 while l_counter is not null loop
4108
4109 -- Job name / ID start
4110 if (p_resulting_jobs_tbl(l_counter).wip_entity_id is null) and
4111 (p_resulting_jobs_tbl(l_counter).wip_entity_name is null)
4112 then
4113 -- error out..... as both cant be NULL--
4114 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
4115
4116 l_msg_tokens.delete;
4117 l_msg_tokens(1).TokenName := 'FLD_NAME';
4118 l_msg_tokens(1).TokenValue := 'Entity id and name ';
4119 WSM_log_PVT.logMessage(p_module_name => l_module ,
4120 p_msg_name => 'WSM_NULL_FIELD',
4121 p_msg_appl_name => 'WSM' ,
4122 p_msg_tokens => l_msg_tokens ,
4123 p_stmt_num => l_stmt_num ,
4124 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4125 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4126 p_run_log_level => l_log_level
4127 );
4128 END IF;
4129 raise FND_API.G_EXC_ERROR;
4130 end if;
4131
4132 l_stmt_num := 40;
4133 if p_resulting_jobs_tbl(l_counter).wip_entity_name is not null then
4134
4135 if p_resulting_jobs_tbl(l_counter).wip_entity_name = p_starting_job_rec.wip_entity_name then
4136 p_resulting_jobs_tbl(l_counter).wip_entity_id := p_starting_job_rec.wip_entity_id;
4137 else
4138 -- validate the job name .....
4139 l_return_status := FND_API.G_RET_STS_SUCCESS;
4140 l_msg_count := 0;
4141 l_msg_data := null;
4142
4143 wip_entity(p_load_type => 'C',
4144 p_org_id => p_txn_org_id,
4145 p_wip_entity_id => p_resulting_jobs_tbl(l_counter).wip_entity_id,
4146 p_job_name => p_resulting_jobs_tbl(l_counter).wip_entity_name,
4147 x_return_status => l_return_status,
4148 x_error_msg => l_msg_data,
4149 x_error_count => l_msg_count
4150 );
4151 if l_return_status <> G_RET_SUCCESS then
4152 IF l_return_status = G_RET_ERROR THEN
4153 raise FND_API.G_EXC_ERROR;
4154 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4155 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4156 END IF;
4157 end if;
4158
4159 end if;
4160 else -- wip entity id is not null
4161
4162 if p_resulting_jobs_tbl(l_counter).wip_entity_id = p_starting_job_rec.wip_entity_id then
4163 -- copy the job name ....
4164 if( g_log_level_statement >= l_log_level ) then
4165 l_msg_tokens.delete;
4166 WSM_log_PVT.logMessage(p_module_name => l_module ,
4167 p_msg_text => 'Copying job name' ,
4168 p_stmt_num => l_stmt_num ,
4169 p_msg_tokens => l_msg_tokens,
4170 p_fnd_log_level => g_log_level_statement,
4171 p_run_log_level => l_log_level
4172 );
4173 End if;
4174
4175 p_resulting_jobs_tbl(l_counter).wip_entity_name := p_starting_job_rec.wip_entity_name;
4176 else
4177 -- error out....
4178 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4179 l_msg_tokens.delete;
4180 WSM_log_PVT.logMessage(p_module_name=> l_module ,
4181 p_msg_name => 'WSM_SJ_AS_RJ',
4182 p_msg_appl_name => 'WSM',
4183 p_msg_tokens => l_msg_tokens ,
4184 p_stmt_num => l_stmt_num ,
4185 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4186 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4187 p_run_log_level => l_log_level
4188 );
4189 END IF;
4190 RAISE FND_API.G_EXC_ERROR;
4191 END IF;
4192 END IF;
4193
4194 l_stmt_num := 50;
4195 IF p_resulting_jobs_tbl(l_counter).wip_entity_id = p_starting_job_rec.wip_entity_id THEN
4196 -- time to assign the flag.....
4197 IF l_start_as_result = -1 THEN
4198
4199 if( g_log_level_statement >= l_log_level ) then
4200 l_msg_tokens.delete;
4201 WSM_log_PVT.logMessage(p_module_name => l_module ,
4202 p_msg_text => 'Assign l_start_as_result=1' ,
4203 p_stmt_num => l_stmt_num ,
4204 p_msg_tokens => l_msg_tokens,
4205 p_fnd_log_level => g_log_level_statement,
4206 p_run_log_level => l_log_level
4207 );
4208 End if;
4209
4210 l_start_as_result := 1;
4211 ELSE
4212 -- error out,,,,,
4213 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4214
4215 l_msg_tokens.delete;
4216 WSM_log_PVT.logMessage(p_module_name=> l_module ,
4217 p_msg_name => 'WSM_SJ_AS_RJ_ONCE',
4218 p_msg_appl_name => 'WSM',
4219 p_msg_tokens => l_msg_tokens ,
4220 p_stmt_num => l_stmt_num ,
4221 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4222 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4223 p_run_log_level => l_log_level
4224 );
4225 END IF;
4226 raise FND_API.G_EXC_ERROR;
4227 END IF;
4228 END IF;
4229
4230 l_stmt_num := 60;
4231 -- check for duplicate job name
4232 If l_job_name_tbl.exists(p_resulting_jobs_tbl(l_counter).wip_entity_name) THEN
4233 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4234
4235 l_msg_tokens.delete;
4236 WSM_log_PVT.logMessage(p_module_name=> l_module ,
4237 p_msg_name => 'WSM_DUPLICATE_RJ_NAME',
4238 p_msg_appl_name => 'WSM',
4239 p_msg_tokens => l_msg_tokens ,
4240 p_stmt_num => l_stmt_num ,
4241 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4242 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4243 p_run_log_level => l_log_level
4244 );
4245 END IF;
4246 raise FND_API.G_EXC_ERROR;
4247 else
4248 l_job_name_tbl(p_resulting_jobs_tbl(l_counter).wip_entity_name) := 1;
4249 end if;
4250 -- Job name / ID end
4251
4252 -- ST : Fix for bug 5131059 : description....... --
4253 p_resulting_jobs_tbl(l_counter).description := nvl(p_resulting_jobs_tbl(l_counter).description,p_starting_job_rec.description);
4254 if p_resulting_jobs_tbl(l_counter).description = l_null_char then
4255 p_resulting_jobs_tbl(l_counter).description := null;
4256 end if;
4257
4258 -- Quantity start--
4259 l_stmt_num := 70;
4260 if (p_resulting_jobs_tbl(l_counter).start_quantity is null) or
4261 (p_resulting_jobs_tbl(l_counter).start_quantity <= 0)
4262 then
4263 -- error out....--
4264 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
4265 l_msg_tokens.delete;
4266 l_msg_tokens(1).TokenName := 'FLD_NAME';
4267 l_msg_tokens(1).TokenValue := 'start_quantity';
4268 WSM_log_PVT.logMessage(p_module_name => l_module ,
4269 p_msg_name => 'WSM_NULL_FIELD',
4270 p_msg_appl_name => 'WSM' ,
4271 p_stmt_num => l_stmt_num ,
4272 p_msg_tokens => l_msg_tokens ,
4273 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4274 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4275 p_run_log_level => l_log_level
4276 );
4277 END IF;
4278 raise FND_API.G_EXC_ERROR;
4279 end if;
4280
4281 -- ST : Serial Support Project --
4282 IF (l_start_serial_code = 2) and
4283 (p_resulting_jobs_tbl(l_counter).start_quantity <> floor(p_resulting_jobs_tbl(l_counter).start_quantity))
4284 THEN
4285 -- error out...
4286 IF g_log_level_error >= l_log_level OR
4287 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4288 THEN
4289
4290 l_msg_tokens.delete;
4291 WSM_log_PVT.logMessage(p_module_name => l_module ,
4292 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
4293 p_msg_appl_name => 'WSM' ,
4294 p_msg_tokens => l_msg_tokens ,
4295 p_stmt_num => l_stmt_num ,
4296 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4297 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4298 p_run_log_level => l_log_level
4299 );
4300 END IF;
4301 RAISE FND_API.G_EXC_ERROR;
4302 END IF;
4303 -- ST : Serial Support Project --
4304
4305 l_stmt_num := 80;
4306 if (l_total_quantity + p_resulting_jobs_tbl(l_counter).start_quantity) > p_starting_job_rec.quantity_available then
4307 -- error out..... --
4308 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4309
4310 l_msg_tokens.delete;
4311 WSM_log_PVT.logMessage(p_module_name => l_module ,
4312 p_msg_name => 'WSM_SUM_RESULT_START_MORE',
4313 p_msg_appl_name => 'WSM' ,
4314 p_msg_tokens => l_msg_tokens ,
4315 p_stmt_num => l_stmt_num ,
4316 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4317 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4318 p_run_log_level => l_log_level
4319 );
4320 END IF;
4321 raise FND_API.G_EXC_ERROR;
4322 end if;
4323
4324 l_stmt_num := 90;
4325 l_total_quantity := l_total_quantity + p_resulting_jobs_tbl(l_counter).start_quantity;
4326
4327 if p_resulting_jobs_tbl(l_counter).net_quantity is null then
4328 --use the !!!logic!!! --
4329 p_resulting_jobs_tbl(l_counter).net_quantity := round(( (p_resulting_jobs_tbl(l_counter).start_quantity/p_starting_job_rec.quantity_available)*p_starting_job_rec.net_quantity ),6);
4330
4331 if p_resulting_jobs_tbl(l_counter).net_quantity > p_resulting_jobs_tbl(l_counter).start_quantity then
4332 p_resulting_jobs_tbl(l_counter).net_quantity := p_resulting_jobs_tbl(l_counter).start_quantity;
4333 end if;
4334
4335 -- ST : Serial Support Project --
4336 IF l_start_serial_code = 2 THEN
4337 p_resulting_jobs_tbl(l_counter).net_quantity := floor(p_resulting_jobs_tbl(l_counter).net_quantity);
4338 END IF;
4339 -- ST : Serial Support Project --
4340
4341 else
4342 if -- (p_resulting_jobs_tbl(l_counter).net_quantity = l_null_num) or
4343 (p_resulting_jobs_tbl(l_counter).net_quantity < 0 ) or
4344 (p_resulting_jobs_tbl(l_counter).net_quantity > p_resulting_jobs_tbl(l_counter).start_quantity)
4345 then
4346 -- error out... --
4347 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
4348
4349 l_msg_tokens.delete;
4350 l_msg_tokens(1).TokenName := 'FLD_NAME';
4351 l_msg_tokens(1).TokenValue := 'net_quantity';
4352 WSM_log_PVT.logMessage(p_module_name => l_module ,
4353 p_msg_name => 'WSM_INVALID_FIELD',
4354 p_msg_appl_name => 'WSM' ,
4355 p_msg_tokens => l_msg_tokens ,
4356 p_stmt_num => l_stmt_num ,
4357 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4358 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4359 p_run_log_level => l_log_level
4360 );
4361 END IF;
4362 RAISE FND_API.G_EXC_ERROR;
4363 end if;
4364
4365 -- ST : Serial Support Project --
4366 -- ST : Fix for bug 5199646 -- replaced start_quantity with net_quantity in the belwo check --
4367 -- Typo error --
4368 IF (l_start_serial_code = 2) and
4369 (p_resulting_jobs_tbl(l_counter).net_quantity <> floor(p_resulting_jobs_tbl(l_counter).net_quantity))
4370 THEN
4371 -- error out...
4372 IF g_log_level_error >= l_log_level OR
4373 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4374 THEN
4375
4376 l_msg_tokens.delete;
4377 WSM_log_PVT.logMessage(p_module_name => l_module ,
4378 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
4379 p_msg_appl_name => 'WSM' ,
4380 p_msg_tokens => l_msg_tokens ,
4381 p_stmt_num => l_stmt_num ,
4382 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4383 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4384 p_run_log_level => l_log_level
4385 );
4386 END IF;
4387 RAISE FND_API.G_EXC_ERROR;
4388 END IF;
4389 -- ST : Serial Support Project --
4390
4391 end if;
4392 ---Quantity end --
4393
4394 -- Co products supply start --
4395 if p_resulting_jobs_tbl(l_counter).wip_entity_name = p_starting_job_rec.wip_entity_name then
4396
4397 if p_resulting_jobs_tbl(l_counter).coproducts_supply is null then
4398 p_resulting_jobs_tbl(l_counter).coproducts_supply := p_starting_job_rec.coproducts_supply;
4399 end if;
4400
4401 else -- new job.....---
4402 if p_resulting_jobs_tbl(l_counter).coproducts_supply is null then
4403 p_resulting_jobs_tbl(l_counter).coproducts_supply := l_coproducts_supply;
4404 end if;
4405 end if;
4406
4407 if NVL(p_resulting_jobs_tbl(l_counter).coproducts_supply,0) not in(1,2) then
4408 --error out.... --
4409 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4410
4411 l_msg_tokens.delete;
4412 l_msg_tokens(1).TokenName := 'FLD_NAME';
4413 l_msg_tokens(1).TokenName := 'CoProducts Supply';
4414
4415 WSM_log_PVT.logMessage(p_module_name => l_module ,
4416 p_msg_name => 'WSM_INVALID_FIELD' ,
4417 p_msg_appl_name => 'WSM' ,
4418 p_msg_tokens => l_msg_tokens ,
4419 p_stmt_num => l_stmt_num ,
4420 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4421 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4422 p_run_log_level => l_log_level
4423 );
4424 END IF;
4425 raise FND_API.G_EXC_ERROR;
4426 end if;
4427 --- Co products supply end --
4428
4429 -- check the split has update assy flag.........--
4430 l_stmt_num := 100;
4431 p_resulting_jobs_tbl(l_counter).split_has_update_assy := nvl(p_resulting_jobs_tbl(l_counter).split_has_update_assy,0);
4432 if p_resulting_jobs_tbl(l_counter).split_has_update_assy not in (0,1) then
4433 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4434 l_msg_tokens.delete;
4435 l_msg_tokens(1).TokenName := 'FLD_NAME';
4436 l_msg_tokens(1).TokenName := 'Split_has_update_assembly';
4437
4438 WSM_log_PVT.logMessage(p_module_name => l_module ,
4439 p_msg_name => 'WSM_INVALID_FIELD' ,
4440 p_msg_appl_name => 'WSM' ,
4441 p_msg_tokens => l_msg_tokens ,
4442 p_stmt_num => l_stmt_num ,
4443 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4444 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4445 p_run_log_level => l_log_level
4446 );
4447 END IF;
4448 raise FND_API.G_EXC_ERROR;
4449 end if;
4450 -- check the split has update assy flag....--
4451
4452 -- Now get the common fields..... --
4453 p_resulting_jobs_tbl(l_counter).status_type := p_starting_job_rec.status_type;
4454 p_resulting_jobs_tbl(l_counter).class_code := p_starting_job_rec.class_code;
4455 p_resulting_jobs_tbl(l_counter).job_type := p_starting_job_rec.job_type;
4456 p_resulting_jobs_tbl(l_counter).organization_id := p_starting_job_rec.organization_id;
4457 p_resulting_jobs_tbl(l_counter).organization_code := p_starting_job_rec.organization_code;
4458 p_resulting_jobs_tbl(l_counter).wip_supply_type := p_starting_job_rec.wip_supply_type;
4459
4460 p_resulting_jobs_tbl(l_counter).scheduled_start_date := p_starting_job_rec.scheduled_start_date;
4461 p_resulting_jobs_tbl(l_counter).scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
4462
4463 -- Now fork based on split has update assy flag.
4464 l_stmt_num := 110;
4465 if p_resulting_jobs_tbl(l_counter).split_has_update_assy = 0 then
4466 if( g_log_level_statement >= l_log_level ) then
4467 l_msg_tokens.delete;
4468 WSM_log_PVT.logMessage(p_module_name => l_module ,
4469 p_msg_text => 'no update of assembly ' ,
4470 p_stmt_num => l_stmt_num ,
4471 p_msg_tokens => l_msg_tokens,
4472 p_fnd_log_level => g_log_level_statement,
4473 p_run_log_level => l_log_level
4474 );
4475 End if;
4476 -- Copy all colums except for start qty, net qty and completion subinv and coproducts supply --
4477
4478 -- Primary info .....
4479 p_resulting_jobs_tbl(l_counter).item_name := p_starting_job_rec.item_name;
4480 p_resulting_jobs_tbl(l_counter).primary_item_id := p_starting_job_rec.primary_item_id;
4481 p_resulting_jobs_tbl(l_counter).class_code := p_starting_job_rec.class_code;
4482
4483 -- BOM details ....
4484 p_resulting_jobs_tbl(l_counter).bom_reference_id := p_starting_job_rec.bom_reference_id;
4485 p_resulting_jobs_tbl(l_counter).common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
4486 p_resulting_jobs_tbl(l_counter).bom_revision := p_starting_job_rec.bom_revision;
4487 p_resulting_jobs_tbl(l_counter).bom_revision_date := p_starting_job_rec.bom_revision_date;
4488 p_resulting_jobs_tbl(l_counter).alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
4489
4490 -- Routing details
4491 p_resulting_jobs_tbl(l_counter).routing_reference_id := p_starting_job_rec.routing_reference_id;
4492 p_resulting_jobs_tbl(l_counter).common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
4493 p_resulting_jobs_tbl(l_counter).routing_revision := p_starting_job_rec.routing_revision;
4494 p_resulting_jobs_tbl(l_counter).routing_revision_date := p_starting_job_rec.routing_revision_date;
4495 p_resulting_jobs_tbl(l_counter).alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
4496
4497 -- Starting operation details....
4498 p_resulting_jobs_tbl(l_counter).starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
4499 p_resulting_jobs_tbl(l_counter).starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
4500 p_resulting_jobs_tbl(l_counter).starting_operation_code := p_starting_job_rec.operation_code;
4501 p_resulting_jobs_tbl(l_counter).starting_std_op_id := p_starting_job_rec.standard_operation_id;
4502 p_resulting_jobs_tbl(l_counter).starting_operation_seq_id := p_starting_job_rec.operation_seq_id;
4503
4504 p_resulting_jobs_tbl(l_counter).department_id := p_starting_job_rec.department_id;
4505 p_resulting_jobs_tbl(l_counter).department_code := p_starting_job_rec.department_code;
4506 p_resulting_jobs_tbl(l_counter).operation_description := p_starting_job_rec.operation_description;
4507
4508
4509 else
4510 -- Update of assembly .....
4511 if( g_log_level_statement >= l_log_level ) then
4512 l_msg_tokens.delete;
4513 WSM_log_PVT.logMessage(p_module_name => l_module ,
4514 p_msg_text => 'There is update of assembly ' ,
4515 p_stmt_num => l_stmt_num ,
4516 p_msg_tokens => l_msg_tokens,
4517 p_fnd_log_level => g_log_level_statement,
4518 p_run_log_level => l_log_level
4519 );
4520 End if;
4521
4522 derive_val_primary_item ( p_txn_org_id => p_resulting_jobs_tbl(l_counter).organization_id,
4523 p_old_item_id => p_starting_job_rec.primary_item_id,
4524 p_new_item_name => p_resulting_jobs_tbl(l_counter).item_name,
4525 p_new_item_id => p_resulting_jobs_tbl(l_counter).primary_item_id,
4526 x_return_status => l_return_status,
4527 x_msg_count => l_msg_count,
4528 x_msg_data => l_msg_data
4529 );
4530 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
4531 if( g_log_level_statement >= l_log_level ) then
4532
4533 l_msg_tokens.delete;
4534 WSM_log_PVT.logMessage(p_module_name => l_module ,
4535 p_msg_text => 'derive_val_primary_item returned failure',
4536 p_stmt_num => l_stmt_num ,
4537 p_msg_tokens => l_msg_tokens,
4538 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4539 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4540 p_run_log_level => l_log_level
4541 );
4542 END IF;
4543 IF l_return_status = G_RET_ERROR THEN
4544 raise FND_API.G_EXC_ERROR;
4545 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4546 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4547 END IF;
4548 END IF ;
4549
4550 -- ST : Serial Support Project --
4551 select nvl(serial_number_control_code,1)
4552 into l_res_serial_code
4553 from mtl_system_items msi
4554 where inventory_item_id = p_resulting_jobs_tbl(l_counter).primary_item_id
4555 and organization_id = p_txn_org_id;
4556
4557 IF l_res_serial_code <> l_start_serial_code then
4558 -- error out...
4559 -- cannot do a update from non-serial to serial or vice versa....
4560
4561 IF g_log_level_error >= l_log_level OR
4562 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4563 THEN
4564
4565 l_msg_tokens.delete;
4566 WSM_log_PVT.logMessage(p_module_name => l_module ,
4567 p_msg_name => 'WSM_INVALID_UPD_ASSY' ,
4568 p_msg_appl_name => 'WSM' ,
4569 p_msg_tokens => l_msg_tokens ,
4570 p_stmt_num => l_stmt_num ,
4571 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4572 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4573 p_run_log_level => l_log_level
4574 );
4575 END IF;
4576 RAISE FND_API.G_EXC_ERROR;
4577 END IF;
4578 -- ST : Serial Support Project --
4579
4580 l_stmt_num := 120;
4581 -- call derive_val_bom_info
4582 derive_val_bom_info ( p_txn_org_id => p_resulting_jobs_tbl(l_counter).organization_id,
4583 p_sj_job_type => p_starting_job_rec.job_type,
4584 p_rj_primary_item_id => p_resulting_jobs_tbl(l_counter).primary_item_id,
4585 p_rj_bom_reference_item => p_resulting_jobs_tbl(l_counter).bom_reference_item,
4586 p_rj_bom_reference_id => p_resulting_jobs_tbl(l_counter).bom_reference_id,
4587 p_rj_alternate_bom_desig => p_resulting_jobs_tbl(l_counter).alternate_bom_designator,
4588 p_rj_common_bom_seq_id => p_resulting_jobs_tbl(l_counter).common_bom_sequence_id,
4589 p_rj_bom_revision => p_resulting_jobs_tbl(l_counter).bom_revision,
4590 p_rj_bom_revision_date => p_resulting_jobs_tbl(l_counter).bom_revision_date,
4591 x_return_status => l_return_status,
4592 x_msg_count => l_msg_count,
4593 x_msg_data => l_msg_data
4594 );
4595
4596 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
4597 if( g_log_level_statement >= l_log_level ) then
4598
4599 l_msg_tokens.delete;
4600 WSM_log_PVT.logMessage(p_module_name => l_module ,
4601 p_msg_text => 'derive_val_bom_info returned failure',
4602 p_stmt_num => l_stmt_num ,
4603 p_msg_tokens => l_msg_tokens,
4604 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4605 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4606 p_run_log_level => l_log_level
4607 );
4608 END IF;
4609 IF l_return_status = G_RET_ERROR THEN
4610 raise FND_API.G_EXC_ERROR;
4611 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4612 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4613 END IF;
4614 end if ;
4615
4616 l_stmt_num := 130;
4617
4618 -- call derive_val_routing_info
4619 derive_val_routing_info ( p_txn_org_id => p_resulting_jobs_tbl(l_counter).organization_id,
4620 p_sj_job_type => p_starting_job_rec.job_type,
4621 p_rj_primary_item_id => p_resulting_jobs_tbl(l_counter).primary_item_id,
4622 p_rj_rtg_reference_item => p_resulting_jobs_tbl(l_counter).routing_reference_item,
4623 p_rj_rtg_reference_id => p_resulting_jobs_tbl(l_counter).routing_reference_id,
4624 p_rj_alternate_rtg_desig => p_resulting_jobs_tbl(l_counter).alternate_routing_designator,
4625 p_rj_common_rtg_seq_id => p_resulting_jobs_tbl(l_counter).common_routing_sequence_id,
4626 p_rj_rtg_revision => p_resulting_jobs_tbl(l_counter).routing_revision,
4627 p_rj_rtg_revision_date => p_resulting_jobs_tbl(l_counter).routing_revision_date,
4628 x_return_status => l_return_status,
4629 x_msg_count => l_msg_count,
4630 x_msg_data => l_msg_data
4631 );
4632
4633 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
4634 if( g_log_level_statement >= l_log_level ) then
4635
4636 l_msg_tokens.delete;
4637 WSM_log_PVT.logMessage(p_module_name => l_module ,
4638 p_msg_text => 'derive_val_routing_info returned failure',
4639 p_stmt_num => l_stmt_num ,
4640 p_msg_tokens => l_msg_tokens,
4641 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4642 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4643 p_run_log_level => l_log_level
4644 );
4645 END IF;
4646 IF l_return_status = G_RET_ERROR THEN
4647 raise FND_API.G_EXC_ERROR;
4648 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4649 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4650 END IF;
4651 end if ;
4652
4653 l_stmt_num := 135;
4654 -- call WSMPUTIL.find_routing_start to validate first operation in N/W.
4655 -- added for bug 5386675.
4656
4657 wsmputil.find_routing_start (p_routing_sequence_id => p_resulting_jobs_tbl(l_counter).common_routing_sequence_id,
4658 p_routing_rev_date => p_resulting_jobs_tbl(l_counter).routing_revision_date,
4659 start_op_seq_id => l_start_op_seq_id,
4660 x_err_code => l_error_code,
4661 x_err_msg => l_msg_data);
4662
4663 IF l_error_code < 0 THEN
4664 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
4665 l_msg_tokens.delete;
4666 WSM_log_PVT.logMessage(p_module_name => l_module ,
4667 p_msg_text => l_msg_data,
4668 p_stmt_num => l_stmt_num ,
4669 p_msg_tokens => l_msg_tokens,
4670 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4671 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4672 p_run_log_level => l_log_level
4673 );
4674 END IF;
4675
4676 raise FND_API.G_EXC_ERROR;
4677
4678 end if;
4679
4680 -- call WSMPUTIL.find_routing_end to validate last operation in N/W.
4681 -- added for bug 5386675.
4682
4683 wsmputil.find_routing_end (p_routing_sequence_id => p_resulting_jobs_tbl(l_counter).common_routing_sequence_id,
4684 p_routing_rev_date => p_resulting_jobs_tbl(l_counter).routing_revision_date,
4685 end_op_seq_id => l_end_op_seq_id,
4686 x_err_code => l_error_code,
4687 x_err_msg => l_msg_data);
4688
4689 IF l_error_code < 0 THEN
4690 IF( G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) ) then
4691 l_msg_tokens.delete;
4692 WSM_log_PVT.logMessage(p_module_name => l_module ,
4693 p_msg_text => l_msg_data,
4694 p_stmt_num => l_stmt_num ,
4695 p_msg_tokens => l_msg_tokens,
4696 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4697 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4698 p_run_log_level => l_log_level
4699 );
4700 END IF;
4701
4702 raise FND_API.G_EXC_ERROR;
4703
4704 end if;
4705
4706 l_stmt_num := 140;
4707 derive_val_starting_op ( p_txn_org_id => p_resulting_jobs_tbl(l_counter).organization_id,
4708 p_curr_op_seq_id => p_starting_job_rec.operation_seq_id,
4709 p_curr_op_code => p_starting_job_rec.operation_code,
4710 p_curr_std_op_id => p_starting_job_rec.standard_operation_id,
4711 p_curr_intra_op_step => p_starting_job_rec.intraoperation_step,
4712 p_new_comm_rtg_seq_id => p_resulting_jobs_tbl(l_counter).common_routing_sequence_id,
4713 p_new_rtg_rev_date => p_resulting_jobs_tbl(l_counter).routing_revision_date ,
4714 p_new_op_seq_num => p_resulting_jobs_tbl(l_counter).starting_operation_seq_num,
4715 p_new_op_seq_id => p_resulting_jobs_tbl(l_counter).starting_operation_seq_id,
4716 p_new_std_op_id => p_resulting_jobs_tbl(l_counter).starting_std_op_id,
4717 p_new_op_seq_code => p_resulting_jobs_tbl(l_counter).starting_operation_code,
4718 p_new_dept_id => p_resulting_jobs_tbl(l_counter).department_id,
4719 x_return_status => l_return_status,
4720 x_msg_count => l_msg_count,
4721 x_msg_data => l_msg_data
4722 );
4723 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
4724 if( g_log_level_statement >= l_log_level ) then
4725
4726 l_msg_tokens.delete;
4727 WSM_log_PVT.logMessage(p_module_name => l_module ,
4728 p_msg_text => 'derive_val_starting_op returned failure',
4729 p_stmt_num => l_stmt_num ,
4730 p_msg_tokens => l_msg_tokens,
4731 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4732 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4733 p_run_log_level => l_log_level
4734 );
4735 END IF;
4736 IF l_return_status = G_RET_ERROR THEN
4737 raise FND_API.G_EXC_ERROR;
4738 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4739 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4740 END IF;
4741 end if ;
4742
4743 -- Always overwrite the starting intraop step for Split and Update Assy txn..
4744 p_resulting_jobs_tbl(l_counter).starting_intraoperation_step := WIP_CONSTANTS.QUEUE;
4745
4746 end if; -- End Check on Split and Update Flag
4747
4748 l_stmt_num := 150;
4749
4750 -- Completion subinv derivation....
4751 derive_val_compl_subinv( p_job_type => p_resulting_jobs_tbl(l_counter).job_type,
4752 p_old_rtg_seq_id => p_starting_job_rec.common_routing_sequence_id,
4753 p_new_rtg_seq_id => p_resulting_jobs_tbl(l_counter).common_routing_sequence_id,
4754 p_organization_id => p_resulting_jobs_tbl(l_counter).organization_id,
4755 p_primary_item_id => p_resulting_jobs_tbl(l_counter).primary_item_id,
4756 p_sj_completion_subinventory => p_starting_job_rec.completion_subinventory,
4757 p_sj_completion_locator_id => p_starting_job_rec.completion_locator_id,
4758 -- ST : Bug fix 5094555 start
4759 p_rj_alt_rtg_designator => p_resulting_jobs_tbl(l_counter).alternate_routing_designator,
4760 p_rj_rtg_reference_item_id => p_resulting_jobs_tbl(l_counter).routing_reference_id,
4761 -- ST : Bug fix 5094555 end
4762 p_rj_completion_subinventory => p_resulting_jobs_tbl(l_counter).completion_subinventory,
4763 p_rj_completion_locator_id => p_resulting_jobs_tbl(l_counter).completion_locator_id,
4764 p_rj_completion_locator => p_resulting_jobs_tbl(l_counter).completion_locator,
4765 x_return_status => l_return_status,
4766 x_msg_count => l_msg_count,
4767 x_msg_data => l_msg_data
4768 );
4769
4770 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
4771 if( g_log_level_statement >= l_log_level ) then
4772
4773 l_msg_tokens.delete;
4774 WSM_log_PVT.logMessage(p_module_name => l_module ,
4775 p_msg_text => 'derive_val_compl_subinv returned failure',
4776 p_stmt_num => l_stmt_num ,
4777 p_msg_tokens => l_msg_tokens,
4778 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4779 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4780 p_run_log_level => l_log_level
4781 );
4782 END IF;
4783 IF l_return_status = G_RET_ERROR THEN
4784 raise FND_API.G_EXC_ERROR;
4785 ELSIF l_return_status = G_RET_UNEXPECTED THEN
4786 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4787 END IF;
4788 end if ;
4789 l_counter := p_resulting_jobs_tbl.next(l_counter);
4790
4791 end loop;
4792
4793 /* Bugfix 5438722 Validate that there isn't just one resulting job with all the available quantity */
4794
4795 if (l_total_quantity = p_starting_job_rec.quantity_available) and (p_resulting_jobs_tbl.count = 1) then
4796 -- error out...
4797 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4798 l_msg_tokens.delete;
4799 WSM_log_PVT.logMessage(p_module_name => l_module ,
4800 p_msg_name => 'WSM_ONE_RES_JOB_HAS_FULL_QTY',
4801 p_msg_appl_name => 'WSM',
4802 p_msg_tokens => l_msg_tokens ,
4803 p_stmt_num => l_stmt_num ,
4804 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4805 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4806 p_run_log_level => l_log_level
4807 );
4808 END IF;
4809 RAISE FND_API.G_EXC_ERROR;
4810 end if;
4811
4812 /* End Bugfix 5438722 */
4813
4814 l_stmt_num := 165;
4815 -- check if all available qty utilised.......
4816 if l_total_quantity < p_starting_job_rec.quantity_available then
4817 -- Either create.... a new record or modify the parent if it exists.....
4818 if l_start_as_result = -1 then
4819 if p_resulting_jobs_tbl.count < 1 then
4820 -- error out...
4821 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4822 l_msg_tokens.delete;
4823 WSM_log_PVT.logMessage(p_module_name => l_module ,
4824 p_msg_name => 'WSM_RESULT_LOT_REQUIRED',
4825 p_msg_appl_name => 'WSM',
4826 p_msg_tokens => l_msg_tokens ,
4827 p_stmt_num => l_stmt_num ,
4828 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4829 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4830 p_run_log_level => l_log_level
4831 );
4832 END IF;
4833 RAISE FND_API.G_EXC_ERROR;
4834 end if;
4835
4836 l_counter := p_resulting_jobs_tbl.last + 1;
4837 l_stmt_num := 170;
4838 -- Indicates that parent record is not a resulting record.... create one for it....
4839 -- Primary info .....
4840 p_resulting_jobs_tbl(l_counter).wip_entity_id := p_starting_job_rec.wip_entity_id;
4841 p_resulting_jobs_tbl(l_counter).wip_entity_name := p_starting_job_rec.wip_entity_name;
4842 p_resulting_jobs_tbl(l_counter).item_name := p_starting_job_rec.item_name;
4843 p_resulting_jobs_tbl(l_counter).primary_item_id := p_starting_job_rec.primary_item_id;
4844 p_resulting_jobs_tbl(l_counter).class_code := p_starting_job_rec.class_code;
4845 p_resulting_jobs_tbl(l_counter).job_type := p_starting_job_rec.job_type;
4846 p_resulting_jobs_tbl(l_counter).organization_id := p_starting_job_rec.organization_id;
4847 p_resulting_jobs_tbl(l_counter).organization_code := p_starting_job_rec.organization_code;
4848 p_resulting_jobs_tbl(l_counter).description := p_starting_job_rec.description;
4849
4850 -- BOM details ....
4851 p_resulting_jobs_tbl(l_counter).bom_reference_id := p_starting_job_rec.bom_reference_id;
4852 p_resulting_jobs_tbl(l_counter).common_bom_sequence_id := p_starting_job_rec.common_bill_sequence_id;
4853 p_resulting_jobs_tbl(l_counter).bom_revision := p_starting_job_rec.bom_revision;
4854 p_resulting_jobs_tbl(l_counter).bom_revision_date := p_starting_job_rec.bom_revision_date;
4855 p_resulting_jobs_tbl(l_counter).alternate_bom_designator := p_starting_job_rec.alternate_bom_designator;
4856
4857 -- Routing details
4858 p_resulting_jobs_tbl(l_counter).routing_reference_id := p_starting_job_rec.routing_reference_id;
4859 p_resulting_jobs_tbl(l_counter).common_routing_sequence_id := p_starting_job_rec.common_routing_sequence_id;
4860 p_resulting_jobs_tbl(l_counter).routing_revision := p_starting_job_rec.routing_revision;
4861 p_resulting_jobs_tbl(l_counter).routing_revision_date := p_starting_job_rec.routing_revision_date;
4862 p_resulting_jobs_tbl(l_counter).alternate_routing_designator := p_starting_job_rec.alternate_routing_designator;
4863
4864 -- Completion sub inv details.... Non Updatable....
4865 p_resulting_jobs_tbl(l_counter).completion_subinventory := p_starting_job_rec.completion_subinventory;
4866 p_resulting_jobs_tbl(l_counter).completion_locator_id := p_starting_job_rec.completion_locator_id;
4867
4868 -- Starting operation details....
4869 p_resulting_jobs_tbl(l_counter).starting_operation_seq_num := p_starting_job_rec.operation_seq_num;
4870 p_resulting_jobs_tbl(l_counter).starting_intraoperation_step := p_starting_job_rec.intraoperation_step;
4871 p_resulting_jobs_tbl(l_counter).starting_operation_code := p_starting_job_rec.operation_code;
4872 p_resulting_jobs_tbl(l_counter).starting_std_op_id := p_starting_job_rec.standard_operation_id;
4873 p_resulting_jobs_tbl(l_counter).department_id := p_starting_job_rec.department_id;
4874 p_resulting_jobs_tbl(l_counter).department_code := p_starting_job_rec.department_code;
4875 p_resulting_jobs_tbl(l_counter).operation_description := p_starting_job_rec.operation_description;
4876
4877 -- Date info....
4878 p_resulting_jobs_tbl(l_counter).scheduled_start_date := p_starting_job_rec.scheduled_start_date;
4879 p_resulting_jobs_tbl(l_counter).scheduled_completion_date := p_starting_job_rec.scheduled_completion_date;
4880
4881 -- Other parameters....
4882 p_resulting_jobs_tbl(l_counter).coproducts_supply := p_starting_job_rec.coproducts_supply;
4883
4884 -- Quantity info
4885 p_resulting_jobs_tbl(l_counter).start_quantity := ( p_starting_job_rec.quantity_available - l_total_quantity );
4886
4887 -- logic to derive the net quantity....
4888 p_resulting_jobs_tbl(l_counter).net_quantity := round(( (p_resulting_jobs_tbl(l_counter).start_quantity/p_starting_job_rec.quantity_available)*p_starting_job_rec.net_quantity ),6);
4889
4890 if p_resulting_jobs_tbl(l_counter).net_quantity > p_resulting_jobs_tbl(l_counter).start_quantity then
4891 p_resulting_jobs_tbl(l_counter).net_quantity := p_resulting_jobs_tbl(l_counter).start_quantity;
4892 end if;
4893
4894 -- ST : Serial Support Project --
4895 IF l_start_serial_code = 2 THEN
4896 p_resulting_jobs_tbl(l_counter).net_quantity := floor(p_resulting_jobs_tbl(l_counter).net_quantity);
4897 END IF;
4898 -- ST : Serial Support Project --
4899
4900 -- ST : Fix for bug 5211424 : default
4901 p_resulting_jobs_tbl(l_counter).split_has_update_assy := 0;
4902 ELSE
4903 -- parent record is also a part of the resulting jobs bunch....
4904 IF p_resulting_jobs_tbl.count <= 1 THEN
4905 -- error out...
4906 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4907 l_msg_tokens.delete;
4908 WSM_log_PVT.logMessage(p_module_name => l_module ,
4909 p_msg_name => 'WSM_SJ_AS_RJ_ONCE',
4910 p_msg_appl_name => 'WSM',
4911 p_msg_tokens => l_msg_tokens ,
4912 p_stmt_num => l_stmt_num ,
4913 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4914 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4915 p_run_log_level => l_log_level
4916 );
4917 END IF;
4918 RAISE FND_API.G_EXC_ERROR;
4919 END IF;
4920
4921 p_resulting_jobs_tbl(l_start_as_result).start_quantity := p_resulting_jobs_tbl(l_start_as_result).start_quantity + ( p_starting_job_rec.quantity_available - l_total_quantity );
4922
4923 -- logic to derive the net quantity....
4924 p_resulting_jobs_tbl(l_start_as_result).net_quantity := round(( (p_resulting_jobs_tbl(l_start_as_result).start_quantity/p_starting_job_rec.quantity_available)*p_starting_job_rec.net_quantity ),6);
4925
4926 IF p_resulting_jobs_tbl(l_start_as_result).net_quantity > p_resulting_jobs_tbl(l_start_as_result).start_quantity then
4927 p_resulting_jobs_tbl(l_start_as_result).net_quantity := p_resulting_jobs_tbl(l_start_as_result).start_quantity;
4928 END IF;
4929
4930 -- ST : Serial Support Project --
4931 IF l_start_serial_code = 2 THEN
4932 p_resulting_jobs_tbl(l_counter).net_quantity := floor(p_resulting_jobs_tbl(l_counter).net_quantity);
4933 END IF;
4934 -- ST : Serial Support Project --
4935 END IF;
4936 END IF;
4937 x_return_status := FND_API.G_RET_STS_SUCCESS;
4938
4939 exception
4940
4941 WHEN FND_API.G_EXC_ERROR THEN
4942
4943 x_return_status := G_RET_ERROR;
4944 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
4945 p_count => x_msg_count ,
4946 p_data => x_msg_data
4947 );
4948
4949 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4950
4951 x_return_status := G_RET_UNEXPECTED;
4952
4953 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
4954 p_count => x_msg_count ,
4955 p_data => x_msg_data
4956 );
4957
4958 WHEN OTHERS THEN
4959
4960 x_return_status := G_RET_UNEXPECTED;
4961
4962 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4963 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4964 THEN
4965 WSM_log_PVT.handle_others( p_module_name => l_module ,
4966 p_stmt_num => l_stmt_num ,
4967 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4968 p_run_log_level => l_log_level
4969 );
4970 END IF;
4971
4972 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
4973 p_count => x_msg_count ,
4974 p_data => x_msg_data
4975 );
4976
4977 END derive_val_res_job_details;
4978
4979
4980 -- Default resulting job details for bonus txn
4981 PROCEDURE derive_val_res_job_details( p_txn_type IN NUMBER,
4982 p_txn_org_id IN NUMBER,
4983 p_transaction_date IN DATE,
4984 p_resulting_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
4985 x_return_status OUT NOCOPY VARCHAR2,
4986 x_msg_count OUT NOCOPY NUMBER ,
4987 x_msg_data OUT NOCOPY VARCHAR2
4988 )
4989 IS
4990
4991 l_class_code WIP_ACCOUNTING_CLASSES.CLASS_CODE%TYPE;
4992 l_class_type WIP_ACCOUNTING_CLASSES.CLASS_TYPE%TYPE; -- Bug 5487991 Added
4993 l_dummy NUMBER;
4994 l_est_scrap_account NUMBER;
4995 l_est_scrap_var_account NUMBER;
4996 l_serial_control NUMBER;
4997
4998 l_return_status VARCHAR2(1);
4999 l_msg_count NUMBER;
5000 l_msg_data VARCHAR2(2000);
5001
5002 l_err_code NUMBER;
5003 l_err_msg VARCHAR2(2000);
5004 l_null_char VARCHAR2(1) := FND_API.G_NULL_CHAR;
5005
5006 -- logging variables
5007 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_res_job_details';
5008 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5009 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5010 l_stmt_num NUMBER := 0;
5011
5012 BEGIN
5013
5014 l_stmt_num := 10;
5015
5016 if p_txn_type <> WSMPCNST.BONUS then
5017 -- error out...
5018 if( g_log_level_statement >= l_log_level ) then
5019 l_msg_tokens.delete;
5020 WSM_log_PVT.logMessage(p_module_name => l_module ,
5021 p_msg_text => 'Transaction Type not bonus',
5022 p_stmt_num => l_stmt_num ,
5023 p_msg_tokens => l_msg_tokens ,
5024 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5025 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5026 p_run_log_level => l_log_level
5027 );
5028 END IF;
5029 raise FND_API.G_EXC_ERROR;
5030 end if;
5031
5032 l_stmt_num := 20;
5033 -- Default the job type to be Standard
5034 if p_resulting_job_rec.job_type is null then
5035 p_resulting_job_rec.job_type := WIP_CONSTANTS.STANDARD;
5036
5037 -- Bug 5487991 added elsif condition to validate the job_type is either 1 or 3
5038 -- these are two valid values for lot based jobs
5039
5040 elsif ( p_resulting_job_rec.job_type <> 1 and p_resulting_job_rec.job_type <> 3 ) then
5041
5042 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5043 l_msg_tokens.delete;
5044 l_msg_tokens(1).TokenName := 'FLD_NAME';
5045 l_msg_tokens(1).TokenValue := 'Job Type';
5046 WSM_log_PVT.logMessage(p_module_name => l_module ,
5047 p_msg_name => 'WSM_INVALID_FIELD' ,
5048 p_msg_appl_name => 'WSM' ,
5049 p_stmt_num => l_stmt_num ,
5050 p_msg_tokens => l_msg_tokens ,
5051 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5052 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5053 p_run_log_level => l_log_level
5054 );
5055 END IF;
5056 RAISE FND_API.G_EXC_ERROR;
5057
5058 -- Bug 5487991 end of code addition for this fix
5059
5060 end if;
5061
5062 -- Deafult the BOM supply type..
5063 if p_resulting_job_rec.wip_supply_type is null then
5064 p_resulting_job_rec.wip_supply_type := WIP_CONSTANTS.BASED_ON_BOM;
5065 end if;
5066
5067 -- Default the organization info..
5068 if p_resulting_job_rec.organization_id is null then
5069 p_resulting_job_rec.organization_id := p_txn_org_id;
5070 end if;
5071
5072 -- ST : Fix for bug 5131059 : description....... --
5073 if p_resulting_job_rec.description = l_null_char then
5074 p_resulting_job_rec.description := null;
5075 end if;
5076
5077 -- check the wip entity name for existence....
5078 if( g_log_level_statement >= l_log_level ) then
5079 l_msg_tokens.delete;
5080 WSM_log_PVT.logMessage(p_module_name => l_module ,
5081 p_msg_text => 'Checking the wip_entity_name for existence',
5082 p_stmt_num => l_stmt_num,
5083 p_msg_tokens => l_msg_tokens,
5084 p_fnd_log_level => g_log_level_statement,
5085 p_run_log_level => l_log_level
5086 );
5087 END IF;
5088
5089 BEGIN
5090 l_stmt_num := 30;
5091 IF p_resulting_job_rec.wip_entity_name is null then
5092 -- error out as it is mandatory......
5093 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5094 l_msg_tokens.delete;
5095 l_msg_tokens(1).TokenName := 'FLD_NAME';
5096 l_msg_tokens(1).TokenValue := 'wip_entity_name';
5097 WSM_log_PVT.logMessage(p_module_name => l_module ,
5098 p_msg_name => 'WSM_NULL_FIELD',
5099 p_msg_appl_name => 'WSM' ,
5100 p_stmt_num => l_stmt_num ,
5101 p_msg_tokens => l_msg_tokens ,
5102 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5103 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5104 p_run_log_level => l_log_level
5105 );
5106 END IF;
5107 RAISE FND_API.G_EXC_ERROR;
5108 ELSE
5109 l_stmt_num := 40;
5110 -- check if already existing job name
5111 select 1
5112 into l_dummy
5113 from wip_entities WE
5114 where WE.wip_entity_name = p_resulting_job_rec.wip_entity_name
5115 and WE.organization_id = p_txn_org_id;
5116
5117 if l_dummy=1 then
5118 -- error out as duplicate job....
5119 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5120 l_msg_tokens.delete;
5121 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5122 p_msg_name => 'WSM_DUPLICATE_ENT_NAME',
5123 p_msg_appl_name => 'WSM',
5124 p_msg_tokens => l_msg_tokens ,
5125 p_stmt_num => l_stmt_num ,
5126 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5127 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5128 p_run_log_level => l_log_level
5129 );
5130 END IF;
5131 RAISE FND_API.G_EXC_ERROR;
5132 END IF;
5133 END IF;
5134 EXCEPTION
5135 WHEN NO_DATA_FOUND THEN
5136 null;
5137 END;
5138
5139 -- call derive val primary item
5140 l_stmt_num := 50;
5141 derive_val_primary_item ( p_txn_org_id => p_txn_org_id ,
5142 p_old_item_id => null ,
5143 p_new_item_name => p_resulting_job_rec.item_name ,
5144 p_new_item_id => p_resulting_job_rec.primary_item_id,
5145 x_return_status => l_return_status,
5146 x_msg_count => l_msg_count,
5147 x_msg_data => l_msg_data
5148 );
5149
5150 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
5151 if( g_log_level_statement >= l_log_level ) then
5152
5153 l_msg_tokens.delete;
5154 WSM_log_PVT.logMessage(p_module_name => l_module ,
5155 p_msg_text => 'derive_val_primary_item returned failure',
5156 p_stmt_num => l_stmt_num ,
5157 p_msg_tokens => l_msg_tokens ,
5158 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5159 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5160 p_run_log_level => l_log_level
5161 );
5162 END IF;
5163 IF l_return_status = G_RET_ERROR THEN
5164 raise FND_API.G_EXC_ERROR;
5165 ELSIF l_return_status = G_RET_UNEXPECTED THEN
5166 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5167 END IF;
5168 END IF;
5169
5170 select nvl(serial_number_control_code,1)
5171 into l_serial_control
5172 from mtl_system_items
5173 where inventory_item_id = p_resulting_job_rec.primary_item_id
5174 and organization_id = p_resulting_job_rec.organization_id;
5175
5176 -- Quantity check .....
5177 -- ST : Fix for bug 5218598 : Added the nvl clause --
5178 if nvl(p_resulting_job_rec.start_quantity,0) <= 0 then
5179 -- error out...
5180 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5181 l_msg_tokens.delete;
5182 l_msg_tokens(1).TokenName := 'FLD_NAME';
5183 l_msg_tokens(1).TokenValue := 'start_quantity';
5184 WSM_log_PVT.logMessage(p_module_name => l_module ,
5185 p_msg_name => 'WSM_INVALID_FIELD' ,
5186 p_msg_appl_name => 'WSM' ,
5187 p_stmt_num => l_stmt_num ,
5188 p_msg_tokens => l_msg_tokens ,
5189 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5190 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5191 p_run_log_level => l_log_level
5192 );
5193 END IF;
5194 RAISE FND_API.G_EXC_ERROR;
5195 elsif p_resulting_job_rec.net_quantity is NULL then
5196 -- default the net quantity
5197 p_resulting_job_rec.net_quantity := round(p_resulting_job_rec.start_quantity,6);
5198
5199 elsif ( p_resulting_job_rec.net_quantity is not null) and
5200 ( (p_resulting_job_rec.net_quantity > p_resulting_job_rec.start_quantity) or
5201 (p_resulting_job_rec.net_quantity < 0)
5202 )
5203 then
5204 -- error out...
5205 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5206 l_msg_tokens.delete;
5207 l_msg_tokens(1).TokenName := 'FLD_NAME';
5208 l_msg_tokens(1).TokenValue := 'Net quantity';
5209 WSM_log_PVT.logMessage(p_module_name => l_module ,
5210 p_msg_name => 'WSM_INVALID_FIELD' ,
5211 p_msg_appl_name => 'WSM' ,
5212 p_stmt_num => l_stmt_num ,
5213 p_msg_tokens => l_msg_tokens ,
5214 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5215 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5216 p_run_log_level => l_log_level
5217 );
5218 END IF;
5219 RAISE FND_API.G_EXC_ERROR;
5220 end if;
5221
5222 -- Validate for serial --
5223 if (l_serial_control = 2) AND
5224 ( (floor(p_resulting_job_rec.net_quantity) <> p_resulting_job_rec.net_quantity) OR
5225 (floor(p_resulting_job_rec.start_quantity) <> p_resulting_job_rec.start_quantity)
5226 )
5227 then
5228 -- error out..
5229 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5230 l_msg_tokens.delete;
5231 WSM_log_PVT.logMessage(p_module_name => l_module ,
5232 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
5233 p_msg_appl_name => 'WSM' ,
5234 p_stmt_num => l_stmt_num ,
5235 p_msg_tokens => l_msg_tokens ,
5236 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5237 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5238 p_run_log_level => l_log_level
5239 );
5240 END IF;
5241 RAISE FND_API.G_EXC_ERROR;
5242 end if;
5243 -- end validate for serial --
5244
5245 -- Start date completion date defaulting to be handled...
5246 if p_resulting_job_rec.scheduled_start_date is null and p_resulting_job_rec.scheduled_completion_date is null then
5247 -- error out...
5248 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5249
5250 l_msg_tokens.delete;
5251 l_msg_tokens(1).TokenName := 'FLD_NAME';
5252 l_msg_tokens(1).TokenValue := 'Both scheduled_start_date and scheduled_end_date';
5253 WSM_log_PVT.logMessage(p_module_name => l_module ,
5254 p_msg_name => 'WSM_NULL_FIELD',
5255 p_msg_appl_name => 'WSM' ,
5256 p_stmt_num => l_stmt_num ,
5257 p_msg_tokens => l_msg_tokens ,
5258 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5259 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5260 p_run_log_level => l_log_level
5261 );
5262 END IF;
5263 RAISE FND_API.G_EXC_ERROR;
5264
5265 else
5266 -- Obtain the scheduled completion date information
5267 if p_resulting_job_rec.scheduled_completion_date is null then
5268 p_resulting_job_rec.scheduled_completion_date := WSMPUTIL.GET_SCHEDULED_DATE( p_organization_id => p_resulting_job_rec.organization_id,
5269 p_primary_item_id => p_resulting_job_rec.primary_item_id,
5270 p_schedule_method => 'F',
5271 p_input_date => p_resulting_job_rec.scheduled_start_date,
5272 p_quantity => p_resulting_job_rec.start_quantity,
5273 x_err_code => l_err_code,
5274 x_err_msg => l_err_msg);
5275
5276 elsif p_resulting_job_rec.scheduled_start_date is null then
5277 p_resulting_job_rec.scheduled_completion_date := WSMPUTIL.GET_SCHEDULED_DATE( p_organization_id => p_resulting_job_rec.organization_id,
5278 p_primary_item_id => p_resulting_job_rec.primary_item_id,
5279 p_schedule_method => 'B',
5280 p_input_date => p_resulting_job_rec.scheduled_completion_date,
5281 p_quantity => p_resulting_job_rec.start_quantity,
5282 x_err_code => l_err_code,
5283 x_err_msg => l_err_msg);
5284
5285 end if;
5286 end if;
5287
5288 if p_resulting_job_rec.scheduled_start_date > p_resulting_job_rec.scheduled_completion_date then
5289 -- error out.....
5290 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5291
5292 l_msg_tokens.delete;
5293 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5294 p_msg_name => 'WSM_INVALID_DATES',
5295 p_msg_appl_name => 'WSM',
5296 p_msg_tokens => l_msg_tokens ,
5297 p_stmt_num => l_stmt_num ,
5298 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5299 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5300 p_run_log_level => l_log_level
5301 );
5302 END IF;
5303 RAISE FND_API.G_EXC_ERROR;
5304 end if;
5305
5306
5307 -- check the account .......
5308 l_stmt_num := 60;
5309 BEGIN
5310 select 1
5311 into l_dummy
5312 from gl_code_combinations gcc,
5313 -- ST : Performance bug fix 4914162 : Remove the use of org_organization_definitions.
5314 -- org_organization_definitions ood
5315 hr_organization_information hoi,
5316 gl_sets_of_books gsob
5317 -- where p_txn_org_id = ood.organization_id
5318 where p_txn_org_id = hoi.organization_id
5319 -- and ood.chart_of_accounts_id = gcc.chart_of_accounts_id
5320 and gsob.chart_of_accounts_id = gcc.chart_of_accounts_id
5321 and nvl (p_resulting_job_rec.bonus_acct_id, -1) = gcc.code_combination_id
5322 and gcc.enabled_flag = 'Y'
5323 and p_transaction_date between nvl(gcc.start_date_active, p_transaction_date)
5324 and nvl(gcc.end_date_active, p_transaction_date)
5325 and gsob.set_of_books_id = TO_NUMBER(DECODE(RTRIM(TRANSLATE(hoi.org_information1,'0123456789',' ')),
5326 NULL,
5327 hoi.org_information1,
5328 -99999))
5329 and hoi.org_information_context || '' = 'Accounting Information';
5330
5331 EXCEPTION
5332 WHEN NO_DATA_FOUND then
5333 -- error out....
5334 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5335
5336 l_msg_tokens.delete;
5337 l_msg_tokens(1).TokenName := 'FLD_NAME';
5338 l_msg_tokens(1).TokenValue := 'BONUS_ACCT_ID';
5339 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5340 p_msg_name => 'WSM_INVALID_FIELD' ,
5341 p_msg_appl_name => 'WSM' ,
5342 p_msg_tokens => l_msg_tokens ,
5343 p_stmt_num => l_stmt_num ,
5344 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5345 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5346 p_run_log_level => l_log_level
5347 );
5348 END IF;
5349 raise FND_API.G_EXC_ERROR;
5350 END;
5351
5352 -- call derive_val_bom_info
5353 l_stmt_num := 70;
5354 derive_val_bom_info ( p_txn_org_id => p_txn_org_id,
5355 p_sj_job_type => p_resulting_job_rec.job_type,
5356 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
5357 p_rj_bom_reference_item => p_resulting_job_rec.bom_reference_item,
5358 p_rj_bom_reference_id => p_resulting_job_rec.bom_reference_id,
5359 p_rj_alternate_bom_desig => p_resulting_job_rec.alternate_bom_designator,
5360 p_rj_common_bom_seq_id => p_resulting_job_rec.common_bom_sequence_id,
5361 p_rj_bom_revision => p_resulting_job_rec.bom_revision,
5362 p_rj_bom_revision_date => p_resulting_job_rec.bom_revision_date,
5363 x_return_status => l_return_status,
5364 x_msg_count => l_msg_count,
5365 x_msg_data => l_msg_data
5366 );
5367
5368 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
5369 if( g_log_level_statement >= l_log_level ) then
5370
5371 l_msg_tokens.delete;
5372 WSM_log_PVT.logMessage(p_module_name => l_module ,
5373 p_msg_text => 'derive_val_bom_info returned failure',
5374 p_stmt_num => l_stmt_num ,
5375 p_msg_tokens => l_msg_tokens,
5376 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5377 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5378 p_run_log_level => l_log_level
5379 );
5380 END IF;
5381 IF l_return_status = G_RET_ERROR THEN
5382 raise FND_API.G_EXC_ERROR;
5383 ELSIF l_return_status = G_RET_UNEXPECTED THEN
5384 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5385 END IF;
5386 end if ;
5387
5388 -- call derive_val_routing_info
5389 l_stmt_num := 80;
5390 derive_val_routing_info ( p_txn_org_id => p_txn_org_id,
5391 p_sj_job_type => p_resulting_job_rec.job_type,
5392 p_rj_primary_item_id => p_resulting_job_rec.primary_item_id,
5393 p_rj_rtg_reference_item => p_resulting_job_rec.routing_reference_item,
5394 p_rj_rtg_reference_id => p_resulting_job_rec.routing_reference_id,
5395 p_rj_alternate_rtg_desig => p_resulting_job_rec.alternate_routing_designator,
5396 p_rj_common_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
5397 p_rj_rtg_revision => p_resulting_job_rec.routing_revision,
5398 p_rj_rtg_revision_date => p_resulting_job_rec.routing_revision_date,
5399 x_return_status => l_return_status,
5400 x_msg_count => l_msg_count,
5401 x_msg_data => l_msg_data
5402 );
5403
5404 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
5405 if( g_log_level_statement >= l_log_level ) then
5406
5407 l_msg_tokens.delete;
5408 WSM_log_PVT.logMessage(p_module_name => l_module ,
5409 p_msg_text => 'derive_val_routing_info returned failure',
5410 p_stmt_num => l_stmt_num ,
5411 p_msg_tokens => l_msg_tokens,
5412 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5413 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5414 p_run_log_level => l_log_level
5415 );
5416 END IF;
5417 IF l_return_status = G_RET_ERROR THEN
5418 raise FND_API.G_EXC_ERROR;
5419 ELSIF l_return_status = G_RET_UNEXPECTED THEN
5420 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5421 END IF;
5422 end if ;
5423
5424 l_stmt_num := 90;
5425 -- If the starting intraop step isnt specified, default to QUEUE
5426 p_resulting_job_rec.starting_intraoperation_step := nvl(p_resulting_job_rec.starting_intraoperation_step,WIP_CONSTANTS.QUEUE);
5427
5428 IF p_resulting_job_rec.starting_intraoperation_step <> 1 THEN
5429 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5430
5431 l_msg_tokens.delete;
5432 l_msg_tokens(1).TokenName := 'FLD_NAME';
5433 l_msg_tokens(1).TokenValue := 'intraoperation step for bonus';
5434
5435 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5436 p_msg_name => 'WSM_INVALID_FIELD' ,
5437 p_msg_appl_name => 'WSM' ,
5438 p_msg_tokens => l_msg_tokens ,
5439 p_stmt_num => l_stmt_num ,
5440 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5441 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5442 p_run_log_level => l_log_level
5443 );
5444 END IF;
5445 RAISE FND_API.G_EXC_ERROR;
5446 END IF;
5447
5448 -- validate network
5449 validate_network( p_txn_org_id => p_txn_org_id,
5450 p_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
5451 p_revision_date => p_resulting_job_rec.routing_revision_date,
5452 p_start_op_seq_num => p_resulting_job_rec.starting_operation_seq_num,
5453 p_start_op_seq_id => p_resulting_job_rec.starting_operation_seq_id,
5454 p_start_op_seq_code => p_resulting_job_rec.starting_operation_code,
5455 p_dept_id => p_resulting_job_rec.department_id,
5456 x_return_status => l_return_status,
5457 x_msg_count => l_msg_count,
5458 x_msg_data => l_msg_data
5459 );
5460
5461 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
5462 if( g_log_level_statement >= l_log_level ) then
5463
5464 l_msg_tokens.delete;
5465 WSM_log_PVT.logMessage(p_module_name => l_module ,
5466 p_msg_text => 'validate_network returned failure'||l_msg_data,
5467 p_stmt_num => l_stmt_num ,
5468 p_msg_tokens => l_msg_tokens,
5469 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5470 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5471 p_run_log_level => l_log_level
5472 );
5473 END IF;
5474 IF l_return_status = G_RET_ERROR THEN
5475 raise FND_API.G_EXC_ERROR;
5476 ELSIF l_return_status = G_RET_UNEXPECTED THEN
5477 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5478 END IF;
5479 end if ;
5480
5481 -- Subinv derivation...
5482 l_stmt_num := 100;
5483 derive_val_compl_subinv( p_job_type => p_resulting_job_rec.job_type,
5484 p_old_rtg_seq_id => null,
5485 p_new_rtg_seq_id => p_resulting_job_rec.common_routing_sequence_id,
5486 p_organization_id => p_txn_org_id,
5487 p_primary_item_id => p_resulting_job_rec.primary_item_id,
5488 p_sj_completion_subinventory => null,
5489 p_sj_completion_locator_id => null,
5490 -- ST : Bug fix 5094555 start
5491 p_rj_alt_rtg_designator => p_resulting_job_rec.alternate_routing_designator,
5492 p_rj_rtg_reference_item_id => p_resulting_job_rec.routing_reference_id,
5493 -- ST : Bug fix 5094555 end
5494 p_rj_completion_subinventory => p_resulting_job_rec.completion_subinventory,
5495 p_rj_completion_locator_id => p_resulting_job_rec.completion_locator_id,
5496 p_rj_completion_locator => p_resulting_job_rec.completion_locator,
5497 x_return_status => l_return_status,
5498 x_msg_count => l_msg_count,
5499 x_msg_data => l_msg_data
5500 );
5501
5502 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
5503 if( g_log_level_statement >= l_log_level ) then
5504
5505 l_msg_tokens.delete;
5506 WSM_log_PVT.logMessage(p_module_name => l_module ,
5507 p_msg_text => 'derive_val_compl_subinv returned failure',
5508 p_stmt_num => l_stmt_num ,
5509 p_msg_tokens => l_msg_tokens,
5510 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5511 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5512 p_run_log_level => l_log_level
5513 );
5514 END IF;
5515 IF l_return_status = G_RET_ERROR THEN
5516 raise FND_API.G_EXC_ERROR;
5517 ELSIF l_return_status = G_RET_UNEXPECTED THEN
5518 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5519 END IF;
5520 end if ;
5521
5522 -- class code check .....dependent on the subinventory....
5523 l_stmt_num := 110;
5524 BEGIN
5525 if p_resulting_job_rec.class_code is null then
5526 l_class_code := WSMPUTIL.GET_DEF_ACCT_CLASS_CODE( p_txn_org_id,
5527 p_resulting_job_rec.primary_item_id,
5528 p_resulting_job_rec.completion_subinventory,
5529 l_err_code,
5530 l_err_msg
5531 );
5532
5533 IF (l_err_code <> 0) THEN
5534 -- error out ........
5535 l_stmt_num := 120;
5536 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5537
5538 l_msg_tokens.delete;
5539 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5540 p_msg_name => 'WSM_INVALID_CLASS_CODE',
5541 p_msg_appl_name => 'WSM',
5542 p_msg_tokens => l_msg_tokens ,
5543 p_stmt_num => l_stmt_num ,
5544 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5545 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5546 p_run_log_level => l_log_level
5547 );
5548 END IF;
5549 RAISE FND_API.G_EXC_ERROR;
5550 END IF;
5551
5552 IF l_class_code IS NULL THEN
5553 -- error out....
5554 l_stmt_num := 130;
5555 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5556
5557 l_msg_tokens.delete;
5558 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5559 p_msg_name => 'WSM_INVALID_CLASS_CODE',
5560 p_msg_appl_name => 'WSM',
5561 p_msg_tokens => l_msg_tokens ,
5562 p_stmt_num => l_stmt_num ,
5563 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5564 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5565 p_run_log_level => l_log_level
5566 );
5567 END IF;
5568 RAISE FND_API.G_EXC_ERROR;
5569
5570 END IF;
5571
5572 p_resulting_job_rec.class_code := l_class_code;
5573
5574 l_stmt_num := 135;
5575 -- IF Estimated Scrap account is enabled... check accounts of the defaulted class code....
5576 IF wsmputil.WSM_ESA_ENABLED( p_wip_entity_id => NULL,
5577 err_code => l_err_code,
5578 err_msg => l_err_msg,
5579 p_org_id => p_txn_org_id,
5580 p_job_type => p_resulting_job_rec.job_type
5581 ) = 1
5582 THEN
5583 l_stmt_num := 140;
5584 select est_scrap_account,
5585 est_scrap_var_account
5586 into l_est_scrap_account,
5587 l_est_scrap_var_account
5588 from wip_accounting_classes
5589 where class_code = p_resulting_job_rec.class_code
5590 and organization_id = p_txn_org_id;
5591
5592
5593 IF l_est_scrap_account IS NULL OR l_est_scrap_var_account IS NULL THEN
5594 -- error out ...
5595 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5596
5597 l_msg_tokens.delete;
5598 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5599 p_msg_name => 'WSM_NO_WAC_SCRAP_ACC',
5600 p_msg_appl_name => 'WSM',
5601 p_msg_tokens => l_msg_tokens ,
5602 p_stmt_num => l_stmt_num ,
5603 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5604 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5605 p_run_log_level => l_log_level
5606 );
5607 END IF;
5608 RAISE FND_API.G_EXC_ERROR;
5609 END IF;
5610
5611 END IF;
5612
5613
5614 /* Bug 5487991 Commented out the following check as this is taken care of in the code
5615 added below as part of this fix
5616
5617 ELSE
5618 -- validate if such a class code exists or not.....
5619 select 1
5620 into l_dummy
5621 from wip_accounting_classes
5622 where class_code = p_resulting_job_rec.class_code
5623 and organization_id = p_txn_org_id; */
5624
5625 END IF;
5626
5627 -- Bug 5487991 Added the following check to ensure that class code is of correct type
5628 -- for standard and non standard bonus jobs.
5629
5630 l_stmt_num := 150;
5631
5632 SELECT class_type
5633 INTO l_class_type
5634 FROM wip_accounting_classes
5635 WHERE class_code = p_resulting_job_rec.class_code
5636 AND organization_id = p_txn_org_id;
5637
5638 l_stmt_num := 160;
5639
5640 IF ((p_resulting_job_rec.job_type = 1 and l_class_type <> 5 ) OR
5641 (p_resulting_job_rec.job_type = 3 and l_class_type <> 7 ))
5642 THEN
5643
5644 l_stmt_num := 170;
5645 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5646
5647 l_msg_tokens.delete;
5648 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5649 p_msg_name => 'WSM_INVALID_CLASS_CODE',
5650 p_msg_appl_name => 'WSM',
5651 p_msg_tokens => l_msg_tokens ,
5652 p_stmt_num => l_stmt_num ,
5653 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5654 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5655 p_run_log_level => l_log_level
5656 );
5657 END IF;
5658 RAISE FND_API.G_EXC_ERROR;
5659 END IF;
5660
5661 l_stmt_num := 150;
5662 -- Bug 5487991 end addition of code for this fix
5663
5664
5665 EXCEPTION
5666 WHEN NO_DATA_FOUND then
5667 -- handle ....
5668 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5669
5670 l_msg_tokens.delete;
5671 WSM_log_PVT.logMessage(p_module_name=> l_module ,
5672 p_msg_name => 'WSM_INVALID_CLASS_CODE',
5673 p_msg_appl_name => 'WSM',
5674 p_msg_tokens => l_msg_tokens ,
5675 p_stmt_num => l_stmt_num ,
5676 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5677 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5678 p_run_log_level => l_log_level
5679 );
5680 END IF;
5681 RAISE FND_API.G_EXC_ERROR;
5682 END;
5683
5684 x_return_status := FND_API.G_RET_STS_SUCCESS;
5685
5686 EXCEPTION
5687 WHEN FND_API.G_EXC_ERROR THEN
5688
5689 x_return_status := G_RET_ERROR;
5690 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
5691 p_count => x_msg_count ,
5692 p_data => x_msg_data
5693 );
5694
5695 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5696
5697 x_return_status := G_RET_UNEXPECTED;
5698
5699 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
5700 p_count => x_msg_count ,
5701 p_data => x_msg_data
5702 );
5703
5704 WHEN OTHERS THEN
5705
5706 x_return_status := G_RET_UNEXPECTED;
5707
5708 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
5709 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
5710 THEN
5711 WSM_log_PVT.handle_others( p_module_name => l_module ,
5712 p_stmt_num => l_stmt_num ,
5713 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
5714 p_run_log_level => l_log_level
5715 );
5716 END IF;
5717
5718 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
5719 p_count => x_msg_count ,
5720 p_data => x_msg_data
5721 );
5722 END derive_val_res_job_details;
5723
5724
5725 -- routing procedure.....
5726 Procedure derive_val_routing_info (p_txn_org_id IN NUMBER,
5727 p_sj_job_type IN NUMBER,
5728 p_rj_primary_item_id IN NUMBER,
5729 p_rj_rtg_reference_item IN VARCHAR2,
5730 p_rj_rtg_reference_id IN OUT NOCOPY NUMBER,
5731 p_rj_alternate_rtg_desig IN OUT NOCOPY VARCHAR2,
5732 p_rj_common_rtg_seq_id IN OUT NOCOPY NUMBER,
5733 p_rj_rtg_revision IN OUT NOCOPY VARCHAR2,
5734 p_rj_rtg_revision_date IN OUT NOCOPY DATE,
5735 x_return_status OUT NOCOPY varchar2,
5736 x_msg_count OUT NOCOPY NUMBER,
5737 x_msg_data OUT NOCOPY VARCHAR2
5738 ) is
5739
5740 l_rtg_revision WIP_DISCRETE_JOBS.ROUTING_REVISION%TYPE; --varchar2(10); -- ST : Changed
5741 l_null_char VARCHAR2(10) := FND_API.G_NULL_CHAR;
5742
5743 l_rj_compl_subinv WIP_DISCRETE_JOBS.completion_subinventory%TYPE; -- VARCHAR2(1000); -- ST : Changed
5744 l_rj_loc_id NUMBER;
5745 l_rj_rtg_seq_id NUMBER;
5746 l_rj_common_rtg_seq_id NUMBER;
5747 l_return_status VARCHAR2(1);
5748 l_msg_data VARCHAR2(1000);
5749 l_msg_count NUMBER;
5750 l_item_id NUMBER;
5751 l_row_exists NUMBER := 0; -- ST : Added for bug 5218479 --
5752 l_error_out NUMBER := 0; -- ST : Added for bug 5218479 --
5753 e_invalid_revision exception; -- ST : Added for bug 5218479 --
5754
5755 -- ST : Added for bug 5218479
5756 -- This is done b'cos the call to wip_revisions.*** procedures throw an app_exception
5757 -- app_exception is nothing but raise_application_error(-20001,<text......>
5758 -- So this has to be handled as a function error and not as an unexpected error...
5759 PRAGMA EXCEPTION_INIT(e_invalid_revision,-20001);
5760
5761 -- logging variables
5762 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_routing_info';
5763 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5764 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5765 l_stmt_num NUMBER := 0;
5766 l_param_tbl WSM_Log_PVT.param_tbl_type;
5767
5768 begin
5769 x_return_status := FND_API.G_RET_STS_SUCCESS;
5770
5771 l_stmt_num := 10;
5772
5773 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
5774
5775 l_stmt_num := 15;
5776 l_param_tbl.delete;
5777
5778 l_param_tbl(1).paramName := 'p_txn_org_id';
5779 l_param_tbl(1).paramValue := p_txn_org_id;
5780
5781 l_param_tbl(2).paramName := 'p_sj_job_type';
5782 l_param_tbl(2).paramValue := p_sj_job_type;
5783
5784 l_param_tbl(3).paramName := 'p_rj_primary_item_id';
5785 l_param_tbl(3).paramValue := p_rj_primary_item_id;
5786
5787 l_param_tbl(4).paramName := 'p_rj_rtg_reference_item';
5788 l_param_tbl(4).paramValue := p_rj_rtg_reference_item;
5789
5790 l_param_tbl(5).paramName := 'p_rj_rtg_reference_id';
5791 l_param_tbl(5).paramValue := p_rj_rtg_reference_id;
5792
5793 l_param_tbl(6).paramName := 'p_rj_alternate_rtg_desig';
5794 l_param_tbl(6).paramValue := p_rj_alternate_rtg_desig;
5795
5796 l_param_tbl(7).paramName := 'p_rj_common_rtg_seq_id';
5797 l_param_tbl(7).paramValue := p_rj_common_rtg_seq_id;
5798
5799 l_param_tbl(8).paramName := 'p_rj_rtg_revision_date';
5800 l_param_tbl(8).paramValue := p_rj_rtg_revision_date;
5801
5802 l_param_tbl(9).paramName := 'p_rj_rtg_revision';
5803 l_param_tbl(9).paramValue := p_rj_rtg_revision;
5804
5805 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
5806 p_param_tbl => l_param_tbl,
5807 p_fnd_log_level => l_log_level
5808 );
5809 END IF;
5810
5811 if p_sj_job_type = WIP_CONSTANTS.NONSTANDARD then
5812 -- if both null then copy from the starting....
5813 if p_rj_rtg_reference_id is null and p_rj_rtg_reference_item is null then
5814 --p_rj_rtg_reference_id := p_sj_rtg_reference_id; (AH)
5815 --error out as user has to specify some info...(AH)
5816 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5817 l_msg_tokens.delete;
5818 l_msg_tokens(1).TokenName := 'FLD_NAME';
5819 l_msg_tokens(1).TokenValue := 'For NSJ,Both rtg_reference_id and rtg_reference_item ';
5820 WSM_log_PVT.logMessage(p_module_name => l_module ,
5821 p_msg_name => 'WSM_NULL_FIELD',
5822 p_msg_appl_name => 'WSM' ,
5823 p_msg_tokens => l_msg_tokens ,
5824 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5825 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5826 p_run_log_level => l_log_level
5827 );
5828 END IF;
5829 RAISE FND_API.G_EXC_ERROR;
5830 else
5831 -- cross validate......
5832 if( g_log_level_statement >= l_log_level ) then
5833 l_msg_tokens.delete;
5834 WSM_log_PVT.logMessage(p_module_name => l_module ,
5835 p_msg_text => 'Cross validate routing_info',
5836 p_stmt_num => l_stmt_num ,
5837 p_msg_tokens => l_msg_tokens,
5838 p_fnd_log_level => g_log_level_statement,
5839 p_run_log_level => l_log_level
5840 );
5841 END IF;
5842
5843 BEGIN
5844 -- ST : Bug fix 4914162 : Added an IF clause
5845 IF p_rj_rtg_reference_id IS NOT NULL THEN
5846 select inventory_item_id
5847 into p_rj_rtg_reference_id
5848 from mtl_system_items_kfv
5849 where inventory_item_id = p_rj_rtg_reference_id
5850 and concatenated_segments = nvl(p_rj_rtg_reference_item,concatenated_segments)
5851 and organization_id = p_txn_org_id;
5852 ELSE
5853 select inventory_item_id
5854 into p_rj_rtg_reference_id
5855 from mtl_system_items_kfv
5856 where concatenated_segments = p_rj_rtg_reference_item
5857 and organization_id = p_txn_org_id;
5858 END IF;
5859
5860 EXCEPTION
5861 WHEN no_data_found THEN
5862 -- error out...
5863 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5864
5865 l_msg_tokens.delete;
5866 l_msg_tokens(1).TokenName := 'FLD_NAME';
5867 l_msg_tokens(1).TokenValue := 'value for rotuing reference item/routing reference id';
5868 WSM_log_PVT.logMessage(p_module_name => l_module ,
5869 p_msg_name => 'WSM_INVALID_FIELD',
5870 p_msg_appl_name => 'WSM' ,
5871 p_msg_tokens => l_msg_tokens ,
5872 p_stmt_num => l_stmt_num ,
5873 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5874 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5875 p_run_log_level => l_log_level
5876 );
5877 END IF;
5878 RAISE FND_API.G_EXC_ERROR;
5879 END;
5880 END IF;
5881
5882 end if;
5883
5884 -- ST : Fix for bug 5218479 --
5885 l_stmt_num := 19;
5886
5887 -- Check if a OSFM routing
5888 l_row_exists := 0;
5889 IF p_sj_job_type = wip_constants.nonstandard THEN
5890 l_item_id := p_rj_rtg_reference_id;
5891 ELSE
5892 l_item_id := p_rj_primary_item_id;
5893 END IF;
5894
5895 select count(1)
5896 into l_row_exists
5897 from bom_operational_routings bor
5898 where bor.assembly_item_id= l_item_id
5899 and bor.organization_id= p_txn_org_id
5900 and bor.routing_type = 1
5901 and bor.cfm_routing_flag = 3
5902 and rownum < 2;
5903
5904 IF l_row_exists = 0 THEN
5905 -- error out as no network routing exists...
5906 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5907
5908 WSM_log_PVT.logMessage(p_module_name => l_module ,
5909 p_msg_name => 'WSM_NO_WSM_ROUTING' ,
5910 p_msg_appl_name => 'WSM' ,
5911 p_msg_tokens => l_msg_tokens ,
5912 p_stmt_num => l_stmt_num ,
5913 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5914 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5915 p_run_log_level => l_log_level
5916 );
5917 END IF;
5918 RAISE FND_API.G_EXC_ERROR;
5919
5920 END IF;
5921 -- ST : Fix for bug 5218479 end --
5922
5923 l_stmt_num := 20;
5924 IF p_rj_rtg_revision_date IS NULL THEN
5925
5926 IF p_rj_rtg_revision IS NULL THEN
5927 -- yes..... assign rtg_revision_date to job start date or sysdate
5928 if( g_log_level_statement >= l_log_level ) then
5929 l_msg_tokens.delete;
5930 WSM_log_PVT.logMessage(p_module_name => l_module ,
5931 p_msg_text => 'assign rtg_revision_date to job start date or sysdate',
5932 p_stmt_num => l_stmt_num ,
5933 p_msg_tokens => l_msg_tokens,
5934 p_fnd_log_level => g_log_level_statement,
5935 p_run_log_level => l_log_level
5936 );
5937 END IF;
5938 p_rj_rtg_revision_date := sysdate;
5939
5940 END IF;
5941
5942 if p_sj_job_type = wip_constants.nonstandard THEN
5943 l_item_id := p_rj_rtg_reference_id;
5944 ELSE
5945 l_item_id := p_rj_primary_item_id;
5946 END IF;
5947
5948 -- ST : Fix for bug 5218479 : Added the BEGIN clause --
5949 l_error_out := 0;
5950 BEGIN
5951 -- call wip_revisions
5952 wip_revisions.routing_revision(p_organization_id => p_txn_org_id,
5953 p_item_id => l_item_id,
5954 p_revision => p_rj_rtg_revision,
5955 p_revision_date => p_rj_rtg_revision_date,
5956 p_start_date => p_rj_rtg_revision_date
5957 );
5958
5959 IF( g_log_level_statement >= l_log_level ) THEN
5960 l_msg_tokens.delete;
5961 WSM_log_PVT.logMessage(p_module_name => l_module ,
5962 p_msg_text => 'return from wip_revisions.routing_revision',
5963 p_stmt_num => l_stmt_num ,
5964 p_msg_tokens => l_msg_tokens,
5965 p_fnd_log_level => g_log_level_statement,
5966 p_run_log_level => l_log_level
5967 );
5968 END IF;
5969 EXCEPTION
5970 WHEN e_invalid_revision THEN
5971 l_error_out := 1;
5972 END;
5973 -- ST : Fix for bug 5218479 : end --
5974 ELSE -- revision date is not null
5975 l_rtg_revision := null;
5976
5977 IF p_sj_job_type = wip_constants.nonstandard THEN
5978 l_item_id := p_rj_rtg_reference_id;
5979 ELSE
5980 l_item_id := p_rj_primary_item_id;
5981 END IF;
5982
5983 -- ST : Fix for bug 5218479 : Added the BEGIN clause --
5984 l_error_out := 0;
5985 l_stmt_num := 30;
5986 BEGIN
5987
5988 wip_revisions.routing_revision( p_organization_id => p_txn_org_id,
5989 p_item_id => l_item_id,
5990 p_revision => l_rtg_revision,
5991 p_revision_date => p_rj_rtg_revision_date,
5992 p_start_date => p_rj_rtg_revision_date
5993 );
5994
5995 p_rj_rtg_revision := nvl(p_rj_rtg_revision,l_rtg_revision);
5996
5997 IF l_rtg_revision <> p_rj_rtg_revision THEN
5998 l_error_out := 1;
5999 END IF;
6000 EXCEPTION
6001 WHEN e_invalid_revision THEN
6002 l_error_out := 1;
6003 END;
6004 -- ST : Fix for bug 5218479 end --
6005 END IF;
6006
6007 -- ST : Fix for bug 5218479 : Moved the erroring out code outside (so that it's common)
6008 l_stmt_num := 35;
6009 IF l_error_out = 1 THEN
6010 -- error out...
6011 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6012
6013 l_msg_tokens.delete;
6014 l_msg_tokens(1).TokenName := 'FLD_NAME';
6015 l_msg_tokens(1).TokenValue := 'value for rotuing revision/routing revision date';
6016 WSM_log_PVT.logMessage(p_module_name => l_module ,
6017 p_msg_name => 'WSM_INVALID_FIELD' ,
6018 p_msg_appl_name => 'WSM' ,
6019 p_msg_tokens => l_msg_tokens ,
6020 p_stmt_num => l_stmt_num ,
6021 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6022 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6023 p_run_log_level => l_log_level
6024 );
6025 END IF;
6026 RAISE FND_API.G_EXC_ERROR;
6027 END IF;
6028 -- ST : Fix for bug 5218479 end --
6029
6030 -- call routing_seq procedure to validate the routing fields...
6031 l_stmt_num := 40;
6032 routing_seq(p_job_type => p_sj_job_type,
6033 p_org_id => p_txn_org_id,
6034 p_item_id => p_rj_primary_item_id,
6035 p_alt_rtg => p_rj_alternate_rtg_desig,
6036 p_common_rtg_seq_id => p_rj_common_rtg_seq_id, --l_rj_common_rtg_seq_id,
6037 p_rtg_ref_id => p_rj_rtg_reference_id,
6038 p_default_subinv => l_rj_compl_subinv,
6039 p_default_loc_id => l_rj_loc_id,
6040 x_rtg_seq_id => l_rj_rtg_seq_id,
6041 x_return_status => l_return_status,
6042 x_error_msg => l_msg_data,
6043 x_error_count => l_msg_count
6044 );
6045
6046 if l_return_status <> fnd_api.g_ret_sts_success then
6047 -- error our...........
6048 if( g_log_level_statement >= l_log_level ) then
6049 l_msg_tokens.delete;
6050 WSM_log_PVT.logMessage(p_module_name => l_module ,
6051 p_msg_text => 'Procedure routing_seq returned failure',
6052 p_stmt_num => l_stmt_num ,
6053 p_msg_tokens => l_msg_tokens,
6054 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6055 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6056 p_run_log_level => l_log_level
6057 );
6058 END IF;
6059 raise FND_API.G_EXC_ERROR;
6060 end if;
6061
6062 l_stmt_num := 50;
6063 x_return_status := FND_API.G_RET_STS_SUCCESS;
6064
6065 exception
6066
6067 WHEN FND_API.G_EXC_ERROR THEN
6068
6069 x_return_status := G_RET_ERROR;
6070 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6071 p_count => x_msg_count ,
6072 p_data => x_msg_data
6073 );
6074
6075 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6076
6077 x_return_status := G_RET_UNEXPECTED;
6078
6079 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6080 p_count => x_msg_count ,
6081 p_data => x_msg_data
6082 );
6083 WHEN OTHERS THEN
6084
6085 x_return_status := G_RET_UNEXPECTED;
6086
6087 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
6088 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
6089 THEN
6090 WSM_log_PVT.handle_others( p_module_name => l_module ,
6091 p_stmt_num => l_stmt_num ,
6092 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
6093 p_run_log_level => l_log_level
6094 );
6095 END IF;
6096
6097 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6098 p_count => x_msg_count ,
6099 p_data => x_msg_data
6100 );
6101 END derive_val_routing_info;
6102
6103
6104 -- BOM procedure......
6105 Procedure derive_val_bom_info ( p_txn_org_id IN NUMBER,
6106 p_sj_job_type IN NUMBER,
6107 p_rj_primary_item_id IN NUMBER,
6108 p_rj_bom_reference_item IN OUT NOCOPY VARCHAR2,
6109 p_rj_bom_reference_id IN OUT NOCOPY NUMBER,
6110 p_rj_alternate_bom_desig IN OUT NOCOPY VARCHAR2,
6111 p_rj_common_bom_seq_id IN OUT NOCOPY NUMBER,
6112 p_rj_bom_revision IN OUT NOCOPY VARCHAR2,
6113 p_rj_bom_revision_date IN OUT NOCOPY DATE,
6114 x_return_status OUT NOCOPY varchar2,
6115 x_msg_count OUT NOCOPY NUMBER,
6116 x_msg_data OUT NOCOPY VARCHAR2
6117 ) is
6118
6119 l_null_char VARCHAR2(10) := FND_API.G_NULL_CHAR;
6120 l_null_num NUMBER := FND_API.G_NULL_NUM;
6121 l_null_date DATE := FND_API.G_NULL_DATE;
6122
6123 l_bom_seq_id NUMBER;
6124 l_common_bom_seq_id NUMBER;
6125 l_return_status VARCHAR2(1);
6126 l_msg_data VARCHAR2(1000);
6127 l_msg_count NUMBER;
6128 l_item_id NUMBER;
6129 l_bom_revision WIP_DISCRETE_JOBS.BOM_REVISION%TYPE; -- VARCHAR2(10); --ST : Changed
6130 l_error_out NUMBER := 0; -- ST : Added for bug 5218479 --
6131 e_invalid_revision exception; -- ST : Added for bug 5218479 --
6132
6133 -- ST : Added for bug 5218479
6134 -- This is done b'cos the call to wip_revisions.*** procedures throw an app_exception
6135 -- app_exception is nothing but raise_application_error(-20001,<text......>
6136 -- So this has to be handled as a function error and not as an unexpected error...
6137 PRAGMA EXCEPTION_INIT(e_invalid_revision,-20001);
6138
6139 -- logging variables
6140 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_bom_info';
6141 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
6142 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6143 l_stmt_num NUMBER := 0;
6144 l_param_tbl WSM_Log_PVT.param_tbl_type;
6145
6146 begin
6147 x_return_status := FND_API.G_RET_STS_SUCCESS;
6148 l_stmt_num := 10;
6149
6150 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
6151
6152 l_stmt_num := 15;
6153 l_param_tbl.delete;
6154
6155 l_param_tbl(1).paramName := 'p_txn_org_id';
6156 l_param_tbl(1).paramValue := p_txn_org_id;
6157
6158 l_param_tbl(2).paramName := 'p_sj_job_type';
6159 l_param_tbl(2).paramValue := p_sj_job_type;
6160
6161 l_param_tbl(3).paramName := 'p_rj_primary_item_id';
6162 l_param_tbl(3).paramValue := p_rj_primary_item_id;
6163
6164 l_param_tbl(4).paramName := 'p_rj_bom_reference_item';
6165 l_param_tbl(4).paramValue := p_rj_bom_reference_item;
6166
6167 l_param_tbl(5).paramName := 'p_rj_bom_reference_id';
6168 l_param_tbl(5).paramValue := p_rj_bom_reference_id;
6169
6170 l_param_tbl(6).paramName := 'p_rj_alternate_bom_desig';
6171 l_param_tbl(6).paramValue := p_rj_alternate_bom_desig;
6172
6173 l_param_tbl(7).paramName := 'p_rj_common_bom_seq_id';
6174 l_param_tbl(7).paramValue := p_rj_common_bom_seq_id;
6175
6176 l_param_tbl(8).paramName := 'p_rj_bom_revision_date';
6177 l_param_tbl(8).paramValue := p_rj_bom_revision_date;
6178
6179 l_param_tbl(9).paramName := 'p_rj_bom_revision';
6180 l_param_tbl(9).paramValue := p_rj_bom_revision;
6181
6182 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
6183 p_param_tbl => l_param_tbl,
6184 p_fnd_log_level => l_log_level
6185 );
6186 END IF;
6187
6188 l_stmt_num := 18;
6189
6190 IF -- ST : Fix for bug 5101841 Commenting the below statement for Standard job.
6191 -- Standard Jobs will always have a BOM
6192 -- ( (p_sj_job_type = WIP_CONSTANTS.STANDARD) AND
6193 -- (p_rj_alternate_bom_desig IS NULL) AND
6194 -- (p_rj_common_bom_seq_id IS NULL) AND
6195 -- (p_rj_bom_revision IS NULL) AND
6196 -- (p_rj_bom_revision_date IS NULL)
6197 -- )
6198 -- OR
6199 ( (p_sj_job_type = WIP_CONSTANTS.NONSTANDARD) and
6200 (p_rj_bom_reference_id IS NULL) and
6201 (p_rj_bom_reference_item IS NULL)
6202 )
6203 then
6204 --- the user intends to detach the BOM.. cool.. so null out all the columns BOM
6205 p_rj_bom_reference_id := NULL;
6206 p_rj_bom_reference_item := NULL;
6207 p_rj_alternate_bom_desig := NULL;
6208 p_rj_common_bom_seq_id := NULL;
6209 p_rj_bom_revision := NULL;
6210 p_rj_bom_revision_date := NULL;
6211 return;
6212 end if;
6213
6214 l_stmt_num := 20;
6215
6216 if p_sj_job_type = WIP_CONSTANTS.NONSTANDARD then
6217 -- if both null then copy from the starting....
6218 if p_rj_bom_reference_id is null and p_rj_bom_reference_item is null then
6219 --p_rj_bom_reference_id := p_sj_bom_reference_id; (AH)
6220 --error out as user has to specify some info...(AH)
6221 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6222
6223 l_msg_tokens.delete;
6224 l_msg_tokens(1).TokenName := 'FLD_NAME';
6225 l_msg_tokens(1).TokenValue := 'BOM_REFERENCE_ID in resulting jobs';
6226 WSM_log_PVT.logMessage(p_module_name => l_module ,
6227 p_msg_name => 'WSM_NULL_FIELD',
6228 p_msg_appl_name => 'WSM' ,
6229 p_msg_tokens => l_msg_tokens ,
6230 p_stmt_num => l_stmt_num ,
6231 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6232 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6233 p_run_log_level => l_log_level
6234 );
6235 END IF;
6236 RAISE FND_API.G_EXC_ERROR;
6237 ELSE
6238 -- cross validate......
6239 BEGIN
6240 -- ST : Bug fix 4914162 : Added an IF clause
6241 IF p_rj_bom_reference_id IS NOT NULL THEN
6242 select inventory_item_id
6243 into p_rj_bom_reference_id
6244 from mtl_system_items_kfv
6245 where inventory_item_id = p_rj_bom_reference_id
6246 and concatenated_segments = nvl(p_rj_bom_reference_item,concatenated_segments)
6247 and organization_id = p_txn_org_id;
6248 ELSE
6249 select inventory_item_id
6250 into p_rj_bom_reference_id
6251 from mtl_system_items_kfv
6252 where concatenated_segments = p_rj_bom_reference_item
6253 and organization_id = p_txn_org_id;
6254 END IF;
6255
6256 EXCEPTION
6257 WHEN no_data_found then
6258 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6259
6260 l_msg_tokens.delete;
6261 l_msg_tokens(1).TokenName := 'FLD_NAME';
6262 l_msg_tokens(1).TokenValue := 'BOM REFERENCE ITEM/BOM REFERENCE ID in resulting jobs';
6263 WSM_log_PVT.logMessage(p_module_name => l_module ,
6264 p_msg_name => 'WSM_INVALID_FIELD',
6265 p_msg_appl_name => 'WSM' ,
6266 p_msg_tokens => l_msg_tokens ,
6267 p_stmt_num => l_stmt_num ,
6268 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6269 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6270 p_run_log_level => l_log_level
6271 );
6272 END IF;
6273 RAISE FND_API.G_EXC_ERROR;
6274
6275 END;
6276 END IF;
6277
6278 END IF;
6279
6280 l_stmt_num := 30;
6281 -- ST : Added for bug 5218479 --
6282 l_error_out := 0;
6283
6284 if p_rj_bom_revision_date is null then
6285
6286 if p_rj_bom_revision is null then
6287 -- yes..... assign bom_revision_date to job start date or sysdate
6288 p_rj_bom_revision_date := sysdate;
6289 end if;
6290
6291 if p_sj_job_type = wip_constants.nonstandard then
6292 l_item_id := p_rj_bom_reference_id;
6293 else
6294 l_item_id := p_rj_primary_item_id;
6295 end if;
6296
6297 -- ST : Fix for bug 5218479 start : Added the BEGIN clause --
6298 BEGIN
6299 -- call wip_revisions
6300 wip_revisions.bom_revision( p_organization_id => p_txn_org_id,
6301 p_item_id => l_item_id,
6302 p_revision => p_rj_bom_revision,
6303 p_revision_date => p_rj_bom_revision_date,
6304 p_start_date => p_rj_bom_revision_date
6305 );
6306 EXCEPTION
6307 WHEN e_invalid_revision THEN
6308 l_error_out := 1;
6309 END ;
6310 -- ST : Fix for bug 5218479 end --
6311
6312 else -- revision date is not null
6313 l_bom_revision := null;
6314
6315 if p_sj_job_type = wip_constants.nonstandard then
6316 l_item_id := p_rj_bom_reference_id;
6317 else
6318 l_item_id := p_rj_primary_item_id;
6319 end if;
6320
6321 -- ST : Fix for bug 5218479 : Added BEGIN clause --
6322 BEGIN
6323 wip_revisions.bom_revision( p_organization_id => p_txn_org_id,
6324 p_item_id => l_item_id,
6325 p_revision => l_bom_revision,
6326 p_revision_date => p_rj_bom_revision_date,
6327 p_start_date => p_rj_bom_revision_date
6328 );
6329
6330 p_rj_bom_revision := nvl(p_rj_bom_revision,l_bom_revision);
6331
6332 IF l_bom_revision <> p_rj_bom_revision THEN
6333 l_error_out := 1;
6334 END IF;
6335
6336 EXCEPTION
6337 WHEN e_invalid_revision THEN
6338 l_error_out := 1;
6339 END;
6340 -- ST : Fix for bug 5218479 : end --
6341
6342 end if;
6343
6344 -- ST : Fix for bug 5218479 --
6345 IF l_error_out = 1 THEN
6346 -- error out...
6347 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6348
6349 l_msg_tokens.delete;
6350 l_msg_tokens(1).TokenName := 'FLD_NAME';
6351 l_msg_tokens(1).TokenValue := 'value for bom_revision';
6352 WSM_log_PVT.logMessage(p_module_name => l_module ,
6353 p_msg_name => 'WSM_INVALID_FIELD',
6354 p_msg_appl_name => 'WSM' ,
6355 p_msg_tokens => l_msg_tokens ,
6356 p_stmt_num => l_stmt_num ,
6357 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6358 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6359 p_run_log_level => l_log_level
6360 );
6361 END IF;
6362 raise FND_API.G_EXC_ERROR;
6363 END IF;
6364 -- ST : Fix for bug 5218479 end..
6365
6366 l_stmt_num := 40;
6367 -- call bom_seq
6368 l_return_status := FND_API.G_RET_STS_SUCCESS;
6369 l_msg_data := null;
6370
6371 bom_seq ( p_job_type => p_sj_job_type , -- 1 std job, 3 or otherwise non-std
6372 p_org_id => p_txn_org_id,
6373 p_item_id => p_rj_primary_item_id,
6374 p_alt_bom => p_rj_alternate_bom_desig,
6375 p_common_bom_seq_id => p_rj_common_bom_seq_id,
6376 p_bom_ref_id => p_rj_bom_reference_id,
6377 x_bom_seq_id => l_bom_seq_id,
6378 x_return_status => l_return_status,
6379 x_error_msg => l_msg_data,
6380 x_error_count => l_msg_count
6381 );
6382
6383 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
6384 if( g_log_level_statement >= l_log_level ) then
6385 l_msg_tokens.delete;
6386 WSM_log_PVT.logMessage(p_module_name => l_module ,
6387 p_msg_text => 'Procedure bom_seq returned failure',
6388 p_stmt_num => l_stmt_num ,
6389 p_msg_tokens => l_msg_tokens,
6390 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6391 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6392 p_run_log_level => l_log_level
6393 );
6394 END IF;
6395 raise FND_API.G_EXC_ERROR;
6396 end if;
6397
6398 l_stmt_num := 50;
6399 x_return_status := FND_API.G_RET_STS_SUCCESS;
6400
6401 exception
6402 WHEN FND_API.G_EXC_ERROR THEN
6403
6404 x_return_status := G_RET_ERROR;
6405 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6406 p_count => x_msg_count ,
6407 p_data => x_msg_data
6408 );
6409
6410 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6411
6412 x_return_status := G_RET_UNEXPECTED;
6413
6414 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6415 p_count => x_msg_count ,
6416 p_data => x_msg_data
6417 );
6418 WHEN OTHERS THEN
6419
6420 x_return_status := G_RET_UNEXPECTED;
6421
6422 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
6423 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
6424 THEN
6425 WSM_log_PVT.handle_others( p_module_name => l_module ,
6426 p_stmt_num => l_stmt_num ,
6427 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
6428 p_run_log_level => l_log_level
6429 );
6430 END IF;
6431
6432 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6433 p_count => x_msg_count ,
6434 p_data => x_msg_data
6435 );
6436 end derive_val_bom_info;
6437
6438 -- Validate the completion subinventory details....
6439 Procedure derive_val_compl_subinv( p_job_type IN NUMBER,
6440 -- added for the call to LBJ procedure....
6441 p_old_rtg_seq_id IN NUMBER,
6442 p_new_rtg_seq_id IN NUMBER,
6443 p_organization_id IN NUMBER,
6444 p_primary_item_id IN NUMBER,
6445 p_sj_completion_subinventory IN VARCHAR2,
6446 p_sj_completion_locator_id IN NUMBER,
6447 p_rj_alt_rtg_designator IN VARCHAR2, -- Added for the bug 5094555
6448 p_rj_rtg_reference_item_id IN NUMBER, -- Added for the bug 5094555
6449 p_rj_completion_subinventory IN OUT NOCOPY VARCHAR2,
6450 p_rj_completion_locator_id IN OUT NOCOPY NUMBER,
6451 p_rj_completion_locator IN OUT NOCOPY VARCHAR2,
6452 x_return_status OUT NOCOPY VARCHAR2,
6453 x_msg_count OUT NOCOPY NUMBER,
6454 x_msg_data OUT NOCOPY VARCHAR2
6455 ) is
6456
6457 l_completion_subinventory BOM_OPERATIONAL_ROUTINGS.COMPLETION_SUBINVENTORY%type;
6458 l_completion_locator_id number;
6459
6460 l_sub_loc_control number;
6461 l_org_loc_control number;
6462 l_restrict_loc_code number;
6463 l_item_loc_control number;
6464 l_temp_boolean boolean := true;
6465 l_rtg_item_id NUMBER;
6466
6467 --- logging variables
6468 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_compl_subinv';
6469 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
6470 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6471 l_stmt_num NUMBER := 0;
6472 l_param_tbl WSM_Log_PVT.param_tbl_type;
6473
6474 begin
6475 x_return_status := FND_API.G_RET_STS_SUCCESS;
6476 l_stmt_num := 10;
6477
6478 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
6479
6480 l_stmt_num := 15;
6481 l_param_tbl.delete;
6482
6483 l_param_tbl(1).paramName := 'p_job_type';
6484 l_param_tbl(1).paramValue := p_job_type;
6485
6486 l_param_tbl(2).paramName := 'p_old_rtg_seq_id';
6487 l_param_tbl(2).paramValue := p_old_rtg_seq_id;
6488
6489 l_param_tbl(3).paramName := 'p_new_rtg_seq_id';
6490 l_param_tbl(3).paramValue := p_new_rtg_seq_id;
6491
6492 l_param_tbl(4).paramName := 'p_organization_id';
6493 l_param_tbl(4).paramValue := p_organization_id;
6494
6495 l_param_tbl(5).paramName := 'p_primary_item_id';
6496 l_param_tbl(5).paramValue := p_primary_item_id;
6497
6498 l_param_tbl(6).paramName := 'p_sj_completion_subinventory';
6499 l_param_tbl(6).paramValue := p_sj_completion_subinventory;
6500
6501 l_param_tbl(7).paramName := 'p_sj_completion_locator_id';
6502 l_param_tbl(7).paramValue := p_sj_completion_locator_id;
6503
6504 l_param_tbl(8).paramName := 'p_rj_alt_rtg_designator';
6505 l_param_tbl(8).paramValue := p_rj_alt_rtg_designator;
6506
6507 l_param_tbl(9).paramName := 'p_rj_completion_subinventory';
6508 l_param_tbl(9).paramValue := p_rj_completion_subinventory;
6509
6510 l_param_tbl(10).paramName := 'p_rj_completion_locator_id';
6511 l_param_tbl(10).paramValue := p_rj_completion_locator_id;
6512
6513 l_param_tbl(11).paramName := 'p_rj_completion_locator';
6514 l_param_tbl(11).paramValue := p_rj_completion_locator;
6515
6516 l_param_tbl(12).paramName := 'p_rj_rtg_reference_item_id';
6517 l_param_tbl(12).paramValue := p_rj_rtg_reference_item_id;
6518
6519 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
6520 p_param_tbl => l_param_tbl,
6521 p_fnd_log_level => l_log_level
6522 );
6523 END IF;
6524
6525 l_stmt_num := 20;
6526 IF p_job_type = WIP_CONSTANTS.STANDARD THEN
6527 l_rtg_item_id := p_primary_item_id;
6528 ELSE
6529 l_rtg_item_id := p_rj_rtg_reference_item_id;
6530 END IF;
6531
6532 -- If no change in routing..
6533 IF p_old_rtg_seq_id = p_new_rtg_seq_id THEN
6534
6535 p_rj_completion_subinventory := nvl(p_rj_completion_subinventory,p_sj_completion_subinventory);
6536
6537 IF p_rj_completion_locator IS NULL THEN
6538 --Bug 5380799: Completion locator should be defaulted from starting job only when
6539 --completion subinventory in the resulting job is same as that of starting job.
6540 if p_rj_completion_subinventory = p_sj_completion_subinventory then
6541 p_rj_completion_locator_id := nvl(p_rj_completion_locator_id,p_sj_completion_locator_id);
6542 end if;--Bug 5380799:End of check on completion subinventory.
6543 ELSE
6544 l_stmt_num := 30;
6545 BEGIN
6546 SELECT inventory_location_id
6547 INTO p_rj_completion_locator_id
6548 FROM mtl_item_locations_kfv
6549 WHERE inventory_item_id = l_rtg_item_id -- p_primary_item_id
6550 AND organization_id = p_organization_id
6551 AND subinventory_code = p_rj_completion_subinventory
6552 AND concatenated_segments = nvl(p_rj_completion_locator,concatenated_segments);
6553
6554 EXCEPTION
6555 WHEN no_data_found THEN
6556 -- error out....
6557 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6558
6559 l_msg_tokens.delete;
6560 l_msg_tokens(1).TokenName := 'FLD_NAME';
6561 l_msg_tokens(1).TokenValue := 'value for completion subinventory';
6562 WSM_log_PVT.logMessage(p_module_name => l_module ,
6563 p_msg_name => 'WSM_INVALID_FIELD',
6564 p_msg_appl_name => 'WSM' ,
6565 p_msg_tokens => l_msg_tokens ,
6566 p_stmt_num => l_stmt_num ,
6567 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6568 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6569 p_run_log_level => l_log_level
6570 );
6571 END IF;
6572 RAISE FND_API.G_EXC_ERROR;
6573 END;
6574 END IF;
6575 ELSE -- p_old_rtg_seq_id <> p_new_rtg_seq_id
6576 l_stmt_num := 40;
6577 BEGIN
6578
6579 select bor.completion_subinventory, bor.completion_locator_id
6580 into l_completion_subinventory,l_completion_locator_id
6581 from bom_operational_routings bor
6582 where bor.organization_id = p_organization_id
6583 and bor.common_routing_sequence_id = p_new_rtg_seq_id
6584 -- ST : Fix for bug 5094555 start --
6585 and nvl(bor.alternate_routing_designator,'@@@@****') = nvl(p_rj_alt_rtg_designator,'@@@@****')
6586 and organization_id = p_organization_id
6587 and assembly_item_id = l_rtg_item_id; -- p_primary_item_id;
6588 -- ST : Fix for bug 5094555 end --
6589
6590 EXCEPTION
6591 when no_data_found then
6592 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6593
6594 l_msg_tokens.delete;
6595 l_msg_tokens(1).TokenName := 'FLD_NAME';
6596 l_msg_tokens(1).TokenValue := 'or no matching value for completion subinventory';
6597 WSM_log_PVT.logMessage(p_module_name => l_module ,
6598 p_msg_name => 'WSM_INVALID_FIELD',
6599 p_msg_appl_name => 'WSM' ,
6600 p_msg_tokens => l_msg_tokens ,
6601 p_stmt_num => l_stmt_num ,
6602 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6603 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6604 p_run_log_level => l_log_level
6605 );
6606 END IF;
6607 RAISE FND_API.G_EXC_ERROR;
6608 end;
6609
6610 p_rj_completion_subinventory := nvl(p_rj_completion_subinventory,l_completion_subinventory);
6611
6612 IF p_rj_completion_locator IS NULL THEN
6613 --Bug 5380799: Completion locator should be defaulted from routing details only when
6614 --completion subinventory in the resulting job is same as that in routing details.
6615 IF p_rj_completion_subinventory = l_completion_subinventory THEN
6616 p_rj_completion_locator_id := nvl(p_rj_completion_locator_id,l_completion_locator_id);
6617 END IF;--Bug 5380799:End of check on completion subinventory.
6618 ELSE
6619 l_stmt_num := 50;
6620 BEGIN
6621 select inventory_location_id
6622 into p_rj_completion_locator_id
6623 from mtl_item_locations_kfv
6624 where inventory_item_id = l_rtg_item_id -- p_primary_item_id
6625 and organization_id = p_organization_id
6626 and subinventory_code = p_rj_completion_subinventory
6627 and concatenated_segments = p_rj_completion_locator;
6628
6629 EXCEPTION
6630 WHEN no_data_found THEN
6631 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6632
6633 l_msg_tokens.delete;
6634 l_msg_tokens(1).TokenName := 'FLD_NAME';
6635 l_msg_tokens(1).TokenValue := 'Completion locator id.';
6636 WSM_log_PVT.logMessage(p_module_name => l_module ,
6637 p_msg_name => 'WSM_INVALID_FIELD',
6638 p_msg_appl_name => 'WSM' ,
6639 p_msg_tokens => l_msg_tokens ,
6640 p_stmt_num => l_stmt_num ,
6641 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6642 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6643 p_run_log_level => l_log_level
6644 );
6645 END IF;
6646 RAISE FND_API.G_EXC_ERROR;
6647 END;
6648 END IF;
6649 END IF;
6650
6651 l_stmt_num := 60;
6652 -- call the LBJ code to validate.....
6653 --Bug 5380799:Locator id should be validated even if the locator id is null
6654 --if (p_rj_completion_locator_id is not null ) then
6655 -- Validate locator id (std job creation)
6656 BEGIN
6657 SELECT nvl(msi.locator_type, 1),
6658 mp.stock_locator_control_code,
6659 ms.restrict_locators_code,
6660 ms.location_control_code
6661 into l_sub_loc_control,
6662 l_org_loc_control,
6663 l_restrict_loc_code,
6664 l_item_loc_control
6665 from mtl_system_items ms,
6666 mtl_secondary_inventories msi,
6667 mtl_parameters mp
6668 where mp.organization_id = p_organization_id
6669 and ms.organization_id = p_organization_id
6670 and ms.inventory_item_id = l_rtg_item_id -- p_primary_item_id
6671 and msi.secondary_inventory_name = p_rj_completion_subinventory
6672 and msi.organization_id = p_organization_id;
6673
6674 exception
6675 when NO_DATA_FOUND then
6676 -- error out..
6677 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6678 l_msg_tokens.delete;
6679 l_msg_tokens(1).TokenName := 'FLD_NAME';
6680 l_msg_tokens(1).TokenValue := 'Completion locator.';
6681 WSM_log_PVT.logMessage(p_module_name => l_module ,
6682 p_msg_name => 'WSM_INVALID_FIELD',
6683 p_msg_appl_name => 'WSM' ,
6684 p_msg_tokens => l_msg_tokens ,
6685 p_stmt_num => l_stmt_num ,
6686 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6687 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6688 p_run_log_level => l_log_level
6689 );
6690 END IF;
6691 RAISE FND_API.G_EXC_ERROR;
6692
6693 end;
6694 l_stmt_num := 70;
6695 begin
6696 WIP_LOCATOR.validate ( p_organization_id,
6697 l_rtg_item_id , -- p_primary_item_id,
6698 p_rj_completion_subinventory,
6699 l_org_loc_control,
6700 l_sub_loc_control,
6701 l_item_loc_control,
6702 l_restrict_loc_code,
6703 NULL, NULL, NULL, NULL,
6704 p_rj_completion_locator_id,
6705 p_rj_completion_locator,
6706 l_temp_boolean
6707 );
6708 exception
6709 when NO_DATA_FOUND then
6710 l_temp_boolean := FALSE;
6711 end;
6712 l_stmt_num := 80;
6713 if not l_temp_boolean then
6714 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6715 l_msg_tokens.delete;
6716 l_msg_tokens(1).TokenName := 'FLD_NAME';
6717 l_msg_tokens(1).TokenValue := 'COMPLETION_LOCATOR_ID';
6718 WSM_log_PVT.logMessage(p_module_name => l_module ,
6719 p_msg_name => 'WSM_INVALID_FIELD',
6720 p_msg_appl_name => 'WSM' ,
6721 p_msg_tokens => l_msg_tokens ,
6722 p_stmt_num => l_stmt_num ,
6723 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6724 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6725 p_run_log_level => l_log_level
6726 );
6727 END IF;
6728 RAISE FND_API.G_EXC_ERROR;
6729 RETURN;
6730 END IF;
6731 --END IF; --Bug 5380799:Locator id validation is called even if the locator id is null.
6732
6733 x_return_status := FND_API.G_RET_STS_SUCCESS;
6734 exception
6735
6736 WHEN FND_API.G_EXC_ERROR THEN
6737
6738 x_return_status := G_RET_ERROR;
6739 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6740 p_count => x_msg_count ,
6741 p_data => x_msg_data
6742 );
6743
6744 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6745
6746 x_return_status := G_RET_UNEXPECTED;
6747
6748 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6749 p_count => x_msg_count ,
6750 p_data => x_msg_data
6751 );
6752 WHEN OTHERS THEN
6753
6754 x_return_status := G_RET_UNEXPECTED;
6755
6756 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
6757 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
6758 THEN
6759 WSM_log_PVT.handle_others( p_module_name => l_module ,
6760 p_stmt_num => l_stmt_num ,
6761 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
6762 p_run_log_level => l_log_level
6763 );
6764 END IF;
6765
6766 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
6767 p_count => x_msg_count ,
6768 p_data => x_msg_data
6769 );
6770 end derive_val_compl_subinv;
6771
6772 -- Procedure to derive/validate the starting operation information....
6773 Procedure derive_val_starting_op ( p_txn_org_id IN NUMBER,
6774 p_curr_op_seq_id IN NUMBER,
6775 p_curr_op_code IN VARCHAR2,
6776 p_curr_std_op_id IN NUMBER,
6777 p_curr_intra_op_step IN NUMBER,
6778 p_new_comm_rtg_seq_id IN NUMBER,
6779 p_new_rtg_rev_date IN DATE,
6780 p_new_op_seq_num IN OUT NOCOPY NUMBER,
6781 p_new_op_seq_id IN OUT NOCOPY NUMBER,
6782 p_new_std_op_id IN OUT NOCOPY NUMBER,
6783 p_new_op_seq_code IN OUT NOCOPY VARCHAR2,
6784 p_new_dept_id IN OUT NOCOPY NUMBER,
6785 x_return_status OUT NOCOPY varchar2,
6786 x_msg_count OUT NOCOPY NUMBER,
6787 x_msg_data OUT NOCOPY VARCHAR2
6788 ) is
6789
6790 l_op_is_std number;
6791 l_op_rptd_time number;
6792 l_err_code number;
6793 l_err_msg varchar2(2000);
6794
6795 l_operation_code BOM_STANDARD_OPERATIONS.OPERATION_CODE%type;
6796 l_op_rptd_times number;
6797
6798 -- logging variables
6799 l_stmt_num number:=0;
6800 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
6801 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6802 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_starting_op';
6803
6804 begin
6805 x_return_status := FND_API.G_RET_STS_SUCCESS;
6806 -- currently not supported for option 'a' : assumption it is not supported
6807 l_stmt_num :=10;
6808 if( g_log_level_statement >= l_log_level ) then
6809 l_msg_tokens.delete;
6810 WSM_log_PVT.logMessage(p_module_name => l_module ,
6811 p_msg_text => 'Entered derive_val_starting_op' ,
6812 p_stmt_num => l_stmt_num ,
6813 p_msg_tokens => l_msg_tokens,
6814 p_fnd_log_level => g_log_level_statement,
6815 p_run_log_level => l_log_level
6816 );
6817 End if;
6818
6819 if p_new_op_seq_num is null and p_new_op_seq_id is null then
6820
6821 if( g_log_level_statement >= l_log_level ) then
6822 l_msg_tokens.delete;
6823 WSM_log_PVT.logMessage(p_module_name => l_module ,
6824 p_msg_text => 'p_new_op_seq_num and p_new_op_seq_id is null',
6825 p_stmt_num => l_stmt_num ,
6826 p_msg_tokens => l_msg_tokens,
6827 p_fnd_log_level => g_log_level_statement,
6828 p_run_log_level => l_log_level
6829 );
6830 End if;
6831
6832 if p_curr_intra_op_step = WIP_CONSTANTS.QUEUE then
6833 l_stmt_num :=20;
6834
6835 if( g_log_level_statement >= l_log_level ) then
6836 l_msg_tokens.delete;
6837 WSM_log_PVT.logMessage(p_module_name => l_module ,
6838 p_msg_text => 'Calling WSMPUTIL.operation_is_standard_repeats',
6839 p_stmt_num => l_stmt_num ,
6840 p_msg_tokens => l_msg_tokens,
6841 p_fnd_log_level => g_log_level_statement,
6842 p_run_log_level => l_log_level
6843 );
6844 End if;
6845
6846 -- logic goes here.....
6847 l_err_code := 0;
6848 l_err_msg := null;
6849 WSMPUTIL.operation_is_standard_repeats ( p_routing_sequence_id => p_new_comm_rtg_seq_id,
6850 p_routing_revision_date => p_new_rtg_rev_date,
6851 p_standard_operation_id => p_curr_std_op_id,
6852 p_operation_code => p_curr_op_code,
6853 p_organization_id => p_txn_org_id,
6854 p_op_is_std_op => l_op_is_std,
6855 p_op_repeated_times => l_op_rptd_times,
6856 x_err_code => l_err_code,
6857 x_err_msg => l_err_msg);
6858
6859 if l_err_code <> 0 then
6860 -- error out....
6861 if( g_log_level_statement >= l_log_level ) then
6862
6863 l_msg_tokens.delete;
6864 WSM_log_PVT.logMessage(p_module_name => l_module ,
6865 p_msg_text => 'WSMPUTIL.operation_is_standard_repeats returned failure',
6866 p_stmt_num => l_stmt_num ,
6867 p_msg_tokens => l_msg_tokens,
6868 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6869 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6870 p_run_log_level => l_log_level
6871 );
6872 END IF;
6873 raise FND_API.G_EXC_ERROR;
6874 end if;
6875
6876 if l_op_rptd_times = 1 then -- Found a match
6877 l_stmt_num :=30;
6878 if( g_log_level_statement >= l_log_level ) then
6879 l_msg_tokens.delete;
6880 WSM_log_PVT.logMessage(p_module_name => l_module ,
6881 p_msg_text => 'Found match in resulting routing',
6882 p_stmt_num => l_stmt_num ,
6883 p_msg_tokens => l_msg_tokens,
6884 p_fnd_log_level => g_log_level_statement,
6885 p_run_log_level => l_log_level
6886 );
6887 End if;
6888
6889 BEGIN
6890 SELECT bos.operation_seq_num,
6891 bso.operation_code,
6892 bos.operation_sequence_id,
6893 bos.standard_operation_id,
6894 BD.department_id
6895 into p_new_op_seq_num,
6896 l_operation_code,
6897 p_new_op_seq_id,
6898 p_new_std_op_id,
6899 p_new_dept_id
6900 FROM bom_standard_operations BSO,
6901 bom_operation_sequences BOS,
6902 bom_departments BD
6903 WHERE BOS.routing_sequence_id = p_new_comm_rtg_seq_id
6904 AND BSO.standard_operation_id = BOS.standard_operation_id
6905 AND BSO.standard_operation_id = p_curr_std_op_id
6906 AND BD.department_id = BOS.department_id
6907 AND BD.department_id = nvl(p_new_dept_id,BD.department_id)
6908 AND p_new_rtg_rev_date between BOS.effectivity_date and nvl(BOS.disable_date, p_new_rtg_rev_date+1);
6909
6910 if p_new_op_seq_code is null then
6911 p_new_op_seq_code := l_operation_code;
6912 elsif nvl(p_new_op_seq_code,'$$&&') <> nvl(l_operation_code,'$$&&') then
6913 -- ST : Fix for bug 5116062 : Added an outer NVL clause
6914 -- error out.... wrong op_code...
6915 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6916
6917 l_msg_tokens.delete;
6918 l_msg_tokens(1).TokenName := 'FLD_NAME';
6919 l_msg_tokens(1).TokenValue := 'value for operation code';
6920 WSM_log_PVT.logMessage(p_module_name => l_module ,
6921 p_msg_name => 'WSM_INVALID_FIELD',
6922 p_msg_appl_name => 'WSM' ,
6923 p_msg_tokens => l_msg_tokens ,
6924 p_stmt_num => l_stmt_num ,
6925 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6926 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6927 p_run_log_level => l_log_level
6928 );
6929 END IF;
6930 raise FND_API.G_EXC_ERROR;
6931 end if;
6932
6933 EXCEPTION
6934 when no_data_found then
6935 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6936
6937 l_msg_tokens.delete;
6938 l_msg_tokens(1).TokenName := 'FLD_NAME';
6939 l_msg_tokens(1).TokenValue := 'Starting operation information';
6940 WSM_log_PVT.logMessage(p_module_name => l_module ,
6941 p_msg_name => 'WSM_INVALID_FIELD',
6942 p_msg_appl_name => 'WSM' ,
6943 p_msg_tokens => l_msg_tokens ,
6944 p_stmt_num => l_stmt_num ,
6945 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6946 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6947 p_run_log_level => l_log_level
6948 );
6949 END IF;
6950 raise FND_API.G_EXC_ERROR;
6951 END;
6952
6953 elsif l_op_rptd_times > 1 then
6954 l_stmt_num :=40;
6955 -- have to error out... repeated in the target ....
6956 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6957
6958 l_msg_tokens.delete;
6959 WSM_log_PVT.logMessage(p_module_name=> l_module ,
6960 p_msg_name => 'WSM_JOB_AT_REPEATED_OP',
6961 p_msg_appl_name => 'WSM',
6962 p_msg_tokens => l_msg_tokens ,
6963 p_stmt_num => l_stmt_num ,
6964 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6965 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6966 p_run_log_level => l_log_level
6967 );
6968 END IF;
6969 raise FND_API.G_EXC_ERROR;
6970 else
6971 l_stmt_num :=50;
6972 -- no match found....
6973 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6974
6975 l_msg_tokens.delete;
6976 WSM_log_PVT.logMessage(p_module_name=> l_module ,
6977 p_msg_name => 'WSM_NO_CURRENT_STDOP_TGTRTG',
6978 p_msg_appl_name => 'WSM',
6979 p_msg_tokens => l_msg_tokens ,
6980 p_stmt_num => l_stmt_num ,
6981 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6982 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6983 p_run_log_level => l_log_level
6984 );
6985 END IF;
6986 raise FND_API.G_EXC_ERROR;
6987 end if;
6988
6989 else
6990 l_stmt_num :=60;
6991 -- error out as for ToMove have to provide the starting op...
6992 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6993
6994 l_msg_tokens.delete;
6995 WSM_log_PVT.logMessage(p_module_name=> l_module ,
6996 p_msg_name => 'WSM_START_OP_REQD',
6997 p_msg_appl_name => 'WSM',
6998 p_msg_tokens => l_msg_tokens ,
6999 p_stmt_num => l_stmt_num ,
7000 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7001 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7002 p_run_log_level => l_log_level
7003 );
7004 END IF;
7005 raise FND_API.G_EXC_ERROR;
7006 end if;
7007 else
7008 -- logic .....
7009 l_stmt_num :=70;
7010 if( g_log_level_statement >= l_log_level ) then
7011 l_msg_tokens.delete;
7012 WSM_log_PVT.logMessage(p_module_name => l_module ,
7013 p_msg_text => 'p_new_op_seq_num and p_new_op_seq_id is not null',
7014 p_stmt_num => l_stmt_num ,
7015 p_msg_tokens => l_msg_tokens,
7016 p_fnd_log_level => g_log_level_statement,
7017 p_run_log_level => l_log_level
7018 );
7019 End if;
7020
7021 BEGIN
7022 if p_new_std_op_id is null and p_new_op_seq_code is null then
7023
7024 l_stmt_num :=80;
7025
7026 if( g_log_level_statement >= l_log_level ) then
7027 l_msg_tokens.delete;
7028 WSM_log_PVT.logMessage(p_module_name => l_module ,
7029 p_msg_text => 'p_new_std_op_id and p_new_op_seq_code is null',
7030 p_stmt_num => l_stmt_num ,
7031 p_msg_tokens => l_msg_tokens,
7032 p_fnd_log_level => g_log_level_statement,
7033 p_run_log_level => l_log_level
7034 );
7035 End if;
7036
7037 -- might be a non-standard...
7038 SELECT bos.operation_seq_num,
7039 bso.operation_code,
7040 bos.operation_sequence_id,
7041 bos.standard_operation_id,
7042 BD.department_id
7043 into p_new_op_seq_num,
7044 p_new_op_seq_code,
7045 p_new_op_seq_id,
7046 p_new_std_op_id,
7047 p_new_dept_id
7048 FROM bom_standard_operations BSO,
7049 bom_operation_sequences BOS,
7050 bom_departments BD
7051 WHERE BOS.routing_sequence_id = p_new_comm_rtg_seq_id
7052 AND BOS.operation_seq_num = nvl(p_new_op_seq_num,BOS.operation_seq_num)
7053 AND BOS.operation_sequence_id = nvl(p_new_op_seq_id,BOS.operation_sequence_id)
7054 AND BOS.standard_operation_id = BSO.standard_operation_id (+)
7055 AND nvl(p_new_std_op_id,BOS.standard_operation_id) = BSO.standard_operation_id (+)
7056 AND BD.department_id = BOS.department_id
7057 AND BD.department_id = nvl(p_new_dept_id,BD.department_id)
7058 AND p_new_rtg_rev_date between BOS.effectivity_date and nvl(BOS.disable_date, p_new_rtg_rev_date+1);
7059
7060 else
7061 l_stmt_num :=90;
7062
7063 if( g_log_level_statement >= l_log_level ) then
7064 l_msg_tokens.delete;
7065 WSM_log_PVT.logMessage(p_module_name => l_module ,
7066 p_msg_text => 'p_new_std_op_id and p_new_op_seq_code is not null',
7067 p_stmt_num => l_stmt_num ,
7068 p_msg_tokens => l_msg_tokens,
7069 p_fnd_log_level => g_log_level_statement,
7070 p_run_log_level => l_log_level
7071 );
7072 End if;
7073
7074 SELECT bos.operation_seq_num,
7075 bso.operation_code,
7076 bos.operation_sequence_id,
7077 bos.standard_operation_id,
7078 BD.department_id
7079 into p_new_op_seq_num,
7080 p_new_op_seq_code,
7081 p_new_op_seq_id,
7082 p_new_std_op_id,
7083 p_new_dept_id
7084 FROM bom_standard_operations BSO,
7085 bom_operation_sequences BOS,
7086 bom_departments BD
7087 WHERE BOS.routing_sequence_id = p_new_comm_rtg_seq_id
7088 AND BOS.operation_seq_num = nvl(p_new_op_seq_num,BOS.operation_seq_num)
7089 AND BOS.operation_sequence_id = nvl(p_new_op_seq_id,BOS.operation_sequence_id)
7090 AND BOS.standard_operation_id = BSO.standard_operation_id
7091 AND BSO.standard_operation_id = nvl(p_new_std_op_id,BSO.standard_operation_id)
7092 -- ST : Fix for bug 5116062 : Added an outer NVL clause
7093 AND nvl(BSO.operation_code,'$$&&') = nvl(nvl(p_new_op_seq_code,BSO.operation_code),'$$&&')
7094 AND BD.department_id = BOS.department_id
7095 AND BD.department_id = nvl(p_new_dept_id,BD.department_id)
7096 AND p_new_rtg_rev_date between BOS.effectivity_date and nvl(BOS.disable_date, p_new_rtg_rev_date+1);
7097
7098 end if;
7099
7100 EXCEPTION
7101 when no_data_found then
7102 -- error out....
7103 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7104
7105 l_msg_tokens.delete;
7106 l_msg_tokens(1).TokenName := 'FLD_NAME';
7107 l_msg_tokens(1).TokenValue := 'start operation information';
7108 WSM_log_PVT.logMessage(p_module_name => l_module ,
7109 p_msg_name => 'WSM_INVALID_FIELD',
7110 p_msg_appl_name => 'WSM' ,
7111 p_msg_tokens => l_msg_tokens ,
7112 p_stmt_num => l_stmt_num ,
7113 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7114 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7115 p_run_log_level => l_log_level
7116 );
7117 END IF;
7118 raise FND_API.G_EXC_ERROR;
7119 END;
7120 end if;
7121
7122 -- check for PO_MOVE....
7123 l_err_code := 0;
7124 If WSMPUTIL.CHECK_PO_MOVE( p_sequence_id => p_new_op_seq_id ,
7125 p_sequence_id_type => 'O' ,
7126 p_routing_rev_date => p_new_rtg_rev_date ,
7127 x_err_code => l_err_code ,
7128 x_err_msg => l_err_msg)
7129 THEN
7130 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7131 l_msg_tokens.delete;
7132 WSM_log_PVT.logMessage(p_module_name => l_module ,
7133 p_msg_name => 'WSM_OP_PO_MOVE',
7134 p_msg_appl_name => 'WSM' ,
7135 p_msg_tokens => l_msg_tokens ,
7136 p_stmt_num => l_stmt_num ,
7137 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7138 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7139 p_run_log_level => l_log_level
7140 );
7141 END IF;
7142 raise FND_API.G_EXC_ERROR;
7143 END IF;
7144
7145 if( g_log_level_statement >= l_log_level ) then
7146 l_msg_tokens.delete;
7147 WSM_log_PVT.logMessage(p_module_name => l_module ,
7148 p_msg_text => 'End of derive_val_starting_op',
7149 p_stmt_num => l_stmt_num ,
7150 p_msg_tokens => l_msg_tokens,
7151 p_fnd_log_level => g_log_level_statement,
7152 p_run_log_level => l_log_level
7153 );
7154 End if;
7155
7156 x_return_status := FND_API.G_RET_STS_SUCCESS;
7157
7158 exception
7159
7160 WHEN FND_API.G_EXC_ERROR THEN
7161
7162 x_return_status := G_RET_ERROR;
7163 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7164 p_count => x_msg_count ,
7165 p_data => x_msg_data
7166 );
7167
7168 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7169
7170 x_return_status := G_RET_UNEXPECTED;
7171
7172 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7173 p_count => x_msg_count ,
7174 p_data => x_msg_data
7175 );
7176 WHEN OTHERS THEN
7177
7178 x_return_status := G_RET_UNEXPECTED;
7179
7180 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7181 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7182 THEN
7183 WSM_log_PVT.handle_others( p_module_name => l_module ,
7184 p_stmt_num => l_stmt_num ,
7185 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7186 p_run_log_level => l_log_level
7187 );
7188 END IF;
7189
7190 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7191 p_count => x_msg_count ,
7192 p_data => x_msg_data
7193 );
7194 end derive_val_starting_op;
7195
7196 -- Procedure derive/validate the item information
7197 Procedure derive_val_primary_item ( p_txn_org_id IN NUMBER,
7198 p_old_item_id IN NUMBER,
7199 p_new_item_name IN VARCHAR2,
7200 p_new_item_id IN OUT NOCOPY NUMBER,
7201 x_return_status OUT NOCOPY varchar2,
7202 x_msg_count OUT NOCOPY NUMBER,
7203 x_msg_data OUT NOCOPY VARCHAR2
7204 ) is
7205 l_lot_control_code NUMBER;
7206 l_serial_number_control_code NUMBER;
7207
7208 -- logging variables
7209 l_stmt_num number:=0;
7210 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
7211 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7212 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.derive_val_primary_item';
7213
7214 begin
7215 x_return_status := FND_API.G_RET_STS_SUCCESS;
7216
7217 l_stmt_num := 10;
7218 IF p_new_item_name IS NULL AND p_new_item_id IS NULL THEN
7219 -- error out.... .
7220 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7221 l_msg_tokens.delete;
7222 l_msg_tokens(1).TokenName := 'FLD_NAME';
7223 l_msg_tokens(1).TokenValue := 'p_new_item_name and p_new_item_id ';
7224 WSM_log_PVT.logMessage(p_module_name => l_module ,
7225 p_msg_name => 'WSM_NULL_FIELD',
7226 p_msg_appl_name => 'WSM' ,
7227 p_msg_tokens => l_msg_tokens ,
7228 p_stmt_num => l_stmt_num ,
7229 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7230 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7231 p_run_log_level => l_log_level
7232 );
7233 END IF;
7234
7235 RAISE FND_API.G_EXC_ERROR;
7236
7237 end if;
7238
7239 l_stmt_num := 20;
7240 BEGIN
7241 -- ST : Bug fix 4914162 : Added an IF clause
7242 IF p_new_item_id IS NOT NULL THEN
7243 SELECT inventory_item_id,LOT_CONTROL_CODE,SERIAL_NUMBER_CONTROL_CODE
7244 INTO p_new_item_id,
7245 l_lot_control_code,
7246 l_serial_number_control_code
7247 from mtl_system_items_kfv
7248 where inventory_item_id = p_new_item_id
7249 and concatenated_segments = nvl(p_new_item_name,concatenated_segments)
7250 and organization_id = p_txn_org_id;
7251 ELSE
7252 SELECT inventory_item_id,LOT_CONTROL_CODE,SERIAL_NUMBER_CONTROL_CODE
7253 INTO p_new_item_id,
7254 l_lot_control_code,
7255 l_serial_number_control_code
7256 from mtl_system_items_kfv
7257 where concatenated_segments = p_new_item_name
7258 and organization_id = p_txn_org_id;
7259 END IF;
7260 EXCEPTION
7261 WHEN no_data_found THEN
7262 -- Invalid item name / item id combo.... error out
7263 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7264
7265 l_msg_tokens.delete;
7266 l_msg_tokens(1).TokenName := 'FLD_NAME';
7267 l_msg_tokens(1).TokenValue := 'value for item name / item_id specified ';
7268 WSM_log_PVT.logMessage(p_module_name => l_module ,
7269 p_msg_name => 'WSM_INVALID_FIELD',
7270 p_msg_appl_name => 'WSM' ,
7271 p_msg_tokens => l_msg_tokens ,
7272 p_stmt_num => l_stmt_num ,
7273 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7274 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7275 p_run_log_level => l_log_level
7276 );
7277 END IF;
7278 RAISE FND_API.G_EXC_ERROR;
7279 END;
7280
7281 l_stmt_num := 30;
7282 IF p_new_item_id = p_old_item_id then
7283 -- error out....
7284 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7285
7286 l_msg_tokens.delete;
7287 l_msg_tokens(1).TokenName := 'FLD_NAME';
7288 l_msg_tokens(1).TokenValue := 'Assembly cannot be same';
7289 WSM_log_PVT.logMessage(p_module_name => l_module ,
7290 p_msg_name => 'WSM_INVALID_FIELD',
7291 p_msg_appl_name => 'WSM' ,
7292 p_msg_tokens => l_msg_tokens ,
7293 p_stmt_num => l_stmt_num ,
7294 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7295 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7296 p_run_log_level => l_log_level
7297 );
7298 END IF;
7299 RAISE FND_API.G_EXC_ERROR;
7300 end if;
7301
7302 l_stmt_num := 40;
7303 if l_lot_control_code <> 2 OR (l_serial_number_control_code NOT IN(1,2))then
7304 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7305
7306 l_msg_tokens.delete;
7307 l_msg_tokens(1).TokenName := 'FLD_NAME';
7308 l_msg_tokens(1).TokenValue := 'value for lot_control_code/serial_control_code';
7309 WSM_log_PVT.logMessage(p_module_name => l_module ,
7310 p_msg_name => 'WSM_INVALID_FIELD',
7311 p_msg_appl_name => 'WSM' ,
7312 p_msg_tokens => l_msg_tokens ,
7313 p_stmt_num => l_stmt_num ,
7314 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7315 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7316 p_run_log_level => l_log_level
7317 );
7318 END IF;
7319 RAISE FND_API.G_EXC_ERROR;
7320
7321 end if;
7322
7323 x_return_status := FND_API.G_RET_STS_SUCCESS;
7324
7325 exception
7326
7327 WHEN FND_API.G_EXC_ERROR THEN
7328
7329 x_return_status := G_RET_ERROR;
7330 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7331 p_count => x_msg_count ,
7332 p_data => x_msg_data
7333 );
7334
7335 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7336
7337 x_return_status := G_RET_UNEXPECTED;
7338
7339 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7340 p_count => x_msg_count ,
7341 p_data => x_msg_data
7342 );
7343 WHEN OTHERS THEN
7344
7345 x_return_status := G_RET_UNEXPECTED;
7346
7347 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7348 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7349 THEN
7350 WSM_log_PVT.handle_others( p_module_name => l_module ,
7351 p_stmt_num => l_stmt_num ,
7352 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7353 p_run_log_level => l_log_level
7354 );
7355 END IF;
7356
7357 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7358 p_count => x_msg_count ,
7359 p_data => x_msg_data
7360 );
7361 end derive_val_primary_item;
7362
7363 -- Inserts the data into the base tables...
7364 Procedure insert_txn_data (p_transaction_id IN NUMBER,
7365 p_wltx_header IN WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
7366 p_wltx_starting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
7367 p_wltx_resulting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
7368 x_return_status OUT NOCOPY VARCHAR2,
7369 x_msg_count OUT NOCOPY NUMBER,
7370 x_msg_data OUT NOCOPY VARCHAR2
7371 ) IS
7372
7373 -- Status variables
7374 l_return_status VARCHAR2(1);
7375 l_msg_count NUMBER;
7376 l_msg_data VARCHAR2(2000);
7377
7378 -- local variable for logging purpose
7379 l_stmt_num NUMBER := 0;
7380 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
7381 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7382 l_module VARCHAR2(100) := 'wsm.plsql.WSM_WLT_VALIDATE_PVT.insert_txn_data';
7383
7384 -- Loop Variable --
7385 l_counter NUMBER := 0;
7386
7387 -- Starting and resulting jobs records
7388 l_starting_job_rec WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_REC_TYPE;
7389 l_resulting_job_rec WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE;
7390
7391
7392 BEGIN
7393 -- Have a starting point
7394 savepoint start_insert_txn_data;
7395
7396 l_stmt_num := 10;
7397 -- Initialize API return status to success
7398 x_return_status := FND_API.G_RET_STS_SUCCESS;
7399
7400 -- Log the Procedure entry point....
7401 if( g_log_level_statement >= l_log_level ) then
7402 l_msg_tokens.delete;
7403 WSM_log_PVT.logMessage(p_module_name => l_module ,
7404 p_msg_text => 'Entering the Insert Txn Data procedure to insert into the base tables',
7405 p_stmt_num => l_stmt_num ,
7406 p_msg_tokens => l_msg_tokens,
7407 p_fnd_log_level => g_log_level_statement,
7408 p_run_log_level => l_log_level
7409 );
7410 End if;
7411
7412 l_stmt_num := 20;
7413
7414 -- Start insert into WSMT table
7415 INSERT INTO wsm_split_merge_transactions(
7416 TRANSACTION_ID,
7417 TRANSACTION_TYPE_ID,
7418 ORGANIZATION_ID,
7419 INTERNAL_GROUP_ID,
7420 REASON_ID,
7421 TRANSACTION_DATE,
7422 TRANSACTION_REFERENCE,
7423 STATUS,
7424 SUSPENSE_ACCT_ID,
7425 LAST_UPDATE_DATE,
7426 LAST_UPDATED_BY,
7427 CREATION_DATE,
7428 CREATED_BY,
7429 LAST_UPDATE_LOGIN,
7430 ATTRIBUTE_CATEGORY,
7431 ATTRIBUTE1,
7432 ATTRIBUTE2,
7433 ATTRIBUTE3,
7434 ATTRIBUTE4,
7435 ATTRIBUTE5,
7436 ATTRIBUTE6,
7437 ATTRIBUTE7,
7438 ATTRIBUTE8,
7439 ATTRIBUTE9,
7440 ATTRIBUTE10,
7441 ATTRIBUTE11,
7442 ATTRIBUTE12,
7443 ATTRIBUTE13,
7444 ATTRIBUTE14,
7445 ATTRIBUTE15,
7446 REQUEST_ID,
7447 PROGRAM_APPLICATION_ID,
7448 PROGRAM_ID ,
7449 PROGRAM_UPDATE_DATE,
7450 EMPLOYEE_ID , --Added for MES
7451 COSTED
7452 )
7453 VALUES
7454 (
7455 p_TRANSACTION_ID,
7456 p_wltx_header.transaction_type_id,
7457 p_wltx_header.ORGANIZATION_ID,
7458 WSMPLOAD.G_GROUP_ID,
7459 p_wltx_header.REASON_ID,
7460 p_wltx_header.TRANSACTION_DATE,
7461 p_wltx_header.TRANSACTION_REFERENCE,
7462 WIP_CONSTANTS.COMPLETED,
7463 null,--p_wltx_header.SUSPENSE_ACCT_ID,
7464 sysdate,
7465 fnd_global.user_id,
7466 sysdate,
7467 fnd_global.user_id,
7468 fnd_global.login_id,
7469 p_wltx_header.ATTRIBUTE_CATEGORY,
7470 p_wltx_header.ATTRIBUTE1,
7471 p_wltx_header.ATTRIBUTE2,
7472 p_wltx_header.ATTRIBUTE3,
7473 p_wltx_header.ATTRIBUTE4,
7474 p_wltx_header.ATTRIBUTE5,
7475 p_wltx_header.ATTRIBUTE6,
7476 p_wltx_header.ATTRIBUTE7,
7477 p_wltx_header.ATTRIBUTE8,
7478 p_wltx_header.ATTRIBUTE9,
7479 p_wltx_header.ATTRIBUTE10,
7480 p_wltx_header.ATTRIBUTE11,
7481 p_wltx_header.ATTRIBUTE12,
7482 p_wltx_header.ATTRIBUTE13,
7483 p_wltx_header.ATTRIBUTE14,
7484 p_wltx_header.ATTRIBUTE15,
7485 FND_GLOBAL.CONC_REQUEST_ID,
7486 FND_GLOBAL.PROG_APPL_ID,
7487 FND_GLOBAL.CONC_PROGRAM_ID,
7488 sysdate,
7489 p_wltx_header.EMPLOYEE_ID ,--Added for MES
7490 decode(p_wltx_header.transaction_type_id,3,WIP_CONSTANTS.COMPLETED,
7491 5,WIP_CONSTANTS.COMPLETED,
7492 7,WIP_CONSTANTS.COMPLETED,
7493 WIP_CONSTANTS.PENDING
7494 )
7495 );
7496
7497 if( g_log_level_statement >= l_log_level ) then
7498 l_msg_tokens.delete;
7499 WSM_log_PVT.logMessage(p_module_name => l_module ,
7500 p_msg_text => 'Inserted Txn Header Data into the wsm_split_merge_transactions',
7501 p_stmt_num => l_stmt_num ,
7502 p_msg_tokens => l_msg_tokens,
7503 p_fnd_log_level => g_log_level_statement,
7504 p_run_log_level => l_log_level
7505 );
7506 End if;
7507
7508 l_stmt_num := 30;
7509 -- Start insert into starting lots base table
7510 l_counter := p_wltx_starting_jobs_tbl.first;
7511
7512 while l_counter is not null loop
7513
7514 l_starting_job_rec := p_wltx_starting_jobs_tbl(l_counter);
7515
7516 INSERT INTO wsm_sm_starting_jobs(
7517 TRANSACTION_ID,
7518 WIP_ENTITY_ID,
7519 INTERNAL_GROUP_ID,
7520 PRIMARY_ITEM_ID,
7521 OPERATION_SEQ_NUM,
7522 INTRAOPERATION_STEP,
7523 JOB_START_QUANTITY,
7524 AVAILABLE_QUANTITY,
7525 REPRESENTATIVE_FLAG,
7526 LAST_UPDATE_DATE,
7527 LAST_UPDATED_BY,
7528 CREATION_DATE,
7529 CREATED_BY,
7530 LAST_UPDATE_LOGIN,
7531 ATTRIBUTE_CATEGORY,
7532 ATTRIBUTE1,
7533 ATTRIBUTE2,
7534 ATTRIBUTE3,
7535 ATTRIBUTE4,
7536 ATTRIBUTE5,
7537 ATTRIBUTE6,
7538 ATTRIBUTE7,
7539 ATTRIBUTE8,
7540 ATTRIBUTE9,
7541 ATTRIBUTE10,
7542 ATTRIBUTE11,
7543 ATTRIBUTE12,
7544 ATTRIBUTE13,
7545 ATTRIBUTE14,
7546 ATTRIBUTE15,
7547 REQUEST_ID,
7548 PROGRAM_APPLICATION_ID,
7549 PROGRAM_ID,
7550 PROGRAM_UPDATE_DATE,
7551 WIP_ENTITY_NAME,
7552 NET_QUANTITY,
7553 ROUTING_SEQ_ID,
7554 ROUTING_REFERENCE_ID,
7555 BOM_REFERENCE_ID,
7556 ORGANIZATION_ID,
7557 DESCRIPTION,
7558 COMPLETION_SUBINVENTORY,
7559 COMPLETION_LOCATOR_ID,
7560 BILL_SEQUENCE_ID,
7561 DEPARTMENT_ID,
7562 OPERATION_SEQUENCE_ID,
7563 BOM_REVISION,
7564 BOM_REVISION_DATE,
7565 ROUTING_REVISION,
7566 ROUTING_REVISION_DATE,
7567 SCHEDULED_START_DATE,
7568 SCHEDULED_COMPLETION_DATE,
7569 COPRODUCTS_SUPPLY)
7570 VALUES
7571 (
7572 p_TRANSACTION_ID,
7573 l_starting_job_rec.WIP_ENTITY_ID,
7574 WSMPLOAD.G_GROUP_ID,
7575 l_starting_job_rec.PRIMARY_ITEM_ID,
7576 l_starting_job_rec.OPERATION_SEQ_NUM,
7577 l_starting_job_rec.INTRAOPERATION_STEP,
7578 l_starting_job_rec.START_QUANTITY,
7579 l_starting_job_rec.QUANTITY_available,
7580 l_starting_job_rec.REPRESENTATIVE_FLAG,
7581 sysdate,
7582 fnd_global.user_id,
7583 sysdate,
7584 fnd_global.user_id,
7585 fnd_global.login_id,
7586 l_starting_job_rec.ATTRIBUTE_CATEGORY,
7587 l_starting_job_rec.ATTRIBUTE1,
7588 l_starting_job_rec.ATTRIBUTE2,
7589 l_starting_job_rec.ATTRIBUTE3,
7590 l_starting_job_rec.ATTRIBUTE4,
7591 l_starting_job_rec.ATTRIBUTE5,
7592 l_starting_job_rec.ATTRIBUTE6,
7593 l_starting_job_rec.ATTRIBUTE7,
7594 l_starting_job_rec.ATTRIBUTE8,
7595 l_starting_job_rec.ATTRIBUTE9,
7596 l_starting_job_rec.ATTRIBUTE10,
7597 l_starting_job_rec.ATTRIBUTE11,
7598 l_starting_job_rec.ATTRIBUTE12,
7599 l_starting_job_rec.ATTRIBUTE13,
7600 l_starting_job_rec.ATTRIBUTE14,
7601 l_starting_job_rec.ATTRIBUTE15,
7602 fnd_global.conc_REQUEST_ID,
7603 FND_GLOBAL.PROG_APPL_ID,
7604 FND_GLOBAL.CONC_PROGRAM_ID,
7605 sysdate,
7606 l_starting_job_rec.WIP_ENTITY_NAME,
7607 l_starting_job_rec.NET_QUANTITY,
7608 l_starting_job_rec.COMMON_ROUTING_SEQUENCE_ID,
7609 l_starting_job_rec.ROUTING_REFERENCE_ID,
7610 l_starting_job_rec.BOM_REFERENCE_ID,
7611 l_starting_job_rec.ORGANIZATION_ID,
7612 l_starting_job_rec.DESCRIPTION,
7613 l_starting_job_rec.COMPLETION_SUBINVENTORY,
7614 l_starting_job_rec.COMPLETION_LOCATOR_ID,
7615 l_starting_job_rec.COMMON_BILL_SEQUENCE_ID,
7616 l_starting_job_rec.DEPARTMENT_ID,
7617 l_starting_job_rec.OPERATION_SEQ_ID,
7618 l_starting_job_rec.BOM_REVISION,
7619 l_starting_job_rec.BOM_REVISION_DATE,
7620 l_starting_job_rec.ROUTING_REVISION,
7621 l_starting_job_rec.ROUTING_REVISION_DATE,
7622 l_starting_job_rec.SCHEDULED_START_DATE,
7623 l_starting_job_rec.SCHEDULED_COMPLETION_DATE,
7624 l_starting_job_rec.COPRODUCTS_SUPPLY
7625 );
7626 l_counter := p_wltx_starting_jobs_tbl.next(l_counter);
7627 end loop;
7628 if( g_log_level_statement >= l_log_level ) then
7629 l_msg_tokens.delete;
7630 WSM_log_PVT.logMessage(p_module_name => l_module ,
7631 p_msg_text => 'Inserted '||SQL%ROWCOUNT||' records with transaction id:'|| p_wltx_header.transaction_id ,
7632 p_stmt_num => l_stmt_num,
7633 p_msg_tokens => l_msg_tokens,
7634 p_fnd_log_level => g_log_level_statement,
7635 p_run_log_level => l_log_level
7636 );
7637 End if;
7638
7639 l_stmt_num := 40;
7640
7641 -- Start insert into resulting lots base table
7642 l_counter := p_wltx_resulting_jobs_tbl.first;
7643 while l_counter is not null loop
7644
7645 l_resulting_job_rec := p_wltx_resulting_jobs_tbl(l_counter);
7646
7647 INSERT INTO wsm_sm_resulting_jobs(
7648 TRANSACTION_ID,
7649 WIP_ENTITY_NAME,
7650 WIP_ENTITY_ID,
7651 DESCRIPTION,
7652 INTERNAL_GROUP_ID,
7653 PRIMARY_ITEM_ID,
7654 CLASS_CODE,
7655 BONUS_ACCT_ID,
7656 START_QUANTITY,
7657 NET_QUANTITY,
7658 BOM_REFERENCE_ID,
7659 ROUTING_REFERENCE_ID,
7660 COMMON_BOM_SEQUENCE_ID,
7661 COMMON_ROUTING_SEQUENCE_ID,
7662 BOM_REVISION,
7663 BOM_REVISION_DATE,
7664 ROUTING_REVISION_DATE,
7665 ROUTING_REVISION,
7666 ALTERNATE_BOM_DESIGNATOR,
7667 ALTERNATE_ROUTING_DESIGNATOR,
7668 COPRODUCTS_SUPPLY,
7669 COMPLETION_LOCATOR_ID,
7670 COMPLETION_SUBINVENTORY,
7671 STARTING_OPERATION_CODE,
7672 STARTING_STD_OP_ID,
7673 STARTING_OPERATION_SEQ_NUM,
7674 STARTING_INTRAOPERATION_STEP,
7675 SCHEDULED_START_DATE,
7676 SCHEDULED_COMPLETION_DATE,
7677 DEMAND_CLASS,
7678 FORWARD_OP_OPTION,
7679 LAST_UPDATE_DATE,
7680 LAST_UPDATED_BY,
7681 CREATION_DATE,
7682 CREATED_BY,
7683 LAST_UPDATE_LOGIN,
7684 ATTRIBUTE_CATEGORY,
7685 ATTRIBUTE1,
7686 ATTRIBUTE2,
7687 ATTRIBUTE3,
7688 ATTRIBUTE4,
7689 ATTRIBUTE5,
7690 ATTRIBUTE6,
7691 ATTRIBUTE7,
7692 ATTRIBUTE8,
7693 ATTRIBUTE9,
7694 ATTRIBUTE10,
7695 ATTRIBUTE11,
7696 ATTRIBUTE12,
7697 ATTRIBUTE13,
7698 ATTRIBUTE14,
7699 ATTRIBUTE15,
7700 REQUEST_ID,
7701 PROGRAM_APPLICATION_ID,
7702 PROGRAM_ID,
7703 PROGRAM_UPDATE_DATE,
7704 JOB_TYPE,
7705 ORGANIZATION_ID,
7706 SPLIT_HAS_UPDATE_ASSY,
7707 JOB_OPERATION_SEQ_NUM)
7708 VALUES
7709 (
7710 p_TRANSACTION_ID,
7711 l_resulting_job_rec.WIP_ENTITY_NAME,
7712 l_resulting_job_rec.WIP_ENTITY_ID,
7713 l_resulting_job_rec.DESCRIPTION,
7714 WSMPLOAD.G_GROUP_ID,
7715 l_resulting_job_rec.PRIMARY_ITEM_ID,
7716 l_resulting_job_rec.CLASS_CODE,
7717 l_resulting_job_rec.BONUS_ACCT_ID,
7718 l_resulting_job_rec.START_QUANTITY,
7719 l_resulting_job_rec.NET_QUANTITY,
7720 l_resulting_job_rec.BOM_REFERENCE_ID,
7721 l_resulting_job_rec.ROUTING_REFERENCE_ID,
7722 l_resulting_job_rec.COMMON_BOM_SEQUENCE_ID,
7723 l_resulting_job_rec.COMMON_ROUTING_SEQUENCE_ID,
7724 l_resulting_job_rec.BOM_REVISION,
7725 l_resulting_job_rec.BOM_REVISION_DATE,
7726 l_resulting_job_rec.ROUTING_REVISION_DATE,
7727 l_resulting_job_rec.ROUTING_REVISION,
7728 l_resulting_job_rec.ALTERNATE_BOM_DESIGNATOR,
7729 l_resulting_job_rec.ALTERNATE_ROUTING_DESIGNATOR,
7730 l_resulting_job_rec.COPRODUCTS_SUPPLY,
7731 l_resulting_job_rec.COMPLETION_LOCATOR_ID,
7732 l_resulting_job_rec.COMPLETION_SUBINVENTORY,
7733 l_resulting_job_rec.STARTING_OPERATION_CODE,
7734 l_resulting_job_rec.STARTING_STD_OP_ID,
7735 l_resulting_job_rec.STARTING_OPERATION_SEQ_NUM,
7736 l_resulting_job_rec.STARTING_INTRAOPERATION_STEP,
7737 l_resulting_job_rec.SCHEDULED_START_DATE,
7738 l_resulting_job_rec.SCHEDULED_COMPLETION_DATE,
7739 null, -- l_resulting_job_rec.DEMAND_CLASS,
7740 null,--l_resulting_job_rec.FORWARD_OP_OPTION,
7741 sysdate,
7742 fnd_global.user_id,
7743 sysdate,
7744 fnd_global.user_id,
7745 fnd_global.login_id,
7746 l_resulting_job_rec.ATTRIBUTE_CATEGORY,
7747 l_resulting_job_rec.ATTRIBUTE1,
7748 l_resulting_job_rec.ATTRIBUTE2,
7749 l_resulting_job_rec.ATTRIBUTE3,
7750 l_resulting_job_rec.ATTRIBUTE4,
7751 l_resulting_job_rec.ATTRIBUTE5,
7752 l_resulting_job_rec.ATTRIBUTE6,
7753 l_resulting_job_rec.ATTRIBUTE7,
7754 l_resulting_job_rec.ATTRIBUTE8,
7755 l_resulting_job_rec.ATTRIBUTE9,
7756 l_resulting_job_rec.ATTRIBUTE10,
7757 l_resulting_job_rec.ATTRIBUTE11,
7758 l_resulting_job_rec.ATTRIBUTE12,
7759 l_resulting_job_rec.ATTRIBUTE13,
7760 l_resulting_job_rec.ATTRIBUTE14,
7761 l_resulting_job_rec.ATTRIBUTE15,
7762 fnd_global.conc_REQUEST_ID,
7763 FND_GLOBAL.PROG_APPL_ID,
7764 FND_GLOBAL.CONC_PROGRAM_ID,
7765 sysdate,
7766 l_resulting_job_rec.JOB_TYPE,
7767 l_resulting_job_rec.ORGANIZATION_ID,
7768 l_resulting_job_rec.SPLIT_HAS_UPDATE_ASSY,
7769 l_resulting_job_rec.job_operation_seq_num
7770 );
7771
7772 l_counter := p_wltx_resulting_jobs_tbl.next(l_counter);
7773 END LOOP;
7774
7775 if( g_log_level_statement >= l_log_level ) then
7776 l_msg_tokens.delete;
7777 WSM_log_PVT.logMessage(p_module_name => l_module ,
7778 p_msg_text => 'Inserted '||SQL%ROWCOUNT||'records with transaction id:'|| p_wltx_header.transaction_id ,
7779 p_stmt_num => l_stmt_num ,
7780 p_msg_tokens => l_msg_tokens,
7781 p_fnd_log_level => g_log_level_statement,
7782 p_run_log_level => l_log_level
7783 );
7784 End if;
7785 x_return_status := FND_API.G_RET_STS_SUCCESS;
7786
7787 EXCEPTION
7788 WHEN FND_API.G_EXC_ERROR THEN
7789
7790 x_return_status := G_RET_ERROR;
7791 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7792 p_count => x_msg_count ,
7793 p_data => x_msg_data
7794 );
7795
7796 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7797
7798 x_return_status := G_RET_UNEXPECTED;
7799
7800 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7801 p_count => x_msg_count ,
7802 p_data => x_msg_data
7803 );
7804 WHEN OTHERS THEN
7805
7806 x_return_status := G_RET_UNEXPECTED;
7807
7808 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7809 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7810 THEN
7811 WSM_log_PVT.handle_others( p_module_name => l_module ,
7812 p_stmt_num => l_stmt_num ,
7813 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7814 p_run_log_level => l_log_level
7815 );
7816 END IF;
7817
7818 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7819 p_count => x_msg_count ,
7820 p_data => x_msg_data
7821 );
7822
7823 END;
7824
7825 -- procedure specific to bonus...
7826 Procedure validate_network( p_txn_org_id IN NUMBER ,
7827 p_rtg_seq_id IN NUMBER ,
7828 p_revision_date IN DATE ,
7829 p_start_op_seq_num IN OUT NOCOPY NUMBER ,
7830 p_start_op_seq_id IN OUT NOCOPY NUMBER ,
7831 p_start_op_seq_code IN OUT NOCOPY VARCHAR2,
7832 p_dept_id IN OUT NOCOPY NUMBER ,
7833 x_return_status OUT NOCOPY VARCHAR2,
7834 x_msg_count OUT NOCOPY NUMBER ,
7835 x_msg_data OUT NOCOPY VARCHAR2
7836 )
7837 IS
7838
7839 l_err_code number;
7840 l_err_msg varchar2(2000);
7841
7842 l_end_op_seq_id number;
7843 l_start_op_seq_id number;
7844
7845 l_flag number;
7846 l_primary number;
7847
7848 -- Logging variables.....
7849 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
7850 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7851
7852 l_stmt_num NUMBER;
7853 l_module VARCHAR2(100) :='wsm.plsql.WSM_WLT_VALIDATE_PVT.validate_network';
7854 BEGIN
7855 x_return_status := G_RET_SUCCESS;
7856 l_stmt_num := 10;
7857 l_err_code := 0;
7858 l_err_msg := null;
7859
7860 WSMPUTIL.find_routing_start (p_routing_sequence_id => p_rtg_seq_id,
7861 p_routing_rev_date => p_revision_date,
7862 start_op_seq_id => l_start_op_seq_id,
7863 x_err_code => l_err_code,
7864 x_err_msg => l_err_msg);
7865
7866 if l_err_code <> 0 then
7867 if( g_log_level_statement >= l_log_level ) then
7868
7869 l_msg_tokens.delete;
7870 WSM_log_PVT.logMessage(p_module_name => l_module ,
7871 p_msg_text => 'WSMPUTIL.find_routing_start returned failure:'||l_err_msg,
7872 p_stmt_num => l_stmt_num ,
7873 p_msg_tokens => l_msg_tokens,
7874 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7875 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7876 p_run_log_level => l_log_level
7877 );
7878 END IF;
7879 RAISE FND_API.G_EXC_ERROR;
7880 end if;
7881
7882 --Bug 5395091: Get replacement op seq id for the starting op seq id determined above.
7883 l_start_op_seq_id := WSMPUTIL.replacement_op_seq_id(l_start_op_seq_id,p_revision_date);
7884
7885 l_stmt_num := 20;
7886 l_err_code := 0;
7887 l_err_msg := null;
7888
7889 WSMPUTIL.find_routing_end ( p_routing_sequence_id => p_rtg_seq_id,
7890 p_routing_rev_date => p_revision_date,
7891 end_op_seq_id => l_end_op_seq_id,
7892 x_err_code => l_err_code,
7893 x_err_msg => l_err_msg);
7894
7895 if l_err_code <> 0 then
7896 if( g_log_level_statement >= l_log_level ) then
7897
7898 l_msg_tokens.delete;
7899 WSM_log_PVT.logMessage(p_module_name => l_module ,
7900 p_msg_text => 'WSMPUTIL.find_routing_end returned failure:'||l_err_msg,
7901 p_stmt_num => l_stmt_num ,
7902 p_msg_tokens => l_msg_tokens,
7903 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7904 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7905 p_run_log_level => l_log_level
7906 );
7907 END IF;
7908 RAISE FND_API.G_EXC_ERROR;
7909 end if;
7910 --Bug 5395091: Get replacement op seq id for the end op seq id determined above.
7911 l_end_op_seq_id := WSMPUTIL.replacement_op_seq_id(l_end_op_seq_id,p_revision_date);
7912
7913 l_stmt_num := 30;
7914 if p_start_op_seq_num IS null and p_start_op_seq_id IS null and p_start_op_seq_code IS null then
7915 select bos.OPERATION_SEQ_NUM ,
7916 bos.OPERATION_SEQUENCE_ID ,
7917 bso.OPERATION_CODE
7918 into p_start_op_seq_num,
7919 p_start_op_seq_id,
7920 p_start_op_seq_code
7921 from bom_operation_sequences BOS,
7922 bom_standard_operations BSO
7923 where bos.OPERATION_SEQUENCE_ID = l_start_op_seq_id
7924 and BOS.routing_sequence_id = p_rtg_seq_id
7925 and BSO.standard_operation_id (+) = BOS.standard_operation_id
7926 and p_revision_date between BOS.effectivity_date and nvl(BOS.disable_date, p_revision_date+1);
7927 else
7928 l_stmt_num := 40;
7929
7930 if( g_log_level_statement >= l_log_level ) then
7931 l_msg_tokens.delete;
7932 WSM_log_PVT.logMessage(p_module_name => l_module ,
7933 p_msg_text => 'Start Op Seq Num : ' || p_start_op_seq_num ||
7934 ' Routing seq Id : ' || p_rtg_seq_id ||
7935 ' p_start_op_seq_id : ' || p_start_op_seq_id ||
7936 ' p_start_op_seq_code : ' || p_start_op_seq_code ||
7937 ' Revision Date : ' || p_revision_date,
7938 p_stmt_num => l_stmt_num ,
7939 p_msg_tokens => l_msg_tokens,
7940 p_fnd_log_level => g_log_level_statement,
7941 p_run_log_level => l_log_level
7942 );
7943 End if;
7944
7945 BEGIN
7946 select 1
7947 into l_flag
7948 from bom_operation_sequences BOS,
7949 bom_standard_operations BSO
7950 where bos.OPERATION_SEQ_NUM = nvl(p_start_op_seq_num,bos.OPERATION_SEQ_NUM)
7951 and bos.OPERATION_SEQUENCE_ID = nvl(p_start_op_seq_id,bos.OPERATION_SEQUENCE_ID)
7952 -- ST : Fix for bug 5116062 : Added an outer NVL clause
7953 and nvl(bso.OPERATION_CODE,'$$&&') = nvl(nvl(p_start_op_seq_code,bso.OPERATION_CODE),'$$&&')
7954 and bos.routing_sequence_id = p_rtg_seq_id
7955 and BSO.standard_operation_id (+) = BOS.standard_operation_id
7956 and p_revision_date between BOS.effectivity_date and nvl(BOS.disable_date, p_revision_date+1);
7957 EXCEPTION
7958 WHEN NO_DATA_FOUND THEN
7959 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
7960 l_msg_tokens.delete;
7961 l_msg_tokens(1).TokenName := 'FLD_NAME';
7962 l_msg_tokens(1).TokenValue := 'starting_operation';
7963 WSM_log_PVT.logMessage(p_module_name => l_module ,
7964 p_msg_name => 'WSM_INVALID_FIELD',
7965 p_msg_appl_name => 'WSM' ,
7966 p_msg_tokens => l_msg_tokens ,
7967 p_stmt_num => l_stmt_num ,
7968 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7969 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7970 p_run_log_level => l_log_level
7971 );
7972 END IF;
7973 RAISE FND_API.G_EXC_ERROR;
7974 END;
7975
7976 -- Is it a primary path..... .
7977 BEGIN
7978 l_stmt_num := 50;
7979 select 1
7980 into l_primary
7981 from dual
7982 where 1 in ( select 1
7983 from bom_operation_networks bon,
7984 bom_operation_sequences bos
7985 where bon.transition_type = 1 -- Primary
7986 and nvl(bon.disable_date, sysdate+1) > p_revision_date -- or is it sysdate
7987 -- Start : Fix for bug 4494368/4576184 --
7988 --and WSMPUTIL.replacement_op_seq_id(bon.from_op_seq_id,
7989 -- p_revision_date) = bos.operation_sequence_id
7990 and bon.from_op_seq_id = bos.operation_sequence_id
7991 and p_revision_date between bos.effectivity_date and nvl(bos.disable_date, p_revision_date+1)
7992 -- End : Fix for bug 4494368/4576184 --
7993 and bos.routing_sequence_id = p_rtg_seq_id
7994 and bos.operation_seq_num = p_start_op_seq_num
7995
7996 UNION
7997
7998 select 1
7999 from bom_operation_networks bon,
8000 bom_operation_sequences bos
8001 -- Start : Fix for bug 4494368/4576184 --
8002 --where WSMPUTIL.replacement_op_seq_id(bon.to_op_seq_id,
8003 -- p_revision_date) = bos.operation_sequence_id
8004 where bon.to_op_seq_id = bos.operation_sequence_id
8005 and p_revision_date between bos.effectivity_date and nvl(bos.disable_date, p_revision_date+1)
8006 -- End : Fix for bug 4494368/4576184 --
8007 and bos.routing_sequence_id = p_rtg_seq_id
8008 and bos.operation_seq_num = p_start_op_seq_num
8009 and bon.to_op_seq_id not in ( select bon1.from_op_seq_id
8010 from bom_operation_networks bon1,
8011 bom_operation_sequences bos1
8012 where WSMPUTIL.replacement_op_seq_id (
8013 bon1.from_op_seq_id,
8014 p_revision_date) = bos1.operation_sequence_id
8015 and bos1.routing_sequence_id = p_rtg_seq_id)
8016 );
8017
8018 EXCEPTION
8019 WHEN NO_DATA_FOUND then
8020 -- not on the primary path....
8021 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
8022
8023 l_msg_tokens.delete;
8024 WSM_log_PVT.logMessage(p_module_name=> l_module ,
8025 p_msg_name => 'WSM_OPRN_NOT_PRIMARY',
8026 p_msg_appl_name => 'WSM',
8027 p_msg_tokens => l_msg_tokens ,
8028 p_stmt_num => l_stmt_num ,
8029 p_fnd_msg_level => G_MSG_LVL_ERROR ,
8030 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
8031 p_run_log_level => l_log_level
8032 );
8033 END IF;
8034 RAISE FND_API.G_EXC_ERROR;
8035 END;
8036
8037 -- Checks if primary path exists till the start....
8038 l_stmt_num := 60;
8039 IF (WSMPUTIL.primary_path_is_effective_till( p_routing_sequence_id => p_rtg_seq_id,
8040 p_routing_rev_date => p_revision_date,
8041 p_start_op_seq_id => p_start_op_seq_id,
8042 p_op_seq_num => p_start_op_seq_num,
8043 x_err_code => l_err_code,
8044 x_err_msg => l_err_msg
8045 )
8046 = 0)
8047 THEN
8048 -- Disabled primary path.............
8049 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
8050
8051 l_msg_tokens.delete;
8052 WSM_log_PVT.logMessage(p_module_name=> l_module ,
8053 p_msg_name => 'WSM_PRIMARY_PATH_DISABLED',
8054 p_msg_appl_name => 'WSM',
8055 p_msg_tokens => l_msg_tokens ,
8056 p_stmt_num => l_stmt_num ,
8057 p_fnd_msg_level => G_MSG_LVL_ERROR ,
8058 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
8059 p_run_log_level => l_log_level
8060 );
8061 END IF;
8062 RAISE FND_API.G_EXC_ERROR;
8063 END IF;
8064 END IF;
8065 EXCEPTION
8066 WHEN FND_API.G_EXC_ERROR THEN
8067 x_return_status := G_RET_ERROR;
8068 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
8069 p_count => x_msg_count ,
8070 p_data => x_msg_data
8071 );
8072
8073 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8074
8075
8076 x_return_status := G_RET_UNEXPECTED;
8077
8078 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
8079 p_count => x_msg_count ,
8080 p_data => x_msg_data
8081 );
8082 WHEN OTHERS THEN
8083
8084 x_return_status := G_RET_UNEXPECTED;
8085
8086 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
8087 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
8088 THEN
8089 WSM_log_PVT.handle_others( p_module_name => l_module ,
8090 p_stmt_num => l_stmt_num ,
8091 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
8092 p_run_log_level => l_log_level
8093 );
8094 END IF;
8095
8096 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
8097 p_count => x_msg_count ,
8098 p_data => x_msg_data
8099 );
8100 END;
8101 end WSM_WLT_VALIDATE_PVT;