[Home] [Help]
PACKAGE BODY: APPS.RLM_RD_SV
Source
1 PACKAGE BODY RLM_RD_SV as
2 /*$Header: RLMDPRDB.pls 120.15.12010000.2 2008/07/30 12:52:24 sunilku ship $*/
3 /*===========================================================================*/
4 --
5 l_DEBUG NUMBER := NVL(fnd_profile.value('RLM_DEBUG_MODE'),-1);
6
7 g_sch_line_qty NUMBER := 0; --Bugfix 6131516
8 g_del_reconcile VARCHAR2(1) := 'N'; --Bugfix 6131516
9 g_inc_exception VARCHAR2(1) := 'N'; --Bugfix 6159269
10 --
11 /*============================================================================
12
13 PROCEDURE NAME: RecDemand
14
15 ==============================================================================*/
16 PROCEDURE RecDemand(x_InterfaceHeaderId IN NUMBER,
17 x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
18 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
19 x_ReturnStatus OUT NOCOPY NUMBER)
20 IS
21 --
22 v_ReGroup_ref t_Cursor_ref;
23 v_ReGroup_rec rlm_dp_sv.t_Group_rec;
24 x_progress VARCHAR2(3) := '010';
25 e_lines_locked EXCEPTION;
26 v_sf_org_id NUMBER;
27 v_rso_start_date DATE;
28 v_Processed VARCHAR2(1) := 'N';
29 --
30 BEGIN
31 --
32 IF (l_debug <> -1) THEN
33 rlm_core_sv.dpush(k_SDEBUG,'RecDemand');
34 rlm_core_sv.dlog(k_DEBUG,'InterfaceHeaderId',x_Sched_rec.header_id);
35 END IF;
36 --
37 -- We set the return status = sucess at the start
38 -- if there are errors the status will become error or else will complete
39 -- as success
40 --
41 x_ReturnStatus := rlm_core_sv.k_PROC_SUCCESS;
42 --
43 IF (l_debug <> -1) THEN
44 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.headerId',x_Sched_rec.header_id);
45 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_type',
46 x_Sched_rec.schedule_type);
47 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_purpose',
48 x_Sched_rec.schedule_purpose);
49 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_source',
50 x_Sched_rec.schedule_source);
51 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_generation_date',
52 x_Sched_rec.sched_generation_date);
53 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date',
54 x_Sched_rec.sched_horizon_start_date);
55 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date',
56 x_Sched_rec.sched_horizon_end_date);
57 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_reference_num',
58 x_Sched_rec.schedule_reference_num);
59 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.isSourced',
60 x_Group_rec.isSourced);
61 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab.COUNT', g_SourceTab.COUNT);
62 END IF;
63 --
64 g_Reconcile_Tab.DELETE;
65 -- Bug 4223359
66 g_IsFirm := FALSE;
67 g_IntransitTab.DELETE;
68 g_Accounted_Tab.DELETE;
69 g_BlktIntransits := FALSE;
70 g_IntransitQty := FND_API.G_MISS_NUM;
71 --
72 RLM_TPA_SV.InitializeSoGroup(x_Sched_rec, v_ReGroup_ref, x_Group_rec);
73 --
74 WHILE FetchGroup(v_ReGroup_ref, v_ReGroup_rec) LOOP
75 --{
76 CallSetups(x_Sched_rec, v_ReGroup_rec);
77 v_ReGroup_rec.isSourced := x_Group_rec.isSourced;
78 --
79 ProcessReleases(x_Sched_rec, v_ReGroup_rec, v_Processed);
80 --
81 IF (l_debug <> -1) THEN
82 rlm_core_sv.dlog(k_DEBUG, 'Releases Processed (Y/N)', v_Processed);
83 END IF;
84 --
85 v_ReGroup_rec.order_header_id := NULL;
86 v_ReGroup_rec.blanket_number := NULL;
87 --
88 IF NVL(v_Processed, 'N') = 'N' THEN
89 RecGroupDemand(x_Sched_rec, v_ReGroup_rec);
90 END IF;
91 --
92 IF (l_debug <> -1) THEN
93 rlm_core_sv.dlog(k_DEBUG, 'Cleaning up global tables');
94 END IF;
95 --
96 g_Reconcile_Tab.DELETE;
97 g_IntransitTab.DELETE;
98 g_BlktIntransits := FALSE;
99 -- Bug 4223359
100 g_IsFirm := FALSE;
101 --}
102 END LOOP;
103 --
104 --x_ReturnStatus := rlm_core_sv.k_PROC_ERROR;
105 --
106 IF (l_debug <> -1) THEN
107 rlm_core_sv.dpop(k_SDEBUG);
108 END IF;
109 --
110 EXCEPTION
111 --
112 WHEN e_lines_locked THEN
113 --
114 x_ReturnStatus := rlm_core_sv.k_PROC_ERROR;
115 --
116 rlm_message_sv.app_error(
117 x_ExceptionLevel => rlm_message_sv.k_error_level,
118 x_MessageName => 'RLM_LOCK_NOT_OBTAINED',
119 x_InterfaceHeaderId => x_Sched_rec.header_id,
120 x_InterfaceLineId => NULL,
121 x_ScheduleHeaderId => x_Sched_rec.schedule_header_id,
122 x_ScheduleLineId => NULL,
123 x_OrderHeaderId => x_Group_rec.setup_terms_rec.header_id,
124 x_OrderLineId => NULL,
125 --x_ErrorText => 'Lock Not Obtained',
126 x_Token1 => 'SCHED_REF',
127 x_value1 => x_Sched_rec.schedule_reference_num);
128 --
129 IF (l_debug <> -1) THEN
130 rlm_core_sv.dpop(k_SDEBUG,'lines locked already');
131 END IF;
132 --
133 WHEN e_Group_error THEN
134 --
135 x_ReturnStatus := rlm_core_sv.k_PROC_ERROR;
136 --
137 IF (l_debug <> -1) THEN
138 rlm_core_sv.dpop(k_SDEBUG,'Group error');
139 END IF;
140 --
141 WHEN NO_DATA_FOUND THEN
142 --
143 x_ReturnStatus := rlm_core_sv.k_PROC_ERROR;
144 --
145 IF (l_debug <> -1) THEN
146 rlm_core_sv.dlog(k_DEBUG,'No data found in Interface headers for headerId',
147 x_Sched_rec.header_id);
148 rlm_core_sv.dpop(k_SDEBUG);
149 END IF;
150 --
151 WHEN OTHERS THEN
152 --
153 x_ReturnStatus := rlm_core_sv.k_PROC_ERROR;
154 rlm_message_sv.sql_error('rlm_rd_sv.RecDemand',x_progress);
155 --
156 IF (l_debug <> -1) THEN
157 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
158 END IF;
159 --
160 END RecDemand;
161
162
163 /*============================================================================
164
165 PROCEDURE NAME: RecGroupDemand
166
167 ============================================================================*/
168
169 PROCEDURE RecGroupDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
170 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
171 IS
172 --
173 x_progress VARCHAR2(3) := '010';
174 --
175 -- JAUTOMO: pdue hierarchy
176 e_MRPOnly EXCEPTION;
177
178 -- Bug 4351397
179 CURSOR c_order_dem IS
180 SELECT header_id,
181 line_id,
182 ship_from_org_id,
183 ship_to_org_id,
184 ordered_item_id,
185 inventory_item_id,
186 invoice_to_org_id,
187 intmed_ship_to_org_id,
188 demand_bucket_type_code,
189 rla_schedule_type_code,
190 authorized_to_ship_flag ATS,
191 ordered_quantity orig_ordered_quantity,
192 NVL(ordered_quantity,0) -
193 NVL(shipped_quantity,0) ordered_quantity,
194 ordered_item,
195 item_identifier_type,
196 item_type_code,
197 DECODE(x_Group_rec.setup_terms_rec.blanket_number, NULL,
198 NULL, blanket_number) blanket_number,
199 customer_line_number,
200 customer_production_line cust_production_line,
201 customer_dock_code,
202 request_date,
203 schedule_ship_date,
204 cust_po_number,
205 item_revision customer_item_revision,
206 customer_job,
207 cust_model_serial_number,
208 cust_production_seq_num,
209 industry_attribute1,
210 industry_attribute2,
211 industry_attribute3,
212 industry_attribute4,
213 industry_attribute5,
214 industry_attribute6,
215 industry_attribute7,
216 industry_attribute8,
217 industry_attribute9,
218 industry_attribute10,
219 industry_attribute11,
220 industry_attribute12,
221 industry_attribute13,
222 industry_attribute14,
223 industry_attribute15,
224 attribute1,
225 attribute2,
226 attribute3,
227 attribute4,
228 attribute5,
229 attribute6,
230 attribute7,
231 attribute8,
232 attribute9,
233 attribute10,
234 attribute11,
235 attribute12,
236 attribute13,
237 attribute14,
238 attribute15,
239 request_date +
240 DECODE(demand_bucket_type_code,
241 k_WEEKLY,6.99999,
242 k_MONTHLY,29.99999,
243 k_QUARTERLY,89.99999,0.99999) end_date_time,
244 DECODE(rla_schedule_type_code,
245 x_Group_rec.schedule_type_one, 1,
246 x_Group_rec.schedule_type_two, 2,
247 x_Group_rec.schedule_type_three, 3) schedule_hierarchy
248 FROM oe_order_lines_all
249 WHERE header_id = x_Group_rec.order_header_id
250 AND open_flag = 'Y'
251 AND ship_from_org_id = DECODE(g_ATP, k_ATP, ship_from_org_id, x_Group_rec.ship_from_org_id)
252 AND ship_to_org_id = x_Group_rec.ship_to_org_id
253 AND ordered_item_id = x_Group_rec.customer_item_id
254 AND inventory_item_id = x_Group_rec.inventory_item_id
255 AND NVL(intmed_ship_to_org_id,k_NNULL) = NVL(x_Group_rec.intmed_ship_to_org_id,k_NNULL) --Bugfix 5911991
256 AND NVL(industry_attribute15, k_VNULL) =
257 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
258 NVL(x_Group_rec.industry_attribute15, k_VNULL))
259 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS') BETWEEN
260 DECODE(authorized_to_ship_flag,k_ATS,
261 DECODE(x_group_rec.disposition_code,
262 k_REMAIN_ON_FILE,x_Sched_rec.sched_horizon_start_date,
263 k_REMAIN_ON_FILE_RECONCILE, to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS'),
264 TRUNC(SYSDATE) - nvl(x_Group_rec.Cutoff_days,0)),
265 TRUNC(SYSDATE))
266 AND TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999
267 AND DECODE(rla_schedule_type_code,
268 x_Group_rec.schedule_type_one, 1,
269 x_Group_rec.schedule_type_two, 2,
270 x_Group_rec.schedule_type_three, 3,0) >
271 DECODE(x_Sched_rec.schedule_type, x_Group_rec.schedule_type_one, 1,
272 x_Group_rec.schedule_type_two, 2,
273 x_Group_rec.schedule_type_three, 3)
274 AND (NVL(ordered_quantity,0) - NVL(shipped_quantity,0) > 0)
275 ORDER BY request_date DESC;
276 --
277 BEGIN
278 --
279 IF (l_debug <> -1) THEN
280 rlm_core_sv.dpush(k_SDEBUG, 'RecGroupDemand');
281 rlm_core_sv.dlog(k_DEBUG, 'x_Group_rec.isSourced', x_Group_rec.isSourced);
282 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.schedule_purpose',
283 x_Sched_rec.schedule_purpose);
284 END IF;
285 --
286 g_Op_tab.DELETE;
287 --global_atp
288 g_Op_tab_Unschedule.DELETE;
289 --Bugfix 5620035 Initialize to null
290 g_order_rec :=NULL;
291 --
292 /* These are now part of RecDemand */
293 --g_Reconcile_tab.DELETE;
294 --g_IntransitTab.DELETE;
295 --CallSetups(x_Sched_rec, x_Group_rec);
296 --
297 -- JAUTOMO: pdue hierarchy
298 IF MRPOnly(x_Sched_rec, x_Group_rec) THEN
299 RAISE e_MRPOnly;
300 END IF;
301 --
302 IF x_Group_rec.order_header_id IS NULL THEN
303 x_group_rec.order_header_id := x_Group_rec.setup_terms_rec.header_id;
304 END IF;
305 --
306 IF x_Group_rec.blanket_number IS NULL THEN
307 x_Group_rec.blanket_number := x_Group_rec.setup_terms_rec.blanket_number;
308 END IF;
309 --
310 IF (l_debug <> -1) THEN
311 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis', x_Group_Rec.setup_terms_Rec.intransit_calc_basis);
312 rlm_core_sv.dlog(k_DEBUG, 'Order Header Id', x_Group_rec.order_header_id); rlm_core_sv.dlog(k_DEBUG, 'Blanket Number', x_Group_rec.blanket_number);
313 END IF;
314 --
315 --global_atp
316 IF RLM_MANAGE_DEMAND_SV.IsATPItem(x_group_rec.ship_from_org_id,x_group_rec.inventory_item_id) THEN
317 g_ATP := k_ATP;
318 ELSE
319 g_ATP := k_NON_ATP;
320 END IF;
321 --
322 IF x_Sched_rec.schedule_purpose IN (k_REPLACE, k_REPLACE_ALL, k_ORIGINAL,K_CHANGE) THEN
323 --
324 CancelPreHorizonNATS(x_Sched_rec, x_Group_rec);
325 RLM_TPA_SV.SynchronizeShipments(x_Sched_rec, x_Group_rec);
326 RLM_TPA_SV.ProcessPreHorizonATS(x_Sched_rec, x_Group_rec);
327 RLM_TPA_SV.ProcessOld(x_Sched_rec, x_Group_rec);
328 --
329 END IF;
330 --
331 IF x_Sched_rec.schedule_purpose = k_ADD THEN
332 --
333 RLM_TPA_SV.ProcessOld(x_Sched_rec, x_Group_rec);
334 --
335 END IF;
336 --
337 -- Bug 4351397 : Start
338 -- Here, we consider the existing demands populated by higher precedence schedules
339 -- and get the most recent request date. When the incoming schedule has a lower
340 -- precedence, the new requirements falling on/prior to this most recent request
341 -- date will not be inserted. See InsertRequirement().
342 --
343 OPEN c_order_dem;
344 --
345 FETCH c_order_dem INTO g_order_rec ;
346 --
347 IF c_order_dem%FOUND THEN
348 --
349 IF (l_debug <> -1) THEN
350 rlm_core_sv.dlog(k_DEBUG,'--- Most recent existing demand populated by higher precedence schedule ---' );
351 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.request_date', g_order_rec.request_date);
352 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.line_id', g_order_rec.line_id);
353 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.rla_schedule_type_code', g_order_rec.rla_schedule_type_code);
354 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.industry_attribute3', g_order_rec.industry_attribute3);
355 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.schedule_hierarchy', g_order_rec.schedule_hierarchy);
356 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.ordered_item_id', g_order_rec.ordered_item_id);
357 rlm_core_sv.dlog(k_DEBUG,'g_order_rec.inventory_item_id', g_order_rec.inventory_item_id);
358 END IF;
359 --
360 END IF;
361 --
362 CLOSE c_order_dem ;
363 --
364 -- Bug 4351397 : End
365 --
366 -- the following order of ATS and then NATS is used reg.bug1548628
367 --
368 RLM_TPA_SV.ProcessATS(x_Sched_rec, x_Group_rec);
369 --
370 --Start of bug fix 4223359
371 --
372 IF (l_debug <> -1) THEN
373 rlm_core_sv.dlog(k_DEBUG, 'g_max_rso_hdr_id',g_max_rso_hdr_id);
374 rlm_core_sv.dlog(k_DEBUG, 'x_group_rec.blanket_number',x_group_rec.blanket_number);
375 rlm_core_sv.dlog(k_DEBUG, 'g_isFirm',g_isFirm);
376 END IF;
377 --
378 IF NOT g_isFirm AND x_group_rec.blanket_number is NOT NULL
379 AND x_group_rec.order_header_id = g_max_rso_hdr_id THEN
380 --
381 FrozenFenceWarning(x_Sched_rec, x_Group_rec);
382 --
383 END IF;
384 --
385 IF NOT g_isFirm AND x_group_rec.blanket_number is NULL THEN
386 --
387 FrozenFenceWarning(x_Sched_rec, x_Group_rec);
388 --
389 END IF;
390 --
391 --End of bug fix 4223359
392 --
393 RLM_TPA_SV.ProcessNATS(x_Sched_rec, x_Group_rec);
394 --
395 ExecOperations(x_Sched_rec, x_Group_rec);
396 --
397 -- Bug 2261743
398 IF (l_debug <> -1) THEN
399 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
400 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
401 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
402 END IF;
403 --
404 IF (l_debug <> -1) THEN
405 rlm_core_sv.dpop(k_SDEBUG);
406 END IF;
407 --
408 EXCEPTION
409 --
410 WHEN e_MRPOnly THEN
411 --
412 IF (l_debug <> -1) THEN
413 rlm_core_sv.dlog(k_DEBUG,'MRP Requirements only. There is no need to reconcile against Sales Order');
414 rlm_core_sv.dpop(k_SDEBUG);
415 END IF;
416
417 WHEN e_group_error THEN
418 --
419 IF (l_debug <> -1) THEN
420 rlm_core_sv.dlog(k_DEBUG,'group error');
421 rlm_core_sv.dpop(k_SDEBUG);
422 END IF;
423 --
424 raise e_group_error;
425 --
426 WHEN OTHERS THEN
427 --
428 rlm_message_sv.sql_error('rlm_rd_sv.RecGroupDemand',x_progress);
429 --
430 IF (l_debug <> -1) THEN
431 rlm_core_sv.dpop(k_SDEBUG);
432 END IF;
433 --
434 RAISE;
435 --
436 END RecGroupDemand;
437
438 /*===========================================================================
439
440 PROCEDURE CallSetups
441
442 ===========================================================================*/
443 PROCEDURE CallSetups(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
444 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
445 IS
446 --
447 v_SetupTerms_rec rlm_setup_terms_sv.setup_terms_rec_typ;
448 v_TermsLevel VARCHAR2(30) := NULL;
449 v_ReturnStatus BOOLEAN;
450 v_ReturnMsg VARCHAR2(3000);
451 e_SetupAPIFailed EXCEPTION;
452 x_progress VARCHAR2(3) := '010';
453 v_InterfaceLineId NUMBER;
454 --
455 BEGIN
456 --
457 IF (l_debug <> -1) THEN
458 rlm_core_sv.dpush(k_SDEBUG,'CallSetups');
459 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id',x_Group_rec.ship_from_org_id);
460 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_id',x_Group_rec.customer_id);
461 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_address_id',x_Group_rec.ship_to_address_id);
462 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id',x_Group_rec.customer_item_id);
463 END IF;
464 --
465 -- NOTE: call rla setups to populate setup info in the group rec:
466 -- schedule precedence, match within/across strings, firm disposition code
467 -- offset days, order header id
468 --
469 RLM_TPA_SV.get_setup_terms(x_Group_rec.ship_from_org_id,
470 x_Group_rec.customer_id,
471 x_Group_rec.ship_to_address_id,
472 x_Group_rec.customer_item_id,
473 v_TermsLevel,
474 v_SetupTerms_rec,
475 v_ReturnMsg,
476 v_ReturnStatus);
477 --
478 IF (l_debug <> -1) THEN
479 rlm_core_sv.dlog(k_DEBUG, 'v_TermsLevel', v_TermsLevel);
480 rlm_core_sv.dlog(k_DEBUG, 'v_ReturnStatus', v_ReturnStatus);
481 rlm_core_sv.dlog(k_DEBUG,'v_SetupTerms_rec.schedule_hierarchy_code',
482 v_SetupTerms_rec.schedule_hierarchy_code);
483 rlm_core_sv.dlog(k_DEBUG,'v_SetupTerms_rec.header_id',
484 v_SetupTerms_rec.header_id);
485 rlm_core_sv.dlog(k_DEBUG,'v_SetupTerms_rec.demand_tolerance_above',
486 v_SetupTerms_rec.demand_tolerance_above);
487 rlm_core_sv.dlog(k_DEBUG,'v_SetupTerms_rec.demand_tolerance_below',
488 v_SetupTerms_rec.demand_tolerance_below);
489 END IF;
490 --
491 IF NOT v_ReturnStatus THEN
492 --
493 RAISE e_SetupAPIFailed;
494 --
495 IF (l_debug <> -1) THEN
496 rlm_core_sv.dlog(k_DEBUG,'setups failed');
497 END IF;
498 --
499 ELSE
500 --
501 x_Group_rec.match_within := v_SetupTerms_rec.match_within_key;
502 --
503 x_Group_rec.match_across := v_SetupTerms_rec.match_across_key;
504 --
505 IF (l_debug <> -1) THEN
506 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.match_within',
507 x_Group_rec.match_within);
508 END IF;
509 --
510 rlm_core_sv.populate_match_keys(x_Group_rec.match_within_rec,
511 x_Group_rec.match_within);
512 --
513 IF (l_debug <> -1) THEN
514 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.match_across',
515 x_Group_rec.match_across);
516 END IF;
517 --
518 rlm_core_sv.populate_match_keys(x_Group_rec.match_across_rec,
519 x_Group_rec.match_across);
520 --
521 IF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,1,3) = 'PLN' THEN
522 --
523 x_Group_rec.schedule_type_one := k_PLANNING;
524 --
525 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,1,3) = 'SHP' THEN
526 --
527 x_Group_rec.schedule_type_one := k_SHIPPING;
528 --
529 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,1,3) = 'SEQ' THEN
530 --
531 x_Group_rec.schedule_type_one := k_SEQUENCED;
532 --
533 ELSE
534 --
535 x_Group_rec.schedule_type_one := NULL;
536 --
537 END IF;
538 --
539 IF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,5,3) = 'PLN' THEN
540 --
541 x_Group_rec.schedule_type_two := k_PLANNING;
542 --
543 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,5,3) = 'SHP' THEN
544 --
545 x_Group_rec.schedule_type_two := k_SHIPPING;
546 --
547 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,5,3) = 'SEQ' THEN
548 --
549 x_Group_rec.schedule_type_two := k_SEQUENCED;
550 --
551 ELSE
552 --
553 x_Group_rec.schedule_type_two := NULL;
554 --
555 END IF;
556 --
557 IF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,9,3) = 'PLN' THEN
558 --
559 x_Group_rec.schedule_type_three := k_PLANNING;
560 --
561 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,9,3) = 'SHP' THEN
562 --
563 x_Group_rec.schedule_type_three := k_SHIPPING;
564 --
565 ELSIF SUBSTR(v_SetupTerms_rec.schedule_hierarchy_code,9,3) = 'SEQ' THEN
566 --
567 x_Group_rec.schedule_type_three := k_SEQUENCED;
568 --
569 ELSE
570 --
571 x_Group_rec.schedule_type_three := NULL;
572 --
573 END IF;
574 --
575 x_Group_rec.disposition_code := v_SetupTerms_rec.unshipped_firm_disp_cd;
576 --
577 x_Group_rec.cutoff_days := v_SetupTerms_rec.unship_firm_cutoff_days;
578 --
579 IF (l_debug <> -1) THEN
580 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.disposition_code',
581 x_Group_rec.disposition_code);
582 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.cutoff_days',
583 x_Group_rec.cutoff_days);
584 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_one',
585 x_Group_rec.schedule_type_one);
586 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_two',
587 x_Group_rec.schedule_type_two);
588 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_three',
589 x_Group_rec.schedule_type_three);
590 END IF;
591 --
592 IF x_Sched_rec.Schedule_type = k_PLANNING THEN
593 --
594 IF v_SetupTerms_rec.pln_frozen_day_from IS NOT NULL THEN
595 --
596 x_Group_rec.frozen_days := nvl(v_SetupTerms_rec.pln_frozen_day_to,0)
597 - nvl(v_SetupTerms_rec.pln_frozen_day_from,0) + 1;
598 --
599 x_Group_rec.roll_forward_frozen_flag:=v_SetupTerms_rec.pln_frozen_flag;
600 --
601 ELSE
602 --
603 x_Group_rec.frozen_days := 0;
604 --
605 x_Group_rec.roll_forward_frozen_flag:='N';
606 --
607 END IF;
608 --
609 ELSIF x_Sched_rec.Schedule_type = k_SHIPPING THEN
610 --
611 IF v_SetupTerms_rec.shp_frozen_day_from IS NOT NULL THEN
612 --
613 x_Group_rec.frozen_days := nvl(v_SetupTerms_rec.shp_frozen_day_to,0)
614 - nvl(v_SetupTerms_rec.shp_frozen_day_from,0) + 1;
615
616 x_Group_rec.roll_forward_frozen_flag:=v_SetupTerms_rec.shp_frozen_flag;
617 --
618 ELSE
619 --
620 x_Group_rec.frozen_days := 0;
621 --
622 x_Group_rec.roll_forward_frozen_flag:='N';
623 --
624 END IF;
625 --
626 ELSIF x_Sched_rec.Schedule_type = k_SEQUENCED THEN
627 --
628 IF v_SetupTerms_rec.seq_frozen_day_from IS NOT NULL THEN
629 --
630 x_Group_rec.frozen_days := nvl(v_SetupTerms_rec.seq_frozen_day_to,0)
631 - nvl(v_SetupTerms_rec.seq_frozen_day_from,0) + 1;
632 --
633 x_Group_rec.roll_forward_frozen_flag:=v_SetupTerms_rec.seq_frozen_flag;
634 --
635 ELSE
636 --
637 x_Group_rec.frozen_days := 0;
638 x_Group_rec.roll_forward_frozen_flag:='N';
639 --
640 END IF;
641 --
642 END IF;
643 --
644 IF (l_debug <> -1) THEN
645 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.frozen_days',
646 x_Group_rec.frozen_days );
647 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.roll_forward_frozen_flag',
648 x_Group_rec.roll_forward_frozen_flag);
649 END IF;
650 --
651 -- Need to change the group rec to remove the cutoff days and the
652 -- match_within and accross keys.
653 --
654 x_Group_rec.setup_terms_rec := v_SetupTerms_rec;
655 --
656 END IF;
657 --
658 IF (l_debug <> -1) THEN
659 rlm_core_sv.dpop(k_SDEBUG);
660 END IF;
661 --
662 EXCEPTION
663 --
664 WHEN e_SetupAPIFailed THEN
665 --
666 SELECT line_id
667 INTO v_InterfaceLineId
668 FROM rlm_interface_lines
669 WHERE header_id = x_Sched_rec.header_id
670 AND ship_from_org_id = x_Group_rec.ship_from_org_id
671 AND ship_to_address_id = x_Group_rec.ship_to_address_id
672 AND customer_item_id = x_Group_rec.customer_item_id
673 AND rownum = 1;
674 --
675 rlm_message_sv.app_error(
676 x_ExceptionLevel => rlm_message_sv.k_error_level,
677 x_MessageName => 'RLM_SETUPAPI_FAILED',
678 x_ChildMessageName => v_SetupTerms_rec.msg_name,
679 x_InterfaceHeaderId => x_sched_rec.header_id,
680 x_InterfaceLineId => v_InterfaceLineId,
681 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
682 x_ScheduleLineId => NULL,
683 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
684 x_OrderLineId => NULL,
685 --x_ErrorText => 'Setup API failed',
686 x_Token1 => 'ERROR',
687 x_value1 => v_ReturnMsg);
688 --
689 IF (l_debug <> -1) THEN
690 rlm_core_sv.dlog(k_SDEBUG,'SetupAPI failed');
691 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
692 END IF;
693 --
694 raise e_group_error;
695 --
696 WHEN OTHERS THEN
697 --
698 rlm_message_sv.sql_error('rlm_rd_sv.CallSetups',x_progress);
699 --
700 IF (l_debug <> -1) THEN
701 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
702 END IF;
703 --
704 raise;
705 --
706 END CallSetups;
707
708
709 /*===========================================================================
710
711 PROCEDURE ExecOperations
712
713 ===========================================================================*/
714 PROCEDURE ExecOperations(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
715 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
716 IS
717
718 --
719 x_progress VARCHAR2(3) := '010';
720 v_ReturnStatus VARCHAR2(30);
721 --
722 BEGIN
723 --
724 IF (l_debug <> -1) THEN
725 rlm_core_sv.dpush(k_SDEBUG,'ExecOperations');
726 END IF;
727 --
728 --global_atp
729 -- Need to call ProcessConstraint for g_Op_Tab_Unschedule before doing for
730 -- g_Op_Tab
731 rlm_extinterface_sv.ProcessOperation(g_Op_Tab_Unschedule,x_Sched_rec.header_id,v_ReturnStatus);
732 --
733 IF (l_debug <> -1) THEN
734 rlm_core_sv.dlog(k_DEBUG, 'After calling Process Order API (Unscheduling)');
735 rlm_core_sv.dlog(k_DEBUG, 'v_ReturnStatus', v_ReturnStatus);
736 END IF;
737 --
738 IF v_ReturnStatus = FND_API.G_RET_STS_UNEXP_ERROR THEN
739 --
740 IF (l_debug <> -1) THEN
741 rlm_core_sv.dpop(k_SDEBUG, 'Process Order API (Unscheduling) Failed');
742 END IF;
743 --
744 RAISE e_group_error;
745 --
746 ELSIF v_ReturnStatus = FND_API.G_RET_STS_ERROR THEN
747 --
748 IF (l_debug <> -1) THEN
749 rlm_core_sv.dpop(k_SDEBUG, 'Process Order API (Unscheduling) Failed');
750 END IF;
751 --
752 RAISE e_group_error;
753 --
754 END IF;
755 --
756 -- Proceed with Process Order API (Scheduling)
757
758 rlm_extinterface_sv.ProcessOperation(g_Op_Tab,x_Sched_rec.header_id,v_ReturnStatus);
759 --
760 IF (l_debug <> -1) THEN
761 rlm_core_sv.dlog(k_DEBUG, 'After calling Process Order API (Scheduling)');
762 rlm_core_sv.dlog(k_DEBUG, 'v_ReturnStatus', v_ReturnStatus);
763 END IF;
764 --
765 IF v_ReturnStatus = FND_API.G_RET_STS_UNEXP_ERROR THEN
766 --
767 IF (l_debug <> -1) THEN
768 rlm_core_sv.dpop(k_SDEBUG, 'Process Order API Failed');
769 END IF;
770 --
771 RAISE e_group_error;
772 --
773 ELSIF v_ReturnStatus = FND_API.G_RET_STS_ERROR THEN
774 --
775 IF (l_debug <> -1) THEN
776 rlm_core_sv.dpop(k_SDEBUG, 'Process Order API Failed');
777 END IF;
778 --
779 RAISE e_group_error;
780 --
781 END IF;
782 --
783 IF (l_debug <> -1) THEN
784 rlm_core_sv.dlog(k_DEBUG, 'Process Order API Suceess');
785 rlm_core_sv.dpop(k_SDEBUG);
786 END IF;
787 --
788 EXCEPTION
789 WHEN e_group_error THEN
790 --
791 raise;
792 --
793 WHEN OTHERS THEN
794 rlm_message_sv.sql_error('rlm_rd_sv.ExecOperations', x_progress);
795 --
796 IF (l_debug <> -1) THEN
797 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
798 END IF;
799 --
800 raise;
801
802 END ExecOperations;
803
804
805 /*===========================================================================
806
807 PROCEDURE CancelPreHorizonNATS
808
809 ===========================================================================*/
810 PROCEDURE CancelPreHorizonNATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
811 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
812 IS
813
814 CURSOR c_PreHorizonNATS IS
815 SELECT line_id
816 FROM oe_order_lines
817 WHERE header_id = x_Group_rec.order_header_id
818 --global_atp
819 AND ship_from_org_id =
820 DECODE(g_ATP, k_ATP, ship_from_org_id,
821 x_Group_rec.ship_from_org_id)
822 AND ship_to_org_id = x_Group_rec.ship_to_org_id
823 AND ordered_item_id = x_Group_rec.customer_item_id
824 AND inventory_item_id= x_Group_rec.inventory_item_id
825 --global_atp
826 AND NVL(industry_attribute15, k_VNULL) =
827 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
828 NVL(x_Group_rec.industry_attribute15, k_VNULL))
829 --bug 2181228
830 /*AND NVL(cust_production_seq_num, k_NNULL) =
831 NVL(x_Group_rec.cust_production_seq_num, k_NNULL)*/
832 --
833 --AND request_date < x_Sched_rec.sched_horizon_start_date --chg
834 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS')
835 < TRUNC(SYSDATE)
836 --pdue
837 -- < x_Sched_rec.sched_horizon_start_date
838 AND authorized_to_ship_flag = k_NATS
839 AND nvl(ordered_quantity,0 ) - nvl(shipped_quantity,0) > 0;
840
841 v_Key_rec t_Key_rec;
842 v_DeleteQty NUMBER;
843
844 x_progress VARCHAR2(3) := '010';
845
846 BEGIN
847 --
848 IF (l_debug <> -1) THEN
849 rlm_core_sv.dpush(k_SDEBUG,'CancelPreHorizonNATS');
850 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id',
851 x_Group_rec.order_header_id);
852 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id',
853 x_Group_rec.ship_from_org_id);
854 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id',
855 x_Group_rec.ship_to_org_id);
856 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id',
857 x_Group_rec.customer_item_id);
858 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',
859 x_Group_rec.inventory_item_id);
860 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date',
861 x_Sched_rec.sched_horizon_start_date);
862 END IF;
863 --
864 FOR c_PreHorizonNATS_rec IN c_PreHorizonNATS LOOP
865 --
866 IF (l_debug <> -1) THEN
867 rlm_core_sv.dlog(k_DEBUG,'c_PreHorizonNATS_rec.line_id',
868 c_PreHorizonNATS_rec.line_id);
869 END IF;
870 --
871 v_Key_rec.oe_line_id := c_PreHorizonNATS_rec.line_id;
872 --
873 GetDemand(v_Key_rec, x_Group_rec);
874 --
875 v_Key_rec.req_rec := v_Key_rec.dem_rec;
876 --
877 DeleteRequirement(x_Sched_rec, x_Group_rec,
878 v_Key_rec, k_NORECONCILE, v_DeleteQty);
879 --
880 END LOOP;
881 --
882 IF (l_debug <> -1) THEN
883 rlm_core_sv.dpop(k_SDEBUG);
884 END IF;
885 --
886 EXCEPTION
887 --
888 WHEN e_group_error THEN
889 --
890 IF (l_debug <> -1) THEN
891 rlm_core_sv.dlog(k_DEBUG,'group error');
892 rlm_core_sv.dpop(k_SDEBUG);
893 END IF;
894 --
895 raise e_group_error;
896
897 WHEN OTHERS THEN
898 rlm_message_sv.sql_error('rlm_rd_sv.CancelPreHorizonNATS',x_progress);
899 --
900 IF (l_debug <> -1) THEN
901 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
902 END IF;
903 --
904 raise;
905
906 END CancelPreHorizonNATS;
907
908
909 /*===========================================================================
910
911 FUNCTION ProcessConstraint
912
913 ===========================================================================*/
914 FUNCTION ProcessConstraint(x_Key_rec IN RLM_RD_SV.t_Key_rec,
915 x_Qty_rec OUT NOCOPY t_Qty_rec,
916 x_Operation IN VARCHAR2,
917 x_OperationQty IN NUMBER := 0)
918 RETURN BOOLEAN
919 IS
920 b_Result BOOLEAN := FALSE;
921 x_progress VARCHAR2(3) := '010';
922
923 BEGIN
924 --
925 IF (l_debug <> -1) THEN
926 rlm_core_sv.dpush(k_SDEBUG,'ProcessConstraint');
927 rlm_core_sv.dlog(k_DEBUG,'x_Operation',x_Operation);
928 rlm_core_sv.dlog(k_DEBUG,'x_OperationQty',x_OperationQty);
929 END IF;
930 --
931 IF x_Operation = k_UPDATE_ATTR THEN
932 --
933 b_Result := rlm_extinterface_sv.CallProcessConstraintAPI(x_key_rec,
934 x_Qty_rec,
935 'UPDATE',
936 x_OperationQty);
937 --
938 ELSE
939 --
940 b_Result := rlm_extinterface_sv.CallProcessConstraintAPI(x_key_rec,
941 x_Qty_rec,
942 x_Operation,
943 x_OperationQty);
944 --
945 END IF;
946 --
947 IF x_Operation = k_DELETE THEN
948 IF b_Result THEN
949 x_Qty_rec.reconcile := x_Key_rec.dem_rec.ordered_quantity;
950 -- ASH : Temp fix till process constraint returns the quantity
951 x_Qty_rec.available_to_cancel := 0;
952 ELSE
953 -- ASH : Temp fix till process constraint returns the quantity
954 x_Qty_rec.reconcile := 0;
955 x_Qty_rec.ordered := x_Key_rec.dem_rec.ordered_quantity;
956 x_Qty_rec.available_to_cancel := 0;
957 END IF;
958 ELSIF x_Operation = k_INSERT THEN
959 NULL;
960 ELSIF x_Operation = k_UPDATE THEN
961 IF b_Result THEN
962 x_Qty_rec.reconcile := x_Key_rec.req_rec.ordered_quantity
963 - x_Key_rec.dem_rec.ordered_quantity;
964 -- ASH :Temp fix till process constraint returns the quantity
965 x_Qty_rec.available_to_cancel := 0;
966 ELSE
967 -- ASH : Temp fix till process constraint returns the quantity
968 x_Qty_rec.reconcile := 0;
969 x_Qty_rec.ordered := x_Key_rec.dem_rec.ordered_quantity;
970 x_Qty_rec.available_to_cancel := 0;
971 END IF;
972 ELSIF x_Operation = k_UPDATE_ATTR THEN
973 NULL;
974 END IF;
975
976 IF b_Result THEN
977 --
978 IF (l_debug <> -1) THEN
979 rlm_core_sv.dpop(k_SDEBUG, 'true');
980 END IF;
981 --
982 ELSE
983 --
984 IF (l_debug <> -1) THEN
985 rlm_core_sv.dpop(k_SDEBUG, 'false');
986 END IF;
987 --
988 END IF;
989 --
990 RETURN(b_Result);
991 --
992 EXCEPTION
993 WHEN OTHERS THEN
994 rlm_message_sv.sql_error('rlm_rd_sv.ProcessConstraint',x_progress);
995 --
996 IF (l_debug <> -1) THEN
997 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
998 END IF;
999 --
1000 raise;
1001
1002 END ProcessConstraint;
1003
1004 /*===========================================================================
1005
1006 FUNCTION FetchGroup
1007
1008 ===========================================================================*/
1009 FUNCTION FetchGroup(x_Group_ref IN OUT NOCOPY t_Cursor_ref,
1010 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
1011 RETURN BOOLEAN
1012 IS
1013
1014 x_progress VARCHAR2(3) := '010';
1015 BEGIN
1016 --
1017 IF (l_debug <> -1) THEN
1018 rlm_core_sv.dpush(k_SDEBUG,'FetchGroup');
1019 END IF;
1020 --
1021 FETCH x_Group_ref INTO
1022 x_Group_rec.customer_id,
1023 x_Group_rec.ship_from_org_id,
1024 x_Group_rec.ship_to_address_id,
1025 x_Group_rec.ship_to_org_id,
1026 x_Group_rec.customer_item_id,
1027 x_Group_rec.inventory_item_id,
1028 x_Group_rec.industry_attribute15,
1029 x_Group_rec.intrmd_ship_to_id, --Bugfix 5911991
1030 x_Group_rec.intmed_ship_to_org_id ; --Bugfix 5911991
1031 --x_Group_rec.order_header_id,
1032 --x_Group_rec.blanket_number;
1033 --x_Group_rec.cust_production_seq_num;
1034 --
1035 IF x_Group_ref%NOTFOUND THEN
1036 --
1037 IF (l_debug <> -1) THEN
1038 rlm_core_sv.dpop(k_SDEBUG, 'false');
1039 END IF;
1040 --
1041 RETURN(FALSE);
1042 --
1043 ELSE
1044 --
1045 IF (l_debug <> -1) THEN
1046 rlm_core_sv.dpop(k_SDEBUG, 'true');
1047 END IF;
1048 --
1049 RETURN(TRUE);
1050 --
1051 END IF;
1052
1053 EXCEPTION
1054 WHEN OTHERS THEN
1055 rlm_message_sv.sql_error('rlm_rd_sv.FetchGroup',x_progress);
1056 --
1057 IF (l_debug <> -1) THEN
1058 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
1059 END IF;
1060 --
1061 raise;
1062
1063 END FetchGroup;
1064
1065 /*===========================================================================
1066
1067 FUNCTION NAME: RemainOnFile
1068
1069 ===========================================================================*/
1070
1071 FUNCTION RemainOnFile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
1072 x_Key_rec IN RLM_RD_SV.t_Key_rec)
1073 RETURN BOOLEAN
1074 IS
1075 v_Progress VARCHAR2(3) := '010';
1076 BEGIN
1077 --
1078 IF (l_debug <> -1) THEN
1079 rlm_core_sv.dpush(k_SDEBUG,'RemainOnFile');
1080 END IF;
1081 --
1082 IF (TO_DATE(x_key_rec.dem_rec.industry_attribute2,'RRRR/MM/DD HH24:MI:SS') < TRUNC(SYSDATE)) AND x_key_rec.dem_rec.authorized_to_ship_flag = 'Y' THEN
1083 --
1084 IF x_group_rec.disposition_code = k_REMAIN_ON_FILE THEN
1085 --
1086 IF (l_debug <> -1) THEN
1087 rlm_core_sv.dlog(k_DEBUG,'Remain on File');
1088 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
1089 END IF;
1090 RETURN TRUE;
1091 --
1092 ELSIF x_group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS THEN
1093 --
1094 IF TO_DATE(x_key_rec.dem_rec.industry_attribute2,'RRRR/MM/DD HH24:MI:SS') >= (TRUNC(SYSDATE) - NVL(x_group_rec.cutoff_days,0)) THEN
1095 --
1096 IF (l_debug <> -1) THEN
1097 rlm_core_sv.dlog(k_DEBUG,'Between cutoff and sysdate');
1098 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
1099 END IF;
1100 RETURN TRUE;
1101 --
1102 END IF;
1103 --
1104 END IF;
1105 --
1106 END IF;
1107 --
1108 IF (l_debug <> -1) THEN
1109 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
1110 END IF;
1111 --
1112 RETURN FALSE;
1113 --
1114 EXCEPTION
1115
1116 WHEN OTHERS THEN
1117 --
1118 rlm_message_sv.sql_error('RLM_RD_SV.RemainOnFile', v_Progress);
1119 IF (l_debug <> -1) THEN
1120 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '|| SUBSTR(SQLERRM,1,200));
1121 END IF;
1122 RAISE;
1123
1124 END RemainOnFile;
1125
1126 /*===========================================================================
1127
1128 PROCEDURE DeleteRequirement
1129
1130 ===========================================================================*/
1131 PROCEDURE DeleteRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
1132 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
1133 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
1134 x_Reconcile IN BOOLEAN,
1135 x_DeleteQty OUT NOCOPY NUMBER)
1136 IS
1137
1138 v_Qty_rec t_Qty_rec;
1139 x_progress VARCHAR2(3) := '010';
1140 -- For Shipping API
1141 v_changed_attributes WSH_SHIPPING_CONSTRAINTS_PKG.ChangedAttributeRecType;
1142 v_return_status VARCHAR2(4);
1143 v_action_allowed VARCHAR2(2);
1144 v_action_message VARCHAR2(30);
1145 v_ord_qty_allowed NUMBER := 0;
1146 v_source_code VARCHAR2(3) := 'OE';
1147 --v_log_level NUMBER := 0;
1148 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
1149 v_del_line_qty NUMBER :=0; --Bugfix 6159269
1150
1151 BEGIN
1152
1153 IF (l_debug <> -1) THEN
1154 rlm_core_sv.dpush(k_SDEBUG,'DeleteRequirement');
1155 rlm_core_sv.dlog(k_DEBUG,'x_Reconcile',x_Reconcile);
1156 rlm_core_sv.dlog(k_DEBUG,'g_del_reconcile',g_del_reconcile); --Bugfix 6131516
1157 END IF;
1158 --
1159 /*passing the header_id so it can create proper error message if
1160 process order api fails*/
1161
1162 x_key_rec.dem_rec.header_id := x_Sched_rec.header_id;
1163 x_key_rec.dem_rec.schedule_header_id := x_Sched_rec.schedule_header_id;
1164 x_key_rec.req_rec.header_id := x_Sched_rec.header_id;
1165 x_key_rec.req_rec.schedule_header_id := x_Sched_rec.schedule_header_id;
1166
1167 --pdue
1168 IF x_Sched_rec.schedule_source <> 'MANUAL' AND
1169 IsFrozen(TRUNC(SYSDATE),
1170 x_Group_rec, x_key_rec.dem_rec.request_date) THEN
1171 --
1172 IF (l_debug <> -1) THEN
1173 rlm_core_sv.dlog(k_DEBUG,'Line cannot be deleted-- within frozen fence',
1174 x_key_rec.dem_rec.line_id);
1175 rlm_core_sv.dlog(k_DEBUG,'dem_rec.request_date',
1176 x_key_rec.dem_rec.request_date);
1177 END IF;
1178 --
1179 IF x_Reconcile THEN
1180 --
1181 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1182 x_key_rec.dem_rec.ordered_quantity);/*2263253*/
1183 --
1184 END IF;
1185 --
1186 -- Bug 4297984 Start
1187 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.dem_rec,v_MatchAttrTxt);
1188 --
1189 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
1190
1191 IF (x_Key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
1192 --
1193 rlm_message_sv.app_error(
1194 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1195 x_MessageName => 'RLM_FROZEN_DELETE_SEQ',
1196 x_InterfaceHeaderId => x_sched_rec.header_id,
1197 x_InterfaceLineId => NULL,
1198 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1199 x_ScheduleLineId => NULL,
1200 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1201 x_OrderLineId => x_key_rec.dem_rec.line_id,
1202 x_Token1 => 'LINE',
1203 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
1204 x_Token2 => 'ORDER',
1205 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1206 x_Token3 => 'QUANTITY',
1207 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
1208 x_Token4 => 'CUSTITEM',
1209 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1210 x_Token5 => 'REQ_DATE',
1211 x_value5 => x_key_rec.dem_rec.request_date,
1212 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
1213 x_value6 => v_del_line_qty, --Bugfix 6159269
1214 x_Token7 => 'SEQ_INFO',
1215 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL')||'-'||
1216 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
1217 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
1218 x_Token8 => 'MATCH_ATTR',
1219 x_value8 => v_MatchAttrTxt );
1220 --
1221 IF (l_debug <> -1) THEN
1222 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE_SEQ',x_key_rec.dem_rec.line_id);
1223 END IF;
1224 --
1225 ELSE
1226 --
1227 rlm_message_sv.app_error(
1228 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1229 x_MessageName => 'RLM_FROZEN_DELETE',
1230 x_InterfaceHeaderId => x_sched_rec.header_id,
1231 x_InterfaceLineId => NULL,
1232 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1233 x_ScheduleLineId => NULL,
1234 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1235 x_OrderLineId => x_key_rec.dem_rec.line_id,
1236 x_Token1 => 'LINE',
1237 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
1238 x_Token2 => 'ORDER',
1239 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1240 x_Token3 => 'QUANTITY',
1241 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
1242 x_Token4 => 'CUSTITEM',
1243 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1244 x_Token5 => 'REQ_DATE',
1245 x_value5 => x_key_rec.dem_rec.request_date,
1246 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
1247 x_value6 => v_del_line_qty, --Bugfix 6159269
1248 x_Token7 => 'MATCH_ATTR',
1249 x_value7 => v_MatchAttrTxt);
1250 --
1251 IF (l_debug <> -1) THEN
1252 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE',x_key_rec.dem_rec.line_id);
1253 END IF;
1254 --
1255 END IF;
1256
1257 END IF; --Bugfix 6159269
1258 -- Bug 4297984 End
1259 ELSIF ProcessConstraint(x_Key_rec, v_Qty_rec, k_DELETE) THEN
1260 --
1261 --CancelRequirement(x_Sched_rec, x_Group_rec,
1262 --x_Key_rec, v_Qty_rec.available_to_cancel);
1263 IF x_Reconcile THEN
1264 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1265 v_Qty_rec.reconcile);
1266 END IF;
1267 --x_DeleteQty := v_Qty_rec.available_to_cancel;
1268 --rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1269 --
1270 ELSE
1271 --
1272 -- Call to check if Shipping allows delete
1273 -- Use 'D' for delete, 'U' for update, and 'C' for cancel
1274 --
1275 IF (l_debug <> -1) THEN
1276 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.dem_rec.line_id',x_key_rec.dem_rec.line_id);
1277 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.oe_line_id',x_key_rec.oe_line_id);
1278 END IF;
1279 --
1280 v_changed_attributes.action_flag := 'D';
1281 v_changed_attributes.source_line_id := nvl(x_Key_rec.oe_line_id, x_key_rec.dem_rec.line_id);
1282 --
1283 IF (l_debug <> -1) THEN
1284 rlm_core_sv.dlog(k_DEBUG,'source_line_id',v_changed_attributes.source_line_id);
1285 END IF;
1286 --
1287 RLM_EXTINTERFACE_SV.CheckShippingConstraints(
1288 x_source_code => v_source_code,
1289 x_changed_attributes => v_changed_attributes,
1290 x_return_status => v_return_status,
1291 x_action_allowed => v_action_allowed,
1292 x_action_message => v_action_message,
1293 x_ord_qty_allowed => v_ord_qty_allowed,
1294 x_header_id => x_Sched_rec.header_id,
1295 x_order_header_id => x_group_rec.setup_terms_rec.header_id);
1296 --
1297 IF (l_debug <> -1) THEN
1298 rlm_core_sv.dlog(k_DEBUG,'v_action_allowed',v_action_allowed);
1299 rlm_core_sv.dlog(k_DEBUG,'v_return_status',v_return_status);
1300 END IF;
1301 --
1302 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1303 --
1304 IF (l_debug <> -1) THEN
1305 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed. Unexpected Error');
1306 END IF;
1307 --
1308 RAISE e_group_error;
1309 --
1310 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1311 --
1312 IF (l_debug <> -1) THEN
1313 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed.');
1314 END IF;
1315 --
1316 RAISE e_group_error;
1317 --
1318 END IF;
1319 --
1320 IF (v_action_allowed = 'N') THEN
1321
1322 -- bug 5199318
1323 IF ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE, 0) THEN
1324 --{
1325 --
1326
1327 IF x_Reconcile THEN
1328 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec, x_key_rec.dem_rec.ordered_quantity);
1329 END IF;
1330
1331 --
1332 --}
1333 ELSE
1334 --{
1335 --
1336 -- Call again to see if Shipping allows Cancel
1337 -- Use 'D' for delete, 'U' for update, and 'C' for cancel
1338 --
1339 IF (l_debug <> -1) THEN
1340 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',x_Key_rec.oe_line_id);
1341 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',x_Key_rec.dem_rec.line_id);
1342 END IF;
1343 --
1344 v_changed_attributes.action_flag := 'C';
1345 v_changed_attributes.source_line_id := nvl(x_Key_rec.oe_line_id,
1346 x_key_rec.dem_rec.line_id);
1347 --
1348 IF (l_debug <> -1) THEN
1349 rlm_core_sv.dlog(k_DEBUG,'source_line_id',v_changed_attributes.source_line_id);
1350 END IF;
1351 --
1352 RLM_EXTINTERFACE_SV.CheckShippingConstraints(
1353 x_source_code => v_source_code,
1354 x_changed_attributes => v_changed_attributes,
1355 x_return_status => v_return_status,
1356 x_action_allowed => v_action_allowed,
1357 x_action_message => v_action_message,
1358 x_ord_qty_allowed => v_ord_qty_allowed,
1359 x_header_id => x_Sched_rec.header_id,
1360 x_order_header_id => x_group_rec.setup_terms_rec.header_id);
1361 --
1362 IF (l_debug <> -1) THEN
1363 rlm_core_sv.dlog(k_DEBUG,'v_action_allowed',v_action_allowed);
1364 rlm_core_sv.dlog(k_DEBUG,'v_return_status',v_return_status);
1365 END IF;
1366 --
1367 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1368 --
1369 IF (l_debug <> -1) THEN
1370 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed');
1371 END IF;
1372 --
1373 RAISE e_group_error;
1374 --
1375 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1376 --
1377 IF (l_debug <> -1) THEN
1378 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed.');
1379 END IF;
1380 --
1381 RAISE e_group_error;
1382 --
1383 END IF;
1384 --
1385 IF (v_action_allowed = 'N') THEN
1386 --
1387 IF x_Reconcile THEN
1388 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1389 v_Qty_rec.reconcile);
1390 END IF;
1391 --
1392 ELSE
1393 --
1394 IF NOT RemainOnFile(x_group_rec, x_key_rec) THEN
1395 --
1396 x_DeleteQty := 0;
1397 SetOperation(x_Key_rec, k_UPDATE, x_DeleteQty);
1398 --
1399 IF (l_debug <> -1) THEN
1400 rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1401 END IF;
1402 --
1403 END IF;
1404 --
1405 END IF;
1406 --}
1407 END IF; -- bug 5199318
1408 --
1409 ELSE
1410 --
1411 IF NOT RemainOnFile(x_group_rec, x_key_rec) THEN
1412 --
1413 SetOperation(x_Key_rec, k_DELETE);
1414 x_DeleteQty := v_Qty_rec.ordered;
1415 --
1416 --Bugfix 6131516 Start
1417 IF g_sch_line_qty >0 AND g_del_reconcile = 'Y' THEN
1418 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1419 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1420 --
1421 rlm_message_sv.app_error(
1422 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1423 x_MessageName => 'RLM_RECONCILE_DELETE_SEQ',
1424 x_InterfaceHeaderId => x_sched_rec.header_id,
1425 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1426 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1427 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1428 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1429 x_OrderLineId => NULL,
1430 x_Token1 => 'QUANTITY',
1431 x_value1 => g_sch_line_qty,
1432 x_Token2 => 'GROUP',
1433 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1434 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1435 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1436 x_Token3 => 'REQ_DATE',
1437 x_value3 => x_key_rec.req_rec.request_date,
1438 x_Token4 => 'START_DATE_TIME',
1439 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1440 x_Token5 => 'SEQ_INFO',
1441 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1442 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1443 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1444 x_Token6 => 'ORDER',
1445 x_value6 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1446 x_Token7 => 'LINE',
1447 x_value7 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
1448 x_Token8 => 'MATCH_ATTR',
1449 x_value8 => v_MatchAttrTxt);
1450 --
1451 IF (l_debug <> -1) THEN
1452 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1453 x_key_rec.req_rec.line_id);
1454 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1455 x_Key_rec.req_rec.cust_model_serial_number);
1456 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1457 x_Key_rec.req_rec.request_date);
1458 END IF;
1459 --
1460 ELSE
1461 --
1462 rlm_message_sv.app_error(
1463 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1464 x_MessageName => 'RLM_RECONCILE_DELETE',
1465 x_InterfaceHeaderId => x_sched_rec.header_id,
1466 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1467 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1468 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1469 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1470 x_OrderLineId => NULL,
1471 x_Token1 => 'QUANTITY',
1472 x_value1 => g_sch_line_qty,
1473 x_Token2 => 'GROUP',
1474 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1475 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1476 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1477 x_Token3 => 'REQ_DATE',
1478 x_value3 => x_key_rec.req_rec.request_date,
1479 x_Token4 => 'START_DATE_TIME',
1480 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1481 x_Token5 => 'SCHEDULE_LINE',
1482 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1483 x_Token6 => 'ORDER',
1484 x_value6 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1485 x_Token7 => 'LINE',
1486 x_value7 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
1487 x_Token8 => 'MATCH_ATTR',
1488 x_value8 => v_MatchAttrTxt);
1489 --
1490 IF (l_debug <> -1) THEN
1491 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1492 x_key_rec.req_rec.line_id);
1493 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1494 x_Key_rec.req_rec.cust_model_serial_number);
1495 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1496 x_Key_rec.req_rec.request_date);
1497 END IF;
1498 --
1499 END IF; /* Exception */
1500
1501 END IF;/* Check g_sch_line_qty*/
1502 --Bugfix 6131516 End
1503
1504 IF (l_debug <> -1) THEN
1505 rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1506 END IF;
1507 --
1508 END IF;
1509 --
1510 END IF;
1511 --
1512 END IF;
1513 --
1514 IF (l_debug <> -1) THEN
1515 rlm_core_sv.dpop(k_SDEBUG);
1516 END IF;
1517 --
1518 EXCEPTION
1519 --
1520 WHEN e_group_error THEN
1521 --
1522 RAISE;
1523 --
1524 WHEN OTHERS THEN
1525 --
1526 rlm_message_sv.sql_error('rlm_rd_sv.DeleteRequirement',x_progress);
1527 --
1528 IF (l_debug <> -1) THEN
1529 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
1530 END IF;
1531 --
1532 raise;
1533
1534 END DeleteRequirement;
1535
1536 /*===========================================================================
1537
1538 PROCEDURE InsertRequirement
1539
1540 ===========================================================================*/
1541 PROCEDURE InsertRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
1542 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
1543 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
1544 x_Reconcile IN BOOLEAN,
1545 x_Quantity IN OUT NOCOPY NUMBER)
1546 IS
1547
1548 x_progress VARCHAR2(3) := '010';
1549 v_RF_Enabled VARCHAR2(1) := 'N';
1550 e_FrozenFences EXCEPTION;
1551 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
1552 v_Quantity NUMBER; -- Bug 4297984
1553
1554 BEGIN
1555 --
1556 IF (l_debug <> -1) THEN
1557 rlm_core_sv.dpush(k_SDEBUG,'InsertRequirement');
1558 rlm_core_sv.dlog(k_DEBUG,'x_Reconcile',x_Reconcile);
1559 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1560 rlm_core_sv.dlog(k_DEBUG,'request_date',x_key_rec.req_rec.request_date);
1561 END IF;
1562
1563 --logic to roll forward frozen fence goes here
1564
1565 v_RF_Enabled:=x_Group_rec.roll_forward_frozen_flag;
1566 --
1567 IF (l_debug <> -1) THEN
1568 rlm_core_sv.dlog(k_DEBUG,' Rollforward set to: ', v_RF_Enabled);
1569 END IF;
1570 --
1571 -- bug 4223359 first reconcile the quantity in the reconcile table before trying to
1572 -- insert the new requirement. If there is additional qty after reconciling then
1573 -- check for frozenfences and if not within frozen fence then insert that qty.
1574 --
1575 IF x_Quantity > 0 THEN
1576 --
1577 v_Quantity := x_Quantity; -- Bug 4297984
1578 --
1579 IF x_Reconcile THEN
1580 --
1581 RLM_TPA_SV.ReconcileShipments(x_Group_rec, x_Key_rec, x_Quantity);
1582 --
1583 IF (l_debug <> -1) THEN
1584 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1585 END IF;
1586 --
1587 Reconcile(x_Group_rec, x_Key_rec, x_Quantity);
1588 --
1589 END IF;
1590 --
1591 IF (l_debug <> -1) THEN
1592 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1593 END IF;
1594 --
1595 IF x_Quantity = 0 THEN
1596 -- Bug 4297984 Start
1597 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1598 --
1599 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1600 --
1601 rlm_message_sv.app_error(
1602 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1603 x_MessageName => 'RLM_RECONCILE_ZERO_INSERT_SEQ',
1604 x_InterfaceHeaderId => x_sched_rec.header_id,
1605 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1606 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1607 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1608 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1609 x_OrderLineId => NULL,
1610 x_Token1 => 'QUANTITY',
1611 x_value1 => v_Quantity,
1612 x_Token2 => 'GROUP',
1613 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1614 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1615 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1616 x_Token3 => 'REQ_DATE',
1617 x_value3 => x_key_rec.req_rec.request_date,
1618 x_Token4 => 'START_DATE_TIME',
1619 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1620 x_Token5 => 'SEQ_INFO',
1621 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1622 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1623 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1624 x_Token6 => 'MATCH_ATTR',
1625 x_value6 => v_MatchAttrTxt);
1626 --
1627 IF (l_debug <> -1) THEN
1628 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1629 x_key_rec.req_rec.line_id);
1630 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1631 x_Key_rec.req_rec.cust_model_serial_number);
1632 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1633 x_Key_rec.req_rec.request_date);
1634 END IF;
1635 --
1636 ELSE
1637 --
1638 rlm_message_sv.app_error(
1639 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1640 x_MessageName => 'RLM_RECONCILE_ZERO_INSERT',
1641 x_InterfaceHeaderId => x_sched_rec.header_id,
1642 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1643 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1644 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1645 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1646 x_OrderLineId => NULL,
1647 x_Token1 => 'QUANTITY',
1648 x_value1 => v_Quantity,
1649 x_Token2 => 'GROUP',
1650 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1651 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1652 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1653 x_Token3 => 'REQ_DATE',
1654 x_value3 => x_key_rec.req_rec.request_date,
1655 x_Token4 => 'START_DATE_TIME',
1656 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1657 x_Token5 => 'SCHEDULE_LINE',
1658 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1659 x_Token6 => 'MATCH_ATTR',
1660 x_value6 => v_MatchAttrTxt);
1661 --
1662 IF (l_debug <> -1) THEN
1663 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1664 x_key_rec.req_rec.line_id);
1665 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1666 x_Key_rec.req_rec.cust_model_serial_number);
1667 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1668 x_Key_rec.req_rec.request_date);
1669 END IF;
1670 --
1671 END IF;
1672 -- Bug 4297984 End
1673 ELSE
1674 --
1675 IF (l_debug <> -1) THEN
1676 rlm_core_sv.dlog(k_DEBUG,'schedule_source',x_Sched_rec.schedule_source);
1677 END IF;
1678 --
1679 -- start of bug fix 4223359
1680 --
1681 IF x_Sched_rec.schedule_source <> 'MANUAL' AND nvl(v_RF_Enabled,'N') = 'N' THEN
1682 --
1683 IF IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date) OR
1684 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.schedule_date) THEN
1685 --
1686 IF (l_debug <> -1) THEN
1687 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
1688 x_key_rec.req_rec.line_id);
1689 rlm_core_sv.dlog(k_DEBUG, 'Not inserting line', x_key_rec.req_rec.line_id);
1690 rlm_core_sv.dlog(k_DEBUG, 'Qty not inserting ', x_quantity);
1691 END IF;
1692 --
1693 -- If not able to insert the new quantity due to frozen fence
1694 -- store that quantity with a negative quantity in the g_reconcile_tab
1695 -- for that calling store shipments as store shipment stores req_rec
1696 --
1697 x_Key_rec.req_rec.shipment_flag := NULL;
1698 --
1699 x_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
1700 --
1701 StoreShipments(x_Sched_rec, x_Group_rec, x_Key_rec, -x_quantity);
1702 --
1703 IF (l_debug <> -1) THEN
1704 --
1705 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.schedule_type',
1706 x_Key_rec.req_rec.schedule_type);
1707 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.shipment_flag',
1708 x_Key_rec.req_rec.shipment_flag);
1709 --
1710 END IF;
1711 --
1712 RAISE e_FrozenFences;
1713 --
1714 END IF;
1715 --
1716 END IF;
1717 --
1718 -- end of bug fix 4223359
1719 --
1720 IF v_RF_Enabled = 'Y' AND
1721 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date) AND
1722 x_Sched_rec.schedule_source <> 'MANUAL' THEN
1723 --
1724 IF (l_debug <> -1) THEN
1725 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.frozen_days',x_Group_rec.frozen_days);
1726 END IF;
1727 --
1728 x_key_rec.req_rec.request_date := TRUNC(SYSDATE)
1729 + nvl(x_Group_rec.frozen_days,0);
1730 --
1731 IF (l_debug <> -1) THEN
1732 rlm_core_sv.dlog(k_DEBUG,'request_date',x_key_rec.req_rec.request_date);
1733 END IF;
1734 --
1735 END IF;
1736 --
1737 IF v_RF_Enabled = 'Y' AND
1738 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.schedule_date) AND
1739 x_Sched_rec.schedule_source <> 'MANUAL' THEN
1740 --
1741 IF (l_debug <> -1) THEN
1742 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.frozen_days',x_Group_rec.frozen_days);
1743 END IF;
1744 --pdue
1745 x_key_rec.req_rec.schedule_date := TRUNC(SYSDATE)
1746 + nvl(x_Group_rec.frozen_days,0);
1747 --
1748 IF (l_debug <> -1) THEN
1749 rlm_core_sv.dlog(k_DEBUG,'schedule_date',x_key_rec.req_rec.schedule_date);
1750 END IF;
1751 --
1752 END IF;
1753 --
1754 -- Bug 4351397 : Start
1755 --
1756 IF g_order_rec.request_date IS NOT NULL THEN
1757 --
1758 IF trunc(g_order_rec.request_date) < trunc(x_Key_rec.req_rec.request_date) THEN
1759 --
1760 SetOperation(x_Key_rec, k_INSERT, x_Quantity);
1761 --
1762 ELSE
1763 --
1764 IF (l_debug <> -1) THEN
1765 --
1766 rlm_core_sv.dlog(k_DEBUG,'Insertion will not happen as a demand populated by higher precedence ' ||
1767 g_order_rec.rla_schedule_type_code || ' schedule exists on ' ||
1768 g_order_rec.request_date);
1769 --
1770 END IF;
1771 --
1772 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec, v_MatchAttrTxt);
1773 --
1774 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1775 --
1776 rlm_message_sv.app_error(
1777 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1778 x_MessageName => 'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1779 x_InterfaceHeaderId => x_sched_rec.header_id,
1780 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1781 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1782 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1783 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1784 x_OrderLineId => NULL,
1785 x_Token1 => 'QUANTITY',
1786 x_value1 => x_Key_rec.req_rec.primary_quantity,
1787 x_Token2 => 'GROUP',
1788 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1789 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1790 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1791 x_Token3 => 'REQ_DATE',
1792 x_value3 => x_key_rec.req_rec.request_date,
1793 x_Token4 => 'START_DATE_TIME',
1794 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1795 x_Token5 => 'SCHEDULE_TYPE',
1796 x_value5 => g_order_rec.rla_schedule_type_code,
1797 x_Token6 => 'SCHEDULE_NUM',
1798 x_value6 => g_order_rec.industry_attribute3,
1799 x_Token7 => 'RECENT_REQ_DATE',
1800 x_value7 => g_order_rec.request_date,
1801 x_Token8 => 'ORDER',
1802 x_value8 => rlm_core_sv.get_order_number(g_order_rec.header_id),
1803 x_Token9 => 'SEQ_INFO',
1804 x_value9 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1805 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1806 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1807 x_Token10 => 'MATCH_ATTR',
1808 x_value10 => v_MatchAttrTxt);
1809 --
1810 IF (l_debug <> -1) THEN
1811 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1812 x_key_rec.req_rec.line_id);
1813 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1814 x_Key_rec.req_rec.cust_model_serial_number);
1815 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1816 x_Key_rec.req_rec.request_date);
1817 END IF;
1818 --
1819 ELSE
1820 --
1821 rlm_message_sv.app_error(
1822 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1823 x_MessageName => 'RLM_LOW_PRECEDENCE_INSERT',
1824 x_InterfaceHeaderId => x_sched_rec.header_id,
1825 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1826 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1827 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1828 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1829 x_OrderLineId => NULL,
1830 x_Token1 => 'QUANTITY',
1831 x_value1 => x_Key_rec.req_rec.primary_quantity,
1832 x_Token2 => 'GROUP',
1833 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1834 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1835 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1836 x_Token3 => 'REQ_DATE',
1837 x_value3 => x_key_rec.req_rec.request_date,
1838 x_Token4 => 'START_DATE_TIME',
1839 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1840 x_Token5 => 'SCHEDULE_TYPE',
1841 x_value5 => g_order_rec.rla_schedule_type_code,
1842 x_Token6 => 'SCHEDULE_NUM',
1843 x_value6 => g_order_rec.industry_attribute3,
1844 x_Token7 => 'RECENT_REQ_DATE',
1845 x_value7 => g_order_rec.request_date,
1846 x_Token8 => 'ORDER',
1847 x_value8 => rlm_core_sv.get_order_number(g_order_rec.header_id),
1848 x_Token9 => 'SCHEDULE_LINE',
1849 x_value9 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1850 x_Token10 => 'MATCH_ATTR',
1851 x_value10 => v_MatchAttrTxt);
1852 --
1853 IF (l_debug <> -1) THEN
1854 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1855 x_key_rec.req_rec.line_id);
1856 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1857 x_Key_rec.req_rec.cust_model_serial_number);
1858 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1859 x_Key_rec.req_rec.request_date);
1860 END IF;
1861 --
1862 END IF;
1863 --
1864 END IF ;
1865 --
1866 ELSE
1867 --
1868 SetOperation(x_Key_rec, k_INSERT, x_Quantity);
1869 --
1870 END IF;
1871 --
1872 -- Bug 4351397 : End
1873 --
1874 END IF;
1875 --
1876 END IF;
1877 --
1878 IF (l_debug <> -1) THEN
1879 rlm_core_sv.dpop(k_SDEBUG);
1880 END IF;
1881
1882 EXCEPTION
1883 WHEN e_FrozenFences THEN
1884 -- Bug 4297984 Start
1885 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1886 --
1887 IF g_inc_exception <> 'Y' THEN --Bugfix 6159269
1888 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1889 --
1890 rlm_message_sv.app_error(
1891 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1892 x_MessageName => 'RLM_FROZEN_INSERT_SEQ',
1893 x_InterfaceHeaderId => x_sched_rec.header_id,
1894 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1895 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1896 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1897 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1898 x_OrderLineId => NULL,
1899 x_Token1 => 'QUANTITY',
1900 x_value1 => x_Key_rec.req_rec.primary_quantity,
1901 x_Token2 => 'GROUP',
1902 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1903 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1904 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1905 x_Token3 => 'REQ_DATE',
1906 x_value3 => x_key_rec.req_rec.request_date,
1907 x_Token4 => 'START_DATE_TIME',
1908 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1909 x_Token5 => 'SEQ_INFO',
1910 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL')||'-'||
1911 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1912 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1913 x_Token6 => 'MATCH_ATTR',
1914 x_value6 => v_MatchAttrTxt);
1915 --
1916 IF (l_debug <> -1) THEN
1917 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_INSERT_SEQ',
1918 x_key_rec.req_rec.line_id);
1919 rlm_core_sv.dpop(k_SDEBUG);
1920 END IF;
1921 --
1922 ELSE
1923 --
1924 rlm_message_sv.app_error(
1925 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1926 x_MessageName => 'RLM_FROZEN_INSERT',
1927 x_InterfaceHeaderId => x_sched_rec.header_id,
1928 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1929 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1930 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1931 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1932 x_OrderLineId => NULL,
1933 x_Token1 => 'QUANTITY',
1934 x_value1 => x_Key_rec.req_rec.primary_quantity,
1935 x_Token2 => 'GROUP',
1936 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1937 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1938 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1939 x_Token3 => 'REQ_DATE',
1940 x_value3 => x_key_rec.req_rec.request_date,
1941 x_Token4 => 'START_DATE_TIME',
1942 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1943 x_Token5 => 'SCHEDULE_LINE',
1944 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1945 x_Token6 => 'MATCH_ATTR',
1946 x_value6 => v_MatchAttrTxt);
1947 --
1948 IF (l_debug <> -1) THEN
1949 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_INSERT',
1950 x_key_rec.req_rec.line_id);
1951 rlm_core_sv.dpop(k_SDEBUG);
1952 END IF;
1953 --
1954 END IF;
1955 END IF; /*IF g_inc_exception */ --Bugfix 6159269
1956
1957 -- Bug 4297984 End
1958 WHEN OTHERS THEN
1959 rlm_message_sv.sql_error('rlm_rd_sv.InsertRequirement',x_progress);
1960 --
1961 IF (l_debug <> -1) THEN
1962 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
1963 END IF;
1964 --
1965 raise;
1966
1967 END InsertRequirement;
1968
1969 /*===========================================================================
1970
1971 PROCEDURE UpdateRequirement
1972
1973 ===========================================================================*/
1974 PROCEDURE UpdateRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
1975 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
1976 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
1977 x_Quantity IN NUMBER)
1978 IS
1979
1980 v_Qty_rec t_Qty_rec;
1981 x_progress VARCHAR2(3) := '010';
1982 v_RF_Enabled VARCHAR2(1) := 'N';
1983 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
1984 v_line_id_tab t_matching_line;
1985
1986 BEGIN
1987 --
1988 IF (l_debug <> -1) THEN
1989 rlm_core_sv.dpush(k_SDEBUG,'UpdateRequirement');
1990 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1991 END IF;
1992 --
1993 -- logic to get roll forward values
1994 v_RF_Enabled:=x_Group_rec.roll_forward_frozen_flag;
1995 --
1996 IF (l_debug <> -1) THEN
1997 rlm_core_sv.dlog(k_DEBUG, 'Rollforward set to: ', v_RF_Enabled);
1998 END IF;
1999 --
2000 --pdue
2001 --
2002 IF x_Sched_rec.schedule_source <> 'MANUAL' AND
2003 (IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_Key_rec.req_rec.schedule_date) OR
2004 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date)) THEN
2005 --{
2006 IF nvl(v_RF_Enabled, 'N') = 'N' THEN
2007 --{
2008 -- Bug 4297984 Start
2009 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.dem_rec,v_MatchAttrTxt);
2010 --
2011 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
2012 --
2013 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
2014 --
2015 rlm_message_sv.app_error(
2016 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2017 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
2018 x_InterfaceHeaderId => x_sched_rec.header_id,
2019 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2020 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2021 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2022 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2023 x_OrderLineId => x_key_rec.dem_rec.line_id,
2024 x_Token1 => 'LINE',
2025 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
2026 x_Token2 => 'ORDER',
2027 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
2028 x_Token3 => 'QUANTITY',
2029 x_value3 => x_key_rec.dem_rec.ordered_quantity,
2030 x_Token4 => 'CUSTITEM',
2031 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2032 x_Token5 => 'REQ_DATE',
2033 x_value5 => x_key_rec.dem_rec.request_date,
2034 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
2035 x_value6 => g_sch_line_qty, --Bugfix 6159269
2036 x_Token7 => 'SEQ_INFO',
2037 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL')||'-'||
2038 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
2039 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
2040 x_Token8 => 'MATCH_ATTR',
2041 x_value8 => v_MatchAttrTxt);
2042 --
2043 IF (l_debug <> -1) THEN
2044 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
2045 x_key_rec.req_rec.line_id);
2046 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
2047 x_key_rec.req_rec.line_id);
2048 END IF;
2049 --
2050 ELSE
2051 --
2052 rlm_message_sv.app_error(
2053 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2054 x_MessageName => 'RLM_FROZEN_UPDATE',
2055 x_InterfaceHeaderId => x_sched_rec.header_id,
2056 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2057 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2058 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2059 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2060 x_OrderLineId => x_key_rec.dem_rec.line_id,
2061 x_Token1 => 'LINE',
2062 x_value1 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
2063 x_Token2 => 'ORDER',
2064 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
2065 x_Token3 => 'QUANTITY',
2066 x_value3 => x_key_rec.dem_rec.ordered_quantity,
2067 x_Token4 => 'CUSTITEM',
2068 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2069 x_Token5 => 'REQ_DATE',
2070 x_value5 => x_key_rec.dem_rec.request_date,
2071 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
2072 x_value6 => g_sch_line_qty, --Bugfix 6159269
2073 x_Token7 => 'MATCH_ATTR',
2074 x_value7 => v_MatchAttrTxt);
2075 --
2076 IF (l_debug <> -1) THEN
2077 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
2078 x_key_rec.req_rec.line_id);
2079 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
2080 x_key_rec.req_rec.line_id);
2081 END IF;
2082 --
2083 END IF;
2084 --
2085 END IF; --Bugfix 6159269
2086 -- Bug 4297984 End
2087 --}
2088 ELSE
2089 --{
2090 IF (l_debug <> -1) THEN
2091 rlm_core_sv.dlog(k_DEBUG,'dem_rec.ordered_quantity:',
2092 x_key_rec.dem_rec.ordered_quantity);
2093 rlm_core_sv.dlog(k_DEBUG,'frozen_days:',
2094 x_Group_rec.frozen_days);
2095 END IF;
2096 --
2097 x_key_rec.req_rec.request_date := TRUNC(SYSDATE) +
2098 nvl(x_Group_rec.frozen_days,0);
2099 x_key_rec.req_rec.schedule_Date := TRUNC(SYSDATE) +
2100 nvl(x_Group_rec.frozen_days,0);
2101 --
2102 IF (x_key_rec.dem_rec.ordered_quantity < x_Quantity ) THEN
2103 --
2104 SetOperation(x_Key_rec, k_INSERT,
2105 x_Quantity - x_key_rec.dem_rec.ordered_quantity);
2106 --
2107 ELSE
2108 --
2109 -- Bug 3999833 : Update the quantity on the OE line
2110 --
2111 SetOperation(x_Key_rec, k_UPDATE, x_Quantity);
2112 --
2113 END IF;
2114 --}
2115 END IF;
2116 --}
2117 ELSE
2118 --
2119 -- Bug 5122974
2120 --
2121 v_line_id_tab(0) := x_Key_rec.dem_rec.line_id;
2122 --
2123 IF not alreadyupdated(v_line_id_tab) THEN
2124 SetOperation(x_Key_rec, k_UPDATE, x_Quantity);
2125 else
2126 --
2127 if (x_Quantity < x_Key_rec.dem_rec.ordered_quantity) then
2128 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
2129 x_Key_rec, k_RECONCILE,
2130 x_Key_rec.req_rec.primary_quantity);
2131 end if;
2132 --
2133 end if;
2134 --
2135 -- End bug 5122974
2136
2137 END IF;
2138 --
2139 IF (l_debug <> -1) THEN
2140 rlm_core_sv.dpop(k_SDEBUG);
2141 END IF;
2142 --
2143 EXCEPTION
2144 WHEN OTHERS THEN
2145 rlm_message_sv.sql_error('rlm_rd_sv.UpdateRequirement',x_progress);
2146 --
2147 IF (l_debug <> -1) THEN
2148 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2149 END IF;
2150 --
2151 raise;
2152
2153 END UpdateRequirement;
2154
2155 /*===========================================================================
2156
2157 PROCEDURE GetQtyRec
2158
2159 ===========================================================================*/
2160 PROCEDURE GetQtyRec(x_Key_rec IN RLM_RD_SV.t_Key_rec,
2161 x_Qty_rec OUT NOCOPY t_Qty_rec)
2162 IS
2163
2164 x_progress VARCHAR2(3) := '010';
2165 BEGIN
2166
2167 IF (l_debug <> -1) THEN
2168 rlm_core_sv.dpush(k_SDEBUG,'GetQtyRec');
2169 rlm_core_sv.dpop(k_SDEBUG);
2170 END IF;
2171
2172 EXCEPTION
2173 WHEN OTHERS THEN
2174 rlm_message_sv.sql_error('rlm_rd_sv.GetQtyRec',x_progress);
2175 --
2176 IF (l_debug <> -1) THEN
2177 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2178 END IF;
2179 --
2180 raise;
2181
2182 END GetQtyRec;
2183
2184
2185 /*===========================================================================
2186
2187 PROCEDURE GetReq
2188
2189 ===========================================================================*/
2190 PROCEDURE GetReq(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec)
2191 IS
2192 x_progress VARCHAR2(3) := '010';
2193
2194 BEGIN
2195 --
2196 IF (l_debug <> -1) THEN
2197 rlm_core_sv.dpush(k_SDEBUG,'GetReq');
2198 END IF;
2199 --
2200 IF x_Key_rec.rlm_line_id IS NOT NULL THEN
2201 IF x_Key_rec.rlm_line_id <> NVL(x_Key_rec.req_rec.line_id,k_NNULL) THEN
2202 NULL;
2203 END IF;
2204 END IF;
2205 --
2206 IF (l_debug <> -1) THEN
2207 rlm_core_sv.dpop(k_SDEBUG);
2208 END IF;
2209 --
2210 EXCEPTION
2211 WHEN OTHERS THEN
2212 rlm_message_sv.sql_error('rlm_rd_sv.GetReq',x_progress);
2213 --
2214 IF (l_debug <> -1) THEN
2215 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2216 END IF;
2217 --
2218 raise;
2219
2220 END GetReq;
2221
2222
2223 /*===========================================================================
2224
2225 PROCEDURE GetDemand
2226
2227 ===========================================================================*/
2228 PROCEDURE GetDemand(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
2229 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
2230 IS
2231 x_progress VARCHAR2(3) := '010';
2232 v_sql VARCHAR2(32000);
2233 c_Demand t_Cursor_ref;
2234
2235 CURSOR c_blanket IS
2236 SELECT line_id,customer_production_line,customer_dock_code,request_date,
2237 schedule_ship_date,cust_po_number,item_revision customer_item_revision,
2238 customer_job,cust_model_serial_number,cust_production_seq_num,
2239 industry_attribute1,industry_attribute2,industry_attribute3,
2240 industry_attribute4,industry_attribute5,industry_attribute6,
2241 industry_attribute7,industry_attribute8,industry_attribute9,
2242 industry_attribute10,industry_attribute11,industry_attribute12,
2243 industry_attribute13,industry_attribute14,industry_attribute15,
2244 attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,
2245 attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,
2246 attribute13,attribute14,attribute15,demand_bucket_type_code,
2247 ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,
2248 ordered_item_id customer_item_id,inventory_item_id,header_id,
2249 ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,
2250 ordered_quantity,ordered_item,item_identifier_type,item_type_code,
2251 customer_line_number,blanket_number
2252 FROM oe_order_lines_all WHERE line_id = x_Key_rec.oe_line_id;
2253
2254 CURSOR c_order IS
2255 SELECT line_id,customer_production_line,customer_dock_code,request_date,
2256 schedule_ship_date,cust_po_number,item_revision customer_item_revision,
2257 customer_job,cust_model_serial_number,cust_production_seq_num,
2258 industry_attribute1,industry_attribute2,industry_attribute3,
2259 industry_attribute4,industry_attribute5,industry_attribute6,
2260 industry_attribute7,industry_attribute8,industry_attribute9,
2261 industry_attribute10,industry_attribute11,industry_attribute12,
2262 industry_attribute13,industry_attribute14,industry_attribute15,
2263 attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,
2264 attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,
2265 attribute13,attribute14,attribute15,demand_bucket_type_code,
2266 ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,
2267 ordered_item_id customer_item_id,inventory_item_id,header_id,
2268 ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,
2269 ordered_quantity,ordered_item,item_identifier_type,item_type_code,
2270 customer_line_number,NULL
2271 FROM oe_order_lines_all WHERE line_id = x_Key_rec.oe_line_id;
2272
2273 BEGIN
2274 --
2275 IF (l_debug <> -1) THEN
2276 rlm_core_sv.dpush(k_SDEBUG,'GetDemand');
2277 END IF;
2278 --
2279 IF x_Group_rec.setup_terms_rec.blanket_number IS NOT NULL THEN
2280 --
2281 OPEN c_blanket;
2282 --
2283 FETCH c_blanket INTO
2284 x_Key_rec.dem_rec.line_id,
2285 x_Key_rec.dem_rec.cust_production_line,
2286 x_Key_rec.dem_rec.customer_dock_code,
2287 x_Key_rec.dem_rec.request_date,
2288 x_Key_rec.dem_rec.schedule_date,
2289 x_Key_rec.dem_rec.cust_po_number,
2290 x_Key_rec.dem_rec.customer_item_revision,
2291 x_Key_rec.dem_rec.customer_job,
2292 x_Key_rec.dem_rec.cust_model_serial_number,
2293 x_Key_rec.dem_rec.cust_production_seq_num,
2294 x_Key_rec.dem_rec.industry_attribute1,
2295 x_Key_rec.dem_rec.industry_attribute2,
2296 x_Key_rec.dem_rec.industry_attribute3,
2297 x_Key_rec.dem_rec.industry_attribute4,
2298 x_Key_rec.dem_rec.industry_attribute5,
2299 x_Key_rec.dem_rec.industry_attribute6,
2300 x_Key_rec.dem_rec.industry_attribute7,
2301 x_Key_rec.dem_rec.industry_attribute8,
2302 x_Key_rec.dem_rec.industry_attribute9,
2303 x_Key_rec.dem_rec.industry_attribute10,
2304 x_Key_rec.dem_rec.industry_attribute11,
2305 x_Key_rec.dem_rec.industry_attribute12,
2306 x_Key_rec.dem_rec.industry_attribute13,
2307 x_Key_rec.dem_rec.industry_attribute14,
2308 x_Key_rec.dem_rec.industry_attribute15,
2309 x_Key_rec.dem_rec.attribute1,
2310 x_Key_rec.dem_rec.attribute2,
2311 x_Key_rec.dem_rec.attribute3,
2312 x_Key_rec.dem_rec.attribute4,
2313 x_Key_rec.dem_rec.attribute5,
2314 x_Key_rec.dem_rec.attribute6,
2315 x_Key_rec.dem_rec.attribute7,
2316 x_Key_rec.dem_rec.attribute8,
2317 x_Key_rec.dem_rec.attribute9,
2318 x_Key_rec.dem_rec.attribute10,
2319 x_Key_rec.dem_rec.attribute11,
2320 x_Key_rec.dem_rec.attribute12,
2321 x_Key_rec.dem_rec.attribute13,
2322 x_Key_rec.dem_rec.attribute14,
2323 x_Key_rec.dem_rec.attribute15,
2324 x_Key_rec.dem_rec.item_detail_subtype,
2325 x_Key_rec.dem_rec.ship_to_org_id,
2326 x_Key_rec.dem_rec.invoice_to_org_id,
2327 x_Key_rec.dem_rec.intmed_ship_to_org_id,
2328 x_Key_rec.dem_rec.customer_item_id,
2329 x_Key_rec.dem_rec.inventory_item_id,
2330 x_Key_rec.dem_rec.order_header_id,
2331 x_Key_rec.dem_rec.ship_from_org_id,
2332 x_Key_rec.dem_rec.schedule_type,
2333 x_Key_rec.dem_rec.authorized_to_ship_flag,
2334 x_Key_rec.dem_rec.ordered_quantity,
2335 x_Key_rec.dem_rec.customer_item_ext,
2336 x_Key_rec.dem_rec.item_identifier_type,
2337 x_Key_rec.dem_rec.item_detail_type,
2338 x_Key_rec.dem_rec.cust_po_line_num,
2339 x_Key_rec.dem_rec.blanket_number;
2340 --
2341 CLOSE c_blanket;
2342 --
2343 ELSE
2344 --
2345 OPEN c_order;
2346 --
2347 FETCH c_order INTO
2348 x_Key_rec.dem_rec.line_id,
2349 x_Key_rec.dem_rec.cust_production_line,
2350 x_Key_rec.dem_rec.customer_dock_code,
2351 x_Key_rec.dem_rec.request_date,
2352 x_Key_rec.dem_rec.schedule_date,
2353 x_Key_rec.dem_rec.cust_po_number,
2354 x_Key_rec.dem_rec.customer_item_revision,
2355 x_Key_rec.dem_rec.customer_job,
2356 x_Key_rec.dem_rec.cust_model_serial_number,
2357 x_Key_rec.dem_rec.cust_production_seq_num,
2358 x_Key_rec.dem_rec.industry_attribute1,
2359 x_Key_rec.dem_rec.industry_attribute2,
2360 x_Key_rec.dem_rec.industry_attribute3,
2361 x_Key_rec.dem_rec.industry_attribute4,
2362 x_Key_rec.dem_rec.industry_attribute5,
2363 x_Key_rec.dem_rec.industry_attribute6,
2364 x_Key_rec.dem_rec.industry_attribute7,
2365 x_Key_rec.dem_rec.industry_attribute8,
2366 x_Key_rec.dem_rec.industry_attribute9,
2367 x_Key_rec.dem_rec.industry_attribute10,
2368 x_Key_rec.dem_rec.industry_attribute11,
2369 x_Key_rec.dem_rec.industry_attribute12,
2370 x_Key_rec.dem_rec.industry_attribute13,
2371 x_Key_rec.dem_rec.industry_attribute14,
2372 x_Key_rec.dem_rec.industry_attribute15,
2373 x_Key_rec.dem_rec.attribute1,
2374 x_Key_rec.dem_rec.attribute2,
2375 x_Key_rec.dem_rec.attribute3,
2376 x_Key_rec.dem_rec.attribute4,
2377 x_Key_rec.dem_rec.attribute5,
2378 x_Key_rec.dem_rec.attribute6,
2379 x_Key_rec.dem_rec.attribute7,
2380 x_Key_rec.dem_rec.attribute8,
2381 x_Key_rec.dem_rec.attribute9,
2382 x_Key_rec.dem_rec.attribute10,
2383 x_Key_rec.dem_rec.attribute11,
2384 x_Key_rec.dem_rec.attribute12,
2385 x_Key_rec.dem_rec.attribute13,
2386 x_Key_rec.dem_rec.attribute14,
2387 x_Key_rec.dem_rec.attribute15,
2388 x_Key_rec.dem_rec.item_detail_subtype,
2389 x_Key_rec.dem_rec.ship_to_org_id,
2390 x_Key_rec.dem_rec.invoice_to_org_id,
2391 x_Key_rec.dem_rec.intmed_ship_to_org_id,
2392 x_Key_rec.dem_rec.customer_item_id,
2393 x_Key_rec.dem_rec.inventory_item_id,
2394 x_Key_rec.dem_rec.order_header_id,
2395 x_Key_rec.dem_rec.ship_from_org_id,
2396 x_Key_rec.dem_rec.schedule_type,
2397 x_Key_rec.dem_rec.authorized_to_ship_flag,
2398 x_Key_rec.dem_rec.ordered_quantity,
2399 x_Key_rec.dem_rec.customer_item_ext,
2400 x_Key_rec.dem_rec.item_identifier_type,
2401 x_Key_rec.dem_rec.item_detail_type,
2402 x_Key_rec.dem_rec.cust_po_line_num,
2403 x_Key_rec.dem_rec.blanket_number;
2404 --
2405 CLOSE c_order;
2406 --
2407 END IF;
2408 --
2409 IF (l_debug <> -1) THEN
2410 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.order_header_id',
2411 x_Key_rec.dem_rec.order_header_id);
2412 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.blanket_number',
2413 x_Key_rec.dem_rec.blanket_number);
2414 END IF;
2415 --
2416 IF (l_debug <> -1) THEN
2417 rlm_core_sv.dpop(k_SDEBUG);
2418 END IF;
2419 --
2420 EXCEPTION
2421 WHEN OTHERS THEN
2422 rlm_message_sv.sql_error('rlm_rd_sv.GetDemand',x_progress);
2423 --
2424 IF (l_debug <> -1) THEN
2425 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2426 END IF;
2427 --
2428 raise;
2429
2430 END GetDemand;
2431
2432
2433 /*===========================================================================
2434
2435 PROCEDURE InitializeDemand
2436
2437 ===========================================================================*/
2438 PROCEDURE InitializeDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
2439 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
2440 x_Key_rec IN RLM_RD_SV.t_Key_rec,
2441 x_Demand_ref IN OUT NOCOPY t_Cursor_ref,
2442 x_DemandType IN VARCHAR2)
2443 IS
2444 x_progress VARCHAR2(3) := '010';
2445 v_select_clause VARCHAR2(32000);
2446 v_where_clause VARCHAR2(32000);
2447 v_sql VARCHAR2(32000);
2448 e_no_init EXCEPTION;
2449 v_request_date_str VARCHAR2(30);
2450 BEGIN
2451 --
2452 IF (l_debug <> -1) THEN
2453 rlm_core_sv.dpush(k_SDEBUG,'InitializeDemand');
2454 END IF;
2455 --
2456 g_InitDemandTab.DELETE;
2457 --
2458 IF x_DemandType NOT IN (k_ATS, k_NATS) THEN
2459 --
2460 RAISE e_no_init;
2461 --
2462 END IF;
2463 --
2464 v_select_clause :=
2465 'SELECT line_id,NVL(ordered_quantity,0),NVL(shipped_quantity,0),'||
2466 'sold_to_org_id,customer_production_line,customer_dock_code,'||
2467 'request_date,schedule_ship_date,cust_po_number,'||
2468 'item_revision customer_item_revision,customer_job,'||
2469 'cust_model_serial_number,cust_production_seq_num,industry_attribute1,'||
2470 'industry_attribute2,industry_attribute3,industry_attribute4,'||
2471 'industry_attribute5,industry_attribute6,industry_attribute7,'||
2472 'industry_attribute8,industry_attribute9,industry_attribute10,'||
2473 'industry_attribute11,industry_attribute12,industry_attribute13,'||
2474 'industry_attribute14,industry_attribute15,industry_context,'||
2475 'attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,'||
2476 'attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,'||
2477 'attribute13,attribute14,attribute15,context,tp_attribute1,'||
2478 'tp_attribute2,tp_attribute3,tp_attribute4,tp_attribute5,tp_attribute6,'||
2479 'tp_attribute7,tp_attribute8,tp_attribute9,tp_attribute10,'||
2480 'tp_attribute11,tp_attribute12,tp_attribute13,tp_attribute14,'||
2481 'tp_attribute15,tp_context,demand_bucket_type_code,item_type_code,'||
2482 'ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,'||
2483 'ordered_item_id customer_item_id,inventory_item_id,header_id,'||
2484 'ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,'||
2485 'item_identifier_type,agreement_id,price_list_id,ordered_item,'||
2486 'order_quantity_uom,';
2487
2488 IF x_Group_rec.setup_terms_rec.blanket_number IS NOT NULL THEN
2489 --
2490 v_select_clause := v_select_clause || 'blanket_number FROM oe_order_lines';
2491 --
2492 ELSE
2493 --
2494 v_select_clause := v_select_clause || 'NULL FROM oe_order_lines';
2495 --
2496 END IF;
2497
2498 -- Mandatory Match Attributes
2499 v_where_clause :=
2500 ' WHERE header_id = :order_header_id' ||
2501 ' AND ship_to_org_id = :ship_to_org_id' ||
2502 ' AND ordered_item_id = :customer_item_id'||
2503 ' AND inventory_item_id= :inventory_item_id' ||
2504 ' AND NVL(intmed_ship_to_org_id,' || k_NNULL|| ') = NVL(:intmed_ship_to_org_id , '||k_NNULL || ')'|| --Bugfix 5911991
2505 ' AND (NVL(ordered_quantity,0) - NVL(shipped_quantity,0)) > 0' ||
2506 ' AND NVL(demand_bucket_type_code,'|| k_NNULL || ') = NVL(:item_detail_subtype,'||k_NNULL||')';
2507 --
2508 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.order_header_id;
2509 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.ship_to_org_id;
2510 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.customer_item_id;
2511 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.inventory_item_id;
2512 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.intmed_ship_to_org_id; --Bugfix 5911991
2513 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.item_detail_subtype;
2514 --
2515 -- Start of bug 4223359
2516 --If the disposition code is remain on File reconcile get all the open sales order lines
2517 --If the disposition code is remain on File then use horizon_start_date and horizon end date
2518 --If the disposition code is Cancel All then use SYSDATE
2519 --
2520 IF x_Group_rec.disposition_code = k_CANCEL_ALL THEN
2521 --
2522 v_where_clause := v_where_clause || ' AND TO_DATE(industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
2523 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(SYSDATE), 'RRRR/MM/DD HH24:MI:SS');
2524 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2525 --
2526 ELSIF x_Group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS THEN
2527 --
2528 v_where_clause := v_where_clause || ' AND TO_DATE(industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
2529 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(SYSDATE) - NVL(x_group_rec.cutoff_days,0), 'RRRR/MM/DD HH24:MI:SS');
2530 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2531 --
2532 ELSIF x_Group_rec.disposition_code = k_REMAIN_ON_FILE_RECONCILE THEN
2533 --
2534 v_where_clause := v_where_clause || ' AND TO_DATE(industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') < TO_DATE(:sched_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
2535 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2536 --
2537 ELSE
2538 --
2539 v_where_clause := v_where_clause || ' AND TO_DATE(industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
2540 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date), 'RRRR/MM/DD HH24:MI:SS');
2541 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2542 --
2543 END IF;
2544 --
2545 -- END of bug 4223359
2546 --
2547 -- Optional match
2548 v_request_date_str := TO_CHAR(x_Key_rec.req_rec.request_date,'RRRR/MM/DD HH24:MI:SS');
2549
2550 IF x_group_rec.match_across_rec.request_date = 'Y' THEN
2551 --
2552 v_where_clause := v_where_clause ||
2553 ' AND request_date = TO_DATE(:v_req_date,''RRRR/MM/DD HH24:MI:SS'')';
2554 g_InitDemandTab(g_InitDemandTab.COUNT+1) := v_request_date_str;
2555 --
2556 ELSE
2557 --
2558 IF x_group_rec.match_within_rec.request_date = 'Y' THEN
2559 --
2560 v_where_clause := v_where_clause ||
2561 ' AND request_date = DECODE(rla_schedule_type_code, :schedule_type, TO_DATE(:v_req_date,''RRRR/MM/DD HH24:MI:SS'')'||',request_date)';
2562 --
2563 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2564 g_InitDemandTab(g_InitDemandTab.COUNT+1) := v_request_date_str;
2565 END IF;
2566 --
2567 END IF;
2568 --
2569
2570 IF x_group_rec.match_across_rec.cust_production_line = 'Y' THEN
2571 --
2572 v_where_clause := v_where_clause ||
2573 ' AND NVL(customer_production_line,'''||k_VNULL||
2574 ''') = NVL(:customer_production_line, ''' || k_VNULL || ''')';
2575 --
2576 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_line;
2577 --
2578 ELSE
2579 --
2580 IF x_group_rec.match_within_rec.cust_production_line = 'Y' THEN
2581 --
2582 v_where_clause := v_where_clause ||
2583 ' AND NVL(customer_production_line,'''||k_VNULL||
2584 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_production_line,''' || k_VNULL ||
2585 '''), NVL(customer_production_line,'''||k_VNULL||'''))';
2586 --
2587 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2588 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_line;
2589 --
2590 END IF;
2591 --
2592 END IF;
2593 --
2594 IF x_group_rec.match_across_rec.customer_dock_code = 'Y' THEN
2595 --
2596 v_where_clause := v_where_clause ||
2597 ' AND NVL(customer_dock_code,'''||k_VNULL||
2598 ''') = NVL(:customer_dock_code,''' || k_VNULL || ''')';
2599 --
2600 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_dock_code;
2601 --
2602 ELSE
2603 --
2604 IF x_group_rec.match_within_rec.customer_dock_code = 'Y' THEN
2605 --
2606 v_where_clause := v_where_clause ||
2607 ' AND NVL(customer_dock_code,'''||k_VNULL||
2608 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_dock_code,''' || k_VNULL ||
2609 '''), NVL(customer_dock_code,'''||k_VNULL||'''))';
2610 --
2611 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2612 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_dock_code;
2613 --
2614 END IF;
2615 --
2616 END IF;
2617 --
2618 IF x_group_rec.match_across_rec.cust_po_number = 'Y' THEN
2619 --
2620 v_where_clause := v_where_clause ||
2621 ' AND NVL(cust_po_number,'''||k_VNULL||
2622 ''') = NVL(:cust_po_number,''' || k_VNULL || ''')';
2623 --
2624 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_po_number;
2625 --
2626 ELSE
2627 --
2628 IF x_group_rec.match_within_rec.cust_po_number = 'Y' THEN
2629 --
2630 v_where_clause := v_where_clause ||
2631 ' AND NVL(cust_po_number,'''||k_VNULL||
2632 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_po_number,''' || k_VNULL ||
2633 '''), NVL(cust_po_number,'''||k_VNULL||'''))';
2634 --
2635 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2636 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_po_number;
2637 --
2638 END IF;
2639 --
2640 END IF;
2641 --
2642 IF x_group_rec.match_across_rec.customer_item_revision = 'Y' THEN
2643 --
2644 v_where_clause := v_where_clause ||
2645 ' AND NVL(item_revision,'''||k_VNULL||
2646 ''') = NVL(:customer_item_revision,''' || k_VNULL || ''')';
2647 --
2648 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_item_revision;
2649 --
2650 ELSE
2651 --
2652 IF x_group_rec.match_within_rec.customer_item_revision = 'Y' THEN
2653 --
2654 v_where_clause := v_where_clause ||
2655 ' AND NVL(item_revision,'''||k_VNULL||
2656 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_item_revision,''' || k_VNULL ||
2657 '''), NVL(item_revision,'''||k_VNULL||'''))';
2658 --
2659 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2660 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_item_revision;
2661 --
2662 END IF;
2663 --
2664 END IF;
2665 --
2666 IF x_group_rec.match_across_rec.customer_job = 'Y' THEN
2667 --
2668 v_where_clause := v_where_clause ||
2669 ' AND NVL(customer_job,'''||k_VNULL||
2670 ''') = NVL(:customer_job,''' || k_VNULL || ''')';
2671 --
2672 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_job;
2673 --
2674 ELSE
2675 --
2676 IF x_group_rec.match_within_rec.customer_job = 'Y' THEN
2677 --
2678 v_where_clause := v_where_clause ||
2679 ' AND NVL(customer_job,'''||k_VNULL||
2680 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_job, ''' || k_VNULL ||
2681 '''), NVL(customer_job,'''||k_VNULL||'''))';
2682 --
2683 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2684 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_job;
2685 --
2686 END IF;
2687 --
2688 END IF;
2689 --
2690 IF x_group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
2691 --
2692 v_where_clause := v_where_clause ||
2693 ' AND NVL(cust_model_serial_number,'''||k_VNULL||
2694 ''') = NVL(:cust_model_serial_number,''' || k_VNULL || ''')';
2695 --
2696 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_model_serial_number;
2697 --
2698 ELSE
2699 --
2700 IF x_group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
2701 --
2702 v_where_clause := v_where_clause ||
2703 ' AND NVL(cust_model_serial_number,'''||k_VNULL||
2704 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_model_serial_num,''' || k_VNULL ||
2705 '''), NVL(cust_model_serial_number,'''||k_VNULL||'''))';
2706 --
2707 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2708 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_model_serial_number;
2709 --
2710 END IF;
2711 --
2712 END IF;
2713 --
2714 IF x_group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
2715 --
2716 v_where_clause := v_where_clause ||
2717 ' AND NVL(cust_production_seq_num,'''||k_VNULL||
2718 ''') = NVL(:cust_production_seq_num,''' || k_VNULL || ''')';
2719 --
2720 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_seq_num;
2721 --
2722 ELSE
2723 --
2724 IF x_group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
2725 --
2726 v_where_clause := v_where_clause ||
2727 ' AND NVL(cust_production_seq_num,'''||k_VNULL||
2728 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_production_seq_num,''' || k_VNULL ||
2729 '''), NVL(cust_production_seq_num,'''||k_VNULL||'''))';
2730 --
2731 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2732 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_seq_num;
2733 --
2734 END IF;
2735 --
2736 END IF;
2737 --
2738 IF x_group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
2739 --
2740 v_where_clause := v_where_clause ||
2741 ' AND NVL(industry_attribute1,'''||k_VNULL||
2742 ''') = NVL(:industry_attribute1,''' || k_VNULL || ''')';
2743 --
2744 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute1;
2745 --
2746 ELSE
2747 --
2748 IF x_group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
2749 --
2750 v_where_clause := v_where_clause ||
2751 ' AND NVL(industry_attribute1,'''||k_VNULL||
2752 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute1,''' || k_VNULL ||
2753 '''), NVL(industry_attribute1,'''||k_VNULL||'''))';
2754 --
2755 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2756 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute1;
2757 --
2758 END IF;
2759 --
2760 END IF;
2761 --
2762 IF x_group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
2763 --
2764 v_where_clause := v_where_clause ||
2765 ' AND NVL(industry_attribute2,'''||k_VNULL||
2766 ''') = NVL(:industry_attribute2,''' || k_VNULL || ''')';
2767 --
2768 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute2;
2769 --
2770 ELSE
2771 --
2772 IF x_group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
2773 --
2774 v_where_clause := v_where_clause ||
2775 ' AND NVL(industry_attribute2,'''||k_VNULL||
2776 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute2,''' || k_VNULL ||
2777 '''),NVL(industry_attribute2,'''||k_VNULL||'''))';
2778 --
2779 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2780 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute2;
2781 --
2782 END IF;
2783 --
2784 END IF;
2785 --
2786 IF x_group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
2787 --
2788 v_where_clause := v_where_clause ||
2789 ' AND NVL(industry_attribute4,'''||k_VNULL||
2790 ''') = NVL(:industry_attribute4, ''' || k_VNULL || ''')';
2791 --
2792 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute4;
2793 --
2794 ELSE
2795 --
2796 IF x_group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
2797 --
2798 v_where_clause := v_where_clause ||
2799 ' AND NVL(industry_attribute4,'''||k_VNULL||
2800 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute4,''' || k_VNULL ||
2801 '''),NVL(industry_attribute4,'''||k_VNULL||'''))';
2802 --
2803 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2804 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute4;
2805 --
2806 END IF;
2807 --
2808 END IF;
2809 --
2810 IF x_group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
2811 --
2812 v_where_clause := v_where_clause ||
2813 ' AND NVL(industry_attribute5,'''||k_VNULL||
2814 ''') = NVL(:industry_attribute5,''' || k_VNULL || ''')';
2815 --
2816 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute5;
2817 --
2818 ELSE
2819 --
2820 IF x_group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
2821 --
2822 v_where_clause := v_where_clause ||
2823 ' AND NVL(industry_attribute5,'''||k_VNULL||
2824 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute5,''' || k_VNULL ||
2825 '''),NVL(industry_attribute5,'''||k_VNULL||'''))';
2826 --
2827 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2828 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute5;
2829 --
2830 END IF;
2831 --
2832 END IF;
2833 --
2834 IF x_group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
2835 --
2836 v_where_clause := v_where_clause ||
2837 ' AND NVL(industry_attribute6,'''||k_VNULL||
2838 ''') = NVL(:industry_attribute6,''' || k_VNULL || ''')';
2839 --
2840 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute6;
2841 --
2842 ELSE
2843 --
2844 IF x_group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
2845 --
2846 v_where_clause := v_where_clause ||
2847 ' AND NVL(industry_attribute6,'''||k_VNULL||
2848 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute6,''' || k_VNULL ||
2849 '''), NVL(industry_attribute6,'''||k_VNULL||'''))';
2850 --
2851 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2852 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute6;
2853 --
2854 END IF;
2855 --
2856 END IF;
2857 --
2858 IF x_group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
2859 --
2860 v_where_clause := v_where_clause ||
2861 ' AND NVL(industry_attribute10,'''||k_VNULL||
2862 ''') = NVL(:industry_attribute10,''' || k_VNULL || ''')';
2863 --
2864 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute10;
2865 --
2866 ELSE
2867 --
2868 IF x_group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
2869 --
2870 v_where_clause := v_where_clause ||
2871 ' AND NVL(industry_attribute10,'''||k_VNULL||
2872 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute10,''' || k_VNULL ||
2873 '''),NVL(industry_attribute10,'''||k_VNULL||'''))';
2874 --
2875 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2876 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute10;
2877 --
2878 END IF;
2879 --
2880 END IF;
2881 --
2882 IF x_group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
2883 --
2884 v_where_clause := v_where_clause ||
2885 ' AND NVL(industry_attribute11,'''||k_VNULL||
2886 ''') = NVL(:industry_attribute11,''' || k_VNULL || ''')';
2887 --
2888 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute11;
2889 --
2890 ELSE
2891 --
2892 IF x_group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
2893 --
2894 v_where_clause := v_where_clause ||
2895 ' AND NVL(industry_attribute11,'''||k_VNULL||
2896 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute11,''' || k_VNULL ||
2897 '''), NVL(industry_attribute11,'''||k_VNULL||'''))';
2898 --
2899 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2900 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute11;
2901 --
2902 END IF;
2903 --
2904 END IF;
2905 --
2906 IF x_group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
2907 --
2908 v_where_clause := v_where_clause ||
2909 ' AND NVL(industry_attribute12,'''||k_VNULL||
2910 ''') = NVL(:industry_attribute12,''' || k_VNULL || ''')';
2911 --
2912 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute12;
2913 --
2914 ELSE
2915 --
2916 IF x_group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
2917 --
2918 v_where_clause := v_where_clause ||
2919 ' AND NVL(industry_attribute12,'''||k_VNULL||
2920 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute12,''' || k_VNULL ||
2921 '''), NVL(industry_attribute12,'''||k_VNULL||'''))';
2922 --
2923 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2924 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute12;
2925 --
2926 END IF;
2927 --
2928 END IF;
2929 --
2930 IF x_group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
2931 --
2932 v_where_clause := v_where_clause ||
2933 ' AND NVL(industry_attribute13,'''||k_VNULL||
2934 ''') = NVL(:industry_attribute13,''' || k_VNULL || ''')';
2935 --
2936 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute13;
2937 --
2938 ELSE
2939 --
2940 IF x_group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
2941 --
2942 v_where_clause := v_where_clause ||
2943 ' AND NVL(industry_attribute13,'''||k_VNULL||
2944 ''') = DECODE(rla_schedule_type_code, :schedule_type,' ||
2945 ' NVL(:industry_attribute13,''' || k_VNULL || '''), NVL(industry_attribute13,'''||k_VNULL||'''))';
2946 --
2947 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2948 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute13;
2949 --
2950 END IF;
2951 --
2952 END IF;
2953 --
2954 IF x_group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
2955 --
2956 v_where_clause := v_where_clause ||
2957 ' AND NVL(industry_attribute14,'''||k_VNULL||
2958 ''') = NVL(:industry_attribute14,''' || k_VNULL || ''')';
2959 --
2960 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute14;
2961 --
2962 ELSE
2963 --
2964 IF x_group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
2965 --
2966 v_where_clause := v_where_clause ||
2967 ' AND NVL(industry_attribute14,'''||k_VNULL||
2968 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute14,''' || k_VNULL ||
2969 '''), NVL(industry_attribute14,'''||k_VNULL||'''))';
2970 --
2971 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2972 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute14;
2973 --
2974 END IF;
2975 --
2976 END IF;
2977 --
2978 IF g_ATP <> k_ATP THEN
2979 --
2980 v_where_clause := v_where_clause ||
2981 ' AND ship_from_org_id = :ship_from_org_id '||
2982 ' AND NVL(industry_attribute15,'''||k_VNULL||
2983 ''') = NVL(:industry_attribute15,''' || k_VNULL || ''')';
2984 --
2985 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.ship_from_org_id;
2986 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute15;
2987 --
2988 END IF;
2989
2990 --
2991 IF x_group_rec.match_across_rec.attribute1 = 'Y' THEN
2992 --
2993 v_where_clause := v_where_clause ||
2994 ' AND NVL(attribute1,'''||k_VNULL||
2995 ''') = NVL(:attribute1, ''' || k_VNULL || ''')';
2996 --
2997 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute1;
2998 --
2999 ELSE
3000 --
3001 IF x_group_rec.match_within_rec.attribute1 = 'Y' THEN
3002 --
3003 v_where_clause := v_where_clause ||
3004 ' AND NVL(attribute1,'''||k_VNULL||
3005 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute2,''' || k_VNULL || '''), NVL(attribute2,'''||k_VNULL||'''))';
3006 --
3007 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3008 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute2;
3009 --
3010 END IF;
3011 --
3012 END IF;
3013 --
3014 IF x_group_rec.match_across_rec.attribute3 = 'Y' THEN
3015 --
3016 v_where_clause := v_where_clause ||
3017 ' AND NVL(attribute3,'''||k_VNULL||
3018 ''') = NVL(:attribute3,''' || k_VNULL || ''')';
3019 --
3020 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute3;
3021 --
3022 ELSE
3023 --
3024 IF x_group_rec.match_within_rec.attribute3 = 'Y' THEN
3025 --
3026 v_where_clause := v_where_clause ||
3027 ' AND NVL(attribute3,'''||k_VNULL||
3028 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute3,''' || k_VNULL ||
3029 '''), NVL(attribute3,'''||k_VNULL||'''))';
3030 --
3031 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3032 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute3;
3033 --
3034 END IF;
3035 --
3036 END IF;
3037 --
3038 IF x_group_rec.match_across_rec.attribute4 = 'Y' THEN
3039 --
3040 v_where_clause := v_where_clause ||
3041 ' AND NVL(attribute4,'''||k_VNULL||
3042 ''') = NVL(:attribute4,''' || k_VNULL || ''')';
3043 --
3044 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute4;
3045 --
3046 ELSE
3047 --
3048 IF x_group_rec.match_within_rec.attribute4 = 'Y' THEN
3049 --
3050 v_where_clause := v_where_clause ||
3051 ' AND NVL(attribute4,'''||k_VNULL||
3052 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute4,''' || k_VNULL ||
3053 '''), NVL(attribute4,'''||k_VNULL||'''))';
3054 --
3055 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3056 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute4;
3057 --
3058 END IF;
3059 --
3060 END IF;
3061 --
3062 IF x_group_rec.match_across_rec.attribute5 = 'Y' THEN
3063 --
3064 v_where_clause := v_where_clause ||
3065 ' AND NVL(attribute5,'''||k_VNULL||
3066 ''') = NVL(:attribute5,''' || k_VNULL || ''')';
3067 --
3068 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute5;
3069 --
3070 ELSE
3071 --
3072 IF x_group_rec.match_within_rec.attribute5 = 'Y' THEN
3073 --
3074 v_where_clause := v_where_clause ||
3075 ' AND NVL(attribute5,'''||k_VNULL||
3076 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute5,''' || k_VNULL ||
3077 '''), NVL(attribute5,'''||k_VNULL||'''))';
3078 --
3079 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3080 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute5;
3081 --
3082 END IF;
3083 --
3084 END IF;
3085 --
3086 IF x_group_rec.match_across_rec.attribute6 = 'Y' THEN
3087 --
3088 v_where_clause := v_where_clause ||
3089 ' AND NVL(attribute6,'''||k_VNULL||
3090 ''') = NVL(:attribute6,''' || k_VNULL || ''')';
3091 --
3092 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute6;
3093 --
3094 ELSE
3095 --
3096 IF x_group_rec.match_within_rec.attribute6 = 'Y' THEN
3097 --
3098 v_where_clause := v_where_clause ||
3099 ' AND NVL(attribute6,'''||k_VNULL||
3100 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute6,''' || k_VNULL ||
3101 '''), NVL(attribute6,'''||k_VNULL||'''))';
3102 --
3103 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3104 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute6;
3105 --
3106 END IF;
3107 --
3108 END IF;
3109 --
3110 IF x_group_rec.match_across_rec.attribute7 = 'Y' THEN
3111 --
3112 v_where_clause := v_where_clause ||
3113 ' AND NVL(attribute7,'''||k_VNULL||
3114 ''') = NVL(:attribute7,''' || k_VNULL || ''')';
3115 --
3116 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute7;
3117 --
3118 ELSE
3119 --
3120 IF x_group_rec.match_within_rec.attribute7 = 'Y' THEN
3121 --
3122 v_where_clause := v_where_clause ||
3123 ' AND NVL(attribute7,'''||k_VNULL||
3124 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute7,''' || k_VNULL ||
3125 '''), NVL(attribute7,'''||k_VNULL||'''))';
3126 --
3127 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3128 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute7;
3129 --
3130 END IF;
3131 --
3132 END IF;
3133 --
3134 IF x_group_rec.match_across_rec.attribute8 = 'Y' THEN
3135 --
3136 v_where_clause := v_where_clause ||
3137 ' AND NVL(attribute8,'''||k_VNULL||
3138 ''') = NVL(:attribute8,''' || k_VNULL || ''')';
3139 --
3140 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute8;
3141 --
3142 ELSE
3143 --
3144 IF x_group_rec.match_within_rec.attribute8 = 'Y' THEN
3145 --
3146 v_where_clause := v_where_clause ||
3147 ' AND NVL(attribute8,'''||k_VNULL||
3148 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute8,''' || k_VNULL ||
3149 '''), NVL(attribute8,'''||k_VNULL||'''))';
3150 --
3151 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3152 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute8;
3153 --
3154 END IF;
3155 --
3156 END IF;
3157 --
3158 IF x_group_rec.match_across_rec.attribute9 = 'Y' THEN
3159 --
3160 v_where_clause := v_where_clause ||
3161 ' AND NVL(attribute9,'''||k_VNULL||
3162 ''') = NVL(:attribute9,''' || k_VNULL || ''')';
3163 --
3164 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute9;
3165 --
3166 ELSE
3167 --
3168 IF x_group_rec.match_within_rec.attribute9 = 'Y' THEN
3169 --
3170 v_where_clause := v_where_clause ||
3171 ' AND NVL(attribute9,'''||k_VNULL||
3172 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute9,''' || k_VNULL ||
3173 '''), NVL(attribute9,'''||k_VNULL||'''))';
3174 --
3175 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3176 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute9;
3177 --
3178 END IF;
3179 --
3180 END IF;
3181 --
3182 IF x_group_rec.match_across_rec.attribute10 = 'Y' THEN
3183 --
3184 v_where_clause := v_where_clause ||
3185 ' AND NVL(attribute10,'''||k_VNULL||
3186 ''') = NVL(:attribute10,''' || k_VNULL || ''')';
3187 --
3188 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute10;
3189 --
3190 ELSE
3191 --
3192 IF x_group_rec.match_within_rec.attribute10 = 'Y' THEN
3193 --
3194 v_where_clause := v_where_clause ||
3195 ' AND NVL(attribute10,'''||k_VNULL||
3196 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute10,''' || k_VNULL ||
3197 '''), NVL(attribute10,'''||k_VNULL||'''))';
3198 --
3199 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3200 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute10;
3201 --
3202 END IF;
3203 --
3204 END IF;
3205 --
3206 IF x_group_rec.match_across_rec.attribute11 = 'Y' THEN
3207 --
3208 v_where_clause := v_where_clause ||
3209 ' AND NVL(attribute11,'''||k_VNULL||
3210 ''') = NVL(:attribute11,''' || k_VNULL || ''')';
3211 --
3212 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute11;
3213 --
3214 ELSE
3215 --
3216 IF x_group_rec.match_within_rec.attribute11 = 'Y' THEN
3217 --
3218 v_where_clause := v_where_clause ||
3219 ' AND NVL(attribute11,'''||k_VNULL||
3220 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute11, ''' || k_VNULL ||
3221 '''), NVL(attribute11,'''||k_VNULL||'''))';
3222 --
3223 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3224 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute11;
3225 --
3226 END IF;
3227 --
3228 END IF;
3229 --
3230 IF x_group_rec.match_across_rec.attribute12 = 'Y' THEN
3231 --
3232 v_where_clause := v_where_clause ||
3233 ' AND NVL(attribute12,'''||k_VNULL||
3234 ''') = NVL(:attribute12,''' || k_VNULL || ''')';
3235 --
3236 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute12;
3237 --
3238 ELSE
3239 --
3240 IF x_group_rec.match_within_rec.attribute12 = 'Y' THEN
3241 --
3242 v_where_clause := v_where_clause ||
3243 ' AND NVL(attribute12,'''||k_VNULL||
3244 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute12,''' || k_VNULL ||
3245 '''), NVL(attribute12,'''||k_VNULL||'''))';
3246 --
3247 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3248 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute12;
3249 --
3250 END IF;
3251 --
3252 END IF;
3253 --
3254 IF x_group_rec.match_across_rec.attribute13 = 'Y' THEN
3255 --
3256 v_where_clause := v_where_clause ||
3257 ' AND NVL(attribute13,'''||k_VNULL||
3258 ''') = NVL(:attribute13,''' || k_VNULL || ''')';
3259 --
3260 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute13;
3261 --
3262 ELSE
3263 --
3264 IF x_group_rec.match_within_rec.attribute13 = 'Y' THEN
3265 --
3266 v_where_clause := v_where_clause ||
3267 ' AND NVL(attribute13,'''||k_VNULL||
3268 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute13,''' || k_VNULL ||
3269 '''), NVL(attribute13,'''||k_VNULL||'''))';
3270 --
3271 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3272 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute13;
3273 --
3274 END IF;
3275 --
3276 END IF;
3277 --
3278 IF x_group_rec.match_across_rec.attribute14 = 'Y' THEN
3279 --
3280 v_where_clause := v_where_clause ||
3281 ' AND NVL(attribute14,'''||k_VNULL||
3282 ''') = NVL(:attribute14,''' || k_VNULL || ''')';
3283 --
3284 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute14;
3285 --
3286 ELSE
3287 --
3288 IF x_group_rec.match_within_rec.attribute14 = 'Y' THEN
3289 --
3290 v_where_clause := v_where_clause ||
3291 ' AND NVL(attribute14,'''||k_VNULL||
3292 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute14,''' || k_VNULL ||
3293 '''), NVL(attribute14,'''||k_VNULL||'''))';
3294 --
3295 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3296 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute14;
3297 --
3298 END IF;
3299 --
3300 END IF;
3301 --
3302 IF x_group_rec.match_across_rec.attribute15 = 'Y' THEN
3303 --
3304 v_where_clause := v_where_clause ||
3305 ' AND NVL(attribute15,'''||k_VNULL||
3306 ''') = NVL(:attribute15,''' || k_VNULL || ''')';
3307 --
3308 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute15;
3309 --
3310 ELSE
3311 --
3312 IF x_group_rec.match_within_rec.attribute15 = 'Y' THEN
3313 --
3314 v_where_clause := v_where_clause ||
3315 ' AND NVL(attribute15,'''||k_VNULL||
3316 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute15,''' || k_VNULL ||
3317 '''), NVL(attribute15,'''||k_VNULL||'''))';
3318 --
3319 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3320 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute15;
3321 --
3322 END IF;
3323 --
3324 END IF;
3325 --
3326 -- R12 Perf Bug 5013956 : Use bind variable for ATS flag
3327 --
3328 v_where_clause := v_where_clause || ' AND authorized_to_ship_flag = :x_DemandType ORDER BY request_date DESC';
3329 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_DemandType;
3330 --
3331 IF (l_debug <> -1) THEN
3332 rlm_core_sv.dlog(k_DEBUG,'v_select_clause',v_select_clause);
3333 rlm_core_sv.dlog(k_DEBUG,'v_where_clause',v_where_clause);
3334 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for x_Demand_ref cursor', g_InitDemandTab.COUNT);
3335 END IF;
3336 --
3337 v_sql := v_select_clause || v_where_clause;
3338 --
3339 RLM_CORE_SV.OpenDynamicCursor(x_Demand_ref, v_sql, g_InitDemandTab);
3340 --
3341 IF (l_debug <> -1) THEN
3342 rlm_core_sv.dpop(k_SDEBUG);
3343 END IF;
3344 --
3345 EXCEPTION
3346 WHEN e_no_init THEN
3347 rlm_core_sv.dpop(k_SDEBUG,'Demand Type is not ATS or NATS');
3348
3349 WHEN OTHERS THEN
3350 rlm_message_sv.sql_error('rlm_rd_sv.InitializeDemand',x_progress);
3351 --
3352 IF (l_debug <> -1) THEN
3353 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3354 END IF;
3355 --
3356 raise;
3357
3358 END InitializeDemand;
3359
3360 /*===========================================================================
3361
3362 PROCEDURE InitializeSoGroup
3363
3364 ===========================================================================*/
3365 PROCEDURE InitializeSoGroup(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3366 x_Group_ref IN OUT NOCOPY rlm_rd_sv.t_Cursor_ref,
3367 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
3368 IS
3369 x_progress VARCHAR2(3) := '010';
3370
3371 BEGIN
3372 --
3373 IF (l_debug <> -1) THEN
3374 rlm_core_sv.dpush(k_SDEBUG,'InitializeSoGroup');
3375 END IF;
3376 --
3377 OPEN x_Group_ref FOR
3378 SELECT rih.customer_id,
3379 ril.ship_from_org_id,
3380 ril.ship_to_address_id,
3381 ril.ship_to_org_id,
3382 ril.customer_item_id,
3383 ril.inventory_item_id,
3384 ril.industry_attribute15,
3385 ril.intrmd_ship_to_id, --Bugfix 5911991
3386 ril.intmed_ship_to_org_id --Bugfix 5911991
3387 --ril.order_header_id,
3388 --ril.blanket_number
3389 --ril.cust_production_seq_num
3390 FROM rlm_interface_headers rih,
3391 rlm_interface_lines_all ril
3392 WHERE rih.header_id = x_Sched_rec.header_id
3393 AND rih.org_id = ril.org_id
3394 AND ril.header_id = rih.header_id
3395 AND ril.industry_attribute15 = x_Group_rec.ship_from_org_id
3396 AND ril.process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
3397 --AND ril.inventory_item_id = x_Group_rec.inventory_item_id
3398 AND ril.customer_item_id = x_Group_rec.customer_item_id
3399 AND ril.ship_to_address_id = x_Group_rec.ship_to_address_id
3400 -- blankets
3401 --AND ril.blanket_number IS NULL
3402 GROUP BY rih.customer_id,
3403 ril.ship_from_org_id,
3404 ril.ship_to_address_id,
3405 ril.ship_to_org_id,
3406 ril.customer_item_id,
3407 ril.inventory_item_id,
3408 ril.industry_attribute15,
3409 ril.intrmd_ship_to_id, --Bugfix 5911991
3410 ril.intmed_ship_to_org_id --Bugfix 5911991
3411 --ril.order_header_id,
3412 --ril.blanket_number
3413 --ril.cust_production_seq_num
3414 ORDER BY ril.ship_to_org_id,
3415 ril.customer_item_id;
3416 --
3417 IF (l_debug <> -1) THEN
3418 rlm_core_sv.dpop(k_SDEBUG);
3419 END IF;
3420 --
3421 EXCEPTION
3422 WHEN OTHERS THEN
3423 rlm_message_sv.sql_error('rlm_rd_sv.InitializeSoGroup',x_progress);
3424 --
3425 IF (l_debug <> -1) THEN
3426 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3427 END IF;
3428 --
3429 raise e_group_error;
3430
3431 END InitializeSoGroup;
3432
3433
3434 /*===========================================================================
3435
3436 PROCEDURE InitializeReq
3437
3438 ===========================================================================*/
3439 PROCEDURE InitializeReq(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3440 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
3441 x_Req_ref IN OUT NOCOPY t_Cursor_ref,
3442 x_ReqType IN VARCHAR2)
3443 IS
3444 x_progress VARCHAR2(3) := '010';
3445
3446 BEGIN
3447 --
3448 IF (l_debug <> -1) THEN
3449 rlm_core_sv.dpush(k_SDEBUG,'InitializeReq');
3450 rlm_core_sv.dlog(k_DEBUG,'x_ReqType', x_ReqType);
3451 END IF;
3452 --
3453 IF x_ReqType IN (k_NATS, k_ATS) THEN
3454 --
3455 IF (l_debug <> -1) THEN
3456 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id', x_Group_rec.ship_to_org_id);
3457 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
3458 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
3459 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
3460 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date', x_Sched_rec.sched_horizon_start_date);
3461 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date', x_Sched_rec.sched_horizon_end_date);
3462 END IF;
3463 --
3464 IF (x_ReqType = k_ATS) THEN
3465
3466 OPEN x_Req_ref FOR
3467 SELECT x_group_rec.customer_id,
3468 header_id,
3469 line_id,
3470 cust_production_line,
3471 customer_dock_code,
3472 request_date,
3473 schedule_date,
3474 cust_po_number,
3475 customer_item_revision,
3476 customer_job,
3477 cust_model_serial_number,
3478 cust_production_seq_num,
3479 industry_attribute1,
3480 industry_attribute2,
3481 industry_attribute3,
3482 industry_attribute4,
3483 industry_attribute5,
3484 industry_attribute6,
3485 industry_attribute7,
3486 industry_attribute8,
3487 industry_attribute9,
3488 industry_attribute10,
3489 industry_attribute11,
3490 industry_attribute12,
3491 industry_attribute13,
3492 industry_attribute14,
3493 industry_attribute15,
3494 industry_context,
3495 attribute1,
3496 attribute2,
3497 attribute3,
3498 attribute4,
3499 attribute5,
3500 attribute6,
3501 attribute7,
3502 attribute8,
3503 attribute9,
3504 attribute10,
3505 attribute11,
3506 attribute12,
3507 attribute13,
3508 attribute14,
3509 attribute15,
3510 attribute_category,
3511 tp_attribute1,
3512 tp_attribute2,
3513 tp_attribute3,
3514 tp_attribute4,
3515 tp_attribute5,
3516 tp_attribute6,
3517 tp_attribute7,
3518 tp_attribute8,
3519 tp_attribute9,
3520 tp_attribute10,
3521 tp_attribute11,
3522 tp_attribute12,
3523 tp_attribute13,
3524 tp_attribute14,
3525 tp_attribute15,
3526 tp_attribute_category,
3527 item_detail_type,
3528 item_detail_subtype,
3529 intrmd_ship_to_id,
3530 ship_to_org_id,
3531 invoice_to_org_id,
3532 primary_quantity,
3533 intmed_ship_to_org_id,
3534 customer_item_id,
3535 inventory_item_id,
3536 order_header_id,
3537 x_ReqType,
3538 ship_from_org_id,
3539 x_Sched_rec.schedule_type,
3540 'CUST' item_identifier_type,
3541 customer_item_ext,
3542 agreement_id,
3543 price_list_id,
3544 x_Sched_rec.schedule_header_id,
3545 schedule_line_id,
3546 process_status,
3547 uom_code,
3548 cust_po_line_num
3549 FROM rlm_interface_lines
3550 WHERE header_id = x_Sched_rec.header_id
3551 AND ship_from_org_id = x_Group_rec.ship_from_org_id
3552 AND industry_attribute15 = x_Group_rec.industry_attribute15
3553 AND ship_to_org_id = x_Group_rec.ship_to_org_id
3554 AND customer_item_id = x_Group_rec.customer_item_id
3555 AND inventory_item_id = x_Group_rec.inventory_item_id
3556 AND order_header_id = x_Group_rec.order_header_id
3557 AND NVL(intmed_ship_to_org_id ,K_NNULL) = NVL(x_Group_rec.intmed_ship_to_org_id, K_NNULL) --Bugfix 5911991
3558 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
3559 rlm_core_sv.k_PS_FROZEN_FIRM)
3560 AND (item_detail_type = k_FIRM OR item_detail_type = k_PAST_DUE_FIRM)
3561 ORDER BY request_date;
3562
3563 ELSE
3564
3565 OPEN x_Req_ref FOR
3566 SELECT x_group_rec.customer_id,
3567 header_id,
3568 line_id,
3569 cust_production_line,
3570 customer_dock_code,
3571 request_date,
3572 schedule_date,
3573 cust_po_number,
3574 customer_item_revision,
3575 customer_job,
3576 cust_model_serial_number,
3577 cust_production_seq_num,
3578 industry_attribute1,
3579 industry_attribute2,
3580 industry_attribute3,
3581 industry_attribute4,
3582 industry_attribute5,
3583 industry_attribute6,
3584 industry_attribute7,
3585 industry_attribute8,
3586 industry_attribute9,
3587 industry_attribute10,
3588 industry_attribute11,
3589 industry_attribute12,
3590 industry_attribute13,
3591 industry_attribute14,
3592 industry_attribute15,
3593 industry_context,
3594 attribute1,
3595 attribute2,
3596 attribute3,
3597 attribute4,
3598 attribute5,
3599 attribute6,
3600 attribute7,
3601 attribute8,
3602 attribute9,
3603 attribute10,
3604 attribute11,
3605 attribute12,
3606 attribute13,
3607 attribute14,
3608 attribute15,
3609 attribute_category,
3610 tp_attribute1,
3611 tp_attribute2,
3612 tp_attribute3,
3613 tp_attribute4,
3614 tp_attribute5,
3615 tp_attribute6,
3616 tp_attribute7,
3617 tp_attribute8,
3618 tp_attribute9,
3619 tp_attribute10,
3620 tp_attribute11,
3621 tp_attribute12,
3622 tp_attribute13,
3623 tp_attribute14,
3624 tp_attribute15,
3625 tp_attribute_category,
3626 item_detail_type,
3627 item_detail_subtype,
3628 intrmd_ship_to_id,
3629 ship_to_org_id,
3630 invoice_to_org_id,
3631 primary_quantity,
3632 intmed_ship_to_org_id,
3633 customer_item_id,
3634 inventory_item_id,
3635 order_header_id,
3636 x_ReqType,
3637 ship_from_org_id,
3638 x_Sched_rec.schedule_type,
3639 'CUST' item_identifier_type,
3640 customer_item_ext,
3641 agreement_id,
3642 price_list_id,
3643 x_Sched_rec.schedule_header_id,
3644 schedule_line_id,
3645 process_status,
3646 uom_code,
3647 cust_po_line_num
3648 FROM rlm_interface_lines
3649 WHERE header_id = x_Sched_rec.header_id
3650 AND ship_from_org_id = x_Group_rec.ship_from_org_id
3651 AND industry_attribute15 = x_Group_rec.industry_attribute15
3652 AND ship_to_org_id = x_Group_rec.ship_to_org_id
3653 AND customer_item_id = x_Group_rec.customer_item_id
3654 AND inventory_item_id = x_Group_rec.inventory_item_id
3655 AND NVL(intmed_ship_to_org_id ,K_NNULL) = NVL(x_Group_rec.intmed_ship_to_org_id, K_NNULL) --Bugfix 5911991
3656 AND order_header_id = x_Group_rec.order_header_id
3657 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
3658 rlm_core_sv.k_PS_FROZEN_FIRM)
3659 AND item_detail_type = k_FORECAST
3660 ORDER BY request_date;
3661
3662 END IF;
3663
3664 END IF;
3665 --
3666 IF (l_debug <> -1) THEN
3667 rlm_core_sv.dpop(k_SDEBUG);
3668 END IF;
3669 --
3670 EXCEPTION
3671 WHEN OTHERS THEN
3672 rlm_message_sv.sql_error('rlm_rd_sv.InitializeReq',x_progress);
3673 --
3674 IF (l_debug <> -1) THEN
3675 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3676 END IF;
3677 --
3678 raise e_group_error;
3679
3680 END InitializeReq;
3681
3682
3683 -- NOTE: cancel requirement may be obsolete
3684 /*===========================================================================
3685
3686 PROCEDURE CancelRequirement
3687
3688 ===========================================================================*/
3689 PROCEDURE CancelRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3690 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
3691 x_Key_rec IN RLM_RD_SV.t_Key_rec,
3692 x_CancelQty IN NUMBER)
3693 IS
3694 x_progress VARCHAR2(3) := '010';
3695
3696 BEGIN
3697 --
3698 IF (l_debug <> -1) THEN
3699 rlm_core_sv.dpush(k_SDEBUG,'CancelRequirement');
3700 rlm_core_sv.dlog(k_DEBUG,'x_CancelQty',x_CancelQty);
3701 END IF;
3702 --
3703 SetOperation(x_Key_rec, k_UPDATE, x_Key_rec.dem_rec.ordered_quantity - x_CancelQty);
3704 --
3705 IF (l_debug <> -1) THEN
3706 rlm_core_sv.dpop(k_SDEBUG);
3707 END IF;
3708 --
3709 EXCEPTION
3710 WHEN OTHERS THEN
3711 rlm_message_sv.sql_error('rlm_rd_sv.CancelRequirement',x_progress);
3712 --
3713 IF (l_debug <> -1) THEN
3714 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3715 END IF;
3716 --
3717 raise;
3718
3719 END CancelRequirement;
3720
3721
3722 /*===========================================================================
3723
3724 PROCEDURE SynchronizeShipments
3725
3726 ===========================================================================*/
3727 PROCEDURE SynchronizeShipments(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3728 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
3729 IS
3730 --
3731 v_InTransitQty NUMBER;
3732 --
3733 v_shipper_rec WSH_RLM_INTERFACE.t_shipper_rec;
3734 v_match_rec WSH_RLM_INTERFACE.t_optional_match_rec;
3735 --
3736 v_Key_rec t_Key_rec;
3737 --
3738 v_count NUMBER DEFAULT 0 ;
3739 v_shipment_date DATE;
3740 v_intransit_time NUMBER := 0;
3741 v_item_detail_subtype VARCHAR2(80);
3742 --
3743 x_progress VARCHAR2(3) DEFAULT '010';
3744 v_return_status VARCHAR2(240);
3745 --
3746 v_cumDiscrete NUMBER;
3747 e_cumDiscrete EXCEPTION;
3748 --
3749 v_match_ref t_Cursor_ref;
3750 v_Index NUMBER;
3751 v_intransit_calc_basis VARCHAR2(15);
3752 v_match_across_rule RLM_CORE_SV.t_Match_rec;
3753 v_match_within_rule RLM_CORE_SV.t_Match_rec;
3754 v_header_id NUMBER;
3755 v_Intransit NUMBER := 0;
3756 v_LineID NUMBER;
3757 v_min_horizon_date VARCHAR2(30);
3758 --
3759
3760 BEGIN
3761 --
3762 IF (l_debug <> -1) THEN
3763 rlm_core_sv.dpush(k_SDEBUG,'SynchronizeShipments');
3764 END IF;
3765 --
3766 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
3767 --
3768 --
3769 IF (l_debug <> -1) THEN
3770 rlm_core_sv.dlog(k_DEBUG,'ship_from_org_id', x_Group_rec.ship_from_org_id);
3771 rlm_core_sv.dlog(k_DEBUG, 'inventory_item_id', x_Group_rec.inventory_item_id);
3772 rlm_core_sv.dlog(k_DEBUG, 'ship_to_org_id', x_Group_rec.ship_to_org_id);
3773 rlm_core_sv.dlog(k_DEBUG,'customer_item_id', x_Group_rec.customer_item_id);
3774 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis', v_intransit_calc_basis);
3775 rlm_core_sv.dlog(k_DEBUG, 'Order Header Id', x_Group_rec.order_header_id);
3776 rlm_core_sv.dlog(k_DEBUG, 'Blanket Number', x_Group_rec.blanket_number);
3777 rlm_core_sv.dlog(k_DEBUG, 'g_BlktIntransits', g_BlktIntransits);
3778 rlm_core_sv.dlog(k_DEBUG, 'CUM Org Level',
3779 x_Group_rec.setup_terms_rec.cum_org_level_code);
3780 rlm_core_sv.dlog(k_DEBUG, 'x_Group_rec.isSourced', x_Group_rec.isSourced);
3781 END IF;
3782 --
3783 v_match_across_rule := x_Group_rec.match_across_rec;
3784 v_match_within_rule := x_Group_rec.match_within_rec;
3785 --
3786 IF (v_intransit_calc_basis = k_NONE OR v_intransit_calc_basis is NULL) THEN
3787 --
3788 IF (l_debug <> -1) THEN
3789 rlm_core_sv.dlog(k_DEBUG, 'All shipments assumed to have been received');
3790 rlm_core_sv.dpop(k_SDEBUG, 'Processing rule set to NONE or NULL');
3791 END IF;
3792 --
3793 RETURN;
3794 --
3795 END IF;
3796 --
3797 --
3798 SELECT COUNT(*)
3799 INTO v_cumDiscrete
3800 FROM rlm_interface_lines il,
3801 rlm_schedule_lines_all sl
3802 WHERE il.header_id = x_Sched_rec.header_id
3803 AND il.ship_from_org_id = x_Group_rec.ship_from_org_id
3804 AND il.ship_to_org_id = x_Group_rec.ship_to_org_id
3805 AND il.inventory_item_id = x_Group_rec.inventory_item_id
3806 AND il.customer_item_id = x_Group_rec.customer_item_id
3807 AND NVL(il.item_detail_type, ' ') NOT IN
3808 (rlm_manage_demand_sv.k_SHIP_RECEIPT_INFO,
3809 rlm_manage_demand_sv.k_AUTHORIZATION,
3810 rlm_manage_demand_sv.k_OTHER_DETAIL_TYPE)
3811 AND il.schedule_line_id = sl.line_id
3812 AND sl.qty_type_code = rlm_manage_demand_sv.k_CUMULATIVE
3813 AND il.org_id = sl.org_id;
3814 --
3815 IF (l_debug <> -1) THEN
3816 rlm_core_sv.dlog(k_DEBUG,'v_cumDiscrete', v_cumDiscrete);
3817 END IF;
3818 --
3819 IF v_cumDiscrete > 0 THEN
3820 --
3821 /*
3822 If the interface line has a CUMULATIVE qty_code then this means
3823 that its primary qty has been calculated based on the supplier cum.
3824 There is no need to re-calculate the in transit qty.
3825 See manage demand CumtoDiscrete procedure.
3826 */
3827 RAISE e_cumDiscrete;
3828 --
3829 END IF;
3830 --
3831 -- Customer CUM logic is as follows :
3832 --
3833 -- (a) If blankets are used and g_BlktIntransits = TRUE, it means
3834 -- that intransit quantity has already been calc. across all releases
3835 -- tied to the blanket. If not, proceed further.
3836 -- (b) If the group is sourced and the CUM org level is XXX/All SFs
3837 -- (which is what it should be), calculate intransit quantity
3838 -- ONLY ONCE across the sourced orgs and store it in the variable
3839 -- g_IntransitQty. Then for each sourced group, call
3840 -- SourceCUMIntransitQty to store a percent of g_IntransitQty
3841 -- in g_ReconcileTab. This percentage would come from the sourcing
3842 -- rules applied in Manage Demand.
3843 -- (c) If the group is not sourced, then calculate intransit quantity
3844 -- every time and store the intransit quantity in g_ReconcileTab.
3845 --
3846 IF (v_intransit_calc_basis = 'CUSTOMER_CUM') THEN
3847 --{
3848 IF ((x_Group_rec.blanket_number IS NOT NULL AND NOT g_BlktIntransits) OR
3849 (x_Group_rec.blanket_number IS NULL)) THEN
3850 --
3851 PopulateReconcileCumRec(x_Sched_rec, x_Group_rec); --Bugfix 7007638
3852 --{
3853 IF (x_Group_rec.isSourced AND
3854 x_Group_rec.setup_terms_rec.cum_org_level_code IN
3855 ('SHIP_TO_ALL_SHIP_FROMS', 'BILL_TO_ALL_SHIP_FROMS',
3856 'DELIVER_TO_ALL_SHIP_FROMS')) THEN
3857 --{
3858 IF g_RecCUM_tab.COUNT > 0 THEN
3859
3860 FOR v_Count IN 1..g_RecCUM_tab.COUNT LOOP --Bugfix 7007638
3861 --
3862 IF (g_IntransitQty = FND_API.G_MISS_NUM) THEN
3863 CalculateCUMIntransit(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count).line_id, g_IntransitQty);
3864 END IF;
3865 --
3866 IF (l_debug <> -1) THEN
3867 rlm_core_sv.dlog(k_DEBUG, 'Intransit Qty', g_IntransitQty);
3868 END IF;
3869 --
3870 IF g_IntransitQty > 0 THEN
3871 SourceCUMIntransitQty(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count));
3872 END IF;
3873 --
3874 g_IntransitQty := FND_API.G_MISS_NUM; --Bugfix 7007638
3875 --
3876 END LOOP; --Bugfix 7007638
3877
3878 END IF; --if count
3879 --}
3880 ELSE --if cum_org_level_code SHIP_TO_SHIP_FROM
3881 --{
3882 IF g_RecCUM_tab.COUNT > 0 THEN
3883 --
3884 FOR v_Count IN 1..g_RecCUM_tab.COUNT LOOP --Bugfix 7007638
3885 --
3886 CalculateCUMIntransit(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count).line_id, v_Intransit);
3887 --
3888 IF (l_debug <> -1) THEN
3889 rlm_core_sv.dlog(k_DEBUG, 'Intransit Qty', v_Intransit);
3890 END IF;
3891 --
3892 IF v_Intransit > 0 THEN
3893 --
3894 v_Key_rec.rlm_line_id := null;
3895 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
3896 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
3897 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
3898 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
3899 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
3900 v_Key_rec.req_rec.ship_from_org_id := x_Group_rec.ship_from_org_id;
3901 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
3902 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
3903 --
3904 -- Bugfix 7007638 Start
3905 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
3906 v_Key_rec.req_rec.cust_po_number := g_RecCUM_tab(v_Count).purchase_order_number;
3907 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
3908 v_Key_rec.req_rec.industry_attribute1 := g_RecCUM_tab(v_Count).cust_record_year;
3909 END IF;
3910 -- Bugfix 7007638 End
3911
3912 RLM_RD_SV.StoreShipments(x_Sched_rec, x_Group_rec,
3913 v_Key_rec, v_Intransit);
3914 --
3915 END IF;
3916 --
3917 g_IntransitQty := FND_API.G_MISS_NUM; --Bugfix 7007638
3918 --
3919 END LOOP; --Bugfix 7007638
3920
3921 END IF; --if count
3922 --}
3923 END IF; -- cum_org_level_code
3924 --
3925 IF (l_debug <> -1) THEN
3926 rlm_core_sv.dpop(k_SDEBUG);
3927 END IF;
3928 --
3929 IF (x_Group_rec.blanket_number IS NOT NULL AND NOT g_BlktIntransits) THEN
3930 g_BlktIntransits := TRUE;
3931 END IF;
3932 --
3933 RETURN;
3934 --}
3935 END IF; -- blanket_number
3936 --}
3937 ELSIF v_intransit_calc_basis IN (k_RECEIPT, k_SHIPMENT) THEN
3938 --{
3939 InitializeIntransitParam(x_Sched_rec, x_Group_rec,
3940 v_intransit_calc_basis, v_Shipper_rec,
3941 v_Shipment_date);
3942 --
3943 InitializeMatchRec(x_Sched_rec, x_Group_rec, v_match_ref);
3944 --
3945 IF (l_debug <> -1) THEN
3946 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.schedule_type', x_Sched_rec.schedule_type);
3947 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.sched_generation_date', x_Sched_rec.sched_generation_date);
3948 END IF;
3949 --
3950 WHILE FetchMatchRec(v_match_ref, v_match_rec) LOOP
3951 --
3952 PrintMatchRec(v_match_rec);
3953 --
3954 IF NOT AlreadyMatched(x_Group_rec, v_match_rec, v_Index) Then
3955 --
3956 RLM_EXTINTERFACE_SV.getIntransitQty (
3957 x_Group_rec.customer_id,
3958 x_Group_rec.ship_to_org_id,
3959 x_Group_rec.intmed_ship_to_org_id, --Bugfix 5911991
3960 x_Group_rec.ship_from_org_id,
3961 x_Group_rec.inventory_item_id,
3962 x_Group_rec.customer_item_id,
3963 x_Group_rec.order_header_id,
3964 NVL(x_Group_rec.blanket_number, k_NNULL),
3965 x_Sched_rec.org_id,
3966 x_Sched_rec.schedule_type,
3967 v_Shipper_rec,
3968 v_Shipment_date,
3969 v_match_within_rule,
3970 v_match_across_rule,
3971 v_match_rec,
3972 x_Sched_rec.header_id,
3973 v_InTransitQty,
3974 v_return_status);
3975
3976 --
3977 IF (l_debug <> -1) THEN
3978 rlm_core_sv.dlog(k_DEBUG, 'v_return_status', v_return_status);
3979 rlm_core_sv.dlog(k_DEBUG, 'v_InTransitQty', v_InTransitQty);
3980 END IF;
3981 --
3982 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3983 --
3984 IF (l_debug <> -1) THEN
3985 rlm_core_sv.dpop(k_SDEBUG, 'GetIntransitQtyAPI Failed');
3986 END IF;
3987 --
3988 RAISE e_group_error;
3989 --
3990 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3991 --
3992 IF (l_debug <> -1) THEN
3993 rlm_core_sv.dpop(k_SDEBUG, 'GetIntransitQtyAPI Failed');
3994 END IF;
3995 --
3996 RAISE e_group_error;
3997 --
3998 END IF;
3999
4000 --
4001 -- to do JH : The line id os from schedule lines and not interface lines
4002 -- what implications of keeping this line id and also or line id as null?
4003 --
4004
4005 IF v_InTransitQty > 0 THEN
4006 --
4007 v_Key_rec.rlm_line_id := null;
4008 --
4009 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
4010 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
4011 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
4012 --v_Key_rec.req_rec.bill_to_address_id := x_Group_rec.bill_to_address_id;
4013 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
4014 --v_Key_rec.req_rec.intrmd_ship_to_id := x_Group_rec.intrmd_ship_to_id;
4015 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
4016 v_Key_rec.req_rec.ship_from_org_id := x_Group_rec.ship_from_org_id;
4017 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
4018 v_Key_rec.req_rec.cust_production_line := v_match_rec.cust_production_line;
4019 v_Key_rec.req_rec.customer_dock_code := v_match_rec.customer_dock_code;
4020 v_Key_rec.req_rec.cust_po_number := v_match_rec.cust_po_number;
4021 v_Key_rec.req_rec.customer_item_revision := v_match_rec.customer_item_revision;
4022 v_Key_rec.req_rec.customer_job := v_match_rec.customer_job;
4023 v_Key_rec.req_rec.cust_model_serial_number := v_match_rec.cust_model_serial_number;
4024 v_Key_rec.req_rec.cust_production_seq_num := v_match_rec.cust_production_seq_num;
4025 v_Key_rec.req_rec.industry_attribute1 := v_match_rec.industry_attribute1;
4026 v_Key_rec.req_rec.industry_attribute2 := v_match_rec.industry_attribute2;
4027 v_Key_rec.req_rec.industry_attribute3 := v_match_rec.industry_attribute3;
4028 v_Key_rec.req_rec.industry_attribute4 := v_match_rec.industry_attribute4;
4029 v_Key_rec.req_rec.industry_attribute5 := v_match_rec.industry_attribute5;
4030 v_Key_rec.req_rec.industry_attribute6 := v_match_rec.industry_attribute6;
4031 v_Key_rec.req_rec.industry_attribute7 := v_match_rec.industry_attribute7;
4032 v_Key_rec.req_rec.industry_attribute8 := v_match_rec.industry_attribute8;
4033 v_Key_rec.req_rec.industry_attribute9 := v_match_rec.industry_attribute9;
4034 v_Key_rec.req_rec.industry_attribute10 := v_match_rec.industry_attribute10;
4035 v_Key_rec.req_rec.industry_attribute11 := v_match_rec.industry_attribute11;
4036 v_Key_rec.req_rec.industry_attribute12 := v_match_rec.industry_attribute12;
4037 v_Key_rec.req_rec.industry_attribute13 := v_match_rec.industry_attribute13;
4038 v_Key_rec.req_rec.industry_attribute14 := v_match_rec.industry_attribute14;
4039 v_Key_rec.req_rec.industry_attribute15 := v_match_rec.industry_attribute15;
4040 v_Key_rec.req_rec.attribute1 := v_match_rec.attribute1;
4041 v_Key_rec.req_rec.attribute2 := v_match_rec.attribute2;
4042 v_Key_rec.req_rec.attribute3 := v_match_rec.attribute3;
4043 v_Key_rec.req_rec.attribute4 := v_match_rec.attribute4;
4044 v_Key_rec.req_rec.attribute5 := v_match_rec.attribute5;
4045 v_Key_rec.req_rec.attribute6 := v_match_rec.attribute6;
4046 v_Key_rec.req_rec.attribute7 := v_match_rec.attribute7;
4047 v_Key_rec.req_rec.attribute8 := v_match_rec.attribute8;
4048 v_Key_rec.req_rec.attribute9 := v_match_rec.attribute9;
4049 v_Key_rec.req_rec.attribute10 := v_match_rec.attribute10;
4050 v_Key_rec.req_rec.attribute11 := v_match_rec.attribute11;
4051 v_Key_rec.req_rec.attribute12 := v_match_rec.attribute12;
4052 v_Key_rec.req_rec.attribute13 := v_match_rec.attribute13;
4053 v_Key_rec.req_rec.attribute14 := v_match_rec.attribute14;
4054 v_Key_rec.req_rec.attribute15 := v_match_rec.attribute15;
4055 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
4056 v_Key_rec.req_rec.blanket_number := x_Group_rec.blanket_number;
4057 --
4058 StoreShipments(x_Sched_rec, x_Group_rec, v_Key_rec, v_IntransitQty);
4059 --
4060 END IF; /* if intransit_qty > 0 */
4061 --
4062 InsertIntransitMatchRec(v_match_rec, v_IntransitQty);
4063 --
4064 END IF; /* if not alreadymatched */
4065 --
4066 END LOOP; /* while fetchmatchrec */
4067 --}
4068 END IF; /*Intransit Basis*/
4069 --
4070 IF (l_debug <> -1) THEN
4071 rlm_core_sv.dpop(k_SDEBUG);
4072 END IF;
4073 --
4074 EXCEPTION
4075 --
4076 WHEN e_cumDiscrete THEN
4077 --
4078 IF (l_debug <> -1) THEN
4079 rlm_core_sv.dlog(k_DEBUG,'Intransit Calculations not needed as more than one CUM lines exist');
4080 rlm_core_sv.dpop(k_SDEBUG,'e_cumDiscrete');
4081 END IF;
4082 --
4083 WHEN OTHERS THEN
4084 rlm_message_sv.sql_error('rlm_rd_sv.SynchronizeShipments',x_progress);
4085 --
4086 IF (l_debug <> -1) THEN
4087 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4088 END IF;
4089 --
4090 raise;
4091
4092 END SynchronizeShipments;
4093
4094
4095 /*===========================================================================
4096
4097 FUNCTION MatchWithin
4098
4099 ===========================================================================*/
4100 FUNCTION MatchWithin(x_WithinString IN VARCHAR2,
4101 x_ColumnName IN VARCHAR2)
4102 RETURN VARCHAR2
4103 IS
4104
4105 x_progress VARCHAR2(3) := '010';
4106
4107 BEGIN
4108 --
4109 IF (l_debug <> -1) THEN
4110 rlm_core_sv.dpush(k_SDEBUG,'MatchWithin');
4111 rlm_core_sv.dpop(k_SDEBUG);
4112 END IF;
4113 --
4114 RETURN('Y');
4115
4116 EXCEPTION
4117 WHEN OTHERS THEN
4118 rlm_message_sv.sql_error('rlm_rd_sv.MatchWithin',x_progress);
4119 --
4120 IF (l_debug <> -1) THEN
4121 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4122 END IF;
4123 --
4124 raise;
4125
4126 END MatchWithin;
4127
4128
4129 /*===========================================================================
4130
4131 FUNCTION MatchAcross
4132
4133 ===========================================================================*/
4134 FUNCTION MatchAcross(x_AcrossString IN VARCHAR2,
4135 x_ColumnName IN VARCHAR2)
4136 RETURN VARCHAR2
4137 IS
4138 x_progress VARCHAR2(3) := '010';
4139
4140 BEGIN
4141 --
4142 IF (l_debug <> -1) THEN
4143 rlm_core_sv.dpush(k_SDEBUG,'MatchAcross');
4144 rlm_core_sv.dpop(k_SDEBUG);
4145 END IF;
4146 --
4147 RETURN('Y');
4148
4149 EXCEPTION
4150 WHEN OTHERS THEN
4151 rlm_message_sv.sql_error('rlm_rd_sv.MatchAcross',x_progress);
4152 --
4153 IF (l_debug <> -1) THEN
4154 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4155 END IF;
4156 --
4157 raise;
4158
4159 END MatchAcross;
4160
4161
4162 /*===========================================================================
4163
4164 PROCEDURE StoreShipments
4165
4166 ===========================================================================*/
4167 PROCEDURE StoreShipments(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
4168 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4169 x_Key_rec IN RLM_RD_SV.t_Key_rec,
4170 x_Quantity IN NUMBER)
4171 IS
4172
4173 v_Index NUMBER;
4174 x_progress VARCHAR2(3) := '010';
4175
4176 BEGIN
4177 --
4178 IF (l_debug <> -1) THEN
4179 rlm_core_sv.dpush(k_SDEBUG,'StoreShipments');
4180 END IF;
4181 --
4182 -- start of bug fix 4223359
4183 --
4184 IF x_Quantity > 0 THEN
4185 --
4186 IF RLM_TPA_SV.MatchShipments(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4187 --
4188 IF (l_debug <> -1) THEN
4189 rlm_core_sv.dlog(k_DEBUG,'v_index',v_Index);
4190 END IF;
4191 --
4192 g_Reconcile_tab(v_Index).ordered_quantity :=
4193 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + NVL(x_Quantity,0);
4194 --
4195 ELSE
4196 --
4197 IF g_Reconcile_tab.First is NULL THEN
4198 --
4199 g_Reconcile_tab(1) := x_Key_rec.req_rec;
4200 g_Reconcile_tab(1).ordered_quantity := NVL(x_Quantity, 0);
4201 --
4202 ELSE
4203 --
4204 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.req_rec;
4205 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := NVL(x_Quantity,0);
4206 --
4207 END IF;
4208 --
4209 IF (l_debug <> -1) THEN
4210 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4211 rlm_core_sv.dlog(k_DEBUG,'Added to reconcile table x_index',g_Reconcile_tab.LAST);
4212 END IF;
4213 --
4214 END IF;
4215 --
4216 ELSE
4217 --
4218 IF MatchReconcile(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4219 --
4220 g_Reconcile_tab(v_Index).ordered_quantity :=
4221 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + NVL(x_Quantity,0);
4222 --
4223 IF (l_debug <> -1) THEN
4224 rlm_core_sv.dlog(k_DEBUG,'v_index',v_Index);
4225 rlm_core_sv.dlog(k_DEBUG,'g_reconcile_tab.ordered_quantity',g_Reconcile_tab(v_Index).ordered_quantity);
4226 END IF;
4227 --
4228 ELSE
4229 --
4230 IF g_Reconcile_tab.First is NULL THEN
4231 --
4232 g_Reconcile_tab(1) := x_Key_rec.req_rec;
4233 g_Reconcile_tab(1).ordered_quantity := NVL(x_Quantity, 0);
4234 --
4235 ELSE
4236 --
4237 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.req_rec;
4238 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := NVL(x_Quantity,0);
4239 --
4240 END IF;
4241 --
4242 IF (l_debug <> -1) THEN
4243 rlm_core_sv.dlog(k_DEBUG,'New Line x_quantity',x_quantity);
4244 rlm_core_sv.dlog(k_DEBUG,'Added to reconcile table x_index',g_Reconcile_tab.LAST);
4245 END IF;
4246 --
4247 END IF;
4248 --
4249 END IF;
4250 --
4251 -- end of bug fix 4223359
4252 --
4253 IF (l_debug <> -1) THEN
4254 rlm_core_sv.dpop(k_SDEBUG);
4255 END IF;
4256 --
4257 EXCEPTION
4258 WHEN OTHERS THEN
4259 rlm_message_sv.sql_error('rlm_rd_sv.StoreShipments',x_progress);
4260 --
4261 IF (l_debug <> -1) THEN
4262 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4263 END IF;
4264 --
4265 raise;
4266
4267 END StoreShipments;
4268
4269
4270 /*===========================================================================
4271
4272 PROCEDURE ReconcileShipments
4273
4274 ===========================================================================*/
4275 PROCEDURE ReconcileShipments(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4276 x_Key_rec IN RLM_RD_SV.t_Key_rec,
4277 x_Quantity IN OUT NOCOPY NUMBER)
4278 IS
4279
4280 v_Index NUMBER;
4281 x_progress VARCHAR2(3) := '010';
4282
4283 BEGIN
4284 --
4285 IF (l_debug <> -1) THEN
4286 rlm_core_sv.dpush(k_SDEBUG,'ReconcileShipments');
4287 END IF;
4288 --
4289 IF RLM_TPA_SV.MatchShipments(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4290 --
4291 IF (l_debug <> -1) THEN
4292 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4293 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab(v_Index).ordered_quantity',
4294 g_Reconcile_tab(v_Index).ordered_quantity);
4295 END IF;
4296 --
4297 -- start of bug fix 4223359
4298 --
4299 IF nvl(g_Reconcile_tab(v_Index).ordered_quantity,0) > NVL(x_Quantity,0)
4300 THEN
4301 --
4302 g_Reconcile_tab(v_Index).ordered_quantity :=
4303 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0)
4304 - NVL(x_Quantity,0);
4305 IF (l_debug <> -1) THEN
4306 rlm_core_sv.dlog(k_DEBUG,'new g_Reconcile_tab(v_Index).ordered_quantity',
4307 g_Reconcile_tab(v_Index).ordered_quantity);
4308 END IF;
4309 --
4310 x_Quantity := 0;
4311 --
4312 ELSE
4313 --
4314 x_Quantity := NVL(x_Quantity,0)
4315 - nvl(g_Reconcile_tab(v_Index).ordered_quantity,0);
4316 --
4317 IF (l_debug <> -1) THEN
4318 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4319 rlm_core_sv.dlog(k_DEBUG,'Entry getting deleted from Reconcile Table', v_Index);
4320 rlm_core_sv.dlog(k_DEBUG,'deleted g_Reconcile_tab(v_Index).ordered_quantity',
4321 g_Reconcile_tab(v_Index).ordered_quantity);
4322
4323 END IF;
4324 --
4325 g_Reconcile_tab.DELETE(v_Index);
4326 --
4327 END IF;
4328 --
4329 END IF;
4330 --
4331 -- end of bug fix 4223359
4332 --
4333 IF (l_debug <> -1) THEN
4334 rlm_core_sv.dpop(k_SDEBUG);
4335 END IF;
4336 --
4337 EXCEPTION
4338 WHEN OTHERS THEN
4339 rlm_message_sv.sql_error('rlm_rd_sv.ReconcileShipments',x_progress);
4340 --
4341 IF (l_debug <> -1) THEN
4342 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4343 END IF;
4344 --
4345 raise;
4346
4347 END ReconcileShipments;
4348
4349 /*===========================================================================
4350
4351 FUNCTION MatchShipments
4352
4353 ===========================================================================*/
4354 FUNCTION MatchShipments(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4355 x_Current_rec IN RLM_RD_SV.t_Generic_rec,
4356 x_Index OUT NOCOPY NUMBER)
4357 RETURN BOOLEAN
4358 IS
4359 x_progress VARCHAR2(3) := '010';
4360
4361 v_Index NUMBER;
4362 v_Count NUMBER;
4363 b_Match BOOLEAN := FALSE;
4364 v_intransit_calc_basis VARCHAR2(15);
4365
4366 BEGIN
4367 --
4368 IF (l_debug <> -1) THEN
4369 rlm_core_sv.dpush(k_SDEBUG,'MatchShipments');
4370 END IF;
4371 --
4372 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
4373 --
4374 IF (l_debug <> -1) THEN
4375 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
4376 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
4377 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
4378 END IF;
4379 --
4380 -- Bug 2261743
4381 --
4382 IF g_Reconcile_tab.COUNT <> 0 THEN
4383 --
4384 -- 4223359 Changed the for loop to while as the entries in the PL/SQL table could be non-contiguous
4385 --
4386 v_Count := g_Reconcile_tab.FIRST;
4387 --
4388 WHILE v_Count is NOT NULL LOOP
4389 --
4390 IF nvl(g_Reconcile_tab(v_Count).shipment_flag,k_VNULL) = 'SHIPMENT' THEN
4391 --
4392 IF( v_intransit_calc_basis = 'CUSTOMER_CUM') THEN
4393 --
4394 IF Match_PO_RY_Reconcile(x_Group_rec, x_Current_rec, v_Index) THEN --Bugfix 7007638
4395 b_Match := TRUE;
4396 x_Index := v_Index; --Bugfix 7007638
4397 EXIT;
4398 END IF;
4399 --
4400 ELSE
4401 --
4402 IF MatchReconcile(x_Group_rec, x_Current_rec, v_Index) THEN
4403 b_Match := TRUE;
4404 x_Index := v_Index;
4405 EXIT;
4406 END IF;
4407 --
4408 END IF;
4409 --
4410 END IF;
4411 --
4412 v_Count := g_Reconcile_tab.next(v_Count);
4413 --
4414 END LOOP;
4415 --
4416 END IF;
4417 --
4418 IF (l_debug <> -1) THEN
4419 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
4420 rlm_core_sv.dlog(k_DEBUG, 'Returning index', x_Index);
4421 rlm_core_sv.dpop(k_SDEBUG);
4422 END IF;
4423 --
4424 RETURN(b_Match);
4425
4426 EXCEPTION
4427 WHEN OTHERS THEN
4428 rlm_message_sv.sql_error('rlm_rd_sv.MatchShipments',x_progress);
4429 --
4430 IF (l_debug <> -1) THEN
4431 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4432 END IF;
4433 --
4434 raise;
4435
4436 END MatchShipments;
4437
4438 /*===========================================================================
4439
4440 FUNCTION Matchfrozen
4441
4442 Description: Added this function for bug 4223359
4443 this is required to find duplicate records in the g_reconcile_tab to
4444 print the aggregate frozenQty message
4445
4446 ===========================================================================*/
4447 FUNCTION MatchFrozen(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4448 x_Index2 IN NUMBER,
4449 x_Current_rec IN t_Generic_rec,
4450 x_Index OUT NOCOPY NUMBER)
4451 RETURN BOOLEAN
4452 IS
4453 x_progress VARCHAR2(3) := '010';
4454 v_Index NUMBER;
4455 v_Count NUMBER;
4456 b_Match BOOLEAN := FALSE;
4457
4458 BEGIN
4459 --
4460 IF (l_debug <> -1) THEN
4461 rlm_core_sv.dpush(k_SDEBUG,'MatchFrozen');
4462 END IF;
4463 --
4464 IF (l_debug <> -1) THEN
4465 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
4466 rlm_core_sv.dlog(k_DEBUG,'x_index2', x_Index2);
4467 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
4468 rlm_core_sv.dlog(k_DEBUG,'x_current_rec.schedule_type', x_Current_rec.schedule_type);
4469 END IF;
4470 --
4471 IF g_Reconcile_tab.COUNT <> 0 THEN
4472 --
4473 v_Count := x_Index2;
4474 --
4475 WHILE v_Count IS NOT NULL LOOP
4476 --{
4477 b_Match := TRUE;
4478 --
4479 IF (l_debug <> -1) THEN
4480 rlm_core_sv.dlog(k_DEBUG,'schedule_type', g_Reconcile_tab(v_Count).schedule_type);
4481 END IF;
4482 --
4483 IF x_Current_rec.schedule_type = g_Reconcile_tab(v_Count).schedule_type THEN
4484 --{
4485 IF (l_debug <> -1) THEN
4486 rlm_core_sv.dlog(k_DEBUG,'Match Within Schedules only ');
4487 END IF;
4488 --
4489 IF x_Group_rec.match_within_rec.cust_po_number = 'Y' THEN
4490 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
4491 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
4492 b_Match := FALSE;
4493 END IF;
4494 END IF;
4495 --
4496 IF (l_debug <> -1) THEN
4497 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
4498 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
4499 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4500 END IF;
4501 --
4502 IF b_Match THEN
4503 IF x_Group_rec.match_within_rec.customer_item_revision = 'Y' THEN
4504 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
4505 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
4506 b_Match := FALSE;
4507 END IF;
4508 END IF;
4509 END IF;
4510 --
4511 IF (l_debug <> -1) THEN
4512 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
4513 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
4514 g_Reconcile_tab(v_Count).customer_item_revision);
4515 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4516 END IF;
4517 --
4518 IF b_Match THEN
4519 IF x_Group_rec.match_within_rec.customer_dock_code = 'Y' THEN
4520 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
4521 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
4522 b_Match := FALSE;
4523 END IF;
4524 END IF;
4525 END IF;
4526 --
4527 IF (l_debug <> -1) THEN
4528 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
4529 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
4530 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4531 END IF;
4532 --
4533 IF b_Match THEN
4534 IF x_Group_rec.match_within_rec.customer_job = 'Y' THEN
4535 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
4536 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
4537 b_Match := FALSE;
4538 END IF;
4539 END IF;
4540 END IF;
4541 --
4542 IF (l_debug <> -1) THEN
4543 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
4544 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
4545 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4546 END IF;
4547 --
4548 IF b_Match THEN
4549 IF x_Group_rec.match_within_rec.cust_production_line = 'Y' THEN
4550 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
4551 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
4552 b_Match := FALSE;
4553 END IF;
4554 END IF;
4555 END IF;
4556 --
4557 IF (l_debug <> -1) THEN
4558 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
4559 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
4560 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4561 END IF;
4562 --
4563 IF b_Match THEN
4564 IF x_Group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
4565 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
4566 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
4567 b_Match := FALSE;
4568 END IF;
4569 END IF;
4570 END IF;
4571 --
4572 IF (l_debug <> -1) THEN
4573 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
4574 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
4575 g_Reconcile_tab(v_Count).cust_model_serial_number);
4576 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4577 END IF;
4578 --
4579 IF b_Match THEN
4580 IF x_Group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
4581 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
4582 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
4583 b_Match := FALSE;
4584 END IF;
4585 END IF;
4586 END IF;
4587 --
4588 IF (l_debug <> -1) THEN
4589 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
4590 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
4591 g_Reconcile_tab(v_Count).cust_production_seq_num);
4592 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4593 END IF;
4594 --
4595 IF b_Match THEN
4596 IF x_Group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
4597 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
4598 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
4599 b_Match := FALSE;
4600 END IF;
4601 END IF;
4602 END IF;
4603 --
4604 IF (l_debug <> -1) THEN
4605 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
4606 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
4607 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4608 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
4609 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
4610 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4611 END IF;
4612 --
4613 IF b_Match THEN
4614 IF x_Group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
4615 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
4616 NVL(g_Reconcile_tab(v_Count).industry_attribute4, k_VNULL) THEN
4617 b_Match := FALSE;
4618 END IF;
4619 END IF;
4620 END IF;
4621 --
4622 IF (l_debug <> -1) THEN
4623 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute4', x_Current_rec.industry_attribute4);
4624 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
4625 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4626 END IF;
4627 --
4628 IF b_Match THEN
4629 IF x_Group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
4630 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
4631 NVL(g_Reconcile_tab(v_Count).industry_attribute5, k_VNULL) THEN
4632 b_Match := FALSE;
4633 END IF;
4634 END IF;
4635 END IF;
4636 --
4637 IF (l_debug <> -1) THEN
4638 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute5', x_Current_rec.industry_attribute5);
4639 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
4640 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4641 END IF;
4642 --
4643 IF b_Match THEN
4644 IF x_Group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
4645 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
4646 NVL(g_Reconcile_tab(v_Count).industry_attribute6, k_VNULL) THEN
4647 b_Match := FALSE;
4648 END IF;
4649 END IF;
4650 END IF;
4651 --
4652 IF (l_debug <> -1) THEN
4653 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute6', x_Current_rec.industry_attribute6);
4654 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
4655 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4656 END IF;
4657 --
4658 IF b_Match THEN
4659 IF x_Group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
4660 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
4661 NVL(g_Reconcile_tab(v_Count).industry_attribute10, k_VNULL) THEN
4662 b_Match := FALSE;
4663 END IF;
4664 END IF;
4665 END IF;
4666 --
4667 IF (l_debug <> -1) THEN
4668 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute10', x_Current_rec.industry_attribute10);
4669 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
4670 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4671 END IF;
4672 --
4673 IF b_Match THEN
4674 IF x_Group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
4675 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
4676 NVL(g_Reconcile_tab(v_Count).industry_attribute11, k_VNULL) THEN
4677 b_Match := FALSE;
4678 END IF;
4679 END IF;
4680 END IF;
4681 --
4682 IF (l_debug <> -1) THEN
4683 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute11', x_Current_rec.industry_attribute11);
4684 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
4685 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4686 END IF;
4687 --
4688 IF b_Match THEN
4689 IF x_Group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
4690 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
4691 NVL(g_Reconcile_tab(v_Count).industry_attribute12, k_VNULL) THEN
4692 b_Match := FALSE;
4693 END IF;
4694 END IF;
4695 END IF;
4696 --
4697 IF (l_debug <> -1) THEN
4698 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute12', x_Current_rec.industry_attribute12);
4699 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
4700 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4701 END IF;
4702 --
4703 IF b_Match THEN
4704 IF x_Group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
4705 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
4706 NVL(g_Reconcile_tab(v_Count).industry_attribute13, k_VNULL) THEN
4707 b_Match := FALSE;
4708 END IF;
4709 END IF;
4710 END IF;
4711 --
4712 IF (l_debug <> -1) THEN
4713 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute13', x_Current_rec.industry_attribute13);
4714 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
4715 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4716 END IF;
4717 --
4718 IF b_Match THEN
4719 IF x_Group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
4720 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
4721 NVL(g_Reconcile_tab(v_Count).industry_attribute14, k_VNULL) THEN
4722 b_Match := FALSE;
4723 END IF;
4724 END IF;
4725 END IF;
4726 --
4727 IF (l_debug <> -1) THEN
4728 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute14', x_Current_rec.industry_attribute14);
4729 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
4730 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4731 END IF;
4732 --
4733 IF b_Match THEN
4734 IF x_Group_rec.match_within_rec.industry_attribute15 = 'Y' THEN
4735 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
4736 NVL(g_Reconcile_tab(v_Count).industry_attribute15, k_VNULL) THEN
4737 b_Match := FALSE;
4738 END IF;
4739 END IF;
4740 END IF;
4741 --
4742 IF (l_debug <> -1) THEN
4743 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute15', x_Current_rec.industry_attribute15);
4744 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
4745 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4746 END IF;
4747 --
4748 IF b_Match THEN
4749 IF x_Group_rec.match_within_rec.attribute1 = 'Y' THEN
4750 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
4751 NVL(g_Reconcile_tab(v_Count).attribute1, k_VNULL) THEN
4752 b_Match := FALSE;
4753 END IF;
4754 END IF;
4755 END IF;
4756 --
4757 IF (l_debug <> -1) THEN
4758 rlm_core_sv.dlog(k_DEBUG, 'attribute1', x_Current_rec.attribute1);
4759 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
4760 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4761 END IF;
4762 --
4763 IF b_Match THEN
4764 IF x_Group_rec.match_within_rec.attribute2 = 'Y' THEN
4765 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
4766 NVL(g_Reconcile_tab(v_Count).attribute2, k_VNULL) THEN
4767 b_Match := FALSE;
4768 END IF;
4769 END IF;
4770 END IF;
4771 --
4772 IF (l_debug <> -1) THEN
4773 rlm_core_sv.dlog(k_DEBUG, 'uattribute2', x_Current_rec.attribute2);
4774 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
4775 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4776 END IF;
4777 --
4778 IF b_Match THEN
4779 IF x_Group_rec.match_within_rec.attribute3 = 'Y' THEN
4780 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
4781 NVL(g_Reconcile_tab(v_Count).attribute3, k_VNULL) THEN
4782 b_Match := FALSE;
4783 END IF;
4784 END IF;
4785 END IF;
4786 --
4787 IF (l_debug <> -1) THEN
4788 rlm_core_sv.dlog(k_DEBUG, 'attribute3', x_Current_rec.attribute3);
4789 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
4790 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4791 END IF;
4792 --
4793 IF b_Match THEN
4794 IF x_Group_rec.match_within_rec.attribute4 = 'Y' THEN
4795 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
4796 NVL(g_Reconcile_tab(v_Count).attribute4, k_VNULL) THEN
4797 b_Match := FALSE;
4798 END IF;
4799 END IF;
4800 END IF;
4801 --
4802 IF (l_debug <> -1) THEN
4803 rlm_core_sv.dlog(k_DEBUG, 'attribute4', x_Current_rec.attribute4);
4804 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
4805 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4806 END IF;
4807 --
4808 IF b_Match THEN
4809 IF x_Group_rec.match_within_rec.attribute5 = 'Y' THEN
4810 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
4811 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
4812 b_Match := FALSE;
4813 END IF;
4814 END IF;
4815 END IF;
4816 --
4817 IF (l_debug <> -1) THEN
4818 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
4819 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
4820 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4821 END IF;
4822 --
4823 IF b_Match THEN
4824 IF x_Group_rec.match_within_rec.attribute6 = 'Y' THEN
4825 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
4826 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
4827 b_Match := FALSE;
4828 END IF;
4829 END IF;
4830 END IF;
4831 --
4832 IF (l_debug <> -1) THEN
4833 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
4834 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
4835 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4836 END IF;
4837 --
4838 IF b_Match THEN
4839 IF x_Group_rec.match_within_rec.attribute7 = 'Y' THEN
4840 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
4841 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
4842 b_Match := FALSE;
4843 END IF;
4844 END IF;
4845 END IF;
4846 --
4847 IF (l_debug <> -1) THEN
4848 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
4849 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
4850 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4851 END IF;
4852 --
4853 IF b_Match THEN
4854 IF x_Group_rec.match_within_rec.attribute8 = 'Y' THEN
4855 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
4856 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
4857 b_Match := FALSE;
4858 END IF;
4859 END IF;
4860 END IF;
4861 --
4862 IF (l_debug <> -1) THEN
4863 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
4864 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
4865 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4866 END IF;
4867 --
4868 IF b_Match THEN
4869 IF x_Group_rec.match_within_rec.attribute9 = 'Y' THEN
4870 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
4871 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
4872 b_Match := FALSE;
4873 END IF;
4874 END IF;
4875 END IF;
4876 --
4877 IF (l_debug <> -1) THEN
4878 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
4879 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
4880 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4881 END IF;
4882 --
4883 IF b_Match THEN
4884 IF x_Group_rec.match_within_rec.attribute10 = 'Y' THEN
4885 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
4886 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
4887 b_Match := FALSE;
4888 END IF;
4889 END IF;
4890 END IF;
4891 --
4892 IF (l_debug <> -1) THEN
4893 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
4894 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
4895 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4896 END IF;
4897 --
4898 IF b_Match THEN
4899 IF x_Group_rec.match_within_rec.attribute11 = 'Y' THEN
4900 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
4901 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
4902 b_Match := FALSE;
4903 END IF;
4904 END IF;
4905 END IF;
4906 --
4907 IF (l_debug <> -1) THEN
4908 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
4909 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
4910 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4911 END IF;
4912 --
4913 IF b_Match THEN
4914 IF x_Group_rec.match_within_rec.attribute12 = 'Y' THEN
4915 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
4916 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
4917 b_Match := FALSE;
4918 END IF;
4919 END IF;
4920 END IF;
4921 --
4922 IF (l_debug <> -1) THEN
4923 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
4924 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
4925 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4926 END IF;
4927 --
4928 IF b_Match THEN
4929 IF x_Group_rec.match_within_rec.attribute13 = 'Y' THEN
4930 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
4931 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
4932 b_Match := FALSE;
4933 END IF;
4934 END IF;
4935 END IF;
4936 --
4937 IF (l_debug <> -1) THEN
4938 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
4939 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
4940 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4941 END IF;
4942 --
4943 IF b_Match THEN
4944 IF x_Group_rec.match_within_rec.attribute14 = 'Y' THEN
4945 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
4946 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
4947 b_Match := FALSE;
4948 END IF;
4949 END IF;
4950 END IF;
4951 --
4952 IF (l_debug <> -1) THEN
4953 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
4954 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
4955 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4956 END IF;
4957 --
4958 IF b_Match THEN
4959 IF x_Group_rec.match_within_rec.attribute15 = 'Y' THEN
4960 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
4961 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
4962 b_Match := FALSE;
4963 END IF;
4964 END IF;
4965 END IF;
4966 --
4967 IF (l_debug <> -1) THEN
4968 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
4969 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
4970 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4971 END IF;
4972 --
4973 --
4974 --}
4975 ELSIF x_Current_rec.schedule_type <> g_Reconcile_tab(v_Count).schedule_type THEN
4976 --
4977 --
4978 --{
4979 IF (l_debug <> -1) THEN
4980 rlm_core_sv.dlog(k_DEBUG,'Match across Schedules only ');
4981 END IF;
4982 --
4983 IF x_Group_rec.match_across_rec.cust_po_number = 'Y' THEN
4984 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
4985 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
4986 b_Match := FALSE;
4987 END IF;
4988 END IF;
4989 --
4990 IF (l_debug <> -1) THEN
4991 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
4992 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
4993 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4994 END IF;
4995 --
4996 IF b_Match THEN
4997 IF x_Group_rec.match_across_rec.customer_item_revision = 'Y' THEN
4998 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
4999 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
5000 b_Match := FALSE;
5001 END IF;
5002 END IF;
5003 END IF;
5004 --
5005 IF (l_debug <> -1) THEN
5006 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
5007 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
5008 g_Reconcile_tab(v_Count).customer_item_revision);
5009 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5010 END IF;
5011 --
5012 IF b_Match THEN
5013 IF x_Group_rec.match_across_rec.customer_dock_code = 'Y' THEN
5014 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
5015 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
5016 b_Match := FALSE;
5017 END IF;
5018 END IF;
5019 END IF;
5020 --
5021 IF (l_debug <> -1) THEN
5022 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
5023 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
5024 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5025 END IF;
5026 --
5027 IF b_Match THEN
5028 IF x_Group_rec.match_across_rec.customer_job = 'Y' THEN
5029 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
5030 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
5031 b_Match := FALSE;
5032 END IF;
5033 END IF;
5034 END IF;
5035 --
5036 IF (l_debug <> -1) THEN
5037 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
5038 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
5039 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5040 END IF;
5041 --
5042 IF b_Match THEN
5043 IF x_Group_rec.match_across_rec.cust_production_line = 'Y' THEN
5044 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
5045 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
5046 b_Match := FALSE;
5047 END IF;
5048 END IF;
5049 END IF;
5050 --
5051 IF (l_debug <> -1) THEN
5052 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
5053 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
5054 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5055 END IF;
5056 --
5057 IF b_Match THEN
5058 IF x_Group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
5059 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
5060 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
5061 b_Match := FALSE;
5062 END IF;
5063 END IF;
5064 END IF;
5065 --
5066 IF (l_debug <> -1) THEN
5067 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
5068 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
5069 g_Reconcile_tab(v_Count).cust_model_serial_number);
5070 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5071 END IF;
5072 --
5073 IF b_Match THEN
5074 IF x_Group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
5075 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
5076 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
5077 b_Match := FALSE;
5078 END IF;
5079 END IF;
5080 END IF;
5081 --
5082 IF (l_debug <> -1) THEN
5083 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
5084 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
5085 g_Reconcile_tab(v_Count).cust_production_seq_num);
5086 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5087 END IF;
5088 --
5089 IF b_Match THEN
5090 IF x_Group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
5091 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
5092 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
5093 b_Match := FALSE;
5094 END IF;
5095 END IF;
5096 END IF;
5097 --
5098 IF (l_debug <> -1) THEN
5099 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
5100 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
5101 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5102 END IF;
5103 --
5104 IF b_Match THEN
5105 IF x_Group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
5106 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
5107 NVL(g_Reconcile_tab(v_Count).industry_attribute2, k_VNULL) THEN
5108 b_Match := FALSE;
5109 END IF;
5110 END IF;
5111 END IF;
5112 --
5113 IF (l_debug <> -1) THEN
5114 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
5115 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
5116 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5117 END IF;
5118 --
5119 IF b_Match THEN
5120 IF x_Group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
5121 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
5122 NVL(g_Reconcile_tab(v_Count).industry_attribute4, k_VNULL) THEN
5123 b_Match := FALSE;
5124 END IF;
5125 END IF;
5126 END IF;
5127 --
5128 IF (l_debug <> -1) THEN
5129 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute4', x_Current_rec.industry_attribute4);
5130 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
5131 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5132 END IF;
5133 --
5134 IF b_Match THEN
5135 IF x_Group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
5136 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
5137 NVL(g_Reconcile_tab(v_Count).industry_attribute5, k_VNULL) THEN
5138 b_Match := FALSE;
5139 END IF;
5140 END IF;
5141 END IF;
5142 --
5143 IF (l_debug <> -1) THEN
5144 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute5', x_Current_rec.industry_attribute5);
5145 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
5146 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5147 END IF;
5148 --
5149 IF b_Match THEN
5150 IF x_Group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
5151 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
5152 NVL(g_Reconcile_tab(v_Count).industry_attribute6, k_VNULL) THEN
5153 b_Match := FALSE;
5154 END IF;
5155 END IF;
5156 END IF;
5157 --
5158 IF (l_debug <> -1) THEN
5159 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute6', x_Current_rec.industry_attribute6);
5160 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
5161 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5162 END IF;
5163 --
5164 IF b_Match THEN
5165 IF x_Group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
5166 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
5167 NVL(g_Reconcile_tab(v_Count).industry_attribute10, k_VNULL) THEN
5168 b_Match := FALSE;
5169 END IF;
5170 END IF;
5171 END IF;
5172 --
5173 IF (l_debug <> -1) THEN
5174 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute10', x_Current_rec.industry_attribute10);
5175 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
5176 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5177 END IF;
5178 --
5179 IF b_Match THEN
5180 IF x_Group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
5181 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
5182 NVL(g_Reconcile_tab(v_Count).industry_attribute11, k_VNULL) THEN
5183 b_Match := FALSE;
5184 END IF;
5185 END IF;
5186 END IF;
5187 --
5188 IF (l_debug <> -1) THEN
5189 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute11', x_Current_rec.industry_attribute11);
5190 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
5191 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5192 END IF;
5193 --
5194 IF b_Match THEN
5195 IF x_Group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
5196 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
5197 NVL(g_Reconcile_tab(v_Count).industry_attribute12, k_VNULL) THEN
5198 b_Match := FALSE;
5199 END IF;
5200 END IF;
5201 END IF;
5202 --
5203 IF (l_debug <> -1) THEN
5204 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute12', x_Current_rec.industry_attribute12);
5205 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
5206 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5207 END IF;
5208 --
5209 IF b_Match THEN
5210 IF x_Group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
5211 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
5212 NVL(g_Reconcile_tab(v_Count).industry_attribute13, k_VNULL) THEN
5213 b_Match := FALSE;
5214 END IF;
5215 END IF;
5216 END IF;
5217 --
5218 IF (l_debug <> -1) THEN
5219 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute13', x_Current_rec.industry_attribute13);
5220 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
5221 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5222 END IF;
5223 --
5224 IF b_Match THEN
5225 IF x_Group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
5226 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
5227 NVL(g_Reconcile_tab(v_Count).industry_attribute14, k_VNULL) THEN
5228 b_Match := FALSE;
5229 END IF;
5230 END IF;
5231 END IF;
5232 --
5233 IF (l_debug <> -1) THEN
5234 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute14', x_Current_rec.industry_attribute14);
5235 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
5236 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5237 END IF;
5238 --
5239 IF b_Match THEN
5240 IF x_Group_rec.match_across_rec.industry_attribute15 = 'Y' THEN
5241 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
5242 NVL(g_Reconcile_tab(v_Count).industry_attribute15, k_VNULL) THEN
5243 b_Match := FALSE;
5244 END IF;
5245 END IF;
5246 END IF;
5247 --
5248 IF (l_debug <> -1) THEN
5249 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute15', x_Current_rec.industry_attribute15);
5250 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
5251 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5252 END IF;
5253 --
5254 IF b_Match THEN
5255 IF x_Group_rec.match_across_rec.attribute1 = 'Y' THEN
5256 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
5257 NVL(g_Reconcile_tab(v_Count).attribute1, k_VNULL) THEN
5258 b_Match := FALSE;
5259 END IF;
5260 END IF;
5261 END IF;
5262 --
5263 IF (l_debug <> -1) THEN
5264 rlm_core_sv.dlog(k_DEBUG, 'attribute1', x_Current_rec.attribute1);
5265 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
5266 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5267 END IF;
5268 --
5269 IF b_Match THEN
5270 IF x_Group_rec.match_across_rec.attribute2 = 'Y' THEN
5271 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
5272 NVL(g_Reconcile_tab(v_Count).attribute2, k_VNULL) THEN
5273 b_Match := FALSE;
5274 END IF;
5275 END IF;
5276 END IF;
5277 --
5278 IF (l_debug <> -1) THEN
5279 rlm_core_sv.dlog(k_DEBUG, 'uattribute2', x_Current_rec.attribute2);
5280 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
5281 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5282 END IF;
5283 --
5284 IF b_Match THEN
5285 IF x_Group_rec.match_across_rec.attribute3 = 'Y' THEN
5286 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
5287 NVL(g_Reconcile_tab(v_Count).attribute3, k_VNULL) THEN
5288 b_Match := FALSE;
5289 END IF;
5290 END IF;
5291 END IF;
5292 --
5293 IF (l_debug <> -1) THEN
5294 rlm_core_sv.dlog(k_DEBUG, 'attribute3', x_Current_rec.attribute3);
5295 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
5296 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5297 END IF;
5298 --
5299 IF b_Match THEN
5300 IF x_Group_rec.match_across_rec.attribute4 = 'Y' THEN
5301 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
5302 NVL(g_Reconcile_tab(v_Count).attribute4, k_VNULL) THEN
5303 b_Match := FALSE;
5304 END IF;
5305 END IF;
5306 END IF;
5307 --
5308 IF (l_debug <> -1) THEN
5309 rlm_core_sv.dlog(k_DEBUG, 'attribute4', x_Current_rec.attribute4);
5310 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
5311 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5312 END IF;
5313 --
5314 IF b_Match THEN
5315 IF x_Group_rec.match_across_rec.attribute5 = 'Y' THEN
5316 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
5317 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
5318 b_Match := FALSE;
5319 END IF;
5320 END IF;
5321 END IF;
5322 --
5323 IF (l_debug <> -1) THEN
5324 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
5325 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
5326 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5327 END IF;
5328 --
5329 IF b_Match THEN
5330 IF x_Group_rec.match_across_rec.attribute6 = 'Y' THEN
5331 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
5332 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
5333 b_Match := FALSE;
5334 END IF;
5335 END IF;
5336 END IF;
5337 --
5338 IF (l_debug <> -1) THEN
5339 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
5340 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
5341 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5342 END IF;
5343 --
5344 IF b_Match THEN
5345 IF x_Group_rec.match_across_rec.attribute7 = 'Y' THEN
5346 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
5347 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
5348 b_Match := FALSE;
5349 END IF;
5350 END IF;
5351 END IF;
5352 --
5353 IF (l_debug <> -1) THEN
5354 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
5355 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
5356 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5357 END IF;
5358 --
5359 IF b_Match THEN
5360 IF x_Group_rec.match_across_rec.attribute8 = 'Y' THEN
5361 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
5362 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
5363 b_Match := FALSE;
5364 END IF;
5365 END IF;
5366 END IF;
5367 --
5368 IF (l_debug <> -1) THEN
5369 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
5370 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
5371 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5372 END IF;
5373 --
5374 IF b_Match THEN
5375 IF x_Group_rec.match_across_rec.attribute9 = 'Y' THEN
5376 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
5377 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
5378 b_Match := FALSE;
5379 END IF;
5380 END IF;
5381 END IF;
5382 --
5383 IF (l_debug <> -1) THEN
5384 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
5385 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
5386 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5387 END IF;
5388 --
5389 IF b_Match THEN
5390 IF x_Group_rec.match_across_rec.attribute10 = 'Y' THEN
5391 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
5392 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
5393 b_Match := FALSE;
5394 END IF;
5395 END IF;
5396 END IF;
5397 --
5398 IF (l_debug <> -1) THEN
5399 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
5400 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
5401 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5402 END IF;
5403 --
5404 IF b_Match THEN
5405 IF x_Group_rec.match_across_rec.attribute11 = 'Y' THEN
5406 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
5407 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
5408 b_Match := FALSE;
5409 END IF;
5410 END IF;
5411 END IF;
5412 --
5413 IF (l_debug <> -1) THEN
5414 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
5415 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
5416 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5417 END IF;
5418 --
5419 IF b_Match THEN
5420 IF x_Group_rec.match_across_rec.attribute12 = 'Y' THEN
5421 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
5422 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
5423 b_Match := FALSE;
5424 END IF;
5425 END IF;
5426 END IF;
5427 --
5428 IF (l_debug <> -1) THEN
5429 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
5430 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
5431 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5432 END IF;
5433 --
5434 IF b_Match THEN
5435 IF x_Group_rec.match_across_rec.attribute13 = 'Y' THEN
5436 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
5437 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
5438 b_Match := FALSE;
5439 END IF;
5440 END IF;
5441 END IF;
5442 --
5443 IF (l_debug <> -1) THEN
5444 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
5445 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
5446 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5447 END IF;
5448 --
5449 IF b_Match THEN
5450 IF x_Group_rec.match_across_rec.attribute14 = 'Y' THEN
5451 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
5452 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
5453 b_Match := FALSE;
5454 END IF;
5455 END IF;
5456 END IF;
5457 --
5458 IF (l_debug <> -1) THEN
5459 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
5460 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
5461 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5462 END IF;
5463 --
5464 IF b_Match THEN
5465 IF x_Group_rec.match_across_rec.attribute15 = 'Y' THEN
5466 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
5467 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
5468 b_Match := FALSE;
5469 END IF;
5470 END IF;
5471 END IF;
5472 --
5473 IF (l_debug <> -1) THEN
5474 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
5475 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
5476 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5477 END IF;
5478 --}
5479 ELSE
5480 --{
5481 b_Match := FALSE;
5482 IF (l_debug <> -1) THEN
5483 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5484 END IF;
5485 --}
5486 END IF;
5487 --
5488 IF b_Match THEN
5489 x_Index := v_Count;
5490 EXIT;
5491 END IF;
5492 --
5493 v_Count := g_Reconcile_Tab.next(v_Count);
5494 --
5495 --}
5496 END LOOP;
5497 --
5498 END IF;
5499 --
5500 IF (l_debug <> -1) THEN
5501 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
5502 rlm_core_sv.dlog(k_DEBUG,'x_index', x_index);
5503 rlm_core_sv.dpop(k_SDEBUG);
5504 END IF;
5505 --
5506 RETURN(b_Match);
5507 --
5508 EXCEPTION
5509 WHEN OTHERS THEN
5510 rlm_message_sv.sql_error('rlm_rd_sv.MatchFrozen',x_progress);
5511 --
5512 IF (l_debug <> -1) THEN
5513 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
5514 END IF;
5515 --
5516 raise;
5517
5518 END MatchFrozen;
5519
5520
5521 /*===========================================================================
5522
5523 FUNCTION MatchReconcile
5524
5525 ===========================================================================*/
5526 FUNCTION MatchReconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
5527 x_Current_rec IN t_Generic_rec,
5528 x_Index OUT NOCOPY NUMBER)
5529 RETURN BOOLEAN
5530 IS
5531 x_progress VARCHAR2(3) := '010';
5532 v_Count NUMBER;
5533 v_Index NUMBER;
5534 b_Match BOOLEAN := FALSE;
5535 v_intransit_calc_basis VARCHAR2(30) ;
5536
5537 BEGIN
5538 --
5539 IF (l_debug <> -1) THEN
5540 rlm_core_sv.dpush(k_SDEBUG,'MatchReconcile');
5541 rlm_core_sv.dlog(k_DEBUG, 'x_Current_rec.schedule_type',
5542 x_Current_rec.schedule_type);
5543 END IF;
5544 --
5545 -- Bug 2261743
5546 IF (l_debug <> -1) THEN
5547 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
5548 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
5549 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
5550 END IF;
5551
5552 IF g_Reconcile_tab.COUNT <> 0 THEN
5553 --
5554 -- bug 4223359 changed the for loop to while as the PL/SQL table to null entries in between
5555 --
5556 v_Count := g_Reconcile_tab.FIRST;
5557 --
5558 WHILE v_Count IS NOT NULL LOOP
5559 --{
5560 b_Match := TRUE;
5561 --
5562 IF (l_debug <> -1) THEN
5563 rlm_core_sv.dlog(k_DEBUG, 'g_Reconcile_Tab('||v_Count||').schedule_type',
5564 g_Reconcile_Tab(v_Count).schedule_type);
5565 END IF;
5566 -- Bug 5608510
5567 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
5568 --
5569 IF (l_debug <> -1) THEN
5570 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis ',x_Group_rec.setup_terms_rec.intransit_calc_basis);
5571 END IF;
5572 --
5573 IF x_Current_rec.schedule_type = g_Reconcile_tab(v_Count).schedule_type THEN
5574 --
5575 IF (l_debug <> -1) THEN
5576 rlm_core_sv.dlog(k_DEBUG,'Match Within Schedules only ');
5577 END IF;
5578 --
5579 IF x_Group_rec.match_within_rec.cust_po_number = 'Y' THEN
5580 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
5581 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
5582 b_Match := FALSE;
5583 END IF;
5584 END IF;
5585 --
5586 IF (l_debug <> -1) THEN
5587 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
5588 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
5589 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5590 END IF;
5591 --
5592 IF b_Match THEN
5593 IF x_Group_rec.match_within_rec.customer_item_revision = 'Y' THEN
5594 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
5595 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
5596 b_Match := FALSE;
5597 END IF;
5598 END IF;
5599 END IF;
5600 --
5601 IF (l_debug <> -1) THEN
5602 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
5603 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
5604 g_Reconcile_tab(v_Count).customer_item_revision);
5605 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5606 END IF;
5607 --
5608 IF b_Match THEN
5609 IF x_Group_rec.match_within_rec.customer_dock_code = 'Y' THEN
5610 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
5611 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
5612 b_Match := FALSE;
5613 END IF;
5614 END IF;
5615 END IF;
5616 --
5617 IF (l_debug <> -1) THEN
5618 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
5619 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
5620 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5621 END IF;
5622 --
5623 IF b_Match THEN
5624 IF x_Group_rec.match_within_rec.customer_job = 'Y' THEN
5625 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
5626 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
5627 b_Match := FALSE;
5628 END IF;
5629 END IF;
5630 END IF;
5631 --
5632 IF (l_debug <> -1) THEN
5633 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
5634 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
5635 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5636 END IF;
5637 --
5638 IF b_Match THEN
5639 IF x_Group_rec.match_within_rec.cust_production_line = 'Y' THEN
5640 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
5641 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
5642 b_Match := FALSE;
5643 END IF;
5644 END IF;
5645 END IF;
5646 --
5647 IF (l_debug <> -1) THEN
5648 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
5649 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
5650 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5651 END IF;
5652 --
5653 IF b_Match THEN
5654 IF x_Group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
5655 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
5656 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
5657 b_Match := FALSE;
5658 END IF;
5659 END IF;
5660 END IF;
5661 --
5662 IF (l_debug <> -1) THEN
5663 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
5664 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
5665 g_Reconcile_tab(v_Count).cust_model_serial_number);
5666 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5667 END IF;
5668 --
5669 IF b_Match THEN
5670 IF x_Group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
5671 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
5672 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
5673 b_Match := FALSE;
5674 END IF;
5675 END IF;
5676 END IF;
5677 --
5678 IF (l_debug <> -1) THEN
5679 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
5680 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
5681 g_Reconcile_tab(v_Count).cust_production_seq_num);
5682 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5683 END IF;
5684 --
5685 IF b_Match THEN
5686 IF x_Group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
5687 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
5688 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
5689 b_Match := FALSE;
5690 END IF;
5691 END IF;
5692 END IF;
5693 --
5694 IF (l_debug <> -1) THEN
5695 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
5696 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
5697 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5698 END IF;
5699 --
5700 --Bug 5608510
5701 --
5702 IF v_intransit_calc_basis = 'PART_SHIP_LINES' THEN
5703 IF b_Match THEN
5704 IF x_Group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
5705 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
5706 NVL(g_Reconcile_tab(v_Count).industry_attribute2, k_VNULL) THEN
5707 b_Match := FALSE;
5708 END IF;
5709 END IF;
5710 END IF;
5711 --
5712 IF (l_debug <> -1) THEN
5713 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
5714 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
5715 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5716 END IF;
5717 --
5718 IF b_Match THEN
5719 IF x_Group_rec.match_within_rec.request_date = 'Y' THEN
5720 IF NVL(x_Current_rec.request_date, k_DNULL) <>
5721 NVL(g_Reconcile_tab(v_Count).request_date, k_DNULL) THEN
5722 b_Match := FALSE;
5723 END IF;
5724 END IF;
5725 END IF;
5726 --
5727 --
5728 IF (l_debug <> -1) THEN
5729 rlm_core_sv.dlog(k_DEBUG, 'request_date', x_Current_rec.request_date);
5730 rlm_core_sv.dlog(k_DEBUG, 'rec request_date', g_Reconcile_tab(v_Count).request_date);
5731 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5732 END IF;
5733 --
5734 END IF; --bugfix 5608510 ends
5735 --
5736 IF b_Match THEN
5737 IF x_Group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
5738 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
5739 NVL(g_Reconcile_tab(v_Count).industry_attribute4, k_VNULL) THEN
5740 b_Match := FALSE;
5741 END IF;
5742 END IF;
5743 END IF;
5744 --
5745 IF (l_debug <> -1) THEN
5746 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute4', x_Current_rec.industry_attribute4);
5747 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
5748 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5749 END IF;
5750 --
5751 IF b_Match THEN
5752 IF x_Group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
5753 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
5754 NVL(g_Reconcile_tab(v_Count).industry_attribute5, k_VNULL) THEN
5755 b_Match := FALSE;
5756 END IF;
5757 END IF;
5758 END IF;
5759 --
5760 IF (l_debug <> -1) THEN
5761 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute5', x_Current_rec.industry_attribute5);
5762 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
5763 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5764 END IF;
5765 --
5766 IF b_Match THEN
5767 IF x_Group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
5768 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
5769 NVL(g_Reconcile_tab(v_Count).industry_attribute6, k_VNULL) THEN
5770 b_Match := FALSE;
5771 END IF;
5772 END IF;
5773 END IF;
5774 --
5775 IF (l_debug <> -1) THEN
5776 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute6', x_Current_rec.industry_attribute6);
5777 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
5778 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5779 END IF;
5780 --
5781 IF b_Match THEN
5782 IF x_Group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
5783 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
5784 NVL(g_Reconcile_tab(v_Count).industry_attribute10, k_VNULL) THEN
5785 b_Match := FALSE;
5786 END IF;
5787 END IF;
5788 END IF;
5789 --
5790 IF (l_debug <> -1) THEN
5791 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute10', x_Current_rec.industry_attribute10);
5792 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
5793 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5794 END IF;
5795 --
5796 IF b_Match THEN
5797 IF x_Group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
5798 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
5799 NVL(g_Reconcile_tab(v_Count).industry_attribute11, k_VNULL) THEN
5800 b_Match := FALSE;
5801 END IF;
5802 END IF;
5803 END IF;
5804 --
5805 IF (l_debug <> -1) THEN
5806 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute11', x_Current_rec.industry_attribute11);
5807 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
5808 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5809 END IF;
5810 --
5811 IF b_Match THEN
5812 IF x_Group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
5813 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
5814 NVL(g_Reconcile_tab(v_Count).industry_attribute12, k_VNULL) THEN
5815 b_Match := FALSE;
5816 END IF;
5817 END IF;
5818 END IF;
5819 --
5820 IF (l_debug <> -1) THEN
5821 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute12', x_Current_rec.industry_attribute12);
5822 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
5823 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5824 END IF;
5825 --
5826 IF b_Match THEN
5827 IF x_Group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
5828 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
5829 NVL(g_Reconcile_tab(v_Count).industry_attribute13, k_VNULL) THEN
5830 b_Match := FALSE;
5831 END IF;
5832 END IF;
5833 END IF;
5834 --
5835 IF (l_debug <> -1) THEN
5836 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute13', x_Current_rec.industry_attribute13);
5837 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
5838 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5839 END IF;
5840 --
5841 IF b_Match THEN
5842 IF x_Group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
5843 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
5844 NVL(g_Reconcile_tab(v_Count).industry_attribute14, k_VNULL) THEN
5845 b_Match := FALSE;
5846 END IF;
5847 END IF;
5848 END IF;
5849 --
5850 IF (l_debug <> -1) THEN
5851 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute14', x_Current_rec.industry_attribute14);
5852 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
5853 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5854 END IF;
5855 --
5856 IF b_Match THEN
5857 IF x_Group_rec.match_within_rec.industry_attribute15 = 'Y' THEN
5858 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
5859 NVL(g_Reconcile_tab(v_Count).industry_attribute15, k_VNULL) THEN
5860 b_Match := FALSE;
5861 END IF;
5862 END IF;
5863 END IF;
5864 --
5865 IF (l_debug <> -1) THEN
5866 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute15', x_Current_rec.industry_attribute15);
5867 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
5868 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5869 END IF;
5870 --
5871 IF b_Match THEN
5872 IF x_Group_rec.match_within_rec.attribute1 = 'Y' THEN
5873 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
5874 NVL(g_Reconcile_tab(v_Count).attribute1, k_VNULL) THEN
5875 b_Match := FALSE;
5876 END IF;
5877 END IF;
5878 END IF;
5879 --
5880 IF (l_debug <> -1) THEN
5881 rlm_core_sv.dlog(k_DEBUG, 'attribute1', x_Current_rec.attribute1);
5882 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
5883 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5884 END IF;
5885 --
5886 IF b_Match THEN
5887 IF x_Group_rec.match_within_rec.attribute2 = 'Y' THEN
5888 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
5889 NVL(g_Reconcile_tab(v_Count).attribute2, k_VNULL) THEN
5890 b_Match := FALSE;
5891 END IF;
5892 END IF;
5893 END IF;
5894 --
5895 IF (l_debug <> -1) THEN
5896 rlm_core_sv.dlog(k_DEBUG, 'uattribute2', x_Current_rec.attribute2);
5897 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
5898 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5899 END IF;
5900 --
5901 IF b_Match THEN
5902 IF x_Group_rec.match_within_rec.attribute3 = 'Y' THEN
5903 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
5904 NVL(g_Reconcile_tab(v_Count).attribute3, k_VNULL) THEN
5905 b_Match := FALSE;
5906 END IF;
5907 END IF;
5908 END IF;
5909 --
5910 IF (l_debug <> -1) THEN
5911 rlm_core_sv.dlog(k_DEBUG, 'attribute3', x_Current_rec.attribute3);
5912 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
5913 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5914 END IF;
5915 --
5916 IF b_Match THEN
5917 IF x_Group_rec.match_within_rec.attribute4 = 'Y' THEN
5918 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
5919 NVL(g_Reconcile_tab(v_Count).attribute4, k_VNULL) THEN
5920 b_Match := FALSE;
5921 END IF;
5922 END IF;
5923 END IF;
5924 --
5925 IF (l_debug <> -1) THEN
5926 rlm_core_sv.dlog(k_DEBUG, 'attribute4', x_Current_rec.attribute4);
5927 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
5928 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5929 END IF;
5930 --
5931 IF b_Match THEN
5932 IF x_Group_rec.match_within_rec.attribute5 = 'Y' THEN
5933 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
5934 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
5935 b_Match := FALSE;
5936 END IF;
5937 END IF;
5938 END IF;
5939 --
5940 IF (l_debug <> -1) THEN
5941 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
5942 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
5943 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5944 END IF;
5945 --
5946 IF b_Match THEN
5947 IF x_Group_rec.match_within_rec.attribute6 = 'Y' THEN
5948 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
5949 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
5950 b_Match := FALSE;
5951 END IF;
5952 END IF;
5953 END IF;
5954 --
5955 IF (l_debug <> -1) THEN
5956 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
5957 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
5958 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5959 END IF;
5960 --
5961 IF b_Match THEN
5962 IF x_Group_rec.match_within_rec.attribute7 = 'Y' THEN
5963 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
5964 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
5965 b_Match := FALSE;
5966 END IF;
5967 END IF;
5968 END IF;
5969 --
5970 IF (l_debug <> -1) THEN
5971 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
5972 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
5973 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5974 END IF;
5975 --
5976 IF b_Match THEN
5977 IF x_Group_rec.match_within_rec.attribute8 = 'Y' THEN
5978 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
5979 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
5980 b_Match := FALSE;
5981 END IF;
5982 END IF;
5983 END IF;
5984 --
5985 IF (l_debug <> -1) THEN
5986 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
5987 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
5988 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5989 END IF;
5990 --
5991 IF b_Match THEN
5992 IF x_Group_rec.match_within_rec.attribute9 = 'Y' THEN
5993 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
5994 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
5995 b_Match := FALSE;
5996 END IF;
5997 END IF;
5998 END IF;
5999 --
6000 IF (l_debug <> -1) THEN
6001 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
6002 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
6003 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6004 END IF;
6005 --
6006 IF b_Match THEN
6007 IF x_Group_rec.match_within_rec.attribute10 = 'Y' THEN
6008 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
6009 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
6010 b_Match := FALSE;
6011 END IF;
6012 END IF;
6013 END IF;
6014 --
6015 IF (l_debug <> -1) THEN
6016 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
6017 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
6018 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6019 END IF;
6020 --
6021 IF b_Match THEN
6022 IF x_Group_rec.match_within_rec.attribute11 = 'Y' THEN
6023 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
6024 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
6025 b_Match := FALSE;
6026 END IF;
6027 END IF;
6028 END IF;
6029 --
6030 IF (l_debug <> -1) THEN
6031 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
6032 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
6033 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6034 END IF;
6035 --
6036 IF b_Match THEN
6037 IF x_Group_rec.match_within_rec.attribute12 = 'Y' THEN
6038 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
6039 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
6040 b_Match := FALSE;
6041 END IF;
6042 END IF;
6043 END IF;
6044 --
6045 IF (l_debug <> -1) THEN
6046 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
6047 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
6048 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6049 END IF;
6050 --
6051 IF b_Match THEN
6052 IF x_Group_rec.match_within_rec.attribute13 = 'Y' THEN
6053 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
6054 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
6055 b_Match := FALSE;
6056 END IF;
6057 END IF;
6058 END IF;
6059 --
6060 IF (l_debug <> -1) THEN
6061 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
6062 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
6063 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6064 END IF;
6065 --
6066 IF b_Match THEN
6067 IF x_Group_rec.match_within_rec.attribute14 = 'Y' THEN
6068 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
6069 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
6070 b_Match := FALSE;
6071 END IF;
6072 END IF;
6073 END IF;
6074 --
6075 IF (l_debug <> -1) THEN
6076 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
6077 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
6078 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6079 END IF;
6080 --
6081 IF b_Match THEN
6082 IF x_Group_rec.match_within_rec.attribute15 = 'Y' THEN
6083 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
6084 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
6085 b_Match := FALSE;
6086 END IF;
6087 END IF;
6088 END IF;
6089 --
6090 IF (l_debug <> -1) THEN
6091 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
6092 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
6093 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6094 END IF;
6095 --
6096 --
6097 --
6098 ELSIF x_Current_rec.schedule_type <> g_Reconcile_tab(v_Count).schedule_type THEN
6099 --
6100 --
6101 --
6102 IF (l_debug <> -1) THEN
6103 rlm_core_sv.dlog(k_DEBUG,'Match across Schedules only ');
6104 END IF;
6105 --
6106 IF x_Group_rec.match_across_rec.cust_po_number = 'Y' THEN
6107 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
6108 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
6109 b_Match := FALSE;
6110 END IF;
6111 END IF;
6112 --
6113 IF (l_debug <> -1) THEN
6114 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
6115 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
6116 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6117 END IF;
6118 --
6119 IF b_Match THEN
6120 IF x_Group_rec.match_across_rec.customer_item_revision = 'Y' THEN
6121 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
6122 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
6123 b_Match := FALSE;
6124 END IF;
6125 END IF;
6126 END IF;
6127 --
6128 IF (l_debug <> -1) THEN
6129 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
6130 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
6131 g_Reconcile_tab(v_Count).customer_item_revision);
6132 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6133 END IF;
6134 --
6135 IF b_Match THEN
6136 IF x_Group_rec.match_across_rec.customer_dock_code = 'Y' THEN
6137 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
6138 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
6139 b_Match := FALSE;
6140 END IF;
6141 END IF;
6142 END IF;
6143 --
6144 IF (l_debug <> -1) THEN
6145 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
6146 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
6147 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6148 END IF;
6149 --
6150 IF b_Match THEN
6151 IF x_Group_rec.match_across_rec.customer_job = 'Y' THEN
6152 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
6153 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
6154 b_Match := FALSE;
6155 END IF;
6156 END IF;
6157 END IF;
6158 --
6159 IF (l_debug <> -1) THEN
6160 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
6161 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
6162 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6163 END IF;
6164 --
6165 IF b_Match THEN
6166 IF x_Group_rec.match_across_rec.cust_production_line = 'Y' THEN
6167 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
6168 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
6169 b_Match := FALSE;
6170 END IF;
6171 END IF;
6172 END IF;
6173 --
6174 IF (l_debug <> -1) THEN
6175 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
6176 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
6177 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6178 END IF;
6179 --
6180 IF b_Match THEN
6181 IF x_Group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
6182 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
6183 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
6184 b_Match := FALSE;
6185 END IF;
6186 END IF;
6187 END IF;
6188 --
6189 IF (l_debug <> -1) THEN
6190 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
6191 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
6192 g_Reconcile_tab(v_Count).cust_model_serial_number);
6193 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6194 END IF;
6195 --
6196 IF b_Match THEN
6197 IF x_Group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
6198 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
6199 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
6200 b_Match := FALSE;
6201 END IF;
6202 END IF;
6203 END IF;
6204 --
6205 IF (l_debug <> -1) THEN
6206 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
6207 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
6208 g_Reconcile_tab(v_Count).cust_production_seq_num);
6209 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6210 END IF;
6211 --
6212 IF b_Match THEN
6213 IF x_Group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
6214 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
6215 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
6216 b_Match := FALSE;
6217 END IF;
6218 END IF;
6219 END IF;
6220 --
6221 IF (l_debug <> -1) THEN
6222 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
6223 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
6224 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6225 END IF;
6226 --
6227 -- Bugfix 5608510
6228 IF v_intransit_calc_basis = 'PART_SHIP_LINES' THEN
6229
6230 IF b_Match THEN
6231 IF x_Group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
6232 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
6233 NVL(g_Reconcile_tab(v_Count).industry_attribute2, k_VNULL) THEN
6234 b_Match := FALSE;
6235 END IF;
6236 END IF;
6237 END IF;
6238 --
6239
6240 IF (l_debug <> -1) THEN
6241 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
6242 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
6243 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6244 END IF;
6245 --
6246 IF b_Match THEN
6247 IF x_Group_rec.match_across_rec.request_date = 'Y' THEN
6248 IF NVL(x_Current_rec.request_date, k_DNULL) <>
6249 NVL(g_Reconcile_tab(v_Count).request_date, k_DNULL) THEN
6250 b_Match := FALSE;
6251 END IF;
6252 END IF;
6253 END IF;
6254 --
6255 --
6256 IF (l_debug <> -1) THEN
6257 rlm_core_sv.dlog(k_DEBUG, 'request_date', x_Current_rec.request_date);
6258 rlm_core_sv.dlog(k_DEBUG, 'rec request_date', g_Reconcile_tab(v_Count).request_date);
6259 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6260 END IF;
6261 --
6262 END IF ; -- bugfix 5608510
6263 IF b_Match THEN
6264 IF x_Group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
6265 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
6266 NVL(g_Reconcile_tab(v_Count).industry_attribute4, k_VNULL) THEN
6267 b_Match := FALSE;
6268 END IF;
6269 END IF;
6270 END IF;
6271 --
6272 IF (l_debug <> -1) THEN
6273 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute4', x_Current_rec.industry_attribute4);
6274 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
6275 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6276 END IF;
6277 --
6278 IF b_Match THEN
6279 IF x_Group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
6280 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
6281 NVL(g_Reconcile_tab(v_Count).industry_attribute5, k_VNULL) THEN
6282 b_Match := FALSE;
6283 END IF;
6284 END IF;
6285 END IF;
6286 --
6287 IF (l_debug <> -1) THEN
6288 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute5', x_Current_rec.industry_attribute5);
6289 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
6290 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6291 END IF;
6292 --
6293 IF b_Match THEN
6294 IF x_Group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
6295 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
6296 NVL(g_Reconcile_tab(v_Count).industry_attribute6, k_VNULL) THEN
6297 b_Match := FALSE;
6298 END IF;
6299 END IF;
6300 END IF;
6301 --
6302 IF (l_debug <> -1) THEN
6303 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute6', x_Current_rec.industry_attribute6);
6304 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
6305 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6306 END IF;
6307 --
6308 IF b_Match THEN
6309 IF x_Group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
6310 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
6311 NVL(g_Reconcile_tab(v_Count).industry_attribute10, k_VNULL) THEN
6312 b_Match := FALSE;
6313 END IF;
6314 END IF;
6315 END IF;
6316 --
6317 IF (l_debug <> -1) THEN
6318 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute10', x_Current_rec.industry_attribute10);
6319 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
6320 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6321 END IF;
6322 --
6323 IF b_Match THEN
6324 IF x_Group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
6325 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
6326 NVL(g_Reconcile_tab(v_Count).industry_attribute11, k_VNULL) THEN
6327 b_Match := FALSE;
6328 END IF;
6329 END IF;
6330 END IF;
6331 --
6332 IF (l_debug <> -1) THEN
6333 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute11', x_Current_rec.industry_attribute11);
6334 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
6335 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6336 END IF;
6337 --
6338 IF b_Match THEN
6339 IF x_Group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
6340 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
6341 NVL(g_Reconcile_tab(v_Count).industry_attribute12, k_VNULL) THEN
6342 b_Match := FALSE;
6343 END IF;
6344 END IF;
6345 END IF;
6346 --
6347 IF (l_debug <> -1) THEN
6348 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute12', x_Current_rec.industry_attribute12);
6349 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
6350 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6351 END IF;
6352 --
6353 IF b_Match THEN
6354 IF x_Group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
6355 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
6356 NVL(g_Reconcile_tab(v_Count).industry_attribute13, k_VNULL) THEN
6357 b_Match := FALSE;
6358 END IF;
6359 END IF;
6360 END IF;
6361 --
6362 IF (l_debug <> -1) THEN
6363 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute13', x_Current_rec.industry_attribute13);
6364 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
6365 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6366 END IF;
6367 --
6368 IF b_Match THEN
6369 IF x_Group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
6370 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
6371 NVL(g_Reconcile_tab(v_Count).industry_attribute14, k_VNULL) THEN
6372 b_Match := FALSE;
6373 END IF;
6374 END IF;
6375 END IF;
6376 --
6377 IF (l_debug <> -1) THEN
6378 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute14', x_Current_rec.industry_attribute14);
6379 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
6380 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6381 END IF;
6382 --
6383 IF b_Match THEN
6384 IF x_Group_rec.match_across_rec.industry_attribute15 = 'Y' THEN
6385 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
6386 NVL(g_Reconcile_tab(v_Count).industry_attribute15, k_VNULL) THEN
6387 b_Match := FALSE;
6388 END IF;
6389 END IF;
6390 END IF;
6391 --
6392 IF (l_debug <> -1) THEN
6393 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute15', x_Current_rec.industry_attribute15);
6394 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
6395 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6396 END IF;
6397 --
6398 IF b_Match THEN
6399 IF x_Group_rec.match_across_rec.attribute1 = 'Y' THEN
6400 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
6401 NVL(g_Reconcile_tab(v_Count).attribute1, k_VNULL) THEN
6402 b_Match := FALSE;
6403 END IF;
6404 END IF;
6405 END IF;
6406 --
6407 IF (l_debug <> -1) THEN
6408 rlm_core_sv.dlog(k_DEBUG, 'attribute1', x_Current_rec.attribute1);
6409 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
6410 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6411 END IF;
6412 --
6413 IF b_Match THEN
6414 IF x_Group_rec.match_across_rec.attribute2 = 'Y' THEN
6415 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
6416 NVL(g_Reconcile_tab(v_Count).attribute2, k_VNULL) THEN
6417 b_Match := FALSE;
6418 END IF;
6419 END IF;
6420 END IF;
6421 --
6422 IF (l_debug <> -1) THEN
6423 rlm_core_sv.dlog(k_DEBUG, 'uattribute2', x_Current_rec.attribute2);
6424 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
6425 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6426 END IF;
6427 --
6428 IF b_Match THEN
6429 IF x_Group_rec.match_across_rec.attribute3 = 'Y' THEN
6430 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
6431 NVL(g_Reconcile_tab(v_Count).attribute3, k_VNULL) THEN
6432 b_Match := FALSE;
6433 END IF;
6434 END IF;
6435 END IF;
6436 --
6437 IF (l_debug <> -1) THEN
6438 rlm_core_sv.dlog(k_DEBUG, 'attribute3', x_Current_rec.attribute3);
6439 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
6440 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6441 END IF;
6442 --
6443 IF b_Match THEN
6444 IF x_Group_rec.match_across_rec.attribute4 = 'Y' THEN
6445 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
6446 NVL(g_Reconcile_tab(v_Count).attribute4, k_VNULL) THEN
6447 b_Match := FALSE;
6448 END IF;
6449 END IF;
6450 END IF;
6451 --
6452 IF (l_debug <> -1) THEN
6453 rlm_core_sv.dlog(k_DEBUG, 'attribute4', x_Current_rec.attribute4);
6454 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
6455 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6456 END IF;
6457 --
6458 IF b_Match THEN
6459 IF x_Group_rec.match_across_rec.attribute5 = 'Y' THEN
6460 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
6461 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
6462 b_Match := FALSE;
6463 END IF;
6464 END IF;
6465 END IF;
6466 --
6467 IF (l_debug <> -1) THEN
6468 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
6469 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
6470 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6471 END IF;
6472 --
6473 IF b_Match THEN
6474 IF x_Group_rec.match_across_rec.attribute6 = 'Y' THEN
6475 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
6476 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
6477 b_Match := FALSE;
6478 END IF;
6479 END IF;
6480 END IF;
6481 --
6482 IF (l_debug <> -1) THEN
6483 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
6484 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
6485 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6486 END IF;
6487 --
6488 IF b_Match THEN
6489 IF x_Group_rec.match_across_rec.attribute7 = 'Y' THEN
6490 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
6491 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
6492 b_Match := FALSE;
6493 END IF;
6494 END IF;
6495 END IF;
6496 --
6497 IF (l_debug <> -1) THEN
6498 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
6499 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
6500 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6501 END IF;
6502 --
6503 IF b_Match THEN
6504 IF x_Group_rec.match_across_rec.attribute8 = 'Y' THEN
6505 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
6506 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
6507 b_Match := FALSE;
6508 END IF;
6509 END IF;
6510 END IF;
6511 --
6512 IF (l_debug <> -1) THEN
6513 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
6514 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
6515 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6516 END IF;
6517 --
6518 IF b_Match THEN
6519 IF x_Group_rec.match_across_rec.attribute9 = 'Y' THEN
6520 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
6521 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
6522 b_Match := FALSE;
6523 END IF;
6524 END IF;
6525 END IF;
6526 --
6527 IF (l_debug <> -1) THEN
6528 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
6529 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
6530 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6531 END IF;
6532 --
6533 IF b_Match THEN
6534 IF x_Group_rec.match_across_rec.attribute10 = 'Y' THEN
6535 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
6536 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
6537 b_Match := FALSE;
6538 END IF;
6539 END IF;
6540 END IF;
6541 --
6542 IF (l_debug <> -1) THEN
6543 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
6544 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
6545 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6546 END IF;
6547 --
6548 IF b_Match THEN
6549 IF x_Group_rec.match_across_rec.attribute11 = 'Y' THEN
6550 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
6551 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
6552 b_Match := FALSE;
6553 END IF;
6554 END IF;
6555 END IF;
6556 --
6557 IF (l_debug <> -1) THEN
6558 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
6559 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
6560 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6561 END IF;
6562 --
6563 IF b_Match THEN
6564 IF x_Group_rec.match_across_rec.attribute12 = 'Y' THEN
6565 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
6566 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
6567 b_Match := FALSE;
6568 END IF;
6569 END IF;
6570 END IF;
6571 --
6572 IF (l_debug <> -1) THEN
6573 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
6574 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
6575 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6576 END IF;
6577 --
6578 IF b_Match THEN
6579 IF x_Group_rec.match_across_rec.attribute13 = 'Y' THEN
6580 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
6581 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
6582 b_Match := FALSE;
6583 END IF;
6584 END IF;
6585 END IF;
6586 --
6587 IF (l_debug <> -1) THEN
6588 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
6589 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
6590 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6591 END IF;
6592 --
6593 IF b_Match THEN
6594 IF x_Group_rec.match_across_rec.attribute14 = 'Y' THEN
6595 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
6596 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
6597 b_Match := FALSE;
6598 END IF;
6599 END IF;
6600 END IF;
6601 --
6602 IF (l_debug <> -1) THEN
6603 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
6604 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
6605 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6606 END IF;
6607 --
6608 IF b_Match THEN
6609 IF x_Group_rec.match_across_rec.attribute15 = 'Y' THEN
6610 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
6611 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
6612 b_Match := FALSE;
6613 END IF;
6614 END IF;
6615 END IF;
6616 --
6617 IF (l_debug <> -1) THEN
6618 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
6619 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
6620 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6621 END IF;
6622 --
6623 END IF;
6624 --
6625 IF b_Match THEN
6626 --
6627 x_Index := v_Count;
6628 EXIT;
6629 --
6630 END IF;
6631 --
6632 v_Count := g_Reconcile_tab.NEXT(v_Count);
6633 --}
6634 END LOOP;
6635 --}
6636 END IF;
6637 --
6638 IF (l_debug <> -1) THEN
6639 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
6640 rlm_core_sv.dpop(k_SDEBUG);
6641 END IF;
6642 --
6643 RETURN(b_Match);
6644 --
6645 EXCEPTION
6646 WHEN OTHERS THEN
6647 rlm_message_sv.sql_error('rlm_rd_sv.MatchReconcile',x_progress);
6648 --
6649 IF (l_debug <> -1) THEN
6650 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6651 END IF;
6652 --
6653 raise;
6654
6655 END MatchReconcile;
6656
6657
6658 /*===========================================================================
6659
6660 PROCEDURE StoreReconcile
6661
6662 ===========================================================================*/
6663 PROCEDURE StoreReconcile(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
6664 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
6665 x_Key_rec IN RLM_RD_SV.t_Key_rec,
6666 x_Quantity IN NUMBER)
6667 IS
6668 --
6669 v_Index NUMBER;
6670 x_progress VARCHAR2(3) := '010';
6671 --
6672 BEGIN
6673 /*Bug 2263253 : Reverted the modifications done under bug 2194938 */
6674 --
6675 IF (l_debug <> -1) THEN
6676 rlm_core_sv.dpush(k_SDEBUG,'StoreReconcile');
6677 rlm_core_sv.dlog(k_DEBUG,'Quantity to be reconciled', x_Quantity);
6678 END IF;
6679 --
6680 IF MatchReconcile(x_Group_rec, x_Key_rec.dem_rec, v_Index) THEN
6681 --
6682 g_Reconcile_tab(v_Index).ordered_quantity:=
6683 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + x_Quantity;
6684 --
6685 IF (l_debug <> -1) THEN
6686 rlm_core_sv.dlog(k_DEBUG,' Match Quantity ', g_Reconcile_tab(v_Index).ordered_quantity);
6687 END IF;
6688 --
6689 ELSE
6690 --
6691 -- bug 4223359 added this check as the PL/SQL table to null entries in between
6692 -- and the count is not necessarily the last element of the table
6693 --
6694 IF g_Reconcile_tab.First is NULL THEN
6695 --
6696 g_Reconcile_tab(1) := x_Key_rec.dem_rec;
6697 g_Reconcile_tab(1).ordered_quantity := x_Quantity;
6698 --
6699 ELSE
6700 --
6701 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.dem_rec;
6702 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := x_Quantity;
6703 --
6704 END IF;
6705 --
6706 IF (l_debug <> -1) THEN
6707 rlm_core_sv.dlog(k_DEBUG,' New Line Quantity ', g_Reconcile_tab(g_Reconcile_tab.COUNT).ordered_quantity);
6708 END IF;
6709 --
6710 END IF;
6711 --
6712 IF (l_debug <> -1) THEN
6713 rlm_core_sv.dpop(k_SDEBUG);
6714 END IF;
6715
6716 EXCEPTION
6717 WHEN OTHERS THEN
6718 rlm_message_sv.sql_error('rlm_rd_sv.StoreReconcile',x_progress);
6719 --
6720 IF (l_debug <> -1) THEN
6721 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6722 END IF;
6723 --
6724 raise;
6725
6726 END StoreReconcile;
6727
6728
6729 /*===========================================================================
6730
6731 PROCEDURE Reconcile
6732
6733 ===========================================================================*/
6734 PROCEDURE Reconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
6735 x_Key_rec IN RLM_RD_SV.t_Key_rec,
6736 x_Quantity IN OUT NOCOPY NUMBER)
6737 IS
6738
6739 v_Index NUMBER;
6740 x_progress VARCHAR2(3) := '010';
6741
6742 BEGIN
6743 --
6744 IF (l_debug <> -1) THEN
6745 rlm_core_sv.dpush(k_SDEBUG,'Reconcile');
6746 END IF;
6747 --
6748 IF MatchReconcile(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
6749 --
6750 IF (l_debug <> -1) THEN
6751 rlm_core_sv.dlog(k_DEBUG,'v_Index',v_Index);
6752 END IF;
6753 --
6754 --start of bug 4223359
6755 --
6756 IF NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) < 0 THEN
6757 --
6758 IF (l_debug <> -1) THEN
6759 --
6760 rlm_core_sv.dlog(k_DEBUG,'ordered_quantity',g_Reconcile_tab(v_Index).ordered_quantity);
6761 rlm_core_sv.dpop(k_SDEBUG);
6762 --
6763 END IF;
6764 --
6765 return;
6766 --
6767 ELSIF NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) > NVL(x_Quantity,0) THEN
6768 --
6769 g_Reconcile_tab(v_Index).ordered_quantity :=
6770 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0)
6771 - NVL(x_Quantity,0);
6772 --
6773 x_Quantity := 0;
6774 --
6775 ELSE
6776 --
6777 IF (l_debug <> -1) THEN
6778 --
6779 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
6780 rlm_core_sv.dlog(k_DEBUG,'Entry getting deleted from Reconcile Table', v_Index);
6781 rlm_core_sv.dlog(k_DEBUG,'deleted g_Reconcile_tab(v_Index).ordered_quantity',
6782 g_Reconcile_tab(v_Index).ordered_quantity);
6783 --
6784 END IF;
6785 --
6786 x_Quantity := NVL(x_Quantity ,0)-
6787 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0);
6788 g_Reconcile_tab.DELETE(v_Index);
6789 --
6790 END IF;
6791 --
6792 --end of bug 4223359
6793 --
6794 IF (l_debug <> -1) THEN
6795 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
6796 END IF;
6797 --
6798 END IF;
6799 --
6800 IF (l_debug <> -1) THEN
6801 rlm_core_sv.dpop(k_SDEBUG);
6802 END IF;
6803 --
6804 EXCEPTION
6805 WHEN OTHERS THEN
6806 rlm_message_sv.sql_error('rlm_rd_sv.Reconcile',x_progress);
6807 --
6808 IF (l_debug <> -1) THEN
6809 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6810 END IF;
6811 --
6812 raise;
6813
6814 END Reconcile;
6815
6816
6817 /*===========================================================================
6818
6819 FUNCTION AttributeChange
6820
6821 ===========================================================================*/
6822 FUNCTION AttributeChange(x_Key_rec IN RLM_RD_SV.t_Key_rec)
6823 RETURN BOOLEAN
6824 IS
6825
6826 b_Result BOOLEAN := TRUE;
6827 b_change BOOLEAN := FALSE;
6828 c_attr_cur t_Cursor_ref;
6829 x_progress VARCHAR2(3) := '010';
6830
6831 BEGIN
6832 --
6833 IF (l_debug <> -1) THEN
6834 rlm_core_sv.dpush(k_SDEBUG,'AttributeChange');
6835 END IF;
6836 --
6837 /*checks for an attribute change between dem rec
6838 and req rec. */
6839
6840 IF NVL(x_key_rec.req_rec.cust_po_number, k_VNULL) <>
6841 NVL(x_key_rec.dem_rec.cust_po_number, k_VNULL) THEN
6842 b_Change := TRUE;
6843 END IF;
6844 IF NOT b_Change THEN
6845 IF NVL(x_key_rec.req_rec.customer_item_revision, k_VNULL) <>
6846 NVL(x_key_rec.dem_rec.customer_item_revision, k_VNULL) THEN
6847 b_Change := TRUE;
6848 END IF;
6849 END IF;
6850 IF NOT b_Change THEN
6851 IF NVL(x_key_rec.req_rec.customer_dock_code, k_VNULL) <>
6852 NVL(x_key_rec.dem_rec.customer_dock_code, k_VNULL) THEN
6853 b_Change := TRUE;
6854 END IF;
6855 END IF;
6856 IF NOT b_Change THEN
6857 IF NVL(x_key_rec.req_rec.customer_job, k_VNULL) <>
6858 NVL(x_key_rec.dem_rec.customer_job, k_VNULL) THEN
6859 b_Change := TRUE;
6860 END IF;
6861 END IF;
6862 IF NOT b_Change THEN
6863 IF NVL(x_key_rec.req_rec.cust_production_line, k_VNULL) <>
6864 NVL(x_key_rec.dem_rec.cust_production_line, k_VNULL) THEN
6865 b_Change := TRUE;
6866 END IF;
6867 END IF;
6868 IF NOT b_Change THEN
6869 IF NVL(x_key_rec.req_rec.cust_model_serial_number, k_VNULL) <>
6870 NVL(x_key_rec.dem_rec.cust_model_serial_number, k_VNULL) THEN
6871 b_Change := TRUE;
6872 END IF;
6873 END IF;
6874 IF NOT b_Change THEN
6875 IF NVL(x_key_rec.req_rec.cust_production_seq_num, k_VNULL) <>
6876 NVL(x_key_rec.dem_rec.cust_production_seq_num, k_VNULL) THEN
6877 b_Change := TRUE;
6878 END IF;
6879 END IF;
6880 IF NOT b_Change THEN
6881 IF NVL(x_key_rec.req_rec.industry_attribute1, k_VNULL) <>
6882 NVL(x_key_rec.dem_rec.industry_attribute1, k_VNULL) THEN
6883 b_Change := TRUE;
6884 END IF;
6885 END IF;
6886 IF NOT b_Change THEN
6887 IF NVL(x_key_rec.req_rec.industry_attribute2, k_VNULL) <>
6888 NVL(x_key_rec.dem_rec.industry_attribute2, k_VNULL) THEN
6889 b_Change := TRUE;
6890 END IF;
6891 END IF;
6892 IF NOT b_Change THEN
6893 IF NVL(x_key_rec.req_rec.industry_attribute4, k_VNULL) <>
6894 NVL(x_key_rec.dem_rec.industry_attribute4, k_VNULL) THEN
6895 b_Change := TRUE;
6896 END IF;
6897 END IF;
6898 IF NOT b_Change THEN
6899 IF NVL(x_key_rec.req_rec.industry_attribute5, k_VNULL) <>
6900 NVL(x_key_rec.dem_rec.industry_attribute5, k_VNULL) THEN
6901 b_Change := TRUE;
6902 END IF;
6903 END IF;
6904 IF NOT b_Change THEN
6905 IF NVL(x_key_rec.req_rec.industry_attribute6, k_VNULL) <>
6906 NVL(x_key_rec.dem_rec.industry_attribute6, k_VNULL) THEN
6907 b_Change := TRUE;
6908 END IF;
6909 END IF;
6910 IF NOT b_Change THEN
6911 IF NVL(x_key_rec.req_rec.industry_attribute10, k_VNULL) <>
6912 NVL(x_key_rec.dem_rec.industry_attribute10, k_VNULL) THEN
6913 b_Change := TRUE;
6914 END IF;
6915 END IF;
6916 IF NOT b_Change THEN
6917 IF NVL(x_key_rec.req_rec.industry_attribute11, k_VNULL) <>
6918 NVL(x_key_rec.dem_rec.industry_attribute11, k_VNULL) THEN
6919 b_Change := TRUE;
6920 END IF;
6921 END IF;
6922 IF NOT b_Change THEN
6923 IF NVL(x_key_rec.req_rec.industry_attribute12, k_VNULL) <>
6924 NVL(x_key_rec.dem_rec.industry_attribute12, k_VNULL) THEN
6925 b_Change := TRUE;
6926 END IF;
6927 END IF;
6928 IF NOT b_Change THEN
6929 IF NVL(x_key_rec.req_rec.industry_attribute13, k_VNULL) <>
6930 NVL(x_key_rec.dem_rec.industry_attribute13, k_VNULL) THEN
6931 b_Change := TRUE;
6932 END IF;
6933 END IF;
6934 IF NOT b_Change THEN
6935 IF NVL(x_key_rec.req_rec.industry_attribute14, k_VNULL) <>
6936 NVL(x_key_rec.dem_rec.industry_attribute14, k_VNULL) THEN
6937 b_Change := TRUE;
6938 END IF;
6939 END IF;
6940 IF NOT b_Change THEN
6941 IF NVL(x_key_rec.req_rec.industry_attribute15, k_VNULL) <>
6942 NVL(x_key_rec.dem_rec.industry_attribute15, k_VNULL) THEN
6943 b_Change := TRUE;
6944 END IF;
6945 END IF;
6946 IF NOT b_Change THEN
6947 IF NVL(x_key_rec.req_rec.attribute1, k_VNULL) <>
6948 NVL(x_key_rec.dem_rec.attribute1, k_VNULL) THEN
6949 b_Change := TRUE;
6950 END IF;
6951 END IF;
6952 IF NOT b_Change THEN
6953 IF NVL(x_key_rec.req_rec.attribute2, k_VNULL) <>
6954 NVL(x_key_rec.dem_rec.attribute2, k_VNULL) THEN
6955 b_Change := TRUE;
6956 END IF;
6957 END IF;
6958 IF NOT b_Change THEN
6959 IF NVL(x_key_rec.req_rec.attribute3, k_VNULL) <>
6960 NVL(x_key_rec.dem_rec.attribute3, k_VNULL) THEN
6961 b_Change := TRUE;
6962 END IF;
6963 END IF;
6964 IF NOT b_Change THEN
6965 IF NVL(x_key_rec.req_rec.attribute4, k_VNULL) <>
6966 NVL(x_key_rec.dem_rec.attribute4, k_VNULL) THEN
6967 b_Change := TRUE;
6968 END IF;
6969 END IF;
6970 IF NOT b_Change THEN
6971 IF NVL(x_key_rec.req_rec.attribute5, k_VNULL) <>
6972 NVL(x_key_rec.dem_rec.attribute5, k_VNULL) THEN
6973 b_Change := TRUE;
6974 END IF;
6975 END IF;
6976 IF NOT b_Change THEN
6977 IF NVL(x_key_rec.req_rec.attribute6, k_VNULL) <>
6978 NVL(x_key_rec.dem_rec.attribute6, k_VNULL) THEN
6979 b_Change := TRUE;
6980 END IF;
6981 END IF;
6982 IF NOT b_Change THEN
6983 IF NVL(x_key_rec.req_rec.attribute7, k_VNULL) <>
6984 NVL(x_key_rec.dem_rec.attribute7, k_VNULL) THEN
6985 b_Change := TRUE;
6986 END IF;
6987 END IF;
6988 IF NOT b_Change THEN
6989 IF NVL(x_key_rec.req_rec.attribute8, k_VNULL) <>
6990 NVL(x_key_rec.dem_rec.attribute8, k_VNULL) THEN
6991 b_Change := TRUE;
6992 END IF;
6993 END IF;
6994 IF NOT b_Change THEN
6995 IF NVL(x_key_rec.req_rec.attribute9, k_VNULL) <>
6996 NVL(x_key_rec.dem_rec.attribute9, k_VNULL) THEN
6997 b_Change := TRUE;
6998 END IF;
6999 END IF;
7000 IF NOT b_Change THEN
7001 IF NVL(x_key_rec.req_rec.attribute10, k_VNULL) <>
7002 NVL(x_key_rec.dem_rec.attribute10, k_VNULL) THEN
7003 b_Change := TRUE;
7004 END IF;
7005 END IF;
7006 IF NOT b_Change THEN
7007 IF NVL(x_key_rec.req_rec.attribute12, k_VNULL) <>
7008 NVL(x_key_rec.dem_rec.attribute12, k_VNULL) THEN
7009 b_Change := TRUE;
7010 END IF;
7011 END IF;
7012 IF NOT b_Change THEN
7013 IF NVL(x_key_rec.req_rec.attribute13, k_VNULL) <>
7014 NVL(x_key_rec.dem_rec.attribute13, k_VNULL) THEN
7015 b_Change := TRUE;
7016 END IF;
7017 END IF;
7018 IF NOT b_Change THEN
7019 IF NVL(x_key_rec.req_rec.attribute14, k_VNULL) <>
7020 NVL(x_key_rec.dem_rec.attribute14, k_VNULL) THEN
7021 b_Change := TRUE;
7022 END IF;
7023 END IF;
7024 IF NOT b_Change THEN
7025 IF NVL(x_key_rec.req_rec.attribute15, k_VNULL) <>
7026 NVL(x_key_rec.dem_rec.attribute15, k_VNULL) THEN
7027 b_Change := TRUE;
7028 END IF;
7029 END IF;
7030
7031 IF b_Change THEN
7032 IF (l_debug <> -1) THEN
7033 rlm_core_sv.dpop(k_SDEBUG, 'true');
7034 END IF;
7035 ELSE
7036 --
7037 IF (l_debug <> -1) THEN
7038 rlm_core_sv.dpop(k_SDEBUG, 'false');
7039 END IF;
7040 --
7041 END IF;
7042
7043 RETURN(b_Change);
7044
7045 EXCEPTION
7046 WHEN OTHERS THEN
7047 rlm_message_sv.sql_error('rlm_rd_sv.AttributeChange',x_progress);
7048 --
7049 IF (l_debug <> -1) THEN
7050 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
7051 END IF;
7052 --
7053 raise;
7054
7055 END AttributeChange;
7056
7057
7058 /*===========================================================================
7059
7060 PROCEDURE ProcessPreHorizonATS
7061
7062 ===========================================================================*/
7063 PROCEDURE ProcessPreHorizonATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
7064 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
7065 IS
7066
7067 CURSOR c_PreHorizonDisp (x_OffsetDays NUMBER) IS
7068 SELECT line_id, rla_schedule_type_code
7069 FROM oe_order_lines
7070 WHERE header_id = x_Group_rec.order_header_id
7071 --global_atp
7072 AND ship_from_org_id =
7073 DECODE(g_ATP, k_ATP, ship_from_org_id,
7074 x_Group_rec.ship_from_org_id)
7075 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7076 AND ordered_item_id = x_Group_rec.customer_item_id
7077 AND inventory_item_id= x_Group_rec.inventory_item_id
7078 --pdue, global_atp
7079 AND NVL(industry_attribute15, k_VNULL) =
7080 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7081 NVL(x_Group_rec.industry_attribute15, k_VNULL))
7082 --bug 2181228
7083 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS')
7084 < (TRUNC(SYSDATE) - x_OffsetDays)
7085 AND (NVL(ordered_quantity,0) -
7086 NVL(shipped_quantity,0) > 0)
7087 AND authorized_to_ship_flag = k_ATS
7088 ORDER BY request_date DESC;
7089
7090 v_Key_rec t_Key_rec;
7091 v_DeleteQty NUMBER;
7092 x_progress VARCHAR2(3) := '010';
7093 v_line_num oe_order_lines.line_number%TYPE;
7094
7095 BEGIN
7096 --
7097 IF (l_debug <> -1) THEN
7098 rlm_core_sv.dpush(k_SDEBUG,'ProcessPreHorizonATS');
7099 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id',x_Group_rec.order_header_id);
7100 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id',x_Group_rec.ship_from_org_id);
7101 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id',x_Group_rec.ship_to_org_id);
7102 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id',x_Group_rec.customer_item_id);
7103 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',x_Group_rec.inventory_item_id);
7104 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.disposition_code',x_Group_rec.disposition_code);
7105 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.cutoff_days',x_Group_rec.cutoff_days);
7106 END IF;
7107 --
7108 IF x_Group_rec.disposition_code IN (k_CANCEL_ALL, k_CANCEL_AFTER_N_DAYS) THEN
7109 --
7110 FOR c_PreHorizonDisp_rec IN c_PreHorizonDisp(nvl(x_Group_rec.cutoff_days,0)) LOOP
7111 --
7112 v_Key_rec.oe_line_id := c_PreHorizonDisp_rec.line_id;
7113 --
7114 IF (l_debug <> -1) THEN
7115 rlm_core_sv.dlog(k_DEBUG,'c_PreHorizonDisp_rec.line_id',
7116 c_PreHorizonDisp_rec.line_id);
7117 END IF;
7118 --
7119 GetDemand(v_Key_rec, x_Group_rec);
7120 --
7121 v_Key_rec.req_rec := v_Key_rec.dem_rec;
7122 --
7123 IF NVL(c_PreHorizonDisp_rec.rla_schedule_type_code, ' ')
7124 NOT IN (x_Group_rec.schedule_type_one,
7125 x_Group_rec.schedule_type_two,
7126 x_Group_rec.schedule_type_three)
7127 THEN
7128 --
7129 SELECT line_number INTO v_line_num
7130 FROM oe_order_lines_all
7131 WHERE line_id = c_PreHorizonDisp_rec.line_id;
7132 --
7133 rlm_message_sv.app_error(
7134 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7135 x_MessageName => 'RLM_WRONG_SCHEDTYPE',
7136 x_InterfaceHeaderId => x_sched_rec.header_id,
7137 x_InterfaceLineId => NULL,
7138 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7139 x_ScheduleLineId => NULL,
7140 x_OrderHeaderId => x_Group_rec.order_header_id,
7141 x_Token1 => 'LINENUM',
7142 x_value1 => v_line_num,
7143 x_Token2 => 'SCHEDTYPE',
7144 x_value2 => c_PreHorizonDisp_rec.rla_schedule_type_code );
7145 --
7146 IF (l_debug <> -1) THEN
7147 rlm_core_sv.dlog(k_DEBUG,'line_number', v_line_num);
7148 rlm_core_sv.dlog(k_DEBUG,'RLM_WRONG_SCHEDTYPE');
7149 END IF;
7150 --
7151 END IF;
7152 --
7153 IF SchedulePrecedence(x_Group_rec, x_sched_rec,c_PreHorizonDisp_rec.rla_schedule_type_code) THEN
7154 --
7155 DeleteRequirement(x_Sched_rec, x_Group_rec,
7156 v_Key_rec, k_NORECONCILE, v_DeleteQty);
7157 END IF;
7158 --
7159 END LOOP;
7160 --
7161 END IF;
7162 --
7163 IF (l_debug <> -1) THEN
7164 rlm_core_sv.dpop(k_SDEBUG);
7165 END IF;
7166 --
7167 EXCEPTION
7168
7169 WHEN e_group_error THEN
7170 --
7171 IF (l_debug <> -1) THEN
7172 rlm_core_sv.dlog(k_DEBUG,'group error');
7173 rlm_core_sv.dpop(k_SDEBUG);
7174 END IF;
7175 --
7176 raise e_group_error;
7177
7178 WHEN OTHERS THEN
7179 rlm_message_sv.sql_error('rlm_rd_sv.ProcessPreHorizonATS',x_progress);
7180 --
7181 IF (l_debug <> -1) THEN
7182 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
7183 END IF;
7184 --
7185 raise;
7186
7187 END ProcessPreHorizonATS;
7188
7189
7190 /*===========================================================================
7191
7192 PROCEDURE ProcessOld
7193 -- NOTE JH: open issue with bucket requirements overlapping end horizon date
7194
7195 ===========================================================================*/
7196 PROCEDURE ProcessOld(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
7197 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
7198 IS
7199 --
7200 -- Bug 3733520 : Modified cursor to select attributes that are
7201 -- selected in procedure GetDemand(). All calls to GetDemand()
7202 -- have been replaced with a call to AssignOEAttribValues().
7203 --
7204 CURSOR c_OldDemand (x_ATS_start_date DATE,
7205 x_NATS_start_date DATE) IS
7206 SELECT header_id,
7207 line_id,
7208 ship_from_org_id,
7209 ship_to_org_id,
7210 ordered_item_id,
7211 inventory_item_id,
7212 invoice_to_org_id,
7213 intmed_ship_to_org_id,
7214 demand_bucket_type_code,
7215 rla_schedule_type_code,
7216 authorized_to_ship_flag ATS,
7217 ordered_quantity orig_ordered_quantity,
7218 NVL(ordered_quantity,0) -
7219 NVL(shipped_quantity,0) ordered_quantity,
7220 ordered_item,
7221 item_identifier_type,
7222 item_type_code,
7223 DECODE(x_Group_rec.setup_terms_rec.blanket_number, NULL,
7224 NULL, blanket_number) blanket_number,
7225 customer_line_number,
7226 customer_production_line cust_production_line,
7227 customer_dock_code,
7228 request_date,
7229 schedule_ship_date,
7230 cust_po_number,
7231 item_revision customer_item_revision,
7232 customer_job,
7233 cust_model_serial_number,
7234 cust_production_seq_num,
7235 industry_attribute1,
7236 industry_attribute2,
7237 industry_attribute3,
7238 industry_attribute4,
7239 industry_attribute5,
7240 industry_attribute6,
7241 industry_attribute7,
7242 industry_attribute8,
7243 industry_attribute9,
7244 industry_attribute10,
7245 industry_attribute11,
7246 industry_attribute12,
7247 industry_attribute13,
7248 industry_attribute14,
7249 industry_attribute15,
7250 attribute1,
7251 attribute2,
7252 attribute3,
7253 attribute4,
7254 attribute5,
7255 attribute6,
7256 attribute7,
7257 attribute8,
7258 attribute9,
7259 attribute10,
7260 attribute11,
7261 attribute12,
7262 attribute13,
7263 attribute14,
7264 attribute15,
7265 request_date +
7266 DECODE(demand_bucket_type_code,
7267 k_WEEKLY,6.99999,
7268 k_MONTHLY,29.99999,
7269 k_QUARTERLY,89.99999,0.99999) end_date_time, --bug 3596869
7270 DECODE(x_Sched_rec.schedule_purpose,
7271 k_ADD,DECODE(rla_schedule_type_code,
7272 x_Group_rec.schedule_type_one, 3,
7273 x_Group_rec.schedule_type_two, 2,
7274 x_Group_rec.schedule_type_three, 1),
7275 DECODE(rla_schedule_type_code,
7276 x_Group_rec.schedule_type_one, 1,
7277 x_Group_rec.schedule_type_two, 2,
7278 x_Group_rec.schedule_type_three, 3)) schedule_hierarchy
7279 FROM oe_order_lines
7280 WHERE header_id = x_Group_rec.order_header_id
7281 AND open_flag = 'Y' /*2263270*/
7282 --global_atp
7283 AND ship_from_org_id =
7284 DECODE(g_ATP, k_ATP, ship_from_org_id,
7285 x_Group_rec.ship_from_org_id)
7286 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7287 AND ordered_item_id = x_Group_rec.customer_item_id
7288 AND inventory_item_id = x_Group_rec.inventory_item_id
7289 AND NVL(intmed_ship_to_org_id,k_NNULL)= NVL(x_Group_rec.intmed_ship_to_org_id,k_NNULL) --Bugfix 5911991
7290 --global_atp
7291 AND NVL(industry_attribute15, k_VNULL) =
7292 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7293 NVL(x_Group_rec.industry_attribute15, k_VNULL))
7294 --bug 4223359
7295 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS') BETWEEN /*bug3879857*/
7296 DECODE(authorized_to_ship_flag,k_ATS,
7297 DECODE(x_group_rec.disposition_code,
7298 k_REMAIN_ON_FILE, x_Sched_rec.sched_horizon_start_date,
7299 k_REMAIN_ON_FILE_RECONCILE, to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS'),
7300 TRUNC(SYSDATE) - nvl(x_Group_rec.Cutoff_days,0)), TRUNC(SYSDATE))
7301 AND TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999
7302 --bug 2022158 (issue with sched_horizon_end_date timestamp)
7303 AND DECODE(x_Sched_rec.schedule_purpose,
7304 k_ADD, DECODE(rla_schedule_type_code,
7305 x_Group_rec.schedule_type_one, 2,
7306 x_Group_rec.schedule_type_two, 3,
7307 x_Group_rec.schedule_type_three, 4,0),
7308 DECODE(rla_schedule_type_code,
7309 x_Group_rec.schedule_type_one, 1,
7310 x_Group_rec.schedule_type_two, 2,
7311 x_Group_rec.schedule_type_three, 3,0)) <=
7312 DECODE(x_Sched_rec.schedule_type, x_Group_rec.schedule_type_one, 1,
7313 x_Group_rec.schedule_type_two, 2,
7314 x_Group_rec.schedule_type_three, 3)
7315 AND DECODE(x_Sched_rec.schedule_purpose,
7316 k_ADD,authorized_to_ship_flag,
7317 'N') = 'N'
7318 AND (NVL(ordered_quantity,0) - NVL(shipped_quantity,0) > 0)
7319 ORDER BY demand_bucket_type_code, schedule_hierarchy, end_date_time;
7320 --
7321 v_Quantity NUMBER;
7322 j NUMBER;
7323 v_Index NUMBER;
7324 v_Count NUMBER;
7325 v_Key_rec t_Key_rec;
7326 v_DeleteQty NUMBER;
7327 c_NewReq_ref t_Cursor_ref;
7328 v_Qty_rec t_Qty_rec;
7329 v_qty NUMBER;
7330 v_consume_quantity NUMBER;
7331 v_newref_qty NUMBER;
7332 v_newref_line_id RLM_INTERFACE_LINES.LINE_ID%TYPE;
7333 v_line_id RLM_INTERFACE_LINES.LINE_ID%TYPE;
7334 c_consume_ref t_Cursor_ref;
7335 v_consume_line_tab t_consume_tab;
7336 x_progress VARCHAR2(3) := '010';
7337 v_line_num oe_order_lines.line_number%type;
7338 e_WrongSchedType EXCEPTION;
7339 c_OldDemand_rec t_OEDemand_rec;
7340 v_ATS_start_date DATE;
7341 v_NATS_start_date DATE;
7342 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
7343 v_del_line_qty NUMBER :=0; --Bugfix 6159269
7344 --
7345 BEGIN
7346 --
7347 IF (l_debug <> -1) THEN
7348 rlm_core_sv.dpush(k_SDEBUG,'ProcessOld');
7349 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
7350 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
7351 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
7352 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',
7353 x_Group_rec.inventory_item_id);
7354 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id',
7355 x_Group_rec.ship_to_org_id);
7356 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_one', x_Group_rec.schedule_type_one);
7357 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_two',
7358 x_Group_rec.schedule_type_two);
7359 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_three',
7360 x_Group_rec.schedule_type_three);
7361 END IF;
7362 --
7363 /* We need to initialize the consume tab before the oldrec because the
7364 line should be matched against all old lines and consumed accordingly */
7365 --
7366 v_consume_line_tab.DELETE;
7367 --
7368 --
7369 -- FP Bug 3933822 jckwok
7370 IF (TRUNC(SYSDATE) > x_Sched_rec.sched_horizon_start_date)
7371 THEN
7372 IF (x_group_rec.disposition_code = k_REMAIN_ON_FILE)
7373 THEN
7374 v_ATS_start_date := x_Sched_rec.sched_horizon_start_date;
7375 ELSIF (x_group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS)
7376 THEN
7377 v_ATS_start_date := TRUNC(SYSDATE) - nvl(x_Group_rec.Cutoff_days,0);
7378 ELSE
7379 v_ATS_start_date := TRUNC(SYSDATE);
7380 END IF;
7381
7382 v_NATS_start_date := TRUNC(SYSDATE);
7383 ELSE
7384 v_ATS_start_date := x_Sched_rec.sched_horizon_start_date;
7385 v_NATS_start_date := x_Sched_rec.sched_horizon_start_date;
7386 END IF;
7387
7388 IF (l_debug <> -1) THEN
7389 rlm_core_sv.dlog(k_DEBUG,'x_ATS_start_date', v_ATS_start_date);
7390 rlm_core_sv.dlog(k_DEBUG,'x_NATS_start_date', v_NATS_start_date);
7391 END IF;
7392
7393 OPEN c_OldDemand(v_ATS_start_date , v_NATS_start_date);
7394 --End of FP Bug 3933822 changes --jckwok
7395 FETCH c_OldDemand INTO c_OldDemand_rec;
7396 WHILE c_OldDemand%FOUND LOOP
7397 --
7398 BEGIN
7399 --
7400 IF NVL(c_OldDemand_rec.rla_schedule_type_code, ' ')
7401 NOT IN (x_Group_rec.schedule_type_one,
7402 x_Group_rec.schedule_type_two,
7403 x_Group_rec.schedule_type_three)
7404 THEN
7405 RAISE e_WrongSchedType;
7406 END IF;
7407
7408 --
7409 IF (l_debug <> -1) THEN
7410 rlm_core_sv.dlog(k_DEBUG, '-------------------------------------------');
7411 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.line_id', c_OldDemand_rec.line_id);
7412 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_hierarchy',
7413 c_OldDemand_rec.schedule_hierarchy);
7414 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.end_date_time',
7415 c_OldDemand_rec.end_date_time);
7416 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_ship_date',
7417 c_OldDemand_rec.schedule_ship_date);
7418 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.request_date', c_OldDemand_rec.request_date);
7419 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.rla_schedule_type_code',
7420 c_OldDemand_rec.rla_schedule_type_code);
7421 END IF;
7422
7423 --
7424 /* We do need to select based on the item detail subtype as the weekly
7425 demand needs to be consumed by the daily demand as the weekly demand needs
7426 to be replaced by daily. Also we need to take into account the
7427 schedule date between old demands schedule date and end date.
7428 We have taken item_detail_type <= demand.item_method_type so that
7429 firm demand is never replaced by forecast data */
7430 --
7431 OPEN c_NewReq_ref FOR
7432 SELECT line_id, primary_quantity
7433 FROM rlm_interface_lines_all -- Bug 5223933
7434 WHERE header_id = x_Sched_rec.header_id
7435 --global_atp
7436 AND ship_from_org_id = x_Group_rec.ship_from_org_id
7437 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7438 AND customer_item_id = x_Group_rec.customer_item_id
7439 AND inventory_item_id= x_Group_rec.inventory_item_id
7440 AND order_header_id= x_Group_rec.order_header_id
7441 AND item_detail_subtype = c_OldDemand_rec.demand_bucket_type_code
7442 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
7443 rlm_core_sv.k_PS_FROZEN_FIRM)
7444 --bug 2031077
7445 --AND NVL(invoice_to_org_id, k_NNULL) =
7446 -- NVL(c_OldDemand_rec.invoice_to_org_id, k_NNULL)
7447 -- bug 4502559
7448 AND NVL(intmed_ship_to_org_id, k_NNULL) =
7449 NVL(c_OldDemand_rec.intmed_ship_to_org_id, k_NNULL)
7450 AND NVL(ship_to_org_id, k_NNULL) =
7451 NVL(c_OldDemand_rec.ship_to_org_id, k_NNULL)
7452 AND NVL(cust_production_line, k_VNULL) =
7453 DECODE(x_Group_rec.match_across_rec.cust_production_line, 'Y',
7454 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7455 DECODE(x_Group_rec.match_within_rec.cust_production_line, 'Y',
7456 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7457 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7458 NVL(cust_production_line, k_VNULL)),
7459 NVL(cust_production_line, k_VNULL)))
7460 AND NVL(customer_dock_code, k_VNULL) =
7461 DECODE(x_Group_rec.match_across_rec.customer_dock_code, 'Y',
7462 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7463 DECODE(x_Group_rec.match_within_rec.customer_dock_code, 'Y',
7464 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7465 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7466 NVL(customer_dock_code, k_VNULL)),
7467 NVL(customer_dock_code, k_VNULL)))
7468 AND NVL(request_date, k_DNULL) =
7469 DECODE(x_Group_rec.match_across_rec.request_date, 'Y',
7470 NVL(c_OldDemand_rec.request_date, k_DNULL),
7471 DECODE(x_Group_rec.match_within_rec.request_date, 'Y',
7472 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7473 NVL(c_OldDemand_rec.request_date, k_DNULL),
7474 NVL(request_date, k_DNULL)),
7475 NVL(request_date, k_DNULL)))
7476 AND NVL(cust_po_number, k_VNULL) =
7477 DECODE(x_Group_rec.match_across_rec.cust_po_number, 'Y',
7478 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7479 DECODE(x_Group_rec.match_within_rec.cust_po_number, 'Y',
7480 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7481 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7482 NVL(cust_po_number, k_VNULL)),
7483 NVL(cust_po_number, k_VNULL)))
7484 AND NVL(customer_item_revision, k_VNULL) =
7485 DECODE(x_Group_rec.match_across_rec.customer_item_revision, 'Y',
7486 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7487 DECODE(x_Group_rec.match_within_rec.customer_item_revision, 'Y',
7488 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7489 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7490 NVL(customer_item_revision, k_VNULL)),
7491 NVL(customer_item_revision, k_VNULL)))
7492 AND NVL(customer_job, k_VNULL) =
7493 DECODE(x_Group_rec.match_across_rec.customer_job, 'Y',
7494 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7495 DECODE(x_Group_rec.match_within_rec.customer_job, 'Y',
7496 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7497 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7498 NVL(customer_job, k_VNULL)),
7499 NVL(customer_job, k_VNULL)))
7500 AND NVL(cust_model_serial_number, k_VNULL) =
7501 DECODE(x_Group_rec.match_across_rec.cust_model_serial_number, 'Y',
7502 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7503 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number, 'Y',
7504 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7505 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7506 NVL(cust_model_serial_number, k_VNULL)),
7507 NVL(cust_model_serial_number, k_VNULL)))
7508 AND NVL(cust_production_seq_num, k_VNULL) =
7509 DECODE(x_Group_rec.match_across_rec.cust_production_seq_num, 'Y',
7510 NVL(c_OldDemand_rec.cust_production_seq_num, k_VNULL),
7511 DECODE(x_Group_rec.match_within_rec.cust_production_seq_num, 'Y',
7512 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7513 NVL(c_OldDemand_rec.cust_production_seq_num, k_VNULL),
7514 NVL(cust_production_seq_num, k_VNULL)),
7515 NVL(cust_production_seq_num, k_VNULL)))
7516 AND NVL(industry_attribute1, k_VNULL) =
7517 DECODE(x_Group_rec.match_across_rec.industry_attribute1, 'Y',
7518 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7519 DECODE(x_Group_rec.match_within_rec.industry_attribute1, 'Y',
7520 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7521 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7522 NVL(industry_attribute1, k_VNULL)),
7523 NVL(industry_attribute1, k_VNULL)))
7524 AND NVL(industry_attribute2, k_VNULL) =
7525 DECODE(x_Group_rec.match_across_rec.industry_attribute2, 'Y',
7526 NVL(c_OldDemand_rec.industry_attribute2, k_VNULL),
7527 DECODE(x_Group_rec.match_within_rec.industry_attribute2, 'Y',
7528 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7529 NVL(c_OldDemand_rec.industry_attribute2, k_VNULL),
7530 NVL(industry_attribute2, k_VNULL)),
7531 NVL(industry_attribute2, k_VNULL)))
7532 AND NVL(industry_attribute4, k_VNULL) =
7533 DECODE(x_Group_rec.match_across_rec.industry_attribute4, 'Y',
7534 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7535 DECODE(x_Group_rec.match_within_rec.industry_attribute4, 'Y',
7536 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7537 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7538 NVL(industry_attribute4, k_VNULL)),
7539 NVL(industry_attribute4, k_VNULL)))
7540 AND NVL(industry_attribute5, k_VNULL) =
7541 DECODE(x_Group_rec.match_across_rec.industry_attribute5, 'Y',
7542 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7543 DECODE(x_Group_rec.match_within_rec.industry_attribute5, 'Y',
7544 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7545 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7546 NVL(industry_attribute5, k_VNULL)),
7547 NVL(industry_attribute5, k_VNULL)))
7548 AND NVL(industry_attribute6, k_VNULL) =
7549 DECODE(x_Group_rec.match_across_rec.industry_attribute6, 'Y',
7550 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7551 DECODE(x_Group_rec.match_within_rec.industry_attribute6, 'Y',
7552 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7553 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7554 NVL(industry_attribute6, k_VNULL)),
7555 NVL(industry_attribute6, k_VNULL)))
7556 AND NVL(industry_attribute10, k_VNULL) =
7557 DECODE(x_Group_rec.match_across_rec.industry_attribute10, 'Y',
7558 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7559 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y',
7560 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7561 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7562 NVL(industry_attribute10, k_VNULL)),
7563 NVL(industry_attribute10, k_VNULL)))
7564 AND NVL(industry_attribute11, k_VNULL) =
7565 DECODE(x_Group_rec.match_across_rec.industry_attribute11, 'Y',
7566 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
7567 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y',
7568 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7569 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
7570 NVL(industry_attribute11, k_VNULL)),
7571 NVL(industry_attribute11, k_VNULL)))
7572 AND NVL(industry_attribute12, k_VNULL) =
7573 DECODE(x_Group_rec.match_across_rec.industry_attribute12, 'Y',
7574 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
7575 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y',
7576 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7577 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
7578 NVL(industry_attribute12, k_VNULL)),
7579 NVL(industry_attribute12, k_VNULL)))
7580 AND NVL(industry_attribute13, k_VNULL) =
7581 DECODE(x_Group_rec.match_across_rec.industry_attribute13, 'Y',
7582 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
7583 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y',
7584 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7585 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
7586 NVL(industry_attribute13, k_VNULL)),
7587 NVL(industry_attribute13, k_VNULL)))
7588 AND NVL(industry_attribute14, k_VNULL) =
7589 DECODE(x_Group_rec.match_across_rec.industry_attribute14, 'Y',
7590 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
7591 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y',
7592 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7593 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
7594 NVL(industry_attribute14, k_VNULL)),
7595 NVL(industry_attribute14, k_VNULL)))
7596 --global_atp?
7597 AND NVL(industry_attribute15, k_VNULL) =
7598 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7599 NVL(c_OldDemand_rec.industry_attribute15, k_VNULL))
7600 AND NVL(attribute1, k_VNULL) =
7601 DECODE(x_Group_rec.match_across_rec.attribute1, 'Y',
7602 NVL(c_OldDemand_rec.attribute1, k_VNULL),
7603 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y',
7604 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7605 NVL(c_OldDemand_rec.attribute1, k_VNULL),
7606 NVL(attribute1, k_VNULL)),
7607 NVL(attribute1, k_VNULL)))
7608 AND NVL(attribute2, k_VNULL) =
7609 DECODE(x_Group_rec.match_across_rec.attribute2, 'Y',
7610 NVL(c_OldDemand_rec.attribute2, k_VNULL),
7611 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y',
7612 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7613 NVL(c_OldDemand_rec.attribute2, k_VNULL),
7614 NVL(attribute2, k_VNULL)),
7615 NVL(attribute2, k_VNULL)))
7616 AND NVL(attribute3, k_VNULL) =
7617 DECODE(x_Group_rec.match_across_rec.attribute3, 'Y',
7618 NVL(c_OldDemand_rec.attribute3, k_VNULL),
7619 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y',
7620 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7621 NVL(c_OldDemand_rec.attribute3, k_VNULL),
7622 NVL(attribute3, k_VNULL)),
7623 NVL(attribute3, k_VNULL)))
7624 AND NVL(attribute4, k_VNULL) =
7625 DECODE(x_Group_rec.match_across_rec.attribute4, 'Y',
7626 NVL(c_OldDemand_rec.attribute4, k_VNULL),
7627 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y',
7628 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7629 NVL(c_OldDemand_rec.attribute4, k_VNULL),
7630 NVL(attribute4, k_VNULL)),
7631 NVL(attribute4, k_VNULL)))
7632 AND NVL(attribute5, k_VNULL) =
7633 DECODE(x_Group_rec.match_across_rec.attribute5, 'Y',
7634 NVL(c_OldDemand_rec.attribute5, k_VNULL),
7635 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y',
7636 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7637 NVL(c_OldDemand_rec.attribute5, k_VNULL),
7638 NVL(attribute5, k_VNULL)),
7639 NVL(attribute5, k_VNULL)))
7640 AND NVL(attribute6, k_VNULL) =
7641 DECODE(x_Group_rec.match_across_rec.attribute6, 'Y',
7642 NVL(c_OldDemand_rec.attribute6, k_VNULL),
7643 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y',
7644 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7645 NVL(c_OldDemand_rec.attribute6, k_VNULL),
7646 NVL(attribute6, k_VNULL)),
7647 NVL(attribute6, k_VNULL)))
7648 AND NVL(attribute7, k_VNULL) =
7649 DECODE(x_Group_rec.match_across_rec.attribute7, 'Y',
7650 NVL(c_OldDemand_rec.attribute7, k_VNULL),
7651 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y',
7652 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7653 NVL(c_OldDemand_rec.attribute7, k_VNULL),
7654 NVL(attribute7, k_VNULL)),
7655 NVL(attribute7, k_VNULL)))
7656 AND NVL(attribute8, k_VNULL) =
7657 DECODE(x_Group_rec.match_across_rec.attribute8, 'Y',
7658 NVL(c_OldDemand_rec.attribute8, k_VNULL),
7659 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y',
7660 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7661 NVL(c_OldDemand_rec.attribute8, k_VNULL),
7662 NVL(attribute8, k_VNULL)),
7663 NVL(attribute8, k_VNULL)))
7664 AND NVL(attribute9, k_VNULL) =
7665 DECODE(x_Group_rec.match_across_rec.attribute9, 'Y',
7666 NVL(c_OldDemand_rec.attribute9, k_VNULL),
7667 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y',
7668 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7669 NVL(c_OldDemand_rec.attribute9, k_VNULL),
7670 NVL(attribute9, k_VNULL)),
7671 NVL(attribute9, k_VNULL)))
7672 AND NVL(attribute10, k_VNULL) =
7673 DECODE(x_Group_rec.match_across_rec.attribute10, 'Y',
7674 NVL(c_OldDemand_rec.attribute10, k_VNULL),
7675 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y',
7676 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7677 NVL(c_OldDemand_rec.attribute10, k_VNULL),
7678 NVL(attribute10, k_VNULL)),
7679 NVL(attribute10, k_VNULL)))
7680 AND NVL(attribute11, k_VNULL) =
7681 DECODE(x_Group_rec.match_across_rec.attribute11, 'Y',
7682 NVL(c_OldDemand_rec.attribute11, k_VNULL),
7683 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y',
7684 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7685 NVL(c_OldDemand_rec.attribute11, k_VNULL),
7686 NVL(attribute11, k_VNULL)),
7687 NVL(attribute11, k_VNULL)))
7688 AND NVL(attribute12, k_VNULL) =
7689 DECODE(x_Group_rec.match_across_rec.attribute12, 'Y',
7690 NVL(c_OldDemand_rec.attribute12, k_VNULL),
7691 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y',
7692 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7693 NVL(c_OldDemand_rec.attribute12, k_VNULL),
7694 NVL(attribute12, k_VNULL)),
7695 NVL(attribute12, k_VNULL)))
7696 AND NVL(attribute13, k_VNULL) =
7697 DECODE(x_Group_rec.match_across_rec.attribute13, 'Y',
7698 NVL(c_OldDemand_rec.attribute13, k_VNULL),
7699 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y',
7700 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7701 NVL(c_OldDemand_rec.attribute13, k_VNULL),
7702 NVL(attribute13, k_VNULL)),
7703 NVL(attribute13, k_VNULL)))
7704 AND NVL(attribute14, k_VNULL) =
7705 DECODE(x_Group_rec.match_across_rec.attribute14, 'Y',
7706 NVL(c_OldDemand_rec.attribute14, k_VNULL),
7707 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y',
7708 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7709 NVL(c_OldDemand_rec.attribute14, k_VNULL),
7710 NVL(attribute14, k_VNULL)),
7711 NVL(attribute14, k_VNULL)))
7712 AND NVL(attribute15, k_VNULL) =
7713 DECODE(x_Group_rec.match_across_rec.attribute15, 'Y',
7714 NVL(c_OldDemand_rec.attribute15, k_VNULL),
7715 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y',
7716 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7717 NVL(c_OldDemand_rec.attribute15, k_VNULL),
7718 NVL(attribute15, k_VNULL)),
7719 NVL(attribute15, k_VNULL)));
7720 --
7721 FETCH c_NewReq_ref INTO v_newref_line_id, v_newref_qty;
7722 --
7723 IF (l_debug <> -1) THEN
7724 rlm_core_sv.dlog(k_DEBUG,'v_consume_quantity',v_consume_quantity);
7725 rlm_core_sv.dlog(k_DEBUG,'v_Count',v_Count);
7726 rlm_core_sv.dlog(k_DEBUG,'c_NewReq_ref%ROWCOUNT',c_NewReq_ref%ROWCOUNT);
7727 rlm_core_sv.dlog(k_DEBUG,'c_NewReq_ref%NOTFOUND',c_NewReq_ref%NOTFOUND);
7728 END IF;
7729 --
7730 IF c_NewReq_ref%NOTFOUND OR x_Sched_rec.schedule_purpose = k_ADD THEN
7731 --
7732 IF (l_debug <> -1) THEN
7733 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date',
7734 x_Sched_rec.sched_horizon_end_date);
7735 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.end_date_time',
7736 c_OldDemand_rec.end_date_time);
7737 END IF;
7738 --
7739 --pdue
7740 IF x_Sched_rec.schedule_source <> 'MANUAL' AND
7741 IsFrozen(TRUNC(SYSDATE), x_Group_rec, c_OldDemand_rec.request_date)
7742 AND x_Sched_rec.schedule_purpose <> k_ADD THEN
7743 --
7744 IF (l_debug <> -1) THEN
7745 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.line_id',
7746 c_OldDemand_rec.line_id);
7747 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.request_date',
7748 c_OldDemand_rec.request_date);
7749 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_ship_date',
7750 c_OldDemand_rec.schedule_ship_date);
7751 END IF;
7752 --
7753 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
7754 StoreReconcile(x_Sched_rec, x_Group_rec, v_Key_rec,
7755 c_OldDemand_rec.ordered_quantity);
7756 --
7757 -- Bug 4297984 Start
7758 GetMatchAttributes(x_sched_rec,x_group_rec, v_Key_rec.dem_rec,v_MatchAttrTxt);
7759 --
7760 IF (c_OldDemand_rec.rla_schedule_type_code = 'SEQUENCED') THEN
7761 --
7762 rlm_message_sv.app_error(
7763 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7764 x_MessageName => 'RLM_FROZEN_DELETE_SEQ',
7765 x_InterfaceHeaderId => x_sched_rec.header_id,
7766 x_InterfaceLineId => NULL,
7767 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7768 x_ScheduleLineId => NULL,
7769 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
7770 x_OrderLineId => c_OldDemand_rec.line_id,
7771 x_Token1 => 'LINE',
7772 x_value1 => rlm_core_sv.get_order_line_number(c_OldDemand_rec.line_id),
7773 x_Token2 => 'ORDER',
7774 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
7775 x_Token3 => 'QUANTITY',
7776 x_value3 => c_OldDemand_rec.ordered_quantity,
7777 x_Token4 => 'CUSTITEM',
7778 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
7779 x_Token5 => 'REQ_DATE',
7780 x_value5 => c_OldDemand_rec.request_date,
7781 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
7782 x_value6 => v_del_line_qty, --Bugfix 6159269
7783 x_Token7 => 'SEQ_INFO',
7784 x_value7 => nvl(c_OldDemand_rec.cust_production_seq_num,'NULL') ||'-'||
7785 nvl(c_OldDemand_rec.cust_model_serial_number,'NULL')||'-'||
7786 nvl(c_OldDemand_rec.customer_job,'NULL'),
7787 x_Token8 => 'MATCH_ATTR',
7788 x_value8 => v_MatchAttrTxt);
7789 --
7790 IF (l_debug <> -1) THEN
7791 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE_SEQ',
7792 c_OldDemand_rec.line_id);
7793 END IF;
7794 --
7795 ELSE
7796 --
7797 rlm_message_sv.app_error(
7798 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7799 x_MessageName => 'RLM_FROZEN_DELETE',
7800 x_InterfaceHeaderId => x_sched_rec.header_id,
7801 x_InterfaceLineId => NULL,
7802 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7803 x_ScheduleLineId => NULL,
7804 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
7805 x_OrderLineId => c_OldDemand_rec.line_id,
7806 x_Token1 => 'LINE',
7807 x_value1 => rlm_core_sv.get_order_line_number(c_OldDemand_rec.line_id),
7808 x_Token2 => 'ORDER',
7809 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
7810 x_Token3 => 'QUANTITY',
7811 x_value3 => c_OldDemand_rec.ordered_quantity,
7812 x_Token4 => 'CUSTITEM',
7813 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
7814 x_Token5 => 'REQ_DATE',
7815 x_value5 => c_OldDemand_rec.request_date,
7816 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
7817 x_value6 => v_del_line_qty, --Bugfix 6159269
7818 x_Token7 => 'MATCH_ATTR',
7819 x_value7 => v_MatchAttrTxt);
7820 --
7821 IF (l_debug <> -1) THEN
7822 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE',
7823 c_OldDemand_rec.line_id);
7824 END IF;
7825 --
7826 END IF;
7827 -- Bug 4297984 End
7828 --
7829 ELSIF TRUNC(x_Sched_rec.sched_horizon_end_date) + 0.99999
7830 >= TRUNC(c_OldDemand_rec.end_date_time) AND
7831 x_Sched_rec.schedule_purpose <> k_ADD THEN
7832 --bug 1680657
7833 --
7834 IF (l_debug <> -1) THEN
7835 rlm_core_sv.dlog(k_DEBUG,'in no consume delete ');
7836 END IF;
7837 --
7838 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
7839 --
7840 v_Key_rec.req_rec := v_Key_rec.dem_rec;
7841 --
7842 DeleteRequirement(x_Sched_rec, x_Group_rec,
7843 v_Key_rec, k_RECONCILE, v_DeleteQty);
7844 --
7845 ELSE
7846 --
7847 IF (l_debug <> -1) THEN
7848 rlm_core_sv.dlog(k_DEBUG,'In consume -- c_OldDemand_rec.end_date_time',
7849 c_OldDemand_rec.end_date_time);
7850 END IF;
7851 --
7852 /* Consume demand -- We may need to loop through the new demand
7853 recs because there could be a case where
7854 we have multiple new lines which need to be consumed as 2
7855 or more old demands fall outside the new horizon and
7856 so we need to keep a track of which lines are consumed
7857 already and then consume the demand as it comes in. */
7858 --
7859 OPEN c_consume_ref FOR
7860 SELECT line_id, primary_quantity
7861 FROM rlm_interface_lines
7862 WHERE header_id = x_Sched_rec.header_id
7863 --global_atp
7864 AND ship_from_org_id = x_Group_rec.ship_from_org_id
7865 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7866 AND customer_item_id = x_Group_rec.customer_item_id
7867 AND inventory_item_id= x_Group_rec.inventory_item_id
7868 AND order_header_id= x_Group_rec.order_header_id
7869 /*AND nvl(cust_production_seq_num, k_VNULL)=
7870 nvl(x_Group_rec.cust_production_seq_num,k_VNULL)*/
7871 AND item_detail_type in (
7872 DECODE(x_Sched_rec.schedule_purpose,
7873 k_ADD,
7874 1,0),
7875 DECODE(x_Sched_rec.schedule_purpose,
7876 k_ADD,
7877 0,1),DECODE(x_Sched_rec.schedule_purpose,
7878 k_ADD,
7879 0,2))
7880 AND DECODE(x_Sched_rec.schedule_purpose,
7881 k_ADD,
7882 item_detail_subtype,
7883 DECODE(item_detail_subtype,'AHEAD_BEHIND', k_LARGE,
7884 'CUM', k_LARGE, 'FINISHED', k_LARGE,
7885 'HOLDOUT_QTY', k_LARGE, 'INVENTORY_BAL', k_LARGE,
7886 'LABOR', k_LARGE, 'LABOR_MATERIAL', k_LARGE,
7887 'MATERIAL', k_LARGE, 'PRIOR_CUM_REQ', k_LARGE,
7888 'RECEIPT', k_LARGE, 'SHIPMENT', k_LARGE,
7889 item_detail_subtype)
7890 +1)
7891 <= c_OldDemand_rec.demand_bucket_type_code
7892 AND request_date BETWEEN c_OldDemand_rec.request_date
7893 AND c_OldDemand_rec.end_date_time
7894 AND process_status = rlm_core_sv.k_PS_AVAILABLE
7895 --bug 2031077
7896 --AND NVL(invoice_to_org_id, k_NNULL) =
7897 -- NVL(c_OldDemand_rec.invoice_to_org_id, k_NNULL)
7898 AND NVL(intmed_ship_to_org_id, k_NNULL) =
7899 NVL(c_OldDemand_rec.intmed_ship_to_org_id, k_NNULL)
7900 /* including matching critera */
7901 AND NVL(cust_production_line, k_VNULL) =
7902 DECODE(x_Group_rec.match_across_rec.cust_production_line, 'Y',
7903 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7904 DECODE(x_Group_rec.match_within_rec.cust_production_line, 'Y',
7905 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7906 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7907 NVL(cust_production_line, k_VNULL)),
7908 NVL(cust_production_line, k_VNULL)))
7909 AND NVL(customer_dock_code, k_VNULL) =
7910 DECODE(x_Group_rec.match_across_rec.customer_dock_code, 'Y',
7911 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7912 DECODE(x_Group_rec.match_within_rec.customer_dock_code, 'Y',
7913 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7914 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7915 NVL(customer_dock_code, k_VNULL)),
7916 NVL(customer_dock_code, k_VNULL)))
7917
7918 /* Fix for Bug #: 1588331
7919 For consumption, do not use request_date as a
7920 matching attribute across schedules */
7921
7922 AND NVL(cust_po_number, k_VNULL) =
7923 DECODE(x_Group_rec.match_across_rec.cust_po_number, 'Y',
7924 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7925 DECODE(x_Group_rec.match_within_rec.cust_po_number, 'Y',
7926 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7927 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7928 NVL(cust_po_number, k_VNULL)),
7929 NVL(cust_po_number, k_VNULL)))
7930 AND NVL(customer_item_revision, k_VNULL) =
7931 DECODE(x_Group_rec.match_across_rec.customer_item_revision, 'Y',
7932 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7933 DECODE(x_Group_rec.match_within_rec.customer_item_revision, 'Y',
7934 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7935 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7936 NVL(customer_item_revision, k_VNULL)),
7937 NVL(customer_item_revision, k_VNULL)))
7938 AND NVL(customer_job, k_VNULL) =
7939 DECODE(x_Group_rec.match_across_rec.customer_job, 'Y',
7940 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7941 DECODE(x_Group_rec.match_within_rec.customer_job, 'Y',
7942 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7943 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7944 NVL(customer_job, k_VNULL)),
7945 NVL(customer_job, k_VNULL)))
7946 AND NVL(cust_model_serial_number, k_VNULL) =
7947 DECODE(x_Group_rec.match_across_rec.cust_model_serial_number, 'Y',
7948 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7949 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number, 'Y',
7950 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7951 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7952 NVL(cust_model_serial_number, k_VNULL)),
7953 NVL(cust_model_serial_number, k_VNULL)))
7954 AND NVL(industry_attribute1, k_VNULL) =
7955 DECODE(x_Group_rec.match_across_rec.industry_attribute1, 'Y',
7956 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7957 DECODE(x_Group_rec.match_within_rec.industry_attribute1, 'Y',
7958 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7959 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7960 NVL(industry_attribute1, k_VNULL)),
7961 NVL(industry_attribute1, k_VNULL)))
7962
7963 /* Fix for Bug #: 1588331
7964 For consumption, do not use industry_attribute2 as a
7965 matching attribute across schedules. */
7966
7967 AND NVL(industry_attribute4, k_VNULL) =
7968 DECODE(x_Group_rec.match_across_rec.industry_attribute4, 'Y',
7969 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7970 DECODE(x_Group_rec.match_within_rec.industry_attribute4, 'Y',
7971 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7972 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7973 NVL(industry_attribute4, k_VNULL)),
7974 NVL(industry_attribute4, k_VNULL)))
7975 AND NVL(industry_attribute5, k_VNULL) =
7976 DECODE(x_Group_rec.match_across_rec.industry_attribute5, 'Y',
7977 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7978 DECODE(x_Group_rec.match_within_rec.industry_attribute5, 'Y',
7979 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7980 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7981 NVL(industry_attribute5, k_VNULL)),
7982 NVL(industry_attribute5, k_VNULL)))
7983 AND NVL(industry_attribute6, k_VNULL) =
7984 DECODE(x_Group_rec.match_across_rec.industry_attribute6, 'Y',
7985 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7986 DECODE(x_Group_rec.match_within_rec.industry_attribute6, 'Y',
7987 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7988 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7989 NVL(industry_attribute6, k_VNULL)),
7990 NVL(industry_attribute6, k_VNULL)))
7991 AND NVL(industry_attribute10, k_VNULL) =
7992 DECODE(x_Group_rec.match_across_rec.industry_attribute10, 'Y',
7993 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7994 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y',
7995 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7996 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7997 NVL(industry_attribute10, k_VNULL)),
7998 NVL(industry_attribute10, k_VNULL)))
7999 AND NVL(industry_attribute11, k_VNULL) =
8000 DECODE(x_Group_rec.match_across_rec.industry_attribute11, 'Y',
8001 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
8002 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y',
8003 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8004 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
8005 NVL(industry_attribute11, k_VNULL)),
8006 NVL(industry_attribute11, k_VNULL)))
8007 AND NVL(industry_attribute12, k_VNULL) =
8008 DECODE(x_Group_rec.match_across_rec.industry_attribute12, 'Y',
8009 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
8010 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y',
8011 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8012 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
8013 NVL(industry_attribute12, k_VNULL)),
8014 NVL(industry_attribute12, k_VNULL)))
8015 AND NVL(industry_attribute13, k_VNULL) =
8016 DECODE(x_Group_rec.match_across_rec.industry_attribute13, 'Y',
8017 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
8018 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y',
8019 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8020 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
8021 NVL(industry_attribute13, k_VNULL)),
8022 NVL(industry_attribute13, k_VNULL)))
8023 AND NVL(industry_attribute14, k_VNULL) =
8024 DECODE(x_Group_rec.match_across_rec.industry_attribute14, 'Y',
8025 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
8026 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y',
8027 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8028 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
8029 NVL(industry_attribute14, k_VNULL)),
8030 NVL(industry_attribute14, k_VNULL)))
8031 --global_atp
8032 AND NVL(industry_attribute15, k_VNULL) =
8033 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
8034 NVL(c_OldDemand_rec.industry_attribute15, k_VNULL))
8035 AND NVL(attribute1, k_VNULL) =
8036 DECODE(x_Group_rec.match_across_rec.attribute1, 'Y',
8037 NVL(c_OldDemand_rec.attribute1, k_VNULL),
8038 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y',
8039 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8040 NVL(c_OldDemand_rec.attribute1, k_VNULL),
8041 NVL(attribute1, k_VNULL)),
8042 NVL(attribute1, k_VNULL)))
8043 AND NVL(attribute2, k_VNULL) =
8044 DECODE(x_Group_rec.match_across_rec.attribute2, 'Y',
8045 NVL(c_OldDemand_rec.attribute2, k_VNULL),
8046 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y',
8047 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8048 NVL(c_OldDemand_rec.attribute2, k_VNULL),
8049 NVL(attribute2, k_VNULL)),
8050 NVL(attribute2, k_VNULL)))
8051 AND NVL(attribute3, k_VNULL) =
8052 DECODE(x_Group_rec.match_across_rec.attribute3, 'Y',
8053 NVL(c_OldDemand_rec.attribute3, k_VNULL),
8054 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y',
8055 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8056 NVL(c_OldDemand_rec.attribute3, k_VNULL),
8057 NVL(attribute3, k_VNULL)),
8058 NVL(attribute3, k_VNULL)))
8059 AND NVL(attribute4, k_VNULL) =
8060 DECODE(x_Group_rec.match_across_rec.attribute4, 'Y',
8061 NVL(c_OldDemand_rec.attribute4, k_VNULL),
8062 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y',
8063 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8064 NVL(c_OldDemand_rec.attribute4, k_VNULL),
8065 NVL(attribute4, k_VNULL)),
8066 NVL(attribute4, k_VNULL)))
8067 AND NVL(attribute5, k_VNULL) =
8068 DECODE(x_Group_rec.match_across_rec.attribute5, 'Y',
8069 NVL(c_OldDemand_rec.attribute5, k_VNULL),
8070 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y',
8071 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8072 NVL(c_OldDemand_rec.attribute5, k_VNULL),
8073 NVL(attribute5, k_VNULL)),
8074 NVL(attribute5, k_VNULL)))
8075 AND NVL(attribute6, k_VNULL) =
8076 DECODE(x_Group_rec.match_across_rec.attribute6, 'Y',
8077 NVL(c_OldDemand_rec.attribute6, k_VNULL),
8078 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y',
8079 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8080 NVL(c_OldDemand_rec.attribute6, k_VNULL),
8081 NVL(attribute6, k_VNULL)),
8082 NVL(attribute6, k_VNULL)))
8083 AND NVL(attribute7, k_VNULL) =
8084 DECODE(x_Group_rec.match_across_rec.attribute7, 'Y',
8085 NVL(c_OldDemand_rec.attribute7, k_VNULL),
8086 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y',
8087 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8088 NVL(c_OldDemand_rec.attribute7, k_VNULL),
8089 NVL(attribute7, k_VNULL)),
8090 NVL(attribute7, k_VNULL)))
8091 AND NVL(attribute8, k_VNULL) =
8092 DECODE(x_Group_rec.match_across_rec.attribute8, 'Y',
8093 NVL(c_OldDemand_rec.attribute8, k_VNULL),
8094 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y',
8095 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8096 NVL(c_OldDemand_rec.attribute8, k_VNULL),
8097 NVL(attribute8, k_VNULL)),
8098 NVL(attribute8, k_VNULL)))
8099 AND NVL(attribute9, k_VNULL) =
8100 DECODE(x_Group_rec.match_across_rec.attribute9, 'Y',
8101 NVL(c_OldDemand_rec.attribute9, k_VNULL),
8102 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y',
8103 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8104 NVL(c_OldDemand_rec.attribute9, k_VNULL),
8105 NVL(attribute9, k_VNULL)),
8106 NVL(attribute9, k_VNULL)))
8107 AND NVL(attribute10, k_VNULL) =
8108 DECODE(x_Group_rec.match_across_rec.attribute10, 'Y',
8109 NVL(c_OldDemand_rec.attribute10, k_VNULL),
8110 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y',
8111 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8112 NVL(c_OldDemand_rec.attribute10, k_VNULL),
8113 NVL(attribute10, k_VNULL)),
8114 NVL(attribute10, k_VNULL)))
8115 AND NVL(attribute11, k_VNULL) =
8116 DECODE(x_Group_rec.match_across_rec.attribute11, 'Y',
8117 NVL(c_OldDemand_rec.attribute11, k_VNULL),
8118 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y',
8119 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8120 NVL(c_OldDemand_rec.attribute11, k_VNULL),
8121 NVL(attribute11, k_VNULL)),
8122 NVL(attribute11, k_VNULL)))
8123 AND NVL(attribute12, k_VNULL) =
8124 DECODE(x_Group_rec.match_across_rec.attribute12, 'Y',
8125 NVL(c_OldDemand_rec.attribute12, k_VNULL),
8126 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y',
8127 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8128 NVL(c_OldDemand_rec.attribute12, k_VNULL),
8129 NVL(attribute12, k_VNULL)),
8130 NVL(attribute12, k_VNULL)))
8131 AND NVL(attribute13, k_VNULL) =
8132 DECODE(x_Group_rec.match_across_rec.attribute13, 'Y',
8133 NVL(c_OldDemand_rec.attribute13, k_VNULL),
8134 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y',
8135 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8136 NVL(c_OldDemand_rec.attribute13, k_VNULL),
8137 NVL(attribute13, k_VNULL)),
8138 NVL(attribute13, k_VNULL)))
8139 AND NVL(attribute14, k_VNULL) =
8140 DECODE(x_Group_rec.match_across_rec.attribute14, 'Y',
8141 NVL(c_OldDemand_rec.attribute14, k_VNULL),
8142 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y',
8143 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8144 NVL(c_OldDemand_rec.attribute14, k_VNULL),
8145 NVL(attribute14, k_VNULL)),
8146 NVL(attribute14, k_VNULL)))
8147 AND NVL(attribute15, k_VNULL) =
8148 DECODE(x_Group_rec.match_across_rec.attribute15, 'Y',
8149 NVL(c_OldDemand_rec.attribute15, k_VNULL),
8150 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y',
8151 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8152 NVL(c_OldDemand_rec.attribute15, k_VNULL),
8153 NVL(attribute15, k_VNULL)),
8154 NVL(attribute15, k_VNULL)));
8155
8156 /* We need the above query because we could have a case where the
8157 schedule date for both the lines are same but the item detail
8158 subtype is of less granularity in which case we will have
8159 to consume the old quantity, else replace.
8160 Also we do not need to check for non mandatory attributes
8161 in this case as they will be different */
8162 --
8163 v_consume_quantity := 0;
8164 --
8165 j := v_consume_line_tab.COUNT;
8166 --
8167 LOOP
8168 --
8169 FETCH c_consume_ref INTO v_line_id, v_qty;
8170 --
8171 EXIT WHEN c_consume_ref%NOTFOUND;
8172 --
8173 IF (l_debug <> -1) THEN
8174 rlm_core_sv.dlog(k_DEBUG,'consume_ref.v_line_id' , v_line_id);
8175 rlm_core_sv.dlog(k_DEBUG,'consume_ref.v_qty', v_qty);
8176 END IF;
8177 --
8178 IF isLineConsumable(v_consume_line_tab,v_line_id, v_index) THEN
8179 --
8180 j := j + 1;
8181 --
8182 IF c_OldDemand_rec.ordered_quantity >
8183 (v_consume_quantity + v_qty) THEN
8184 --
8185 IF (l_debug <> -1) THEN
8186 rlm_core_sv.dlog(k_DEBUG,'complete consumtion of qty' , v_qty);
8187 END IF;
8188 --
8189 v_consume_line_tab(j).quantity := v_qty;
8190 v_consume_line_tab(j).line_id := v_line_id;
8191 v_consume_quantity := v_consume_quantity + v_qty;
8192 --
8193 IF (l_debug <> -1) THEN
8194 rlm_core_sv.dlog(k_DEBUG,'v_consume_quantity',
8195 v_consume_quantity);
8196 END IF;
8197 --
8198 ELSE
8199 --
8200 v_qty := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8201 --
8202 IF (l_debug <> -1) THEN
8203 rlm_core_sv.dlog(k_DEBUG,'partial consumtion of qty', v_qty);
8204 rlm_core_sv.dlog(k_DEBUG,'partial consumtion of line',v_line_id);
8205 END IF;
8206 --
8207 v_consume_line_tab(j).quantity := v_qty;
8208 v_consume_line_tab(j).line_id := v_line_id;
8209 v_consume_quantity := v_consume_quantity + v_qty;
8210 --
8211 END IF;
8212 --
8213 IF (l_debug <> -1) THEN
8214 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(j).line_id',
8215 v_consume_line_tab(j).line_id);
8216 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(j).quantity',
8217 v_consume_line_tab(j).quantity);
8218 END IF;
8219 --
8220 ELSE
8221 --
8222 /* If the line is not consumable then we need to check if the line
8223 has been partially consumed in which case we need to consume
8224 the remaining qty */
8225 --
8226 IF (l_debug <> -1) THEN
8227 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Index).line_id',
8228 v_consume_line_tab(v_Index).line_id);
8229 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Index).quantity',
8230 v_consume_line_tab(v_Index).quantity);
8231 rlm_core_sv.dlog(k_DEBUG,'quantity for current line v_qty',v_qty);
8232 END IF;
8233 --
8234 IF v_consume_line_tab(v_Index).quantity <> v_qty THEN
8235 --
8236 /* This will ocur when there is partial consumption so
8237 we need to take into account only the difference between the
8238 two quantities */
8239 --
8240 IF (l_debug <> -1) THEN
8241 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line', v_line_id);
8242 END IF;
8243 --
8244 v_qty := v_qty - v_consume_line_tab(v_Index).quantity;
8245 --
8246 IF (l_debug <> -1) THEN
8247 rlm_core_sv.dlog(k_DEBUG,'v_qty',v_qty);
8248 END IF;
8249 --
8250 IF c_OldDemand_rec.ordered_quantity >
8251 (v_consume_quantity + v_qty) THEN
8252 --
8253 IF (l_debug <> -1) THEN
8254 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8255 completely', v_line_id);
8256 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8257 completely qty ', v_qty);
8258 END IF;
8259 --
8260 v_consume_line_tab(v_index).quantity :=
8261 v_consume_line_tab(v_index).quantity + v_qty;
8262 v_consume_quantity := v_consume_quantity + v_qty;
8263 --
8264 ELSE
8265 --
8266 v_qty := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8267 --
8268 IF (l_debug <> -1) THEN
8269 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8270 again partially',v_line_id);
8271 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8272 again partially qty ', v_qty);
8273 END IF;
8274 --
8275 v_consume_line_tab(v_index).quantity :=
8276 v_consume_line_tab(v_index).quantity + v_qty;
8277 v_consume_quantity := v_consume_quantity + v_qty;
8278 --
8279 END IF;
8280 --
8281 END IF;
8282 --
8283 END IF;
8284 --
8285 END LOOP;
8286 --
8287 IF (l_debug <> -1) THEN
8288 rlm_core_sv.dlog(k_DEBUG,'Total quantity to be consumed ',
8289 v_consume_quantity);
8290 END IF;
8291 --
8292 IF c_consume_ref%ROWCOUNT = 0 THEN
8293 -- If the rowcount is = 0 means that there are no lines to be consumed
8294 -- If the rowcount is = 0 means that there are no lines to be consumed
8295 -- so the old line needs to be deleted
8296 --
8297 IF (l_debug <> -1) THEN
8298 rlm_core_sv.dlog(k_DEBUG,'in rowcount = 0');
8299 rlm_core_sv.dlog(k_DEBUG,'No lines came into the
8300 schedule to be consumed so keep line as it is');
8301 END IF;
8302 --
8303 ELSIF v_consume_quantity > 0 THEN
8304 --
8305 v_Key_rec.oe_line_id := c_OldDemand_rec.line_id;
8306 --
8307 IF (l_debug <> -1) THEN
8308 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',v_Key_rec.oe_line_id);
8309 END IF;
8310 --
8311 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
8312 --
8313 v_Key_rec.req_rec := v_Key_rec.dem_rec;
8314 --
8315 v_quantity := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8316 --
8317 IF (l_debug <> -1) THEN
8318 rlm_core_sv.dlog(k_DEBUG,'v_quantity',v_quantity);
8319 END IF;
8320 --
8321 IF v_quantity = 0 THEN
8322 --
8323 DeleteRequirement(x_Sched_rec, x_Group_rec, v_Key_rec,
8324 k_RECONCILE, v_DeleteQty);
8325 --
8326 ELSE
8327 --
8328 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
8329 --
8330 IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec,
8331 v_Key_rec.dem_rec.request_date) OR
8332 IsFrozen(TRUNC(SYSDATE), x_Group_rec, v_Key_rec.req_rec.request_date))
8333 AND NOT ProcessConstraint(v_Key_rec,v_Qty_rec,k_UPDATE,v_Quantity) THEN
8334 --
8335 IF (l_debug <> -1) THEN
8336 rlm_core_sv.dlog(k_DEBUG,'v_quantity',v_quantity);
8337 END IF;
8338 --
8339 --global_atp
8340 UpdateRequirement(x_Sched_rec, x_Group_rec, v_Key_rec,
8341 v_quantity);
8342 --
8343 ELSE
8344 -- irreconcileable differences
8345 --
8346 StoreReconcile(x_Sched_rec, x_Group_rec, v_Key_rec,
8347 v_consume_quantity);
8348 --
8349 END IF;
8350 --
8351 END IF;
8352 --
8353 END IF;
8354 --
8355 END IF;
8356 --
8357 ELSE
8358 --
8359 /* We add this new line to the consume tab so that these lines should not
8360 be considered for consumption later on.
8361 WE have added the difference between the New ref qty and what was
8362 there earlier. Hence we find that if this consume_line_tab.quantity
8363 > 0 then we should consume */
8364 --
8365 v_Count := v_consume_line_tab.COUNT + 1;
8366 --
8367 v_consume_line_tab(v_Count).line_id := v_Newref_line_id;
8368 v_consume_line_tab(v_Count).quantity := c_OldDemand_rec.ordered_quantity;
8369 --
8370 IF (l_debug <> -1) THEN
8371 rlm_core_sv.dlog(k_DEBUG,'new line addede to the consume tab');
8372 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Count).line_id',
8373 v_consume_line_tab(v_Count).line_id);
8374 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Count).quantity',
8375 v_consume_line_tab(v_Count).quantity);
8376 END IF;
8377 --
8378 END IF;
8379 --
8380 CLOSE c_NewReq_ref;
8381
8382 EXCEPTION
8383 --
8384 WHEN e_WrongSchedType THEN
8385 --
8386 SELECT line_number INTO v_line_num
8387 FROM oe_order_lines
8388 WHERE line_id = c_OldDemand_rec.line_id;
8389 --
8390 IF (l_debug <> -1) THEN
8391 rlm_core_sv.dlog(k_DEBUG,'line_id', c_OldDemand_rec.line_id);
8392 rlm_core_sv.dlog(k_DEBUG,'rla_schedule_type_code',
8393 c_OldDemand_rec.rla_schedule_type_code);
8394 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_type',
8395 x_Sched_rec.schedule_type);
8396 rlm_core_sv.dlog(k_DEBUG,'line_number', v_line_num);
8397 rlm_core_sv.dlog(k_DEBUG,'RLM_WRONG_SCHEDTYPE');
8398 END IF;
8399 --
8400 rlm_message_sv.app_error(
8401 x_ExceptionLevel => rlm_message_sv.k_warn_level,
8402 x_MessageName => 'RLM_WRONG_SCHEDTYPE',
8403 x_InterfaceHeaderId => x_sched_rec.header_id,
8404 x_InterfaceLineId => NULL,
8405 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
8406 x_ScheduleLineId => NULL,
8407 x_OrderHeaderId => x_Group_rec.order_header_id,
8408 x_OrderLineId => c_OldDemand_rec.line_id,
8409 x_Token1 => 'LINENUM',
8410 x_value1 => v_line_num,
8411 x_Token2 => 'SCHEDTYPE',
8412 x_value2 => c_OldDemand_rec.rla_schedule_type_code );
8413 --
8414 END;
8415 --
8416 FETCH c_OldDemand INTO c_OldDemand_rec;
8417 --
8418 END LOOP;
8419 CLOSE c_OldDemand; --bug 4570658
8420 --
8421 IF (l_debug <> -1) THEN
8422 rlm_core_sv.dpop(k_SDEBUG);
8423 END IF;
8424 --
8425 EXCEPTION
8426
8427 WHEN e_group_error THEN
8428 --
8429 IF (l_debug <> -1) THEN
8430 rlm_core_sv.dlog(k_DEBUG,'group error');
8431 rlm_core_sv.dpop(k_SDEBUG);
8432 END IF;
8433 --
8434 raise e_group_error;
8435
8436 WHEN OTHERS THEN
8437 rlm_message_sv.sql_error('rlm_rd_sv.ProcessOld',x_progress);
8438 --
8439 IF (l_debug <> -1) THEN
8440 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8441 END IF;
8442 --
8443 raise;
8444
8445 END ProcessOld;
8446
8447
8448 /*===========================================================================
8449
8450 FUNCTION FetchReq
8451
8452 ===========================================================================*/
8453 FUNCTION FetchReq(x_Req_ref IN OUT NOCOPY t_Cursor_ref,
8454 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
8455 x_oe_line_id OUT NOCOPY NUMBER,
8456 x_SumOrderedQty OUT NOCOPY NUMBER,
8457 x_ScheduleType OUT NOCOPY VARCHAR2)
8458 RETURN BOOLEAN
8459 IS
8460 x_progress VARCHAR2(3) := '010';
8461
8462 BEGIN
8463 --
8464 IF (l_debug <> -1) THEN
8465 rlm_core_sv.dpush(k_SDEBUG,'FetchReq');
8466 END IF;
8467 --
8468 FETCH x_Req_Ref INTO
8469 x_oe_line_id,
8470 x_SumOrderedQty,
8471 x_ScheduleType, -- existing schedule_type
8472 x_Key_rec.req_rec.customer_id,
8473 x_Key_rec.req_rec.header_id,
8474 x_Key_rec.req_rec.line_id,
8475 x_Key_rec.req_rec.cust_production_line,
8476 x_Key_rec.req_rec.customer_dock_code,
8477 x_Key_rec.req_rec.request_date,
8478 x_Key_rec.req_rec.schedule_date,
8479 x_Key_rec.req_rec.cust_po_number,
8480 x_Key_rec.req_rec.customer_item_revision,
8481 x_Key_rec.req_rec.customer_job,
8482 x_Key_rec.req_rec.cust_model_serial_number,
8483 x_Key_rec.req_rec.cust_production_seq_num,
8484 x_Key_rec.req_rec.industry_attribute1,
8485 x_Key_rec.req_rec.industry_attribute2,
8486 x_Key_rec.req_rec.industry_attribute3,
8487 x_Key_rec.req_rec.industry_attribute4,
8488 x_Key_rec.req_rec.industry_attribute5,
8489 x_Key_rec.req_rec.industry_attribute6,
8490 x_Key_rec.req_rec.industry_attribute7,
8491 x_Key_rec.req_rec.industry_attribute8,
8492 x_Key_rec.req_rec.industry_attribute9,
8493 x_Key_rec.req_rec.industry_attribute10,
8494 x_Key_rec.req_rec.industry_attribute11,
8495 x_Key_rec.req_rec.industry_attribute12,
8496 x_Key_rec.req_rec.industry_attribute13,
8497 x_Key_rec.req_rec.industry_attribute14,
8498 x_Key_rec.req_rec.industry_attribute15,
8499 x_Key_rec.req_rec.industry_context,
8500 x_Key_rec.req_rec.attribute1,
8501 x_Key_rec.req_rec.attribute2,
8502 x_Key_rec.req_rec.attribute3,
8503 x_Key_rec.req_rec.attribute4,
8504 x_Key_rec.req_rec.attribute5,
8505 x_Key_rec.req_rec.attribute6,
8506 x_Key_rec.req_rec.attribute7,
8507 x_Key_rec.req_rec.attribute8,
8508 x_Key_rec.req_rec.attribute9,
8509 x_Key_rec.req_rec.attribute10,
8510 x_Key_rec.req_rec.attribute11,
8511 x_Key_rec.req_rec.attribute12,
8512 x_Key_rec.req_rec.attribute13,
8513 x_Key_rec.req_rec.attribute14,
8514 x_Key_rec.req_rec.attribute15,
8515 x_Key_rec.req_rec.attribute_category,
8516 x_Key_rec.req_rec.tp_attribute1,
8517 x_Key_rec.req_rec.tp_attribute2,
8518 x_Key_rec.req_rec.tp_attribute3,
8519 x_Key_rec.req_rec.tp_attribute4,
8520 x_Key_rec.req_rec.tp_attribute5,
8521 x_Key_rec.req_rec.tp_attribute6,
8522 x_Key_rec.req_rec.tp_attribute7,
8523 x_Key_rec.req_rec.tp_attribute8,
8524 x_Key_rec.req_rec.tp_attribute9,
8525 x_Key_rec.req_rec.tp_attribute10,
8526 x_Key_rec.req_rec.tp_attribute11,
8527 x_Key_rec.req_rec.tp_attribute12,
8528 x_Key_rec.req_rec.tp_attribute13,
8529 x_Key_rec.req_rec.tp_attribute14,
8530 x_Key_rec.req_rec.tp_attribute15,
8531 x_Key_rec.req_rec.tp_attribute_category,
8532 x_Key_rec.req_rec.item_detail_type,
8533 x_Key_rec.req_rec.item_detail_subtype,
8534 x_Key_rec.req_rec.intrmd_ship_to_id,
8535 x_Key_rec.req_rec.ship_to_org_id,
8536 x_Key_rec.req_rec.invoice_to_org_id,
8537 x_Key_rec.req_rec.primary_quantity,
8538 x_Key_rec.req_rec.intmed_ship_to_org_id,
8539 x_Key_rec.req_rec.customer_item_id,
8540 x_Key_rec.req_rec.inventory_item_id,
8541 x_Key_rec.req_rec.order_header_id,
8542 x_Key_rec.req_rec.authorized_to_ship_flag,
8543 x_Key_rec.req_rec.ship_from_org_id,
8544 x_Key_rec.req_rec.schedule_type, --incoming
8545 x_Key_rec.req_rec.item_identifier_type,
8546 x_Key_rec.req_rec.customer_item_ext,
8547 x_Key_rec.req_rec.agreement_id,
8548 x_Key_rec.req_rec.price_list_id,
8549 x_Key_rec.req_rec.schedule_header_id,
8550 x_Key_rec.req_rec.schedule_line_id,
8551 x_Key_rec.req_rec.process_status,
8552 x_Key_rec.req_rec.uom_code,
8553 x_Key_rec.req_rec.cust_po_line_num,
8554 x_Key_rec.req_rec.blanket_number;
8555
8556 --
8557 IF (l_debug <> -1) THEN
8558 rlm_core_sv.dlog(k_DEBUG, 'after fetch');
8559 END IF;
8560 --
8561 IF x_Req_ref%NOTFOUND THEN
8562 --
8563 IF (l_debug <> -1) THEN
8564 rlm_core_sv.dpop(k_SDEBUG, 'false');
8565 END IF;
8566 --
8567 RETURN(FALSE);
8568 --
8569 ELSE
8570 --
8571 IF (l_debug <> -1) THEN
8572 rlm_core_sv.dpop(k_SDEBUG, 'true');
8573 END IF;
8574 --
8575 RETURN(TRUE);
8576 --
8577 END IF;
8578 --
8579 EXCEPTION
8580 WHEN OTHERS THEN
8581 rlm_message_sv.sql_error('rlm_rd_sv.FetchReq',x_progress);
8582 --
8583 IF (l_debug <> -1) THEN
8584 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8585 END IF;
8586 --
8587 raise;
8588
8589 END FetchReq;
8590
8591
8592 /*===========================================================================
8593
8594 FUNCTION FetchDemand
8595
8596 ===========================================================================*/
8597 FUNCTION FetchDemand(x_Demand_ref IN OUT NOCOPY t_Cursor_ref,
8598 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec)
8599 RETURN BOOLEAN
8600 IS
8601 x_progress VARCHAR2(3) := '010';
8602
8603 BEGIN
8604 --
8605 IF (l_debug <> -1) THEN
8606 rlm_core_sv.dpush(k_SDEBUG,'FetchDemand');
8607 END IF;
8608 --
8609 FETCH x_Demand_ref INTO
8610 x_Key_rec.dem_rec.line_id,
8611 x_Key_rec.dem_rec.ordered_quantity,
8612 x_Key_rec.dem_rec.shipped_quantity,
8613 x_Key_rec.dem_rec.customer_id,
8614 x_Key_rec.dem_rec.cust_production_line,
8615 x_Key_rec.dem_rec.customer_dock_code,
8616 x_Key_rec.dem_rec.request_date,
8617 x_Key_rec.dem_rec.schedule_date,
8618 x_Key_rec.dem_rec.cust_po_number,
8619 x_Key_rec.dem_rec.customer_item_revision,
8620 x_Key_rec.dem_rec.customer_job,
8621 x_Key_rec.dem_rec.cust_model_serial_number,
8622 x_Key_rec.dem_rec.cust_production_seq_num,
8623 x_Key_rec.dem_rec.industry_attribute1,
8624 x_Key_rec.dem_rec.industry_attribute2,
8625 x_Key_rec.dem_rec.industry_attribute3,
8626 x_Key_rec.dem_rec.industry_attribute4,
8627 x_Key_rec.dem_rec.industry_attribute5,
8628 x_Key_rec.dem_rec.industry_attribute6,
8629 x_Key_rec.dem_rec.industry_attribute7,
8630 x_Key_rec.dem_rec.industry_attribute8,
8631 x_Key_rec.dem_rec.industry_attribute9,
8632 x_Key_rec.dem_rec.industry_attribute10,
8633 x_Key_rec.dem_rec.industry_attribute11,
8634 x_Key_rec.dem_rec.industry_attribute12,
8635 x_Key_rec.dem_rec.industry_attribute13,
8636 x_Key_rec.dem_rec.industry_attribute14,
8637 x_Key_rec.dem_rec.industry_attribute15,
8638 x_Key_rec.dem_rec.industry_context,
8639 x_Key_rec.dem_rec.attribute1,
8640 x_Key_rec.dem_rec.attribute2,
8641 x_Key_rec.dem_rec.attribute3,
8642 x_Key_rec.dem_rec.attribute4,
8643 x_Key_rec.dem_rec.attribute5,
8644 x_Key_rec.dem_rec.attribute6,
8645 x_Key_rec.dem_rec.attribute7,
8646 x_Key_rec.dem_rec.attribute8,
8647 x_Key_rec.dem_rec.attribute9,
8648 x_Key_rec.dem_rec.attribute10,
8649 x_Key_rec.dem_rec.attribute11,
8650 x_Key_rec.dem_rec.attribute12,
8651 x_Key_rec.dem_rec.attribute13,
8652 x_Key_rec.dem_rec.attribute14,
8653 x_Key_rec.dem_rec.attribute15,
8654 x_Key_rec.dem_rec.attribute_category,
8655 x_Key_rec.dem_rec.tp_attribute1,
8656 x_Key_rec.dem_rec.tp_attribute2,
8657 x_Key_rec.dem_rec.tp_attribute3,
8658 x_Key_rec.dem_rec.tp_attribute4,
8659 x_Key_rec.dem_rec.tp_attribute5,
8660 x_Key_rec.dem_rec.tp_attribute6,
8661 x_Key_rec.dem_rec.tp_attribute7,
8662 x_Key_rec.dem_rec.tp_attribute8,
8663 x_Key_rec.dem_rec.tp_attribute9,
8664 x_Key_rec.dem_rec.tp_attribute10,
8665 x_Key_rec.dem_rec.tp_attribute11,
8666 x_Key_rec.dem_rec.tp_attribute12,
8667 x_Key_rec.dem_rec.tp_attribute13,
8668 x_Key_rec.dem_rec.tp_attribute14,
8669 x_Key_rec.dem_rec.tp_attribute15,
8670 x_Key_rec.dem_rec.tp_attribute_category,
8671 x_Key_rec.dem_rec.item_detail_subtype,
8672 x_Key_rec.dem_rec.item_detail_type,
8673 x_Key_rec.dem_rec.ship_to_org_id,
8674 x_Key_rec.dem_rec.invoice_to_org_id,
8675 x_Key_rec.dem_rec.intmed_ship_to_org_id,
8676 x_Key_rec.dem_rec.customer_item_id,
8677 x_Key_rec.dem_rec.inventory_item_id,
8678 x_Key_rec.dem_rec.order_header_id,
8679 x_Key_rec.dem_rec.ship_from_org_id,
8680 x_Key_rec.dem_rec.schedule_type,
8681 x_Key_rec.dem_rec.authorized_to_ship_flag,
8682 x_Key_rec.dem_rec.item_identifier_type,
8683 x_Key_rec.dem_rec.agreement_id,
8684 x_Key_rec.dem_rec.price_list_id,
8685 x_Key_rec.dem_rec.customer_item_ext,
8686 x_key_rec.dem_rec.uom_code,
8687 x_Key_rec.dem_rec.blanket_number;
8688 --
8689 IF x_Demand_ref%NOTFOUND THEN
8690 --
8691 IF (l_debug <> -1) THEN
8692 rlm_core_sv.dpop(k_SDEBUG, 'false');
8693 END IF;
8694 --
8695 RETURN(FALSE);
8696 --
8697 ELSE
8698 --
8699 IF (l_debug <> -1) THEN
8700 rlm_core_sv.dpop(k_SDEBUG, 'true');
8701 END IF;
8702 --
8703 RETURN(TRUE);
8704 --
8705 END IF;
8706
8707 EXCEPTION
8708 WHEN OTHERS THEN
8709 rlm_message_sv.sql_error('rlm_rd_sv.FetchDemand',x_progress);
8710 --
8711 IF (l_debug <> -1) THEN
8712 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8713 END IF;
8714 --
8715 raise;
8716
8717 END FetchDemand;
8718
8719
8720 /*===========================================================================
8721
8722 FUNCTION SchedulePrecedence
8723
8724 ===========================================================================*/
8725 FUNCTION SchedulePrecedence(x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
8726 x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
8727 x_ScheduleType IN VARCHAR2)
8728 RETURN BOOLEAN
8729 IS
8730 v_cannot_replace NUMBER;
8731 x_progress VARCHAR2(3) := '010';
8732 BEGIN
8733 --
8734 IF (l_debug <> -1) THEN
8735 rlm_core_sv.dpush(k_SDEBUG,'SchedulePrecedence');
8736 rlm_core_sv.dlog(k_DEBUG,'x_ScheduleType', x_ScheduleType);
8737 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_one', x_group_rec.schedule_type_one);
8738 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_two', x_group_rec.schedule_type_two);
8739 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_three', x_group_rec.schedule_type_three);
8740 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.schedule_type', x_sched_rec.schedule_type);
8741 END IF;
8742 --
8743 -- If the given schedule line is less in hierarchy than the oe line
8744 -- schedule line then return false else return true
8745 --
8746 SELECT DECODE(x_ScheduleType,x_group_rec.schedule_type_one,1,
8747 x_group_rec.schedule_type_two,2,
8748 x_group_rec.schedule_type_three,3) -
8749 DECODE(x_Sched_rec.schedule_type,x_group_rec.schedule_type_one,1,
8750 x_group_rec.schedule_type_two,2,
8751 x_group_rec.schedule_type_three,3)
8752 INTO v_cannot_replace
8753 FROM dual;
8754 --
8755 IF (l_debug <> -1) THEN
8756 rlm_core_sv.dlog(k_DEBUG,'v_cannot_replace', v_cannot_replace);
8757 END IF;
8758 --
8759 IF v_cannot_replace <= 0 THEN
8760 --
8761 IF (l_debug <> -1) THEN
8762 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
8763 END IF;
8764 --
8765 RETURN TRUE;
8766 --
8767 ELSE
8768 --
8769 IF (l_debug <> -1) THEN
8770 rlm_core_sv.dpop(k_SDEBUG, 'false');
8771 END IF;
8772 --
8773 RETURN FALSE;
8774 --
8775 END IF;
8776
8777 EXCEPTION
8778 WHEN OTHERS THEN
8779 rlm_message_sv.sql_error('rlm_rd_sv.SchedulePrecedence',x_progress);
8780 --
8781 IF (l_debug <> -1) THEN
8782 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8783 END IF;
8784 --
8785 raise;
8786
8787 END SchedulePrecedence;
8788
8789
8790 PROCEDURE CountMatchedDemand(x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
8791 x_key_rec IN RLM_RD_SV.t_Key_rec,
8792 x_rlm_line_id IN NUMBER,
8793 x_oe_line_id IN NUMBER,
8794 x_DemandCount IN OUT NOCOPY NUMBER,
8795 x_SumOrderedQty IN OUT NOCOPY NUMBER,
8796 x_SumOrderedQtyTmp IN OUT NOCOPY NUMBER)
8797 IS
8798 x_progress VARCHAR2(3) := '010';
8799 BEGIN
8800 --
8801 IF (l_debug <> -1) THEN
8802 rlm_core_sv.dpush(k_SDEBUG,'CountMatchedDemand');
8803 rlm_core_sv.dlog(k_DEBUG, 'Matched Demand Counter', x_DemandCount);
8804 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', x_rlm_line_id);
8805 rlm_core_sv.dlog(k_DEBUG, 'OM Line Id', x_oe_line_id);
8806 rlm_core_sv.dlog(k_DEBUG, 'x_SumOrderedQtyTmp', x_SumOrderedQtyTmp);
8807 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_type',
8808 x_Sched_rec.schedule_type);
8809 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.item_detail_subtype',
8810 x_Key_rec.req_rec.item_detail_subtype);
8811 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.invoice_to_org_id',
8812 x_Key_rec.req_rec.invoice_to_org_id);
8813 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.ship_to_org_id',
8814 x_Key_rec.req_rec.ship_to_org_id);
8815 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.intmed_ship_to_org_id',
8816 x_key_rec.req_rec.intmed_ship_to_org_id);
8817 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_line',
8818 x_key_rec.req_rec.cust_production_line);
8819 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_seq_num',
8820 x_key_rec.req_rec.cust_production_seq_num);
8821 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
8822 x_key_rec.req_rec.primary_quantity);
8823 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_line',
8824 x_key_rec.req_rec.cust_production_line);
8825 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
8826 x_key_rec.req_rec.primary_quantity);
8827 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_item_revision',
8828 x_key_rec.req_rec.customer_item_revision);
8829 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_job',
8830 x_key_rec.req_rec.customer_job);
8831 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_po_number',
8832 x_key_rec.req_rec.cust_po_number);
8833 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_dock_code',
8834 x_key_rec.req_rec.customer_dock_code);
8835 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_model_serial_number',
8836 x_key_rec.req_rec.cust_model_serial_number);
8837 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.request_date',
8838 x_key_rec.req_rec.request_date);
8839 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.schedule_date',
8840 x_key_rec.req_rec.schedule_date);
8841 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_purpose',
8842 x_Sched_rec.schedule_purpose);
8843 END IF;
8844 --
8845 x_SumOrderedQty := x_SumOrderedQty + x_SumOrderedQtyTmp;
8846 --
8847 x_DemandCount := x_DemandCount + 1;
8848 --
8849 IF (l_debug <> -1) THEN
8850 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty',x_SumOrderedQty);
8851 rlm_core_sv.dlog(k_DEBUG,'x_DemandCount',x_DemandCount);
8852 rlm_core_sv.dpop(k_SDEBUG);
8853 END IF;
8854 --
8855 EXCEPTION
8856
8857 WHEN e_group_error THEN
8858 --
8859 IF (l_debug <> -1) THEN
8860 rlm_core_sv.dlog(k_DEBUG,'group error');
8861 rlm_core_sv.dpop(k_SDEBUG);
8862 END IF;
8863 --
8864 raise e_group_error;
8865
8866 WHEN OTHERS THEN
8867 rlm_message_sv.sql_error('rlm_rd_sv.CountMatchedDemand',x_progress);
8868 --
8869 IF (l_debug <> -1) THEN
8870 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8871 END IF;
8872 --
8873 raise;
8874
8875 END CountMatchedDemand;
8876
8877
8878 PROCEDURE ReconcileAction(x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
8879 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
8880 x_key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
8881 x_line_id_tab IN RLM_RD_SV.t_matching_line,
8882 x_DemandCount IN NUMBER,
8883 x_SumOrderedQty IN NUMBER,
8884 x_DemandType IN VARCHAR2)
8885 IS
8886 x_progress VARCHAR2(3) := '010';
8887 BEGIN
8888 --
8889 IF (l_debug <> -1) THEN
8890 rlm_core_sv.dpush(k_SDEBUG, 'ReconcileAction');
8891 END IF;
8892 --
8893 IF (x_DemandCount > 0) AND (NOT AlreadyUpdated(x_line_id_tab)) THEN
8894 --
8895 IF x_Sched_rec.schedule_purpose IN (k_DELETE, k_CANCEL) THEN
8896 --
8897 IF (l_debug <> -1) THEN
8898 rlm_core_sv.dlog(k_DEBUG,'Deleting requirement due to purpose code of '
8899 ,x_Sched_rec.schedule_purpose);
8900 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
8901 x_key_rec.req_rec.primary_quantity);
8902 END IF;
8903 --
8904 x_key_rec.req_rec.primary_quantity := x_SumOrderedQty -
8905 x_key_rec.req_rec.primary_quantity;
8906 --
8907 IF (l_debug <> -1) THEN
8908 rlm_core_sv.dlog(k_DEBUG,'new x_key_rec.req_rec.primary_quantity',
8909 x_key_rec.req_rec.primary_quantity);
8910 END IF;
8911 --
8912 ELSIF x_Sched_rec.schedule_purpose = k_ADD THEN
8913 --
8914 IF (l_debug <> -1) THEN
8915 rlm_core_sv.dlog(k_DEBUG,'Adding requirement due to purpose code of ',
8916 x_Sched_rec.schedule_purpose);
8917 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
8918 x_key_rec.req_rec.primary_quantity);
8919 END IF;
8920 --
8921 x_key_rec.req_rec.primary_quantity := x_SumOrderedQty +
8922 x_key_rec.req_rec.primary_quantity;
8923 --
8924 IF (l_debug <> -1) THEN
8925 rlm_core_sv.dlog(k_DEBUG,'new x_key_rec.req_rec.primary_quantity',
8926 x_key_rec.req_rec.primary_quantity);
8927 END IF;
8928 --
8929 END IF;
8930 --
8931 RLM_TPA_SV.UpdateDemand(x_Sched_rec, x_Group_rec, x_Key_rec,
8932 x_SumOrderedQty, x_DemandType);
8933 --
8934 -- this means that the req was not matched in OE so we should
8935 -- only insert the new requirement
8936 ELSIF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
8937 --
8938 IF (l_debug <> -1) THEN
8939 rlm_core_sv.dlog(k_DEBUG,'insert x_key_rec.req_rec.primary_quantity',
8940 x_key_rec.req_rec.primary_quantity);
8941 END IF;
8942 --
8943 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
8944 x_Key_rec, k_RECONCILE,
8945 x_Key_rec.req_rec.primary_quantity);
8946 --
8947 END IF;
8948 --
8949 IF (l_debug <> -1) THEN
8950 rlm_core_sv.dpop(k_SDEBUG);
8951 END IF;
8952 --
8953 EXCEPTION
8954
8955 WHEN e_group_error THEN
8956 --
8957 IF (l_debug <> -1) THEN
8958 rlm_core_sv.dlog(k_DEBUG,'group error');
8959 rlm_core_sv.dpop(k_SDEBUG);
8960 END IF;
8961 --
8962 raise e_group_error;
8963
8964 WHEN OTHERS THEN
8965 rlm_message_sv.sql_error('rlm_rd_sv.ReconcileAction',x_progress);
8966 --
8967 IF (l_debug <> -1) THEN
8968 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8969 END IF;
8970 --
8971 raise;
8972
8973 END ReconcileAction;
8974
8975
8976 /* ============================================================================================
8977
8978 Procedure BuildMatchQuery
8979
8980 The following is the order of WHERE clause for each SQL
8981 x_Sql => uses v_where_clause1, v_where_clause2, w_where_clause1, v_where_clause1, v_where_clause2
8982 x_Sql1 => uses v_where_clause1, v_where_clause2
8983 x_Sql2 => uses w_where_clause1, v_where_clause1, v_where_clause2
8984
8985 ProcessATS calls BuildMatchQuery with the following parameter mapping
8986 v_ATSDemand => x_Sql
8987 v_NATSDemand => x_Sql1
8988 v_SumDemand => x_Sum_Sql
8989 v_NewDemand => x_Sql2
8990
8991 ProcessNATS calls BuildMatchQuery with the following parameter mapping
8992 v_ATSDemand => x_Sql1
8993 v_NATSDemand => x_Sql
8994 v_SumDemand => x_Sum_Sql
8995 v_NewDemand => x_Sql2
8996
8997 =============================================================================================== */
8998
8999 PROCEDURE BuildMatchQuery(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
9000 x_Group_Rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
9001 x_Demand_Type IN VARCHAR2,
9002 x_Sql OUT NOCOPY VARCHAR2,
9003 x_Sql1 OUT NOCOPY VARCHAR2,
9004 x_Sql2 OUT NOCOPY VARCHAR2,
9005 x_Sum_Sql OUT NOCOPY VARCHAR2)
9006 IS
9007 --
9008 x_progress VARCHAR2(3) := '010';
9009 v_Select_Clause VARCHAR2(32000);
9010 w_Select_Clause1 VARCHAR2(32000);
9011 w_Select_Clause2 VARCHAR2(32000);
9012 v_Where_Clause1 VARCHAR2(32000);
9013 w_Where_Clause1 VARCHAR2(32000);
9014 v_Where_Clause2 VARCHAR2(32000);
9015 v_Order_Clause VARCHAR2(5000);
9016 v_sum_clause VARCHAR2(32000);
9017 v_ATSWhere VARCHAR2(5000);
9018 v_NATSWhere VARCHAR2(5000);
9019 v_Date DATE;
9020 --
9021 BEGIN
9022 --
9023 IF (l_debug <> -1) THEN
9024 rlm_core_sv.dpush(k_SDEBUG, 'BuildMatchQuery');
9025 rlm_core_sv.dlog(k_DEBUG, 'Disposition Code', x_Group_rec.disposition_code);
9026 END IF;
9027
9028 v_select_clause :=
9029
9030 'SELECT o.line_id,(NVL(o.ordered_quantity,0)-NVL(o.shipped_quantity,0)),'||
9031 'o.rla_schedule_type_code,'|| x_group_rec.customer_id ||
9032 ',r.header_id interface_header_id, r.line_id interface_line_id,'||
9033 'r.cust_production_line,r.customer_dock_code,r.request_date,'||
9034 'r.schedule_date,r.cust_po_number,r.customer_item_revision,'||
9035 'r.customer_job,r.cust_model_serial_number,r.cust_production_seq_num,'||
9036 'r.industry_attribute1,r.industry_attribute2,r.industry_attribute3,'||
9037 'r.industry_attribute4,r.industry_attribute5,r.industry_attribute6,'||
9038 'r.industry_attribute7,r.industry_attribute8,r.industry_attribute9,'||
9039 'r.industry_attribute10,r.industry_attribute11,r.industry_attribute12,'||
9040 'r.industry_attribute13,r.industry_attribute14,r.industry_attribute15,'||
9041 'r.industry_context,r.attribute1,r.attribute2,r.attribute3,'||
9042 'r.attribute4,r.attribute5,r.attribute6,r.attribute7,r.attribute8,'||
9043 'r.attribute9,r.attribute10,r.attribute11,r.attribute12,r.attribute13,'||
9044 'r.attribute14,r.attribute15,r.attribute_category,r.tp_attribute1,'||
9045 'r.tp_attribute2,r.tp_attribute3,r.tp_attribute4,r.tp_attribute5,'||
9046 'r.tp_attribute6,r.tp_attribute7,r.tp_attribute8,r.tp_attribute9,'||
9047 'r.tp_attribute10,r.tp_attribute11,r.tp_attribute12,r.tp_attribute13,'||
9048 'r.tp_attribute14,r.tp_attribute15,r.tp_attribute_category,'||
9049 'r.item_detail_type,r.item_detail_subtype,r.intrmd_ship_to_id,'||
9050 'r.ship_to_org_id,r.invoice_to_org_id,r.primary_quantity,'||
9051 'r.intmed_ship_to_org_id,r.customer_item_id,r.inventory_item_id,'||
9052 'r.order_header_id,o.authorized_to_ship_flag,r.ship_from_org_id,''' ||
9053 x_sched_rec.schedule_type ||''',''CUST'' item_identifier_type,'||
9054 'r.customer_item_ext,r.agreement_id,r.price_list_id,'||
9055 x_Sched_rec.schedule_header_id ||
9056 ',r.schedule_line_id,r.process_status,r.uom_code,r.cust_po_line_num,r.blanket_number ' ||
9057 'FROM oe_order_lines_all o,rlm_interface_lines r ';
9058
9059 w_Select_Clause1 :=
9060
9061 'SELECT TO_NUMBER(NULL),TO_NUMBER(NULL),TO_CHAR(NULL),'||
9062 x_group_rec.customer_id ||
9063 ',r1.header_id interface_header_id, r1.line_id interface_line_id,'||
9064 'r1.cust_production_line,r1.customer_dock_code,r1.request_date,'||
9065 'r1.schedule_date,r1.cust_po_number,r1.customer_item_revision,'||
9066 'r1.customer_job,r1.cust_model_serial_number,r1.cust_production_seq_num,'||
9067 'r1.industry_attribute1,r1.industry_attribute2,r1.industry_attribute3,'||
9068 'r1.industry_attribute4,r1.industry_attribute5,r1.industry_attribute6,'||
9069 'r1.industry_attribute7,r1.industry_attribute8,r1.industry_attribute9,'||
9070 'r1.industry_attribute10,r1.industry_attribute11,r1.industry_attribute12,'||
9071 'r1.industry_attribute13,r1.industry_attribute14,r1.industry_attribute15,'||
9072 'r1.industry_context,r1.attribute1,r1.attribute2,r1.attribute3,'||
9073 'r1.attribute4,r1.attribute5,r1.attribute6,r1.attribute7,r1.attribute8,'||
9074 'r1.attribute9,r1.attribute10,r1.attribute11,r1.attribute12,r1.attribute13,'||
9075 'r1.attribute14,r1.attribute15,r1.attribute_category,r1.tp_attribute1,'||
9076 'r1.tp_attribute2,r1.tp_attribute3,r1.tp_attribute4,r1.tp_attribute5,'||
9077 'r1.tp_attribute6,r1.tp_attribute7,r1.tp_attribute8,r1.tp_attribute9,'||
9078 'r1.tp_attribute10,r1.tp_attribute11,r1.tp_attribute12,r1.tp_attribute13,'||
9079 'r1.tp_attribute14,r1.tp_attribute15,r1.tp_attribute_category,'||
9080 'r1.item_detail_type,r1.item_detail_subtype,r1.intrmd_ship_to_id,'||
9081 'r1.ship_to_org_id,r1.invoice_to_org_id,r1.primary_quantity,'||
9082 'r1.intmed_ship_to_org_id,r1.customer_item_id,r1.inventory_item_id,'||
9083 'r1.order_header_id,''' || x_Demand_Type ||
9084 ''' authorized_to_ship_flag,r1.ship_from_org_id,''' ||
9085 x_sched_rec.schedule_type ||''',''CUST'' item_identifier_type,'||
9086 'r1.customer_item_ext,r1.agreement_id,r1.price_list_id,'||
9087 x_Sched_rec.schedule_header_id ||
9088 ',r1.schedule_line_id,r1.process_status,r1.uom_code,r1.cust_po_line_num,r1.blanket_number ' ||
9089 'FROM rlm_interface_lines r1 ';
9090
9091 --
9092 v_where_clause1 :=
9093
9094 'WHERE o.header_id = r.order_header_id ' ||
9095 ' AND o.org_id = r.org_id ' ||
9096 ' AND o.header_id = :order_header_id' ||
9097 ' AND r.order_header_id = :order_header_id' ||
9098 ' AND o.open_flag = ''Y''' ||
9099 ' AND r.header_id = :header_id' ||
9100 ' AND o.ship_to_org_id = r.ship_to_org_id ' ||
9101 ' AND o.ship_to_org_id = :ship_to_org_id' ||
9102 ' AND r.ship_to_org_id = :ship_to_org_id' ||
9103 ' AND NVL(o.intmed_ship_to_org_id,-19999) = NVL(r.intmed_ship_to_org_id,-19999) ' ||
9104 ' AND o.ordered_item_id = r.customer_item_id ' ||
9105 ' AND o.ordered_item_id = :customer_item_id' ||
9106 ' AND r.customer_item_id = :customer_item_id' ||
9107 ' AND o.inventory_item_id = r.inventory_item_id ' ||
9108 ' AND o.inventory_item_id = :inventory_item_id '||
9109 ' AND r.inventory_item_id = :inventory_item_id ' ||
9110 ' AND o.demand_bucket_type_code = r.item_detail_subtype ' ||
9111 ' AND r.process_status IN ('||rlm_core_sv.k_PS_AVAILABLE||','||rlm_core_sv.k_PS_FROZEN_FIRM||')';
9112 --
9113 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.order_header_id;
9114 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.order_header_id;
9115 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Sched_rec.header_id;
9116 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_to_org_id;
9117 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_to_org_id;
9118 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.customer_item_id;
9119 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.customer_item_id;
9120 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.inventory_item_id;
9121 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.inventory_item_id;
9122 --
9123 --
9124 -- Optional Match
9125 IF x_group_rec.match_across_rec.request_date = 'Y' THEN
9126 --
9127 v_where_clause2 := v_where_clause2 ||
9128 ' AND o.request_date = r.request_date';
9129 --
9130 ELSE
9131 --
9132 IF x_group_rec.match_within_rec.request_date = 'Y' THEN
9133 --
9134 v_where_clause2 := v_where_clause2 ||
9135 ' AND o.request_date = DECODE(o.rla_schedule_type_code,:schedule_type, r.request_date, o.request_date)';
9136 --
9137 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9138 --
9139 END IF;
9140 --
9141 END IF;
9142 --
9143 IF x_group_rec.match_across_rec.cust_production_line = 'Y' THEN
9144 --
9145 v_where_clause2 := v_where_clause2 ||
9146 ' AND NVL(o.customer_production_line,'''||k_VNULL||
9147 ''') = NVL(r.cust_production_line,'''||k_VNULL|| ''')';
9148 --
9149 ELSE
9150 --
9151 IF x_group_rec.match_within_rec.cust_production_line = 'Y' THEN
9152 --
9153 v_where_clause2 := v_where_clause2 ||
9154 ' AND NVL(o.customer_production_line,'''||k_VNULL||
9155 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_production_line,'''||
9156 k_VNULL||'''), NVL(o.customer_production_line,'''||k_VNULL||'''))';
9157 --
9158 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9159 --
9160 END IF;
9161 --
9162 END IF;
9163 --
9164 IF x_group_rec.match_across_rec.customer_dock_code = 'Y' THEN
9165 --
9166 v_where_clause2 := v_where_clause2 ||
9167 ' AND NVL(o.customer_dock_code,'''||k_VNULL||
9168 ''') = NVL(r.customer_dock_code,'''||k_VNULL|| ''')';
9169 --
9170 ELSE
9171 --
9172 IF x_group_rec.match_within_rec.customer_dock_code = 'Y' THEN
9173 --
9174 v_where_clause2 := v_where_clause2 ||
9175 ' AND NVL(o.customer_dock_code,'''||k_VNULL||
9176 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_dock_code,'''||
9177 k_VNULL||'''), NVL(o.customer_dock_code,'''||k_VNULL||'''))';
9178 --
9179 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9180 --
9181 END IF;
9182 --
9183 END IF;
9184 --
9185 IF x_group_rec.match_across_rec.cust_po_number = 'Y' THEN
9186 --
9187 v_where_clause2 := v_where_clause2 ||
9188 ' AND NVL(o.cust_po_number,'''||k_VNULL||
9189 ''') = NVL(r.cust_po_number,'''||k_VNULL|| ''')';
9190 --
9191 ELSE
9192 --
9193 IF x_group_rec.match_within_rec.cust_po_number = 'Y' THEN
9194 --
9195 v_where_clause2 := v_where_clause2 ||
9196 ' AND NVL(o.cust_po_number,'''||k_VNULL||
9197 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_po_number,'''||
9198 k_VNULL||'''), NVL(o.cust_po_number,'''||k_VNULL||'''))';
9199 --
9200 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9201 --
9202 END IF;
9203 --
9204 END IF;
9205 --
9206 IF x_group_rec.match_across_rec.customer_item_revision = 'Y' THEN
9207 --
9208 v_where_clause2 := v_where_clause2 ||
9209 ' AND NVL(o.item_revision,'''||k_VNULL||
9210 ''') = NVL(r.customer_item_revision,'''||k_VNULL|| ''')';
9211 --
9212 ELSE
9213 --
9214 IF x_group_rec.match_within_rec.customer_item_revision = 'Y' THEN
9215 --
9216 v_where_clause2 := v_where_clause2 ||
9217 ' AND NVL(o.item_revision,'''||k_VNULL||
9218 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_item_revision,'''||
9219 k_VNULL||'''), NVL(o.item_revision,'''||k_VNULL||'''))';
9220 --
9221 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9222 --
9223 END IF;
9224 --
9225 END IF;
9226 --
9227 IF x_group_rec.match_across_rec.customer_job = 'Y' THEN
9228 --
9229 v_where_clause2 := v_where_clause2 ||
9230 ' AND NVL(o.customer_job,'''||k_VNULL||
9231 ''') = NVL(r.customer_job,'''||k_VNULL|| ''')';
9232 --
9233 ELSE
9234 --
9235 IF x_group_rec.match_within_rec.customer_job = 'Y' THEN
9236 --
9237 v_where_clause2 := v_where_clause2 ||
9238 ' AND NVL(o.customer_job,'''||k_VNULL||
9239 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_job,'''||
9240 k_VNULL||'''), NVL(o.customer_job,'''||k_VNULL||'''))';
9241 --
9242 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9243 --
9244 END IF;
9245 --
9246 END IF;
9247 --
9248 IF x_group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
9249 --
9250 v_where_clause2 := v_where_clause2 ||
9251 ' AND NVL(o.cust_model_serial_number,'''||k_VNULL||
9252 ''') = NVL(r.cust_model_serial_number,'''||k_VNULL|| ''')';
9253 --
9254 ELSE
9255 --
9256 IF x_group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
9257 --
9258 v_where_clause2 := v_where_clause2 ||
9259 ' AND NVL(o.cust_model_serial_number,'''||k_VNULL||
9260 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_model_serial_number,'''||
9261 k_VNULL||'''), NVL(o.cust_model_serial_number,'''||k_VNULL||'''))';
9262 --
9263 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9264 --
9265 END IF;
9266 --
9267 END IF;
9268 --
9269 IF x_group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
9270 --
9271 v_where_clause2 := v_where_clause2 ||
9272 ' AND NVL(o.cust_production_seq_num,'''||k_VNULL||
9273 ''') = NVL(r.cust_production_seq_num,'''||k_VNULL|| ''')';
9274 --
9275 ELSE
9276 --
9277 IF x_group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
9278 --
9279 v_where_clause2 := v_where_clause2 ||
9280 ' AND NVL(o.cust_production_seq_num,'''||k_VNULL||
9281 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_production_seq_num,'''||
9282 k_VNULL||'''), NVL(o.cust_production_seq_num,'''||k_VNULL||'''))';
9283 --
9284 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9285 --
9286 END IF;
9287 --
9288 END IF;
9289 --
9290 IF x_group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
9291 --
9292 v_where_clause2 := v_where_clause2 ||
9293 ' AND NVL(o.industry_attribute1,'''||k_VNULL||
9294 ''') = NVL(r.industry_attribute1,'''||k_VNULL|| ''')';
9295 --
9296 ELSE
9297 --
9298 IF x_group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
9299 --
9300 v_where_clause2 := v_where_clause2 ||
9301 ' AND NVL(o.industry_attribute1,'''||k_VNULL||
9302 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute1,'''||
9303 k_VNULL||'''), NVL(o.industry_attribute1,'''||k_VNULL||'''))';
9304 --
9305 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9306 --
9307 END IF;
9308 --
9309 END IF;
9310 --
9311 IF x_group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
9312 --
9313 v_where_clause2 := v_where_clause2 ||
9314 ' AND NVL(o.industry_attribute2,'''||k_VNULL||
9315 ''') = NVL(r.industry_attribute2,'''||k_VNULL|| ''')';
9316 --
9317 ELSE
9318 --
9319 IF x_group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
9320 --
9321 v_where_clause2 := v_where_clause2 ||
9322 ' AND NVL(o.industry_attribute2,'''||k_VNULL||
9323 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute2,'''||
9324 k_VNULL||'''), NVL(o.industry_attribute2,'''||k_VNULL||'''))';
9325 --
9326 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9327 --
9328 END IF;
9329 --
9330 END IF;
9331 --
9332 IF x_group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
9333 --
9334 v_where_clause2 := v_where_clause2 ||
9335 ' AND NVL(o.industry_attribute4,'''||k_VNULL||
9336 ''') = NVL(r.industry_attribute4,'''||k_VNULL|| ''')';
9337 --
9338 ELSE
9339 --
9340 IF x_group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
9341 --
9342 v_where_clause2 := v_where_clause2 ||
9343 ' AND NVL(o.industry_attribute4,'''||k_VNULL||
9344 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute4,'''||
9345 k_VNULL||'''), NVL(o.industry_attribute4,'''||k_VNULL||'''))';
9346 --
9347 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9348 --
9349 END IF;
9350 --
9351 END IF;
9352 --
9353 IF x_group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
9354 --
9355 v_where_clause2 := v_where_clause2 ||
9356 ' AND NVL(o.industry_attribute5,'''||k_VNULL||
9357 ''') = NVL(r.industry_attribute5,'''||k_VNULL|| ''')';
9358 --
9359 ELSE
9360 --
9361 IF x_group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
9362 --
9363 v_where_clause2 := v_where_clause2 ||
9364 ' AND NVL(o.industry_attribute5,'''||k_VNULL||
9365 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute5,'''||
9366 k_VNULL||'''), NVL(o.industry_attribute5,'''||k_VNULL||'''))';
9367 --
9368 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9369 --
9370 END IF;
9371 --
9372 END IF;
9373 --
9374 IF x_group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
9375 --
9376 v_where_clause2 := v_where_clause2 ||
9377 ' AND NVL(o.industry_attribute6,'''||k_VNULL||
9378 ''') = NVL(r.industry_attribute6,'''||k_VNULL|| ''')';
9379 --
9380 ELSE
9381 --
9382 IF x_group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
9383 --
9384 v_where_clause2 := v_where_clause2 ||
9385 ' AND NVL(o.industry_attribute6,'''||k_VNULL||
9386 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute6,'''||
9387 k_VNULL||'''), NVL(o.industry_attribute6,'''||k_VNULL||'''))';
9388 --
9389 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9390 --
9391 END IF;
9392 --
9393 END IF;
9394 --
9395 IF x_group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
9396 --
9397 v_where_clause2 := v_where_clause2 ||
9398 ' AND NVL(o.industry_attribute10,'''||k_VNULL||
9399 ''') = NVL(r.industry_attribute10,'''||k_VNULL|| ''')';
9400 --
9401 ELSE
9402 --
9403 IF x_group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
9404 --
9405 v_where_clause2 := v_where_clause2 ||
9406 ' AND NVL(o.industry_attribute10,'''||k_VNULL||
9407 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute10,'''||
9408 k_VNULL||'''), NVL(o.industry_attribute10,'''||k_VNULL||'''))';
9409 --
9410 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9411 --
9412 END IF;
9413 --
9414 END IF;
9415 --
9416 IF x_group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
9417 --
9418 v_where_clause2 := v_where_clause2 ||
9419 ' AND NVL(o.industry_attribute11,'''||k_VNULL||
9420 ''') = NVL(r.industry_attribute11,'''||k_VNULL|| ''')';
9421 --
9422 ELSE
9423 --
9424 IF x_group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
9425 --
9426 v_where_clause2 := v_where_clause2 ||
9427 ' AND NVL(o.industry_attribute11,'''||k_VNULL||
9428 ''') = DECODE(o.rla_schedule_type_code,:schedule_type, NVL(r.industry_attribute11,'''||
9429 k_VNULL||'''), NVL(o.industry_attribute11,'''||k_VNULL||'''))';
9430 --
9431 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9432 --
9433 END IF;
9434 --
9435 END IF;
9436 --
9437 IF x_group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
9438 --
9439 v_where_clause2 := v_where_clause2 ||
9440 ' AND NVL(o.industry_attribute12,'''||k_VNULL||
9441 ''') = NVL(r.industry_attribute12,'''||k_VNULL|| ''')';
9442 --
9443 ELSE
9444 --
9445 IF x_group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
9446 --
9447 v_where_clause2 := v_where_clause2 ||
9448 ' AND NVL(o.industry_attribute12,'''||k_VNULL||
9449 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute12,'''||
9450 k_VNULL||'''), NVL(o.industry_attribute12,'''||k_VNULL||'''))';
9451 --
9452 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9453 --
9454 END IF;
9455 --
9456 END IF;
9457 --
9458 IF x_group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
9459 --
9460 v_where_clause2 := v_where_clause2 ||
9461 ' AND NVL(o.industry_attribute13,'''||k_VNULL||
9462 ''') = NVL(r.industry_attribute13,'''||k_VNULL|| ''')';
9463 --
9464 ELSE
9465 --
9466 IF x_group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
9467 --
9468 v_where_clause2 := v_where_clause2 ||
9469 ' AND NVL(o.industry_attribute13,'''||k_VNULL||
9470 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute13,'''||
9471 k_VNULL||'''), NVL(o.industry_attribute13,'''||k_VNULL||'''))';
9472 --
9473 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9474 --
9475 END IF;
9476 --
9477 END IF;
9478 --
9479 IF x_group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
9480 --
9481 v_where_clause2 := v_where_clause2 ||
9482 ' AND NVL(o.industry_attribute14,'''||k_VNULL||
9483 ''') = NVL(r.industry_attribute14,'''||k_VNULL|| ''')';
9484 --
9485 ELSE
9486 --
9487 IF x_group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
9488 --
9489 v_where_clause2 := v_where_clause2 ||
9490 ' AND NVL(o.industry_attribute14,'''||k_VNULL||
9491 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute14,'''||
9492 k_VNULL||'''), NVL(o.industry_attribute14,'''||k_VNULL||'''))';
9493 --
9494 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9495 --
9496 END IF;
9497 --
9498 END IF;
9499 --
9500 IF x_group_rec.match_across_rec.attribute1 = 'Y' THEN
9501 --
9502 v_where_clause2 := v_where_clause2 ||
9503 ' AND NVL(o.attribute1,'''||k_VNULL||
9504 ''') = NVL(r.attribute1,'''||k_VNULL|| ''')';
9505 --
9506 ELSE
9507 --
9508 IF x_group_rec.match_within_rec.attribute1 = 'Y' THEN
9509 --
9510 v_where_clause2 := v_where_clause2 ||
9511 ' AND NVL(o.attribute1,'''||k_VNULL||
9512 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute1,'''||
9513 k_VNULL||'''), NVL(o.attribute1,'''||k_VNULL||'''))';
9514 --
9515 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9516 --
9517 END IF;
9518 --
9519 END IF;
9520 --
9521 IF x_group_rec.match_across_rec.attribute2 = 'Y' THEN
9522 --
9523 v_where_clause2 := v_where_clause2 ||
9524 ' AND NVL(o.attribute2,'''||k_VNULL||
9525 ''') = NVL(r.attribute2,'''||k_VNULL|| ''')';
9526 --
9527 ELSE
9528 --
9529 IF x_group_rec.match_within_rec.attribute2 = 'Y' THEN
9530 --
9531 v_where_clause2 := v_where_clause2 ||
9532 ' AND NVL(o.attribute2,'''||k_VNULL||
9533 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute2,'''||
9534 k_VNULL||'''), NVL(o.attribute2,'''||k_VNULL||'''))';
9535 --
9536 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9537 --
9538 END IF;
9539 --
9540 END IF;
9541 --
9542 IF x_group_rec.match_across_rec.attribute3 = 'Y' THEN
9543 --
9544 v_where_clause2 := v_where_clause2 ||
9545 ' AND NVL(o.attribute3,'''||k_VNULL||
9546 ''') = NVL(r.attribute3,'''||k_VNULL|| ''')';
9547 --
9548 ELSE
9549 --
9550 IF x_group_rec.match_within_rec.attribute3 = 'Y' THEN
9551 --
9552 v_where_clause2 := v_where_clause2 ||
9553 ' AND NVL(o.attribute3,'''||k_VNULL||
9554 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute3,'''||
9555 k_VNULL||'''), NVL(o.attribute3,'''||k_VNULL||'''))';
9556 --
9557 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9558 --
9559 END IF;
9560 --
9561 END IF;
9562 --
9563 IF x_group_rec.match_across_rec.attribute4 = 'Y' THEN
9564 --
9565 v_where_clause2 := v_where_clause2 ||
9566 ' AND NVL(o.attribute4,'''||k_VNULL||
9567 ''') = NVL(r.attribute4,'''||k_VNULL|| ''')';
9568 --
9569 ELSE
9570 --
9571 IF x_group_rec.match_within_rec.attribute4 = 'Y' THEN
9572 --
9573 v_where_clause2 := v_where_clause2 ||
9574 ' AND NVL(o.attribute4,'''||k_VNULL||
9575 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute4,'''||
9576 k_VNULL||'''), NVL(o.attribute4,'''||k_VNULL||'''))';
9577 --
9578 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9579 --
9580 END IF;
9581 --
9582 END IF;
9583 --
9584 IF x_group_rec.match_across_rec.attribute5 = 'Y' THEN
9585 --
9586 v_where_clause2 := v_where_clause2 ||
9587 ' AND NVL(o.attribute5,'''||k_VNULL||
9588 ''') = NVL(r.attribute5,'''||k_VNULL|| ''')';
9589 --
9590 ELSE
9591 --
9592 IF x_group_rec.match_within_rec.attribute5 = 'Y' THEN
9593 --
9594 v_where_clause2 := v_where_clause2 ||
9595 ' AND NVL(o.attribute5,'''||k_VNULL||
9596 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute5,'''||
9597 k_VNULL||'''), NVL(o.attribute5,'''||k_VNULL||'''))';
9598 --
9599 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9600 --
9601 END IF;
9602 --
9603 END IF;
9604 --
9605 IF x_group_rec.match_across_rec.attribute6 = 'Y' THEN
9606 --
9607 v_where_clause2 := v_where_clause2 ||
9608 ' AND NVL(o.attribute6,'''||k_VNULL||
9609 ''') = NVL(r.attribute6,'''||k_VNULL|| ''')';
9610 --
9611 ELSE
9612 --
9613 IF x_group_rec.match_within_rec.attribute6 = 'Y' THEN
9614 --
9615 v_where_clause2 := v_where_clause2 ||
9616 ' AND NVL(o.attribute6,'''||k_VNULL||
9617 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute6,'''||
9618 k_VNULL||'''), NVL(o.attribute6,'''||k_VNULL||'''))';
9619 --
9620 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9621 --
9622 END IF;
9623 --
9624 END IF;
9625 --
9626 IF x_group_rec.match_across_rec.attribute7 = 'Y' THEN
9627 --
9628 v_where_clause2 := v_where_clause2 ||
9629 ' AND NVL(o.attribute7,'''||k_VNULL||
9630 ''') = NVL(r.attribute7,'''||k_VNULL|| ''')';
9631 --
9632 ELSE
9633 --
9634 IF x_group_rec.match_within_rec.attribute7 = 'Y' THEN
9635 --
9636 v_where_clause2 := v_where_clause2 ||
9637 ' AND NVL(o.attribute7,'''||k_VNULL||
9638 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute7,'''||
9639 k_VNULL||'''), NVL(o.attribute7,'''||k_VNULL||'''))';
9640 --
9641 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9642 --
9643 END IF;
9644 --
9645 END IF;
9646 --
9647 IF x_group_rec.match_across_rec.attribute8 = 'Y' THEN
9648 --
9649 v_where_clause2 := v_where_clause2 ||
9650 ' AND NVL(o.attribute8,'''||k_VNULL||
9651 ''') = NVL(r.attribute8,'''||k_VNULL|| ''')';
9652 --
9653 ELSE
9654 --
9655 IF x_group_rec.match_within_rec.attribute8 = 'Y' THEN
9656 --
9657 v_where_clause2 := v_where_clause2 ||
9658 ' AND NVL(o.attribute8,'''||k_VNULL||
9659 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute8,'''||
9660 k_VNULL||'''), NVL(o.attribute8,'''||k_VNULL||'''))';
9661 --
9662 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9663 --
9664 END IF;
9665 --
9666 END IF;
9667 --
9668 IF x_group_rec.match_across_rec.attribute9 = 'Y' THEN
9669 --
9670 v_where_clause2 := v_where_clause2 ||
9671 ' AND NVL(o.attribute9,'''||k_VNULL||
9672 ''') = NVL(r.attribute9,'''||k_VNULL|| ''')';
9673 --
9674 ELSE
9675 --
9676 IF x_group_rec.match_within_rec.attribute9 = 'Y' THEN
9677 --
9678 v_where_clause2 := v_where_clause2 ||
9679 ' AND NVL(o.attribute9,'''||k_VNULL||
9680 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute9,'''||
9681 k_VNULL||'''), NVL(o.attribute9,'''||k_VNULL||'''))';
9682 --
9683 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9684 --
9685 END IF;
9686 --
9687 END IF;
9688 --
9689 IF x_group_rec.match_across_rec.attribute10 = 'Y' THEN
9690 --
9691 v_where_clause2 := v_where_clause2 ||
9692 ' AND NVL(o.attribute10,'''||k_VNULL||
9693 ''') = NVL(r.attribute10,'''||k_VNULL|| ''')';
9694 --
9695 ELSE
9696 --
9697 IF x_group_rec.match_within_rec.attribute10 = 'Y' THEN
9698 --
9699 v_where_clause2 := v_where_clause2 ||
9700 ' AND NVL(o.attribute10,'''||k_VNULL||
9701 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute10,'''||
9702 k_VNULL||'''), NVL(o.attribute10,'''||k_VNULL||'''))';
9703 --
9704 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9705 --
9706 END IF;
9707 --
9708 END IF;
9709 --
9710 IF x_group_rec.match_across_rec.attribute11 = 'Y' THEN
9711 --
9712 v_where_clause2 := v_where_clause2 ||
9713 ' AND NVL(o.attribute11,'''||k_VNULL||
9714 ''') = NVL(r.attribute11,'''||k_VNULL|| ''')';
9715 --
9716 ELSE
9717 --
9718 IF x_group_rec.match_within_rec.attribute11 = 'Y' THEN
9719 --
9720 v_where_clause2 := v_where_clause2 ||
9721 ' AND NVL(o.attribute11,'''||k_VNULL||
9722 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute11,'''||
9723 k_VNULL||'''), NVL(o.attribute11,'''||k_VNULL||'''))';
9724 --
9725 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9726 --
9727 END IF;
9728 --
9729 END IF;
9730 --
9731 IF x_group_rec.match_across_rec.attribute12 = 'Y' THEN
9732 --
9733 v_where_clause2 := v_where_clause2 ||
9734 ' AND NVL(o.attribute12,'''||k_VNULL||
9735 ''') = NVL(r.attribute12,'''||k_VNULL|| ''')';
9736 --
9737 ELSE
9738 --
9739 IF x_group_rec.match_within_rec.attribute12 = 'Y' THEN
9740 --
9741 v_where_clause2 := v_where_clause2 ||
9742 ' AND NVL(o.attribute12,'''||k_VNULL||
9743 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute12,'''||
9744 k_VNULL||'''), NVL(o.attribute12,'''||k_VNULL||'''))';
9745 --
9746 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9747 --
9748 END IF;
9749 --
9750 END IF;
9751 --
9752 IF x_group_rec.match_across_rec.attribute13 = 'Y' THEN
9753 --
9754 v_where_clause2 := v_where_clause2 ||
9755 ' AND NVL(o.attribute13,'''||k_VNULL||
9756 ''') = NVL(r.attribute13,'''||k_VNULL|| ''')';
9757 --
9758 ELSE
9759 --
9760 IF x_group_rec.match_within_rec.attribute13 = 'Y' THEN
9761 --
9762 v_where_clause2 := v_where_clause2 ||
9763 ' AND NVL(o.attribute13,'''||k_VNULL||
9764 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute13,'''||
9765 k_VNULL||'''), NVL(o.attribute13,'''||k_VNULL||'''))';
9766 --
9767 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9768 --
9769 END IF;
9770 --
9771 END IF;
9772 --
9773 IF x_group_rec.match_across_rec.attribute14 = 'Y' THEN
9774 --
9775 v_where_clause2 := v_where_clause2 ||
9776 ' AND NVL(o.attribute14,'''||k_VNULL||
9777 ''') = NVL(r.attribute14,'''||k_VNULL|| ''')';
9778 --
9779 ELSE
9780 --
9781 IF x_group_rec.match_within_rec.attribute14 = 'Y' THEN
9782 --
9783 v_where_clause2 := v_where_clause2 ||
9784 ' AND NVL(o.attribute14,'''||k_VNULL||
9785 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute14,'''||
9786 k_VNULL||'''), NVL(o.attribute14,'''||k_VNULL||'''))';
9787 --
9788 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9789 --
9790 END IF;
9791 --
9792 END IF;
9793 --
9794 IF x_group_rec.match_across_rec.attribute15 = 'Y' THEN
9795 --
9796 v_where_clause2 := v_where_clause2 ||
9797 ' AND NVL(o.attribute15,'''||k_VNULL||
9798 ''') = NVL(r.attribute15,'''||k_VNULL|| ''')';
9799 --
9800 ELSE
9801 --
9802 IF x_group_rec.match_within_rec.attribute15 = 'Y' THEN
9803 --
9804 v_where_clause2 := v_where_clause2 ||
9805 ' AND NVL(o.attribute15,'''||k_VNULL||
9806 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute15,'''||
9807 k_VNULL||'''), NVL(o.attribute15,'''||k_VNULL||'''))';
9808 --
9809 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9810 --
9811 END IF;
9812 --
9813 END IF;
9814 --
9815
9816 w_where_clause1 :=
9817 'WHERE r1.order_header_id = :order_header_id' ||
9818 ' AND r1.header_id = :header_id' ||
9819 ' AND r1.ship_from_org_id = :ship_from_org_id' ||
9820 ' AND r1.industry_attribute15 = :industry_attribute15' ||
9821 ' AND r1.ship_to_org_id = :ship_to_org_id' ||
9822 ' AND r1.customer_item_id = :customer_item_id' ||
9823 ' AND r1.inventory_item_id = :inventory_item_id' ||
9824 ' AND r1.process_status IN ('||rlm_core_sv.k_PS_AVAILABLE||','||rlm_core_sv.k_PS_FROZEN_FIRM||')';
9825 --
9826 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.order_header_id;
9827 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Sched_rec.header_id;
9828 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.ship_from_org_id;
9829 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.industry_attribute15;
9830 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.ship_to_org_id;
9831 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.customer_item_id;
9832 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.inventory_item_id;
9833 --
9834 IF g_ATP <> k_ATP THEN
9835 --
9836 v_where_clause1 := v_where_clause1 ||
9837 ' AND o.ship_from_org_id = r.ship_from_org_id '||
9838 ' AND o.ship_from_org_id = :ship_from_org_id'||
9839 ' AND r.ship_from_org_id = :ship_from_org_id';
9840 --
9841 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_from_org_id;
9842 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_from_org_id;
9843 --
9844 v_where_clause1 := v_where_clause1 ||
9845 ' AND NVL(o.industry_attribute15,'''||k_VNULL||
9846 ''') = NVL(r.industry_attribute15,'''||k_VNULL|| ''')';
9847 --
9848 END IF;
9849 --
9850
9851 -- match on blanket number only if blankets are used
9852 --
9853 IF x_Group_rec.blanket_number IS NOT NULL THEN
9854 v_where_clause1 := v_where_clause1 || ' AND o.blanket_number = r.blanket_number ';
9855 w_where_clause1 := w_where_clause1 || ' AND r1.blanket_number = :blanket_number ';
9856 --
9857 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.blanket_number;
9858 --
9859 END IF;
9860 --
9861
9862 IF x_Demand_Type = k_ATS THEN
9863 --
9864 -- Begin ArvinMeritor Change
9865 --
9866 IF x_Group_rec.disposition_code = k_CANCEL_ALL THEN
9867 --
9868 v_ATSWhere := ' TO_DATE(o.industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_horizon_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_horizon_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
9869 --
9870 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(SYSDATE),'RRRR/MM/DD HH24:MI:SS');
9871 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
9872 --
9873 ELSIF x_Group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS THEN
9874 --
9875 v_Date := SYSDATE - nvl(x_Group_rec.cutoff_days, 0);
9876 rlm_core_sv.dlog(k_DEBUG, 'x_Group_rec.cutoff_days', x_Group_rec.cutoff_days);
9877 rlm_core_sv.dlog(k_DEBUG, 'v_Date', v_Date);
9878 --
9879 v_ATSWhere := ' TO_DATE(o.industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_horizon_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_horizon_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
9880 --
9881 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(v_Date),'RRRR/MM/DD HH24:MI:SS');
9882 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
9883 --
9884 ELSIF x_Group_rec.disposition_code = k_REMAIN_ON_FILE_RECONCILE THEN
9885 --
9886 -- bug4223359 For 'RemainOnFileReconcile' consider all the open order lines to be matched.
9887 --
9888 v_ATSWhere := ' TO_DATE(o.industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') < TO_DATE(:sched_horizon_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
9889 --
9890 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
9891 --
9892 ELSE
9893 --
9894 v_ATSWhere := ' TO_DATE(o.industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_horizon_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_horizon_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
9895 --
9896 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date),'RRRR/MM/DD HH24:MI:SS');
9897 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
9898 --
9899 END IF;
9900 --
9901 v_where_clause1 := v_where_clause1 || ' AND ' || v_ATSWhere;
9902 --
9903 -- End ArvinMeritor Change
9904 --
9905 --
9906 v_where_clause1 := v_where_clause1 ||
9907 ' AND (r.item_detail_type = '||k_FIRM||' OR r.item_detail_type = '||k_PAST_DUE_FIRM||')';
9908 --
9909 w_where_clause1 := w_where_clause1 ||
9910 ' AND (r1.item_detail_type = '||k_FIRM||' OR r1.item_detail_type = '||k_PAST_DUE_FIRM||')';
9911
9912 -- this is to let ATS replace existing NATS
9913 x_Sql1 := v_select_clause ||
9914 v_where_clause1 ||
9915 v_where_clause2 ||
9916 ' AND o.authorized_to_ship_flag = ''N'' ';
9917
9918 -- this has to come after x_Sql1
9919 v_where_clause2 := v_where_clause2 ||
9920 ' AND o.authorized_to_ship_flag = ''Y'' ';
9921 --
9922 ELSE /* k_NATS */
9923 --
9924 -- Begin ArvinMeritor Change
9925 --
9926 v_NATSWhere := ' TO_DATE(o.industry_attribute2,''RRRR/MM/DD HH24:MI:SS'') BETWEEN TO_DATE(:sched_horizon_start_date,''RRRR/MM/DD HH24:MI:SS'') AND TO_DATE(:sched_horizon_end_date,''RRRR/MM/DD HH24:MI:SS'') ';
9927 --
9928 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(SYSDATE),'RRRR/MM/DD HH24:MI:SS');
9929 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
9930 --
9931 v_where_clause1 := v_where_clause1 || ' AND ' || v_NATSWhere;
9932 --
9933 -- End ArvinMeritor Change
9934 v_where_clause1 := v_where_clause1 ||
9935 ' AND r.item_detail_type = '|| k_FORECAST;
9936 --
9937 w_where_clause1 := w_where_clause1 ||
9938 ' AND r1.item_detail_type = '|| k_FORECAST;
9939
9940 -- this is to let NATS replace existing ATS
9941 x_Sql1 := v_select_clause ||
9942 v_where_clause1 ||
9943 v_where_clause2 ||
9944 ' AND o.authorized_to_ship_flag = ''Y'' ';
9945
9946 -- this has to come after x_Sql1
9947 v_where_clause2 := v_where_clause2 ||
9948 ' AND o.authorized_to_ship_flag = ''N'' ';
9949 --
9950 END IF;
9951 --
9952
9953 -- subquery
9954 w_select_clause2 :=
9955 '(SELECT ''X'' ' ||
9956 'FROM oe_order_lines_all o,rlm_interface_lines r ' ||
9957 v_where_clause1 ||
9958 v_where_clause2 ||
9959 ' AND r1.line_id = r.line_id) ';
9960
9961 v_order_clause :=
9962 ' ORDER BY request_date, line_id ';
9963 --
9964
9965 x_Sql2 := w_select_clause1 ||
9966 w_where_clause1 ||
9967 ' AND NOT EXISTS ' ||
9968 w_select_clause2 ||
9969 v_order_clause;
9970
9971
9972 x_Sql := v_select_clause ||
9973 v_where_clause1 ||
9974 v_where_clause2 ||
9975 ' UNION ALL ' || x_Sql2;
9976
9977 x_Sum_Sql := 'SELECT r.line_id, SUM(NVL(o.ordered_quantity,0)-NVL(o.shipped_quantity,0)), COUNT(1), MIN(o.line_id) ' ||
9978 'FROM rlm_interface_lines r, oe_order_lines_all o ' ||
9979 v_where_clause1 ||
9980 v_where_clause2 ||
9981 ' GROUP BY r.line_id ORDER BY line_id';
9982
9983 IF (l_debug <> -1) THEN
9984 rlm_core_sv.dlog(k_DEBUG, 'v_select_clause', v_select_clause);
9985 rlm_core_sv.dlog(k_DEBUG, 'v_ATSWhere', v_ATSWhere);
9986 rlm_core_sv.dlog(k_DEBUG, 'v_NATSWhere', v_NATSWhere);
9987 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1', substr(v_where_clause1, 1, 800));
9988 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1 Contd.', substr(v_where_clause1, 800, 1600));
9989 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1 Contd.', substr(v_where_clause1, 1600, 2400));
9990 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2', substr(v_where_clause2, 1, 800));
9991 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2 Contd.', substr(v_where_clause2, 800, 1600));
9992 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2 Contd.', substr(v_where_clause2, 1600, 2400));
9993 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause1', w_select_clause1);
9994 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2', substr(w_select_clause2, 1, 800));
9995 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2 Contd.', substr(w_select_clause2, 800, 1600));
9996 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2 Contd.', substr(w_select_clause2, 1600, 2400));
9997 rlm_core_sv.dlog(k_DEBUG, 'w_where_clause1', w_where_clause1);
9998 rlm_core_sv.dlog(k_DEBUG, 'x_Sum_Sql', x_Sum_Sql);
9999 rlm_core_sv.dlog(k_DEBUG, 'v_order_clause', v_order_clause);
10000 rlm_core_sv.dpop(k_SDEBUG);
10001 END IF;
10002 --
10003
10004 EXCEPTION
10005
10006 WHEN OTHERS THEN
10007 rlm_message_sv.sql_error('rlm_rd_sv.BuildMatchQuery',x_progress);
10008 IF (l_debug <> -1) THEN
10009 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10010 END IF;
10011 RAISE;
10012
10013 END;
10014
10015
10016 /*===========================================================================
10017
10018 PROCEDURE ProcessATS -
10019 (1) New code with performance changes (dynamic sql)
10020
10021 ===========================================================================*/
10022
10023 PROCEDURE ProcessATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10024 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
10025 IS
10026
10027 v_Key_rec t_Key_rec;
10028 v_ScheduleType VARCHAR2(30);
10029 v_SumOrderedQty NUMBER DEFAULT 0;
10030 v_SumOrderedQtyTmp NUMBER DEFAULT 0;
10031 v_DemandCount NUMBER DEFAULT 0;
10032 v_LowestOeLineId NUMBER DEFAULT 0;
10033 v_line_id_tab t_matching_line;
10034 v_line_id_tmp NUMBER DEFAULT 0;
10035 --
10036 v_DeleteQty NUMBER;
10037 c_NATS t_Cursor_ref;
10038 c_Matched t_Cursor_ref;
10039 c_Sum t_Cursor_ref;
10040 x_progress VARCHAR2(3) := '010';
10041 v_NewCount NUMBER DEFAULT 0;
10042 v_AtsDemand VARCHAR2(32000);
10043 v_NatsDemand VARCHAR2(32000);
10044 v_SumDemand VARCHAR2(32000);
10045 v_NewDemand VARCHAR2(32000);
10046 v_LineId NUMBER;
10047 v_LineMatch t_Line_Match_Tab;
10048 v_LowestLineId NUMBER;
10049 v_min_horizon_date VARCHAR2(40);
10050 v_InTransitQty NUMBER :=0;
10051 v_ActualCount NUMBER;
10052 -- Bug 5608510
10053 v_total_ordered_qty NUMBER :=0;
10054 v_total_partial_shipped_qty NUMBER :=0;
10055 v_check_partial_flag VARCHAR2(1) :='N';
10056 --
10057 BEGIN
10058 --
10059 IF (l_debug <> -1) THEN
10060 rlm_core_sv.dpush(k_SDEBUG,'ProcessATS');
10061 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.header_id', x_Sched_rec.header_id);
10062 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
10063 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
10064 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
10065 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
10066 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.industry_attribute15', x_Group_rec.industry_attribute15);
10067 END IF;
10068
10069 IF(UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES', 'PART_SHIP_LINES' )) THEN
10070 --
10071 --Bug 3549475 jckwok
10072 --
10073 SELECT COUNT(*)
10074 INTO v_ActualCount
10075 FROM rlm_interface_lines il,
10076 rlm_schedule_lines_all sl
10077 WHERE il.header_id = x_Sched_rec.header_id
10078 AND il.ship_from_org_id = x_Group_rec.ship_from_org_id
10079 AND il.ship_to_org_id = x_Group_rec.ship_to_org_id
10080 AND il.inventory_item_id = x_Group_rec.inventory_item_id
10081 AND il.customer_item_id = x_Group_rec.customer_item_id
10082 AND il.schedule_line_id = sl.line_id
10083 AND NVL(il.item_detail_type, ' ')
10084 <> rlm_manage_demand_sv.k_SHIP_RECEIPT_INFO
10085 AND sl.qty_type_code = rlm_manage_demand_sv.k_ACTUAL
10086 AND il.org_id = sl.org_id;
10087 --
10088 IF (l_debug <> -1) THEN
10089 rlm_core_sv.dlog(k_DEBUG,'number of lines with qty_type_code ACTUAL: ',v_ActualCount);
10090 END IF;
10091 --
10092 IF (v_ActualCount > 0 ) THEN
10093 --
10094 SELECT TO_CHAR(TRUNC(min(request_date)), 'RRRR/MM/DD HH24:MI:SS')
10095 INTO v_min_horizon_date
10096 FROM rlm_interface_lines
10097 WHERE header_id=x_sched_rec.header_id
10098 AND inventory_item_id = x_group_rec.inventory_item_id
10099 AND customer_item_id = x_group_rec.customer_item_id
10100 AND Ship_from_org_id=x_group_rec.ship_from_org_id
10101 AND Ship_to_address_id=x_group_rec.ship_to_address_id;
10102
10103 IF (l_debug <> -1) THEN
10104 rlm_core_sv.dlog(k_DEBUG, 'v_min_request_date', v_min_horizon_date);
10105 END IF;
10106 --
10107 IF TO_DATE(v_min_horizon_date,'RRRR/MM/DD HH24:MI:SS') > x_Sched_rec.sched_horizon_start_date THEN
10108 --
10109 v_min_horizon_date:= TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date), 'RRRR/MM/DD HH24:MI:SS');
10110 --
10111 END IF;
10112 --
10113 IF (l_debug <> -1) THEN
10114 rlm_core_sv.dlog(k_DEBUG, 'v_min_horizon_date', v_min_horizon_date);
10115 END IF;
10116 END IF;
10117 END IF;
10118 --
10119 -- Delete all the bind variable tables
10120 --
10121 g_NewDemandTab.DELETE;
10122 g_WhereTab1.DELETE;
10123 g_WhereTab2.DELETE;
10124 g_BindVarTab.DELETE;
10125 --
10126 RLM_TPA_SV.BuildMatchQuery(x_sched_rec,
10127 x_Group_rec,
10128 k_ATS,
10129 v_AtsDemand,
10130 v_NatsDemand,
10131 v_NewDemand,
10132 v_SumDemand);
10133 --
10134 -- (1) Handle the case when incoming ATS match existing NATS
10135 --
10136 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10137 --
10138 IF (l_debug <> -1) THEN
10139 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NATS cursor', g_BindVarTab.COUNT);
10140 END IF;
10141 --
10142 RLM_CORE_SV.OpenDynamicCursor(c_NATS, v_NatsDemand, g_BindVarTab);
10143 --
10144 WHILE FetchReq(c_NATS,
10145 v_Key_rec,
10146 v_line_id_tmp,
10147 v_SumOrderedQtyTmp,
10148 v_ScheduleType)
10149
10150 LOOP
10151
10152 EXIT WHEN c_NATS%NOTFOUND;
10153 --
10154 IF (l_debug <> -1) THEN
10155 --
10156 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10157 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10158 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10159 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10160 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10161 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.intmed_ship_to_org_id', v_Key_rec.req_rec.intmed_ship_to_org_id);
10162 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10163 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10164 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10165 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10166 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10167 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10168 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10169 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10170 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10171 --
10172 END IF;
10173
10174 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE, k_CANCEL, k_ADD) THEN
10175 --
10176 v_Key_rec.oe_line_id := v_line_id_tmp;
10177 --
10178 IF (l_debug <> -1) THEN
10179 rlm_core_sv.dlog(k_DEBUG, 'OM NATS Line Id', v_line_id_tmp);
10180 END IF;
10181 --
10182 GetDemand(v_Key_rec, x_Group_rec);
10183 --
10184 IF SchedulePrecedence(x_Group_rec, x_Sched_rec, v_ScheduleType) THEN
10185 --
10186 DeleteRequirement(x_Sched_rec, x_Group_rec,
10187 v_Key_rec, k_RECONCILE,
10188 v_DeleteQty);
10189 --
10190 END IF;
10191 --
10192 END IF;
10193 --
10194 END LOOP;
10195 CLOSE c_NATS;
10196 --
10197 -- (2) Find all the ATS and NATS demand that matches in OM
10198 --
10199 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10200 --
10201 IF (l_debug <> -1) THEN
10202 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_SumDemand cursor', g_BindVarTab.COUNT);
10203 END IF;
10204 --
10205 RLM_CORE_SV.OpenDynamicCursor(c_Sum, v_SumDemand, g_BindVarTab);
10206 --
10207 FETCH c_Sum INTO v_LowestLineId,
10208 v_SumOrderedQtyTmp,
10209 v_DemandCount,
10210 v_LowestOeLineId;
10211 IF c_Sum%FOUND THEN
10212 --
10213 v_LineMatch(0).sum_qty := v_SumOrderedQtyTmp;
10214 v_LineMatch(0).match_count := v_DemandCount;
10215 v_LineMatch(0).lowest_oelineid := v_LowestOeLineId;
10216 --
10217 IF (l_debug <> -1) THEN
10218 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10219 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10220 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10221 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10222 END IF;
10223 --
10224 LOOP
10225 FETCH c_Sum INTO v_LineId,
10226 v_SumOrderedQtyTmp,
10227 v_DemandCount,
10228 v_LowestOeLineId;
10229 EXIT WHEN c_Sum%NOTFOUND;
10230 v_LineMatch(v_LineId-v_LowestLineId).sum_qty := v_SumOrderedQtyTmp;
10231 v_LineMatch(v_LineId-v_LowestLineId).match_count := v_DemandCount;
10232 v_LineMatch(v_LineId-v_LowestLineId).lowest_oelineid := v_LowestOeLineId;
10233 IF (l_debug <> -1) THEN
10234 rlm_core_sv.dlog(k_DEBUG,'For RLM Line Id', v_LineId);
10235 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10236 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10237 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10238 END IF;
10239 END LOOP;
10240 --
10241 END IF;
10242 CLOSE c_Sum;
10243 --
10244 IF (l_debug <> -1) THEN
10245 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10246 END IF;
10247 --
10248 IF v_LineMatch.COUNT > 0 THEN
10249 --
10250 -- (3) Find all ATS demand that matched in OM
10251 --
10252 g_BindVarTab := BuildBindVarTab5(g_WhereTab1, g_WhereTab2, g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10253 --
10254 IF (l_debug <> -1) THEN
10255 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_ATSDemand cursor', g_BindVarTab.COUNT);
10256 rlm_core_sv.dlog(k_DEBUG,'Opening for v_AtsDemand');
10257 END IF;
10258 --
10259 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_ATSDemand, g_BindVarTab);
10260 --
10261 ELSE
10262 --
10263 -- (4) Find all ATS demand that did not match with lines in OM
10264 --
10265 g_BindVarTab := BuildBindVarTab3(g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10266 --
10267 IF (l_debug <> -1) THEN
10268 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NewDemand cursor', g_BindVarTab.COUNT);
10269 rlm_core_sv.dlog(k_DEBUG,'Opening for v_NewDemand');
10270 END IF;
10271 --
10272 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NewDemand, g_BindVarTab);
10273 --
10274 END IF;
10275 --
10276 WHILE FetchReq(c_Matched,
10277 v_Key_rec,
10278 v_line_id_tmp,
10279 v_SumOrderedQtyTmp,
10280 v_ScheduleType)
10281 LOOP
10282
10283 EXIT WHEN c_Matched%NOTFOUND;
10284 --
10285 IF (l_debug <> -1) THEN
10286 --
10287 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10288 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10289 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10290 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10291 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10292 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.intmed_ship_to_org_id', v_Key_rec.req_rec.intmed_ship_to_org_id);
10293 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10294 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10295 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10296 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10297 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10298 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10299 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10300 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10301 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10302 --
10303 END IF;
10304 --
10305 g_sch_line_qty := v_Key_rec.req_rec.primary_quantity; --Bugfix 6131516
10306 -- start of bug fix 4223359
10307 --
10308 IF (v_key_rec.req_rec.process_status <> rlm_core_sv.k_PS_FROZEN_FIRM) THEN
10309 --
10310 FrozenFenceWarning(x_sched_rec, x_group_rec);
10311 --
10312 END IF;
10313 --
10314 -- end of bug fix 4223359
10315 --
10316 -- When there is NO MATCH
10317
10318 IF v_line_id_tmp IS NULL THEN
10319 --
10320 --Intransit Based on Shipped Lines
10321 --
10322 -- Bug 3549475 Added condition to check if there is at least one ACTUAL lines jckwok
10323 IF(UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES','PART_SHIP_LINES')
10324 AND v_ActualCount > 0) THEN
10325 --
10326 RLM_EXTINTERFACE_SV.GetIntransitShippedLines(x_Sched_rec,
10327 x_Group_rec,
10328 v_Key_rec.req_rec,
10329 v_min_horizon_date,
10330 v_InTransitQty);
10331 IF(v_InTransitQty >0 ) THEN
10332 --
10333 v_key_rec.req_rec.shipment_flag := 'SHIPMENT';
10334 StoreShipments(x_Sched_rec,
10335 x_Group_rec,
10336 v_Key_rec,
10337 v_InTransitQty);
10338 --
10339 END IF;
10340 --
10341 END IF;
10342
10343 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
10344 --
10345 v_NewCount := v_NewCount +1;
10346 --
10347 IF (l_debug <> -1) THEN
10348 rlm_core_sv.dlog(k_DEBUG,'v_NewCount', v_NewCount);
10349 END IF;
10350 --
10351 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
10352 v_Key_rec, k_RECONCILE,
10353 v_Key_rec.req_rec.primary_quantity);
10354 END IF;
10355 --
10356 -- When there is a MATCH
10357 ELSE
10358
10359 IF (l_debug <> -1) THEN
10360 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', v_Key_rec.req_rec.line_id);
10361 END IF;
10362 --
10363 IF v_line_id_tmp = v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).lowest_oelineid THEN
10364 --
10365 v_DemandCount := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).match_count;
10366 v_SumOrderedQty := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).sum_qty;
10367 v_line_id_tab(0) := v_line_id_tmp;
10368
10369 --Intransit Based on Shipped Lines
10370 -- Bug 5608510
10371 v_check_partial_flag := 'N' ;
10372 IF (UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES','PART_SHIP_LINES')
10373 AND v_ActualCount > 0) THEN
10374 --
10375 RLM_EXTINTERFACE_SV.GetIntransitShippedLines(x_Sched_rec,
10376 x_Group_rec,
10377 v_Key_rec.req_rec,
10378 v_min_horizon_date,
10379 v_InTransitQty);
10380 --Bug 5608510
10381 IF(v_InTransitQty >0 ) THEN
10382 --
10383 IF (UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) = 'PART_SHIP_LINES' ) THEN
10384
10385 v_total_ordered_qty := 0 ;
10386 v_total_partial_shipped_qty := 0;
10387
10388 BEGIN
10389 SELECT SUM(nvl(ordered_quantity,0)) ,SUM(nvl(shipped_quantity,0))
10390 INTO v_total_ordered_qty, v_total_partial_shipped_qty
10391 FROM oe_order_lines oel
10392 WHERE oel.line_set_id IN
10393 (SELECT ol.line_set_id
10394 FROM oe_order_lines ol
10395 WHERE ol.line_id = v_line_id_tmp);
10396 --
10397 IF (l_debug <> -1) THEN
10398 rlm_core_sv.dlog(k_DEBUG,' Total Order Quantity', v_total_ordered_qty);
10399 rlm_core_sv.dlog(k_DEBUG,' Partial Shipped Quantity' , v_total_partial_shipped_qty);
10400 END IF;
10401 --
10402 EXCEPTION
10403 WHEN OTHERS THEN
10404 --
10405 IF (l_debug <> -1) THEN
10406 rlm_core_sv.dlog(k_DEBUG,'When Other Exception PART_SHIP_LINES',substr(sqlerrm,1,200));
10407 END IF;
10408 --
10409 END;
10410
10411 END IF ;
10412 --
10413 --
10414 IF ((v_InTransitQty < v_total_ordered_qty AND v_total_partial_shipped_qty > 0 )
10415 AND (v_total_ordered_qty > v_Key_rec.req_rec.primary_quantity )) THEN
10416 --
10417 IF v_Key_rec.req_rec.primary_quantity <> 0 THEN
10418 v_check_partial_flag := 'Y';
10419 END IF;
10420 --
10421 IF (l_debug <> -1) THEN
10422 rlm_core_sv.dlog(k_DEBUG,'Intransit Qty ',v_InTransitQty);
10423 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity ',v_Key_rec.req_rec.primary_quantity );
10424 rlm_core_sv.dlog(k_DEBUG,'v_check_partial_flag ',v_check_partial_flag );
10425 END IF;
10426 --
10427 ELSE
10428 --
10429 v_key_rec.req_rec.shipment_flag := 'SHIPMENT';
10430 StoreShipments(x_Sched_rec,
10431 x_Group_rec,
10432 v_Key_rec,
10433 v_InTransitQty);
10434 --
10435 END IF;
10436 --
10437 END IF;
10438 --
10439 END IF ;
10440 --
10441 --bug 5608510
10442 --
10443 IF v_check_partial_flag = 'N' THEN
10444 RLM_TPA_SV.ReconcileAction(x_sched_rec,
10445 x_group_rec,
10446 v_Key_rec,
10447 v_line_id_tab,
10448 v_DemandCount,
10449 v_SumOrderedQty,
10450 k_ATS);
10451 v_line_id_tab.DELETE;
10452 --
10453 END IF;
10454 --
10455 END IF;
10456 --
10457 END IF;
10458 END LOOP;
10459 --
10460 CLOSE c_Matched;
10461 --
10462 g_sch_line_qty :=0; --Bugfix 6159269
10463 IF (l_debug <> -1) THEN
10464 rlm_core_sv.dpop(k_SDEBUG);
10465 END IF;
10466 --
10467 EXCEPTION
10468
10469 WHEN e_group_error THEN
10470 --
10471 IF (l_debug <> -1) THEN
10472 rlm_core_sv.dlog(k_DEBUG,'group error');
10473 rlm_core_sv.dpop(k_SDEBUG);
10474 END IF;
10475 --
10476 raise e_group_error;
10477
10478 WHEN OTHERS THEN
10479 rlm_message_sv.sql_error('rlm_rd_sv.ProcessATS',x_progress);
10480 --
10481 IF (l_debug <> -1) THEN
10482 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10483 END IF;
10484 --
10485 raise;
10486
10487 END ProcessATS;
10488
10489
10490 /*===========================================================================
10491
10492 PROCEDURE ProcessNATS
10493 (1) New version with dynamic sql for performance changes
10494
10495 ===========================================================================*/
10496
10497 PROCEDURE ProcessNATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10498 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
10499 IS
10500
10501 v_Key_rec t_Key_rec;
10502 v_ScheduleType VARCHAR2(30);
10503 v_SumOrderedQty NUMBER DEFAULT 0;
10504 v_SumOrderedQtyTmp NUMBER DEFAULT 0;
10505 v_DemandCount NUMBER DEFAULT 0;
10506 v_LowestOeLineId NUMBER DEFAULT 0;
10507 v_line_id_tab t_matching_line;
10508 v_line_id_tmp NUMBER DEFAULT 0;
10509 --
10510 v_DeleteQty NUMBER;
10511 c_ATS t_Cursor_ref;
10512 c_Matched t_Cursor_ref;
10513 c_Sum t_Cursor_ref;
10514 x_progress VARCHAR2(3) := '010';
10515 v_NewCount NUMBER DEFAULT 0;
10516 v_NatsDemand VARCHAR2(32000);
10517 v_AtsDemand VARCHAR2(32000);
10518 v_SumDemand VARCHAR2(32000);
10519 v_NewDemand VARCHAR2(32000);
10520 v_LineId NUMBER;
10521 v_LineMatch t_Line_Match_Tab;
10522 v_LowestLineId NUMBER;
10523 --
10524 BEGIN
10525 --
10526 IF (l_debug <> -1) THEN
10527 rlm_core_sv.dpush(k_SDEBUG,'ProcessNATS');
10528 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.header_id', x_Sched_rec.header_id);
10529 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
10530 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
10531 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
10532 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
10533 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.industry_attribute15', x_Group_rec.industry_attribute15);
10534 END IF;
10535 --
10536 -- Delete all the bind variable tables
10537 --
10538 g_NewDemandTab.DELETE;
10539 g_WhereTab1.DELETE;
10540 g_WhereTab2.DELETE;
10541 g_BindVarTab.DELETE;
10542 --
10543 RLM_TPA_SV.BuildMatchQuery(x_sched_rec,
10544 x_Group_rec,
10545 k_NATS,
10546 v_NatsDemand,
10547 v_AtsDemand,
10548 v_NewDemand,
10549 v_SumDemand);
10550 --
10551 -- (1) Handle the case when incoming NATS match existing ATS
10552 --
10553 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10554 --
10555 IF (l_debug <> -1) THEN
10556 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_ATSDemand cursor', g_BindVarTab.COUNT);
10557 END IF;
10558 --
10559 RLM_CORE_SV.OpenDynamicCursor(c_ATS, v_ATSDemand, g_BindVarTab);
10560 --
10561 WHILE FetchReq(c_ATS,
10562 v_Key_rec,
10563 v_line_id_tmp,
10564 v_SumOrderedQtyTmp,
10565 v_ScheduleType)
10566 LOOP
10567
10568 EXIT WHEN c_ATS%NOTFOUND;
10569 --
10570 IF (l_debug <> -1) THEN
10571 --
10572 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10573 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10574 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10575 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10576 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10577 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.intmed_ship_to_org_id', v_Key_rec.req_rec.intmed_ship_to_org_id);
10578 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10579 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10580 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10581 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10582 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10583 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10584 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10585 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10586 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10587 --
10588 END IF;
10589
10590 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE, k_CANCEL, k_ADD) THEN
10591 --
10592 v_Key_rec.oe_line_id := v_line_id_tmp;
10593 --
10594 IF (l_debug <> -1) THEN
10595 rlm_core_sv.dlog(k_DEBUG, 'OM NATS Line Id', v_line_id_tmp);
10596 END IF;
10597 --
10598 GetDemand(v_Key_rec, x_Group_rec);
10599 --
10600 IF SchedulePrecedence(x_Group_rec, x_Sched_rec, v_ScheduleType) THEN
10601 --
10602 DeleteRequirement(x_Sched_rec, x_Group_rec,
10603 v_Key_rec, k_RECONCILE,
10604 v_DeleteQty);
10605 --
10606 END IF;
10607 --
10608 END IF;
10609 --
10610 END LOOP;
10611 --
10612 CLOSE c_ATS;
10613 --
10614 -- (2) Find all the ATS and NATS demand that matches in OM
10615 --
10616 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10617 --
10618 IF (l_debug <> -1) THEN
10619 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_SumDemand cursor', g_BindVarTab.COUNT);
10620 END IF;
10621 --
10622 RLM_CORE_SV.OpenDynamicCursor(c_Sum, v_SumDemand, g_BindVarTab);
10623 --
10624 FETCH c_Sum INTO v_LowestLineId,
10625 v_SumOrderedQtyTmp,
10626 v_DemandCount,
10627 v_LowestOeLineId;
10628 --
10629 IF c_Sum%FOUND THEN
10630 --
10631 v_LineMatch(0).sum_qty := v_SumOrderedQtyTmp;
10632 v_LineMatch(0).match_count := v_DemandCount;
10633 v_LineMatch(0).lowest_oelineid := v_LowestOeLineId;
10634 --
10635 IF (l_debug <> -1) THEN
10636 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10637 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10638 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10639 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10640 END IF;
10641 --
10642 LOOP
10643 FETCH c_Sum INTO v_LineId,
10644 v_SumOrderedQtyTmp,
10645 v_DemandCount,
10646 v_LowestOeLineId;
10647 EXIT WHEN c_Sum%NOTFOUND;
10648 v_LineMatch(v_LineId-v_LowestLineId).sum_qty := v_SumOrderedQtyTmp;
10649 v_LineMatch(v_LineId-v_LowestLineId).match_count := v_DemandCount;
10650 v_LineMatch(v_LineId-v_LowestLineId).lowest_oelineid := v_LowestOeLineId;
10651 --
10652 IF (l_debug <> -1) THEN
10653 rlm_core_sv.dlog(k_DEBUG,'RLM Line Id', v_LineId);
10654 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10655 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10656 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10657 END IF;
10658 --
10659 END LOOP;
10660 --
10661 END IF;
10662 --
10663 --
10664 IF v_LineMatch.COUNT > 0 THEN
10665 --
10666 -- (3) Find all NATS demand that matched
10667 --
10668 g_BindVarTab := BuildBindVarTab5(g_WhereTab1, g_WhereTab2, g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10669 --
10670 IF (l_debug <> -1) THEN
10671 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NATS cursor', g_BindVarTab.COUNT);
10672 rlm_core_sv.dlog(k_DEBUG, 'Opening for v_NATSDemand');
10673 END IF;
10674 --
10675 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NatsDemand, g_BindVarTab);
10676 --
10677 ELSE
10678 --
10679 -- (4) Find all NATS demand that did not match in OM
10680 --
10681 g_BindVarTab := BuildBindVarTab3(g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10682 --
10683 IF (l_debug <> -1) THEN
10684 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NewDemand cursor', g_BindVarTab.COUNT);
10685 rlm_core_sv.dlog(k_DEBUG,'Opening for v_NewDemand');
10686 END IF;
10687 --
10688 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NewDemand, g_BindVarTab);
10689 --
10690 END IF;
10691 --
10692 WHILE FetchReq(c_Matched,
10693 v_Key_rec,
10694 v_line_id_tmp,
10695 v_SumOrderedQtyTmp,
10696 v_ScheduleType)
10697 LOOP
10698
10699 EXIT WHEN c_Matched%NOTFOUND;
10700 --
10701 IF (l_debug <> -1) THEN
10702 --
10703 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10704 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10705 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10706 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10707 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10708 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.intmed_ship_to_org_id', v_Key_rec.req_rec.intmed_ship_to_org_id);
10709 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10710 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10711 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10712 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10713 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10714 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10715 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10716 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10717 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10718 --
10719 END IF;
10720 --
10721 g_sch_line_qty := v_Key_rec.req_rec.primary_quantity; --Bugfix 6159269
10722 -- When there is NO MATCH
10723 IF v_line_id_tmp IS NULL THEN
10724
10725 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
10726 --
10727 v_NewCount := v_NewCount +1;
10728 --
10729 IF (l_debug <> -1) THEN
10730 rlm_core_sv.dlog(k_DEBUG,'v_NewCount', v_NewCount);
10731 END IF;
10732 --
10733 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
10734 v_Key_rec, k_RECONCILE,
10735 v_Key_rec.req_rec.primary_quantity);
10736 END IF;
10737
10738 -- When there is a MATCH
10739 ELSE
10740 --
10741 IF (l_debug <> -1) THEN
10742 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', v_Key_rec.req_rec.line_id);
10743 END IF;
10744 --
10745 IF v_line_id_tmp = v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).lowest_oelineid THEN
10746 v_DemandCount := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).match_count;
10747 v_SumOrderedQty := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).sum_qty;
10748 v_line_id_tab(0) := v_line_id_tmp;
10749 --
10750 RLM_TPA_SV.ReconcileAction(x_sched_rec,
10751 x_group_rec,
10752 v_Key_rec,
10753 v_line_id_tab,
10754 v_DemandCount,
10755 v_SumOrderedQty,
10756 k_NATS);
10757 v_line_id_tab.DELETE;
10758 --
10759 END IF;
10760 --
10761 END IF;
10762 --
10763 END LOOP;
10764 --
10765 CLOSE c_Matched;
10766 --
10767 g_sch_line_qty :=0; --Bugfix 6159269
10768 --
10769 IF (l_debug <> -1) THEN
10770 rlm_core_sv.dpop(k_SDEBUG);
10771 END IF;
10772 --
10773 EXCEPTION
10774
10775 WHEN e_group_error THEN
10776 --
10777 IF (l_debug <> -1) THEN
10778 rlm_core_sv.dlog(k_DEBUG,'group error');
10779 rlm_core_sv.dpop(k_SDEBUG);
10780 END IF;
10781 --
10782 raise e_group_error;
10783
10784 WHEN OTHERS THEN
10785 rlm_message_sv.sql_error('rlm_rd_sv.ProcessNATS',x_progress);
10786 --
10787 IF (l_debug <> -1) THEN
10788 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10789 END IF;
10790 --
10791 raise;
10792
10793 END ProcessNATS;
10794
10795
10796 /*===========================================================================
10797
10798 PROCEDURE UpdateDemand
10799
10800 ===========================================================================*/
10801 PROCEDURE UpdateDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10802 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
10803 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
10804 x_SumOrderedQty IN NUMBER,
10805 x_DemandType IN VARCHAR2)
10806 IS
10807
10808 v_QtyDelta NUMBER;
10809 v_Qty_rec t_Qty_rec;
10810 v_Demand_ref t_Cursor_ref;
10811 v_DeleteQty NUMBER;
10812 x_progress VARCHAR2(3) := '010';
10813
10814 BEGIN
10815 --
10816 IF (l_debug <> -1) THEN
10817 rlm_core_sv.dpush(k_SDEBUG,'UpdateDemand');
10818 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty', x_SumOrderedQty);
10819 rlm_core_sv.dlog(k_DEBUG,'x_DemandType', x_DemandType);
10820 END IF;
10821 --
10822 RLM_TPA_SV.ReconcileShipments(x_Group_rec,
10823 x_Key_rec,
10824 x_Key_rec.req_rec.primary_quantity);
10825 --
10826 Reconcile(x_Group_rec,
10827 x_Key_rec,
10828 x_Key_rec.req_rec.primary_quantity);
10829 --
10830 InitializeDemand(x_Sched_rec,
10831 x_Group_rec,
10832 x_Key_rec,
10833 v_Demand_ref,
10834 x_DemandType);
10835 --
10836 IF (l_debug <> -1) THEN
10837 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
10838 x_key_rec.req_rec.primary_quantity);
10839 END IF;
10840 --
10841 CheckTolerance(x_Sched_rec,
10842 x_Group_rec,
10843 x_Key_rec,
10844 x_SumOrderedQty,
10845 x_key_rec.req_rec.primary_quantity);
10846 --
10847 IF x_Key_rec.req_rec.primary_quantity <= 0 THEN
10848 --
10849 g_del_reconcile := 'Y'; --Bugfix 6131516
10850 RLM_TPA_SV.DeleteDemand(x_Sched_rec,
10851 x_Group_rec,
10852 x_Key_rec,
10853 v_Demand_ref);
10854 --
10855 ELSIF x_Key_rec.req_rec.primary_quantity > x_SumOrderedQty THEN
10856 --
10857 RLM_TPA_SV.IncreaseDemand(x_Sched_rec,
10858 x_Group_rec,
10859 x_Key_rec,
10860 v_Demand_ref,
10861 x_SumOrderedQty);
10862 --
10863 ELSIF x_Key_rec.req_rec.primary_quantity < x_SumOrderedQty THEN
10864 --
10865 RLM_TPA_SV.DecreaseDemand(x_Sched_rec,
10866 x_Group_rec,
10867 x_Key_rec,
10868 v_Demand_ref,
10869 x_SumOrderedQty);
10870 --
10871 ELSIF x_Key_rec.req_rec.primary_quantity = x_SumOrderedQty THEN
10872 --
10873 RLM_TPA_SV.OtherDemand(x_Sched_rec,
10874 x_Group_rec,
10875 x_Key_rec,
10876 v_Demand_ref);
10877 --
10878 END IF;
10879 CLOSE v_Demand_ref;
10880 --
10881 IF (l_debug <> -1) THEN
10882 rlm_core_sv.dpop(k_SDEBUG);
10883 END IF;
10884 --
10885 EXCEPTION
10886 WHEN OTHERS THEN
10887 rlm_message_sv.sql_error('rlm_rd_sv.UpdateDemand',x_progress);
10888 --
10889 IF (l_debug <> -1) THEN
10890 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10891 END IF;
10892 --
10893 raise;
10894
10895 END UpdateDemand;
10896
10897
10898 /*===========================================================================
10899
10900 PROCEDURE DeleteDemand
10901
10902 ===========================================================================*/
10903 PROCEDURE DeleteDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10904 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
10905 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
10906 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref)
10907 IS
10908
10909 v_DeleteQty NUMBER;
10910 x_progress VARCHAR2(3) := '010';
10911
10912 BEGIN
10913 --
10914 IF (l_debug <> -1) THEN
10915 rlm_core_sv.dpush(k_SDEBUG,'DeleteDemand');
10916 END IF;
10917 --
10918 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
10919 --
10920 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
10921 --
10922 DeleteRequirement(x_Sched_rec, x_Group_rec,
10923 x_Key_rec, k_RECONCILE,
10924 v_DeleteQty);
10925 --
10926 END IF;
10927 --
10928 END LOOP;
10929 --
10930 g_del_reconcile := 'N'; --Bugfix 6131516
10931 --
10932 IF (l_debug <> -1) THEN
10933 rlm_core_sv.dpop(k_SDEBUG);
10934 END IF;
10935 --
10936 EXCEPTION
10937
10938 WHEN e_group_error THEN
10939 --
10940 IF (l_debug <> -1) THEN
10941 rlm_core_sv.dlog(k_DEBUG,'group error');
10942 rlm_core_sv.dpop(k_SDEBUG);
10943 END IF;
10944 --
10945 raise e_group_error;
10946
10947 WHEN OTHERS THEN
10948 rlm_message_sv.sql_error('rlm_rd_sv.DeleteDemand',x_progress);
10949 --
10950 IF (l_debug <> -1) THEN
10951 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10952 END IF;
10953 --
10954 raise;
10955
10956 END DeleteDemand;
10957
10958
10959 /*===========================================================================
10960
10961 PROCEDURE IncreaseDemand
10962
10963 ===========================================================================*/
10964 PROCEDURE IncreaseDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10965 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
10966 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
10967 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref,
10968 x_SumOrderedQty IN NUMBER)
10969 IS
10970 --
10971 v_QtyDelta NUMBER;
10972 v_Qty_rec t_Qty_rec;
10973 x_progress VARCHAR2(3) := '010';
10974 IsSchedulePrecedence BOOLEAN := TRUE;
10975 v_Index NUMBER := 0;
10976 v_MatchAttrTxt VARCHAR2(2000); --Bugfix 6159269
10977 --
10978 BEGIN
10979 --
10980 IF (l_debug <> -1) THEN
10981 rlm_core_sv.dpush(k_SDEBUG,'IncreaseDemand');
10982 END IF;
10983 --
10984 v_QtyDelta := x_Key_rec.req_rec.primary_quantity - x_SumOrderedQty;
10985 --
10986 IF (l_debug <> -1) THEN
10987 rlm_core_sv.dlog(k_DEBUG,'v_QtyDelta',v_QtyDelta);
10988 END IF;
10989 --
10990 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
10991 --
10992 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
10993 --
10994 IF (l_debug <> -1) THEN
10995 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.ordered_quantity',
10996 x_Key_rec.dem_rec.ordered_quantity);
10997 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.dem_rec.line_id',
10998 x_Key_rec.dem_rec.line_id);
10999 rlm_core_sv.dlog(k_DEBUG,'New Schedule of higher Precedence -- TRUE');
11000 END IF;
11001 --
11002 IsSchedulePrecedence := TRUE;
11003 --
11004 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
11005 --
11006 IF v_QtyDelta > 0 AND NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE,
11007 x_Key_rec.dem_rec.ordered_quantity + v_QtyDelta) THEN
11008
11009 IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11010 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) THEN
11011 --
11012 UpdateRequirement(x_Sched_rec, x_Group_rec,
11013 x_Key_rec, x_Key_rec.dem_rec.ordered_quantity + v_QtyDelta);
11014 v_QtyDelta := 0;
11015 --
11016 --Bugfix 6159269 START
11017 ELSE
11018
11019 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN
11020 g_inc_exception := 'Y';
11021 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11022 --
11023 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11024 --
11025 rlm_message_sv.app_error(
11026 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11027 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11028 x_InterfaceHeaderId => x_sched_rec.header_id,
11029 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11030 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11031 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11032 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11033 x_OrderLineId => x_key_rec.dem_rec.line_id,
11034 x_Token1 => 'LINE',
11035 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11036 x_Token2 => 'ORDER',
11037 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11038 x_Token3 => 'QUANTITY',
11039 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11040 x_Token4 => 'CUSTITEM',
11041 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11042 x_Token5 => 'REQ_DATE',
11043 x_value5 => x_key_rec.dem_rec.request_date,
11044 x_Token6 => 'SCH_LINE_QTY',
11045 x_value6 => g_sch_line_qty,
11046 x_Token7 => 'SEQ_INFO',
11047 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11048 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11049 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11050 x_Token8 => 'MATCH_ATTR',
11051 x_value8 => v_MatchAttrTxt);
11052 --
11053 IF (l_debug <> -1) THEN
11054 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11055 x_key_rec.req_rec.line_id);
11056 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11057 x_key_rec.req_rec.line_id);
11058 END IF;
11059 --
11060 ELSE
11061 --
11062 rlm_message_sv.app_error(
11063 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11064 x_MessageName => 'RLM_FROZEN_UPDATE',
11065 x_InterfaceHeaderId => x_sched_rec.header_id,
11066 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11067 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11068 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11069 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11070 x_OrderLineId => x_key_rec.dem_rec.line_id,
11071 x_Token1 => 'LINE',
11072 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11073 x_Token2 => 'ORDER',
11074 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11075 x_Token3 => 'QUANTITY',
11076 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11077 x_Token4 => 'CUSTITEM',
11078 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11079 x_Token5 => 'REQ_DATE',
11080 x_value5 => x_key_rec.dem_rec.request_date,
11081 x_Token6 => 'SCH_LINE_QTY',
11082 x_value6 => g_sch_line_qty,
11083 x_Token7 => 'MATCH_ATTR',
11084 x_value7 => v_MatchAttrTxt);
11085 --
11086 IF (l_debug <> -1) THEN
11087 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11088 x_key_rec.req_rec.line_id);
11089 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11090 x_key_rec.req_rec.line_id);
11091 END IF;
11092 --
11093 END IF; /* Exception */
11094
11095 END IF; /* Check g_sch_line_qty */
11096 --
11097 END IF; /* IsFrozen */
11098
11099 END IF; /* v_QtyDelta AND ProcessConstraint */
11100 --
11101 --Bugfix 6159269 END
11102 --
11103 -- Bug 3919971 : Add OE line to g_Accounted_tab, so DSP will not
11104 -- try to reconcile against the quantity again.
11105 -- Need to be accounted only after update requirement call
11106
11107 v_Index := g_Accounted_tab.COUNT+1;
11108 g_Accounted_tab(v_Index) := x_Key_rec.dem_rec;
11109 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11110 ELSE
11111 --
11112 IsSchedulePrecedence := FALSE;
11113 --
11114 IF (l_debug <> -1) THEN
11115 rlm_core_sv.dlog(k_DEBUG,'New Schedule of Lower Precedence -- FALSE');
11116 END IF;
11117 --
11118 END IF;
11119 --
11120 END LOOP;
11121 --
11122 IF v_QtyDelta <> 0 AND IsSchedulePrecedence THEN
11123 --
11124 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
11125 x_Key_rec, k_NORECONCILE, v_QtyDelta);
11126 --
11127 END IF;
11128 g_inc_exception := 'N'; --Bugfix 6159269
11129 --
11130 IF (l_debug <> -1) THEN
11131 rlm_core_sv.dpop(k_SDEBUG);
11132 END IF;
11133 --
11134 EXCEPTION
11135 WHEN OTHERS THEN
11136 rlm_message_sv.sql_error('rlm_rd_sv.IncreaseDemand',x_progress);
11137 --
11138 IF (l_debug <> -1) THEN
11139 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11140 END IF;
11141 --
11142 raise;
11143
11144 END IncreaseDemand;
11145
11146
11147 /*===========================================================================
11148
11149 PROCEDURE DecreaseDemand
11150
11151 ===========================================================================*/
11152 PROCEDURE DecreaseDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11153 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11154 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11155 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref,
11156 x_SumOrderedQty IN NUMBER)
11157 IS
11158
11159 v_QtyDelta NUMBER;
11160 v_Qty_rec t_Qty_rec;
11161 v_DeleteQty NUMBER;
11162 x_progress VARCHAR2(3) := '010';
11163 v_Index NUMBER := 0;
11164 v_MatchAttrTxt VARCHAR2(2000); --Bugfix 6159269
11165 BEGIN
11166 --
11167 IF (l_debug <> -1) THEN
11168 rlm_core_sv.dpush(k_SDEBUG,'DecreaseDemand');
11169 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty',x_SumOrderedQty);
11170 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.primary_quantity',
11171 x_Key_rec.req_rec.primary_quantity);
11172 END IF;
11173 --
11174 v_QtyDelta := x_SumOrderedQty - x_Key_rec.req_rec.primary_quantity;
11175 --
11176 IF (l_debug <> -1) THEN
11177 rlm_core_sv.dlog(k_DEBUG,'v_QtyDelta',v_QtyDelta);
11178 END IF;
11179 --
11180 WHILE FetchDemand(x_Demand_ref, x_Key_rec) AND v_QtyDelta >0 LOOP
11181 --
11182 IF (l_debug <> -1) THEN
11183 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.ordered_quantity',x_Key_rec.dem_rec.ordered_quantity);
11184 END IF;
11185 --
11186 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11187 --
11188 IF v_QtyDelta >= x_Key_rec.dem_rec.ordered_quantity THEN
11189 --
11190 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_DELETE,
11191 x_Key_rec.dem_rec.ordered_quantity-v_QtyDelta)
11192 AND NOT
11193 (IsFrozen(TRUNC(SYSDATE), x_Group_rec,
11194 x_Key_rec.dem_rec.request_date) OR
11195 IsFrozen(TRUNC(SYSDATE), x_Group_rec,
11196 x_Key_rec.dem_rec.schedule_date)) THEN
11197 --
11198 DeleteRequirement(x_Sched_rec, x_Group_rec,
11199 x_Key_rec, k_RECONCILE,
11200 v_DeleteQty);
11201 v_QtyDelta := v_QtyDelta - x_Key_rec.dem_rec.ordered_quantity;
11202 --
11203 END IF;
11204 --
11205 ELSIF v_QtyDelta > 0 THEN
11206 --
11207 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
11208 --
11209 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE, x_Key_rec.dem_rec.ordered_quantity - v_QtyDelta) THEN
11210
11211 IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11212 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) THEN
11213
11214 UpdateRequirement(x_Sched_rec, x_Group_rec, x_Key_rec, x_Key_rec.dem_rec.ordered_quantity - v_QtyDelta);
11215 --
11216 v_QtyDelta := 0;
11217 --
11218 --Bugfix 6159269 START
11219 ELSE
11220
11221 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN
11222 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11223 --
11224 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11225 --
11226 rlm_message_sv.app_error(
11227 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11228 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11229 x_InterfaceHeaderId => x_sched_rec.header_id,
11230 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11231 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11232 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11233 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11234 x_OrderLineId => x_key_rec.dem_rec.line_id,
11235 x_Token1 => 'LINE',
11236 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11237 x_Token2 => 'ORDER',
11238 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11239 x_Token3 => 'QUANTITY',
11240 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11241 x_Token4 => 'CUSTITEM',
11242 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11243 x_Token5 => 'REQ_DATE',
11244 x_value5 => x_key_rec.dem_rec.request_date,
11245 x_Token6 => 'SCH_LINE_QTY',
11246 x_value6 => g_sch_line_qty,
11247 x_Token7 => 'SEQ_INFO',
11248 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11249 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11250 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11251 x_Token8 => 'MATCH_ATTR',
11252 x_value8 => v_MatchAttrTxt);
11253 --
11254 IF (l_debug <> -1) THEN
11255 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11256 x_key_rec.req_rec.line_id);
11257 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11258 x_key_rec.req_rec.line_id);
11259 END IF;
11260 --
11261 ELSE
11262 --
11263 rlm_message_sv.app_error(
11264 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11265 x_MessageName => 'RLM_FROZEN_UPDATE',
11266 x_InterfaceHeaderId => x_sched_rec.header_id,
11267 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11268 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11269 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11270 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11271 x_OrderLineId => x_key_rec.dem_rec.line_id,
11272 x_Token1 => 'LINE',
11273 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11274 x_Token2 => 'ORDER',
11275 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11276 x_Token3 => 'QUANTITY',
11277 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11278 x_Token4 => 'CUSTITEM',
11279 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11280 x_Token5 => 'REQ_DATE',
11281 x_value5 => x_key_rec.dem_rec.request_date,
11282 x_Token6 => 'SCH_LINE_QTY',
11283 x_value6 => g_sch_line_qty,
11284 x_Token7 => 'MATCH_ATTR',
11285 x_value7 => v_MatchAttrTxt);
11286 --
11287 IF (l_debug <> -1) THEN
11288 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11289 x_key_rec.req_rec.line_id);
11290 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11291 x_key_rec.req_rec.line_id);
11292 END IF;
11293 --
11294 END IF; /* Exception */
11295
11296 END IF; /* g_sch_line_qty */
11297
11298 END IF; /* IsFrozen */
11299 --
11300 END IF; /* ProcessConstraint */
11301 --Bugfix 6159269 END
11302 --
11303 END IF;
11304 --
11305 -- Bug 3919971, 3999833 : Add OE line to g_Accounted_tab so DSP will
11306 -- not attempt reconciling this quantity again
11307 --
11308 v_Index := g_Accounted_Tab.COUNT+1;
11309 g_Accounted_tab(v_Index):= x_Key_rec.dem_rec;
11310 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11311 --
11312 END IF;
11313 --
11314 END LOOP;
11315 --
11316 IF v_QtyDelta <> 0 THEN
11317 -- irreconcileable differences
11318 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
11319 v_QtyDelta);
11320 END IF;
11321 --
11322 IF (l_debug <> -1) THEN
11323 rlm_core_sv.dpop(k_SDEBUG);
11324 END IF;
11325 --
11326 EXCEPTION
11327
11328 WHEN e_group_error THEN
11329 --
11330 IF (l_debug <> -1) THEN
11331 rlm_core_sv.dlog(k_DEBUG,'group error');
11332 rlm_core_sv.dpop(k_SDEBUG);
11333 END IF;
11334 --
11335 raise e_group_error;
11336
11337 WHEN OTHERS THEN
11338 rlm_message_sv.sql_error('rlm_rd_sv.DecreaseDemand',x_progress);
11339 --
11340 IF (l_debug <> -1) THEN
11341 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11342 END IF;
11343 --
11344 raise;
11345
11346 END DecreaseDemand;
11347
11348
11349 /*===========================================================================
11350
11351 PROCEDURE OtherDemand
11352
11353 ===========================================================================*/
11354 PROCEDURE OtherDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11355 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11356 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11357 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref)
11358 IS
11359
11360 v_Qty_rec t_Qty_rec;
11361 x_progress VARCHAR2(3) := '010';
11362 v_Index NUMBER;
11363 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
11364 BEGIN
11365 --
11366 IF (l_debug <> -1) THEN
11367 rlm_core_sv.dpush(k_SDEBUG,'OtherDemand');
11368 END IF;
11369 --
11370 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
11371 --
11372 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11373 --
11374 -- Bug 3919971 : Add OE line to g_Accounted_Tab so DSP will
11375 -- not attempt to reconcile the quantity again
11376 --
11377 v_Index := g_Accounted_tab.COUNT+1;
11378 g_Accounted_Tab(v_Index) := x_Key_rec.dem_rec;
11379 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11380 --
11381 IF (l_debug <> -1) THEN
11382 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.dem_rec.ordered_quantity',
11383 x_Key_rec.dem_rec.ordered_quantity);
11384 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.primary_quantity',
11385 x_Key_rec.req_rec.primary_quantity);
11386 END IF;
11387
11388 --bug2308608
11389
11390 --IF AttributeChange(x_Key_rec) THEN
11391
11392 -- Bug 2802487
11393 -- Changes:
11394 -- (1) Pass x_Key_rec.dem_rec.ordered_quantity to
11395 -- ProcessConstraint instead of passing 0 quantity.
11396 -- (2) Pass x_Key_rec.dem_rec.ordered_quantity to
11397 -- UpdateRequirement.
11398 -- Result: if primary quantity equals SumOrderedQty,
11399 -- update SO line with the same existing quantity,
11400 -- or in other words, no ordered qty update would occur at all.
11401 -- Also update SO line with any attribute changes.
11402
11403 -- Bug 4297984 Start
11404 IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11405 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) THEN
11406 --
11407 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE_ATTR,
11408 x_Key_rec.dem_rec.ordered_quantity) THEN
11409 --
11410 UpdateRequirement(x_Sched_rec, x_Group_rec, x_Key_rec,
11411 x_Key_rec.dem_rec.ordered_quantity);
11412 --
11413 ELSE
11414 --
11415 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11416 --
11417 IF (x_Key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11418 --
11419 rlm_message_sv.app_error(
11420 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11421 x_MessageName => 'RLM_UNABLE_ATTR_UPDATE_SEQ',
11422 x_InterfaceHeaderId => x_sched_rec.header_id,
11423 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
11424 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11425 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
11426 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11427 x_OrderLineId => x_Key_rec.dem_rec.line_id,
11428 x_Token1 => 'LINE',
11429 x_value1 =>rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
11430 x_Token2 => 'ORDER',
11431 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11432 x_Token3 => 'QUANTITY',
11433 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
11434 x_Token4 => 'CUSTITEM',
11435 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11436 x_Token5 => 'REQ_DATE',
11437 x_value5 => x_key_rec.dem_rec.request_date,
11438 x_Token6 => 'SEQ_INFO',
11439 x_value6 => nvl(x_key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11440 nvl(x_key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11441 nvl(x_key_rec.dem_rec.customer_job,'NULL'),
11442 x_Token7 => 'MATCH_ATTR',
11443 x_value7 => v_MatchAttrTxt);
11444 --
11445 IF (l_debug <> -1) THEN
11446 rlm_core_sv.dlog(k_DEBUG,'Process Constraints on line',
11447 x_key_rec.req_rec.line_id);
11448 rlm_core_sv.dlog(k_DEBUG,'RLM_UNABLE_ATTR_UPDATE_SEQ',
11449 x_key_rec.req_rec.line_id);
11450 END IF;
11451 --
11452 ELSE
11453 --
11454 rlm_message_sv.app_error(
11455 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11456 x_MessageName => 'RLM_UNABLE_ATTR_UPDATE',
11457 x_InterfaceHeaderId => x_sched_rec.header_id,
11458 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
11459 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11460 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
11461 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11462 x_OrderLineId => x_Key_rec.dem_rec.line_id,
11463 x_Token1 => 'LINE',
11464 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
11465 x_Token2 => 'ORDER',
11466 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11467 x_Token3 => 'QUANTITY',
11468 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
11469 x_Token4 => 'CUSTITEM',
11470 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11471 x_Token5 => 'REQ_DATE',
11472 x_value5 => x_key_rec.dem_rec.request_date,
11473 x_Token6 => 'MATCH_ATTR',
11474 x_value6 => v_MatchAttrTxt);
11475 --
11476 IF (l_debug <> -1) THEN
11477 rlm_core_sv.dlog(k_DEBUG,'Process Constraints on line',
11478 x_key_rec.req_rec.line_id);
11479 rlm_core_sv.dlog(k_DEBUG,'RLM_UNABLE_ATTR_UPDATE',
11480 x_key_rec.req_rec.line_id);
11481 END IF;
11482 --
11483 END IF;
11484 --
11485 END IF;
11486 --
11487 ELSE
11488 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
11489 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11490 --
11491 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11492 --
11493 rlm_message_sv.app_error(
11494 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11495 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11496 x_InterfaceHeaderId => x_sched_rec.header_id,
11497 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11498 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11499 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11500 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11501 x_OrderLineId => x_key_rec.dem_rec.line_id,
11502 x_Token1 => 'LINE',
11503 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11504 x_Token2 => 'ORDER',
11505 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11506 x_Token3 => 'QUANTITY',
11507 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11508 x_Token4 => 'CUSTITEM',
11509 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11510 x_Token5 => 'REQ_DATE',
11511 x_value5 => x_key_rec.dem_rec.request_date,
11512 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
11513 x_value6 => g_sch_line_qty, --Bugfix 6159269
11514 x_Token7 => 'SEQ_INFO',
11515 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11516 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11517 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11518 x_Token8 => 'MATCH_ATTR',
11519 x_value8 => v_MatchAttrTxt);
11520 --
11521 IF (l_debug <> -1) THEN
11522 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11523 x_key_rec.req_rec.line_id);
11524 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11525 x_key_rec.req_rec.line_id);
11526 END IF;
11527 --
11528 ELSE
11529 --
11530 rlm_message_sv.app_error(
11531 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11532 x_MessageName => 'RLM_FROZEN_UPDATE',
11533 x_InterfaceHeaderId => x_sched_rec.header_id,
11534 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11535 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11536 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11537 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11538 x_OrderLineId => x_key_rec.dem_rec.line_id,
11539 x_Token1 => 'LINE',
11540 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11541 x_Token2 => 'ORDER',
11542 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11543 x_Token3 => 'QUANTITY',
11544 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11545 x_Token4 => 'CUSTITEM',
11546 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11547 x_Token5 => 'REQ_DATE',
11548 x_value5 => x_key_rec.dem_rec.request_date,
11549 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
11550 x_value6 => g_sch_line_qty, --Bugfix 6159269
11551 x_Token7 => 'MATCH_ATTR',
11552 x_value7 => v_MatchAttrTxt);
11553 --
11554 IF (l_debug <> -1) THEN
11555 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11556 x_key_rec.req_rec.line_id);
11557 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11558 x_key_rec.req_rec.line_id);
11559 END IF;
11560 --
11561 END IF;
11562 END IF; --Bugfix 6159269
11563 --
11564 END IF; /* IsFrozen */
11565 -- Bug 4297984 End
11566 END IF;
11567 --
11568 END LOOP;
11569 --
11570 IF (l_debug <> -1) THEN
11571 rlm_core_sv.dpop(k_SDEBUG);
11572 END IF;
11573 --
11574 EXCEPTION
11575 WHEN OTHERS THEN
11576 rlm_message_sv.sql_error('rlm_rd_sv.OtherDemand',x_progress);
11577 --
11578 IF (l_debug <> -1) THEN
11579 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11580 END IF;
11581 --
11582 raise;
11583
11584 END OtherDemand;
11585
11586
11587 /*===========================================================================
11588
11589 PROCEDURE SetOperation
11590
11591 ===========================================================================*/
11592 PROCEDURE SetOperation(x_Key_rec IN RLM_RD_SV.t_Key_rec,
11593 x_Operation IN VARCHAR2,
11594 x_Quantity IN NUMBER := NULL)
11595 IS
11596
11597 v_Index NUMBER;
11598 x_progress VARCHAR2(3) := '010';
11599 --pdue
11600 v_line_id_tab t_matching_line;
11601
11602 BEGIN
11603 --
11604 IF (l_debug <> -1) THEN
11605 rlm_core_sv.dpush(k_SDEBUG,'SetOperation');
11606 rlm_core_sv.dlog(k_DEBUG, 'x_Quantity',
11607 x_Quantity);
11608 END IF;
11609 --
11610 IF x_Operation = k_DELETE THEN
11611 --pdue, global_atp
11612 v_line_id_tab(0) := x_Key_rec.dem_rec.line_id;
11613 IF NOT AlreadyUpdated(v_line_id_tab) THEN
11614 --
11615 v_Index := g_Op_tab_Unschedule.COUNT + 1;
11616 g_Op_tab_Unschedule(v_Index) := x_Key_rec.dem_rec;
11617 g_Op_tab_Unschedule(v_Index).operation := OE_GLOBALS.G_OPR_DELETE;
11618 g_Op_tab_Unschedule(v_Index).ordered_quantity := x_Quantity;
11619 --
11620 IF (l_debug <> -1) THEN
11621 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).line_id',
11622 g_Op_tab_Unschedule(v_Index).line_id);
11623 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).operation',
11624 g_Op_tab_Unschedule(v_Index).operation);
11625 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ship_to_org_id',
11626 g_Op_tab_Unschedule(v_Index).ship_to_org_id);
11627 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).invoice_to_org_id',
11628 g_Op_tab_Unschedule(v_Index).invoice_to_org_id);
11629 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).inventory_item_id',
11630 g_Op_tab_Unschedule(v_Index).inventory_item_id);
11631 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).schedule_date',
11632 g_Op_tab_Unschedule(v_Index).schedule_date);
11633 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).request_date',
11634 g_Op_tab_Unschedule(v_Index).request_date);
11635 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ordered_quantity',
11636 g_Op_tab_Unschedule(v_Index).ordered_quantity);
11637 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).UOM_code',
11638 g_Op_tab_Unschedule(v_Index).UOM_code);
11639 END IF;
11640 --
11641 END IF;
11642 --
11643 ELSE
11644
11645 IF x_Operation = k_INSERT THEN
11646 --pdue
11647 v_Index := g_Op_tab.COUNT + 1;
11648 g_Op_tab(v_Index) := x_Key_rec.req_rec;
11649 g_Op_tab(v_Index).line_id := NULL;
11650 g_Op_tab(v_Index).operation := OE_GLOBALS.G_OPR_CREATE;
11651 g_Op_tab(v_Index).ordered_quantity := x_Quantity;
11652 --
11653 ELSIF x_Operation = k_UPDATE THEN
11654 --pdue, global_atp
11655 IF x_Quantity < x_Key_rec.dem_rec.ordered_quantity THEN
11656 --
11657 v_Index := g_Op_tab_Unschedule.COUNT + 1;
11658 g_Op_tab_Unschedule(v_Index) := x_Key_rec.req_rec;
11659 g_Op_tab_Unschedule(v_Index).operation := OE_GLOBALS.G_OPR_UPDATE;
11660 g_Op_tab_Unschedule(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11661 g_Op_tab_Unschedule(v_Index).ordered_quantity := x_Quantity;
11662 --
11663 IF (l_debug <> -1) THEN
11664 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).line_id',
11665 g_Op_tab_Unschedule(v_Index).line_id);
11666 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).operation',
11667 g_Op_tab_Unschedule(v_Index).operation);
11668 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ship_to_org_id',
11669 g_Op_tab_Unschedule(v_Index).ship_to_org_id);
11670 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).invoice_to_org_id',
11671 g_Op_tab_Unschedule(v_Index).invoice_to_org_id);
11672 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).inventory_item_id',
11673 g_Op_tab_Unschedule(v_Index).inventory_item_id);
11674 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).schedule_date',
11675 g_Op_tab_Unschedule(v_Index).schedule_date);
11676 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).request_date',
11677 g_Op_tab_Unschedule(v_Index).request_date);
11678 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ordered_quantity',
11679 g_Op_tab_Unschedule(v_Index).ordered_quantity);
11680 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).UOM_code',
11681 g_Op_tab_Unschedule(v_Index).UOM_code);
11682 END IF;
11683 --
11684 ELSE
11685 --
11686 v_Index := g_Op_tab.COUNT + 1;
11687 g_Op_tab(v_Index) := x_Key_rec.req_rec;
11688 g_Op_tab(v_Index).operation := OE_GLOBALS.G_OPR_UPDATE;
11689 g_Op_tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11690 g_Op_tab(v_Index).ordered_quantity := x_Quantity;
11691 --
11692 IF (l_debug <> -1) THEN
11693 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).line_id',
11694 g_Op_tab(v_Index).line_id);
11695 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).operation',
11696 g_Op_tab(v_Index).operation);
11697 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).ship_to_org_id',
11698 g_Op_tab(v_Index).ship_to_org_id);
11699 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).invoice_to_org_id',
11700 g_Op_tab(v_Index).invoice_to_org_id);
11701 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).inventory_item_id',
11702 g_Op_tab(v_Index).inventory_item_id);
11703 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).schedule_date',
11704 g_Op_tab(v_Index).schedule_date);
11705 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).request_date',
11706 g_Op_tab(v_Index).request_date);
11707 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).ordered_quantity',
11708 g_Op_tab(v_Index).ordered_quantity);
11709 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).UOM_code',
11710 g_Op_tab(v_Index).UOM_code);
11711 END IF;
11712 --
11713 END IF;
11714 --
11715 END IF;
11716 --
11717 END IF;
11718 --
11719 IF (l_debug <> -1) THEN
11720 rlm_core_sv.dpop(k_SDEBUG);
11721 END IF;
11722 --
11723 EXCEPTION
11724 WHEN OTHERS THEN
11725 rlm_message_sv.sql_error('rlm_rd_sv.SetOperation',x_progress);
11726 --
11727 IF (l_debug <> -1) THEN
11728 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11729 END IF;
11730 --
11731 raise;
11732
11733 END SetOperation;
11734
11735 /*===========================================================================
11736
11737 FUNCTION IsLineConsumable
11738
11739 ===========================================================================*/
11740 FUNCTION IsLineConsumable(x_consume_tab IN t_consume_tab,
11741 x_line_id IN RLM_INTERFACE_LINES.LINE_ID%TYPE,
11742 x_index OUT NOCOPY NUMBER)
11743 RETURN BOOLEAN
11744 IS
11745
11746 x_progress VARCHAR2(3) := '010';
11747 BEGIN
11748 --
11749 IF (l_debug <> -1) THEN
11750 rlm_core_sv.dpush(k_SDEBUG, 'IsLineConsumable');
11751 END IF;
11752 --
11753 FOR i IN 1..x_consume_tab.COUNT LOOP
11754 --
11755 IF x_consume_tab(i).line_id = x_line_id THEN
11756 --
11757 x_Index := i;
11758 --
11759 IF (l_debug <> -1) THEN
11760 rlm_core_sv.dlog(k_DEBUG, 'index', i);
11761 rlm_core_sv.dlog(k_DEBUG, 'returning False');
11762 rlm_core_sv.dpop(k_SDEBUG);
11763 END IF;
11764 --
11765 RETURN FALSE;
11766 --
11767 END IF;
11768 --
11769 END LOOP;
11770 --
11771 IF (l_debug <> -1) THEN
11772 rlm_core_sv.dlog(k_DEBUG, 'returning true');
11773 rlm_core_sv.dpop(k_SDEBUG);
11774 END IF;
11775 --
11776 RETURN TRUE;
11777 --
11778 EXCEPTION
11779 WHEN OTHERS THEN
11780 rlm_message_sv.sql_error('rlm_rd_sv.IsLineConsumable',x_progress);
11781 --
11782 IF (l_debug <> -1) THEN
11783 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11784 END IF;
11785 --
11786 raise;
11787
11788 END IsLineConsumable;
11789
11790
11791 /*===========================================================================
11792
11793 FUNCTION UpdateGroupStatus
11794
11795 ===========================================================================*/
11796 PROCEDURE UpdateGroupStatus( x_header_id IN NUMBER,
11797 x_ScheduleHeaderId IN NUMBER,
11798 x_Group_rec IN rlm_dp_sv.t_Group_rec,
11799 x_status IN NUMBER,
11800 x_UpdateLevel IN VARCHAR2)
11801 IS
11802 x_progress VARCHAR2(3) := '010';
11803
11804 BEGIN
11805 --
11806 IF (l_debug <> -1) THEN
11807 rlm_core_sv.dpush(k_SDEBUG,'UpdateGroupStatus');
11808 rlm_core_sv.dlog(k_DEBUG,'UpdateGroupStatus to ', x_status);
11809 rlm_core_sv.dlog(k_DEBUG,'x_header_id ', x_header_id);
11810 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id ',
11811 x_Group_rec.ship_from_org_id);
11812 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id ',
11813 x_Group_rec.order_header_id);
11814 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id ',
11815 x_Group_rec.ship_to_org_id);
11816 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id ',
11817 x_Group_rec.customer_item_id);
11818 rlm_core_sv.dlog(k_DEBUG,'x_ScheduleHeaderId ', x_ScheduleHeaderId);
11819 rlm_core_sv.dlog(k_DEBUG,'x_UpdateLevel to ', x_UpdateLevel);
11820 END IF;
11821 --
11822 IF x_UpdateLevel <> 'GROUP' THEN
11823 --
11824 UPDATE rlm_interface_lines
11825 SET process_status = x_Status
11826 WHERE header_id = x_header_id
11827 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
11828 rlm_core_sv.k_PS_FROZEN_FIRM)
11829 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
11830 --
11831 UPDATE rlm_schedule_lines
11832 SET process_status = x_Status
11833 WHERE header_id = x_ScheduleHeaderid
11834 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
11835 rlm_core_sv.k_PS_FROZEN_FIRM)
11836 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
11837 --
11838 ELSE
11839 --
11840 IF (l_debug <> -1) THEN
11841 rlm_core_sv.dlog(k_DEBUG,'Update Group');
11842 END IF;
11843 --
11844 UPDATE rlm_interface_lines
11845 SET process_status = x_Status
11846 WHERE header_id = x_header_id
11847 AND ship_from_org_id = x_Group_rec.ship_from_org_id
11848 AND ship_to_org_id = x_Group_rec.ship_to_org_id
11849 AND customer_item_id = x_Group_rec.customer_item_id
11850 AND inventory_item_id = x_Group_rec.inventory_item_id
11851 AND order_header_id = x_Group_rec.order_header_id
11852 /*AND nvl(cust_production_seq_num,k_VNULL) =
11853 nvl(x_Group_rec.cust_production_seq_num, k_VNULL)
11854 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
11855 rlm_core_sv.k_PS_FROZEN_FIRM) */
11856 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
11857 --
11858 IF (l_debug <> -1) THEN
11859 rlm_core_sv.dlog(k_DEBUG,'No of interface Lines Updated ', SQL%ROWCOUNT);
11860 END IF;
11861 --
11862 UPDATE rlm_schedule_lines
11863 SET process_status = x_Status
11864 WHERE header_id = x_ScheduleheaderId
11865 AND ship_from_org_id = x_Group_rec.ship_from_org_id
11866 AND ship_to_org_id = x_Group_rec.ship_to_org_id
11867 AND customer_item_id = x_Group_rec.customer_item_id
11868 AND inventory_item_id = x_Group_rec.inventory_item_id
11869 --AND order_header_id = x_Group_rec.order_header_id
11870 /*AND nvl(cust_production_seq_num, k_VNULL) =
11871 nvl(x_Group_rec.cust_production_seq_num, k_VNULL)*/
11872 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
11873 rlm_core_sv.k_PS_FROZEN_FIRM, rlm_core_sv.k_PS_ERROR)
11874 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
11875 --
11876 END IF;
11877 --
11878 IF (l_debug <> -1) THEN
11879 rlm_core_sv.dlog(k_DEBUG,'No of Schedule Lines Updated ', SQL%ROWCOUNT);
11880 rlm_core_sv.dpop(k_SDEBUG);
11881 END IF;
11882 --
11883 EXCEPTION
11884 --
11885 WHEN OTHERS THEN
11886 --
11887 rlm_message_sv.sql_error('rlm_rd_sv.UpdateGroupStatus',x_progress);
11888 --
11889 IF (l_debug <> -1) THEN
11890 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
11891 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
11892 END IF;
11893 --
11894 RAISE ;
11895 --
11896 END UpdateGroupStatus;
11897
11898 /*===========================================================================
11899
11900 FUNCTION IsFrozen
11901
11902 ===========================================================================*/
11903 FUNCTION IsFrozen(x_horizon_start_date IN DATE,
11904 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11905 x_ShipDate IN DATE)
11906 RETURN BOOLEAN
11907 IS
11908
11909 x_progress VARCHAR2(3) := '010';
11910
11911 BEGIN
11912 --
11913 IF (l_debug <> -1) THEN
11914 rlm_core_sv.dpush(k_SDEBUG,'IsFrozen');
11915 rlm_core_sv.dlog(k_DEBUG,'x_ShipToId',x_group_rec.ship_to_org_id);
11916 rlm_core_sv.dlog(k_DEBUG,'x_ShipfromOrgId',x_group_rec.ship_from_org_id);
11917 rlm_core_sv.dlog(k_DEBUG,'x_horizon_start_date',x_horizon_start_date);
11918 rlm_core_sv.dlog(k_DEBUG,'x_ShipDate',x_ShipDate);
11919 rlm_core_sv.dlog(k_DEBUG,'frozen_days',x_Group_rec.frozen_days);
11920 END IF;
11921 --
11922 /*
11923 --global_atp
11924 IF g_ATP = k_ATP THEN
11925 --
11926 IF (l_debug <> -1) THEN
11927 rlm_core_sv.dpop(k_SDEBUG,'FALSE');
11928 END IF;
11929 --
11930 RETURN FALSE;
11931 --
11932 END IF;
11933 */
11934
11935 /* check if the order line falls within the frozen fence */
11936 --
11937 IF ((to_date(to_char(x_ShipDate,'DD-MM-YYYY'),'DD-MM-YYYY')) <
11938 (to_date(to_char(x_horizon_start_date,'DD-MM-YYYY'),'DD-MM-YYYY') +
11939 x_Group_rec.frozen_days )) AND x_Group_rec.frozen_days <> 0 THEN
11940 --
11941 IF (l_debug <> -1) THEN
11942 rlm_core_sv.dpop(k_SDEBUG,'TRUE');
11943 END IF;
11944 --
11945 RETURN(TRUE);
11946 --
11947 ELSE
11948 --
11949 IF (l_debug <> -1) THEN
11950 rlm_core_sv.dpop(k_SDEBUG,'FALSE');
11951 END IF;
11952 --
11953 RETURN(FALSE);
11954 --
11955 END IF;
11956 --
11957 EXCEPTION
11958 --
11959 WHEN OTHERS THEN
11960 --
11961 rlm_message_sv.sql_error('rlm_rd_sv.IsFrozen', x_progress);
11962 --
11963 IF (l_debug <> -1) THEN
11964 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11965 END IF;
11966 --
11967 RAISE;
11968 --
11969 END IsFrozen;
11970 --
11971 /*===========================================================================
11972
11973 FUNCTION LockHeaders
11974
11975 ===========================================================================*/
11976 FUNCTION LockHeaders (x_header_id IN NUMBER)
11977 RETURN BOOLEAN
11978 IS
11979 x_progress VARCHAR2(3) := '010';
11980
11981 CURSOR c IS
11982 SELECT *
11983 FROM rlm_interface_headers
11984 WHERE header_id = x_header_id
11985 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,rlm_core_sv.k_PS_PARTIAL_PROCESSED)
11986 FOR UPDATE NOWAIT;
11987
11988 BEGIN
11989 --
11990 IF (l_debug <> -1) THEN
11991 rlm_core_sv.dpush(k_SDEBUG,'LockHeaders');
11992 rlm_core_sv.dlog(k_DEBUG,'Locking RLM_INTERFACE_HEADERS');
11993 END IF;
11994 --
11995 OPEN c;
11996 --
11997 CLOSE c;
11998 --
11999 IF (l_debug <> -1) THEN
12000 rlm_core_sv.dlog(k_DEBUG,'Returning True ');
12001 rlm_core_sv.dpop(k_SDEBUG);
12002 END IF;
12003 --
12004 RETURN TRUE;
12005 --
12006 EXCEPTION
12007 WHEN APP_EXCEPTION.RECORD_LOCK_EXCEPTION THEN
12008 --
12009 IF (l_debug <> -1) THEN
12010 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE');
12011 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12012 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12013 END IF;
12014 --
12015 RETURN FALSE;
12016 --
12017 WHEN OTHERS THEN
12018 rlm_message_sv.sql_error('rlm_rd_sv.LockHeaders',x_progress);
12019 --
12020 IF (l_debug <> -1) THEN
12021 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE OTHERS ');
12022 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12023 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12024 END IF;
12025 --
12026 RETURN FALSE;
12027
12028 END LockHeaders;
12029
12030 /*===========================================================================
12031
12032 PROCEDURE UpdateHeaderStatus
12033
12034 ===========================================================================*/
12035 PROCEDURE UpdateHeaderStatus( x_HeaderId IN NUMBER,
12036 x_ScheduleHeaderId IN NUMBER,
12037 x_status IN NUMBER)
12038 IS
12039 x_progress VARCHAR2(3) := '010';
12040
12041 BEGIN
12042 --
12043 IF (l_debug <> -1) THEN
12044 rlm_core_sv.dpush(k_SDEBUG,'UpdateHeaderStatus');
12045 rlm_core_sv.dlog(k_DEBUG,'UpdateHeaderStatus to ', x_status);
12046 END IF;
12047 --
12048 UPDATE rlm_interface_headers
12049 SET process_status = x_Status
12050 WHERE header_id = x_HeaderId;
12051
12052 UPDATE rlm_schedule_headers
12053 SET process_status = x_Status
12054 WHERE header_id = x_ScheduleHeaderId;
12055
12056 --
12057 IF (l_debug <> -1) THEN
12058 rlm_core_sv.dpop(k_SDEBUG);
12059 END IF;
12060 --
12061 EXCEPTION
12062 --
12063 WHEN OTHERS THEN
12064 --
12065 rlm_message_sv.sql_error('rlm_rd_sv.UpdateHeaderStatus',x_progress);
12066 --
12067 IF (l_debug <> -1) THEN
12068 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12069 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12070 END IF;
12071 --
12072 RAISE ;
12073 --
12074 END UpdateHeaderStatus;
12075
12076 /*===========================================================================
12077
12078 FUNCTION LockLines
12079
12080 ===========================================================================*/
12081 FUNCTION LockLines (x_Group_rec IN rlm_dp_sv.t_Group_rec,
12082 x_header_id IN NUMBER)
12083 RETURN BOOLEAN
12084 IS
12085 x_progress VARCHAR2(3) := '010';
12086
12087 CURSOR c IS
12088 SELECT *
12089 FROM rlm_interface_lines_all
12090 WHERE header_id = x_header_id
12091 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12092 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12093 AND customer_item_id = x_Group_rec.customer_item_id
12094 AND inventory_item_id = x_Group_rec.inventory_item_id
12095 --AND nvl(schedule_item_num,k_NNULL) = nvl(x_Group_rec.schedule_item_num, k_NNULL)
12096 AND order_header_id = x_Group_rec.order_header_id
12097 /*AND nvl(cust_production_seq_num,k_VNULL) = nvl(x_Group_rec.cust_production_seq_num, k_VNULL)*/
12098 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
12099 FOR UPDATE NOWAIT;
12100
12101 BEGIN
12102 --
12103 IF (l_debug <> -1) THEN
12104 rlm_core_sv.dpush(k_SDEBUG,'LockLines');
12105 rlm_core_sv.dlog(k_DEBUG,'Locking RLM_INTERFACE_LINES');
12106 END IF;
12107 --
12108 OPEN c;
12109 --
12110 CLOSE c;
12111 --
12112 IF (l_debug <> -1) THEN
12113 rlm_core_sv.dlog(k_DEBUG,'Returning True ');
12114 rlm_core_sv.dpop(k_SDEBUG);
12115 END IF;
12116 --
12117 RETURN TRUE;
12118 --
12119 EXCEPTION
12120 WHEN APP_EXCEPTION.RECORD_LOCK_EXCEPTION THEN
12121 --
12122 IF (l_debug <> -1) THEN
12123 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE');
12124 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12125 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12126 END IF;
12127 --
12128 RETURN FALSE;
12129 --
12130 WHEN OTHERS THEN
12131 rlm_message_sv.sql_error('rlm_rd_sv.LockLines',x_progress);
12132 --
12133 IF (l_debug <> -1) THEN
12134 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE OTHERS ');
12135 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12136 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12137 END IF;
12138 --
12139 RETURN FALSE;
12140 --
12141 END LockLines;
12142
12143 /*===========================================================================
12144
12145 PROCEDURE NAME: CheckTolerance
12146
12147 ===========================================================================*/
12148
12149 PROCEDURE CheckTolerance(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12150 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
12151 x_Key_rec IN RLM_RD_SV.t_Key_rec,
12152 x_OldQty IN NUMBER,
12153 x_NewQty IN NUMBER)
12154 IS
12155
12156 v_PctDelta NUMBER;
12157 v_item_no VARCHAR2(80);
12158 v_Progress VARCHAR2(3) := '010';
12159 v_text VARCHAR2(2000) := NULL;
12160 x_DemandTolerancePos NUMBER;
12161 x_DemandToleranceNeg NUMBER;
12162 BEGIN
12163 --
12164 IF (l_debug <> -1) THEN
12165 rlm_core_sv.dpush(k_SDEBUG,'checktolerance');
12166 rlm_core_sv.dlog(k_DEBUG,'CustomerItemId',x_Group_rec.Customer_Item_Id);
12167 rlm_core_sv.dlog(k_DEBUG,'x_OldQty',x_OldQty);
12168 rlm_core_sv.dlog(k_DEBUG,'x_NewQty',x_NewQty);
12169 rlm_core_sv.dlog(k_DEBUG,'x_DemandTolerancePos',
12170 x_Group_rec.setup_terms_rec.demand_tolerance_above);
12171 rlm_core_sv.dlog(k_DEBUG,'x_DemandToleranceNeg',
12172 x_group_rec.setup_terms_rec.demand_tolerance_below);
12173 END IF;
12174 --
12175 -- Verify that the quantity change falls within the defined tolerance limits
12176 -- for the passed customer_item_id
12177 --
12178 x_DemandTolerancePos := x_Group_rec.setup_terms_rec.demand_tolerance_above;
12179 x_DemandToleranceNeg := x_Group_rec.setup_terms_rec.demand_tolerance_below;
12180 --
12181 IF nvl(x_OldQty,0) <> 0 THEN
12182 --
12183 v_PctDelta := ((x_NewQty - x_OldQty)/x_OldQty)*100;
12184 v_PctDelta := round(v_PctDelta,2);
12185 --
12186 IF (l_debug <> -1) THEN
12187 rlm_core_sv.dlog(k_DEBUG,'v_PctDelta',v_PctDelta);
12188 END IF;
12189 --
12190 IF (x_DemandTolerancePos < v_PctDelta) OR
12191 (x_DemandToleranceNeg < ABS(v_PctDelta)) THEN
12192 --
12193 rlm_message_sv.app_error(
12194 x_ExceptionLevel => rlm_message_sv.k_warn_level,
12195 x_MessageName => 'RLM_TOLERANCE_CHECK_FAILED',
12196 x_InterfaceHeaderId => x_sched_rec.header_id,
12197 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
12198 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
12199 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
12200 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
12201 x_OrderLineId => x_Key_rec.dem_rec.line_id,
12202 x_token1=>'CUSITEM',
12203 x_value1=>rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
12204 x_token2=>'PCT_DELTA1',
12205 x_value2=>v_PctDelta,
12206 x_token3=>'PCT_DELTA_POSITIVE',
12207 x_value3=>x_DemandTolerancePos,
12208 x_token4=>'PCT_DELTA_NEGATIVE',
12209 x_value4=>x_DemandToleranceNeg);
12210 --
12211 IF (l_debug <> -1) THEN
12212 rlm_core_sv.dlog(k_DEBUG,'WARNING:RLM_TOLERANCE_CHECK_FAILED');
12213 rlm_core_sv.dlog(k_DEBUG,'tolerance check failed');
12214 END IF;
12215 --
12216 END IF;
12217 --
12218 END IF;
12219 --
12220 IF (l_debug <> -1) THEN
12221 rlm_core_sv.dpop(k_SDEBUG);
12222 END IF;
12223 --
12224 EXCEPTION
12225 --
12226 WHEN OTHERS THEN
12227 --
12228 rlm_message_sv.sql_error('rlm_rd_sv.CheckTolerance', v_Progress);
12229 --
12230 IF (l_debug <> -1) THEN
12231 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHERS - sql error');
12232 END IF;
12233 --
12234 raise;
12235 --
12236 END CheckTolerance;
12237 --
12238
12239 /*===========================================================================
12240
12241 FUNCTION NAME: AlreadyUpdated
12242
12243 ===========================================================================*/
12244 FUNCTION AlreadyUpdated(x_line_id_tab IN t_matching_line)
12245 RETURN BOOLEAN
12246 IS
12247 v_already_updated BOOLEAN DEFAULT FALSE;
12248 BEGIN
12249 --
12250 IF (l_debug <> -1) THEN
12251 --{
12252 rlm_core_sv.dpush(k_SDEBUG, 'AlreadyUpdated');
12253 rlm_core_sv.dlog(k_DEBUG, 'x_line_id_tab.COUNT', x_line_id_tab.COUNT);
12254 rlm_core_sv.dlog(k_DEBUG, 'x_line_id_tab(0)', x_line_id_tab(0));
12255 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab.COUNT', g_Op_tab.COUNT);
12256 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule.COUNT', g_Op_tab_Unschedule.COUNT);
12257 rlm_core_sv.dlog(k_DEBUG, 'g_Accounted_Tab.COUNT', g_Accounted_Tab.COUNT);
12258 --
12259 IF g_Op_tab.COUNT <> 0 THEN
12260 FOR i IN g_Op_Tab.FIRST..g_Op_Tab.LAST LOOP
12261 rlm_core_sv.dlog(k_DEBUG, 'g_Op_Tab('||i||').line_id',
12262 g_Op_Tab(i).line_id);
12263 END LOOP;
12264 END IF;
12265 --
12266 IF g_Op_Tab_Unschedule.COUNT <> 0 THEN
12267 FOR i IN g_Op_Tab_Unschedule.FIRST..g_Op_Tab_unschedule.LAST LOOP
12268 rlm_core_sv.dlog(k_DEBUG, 'g_Op_Tab_Unschedule('||i||').line_id',
12269 g_Op_Tab_Unschedule(i).line_id);
12270 END LOOP;
12271 END IF;
12272 --
12273 IF g_Accounted_Tab.COUNT <> 0 THEN
12274 FOR i IN g_Accounted_Tab.FIRST..g_Accounted_Tab.LAST LOOP
12275 rlm_core_sv.dlog(k_DEBUG, 'g_Accounted_Tab('||i||').line_id',
12276 g_Accounted_Tab(i).line_id);
12277 END LOOP;
12278 END IF;
12279 --}
12280 END IF;
12281 --
12282 IF (x_line_id_tab.COUNT = 0) THEN
12283 --
12284 IF (l_debug <> -1) THEN
12285 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12286 END IF;
12287 --
12288 RETURN FALSE;
12289 --
12290 END IF;
12291
12292 IF g_Op_tab.COUNT <> 0 THEN
12293 --
12294 FOR i IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12295 --
12296 FOR j IN g_Op_tab.FIRST..g_Op_tab.LAST LOOP
12297 --
12298 IF x_line_id_tab(i) = g_Op_tab(j).line_id THEN
12299 --
12300 IF (l_debug <> -1) THEN
12301 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(i));
12302 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12303 END IF;
12304 --
12305 RETURN TRUE;
12306 --
12307 END IF;
12308 --
12309 END LOOP;
12310 --
12311 END LOOP;
12312 --
12313 END IF;
12314 --
12315 --
12316 IF g_Accounted_tab.COUNT <> 0 THEN
12317 --
12318 FOR i IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12319 --
12320 FOR j IN g_Accounted_tab.FIRST..g_Accounted_tab.LAST LOOP
12321 --
12322 IF x_line_id_tab(i) = g_Accounted_tab(j).line_id THEN
12323 --
12324 IF (l_debug <> -1) THEN
12325 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(i));
12326 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12327 END IF;
12328 --
12329 RETURN TRUE;
12330 --
12331 END IF;
12332 --
12333 END LOOP;
12334 --
12335 END LOOP;
12336 --
12337 END IF;
12338 --
12339 --
12340 --global_atp
12341 --
12342 IF g_Op_tab_Unschedule.COUNT <> 0 THEN
12343 --
12344 FOR k IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12345 --
12346 FOR l IN g_Op_tab_Unschedule.FIRST..g_Op_tab_Unschedule.LAST LOOP
12347 --
12348 IF x_line_id_tab(k) = g_Op_tab_Unschedule(l).line_id THEN
12349 --
12350 IF (l_debug <> -1) THEN
12351 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(k));
12352 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12353 END IF;
12354 --
12355 RETURN TRUE;
12356 --
12357 END IF;
12358 --
12359 END LOOP;
12360 --
12361 END LOOP;
12362 --
12363 IF (l_debug <> -1) THEN
12364 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12365 END IF;
12366 --
12367 RETURN FALSE;
12368 --
12369 ELSE
12370 --
12371 IF (l_debug <> -1) THEN
12372 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12373 END IF;
12374 --
12375 RETURN FALSE;
12376 --
12377 END IF;
12378 --
12379 EXCEPTION
12380 --
12381 WHEN OTHERS THEN
12382 --
12383 IF (l_debug <> -1) THEN
12384 rlm_core_sv.dlog(k_DEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
12385 rlm_core_sv.dpop(k_SDEBUG, 'When Others - FALSE');
12386 END IF;
12387 --
12388 RETURN FALSE;
12389 --
12390
12391 END;
12392 --
12393 /*===========================================================================
12394
12395 FUNCTION NAME: GetTPContext
12396
12397 ===========================================================================*/
12398 PROCEDURE GetTPContext( x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12399 x_group_rec IN rlm_dp_sv.t_Group_rec,
12400 x_req_rec IN rlm_rd_sv.t_generic_rec,
12401 x_customer_number OUT NOCOPY VARCHAR2,
12402 x_ship_to_ece_locn_code OUT NOCOPY VARCHAR2,
12403 x_bill_to_ece_locn_code OUT NOCOPY VARCHAR2,
12404 x_inter_ship_to_ece_locn_code OUT NOCOPY VARCHAR2,
12405 x_tp_group_code OUT NOCOPY VARCHAR2,
12406 x_key_rec IN rlm_rd_sv.t_key_rec)
12407 IS
12408
12409 --
12410 v_Progress VARCHAR2(3) := '010';
12411 v_ece_tp_location_code_ext VARCHAR2(35);
12412 v_ece_tp_translator_code VARCHAR2(35);
12413 --
12414 BEGIN
12415 --
12416 --
12417 IF (l_debug <> -1) THEN
12418 rlm_core_sv.dpush(k_SDEBUG,'GetTPContext');
12419 END IF;
12420 --
12421 IF(x_sched_rec.header_id is not null) then
12422 --
12423 IF (l_debug <> -1) THEN
12424 rlm_core_sv.dlog(k_DEBUG,'customer_id', x_sched_rec.customer_id);
12425 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.ece_tp_translator_code',
12426 x_sched_rec.ece_tp_translator_code);
12427 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.ece_tp_location_code_ext',
12428 x_sched_rec.ece_tp_location_code_ext);
12429 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.ship_to_address_id',
12430 x_group_rec.ship_to_address_id);
12431 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.bill_to_address_id',
12432 x_group_rec.bill_to_address_id);
12433 END IF;
12434 --
12435 IF x_sched_rec.ECE_TP_LOCATION_CODE_EXT is NOT NULL THEN
12436 --
12437 -- Following query is changed as per TCA obsolescence project.
12438 SELECT ETG.TP_GROUP_CODE
12439 INTO x_tp_group_code
12440 FROM ECE_TP_GROUP ETG,
12441 ECE_TP_HEADERS ETH,
12442 HZ_CUST_ACCT_SITES ACCT_SITE
12443 WHERE ETG.TP_GROUP_ID = ETH.TP_GROUP_ID
12444 and ETH.TP_HEADER_ID = ACCT_SITE.TP_HEADER_ID
12445 and ACCT_SITE.CUST_ACCOUNT_ID = x_sched_rec.CUSTOMER_ID
12446 and ACCT_SITE.ECE_TP_LOCATION_CODE = x_Sched_rec.ECE_TP_LOCATION_CODE_EXT;
12447
12448 ELSE
12449 x_tp_group_code := x_sched_rec.ECE_TP_TRANSLATOR_CODE;
12450 END IF;
12451 --
12452 BEGIN
12453 --
12454 -- Following query is changed as per TCA obsolescence project.
12455 SELECT ece_tp_location_code
12456 INTO x_ship_to_ece_locn_code
12457 FROM HZ_CUST_ACCT_SITES ACCT_SITE
12458 WHERE ACCT_SITE.CUST_ACCT_SITE_ID = x_group_rec.ship_to_address_id;
12459 --
12460 EXCEPTION
12461 WHEN NO_DATA_FOUND THEN
12462 x_ship_to_ece_locn_code := NULL;
12463 END;
12464 --
12465
12466 --
12467
12468 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12469 -- have the bill_to in x_group_rec. Code has been removed as a part of
12470 -- TCA OBSOLESCENCE PROJECT.
12471
12472 --
12473 IF x_sched_rec.customer_id is NOT NULL THEN
12474 --
12475 -- Following query is changed as per TCA obsolescence project.
12476 SELECT account_number
12477 INTO x_customer_number
12478 FROM HZ_CUST_ACCOUNTS CUST_ACCT
12479 WHERE CUST_ACCT.CUST_ACCOUNT_ID = x_sched_rec.customer_id;
12480 --
12481 END IF;
12482 --
12483 IF (l_debug <> -1) THEN
12484 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12485 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12486 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12487 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12488 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12489 END IF;
12490 --
12491 ELSIF(x_key_rec.req_rec.header_id is not NULL) THEN
12492 --
12493 IF (l_debug <> -1) THEN
12494 rlm_core_sv.dlog(k_DEBUG,'customer_id', x_key_rec.req_rec.customer_id);
12495 rlm_core_sv.dlog(k_DEBUG,'ship_to_address_id',
12496 x_key_rec.req_rec.ship_to_address_id);
12497 rlm_core_sv.dlog(k_DEBUG,'bill_to_address_id',
12498 x_key_rec.req_rec.bill_to_address_id);
12499 END IF;
12500 --
12501 SELECT ECE_TP_LOCATION_CODE_EXT, ECE_TP_TRANSLATOR_CODE
12502 INTO v_ece_tp_location_code_ext,v_ece_tp_translator_code
12503 FROM rlm_interface_headers
12504 WHERE header_id = x_key_rec.req_rec.header_id;
12505 --
12506 IF v_ECE_TP_LOCATION_CODE_EXT is NOT NULL THEN
12507 --
12508 -- Following query is changed as per TCA obsolescence project.
12509 SELECT ETG.TP_GROUP_CODE
12510 INTO x_tp_group_code
12511 FROM ECE_TP_GROUP ETG,
12512 ECE_TP_HEADERS ETH,
12513 HZ_CUST_ACCT_SITES ACCT_SITE
12514 WHERE ETG.TP_GROUP_ID = ETH.TP_GROUP_ID
12515 and ETH.TP_HEADER_ID = ACCT_SITE.TP_HEADER_ID
12516 and ACCT_SITE.ECE_TP_LOCATION_CODE = v_ECE_TP_LOCATION_CODE_EXT ;
12517 ELSE
12518 x_tp_group_code := v_ECE_TP_TRANSLATOR_CODE;
12519 END IF;
12520 --
12521 BEGIN
12522 --
12523 -- Following query is changed as per TCA obsolescence project.
12524 SELECT ece_tp_location_code
12525 INTO x_ship_to_ece_locn_code
12526 FROM HZ_CUST_ACCT_SITES
12527 WHERE CUST_ACCT_SITE_ID = x_key_rec.req_rec.ship_to_address_id;
12528 --
12529 EXCEPTION
12530 WHEN NO_DATA_FOUND THEN
12531 x_ship_to_ece_locn_code := NULL;
12532 END;
12533 --
12534
12535 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12536 -- have the bill_to in x_group_rec. Code has been removed as a part of
12537 -- TCA OBSOLESCENCE PROJECT.
12538
12539 --
12540 IF x_key_rec.req_rec.customer_id is NOT NULL THEN
12541 --
12542 -- Following query is changed as per TCA obsolescence project.
12543 SELECT account_number
12544 INTO x_customer_number
12545 FROM HZ_CUST_ACCOUNTS
12546 WHERE ACCOUNT_NUMBER = x_key_rec.req_rec.customer_id;
12547 --
12548 END IF;
12549 --
12550 IF (l_debug <> -1) THEN
12551 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12552 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12553 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12554 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12555 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12556 END IF;
12557 --
12558 ELSE
12559 --
12560 BEGIN
12561 --
12562 -- Following query is changed as per TCA obsolescence project.
12563 SELECT ece_tp_location_code
12564 INTO x_ship_to_ece_locn_code
12565 FROM HZ_CUST_ACCT_SITES
12566 WHERE CUST_ACCT_SITE_ID = x_group_rec.ship_to_address_id;
12567 --
12568 EXCEPTION
12569 WHEN NO_DATA_FOUND THEN
12570 x_ship_to_ece_locn_code := NULL;
12571 END;
12572 --
12573
12574 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12575 -- have the bill_to in x_group_rec. Code has been removed as a part of
12576 -- TCA OBSOLESCENCE PROJECT.
12577
12578 --
12579 IF x_group_rec.customer_id is NOT NULL THEN
12580 --
12581 -- Following query is changed as per TCA obsolescence project.
12582 SELECT account_number
12583 INTO x_customer_number
12584 FROM HZ_CUST_ACCOUNTS CUST_ACCT
12585 WHERE CUST_ACCT.CUST_ACCOUNT_ID = x_sched_rec.customer_id;
12586 --
12587 END IF;
12588 --
12589 IF (l_debug <> -1) THEN
12590 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12591 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12592 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12593 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12594 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12595 END IF;
12596 --
12597 END IF;
12598 --
12599 IF (l_debug <> -1) THEN
12600 rlm_core_sv.dpop(k_SDEBUG);
12601 END IF;
12602 --
12603 EXCEPTION
12604 --
12605 WHEN NO_DATA_FOUND THEN
12606 --
12607 x_customer_number := NULL;
12608 --
12609 IF (l_debug <> -1) THEN
12610 rlm_core_sv.dlog(k_DEBUG, 'No data found for' , x_sched_rec.customer_id);
12611 rlm_core_sv.dpop(k_SDEBUG);
12612 END IF;
12613 --
12614 WHEN OTHERS THEN
12615 rlm_message_sv.sql_error('rlm_rd_sv.GetTPContext',v_Progress);
12616 --
12617 IF (l_debug <> -1) THEN
12618 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
12619 END IF;
12620 --
12621 raise;
12622 --
12623 END GetTPContext;
12624
12625
12626 PROCEDURE InitializeMatchRec(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12627 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
12628 x_match_ref IN OUT NOCOPY t_Cursor_ref) IS
12629 --
12630 x_progress VARCHAR2(3) := '010';
12631 x_Query VARCHAR2(32767);
12632 --
12633 BEGIN
12634 --
12635 IF (l_debug <> -1) THEN
12636 rlm_core_sv.dpush(k_SDEBUG, 'InitializeMatchRec');
12637 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id', x_Group_rec.ship_to_org_id);
12638 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
12639 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
12640 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
12641 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date', x_Sched_rec.sched_horizon_start_date);
12642 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date', x_Sched_rec.sched_horizon_end_date);
12643 END IF;
12644 --
12645 OPEN x_match_ref FOR
12646 SELECT
12647 DECODE(x_Group_rec.match_within_rec.cust_production_line,'Y',cust_production_line, NULL),
12648 DECODE(x_Group_rec.match_within_rec.customer_dock_code,'Y',customer_dock_code,NULL),
12649 NULL,--request_date
12650 NULL,--schedule_date
12651 DECODE(x_Group_rec.match_within_rec.cust_po_number,'Y',cust_po_number,NULL),
12652 DECODE(x_Group_rec.match_within_rec.customer_item_revision,'Y', customer_item_revision, NULL),
12653 DECODE(x_Group_rec.match_within_rec.customer_job,'Y',customer_job, NULL),
12654 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number,'Y',cust_model_serial_number, NULL),
12655 DECODE(x_Group_rec.match_within_rec.cust_production_seq_num,'Y',cust_production_seq_num,NULL),
12656 DECODE(x_Group_rec.match_within_rec.industry_attribute1,'Y', industry_attribute1,NULL),
12657 NULL,
12658 NULL,
12659 DECODE(x_Group_rec.match_within_rec.industry_attribute4,'Y', industry_attribute4,NULL),
12660 DECODE(x_Group_rec.match_within_rec.industry_attribute5,'Y', industry_attribute5,NULL),
12661 DECODE(x_Group_rec.match_within_rec.industry_attribute6,'Y', industry_attribute6,NULL),
12662 NULL,
12663 NULL,
12664 DECODE(x_Group_rec.match_within_rec.industry_attribute9, 'Y', industry_attribute9,NULL),
12665 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y', industry_attribute10,NULL),
12666 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y', industry_attribute11,NULL),
12667 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y', industry_attribute12,NULL),
12668 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y', industry_attribute13,NULL),
12669 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y', industry_attribute14,NULL),
12670 DECODE(x_Group_rec.match_within_rec.industry_attribute15, 'Y', industry_attribute15,NULL),
12671 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y', attribute1, NULL),
12672 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y', attribute2, NULL),
12673 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y', attribute3, NULL),
12674 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y', attribute4, NULL),
12675 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y', attribute5, NULL),
12676 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y', attribute6, NULL),
12677 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y', attribute7, NULL),
12678 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y', attribute8, NULL),
12679 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y', attribute9, NULL),
12680 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y', attribute10,NULL),
12681 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y', attribute11,NULL),
12682 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y', attribute12,NULL),
12683 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y', attribute13,NULL),
12684 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y', attribute14,NULL),
12685 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y', attribute15,NULL)
12686 FROM rlm_interface_lines
12687 WHERE header_id = x_Sched_rec.header_id
12688 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12689 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12690 AND customer_item_id = x_Group_rec.customer_item_id
12691 AND inventory_item_id = x_Group_rec.inventory_item_id
12692 AND order_header_id = x_Group_rec.order_header_id
12693 AND item_detail_type IN (k_FIRM, k_FORECAST, k_PAST_DUE_FIRM);
12694 --
12695 IF (l_debug <> -1) THEN
12696 rlm_core_sv.dpop(k_SDEBUG, 'InitializeMatchRec');
12697 END IF;
12698 --
12699 EXCEPTION
12700 WHEN OTHERS THEN
12701 rlm_message_sv.sql_error('RLM_RD_SV.InitializeMatchRec', x_progress);
12702 --
12703 IF (l_debug <> -1) THEN
12704 rlm_core_sv.dpop(k_SDEBUG, 'EXCEPTION: ' || SUBSTR(SQLERRM,1,200));
12705 END IF;
12706 --
12707 RAISE e_group_error;
12708
12709 END InitializeMatchRec;
12710
12711
12712 FUNCTION FetchMatchRec(x_match_ref IN OUT NOCOPY t_Cursor_ref,
12713 x_opt_match_rec IN OUT NOCOPY WSH_RLM_INTERFACE.t_optional_match_rec)
12714 RETURN BOOLEAN IS
12715
12716 x_progress VARCHAR2(3) := '010';
12717
12718 BEGIN
12719 --
12720 IF (l_debug <> -1) THEN
12721 rlm_core_sv.dpush('FetchMatchRec');
12722 END IF;
12723 --
12724 FETCH x_match_ref INTO
12725 x_opt_match_rec.cust_production_line,
12726 x_opt_match_rec.customer_dock_code,
12727 x_opt_match_rec.request_date,
12728 x_opt_match_rec.schedule_date,
12729 x_opt_match_rec.cust_po_number,
12730 x_opt_match_rec.customer_item_revision,
12731 x_opt_match_rec.customer_job,
12732 x_opt_match_rec.cust_model_serial_number,
12733 x_opt_match_rec.cust_production_seq_num,
12734 x_opt_match_rec.industry_attribute1,
12735 x_opt_match_rec.industry_attribute2,
12736 x_opt_match_rec.industry_attribute3,
12737 x_opt_match_rec.industry_attribute4,
12738 x_opt_match_rec.industry_attribute5,
12739 x_opt_match_rec.industry_attribute6,
12740 x_opt_match_rec.industry_attribute7,
12741 x_opt_match_rec.industry_attribute8,
12742 x_opt_match_rec.industry_attribute9,
12743 x_opt_match_rec.industry_attribute10,
12744 x_opt_match_rec.industry_attribute11,
12745 x_opt_match_rec.industry_attribute12,
12746 x_opt_match_rec.industry_attribute13,
12747 x_opt_match_rec.industry_attribute14,
12748 x_opt_match_rec.industry_attribute15,
12749 x_opt_match_rec.attribute1,
12750 x_opt_match_rec.attribute2,
12751 x_opt_match_rec.attribute3,
12752 x_opt_match_rec.attribute4,
12753 x_opt_match_rec.attribute5,
12754 x_opt_match_rec.attribute6,
12755 x_opt_match_rec.attribute7,
12756 x_opt_match_rec.attribute8,
12757 x_opt_match_rec.attribute9,
12758 x_opt_match_rec.attribute10,
12759 x_opt_match_rec.attribute11,
12760 x_opt_match_rec.attribute12,
12761 x_opt_match_rec.attribute13,
12762 x_opt_match_rec.attribute14,
12763 x_opt_match_rec.attribute15;
12764 --
12765 IF x_match_ref%NOTFOUND THEN
12766 --
12767 IF (l_debug <> -1) THEN
12768 rlm_core_sv.dpop(k_SDEBUG, 'false');
12769 END IF;
12770 --
12771 RETURN (FALSE);
12772 --
12773 ELSE
12774 --
12775 IF (l_debug <> -1) THEN
12776 rlm_core_sv.dpop(k_SDEBUG, 'true');
12777 END IF;
12778 --
12779 RETURN (TRUE);
12780 --
12781 END IF;
12782 --
12783 EXCEPTION
12784 WHEN OTHERS THEN
12785 rlm_message_sv.sql_error('RLM_RD_SV.FetchMatchRec', x_progress);
12786 --
12787 IF (l_debug <> -1) THEN
12788 rlm_core_sv.dpop(k_SDEBUG, 'EXCEPTION: ' || SUBSTR(SQLERRM,1,200));
12789 END IF;
12790 --
12791 RAISE e_group_error;
12792 --
12793 END FetchMatchRec;
12794
12795
12796 PROCEDURE PrintMatchRec(x_opt_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec) IS
12797
12798 BEGIN
12799 --
12800 IF (l_debug <> -1) THEN
12801 rlm_core_sv.dpush(k_SDEBUG, 'PrintMatchRec');
12802 rlm_core_sv.dlog(k_DEBUG, 'Production Line', x_opt_match_rec.cust_production_line);
12803 rlm_core_sv.dlog(k_DEBUG, 'Customer dock code', x_opt_match_rec.customer_dock_code);
12804 rlm_core_sv.dlog(k_DEBUG, 'Cust PO Number', x_opt_match_rec.cust_po_number);
12805 rlm_core_sv.dlog(k_DEBUG, 'Customer item revision', x_opt_match_rec.customer_item_revision);
12806 rlm_core_sv.dlog(k_DEBUG, 'Customer job', x_opt_match_rec.customer_job);
12807 rlm_core_sv.dlog(k_DEBUG, 'Model serial number', x_opt_match_rec.cust_model_serial_number);
12808 rlm_core_sv.dlog(k_DEBUG, 'Prod seq num', x_opt_match_rec.cust_production_seq_num);
12809 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute1', x_opt_match_rec.industry_attribute1);
12810 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute2', x_opt_match_rec.industry_attribute1);
12811 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute4', x_opt_match_rec.industry_attribute4);
12812 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute5', x_opt_match_rec.industry_attribute5);
12813 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute6', x_opt_match_rec.industry_attribute6);
12814 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute9', x_opt_match_rec.industry_attribute9);
12815 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute10', x_opt_match_rec.industry_attribute10);
12816 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute11', x_opt_match_rec.industry_attribute11);
12817 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute12', x_opt_match_rec.industry_attribute12);
12818 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute13', x_opt_match_rec.industry_attribute13);
12819 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute14', x_opt_match_rec.industry_attribute14);
12820 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute15', x_opt_match_rec.industry_attribute15);
12821 rlm_core_sv.dlog(k_DEBUG, 'Attribute1', x_opt_match_rec.attribute1);
12822 rlm_core_sv.dlog(k_DEBUG, 'Attribute2', x_opt_match_rec.attribute2);
12823 rlm_core_sv.dlog(k_DEBUG, 'Attribute3', x_opt_match_rec.attribute3);
12824 rlm_core_sv.dlog(k_DEBUG, 'Attribute4', x_opt_match_rec.attribute4);
12825 rlm_core_sv.dlog(k_DEBUG, 'Attribute5', x_opt_match_rec.attribute5);
12826 rlm_core_sv.dlog(k_DEBUG, 'Attribute6', x_opt_match_rec.attribute6);
12827 rlm_core_sv.dlog(k_DEBUG, 'Attribute7', x_opt_match_rec.attribute7);
12828 rlm_core_sv.dlog(k_DEBUG, 'Attribute8', x_opt_match_rec.attribute8);
12829 rlm_core_sv.dlog(k_DEBUG, 'Attribute9', x_opt_match_rec.attribute9);
12830 rlm_core_sv.dlog(k_DEBUG, 'Attribute10', x_opt_match_rec.attribute10);
12831 rlm_core_sv.dlog(k_DEBUG, 'Attribute11', x_opt_match_rec.attribute11);
12832 rlm_core_sv.dlog(k_DEBUG, 'Attribute12', x_opt_match_rec.attribute12);
12833 rlm_core_sv.dlog(k_DEBUG, 'Attribute13', x_opt_match_rec.attribute13);
12834 rlm_core_sv.dlog(k_DEBUG, 'Attribute14', x_opt_match_rec.attribute14);
12835 rlm_core_sv.dlog(k_DEBUG, 'Attribute15', x_opt_match_rec.attribute15);
12836 rlm_core_sv.dpop(k_SDEBUG, 'PrintMatchRec');
12837 END IF;
12838 --
12839 END PrintMatchRec;
12840
12841
12842 FUNCTION AlreadyMatched(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
12843 x_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec, x_Index OUT NOCOPY NUMBER)
12844 RETURN BOOLEAN
12845 IS
12846 --
12847 b_Match BOOLEAN;
12848 e_NoMatch EXCEPTION;
12849 x_progress VARCHAR2(3) := '010';
12850 --
12851 BEGIN
12852 --
12853 IF (l_debug <> -1) THEN
12854 rlm_core_sv.dpush(k_SDEBUG, 'AlreadyMatched');
12855 rlm_core_sv.dlog(k_DEBUG, '# of rows in intransit tab', g_IntransitTab.COUNT);
12856 END IF;
12857 --
12858 b_Match := FALSE;
12859 --
12860 IF g_IntransitTab.COUNT = 0 THEN
12861 --
12862 IF (l_debug <> -1) THEN
12863 rlm_core_sv.dpop(k_SDEBUG, 'false');
12864 END IF;
12865 --
12866 RETURN (FALSE);
12867 --
12868 END IF;
12869 --
12870 FOR i IN 1..g_IntransitTab.COUNT LOOP
12871 --
12872 BEGIN
12873 --
12874 IF (x_Group_rec.match_within_rec.cust_production_line = 'Y') THEN
12875 IF NVL(g_IntransitTab(i).cust_production_line, k_VNULL) <> NVL(x_match_rec.cust_production_line, k_VNULL) THEN
12876 --
12877 IF (l_debug <> -1) THEN
12878 rlm_core_sv.dlog(k_DEBUG, 'prod line didnt match');
12879 END IF;
12880 --
12881 RAISE e_NoMatch;
12882 END IF;
12883 END IF;
12884
12885 IF (x_Group_rec.match_within_rec.customer_dock_code = 'Y') THEN
12886 IF NVL(g_IntransitTab(i).customer_dock_code, k_VNULL) <> NVL(x_match_rec.customer_dock_code, k_VNULL) THEN
12887 --
12888 IF (l_debug <> -1) THEN
12889 rlm_core_sv.dlog(k_DEBUG, 'dock code didnt match');
12890 END IF;
12891 --
12892 RAISE e_NoMatch;
12893 --
12894 END IF;
12895 END IF;
12896
12897 IF (x_Group_rec.match_within_rec.cust_po_number = 'Y') THEN
12898 IF NVL(g_IntransitTab(i).cust_po_number, k_VNULL) <> NVL(x_match_rec.cust_po_number, k_VNULL) THEN
12899 --
12900 IF (l_debug <> -1) THEN
12901 rlm_core_sv.dlog(k_DEBUG, 'po num didnt match');
12902 END IF;
12903 --
12904 RAISE e_NoMatch;
12905 END IF;
12906 END IF;
12907
12908 IF (x_Group_rec.match_within_rec.customer_item_revision = 'Y') THEN
12909 IF NVL(g_IntransitTab(i).customer_item_revision, k_VNULL) <> NVL(x_match_rec.customer_item_revision, k_VNULL) THEN
12910 --
12911 IF (l_debug <> -1) THEN
12912 rlm_core_sv.dlog(k_DEBUG, 'cust item rev didnt match');
12913 END IF;
12914 --
12915 RAISE e_NoMatch;
12916 END IF;
12917 END IF;
12918
12919 IF (x_Group_rec.match_within_rec.customer_job = 'Y') THEN
12920 IF NVL(g_IntransitTab(i).customer_job, k_VNULL) <> NVL(x_match_rec.customer_job, k_VNULL) THEN
12921 --
12922 IF (l_debug <> -1) THEN
12923 rlm_core_sv.dlog(k_DEBUG, 'customer job didnt match');
12924 END IF;
12925 --
12926 RAISE e_NoMatch;
12927 END IF;
12928 END IF;
12929
12930 IF (x_Group_rec.match_within_rec.cust_model_serial_number = 'Y') THEN
12931 IF NVL(g_IntransitTab(i).cust_model_serial_number, k_VNULL) <> NVL(x_match_rec.cust_model_serial_number, k_VNULL) THEN
12932 --
12933 IF (l_debug <> -1) THEN
12934 rlm_core_sv.dlog(k_DEBUG, 'model serial no. didnt match');
12935 END IF;
12936 --
12937 RAISE e_NoMatch;
12938 END IF;
12939 END IF;
12940
12941 IF (x_Group_rec.match_within_rec.cust_production_seq_num = 'Y') THEN
12942 IF NVL(g_IntransitTab(i).cust_production_seq_num, k_VNULL) <> NVL(x_match_rec.cust_production_seq_num, k_VNULL) THEN
12943 --
12944 IF (l_debug <> -1) THEN
12945 rlm_core_sv.dlog(k_DEBUG, 'PSQ num didnt match');
12946 END IF;
12947 --
12948 RAISE e_NoMatch;
12949 END IF;
12950 END IF;
12951
12952 IF (x_Group_rec.match_within_rec.industry_attribute1 = 'Y') THEN
12953 IF NVL(g_IntransitTab(i).industry_attribute1, k_VNULL) <> NVL(x_match_rec.industry_attribute1, k_VNULL) THEN
12954 --
12955 IF (l_debug <> -1) THEN
12956 rlm_core_sv.dlog(k_DEBUG, 'IA1 num didnt match');
12957 END IF;
12958 --
12959 RAISE e_NoMatch;
12960 END IF;
12961 END IF;
12962
12963 IF (x_Group_rec.match_within_rec.industry_attribute4 = 'Y') THEN
12964 IF NVL(g_IntransitTab(i).industry_attribute4, k_VNULL) <> NVL(x_match_rec.industry_attribute4, k_VNULL) THEN
12965 --
12966 IF (l_debug <> -1) THEN
12967 rlm_core_sv.dlog(k_DEBUG, 'IA4 num didnt match');
12968 END IF;
12969 --
12970 RAISE e_NoMatch;
12971 END IF;
12972 END IF;
12973
12974 IF (x_Group_rec.match_within_rec.industry_attribute5 = 'Y') THEN
12975 IF NVL(g_IntransitTab(i).industry_attribute5, k_VNULL) <> NVL(x_match_rec.industry_attribute5, k_VNULL) THEN
12976 --
12977 IF (l_debug <> -1) THEN
12978 rlm_core_sv.dlog(k_DEBUG, 'IA5 num didnt match');
12979 END IF;
12980 --
12981 RAISE e_NoMatch;
12982 END IF;
12983 END IF;
12984
12985 IF (x_Group_rec.match_within_rec.industry_attribute6 = 'Y') THEN
12986 IF NVL(g_IntransitTab(i).industry_attribute6, k_VNULL) <> NVL(x_match_rec.industry_attribute6, k_VNULL) THEN
12987 --
12988 IF (l_debug <> -1) THEN
12989 rlm_core_sv.dlog(k_DEBUG, 'IA6 num didnt match');
12990 END IF;
12991 --
12992 RAISE e_NoMatch;
12993 END IF;
12994 END IF;
12995
12996 IF (x_Group_rec.match_within_rec.industry_attribute9 = 'Y') THEN
12997 IF NVL(g_IntransitTab(i).industry_attribute9, k_VNULL) <> NVL(x_match_rec.industry_attribute9, k_VNULL) THEN
12998 --
12999 IF (l_debug <> -1) THEN
13000 rlm_core_sv.dlog(k_DEBUG, 'IA9 num didnt match');
13001 END IF;
13002 --
13003 RAISE e_NoMatch;
13004 END IF;
13005 END IF;
13006
13007 IF (x_Group_rec.match_within_rec.industry_attribute10 = 'Y') THEN
13008 IF NVL(g_IntransitTab(i).industry_attribute10, k_VNULL) <> NVL(x_match_rec.industry_attribute10, k_VNULL) THEN
13009 --
13010 IF (l_debug <> -1) THEN
13011 rlm_core_sv.dlog(k_DEBUG, 'IA10 num didnt match');
13012 END IF;
13013 --
13014 RAISE e_NoMatch;
13015 END IF;
13016 END IF;
13017
13018 IF (x_Group_rec.match_within_rec.industry_attribute11 = 'Y') THEN
13019 IF NVL(g_IntransitTab(i).industry_attribute11, k_VNULL) <> NVL(x_match_rec.industry_attribute11, k_VNULL) THEN
13020 --
13021 IF (l_debug <> -1) THEN
13022 rlm_core_sv.dlog(k_DEBUG, 'IA11 num didnt match');
13023 END IF;
13024 --
13025 RAISE e_NoMatch;
13026 END IF;
13027 END IF;
13028
13029 IF (x_Group_rec.match_within_rec.industry_attribute12 = 'Y') THEN
13030 IF NVL(g_IntransitTab(i).industry_attribute12, k_VNULL) <> NVL(x_match_rec.industry_attribute12, k_VNULL) THEN
13031 --
13032 IF (l_debug <> -1) THEN
13033 rlm_core_sv.dlog(k_DEBUG, 'IA12 num didnt match');
13034 END IF;
13035 --
13036 RAISE e_NoMatch;
13037 END IF;
13038 END IF;
13039
13040 IF (x_Group_rec.match_within_rec.industry_attribute13 = 'Y') THEN
13041 IF NVL(g_IntransitTab(i).industry_attribute13, k_VNULL) <> NVL(x_match_rec.industry_attribute13, k_VNULL) THEN
13042 --
13043 IF (l_debug <> -1) THEN
13044 rlm_core_sv.dlog(k_DEBUG, 'IA13 num didnt match');
13045 END IF;
13046 --
13047 RAISE e_NoMatch;
13048 END IF;
13049 END IF;
13050
13051 IF (x_Group_rec.match_within_rec.industry_attribute14 = 'Y') THEN
13052 IF NVL(g_IntransitTab(i).industry_attribute14, k_VNULL) <> NVL(x_match_rec.industry_attribute14, k_VNULL) THEN
13053 --
13054 IF (l_debug <> -1) THEN
13055 rlm_core_sv.dlog(k_DEBUG, 'IA14 num didnt match');
13056 END IF;
13057 --
13058 RAISE e_NoMatch;
13059 END IF;
13060 END IF;
13061
13062 IF (x_Group_rec.match_within_rec.attribute1 = 'Y') THEN
13063 IF NVL(g_IntransitTab(i).attribute1, k_VNULL) <> NVL(x_match_rec.attribute1, k_VNULL) THEN
13064 --
13065 IF (l_debug <> -1) THEN
13066 rlm_core_sv.dlog(k_DEBUG, 'A1 num didnt match');
13067 END IF;
13068 --
13069 RAISE e_NoMatch;
13070 END IF;
13071 END IF;
13072
13073 IF (x_Group_rec.match_within_rec.attribute2 = 'Y') THEN
13074 IF NVL(g_IntransitTab(i).attribute2, k_VNULL) <> NVL(x_match_rec.attribute2, k_VNULL) THEN
13075 --
13076 IF (l_debug <> -1) THEN
13077 rlm_core_sv.dlog(k_DEBUG, 'A2 num didnt match');
13078 END IF;
13079 --
13080 RAISE e_NoMatch;
13081 END IF;
13082 END IF;
13083
13084 IF (x_Group_rec.match_within_rec.attribute3 = 'Y') THEN
13085 IF NVL(g_IntransitTab(i).attribute3, k_VNULL) <> NVL(x_match_rec.attribute3, k_VNULL) THEN
13086 --
13087 IF (l_debug <> -1) THEN
13088 rlm_core_sv.dlog(k_DEBUG, 'A3 num didnt match');
13089 END IF;
13090 --
13091 RAISE e_NoMatch;
13092 END IF;
13093 END IF;
13094
13095 IF (x_Group_rec.match_within_rec.attribute4 = 'Y') THEN
13096 IF NVL(g_IntransitTab(i).attribute4, k_VNULL) <> NVL(x_match_rec.attribute4, k_VNULL) THEN
13097 --
13098 IF (l_debug <> -1) THEN
13099 rlm_core_sv.dlog(k_DEBUG, 'A4 num didnt match');
13100 END IF;
13101 --
13102 RAISE e_NoMatch;
13103 END IF;
13104 END IF;
13105
13106 IF (x_Group_rec.match_within_rec.attribute5 = 'Y') THEN
13107 IF NVL(g_IntransitTab(i).attribute5, k_VNULL) <> NVL(x_match_rec.attribute5, k_VNULL) THEN
13108 --
13109 IF (l_debug <> -1) THEN
13110 rlm_core_sv.dlog(k_DEBUG, 'A5 num didnt match');
13111 END IF;
13112 --
13113 RAISE e_NoMatch;
13114 END IF;
13115 END IF;
13116
13117 IF (x_Group_rec.match_within_rec.attribute6 = 'Y') THEN
13118 IF NVL(g_IntransitTab(i).attribute6, k_VNULL) <> NVL(x_match_rec.attribute6, k_VNULL) THEN
13119 --
13120 IF (l_debug <> -1) THEN
13121 rlm_core_sv.dlog(k_DEBUG, 'A6 num didnt match');
13122 END IF;
13123 --
13124 RAISE e_NoMatch;
13125 END IF;
13126 END IF;
13127
13128 IF (x_Group_rec.match_within_rec.attribute7 = 'Y') THEN
13129 IF NVL(g_IntransitTab(i).attribute7, k_VNULL) <> NVL(x_match_rec.attribute7, k_VNULL) THEN
13130 --
13131 IF (l_debug <> -1) THEN
13132 rlm_core_sv.dlog(k_DEBUG, 'A7 num didnt match');
13133 END IF;
13134 --
13135 RAISE e_NoMatch;
13136 END IF;
13137 END IF;
13138
13139 IF (x_Group_rec.match_within_rec.attribute8 = 'Y') THEN
13140 IF NVL(g_IntransitTab(i).attribute8, k_VNULL) <> NVL(x_match_rec.attribute8, k_VNULL) THEN
13141 --
13142 IF (l_debug <> -1) THEN
13143 rlm_core_sv.dlog(k_DEBUG, 'A8 num didnt match');
13144 END IF;
13145 --
13146 RAISE e_NoMatch;
13147 END IF;
13148 END IF;
13149
13150 IF (x_Group_rec.match_within_rec.attribute9 = 'Y') THEN
13151 IF NVL(g_IntransitTab(i).attribute9, k_VNULL) <> NVL(x_match_rec.attribute9, k_VNULL) THEN
13152 --
13153 IF (l_debug <> -1) THEN
13154 rlm_core_sv.dlog(k_DEBUG, 'A9 num didnt match');
13155 END IF;
13156 --
13157 RAISE e_NoMatch;
13158 END IF;
13159 END IF;
13160
13161 IF (x_Group_rec.match_within_rec.attribute10 = 'Y') THEN
13162 IF NVL(g_IntransitTab(i).attribute10, k_VNULL) <> NVL(x_match_rec.attribute10, k_VNULL) THEN
13163 --
13164 IF (l_debug <> -1) THEN
13165 rlm_core_sv.dlog(k_DEBUG, 'A10 num didnt match');
13166 END IF;
13167 --
13168 RAISE e_NoMatch;
13169 END IF;
13170 END IF;
13171
13172 IF (x_Group_rec.match_within_rec.attribute11 = 'Y') THEN
13173 IF NVL(g_IntransitTab(i).attribute11, k_VNULL) <> NVL(x_match_rec.attribute11, k_VNULL) THEN
13174 --
13175 IF (l_debug <> -1) THEN
13176 rlm_core_sv.dlog(k_DEBUG, 'A11 num didnt match');
13177 END IF;
13178 --
13179 RAISE e_NoMatch;
13180 END IF;
13181 END IF;
13182
13183 IF (x_Group_rec.match_within_rec.attribute12 = 'Y') THEN
13184 IF NVL(g_IntransitTab(i).attribute12, k_VNULL) <> NVL(x_match_rec.attribute12, k_VNULL) THEN
13185 --
13186 IF (l_debug <> -1) THEN
13187 rlm_core_sv.dlog(k_DEBUG, 'A12 num didnt match');
13188 END IF;
13189 --
13190 RAISE e_NoMatch;
13191 END IF;
13192 END IF;
13193
13194 IF (x_Group_rec.match_within_rec.attribute13 = 'Y') THEN
13195 IF NVL(g_IntransitTab(i).attribute13, k_VNULL) <> NVL(x_match_rec.attribute13, k_VNULL) THEN
13196 --
13197 IF (l_debug <> -1) THEN
13198 rlm_core_sv.dlog(k_DEBUG, 'A13 num didnt match');
13199 END IF;
13200 --
13201 RAISE e_NoMatch;
13202 END IF;
13203 END IF;
13204
13205 IF (x_Group_rec.match_within_rec.attribute14 = 'Y') THEN
13206 IF NVL(g_IntransitTab(i).attribute14, k_VNULL) <> NVL(x_match_rec.attribute14, k_VNULL) THEN
13207 --
13208 IF (l_debug <> -1) THEN
13209 rlm_core_sv.dlog(k_DEBUG, 'A14 num didnt match');
13210 END IF;
13211 --
13212 RAISE e_NoMatch;
13213 END IF;
13214 END IF;
13215
13216 IF (x_Group_rec.match_within_rec.attribute15 = 'Y') THEN
13217 IF NVL(g_IntransitTab(i).attribute15, k_VNULL) <> NVL(x_match_rec.attribute15, k_VNULL) THEN
13218 --
13219 IF (l_debug <> -1) THEN
13220 rlm_core_sv.dlog(k_DEBUG, 'A15 num didnt match');
13221 END IF;
13222 --
13223 RAISE e_NoMatch;
13224 END IF;
13225 END IF;
13226 --
13227 b_Match := TRUE;
13228 --
13229 IF (l_debug <> -1) THEN
13230 rlm_core_sv.dlog(k_DEBUG, 'Matched with index', i);
13231 END IF;
13232 --
13233 x_Index := i;
13234 EXIT;
13235 --
13236 EXCEPTION
13237 WHEN e_NoMatch THEN
13238 null;
13239 END;
13240 --
13241 END LOOP;
13242 --
13243 IF (l_debug <> -1) THEN
13244 rlm_core_sv.dpop(k_SDEBUG, 'AlreadyMatched');
13245 END IF;
13246 --
13247 RETURN (b_Match);
13248 --
13249 END AlreadyMatched;
13250
13251 /*===========================================================================
13252
13253 FUNCTION NAME: MRPOnly
13254
13255 ===========================================================================*/
13256
13257 FUNCTION MRPOnly(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13258 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
13259 RETURN BOOLEAN
13260
13261 IS
13262 --
13263 v_Progress VARCHAR2(3) := '010';
13264 --
13265 BEGIN
13266 --
13267 IF (l_debug <> -1) THEN
13268 rlm_core_sv.dpush(k_SDEBUG, 'MRPOnly');
13269 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab.COUNT', g_Op_tab.COUNT);
13270 END IF;
13271 --
13272 IF x_Sched_rec.Schedule_Source <> 'MANUAL' THEN
13273
13274 IF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_PLANNING THEN
13275 --
13276 IF (l_debug <> -1) THEN
13277 rlm_core_sv.dlog(k_DEBUG, 'pln_mrp_forecast_day_from',
13278 x_group_rec.setup_terms_rec.pln_mrp_forecast_day_from);
13279 END IF;
13280 --
13281 IF x_Group_rec.setup_terms_rec.pln_mrp_forecast_day_from = 1 THEN
13282 --
13283 IF (l_debug <> -1) THEN
13284 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13285 END IF;
13286 --
13287 RETURN TRUE;
13288 --
13289 ELSE
13290 --
13291 IF (l_debug <> -1) THEN
13292 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13293 END IF;
13294 --
13295 RETURN FALSE;
13296 --
13297 END IF;
13298 --
13299 ELSIF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_SHIPPING THEN
13300 --
13301 IF (l_debug <> -1) THEN
13302 rlm_core_sv.dlog(k_DEBUG, 'shp_mrp_forecast_day_from',
13303 x_group_rec.setup_terms_rec.shp_mrp_forecast_day_from);
13304 END IF;
13305 --
13306 IF x_Group_rec.setup_terms_rec.shp_mrp_forecast_day_from = 1 THEN
13307 --
13308 IF (l_debug <> -1) THEN
13309 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13310 END IF;
13311 --
13312 RETURN TRUE;
13313 --
13314 ELSE
13315 --
13316 IF (l_debug <> -1) THEN
13317 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13318 END IF;
13319 --
13320 RETURN FALSE;
13321 --
13322 END IF;
13323 --
13324 ELSIF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_SEQUENCED THEN
13325 --
13326 IF (l_debug <> -1) THEN
13327 rlm_core_sv.dlog(k_DEBUG, 'seq_mrp_forecast_day_from',
13328 x_group_rec.setup_terms_rec.seq_mrp_forecast_day_from);
13329 END IF;
13330 --
13331 IF x_Group_rec.setup_terms_rec.seq_mrp_forecast_day_from = 1 THEN
13332 --
13333 IF (l_debug <> -1) THEN
13334 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13335 END IF;
13336 --
13337 RETURN TRUE;
13338 --
13339 ELSE
13340 --
13341 IF (l_debug <> -1) THEN
13342 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13343 END IF;
13344 --
13345 RETURN FALSE;
13346 --
13347 END IF;
13348 --
13349 ELSE
13350 --
13351 IF (l_debug <> -1) THEN
13352 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13353 END IF;
13354 --
13355 RETURN FALSE;
13356 --
13357 END IF;
13358 --
13359 ELSE
13360 --
13361 IF (l_debug <> -1) THEN
13362 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13363 END IF;
13364 --
13365 RETURN FALSE;
13366 --
13367 END IF;
13368 --
13369 EXCEPTION
13370 --
13371 WHEN OTHERS THEN
13372 --
13373 rlm_message_sv.sql_error('RLM_RD_SV.MRPOnly', v_Progress);
13374 --
13375 IF (l_debug <> -1) THEN
13376 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '|| SUBSTR(SQLERRM,1,200));
13377 END IF;
13378 --
13379 raise;
13380 --
13381 END MRPOnly;
13382
13383
13384 PROCEDURE InsertIntransitMatchRec(x_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec,
13385 x_Quantity IN NUMBER) IS
13386 v_Index NUMBER;
13387
13388 BEGIN
13389 --
13390 IF (l_debug <> -1) THEN
13391 rlm_core_sv.dpush(k_SDEBUG, 'InsertIntransitMatchRec');
13392 END IF;
13393 --
13394 v_Index := g_IntransitTab.COUNT;
13395 --
13396 IF (l_debug <> -1) THEN
13397 rlm_core_sv.dlog(k_DEBUG, '# of rows in intransit table', v_Index);
13398 END IF;
13399 --
13400 g_IntransitTab(v_Index+1).cust_production_line := x_match_rec.cust_production_line;
13401 g_IntransitTab(v_Index+1).customer_dock_code := x_match_rec.customer_dock_code;
13402 g_IntransitTab(v_Index+1).request_date := NULL; --x_match_rec.request_date;
13403 g_IntransitTab(v_Index+1).schedule_date := NULL; --x_match_rec.schedule_date;
13404 g_IntransitTab(v_Index+1).cust_po_number := x_match_rec.cust_po_number;
13405 g_IntransitTab(v_Index+1).customer_item_revision := x_match_rec.customer_item_revision;
13406 g_IntransitTab(v_Index+1).customer_job := x_match_rec.customer_job;
13407 g_IntransitTab(v_Index+1).cust_model_serial_number := x_match_rec.cust_model_serial_number;
13408 g_IntransitTab(v_Index+1).cust_production_seq_num := x_match_rec.cust_production_seq_num;
13409 g_IntransitTab(v_Index+1).industry_attribute1 := x_match_rec.industry_attribute1;
13410 g_IntransitTab(v_Index+1).industry_attribute2 := NULL; --x_match_rec.industry_attribute2;
13411 g_IntransitTab(v_Index+1).industry_attribute3 := NULL; --x_match_rec.industry_attribute3;
13412 g_IntransitTab(v_Index+1).industry_attribute4 := x_match_rec.industry_attribute4;
13413 g_IntransitTab(v_Index+1).industry_attribute5 := x_match_rec.industry_attribute5;
13414 g_IntransitTab(v_Index+1).industry_attribute6 := x_match_rec.industry_attribute6;
13415 g_IntransitTab(v_Index+1).industry_attribute7 := NULL; --x_match_rec.industry_attribute7;
13416 g_IntransitTab(v_Index+1).industry_attribute8 := NULL; --x_match_rec.industry_attribute8;
13417 g_IntransitTab(v_Index+1).industry_attribute9 := x_match_rec.industry_attribute9;
13418 g_IntransitTab(v_Index+1).industry_attribute10 := x_match_rec.industry_attribute10;
13419 g_IntransitTab(v_Index+1).industry_attribute11 := x_match_rec.industry_attribute11;
13420 g_IntransitTab(v_Index+1).industry_attribute12 := x_match_rec.industry_attribute12;
13421 g_IntransitTab(v_Index+1).industry_attribute13 := x_match_rec.industry_attribute13;
13422 g_IntransitTab(v_Index+1).industry_attribute14 := x_match_rec.industry_attribute14;
13423 g_IntransitTab(v_Index+1).industry_attribute15 := x_match_rec.industry_attribute15;
13424 g_IntransitTab(v_Index+1).attribute1 := x_match_rec.attribute1;
13425 g_IntransitTab(v_Index+1).attribute2 := x_match_rec.attribute2;
13426 g_IntransitTab(v_Index+1).attribute3 := x_match_rec.attribute3;
13427 g_IntransitTab(v_Index+1).attribute4 := x_match_rec.attribute4;
13428 g_IntransitTab(v_Index+1).attribute5 := x_match_rec.attribute5;
13429 g_IntransitTab(v_Index+1).attribute6 := x_match_rec.attribute6;
13430 g_IntransitTab(v_Index+1).attribute7 := x_match_rec.attribute7;
13431 g_IntransitTab(v_Index+1).attribute8 := x_match_rec.attribute8;
13432 g_IntransitTab(v_Index+1).attribute9 := x_match_rec.attribute9;
13433 g_IntransitTab(v_Index+1).attribute10 := x_match_rec.attribute10;
13434 g_IntransitTab(v_Index+1).attribute11 := x_match_rec.attribute11;
13435 g_IntransitTab(v_Index+1).attribute12 := x_match_rec.attribute12;
13436 g_IntransitTab(v_Index+1).attribute13 := x_match_rec.attribute13;
13437 g_IntransitTab(v_Index+1).attribute14 := x_match_rec.attribute14;
13438 g_IntransitTab(v_Index+1).attribute15 := x_match_rec.attribute15;
13439 g_IntransitTab(v_Index+1).intransit_qty := x_Quantity;
13440 --
13441 IF (l_debug <> -1) THEN
13442 rlm_core_sv.dpop(k_SDEBUG, 'InsertIntransitMatchRec');
13443 END IF;
13444 --
13445 END InsertIntransitMatchRec;
13446
13447
13448 --
13449 -- Common to reconcile and manage demand
13450 -- Set up parameters to pass to shipping API
13451 --
13452 PROCEDURE InitializeIntransitParam(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13453 x_Group_rec IN rlm_dp_sv.t_Group_rec,
13454 x_intransit_calc_basis IN VARCHAR2,
13455 x_Shipper_rec IN OUT NOCOPY WSH_RLM_INTERFACE.t_shipper_rec,
13456 x_Shipment_date IN OUT NOCOPY DATE)
13457 IS
13458
13459 -- The shipper ID is stored in the item_detail_ref_value_1 field
13460 -- when the item detail type = 4 and the sub type = 'RECEIPT', 'SHIPMENT'
13461 --
13462 CURSOR c_RctShipperIds IS
13463 SELECT start_date_time,
13464 primary_quantity,
13465 -- do not use item_ref_value_1
13466 substr(item_detail_ref_value_1,1,29) shipper_Id,
13467 line_id
13468 FROM rlm_schedule_lines
13469 WHERE ship_from_org_id = x_Group_rec.ship_from_org_id
13470 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13471 AND inventory_item_id = x_Group_rec.inventory_item_id
13472 AND customer_item_id = x_Group_rec.customer_item_id
13473 AND item_detail_type = k_RECT
13474 AND qty_type_code = k_ACTUAL
13475 AND item_detail_subtype = k_RECEIPT
13476 ORDER BY start_date_time DESC;
13477
13478 CURSOR c_ShpShipperIds IS
13479 SELECT start_date_time,
13480 primary_quantity,
13481 -- do not use item_ref_value_1
13482 substr(item_detail_ref_value_1,1,29) shipper_Id,
13483 line_id
13484 FROM rlm_schedule_lines
13485 WHERE ship_from_org_id = x_Group_rec.ship_from_org_id
13486 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13487 AND inventory_item_id = x_Group_rec.inventory_item_id
13488 AND customer_item_id = x_Group_rec.customer_item_id
13489 AND item_detail_type = k_RECT
13490 AND qty_type_code = k_ACTUAL
13491 AND item_detail_subtype = k_SHIPMENT
13492 ORDER BY start_date_time DESC;
13493
13494 --
13495 -- This cursor is to select the most recent receipt
13496 -- line on the current schedule for each group
13497 --
13498
13499 CURSOR c_LastReceipt IS
13500 SELECT start_date_time,
13501 item_detail_subtype,
13502 item_detail_ref_value_1
13503 FROM rlm_interface_lines
13504 WHERE header_id = x_Sched_rec.header_id
13505 AND ship_from_org_id = x_Group_rec.ship_from_org_id
13506 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13507 AND inventory_item_id = x_Group_rec.inventory_item_id
13508 AND customer_item_id = x_Group_rec.customer_item_id
13509 AND item_detail_type = k_RECT
13510 AND qty_type_code = k_ACTUAL
13511 AND item_detail_subtype = k_RECEIPT
13512 ORDER BY start_date_time DESC;
13513
13514 --
13515 -- This cursor is to select the most recent shipment
13516 -- line on the current schedule for each group
13517 --
13518
13519 CURSOR c_LastShipment IS
13520 SELECT start_date_time,
13521 item_detail_subtype,
13522 item_detail_ref_value_1
13523 FROM rlm_interface_lines
13524 WHERE header_id = x_Sched_rec.header_id
13525 AND ship_from_org_id = x_Group_rec.ship_from_org_id
13526 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13527 AND inventory_item_id = x_Group_rec.inventory_item_id
13528 AND customer_item_id = x_Group_rec.customer_item_id
13529 AND item_detail_type = k_RECT
13530 AND qty_type_code = k_ACTUAL
13531 AND item_detail_subtype = k_SHIPMENT
13532 ORDER BY start_date_time DESC;
13533 --
13534 v_intransit_time NUMBER := 0;
13535 v_intransit_calc_basis VARCHAR2(15);
13536 v_shipment_date DATE;
13537 v_item_detail_subtype VARCHAR2(80);
13538 v_count NUMBER DEFAULT 0;
13539 v_deliveryID VARCHAR2(35);
13540 --
13541
13542 BEGIN
13543 --
13544 IF (l_debug <> -1) THEN
13545 rlm_core_sv.dpush(k_SDEBUG, 'InitializeIntransitParam');
13546 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis', x_intransit_calc_basis);
13547 END IF;
13548 --
13549 IF (x_Group_rec.setup_terms_rec.time_uom_code = 'HR') THEN
13550 v_intransit_time := nvl(x_Group_rec.setup_terms_rec.intransit_time,0)/24;
13551 ELSE
13552 v_intransit_time := nvl(x_Group_rec.setup_terms_rec.intransit_time,0);
13553 END IF;
13554 --
13555 IF (x_intransit_calc_basis = k_RECEIPT) THEN
13556 --
13557 OPEN c_LastReceipt;
13558 FETCH c_LastReceipt INTO v_shipment_date, v_item_detail_subtype, v_deliveryID;
13559 --
13560 IF (c_LastReceipt%NOTFOUND) THEN
13561 --
13562 IF (l_debug <> -1) THEN
13563 rlm_core_sv.dlog(k_DEBUG, 'No receipt line, so shipment date = sched_gen_Date - intransit');
13564 END IF;
13565 --
13566 v_shipment_date := x_Sched_rec.sched_generation_date - v_intransit_time;
13567 x_shipper_rec.shipper_Id1 := NULL;
13568 x_Shipper_rec.shipper_Id2 := NULL;
13569 x_Shipper_rec.shipper_Id3 := NULL;
13570 x_Shipper_rec.shipper_Id4 := NULL;
13571 x_Shipper_rec.shipper_Id5 := NULL;
13572 --
13573 ELSIF (v_deliveryID is NOT NULL) THEN
13574 --
13575 IF (l_debug <> -1) THEN
13576 rlm_core_sv.dlog('Delivery ID present on schedule');
13577 END IF;
13578 --
13579 FOR v_RctSID IN c_RctShipperIds LOOP
13580 --
13581 IF (c_RctShipperIds%NOTFOUND OR v_count > 5) THEN
13582 EXIT;
13583 END IF;
13584 --
13585 v_count := v_count + 1;
13586 --
13587 IF (l_debug <> -1) THEN
13588 rlm_core_sv.dlog(k_DEBUG,'line_id', v_RctSID.line_id);
13589 rlm_core_sv.dlog(k_DEBUG,'start_date_time', v_RctSID.start_date_time);
13590 rlm_core_sv.dlog(k_DEBUG,'v_count', v_count);
13591 rlm_core_sv.dlog(k_DEBUG,'Shipper_id', v_RctSID.shipper_Id);
13592 END IF;
13593 --
13594 IF v_count = 1 THEN
13595 --
13596 x_shipper_rec.shipper_Id1 := v_RctSID.shipper_Id;
13597 --
13598 ELSIF v_count = 2 THEN
13599 --
13600 x_shipper_rec.shipper_Id2 := v_RctSID.shipper_Id;
13601 --
13602 ELSIF v_count = 3 THEN
13603 --
13604 x_shipper_rec.shipper_Id3 := v_RctSID.shipper_Id;
13605 --
13606 ELSIF v_count = 4 THEN
13607 --
13608 x_shipper_rec.shipper_Id4 := v_RctSID.shipper_Id;
13609 --
13610 ELSIF v_count = 5 THEN
13611 --
13612 x_shipper_rec.shipper_Id5 := v_RctSID.shipper_Id;
13613 --
13614 END IF;
13615 --
13616 END LOOP;
13617 --
13618 ELSIF (v_shipment_date IS NOT NULL) THEN
13619 --
13620 IF (l_debug <> -1) THEN
13621 rlm_core_sv.dlog(k_DEBUG, 'No delivery ID present on schedule');
13622 END IF;
13623 --
13624 v_shipment_date := v_shipment_date - v_intransit_time;
13625 x_shipper_rec.shipper_Id1 := NULL;
13626 x_Shipper_rec.shipper_Id2 := NULL;
13627 x_Shipper_rec.shipper_Id3 := NULL;
13628 x_Shipper_rec.shipper_Id4 := NULL;
13629 x_Shipper_rec.shipper_Id5 := NULL;
13630 --
13631 END IF;
13632 --
13633 IF (l_debug <> -1) THEN
13634 rlm_core_sv.dlog(k_DEBUG, 'v_item_detail_subtype', v_item_detail_subtype);
13635 rlm_core_sv.dlog(k_DEBUG, 'calculated shipment_date', v_shipment_date);
13636 END IF;
13637 --
13638 x_Shipment_date := v_shipment_date;
13639 CLOSE c_LastReceipt;
13640 --
13641 ELSIF (x_intransit_calc_basis = k_SHIPMENT) THEN
13642 --
13643 OPEN c_LastShipment;
13644 FETCH c_LastShipment INTO v_shipment_date, v_item_detail_subtype, v_deliveryID;
13645 --
13646 IF (c_LastShipment%NOTFOUND) THEN
13647 --
13648 IF (l_debug <> -1) THEN
13649 rlm_core_sv.dlog(k_DEBUG, 'No shipment line, so shipment date = sched_gen_Date');
13650 END IF;
13651 --
13652 v_shipment_date := x_Sched_rec.sched_generation_date;
13653 x_shipper_rec.shipper_Id1 := NULL;
13654 x_Shipper_rec.shipper_Id2 := NULL;
13655 x_Shipper_rec.shipper_Id3 := NULL;
13656 x_Shipper_rec.shipper_Id4 := NULL;
13657 x_Shipper_rec.shipper_Id5 := NULL;
13658 --
13659 ELSIF (v_deliveryID is NOT NULL) THEN
13660 --
13661 IF (l_debug <> -1) THEN
13662 rlm_core_sv.dlog('Delivery ID present on schedule');
13663 END IF;
13664 --
13665 FOR v_ShpSID IN c_ShpShipperIds LOOP
13666 --
13667 IF (c_ShpShipperIds%NOTFOUND OR v_count > 5) THEN
13668 EXIT;
13669 END IF;
13670 --
13671 v_count := v_count + 1;
13672 --
13673 IF (l_debug <> -1) THEN
13674 rlm_core_sv.dlog(k_DEBUG,'line_id', v_ShpSID.line_id);
13675 rlm_core_sv.dlog(k_DEBUG,'start_date_time', v_ShpSID.start_date_time);
13676 rlm_core_sv.dlog(k_DEBUG,'v_count', v_count);
13677 rlm_core_sv.dlog(k_DEBUG,'Shipper_id', v_ShpSID.shipper_Id);
13678 END IF;
13679 --
13680 IF v_count = 1 THEN
13681 --
13682 x_shipper_rec.shipper_Id1 := v_ShpSID.shipper_Id;
13683 --
13684 ELSIF v_count = 2 THEN
13685 --
13686 x_shipper_rec.shipper_Id2 := v_ShpSID.shipper_Id;
13687 --
13688 ELSIF v_count = 3 THEN
13689 --
13690 x_shipper_rec.shipper_Id3 := v_ShpSID.shipper_Id;
13691 --
13692 ELSIF v_count = 4 THEN
13693 --
13694 x_shipper_rec.shipper_Id4 := v_ShpSID.shipper_Id;
13695 --
13696 ELSIF v_count = 5 THEN
13697 --
13698 x_shipper_rec.shipper_Id5 := v_ShpSID.shipper_Id;
13699 --
13700 END IF;
13701 --
13702 END LOOP;
13703 --
13704 ELSIF (v_shipment_date IS NOT NULL) THEN
13705 --
13706 IF (l_debug <> -1) THEN
13707 rlm_core_sv.dlog(k_DEBUG, 'No delivery ID present on schedule');
13708 END IF;
13709 --
13710 x_shipper_rec.shipper_Id1 := NULL;
13711 x_Shipper_rec.shipper_Id2 := NULL;
13712 x_Shipper_rec.shipper_Id3 := NULL;
13713 x_Shipper_rec.shipper_Id4 := NULL;
13714 x_Shipper_rec.shipper_Id5 := NULL;
13715 --
13716 END IF;
13717 --
13718 IF (l_debug <> -1) THEN
13719 rlm_core_sv.dlog(k_DEBUG, 'v_item_detail_subtype', v_item_detail_subtype);
13720 rlm_core_sv.dlog(k_DEBUG, 'calculated shipment_date', v_shipment_date);
13721 END IF;
13722 --
13723 x_Shipment_date := v_shipment_date;
13724 CLOSE c_LastShipment;
13725 --
13726 END IF; /* if intransit_calc_basis */
13727 --
13728 IF (l_debug <> -1) THEN
13729 rlm_core_sv.dpop(k_SDEBUG, 'InitializeIntransitParam');
13730 END IF;
13731 --
13732 END InitializeIntransitParam;
13733
13734
13735 --
13736 -- Blanket Order Procedures
13737 --
13738 /*===========================================================================
13739
13740 PROCEDURE InitializeBlktGroup
13741
13742 ===========================================================================*/
13743 PROCEDURE InitializeBlktGrp(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13744 x_Group_ref IN OUT NOCOPY rlm_rd_sv.t_Cursor_ref,
13745 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
13746 IS
13747 --
13748 x_progress VARCHAR2(3) := '010';
13749 --
13750 BEGIN
13751 --
13752 IF (l_debug <> -1) THEN
13753 rlm_core_sv.dpush(k_SDEBUG,'InitializeBlktGroup');
13754 END IF;
13755 --
13756 OPEN x_Group_ref FOR
13757 SELECT rih.customer_id,
13758 ril.ship_from_org_id,
13759 ril.ship_to_address_id,
13760 ril.ship_to_org_id,
13761 ril.customer_item_id,
13762 ril.inventory_item_id,
13763 ril.industry_attribute15,
13764 rso.rso_hdr_id,
13765 ril.blanket_number,
13766 rso.effective_start_date,
13767 ril.intrmd_ship_to_id, --Bugfix 5911991
13768 ril.intmed_ship_to_org_id --Bugfix 5911991
13769 FROM rlm_interface_headers rih,
13770 rlm_interface_lines_all ril,
13771 rlm_blanket_rso rso
13772 WHERE rih.header_id = x_Sched_rec.header_id
13773 AND rih.org_id = ril.org_id
13774 AND ril.header_id = rih.header_id
13775 AND ril.ship_from_org_id = x_Group_rec.ship_from_org_id
13776 AND ril.process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
13777 AND ril.customer_item_id = x_Group_rec.customer_item_id
13778 AND ril.ship_to_address_id = x_Group_rec.ship_to_address_id
13779 AND ril.blanket_number = rso.blanket_number
13780 AND rih.customer_id = rso.customer_id
13781 AND item_detail_type IN (k_FIRM, k_FORECAST, k_PAST_DUE_FIRM)
13782 AND rso.customer_item_id = DECODE(x_Group_rec.setup_terms_rec.release_rule, 'PI',
13783 x_Group_rec.customer_item_id, K_NNULL)
13784 GROUP BY rih.customer_id,
13785 ril.ship_from_org_id,
13786 ril.ship_to_address_id,
13787 ril.ship_to_org_id,
13788 ril.customer_item_id,
13789 ril.inventory_item_id,
13790 ril.industry_attribute15,
13791 rso.rso_hdr_id,
13792 ril.blanket_number,
13793 rso.effective_start_date,
13794 ril.intrmd_ship_to_id, --Bugfix 5911991
13795 ril.intmed_ship_to_org_id --Bugfix 5911991
13796 ORDER BY ril.ship_from_org_id,
13797 ril.ship_to_org_id,
13798 ril.customer_item_id,
13799 rso.effective_start_date;
13800 --
13801 IF (l_debug <> -1) THEN
13802 rlm_core_sv.dpop(k_SDEBUG);
13803 END IF;
13804 --
13805 EXCEPTION
13806 --
13807 WHEN OTHERS THEN
13808 rlm_message_sv.sql_error('rlm_rd_sv.InitializeBlktGrp',x_progress);
13809 --
13810 IF (l_debug <> -1) THEN
13811 rlm_core_sv.dlog(k_DEBUG, 'When others of InitializeBlktGrp');
13812 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
13813 END IF;
13814 --
13815 raise e_group_error;
13816 --
13817 END InitializeBlktGrp;
13818
13819
13820 /*===========================================================================
13821
13822 FUNCTION FetchBlktGroup
13823
13824 ===========================================================================*/
13825 FUNCTION FetchBlktGrp(x_Group_ref IN OUT NOCOPY t_Cursor_ref,
13826 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
13827 RETURN BOOLEAN
13828 IS
13829 --
13830 x_progress VARCHAR2(3) := '010';
13831 v_effective_start_date DATE;
13832 --
13833 BEGIN
13834 --
13835 IF (l_debug <> -1) THEN
13836 rlm_core_sv.dpush(k_SDEBUG,'FetchBlktGroup');
13837 END IF;
13838 --
13839 FETCH x_Group_ref INTO
13840 x_Group_rec.customer_id,
13841 x_Group_rec.ship_from_org_id,
13842 x_Group_rec.ship_to_address_id,
13843 x_Group_rec.ship_to_org_id,
13844 x_Group_rec.customer_item_id,
13845 x_Group_rec.inventory_item_id,
13846 x_Group_rec.industry_attribute15,
13847 x_Group_rec.order_header_id,
13848 x_Group_rec.blanket_number,
13849 v_effective_start_date,
13850 x_Group_rec.intrmd_ship_to_id, --Bugfix 5911991
13851 x_Group_rec.intmed_ship_to_org_id ; --Bugfix 5911991
13852 --
13853 IF (l_debug <> -1) THEN
13854 rlm_core_sv.dlog(k_DEBUG,'Blanket Number', x_Group_rec.blanket_number);
13855 rlm_core_sv.dlog(k_DEBUG,'Order header ID', x_Group_rec.order_header_id);
13856 rlm_core_sv.dlog(k_DEBUG,'v_effective_start_date',v_effective_start_date);
13857 END IF;
13858 --
13859 IF x_Group_ref%NOTFOUND THEN
13860 --
13861 IF (l_debug <> -1) THEN
13862 rlm_core_sv.dpop(k_SDEBUG, 'false');
13863 END IF;
13864 --
13865 RETURN(FALSE);
13866 ELSE
13867 --
13868 IF (l_debug <> -1) THEN
13869 rlm_core_sv.dpop(k_SDEBUG, 'true');
13870 END IF;
13871 --
13872 RETURN(TRUE);
13873 END IF;
13874 --
13875 EXCEPTION
13876 --
13877 WHEN OTHERS THEN
13878 rlm_message_sv.sql_error('rlm_rd_sv.FetchBlktGrp',x_progress);
13879 --
13880 IF (l_debug <> -1) THEN
13881 rlm_core_sv.dlog(k_DEBUG, 'When others of FetchBlktGrp');
13882 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
13883 END IF;
13884 --
13885 raise;
13886 --
13887 END FetchBlktGrp;
13888
13889
13890 /* *
13891 * SQL Bind Project: These functions just build a combined table *
13892 * of bind variable values to be passed to RLM_CORE_SV.OpenDynamicCursor *
13893 */
13894 FUNCTION BuildBindVarTab3(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
13895 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab,
13896 p_Tab3 IN RLM_CORE_SV.t_dynamic_tab)
13897 RETURN RLM_CORE_SV.t_dynamic_tab IS
13898 --
13899 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
13900 x_Progress VARCHAR2(3) := '010';
13901 --
13902 BEGIN
13903 --
13904 IF (l_debug <> -1) THEN
13905 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab3');
13906 END IF;
13907 --
13908 FOR i IN 1..p_Tab1.COUNT LOOP
13909 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
13910 END LOOP;
13911 --
13912 FOR i IN 1..p_Tab2.COUNT LOOP
13913 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
13914 END LOOP;
13915 --
13916 FOR i IN 1..p_Tab3.COUNT LOOP
13917 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab3(i);
13918 END LOOP;
13919 --
13920 IF (l_debug <> -1) THEN
13921 rlm_core_sv.dpop(k_SDEBUG);
13922 END IF;
13923 --
13924 RETURN x_BindVarTab;
13925 --
13926 EXCEPTION
13927 --
13928 WHEN OTHERS THEN
13929 --
13930 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab3',x_progress);
13931 --
13932 IF (l_debug <> -1) THEN
13933 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
13934 END IF;
13935 --
13936 raise;
13937 --
13938 END BuildBindVarTab3;
13939
13940
13941 FUNCTION BuildBindVarTab5(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
13942 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab,
13943 p_Tab3 IN RLM_CORE_SV.t_dynamic_tab,
13944 p_Tab4 IN RLM_CORE_SV.t_dynamic_tab,
13945 p_Tab5 IN RLM_CORE_SV.t_dynamic_tab)
13946 RETURN RLM_CORE_SV.t_dynamic_tab IS
13947 --
13948 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
13949 x_Progress VARCHAR2(3) := '010';
13950 --
13951 BEGIN
13952 --
13953 IF (l_debug <> -1) THEN
13954 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab5');
13955 END IF;
13956 --
13957 FOR i IN 1..p_Tab1.COUNT LOOP
13958 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
13959 END LOOP;
13960 --
13961 FOR i IN 1..p_Tab2.COUNT LOOP
13962 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
13963 END LOOP;
13964 --
13965 FOR i IN 1..p_Tab3.COUNT LOOP
13966 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab3(i);
13967 END LOOP;
13968 --
13969 FOR i IN 1..p_Tab4.COUNT LOOP
13970 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab4(i);
13971 END LOOP;
13972 --
13973 FOR i IN 1..p_Tab5.COUNT LOOP
13974 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab5(i);
13975 END LOOP;
13976 --
13977 IF (l_debug <> -1) THEN
13978 rlm_core_sv.dpop(k_SDEBUG);
13979 END IF;
13980 --
13981 RETURN x_BindVarTab;
13982 --
13983 EXCEPTION
13984 --
13985 WHEN OTHERS THEN
13986 --
13987 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab5',x_progress);
13988 --
13989 IF (l_debug <> -1) THEN
13990 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
13991 END IF;
13992 --
13993 raise;
13994 --
13995 END BuildBindVarTab5;
13996
13997
13998 FUNCTION BuildBindVarTab2(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
13999 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab)
14000 RETURN RLM_CORE_SV.t_dynamic_tab IS
14001 --
14002 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
14003 x_Progress VARCHAR2(3) := '010';
14004 --
14005 BEGIN
14006 --
14007 IF (l_debug <> -1) THEN
14008 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab2');
14009 END IF;
14010 --
14011 FOR i IN 1..p_Tab1.COUNT LOOP
14012 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
14013 END LOOP;
14014 --
14015 FOR i IN 1..p_Tab2.COUNT LOOP
14016 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
14017 END LOOP;
14018 --
14019 IF (l_debug <> -1) THEN
14020 rlm_core_sv.dpop(k_SDEBUG);
14021 END IF;
14022 --
14023 RETURN x_BindVarTab;
14024 --
14025 EXCEPTION
14026 --
14027 WHEN OTHERS THEN
14028 --
14029 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab2',x_progress);
14030 --
14031 IF (l_debug <> -1) THEN
14032 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
14033 END IF;
14034 --
14035 raise;
14036 --
14037 END BuildBindVarTab2;
14038
14039
14040 /*============================================================================
14041
14042 PROCEDURE NAME: SourceCUMIntransitQty
14043
14044 ==============================================================================*/
14045 PROCEDURE SourceCUMIntransitQty(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
14046 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
14047 x_Cum_rec IN RLM_RD_SV.t_Ship_rec) --Bugfix 7007638
14048 IS
14049 --
14050 i NUMBER;
14051 j NUMBER;
14052 v_SrcIntransitTab RLM_MANAGE_DEMAND_SV.t_SrcIntransitQtyTab;
14053 v_Progress VARCHAR2(3);
14054 v_Key_rec t_Key_rec;
14055 --
14056 BEGIN
14057 --
14058 IF (l_debug <> -1) THEN
14059 rlm_core_sv.dpush(k_SDEBUG, 'SourceCUMIntransitQty');
14060 rlm_core_sv.dlog(k_DEBUG, 'IntransitQty to be sourced', g_IntransitQty);
14061 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab.COUNT', g_SourceTab.COUNT);
14062 --
14063 FOR i IN g_SourceTab.FIRST..g_SourceTab.LAST LOOP
14064 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab('||i||').organization_id',
14065 g_SourceTab(i).organization_id);
14066 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab('||i||').allocation_percent',
14067 g_SourceTab(i).allocation_percent);
14068 END LOOP;
14069 --
14070 END IF;
14071 --
14072 v_Progress := '010';
14073 --
14074 i := g_SourceTab.FIRST;
14075 j := 0;
14076 --
14077 WHILE i IS NOT NULL LOOP
14078 --{
14079 j := j+1;
14080 --
14081 v_SrcIntransitTab(j).intransit_qty :=
14082 ROUND(g_IntransitQty * g_SourceTab(i).allocation_percent/100);
14083 v_SrcIntransitTab(j).organization_id := g_SourceTab(i).organization_id;
14084 --
14085 IF (l_debug <> -1) THEN
14086 rlm_core_sv.dlog(k_DEBUG, 'v_SrcIntransitTab('||j||').intransit_qty',
14087 v_SrcIntransitTab(j).intransit_qty);
14088 rlm_core_sv.dlog(k_DEBUG, 'v_SrcIntransitTab('||j||').organization_id',
14089 v_SrcIntransitTab(j).organization_id);
14090 END IF;
14091 --
14092 i := g_SourceTab.NEXT(i);
14093 --}
14094 END LOOP;
14095 --
14096 v_Progress := '020';
14097 i := v_SrcIntransitTab.FIRST;
14098 --
14099 WHILE i IS NOT NULL LOOP
14100 --{
14101 IF v_SrcIntransitTab(i).organization_id = x_Group_rec.ship_from_org_id THEN
14102 --
14103 v_Key_rec.rlm_line_id := null;
14104 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
14105 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
14106 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
14107 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
14108 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
14109 v_Key_rec.req_rec.ship_from_org_id := v_SrcIntransitTab(i).organization_id;
14110 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
14111 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
14112 --
14113 -- Bugfix 7007638 Start
14114 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
14115 v_Key_rec.req_rec.cust_po_number := x_Cum_rec.purchase_order_number;
14116 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
14117 v_Key_rec.req_rec.industry_attribute1 := x_Cum_rec.cust_record_year;
14118 END IF;
14119 -- Bugfix 7007638 End
14120 RLM_RD_SV.StoreShipments(x_Sched_rec, x_Group_rec, v_Key_rec,
14121 v_SrcIntransitTab(i).intransit_qty);
14122 --
14123 END IF;
14124 --
14125 i := v_SrcIntransitTab.NEXT(i);
14126 --}
14127 END LOOP;
14128 --
14129 v_Progress := '030';
14130 --
14131 IF (l_debug <> -1) THEN
14132 rlm_core_sv.dpop(k_SDEBUG);
14133 END IF;
14134 --
14135 EXCEPTION
14136 --
14137 WHEN OTHERS THEN
14138 --
14139 rlm_message_sv.sql_error('RLM_RD_SV.SourceCUMIntransitQty',v_Progress);
14140 --
14141 IF (l_debug <> -1) THEN
14142 rlm_core_sv.dlog(k_DEBUG,'progress',v_Progress);
14143 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14144 END IF;
14145 --
14146 RAISE;
14147 --
14148 END SourceCUMIntransitQty;
14149
14150
14151
14152 PROCEDURE CalculateCUMIntransit(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
14153 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
14154 x_Line_id IN NUMBER, --Bugfix 7007638
14155 x_Intransit OUT NOCOPY NUMBER)
14156 IS
14157 --
14158 v_cum_key_record RLM_CUM_SV.cum_key_attrib_rec_type;
14159 v_cum_record RLM_CUM_SV.cum_rec_type;
14160 v_PrimaryQty NUMBER;
14161 v_CUMQty NUMBER;
14162 v_SupQty NUMBER;
14163 v_Intransit NUMBER;
14164 v_LineID NUMBER;
14165 v_Progress VARCHAR2(3);
14166 e_no_cum_key EXCEPTION;
14167 v_control_text VARCHAR2(100); --Bugfix 7007638
14168 v_control_value VARCHAR2(100); --Bugfix 7007638
14169 --
14170 BEGIN
14171 --
14172 IF (l_debug <> -1) THEN
14173 rlm_core_sv.dpush(k_SDEBUG, 'CalculateCUMIntransit');
14174 rlm_core_sv.dlog(k_DEBUG, 'x_Line_id', x_Line_id); --Bugfix 7007638
14175 END IF;
14176 --
14177 v_CUMQty := 0;
14178 v_SupQty := 0;
14179 v_Intransit := 0;
14180 v_Progress := '010';
14181 --
14182 SELECT x_group_rec.customer_id,
14183 customer_item_id,
14184 inventory_item_id,
14185 ship_from_org_id,
14186 intrmd_ship_to_id intrmd_ship_to_address_id,
14187 ship_to_address_id,
14188 bill_to_address_id,
14189 cust_po_number purchase_order_number,
14190 primary_quantity,
14191 item_detail_quantity,
14192 start_date_time,
14193 industry_attribute1 cust_record_year,
14194 line_id
14195 INTO v_cum_key_record.customer_id,
14196 v_cum_key_record.customer_item_id,
14197 v_cum_key_record.inventory_item_id,
14198 v_cum_key_record.ship_from_org_id,
14199 v_cum_key_record.intrmd_ship_to_address_id,
14200 v_cum_key_record.ship_to_address_id,
14201 v_cum_key_record.bill_to_address_id,
14202 v_cum_key_record.purchase_order_number,
14203 v_PrimaryQty,
14204 v_CUMQty,
14205 v_cum_key_record.cum_start_date,
14206 v_cum_key_record.cust_record_year,
14207 v_LineID
14208 FROM rlm_interface_lines
14209 WHERE header_id = x_Sched_rec.header_id
14210 AND item_detail_type = RLM_MANAGE_DEMAND_SV.k_SHIP_RECEIPT_INFO
14211 AND item_detail_subtype = RLM_MANAGE_DEMAND_SV.k_CUM
14212 AND ship_from_org_id = x_Group_rec.ship_from_org_id
14213 AND ship_to_address_id = x_Group_rec.ship_to_address_id
14214 AND inventory_item_id = x_Group_rec.inventory_item_id
14215 AND customer_item_id = x_Group_rec.customer_item_id
14216 AND line_id = x_Line_id --Bugfix 7007638
14217 ORDER BY start_date_time desc;
14218 --
14219 v_cum_key_record.create_cum_key_flag := 'N';
14220 RLM_TPA_SV.CalculateCUMKey(v_cum_key_record, v_cum_record);
14221 --
14222 v_Progress := '020';
14223 --
14224 IF v_cum_record.cum_key_id IS NULL THEN
14225 --Bugfix 7007638
14226 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
14227 rlm_message_sv.get_msg_text(
14228 x_message_name => 'RLM_CUM_CONTROL_PO',
14229 x_text => v_control_text);
14230 v_control_value := v_cum_key_record.purchase_order_number;
14231 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
14232 rlm_message_sv.get_msg_text(
14233 x_message_name => 'RLM_CUM_CONTROL_RY',
14234 x_text => v_control_text);
14235 v_control_value := v_cum_key_record.cust_record_year;
14236 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_ONLY') THEN
14237 rlm_message_sv.get_msg_text(
14238 x_message_name => 'RLM_CUM_CONTROL_DATE',
14239 x_text => v_control_text);
14240 v_control_value := v_cum_key_record.cum_start_date;
14241 END IF;
14242 --Bugfix 7007638
14243 --
14244 RAISE e_No_Cum_Key;
14245 --
14246 ELSE
14247 --
14248 v_SupQty := NVL(v_cum_record.cum_qty,0) +
14249 NVL(v_cum_record.cum_qty_after_cutoff,0) +
14250 NVL(v_cum_record.cum_qty_to_be_accumulated,0);
14251 --
14252 END IF;
14253 --
14254 IF (l_debug <> -1) THEN
14255 rlm_core_sv.dlog(k_DEBUG, 'Supplier CUM Qty', v_SupQty);
14256 rlm_core_sv.dlog(k_DEBUG, 'Customer CUM Qty', v_CUMQty);
14257 END IF;
14258 --
14259 IF NVL(v_SupQty, 0) <> NVL(v_CUMQty, 0) THEN
14260 v_Intransit := v_SupQty - v_CUMQty;
14261 END IF;
14262 --
14263 x_Intransit := v_Intransit;
14264 v_Progress := '030';
14265 --
14266 IF (l_debug <> -1) THEN
14267 rlm_core_sv.dpop(k_SDEBUG);
14268 END IF;
14269 --
14270 EXCEPTION
14271 -- 4307505 [
14272 WHEN NO_DATA_FOUND THEN
14273 v_Intransit := 0;
14274 x_Intransit := 0;
14275 rlm_message_sv.app_error(
14276 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14277 x_MessageName => 'RLM_NO_CUM_INTRST_CUST_CUM',
14278 x_InterfaceHeaderId => x_sched_rec.header_id,
14279 x_InterfaceLineId => NULL,
14280 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14281 x_ScheduleLineId => NULL ,
14282 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14283 x_OrderLineId => NULL,
14284 x_Token1 => 'SHIP_TO',
14285 x_Value1 =>
14286 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14287 x_Token2 => 'CITEM',
14288 x_Value2 =>
14289 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14290 x_GroupInfo => TRUE);
14291 --
14292 IF (l_debug <> -1) THEN
14293 rlm_core_sv.dlog(k_DEBUG,'- warning: RLM_CUM_STUP_NO_RECORD');
14294 rlm_core_sv.dlog(k_DEBUG,'- Intransit Qty = 0 considered to be 0 in this case');
14295 rlm_core_sv.dpop(k_SDEBUG);
14296 END IF;
14297 -- 4307505 ]
14298 WHEN e_no_cum_key THEN
14299 --
14300 rlm_message_sv.app_error(
14301 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14302 x_MessageName => 'RLM_CUM_KEY_MISSING',
14303 x_InterfaceHeaderId => x_sched_rec.header_id,
14304 x_InterfaceLineId => NULL,
14305 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14306 x_ScheduleLineId => NULL,
14307 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14308 x_OrderLineId => NULL,
14309 x_GroupInfo => TRUE,
14310 x_Token1 => 'GROUP', --Bugfix 7007638
14311 x_value1 => '-'||v_control_text||' '|| --Bugfix 7007638
14312 rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
14313 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
14314 rlm_core_sv.get_item_number(x_group_rec.customer_item_id)||'-'||
14315 v_control_value);
14316 --
14317 IF (l_debug <> -1) THEN
14318 rlm_core_sv.dlog(k_DEBUG, 'No CUM Key Found - intransit qty no calc');
14319 rlm_core_sv.dpop(k_SDEBUG);
14320 END IF;
14321 --
14322 WHEN OTHERS THEN
14323 rlm_message_sv.sql_error('rlm_rd_sv.CalculateCUMIntransit',v_progress);
14324 --
14325 IF (l_debug <> -1) THEN
14326 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14327 END IF;
14328 --
14329 raise;
14330 --
14331 END CalculateCUMIntransit;
14332
14333
14334 /*============================================================================
14335
14336 PROCEDURE NAME: AssignOEAttribValues
14337
14338 This procedure uses the information in p_OEDemand_rec structure to populate values
14339 for the dem_rec component of x_Key_rec. This is currently only called from
14340 procedure ProcessOld() and can eventually be used to eliminate calls to GetDemand().
14341
14342 ==============================================================================*/
14343 PROCEDURE AssignOEAttribValues(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
14344 p_OEDemand_rec IN RLM_RD_SV.t_OEDemand_rec) IS
14345 BEGIN
14346 --
14347 IF (l_debug <> -1) THEN
14348 rlm_core_sv.dpush(k_SDEBUG, 'AssignOEAttribValues');
14349 END IF;
14350 --
14351 x_Key_rec.oe_line_id := p_OEDemand_rec.line_id;
14352 x_Key_rec.dem_rec.line_id := p_OEDemand_rec.line_id;
14353 x_Key_rec.dem_rec.request_date := p_OEDemand_rec.request_date;
14354 x_Key_rec.dem_rec.schedule_date := p_OEDemand_rec.schedule_ship_date;
14355 --
14356 x_Key_rec.dem_rec.ship_from_org_id := p_OEDemand_rec.ship_from_org_id;
14357 x_Key_rec.dem_rec.ship_to_org_id := p_OEDemand_rec.ship_to_org_id;
14358 x_Key_rec.dem_rec.invoice_to_org_id := p_OEDemand_rec.invoice_to_org_id;
14359 x_Key_rec.dem_rec.customer_item_id := p_OEDemand_rec.ordered_item_id;
14360 x_Key_rec.dem_rec.inventory_item_id := p_OEDemand_rec.inventory_item_id;
14361 x_Key_rec.dem_rec.order_header_id := p_OEDemand_rec.header_id;
14362 x_Key_rec.dem_rec.blanket_number := p_OEDemand_rec.blanket_number;
14363 x_Key_rec.dem_rec.customer_item_ext := p_OEDemand_rec.ordered_item;
14364 x_Key_rec.dem_rec.intmed_ship_to_org_id := p_OEDemand_rec.intmed_ship_to_org_id;
14365 --
14366 x_Key_rec.dem_rec.item_detail_type := p_OEDemand_rec.item_type_code;
14367 x_Key_rec.dem_rec.schedule_type := p_OEDemand_rec.rla_schedule_type_code;
14368 x_Key_rec.dem_rec.ordered_quantity := p_OEDemand_rec.orig_ordered_quantity;
14369 x_Key_rec.dem_rec.item_identifier_type := p_OEDemand_rec.item_identifier_type;
14370 x_Key_rec.dem_rec.item_detail_subtype := p_OEDemand_rec.demand_bucket_type_code;
14371 x_Key_rec.dem_rec.authorized_to_ship_flag := p_OEDemand_rec.authorized_to_ship_flag;
14372 --
14373 x_Key_rec.dem_rec.cust_po_line_num := p_OEDemand_rec.customer_line_number;
14374 x_Key_rec.dem_rec.customer_dock_code := p_OEDemand_rec.customer_dock_code;
14375 x_Key_rec.dem_rec.cust_po_number := p_OEDemand_rec.cust_po_number;
14376 x_Key_rec.dem_rec.customer_job := p_OEDemand_rec.customer_job;
14377 x_Key_rec.dem_rec.customer_item_revision := p_OEDemand_rec.customer_item_revision;
14378 x_Key_rec.dem_rec.cust_production_line := p_OEDemand_rec.cust_production_line;
14379 x_Key_rec.dem_rec.cust_production_seq_num := p_OEDemand_rec.cust_production_seq_num;
14380 x_Key_rec.dem_rec.cust_model_serial_number := p_OEDemand_rec.cust_model_serial_number;
14381 --
14382 x_Key_rec.dem_rec.industry_attribute1 := p_OEDemand_rec.industry_attribute1;
14383 x_Key_rec.dem_rec.industry_attribute2 := p_OEDemand_rec.industry_attribute2;
14384 x_Key_rec.dem_rec.industry_attribute3 := p_OEDemand_rec.industry_attribute3;
14385 x_Key_rec.dem_rec.industry_attribute4 := p_OEDemand_rec.industry_attribute4;
14386 x_Key_rec.dem_rec.industry_attribute5 := p_OEDemand_rec.industry_attribute5;
14387 x_Key_rec.dem_rec.industry_attribute6 := p_OEDemand_rec.industry_attribute6;
14388 x_Key_rec.dem_rec.industry_attribute7 := p_OEDemand_rec.industry_attribute7;
14389 x_Key_rec.dem_rec.industry_attribute8 := p_OEDemand_rec.industry_attribute8;
14390 x_Key_rec.dem_rec.industry_attribute9 := p_OEDemand_rec.industry_attribute9;
14391 x_Key_rec.dem_rec.industry_attribute10 := p_OEDemand_rec.industry_attribute10;
14392 x_Key_rec.dem_rec.industry_attribute11 := p_OEDemand_rec.industry_attribute11;
14393 x_Key_rec.dem_rec.industry_attribute12 := p_OEDemand_rec.industry_attribute12;
14394 x_Key_rec.dem_rec.industry_attribute13 := p_OEDemand_rec.industry_attribute13;
14395 x_Key_rec.dem_rec.industry_attribute14 := p_OEDemand_rec.industry_attribute14;
14396 x_Key_rec.dem_rec.industry_attribute15 := p_OEDemand_rec.industry_attribute15;
14397 --
14398 x_Key_rec.dem_rec.attribute1 := p_OEDemand_rec.attribute1;
14399 x_Key_rec.dem_rec.attribute2 := p_OEDemand_rec.attribute2;
14400 x_Key_rec.dem_rec.attribute3 := p_OEDemand_rec.attribute3;
14401 x_Key_rec.dem_rec.attribute4 := p_OEDemand_rec.attribute4;
14402 x_Key_rec.dem_rec.attribute5 := p_OEDemand_rec.attribute5;
14403 x_Key_rec.dem_rec.attribute6 := p_OEDemand_rec.attribute6;
14404 x_Key_rec.dem_rec.attribute7 := p_OEDemand_rec.attribute7;
14405 x_Key_rec.dem_rec.attribute8 := p_OEDemand_rec.attribute8;
14406 x_Key_rec.dem_rec.attribute9 := p_OEDemand_rec.attribute9;
14407 x_Key_rec.dem_rec.attribute10 := p_OEDemand_rec.attribute10;
14408 x_Key_rec.dem_rec.attribute11 := p_OEDemand_rec.attribute11;
14409 x_Key_rec.dem_rec.attribute12 := p_OEDemand_rec.attribute12;
14410 x_Key_rec.dem_rec.attribute13 := p_OEDemand_rec.attribute13;
14411 x_Key_rec.dem_rec.attribute14 := p_OEDemand_rec.attribute14;
14412 x_Key_rec.dem_rec.attribute15 := p_OEDemand_rec.attribute15;
14413 --
14414 IF (l_debug <> -1) THEN
14415 rlm_core_sv.dpop(k_SDEBUG);
14416 END IF;
14417 --
14418 EXCEPTION
14419 --
14420 WHEN OTHERS THEN
14421 --
14422 rlm_message_sv.sql_error('RLM_RD_SV.AssignOEAttribValues', '010');
14423 --
14424 IF (l_debug <> -1) THEN
14425 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
14426 rlm_core_sv.dpop(k_SDEBUG);
14427 END IF;
14428 --
14429 RAISE;
14430 --
14431 END AssignOEAttribValues;
14432
14433
14434 /*==============================================================================
14435 PROCEDURE NAME: FrozenFenceWarning
14436 Added this new procedure to give the overall frozen period warning for bug4223359
14437 ==============================================================================*/
14438
14439 PROCEDURE FrozenFenceWarning(x_sched_rec IN rlm_interface_headers%ROWTYPE,
14440 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec) IS
14441 --
14442 i NUMBER DEFAULT 0;
14443 v_index NUMBER DEFAULT 0;
14444 v_Count NUMBER DEFAULT 0;
14445 v_FrozenTab t_generic_Tab;
14446 x_frozenWarnQty NUMBER;
14447 v_frozenDays NUMBER;
14448 v_frozenFrom NUMBER;
14449 v_MatchAttrTxt VARCHAR2(2000);
14450 --
14451 BEGIN
14452 --{
14453 IF (l_debug > -1) THEN
14454 rlm_core_sv.dpush(k_SDEBUG, ' FrozenFenceWarning ');
14455 END IF;
14456 --
14457 IF x_Sched_rec.Schedule_type = 'PLANNING_RELEASE' THEN
14458 --
14459 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.pln_frozen_day_to,0) -
14460 nvl(x_Group_rec.setup_terms_rec.pln_frozen_day_from, 0) + 1;
14461 v_frozenFrom := x_group_rec.setup_terms_rec.pln_frozen_day_from;
14462 --
14463 ELSIF x_Sched_rec.Schedule_type = 'SHIPPING' THEN
14464 --
14465 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.shp_frozen_day_to,0) -
14466 nvl(x_Group_rec.setup_terms_rec.shp_frozen_day_from, 0) + 1;
14467 v_frozenFrom := x_group_rec.setup_terms_rec.shp_frozen_day_from;
14468 --
14469 ELSE
14470 --
14471 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.seq_frozen_day_to,0) -
14472 nvl(x_Group_rec.setup_terms_rec.seq_frozen_day_from, 0) + 1;
14473 v_frozenFrom := x_group_rec.setup_terms_rec.seq_frozen_day_from;
14474 --
14475 END IF;
14476 --
14477 IF (l_debug > -1) THEN
14478 rlm_core_sv.dlog(k_DEBUG, 'g_isFirm', g_isFirm);
14479 rlm_core_sv.dlog(k_DEBUG, 'v_frozenDays', v_frozenDays);
14480 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.Schedule_Source', x_Sched_rec.Schedule_Source);
14481 END IF;
14482 --
14483 IF NOT g_isFirm AND x_Sched_rec.Schedule_Source <> 'MANUAL' AND v_frozenFrom is NOT NULL THEN
14484 --{
14485 g_isFirm := TRUE;
14486 --
14487 IF g_Reconcile_tab.COUNT <> 0 THEN
14488 --{
14489 v_Count := g_Reconcile_tab.FIRST;
14490 --
14491 WHILE v_Count is NOT NULL LOOP
14492 --{
14493 x_frozenWarnQty := g_Reconcile_tab(v_Count).ordered_quantity;
14494 --
14495 i := v_FrozenTab.count;
14496 --
14497 IF (l_debug <> -1) THEN
14498 rlm_core_sv.dlog(k_DEBUG, 'Begining of the loop Index i', i);
14499 rlm_core_sv.dlog(k_DEBUG, 'v_Count', v_Count);
14500 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenWarnQty', x_FrozenWarnQty);
14501 rlm_core_sv.dlog(k_DEBUG, 'request_date', g_Reconcile_tab(v_Count).request_date);
14502 rlm_core_sv.dlog(k_DEBUG, 'Customer request Date', g_Reconcile_tab(v_Count).industry_attribute2);
14503 END IF;
14504 --
14505 IF MatchFrozen(x_Group_rec, g_Reconcile_tab.NEXT(v_Count), g_Reconcile_tab(v_Count), v_Index) THEN
14506 --
14507 x_frozenWarnQty := x_frozenWarnQty + g_Reconcile_tab(v_Index).ordered_quantity;
14508 --
14509 IF (l_debug <> -1) THEN
14510 --
14511 rlm_core_sv.dlog(k_DEBUG, 'v_Index', v_Index);
14512 rlm_core_sv.dlog(k_DEBUG, 'ordered_quantity', g_Reconcile_tab(v_Index).ordered_quantity);
14513 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenWarnQty', x_FrozenWarnQty);
14514 --
14515 END IF;
14516 --
14517 END IF;
14518 --
14519 i := i + 1;
14520 v_FrozenTab(i) := g_Reconcile_tab(v_Count);
14521 v_FrozenTab(i).ordered_quantity := x_frozenWarnQty;
14522 --
14523 IF (l_debug <> -1) THEN
14524 rlm_core_sv.dlog(k_DEBUG, 'Ending of the loop Index i', i);
14525 END IF;
14526 --
14527 v_Count := g_Reconcile_tab.next(v_Count);
14528 --
14529 END LOOP;
14530 --}
14531 END IF;
14532 --}
14533 IF (l_debug <> -1) THEN
14534 rlm_core_sv.dlog(k_DEBUG, 'v_FrozenTab.COUNT', v_FrozenTab.COUNT);
14535 END IF;
14536 --
14537 IF v_FrozenTab.COUNT <> 0 THEN
14538 --{
14539 FOR v_Count IN v_frozenTab.FIRST..v_frozenTab.LAST LOOP
14540 --{
14541 GetMatchAttributes(x_sched_rec,x_group_rec, v_frozenTab(v_count), v_MatchAttrTxt);
14542 --
14543 IF v_MatchAttrTxt is NULL THEN
14544 --
14545 IF v_frozenTab(v_Count).ordered_quantity < 0 THEN
14546 --
14547 IF (l_debug <> -1) THEN
14548 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_WARN_UNDER:',
14549 v_frozenTab(v_Count).ordered_quantity);
14550 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14551 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14552 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14553 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14554 END IF;
14555 --
14556 rlm_message_sv.app_error(
14557 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14558 x_MessageName => 'RLM_FROZEN_OVERALL_WARN_UNDER',
14559 x_InterfaceHeaderId => x_sched_rec.header_id,
14560 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14561 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14562 x_OrderLineId => NULL,
14563 x_Token1 => 'ENDDATE',
14564 x_Value1 => TRUNC(SYSDATE) + v_frozenDays - 1,
14565 x_Token2 => 'SHIP_FROM',
14566 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14567 x_Token3 => 'SHIP_TO',
14568 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14569 x_Token4 => 'CUSTITEM',
14570 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14571 x_Token5 => 'QUANTITY',
14572 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity));
14573 --
14574 ELSE
14575 --
14576 IF (l_debug <> -1) THEN
14577 --
14578 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_WARN_OVER:',
14579 v_frozenTab(v_Count).ordered_quantity);
14580 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14581 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14582 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14583 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14584 --
14585 END IF;
14586 --
14587 rlm_message_sv.app_error(
14588 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14589 x_MessageName => 'RLM_FROZEN_OVERALL_WARN_OVER',
14590 x_InterfaceHeaderId => x_sched_rec.header_id,
14591 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14592 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14593 x_OrderLineId => NULL,
14594 x_Token1 => 'ENDDATE',
14595 x_Value1 => TRUNC(SYSDATE) + v_frozenDays - 1,
14596 x_Token2 => 'SHIP_FROM',
14597 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14598 x_Token3 => 'SHIP_TO',
14599 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14600 x_Token4 => 'CUSTITEM',
14601 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14602 x_Token5 => 'QUANTITY',
14603 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity));
14604 --
14605 END IF;
14606 --
14607 ELSE
14608 --
14609 IF v_frozenTab(v_Count).ordered_quantity < 0 THEN
14610 --
14611 IF (l_debug <> -1) THEN
14612 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_QTY_UNDER:',
14613 v_frozenTab(v_Count).ordered_quantity);
14614 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14615 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14616 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14617 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14618 END IF;
14619 --
14620 rlm_message_sv.app_error(
14621 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14622 x_MessageName => 'RLM_FROZEN_OVERALL_QTY_UNDER',
14623 x_InterfaceHeaderId => x_sched_rec.header_id,
14624 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14625 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14626 x_OrderLineId => NULL,
14627 x_Token1 => 'ENDDATE',
14628 x_Value1 => TRUNC(SYSDATE) + v_frozenDays - 1,
14629 x_Token2 => 'SHIP_FROM',
14630 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14631 x_Token3 => 'SHIP_TO',
14632 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14633 x_Token4 => 'CUSTITEM',
14634 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14635 x_Token5 => 'QUANTITY',
14636 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity),
14637 x_Token6 => 'MATCH_ATTR',
14638 x_value6 => v_MatchAttrTxt);
14639 --
14640 ELSE
14641 --
14642 IF (l_debug <> -1) THEN
14643 --
14644 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_QTY_OVER:',
14645 v_frozenTab(v_Count).ordered_quantity);
14646 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14647 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14648 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14649 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14650 --
14651 END IF;
14652 --
14653 rlm_message_sv.app_error(
14654 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14655 x_MessageName => 'RLM_FROZEN_OVERALL_QTY_OVER',
14656 x_InterfaceHeaderId => x_sched_rec.header_id,
14657 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14658 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14659 x_OrderLineId => NULL,
14660 x_Token1 => 'ENDDATE',
14661 x_Value1 => TRUNC(SYSDATE) + v_frozenDays - 1,
14662 x_Token2 => 'SHIP_FROM',
14663 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14664 x_Token3 => 'SHIP_TO',
14665 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14666 x_Token4 => 'CUSTITEM',
14667 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14668 x_Token5 => 'QUANTITY',
14669 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity),
14670 x_Token6 => 'MATCH_ATTR',
14671 x_value6 => v_MatchAttrTxt);
14672 --
14673 END IF;
14674 --
14675 END IF ;
14676 --
14677 END LOOP;
14678 --}
14679 END IF;
14680 --}
14681 END IF;
14682 --}
14683 IF (l_debug <> -1) THEN
14684 rlm_core_sv.dpop(k_SDEBUG);
14685 END IF;
14686 --}
14687 EXCEPTION
14688 WHEN OTHERS THEN
14689 --
14690 rlm_message_sv.sql_error('RLM_RD_SV.FrozenFenceWarning', '010');
14691 --
14692 IF (l_debug <> -1) THEN
14693 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
14694 rlm_core_sv.dpop(k_SDEBUG);
14695 END IF;
14696 --
14697 --
14698 RAISE;
14699 --
14700 END FrozenFenceWarning;
14701
14702 /*==============================================================================
14703 PROCEDURE NAME: GetMatchAttributes
14704 Added this new procedure to get the matching attributes code value pair to display
14705 in the overall frozen fence message for bug 4223359.
14706 ==============================================================================*/
14707
14708 PROCEDURE GetMatchAttributes(x_sched_rec IN rlm_interface_headers%ROWTYPE,
14709 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
14710 x_frozenTabRec IN t_generic_rec,
14711 x_MatAttrCodeValue OUT NOCOPY VARCHAR2)
14712 IS
14713 --
14714 i NUMBER DEFAULT 0;
14715 v_lookupCode VARCHAR2(30);
14716 v_lookupMeaning VARCHAR2(80);
14717 v_ColumnName VARCHAR2(30);
14718 v_MatchCode VARCHAR2(2);
14719 v_MatchWithinRec rlm_core_sv.t_match_rec;
14720 -- v_MatchKey rlm_cust_shipto_terms.match_within_key%TYPE;
14721 v_first BOOLEAN := TRUE;
14722 --
14723 Cursor C(p_MatchCode in VARCHAR2,
14724 p_enabledFlag in VARCHAR2,
14725 p_lookupType in VARCHAR2)
14726 IS
14727 SELECT LOOKUP_CODE, MEANING
14728 FROM FND_LOOKUPS
14729 WHERE LOOKUP_TYPE = p_lookupType
14730 AND ENABLED_FLAG = p_enabledFlag
14731 AND SUBSTR(LOOKUP_CODE,INSTR(LOOKUP_CODE, ',') +1) = p_MatchCode;
14732 --
14733 Cursor c_flex_ind_attr(p_ColumnName IN VARCHAR2,
14734 p_descFlex IN VARCHAR2,
14735 p_enabledFlag IN VARCHAR2,
14736 p_appId IN NUMBER)
14737 IS
14738 SELECT FORM_ABOVE_PROMPT
14739 FROM FND_DESCR_FLEX_COL_USAGE_VL
14740 WHERE APPLICATION_ID = p_appId
14741 AND DESCRIPTIVE_FLEXFIELD_NAME = p_descFlex
14742 AND ENABLED_FLAG = p_enabledFlag
14743 AND APPLICATION_COLUMN_NAME = p_ColumnName;
14744 --
14745 Cursor c_flex_line_attr(p_ColumnName IN VARCHAR2,
14746 p_descFlex IN VARCHAR2,
14747 p_enabledFlag IN VARCHAR2,
14748 p_appId IN NUMBER)
14749 IS
14750 SELECT FORM_LEFT_PROMPT
14751 FROM FND_DESCR_FLEX_COL_USAGE_VL
14752 WHERE APPLICATION_ID = p_appId
14753 AND DESCRIPTIVE_FLEXFIELD_NAME = p_descFlex
14754 AND ENABLED_FLAG = p_enabledFlag
14755 AND APPLICATION_COLUMN_NAME = p_ColumnName;
14756 --
14757 BEGIN
14758 --
14759 IF (l_debug > -1) THEN
14760 rlm_core_sv.dpush(k_SDEBUG, 'GetMatchAttributes ');
14761 rlm_core_sv.dlog(k_DEBUG, 'match_within ', x_group_rec.match_within);
14762 END IF;
14763 --
14764 v_MatchCode := SUBSTR(x_Group_rec.match_within,1,1);
14765 i := 1;
14766 --
14767 WHILE v_MatchCode is NOT NULL LOOP
14768 --{
14769 IF (l_debug > -1) THEN
14770 rlm_core_sv.dlog(k_DEBUG, 'v_MatchCode ', v_MatchCode);
14771 END IF;
14772 --
14773 IF v_MatchCode <> 'C' AND v_MatchCode <> 'J' THEN
14774 --{
14775 OPEN c(v_matchCode, 'Y', 'RLM_OPTIONAL_MATCH_ATTRIBUTES');
14776 --{
14777 FETCH c INTO v_lookupCode, v_lookupMeaning;
14778 --
14779 v_ColumnName := SUBSTR(v_lookupCode, 1, INSTR(v_lookupCode, ',')-1);
14780 --
14781 IF (INSTR(v_ColumnName, 'INDUSTRY_ATTRIBUTE') = 1) THEN
14782 --
14783 OPEN c_flex_ind_attr(v_ColumnName, 'RLM_SCHEDULE_LINES', 'Y', 662);
14784 FETCH c_flex_ind_attr INTO v_lookupMeaning;
14785 CLOSE c_flex_ind_attr;
14786 --
14787 ELSIF(INSTR(v_ColumnName, 'ATTRIBUTE') = 1) THEN
14788 --
14789 OPEN c_flex_line_attr(v_ColumnName, 'OE_LINE_ATTRIBUTES', 'Y', 660);
14790 FETCH c_flex_line_attr INTO v_lookupMeaning;
14791 CLOSE c_flex_line_attr;
14792 --
14793 END IF;
14794 --
14795 IF v_first THEN
14796 --
14797 x_MatAttrCodeValue := v_lookupMeaning || '= ';
14798 --
14799 ELSE
14800 --
14801 x_MatAttrCodeValue := x_MatAttrCodeValue || ', ' || v_lookupMeaning || '= ';
14802 --
14803 END IF;
14804 --
14805 rlm_core_sv.populate_match_keys(v_MatchWithinRec, v_MatchCode);
14806 --
14807 IF v_MatchWithinRec.cust_po_number = 'Y' THEN
14808 --
14809 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_po_number;
14810 --
14811 ELSIF v_MatchWithinRec.customer_item_revision = 'Y' THEN
14812 --
14813 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_item_revision;
14814
14815 --
14816 ELSIF v_MatchWithinRec.customer_dock_code = 'Y' THEN
14817 --
14818 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_dock_code;
14819 --
14820 ELSIF v_MatchWithinRec.customer_job = 'Y' THEN
14821 --
14822 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_job;
14823 --
14824 ELSIF v_MatchWithinRec.cust_production_line = 'Y' THEN
14825 --
14826 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_production_line;
14827 --
14828 ELSIF v_MatchWithinRec.cust_model_serial_number = 'Y' THEN
14829 --
14830 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_model_serial_number;
14831
14832 --
14833 ELSIF v_MatchWithinRec.cust_production_seq_num = 'Y' THEN
14834 --
14835 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_production_seq_num;
14836
14837 --
14838 ELSIF v_MatchwithinRec.industry_attribute1 = 'Y' THEN
14839 --
14840 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute1;
14841 --
14842 ELSIF v_MatchwithinRec.industry_attribute4 = 'Y' THEN
14843 --
14844 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute4;
14845 --
14846 ELSIF v_MatchwithinRec.industry_attribute5 = 'Y' THEN
14847 --
14848 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute5;
14849 --
14850 IF (l_debug > -1) THEN
14851 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenTabRec.industry_attribute5 ', x_FrozenTabRec.industry_attribute5);
14852 END IF;
14853 --
14854 ELSIF v_MatchwithinRec.industry_attribute6 = 'Y' THEN
14855 --
14856 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute6;
14857 --
14858 ELSIF v_MatchwithinRec.industry_attribute10 = 'Y' THEN
14859 --
14860 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute10;
14861 --
14862 ELSIF v_MatchwithinRec.industry_attribute11 = 'Y' THEN
14863 --
14864 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute11;
14865 --
14866 ELSIF v_MatchwithinRec.industry_attribute12 = 'Y' THEN
14867 --
14868 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute12;
14869 --
14870 ELSIF v_MatchwithinRec.industry_attribute13 = 'Y' THEN
14871 --
14872 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute13;
14873 --
14874 ELSIF v_MatchwithinRec.industry_attribute14 = 'Y' THEN
14875 --
14876 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute14;
14877 --
14878 -- ELSIF v_MatchwithinRec.industry_attribute15 = 'Y' THEN
14879 --
14880 -- x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute15;
14881
14882 --
14883 ELSIF v_MatchwithinRec.attribute1 = 'Y' THEN
14884 --
14885 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute1;
14886 --
14887 ELSIF v_MatchwithinRec.attribute2 = 'Y' THEN
14888 --
14889 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute2;
14890 --
14891 ELSIF v_MatchwithinRec.attribute3 = 'Y' THEN
14892 --
14893 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute3;
14894 --
14895 ELSIF v_MatchwithinRec.attribute4 = 'Y' THEN
14896 --
14897 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute4;
14898 --
14899 ELSIF v_MatchwithinRec.attribute5 = 'Y' THEN
14900 --
14901 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute5;
14902 --
14903 ELSIF v_MatchwithinRec.attribute6 = 'Y' THEN
14904 --
14905 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute6;
14906 --
14907 ELSIF v_MatchwithinRec.attribute7 = 'Y' THEN
14908 --
14909 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute7;
14910 --
14911 ELSIF v_MatchwithinRec.attribute8 = 'Y' THEN
14912 --
14913 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute8;
14914 --
14915 ELSIF v_MatchwithinRec.attribute9 = 'Y' THEN
14916 --
14917 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute9;
14918 --
14919 ELSIF v_MatchwithinRec.attribute10 = 'Y' THEN
14920 --
14921 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute10;
14922 --
14923 ELSIF v_MatchwithinRec.attribute11 = 'Y' THEN
14924 --
14925 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute11;
14926 --
14927 ELSIF v_MatchwithinRec.attribute12 = 'Y' THEN
14928 --
14929 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute12;
14930 --
14931 ELSIF v_MatchwithinRec.attribute13 = 'Y' THEN
14932 --
14933 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute13;
14934 --
14935 ELSIF v_MatchwithinRec.attribute14 = 'Y' THEN
14936 --
14937 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute14;
14938 --
14939 ELSIF v_MatchwithinRec.attribute15 = 'Y' THEN
14940 --
14941 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute15;
14942 --
14943 END IF;
14944 --
14945 IF (l_debug > -1) THEN
14946 rlm_core_sv.dlog(k_DEBUG, 'x_MatAttrCodeValue ', x_MatAttrCodeValue);
14947 END IF;
14948 --}
14949 CLOSE C;
14950 --
14951 v_first := FALSE;
14952 --}
14953 END IF;
14954 --
14955 i := i + 1;
14956 v_MatchCode := SUBSTR(x_Group_rec.match_within,i,1);
14957 --}
14958 END LOOP;
14959 --
14960 IF (l_debug <> -1) THEN
14961 rlm_core_sv.dpop(k_SDEBUG);
14962 END IF;
14963 --
14964 EXCEPTION
14965 WHEN OTHERS THEN
14966 --
14967 rlm_message_sv.sql_error('RLM_RD_SV.GetMatchAttributes', '010');
14968 --
14969 IF (l_debug <> -1) THEN
14970 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
14971 rlm_core_sv.dpop(k_SDEBUG);
14972 END IF;
14973 --
14974 RAISE;
14975 --
14976 END GetMatchAttributes;
14977 --}
14978
14979
14980 /*======================================================================
14981
14982 PROCEDURE NAME: ProcessReleases
14983
14984 DESCRIPTION: The following logic is used within this procedure
14985 (a) For a given SF/ST/CI, obtain the number of
14986 distinct releases tied to the demand lines.
14987 (b) For each such distinct release, call
14988 RecGroupDemand()
14989 (c) If any release was processed by DSP, set the output
14990 variable x_Processed to Y, so we do not call
14991 RecGroupDemand() again in procedure RecDemand().
14992
14993 =======================================================================*/
14994 PROCEDURE ProcessReleases(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
14995 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
14996 x_Processed IN OUT NOCOPY VARCHAR2) IS
14997 --
14998 v_BlkGroup_ref t_Cursor_ref;
14999 v_BlkGroup_rec rlm_dp_sv.t_Group_rec;
15000 e_lines_locked EXCEPTION;
15001 v_sf_org_id NUMBER;
15002 v_rso_start_date DATE;
15003 --
15004 CURSOR c_getMaxRSO IS
15005 SELECT rso_hdr_id, effective_start_date
15006 FROM RLM_BLANKET_RSO
15007 WHERE blanket_number = v_BlkGroup_rec.setup_terms_rec.blanket_number
15008 AND customer_item_id =
15009 DECODE(v_BlkGroup_rec.setup_terms_rec.release_rule, 'PI',
15010 v_BlkGroup_rec.customer_item_id, k_NNULL)
15011 AND effective_start_date =
15012 (SELECT max(rlm.effective_start_date)
15013 FROM RLM_BLANKET_RSO rlm, OE_ORDER_HEADERS oe
15014 WHERE rlm.blanket_number = v_BlkGroup_rec.setup_terms_rec.blanket_number
15015 AND rlm.rso_hdr_id = oe.header_id
15016 AND rlm.customer_item_id =
15017 DECODE(v_BlkGroup_rec.setup_terms_rec.release_rule, 'PI',
15018 v_BlkGroup_rec.customer_item_id, K_NNULL)
15019 AND oe.open_flag = 'Y')
15020 ORDER BY rso_hdr_id DESC;
15021 --
15022 BEGIN
15023 --
15024 IF (l_debug <> -1) THEN
15025 rlm_core_sv.dpush(k_SDEBUG, 'ProcessReleases');
15026 END IF;
15027 x_Processed := 'N';
15028 --
15029 RLM_TPA_SV.InitializeBlktGrp(x_Sched_rec, v_BlkGroup_ref, x_Group_rec);
15030 --
15031 WHILE FetchBlktGrp(v_BlkGroup_ref, v_BlkGroup_rec) LOOP
15032 --{
15033 v_BlkGroup_rec.isSourced := x_Group_rec.isSourced;
15034 CallSetups(x_Sched_rec, v_BlkGroup_rec);
15035 --
15036 IF NOT LockLines(v_BlkGroup_rec, x_Sched_rec.header_id) THEN
15037 --
15038 IF (l_debug <> -1) THEN
15039 rlm_core_sv.dlog(k_DEBUG, 'RLM_LOCK_NOT_OBTAINED');
15040 END IF;
15041 --
15042 RAISE e_lines_locked;
15043 --
15044 END IF;
15045 --
15046 OPEN c_getMaxRSO;
15047 FETCH c_getMaxRSO INTO g_max_rso_hdr_id, v_rso_start_date;
15048 CLOSE c_getMaxRSO;
15049 --
15050 IF (l_debug <> -1) THEN
15051 rlm_core_sv.dlog(k_DEBUG, 'g_max_rso_hdr_id',g_max_rso_hdr_id);
15052 rlm_core_sv.dlog(k_DEBUG, 'v_rso_start_date',v_rso_start_date);
15053 END IF;
15054 --
15055 RecGroupDemand(x_Sched_rec, v_BlkGroup_rec);
15056 x_Processed := 'Y';
15057 --}
15058 END LOOP;
15059 --
15060 IF (l_debug <> -1) THEN
15061 rlm_core_sv.dpop(k_SDEBUG);
15062 END IF;
15063 --
15064 EXCEPTION
15065 --
15066 WHEN e_lines_locked THEN
15067 --
15068 IF (l_debug <> -1) THEN
15069 rlm_core_sv.dlog(k_DEBUG, 'e_lines_locked exception');
15070 rlm_core_sv.dpop(k_SDEBUG);
15071 END IF;
15072 --
15073 RAISE;
15074 --
15075 WHEN OTHERS THEN
15076 --
15077 IF (l_debug <> -1) THEN
15078 rlm_core_sv.dlog(k_DEBUG, 'SQLERRM', SUBSTRB(SQLERRM,1,200));
15079 rlm_core_sv.dpop(k_SDEBUG);
15080 END IF;
15081 --
15082 RAISE;
15083 --
15084 END ProcessReleases;
15085
15086 /*=========================================================================
15087
15088 PROCEDURE NAME: AssignMatchAttribValues
15089
15090 ===========================================================================*/
15091 -- Bug 4297984
15092 PROCEDURE AssignMatchAttribValues ( x_req_rec IN rlm_interface_lines_all%ROWTYPE,
15093 x_match_rec IN OUT NOCOPY RLM_RD_SV.t_generic_rec)
15094 IS
15095
15096 BEGIN
15097 --
15098 -- The x_match_rec populated here will be passed to RLM_RD_SV.GetMatchAttributes
15099 -- where we retrieve only the additional matching attribute columns. Hence only the
15100 -- additional matching attribute columns are populated here and the remaining fields
15101 -- defined in RLM_RD_SV.t_Generic_rec will be NULL. The function is needed
15102 -- as the RLM_RD_SV.GetMatchAttributes requires a RLM_RD_SV.t_Generic_rec argument type.
15103 --
15104 x_match_rec.cust_po_number := x_req_rec.cust_po_number ;
15105 x_match_rec.customer_item_revision := x_req_rec.customer_item_revision ;
15106 x_match_rec.customer_dock_code := x_req_rec.customer_dock_code ;
15107 x_match_rec.customer_job := x_req_rec.customer_job ;
15108 x_match_rec.cust_production_line := x_req_rec.cust_production_line ;
15109 x_match_rec.cust_model_serial_number := x_req_rec.cust_model_serial_number ;
15110 x_match_rec.cust_production_seq_num := x_req_rec.cust_production_seq_num ;
15111 x_match_rec.industry_attribute1 := x_req_rec.industry_attribute1 ;
15112 x_match_rec.industry_attribute2 := x_req_rec.industry_attribute2 ;
15113 x_match_rec.industry_attribute3 := x_req_rec.industry_attribute3 ;
15114 x_match_rec.industry_attribute4 := x_req_rec.industry_attribute4 ;
15115 x_match_rec.industry_attribute5 := x_req_rec.industry_attribute5 ;
15116 x_match_rec.industry_attribute6 := x_req_rec.industry_attribute6 ;
15117 x_match_rec.industry_attribute7 := x_req_rec.industry_attribute7 ;
15118 x_match_rec.industry_attribute8 := x_req_rec.industry_attribute8 ;
15119 x_match_rec.industry_attribute9 := x_req_rec.industry_attribute9 ;
15120 x_match_rec.industry_attribute10 := x_req_rec.industry_attribute10 ;
15121 x_match_rec.industry_attribute11 := x_req_rec.industry_attribute11 ;
15122 x_match_rec.industry_attribute12 := x_req_rec.industry_attribute12 ;
15123 x_match_rec.industry_attribute13 := x_req_rec.industry_attribute13 ;
15124 x_match_rec.industry_attribute14 := x_req_rec.industry_attribute14 ;
15125 x_match_rec.industry_attribute15 := x_req_rec.industry_attribute15 ;
15126 x_match_rec.attribute1 := x_req_rec.attribute1 ;
15127 x_match_rec.attribute2 := x_req_rec.attribute2 ;
15128 x_match_rec.attribute3 := x_req_rec.attribute3 ;
15129 x_match_rec.attribute4 := x_req_rec.attribute4 ;
15130 x_match_rec.attribute5 := x_req_rec.attribute5 ;
15131 x_match_rec.attribute6 := x_req_rec.attribute6 ;
15132 x_match_rec.attribute7 := x_req_rec.attribute7 ;
15133 x_match_rec.attribute8 := x_req_rec.attribute8 ;
15134 x_match_rec.attribute9 := x_req_rec.attribute9 ;
15135 x_match_rec.attribute10 := x_req_rec.attribute10 ;
15136 x_match_rec.attribute11 := x_req_rec.attribute11 ;
15137 x_match_rec.attribute12 := x_req_rec.attribute12 ;
15138 x_match_rec.attribute13 := x_req_rec.attribute13 ;
15139 x_match_rec.attribute14 := x_req_rec.attribute14 ;
15140 x_match_rec.attribute15 := x_req_rec.attribute15 ;
15141
15142 END AssignMatchAttribValues;
15143
15144 /*===========================================================================
15145
15146 PROCEDURE NAME: PopulateReconcileCumRec
15147
15148 ===========================================================================*/
15149 --Bugfix 7007638 Start
15150 PROCEDURE PopulateReconcileCumRec(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
15151 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
15152 IS
15153
15154 CURSOR c_CUMRec IS
15155 SELECT x_group_rec.customer_id,
15156 customer_item_id,
15157 inventory_item_id,
15158 ship_from_org_id,
15159 intrmd_ship_to_id intrmd_ship_to_address_id,
15160 ship_to_address_id,
15161 bill_to_address_id,
15162 cust_po_number purchase_order_number,
15163 primary_quantity,
15164 item_detail_quantity,
15165 start_date_time,
15166 industry_attribute1 cust_record_year,
15167 line_id
15168 FROM rlm_interface_lines
15169 WHERE header_id = x_Sched_rec.header_id
15170 AND item_detail_type = RLM_MANAGE_DEMAND_SV.k_SHIP_RECEIPT_INFO
15171 AND item_detail_subtype = RLM_MANAGE_DEMAND_SV.k_CUM
15172 AND ship_from_org_id = x_Group_rec.ship_from_org_id
15173 AND ship_to_address_id = x_Group_rec.ship_to_address_id
15174 AND inventory_item_id = x_Group_rec.inventory_item_id
15175 AND customer_item_id = x_Group_rec.customer_item_id
15176 ORDER BY start_date_time desc;
15177 --
15178
15179 v_Progress VARCHAR2(3) := '010';
15180 v_Count NUMBER := 1;
15181
15182 BEGIN
15183 --
15184 IF (l_debug <> -1) THEN
15185 rlm_core_sv.dpush(k_SDEBUG,'PopulateReconcileCumRec');
15186 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.Schedule_header_id',
15187 x_Sched_rec.Schedule_header_id);
15188 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_address_id',
15189 x_Group_rec.ship_to_address_id);
15190 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',
15191 x_Group_rec.inventory_item_id);
15192 END IF;
15193 --
15194 g_RecCUM_tab.DELETE;
15195 --
15196 OPEN c_CUMRec;
15197 --
15198 LOOP
15199 FETCH c_CUMRec INTO g_RecCUM_rec;
15200 EXIT WHEN c_CUMRec%NOTFOUND;
15201
15202 g_RecCUM_tab(v_Count).customer_id := g_RecCUM_rec.customer_id;
15203 g_RecCUM_tab(v_Count).customer_item_id := g_RecCUM_rec.customer_item_id;
15204 g_RecCUM_tab(v_Count).inventory_item_id := g_RecCUM_rec.inventory_item_id;
15205 g_RecCUM_tab(v_Count).ship_from_org_id := g_RecCUM_rec.ship_from_org_id;
15206 g_RecCUM_tab(v_Count).intrmd_ship_to_address_id := g_RecCUM_rec.intrmd_ship_to_address_id;
15207 g_RecCUM_tab(v_Count).ship_to_address_id := g_RecCUM_rec.ship_to_address_id;
15208 g_RecCUM_tab(v_Count).bill_to_address_id := g_RecCUM_rec.bill_to_address_id;
15209 g_RecCUM_tab(v_Count).purchase_order_number := g_RecCUM_rec.purchase_order_number;
15210 g_RecCUM_tab(v_Count).primary_quantity := g_RecCUM_rec.primary_quantity;
15211 g_RecCUM_tab(v_Count).item_detail_quantity := g_RecCUM_rec.item_detail_quantity;
15212 g_RecCUM_tab(v_Count).start_date_time := g_RecCUM_rec.start_date_time;
15213 g_RecCUM_tab(v_Count).cust_record_year := g_RecCUM_rec.cust_record_year;
15214 g_RecCUM_tab(v_Count).line_id := g_RecCUM_rec.line_id;
15215
15216 IF (l_debug <> -1) THEN
15217 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').purchase_order_number', g_RecCUM_tab(v_Count).purchase_order_number);
15218 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').primary_quantity', g_RecCUM_tab(v_Count).primary_quantity);
15219 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').item_detail_quantity', g_RecCUM_tab(v_Count).item_detail_quantity);
15220 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').start_date_time', g_RecCUM_tab(v_Count).start_date_time);
15221 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').cust_record_year', g_RecCUM_tab(v_Count).cust_record_year);
15222 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').line_id', g_RecCUM_tab(v_Count).line_id);
15223 END IF;
15224
15225 v_Count := v_Count + 1;
15226
15227 END LOOP;
15228 --
15229 CLOSE c_CUMRec;
15230
15231 IF (l_debug <> -1) THEN
15232 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab.COUNT',g_RecCUM_tab.COUNT);
15233 rlm_core_sv.dpop(k_SDEBUG);
15234 END IF;
15235 --
15236 EXCEPTION
15237
15238 WHEN OTHERS THEN
15239 --
15240 rlm_message_sv.sql_error('rlm_rd_sv.PopulateReconcileCumRec',
15241 v_Progress);
15242 --
15243 IF (l_debug <> -1) THEN
15244 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
15245 END IF;
15246 --
15247 raise;
15248
15249 END PopulateReconcileCumRec;
15250
15251 /*===========================================================================
15252
15253 FUNCTION Match_PO_RY_Reconcile
15254
15255 ===========================================================================*/
15256 FUNCTION Match_PO_RY_Reconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
15257 x_Current_rec IN t_Generic_rec,
15258 x_Index OUT NOCOPY NUMBER)
15259 RETURN BOOLEAN
15260 IS
15261 x_progress VARCHAR2(3) := '010';
15262 v_Count NUMBER;
15263 v_Index NUMBER;
15264 b_Match BOOLEAN := FALSE;
15265 v_intransit_calc_basis VARCHAR2(30) ;
15266
15267 BEGIN
15268 --
15269 IF (l_debug <> -1) THEN
15270 rlm_core_sv.dpush(k_SDEBUG,'Match_PO_RY_Reconcile');
15271 rlm_core_sv.dlog(k_DEBUG, 'x_Current_rec.schedule_type',
15272 x_Current_rec.schedule_type);
15273 END IF;
15274 --
15275 IF (l_debug <> -1) THEN
15276 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
15277 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
15278 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
15279 END IF;
15280
15281 IF g_Reconcile_tab.COUNT <> 0 THEN
15282 --{
15283 v_Count := g_Reconcile_tab.FIRST;
15284 --
15285 WHILE v_Count IS NOT NULL LOOP
15286 --{
15287 b_Match := TRUE;
15288 --
15289 IF (l_debug <> -1) THEN
15290 rlm_core_sv.dlog(k_DEBUG, 'g_Reconcile_Tab('||v_Count||').schedule_type',
15291 g_Reconcile_Tab(v_Count).schedule_type);
15292 END IF;
15293
15294 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
15295 --
15296 IF (l_debug <> -1) THEN
15297 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis ',x_Group_rec.setup_terms_rec.intransit_calc_basis);
15298 END IF;
15299 --
15300 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
15301 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
15302 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
15303 b_Match := FALSE;
15304 END IF;
15305 END IF;
15306 --
15307 IF (l_debug <> -1) THEN
15308 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
15309 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
15310 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
15311 END IF;
15312 --
15313 IF b_Match THEN
15314 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
15315 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
15316 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
15317 b_Match := FALSE;
15318 END IF;
15319 END IF;
15320 END IF;
15321 --
15322 IF (l_debug <> -1) THEN
15323 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
15324 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
15325 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
15326 END IF;
15327 --
15328 IF b_Match THEN
15329 --
15330 x_Index := v_Count;
15331 EXIT;
15332 --
15333 END IF;
15334 --
15335 v_Count := g_Reconcile_tab.NEXT(v_Count);
15336 --}
15337 END LOOP;
15338 --}
15339 END IF;
15340 --
15341 IF (l_debug <> -1) THEN
15342 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
15343 rlm_core_sv.dpop(k_SDEBUG);
15344 END IF;
15345 --
15346 RETURN(b_Match);
15347 --
15348 EXCEPTION
15349 WHEN OTHERS THEN
15350 rlm_message_sv.sql_error('rlm_rd_sv.Match_PO_RY_Reconcile',x_progress);
15351 --
15352 IF (l_debug <> -1) THEN
15353 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
15354 END IF;
15355 --
15356 raise;
15357
15358 END Match_PO_RY_Reconcile;
15359 --Bugfix 7007638 End
15360
15361 END RLM_RD_SV;