[Home] [Help]
PACKAGE BODY: APPS.WSM_SERIAL_SUPPORT_PVT
Source
1 PACKAGE BODY WSM_Serial_support_PVT AS
2 /* $Header: WSMVSERB.pls 120.26 2006/09/08 00:55:22 nlal noship $ */
3
4
5 type t_contorl_code is table of number index by varchar2(200);
6 -- We'll store the serial control code information as g_serial_ctl_code('ItemId_Organization_id') := 1;
7 -- Global table to store the serial control code...
8
9 g_serial_ctl_code t_contorl_code;
10 g_user_id NUMBER := FND_GLOBAL.USER_ID;
11
12 g_user_name FND_USER.USER_NAME%TYPE := FND_GLOBAL.USER_NAME;
13 g_user_login_id NUMBER := FND_GLOBAL.LOGIN_ID;
14 g_program_appl_id NUMBER := FND_GLOBAL.PROG_APPL_ID;
15 g_request_id NUMBER := FND_GLOBAL.CONC_REQUEST_ID;
16 g_program_id NUMBER := FND_GLOBAL.CONC_PROGRAM_ID;
17 g_wms_installed NUMBER;
18
19 g_log_level_unexpected NUMBER := FND_LOG.LEVEL_UNEXPECTED ;
20 g_log_level_error number := FND_LOG.LEVEL_ERROR ;
21 g_log_level_exception number := FND_LOG.LEVEL_EXCEPTION ;
22 g_log_level_event number := FND_LOG.LEVEL_EVENT ;
23 g_log_level_procedure number := FND_LOG.LEVEL_PROCEDURE ;
24 g_log_level_statement number := FND_LOG.LEVEL_STATEMENT ;
25
26 g_msg_lvl_unexp_error NUMBER := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR ;
27 g_msg_lvl_error NUMBER := FND_MSG_PUB.G_MSG_LVL_ERROR ;
28 g_msg_lvl_success NUMBER := FND_MSG_PUB.G_MSG_LVL_SUCCESS ;
29 g_msg_lvl_debug_high NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH ;
30 g_msg_lvl_debug_medium NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM ;
31 g_msg_lvl_debug_low NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW ;
32
33 g_ret_success VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
34 g_ret_error VARCHAR2(1) := FND_API.G_RET_STS_ERROR;
35 g_ret_unexpected VARCHAR2(1) := FND_API.G_RET_STS_UNEXP_ERROR;
36
37
38 --______________________________________________________________________________________________
39 -- Forward declaration section....----------------------------------------------------------------
40
41 -- Serial Processor for LBJ Interface
42 Procedure LBJ_serial_processor ( p_calling_mode IN NUMBER,
43 p_wsm_serial_nums_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
44 p_wip_entity_id IN NUMBER,
45 p_organization_id IN NUMBER,
46 p_inventory_item_id IN NUMBER,
47 x_return_status OUT NOCOPY VARCHAR2,
48 x_error_msg OUT NOCOPY VARCHAR2,
49 x_error_count OUT NOCOPY NUMBER
50 );
51
52 -- Obtain serial information for a job
53 Procedure get_serial_track_info ( p_serial_item_id IN NUMBER,
54 p_organization_id IN NUMBER,
55 p_wip_entity_id IN NUMBER,
56 x_serial_start_flag OUT NOCOPY NUMBER,
57 x_serial_ctrl_code OUT NOCOPY NUMBER,
58 x_first_serial_txn_id OUT NOCOPY NUMBER,
59 x_serial_start_op OUT NOCOPY NUMBER,
60 x_return_status OUT NOCOPY VARCHAR2,
61 x_error_msg OUT NOCOPY VARCHAR2,
62 x_error_count OUT NOCOPY NUMBER
63 );
64
65 -- Handles processing (asscoiating, delinking, updating, generation)
66 Procedure process_serial_info ( p_calling_mode IN NUMBER,
67 p_wsm_serial_nums_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
68 p_wip_entity_id IN NUMBER,
69 p_serial_start_flag IN NUMBER,
70 p_organization_id IN NUMBER,
71 p_item_id IN NUMBER,
72 -- Indicates that this call is made for update qty transaction....
73 p_wlt_upd_qty_txn IN NUMBER DEFAULT NULL,
74 p_operation_seq_num IN NUMBER DEFAULT NULL,
75 p_intraoperation_step IN NUMBER DEFAULT NULL,
76 -- This PL/SQL table parameter would return the serial numbers added/generated and added..
77 -- We need this information to insert into WSM_SERIAL_TRANSACTIONS
78 x_serial_tbl OUT NOCOPY t_varchar2,
79 x_return_status OUT NOCOPY VARCHAR2,
80 x_error_msg OUT NOCOPY VARCHAR2,
81 x_error_count OUT NOCOPY NUMBER
82 );
83
84 -- Generate and associate a serial number or else associate if already exisitng
85 Procedure add_assoc_serial_number(p_calling_mode IN NUMBER,
86 p_serial_number_rec IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_REC,
87 p_wip_entity_id IN NUMBER,
88 p_gen_serial_flag IN NUMBER,
89 p_organization_id IN NUMBER,
90 p_inventory_item_id IN NUMBER,
91 p_operation_seq_num IN NUMBER DEFAULT NULL,
92 p_intraoperation_step IN NUMBER DEFAULT NULL,
93 x_serial_number OUT NOCOPY VARCHAR2,
94 x_return_status OUT NOCOPY VARCHAR2,
95 x_error_msg OUT NOCOPY VARCHAR2,
96 x_error_count OUT NOCOPY NUMBER
97 );
98
99 -- Generate and associate a serial number or else associate if already exisitng
100 Procedure add_serial_number ( p_assembly_item_id IN NUMBER,
101 p_organization_id IN NUMBER,
102 p_wip_entity_id IN NUMBER,
103 p_new_serial_number IN NUMBER DEFAULT NULL,
104 p_serial_number IN OUT NOCOPY VARCHAR2,
105 x_return_status OUT NOCOPY VARCHAR2,
106 x_error_msg OUT NOCOPY VARCHAR2,
107 x_error_count OUT NOCOPY NUMBER
108 );
109
110
111 PROCEDURE update_serial_attr ( p_calling_mode IN NUMBER,
112 p_serial_number_rec IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_REC,
113 p_inventory_item_id IN NUMBER,
114 p_organization_id IN NUMBER,
115 p_clear_serial_attr IN NUMBER DEFAULT NULL, -- will be used in case of WLT SpUA to clear the attributes
116 p_wlt_txn_type IN NUMBER DEFAULT NULL,
117 -- Pass the serial attribute context corresponding to the inventory item id
118 p_serial_attr_context IN VARCHAR2 DEFAULT NULL,
119 p_update_serial_attr IN NUMBER,
120 p_update_desc_attr IN NUMBER,
121 x_return_status OUT NOCOPY VARCHAR2,
122 x_error_count OUT NOCOPY NUMBER,
123 x_error_msg OUT NOCOPY VARCHAR2
124 );
125
126 Procedure wms_installed ( x_return_status OUT NOCOPY VARCHAR2,
127 x_error_count OUT NOCOPY NUMBER ,
128 x_err_data OUT NOCOPY VARCHAR2
129 );
130
131 -- Expected i/p is the header id of the Move Transaction...
132 -- All the qty information to be passed in the primary UOM only...
133 Procedure Move_serial_processor ( p_calling_mode IN NUMBER,
134 p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
135 p_move_txn_type IN NUMBER,
136 p_wip_entity_id IN NUMBER,
137 p_organization_id IN NUMBER,
138 p_inventory_item_id IN NUMBER,
139 p_move_qty IN NUMBER,
140 p_scrap_qty IN NUMBER,
141 p_available_qty IN NUMBER,
142 p_curr_job_op_seq_num IN NUMBER,
143 p_curr_job_intraop_step IN NUMBER,
144 p_from_rtg_op_seq_num IN NUMBER,
145 p_to_rtg_op_seq_num IN NUMBER,
146 p_to_intraoperation_step IN NUMBER,
147 p_job_serial_start_op IN NUMBER,
148 p_user_serial_tracking IN NUMBER,
149 p_move_txn_id IN NUMBER,
150 p_scrap_txn_id IN NUMBER,
151 p_old_move_txn_id IN NUMBER,
152 p_old_scrap_txn_id IN NUMBER,
153 p_jump_flag IN varchar2 DEFAULT NULL,
154 p_scrap_at_operation IN NUMBER DEFAULT NULL,
155 -- ST : Fix for bug 5140761 Addded the above parameter --
156 x_serial_track_flag IN OUT NOCOPY NUMBER,
157 x_return_status OUT NOCOPY VARCHAR2,
158 x_error_msg OUT NOCOPY VARCHAR2,
159 x_error_count OUT NOCOPY NUMBER
160 );
161
162 Procedure check_move_serial_qty( p_calling_mode IN NUMBER,
163 p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
164 p_move_txn_type IN NUMBER,
165 p_wip_entity_id IN NUMBER,
166 p_inventory_item_id IN NUMBER,
167 p_organization_id IN NUMBER,
168 p_move_qty IN NUMBER,
169 p_scrap_qty IN NUMBER,
170 p_available_qty IN NUMBER,
171 p_curr_job_op_seq_num IN NUMBER,
172 p_curr_job_intraop_step IN NUMBER,
173 p_job_serial_start_op IN NUMBER,
174 p_from_rtg_op_seq_num IN NUMBER,
175 p_to_rtg_op_seq_num IN NUMBER,
176 p_to_intraoperation_step IN NUMBER,
177 p_user_serial_tracking IN NUMBER,
178 p_move_txn_id IN NUMBER,
179 p_scrap_txn_id IN NUMBER,
180 p_jump_flag IN varchar2 DEFAULT NULL,
181 p_scrap_at_operation IN NUMBER DEFAULT NULL,
182 -- ST : Fix for bug 5140761 Addded the above parameter --
183 x_serial_track_flag IN OUT NOCOPY NUMBER,
184 x_return_status OUT NOCOPY VARCHAR2,
185 x_error_msg OUT NOCOPY VARCHAR2,
186 x_error_count OUT NOCOPY NUMBER
187 );
188
189 -- Populate serial numbers for undo transactions..
190 Procedure populate_undo_txn ( p_move_txn_type IN NUMBER,
191 p_wip_entity_id IN NUMBER,
192 p_inventory_item_id IN NUMBER,
193 p_organization_id IN NUMBER,
194 p_move_qty IN NUMBER,
195 p_scrap_qty IN NUMBER,
196 p_new_move_txn_id IN NUMBER,
197 p_new_scrap_txn_id IN NUMBER,
198 p_old_move_txn_id IN NUMBER DEFAULT NULL,
199 p_old_scrap_txn_id IN NUMBER DEFAULT NULL,
200 x_return_status OUT NOCOPY VARCHAR2,
201 x_error_msg OUT NOCOPY VARCHAR2,
202 x_error_count OUT NOCOPY NUMBER
203 );
204
205 -- Procedure to dump the serial records' data....
206 Procedure log_serial_data ( p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL ,
207 x_return_status OUT NOCOPY VARCHAR2 ,
208 x_error_msg OUT NOCOPY VARCHAR2 ,
209 x_error_count OUT NOCOPY NUMBER
210 );
211
212 /*______________________________________________________________________________________________*/
213
214
215 --------------------------------------------------------------------------------------------------
216 Procedure LBJ_serial_intf_proc( p_header_id IN NUMBER,
217 p_wip_entity_id IN NUMBER,
218 p_organization_id IN NUMBER,
219 p_inventory_item_id IN NUMBER,
220 x_return_status OUT NOCOPY VARCHAR2,
221 x_error_count OUT NOCOPY NUMBER,
222 x_error_msg OUT NOCOPY VARCHAR2
223 )
224 IS
225 l_miss_char VARCHAR2(1) := FND_API.G_MISS_CHAR;
226 l_null_num NUMBER := FND_API.G_NULL_NUM;
227 l_null_date DATE := FND_API.G_NULL_DATE;
228 l_null_char VARCHAR2(1) := FND_API.G_NULL_CHAR;
229
230 cursor c_lbj_serials is
231 select
232 wsti.Serial_Number ,
233 null , -- assembly_item_id
234 wsti.header_id , -- header_id
235 wsti.Generate_serial_number ,
236 wsti.Generate_for_qty ,
237 wsti.Action_flag ,
238 wsti.Current_wip_entity_name ,
239 wsti.Changed_wip_entity_name ,
240 wsti.Current_wip_entity_id ,
241 wsti.Changed_wip_entity_id ,
242 decode(wsti.serial_attribute_category , l_null_char, null, null, msn.serial_attribute_category, wsti.serial_attribute_category), -- serial_attribute_category
243 decode(wsti.territory_code , l_null_char, null, null, msn.territory_code , wsti.territory_code ), -- territory_code
244 decode(wsti.origination_date , l_null_date, null, null, msn.origination_date , wsti.origination_date ), -- origination_date
245 decode(wsti.c_attribute1 , l_null_char, null, null, msn.c_attribute1 , wsti.c_attribute1 ), -- c_attribute1
246 decode(wsti.c_attribute2 , l_null_char, null, null, msn.c_attribute2 , wsti.c_attribute2 ), -- c_attribute2
247 decode(wsti.c_attribute3 , l_null_char, null, null, msn.c_attribute3 , wsti.c_attribute3 ), -- c_attribute3
248 decode(wsti.c_attribute4 , l_null_char, null, null, msn.c_attribute4 , wsti.c_attribute4 ), -- c_attribute4
249 decode(wsti.c_attribute5 , l_null_char, null, null, msn.c_attribute5 , wsti.c_attribute5 ), -- c_attribute5
250 decode(wsti.c_attribute6 , l_null_char, null, null, msn.c_attribute6 , wsti.c_attribute6 ), -- c_attribute6
251 decode(wsti.c_attribute7 , l_null_char, null, null, msn.c_attribute7 , wsti.c_attribute7 ), -- c_attribute7
252 decode(wsti.c_attribute8 , l_null_char, null, null, msn.c_attribute8 , wsti.c_attribute8 ), -- c_attribute8
253 decode(wsti.c_attribute9 , l_null_char, null, null, msn.c_attribute9 , wsti.c_attribute9 ), -- c_attribute9
254 decode(wsti.c_attribute10 , l_null_char, null, null, msn.c_attribute10 , wsti.c_attribute10 ), -- c_attribute10
255 decode(wsti.c_attribute11 , l_null_char, null, null, msn.c_attribute11 , wsti.c_attribute11 ), -- c_attribute11
256 decode(wsti.c_attribute12 , l_null_char, null, null, msn.c_attribute12 , wsti.c_attribute12 ), -- c_attribute12
257 decode(wsti.c_attribute13 , l_null_char, null, null, msn.c_attribute13 , wsti.c_attribute13 ), -- c_attribute13
258 decode(wsti.c_attribute14 , l_null_char, null, null, msn.c_attribute14 , wsti.c_attribute14 ), -- c_attribute14
259 decode(wsti.c_attribute15 , l_null_char, null, null, msn.c_attribute15 , wsti.c_attribute15 ), -- c_attribute15
260 decode(wsti.c_attribute16 , l_null_char, null, null, msn.c_attribute16 , wsti.c_attribute16 ), -- c_attribute16
261 decode(wsti.c_attribute17 , l_null_char, null, null, msn.c_attribute17 , wsti.c_attribute17 ), -- c_attribute17
262 decode(wsti.c_attribute18 , l_null_char, null, null, msn.c_attribute18 , wsti.c_attribute18 ), -- c_attribute18
263 decode(wsti.c_attribute19 , l_null_char, null, null, msn.c_attribute19 , wsti.c_attribute19 ), -- c_attribute19
264 decode(wsti.c_attribute20 , l_null_char, null, null, msn.c_attribute20 , wsti.c_attribute20 ), -- c_attribute20
265 decode(wsti.d_attribute1 , l_null_date, null, null, msn.d_attribute1 , wsti.d_attribute1 ), -- d_attribute1
266 decode(wsti.d_attribute2 , l_null_date, null, null, msn.d_attribute2 , wsti.d_attribute2 ), -- d_attribute2
267 decode(wsti.d_attribute3 , l_null_date, null, null, msn.d_attribute3 , wsti.d_attribute3 ), -- d_attribute3
268 decode(wsti.d_attribute4 , l_null_date, null, null, msn.d_attribute4 , wsti.d_attribute4 ), -- d_attribute4
269 decode(wsti.d_attribute5 , l_null_date, null, null, msn.d_attribute5 , wsti.d_attribute5 ), -- d_attribute5
270 decode(wsti.d_attribute6 , l_null_date, null, null, msn.d_attribute6 , wsti.d_attribute6 ), -- d_attribute6
271 decode(wsti.d_attribute7 , l_null_date, null, null, msn.d_attribute7 , wsti.d_attribute7 ), -- d_attribute7
272 decode(wsti.d_attribute8 , l_null_date, null, null, msn.d_attribute8 , wsti.d_attribute8 ), -- d_attribute8
273 decode(wsti.d_attribute9 , l_null_date, null, null, msn.d_attribute9 , wsti.d_attribute9 ), -- d_attribute9
274 decode(wsti.d_attribute10 , l_null_date, null, null, msn.d_attribute10 , wsti.d_attribute10 ), -- d_attribute10
275 decode(wsti.n_attribute1 , l_null_num , null, null, msn.n_attribute1 , wsti.n_attribute1 ), -- n_attribute1
276 decode(wsti.n_attribute2 , l_null_num , null, null, msn.n_attribute2 , wsti.n_attribute2 ), -- n_attribute2
277 decode(wsti.n_attribute3 , l_null_num , null, null, msn.n_attribute3 , wsti.n_attribute3 ), -- n_attribute3
278 decode(wsti.n_attribute4 , l_null_num , null, null, msn.n_attribute4 , wsti.n_attribute4 ), -- n_attribute4
279 decode(wsti.n_attribute5 , l_null_num , null, null, msn.n_attribute5 , wsti.n_attribute5 ), -- n_attribute5
280 decode(wsti.n_attribute6 , l_null_num , null, null, msn.n_attribute6 , wsti.n_attribute6 ), -- n_attribute6
281 decode(wsti.n_attribute7 , l_null_num , null, null, msn.n_attribute7 , wsti.n_attribute7 ), -- n_attribute7
282 decode(wsti.n_attribute8 , l_null_num , null, null, msn.n_attribute8 , wsti.n_attribute8 ), -- n_attribute8
283 decode(wsti.n_attribute9 , l_null_num , null, null, msn.n_attribute9 , wsti.n_attribute9 ), -- n_attribute9
284 decode(wsti.n_attribute10 , l_null_num , null, null, msn.n_attribute10 , wsti.n_attribute10 ), -- n_attribute10
285 decode(wsti.status_id , l_null_num , null, null, msn.status_id , wsti.status_id ), -- status_id
286 decode(wsti.time_since_new , l_null_num , null, null, msn.time_since_new , wsti.time_since_new ), -- time_since_new
287 decode(wsti.cycles_since_new , l_null_num , null, null, msn.cycles_since_new , wsti.cycles_since_new ), -- cycles_since_new
288 decode(wsti.time_since_overhaul , l_null_num , null, null, msn.time_since_overhaul , wsti.time_since_overhaul ), -- time_since_overhaul
289 decode(wsti.cycles_since_overhaul , l_null_num , null, null, msn.cycles_since_overhaul , wsti.cycles_since_overhaul ), -- cycles_since_overhaul
290 decode(wsti.time_since_repair , l_null_num , null, null, msn.time_since_repair , wsti.time_since_repair ), -- time_since_repair
291 decode(wsti.cycles_since_repair , l_null_num , null, null, msn.cycles_since_repair , wsti.cycles_since_repair ), -- cycles_since_repair
292 decode(wsti.time_since_visit , l_null_num , null, null, msn.time_since_visit , wsti.time_since_visit ), -- time_since_visit
293 decode(wsti.cycles_since_visit , l_null_num , null, null, msn.cycles_since_visit , wsti.cycles_since_visit ), -- cycles_since_visit
294 decode(wsti.time_since_mark , l_null_num , null, null, msn.time_since_mark , wsti.time_since_mark ), -- time_since_mark
295 decode(wsti.cycles_since_mark , l_null_num , null, null, msn.cycles_since_mark , wsti.cycles_since_mark ), -- cycles_since_mark
296 decode(wsti.number_of_repairs , l_null_num , null, null, msn.number_of_repairs , wsti.number_of_repairs ), -- number_of_repairs
297 decode(wsti.attribute_category , l_null_char, l_miss_char , null ,msn.attribute_category ,wsti.attribute_category ),
298 decode(wsti.attribute1 , l_null_char ,l_miss_char , wsti.attribute1 ),
299 decode(wsti.attribute2 , l_null_char ,l_miss_char , wsti.attribute2 ),
300 decode(wsti.attribute3 , l_null_char ,l_miss_char , wsti.attribute3 ),
301 decode(wsti.attribute4 , l_null_char ,l_miss_char , wsti.attribute4 ),
302 decode(wsti.attribute5 , l_null_char ,l_miss_char , wsti.attribute5 ),
303 decode(wsti.attribute6 , l_null_char ,l_miss_char , wsti.attribute6 ),
304 decode(wsti.attribute7 , l_null_char ,l_miss_char , wsti.attribute7 ),
305 decode(wsti.attribute8 , l_null_char ,l_miss_char , wsti.attribute8 ),
306 decode(wsti.attribute9 , l_null_char ,l_miss_char , wsti.attribute9 ),
307 decode(wsti.attribute10 , l_null_char ,l_miss_char , wsti.attribute10 ),
308 decode(wsti.attribute11 , l_null_char ,l_miss_char , wsti.attribute11 ),
309 decode(wsti.attribute12 , l_null_char ,l_miss_char , wsti.attribute12 ),
310 decode(wsti.attribute13 , l_null_char ,l_miss_char , wsti.attribute13 ),
311 decode(wsti.attribute14 , l_null_char ,l_miss_char , wsti.attribute14 ),
312 decode(wsti.attribute15 , l_null_char ,l_miss_char , wsti.attribute15 )
313 from wsm_serial_txn_interface wsti,
314 mtl_serial_numbers msn
315 where header_id = p_header_id
316 and transaction_type_id = 1
317 and wsti.serial_number = msn.serial_number (+)
318 and msn.inventory_item_id (+) = p_inventory_item_id
319 and msn.current_organization_id (+) = p_organization_id
320 order by nvl(wsti.action_flag,0) desc; -- Code review remark
321 -- first process Delete and then add
322
323 l_wsm_serial_nums_tbl WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL;
324 l_status_type NUMBER;
325
326 -- Logging variables.....
327 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
328 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
329
330 l_stmt_num NUMBER;
331 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.LBJ_serial_intf_proc';
332 l_param_tbl WSM_Log_PVT.param_tbl_type;
333 -- Logging variables...
334
335
336 BEGIN
337 l_stmt_num := 10;
338
339 x_return_status := G_RET_SUCCESS;
340 x_error_msg := NULL;
341 x_error_count := 0;
342
343 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
344 l_stmt_num := 15;
345 l_param_tbl.delete;
346 l_param_tbl(1).paramName := 'p_wip_entity_id';
347 l_param_tbl(1).paramValue := p_wip_entity_id;
348
349 l_param_tbl(2).paramName := 'p_inventory_item_id';
350 l_param_tbl(2).paramValue := p_inventory_item_id;
351
352 l_param_tbl(3).paramName := 'p_organization_id';
353 l_param_tbl(3).paramValue := p_organization_id;
354
355 l_param_tbl(4).paramName := 'p_header_id';
356 l_param_tbl(4).paramValue := p_header_id;
357
358 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
359 p_param_tbl => l_param_tbl,
360 p_fnd_log_level => l_log_level
361 );
362 END IF;
363
364
365
366 l_stmt_num := 20;
367 -- get the data from the interface
368 open c_lbj_serials;
369 fetch c_lbj_serials
370 bulk collect into l_wsm_serial_nums_tbl;
371 close c_lbj_serials;
372
373 l_stmt_num := 30;
374 IF l_wsm_serial_nums_tbl.count = 0 THEN
375 l_stmt_num := 40;
376 RETURN;
377 END IF;
378
379 -- Get the staus of the job...
380 -- has to be only (1,3,6) Unreleased, Released or ONHold..
381 select status_type
382 into l_status_type
383 from wip_discrete_jobs
384 where wip_entity_id = p_wip_entity_id
385 and organization_id = p_organization_id;
386
387 -- Fix for Bug 4665172 : Move this code after the code to fetch the data from the intf table.
388 -- Error out if not in valid status...
389 if l_status_type not in (1,3,6) then
390 -- error out..
391 IF g_log_level_error >= l_log_level OR
392 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
393 THEN
394
395 l_msg_tokens.delete;
396 WSM_log_PVT.logMessage(p_module_name => l_module ,
397 p_msg_name => 'WSM_SERIAL_JOB_INVALID_STATUS',
398 p_msg_appl_name => 'WSM' ,
399 p_msg_tokens => l_msg_tokens ,
400 p_stmt_num => l_stmt_num ,
401 p_fnd_msg_level => G_MSG_LVL_ERROR ,
402 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
403 p_run_log_level => l_log_level
404 );
405 END IF;
406 RAISE FND_API.G_EXC_ERROR;
407 end if;
408
409 l_stmt_num := 50;
410 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
411 l_msg_tokens.delete;
412 WSM_log_PVT.logMessage (p_module_name => l_module ,
413 p_msg_text => 'Invoking LBJ_serial_processor',
414 p_stmt_num => l_stmt_num ,
415 p_msg_tokens => l_msg_tokens ,
416 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
417 p_run_log_level => l_log_level
418 );
419 END IF;
420
421 -- Invoke the LBJ Serial Processor...
422 LBJ_serial_processor ( p_calling_mode => 1,
423 p_wsm_serial_nums_tbl => l_wsm_serial_nums_tbl ,
424 p_wip_entity_id => p_wip_entity_id ,
425 p_organization_id => p_organization_id ,
426 p_inventory_item_id => p_inventory_item_id ,
427 x_return_status => x_return_status ,
428 x_error_msg => x_error_msg ,
429 x_error_count => x_error_count
430 );
431
432 l_stmt_num := 60;
433
434 if x_return_status <> G_RET_SUCCESS then
435 IF x_return_status = G_RET_ERROR THEN
436 raise FND_API.G_EXC_ERROR;
437 ELSIF x_return_status = G_RET_UNEXPECTED THEN
438 raise FND_API.G_EXC_UNEXPECTED_ERROR;
439 END IF;
440 end if;
441
442 EXCEPTION
443
444 WHEN FND_API.G_EXC_ERROR THEN
445
446 x_return_status := G_RET_ERROR;
447 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
448 p_count => x_error_count ,
449 p_data => x_error_msg
450 );
451
452 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
453
454 x_return_status := G_RET_UNEXPECTED;
455
456 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
457 p_count => x_error_count ,
458 p_data => x_error_msg
459 );
460 WHEN OTHERS THEN
461
462 x_return_status := G_RET_UNEXPECTED;
463
464 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
465 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
466 THEN
467 WSM_log_PVT.handle_others( p_module_name => l_module ,
468 p_stmt_num => l_stmt_num ,
469 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
470 p_run_log_level => l_log_level
471 );
472 END IF;
473
474 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
475 p_count => x_error_count ,
476 p_data => x_error_msg
477 );
478 END LBJ_serial_intf_proc;
479
480
481 -- Expected i/p header_id of the WSM_LOT_JOB_INTERFACE
482 Procedure LBJ_serial_processor ( p_calling_mode IN NUMBER,
483 p_wsm_serial_nums_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
484 p_wip_entity_id IN NUMBER,
485 p_organization_id IN NUMBER,
486 p_inventory_item_id IN NUMBER,
487 x_return_status OUT NOCOPY VARCHAR2,
488 x_error_msg OUT NOCOPY VARCHAR2,
489 x_error_count OUT NOCOPY NUMBER
490 )
491 IS
492
493
494 l_serial_start_flag NUMBER;
495 l_serial_ctrl_code NUMBER;
496 l_first_serial_txn_id NUMBER;
497 l_serial_start_op NUMBER;
498
499 l_return_status VARCHAR2(1);
500 l_error_msg VARCHAR2(2000);
501 l_error_count NUMBER;
502 l_serial_tbl t_varchar2;
503
504 -- Logging variables.....
505 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
506 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
507
508 l_stmt_num NUMBER;
509 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.LBJ_serial_processor';
510 l_param_tbl WSM_Log_PVT.param_tbl_type;
511 -- Logging variables...
512
513 BEGIN
514 l_stmt_num := 10;
515 SAVEPOINT LBJ_serial_proc;
516 x_return_status := G_RET_SUCCESS;
517 x_error_msg := NULL;
518 x_error_count := 0;
519
520 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
521
522 l_param_tbl.delete;
523 l_param_tbl(1).paramName := 'p_calling_mode';
524 l_param_tbl(1).paramValue := p_calling_mode;
525
526 l_param_tbl(2).paramName := 'p_organization_id';
527 l_param_tbl(2).paramValue := p_organization_id;
528
529 l_param_tbl(3).paramName := 'p_wip_entity_id';
530 l_param_tbl(3).paramValue := p_wip_entity_id;
531
532 l_param_tbl(4).paramName := 'p_wsm_serial_nums_tbl.count';
533 l_param_tbl(4).paramValue := p_wsm_serial_nums_tbl.count;
534
535 WSM_Log_PVT.logProcParams(p_module_name => l_module,
536 p_param_tbl => l_param_tbl,
537 p_fnd_log_level => l_log_level
538 );
539 END IF;
540
541 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
542 l_stmt_num := 15;
543 -- Procedure to dump the serial records' data....
544 log_serial_data ( p_serial_num_tbl => p_wsm_serial_nums_tbl ,
545 x_return_status => x_return_status ,
546 x_error_msg => x_error_msg ,
547 x_error_count => x_error_count
548 );
549 if x_return_status <> G_RET_SUCCESS then
550 IF x_return_status = G_RET_ERROR THEN
551 raise FND_API.G_EXC_ERROR;
552 ELSIF x_return_status = G_RET_UNEXPECTED THEN
553 raise FND_API.G_EXC_UNEXPECTED_ERROR;
554 END IF;
555 end if;
556 END IF;
557
558 l_stmt_num := 20;
559 -- Validate the item_id for serial control..
560 get_serial_track_info (p_serial_item_id => p_inventory_item_id,
561 p_organization_id => p_organization_id,
562 p_wip_entity_id => p_wip_entity_id,
563 x_serial_start_flag => l_serial_start_flag,
564 x_serial_ctrl_code => l_serial_ctrl_code,
565 x_first_serial_txn_id => l_first_serial_txn_id,
566 x_serial_start_op => l_serial_start_op,
567 x_return_status => x_return_status,
568 x_error_msg => x_error_msg,
569 x_error_count => x_error_count
570 );
571
572 l_stmt_num := 30;
573
574 if x_return_status <> G_RET_SUCCESS then
575 IF x_return_status = G_RET_ERROR THEN
576 raise FND_API.G_EXC_ERROR;
577 ELSIF x_return_status = G_RET_UNEXPECTED THEN
578 raise FND_API.G_EXC_UNEXPECTED_ERROR;
579 END IF;
580 end if;
581
582 l_stmt_num := 40;
583 -- check for serial track...
584 -- we dont have to worry about Lot control as the LBJ creation would have failed before this is invoked..
585 if l_serial_ctrl_code = 1 then -- No serial control
586 if p_wsm_serial_nums_tbl.count > 0 then
587 -- return error as interface rows were updated...
588 l_stmt_num := 50;
589 IF g_log_level_error >= l_log_level OR
590 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
591 THEN
592 l_msg_tokens.delete;
593 WSM_log_PVT.logMessage(p_module_name => l_module ,
594 p_msg_name => 'WSM_INVLAID_SERIAL_INFO',
595 p_msg_appl_name => 'WSM' ,
596 p_msg_tokens => l_msg_tokens ,
597 p_stmt_num => l_stmt_num ,
598 p_fnd_msg_level => G_MSG_LVL_ERROR ,
599 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
600 p_run_log_level => l_log_level
601 );
602 END IF;
603 RAISE FND_API.G_EXC_ERROR;
604 else
605 -- return success... as no rows were found as expected..
606 l_stmt_num := 60;
607 return;
608 end if;
609
610 else
611 l_stmt_num := 70;
612 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
613 l_msg_tokens.delete;
614 WSM_log_PVT.logMessage (p_module_name => l_module ,
615 p_msg_text => 'Invoking process_serial_info',
616 p_stmt_num => l_stmt_num ,
617 p_msg_tokens => l_msg_tokens ,
618 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
619 p_run_log_level => l_log_level
620 );
621 END IF;
622 -- invoke process_serial_info
623 process_serial_info( p_calling_mode => p_calling_mode ,
624 p_wsm_serial_nums_tbl => p_wsm_serial_nums_tbl ,
625 p_wip_entity_id => p_wip_entity_id ,
626 p_serial_start_flag => l_serial_start_flag ,
627 p_organization_id => p_organization_id ,
628 p_item_id => p_inventory_item_id ,
629 x_serial_tbl => l_serial_tbl ,
630 x_return_status => x_return_status ,
631 x_error_msg => x_error_msg ,
632 x_error_count => x_error_count
633 );
634
635 l_stmt_num := 80;
636 if x_return_status <> G_RET_SUCCESS then
637 IF x_return_status = G_RET_ERROR THEN
638 raise FND_API.G_EXC_ERROR;
639 ELSIF x_return_status = G_RET_UNEXPECTED THEN
640 raise FND_API.G_EXC_UNEXPECTED_ERROR;
641 END IF;
642 end if;
643 end if;
644
645 EXCEPTION
646 WHEN FND_API.G_EXC_ERROR THEN
647 ROLLBACK TO LBJ_serial_proc;
648 x_return_status := G_RET_ERROR;
649 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
650 p_count => x_error_count ,
651 p_data => x_error_msg
652 );
653
654 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
655 ROLLBACK TO LBJ_serial_proc;
656 x_return_status := G_RET_UNEXPECTED;
657
658 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
659 p_count => x_error_count ,
660 p_data => x_error_msg
661 );
662 WHEN OTHERS THEN
663 ROLLBACK TO LBJ_serial_proc;
664 x_return_status := G_RET_UNEXPECTED;
665
666 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
667 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
668 THEN
669 WSM_log_PVT.handle_others( p_module_name => l_module ,
670 p_stmt_num => l_stmt_num ,
671 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
672 p_run_log_level => l_log_level
673 );
674 END IF;
675
676 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
677 p_count => x_error_count ,
678 p_data => x_error_msg
679 );
680 END LBJ_serial_processor;
681
682 -- x_serial_ctrl_code --> 1 -- No serial control
683 -- x_serial_ctrl_code --> 2 -- Predefined... (this is the only one allowed in OSFM..)
684
685 Procedure get_serial_track_info ( p_serial_item_id IN NUMBER,
686 p_organization_id IN NUMBER,
687 p_wip_entity_id IN NUMBER,
688 x_serial_start_flag OUT NOCOPY NUMBER,
689 x_serial_ctrl_code OUT NOCOPY NUMBER,
690 x_first_serial_txn_id OUT NOCOPY NUMBER,
691 x_serial_start_op OUT NOCOPY NUMBER,
692 x_return_status OUT NOCOPY VARCHAR2,
693 x_error_msg OUT NOCOPY VARCHAR2,
694 x_error_count OUT NOCOPY NUMBER
695 )
696
697 IS
698
699 -- Logging variables.....
700 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
701 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
702
703 l_stmt_num NUMBER;
704 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.get_serial_track_info';
705 -- Logging variables...
706
707 BEGIN
708 l_stmt_num := 10;
709
710 x_return_status := G_RET_SUCCESS;
711 x_error_msg := NULL;
712 x_error_count := 0;
713
714 -- Query up the MTL_SYSTEM_ITEMS_B to get the serial control code for the item passed..
715 -- IF g_serial_ctl_code.exists(p_serial_item_id) THEN
716 IF g_serial_ctl_code.exists(p_serial_item_id || '_' || p_organization_id) THEN
717 l_stmt_num := 20;
718 x_serial_ctrl_code := g_serial_ctl_code(p_serial_item_id || '_' || p_organization_id);
719 ELSE
720 l_stmt_num := 30;
721
722 BEGIN
723 SELECT nvl(SERIAL_NUMBER_CONTROL_CODE,1)
724 INTO x_serial_ctrl_code
725 FROM MTL_SYSTEM_ITEMS MSI
726 WHERE MSI.inventory_item_id = p_serial_item_id
727 AND MSI.organization_id = p_organization_id;
728
729 EXCEPTION
730 WHEN NO_DATA_FOUND THEN
731 --Invalid item id/org id combination
732 --error out..
733 IF g_log_level_error >= l_log_level OR
734 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
735 THEN
736
737 l_msg_tokens.delete;
738 l_msg_tokens(1).TokenName := 'FLD_NAME';
739 l_msg_tokens(1).TokenValue := 'Organization Identifdier or Item Identifier';
740 WSM_log_PVT.logMessage(p_module_name => l_module ,
741 p_msg_name => 'WSM_INVALID_FILED' ,
742 p_msg_appl_name => 'WSM' ,
743 p_msg_tokens => l_msg_tokens ,
744 p_stmt_num => l_stmt_num ,
745 p_fnd_msg_level => G_MSG_LVL_ERROR ,
746 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
747 p_run_log_level => l_log_level
748 );
749 END IF;
750 RAISE FND_API.G_EXC_ERROR;
751 END;
752
753 l_stmt_num := 40;
754 g_serial_ctl_code(p_serial_item_id || '_' || p_organization_id) := x_serial_ctrl_code;
755
756 IF x_serial_ctrl_code = 1 THEN
757 l_stmt_num := 50;
758 RETURN;
759 END IF;
760 END IF;
761
762 l_stmt_num := 60;
763 --
764 -- Query up the serial_start_flag from WSM_LOT_BASED_JOBS
765 --
766 BEGIN
767 SELECT WDJ.serialization_start_op,
768 first_serial_txn_id,
769 WLBJ.serialization_start_op
770 INTO x_serial_start_flag,
771 x_first_serial_txn_id,
772 x_serial_start_op
773 FROM WSM_LOT_BASED_JOBS WLBJ,WIP_DISCRETE_JOBS WDJ
774 WHERE WLBJ.wip_entity_id = p_wip_entity_id
775 AND WDJ.wip_entity_id = WLBJ.wip_entity_id
776 AND WLBJ.organization_id = p_organization_id;
777
778 EXCEPTION
779 WHEN NO_DATA_FOUND THEN
780 --Invalid wip_entity_id
781 -- error out..
782 IF g_log_level_error >= l_log_level OR
783 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
784 THEN
785
786 l_msg_tokens.delete;
787 l_msg_tokens(1).TokenName := 'FLD_NAME';
788 l_msg_tokens(1).TokenValue := 'Job Identifier (wip_entity_id)';
789 WSM_log_PVT.logMessage(p_module_name => l_module ,
790 p_msg_name => 'WSM_INVALID_FIELD' ,
791 p_msg_appl_name => 'WSM' ,
792 p_msg_tokens => l_msg_tokens ,
793 p_stmt_num => l_stmt_num ,
794 p_fnd_msg_level => G_MSG_LVL_ERROR ,
795 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
796 p_run_log_level => l_log_level
797 );
798 END IF;
799 RAISE FND_API.G_EXC_ERROR;
800 END;
801
802 EXCEPTION
803
804 WHEN FND_API.G_EXC_ERROR THEN
805
806 x_return_status := G_RET_ERROR;
807 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
808 p_count => x_error_count ,
809 p_data => x_error_msg
810 );
811 WHEN OTHERS THEN
812
813 x_return_status := G_RET_UNEXPECTED;
814
815 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
816 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
817 THEN
818 WSM_log_PVT.handle_others( p_module_name => l_module ,
819 p_stmt_num => l_stmt_num ,
820 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
821 p_run_log_level => l_log_level
822 );
823 END IF;
824
825 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
826 p_count => x_error_count ,
827 p_data => x_error_msg
828 );
829
830 END get_serial_track_info;
831
832
833 Procedure process_serial_info ( p_calling_mode IN NUMBER,
834 p_wsm_serial_nums_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
835 p_wip_entity_id IN NUMBER,
836 p_serial_start_flag IN NUMBER,
837 p_organization_id IN NUMBER,
838 p_item_id IN NUMBER,
839 -- Indicates that this call is made for update qty transaction....
840 p_wlt_upd_qty_txn IN NUMBER DEFAULT NULL,
841 p_operation_seq_num IN NUMBER DEFAULT NULL,
842 p_intraoperation_step IN NUMBER DEFAULT NULL,
843 -- This PL/SQL table parameter would return the serial numbers added/generated and added..
844 -- We need this information to insert into WSM_SERIAL_TRANSACTIONS
845 x_serial_tbl OUT NOCOPY t_varchar2,
846 x_return_status OUT NOCOPY VARCHAR2,
847 x_error_msg OUT NOCOPY VARCHAR2,
848 x_error_count OUT NOCOPY NUMBER
849 )
850
851 IS
852
853 l_index NUMBER;
854 l_return_status VARCHAR2(1);
855 l_error_msg VARCHAR2(2000);
856 l_error_count NUMBER;
857 l_serial_start_flag NUMBER;
858 l_job_qty NUMBER;
859 l_serial_num_count NUMBER;
860
861 l_qty_queue NUMBER;
862 l_qty_run NUMBER;
863 l_qty_tomove NUMBER;
864 l_qty NUMBER;
865 l_op_seq_num NUMBER;
866 l_serial_number MTL_SERIAL_NUMBERS.SERIAL_NUMBER%TYPE;
867
868 -- Logging variables.....
869 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
870 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
871
872 l_stmt_num NUMBER;
873 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.process_serial_info';
874 l_param_tbl WSM_Log_PVT.param_tbl_type;
875 -- Logging variables...
876
877 BEGIN
878 l_stmt_num := 10;
879
880 x_return_status := G_RET_SUCCESS;
881 x_error_msg := NULL;
882 x_error_count := 0;
883
884 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
885
886 l_param_tbl.delete;
887 l_param_tbl(1).paramName := 'p_operation_seq_num';
888 l_param_tbl(1).paramValue := p_operation_seq_num;
889
890 l_param_tbl(2).paramName := 'p_intraoperation_step';
891 l_param_tbl(2).paramValue := p_intraoperation_step;
892
893 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
894 p_param_tbl => l_param_tbl,
895 p_fnd_log_level => l_log_level
896 );
897 END IF;
898
899 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
900 l_msg_tokens.delete;
901 WSM_log_PVT.logMessage (p_module_name => l_module ,
902 p_msg_text => 'Inside WSM_SERIAL_SUPPORT_PVT.process_serial_info',
903 p_stmt_num => l_stmt_num ,
904 p_msg_tokens => l_msg_tokens ,
905 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
906 p_run_log_level => l_log_level
907 );
908 END IF;
909
910
911
912 -- Ok the first thing is get the job qty and the number of serial numbers currently attached to the job if it is not
913 -- serial tracked..
914 l_stmt_num := 20;
915 l_index := p_wsm_serial_nums_tbl.first;
916
917 if (p_serial_start_flag IS NULL) THEN
918
919 l_stmt_num := 30;
920
921 SELECT start_quantity
922 into l_job_qty
923 from wip_discrete_jobs
924 where wip_entity_id = p_wip_entity_id
925 and organization_id = p_organization_id;
926
927 BEGIN
928 l_stmt_num := 40;
929
930 SELECT max(operation_seq_num)
931 INTO l_op_seq_num
932 FROM wip_operations
933 WHERE wip_entity_id = p_wip_entity_id
934 AND ((quantity_in_queue <> 0
935 OR quantity_running <> 0
936 OR quantity_waiting_to_move <> 0)
937 OR (quantity_in_queue = 0
938 and quantity_running = 0
939 and quantity_waiting_to_move = 0
940 and quantity_scrapped = quantity_completed
941 and quantity_completed > 0));
942
943 l_stmt_num := 50;
944
945 SELECT quantity_in_queue,
946 quantity_running,
947 quantity_waiting_to_move
948 INTO l_qty_queue,
949 l_qty_run,
950 l_qty_tomove
951 FROM wip_operations
952 WHERE wip_entity_id = p_wip_entity_id
953 AND operation_seq_num = l_op_seq_num;
954
955 l_stmt_num := 60;
956
957 IF l_qty_queue <> 0 then
958 l_qty := l_qty_queue;
959 elsif l_qty_run <> 0 then
960 l_qty := l_qty_run;
961 elsif l_qty_tomove <> 0 then
962 l_qty := l_qty_tomove;
963 end if;
964
965 EXCEPTION
966 WHEN NO_DATA_FOUND THEN
967 l_stmt_num := 70;
968 l_qty := l_job_qty;
969 END;
970
971 l_stmt_num := 80;
972
973 SELECT count(*)
974 into l_serial_num_count
975 -- ST : Fix for bug 4910758 (remove usage of wsm_job_serial_numbers_v)
976 -- from wsm_job_serial_numbers_v
977 from mtl_serial_numbers
978 where wip_entity_id = p_wip_entity_id
979 and inventory_item_id = p_item_id
980 and current_organization_id = p_organization_id;
981
982 end if;
983
984
985 WHILE l_index IS NOT NULL LOOP
986
987 l_stmt_num := 90;
988 if (p_serial_start_flag IS NOT NULL) and
989 (p_wlt_upd_qty_txn IS NULL) and
990 (p_wsm_serial_nums_tbl(l_index).action_flag <> WSM_UPDATE_SERIAL_NUM)
991 then -- Serialization has begun and action is not update...
992
993 l_stmt_num := 100;
994 -- Error out.. As cannot add/delete/ generate and associate once serialization has begun..
995 IF g_log_level_error >= l_log_level OR
996 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
997 THEN
998
999 l_msg_tokens.delete;
1000 WSM_log_PVT.logMessage(p_module_name => l_module ,
1001 p_msg_name => 'WSM_INVLD_OP_JOB_SERIAL_TRACK',
1002 p_msg_appl_name => 'WSM' ,
1003 p_msg_tokens => l_msg_tokens ,
1004 p_stmt_num => l_stmt_num ,
1005 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1006 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1007 p_run_log_level => l_log_level
1008 );
1009 END IF;
1010 RAISE FND_API.G_EXC_ERROR;
1011 end if;
1012
1013 l_stmt_num := 110;
1014 if p_wsm_serial_nums_tbl(l_index).action_flag = WSM_ADD_SERIAL_NUM then -- Add a serial number
1015
1016 l_stmt_num := 120;
1017 IF l_serial_num_count >= l_qty then
1018 --error out...
1019 -- enough serial numbers reached...
1020 IF g_log_level_error >= l_log_level OR
1021 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1022 THEN
1023
1024 l_msg_tokens.delete;
1025 WSM_log_PVT.logMessage(p_module_name => l_module ,
1026 p_msg_name => 'WSM_INVALID_SERIAL_QTY',
1027 p_msg_appl_name => 'WSM' ,
1028 p_msg_tokens => l_msg_tokens ,
1029 p_stmt_num => l_stmt_num ,
1030 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1031 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1032 p_run_log_level => l_log_level
1033 );
1034 END IF;
1035 RAISE FND_API.G_EXC_ERROR;
1036 END IF;
1037
1038 l_stmt_num := 130;
1039 add_assoc_serial_number( p_calling_mode => p_calling_mode,
1040 p_serial_number_rec => p_wsm_serial_nums_tbl(l_index),
1041 p_wip_entity_id => p_wip_entity_id,
1042 p_gen_serial_flag => 0, -- donot generate
1043 p_organization_id => p_organization_id,
1044 p_inventory_item_id => p_item_id,
1045 p_operation_seq_num => p_operation_seq_num,
1046 p_intraoperation_step => p_intraoperation_step,
1047 x_serial_number => l_serial_number,
1048 x_return_status => x_return_status,
1049 x_error_msg => x_error_msg ,
1050 x_error_count => x_error_count
1051 );
1052
1053 l_stmt_num := 140;
1054
1055 if x_return_status <> G_RET_SUCCESS then
1056 IF x_return_status = G_RET_ERROR THEN
1057 raise FND_API.G_EXC_ERROR;
1058 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1059 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1060 END IF;
1061 end if;
1062
1063 x_serial_tbl(x_serial_tbl.count+1) := p_wsm_serial_nums_tbl(l_index).serial_number;
1064
1065 l_serial_num_count := l_serial_num_count + 1;
1066 l_stmt_num := 150;
1067
1068 elsif p_wsm_serial_nums_tbl(l_index).action_flag = WSM_DELINK_SERIAL_NUM then -- Delink a serial number.
1069
1070 l_stmt_num := 160;
1071
1072 -- Update the serial number,., clear the wip entity id ...
1073 update_serial( p_serial_number => p_wsm_serial_nums_tbl(l_index).serial_number,
1074 p_inventory_item_id => p_item_id,
1075 -- p_new_inventory_item_id => p_inventory_item_id,
1076 p_organization_id => p_organization_id,
1077 p_wip_entity_id => null,
1078 p_operation_seq_num => null,
1079 p_intraoperation_step_type => null,
1080 x_return_status => x_return_status,
1081 x_error_msg => x_error_msg,
1082 x_error_count => x_error_count
1083 );
1084
1085 l_stmt_num := 170;
1086
1087 if x_return_status <> G_RET_SUCCESS then
1088 IF x_return_status = G_RET_ERROR THEN
1089 raise FND_API.G_EXC_ERROR;
1090 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1091 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1092 END IF;
1093 end if;
1094
1095 l_stmt_num := 180;
1096 l_serial_num_count := l_serial_num_count - 1;
1097
1098 elsif p_wsm_serial_nums_tbl(l_index).generate_serial_number = 1 then -- Generate and associate serial numbers.
1099
1100 l_stmt_num := 190;
1101
1102 IF (nvl(p_wsm_serial_nums_tbl(l_index).generate_for_qty,-1) <= 0)
1103 OR
1104 (floor(nvl(p_wsm_serial_nums_tbl(l_index).generate_for_qty,-1)) <> nvl(p_wsm_serial_nums_tbl(l_index).generate_for_qty,-1))
1105 THEN
1106 -- error out...
1107 -- as qty cannot be null/negative or non-integer.....
1108 l_stmt_num := 200;
1109 IF g_log_level_error >= l_log_level OR
1110 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1111 THEN
1112
1113 l_msg_tokens.delete;
1114 WSM_log_PVT.logMessage(p_module_name => l_module ,
1115 p_msg_name => 'WSM_INVALID_GEN_QTY' ,
1116 p_msg_appl_name => 'WSM' ,
1117 p_msg_tokens => l_msg_tokens ,
1118 p_stmt_num => l_stmt_num ,
1119 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1120 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1121 p_run_log_level => l_log_level
1122 );
1123 END IF;
1124 RAISE FND_API.G_EXC_ERROR;
1125 end if;
1126
1127 l_stmt_num := 210;
1128 IF l_qty < l_serial_num_count + p_wsm_serial_nums_tbl(l_index).generate_for_qty then
1129 --error out...
1130 -- enough serial numbers reached...
1131 -- enough serial numbers reached...
1132 l_stmt_num := 220;
1133 IF g_log_level_error >= l_log_level OR
1134 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1135 THEN
1136
1137 l_msg_tokens.delete;
1138 WSM_log_PVT.logMessage(p_module_name => l_module ,
1139 p_msg_name => 'WSM_INVALID_SERIAL_QTY',
1140 p_msg_appl_name => 'WSM' ,
1141 p_msg_tokens => l_msg_tokens ,
1142 p_stmt_num => l_stmt_num ,
1143 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1144 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1145 p_run_log_level => l_log_level
1146 );
1147 END IF;
1148 RAISE FND_API.G_EXC_ERROR;
1149 END IF;
1150
1151 l_stmt_num := 230;
1152 for l_cntr in 1..p_wsm_serial_nums_tbl(l_index).generate_for_qty loop
1153
1154 l_stmt_num := 240;
1155
1156 add_assoc_serial_number ( p_calling_mode => p_calling_mode,
1157 p_serial_number_rec => p_wsm_serial_nums_tbl(l_index),
1158 p_wip_entity_id => p_wip_entity_id,
1159 p_gen_serial_flag => 1, -- generate serial number
1160 p_organization_id => p_organization_id,
1161 p_inventory_item_id => p_item_id,
1162 p_operation_seq_num => p_operation_seq_num,
1163 p_intraoperation_step => p_intraoperation_step,
1164 x_serial_number => l_serial_number,
1165 x_return_status => x_return_status,
1166 x_error_msg => x_error_msg ,
1167 x_error_count => x_error_count
1168 );
1169
1170 l_stmt_num := 250;
1171
1172 if x_return_status <> G_RET_SUCCESS then
1173 IF x_return_status = G_RET_ERROR THEN
1174 raise FND_API.G_EXC_ERROR;
1175 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1176 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1177 END IF;
1178 end if;
1179
1180 x_serial_tbl(x_serial_tbl.count+1) := l_serial_number;
1181
1182 end loop;
1183
1184 l_stmt_num := 260;
1185 l_serial_num_count := l_serial_num_count + p_wsm_serial_nums_tbl(l_index).generate_for_qty;
1186
1187 elsif p_wsm_serial_nums_tbl(l_index).action_flag = WSM_UPDATE_SERIAL_NUM then
1188
1189 l_stmt_num := 270;
1190 -- this will basically update only serial attributes.. (No other updates allowed....)
1191 update_serial_attr ( p_calling_mode => p_calling_mode ,
1192 p_serial_number_rec => p_wsm_serial_nums_tbl(l_index) ,
1193 p_inventory_item_id => p_item_id ,
1194 p_organization_id => p_organization_id ,
1195 p_clear_serial_attr => null ,
1196 p_wlt_txn_type => null ,
1197 p_update_serial_attr => null ,
1198 p_update_desc_attr => null ,
1199 x_return_status => x_return_status ,
1200 x_error_count => x_error_count ,
1201 x_error_msg => x_error_msg
1202 );
1203
1204 l_stmt_num := 280;
1205 if x_return_status <> G_RET_SUCCESS then
1206 IF x_return_status = G_RET_ERROR THEN
1207 raise FND_API.G_EXC_ERROR;
1208 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1209 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1210 END IF;
1211 end if;
1212 else
1213 -- Invalid action code...
1214 -- Error out...
1215 l_stmt_num := 290;
1216 IF g_log_level_error >= l_log_level OR
1217 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1218 THEN
1219
1220 l_msg_tokens.delete;
1221 l_msg_tokens(1).TokenName := 'FLD_NAME';
1222 l_msg_tokens(1).TokenValue := 'Action Flag/Generate Serial Number Flag';
1223 WSM_log_PVT.logMessage(p_module_name => l_module ,
1224 p_msg_name => 'WSM_INVALID_FIELD' ,
1225 p_msg_appl_name => 'WSM' ,
1226 p_msg_tokens => l_msg_tokens ,
1227 p_stmt_num => l_stmt_num ,
1228 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1229 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1230 p_run_log_level => l_log_level
1231 );
1232 END IF;
1233 RAISE FND_API.G_EXC_ERROR;
1234 end if;
1235 l_stmt_num := 300;
1236 l_index := p_wsm_serial_nums_tbl.next(l_index);
1237
1238 END LOOP;
1239
1240
1241 EXCEPTION
1242
1243 WHEN FND_API.G_EXC_ERROR THEN
1244
1245 x_return_status := G_RET_ERROR;
1246 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1247 p_count => x_error_count ,
1248 p_data => x_error_msg
1249 );
1250
1251 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1252
1253 x_return_status := G_RET_UNEXPECTED;
1254
1255 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1256 p_count => x_error_count ,
1257 p_data => x_error_msg
1258 );
1259 WHEN OTHERS THEN
1260
1261 x_return_status := G_RET_UNEXPECTED;
1262
1263 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1264 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1265 THEN
1266 WSM_log_PVT.handle_others( p_module_name => l_module ,
1267 p_stmt_num => l_stmt_num ,
1268 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1269 p_run_log_level => l_log_level
1270 );
1271 END IF;
1272
1273 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1274 p_count => x_error_count ,
1275 p_data => x_error_msg
1276 );
1277 END process_serial_info;
1278
1279
1280 Procedure add_assoc_serial_number(p_calling_mode IN NUMBER,
1281 p_serial_number_rec IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_REC,
1282 p_wip_entity_id IN NUMBER,
1283 p_gen_serial_flag IN NUMBER,
1284 -- will be equal to the 1 in case (Generation..)
1285 p_organization_id IN NUMBER,
1286 p_inventory_item_id IN NUMBER,
1287 p_operation_seq_num IN NUMBER DEFAULT NULL,
1288 p_intraoperation_step IN NUMBER DEFAULT NULL,
1289 -- return the generated serial number...
1290 x_serial_number OUT NOCOPY VARCHAR2,
1291 x_return_status OUT NOCOPY VARCHAR2,
1292 x_error_msg OUT NOCOPY VARCHAR2,
1293 x_error_count OUT NOCOPY NUMBER
1294 )
1295
1296 IS
1297 l_serial_number MTL_SERIAL_NUMBERS.SERIAL_NUMBER%TYPE;
1298
1299 l_return_code NUMBER;
1300 l_quantity NUMBER;
1301
1302 -- Logging variables.....
1303 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1304 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1305
1306 l_stmt_num NUMBER;
1307 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.add_assoc_serial_number';
1308 -- Logging variables...
1309
1310 BEGIN
1311 l_stmt_num := 10;
1312 x_return_status := G_RET_SUCCESS;
1313 x_error_msg := NULL;
1314 x_error_count := 0;
1315
1316 IF p_gen_serial_flag = 1 THEN
1317
1318 l_stmt_num := 20;
1319 l_quantity := 1;
1320
1321 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1322 l_msg_tokens.delete;
1323 WSM_log_PVT.logMessage (p_module_name => l_module ,
1324 p_msg_text => 'Invoking inv_serial_number_pub.generate_serials',
1325 p_stmt_num => l_stmt_num ,
1326 p_msg_tokens => l_msg_tokens ,
1327 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1328 p_run_log_level => l_log_level
1329 );
1330 END IF;
1331
1332 l_return_code := inv_serial_number_pub.generate_serials(p_org_id => p_organization_id,
1333 p_item_id => p_inventory_item_id,
1334 p_qty => l_quantity,
1335 p_wip_id => null,
1336 p_group_mark_id => null,
1337 p_line_mark_id => null,
1338 p_rev => null,
1339 p_lot => null,
1340 p_skip_serial => wip_constants.yes,
1341 x_start_ser => l_serial_number,
1342 x_end_ser => l_serial_number,
1343 x_proc_msg => x_error_msg);
1344
1345 if l_quantity <> 1 or l_return_code <> 0 then
1346 -- error out
1347 IF g_log_level_error >= l_log_level OR
1348 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1349 THEN
1350
1351 l_msg_tokens.delete;
1352 l_msg_tokens(1).TokenName := 'SERIAL_NUM';
1353 l_msg_tokens(1).TokenValue := null;
1354
1355 WSM_log_PVT.logMessage(p_module_name => l_module ,
1356 p_msg_name => 'WSM_SERIAL_GEN_FAILED' ,
1357 p_msg_appl_name => 'WSM' ,
1358 p_msg_tokens => l_msg_tokens ,
1359 p_stmt_num => l_stmt_num ,
1360 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1361 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1362 p_run_log_level => l_log_level
1363 );
1364 END IF;
1365 RAISE FND_API.G_EXC_ERROR;
1366 end if;
1367
1368 x_serial_number := l_serial_number;
1369
1370 l_stmt_num := 30;
1371 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1372 l_msg_tokens.delete;
1373 WSM_log_PVT.logMessage (p_module_name => l_module ,
1374 p_msg_text => 'Invoke inv_serial_number_pub.generate_serials Success',
1375 p_stmt_num => l_stmt_num ,
1376 p_msg_tokens => l_msg_tokens ,
1377 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1378 p_run_log_level => l_log_level
1379 );
1380 END IF;
1381
1382 -- Bug fix 5219922: START.
1383 l_stmt_num := 35;
1384 if g_wms_installed IS NULL THEN
1385
1386 wms_installed ( x_return_status => x_return_status ,
1387 x_error_count => x_error_count ,
1388 x_err_data => x_error_msg
1389 );
1390
1391 if x_return_status <> G_RET_SUCCESS then
1392 IF x_return_status = G_RET_ERROR THEN
1393 raise FND_API.G_EXC_ERROR;
1394 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1395 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1396 END IF;
1397 end if;
1398 end if;
1399
1400 IF (g_wms_installed=1 AND
1401 inv_lot_sel_attr.is_enabled( 'Serial Attributes',
1402 p_organization_id,
1403 p_inventory_item_id) >= 2) OR
1404 (inv_lot_sel_attr.is_dff_required('MTL_SERIAL_NUMBERS',
1405 'INV',
1406 p_organization_id,
1407 p_inventory_item_id) = 1 ) THEN
1408
1409 l_msg_tokens.delete;
1410 WSM_log_PVT.logMessage(p_module_name => l_module ,
1411 p_msg_name => 'WSM_ENT_MAND_SER_ATTR_FLEX',
1412 p_msg_appl_name => 'WSM' ,
1413 p_msg_tokens => l_msg_tokens ,
1414 p_stmt_num => l_stmt_num ,
1415 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1416 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1417 p_run_log_level => l_log_level
1418 );
1419
1420
1421 END IF;
1422 -- Bug fix 5219922: END.
1423 ELSE
1424 -- indicates linking a new/existing serial number...
1425 -- first is check if the serial number exists...
1426 -- if not exists , then create the serial number
1427 l_stmt_num := 40;
1428 l_serial_number := p_serial_number_rec.serial_number;
1429
1430 add_serial_number(p_serial_number => l_serial_number,
1431 p_assembly_item_id => p_inventory_item_id,
1432 p_organization_id => p_organization_id,
1433 p_wip_entity_id => p_wip_entity_id,
1434 x_return_status => x_return_status,
1435 x_error_msg => x_error_msg,
1436 x_error_count => x_error_count
1437 );
1438
1439 if x_return_status <> G_RET_SUCCESS then
1440 IF x_return_status = G_RET_ERROR THEN
1441 raise FND_API.G_EXC_ERROR;
1442 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1443 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1444 END IF;
1445 end if;
1446 l_stmt_num := 50;
1447 END IF;
1448
1449 l_stmt_num := 60;
1450 -- Update the serial number to the job...
1451 update_serial( p_serial_number => l_serial_number,
1452 p_inventory_item_id => p_inventory_item_id,
1453 --p_new_inventory_item_id => p_inventory_item_id,
1454 p_organization_id => p_organization_id,
1455 p_wip_entity_id => p_wip_entity_id,
1456 p_operation_seq_num => p_operation_seq_num,
1457 p_intraoperation_step_type => p_intraoperation_step,
1458 x_return_status => x_return_status,
1459 x_error_msg => x_error_msg,
1460 x_error_count => x_error_count
1461 );
1462
1463
1464 if x_return_status <> G_RET_SUCCESS then
1465 IF x_return_status = G_RET_ERROR THEN
1466 raise FND_API.G_EXC_ERROR;
1467 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1468 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1469 END IF;
1470 end if;
1471
1472 l_stmt_num := 70;
1473 IF p_gen_serial_flag = 1 THEN -- Indicates that it is a generation call.. so no updates will be done...
1474 RETURN;
1475 END IF;
1476
1477 l_stmt_num := 80;
1478 -- call the code to update the serial attributes/dff fields...
1479 update_serial_attr ( p_calling_mode => p_calling_mode ,
1480 p_serial_number_rec => p_serial_number_rec ,
1481 p_inventory_item_id => p_inventory_item_id ,
1482 p_organization_id => p_organization_id ,
1483 p_clear_serial_attr => null ,
1484 p_wlt_txn_type => null ,
1485 p_update_serial_attr => 1 ,
1486 p_update_desc_attr => 1 ,
1487 x_return_status => x_return_status ,
1488 x_error_count => x_error_count ,
1489 x_error_msg => x_error_msg
1490 );
1491
1492 if x_return_status <> G_RET_SUCCESS then
1493 IF x_return_status = G_RET_ERROR THEN
1494 raise FND_API.G_EXC_ERROR;
1495 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1496 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1497 END IF;
1498 end if;
1499
1500 l_stmt_num := 90;
1501
1502 EXCEPTION
1503
1504 WHEN FND_API.G_EXC_ERROR THEN
1505
1506 x_return_status := G_RET_ERROR;
1507 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1508 p_count => x_error_count ,
1509 p_data => x_error_msg
1510 );
1511
1512 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1513
1514 x_return_status := G_RET_UNEXPECTED;
1515
1516 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1517 p_count => x_error_count ,
1518 p_data => x_error_msg
1519 );
1520 WHEN OTHERS THEN
1521
1522 x_return_status := G_RET_UNEXPECTED;
1523
1524 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1525 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1526 THEN
1527 WSM_log_PVT.handle_others( p_module_name => l_module ,
1528 p_stmt_num => l_stmt_num ,
1529 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1530 p_run_log_level => l_log_level
1531 );
1532 END IF;
1533
1534 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1535 p_count => x_error_count ,
1536 p_data => x_error_msg
1537 );
1538 END add_assoc_serial_number;
1539
1540
1541 Procedure add_assoc_serial_number(p_wip_entity_id IN NUMBER,
1542 p_organization_id IN NUMBER,
1543 p_inventory_item_id IN NUMBER,
1544 -- will be null in case (Generation..)
1545 p_serial_number IN OUT NOCOPY VARCHAR2,
1546 -- pass 1 if the calling program knows that it is a new serial number
1547 p_new_serial_number IN NUMBER DEFAULT NULL,
1548 p_operation_seq_num IN NUMBER DEFAULT NULL,
1549 p_intraoperation_step IN NUMBER DEFAULT NULL,
1550 x_return_status OUT NOCOPY VARCHAR2,
1551 x_error_msg OUT NOCOPY VARCHAR2,
1552 x_error_count OUT NOCOPY NUMBER
1553 )
1554
1555 IS
1556 l_error_msg VARCHAR2(2000);
1557
1558 l_error_count NUMBER;
1559 l_return_code NUMBER;
1560 l_quantity NUMBER;
1561
1562
1563
1564 -- Logging variables.....
1565 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1566 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1567
1568 l_stmt_num NUMBER;
1569 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.add_assoc_serial_number(2)';
1570 -- Logging variables...
1571
1572
1573 BEGIN
1574 l_stmt_num := 10;
1575
1576 x_return_status := G_RET_SUCCESS;
1577 x_error_msg := NULL;
1578 x_error_count := 0;
1579
1580 IF p_serial_number IS NULL THEN
1581
1582 l_stmt_num := 20;
1583
1584 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1585 l_msg_tokens.delete;
1586 WSM_log_PVT.logMessage (p_module_name => l_module ,
1587 p_msg_text => 'Invoking inv_serial_number_pub.generate_serials',
1588 p_stmt_num => l_stmt_num ,
1589 p_msg_tokens => l_msg_tokens ,
1590 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1591 p_run_log_level => l_log_level
1592 );
1593 END IF;
1594
1595 l_quantity := 1;
1596 l_return_code := inv_serial_number_pub.generate_serials(p_org_id => p_organization_id,
1597 p_item_id => p_inventory_item_id,
1598 p_qty => l_quantity,
1599 p_wip_id => null,
1600 p_group_mark_id => null,
1601 p_line_mark_id => null,
1602 p_rev => null,
1603 p_lot => null,
1604 p_skip_serial => wip_constants.yes,
1605 x_start_ser => p_serial_number,
1606 x_end_ser => p_serial_number,
1607 x_proc_msg => x_error_msg);
1608
1609
1610 l_stmt_num := 30;
1611 if l_quantity <> 1 OR l_return_code <> 0 then
1612 IF g_log_level_error >= l_log_level OR
1613 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1614 THEN
1615 l_msg_tokens.delete;
1616 l_msg_tokens(1).TokenName := 'SERIAL_NUM';
1617 l_msg_tokens(1).TokenValue := null;
1618 WSM_log_PVT.logMessage(p_module_name => l_module ,
1619 p_msg_name => 'WSM_SERIAL_GEN_FAILED' ,
1620 p_msg_appl_name => 'WSM' ,
1621 p_msg_tokens => l_msg_tokens ,
1622 p_stmt_num => l_stmt_num ,
1623 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1624 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1625 p_run_log_level => l_log_level
1626 );
1627 END IF;
1628 RAISE FND_API.G_EXC_ERROR;
1629 end if;
1630
1631 -- Bug fix 5219922: START.
1632 l_stmt_num := 35;
1633 if g_wms_installed IS NULL THEN
1634
1635 wms_installed ( x_return_status => x_return_status ,
1636 x_error_count => x_error_count ,
1637 x_err_data => x_error_msg
1638 );
1639
1640 if x_return_status <> G_RET_SUCCESS then
1641 IF x_return_status = G_RET_ERROR THEN
1642 raise FND_API.G_EXC_ERROR;
1643 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1644 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1645 END IF;
1646 end if;
1647 end if;
1648
1649 IF (g_wms_installed=1 AND
1650 inv_lot_sel_attr.is_enabled( 'Serial Attributes',
1651 p_organization_id,
1652 p_inventory_item_id) >= 2) OR
1653 (inv_lot_sel_attr.is_dff_required('MTL_SERIAL_NUMBERS',
1654 'INV',
1655 p_organization_id,
1656 p_inventory_item_id) = 1 ) THEN
1657
1658 l_msg_tokens.delete;
1659 WSM_log_PVT.logMessage(p_module_name => l_module ,
1660 p_msg_name => 'WSM_ENT_MAND_SER_ATTR_FLEX',
1661 p_msg_appl_name => 'WSM' ,
1662 p_msg_tokens => l_msg_tokens ,
1663 p_stmt_num => l_stmt_num ,
1664 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1665 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1666 p_run_log_level => l_log_level
1667 );
1668
1669
1670 END IF;
1671 -- Bug fix 5219922: END.
1672 ELSE
1673 -- indicates linking a new/existing serial number...
1674 -- first is check if the serial number exists...
1675 -- if not exists , then create the serial number
1676
1677 l_stmt_num := 40;
1678
1679 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1680 l_msg_tokens.delete;
1681 WSM_log_PVT.logMessage (p_module_name => l_module ,
1682 p_msg_text => 'Invoking add_serial_number',
1683 p_stmt_num => l_stmt_num ,
1684 p_msg_tokens => l_msg_tokens ,
1685 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1686 p_run_log_level => l_log_level
1687 );
1688 END IF;
1689
1690 add_serial_number(p_serial_number => p_serial_number,
1691 p_assembly_item_id => p_inventory_item_id,
1692 p_organization_id => p_organization_id,
1693 p_wip_entity_id => p_wip_entity_id,
1694 p_new_serial_number => p_new_serial_number,
1695 x_return_status => x_return_status,
1696 x_error_msg => x_error_msg,
1697 x_error_count => x_error_count
1698 );
1699
1700 l_stmt_num := 50;
1701 if x_return_status <> G_RET_SUCCESS then
1702 IF x_return_status = G_RET_ERROR THEN
1703 raise FND_API.G_EXC_ERROR;
1704 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1705 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1706 END IF;
1707 end if;
1708 END IF;
1709
1710 l_stmt_num := 60;
1711
1712 -- Invoke Updation only if the wip_entity_id is NON-NULL...
1713 IF p_wip_entity_id IS NOT NULL THEN
1714
1715 l_stmt_num := 70;
1716
1717 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1718 l_msg_tokens.delete;
1719 WSM_log_PVT.logMessage (p_module_name => l_module ,
1720 p_msg_text => 'Invoking update_serial',
1721 p_stmt_num => l_stmt_num ,
1722 p_msg_tokens => l_msg_tokens ,
1723 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1724 p_run_log_level => l_log_level
1725 );
1726 END IF;
1727
1728 -- Update the serial number to the job...
1729 update_serial( p_serial_number => p_serial_number,
1730 p_inventory_item_id => p_inventory_item_id,
1731 --p_new_inventory_item_id => p_inventory_item_id,
1732 p_organization_id => p_organization_id,
1733 p_wip_entity_id => p_wip_entity_id,
1734 p_operation_seq_num => p_operation_seq_num,
1735 p_intraoperation_step_type => p_intraoperation_step,
1736 x_return_status => x_return_status,
1737 x_error_msg => x_error_msg,
1738 x_error_count => x_error_count
1739 );
1740
1741 l_stmt_num := 80;
1742
1743 if x_return_status <> G_RET_SUCCESS then
1744 IF x_return_status = G_RET_ERROR THEN
1745 raise FND_API.G_EXC_ERROR;
1746 ELSIF x_return_status = G_RET_UNEXPECTED THEN
1747 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1748 END IF;
1749 end if;
1750
1751 END IF;
1752
1753 EXCEPTION
1754
1755 WHEN FND_API.G_EXC_ERROR THEN
1756
1757 x_return_status := G_RET_ERROR;
1758 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1759 p_count => x_error_count ,
1760 p_data => x_error_msg
1761 );
1762
1763 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1764
1765 x_return_status := G_RET_UNEXPECTED;
1766
1767 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1768 p_count => x_error_count ,
1769 p_data => x_error_msg
1770 );
1771 WHEN OTHERS THEN
1772
1773 x_return_status := G_RET_UNEXPECTED;
1774
1775 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1776 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1777 THEN
1778 WSM_log_PVT.handle_others( p_module_name => l_module ,
1779 p_stmt_num => l_stmt_num ,
1780 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1781 p_run_log_level => l_log_level
1782 );
1783 END IF;
1784
1785 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1786 p_count => x_error_count ,
1787 p_data => x_error_msg
1788 );
1789
1790 END add_assoc_serial_number;
1791
1792 Procedure add_serial_number ( p_assembly_item_id IN NUMBER,
1793 p_organization_id IN NUMBER,
1794 p_wip_entity_id IN NUMBER,
1795 -- pass 1 if the calling program knows that it is a new serial number
1796 p_new_serial_number IN NUMBER DEFAULT NULL,
1797 p_serial_number IN OUT NOCOPY VARCHAR2,
1798 x_return_status OUT NOCOPY VARCHAR2,
1799 x_error_msg OUT NOCOPY VARCHAR2,
1800 x_error_count OUT NOCOPY NUMBER
1801 )
1802
1803 IS
1804 l_wip_entity_id NUMBER;
1805 l_group_mark_id NUMBER;
1806 l_line_mark_id NUMBER;
1807 l_current_status NUMBER;
1808 l_last_txn_srcid NUMBER;
1809 l_last_txn_src_typid NUMBER;
1810
1811 l_quantity NUMBER;
1812 l_return_code NUMBER;
1813 l_error_msg VARCHAR2(2000);
1814 l_serial_number VARCHAR2(30);
1815 l_exists NUMBER := 0;
1816 l_gen_object_id NUMBER;
1817
1818 -- Logging variables.....
1819 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
1820 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1821
1822 l_stmt_num NUMBER;
1823 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.add_serial_number';
1824 -- Logging variables...
1825
1826 BEGIN
1827
1828 l_stmt_num := 10;
1829 x_return_status := G_RET_SUCCESS;
1830 x_error_msg := NULL;
1831 x_error_count := 0;
1832
1833 IF p_new_serial_number IS NULL THEN -- calling program doesnt know...
1834
1835 l_stmt_num := 20;
1836 BEGIN
1837 select wip_entity_id,
1838 group_mark_id,
1839 line_mark_id,
1840 current_status,
1841 last_txn_source_id,
1842 last_txn_source_type_id,
1843 gen_object_id
1844 into l_wip_entity_id,
1845 l_group_mark_id,
1846 l_line_mark_id,
1847 l_current_status,
1848 l_last_txn_srcid,
1849 l_last_txn_src_typid,
1850 l_gen_object_id
1851 from mtl_serial_numbers
1852 where inventory_item_id = p_assembly_item_id
1853 and current_organization_id = p_organization_id
1854 and serial_number = p_serial_number;
1855
1856 IF ( l_current_status in (1,6)
1857 and l_wip_entity_id is null
1858 and l_group_mark_id is null
1859 and l_line_Mark_id is null
1860 )
1861 THEN
1862 --serial number is available...
1863 return;
1864 ELSIF ( ( l_current_status = 4 and
1865 l_last_txn_srcid = p_wip_entity_id and
1866 l_last_txn_src_typid = 5
1867 )
1868 and l_wip_entity_id is null
1869 and l_group_mark_id is null
1870 and l_line_Mark_id is null
1871 )
1872 THEN
1873 -- The serial is issued to the job .. check that it is not linked to any of the serials of the
1874 -- job.
1875 l_exists := 0;
1876
1877 select count(1)
1878 into l_exists
1879 from mtl_object_genealogy mog,
1880 mtl_serial_numbers msn
1881 where mog.object_id = l_gen_object_id
1882 and mog.parent_object_type = 2
1883 and mog.parent_object_id = msn.gen_object_id
1884 and msn.inventory_item_id = p_assembly_item_id
1885 and msn.current_organization_id = p_organization_id
1886 and msn.wip_entity_id = p_wip_entity_id;
1887
1888 IF l_exists = 1 THEN
1889 IF g_log_level_error >= l_log_level OR
1890 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1891 THEN
1892 l_msg_tokens.delete;
1893 WSM_log_PVT.logMessage(p_module_name => l_module ,
1894 p_msg_name => 'WIP_JDI_INVALID_UNUSED_SERIAL',
1895 p_msg_appl_name => 'WIP' ,
1896 p_msg_tokens => l_msg_tokens ,
1897 p_stmt_num => l_stmt_num ,
1898 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1899 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1900 p_run_log_level => l_log_level
1901 );
1902 END IF;
1903 RAISE FND_API.G_EXC_ERROR;
1904 END IF;
1905 ELSE
1906 IF g_log_level_error >= l_log_level OR
1907 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
1908 THEN
1909 l_msg_tokens.delete;
1910 WSM_log_PVT.logMessage(p_module_name => l_module ,
1911 p_msg_name => 'WIP_JDI_INVALID_UNUSED_SERIAL',
1912 p_msg_appl_name => 'WIP' ,
1913 p_msg_tokens => l_msg_tokens ,
1914 p_stmt_num => l_stmt_num ,
1915 p_fnd_msg_level => G_MSG_LVL_ERROR ,
1916 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
1917 p_run_log_level => l_log_level
1918 );
1919 END IF;
1920 RAISE FND_API.G_EXC_ERROR;
1921 END IF;
1922
1923 EXCEPTION
1924 WHEN NO_DATA_FOUND THEN
1925 null;
1926 END;
1927
1928 END IF;
1929
1930 -- We'll reach here only if the serial number is not found...
1931 -- or the calling program had passed 1 for new serial number
1932 -- Invoke the API.. to generate this serial number...
1933
1934 l_stmt_num := 30;
1935
1936
1937 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
1938 l_msg_tokens.delete;
1939 WSM_log_PVT.logMessage (p_module_name => l_module ,
1940 p_msg_text => 'Invoking inv_serial_number_pub.validate_serials',
1941 p_stmt_num => l_stmt_num ,
1942 p_msg_tokens => l_msg_tokens ,
1943 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
1944 p_run_log_level => l_log_level
1945 );
1946 END IF;
1947
1948 l_quantity := 0;
1949 l_return_code := inv_serial_number_pub.validate_serials ( p_org_id => p_organization_id,
1950 p_item_id => p_assembly_item_id,
1951 p_qty => l_quantity,
1952 p_wip_entity_id => null,
1953 p_group_mark_id => null,
1954 p_line_mark_id => null,
1955 p_rev => null,
1956 p_lot => null,
1957 p_start_ser => p_serial_number,
1958 p_trx_src_id => null,
1959 p_trx_action_id => null,
1960 p_subinventory_code => null,
1961 p_locator_id => null,
1962 x_end_ser => p_serial_number,
1963 x_proc_msg => x_error_msg);
1964
1965 l_stmt_num := 40;
1966
1967 if l_quantity <> 1 or l_return_code <> 0 then
1968 RAISE FND_API.G_EXC_ERROR;
1969 end if;
1970
1971 EXCEPTION
1972
1973 WHEN FND_API.G_EXC_ERROR THEN
1974
1975 x_return_status := G_RET_ERROR;
1976 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1977 p_count => x_error_count ,
1978 p_data => x_error_msg
1979 );
1980
1981 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1982
1983 x_return_status := G_RET_UNEXPECTED;
1984
1985 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
1986 p_count => x_error_count ,
1987 p_data => x_error_msg
1988 );
1989 WHEN OTHERS THEN
1990
1991 x_return_status := G_RET_UNEXPECTED;
1992
1993 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
1994 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
1995 THEN
1996 WSM_log_PVT.handle_others( p_module_name => l_module ,
1997 p_stmt_num => l_stmt_num ,
1998 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
1999 p_run_log_level => l_log_level
2000 );
2001 END IF;
2002
2003 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2004 p_count => x_error_count ,
2005 p_data => x_error_msg
2006 );
2007
2008 END add_serial_number;
2009
2010 --- p_calling_mode = 1 --> Interface
2011 --- = 2 --> Non-Interface..
2012 --- update_serial_attr(1)
2013
2014 PROCEDURE update_serial_attr ( p_calling_mode IN NUMBER,
2015 p_serial_number_rec IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_REC,
2016 p_inventory_item_id IN NUMBER,
2017 p_organization_id IN NUMBER,
2018 p_clear_serial_attr IN NUMBER DEFAULT NULL, -- will be used in case of WLT to clear the attributes
2019 p_wlt_txn_type IN NUMBER DEFAULT NULL,
2020 -- Pass the serial attribute context corresponding to the inventory item id
2021 p_serial_attr_context IN VARCHAR2 DEFAULT NULL,
2022 p_update_serial_attr IN NUMBER,
2023 p_update_desc_attr IN NUMBER,
2024 x_return_status OUT NOCOPY VARCHAR2,
2025 x_error_count OUT NOCOPY NUMBER,
2026 x_error_msg OUT NOCOPY VARCHAR2
2027 )
2028
2029 IS
2030 l_serial_attributes_tbl inv_lot_sel_attr.lot_sel_attributes_tbl_type;
2031 l_desc_attributes_tbl inv_serial_number_attr.char_table;
2032
2033 l_miss_char VARCHAR2(1) := FND_API.G_MISS_CHAR;
2034 l_attribute_category VARCHAR2(30);
2035
2036 l_update_serial_attr NUMBER;
2037 l_update_desc_attr NUMBER;
2038
2039 l_ser_context MTL_SERIAL_NUMBERS.serial_attribute_category%type;
2040
2041
2042 -- Logging variables.....
2043 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2044 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2045
2046 l_stmt_num NUMBER;
2047 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.update_serial_attr';
2048 l_param_tbl WSM_Log_PVT.param_tbl_type;
2049 -- Logging variables...
2050
2051 BEGIN
2052 l_stmt_num := 10;
2053
2054 x_return_status := G_RET_SUCCESS;
2055 x_error_msg := NULL;
2056 x_error_count := 0;
2057
2058 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
2059
2060 l_param_tbl.delete;
2061 l_param_tbl(1).paramName := 'p_inventory_item_id';
2062 l_param_tbl(1).paramValue := p_inventory_item_id;
2063
2064 l_param_tbl(2).paramName := 'p_organization_id';
2065 l_param_tbl(2).paramValue := p_organization_id;
2066
2067 l_param_tbl(3).paramName := 'p_serial_attr_context';
2068 l_param_tbl(3).paramValue := p_serial_attr_context;
2069
2070 WSM_Log_PVT.logProcParams(p_module_name => l_module,
2071 p_param_tbl => l_param_tbl,
2072 p_fnd_log_level => l_log_level
2073 );
2074 END IF;
2075
2076
2077 l_update_serial_attr := p_update_serial_attr;
2078
2079 l_stmt_num := 20;
2080
2081 if l_update_serial_attr is null then -- the calling program hasnt passed on the value..
2082
2083 -- derive if a context exists...
2084 -- need an additional check on if WMS is installed or not...
2085 l_stmt_num := 30;
2086
2087 if g_wms_installed IS NULL THEN
2088
2089 wms_installed ( x_return_status => x_return_status ,
2090 x_error_count => x_error_count ,
2091 x_err_data => x_error_msg
2092 );
2093
2094 if x_return_status <> g_ret_success then
2095 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2096 end if;
2097
2098 l_update_serial_attr := g_wms_installed;
2099 else
2100 l_update_serial_attr := g_wms_installed;
2101 end if;
2102 end if;
2103
2104 l_stmt_num := 40;
2105
2106 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2107 l_msg_tokens.delete;
2108 WSM_log_PVT.logMessage (p_module_name => l_module ,
2109 p_msg_text => 'Value of l_update_serial_attr ' || l_update_serial_attr,
2110 p_stmt_num => l_stmt_num ,
2111 p_msg_tokens => l_msg_tokens ,
2112 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2113 p_run_log_level => l_log_level
2114 );
2115 END IF;
2116
2117 l_stmt_num := 41;
2118 IF p_serial_attr_context IS NULL THEN
2119 -- The calling program hasnt passed the value...
2120 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_ser_context,
2121 org_id => p_organization_id ,
2122 item_id => p_inventory_item_id,
2123 flex_name => 'Serial Attributes'
2124 );
2125
2126 ELSE
2127 l_ser_context := p_serial_attr_context;
2128 END IF;
2129
2130 l_stmt_num := 42;
2131 IF l_ser_context <> p_serial_number_rec.SERIAL_ATTRIBUTE_CATEGORY THEN
2132 -- error out.. if no context is defined then l_ser_context will be NULL
2133 -- and the user is free to specify the context..
2134 -- IF the user has passed NULL the INV API takes care of finding the defined context...
2135 -- populate a error message saying that the attributes will be cleared...
2136 IF g_log_level_exception >= l_log_level OR
2137 FND_MSG_PUB.check_msg_level(G_MSG_LVL_DEBUG_HIGH)
2138 THEN
2139 l_msg_tokens.delete;
2140 l_msg_tokens(1).TokenName := 'FLD_NAME';
2141 l_msg_tokens(1).TokenValue := 'Serial Attribute Category for Serial Number : ' || p_serial_number_rec.serial_number;
2142
2143 WSM_log_PVT.logMessage(p_module_name => l_module ,
2144 p_msg_name => 'WSM_INVALID_FIELD' ,
2145 p_msg_appl_name => 'WSM' ,
2146 p_msg_tokens => l_msg_tokens ,
2147 p_fnd_msg_level => G_MSG_LVL_SUCCESS ,
2148 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
2149 p_run_log_level => l_log_level ,
2150 p_wsm_warning => 1
2151 );
2152 END IF;
2153 END IF;
2154
2155 -- now construct the PL/SQL tables...
2156 if l_update_serial_attr = 1 THEN
2157
2158 l_stmt_num := 50;
2159
2160 l_serial_attributes_tbl(1).column_name := 'SERIAL_ATTRIBUTE_CATEGORY';
2161 l_serial_attributes_tbl(1).column_type := 'VARCHAR2';
2162 l_serial_attributes_tbl(2).column_name := 'ORIGINATION_DATE';
2163 l_serial_attributes_tbl(2).column_type := 'DATE';
2164 l_serial_attributes_tbl(3).column_name := 'C_ATTRIBUTE1';
2165 l_serial_attributes_tbl(3).column_type := 'VARCHAR2';
2166 l_serial_attributes_tbl(4).column_name := 'C_ATTRIBUTE2';
2167 l_serial_attributes_tbl(4).column_type := 'VARCHAR2';
2168 l_serial_attributes_tbl(5).column_name := 'C_ATTRIBUTE3';
2169 l_serial_attributes_tbl(5).column_type := 'VARCHAR2';
2170 l_serial_attributes_tbl(6).column_name := 'C_ATTRIBUTE4';
2171 l_serial_attributes_tbl(6).column_type := 'VARCHAR2';
2172 l_serial_attributes_tbl(7).column_name := 'C_ATTRIBUTE5';
2173 l_serial_attributes_tbl(7).column_type := 'VARCHAR2';
2174 l_serial_attributes_tbl(8).column_name := 'C_ATTRIBUTE6';
2175 l_serial_attributes_tbl(8).column_type := 'VARCHAR2';
2176 l_serial_attributes_tbl(9).column_name := 'C_ATTRIBUTE7';
2177 l_serial_attributes_tbl(9).column_type := 'VARCHAR2';
2178 l_serial_attributes_tbl(10).column_name := 'C_ATTRIBUTE8';
2179 l_serial_attributes_tbl(10).column_type := 'VARCHAR2';
2180 l_serial_attributes_tbl(11).column_name := 'C_ATTRIBUTE9';
2181 l_serial_attributes_tbl(11).column_type := 'VARCHAR2';
2182 l_serial_attributes_tbl(12).column_name := 'C_ATTRIBUTE10';
2183 l_serial_attributes_tbl(12).column_type := 'VARCHAR2';
2184 l_serial_attributes_tbl(13).column_name := 'C_ATTRIBUTE11';
2185 l_serial_attributes_tbl(13).column_type := 'VARCHAR2';
2186 l_serial_attributes_tbl(14).column_name := 'C_ATTRIBUTE12';
2187 l_serial_attributes_tbl(14).column_type := 'VARCHAR2';
2188 l_serial_attributes_tbl(15).column_name := 'C_ATTRIBUTE13';
2189 l_serial_attributes_tbl(15).column_type := 'VARCHAR2';
2190 l_serial_attributes_tbl(16).column_name := 'C_ATTRIBUTE14';
2191 l_serial_attributes_tbl(16).column_type := 'VARCHAR2';
2192 l_serial_attributes_tbl(17).column_name := 'C_ATTRIBUTE15';
2193 l_serial_attributes_tbl(17).column_type := 'VARCHAR2';
2194 l_serial_attributes_tbl(18).column_name := 'C_ATTRIBUTE16';
2195 l_serial_attributes_tbl(18).column_type := 'VARCHAR2';
2196 l_serial_attributes_tbl(19).column_name := 'C_ATTRIBUTE17';
2197 l_serial_attributes_tbl(19).column_type := 'VARCHAR2';
2198 l_serial_attributes_tbl(20).column_name := 'C_ATTRIBUTE18';
2199 l_serial_attributes_tbl(20).column_type := 'VARCHAR2';
2200 l_serial_attributes_tbl(21).column_name := 'C_ATTRIBUTE19';
2201 l_serial_attributes_tbl(21).column_type := 'VARCHAR2';
2202 l_serial_attributes_tbl(22).column_name := 'C_ATTRIBUTE20';
2203 l_serial_attributes_tbl(22).column_type := 'VARCHAR2';
2204 l_serial_attributes_tbl(23).column_name := 'D_ATTRIBUTE1';
2205 l_serial_attributes_tbl(23).column_type := 'DATE';
2206 l_serial_attributes_tbl(24).column_name := 'D_ATTRIBUTE2';
2207 l_serial_attributes_tbl(24).column_type := 'DATE';
2208 l_serial_attributes_tbl(25).column_name := 'D_ATTRIBUTE3';
2209 l_serial_attributes_tbl(25).column_type := 'DATE';
2210 l_serial_attributes_tbl(26).column_name := 'D_ATTRIBUTE4';
2211 l_serial_attributes_tbl(26).column_type := 'DATE';
2212 l_serial_attributes_tbl(27).column_name := 'D_ATTRIBUTE5';
2213 l_serial_attributes_tbl(27).column_type := 'DATE';
2214 l_serial_attributes_tbl(28).column_name := 'D_ATTRIBUTE6';
2215 l_serial_attributes_tbl(28).column_type := 'DATE';
2216 l_serial_attributes_tbl(29).column_name := 'D_ATTRIBUTE7';
2217 l_serial_attributes_tbl(29).column_type := 'DATE';
2218 l_serial_attributes_tbl(30).column_name := 'D_ATTRIBUTE8';
2219 l_serial_attributes_tbl(30).column_type := 'DATE';
2220 l_serial_attributes_tbl(31).column_name := 'D_ATTRIBUTE9';
2221 l_serial_attributes_tbl(31).column_type := 'DATE';
2222 l_serial_attributes_tbl(32).column_name := 'D_ATTRIBUTE10';
2223 l_serial_attributes_tbl(32).column_type := 'DATE';
2224 l_serial_attributes_tbl(33).column_name := 'N_ATTRIBUTE1';
2225 l_serial_attributes_tbl(33).column_type := 'NUMBER';
2226 l_serial_attributes_tbl(34).column_name := 'N_ATTRIBUTE2';
2227 l_serial_attributes_tbl(34).column_type := 'NUMBER';
2228 l_serial_attributes_tbl(35).column_name := 'N_ATTRIBUTE3';
2229 l_serial_attributes_tbl(35).column_type := 'NUMBER';
2230 l_serial_attributes_tbl(36).column_name := 'N_ATTRIBUTE4';
2231 l_serial_attributes_tbl(36).column_type := 'NUMBER';
2232 l_serial_attributes_tbl(37).column_name := 'N_ATTRIBUTE5';
2233 l_serial_attributes_tbl(37).column_type := 'NUMBER';
2234 l_serial_attributes_tbl(38).column_name := 'N_ATTRIBUTE6';
2235 l_serial_attributes_tbl(38).column_type := 'NUMBER';
2236 l_serial_attributes_tbl(39).column_name := 'N_ATTRIBUTE7';
2237 l_serial_attributes_tbl(39).column_type := 'NUMBER';
2238 l_serial_attributes_tbl(40).column_name := 'N_ATTRIBUTE8';
2239 l_serial_attributes_tbl(40).column_type := 'NUMBER';
2240 l_serial_attributes_tbl(41).column_name := 'N_ATTRIBUTE9';
2241 l_serial_attributes_tbl(41).column_type := 'NUMBER';
2242 l_serial_attributes_tbl(42).column_name := 'N_ATTRIBUTE10';
2243 l_serial_attributes_tbl(42).column_type := 'NUMBER';
2244 l_serial_attributes_tbl(43).column_name := 'STATUS_ID';
2245 l_serial_attributes_tbl(43).column_type := 'NUMBER';
2246 l_serial_attributes_tbl(44).column_name := 'TERRITORY_CODE';
2247 l_serial_attributes_tbl(44).column_type := 'VARCHAR2';
2248
2249 IF p_clear_serial_attr IS NOT NULL THEN
2250 -- clear all the attributes..
2251 -- clear all the attributes..
2252 l_stmt_num := 60;
2253 for l_counter in 1..44 loop
2254 l_serial_attributes_tbl(l_counter).column_value := null;
2255 end loop;
2256 ELSE
2257 l_stmt_num := 70;
2258
2259 l_serial_attributes_tbl(1).column_value := p_serial_number_rec.SERIAL_ATTRIBUTE_CATEGORY;
2260 l_serial_attributes_tbl(2).column_value := p_serial_number_rec.ORIGINATION_DATE;
2261 l_serial_attributes_tbl(3).column_value := p_serial_number_rec.C_ATTRIBUTE1;
2262 l_serial_attributes_tbl(4).column_value := p_serial_number_rec.C_ATTRIBUTE2;
2263 l_serial_attributes_tbl(5).column_value := p_serial_number_rec.C_ATTRIBUTE3;
2264 l_serial_attributes_tbl(6).column_value := p_serial_number_rec.C_ATTRIBUTE4;
2265 l_serial_attributes_tbl(7).column_value := p_serial_number_rec.C_ATTRIBUTE5;
2266 l_serial_attributes_tbl(8).column_value := p_serial_number_rec.C_ATTRIBUTE6;
2267 l_serial_attributes_tbl(9).column_value := p_serial_number_rec.C_ATTRIBUTE7;
2268 l_serial_attributes_tbl(10).column_value := p_serial_number_rec.C_ATTRIBUTE8;
2269 l_serial_attributes_tbl(11).column_value := p_serial_number_rec.C_ATTRIBUTE9;
2270 l_serial_attributes_tbl(12).column_value := p_serial_number_rec.C_ATTRIBUTE10;
2271 l_serial_attributes_tbl(13).column_value := p_serial_number_rec.C_ATTRIBUTE11;
2272 l_serial_attributes_tbl(14).column_value := p_serial_number_rec.C_ATTRIBUTE12;
2273 l_serial_attributes_tbl(15).column_value := p_serial_number_rec.C_ATTRIBUTE13;
2274 l_serial_attributes_tbl(16).column_value := p_serial_number_rec.C_ATTRIBUTE14;
2275 l_serial_attributes_tbl(17).column_value := p_serial_number_rec.C_ATTRIBUTE15;
2276 l_serial_attributes_tbl(18).column_value := p_serial_number_rec.C_ATTRIBUTE16;
2277 l_serial_attributes_tbl(19).column_value := p_serial_number_rec.C_ATTRIBUTE17;
2278 l_serial_attributes_tbl(20).column_value := p_serial_number_rec.C_ATTRIBUTE18;
2279 l_serial_attributes_tbl(21).column_value := p_serial_number_rec.C_ATTRIBUTE19;
2280 l_serial_attributes_tbl(22).column_value := p_serial_number_rec.C_ATTRIBUTE20;
2281 l_serial_attributes_tbl(23).column_value := p_serial_number_rec.D_ATTRIBUTE1;
2282 l_serial_attributes_tbl(24).column_value := p_serial_number_rec.D_ATTRIBUTE2;
2283 l_serial_attributes_tbl(25).column_value := p_serial_number_rec.D_ATTRIBUTE3;
2284 l_serial_attributes_tbl(26).column_value := p_serial_number_rec.D_ATTRIBUTE4;
2285 l_serial_attributes_tbl(27).column_value := p_serial_number_rec.D_ATTRIBUTE5;
2286 l_serial_attributes_tbl(28).column_value := p_serial_number_rec.D_ATTRIBUTE6;
2287 l_serial_attributes_tbl(29).column_value := p_serial_number_rec.D_ATTRIBUTE7;
2288 l_serial_attributes_tbl(30).column_value := p_serial_number_rec.D_ATTRIBUTE8;
2289 l_serial_attributes_tbl(31).column_value := p_serial_number_rec.D_ATTRIBUTE9;
2290 l_serial_attributes_tbl(32).column_value := p_serial_number_rec.D_ATTRIBUTE10;
2291 l_serial_attributes_tbl(33).column_value := p_serial_number_rec.N_ATTRIBUTE1;
2292 l_serial_attributes_tbl(34).column_value := p_serial_number_rec.N_ATTRIBUTE2;
2293 l_serial_attributes_tbl(35).column_value := p_serial_number_rec.N_ATTRIBUTE3;
2294 l_serial_attributes_tbl(36).column_value := p_serial_number_rec.N_ATTRIBUTE4;
2295 l_serial_attributes_tbl(37).column_value := p_serial_number_rec.N_ATTRIBUTE5;
2296 l_serial_attributes_tbl(38).column_value := p_serial_number_rec.N_ATTRIBUTE6;
2297 l_serial_attributes_tbl(39).column_value := p_serial_number_rec.N_ATTRIBUTE7;
2298 l_serial_attributes_tbl(40).column_value := p_serial_number_rec.N_ATTRIBUTE8;
2299 l_serial_attributes_tbl(41).column_value := p_serial_number_rec.N_ATTRIBUTE9;
2300 l_serial_attributes_tbl(42).column_value := p_serial_number_rec.N_ATTRIBUTE10;
2301 l_serial_attributes_tbl(43).column_value := p_serial_number_rec.STATUS_ID;
2302 l_serial_attributes_tbl(44).column_value := p_serial_number_rec.TERRITORY_CODE;
2303
2304 END IF;
2305
2306 END IF;
2307
2308 l_stmt_num := 72;
2309 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2310
2311 l_msg_tokens.delete;
2312 WSM_log_PVT.logMessage (p_module_name => l_module ,
2313 p_msg_text => 'Value of p_update_desc_attr ' || p_update_desc_attr,
2314 p_stmt_num => l_stmt_num ,
2315 p_msg_tokens => l_msg_tokens ,
2316 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2317 p_run_log_level => l_log_level
2318 );
2319 END IF;
2320
2321 IF nvl(p_update_desc_attr,1) = 1 THEN
2322
2323 l_stmt_num := 75;
2324
2325 If p_calling_mode = 1 THEN -- Interface
2326
2327 l_stmt_num := 80;
2328
2329 l_desc_attributes_tbl(1) := p_serial_number_rec.attribute1;
2330 l_desc_attributes_tbl(2) := p_serial_number_rec.attribute2;
2331 l_desc_attributes_tbl(3) := p_serial_number_rec.attribute3;
2332 l_desc_attributes_tbl(4) := p_serial_number_rec.attribute4;
2333 l_desc_attributes_tbl(5) := p_serial_number_rec.attribute5;
2334 l_desc_attributes_tbl(6) := p_serial_number_rec.attribute6;
2335 l_desc_attributes_tbl(7) := p_serial_number_rec.attribute7;
2336 l_desc_attributes_tbl(8) := p_serial_number_rec.attribute8;
2337 l_desc_attributes_tbl(9) := p_serial_number_rec.attribute9;
2338 l_desc_attributes_tbl(10) := p_serial_number_rec.attribute10;
2339 l_desc_attributes_tbl(11) := p_serial_number_rec.attribute11;
2340 l_desc_attributes_tbl(12) := p_serial_number_rec.attribute12;
2341 l_desc_attributes_tbl(13) := p_serial_number_rec.attribute13;
2342 l_desc_attributes_tbl(14) := p_serial_number_rec.attribute14;
2343 l_desc_attributes_tbl(15) := p_serial_number_rec.attribute15;
2344
2345 ELSE
2346 l_stmt_num := 90;
2347
2348 l_desc_attributes_tbl(1) := NVL(p_serial_number_rec.attribute1,l_miss_char);
2349 l_desc_attributes_tbl(2) := NVL(p_serial_number_rec.attribute2,l_miss_char);
2350 l_desc_attributes_tbl(3) := NVL(p_serial_number_rec.attribute3,l_miss_char);
2351 l_desc_attributes_tbl(4) := NVL(p_serial_number_rec.attribute4,l_miss_char);
2352 l_desc_attributes_tbl(5) := NVL(p_serial_number_rec.attribute5,l_miss_char);
2353 l_desc_attributes_tbl(6) := NVL(p_serial_number_rec.attribute6,l_miss_char);
2354 l_desc_attributes_tbl(7) := NVL(p_serial_number_rec.attribute7,l_miss_char);
2355 l_desc_attributes_tbl(8) := NVL(p_serial_number_rec.attribute8,l_miss_char);
2356 l_desc_attributes_tbl(9) := NVL(p_serial_number_rec.attribute9,l_miss_char);
2357 l_desc_attributes_tbl(10) := NVL(p_serial_number_rec.attribute10,l_miss_char);
2358 l_desc_attributes_tbl(11) := NVL(p_serial_number_rec.attribute11,l_miss_char);
2359 l_desc_attributes_tbl(12) := NVL(p_serial_number_rec.attribute12,l_miss_char);
2360 l_desc_attributes_tbl(13) := NVL(p_serial_number_rec.attribute13,l_miss_char);
2361 l_desc_attributes_tbl(14) := NVL(p_serial_number_rec.attribute14,l_miss_char);
2362 l_desc_attributes_tbl(15) := NVL(p_serial_number_rec.attribute15,l_miss_char);
2363
2364 END IF;
2365
2366 l_attribute_category := p_serial_number_rec.attribute_category;
2367
2368 END IF;
2369
2370 l_stmt_num := 100;
2371 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2372
2373 l_msg_tokens.delete;
2374 WSM_log_PVT.logMessage (p_module_name => l_module ,
2375 p_msg_text => 'Invoking the procedure update_serial_attr(2)',
2376 p_stmt_num => l_stmt_num ,
2377 p_msg_tokens => l_msg_tokens ,
2378 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2379 p_run_log_level => l_log_level
2380 );
2381 END IF;
2382
2383 update_serial_attr( p_job_serial_number => p_serial_number_rec.serial_number ,
2384 p_inventory_item_id => p_inventory_item_id ,
2385 p_organization_id => p_organization_id ,
2386 p_serial_desc_attr_tbl => l_desc_attributes_tbl ,
2387 p_attribute_category => l_attribute_category ,
2388 p_update_serial_attr => p_update_serial_attr ,
2389 p_update_desc_attr => 1 ,
2390 p_serial_attributes_tbl => l_serial_attributes_tbl ,
2391 x_return_status => x_return_status ,
2392 x_error_count => x_error_count ,
2393 x_error_msg => x_error_msg
2394 );
2395
2396 if x_return_status <> G_RET_SUCCESS then
2397 IF x_return_status = G_RET_ERROR THEN
2398 raise FND_API.G_EXC_ERROR;
2399 ELSIF x_return_status = G_RET_UNEXPECTED THEN
2400 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2401 END IF;
2402 end if;
2403
2404 EXCEPTION
2405
2406 WHEN FND_API.G_EXC_ERROR THEN
2407
2408 x_return_status := G_RET_ERROR;
2409 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2410 p_count => x_error_count ,
2411 p_data => x_error_msg
2412 );
2413
2414 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2415
2416 x_return_status := G_RET_UNEXPECTED;
2417
2418 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2419 p_count => x_error_count ,
2420 p_data => x_error_msg
2421 );
2422 WHEN OTHERS THEN
2423
2424 x_return_status := G_RET_UNEXPECTED;
2425
2426 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2427 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2428 THEN
2429 WSM_log_PVT.handle_others( p_module_name => l_module ,
2430 p_stmt_num => l_stmt_num ,
2431 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2432 p_run_log_level => l_log_level
2433 );
2434 END IF;
2435
2436 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2437 p_count => x_error_count ,
2438 p_data => x_error_msg
2439 );
2440 END update_serial_attr;
2441
2442
2443 PROCEDURE update_serial_attr( p_job_serial_number IN VARCHAR2,
2444 p_inventory_item_id IN NUMBER,
2445 p_organization_id IN NUMBER,
2446 p_serial_desc_attr_tbl IN inv_serial_number_attr.char_table,
2447 p_attribute_category IN VARCHAR2,
2448 p_update_serial_attr IN NUMBER DEFAULT NULL,
2449 p_update_desc_attr IN NUMBER,
2450 p_serial_attributes_tbl IN inv_lot_sel_attr.lot_sel_attributes_tbl_type,
2451 x_return_status OUT NOCOPY VARCHAR2,
2452 x_error_count OUT NOCOPY NUMBER,
2453 x_error_msg OUT NOCOPY VARCHAR2
2454 ) IS
2455
2456 l_validation_status varchar2(10);
2457 l_update_serial_attr NUMBER;
2458 l_update_desc_attr NUMBER;
2459
2460 l_context_value MTL_SERIAL_NUMBERS.serial_attribute_category%type;
2461
2462 -- Logging variables.....
2463 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2464 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2465
2466 l_stmt_num NUMBER;
2467 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.update_serial_attr(2)';
2468 l_param_tbl WSM_Log_PVT.param_tbl_type;
2469 -- Logging variables...
2470
2471 BEGIN
2472 l_stmt_num := 10;
2473
2474 x_return_status := G_RET_SUCCESS;
2475 x_error_msg := NULL;
2476 x_error_count := 0;
2477
2478 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
2479
2480 l_param_tbl.delete;
2481 l_param_tbl(1).paramName := 'p_update_serial_attr';
2482 l_param_tbl(1).paramValue := p_update_serial_attr;
2483
2484 l_param_tbl(2).paramName := 'p_update_desc_attr';
2485 l_param_tbl(2).paramValue := p_update_desc_attr;
2486
2487 WSM_Log_PVT.logProcParams(p_module_name => l_module,
2488 p_param_tbl => l_param_tbl,
2489 p_fnd_log_level => l_log_level
2490 );
2491 END IF;
2492
2493 l_update_serial_attr := p_update_serial_attr;
2494 l_update_desc_attr := nvl(p_update_desc_attr,1);
2495
2496 l_stmt_num := 20;
2497
2498 if l_update_serial_attr is null then -- the calling program hasnt passed on the value..
2499
2500 l_stmt_num := 30;
2501 -- derive if a context exists...
2502 -- need an additional check on if WMS is installed or not...
2503 if g_wms_installed IS NULL THEN
2504
2505 wms_installed ( x_return_status => x_return_status ,
2506 x_error_count => x_error_count ,
2507 x_err_data => x_error_msg
2508 );
2509
2510 if x_return_status <> g_ret_success then
2511 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2512 end if;
2513
2514 l_update_serial_attr := g_wms_installed;
2515 else
2516 l_update_serial_attr := g_wms_installed;
2517 end if;
2518 end if;
2519
2520 l_stmt_num := 40;
2521 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2522 l_msg_tokens.delete;
2523 WSM_log_PVT.logMessage (p_module_name => l_module ,
2524 p_msg_text => 'Value of l_update_serial_attr : ' || l_update_serial_attr,
2525 p_stmt_num => l_stmt_num ,
2526 p_msg_tokens => l_msg_tokens ,
2527 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2528 p_run_log_level => l_log_level
2529 );
2530 END IF;
2531
2532 if (l_update_serial_attr = 1)
2533 then
2534 l_stmt_num := 50;
2535
2536 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2537 l_msg_tokens.delete;
2538 WSM_log_PVT.logMessage (p_module_name => l_module ,
2539 p_msg_text => 'Invoking INV_SERIAL_NUMBER_PUB.validate_update_serial_att',
2540 p_stmt_num => l_stmt_num ,
2541 p_msg_tokens => l_msg_tokens ,
2542 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2543 p_run_log_level => l_log_level
2544 );
2545 END IF;
2546
2547 INV_SERIAL_NUMBER_PUB.validate_update_serial_att (x_return_status => x_return_status,
2548 x_msg_count => x_error_count ,
2549 x_msg_data => x_error_msg ,
2550 x_validation_status => l_validation_status,
2551 p_serial_number => p_job_serial_number,
2552 p_organization_id => p_organization_id,
2553 p_inventory_item_id => p_inventory_item_id,
2554 p_serial_att_tbl => p_serial_attributes_tbl,
2555 p_validate_only => false
2556 );
2557
2558 if x_return_status <> g_ret_success or l_validation_status <> 'Y' then
2559 IF x_return_status = G_RET_ERROR THEN
2560 raise FND_API.G_EXC_ERROR;
2561 ELSIF x_return_status = G_RET_UNEXPECTED THEN
2562 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2563 END IF;
2564 end if;
2565 end if;
2566
2567 l_stmt_num := 60;
2568
2569 IF l_update_desc_attr = 1 then
2570
2571 l_stmt_num := 70;
2572
2573 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2574 l_msg_tokens.delete;
2575 WSM_log_PVT.logMessage (p_module_name => l_module ,
2576 p_msg_text => 'Invoking INV_SERIAL_NUMBER_ATTR.Update_Serial_number_attr',
2577 p_stmt_num => l_stmt_num ,
2578 p_msg_tokens => l_msg_tokens ,
2579 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2580 p_run_log_level => l_log_level
2581 );
2582 END IF;
2583
2584 -- Call to update the descriptive flex field...
2585 INV_SERIAL_NUMBER_ATTR.Update_Serial_number_attr( x_return_status => x_return_status,
2586 x_msg_count => x_error_count,
2587 x_msg_data => x_error_msg,
2588 p_serial_number => p_job_serial_number,
2589 p_inventory_item_id => p_inventory_item_id,
2590 p_attribute_category => p_attribute_category,
2591 p_attributes_tbl => p_serial_desc_attr_tbl
2592 );
2593
2594 if x_return_status <> G_RET_SUCCESS then
2595 --error out..
2596 IF x_return_status = G_RET_ERROR THEN
2597 raise FND_API.G_EXC_ERROR;
2598 ELSIF x_return_status = G_RET_UNEXPECTED THEN
2599 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2600 END IF;
2601
2602 end if;
2603 end if;
2604
2605 EXCEPTION
2606
2607 WHEN FND_API.G_EXC_ERROR THEN
2608
2609 x_return_status := G_RET_ERROR;
2610 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2611 p_count => x_error_count ,
2612 p_data => x_error_msg
2613 );
2614
2615 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2616
2617 x_return_status := G_RET_UNEXPECTED;
2618
2619 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2620 p_count => x_error_count ,
2621 p_data => x_error_msg
2622 );
2623 WHEN OTHERS THEN
2624
2625 x_return_status := G_RET_UNEXPECTED;
2626
2627 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2628 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2629 THEN
2630 WSM_log_PVT.handle_others( p_module_name => l_module ,
2631 p_stmt_num => l_stmt_num ,
2632 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2633 p_run_log_level => l_log_level
2634 );
2635 END IF;
2636
2637 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2638 p_count => x_error_count ,
2639 p_data => x_error_msg
2640 );
2641
2642 END update_serial_attr;
2643
2644 Procedure wms_installed(x_return_status OUT NOCOPY VARCHAR2 ,
2645 x_error_count OUT NOCOPY NUMBER ,
2646 x_err_data OUT NOCOPY VARCHAR2
2647 )
2648
2649 IS
2650
2651 -- Logging variables.....
2652 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2653 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2654
2655 l_stmt_num NUMBER;
2656 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.wms_installed';
2657 -- Logging variables...
2658 BEGIN
2659
2660 x_return_status := G_RET_SUCCESS;
2661 x_error_count := 0;
2662 x_err_data := null;
2663
2664 l_stmt_num := 5;
2665
2666 IF inv_install.adv_inv_installed(NULL) = TRUE THEN
2667
2668 l_stmt_num := 10;
2669 g_wms_installed := 1;
2670 return;
2671
2672 ELSE
2673 l_stmt_num := 20;
2674 g_wms_installed := 0;
2675 return;
2676
2677 END IF;
2678
2679 l_stmt_num := 30;
2680
2681 EXCEPTION
2682
2683 WHEN others THEN
2684 x_return_status := G_RET_UNEXPECTED;
2685
2686 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2687 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2688 THEN
2689 WSM_log_PVT.handle_others( p_module_name => l_module ,
2690 p_stmt_num => l_stmt_num ,
2691 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2692 p_run_log_level => l_log_level
2693 );
2694 END IF;
2695
2696 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2697 p_count => x_error_count ,
2698 p_data => x_err_data
2699 );
2700
2701 END;
2702
2703
2704 procedure update_serial( p_serial_number IN VARCHAR2,
2705 p_inventory_item_id IN NUMBER,
2706 --p_new_inventory_item_id IN NUMBER,
2707 p_organization_id IN NUMBER,
2708 p_wip_entity_id IN NUMBER,
2709 p_operation_seq_num IN NUMBER,
2710 p_intraoperation_step_type IN NUMBER,
2711 x_return_status OUT NOCOPY VARCHAR2,
2712 x_error_msg OUT NOCOPY VARCHAR2,
2713 x_error_count OUT NOCOPY NUMBER
2714 ) is
2715 l_object_id NUMBER;
2716
2717 l_current_status NUMBER;
2718 l_initialization_date DATE;
2719 l_completion_date DATE;
2720 l_ship_date DATE;
2721 l_revision VARCHAR2(3);
2722 l_lot_number VARCHAR2(80); -- Changed for OPM Convergence project
2723 l_group_mark_id NUMBER;
2724 l_lot_line_mark_id NUMBER;
2725 l_current_organization_id NUMBER;
2726 l_current_locator_id NUMBER;
2727 l_current_subinventory_code VARCHAR2(30);
2728 l_original_wip_entity_id NUMBER;
2729 l_original_unit_vendor_id NUMBER;
2730 l_vendor_lot_number VARCHAR2(80); -- Changed for OPM Convergence project
2731 l_vendor_serial_number VARCHAR2(30);
2732 l_last_receipt_issue_type NUMBER;
2733 l_last_txn_source_id NUMBER;
2734 l_last_txn_source_type_id NUMBER;
2735 l_last_txn_source_name VARCHAR2(80); -- Changed for OPM Convergence project
2736 l_parent_item_id NUMBER;
2737 l_parent_serial_number VARCHAR2(30);
2738
2739 l_last_status NUMBER;
2740
2741 -- Logging variables.....
2742 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
2743 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
2744
2745 l_stmt_num NUMBER;
2746 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.update_serial';
2747 l_param_tbl WSM_Log_PVT.param_tbl_type;
2748 -- Logging variables...
2749
2750 begin
2751 l_stmt_num := 10;
2752
2753 x_return_status := G_RET_SUCCESS;
2754 x_error_msg := NULL;
2755 x_error_count := 0;
2756
2757 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
2758
2759 l_param_tbl.delete;
2760 l_param_tbl(1).paramName := 'p_serial_number';
2761 l_param_tbl(1).paramValue := p_serial_number;
2762
2763 l_param_tbl(2).paramName := 'p_wip_entity_id';
2764 l_param_tbl(2).paramValue := p_wip_entity_id;
2765
2766 l_param_tbl(3).paramName := 'p_operation_seq_num';
2767 l_param_tbl(3).paramValue := p_operation_seq_num;
2768
2769 l_param_tbl(4).paramName := 'p_intraoperation_step_type';
2770 l_param_tbl(4).paramValue := p_intraoperation_step_type;
2771
2772 WSM_Log_PVT.logProcParams(p_module_name => l_module,
2773 p_param_tbl => l_param_tbl,
2774 p_fnd_log_level => l_log_level
2775 );
2776 END IF;
2777
2778 SAVEPOINT update_serial;
2779
2780 SELECT current_status,
2781 initialization_date,
2782 completion_date,
2783 ship_date,
2784 revision,
2785 lot_number,
2786 group_mark_id,
2787 lot_line_mark_id,
2788 current_organization_id,
2789 current_locator_id,
2790 current_subinventory_code,
2791 original_wip_entity_id,
2792 original_unit_vendor_id,
2793 vendor_lot_number,
2794 vendor_serial_number,
2795 last_receipt_issue_type,
2796 last_txn_source_id,
2797 last_txn_source_type_id,
2798 last_txn_source_name,
2799 parent_item_id,
2800 parent_serial_number
2801 INTO l_current_status,
2802 l_initialization_date,
2803 l_completion_date,
2804 l_ship_date,
2805 l_revision,
2806 l_lot_number,
2807 l_group_mark_id,
2808 l_lot_line_mark_id,
2809 l_current_organization_id,
2810 l_current_locator_id,
2811 l_current_subinventory_code,
2812 l_original_wip_entity_id,
2813 l_original_unit_vendor_id,
2814 l_vendor_lot_number,
2815 l_vendor_serial_number,
2816 l_last_receipt_issue_type,
2817 l_last_txn_source_id,
2818 l_last_txn_source_type_id,
2819 l_last_txn_source_name,
2820 l_parent_item_id,
2821 l_parent_serial_number
2822 FROM mtl_serial_numbers
2823 WHERE serial_number = p_serial_number
2824 AND inventory_item_id = p_inventory_item_id
2825 AND current_organization_id = p_organization_id
2826 FOR UPDATE NOWAIT;
2827
2828 l_stmt_num := 20;
2829
2830 if(l_current_status = 6) then
2831 l_last_status := 1;
2832 else
2833 l_last_status := l_current_status;
2834 end if;
2835
2836 l_stmt_num := 30;
2837
2838 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
2839 l_msg_tokens.delete;
2840 WSM_log_PVT.logMessage (p_module_name => l_module ,
2841 p_msg_text => 'Invoking INV_SERIAL_NUMBER_PUB.updateserial',
2842 p_stmt_num => l_stmt_num ,
2843 p_msg_tokens => l_msg_tokens ,
2844 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
2845 p_run_log_level => l_log_level
2846 );
2847 END IF;
2848
2849 inv_serial_number_pub.updateserial ( p_api_version => 1.0,
2850 p_inventory_item_id => p_inventory_item_id,
2851 p_organization_id => p_organization_id,
2852 p_serial_number => p_serial_number,
2853 p_initialization_date => l_initialization_date,
2854 p_completion_date => l_completion_date,
2855 p_ship_date => l_ship_date,
2856 p_revision => l_revision,
2857 p_lot_number => l_lot_number,
2858 p_current_locator_id => l_current_locator_id,
2859 p_subinventory_code => l_current_subinventory_code,
2860 p_trx_src_id => l_original_wip_entity_id,
2861 p_unit_vendor_id => l_original_unit_vendor_id,
2862 p_vendor_lot_number => l_vendor_lot_number,
2863 p_vendor_serial_number => l_vendor_serial_number,
2864 p_receipt_issue_type => l_last_receipt_issue_type,
2865 p_txn_src_id => l_last_txn_source_id,
2866 p_txn_src_name => l_last_txn_source_name,
2867 p_txn_src_type_id => l_last_txn_source_type_id,
2868 p_current_status => l_current_status,
2869 p_parent_item_id => l_parent_item_id,
2870 p_parent_serial_number => l_parent_serial_number,
2871 p_serial_temp_id => null,
2872 p_last_status => l_last_status,
2873 p_status_id => null,
2874 x_object_id => l_object_id,
2875 x_return_status => x_return_status,
2876 x_msg_count => x_error_count,
2877 x_msg_data => x_error_msg,
2878 p_wip_entity_id => p_wip_entity_id,
2879 p_operation_seq_num => p_operation_seq_num,
2880 p_intraoperation_step_type => p_intraoperation_step_type,
2881 p_line_mark_id => l_lot_line_mark_id
2882 );
2883
2884 l_stmt_num := 40;
2885
2886 IF x_return_status = G_RET_ERROR THEN
2887 raise FND_API.G_EXC_ERROR;
2888 ELSIF x_return_status = G_RET_UNEXPECTED THEN
2889 raise FND_API.G_EXC_UNEXPECTED_ERROR;
2890 END IF;
2891
2892 exception
2893
2894 WHEN FND_API.G_EXC_ERROR THEN
2895 rollback to update_serial;
2896 x_return_status := G_RET_ERROR;
2897 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2898 p_count => x_error_count ,
2899 p_data => x_error_msg
2900 );
2901
2902 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2903 rollback to update_serial;
2904 x_return_status := G_RET_UNEXPECTED;
2905 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2906 p_count => x_error_count ,
2907 p_data => x_error_msg
2908 );
2909 WHEN OTHERS THEN
2910 rollback to update_serial;
2911 x_return_status := G_RET_UNEXPECTED;
2912 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
2913 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
2914 THEN
2915 WSM_log_PVT.handle_others( p_module_name => l_module ,
2916 p_stmt_num => l_stmt_num ,
2917 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
2918 p_run_log_level => l_log_level
2919 );
2920 END IF;
2921
2922 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
2923 p_count => x_error_count ,
2924 p_data => x_error_msg
2925 );
2926
2927 end update_serial;
2928
2929 -- The addition/deletion of serial numbers will be handled by this procedure...
2930 -- Then it will invoke the main processor whose activities will be common...
2931 Procedure Move_serial_intf_proc(p_header_id IN NUMBER,
2932 p_wsm_serial_nums_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
2933 p_move_txn_type IN NUMBER,
2934 p_wip_entity_id IN NUMBER,
2935 p_organization_id IN NUMBER,
2936 p_inventory_item_id IN NUMBER,
2937 p_move_qty IN NUMBER,
2938 p_scrap_qty IN NUMBER,
2939 p_available_qty IN NUMBER,
2940 p_curr_job_op_seq_num IN NUMBER,
2941 p_curr_job_intraop_step IN NUMBER,
2942 p_from_rtg_op_seq_num IN NUMBER,
2943 p_to_rtg_op_seq_num IN NUMBER,
2944 p_to_intraoperation_step IN NUMBER,
2945 p_user_serial_tracking IN NUMBER,
2946 p_move_txn_id IN NUMBER,
2947 p_scrap_txn_id IN NUMBER,
2948 p_old_move_txn_id IN NUMBER,
2949 p_old_scrap_txn_id IN NUMBER,
2950 p_jump_flag IN varchar2 DEFAULT NULL,
2951 p_scrap_at_operation IN NUMBER DEFAULT NULL,
2952 -- ST : Fix for bug 5140761 Addded the above parameter --
2953 x_serial_track_flag OUT NOCOPY NUMBER,
2954 x_return_status OUT NOCOPY VARCHAR2,
2955 x_error_msg OUT NOCOPY VARCHAR2,
2956 x_error_count OUT NOCOPY NUMBER
2957 )
2958
2959 IS
2960
2961 l_serial_ctrl_code NUMBER;
2962 l_serial_start_flag NUMBER;
2963 l_first_serial_txn_id NUMBER;
2964 l_serial_start_op NUMBER;
2965
2966 l_miss_char VARCHAR2(1) := FND_API.G_MISS_CHAR;
2967 l_null_num NUMBER := FND_API.G_NULL_NUM;
2968 l_null_date DATE := FND_API.G_NULL_DATE;
2969 l_null_char VARCHAR2(1) := FND_API.G_NULL_CHAR;
2970
2971 cursor c_move_serials
2972 is
2973 select
2974 wsti.Serial_Number ,
2975 msn.gen_object_id ,
2976 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
2977 wsti.header_id , -- header_id
2978 wsti.Generate_serial_number ,
2979 wsti.Generate_for_qty ,
2980 wsti.Action_flag ,
2981 wsti.Current_wip_entity_name ,
2982 wsti.Changed_wip_entity_name ,
2983 wsti.Current_wip_entity_id ,
2984 wsti.Changed_wip_entity_id ,
2985 decode(wsti.serial_attribute_category , l_null_char, null, null, msn.serial_attribute_category, wsti.serial_attribute_category), -- serial_attribute_category
2986 decode(wsti.territory_code , l_null_char, null, null, msn.territory_code , wsti.territory_code ), -- territory_code
2987 decode(wsti.origination_date , l_null_date, null, null, msn.origination_date , wsti.origination_date ), -- origination_date
2988 decode(wsti.c_attribute1 , l_null_char, null, null, msn.c_attribute1 , wsti.c_attribute1 ), -- c_attribute1
2989 decode(wsti.c_attribute2 , l_null_char, null, null, msn.c_attribute2 , wsti.c_attribute2 ), -- c_attribute2
2990 decode(wsti.c_attribute3 , l_null_char, null, null, msn.c_attribute3 , wsti.c_attribute3 ), -- c_attribute3
2991 decode(wsti.c_attribute4 , l_null_char, null, null, msn.c_attribute4 , wsti.c_attribute4 ), -- c_attribute4
2992 decode(wsti.c_attribute5 , l_null_char, null, null, msn.c_attribute5 , wsti.c_attribute5 ), -- c_attribute5
2993 decode(wsti.c_attribute6 , l_null_char, null, null, msn.c_attribute6 , wsti.c_attribute6 ), -- c_attribute6
2994 decode(wsti.c_attribute7 , l_null_char, null, null, msn.c_attribute7 , wsti.c_attribute7 ), -- c_attribute7
2995 decode(wsti.c_attribute8 , l_null_char, null, null, msn.c_attribute8 , wsti.c_attribute8 ), -- c_attribute8
2996 decode(wsti.c_attribute9 , l_null_char, null, null, msn.c_attribute9 , wsti.c_attribute9 ), -- c_attribute9
2997 decode(wsti.c_attribute10 , l_null_char, null, null, msn.c_attribute10 , wsti.c_attribute10 ), -- c_attribute10
2998 decode(wsti.c_attribute11 , l_null_char, null, null, msn.c_attribute11 , wsti.c_attribute11 ), -- c_attribute11
2999 decode(wsti.c_attribute12 , l_null_char, null, null, msn.c_attribute12 , wsti.c_attribute12 ), -- c_attribute12
3000 decode(wsti.c_attribute13 , l_null_char, null, null, msn.c_attribute13 , wsti.c_attribute13 ), -- c_attribute13
3001 decode(wsti.c_attribute14 , l_null_char, null, null, msn.c_attribute14 , wsti.c_attribute14 ), -- c_attribute14
3002 decode(wsti.c_attribute15 , l_null_char, null, null, msn.c_attribute15 , wsti.c_attribute15 ), -- c_attribute15
3003 decode(wsti.c_attribute16 , l_null_char, null, null, msn.c_attribute16 , wsti.c_attribute16 ), -- c_attribute16
3004 decode(wsti.c_attribute17 , l_null_char, null, null, msn.c_attribute17 , wsti.c_attribute17 ), -- c_attribute17
3005 decode(wsti.c_attribute18 , l_null_char, null, null, msn.c_attribute18 , wsti.c_attribute18 ), -- c_attribute18
3006 decode(wsti.c_attribute19 , l_null_char, null, null, msn.c_attribute19 , wsti.c_attribute19 ), -- c_attribute19
3007 decode(wsti.c_attribute20 , l_null_char, null, null, msn.c_attribute20 , wsti.c_attribute20 ), -- c_attribute20
3008 decode(wsti.d_attribute1 , l_null_date, null, null, msn.d_attribute1 , wsti.d_attribute1 ), -- d_attribute1
3009 decode(wsti.d_attribute2 , l_null_date, null, null, msn.d_attribute2 , wsti.d_attribute2 ), -- d_attribute2
3010 decode(wsti.d_attribute3 , l_null_date, null, null, msn.d_attribute3 , wsti.d_attribute3 ), -- d_attribute3
3011 decode(wsti.d_attribute4 , l_null_date, null, null, msn.d_attribute4 , wsti.d_attribute4 ), -- d_attribute4
3012 decode(wsti.d_attribute5 , l_null_date, null, null, msn.d_attribute5 , wsti.d_attribute5 ), -- d_attribute5
3013 decode(wsti.d_attribute6 , l_null_date, null, null, msn.d_attribute6 , wsti.d_attribute6 ), -- d_attribute6
3014 decode(wsti.d_attribute7 , l_null_date, null, null, msn.d_attribute7 , wsti.d_attribute7 ), -- d_attribute7
3015 decode(wsti.d_attribute8 , l_null_date, null, null, msn.d_attribute8 , wsti.d_attribute8 ), -- d_attribute8
3016 decode(wsti.d_attribute9 , l_null_date, null, null, msn.d_attribute9 , wsti.d_attribute9 ), -- d_attribute9
3017 decode(wsti.d_attribute10 , l_null_date, null, null, msn.d_attribute10 , wsti.d_attribute10 ), -- d_attribute10
3018 decode(wsti.n_attribute1 , l_null_num , null, null, msn.n_attribute1 , wsti.n_attribute1 ), -- n_attribute1
3019 decode(wsti.n_attribute2 , l_null_num , null, null, msn.n_attribute2 , wsti.n_attribute2 ), -- n_attribute2
3020 decode(wsti.n_attribute3 , l_null_num , null, null, msn.n_attribute3 , wsti.n_attribute3 ), -- n_attribute3
3021 decode(wsti.n_attribute4 , l_null_num , null, null, msn.n_attribute4 , wsti.n_attribute4 ), -- n_attribute4
3022 decode(wsti.n_attribute5 , l_null_num , null, null, msn.n_attribute5 , wsti.n_attribute5 ), -- n_attribute5
3023 decode(wsti.n_attribute6 , l_null_num , null, null, msn.n_attribute6 , wsti.n_attribute6 ), -- n_attribute6
3024 decode(wsti.n_attribute7 , l_null_num , null, null, msn.n_attribute7 , wsti.n_attribute7 ), -- n_attribute7
3025 decode(wsti.n_attribute8 , l_null_num , null, null, msn.n_attribute8 , wsti.n_attribute8 ), -- n_attribute8
3026 decode(wsti.n_attribute9 , l_null_num , null, null, msn.n_attribute9 , wsti.n_attribute9 ), -- n_attribute9
3027 decode(wsti.n_attribute10 , l_null_num , null, null, msn.n_attribute10 , wsti.n_attribute10 ), -- n_attribute10
3028 decode(wsti.status_id , l_null_num , null, null, msn.status_id , wsti.status_id ), -- status_id
3029 decode(wsti.time_since_new , l_null_num , null, null, msn.time_since_new , wsti.time_since_new ), -- time_since_new
3030 decode(wsti.cycles_since_new , l_null_num , null, null, msn.cycles_since_new , wsti.cycles_since_new ), -- cycles_since_new
3031 decode(wsti.time_since_overhaul , l_null_num , null, null, msn.time_since_overhaul , wsti.time_since_overhaul ), -- time_since_overhaul
3032 decode(wsti.cycles_since_overhaul , l_null_num , null, null, msn.cycles_since_overhaul , wsti.cycles_since_overhaul ), -- cycles_since_overhaul
3033 decode(wsti.time_since_repair , l_null_num , null, null, msn.time_since_repair , wsti.time_since_repair ), -- time_since_repair
3034 decode(wsti.cycles_since_repair , l_null_num , null, null, msn.cycles_since_repair , wsti.cycles_since_repair ), -- cycles_since_repair
3035 decode(wsti.time_since_visit , l_null_num , null, null, msn.time_since_visit , wsti.time_since_visit ), -- time_since_visit
3036 decode(wsti.cycles_since_visit , l_null_num , null, null, msn.cycles_since_visit , wsti.cycles_since_visit ), -- cycles_since_visit
3037 decode(wsti.time_since_mark , l_null_num , null, null, msn.time_since_mark , wsti.time_since_mark ), -- time_since_mark
3038 decode(wsti.cycles_since_mark , l_null_num , null, null, msn.cycles_since_mark , wsti.cycles_since_mark ), -- cycles_since_mark
3039 decode(wsti.number_of_repairs , l_null_num , null, null, msn.number_of_repairs , wsti.number_of_repairs ), -- number_of_repairs
3040 decode(wsti.attribute_category , l_null_char, l_miss_char , null ,msn.attribute_category ,wsti.attribute_category ),
3041 decode(wsti.attribute1 , l_null_char ,l_miss_char , wsti.attribute1 ),
3042 decode(wsti.attribute2 , l_null_char ,l_miss_char , wsti.attribute2 ),
3043 decode(wsti.attribute3 , l_null_char ,l_miss_char , wsti.attribute3 ),
3044 decode(wsti.attribute4 , l_null_char ,l_miss_char , wsti.attribute4 ),
3045 decode(wsti.attribute5 , l_null_char ,l_miss_char , wsti.attribute5 ),
3046 decode(wsti.attribute6 , l_null_char ,l_miss_char , wsti.attribute6 ),
3047 decode(wsti.attribute7 , l_null_char ,l_miss_char , wsti.attribute7 ),
3048 decode(wsti.attribute8 , l_null_char ,l_miss_char , wsti.attribute8 ),
3049 decode(wsti.attribute9 , l_null_char ,l_miss_char , wsti.attribute9 ),
3050 decode(wsti.attribute10 , l_null_char ,l_miss_char , wsti.attribute10 ),
3051 decode(wsti.attribute11 , l_null_char ,l_miss_char , wsti.attribute11 ),
3052 decode(wsti.attribute12 , l_null_char ,l_miss_char , wsti.attribute12 ),
3053 decode(wsti.attribute13 , l_null_char ,l_miss_char , wsti.attribute13 ),
3054 decode(wsti.attribute14 , l_null_char ,l_miss_char , wsti.attribute14 ),
3055 decode(wsti.attribute15 , l_null_char ,l_miss_char , wsti.attribute15 )
3056 from wsm_serial_txn_interface wsti,
3057 mtl_serial_numbers msn
3058 where wsti.header_id = p_header_id
3059 and wsti.transaction_type_id = 2
3060 and (wsti.action_flag >= 5 AND wsti.action_flag <= 6) -- select the move/scrap
3061 and wsti.serial_number = msn.serial_number (+)
3062 and msn.inventory_item_id (+) = p_inventory_item_id
3063 and msn.current_organization_id (+) = p_organization_id;
3064
3065 cursor c_process_move_serials
3066 is
3067 select
3068 wsti.Serial_Number ,
3069 msn.gen_object_id ,
3070 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
3071 wsti.header_id , -- header_id
3072 wsti.Generate_serial_number ,
3073 wsti.Generate_for_qty ,
3074 wsti.Action_flag ,
3075 wsti.Current_wip_entity_name ,
3076 wsti.Changed_wip_entity_name ,
3077 wsti.Current_wip_entity_id ,
3078 wsti.Changed_wip_entity_id ,
3079 decode(wsti.serial_attribute_category , l_null_char, null, null, msn.serial_attribute_category, wsti.serial_attribute_category), -- serial_attribute_category
3080 decode(wsti.territory_code , l_null_char, null, null, msn.territory_code , wsti.territory_code ), -- territory_code
3081 decode(wsti.origination_date , l_null_date, null, null, msn.origination_date , wsti.origination_date ), -- origination_date
3082 decode(wsti.c_attribute1 , l_null_char, null, null, msn.c_attribute1 , wsti.c_attribute1 ), -- c_attribute1
3083 decode(wsti.c_attribute2 , l_null_char, null, null, msn.c_attribute2 , wsti.c_attribute2 ), -- c_attribute2
3084 decode(wsti.c_attribute3 , l_null_char, null, null, msn.c_attribute3 , wsti.c_attribute3 ), -- c_attribute3
3085 decode(wsti.c_attribute4 , l_null_char, null, null, msn.c_attribute4 , wsti.c_attribute4 ), -- c_attribute4
3086 decode(wsti.c_attribute5 , l_null_char, null, null, msn.c_attribute5 , wsti.c_attribute5 ), -- c_attribute5
3087 decode(wsti.c_attribute6 , l_null_char, null, null, msn.c_attribute6 , wsti.c_attribute6 ), -- c_attribute6
3088 decode(wsti.c_attribute7 , l_null_char, null, null, msn.c_attribute7 , wsti.c_attribute7 ), -- c_attribute7
3089 decode(wsti.c_attribute8 , l_null_char, null, null, msn.c_attribute8 , wsti.c_attribute8 ), -- c_attribute8
3090 decode(wsti.c_attribute9 , l_null_char, null, null, msn.c_attribute9 , wsti.c_attribute9 ), -- c_attribute9
3091 decode(wsti.c_attribute10 , l_null_char, null, null, msn.c_attribute10 , wsti.c_attribute10 ), -- c_attribute10
3092 decode(wsti.c_attribute11 , l_null_char, null, null, msn.c_attribute11 , wsti.c_attribute11 ), -- c_attribute11
3093 decode(wsti.c_attribute12 , l_null_char, null, null, msn.c_attribute12 , wsti.c_attribute12 ), -- c_attribute12
3094 decode(wsti.c_attribute13 , l_null_char, null, null, msn.c_attribute13 , wsti.c_attribute13 ), -- c_attribute13
3095 decode(wsti.c_attribute14 , l_null_char, null, null, msn.c_attribute14 , wsti.c_attribute14 ), -- c_attribute14
3096 decode(wsti.c_attribute15 , l_null_char, null, null, msn.c_attribute15 , wsti.c_attribute15 ), -- c_attribute15
3097 decode(wsti.c_attribute16 , l_null_char, null, null, msn.c_attribute16 , wsti.c_attribute16 ), -- c_attribute16
3098 decode(wsti.c_attribute17 , l_null_char, null, null, msn.c_attribute17 , wsti.c_attribute17 ), -- c_attribute17
3099 decode(wsti.c_attribute18 , l_null_char, null, null, msn.c_attribute18 , wsti.c_attribute18 ), -- c_attribute18
3100 decode(wsti.c_attribute19 , l_null_char, null, null, msn.c_attribute19 , wsti.c_attribute19 ), -- c_attribute19
3101 decode(wsti.c_attribute20 , l_null_char, null, null, msn.c_attribute20 , wsti.c_attribute20 ), -- c_attribute20
3102 decode(wsti.d_attribute1 , l_null_date, null, null, msn.d_attribute1 , wsti.d_attribute1 ), -- d_attribute1
3103 decode(wsti.d_attribute2 , l_null_date, null, null, msn.d_attribute2 , wsti.d_attribute2 ), -- d_attribute2
3104 decode(wsti.d_attribute3 , l_null_date, null, null, msn.d_attribute3 , wsti.d_attribute3 ), -- d_attribute3
3105 decode(wsti.d_attribute4 , l_null_date, null, null, msn.d_attribute4 , wsti.d_attribute4 ), -- d_attribute4
3106 decode(wsti.d_attribute5 , l_null_date, null, null, msn.d_attribute5 , wsti.d_attribute5 ), -- d_attribute5
3107 decode(wsti.d_attribute6 , l_null_date, null, null, msn.d_attribute6 , wsti.d_attribute6 ), -- d_attribute6
3108 decode(wsti.d_attribute7 , l_null_date, null, null, msn.d_attribute7 , wsti.d_attribute7 ), -- d_attribute7
3109 decode(wsti.d_attribute8 , l_null_date, null, null, msn.d_attribute8 , wsti.d_attribute8 ), -- d_attribute8
3110 decode(wsti.d_attribute9 , l_null_date, null, null, msn.d_attribute9 , wsti.d_attribute9 ), -- d_attribute9
3111 decode(wsti.d_attribute10 , l_null_date, null, null, msn.d_attribute10 , wsti.d_attribute10 ), -- d_attribute10
3112 decode(wsti.n_attribute1 , l_null_num , null, null, msn.n_attribute1 , wsti.n_attribute1 ), -- n_attribute1
3113 decode(wsti.n_attribute2 , l_null_num , null, null, msn.n_attribute2 , wsti.n_attribute2 ), -- n_attribute2
3114 decode(wsti.n_attribute3 , l_null_num , null, null, msn.n_attribute3 , wsti.n_attribute3 ), -- n_attribute3
3115 decode(wsti.n_attribute4 , l_null_num , null, null, msn.n_attribute4 , wsti.n_attribute4 ), -- n_attribute4
3116 decode(wsti.n_attribute5 , l_null_num , null, null, msn.n_attribute5 , wsti.n_attribute5 ), -- n_attribute5
3117 decode(wsti.n_attribute6 , l_null_num , null, null, msn.n_attribute6 , wsti.n_attribute6 ), -- n_attribute6
3118 decode(wsti.n_attribute7 , l_null_num , null, null, msn.n_attribute7 , wsti.n_attribute7 ), -- n_attribute7
3119 decode(wsti.n_attribute8 , l_null_num , null, null, msn.n_attribute8 , wsti.n_attribute8 ), -- n_attribute8
3120 decode(wsti.n_attribute9 , l_null_num , null, null, msn.n_attribute9 , wsti.n_attribute9 ), -- n_attribute9
3121 decode(wsti.n_attribute10 , l_null_num , null, null, msn.n_attribute10 , wsti.n_attribute10 ), -- n_attribute10
3122 decode(wsti.status_id , l_null_num , null, null, msn.status_id , wsti.status_id ), -- status_id
3123 decode(wsti.time_since_new , l_null_num , null, null, msn.time_since_new , wsti.time_since_new ), -- time_since_new
3124 decode(wsti.cycles_since_new , l_null_num , null, null, msn.cycles_since_new , wsti.cycles_since_new ), -- cycles_since_new
3125 decode(wsti.time_since_overhaul , l_null_num , null, null, msn.time_since_overhaul , wsti.time_since_overhaul ), -- time_since_overhaul
3126 decode(wsti.cycles_since_overhaul , l_null_num , null, null, msn.cycles_since_overhaul , wsti.cycles_since_overhaul ), -- cycles_since_overhaul
3127 decode(wsti.time_since_repair , l_null_num , null, null, msn.time_since_repair , wsti.time_since_repair ), -- time_since_repair
3128 decode(wsti.cycles_since_repair , l_null_num , null, null, msn.cycles_since_repair , wsti.cycles_since_repair ), -- cycles_since_repair
3129 decode(wsti.time_since_visit , l_null_num , null, null, msn.time_since_visit , wsti.time_since_visit ), -- time_since_visit
3130 decode(wsti.cycles_since_visit , l_null_num , null, null, msn.cycles_since_visit , wsti.cycles_since_visit ), -- cycles_since_visit
3131 decode(wsti.time_since_mark , l_null_num , null, null, msn.time_since_mark , wsti.time_since_mark ), -- time_since_mark
3132 decode(wsti.cycles_since_mark , l_null_num , null, null, msn.cycles_since_mark , wsti.cycles_since_mark ), -- cycles_since_mark
3133 decode(wsti.number_of_repairs , l_null_num , null, null, msn.number_of_repairs , wsti.number_of_repairs ), -- number_of_repairs
3134 decode(wsti.attribute_category , l_null_char, l_miss_char , null ,msn.attribute_category ,wsti.attribute_category ),
3135 decode(wsti.attribute1 , l_null_char ,l_miss_char , wsti.attribute1 ),
3136 decode(wsti.attribute2 , l_null_char ,l_miss_char , wsti.attribute2 ),
3137 decode(wsti.attribute3 , l_null_char ,l_miss_char , wsti.attribute3 ),
3138 decode(wsti.attribute4 , l_null_char ,l_miss_char , wsti.attribute4 ),
3139 decode(wsti.attribute5 , l_null_char ,l_miss_char , wsti.attribute5 ),
3140 decode(wsti.attribute6 , l_null_char ,l_miss_char , wsti.attribute6 ),
3141 decode(wsti.attribute7 , l_null_char ,l_miss_char , wsti.attribute7 ),
3142 decode(wsti.attribute8 , l_null_char ,l_miss_char , wsti.attribute8 ),
3143 decode(wsti.attribute9 , l_null_char ,l_miss_char , wsti.attribute9 ),
3144 decode(wsti.attribute10 , l_null_char ,l_miss_char , wsti.attribute10 ),
3145 decode(wsti.attribute11 , l_null_char ,l_miss_char , wsti.attribute11 ),
3146 decode(wsti.attribute12 , l_null_char ,l_miss_char , wsti.attribute12 ),
3147 decode(wsti.attribute13 , l_null_char ,l_miss_char , wsti.attribute13 ),
3148 decode(wsti.attribute14 , l_null_char ,l_miss_char , wsti.attribute14 ),
3149 decode(wsti.attribute15 , l_null_char ,l_miss_char , wsti.attribute15 )
3150 from wsm_serial_txn_interface wsti,
3151 mtl_serial_numbers msn
3152 where wsti.header_id = p_header_id
3153 and wsti.transaction_type_id = 2
3154 and (nvl(wsti.action_flag,wsti.generate_serial_number) >= 1 AND nvl(wsti.action_flag,wsti.generate_serial_number) <= 3) -- select the move/scrap
3155 and wsti.serial_number = msn.serial_number (+)
3156 and msn.inventory_item_id (+) = p_inventory_item_id
3157 and msn.current_organization_id (+) = p_organization_id
3158 order by nvl(wsti.action_flag,0) desc; -- Code review remark
3159 -- first process Delete and then add
3160
3161 l_wsm_serial_nums_tbl WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL;
3162 l_serial_tbl t_varchar2;
3163 l_row_updated NUMBER;
3164
3165 -- Logging variables.....
3166 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3167 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3168
3169 l_stmt_num NUMBER;
3170 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Move_serial_intf_proc';
3171 l_param_tbl WSM_Log_PVT.param_tbl_type;
3172 -- Logging variables...
3173
3174 BEGIN
3175 l_stmt_num := 10;
3176
3177 x_return_status := G_RET_SUCCESS;
3178 x_error_msg := NULL;
3179 x_error_count := 0;
3180
3181 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
3182 l_stmt_num := 15;
3183 l_param_tbl.delete;
3184 l_param_tbl(1).paramName := 'p_wip_entity_id';
3185 l_param_tbl(1).paramValue := p_wip_entity_id;
3186
3187 l_param_tbl(2).paramName := 'p_inventory_item_id';
3188 l_param_tbl(2).paramValue := p_inventory_item_id;
3189
3190 l_param_tbl(3).paramName := 'p_organization_id';
3191 l_param_tbl(3).paramValue := p_organization_id;
3192
3193 l_param_tbl(4).paramName := 'p_header_id';
3194 l_param_tbl(4).paramValue := p_header_id;
3195
3196 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
3197 p_param_tbl => l_param_tbl,
3198 p_fnd_log_level => l_log_level
3199 );
3200 END IF;
3201
3202 -- first get all the serial numbers to be inserted/delinked/updated...
3203 -- call process_serial_info..
3204 l_stmt_num := 20;
3205
3206 -- Validate the item_id/job for serial control..
3207 get_serial_track_info( p_serial_item_id => p_inventory_item_id,
3208 p_organization_id => p_organization_id,
3209 p_wip_entity_id => p_wip_entity_id,
3210 x_serial_start_flag => x_serial_track_flag,
3211 x_serial_ctrl_code => l_serial_ctrl_code,
3212 x_first_serial_txn_id => l_first_serial_txn_id,
3213 x_serial_start_op => l_serial_start_op,
3214 x_return_status => x_return_status,
3215 x_error_msg => x_error_msg,
3216 x_error_count => x_error_count
3217 );
3218
3219 if x_return_status <> G_RET_SUCCESS then
3220 IF x_return_status = G_RET_ERROR THEN
3221 raise FND_API.G_EXC_ERROR;
3222 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3223 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3224 END IF;
3225 end if;
3226 l_stmt_num := 25;
3227
3228 -- check for serial track...
3229 -- we dont have to worry about Lot control as the LBJ creation would have failed before this is invoked..
3230 if l_serial_ctrl_code = 1 then -- No serial control
3231
3232 l_stmt_num := 30;
3233 -- issue an update statement to the interface records setting them to errored..
3234 l_row_updated := 0;
3235 IF p_wsm_serial_nums_tbl.count = 0 THEN
3236 update wsm_serial_txn_interface
3237 set process_status = wip_constants.error
3238 where header_id = p_header_id
3239 and transaction_type_id = 2;
3240
3241 l_row_updated := SQL%ROWCOUNT;
3242 END IF;
3243
3244 if l_row_updated > 0 OR p_wsm_serial_nums_tbl.count > 0 then
3245 -- return error as interface rows were updated...
3246 IF g_log_level_error >= l_log_level OR
3247 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3248 THEN
3249
3250 l_msg_tokens.delete;
3251 WSM_log_PVT.logMessage(p_module_name => l_module ,
3252 p_msg_name => 'WSM_INVLAID_SERIAL_INFO',
3253 p_msg_appl_name => 'WSM' ,
3254 p_msg_tokens => l_msg_tokens ,
3255 p_stmt_num => l_stmt_num ,
3256 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3257 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3258 p_run_log_level => l_log_level
3259 );
3260 END IF;
3261 RAISE FND_API.G_EXC_ERROR;
3262 end if;
3263 RETURN;
3264
3265 ELSIF p_wsm_serial_nums_tbl.count = 0 THEN
3266 -- Fetch the serials only for interface/in case of MES ignore
3267 l_stmt_num := 40;
3268 -- Initially process all the serial number addition
3269 open c_process_move_serials;
3270 fetch c_process_move_serials
3271 bulk collect into l_wsm_serial_nums_tbl;
3272 close c_process_move_serials;
3273
3274 -- invoke process_serial_info
3275 if l_wsm_serial_nums_tbl.count > 0 then
3276
3277 l_stmt_num := 50;
3278 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3279 l_msg_tokens.delete;
3280 WSM_log_PVT.logMessage (p_module_name => l_module ,
3281 p_msg_text => 'Inside process_serial_info to process : ' || l_wsm_serial_nums_tbl.count || ' records',
3282 p_stmt_num => l_stmt_num ,
3283 p_msg_tokens => l_msg_tokens ,
3284 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3285 p_run_log_level => l_log_level
3286 );
3287 END IF;
3288 process_serial_info (p_calling_mode => 1,
3289 p_wsm_serial_nums_tbl => l_wsm_serial_nums_tbl,
3290 p_wip_entity_id => p_wip_entity_id,
3291 p_serial_start_flag => l_serial_start_flag,
3292 p_organization_id => p_organization_id,
3293 p_item_id => p_inventory_item_id,
3294 x_serial_tbl => l_serial_tbl,
3295 x_return_status => x_return_status,
3296 x_error_msg => x_error_msg,
3297 x_error_count => x_error_count
3298 );
3299
3300 if x_return_status <> G_RET_SUCCESS then
3301 IF x_return_status = G_RET_ERROR THEN
3302 raise FND_API.G_EXC_ERROR;
3303 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3304 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3305 END IF;
3306 end if;
3307 end if; -- end invoke process_serial_info
3308
3309 END IF; -- end check for serial control
3310
3311 l_stmt_num := 60;
3312 -- empty the PL/SQL table...
3313 l_wsm_serial_nums_tbl.delete;
3314
3315 IF p_move_txn_type IN (3,4) THEN -- Undo/assembly return...
3316
3317 l_stmt_num := 70;
3318 l_row_updated := 0;
3319 IF p_wsm_serial_nums_tbl.count = 0 then
3320 update wsm_serial_txn_interface wsti
3321 set wsti.process_status = wip_constants.error
3322 where wsti.header_id = p_header_id
3323 and wsti.transaction_type_id = 2
3324 and wsti.action_flag in (5,6);
3325
3326 l_row_updated := SQL%ROWCOUNT;
3327 END IF;
3328
3329 if l_row_updated > 0 or p_wsm_serial_nums_tbl.count > 0 then
3330 -- error.. message....
3331 l_stmt_num := 80;
3332 IF g_log_level_error >= l_log_level OR
3333 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3334 THEN
3335
3336 l_msg_tokens.delete;
3337 WSM_log_PVT.logMessage(p_module_name => l_module ,
3338 p_msg_name => 'WSM_NO_FOR_SERIAL_UNDO_ASSYRET',
3339 p_msg_appl_name => 'WSM' ,
3340 p_msg_tokens => l_msg_tokens ,
3341 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3342 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3343 p_run_log_level => l_log_level
3344 );
3345 END IF;
3346 RAISE FND_API.G_EXC_ERROR;
3347 end if;
3348
3349 ELSE
3350 l_stmt_num := 90;
3351
3352 IF p_wsm_serial_nums_tbl.count = 0 then
3353 update wsm_serial_txn_interface wsti
3354 set wsti.process_status = wip_constants.error
3355 where wsti.header_id = p_header_id
3356 and wsti.transaction_type_id = 2
3357 and wsti.action_flag in (5,6)
3358 and not exists( SELECT MSN.serial_number
3359 FROM MTL_SERIAL_NUMBERS MSN
3360 WHERE MSN.SERIAL_NUMBER = wsti.serial_number
3361 AND MSN.wip_entity_id = p_wip_entity_id
3362 AND MSN.current_organization_id = p_organization_id
3363 AND MSN.inventory_item_id = p_inventory_item_id
3364 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
3365 -- AND MSN.operation_seq_num = p_curr_job_op_seq_num
3366 --AND MSN.intraoperation_step_type = p_curr_job_intraop_step
3367 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP
3368 );
3369
3370 if SQL%ROWCOUNT > 0 then
3371 -- Error out..
3372 l_stmt_num := 100;
3373 IF g_log_level_error >= l_log_level OR
3374 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3375 THEN
3376
3377 l_msg_tokens.delete;
3378 WSM_log_PVT.logMessage(p_module_name => l_module ,
3379 p_msg_name => 'WSM_INVALID_SERIALS_SUPPLIED',
3380 p_msg_appl_name => 'WSM' ,
3381 p_msg_tokens => l_msg_tokens ,
3382 p_stmt_num => l_stmt_num ,
3383 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3384 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3385 p_run_log_level => l_log_level
3386 );
3387 END IF;
3388 RAISE FND_API.G_EXC_ERROR;
3389 end if;
3390
3391 l_stmt_num := 110;
3392 open c_move_serials;
3393 fetch c_move_serials
3394 bulk collect into l_wsm_serial_nums_tbl;
3395 close c_move_serials;
3396 ELSE
3397 l_wsm_serial_nums_tbl := p_wsm_serial_nums_tbl;
3398 END IF;
3399 l_stmt_num := 120;
3400 END IF;
3401
3402 l_stmt_num := 130;
3403 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3404 l_msg_tokens.delete;
3405 WSM_log_PVT.logMessage (p_module_name => l_module ,
3406 p_msg_text => 'Invoking Move_serial_processor',
3407 p_stmt_num => l_stmt_num ,
3408 p_msg_tokens => l_msg_tokens ,
3409 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3410 p_run_log_level => l_log_level
3411 );
3412 END IF;
3413 -- then call the Move Serial Processor..
3414 Move_serial_processor ( p_calling_mode => 1 ,
3415 p_serial_num_tbl => l_wsm_serial_nums_tbl ,
3416 p_move_txn_type => p_move_txn_type ,
3417 p_wip_entity_id => p_wip_entity_id ,
3418 p_organization_id => p_organization_id ,
3419 p_inventory_item_id => p_inventory_item_id ,
3420 p_move_qty => p_move_qty ,
3421 p_scrap_qty => p_scrap_qty ,
3422 p_available_qty => p_available_qty ,
3423 p_curr_job_op_seq_num => p_curr_job_op_seq_num ,
3424 p_curr_job_intraop_step => p_curr_job_intraop_step ,
3425 p_job_serial_start_op => l_serial_start_op ,
3426 p_from_rtg_op_seq_num => p_from_rtg_op_seq_num ,
3427 p_to_rtg_op_seq_num => p_to_rtg_op_seq_num ,
3428 p_to_intraoperation_step => p_to_intraoperation_step ,
3429 p_user_serial_tracking => p_user_serial_tracking ,
3430 p_move_txn_id => p_move_txn_id ,
3431 p_scrap_txn_id => p_scrap_txn_id ,
3432 p_old_move_txn_id => p_old_move_txn_id ,
3433 p_old_scrap_txn_id => p_old_scrap_txn_id ,
3434 p_jump_flag => p_jump_flag ,
3435 p_scrap_at_operation => p_scrap_at_operation ,
3436 -- ST : Fix for bug 5140761 Addded the above parameter --
3437 x_serial_track_flag => x_serial_track_flag ,
3438 x_return_status => x_return_status ,
3439 x_error_msg => x_error_msg ,
3440 x_error_count => x_error_count
3441 );
3442
3443 if x_return_status <> G_RET_SUCCESS then
3444 IF x_return_status = G_RET_ERROR THEN
3445 raise FND_API.G_EXC_ERROR;
3446 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3447 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3448 END IF;
3449 end if;
3450
3451 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3452 l_msg_tokens.delete;
3453 WSM_log_PVT.logMessage (p_module_name => l_module ,
3454 p_msg_text => 'Move_serial_intf_proc Sucess',
3455 p_stmt_num => l_stmt_num ,
3456 p_msg_tokens => l_msg_tokens ,
3457 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3458 p_run_log_level => l_log_level
3459 );
3460 END IF;
3461
3462 EXCEPTION
3463
3464 WHEN FND_API.G_EXC_ERROR THEN
3465
3466 x_return_status := G_RET_ERROR;
3467 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3468 p_count => x_error_count ,
3469 p_data => x_error_msg
3470 );
3471
3472 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3473
3474 x_return_status := G_RET_UNEXPECTED;
3475
3476 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3477 p_count => x_error_count ,
3478 p_data => x_error_msg
3479 );
3480 WHEN OTHERS THEN
3481
3482 x_return_status := G_RET_UNEXPECTED;
3483
3484 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3485 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3486 THEN
3487 WSM_log_PVT.handle_others( p_module_name => l_module ,
3488 p_stmt_num => l_stmt_num ,
3489 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3490 p_run_log_level => l_log_level
3491 );
3492 END IF;
3493
3494 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3495 p_count => x_error_count ,
3496 p_data => x_error_msg
3497 );
3498 END Move_serial_intf_proc;
3499
3500 -- Expected i/p is the header id of the Move Transaction...
3501 Procedure Move_serial_processor ( p_calling_mode IN NUMBER,
3502 p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
3503 p_move_txn_type IN NUMBER,
3504 p_wip_entity_id IN NUMBER,
3505 p_organization_id IN NUMBER,
3506 p_inventory_item_id IN NUMBER,
3507 p_move_qty IN NUMBER,
3508 p_scrap_qty IN NUMBER,
3509 p_available_qty IN NUMBER,
3510 p_curr_job_op_seq_num IN NUMBER,
3511 p_curr_job_intraop_step IN NUMBER,
3512 p_from_rtg_op_seq_num IN NUMBER,
3513 p_to_rtg_op_seq_num IN NUMBER,
3514 p_to_intraoperation_step IN NUMBER,
3515 p_job_serial_start_op IN NUMBER,
3516 p_user_serial_tracking IN NUMBER,
3517 p_move_txn_id IN NUMBER,
3518 p_scrap_txn_id IN NUMBER,
3519 p_old_move_txn_id IN NUMBER,
3520 p_old_scrap_txn_id IN NUMBER,
3521 p_jump_flag IN varchar2 DEFAULT NULL,
3522 p_scrap_at_operation IN NUMBER DEFAULT NULL,
3523 -- ST : Fix for bug 5140761 Addded the above parameter --
3524 x_serial_track_flag IN OUT NOCOPY NUMBER,
3525 x_return_status OUT NOCOPY VARCHAR2,
3526 x_error_msg OUT NOCOPY VARCHAR2,
3527 x_error_count OUT NOCOPY NUMBER
3528 )
3529
3530 IS
3531
3532 l_old_serial_track_flag NUMBER;
3533
3534 -- Logging variables.....
3535 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3536 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3537
3538 l_stmt_num NUMBER;
3539 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Move_serial_processor';
3540 l_param_tbl WSM_Log_PVT.param_tbl_type;
3541 -- Logging variables...
3542
3543 BEGIN
3544 SAVEPOINT Move_serial_proc;
3545
3546 x_return_status := G_RET_SUCCESS;
3547 x_error_msg := NULL;
3548 x_error_count := 0;
3549
3550 l_stmt_num := 10;
3551 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
3552
3553 l_param_tbl.delete;
3554 l_param_tbl(1).paramName := 'p_calling_mode';
3555 l_param_tbl(1).paramValue := p_calling_mode;
3556
3557 l_param_tbl(2).paramName := 'p_organization_id';
3558 l_param_tbl(2).paramValue := p_organization_id;
3559
3560 l_param_tbl(3).paramName := 'p_wip_entity_id';
3561 l_param_tbl(3).paramValue := p_wip_entity_id;
3562
3563 l_param_tbl(4).paramName := 'p_serial_num_tbl.count';
3564 l_param_tbl(4).paramValue := p_serial_num_tbl.count;
3565
3566 l_param_tbl(5).paramName := 'p_move_txn_type';
3567 l_param_tbl(5).paramValue := p_move_txn_type;
3568
3569 l_param_tbl(6).paramName := 'p_scrap_at_operation';
3570 l_param_tbl(6).paramValue := p_scrap_at_operation;
3571
3572 WSM_Log_PVT.logProcParams(p_module_name => l_module,
3573 p_param_tbl => l_param_tbl,
3574 p_fnd_log_level => l_log_level
3575 );
3576 END IF;
3577
3578 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3579 l_stmt_num := 15;
3580 -- Procedure to dump the serial records' data....
3581 log_serial_data ( p_serial_num_tbl => p_serial_num_tbl ,
3582 x_return_status => x_return_status ,
3583 x_error_msg => x_error_msg ,
3584 x_error_count => x_error_count
3585 );
3586 if x_return_status <> G_RET_SUCCESS then
3587 IF x_return_status = G_RET_ERROR THEN
3588 raise FND_API.G_EXC_ERROR;
3589 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3590 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3591 END IF;
3592 end if;
3593 END IF;
3594
3595 -- check the qty...
3596 if p_move_txn_type in (1,2) then
3597
3598 l_stmt_num := 20;
3599 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3600 l_msg_tokens.delete;
3601 WSM_log_PVT.logMessage (p_module_name => l_module ,
3602 p_msg_text => 'Invoking WSM_SERIAL_SUPPORT_PVT.check_move_serial_qty',
3603 p_stmt_num => l_stmt_num ,
3604 p_msg_tokens => l_msg_tokens ,
3605 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3606 p_run_log_level => l_log_level
3607 );
3608 END IF;
3609
3610 l_old_serial_track_flag := x_serial_track_flag;
3611
3612 -- invoke check_move_txn_qty
3613 check_move_serial_qty ( p_calling_mode => p_calling_mode ,
3614 p_serial_num_tbl => p_serial_num_tbl ,
3615 p_move_txn_type => p_move_txn_type ,
3616 p_wip_entity_id => p_wip_entity_id ,
3617 p_inventory_item_id => p_inventory_item_id ,
3618 p_organization_id => p_organization_id ,
3619 p_move_qty => p_move_qty ,
3620 p_scrap_qty => p_scrap_qty ,
3621 p_available_qty => p_available_qty ,
3622 p_curr_job_op_seq_num => p_curr_job_op_seq_num ,
3623 p_curr_job_intraop_step => p_curr_job_intraop_step ,
3624 p_job_serial_start_op => p_job_serial_start_op ,
3625 p_from_rtg_op_seq_num => p_from_rtg_op_seq_num ,
3626 p_to_rtg_op_seq_num => p_to_rtg_op_seq_num ,
3627 p_to_intraoperation_step => p_to_intraoperation_step ,
3628 p_user_serial_tracking => p_user_serial_tracking ,
3629 p_move_txn_id => p_move_txn_id ,
3630 p_scrap_txn_id => p_scrap_txn_id ,
3631 p_jump_flag => p_jump_flag ,
3632 p_scrap_at_operation => p_scrap_at_operation ,
3633 -- ST : Fix for bug 5140761 Addded the above parameter --
3634 x_serial_track_flag => x_serial_track_flag ,
3635 x_return_status => x_return_status ,
3636 x_error_msg => x_error_msg ,
3637 x_error_count => x_error_count
3638 );
3639
3640 if x_return_status <> G_RET_SUCCESS then
3641 IF x_return_status = G_RET_ERROR THEN
3642 raise FND_API.G_EXC_ERROR;
3643 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3644 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3645 END IF;
3646 end if;
3647
3648 l_stmt_num := 30;
3649
3650 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3651 l_msg_tokens.delete;
3652 WSM_log_PVT.logMessage (p_module_name => l_module ,
3653 p_msg_text => 'Value of x_serial_track_flag : ' || x_serial_track_flag,
3654 p_stmt_num => l_stmt_num ,
3655 p_msg_tokens => l_msg_tokens ,
3656 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3657 p_run_log_level => l_log_level
3658 );
3659 END IF;
3660
3661 -- if serialization begun at this move transaction update the field in WSM_LOT_BASED_JOBS, WIP_DISCRETE_JOBS
3662 IF l_old_serial_track_flag IS NULL and x_serial_track_flag IS NOT NULL
3663 THEN
3664
3665 l_stmt_num := 40;
3666 -- Update WDJ also...
3667 UPDATE WSM_LOT_BASED_JOBS
3668 SET first_serial_txn_id = p_move_txn_id
3669 WHERE wip_entity_id = p_wip_entity_id;
3670
3671 l_stmt_num := 50;
3672 UPDATE WIP_DISCRETE_JOBS
3673 SET serialization_start_op = 10
3674 WHERE wip_entity_id = p_wip_entity_id;
3675
3676 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3677 l_msg_tokens.delete;
3678 WSM_log_PVT.logMessage (p_module_name => l_module ,
3679 p_msg_text => 'Updated WIP_DISCRETE_JOBS to set the serialization_start_op',
3680 p_stmt_num => l_stmt_num ,
3681 p_msg_tokens => l_msg_tokens ,
3682 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3683 p_run_log_level => l_log_level
3684 );
3685 END IF;
3686
3687 END IF;
3688
3689 else -- Undo/Assembly return
3690 -- invoke populate_undo_serial_nums
3691 l_stmt_num := 60;
3692
3693 IF x_serial_track_flag IS NOT NULL THEN
3694
3695 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3696 l_msg_tokens.delete;
3697 WSM_log_PVT.logMessage (p_module_name => l_module ,
3698 p_msg_text => 'Invoking WSM_Serial_support_PVT.populate_undo_txn',
3699 p_stmt_num => l_stmt_num ,
3700 p_msg_tokens => l_msg_tokens ,
3701 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3702 p_run_log_level => l_log_level
3703 );
3704 END IF;
3705
3706 populate_undo_txn ( p_move_txn_type => p_move_txn_type ,
3707 p_wip_entity_id => p_wip_entity_id ,
3708 p_inventory_item_id => p_inventory_item_id ,
3709 p_organization_id => p_organization_id ,
3710 p_move_qty => p_move_qty ,
3711 p_scrap_qty => p_scrap_qty ,
3712 p_new_move_txn_id => p_move_txn_id ,
3713 p_new_scrap_txn_id => p_scrap_txn_id ,
3714 p_old_move_txn_id => p_old_move_txn_id ,
3715 p_old_scrap_txn_id => p_old_scrap_txn_id ,
3716 x_return_status => x_return_status ,
3717 x_error_msg => x_error_msg ,
3718 x_error_count => x_error_count
3719 );
3720
3721 if x_return_status <> G_RET_SUCCESS then
3722 IF x_return_status = G_RET_ERROR THEN
3723 raise FND_API.G_EXC_ERROR;
3724 ELSIF x_return_status = G_RET_UNEXPECTED THEN
3725 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3726 END IF;
3727 end if;
3728
3729 -- if the old txn_id = first serial move transaction id, then clear the fields in
3730 -- WSM_LOT_BASED_JOBS
3731 l_stmt_num := 70;
3732
3733 -- The field in WDJ can be cleared only after the Txn is successful...
3734 UPDATE WSM_LOT_BASED_JOBS
3735 set first_serial_txn_id = null
3736 WHERE wip_entity_id = p_wip_entity_id
3737 AND first_serial_txn_id = p_old_move_txn_id;
3738
3739 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3740 l_msg_tokens.delete;
3741 WSM_log_PVT.logMessage (p_module_name => l_module ,
3742 p_msg_text => 'Updated ' || SQL%ROWCOUNT || ' records in WSM_LOT_BASED_JOBS',
3743 p_stmt_num => l_stmt_num ,
3744 p_msg_tokens => l_msg_tokens ,
3745 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3746 p_run_log_level => l_log_level
3747 );
3748 END IF;
3749 END IF;
3750 end if;
3751 EXCEPTION
3752
3753 WHEN FND_API.G_EXC_ERROR THEN
3754 ROLLBACK to Move_serial_proc;
3755 x_return_status := G_RET_ERROR;
3756 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3757 p_count => x_error_count ,
3758 p_data => x_error_msg
3759 );
3760
3761 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3762 ROLLBACK to Move_serial_proc;
3763 x_return_status := G_RET_UNEXPECTED;
3764
3765 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3766 p_count => x_error_count ,
3767 p_data => x_error_msg
3768 );
3769 WHEN OTHERS THEN
3770 ROLLBACK to Move_serial_proc;
3771 x_return_status := G_RET_UNEXPECTED;
3772
3773 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
3774 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
3775 THEN
3776 WSM_log_PVT.handle_others( p_module_name => l_module ,
3777 p_stmt_num => l_stmt_num ,
3778 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
3779 p_run_log_level => l_log_level
3780 );
3781 END IF;
3782
3783 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
3784 p_count => x_error_count ,
3785 p_data => x_error_msg
3786 );
3787 END Move_serial_processor;
3788
3789
3790 -- check the move qty and ensure that serial no.s are inserted if inadequate...
3791 Procedure check_move_serial_qty( p_calling_mode IN NUMBER,
3792 p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
3793 p_move_txn_type IN NUMBER,
3794 p_wip_entity_id IN NUMBER,
3795 p_inventory_item_id IN NUMBER,
3796 p_organization_id IN NUMBER,
3797 p_move_qty IN NUMBER,
3798 p_scrap_qty IN NUMBER,
3799 p_available_qty IN NUMBER,
3800 p_curr_job_op_seq_num IN NUMBER,
3801 p_curr_job_intraop_step IN NUMBER,
3802 p_job_serial_start_op IN NUMBER,
3803 p_from_rtg_op_seq_num IN NUMBER,
3804 p_to_rtg_op_seq_num IN NUMBER,
3805 p_to_intraoperation_step IN NUMBER,
3806 p_user_serial_tracking IN NUMBER,
3807 p_move_txn_id IN NUMBER,
3808 p_scrap_txn_id IN NUMBER,
3809 p_jump_flag IN varchar2 DEFAULT NULL,
3810 p_scrap_at_operation IN NUMBER DEFAULT NULL,
3811 -- ST : Fix for bug 5140761 Addded the above parameter --
3812 x_serial_track_flag IN OUT NOCOPY NUMBER,
3813 x_return_status OUT NOCOPY VARCHAR2,
3814 x_error_msg OUT NOCOPY VARCHAR2,
3815 x_error_count OUT NOCOPY NUMBER
3816 )
3817 IS
3818
3819 type t_serial_tbl is table of number index by mtl_serial_numbers.serial_number%type;
3820
3821 l_move_serial_qty NUMBER;
3822 l_scrap_serial_qty NUMBER;
3823
3824 l_index NUMBER;
3825 l_return_status NUMBER;
3826 l_error_count NUMBER;
3827 l_error_msg VARCHAR2(2000);
3828 l_count NUMBER;
3829 l_cntr NUMBER;
3830
3831 l_update_serial_attr NUMBER;
3832 l_context_value MTL_SERIAL_NUMBERS.serial_attribute_category%type;
3833
3834 l_wip_serial_nums_tbl t_wip_intf_tbl_type;
3835 l_serial_list t_serial_tbl;
3836
3837 l_old_serial_track_status NUMBER;
3838 l_job_serial_count NUMBER;
3839 l_gen_object_id NUMBER;
3840
3841 CURSOR c_job_serials is SELECT serial_number
3842 FROM mtl_serial_numbers msn
3843 where msn.inventory_item_id = p_inventory_item_id
3844 and msn.current_organization_id = p_organization_id
3845 and msn.wip_entity_id = p_wip_entity_id;
3846
3847 -- Logging variables.....
3848 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
3849 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3850
3851 l_stmt_num NUMBER;
3852 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.check_move_serial_qty';
3853 l_param_tbl WSM_Log_PVT.param_tbl_type;
3854 -- Logging variables...
3855
3856 l_charge_jump_from_queue NUMBER;
3857
3858 BEGIN
3859 l_stmt_num := 10;
3860
3861 x_return_status := G_RET_SUCCESS;
3862 x_error_msg := NULL;
3863 x_error_count := 0;
3864
3865 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
3866
3867 l_param_tbl.delete;
3868 l_param_tbl(1).paramName := 'p_available_qty';
3869 l_param_tbl(1).paramValue := p_available_qty;
3870
3871 l_param_tbl(2).paramName := 'p_move_qty';
3872 l_param_tbl(2).paramValue := p_move_qty;
3873
3874 l_param_tbl(3).paramName := 'p_to_rtg_op_seq_num';
3875 l_param_tbl(3).paramValue := p_to_rtg_op_seq_num;
3876
3877 l_param_tbl(4).paramName := 'p_from_rtg_op_seq_num';
3878 l_param_tbl(4).paramValue := p_from_rtg_op_seq_num;
3879
3880 l_param_tbl(5).paramName := 'p_job_serial_start_op';
3881 l_param_tbl(5).paramValue := p_job_serial_start_op;
3882
3883 l_param_tbl(6).paramName := 'p_serial_num_tbl (count)';
3884 l_param_tbl(6).paramValue := p_serial_num_tbl.count;
3885
3886 WSM_Log_PVT.logProcParams(p_module_name => l_module,
3887 p_param_tbl => l_param_tbl,
3888 p_fnd_log_level => l_log_level
3889 );
3890 END IF;
3891
3892 l_old_serial_track_status := x_serial_track_flag;
3893
3894 -- first check for serialization start op...
3895 if x_serial_track_flag IS NULL then
3896
3897 l_stmt_num := 20;
3898 -- Indicates serial tracking hasnot yet begun
3899 If p_user_serial_tracking IS NULL then
3900 l_stmt_num := 30;
3901
3902 IF p_jump_flag IS NOT NULL THEN
3903 select charge_jump_from_queue
3904 into l_charge_jump_from_queue
3905 from wsm_parameters
3906 where organization_id = p_organization_id;
3907 END IF;
3908 --The user also doesn't want to start serial tracking..
3909 -- But if the below conditions satisfy then serial tracking will begin...
3910 -- i) To operation is the serial start op and the to intraop step <> QUEUE
3911 -- ii) To operation is the serial start op and the intraop atep = queue and scrap qty > 0 and scrap is at to operation
3912 -- iii) Completion txn
3913 -- iv) From operation is the serial start op and is a jump op and charge current op during jump is Yes
3914 If ( p_to_rtg_op_seq_num = p_job_serial_start_op
3915 AND
3916 (p_to_intraoperation_step <> WIP_CONSTANTS.QUEUE OR
3917 (nvl(p_scrap_qty,0) <> 0 AND nvl(p_scrap_at_operation,1) = 2)
3918 -- ST : Fix for bug 5140761 Added the above clause --
3919 )
3920 )
3921 OR
3922 (p_from_rtg_op_seq_num = p_job_serial_start_op and NOT(nvl(p_jump_flag,'N') = 'Y' and l_charge_jump_from_queue <> 1))
3923 OR
3924 (p_move_txn_type = 2)
3925 --and p_job_serial_start_op is not Null
3926 --IF the move txn type is completion we enforce...
3927 THEN
3928 l_stmt_num := 40;
3929 x_serial_track_flag := 1;
3930 end if;
3931 else
3932 -- The User intends to start...
3933 x_serial_track_flag := 1;
3934 end if;
3935 end if;
3936
3937 l_stmt_num := 50;
3938 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
3939 l_msg_tokens.delete;
3940 WSM_log_PVT.logMessage (p_module_name => l_module ,
3941 p_msg_text => 'Serial Tracking for the Job : ' || x_serial_track_flag,
3942 p_stmt_num => l_stmt_num ,
3943 p_msg_tokens => l_msg_tokens ,
3944 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
3945 p_run_log_level => l_log_level
3946 );
3947 END IF;
3948
3949 -- check for non-needed serial info...
3950 if x_serial_track_flag IS NULL and p_serial_num_tbl.count>0 then
3951 -- Set return status to error and return.. we don't expect records
3952 IF g_log_level_error >= l_log_level OR
3953 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3954 THEN
3955
3956 l_msg_tokens.delete;
3957 WSM_log_PVT.logMessage(p_module_name => l_module ,
3958 p_msg_name => 'WSM_INVALID_INFO_NOT_TRACKED',
3959 p_msg_appl_name => 'WSM' ,
3960 p_msg_tokens => l_msg_tokens ,
3961 p_stmt_num => l_stmt_num ,
3962 p_fnd_msg_level => G_MSG_LVL_ERROR ,
3963 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
3964 p_run_log_level => l_log_level
3965 );
3966 END IF;
3967 RAISE FND_API.G_EXC_ERROR;
3968
3969 End if;
3970
3971
3972 l_stmt_num := 60;
3973 -- get the count of serial numbers present
3974 SELECT count(*)
3975 INTO l_job_serial_count
3976 FROM mtl_serial_numbers MSN
3977 where MSN.wip_entity_id = p_wip_entity_id
3978 AND MSN.current_organization_id = p_organization_id
3979 AND MSN.inventory_item_id = p_inventory_item_id
3980 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP;
3981
3982 -- ST : Fix for bug 5190943 : Added the validation --
3983 -- Now validate the qty for a non-serial traked job
3984 IF x_serial_track_flag IS NULL THEN
3985 -- Validate...
3986 IF l_job_serial_count > (p_available_qty - p_scrap_qty) THEN
3987 -- error out in this case...
3988 IF g_log_level_error >= l_log_level OR
3989 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
3990 THEN
3991 l_msg_tokens.delete;
3992 l_msg_tokens(1).TokenName := 'JOB';
3993
3994 select wip_entity_name
3995 into l_msg_tokens(1).TokenValue
3996 from wip_entities
3997 where wip_entity_id = p_wip_entity_id
3998 and organization_id = p_organization_id;
3999
4000 WSM_log_PVT.logMessage(p_module_name => l_module ,
4001 p_msg_name => 'WSM_PARTIAL_EXCESS_SERIAL',
4002 p_msg_appl_name => 'WSM' ,
4003 p_msg_tokens => l_msg_tokens ,
4004 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4005 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4006 p_run_log_level => l_log_level
4007 );
4008 END IF;
4009 RAISE FND_API.G_EXC_ERROR;
4010 END IF;
4011 -- return...
4012 RETURN;
4013 END IF;
4014
4015 IF l_job_serial_count <> p_available_qty THEN
4016
4017 -- Not enough data to start serial tracking...
4018 IF g_log_level_error >= l_log_level OR
4019 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4020 THEN
4021 l_msg_tokens.delete;
4022 WSM_log_PVT.logMessage(p_module_name => l_module ,
4023 p_msg_name => 'WSM_NO_START_SERTRACK' ,
4024 p_msg_appl_name => 'WSM' ,
4025 p_msg_tokens => l_msg_tokens ,
4026 p_stmt_num => l_stmt_num ,
4027 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4028 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4029 p_run_log_level => l_log_level
4030 );
4031 END IF;
4032 RAISE FND_API.G_EXC_ERROR;
4033 END IF;
4034
4035 -- Now get the count of the serial numbers being moved....
4036 l_move_serial_qty := 0;
4037 l_scrap_serial_qty := 0;
4038
4039 l_cntr := p_serial_num_tbl.first;
4040
4041 while (l_cntr is not null) loop
4042
4043 if l_serial_list.exists(p_serial_num_tbl(l_cntr).serial_number) then
4044 -- error out...
4045 -- Duplicate entry...
4046 IF g_log_level_error >= l_log_level OR
4047 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4048 THEN
4049 l_msg_tokens.delete;
4050 l_msg_tokens(1).TokenName := 'SERIAL';
4051 l_msg_tokens(1).TokenValue := p_serial_num_tbl(l_cntr).serial_number;
4052
4053 WSM_log_PVT.logMessage(p_module_name => l_module ,
4054 p_msg_name => 'WSM_DUPLICATE_TXN_SERIAL',
4055 p_msg_appl_name => 'WSM' ,
4056 p_msg_tokens => l_msg_tokens ,
4057 p_stmt_num => l_stmt_num ,
4058 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4059 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4060 p_run_log_level => l_log_level
4061 );
4062 END IF;
4063 RAISE FND_API.G_EXC_ERROR;
4064 end if;
4065
4066 if p_serial_num_tbl(l_cntr).action_flag = 5 then
4067 l_move_serial_qty := l_move_serial_qty + 1;
4068 else
4069 l_scrap_serial_qty := l_scrap_serial_qty + 1;
4070 end if;
4071
4072 l_serial_list(p_serial_num_tbl(l_cntr).serial_number) := 1;
4073 l_cntr := p_serial_num_tbl.next(l_cntr);
4074
4075 end loop;
4076
4077 l_serial_list.delete;
4078
4079 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4080 l_msg_tokens.delete;
4081 WSM_log_PVT.logMessage (p_module_name => l_module ,
4082 p_msg_text => 'User provided serials to be moved : ' || l_move_serial_qty || ' : Serials to be scrapped : ' || l_scrap_serial_qty,
4083 p_stmt_num => l_stmt_num ,
4084 p_msg_tokens => l_msg_tokens ,
4085 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4086 p_run_log_level => l_log_level
4087 );
4088 END IF;
4089 l_stmt_num := 70;
4090 -- validations...
4091 IF p_move_qty <> 0 AND p_scrap_qty <> 0 THEN
4092 -- Move and scrap transaction...
4093 -- move and scrap txn..
4094 -- User has to provide either the move qty or scrap qty in full..
4095 l_stmt_num := 80;
4096 if l_move_serial_qty <> p_move_qty and l_scrap_serial_qty <> p_scrap_qty then
4097 -- error out...
4098 -- insufficient info...
4099 l_stmt_num := 90;
4100
4101 IF g_log_level_error >= l_log_level OR
4102 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4103 THEN
4104
4105 l_msg_tokens.delete;
4106 WSM_log_PVT.logMessage(p_module_name => l_module ,
4107 p_msg_name => 'WSM_SUPPLIED_QTY_INVALID',
4108 p_msg_appl_name => 'WSM' ,
4109 p_msg_tokens => l_msg_tokens ,
4110 p_stmt_num => l_stmt_num ,
4111 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4112 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4113 p_run_log_level => l_log_level
4114 );
4115 END IF;
4116 RAISE FND_API.G_EXC_ERROR;
4117
4118 elsif (l_move_serial_qty = p_move_qty) THEN
4119 -- -- all the move serial numbers provided...
4120 l_count := 0;
4121 l_stmt_num := 100;
4122 -- loop theough p_serial_num_tbl and load the local PL/SQl table...
4123 for l_serial_counter in p_serial_num_tbl.first..p_serial_num_tbl.last loop
4124
4125 l_count := l_count + 1;
4126
4127 IF p_serial_num_tbl(l_serial_counter).action_flag = 5 THEN
4128 l_wip_serial_nums_tbl(l_count).TRANSACTION_ID := p_move_txn_id;
4129 ELSE
4130 l_wip_serial_nums_tbl(l_count).TRANSACTION_ID := p_scrap_txn_id;
4131 END IF;
4132
4133 l_wip_serial_nums_tbl(l_count).ASSEMBLY_SERIAL_NUMBER := p_serial_num_tbl(l_count).serial_number;
4134 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
4135 -- Column not renamed due to
4136 -- i) MES depency through the record defined in the WSM_SERIAL_SUPPORT_GRP package
4137 -- ii) The column is not exposed to the user .. It is an internal column
4138 l_gen_object_id := p_serial_num_tbl(l_count).assembly_item_id;
4139 IF l_gen_object_id IS NULL THEN
4140 -- could be NULL when passed from MES..
4141 select gen_object_id
4142 into l_gen_object_id
4143 from mtl_serial_numbers
4144 where serial_number = p_serial_num_tbl(l_count).serial_number
4145 and inventory_item_id = p_inventory_item_id
4146 and current_organization_id = p_organization_id;
4147 END IF;
4148
4149 l_wip_serial_nums_tbl(l_count).gen_object_id := l_gen_object_id;
4150 l_wip_serial_nums_tbl(l_count).CREATION_DATE := sysdate;
4151 l_wip_serial_nums_tbl(l_count).CREATED_BY := g_user_id;
4152 l_wip_serial_nums_tbl(l_count).CREATED_BY_NAME := g_user_name;
4153 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_DATE := sysdate;
4154 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY := g_user_id;
4155 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY_NAME := g_user_name;
4156 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_LOGIN := g_user_login_id;
4157 l_wip_serial_nums_tbl(l_count).REQUEST_ID := g_request_id;
4158 l_wip_serial_nums_tbl(l_count).PROGRAM_APPLICATION_ID := g_program_appl_id;
4159 l_wip_serial_nums_tbl(l_count).PROGRAM_ID := g_program_id;
4160 l_wip_serial_nums_tbl(l_count).PROGRAM_UPDATE_DATE := sysdate;
4161 end loop;
4162
4163 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4164 l_msg_tokens.delete;
4165 WSM_log_PVT.logMessage (p_module_name => l_module ,
4166 p_msg_text => 'Going to Insert ' || l_count || ' user provided records into wip_serial_move_interface for move and scrap',
4167 p_stmt_num => l_stmt_num ,
4168 p_msg_tokens => l_msg_tokens ,
4169 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4170 p_run_log_level => l_log_level
4171 );
4172 END IF;
4173
4174 l_stmt_num := 110;
4175 -- do a bulk insert...
4176 forall l_cntr in l_wip_serial_nums_tbl.first..l_wip_serial_nums_tbl.last
4177 insert into wip_serial_move_interface values l_wip_serial_nums_tbl(l_cntr);
4178
4179 l_stmt_num := 120;
4180 IF l_move_serial_qty + l_scrap_serial_qty <> p_available_qty THEN
4181
4182 l_stmt_num := 130;
4183 -- Now insert the left over serial numbers for scrap..
4184 -- insert the remaining records as scrap records....
4185 INSERT INTO WIP_SERIAL_MOVE_INTERFACE
4186 ( TRANSACTION_ID,
4187 ASSEMBLY_SERIAL_NUMBER,
4188 GEN_OBJECT_ID,
4189 LAST_UPDATE_DATE,
4190 LAST_UPDATED_BY,
4191 LAST_UPDATED_BY_NAME,
4192 CREATION_DATE,
4193 CREATED_BY,
4194 CREATED_BY_NAME,
4195 LAST_UPDATE_LOGIN,
4196 REQUEST_ID,
4197 PROGRAM_APPLICATION_ID,
4198 PROGRAM_ID,
4199 PROGRAM_UPDATE_DATE
4200 )
4201 (
4202 SELECT
4203 p_scrap_txn_id,
4204 SERIAL_NUMBER,
4205 gen_object_id,
4206 sysdate,
4207 g_user_id,
4208 g_user_name,
4209 sysdate,
4210 g_user_id,
4211 g_user_name,
4212 g_user_login_id,
4213 g_request_id,
4214 g_program_appl_id,
4215 g_program_id,
4216 sysdate
4217 FROM MTL_SERIAL_NUMBERS MSN
4218 WHERE MSN.wip_entity_id = p_wip_entity_id
4219 AND MSN.current_organization_id = p_organization_id
4220 AND MSN.inventory_item_id = p_inventory_item_id
4221 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
4222 -- AND MSN.operation_seq_num = p_curr_job_op_seq_num
4223 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP
4224 AND NOT EXISTS (select 'Serial Already inserted for move'
4225 from WIP_SERIAL_MOVE_INTERFACE
4226 where TRANSACTION_ID = p_move_txn_id
4227 AND ASSEMBLY_SERIAL_NUMBER = MSN.SERIAL_NUMBER
4228 )
4229 AND NOT EXISTS (select 'Serial Already inserted for scrap'
4230 from WIP_SERIAL_MOVE_INTERFACE
4231 where TRANSACTION_ID = p_scrap_txn_id
4232 AND ASSEMBLY_SERIAL_NUMBER = MSN.SERIAL_NUMBER
4233 )
4234 );
4235
4236 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4237 l_msg_tokens.delete;
4238 WSM_log_PVT.logMessage (p_module_name => l_module ,
4239 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' records into wip_serial_move_interface for scrap',
4240 p_stmt_num => l_stmt_num ,
4241 p_msg_tokens => l_msg_tokens ,
4242 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4243 p_run_log_level => l_log_level
4244 );
4245 END IF;
4246
4247 l_stmt_num := 140;
4248 END IF;
4249
4250 elsif l_scrap_serial_qty = p_scrap_qty then -- -- all the scrap serial numbers provided...
4251 -- loop theough p_serial_num_tbl and load the local PL/SQl table...
4252 l_count := 0;
4253 l_stmt_num := 150;
4254 -- loop theough p_serial_num_tbl and load the local PL/SQl table...
4255 for l_serial_counter in p_serial_num_tbl.first..p_serial_num_tbl.last loop
4256
4257 l_count := l_count + 1;
4258
4259 IF p_serial_num_tbl(l_serial_counter).action_flag = 5 THEN
4260 l_wip_serial_nums_tbl(l_count).TRANSACTION_ID := p_move_txn_id;
4261 ELSE
4262 l_wip_serial_nums_tbl(l_count).TRANSACTION_ID := p_scrap_txn_id;
4263 END IF;
4264
4265 l_wip_serial_nums_tbl(l_count).ASSEMBLY_SERIAL_NUMBER := p_serial_num_tbl(l_count).serial_number;
4266 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
4267 -- Column not renamed due to
4268 -- i) MES depency through the record defined in the WSM_SERIAL_SUPPORT_GRP package
4269 -- ii) The column is not exposed to the user .. It is an internal column
4270 l_gen_object_id := p_serial_num_tbl(l_count).assembly_item_id;
4271 IF l_gen_object_id IS NULL THEN
4272 -- could be NULL when passed from MES..
4273 select gen_object_id
4274 into l_gen_object_id
4275 from mtl_serial_numbers
4276 where serial_number = p_serial_num_tbl(l_count).serial_number
4277 and inventory_item_id = p_inventory_item_id
4278 and current_organization_id = p_organization_id;
4279 END IF;
4280
4281 l_wip_serial_nums_tbl(l_count).gen_object_id := l_gen_object_id;
4282 l_wip_serial_nums_tbl(l_count).CREATION_DATE := sysdate;
4283 l_wip_serial_nums_tbl(l_count).CREATED_BY := g_user_id;
4284 l_wip_serial_nums_tbl(l_count).CREATED_BY_NAME := g_user_name;
4285 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_DATE := sysdate;
4286 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY := g_user_id;
4287 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY_NAME := g_user_name;
4288 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_LOGIN := g_user_login_id;
4289 l_wip_serial_nums_tbl(l_count).REQUEST_ID := g_request_id;
4290 l_wip_serial_nums_tbl(l_count).PROGRAM_APPLICATION_ID := g_program_appl_id;
4291 l_wip_serial_nums_tbl(l_count).PROGRAM_ID := g_program_id;
4292 l_wip_serial_nums_tbl(l_count).PROGRAM_UPDATE_DATE := sysdate;
4293 end loop;
4294
4295 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4296 l_msg_tokens.delete;
4297 WSM_log_PVT.logMessage (p_module_name => l_module ,
4298 p_msg_text => 'Going to Insert ' || l_count || ' user provided records into wip_serial_move_interface for move and scrap',
4299 p_stmt_num => l_stmt_num ,
4300 p_msg_tokens => l_msg_tokens ,
4301 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4302 p_run_log_level => l_log_level
4303 );
4304 END IF;
4305
4306 l_stmt_num := 160;
4307 -- do a bulk insert...
4308 forall l_cntr in l_wip_serial_nums_tbl.first..l_wip_serial_nums_tbl.last
4309 insert into wip_serial_move_interface values l_wip_serial_nums_tbl(l_cntr);
4310
4311 l_stmt_num := 170;
4312 IF l_move_serial_qty + l_scrap_serial_qty <> p_available_qty THEN
4313
4314 l_stmt_num := 180;
4315 -- Now insert the left over serial numbers for scrap..
4316 -- insert the remaining records as scrap records....
4317 INSERT INTO WIP_SERIAL_MOVE_INTERFACE
4318 ( TRANSACTION_ID,
4319 ASSEMBLY_SERIAL_NUMBER,
4320 gen_object_id,
4321 LAST_UPDATE_DATE,
4322 LAST_UPDATED_BY,
4323 LAST_UPDATED_BY_NAME,
4324 CREATION_DATE,
4325 CREATED_BY,
4326 CREATED_BY_NAME,
4327 LAST_UPDATE_LOGIN,
4328 REQUEST_ID,
4329 PROGRAM_APPLICATION_ID,
4330 PROGRAM_ID,
4331 PROGRAM_UPDATE_DATE
4332 )
4333 (
4334 SELECT
4335 p_move_txn_id,
4336 SERIAL_NUMBER,
4337 gen_object_id,
4338 sysdate,
4339 g_user_id,
4340 g_user_name,
4341 sysdate,
4342 g_user_id,
4343 g_user_name,
4344 g_user_login_id,
4345 g_request_id,
4346 g_program_appl_id,
4347 g_program_id,
4348 sysdate
4349 FROM MTL_SERIAL_NUMBERS MSN
4350 WHERE MSN.wip_entity_id = p_wip_entity_id
4351 AND MSN.current_organization_id = p_organization_id
4352 AND MSN.inventory_item_id = p_inventory_item_id
4353 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
4354 -- AND MSN.operation_seq_num = p_curr_job_op_seq_num
4355 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP
4356 AND NOT EXISTS (select 'Serial Already inserted for move'
4357 from WIP_SERIAL_MOVE_INTERFACE
4358 where TRANSACTION_ID = p_move_txn_id
4359 AND ASSEMBLY_SERIAL_NUMBER = MSN.SERIAL_NUMBER
4360 )
4361 AND NOT EXISTS (select 'Serial Already inserted for scrap'
4362 from WIP_SERIAL_MOVE_INTERFACE
4363 where TRANSACTION_ID = p_scrap_txn_id
4364 AND ASSEMBLY_SERIAL_NUMBER = MSN.SERIAL_NUMBER
4365 )
4366 );
4367
4368 l_stmt_num := 190;
4369 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4370 l_msg_tokens.delete;
4371 WSM_log_PVT.logMessage (p_module_name => l_module ,
4372 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' records into wip_serial_move_interface for Move',
4373 p_stmt_num => l_stmt_num ,
4374 p_msg_tokens => l_msg_tokens ,
4375 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4376 p_run_log_level => l_log_level
4377 );
4378 END IF;
4379
4380 END IF;
4381 end if;
4382
4383 ELSE
4384
4385 IF p_move_qty = p_available_qty THEN
4386
4387 l_stmt_num := 200;
4388 -- Move Quantity is equal to the available qty...
4389 -- Insert all the serial numbers linked to the job...
4390 INSERT INTO WIP_SERIAL_MOVE_INTERFACE
4391 ( TRANSACTION_ID,
4392 ASSEMBLY_SERIAL_NUMBER,
4393 gen_object_id,
4394 LAST_UPDATE_DATE,
4395 LAST_UPDATED_BY,
4396 LAST_UPDATED_BY_NAME,
4397 CREATION_DATE,
4398 CREATED_BY,
4399 CREATED_BY_NAME,
4400 LAST_UPDATE_LOGIN,
4401 REQUEST_ID,
4402 PROGRAM_APPLICATION_ID,
4403 PROGRAM_ID,
4404 PROGRAM_UPDATE_DATE
4405 )
4406 (
4407 SELECT
4408 p_move_txn_id,
4409 SERIAL_NUMBER,
4410 gen_object_id,
4411 sysdate,
4412 g_user_id,
4413 g_user_name,
4414 sysdate,
4415 g_user_id,
4416 g_user_name,
4417 g_user_login_id,
4418 g_request_id,
4419 g_program_appl_id,
4420 g_program_id,
4421 sysdate
4422 FROM MTL_SERIAL_NUMBERS MSN
4423 WHERE MSN.wip_entity_id = p_wip_entity_id
4424 AND MSN.current_organization_id = p_organization_id
4425 AND MSN.inventory_item_id = p_inventory_item_id
4426 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
4427 -- AND MSN.operation_seq_num = p_curr_job_op_seq_num
4428 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP
4429 );
4430
4431 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4432 l_msg_tokens.delete;
4433 WSM_log_PVT.logMessage (p_module_name => l_module ,
4434 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' records into WIP_SERIAL_MOVE_INTERFACE to be moved',
4435 p_stmt_num => l_stmt_num ,
4436 p_msg_tokens => l_msg_tokens ,
4437 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4438 p_run_log_level => l_log_level
4439 );
4440 END IF;
4441
4442 l_stmt_num := 210;
4443 ELSIF p_scrap_qty = p_available_qty THEN
4444
4445 l_stmt_num := 220;
4446 -- Scrap Quantity is equal to the available qty...
4447 -- Insert all the serial numbers linked to the job...
4448 INSERT INTO WIP_SERIAL_MOVE_INTERFACE
4449 ( TRANSACTION_ID,
4450 ASSEMBLY_SERIAL_NUMBER,
4451 gen_object_id,
4452 LAST_UPDATE_DATE,
4453 LAST_UPDATED_BY,
4454 LAST_UPDATED_BY_NAME,
4455 CREATION_DATE,
4456 CREATED_BY,
4457 CREATED_BY_NAME,
4458 LAST_UPDATE_LOGIN,
4459 REQUEST_ID,
4460 PROGRAM_APPLICATION_ID,
4461 PROGRAM_ID,
4462 PROGRAM_UPDATE_DATE
4463 )
4464 (
4465 SELECT
4466 p_scrap_txn_id,
4467 SERIAL_NUMBER,
4468 gen_object_id,
4469 sysdate,
4470 g_user_id,
4471 g_user_name,
4472 sysdate,
4473 g_user_id,
4474 g_user_name,
4475 g_user_login_id,
4476 g_request_id,
4477 g_program_appl_id,
4478 g_program_id,
4479 sysdate
4480 FROM MTL_SERIAL_NUMBERS MSN
4481 WHERE MSN.wip_entity_id = p_wip_entity_id
4482 AND MSN.current_organization_id = p_organization_id
4483 AND MSN.inventory_item_id = p_inventory_item_id
4484 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
4485 -- AND MSN.operation_seq_num = p_curr_job_op_seq_num
4486 AND nvl(MSN.intraoperation_step_type,-1) <> WIP_CONSTANTS.SCRAP
4487 );
4488
4489 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4490 l_msg_tokens.delete;
4491 WSM_log_PVT.logMessage (p_module_name => l_module ,
4492 p_msg_text => 'Inserted ' || SQL%ROWCOUNT || ' records into WIP_SERIAL_MOVE_INTERFACE to be scrapped',
4493 p_stmt_num => l_stmt_num ,
4494 p_msg_tokens => l_msg_tokens ,
4495 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4496 p_run_log_level => l_log_level
4497 );
4498 END IF;
4499
4500 l_stmt_num := 230;
4501 ELSE
4502 l_stmt_num := 240;
4503 -- Partial Scrap txn...
4504 -- scrap txn but not all the qty
4505 if p_scrap_qty <> l_scrap_serial_qty then
4506 -- error out. Insufficient info..
4507 l_stmt_num := 250;
4508 IF g_log_level_error >= l_log_level OR
4509 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4510 THEN
4511
4512 l_msg_tokens.delete;
4513 WSM_log_PVT.logMessage(p_module_name => l_module ,
4514 p_msg_name => 'WSM_SUPPLIED_QTY_INVALID',
4515 p_msg_appl_name => 'WSM' ,
4516 p_msg_tokens => l_msg_tokens ,
4517 p_stmt_num => l_stmt_num ,
4518 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4519 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4520 p_run_log_level => l_log_level
4521 );
4522 END IF;
4523 RAISE FND_API.G_EXC_ERROR;
4524 end if;
4525
4526 l_stmt_num := 260;
4527 -- loop theough p_serial_num_tbl and load the local PL/SQl table...
4528 l_count := 0;
4529
4530 l_index := p_serial_num_tbl.first;
4531 -- loop theough p_serial_num_tbl and load the local PL/SQl table...
4532 while l_index is not null loop
4533
4534 l_count := l_count + 1;
4535
4536 l_wip_serial_nums_tbl(l_count).TRANSACTION_ID := p_scrap_txn_id;
4537 l_wip_serial_nums_tbl(l_count).ASSEMBLY_SERIAL_NUMBER := p_serial_num_tbl(l_count).serial_number;
4538 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
4539 -- Column not renamed due to
4540 -- i) MES depency through the record defined in the WSM_SERIAL_SUPPORT_GRP package
4541 -- ii) The column is not exposed to the user .. It is an internal column
4542 l_gen_object_id := p_serial_num_tbl(l_count).assembly_item_id;
4543 IF l_gen_object_id IS NULL THEN
4544 -- could be NULL when passed from MES..
4545 select gen_object_id
4546 into l_gen_object_id
4547 from mtl_serial_numbers
4548 where serial_number = p_serial_num_tbl(l_count).serial_number
4549 and inventory_item_id = p_inventory_item_id
4550 and current_organization_id = p_organization_id;
4551 END IF;
4552
4553 l_wip_serial_nums_tbl(l_count).gen_object_id := l_gen_object_id;
4554 l_wip_serial_nums_tbl(l_count).CREATION_DATE := sysdate;
4555 l_wip_serial_nums_tbl(l_count).CREATED_BY := g_user_id;
4556 l_wip_serial_nums_tbl(l_count).CREATED_BY_NAME := g_user_name;
4557 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_DATE := sysdate;
4558 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY := g_user_id;
4559 l_wip_serial_nums_tbl(l_count).LAST_UPDATED_BY_NAME := g_user_name;
4560 l_wip_serial_nums_tbl(l_count).LAST_UPDATE_LOGIN := g_user_login_id;
4561 l_wip_serial_nums_tbl(l_count).REQUEST_ID := g_request_id;
4562 l_wip_serial_nums_tbl(l_count).PROGRAM_APPLICATION_ID := g_program_appl_id;
4563 l_wip_serial_nums_tbl(l_count).PROGRAM_ID := g_program_id;
4564 l_wip_serial_nums_tbl(l_count).PROGRAM_UPDATE_DATE := sysdate;
4565
4566 l_index := p_serial_num_tbl.next(l_index);
4567 end loop;
4568
4569 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4570 l_msg_tokens.delete;
4571 WSM_log_PVT.logMessage (p_module_name => l_module ,
4572 p_msg_text => 'Going to insert ' || l_wip_serial_nums_tbl.count || ' records into WIP_SERIAL_MOVE_INTERFACE to be scrapped',
4573 p_stmt_num => l_stmt_num ,
4574 p_msg_tokens => l_msg_tokens ,
4575 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4576 p_run_log_level => l_log_level
4577 );
4578 END IF;
4579
4580 l_stmt_num := 270;
4581 -- do a bulk insert...
4582 forall l_cntr in l_wip_serial_nums_tbl.first..l_wip_serial_nums_tbl.last
4583 insert into wip_serial_move_interface values l_wip_serial_nums_tbl(l_cntr);
4584
4585 l_stmt_num := 280;
4586 END IF;
4587 END IF;
4588
4589 l_stmt_num := 290;
4590 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4591 l_msg_tokens.delete;
4592 WSM_log_PVT.logMessage (p_module_name => l_module ,
4593 p_msg_text => 'Serial Attributes updation start',
4594 p_stmt_num => l_stmt_num ,
4595 p_msg_tokens => l_msg_tokens ,
4596 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4597 p_run_log_level => l_log_level
4598 );
4599 END IF;
4600
4601 l_cntr := p_serial_num_tbl.first;
4602 while l_cntr is not null loop
4603
4604 l_stmt_num := 300;
4605 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4606 l_msg_tokens.delete;
4607 WSM_log_PVT.logMessage (p_module_name => l_module ,
4608 p_msg_text => 'Invoking update_serial_attr(1) for ' ||
4609 'Serial Attributes updation for serial number ' ||
4610 p_serial_num_tbl(l_cntr).serial_number,
4611 p_stmt_num => l_stmt_num ,
4612 p_msg_tokens => l_msg_tokens ,
4613 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4614 p_run_log_level => l_log_level
4615 );
4616 END IF;
4617
4618 update_serial_attr ( p_calling_mode => p_calling_mode,
4619 p_serial_number_rec => p_serial_num_tbl(l_cntr),
4620 p_inventory_item_id => p_inventory_item_id,
4621 p_organization_id => p_organization_id ,
4622 p_clear_serial_attr => null,
4623 p_wlt_txn_type => null,
4624 p_update_serial_attr => null,
4625 p_update_desc_attr => 1,
4626 x_return_status => x_return_status,
4627 x_error_count => x_error_count,
4628 x_error_msg => x_error_msg
4629 );
4630
4631 if x_return_status <> G_RET_SUCCESS then
4632 IF x_return_status = G_RET_ERROR THEN
4633 raise FND_API.G_EXC_ERROR;
4634 ELSIF x_return_status = G_RET_UNEXPECTED THEN
4635 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4636 END IF;
4637 end if;
4638
4639 l_stmt_num := 310;
4640 l_cntr := p_serial_num_tbl.next(l_cntr);
4641
4642 end loop;
4643
4644 l_stmt_num := 320;
4645 IF l_old_serial_track_status IS NULL THEN
4646 -- Indicates that this is the first serial start operation...
4647 for l_job_serial_rec in c_job_serials loop
4648
4649 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4650 l_msg_tokens.delete;
4651 WSM_log_PVT.logMessage (p_module_name => l_module ,
4652 p_msg_text => 'Invoking update_serial : ' || l_job_serial_rec.serial_number
4653 || ' Operation : ' || p_curr_job_op_seq_num
4654 || ' Op Step : ' || p_curr_job_intraop_step,
4655 p_stmt_num => l_stmt_num ,
4656 p_msg_tokens => l_msg_tokens ,
4657 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4658 p_run_log_level => l_log_level
4659 );
4660 END IF;
4661
4662 -- Call the API to update the serial number...
4663 update_serial( p_serial_number => l_job_serial_rec.serial_number ,
4664 p_inventory_item_id => p_inventory_item_id ,
4665 p_organization_id => p_organization_id ,
4666 p_wip_entity_id => p_wip_entity_id ,
4667 p_operation_seq_num => p_curr_job_op_seq_num ,
4668 p_intraoperation_step_type => p_curr_job_intraop_step ,
4669 x_return_status => x_return_status ,
4670 x_error_msg => x_error_count ,
4671 x_error_count => x_error_msg
4672 );
4673
4674 if x_return_status <> G_RET_SUCCESS then
4675 IF x_return_status = G_RET_ERROR THEN
4676 raise FND_API.G_EXC_ERROR;
4677 ELSIF x_return_status = G_RET_UNEXPECTED THEN
4678 raise FND_API.G_EXC_UNEXPECTED_ERROR;
4679 END IF;
4680 end if;
4681 end loop;
4682 END IF;
4683
4684 l_stmt_num := 330;
4685
4686 EXCEPTION
4687 WHEN FND_API.G_EXC_ERROR THEN
4688
4689 x_return_status := G_RET_ERROR;
4690 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
4691 p_count => x_error_count ,
4692 p_data => x_error_msg
4693 );
4694
4695 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4696
4697 x_return_status := G_RET_UNEXPECTED;
4698
4699 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
4700 p_count => x_error_count ,
4701 p_data => x_error_msg
4702 );
4703 WHEN OTHERS THEN
4704
4705 x_return_status := G_RET_UNEXPECTED;
4706
4707 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
4708 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
4709 THEN
4710 WSM_log_PVT.handle_others( p_module_name => l_module ,
4711 p_stmt_num => l_stmt_num ,
4712 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
4713 p_run_log_level => l_log_level
4714 );
4715 END IF;
4716
4717 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
4718 p_count => x_error_count ,
4719 p_data => x_error_msg
4720 );
4721 END check_move_serial_qty;
4722
4723 -- Populate serial numbers for undo/return transactions..
4724 Procedure populate_undo_txn ( p_move_txn_type IN NUMBER,
4725 p_wip_entity_id IN NUMBER,
4726 p_inventory_item_id IN NUMBER,
4727 p_organization_id IN NUMBER,
4728 p_move_qty IN NUMBER,
4729 p_scrap_qty IN NUMBER,
4730 p_new_move_txn_id IN NUMBER,
4731 p_new_scrap_txn_id IN NUMBER,
4732 p_old_move_txn_id IN NUMBER DEFAULT NULL,
4733 p_old_scrap_txn_id IN NUMBER DEFAULT NULL,
4734 x_return_status OUT NOCOPY VARCHAR2,
4735 x_error_msg OUT NOCOPY VARCHAR2,
4736 x_error_count OUT NOCOPY NUMBER
4737 )
4738
4739
4740 IS
4741
4742 cursor c_ret_serial_num(v_txn_id IN NUMBER) IS
4743 SELECT MSN.serial_number,
4744 MSN.gen_object_id
4745 FROM MTL_SERIAL_NUMBERS MSN
4746 WHERE MSN.SERIAL_NUMBER IN (select wsmt.assembly_serial_number
4747 FROM WIP_SERIAL_MOVE_TRANSACTIONS WSMT
4748 WHERE WSMT.transaction_id = v_txn_id
4749 )
4750 AND MSN.current_organization_id = p_organization_id
4751 AND MSN.inventory_item_id = p_inventory_item_id
4752 --AND MSN.current_status = WIP_CONSTANTS.IN_STORES
4753 FOR UPDATE NOWAIT;
4754
4755 cursor c_undo_serial_num(v_txn_id IN NUMBER) IS
4756 SELECT MSN.serial_number,
4757 MSN.gen_object_id
4758 FROM MTL_SERIAL_NUMBERS MSN
4759 WHERE MSN.SERIAL_NUMBER IN (select wsmt.assembly_serial_number
4760 FROM WIP_SERIAL_MOVE_TRANSACTIONS WSMT
4761 WHERE WSMT.transaction_id = v_txn_id
4762 )
4763 AND MSN.current_organization_id = p_organization_id
4764 AND MSN.inventory_item_id = p_inventory_item_id
4765 --AND MSN.current_status = WIP_CONSTANTS.DEF_NOT_USED
4766 AND MSN.wip_entity_id = p_wip_entity_id
4767 FOR UPDATE NOWAIT;
4768
4769 type t_serial_txn_info_rec is RECORD
4770 ( serial_number MTL_SERIAL_NUMBERS.serial_number%TYPE,
4771 gen_object_id MTL_SERIAL_NUMBERS.gen_object_id%TYPE
4772 );
4773
4774 type t_serial_txn_info_tbl IS table of t_serial_txn_info_rec INDEX BY BINARY_INTEGER;
4775
4776 l_move_serial_num_list t_serial_txn_info_tbl;
4777 l_scrap_serial_num_list t_serial_txn_info_tbl;
4778
4779 l_wip_serial_rows_tbl t_wip_intf_tbl_type;
4780 l_index NUMBER;
4781 l_pos NUMBER;
4782
4783 -- Logging variables.....
4784 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
4785 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
4786
4787 l_stmt_num NUMBER;
4788 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.populate_undo_txn';
4789 l_param_tbl WSM_Log_PVT.param_tbl_type;
4790 -- Logging variables...
4791
4792
4793 BEGIN
4794 l_stmt_num := 10;
4795
4796 x_return_status := G_RET_SUCCESS;
4797 x_error_msg := NULL;
4798 x_error_count := 0;
4799
4800 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
4801
4802 l_param_tbl.delete;
4803 l_param_tbl(1).paramName := 'p_move_qty';
4804 l_param_tbl(1).paramValue := p_move_qty;
4805
4806 l_param_tbl(2).paramName := 'p_scrap_qty';
4807 l_param_tbl(2).paramValue := p_scrap_qty;
4808
4809 l_param_tbl(3).paramName := 'p_move_txn_type';
4810 l_param_tbl(3).paramValue := p_move_txn_type;
4811
4812 l_param_tbl(4).paramName := 'p_old_move_txn_id';
4813 l_param_tbl(4).paramValue := p_old_move_txn_id;
4814
4815 l_param_tbl(5).paramName := 'p_old_scrap_txn_id';
4816 l_param_tbl(5).paramValue := p_old_scrap_txn_id;
4817
4818 WSM_Log_PVT.logProcParams(p_module_name => l_module,
4819 p_param_tbl => l_param_tbl,
4820 p_fnd_log_level => l_log_level
4821 );
4822 END IF;
4823
4824 IF p_move_txn_type = 3 THEN -- assembly return
4825
4826 l_stmt_num := 20;
4827
4828 open c_ret_serial_num(p_old_move_txn_id);
4829 fetch c_ret_serial_num bulk collect into l_move_serial_num_list;
4830 close c_ret_serial_num;
4831
4832 ELSIF p_move_txn_type = 4 THEN -- undo txn
4833
4834 l_stmt_num := 30;
4835
4836 open c_undo_serial_num(p_old_move_txn_id);
4837 fetch c_undo_serial_num bulk collect into l_move_serial_num_list;
4838 close c_undo_serial_num;
4839
4840 END IF;
4841
4842 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4843 l_msg_tokens.delete;
4844 WSM_log_PVT.logMessage (p_module_name => l_module ,
4845 p_msg_text => 'Undo Transaction (Move): Serial Records found for p_old_move_txn_id: ' || l_move_serial_num_list.count,
4846 p_stmt_num => l_stmt_num ,
4847 p_msg_tokens => l_msg_tokens ,
4848 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4849 p_run_log_level => l_log_level
4850 );
4851 END IF;
4852
4853 l_stmt_num := 50;
4854
4855 if l_move_serial_num_list.count <> p_move_qty and
4856 p_move_qty > 0
4857 then
4858 l_stmt_num := 60;
4859 -- some of the serials are not present hence error out....
4860 IF g_log_level_error >= l_log_level OR
4861 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4862 THEN
4863
4864 l_msg_tokens.delete;
4865 WSM_log_PVT.logMessage(p_module_name => l_module ,
4866 p_msg_name => 'WSM_SERIAL_INSUFFICIENT',
4867 p_msg_appl_name => 'WSM' ,
4868 p_msg_tokens => l_msg_tokens ,
4869 p_stmt_num => l_stmt_num ,
4870 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4871 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4872 p_run_log_level => l_log_level
4873 );
4874 END IF;
4875 RAISE FND_API.G_EXC_ERROR;
4876 end if;
4877
4878 l_stmt_num := 70;
4879 IF p_move_qty > 0 THEN
4880 IF p_move_txn_type = 3 THEN -- assembly return
4881
4882 l_stmt_num := 80;
4883 open c_ret_serial_num(p_old_scrap_txn_id);
4884 fetch c_ret_serial_num bulk collect into l_scrap_serial_num_list;
4885 close c_ret_serial_num;
4886
4887 ELSIF p_move_txn_type = 4 THEN -- undo txn
4888
4889 l_stmt_num := 90;
4890 open c_undo_serial_num(p_old_scrap_txn_id);
4891 fetch c_undo_serial_num bulk collect into l_scrap_serial_num_list;
4892 close c_undo_serial_num;
4893
4894 END IF;
4895 ELSIF p_move_qty = 0 THEN
4896 -- Then we would be having only one Txn ID.. Scrap ID would be null..
4897 -- Basically this is a pure scrap case... -- So just assign the already fetched list..
4898 l_scrap_serial_num_list := l_move_serial_num_list;
4899 END IF;
4900
4901 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4902 l_msg_tokens.delete;
4903 WSM_log_PVT.logMessage (p_module_name => l_module ,
4904 p_msg_text => 'Undo Transaction (Scrap): Serial Records found : ' || l_scrap_serial_num_list.count,
4905 p_stmt_num => l_stmt_num ,
4906 p_msg_tokens => l_msg_tokens ,
4907 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4908 p_run_log_level => l_log_level
4909 );
4910 END IF;
4911
4912 l_stmt_num := 100;
4913
4914 if l_scrap_serial_num_list.count <> p_scrap_qty then
4915 l_stmt_num := 110;
4916 -- some of the serials are not present hence error out....
4917 IF g_log_level_error >= l_log_level OR
4918 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
4919 THEN
4920
4921 l_msg_tokens.delete;
4922 WSM_log_PVT.logMessage(p_module_name => l_module ,
4923 p_msg_name => 'WSM_SERIAL_INSUFFICIENT',
4924 p_msg_appl_name => 'WSM' ,
4925 p_msg_tokens => l_msg_tokens ,
4926 p_stmt_num => l_stmt_num ,
4927 p_fnd_msg_level => G_MSG_LVL_ERROR ,
4928 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
4929 p_run_log_level => l_log_level
4930 );
4931 END IF;
4932 RAISE FND_API.G_EXC_ERROR;
4933 end if;
4934
4935 l_stmt_num := 120;
4936 l_pos := 0;
4937 IF p_move_qty > 0 THEN
4938 -- This is to take care of a pure scrap transaction...
4939 l_index := l_move_serial_num_list.first;
4940
4941 while l_index is not null loop
4942
4943 l_pos := l_pos + 1;
4944
4945 l_wip_serial_rows_tbl(l_pos).assembly_serial_number := l_move_serial_num_list(l_index).serial_number;
4946 l_wip_serial_rows_tbl(l_pos).gen_object_id := l_move_serial_num_list(l_index).gen_object_id;
4947 l_wip_serial_rows_tbl(l_pos).transaction_id := p_new_move_txn_id ;
4948 l_wip_serial_rows_tbl(l_pos).LAST_UPDATE_DATE := sysdate ;
4949 l_wip_serial_rows_tbl(l_pos).LAST_UPDATED_BY := g_user_id ;
4950 l_wip_serial_rows_tbl(l_pos).CREATION_DATE := sysdate ;
4951 l_wip_serial_rows_tbl(l_pos).CREATED_BY := g_user_id ;
4952 l_wip_serial_rows_tbl(l_pos).LAST_UPDATE_LOGIN := g_user_login_id ;
4953 l_wip_serial_rows_tbl(l_pos).REQUEST_ID := g_request_id ;
4954 l_wip_serial_rows_tbl(l_pos).PROGRAM_APPLICATION_ID := g_program_appl_id ;
4955 l_wip_serial_rows_tbl(l_pos).PROGRAM_ID := g_program_id ;
4956 l_wip_serial_rows_tbl(l_pos).PROGRAM_UPDATE_DATE := sysdate ;
4957
4958 l_index := l_move_serial_num_list.next(l_index);
4959 end loop;
4960 END IF;
4961
4962 l_stmt_num := 130;
4963 l_index := l_scrap_serial_num_list.first;
4964
4965 while l_index is not null loop
4966
4967 l_pos := l_pos + 1;
4968
4969 l_wip_serial_rows_tbl(l_pos).assembly_serial_number := l_scrap_serial_num_list(l_index).serial_number;
4970 l_wip_serial_rows_tbl(l_pos).gen_object_id := l_scrap_serial_num_list(l_index).gen_object_id;
4971 l_wip_serial_rows_tbl(l_pos).transaction_id := p_new_scrap_txn_id ;
4972 l_wip_serial_rows_tbl(l_pos).LAST_UPDATE_DATE := sysdate ;
4973 l_wip_serial_rows_tbl(l_pos).LAST_UPDATED_BY := g_user_id ;
4974 l_wip_serial_rows_tbl(l_pos).CREATION_DATE := sysdate ;
4975 l_wip_serial_rows_tbl(l_pos).CREATED_BY := g_user_id ;
4976 l_wip_serial_rows_tbl(l_pos).LAST_UPDATE_LOGIN := g_user_login_id ;
4977 l_wip_serial_rows_tbl(l_pos).REQUEST_ID := g_request_id ;
4978 l_wip_serial_rows_tbl(l_pos).PROGRAM_APPLICATION_ID := g_program_appl_id ;
4979 l_wip_serial_rows_tbl(l_pos).PROGRAM_ID := g_program_id ;
4980 l_wip_serial_rows_tbl(l_pos).PROGRAM_UPDATE_DATE := sysdate ;
4981
4982 l_index := l_scrap_serial_num_list.next(l_index);
4983 end loop;
4984
4985 l_stmt_num := 140;
4986 -- obtained all the serial numbers...
4987 -- have to insert all these into wip_serial_txn_interface...
4988 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
4989 l_msg_tokens.delete;
4990 WSM_log_PVT.logMessage (p_module_name => l_module ,
4991 p_msg_text => 'Undo Transaction : Going to insert : ' || l_wip_serial_rows_tbl.count || ' records',
4992 p_stmt_num => l_stmt_num ,
4993 p_msg_tokens => l_msg_tokens ,
4994 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
4995 p_run_log_level => l_log_level
4996 );
4997 END IF;
4998
4999 forall l_counter in l_wip_serial_rows_tbl.first..l_wip_serial_rows_tbl.last
5000 insert into wip_serial_move_interface values l_wip_serial_rows_tbl(l_counter);
5001
5002 EXCEPTION
5003 WHEN FND_API.G_EXC_ERROR THEN
5004
5005 x_return_status := G_RET_ERROR;
5006 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5007 p_count => x_error_count ,
5008 p_data => x_error_msg
5009 );
5010
5011 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5012
5013 x_return_status := G_RET_UNEXPECTED;
5014
5015 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5016 p_count => x_error_count ,
5017 p_data => x_error_msg
5018 );
5019 WHEN OTHERS THEN
5020
5021 x_return_status := G_RET_UNEXPECTED;
5022
5023 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
5024 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
5025 THEN
5026 WSM_log_PVT.handle_others( p_module_name => l_module ,
5027 p_stmt_num => l_stmt_num ,
5028 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
5029 p_run_log_level => l_log_level
5030 );
5031 END IF;
5032
5033 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5034 p_count => x_error_count ,
5035 p_data => x_error_msg
5036 );
5037
5038
5039 END populate_undo_txn;
5040
5041 -- this procedure will fetch data only for split and update quantity transactions...
5042 Procedure WLT_serial_intf_proc ( p_header_id IN NUMBER,
5043 p_wip_entity_id IN NUMBER,
5044 p_wip_entity_name IN VARCHAR2,
5045 p_wlt_txn_type IN NUMBER,
5046 p_organization_id IN NUMBER,
5047 x_serial_num_tbl OUT NOCOPY WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
5048 x_return_status OUT NOCOPY VARCHAR2,
5049 x_error_msg OUT NOCOPY VARCHAR2,
5050 x_error_count OUT NOCOPY NUMBER
5051 )
5052
5053 IS
5054
5055 l_wip_entity_id NUMBER;
5056 l_inventory_item_id NUMBER;
5057
5058 l_miss_char VARCHAR2(1) := FND_API.G_MISS_CHAR;
5059 l_null_num NUMBER := FND_API.G_NULL_NUM;
5060 l_null_date DATE := FND_API.G_NULL_DATE;
5061 l_null_char VARCHAR2(1) := FND_API.G_NULL_CHAR;
5062
5063 cursor c_wlt_serials
5064 is
5065 select
5066 wsti.Serial_Number ,
5067 null ,
5068 -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id though the name is assembly_item_id)
5069 wsti.header_id , -- header_id
5070 wsti.Generate_serial_number ,
5071 wsti.Generate_for_qty ,
5072 wsti.Action_flag ,
5073 wsti.Current_wip_entity_name ,
5074 wsti.Changed_wip_entity_name ,
5075 wsti.Current_wip_entity_id ,
5076 wsti.Changed_wip_entity_id ,
5077 decode(wsti.serial_attribute_category , l_null_char, null, null, msn.serial_attribute_category, wsti.serial_attribute_category), -- serial_attribute_category
5078 decode(wsti.territory_code , l_null_char, null, null, msn.territory_code , wsti.territory_code ), -- territory_code
5079 decode(wsti.origination_date , l_null_date, null, null, msn.origination_date , wsti.origination_date ), -- origination_date
5080 decode(wsti.c_attribute1 , l_null_char, null, null, msn.c_attribute1 , wsti.c_attribute1 ), -- c_attribute1
5081 decode(wsti.c_attribute2 , l_null_char, null, null, msn.c_attribute2 , wsti.c_attribute2 ), -- c_attribute2
5082 decode(wsti.c_attribute3 , l_null_char, null, null, msn.c_attribute3 , wsti.c_attribute3 ), -- c_attribute3
5083 decode(wsti.c_attribute4 , l_null_char, null, null, msn.c_attribute4 , wsti.c_attribute4 ), -- c_attribute4
5084 decode(wsti.c_attribute5 , l_null_char, null, null, msn.c_attribute5 , wsti.c_attribute5 ), -- c_attribute5
5085 decode(wsti.c_attribute6 , l_null_char, null, null, msn.c_attribute6 , wsti.c_attribute6 ), -- c_attribute6
5086 decode(wsti.c_attribute7 , l_null_char, null, null, msn.c_attribute7 , wsti.c_attribute7 ), -- c_attribute7
5087 decode(wsti.c_attribute8 , l_null_char, null, null, msn.c_attribute8 , wsti.c_attribute8 ), -- c_attribute8
5088 decode(wsti.c_attribute9 , l_null_char, null, null, msn.c_attribute9 , wsti.c_attribute9 ), -- c_attribute9
5089 decode(wsti.c_attribute10 , l_null_char, null, null, msn.c_attribute10 , wsti.c_attribute10 ), -- c_attribute10
5090 decode(wsti.c_attribute11 , l_null_char, null, null, msn.c_attribute11 , wsti.c_attribute11 ), -- c_attribute11
5091 decode(wsti.c_attribute12 , l_null_char, null, null, msn.c_attribute12 , wsti.c_attribute12 ), -- c_attribute12
5092 decode(wsti.c_attribute13 , l_null_char, null, null, msn.c_attribute13 , wsti.c_attribute13 ), -- c_attribute13
5093 decode(wsti.c_attribute14 , l_null_char, null, null, msn.c_attribute14 , wsti.c_attribute14 ), -- c_attribute14
5094 decode(wsti.c_attribute15 , l_null_char, null, null, msn.c_attribute15 , wsti.c_attribute15 ), -- c_attribute15
5095 decode(wsti.c_attribute16 , l_null_char, null, null, msn.c_attribute16 , wsti.c_attribute16 ), -- c_attribute16
5096 decode(wsti.c_attribute17 , l_null_char, null, null, msn.c_attribute17 , wsti.c_attribute17 ), -- c_attribute17
5097 decode(wsti.c_attribute18 , l_null_char, null, null, msn.c_attribute18 , wsti.c_attribute18 ), -- c_attribute18
5098 decode(wsti.c_attribute19 , l_null_char, null, null, msn.c_attribute19 , wsti.c_attribute19 ), -- c_attribute19
5099 decode(wsti.c_attribute20 , l_null_char, null, null, msn.c_attribute20 , wsti.c_attribute20 ), -- c_attribute20
5100 decode(wsti.d_attribute1 , l_null_date, null, null, msn.d_attribute1 , wsti.d_attribute1 ), -- d_attribute1
5101 decode(wsti.d_attribute2 , l_null_date, null, null, msn.d_attribute2 , wsti.d_attribute2 ), -- d_attribute2
5102 decode(wsti.d_attribute3 , l_null_date, null, null, msn.d_attribute3 , wsti.d_attribute3 ), -- d_attribute3
5103 decode(wsti.d_attribute4 , l_null_date, null, null, msn.d_attribute4 , wsti.d_attribute4 ), -- d_attribute4
5104 decode(wsti.d_attribute5 , l_null_date, null, null, msn.d_attribute5 , wsti.d_attribute5 ), -- d_attribute5
5105 decode(wsti.d_attribute6 , l_null_date, null, null, msn.d_attribute6 , wsti.d_attribute6 ), -- d_attribute6
5106 decode(wsti.d_attribute7 , l_null_date, null, null, msn.d_attribute7 , wsti.d_attribute7 ), -- d_attribute7
5107 decode(wsti.d_attribute8 , l_null_date, null, null, msn.d_attribute8 , wsti.d_attribute8 ), -- d_attribute8
5108 decode(wsti.d_attribute9 , l_null_date, null, null, msn.d_attribute9 , wsti.d_attribute9 ), -- d_attribute9
5109 decode(wsti.d_attribute10 , l_null_date, null, null, msn.d_attribute10 , wsti.d_attribute10 ), -- d_attribute10
5110 decode(wsti.n_attribute1 , l_null_num , null, null, msn.n_attribute1 , wsti.n_attribute1 ), -- n_attribute1
5111 decode(wsti.n_attribute2 , l_null_num , null, null, msn.n_attribute2 , wsti.n_attribute2 ), -- n_attribute2
5112 decode(wsti.n_attribute3 , l_null_num , null, null, msn.n_attribute3 , wsti.n_attribute3 ), -- n_attribute3
5113 decode(wsti.n_attribute4 , l_null_num , null, null, msn.n_attribute4 , wsti.n_attribute4 ), -- n_attribute4
5114 decode(wsti.n_attribute5 , l_null_num , null, null, msn.n_attribute5 , wsti.n_attribute5 ), -- n_attribute5
5115 decode(wsti.n_attribute6 , l_null_num , null, null, msn.n_attribute6 , wsti.n_attribute6 ), -- n_attribute6
5116 decode(wsti.n_attribute7 , l_null_num , null, null, msn.n_attribute7 , wsti.n_attribute7 ), -- n_attribute7
5117 decode(wsti.n_attribute8 , l_null_num , null, null, msn.n_attribute8 , wsti.n_attribute8 ), -- n_attribute8
5118 decode(wsti.n_attribute9 , l_null_num , null, null, msn.n_attribute9 , wsti.n_attribute9 ), -- n_attribute9
5119 decode(wsti.n_attribute10 , l_null_num , null, null, msn.n_attribute10 , wsti.n_attribute10 ), -- n_attribute10
5120 decode(wsti.status_id , l_null_num , null, null, msn.status_id , wsti.status_id ), -- status_id
5121 decode(wsti.time_since_new , l_null_num , null, null, msn.time_since_new , wsti.time_since_new ), -- time_since_new
5122 decode(wsti.cycles_since_new , l_null_num , null, null, msn.cycles_since_new , wsti.cycles_since_new ), -- cycles_since_new
5123 decode(wsti.time_since_overhaul , l_null_num , null, null, msn.time_since_overhaul , wsti.time_since_overhaul ), -- time_since_overhaul
5124 decode(wsti.cycles_since_overhaul , l_null_num , null, null, msn.cycles_since_overhaul , wsti.cycles_since_overhaul ), -- cycles_since_overhaul
5125 decode(wsti.time_since_repair , l_null_num , null, null, msn.time_since_repair , wsti.time_since_repair ), -- time_since_repair
5126 decode(wsti.cycles_since_repair , l_null_num , null, null, msn.cycles_since_repair , wsti.cycles_since_repair ), -- cycles_since_repair
5127 decode(wsti.time_since_visit , l_null_num , null, null, msn.time_since_visit , wsti.time_since_visit ), -- time_since_visit
5128 decode(wsti.cycles_since_visit , l_null_num , null, null, msn.cycles_since_visit , wsti.cycles_since_visit ), -- cycles_since_visit
5129 decode(wsti.time_since_mark , l_null_num , null, null, msn.time_since_mark , wsti.time_since_mark ), -- time_since_mark
5130 decode(wsti.cycles_since_mark , l_null_num , null, null, msn.cycles_since_mark , wsti.cycles_since_mark ), -- cycles_since_mark
5131 decode(wsti.number_of_repairs , l_null_num , null, null, msn.number_of_repairs , wsti.number_of_repairs ), -- number_of_repairs
5132 decode(wsti.attribute_category , l_null_char, l_miss_char , null ,msn.attribute_category ,wsti.attribute_category ),
5133 decode(wsti.attribute1 , l_null_char ,l_miss_char , wsti.attribute1 ),
5134 decode(wsti.attribute2 , l_null_char ,l_miss_char , wsti.attribute2 ),
5135 decode(wsti.attribute3 , l_null_char ,l_miss_char , wsti.attribute3 ),
5136 decode(wsti.attribute4 , l_null_char ,l_miss_char , wsti.attribute4 ),
5137 decode(wsti.attribute5 , l_null_char ,l_miss_char , wsti.attribute5 ),
5138 decode(wsti.attribute6 , l_null_char ,l_miss_char , wsti.attribute6 ),
5139 decode(wsti.attribute7 , l_null_char ,l_miss_char , wsti.attribute7 ),
5140 decode(wsti.attribute8 , l_null_char ,l_miss_char , wsti.attribute8 ),
5141 decode(wsti.attribute9 , l_null_char ,l_miss_char , wsti.attribute9 ),
5142 decode(wsti.attribute10 , l_null_char ,l_miss_char , wsti.attribute10 ),
5143 decode(wsti.attribute11 , l_null_char ,l_miss_char , wsti.attribute11 ),
5144 decode(wsti.attribute12 , l_null_char ,l_miss_char , wsti.attribute12 ),
5145 decode(wsti.attribute13 , l_null_char ,l_miss_char , wsti.attribute13 ),
5146 decode(wsti.attribute14 , l_null_char ,l_miss_char , wsti.attribute14 ),
5147 decode(wsti.attribute15 , l_null_char ,l_miss_char , wsti.attribute15 )
5148 from wsm_serial_txn_interface wsti,
5149 mtl_serial_numbers msn
5150 where header_id = p_header_id
5151 and transaction_type_id = 3
5152 and wsti.serial_number = msn.serial_number (+)
5153 and msn.inventory_item_id (+) = l_inventory_item_id
5154 and msn.current_organization_id (+) = p_organization_id
5155 order by nvl(wsti.action_flag,0) desc; -- Code review remark
5156 -- first process Delete and then add
5157
5158 -- Logging variables.....
5159 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5160 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5161
5162 l_stmt_num NUMBER;
5163 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.WLT_serial_intf_proc';
5164 l_param_tbl WSM_Log_PVT.param_tbl_type;
5165 -- Logging variables...
5166
5167 BEGIN
5168
5169 l_stmt_num := 10;
5170 x_return_status := G_RET_SUCCESS;
5171 x_error_msg := NULL;
5172 x_error_count := 0;
5173
5174 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
5175 l_stmt_num := 15;
5176 l_param_tbl.delete;
5177 l_param_tbl(1).paramName := 'p_wip_entity_id';
5178 l_param_tbl(1).paramValue := p_wip_entity_id;
5179
5180 l_param_tbl(2).paramName := 'p_wip_entity_name';
5181 l_param_tbl(2).paramValue := p_wip_entity_name;
5182
5183 l_param_tbl(3).paramName := 'p_organization_id';
5184 l_param_tbl(3).paramValue := p_organization_id;
5185
5186 l_param_tbl(4).paramName := 'p_header_id';
5187 l_param_tbl(4).paramValue := p_header_id;
5188
5189 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
5190 p_param_tbl => l_param_tbl,
5191 p_fnd_log_level => l_log_level
5192 );
5193 END IF;
5194
5195 if p_wlt_txn_type = (WSMPCNST.SPLIT) THEN -- check for the correctness..
5196
5197 IF p_wip_entity_id IS NULL THEN
5198 l_stmt_num := 20;
5199 BEGIN
5200 -- These two can cause error...
5201 select we.wip_entity_id,wdj.primary_item_id
5202 into l_wip_entity_id,l_inventory_item_id
5203 from wip_entities we,
5204 wip_discrete_jobs wdj
5205 where we.wip_entity_name = p_wip_entity_name
5206 and we.wip_entity_id = wdj.wip_entity_id
5207 and we.organization_id = p_organization_id;
5208
5209 -- SELECT max(operation_seq_num)
5210 -- INTO l_op_seq_num
5211 -- FROM wip_operations
5212 -- WHERE wip_entity_id = p_wip_entity_id
5213 -- AND (quantity_in_queue <> 0
5214 -- OR quantity_waiting_to_move <> 0
5215 -- );
5216
5217 EXCEPTION
5218 WHEN NO_DATA_FOUND THEN
5219 IF g_log_level_error >= l_log_level OR
5220 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5221 THEN
5222
5223 l_msg_tokens.delete;
5224 l_msg_tokens(1).TokenName := 'FLD_NAME';
5225 l_msg_tokens(1).TokenValue := 'Wip Entity Name';
5226 WSM_log_PVT.logMessage(p_module_name => l_module ,
5227 p_msg_name => 'WSM_INVALID_FIELD',
5228 p_msg_appl_name => 'WSM' ,
5229 p_msg_tokens => l_msg_tokens ,
5230 p_stmt_num => l_stmt_num ,
5231 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5232 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5233 p_run_log_level => l_log_level
5234 );
5235 END IF;
5236 RAISE FND_API.G_EXC_ERROR;
5237 END;
5238 ELSE
5239 l_stmt_num := 30;
5240 BEGIN
5241 -- These two can cause error...
5242 select we.wip_entity_id,wdj.primary_item_id
5243 into l_wip_entity_id,l_inventory_item_id
5244 from wip_entities we,
5245 wip_discrete_jobs wdj
5246 where we.wip_entity_name = nvl(p_wip_entity_name,we.wip_entity_name)
5247 and we.wip_entity_id = wdj.wip_entity_id
5248 and we.wip_entity_id = p_wip_entity_id
5249 and we.organization_id = p_organization_id;
5250
5251 l_stmt_num := 35;
5252
5253 -- SELECT max(operation_seq_num)
5254 -- INTO l_op_seq_num
5255 -- FROM wip_operations
5256 -- WHERE wip_entity_id = p_wip_entity_id
5257 -- AND (quantity_in_queue <> 0
5258 -- OR quantity_waiting_to_move <> 0
5259 -- );
5260
5261 EXCEPTION
5262 WHEN NO_DATA_FOUND THEN
5263 IF g_log_level_error >= l_log_level OR
5264 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5265 THEN
5266
5267 l_msg_tokens.delete;
5268 l_msg_tokens(1).TokenName := 'FLD_NAME';
5269 l_msg_tokens(1).TokenValue := 'Wip Entity Name/Wip entity ID';
5270 WSM_log_PVT.logMessage(p_module_name => l_module ,
5271 p_msg_name => 'WSM_INVALID_FIELD' ,
5272 p_msg_appl_name => 'WSM' ,
5273 p_msg_tokens => l_msg_tokens ,
5274 p_stmt_num => l_stmt_num ,
5275 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5276 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5277 p_run_log_level => l_log_level
5278 );
5279 END IF;
5280 RAISE FND_API.G_EXC_ERROR;
5281 END;
5282 END IF;
5283
5284 l_stmt_num := 40;
5285
5286 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5287 l_msg_tokens.delete;
5288 WSM_log_PVT.logMessage (p_module_name => l_module ,
5289 p_msg_text => 'l_wip_entity_id : ' || l_wip_entity_id || ' l_inventory_item_id : ' || l_inventory_item_id,
5290 p_stmt_num => l_stmt_num ,
5291 p_msg_tokens => l_msg_tokens ,
5292 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
5293 p_run_log_level => l_log_level
5294 );
5295 END IF;
5296
5297 update wsm_serial_txn_interface wsti
5298 set wsti.process_status = wip_constants.error
5299 where wsti.header_id = p_header_id
5300 and wsti.transaction_type_id = 3
5301 and serial_number not in ( SELECT MSN.serial_number
5302 FROM MTL_SERIAL_NUMBERS MSN
5303 WHERE MSN.wip_entity_id = l_wip_entity_id
5304 AND MSN.current_organization_id = p_organization_id
5305 AND MSN.inventory_item_id = l_inventory_item_id
5306 -- AND MSN.current_status = WIP_CONSTANTS.IN_STORES
5307 -- AND MSN.operation_seq_num = l_op_seq_num
5308 -- AND MSN.intraoperation_step_type = p_curr_job_intraop_step < not required...>
5309 AND nvl(MSN.intraoperation_step_type,-1) <> 5
5310 );
5311
5312 if SQL%ROWCOUNT > 0 then
5313 -- Error out..
5314 IF g_log_level_error >= l_log_level OR
5315 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5316 THEN
5317
5318 l_msg_tokens.delete;
5319 WSM_log_PVT.logMessage(p_module_name => l_module ,
5320 p_msg_name => 'WSM_INVALID_SERIALS_SUPPLIED',
5321 p_msg_appl_name => 'WSM' ,
5322 p_msg_tokens => l_msg_tokens ,
5323 p_stmt_num => l_stmt_num ,
5324 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5325 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5326 p_run_log_level => l_log_level
5327 );
5328 END IF;
5329 RAISE FND_API.G_EXC_ERROR;
5330 end if;
5331
5332 l_stmt_num := 50;
5333 open c_wlt_serials;
5334 fetch c_wlt_serials
5335 bulk collect into x_serial_num_tbl;
5336 close c_wlt_serials;
5337
5338 elsif p_wlt_txn_type = (WSMPCNST.UPDATE_QUANTITY) THEN
5339
5340 l_stmt_num := 60;
5341 update wsm_serial_txn_interface wsti
5342 set wsti.process_status = wip_constants.error
5343 where wsti.header_id = p_header_id
5344 and wsti.transaction_type_id = 3
5345 and action_flag not in (WSM_GASSOC_SERIAL_NUM,WSM_ADD_SERIAL_NUM);
5346
5347
5348 if SQL%ROWCOUNT > 0 then
5349 -- Error out..
5350 IF g_log_level_error >= l_log_level OR
5351 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5352 THEN
5353
5354 l_msg_tokens.delete;
5355 l_msg_tokens(1).TokenName := 'FLD_NAME';
5356 l_msg_tokens(1).TokenValue := 'Action flag for Update Quantity transaction';
5357 WSM_log_PVT.logMessage(p_module_name => l_module ,
5358 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
5359 p_msg_appl_name => 'WSM' ,
5360 p_msg_tokens => l_msg_tokens ,
5361 p_stmt_num => l_stmt_num ,
5362 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5363 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5364 p_run_log_level => l_log_level
5365 );
5366 END IF;
5367 RAISE FND_API.G_EXC_ERROR;
5368 end if;
5369
5370 l_stmt_num := 70;
5371 -- just fetch the data...
5372 open c_wlt_serials;
5373 fetch c_wlt_serials
5374 bulk collect into x_serial_num_tbl;
5375 close c_wlt_serials;
5376
5377 l_stmt_num := 80;
5378 end if;
5379 EXCEPTION
5380
5381 WHEN FND_API.G_EXC_ERROR THEN
5382
5383 x_return_status := G_RET_ERROR;
5384 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5385 p_count => x_error_count ,
5386 p_data => x_error_msg
5387 );
5388
5389 WHEN OTHERS THEN
5390
5391 x_return_status := G_RET_UNEXPECTED;
5392
5393 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
5394 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
5395 THEN
5396 WSM_log_PVT.handle_others( p_module_name => l_module ,
5397 p_stmt_num => l_stmt_num ,
5398 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
5399 p_run_log_level => l_log_level
5400 );
5401 END IF;
5402
5403 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5404 p_count => x_error_count ,
5405 p_data => x_error_msg
5406 );
5407 END WLT_serial_intf_proc;
5408
5409 Procedure fetch_wlt_serials ( p_new_job_name IN VARCHAR2 ,
5410 p_split_txn_job_id IN NUMBER ,
5411 p_serial_num_tbl IN OUT NOCOPY WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
5412 x_return_status OUT NOCOPY VARCHAR2 ,
5413 x_error_msg OUT NOCOPY VARCHAR2 ,
5414 x_error_count OUT NOCOPY NUMBER
5415 )
5416
5417 IS
5418
5419 CURSOR c_job_serials IS
5420 select serial_number
5421 from mtl_serial_numbers MSN,
5422 wip_discrete_jobs WDJ
5423 where MSN.inventory_item_id = WDJ.primary_item_id
5424 and MSN.wip_entity_id = p_split_txn_job_id
5425 and MSN.current_organization_id = WDJ.organization_id
5426 and WDJ.wip_entity_id = p_split_txn_job_id
5427 and nvl(MSN.intraoperation_step_type,-1) <> 5;
5428
5429
5430 type t_serial_tbl IS table of number INDEX by MTL_SERIAL_NUMBERS.SERIAL_NUMBER%TYPE;
5431 l_serial_list t_serial_tbl;
5432
5433 l_job_serials t_varchar2;
5434 l_index NUMBER;
5435 l_sindex NUMBER;
5436 l_new_index NUMBER;
5437
5438 -- Logging variables.....
5439 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5440 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5441
5442 l_stmt_num NUMBER;
5443 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.fetch_wlt_serials';
5444 l_param_tbl WSM_Log_PVT.param_tbl_type;
5445 -- Logging variables...
5446
5447
5448 BEGIN
5449 l_stmt_num := 10;
5450
5451 x_return_status := G_RET_SUCCESS;
5452 x_error_msg := NULL;
5453 x_error_count := 0;
5454
5455 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5456 l_msg_tokens.delete;
5457 WSM_log_PVT.logMessage (p_module_name => l_module ,
5458 p_msg_text => 'Inside fetch_wlt_serials',
5459 p_stmt_num => l_stmt_num ,
5460 p_msg_tokens => l_msg_tokens ,
5461 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
5462 p_run_log_level => l_log_level
5463 );
5464 END IF;
5465
5466 l_stmt_num := 15;
5467
5468 l_index := p_serial_num_tbl.first;
5469 while l_index is not null loop
5470 l_serial_list(p_serial_num_tbl(l_index).serial_number) := 1;
5471 l_index := p_serial_num_tbl.next(l_index);
5472 end loop;
5473
5474 open c_job_serials;
5475 fetch c_job_serials
5476 bulk collect into l_job_serials;
5477 close c_job_serials;
5478
5479 l_sindex := l_job_serials.first;
5480 while (l_sindex IS NOT NULL) loop
5481 IF NOT(l_serial_list.exists(l_job_serials(l_sindex))) THEN
5482 -- Add to the list...
5483 l_new_index := p_serial_num_tbl.count + 1;
5484 p_serial_num_tbl(l_new_index).serial_number := l_job_serials(l_sindex);
5485 p_serial_num_tbl(l_new_index).Changed_wip_entity_name := p_new_job_name;
5486 END IF;
5487 l_sindex := l_job_serials.next(l_sindex);
5488 end loop;
5489
5490 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5491 l_msg_tokens.delete;
5492 WSM_log_PVT.logMessage (p_module_name => l_module ,
5493 p_msg_text => 'Inside fetch_wlt_serials : Serial Numbers count : ' || p_serial_num_tbl.count,
5494 p_stmt_num => l_stmt_num ,
5495 p_msg_tokens => l_msg_tokens ,
5496 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
5497 p_run_log_level => l_log_level
5498 );
5499 END IF;
5500
5501 EXCEPTION
5502 WHEN OTHERS THEN
5503
5504 x_return_status := G_RET_UNEXPECTED;
5505
5506 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
5507 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
5508 THEN
5509 WSM_log_PVT.handle_others( p_module_name => l_module ,
5510 p_stmt_num => l_stmt_num ,
5511 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
5512 p_run_log_level => l_log_level
5513 );
5514 END IF;
5515
5516 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5517 p_count => x_error_count ,
5518 p_data => x_error_msg
5519 );
5520
5521 END fetch_wlt_serials;
5522
5523 -- Insert records into WSM_SERIAL_TRANSACTIONS for WIP Lot Transactions...
5524 -- This procedure will be called for all wip lot transactions other than split and merge...
5525 Procedure Insert_into_WST ( p_transaction_id IN NUMBER ,
5526 p_transaction_type_id IN NUMBER ,
5527 p_old_wip_entity_name IN VARCHAR2 ,
5528 p_new_wip_entity_name IN VARCHAR2 ,
5529 p_organization_id IN NUMBER ,
5530 p_item_id IN NUMBER ,
5531 p_wip_entity_id IN NUMBER ,
5532 x_return_status OUT NOCOPY VARCHAR2 ,
5533 x_error_msg OUT NOCOPY VARCHAR2 ,
5534 x_error_count OUT NOCOPY NUMBER
5535 )
5536 IS
5537
5538 -- Logging variables.....
5539 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5540 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5541
5542 l_stmt_num NUMBER;
5543 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Insert_into_WST';
5544 l_param_tbl WSM_Log_PVT.param_tbl_type;
5545 -- Logging variables...
5546
5547 BEGIN
5548 l_stmt_num := 10;
5549
5550 x_return_status := G_RET_SUCCESS;
5551 x_error_msg := NULL;
5552 x_error_count := 0;
5553
5554 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
5555 l_stmt_num := 15;
5556 l_param_tbl.delete;
5557 l_param_tbl(1).paramName := 'p_transaction_type_id';
5558 l_param_tbl(1).paramValue := p_transaction_type_id;
5559
5560 l_param_tbl(2).paramName := 'p_old_wip_entity_name';
5561 l_param_tbl(2).paramValue := p_old_wip_entity_name;
5562
5563 l_param_tbl(3).paramName := 'p_new_wip_entity_name';
5564 l_param_tbl(3).paramValue := p_new_wip_entity_name;
5565
5566 l_param_tbl(4).paramName := 'p_transaction_id';
5567 l_param_tbl(4).paramValue := p_transaction_id;
5568
5569 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
5570 p_param_tbl => l_param_tbl,
5571 p_fnd_log_level => l_log_level
5572 );
5573 END IF;
5574
5575 l_stmt_num := 20;
5576 -- Check for the transaction type...
5577 insert into wsm_serial_transactions
5578 (transaction_id ,
5579 transaction_type_id ,
5580 serial_number ,
5581 gen_object_id ,
5582 current_wip_entity_name ,
5583 changed_wip_entity_name ,
5584 current_wip_entity_id ,
5585 changed_wip_entity_id ,
5586 created_by ,
5587 last_update_date ,
5588 last_updated_by ,
5589 creation_date ,
5590 last_update_login ,
5591 request_id ,
5592 program_application_id ,
5593 program_id ,
5594 program_update_date ,
5595 original_system_reference
5596 )
5597 select
5598 p_transaction_id ,
5599 3 ,
5600 MSN.serial_number ,
5601 MSN.gen_object_id ,
5602 p_old_wip_entity_name ,
5603 p_new_wip_entity_name ,
5604 p_wip_entity_id ,
5605 p_wip_entity_id ,
5606 g_user_id ,
5607 sysdate ,
5608 g_user_id ,
5609 sysdate ,
5610 g_user_login_id ,
5611 g_request_id ,
5612 g_program_appl_id ,
5613 g_program_id ,
5614 sysdate ,
5615 null
5616 from mtl_serial_numbers MSN
5617 where MSN.current_organization_id = p_organization_id
5618 and MSN.inventory_item_id = p_item_id
5619 and MSN.wip_entity_id = p_wip_entity_id
5620 and nvl(MSN.intraoperation_step_type,-1) <> 5;
5621
5622
5623 EXCEPTION
5624
5625 WHEN OTHERS THEN
5626
5627 x_return_status := G_RET_UNEXPECTED;
5628
5629 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
5630 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
5631 THEN
5632 WSM_log_PVT.handle_others( p_module_name => l_module ,
5633 p_stmt_num => l_stmt_num ,
5634 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
5635 p_run_log_level => l_log_level
5636 );
5637 END IF;
5638
5639 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
5640 p_count => x_error_count ,
5641 p_data => x_error_msg
5642 );
5643 END Insert_into_WST;
5644
5645 -- WIP Lot transactions processor...
5646
5647 Procedure WLT_serial_processor ( p_calling_mode IN NUMBER,
5648 p_wlt_txn_type IN NUMBER,
5649 p_organization_id IN NUMBER,
5650 p_txn_id IN NUMBER,
5651 p_starting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_STARTING_JOBS_TBL_TYPE,
5652 p_resulting_jobs_tbl IN WSM_WIP_LOT_TXN_PVT.WLTX_RESULTING_JOBS_TBL_TYPE,
5653 p_serial_num_tbl IN OUT NOCOPY WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL,
5654 x_return_status OUT NOCOPY VARCHAR2,
5655 x_error_msg OUT NOCOPY VARCHAR2,
5656 x_error_count OUT NOCOPY NUMBER
5657 )
5658
5659 IS
5660
5661 type t_jser_info_rec_type is record
5662 (
5663 l_index_start NUMBER,
5664 l_count NUMBER
5665 );
5666
5667
5668 type t_jser_info_tbl_type is table of t_jser_info_rec_type index by WIP_ENTITIES.wip_entity_name%type;
5669 type t_job_name_tbl_type is table of NUMBER index by WIP_ENTITIES.wip_entity_name%type;
5670
5671 l_job_ser_info_tbl t_jser_info_tbl_type;
5672 l_res_job_tbl t_job_name_tbl_type;
5673
5674 l_wip_entity_name VARCHAR2(80);
5675 l_wip_entity_id NUMBER;
5676 l_inventory_item_id NUMBER;
5677 l_curr_job_op_seq_num NUMBER;
5678 l_curr_job_op_step NUMBER;
5679
5680 -- To be passed to the new INV API...
5681 l_validation_status VARCHAR2(10);
5682
5683 l_index NUMBER;
5684 l_clear_serial_attr NUMBER;
5685 l_update_serial_attr NUMBER;
5686 l_return_status VARCHAR2(1);
5687 l_msg_count NUMBER;
5688 l_msg_data VARCHAR2(2000);
5689 l_serial_start_flag NUMBER;
5690 l_index1 NUMBER;
5691 l_index2 NUMBER;
5692 l_serial_ctrl_code NUMBER;
5693 l_first_serial_txn_id NUMBER;
5694 l_start_quantity NUMBER;
5695
5696 l_parent_job_ser_context MTL_SERIAL_NUMBERS.SERIAL_ATTRIBUTE_CATEGORY%type;
5697 l_child_job_ser_context MTL_SERIAL_NUMBERS.SERIAL_ATTRIBUTE_CATEGORY%type;
5698 l_context MTL_SERIAL_NUMBERS.SERIAL_ATTRIBUTE_CATEGORY%type;
5699
5700 l_temp_rec WSM_Serial_Support_GRP.WSM_SERIAL_NUM_REC;
5701 l_start_as_res_job NUMBER;
5702 l_serial_start_op NUMBER;
5703 l_serial_num_count NUMBER;
5704 l_rep_job_index NUMBER;
5705 l_old_start_index NUMBER;
5706 l_count NUMBER;
5707 l_serial_tbl t_varchar2;
5708 l_op_seq_incr NUMBER;
5709
5710 l_temp_op_seq_num NUMBER;
5711 l_temp_op_step NUMBER;
5712
5713 -- This is the job against which the left over serial numbers of the parent job will be assigned...
5714 l_filling_job_name WIP_ENTITIES.wip_entity_name%type := null;
5715 l_parent_as_resjob NUMBER := null;
5716 l_old_count NUMBER;
5717 l_new_count NUMBER;
5718 l_temp_job WIP_ENTITIES.wip_entity_name%TYPE; -- Used for debugging..
5719 l_index_job_name WIP_ENTITIES.wip_entity_name%TYPE;
5720 l_move_flag VARCHAR2(1) := 'N';
5721 l_curr_job_name WIP_ENTITIES.wip_entity_name%TYPE;
5722
5723 CURSOR c_job_serials(v_wip_entity_id IN NUMBER,v_item_id IN NUMBER)
5724 IS SELECT msn.serial_number
5725 FROM MTL_SERIAL_NUMBERS MSN
5726 WHERE msn.wip_entity_id = v_wip_entity_id
5727 AND msn.inventory_item_id = v_item_id
5728 AND nvl(msn.INTRAOPERATION_STEP_TYPE,-1) <> WIP_CONSTANTS.SCRAP
5729 AND msn.current_organization_id = p_organization_id;
5730
5731 -- Logging variables.....
5732 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
5733 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5734
5735 l_stmt_num NUMBER;
5736 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.WLT_serial_processor';
5737 l_param_tbl WSM_Log_PVT.param_tbl_type;
5738 -- Logging variables...
5739
5740 BEGIN
5741 l_stmt_num := 10;
5742
5743 SAVEPOINT WLT_serial_proc;
5744
5745 x_return_status := G_RET_SUCCESS;
5746 x_error_msg := NULL;
5747 x_error_count := 0;
5748
5749 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
5750
5751 l_param_tbl.delete;
5752 l_param_tbl(1).paramName := 'p_calling_mode';
5753 l_param_tbl(1).paramValue := p_calling_mode;
5754
5755 l_param_tbl(2).paramName := 'p_organization_id';
5756 l_param_tbl(2).paramValue := p_organization_id;
5757
5758 l_param_tbl(3).paramName := 'p_txn_id';
5759 l_param_tbl(3).paramValue := p_txn_id;
5760
5761 l_param_tbl(4).paramName := 'p_serial_num_tbl.count';
5762 l_param_tbl(4).paramValue := p_serial_num_tbl.count;
5763
5764 l_param_tbl(5).paramName := 'p_wlt_txn_type';
5765 l_param_tbl(5).paramValue := p_wlt_txn_type;
5766
5767 WSM_Log_PVT.logProcParams(p_module_name => l_module,
5768 p_param_tbl => l_param_tbl,
5769 p_fnd_log_level => l_log_level
5770 );
5771 END IF;
5772
5773 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5774 l_stmt_num := 15;
5775 -- Procedure to dump the serial records' data....
5776 log_serial_data ( p_serial_num_tbl => p_serial_num_tbl ,
5777 x_return_status => x_return_status ,
5778 x_error_msg => x_error_msg ,
5779 x_error_count => x_error_count
5780 );
5781 if x_return_status <> G_RET_SUCCESS then
5782 IF x_return_status = G_RET_ERROR THEN
5783 raise FND_API.G_EXC_ERROR;
5784 ELSIF x_return_status = G_RET_UNEXPECTED THEN
5785 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5786 END IF;
5787 end if;
5788 END IF;
5789
5790 l_stmt_num := 20;
5791 IF p_wlt_txn_type = WSMPCNST.MERGE THEN
5792 l_index := p_starting_jobs_tbl.first;
5793
5794 l_stmt_num := 25;
5795 while l_index is not null loop
5796 if p_starting_jobs_tbl(l_index).representative_flag = 'Y' then
5797 l_rep_job_index := l_index;
5798 exit;
5799 end if;
5800 l_index := p_starting_jobs_tbl.next(l_index);
5801 end loop;
5802
5803 ELSIF p_wlt_txn_type = WSMPCNST.BONUS THEN
5804 return;
5805 ELSE
5806 l_rep_job_index := p_starting_jobs_tbl.first;
5807 END IF;
5808
5809 l_stmt_num := 30;
5810 l_wip_entity_id := p_starting_jobs_tbl(l_rep_job_index).wip_entity_id;
5811 l_inventory_item_id := p_starting_jobs_tbl(l_rep_job_index).primary_item_id;
5812 l_wip_entity_name := p_starting_jobs_tbl(l_rep_job_index).wip_entity_name;
5813
5814 -- l_curr_job_op_seq_num := p_starting_jobs_tbl(l_rep_job_index).operation_seq_num;
5815 -- l_curr_job_op_step := p_starting_jobs_tbl(l_rep_job_index).intraoperation_step;
5816 l_start_quantity := p_starting_jobs_tbl(l_rep_job_index).quantity_available;
5817
5818 get_serial_track_info ( p_serial_item_id => l_inventory_item_id ,
5819 p_organization_id => p_organization_id ,
5820 p_wip_entity_id => l_wip_entity_id ,
5821 x_serial_start_flag => l_serial_start_flag ,
5822 x_serial_ctrl_code => l_serial_ctrl_code ,
5823 x_first_serial_txn_id => l_first_serial_txn_id ,
5824 x_serial_start_op => l_serial_start_op ,
5825 x_return_status => x_return_status ,
5826 x_error_msg => x_error_msg ,
5827 x_error_count => x_error_count
5828 );
5829
5830 if x_return_status <> G_RET_SUCCESS then
5831 IF x_return_status = G_RET_ERROR THEN
5832 raise FND_API.G_EXC_ERROR;
5833 ELSIF x_return_status = G_RET_UNEXPECTED THEN
5834 raise FND_API.G_EXC_UNEXPECTED_ERROR;
5835 END IF;
5836 end if;
5837
5838 IF l_serial_start_flag IS NOT NULL THEN
5839
5840 select nvl(op_seq_num_increment, 10)
5841 into l_op_seq_incr
5842 from wsm_parameters
5843 where organization_id = p_organization_id;
5844
5845 IF p_wlt_txn_type IN (WSMPCNST.UPDATE_ASSEMBLY,WSMPCNST.UPDATE_ROUTING) THEN
5846 l_curr_job_op_seq_num := p_starting_jobs_tbl(l_rep_job_index).operation_seq_num + l_op_seq_incr;
5847 l_curr_job_op_step := WIP_CONSTANTS.QUEUE;
5848 ELSE
5849 l_curr_job_op_seq_num := p_starting_jobs_tbl(l_rep_job_index).operation_seq_num;
5850 l_curr_job_op_step := p_starting_jobs_tbl(l_rep_job_index).intraoperation_step;
5851 END IF;
5852
5853 ELSE
5854 l_curr_job_op_seq_num := null;
5855 l_curr_job_op_step := null;
5856 END IF;
5857
5858 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5859 l_msg_tokens.delete;
5860 WSM_log_PVT.logMessage (p_module_name => l_module ,
5861 p_msg_text => 'l_curr_job_op_seq_num : ' || l_curr_job_op_seq_num
5862 || ' l_curr_job_op_step : ' || l_curr_job_op_step
5863 || ' p_serial_num_tbl.count ' || p_serial_num_tbl.count,
5864 p_stmt_num => l_stmt_num ,
5865 p_msg_tokens => l_msg_tokens ,
5866 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
5867 p_run_log_level => l_log_level
5868 );
5869 END IF;
5870
5871 l_stmt_num := 40;
5872 if l_serial_ctrl_code <> 2 then
5873
5874 -- Populate a warning message and return...
5875 IF p_serial_num_tbl.count <> 0 then
5876 l_stmt_num := 45;
5877 -- error out...
5878 IF g_log_level_error >= l_log_level OR
5879 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5880 THEN
5881
5882 l_msg_tokens.delete;
5883 WSM_log_PVT.logMessage(p_module_name => l_module ,
5884 p_msg_name => 'WSM_INVLAID_SERIAL_INFO',
5885 p_msg_appl_name => 'WSM' ,
5886 p_stmt_num => l_stmt_num ,
5887 p_msg_tokens => l_msg_tokens ,
5888 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5889 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5890 p_run_log_level => l_log_level
5891 );
5892 END IF;
5893 RAISE FND_API.G_EXC_ERROR;
5894 END IF;
5895 RETURN;
5896 end if;
5897
5898 l_stmt_num := 50;
5899 IF p_wlt_txn_type = WSMPCNST.SPLIT THEN --split transaction
5900
5901 l_stmt_num := 60;
5902 -- For non-serial tracked jobs, the serial information should be complete...
5903 -- If the starting job is not a resulting job, then
5904 -- Total number of serial numbers should equal the job serial qty....
5905 select count(*)
5906 into l_serial_num_count
5907 -- ST : Fix for bug 4910758 (remove usage of wsm_job_serial_numbers_v)
5908 -- from wsm_job_serial_numbers_v
5909 from mtl_serial_numbers
5910 where inventory_item_id = l_inventory_item_id
5911 and wip_entity_id = l_wip_entity_id
5912 and nvl(intraoperation_step_type,-1) <> 5;
5913
5914 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
5915 l_msg_tokens.delete;
5916 WSM_log_PVT.logMessage (p_module_name => l_module ,
5917 p_msg_text => 'Serial Numbers of Parent Job : ' || l_serial_num_count ||
5918 ' Provided Serial Numbers : ' || p_serial_num_tbl.count,
5919 p_stmt_num => l_stmt_num ,
5920 p_msg_tokens => l_msg_tokens ,
5921 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
5922 p_run_log_level => l_log_level
5923 );
5924 END IF;
5925 IF (l_serial_num_count = 0 and p_serial_num_tbl.count = 0) THEN
5926 -- Return as no serial processing required...
5927 return;
5928 ELSIF l_serial_num_count = 0 and p_serial_num_tbl.count <> 0 THEN
5929 -- error out...
5930 -- error out...
5931 l_stmt_num := 70;
5932 IF g_log_level_error >= l_log_level OR
5933 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5934 THEN
5935
5936 l_msg_tokens.delete;
5937 WSM_log_PVT.logMessage(p_module_name => l_module ,
5938 p_msg_name => 'WSM_SPLIT_SERIAL_INFO_REQ',
5939 p_msg_appl_name => 'WSM' ,
5940 p_msg_tokens => l_msg_tokens ,
5941 p_stmt_num => l_stmt_num ,
5942 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5943 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5944 p_run_log_level => l_log_level
5945 );
5946 END IF;
5947 RAISE FND_API.G_EXC_ERROR;
5948 END IF;
5949
5950 l_stmt_num := 80;
5951 -- First thing is sort the serial numbers table based on wip_entity_name
5952 -- We also ensure that the serial numbers of the starting job if present as a resulting job comes at the end...
5953 -- This is required to determine the records not specified...
5954 l_index1 := p_serial_num_tbl.first;
5955 while(l_index1 IS NOT NULL) loop
5956
5957 l_index2 := p_serial_num_tbl.next(l_index1);
5958
5959 while(l_index2 IS NOT NULL) loop
5960
5961 IF p_serial_num_tbl(l_index2).serial_number = p_serial_num_tbl(l_index1).serial_number THEN
5962 -- Duplicate entry....
5963 -- error out...
5964 l_stmt_num := 85;
5965 IF g_log_level_error >= l_log_level OR
5966 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
5967 THEN
5968 l_msg_tokens.delete;
5969 l_msg_tokens(1).TokenName := 'SERIAL';
5970 l_msg_tokens(1).TokenValue := p_serial_num_tbl(l_index2).serial_number;
5971
5972 WSM_log_PVT.logMessage(p_module_name => l_module ,
5973 p_msg_name => 'WSM_DUPLICATE_TXN_SERIAL',
5974 p_msg_appl_name => 'WSM' ,
5975 p_msg_tokens => l_msg_tokens ,
5976 p_stmt_num => l_stmt_num ,
5977 p_fnd_msg_level => G_MSG_LVL_ERROR ,
5978 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
5979 p_run_log_level => l_log_level
5980 );
5981 END IF;
5982 RAISE FND_API.G_EXC_ERROR;
5983 END IF;
5984
5985 IF (p_serial_num_tbl(l_index2).changed_wip_entity_name < p_serial_num_tbl(l_index1).changed_wip_entity_name)
5986 -- OR (p_serial_num_tbl(l_index2).changed_wip_entity_name <> l_wip_entity_name AND
5987 -- p_serial_num_tbl(l_index1).changed_wip_entity_name = l_wip_entity_name)
5988 THEN
5989 -- exchange...
5990 l_temp_rec := p_serial_num_tbl(l_index2);
5991 p_serial_num_tbl(l_index2) := p_serial_num_tbl(l_index1);
5992 p_serial_num_tbl(l_index1) := l_temp_rec;
5993 END IF;
5994
5995 l_index2 := p_serial_num_tbl.next(l_index2);
5996
5997 end loop;
5998
5999 l_index1 := p_serial_num_tbl.next(l_index1);
6000
6001 end loop;
6002
6003 l_stmt_num := 90;
6004 -- Now the data is sorted...
6005 l_index := p_resulting_jobs_tbl.first;
6006 while l_index is not null loop
6007
6008 IF p_resulting_jobs_tbl(l_index).wip_entity_name = l_wip_entity_name then
6009 l_parent_as_resjob := l_index;
6010 end if;
6011
6012 l_res_job_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name) := l_index;
6013
6014 l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start := null;
6015 l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count := 0;
6016
6017 l_index := p_resulting_jobs_tbl.next(l_index);
6018
6019 end loop;
6020
6021 l_stmt_num := 100;
6022 -- create a index on the collected serial numbers...
6023 l_index := p_serial_num_tbl.first;
6024
6025 while l_index is not null loop
6026
6027 -- Info already present...
6028 if l_job_ser_info_tbl(p_serial_num_tbl(l_index).changed_wip_entity_name).l_index_start IS NOT NULL then
6029 --same job so increment just the count..
6030 l_job_ser_info_tbl(p_serial_num_tbl(l_index).changed_wip_entity_name).l_count := l_job_ser_info_tbl(p_serial_num_tbl(l_index).changed_wip_entity_name).l_count + 1;
6031 else
6032 if not (l_res_job_tbl.exists(p_serial_num_tbl(l_index).changed_wip_entity_name)) THEN
6033
6034 l_stmt_num := 105;
6035 --error out..
6036 IF g_log_level_error >= l_log_level OR
6037 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6038 THEN
6039 l_msg_tokens.delete;
6040 l_msg_tokens(1).TokenName := 'FLD_NAME';
6041 l_msg_tokens(1).TokenValue := 'Changed Job Name';
6042 WSM_log_PVT.logMessage(p_module_name => l_module ,
6043 p_msg_name => 'WSM_INVALID_FIELD' ,
6044 p_msg_appl_name => 'WSM' ,
6045 p_msg_tokens => l_msg_tokens ,
6046 p_stmt_num => l_stmt_num ,
6047 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6048 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6049 p_run_log_level => l_log_level
6050 );
6051 END IF;
6052 RAISE FND_API.G_EXC_ERROR;
6053 end if;
6054
6055 l_job_ser_info_tbl(p_serial_num_tbl(l_index).changed_wip_entity_name).l_index_start := l_index;
6056 l_job_ser_info_tbl(p_serial_num_tbl(l_index).changed_wip_entity_name).l_count := 1;
6057 end if;
6058
6059 l_index := p_serial_num_tbl.next(l_index);
6060
6061 end loop;
6062
6063 l_stmt_num := 107;
6064
6065 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6066 l_temp_job := l_job_ser_info_tbl.first;
6067 WHILE l_temp_job IS NOT NULL LOOP
6068 l_msg_tokens.delete;
6069 WSM_log_PVT.logMessage (p_module_name => l_module ,
6070 p_msg_text => 'Job Name : ' || l_temp_job ||
6071 ' Job Index Start : ' || l_job_ser_info_tbl(l_temp_job).l_index_start ||
6072 ' Count : ' || l_job_ser_info_tbl(l_temp_job).l_count ,
6073 p_stmt_num => l_stmt_num ,
6074 p_msg_tokens => l_msg_tokens ,
6075 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6076 p_run_log_level => l_log_level
6077 );
6078 l_temp_job := l_job_ser_info_tbl.next(l_temp_job);
6079 END LOOP;
6080
6081 END IF;
6082
6083 l_stmt_num := 110;
6084 -- Now the main processing part starts...
6085 if g_wms_installed IS NULL THEN
6086
6087 wms_installed ( x_return_status => x_return_status ,
6088 x_error_count => x_error_count ,
6089 x_err_data => x_error_msg
6090 );
6091
6092 if x_return_status <> G_RET_SUCCESS then
6093 IF x_return_status = G_RET_ERROR THEN
6094 raise FND_API.G_EXC_ERROR;
6095 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6096 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6097 END IF;
6098 end if;
6099
6100 l_update_serial_attr := g_wms_installed;
6101 else
6102 l_update_serial_attr := g_wms_installed;
6103 end if;
6104
6105 l_stmt_num := 120;
6106 IF l_update_serial_attr = 1 then
6107
6108 l_parent_job_ser_context := null;
6109
6110 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_parent_job_ser_context,
6111 org_id => p_organization_id ,
6112 item_id => l_inventory_item_id,
6113 flex_name => 'Serial Attributes'
6114 );
6115 END IF;
6116
6117 l_stmt_num := 130;
6118 l_index := p_resulting_jobs_tbl.first;
6119
6120 while l_index is not null loop
6121
6122 l_stmt_num := 131;
6123 if (l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count >
6124 p_resulting_jobs_tbl(l_index).start_quantity)
6125 then
6126 l_stmt_num := 132;
6127 -- error out...
6128 IF g_log_level_error >= l_log_level OR
6129 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6130 THEN
6131
6132 l_msg_tokens.delete;
6133 l_msg_tokens(1).TokenName := 'JOB';
6134 l_msg_tokens(1).TokenValue := p_resulting_jobs_tbl(l_index).wip_entity_name;
6135 WSM_log_PVT.logMessage(p_module_name => l_module ,
6136 p_msg_name => 'WSM_INVALID_SERIAL_QTY1' ,
6137 p_msg_appl_name => 'WSM' ,
6138 p_msg_tokens => l_msg_tokens ,
6139 p_stmt_num => l_stmt_num ,
6140 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6141 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6142 p_run_log_level => l_log_level
6143 );
6144 END IF;
6145 RAISE FND_API.G_EXC_ERROR;
6146 end if;
6147
6148 l_stmt_num := 133;
6149 -- first check is on the count...
6150 IF (l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count < p_resulting_jobs_tbl(l_index).start_quantity)
6151 THEN
6152
6153 l_stmt_num := 134;
6154
6155 -- check if already another job has been encountered...
6156 -- Serial Numbers can be derived be derived only for one of the resulting jobs and
6157 if (l_filling_job_name IS NULL) and
6158 (p_serial_num_tbl.count <> l_serial_num_count) -- try to derive only when complete info is not specified.
6159 THEN
6160
6161 l_stmt_num := 135;
6162 -- See if you can derive first of all...
6163 IF p_resulting_jobs_tbl(l_index).start_quantity <
6164 (l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count + l_serial_num_count - p_serial_num_tbl.count)
6165 THEN
6166 IF g_log_level_error >= l_log_level OR
6167 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6168 THEN
6169
6170 l_msg_tokens.delete;
6171 l_msg_tokens(1).TokenName := 'JOB';
6172 l_msg_tokens(1).TokenValue := p_resulting_jobs_tbl(l_index).wip_entity_name;
6173 WSM_log_PVT.logMessage(p_module_name => l_module ,
6174 p_msg_name => 'WSM_SPLIT_SERIAL_INSUFF',
6175 p_msg_appl_name => 'WSM' ,
6176 p_msg_tokens => l_msg_tokens ,
6177 p_stmt_num => l_stmt_num ,
6178 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6179 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6180 p_run_log_level => l_log_level
6181 );
6182 END IF;
6183 RAISE FND_API.G_EXC_ERROR;
6184 END IF;
6185
6186 -- None encountered so far...
6187 l_filling_job_name := p_resulting_jobs_tbl(l_index).wip_entity_name;
6188
6189 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6190 l_msg_tokens.delete;
6191 WSM_log_PVT.logMessage (p_module_name => l_module ,
6192 p_msg_text => 'Deriving serial numbers for the job : ' || l_filling_job_name,
6193 p_stmt_num => l_stmt_num ,
6194 p_msg_tokens => l_msg_tokens ,
6195 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6196 p_run_log_level => l_log_level
6197 );
6198 END IF;
6199
6200 l_move_flag := 'N';
6201 -- l_index1 := p_resulting_jobs_tbl.next(l_index);
6202 -- -- Indices of the later jobs are modified...
6203 -- while l_index1 IS NOT NULL loop
6204 --
6205 -- IF l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index1).wip_entity_name).l_index_start IS NOT NULL THEN
6206 --
6207 -- l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index1).wip_entity_name).l_index_start
6208 -- := l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index1).wip_entity_name).l_index_start -
6209 -- l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count;
6210 -- END IF;
6211 --
6212 -- l_index1 := p_resulting_jobs_tbl.next(l_index1);
6213 -- end loop;
6214
6215 -- Now decrease the starting index of all the jobs whose index starts after this job's index start...
6216 l_index_job_name := l_job_ser_info_tbl.first;
6217 l_curr_job_name := p_resulting_jobs_tbl(l_index).wip_entity_name;
6218 -- Indices of the later jobs are modified...
6219 while l_index_job_name IS NOT NULL loop
6220
6221 IF (l_job_ser_info_tbl(l_index_job_name).l_index_start IS NOT NULL) AND
6222 (l_job_ser_info_tbl(l_index_job_name).l_index_start > l_job_ser_info_tbl(l_curr_job_name).l_index_start)
6223 THEN
6224 l_job_ser_info_tbl(l_index_job_name).l_index_start := l_job_ser_info_tbl(l_index_job_name).l_index_start
6225 - l_job_ser_info_tbl(l_curr_job_name).l_count;
6226 l_move_flag := 'Y';
6227 END IF;
6228
6229 l_index_job_name := l_job_ser_info_tbl.next(l_index_job_name);
6230 end loop;
6231
6232 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6233 l_msg_tokens.delete;
6234 WSM_log_PVT.logMessage (p_module_name => l_module ,
6235 p_msg_text => 'After decrementing all the subsequent indices',
6236 p_stmt_num => l_stmt_num ,
6237 p_msg_tokens => l_msg_tokens ,
6238 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6239 p_run_log_level => l_log_level
6240 );
6241 l_temp_job := l_job_ser_info_tbl.first;
6242 WHILE l_temp_job IS NOT NULL LOOP
6243
6244 WSM_log_PVT.logMessage (p_module_name => l_module ,
6245 p_msg_text => 'Job Name : ' || l_temp_job ||
6246 ' Job Index Start : ' || l_job_ser_info_tbl(l_temp_job).l_index_start ||
6247 ' Count : ' || l_job_ser_info_tbl(l_temp_job).l_count ,
6248 p_stmt_num => l_stmt_num ,
6249 p_msg_tokens => l_msg_tokens ,
6250 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6251 p_run_log_level => l_log_level
6252 );
6253 l_temp_job := l_job_ser_info_tbl.next(l_temp_job);
6254 END LOOP;
6255
6256 l_index1 := p_serial_num_tbl.first;
6257 while l_index1 IS NOT NULL LOOP
6258 WSM_log_PVT.logMessage (p_module_name => l_module ,
6259 p_msg_text => 'Index : ' || l_index1 ||
6260 ' Serial Number : ' || p_serial_num_tbl(l_index1).serial_number ||
6261 ' Job Name : ' || p_serial_num_tbl(l_index1).changed_wip_entity_name ,
6262 p_stmt_num => l_stmt_num ,
6263 p_msg_tokens => l_msg_tokens ,
6264 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6265 p_run_log_level => l_log_level
6266 );
6267 l_index1 := p_serial_num_tbl.next(l_index1);
6268 END LOOP;
6269 END IF;
6270
6271 l_stmt_num := 136;
6272 -- Next.. move the records of this job to the last...
6273 -- We'' do this only when we have some entries for our current job in the dictonary..
6274 IF l_move_flag = 'Y' THEN
6275 -- l_old_start_index := l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start;
6276 l_old_start_index := l_job_ser_info_tbl(l_curr_job_name).l_index_start;
6277
6278 l_index1 := l_job_ser_info_tbl(l_curr_job_name).l_index_start;
6279 while (l_index1 IS NOT NULL) and
6280 (l_index1 < (l_job_ser_info_tbl(l_curr_job_name).l_index_start + l_job_ser_info_tbl(l_curr_job_name).l_count))
6281 loop
6282 p_serial_num_tbl(p_serial_num_tbl.count+1) := p_serial_num_tbl(l_index1);
6283 l_index1 := l_index1 + 1;
6284 end loop;
6285
6286 l_stmt_num := 137;
6287 -- Ok .. overwrite the records now...
6288 l_index1 := l_old_start_index;
6289 while (l_index1 IS NOT NULL) AND
6290 (l_index1 <= (p_serial_num_tbl.count -
6291 l_job_ser_info_tbl(l_curr_job_name).l_count))
6292 loop
6293 p_serial_num_tbl(l_index1) := p_serial_num_tbl(l_index1 + l_job_ser_info_tbl(l_curr_job_name).l_count);
6294 l_index1 := l_index1 + 1;
6295 end loop;
6296
6297 l_stmt_num := 138;
6298 -- Ok.. done...
6299 -- Delete the last records...
6300 l_index1 := p_serial_num_tbl.count - l_job_ser_info_tbl(l_curr_job_name).l_count + 1;
6301 l_count := 1;
6302 while (l_count <= l_job_ser_info_tbl(l_curr_job_name).l_count) loop
6303 p_serial_num_tbl.delete(l_index1);
6304 l_index1 := l_index1 + 1;
6305 l_count := l_count + 1;
6306 end loop;
6307
6308 END IF;
6309
6310 l_stmt_num := 139;
6311 -- Update the start index...
6312 l_job_ser_info_tbl(l_curr_job_name).l_index_start := p_serial_num_tbl.count - (l_job_ser_info_tbl(l_curr_job_name).l_count) + 1;
6313
6314 l_stmt_num := 140;
6315 l_old_count := p_serial_num_tbl.count;
6316 -- Fetch the rows,, and fill in the non-present serial numbers...
6317 fetch_wlt_serials(p_new_job_name => p_resulting_jobs_tbl(l_index).wip_entity_name ,
6318 p_serial_num_tbl => p_serial_num_tbl ,
6319 p_split_txn_job_id => l_wip_entity_id ,
6320 x_return_status => x_return_status ,
6321 x_error_msg => x_error_msg ,
6322 x_error_count => x_error_count
6323 );
6324
6325 if x_return_status <> G_RET_SUCCESS then
6326 IF x_return_status = G_RET_ERROR THEN
6327 raise FND_API.G_EXC_ERROR;
6328 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6329 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6330 END IF;
6331 end if;
6332
6333 l_stmt_num := 141;
6334 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6335 l_msg_tokens.delete;
6336 WSM_log_PVT.logMessage (p_module_name => l_module ,
6337 p_msg_text => 'After all operations',
6338 p_stmt_num => l_stmt_num ,
6339 p_msg_tokens => l_msg_tokens ,
6340 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6341 p_run_log_level => l_log_level
6342 );
6343
6344 l_temp_job := l_job_ser_info_tbl.first;
6345 WHILE l_temp_job IS NOT NULL LOOP
6346
6347 WSM_log_PVT.logMessage (p_module_name => l_module ,
6348 p_msg_text => 'Job Name : ' || l_temp_job ||
6349 ' Job Index Start : ' || l_job_ser_info_tbl(l_temp_job).l_index_start ||
6350 ' Count : ' || l_job_ser_info_tbl(l_temp_job).l_count ,
6351 p_stmt_num => l_stmt_num ,
6352 p_msg_tokens => l_msg_tokens ,
6353 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6354 p_run_log_level => l_log_level
6355 );
6356 l_temp_job := l_job_ser_info_tbl.next(l_temp_job);
6357 END LOOP;
6358
6359 l_index1 := p_serial_num_tbl.first;
6360 while l_index1 IS NOT NULL LOOP
6361 WSM_log_PVT.logMessage (p_module_name => l_module ,
6362 p_msg_text => 'Index : ' || l_index1 ||
6363 ' Serial Number : ' || p_serial_num_tbl(l_index1).serial_number ||
6364 ' Job Name : ' || p_serial_num_tbl(l_index1).changed_wip_entity_name ,
6365 p_stmt_num => l_stmt_num ,
6366 p_msg_tokens => l_msg_tokens ,
6367 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6368 p_run_log_level => l_log_level
6369 );
6370 l_index1 := p_serial_num_tbl.next(l_index1);
6371 END LOOP;
6372 END IF;
6373
6374 l_stmt_num := 142;
6375 l_new_count := p_serial_num_tbl.count;
6376
6377 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6378 l_msg_tokens.delete;
6379 WSM_log_PVT.logMessage (p_module_name => l_module ,
6380 p_msg_text => 'Total Serial Numbers : Old count : ' || l_old_count
6381 || ' New Count (After Derivation) : '|| l_new_count,
6382 p_stmt_num => l_stmt_num ,
6383 p_msg_tokens => l_msg_tokens ,
6384 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6385 p_run_log_level => l_log_level
6386 );
6387 END IF;
6388
6389 -- Update the count...
6390 l_job_ser_info_tbl(l_curr_job_name).l_count := l_job_ser_info_tbl(l_curr_job_name).l_count + (l_new_count - l_old_count);
6391
6392 ELSIF (l_filling_job_name IS NOT NULL)
6393 THEN
6394 -- Already encountered....
6395 -- error out...
6396 l_stmt_num := 142;
6397 IF g_log_level_error >= l_log_level OR
6398 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6399 THEN
6400 l_msg_tokens.delete;
6401 l_msg_tokens(1).TokenName := 'JOB';
6402 l_msg_tokens(1).TokenValue := p_resulting_jobs_tbl(l_index).wip_entity_name;
6403 WSM_log_PVT.logMessage(p_module_name => l_module ,
6404 p_msg_name => 'WSM_SPLIT_SERIAL_INSUFF',
6405 p_msg_appl_name => 'WSM' ,
6406 p_msg_tokens => l_msg_tokens ,
6407 p_stmt_num => l_stmt_num ,
6408 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6409 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6410 p_run_log_level => l_log_level
6411 );
6412 END IF;
6413 RAISE FND_API.G_EXC_ERROR;
6414 END IF;
6415
6416 END IF;
6417
6418 l_index := p_resulting_jobs_tbl.next(l_index);
6419
6420 end loop;
6421
6422 l_stmt_num := 143;
6423 -- ok now validate the total qty..
6424 IF l_parent_as_resjob IS NOT NULL THEN
6425 l_stmt_num := 144;
6426 -- Indicates that the starting job is also a res. job...
6427 if (l_serial_num_count - p_serial_num_tbl.count) > p_resulting_jobs_tbl(l_parent_as_resjob).start_quantity then
6428
6429 l_stmt_num := 145;
6430 -- error out...
6431 -- Possible that we dont add serial numbers for a parent job that is not serial tracked...
6432 -- This happens when the total no. of serial numbers is less than the available qty..
6433 IF g_log_level_error >= l_log_level OR
6434 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6435 THEN
6436 l_msg_tokens.delete;
6437 l_msg_tokens(1).TokenName := 'JOB';
6438 l_msg_tokens(1).TokenValue := p_resulting_jobs_tbl(l_parent_as_resjob).wip_entity_name;
6439 WSM_log_PVT.logMessage(p_module_name => l_module ,
6440 p_msg_name => 'WSM_INVALID_SERIAL_QTY1',
6441 p_msg_appl_name => 'WSM' ,
6442 p_msg_tokens => l_msg_tokens ,
6443 p_stmt_num => l_stmt_num ,
6444 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6445 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6446 p_run_log_level => l_log_level
6447 );
6448 END IF;
6449 RAISE FND_API.G_EXC_ERROR;
6450 end if;
6451
6452 ELSE
6453 -- Indicates that the starting job is not a res. job...
6454 IF l_serial_num_count <> p_serial_num_tbl.count then
6455 l_stmt_num := 146;
6456 -- error out...
6457 IF g_log_level_error >= l_log_level OR
6458 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
6459 THEN
6460
6461 l_msg_tokens.delete;
6462 WSM_log_PVT.logMessage(p_module_name => l_module ,
6463 p_msg_name => 'WSM_SPLIT_SERIAL_INFO_REQ',
6464 p_msg_appl_name => 'WSM' ,
6465 p_msg_tokens => l_msg_tokens ,
6466 p_stmt_num => l_stmt_num ,
6467 p_fnd_msg_level => G_MSG_LVL_ERROR ,
6468 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6469 p_run_log_level => l_log_level
6470 );
6471 END IF;
6472 RAISE FND_API.G_EXC_ERROR;
6473 end if;
6474 end if;
6475
6476 l_stmt_num := 147;
6477 -- Now begin the actual processing....
6478 l_index := p_resulting_jobs_tbl.first;
6479
6480 while l_index is not null loop
6481
6482 IF p_resulting_jobs_tbl(l_index).wip_entity_name = l_wip_entity_name then
6483 l_start_as_res_job := 1;
6484 ELSE
6485 l_start_as_res_job := 0;
6486 END IF;
6487
6488 l_stmt_num := 148;
6489 -- if SpUA then
6490 if p_resulting_jobs_tbl(l_index).split_has_update_assy = 1 then
6491
6492 -- During split transaction.. user can provide attributes' information...
6493 if l_update_serial_attr = 1 then
6494 -- get the context of the new assembly if no context/different from the existing context then
6495 -- populate message about the serial attributes being cleared...
6496 l_stmt_num := 149;
6497 l_child_job_ser_context := null;
6498
6499 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_child_job_ser_context,
6500 org_id => p_organization_id ,
6501 item_id => p_resulting_jobs_tbl(l_index).primary_item_id,
6502 flex_name => 'Serial Attributes'
6503 );
6504
6505 IF nvl(l_child_job_ser_context,'&#') <> nvl(l_parent_job_ser_context,'&#') then
6506 -- populate a error message saying that the attributes will be cleared...
6507 IF g_log_level_exception >= l_log_level OR
6508 FND_MSG_PUB.check_msg_level(G_MSG_LVL_DEBUG_HIGH)
6509 THEN
6510
6511 l_msg_tokens.delete;
6512 l_msg_tokens(1).TokenName := 'JOB';
6513 l_msg_tokens(1).TokenValue := p_resulting_jobs_tbl(l_index).wip_entity_name;
6514
6515 WSM_log_PVT.logMessage(p_module_name => l_module ,
6516 p_msg_name => 'WSM_SERIAL_CLEAR_ATTR' ,
6517 p_msg_appl_name => 'WSM' ,
6518 p_msg_tokens => l_msg_tokens ,
6519 p_fnd_msg_level => G_MSG_LVL_SUCCESS ,
6520 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6521 p_run_log_level => l_log_level ,
6522 p_wsm_warning => 1
6523 );
6524 END IF;
6525 l_clear_serial_attr := 1;
6526 else
6527 l_clear_serial_attr := 0;
6528 end if;
6529 end if; -- end l_update_serial_attr = 1
6530
6531 l_stmt_num := 150;
6532 l_index1 := l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start;
6533
6534 IF l_serial_start_flag IS NOT NULL THEN
6535 -- Indicates that serial tracking hasnt begun
6536 l_temp_op_seq_num := l_curr_job_op_seq_num + l_op_seq_incr;
6537 l_temp_op_step := WIP_CONSTANTS.QUEUE;
6538 ELSE
6539 l_temp_op_seq_num := NULL;
6540 l_temp_op_step := NULL;
6541 END IF;
6542
6543
6544 while l_index1 < (l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start +
6545 l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count)
6546 loop
6547 l_stmt_num := 151;
6548
6549 -- call to update the serial number with the new wip_entity_id
6550 if (l_start_as_res_job = 0)
6551 then
6552 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6553 l_msg_tokens.delete;
6554 WSM_log_PVT.logMessage (p_module_name => l_module ,
6555 p_msg_text => 'Job Name : ' || p_resulting_jobs_tbl(l_index).wip_entity_name
6556 || 'Serial number : ' || p_serial_num_tbl(l_index1).serial_number,
6557 p_stmt_num => l_stmt_num ,
6558 p_msg_tokens => l_msg_tokens ,
6559 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6560 p_run_log_level => l_log_level
6561 );
6562 END IF;
6563
6564 update_serial ( p_serial_number => p_serial_num_tbl(l_index1).serial_number,
6565 p_inventory_item_id => l_inventory_item_id,
6566 p_organization_id => p_organization_id,
6567 p_wip_entity_id => p_resulting_jobs_tbl(l_index).wip_entity_id,
6568 p_operation_seq_num => l_temp_op_seq_num,
6569 p_intraoperation_step_type => l_temp_op_step,
6570 x_return_status => x_return_status,
6571 x_error_msg => x_error_msg ,
6572 x_error_count => x_error_count
6573 );
6574
6575 if x_return_status <> G_RET_SUCCESS then
6576 IF x_return_status = G_RET_ERROR THEN
6577 raise FND_API.G_EXC_ERROR;
6578 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6579 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6580 END IF;
6581 end if;
6582
6583 end if;
6584
6585 l_stmt_num := 152;
6586
6587 -- Update the attributes only if they arent going to be cleared by the INV API..
6588 -- and also We'll have to ensure that this procedure gets invoked only for the serials given by the user...
6589 -- For all those records header_id will be populated..
6590 -- But for the records that the code derives, header_id will be NULL :)
6591
6592 IF l_clear_serial_attr = 0 and p_serial_num_tbl(l_index1).header_id IS NOT NULL THEN
6593 update_serial_attr ( p_calling_mode => p_calling_mode ,
6594 p_serial_number_rec => p_serial_num_tbl(l_index1) ,
6595 p_inventory_item_id => l_inventory_item_id ,
6596 p_organization_id => p_organization_id ,
6597 p_clear_serial_attr => l_clear_serial_attr ,
6598 p_wlt_txn_type => WSMPCNST.SPLIT ,
6599 p_update_serial_attr => l_update_serial_attr ,
6600 p_update_desc_attr => 1 ,
6601 p_serial_attr_context => l_child_job_ser_context ,
6602 x_return_status => x_return_status ,
6603 x_error_count => x_error_count ,
6604 x_error_msg => x_error_msg
6605 );
6606
6607 if x_return_status <> G_RET_SUCCESS then
6608 IF x_return_status = G_RET_ERROR THEN
6609 raise FND_API.G_EXC_ERROR;
6610 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6611 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6612 END IF;
6613 end if;
6614 END IF;
6615
6616 l_index1 := l_index1 + 1;
6617
6618 end loop;
6619
6620 -- Now call the new API proposed by the INV team that will update all the serial numbers linked
6621 -- with a particular job with new inventory item
6622 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6623 l_msg_tokens.delete;
6624 WSM_log_PVT.logMessage (p_module_name => l_module ,
6625 p_msg_text => 'Invoking INV_LOT_TRX_VALIDATION_PUB.update_item_serial',
6626 p_stmt_num => l_stmt_num ,
6627 p_msg_tokens => l_msg_tokens ,
6628 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6629 p_run_log_level => l_log_level
6630 );
6631 END IF;
6632
6633 INV_LOT_TRX_VALIDATION_PUB.update_item_serial( x_msg_count => x_error_count ,
6634 x_return_status => x_return_status ,
6635 x_msg_data => x_error_msg ,
6636 x_validation_status => l_validation_status ,
6637 p_org_id => p_organization_id ,
6638 p_item_id => l_inventory_item_id ,
6639 p_to_item_id => p_resulting_jobs_tbl(l_index).primary_item_id ,
6640 p_wip_entity_id => p_resulting_jobs_tbl(l_index).wip_entity_id ,
6641 p_to_wip_entity_id => p_resulting_jobs_tbl(l_index).wip_entity_id ,
6642 p_to_operation_sequence => l_temp_op_seq_num ,
6643 p_intraoperation_step_type => l_temp_op_step
6644 );
6645
6646 if x_return_status <> G_RET_SUCCESS then
6647 IF x_return_status = G_RET_ERROR THEN
6648 raise FND_API.G_EXC_ERROR;
6649 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6650 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6651 END IF;
6652 end if;
6653
6654 else
6655 -- No Update of assembly for this job...
6656 l_stmt_num := 153;
6657 -- update the serial number .. basically just linking it with the new job...
6658 -- start_index and count already present .. just loop through...
6659 l_index1 := l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start;
6660
6661 while l_index1 < (l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_index_start +
6662 l_job_ser_info_tbl(p_resulting_jobs_tbl(l_index).wip_entity_name).l_count)
6663 loop
6664
6665 -- call to update the serial number...
6666 -- call to update the serial number with the new wip_entity_id ...
6667 if l_start_as_res_job = 0 then
6668 l_stmt_num := 154;
6669 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6670 l_msg_tokens.delete;
6671 WSM_log_PVT.logMessage (p_module_name => l_module ,
6672 p_msg_text => 'Job Name : ' || p_resulting_jobs_tbl(l_index).wip_entity_name
6673 || 'Serial number : ' || p_serial_num_tbl(l_index1).serial_number,
6674 p_stmt_num => l_stmt_num ,
6675 p_msg_tokens => l_msg_tokens ,
6676 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6677 p_run_log_level => l_log_level
6678 );
6679 END IF;
6680
6681 update_serial ( p_serial_number => p_serial_num_tbl(l_index1).serial_number ,
6682 p_inventory_item_id => l_inventory_item_id ,
6683 p_organization_id => p_organization_id ,
6684 p_wip_entity_id => p_resulting_jobs_tbl(l_index).wip_entity_id ,
6685 p_operation_seq_num => l_curr_job_op_seq_num ,
6686 p_intraoperation_step_type => l_curr_job_op_step ,
6687 x_return_status => x_return_status ,
6688 x_error_msg => x_error_msg ,
6689 x_error_count => x_error_count
6690 );
6691
6692 if x_return_status <> G_RET_SUCCESS then
6693 IF x_return_status = G_RET_ERROR THEN
6694 raise FND_API.G_EXC_ERROR;
6695 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6696 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6697 END IF;
6698 end if;
6699 end if;
6700
6701 -- We'll have to ensure that this procedure gets invoked only for the serials given by the user...
6702 -- For all those records header_id will be populated..
6703 -- But for the records that the code derives, header_id will be NULL :)
6704 IF p_serial_num_tbl(l_index1).header_id IS NOT NULL THEN
6705 l_stmt_num := 156;
6706 update_serial_attr ( p_calling_mode => p_calling_mode ,
6707 p_serial_number_rec => p_serial_num_tbl(l_index1) ,
6708 p_inventory_item_id => l_inventory_item_id ,
6709 p_organization_id => p_organization_id ,
6710 p_clear_serial_attr => l_clear_serial_attr ,
6711 p_wlt_txn_type => WSMPCNST.SPLIT ,
6712 p_update_serial_attr => l_update_serial_attr ,
6713 p_update_desc_attr => 1 ,
6714 x_return_status => x_return_status ,
6715 x_error_count => x_error_count ,
6716 x_error_msg => x_error_msg
6717 );
6718 if x_return_status <> G_RET_SUCCESS then
6719 IF x_return_status = G_RET_ERROR THEN
6720 raise FND_API.G_EXC_ERROR;
6721 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6722 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6723 END IF;
6724 end if;
6725 END IF;
6726
6727 l_index1 := l_index1 + 1;
6728
6729 end loop;
6730 end if;
6731
6732 l_index := p_resulting_jobs_tbl.next(l_index);
6733
6734 end loop;
6735
6736 l_stmt_num := 157;
6737 -- Insert all the serial numbers present to the WSM_SERIAL_TRANSACTIONS table...
6738 insert into wsm_serial_transactions
6739 (transaction_id ,
6740 transaction_type_id ,
6741 serial_number ,
6742 gen_object_id ,
6743 current_wip_entity_name ,
6744 changed_wip_entity_name ,
6745 current_wip_entity_id ,
6746 changed_wip_entity_id ,
6747 created_by ,
6748 last_update_date ,
6749 last_updated_by ,
6750 creation_date ,
6751 last_update_login ,
6752 request_id ,
6753 program_application_id ,
6754 program_id ,
6755 program_update_date ,
6756 original_system_reference
6757 )
6758 select
6759 p_txn_id ,
6760 3 ,
6761 MSN.serial_number ,
6762 MSN.gen_object_id ,
6763 WSSJ.wip_entity_name ,
6764 WSRJ.wip_entity_name ,
6765 WSSJ.wip_entity_id ,
6766 WSRJ.wip_entity_id ,
6767 g_user_id ,
6768 sysdate ,
6769 g_user_id ,
6770 sysdate ,
6771 g_user_login_id ,
6772 g_request_id ,
6773 g_program_appl_id ,
6774 g_program_id ,
6775 sysdate ,
6776 null
6777 from mtl_serial_numbers MSN ,
6778 wsm_sm_starting_jobs WSSJ ,
6779 wsm_sm_resulting_jobs WSRJ
6780 where MSN.current_organization_id = p_organization_id
6781 and MSN.inventory_item_id = WSRJ.primary_item_id
6782 and WSSJ.transaction_id = p_txn_id
6783 and WSRJ.transaction_id = p_txn_id
6784 and MSN.wip_entity_id = WSRJ.wip_entity_id
6785 and nvl(MSN.intraoperation_step_type,-1) <> 5;
6786
6787 -- If the parent is serial tracked then all child jobs will also be serial tracked...
6788 IF l_serial_start_flag IS NOT NULL THEN
6789 update wip_discrete_jobs
6790 set serialization_start_op = 10
6791 where wip_entity_id in (select wip_entity_id
6792 from wsm_sm_resulting_jobs
6793 where transaction_id = p_txn_id);
6794
6795 -- We set the first_serial_txn_id as a non-NULL value as some code depends on it.. in Move
6796 update wsm_lot_based_jobs
6797 set first_serial_txn_id = -1
6798 where wip_entity_id in (select wip_entity_id
6799 from wsm_sm_resulting_jobs
6800 where transaction_id = p_txn_id);
6801
6802 END IF;
6803
6804 ELSIF p_wlt_txn_type = WSMPCNST.MERGE THEN -- Merge transaction
6805
6806 l_stmt_num := 160;
6807 -- Now the main processing part starts...
6808 if g_wms_installed IS NULL THEN
6809
6810 wms_installed ( x_return_status => x_return_status ,
6811 x_error_count => x_error_count ,
6812 x_err_data => x_error_msg
6813 );
6814
6815 if x_return_status <> G_RET_SUCCESS then
6816 IF x_return_status = G_RET_ERROR THEN
6817 raise FND_API.G_EXC_ERROR;
6818 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6819 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6820 END IF;
6821 end if;
6822 end if;
6823
6824 l_stmt_num := 165;
6825 IF g_wms_installed = 1 then
6826
6827 l_parent_job_ser_context := null;
6828
6829 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_parent_job_ser_context,
6830 org_id => p_organization_id ,
6831 item_id => p_starting_jobs_tbl(l_rep_job_index).primary_item_id,
6832 flex_name => 'Serial Attributes'
6833 );
6834 END IF;
6835
6836 l_stmt_num := 170;
6837 -- Insert into the WSM table here itself....
6838 insert into wsm_serial_transactions
6839 (transaction_id ,
6840 transaction_type_id ,
6841 serial_number ,
6842 gen_object_id ,
6843 current_wip_entity_name ,
6844 changed_wip_entity_name ,
6845 current_wip_entity_id ,
6846 changed_wip_entity_id ,
6847 created_by ,
6848 last_update_date ,
6849 last_updated_by ,
6850 creation_date ,
6851 last_update_login ,
6852 request_id ,
6853 program_application_id ,
6854 program_id ,
6855 program_update_date ,
6856 original_system_reference
6857 )
6858 select
6859 p_txn_id ,
6860 3 ,
6861 MSN.serial_number ,
6862 MSN.gen_object_id ,
6863 WSSJ.wip_entity_name ,
6864 WSRJ.wip_entity_name ,
6865 WSSJ.wip_entity_id ,
6866 WSRJ.wip_entity_id ,
6867 g_user_id ,
6868 sysdate ,
6869 g_user_id ,
6870 sysdate ,
6871 g_user_login_id ,
6872 g_request_id ,
6873 g_program_appl_id ,
6874 g_program_id ,
6875 sysdate ,
6876 null
6877 from mtl_serial_numbers MSN ,
6878 wsm_sm_starting_jobs WSSJ ,
6879 wsm_sm_resulting_jobs WSRJ
6880 where MSN.current_organization_id = p_organization_id
6881 and MSN.inventory_item_id = WSSJ.primary_item_id
6882 and WSSJ.transaction_id = p_txn_id
6883 and WSRJ.transaction_id = p_txn_id
6884 and MSN.wip_entity_id = WSSJ.wip_entity_id
6885 and nvl(MSN.intraoperation_step_type,-1) <> 5;
6886
6887 l_stmt_num := 180;
6888 -- Start the processing....
6889 l_index := p_starting_jobs_tbl.first;
6890
6891 while l_index is not null loop
6892
6893 -- ST : Fix for bug 5161024 --
6894 -- Don't l_inventory_item_id as it contains the rep job data...
6895 -- l_inventory_item_id := p_starting_jobs_tbl(l_index).primary_item_id;
6896
6897 if l_index <> l_rep_job_index then
6898 l_stmt_num := 190;
6899
6900 -- ok check the context..
6901 IF g_wms_installed = 1 THEN -- WMS installed,,
6902 -- first check is to see the item id....
6903 if p_starting_jobs_tbl(l_index).primary_item_id <> p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).primary_item_id then
6904 -- have to check the context and populate the warning message...
6905 l_context := null;
6906 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_context ,
6907 org_id => p_organization_id ,
6908 item_id => p_starting_jobs_tbl(l_index).primary_item_id ,
6909 -- ST : Fix for bug 5161024 : l_inventory_item_id ,
6910 flex_name => 'Serial Attributes'
6911 );
6912
6913 if nvl(l_context,'&#') <> nvl(l_parent_job_ser_context,'&#') THEN
6914 -- populate a warning message...
6915 IF g_log_level_exception >= l_log_level OR
6916 FND_MSG_PUB.check_msg_level(G_MSG_LVL_DEBUG_HIGH)
6917 THEN
6918
6919 l_msg_tokens.delete;
6920 l_msg_tokens(1).TokenName := 'JOB';
6921 l_msg_tokens(1).TokenValue := p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name;
6922
6923 WSM_log_PVT.logMessage(p_module_name => l_module ,
6924 p_msg_name => 'WSM_SERIAL_CLEAR_ATTR' ,
6925 p_msg_appl_name => 'WSM' ,
6926 p_msg_tokens => l_msg_tokens ,
6927 p_fnd_msg_level => G_MSG_LVL_SUCCESS ,
6928 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
6929 p_run_log_level => l_log_level ,
6930 p_wsm_warning => 1
6931 );
6932 END IF;
6933 end if;
6934 end if;
6935 END IF;
6936
6937 l_stmt_num := 195;
6938 -- invoke the mail INV API to update the wip entity id, item and op information....
6939 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
6940 l_msg_tokens.delete;
6941 WSM_log_PVT.logMessage (p_module_name => l_module ,
6942 p_msg_text => 'Invoking INV_LOT_TRX_VALIDATION_PUB.update_item_serial : for Res wip_entity_id ' || p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).wip_entity_id,
6943 p_stmt_num => l_stmt_num ,
6944 p_msg_tokens => l_msg_tokens ,
6945 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
6946 p_run_log_level => l_log_level
6947 );
6948 END IF;
6949
6950 INV_LOT_TRX_VALIDATION_PUB.update_item_serial( x_msg_count => x_error_count ,
6951 x_return_status => x_return_status ,
6952 x_msg_data => x_error_msg ,
6953 x_validation_status => l_validation_status ,
6954 p_org_id => p_organization_id ,
6955 p_item_id => p_starting_jobs_tbl(l_index).primary_item_id ,
6956 p_to_item_id => l_inventory_item_id ,
6957 p_wip_entity_id => p_starting_jobs_tbl(l_index).wip_entity_id ,
6958 p_to_wip_entity_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).wip_entity_id,
6959 p_to_operation_sequence => l_curr_job_op_seq_num ,
6960 p_intraoperation_step_type => l_curr_job_op_step
6961 );
6962
6963 if x_return_status <> G_RET_SUCCESS then
6964 IF x_return_status = G_RET_ERROR THEN
6965 raise FND_API.G_EXC_ERROR;
6966 ELSIF x_return_status = G_RET_UNEXPECTED THEN
6967 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6968 END IF;
6969 END IF;
6970 ELSE
6971 l_stmt_num := 200;
6972 -- ok the rep job..
6973 -- Now the important thing is that check for the job name, if different,
6974 -- a new job would have been created and will have to link the serial numbers to it,.,
6975 -- or else no problems
6976 IF p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).wip_entity_name <> p_starting_jobs_tbl(l_rep_job_index).wip_entity_name THEN
6977 -- In this case invoke the new INV API procedure...
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 => 'Invoking INV_LOT_TRX_VALIDATION_PUB.update_item_serial',
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 INV_LOT_TRX_VALIDATION_PUB.update_item_serial( x_msg_count => x_error_count ,
6990 x_return_status => x_return_status ,
6991 x_msg_data => x_error_msg ,
6992 x_validation_status => l_validation_status ,
6993 p_org_id => p_organization_id ,
6994 p_item_id => l_inventory_item_id ,
6995 p_to_item_id => l_inventory_item_id ,
6996 p_wip_entity_id => l_wip_entity_id ,
6997 p_to_wip_entity_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).wip_entity_id,
6998 p_to_operation_sequence => l_curr_job_op_seq_num ,
6999 p_intraoperation_step_type => l_curr_job_op_step
7000 );
7001
7002 IF x_return_status <> G_RET_SUCCESS THEN
7003 IF x_return_status = G_RET_ERROR THEN
7004 raise FND_API.G_EXC_ERROR;
7005 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7006 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7007 END IF;
7008 END IF;
7009
7010 -- If the parent is serial tracked then all child jobs will also be serial tracked...
7011 IF l_serial_start_flag IS NOT NULL THEN
7012 update wip_discrete_jobs
7013 set serialization_start_op = 10
7014 where wip_entity_id in (select wip_entity_id
7015 from wsm_sm_resulting_jobs
7016 where transaction_id = p_txn_id);
7017
7018 -- We set the first_serial_txn_id to NULL as some code depends on it.. in Move
7019 update wsm_lot_based_jobs
7020 set first_serial_txn_id = -1
7021 where wip_entity_id in (select wip_entity_id
7022 from wsm_sm_resulting_jobs
7023 where transaction_id = p_txn_id);
7024 END IF;
7025 END IF;
7026
7027 END IF;
7028
7029 l_index := p_starting_jobs_tbl.next(l_index);
7030
7031 END LOOP;
7032
7033 ELSIF p_wlt_txn_type = WSMPCNST.UPDATE_ASSEMBLY THEN -- Update Assembly transaction
7034
7035 l_stmt_num := 210;
7036 -- Now the main processing part starts...
7037 if g_wms_installed IS NULL THEN
7038
7039 wms_installed ( x_return_status => x_return_status ,
7040 x_error_count => x_error_count ,
7041 x_err_data => x_error_msg
7042 );
7043
7044 if x_return_status <> G_RET_SUCCESS then
7045 IF x_return_status = G_RET_ERROR THEN
7046 raise FND_API.G_EXC_ERROR;
7047 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7048 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7049 END IF;
7050 end if;
7051 end if;
7052
7053 l_stmt_num := 220;
7054 IF g_wms_installed = 1 then
7055
7056 l_parent_job_ser_context := null;
7057
7058 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_parent_job_ser_context ,
7059 org_id => p_organization_id ,
7060 item_id => p_starting_jobs_tbl(p_starting_jobs_tbl.first).primary_item_id,
7061 flex_name => 'Serial Attributes'
7062 );
7063 l_context := null;
7064
7065 INV_LOT_SEL_ATTR.get_context_code ( context_value => l_context ,
7066 org_id => p_organization_id ,
7067 item_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).primary_item_id,
7068 flex_name => 'Serial Attributes'
7069 );
7070
7071 --
7072 if nvl(l_context,'&#') <> nvl(l_parent_job_ser_context,'&#') THEN
7073 -- populate a warning message...
7074 IF g_log_level_exception >= l_log_level OR
7075 FND_MSG_PUB.check_msg_level(G_MSG_LVL_DEBUG_HIGH)
7076 THEN
7077
7078 l_msg_tokens.delete;
7079 l_msg_tokens(1).TokenName := 'JOB';
7080 l_msg_tokens(1).TokenValue := p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name;
7081
7082 WSM_log_PVT.logMessage(p_module_name => l_module ,
7083 p_msg_name => 'WSM_SERIAL_CLEAR_ATTR' ,
7084 p_msg_appl_name => 'WSM' ,
7085 p_msg_tokens => l_msg_tokens ,
7086 p_fnd_msg_level => G_MSG_LVL_SUCCESS ,
7087 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7088 p_run_log_level => l_log_level ,
7089 p_wsm_warning => 1
7090 );
7091 END IF;
7092
7093 -- Clearing of the serial attributes will be taken care by the INV API being called..
7094 end if;
7095 END IF;
7096
7097 l_stmt_num := 230;
7098 -- Invoke the new INV API procedure...
7099 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7100 l_msg_tokens.delete;
7101 WSM_log_PVT.logMessage (p_module_name => l_module ,
7102 p_msg_text => 'Invoking INV_LOT_TRX_VALIDATION_PUB.update_item_serial',
7103 p_stmt_num => l_stmt_num ,
7104 p_msg_tokens => l_msg_tokens ,
7105 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7106 p_run_log_level => l_log_level
7107 );
7108 END IF;
7109
7110 INV_LOT_TRX_VALIDATION_PUB.update_item_serial( x_msg_count => x_error_count ,
7111 x_return_status => x_return_status ,
7112 x_msg_data => x_error_msg ,
7113 x_validation_status => l_validation_status ,
7114 p_org_id => p_organization_id ,
7115 p_item_id => l_inventory_item_id ,
7116 p_to_item_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).primary_item_id ,
7117 p_wip_entity_id => l_wip_entity_id ,
7118 p_to_wip_entity_id => l_wip_entity_id ,
7119 p_to_operation_sequence => l_curr_job_op_seq_num ,
7120 p_intraoperation_step_type => l_curr_job_op_step
7121 );
7122
7123 if x_return_status <> G_RET_SUCCESS then
7124 IF x_return_status = G_RET_ERROR THEN
7125 raise FND_API.G_EXC_ERROR;
7126 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7127 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7128 END IF;
7129 end if;
7130
7131 l_stmt_num := 240;
7132 Insert_into_WST ( p_transaction_id => p_txn_id ,
7133 p_transaction_type_id => WSMPCNST.UPDATE_ASSEMBLY ,
7134 p_old_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7135 p_new_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7136 p_wip_entity_id => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_id ,
7137 p_organization_id => p_organization_id ,
7138 p_item_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).primary_item_id ,
7139 x_return_status => x_return_status ,
7140 x_error_msg => x_error_msg ,
7141 x_error_count => x_error_count
7142 );
7143
7144 if x_return_status <> G_RET_SUCCESS then
7145 IF x_return_status = G_RET_ERROR THEN
7146 raise FND_API.G_EXC_ERROR;
7147 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7148 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7149 END IF;
7150 end if;
7151
7152 ELSIF p_wlt_txn_type = WSMPCNST.UPDATE_ROUTING THEN -- Update Routing transaction
7153
7154 l_stmt_num := 250;
7155
7156 -- Invoke the new INV API procedure...
7157 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7158 l_msg_tokens.delete;
7159 WSM_log_PVT.logMessage (p_module_name => l_module ,
7160 p_msg_text => 'Invoking INV_LOT_TRX_VALIDATION_PUB.update_item_serial',
7161 p_stmt_num => l_stmt_num ,
7162 p_msg_tokens => l_msg_tokens ,
7163 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7164 p_run_log_level => l_log_level
7165 );
7166 END IF;
7167
7168 INV_LOT_TRX_VALIDATION_PUB.update_item_serial( x_msg_count => x_error_count ,
7169 x_return_status => x_return_status ,
7170 x_msg_data => x_error_msg ,
7171 x_validation_status => l_validation_status ,
7172 p_org_id => p_organization_id ,
7173 p_item_id => l_inventory_item_id ,
7174 p_to_item_id => l_inventory_item_id ,
7175 p_wip_entity_id => l_wip_entity_id ,
7176 p_to_wip_entity_id => l_wip_entity_id ,
7177 p_to_operation_sequence => l_curr_job_op_seq_num ,
7178 p_intraoperation_step_type => l_curr_job_op_step
7179 );
7180
7181 if x_return_status <> G_RET_SUCCESS then
7182 IF x_return_status = G_RET_ERROR THEN
7183 raise FND_API.G_EXC_ERROR;
7184 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7185 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7186 END IF;
7187 end if;
7188
7189 l_stmt_num := 260;
7190 -- Invoke the call to insert into the new table...
7191 Insert_into_WST ( p_transaction_id => p_txn_id ,
7192 p_transaction_type_id => WSMPCNST.UPDATE_ROUTING ,
7193 p_old_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7194 p_new_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7195 p_wip_entity_id => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_id ,
7196 p_organization_id => p_organization_id ,
7197 p_item_id => l_inventory_item_id ,
7198 x_return_status => x_return_status ,
7199 x_error_msg => x_error_msg ,
7200 x_error_count => x_error_count
7201 );
7202
7203 if x_return_status <> G_RET_SUCCESS then
7204 IF x_return_status = G_RET_ERROR THEN
7205 raise FND_API.G_EXC_ERROR;
7206 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7207 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7208 END IF;
7209 end if;
7210
7211 ELSIF p_wlt_txn_type = WSMPCNST.UPDATE_LOT_NAME THEN -- Update Lot Name transaction
7212
7213 l_stmt_num := 270;
7214 Insert_into_WST ( p_transaction_id => p_txn_id ,
7215 p_transaction_type_id => WSMPCNST.UPDATE_ROUTING ,
7216 p_old_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7217 p_new_wip_entity_name => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).wip_entity_name ,
7218 p_wip_entity_id => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_id ,
7219 p_organization_id => p_organization_id ,
7220 p_item_id => l_inventory_item_id ,
7221 x_return_status => x_return_status ,
7222 x_error_msg => x_error_msg ,
7223 x_error_count => x_error_count
7224 );
7225
7226 if x_return_status <> G_RET_SUCCESS then
7227 IF x_return_status = G_RET_ERROR THEN
7228 raise FND_API.G_EXC_ERROR;
7229 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7230 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7231 END IF;
7232 end if;
7233
7234 ELSIF p_wlt_txn_type = WSMPCNST.UPDATE_QUANTITY THEN -- Update Quantity transaction
7235
7236 l_stmt_num := 280;
7237 IF l_serial_start_flag IS NULL then
7238
7239 l_stmt_num := 290;
7240 IF p_serial_num_tbl.count > 0 THEN
7241 -- error out...
7242 IF g_log_level_error >= l_log_level OR
7243 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7244 THEN
7245
7246 l_msg_tokens.delete;
7247 WSM_log_PVT.logMessage(p_module_name => l_module ,
7248 p_msg_name => 'WSM_UPD_QTY_REC_IGNORE' ,
7249 p_msg_appl_name => 'WSM' ,
7250 p_msg_tokens => l_msg_tokens ,
7251 p_stmt_num => l_stmt_num ,
7252 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7253 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7254 p_run_log_level => l_log_level
7255 );
7256 END IF;
7257 RAISE FND_API.G_EXC_ERROR;
7258 ELSE
7259 -- ST : Fix for bug 5143373
7260 -- Insert the existing serials...
7261 Insert_into_WST ( p_transaction_id => p_txn_id ,
7262 p_transaction_type_id => WSMPCNST.UPDATE_QUANTITY ,
7263 p_old_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7264 p_new_wip_entity_name => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_name ,
7265 p_wip_entity_id => p_starting_jobs_tbl(p_starting_jobs_tbl.first).wip_entity_id ,
7266 p_organization_id => p_organization_id ,
7267 p_item_id => p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).primary_item_id ,
7268 x_return_status => x_return_status ,
7269 x_error_msg => x_error_msg ,
7270 x_error_count => x_error_count
7271 );
7272
7273 if x_return_status <> G_RET_SUCCESS then
7274 IF x_return_status = G_RET_ERROR THEN
7275 raise FND_API.G_EXC_ERROR;
7276 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7277 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7278 END IF;
7279 end if;
7280 -- ST : Fix for bug 5143373 end --
7281 return;
7282 END IF;
7283 END IF;
7284
7285 l_stmt_num := 300;
7286 -- You will have records only thru the interface..
7287 -- Forms will be handled in the code itself ...
7288 -- Also records will be considered only for a serial tracked job...
7289 -- invoke process_serial_info
7290 IF p_serial_num_tbl.count > 0 THEN
7291 process_serial_info( p_calling_mode => p_calling_mode ,
7292 p_wsm_serial_nums_tbl => p_serial_num_tbl ,
7293 p_wip_entity_id => l_wip_entity_id ,
7294 p_serial_start_flag => l_serial_start_flag ,
7295 p_organization_id => p_organization_id ,
7296 p_item_id => l_inventory_item_id ,
7297 p_wlt_upd_qty_txn => 1 ,
7298 p_operation_seq_num => l_curr_job_op_seq_num ,
7299 p_intraoperation_step => l_curr_job_op_step ,
7300 x_serial_tbl => l_serial_tbl ,
7301 x_return_status => x_return_status ,
7302 x_error_msg => x_error_msg ,
7303 x_error_count => x_error_count
7304 );
7305
7306 l_stmt_num := 320;
7307 if x_return_status <> G_RET_SUCCESS then
7308 IF x_return_status = G_RET_ERROR THEN
7309 raise FND_API.G_EXC_ERROR;
7310 ELSIF x_return_status = G_RET_UNEXPECTED THEN
7311 raise FND_API.G_EXC_UNEXPECTED_ERROR;
7312 END IF;
7313 end if;
7314 END IF;
7315
7316 l_stmt_num := 330;
7317 select count(*)
7318 into l_serial_num_count
7319 -- ST : Fix for bug 4910758 (remove usage of wsm_job_serial_numbers_v)
7320 -- from wsm_job_serial_numbers_v
7321 from mtl_serial_numbers
7322 where inventory_item_id = l_inventory_item_id
7323 and wip_entity_id = l_wip_entity_id
7324 and nvl(intraoperation_step_type,-1) <> 5;
7325
7326 l_stmt_num := 340;
7327
7328 IF l_serial_num_count <> p_resulting_jobs_tbl(p_resulting_jobs_tbl.first).start_quantity then
7329 -- error out..
7330 IF g_log_level_error >= l_log_level OR
7331 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7332 THEN
7333
7334 l_msg_tokens.delete;
7335 WSM_log_PVT.logMessage(p_module_name => l_module ,
7336 p_msg_name => 'WSM_INVALID_SERIAL_TRACK_QTY',
7337 p_msg_appl_name => 'WSM' ,
7338 p_msg_tokens => l_msg_tokens ,
7339 p_stmt_num => l_stmt_num ,
7340 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7341 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7342 p_run_log_level => l_log_level
7343 );
7344 END IF;
7345 RAISE FND_API.G_EXC_ERROR;
7346 END IF;
7347
7348 l_stmt_num := 350;
7349
7350 IF l_serial_tbl.count > 0 THEN
7351 -- Insert the new serial numbers...
7352 forall l_cntr IN l_serial_tbl.first..l_serial_tbl.last
7353 insert into wsm_serial_transactions
7354 (transaction_id ,
7355 transaction_type_id ,
7356 serial_number ,
7357 gen_object_id ,
7358 current_wip_entity_name ,
7359 changed_wip_entity_name ,
7360 current_wip_entity_id ,
7361 changed_wip_entity_id ,
7362 created_by ,
7363 last_update_date ,
7364 last_updated_by ,
7365 creation_date ,
7366 last_update_login ,
7367 request_id ,
7368 program_application_id ,
7369 program_id ,
7370 program_update_date ,
7371 original_system_reference
7372 )
7373 select
7374 p_txn_id ,
7375 3 ,
7376 l_serial_tbl(l_cntr) ,
7377 gen_object_id ,
7378 null ,
7379 l_wip_entity_name ,
7380 null ,
7381 l_wip_entity_id ,
7382 g_user_id ,
7383 sysdate ,
7384 g_user_id ,
7385 sysdate ,
7386 g_user_login_id ,
7387 g_request_id ,
7388 g_program_appl_id ,
7389 g_program_id ,
7390 sysdate ,
7391 null
7392 from mtl_serial_numbers
7393 where serial_number = l_serial_tbl(l_cntr)
7394 and inventory_item_id = l_inventory_item_id
7395 and current_organization_id = p_organization_id;
7396 END IF;
7397
7398 -- Insert the old serial numbers...
7399 IF l_serial_num_count > 0 THEN
7400 -- Insert...
7401 insert into wsm_serial_transactions
7402 (transaction_id ,
7403 transaction_type_id ,
7404 serial_number ,
7405 gen_object_id ,
7406 current_wip_entity_name ,
7407 current_wip_entity_id ,
7408 changed_wip_entity_name ,
7409 changed_wip_entity_id ,
7410 created_by ,
7411 last_update_date ,
7412 last_updated_by ,
7413 creation_date ,
7414 last_update_login ,
7415 request_id ,
7416 program_application_id ,
7417 program_id ,
7418 program_update_date ,
7419 original_system_reference
7420 )
7421 select
7422 p_txn_id ,
7423 3 ,
7424 serial_number ,
7425 gen_object_id ,
7426 l_wip_entity_name ,
7427 l_wip_entity_id ,
7428 l_wip_entity_name ,
7429 l_wip_entity_id ,
7430 g_user_id ,
7431 sysdate ,
7432 g_user_id ,
7433 sysdate ,
7434 g_user_login_id ,
7435 g_request_id ,
7436 g_program_appl_id ,
7437 g_program_id ,
7438 sysdate ,
7439 null
7440 from mtl_serial_numbers
7441 where inventory_item_id = l_inventory_item_id
7442 and current_organization_id = p_organization_id
7443 and wip_entity_id = l_wip_entity_id
7444 and nvl(intraoperation_step_type,-1) <> 5
7445 and serial_number NOT IN (select serial_number
7446 from wsm_serial_transactions
7447 where transaction_type_id = 3
7448 and transaction_id = p_txn_id);
7449 END IF;
7450
7451 END IF;
7452
7453 EXCEPTION
7454 WHEN FND_API.G_EXC_ERROR THEN
7455 ROLLBACK to WLT_serial_proc;
7456 x_return_status := G_RET_ERROR;
7457 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7458 p_count => x_error_count ,
7459 p_data => x_error_msg
7460 );
7461
7462 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7463 ROLLBACK to WLT_serial_proc;
7464 x_return_status := G_RET_UNEXPECTED;
7465
7466 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7467 p_count => x_error_count ,
7468 p_data => x_error_msg
7469 );
7470 WHEN OTHERS THEN
7471 ROLLBACK to WLT_serial_proc;
7472 x_return_status := G_RET_UNEXPECTED;
7473
7474 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7475 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7476 THEN
7477 WSM_log_PVT.handle_others( p_module_name => l_module ,
7478 p_stmt_num => l_stmt_num ,
7479 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7480 p_run_log_level => l_log_level
7481 );
7482 END IF;
7483
7484 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7485 p_count => x_error_count ,
7486 p_data => x_error_msg
7487 );
7488
7489 END WLT_serial_processor;
7490
7491 PROCEDURE validate_qty ( p_primary_item_id IN NUMBER,
7492 p_organization_id IN NUMBER,
7493 p_primary_qty IN NUMBER,
7494 p_net_qty IN NUMBER,
7495 p_primary_uom IN VARCHAR2,
7496 p_transaction_qty IN NUMBER DEFAULT NULL,
7497 p_transaction_uom IN VARCHAR2 DEFAULT NULL,
7498 x_return_status OUT NOCOPY VARCHAR2,
7499 x_error_count OUT NOCOPY NUMBER,
7500 x_error_msg OUT NOCOPY VARCHAR2
7501 )
7502
7503 IS
7504 l_serial_cntrl_code NUMBER;
7505 l_conv_rate NUMBER;
7506 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
7507 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7508
7509 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.validate_qty';
7510 l_stmt_num NUMBER;
7511
7512 BEGIN
7513 x_return_status := G_RET_SUCCESS;
7514 x_error_msg := NULL;
7515 x_error_count := 0;
7516
7517 l_stmt_num := 10;
7518
7519 IF p_primary_item_id IS NULL or p_organization_id IS NULL THEN
7520 return;
7521 END IF;
7522
7523 l_stmt_num := 20;
7524
7525 SELECT NVL(SERIAL_NUMBER_CONTROL_CODE,1)
7526 INTO l_serial_cntrl_code
7527 FROM MTL_SYSTEM_ITEMS
7528 WHERE inventory_item_id = p_primary_item_id
7529 AND organization_id = p_organization_id;
7530
7531 IF l_serial_cntrl_code <> 2 THEN
7532 return;
7533 END IF;
7534
7535 l_stmt_num := 30;
7536
7537 IF (p_primary_qty IS NOT NULL and
7538 floor(p_primary_qty) <> p_primary_qty)
7539 OR
7540 (p_net_qty IS NOT NULL and
7541 floor(p_net_qty) <> p_net_qty)
7542 THEN
7543
7544 IF g_log_level_error >= l_log_level OR
7545 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7546 THEN
7547
7548 l_msg_tokens.delete;
7549 WSM_log_PVT.logMessage(p_module_name => l_module ,
7550 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
7551 p_msg_appl_name => 'WSM' ,
7552 p_msg_tokens => l_msg_tokens ,
7553 p_stmt_num => l_stmt_num ,
7554 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7555 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7556 p_run_log_level => l_log_level
7557 );
7558 END IF;
7559 RAISE FND_API.G_EXC_ERROR;
7560
7561 END IF;
7562
7563
7564 l_stmt_num := 50;
7565
7566 IF p_transaction_qty IS NOT NULL THEN
7567
7568 IF floor(p_transaction_qty) <> p_transaction_qty THEN
7569
7570 IF g_log_level_error >= l_log_level OR
7571 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7572 THEN
7573
7574 l_msg_tokens.delete;
7575 WSM_log_PVT.logMessage(p_module_name => l_module ,
7576 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
7577 p_msg_appl_name => 'WSM' ,
7578 p_msg_tokens => l_msg_tokens ,
7579 p_stmt_num => l_stmt_num ,
7580 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7581 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7582 p_run_log_level => l_log_level
7583 );
7584 END IF;
7585 RAISE FND_API.G_EXC_ERROR;
7586
7587 END IF;
7588
7589 l_stmt_num := 60;
7590
7591 -- get the conversion rate....
7592 l_conv_rate := inv_convert.inv_um_convert(item_id => p_primary_qty,
7593 precision => WIP_CONSTANTS.MAX_NUMBER_PRECISION,
7594 from_quantity => 1,
7595 from_unit => p_transaction_uom,
7596 to_unit => p_primary_uom,
7597 from_name => NULL,
7598 to_name => NULL);
7599
7600 IF l_conv_rate = -99999 THEN
7601
7602 IF g_log_level_error >= l_log_level OR
7603 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7604 THEN
7605
7606 l_msg_tokens.delete;
7607 WSM_log_PVT.logMessage(p_module_name => l_module ,
7608 p_msg_name => 'WSM_UOM_CONVERSION_FAILED',
7609 p_msg_appl_name => 'WSM' ,
7610 p_msg_tokens => l_msg_tokens ,
7611 p_stmt_num => l_stmt_num ,
7612 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7613 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7614 p_run_log_level => l_log_level
7615 );
7616 END IF;
7617 RAISE FND_API.G_EXC_ERROR;
7618
7619 END IF;
7620
7621 l_stmt_num := 70;
7622
7623 IF ( floor(round(l_conv_rate * p_transaction_qty, WIP_CONSTANTS.MAX_NUMBER_PRECISION))
7624 <>
7625 round(l_conv_rate * p_transaction_qty, WIP_CONSTANTS.MAX_NUMBER_PRECISION)
7626 )
7627 THEN
7628
7629 IF g_log_level_error >= l_log_level OR
7630 FND_MSG_PUB.check_msg_level(G_MSG_LVL_ERROR)
7631 THEN
7632
7633 l_msg_tokens.delete;
7634 WSM_log_PVT.logMessage(p_module_name => l_module ,
7635 p_msg_name => 'WSM_INVALID_JOB_TXN_QTY',
7636 p_msg_appl_name => 'WSM' ,
7637 p_msg_tokens => l_msg_tokens ,
7638 p_stmt_num => l_stmt_num ,
7639 p_fnd_msg_level => G_MSG_LVL_ERROR ,
7640 p_fnd_log_level => G_LOG_LEVEL_ERROR ,
7641 p_run_log_level => l_log_level
7642 );
7643 END IF;
7644 RAISE FND_API.G_EXC_ERROR;
7645
7646 END IF;
7647 END IF;
7648
7649 l_stmt_num := 80;
7650
7651 EXCEPTION
7652
7653 WHEN FND_API.G_EXC_ERROR THEN
7654
7655 x_return_status := G_RET_ERROR;
7656 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7657 p_count => x_error_count ,
7658 p_data => x_error_msg
7659 );
7660
7661 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7662
7663 x_return_status := G_RET_UNEXPECTED;
7664
7665 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7666 p_count => x_error_count ,
7667 p_data => x_error_msg
7668 );
7669 WHEN OTHERS THEN
7670
7671 x_return_status := G_RET_UNEXPECTED;
7672
7673 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
7674 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
7675 THEN
7676 WSM_log_PVT.handle_others( p_module_name => l_module ,
7677 p_stmt_num => l_stmt_num ,
7678 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
7679 p_run_log_level => l_log_level
7680 );
7681 END IF;
7682
7683 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
7684 p_count => x_error_count ,
7685 p_data => x_error_msg
7686 );
7687
7688 END validate_qty;
7689
7690 -- group id on wip_move_txn_interface will be passed
7691 Procedure Insert_move_attr ( p_group_id IN NUMBER DEFAULT NULL,
7692 p_move_txn_id IN NUMBER DEFAULT NULL,
7693 p_scrap_txn_id IN NUMBER DEFAULT NULL,
7694 x_return_status OUT NOCOPY VARCHAR2,
7695 x_error_count OUT NOCOPY NUMBER,
7696 x_error_msg OUT NOCOPY VARCHAR2
7697 )
7698
7699 IS
7700 -- Logging variables.....
7701 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
7702 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7703
7704 l_stmt_num NUMBER;
7705 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Insert_move_attr';
7706 l_param_tbl WSM_Log_PVT.param_tbl_type;
7707 -- Logging variables...
7708
7709 BEGIN
7710 x_return_status := G_RET_SUCCESS;
7711 x_error_msg := NULL;
7712 x_error_count := 0;
7713
7714 l_stmt_num := 10;
7715
7716 -- This procedure is no longer used....
7717 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
7718 l_stmt_num := 15;
7719 l_param_tbl.delete;
7720 l_param_tbl(1).paramName := 'p_move_txn_id';
7721 l_param_tbl(1).paramValue := p_move_txn_id;
7722
7723 l_param_tbl(2).paramName := 'p_scrap_txn_id';
7724 l_param_tbl(2).paramValue := p_scrap_txn_id;
7725
7726 l_param_tbl(3).paramName := 'p_group_id';
7727 l_param_tbl(3).paramValue := p_group_id;
7728
7729
7730 WSM_Log_PVT.logProcParams(p_module_name => l_module ,
7731 p_param_tbl => l_param_tbl,
7732 p_fnd_log_level => l_log_level
7733 );
7734 END IF;
7735
7736 IF p_group_id IS NOT NULL THEN
7737
7738 l_stmt_num := 20;
7739
7740 -- We are having a direct insert because
7741 -- this procedure will be invoked for a batch of move txn records each belonging to a distinct job
7742 insert into wsm_serial_txn_interface
7743 (
7744 HEADER_ID ,
7745 TRANSACTION_TYPE_ID ,
7746 SERIAL_NUMBER ,
7747 ASSEMBLY_ITEM_ID ,
7748 GENERATE_SERIAL_NUMBER ,
7749 GENERATE_FOR_QTY ,
7750 ACTION_FLAG ,
7751 CURRENT_WIP_ENTITY_NAME ,
7752 CHANGED_WIP_ENTITY_NAME ,
7753 CURRENT_WIP_ENTITY_ID ,
7754 CHANGED_WIP_ENTITY_ID ,
7755 SERIAL_ATTRIBUTE_CATEGORY ,
7756 TERRITORY_CODE ,
7757 ORIGINATION_DATE ,
7758 C_ATTRIBUTE1 ,
7759 C_ATTRIBUTE2 ,
7760 C_ATTRIBUTE3 ,
7761 C_ATTRIBUTE4 ,
7762 C_ATTRIBUTE5 ,
7763 C_ATTRIBUTE6 ,
7764 C_ATTRIBUTE7 ,
7765 C_ATTRIBUTE8 ,
7766 C_ATTRIBUTE9 ,
7767 C_ATTRIBUTE10 ,
7768 C_ATTRIBUTE11 ,
7769 C_ATTRIBUTE12 ,
7770 C_ATTRIBUTE13 ,
7771 C_ATTRIBUTE14 ,
7772 C_ATTRIBUTE15 ,
7773 C_ATTRIBUTE16 ,
7774 C_ATTRIBUTE17 ,
7775 C_ATTRIBUTE18 ,
7776 C_ATTRIBUTE19 ,
7777 C_ATTRIBUTE20 ,
7778 D_ATTRIBUTE1 ,
7779 D_ATTRIBUTE2 ,
7780 D_ATTRIBUTE3 ,
7781 D_ATTRIBUTE4 ,
7782 D_ATTRIBUTE5 ,
7783 D_ATTRIBUTE6 ,
7784 D_ATTRIBUTE7 ,
7785 D_ATTRIBUTE8 ,
7786 D_ATTRIBUTE9 ,
7787 D_ATTRIBUTE10 ,
7788 N_ATTRIBUTE1 ,
7789 N_ATTRIBUTE2 ,
7790 N_ATTRIBUTE3 ,
7791 N_ATTRIBUTE4 ,
7792 N_ATTRIBUTE5 ,
7793 N_ATTRIBUTE6 ,
7794 N_ATTRIBUTE7 ,
7795 N_ATTRIBUTE8 ,
7796 N_ATTRIBUTE9 ,
7797 N_ATTRIBUTE10 ,
7798 STATUS_ID ,
7799 TIME_SINCE_NEW ,
7800 CYCLES_SINCE_NEW ,
7801 TIME_SINCE_OVERHAUL ,
7802 CYCLES_SINCE_OVERHAUL ,
7803 TIME_SINCE_REPAIR ,
7804 CYCLES_SINCE_REPAIR ,
7805 TIME_SINCE_VISIT ,
7806 CYCLES_SINCE_VISIT ,
7807 TIME_SINCE_MARK ,
7808 CYCLES_SINCE_MARK ,
7809 NUMBER_OF_REPAIRS ,
7810 ATTRIBUTE_CATEGORY ,
7811 ATTRIBUTE1 ,
7812 ATTRIBUTE2 ,
7813 ATTRIBUTE3 ,
7814 ATTRIBUTE4 ,
7815 ATTRIBUTE5 ,
7816 ATTRIBUTE6 ,
7817 ATTRIBUTE7 ,
7818 ATTRIBUTE8 ,
7819 ATTRIBUTE9 ,
7820 ATTRIBUTE10 ,
7821 ATTRIBUTE11 ,
7822 ATTRIBUTE12 ,
7823 ATTRIBUTE13 ,
7824 ATTRIBUTE14 ,
7825 ATTRIBUTE15 ,
7826 CREATED_BY ,
7827 LAST_UPDATE_DATE ,
7828 LAST_UPDATED_BY ,
7829 CREATION_DATE ,
7830 LAST_UPDATE_LOGIN ,
7831 REQUEST_ID ,
7832 PROGRAM_APPLICATION_ID ,
7833 PROGRAM_ID ,
7834 PROGRAM_UPDATE_DATE ,
7835 ORIGINAL_SYSTEM_REFERENCE
7836 )
7837 Select
7838 WMTI.transaction_id ,
7839 5 , -- for internal use... 5 for Attributes updation..
7840 MSN.SERIAL_NUMBER ,
7841 WMTI.primary_item_id ,
7842 null ,
7843 null ,
7844 null ,
7845 null ,
7846 null ,
7847 WMTI.WIP_ENTITY_ID ,
7848 null ,
7849 MSN.SERIAL_ATTRIBUTE_CATEGORY ,
7850 MSN.TERRITORY_CODE ,
7851 MSN.ORIGINATION_DATE ,
7852 MSN.C_ATTRIBUTE1 ,
7853 MSN.C_ATTRIBUTE2 ,
7854 MSN.C_ATTRIBUTE3 ,
7855 MSN.C_ATTRIBUTE4 ,
7856 MSN.C_ATTRIBUTE5 ,
7857 MSN.C_ATTRIBUTE6 ,
7858 MSN.C_ATTRIBUTE7 ,
7859 MSN.C_ATTRIBUTE8 ,
7860 MSN.C_ATTRIBUTE9 ,
7861 MSN.C_ATTRIBUTE10 ,
7862 MSN.C_ATTRIBUTE11 ,
7863 MSN.C_ATTRIBUTE12 ,
7864 MSN.C_ATTRIBUTE13 ,
7865 MSN.C_ATTRIBUTE14 ,
7866 MSN.C_ATTRIBUTE15 ,
7867 MSN.C_ATTRIBUTE16 ,
7868 MSN.C_ATTRIBUTE17 ,
7869 MSN.C_ATTRIBUTE18 ,
7870 MSN.C_ATTRIBUTE19 ,
7871 MSN.C_ATTRIBUTE20 ,
7872 MSN.D_ATTRIBUTE1 ,
7873 MSN.D_ATTRIBUTE2 ,
7874 MSN.D_ATTRIBUTE3 ,
7875 MSN.D_ATTRIBUTE4 ,
7876 MSN.D_ATTRIBUTE5 ,
7877 MSN.D_ATTRIBUTE6 ,
7878 MSN.D_ATTRIBUTE7 ,
7879 MSN.D_ATTRIBUTE8 ,
7880 MSN.D_ATTRIBUTE9 ,
7881 MSN.D_ATTRIBUTE10 ,
7882 MSN.N_ATTRIBUTE1 ,
7883 MSN.N_ATTRIBUTE2 ,
7884 MSN.N_ATTRIBUTE3 ,
7885 MSN.N_ATTRIBUTE4 ,
7886 MSN.N_ATTRIBUTE5 ,
7887 MSN.N_ATTRIBUTE6 ,
7888 MSN.N_ATTRIBUTE7 ,
7889 MSN.N_ATTRIBUTE8 ,
7890 MSN.N_ATTRIBUTE9 ,
7891 MSN.N_ATTRIBUTE10 ,
7892 MSN.STATUS_ID ,
7893 MSN.TIME_SINCE_NEW ,
7894 MSN.CYCLES_SINCE_NEW ,
7895 MSN.TIME_SINCE_OVERHAUL ,
7896 MSN.CYCLES_SINCE_OVERHAUL ,
7897 MSN.TIME_SINCE_REPAIR ,
7898 MSN.CYCLES_SINCE_REPAIR ,
7899 MSN.TIME_SINCE_VISIT ,
7900 MSN.CYCLES_SINCE_VISIT ,
7901 MSN.TIME_SINCE_MARK ,
7902 MSN.CYCLES_SINCE_MARK ,
7903 MSN.NUMBER_OF_REPAIRS ,
7904 MSN.ATTRIBUTE_CATEGORY ,
7905 MSN.ATTRIBUTE1 ,
7906 MSN.ATTRIBUTE2 ,
7907 MSN.ATTRIBUTE3 ,
7908 MSN.ATTRIBUTE4 ,
7909 MSN.ATTRIBUTE5 ,
7910 MSN.ATTRIBUTE6 ,
7911 MSN.ATTRIBUTE7 ,
7912 MSN.ATTRIBUTE8 ,
7913 MSN.ATTRIBUTE9 ,
7914 MSN.ATTRIBUTE10 ,
7915 MSN.ATTRIBUTE11 ,
7916 MSN.ATTRIBUTE12 ,
7917 MSN.ATTRIBUTE13 ,
7918 MSN.ATTRIBUTE14 ,
7919 MSN.ATTRIBUTE15 ,
7920 g_user_id ,
7921 SYSDATE ,
7922 g_user_id ,
7923 SYSDATE ,
7924 g_user_login_id ,
7925 g_request_id ,
7926 g_program_appl_id ,
7927 g_program_id ,
7928 sysdate ,
7929 null
7930 from wip_serial_move_interface WSMI,
7931 mtl_serial_numbers MSN,
7932 wip_move_txn_interface WMTI
7933 where WMTI.group_id = p_group_id
7934 and WMTI.transaction_id = WSMI.transaction_id
7935 and MSN.serial_number = WSMI.assembly_serial_number
7936 and MSN.current_organization_id = WMTI.organization_id
7937 and MSN.inventory_item_id = WMTI.primary_item_id
7938 -- ST : Commenting it out...
7939 -- and MSN.serial_attribute_category IS NOT NULL -- Desc flex fields are not cleared. Only serial attributes
7940 and WMTI.transaction_type IN (2,3); -- Completion/Assembly return
7941
7942 l_stmt_num := 30;
7943 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
7944 l_msg_tokens.delete;
7945 WSM_log_PVT.logMessage (p_module_name => l_module ,
7946 p_msg_text => 'Total Serial Numbers inserted : ' || SQL%ROWCOUNT,
7947 p_stmt_num => l_stmt_num ,
7948 p_msg_tokens => l_msg_tokens ,
7949 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
7950 p_run_log_level => l_log_level
7951 );
7952 END IF;
7953 ELSE
7954 l_stmt_num := 40;
7955
7956 insert into wsm_serial_txn_temp
7957 (
7958 HEADER_ID ,
7959 TRANSACTION_TYPE_ID ,
7960 SERIAL_NUMBER ,
7961 ASSEMBLY_ITEM_ID ,
7962 GENERATE_SERIAL_NUMBER ,
7963 GENERATE_FOR_QTY ,
7964 ACTION_FLAG ,
7965 CURRENT_WIP_ENTITY_NAME ,
7966 CHANGED_WIP_ENTITY_NAME ,
7967 CURRENT_WIP_ENTITY_ID ,
7968 CHANGED_WIP_ENTITY_ID ,
7969 SERIAL_ATTRIBUTE_CATEGORY ,
7970 TERRITORY_CODE ,
7971 ORIGINATION_DATE ,
7972 C_ATTRIBUTE1 ,
7973 C_ATTRIBUTE2 ,
7974 C_ATTRIBUTE3 ,
7975 C_ATTRIBUTE4 ,
7976 C_ATTRIBUTE5 ,
7977 C_ATTRIBUTE6 ,
7978 C_ATTRIBUTE7 ,
7979 C_ATTRIBUTE8 ,
7980 C_ATTRIBUTE9 ,
7981 C_ATTRIBUTE10 ,
7982 C_ATTRIBUTE11 ,
7983 C_ATTRIBUTE12 ,
7984 C_ATTRIBUTE13 ,
7985 C_ATTRIBUTE14 ,
7986 C_ATTRIBUTE15 ,
7987 C_ATTRIBUTE16 ,
7988 C_ATTRIBUTE17 ,
7989 C_ATTRIBUTE18 ,
7990 C_ATTRIBUTE19 ,
7991 C_ATTRIBUTE20 ,
7992 D_ATTRIBUTE1 ,
7993 D_ATTRIBUTE2 ,
7994 D_ATTRIBUTE3 ,
7995 D_ATTRIBUTE4 ,
7996 D_ATTRIBUTE5 ,
7997 D_ATTRIBUTE6 ,
7998 D_ATTRIBUTE7 ,
7999 D_ATTRIBUTE8 ,
8000 D_ATTRIBUTE9 ,
8001 D_ATTRIBUTE10 ,
8002 N_ATTRIBUTE1 ,
8003 N_ATTRIBUTE2 ,
8004 N_ATTRIBUTE3 ,
8005 N_ATTRIBUTE4 ,
8006 N_ATTRIBUTE5 ,
8007 N_ATTRIBUTE6 ,
8008 N_ATTRIBUTE7 ,
8009 N_ATTRIBUTE8 ,
8010 N_ATTRIBUTE9 ,
8011 N_ATTRIBUTE10 ,
8012 STATUS_ID ,
8013 TIME_SINCE_NEW ,
8014 CYCLES_SINCE_NEW ,
8015 TIME_SINCE_OVERHAUL ,
8016 CYCLES_SINCE_OVERHAUL ,
8017 TIME_SINCE_REPAIR ,
8018 CYCLES_SINCE_REPAIR ,
8019 TIME_SINCE_VISIT ,
8020 CYCLES_SINCE_VISIT ,
8021 TIME_SINCE_MARK ,
8022 CYCLES_SINCE_MARK ,
8023 NUMBER_OF_REPAIRS ,
8024 ATTRIBUTE_CATEGORY ,
8025 ATTRIBUTE1 ,
8026 ATTRIBUTE2 ,
8027 ATTRIBUTE3 ,
8028 ATTRIBUTE4 ,
8029 ATTRIBUTE5 ,
8030 ATTRIBUTE6 ,
8031 ATTRIBUTE7 ,
8032 ATTRIBUTE8 ,
8033 ATTRIBUTE9 ,
8034 ATTRIBUTE10 ,
8035 ATTRIBUTE11 ,
8036 ATTRIBUTE12 ,
8037 ATTRIBUTE13 ,
8038 ATTRIBUTE14 ,
8039 ATTRIBUTE15 ,
8040 CREATED_BY ,
8041 LAST_UPDATE_DATE ,
8042 LAST_UPDATED_BY ,
8043 CREATION_DATE ,
8044 LAST_UPDATE_LOGIN ,
8045 REQUEST_ID ,
8046 PROGRAM_APPLICATION_ID ,
8047 PROGRAM_ID ,
8048 PROGRAM_UPDATE_DATE ,
8049 ORIGINAL_SYSTEM_REFERENCE
8050 )
8051 Select
8052 WMTI.transaction_id ,
8053 5 , -- for internal use... 5 for Attributes updation..
8054 MSN.SERIAL_NUMBER ,
8055 WMTI.primary_item_id ,
8056 null ,
8057 null ,
8058 null ,
8059 null ,
8060 null ,
8061 WMTI.WIP_ENTITY_ID ,
8062 null ,
8063 MSN.SERIAL_ATTRIBUTE_CATEGORY ,
8064 MSN.TERRITORY_CODE ,
8065 MSN.ORIGINATION_DATE ,
8066 MSN.C_ATTRIBUTE1 ,
8067 MSN.C_ATTRIBUTE2 ,
8068 MSN.C_ATTRIBUTE3 ,
8069 MSN.C_ATTRIBUTE4 ,
8070 MSN.C_ATTRIBUTE5 ,
8071 MSN.C_ATTRIBUTE6 ,
8072 MSN.C_ATTRIBUTE7 ,
8073 MSN.C_ATTRIBUTE8 ,
8074 MSN.C_ATTRIBUTE9 ,
8075 MSN.C_ATTRIBUTE10 ,
8076 MSN.C_ATTRIBUTE11 ,
8077 MSN.C_ATTRIBUTE12 ,
8078 MSN.C_ATTRIBUTE13 ,
8079 MSN.C_ATTRIBUTE14 ,
8080 MSN.C_ATTRIBUTE15 ,
8081 MSN.C_ATTRIBUTE16 ,
8082 MSN.C_ATTRIBUTE17 ,
8083 MSN.C_ATTRIBUTE18 ,
8084 MSN.C_ATTRIBUTE19 ,
8085 MSN.C_ATTRIBUTE20 ,
8086 MSN.D_ATTRIBUTE1 ,
8087 MSN.D_ATTRIBUTE2 ,
8088 MSN.D_ATTRIBUTE3 ,
8089 MSN.D_ATTRIBUTE4 ,
8090 MSN.D_ATTRIBUTE5 ,
8091 MSN.D_ATTRIBUTE6 ,
8092 MSN.D_ATTRIBUTE7 ,
8093 MSN.D_ATTRIBUTE8 ,
8094 MSN.D_ATTRIBUTE9 ,
8095 MSN.D_ATTRIBUTE10 ,
8096 MSN.N_ATTRIBUTE1 ,
8097 MSN.N_ATTRIBUTE2 ,
8098 MSN.N_ATTRIBUTE3 ,
8099 MSN.N_ATTRIBUTE4 ,
8100 MSN.N_ATTRIBUTE5 ,
8101 MSN.N_ATTRIBUTE6 ,
8102 MSN.N_ATTRIBUTE7 ,
8103 MSN.N_ATTRIBUTE8 ,
8104 MSN.N_ATTRIBUTE9 ,
8105 MSN.N_ATTRIBUTE10 ,
8106 MSN.STATUS_ID ,
8107 MSN.TIME_SINCE_NEW ,
8108 MSN.CYCLES_SINCE_NEW ,
8109 MSN.TIME_SINCE_OVERHAUL ,
8110 MSN.CYCLES_SINCE_OVERHAUL ,
8111 MSN.TIME_SINCE_REPAIR ,
8112 MSN.CYCLES_SINCE_REPAIR ,
8113 MSN.TIME_SINCE_VISIT ,
8114 MSN.CYCLES_SINCE_VISIT ,
8115 MSN.TIME_SINCE_MARK ,
8116 MSN.CYCLES_SINCE_MARK ,
8117 MSN.NUMBER_OF_REPAIRS ,
8118 MSN.ATTRIBUTE_CATEGORY ,
8119 MSN.ATTRIBUTE1 ,
8120 MSN.ATTRIBUTE2 ,
8121 MSN.ATTRIBUTE3 ,
8122 MSN.ATTRIBUTE4 ,
8123 MSN.ATTRIBUTE5 ,
8124 MSN.ATTRIBUTE6 ,
8125 MSN.ATTRIBUTE7 ,
8126 MSN.ATTRIBUTE8 ,
8127 MSN.ATTRIBUTE9 ,
8128 MSN.ATTRIBUTE10 ,
8129 MSN.ATTRIBUTE11 ,
8130 MSN.ATTRIBUTE12 ,
8131 MSN.ATTRIBUTE13 ,
8132 MSN.ATTRIBUTE14 ,
8133 MSN.ATTRIBUTE15 ,
8134 g_user_id ,
8135 SYSDATE ,
8136 g_user_id ,
8137 SYSDATE ,
8138 g_user_login_id ,
8139 g_request_id ,
8140 g_program_appl_id ,
8141 g_program_id ,
8142 sysdate ,
8143 null
8144 from wip_serial_move_interface WSMI,
8145 mtl_serial_numbers MSN,
8146 wip_move_txn_interface WMTI
8147 where WMTI.transaction_id in (p_move_txn_id,p_scrap_txn_id)
8148 and WMTI.transaction_id = WSMI.transaction_id
8149 and MSN.serial_number = WSMI.assembly_serial_number
8150 and MSN.current_organization_id = WMTI.organization_id
8151 and MSN.inventory_item_id = WMTI.primary_item_id
8152 -- ST : Commenting it out...
8153 -- and MSN.serial_attribute_category IS NOT NULL -- Desc flex fields are not cleared. Only serial attributes
8154 and WMTI.transaction_type IN (2,3); -- Completion/Assembly return
8155
8156 l_stmt_num := 50;
8157 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8158 l_msg_tokens.delete;
8159 WSM_log_PVT.logMessage (p_module_name => l_module ,
8160 p_msg_text => 'Total Serial Numbers inserted : ' || SQL%ROWCOUNT,
8161 p_stmt_num => l_stmt_num ,
8162 p_msg_tokens => l_msg_tokens ,
8163 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8164 p_run_log_level => l_log_level
8165 );
8166 END IF;
8167 END IF;
8168
8169 END Insert_move_attr;
8170
8171 -- Internal group id on wsm_lot_move_txn_interface will be passed
8172 Procedure Update_attr_move ( p_group_id IN NUMBER DEFAULT NULL, -- for interface...
8173 p_internal_group_id IN NUMBER DEFAULT NULL, -- for interface...
8174 p_move_txn_id IN NUMBER DEFAULT NULL, -- for forms...
8175 p_scrap_txn_id IN NUMBER DEFAULT NULL, -- for forms...
8176 p_organization_id IN NUMBER ,
8177 x_return_status OUT NOCOPY VARCHAR2 ,
8178 x_error_count OUT NOCOPY NUMBER ,
8179 x_error_msg OUT NOCOPY VARCHAR2
8180 )
8181
8182 IS
8183 -- This cursor fetches the serials whose op info need to be cleared...but havent been cleared by WIP
8184 -- Possible when the serial tracking doesnt start with the move tranaction's from op seq num as 10 and step as Queue
8185 -- This is because we fill the serial start op as 10 always in WDJ
8186 -- So the reverse doesnt happen (ie) WIP clears the op info when it has to be present as there is
8187 -- no possible step prior to 10 Queue
8188 -- Or it is also possible if a pure scrap transaction triggered the serial tracking.
8189 cursor c_serials_intf is
8190 select msn.serial_number,
8191 msn.inventory_item_id,
8192 msn.current_organization_id,
8193 wmt.wip_entity_id
8194 from mtl_serial_numbers msn,
8195 wip_move_transactions wmt,
8196 wsm_lot_move_txn_interface wlmti,
8197 wsm_lot_based_jobs wlbj
8198 where wlmti.group_id = p_group_id
8199 and wlmti.internal_group_id = p_internal_group_id
8200 and wlmti.wip_entity_id = wmt.wip_entity_id
8201 and wmt.group_id = p_internal_group_id
8202 and wlmti.status = WIP_CONSTANTS.COMPLETED
8203 and wmt.wip_entity_id = wlbj.wip_entity_id
8204 and wlbj.first_serial_txn_id IS NULL
8205 and msn.inventory_item_id = wmt.primary_item_id
8206 and msn.current_organization_id = wmt.organization_id
8207 and msn.wip_entity_id = wmt.wip_entity_id
8208 and msn.operation_seq_num IS NOT NULL;
8209
8210 -- This cursor fetches the serials that shouldnt have been cleared..
8211 cursor c_serials_lot_create_intf is
8212 select msn.serial_number,
8213 msn.inventory_item_id,
8214 msn.current_organization_id,
8215 wdj.wip_entity_id
8216 from mtl_serial_numbers msn,
8217 wsm_lot_move_txn_interface wlmti,
8218 wip_discrete_jobs wdj,
8219 wsm_lot_based_jobs wlbj
8220 where wlmti.group_id = p_group_id
8221 and wlmti.internal_group_id = p_internal_group_id
8222 and wlmti.wip_entity_id = wdj.wip_entity_id
8223 and wlmti.status = WIP_CONSTANTS.COMPLETED
8224 and wdj.wip_entity_id = wlbj.wip_entity_id
8225 and wlbj.first_serial_txn_id = -1 -- It will be set to -1 only for those jobs created through Lot Creation form..
8226 and msn.inventory_item_id = wdj.primary_item_id
8227 and msn.current_organization_id = wdj.organization_id
8228 and msn.wip_entity_id = wdj.wip_entity_id
8229 and msn.operation_seq_num IS NULL; -- This will be set when the jobs created Lot Creation reach operation 10..
8230
8231 -- This cursor fetches the serials whose op info need to be cleared...but havent been cleared by WIP
8232 -- Possible when the serial tracking doesnt start with the move tranaction's from op seq num as 10 and step as Queue
8233 -- Also for pure scrap transactions..
8234 cursor c_serials_form is
8235 select msn.serial_number,
8236 msn.inventory_item_id,
8237 msn.current_organization_id,
8238 wmt.wip_entity_id
8239 from mtl_serial_numbers msn,
8240 wip_move_transactions wmt,
8241 wsm_lot_based_jobs wlbj
8242 where wmt.transaction_id in (p_move_txn_id, p_scrap_txn_id)
8243 and wmt.wip_entity_id = wlbj.wip_entity_id
8244 and wlbj.first_serial_txn_id IS NULL
8245 and msn.inventory_item_id = wmt.primary_item_id
8246 and msn.current_organization_id = wmt.organization_id
8247 and msn.wip_entity_id = wmt.wip_entity_id
8248 and msn.operation_seq_num IS NOT NULL;
8249
8250 -- This cursor is for jobs created through Lot Creation which will remain serial tracked throughout...
8251 cursor c_serials_lot_create_form is
8252 select msn.serial_number,
8253 msn.inventory_item_id,
8254 msn.current_organization_id,
8255 wmt.wip_entity_id
8256 from mtl_serial_numbers msn,
8257 wip_move_transactions wmt,
8258 wip_serial_move_transactions wsmt,
8259 wsm_lot_based_jobs wlbj
8260 where wmt.transaction_id in (p_move_txn_id, p_scrap_txn_id)
8261 and wmt.wip_entity_id = wlbj.wip_entity_id
8262 and wmt.transaction_id = wsmt.transaction_id
8263 and wlbj.first_serial_txn_id = -1 -- It will be set to -1 only for those jobs created through Lot Creation form..
8264 and msn.serial_number = wsmt.assembly_serial_number
8265 and msn.inventory_item_id = wmt.primary_item_id
8266 and msn.current_organization_id = wmt.organization_id
8267 and msn.wip_entity_id = wmt.wip_entity_id
8268 and msn.operation_seq_num IS NULL;
8269
8270 -- Attributes section...
8271 cursor c_serials_attr_intf
8272 is
8273 select
8274 Serial_Number ,
8275 assembly_item_id , -- assembly_item_id
8276 header_id , -- header_id
8277 Generate_serial_number ,
8278 Generate_for_qty ,
8279 Action_flag ,
8280 Current_wip_entity_name ,
8281 Changed_wip_entity_name ,
8282 Current_wip_entity_id ,
8283 Changed_wip_entity_id ,
8284 serial_attribute_category ,
8285 territory_code ,
8286 origination_date ,
8287 c_attribute1 ,
8288 c_attribute2 ,
8289 c_attribute3 ,
8290 c_attribute4 ,
8291 c_attribute5 ,
8292 c_attribute6 ,
8293 c_attribute7 ,
8294 c_attribute8 ,
8295 c_attribute9 ,
8296 c_attribute10 ,
8297 c_attribute11 ,
8298 c_attribute12 ,
8299 c_attribute13 ,
8300 c_attribute14 ,
8301 c_attribute15 ,
8302 c_attribute16 ,
8303 c_attribute17 ,
8304 c_attribute18 ,
8305 c_attribute19 ,
8306 c_attribute20 ,
8307 d_attribute1 ,
8308 d_attribute2 ,
8309 d_attribute3 ,
8310 d_attribute4 ,
8311 d_attribute5 ,
8312 d_attribute6 ,
8313 d_attribute7 ,
8314 d_attribute8 ,
8315 d_attribute9 ,
8316 d_attribute10 ,
8317 n_attribute1 ,
8318 n_attribute2 ,
8319 n_attribute3 ,
8320 n_attribute4 ,
8321 n_attribute5 ,
8322 n_attribute6 ,
8323 n_attribute7 ,
8324 n_attribute8 ,
8325 n_attribute9 ,
8326 n_attribute10 ,
8327 status_id ,
8328 time_since_new ,
8329 cycles_since_new ,
8330 time_since_overhaul ,
8331 cycles_since_overhaul ,
8332 time_since_repair ,
8333 cycles_since_repair ,
8334 time_since_visit ,
8335 cycles_since_visit ,
8336 time_since_mark ,
8337 cycles_since_mark ,
8338 number_of_repairs ,
8339 attribute_category ,
8340 attribute1 ,
8341 attribute2 ,
8342 attribute3 ,
8343 attribute4 ,
8344 attribute5 ,
8345 attribute6 ,
8346 attribute7 ,
8347 attribute8 ,
8348 attribute9 ,
8349 attribute10 ,
8350 attribute11 ,
8351 attribute12 ,
8352 attribute13 ,
8353 attribute14 ,
8354 attribute15
8355 from wsm_serial_txn_interface wsti
8356 where header_id IN (Select wmt.transaction_id
8357 from wip_move_transactions wmt,
8358 wsm_lot_move_txn_interface wlmti
8359 where wlmti.group_id = p_group_id
8360 and wlmti.internal_group_id = p_internal_group_id
8361 and wlmti.wip_entity_id = wmt.wip_entity_id
8362 and wlmti.status = WIP_CONSTANTS.COMPLETED
8363 )
8364 and transaction_type_id = 5;
8365
8366 cursor c_serials_attr_form
8367 is
8368 select
8369 Serial_Number ,
8370 assembly_item_id , -- assembly_item_id
8371 header_id , -- header_id
8372 Generate_serial_number ,
8373 Generate_for_qty ,
8374 Action_flag ,
8375 Current_wip_entity_name ,
8376 Changed_wip_entity_name ,
8377 Current_wip_entity_id ,
8378 Changed_wip_entity_id ,
8379 serial_attribute_category ,
8380 territory_code ,
8381 origination_date ,
8382 c_attribute1 ,
8383 c_attribute2 ,
8384 c_attribute3 ,
8385 c_attribute4 ,
8386 c_attribute5 ,
8387 c_attribute6 ,
8388 c_attribute7 ,
8389 c_attribute8 ,
8390 c_attribute9 ,
8391 c_attribute10 ,
8392 c_attribute11 ,
8393 c_attribute12 ,
8394 c_attribute13 ,
8395 c_attribute14 ,
8396 c_attribute15 ,
8397 c_attribute16 ,
8398 c_attribute17 ,
8399 c_attribute18 ,
8400 c_attribute19 ,
8401 c_attribute20 ,
8402 d_attribute1 ,
8403 d_attribute2 ,
8404 d_attribute3 ,
8405 d_attribute4 ,
8406 d_attribute5 ,
8407 d_attribute6 ,
8408 d_attribute7 ,
8409 d_attribute8 ,
8410 d_attribute9 ,
8411 d_attribute10 ,
8412 n_attribute1 ,
8413 n_attribute2 ,
8414 n_attribute3 ,
8415 n_attribute4 ,
8416 n_attribute5 ,
8417 n_attribute6 ,
8418 n_attribute7 ,
8419 n_attribute8 ,
8420 n_attribute9 ,
8421 n_attribute10 ,
8422 status_id ,
8423 time_since_new ,
8424 cycles_since_new ,
8425 time_since_overhaul ,
8426 cycles_since_overhaul ,
8427 time_since_repair ,
8428 cycles_since_repair ,
8429 time_since_visit ,
8430 cycles_since_visit ,
8431 time_since_mark ,
8432 cycles_since_mark ,
8433 number_of_repairs ,
8434 attribute_category ,
8435 attribute1 ,
8436 attribute2 ,
8437 attribute3 ,
8438 attribute4 ,
8439 attribute5 ,
8440 attribute6 ,
8441 attribute7 ,
8442 attribute8 ,
8443 attribute9 ,
8444 attribute10 ,
8445 attribute11 ,
8446 attribute12 ,
8447 attribute13 ,
8448 attribute14 ,
8449 attribute15
8450 from wsm_serial_txn_temp wsti
8451 where header_id IN (p_move_txn_id, p_scrap_txn_id)
8452 and transaction_type_id = 5;
8453
8454
8455 type t_serial_op_info_rec is record
8456 (
8457 serial_number MTL_SERIAL_NUMBERS.SERIAL_NUMBER%TYPE,
8458 inventory_item_id NUMBER,
8459 organization_id NUMBER,
8460 wip_entity_id NUMBER
8461 );
8462
8463 type t_serial_op_info_tbl is table of t_serial_op_info_rec index by binary_integer;
8464
8465 l_serial_info_tbl t_serial_op_info_tbl;
8466 l_cntr NUMBER;
8467
8468 -- Attributes updation variables...
8469 l_serial_txn_tbl t_number;
8470 l_wsm_serial_attrs_tbl WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL;
8471
8472 -- Logging variables.....
8473 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
8474 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
8475
8476 l_stmt_num NUMBER;
8477 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.update_attr_move';
8478 l_param_tbl WSM_Log_PVT.param_tbl_type;
8479 -- Logging variables...
8480
8481 BEGIN
8482 l_stmt_num := 10;
8483 x_return_status := G_RET_SUCCESS;
8484 x_error_msg := NULL;
8485 x_error_count := 0;
8486
8487 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
8488
8489 l_param_tbl.delete;
8490 l_param_tbl(1).paramName := 'p_move_txn_id';
8491 l_param_tbl(1).paramValue := p_move_txn_id;
8492
8493 l_param_tbl(2).paramName := 'p_scrap_txn_id';
8494 l_param_tbl(2).paramValue := p_scrap_txn_id;
8495
8496 l_param_tbl(3).paramName := 'p_group_id';
8497 l_param_tbl(3).paramValue := p_group_id;
8498
8499 l_param_tbl(4).paramName := 'p_internal_group_id';
8500 l_param_tbl(4).paramValue := p_internal_group_id;
8501
8502 l_param_tbl(5).paramName := 'p_organization_id';
8503 l_param_tbl(5).paramValue := p_organization_id;
8504
8505 WSM_Log_PVT.logProcParams(p_module_name => l_module,
8506 p_param_tbl => l_param_tbl,
8507 p_fnd_log_level => l_log_level
8508 );
8509 END IF;
8510
8511 -- This fist part is to clear the serials' op information when serial tracking ends...
8512 IF (p_group_id IS NOT NULL OR p_internal_group_id IS NOT NULL) THEN
8513 --
8514 l_stmt_num := 20;
8515 loop
8516
8517 l_stmt_num := 30;
8518
8519 open c_serials_intf;
8520 fetch c_serials_intf
8521 bulk collect into l_serial_info_tbl
8522 limit 1000; -- hard coded this
8523 close c_serials_intf;
8524
8525 l_stmt_num := 40;
8526 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8527 l_msg_tokens.delete;
8528 WSM_log_PVT.logMessage (p_module_name => l_module ,
8529 p_msg_text => 'Total Serial Numbers : ' || l_serial_info_tbl.count,
8530 p_stmt_num => l_stmt_num ,
8531 p_msg_tokens => l_msg_tokens ,
8532 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8533 p_run_log_level => l_log_level
8534 );
8535 END IF;
8536
8537 if l_serial_info_tbl.count = 0 then
8538 exit;
8539 end if;
8540
8541
8542 l_stmt_num := 50;
8543 l_cntr := l_serial_info_tbl.first;
8544
8545 while l_cntr is not null loop
8546
8547 -- Clear the op informatio.....
8548 update_serial( p_serial_number => l_serial_info_tbl(l_cntr).serial_number ,
8549 p_inventory_item_id => l_serial_info_tbl(l_cntr).inventory_item_id ,
8550 p_organization_id => l_serial_info_tbl(l_cntr).organization_id ,
8551 p_wip_entity_id => l_serial_info_tbl(l_cntr).wip_entity_id ,
8552 p_operation_seq_num => null ,
8553 p_intraoperation_step_type => null ,
8554 x_return_status => x_return_status ,
8555 x_error_msg => x_error_msg ,
8556 x_error_count => x_error_count
8557 );
8558
8559 if x_return_status <> G_RET_SUCCESS then
8560 IF x_return_status = G_RET_ERROR THEN
8561 raise FND_API.G_EXC_ERROR;
8562 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8563 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8564 END IF;
8565 end if;
8566
8567 l_cntr := l_serial_info_tbl.next(l_cntr);
8568 end loop;
8569
8570 l_stmt_num := 70;
8571
8572 end loop;
8573 ELSE
8574 open c_serials_form;
8575 fetch c_serials_form
8576 bulk collect into l_serial_info_tbl;
8577 close c_serials_form;
8578
8579 l_stmt_num := 80;
8580
8581 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8582 l_msg_tokens.delete;
8583 WSM_log_PVT.logMessage (p_module_name => l_module ,
8584 p_msg_text => 'Total Serial Numbers : ' || l_serial_info_tbl.count,
8585 p_stmt_num => l_stmt_num ,
8586 p_msg_tokens => l_msg_tokens ,
8587 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8588 p_run_log_level => l_log_level
8589 );
8590 END IF;
8591
8592 l_stmt_num := 90;
8593 l_cntr := l_serial_info_tbl.first;
8594
8595 while l_cntr is not null loop
8596
8597 -- Clear the op informatio.....
8598 update_serial( p_serial_number => l_serial_info_tbl(l_cntr).serial_number ,
8599 p_inventory_item_id => l_serial_info_tbl(l_cntr).inventory_item_id ,
8600 p_organization_id => l_serial_info_tbl(l_cntr).organization_id ,
8601 p_wip_entity_id => l_serial_info_tbl(l_cntr).wip_entity_id ,
8602 p_operation_seq_num => null ,
8603 p_intraoperation_step_type => null ,
8604 x_return_status => x_return_status ,
8605 x_error_msg => x_error_msg ,
8606 x_error_count => x_error_count
8607 );
8608
8609 if x_return_status <> G_RET_SUCCESS then
8610 IF x_return_status = G_RET_ERROR THEN
8611 raise FND_API.G_EXC_ERROR;
8612 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8613 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8614 END IF;
8615 end if;
8616
8617 l_cntr := l_serial_info_tbl.next(l_cntr);
8618 end loop;
8619
8620 l_stmt_num := 100;
8621
8622 END IF;
8623
8624 l_stmt_num := 110;
8625 -- This second part is meant soley for jobs created through Lot Creation form...
8626 -- They should always have op information in the serial numbers..
8627 IF (p_group_id IS NOT NULL OR p_internal_group_id IS NOT NULL) THEN
8628 --
8629 l_stmt_num := 120;
8630 loop
8631
8632 l_stmt_num := 130;
8633
8634 open c_serials_lot_create_intf;
8635 fetch c_serials_lot_create_intf
8636 bulk collect into l_serial_info_tbl
8637 limit 1000; -- hard coded this
8638 close c_serials_lot_create_intf;
8639
8640 l_stmt_num := 140;
8641 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8642 l_msg_tokens.delete;
8643 WSM_log_PVT.logMessage (p_module_name => l_module ,
8644 p_msg_text => 'Total Serial Numbers : ' || l_serial_info_tbl.count,
8645 p_stmt_num => l_stmt_num ,
8646 p_msg_tokens => l_msg_tokens ,
8647 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8648 p_run_log_level => l_log_level
8649 );
8650 END IF;
8651
8652 if l_serial_info_tbl.count = 0 then
8653 exit;
8654 end if;
8655
8656
8657 l_stmt_num := 150;
8658 l_cntr := l_serial_info_tbl.first;
8659
8660 while l_cntr is not null loop
8661
8662 -- Clear the op informatio.....
8663 update_serial( p_serial_number => l_serial_info_tbl(l_cntr).serial_number ,
8664 p_inventory_item_id => l_serial_info_tbl(l_cntr).inventory_item_id ,
8665 p_organization_id => l_serial_info_tbl(l_cntr).organization_id ,
8666 p_wip_entity_id => l_serial_info_tbl(l_cntr).wip_entity_id ,
8667 p_operation_seq_num => 10 ,
8668 p_intraoperation_step_type => WIP_CONSTANTS.QUEUE ,
8669 x_return_status => x_return_status ,
8670 x_error_msg => x_error_msg ,
8671 x_error_count => x_error_count
8672 );
8673
8674 if x_return_status <> G_RET_SUCCESS then
8675 IF x_return_status = G_RET_ERROR THEN
8676 raise FND_API.G_EXC_ERROR;
8677 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8678 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8679 END IF;
8680 end if;
8681
8682 l_cntr := l_serial_info_tbl.next(l_cntr);
8683 end loop;
8684
8685 l_stmt_num := 170;
8686
8687 end loop;
8688 ELSE
8689 open c_serials_lot_create_form;
8690 fetch c_serials_lot_create_form
8691 bulk collect into l_serial_info_tbl;
8692 close c_serials_lot_create_form;
8693
8694 l_stmt_num := 180;
8695
8696 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8697 l_msg_tokens.delete;
8698 WSM_log_PVT.logMessage (p_module_name => l_module ,
8699 p_msg_text => 'Total Serial Numbers : ' || l_serial_info_tbl.count,
8700 p_stmt_num => l_stmt_num ,
8701 p_msg_tokens => l_msg_tokens ,
8702 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8703 p_run_log_level => l_log_level
8704 );
8705 END IF;
8706
8707 l_stmt_num := 190;
8708 l_cntr := l_serial_info_tbl.first;
8709
8710 while l_cntr is not null loop
8711
8712 -- Clear the op informatio.....
8713 update_serial( p_serial_number => l_serial_info_tbl(l_cntr).serial_number ,
8714 p_inventory_item_id => l_serial_info_tbl(l_cntr).inventory_item_id ,
8715 p_organization_id => l_serial_info_tbl(l_cntr).organization_id ,
8716 p_wip_entity_id => l_serial_info_tbl(l_cntr).wip_entity_id ,
8717 p_operation_seq_num => 10 ,
8718 p_intraoperation_step_type => WIP_CONSTANTS.QUEUE ,
8719 x_return_status => x_return_status ,
8720 x_error_msg => x_error_msg ,
8721 x_error_count => x_error_count
8722 );
8723
8724 if x_return_status <> G_RET_SUCCESS then
8725 IF x_return_status = G_RET_ERROR THEN
8726 raise FND_API.G_EXC_ERROR;
8727 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8728 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8729 END IF;
8730 end if;
8731
8732 l_cntr := l_serial_info_tbl.next(l_cntr);
8733 end loop;
8734
8735 l_stmt_num := 200;
8736 END IF;
8737
8738 -- Attributes section...
8739 l_stmt_num := 210;
8740 IF (p_group_id IS NOT NULL OR p_internal_group_id IS NOT NULL) THEN
8741 l_stmt_num := 220;
8742 loop
8743
8744 l_stmt_num := 230;
8745
8746 open c_serials_attr_intf;
8747 fetch c_serials_attr_intf
8748 bulk collect into l_wsm_serial_attrs_tbl
8749 limit 1000; -- hard coded this;
8750 close c_serials_attr_intf;
8751
8752 l_stmt_num := 240;
8753 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8754 l_msg_tokens.delete;
8755 WSM_log_PVT.logMessage (p_module_name => l_module ,
8756 p_msg_text => 'Total Serial Numbers : ' || l_wsm_serial_attrs_tbl.count,
8757 p_stmt_num => l_stmt_num ,
8758 p_msg_tokens => l_msg_tokens ,
8759 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8760 p_run_log_level => l_log_level
8761 );
8762 END IF;
8763
8764 if l_wsm_serial_attrs_tbl.count = 0 then
8765 exit;
8766 end if;
8767
8768 l_stmt_num := 250;
8769 l_cntr := l_wsm_serial_attrs_tbl.first;
8770 WHILE l_cntr IS NOT NULL LOOP
8771
8772 l_stmt_num := 260;
8773 -- call the update_serial_attr procedure...
8774 update_serial_attr ( p_calling_mode => 1 ,
8775 p_serial_number_rec => l_wsm_serial_attrs_tbl(l_cntr) ,
8776 p_inventory_item_id => l_wsm_serial_attrs_tbl(l_cntr).assembly_item_id ,
8777 p_organization_id => nvl(p_organization_id,l_wsm_serial_attrs_tbl(l_cntr).action_flag) ,
8778 p_clear_serial_attr => null ,
8779 p_wlt_txn_type => null ,
8780 p_update_serial_attr => 1 ,
8781 p_update_desc_attr => null ,
8782 x_return_status => x_return_status ,
8783 x_error_count => x_error_count ,
8784 x_error_msg => x_error_msg
8785 );
8786
8787 if x_return_status <> G_RET_SUCCESS then
8788 IF x_return_status = G_RET_ERROR THEN
8789 raise FND_API.G_EXC_ERROR;
8790 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8791 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8792 END IF;
8793 end if;
8794
8795 IF not (l_serial_txn_tbl.exists(l_wsm_serial_attrs_tbl(l_cntr).header_id)) THEN
8796 l_serial_txn_tbl(l_wsm_serial_attrs_tbl(l_cntr).header_id) := l_wsm_serial_attrs_tbl(l_cntr).header_id;
8797 END IF;
8798
8799 l_cntr := l_wsm_serial_attrs_tbl.next(l_cntr);
8800 end loop;
8801
8802 l_stmt_num := 270;
8803
8804 forall l_header in indices OF l_serial_txn_tbl
8805 delete from wsm_serial_txn_interface
8806 where header_id = l_serial_txn_tbl(l_header)
8807 and transaction_type_id = 5;
8808
8809 end loop;
8810 ELSE
8811 open c_serials_attr_form;
8812 fetch c_serials_attr_form
8813 bulk collect into l_wsm_serial_attrs_tbl;
8814 close c_serials_attr_form;
8815
8816 l_stmt_num := 280;
8817
8818 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8819 l_msg_tokens.delete;
8820 WSM_log_PVT.logMessage (p_module_name => l_module ,
8821 p_msg_text => 'Total Serial Numbers for attributes updation : '
8822 || l_wsm_serial_attrs_tbl.count,
8823 p_stmt_num => l_stmt_num ,
8824 p_msg_tokens => l_msg_tokens ,
8825 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8826 p_run_log_level => l_log_level
8827 );
8828 END IF;
8829
8830
8831 l_stmt_num := 290;
8832 l_cntr := l_wsm_serial_attrs_tbl.first;
8833 WHILE l_cntr IS NOT NULL LOOP
8834
8835 l_stmt_num := 300;
8836 -- call the update_serial_attr procedure...
8837 update_serial_attr ( p_calling_mode => 2 ,
8838 p_serial_number_rec => l_wsm_serial_attrs_tbl(l_cntr) ,
8839 p_inventory_item_id => l_wsm_serial_attrs_tbl(l_cntr).assembly_item_id ,
8840 p_organization_id => p_organization_id ,
8841 p_clear_serial_attr => null ,
8842 p_wlt_txn_type => null ,
8843 p_update_serial_attr => 1 ,
8844 p_update_desc_attr => null ,
8845 x_return_status => x_return_status ,
8846 x_error_count => x_error_count ,
8847 x_error_msg => x_error_msg
8848 );
8849
8850 if x_return_status <> G_RET_SUCCESS then
8851 IF x_return_status = G_RET_ERROR THEN
8852 raise FND_API.G_EXC_ERROR;
8853 ELSIF x_return_status = G_RET_UNEXPECTED THEN
8854 raise FND_API.G_EXC_UNEXPECTED_ERROR;
8855 END IF;
8856 end if;
8857
8858 l_cntr := l_wsm_serial_attrs_tbl.next(l_cntr);
8859 END LOOP;
8860
8861 l_stmt_num := 310;
8862
8863 delete from wsm_serial_txn_temp
8864 where header_id IN (p_move_txn_id,p_scrap_txn_id)
8865 and transaction_type_id = 5;
8866
8867 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8868 l_msg_tokens.delete;
8869 WSM_log_PVT.logMessage (p_module_name => l_module,
8870 p_msg_text => 'Deleted ' || SQL%ROWCOUNT || ' records inserted for attributes reason',
8871 p_stmt_num => l_stmt_num ,
8872 p_msg_tokens => l_msg_tokens ,
8873 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8874 p_run_log_level => l_log_level
8875 );
8876 END IF;
8877 END IF;
8878
8879 l_stmt_num := 320;
8880 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
8881 l_msg_tokens.delete;
8882 WSM_log_PVT.logMessage (p_module_name => l_module ,
8883 p_msg_text => 'Completed updation of the attributes',
8884 p_stmt_num => l_stmt_num ,
8885 p_msg_tokens => l_msg_tokens ,
8886 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
8887 p_run_log_level => l_log_level
8888 );
8889 END IF;
8890
8891 EXCEPTION
8892
8893 WHEN FND_API.G_EXC_ERROR THEN
8894
8895 x_return_status := G_RET_ERROR;
8896 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
8897 p_count => x_error_count ,
8898 p_data => x_error_msg
8899 );
8900
8901 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8902
8903 x_return_status := G_RET_UNEXPECTED;
8904
8905 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
8906 p_count => x_error_count ,
8907 p_data => x_error_msg
8908 );
8909 WHEN OTHERS THEN
8910
8911 x_return_status := G_RET_UNEXPECTED;
8912
8913 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
8914 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
8915 THEN
8916 WSM_log_PVT.handle_others( p_module_name => l_module ,
8917 p_stmt_num => l_stmt_num ,
8918 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
8919 p_run_log_level => l_log_level
8920 );
8921 END IF;
8922
8923 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
8924 p_count => x_error_count ,
8925 p_data => x_error_msg
8926 );
8927 END Update_attr_move;
8928
8929 -- This procedure will not be invoked for Interface...
8930 -- This procedure is not currently used as if populate_component fails the move transaction will also fail.
8931 -- (Previously this procedure was required to populate the parent serial numbers to be seen in the backflush screen)
8932 Procedure find_undo_ret_serials ( p_header_id IN NUMBER, -- passed value will be :parameter.move_txn_id
8933 p_wip_entity_id IN NUMBER,
8934 p_move_txn_type IN NUMBER,
8935 p_organization_id IN NUMBER,
8936 p_inventory_item_id IN NUMBER,
8937 p_move_qty IN NUMBER,
8938 p_scrap_qty IN NUMBER,
8939 x_return_status OUT NOCOPY VARCHAR2,
8940 x_error_msg OUT NOCOPY VARCHAR2,
8941 x_error_count OUT NOCOPY NUMBER
8942 ) IS
8943
8944 -- Logging variables.....
8945 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
8946 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
8947
8948 l_stmt_num NUMBER;
8949 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.find_undo_ret_serials';
8950 l_param_tbl WSM_Log_PVT.param_tbl_type;
8951 -- Logging variables...
8952
8953 begin
8954
8955 x_return_status := G_RET_SUCCESS;
8956 x_error_msg := NULL;
8957 x_error_count := 0;
8958
8959 -- This procedure is no longer used...
8960 return;
8961
8962 EXCEPTION
8963
8964 WHEN OTHERS THEN
8965
8966 x_return_status := G_RET_UNEXPECTED;
8967
8968 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
8969 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
8970 THEN
8971 WSM_log_PVT.handle_others( p_module_name => l_module ,
8972 p_stmt_num => l_stmt_num ,
8973 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
8974 p_run_log_level => l_log_level
8975 );
8976 END IF;
8977
8978 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
8979 p_count => x_error_count ,
8980 p_data => x_error_msg
8981 );
8982
8983 end find_undo_ret_serials;
8984
8985
8986 Procedure Move_forms_serial_proc( p_move_txn_type IN NUMBER,
8987 p_wip_entity_id IN NUMBER,
8988 p_organization_id IN NUMBER,
8989 p_inventory_item_id IN NUMBER,
8990 p_move_qty IN NUMBER,
8991 p_scrap_qty IN NUMBER,
8992 p_available_qty IN NUMBER,
8993 p_curr_job_op_seq_num IN NUMBER,
8994 p_curr_job_intraop_step IN NUMBER,
8995 p_from_rtg_op_seq_num IN NUMBER,
8996 p_to_rtg_op_seq_num IN NUMBER,
8997 p_to_intraoperation_step IN NUMBER,
8998 p_user_serial_tracking IN NUMBER,
8999 p_move_txn_id IN NUMBER,
9000 p_scrap_txn_id IN NUMBER,
9001 x_return_status OUT NOCOPY VARCHAR2,
9002 x_error_msg OUT NOCOPY VARCHAR2,
9003 x_error_count OUT NOCOPY NUMBER
9004 )
9005
9006 IS
9007 cursor c_move_serials
9008 is
9009 select
9010 Serial_Number ,
9011 gen_object_id , -- (Gen_object_id --> assembly_item_id No longer used Instead the column will have gen_object_id)
9012 header_id , -- header_id
9013 Generate_serial_number ,
9014 Generate_for_qty ,
9015 Action_flag ,
9016 Current_wip_entity_name ,
9017 Changed_wip_entity_name ,
9018 Current_wip_entity_id ,
9019 Changed_wip_entity_id ,
9020 serial_attribute_category ,
9021 territory_code ,
9022 origination_date ,
9023 c_attribute1 ,
9024 c_attribute2 ,
9025 c_attribute3 ,
9026 c_attribute4 ,
9027 c_attribute5 ,
9028 c_attribute6 ,
9029 c_attribute7 ,
9030 c_attribute8 ,
9031 c_attribute9 ,
9032 c_attribute10 ,
9033 c_attribute11 ,
9034 c_attribute12 ,
9035 c_attribute13 ,
9036 c_attribute14 ,
9037 c_attribute15 ,
9038 c_attribute16 ,
9039 c_attribute17 ,
9040 c_attribute18 ,
9041 c_attribute19 ,
9042 c_attribute20 ,
9043 d_attribute1 ,
9044 d_attribute2 ,
9045 d_attribute3 ,
9046 d_attribute4 ,
9047 d_attribute5 ,
9048 d_attribute6 ,
9049 d_attribute7 ,
9050 d_attribute8 ,
9051 d_attribute9 ,
9052 d_attribute10 ,
9053 n_attribute1 ,
9054 n_attribute2 ,
9055 n_attribute3 ,
9056 n_attribute4 ,
9057 n_attribute5 ,
9058 n_attribute6 ,
9059 n_attribute7 ,
9060 n_attribute8 ,
9061 n_attribute9 ,
9062 n_attribute10 ,
9063 status_id ,
9064 time_since_new ,
9065 cycles_since_new ,
9066 time_since_overhaul ,
9067 cycles_since_overhaul ,
9068 time_since_repair ,
9069 cycles_since_repair ,
9070 time_since_visit ,
9071 cycles_since_visit ,
9072 time_since_mark ,
9073 cycles_since_mark ,
9074 number_of_repairs ,
9075 attribute_category ,
9076 attribute1 ,
9077 attribute2 ,
9078 attribute3 ,
9079 attribute4 ,
9080 attribute5 ,
9081 attribute6 ,
9082 attribute7 ,
9083 attribute8 ,
9084 attribute9 ,
9085 attribute10 ,
9086 attribute11 ,
9087 attribute12 ,
9088 attribute13 ,
9089 attribute14 ,
9090 attribute15
9091 from wsm_serial_txn_temp
9092 where header_id = p_move_txn_id
9093 and transaction_type_id = 2
9094 and action_flag IN (5,6); -- select the move/scrap
9095
9096 l_wsm_serial_num_tbl WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL;
9097 l_old_scrap_txn_id NUMBER;
9098 l_old_move_txn_id NUMBER;
9099 l_serial_start_op NUMBER;
9100 l_serial_track_flag NUMBER;
9101 l_serial_ctrl_code NUMBER;
9102 l_first_serial_txn_id NUMBER;
9103
9104
9105 -- Logging variables.....
9106 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
9107 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
9108
9109 l_stmt_num NUMBER;
9110 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Move_forms_serial_proc';
9111 l_param_tbl WSM_Log_PVT.param_tbl_type;
9112 -- Logging variables...
9113
9114 BEGIN
9115 l_stmt_num := 10;
9116 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9117 l_msg_tokens.delete;
9118 WSM_log_PVT.logMessage (p_module_name => l_module ,
9119 p_msg_text => 'Entered wsm.plsql.WSM_SERIAL_SUPPORT_PVT.Move_forms_serial_proc',
9120 p_stmt_num => l_stmt_num ,
9121 p_msg_tokens => l_msg_tokens ,
9122 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9123 p_run_log_level => l_log_level
9124 );
9125 END IF;
9126
9127 x_return_status := G_RET_SUCCESS;
9128 x_error_msg := NULL;
9129 x_error_count := 0;
9130
9131 -- Validate the item_id/job for serial control..
9132 get_serial_track_info( p_serial_item_id => p_inventory_item_id,
9133 p_organization_id => p_organization_id,
9134 p_wip_entity_id => p_wip_entity_id,
9135 x_serial_start_flag => l_serial_track_flag,
9136 x_serial_ctrl_code => l_serial_ctrl_code,
9137 x_first_serial_txn_id => l_first_serial_txn_id,
9138 x_serial_start_op => l_serial_start_op,
9139 x_return_status => x_return_status,
9140 x_error_msg => x_error_msg,
9141 x_error_count => x_error_count
9142 );
9143
9144 if x_return_status <> G_RET_SUCCESS then
9145 IF x_return_status = G_RET_ERROR THEN
9146 raise FND_API.G_EXC_ERROR;
9147 ELSIF x_return_status = G_RET_UNEXPECTED THEN
9148 raise FND_API.G_EXC_UNEXPECTED_ERROR;
9149 END IF;
9150 end if;
9151
9152 IF p_move_txn_type IN (1,2) THEN -- Not undo/assembly return
9153 -- bulk collect from the cursor...
9154 open c_move_serials;
9155 fetch c_move_serials
9156 bulk collect into l_wsm_serial_num_tbl;
9157 close c_move_serials;
9158
9159 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9160 l_msg_tokens.delete;
9161 WSM_log_PVT.logMessage (p_module_name => l_module ,
9162 p_msg_text => 'Total Rows : ' || l_wsm_serial_num_tbl.count,
9163 p_stmt_num => l_stmt_num ,
9164 p_msg_tokens => l_msg_tokens ,
9165 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9166 p_run_log_level => l_log_level
9167 );
9168 END IF;
9169 ELSE
9170 select max(wmt.transaction_id)
9171 into l_old_move_txn_id
9172 from wip_move_transactions wmt
9173 where wmt.organization_id = p_organization_id
9174 and wmt.wip_entity_id = p_wip_entity_id
9175 and wmt.wsm_undo_txn_id IS NULL
9176 and wmt.transaction_id = wmt.batch_id;
9177
9178 BEGIN
9179 select max(transaction_id)
9180 into l_old_scrap_txn_id
9181 from wip_move_transactions
9182 where organization_id = p_organization_id
9183 and wip_entity_id = p_wip_entity_id
9184 and batch_id = l_old_move_txn_id
9185 and transaction_id <> batch_id;
9186 EXCEPTION
9187 WHEN NO_DATA_FOUND THEN
9188 null;
9189 END;
9190 END IF;
9191
9192 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9193 l_msg_tokens.delete;
9194 WSM_log_PVT.logMessage (p_module_name => l_module ,
9195 p_msg_text => 'Invoking WSM_Serial_support_PVT.Move_serial_processor',
9196 p_stmt_num => l_stmt_num ,
9197 p_msg_tokens => l_msg_tokens ,
9198 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9199 p_run_log_level => l_log_level
9200 );
9201 END IF;
9202
9203 WSM_Serial_support_PVT.Move_serial_processor ( p_calling_mode => 2 ,
9204 p_serial_num_tbl => l_wsm_serial_num_tbl ,
9205 p_move_txn_type => p_move_txn_type ,
9206 p_wip_entity_id => p_wip_entity_id ,
9207 p_organization_id => p_organization_id ,
9208 p_inventory_item_id => p_inventory_item_id ,
9209 p_move_qty => p_move_qty ,
9210 p_scrap_qty => p_scrap_qty ,
9211 p_available_qty => p_available_qty ,
9212 p_curr_job_op_seq_num => p_curr_job_op_seq_num ,
9213 p_curr_job_intraop_step => p_curr_job_intraop_step ,
9214 p_from_rtg_op_seq_num => p_from_rtg_op_seq_num ,
9215 p_to_rtg_op_seq_num => p_to_rtg_op_seq_num ,
9216 p_to_intraoperation_step => p_to_intraoperation_step ,
9217 p_job_serial_start_op => l_serial_start_op ,
9218 p_user_serial_tracking => p_user_serial_tracking ,
9219 p_move_txn_id => p_move_txn_id ,
9220 p_scrap_txn_id => p_scrap_txn_id ,
9221 p_old_move_txn_id => l_old_move_txn_id ,
9222 p_old_scrap_txn_id => l_old_scrap_txn_id ,
9223 x_serial_track_flag => l_serial_track_flag ,
9224 x_return_status => x_return_status ,
9225 x_error_msg => x_error_msg ,
9226 x_error_count => x_error_count
9227 );
9228 if x_return_status <> G_RET_SUCCESS then
9229 IF x_return_status = G_RET_ERROR THEN
9230 raise FND_API.G_EXC_ERROR;
9231 ELSIF x_return_status = G_RET_UNEXPECTED THEN
9232 raise FND_API.G_EXC_UNEXPECTED_ERROR;
9233 END IF;
9234 end if;
9235
9236 IF p_move_txn_type IN (2,3) THEN -- Assembly return and completion transaction...
9237 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9238 l_msg_tokens.delete;
9239 WSM_log_PVT.logMessage (p_module_name => l_module ,
9240 p_msg_text => 'Invoking WSM_Serial_support_PVT.Insert_move_attr',
9241 p_stmt_num => l_stmt_num ,
9242 p_msg_tokens => l_msg_tokens ,
9243 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9244 p_run_log_level => l_log_level
9245 );
9246 END IF;
9247
9248 -- Insert records into the WSM_SERIAL_TXN_TEMP for serial attributes...
9249 WSM_Serial_support_PVT.Insert_move_attr ( p_group_id => null ,
9250 p_move_txn_id => p_move_txn_id ,
9251 p_scrap_txn_id => p_scrap_txn_id ,
9252 x_return_status => x_return_status ,
9253 x_error_count => x_error_count ,
9254 x_error_msg => x_error_msg
9255 );
9256
9257 if x_return_status <> G_RET_SUCCESS then
9258 IF x_return_status = G_RET_ERROR THEN
9259 raise FND_API.G_EXC_ERROR;
9260 ELSIF x_return_status = G_RET_UNEXPECTED THEN
9261 raise FND_API.G_EXC_UNEXPECTED_ERROR;
9262 END IF;
9263 end if;
9264 END IF;
9265
9266 IF (G_LOG_LEVEL_STATEMENT >= l_log_level) THEN
9267 l_msg_tokens.delete;
9268 WSM_log_PVT.logMessage (p_module_name => l_module ,
9269 p_msg_text => 'Processing in WSM_Serial_support_PVT.Move_forms_serial_proc complete',
9270 p_stmt_num => l_stmt_num ,
9271 p_msg_tokens => l_msg_tokens ,
9272 p_fnd_log_level => G_LOG_LEVEL_STATEMENT ,
9273 p_run_log_level => l_log_level
9274 );
9275 END IF;
9276
9277 EXCEPTION
9278
9279 WHEN FND_API.G_EXC_ERROR THEN
9280
9281 x_return_status := G_RET_ERROR;
9282 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
9283 p_count => x_error_count ,
9284 p_data => x_error_msg
9285 );
9286
9287 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9288
9289 x_return_status := G_RET_UNEXPECTED;
9290
9291 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
9292 p_count => x_error_count ,
9293 p_data => x_error_msg
9294 );
9295 WHEN OTHERS THEN
9296
9297 x_return_status := G_RET_UNEXPECTED;
9298
9299 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
9300 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
9301 THEN
9302 WSM_log_PVT.handle_others( p_module_name => l_module ,
9303 p_stmt_num => l_stmt_num ,
9304 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
9305 p_run_log_level => l_log_level
9306 );
9307 END IF;
9308
9309 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
9310 p_count => x_error_count ,
9311 p_data => x_error_msg
9312 );
9313 END Move_forms_serial_proc;
9314
9315 -- Procedure to dump the serial records' data....
9316 Procedure log_serial_data ( p_serial_num_tbl IN WSM_Serial_Support_GRP.WSM_SERIAL_NUM_TBL ,
9317 x_return_status OUT NOCOPY VARCHAR2 ,
9318 x_error_msg OUT NOCOPY VARCHAR2 ,
9319 x_error_count OUT NOCOPY NUMBER
9320 ) IS
9321
9322 -- This assumption is based that each individual column to be logged doesnt exceed 3900 chars... (that's the max...)
9323 type t_log_message_tbl IS table OF varchar2(3900) index by binary_integer;
9324
9325 -- MESSAGE_TEXT column in FND_LOG_MESSAGES is 4000 characters long..
9326 -- WSM_Log_PVT adds the date information in the start,,, so leave 50 characters for that
9327 -- Effective length we would use is 3900
9328
9329 -- Logging variables.....
9330 l_msg_tokens WSM_Log_PVT.token_rec_tbl;
9331 l_log_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
9332
9333 l_stmt_num NUMBER;
9334 l_module VARCHAR2(100) := 'wsm.plsql.WSM_SERIAL_SUPPORT_PVT.log_serial_data';
9335 l_param_tbl WSM_Log_PVT.param_tbl_type;
9336 -- Logging variables...
9337
9338 l_message_tbl t_log_message_tbl;
9339 l_log_message FND_LOG_MESSAGES.MESSAGE_TEXT%TYPE;
9340 l_counter NUMBER;
9341 l_index NUMBER;
9342
9343 BEGIN
9344 l_stmt_num := 10;
9345 x_return_status := G_RET_SUCCESS;
9346 x_error_msg := NULL;
9347 x_error_count := 0;
9348
9349 IF FND_LOG.LEVEL_PROCEDURE >= l_log_level THEN
9350
9351 l_param_tbl.delete;
9352 l_param_tbl(1).paramName := 'p_serial_num_tbl.count';
9353 l_param_tbl(1).paramValue := p_serial_num_tbl.count;
9354
9355 WSM_Log_PVT.logProcParams(p_module_name => l_module,
9356 p_param_tbl => l_param_tbl,
9357 p_fnd_log_level => l_log_level
9358 );
9359 END IF;
9360
9361 IF( g_log_level_statement >= l_log_level ) THEN
9362
9363 WSM_log_PVT.logMessage(p_module_name => l_module ,
9364 p_msg_text => 'Logging the transaction serial data..',
9365 p_stmt_num => l_stmt_num ,
9366 p_msg_tokens => l_msg_tokens,
9367 p_fnd_log_level => g_log_level_statement,
9368 p_run_log_level => l_log_level
9369 );
9370
9371 l_stmt_num := 20;
9372 -- Loop and dump the data...
9373 l_index := p_serial_num_tbl.first;
9374 WHILE l_index IS NOT NULL LOOP
9375
9376 l_message_tbl.delete;
9377
9378 l_message_tbl(l_message_tbl.count+1) := 'serial_Number [' || p_serial_num_tbl(l_index).serial_Number || ']';
9379 l_message_tbl(l_message_tbl.count+1) := 'Changed_wip_entity_name [' || p_serial_num_tbl(l_index).Changed_wip_entity_name || ']';
9380 l_message_tbl(l_message_tbl.count+1) := 'Assembly_item_id [' || p_serial_num_tbl(l_index).Assembly_item_id || ']';
9381 l_message_tbl(l_message_tbl.count+1) := 'header_id [' || p_serial_num_tbl(l_index).header_id || ']';
9382 l_message_tbl(l_message_tbl.count+1) := 'Generate_serial_number [' || p_serial_num_tbl(l_index).Generate_serial_number || ']';
9383 l_message_tbl(l_message_tbl.count+1) := 'Generate_for_qty [' || p_serial_num_tbl(l_index).Generate_for_qty || ']';
9384 l_message_tbl(l_message_tbl.count+1) := 'Action_flag [' || p_serial_num_tbl(l_index).Action_flag || ']';
9385 l_message_tbl(l_message_tbl.count+1) := 'Current_wip_entity_name [' || p_serial_num_tbl(l_index).Current_wip_entity_name || ']';
9386 l_message_tbl(l_message_tbl.count+1) := 'Current_wip_entity_id [' || p_serial_num_tbl(l_index).Current_wip_entity_id || ']';
9387 l_message_tbl(l_message_tbl.count+1) := 'Changed_wip_entity_id [' || p_serial_num_tbl(l_index).Changed_wip_entity_id || ']';
9388 l_message_tbl(l_message_tbl.count+1) := 'serial_attribute_category [' || p_serial_num_tbl(l_index).serial_attribute_category || ']';
9389 l_message_tbl(l_message_tbl.count+1) := 'territory_code [' || p_serial_num_tbl(l_index).territory_code || ']';
9390 l_message_tbl(l_message_tbl.count+1) := 'origination_date [' || p_serial_num_tbl(l_index).origination_date || ']';
9391 l_message_tbl(l_message_tbl.count+1) := 'c_attribute1 [' || p_serial_num_tbl(l_index).c_attribute1 || ']';
9392 l_message_tbl(l_message_tbl.count+1) := 'c_attribute2 [' || p_serial_num_tbl(l_index).c_attribute2 || ']';
9393 l_message_tbl(l_message_tbl.count+1) := 'c_attribute3 [' || p_serial_num_tbl(l_index).c_attribute3 || ']';
9394 l_message_tbl(l_message_tbl.count+1) := 'c_attribute4 [' || p_serial_num_tbl(l_index).c_attribute4 || ']';
9395 l_message_tbl(l_message_tbl.count+1) := 'c_attribute5 [' || p_serial_num_tbl(l_index).c_attribute5 || ']';
9396 l_message_tbl(l_message_tbl.count+1) := 'c_attribute6 [' || p_serial_num_tbl(l_index).c_attribute6 || ']';
9397 l_message_tbl(l_message_tbl.count+1) := 'c_attribute7 [' || p_serial_num_tbl(l_index).c_attribute7 || ']';
9398 l_message_tbl(l_message_tbl.count+1) := 'c_attribute8 [' || p_serial_num_tbl(l_index).c_attribute8 || ']';
9399 l_message_tbl(l_message_tbl.count+1) := 'c_attribute9 [' || p_serial_num_tbl(l_index).c_attribute9 || ']';
9400 l_message_tbl(l_message_tbl.count+1) := 'c_attribute10 [' || p_serial_num_tbl(l_index).c_attribute10 || ']';
9401 l_message_tbl(l_message_tbl.count+1) := 'c_attribute11 [' || p_serial_num_tbl(l_index).c_attribute11 || ']';
9402 l_message_tbl(l_message_tbl.count+1) := 'c_attribute12 [' || p_serial_num_tbl(l_index).c_attribute12 || ']';
9403 l_message_tbl(l_message_tbl.count+1) := 'c_attribute13 [' || p_serial_num_tbl(l_index).c_attribute13 || ']';
9404 l_message_tbl(l_message_tbl.count+1) := 'c_attribute14 [' || p_serial_num_tbl(l_index).c_attribute14 || ']';
9405 l_message_tbl(l_message_tbl.count+1) := 'c_attribute15 [' || p_serial_num_tbl(l_index).c_attribute15 || ']';
9406 l_message_tbl(l_message_tbl.count+1) := 'c_attribute16 [' || p_serial_num_tbl(l_index).c_attribute16 || ']';
9407 l_message_tbl(l_message_tbl.count+1) := 'c_attribute17 [' || p_serial_num_tbl(l_index).c_attribute17 || ']';
9408 l_message_tbl(l_message_tbl.count+1) := 'c_attribute18 [' || p_serial_num_tbl(l_index).c_attribute18 || ']';
9409 l_message_tbl(l_message_tbl.count+1) := 'c_attribute19 [' || p_serial_num_tbl(l_index).c_attribute19 || ']';
9410 l_message_tbl(l_message_tbl.count+1) := 'c_attribute20 [' || p_serial_num_tbl(l_index).c_attribute20 || ']';
9411 l_message_tbl(l_message_tbl.count+1) := 'd_attribute1 [' || p_serial_num_tbl(l_index).d_attribute1 || ']';
9412 l_message_tbl(l_message_tbl.count+1) := 'd_attribute2 [' || p_serial_num_tbl(l_index).d_attribute2 || ']';
9413 l_message_tbl(l_message_tbl.count+1) := 'd_attribute3 [' || p_serial_num_tbl(l_index).d_attribute3 || ']';
9414 l_message_tbl(l_message_tbl.count+1) := 'd_attribute4 [' || p_serial_num_tbl(l_index).d_attribute4 || ']';
9415 l_message_tbl(l_message_tbl.count+1) := 'd_attribute5 [' || p_serial_num_tbl(l_index).d_attribute5 || ']';
9416 l_message_tbl(l_message_tbl.count+1) := 'd_attribute6 [' || p_serial_num_tbl(l_index).d_attribute6 || ']';
9417 l_message_tbl(l_message_tbl.count+1) := 'd_attribute7 [' || p_serial_num_tbl(l_index).d_attribute7 || ']';
9418 l_message_tbl(l_message_tbl.count+1) := 'd_attribute8 [' || p_serial_num_tbl(l_index).d_attribute8 || ']';
9419 l_message_tbl(l_message_tbl.count+1) := 'd_attribute9 [' || p_serial_num_tbl(l_index).d_attribute9 || ']';
9420 l_message_tbl(l_message_tbl.count+1) := 'd_attribute10 [' || p_serial_num_tbl(l_index).d_attribute10 || ']';
9421 l_message_tbl(l_message_tbl.count+1) := 'n_attribute1 [' || p_serial_num_tbl(l_index).n_attribute1 || ']';
9422 l_message_tbl(l_message_tbl.count+1) := 'n_attribute2 [' || p_serial_num_tbl(l_index).n_attribute2 || ']';
9423 l_message_tbl(l_message_tbl.count+1) := 'n_attribute3 [' || p_serial_num_tbl(l_index).n_attribute3 || ']';
9424 l_message_tbl(l_message_tbl.count+1) := 'n_attribute4 [' || p_serial_num_tbl(l_index).n_attribute4 || ']';
9425 l_message_tbl(l_message_tbl.count+1) := 'n_attribute5 [' || p_serial_num_tbl(l_index).n_attribute5 || ']';
9426 l_message_tbl(l_message_tbl.count+1) := 'n_attribute6 [' || p_serial_num_tbl(l_index).n_attribute6 || ']';
9427 l_message_tbl(l_message_tbl.count+1) := 'n_attribute7 [' || p_serial_num_tbl(l_index).n_attribute7 || ']';
9428 l_message_tbl(l_message_tbl.count+1) := 'n_attribute8 [' || p_serial_num_tbl(l_index).n_attribute8 || ']';
9429 l_message_tbl(l_message_tbl.count+1) := 'n_attribute9 [' || p_serial_num_tbl(l_index).n_attribute9 || ']';
9430 l_message_tbl(l_message_tbl.count+1) := 'n_attribute10 [' || p_serial_num_tbl(l_index).n_attribute10 || ']';
9431 l_message_tbl(l_message_tbl.count+1) := 'status_id [' || p_serial_num_tbl(l_index).status_id || ']';
9432 l_message_tbl(l_message_tbl.count+1) := 'time_since_new [' || p_serial_num_tbl(l_index).time_since_new || ']';
9433 l_message_tbl(l_message_tbl.count+1) := 'cycles_since_new [' || p_serial_num_tbl(l_index).cycles_since_new || ']';
9434 l_message_tbl(l_message_tbl.count+1) := 'time_since_overhaul [' || p_serial_num_tbl(l_index).time_since_overhaul || ']';
9435 l_message_tbl(l_message_tbl.count+1) := 'cycles_since_overhaul [' || p_serial_num_tbl(l_index).cycles_since_overhaul || ']';
9436 l_message_tbl(l_message_tbl.count+1) := 'time_since_repair [' || p_serial_num_tbl(l_index).time_since_repair || ']';
9437 l_message_tbl(l_message_tbl.count+1) := 'cycles_since_repair [' || p_serial_num_tbl(l_index).cycles_since_repair || ']';
9438 l_message_tbl(l_message_tbl.count+1) := 'time_since_visit [' || p_serial_num_tbl(l_index).time_since_visit || ']';
9439 l_message_tbl(l_message_tbl.count+1) := 'cycles_since_visit [' || p_serial_num_tbl(l_index).cycles_since_visit || ']';
9440 l_message_tbl(l_message_tbl.count+1) := 'time_since_mark [' || p_serial_num_tbl(l_index).time_since_mark || ']';
9441 l_message_tbl(l_message_tbl.count+1) := 'cycles_since_mark [' || p_serial_num_tbl(l_index).cycles_since_mark || ']';
9442 l_message_tbl(l_message_tbl.count+1) := 'number_of_repairs [' || p_serial_num_tbl(l_index).number_of_repairs || ']';
9443 l_message_tbl(l_message_tbl.count+1) := 'attribute_category [' || p_serial_num_tbl(l_index).attribute_category || ']';
9444 l_message_tbl(l_message_tbl.count+1) := 'attribute1 [' || p_serial_num_tbl(l_index).attribute1 || ']';
9445 l_message_tbl(l_message_tbl.count+1) := 'attribute2 [' || p_serial_num_tbl(l_index).attribute2 || ']';
9446 l_message_tbl(l_message_tbl.count+1) := 'attribute3 [' || p_serial_num_tbl(l_index).attribute3 || ']';
9447 l_message_tbl(l_message_tbl.count+1) := 'attribute4 [' || p_serial_num_tbl(l_index).attribute4 || ']';
9448 l_message_tbl(l_message_tbl.count+1) := 'attribute5 [' || p_serial_num_tbl(l_index).attribute5 || ']';
9449 l_message_tbl(l_message_tbl.count+1) := 'attribute6 [' || p_serial_num_tbl(l_index).attribute6 || ']';
9450 l_message_tbl(l_message_tbl.count+1) := 'attribute7 [' || p_serial_num_tbl(l_index).attribute7 || ']';
9451 l_message_tbl(l_message_tbl.count+1) := 'attribute8 [' || p_serial_num_tbl(l_index).attribute8 || ']';
9452 l_message_tbl(l_message_tbl.count+1) := 'attribute9 [' || p_serial_num_tbl(l_index).attribute9 || ']';
9453 l_message_tbl(l_message_tbl.count+1) := 'attribute10 [' || p_serial_num_tbl(l_index).attribute10 || ']';
9454 l_message_tbl(l_message_tbl.count+1) := 'attribute11 [' || p_serial_num_tbl(l_index).attribute11 || ']';
9455 l_message_tbl(l_message_tbl.count+1) := 'attribute12 [' || p_serial_num_tbl(l_index).attribute12 || ']';
9456 l_message_tbl(l_message_tbl.count+1) := 'attribute13 [' || p_serial_num_tbl(l_index).attribute13 || ']';
9457 l_message_tbl(l_message_tbl.count+1) := 'attribute14 [' || p_serial_num_tbl(l_index).attribute14 || ']';
9458 l_message_tbl(l_message_tbl.count+1) := 'attribute15 [' || p_serial_num_tbl(l_index).attribute15 || ']';
9459
9460 -- Log the constructed data...
9461 l_counter := l_message_tbl.first;
9462 l_log_message := null;
9463
9464 l_stmt_num := 30;
9465
9466 WHILE l_counter IS NOT NULL LOOP
9467 IF length(l_log_message || l_message_tbl(l_counter)) > 3900 THEN
9468 -- Log the data in l_log_message...
9469 WSM_log_PVT.logMessage(p_module_name => l_module ,
9470 p_msg_text => l_log_message ,
9471 p_stmt_num => l_stmt_num ,
9472 p_msg_tokens => l_msg_tokens ,
9473 p_fnd_log_level => g_log_level_statement ,
9474 p_run_log_level => l_log_level
9475 );
9476 l_log_message := null;
9477 END IF;
9478
9479 l_log_message := l_log_message || l_message_tbl(l_counter);
9480 l_counter := l_message_tbl.next(l_counter);
9481
9482 END LOOP;
9483
9484 l_stmt_num := 40;
9485 -- Log the remainder data..
9486 IF l_log_message IS NOT NULL THEN
9487 -- Log the data in l_log_message...
9488 WSM_log_PVT.logMessage(p_module_name => l_module ,
9489 p_msg_text => l_log_message ,
9490 p_stmt_num => l_stmt_num ,
9491 p_msg_tokens => l_msg_tokens ,
9492 p_fnd_log_level => g_log_level_statement ,
9493 p_run_log_level => l_log_level
9494 );
9495
9496 END IF;
9497
9498 l_index := p_serial_num_tbl.next(l_index);
9499 END LOOP;
9500 END IF;
9501 l_stmt_num := 50;
9502 EXCEPTION
9503 WHEN OTHERS THEN
9504
9505 x_return_status := G_RET_UNEXPECTED;
9506
9507 IF (G_LOG_LEVEL_UNEXPECTED >= l_log_level) OR
9508 (FND_MSG_PUB.check_msg_level(G_MSG_LVL_UNEXP_ERROR))
9509 THEN
9510 WSM_log_PVT.handle_others( p_module_name => l_module ,
9511 p_stmt_num => l_stmt_num ,
9512 p_fnd_log_level => G_LOG_LEVEL_UNEXPECTED ,
9513 p_run_log_level => l_log_level
9514 );
9515 END IF;
9516
9517 FND_MSG_PUB.Count_And_Get ( p_encoded => 'F' ,
9518 p_count => x_error_count ,
9519 p_data => x_error_msg
9520 );
9521 END log_serial_data;
9522
9523 end WSM_Serial_support_PVT;