[Home] [Help]
PACKAGE BODY: APPS.WSMPJUPD
Source
1 PACKAGE BODY WSMPJUPD AS
2 /* $Header: WSMJUPDB.pls 120.43.12020000.6 2013/03/22 13:58:45 sisankar ship $ */
3
4 g_user_id number;
5 g_user_login_id number;
6 g_program_appl_id number;
7 g_request_id number;
8 g_program_id number;
9 g_translated_meaning varchar2(240);
10
11 /* Package name */
12 g_pkg_name VARCHAR2(20) := 'WSMPJUPD';
13
14 /*logging variables*/
15
16 g_log_level_unexpected NUMBER := FND_LOG.LEVEL_UNEXPECTED ;
17 g_log_level_error number := FND_LOG.LEVEL_ERROR ;
18 g_log_level_exception number := FND_LOG.LEVEL_EXCEPTION ;
19 g_log_level_event number := FND_LOG.LEVEL_EVENT ;
20 g_log_level_procedure number := FND_LOG.LEVEL_PROCEDURE ;
21 g_log_level_statement number := FND_LOG.LEVEL_STATEMENT ;
22
23 g_msg_lvl_unexp_error NUMBER := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR ;
24 g_msg_lvl_error NUMBER := FND_MSG_PUB.G_MSG_LVL_ERROR ;
25 g_msg_lvl_success NUMBER := FND_MSG_PUB.G_MSG_LVL_SUCCESS ;
26 g_msg_lvl_debug_high NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH ;
27 g_msg_lvl_debug_medium NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM ;
28 g_msg_lvl_debug_low NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW ;
29
30 g_ret_success varchar2(1) := FND_API.G_RET_STS_SUCCESS;
31 g_ret_error varchar2(1) := FND_API.G_RET_STS_ERROR;
32 g_ret_unexpected varchar2(1) := FND_API.G_RET_STS_UNEXP_ERROR;
33
34
35 type t_number is table of number index by binary_integer;
36 type t_job_name_tbl is table of number index by wip_entities.wip_entity_name%type;
37
38 -- MES secondary qty changes
39 type t_wsm_job_sec_qty_tbl is table of wsm_job_secondary_quantities%rowtype index by binary_integer;
40 type t_wsm_sj_sec_qty_tbl is table of wsm_sj_secondary_quantities%rowtype index by binary_integer;
41 type t_wsm_rj_sec_qty_tbl is table of wsm_rj_secondary_quantities%rowtype index by binary_integer;
42 type t_wsm_op_sec_qty_tbl is table of wsm_op_secondary_quantities%rowtype index by binary_integer;
43
44 type t_we_id_tbl is table of wip_entities.wip_entity_id%type index by binary_integer;
45 type t_cur_qty_tbl is table of wsm_job_secondary_quantities.current_quantity%type index by binary_integer;
46 type t_cur_uom_tbl is table of wsm_job_secondary_quantities.uom_code%type index by binary_integer;
47 -- End MES secondary qty changes
48
49 -- MES copy tables changes
50 type t_wsm_op_reason_codes_tbl is table of wsm_op_reason_codes%rowtype index by binary_integer;
51 --type t_wsm_subst_comp_tbl is table of wsm_substitute_components%rowtype index by binary_integer;
52 type t_wsm_copy_requirement_ops_tbl is table of wsm_copy_requirement_ops%rowtype index by binary_integer;
53 -- End MES copy tables changes
54
55 -- start...
56 Procedure process_mes_info ( p_secondary_qty_tbl IN WSM_WIP_LOT_TXN_PVT.WSM_JOB_SECONDARY_QTY_TBL_TYPE,
57 p_wltx_header IN WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
58 p_wltx_starting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
59 p_wltx_resulting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
60 p_sj_also_rj_index IN NUMBER,
61 p_rep_job_index IN NUMBER,
62 x_return_status OUT NOCOPY VARCHAR2,
63 x_msg_count OUT NOCOPY NUMBER,
64 x_error_msg OUT NOCOPY VARCHAR2
65 )
66 IS
67
68 l_sj_rj_wip_entity_id NUMBER ;
69 l_sj_rj_wip_entity_name VARCHAR2(2000) ;
70 l_sj_rj_inventory_item_id NUMBER ;
71
72 -- l_sj_rj_sec_qty_tbl WSM_WIP_LOT_TXN_PVT.wsm_job_secondary_qty_tbl_type;
73
74 l_sj_we_id_tbl t_we_id_tbl ;
75 l_sj_rj_sec_qty_exists NUMBER;
76
77 l_cur_qty_tbl t_cur_qty_tbl;
78 l_cur_uom_tbl t_cur_uom_tbl;
79 l_wip_entity_id_tbl t_number;
80
81 l_job_name_tbl t_job_name_tbl;
82
83 l_wsm_job_sec_qty_tbl t_wsm_job_sec_qty_tbl;
84 l_wsm_op_sec_qty_tbl t_wsm_op_sec_qty_tbl;
85 l_wsm_sj_sec_qty_tbl t_wsm_sj_sec_qty_tbl;
86 l_wsm_rj_sec_qty_tbl t_wsm_rj_sec_qty_tbl;
87
88 l_rj_op_reason_codes_tbl t_wsm_op_reason_codes_tbl;
89 l_sj_op_reason_codes_tbl t_wsm_op_reason_codes_tbl;
90
91 l_job_qty_tbl t_wsm_job_sec_qty_tbl;
92
93 l_sj_tbl_counter number;
94 l_rj_tbl_counter number;
95 l_op_tbl_counter number;
96
97 l_counter number;
98 l_index number;
99 -- Logging variables.....
100 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
101 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
102
103 l_stmt_num NUMBER;
104 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.process_mes_info';
105 l_param_tbl WSM_Log_PVT.param_tbl_type;
106
107 BEGIN
108
109 savepoint start_secondary_quantities;
110
111 x_return_status := FND_API.G_RET_STS_SUCCESS;
112
113 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
114 l_stmt_num := 5;
115 l_param_tbl.delete;
116 l_param_tbl(1).paramName := 'p_sj_also_rj_index';
117 l_param_tbl(1).paramValue := p_sj_also_rj_index;
118
119 l_param_tbl(2).paramName := 'p_rep_job_index';
120 l_param_tbl(2).paramValue := p_rep_job_index;
121
122 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
123 p_param_tbl => l_param_tbl,
124 p_fnd_log_level => l_log_level
125 );
126 END IF;
127
128 l_stmt_num := 8;
129 -- If the starting job is also the resulting job, store the starting job information..
130 -- or is it that the resulting job info is needed...
131 IF p_sj_also_rj_index IS NOT NULL THEN
132 l_sj_rj_wip_entity_id := p_wltx_resulting_jobs_tbl(p_sj_also_rj_index).wip_entity_id;
133 l_sj_rj_wip_entity_name := p_wltx_resulting_jobs_tbl(p_sj_also_rj_index).wip_entity_name;
134 l_sj_rj_inventory_item_id := p_wltx_resulting_jobs_tbl(p_sj_also_rj_index).primary_item_id;
135 END IF;
136
137 if( g_log_level_statement >= l_log_level ) then
138 l_msg_tokens.delete;
139 WSM_log_PVT.logMessage(p_module_name => l_module ,
140 p_msg_text => 'l_sj_rj_wip_entity_id ' || l_sj_rj_wip_entity_id ||
141 'l_sj_rj_wip_entity_name ' || l_sj_rj_wip_entity_name ||
142 'l_sj_rj_inventory_item_id ' || l_sj_rj_inventory_item_id ,
143 p_stmt_num => l_stmt_num ,
144 p_msg_tokens => l_msg_tokens,
145 p_fnd_log_level => g_log_level_statement,
146 p_run_log_level => l_log_level
147 );
148 End if;
149
150 l_wsm_sj_sec_qty_tbl.delete;
151 l_sj_we_id_tbl.delete;
152 l_job_qty_tbl.delete;
153
154 l_stmt_num := 10;
155 --*****************************Insert SJ sec qty info into history table**************************
156 -- First store SJ sec qty info in wsm_sj_secondary_quantities.The following steps followed for this:
157 -- 1. Query wsm_job_secondary_quantities table to get the SJ data into l_job_qty_tbl
158 -- 2. Now use this to populate fields in l_wsm_sj_sec_qty_tbl having rowtype same as wsm_sj_secondary_quantities
159 -- in order to do bulk insert later on
160 -- 3. Bulk insert in wsm_sj_secondary_quantities
161
162 l_counter := p_wltx_starting_jobs_tbl.first;
163 l_sj_tbl_counter := 1;
164 while l_counter is not null loop
165 --store SJ WE_ids in a local table for later use
166 l_sj_we_id_tbl(l_counter) := p_wltx_starting_jobs_tbl(l_counter).wip_entity_id;
167
168 -- Query wsm_job_secondary_quantities table to get the SJ data into l_job_qty_tbl
169 select *
170 bulk collect into l_job_qty_tbl
171 from wsm_job_secondary_quantities
172 where wip_entity_id = p_wltx_starting_jobs_tbl(l_counter).wip_entity_id
173 and currently_active= 1;
174
175 if( g_log_level_statement >= l_log_level ) then
176 l_msg_tokens.delete;
177 WSM_log_PVT.logMessage(p_module_name => l_module ,
178 p_msg_text => 'Current Secondary quantitites Count : ' || l_job_qty_tbl.count,
179 p_stmt_num => l_stmt_num ,
180 p_msg_tokens => l_msg_tokens,
181 p_fnd_log_level => g_log_level_statement,
182 p_run_log_level => l_log_level
183 );
184 End if;
185 l_stmt_num := 20;
186
187 -- now populate the local pl/sql table
188 if l_job_qty_tbl.count > 0 then
189 l_index := l_job_qty_tbl.first;
190 while l_index is not null loop
191 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).wip_entity_id := l_job_qty_tbl(l_index).wip_entity_id;
192 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).uom_code := l_job_qty_tbl(l_index).uom_code;
193 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).quantity := l_job_qty_tbl(l_index).current_quantity;
194 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).organization_id := l_job_qty_tbl(l_index).organization_id;
195 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).transaction_id := p_wltx_header.transaction_id;
196 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).last_update_date := sysdate;
197 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).last_update_login := fnd_global.login_id;
198 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).last_updated_by := fnd_global.user_id;
199 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).creation_date := sysdate;
200 l_wsm_sj_sec_qty_tbl(l_sj_tbl_counter).created_by := fnd_global.user_id;
201
202 l_sj_tbl_counter := l_sj_tbl_counter+1;
203 l_index := l_job_qty_tbl.next(l_index);
204 end loop;
205 end if;
206
207 l_counter := p_wltx_starting_jobs_tbl.next(l_counter);
208 end loop;
209
210 -- bulk insert in wsm_sj_secondary_quantities
211 if l_wsm_sj_sec_qty_tbl.count > 0 then
212 forall i in indices of l_wsm_sj_sec_qty_tbl
213 insert into wsm_sj_secondary_quantities
214 values l_wsm_sj_sec_qty_tbl(i);
215 end if;
216 if( g_log_level_statement >= l_log_level ) then
217 l_msg_tokens.delete;
218 WSM_log_PVT.logMessage(p_module_name => l_module ,
219 p_msg_text => 'Population of Histroy information for Starting Jobs done.',
220 p_stmt_num => l_stmt_num ,
221 p_msg_tokens => l_msg_tokens,
222 p_fnd_log_level => g_log_level_statement,
223 p_run_log_level => l_log_level
224 );
225 End if;
226 --********* End Insert SJ sec qty info into history table******************--
227
228 l_stmt_num := 40;
229
230 ----- Handle Secondary qty information passed for Split,Merge,Upd Assy and Update Qty transaction-------------------------------------
231 IF p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE,WSMPCNST.UPDATE_ASSEMBLY,WSMPCNST.UPDATE_QUANTITY) then
232
233 -- For all the new resulting jobs (non-SpUA jobs)
234 -- bulk insert data into wsm_op_secondary_quantities by reading from wsm_job_secondary_quantities
235 --Assumes that the wsm_job_secondary_quantities is already populated in lbj build_header_info proc
236 IF p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE) then
237 l_op_tbl_counter := 1;
238
239 l_stmt_num := 50;
240 l_counter := p_wltx_resulting_jobs_tbl.first;
241
242 -- get the secondary qty info from base table into local pl/sql table
243 while l_counter is not null loop
244 l_job_name_tbl(p_wltx_resulting_jobs_tbl(l_counter).wip_entity_name) := p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id;
245
246 l_job_qty_tbl.delete;
247 -- ST : Sec. UOM Fix : Added the nvl clause
248 IF (l_counter <> nvl(p_sj_also_rj_index,-1)) and
249 not (p_wltx_header.transaction_type_id = WSMPCNST.SPLIT and
250 p_wltx_resulting_jobs_tbl(l_counter).split_has_update_assy = 1
251 )
252 THEN
253 select *
254 bulk collect
255 into l_job_qty_tbl
256 from wsm_job_secondary_quantities
257 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id
258 and currently_active = 1;
259
260 -- now populate the local pl/sql table with rowtype same as wsm_op_secondary_quantities
261 -- so as to do bulk insert
262
263 if l_job_qty_tbl.count > 0 then
264 l_index := l_job_qty_tbl.first;
265 while l_index is not null loop
266
267 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).wip_entity_id := l_job_qty_tbl(l_index).wip_entity_id;
268 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).uom_code := l_job_qty_tbl(l_index).uom_code;
269 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).Operation_seq_num:= p_wltx_resulting_jobs_tbl(l_counter).starting_operation_seq_num;
270 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).move_in_quantity := null;
271 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).move_out_quantity:= null;
272 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).organization_id := l_job_qty_tbl(l_index).organization_id;
273 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).last_update_date := sysdate;
274 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).last_update_login:= fnd_global.login_id;
275 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).last_updated_by := fnd_global.user_id;
276 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).creation_date := sysdate;
277 l_wsm_op_sec_qty_tbl(l_op_tbl_counter).created_by := fnd_global.user_id;
278
279 l_op_tbl_counter := l_op_tbl_counter+1;
280 l_index := l_job_qty_tbl.next(l_index);
281 end loop;
282 end if;
283 END IF;
284 l_counter := p_wltx_resulting_jobs_tbl.next(l_counter);
285 end loop;
286
287 -- bulk insert into wsm_op_secondary_quantities
288 if l_wsm_op_sec_qty_tbl.count > 0 then
289 forall i in indices of l_wsm_op_sec_qty_tbl
290 insert into wsm_op_secondary_quantities
291 values l_wsm_op_sec_qty_tbl(i);
292 end if;
293 ELSE
294 l_job_name_tbl(p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_name) :=
295 p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_id;
296 END IF;
297
298 -- Insertion of wsm_op_secondary_quantities for non-SpUA new resulting jobs over
299 l_stmt_num := 60;
300 l_sj_rj_sec_qty_exists := 0;
301 IF p_secondary_qty_tbl.count > 0 then
302
303 l_index := p_secondary_qty_tbl.first;
304 l_stmt_num := 70;
305 while l_index is not null loop
306 IF (p_secondary_qty_tbl(l_index).wip_entity_name = nvl(l_sj_rj_wip_entity_name,'&&&&&*****')) and
307 (l_sj_rj_sec_qty_exists = 0)
308 THEN
309 -- This indicates that secondary qty information has been
310 -- provided for the starting job which is also a resulting job..
311 l_sj_rj_sec_qty_exists := 1;
312 END IF;
313 l_cur_qty_tbl(l_index) := p_secondary_qty_tbl(l_index).current_quantity;
314 l_cur_uom_tbl(l_index) := p_secondary_qty_tbl(l_index).uom_code;
315 l_wip_entity_id_tbl(l_index) := l_job_name_tbl(p_secondary_qty_tbl(l_index).wip_entity_name);
316
317 l_index := p_secondary_qty_tbl.next(l_index);
318 END LOOP;
319 END IF;
320
321 l_stmt_num := 80;
322 -- For a resulting job with change of assembly and for a job after update assembly transaction
323 -- The secondary qty UOMs not present for the new assembly have to be obsoleted
324 -- Insert new UOMs for the new assembly...which are not present in the old assembly
325 -- this part handles SpUA for SJ as RJ and UA
326 IF ( p_wltx_header.transaction_type_id = WSMPCNST.SPLIT and p_sj_also_rj_index is not NULL and
327 p_wltx_resulting_jobs_tbl(p_sj_also_rj_index).split_has_update_assy = 1
328 )
329 OR
330 (p_wltx_header.transaction_type_id = WSMPCNST.UPDATE_ASSEMBLY)
331 THEN
332 l_stmt_num := 80.1;
333 -- obsolete Old UOMs no longer valid in new assy
334 update wsm_job_secondary_quantities
335 set currently_active =2,
336 current_quantity=null
337 where wip_entity_id = l_sj_rj_wip_entity_id
338 AND uom_code not in (select uom_code
339 from wsm_secondary_uoms
340 where inventory_item_id =l_sj_rj_inventory_item_id);
341
342 if( g_log_level_statement >= l_log_level ) then
343 l_msg_tokens.delete;
344 WSM_log_PVT.logMessage(p_module_name => l_module ,
345 p_msg_text => 'Updated ' || SQL%ROWCOUNT || ' rows to be inactive in job secondary quantities',
346 p_stmt_num => l_stmt_num ,
347 p_msg_tokens => l_msg_tokens,
348 p_fnd_log_level => g_log_level_statement,
349 p_run_log_level => l_log_level
350 );
351 End if;
352
353 -- ST : Bug fix 5046332 : Added the below update to change the active flag of UOMs
354 -- currently inactive but are present in the new item
355 l_stmt_num := 80.2;
356 -- Enable old UOMs to be valid if present in new assy
357 update wsm_job_secondary_quantities
358 set currently_active = 1,
359 current_quantity= null
360 where wip_entity_id = l_sj_rj_wip_entity_id
361 AND uom_code in (select uom_code
362 from wsm_secondary_uoms
363 where inventory_item_id =l_sj_rj_inventory_item_id)
364 AND currently_active = 2; --Bugfix 4765660, left out of fix for 5046332
365
366 if( g_log_level_statement >= l_log_level ) then
367 l_msg_tokens.delete;
368 WSM_log_PVT.logMessage(p_module_name => l_module ,
369 p_msg_text => 'Updated ' || SQL%ROWCOUNT || ' rows to be active in job secondary quantities',
370 p_stmt_num => l_stmt_num ,
371 p_msg_tokens => l_msg_tokens,
372 p_fnd_log_level => g_log_level_statement,
373 p_run_log_level => l_log_level
374 );
375 End if;
376 -- ST : Bug fix 5046332 : End --
377
378 --Insert new UOMs skeletal info into the base table by reading from wsm_secondary_uoms
379 insert into wsm_job_secondary_quantities
380 (wip_entity_id
381 ,organization_id
382 ,uom_code
383 ,start_quantity
384 ,current_quantity
385 ,currently_active
386 ,last_update_date
387 ,last_updated_by
388 ,last_update_login
389 ,creation_date
390 ,created_by
391 )
392 (select
393 l_sj_rj_wip_entity_id,
394 organization_id,
395 uom_code,
396 null,
397 null,
398 1,
399 sysdate,
400 fnd_global.user_id,
401 fnd_global.login_id,
402 sysdate,
403 fnd_global.user_id
404 from wsm_secondary_uoms
405 where inventory_item_id = l_sj_rj_inventory_item_id -- (resulting job's item id..)
406 -- ST : Bug Fix 5046332 : Commenting out the below condition ---
407 -- and uom_code not in (select uom_code
408 -- from wsm_secondary_uoms
409 -- where inventory_item_id= p_wltx_starting_jobs_tbl(p_rep_job_index).primary_item_id)
410 -- -- ST : Sec. UOM Fix : Use the starting rep jobs's item id --
411 -- ST : Bug Fix 5046332 : Added the below condition ---
412 and uom_code not in (select uom_code
413 from wsm_job_secondary_quantities
414 where wip_entity_id = l_sj_rj_wip_entity_id)
415 -- ST : Bug Fix 5046332 : End --
416 );
417
418 IF( g_log_level_statement >= l_log_level ) THEN
419 l_msg_tokens.delete;
420 WSM_log_PVT.logMessage(p_module_name => l_module ,
421 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' new rows in in job secondary quantities tables',
422 p_stmt_num => l_stmt_num ,
423 p_msg_tokens => l_msg_tokens,
424 p_fnd_log_level => g_log_level_statement,
425 p_run_log_level => l_log_level
426 );
427 END IF;
428 END IF;
429
430 -- For a starting job also present as a resulting job, NULL out the current qty information if nothing is passed..
431 -- Demo Issue Fix : Retain the old information for the starting job
432 -- IF (p_wltx_header.transaction_type_id IN (WSMPCNST.SPLIT,WSMPCNST.MERGE)) and
433 -- (p_sj_also_rj_index is not NULL) and
434 -- (l_sj_rj_sec_qty_exists = 0)
435 -- THEN
436 -- -- User hasnt provided secondary qty information...
437 -- Update wsm_job_secondary_quantities wjsq
438 -- set current_quantity = null
439 -- where wjsq.wip_entity_id = l_sj_rj_wip_entity_id
440 -- and currently_active = 1;
441 -- END IF;
442
443 -- Now do the updation for all the resulting jobs...
444 IF p_secondary_qty_tbl.count <> 0 THEN
445 forall i in indices of p_secondary_qty_tbl
446 update wsm_job_secondary_quantities
447 set current_quantity = l_cur_qty_tbl(i)
448 where wip_entity_id = l_wip_entity_id_tbl(i)
449 and uom_code = l_cur_uom_tbl(i);
450 END IF;
451 END IF;
452 ----- End : Handle Split,Merge,Upd Assy --------------------------------------
453
454 l_stmt_num := 90;
455 if( g_log_level_statement >= l_log_level ) then
456 l_msg_tokens.delete;
457 WSM_log_PVT.logMessage(p_module_name => l_module ,
458 p_msg_text => 'Processing for Split Merge, Update Assembly Done',
459 p_stmt_num => l_stmt_num ,
460 p_msg_tokens => l_msg_tokens,
461 p_fnd_log_level => g_log_level_statement,
462 p_run_log_level => l_log_level
463 );
464 End if;
465
466 l_stmt_num := 120;
467 -- In case of Merge and Split,
468 -- then need to set the cur_qty = null and cur_active = N for Starting Jobs not present as a Resulting job
469 IF p_wltx_header.transaction_type_id IN (WSMPCNST.SPLIT,WSMPCNST.MERGE) THEN
470 forall i in indices of l_sj_we_id_tbl
471 update wsm_job_secondary_quantities
472 set currently_active = 2,
473 current_quantity=null
474 where wip_entity_id = l_sj_we_id_tbl(i)
475 and wip_entity_id <> nvl(l_sj_rj_wip_entity_id,0);
476 --If sj is rj(means l_sj_rj_wip_entity_id is not null),
477 --it shouldnt be updated.
478 END IF;
479
480 -- Here handle the Reason code for SPLIT and MERGE transaction..
481 If p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE) then
482
483 select *
484 bulk collect
485 into l_sj_op_reason_codes_tbl
486 from wsm_op_reason_codes
487 where operation_seq_num = p_wltx_starting_jobs_tbl(p_rep_job_index).operation_seq_num
488 and wip_entity_id = p_wltx_starting_jobs_tbl(p_rep_job_index).wip_entity_id;
489
490 if( g_log_level_statement >= l_log_level ) then
491 l_msg_tokens.delete;
492 WSM_log_PVT.logMessage(p_module_name => l_module ,
493 p_msg_text => 'Starting Job Reason codes count : ' || l_sj_op_reason_codes_tbl.count,
494 p_stmt_num => l_stmt_num ,
495 p_msg_tokens => l_msg_tokens,
496 p_fnd_log_level => g_log_level_statement,
497 p_run_log_level => l_log_level
498 );
499 End if;
500
501 l_rj_op_reason_codes_tbl.delete;
502 l_counter := p_wltx_resulting_jobs_tbl.first;
503 l_rj_tbl_counter := 1;
504
505 -- forall the no-SpUA resulting jobs (not present also as a starting job, create the reason code information in PL/SQL tables)
506 -- and do a bulk insert at the end
507 while l_counter IS NOT NULL and l_sj_op_reason_codes_tbl.count > 0 LOOP
508
509 IF ( p_wltx_header.transaction_type_id = WSMPCNST.MERGE OR
510 ( p_wltx_header.transaction_type_id = WSMPCNST.SPLIT AND p_wltx_resulting_jobs_tbl(l_counter).split_has_update_assy <> 1)
511 ) AND
512 ( l_counter <> nvl(p_sj_also_rj_index,-1) )
513 -- Resulting Job shouldnt be a starting job
514 THEN
515 l_index := l_sj_op_reason_codes_tbl.first;
516 WHILE l_index is not NULL LOOP
517 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).wip_entity_id := p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id;
518 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).OPERATION_SEQ_NUM := l_sj_op_reason_codes_tbl(l_index).operation_seq_num;
519 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).code_type := l_sj_op_reason_codes_tbl(l_index).code_type;
520
521 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).reason_code := l_sj_op_reason_codes_tbl(l_index).reason_code;
522 -- Bug 5458450 Reason Code quantity should not be propagated to child jobs.Commented out next line
523
524 -- l_rj_op_reason_codes_tbl(l_rj_tbl_counter).quantity := p_wltx_resulting_jobs_tbl(l_counter).start_quantity;
525
526 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).Created_by := fnd_global.user_id;
527 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).Last_update_date := sysdate;
528 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).Last_updated_by := fnd_global.user_id;
529 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).Creation_date := sysdate;
530 l_rj_op_reason_codes_tbl(l_rj_tbl_counter).Last_updated_login := fnd_global.login_id;
531
532 l_rj_tbl_counter := l_rj_tbl_counter + 1;
533 l_index := l_sj_op_reason_codes_tbl.next(l_index);
534 END LOOP;
535 END IF;
536 l_counter := p_wltx_resulting_jobs_tbl.next(l_counter);
537 END LOOP;
538
539 -- Bulk insert now...
540 IF l_rj_op_reason_codes_tbl.count > 0 then
541 if( g_log_level_statement >= l_log_level ) then
542 l_msg_tokens.delete;
543 WSM_log_PVT.logMessage(p_module_name => l_module ,
544 p_msg_text => 'Resulting Jobs Reason codes count : ' || l_rj_op_reason_codes_tbl.count,
545 p_stmt_num => l_stmt_num ,
546 p_msg_tokens => l_msg_tokens,
547 p_fnd_log_level => g_log_level_statement,
548 p_run_log_level => l_log_level
549 );
550 End if;
551 forall i in indices of l_rj_op_reason_codes_tbl
552 insert into wsm_op_reason_codes
553 values l_rj_op_reason_codes_tbl(i);
554
555 END IF;
556
557 if( g_log_level_statement >= l_log_level ) then
558 l_msg_tokens.delete;
559 WSM_log_PVT.logMessage(p_module_name => l_module ,
560 p_msg_text => 'Processing Reason codes for non-SpUA and Merge resulting Jobs done',
561 p_stmt_num => l_stmt_num ,
562 p_msg_tokens => l_msg_tokens,
563 p_fnd_log_level => g_log_level_statement,
564 p_run_log_level => l_log_level
565 );
566 End if;
567 END IF;
568
569 -- Back to Secondary Quantities processing for Jobs with New Operation.....
570 -- now handle bonus.Insert skeletal data in both job level and op level tables as for job
571 -- we are calling option 1 code so LBJ proc wont insert elementary sec qty data
572
573 -- Call the WSMOPRNB procedure for BONUS,UPDATE_ASSEMBLY, SpUA and UPDATE_ROUTING transactions
574 -- to fill in data from the WSM_JOB_SECONDARY_QUANTITIES into ... WSM_OP_SECONDARY_QUANTITIES
575 IF p_wltx_header.transaction_type_id IN (WSMPCNST.BONUS,WSMPCNST.UPDATE_ASSEMBLY,WSMPCNST.UPDATE_ROUTING,WSMPCNST.SPLIT) THEN
576 l_counter := p_wltx_resulting_jobs_tbl.first;
577 while l_counter IS NOT NULL LOOP
578 IF (p_wltx_header.transaction_type_id <> WSMPCNST.SPLIT) OR
579 (p_wltx_header.transaction_type_id = WSMPCNST.SPLIT and p_wltx_resulting_jobs_tbl(l_counter).split_has_update_assy = 1)
580 THEN
581 l_stmt_num := 130;
582 -- In case of bonus we'll have to create the skeletal data and then invoke the OPRNB code
583 IF p_wltx_header.transaction_type_id = WSMPCNST.BONUS THEN
584 insert into wsm_job_secondary_quantities
585 ( wip_entity_id
586 ,organization_id
587 ,uom_code
588 ,start_quantity
589 ,current_quantity
590 ,currently_active
591 ,last_update_date
592 ,last_updated_by
593 ,last_update_login
594 ,creation_date
595 ,created_by
596 )
597 (select
598 p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id,
599 p_wltx_resulting_jobs_tbl(l_counter).organization_id,
600 uom_code,
601 null,
602 null,
603 1,
604 sysdate,
605 fnd_global.user_id,
606 fnd_global.login_id,
607 sysdate,
608 fnd_global.user_id
609 from wsm_secondary_uoms
610 where inventory_item_id = p_wltx_resulting_jobs_tbl(l_counter).primary_item_id
611 );
612
613 if( g_log_level_statement >= l_log_level ) then
614 l_msg_tokens.delete;
615 WSM_log_PVT.logMessage(p_module_name => l_module ,
616 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' new rows in in job secondary quantities tables for bonus',
617 p_stmt_num => l_stmt_num ,
618 p_msg_tokens => l_msg_tokens,
619 p_fnd_log_level => g_log_level_statement,
620 p_run_log_level => l_log_level
621 );
622 End if;
623
624 END IF;
625
626 l_stmt_num := 130;
627 -- Invoke the OPRNB code now.
628 WSMPOPRN.copy_to_op_mes_info ( p_wip_entity_id => p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id ,
629 p_to_job_op_seq_num => p_wltx_resulting_jobs_tbl(l_counter).job_operation_seq_num ,
630 p_to_rtg_op_seq_num => p_wltx_resulting_jobs_tbl(l_counter).starting_operation_seq_num ,
631 p_txn_quantity => p_wltx_resulting_jobs_tbl(l_counter).start_quantity ,
632 p_user => fnd_global.user_id ,
633 p_login => fnd_global.login_id ,
634 x_return_status => x_return_status ,
635 x_msg_count => x_msg_count ,
636 x_msg_data => x_error_msg
637 );
638 -- Once this call is over the data for the new operation would be copied...
639 if x_return_status <> G_RET_SUCCESS then
640 IF x_return_status = G_RET_ERROR THEN
641 raise FND_API.G_EXC_ERROR;
642 ELSE
643 raise FND_API.G_EXC_UNEXPECTED_ERROR;
644 END IF;
645 end if;
646 END IF;
647 l_counter := p_wltx_resulting_jobs_tbl.next(l_counter);
648 END LOOP;
649 end if;
650
651 if( g_log_level_statement >= l_log_level ) then
652 l_msg_tokens.delete;
653 WSM_log_PVT.logMessage(p_module_name => l_module ,
654 p_msg_text => 'Processing Secondary Qty and Reason codes for SpUA Split and Upd Assy and Upd Rtg Jobs done',
655 p_stmt_num => l_stmt_num ,
656 p_msg_tokens => l_msg_tokens,
657 p_fnd_log_level => g_log_level_statement,
658 p_run_log_level => l_log_level
659 );
660 End if;
661
662 -- ST : Sec. UOM Fix : Moved this to the end.. Populate history information once every thing is done..
663 --History info for resulting job.
664 l_stmt_num := 140;
665 l_wsm_rj_sec_qty_tbl.delete;
666 l_job_qty_tbl.delete;
667 l_rj_tbl_counter := 1;
668
669 l_counter := p_wltx_resulting_jobs_tbl.first;
670 while l_counter is not null loop
671
672 select *
673 bulk collect into l_job_qty_tbl
674 from wsm_job_secondary_quantities
675 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id
676 and currently_active= 1;
677
678 -- now populate the local pl/sql table
679 if l_job_qty_tbl.count > 0 then
680 l_index := l_job_qty_tbl.first;
681 while l_index is not null loop
682
683 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).wip_entity_id := l_job_qty_tbl(l_index).wip_entity_id;
684 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).uom_code := l_job_qty_tbl(l_index).uom_code;
685 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).quantity := l_job_qty_tbl(l_index).current_quantity;
686 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).organization_id := l_job_qty_tbl(l_index).organization_id;
687 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).transaction_id := p_wltx_header.transaction_id;
688 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).last_update_date := sysdate;
689 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).last_update_login := fnd_global.login_id;
690 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).last_updated_by := fnd_global.user_id;
691 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).creation_date := sysdate;
692 l_wsm_rj_sec_qty_tbl(l_rj_tbl_counter).created_by := fnd_global.user_id;
693
694 l_rj_tbl_counter := l_rj_tbl_counter+1;
695 l_index := l_job_qty_tbl.next(l_index);
696 end loop;
697 end if;
698 l_counter := p_wltx_resulting_jobs_tbl.next(l_counter);
699 end loop;
700
701 if l_wsm_rj_sec_qty_tbl.count > 0 then
702 forall i in indices of l_wsm_rj_sec_qty_tbl
703 insert into wsm_rj_secondary_quantities
704 values l_wsm_rj_sec_qty_tbl(i);
705 end if;
706
707 if( g_log_level_statement >= l_log_level ) then
708 l_msg_tokens.delete;
709 WSM_log_PVT.logMessage(p_module_name => l_module ,
710 p_msg_text => 'History Information for Resulting Jobs Done',
711 p_stmt_num => l_stmt_num ,
712 p_msg_tokens => l_msg_tokens,
713 p_fnd_log_level => g_log_level_statement,
714 p_run_log_level => l_log_level
715 );
716 End if;
717
718 x_return_status := FND_API.G_RET_STS_SUCCESS;
719
720 EXCEPTION
721 WHEN FND_API.G_EXC_ERROR THEN
722 ROLLBACK TO start_secondary_quantities;
723 x_return_status := G_RET_ERROR;
724 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
725 p_count => x_msg_count ,
726 p_data => x_error_msg
727 );
728
729 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
730 ROLLBACK TO start_secondary_quantities;
731 x_return_status := G_RET_UNEXPECTED;
732 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
733 p_count => x_msg_count ,
734 p_data => x_error_msg
735 );
736 WHEN OTHERS THEN
737
738 ROLLBACK TO start_secondary_quantities;
739 x_return_status := G_RET_UNEXPECTED;
740
741 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
742 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
743 THEN
744 WSM_log_PVT.handle_others( p_module_name => l_module ,
745 p_stmt_num => l_stmt_num ,
746 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
747 p_run_log_level => l_log_level
748 );
749 END IF;
750 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
751 p_count => x_msg_count ,
752 p_data => x_error_msg
753 );
754 END;
755
756 /************** Commenting out due to few discrepancies in the code...
757 Reason code information is handled if the process_mes_info
758 PROCEDURE copy_wsm_op_reason_codes ( p_wltx_header IN WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
759 p_wltx_starting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
760 p_wltx_resulting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
761 p_rep_job_index IN NUMBER,
762 p_sj_also_rj_index IN NUMBER,
763 x_return_status OUT NOCOPY VARCHAR2,
764 x_msg_count OUT NOCOPY NUMBER,
765 x_error_msg OUT NOCOPY VARCHAR2)
766 IS
767
768 l_sj_we_id NUMBER ;
769 l_wsm_op_reason_codes_tbl t_wsm_op_reason_codes_tbl;
770
771 l_counter number;
772 g_code_type_bonus CONSTANT NUMBER := 1 ;
773 g_code_type_scrap CONSTANT NUMBER := 2 ;
774
775 -- Logging variables.....
776 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
777 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
778 l_stmt_num NUMBER;
779 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.copy_wsm_op_reason_codes';
780
781 BEGIN
782
783 savepoint start_copy_wsm_op_reason_codes;
784
785 x_return_status := FND_API.G_RET_STS_SUCCESS;
786
787 l_stmt_num := 10;
788
789 if p_sj_also_rj_index is null then
790 l_counter := p_wltx_starting_jobs_tbl.first;
791 l_sj_we_id := p_wltx_starting_jobs_tbl(l_counter).wip_entity_id;
792 else
793 l_sj_we_id := p_wltx_resulting_jobs_tbl(p_sj_also_rj_index).wip_entity_id;
794 end if;
795
796 l_stmt_num := 20;
797 If p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE) then
798 for i in p_wltx_resulting_jobs_tbl.first .. p_wltx_resulting_jobs_tbl.last loop
799 if p_wltx_resulting_jobs_tbl(i).split_has_update_assy <>1 then
800 l_wsm_op_reason_codes_tbl.delete;
801 BEGIN
802 select *
803 bulk collect into l_wsm_op_reason_codes_tbl
804 from wsm_op_reason_codes
805 where operation_seq_num = p_wltx_resulting_jobs_tbl(i).starting_operation_seq_num
806 and wip_entity_id = l_sj_we_id
807 and p_wltx_resulting_jobs_tbl(i).wip_entity_id <> l_sj_we_id;
808 EXCEPTION
809 when no_data_found then
810 null;
811 END;
812 if l_wsm_op_reason_codes_tbl.count > 0 then
813 for j in l_wsm_op_reason_codes_tbl.first .. l_wsm_op_reason_codes_tbl.last loop
814 l_wsm_op_reason_codes_tbl(j).wip_entity_id := p_wltx_resulting_jobs_tbl(i).wip_entity_id;
815 l_wsm_op_reason_codes_tbl(j).Created_by := fnd_global.user_id;
816 l_wsm_op_reason_codes_tbl(j).Last_update_date := sysdate;
817 l_wsm_op_reason_codes_tbl(j).Last_updated_by := fnd_global.user_id;
818 l_wsm_op_reason_codes_tbl(j).Creation_date := sysdate;
819 l_wsm_op_reason_codes_tbl(j).Last_updated_login := fnd_global.login_id;
820 end loop;
821 end if;
822 if l_wsm_op_reason_codes_tbl.count > 0 then
823 forall k in l_wsm_op_reason_codes_tbl.first .. l_wsm_op_reason_codes_tbl.last
824 insert into wsm_op_reason_codes
825 values l_wsm_op_reason_codes_tbl(k);
826 end if;
827 end if;
828 end loop;
829 end if;
830
831 l_stmt_num := 30;
832 -- This will be handled by the call to OPRNB.copy_mes procedure in the secondary_quantities procedure..
833 if p_wltx_header.transaction_type_id = WSMPCNST.BONUS then
834 --query bom_standard_operations child table and populate reason codes for the new op.;
835 l_counter := p_wltx_resulting_jobs_tbl.first;
836 insert into wsm_op_reason_codes
837 (Organization_id,
838 Wip_entity_id ,
839 Operation_seq_num,
840 Code_Type ,
841 Reason_Code ,
842 Quantity ,
843 Created_by ,
844 Last_update_date,
845 Last_updated_by ,
846 Creation_date ,
847 Last_updated_login
848 )
849 (select
850 p_wltx_resulting_jobs_tbl(l_counter).organization_id,
851 p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id,
852 bsobc.sequence_number,
853 1,
854 bsobc.bonus_code,
855 null,
856 fnd_global.user_id,
857 sysdate,
858 fnd_global.user_id,
859 sysdate,
860 fnd_global.login_id
861 from bom_std_op_bonus_codes bsobc
862 where sequence_number = p_wltx_resulting_jobs_tbl(l_counter).starting_operation_seq_num
863 and STANDARD_OPERATION_ID = p_wltx_resulting_jobs_tbl(l_counter).starting_std_op_id
864 );
865
866 insert into wsm_op_reason_codes
867 (Organization_id,
868 Wip_entity_id ,
869 Operation_seq_num,
870 Code_Type ,
871 Reason_Code ,
872 Quantity ,
873 Created_by ,
874 Last_update_date,
875 Last_updated_by ,
876 Creation_date ,
877 Last_updated_login
878 )
879 (select
880 p_wltx_resulting_jobs_tbl(l_counter).organization_id,
881 p_wltx_resulting_jobs_tbl(l_counter).wip_entity_id,
882 bsosc.sequence_num,
883 2,
884 bsosc.scrap_code,
885 null,
886 fnd_global.user_id,
887 sysdate,
888 fnd_global.user_id,
889 sysdate,
890 fnd_global.login_id
891 from bom_std_op_scrap_codes bsosc
892 where sequence_num = p_wltx_resulting_jobs_tbl(l_counter).starting_operation_seq_num
893 and STANDARD_OPERATION_ID = p_wltx_resulting_jobs_tbl(l_counter).starting_std_op_id
894 );
895 end if;
896 x_return_status := FND_API.G_RET_STS_SUCCESS;
897
898 EXCEPTION
899 WHEN FND_API.G_EXC_ERROR THEN
900
901 ROLLBACK TO start_copy_wsm_op_reason_codes;
902
903 x_return_status := G_RET_ERROR;
904 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
905 p_count => x_msg_count ,
906 p_data => x_error_msg
907 );
908
909 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
910
911 ROLLBACK TO start_copy_wsm_op_reason_codes;
912
913 x_return_status := G_RET_UNEXPECTED;
914 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
915 p_count => x_msg_count ,
916 p_data => x_error_msg
917 );
918 WHEN OTHERS THEN
919
920 ROLLBACK TO start_copy_wsm_op_reason_codes;
921
922 x_return_status := G_RET_UNEXPECTED;
923 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
924 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
925 THEN
926 WSM_log_PVT.handle_others( p_module_name => l_module ,
927 p_stmt_num => l_stmt_num ,
928 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
929 p_run_log_level => l_log_level
930 );
931 END IF;
932 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
933 p_count => x_msg_count ,
934 p_data => x_error_msg
935 );
936 END ;
937 *************************************************************/
938 /*** Commenting out : Descoped..
939 PROCEDURE copy_wsm_substitute_components ( p_wltx_header IN WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
940 p_wltx_starting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
941 p_wltx_resulting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
942 p_rep_job_index IN NUMBER,
943 x_return_status OUT NOCOPY VARCHAR2,
944 x_msg_count OUT NOCOPY NUMBER,
945 x_error_msg OUT NOCOPY VARCHAR2)
946 IS
947
948
949 l_sj_we_id NUMBER := p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).wip_entity_id;
950
951 l_wsm_copy_requirement_ops_tbl t_wsm_copy_requirement_ops_tbl;
952 l_wsm_subst_comp_tbl t_wsm_subst_comp_tbl;
953
954 l_counter NUMBER;
955
956 -- Logging variables.....
957 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
958 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
959
960 l_stmt_num NUMBER;
961 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.copy_wsm_substitute_components';
962
963
964 BEGIN
965 savepoint start_copy_wsm_subst_comp;
966
967 x_return_status := FND_API.G_RET_STS_SUCCESS;
968
969 l_stmt_num := 10;
970
971 If p_wltx_starting_jobs_tbl(p_rep_job_index).intraoperation_step = 1 then
972 If p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE,WSMPCNST.BONUS) then
973 --Copy parents substitute components info to new child jobs.For parent jobs,it shld be already populated.
974 for i in p_wltx_resulting_jobs_tbl.first .. p_wltx_resulting_jobs_tbl.last loop
975 if p_wltx_resulting_jobs_tbl (i).split_has_update_assy <>1 then
976 BEGIN
977 select *
978 bulk collect into l_wsm_copy_requirement_ops_tbl
979 from wsm_copy_requirement_ops
980 where wip_entity_id = p_wltx_resulting_jobs_tbl(i).wip_entity_id
981 and recommended = 'N'
982 and operation_seq_num = p_wltx_resulting_jobs_tbl(i).starting_operation_seq_num
983 and wip_entity_id <> nvl(l_sj_we_id,-1);
984 EXCEPTION
985 when no_data_found then
986 null;
987 END;
988
989 l_wsm_subst_comp_tbl.delete;
990
991 if l_wsm_copy_requirement_ops_tbl.count>0 then
992 for j in l_wsm_copy_requirement_ops_tbl.first .. l_wsm_copy_requirement_ops_tbl.last loop
993 l_wsm_subst_comp_tbl(j).WIP_ENTITY_ID := l_wsm_copy_requirement_ops_tbl(j).WIP_ENTITY_ID;
994 l_wsm_subst_comp_tbl(j).OPERATION_SEQ_NUM := l_wsm_copy_requirement_ops_tbl(j).OPERATION_SEQ_NUM ;
995 l_wsm_subst_comp_tbl(j).COMPONENT_ITEM_ID := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_ITEM_ID ;
996 l_wsm_subst_comp_tbl(j).PRIMARY_COMPONENT_ID := l_wsm_copy_requirement_ops_tbl(j).PRIMARY_COMPONENT_ID ;
997 l_wsm_subst_comp_tbl(j).COMPONENT_SEQUENCE_ID := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_SEQUENCE_ID ;
998 l_wsm_subst_comp_tbl(j).DATE_REQUIRED := l_wsm_copy_requirement_ops_tbl(j).RECO_DATE_REQUIRED ;
999 l_wsm_subst_comp_tbl(j).BILL_SEQUENCE_ID := l_wsm_copy_requirement_ops_tbl(j).BILL_SEQUENCE_ID ;
1000 l_wsm_subst_comp_tbl(j).DEPARTMENT_ID := l_wsm_copy_requirement_ops_tbl(j).DEPARTMENT_ID ;
1001 l_wsm_subst_comp_tbl(j).ORGANIZATION_ID := l_wsm_copy_requirement_ops_tbl(j).ORGANIZATION_ID ;
1002 l_wsm_subst_comp_tbl(j).WIP_SUPPLY_TYPE := l_wsm_copy_requirement_ops_tbl(j).WIP_SUPPLY_TYPE ;
1003 l_wsm_subst_comp_tbl(j).SUPPLY_SUBINVENTORY := l_wsm_copy_requirement_ops_tbl(j).SUPPLY_SUBINVENTORY ;
1004 l_wsm_subst_comp_tbl(j).SUPPLY_LOCATOR_ID := l_wsm_copy_requirement_ops_tbl(j).SUPPLY_LOCATOR_ID ;
1005 l_wsm_subst_comp_tbl(j).QUANTITY_PER_ASSEMBLY := l_wsm_copy_requirement_ops_tbl(j).QUANTITY_PER_ASSEMBLY ;
1006 l_wsm_subst_comp_tbl(j).BILL_QUANTITY_PER_ASSEMBLY := l_wsm_copy_requirement_ops_tbl(j).BILL_QUANTITY_PER_ASSEMBLY;
1007 l_wsm_subst_comp_tbl(j).COMPONENT_YIELD_FACTOR := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_YIELD_FACTOR ;
1008 l_wsm_subst_comp_tbl(j).EFFECTIVITY_DATE := l_wsm_copy_requirement_ops_tbl(j).EFFECTIVITY_DATE ;
1009 l_wsm_subst_comp_tbl(j).DISABLE_DATE := l_wsm_copy_requirement_ops_tbl(j).DISABLE_DATE ;
1010 l_wsm_subst_comp_tbl(j).COMPONENT_PRIORITY := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_PRIORITY ;
1011 l_wsm_subst_comp_tbl(j).PARENT_BILL_SEQ_ID := l_wsm_copy_requirement_ops_tbl(j).PARENT_BILL_SEQ_ID ;
1012 l_wsm_subst_comp_tbl(j).ITEM_NUM := l_wsm_copy_requirement_ops_tbl(j).ITEM_NUM ;
1013 l_wsm_subst_comp_tbl(j).COMPONENT_REMARKS := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_REMARKS ;
1014 l_wsm_subst_comp_tbl(j).CHANGE_NOTICE := l_wsm_copy_requirement_ops_tbl(j).CHANGE_NOTICE ;
1015 l_wsm_subst_comp_tbl(j).IMPLEMENTATION_DATE := l_wsm_copy_requirement_ops_tbl(j).IMPLEMENTATION_DATE ;
1016 l_wsm_subst_comp_tbl(j).PLANNING_FACTOR := l_wsm_copy_requirement_ops_tbl(j).PLANNING_FACTOR ;
1017 l_wsm_subst_comp_tbl(j).QUANTITY_RELATED := l_wsm_copy_requirement_ops_tbl(j).QUANTITY_RELATED ;
1018 l_wsm_subst_comp_tbl(j).SO_BASIS := l_wsm_copy_requirement_ops_tbl(j).SO_BASIS ;
1019 l_wsm_subst_comp_tbl(j).OPTIONAL := l_wsm_copy_requirement_ops_tbl(j).OPTIONAL ;
1020 l_wsm_subst_comp_tbl(j).MUTUALLY_EXCLUSIVE_OPTIONS := l_wsm_copy_requirement_ops_tbl(j).MUTUALLY_EXCLUSIVE_OPTIONS;
1021 l_wsm_subst_comp_tbl(j).INCLUDE_IN_COST_ROLLUP := l_wsm_copy_requirement_ops_tbl(j).INCLUDE_IN_COST_ROLLUP ;
1022 l_wsm_subst_comp_tbl(j).CHECK_ATP := l_wsm_copy_requirement_ops_tbl(j).CHECK_ATP ;
1023 l_wsm_subst_comp_tbl(j).SHIPPING_ALLOWED := l_wsm_copy_requirement_ops_tbl(j).SHIPPING_ALLOWED ;
1024 l_wsm_subst_comp_tbl(j).REQUIRED_TO_SHIP := l_wsm_copy_requirement_ops_tbl(j).REQUIRED_TO_SHIP ;
1025 l_wsm_subst_comp_tbl(j).REQUIRED_FOR_REVENUE := l_wsm_copy_requirement_ops_tbl(j).REQUIRED_FOR_REVENUE ;
1026 l_wsm_subst_comp_tbl(j).INCLUDE_ON_SHIP_DOCS := l_wsm_copy_requirement_ops_tbl(j).INCLUDE_ON_SHIP_DOCS ;
1027 l_wsm_subst_comp_tbl(j).LOW_QUANTITY := l_wsm_copy_requirement_ops_tbl(j).LOW_QUANTITY ;
1028 l_wsm_subst_comp_tbl(j).HIGH_QUANTITY := l_wsm_copy_requirement_ops_tbl(j).HIGH_QUANTITY ;
1029 l_wsm_subst_comp_tbl(j).ACD_TYPE := l_wsm_copy_requirement_ops_tbl(j).ACD_TYPE ;
1030 l_wsm_subst_comp_tbl(j).OLD_COMPONENT_SEQUENCE_ID := l_wsm_copy_requirement_ops_tbl(j).OLD_COMPONENT_SEQUENCE_ID;
1031 l_wsm_subst_comp_tbl(j).OPERATION_LEAD_TIME_PERCENT := l_wsm_copy_requirement_ops_tbl(j).OPERATION_LEAD_TIME_PERCENT;
1032 l_wsm_subst_comp_tbl(j).REVISED_ITEM_SEQUENCE_ID := l_wsm_copy_requirement_ops_tbl(j).REVISED_ITEM_SEQUENCE_ID ;
1033 l_wsm_subst_comp_tbl(j).BOM_ITEM_TYPE := l_wsm_copy_requirement_ops_tbl(j).BOM_ITEM_TYPE ;
1034 l_wsm_subst_comp_tbl(j).FROM_END_ITEM_UNIT_NUMBER := l_wsm_copy_requirement_ops_tbl(j).FROM_END_ITEM_UNIT_NUMBER ;
1035 l_wsm_subst_comp_tbl(j).TO_END_ITEM_UNIT_NUMBER := l_wsm_copy_requirement_ops_tbl(j).TO_END_ITEM_UNIT_NUMBER ;
1036 l_wsm_subst_comp_tbl(j).ECO_FOR_PRODUCTION := l_wsm_copy_requirement_ops_tbl(j).ECO_FOR_PRODUCTION ;
1037 l_wsm_subst_comp_tbl(j).ENFORCE_INT_REQUIREMENTS := l_wsm_copy_requirement_ops_tbl(j).ENFORCE_INT_REQUIREMENTS ;
1038 l_wsm_subst_comp_tbl(j).DELETE_GROUP_NAME := l_wsm_copy_requirement_ops_tbl(j).DELETE_GROUP_NAME ;
1039 l_wsm_subst_comp_tbl(j).DG_DESCRIPTION := l_wsm_copy_requirement_ops_tbl(j).DG_DESCRIPTION ;
1040 l_wsm_subst_comp_tbl(j).OPTIONAL_ON_MODEL := l_wsm_copy_requirement_ops_tbl(j).OPTIONAL_ON_MODEL ;
1041 l_wsm_subst_comp_tbl(j).MODEL_COMP_SEQ_ID := l_wsm_copy_requirement_ops_tbl(j).MODEL_COMP_SEQ_ID ;
1042 l_wsm_subst_comp_tbl(j).PLAN_LEVEL := l_wsm_copy_requirement_ops_tbl(j).PLAN_LEVEL ;
1043 l_wsm_subst_comp_tbl(j).AUTO_REQUEST_MATERIAL := l_wsm_copy_requirement_ops_tbl(j).AUTO_REQUEST_MATERIAL ;
1044 l_wsm_subst_comp_tbl(j).COMPONENT_ITEM_REVISION_ID := l_wsm_copy_requirement_ops_tbl(j).COMPONENT_ITEM_REVISION_ID;
1045 l_wsm_subst_comp_tbl(j).FROM_BILL_REVISION_ID := l_wsm_copy_requirement_ops_tbl(j).FROM_BILL_REVISION_ID ;
1046 l_wsm_subst_comp_tbl(j).TO_BILL_REVISION_ID := l_wsm_copy_requirement_ops_tbl(j).TO_BILL_REVISION_ID ;
1047 l_wsm_subst_comp_tbl(j).PICK_COMPONENTS := l_wsm_copy_requirement_ops_tbl(j).PICK_COMPONENTS ;
1048 l_wsm_subst_comp_tbl(j).INCLUDE_ON_BILL_DOCS := l_wsm_copy_requirement_ops_tbl(j).INCLUDE_ON_BILL_DOCS ;
1049 l_wsm_subst_comp_tbl(j).COST_FACTOR := l_wsm_copy_requirement_ops_tbl(j).COST_FACTOR ;
1050 l_wsm_subst_comp_tbl(j).LAST_UPDATE_DATE := l_wsm_copy_requirement_ops_tbl(j).LAST_UPDATE_DATE ;
1051 l_wsm_subst_comp_tbl(j).LAST_UPDATED_BY := l_wsm_copy_requirement_ops_tbl(j).LAST_UPDATED_BY ;
1052 l_wsm_subst_comp_tbl(j).LAST_UPDATED_LOGIN := l_wsm_copy_requirement_ops_tbl(j).LAST_UPDATE_LOGIN ;
1053 l_wsm_subst_comp_tbl(j).CREATION_DATE := l_wsm_copy_requirement_ops_tbl(j).CREATION_DATE ;
1054 l_wsm_subst_comp_tbl(j).CREATED_BY := l_wsm_copy_requirement_ops_tbl(j).CREATED_BY ;
1055 l_wsm_subst_comp_tbl(j).ATTRIBUTE_CATEGORY := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE_CATEGORY ;
1056 l_wsm_subst_comp_tbl(j).ATTRIBUTE1 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE1 ;
1057 l_wsm_subst_comp_tbl(j).ATTRIBUTE2 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE2 ;
1058 l_wsm_subst_comp_tbl(j).ATTRIBUTE3 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE3 ;
1059 l_wsm_subst_comp_tbl(j).ATTRIBUTE4 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE4 ;
1060 l_wsm_subst_comp_tbl(j).ATTRIBUTE5 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE5 ;
1061 l_wsm_subst_comp_tbl(j).ATTRIBUTE6 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE6 ;
1062 l_wsm_subst_comp_tbl(j).ATTRIBUTE7 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE7 ;
1063 l_wsm_subst_comp_tbl(j).ATTRIBUTE8 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE8 ;
1064 l_wsm_subst_comp_tbl(j).ATTRIBUTE9 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE9 ;
1065 l_wsm_subst_comp_tbl(j).ATTRIBUTE10 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE10 ;
1066 l_wsm_subst_comp_tbl(j).ATTRIBUTE11 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE11 ;
1067 l_wsm_subst_comp_tbl(j).ATTRIBUTE12 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE12 ;
1068 l_wsm_subst_comp_tbl(j).ATTRIBUTE13 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE13 ;
1069 l_wsm_subst_comp_tbl(j).ATTRIBUTE14 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE14 ;
1070 l_wsm_subst_comp_tbl(j).ATTRIBUTE15 := l_wsm_copy_requirement_ops_tbl(j).ATTRIBUTE15 ;
1071 l_wsm_subst_comp_tbl(j).ORIGINAL_SYSTEM_REFERENCE := l_wsm_copy_requirement_ops_tbl(j).ORIGINAL_SYSTEM_REFERENCE ;
1072 end loop;
1073 end if;
1074
1075 if l_wsm_subst_comp_tbl.count>0 then
1076 forall k in l_wsm_subst_comp_tbl.first .. l_wsm_subst_comp_tbl.last
1077 insert into WSM_SUBSTITUTE_COMPONENTS
1078 values l_wsm_subst_comp_tbl(k);
1079 end if;
1080
1081 end if;
1082 end loop;
1083 end if;
1084 end if;
1085
1086 x_return_status := FND_API.G_RET_STS_SUCCESS;
1087
1088 EXCEPTION
1089 WHEN FND_API.G_EXC_ERROR THEN
1090
1091 ROLLBACK TO start_copy_wsm_subst_comp;
1092
1093 x_return_status := G_RET_ERROR;
1094 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1095 p_count => x_error_msg ,
1096 p_data => x_msg_count
1097 );
1098
1099 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1100
1101 ROLLBACK TO start_copy_wsm_subst_comp;
1102
1103 x_return_status := G_RET_UNEXPECTED;
1104 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1105 p_count => x_error_msg ,
1106 p_data => x_msg_count
1107 );
1108 WHEN OTHERS THEN
1109
1110 ROLLBACK TO start_copy_wsm_subst_comp;
1111
1112 x_return_status := G_RET_UNEXPECTED;
1113 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1114 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1115 THEN
1116 WSM_log_PVT.handle_others( p_module_name => l_module ,
1117 p_stmt_num => l_stmt_num ,
1118 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1119 p_run_log_level => l_log_level
1120 );
1121 END IF;
1122
1123 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
1124 p_count => x_error_msg ,
1125 p_data => x_msg_count
1126 );
1127
1128 END;
1129 */
1130
1131 PROCEDURE GET_JOB_CURR_OP_INFO(p_wip_entity_id IN NUMBER,
1132 p_op_seq_num OUT NOCOPY NUMBER,
1133 p_op_seq_id OUT NOCOPY NUMBER,
1134 p_std_op_id OUT NOCOPY NUMBER,
1135 p_intra_op OUT NOCOPY NUMBER,
1136 p_dept_id OUT NOCOPY NUMBER,
1137 p_op_qty OUT NOCOPY NUMBER,
1138 p_op_start_date OUT NOCOPY DATE,
1139 p_op_completion_date OUT NOCOPY DATE,
1140 x_err_code OUT NOCOPY NUMBER,
1141 x_err_buf OUT NOCOPY VARCHAR2,
1142 x_msg_count OUT NOCOPY NUMBER)
1143 IS
1144
1145 l_qty_Q NUMBER;
1146 l_qty_RUN NUMBER;
1147 l_qty_TM NUMBER;
1148
1149 -- Logging variables.....
1150 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1151 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1152
1153 l_stmt_num NUMBER;
1154 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.GET_JOB_CURR_OP_INFO';
1155
1156
1157 BEGIN
1158
1159 p_op_qty := 0;
1160
1161 l_stmt_num := 10;
1162
1163 SELECT max(operation_seq_num)
1164 INTO p_op_seq_num
1165 FROM wip_operations
1166 WHERE wip_entity_id = p_wip_entity_id
1167 AND ((quantity_in_queue <> 0
1168 OR quantity_running <> 0
1169 OR quantity_waiting_to_move <> 0)
1170 OR (quantity_in_queue = 0
1171 and quantity_running = 0
1172 and quantity_waiting_to_move = 0
1173 and quantity_scrapped = quantity_completed -- this picks up te max op seq, if only scraps at ops
1174 and quantity_completed > 0));
1175
1176 l_stmt_num := 20;
1177
1178 SELECT operation_sequence_id,
1179 standard_operation_id,
1180 department_id,
1181 quantity_in_queue,
1182 quantity_running,
1183 quantity_waiting_to_move,
1184 first_unit_start_date,
1185 last_unit_completion_date
1186 INTO p_op_seq_id,
1187 p_std_op_id,
1188 p_dept_id,
1189 l_qty_Q,
1190 l_qty_RUN,
1191 l_qty_TM,
1192 p_op_start_date,
1193 p_op_completion_date
1194 FROM wip_operations
1195 WHERE wip_entity_id = p_wip_entity_id
1196 AND operation_seq_num = p_op_seq_num;
1197
1198
1199 IF l_qty_Q > 0 THEN
1200 p_intra_op := 1;
1201 p_op_qty := l_qty_Q;
1202 ELSIF l_qty_TM > 0 THEN
1203 p_intra_op := 3;
1204 p_op_qty := l_qty_TM;
1205 ELSIF l_qty_RUN > 0 THEN
1206 x_err_code := -1;
1207 x_err_buf := 'WSMPJUPD.GET_JOB_CURR_OP_INFO('||to_char(l_stmt_num)||'): Incorrect job status for this transaction';
1208
1209 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
1210
1211 l_msg_tokens.delete;
1212 WSM_log_PVT.logMessage(p_module_name => l_module ,
1213 p_msg_text => x_err_buf ,
1214 p_stmt_num => l_stmt_num ,
1215 p_msg_tokens => l_msg_tokens,
1216 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1217 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1218 p_run_log_level => l_log_level
1219 );
1220 END IF;
1221 RAISE FND_API.G_EXC_ERROR;
1222
1223 ELSIF (l_qty_Q = 0) AND (l_qty_RUN = 0) AND (l_qty_TM = 0) THEN
1224 p_intra_op := 5;
1225 ELSE
1226 x_err_code := -1;
1227 x_err_buf := 'WSMPJUPD.GET_JOB_CURR_OP_INFO('||to_char(l_stmt_num)||'): Incorrect job status for this transaction';
1228
1229 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
1230
1231 l_msg_tokens.delete;
1232 WSM_log_PVT.logMessage(p_module_name => l_module ,
1233 p_msg_text => x_err_buf ,
1234 p_stmt_num => l_stmt_num ,
1235 p_msg_tokens => l_msg_tokens,
1236 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1237 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1238 p_run_log_level => l_log_level
1239 );
1240 END IF;
1241 RAISE FND_API.G_EXC_ERROR;
1242
1243 END IF;
1244
1245 l_stmt_num := 30;
1246 x_err_code := 0;
1247 x_err_buf := NULL;
1248
1249 EXCEPTION
1250 WHEN FND_API.G_EXC_ERROR THEN
1251 x_err_code := -1;
1252 x_err_buf := 'WSMPJUPD.GET_JOB_CURR_OP_INFO('||to_char(l_stmt_num)||'): Incorrect job status for this transaction';
1253
1254 WHEN OTHERS THEN
1255 x_err_code := SQLCODE;
1256 x_err_buf := 'WSMPJUPD.GET_JOB_CURR_OP_INFO('||to_char(l_stmt_num)||'): '||substrb(sqlerrm,1,1000);
1257
1258 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1259 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1260 THEN
1261 WSM_log_PVT.handle_others( p_module_name => l_module ,
1262 p_stmt_num => l_stmt_num ,
1263 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1264 p_run_log_level => l_log_level
1265 );
1266 END IF;
1267
1268 END GET_JOB_CURR_OP_INFO;
1269 -- end ......
1270
1271
1272 /*-------------------------------------------------------------+
1273 | Name : COPY_REP_JOB_WO_FA
1274 ---------------------------------------------------------------*/
1275
1276 PROCEDURE COPY_REP_JOB_WO_FA(p_txn_id IN NUMBER,
1277 p_txn_org_id IN NUMBER,
1278 p_new_rj_we_id_tbl IN t_number,
1279 p_new_rj_qty_tbl IN t_number,
1280 p_rep_we_id IN NUMBER,
1281 p_curr_op_seq_num IN NUMBER,
1282 p_curr_op_seq_id IN NUMBER,
1283 p_txn_job_intraop IN NUMBER,
1284 x_err_code OUT NOCOPY NUMBER,
1285 x_err_buf OUT NOCOPY VARCHAR2)
1286 IS
1287
1288 l_op_seq_id_tbl t_number;
1289 l_op_seq_num_tbl t_number;
1290
1291 l_counter1 number;
1292 l_counter2 number;
1293 l_counter number;
1294
1295 -- Logging variables.....
1296 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1297 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1298
1299 l_stmt_num NUMBER;
1300 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.COPY_REP_JOB_WO_FA';
1301 BEGIN
1302
1303 l_stmt_num := 10;
1304
1305 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1306 l_msg_tokens.delete;
1307 WSM_log_PVT.logMessage (p_module_name => l_module ,
1308 p_msg_text => 'Inside COPY_REP_JOB_WO_FA : New Jobs count ' || p_new_rj_we_id_tbl.count
1309 || ' ' || p_curr_op_seq_num || ' ' || p_rep_we_id,
1310 p_stmt_num => l_stmt_num ,
1311 p_msg_tokens => l_msg_tokens ,
1312 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1313 p_run_log_level => l_log_level
1314 );
1315 END IF;
1316
1317 forall l_job_counter in indices of p_new_rj_we_id_tbl
1318 INSERT INTO WIP_OPERATIONS
1319 (wip_entity_id,
1320 operation_seq_num,
1321 organization_id,
1322 repetitive_schedule_id,
1323 last_update_date,
1324 last_updated_by,
1325 creation_date,
1326 created_by,
1327 last_update_login,
1328 request_id,
1329 program_application_id,
1330 program_id,
1331 program_update_date,
1332 operation_sequence_id,
1333 standard_operation_id,
1334 department_id,
1335 description,
1336 scheduled_quantity,
1337 quantity_in_queue,
1338 quantity_running,
1339 quantity_waiting_to_move,
1340 quantity_rejected,
1341 quantity_scrapped,
1342 quantity_completed,
1343 wsm_costed_quantity_completed,
1344 first_unit_start_date,
1345 first_unit_completion_date,
1346 last_unit_start_date,
1347 last_unit_completion_date,
1348 previous_operation_seq_num,
1349 next_operation_seq_num,
1350 count_point_type,
1351 backflush_flag,
1352 minimum_transfer_quantity,
1353 date_last_moved,
1354 attribute_category,
1355 attribute1,
1356 attribute2,
1357 attribute3,
1358 attribute4,
1359 attribute5,
1360 attribute6,
1361 attribute7,
1362 attribute8,
1363 attribute9,
1364 attribute10,
1365 attribute11,
1366 attribute12,
1367 attribute13,
1368 attribute14,
1369 attribute15,
1370 operation_yield_enabled,
1371 operation_yield,
1372 previous_operation_seq_id,
1373 skip_flag, -- Added for I_PROJECT: JUMP_ENH
1374 disable_date, -- bug 2931071
1375 wsm_op_seq_num -- Added to fix bug 3452913
1376 )
1377 (
1378 select
1379 p_new_rj_we_id_tbl(l_job_counter),
1380 wo.operation_seq_num,
1381 wo.organization_id,
1382 wo.repetitive_schedule_id,
1383 wo.last_update_date,
1384 wo.last_updated_by,
1385 wo.creation_date,
1386 wo.created_by,
1387 wo.last_update_login,
1388 wo.request_id,
1389 wo.program_application_id,
1390 wo.program_id,
1391 wo.program_update_date,
1392 wo.operation_sequence_id,
1393 wo.standard_operation_id,
1394 wo.department_id,
1395 wo.description,
1396 -- ST : Added for bug fix 4619823 (Found in UT)
1397 -- (Update Scheduled qty only in case of Current op + Queue)
1398 decode(wo.operation_seq_num, p_curr_op_seq_num,
1399 decode(p_txn_job_intraop,1,p_new_rj_qty_tbl(l_job_counter) ,0),
1400 0),
1401 --scheduled qty behavior change as part of MES, also updated in CHANGE_QUANTITY procedure
1402 decode(wo.quantity_in_queue, 0, 0, p_new_rj_qty_tbl(l_job_counter)),
1403 wo.quantity_running,
1404 decode(wo.quantity_waiting_to_move, 0, 0, p_new_rj_qty_tbl(l_job_counter)),
1405 0, --reject
1406 0, --scrap
1407 0, --qty_completed
1408 -- decode(wo.quantity_completed, 0, 0, p_new_rj_qty_tbl(l_job_counter)),
1409 -- decode(wo.quantity_waiting_to_move, 0, 0, p_new_rj_qty_tbl(l_job_counter)), --Fixed bug #2790626
1410 decode(wo.operation_seq_num, p_curr_op_seq_num,
1411 decode(wo.quantity_waiting_to_move, 0, 0, p_new_rj_qty_tbl(l_job_counter)),
1412 decode(wo.wsm_costed_quantity_completed, 0, 0, p_new_rj_qty_tbl(l_job_counter))),
1413 --wsm_costed_qty_completed (MES change)
1414 wo.first_unit_start_date,
1415 wo.first_unit_completion_date,
1416 wo.last_unit_start_date,
1417 wo.last_unit_completion_date,
1418 wo.previous_operation_seq_num,
1419 wo.next_operation_seq_num,
1420 wo.count_point_type,
1421 wo.backflush_flag,
1422 wo.minimum_transfer_quantity,
1423 wo.date_last_moved,
1424 wo.attribute_category,
1425 wo.attribute1,
1426 wo.attribute2,
1427 wo.attribute3,
1428 wo.attribute4,
1429 wo.attribute5,
1430 wo.attribute6,
1431 wo.attribute7,
1432 wo.attribute8,
1433
1434 wo.attribute9,
1435 wo.attribute10,
1436 wo.attribute11,
1437 wo.attribute12,
1438 wo.attribute13,
1439 wo.attribute14,
1440 wo.attribute15,
1441 wo.operation_yield_enabled,
1442 wo.operation_yield,
1443 wo.previous_operation_seq_id,
1444 wo.skip_flag, -- Added for I_PROJECT: JUMP_ENH
1445 wo.disable_date, -- bug 2931071
1446 wo.wsm_op_seq_num -- Added to fix bug 3452913.
1447 from wip_operations wo
1448 where wo.wip_entity_id = p_rep_we_id
1449 AND wo.operation_seq_num <= p_curr_op_seq_num
1450 );
1451
1452 -- Added this stmt to fix bug #2680429--
1453 -- This resets the pre and next op_seq_num since copying from only past ops
1454 -- may not set these fields correctly for this new job
1455 -- forall l_job_counter in p_new_rj_we_id_tbl.first..p_new_rj_we_id_tbl.last
1456 forall l_job_counter in indices of p_new_rj_we_id_tbl
1457
1458 UPDATE wip_operations wo
1459 SET wo.previous_operation_seq_num =(SELECT max(operation_seq_num)
1460 FROM wip_operations
1461 WHERE wip_entity_id = p_new_rj_we_id_tbl(l_job_counter)
1462 AND operation_seq_num < wo.operation_seq_num
1463 ),
1464 wo.next_operation_seq_num = (SELECT min(operation_seq_num)
1465 FROM wip_operations
1466 WHERE wip_entity_id = p_new_rj_we_id_tbl(l_job_counter)
1467 AND operation_seq_num > wo.operation_seq_num
1468 )
1469 WHERE wo.wip_entity_id = p_new_rj_we_id_tbl(l_job_counter);
1470 --
1471 l_stmt_num := 20;
1472
1473 select operation_sequence_id,
1474 operation_seq_num
1475 bulk collect into l_op_seq_id_tbl,l_op_seq_num_tbl
1476 from wip_operations wo
1477 where wip_entity_id = p_rep_we_id
1478 AND wo.operation_seq_num <= p_curr_op_seq_num;
1479
1480 l_stmt_num := 30;
1481 if p_new_rj_we_id_tbl.count > 0 then
1482 l_counter := p_new_rj_we_id_tbl.first;
1483 while l_counter is not null loop
1484
1485 --Start: Fix for bug #4990745--
1486 l_stmt_num := 40;
1487 -- Copy job header level attachments
1488 FND_ATTACHED_DOCUMENTS2_PKG.copy_attachments
1489 (x_from_entity_name => 'WSM_LOTBASED_JOBS',
1490 x_from_pk1_value => to_char(p_txn_org_id),
1491 x_from_pk2_value => to_char(p_rep_we_id),
1492 x_to_entity_name => 'WSM_LOTBASED_JOBS',
1493 x_to_pk1_value => to_char(p_txn_org_id),
1494 x_to_pk2_value => to_char(p_new_rj_we_id_tbl(l_counter)),
1495 x_created_by => g_user_id,
1496 x_last_update_login => g_user_login_id,
1497 x_program_application_id => g_program_appl_id,
1498 x_program_id => g_program_id,
1499 x_request_id => g_request_id
1500 );
1501 l_stmt_num := 50;
1502 --End: Fix for bug #4990745--
1503
1504 l_counter1 := l_op_seq_id_tbl.first;
1505 l_counter2 := l_op_seq_num_tbl.first;
1506
1507 while (l_counter1 is not null) and
1508 (l_counter2 is not null)
1509 loop
1510 l_stmt_num := 60;
1511 FND_ATTACHED_DOCUMENTS2_PKG.copy_attachments(x_from_entity_name => 'BOM_OPERATION_SEQUENCES',
1512 x_from_pk1_value => to_char(l_op_seq_num_tbl(l_counter1)),
1513 x_to_entity_name => 'WSM_LOT_BASED_OPERATIONS',
1514 x_to_pk1_value => to_char(p_new_rj_we_id_tbl(l_counter)),
1515 x_to_pk2_value => to_char(l_op_seq_id_tbl(l_counter2)),
1516 x_to_pk3_value => to_char(p_txn_org_id),
1517 x_created_by => g_user_id,
1518 x_last_update_login => g_user_login_id,
1519 x_program_application_id => g_program_appl_id,
1520 x_program_id => g_program_id,
1521 x_request_id => g_request_id
1522 );
1523 l_stmt_num := 70;
1524 l_counter1 := l_op_seq_id_tbl.next(l_counter1);
1525 l_counter2 := l_op_seq_num_tbl.next(l_counter2);
1526
1527 end loop;
1528 l_counter := p_new_rj_we_id_tbl.next(l_counter);
1529 END LOOP;
1530 end if;
1531 l_stmt_num := 80;
1532 x_err_code := 0;
1533 x_err_buf := NULL;
1534
1535 EXCEPTION
1536 WHEN OTHERS THEN
1537 x_err_code := SQLCODE;
1538 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WO_FA('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
1539
1540 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1541 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1542 THEN
1543 WSM_log_PVT.handle_others( p_module_name => l_module ,
1544 p_stmt_num => l_stmt_num ,
1545 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1546 p_run_log_level => l_log_level
1547 );
1548 END IF;
1549
1550
1551 END COPY_REP_JOB_WO_FA;
1552
1553
1554 /*-------------------------------------------------------------+
1555 | Name : COPY_REP_JOB_WOR
1556 ---------------------------------------------------------------*/
1557
1558 PROCEDURE COPY_REP_JOB_WOR(p_txn_id IN NUMBER,
1559 p_new_rj_we_id_tbl IN t_number,
1560 p_rep_we_id IN NUMBER,
1561 p_curr_op_seq_num IN NUMBER,
1562 x_err_code OUT NOCOPY NUMBER,
1563 x_err_buf OUT NOCOPY VARCHAR2)
1564 IS
1565
1566 -- Logging variables.....
1567 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1568 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1569 l_stmt_num NUMBER;
1570 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.COPY_REP_JOB_WOR';
1571
1572 BEGIN
1573
1574 forall l_job_counter in indices of p_new_rj_we_id_tbl
1575 INSERT INTO WIP_OPERATION_RESOURCES
1576 (wip_entity_id,
1577 operation_seq_num,
1578 resource_seq_num,
1579 organization_id,
1580 repetitive_schedule_id,
1581 last_update_date,
1582 last_updated_by,
1583 creation_date,
1584 created_by,
1585 last_update_login,
1586 request_id,
1587 program_application_id,
1588 program_id,
1589 program_update_date,
1590 resource_id,
1591 uom_code,
1592 basis_type,
1593 usage_rate_or_amount,
1594 activity_ID,
1595 scheduled_flag,
1596 assigned_units,
1597 autocharge_type,
1598 standard_rate_flag,
1599 applied_resource_units,
1600 applied_resource_value,
1601 start_date,
1602 completion_date,
1603 attribute_category,
1604 attribute1,
1605 attribute2,
1606 attribute3,
1607 attribute4,
1608 attribute5,
1609 attribute6,
1610 attribute7,
1611 attribute8,
1612 attribute9,
1613 attribute10,
1614 attribute11,
1615 attribute12,
1616 attribute13,
1617 attribute14,
1618 attribute15,
1619 schedule_seq_num,
1620 substitute_group_num,
1621 principle_flag,
1622 setup_id ,
1623 -- ST : Detailed Scheduling --
1624 maximum_assigned_units ,
1625 firm_flag ,
1626 parent_resource_seq
1627 -- ST : Detailed Scheduling --
1628 )
1629 (
1630 select
1631 p_new_rj_we_id_tbl(l_job_counter),
1632 wor.operation_seq_num,
1633 wor.resource_seq_num,
1634 wor.organization_id,
1635 wor.repetitive_schedule_id,
1636 wor.last_update_date,
1637 wor.last_updated_by,
1638 wor.creation_date,
1639 wor.created_by,
1640 wor.last_update_login,
1641 wor.request_id,
1642 wor.program_application_id,
1643 wor.program_id,
1644 wor.program_update_date,
1645 wor.resource_id,
1646 wor.uom_code,
1647 wor.basis_type,
1648 wor.usage_rate_or_amount,
1649 wor.activity_id,
1650 wor.scheduled_flag,
1651 wor.assigned_units,
1652 wor.autocharge_type,
1653 wor.standard_rate_flag,
1654 0, --applied_resource_units
1655 0, --applied_resource_value
1656 wor.start_date,
1657 wor.completion_date,
1658 wor.attribute_category,
1659 wor.attribute1,
1660 wor.attribute2,
1661 wor.attribute3,
1662 wor.attribute4,
1663 wor.attribute5,
1664 wor.attribute6,
1665 wor.attribute7,
1666 wor.attribute8,
1667 wor.attribute9,
1668 wor.attribute10,
1669 wor.attribute11,
1670 wor.attribute12,
1671 wor.attribute13,
1672 wor.attribute14,
1673 wor.attribute15,
1674 wor.schedule_seq_num,
1675 wor.substitute_group_num,
1676 wor.principle_flag,
1677 wor.setup_id ,
1678 -- ST : Detailed Scheduling --
1679 wor.maximum_assigned_units ,
1680 0 ,
1681 wor.parent_resource_seq
1682 -- ST : Detailed Scheduling --
1683 from wip_operation_resources wor
1684 WHERE wor.wip_entity_id = p_rep_we_id
1685 AND wor.operation_seq_num <= p_curr_op_seq_num
1686 );
1687
1688 l_stmt_num := 40;
1689 x_err_code := 0;
1690 x_err_buf := NULL;
1691
1692 EXCEPTION
1693 WHEN OTHERS THEN
1694 x_err_code := SQLCODE;
1695 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WOR('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
1696
1697 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1698 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1699 THEN
1700 WSM_log_PVT.handle_others( p_module_name => l_module ,
1701 p_stmt_num => l_stmt_num ,
1702 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1703 p_run_log_level => l_log_level
1704 );
1705 END IF;
1706
1707
1708 END COPY_REP_JOB_WOR;
1709
1710
1711 --Start: Additions for APS-WLT--
1712 /*-------------------------------------------------------------+
1713 | Name : COPY_REP_JOB_WSOR
1714 ---------------------------------------------------------------*/
1715
1716 PROCEDURE COPY_REP_JOB_WSOR(p_txn_id IN NUMBER,
1717 p_new_rj_we_id_tbl IN t_number,
1718 p_rep_we_id IN NUMBER,
1719 p_curr_op_seq_num IN NUMBER,
1720 x_err_code OUT NOCOPY NUMBER,
1721 x_err_buf OUT NOCOPY VARCHAR2)
1722 IS
1723
1724 -- Logging variables.....
1725 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1726 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1727
1728 l_stmt_num NUMBER;
1729 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.COPY_REP_JOB_WSOR';
1730 BEGIN
1731
1732
1733 l_stmt_num := 20;
1734
1735 forall l_job_counter in indices of p_new_rj_we_id_tbl
1736 INSERT INTO WIP_SUB_OPERATION_RESOURCES
1737 (wip_entity_id,
1738 operation_seq_num,
1739 resource_seq_num,
1740 organization_id,
1741 repetitive_schedule_id,
1742 last_update_date,
1743 last_updated_by,
1744 creation_date,
1745 created_by,
1746 last_update_login,
1747 request_id,
1748 program_application_id,
1749 program_id,
1750 program_update_date,
1751 resource_id,
1752 uom_code,
1753 basis_type,
1754 usage_rate_or_amount,
1755 activity_ID,
1756 scheduled_flag,
1757 assigned_units,
1758 maximum_assigned_units, -- ST : Detailed Scheduling --
1759 autocharge_type,
1760 standard_rate_flag,
1761 applied_resource_units,
1762 applied_resource_value,
1763 start_date,
1764 completion_date,
1765 attribute_category,
1766 attribute1,
1767 attribute2,
1768 attribute3,
1769 attribute4,
1770 attribute5,
1771 attribute6,
1772 attribute7,
1773 attribute8,
1774 attribute9,
1775 attribute10,
1776 attribute11,
1777 attribute12,
1778 attribute13,
1779 attribute14,
1780 attribute15,
1781 relieved_res_completion_units,
1782 relieved_res_scrap_units,
1783 relieved_res_completion_value,
1784 relieved_res_scrap_value,
1785 relieved_variance_value,
1786 temp_relieved_value,
1787 relieved_res_final_comp_units,
1788 department_id,
1789 phantom_flag,
1790 phantom_op_seq_num,
1791 phantom_item_id,
1792 schedule_seq_num,
1793 substitute_group_num,
1794 replacement_group_num,
1795 principle_flag,
1796 setup_id
1797 ) (
1798 select
1799 p_new_rj_we_id_tbl(l_job_counter),
1800 wsor.operation_seq_num,
1801 wsor.resource_seq_num,
1802 wsor.organization_id,
1803 wsor.repetitive_schedule_id,
1804 wsor.last_update_date,
1805 wsor.last_updated_by,
1806 wsor.creation_date,
1807 wsor.created_by,
1808 wsor.last_update_login,
1809 wsor.request_id,
1810 wsor.program_application_id,
1811 wsor.program_id,
1812 wsor.program_update_date,
1813 wsor.resource_id,
1814 wsor.uom_code,
1815 wsor.basis_type,
1816 wsor.usage_rate_or_amount,
1817 wsor.activity_id,
1818 wsor.scheduled_flag,
1819 wsor.assigned_units,
1820 wsor.maximum_assigned_units, -- ST : Detailed Scheduling --
1821 wsor.autocharge_type,
1822 wsor.standard_rate_flag,
1823 0, --applied_resource_units
1824 0, --applied_resource_value
1825 wsor.start_date,
1826 wsor.completion_date,
1827 wsor.attribute_category,
1828 wsor.attribute1,
1829 wsor.attribute2,
1830 wsor.attribute3,
1831 wsor.attribute4,
1832 wsor.attribute5,
1833 wsor.attribute6,
1834 wsor.attribute7,
1835 wsor.attribute8,
1836 wsor.attribute9,
1837 wsor.attribute10,
1838 wsor.attribute11,
1839 wsor.attribute12,
1840 wsor.attribute13,
1841 wsor.attribute14,
1842 wsor.attribute15,
1843 wsor.relieved_res_completion_units,
1844 wsor.relieved_res_scrap_units,
1845 wsor.relieved_res_completion_value,
1846 wsor.relieved_res_scrap_value,
1847 wsor.relieved_variance_value,
1848 wsor.temp_relieved_value,
1849 wsor.relieved_res_final_comp_units,
1850 wsor.department_id,
1851 wsor.phantom_flag,
1852 wsor.phantom_op_seq_num,
1853 wsor.phantom_item_id,
1854 wsor.schedule_seq_num,
1855 wsor.substitute_group_num,
1856 wsor.replacement_group_num,
1857 wsor.principle_flag,
1858 wsor.setup_id
1859 from wip_sub_operation_resources wsor
1860 WHERE wsor.wip_entity_id = p_rep_we_id
1861 AND wsor.operation_seq_num <= p_curr_op_seq_num);
1862
1863 l_stmt_num := 40;
1864 x_err_code := 0;
1865 x_err_buf := NULL;
1866
1867 EXCEPTION
1868 WHEN OTHERS THEN
1869 x_err_code := SQLCODE;
1870 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WSOR('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
1871
1872 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1873 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1874 THEN
1875 WSM_log_PVT.handle_others( p_module_name => l_module ,
1876 p_stmt_num => l_stmt_num ,
1877 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1878 p_run_log_level => l_log_level
1879 );
1880 END IF;
1881
1882
1883 END COPY_REP_JOB_WSOR;
1884 --End: Additions for APS-WLT--
1885
1886 /* ST : Detailed Scheduling start */
1887
1888 /*-------------------------------------------------------------+
1889 | Name : COPY_REP_JOB_WORI |
1890 ---------------------------------------------------------------*/
1891
1892 PROCEDURE COPY_REP_JOB_WORI(p_txn_id IN NUMBER,
1893 p_new_rj_we_id_tbl IN t_number,
1894 p_rep_we_id IN NUMBER,
1895 p_curr_op_seq_num IN NUMBER,
1896 x_err_code OUT NOCOPY NUMBER,
1897 x_err_buf OUT NOCOPY VARCHAR2
1898 )
1899 IS
1900
1901 -- Logging variables.....
1902 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1903 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1904
1905 l_stmt_num NUMBER;
1906 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.COPY_REP_JOB_WORI';
1907
1908
1909 BEGIN
1910 l_stmt_num := 30;
1911
1912 forall l_job_counter in indices of p_new_rj_we_id_tbl
1913
1914 INSERT INTO WIP_OP_RESOURCE_INSTANCES
1915 ( WIP_ENTITY_ID ,
1916 OPERATION_SEQ_NUM,
1917 RESOURCE_SEQ_NUM ,
1918 ORGANIZATION_ID ,
1919 LAST_UPDATE_DATE ,
1920 LAST_UPDATED_BY ,
1921 CREATION_DATE,
1922 CREATED_BY ,
1923 LAST_UPDATE_LOGIN,
1924 INSTANCE_ID ,
1925 SERIAL_NUMBER,
1926 START_DATE ,
1927 COMPLETION_DATE,
1928 BATCH_ID
1929 )
1930 (
1931 select
1932 p_new_rj_we_id_tbl(l_job_counter),
1933 wori.OPERATION_SEQ_NUM,
1934 wori.RESOURCE_SEQ_NUM ,
1935 wori.ORGANIZATION_ID ,
1936 wori.LAST_UPDATE_DATE ,
1937 wori.LAST_UPDATED_BY ,
1938 wori.CREATION_DATE,
1939 wori.CREATED_BY ,
1940 wori.LAST_UPDATE_LOGIN,
1941 wori.INSTANCE_ID ,
1942 wori.SERIAL_NUMBER,
1943 wori.START_DATE ,
1944 wori.COMPLETION_DATE,
1945 wori.BATCH_ID
1946 FROM
1947 wip_op_resource_instances wori
1948 WHERE
1949 wori.wip_entity_id = p_rep_we_id
1950 AND wori.operation_seq_num <= p_curr_op_seq_num
1951 );
1952 l_stmt_num := 40;
1953 x_err_code := 0;
1954 x_err_buf := NULL;
1955 EXCEPTION
1956 WHEN OTHERS THEN
1957 x_err_code := SQLCODE;
1958 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WORI('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
1959
1960 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1961 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1962 THEN
1963 WSM_log_PVT.handle_others( p_module_name => l_module ,
1964 p_stmt_num => l_stmt_num ,
1965 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1966 p_run_log_level => l_log_level
1967 );
1968 END IF;
1969
1970
1971 END ;
1972
1973 /* ST : Detailed Scheduling end */
1974
1975 /*-------------------------------------------------------------+
1976 | Name : COPY_REP_JOB_WRO
1977 ---------------------------------------------------------------*/
1978
1979 PROCEDURE COPY_REP_JOB_WRO(p_txn_id IN NUMBER,
1980 p_new_rj_we_id_tbl IN t_number,
1981 p_new_rj_qty_tbl IN t_number,
1982 p_rep_we_id IN NUMBER,
1983 p_curr_op_seq_num IN NUMBER,
1984 p_txn_intraop_step IN NUMBER,
1985 x_err_code OUT NOCOPY NUMBER,
1986 x_err_buf OUT NOCOPY VARCHAR2)
1987 IS
1988
1989 -- Logging variables.....
1990 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1991 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1992
1993 l_stmt_num NUMBER;
1994 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.COPY_REP_JOB_WRO';
1995 BEGIN
1996
1997
1998 l_stmt_num := 20;
1999
2000 -- related bugs : 3453210
2001 -- Start NL Bugfix 3453210: Set required qty to zero if it's for an obsolete operation
2002 -- Checkin 115.114 is original fix. In 115.115, added a check to make sure we don't do
2003 --- this for phantom component rows, i.e. where op_seq_num is less than zero.
2004
2005 forall l_job_counter in indices of p_new_rj_we_id_tbl
2006 INSERT INTO WIP_REQUIREMENT_OPERATIONS
2007 ( inventory_item_id,
2008 organization_id,
2009 wip_entity_id,
2010 operation_seq_num,
2011 repetitive_schedule_id,
2012 last_update_date,
2013 last_updated_by,
2014 creation_date,
2015 created_by,
2016 last_update_login,
2017 component_sequence_id,
2018 wip_supply_type,
2019 basis_type, --LBM enh
2020 date_required,
2021 required_quantity,
2022 quantity_issued,
2023 quantity_per_assembly,
2024 component_yield_factor,--R12:Comp Shrinkage project
2025 supply_subinventory,
2026 supply_locator_id,
2027 mrp_net_flag,
2028 comments,
2029 attribute_category,
2030 attribute1,
2031 attribute2,
2032 attribute3,
2033 attribute4,
2034 attribute5,
2035 attribute6,
2036 attribute7,
2037 attribute8,
2038 attribute9,
2039 attribute10,
2040 attribute11,
2041 attribute12,
2042 attribute13,
2043 attribute14,
2044 attribute15,
2045 segment1,
2046 segment2,
2047 segment3,
2048 segment4,
2049 segment5,
2050 segment6,
2051 segment7,
2052 segment8,
2053 segment9,
2054 segment10,
2055 segment11,
2056 segment12,
2057 segment13,
2058 segment14,
2059 segment15,
2060 segment16,
2061 segment17,
2062 segment18,
2063 segment19,
2064 segment20,
2065 department_id
2066 )
2067 (
2068 select
2069 wro.inventory_item_id,
2070 wro.organization_id,
2071 p_new_rj_we_id_tbl(l_job_counter),
2072 wro.operation_seq_num,
2073 wro.repetitive_schedule_id,
2074 wro.last_update_date,
2075 wro.last_updated_by,
2076 wro.creation_date,
2077 wro.created_by,
2078 wro.last_update_login,
2079 wro.component_sequence_id,
2080 wro.wip_supply_type,
2081 wro.basis_type, --LBM enh
2082 wro.date_required,
2083 -- ST : Added the below for bug fix : 4619823
2084 (case
2085 when (wro.operation_seq_num = p_curr_op_seq_num)
2086 then decode(p_txn_intraop_step,
2087 WIP_CONSTANTS.QUEUE,
2088 ROUND( ( (wro.quantity_per_assembly/nvl(wro.component_yield_factor,1)) --LBM enh
2089 *
2090 decode(p_new_rj_qty_tbl(l_job_counter),
2091 0, 0,
2092 decode(wro.basis_type,
2093 2, 1,
2094 p_new_rj_qty_tbl(l_job_counter)
2095 )
2096 )
2097 )
2098 , 6
2099 ), --LBM enh
2100 WIP_CONSTANTS.TOMOVE,0)
2101 else
2102 0
2103 end
2104 ),
2105 -- ST : Added the below for bug fix : 4619823
2106 -- ST : Commented out the below for bug fix : 4619823
2107 -- (case when (wro.operation_seq_num>=0 and wo.count_point_type = 3 and wo.scheduled_quantity = 0)
2108 -- then
2109 -- 0
2110 -- else
2111 -- ROUND((wro.quantity_per_assembly/nvl(wro.component_yield_factor,1)) --LBM enh
2112 -- * decode(p_new_rj_qty_tbl(l_job_counter), 0, 0, decode(wro.basis_type, 2, 1, p_new_rj_qty_tbl(l_job_counter))), 6) --LBM enh
2113 -- end),
2114 -- ST : Commented out the below for bug fix : 4619823
2115 0, --quantity_issued,
2116 wro.quantity_per_assembly,
2117 nvl(wro.component_yield_factor,1),--R12:Comp Shrinkage project
2118 wro.supply_subinventory,
2119 wro.supply_locator_id,
2120 wro.mrp_net_flag,
2121 wro.comments,
2122 wro.attribute_category,
2123 wro.attribute1,
2124 wro.attribute2,
2125 wro.attribute3,
2126 wro.attribute4,
2127 wro.attribute5,
2128 wro.attribute6,
2129 wro.attribute7,
2130 wro.attribute8,
2131 wro.attribute9,
2132 wro.attribute10,
2133 wro.attribute11,
2134 wro.attribute12,
2135 wro.attribute13,
2136 wro.attribute14,
2137 wro.attribute15,
2138 wro.segment1,
2139 wro.segment2,
2140 wro.segment3,
2141 wro.segment4,
2142 wro.segment5,
2143 wro.segment6,
2144 wro.segment7,
2145 wro.segment8,
2146 wro.segment9,
2147 wro.segment10,
2148 wro.segment11,
2149 wro.segment12,
2150 wro.segment13,
2151 wro.segment14,
2152 wro.segment15,
2153 wro.segment16,
2154 wro.segment17,
2155 wro.segment18,
2156 wro.segment19,
2157 wro.segment20,
2158 wro.department_id
2159
2160 from wip_requirement_operations wro
2161 , wip_operations wo
2162 WHERE wro.wip_entity_id = p_rep_we_id
2163 AND wro.operation_seq_num <= p_curr_op_seq_num
2164 AND wro.operation_seq_num >= 0-p_curr_op_seq_num --To take care of phantoms bug #2681370
2165 and wo.wip_entity_id = p_rep_we_id
2166 and wo.operation_seq_num = wro.operation_seq_num
2167 );
2168
2169 l_stmt_num := 40;
2170 x_err_code := 0;
2171 x_err_buf := NULL;
2172
2173 EXCEPTION
2174 WHEN OTHERS THEN
2175 x_err_code := SQLCODE;
2176 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WRO('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2177
2178 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2179 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2180 THEN
2181 WSM_log_PVT.handle_others( p_module_name => l_module ,
2182 p_stmt_num => l_stmt_num ,
2183 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2184 p_run_log_level => l_log_level
2185 );
2186 END IF;
2187
2188 END COPY_REP_JOB_WRO;
2189 -- end...
2190
2191 -- start....
2192 /*-------------------------------------------------------------+
2193 | Name : COPY_REP_JOB_WOY
2194 ---------------------------------------------------------------*/
2195
2196 PROCEDURE COPY_REP_JOB_WOY(p_txn_id IN NUMBER,
2197 p_new_rj_we_id_tbl IN t_number,
2198 p_rep_we_id IN NUMBER,
2199 p_curr_op_seq_num IN NUMBER,
2200 x_err_code OUT NOCOPY NUMBER,
2201 x_err_buf OUT NOCOPY VARCHAR2
2202 )
2203 IS
2204
2205 -- Logging variables.....
2206 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2207 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2208
2209 l_stmt_num NUMBER;
2210 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.COPY_REP_JOB_WOY';
2211 BEGIN
2212
2213 l_stmt_num := 20;
2214
2215 forall l_job_counter in indices of p_new_rj_we_id_tbl
2216 INSERT INTO WIP_OPERATION_YIELDS
2217 (wip_entity_id,
2218 operation_seq_num,
2219 organization_id,
2220 last_update_date,
2221 last_updated_by,
2222 creation_date,
2223 created_by,
2224 last_update_login,
2225 request_id,
2226 program_application_id,
2227 program_id,
2228 program_update_date,
2229 scrap_account,
2230 est_scrap_absorb_account,
2231 status
2232 )
2233 (
2234 select
2235 p_new_rj_we_id_tbl(l_job_counter),
2236 woy.operation_seq_num,
2237 woy.organization_id,
2238 woy.last_update_date,
2239 woy.last_updated_by,
2240 woy.creation_date,
2241 woy.created_by,
2242 woy.last_update_login,
2243 woy.request_id,
2244 woy.program_application_id,
2245 woy.program_id,
2246 woy.program_update_date,
2247 woy.scrap_account,
2248 woy.est_scrap_absorb_account,
2249 NULL
2250 from wip_operation_yields woy
2251 WHERE wip_entity_id = p_rep_we_id
2252 AND operation_seq_num <= p_curr_op_seq_num
2253 );
2254
2255 l_stmt_num := 40;
2256 x_err_code := 0;
2257 x_err_buf := NULL;
2258
2259 EXCEPTION
2260 WHEN OTHERS THEN
2261 x_err_code := SQLCODE;
2262 x_err_buf := ' WSMPJUPD.COPY_REP_JOB_WOY('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2263
2264 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2265 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2266 THEN
2267 WSM_log_PVT.handle_others( p_module_name => l_module ,
2268 p_stmt_num => l_stmt_num ,
2269 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2270 p_run_log_level => l_log_level
2271 );
2272 END IF;
2273
2274 END COPY_REP_JOB_WOY;
2275 -- end..
2276
2277
2278 /*-------------------------------------------------------------+
2279 | Name : CHANGE_QUANTITY
2280 ---------------------------------------------------------------*/
2281 -- Updates following quantity columns
2282 -- WDJ: start_quantity, net_quantity
2283 -- WO : quantity_in_queue, quantity_waiting_to_move, scheduled_quantity, quantity_completed
2284 -- WRO: required_quantity
2285 /*
2286 This procedure will be called for split/merge to update the starting jobs and also for Update quantity transaction...
2287
2288
2289 Parameters : p_txn_id : Transaction id
2290 p_txn_type : transaction type
2291 p_wip_entity_id_tbl : Table of Wip entity ids of the starting jobs...
2292 p_new_job_qty_tbl : New job qty tbl... will be 0 for the completely merged/split jobs
2293 p_new_net_qty_tbl : Net quantity ... will be 0 for the completely merged/split jobs
2294 p_txn_job_op_seq_tbl : table of operation seq num of the job
2295 p_txn_job_intraop : intraop step....
2296
2297 p_sj_st_qty_tbl : table of Old start qty of the starting jobs...
2298 p_sj_avail_qty_tbl : table of Old start_quantity - quantity_scrapped of the starting jobs
2299 p_sj_scrap_qty_tbl : table of quantity_scrapped
2300 */
2301
2302 PROCEDURE CHANGE_QUANTITY(p_txn_id IN NUMBER,
2303 p_txn_type IN NUMBER,
2304 p_wip_entity_id_tbl IN t_number,
2305 p_new_job_qty_tbl IN t_number,
2306 p_new_net_qty_tbl IN t_number, -- User given/defaulted Bug# 3181486 - Net Planned Qty
2307 p_txn_job_op_seq_tbl IN t_number,
2308 p_txn_job_intraop IN NUMBER, -- will be number as only one intraop is possible..
2309
2310 p_sj_st_qty_tbl IN t_number,
2311 p_sj_avail_qty_tbl IN t_number,
2312 p_sj_scrap_qty_tbl IN t_number,
2313
2314 x_err_code OUT NOCOPY NUMBER,
2315 x_err_buf OUT NOCOPY VARCHAR2
2316 )
2317 IS
2318
2319 -- Logging variables.....
2320 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2321 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2322
2323 l_stmt_num NUMBER;
2324 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.CHANGE_QUANTITY';
2325 --Bug 5254440: Added the parameter p_op_seq_num.
2326 cursor c_job_wo(p_wip_entity_id number,p_op_seq_num NUMBER) is select quantity_in_queue + quantity_running + quantity_completed total_quantity,
2327 operation_seq_num
2328 from wip_operations wo
2329 where wo.wip_entity_id = p_wip_entity_id
2330 and wo.operation_seq_num = p_op_seq_num;
2331 BEGIN
2332
2333 l_stmt_num := 10;
2334 -- Related Bugs : 3181486 , 2674320 */
2335
2336 --Set the WDJ.start_quantity for all Split/Merge/Update Quantity Transactions----------------------------
2337
2338
2339 forall l_job_counter in indices of p_wip_entity_id_tbl
2340 UPDATE wip_discrete_jobs
2341 SET start_quantity = (p_sj_st_qty_tbl(l_job_counter) - p_sj_avail_qty_tbl(l_job_counter) + p_new_job_qty_tbl(l_job_counter)),
2342 net_quantity = nvl(p_new_net_qty_tbl(l_job_counter), 0)
2343 WHERE wip_entity_id = p_wip_entity_id_tbl(l_job_counter);
2344
2345 l_stmt_num := 40;
2346
2347 -- Update WO using the new qty
2348 forall l_job_counter in indices of p_wip_entity_id_tbl
2349 UPDATE wip_operations
2350 SET quantity_in_queue = decode(quantity_in_queue, 0, 0, p_new_job_qty_tbl(l_job_counter)),
2351 quantity_waiting_to_move = decode(quantity_waiting_to_move, 0, 0, p_new_job_qty_tbl(l_job_counter))
2352 WHERE wip_entity_id = p_wip_entity_id_tbl(l_job_counter)
2353 AND operation_seq_num = p_txn_job_op_seq_tbl(l_job_counter);
2354
2355 l_stmt_num := 50;
2356 if p_txn_job_intraop = 1 then --check added as part of MES actual qty changes(AH)
2357 forall l_job_counter in indices of p_wip_entity_id_tbl
2358 UPDATE wip_operations wo
2359 -- ST : Added for bug fix 4619823 (Found in UT)
2360 -- SET scheduled_quantity = (scheduled_quantity - p_sj_avail_qty_tbl(l_job_counter) + p_new_job_qty_tbl(l_job_counter))
2361 SET scheduled_quantity = (nvl(quantity_scrapped,0) + quantity_in_queue)
2362 WHERE wip_entity_id = p_wip_entity_id_tbl(l_job_counter)
2363 -- ST : Added for bug fix 4619823...
2364 -- Should update the current operation only...
2365 AND operation_seq_num = p_txn_job_op_seq_tbl(l_job_counter);
2366 end if;
2367
2368 l_stmt_num := 60;
2369
2370 forall l_job_counter in indices of p_wip_entity_id_tbl
2371 UPDATE wip_operations wo
2372 SET wsm_costed_quantity_completed = decode(wo.count_point_type,3,0, --changed to costed qty completed as part of MES actual qty changes(AH)
2373 wsm_costed_quantity_completed - p_sj_avail_qty_tbl(l_job_counter) + p_new_job_qty_tbl(l_job_counter))
2374 WHERE wip_entity_id = p_wip_entity_id_tbl(l_job_counter)
2375 AND ( (p_txn_job_intraop = WIP_CONSTANTS.QUEUE
2376 AND operation_seq_num < p_txn_job_op_seq_tbl(l_job_counter))
2377 OR
2378 (p_txn_job_intraop = WIP_CONSTANTS.TOMOVE
2379 AND operation_seq_num <= p_txn_job_op_seq_tbl(l_job_counter))
2380 );
2381
2382 -- Update WRO using the new qty
2383 l_stmt_num := 70;
2384
2385 -- related bugs 2682597
2386 -- ST : Added for bug fix 4619823 --
2387 if p_txn_job_intraop = 1 then
2388 for l_job_counter in p_wip_entity_id_tbl.first..p_wip_entity_id_tbl.last loop
2389 --LBM enh: Changed the expression for required quantity
2390 --Bug 5254440: Value passed for the parameter p_op_seq_num.
2391 for l_job_wo_rec in c_job_wo(p_wip_entity_id_tbl(l_job_counter),p_txn_job_op_seq_tbl(l_job_counter)) loop
2392 UPDATE wip_requirement_operations wro
2393 SET required_quantity = ROUND( (wro.quantity_per_assembly/nvl(wro.component_yield_factor,1)
2394 * decode(l_job_wo_rec.total_quantity
2395 , 0,0
2396 , decode(wro.basis_type,
2397 2,1,
2398 (l_job_wo_rec.total_quantity)
2399 -- ST : Added for bug fix 4619823 (Found in UT)
2400 -- nvl(wro.quantity_relieved,0)) -- Or is it Quantity_completed.
2401 )
2402 )
2403 ),6)
2404 WHERE wro.wip_entity_id = p_wip_entity_id_tbl(l_job_counter)
2405 and nvl(abs(wro.quantity_issued),0) >= nvl(abs(wro.quantity_relieved),0) -- Added abs() on quantity_issued for bug 6053122(fp for 5843039)
2406 -- ST : Commenting out for bug fix 4619823
2407 -- Actual Quantity Changes : Should update the current operation only
2408 -- and ( (wro.operation_seq_num = l_job_wo_rec.operation_seq_num)
2409 -- or
2410 -- (wro.operation_seq_num = 0-l_job_wo_rec.operation_seq_num)
2411 -- )
2412 -- ST : Added for bug fix 4619823...
2413 -- Should update the current operation only...
2414 AND operation_seq_num = p_txn_job_op_seq_tbl(l_job_counter);
2415 end loop;
2416 end loop;
2417 -- To take care of phantoms bug #2681370
2418 -- End fix for bug #2682597--
2419 END IF;
2420 l_stmt_num := 90;
2421
2422 x_err_code := 0;
2423 x_err_buf := NULL;
2424
2425 EXCEPTION
2426 WHEN OTHERS THEN
2427 x_err_code := SQLCODE;
2428 x_err_buf := ' WSMPJUPD.CHANGE_QUANTITY('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2429
2430 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2431 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2432 THEN
2433 WSM_log_PVT.handle_others( p_module_name => l_module ,
2434 p_stmt_num => l_stmt_num ,
2435 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2436 p_run_log_level => l_log_level
2437 );
2438 END IF;
2439
2440 END CHANGE_QUANTITY;
2441 --- end ...
2442
2443 /*-------------------------------------------------------------+
2444 | Name : handle_kanban_sub_loc_change
2445 ---------------------------------------------------------------*/
2446 /*
2447 -- if user has changes sub/loc during a wip lot txn, and the job has kanban ref
2448 -- dereference the job.
2449 -- this returns 0 if subinv/locator are the same, else return 1
2450
2451 */
2452 function handle_kanban_sub_loc_change( p_wip_entity_id IN number,
2453 p_kanban_card_id IN number,
2454 p_wssj_completion_subinventory IN varchar2,
2455 p_wssj_completion_locator_id IN number,
2456 p_wsrj_completion_subinventory IN varchar2,
2457 p_wsrj_completion_locator_id IN number,
2458 x_err_code OUT NOCOPY number,
2459 x_err_msg OUT NOCOPY varchar2
2460 )
2461 return number
2462 IS
2463
2464 l_sub_loc_change_flag number;
2465 l_ret_status varchar2(1);
2466
2467 -- Logging variables.....
2468 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2469 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2470
2471 l_stmt_num NUMBER;
2472 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.handle_kanban_sub_loc_change';
2473
2474 begin
2475
2476 l_stmt_num := 10;
2477
2478 l_sub_loc_change_flag := 0;
2479
2480 if p_kanban_card_id is not null then
2481
2482 l_stmt_num := 20;
2483
2484 if (p_wssj_completion_subinventory = p_wsrj_completion_subinventory) AND
2485 --Bug 5344676:Following statement causes the supply status of the Kanban to be
2486 --exception if the locator id is null.
2487 --(nvl(p_wssj_completion_locator_id,-999) = nvl(p_wsrj_completion_locator_id,-1))
2488 (nvl(p_wssj_completion_locator_id,-1) = nvl(p_wsrj_completion_locator_id,-1))
2489 then
2490 l_sub_loc_change_flag := 0;
2491 else
2492 l_sub_loc_change_flag := 1;
2493
2494 l_stmt_num := 30;
2495
2496 INV_Kanban_PVT.Update_Card_Supply_Status (X_Return_Status => l_ret_status,
2497 p_Kanban_Card_Id => p_kanban_card_id,
2498 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
2499 );
2500
2501 if ( l_ret_status <> fnd_api.g_ret_sts_success ) then
2502 x_err_code := -1;
2503 fnd_message.set_name('WSM', 'WSM_KNBN_CARD_STS_FAIL');
2504
2505 fnd_message.set_token('STATUS',g_translated_meaning);
2506 x_err_msg := fnd_message.get;
2507
2508 return -99;
2509
2510 end if;
2511
2512 l_stmt_num := 40;
2513
2514 end if;
2515
2516 end if; -- kanban card is not null
2517
2518 return l_sub_loc_change_flag;
2519
2520 EXCEPTION
2521
2522 WHEN OTHERS THEN
2523 x_err_code := SQLCODE;
2524 x_err_msg := 'WSMPJUPD.handle_kanban_sub_loc_change('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2525
2526 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2527 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2528 THEN
2529 WSM_log_PVT.handle_others( p_module_name => l_module ,
2530 p_stmt_num => l_stmt_num ,
2531 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2532 p_run_log_level => l_log_level
2533 );
2534 END IF;
2535
2536
2537 return -99;
2538
2539 end handle_kanban_sub_loc_change;
2540 -- abbkanban end
2541
2542
2543 /*-------------------------------------------------------------+
2544 | Name : UPDATE_QTY_ISSUED
2545 ---------------------------------------------------------------*/
2546 /*
2547 -- This procedure is called only for Split/Merge/Update Quantity transactions
2548 Parameters :
2549 p_txn_id : Transaction id
2550 p_txn_type : Transaction type...
2551 p_rep_we_id : Wip entity id of the representative starting job...
2552 p_rep_op_seq_num : Job Operation seq num of the rep. starting job...
2553 p_rep_avail_qty : Available qty of the rep. starting job...
2554 p_new_rep_job_qty : New qty of the rep. starting job ( will be non-zero if the starting job is also a resulting job....)
2555 p_non_rep_sj_we_id_tbl : Table containing the wip_entity_id of the non-representative starting jobs..
2556 p_new_rj_we_id_tbl : Table containing the wip_entity_id of the new resulting jobs..
2557 */
2558 PROCEDURE UPDATE_QTY_ISSUED(p_txn_id IN NUMBER,
2559 p_txn_type IN NUMBER,
2560 p_rep_we_id IN NUMBER,
2561 p_rep_op_seq_num IN NUMBER,
2562 p_rep_avail_qty IN NUMBER,
2563 p_rep_new_job_qty IN NUMBER,
2564 p_txn_job_intraop IN NUMBER,
2565 p_non_rep_sj_we_id_tbl IN t_number,
2566 p_new_rj_we_id_tbl IN t_number,
2567 p_new_rj_start_qty IN t_number,
2568 x_err_code OUT NOCOPY NUMBER,
2569 x_err_buf OUT NOCOPY VARCHAR2
2570 )
2571 IS
2572
2573 -- Logging variables.....
2574 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2575 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2576
2577 l_stmt_num NUMBER;
2578 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.UPDATE_QTY_ISSUED';
2579 BEGIN
2580
2581 l_stmt_num := 10;
2582 x_err_code := 0;
2583
2584 IF p_txn_type IN (WSMPCNST.SPLIT, WSMPCNST.MERGE) THEN
2585 --This has been added to improve performance
2586 -- as such the following stmts wont update anything for Upd Qty
2587 l_stmt_num := 20;
2588
2589 -- Update the non-representative starting jobs
2590 /*** MES Actual Qty changes(Change description) --AH****/
2591 --The calculation for quantity_issued would remain unchanged for the parent job if
2592 --it is at ToMove as per the new behavior and also as costing has fixed the bug 2120717.
2593 -- The calculation of qty_issued will change as below at Queue due to MES
2594 /*** End MES Actual Qty changes(Change description) ****/
2595
2596 if p_txn_type = WSMPCNST.MERGE and
2597 p_txn_job_intraop = 1 -- ST : Added for bug fix : 4619823 --
2598 then
2599
2600 forall l_job_counter in indices of p_non_rep_sj_we_id_tbl
2601
2602 -- Added abs() on quantity_issued for bug 6053122(fp for 5843039)
2603
2604
2605 UPDATE wip_requirement_operations wro
2606 -- ST : Commenting out the below for bug fix : 4619823 --
2607 --SET wro.quantity_issued = decode(p_txn_job_intraop,1,round(NVL(wro.quantity_relieved, 0), 6)
2608 -- ,3,wro.quantity_issued
2609 -- )
2610 -- ST : Added the below for bug fix : 4619823 --
2611 SET wro.quantity_issued = round(NVL(wro.quantity_relieved, 0), 6)
2612 WHERE wro.wip_entity_id = p_non_rep_sj_we_id_tbl(l_job_counter)
2613 AND nvl(abs(wro.quantity_issued), 0) >= nvl(abs(wro.quantity_relieved), 0)
2614 -- ST : Added the below for bug fix : 4619823 --
2615 -- Should be updating only the op at which the TXN took place...
2616 -- That Op will be the MAX Non-Obsoleted Operation
2617 AND wro.operation_seq_num = (select max(operation_seq_num)
2618 from wip_operations wo
2619 where wo.wip_entity_id = p_non_rep_sj_we_id_tbl(l_job_counter)
2620 and wo.count_point_type <> 3);
2621 -- If there is a PUSH comp and the whole qty is scrapped, qty_rel > qty_iss
2622 -- ST : Commenting out the below for bug fix : 4619823 --
2623 -- AND not exists (select 'obsolete operation'
2624 -- from wip_operations wo
2625 -- where wo.wip_entity_id = wro.wip_entity_id
2626 -- and wo.organization_id = wro.organization_id
2627 -- and wo.operation_seq_num = wro.operation_seq_num
2628 -- and wo.count_point_type = 3);
2629
2630 --Start deletions to fix bug #2901741--
2631 --Deleted the following, since this fix is incorrect--
2632 --Start adding condition to fix bug #2664909--
2633 -- AND wro.inventory_item_id IN (select inventory_item_id
2634 -- from wip_requirement_operations
2635 -- where wip_entity_id = l_rep_we_id
2636 -- and operation_seq_num = wro.operation_seq_num)
2637 --End adding condition to fix bug #2664909--
2638 --Deleted the following, since if A(ops 10,20) and B(ops 10,20,30,40) are merged into A,
2639 --requirements for op 30,40 in job B are not set to 0.
2640 --This was initially inherited from costing
2641 -- AND operation_seq_num <= l_op_seq_num;
2642 --End deletions to fix bug #2901741--
2643
2644 end if;
2645
2646 l_stmt_num := 30;
2647
2648 -- Update the non-matching resulting jobs i.e. new jobs (during split and merge)
2649 -- related bugs ... : 3086120
2650 IF p_txn_job_intraop = 1 THEN
2651 forall l_job_counter in indices of p_new_rj_we_id_tbl
2652
2653 -- Added abs() on quantity_issued for bug 6053122(fp for 5843039)
2654
2655 UPDATE wip_requirement_operations wro
2656 -- ST : Commenting for bug fix 4619823
2657 -- SET wro.quantity_issued = decode(p_txn_job_intraop,1,(SELECT round(decode(sign(nvl(wro1.quantity_issued, 0) - nvl(wro1.quantity_relieved, 0)), 1, 1, 0)
2658 -- *(nvl(wro1.quantity_issued,0) - nvl(wro1.quantity_relieved, 0))
2659 -- * p_new_rj_start_qty(l_job_counter)/p_rep_avail_qty, 6)
2660 -- FROM wip_requirement_operations wro1
2661 -- WHERE wro1.wip_entity_id = p_rep_we_id
2662 -- AND wro1.inventory_item_id = wro.inventory_item_id
2663 -- AND wro1.organization_id = wro.organization_id
2664 -- AND wro1.operation_seq_num = wro.operation_seq_num
2665 -- AND p_new_rj_we_id_tbl(l_job_counter) = wro.wip_entity_id),
2666 -- 3,0)
2667 -- ST : Commenting for bug fix 4619823 --
2668 -- ST : Added the below for bug fix 4619823 --
2669 SET wro.quantity_issued = (SELECT round(decode(sign(nvl(abs(wro1.quantity_issued), 0) - nvl(abs(wro1.quantity_relieved), 0)), 1, 1, 0)
2670 *(nvl(wro1.quantity_issued,0) - nvl(wro1.quantity_relieved, 0))
2671 * p_new_rj_start_qty(l_job_counter)/p_rep_avail_qty, 6)
2672 FROM wip_requirement_operations wro1
2673 WHERE wro1.wip_entity_id = p_rep_we_id
2674 AND wro1.inventory_item_id = wro.inventory_item_id
2675 AND wro1.organization_id = wro.organization_id
2676 AND wro1.operation_seq_num = wro.operation_seq_num
2677 AND p_new_rj_we_id_tbl(l_job_counter) = wro.wip_entity_id)
2678 WHERE wro.wip_entity_id = p_new_rj_we_id_tbl(l_job_counter)
2679 and wro.operation_seq_num = p_rep_op_seq_num
2680 AND not exists (select 'obsolete operation'
2681 from wip_operations wo
2682 where wo.wip_entity_id = wro.wip_entity_id
2683 and wo.organization_id = wro.organization_id
2684 and wo.operation_seq_num = wro.operation_seq_num
2685 and wo.count_point_type = 3);
2686
2687 --Start deletions to fix bug #2901741--
2688 --The following condition is not required, since in Rep Job, there wont be any ops > l_op_seq_num
2689 --This was initially inherited from costing
2690 -- AND operation_seq_num <= l_op_seq_num;
2691 --End deletions to fix bug #2901741--
2692 END IF;
2693 END IF;
2694
2695 -- Related bugs : 2901741
2696 -- For representative job
2697 -- Things will change only in case of Queue...
2698 -- ST : Added the IF clause for bug fix 4619823
2699 IF p_txn_job_intraop = 1 THEN
2700
2701 -- Added abs() on quantity_issued for bug 6053122(fp for 5843039)
2702
2703 UPDATE wip_requirement_operations wro
2704 -- ST : Commenting for bug fix 4619823
2705 -- SET wro.quantity_issued = decode(p_txn_job_intraop,1,round( (decode(sign(nvl(wro.quantity_issued, 0) - nvl(wro.quantity_relieved, 0)),
2706 -- 1, 1
2707 -- , 0)
2708 -- *(nvl(wro.quantity_issued,0) - nvl(wro.quantity_relieved, 0))
2709 -- * p_rep_new_job_qty/p_rep_avail_qty
2710 -- + nvl(wro.quantity_relieved, 0)
2711 -- ), 6)
2712 -- -- What for 3..?
2713 -- ,3,wro.quantity_issued
2714 -- )
2715 -- ST : Added the below for bug fix 4619823
2716 SET wro.quantity_issued = round((decode(sign(nvl(abs(wro.quantity_issued), 0) - nvl(abs(wro.quantity_relieved), 0)),
2717 1, 1
2718 , 0)
2719 *(nvl(wro.quantity_issued,0) - nvl(wro.quantity_relieved, 0))
2720 * p_rep_new_job_qty/p_rep_avail_qty
2721 + nvl(wro.quantity_relieved, 0)
2722 ), 6)
2723 WHERE wro.wip_entity_id = p_rep_we_id
2724 AND nvl(abs(wro.quantity_issued),0) >= NVL(abs(wro.quantity_relieved), 0) -- Added to fix bug #2797647
2725 AND not exists (select 'obsolete operation'
2726 from wip_operations wo
2727 where wo.wip_entity_id = wro.wip_entity_id
2728 and wo.organization_id = wro.organization_id
2729 and wo.operation_seq_num = wro.operation_seq_num
2730 and wo.count_point_type = 3)
2731 -- AND operation_seq_num <= p_rep_op_seq_num;
2732 AND operation_seq_num = p_rep_op_seq_num;
2733 -- ST : Added for bug fix 4619823 (Found in UT)
2734 -- Should update only for the current operation
2735 END IF;
2736
2737 -- Added this back to fix bug #3180781,
2738 -- since this should really be the opseq of job under consideration
2739 -- and not that of the rep job.
2740 --This fixes both issues 3180781 and 2901741
2741
2742
2743 --Start deletions to fix bug #2901741--
2744 --The following condition is not required, since in Rep Job, there wont be any ops > l_op_seq_num
2745 --This was initially inherited from costing
2746 -- AND operation_seq_num <= l_op_seq_num;
2747 --End deletions to fix bug #2901741--
2748
2749 l_stmt_num := 50;
2750 x_err_code := 0;
2751 x_err_buf := NULL;
2752
2753 EXCEPTION
2754 WHEN OTHERS THEN
2755 x_err_code := SQLCODE;
2756 x_err_buf := 'WSMPJUPD.UPDATE_QTY_ISSUED('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2757
2758 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2759 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2760 THEN
2761 WSM_log_PVT.handle_others( p_module_name => l_module ,
2762 p_stmt_num => l_stmt_num ,
2763 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2764 p_run_log_level => l_log_level
2765 );
2766 END IF;
2767
2768 END UPDATE_QTY_ISSUED;
2769
2770 /*-----------------------------------------------------------------+
2771 | Name : CREATE_WSOR_WLBJ_RECORDS
2772 | This procedure creates entries in WSOR and WLBJ tables
2773 | -- If p_only_wo_op_seq is not null, -- irrelevant will never be called with null
2774 | for this parameter,....
2775 -------------------------------------------------------------------*/
2776
2777 PROCEDURE CREATE_WSOR_WLBJ_RECORDS(p_wip_entity_id IN NUMBER,
2778 p_org_id IN NUMBER,
2779 p_only_wo_op_seq IN NUMBER,
2780 p_last_update_date IN DATE,
2781 p_last_updated_by IN NUMBER,
2782 p_last_update_login IN NUMBER,
2783 p_creation_date IN DATE,
2784 p_created_by IN NUMBER,
2785 p_request_id IN NUMBER,
2786 p_program_app_id IN NUMBER,
2787 p_program_id IN NUMBER,
2788 p_program_update_date IN DATE,
2789 x_err_code OUT NOCOPY NUMBER,
2790 x_err_buf OUT NOCOPY VARCHAR2)
2791 IS
2792 -- Logging variables.....
2793 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2794 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2795
2796 l_stmt_num NUMBER;
2797 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.CREATE_WSOR_WLBJ_RECORDS';
2798
2799 BEGIN
2800 l_stmt_num := 10;
2801
2802 -- Related bugs : 3313454
2803 INSERT INTO WIP_SUB_OPERATION_RESOURCES
2804 (WIP_ENTITY_ID,
2805 OPERATION_SEQ_NUM,
2806 RESOURCE_SEQ_NUM,
2807 ORGANIZATION_ID,
2808 SUBSTITUTE_GROUP_NUM,
2809 REPLACEMENT_GROUP_NUM,
2810 START_DATE,
2811 COMPLETION_DATE,
2812 RESOURCE_ID,
2813 ACTIVITY_ID,
2814 STANDARD_RATE_FLAG,
2815 ASSIGNED_UNITS,
2816 MAXIMUM_ASSIGNED_UNITS, -- ST : Detailed Scheduling --
2817 USAGE_RATE_OR_AMOUNT,
2818 UOM_CODE,
2819 BASIS_TYPE,
2820 SCHEDULED_FLAG,
2821 AUTOCHARGE_TYPE,
2822 SCHEDULE_SEQ_NUM,
2823 PRINCIPLE_FLAG,
2824 SETUP_ID,
2825 DEPARTMENT_ID,
2826 PHANTOM_FLAG,
2827 PHANTOM_OP_SEQ_NUM,
2828 PHANTOM_ITEM_ID,
2829 applied_resource_units,
2830 applied_resource_value,
2831 LAST_UPDATE_DATE,
2832 LAST_UPDATED_BY,
2833 LAST_UPDATE_LOGIN,
2834 CREATION_DATE,
2835 CREATED_BY,
2836 REQUEST_ID,
2837 PROGRAM_APPLICATION_ID,
2838 PROGRAM_ID,
2839 PROGRAM_UPDATE_DATE,
2840 ATTRIBUTE_CATEGORY,
2841 ATTRIBUTE1,
2842 ATTRIBUTE2,
2843 ATTRIBUTE3,
2844 ATTRIBUTE4,
2845 ATTRIBUTE5,
2846 ATTRIBUTE6,
2847 ATTRIBUTE7,
2848 ATTRIBUTE8,
2849 ATTRIBUTE9,
2850 ATTRIBUTE10,
2851 ATTRIBUTE11,
2852 ATTRIBUTE12,
2853 ATTRIBUTE13,
2854 ATTRIBUTE14,
2855 ATTRIBUTE15
2856 )
2857 SELECT wo.WIP_ENTITY_ID,
2858 wo.OPERATION_SEQ_NUM,
2859 rownum + (SELECT nvl(max(resource_seq_num), 10)
2860 FROM WIP_OPERATION_RESOURCES
2861 WHERE wip_entity_id = p_wip_entity_id
2862 AND OPERATION_SEQ_NUM = wo.OPERATION_SEQ_NUM),
2863 wo.ORGANIZATION_ID,
2864 bsor.SUBSTITUTE_GROUP_NUM,
2865 bsor.REPLACEMENT_GROUP_NUM,
2866 wo.first_unit_start_date, --START_DATE
2867 wo.first_unit_completion_date, --COMPLETION_DATE
2868 bsor.RESOURCE_ID,
2869 bsor.ACTIVITY_ID,
2870 bsor.STANDARD_RATE_FLAG,
2871 bsor.ASSIGNED_UNITS,
2872 bsor.assigned_units, -- ST : Detailed Scheduling --
2873 bsor.USAGE_RATE_OR_AMOUNT,
2874 br.UNIT_OF_MEASURE,
2875 bsor.BASIS_TYPE,
2876 bsor.SCHEDULE_FLAG,
2877 bsor.AUTOCHARGE_TYPE,
2878 bsor.SCHEDULE_SEQ_NUM,
2879 bsor.PRINCIPLE_FLAG,
2880 bsor.SETUP_ID,
2881 NULL, --DEPARTMENT_ID
2882 NULL, --PHANTOM_FLAG
2883 NULL, --PHANTOM_OP_SEQ_NUM
2884 NULL, --PHANTOM_ITEM_ID
2885 0, --applied_resource_units
2886 0, --applied_resource_value
2887 p_last_update_date,
2888 p_last_updated_by,
2889 p_last_update_login,
2890 p_creation_date,
2891 p_created_by,
2892 p_request_id,
2893 p_program_app_id,
2894 p_program_id,
2895 p_program_update_date,
2896 bsor.ATTRIBUTE_CATEGORY,
2897 bsor.ATTRIBUTE1,
2898 bsor.ATTRIBUTE2,
2899 bsor.ATTRIBUTE3,
2900 bsor.ATTRIBUTE4,
2901 bsor.ATTRIBUTE5,
2902 bsor.ATTRIBUTE6,
2903 bsor.ATTRIBUTE7,
2904 bsor.ATTRIBUTE8,
2905 bsor.ATTRIBUTE9,
2906 bsor.ATTRIBUTE10,
2907 bsor.ATTRIBUTE11,
2908 bsor.ATTRIBUTE12,
2909 bsor.ATTRIBUTE13,
2910 bsor.ATTRIBUTE14,
2911 bsor.ATTRIBUTE15
2912 FROM BOM_RESOURCES br,
2913 BOM_OPERATION_RESOURCES bor,
2914 BOM_SUB_OPERATION_RESOURCES bsor,
2915 WIP_OPERATIONS wo
2916 WHERE wo.WIP_ENTITY_ID = p_wip_entity_id
2917 AND wo.OPERATION_SEQUENCE_ID = bor.OPERATION_SEQUENCE_ID
2918 AND nvl(p_only_wo_op_seq, WO.operation_seq_num) = WO.operation_seq_num
2919 AND bor.OPERATION_SEQUENCE_ID = bsor.OPERATION_SEQUENCE_ID
2920 AND bor.SUBSTITUTE_GROUP_NUM = bsor.SUBSTITUTE_GROUP_NUM
2921 AND bsor.RESOURCE_ID = br.RESOURCE_ID
2922 AND br.ORGANIZATION_ID = wo.ORGANIZATION_ID;
2923 --End Bugfix 3313454
2924
2925 l_stmt_num := 20;
2926
2927 x_err_code := 0;
2928 x_err_buf := null;
2929 EXCEPTION
2930 WHEN others THEN
2931 x_err_code := SQLCODE;
2932 x_err_buf := 'CREATE_WSOR_WLBJ_RECORDS('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
2933
2934 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2935 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2936 THEN
2937 WSM_log_PVT.handle_others( p_module_name => l_module ,
2938 p_stmt_num => l_stmt_num ,
2939 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2940 p_run_log_level => l_log_level
2941 );
2942 END IF;
2943
2944
2945 END CREATE_WSOR_WLBJ_RECORDS;
2946
2947 /* main procedure ................. */
2948
2949 /*-------------------------------------------------------------+
2950 | Name : CHANGE_ROUTING
2951 ---------------------------------------------------------------*/
2952
2953 PROCEDURE CHANGE_ROUTING (p_txn_id IN NUMBER,
2954 p_wip_entity_id IN NUMBER,
2955 p_org_id IN NUMBER,
2956 p_rj_job_rec IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
2957 p_new_op_added OUT NOCOPY NUMBER,
2958 x_err_code OUT NOCOPY NUMBER,
2959 x_err_buf OUT NOCOPY VARCHAR2)
2960 IS
2961 l_job_op_seq_num NUMBER;
2962 l_job_max_op_seq_num NUMBER;
2963 l_job_op_seq_id NUMBER;
2964 l_job_std_op_id NUMBER;
2965 l_job_intra_op NUMBER;
2966 l_job_dept_id NUMBER;
2967 l_job_qty NUMBER;
2968 l_job_op_start_dt DATE;
2969 l_job_op_comp_dt DATE;
2970
2971
2972 l_charges_exist NUMBER;
2973 l_manually_added_comp NUMBER;
2974 l_issued_material NUMBER;
2975 l_manually_added_resource NUMBER;
2976 l_issued_resource NUMBER;
2977
2978 l_wsm_param_seq_incr NUMBER;
2979
2980 l_op_seq_num NUMBER; -- Added for APS-WLT --
2981 l_fnd_err_msg VARCHAR2(2000);
2982 x_msg_count number;
2983 -- Logging variables.....
2984 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2985 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2986
2987 l_stmt_num NUMBER;
2988 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.CHANGE_ROUTING';
2989 e_upd_txn Exception;
2990
2991 BEGIN
2992
2993 l_stmt_num := 10;
2994
2995 p_new_op_added := NULL; -- Added for APS-WLT--
2996
2997 SELECT nvl(op_seq_num_increment, 10)
2998 INTO l_wsm_param_seq_incr
2999 FROM wsm_parameters
3000 WHERE organization_id = p_org_id;
3001
3002 l_stmt_num := 20;
3003
3004 if( g_log_level_statement >= l_log_level ) then
3005 l_msg_tokens.delete;
3006 WSM_log_PVT.logMessage(p_module_name => l_module ,
3007 p_msg_text => 'Entered procedure CHANGE_ROUTING',
3008 p_stmt_num => l_stmt_num ,
3009 p_msg_tokens => l_msg_tokens,
3010 p_fnd_log_level => g_log_level_statement,
3011 p_run_log_level => l_log_level
3012 );
3013 End if;
3014
3015 x_err_code := 0;
3016 x_err_buf := null;
3017
3018 GET_JOB_CURR_OP_INFO(p_wip_entity_id => p_wip_entity_id,
3019 p_op_seq_num => l_job_op_seq_num,
3020 p_op_seq_id => l_job_op_seq_id,
3021 p_std_op_id => l_job_std_op_id,
3022 p_intra_op => l_job_intra_op,
3023 p_dept_id => l_job_dept_id,
3024 p_op_qty => l_job_qty,
3025 p_op_start_date => l_job_op_start_dt,
3026 p_op_completion_date => l_job_op_comp_dt,
3027 x_err_code => x_err_code,
3028 x_err_buf => x_err_buf,
3029 x_msg_count => x_msg_count
3030 );
3031
3032
3033 IF (x_err_code <> 0) THEN
3034 IF G_LOG_LEVEL_STATEMENT >= l_log_level THEN
3035 l_msg_tokens.delete;
3036 WSM_log_PVT.logMessage(p_module_name => l_module ,
3037 p_msg_text => 'GET_JOB_CURR_OP_INFO returned failure',
3038 p_stmt_num => l_stmt_num ,
3039 p_msg_tokens => l_msg_tokens,
3040 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3041 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3042 p_run_log_level => l_log_level
3043 );
3044 END IF;
3045 RAISE FND_API.G_EXC_ERROR;
3046
3047 END IF;
3048
3049 l_stmt_num := 30;
3050 l_op_seq_num := p_rj_job_rec.STARTING_OPERATION_SEQ_NUM;
3051
3052 IF (l_job_intra_op = WIP_CONSTANTS.QUEUE) THEN
3053
3054 l_stmt_num := 40;
3055 x_err_code := 0;
3056 x_err_buf := null;
3057
3058 WSMPUTIL.check_charges_exist (p_wip_entity_id => p_wip_entity_id,
3059 p_organization_id => p_org_id,
3060 p_op_seq_num => l_job_op_seq_num,
3061 p_op_seq_id => l_job_op_seq_id,
3062 p_charges_exist => l_charges_exist,
3063 p_manually_added_comp => l_manually_added_comp,
3064 p_issued_material => l_issued_material,
3065 p_manually_added_resource => l_manually_added_resource,
3066 p_issued_resource => l_issued_resource,
3067 x_error_code => x_err_code,
3068 x_error_msg => x_err_buf
3069 );
3070
3071
3072
3073 IF (x_err_code <> 0) THEN
3074 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3075 l_msg_tokens.delete;
3076 WSM_log_PVT.logMessage(p_module_name => l_module ,
3077 p_msg_text => x_err_buf ,
3078 p_stmt_num => l_stmt_num ,
3079 p_msg_tokens => l_msg_tokens ,
3080 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3081 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3082 p_run_log_level => l_log_level
3083 );
3084 END IF;
3085 RAISE FND_API.G_EXC_ERROR;
3086 END IF;
3087
3088 IF (l_charges_exist = 1) THEN
3089 IF ((l_manually_added_resource = 1) OR (l_issued_resource = 1)) THEN
3090 fnd_message.set_name('WSM', 'WSM_MANUAL_CHARGES_EXISTS');
3091 fnd_message.set_token('ELEMENT', 'Resources');
3092 l_fnd_err_msg := FND_MESSAGE.GET;
3093
3094 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3095
3096 l_msg_tokens.delete;
3097 l_msg_tokens(1).TokenName := 'ELEMENT';
3098 l_msg_tokens(1).TokenValue := 'Resources';
3099 WSM_log_PVT.logMessage(p_module_name => l_module ,
3100 p_msg_name => 'WSM_MANUAL_CHARGES_EXISTS',
3101 p_msg_appl_name => 'WSM' ,
3102 p_msg_tokens => l_msg_tokens ,
3103 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3104 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3105 p_run_log_level => l_log_level
3106 );
3107 END IF;
3108 if l_issued_resource <> 0 then
3109 raise e_upd_txn;
3110 end if;
3111 END IF;
3112
3113 IF ((l_manually_added_comp = 1) OR (l_issued_material = 1)) THEN
3114 fnd_message.set_name('WSM', 'WSM_MANUAL_CHARGES_EXISTS');
3115 fnd_message.set_token('ELEMENT', 'Materials');
3116 l_fnd_err_msg := FND_MESSAGE.GET;
3117
3118 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3119
3120 l_msg_tokens.delete;
3121 l_msg_tokens(1).TokenName := 'ELEMENT';
3122 l_msg_tokens(1).TokenValue := 'Materials';
3123 WSM_log_PVT.logMessage(p_module_name => l_module ,
3124 p_msg_name => 'WSM_MANUAL_CHARGES_EXISTS',
3125 p_msg_appl_name => 'WSM' ,
3126 p_msg_tokens => l_msg_tokens ,
3127 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3128 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3129 p_run_log_level => l_log_level
3130 );
3131 END IF;
3132 if l_issued_material <> 0 then
3133 raise e_upd_txn;
3134 end if;
3135 END IF;
3136
3137 IF (l_manually_added_comp = 2) THEN
3138 fnd_message.set_name('WSM','WSM_PHANTOM_COMPONENTS_EXISTS');
3139 l_fnd_err_msg := FND_MESSAGE.GET;
3140
3141 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3142
3143 l_msg_tokens.delete;
3144 WSM_log_PVT.logMessage(p_module_name => l_module ,
3145 p_msg_name => 'WSM_PHANTOM_COMPONENTS_EXISTS',
3146 p_msg_appl_name => 'WSM' ,
3147 p_msg_tokens => l_msg_tokens ,
3148 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3149 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3150 p_run_log_level => l_log_level
3151 );
3152 END IF;
3153 END IF;
3154 END IF;
3155
3156 l_stmt_num := 50;
3157
3158 --=== START: OBSOLETE THE OPERATIONS ===--
3159 UPDATE WIP_OPERATIONS
3160 SET COUNT_POINT_TYPE = 3,
3161 SCHEDULED_QUANTITY = 0,
3162 QUANTITY_IN_QUEUE = 0,
3163 LAST_UPDATE_DATE = SYSDATE,
3164 LAST_UPDATED_BY = g_user_id,
3165 LAST_UPDATE_LOGIN = g_user_login_id,
3166 REQUEST_ID = g_request_id,
3167 PROGRAM_APPLICATION_ID = g_program_appl_id,
3168 PROGRAM_ID = g_program_id,
3169 PROGRAM_UPDATE_DATE = SYSDATE,
3170 DISABLE_DATE = SYSDATE -- bug 2931071
3171 WHERE WIP_ENTITY_ID = p_wip_entity_id
3172 AND ORGANIZATION_ID = p_org_id
3173 AND OPERATION_SEQ_NUM >= l_job_op_seq_num;
3174
3175 l_stmt_num := 55;
3176
3177 -- Start Additions to fix bug #2682612--
3178 UPDATE WIP_REQUIREMENT_OPERATIONS
3179 SET required_quantity = 0
3180 WHERE WIP_ENTITY_ID = p_wip_entity_id
3181 AND ORGANIZATION_ID = p_org_id
3182 AND (OPERATION_SEQ_NUM >= l_job_op_seq_num
3183 OR
3184 OPERATION_SEQ_NUM <= 0-l_job_op_seq_num
3185 );
3186
3187 l_stmt_num := 60;
3188
3189 UPDATE WIP_OPERATION_RESOURCES
3190 SET autocharge_type = 2
3191 WHERE WIP_ENTITY_ID = p_wip_entity_id
3192 AND ORGANIZATION_ID = p_org_id
3193 AND OPERATION_SEQ_NUM >= l_job_op_seq_num;
3194
3195 -- End Additions to fix bug #2682612--
3196
3197 --=== END: OBSOLETE THE OPERATIONS ===--
3198 -- Start : Additions for APS-WLT--
3199
3200 ELSIF (l_job_intra_op = WIP_CONSTANTS.TOMOVE) THEN
3201 l_stmt_num := 61;
3202
3203 l_job_op_start_dt := l_job_op_comp_dt; --Bug 3318382
3204
3205 IF (l_op_seq_num IS NULL) THEN
3206 -- Starting op may not be provided
3207 -- for Option A, if the job is at TM
3208 return;
3209 ELSE -- If starting operation is provided
3210 l_stmt_num := 62;
3211
3212 UPDATE WIP_OPERATIONS
3213 SET QUANTITY_WAITING_TO_MOVE = 0,
3214 LAST_UPDATE_DATE = SYSDATE,
3215 LAST_UPDATED_BY = g_user_id,
3216 LAST_UPDATE_LOGIN = g_user_login_id,
3217 REQUEST_ID = g_request_id,
3218 PROGRAM_APPLICATION_ID = g_program_appl_id,
3219 PROGRAM_ID = g_program_id,
3220 PROGRAM_UPDATE_DATE = SYSDATE
3221 WHERE WIP_ENTITY_ID = p_wip_entity_id
3222 AND ORGANIZATION_ID = p_org_id
3223 AND OPERATION_SEQ_NUM = l_job_op_seq_num;
3224 END IF;
3225
3226 END IF;
3227 -- End : Additions for APS-WLT--
3228 l_stmt_num := 65;
3229
3230 --Add target op with new bom/rtg info into WO, WOR, WRO, WOY, fnd_attach as prev_op + incr
3231
3232 l_stmt_num := 80;
3233
3234 SELECT max(operation_seq_num)
3235 INTO l_job_max_op_seq_num
3236 FROM wip_operations
3237 WHERE wip_entity_id = p_wip_entity_id;
3238
3239 p_new_op_added := l_job_max_op_seq_num + l_wsm_param_seq_incr;
3240
3241 l_stmt_num := 85;
3242
3243 if( g_log_level_statement >= l_log_level ) then
3244 l_msg_tokens.delete;
3245 WSM_log_PVT.logMessage(p_module_name => l_module ,
3246 p_msg_text => 'Calling WSMPLBJI.insert_procedure :' ||p_rj_job_rec.starting_operation_seq_id,
3247 p_stmt_num => l_stmt_num ,
3248 p_msg_tokens => l_msg_tokens,
3249 p_fnd_log_level => g_log_level_statement,
3250 p_run_log_level => l_log_level
3251 );
3252 End if;
3253
3254 x_err_code := 0;
3255 x_err_buf := null;
3256
3257 WSMPLBJI.insert_procedure
3258 (p_seq_id => p_rj_job_rec.starting_operation_seq_id,
3259 p_job_seq_num => p_new_op_added,
3260 p_common_routing_sequence_id => p_rj_job_rec.common_routing_sequence_id,
3261 p_supply_type => p_rj_job_rec.wip_supply_type,
3262 p_wip_entity_id => p_wip_entity_id,
3263 p_organization_id => p_org_id,
3264 p_quantity => p_rj_job_rec.start_quantity,
3265 p_job_type => p_rj_job_rec.job_type,
3266 p_bom_reference_id => p_rj_job_rec.bom_reference_id,
3267 p_rtg_reference_id => p_rj_job_rec.routing_reference_id,
3268 p_assembly_item_id => p_rj_job_rec.primary_item_id,
3269 p_alt_bom_designator => p_rj_job_rec.alternate_bom_designator,
3270 p_alt_rtg_designator => p_rj_job_rec.alternate_routing_designator,
3271 --Bug 3318382 p_fusd => l_sch_st_dt,
3272 --Bug 3318382 p_lucd => l_sch_comp_dt,
3273 --Bug 3318382
3274 p_fusd => l_job_op_start_dt,
3275 --Bug 3318382
3276 p_lucd => l_job_op_comp_dt,
3277
3278 p_rtg_revision_date => p_rj_job_rec.routing_revision_date,
3279 p_bom_revision_date => p_rj_job_rec.bom_revision_date,
3280 p_last_updt_date => sysdate,
3281 p_last_updt_by => g_user_id,
3282 p_creation_date => sysdate,
3283 p_created_by => g_user_id,
3284 p_last_updt_login => g_user_login_id,
3285 p_request_id => g_request_id,
3286 p_program_application_id => g_program_appl_id,
3287 p_program_id => g_program_id,
3288 p_prog_updt_date => sysdate,
3289 p_error_code => x_err_code,
3290 p_error_msg => x_err_buf
3291 );
3292
3293 IF (x_err_code <> 0) THEN
3294
3295 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3296 l_msg_tokens.delete;
3297 WSM_log_PVT.logMessage(p_module_name => l_module ,
3298 p_msg_text => 'Returned failure from WSMPLBJI.insert_procedure.Error:'|| x_err_buf,
3299 p_stmt_num => l_stmt_num ,
3300 p_msg_tokens => l_msg_tokens,
3301 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3302 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3303 p_run_log_level => l_log_level
3304 );
3305 END IF;
3306 RAISE FND_API.G_EXC_ERROR;
3307 END IF;
3308
3309 -- Start : Additions to fix bug 3452913 --
3310 UPDATE wip_operations
3311 SET wsm_op_seq_num = l_op_seq_num
3312 WHERE wip_entity_id = p_wip_entity_id
3313 AND operation_seq_num = p_new_op_added;
3314 -- End : Additions to fix bug 3452913 --
3315
3316 l_stmt_num := 90;
3317
3318 --Start : Additions for APS-WLT--
3319 IF (WSMPJUPD.g_copy_mode = 0) THEN
3320 null;
3321 ELSE
3322 l_stmt_num := 92;
3323 -- Create WSOR table records --
3324 x_err_code := 0;
3325 x_err_buf := null;
3326
3327 CREATE_WSOR_WLBJ_RECORDS( p_wip_entity_id => p_wip_entity_id,
3328 p_org_id => p_org_id,
3329 p_only_wo_op_seq => p_new_op_added, -- Create only this record
3330 p_last_update_date => sysdate,
3331 p_last_updated_by => g_user_id,
3332 p_last_update_login => g_user_login_id,
3333 p_creation_date => sysdate,
3334 p_created_by => g_user_id,
3335 p_request_id => g_request_id,
3336 p_program_app_id => g_program_appl_id,
3337 p_program_id => g_program_id,
3338 p_program_update_date => sysdate,
3339 x_err_code => x_err_code,
3340 x_err_buf => x_err_buf
3341 );
3342
3343
3344 IF (x_err_code <> 0) THEN
3345 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3346
3347 l_msg_tokens.delete;
3348 WSM_log_PVT.logMessage(p_module_name => l_module ,
3349 p_msg_text => 'Returned failure from CREATE_WSOR_WLBJ_RECORDS',
3350 p_stmt_num => l_stmt_num ,
3351 p_msg_tokens => l_msg_tokens,
3352 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3353 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3354 p_run_log_level => l_log_level
3355 );
3356 END IF;
3357 RAISE FND_API.G_EXC_ERROR;
3358 ELSE
3359
3360 if( g_log_level_statement >= l_log_level ) then
3361 l_msg_tokens.delete;
3362 WSM_log_PVT.logMessage(p_module_name => l_module ,
3363 p_msg_text => 'Created WSOR records for new job with id='||p_wip_entity_id,
3364 p_stmt_num => l_stmt_num ,
3365 p_msg_tokens => l_msg_tokens,
3366 p_fnd_log_level => g_log_level_statement,
3367 p_run_log_level => l_log_level
3368 );
3369 End if;
3370
3371 END IF;
3372
3373 END IF; --WSMPJUPD.g_copy_mode
3374 --End : Additions for APS-WLT--
3375
3376 l_stmt_num := 95;
3377
3378 --Update the previous and next op seq nums
3379 UPDATE WIP_OPERATIONS WO
3380 SET WO.PREVIOUS_OPERATION_SEQ_NUM = (SELECT MAX(OPERATION_SEQ_NUM)
3381 FROM WIP_OPERATIONS
3382 WHERE WIP_ENTITY_ID = p_wip_entity_id
3383 AND OPERATION_SEQ_NUM < WO.OPERATION_SEQ_NUM),
3384 WO.NEXT_OPERATION_SEQ_NUM = (SELECT MIN(OPERATION_SEQ_NUM)
3385 FROM WIP_OPERATIONS
3386 WHERE WIP_ENTITY_ID = p_wip_entity_id
3387 AND OPERATION_SEQ_NUM > WO.OPERATION_SEQ_NUM)
3388 WHERE WO.WIP_ENTITY_ID = p_wip_entity_id;
3389
3390 l_stmt_num := 100;
3391
3392 --Set qty in Queue of the target operation
3393 UPDATE WIP_OPERATIONS
3394 SET quantity_in_queue = l_job_qty
3395 WHERE wip_entity_id = p_wip_entity_id
3396 AND operation_seq_num = p_new_op_added;
3397
3398
3399 l_stmt_num := 110;
3400 x_err_code := 0;
3401 x_err_buf := NULL;
3402
3403
3404 EXCEPTION
3405 WHEN e_upd_txn THEN
3406 x_err_code := -100;
3407 x_err_buf := l_fnd_err_msg;
3408 WHEN FND_API.G_EXC_ERROR THEN
3409 x_err_code := SQLCODE;
3410 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3411 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3412 p_count => x_msg_count ,
3413 p_data => x_err_buf
3414 );
3415 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3416 x_err_code := SQLCODE;
3417 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3418 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3419 p_count => x_msg_count ,
3420 p_data => x_err_buf
3421 );
3422 WHEN OTHERS THEN
3423 x_err_code := SQLCODE;
3424 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3425
3426 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3427 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3428 THEN
3429 WSM_log_PVT.handle_others( p_module_name => l_module ,
3430 p_stmt_num => l_stmt_num ,
3431 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3432 p_run_log_level => l_log_level
3433 );
3434 END IF;
3435 END CHANGE_ROUTING;
3436 -- end ..............
3437
3438
3439 /*-----------------------------------------------------------------+
3440 | Name : UPDATE_ASSEMBLY_OR_ROUTING
3441 -------------------------------------------------------------------*/
3442
3443
3444 --SpUA begin: Moved Update Assembly/Routing code from Process_Wip_Lot_Txns here.
3445 -- To be used by Split and Update Assy, Update Assy, Update Routing txns.
3446
3447 PROCEDURE UPDATE_ASSEMBLY_OR_ROUTING(p_txn_id IN NUMBER,
3448 p_txn_type_id IN NUMBER,
3449 p_job_kanban_card_id IN NUMBER, --abbKanban
3450 p_po_creation_time IN NUMBER, --osp
3451 p_request_id IN NUMBER, --osp
3452 p_sj_compl_subinventory IN VARCHAR2,
3453 p_sj_compl_locator_id IN NUMBER,
3454 p_rj_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
3455 x_err_code OUT NOCOPY NUMBER,
3456 x_err_buf OUT NOCOPY VARCHAR2,
3457 x_msg_count OUT NOCOPY NUMBER)
3458
3459 IS
3460
3461 l_txn_type_id NUMBER;
3462 l_org_id NUMBER;
3463 l_wip_entity_id NUMBER;
3464 l_new_op_added NUMBER;
3465 l_po_creation_time NUMBER; --osp
3466 l_request_id NUMBER; --osp
3467 l_job_kanban_card_id NUMBER; --abbKanban
3468 l_kanban_card_id NUMBER; --abbKanban
3469 l_sub_loc_change NUMBER; --abbKanban
3470 l_return_status VARCHAR2(1); --abbKanban
3471 translated_meaning VARCHAR2(240); --abbkanban
3472 l_rtg_op_seq_num NUMBER;
3473
3474 -- Logging variables.....
3475 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3476 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3477
3478 l_stmt_num NUMBER;
3479 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.UPDATE_ASSEMBLY_OR_ROUTING';
3480
3481 BEGIN
3482
3483 l_txn_type_id := p_txn_type_id;
3484 l_org_id := p_rj_job_rec.organization_id;
3485 l_wip_entity_id := p_rj_job_rec.wip_entity_id;
3486 l_job_kanban_card_id := p_job_kanban_card_id;
3487 l_po_creation_time := p_po_creation_time;
3488 l_request_id := p_request_id;
3489
3490 -- SpUA : l_wip_entity_id is resulting job wip_id for Split and Update Assy
3491 -- and for other transactions, it is starting job wip_id -- this is obvious.. comeon...
3492 --
3493
3494 IF l_txn_type_id = WSMPCNST.UPDATE_ROUTING THEN
3495 l_stmt_num := 190;
3496
3497 if l_job_kanban_card_id is not null then
3498
3499 l_sub_loc_change := handle_kanban_sub_loc_change( p_wip_entity_id => p_rj_job_rec.wip_entity_id,
3500 p_kanban_card_id => l_job_kanban_card_id,
3501 p_wssj_completion_subinventory => p_sj_compl_subinventory,
3502 p_wssj_completion_locator_id => p_sj_compl_locator_id,
3503 p_wsrj_completion_subinventory => p_rj_job_rec.completion_subinventory,
3504 p_wsrj_completion_locator_id => p_rj_job_rec.completion_locator_id,
3505 x_err_code => x_err_code,
3506 x_err_msg => x_err_buf
3507 );
3508
3509 IF (x_err_code <> 0) THEN
3510 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3511
3512 l_msg_tokens.delete;
3513 WSM_log_PVT.logMessage(p_module_name => l_module ,
3514 p_msg_text => 'Handle_kanban_sub_loc_change returned error: ' || x_err_buf,
3515 p_stmt_num => l_stmt_num ,
3516 p_msg_tokens => l_msg_tokens,
3517 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3518 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3519 p_run_log_level => l_log_level
3520 );
3521 END IF;
3522 RAISE FND_API.G_EXC_ERROR;
3523
3524 END IF;
3525
3526 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
3527 if l_sub_loc_change <> 0 then
3528 l_job_kanban_card_id := null;
3529 end if;
3530 end if;
3531
3532 UPDATE wip_discrete_jobs wdj
3533 SET routing_reference_id = p_rj_job_rec.routing_reference_id,
3534 alternate_routing_designator = p_rj_job_rec.alternate_routing_designator,
3535 common_routing_sequence_id = p_rj_job_rec.common_routing_sequence_id,
3536 routing_revision = p_rj_job_rec.routing_revision,
3537 routing_revision_date = p_rj_job_rec.routing_revision_date,
3538 completion_subinventory = p_rj_job_rec.completion_subinventory,
3539 completion_locator_id = p_rj_job_rec.completion_locator_id,
3540 kanban_card_id = l_job_kanban_card_id,
3541 -- ST : Fix for bug 5254137 : Update the BOM Info as well for Update Rtg as Bom data can be changed during upd rtg..
3542 --Bug 5491020:bom_reference_id is updated by p_rj_job_rec.bom_reference_id
3543 bom_reference_id = p_rj_job_rec.bom_reference_id, --routing_reference_id,
3544 alternate_bom_designator = p_rj_job_rec.alternate_bom_designator,
3545 common_bom_sequence_id = p_rj_job_rec.common_bom_sequence_id,
3546 bom_revision = p_rj_job_rec.bom_revision,
3547 bom_revision_date = p_rj_job_rec.bom_revision_date,
3548 -- ST : Fix for bug 5254137 end --
3549 last_update_date = sysdate,
3550 last_updated_by = g_user_id
3551 WHERE wdj.wip_entity_id = l_wip_entity_id;
3552
3553 --SpUA: add Split
3554 ELSIF l_txn_type_id IN (WSMPCNST.UPDATE_ASSEMBLY, WSMPCNST.SPLIT) THEN
3555
3556 l_stmt_num := 200;
3557
3558 -- abbKanban begin
3559 l_stmt_num := 203;
3560
3561
3562 if l_job_kanban_card_id is not null then
3563
3564 l_return_status := null;
3565
3566 INV_Kanban_PVT.Update_Card_Supply_Status(X_Return_Status => l_return_status,
3567 p_Kanban_Card_Id => l_job_kanban_card_id,
3568 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
3569 );
3570
3571 if ( l_return_status <> fnd_api.g_ret_sts_success ) then
3572 x_err_code := -1;
3573 fnd_message.set_name('WSM', 'WSM_KNBN_CARD_STS_FAIL');
3574
3575 fnd_message.set_token('STATUS',g_translated_meaning);
3576 x_err_buf := fnd_message.get;
3577
3578 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3579
3580 l_msg_tokens.delete;
3581 l_msg_tokens(1).TokenName := 'STATUS';
3582 l_msg_tokens(1).TokenValue := g_translated_meaning;
3583 WSM_log_PVT.logMessage(p_module_name => l_module ,
3584 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
3585 p_msg_appl_name => 'WSM' ,
3586 p_msg_tokens => l_msg_tokens ,
3587 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3588 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3589 p_run_log_level => l_log_level
3590 );
3591 END IF;
3592 RAISE FND_API.G_EXC_ERROR;
3593
3594 end if;
3595
3596 l_job_kanban_card_id := null;
3597
3598 l_stmt_num := 207;
3599
3600 end if; -- kanban_card_id not null
3601
3602
3603 UPDATE wip_discrete_jobs wdj
3604 SET primary_item_id = p_rj_job_rec.primary_item_id,
3605 kanban_card_id = l_job_kanban_card_id,
3606 routing_reference_id = p_rj_job_rec.routing_reference_id,
3607 alternate_routing_designator = p_rj_job_rec.alternate_routing_designator,
3608 common_routing_sequence_id = p_rj_job_rec.common_routing_sequence_id,
3609 routing_revision = p_rj_job_rec.routing_revision,
3610 routing_revision_date = p_rj_job_rec.routing_revision_date,
3611 completion_subinventory = p_rj_job_rec.completion_subinventory,
3612 completion_locator_id = p_rj_job_rec.completion_locator_id,
3613 --Bug 5491020:bom_reference_id is updated by p_rj_job_rec.bom_reference_id
3614 bom_reference_id = p_rj_job_rec.bom_reference_id, --routing_reference_id,
3615 alternate_bom_designator = p_rj_job_rec.alternate_bom_designator,
3616 common_bom_sequence_id = p_rj_job_rec.common_bom_sequence_id,
3617 bom_revision = p_rj_job_rec.bom_revision,
3618 bom_revision_date = p_rj_job_rec.bom_revision_date,
3619 last_update_date = sysdate,
3620 last_updated_by = g_user_id
3621 WHERE wdj.wip_entity_id = l_wip_entity_id;
3622
3623 -- ST : Fix for bug 5122653 --
3624 -- Update the details in WIP_ENTITIES as well...
3625 UPDATE wip_entities
3626 SET primary_item_id = p_rj_job_rec.primary_item_id
3627 WHERE wip_entity_id = l_wip_entity_id;
3628 -- ST : Fix for bug 5122653 end --
3629
3630 END IF;
3631
3632 l_stmt_num := 210;
3633 CHANGE_ROUTING (p_txn_id => p_txn_id,
3634 p_wip_entity_id => l_wip_entity_id,
3635 p_org_id => l_org_id,
3636 p_rj_job_rec => p_rj_job_rec,
3637 p_new_op_added => l_new_op_added,
3638 x_err_code => x_err_code,
3639 x_err_buf => x_err_buf
3640 );
3641
3642 IF (x_err_code <> 0) THEN
3643 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3644
3645 l_msg_tokens.delete;
3646 WSM_log_PVT.logMessage(p_module_name => l_module ,
3647 p_msg_text => 'CHANGE_ROUTING returned error:'||x_err_buf,
3648 p_stmt_num => l_stmt_num ,
3649 p_msg_tokens => l_msg_tokens,
3650 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3651 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3652 p_run_log_level => l_log_level
3653 );
3654 END IF;
3655 RAISE FND_API.G_EXC_ERROR;
3656 ELSE
3657
3658 IF (l_new_op_added IS NOT NULL) THEN -- Added condition check for APS-WLT --
3659 if( g_log_level_statement >= l_log_level ) then
3660 l_msg_tokens.delete;
3661 WSM_log_PVT.logMessage(p_module_name => l_module ,
3662 p_msg_text => 'Added new operation sequence '||l_new_op_added||' to the job',
3663 p_stmt_num => l_stmt_num ,
3664 p_msg_tokens => l_msg_tokens,
3665 p_fnd_log_level => g_log_level_statement,
3666 p_run_log_level => l_log_level
3667 );
3668 End if;
3669 END IF;
3670 END IF;
3671
3672 l_stmt_num := 220;
3673 p_rj_job_rec.job_operation_seq_num := l_new_op_added;
3674
3675 BEGIN
3676 -- Obtain the op seq num...
3677 SELECT operation_seq_num
3678 into l_rtg_op_seq_num
3679 from bom_operation_sequences
3680 where operation_sequence_id = p_rj_job_rec.starting_operation_seq_id;
3681
3682 EXCEPTION
3683 WHEN NO_DATA_FOUND THEN
3684 l_rtg_op_seq_num := null;
3685 END;
3686
3687 -- Update the WSM_LOT_BASED_JOBS table...
3688 update wsm_lot_based_jobs
3689 set current_rtg_op_seq_num = l_rtg_op_seq_num,
3690 current_job_op_seq_num = l_new_op_added
3691 where wip_entity_id = l_wip_entity_id;
3692
3693 --osp
3694 IF (WSMPUTIL.check_osp_operation(p_wip_entity_id => l_wip_entity_id,
3695 p_operation_seq_num => l_new_op_added,
3696 p_organization_id => l_org_id))
3697 THEN
3698
3699 WSMPJUPD.g_osp_exists := 1;
3700
3701 if (l_po_creation_time <> WIP_CONSTANTS.MANUAL_CREATION) then
3702 --if l_request_id is null means online processing so launch import req
3703 -- (i.e) not from the Interface
3704 --Bug 5263262: During online processing l_request_id will be
3705 ---1.Hence check on -1 is also included in the if condition below.
3706 if (l_request_id is null or l_request_id = -1) then
3707 l_stmt_num := 223;
3708 wip_osp.create_requisition( P_Wip_Entity_Id => l_wip_entity_id,
3709 P_Organization_Id => l_org_id,
3710 P_Repetitive_Schedule_Id => null,
3711 P_Operation_Seq_Num => l_new_op_added,
3712 P_Resource_Seq_Num => null,
3713 P_Run_ReqImport => WIP_CONSTANTS.YES);
3714 else
3715 l_stmt_num := 227;
3716 wip_osp.create_requisition( P_Wip_Entity_Id => l_wip_entity_id,
3717 P_Organization_Id => l_org_id,
3718 P_Repetitive_Schedule_Id => null,
3719 P_Operation_Seq_Num => l_new_op_added,
3720 P_Resource_Seq_Num => null,
3721 P_Run_ReqImport => WIP_CONSTANTS.NO);
3722 end if;
3723 end if;
3724
3725 END IF;
3726 --WSMPUTIL.check_osp_operation
3727 --osp end
3728
3729 x_err_code := 0;
3730 x_err_buf := null;
3731
3732 EXCEPTION
3733 WHEN FND_API.G_EXC_ERROR THEN
3734 x_err_code := -1;
3735 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||x_err_buf;
3736 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
3737 p_count => x_msg_count ,
3738 p_data => x_err_buf
3739 );
3740
3741 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3742 x_err_code := -1;
3743 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||x_err_buf;
3744 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3745 p_count => x_msg_count ,
3746 p_data => x_err_buf
3747 );
3748 WHEN OTHERS THEN
3749 x_err_code := SQLCODE;
3750 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3751
3752 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3753 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3754 THEN
3755 WSM_log_PVT.handle_others( p_module_name => l_module ,
3756 p_stmt_num => l_stmt_num ,
3757 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3758 p_run_log_level => l_log_level
3759 );
3760 END IF;
3761
3762 END UPDATE_ASSEMBLY_OR_ROUTING;
3763 /*EA SpUA*/
3764
3765
3766 Procedure Insert_MMT_record ( p_txn_id IN NUMBER,
3767 p_txn_org_id IN NUMBER,
3768 p_txn_date IN DATE,
3769 p_txn_type_id IN NUMBER,
3770 p_sj_wip_entity_id IN NUMBER,
3771 p_sj_wip_entity_name IN VARCHAR2,
3772 p_sj_avail_quantity IN NUMBER,
3773 p_rj_wip_entity_id IN NUMBER,
3774 p_rj_wip_entity_name IN VARCHAR2,
3775 p_rj_start_quantity IN NUMBER,
3776 p_sj_item_id IN number,
3777 p_sj_op_seq_num IN number,
3778 x_return_status OUT NOCOPY VARCHAR2,
3779 x_msg_count OUT NOCOPY NUMBER,
3780 x_msg_data OUT NOCOPY VARCHAR2
3781 ) is
3782
3783 l_wms_org mtl_parameters.wms_enabled_flag%type;
3784 l_def_cost_grp_id mtl_parameters.default_cost_group_id%type;
3785
3786 l_acct_period_id number;
3787
3788 l_err_code number;
3789 l_err_buf varchar2(2000);
3790
3791 -- Logging variables.....
3792 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3793 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3794
3795 l_stmt_num NUMBER;
3796 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.Insert_MMT_record';
3797
3798
3799 begin
3800 l_stmt_num := 10;
3801 --Start additions to fix bug #2828376--
3802 SELECT wms_enabled_flag,
3803 default_cost_group_id
3804 INTO l_wms_org,
3805 l_def_cost_grp_id
3806 FROM mtl_parameters
3807 WHERE organization_id = p_txn_org_id;
3808 --End additions to fix bug #2828376--
3809
3810 l_stmt_num := 20;
3811 l_err_code := 0;
3812 l_err_buf := null;
3813
3814 l_acct_period_id := WSMPUTIL.GET_INV_ACCT_PERIOD(l_err_code,
3815 l_err_buf,
3816 p_txn_org_id,
3817 p_txn_date);
3818 --End NL BugFix 3126650
3819
3820 IF (l_err_code <> 0) THEN
3821 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3822
3823 l_msg_tokens.delete;
3824 WSM_log_PVT.logMessage(p_module_name => l_module ,
3825 p_msg_text => 'WSMPUTIL.GET_INV_ACCT_PERIOD returned error:' || l_err_buf,
3826 p_stmt_num => l_stmt_num ,
3827 p_msg_tokens => l_msg_tokens,
3828 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3829 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3830 p_run_log_level => l_log_level
3831 );
3832 END IF;
3833 RAISE FND_API.G_EXC_ERROR;
3834 END IF;
3835
3836 l_stmt_num := 30;
3837
3838 INSERT INTO mtl_material_transactions
3839 (TRANSACTION_ID,
3840 LAST_UPDATE_DATE,
3841 LAST_UPDATED_BY,
3842 LAST_UPDATE_LOGIN,
3843 CREATION_DATE,
3844 CREATED_BY,
3845 REQUEST_ID,
3846 PROGRAM_APPLICATION_ID,
3847 PROGRAM_ID,
3848 PROGRAM_UPDATE_DATE,
3849 ORGANIZATION_ID,
3850 TRANSACTION_TYPE_ID,
3851 INVENTORY_ITEM_ID,
3852 TRANSACTION_ACTION_ID,
3853 TRANSACTION_SOURCE_TYPE_ID,
3854 TRANSACTION_SOURCE_ID,
3855 TRANSACTION_SOURCE_NAME,
3856 TRANSACTION_QUANTITY,
3857 PRIMARY_QUANTITY,
3858 TRANSACTION_UOM,
3859 TRANSACTION_DATE,
3860 SOURCE_LINE_ID,
3861 OPERATION_SEQ_NUM,
3862 ACCT_PERIOD_ID,
3863 COSTED_FLAG,
3864 COST_GROUP_ID --VJ: Added to fix bug #2828376
3865 )
3866 SELECT mtl_material_transactions_s.nextval,
3867 sysdate,
3868 g_USER_ID,
3869 g_user_LOGIN_ID,
3870 sysdate,
3871 g_USER_ID,
3872 g_REQUEST_ID,
3873 g_program_appl_id,
3874 g_PROGRAM_ID,
3875 sysdate,
3876 p_txn_org_id,
3877 MTT.transaction_type_id,
3878 -- Start : Changes as required by CST for SpUA --
3879 p_sj_item_id,
3880 -- End : Changes as required by CST for SpUA --
3881 decode(p_txn_type_id, WSMPCNST.SPLIT, 40,
3882 WSMPCNST.MERGE, 41,
3883 WSMPCNST.BONUS, 42,
3884 WSMPCNST.UPDATE_QUANTITY, 43,
3885 0),
3886 MTT.transaction_source_type_id,
3887 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_wip_entity_id, p_rj_wip_entity_id),
3888 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_wip_entity_name, p_rj_wip_entity_name),
3889 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_avail_quantity, p_rj_start_quantity),
3890 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_avail_quantity, p_rj_start_quantity),
3891 MSI.primary_uom_code,
3892 p_txn_date,
3893 p_txn_id,
3894 p_sj_op_seq_num,
3895 OAP.acct_period_id,
3896 'N',
3897 decode(l_wms_org, 'Y', l_def_cost_grp_id, NULL) --VJ: Added to fix bug #2828376
3898 FROM mtl_system_items MSI,
3899 org_acct_periods OAP,
3900 mtl_transaction_types MTT
3901 -- Start : Changes as required by CST for SpUA --
3902 WHERE p_sj_item_id = MSI.inventory_item_id
3903 AND p_txn_org_id = MSI.organization_id
3904 -- End : Changes as required by CST for SpUA --
3905 AND p_txn_org_id = OAP.organization_id
3906 AND trunc(p_txn_date) between period_start_date and schedule_close_date
3907 -- Fixed bug #2828278
3908 -- Added trunc above: sch_close_date doesnt have timestamp so a problem for end of month
3909 AND MTT.transaction_action_id IN(decode(p_txn_type_id, WSMPCNST.SPLIT, 40,
3910 WSMPCNST.MERGE, 41,
3911 WSMPCNST.BONUS, 42,
3912 WSMPCNST.UPDATE_QUANTITY, 43,
3913 0)
3914 )
3915 AND MTT.transaction_source_type_id = 5;
3916
3917 --Start additions to fix bug #3048394--
3918 IF (SQL%ROWCOUNT <> 1) THEN
3919
3920 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3921
3922 l_msg_tokens.delete;
3923 l_msg_tokens(1).TokenName := 'ELEMENT';
3924 l_msg_tokens(1).TokenValue := 'mtl_material_transactions';
3925 WSM_log_PVT.logMessage(p_module_name => l_module ,
3926 p_msg_name => 'WSM_INS_TBL_FAILED',
3927 p_msg_appl_name => 'WSM' ,
3928 p_msg_tokens => l_msg_tokens ,
3929 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3930 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3931 p_run_log_level => l_log_level
3932 );
3933 END IF;
3934
3935 end if;
3936
3937 /* set the return status to succes... */
3938 x_return_status := fnd_api.g_ret_sts_success;
3939
3940 exception
3941 WHEN FND_API.G_EXC_ERROR THEN
3942
3943 x_return_status := G_RET_ERROR;
3944 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
3945 p_count => x_msg_count ,
3946 p_data => x_msg_data
3947 );
3948
3949 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3950
3951 x_return_status := G_RET_UNEXPECTED;
3952
3953 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3954 p_count => x_msg_count ,
3955 p_data => x_msg_data
3956 );
3957 when others then
3958 /* handle it... */
3959 x_return_status := fnd_api.g_ret_sts_error;
3960 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
3961
3962 l_msg_tokens.delete;
3963 WSM_log_PVT.logMessage (p_module_name => l_module ,
3964 p_msg_text => SUBSTRB('Unexpected Error : SQLCODE '|| SQLCODE ||' : SQLERRM : '|| SQLERRM, 1, 2000),
3965 p_stmt_num => l_stmt_num ,
3966 p_msg_tokens => l_msg_tokens ,
3967 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3968 p_run_log_level => l_log_level
3969 );
3970
3971 END IF;
3972
3973 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3974 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3975 THEN
3976 WSM_log_PVT.handle_others( p_module_name => l_module ,
3977 p_stmt_num => l_stmt_num ,
3978 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3979 p_run_log_level => l_log_level
3980 );
3981 END IF;
3982
3983 end;
3984
3985 /* have to work on this procedure.... */
3986
3987 /*------------------------------------------------------------------+
3988 | Name : CREATE_COPIES_OR_SET_COPY_DATA |
3989 | This procedure is called from the form and interface |
3990 | NOT a private procedure |
3991 -------------------------------------------------------------------*/
3992
3993 PROCEDURE CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id IN NUMBER,
3994 p_txn_type_id IN NUMBER,
3995 p_copy_mode IN NUMBER,
3996 p_rep_sj_index IN NUMBER,
3997 p_sj_as_rj_index IN NUMBER,
3998 p_wltx_starting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
3999 p_wltx_resulting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
4000 x_err_code OUT NOCOPY NUMBER,
4001 x_err_buf OUT NOCOPY VARCHAR2,
4002 x_msg_count OUT NOCOPY NUMBER)
4003 IS
4004 l_res_rtg_item_id NUMBER; -- Fix for bug #3347947
4005 l_res_bill_item_id NUMBER; -- Fix for bug #3347947
4006
4007 l_res_bill_seq_id NUMBER; -- Fix for bug #3286849
4008
4009 l_new_job_int_copy_type NUMBER;
4010 l_rep_job_par_we_id NUMBER;
4011
4012 l_rj_counter NUMBER;
4013 l_sj_counter NUMBER;
4014 l_rep_wip_entity_id NUMBER;
4015
4016 -- Logging variables.....
4017 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4018 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4019
4020 l_stmt_num NUMBER;
4021 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPDB.CREATE_COPIES_OR_SET_COPY_DATA';
4022 -- Logging variables...
4023 l_phantom_exists NUMBER;
4024 BEGIN
4025
4026 l_stmt_num := 10;
4027
4028 -- IF (g_debug = 'Y') THEN
4029 -- fnd_file.put_line(fnd_file.log, 'In CREATE_COPIES_OR_SET_COPY_DATA '||
4030 -- 'for p_txn_id='||p_txn_id||
4031 -- ' p_txn_type_id='||p_txn_type_id||
4032 -- ' p_copy_mode='||p_copy_mode);
4033 -- END IF;
4034
4035
4036 IF (p_txn_type_id IN (WSMPCNST.BONUS,
4037 WSMPCNST.UPDATE_ASSEMBLY, WSMPCNST.UPDATE_ROUTING)) THEN
4038
4039 l_stmt_num := 11;
4040
4041 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4042
4043 l_stmt_num := 20;
4044
4045 l_rj_counter := p_wltx_resulting_jobs_tbl.first;
4046
4047 if p_wltx_resulting_jobs_tbl(l_rj_counter).job_type = WIP_CONSTANTS.STANDARD then
4048 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id;
4049 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id;
4050 else
4051 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).routing_reference_id;
4052 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).bom_reference_id;
4053 end if;
4054
4055
4056 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id);
4057 --OPTII-PERF:Find if phantom exists or not.
4058 BEGIN
4059 select 1 into l_phantom_exists
4060 from bom_inventory_components
4061 where bill_sequence_id = p_wltx_resulting_jobs_tbl(l_rj_counter).common_bom_sequence_id
4062 and p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date between effectivity_date and
4063 nvl(disable_date,p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date+1)
4064 and wip_supply_type = 6
4065 and rownum = 1;
4066
4067 l_phantom_exists := 1;
4068 EXCEPTION
4069 WHEN OTHERS THEN
4070 l_phantom_exists := 2;
4071 END;
4072
4073 -- related bugs : 3348704, 3347947 , 3286849 , 3303267
4074 WSM_JobCopies_PVT.Create_JobCopies -- Call #1
4075 (x_err_buf => x_err_buf,
4076 x_err_code => x_err_code,
4077 p_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id,
4078 p_org_id => p_wltx_resulting_jobs_tbl(l_rj_counter).organization_id,
4079 p_primary_item_id => p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id,
4080 p_routing_item_id => l_res_rtg_item_id,-- Fix for bug #3347947
4081 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(l_rj_counter).alternate_routing_designator,-- Fix for bug #3347947
4082 p_rtg_seq_id => NULL, -- Will be NULL till reqd for some functionality
4083 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(l_rj_counter).common_routing_sequence_id,
4084 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(l_rj_counter).routing_revision_date,
4085 p_bill_item_id => l_res_bill_item_id, -- Fix for bug #3347947
4086 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(l_rj_counter).alternate_bom_designator,
4087 p_bill_seq_id => l_res_bill_seq_id, -- Fix for bug #3286849
4088 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(l_rj_counter).common_bom_sequence_id,
4089 p_bom_rev_date => p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date,
4090 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_rj_counter).wip_supply_type,
4091 p_last_update_date => sysdate,
4092 p_last_updated_by => g_USER_ID,
4093 p_last_update_login => g_user_LOGIN_ID,
4094 p_creation_date => sysdate,
4095 p_created_by => g_USER_ID,
4096 p_request_id => g_REQUEST_ID,
4097 p_program_app_id => g_program_appl_id,
4098 p_program_id => g_PROGRAM_ID,
4099 p_program_update_date => sysdate,
4100 p_inf_sch_flag => 'Y',
4101 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4102 p_inf_sch_date => NULL, --Bug #3348704 l_inf_sch_date
4103 --OPTII-PERF:Following parameters are added
4104 p_charges_exist => 1,
4105 p_phantom_exists => l_phantom_exists
4106 );
4107
4108
4109 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4110 -- IF (x_err_code <> 0) THEN
4111 IF (x_err_code = 0) OR
4112 (x_err_code IS NULL) OR -- No error
4113 (x_err_code = -1) -- Warning
4114 THEN
4115 x_err_code := 0; -- Fix for bug #3421662 --
4116 ELSE
4117 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4118 l_msg_tokens.delete;
4119 WSM_log_PVT.logMessage(p_module_name => l_module ,
4120 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4121 p_stmt_num => l_stmt_num ,
4122 p_msg_tokens => l_msg_tokens,
4123 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4124 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4125 p_run_log_level => l_log_level
4126 );
4127 END IF;
4128 RAISE FND_API.G_EXC_ERROR;
4129 END IF;
4130
4131 if( g_log_level_statement >= l_log_level ) then
4132 l_msg_tokens.delete;
4133 WSM_log_PVT.logMessage(p_module_name => l_module ,
4134 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4135 p_stmt_num => l_stmt_num ,
4136 p_msg_tokens => l_msg_tokens,
4137 p_fnd_log_level => g_log_level_statement,
4138 p_run_log_level => l_log_level
4139 );
4140 End if;
4141
4142 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4143 l_stmt_num := 30;
4144 -- Added for Bug 8507313.
4145 l_rj_counter := p_wltx_resulting_jobs_tbl.first;
4146
4147 UPDATE wsm_lot_based_jobs
4148 SET internal_copy_type = 2
4149 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id;
4150
4151 if( g_log_level_statement >= l_log_level ) then
4152 l_msg_tokens.delete;
4153 WSM_log_PVT.logMessage(p_module_name => l_module ,
4154 p_msg_text => 'Set internal_copy_type = 2 for we_id=',
4155 p_stmt_num => l_stmt_num ,
4156 p_msg_tokens => l_msg_tokens,
4157 p_fnd_log_level => g_log_level_statement,
4158 p_run_log_level => l_log_level
4159 );
4160 End if;
4161
4162 END IF; --(p_copy_mode)
4163
4164 ELSIF (p_txn_type_id IN (WSMPCNST.SPLIT, WSMPCNST.MERGE)) THEN
4165
4166 l_stmt_num := 40;
4167
4168 l_rep_wip_entity_id := p_wltx_starting_jobs_tbl(p_rep_sj_index).wip_entity_id;
4169
4170 -- for interface copy purpose....
4171 SELECT nvl(internal_copy_type, 0),
4172 copy_parent_wip_entity_id
4173 INTO l_new_job_int_copy_type,
4174 l_rep_job_par_we_id
4175 FROM wsm_lot_based_jobs
4176 WHERE wip_entity_id = l_rep_wip_entity_id;
4177 -- for interface copy purpose.... end
4178
4179 IF (l_new_job_int_copy_type < 1) THEN
4180 l_new_job_int_copy_type := 1;
4181 END IF;
4182
4183 l_stmt_num := 50;
4184
4185 for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
4186
4187 l_stmt_num := 55;
4188
4189 if p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id <> l_rep_wip_entity_id then
4190
4191 l_stmt_num := 58;
4192
4193 -- ST : Bug fix 5092009
4194 -- Adding NVL as for Merge it can be NULL
4195 IF (nvl(p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy,0) = 0) THEN -- No assembly change
4196
4197 l_stmt_num := 59;
4198
4199 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4200 l_stmt_num := 60;
4201
4202 if( g_log_level_statement >= l_log_level ) then
4203 l_msg_tokens.delete;
4204 WSM_log_PVT.logMessage(p_module_name => l_module ,
4205 p_msg_text => 'new we_id :'||p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id||
4206 'rep_job_we_id :'||l_rep_wip_entity_id,
4207 p_stmt_num => l_stmt_num ,
4208 p_msg_tokens => l_msg_tokens,
4209 p_fnd_log_level => g_log_level_statement,
4210 p_run_log_level => l_log_level
4211 );
4212 End if;
4213
4214 WSM_JobCopies_PVT.Create_RepJobCopies
4215 (x_err_buf => x_err_buf,
4216 x_err_code => x_err_code,
4217 p_rep_wip_entity_id => l_rep_wip_entity_id,
4218 p_new_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
4219 p_last_update_date => sysdate,
4220 p_last_updated_by => g_USER_ID,
4221 p_last_update_login => g_user_LOGIN_ID,
4222 p_creation_date => sysdate,
4223 p_created_by => g_USER_ID,
4224 p_request_id => g_REQUEST_ID,
4225 p_program_app_id => g_program_appl_id,
4226 p_program_id => g_PROGRAM_ID,
4227 p_program_update_date => sysdate,
4228 p_inf_sch_flag => 'Y',
4229 p_inf_sch_mode => NULL,
4230 p_inf_sch_date => NULL
4231 );
4232
4233 IF (x_err_code <> 0) THEN
4234 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4235
4236 l_msg_tokens.delete;
4237 WSM_log_PVT.logMessage(p_module_name => l_module ,
4238 p_msg_text => 'WSM_JobCopies_PVT.Create_RepJobCopies returned error:' || x_err_buf,
4239 p_stmt_num => l_stmt_num ,
4240 p_msg_tokens => l_msg_tokens,
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 END IF;
4248
4249 l_stmt_num := 70;
4250
4251 if( g_log_level_statement >= l_log_level ) then
4252 l_msg_tokens.delete;
4253 WSM_log_PVT.logMessage(p_module_name => l_module ,
4254 p_msg_text => 'WSM_JobCopies_PVT.Create_RepJobCopies returned success',
4255 p_stmt_num => l_stmt_num ,
4256 p_msg_tokens => l_msg_tokens,
4257 p_fnd_log_level => g_log_level_statement,
4258 p_run_log_level => l_log_level
4259 );
4260 End if;
4261
4262 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4263
4264 l_stmt_num := 80;
4265
4266 UPDATE wsm_lot_based_jobs
4267 SET internal_copy_type = l_new_job_int_copy_type
4268 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4269
4270 if( g_log_level_statement >= l_log_level ) then
4271 l_msg_tokens.delete;
4272 WSM_log_PVT.logMessage(p_module_name => l_module ,
4273 p_msg_text => 'Set internal_copy_type = '||l_new_job_int_copy_type||' for we_id=',
4274 p_stmt_num => l_stmt_num ,
4275 p_msg_tokens => l_msg_tokens,
4276 p_fnd_log_level => g_log_level_statement,
4277 p_run_log_level => l_log_level
4278 );
4279 End if;
4280
4281 IF (l_new_job_int_copy_type = 1) THEN -- If current job's copy_type = 1
4282
4283 l_stmt_num := 100;
4284
4285 UPDATE wsm_lot_based_jobs
4286 SET copy_parent_wip_entity_id = nvl(l_rep_job_par_we_id, l_rep_wip_entity_id)
4287 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4288
4289 if( g_log_level_statement >= l_log_level ) then
4290 l_msg_tokens.delete;
4291 WSM_log_PVT.logMessage(p_module_name => l_module ,
4292 p_msg_text => 'Set copy_parent_wip_entity_id = '||nvl(l_rep_job_par_we_id, l_rep_wip_entity_id)||' for we_id=',
4293 p_stmt_num => l_stmt_num ,
4294 p_msg_tokens => l_msg_tokens,
4295 p_fnd_log_level => g_log_level_statement,
4296 p_run_log_level => l_log_level
4297 );
4298 End if;
4299
4300 END IF;
4301
4302 END IF; --(p_copy_mode)
4303
4304 ELSIF (p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy = 1) THEN -- Assembly has changed
4305
4306 l_stmt_num := 108;
4307
4308 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4309 l_stmt_num := 110;
4310
4311 if p_wltx_resulting_jobs_tbl(l_job_counter).job_type = WIP_CONSTANTS.STANDARD then
4312 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id;
4313 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id;
4314 else
4315 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id;
4316 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id;
4317 end if;
4318
4319 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id);
4320 --OPTII-PERF
4321 BEGIN
4322 select 1 into l_phantom_exists
4323 from bom_inventory_components
4324 where bill_sequence_id = p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id
4325 and p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date between effectivity_date and
4326 nvl(disable_date,p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date+1)
4327 and wip_supply_type = 6
4328 and rownum = 1;
4329
4330 l_phantom_exists := 1;
4331 EXCEPTION
4332 WHEN OTHERS THEN
4333 l_phantom_exists := 2;
4334 END;
4335
4336 WSM_JobCopies_PVT.Create_JobCopies -- Call #2
4337 (x_err_buf => x_err_buf,
4338 x_err_code => x_err_code,
4339 p_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
4340 p_org_id => p_wltx_resulting_jobs_tbl(l_job_counter).organization_id,
4341 p_primary_item_id => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
4342
4343 p_routing_item_id => l_res_rtg_item_id,-- Fix for bug #3347947
4344 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,-- Fix for bug #3347947
4345 p_rtg_seq_id => NULL, -- Will be NULL till reqd for some functionality
4346 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
4347 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
4348 p_bill_item_id => l_res_bill_item_id, -- Fix for bug #3347947
4349 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
4350 p_bill_seq_id => l_res_bill_seq_id,-- Fix for bug #3286849
4351 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
4352 p_bom_rev_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
4353 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
4354 p_last_update_date => sysdate,
4355 p_last_updated_by => g_USER_ID,
4356 p_last_update_login => g_user_LOGIN_ID,
4357 p_creation_date => sysdate,
4358 p_created_by => g_USER_ID,
4359 p_request_id => g_REQUEST_ID,
4360 p_program_app_id => g_program_appl_id,
4361 p_program_id => g_PROGRAM_ID,
4362 p_program_update_date => sysdate,
4363 p_inf_sch_flag => 'Y',
4364 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4365 p_inf_sch_date => NULL, --Bug #3348704 c_sm_new_jobs_rec.inf_sch_date
4366 --OPTII-PERF:Following parameters are added
4367 p_charges_exist => 1,
4368 p_phantom_exists => l_phantom_exists
4369 );
4370
4371 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4372 -- IF (x_err_code <> 0) THEN
4373 IF (x_err_code = 0) OR
4374 (x_err_code IS NULL) OR -- No error
4375 (x_err_code = -1) -- Warning
4376 THEN
4377 x_err_code := 0; -- Fix for bug #3421662 --
4378 ELSE
4379 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4380
4381 l_msg_tokens.delete;
4382 WSM_log_PVT.logMessage(p_module_name => l_module ,
4383 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4384 p_stmt_num => l_stmt_num ,
4385 p_msg_tokens => l_msg_tokens,
4386 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4387 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4388 p_run_log_level => l_log_level
4389 );
4390 END IF;
4391 RAISE FND_API.G_EXC_ERROR;
4392 END IF;
4393
4394 if( g_log_level_statement >= l_log_level ) then
4395 l_msg_tokens.delete;
4396 WSM_log_PVT.logMessage(p_module_name => l_module ,
4397 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4398 p_stmt_num => l_stmt_num ,
4399 p_msg_tokens => l_msg_tokens,
4400 p_fnd_log_level => g_log_level_statement,
4401 p_run_log_level => l_log_level
4402 );
4403 End if;
4404
4405 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4406
4407 l_stmt_num := 120;
4408
4409 UPDATE wsm_lot_based_jobs
4410 SET internal_copy_type = 2
4411 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4412
4413 if( g_log_level_statement >= l_log_level ) then
4414 l_msg_tokens.delete;
4415 WSM_log_PVT.logMessage(p_module_name => l_module ,
4416 p_msg_text => 'Set internal_copy_type = 2 for we_id=',
4417 p_stmt_num => l_stmt_num ,
4418 p_msg_tokens => l_msg_tokens,
4419 p_fnd_log_level => g_log_level_statement,
4420 p_run_log_level => l_log_level
4421 );
4422 End if;
4423
4424 END IF; --(p_copy_mode)
4425
4426 END IF;
4427 end if; -- check if not a starting job...
4428
4429 END LOOP;
4430
4431 IF (p_txn_type_id = WSMPCNST.SPLIT) THEN
4432
4433 l_stmt_num := 130;
4434
4435 if p_sj_as_rj_index is not null then
4436 l_stmt_num := 135;
4437
4438 IF (p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).split_has_update_assy = 1) THEN
4439
4440 l_stmt_num := 138;
4441
4442 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4443 l_stmt_num := 140;
4444
4445 if p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).job_type = WIP_CONSTANTS.STANDARD then
4446 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id;
4447 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id;
4448 else
4449 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).routing_reference_id;
4450 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_reference_id;
4451 end if;
4452
4453 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).wip_entity_id);
4454 --OPTII-PERF:Find l_phantom_exists
4455 BEGIN
4456 select 1 into l_phantom_exists
4457 from bom_inventory_components
4458 where bill_sequence_id = p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_bom_sequence_id
4459 and p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date between effectivity_date and
4460 nvl(disable_date,p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date+1)
4461 and wip_supply_type = 6
4462 and rownum = 1;
4463
4464 l_phantom_exists := 1;
4465 EXCEPTION
4466 WHEN OTHERS THEN
4467 l_phantom_exists := 2;
4468 end;
4469 WSM_JobCopies_PVT.Create_JobCopies -- Call #3
4470 (x_err_buf => x_err_buf,
4471 x_err_code => x_err_code,
4472 p_wip_entity_id => l_rep_wip_entity_id,
4473 p_org_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).organization_id,
4474 p_primary_item_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id,
4475 p_routing_item_id => l_res_rtg_item_id, -- Fix bug #3347947
4476 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).alternate_routing_designator, -- Fix bug #3347947
4477 p_rtg_seq_id => NULL,-- Will be NULL till reqd for some functionality
4478 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_routing_sequence_id,
4479 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).routing_revision_date,
4480 p_bill_item_id => l_res_bill_item_id, -- Fix bug #3347947
4481 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).alternate_bom_designator,
4482 p_bill_seq_id => l_res_bill_seq_id, -- Fix bug #3347947
4483 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_bom_sequence_id,
4484 p_bom_rev_date => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date,
4485 p_wip_supply_type => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).wip_supply_type,
4486 p_last_update_date => sysdate,
4487 p_last_updated_by => g_USER_ID,
4488 p_last_update_login => g_user_LOGIN_ID,
4489 p_creation_date => sysdate,
4490 p_created_by => g_USER_ID,
4491 p_request_id => g_REQUEST_ID,
4492 p_program_app_id => g_program_appl_id,
4493 p_program_id => g_PROGRAM_ID,
4494 p_program_update_date => sysdate,
4495 p_inf_sch_flag => 'Y',
4496 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4497 p_inf_sch_date => NULL, --Bug #3348704 l_inf_sch_date
4498 --OPTII-PERF:Following parameters are added
4499 p_charges_exist => 1,
4500 p_phantom_exists => l_phantom_exists
4501 );
4502
4503 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4504 -- IF (x_err_code <> 0) THEN
4505 IF (x_err_code = 0) OR
4506 (x_err_code IS NULL) OR -- No error
4507 (x_err_code = -1) -- Warning
4508 THEN
4509 x_err_code := 0; -- Fix for bug #3421662 --
4510 ELSE
4511 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4512
4513 l_msg_tokens.delete;
4514 WSM_log_PVT.logMessage(p_module_name => l_module ,
4515 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4516 p_stmt_num => l_stmt_num ,
4517 p_msg_tokens => l_msg_tokens,
4518 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4519 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4520 p_run_log_level => l_log_level
4521 );
4522 END IF;
4523 RAISE FND_API.G_EXC_ERROR;
4524 END IF;
4525
4526 if( g_log_level_statement >= l_log_level ) then
4527 l_msg_tokens.delete;
4528 WSM_log_PVT.logMessage(p_module_name => l_module ,
4529 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4530 p_stmt_num => l_stmt_num ,
4531 p_msg_tokens => l_msg_tokens,
4532 p_fnd_log_level => g_log_level_statement,
4533 p_run_log_level => l_log_level
4534 );
4535 End if;
4536
4537 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4538 l_stmt_num := 150;
4539
4540 UPDATE wsm_lot_based_jobs
4541 SET internal_copy_type = 2
4542 WHERE wip_entity_id = l_rep_wip_entity_id;
4543
4544 if( g_log_level_statement >= l_log_level ) then
4545 l_msg_tokens.delete;
4546 WSM_log_PVT.logMessage(p_module_name => l_module ,
4547 p_msg_text => 'Set internal_copy_type = 2 for we_id='||l_rep_wip_entity_id,
4548 p_stmt_num => l_stmt_num ,
4549 p_msg_tokens => l_msg_tokens,
4550 p_fnd_log_level => g_log_level_statement,
4551 p_run_log_level => l_log_level
4552 );
4553 End if;
4554
4555 END IF; --(p_copy_mode)
4556
4557 END IF;
4558
4559 end if;
4560
4561 END IF;
4562
4563 END IF; --(p_txn_type_id)
4564
4565 l_stmt_num := 160;
4566 x_err_code := 0;
4567
4568 EXCEPTION
4569 WHEN FND_API.G_EXC_ERROR THEN
4570 x_err_code := SQLCODE;
4571 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||x_err_buf;
4572
4573 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
4574 p_count => x_msg_count ,
4575 p_data => x_err_buf
4576 );
4577
4578 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4579
4580 x_err_code := SQLCODE;
4581 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||x_err_buf;
4582
4583 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
4584 p_count => x_msg_count ,
4585 p_data => x_err_buf
4586 );
4587
4588
4589 WHEN OTHERS THEN
4590 x_err_code := SQLCODE;
4591 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
4592
4593 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4594 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4595 THEN
4596 WSM_log_PVT.handle_others( p_module_name => l_module ,
4597 p_stmt_num => l_stmt_num ,
4598 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4599 p_run_log_level => l_log_level
4600 );
4601 END IF;
4602
4603 END CREATE_COPIES_OR_SET_COPY_DATA;
4604 /* have to work on this procedure..... */
4605
4606
4607 /*-----------------------------------------------------------------+
4608 | Name : CALL_INF_SCH_OR_SET_SCH_DATA
4609 | This procedure calls the Infinite Scheduler
4610 | or sets data in wsm_lot_based_jobs table the Inf.Scheduler
4611 -------------------------------------------------------------------*/
4612
4613 PROCEDURE CALL_INF_SCH_OR_SET_SCH_DATA (p_txn_id IN NUMBER,
4614 p_copy_mode IN NUMBER,
4615 p_org_id IN NUMBER,
4616 p_par_we_id IN NUMBER,
4617 x_err_code OUT NOCOPY NUMBER,
4618 x_err_buf OUT NOCOPY VARCHAR2)
4619 IS
4620 l_schedule_mode NUMBER;
4621
4622 l_job_op_seq_num NUMBER;
4623 l_job_op_seq_id NUMBER;
4624 l_job_std_op_id NUMBER;
4625 l_job_intra_op NUMBER;
4626 l_job_dept_id NUMBER;
4627 l_job_qty NUMBER;
4628 l_job_op_start_dt DATE;
4629 l_job_op_comp_dt DATE;
4630 l_returnStatus VARCHAR2(1);
4631 x_msg_count number;
4632 -- Logging variables.....
4633 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4634 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4635
4636 l_stmt_num NUMBER;
4637 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPDB.CALL_INF_SCH_OR_SET_SCH_DATA';
4638 -- Logging variables...
4639
4640 BEGIN
4641
4642 l_stmt_num := 10;
4643
4644 -- ST : Fix for bug 5181364
4645 -- Changed the scheduling path to forwards scheduling instead of midpoint forward
4646 SELECT decode(on_rec_path, 'Y', WIP_CONSTANTS.FORWARDS, WIP_CONSTANTS.CURRENT_OP)
4647 INTO l_schedule_mode
4648 FROM WSM_LOT_BASED_JOBS
4649 WHERE wip_entity_id = p_par_we_id;
4650
4651 l_stmt_num := 30;
4652
4653 GET_JOB_CURR_OP_INFO(p_wip_entity_id => p_par_we_id,
4654 p_op_seq_num => l_job_op_seq_num,
4655 p_op_seq_id => l_job_op_seq_id,
4656 p_std_op_id => l_job_std_op_id,
4657 p_intra_op => l_job_intra_op,
4658 p_dept_id => l_job_dept_id,
4659 p_op_qty => l_job_qty,
4660 p_op_start_date => l_job_op_start_dt,
4661 p_op_completion_date => l_job_op_comp_dt,
4662 x_err_code => x_err_code,
4663 x_err_buf => x_err_buf,
4664 x_msg_count => x_msg_count
4665 );
4666
4667 IF (x_err_code <> 0) THEN
4668 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4669 l_msg_tokens.delete;
4670 WSM_log_PVT.logMessage(p_module_name => l_module ,
4671 p_msg_text => 'GET_JOB_CURR_OP_INFO returned error:' || x_err_buf,
4672 p_stmt_num => l_stmt_num ,
4673 p_msg_tokens => l_msg_tokens,
4674 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4675 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4676 p_run_log_level => l_log_level
4677 );
4678 END IF;
4679 RAISE FND_API.G_EXC_ERROR;
4680 END IF;
4681
4682 l_stmt_num := 40;
4683
4684 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4685
4686 l_stmt_num := 50;
4687
4688 WSM_infinite_scheduler_PVT.schedule
4689 (
4690 p_initMsgList => FND_API.g_true,
4691 p_endDebug => FND_API.g_true,
4692 p_orgID => p_org_id,
4693 p_wipEntityID => p_par_we_id,
4694 p_scheduleMode => l_schedule_mode,
4695 p_startDate => l_job_op_start_dt,
4696 p_endDate => NULL,
4697 p_opSeqNum => 0-l_job_op_seq_num,
4698 p_resSeqNum => NULL,
4699 x_returnStatus => l_returnStatus,
4700 x_errorMsg => x_err_buf
4701 );
4702
4703 IF(l_returnStatus <> FND_API.G_RET_STS_SUCCESS) THEN
4704 x_err_code := -1;
4705 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4706 l_msg_tokens.delete;
4707 WSM_log_PVT.logMessage(p_module_name => l_module ,
4708 p_msg_text => 'WSM_infinite_scheduler_PVT.schedule returned error:' || x_err_buf,
4709 p_stmt_num => l_stmt_num ,
4710 p_msg_tokens => l_msg_tokens,
4711 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4712 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4713 p_run_log_level => l_log_level
4714 );
4715 END IF;
4716 RAISE FND_API.G_EXC_ERROR;
4717 ELSE
4718 x_err_code := 0;
4719 END IF;
4720
4721 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4722
4723 l_stmt_num := 60;
4724
4725 UPDATE wsm_lot_based_jobs
4726 SET infinite_schedule = 'Y'
4727 WHERE wip_entity_id = p_par_we_id;
4728
4729 END IF; --p_copy_mode
4730
4731 l_stmt_num := 70;
4732
4733 EXCEPTION
4734 WHEN FND_API.G_EXC_ERROR THEN
4735
4736 x_err_code := SQLCODE;
4737 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||x_err_buf;
4738 /*
4739 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
4740 p_count => x_msg_count ,
4741 p_data => x_err_buf
4742 );
4743 */
4744 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4745
4746 x_err_code := SQLCODE;
4747 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||x_err_buf;
4748 /*
4749 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
4750 p_count => x_msg_count ,
4751 p_data => x_err_buf
4752 );
4753 */
4754 WHEN OTHERS THEN
4755 x_err_code := SQLCODE;
4756 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
4757
4758 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4759 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4760 THEN
4761 WSM_log_PVT.handle_others( p_module_name => l_module ,
4762 p_stmt_num => l_stmt_num ,
4763 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4764 p_run_log_level => l_log_level
4765 );
4766 END IF;
4767
4768 END CALL_INF_SCH_OR_SET_SCH_DATA;
4769 /* end..... */
4770
4771 PROCEDURE PROCESS_LOTS (p_copy_qa IN VARCHAR2,
4772 p_txn_org_id IN NUMBER,
4773 p_rep_job_index IN NUMBER,
4774 p_wltx_header IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
4775 p_wltx_starting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
4776 p_wltx_resulting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
4777 p_secondary_qty_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WSM_JOB_SECONDARY_QTY_TBL_TYPE ,
4778 -- p_txn_id OUT NOCOPY NUMBER, /* i dont think this is needed,,,, */
4779 x_return_status OUT NOCOPY VARCHAR2,
4780 x_msg_count OUT NOCOPY NUMBER,
4781 x_error_msg OUT NOCOPY VARCHAR2
4782 ) is
4783
4784 l_new_rj_we_id_tbl t_number;
4785 l_new_rj_qty_tbl t_number;
4786
4787 l_sj_we_id_tbl t_number;
4788 l_sj_old_st_qty_tbl t_number;
4789 l_sj_new_qty_tbl t_number;
4790 l_sj_new_net_qty_tbl t_number;
4791 l_sj_op_seq_tbl t_number;
4792 l_sj_scrap_qty_tbl t_number;
4793 l_sj_avail_qty_tbl t_number;
4794
4795 l_job_intraop_step number;
4796
4797 l_rep_new_qty number;
4798 l_non_rep_sj_tbl t_number; -- table to store the wip_entity_id of the non-rep starting jobs...
4799
4800 l_sj_also_rj_index number;
4801 l_rep_sj_index number;
4802 l_rj_index number;
4803 l_bonus_job_st_op_seq number;
4804 l_bonus_rtg_st_op_seq number;
4805 l_acct_period_id number;
4806
4807 l_profile_value number;
4808 l_po_creation_time wip_parameters.po_creation_time%type;
4809
4810 --MES columns
4811 l_current_rtg_op_seq_num number;
4812 l_current_job_op_seq_num number;
4813 --End MES columns
4814
4815 --SO LBJ Rsvn add
4816 l_rsv_exists boolean;
4817 --End SO LBJ Rsvn add
4818
4819 l_err_code number;
4820 l_err_buf varchar2(2000);
4821
4822 l_txn_status number;
4823 l_txn_costed number;
4824
4825 l_rj_kanban_card_id number;
4826 l_po_request_id number;
4827
4828 l_new_we_id number;
4829 l_sub_loc_change number;
4830 l_ret_status varchar2(1);
4831 l_new_name wip_entities.wip_entity_name%type;
4832 l_dup_job_name wip_entities.wip_entity_name%type;
4833
4834 l_job_counter NUMBER;
4835
4836 l_sj_gen_object_id wip_entities.gen_object_id%type;
4837 l_rj_gen_object_id wip_entities.gen_object_id%type;
4838
4839 l_kanban_card_id wip_discrete_jobs.kanban_card_id%type;
4840
4841 l_msg_count number;
4842 l_msg_data varchar2(2000);
4843
4844 /*logging variables*/
4845 l_stmt_num number := 0;
4846 l_msg_tokens WSM_log_PVT.token_rec_tbl;
4847 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4848 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.process_lots';
4849 l_schedule_group_id NUMBER; -- Bug 6676148
4850
4851 l_attribute_category varchar2(30);
4852 l_attribute1 varchar2(150);
4853 l_attribute2 varchar2(150);
4854 l_attribute3 varchar2(150);
4855 l_attribute4 varchar2(150);
4856 l_attribute5 varchar2(150);
4857 l_attribute6 varchar2(150);
4858 l_attribute7 varchar2(150);
4859 l_attribute8 varchar2(150);
4860 l_attribute9 varchar2(150);
4861 l_attribute10 varchar2(150);
4862 l_attribute11 varchar2(150);
4863 l_attribute12 varchar2(150);
4864 l_attribute13 varchar2(150);
4865 l_attribute14 varchar2(150);
4866 l_attribute15 varchar2(150);
4867
4868 BEGIN
4869
4870 l_stmt_num := 10;
4871 g_user_id := FND_GLOBAL.USER_ID;
4872 g_user_login_id := FND_GLOBAL.LOGIN_ID;
4873 g_program_appl_id := FND_GLOBAL.PROG_APPL_ID;
4874 g_request_id := FND_GLOBAL.CONC_REQUEST_ID;
4875 g_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
4876
4877 x_return_status := g_ret_success;
4878
4879 if( g_log_level_statement >= l_log_level ) then
4880 -- Log the transaction data...
4881 WSM_WIP_LOT_TXN_PVT.Log_transaction_data ( p_txn_header_rec => p_wltx_header ,
4882 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl ,
4883 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl ,
4884 p_secondary_qty_tbl => p_secondary_qty_tbl ,
4885 x_return_status => x_return_status ,
4886 x_msg_count => x_msg_count ,
4887 x_error_msg => x_error_msg
4888 );
4889
4890 if x_return_status <> G_RET_SUCCESS then
4891 IF x_return_status = G_RET_ERROR THEN
4892 raise FND_API.G_EXC_ERROR;
4893 ELSIF x_return_status = G_RET_UNEXPECTED THEN
4894 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4895 END IF;
4896 end if;
4897 End if;
4898
4899 l_profile_value := WSMPUTIL.CREATE_LBJ_COPY_RTG_PROFILE(p_txn_org_id); -- This returns the Profile value
4900
4901 l_stmt_num := 20;
4902
4903 select meaning
4904 into g_translated_meaning
4905 from mfg_lookups
4906 where lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
4907 and lookup_code = 7
4908 and upper(enabled_flag) = 'Y';
4909
4910 l_stmt_num := 30;
4911
4912 IF (l_profile_value = 2) THEN -- Dont make copies
4913 WSMPJUPD.g_copy_mode := 0;
4914 ELSE
4915 IF (WSMPJUPD.g_copy_mode IS NULL) THEN -- Called through the form
4916 WSMPJUPD.g_copy_mode := 1; -- For form, make copies immediately
4917 END IF;
4918 END IF;
4919
4920 l_stmt_num := 40;
4921
4922 -- get the po creation type...
4923 SELECT po_creation_time
4924 INTO l_po_creation_time
4925 FROM wip_parameters
4926 WHERE organization_id = p_txn_org_id;
4927
4928 if p_wltx_header.transaction_id is null then
4929 select wsm_split_merge_transactions_s.nextval
4930 into p_wltx_header.transaction_id
4931 from dual;
4932 end if;
4933
4934 l_stmt_num := 50;
4935 -- for based on each transaction type...
4936 if p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE) then
4937
4938 l_stmt_num := 55;
4939 -- do the split processing....
4940 l_non_rep_sj_tbl.delete;
4941
4942 -- loop on the jobs....
4943 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
4944 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
4945 elsif p_rep_job_index is not null then
4946 l_rep_sj_index := p_rep_job_index;
4947 else
4948 -- rep job index not passed...
4949 l_job_counter := p_wltx_starting_jobs_tbl.first;
4950 while l_job_counter is not null loop
4951 if p_wltx_starting_jobs_tbl(l_job_counter).representative_flag = 'Y' then
4952 l_rep_sj_index := l_job_counter;
4953 exit;
4954 end if;
4955 end loop;
4956 end if;
4957 -- bug fix 6676148
4958 select schedule_group_id,
4959 attribute_category,
4960 attribute1,
4961 attribute2,
4962 attribute3,
4963 attribute4,
4964 attribute5,
4965 attribute6,
4966 attribute7,
4967 attribute8,
4968 attribute9,
4969 attribute10,
4970 attribute11,
4971 attribute12,
4972 attribute13,
4973 attribute14,
4974 attribute15
4975 into
4976 l_schedule_group_id,
4977 l_attribute_category,
4978 l_attribute1,
4979 l_attribute2,
4980 l_attribute3,
4981 l_attribute4,
4982 l_attribute5,
4983 l_attribute6,
4984 l_attribute7,
4985 l_attribute8,
4986 l_attribute9,
4987 l_attribute10,
4988 l_attribute11,
4989 l_attribute12,
4990 l_attribute13,
4991 l_attribute14,
4992 l_attribute15
4993 from wip_discrete_jobs
4994 where wip_entity_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
4995 -- end of bug fix 6676148
4996
4997 l_sj_also_rj_index := null;
4998
4999 l_stmt_num := 60;
5000
5001 l_job_counter := p_wltx_resulting_jobs_tbl.first;
5002
5003 while l_job_counter is not null loop
5004 -- for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
5005
5006 l_stmt_num := 61;
5007
5008 if p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name then
5009 l_stmt_num := 62;
5010 -- indicates the starting job is also a resulting job...
5011 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
5012 l_sj_also_rj_index := l_job_counter;
5013 else
5014 l_stmt_num := 63;
5015
5016 -- else indicates that the job is a new job...
5017 IF (WSMPJUPD.g_copy_mode = 0) THEN -- No copies to be made
5018 -- Added condition for APS-WLT
5019
5020 -------------------- Related Bugs for this piece of code.... ----------------------------
5021 -- 3698595
5022 -- -------------------- Related Bugs for this piece of code.... -------------------------
5023 l_stmt_num := 65;
5024
5025 l_err_code := 0;
5026 l_err_buf := null;
5027 --remove this
5028
5029 if( g_log_level_statement >= l_log_level ) then
5030 l_msg_tokens.delete;
5031 WSM_log_PVT.logMessage(p_module_name => l_module ,
5032 p_msg_text => 'Calling WSMPLBJI.build_lbji_info procedure',
5033 p_stmt_num => l_stmt_num ,
5034 p_msg_tokens => l_msg_tokens,
5035 p_fnd_log_level => g_log_level_statement,
5036 p_run_log_level => l_log_level
5037 );
5038 End if;
5039
5040 -- Create Job Header ONLY
5041 WSMPLBJI.build_lbji_info
5042 (p_routing_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
5043 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
5044 p_explode_header_detail => 2, --This creates header only (WE, WDJ, WPB)
5045 p_status_type => WIP_CONSTANTS.RELEASED,
5046 p_class_code => p_wltx_starting_jobs_tbl(l_rep_sj_index).class_code,
5047 p_org => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
5048 p_wip_entity_id => l_new_we_id, -- this is returned by the API
5049 p_last_updt_date => sysdate,
5050 p_last_updt_by => g_user_id,
5051 p_creation_date => sysdate,
5052 p_created_by => g_user_id,
5053 p_last_updt_login => g_user_login_id,
5054 p_request_id => g_request_id,
5055 p_program_application_id => g_program_appl_id,
5056 p_program_id => g_program_id,
5057 p_prog_updt_date => sysdate,
5058 p_source_line_id => NULL,
5059 p_source_code => NULL,
5060 p_description => p_wltx_resulting_jobs_tbl(l_job_counter).description,
5061 p_item => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
5062 p_job_type => p_wltx_resulting_jobs_tbl(l_job_counter).job_type,
5063 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id,
5064 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id,
5065 p_firm_planned_flag => 2,
5066 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
5067 p_fusd => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_start_date,
5068 p_lucd => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_completion_date,
5069 p_start_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity,
5070 p_net_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).net_quantity,
5071 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_job_counter).coproducts_supply,
5072 p_bom_revision => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision,
5073 p_routing_revision => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision,
5074 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
5075 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
5076 p_lot_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5077 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
5078 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,
5079 p_priority => NULL,
5080 p_due_date => NULL,
5081
5082 p_attribute_category => l_attribute_category,
5083 p_attribute1 => l_attribute1,
5084 p_attribute2 => l_attribute2,
5085 p_attribute3 => l_attribute3,
5086 p_attribute4 => l_attribute4,
5087 p_attribute5 => l_attribute5,
5088 p_attribute6 => l_attribute6,
5089 p_attribute7 => l_attribute7,
5090 p_attribute8 => l_attribute8,
5091 p_attribute9 => l_attribute9,
5092 p_attribute10 => l_attribute10,
5093 p_attribute11 => l_attribute11,
5094 p_attribute12 => l_attribute12,
5095 p_attribute13 => l_attribute13,
5096 p_attribute14 => l_attribute14,
5097 p_attribute15 => l_attribute15,
5098
5099 p_job_name => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5100 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5101 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5102 p_demand_class => p_wltx_starting_jobs_tbl(l_rep_sj_index).demand_class,
5103 p_project_id => NULL,
5104 p_task_id => NULL,
5105 p_schedule_group_id => NULL,
5106 p_build_sequence => NULL,
5107 p_line_id => NULL,
5108 p_kanban_card_id => NULL,
5109 p_overcompl_tol_type => NULL,
5110 p_overcompl_tol_value => NULL,
5111 p_end_item_unit_number => NULL,
5112 p_rtg_op_seq_num => p_wltx_resulting_jobs_tbl(l_job_counter).starting_operation_seq_num,
5113 p_src_client_server => 1,
5114 p_po_creation_time => l_po_creation_time,
5115 p_date_released => p_wltx_header.transaction_date, --bug 4101117
5116 p_error_code => l_err_code,
5117 p_error_msg => l_err_buf
5118 );
5119
5120 l_stmt_num := 70;
5121
5122 IF (l_err_code <> 0) THEN
5123
5124 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5125
5126 l_msg_tokens.delete;
5127 WSM_log_PVT.logMessage(p_module_name => l_module ,
5128 p_msg_text => 'Returned failure from WSMPLBJI.build_lbji_info procedure' ,
5129 p_stmt_num => l_stmt_num ,
5130 p_msg_tokens => l_msg_tokens,
5131 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5132 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5133 p_run_log_level => l_log_level
5134 );
5135 END IF;
5136 RAISE FND_API.G_EXC_ERROR;
5137 ELSE
5138 -- success... now the program would have returned the id ....
5139 if( g_log_level_statement >= l_log_level ) then
5140 l_msg_tokens.delete;
5141 WSM_log_PVT.logMessage(p_module_name => l_module ,
5142 p_msg_text => 'Returned successfully from WSMPLBJI.build_lbji_info procedure',
5143 p_stmt_num => l_stmt_num ,
5144 p_msg_tokens => l_msg_tokens,
5145 p_fnd_log_level => g_log_level_statement,
5146 p_run_log_level => l_log_level
5147 );
5148 End if;
5149 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := l_new_we_id;
5150 END IF;
5151
5152 --Start : Additions for APS-WLT--
5153 ELSIF (WSMPJUPD.g_copy_mode <> 0) THEN -- Copies are to be made i.e. Option C
5154 -- Make copies immediately or at the end
5155
5156 l_stmt_num := 75;
5157 -------------------- Related Bugs for this piece of code.... ---------------------------
5158 -- 3698595
5159 -------------------- Related Bugs for this piece of code.... ------------------------
5160 l_err_code := 0;
5161 l_err_buf := null;
5162
5163 if( g_log_level_statement >= l_log_level ) then
5164 l_msg_tokens.delete;
5165 WSM_log_PVT.logMessage(p_module_name => l_module ,
5166 p_msg_text => 'Calling WSM_lbj_interface_PVT.build_job_header_info',
5167 p_stmt_num => l_stmt_num ,
5168 p_msg_tokens => l_msg_tokens,
5169 p_fnd_log_level => g_log_level_statement,
5170 p_run_log_level => l_log_level
5171 );
5172 End if;
5173
5174 -- Create Job Header ONLY
5175 WSM_lbj_interface_PVT.build_job_header_info
5176 (p_common_routing_sequence_id=> p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
5177 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
5178 p_status_type => WIP_CONSTANTS.RELEASED,
5179 p_class_code => p_wltx_starting_jobs_tbl(l_rep_sj_index).class_code,
5180 p_org_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
5181 p_wip_entity_id => l_new_we_id, -- this is returned by the API
5182 p_last_updt_date => sysdate,
5183 p_last_updt_by => g_user_id,
5184 p_creation_date => sysdate,
5185 p_created_by => g_user_id,
5186 p_last_updt_login => g_user_login_id,
5187 p_request_id => g_request_id,
5188 p_program_appl_id => g_program_appl_id,
5189 p_program_id => g_program_id,
5190 p_prog_updt_date => sysdate,
5191 p_source_line_id => NULL,
5192 p_source_code => NULL,
5193 p_description => p_wltx_resulting_jobs_tbl(l_job_counter).description,
5194 p_item => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
5195 p_job_type => p_wltx_resulting_jobs_tbl(l_job_counter).job_type,
5196 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id,
5197 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id,
5198 p_firm_planned_flag => 2,
5199 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
5200 p_job_scheduled_start_date => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_start_date,
5201 p_job_scheduled_compl_date => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_completion_date,
5202 p_start_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity,
5203 p_net_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).net_quantity,
5204 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_job_counter).coproducts_supply,
5205 p_bom_revision => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision,
5206 p_routing_revision => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision,
5207 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
5208 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
5209 p_lot_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5210 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
5211 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,
5212 p_priority => NULL,
5213 p_due_date => NULL,
5214
5215 p_attribute_category => l_attribute_category,
5216 p_attribute1 => l_attribute1,
5217 p_attribute2 => l_attribute2,
5218 p_attribute3 => l_attribute3,
5219 p_attribute4 => l_attribute4,
5220 p_attribute5 => l_attribute5,
5221 p_attribute6 => l_attribute6,
5222 p_attribute7 => l_attribute7,
5223 p_attribute8 => l_attribute8,
5224 p_attribute9 => l_attribute9,
5225 p_attribute10 => l_attribute10,
5226 p_attribute11 => l_attribute11,
5227 p_attribute12 => l_attribute12,
5228 p_attribute13 => l_attribute13,
5229 p_attribute14 => l_attribute14,
5230 p_attribute15 => l_attribute15,
5231
5232 p_job_name => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5233 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5234 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5235 p_demand_class => p_wltx_starting_jobs_tbl(l_rep_sj_index).demand_class,
5236 p_project_id => NULL,
5237 p_task_id => NULL,
5238 p_schedule_group_id => l_schedule_group_id, -- bug fix 6676148
5239 p_build_sequence => NULL,
5240 p_line_id => NULL,
5241 p_kanban_card_id => NULL,
5242 p_overcompl_tol_type => NULL,
5243 p_overcompl_tol_value => NULL,
5244 p_end_item_unit_number => NULL,
5245 p_src_client_server => 1,
5246 p_po_creation_time => l_po_creation_time,
5247 p_date_released => p_wltx_header.transaction_date, --bug 4101117
5248 p_error_code => l_err_code,
5249 p_error_msg => l_err_buf
5250 );
5251
5252 l_stmt_num := 80;
5253
5254 IF (l_err_code <> 0) THEN
5255 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5256
5257 l_msg_tokens.delete;
5258 WSM_log_PVT.logMessage(p_module_name => l_module ,
5259 p_msg_text => 'Returned failure from WSM_lbj_interface_PVT.build_job_header_info'||l_err_buf,
5260 p_stmt_num => l_stmt_num ,
5261 p_msg_tokens => l_msg_tokens,
5262 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5263 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5264 p_run_log_level => l_log_level
5265 );
5266 END IF;
5267 RAISE FND_API.G_EXC_ERROR;
5268
5269 ELSE
5270 -- success... now the program would have returned the id ....
5271 if( g_log_level_statement >= l_log_level ) then
5272 l_msg_tokens.delete;
5273 WSM_log_PVT.logMessage(p_module_name => l_module ,
5274 p_msg_text => 'Returned success from WSM_lbj_interface_PVT.build_job_header_info',
5275 p_stmt_num => l_stmt_num ,
5276 p_msg_tokens => l_msg_tokens,
5277 p_fnd_log_level => g_log_level_statement,
5278 p_run_log_level => l_log_level
5279 );
5280 End if;
5281
5282 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := l_new_we_id;
5283 END IF;
5284
5285 END IF; --WSMPJUPD.g_copy_mode
5286
5287 l_stmt_num := 85;
5288
5289 l_new_rj_we_id_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
5290 l_new_rj_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity;
5291
5292 -- Kanban stuff for Merge Txn....
5293 if p_wltx_header.transaction_type_id = WSMPCNST.merge then
5294 -- here take care of the following case
5295 -- A*
5296 -- \
5297 -- |-- C
5298 -- /
5299 -- B
5300 -- where A is the representative lot and has a kanban reference. In this case, C will inherit
5301 -- the kanban reference of A, provided that the completion subinventory of A and C are the same.
5302
5303 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id;
5304 p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id := null;
5305
5306 if l_kanban_card_id is not null then
5307 if ( (p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory = p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory)
5308 AND
5309 (nvl(p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_locator_id,-999) = nvl(p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,-999))
5310 )
5311 then
5312
5313 l_stmt_num := 53;
5314 -- this means this kanban_card_id is inherited by resulting job, while examining the starting jobs
5315 -- do not set the kanban card to Exception just because the qties of the starting jobs have become 0
5316 if( g_log_level_statement >= l_log_level ) then
5317 l_msg_tokens.delete;
5318 WSM_log_PVT.logMessage(p_module_name => l_module ,
5319 p_msg_text => 'Calling INV_Kanban_PVT.Update_Card_Supply_Status',
5320 p_stmt_num => l_stmt_num ,
5321 p_msg_tokens => l_msg_tokens,
5322 p_fnd_log_level => g_log_level_statement,
5323 p_run_log_level => l_log_level
5324 );
5325 End if;
5326
5327 INV_Kanban_PVT.Update_Card_Supply_Status( X_Return_Status => l_ret_status,
5328 p_Kanban_Card_Id => l_kanban_card_id,
5329 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
5330 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
5331 p_Document_Header_Id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
5332 p_Document_detail_Id => '',
5333 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity
5334 );
5335
5336 if ( l_ret_status <> fnd_api.g_ret_sts_success ) then
5337 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5338
5339 l_msg_tokens.delete;
5340 l_msg_tokens(1).TokenName := 'STATUS';
5341 l_msg_tokens(1).TokenValue := g_translated_meaning;
5342 WSM_log_PVT.logMessage(p_module_name => l_module ,
5343 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5344 p_msg_appl_name => 'WSM' ,
5345 p_msg_tokens => l_msg_tokens ,
5346 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5347 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5348 p_run_log_level => l_log_level
5349 );
5350 END IF;
5351
5352 RAISE FND_API.G_EXC_ERROR;
5353
5354 end if;
5355
5356 p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id := l_kanban_card_id;
5357
5358 end if;
5359 end if;
5360
5361 update wip_discrete_jobs
5362 set completion_subinventory = p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5363 completion_locator_id = p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5364 kanban_card_id = p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id
5365 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
5366
5367 end if;
5368 end if; -- check for starting job also as a resulting job
5369
5370 l_job_counter := p_wltx_resulting_jobs_tbl.next(l_job_counter);
5371 end loop;
5372
5373 l_stmt_num := 90;
5374
5375 --Copy the job details from the representative parent lot into the child job--
5376 --The details are copied for all ops till the current op.--
5377 --i.e. If say, the job has moved into 30Q, and undone back to 20Q and a split is done here--
5378 --only ops 10 and 20 should get copied to the resulting jobs, since 30's cnt_pt is still 1--
5379 --Also any manual issues at op 30 should remain with original job--
5380 --That is, any manual issues at an op after the curr op, should not be proportionated. --
5381
5382 l_stmt_num := 220;
5383
5384 if( g_log_level_statement >= l_log_level ) then
5385 l_msg_tokens.delete;
5386 WSM_log_PVT.logMessage(p_module_name => l_module ,
5387 p_msg_text => 'Calling COPY_REP_JOB_WO_FA ' || p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5388 p_stmt_num => l_stmt_num ,
5389 p_msg_tokens => l_msg_tokens,
5390 p_fnd_log_level => g_log_level_statement,
5391 p_run_log_level => l_log_level
5392 );
5393 End if;
5394 l_err_code := 0;
5395 l_err_buf := null;
5396
5397 -- Related bugs : 3142153
5398 COPY_REP_JOB_WO_FA( p_txn_id => null,
5399 p_txn_org_id => p_txn_org_id,
5400 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5401 p_new_rj_qty_tbl => l_new_rj_qty_tbl,
5402 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5403 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5404 p_curr_op_seq_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_id,
5405 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
5406 x_err_code => l_err_code,
5407 x_err_buf => l_err_buf
5408 );
5409
5410 IF (l_err_code <> 0) THEN
5411 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5412
5413 l_msg_tokens.delete;
5414 WSM_log_PVT.logMessage(p_module_name => l_module ,
5415 p_msg_text => 'Returned failure from COPY_REP_JOB_WO_FA',
5416 p_stmt_num => l_stmt_num ,
5417 p_msg_tokens => l_msg_tokens,
5418 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5419 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5420 p_run_log_level => l_log_level
5421 );
5422 END IF;
5423 RAISE FND_API.G_EXC_ERROR;
5424 END IF;
5425
5426
5427 l_stmt_num := 230;
5428 if( g_log_level_statement >= l_log_level ) then
5429 l_msg_tokens.delete;
5430 WSM_log_PVT.logMessage(p_module_name => l_module ,
5431 p_msg_text => 'Calling COPY_REP_JOB_WOR ',
5432 p_stmt_num => l_stmt_num ,
5433 p_msg_tokens => l_msg_tokens,
5434 p_fnd_log_level => g_log_level_statement,
5435 p_run_log_level => l_log_level
5436 );
5437 End if;
5438 l_err_code := 0;
5439 l_err_buf := null;
5440
5441 -- Related bugs : 3142153
5442 COPY_REP_JOB_WOR ( p_txn_id => null,
5443 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5444 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5445 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5446 x_err_code => l_err_code,
5447 x_err_buf => l_err_buf);
5448
5449 IF (l_err_code <> 0) THEN
5450 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5451
5452 l_msg_tokens.delete;
5453 WSM_log_PVT.logMessage(p_module_name => l_module ,
5454 p_msg_text => 'Returned failure from COPY_REP_JOB_WOR',
5455 p_stmt_num => l_stmt_num ,
5456 p_msg_tokens => l_msg_tokens,
5457 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5458 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5459 p_run_log_level => l_log_level
5460 );
5461 END IF;
5462 RAISE FND_API.G_EXC_ERROR;
5463 END IF;
5464
5465
5466 -- Related bugs : 3142153
5467 l_stmt_num := 240;
5468
5469 l_err_code := 0;
5470 l_err_buf := null;
5471
5472 --Start: Additions for APS-WLT--
5473 IF (WSMPJUPD.g_copy_mode = 0) THEN
5474 null;
5475 ELSE -- Copies are to be made i.e. Option C
5476 -- Make copies immediately or at the end
5477 if( g_log_level_statement >= l_log_level ) then
5478 l_msg_tokens.delete;
5479 WSM_log_PVT.logMessage(p_module_name => l_module ,
5480 p_msg_text => 'Calling COPY_REP_JOB_WSOR ',
5481 p_stmt_num => l_stmt_num ,
5482 p_msg_tokens => l_msg_tokens,
5483 p_fnd_log_level => g_log_level_statement,
5484 p_run_log_level => l_log_level
5485 );
5486 End if;
5487
5488 COPY_REP_JOB_WSOR( p_txn_id => null,
5489 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5490 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5491 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5492 x_err_code => l_err_code,
5493 x_err_buf => l_err_buf
5494 );
5495
5496 IF (l_err_code <> 0) THEN
5497 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5498
5499 l_msg_tokens.delete;
5500 WSM_log_PVT.logMessage(p_module_name => l_module ,
5501 p_msg_text => 'Returned failure from COPY_REP_JOB_WSOR',
5502 p_stmt_num => l_stmt_num ,
5503 p_msg_tokens => l_msg_tokens,
5504 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5505 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5506 p_run_log_level => l_log_level
5507 );
5508 END IF;
5509 RAISE FND_API.G_EXC_ERROR;
5510 END IF;
5511 END IF;
5512
5513 --End: Additions for APS-WLT--
5514
5515 /* ST : Detailed Scheduling start */
5516 l_stmt_num := 78;
5517 l_err_code := 0;
5518 l_err_buf := null;
5519
5520 COPY_REP_JOB_WORI( p_txn_id => null,
5521 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5522 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5523 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num, -- Fix for bug #3142153
5524 x_err_code => l_err_code,
5525 x_err_buf => l_err_buf
5526 );
5527 IF (l_err_code <> 0) THEN
5528 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5529
5530 l_msg_tokens.delete;
5531 WSM_log_PVT.logMessage(p_module_name => l_module ,
5532 p_msg_text => 'Returned failure from COPY_REP_JOB_WORI',
5533 p_stmt_num => l_stmt_num,
5534 p_msg_tokens => l_msg_tokens,
5535 p_fnd_msg_level => G_MSG_LVL_ERROR,
5536 p_fnd_log_level => G_LOG_LEVEL_ERROR,
5537 p_run_log_level => l_log_level
5538 );
5539 END IF;
5540 RAISE FND_API.G_EXC_ERROR;
5541 END IF;
5542 /* ST : Detailed Scheduling end */
5543
5544 l_stmt_num := 250;
5545 if( g_log_level_statement >= l_log_level ) then
5546 l_msg_tokens.delete;
5547 WSM_log_PVT.logMessage(p_module_name => l_module,
5548 p_msg_text => 'Calling COPY_REP_JOB_WRO',
5549 p_stmt_num => l_stmt_num,
5550 p_msg_tokens => l_msg_tokens,
5551 p_fnd_log_level => g_log_level_statement,
5552 p_run_log_level => l_log_level
5553 );
5554 End if;
5555
5556 l_err_code := 0;
5557 l_err_buf := null;
5558
5559 -- Related bugs : 3142153
5560 COPY_REP_JOB_WRO( p_txn_id => null,
5561 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5562 p_new_rj_qty_tbl => l_new_rj_qty_tbl,
5563 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5564 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5565 p_txn_intraop_step => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
5566 x_err_code => l_err_code,
5567 x_err_buf => l_err_buf
5568 );
5569
5570 IF (l_err_code <> 0) THEN
5571 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5572
5573 l_msg_tokens.delete;
5574 WSM_log_PVT.logMessage(p_module_name => l_module ,
5575 p_msg_text => 'Returned failure from COPY_REP_JOB_WRO',
5576 p_stmt_num => l_stmt_num ,
5577 p_msg_tokens => l_msg_tokens,
5578 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5579 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5580 p_run_log_level => l_log_level
5581 );
5582 END IF;
5583 RAISE FND_API.G_EXC_ERROR;
5584 END IF;
5585
5586
5587 l_stmt_num := 260;
5588 if( g_log_level_statement >= l_log_level ) then
5589 l_msg_tokens.delete;
5590 WSM_log_PVT.logMessage(p_module_name => l_module ,
5591 p_msg_text => 'Calling COPY_REP_JOB_WOY ',
5592 p_stmt_num => l_stmt_num ,
5593 p_msg_tokens => l_msg_tokens,
5594 p_fnd_log_level => g_log_level_statement,
5595 p_run_log_level => l_log_level
5596 );
5597 End if;
5598 l_err_code := 0;
5599 l_err_buf := null;
5600 -- Related bugs : 3142153
5601
5602 COPY_REP_JOB_WOY( p_txn_id => null,
5603 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5604 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5605 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5606 x_err_code => l_err_code,
5607 x_err_buf => l_err_buf
5608 );
5609
5610 IF (l_err_code <> 0) THEN
5611 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5612 l_msg_tokens.delete;
5613 WSM_log_PVT.logMessage(p_module_name => l_module ,
5614 p_msg_text => 'Returned failure from COPY_REP_JOB_WOY',
5615 p_stmt_num => l_stmt_num ,
5616 p_msg_tokens => l_msg_tokens,
5617 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5618 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5619 p_run_log_level => l_log_level
5620 );
5621 END IF;
5622 RAISE FND_API.G_EXC_ERROR;
5623 END IF;
5624
5625 -- ok now process the starting jobs...
5626 if( g_log_level_statement >= l_log_level ) then
5627 l_msg_tokens.delete;
5628 WSM_log_PVT.logMessage(p_module_name => l_module ,
5629 p_msg_text => ' processing the starting jobs...',
5630 p_stmt_num => l_stmt_num ,
5631 p_msg_tokens => l_msg_tokens,
5632 p_fnd_log_level => g_log_level_statement,
5633 p_run_log_level => l_log_level
5634 );
5635 End if;
5636
5637 l_job_counter := p_wltx_starting_jobs_tbl.first;
5638 --Bug 5362019:Initialize l_rep_new_qty
5639 l_rep_new_qty := 0;
5640
5641 while l_job_counter is not null loop
5642 -- for l_job_counter in p_wltx_starting_jobs_tbl.first..p_wltx_starting_jobs_tbl.last loop
5643
5644 if (l_job_counter = l_rep_sj_index)
5645 and
5646 (l_sj_also_rj_index is not null)
5647 then -- indicates that the starting job is also a resulting job
5648 if( g_log_level_statement >= l_log_level ) then
5649 l_msg_tokens.delete;
5650 WSM_log_PVT.logMessage(p_module_name => l_module ,
5651 p_msg_text => 'Representative Starting Job ' || p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_name
5652 || ' is also a resulting job..'
5653 || ' Starting Job index(l_job_counter) : ' || l_job_counter
5654 || ' Resulting Job index(l_sj_also_rj_index) : ' || l_sj_also_rj_index,
5655 p_stmt_num => l_stmt_num ,
5656 p_msg_tokens => l_msg_tokens,
5657 p_fnd_log_level => g_log_level_statement,
5658 p_run_log_level => l_log_level
5659 );
5660 End if;
5661 -- related bugs : 3181486
5662 l_stmt_num := 95;
5663
5664 l_rep_new_qty := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity;
5665
5666 -- we can directly call change_quantity here as only one starting job is possible...
5667 l_sj_we_id_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5668 l_sj_old_st_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity;
5669 l_sj_new_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity;
5670 l_sj_new_net_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).net_quantity;
5671 l_sj_op_seq_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).operation_seq_num;
5672 l_sj_scrap_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity - p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5673 l_sj_avail_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5674
5675 l_err_code := 0;
5676 l_err_buf := null;
5677
5678 l_stmt_num := 100;
5679
5680 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id;
5681
5682 -- nw comes the Kanban card id and the completion subinv. updation part....
5683 -- if the starting job has a kanban and if SpUA then exception...
5684 if l_kanban_card_id is not null then
5685
5686 l_stmt_num := 115;
5687
5688 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT and p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).split_has_update_assy = 1 then
5689
5690 l_stmt_num := 120;
5691 if( g_log_level_statement >= l_log_level ) then
5692 l_msg_tokens.delete;
5693 WSM_log_PVT.logMessage(p_module_name => l_module ,
5694 p_msg_text => ' Calling INV_Kanban_PVT.Update_Card_Supply_Status...',
5695 p_stmt_num => l_stmt_num ,
5696 p_msg_tokens => l_msg_tokens,
5697 p_fnd_log_level => g_log_level_statement,
5698 p_run_log_level => l_log_level
5699 );
5700 End if;
5701
5702 -- SpUA .. so remove it...
5703 INV_Kanban_PVT.Update_Card_Supply_Status ( X_Return_Status => l_ret_status,
5704 p_Kanban_Card_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id,
5705 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
5706 );
5707
5708 if ( l_ret_status <> fnd_api.g_ret_sts_success ) then
5709
5710 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5711
5712 l_msg_tokens.delete;
5713 l_msg_tokens(1).TokenName := 'STATUS';
5714 l_msg_tokens(1).TokenValue := g_translated_meaning;
5715 WSM_log_PVT.logMessage(p_module_name => l_module ,
5716 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5717 p_msg_appl_name => 'WSM' ,
5718 p_msg_tokens => l_msg_tokens ,
5719 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5720 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5721 p_run_log_level => l_log_level
5722 );
5723 END IF;
5724 RAISE FND_API.G_EXC_ERROR;
5725
5726 end if;
5727
5728 l_stmt_num := 125;
5729 l_kanban_card_id := null;
5730 else
5731 -- now check if the resulting job has changed
5732 if( g_log_level_statement >= l_log_level ) then
5733 l_msg_tokens.delete;
5734 WSM_log_PVT.logMessage(p_module_name => l_module ,
5735 p_msg_text => ' Calling handle_kanban_sub_loc_change...',
5736 p_stmt_num => l_stmt_num ,
5737 p_msg_tokens => l_msg_tokens,
5738 p_fnd_log_level => g_log_level_statement,
5739 p_run_log_level => l_log_level
5740 );
5741 End if;
5742
5743 l_err_code := 0;
5744 l_err_buf := null;
5745
5746 l_sub_loc_change := handle_kanban_sub_loc_change( p_wip_entity_id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5747 p_kanban_card_id => p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id,
5748 p_wssj_completion_subinventory => p_wltx_starting_jobs_tbl(l_job_counter).completion_subinventory,
5749 p_wssj_completion_locator_id => p_wltx_starting_jobs_tbl(l_job_counter).completion_locator_id,
5750 p_wsrj_completion_subinventory => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_subinventory,
5751 p_wsrj_completion_locator_id => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_locator_id,
5752 x_err_code => l_err_code,
5753 x_err_msg => l_err_buf
5754 );
5755
5756 IF (l_err_code <> 0) THEN
5757 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5758
5759 l_msg_tokens.delete;
5760 WSM_log_PVT.logMessage(p_module_name => l_module ,
5761 p_msg_text => 'Returned failure from handle_kanban_sub_loc_change',
5762 p_stmt_num => l_stmt_num ,
5763 p_msg_tokens => l_msg_tokens,
5764 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5765 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5766 p_run_log_level => l_log_level
5767 );
5768 END IF;
5769 RAISE FND_API.G_EXC_ERROR;
5770 END IF;
5771
5772 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
5773 if l_sub_loc_change <> 0 then
5774 l_kanban_card_id := null;
5775 end if;
5776
5777 if l_sub_loc_change = 0 then -- reflect the updated quantity in the card
5778
5779 l_stmt_num := 147;
5780 if( g_log_level_statement >= l_log_level ) then
5781 l_msg_tokens.delete;
5782 WSM_log_PVT.logMessage(p_module_name => l_module ,
5783 p_msg_text => ' Calling INV_Kanban_PVT.Update_Card_Supply_Status...',
5784 p_stmt_num => l_stmt_num ,
5785 p_msg_tokens => l_msg_tokens,
5786 p_fnd_log_level => g_log_level_statement,
5787 p_run_log_level => l_log_level
5788 );
5789 End if;
5790
5791
5792 INV_Kanban_PVT.Update_Card_Supply_Status( x_return_status => l_ret_Status,
5793 p_Kanban_Card_Id => l_kanban_card_id,
5794 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
5795 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
5796 p_Document_Header_Id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5797 p_Document_detail_Id => '',
5798 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity
5799 );
5800
5801 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
5802 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5803
5804 l_msg_tokens.delete;
5805 l_msg_tokens(1).TokenName := 'STATUS';
5806 l_msg_tokens(1).TokenValue := g_translated_meaning;
5807 WSM_log_PVT.logMessage(p_module_name => l_module ,
5808 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5809 p_msg_appl_name => 'WSM' ,
5810 p_msg_tokens => l_msg_tokens ,
5811 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5812 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5813 p_run_log_level => l_log_level
5814 );
5815 END IF;
5816 RAISE FND_API.G_EXC_ERROR;
5817
5818 end if;
5819
5820 l_stmt_num := 150;
5821 end if;
5822 end if;
5823 end if;
5824
5825 l_stmt_num := 155;
5826
5827 p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).kanban_card_id := l_kanban_card_id;
5828
5829 if( g_log_level_statement >= l_log_level ) then
5830 l_msg_tokens.delete;
5831 WSM_log_PVT.logMessage(p_module_name => l_module ,
5832 p_msg_text => 'Updating the completion subinv and the kanban card id ...',
5833 p_stmt_num => l_stmt_num ,
5834 p_msg_tokens => l_msg_tokens,
5835 p_fnd_log_level => g_log_level_statement,
5836 p_run_log_level => l_log_level
5837 );
5838 End if;
5839
5840 -- update the completion subinv and the kanban card id ....
5841 UPDATE wip_discrete_jobs
5842 SET completion_subinventory = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_subinventory,
5843 completion_locator_id = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_locator_id ,
5844 kanban_card_id = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).kanban_card_id ,
5845 -- ST : Fix for bug 5122500
5846 coproducts_supply = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).coproducts_supply
5847 WHERE wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5848
5849 l_stmt_num := 158;
5850
5851 else -- starting job is has been completely merged/split or a non-representative job...
5852
5853 l_stmt_num := 160;
5854 if( g_log_level_statement >= l_log_level ) then
5855 l_msg_tokens.delete;
5856 WSM_log_PVT.logMessage(p_module_name => l_module ,
5857 p_msg_text => 'starting job has been completely merged/split or a non-representative job... ',
5858 p_stmt_num => l_stmt_num ,
5859 p_msg_tokens => l_msg_tokens,
5860 p_fnd_log_level => g_log_level_statement,
5861 p_run_log_level => l_log_level
5862 );
5863 End if;
5864
5865 --Bug 5362019: l_rep_new_qty should not be reset.Its not applicable when
5866 -- starting job is has been completely merged/split or a non-representative job.
5867 --l_rep_new_qty := 0;
5868 --Bug 5362019: Populate the table l_non_rep_sj_tbl if the current job is not a representative job
5869 if (l_job_counter <> l_rep_sj_index) then
5870 l_non_rep_sj_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5871 end if;
5872 --Bug 5362019: End of changes
5873 -- related bugs : 3181486
5874 -- we can directly call change_quantity here as only one starting job is possible...
5875 l_sj_we_id_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5876 l_sj_old_st_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity;
5877 l_sj_new_qty_tbl(l_job_counter) := 0;
5878 l_sj_new_net_qty_tbl(l_job_counter) := 0;
5879 l_sj_op_seq_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).operation_seq_num;
5880 l_sj_scrap_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity - p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5881 l_sj_avail_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5882
5883 l_stmt_num := 165;
5884
5885 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id;
5886
5887 -- kanban comes into picture... delete the link...
5888 if l_kanban_card_id is not null then
5889
5890 l_stmt_num := 175;
5891
5892 -- In case of split straight forward....
5893 -- In case of Merge check if the resulting job has kanban or not..
5894
5895 if (p_wltx_header.transaction_type_id = WSMPCNST.SPLIT) or
5896 --Bug 5344612:Case of p_wltx_resulting_jobs_tbl.kanban_card_id being null is handled.
5897 p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id IS NULL or
5898 (p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id IS NOT NULL AND
5899 p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id <> l_kanban_card_id)
5900 then
5901
5902 INV_Kanban_PVT.Update_Card_Supply_Status ( x_return_status => l_ret_status,
5903 p_Kanban_Card_Id => p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id,
5904 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
5905 );
5906
5907 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
5908 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5909
5910 l_msg_tokens.delete;
5911 l_msg_tokens(1).TokenName := 'STATUS';
5912 l_msg_tokens(1).TokenValue := g_translated_meaning;
5913 WSM_log_PVT.logMessage(p_module_name => l_module ,
5914 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5915 p_msg_appl_name => 'WSM' ,
5916 p_msg_tokens => l_msg_tokens ,
5917 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5918 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5919 p_run_log_level => l_log_level
5920 );
5921 END IF;
5922 RAISE FND_API.G_EXC_ERROR;
5923 end if;
5924
5925 l_stmt_num := 137;
5926 --Bug 5344676:Commented out the following line
5927 -- l_kanban_card_id := null;
5928 end if;
5929 --Bug 5344676:Kanban card is should be null even if the Kanban status is not set to exception.
5930 l_kanban_card_id := null;
5931 end if;
5932
5933 l_stmt_num := 180;
5934
5935 -- change the status of the job...
5936 -- Related bugs : 2974419
5937 UPDATE wip_discrete_jobs
5938 SET STATUS_TYPE = 4
5939 ,kanban_card_id = l_kanban_card_id
5940 ,date_completed = sysdate
5941 ,last_updated_by = g_user_id
5942 ,last_update_date = sysdate
5943 ,last_update_login = g_user_login_id
5944 ,program_application_id = g_program_appl_id
5945 ,program_id = g_PROGRAM_ID
5946 ,program_update_date = sysdate
5947 ,request_id = g_REQUEST_ID
5948 WHERE wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5949
5950 l_stmt_num := 190;
5951
5952 l_new_name := WSMPOPRN.update_job_name ( p_wip_entity_id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5953 p_subinventory => p_wltx_starting_jobs_tbl(l_job_counter).completion_subinventory,
5954 p_org_id => p_wltx_starting_jobs_tbl(l_job_counter).organization_id,
5955 p_txn_type => 2, -- COMPLETION
5956 p_update_flag => TRUE,
5957 p_dup_job_name => l_dup_job_name,
5958 x_error_code => l_err_code,
5959 x_error_msg => l_err_buf
5960 );
5961
5962 if l_err_code <> 0 then
5963 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5964 l_msg_tokens.delete;
5965 /* Start bugfix 5738550 Use hardcoded text only if API call did not return message */
5966 if l_err_buf is null then
5967 l_err_buf := 'Returned failure from WSMPOPRN.update_job_name';
5968 end if;
5969 /* End bugfix 5738550 */
5970 WSM_log_PVT.logMessage(p_module_name => l_module ,
5971 p_msg_text => l_err_buf , /* Bugfix 5738550 removed hardcoding */
5972 p_stmt_num => l_stmt_num ,
5973 p_msg_tokens => l_msg_tokens,
5974 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5975 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5976 p_run_log_level => l_log_level
5977 );
5978 END IF;
5979 RAISE FND_API.G_EXC_ERROR;
5980 else
5981 -- success.. got the new name for the job ...
5982 if( g_log_level_statement >= l_log_level ) then
5983 l_msg_tokens.delete;
5984 WSM_log_PVT.logMessage(p_module_name => l_module ,
5985 p_msg_text => 'WSMPOPRN.update_job_name success.Got new job name',
5986 p_stmt_num => l_stmt_num ,
5987 p_msg_tokens => l_msg_tokens,
5988 p_fnd_log_level => g_log_level_statement,
5989 p_run_log_level => l_log_level
5990 );
5991 End if;
5992 end if;
5993 l_stmt_num := 200;
5994
5995 end if;
5996
5997 l_job_counter := p_wltx_starting_jobs_tbl.next(l_job_counter);
5998
5999 end loop;
6000
6001
6002 l_stmt_num := 210;
6003 if( g_log_level_statement >= l_log_level ) then
6004 l_msg_tokens.delete;
6005 WSM_log_PVT.logMessage(p_module_name => l_module ,
6006 p_msg_text => 'Calling CHANGE_QUANTITY',
6007 p_stmt_num => l_stmt_num ,
6008 p_msg_tokens => l_msg_tokens,
6009 p_fnd_log_level => g_log_level_statement,
6010 p_run_log_level => l_log_level
6011 );
6012 End if;
6013
6014 l_err_code := 0;
6015 l_err_buf := null;
6016
6017 -- change the quantity
6018 CHANGE_QUANTITY( p_txn_id => null,
6019 p_txn_type => p_wltx_header.transaction_type_id,
6020 p_wip_entity_id_tbl => l_sj_we_id_tbl,
6021 p_new_job_qty_tbl => l_sj_new_qty_tbl,
6022 p_new_net_qty_tbl => l_sj_new_net_qty_tbl,
6023
6024 p_txn_job_op_seq_tbl => l_sj_op_seq_tbl,
6025 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6026
6027 p_sj_st_qty_tbl => l_sj_old_st_qty_tbl,
6028 p_sj_avail_qty_tbl => l_sj_avail_qty_tbl,
6029 p_sj_scrap_qty_tbl => l_sj_scrap_qty_tbl,
6030
6031 x_err_code => l_err_code,
6032 x_err_buf => l_err_buf
6033 );
6034
6035 IF (l_err_code <> 0) THEN
6036 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6037 l_msg_tokens.delete;
6038 WSM_log_PVT.logMessage(p_module_name => l_module ,
6039 p_msg_text => 'CHANGE_QUANTITY returned failure' ,
6040 p_stmt_num => l_stmt_num ,
6041 p_msg_tokens => l_msg_tokens,
6042 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6043 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6044 p_run_log_level => l_log_level
6045 );
6046 END IF;
6047 RAISE FND_API.G_EXC_ERROR;
6048 END IF;
6049
6050 l_stmt_num := 270;
6051 if( g_log_level_statement >= l_log_level ) then
6052 l_msg_tokens.delete;
6053 WSM_log_PVT.logMessage(p_module_name => l_module ,
6054 p_msg_text => 'Calling UPDATE_QTY_ISSUED',
6055 p_stmt_num => l_stmt_num ,
6056 p_msg_tokens => l_msg_tokens,
6057 p_fnd_log_level => g_log_level_statement,
6058 p_run_log_level => l_log_level
6059 );
6060 End if;
6061
6062 l_err_code := 0;
6063 l_err_buf := null;
6064
6065 UPDATE_QTY_ISSUED(p_txn_id => null,
6066 p_txn_type => p_wltx_header.transaction_type_id,
6067 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6068 p_rep_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6069 p_rep_avail_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6070 p_rep_new_job_qty => l_rep_new_qty,
6071 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6072 p_non_rep_sj_we_id_tbl => l_non_rep_sj_tbl,
6073 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
6074 p_new_rj_start_qty => l_new_rj_qty_tbl,
6075 x_err_code => l_err_code,
6076 x_err_buf => l_err_buf
6077 );
6078
6079 if l_err_code <> 0 then
6080 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6081
6082 l_msg_tokens.delete;
6083 WSM_log_PVT.logMessage(p_module_name => l_module ,
6084 p_msg_text => 'UPDATE_QTY_ISSUED returned failure' ,
6085 p_stmt_num => l_stmt_num ,
6086 p_msg_tokens => l_msg_tokens,
6087 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6088 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6089 p_run_log_level => l_log_level
6090 );
6091 END IF;
6092 RAISE FND_API.G_EXC_ERROR;
6093 end if;
6094
6095 l_stmt_num := 280;
6096
6097 -- loop on the resulting jobs for split has update assembly...
6098 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
6099
6100 l_job_counter := p_wltx_resulting_jobs_tbl.first;
6101 while l_job_counter is not null loop
6102 -- for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
6103 if p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy = 1 then
6104
6105 l_stmt_num := 290;
6106 if( g_log_level_statement >= l_log_level ) then
6107 l_msg_tokens.delete;
6108 WSM_log_PVT.logMessage(p_module_name => l_module ,
6109 p_msg_text => 'Calling UPDATE_ASSEMBLY_OR_ROUTING',
6110 p_stmt_num => l_stmt_num ,
6111 p_msg_tokens => l_msg_tokens,
6112 p_fnd_log_level => g_log_level_statement,
6113 p_run_log_level => l_log_level
6114 );
6115 End if;
6116
6117 l_stmt_num := 281;
6118 l_err_code := 0;
6119 l_err_buf := null;
6120
6121 -- SpUA code....
6122 UPDATE_ASSEMBLY_OR_ROUTING( p_txn_id => null,
6123 p_txn_type_id => WSMPCNST.SPLIT,
6124 -- p_rep_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
6125 p_job_kanban_card_id => null, -- no need already handled within the code.. .....
6126 p_po_creation_time => l_po_creation_time,
6127 p_sj_compl_subinventory => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory,
6128 p_sj_compl_locator_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_locator_id,
6129 p_rj_job_rec => p_wltx_resulting_jobs_tbl(l_job_counter),
6130 p_request_id => g_request_id,
6131 x_err_code => l_err_code,
6132 x_err_buf => l_err_buf ,
6133 x_msg_count => x_msg_count
6134 );
6135
6136 IF (l_err_code <> 0) THEN
6137 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6138
6139 l_msg_tokens.delete;
6140 WSM_log_PVT.logMessage(p_module_name => l_module ,
6141 p_msg_text => 'UPDATE_ASSEMBLY_OR_ROUTING returned failure' ,
6142 p_stmt_num => l_stmt_num ,
6143 p_msg_tokens => l_msg_tokens,
6144 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6145 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6146 p_run_log_level => l_log_level
6147 );
6148 END IF;
6149 RAISE FND_API.G_EXC_ERROR;
6150 END IF;
6151 end if;
6152
6153 l_job_counter := p_wltx_resulting_jobs_tbl.next(l_job_counter);
6154 end loop;
6155 end if;
6156
6157 l_stmt_num := 282;
6158 --Update the new columns in WLBJ as part of MES
6159 l_current_job_op_seq_num := p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num;
6160
6161 BEGIN
6162 select operation_seq_num
6163 into l_current_rtg_op_seq_num
6164 from bom_operation_sequences
6165 where operation_sequence_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_id ;
6166
6167 EXCEPTION
6168 WHEN NO_DATA_FOUND THEN
6169 -- Will reach here when the job lies at an op outside the
6170 -- routing
6171 l_current_rtg_op_seq_num := null;
6172 END;
6173
6174 l_stmt_num := 283;
6175 forall i in indices of l_new_rj_we_id_tbl
6176 update wsm_lot_based_jobs
6177 set CURRENT_RTG_OP_SEQ_NUM = l_current_rtg_op_seq_num,
6178 CURRENT_JOB_OP_SEQ_NUM = l_current_job_op_seq_num
6179 where wip_entity_id = l_new_rj_we_id_tbl(i)
6180 and CURRENT_RTG_OP_SEQ_NUM is null
6181 and CURRENT_JOB_OP_SEQ_NUM is null;
6182
6183 ----End Update the new columns in WLBJ as part of MES
6184
6185 -- Start : Additions for APS-WLT --
6186 l_stmt_num := 295;
6187
6188
6189 IF (WSMPJUPD.g_copy_mode = 0) THEN
6190 null; -- no copies
6191 ELSE
6192 l_stmt_num := 296;
6193
6194 l_err_code := 0;
6195 l_err_buf := null;
6196
6197 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
6198 p_txn_type_id => p_wltx_header.transaction_type_id,
6199 p_copy_mode => WSMPJUPD.g_copy_mode,
6200 p_rep_sj_index => l_rep_sj_index,
6201 p_sj_as_rj_index => l_sj_also_rj_index,
6202 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6203 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6204 x_err_code => l_err_code,
6205 x_err_buf => l_err_buf,
6206 x_msg_count => x_msg_count
6207 );
6208
6209
6210 IF (l_err_code <> 0) THEN
6211 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6212
6213 l_msg_tokens.delete;
6214 WSM_log_PVT.logMessage(p_module_name => l_module ,
6215 p_msg_text => 'CREATE_COPIES_OR_SET_COPY_DATA returned '||l_err_code,
6216 p_stmt_num => l_stmt_num ,
6217 p_msg_tokens => l_msg_tokens,
6218 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6219 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6220 p_run_log_level => l_log_level
6221 );
6222 END IF;
6223 RAISE FND_API.G_EXC_ERROR; --x_err_code has errcode, x_err_buf has the error message
6224 END IF;
6225
6226 -- New Jobs in Split/Merge, jobs undergoing SPUA and jobs involved in Upd Rtg/Assly
6227 -- have already been either Infinite Scheduled or the data has been set for them
6228 -- in the above call CREATE_COPIES_OR_SET_COPY_DATA, which
6229 -- calls Create_JobCopies / Create_RepJobCopies
6230 -- The remaining jobs (parent rep jobs in Sp/Merge and jobs in UpdQty)
6231 -- are taken care of now
6232
6233 l_stmt_num := 300;
6234
6235 IF l_sj_also_rj_index is not null then
6236
6237 l_stmt_num := 310;
6238
6239 l_err_code := 0;
6240 l_err_buf := null;
6241
6242 CALL_INF_SCH_OR_SET_SCH_DATA( p_txn_id => null,
6243 p_copy_mode => WSMPJUPD.g_copy_mode,
6244 p_org_id => p_txn_org_id,
6245 p_par_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6246 x_err_code => l_err_code,
6247 x_err_buf => l_err_buf
6248 );
6249
6250 IF (l_err_code <> 0) THEN
6251 -- error out...
6252 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6253
6254 l_msg_tokens.delete;
6255 WSM_log_PVT.logMessage(p_module_name => l_module ,
6256 p_msg_text => ' CALL_INF_SCH_OR_SET_SCH_DATA returned '||l_err_code,
6257 p_stmt_num => l_stmt_num ,
6258 p_msg_tokens => l_msg_tokens,
6259 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6260 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6261 p_run_log_level => l_log_level
6262 );
6263 END IF;
6264 RAISE FND_API.G_EXC_ERROR;
6265 END IF;
6266
6267 END IF;
6268
6269 END IF;
6270
6271 -- ST : Sec. UOM Fix : Moved the call to process MES information below the call to update_assembly_routing
6272 l_stmt_num := 320;
6273 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6274 p_wltx_header => p_wltx_header,
6275 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6276 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6277 p_sj_also_rj_index => l_sj_also_rj_index,
6278 p_rep_job_index => l_rep_sj_index,
6279 x_return_status => x_return_status ,
6280 x_msg_count => x_msg_count ,
6281 x_error_msg => x_error_msg
6282 );
6283 if x_return_status <> G_RET_SUCCESS then
6284 IF x_return_status = G_RET_ERROR THEN
6285 raise FND_API.G_EXC_ERROR;
6286 ELSE
6287 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6288 END IF;
6289 end if;
6290
6291 l_stmt_num := 330;
6292 -- Geneology differs for split and merge...
6293 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
6294
6295 l_stmt_num := 340;
6296
6297 -- for geneology purpose.... get the gen obj id
6298 select gen_object_id
6299 into l_sj_gen_object_id
6300 from wip_entities we
6301 where we.wip_entity_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6302
6303 for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
6304
6305 l_stmt_num := 345;
6306
6307 -- get the gen object id of the resulting jobs ...
6308 select gen_object_id
6309 into l_rj_gen_object_id
6310 from wip_entities we
6311 where we.wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
6312 --Bug 5387828:Genealogy should be created only when the starting job is diff from
6313 --resulting job.
6314 if l_sj_gen_object_id <> l_rj_gen_object_id then
6315 l_ret_status := 'E'; -- fnd error status...
6316
6317 l_stmt_num := 350;
6318
6319 inv_genealogy_pub.insert_genealogy( p_api_version =>1.0,
6320
6321 p_object_type =>5,
6322 p_object_id =>l_sj_gen_object_id,
6323 p_object_number =>p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6324 p_inventory_item_id =>p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6325 p_org_id =>p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
6326
6327 p_parent_object_type => 5,
6328 p_parent_object_id => l_rj_gen_object_id,
6329 p_parent_object_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
6330 p_parent_inventory_item_id=> p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
6331 p_parent_org_id => p_wltx_resulting_jobs_tbl(l_job_counter).organization_id,
6332
6333 p_genealogy_origin => 3, -- for WIP parent
6334 p_genealogy_type => 4, -- for WIP/Inv Split/Merge/Translate
6335 p_origin_txn_id => p_wltx_header.transaction_id,
6336
6337 x_return_status =>l_ret_status,
6338 x_msg_count =>l_msg_count,
6339 x_msg_data =>l_msg_data
6340 );
6341 end if;
6342 if l_sj_gen_object_id = l_rj_gen_object_id then
6343 l_ret_status := 'S';
6344 end if;
6345 l_stmt_num := 360;
6346 IF (l_ret_status = 'S') THEN
6347 if( g_log_level_statement >= l_log_level ) then
6348 l_msg_tokens.delete;
6349 WSM_log_PVT.logMessage(p_module_name => l_module ,
6350 p_msg_text => 'inv_genealogy_pub.insert_genealogy returned success',
6351 p_stmt_num => l_stmt_num ,
6352 p_msg_tokens => l_msg_tokens,
6353 p_fnd_log_level => g_log_level_statement,
6354 p_run_log_level => l_log_level
6355 );
6356 End if;
6357
6358 ELSE
6359
6360 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6361
6362 l_msg_tokens.delete;
6363 WSM_log_PVT.logMessage(p_module_name => l_module ,
6364 p_msg_text => 'inv_genealogy_pub.insert_genealogy failed',
6365 p_stmt_num => l_stmt_num ,
6366 p_msg_tokens => l_msg_tokens,
6367 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6368 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6369 p_run_log_level => l_log_level
6370 );
6371 END IF;
6372
6373
6374 l_stmt_num := 370;
6375 IF (l_msg_count = 1) THEN
6376 l_err_code := -1;
6377 l_err_buf := 'Error in inv_genealogy_pub.insert_genealogy: '||l_msg_data;
6378
6379 ELSE
6380 FOR i IN 1..l_msg_count LOOP
6381 l_err_code := -1;
6382 l_err_buf := fnd_msg_pub.get;
6383
6384 END LOOP;
6385
6386 l_err_buf := 'Multiple errors in inv_genealogy_pub.insert_genealogy - populated in the log file';
6387
6388 END IF;
6389 RAISE FND_API.G_EXC_ERROR;
6390 END IF;
6391
6392 end loop;
6393 else
6394 -- Merge...
6395
6396 l_stmt_num := 371;
6397
6398 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6399
6400 -- for geneology purpose.... get the gen obj id
6401 select gen_object_id
6402 into l_rj_gen_object_id
6403 from wip_entities we
6404 where we.wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
6405
6406 for l_job_counter in p_wltx_starting_jobs_tbl.first..p_wltx_starting_jobs_tbl.last loop
6407
6408 l_stmt_num := 372;
6409
6410 -- get the gen object id of the resulting jobs ...
6411 select gen_object_id
6412 into l_sj_gen_object_id
6413 from wip_entities we
6414 where we.wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
6415
6416 --Bug 5367218:START. Genealogy should be created only when the resulting job is not
6417 -- among one of the starting jobs.
6418 if l_sj_gen_object_id <> l_rj_gen_object_id then
6419 l_ret_status := 'E'; -- fnd error status...
6420
6421 l_stmt_num := 373;
6422
6423 inv_genealogy_pub.insert_genealogy( p_api_version =>1.0,
6424
6425 p_object_type =>5,
6426 p_object_id =>l_sj_gen_object_id,
6427 p_object_number =>p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_name,
6428 p_inventory_item_id =>p_wltx_starting_jobs_tbl(l_job_counter).primary_item_id,
6429 p_org_id =>p_wltx_starting_jobs_tbl(l_job_counter).organization_id,
6430
6431 p_parent_object_type => 5,
6432 p_parent_object_id => l_rj_gen_object_id,
6433 p_parent_object_number => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_name,
6434 p_parent_inventory_item_id=> p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).primary_item_id,
6435 p_parent_org_id => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).organization_id,
6436
6437 p_genealogy_origin => 3, -- for WIP parent
6438 p_genealogy_type => 4, -- for WIP/Inv Split/Merge/Translate
6439 p_origin_txn_id => p_wltx_header.transaction_id,
6440
6441 x_return_status =>l_ret_status,
6442 x_msg_count =>l_msg_count,
6443 x_msg_data =>l_msg_data
6444 );
6445 end if;
6446
6447 if l_sj_gen_object_id = l_rj_gen_object_id then
6448 l_ret_status := 'S';
6449 end if;
6450 --Bug 5367218:END.
6451 l_stmt_num := 374;
6452 IF (l_ret_status = 'S') THEN
6453 if( g_log_level_statement >= l_log_level ) then
6454 l_msg_tokens.delete;
6455 WSM_log_PVT.logMessage(p_module_name => l_module ,
6456 p_msg_text => 'inv_genealogy_pub.insert_genealogy returned success',
6457 p_stmt_num => l_stmt_num ,
6458 p_msg_tokens => l_msg_tokens,
6459 p_fnd_log_level => g_log_level_statement,
6460 p_run_log_level => l_log_level
6461 );
6462 End if;
6463 ELSE
6464 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6465
6466 l_msg_tokens.delete;
6467 WSM_log_PVT.logMessage(p_module_name => l_module ,
6468 p_msg_text => 'inv_genealogy_pub.insert_genealogy failed',
6469 p_stmt_num => l_stmt_num ,
6470 p_msg_tokens => l_msg_tokens,
6471 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6472 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6473 p_run_log_level => l_log_level
6474 );
6475 END IF;
6476
6477 l_stmt_num := 375;
6478 IF (l_msg_count = 1) THEN
6479 l_err_code := -1;
6480 l_err_buf := 'Error in inv_genealogy_pub.insert_genealogy: '||l_msg_data;
6481 ELSE
6482 FOR i IN 1..l_msg_count LOOP
6483 l_err_code := -1;
6484 l_err_buf := fnd_msg_pub.get;
6485 END LOOP;
6486
6487 l_err_buf := 'Multiple errors in inv_genealogy_pub.insert_genealogy - populated in the log file';
6488
6489 END IF;
6490 RAISE FND_API.G_EXC_ERROR;
6491 END IF;
6492
6493 end loop;
6494
6495 end if;
6496
6497 l_stmt_num := 380;
6498
6499 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
6500 p_txn_org_id => p_txn_org_id,
6501 p_txn_date => p_wltx_header.transaction_date,--sysdate, --l_txn_date,
6502 p_txn_type_id => p_wltx_header.transaction_type_id,
6503 p_sj_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6504 p_sj_wip_entity_name => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6505 p_sj_avail_quantity => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6506 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_id,
6507 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_name,
6508 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).start_quantity,
6509 p_sj_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6510 p_sj_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6511 x_return_status => l_ret_status,
6512 x_msg_count => l_msg_count,
6513 x_msg_data => l_msg_data
6514 );
6515
6516 l_stmt_num := 390;
6517
6518 if l_ret_status <> fnd_api.g_ret_sts_success then
6519 -- error out...
6520 l_stmt_num := 395;
6521 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6522 l_msg_tokens.delete;
6523 WSM_log_PVT.logMessage(p_module_name => l_module ,
6524 p_msg_text => 'Insert_MMT_record failed',
6525 p_stmt_num => l_stmt_num ,
6526 p_msg_tokens => l_msg_tokens,
6527 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6528 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6529 p_run_log_level => l_log_level
6530 );
6531 END IF;
6532 RAISE FND_API.G_EXC_ERROR;
6533 end if;
6534
6535 l_stmt_num := 400;
6536
6537
6538 l_txn_status := WIP_CONSTANTS.COMPLETED;
6539 l_txn_costed := WIP_CONSTANTS.pending;
6540
6541 elsif p_wltx_header.transaction_type_id in (WSMPCNST.UPDATE_ASSEMBLY,WSMPCNST.UPDATE_ROUTING) then
6542
6543 l_stmt_num := 500;
6544 l_err_code := 0;
6545 l_err_buf := null;
6546
6547 UPDATE_ASSEMBLY_OR_ROUTING( p_txn_id => null,
6548 p_txn_type_id => p_wltx_header.transaction_type_id,
6549 -- p_rep_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
6550 p_job_kanban_card_id => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).kanban_card_id,
6551 p_po_creation_time => l_po_creation_time,
6552 p_sj_compl_subinventory => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).completion_subinventory,
6553 p_sj_compl_locator_id => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).completion_locator_id,
6554 p_rj_job_rec => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first),
6555 p_request_id => g_request_id,
6556 x_err_code => l_err_code,
6557 x_err_buf => l_err_buf ,
6558 x_msg_count => x_msg_count
6559 );
6560
6561 IF (l_err_code <> 0) THEN
6562 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6563 l_msg_tokens.delete;
6564 WSM_log_PVT.logMessage(p_module_name => l_module ,
6565 p_msg_text => 'UPDATE_ASSEMBLY_OR_ROUTING failed',
6566 p_stmt_num => l_stmt_num ,
6567 p_msg_tokens => l_msg_tokens,
6568 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6569 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6570 p_run_log_level => l_log_level
6571 );
6572 END IF;
6573 RAISE FND_API.G_EXC_ERROR;
6574 END IF;
6575
6576 l_stmt_num := 510;
6577 l_err_code := 0;
6578 l_err_buf := null;
6579
6580 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
6581 p_txn_type_id => p_wltx_header.transaction_type_id,
6582 p_copy_mode => WSMPJUPD.g_copy_mode,
6583 p_rep_sj_index => p_wltx_starting_jobs_tbl.first,
6584 p_sj_as_rj_index => p_wltx_resulting_jobs_tbl.first,
6585 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6586 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6587 x_err_code => l_err_code,
6588 x_err_buf => l_err_buf,
6589 x_msg_count => x_msg_count
6590 );
6591 IF (l_err_code <> 0) 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 WSM_log_PVT.logMessage(p_module_name => l_module ,
6596 p_msg_text => 'CREATE_COPIES_OR_SET_COPY_DATA failed',
6597 p_stmt_num => l_stmt_num ,
6598 p_msg_tokens => l_msg_tokens,
6599 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6600 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6601 p_run_log_level => l_log_level
6602 );
6603 END IF;
6604 RAISE FND_API.G_EXC_ERROR;
6605 END IF;
6606
6607 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6608 p_wltx_header => p_wltx_header,
6609 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6610 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6611 p_sj_also_rj_index => p_wltx_resulting_jobs_tbl.first,
6612 p_rep_job_index => p_wltx_starting_jobs_tbl.first,
6613 x_return_status => x_return_status ,
6614 x_msg_count => x_msg_count ,
6615 x_error_msg => x_error_msg
6616 );
6617
6618 if x_return_status <> G_RET_SUCCESS then
6619 IF x_return_status = G_RET_ERROR THEN
6620 raise FND_API.G_EXC_ERROR;
6621 ELSE
6622 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6623 END IF;
6624 end if;
6625
6626 l_txn_status := WIP_CONSTANTS.COMPLETED;
6627 l_txn_costed := WIP_CONSTANTS.COMPLETED;
6628
6629
6630 elsif p_wltx_header.transaction_type_id = WSMPCNST.UPDATE_QUANTITY then
6631
6632 l_stmt_num := 520;
6633 l_err_code := 0;
6634 l_err_buf := null;
6635
6636 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
6637 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6638
6639 l_sj_we_id_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6640 l_sj_new_qty_tbl(l_rep_sj_index) := p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity;
6641 l_sj_new_net_qty_tbl(l_rep_sj_index) := p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity;
6642 l_sj_op_seq_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num;
6643
6644 l_sj_old_st_qty_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).start_quantity;
6645 l_sj_avail_qty_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available;
6646 l_sj_scrap_qty_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).start_quantity - p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available;
6647
6648 -- change the quantity
6649 CHANGE_QUANTITY( p_txn_id => null,
6650 p_txn_type => WSMPCNST.UPDATE_QUANTITY,
6651 p_wip_entity_id_tbl => l_sj_we_id_tbl,
6652 p_new_job_qty_tbl => l_sj_new_qty_tbl,
6653 p_new_net_qty_tbl => l_sj_new_net_qty_tbl,
6654
6655 p_txn_job_op_seq_tbl => l_sj_op_seq_tbl,
6656 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6657
6658 p_sj_st_qty_tbl => l_sj_old_st_qty_tbl,
6659 p_sj_avail_qty_tbl => l_sj_avail_qty_tbl,
6660 p_sj_scrap_qty_tbl => l_sj_scrap_qty_tbl,
6661
6662 x_err_code => l_err_code,
6663 x_err_buf => l_err_buf
6664 );
6665
6666 IF (l_err_code <> 0) THEN
6667 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6668
6669 l_msg_tokens.delete;
6670 WSM_log_PVT.logMessage(p_module_name => l_module ,
6671 p_msg_text => 'CHANGE_QUANTITY failed',
6672 p_stmt_num => l_stmt_num ,
6673 p_msg_tokens => l_msg_tokens,
6674 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6675 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6676 p_run_log_level => l_log_level
6677 );
6678 END IF;
6679 RAISE FND_API.G_EXC_ERROR;
6680 END IF;
6681
6682 -- end processing the starting jobs....
6683 l_stmt_num := 530;
6684 l_err_code := 0;
6685 l_err_buf := null;
6686
6687 -- no no no-rep jobs for update qty...
6688 l_non_rep_sj_tbl.delete;
6689 l_new_rj_we_id_tbl.delete;
6690 l_new_rj_qty_tbl.delete;
6691
6692 UPDATE_QTY_ISSUED(p_txn_id => null,
6693 p_txn_type => WSMPCNST.UPDATE_QUANTITY,
6694 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6695 p_rep_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6696 p_rep_avail_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6697 p_rep_new_job_qty => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
6698 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6699 p_non_rep_sj_we_id_tbl => l_non_rep_sj_tbl,
6700 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
6701 p_new_rj_start_qty => l_new_rj_qty_tbl,
6702 x_err_code => l_err_code,
6703 x_err_buf => l_err_buf
6704 );
6705
6706 if l_err_code <> 0 then
6707 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6708
6709 l_msg_tokens.delete;
6710 WSM_log_PVT.logMessage(p_module_name => l_module ,
6711 p_msg_text => 'UPDATE_QTY_ISSUED failed',
6712 p_stmt_num => l_stmt_num ,
6713 p_msg_tokens => l_msg_tokens,
6714 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6715 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6716 p_run_log_level => l_log_level
6717 );
6718 END IF;
6719 RAISE FND_API.G_EXC_ERROR;
6720 end if;
6721
6722 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id;
6723
6724 -- nw comes the Kanban card id and the completion subinv. updation part....
6725 -- if the starting job has a
6726 if l_kanban_card_id is not null then
6727
6728 l_stmt_num := 115;
6729
6730 -- now check if the resulting job has changed
6731 l_err_code := 0;
6732 l_err_buf := null;
6733
6734 l_sub_loc_change := handle_kanban_sub_loc_change( p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6735 p_kanban_card_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id,
6736 p_wssj_completion_subinventory => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory,
6737 p_wssj_completion_locator_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_locator_id,
6738 p_wsrj_completion_subinventory => p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
6739 p_wsrj_completion_locator_id => p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
6740 x_err_code => l_err_code,
6741 x_err_msg => l_err_buf
6742 );
6743
6744 IF (l_err_code <> 0) THEN
6745 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6746
6747 l_msg_tokens.delete;
6748 WSM_log_PVT.logMessage(p_module_name => l_module ,
6749 p_msg_text => 'handle_kanban_sub_loc_change failed',
6750 p_stmt_num => l_stmt_num ,
6751 p_msg_tokens => l_msg_tokens,
6752 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6753 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6754 p_run_log_level => l_log_level
6755 );
6756 END IF;
6757 RAISE FND_API.G_EXC_ERROR;
6758 END IF;
6759
6760 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
6761 if l_sub_loc_change <> 0 then
6762 l_kanban_card_id := null;
6763 end if;
6764
6765 if l_sub_loc_change = 0 then -- reflect the updated quantity in the card
6766
6767 l_stmt_num := 147;
6768
6769 INV_Kanban_PVT.Update_Card_Supply_Status( x_return_status => l_ret_Status,
6770 p_Kanban_Card_Id => l_kanban_card_id,
6771 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
6772 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
6773 p_Document_Header_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6774 p_Document_detail_Id => '',
6775 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity
6776 );
6777
6778 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
6779
6780 --x_err_code := -1;
6781 fnd_message.set_name('WSM', 'WSM_KNBN_CARD_STS_FAIL');
6782 fnd_message.set_token('STATUS',g_translated_meaning);
6783 --x_err_buf := fnd_message.get;
6784 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6785
6786 l_msg_tokens.delete;
6787 l_msg_tokens(1).TokenName := 'STATUS';
6788 l_msg_tokens(1).TokenValue := g_translated_meaning;
6789 WSM_log_PVT.logMessage(p_module_name => l_module ,
6790 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
6791 p_msg_appl_name => 'WSM' ,
6792 p_msg_tokens => l_msg_tokens ,
6793 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6794 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6795 p_run_log_level => l_log_level
6796 );
6797 END IF;
6798
6799 RAISE FND_API.G_EXC_ERROR;
6800
6801 end if;
6802
6803 l_stmt_num := 150;
6804 end if;
6805
6806 end if;
6807
6808 l_stmt_num := 155;
6809
6810 -- update the completion subinv and the kanban card id ....
6811 update wip_discrete_jobs
6812 SET completion_subinventory = p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
6813 completion_locator_id = p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
6814 kanban_card_id = l_kanban_card_id
6815 where wip_entity_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6816
6817 l_stmt_num := 158;
6818
6819 IF (WSMPUTIL.check_osp_operation(p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6820 p_operation_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6821 p_organization_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id
6822 )
6823 )
6824 THEN
6825
6826 WSMPJUPD.g_osp_exists := 1;
6827
6828 if (l_po_creation_time <> WIP_CONSTANTS.MANUAL_CREATION) then
6829
6830 l_stmt_num := 253;
6831
6832 wip_osp.create_additional_req ( P_Wip_Entity_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6833 P_Organization_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
6834 P_Repetitive_Schedule_Id => null,
6835 P_Added_Quantity => (p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity-p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available),
6836 P_Op_Seq => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num
6837 );
6838
6839 --if l_request_id is null,-1 means online processing so launch import req
6840 -- Modified for Bug 15902089.
6841 if (g_request_id is null or g_request_id = -1) then
6842
6843 l_po_request_id := fnd_request.submit_request('PO', 'REQIMPORT', NULL, NULL, FALSE,'WIP', NULL, 'ITEM',
6844 NULL,'N', 'Y', chr(0), NULL, NULL, NULL,
6845 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6846 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6847 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6848 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6849 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6850 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6851 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6852 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6853 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6854 );
6855 -- submitted : l_po_request_id
6856
6857 end if;
6858 end if;
6859 END IF;
6860 --osp end
6861
6862 -- call to infinite schedule....
6863 IF (WSMPJUPD.g_copy_mode = 0) THEN
6864 null; -- no copies
6865 ELSE
6866 l_stmt_num := 540;
6867 l_err_code := 0;
6868 l_err_buf := null;
6869
6870 CALL_INF_SCH_OR_SET_SCH_DATA( p_txn_id => null,
6871 p_copy_mode => WSMPJUPD.g_copy_mode,
6872 p_org_id => p_txn_org_id,
6873 p_par_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6874 x_err_code => l_err_code,
6875 x_err_buf => l_err_buf
6876 );
6877
6878 IF (l_err_code <> 0) THEN
6879 -- error out...
6880 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6881
6882 l_msg_tokens.delete;
6883 WSM_log_PVT.logMessage(p_module_name => l_module ,
6884 p_msg_text => 'CALL_INF_SCH_OR_SET_SCH_DATA returned failure:'||l_err_code,
6885 p_stmt_num => l_stmt_num ,
6886 p_msg_tokens => l_msg_tokens,
6887 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6888 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6889 p_run_log_level => l_log_level
6890 );
6891 END IF;
6892 RAISE FND_API.G_EXC_ERROR;
6893 END IF;
6894 end if;
6895
6896 l_stmt_num := 590;
6897
6898 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6899 p_wltx_header => p_wltx_header,
6900 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6901 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6902 p_sj_also_rj_index => p_wltx_resulting_jobs_tbl.first,
6903 p_rep_job_index => p_wltx_starting_jobs_tbl.first,
6904 x_return_status => x_return_status ,
6905 x_msg_count => x_msg_count ,
6906 x_error_msg => x_error_msg
6907 );
6908
6909 if x_return_status <> G_RET_SUCCESS then
6910 IF x_return_status = G_RET_ERROR THEN
6911 raise FND_API.G_EXC_ERROR;
6912 ELSE
6913 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6914 END IF;
6915 end if;
6916
6917 -- p_txn_id should be known here....
6918 -- call to insert MMT....
6919 l_ret_status := FND_API.G_RET_STS_SUCCESS;
6920 l_msg_data := null;
6921
6922 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
6923 p_txn_org_id => p_txn_org_id,
6924 p_txn_date => sysdate, --l_txn_date, /* has to be txn date... */
6925 p_txn_type_id => WSMPCNST.update_quantity,
6926 p_sj_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6927 p_sj_wip_entity_name => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6928 p_sj_avail_quantity => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6929 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
6930 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
6931 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
6932 p_sj_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6933 p_sj_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6934 x_return_status => l_ret_status,
6935 x_msg_count => l_msg_count,
6936 x_msg_data => l_msg_data
6937 );
6938
6939 l_stmt_num := 390;
6940
6941 if l_ret_status <> fnd_api.g_ret_sts_success then
6942 -- error out...
6943 l_stmt_num := 395;
6944 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6945
6946 l_msg_tokens.delete;
6947 WSM_log_PVT.logMessage(p_module_name => l_module ,
6948 p_msg_text => 'Insert_MMT_record failed',
6949 p_stmt_num => l_stmt_num ,
6950 p_msg_tokens => l_msg_tokens,
6951 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6952 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6953 p_run_log_level => l_log_level
6954 );
6955 END IF;
6956 RAISE FND_API.G_EXC_ERROR;
6957 end if;
6958
6959 l_stmt_num := 400;
6960
6961
6962 l_txn_status := WIP_CONSTANTS.COMPLETED;
6963 l_txn_costed := WIP_CONSTANTS.pending;
6964
6965 elsif p_wltx_header.transaction_type_id = WSMPCNST.UPDATE_LOT_NAME then
6966
6967 l_stmt_num := 550;
6968
6969 if( g_log_level_statement >= l_log_level ) then
6970 l_msg_tokens.delete;
6971 WSM_log_PVT.logMessage(p_module_name => l_module ,
6972 p_msg_text => 'Transaction type is Update Lotname:',
6973 p_stmt_num => l_stmt_num ,
6974 p_msg_tokens => l_msg_tokens,
6975 p_fnd_log_level => g_log_level_statement,
6976 p_run_log_level => l_log_level
6977 );
6978 End if;
6979
6980 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
6981 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6982
6983 if p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id is null then
6984
6985 if p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id is not null then
6986 p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6987 else
6988 select wip_entity_id
6989 into p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id
6990 from wip_entities
6991 where wip_entity_name like p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name;
6992 end if;
6993 end if;
6994
6995 l_stmt_num := 560;
6996
6997 update wip_discrete_jobs
6998 set lot_number = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
6999 description = p_wltx_resulting_jobs_tbl(l_rj_index).description,
7000 /* Start Bugfix 5531371 csi/loc is updatable in upd lot name */
7001 completion_subinventory = p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
7002 completion_locator_id = p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id
7003 /* End Bugfix 5531371*/
7004 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
7005
7006 l_stmt_num := 570;
7007
7008 update wip_entities
7009 set wip_entity_name = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7010 description = p_wltx_resulting_jobs_tbl(l_rj_index).description
7011 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
7012
7013 l_txn_status := WIP_CONSTANTS.COMPLETED;
7014 l_txn_costed := WIP_CONSTANTS.COMPLETED;
7015
7016 elsif p_wltx_header.transaction_type_id = WSMPCNST.BONUS then
7017 if p_wltx_resulting_jobs_tbl.count > 0 then
7018 l_rj_index := p_wltx_resulting_jobs_tbl.first;
7019 else
7020 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7021
7022 l_msg_tokens.delete;
7023 WSM_log_PVT.logMessage(p_module_name=> l_module ,
7024 p_msg_name => 'WSM_RESULT_LOT_REQUIRED',
7025 p_msg_appl_name => 'WSM',
7026 p_msg_tokens => l_msg_tokens ,
7027 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7028 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7029 p_run_log_level => l_log_level
7030 );
7031 END IF;
7032 RAISE FND_API.G_EXC_ERROR;
7033
7034 end if;
7035
7036 l_bonus_rtg_st_op_seq := p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num;
7037
7038 l_stmt_num := 55;
7039 l_err_code := 0;
7040 l_err_buf := null;
7041 --remove this
7042 if( g_log_level_statement >= l_log_level ) then
7043 l_msg_tokens.delete;
7044 WSM_log_PVT.logMessage(p_module_name => l_module ,
7045 p_msg_text => 'Calling WSMPLBJI.build_lbji_info procedure'||p_wltx_resulting_jobs_tbl(l_rj_index).class_code,
7046 p_stmt_num => l_stmt_num ,
7047 p_msg_tokens => l_msg_tokens,
7048 p_fnd_log_level => g_log_level_statement,
7049 p_run_log_level => l_log_level
7050 );
7051 End if;
7052
7053 -- Create Job Header ONLY
7054 WSMPLBJI.build_lbji_info
7055 (p_routing_seq_id => p_wltx_resulting_jobs_tbl(l_rj_index).common_routing_sequence_id,
7056 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_rj_index).common_bom_sequence_id,
7057 p_explode_header_detail => null,
7058 p_status_type => WIP_CONSTANTS.RELEASED,
7059 p_class_code => p_wltx_resulting_jobs_tbl(l_rj_index).class_code,
7060 p_org => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7061 p_wip_entity_id => l_new_we_id, -- this is returned by the API
7062 p_last_updt_date => sysdate,
7063 p_last_updt_by => g_user_id,
7064 p_creation_date => sysdate,
7065 p_created_by => g_user_id,
7066 p_last_updt_login => g_user_login_id,
7067 p_request_id => g_request_id,
7068 p_program_application_id => g_program_appl_id,
7069 p_program_id => g_program_id,
7070 p_prog_updt_date => sysdate,
7071 p_source_line_id => NULL,
7072 p_source_code => NULL,
7073 p_description => p_wltx_resulting_jobs_tbl(l_rj_index).description,
7074 p_item => p_wltx_resulting_jobs_tbl(l_rj_index).primary_item_id,
7075 p_job_type => p_wltx_resulting_jobs_tbl(l_rj_index).job_type,
7076 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_rj_index).bom_reference_id,
7077 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_rj_index).routing_reference_id,
7078 p_firm_planned_flag => 2,
7079 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_rj_index).wip_supply_type,
7080 p_fusd => p_wltx_resulting_jobs_tbl(l_rj_index).scheduled_start_date,
7081 p_lucd => p_wltx_resulting_jobs_tbl(l_rj_index).scheduled_completion_date,
7082 p_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
7083 p_net_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity,
7084 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_rj_index).coproducts_supply,
7085 p_bom_revision => p_wltx_resulting_jobs_tbl(l_rj_index).bom_revision,
7086 p_routing_revision => p_wltx_resulting_jobs_tbl(l_rj_index).routing_revision,
7087 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_rj_index).bom_revision_date,
7088 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_rj_index).routing_revision_date,
7089 p_lot_number => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7090 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_rj_index).alternate_bom_designator,
7091 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_rj_index).alternate_routing_designator,
7092 p_priority => NULL,
7093 p_due_date => NULL,
7094
7095 p_attribute_category => null,
7096 p_attribute1 => null,
7097 p_attribute2 => null,
7098 p_attribute3 => null,
7099 p_attribute4 => null,
7100 p_attribute5 => null,
7101 p_attribute6 => null,
7102 p_attribute7 => null,
7103 p_attribute8 => null,
7104 p_attribute9 => null,
7105 p_attribute10 => null,
7106 p_attribute11 => null,
7107 p_attribute12 => null,
7108 p_attribute13 => null,
7109 p_attribute14 => null,
7110 p_attribute15 => null,
7111
7112 p_job_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7113 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
7114 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
7115 p_demand_class => null,
7116 p_project_id => NULL,
7117 p_task_id => NULL,
7118 p_schedule_group_id => NULL,
7119 p_build_sequence => NULL,
7120 p_line_id => NULL,
7121 p_kanban_card_id => NULL,
7122 p_overcompl_tol_type => NULL,
7123 p_overcompl_tol_value => NULL,
7124 p_end_item_unit_number => NULL,
7125 p_rtg_op_seq_num => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7126 p_src_client_server => 1,
7127 p_po_creation_time => l_po_creation_time,
7128 p_date_released => p_wltx_header.transaction_date, --bug 4101117
7129 p_error_code => l_err_code,
7130 p_error_msg => l_err_buf
7131 );
7132
7133 l_stmt_num := 70;
7134
7135 IF (l_err_code <> 0) THEN
7136 --remove this
7137 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7138
7139 l_msg_tokens.delete;
7140 WSM_log_PVT.logMessage(p_module_name => l_module ,
7141 p_msg_text => 'Returned failure from WSMPLBJI.build_lbji_info procedure'||l_err_buf,
7142 p_stmt_num => l_stmt_num ,
7143 p_msg_tokens => l_msg_tokens,
7144 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7145 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7146 p_run_log_level => l_log_level
7147 );
7148 END IF;
7149 RAISE FND_API.G_EXC_ERROR;
7150 ELSE
7151 -- success... now the program would have returned the id ....
7152 if( g_log_level_statement >= l_log_level ) then
7153 l_msg_tokens.delete;
7154 WSM_log_PVT.logMessage(p_module_name => l_module ,
7155 p_msg_text => 'Returned successfully from WSMPLBJI.build_lbji_info procedure',
7156 p_stmt_num => l_stmt_num ,
7157 p_msg_tokens => l_msg_tokens,
7158 p_fnd_log_level => g_log_level_statement,
7159 p_run_log_level => l_log_level
7160 );
7161 End if;
7162 p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id := l_new_we_id;
7163 END IF;
7164
7165
7166 /*call creat wsor_wlbj_records*/
7167 l_stmt_num := 80;
7168 l_err_code := 0;
7169 l_err_buf := null;
7170
7171 CREATE_WSOR_WLBJ_RECORDS( p_wip_entity_id => l_new_we_id,
7172 p_org_id => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7173 p_only_wo_op_seq => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num, -- Create only this record
7174 p_last_update_date => sysdate,
7175 p_last_updated_by => g_user_id,
7176 p_last_update_login => g_user_login_id,
7177 p_creation_date => sysdate,
7178 p_created_by => g_user_id,
7179 p_request_id => g_request_id,
7180 p_program_app_id => g_program_appl_id,
7181 p_program_id => g_program_id,
7182 p_program_update_date => sysdate,
7183 x_err_code => l_err_code,
7184 x_err_buf => l_err_buf
7185 );
7186
7187
7188 IF (l_err_code <> 0) THEN
7189 if( g_log_level_statement >= l_log_level ) then
7190
7191 l_msg_tokens.delete;
7192 WSM_log_PVT.logMessage(p_module_name => l_module ,
7193 p_msg_text => 'Returned failure from CREATE_WSOR_WLBJ_RECORDS',
7194 p_stmt_num => l_stmt_num ,
7195 p_msg_tokens => l_msg_tokens,
7196 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7197 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7198 p_run_log_level => l_log_level
7199 );
7200 END IF;
7201 RAISE FND_API.G_EXC_ERROR;
7202 ELSE
7203 if( g_log_level_statement >= l_log_level ) then
7204 l_msg_tokens.delete;
7205 WSM_log_PVT.logMessage(p_module_name => l_module ,
7206 p_msg_text => 'Created WSOR records for new job with id='||l_new_we_id,
7207 p_stmt_num => l_stmt_num ,
7208 p_msg_tokens => l_msg_tokens,
7209 p_fnd_log_level => g_log_level_statement,
7210 p_run_log_level => l_log_level
7211 );
7212 End if;
7213 END IF;
7214
7215 l_stmt_num := 90;
7216
7217 /* assign the job seq num*/
7218 SELECT max(operation_seq_num)
7219 INTO l_bonus_job_st_op_seq
7220 FROM wip_operations
7221 WHERE wip_entity_id = l_new_we_id;
7222
7223 p_wltx_resulting_jobs_tbl(l_rj_index).job_operation_seq_num := l_bonus_job_st_op_seq;
7224
7225 if( g_log_level_statement >= l_log_level ) then
7226 l_msg_tokens.delete;
7227 WSM_log_PVT.logMessage(p_module_name => l_module ,
7228 p_msg_text => 'Updated the job seq num in resulting job record : ' || l_bonus_job_st_op_seq,
7229 p_stmt_num => l_stmt_num ,
7230 p_msg_tokens => l_msg_tokens,
7231 p_fnd_log_level => g_log_level_statement,
7232 p_run_log_level => l_log_level
7233 );
7234 End if;
7235
7236 l_stmt_num := 100;
7237 UPDATE wip_operations
7238 SET wsm_op_seq_num = l_bonus_rtg_st_op_seq
7239 WHERE wip_entity_id = l_new_we_id
7240 AND operation_seq_num = l_bonus_job_st_op_seq;
7241
7242 if( g_log_level_statement >= l_log_level ) then
7243 l_msg_tokens.delete;
7244 WSM_log_PVT.logMessage(p_module_name => l_module ,
7245 p_msg_text => 'Updated the op seq num in wip_operations',
7246 p_stmt_num => l_stmt_num,
7247 p_msg_tokens => l_msg_tokens,
7248 p_fnd_log_level => g_log_level_statement,
7249 p_run_log_level => l_log_level
7250 );
7251 End if;
7252
7253 /*insert into WLBJ here as not handled in new CREATE_WSOR_WLBJ_RECORDS,the new MES columns are also handled here*/
7254 l_stmt_num:=105;
7255
7256 INSERT into WSM_LOT_BASED_JOBS
7257 (WIP_ENTITY_ID,
7258 ORGANIZATION_ID,
7259 ON_REC_PATH,
7260 INTERNAL_COPY_TYPE,
7261 COPY_PARENT_WIP_ENTITY_ID,
7262 INFINITE_SCHEDULE,
7263 CURRENT_JOB_OP_SEQ_NUM, --MES add
7264 CURRENT_RTG_OP_SEQ_NUM, --MES add
7265 LAST_UPDATE_DATE,
7266 LAST_UPDATED_BY,
7267 LAST_UPDATE_LOGIN,
7268 CREATION_DATE,
7269 CREATED_BY,
7270 REQUEST_ID,
7271 PROGRAM_APPLICATION_ID,
7272 PROGRAM_ID,
7273 PROGRAM_UPDATE_DATE
7274 )
7275 VALUES
7276 (p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
7277 p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7278 'Y', -- ON_REC_PATH
7279 0,
7280 NULL, -- COPY_PARENT_WIP_ENTITY_ID
7281 NULL, -- INFINITE_SCHEDULE
7282 p_wltx_resulting_jobs_tbl(l_rj_index).job_operation_seq_num,
7283 p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7284 sysdate,
7285 g_user_id,
7286 g_user_login_id,
7287 sysdate,
7288 g_user_id,
7289 g_request_id,
7290 g_program_appl_id,
7291 g_program_id,
7292 sysdate
7293 );
7294
7295 l_stmt_num := 110;
7296
7297 if( g_log_level_statement >= l_log_level ) then
7298 l_msg_tokens.delete;
7299 WSM_log_PVT.logMessage(p_module_name => l_module ,
7300 p_msg_text => 'Checking for open a/c period',
7301 p_stmt_num => l_stmt_num,
7302 p_msg_tokens => l_msg_tokens,
7303 p_fnd_log_level => g_log_level_statement,
7304 p_run_log_level => l_log_level
7305 );
7306 End if;
7307
7308 /*check for open accounting period*/
7309 l_stmt_num := 120;
7310 l_acct_period_id := -1;
7311 l_err_code := -1;
7312 l_err_buf := null;
7313
7314 l_acct_period_id := WSMPUTIL.GET_INV_ACCT_PERIOD(l_err_code, l_err_buf, p_wltx_resulting_jobs_tbl(l_rj_index).organization_id, p_wltx_header.transaction_date);
7315
7316 IF (l_err_code <> 0) THEN
7317 /*error out*/
7318 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7319
7320 l_msg_tokens.delete;
7321 WSM_log_PVT.logMessage(p_module_name => l_module ,
7322 p_msg_text => 'Accounting Period not open',
7323 p_stmt_num => l_stmt_num ,
7324 p_msg_tokens => l_msg_tokens,
7325 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7326 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7327 p_run_log_level => l_log_level
7328 );
7329 END IF;
7330 RAISE FND_API.G_EXC_ERROR;
7331 END IF;
7332
7333 l_stmt_num := 130;
7334 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7335 l_msg_count := 0;
7336 l_msg_data := null;
7337
7338 if( g_log_level_statement >= l_log_level ) then
7339 l_msg_tokens.delete;
7340 WSM_log_PVT.logMessage(p_module_name => l_module ,
7341 p_msg_text => 'Inserting MMT record',
7342 p_stmt_num => l_stmt_num,
7343 p_msg_tokens => l_msg_tokens,
7344 p_fnd_log_level => g_log_level_statement,
7345 p_run_log_level => l_log_level
7346 );
7347 End if;
7348
7349 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
7350 p_txn_org_id => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7351 p_txn_date => p_wltx_header.transaction_date,--sysdate, --l_txn_date,
7352 p_txn_type_id => p_wltx_header.transaction_type_id,
7353 p_sj_wip_entity_id => null,
7354 p_sj_wip_entity_name => null,
7355 p_sj_avail_quantity => null,
7356 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
7357 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7358 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
7359 p_sj_item_id => p_wltx_resulting_jobs_tbl(l_rj_index).primary_item_id,
7360 p_sj_op_seq_num => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7361 x_return_status => l_ret_status,
7362 x_msg_count => l_msg_count,
7363 x_msg_data => l_msg_data
7364 );
7365 if l_ret_status <> fnd_api.g_ret_sts_success then
7366 -- error out...
7367 l_stmt_num := 395;
7368 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7369
7370 l_msg_tokens.delete;
7371 WSM_log_PVT.logMessage(p_module_name => l_module ,
7372 p_msg_text => 'Insert_MMT_record failed:'||l_msg_data,
7373 p_stmt_num => l_stmt_num ,
7374 p_msg_tokens => l_msg_tokens,
7375 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7376 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7377 p_run_log_level => l_log_level
7378 );
7379 END IF;
7380 RAISE FND_API.G_EXC_ERROR;
7381 end if;
7382
7383 l_stmt_num := 140;
7384 l_err_code := 0;
7385 l_err_buf := null;
7386
7387 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
7388 p_txn_type_id => p_wltx_header.transaction_type_id,
7389 p_copy_mode => WSMPJUPD.g_copy_mode,
7390 p_rep_sj_index => null,
7391 p_sj_as_rj_index => l_rj_index,
7392 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7393 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7394 x_err_code => l_err_code,
7395 x_err_buf => l_err_buf,
7396 x_msg_count => x_msg_count
7397 );
7398
7399 IF (l_err_code <> 0) THEN
7400 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7401
7402 l_msg_tokens.delete;
7403 WSM_log_PVT.logMessage(p_module_name => l_module ,
7404 p_msg_text => 'CREATE_COPIES_OR_SET_COPY_DATA returned failure ' || l_err_buf,
7405 p_stmt_num => l_stmt_num ,
7406 p_msg_tokens => l_msg_tokens,
7407 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7408 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7409 p_run_log_level => l_log_level
7410 );
7411 END IF;
7412 RAISE FND_API.G_EXC_ERROR; --x_err_code has errcode, x_err_buf has the error message
7413 END IF;
7414
7415 -- Begin MES changes
7416 -- Commented out due to insufficient data in sec qty table due to which txns r failing-to be uncommented
7417
7418 l_stmt_num := 150;
7419
7420 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
7421 p_wltx_header => p_wltx_header,
7422 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7423 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7424 p_sj_also_rj_index => null,
7425 p_rep_job_index => null,
7426 x_return_status => x_return_status ,
7427 x_msg_count => x_msg_count ,
7428 x_error_msg => x_error_msg
7429 );
7430 if x_return_status <> G_RET_SUCCESS then
7431 IF x_return_status = G_RET_ERROR THEN
7432 raise FND_API.G_EXC_ERROR;
7433 ELSE
7434 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7435 END IF;
7436 end if;
7437
7438 -- End MES changes--
7439 l_stmt_num := 400;
7440
7441 l_txn_status := WIP_CONSTANTS.COMPLETED;
7442 l_txn_costed := WIP_CONSTANTS.pending;
7443
7444 else
7445 -- error out....
7446 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7447
7448 l_msg_tokens.delete;
7449 WSM_log_PVT.logMessage(p_module_name => l_module ,
7450 p_msg_text => 'Invalid Txn type',
7451 p_stmt_num => l_stmt_num ,
7452 p_msg_tokens => l_msg_tokens,
7453 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7454 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7455 p_run_log_level => l_log_level
7456 );
7457 END IF;
7458 raise FND_API.G_EXC_ERROR;
7459 end if;
7460
7461
7462 l_stmt_num := 500;
7463 --Start Sales Order LBJ Reservation Changes -- (Commented out as waiting for INV Changes
7464 If p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.UPDATE_ASSEMBLY,
7465 WSMPCNST.UPDATE_QUANTITY,WSMPCNST.UPDATE_ROUTING,WSMPCNST.UPDATE_LOT_NAME) then
7466 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
7467 l_rsv_exists := WSM_RESERVATIONS_PVT.check_reservation_exists(p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
7468 P_org_id => p_wltx_header.organization_id,
7469 P_inventory_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id
7470 ) ;
7471 If l_rsv_exists then
7472 l_stmt_num := 510;
7473 If p_wltx_header.transaction_type_id in (WSMPCNST.UPDATE_QUANTITY,WSMPCNST.UPDATE_ROUTING,WSMPCNST.UPDATE_LOT_NAME) then
7474 l_rj_index := p_wltx_resulting_jobs_tbl.first;
7475 l_stmt_num := 520;
7476 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7477 l_msg_count := 0;
7478 l_msg_data := null;
7479 WSM_RESERVATIONS_PVT.Modify_reservations_jobupdate(p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
7480 P_old_net_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).net_quantity,
7481 P_new_net_qty => p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity,
7482 P_inventory_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
7483 P_org_id => p_wltx_header.organization_id,
7484 P_status_type => p_wltx_resulting_jobs_tbl(l_rj_index).status_type,
7485 x_return_status => l_ret_status,
7486 x_msg_count => l_msg_count,
7487 x_msg_data => l_msg_data
7488 ); --this is to handle the change in net qty if any.
7489
7490 if l_ret_status <> fnd_api.g_ret_sts_success then
7491 -- error out...
7492
7493 if( g_log_level_statement >= l_log_level ) then
7494
7495 l_msg_tokens.delete;
7496 WSM_log_PVT.logMessage(p_module_name => l_module ,
7497 p_msg_text => 'WSM_RESERVATIONS_PVT.Modify_reservations_jobupdate failed:'||l_msg_data,
7498 p_stmt_num => l_stmt_num ,
7499 p_msg_tokens => l_msg_tokens,
7500 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7501 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7502 p_run_log_level => l_log_level
7503 );
7504 END IF;
7505 RAISE FND_API.G_EXC_ERROR;
7506 END IF;
7507 Else
7508 --Split,SpUA and Update Assembly transaction
7509 l_stmt_num := 530;
7510 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7511 l_msg_count := 0;
7512 l_msg_data := null;
7513 WSM_RESERVATIONS_PVT.modify_reservations_wlt (
7514 p_txn_header => p_wltx_header,
7515 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7516 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7517 p_rep_job_index => 1,--l_ rep_job_index,
7518 p_sj_also_rj_index => l_sj_also_rj_index,
7519 x_return_status => l_ret_status,
7520 x_msg_count => l_msg_count,
7521 x_msg_data => l_msg_data) ;
7522 if l_ret_status <> fnd_api.g_ret_sts_success then
7523 -- error out...
7524 if( g_log_level_statement >= l_log_level ) then
7525
7526 l_msg_tokens.delete;
7527 WSM_log_PVT.logMessage(p_module_name => l_module ,
7528 p_msg_text => 'WSM_RESERVATIONS_PVT.modify_reservations_wlt failed:'||l_msg_data,
7529 p_stmt_num => l_stmt_num ,
7530 p_msg_tokens => l_msg_tokens,
7531 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7532 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7533 p_run_log_level => l_log_level
7534 );
7535 END IF;
7536 --To be reverted
7537 RAISE FND_API.G_EXC_ERROR;
7538 end if;
7539 End if;
7540 End if;
7541 elsif p_wltx_header.transaction_type_id in (WSMPCNST.MERGE) then
7542 l_stmt_num := 540;
7543 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7544 l_msg_count := 0;
7545 l_msg_data := null;
7546 WSM_RESERVATIONS_PVT.modify_reservations_wlt (
7547 p_txn_header => p_wltx_header,
7548 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7549 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7550 p_rep_job_index => l_rep_sj_index,
7551 p_sj_also_rj_index => l_sj_also_rj_index,
7552 x_return_status => l_ret_status,
7553 x_msg_count => l_msg_count,
7554 x_msg_data => l_msg_data) ;
7555 if l_ret_status <> fnd_api.g_ret_sts_success then
7556 -- error out...
7557 l_stmt_num := 200;
7558 if( g_log_level_statement >= l_log_level ) then
7559
7560 l_msg_tokens.delete;
7561 WSM_log_PVT.logMessage(p_module_name => l_module ,
7562 p_msg_text => 'WSM_RESERVATIONS_PVT.modify_reservations_wlt failed:'||l_msg_data,
7563 p_stmt_num => l_stmt_num ,
7564 p_msg_tokens => l_msg_tokens,
7565 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7566 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7567 p_run_log_level => l_log_level
7568 );
7569 END IF;
7570 --To be reverted
7571 --RAISE FND_API.G_EXC_ERROR;
7572 end if;
7573 End if;
7574 --End Sales Order LBJ Reservation Changes--
7575
7576 -- to take care of phantoms...
7577 DELETE FROM BOM_EXPLOSION_TEMP
7578 WHERE GROUP_ID = WSMPWROT.EXPLOSION_GROUP_ID;
7579
7580 WSMPWROT.EXPLOSION_GROUP_ID := NULL;
7581 WSMPWROT.USE_PHANTOM_ROUTINGS := NULL;
7582 -- end to take care of phantoms--
7583
7584 EXCEPTION
7585
7586 WHEN FND_API.G_EXC_ERROR THEN
7587 x_return_status := FND_API.G_RET_STS_ERROR ;
7588
7589 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7590 p_count => x_msg_count ,
7591 p_data => x_error_msg
7592 );
7593
7594 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7595
7596 x_return_status := G_RET_UNEXPECTED;
7597
7598 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7599 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7600 THEN
7601 WSM_log_PVT.handle_others( p_module_name => l_module ,
7602 p_stmt_num => l_stmt_num ,
7603 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7604 p_run_log_level => l_log_level
7605 );
7606 END IF;
7607
7608 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7609 p_count => x_msg_count ,
7610 p_data => x_error_msg
7611 );
7612 WHEN OTHERS THEN
7613
7614 x_return_status := G_RET_UNEXPECTED;
7615
7616 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7617 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7618 THEN
7619 WSM_log_PVT.handle_others( p_module_name => l_module ,
7620 p_stmt_num => l_stmt_num ,
7621 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7622 p_run_log_level => l_log_level
7623 );
7624 END IF;
7625
7626 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7627 p_count => x_msg_count ,
7628 p_data => x_error_msg
7629 );
7630
7631 end PROCESS_LOTS;
7632
7633 END WSMPJUPD;