[Home] [Help]
PACKAGE BODY: APPS.WSMPJUPD
Source
1 PACKAGE BODY WSMPJUPD AS
2 /* $Header: WSMJUPDB.pls 120.40.12000000.3 2007/07/26 09:21:53 adasa 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
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_EXIST');
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_EXIST',
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
3109 END IF;
3110
3111 IF ((l_manually_added_comp = 1) OR (l_issued_material = 1)) THEN
3112 fnd_message.set_name('WSM', 'WSM_MANUAL_CHARGES_EXIST');
3113 fnd_message.set_token('ELEMENT', 'Materials');
3114 l_fnd_err_msg := FND_MESSAGE.GET;
3115
3116 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3117
3118 l_msg_tokens.delete;
3119 l_msg_tokens(1).TokenName := 'ELEMENT';
3120 l_msg_tokens(1).TokenValue := 'Materials';
3121 WSM_log_PVT.logMessage(p_module_name => l_module ,
3122 p_msg_name => 'WSM_MANUAL_CHARGES_EXIST',
3123 p_msg_appl_name => 'WSM' ,
3124 p_msg_tokens => l_msg_tokens ,
3125 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3126 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3127 p_run_log_level => l_log_level
3128 );
3129 END IF;
3130
3131 END IF;
3132
3133 IF (l_manually_added_comp = 2) THEN
3134 fnd_message.set_name('WSM','WSM_PHANTOM_COMPONENTS_EXIST');
3135 l_fnd_err_msg := FND_MESSAGE.GET;
3136
3137 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3138
3139 l_msg_tokens.delete;
3140 WSM_log_PVT.logMessage(p_module_name => l_module ,
3141 p_msg_name => 'WSM_PHANTOM_COMPONENTS_EXIST',
3142 p_msg_appl_name => 'WSM' ,
3143 p_msg_tokens => l_msg_tokens ,
3144 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3145 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3146 p_run_log_level => l_log_level
3147 );
3148 END IF;
3149
3150 END IF;
3151 END IF;
3152
3153 l_stmt_num := 50;
3154
3155 --=== START: OBSOLETE THE OPERATIONS ===--
3156 UPDATE WIP_OPERATIONS
3157 SET COUNT_POINT_TYPE = 3,
3158 SCHEDULED_QUANTITY = 0,
3159 QUANTITY_IN_QUEUE = 0,
3160 LAST_UPDATE_DATE = SYSDATE,
3161 LAST_UPDATED_BY = g_user_id,
3162 LAST_UPDATE_LOGIN = g_user_login_id,
3163 REQUEST_ID = g_request_id,
3164 PROGRAM_APPLICATION_ID = g_program_appl_id,
3165 PROGRAM_ID = g_program_id,
3166 PROGRAM_UPDATE_DATE = SYSDATE,
3167 DISABLE_DATE = SYSDATE -- bug 2931071
3168 WHERE WIP_ENTITY_ID = p_wip_entity_id
3169 AND ORGANIZATION_ID = p_org_id
3170 AND OPERATION_SEQ_NUM >= l_job_op_seq_num;
3171
3172 l_stmt_num := 55;
3173
3174 -- Start Additions to fix bug #2682612--
3175 UPDATE WIP_REQUIREMENT_OPERATIONS
3176 SET required_quantity = 0
3177 WHERE WIP_ENTITY_ID = p_wip_entity_id
3178 AND ORGANIZATION_ID = p_org_id
3179 AND (OPERATION_SEQ_NUM >= l_job_op_seq_num
3180 OR
3181 OPERATION_SEQ_NUM <= 0-l_job_op_seq_num
3182 );
3183
3184 l_stmt_num := 60;
3185
3186 UPDATE WIP_OPERATION_RESOURCES
3187 SET autocharge_type = 2
3188 WHERE WIP_ENTITY_ID = p_wip_entity_id
3189 AND ORGANIZATION_ID = p_org_id
3190 AND OPERATION_SEQ_NUM >= l_job_op_seq_num;
3191
3192 -- End Additions to fix bug #2682612--
3193
3194 --=== END: OBSOLETE THE OPERATIONS ===--
3195 -- Start : Additions for APS-WLT--
3196
3197 ELSIF (l_job_intra_op = WIP_CONSTANTS.TOMOVE) THEN
3198 l_stmt_num := 61;
3199
3200 l_job_op_start_dt := l_job_op_comp_dt; --Bug 3318382
3201
3202 IF (l_op_seq_num IS NULL) THEN
3203 -- Starting op may not be provided
3204 -- for Option A, if the job is at TM
3205 return;
3206 ELSE -- If starting operation is provided
3207 l_stmt_num := 62;
3208
3209 UPDATE WIP_OPERATIONS
3210 SET QUANTITY_WAITING_TO_MOVE = 0,
3211 LAST_UPDATE_DATE = SYSDATE,
3212 LAST_UPDATED_BY = g_user_id,
3213 LAST_UPDATE_LOGIN = g_user_login_id,
3214 REQUEST_ID = g_request_id,
3215 PROGRAM_APPLICATION_ID = g_program_appl_id,
3216 PROGRAM_ID = g_program_id,
3217 PROGRAM_UPDATE_DATE = SYSDATE
3218 WHERE WIP_ENTITY_ID = p_wip_entity_id
3219 AND ORGANIZATION_ID = p_org_id
3220 AND OPERATION_SEQ_NUM = l_job_op_seq_num;
3221 END IF;
3222
3223 END IF;
3224 -- End : Additions for APS-WLT--
3225 l_stmt_num := 65;
3226
3227 --Add target op with new bom/rtg info into WO, WOR, WRO, WOY, fnd_attach as prev_op + incr
3228
3229 l_stmt_num := 80;
3230
3231 SELECT max(operation_seq_num)
3232 INTO l_job_max_op_seq_num
3233 FROM wip_operations
3234 WHERE wip_entity_id = p_wip_entity_id;
3235
3236 p_new_op_added := l_job_max_op_seq_num + l_wsm_param_seq_incr;
3237
3238 l_stmt_num := 85;
3239
3240 if( g_log_level_statement >= l_log_level ) then
3241 l_msg_tokens.delete;
3242 WSM_log_PVT.logMessage(p_module_name => l_module ,
3243 p_msg_text => 'Calling WSMPLBJI.insert_procedure :' ||p_rj_job_rec.starting_operation_seq_id,
3244 p_stmt_num => l_stmt_num ,
3245 p_msg_tokens => l_msg_tokens,
3246 p_fnd_log_level => g_log_level_statement,
3247 p_run_log_level => l_log_level
3248 );
3249 End if;
3250
3251 x_err_code := 0;
3252 x_err_buf := null;
3253
3254 WSMPLBJI.insert_procedure
3255 (p_seq_id => p_rj_job_rec.starting_operation_seq_id,
3256 p_job_seq_num => p_new_op_added,
3257 p_common_routing_sequence_id => p_rj_job_rec.common_routing_sequence_id,
3258 p_supply_type => p_rj_job_rec.wip_supply_type,
3259 p_wip_entity_id => p_wip_entity_id,
3260 p_organization_id => p_org_id,
3261 p_quantity => p_rj_job_rec.start_quantity,
3262 p_job_type => p_rj_job_rec.job_type,
3263 p_bom_reference_id => p_rj_job_rec.bom_reference_id,
3264 p_rtg_reference_id => p_rj_job_rec.routing_reference_id,
3265 p_assembly_item_id => p_rj_job_rec.primary_item_id,
3266 p_alt_bom_designator => p_rj_job_rec.alternate_bom_designator,
3267 p_alt_rtg_designator => p_rj_job_rec.alternate_routing_designator,
3268 --Bug 3318382 p_fusd => l_sch_st_dt,
3269 --Bug 3318382 p_lucd => l_sch_comp_dt,
3270 --Bug 3318382
3271 p_fusd => l_job_op_start_dt,
3272 --Bug 3318382
3273 p_lucd => l_job_op_comp_dt,
3274
3275 p_rtg_revision_date => p_rj_job_rec.routing_revision_date,
3276 p_bom_revision_date => p_rj_job_rec.bom_revision_date,
3277 p_last_updt_date => sysdate,
3278 p_last_updt_by => g_user_id,
3279 p_creation_date => sysdate,
3280 p_created_by => g_user_id,
3281 p_last_updt_login => g_user_login_id,
3282 p_request_id => g_request_id,
3283 p_program_application_id => g_program_appl_id,
3284 p_program_id => g_program_id,
3285 p_prog_updt_date => sysdate,
3286 p_error_code => x_err_code,
3287 p_error_msg => x_err_buf
3288 );
3289
3290 IF (x_err_code <> 0) THEN
3291
3292 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3293 l_msg_tokens.delete;
3294 WSM_log_PVT.logMessage(p_module_name => l_module ,
3295 p_msg_text => 'Returned failure from WSMPLBJI.insert_procedure.Error:'|| x_err_buf,
3296 p_stmt_num => l_stmt_num ,
3297 p_msg_tokens => l_msg_tokens,
3298 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3299 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3300 p_run_log_level => l_log_level
3301 );
3302 END IF;
3303 RAISE FND_API.G_EXC_ERROR;
3304 END IF;
3305
3306 -- Start : Additions to fix bug 3452913 --
3307 UPDATE wip_operations
3308 SET wsm_op_seq_num = l_op_seq_num
3309 WHERE wip_entity_id = p_wip_entity_id
3310 AND operation_seq_num = p_new_op_added;
3311 -- End : Additions to fix bug 3452913 --
3312
3313 l_stmt_num := 90;
3314
3315 --Start : Additions for APS-WLT--
3316 IF (WSMPJUPD.g_copy_mode = 0) THEN
3317 null;
3318 ELSE
3319 l_stmt_num := 92;
3320 -- Create WSOR table records --
3321 x_err_code := 0;
3322 x_err_buf := null;
3323
3324 CREATE_WSOR_WLBJ_RECORDS( p_wip_entity_id => p_wip_entity_id,
3325 p_org_id => p_org_id,
3326 p_only_wo_op_seq => p_new_op_added, -- Create only this record
3327 p_last_update_date => sysdate,
3328 p_last_updated_by => g_user_id,
3329 p_last_update_login => g_user_login_id,
3330 p_creation_date => sysdate,
3331 p_created_by => g_user_id,
3332 p_request_id => g_request_id,
3333 p_program_app_id => g_program_appl_id,
3334 p_program_id => g_program_id,
3335 p_program_update_date => sysdate,
3336 x_err_code => x_err_code,
3337 x_err_buf => x_err_buf
3338 );
3339
3340
3341 IF (x_err_code <> 0) THEN
3342 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3343
3344 l_msg_tokens.delete;
3345 WSM_log_PVT.logMessage(p_module_name => l_module ,
3346 p_msg_text => 'Returned failure from CREATE_WSOR_WLBJ_RECORDS',
3347 p_stmt_num => l_stmt_num ,
3348 p_msg_tokens => l_msg_tokens,
3349 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3350 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3351 p_run_log_level => l_log_level
3352 );
3353 END IF;
3354 RAISE FND_API.G_EXC_ERROR;
3355 ELSE
3356
3357 if( g_log_level_statement >= l_log_level ) then
3358 l_msg_tokens.delete;
3359 WSM_log_PVT.logMessage(p_module_name => l_module ,
3360 p_msg_text => 'Created WSOR records for new job with id='||p_wip_entity_id,
3361 p_stmt_num => l_stmt_num ,
3362 p_msg_tokens => l_msg_tokens,
3363 p_fnd_log_level => g_log_level_statement,
3364 p_run_log_level => l_log_level
3365 );
3366 End if;
3367
3368 END IF;
3369
3370 END IF; --WSMPJUPD.g_copy_mode
3371 --End : Additions for APS-WLT--
3372
3373 l_stmt_num := 95;
3374
3375 --Update the previous and next op seq nums
3376 UPDATE WIP_OPERATIONS WO
3377 SET WO.PREVIOUS_OPERATION_SEQ_NUM = (SELECT MAX(OPERATION_SEQ_NUM)
3378 FROM WIP_OPERATIONS
3379 WHERE WIP_ENTITY_ID = p_wip_entity_id
3380 AND OPERATION_SEQ_NUM < WO.OPERATION_SEQ_NUM),
3381 WO.NEXT_OPERATION_SEQ_NUM = (SELECT MIN(OPERATION_SEQ_NUM)
3382 FROM WIP_OPERATIONS
3383 WHERE WIP_ENTITY_ID = p_wip_entity_id
3384 AND OPERATION_SEQ_NUM > WO.OPERATION_SEQ_NUM)
3385 WHERE WO.WIP_ENTITY_ID = p_wip_entity_id;
3386
3387 l_stmt_num := 100;
3388
3389 --Set qty in Queue of the target operation
3390 UPDATE WIP_OPERATIONS
3391 SET quantity_in_queue = l_job_qty
3392 WHERE wip_entity_id = p_wip_entity_id
3393 AND operation_seq_num = p_new_op_added;
3394
3395
3396 l_stmt_num := 110;
3397 x_err_code := 0;
3398 x_err_buf := NULL;
3399
3400
3401 EXCEPTION
3402 WHEN FND_API.G_EXC_ERROR THEN
3403 x_err_code := SQLCODE;
3404 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3405 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3406 p_count => x_msg_count ,
3407 p_data => x_err_buf
3408 );
3409 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3410 x_err_code := SQLCODE;
3411 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3412 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3413 p_count => x_msg_count ,
3414 p_data => x_err_buf
3415 );
3416 WHEN OTHERS THEN
3417 x_err_code := SQLCODE;
3418 x_err_buf := ' WSMPJUPD.CHANGE_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3419
3420 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3421 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3422 THEN
3423 WSM_log_PVT.handle_others( p_module_name => l_module ,
3424 p_stmt_num => l_stmt_num ,
3425 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3426 p_run_log_level => l_log_level
3427 );
3428 END IF;
3429 END CHANGE_ROUTING;
3430 -- end ..............
3431
3432
3433 /*-----------------------------------------------------------------+
3434 | Name : UPDATE_ASSEMBLY_OR_ROUTING
3435 -------------------------------------------------------------------*/
3436
3437
3438 --SpUA begin: Moved Update Assembly/Routing code from Process_Wip_Lot_Txns here.
3439 -- To be used by Split and Update Assy, Update Assy, Update Routing txns.
3440
3441 PROCEDURE UPDATE_ASSEMBLY_OR_ROUTING(p_txn_id IN NUMBER,
3442 p_txn_type_id IN NUMBER,
3443 p_job_kanban_card_id IN NUMBER, --abbKanban
3444 p_po_creation_time IN NUMBER, --osp
3445 p_request_id IN NUMBER, --osp
3446 p_sj_compl_subinventory IN VARCHAR2,
3447 p_sj_compl_locator_id IN NUMBER,
3448 p_rj_job_rec IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_REC_TYPE,
3449 x_err_code OUT NOCOPY NUMBER,
3450 x_err_buf OUT NOCOPY VARCHAR2,
3451 x_msg_count OUT NOCOPY NUMBER)
3452
3453 IS
3454
3455 l_txn_type_id NUMBER;
3456 l_org_id NUMBER;
3457 l_wip_entity_id NUMBER;
3458 l_new_op_added NUMBER;
3459 l_po_creation_time NUMBER; --osp
3460 l_request_id NUMBER; --osp
3461 l_job_kanban_card_id NUMBER; --abbKanban
3462 l_kanban_card_id NUMBER; --abbKanban
3463 l_sub_loc_change NUMBER; --abbKanban
3464 l_return_status VARCHAR2(1); --abbKanban
3465 translated_meaning VARCHAR2(240); --abbkanban
3466 l_rtg_op_seq_num NUMBER;
3467
3468 -- Logging variables.....
3469 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3470 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3471
3472 l_stmt_num NUMBER;
3473 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.UPDATE_ASSEMBLY_OR_ROUTING';
3474
3475 BEGIN
3476
3477 l_txn_type_id := p_txn_type_id;
3478 l_org_id := p_rj_job_rec.organization_id;
3479 l_wip_entity_id := p_rj_job_rec.wip_entity_id;
3480 l_job_kanban_card_id := p_job_kanban_card_id;
3481 l_po_creation_time := p_po_creation_time;
3482 l_request_id := p_request_id;
3483
3484 -- SpUA : l_wip_entity_id is resulting job wip_id for Split and Update Assy
3485 -- and for other transactions, it is starting job wip_id -- this is obvious.. comeon...
3486 --
3487
3488 IF l_txn_type_id = WSMPCNST.UPDATE_ROUTING THEN
3489 l_stmt_num := 190;
3490
3491 if l_job_kanban_card_id is not null then
3492
3493 l_sub_loc_change := handle_kanban_sub_loc_change( p_wip_entity_id => p_rj_job_rec.wip_entity_id,
3494 p_kanban_card_id => l_job_kanban_card_id,
3495 p_wssj_completion_subinventory => p_sj_compl_subinventory,
3496 p_wssj_completion_locator_id => p_sj_compl_locator_id,
3497 p_wsrj_completion_subinventory => p_rj_job_rec.completion_subinventory,
3498 p_wsrj_completion_locator_id => p_rj_job_rec.completion_locator_id,
3499 x_err_code => x_err_code,
3500 x_err_msg => x_err_buf
3501 );
3502
3503 IF (x_err_code <> 0) THEN
3504 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3505
3506 l_msg_tokens.delete;
3507 WSM_log_PVT.logMessage(p_module_name => l_module ,
3508 p_msg_text => 'Handle_kanban_sub_loc_change returned error: ' || x_err_buf,
3509 p_stmt_num => l_stmt_num ,
3510 p_msg_tokens => l_msg_tokens,
3511 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3512 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3513 p_run_log_level => l_log_level
3514 );
3515 END IF;
3516 RAISE FND_API.G_EXC_ERROR;
3517
3518 END IF;
3519
3520 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
3521 if l_sub_loc_change <> 0 then
3522 l_job_kanban_card_id := null;
3523 end if;
3524 end if;
3525
3526 UPDATE wip_discrete_jobs wdj
3527 SET routing_reference_id = p_rj_job_rec.routing_reference_id,
3528 alternate_routing_designator = p_rj_job_rec.alternate_routing_designator,
3529 common_routing_sequence_id = p_rj_job_rec.common_routing_sequence_id,
3530 routing_revision = p_rj_job_rec.routing_revision,
3531 routing_revision_date = p_rj_job_rec.routing_revision_date,
3532 completion_subinventory = p_rj_job_rec.completion_subinventory,
3533 completion_locator_id = p_rj_job_rec.completion_locator_id,
3534 kanban_card_id = l_job_kanban_card_id,
3535 -- ST : Fix for bug 5254137 : Update the BOM Info as well for Update Rtg as Bom data can be changed during upd rtg..
3536 --Bug 5491020:bom_reference_id is updated by p_rj_job_rec.bom_reference_id
3537 bom_reference_id = p_rj_job_rec.bom_reference_id, --routing_reference_id,
3538 alternate_bom_designator = p_rj_job_rec.alternate_bom_designator,
3539 common_bom_sequence_id = p_rj_job_rec.common_bom_sequence_id,
3540 bom_revision = p_rj_job_rec.bom_revision,
3541 bom_revision_date = p_rj_job_rec.bom_revision_date,
3542 -- ST : Fix for bug 5254137 end --
3543 last_update_date = sysdate,
3544 last_updated_by = g_user_id
3545 WHERE wdj.wip_entity_id = l_wip_entity_id;
3546
3547 --SpUA: add Split
3548 ELSIF l_txn_type_id IN (WSMPCNST.UPDATE_ASSEMBLY, WSMPCNST.SPLIT) THEN
3549
3550 l_stmt_num := 200;
3551
3552 -- abbKanban begin
3553 l_stmt_num := 203;
3554
3555
3556 if l_job_kanban_card_id is not null then
3557
3558 l_return_status := null;
3559
3560 INV_Kanban_PVT.Update_Card_Supply_Status(X_Return_Status => l_return_status,
3561 p_Kanban_Card_Id => l_job_kanban_card_id,
3562 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
3563 );
3564
3565 if ( l_return_status <> fnd_api.g_ret_sts_success ) then
3566 x_err_code := -1;
3567 fnd_message.set_name('WSM', 'WSM_KNBN_CARD_STS_FAIL');
3568
3569 fnd_message.set_token('STATUS',g_translated_meaning);
3570 x_err_buf := fnd_message.get;
3571
3572 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
3573
3574 l_msg_tokens.delete;
3575 l_msg_tokens(1).TokenName := 'STATUS';
3576 l_msg_tokens(1).TokenValue := g_translated_meaning;
3577 WSM_log_PVT.logMessage(p_module_name => l_module ,
3578 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
3579 p_msg_appl_name => 'WSM' ,
3580 p_msg_tokens => l_msg_tokens ,
3581 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3582 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3583 p_run_log_level => l_log_level
3584 );
3585 END IF;
3586 RAISE FND_API.G_EXC_ERROR;
3587
3588 end if;
3589
3590 l_job_kanban_card_id := null;
3591
3592 l_stmt_num := 207;
3593
3594 end if; -- kanban_card_id not null
3595
3596
3597 UPDATE wip_discrete_jobs wdj
3598 SET primary_item_id = p_rj_job_rec.primary_item_id,
3599 kanban_card_id = l_job_kanban_card_id,
3600 routing_reference_id = p_rj_job_rec.routing_reference_id,
3601 alternate_routing_designator = p_rj_job_rec.alternate_routing_designator,
3602 common_routing_sequence_id = p_rj_job_rec.common_routing_sequence_id,
3603 routing_revision = p_rj_job_rec.routing_revision,
3604 routing_revision_date = p_rj_job_rec.routing_revision_date,
3605 completion_subinventory = p_rj_job_rec.completion_subinventory,
3606 completion_locator_id = p_rj_job_rec.completion_locator_id,
3607 --Bug 5491020:bom_reference_id is updated by p_rj_job_rec.bom_reference_id
3608 bom_reference_id = p_rj_job_rec.bom_reference_id, --routing_reference_id,
3609 alternate_bom_designator = p_rj_job_rec.alternate_bom_designator,
3610 common_bom_sequence_id = p_rj_job_rec.common_bom_sequence_id,
3611 bom_revision = p_rj_job_rec.bom_revision,
3612 bom_revision_date = p_rj_job_rec.bom_revision_date,
3613 last_update_date = sysdate,
3614 last_updated_by = g_user_id
3615 WHERE wdj.wip_entity_id = l_wip_entity_id;
3616
3617 -- ST : Fix for bug 5122653 --
3618 -- Update the details in WIP_ENTITIES as well...
3619 UPDATE wip_entities
3620 SET primary_item_id = p_rj_job_rec.primary_item_id
3621 WHERE wip_entity_id = l_wip_entity_id;
3622 -- ST : Fix for bug 5122653 end --
3623
3624 END IF;
3625
3626 l_stmt_num := 210;
3627 CHANGE_ROUTING (p_txn_id => p_txn_id,
3628 p_wip_entity_id => l_wip_entity_id,
3629 p_org_id => l_org_id,
3630 p_rj_job_rec => p_rj_job_rec,
3631 p_new_op_added => l_new_op_added,
3632 x_err_code => x_err_code,
3633 x_err_buf => x_err_buf
3634 );
3635
3636 IF (x_err_code <> 0) THEN
3637 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3638
3639 l_msg_tokens.delete;
3640 WSM_log_PVT.logMessage(p_module_name => l_module ,
3641 p_msg_text => 'CHANGE_ROUTING returned error:'||x_err_buf,
3642 p_stmt_num => l_stmt_num ,
3643 p_msg_tokens => l_msg_tokens,
3644 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3645 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3646 p_run_log_level => l_log_level
3647 );
3648 END IF;
3649 RAISE FND_API.G_EXC_ERROR;
3650 ELSE
3651
3652 IF (l_new_op_added IS NOT NULL) THEN -- Added condition check for APS-WLT --
3653 if( g_log_level_statement >= l_log_level ) then
3654 l_msg_tokens.delete;
3655 WSM_log_PVT.logMessage(p_module_name => l_module ,
3656 p_msg_text => 'Added new operation sequence '||l_new_op_added||' to the job',
3657 p_stmt_num => l_stmt_num ,
3658 p_msg_tokens => l_msg_tokens,
3659 p_fnd_log_level => g_log_level_statement,
3660 p_run_log_level => l_log_level
3661 );
3662 End if;
3663 END IF;
3664 END IF;
3665
3666 l_stmt_num := 220;
3667 p_rj_job_rec.job_operation_seq_num := l_new_op_added;
3668
3669 BEGIN
3670 -- Obtain the op seq num...
3671 SELECT operation_seq_num
3672 into l_rtg_op_seq_num
3673 from bom_operation_sequences
3674 where operation_sequence_id = p_rj_job_rec.starting_operation_seq_id;
3675
3676 EXCEPTION
3677 WHEN NO_DATA_FOUND THEN
3678 l_rtg_op_seq_num := null;
3679 END;
3680
3681 -- Update the WSM_LOT_BASED_JOBS table...
3682 update wsm_lot_based_jobs
3683 set current_rtg_op_seq_num = l_rtg_op_seq_num,
3684 current_job_op_seq_num = l_new_op_added
3685 where wip_entity_id = l_wip_entity_id;
3686
3687 --osp
3688 IF (WSMPUTIL.check_osp_operation(p_wip_entity_id => l_wip_entity_id,
3689 p_operation_seq_num => l_new_op_added,
3690 p_organization_id => l_org_id))
3691 THEN
3692
3693 WSMPJUPD.g_osp_exists := 1;
3694
3695 if (l_po_creation_time <> WIP_CONSTANTS.MANUAL_CREATION) then
3696 --if l_request_id is null means online processing so launch import req
3697 -- (i.e) not from the Interface
3698 --Bug 5263262: During online processing l_request_id will be
3699 ---1.Hence check on -1 is also included in the if condition below.
3700 if (l_request_id is null or l_request_id = -1) then
3701 l_stmt_num := 223;
3702 wip_osp.create_requisition( P_Wip_Entity_Id => l_wip_entity_id,
3703 P_Organization_Id => l_org_id,
3704 P_Repetitive_Schedule_Id => null,
3705 P_Operation_Seq_Num => l_new_op_added,
3706 P_Resource_Seq_Num => null,
3707 P_Run_ReqImport => WIP_CONSTANTS.YES);
3708 else
3709 l_stmt_num := 227;
3710 wip_osp.create_requisition( P_Wip_Entity_Id => l_wip_entity_id,
3711 P_Organization_Id => l_org_id,
3712 P_Repetitive_Schedule_Id => null,
3713 P_Operation_Seq_Num => l_new_op_added,
3714 P_Resource_Seq_Num => null,
3715 P_Run_ReqImport => WIP_CONSTANTS.NO);
3716 end if;
3717 end if;
3718
3719 END IF;
3720 --WSMPUTIL.check_osp_operation
3721 --osp end
3722
3723 x_err_code := 0;
3724 x_err_buf := null;
3725
3726 EXCEPTION
3727 WHEN FND_API.G_EXC_ERROR THEN
3728 x_err_code := -1;
3729 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||x_err_buf;
3730 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
3731 p_count => x_msg_count ,
3732 p_data => x_err_buf
3733 );
3734
3735 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3736 x_err_code := -1;
3737 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||x_err_buf;
3738 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3739 p_count => x_msg_count ,
3740 p_data => x_err_buf
3741 );
3742 WHEN OTHERS THEN
3743 x_err_code := SQLCODE;
3744 x_err_buf := ' WSMPJUPD.UPDATE_ASSEMBLY_OR_ROUTING('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
3745
3746 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3747 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3748 THEN
3749 WSM_log_PVT.handle_others( p_module_name => l_module ,
3750 p_stmt_num => l_stmt_num ,
3751 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3752 p_run_log_level => l_log_level
3753 );
3754 END IF;
3755
3756 END UPDATE_ASSEMBLY_OR_ROUTING;
3757 /*EA SpUA*/
3758
3759
3760 Procedure Insert_MMT_record ( p_txn_id IN NUMBER,
3761 p_txn_org_id IN NUMBER,
3762 p_txn_date IN DATE,
3763 p_txn_type_id IN NUMBER,
3764 p_sj_wip_entity_id IN NUMBER,
3765 p_sj_wip_entity_name IN VARCHAR2,
3766 p_sj_avail_quantity IN NUMBER,
3767 p_rj_wip_entity_id IN NUMBER,
3768 p_rj_wip_entity_name IN VARCHAR2,
3769 p_rj_start_quantity IN NUMBER,
3770 p_sj_item_id IN number,
3771 p_sj_op_seq_num IN number,
3772 x_return_status OUT NOCOPY VARCHAR2,
3773 x_msg_count OUT NOCOPY NUMBER,
3774 x_msg_data OUT NOCOPY VARCHAR2
3775 ) is
3776
3777 l_wms_org mtl_parameters.wms_enabled_flag%type;
3778 l_def_cost_grp_id mtl_parameters.default_cost_group_id%type;
3779
3780 l_acct_period_id number;
3781
3782 l_err_code number;
3783 l_err_buf varchar2(2000);
3784
3785 -- Logging variables.....
3786 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3787 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3788
3789 l_stmt_num NUMBER;
3790 l_module VARCHAR2(100) := 'wsm.plsql.WSMJUPDB.Insert_MMT_record';
3791
3792
3793 begin
3794 l_stmt_num := 10;
3795 --Start additions to fix bug #2828376--
3796 SELECT wms_enabled_flag,
3797 default_cost_group_id
3798 INTO l_wms_org,
3799 l_def_cost_grp_id
3800 FROM mtl_parameters
3801 WHERE organization_id = p_txn_org_id;
3802 --End additions to fix bug #2828376--
3803
3804 l_stmt_num := 20;
3805 l_err_code := 0;
3806 l_err_buf := null;
3807
3808 l_acct_period_id := WSMPUTIL.GET_INV_ACCT_PERIOD(l_err_code,
3809 l_err_buf,
3810 p_txn_org_id,
3811 p_txn_date);
3812 --End NL BugFix 3126650
3813
3814 IF (l_err_code <> 0) THEN
3815 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
3816
3817 l_msg_tokens.delete;
3818 WSM_log_PVT.logMessage(p_module_name => l_module ,
3819 p_msg_text => 'WSMPUTIL.GET_INV_ACCT_PERIOD returned error:' || l_err_buf,
3820 p_stmt_num => l_stmt_num ,
3821 p_msg_tokens => l_msg_tokens,
3822 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3823 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3824 p_run_log_level => l_log_level
3825 );
3826 END IF;
3827 RAISE FND_API.G_EXC_ERROR;
3828 END IF;
3829
3830 l_stmt_num := 30;
3831
3832 INSERT INTO mtl_material_transactions
3833 (TRANSACTION_ID,
3834 LAST_UPDATE_DATE,
3835 LAST_UPDATED_BY,
3836 LAST_UPDATE_LOGIN,
3837 CREATION_DATE,
3838 CREATED_BY,
3839 REQUEST_ID,
3840 PROGRAM_APPLICATION_ID,
3841 PROGRAM_ID,
3842 PROGRAM_UPDATE_DATE,
3843 ORGANIZATION_ID,
3844 TRANSACTION_TYPE_ID,
3845 INVENTORY_ITEM_ID,
3846 TRANSACTION_ACTION_ID,
3847 TRANSACTION_SOURCE_TYPE_ID,
3848 TRANSACTION_SOURCE_ID,
3849 TRANSACTION_SOURCE_NAME,
3850 TRANSACTION_QUANTITY,
3851 PRIMARY_QUANTITY,
3852 TRANSACTION_UOM,
3853 TRANSACTION_DATE,
3854 SOURCE_LINE_ID,
3855 OPERATION_SEQ_NUM,
3856 ACCT_PERIOD_ID,
3857 COSTED_FLAG,
3858 COST_GROUP_ID --VJ: Added to fix bug #2828376
3859 )
3860 SELECT mtl_material_transactions_s.nextval,
3861 sysdate,
3862 g_USER_ID,
3863 g_user_LOGIN_ID,
3864 sysdate,
3865 g_USER_ID,
3866 g_REQUEST_ID,
3867 g_program_appl_id,
3868 g_PROGRAM_ID,
3869 sysdate,
3870 p_txn_org_id,
3871 MTT.transaction_type_id,
3872 -- Start : Changes as required by CST for SpUA --
3873 p_sj_item_id,
3874 -- End : Changes as required by CST for SpUA --
3875 decode(p_txn_type_id, WSMPCNST.SPLIT, 40,
3876 WSMPCNST.MERGE, 41,
3877 WSMPCNST.BONUS, 42,
3878 WSMPCNST.UPDATE_QUANTITY, 43,
3879 0),
3880 MTT.transaction_source_type_id,
3881 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_wip_entity_id, p_rj_wip_entity_id),
3882 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_wip_entity_name, p_rj_wip_entity_name),
3883 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_avail_quantity, p_rj_start_quantity),
3884 decode(p_txn_type_id, WSMPCNST.SPLIT, p_sj_avail_quantity, p_rj_start_quantity),
3885 MSI.primary_uom_code,
3886 p_txn_date,
3887 p_txn_id,
3888 p_sj_op_seq_num,
3889 OAP.acct_period_id,
3890 'N',
3891 decode(l_wms_org, 'Y', l_def_cost_grp_id, NULL) --VJ: Added to fix bug #2828376
3892 FROM mtl_system_items MSI,
3893 org_acct_periods OAP,
3894 mtl_transaction_types MTT
3895 -- Start : Changes as required by CST for SpUA --
3896 WHERE p_sj_item_id = MSI.inventory_item_id
3897 AND p_txn_org_id = MSI.organization_id
3898 -- End : Changes as required by CST for SpUA --
3899 AND p_txn_org_id = OAP.organization_id
3900 AND trunc(p_txn_date) between period_start_date and schedule_close_date
3901 -- Fixed bug #2828278
3902 -- Added trunc above: sch_close_date doesnt have timestamp so a problem for end of month
3903 AND MTT.transaction_action_id IN(decode(p_txn_type_id, WSMPCNST.SPLIT, 40,
3904 WSMPCNST.MERGE, 41,
3905 WSMPCNST.BONUS, 42,
3906 WSMPCNST.UPDATE_QUANTITY, 43,
3907 0)
3908 )
3909 AND MTT.transaction_source_type_id = 5;
3910
3911 --Start additions to fix bug #3048394--
3912 IF (SQL%ROWCOUNT <> 1) THEN
3913
3914 IF g_log_level_event >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_SUCCESS) then
3915
3916 l_msg_tokens.delete;
3917 l_msg_tokens(1).TokenName := 'ELEMENT';
3918 l_msg_tokens(1).TokenValue := 'mtl_material_transactions';
3919 WSM_log_PVT.logMessage(p_module_name => l_module ,
3920 p_msg_name => 'WSM_INS_TBL_FAILED',
3921 p_msg_appl_name => 'WSM' ,
3922 p_msg_tokens => l_msg_tokens ,
3923 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3924 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3925 p_run_log_level => l_log_level
3926 );
3927 END IF;
3928
3929 end if;
3930
3931 /* set the return status to succes... */
3932 x_return_status := fnd_api.g_ret_sts_success;
3933
3934 exception
3935 WHEN FND_API.G_EXC_ERROR THEN
3936
3937 x_return_status := G_RET_ERROR;
3938 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
3939 p_count => x_msg_count ,
3940 p_data => x_msg_data
3941 );
3942
3943 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3944
3945 x_return_status := G_RET_UNEXPECTED;
3946
3947 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
3948 p_count => x_msg_count ,
3949 p_data => x_msg_data
3950 );
3951 when others then
3952 /* handle it... */
3953 x_return_status := fnd_api.g_ret_sts_error;
3954 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) THEN
3955
3956 l_msg_tokens.delete;
3957 WSM_log_PVT.logMessage (p_module_name => l_module ,
3958 p_msg_text => SUBSTRB('Unexpected Error : SQLCODE '|| SQLCODE ||' : SQLERRM : '|| SQLERRM, 1, 2000),
3959 p_stmt_num => l_stmt_num ,
3960 p_msg_tokens => l_msg_tokens ,
3961 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3962 p_run_log_level => l_log_level
3963 );
3964
3965 END IF;
3966
3967 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3968 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3969 THEN
3970 WSM_log_PVT.handle_others( p_module_name => l_module ,
3971 p_stmt_num => l_stmt_num ,
3972 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3973 p_run_log_level => l_log_level
3974 );
3975 END IF;
3976
3977 end;
3978
3979 /* have to work on this procedure.... */
3980
3981 /*------------------------------------------------------------------+
3982 | Name : CREATE_COPIES_OR_SET_COPY_DATA |
3983 | This procedure is called from the form and interface |
3984 | NOT a private procedure |
3985 -------------------------------------------------------------------*/
3986
3987 PROCEDURE CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id IN NUMBER,
3988 p_txn_type_id IN NUMBER,
3989 p_copy_mode IN NUMBER,
3990 p_rep_sj_index IN NUMBER,
3991 p_sj_as_rj_index IN NUMBER,
3992 p_wltx_starting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
3993 p_wltx_resulting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
3994 x_err_code OUT NOCOPY NUMBER,
3995 x_err_buf OUT NOCOPY VARCHAR2,
3996 x_msg_count OUT NOCOPY NUMBER)
3997 IS
3998 l_res_rtg_item_id NUMBER; -- Fix for bug #3347947
3999 l_res_bill_item_id NUMBER; -- Fix for bug #3347947
4000
4001 l_res_bill_seq_id NUMBER; -- Fix for bug #3286849
4002
4003 l_new_job_int_copy_type NUMBER;
4004 l_rep_job_par_we_id NUMBER;
4005
4006 l_rj_counter NUMBER;
4007 l_sj_counter NUMBER;
4008 l_rep_wip_entity_id NUMBER;
4009
4010 -- Logging variables.....
4011 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4012 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4013
4014 l_stmt_num NUMBER;
4015 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPDB.CREATE_COPIES_OR_SET_COPY_DATA';
4016 -- Logging variables...
4017 l_phantom_exists NUMBER;
4018 BEGIN
4019
4020 l_stmt_num := 10;
4021
4022 -- IF (g_debug = 'Y') THEN
4023 -- fnd_file.put_line(fnd_file.log, 'In CREATE_COPIES_OR_SET_COPY_DATA '||
4024 -- 'for p_txn_id='||p_txn_id||
4025 -- ' p_txn_type_id='||p_txn_type_id||
4026 -- ' p_copy_mode='||p_copy_mode);
4027 -- END IF;
4028
4029
4030 IF (p_txn_type_id IN (WSMPCNST.BONUS,
4031 WSMPCNST.UPDATE_ASSEMBLY, WSMPCNST.UPDATE_ROUTING)) THEN
4032
4033 l_stmt_num := 11;
4034
4035 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4036
4037 l_stmt_num := 20;
4038
4039 l_rj_counter := p_wltx_resulting_jobs_tbl.first;
4040
4041 if p_wltx_resulting_jobs_tbl(l_rj_counter).job_type = WIP_CONSTANTS.STANDARD then
4042 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id;
4043 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id;
4044 else
4045 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).routing_reference_id;
4046 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_rj_counter).bom_reference_id;
4047 end if;
4048
4049
4050 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id);
4051 --OPTII-PERF:Find if phantom exists or not.
4052 BEGIN
4053 select 1 into l_phantom_exists
4054 from bom_inventory_components
4055 where bill_sequence_id = p_wltx_resulting_jobs_tbl(l_rj_counter).common_bom_sequence_id
4056 and p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date between effectivity_date and
4057 nvl(disable_date,p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date+1)
4058 and wip_supply_type = 6
4059 and rownum = 1;
4060
4061 l_phantom_exists := 1;
4062 EXCEPTION
4063 WHEN OTHERS THEN
4064 l_phantom_exists := 2;
4065 END;
4066
4067 -- related bugs : 3348704, 3347947 , 3286849 , 3303267
4068 WSM_JobCopies_PVT.Create_JobCopies -- Call #1
4069 (x_err_buf => x_err_buf,
4070 x_err_code => x_err_code,
4071 p_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id,
4072 p_org_id => p_wltx_resulting_jobs_tbl(l_rj_counter).organization_id,
4073 p_primary_item_id => p_wltx_resulting_jobs_tbl(l_rj_counter).primary_item_id,
4074 p_routing_item_id => l_res_rtg_item_id,-- Fix for bug #3347947
4075 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(l_rj_counter).alternate_routing_designator,-- Fix for bug #3347947
4076 p_rtg_seq_id => NULL, -- Will be NULL till reqd for some functionality
4077 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(l_rj_counter).common_routing_sequence_id,
4078 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(l_rj_counter).routing_revision_date,
4079 p_bill_item_id => l_res_bill_item_id, -- Fix for bug #3347947
4080 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(l_rj_counter).alternate_bom_designator,
4081 p_bill_seq_id => l_res_bill_seq_id, -- Fix for bug #3286849
4082 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(l_rj_counter).common_bom_sequence_id,
4083 p_bom_rev_date => p_wltx_resulting_jobs_tbl(l_rj_counter).bom_revision_date,
4084 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_rj_counter).wip_supply_type,
4085 p_last_update_date => sysdate,
4086 p_last_updated_by => g_USER_ID,
4087 p_last_update_login => g_user_LOGIN_ID,
4088 p_creation_date => sysdate,
4089 p_created_by => g_USER_ID,
4090 p_request_id => g_REQUEST_ID,
4091 p_program_app_id => g_program_appl_id,
4092 p_program_id => g_PROGRAM_ID,
4093 p_program_update_date => sysdate,
4094 p_inf_sch_flag => 'Y',
4095 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4096 p_inf_sch_date => NULL, --Bug #3348704 l_inf_sch_date
4097 --OPTII-PERF:Following parameters are added
4098 p_charges_exist => 1,
4099 p_phantom_exists => l_phantom_exists
4100 );
4101
4102
4103 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4104 -- IF (x_err_code <> 0) THEN
4105 IF (x_err_code = 0) OR
4106 (x_err_code IS NULL) OR -- No error
4107 (x_err_code = -1) -- Warning
4108 THEN
4109 x_err_code := 0; -- Fix for bug #3421662 --
4110 ELSE
4111 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4112 l_msg_tokens.delete;
4113 WSM_log_PVT.logMessage(p_module_name => l_module ,
4114 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4115 p_stmt_num => l_stmt_num ,
4116 p_msg_tokens => l_msg_tokens,
4117 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4118 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4119 p_run_log_level => l_log_level
4120 );
4121 END IF;
4122 RAISE FND_API.G_EXC_ERROR;
4123 END IF;
4124
4125 if( g_log_level_statement >= l_log_level ) then
4126 l_msg_tokens.delete;
4127 WSM_log_PVT.logMessage(p_module_name => l_module ,
4128 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4129 p_stmt_num => l_stmt_num ,
4130 p_msg_tokens => l_msg_tokens,
4131 p_fnd_log_level => g_log_level_statement,
4132 p_run_log_level => l_log_level
4133 );
4134 End if;
4135
4136 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4137 l_stmt_num := 30;
4138
4139 UPDATE wsm_lot_based_jobs
4140 SET internal_copy_type = 2
4141 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_counter).wip_entity_id;
4142
4143 if( g_log_level_statement >= l_log_level ) then
4144 l_msg_tokens.delete;
4145 WSM_log_PVT.logMessage(p_module_name => l_module ,
4146 p_msg_text => 'Set internal_copy_type = 2 for we_id=',
4147 p_stmt_num => l_stmt_num ,
4148 p_msg_tokens => l_msg_tokens,
4149 p_fnd_log_level => g_log_level_statement,
4150 p_run_log_level => l_log_level
4151 );
4152 End if;
4153
4154 END IF; --(p_copy_mode)
4155
4156 ELSIF (p_txn_type_id IN (WSMPCNST.SPLIT, WSMPCNST.MERGE)) THEN
4157
4158 l_stmt_num := 40;
4159
4160 l_rep_wip_entity_id := p_wltx_starting_jobs_tbl(p_rep_sj_index).wip_entity_id;
4161
4162 -- for interface copy purpose....
4163 SELECT nvl(internal_copy_type, 0),
4164 copy_parent_wip_entity_id
4165 INTO l_new_job_int_copy_type,
4166 l_rep_job_par_we_id
4167 FROM wsm_lot_based_jobs
4168 WHERE wip_entity_id = l_rep_wip_entity_id;
4169 -- for interface copy purpose.... end
4170
4171 IF (l_new_job_int_copy_type < 1) THEN
4172 l_new_job_int_copy_type := 1;
4173 END IF;
4174
4175 l_stmt_num := 50;
4176
4177 for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
4178
4179 l_stmt_num := 55;
4180
4181 if p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id <> l_rep_wip_entity_id then
4182
4183 l_stmt_num := 58;
4184
4185 -- ST : Bug fix 5092009
4186 -- Adding NVL as for Merge it can be NULL
4187 IF (nvl(p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy,0) = 0) THEN -- No assembly change
4188
4189 l_stmt_num := 59;
4190
4191 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4192 l_stmt_num := 60;
4193
4194 if( g_log_level_statement >= l_log_level ) then
4195 l_msg_tokens.delete;
4196 WSM_log_PVT.logMessage(p_module_name => l_module ,
4197 p_msg_text => 'new we_id :'||p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id||
4198 'rep_job_we_id :'||l_rep_wip_entity_id,
4199 p_stmt_num => l_stmt_num ,
4200 p_msg_tokens => l_msg_tokens,
4201 p_fnd_log_level => g_log_level_statement,
4202 p_run_log_level => l_log_level
4203 );
4204 End if;
4205
4206 WSM_JobCopies_PVT.Create_RepJobCopies
4207 (x_err_buf => x_err_buf,
4208 x_err_code => x_err_code,
4209 p_rep_wip_entity_id => l_rep_wip_entity_id,
4210 p_new_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
4211 p_last_update_date => sysdate,
4212 p_last_updated_by => g_USER_ID,
4213 p_last_update_login => g_user_LOGIN_ID,
4214 p_creation_date => sysdate,
4215 p_created_by => g_USER_ID,
4216 p_request_id => g_REQUEST_ID,
4217 p_program_app_id => g_program_appl_id,
4218 p_program_id => g_PROGRAM_ID,
4219 p_program_update_date => sysdate,
4220 p_inf_sch_flag => 'Y',
4221 p_inf_sch_mode => NULL,
4222 p_inf_sch_date => NULL
4223 );
4224
4225 IF (x_err_code <> 0) THEN
4226 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4227
4228 l_msg_tokens.delete;
4229 WSM_log_PVT.logMessage(p_module_name => l_module ,
4230 p_msg_text => 'WSM_JobCopies_PVT.Create_RepJobCopies returned error:' || x_err_buf,
4231 p_stmt_num => l_stmt_num ,
4232 p_msg_tokens => l_msg_tokens,
4233 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4234 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4235 p_run_log_level => l_log_level
4236 );
4237 END IF;
4238 RAISE FND_API.G_EXC_ERROR;
4239 END IF;
4240
4241 l_stmt_num := 70;
4242
4243 if( g_log_level_statement >= l_log_level ) then
4244 l_msg_tokens.delete;
4245 WSM_log_PVT.logMessage(p_module_name => l_module ,
4246 p_msg_text => 'WSM_JobCopies_PVT.Create_RepJobCopies returned success',
4247 p_stmt_num => l_stmt_num ,
4248 p_msg_tokens => l_msg_tokens,
4249 p_fnd_log_level => g_log_level_statement,
4250 p_run_log_level => l_log_level
4251 );
4252 End if;
4253
4254 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4255
4256 l_stmt_num := 80;
4257
4258 UPDATE wsm_lot_based_jobs
4259 SET internal_copy_type = l_new_job_int_copy_type
4260 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4261
4262 if( g_log_level_statement >= l_log_level ) then
4263 l_msg_tokens.delete;
4264 WSM_log_PVT.logMessage(p_module_name => l_module ,
4265 p_msg_text => 'Set internal_copy_type = '||l_new_job_int_copy_type||' for we_id=',
4266 p_stmt_num => l_stmt_num ,
4267 p_msg_tokens => l_msg_tokens,
4268 p_fnd_log_level => g_log_level_statement,
4269 p_run_log_level => l_log_level
4270 );
4271 End if;
4272
4273 IF (l_new_job_int_copy_type = 1) THEN -- If current job's copy_type = 1
4274
4275 l_stmt_num := 100;
4276
4277 UPDATE wsm_lot_based_jobs
4278 SET copy_parent_wip_entity_id = nvl(l_rep_job_par_we_id, l_rep_wip_entity_id)
4279 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4280
4281 if( g_log_level_statement >= l_log_level ) then
4282 l_msg_tokens.delete;
4283 WSM_log_PVT.logMessage(p_module_name => l_module ,
4284 p_msg_text => 'Set copy_parent_wip_entity_id = '||nvl(l_rep_job_par_we_id, l_rep_wip_entity_id)||' for we_id=',
4285 p_stmt_num => l_stmt_num ,
4286 p_msg_tokens => l_msg_tokens,
4287 p_fnd_log_level => g_log_level_statement,
4288 p_run_log_level => l_log_level
4289 );
4290 End if;
4291
4292 END IF;
4293
4294 END IF; --(p_copy_mode)
4295
4296 ELSIF (p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy = 1) THEN -- Assembly has changed
4297
4298 l_stmt_num := 108;
4299
4300 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4301 l_stmt_num := 110;
4302
4303 if p_wltx_resulting_jobs_tbl(l_job_counter).job_type = WIP_CONSTANTS.STANDARD then
4304 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id;
4305 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id;
4306 else
4307 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id;
4308 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id;
4309 end if;
4310
4311 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id);
4312 --OPTII-PERF
4313 BEGIN
4314 select 1 into l_phantom_exists
4315 from bom_inventory_components
4316 where bill_sequence_id = p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id
4317 and p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date between effectivity_date and
4318 nvl(disable_date,p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date+1)
4319 and wip_supply_type = 6
4320 and rownum = 1;
4321
4322 l_phantom_exists := 1;
4323 EXCEPTION
4324 WHEN OTHERS THEN
4325 l_phantom_exists := 2;
4326 END;
4327
4328 WSM_JobCopies_PVT.Create_JobCopies -- Call #2
4329 (x_err_buf => x_err_buf,
4330 x_err_code => x_err_code,
4331 p_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
4332 p_org_id => p_wltx_resulting_jobs_tbl(l_job_counter).organization_id,
4333 p_primary_item_id => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
4334
4335 p_routing_item_id => l_res_rtg_item_id,-- Fix for bug #3347947
4336 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,-- Fix for bug #3347947
4337 p_rtg_seq_id => NULL, -- Will be NULL till reqd for some functionality
4338 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
4339 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
4340 p_bill_item_id => l_res_bill_item_id, -- Fix for bug #3347947
4341 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
4342 p_bill_seq_id => l_res_bill_seq_id,-- Fix for bug #3286849
4343 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
4344 p_bom_rev_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
4345 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
4346 p_last_update_date => sysdate,
4347 p_last_updated_by => g_USER_ID,
4348 p_last_update_login => g_user_LOGIN_ID,
4349 p_creation_date => sysdate,
4350 p_created_by => g_USER_ID,
4351 p_request_id => g_REQUEST_ID,
4352 p_program_app_id => g_program_appl_id,
4353 p_program_id => g_PROGRAM_ID,
4354 p_program_update_date => sysdate,
4355 p_inf_sch_flag => 'Y',
4356 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4357 p_inf_sch_date => NULL, --Bug #3348704 c_sm_new_jobs_rec.inf_sch_date
4358 --OPTII-PERF:Following parameters are added
4359 p_charges_exist => 1,
4360 p_phantom_exists => l_phantom_exists
4361 );
4362
4363 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4364 -- IF (x_err_code <> 0) THEN
4365 IF (x_err_code = 0) OR
4366 (x_err_code IS NULL) OR -- No error
4367 (x_err_code = -1) -- Warning
4368 THEN
4369 x_err_code := 0; -- Fix for bug #3421662 --
4370 ELSE
4371 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4372
4373 l_msg_tokens.delete;
4374 WSM_log_PVT.logMessage(p_module_name => l_module ,
4375 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4376 p_stmt_num => l_stmt_num ,
4377 p_msg_tokens => l_msg_tokens,
4378 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4379 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4380 p_run_log_level => l_log_level
4381 );
4382 END IF;
4383 RAISE FND_API.G_EXC_ERROR;
4384 END IF;
4385
4386 if( g_log_level_statement >= l_log_level ) then
4387 l_msg_tokens.delete;
4388 WSM_log_PVT.logMessage(p_module_name => l_module ,
4389 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4390 p_stmt_num => l_stmt_num ,
4391 p_msg_tokens => l_msg_tokens,
4392 p_fnd_log_level => g_log_level_statement,
4393 p_run_log_level => l_log_level
4394 );
4395 End if;
4396
4397 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4398
4399 l_stmt_num := 120;
4400
4401 UPDATE wsm_lot_based_jobs
4402 SET internal_copy_type = 2
4403 WHERE wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
4404
4405 if( g_log_level_statement >= l_log_level ) then
4406 l_msg_tokens.delete;
4407 WSM_log_PVT.logMessage(p_module_name => l_module ,
4408 p_msg_text => 'Set internal_copy_type = 2 for we_id=',
4409 p_stmt_num => l_stmt_num ,
4410 p_msg_tokens => l_msg_tokens,
4411 p_fnd_log_level => g_log_level_statement,
4412 p_run_log_level => l_log_level
4413 );
4414 End if;
4415
4416 END IF; --(p_copy_mode)
4417
4418 END IF;
4419 end if; -- check if not a starting job...
4420
4421 END LOOP;
4422
4423 IF (p_txn_type_id = WSMPCNST.SPLIT) THEN
4424
4425 l_stmt_num := 130;
4426
4427 if p_sj_as_rj_index is not null then
4428 l_stmt_num := 135;
4429
4430 IF (p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).split_has_update_assy = 1) THEN
4431
4432 l_stmt_num := 138;
4433
4434 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4435 l_stmt_num := 140;
4436
4437 if p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).job_type = WIP_CONSTANTS.STANDARD then
4438 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id;
4439 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id;
4440 else
4441 l_res_rtg_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).routing_reference_id;
4442 l_res_bill_item_id := p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_reference_id;
4443 end if;
4444
4445 l_res_bill_seq_id := WSMPUTIL.GET_JOB_BOM_SEQ_ID(p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).wip_entity_id);
4446 --OPTII-PERF:Find l_phantom_exists
4447 BEGIN
4448 select 1 into l_phantom_exists
4449 from bom_inventory_components
4450 where bill_sequence_id = p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_bom_sequence_id
4451 and p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date between effectivity_date and
4452 nvl(disable_date,p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date+1)
4453 and wip_supply_type = 6
4454 and rownum = 1;
4455
4456 l_phantom_exists := 1;
4457 EXCEPTION
4458 WHEN OTHERS THEN
4459 l_phantom_exists := 2;
4460 end;
4461 WSM_JobCopies_PVT.Create_JobCopies -- Call #3
4462 (x_err_buf => x_err_buf,
4463 x_err_code => x_err_code,
4464 p_wip_entity_id => l_rep_wip_entity_id,
4465 p_org_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).organization_id,
4466 p_primary_item_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).primary_item_id,
4467 p_routing_item_id => l_res_rtg_item_id, -- Fix bug #3347947
4468 p_alt_rtg_desig => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).alternate_routing_designator, -- Fix bug #3347947
4469 p_rtg_seq_id => NULL,-- Will be NULL till reqd for some functionality
4470 p_common_rtg_seq_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_routing_sequence_id,
4471 p_rtg_rev_date => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).routing_revision_date,
4472 p_bill_item_id => l_res_bill_item_id, -- Fix bug #3347947
4473 p_alt_bom_desig => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).alternate_bom_designator,
4474 p_bill_seq_id => l_res_bill_seq_id, -- Fix bug #3347947
4475 p_common_bill_seq_id => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).common_bom_sequence_id,
4476 p_bom_rev_date => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).bom_revision_date,
4477 p_wip_supply_type => p_wltx_resulting_jobs_tbl(p_sj_as_rj_index).wip_supply_type,
4478 p_last_update_date => sysdate,
4479 p_last_updated_by => g_USER_ID,
4480 p_last_update_login => g_user_LOGIN_ID,
4481 p_creation_date => sysdate,
4482 p_created_by => g_USER_ID,
4483 p_request_id => g_REQUEST_ID,
4484 p_program_app_id => g_program_appl_id,
4485 p_program_id => g_PROGRAM_ID,
4486 p_program_update_date => sysdate,
4487 p_inf_sch_flag => 'Y',
4488 p_inf_sch_mode => NULL, -- Create_JobCopies to figure out
4489 p_inf_sch_date => NULL, --Bug #3348704 l_inf_sch_date
4490 --OPTII-PERF:Following parameters are added
4491 p_charges_exist => 1,
4492 p_phantom_exists => l_phantom_exists
4493 );
4494
4495 -- Fixed bug #3303267 : Checked the return value based on changed error codes
4496 -- IF (x_err_code <> 0) THEN
4497 IF (x_err_code = 0) OR
4498 (x_err_code IS NULL) OR -- No error
4499 (x_err_code = -1) -- Warning
4500 THEN
4501 x_err_code := 0; -- Fix for bug #3421662 --
4502 ELSE
4503 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4504
4505 l_msg_tokens.delete;
4506 WSM_log_PVT.logMessage(p_module_name => l_module ,
4507 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned error:' || x_err_buf,
4508 p_stmt_num => l_stmt_num ,
4509 p_msg_tokens => l_msg_tokens,
4510 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4511 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4512 p_run_log_level => l_log_level
4513 );
4514 END IF;
4515 RAISE FND_API.G_EXC_ERROR;
4516 END IF;
4517
4518 if( g_log_level_statement >= l_log_level ) then
4519 l_msg_tokens.delete;
4520 WSM_log_PVT.logMessage(p_module_name => l_module ,
4521 p_msg_text => 'WSM_JobCopies_PVT.Create_JobCopies returned success',
4522 p_stmt_num => l_stmt_num ,
4523 p_msg_tokens => l_msg_tokens,
4524 p_fnd_log_level => g_log_level_statement,
4525 p_run_log_level => l_log_level
4526 );
4527 End if;
4528
4529 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4530 l_stmt_num := 150;
4531
4532 UPDATE wsm_lot_based_jobs
4533 SET internal_copy_type = 2
4534 WHERE wip_entity_id = l_rep_wip_entity_id;
4535
4536 if( g_log_level_statement >= l_log_level ) then
4537 l_msg_tokens.delete;
4538 WSM_log_PVT.logMessage(p_module_name => l_module ,
4539 p_msg_text => 'Set internal_copy_type = 2 for we_id='||l_rep_wip_entity_id,
4540 p_stmt_num => l_stmt_num ,
4541 p_msg_tokens => l_msg_tokens,
4542 p_fnd_log_level => g_log_level_statement,
4543 p_run_log_level => l_log_level
4544 );
4545 End if;
4546
4547 END IF; --(p_copy_mode)
4548
4549 END IF;
4550
4551 end if;
4552
4553 END IF;
4554
4555 END IF; --(p_txn_type_id)
4556
4557 l_stmt_num := 160;
4558 x_err_code := 0;
4559
4560 EXCEPTION
4561 WHEN FND_API.G_EXC_ERROR THEN
4562 x_err_code := SQLCODE;
4563 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||x_err_buf;
4564
4565 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
4566 p_count => x_msg_count ,
4567 p_data => x_err_buf
4568 );
4569
4570 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4571
4572 x_err_code := SQLCODE;
4573 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||x_err_buf;
4574
4575 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
4576 p_count => x_msg_count ,
4577 p_data => x_err_buf
4578 );
4579
4580
4581 WHEN OTHERS THEN
4582 x_err_code := SQLCODE;
4583 x_err_buf := ' WSMPJUPD.CREATE_COPIES_OR_SET_COPY_DATA('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
4584
4585 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4586 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4587 THEN
4588 WSM_log_PVT.handle_others( p_module_name => l_module ,
4589 p_stmt_num => l_stmt_num ,
4590 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4591 p_run_log_level => l_log_level
4592 );
4593 END IF;
4594
4595 END CREATE_COPIES_OR_SET_COPY_DATA;
4596 /* have to work on this procedure..... */
4597
4598
4599 /*-----------------------------------------------------------------+
4600 | Name : CALL_INF_SCH_OR_SET_SCH_DATA
4601 | This procedure calls the Infinite Scheduler
4602 | or sets data in wsm_lot_based_jobs table the Inf.Scheduler
4603 -------------------------------------------------------------------*/
4604
4605 PROCEDURE CALL_INF_SCH_OR_SET_SCH_DATA (p_txn_id IN NUMBER,
4606 p_copy_mode IN NUMBER,
4607 p_org_id IN NUMBER,
4608 p_par_we_id IN NUMBER,
4609 x_err_code OUT NOCOPY NUMBER,
4610 x_err_buf OUT NOCOPY VARCHAR2)
4611 IS
4612 l_schedule_mode NUMBER;
4613
4614 l_job_op_seq_num NUMBER;
4615 l_job_op_seq_id NUMBER;
4616 l_job_std_op_id NUMBER;
4617 l_job_intra_op NUMBER;
4618 l_job_dept_id NUMBER;
4619 l_job_qty NUMBER;
4620 l_job_op_start_dt DATE;
4621 l_job_op_comp_dt DATE;
4622 l_returnStatus VARCHAR2(1);
4623 x_msg_count number;
4624 -- Logging variables.....
4625 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4626 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4627
4628 l_stmt_num NUMBER;
4629 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPDB.CALL_INF_SCH_OR_SET_SCH_DATA';
4630 -- Logging variables...
4631
4632 BEGIN
4633
4634 l_stmt_num := 10;
4635
4636 -- ST : Fix for bug 5181364
4637 -- Changed the scheduling path to forwards scheduling instead of midpoint forward
4638 SELECT decode(on_rec_path, 'Y', WIP_CONSTANTS.FORWARDS, WIP_CONSTANTS.CURRENT_OP)
4639 INTO l_schedule_mode
4640 FROM WSM_LOT_BASED_JOBS
4641 WHERE wip_entity_id = p_par_we_id;
4642
4643 l_stmt_num := 30;
4644
4645 GET_JOB_CURR_OP_INFO(p_wip_entity_id => p_par_we_id,
4646 p_op_seq_num => l_job_op_seq_num,
4647 p_op_seq_id => l_job_op_seq_id,
4648 p_std_op_id => l_job_std_op_id,
4649 p_intra_op => l_job_intra_op,
4650 p_dept_id => l_job_dept_id,
4651 p_op_qty => l_job_qty,
4652 p_op_start_date => l_job_op_start_dt,
4653 p_op_completion_date => l_job_op_comp_dt,
4654 x_err_code => x_err_code,
4655 x_err_buf => x_err_buf,
4656 x_msg_count => x_msg_count
4657 );
4658
4659 IF (x_err_code <> 0) THEN
4660 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4661 l_msg_tokens.delete;
4662 WSM_log_PVT.logMessage(p_module_name => l_module ,
4663 p_msg_text => 'GET_JOB_CURR_OP_INFO returned error:' || x_err_buf,
4664 p_stmt_num => l_stmt_num ,
4665 p_msg_tokens => l_msg_tokens,
4666 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4667 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4668 p_run_log_level => l_log_level
4669 );
4670 END IF;
4671 RAISE FND_API.G_EXC_ERROR;
4672 END IF;
4673
4674 l_stmt_num := 40;
4675
4676 IF (p_copy_mode = 1) THEN -- Make copies after each transaction
4677
4678 l_stmt_num := 50;
4679
4680 WSM_infinite_scheduler_PVT.schedule
4681 (
4682 p_initMsgList => FND_API.g_true,
4683 p_endDebug => FND_API.g_true,
4684 p_orgID => p_org_id,
4685 p_wipEntityID => p_par_we_id,
4686 p_scheduleMode => l_schedule_mode,
4687 p_startDate => l_job_op_start_dt,
4688 p_endDate => NULL,
4689 p_opSeqNum => 0-l_job_op_seq_num,
4690 p_resSeqNum => NULL,
4691 x_returnStatus => l_returnStatus,
4692 x_errorMsg => x_err_buf
4693 );
4694
4695 IF(l_returnStatus <> FND_API.G_RET_STS_SUCCESS) THEN
4696 x_err_code := -1;
4697 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
4698 l_msg_tokens.delete;
4699 WSM_log_PVT.logMessage(p_module_name => l_module ,
4700 p_msg_text => 'WSM_infinite_scheduler_PVT.schedule returned error:' || x_err_buf,
4701 p_stmt_num => l_stmt_num ,
4702 p_msg_tokens => l_msg_tokens,
4703 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4704 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4705 p_run_log_level => l_log_level
4706 );
4707 END IF;
4708 RAISE FND_API.G_EXC_ERROR;
4709 ELSE
4710 x_err_code := 0;
4711 END IF;
4712
4713 ELSIF (p_copy_mode = 2) THEN -- Make copies at end (for interface ONLY)
4714
4715 l_stmt_num := 60;
4716
4717 UPDATE wsm_lot_based_jobs
4718 SET infinite_schedule = 'Y'
4719 WHERE wip_entity_id = p_par_we_id;
4720
4721 END IF; --p_copy_mode
4722
4723 l_stmt_num := 70;
4724
4725 EXCEPTION
4726 WHEN FND_API.G_EXC_ERROR THEN
4727
4728 x_err_code := SQLCODE;
4729 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||x_err_buf;
4730 /*
4731 FND_MSG_PUB.Count_And_Get (p_encoded => 'F',
4732 p_count => x_msg_count ,
4733 p_data => x_err_buf
4734 );
4735 */
4736 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4737
4738 x_err_code := SQLCODE;
4739 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||x_err_buf;
4740 /*
4741 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F',
4742 p_count => x_msg_count ,
4743 p_data => x_err_buf
4744 );
4745 */
4746 WHEN OTHERS THEN
4747 x_err_code := SQLCODE;
4748 x_err_buf := ' WSMPJUPD.CALL_INF_SCH_OR_SET_SCH_DATA('||l_stmt_num||'): '||substrb(sqlerrm,1,1000);
4749
4750 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4751 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4752 THEN
4753 WSM_log_PVT.handle_others( p_module_name => l_module ,
4754 p_stmt_num => l_stmt_num ,
4755 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4756 p_run_log_level => l_log_level
4757 );
4758 END IF;
4759
4760 END CALL_INF_SCH_OR_SET_SCH_DATA;
4761 /* end..... */
4762
4763 PROCEDURE PROCESS_LOTS (p_copy_qa IN VARCHAR2,
4764 p_txn_org_id IN NUMBER,
4765 p_rep_job_index IN NUMBER,
4766 p_wltx_header IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_TRANSACTIONS_REC_TYPE,
4767 p_wltx_starting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
4768 p_wltx_resulting_jobs_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
4769 p_secondary_qty_tbl IN OUT NOCOPY WSM_WIP_LOT_TXN_PVT.WSM_JOB_SECONDARY_QTY_TBL_TYPE ,
4770 -- p_txn_id OUT NOCOPY NUMBER, /* i dont think this is needed,,,, */
4771 x_return_status OUT NOCOPY VARCHAR2,
4772 x_msg_count OUT NOCOPY NUMBER,
4773 x_error_msg OUT NOCOPY VARCHAR2
4774 ) is
4775
4776 l_new_rj_we_id_tbl t_number;
4777 l_new_rj_qty_tbl t_number;
4778
4779 l_sj_we_id_tbl t_number;
4780 l_sj_old_st_qty_tbl t_number;
4781 l_sj_new_qty_tbl t_number;
4782 l_sj_new_net_qty_tbl t_number;
4783 l_sj_op_seq_tbl t_number;
4784 l_sj_scrap_qty_tbl t_number;
4785 l_sj_avail_qty_tbl t_number;
4786
4787 l_job_intraop_step number;
4788
4789 l_rep_new_qty number;
4790 l_non_rep_sj_tbl t_number; -- table to store the wip_entity_id of the non-rep starting jobs...
4791
4792 l_sj_also_rj_index number;
4793 l_rep_sj_index number;
4794 l_rj_index number;
4795 l_bonus_job_st_op_seq number;
4796 l_bonus_rtg_st_op_seq number;
4797 l_acct_period_id number;
4798
4799 l_profile_value number;
4800 l_po_creation_time wip_parameters.po_creation_time%type;
4801
4802 --MES columns
4803 l_current_rtg_op_seq_num number;
4804 l_current_job_op_seq_num number;
4805 --End MES columns
4806
4807 --SO LBJ Rsvn add
4808 l_rsv_exists boolean;
4809 --End SO LBJ Rsvn add
4810
4811 l_err_code number;
4812 l_err_buf varchar2(2000);
4813
4814 l_txn_status number;
4815 l_txn_costed number;
4816
4817 l_rj_kanban_card_id number;
4818 l_po_request_id number;
4819
4820 l_new_we_id number;
4821 l_sub_loc_change number;
4822 l_ret_status varchar2(1);
4823 l_new_name wip_entities.wip_entity_name%type;
4824 l_dup_job_name wip_entities.wip_entity_name%type;
4825
4826 l_job_counter NUMBER;
4827
4828 l_sj_gen_object_id wip_entities.gen_object_id%type;
4829 l_rj_gen_object_id wip_entities.gen_object_id%type;
4830
4831 l_kanban_card_id wip_discrete_jobs.kanban_card_id%type;
4832
4833 l_msg_count number;
4834 l_msg_data varchar2(2000);
4835
4836 /*logging variables*/
4837 l_stmt_num number := 0;
4838 l_msg_tokens WSM_log_PVT.token_rec_tbl;
4839 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4840 l_module VARCHAR2(100) := 'wsm.plsql.WSMPJUPD.process_lots';
4841
4842
4843 BEGIN
4844
4845 l_stmt_num := 10;
4846 g_user_id := FND_GLOBAL.USER_ID;
4847 g_user_login_id := FND_GLOBAL.LOGIN_ID;
4848 g_program_appl_id := FND_GLOBAL.PROG_APPL_ID;
4849 g_request_id := FND_GLOBAL.CONC_REQUEST_ID;
4850 g_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
4851
4852 x_return_status := g_ret_success;
4853
4854 if( g_log_level_statement >= l_log_level ) then
4855 -- Log the transaction data...
4856 WSM_WIP_LOT_TXN_PVT.Log_transaction_data ( p_txn_header_rec => p_wltx_header ,
4857 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl ,
4858 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl ,
4859 p_secondary_qty_tbl => p_secondary_qty_tbl ,
4860 x_return_status => x_return_status ,
4861 x_msg_count => x_msg_count ,
4862 x_error_msg => x_error_msg
4863 );
4864
4865 if x_return_status <> G_RET_SUCCESS then
4866 IF x_return_status = G_RET_ERROR THEN
4867 raise FND_API.G_EXC_ERROR;
4868 ELSIF x_return_status = G_RET_UNEXPECTED THEN
4869 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4870 END IF;
4871 end if;
4872 End if;
4873
4874 l_profile_value := WSMPUTIL.CREATE_LBJ_COPY_RTG_PROFILE(p_txn_org_id); -- This returns the Profile value
4875
4876 l_stmt_num := 20;
4877
4878 select meaning
4879 into g_translated_meaning
4880 from mfg_lookups
4881 where lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
4882 and lookup_code = 7
4883 and upper(enabled_flag) = 'Y';
4884
4885 l_stmt_num := 30;
4886
4887 IF (l_profile_value = 2) THEN -- Dont make copies
4888 WSMPJUPD.g_copy_mode := 0;
4889 ELSE
4890 IF (WSMPJUPD.g_copy_mode IS NULL) THEN -- Called through the form
4891 WSMPJUPD.g_copy_mode := 1; -- For form, make copies immediately
4892 END IF;
4893 END IF;
4894
4895 l_stmt_num := 40;
4896
4897 -- get the po creation type...
4898 SELECT po_creation_time
4899 INTO l_po_creation_time
4900 FROM wip_parameters
4901 WHERE organization_id = p_txn_org_id;
4902
4903 if p_wltx_header.transaction_id is null then
4904 select wsm_split_merge_transactions_s.nextval
4905 into p_wltx_header.transaction_id
4906 from dual;
4907 end if;
4908
4909 l_stmt_num := 50;
4910 -- for based on each transaction type...
4911 if p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.MERGE) then
4912
4913 l_stmt_num := 55;
4914 -- do the split processing....
4915 l_non_rep_sj_tbl.delete;
4916
4917 -- loop on the jobs....
4918 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
4919 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
4920 elsif p_rep_job_index is not null then
4921 l_rep_sj_index := p_rep_job_index;
4922 else
4923 -- rep job index not passed...
4924 l_job_counter := p_wltx_starting_jobs_tbl.first;
4925 while l_job_counter is not null loop
4926 if p_wltx_starting_jobs_tbl(l_job_counter).representative_flag = 'Y' then
4927 l_rep_sj_index := l_job_counter;
4928 exit;
4929 end if;
4930 end loop;
4931 end if;
4932
4933 l_sj_also_rj_index := null;
4934
4935 l_stmt_num := 60;
4936
4937 l_job_counter := p_wltx_resulting_jobs_tbl.first;
4938
4939 while l_job_counter is not null loop
4940 -- for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
4941
4942 l_stmt_num := 61;
4943
4944 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
4945 l_stmt_num := 62;
4946 -- indicates the starting job is also a resulting job...
4947 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
4948 l_sj_also_rj_index := l_job_counter;
4949 else
4950 l_stmt_num := 63;
4951
4952 -- else indicates that the job is a new job...
4953 IF (WSMPJUPD.g_copy_mode = 0) THEN -- No copies to be made
4954 -- Added condition for APS-WLT
4955
4956 -------------------- Related Bugs for this piece of code.... ----------------------------
4957 -- 3698595
4958 -- -------------------- Related Bugs for this piece of code.... -------------------------
4959 l_stmt_num := 65;
4960
4961 l_err_code := 0;
4962 l_err_buf := null;
4963 --remove this
4964
4965 if( g_log_level_statement >= l_log_level ) then
4966 l_msg_tokens.delete;
4967 WSM_log_PVT.logMessage(p_module_name => l_module ,
4968 p_msg_text => 'Calling WSMPLBJI.build_lbji_info procedure',
4969 p_stmt_num => l_stmt_num ,
4970 p_msg_tokens => l_msg_tokens,
4971 p_fnd_log_level => g_log_level_statement,
4972 p_run_log_level => l_log_level
4973 );
4974 End if;
4975
4976 -- Create Job Header ONLY
4977 WSMPLBJI.build_lbji_info
4978 (p_routing_seq_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
4979 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
4980 p_explode_header_detail => 2, --This creates header only (WE, WDJ, WPB)
4981 p_status_type => WIP_CONSTANTS.RELEASED,
4982 p_class_code => p_wltx_starting_jobs_tbl(l_rep_sj_index).class_code,
4983 p_org => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
4984 p_wip_entity_id => l_new_we_id, -- this is returned by the API
4985 p_last_updt_date => sysdate,
4986 p_last_updt_by => g_user_id,
4987 p_creation_date => sysdate,
4988 p_created_by => g_user_id,
4989 p_last_updt_login => g_user_login_id,
4990 p_request_id => g_request_id,
4991 p_program_application_id => g_program_appl_id,
4992 p_program_id => g_program_id,
4993 p_prog_updt_date => sysdate,
4994 p_source_line_id => NULL,
4995 p_source_code => NULL,
4996 p_description => p_wltx_resulting_jobs_tbl(l_job_counter).description,
4997 p_item => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
4998 p_job_type => p_wltx_resulting_jobs_tbl(l_job_counter).job_type,
4999 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id,
5000 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id,
5001 p_firm_planned_flag => 2,
5002 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
5003 p_fusd => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_start_date,
5004 p_lucd => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_completion_date,
5005 p_start_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity,
5006 p_net_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).net_quantity,
5007 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_job_counter).coproducts_supply,
5008 p_bom_revision => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision,
5009 p_routing_revision => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision,
5010 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
5011 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
5012 p_lot_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5013 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
5014 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,
5015 p_priority => NULL,
5016 p_due_date => NULL,
5017
5018 p_attribute_category => p_wltx_resulting_jobs_tbl(l_job_counter).attribute_category,
5019 p_attribute1 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute1,
5020 p_attribute2 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute2,
5021 p_attribute3 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute3,
5022 p_attribute4 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute4,
5023 p_attribute5 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute5,
5024 p_attribute6 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute6,
5025 p_attribute7 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute7,
5026 p_attribute8 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute8,
5027 p_attribute9 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute9,
5028 p_attribute10 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute10,
5029 p_attribute11 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute11,
5030 p_attribute12 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute12,
5031 p_attribute13 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute13,
5032 p_attribute14 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute14,
5033 p_attribute15 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute15,
5034
5035 p_job_name => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5036 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5037 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5038 p_demand_class => p_wltx_starting_jobs_tbl(l_rep_sj_index).demand_class,
5039 p_project_id => NULL,
5040 p_task_id => NULL,
5041 p_schedule_group_id => NULL,
5042 p_build_sequence => NULL,
5043 p_line_id => NULL,
5044 p_kanban_card_id => NULL,
5045 p_overcompl_tol_type => NULL,
5046 p_overcompl_tol_value => NULL,
5047 p_end_item_unit_number => NULL,
5048 p_rtg_op_seq_num => p_wltx_resulting_jobs_tbl(l_job_counter).starting_operation_seq_num,
5049 p_src_client_server => 1,
5050 p_po_creation_time => l_po_creation_time,
5051 p_date_released => p_wltx_header.transaction_date, --bug 4101117
5052 p_error_code => l_err_code,
5053 p_error_msg => l_err_buf
5054 );
5055
5056 l_stmt_num := 70;
5057
5058 IF (l_err_code <> 0) THEN
5059
5060 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5061
5062 l_msg_tokens.delete;
5063 WSM_log_PVT.logMessage(p_module_name => l_module ,
5064 p_msg_text => 'Returned failure from WSMPLBJI.build_lbji_info procedure' ,
5065 p_stmt_num => l_stmt_num ,
5066 p_msg_tokens => l_msg_tokens,
5067 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5068 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5069 p_run_log_level => l_log_level
5070 );
5071 END IF;
5072 RAISE FND_API.G_EXC_ERROR;
5073 ELSE
5074 -- success... now the program would have returned the id ....
5075 if( g_log_level_statement >= l_log_level ) then
5076 l_msg_tokens.delete;
5077 WSM_log_PVT.logMessage(p_module_name => l_module ,
5078 p_msg_text => 'Returned successfully from WSMPLBJI.build_lbji_info procedure',
5079 p_stmt_num => l_stmt_num ,
5080 p_msg_tokens => l_msg_tokens,
5081 p_fnd_log_level => g_log_level_statement,
5082 p_run_log_level => l_log_level
5083 );
5084 End if;
5085 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := l_new_we_id;
5086 END IF;
5087
5088 --Start : Additions for APS-WLT--
5089 ELSIF (WSMPJUPD.g_copy_mode <> 0) THEN -- Copies are to be made i.e. Option C
5090 -- Make copies immediately or at the end
5091
5092 l_stmt_num := 75;
5093 -------------------- Related Bugs for this piece of code.... ---------------------------
5094 -- 3698595
5095 -------------------- Related Bugs for this piece of code.... ------------------------
5096 l_err_code := 0;
5097 l_err_buf := null;
5098
5099 if( g_log_level_statement >= l_log_level ) then
5100 l_msg_tokens.delete;
5101 WSM_log_PVT.logMessage(p_module_name => l_module ,
5102 p_msg_text => 'Calling WSM_lbj_interface_PVT.build_job_header_info',
5103 p_stmt_num => l_stmt_num ,
5104 p_msg_tokens => l_msg_tokens,
5105 p_fnd_log_level => g_log_level_statement,
5106 p_run_log_level => l_log_level
5107 );
5108 End if;
5109
5110 -- Create Job Header ONLY
5111 WSM_lbj_interface_PVT.build_job_header_info
5112 (p_common_routing_sequence_id=> p_wltx_resulting_jobs_tbl(l_job_counter).common_routing_sequence_id,
5113 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_job_counter).common_bom_sequence_id,
5114 p_status_type => WIP_CONSTANTS.RELEASED,
5115 p_class_code => p_wltx_starting_jobs_tbl(l_rep_sj_index).class_code,
5116 p_org_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
5117 p_wip_entity_id => l_new_we_id, -- this is returned by the API
5118 p_last_updt_date => sysdate,
5119 p_last_updt_by => g_user_id,
5120 p_creation_date => sysdate,
5121 p_created_by => g_user_id,
5122 p_last_updt_login => g_user_login_id,
5123 p_request_id => g_request_id,
5124 p_program_appl_id => g_program_appl_id,
5125 p_program_id => g_program_id,
5126 p_prog_updt_date => sysdate,
5127 p_source_line_id => NULL,
5128 p_source_code => NULL,
5129 p_description => p_wltx_resulting_jobs_tbl(l_job_counter).description,
5130 p_item => p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
5131 p_job_type => p_wltx_resulting_jobs_tbl(l_job_counter).job_type,
5132 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).bom_reference_id,
5133 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_job_counter).routing_reference_id,
5134 p_firm_planned_flag => 2,
5135 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_job_counter).wip_supply_type,
5136 p_job_scheduled_start_date => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_start_date,
5137 p_job_scheduled_compl_date => p_wltx_resulting_jobs_tbl(l_job_counter).scheduled_completion_date,
5138 p_start_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity,
5139 p_net_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).net_quantity,
5140 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_job_counter).coproducts_supply,
5141 p_bom_revision => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision,
5142 p_routing_revision => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision,
5143 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).bom_revision_date,
5144 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_job_counter).routing_revision_date,
5145 p_lot_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5146 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_bom_designator,
5147 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_job_counter).alternate_routing_designator,
5148 p_priority => NULL,
5149 p_due_date => NULL,
5150
5151 p_attribute_category => p_wltx_resulting_jobs_tbl(l_job_counter).attribute_category,
5152 p_attribute1 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute1,
5153 p_attribute2 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute2,
5154 p_attribute3 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute3,
5155 p_attribute4 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute4,
5156 p_attribute5 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute5,
5157 p_attribute6 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute6,
5158 p_attribute7 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute7,
5159 p_attribute8 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute8,
5160 p_attribute9 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute9,
5161 p_attribute10 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute10,
5162 p_attribute11 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute11,
5163 p_attribute12 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute12,
5164 p_attribute13 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute13,
5165 p_attribute14 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute14,
5166 p_attribute15 => p_wltx_resulting_jobs_tbl(l_job_counter).attribute15,
5167
5168 p_job_name => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
5169 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5170 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5171 p_demand_class => p_wltx_starting_jobs_tbl(l_rep_sj_index).demand_class,
5172 p_project_id => NULL,
5173 p_task_id => NULL,
5174 p_schedule_group_id => NULL,
5175 p_build_sequence => NULL,
5176 p_line_id => NULL,
5177 p_kanban_card_id => NULL,
5178 p_overcompl_tol_type => NULL,
5179 p_overcompl_tol_value => NULL,
5180 p_end_item_unit_number => NULL,
5181 p_src_client_server => 1,
5182 p_po_creation_time => l_po_creation_time,
5183 p_date_released => p_wltx_header.transaction_date, --bug 4101117
5184 p_error_code => l_err_code,
5185 p_error_msg => l_err_buf
5186 );
5187
5188 l_stmt_num := 80;
5189
5190 IF (l_err_code <> 0) THEN
5191 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5192
5193 l_msg_tokens.delete;
5194 WSM_log_PVT.logMessage(p_module_name => l_module ,
5195 p_msg_text => 'Returned failure from WSM_lbj_interface_PVT.build_job_header_info'||l_err_buf,
5196 p_stmt_num => l_stmt_num ,
5197 p_msg_tokens => l_msg_tokens,
5198 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5199 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5200 p_run_log_level => l_log_level
5201 );
5202 END IF;
5203 RAISE FND_API.G_EXC_ERROR;
5204
5205 ELSE
5206 -- success... now the program would have returned the id ....
5207 if( g_log_level_statement >= l_log_level ) then
5208 l_msg_tokens.delete;
5209 WSM_log_PVT.logMessage(p_module_name => l_module ,
5210 p_msg_text => 'Returned success from WSM_lbj_interface_PVT.build_job_header_info',
5211 p_stmt_num => l_stmt_num ,
5212 p_msg_tokens => l_msg_tokens,
5213 p_fnd_log_level => g_log_level_statement,
5214 p_run_log_level => l_log_level
5215 );
5216 End if;
5217
5218 p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id := l_new_we_id;
5219 END IF;
5220
5221 END IF; --WSMPJUPD.g_copy_mode
5222
5223 l_stmt_num := 85;
5224
5225 l_new_rj_we_id_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
5226 l_new_rj_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity;
5227
5228 -- Kanban stuff for Merge Txn....
5229 if p_wltx_header.transaction_type_id = WSMPCNST.merge then
5230 -- here take care of the following case
5231 -- A*
5232 -- \
5233 -- |-- C
5234 -- /
5235 -- B
5236 -- where A is the representative lot and has a kanban reference. In this case, C will inherit
5237 -- the kanban reference of A, provided that the completion subinventory of A and C are the same.
5238
5239 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id;
5240 p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id := null;
5241
5242 if l_kanban_card_id is not null then
5243 if ( (p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory = p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory)
5244 AND
5245 (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))
5246 )
5247 then
5248
5249 l_stmt_num := 53;
5250 -- this means this kanban_card_id is inherited by resulting job, while examining the starting jobs
5251 -- do not set the kanban card to Exception just because the qties of the starting jobs have become 0
5252 if( g_log_level_statement >= l_log_level ) then
5253 l_msg_tokens.delete;
5254 WSM_log_PVT.logMessage(p_module_name => l_module ,
5255 p_msg_text => 'Calling INV_Kanban_PVT.Update_Card_Supply_Status',
5256 p_stmt_num => l_stmt_num ,
5257 p_msg_tokens => l_msg_tokens,
5258 p_fnd_log_level => g_log_level_statement,
5259 p_run_log_level => l_log_level
5260 );
5261 End if;
5262
5263 INV_Kanban_PVT.Update_Card_Supply_Status( X_Return_Status => l_ret_status,
5264 p_Kanban_Card_Id => l_kanban_card_id,
5265 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
5266 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
5267 p_Document_Header_Id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
5268 p_Document_detail_Id => '',
5269 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_job_counter).start_quantity
5270 );
5271
5272 if ( l_ret_status <> fnd_api.g_ret_sts_success ) then
5273 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5274
5275 l_msg_tokens.delete;
5276 l_msg_tokens(1).TokenName := 'STATUS';
5277 l_msg_tokens(1).TokenValue := g_translated_meaning;
5278 WSM_log_PVT.logMessage(p_module_name => l_module ,
5279 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5280 p_msg_appl_name => 'WSM' ,
5281 p_msg_tokens => l_msg_tokens ,
5282 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5283 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5284 p_run_log_level => l_log_level
5285 );
5286 END IF;
5287
5288 RAISE FND_API.G_EXC_ERROR;
5289
5290 end if;
5291
5292 p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id := l_kanban_card_id;
5293
5294 end if;
5295 end if;
5296
5297 update wip_discrete_jobs
5298 set completion_subinventory = p_wltx_resulting_jobs_tbl(l_job_counter).completion_subinventory,
5299 completion_locator_id = p_wltx_resulting_jobs_tbl(l_job_counter).completion_locator_id,
5300 kanban_card_id = p_wltx_resulting_jobs_tbl(l_job_counter).kanban_card_id
5301 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
5302
5303 end if;
5304 end if; -- check for starting job also as a resulting job
5305
5306 l_job_counter := p_wltx_resulting_jobs_tbl.next(l_job_counter);
5307 end loop;
5308
5309 l_stmt_num := 90;
5310
5311 --Copy the job details from the representative parent lot into the child job--
5312 --The details are copied for all ops till the current op.--
5313 --i.e. If say, the job has moved into 30Q, and undone back to 20Q and a split is done here--
5314 --only ops 10 and 20 should get copied to the resulting jobs, since 30's cnt_pt is still 1--
5315 --Also any manual issues at op 30 should remain with original job--
5316 --That is, any manual issues at an op after the curr op, should not be proportionated. --
5317
5318 l_stmt_num := 220;
5319
5320 if( g_log_level_statement >= l_log_level ) then
5321 l_msg_tokens.delete;
5322 WSM_log_PVT.logMessage(p_module_name => l_module ,
5323 p_msg_text => 'Calling COPY_REP_JOB_WO_FA ' || p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5324 p_stmt_num => l_stmt_num ,
5325 p_msg_tokens => l_msg_tokens,
5326 p_fnd_log_level => g_log_level_statement,
5327 p_run_log_level => l_log_level
5328 );
5329 End if;
5330 l_err_code := 0;
5331 l_err_buf := null;
5332
5333 -- Related bugs : 3142153
5334 COPY_REP_JOB_WO_FA( p_txn_id => null,
5335 p_txn_org_id => p_txn_org_id,
5336 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5337 p_new_rj_qty_tbl => l_new_rj_qty_tbl,
5338 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5339 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5340 p_curr_op_seq_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_id,
5341 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
5342 x_err_code => l_err_code,
5343 x_err_buf => l_err_buf
5344 );
5345
5346 IF (l_err_code <> 0) THEN
5347 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5348
5349 l_msg_tokens.delete;
5350 WSM_log_PVT.logMessage(p_module_name => l_module ,
5351 p_msg_text => 'Returned failure from COPY_REP_JOB_WO_FA',
5352 p_stmt_num => l_stmt_num ,
5353 p_msg_tokens => l_msg_tokens,
5354 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5355 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5356 p_run_log_level => l_log_level
5357 );
5358 END IF;
5359 RAISE FND_API.G_EXC_ERROR;
5360 END IF;
5361
5362
5363 l_stmt_num := 230;
5364 if( g_log_level_statement >= l_log_level ) then
5365 l_msg_tokens.delete;
5366 WSM_log_PVT.logMessage(p_module_name => l_module ,
5367 p_msg_text => 'Calling COPY_REP_JOB_WOR ',
5368 p_stmt_num => l_stmt_num ,
5369 p_msg_tokens => l_msg_tokens,
5370 p_fnd_log_level => g_log_level_statement,
5371 p_run_log_level => l_log_level
5372 );
5373 End if;
5374 l_err_code := 0;
5375 l_err_buf := null;
5376
5377 -- Related bugs : 3142153
5378 COPY_REP_JOB_WOR ( p_txn_id => null,
5379 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5380 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5381 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5382 x_err_code => l_err_code,
5383 x_err_buf => l_err_buf);
5384
5385 IF (l_err_code <> 0) THEN
5386 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5387
5388 l_msg_tokens.delete;
5389 WSM_log_PVT.logMessage(p_module_name => l_module ,
5390 p_msg_text => 'Returned failure from COPY_REP_JOB_WOR',
5391 p_stmt_num => l_stmt_num ,
5392 p_msg_tokens => l_msg_tokens,
5393 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5394 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5395 p_run_log_level => l_log_level
5396 );
5397 END IF;
5398 RAISE FND_API.G_EXC_ERROR;
5399 END IF;
5400
5401
5402 -- Related bugs : 3142153
5403 l_stmt_num := 240;
5404
5405 l_err_code := 0;
5406 l_err_buf := null;
5407
5408 --Start: Additions for APS-WLT--
5409 IF (WSMPJUPD.g_copy_mode = 0) THEN
5410 null;
5411 ELSE -- Copies are to be made i.e. Option C
5412 -- Make copies immediately or at the end
5413 if( g_log_level_statement >= l_log_level ) then
5414 l_msg_tokens.delete;
5415 WSM_log_PVT.logMessage(p_module_name => l_module ,
5416 p_msg_text => 'Calling COPY_REP_JOB_WSOR ',
5417 p_stmt_num => l_stmt_num ,
5418 p_msg_tokens => l_msg_tokens,
5419 p_fnd_log_level => g_log_level_statement,
5420 p_run_log_level => l_log_level
5421 );
5422 End if;
5423
5424 COPY_REP_JOB_WSOR( p_txn_id => null,
5425 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5426 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5427 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5428 x_err_code => l_err_code,
5429 x_err_buf => l_err_buf
5430 );
5431
5432 IF (l_err_code <> 0) THEN
5433 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5434
5435 l_msg_tokens.delete;
5436 WSM_log_PVT.logMessage(p_module_name => l_module ,
5437 p_msg_text => 'Returned failure from COPY_REP_JOB_WSOR',
5438 p_stmt_num => l_stmt_num ,
5439 p_msg_tokens => l_msg_tokens,
5440 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5441 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5442 p_run_log_level => l_log_level
5443 );
5444 END IF;
5445 RAISE FND_API.G_EXC_ERROR;
5446 END IF;
5447 END IF;
5448
5449 --End: Additions for APS-WLT--
5450
5451 /* ST : Detailed Scheduling start */
5452 l_stmt_num := 78;
5453 l_err_code := 0;
5454 l_err_buf := null;
5455
5456 COPY_REP_JOB_WORI( p_txn_id => null,
5457 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5458 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5459 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num, -- Fix for bug #3142153
5460 x_err_code => l_err_code,
5461 x_err_buf => l_err_buf
5462 );
5463 IF (l_err_code <> 0) THEN
5464 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5465
5466 l_msg_tokens.delete;
5467 WSM_log_PVT.logMessage(p_module_name => l_module ,
5468 p_msg_text => 'Returned failure from COPY_REP_JOB_WORI',
5469 p_stmt_num => l_stmt_num,
5470 p_msg_tokens => l_msg_tokens,
5471 p_fnd_msg_level => G_MSG_LVL_ERROR,
5472 p_fnd_log_level => G_LOG_LEVEL_ERROR,
5473 p_run_log_level => l_log_level
5474 );
5475 END IF;
5476 RAISE FND_API.G_EXC_ERROR;
5477 END IF;
5478 /* ST : Detailed Scheduling end */
5479
5480 l_stmt_num := 250;
5481 if( g_log_level_statement >= l_log_level ) then
5482 l_msg_tokens.delete;
5483 WSM_log_PVT.logMessage(p_module_name => l_module,
5484 p_msg_text => 'Calling COPY_REP_JOB_WRO',
5485 p_stmt_num => l_stmt_num,
5486 p_msg_tokens => l_msg_tokens,
5487 p_fnd_log_level => g_log_level_statement,
5488 p_run_log_level => l_log_level
5489 );
5490 End if;
5491
5492 l_err_code := 0;
5493 l_err_buf := null;
5494
5495 -- Related bugs : 3142153
5496 COPY_REP_JOB_WRO( p_txn_id => null,
5497 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5498 p_new_rj_qty_tbl => l_new_rj_qty_tbl,
5499 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5500 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5501 p_txn_intraop_step => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
5502 x_err_code => l_err_code,
5503 x_err_buf => l_err_buf
5504 );
5505
5506 IF (l_err_code <> 0) THEN
5507 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5508
5509 l_msg_tokens.delete;
5510 WSM_log_PVT.logMessage(p_module_name => l_module ,
5511 p_msg_text => 'Returned failure from COPY_REP_JOB_WRO',
5512 p_stmt_num => l_stmt_num ,
5513 p_msg_tokens => l_msg_tokens,
5514 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5515 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5516 p_run_log_level => l_log_level
5517 );
5518 END IF;
5519 RAISE FND_API.G_EXC_ERROR;
5520 END IF;
5521
5522
5523 l_stmt_num := 260;
5524 if( g_log_level_statement >= l_log_level ) then
5525 l_msg_tokens.delete;
5526 WSM_log_PVT.logMessage(p_module_name => l_module ,
5527 p_msg_text => 'Calling COPY_REP_JOB_WOY ',
5528 p_stmt_num => l_stmt_num ,
5529 p_msg_tokens => l_msg_tokens,
5530 p_fnd_log_level => g_log_level_statement,
5531 p_run_log_level => l_log_level
5532 );
5533 End if;
5534 l_err_code := 0;
5535 l_err_buf := null;
5536 -- Related bugs : 3142153
5537
5538 COPY_REP_JOB_WOY( p_txn_id => null,
5539 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
5540 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
5541 p_curr_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
5542 x_err_code => l_err_code,
5543 x_err_buf => l_err_buf
5544 );
5545
5546 IF (l_err_code <> 0) THEN
5547 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5548 l_msg_tokens.delete;
5549 WSM_log_PVT.logMessage(p_module_name => l_module ,
5550 p_msg_text => 'Returned failure from COPY_REP_JOB_WOY',
5551 p_stmt_num => l_stmt_num ,
5552 p_msg_tokens => l_msg_tokens,
5553 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5554 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5555 p_run_log_level => l_log_level
5556 );
5557 END IF;
5558 RAISE FND_API.G_EXC_ERROR;
5559 END IF;
5560
5561 -- ok now process the starting jobs...
5562 if( g_log_level_statement >= l_log_level ) then
5563 l_msg_tokens.delete;
5564 WSM_log_PVT.logMessage(p_module_name => l_module ,
5565 p_msg_text => ' processing the starting jobs...',
5566 p_stmt_num => l_stmt_num ,
5567 p_msg_tokens => l_msg_tokens,
5568 p_fnd_log_level => g_log_level_statement,
5569 p_run_log_level => l_log_level
5570 );
5571 End if;
5572
5573 l_job_counter := p_wltx_starting_jobs_tbl.first;
5574 --Bug 5362019:Initialize l_rep_new_qty
5575 l_rep_new_qty := 0;
5576
5577 while l_job_counter is not null loop
5578 -- for l_job_counter in p_wltx_starting_jobs_tbl.first..p_wltx_starting_jobs_tbl.last loop
5579
5580 if (l_job_counter = l_rep_sj_index)
5581 and
5582 (l_sj_also_rj_index is not null)
5583 then -- indicates that the starting job is also a resulting job
5584 if( g_log_level_statement >= l_log_level ) then
5585 l_msg_tokens.delete;
5586 WSM_log_PVT.logMessage(p_module_name => l_module ,
5587 p_msg_text => 'Representative Starting Job ' || p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_name
5588 || ' is also a resulting job..'
5589 || ' Starting Job index(l_job_counter) : ' || l_job_counter
5590 || ' Resulting Job index(l_sj_also_rj_index) : ' || l_sj_also_rj_index,
5591 p_stmt_num => l_stmt_num ,
5592 p_msg_tokens => l_msg_tokens,
5593 p_fnd_log_level => g_log_level_statement,
5594 p_run_log_level => l_log_level
5595 );
5596 End if;
5597 -- related bugs : 3181486
5598 l_stmt_num := 95;
5599
5600 l_rep_new_qty := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity;
5601
5602 -- we can directly call change_quantity here as only one starting job is possible...
5603 l_sj_we_id_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5604 l_sj_old_st_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity;
5605 l_sj_new_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity;
5606 l_sj_new_net_qty_tbl(l_job_counter) := p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).net_quantity;
5607 l_sj_op_seq_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).operation_seq_num;
5608 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;
5609 l_sj_avail_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5610
5611 l_err_code := 0;
5612 l_err_buf := null;
5613
5614 l_stmt_num := 100;
5615
5616 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id;
5617
5618 -- nw comes the Kanban card id and the completion subinv. updation part....
5619 -- if the starting job has a kanban and if SpUA then exception...
5620 if l_kanban_card_id is not null then
5621
5622 l_stmt_num := 115;
5623
5624 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
5625
5626 l_stmt_num := 120;
5627 if( g_log_level_statement >= l_log_level ) then
5628 l_msg_tokens.delete;
5629 WSM_log_PVT.logMessage(p_module_name => l_module ,
5630 p_msg_text => ' Calling INV_Kanban_PVT.Update_Card_Supply_Status...',
5631 p_stmt_num => l_stmt_num ,
5632 p_msg_tokens => l_msg_tokens,
5633 p_fnd_log_level => g_log_level_statement,
5634 p_run_log_level => l_log_level
5635 );
5636 End if;
5637
5638 -- SpUA .. so remove it...
5639 INV_Kanban_PVT.Update_Card_Supply_Status ( X_Return_Status => l_ret_status,
5640 p_Kanban_Card_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id,
5641 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
5642 );
5643
5644 if ( l_ret_status <> fnd_api.g_ret_sts_success ) then
5645
5646 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5647
5648 l_msg_tokens.delete;
5649 l_msg_tokens(1).TokenName := 'STATUS';
5650 l_msg_tokens(1).TokenValue := g_translated_meaning;
5651 WSM_log_PVT.logMessage(p_module_name => l_module ,
5652 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5653 p_msg_appl_name => 'WSM' ,
5654 p_msg_tokens => l_msg_tokens ,
5655 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5656 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5657 p_run_log_level => l_log_level
5658 );
5659 END IF;
5660 RAISE FND_API.G_EXC_ERROR;
5661
5662 end if;
5663
5664 l_stmt_num := 125;
5665 l_kanban_card_id := null;
5666 else
5667 -- now check if the resulting job has changed
5668 if( g_log_level_statement >= l_log_level ) then
5669 l_msg_tokens.delete;
5670 WSM_log_PVT.logMessage(p_module_name => l_module ,
5671 p_msg_text => ' Calling handle_kanban_sub_loc_change...',
5672 p_stmt_num => l_stmt_num ,
5673 p_msg_tokens => l_msg_tokens,
5674 p_fnd_log_level => g_log_level_statement,
5675 p_run_log_level => l_log_level
5676 );
5677 End if;
5678
5679 l_err_code := 0;
5680 l_err_buf := null;
5681
5682 l_sub_loc_change := handle_kanban_sub_loc_change( p_wip_entity_id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5683 p_kanban_card_id => p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id,
5684 p_wssj_completion_subinventory => p_wltx_starting_jobs_tbl(l_job_counter).completion_subinventory,
5685 p_wssj_completion_locator_id => p_wltx_starting_jobs_tbl(l_job_counter).completion_locator_id,
5686 p_wsrj_completion_subinventory => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_subinventory,
5687 p_wsrj_completion_locator_id => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_locator_id,
5688 x_err_code => l_err_code,
5689 x_err_msg => l_err_buf
5690 );
5691
5692 IF (l_err_code <> 0) THEN
5693 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5694
5695 l_msg_tokens.delete;
5696 WSM_log_PVT.logMessage(p_module_name => l_module ,
5697 p_msg_text => 'Returned failure from handle_kanban_sub_loc_change',
5698 p_stmt_num => l_stmt_num ,
5699 p_msg_tokens => l_msg_tokens,
5700 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5701 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5702 p_run_log_level => l_log_level
5703 );
5704 END IF;
5705 RAISE FND_API.G_EXC_ERROR;
5706 END IF;
5707
5708 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
5709 if l_sub_loc_change <> 0 then
5710 l_kanban_card_id := null;
5711 end if;
5712
5713 if l_sub_loc_change = 0 then -- reflect the updated quantity in the card
5714
5715 l_stmt_num := 147;
5716 if( g_log_level_statement >= l_log_level ) then
5717 l_msg_tokens.delete;
5718 WSM_log_PVT.logMessage(p_module_name => l_module ,
5719 p_msg_text => ' Calling INV_Kanban_PVT.Update_Card_Supply_Status...',
5720 p_stmt_num => l_stmt_num ,
5721 p_msg_tokens => l_msg_tokens,
5722 p_fnd_log_level => g_log_level_statement,
5723 p_run_log_level => l_log_level
5724 );
5725 End if;
5726
5727
5728 INV_Kanban_PVT.Update_Card_Supply_Status( x_return_status => l_ret_Status,
5729 p_Kanban_Card_Id => l_kanban_card_id,
5730 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
5731 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
5732 p_Document_Header_Id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5733 p_Document_detail_Id => '',
5734 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).start_quantity
5735 );
5736
5737 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
5738 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5739
5740 l_msg_tokens.delete;
5741 l_msg_tokens(1).TokenName := 'STATUS';
5742 l_msg_tokens(1).TokenValue := g_translated_meaning;
5743 WSM_log_PVT.logMessage(p_module_name => l_module ,
5744 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5745 p_msg_appl_name => 'WSM' ,
5746 p_msg_tokens => l_msg_tokens ,
5747 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5748 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5749 p_run_log_level => l_log_level
5750 );
5751 END IF;
5752 RAISE FND_API.G_EXC_ERROR;
5753
5754 end if;
5755
5756 l_stmt_num := 150;
5757 end if;
5758 end if;
5759 end if;
5760
5761 l_stmt_num := 155;
5762
5763 p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).kanban_card_id := l_kanban_card_id;
5764
5765 if( g_log_level_statement >= l_log_level ) then
5766 l_msg_tokens.delete;
5767 WSM_log_PVT.logMessage(p_module_name => l_module ,
5768 p_msg_text => 'Updating the completion subinv and the kanban card id ...',
5769 p_stmt_num => l_stmt_num ,
5770 p_msg_tokens => l_msg_tokens,
5771 p_fnd_log_level => g_log_level_statement,
5772 p_run_log_level => l_log_level
5773 );
5774 End if;
5775
5776 -- update the completion subinv and the kanban card id ....
5777 UPDATE wip_discrete_jobs
5778 SET completion_subinventory = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_subinventory,
5779 completion_locator_id = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).completion_locator_id ,
5780 kanban_card_id = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).kanban_card_id ,
5781 -- ST : Fix for bug 5122500
5782 coproducts_supply = p_wltx_resulting_jobs_tbl(l_sj_also_rj_index).coproducts_supply
5783 WHERE wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5784
5785 l_stmt_num := 158;
5786
5787 else -- starting job is has been completely merged/split or a non-representative job...
5788
5789 l_stmt_num := 160;
5790 if( g_log_level_statement >= l_log_level ) then
5791 l_msg_tokens.delete;
5792 WSM_log_PVT.logMessage(p_module_name => l_module ,
5793 p_msg_text => 'starting job has been completely merged/split or a non-representative job... ',
5794 p_stmt_num => l_stmt_num ,
5795 p_msg_tokens => l_msg_tokens,
5796 p_fnd_log_level => g_log_level_statement,
5797 p_run_log_level => l_log_level
5798 );
5799 End if;
5800
5801 --Bug 5362019: l_rep_new_qty should not be reset.Its not applicable when
5802 -- starting job is has been completely merged/split or a non-representative job.
5803 --l_rep_new_qty := 0;
5804 --Bug 5362019: Populate the table l_non_rep_sj_tbl if the current job is not a representative job
5805 if (l_job_counter <> l_rep_sj_index) then
5806 l_non_rep_sj_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5807 end if;
5808 --Bug 5362019: End of changes
5809 -- related bugs : 3181486
5810 -- we can directly call change_quantity here as only one starting job is possible...
5811 l_sj_we_id_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5812 l_sj_old_st_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).start_quantity;
5813 l_sj_new_qty_tbl(l_job_counter) := 0;
5814 l_sj_new_net_qty_tbl(l_job_counter) := 0;
5815 l_sj_op_seq_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).operation_seq_num;
5816 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;
5817 l_sj_avail_qty_tbl(l_job_counter) := p_wltx_starting_jobs_tbl(l_job_counter).quantity_available;
5818
5819 l_stmt_num := 165;
5820
5821 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id;
5822
5823 -- kanban comes into picture... delete the link...
5824 if l_kanban_card_id is not null then
5825
5826 l_stmt_num := 175;
5827
5828 -- In case of split straight forward....
5829 -- In case of Merge check if the resulting job has kanban or not..
5830
5831 if (p_wltx_header.transaction_type_id = WSMPCNST.SPLIT) or
5832 --Bug 5344612:Case of p_wltx_resulting_jobs_tbl.kanban_card_id being null is handled.
5833 p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id IS NULL or
5834 (p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id IS NOT NULL AND
5835 p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).kanban_card_id <> l_kanban_card_id)
5836 then
5837
5838 INV_Kanban_PVT.Update_Card_Supply_Status ( x_return_status => l_ret_status,
5839 p_Kanban_Card_Id => p_wltx_starting_jobs_tbl(l_job_counter).kanban_card_id,
5840 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_Exception
5841 );
5842
5843 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
5844 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
5845
5846 l_msg_tokens.delete;
5847 l_msg_tokens(1).TokenName := 'STATUS';
5848 l_msg_tokens(1).TokenValue := g_translated_meaning;
5849 WSM_log_PVT.logMessage(p_module_name => l_module ,
5850 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
5851 p_msg_appl_name => 'WSM' ,
5852 p_msg_tokens => l_msg_tokens ,
5853 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5854 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5855 p_run_log_level => l_log_level
5856 );
5857 END IF;
5858 RAISE FND_API.G_EXC_ERROR;
5859 end if;
5860
5861 l_stmt_num := 137;
5862 --Bug 5344676:Commented out the following line
5863 -- l_kanban_card_id := null;
5864 end if;
5865 --Bug 5344676:Kanban card is should be null even if the Kanban status is not set to exception.
5866 l_kanban_card_id := null;
5867 end if;
5868
5869 l_stmt_num := 180;
5870
5871 -- change the status of the job...
5872 -- Related bugs : 2974419
5873 UPDATE wip_discrete_jobs
5874 SET STATUS_TYPE = 4
5875 ,kanban_card_id = l_kanban_card_id
5876 ,date_completed = sysdate
5877 ,last_updated_by = g_user_id
5878 ,last_update_date = sysdate
5879 ,last_update_login = g_user_login_id
5880 ,program_application_id = g_program_appl_id
5881 ,program_id = g_PROGRAM_ID
5882 ,program_update_date = sysdate
5883 ,request_id = g_REQUEST_ID
5884 WHERE wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
5885
5886 l_stmt_num := 190;
5887
5888 l_new_name := WSMPOPRN.update_job_name ( p_wip_entity_id => p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id,
5889 p_subinventory => p_wltx_starting_jobs_tbl(l_job_counter).completion_subinventory,
5890 p_org_id => p_wltx_starting_jobs_tbl(l_job_counter).organization_id,
5891 p_txn_type => 2, -- COMPLETION
5892 p_update_flag => TRUE,
5893 p_dup_job_name => l_dup_job_name,
5894 x_error_code => l_err_code,
5895 x_error_msg => l_err_buf
5896 );
5897
5898 if l_err_code <> 0 then
5899 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5900 l_msg_tokens.delete;
5901 /* Start bugfix 5738550 Use hardcoded text only if API call did not return message */
5902 if l_err_buf is null then
5903 l_err_buf := 'Returned failure from WSMPOPRN.update_job_name';
5904 end if;
5905 /* End bugfix 5738550 */
5906 WSM_log_PVT.logMessage(p_module_name => l_module ,
5907 p_msg_text => l_err_buf , /* Bugfix 5738550 removed hardcoding */
5908 p_stmt_num => l_stmt_num ,
5909 p_msg_tokens => l_msg_tokens,
5910 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5911 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5912 p_run_log_level => l_log_level
5913 );
5914 END IF;
5915 RAISE FND_API.G_EXC_ERROR;
5916 else
5917 -- success.. got the new name for the job ...
5918 if( g_log_level_statement >= l_log_level ) then
5919 l_msg_tokens.delete;
5920 WSM_log_PVT.logMessage(p_module_name => l_module ,
5921 p_msg_text => 'WSMPOPRN.update_job_name success.Got new job name',
5922 p_stmt_num => l_stmt_num ,
5923 p_msg_tokens => l_msg_tokens,
5924 p_fnd_log_level => g_log_level_statement,
5925 p_run_log_level => l_log_level
5926 );
5927 End if;
5928 end if;
5929 l_stmt_num := 200;
5930
5931 end if;
5932
5933 l_job_counter := p_wltx_starting_jobs_tbl.next(l_job_counter);
5934
5935 end loop;
5936
5937
5938 l_stmt_num := 210;
5939 if( g_log_level_statement >= l_log_level ) then
5940 l_msg_tokens.delete;
5941 WSM_log_PVT.logMessage(p_module_name => l_module ,
5942 p_msg_text => 'Calling CHANGE_QUANTITY',
5943 p_stmt_num => l_stmt_num ,
5944 p_msg_tokens => l_msg_tokens,
5945 p_fnd_log_level => g_log_level_statement,
5946 p_run_log_level => l_log_level
5947 );
5948 End if;
5949
5950 l_err_code := 0;
5951 l_err_buf := null;
5952
5953 -- change the quantity
5954 CHANGE_QUANTITY( p_txn_id => null,
5955 p_txn_type => p_wltx_header.transaction_type_id,
5956 p_wip_entity_id_tbl => l_sj_we_id_tbl,
5957 p_new_job_qty_tbl => l_sj_new_qty_tbl,
5958 p_new_net_qty_tbl => l_sj_new_net_qty_tbl,
5959
5960 p_txn_job_op_seq_tbl => l_sj_op_seq_tbl,
5961 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
5962
5963 p_sj_st_qty_tbl => l_sj_old_st_qty_tbl,
5964 p_sj_avail_qty_tbl => l_sj_avail_qty_tbl,
5965 p_sj_scrap_qty_tbl => l_sj_scrap_qty_tbl,
5966
5967 x_err_code => l_err_code,
5968 x_err_buf => l_err_buf
5969 );
5970
5971 IF (l_err_code <> 0) THEN
5972 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
5973 l_msg_tokens.delete;
5974 WSM_log_PVT.logMessage(p_module_name => l_module ,
5975 p_msg_text => 'CHANGE_QUANTITY returned failure' ,
5976 p_stmt_num => l_stmt_num ,
5977 p_msg_tokens => l_msg_tokens,
5978 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5979 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5980 p_run_log_level => l_log_level
5981 );
5982 END IF;
5983 RAISE FND_API.G_EXC_ERROR;
5984 END IF;
5985
5986 l_stmt_num := 270;
5987 if( g_log_level_statement >= l_log_level ) then
5988 l_msg_tokens.delete;
5989 WSM_log_PVT.logMessage(p_module_name => l_module ,
5990 p_msg_text => 'Calling UPDATE_QTY_ISSUED',
5991 p_stmt_num => l_stmt_num ,
5992 p_msg_tokens => l_msg_tokens,
5993 p_fnd_log_level => g_log_level_statement,
5994 p_run_log_level => l_log_level
5995 );
5996 End if;
5997
5998 l_err_code := 0;
5999 l_err_buf := null;
6000
6001 UPDATE_QTY_ISSUED(p_txn_id => null,
6002 p_txn_type => p_wltx_header.transaction_type_id,
6003 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6004 p_rep_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6005 p_rep_avail_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6006 p_rep_new_job_qty => l_rep_new_qty,
6007 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6008 p_non_rep_sj_we_id_tbl => l_non_rep_sj_tbl,
6009 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
6010 p_new_rj_start_qty => l_new_rj_qty_tbl,
6011 x_err_code => l_err_code,
6012 x_err_buf => l_err_buf
6013 );
6014
6015 if l_err_code <> 0 then
6016 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6017
6018 l_msg_tokens.delete;
6019 WSM_log_PVT.logMessage(p_module_name => l_module ,
6020 p_msg_text => 'UPDATE_QTY_ISSUED returned failure' ,
6021 p_stmt_num => l_stmt_num ,
6022 p_msg_tokens => l_msg_tokens,
6023 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6024 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6025 p_run_log_level => l_log_level
6026 );
6027 END IF;
6028 RAISE FND_API.G_EXC_ERROR;
6029 end if;
6030
6031 l_stmt_num := 280;
6032
6033 -- loop on the resulting jobs for split has update assembly...
6034 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
6035
6036 l_job_counter := p_wltx_resulting_jobs_tbl.first;
6037 while l_job_counter is not null loop
6038 -- for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
6039 if p_wltx_resulting_jobs_tbl(l_job_counter).split_has_update_assy = 1 then
6040
6041 l_stmt_num := 290;
6042 if( g_log_level_statement >= l_log_level ) then
6043 l_msg_tokens.delete;
6044 WSM_log_PVT.logMessage(p_module_name => l_module ,
6045 p_msg_text => 'Calling UPDATE_ASSEMBLY_OR_ROUTING',
6046 p_stmt_num => l_stmt_num ,
6047 p_msg_tokens => l_msg_tokens,
6048 p_fnd_log_level => g_log_level_statement,
6049 p_run_log_level => l_log_level
6050 );
6051 End if;
6052
6053 l_stmt_num := 281;
6054 l_err_code := 0;
6055 l_err_buf := null;
6056
6057 -- SpUA code....
6058 UPDATE_ASSEMBLY_OR_ROUTING( p_txn_id => null,
6059 p_txn_type_id => WSMPCNST.SPLIT,
6060 -- p_rep_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
6061 p_job_kanban_card_id => null, -- no need already handled within the code.. .....
6062 p_po_creation_time => l_po_creation_time,
6063 p_sj_compl_subinventory => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory,
6064 p_sj_compl_locator_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_locator_id,
6065 p_rj_job_rec => p_wltx_resulting_jobs_tbl(l_job_counter),
6066 p_request_id => g_request_id,
6067 x_err_code => l_err_code,
6068 x_err_buf => l_err_buf ,
6069 x_msg_count => x_msg_count
6070 );
6071
6072 IF (l_err_code <> 0) THEN
6073 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6074
6075 l_msg_tokens.delete;
6076 WSM_log_PVT.logMessage(p_module_name => l_module ,
6077 p_msg_text => 'UPDATE_ASSEMBLY_OR_ROUTING returned failure' ,
6078 p_stmt_num => l_stmt_num ,
6079 p_msg_tokens => l_msg_tokens,
6080 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6081 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6082 p_run_log_level => l_log_level
6083 );
6084 END IF;
6085 RAISE FND_API.G_EXC_ERROR;
6086 END IF;
6087 end if;
6088
6089 l_job_counter := p_wltx_resulting_jobs_tbl.next(l_job_counter);
6090 end loop;
6091 end if;
6092
6093 l_stmt_num := 282;
6094 --Update the new columns in WLBJ as part of MES
6095 l_current_job_op_seq_num := p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num;
6096
6097 BEGIN
6098 select operation_seq_num
6099 into l_current_rtg_op_seq_num
6100 from bom_operation_sequences
6101 where operation_sequence_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_id ;
6102
6103 EXCEPTION
6104 WHEN NO_DATA_FOUND THEN
6105 -- Will reach here when the job lies at an op outside the
6106 -- routing
6107 l_current_rtg_op_seq_num := null;
6108 END;
6109
6110 l_stmt_num := 283;
6111 forall i in indices of l_new_rj_we_id_tbl
6112 update wsm_lot_based_jobs
6113 set CURRENT_RTG_OP_SEQ_NUM = l_current_rtg_op_seq_num,
6114 CURRENT_JOB_OP_SEQ_NUM = l_current_job_op_seq_num
6115 where wip_entity_id = l_new_rj_we_id_tbl(i)
6116 and CURRENT_RTG_OP_SEQ_NUM is null
6117 and CURRENT_JOB_OP_SEQ_NUM is null;
6118
6119 ----End Update the new columns in WLBJ as part of MES
6120
6121 -- Start : Additions for APS-WLT --
6122 l_stmt_num := 295;
6123
6124
6125 IF (WSMPJUPD.g_copy_mode = 0) THEN
6126 null; -- no copies
6127 ELSE
6128 l_stmt_num := 296;
6129
6130 l_err_code := 0;
6131 l_err_buf := null;
6132
6133 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
6134 p_txn_type_id => p_wltx_header.transaction_type_id,
6135 p_copy_mode => WSMPJUPD.g_copy_mode,
6136 p_rep_sj_index => l_rep_sj_index,
6137 p_sj_as_rj_index => l_sj_also_rj_index,
6138 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6139 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6140 x_err_code => l_err_code,
6141 x_err_buf => l_err_buf,
6142 x_msg_count => x_msg_count
6143 );
6144
6145
6146 IF (l_err_code <> 0) THEN
6147 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6148
6149 l_msg_tokens.delete;
6150 WSM_log_PVT.logMessage(p_module_name => l_module ,
6151 p_msg_text => 'CREATE_COPIES_OR_SET_COPY_DATA returned '||l_err_code,
6152 p_stmt_num => l_stmt_num ,
6153 p_msg_tokens => l_msg_tokens,
6154 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6155 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6156 p_run_log_level => l_log_level
6157 );
6158 END IF;
6159 RAISE FND_API.G_EXC_ERROR; --x_err_code has errcode, x_err_buf has the error message
6160 END IF;
6161
6162 -- New Jobs in Split/Merge, jobs undergoing SPUA and jobs involved in Upd Rtg/Assly
6163 -- have already been either Infinite Scheduled or the data has been set for them
6164 -- in the above call CREATE_COPIES_OR_SET_COPY_DATA, which
6165 -- calls Create_JobCopies / Create_RepJobCopies
6166 -- The remaining jobs (parent rep jobs in Sp/Merge and jobs in UpdQty)
6167 -- are taken care of now
6168
6169 l_stmt_num := 300;
6170
6171 IF l_sj_also_rj_index is not null then
6172
6173 l_stmt_num := 310;
6174
6175 l_err_code := 0;
6176 l_err_buf := null;
6177
6178 CALL_INF_SCH_OR_SET_SCH_DATA( p_txn_id => null,
6179 p_copy_mode => WSMPJUPD.g_copy_mode,
6180 p_org_id => p_txn_org_id,
6181 p_par_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6182 x_err_code => l_err_code,
6183 x_err_buf => l_err_buf
6184 );
6185
6186 IF (l_err_code <> 0) THEN
6187 -- error out...
6188 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6189
6190 l_msg_tokens.delete;
6191 WSM_log_PVT.logMessage(p_module_name => l_module ,
6192 p_msg_text => ' CALL_INF_SCH_OR_SET_SCH_DATA returned '||l_err_code,
6193 p_stmt_num => l_stmt_num ,
6194 p_msg_tokens => l_msg_tokens,
6195 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6196 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6197 p_run_log_level => l_log_level
6198 );
6199 END IF;
6200 RAISE FND_API.G_EXC_ERROR;
6201 END IF;
6202
6203 END IF;
6204
6205 END IF;
6206
6207 -- ST : Sec. UOM Fix : Moved the call to process MES information below the call to update_assembly_routing
6208 l_stmt_num := 320;
6209 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6210 p_wltx_header => p_wltx_header,
6211 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6212 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6213 p_sj_also_rj_index => l_sj_also_rj_index,
6214 p_rep_job_index => l_rep_sj_index,
6215 x_return_status => x_return_status ,
6216 x_msg_count => x_msg_count ,
6217 x_error_msg => x_error_msg
6218 );
6219 if x_return_status <> G_RET_SUCCESS then
6220 IF x_return_status = G_RET_ERROR THEN
6221 raise FND_API.G_EXC_ERROR;
6222 ELSE
6223 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6224 END IF;
6225 end if;
6226
6227 l_stmt_num := 330;
6228 -- Geneology differs for split and merge...
6229 if p_wltx_header.transaction_type_id = WSMPCNST.SPLIT then
6230
6231 l_stmt_num := 340;
6232
6233 -- for geneology purpose.... get the gen obj id
6234 select gen_object_id
6235 into l_sj_gen_object_id
6236 from wip_entities we
6237 where we.wip_entity_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6238
6239 for l_job_counter in p_wltx_resulting_jobs_tbl.first..p_wltx_resulting_jobs_tbl.last loop
6240
6241 l_stmt_num := 345;
6242
6243 -- get the gen object id of the resulting jobs ...
6244 select gen_object_id
6245 into l_rj_gen_object_id
6246 from wip_entities we
6247 where we.wip_entity_id = p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id;
6248 --Bug 5387828:Genealogy should be created only when the starting job is diff from
6249 --resulting job.
6250 if l_sj_gen_object_id <> l_rj_gen_object_id then
6251 l_ret_status := 'E'; -- fnd error status...
6252
6253 l_stmt_num := 350;
6254
6255 inv_genealogy_pub.insert_genealogy( p_api_version =>1.0,
6256
6257 p_object_type =>5,
6258 p_object_id =>l_sj_gen_object_id,
6259 p_object_number =>p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6260 p_inventory_item_id =>p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6261 p_org_id =>p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
6262
6263 p_parent_object_type => 5,
6264 p_parent_object_id => l_rj_gen_object_id,
6265 p_parent_object_number => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_name,
6266 p_parent_inventory_item_id=> p_wltx_resulting_jobs_tbl(l_job_counter).primary_item_id,
6267 p_parent_org_id => p_wltx_resulting_jobs_tbl(l_job_counter).organization_id,
6268
6269 p_genealogy_origin => 3, -- for WIP parent
6270 p_genealogy_type => 4, -- for WIP/Inv Split/Merge/Translate
6271 p_origin_txn_id => p_wltx_header.transaction_id,
6272
6273 x_return_status =>l_ret_status,
6274 x_msg_count =>l_msg_count,
6275 x_msg_data =>l_msg_data
6276 );
6277 end if;
6278 if l_sj_gen_object_id = l_rj_gen_object_id then
6279 l_ret_status := 'S';
6280 end if;
6281 l_stmt_num := 360;
6282 IF (l_ret_status = 'S') THEN
6283 if( g_log_level_statement >= l_log_level ) then
6284 l_msg_tokens.delete;
6285 WSM_log_PVT.logMessage(p_module_name => l_module ,
6286 p_msg_text => 'inv_genealogy_pub.insert_genealogy returned success',
6287 p_stmt_num => l_stmt_num ,
6288 p_msg_tokens => l_msg_tokens,
6289 p_fnd_log_level => g_log_level_statement,
6290 p_run_log_level => l_log_level
6291 );
6292 End if;
6293
6294 ELSE
6295
6296 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6297
6298 l_msg_tokens.delete;
6299 WSM_log_PVT.logMessage(p_module_name => l_module ,
6300 p_msg_text => 'inv_genealogy_pub.insert_genealogy failed',
6301 p_stmt_num => l_stmt_num ,
6302 p_msg_tokens => l_msg_tokens,
6303 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6304 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6305 p_run_log_level => l_log_level
6306 );
6307 END IF;
6308
6309
6310 l_stmt_num := 370;
6311 IF (l_msg_count = 1) THEN
6312 l_err_code := -1;
6313 l_err_buf := 'Error in inv_genealogy_pub.insert_genealogy: '||l_msg_data;
6314
6315 ELSE
6316 FOR i IN 1..l_msg_count LOOP
6317 l_err_code := -1;
6318 l_err_buf := fnd_msg_pub.get;
6319
6320 END LOOP;
6321
6322 l_err_buf := 'Multiple errors in inv_genealogy_pub.insert_genealogy - populated in the log file';
6323
6324 END IF;
6325 RAISE FND_API.G_EXC_ERROR;
6326 END IF;
6327
6328 end loop;
6329 else
6330 -- Merge...
6331
6332 l_stmt_num := 371;
6333
6334 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6335
6336 -- for geneology purpose.... get the gen obj id
6337 select gen_object_id
6338 into l_rj_gen_object_id
6339 from wip_entities we
6340 where we.wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
6341
6342 for l_job_counter in p_wltx_starting_jobs_tbl.first..p_wltx_starting_jobs_tbl.last loop
6343
6344 l_stmt_num := 372;
6345
6346 -- get the gen object id of the resulting jobs ...
6347 select gen_object_id
6348 into l_sj_gen_object_id
6349 from wip_entities we
6350 where we.wip_entity_id = p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_id;
6351
6352 --Bug 5367218:START. Genealogy should be created only when the resulting job is not
6353 -- among one of the starting jobs.
6354 if l_sj_gen_object_id <> l_rj_gen_object_id then
6355 l_ret_status := 'E'; -- fnd error status...
6356
6357 l_stmt_num := 373;
6358
6359 inv_genealogy_pub.insert_genealogy( p_api_version =>1.0,
6360
6361 p_object_type =>5,
6362 p_object_id =>l_sj_gen_object_id,
6363 p_object_number =>p_wltx_starting_jobs_tbl(l_job_counter).wip_entity_name,
6364 p_inventory_item_id =>p_wltx_starting_jobs_tbl(l_job_counter).primary_item_id,
6365 p_org_id =>p_wltx_starting_jobs_tbl(l_job_counter).organization_id,
6366
6367 p_parent_object_type => 5,
6368 p_parent_object_id => l_rj_gen_object_id,
6369 p_parent_object_number => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_name,
6370 p_parent_inventory_item_id=> p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).primary_item_id,
6371 p_parent_org_id => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).organization_id,
6372
6373 p_genealogy_origin => 3, -- for WIP parent
6374 p_genealogy_type => 4, -- for WIP/Inv Split/Merge/Translate
6375 p_origin_txn_id => p_wltx_header.transaction_id,
6376
6377 x_return_status =>l_ret_status,
6378 x_msg_count =>l_msg_count,
6379 x_msg_data =>l_msg_data
6380 );
6381 end if;
6382
6383 if l_sj_gen_object_id = l_rj_gen_object_id then
6384 l_ret_status := 'S';
6385 end if;
6386 --Bug 5367218:END.
6387 l_stmt_num := 374;
6388 IF (l_ret_status = 'S') THEN
6389 if( g_log_level_statement >= l_log_level ) then
6390 l_msg_tokens.delete;
6391 WSM_log_PVT.logMessage(p_module_name => l_module ,
6392 p_msg_text => 'inv_genealogy_pub.insert_genealogy returned success',
6393 p_stmt_num => l_stmt_num ,
6394 p_msg_tokens => l_msg_tokens,
6395 p_fnd_log_level => g_log_level_statement,
6396 p_run_log_level => l_log_level
6397 );
6398 End if;
6399 ELSE
6400 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6401
6402 l_msg_tokens.delete;
6403 WSM_log_PVT.logMessage(p_module_name => l_module ,
6404 p_msg_text => 'inv_genealogy_pub.insert_genealogy failed',
6405 p_stmt_num => l_stmt_num ,
6406 p_msg_tokens => l_msg_tokens,
6407 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6408 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6409 p_run_log_level => l_log_level
6410 );
6411 END IF;
6412
6413 l_stmt_num := 375;
6414 IF (l_msg_count = 1) THEN
6415 l_err_code := -1;
6416 l_err_buf := 'Error in inv_genealogy_pub.insert_genealogy: '||l_msg_data;
6417 ELSE
6418 FOR i IN 1..l_msg_count LOOP
6419 l_err_code := -1;
6420 l_err_buf := fnd_msg_pub.get;
6421 END LOOP;
6422
6423 l_err_buf := 'Multiple errors in inv_genealogy_pub.insert_genealogy - populated in the log file';
6424
6425 END IF;
6426 RAISE FND_API.G_EXC_ERROR;
6427 END IF;
6428
6429 end loop;
6430
6431 end if;
6432
6433 l_stmt_num := 380;
6434
6435 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
6436 p_txn_org_id => p_txn_org_id,
6437 p_txn_date => p_wltx_header.transaction_date,--sysdate, --l_txn_date,
6438 p_txn_type_id => p_wltx_header.transaction_type_id,
6439 p_sj_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6440 p_sj_wip_entity_name => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6441 p_sj_avail_quantity => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6442 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_id,
6443 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).wip_entity_name,
6444 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first).start_quantity,
6445 p_sj_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6446 p_sj_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6447 x_return_status => l_ret_status,
6448 x_msg_count => l_msg_count,
6449 x_msg_data => l_msg_data
6450 );
6451
6452 l_stmt_num := 390;
6453
6454 if l_ret_status <> fnd_api.g_ret_sts_success then
6455 -- error out...
6456 l_stmt_num := 395;
6457 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6458 l_msg_tokens.delete;
6459 WSM_log_PVT.logMessage(p_module_name => l_module ,
6460 p_msg_text => 'Insert_MMT_record failed',
6461 p_stmt_num => l_stmt_num ,
6462 p_msg_tokens => l_msg_tokens,
6463 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6464 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6465 p_run_log_level => l_log_level
6466 );
6467 END IF;
6468 RAISE FND_API.G_EXC_ERROR;
6469 end if;
6470
6471 l_stmt_num := 400;
6472
6473
6474 l_txn_status := WIP_CONSTANTS.COMPLETED;
6475 l_txn_costed := WIP_CONSTANTS.pending;
6476
6477 elsif p_wltx_header.transaction_type_id in (WSMPCNST.UPDATE_ASSEMBLY,WSMPCNST.UPDATE_ROUTING) then
6478
6479 l_stmt_num := 500;
6480 l_err_code := 0;
6481 l_err_buf := null;
6482
6483 UPDATE_ASSEMBLY_OR_ROUTING( p_txn_id => null,
6484 p_txn_type_id => p_wltx_header.transaction_type_id,
6485 -- p_rep_wip_entity_id => p_wltx_resulting_jobs_tbl(l_job_counter).wip_entity_id,
6486 p_job_kanban_card_id => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).kanban_card_id,
6487 p_po_creation_time => l_po_creation_time,
6488 p_sj_compl_subinventory => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).completion_subinventory,
6489 p_sj_compl_locator_id => p_wltx_starting_jobs_tbl(p_wltx_starting_jobs_tbl.first).completion_locator_id,
6490 p_rj_job_rec => p_wltx_resulting_jobs_tbl(p_wltx_resulting_jobs_tbl.first),
6491 p_request_id => g_request_id,
6492 x_err_code => l_err_code,
6493 x_err_buf => l_err_buf ,
6494 x_msg_count => x_msg_count
6495 );
6496
6497 IF (l_err_code <> 0) THEN
6498 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6499 l_msg_tokens.delete;
6500 WSM_log_PVT.logMessage(p_module_name => l_module ,
6501 p_msg_text => 'UPDATE_ASSEMBLY_OR_ROUTING failed',
6502 p_stmt_num => l_stmt_num ,
6503 p_msg_tokens => l_msg_tokens,
6504 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6505 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6506 p_run_log_level => l_log_level
6507 );
6508 END IF;
6509 RAISE FND_API.G_EXC_ERROR;
6510 END IF;
6511
6512 l_stmt_num := 510;
6513 l_err_code := 0;
6514 l_err_buf := null;
6515
6516 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
6517 p_txn_type_id => p_wltx_header.transaction_type_id,
6518 p_copy_mode => WSMPJUPD.g_copy_mode,
6519 p_rep_sj_index => p_wltx_starting_jobs_tbl.first,
6520 p_sj_as_rj_index => p_wltx_resulting_jobs_tbl.first,
6521 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6522 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6523 x_err_code => l_err_code,
6524 x_err_buf => l_err_buf,
6525 x_msg_count => x_msg_count
6526 );
6527 IF (l_err_code <> 0) THEN
6528 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6529
6530 l_msg_tokens.delete;
6531 WSM_log_PVT.logMessage(p_module_name => l_module ,
6532 p_msg_text => 'UPDATE_ASSEMBLY_OR_ROUTING failed',
6533 p_stmt_num => l_stmt_num ,
6534 p_msg_tokens => l_msg_tokens,
6535 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6536 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6537 p_run_log_level => l_log_level
6538 );
6539 END IF;
6540 RAISE FND_API.G_EXC_ERROR;
6541 END IF;
6542
6543 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6544 p_wltx_header => p_wltx_header,
6545 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6546 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6547 p_sj_also_rj_index => p_wltx_resulting_jobs_tbl.first,
6548 p_rep_job_index => p_wltx_starting_jobs_tbl.first,
6549 x_return_status => x_return_status ,
6550 x_msg_count => x_msg_count ,
6551 x_error_msg => x_error_msg
6552 );
6553
6554 if x_return_status <> G_RET_SUCCESS then
6555 IF x_return_status = G_RET_ERROR THEN
6556 raise FND_API.G_EXC_ERROR;
6557 ELSE
6558 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6559 END IF;
6560 end if;
6561
6562 l_txn_status := WIP_CONSTANTS.COMPLETED;
6563 l_txn_costed := WIP_CONSTANTS.COMPLETED;
6564
6565
6566 elsif p_wltx_header.transaction_type_id = WSMPCNST.UPDATE_QUANTITY then
6567
6568 l_stmt_num := 520;
6569 l_err_code := 0;
6570 l_err_buf := null;
6571
6572 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
6573 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6574
6575 l_sj_we_id_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6576 l_sj_new_qty_tbl(l_rep_sj_index) := p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity;
6577 l_sj_new_net_qty_tbl(l_rep_sj_index) := p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity;
6578 l_sj_op_seq_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num;
6579
6580 l_sj_old_st_qty_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).start_quantity;
6581 l_sj_avail_qty_tbl(l_rep_sj_index) := p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available;
6582 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;
6583
6584 -- change the quantity
6585 CHANGE_QUANTITY( p_txn_id => null,
6586 p_txn_type => WSMPCNST.UPDATE_QUANTITY,
6587 p_wip_entity_id_tbl => l_sj_we_id_tbl,
6588 p_new_job_qty_tbl => l_sj_new_qty_tbl,
6589 p_new_net_qty_tbl => l_sj_new_net_qty_tbl,
6590
6591 p_txn_job_op_seq_tbl => l_sj_op_seq_tbl,
6592 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6593
6594 p_sj_st_qty_tbl => l_sj_old_st_qty_tbl,
6595 p_sj_avail_qty_tbl => l_sj_avail_qty_tbl,
6596 p_sj_scrap_qty_tbl => l_sj_scrap_qty_tbl,
6597
6598 x_err_code => l_err_code,
6599 x_err_buf => l_err_buf
6600 );
6601
6602 IF (l_err_code <> 0) THEN
6603 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6604
6605 l_msg_tokens.delete;
6606 WSM_log_PVT.logMessage(p_module_name => l_module ,
6607 p_msg_text => 'CHANGE_QUANTITY failed',
6608 p_stmt_num => l_stmt_num ,
6609 p_msg_tokens => l_msg_tokens,
6610 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6611 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6612 p_run_log_level => l_log_level
6613 );
6614 END IF;
6615 RAISE FND_API.G_EXC_ERROR;
6616 END IF;
6617
6618 -- end processing the starting jobs....
6619 l_stmt_num := 530;
6620 l_err_code := 0;
6621 l_err_buf := null;
6622
6623 -- no no no-rep jobs for update qty...
6624 l_non_rep_sj_tbl.delete;
6625 l_new_rj_we_id_tbl.delete;
6626 l_new_rj_qty_tbl.delete;
6627
6628 UPDATE_QTY_ISSUED(p_txn_id => null,
6629 p_txn_type => WSMPCNST.UPDATE_QUANTITY,
6630 p_rep_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6631 p_rep_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6632 p_rep_avail_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6633 p_rep_new_job_qty => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
6634 p_txn_job_intraop => p_wltx_starting_jobs_tbl(l_rep_sj_index).intraoperation_step,
6635 p_non_rep_sj_we_id_tbl => l_non_rep_sj_tbl,
6636 p_new_rj_we_id_tbl => l_new_rj_we_id_tbl,
6637 p_new_rj_start_qty => l_new_rj_qty_tbl,
6638 x_err_code => l_err_code,
6639 x_err_buf => l_err_buf
6640 );
6641
6642 if l_err_code <> 0 then
6643 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6644
6645 l_msg_tokens.delete;
6646 WSM_log_PVT.logMessage(p_module_name => l_module ,
6647 p_msg_text => 'UPDATE_QTY_ISSUED failed',
6648 p_stmt_num => l_stmt_num ,
6649 p_msg_tokens => l_msg_tokens,
6650 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6651 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6652 p_run_log_level => l_log_level
6653 );
6654 END IF;
6655 RAISE FND_API.G_EXC_ERROR;
6656 end if;
6657
6658 l_kanban_card_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id;
6659
6660 -- nw comes the Kanban card id and the completion subinv. updation part....
6661 -- if the starting job has a
6662 if l_kanban_card_id is not null then
6663
6664 l_stmt_num := 115;
6665
6666 -- now check if the resulting job has changed
6667 l_err_code := 0;
6668 l_err_buf := null;
6669
6670 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,
6671 p_kanban_card_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).kanban_card_id,
6672 p_wssj_completion_subinventory => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_subinventory,
6673 p_wssj_completion_locator_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).completion_locator_id,
6674 p_wsrj_completion_subinventory => p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
6675 p_wsrj_completion_locator_id => p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
6676 x_err_code => l_err_code,
6677 x_err_msg => l_err_buf
6678 );
6679
6680 IF (l_err_code <> 0) THEN
6681 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6682
6683 l_msg_tokens.delete;
6684 WSM_log_PVT.logMessage(p_module_name => l_module ,
6685 p_msg_text => 'handle_kanban_sub_loc_change failed',
6686 p_stmt_num => l_stmt_num ,
6687 p_msg_tokens => l_msg_tokens,
6688 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6689 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6690 p_run_log_level => l_log_level
6691 );
6692 END IF;
6693 RAISE FND_API.G_EXC_ERROR;
6694 END IF;
6695
6696 -- indicates that the compl. subinv has changed hence remove the link to the kanban card id...
6697 if l_sub_loc_change <> 0 then
6698 l_kanban_card_id := null;
6699 end if;
6700
6701 if l_sub_loc_change = 0 then -- reflect the updated quantity in the card
6702
6703 l_stmt_num := 147;
6704
6705 INV_Kanban_PVT.Update_Card_Supply_Status( x_return_status => l_ret_Status,
6706 p_Kanban_Card_Id => l_kanban_card_id,
6707 p_Supply_Status => INV_Kanban_PVT.G_Supply_Status_InProcess,
6708 p_Document_type => inv_kanban_pvt.G_Doc_type_lot_job,
6709 p_Document_Header_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6710 p_Document_detail_Id => '',
6711 p_replenish_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity
6712 );
6713
6714 if ( l_ret_Status <> fnd_api.g_ret_sts_success ) then
6715
6716 --x_err_code := -1;
6717 fnd_message.set_name('WSM', 'WSM_KNBN_CARD_STS_FAIL');
6718 fnd_message.set_token('STATUS',g_translated_meaning);
6719 --x_err_buf := fnd_message.get;
6720 IF g_log_level_error >= l_log_level OR FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR) THEN
6721
6722 l_msg_tokens.delete;
6723 l_msg_tokens(1).TokenName := 'STATUS';
6724 l_msg_tokens(1).TokenValue := g_translated_meaning;
6725 WSM_log_PVT.logMessage(p_module_name => l_module ,
6726 p_msg_name => 'WSM_KNBN_CARD_STS_FAIL',
6727 p_msg_appl_name => 'WSM' ,
6728 p_msg_tokens => l_msg_tokens ,
6729 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6730 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6731 p_run_log_level => l_log_level
6732 );
6733 END IF;
6734
6735 RAISE FND_API.G_EXC_ERROR;
6736
6737 end if;
6738
6739 l_stmt_num := 150;
6740 end if;
6741
6742 end if;
6743
6744 l_stmt_num := 155;
6745
6746 -- update the completion subinv and the kanban card id ....
6747 update wip_discrete_jobs
6748 SET completion_subinventory = p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
6749 completion_locator_id = p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
6750 kanban_card_id = l_kanban_card_id
6751 where wip_entity_id = p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6752
6753 l_stmt_num := 158;
6754
6755 IF (WSMPUTIL.check_osp_operation(p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6756 p_operation_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6757 p_organization_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id
6758 )
6759 )
6760 THEN
6761
6762 WSMPJUPD.g_osp_exists := 1;
6763
6764 if (l_po_creation_time <> WIP_CONSTANTS.MANUAL_CREATION) then
6765
6766 l_stmt_num := 253;
6767
6768 wip_osp.create_additional_req ( P_Wip_Entity_Id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6769 P_Organization_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).organization_id,
6770 P_Repetitive_Schedule_Id => null,
6771 P_Added_Quantity => (p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity-p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available),
6772 P_Op_Seq => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num
6773 );
6774
6775 --if l_request_id is null means online processing so launch import req
6776
6777 if (g_request_id is null) then
6778
6779 l_po_request_id := fnd_request.submit_request('PO', 'REQIMPORT', NULL, NULL, FALSE,'WIP', NULL, 'ITEM',
6780 NULL,'N', 'Y', chr(0), NULL, NULL, NULL,
6781 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6782 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6783 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6784 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6785 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6786 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6787 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6788 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6789 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6790 );
6791 -- submitted : l_po_request_id
6792
6793 end if;
6794 end if;
6795 END IF;
6796 --osp end
6797
6798 -- call to infinite schedule....
6799 IF (WSMPJUPD.g_copy_mode = 0) THEN
6800 null; -- no copies
6801 ELSE
6802 l_stmt_num := 540;
6803 l_err_code := 0;
6804 l_err_buf := null;
6805
6806 CALL_INF_SCH_OR_SET_SCH_DATA( p_txn_id => null,
6807 p_copy_mode => WSMPJUPD.g_copy_mode,
6808 p_org_id => p_txn_org_id,
6809 p_par_we_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6810 x_err_code => l_err_code,
6811 x_err_buf => l_err_buf
6812 );
6813
6814 IF (l_err_code <> 0) THEN
6815 -- error out...
6816 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6817
6818 l_msg_tokens.delete;
6819 WSM_log_PVT.logMessage(p_module_name => l_module ,
6820 p_msg_text => 'CALL_INF_SCH_OR_SET_SCH_DATA returned failure:'||l_err_code,
6821 p_stmt_num => l_stmt_num ,
6822 p_msg_tokens => l_msg_tokens,
6823 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6824 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6825 p_run_log_level => l_log_level
6826 );
6827 END IF;
6828 RAISE FND_API.G_EXC_ERROR;
6829 END IF;
6830 end if;
6831
6832 l_stmt_num := 590;
6833
6834 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
6835 p_wltx_header => p_wltx_header,
6836 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
6837 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
6838 p_sj_also_rj_index => p_wltx_resulting_jobs_tbl.first,
6839 p_rep_job_index => p_wltx_starting_jobs_tbl.first,
6840 x_return_status => x_return_status ,
6841 x_msg_count => x_msg_count ,
6842 x_error_msg => x_error_msg
6843 );
6844
6845 if x_return_status <> G_RET_SUCCESS then
6846 IF x_return_status = G_RET_ERROR THEN
6847 raise FND_API.G_EXC_ERROR;
6848 ELSE
6849 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6850 END IF;
6851 end if;
6852
6853 -- p_txn_id should be known here....
6854 -- call to insert MMT....
6855 l_ret_status := FND_API.G_RET_STS_SUCCESS;
6856 l_msg_data := null;
6857
6858 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
6859 p_txn_org_id => p_txn_org_id,
6860 p_txn_date => sysdate, --l_txn_date, /* has to be txn date... */
6861 p_txn_type_id => WSMPCNST.update_quantity,
6862 p_sj_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
6863 p_sj_wip_entity_name => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name,
6864 p_sj_avail_quantity => p_wltx_starting_jobs_tbl(l_rep_sj_index).quantity_available,
6865 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
6866 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
6867 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
6868 p_sj_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
6869 p_sj_op_seq_num => p_wltx_starting_jobs_tbl(l_rep_sj_index).operation_seq_num,
6870 x_return_status => l_ret_status,
6871 x_msg_count => l_msg_count,
6872 x_msg_data => l_msg_data
6873 );
6874
6875 l_stmt_num := 390;
6876
6877 if l_ret_status <> fnd_api.g_ret_sts_success then
6878 -- error out...
6879 l_stmt_num := 395;
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 => 'Insert_MMT_record failed',
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
6895 l_stmt_num := 400;
6896
6897
6898 l_txn_status := WIP_CONSTANTS.COMPLETED;
6899 l_txn_costed := WIP_CONSTANTS.pending;
6900
6901 elsif p_wltx_header.transaction_type_id = WSMPCNST.UPDATE_LOT_NAME then
6902
6903 l_stmt_num := 550;
6904
6905 if( g_log_level_statement >= l_log_level ) then
6906 l_msg_tokens.delete;
6907 WSM_log_PVT.logMessage(p_module_name => l_module ,
6908 p_msg_text => 'Transaction type is Update Lotname:',
6909 p_stmt_num => l_stmt_num ,
6910 p_msg_tokens => l_msg_tokens,
6911 p_fnd_log_level => g_log_level_statement,
6912 p_run_log_level => l_log_level
6913 );
6914 End if;
6915
6916 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
6917 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6918
6919 if p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id is null then
6920
6921 if p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id is not null then
6922 p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id := p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id;
6923 else
6924 select wip_entity_id
6925 into p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id
6926 from wip_entities
6927 where wip_entity_name like p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_name;
6928 end if;
6929 end if;
6930
6931 l_stmt_num := 560;
6932
6933 update wip_discrete_jobs
6934 set lot_number = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
6935 description = p_wltx_resulting_jobs_tbl(l_rj_index).description,
6936 /* Start Bugfix 5531371 csi/loc is updatable in upd lot name */
6937 completion_subinventory = p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
6938 completion_locator_id = p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id
6939 /* End Bugfix 5531371*/
6940 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
6941
6942 l_stmt_num := 570;
6943
6944 update wip_entities
6945 set wip_entity_name = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
6946 description = p_wltx_resulting_jobs_tbl(l_rj_index).description
6947 where wip_entity_id = p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id;
6948
6949 l_txn_status := WIP_CONSTANTS.COMPLETED;
6950 l_txn_costed := WIP_CONSTANTS.COMPLETED;
6951
6952 elsif p_wltx_header.transaction_type_id = WSMPCNST.BONUS then
6953 if p_wltx_resulting_jobs_tbl.count > 0 then
6954 l_rj_index := p_wltx_resulting_jobs_tbl.first;
6955 else
6956 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
6957
6958 l_msg_tokens.delete;
6959 WSM_log_PVT.logMessage(p_module_name=> l_module ,
6960 p_msg_name => 'WSM_RESULT_LOT_REQUIRED',
6961 p_msg_appl_name => 'WSM',
6962 p_msg_tokens => l_msg_tokens ,
6963 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6964 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6965 p_run_log_level => l_log_level
6966 );
6967 END IF;
6968 RAISE FND_API.G_EXC_ERROR;
6969
6970 end if;
6971
6972 l_bonus_rtg_st_op_seq := p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num;
6973
6974 l_stmt_num := 55;
6975 l_err_code := 0;
6976 l_err_buf := null;
6977 --remove this
6978 if( g_log_level_statement >= l_log_level ) then
6979 l_msg_tokens.delete;
6980 WSM_log_PVT.logMessage(p_module_name => l_module ,
6981 p_msg_text => 'Calling WSMPLBJI.build_lbji_info procedure'||p_wltx_resulting_jobs_tbl(l_rj_index).class_code,
6982 p_stmt_num => l_stmt_num ,
6983 p_msg_tokens => l_msg_tokens,
6984 p_fnd_log_level => g_log_level_statement,
6985 p_run_log_level => l_log_level
6986 );
6987 End if;
6988
6989 -- Create Job Header ONLY
6990 WSMPLBJI.build_lbji_info
6991 (p_routing_seq_id => p_wltx_resulting_jobs_tbl(l_rj_index).common_routing_sequence_id,
6992 p_common_bill_sequence_id => p_wltx_resulting_jobs_tbl(l_rj_index).common_bom_sequence_id,
6993 p_explode_header_detail => null,
6994 p_status_type => WIP_CONSTANTS.RELEASED,
6995 p_class_code => p_wltx_resulting_jobs_tbl(l_rj_index).class_code,
6996 p_org => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
6997 p_wip_entity_id => l_new_we_id, -- this is returned by the API
6998 p_last_updt_date => sysdate,
6999 p_last_updt_by => g_user_id,
7000 p_creation_date => sysdate,
7001 p_created_by => g_user_id,
7002 p_last_updt_login => g_user_login_id,
7003 p_request_id => g_request_id,
7004 p_program_application_id => g_program_appl_id,
7005 p_program_id => g_program_id,
7006 p_prog_updt_date => sysdate,
7007 p_source_line_id => NULL,
7008 p_source_code => NULL,
7009 p_description => p_wltx_resulting_jobs_tbl(l_rj_index).description,
7010 p_item => p_wltx_resulting_jobs_tbl(l_rj_index).primary_item_id,
7011 p_job_type => p_wltx_resulting_jobs_tbl(l_rj_index).job_type,
7012 p_bom_reference_id => p_wltx_resulting_jobs_tbl(l_rj_index).bom_reference_id,
7013 p_routing_reference_id => p_wltx_resulting_jobs_tbl(l_rj_index).routing_reference_id,
7014 p_firm_planned_flag => 2,
7015 p_wip_supply_type => p_wltx_resulting_jobs_tbl(l_rj_index).wip_supply_type,
7016 p_fusd => p_wltx_resulting_jobs_tbl(l_rj_index).scheduled_start_date,
7017 p_lucd => p_wltx_resulting_jobs_tbl(l_rj_index).scheduled_completion_date,
7018 p_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
7019 p_net_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity,
7020 p_coproducts_supply => p_wltx_resulting_jobs_tbl(l_rj_index).coproducts_supply,
7021 p_bom_revision => p_wltx_resulting_jobs_tbl(l_rj_index).bom_revision,
7022 p_routing_revision => p_wltx_resulting_jobs_tbl(l_rj_index).routing_revision,
7023 p_bom_revision_date => p_wltx_resulting_jobs_tbl(l_rj_index).bom_revision_date,
7024 p_routing_revision_date => p_wltx_resulting_jobs_tbl(l_rj_index).routing_revision_date,
7025 p_lot_number => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7026 p_alt_bom_designator => p_wltx_resulting_jobs_tbl(l_rj_index).alternate_bom_designator,
7027 p_alt_routing_designator => p_wltx_resulting_jobs_tbl(l_rj_index).alternate_routing_designator,
7028 p_priority => NULL,
7029 p_due_date => NULL,
7030
7031 p_attribute_category => p_wltx_resulting_jobs_tbl(l_rj_index).attribute_category,
7032 p_attribute1 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute1,
7033 p_attribute2 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute2,
7034 p_attribute3 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute3,
7035 p_attribute4 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute4,
7036 p_attribute5 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute5,
7037 p_attribute6 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute6,
7038 p_attribute7 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute7,
7039 p_attribute8 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute8,
7040 p_attribute9 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute9,
7041 p_attribute10 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute10,
7042 p_attribute11 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute11,
7043 p_attribute12 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute12,
7044 p_attribute13 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute13,
7045 p_attribute14 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute14,
7046 p_attribute15 => p_wltx_resulting_jobs_tbl(l_rj_index).attribute15,
7047
7048 p_job_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7049 p_completion_subinventory => p_wltx_resulting_jobs_tbl(l_rj_index).completion_subinventory,
7050 p_completion_locator_id => p_wltx_resulting_jobs_tbl(l_rj_index).completion_locator_id,
7051 p_demand_class => null,
7052 p_project_id => NULL,
7053 p_task_id => NULL,
7054 p_schedule_group_id => NULL,
7055 p_build_sequence => NULL,
7056 p_line_id => NULL,
7057 p_kanban_card_id => NULL,
7058 p_overcompl_tol_type => NULL,
7059 p_overcompl_tol_value => NULL,
7060 p_end_item_unit_number => NULL,
7061 p_rtg_op_seq_num => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7062 p_src_client_server => 1,
7063 p_po_creation_time => l_po_creation_time,
7064 p_date_released => p_wltx_header.transaction_date, --bug 4101117
7065 p_error_code => l_err_code,
7066 p_error_msg => l_err_buf
7067 );
7068
7069 l_stmt_num := 70;
7070
7071 IF (l_err_code <> 0) THEN
7072 --remove this
7073 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7074
7075 l_msg_tokens.delete;
7076 WSM_log_PVT.logMessage(p_module_name => l_module ,
7077 p_msg_text => 'Returned failure from WSMPLBJI.build_lbji_info procedure'||l_err_buf,
7078 p_stmt_num => l_stmt_num ,
7079 p_msg_tokens => l_msg_tokens,
7080 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7081 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7082 p_run_log_level => l_log_level
7083 );
7084 END IF;
7085 RAISE FND_API.G_EXC_ERROR;
7086 ELSE
7087 -- success... now the program would have returned the id ....
7088 if( g_log_level_statement >= l_log_level ) then
7089 l_msg_tokens.delete;
7090 WSM_log_PVT.logMessage(p_module_name => l_module ,
7091 p_msg_text => 'Returned successfully from WSMPLBJI.build_lbji_info procedure',
7092 p_stmt_num => l_stmt_num ,
7093 p_msg_tokens => l_msg_tokens,
7094 p_fnd_log_level => g_log_level_statement,
7095 p_run_log_level => l_log_level
7096 );
7097 End if;
7098 p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id := l_new_we_id;
7099 END IF;
7100
7101
7102 /*call creat wsor_wlbj_records*/
7103 l_stmt_num := 80;
7104 l_err_code := 0;
7105 l_err_buf := null;
7106
7107 CREATE_WSOR_WLBJ_RECORDS( p_wip_entity_id => l_new_we_id,
7108 p_org_id => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7109 p_only_wo_op_seq => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num, -- Create only this record
7110 p_last_update_date => sysdate,
7111 p_last_updated_by => g_user_id,
7112 p_last_update_login => g_user_login_id,
7113 p_creation_date => sysdate,
7114 p_created_by => g_user_id,
7115 p_request_id => g_request_id,
7116 p_program_app_id => g_program_appl_id,
7117 p_program_id => g_program_id,
7118 p_program_update_date => sysdate,
7119 x_err_code => l_err_code,
7120 x_err_buf => l_err_buf
7121 );
7122
7123
7124 IF (l_err_code <> 0) THEN
7125 if( g_log_level_statement >= l_log_level ) then
7126
7127 l_msg_tokens.delete;
7128 WSM_log_PVT.logMessage(p_module_name => l_module ,
7129 p_msg_text => 'Returned failure from CREATE_WSOR_WLBJ_RECORDS',
7130 p_stmt_num => l_stmt_num ,
7131 p_msg_tokens => l_msg_tokens,
7132 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7133 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7134 p_run_log_level => l_log_level
7135 );
7136 END IF;
7137 RAISE FND_API.G_EXC_ERROR;
7138 ELSE
7139 if( g_log_level_statement >= l_log_level ) then
7140 l_msg_tokens.delete;
7141 WSM_log_PVT.logMessage(p_module_name => l_module ,
7142 p_msg_text => 'Created WSOR records for new job with id='||l_new_we_id,
7143 p_stmt_num => l_stmt_num ,
7144 p_msg_tokens => l_msg_tokens,
7145 p_fnd_log_level => g_log_level_statement,
7146 p_run_log_level => l_log_level
7147 );
7148 End if;
7149 END IF;
7150
7151 l_stmt_num := 90;
7152
7153 /* assign the job seq num*/
7154 SELECT max(operation_seq_num)
7155 INTO l_bonus_job_st_op_seq
7156 FROM wip_operations
7157 WHERE wip_entity_id = l_new_we_id;
7158
7159 p_wltx_resulting_jobs_tbl(l_rj_index).job_operation_seq_num := l_bonus_job_st_op_seq;
7160
7161 if( g_log_level_statement >= l_log_level ) then
7162 l_msg_tokens.delete;
7163 WSM_log_PVT.logMessage(p_module_name => l_module ,
7164 p_msg_text => 'Updated the job seq num in resulting job record : ' || l_bonus_job_st_op_seq,
7165 p_stmt_num => l_stmt_num ,
7166 p_msg_tokens => l_msg_tokens,
7167 p_fnd_log_level => g_log_level_statement,
7168 p_run_log_level => l_log_level
7169 );
7170 End if;
7171
7172 l_stmt_num := 100;
7173 UPDATE wip_operations
7174 SET wsm_op_seq_num = l_bonus_rtg_st_op_seq
7175 WHERE wip_entity_id = l_new_we_id
7176 AND operation_seq_num = l_bonus_job_st_op_seq;
7177
7178 if( g_log_level_statement >= l_log_level ) then
7179 l_msg_tokens.delete;
7180 WSM_log_PVT.logMessage(p_module_name => l_module ,
7181 p_msg_text => 'Updated the op seq num in wip_operations',
7182 p_stmt_num => l_stmt_num,
7183 p_msg_tokens => l_msg_tokens,
7184 p_fnd_log_level => g_log_level_statement,
7185 p_run_log_level => l_log_level
7186 );
7187 End if;
7188
7189 /*insert into WLBJ here as not handled in new CREATE_WSOR_WLBJ_RECORDS,the new MES columns are also handled here*/
7190 l_stmt_num:=105;
7191
7192 INSERT into WSM_LOT_BASED_JOBS
7193 (WIP_ENTITY_ID,
7194 ORGANIZATION_ID,
7195 ON_REC_PATH,
7196 INTERNAL_COPY_TYPE,
7197 COPY_PARENT_WIP_ENTITY_ID,
7198 INFINITE_SCHEDULE,
7199 CURRENT_JOB_OP_SEQ_NUM, --MES add
7200 CURRENT_RTG_OP_SEQ_NUM, --MES add
7201 LAST_UPDATE_DATE,
7202 LAST_UPDATED_BY,
7203 LAST_UPDATE_LOGIN,
7204 CREATION_DATE,
7205 CREATED_BY,
7206 REQUEST_ID,
7207 PROGRAM_APPLICATION_ID,
7208 PROGRAM_ID,
7209 PROGRAM_UPDATE_DATE
7210 )
7211 VALUES
7212 (p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
7213 p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7214 'Y', -- ON_REC_PATH
7215 0,
7216 NULL, -- COPY_PARENT_WIP_ENTITY_ID
7217 NULL, -- INFINITE_SCHEDULE
7218 p_wltx_resulting_jobs_tbl(l_rj_index).job_operation_seq_num,
7219 p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7220 sysdate,
7221 g_user_id,
7222 g_user_login_id,
7223 sysdate,
7224 g_user_id,
7225 g_request_id,
7226 g_program_appl_id,
7227 g_program_id,
7228 sysdate
7229 );
7230
7231 l_stmt_num := 110;
7232
7233 if( g_log_level_statement >= l_log_level ) then
7234 l_msg_tokens.delete;
7235 WSM_log_PVT.logMessage(p_module_name => l_module ,
7236 p_msg_text => 'Checking for open a/c period',
7237 p_stmt_num => l_stmt_num,
7238 p_msg_tokens => l_msg_tokens,
7239 p_fnd_log_level => g_log_level_statement,
7240 p_run_log_level => l_log_level
7241 );
7242 End if;
7243
7244 /*check for open accounting period*/
7245 l_stmt_num := 120;
7246 l_acct_period_id := -1;
7247 l_err_code := -1;
7248 l_err_buf := null;
7249
7250 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);
7251
7252 IF (l_err_code <> 0) THEN
7253 /*error out*/
7254 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7255
7256 l_msg_tokens.delete;
7257 WSM_log_PVT.logMessage(p_module_name => l_module ,
7258 p_msg_text => 'Accounting Period not open',
7259 p_stmt_num => l_stmt_num ,
7260 p_msg_tokens => l_msg_tokens,
7261 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7262 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7263 p_run_log_level => l_log_level
7264 );
7265 END IF;
7266 RAISE FND_API.G_EXC_ERROR;
7267 END IF;
7268
7269 l_stmt_num := 130;
7270 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7271 l_msg_count := 0;
7272 l_msg_data := null;
7273
7274 if( g_log_level_statement >= l_log_level ) then
7275 l_msg_tokens.delete;
7276 WSM_log_PVT.logMessage(p_module_name => l_module ,
7277 p_msg_text => 'Inserting MMT record',
7278 p_stmt_num => l_stmt_num,
7279 p_msg_tokens => l_msg_tokens,
7280 p_fnd_log_level => g_log_level_statement,
7281 p_run_log_level => l_log_level
7282 );
7283 End if;
7284
7285 Insert_MMT_record ( p_txn_id => p_wltx_header.transaction_id,
7286 p_txn_org_id => p_wltx_resulting_jobs_tbl(l_rj_index).organization_id,
7287 p_txn_date => p_wltx_header.transaction_date,--sysdate, --l_txn_date,
7288 p_txn_type_id => p_wltx_header.transaction_type_id,
7289 p_sj_wip_entity_id => null,
7290 p_sj_wip_entity_name => null,
7291 p_sj_avail_quantity => null,
7292 p_rj_wip_entity_id => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_id,
7293 p_rj_wip_entity_name => p_wltx_resulting_jobs_tbl(l_rj_index).wip_entity_name,
7294 p_rj_start_quantity => p_wltx_resulting_jobs_tbl(l_rj_index).start_quantity,
7295 p_sj_item_id => p_wltx_resulting_jobs_tbl(l_rj_index).primary_item_id,
7296 p_sj_op_seq_num => p_wltx_resulting_jobs_tbl(l_rj_index).starting_operation_seq_num,
7297 x_return_status => l_ret_status,
7298 x_msg_count => l_msg_count,
7299 x_msg_data => l_msg_data
7300 );
7301 if l_ret_status <> fnd_api.g_ret_sts_success then
7302 -- error out...
7303 l_stmt_num := 395;
7304 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7305
7306 l_msg_tokens.delete;
7307 WSM_log_PVT.logMessage(p_module_name => l_module ,
7308 p_msg_text => 'Insert_MMT_record failed:'||l_msg_data,
7309 p_stmt_num => l_stmt_num ,
7310 p_msg_tokens => l_msg_tokens,
7311 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7312 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7313 p_run_log_level => l_log_level
7314 );
7315 END IF;
7316 RAISE FND_API.G_EXC_ERROR;
7317 end if;
7318
7319 l_stmt_num := 140;
7320 l_err_code := 0;
7321 l_err_buf := null;
7322
7323 CREATE_COPIES_OR_SET_COPY_DATA (p_txn_id => null,
7324 p_txn_type_id => p_wltx_header.transaction_type_id,
7325 p_copy_mode => WSMPJUPD.g_copy_mode,
7326 p_rep_sj_index => null,
7327 p_sj_as_rj_index => l_rj_index,
7328 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7329 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7330 x_err_code => l_err_code,
7331 x_err_buf => l_err_buf,
7332 x_msg_count => x_msg_count
7333 );
7334
7335 IF (l_err_code <> 0) THEN
7336 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7337
7338 l_msg_tokens.delete;
7339 WSM_log_PVT.logMessage(p_module_name => l_module ,
7340 p_msg_text => 'CREATE_COPIES_OR_SET_COPY_DATA returned failure ' || l_err_buf,
7341 p_stmt_num => l_stmt_num ,
7342 p_msg_tokens => l_msg_tokens,
7343 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7344 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7345 p_run_log_level => l_log_level
7346 );
7347 END IF;
7348 RAISE FND_API.G_EXC_ERROR; --x_err_code has errcode, x_err_buf has the error message
7349 END IF;
7350
7351 -- Begin MES changes
7352 -- Commented out due to insufficient data in sec qty table due to which txns r failing-to be uncommented
7353
7354 l_stmt_num := 150;
7355
7356 process_mes_info ( p_secondary_qty_tbl => p_secondary_qty_tbl,
7357 p_wltx_header => p_wltx_header,
7358 p_wltx_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7359 p_wltx_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7360 p_sj_also_rj_index => null,
7361 p_rep_job_index => null,
7362 x_return_status => x_return_status ,
7363 x_msg_count => x_msg_count ,
7364 x_error_msg => x_error_msg
7365 );
7366 if x_return_status <> G_RET_SUCCESS then
7367 IF x_return_status = G_RET_ERROR THEN
7368 raise FND_API.G_EXC_ERROR;
7369 ELSE
7370 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7371 END IF;
7372 end if;
7373
7374 -- End MES changes--
7375 l_stmt_num := 400;
7376
7377 l_txn_status := WIP_CONSTANTS.COMPLETED;
7378 l_txn_costed := WIP_CONSTANTS.pending;
7379
7380 else
7381 -- error out....
7382 IF G_LOG_LEVEL_ERROR >= l_log_level OR FND_MSG_PUB.check_msg_level(g_msg_lvl_error) THEN
7383
7384 l_msg_tokens.delete;
7385 WSM_log_PVT.logMessage(p_module_name => l_module ,
7386 p_msg_text => 'Invalid Txn type',
7387 p_stmt_num => l_stmt_num ,
7388 p_msg_tokens => l_msg_tokens,
7389 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7390 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7391 p_run_log_level => l_log_level
7392 );
7393 END IF;
7394 raise FND_API.G_EXC_ERROR;
7395 end if;
7396
7397
7398 l_stmt_num := 500;
7399 --Start Sales Order LBJ Reservation Changes -- (Commented out as waiting for INV Changes
7400 If p_wltx_header.transaction_type_id in (WSMPCNST.SPLIT,WSMPCNST.UPDATE_ASSEMBLY,
7401 WSMPCNST.UPDATE_QUANTITY,WSMPCNST.UPDATE_ROUTING,WSMPCNST.UPDATE_LOT_NAME) then
7402 l_rep_sj_index := p_wltx_starting_jobs_tbl.first;
7403 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,
7404 P_org_id => p_wltx_header.organization_id,
7405 P_inventory_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id
7406 ) ;
7407 If l_rsv_exists then
7408 l_stmt_num := 510;
7409 If p_wltx_header.transaction_type_id in (WSMPCNST.UPDATE_QUANTITY,WSMPCNST.UPDATE_ROUTING,WSMPCNST.UPDATE_LOT_NAME) then
7410 l_rj_index := p_wltx_resulting_jobs_tbl.first;
7411 l_stmt_num := 520;
7412 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7413 l_msg_count := 0;
7414 l_msg_data := null;
7415 WSM_RESERVATIONS_PVT.Modify_reservations_jobupdate(p_wip_entity_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).wip_entity_id,
7416 P_old_net_qty => p_wltx_starting_jobs_tbl(l_rep_sj_index).net_quantity,
7417 P_new_net_qty => p_wltx_resulting_jobs_tbl(l_rj_index).net_quantity,
7418 P_inventory_item_id => p_wltx_starting_jobs_tbl(l_rep_sj_index).primary_item_id,
7419 P_org_id => p_wltx_header.organization_id,
7420 P_status_type => p_wltx_resulting_jobs_tbl(l_rj_index).status_type,
7421 x_return_status => l_ret_status,
7422 x_msg_count => l_msg_count,
7423 x_msg_data => l_msg_data
7424 ); --this is to handle the change in net qty if any.
7425
7426 if l_ret_status <> fnd_api.g_ret_sts_success then
7427 -- error out...
7428
7429 if( g_log_level_statement >= l_log_level ) then
7430
7431 l_msg_tokens.delete;
7432 WSM_log_PVT.logMessage(p_module_name => l_module ,
7433 p_msg_text => 'WSM_RESERVATIONS_PVT.Modify_reservations_jobupdate failed:'||l_msg_data,
7434 p_stmt_num => l_stmt_num ,
7435 p_msg_tokens => l_msg_tokens,
7436 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7437 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7438 p_run_log_level => l_log_level
7439 );
7440 END IF;
7441 RAISE FND_API.G_EXC_ERROR;
7442 END IF;
7443 Else
7444 --Split,SpUA and Update Assembly transaction
7445 l_stmt_num := 530;
7446 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7447 l_msg_count := 0;
7448 l_msg_data := null;
7449 WSM_RESERVATIONS_PVT.modify_reservations_wlt (
7450 p_txn_header => p_wltx_header,
7451 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7452 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7453 p_rep_job_index => 1,--l_ rep_job_index,
7454 p_sj_also_rj_index => l_sj_also_rj_index,
7455 x_return_status => l_ret_status,
7456 x_msg_count => l_msg_count,
7457 x_msg_data => l_msg_data) ;
7458 if l_ret_status <> fnd_api.g_ret_sts_success then
7459 -- error out...
7460 if( g_log_level_statement >= l_log_level ) then
7461
7462 l_msg_tokens.delete;
7463 WSM_log_PVT.logMessage(p_module_name => l_module ,
7464 p_msg_text => 'WSM_RESERVATIONS_PVT.modify_reservations_wlt failed:'||l_msg_data,
7465 p_stmt_num => l_stmt_num ,
7466 p_msg_tokens => l_msg_tokens,
7467 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7468 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7469 p_run_log_level => l_log_level
7470 );
7471 END IF;
7472 --To be reverted
7473 RAISE FND_API.G_EXC_ERROR;
7474 end if;
7475 End if;
7476 End if;
7477 elsif p_wltx_header.transaction_type_id in (WSMPCNST.MERGE) then
7478 l_stmt_num := 540;
7479 l_ret_status := FND_API.G_RET_STS_SUCCESS;
7480 l_msg_count := 0;
7481 l_msg_data := null;
7482 WSM_RESERVATIONS_PVT.modify_reservations_wlt (
7483 p_txn_header => p_wltx_header,
7484 p_starting_jobs_tbl => p_wltx_starting_jobs_tbl,
7485 p_resulting_jobs_tbl => p_wltx_resulting_jobs_tbl,
7486 p_rep_job_index => l_rep_sj_index,
7487 p_sj_also_rj_index => l_sj_also_rj_index,
7488 x_return_status => l_ret_status,
7489 x_msg_count => l_msg_count,
7490 x_msg_data => l_msg_data) ;
7491 if l_ret_status <> fnd_api.g_ret_sts_success then
7492 -- error out...
7493 l_stmt_num := 200;
7494 if( g_log_level_statement >= l_log_level ) then
7495
7496 l_msg_tokens.delete;
7497 WSM_log_PVT.logMessage(p_module_name => l_module ,
7498 p_msg_text => 'WSM_RESERVATIONS_PVT.modify_reservations_wlt failed:'||l_msg_data,
7499 p_stmt_num => l_stmt_num ,
7500 p_msg_tokens => l_msg_tokens,
7501 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7502 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7503 p_run_log_level => l_log_level
7504 );
7505 END IF;
7506 --To be reverted
7507 --RAISE FND_API.G_EXC_ERROR;
7508 end if;
7509 End if;
7510 --End Sales Order LBJ Reservation Changes--
7511
7512 -- to take care of phantoms...
7513 DELETE FROM BOM_EXPLOSION_TEMP
7514 WHERE GROUP_ID = WSMPWROT.EXPLOSION_GROUP_ID;
7515
7516 WSMPWROT.EXPLOSION_GROUP_ID := NULL;
7517 WSMPWROT.USE_PHANTOM_ROUTINGS := NULL;
7518 -- end to take care of phantoms--
7519
7520 EXCEPTION
7521
7522 WHEN FND_API.G_EXC_ERROR THEN
7523 x_return_status := FND_API.G_RET_STS_ERROR ;
7524
7525 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7526 p_count => x_msg_count ,
7527 p_data => x_error_msg
7528 );
7529
7530 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7531
7532 x_return_status := G_RET_UNEXPECTED;
7533
7534 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7535 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7536 THEN
7537 WSM_log_PVT.handle_others( p_module_name => l_module ,
7538 p_stmt_num => l_stmt_num ,
7539 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7540 p_run_log_level => l_log_level
7541 );
7542 END IF;
7543
7544 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7545 p_count => x_msg_count ,
7546 p_data => x_error_msg
7547 );
7548 WHEN OTHERS THEN
7549
7550 x_return_status := G_RET_UNEXPECTED;
7551
7552 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7553 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7554 THEN
7555 WSM_log_PVT.handle_others( p_module_name => l_module ,
7556 p_stmt_num => l_stmt_num ,
7557 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7558 p_run_log_level => l_log_level
7559 );
7560 END IF;
7561
7562 FND_MSG_PUB.Count_And_Get (p_encoded => 'F' ,
7563 p_count => x_msg_count ,
7564 p_data => x_error_msg
7565 );
7566
7567 end PROCESS_LOTS;
7568
7569 END WSMPJUPD;