[Home] [Help]
PACKAGE BODY: APPS.RLM_RD_SV
Source
1 PACKAGE BODY RLM_RD_SV as
2 /*$Header: RLMDPRDB.pls 120.24 2011/12/20 07:59:08 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' --Bugfix 12771425
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(rlm_dp_sv.g_dsp_start_time) - nvl(x_Group_rec.Cutoff_days,0)), --Bugfix 10053830
265 TRUNC(rlm_dp_sv.g_dsp_start_time)) --Bugfix 10053830
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) --Bugfix 12771425
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(rlm_dp_sv.g_dsp_start_time) --Bugfix 10053830
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(rlm_dp_sv.g_dsp_start_time)) AND x_key_rec.dem_rec.authorized_to_ship_flag = 'Y' THEN --Bugfix 10053830
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(rlm_dp_sv.g_dsp_start_time) - NVL(x_group_rec.cutoff_days,0)) THEN --Bugfix 10053830
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 --Bugfix 10053830
1170 /* IsFrozen(TRUNC(SYSDATE),
1171 x_Group_rec, x_key_rec.dem_rec.request_date) THEN*/
1172 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),
1173 x_Group_rec, x_key_rec.dem_rec.request_date) THEN
1174 --Bugfix 10053830
1175 --
1176 IF (l_debug <> -1) THEN
1177 rlm_core_sv.dlog(k_DEBUG,'Line cannot be deleted-- within frozen fence',
1178 x_key_rec.dem_rec.line_id);
1179 rlm_core_sv.dlog(k_DEBUG,'dem_rec.request_date',
1180 x_key_rec.dem_rec.request_date);
1181 END IF;
1182 --
1183 IF x_Reconcile THEN
1184 --
1185 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1186 x_key_rec.dem_rec.ordered_quantity);/*2263253*/
1187 --
1188 END IF;
1189 --
1190 -- Bug 4297984 Start
1191 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.dem_rec,v_MatchAttrTxt);
1192 --
1193 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
1194
1195 IF (x_Key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
1196 --
1197 rlm_message_sv.app_error(
1198 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1199 x_MessageName => 'RLM_FROZEN_DELETE_SEQ',
1200 x_InterfaceHeaderId => x_sched_rec.header_id,
1201 x_InterfaceLineId => NULL,
1202 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1203 x_ScheduleLineId => NULL,
1204 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1205 x_OrderLineId => x_key_rec.dem_rec.line_id,
1206 x_Token1 => 'LINE',
1207 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
1208 x_Token2 => 'ORDER',
1209 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1210 x_Token3 => 'QUANTITY',
1211 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
1212 x_Token4 => 'CUSTITEM',
1213 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1214 x_Token5 => 'REQ_DATE',
1215 x_value5 => x_key_rec.dem_rec.request_date,
1216 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
1217 x_value6 => v_del_line_qty, --Bugfix 6159269
1218 x_Token7 => 'SEQ_INFO',
1219 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL')||'-'||
1220 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
1221 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
1222 x_Token8 => 'MATCH_ATTR',
1223 x_value8 => v_MatchAttrTxt );
1224 --
1225 IF (l_debug <> -1) THEN
1226 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE_SEQ',x_key_rec.dem_rec.line_id);
1227 END IF;
1228 --
1229 ELSE
1230 --
1231 rlm_message_sv.app_error(
1232 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1233 x_MessageName => 'RLM_FROZEN_DELETE',
1234 x_InterfaceHeaderId => x_sched_rec.header_id,
1235 x_InterfaceLineId => NULL,
1236 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1237 x_ScheduleLineId => NULL,
1238 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1239 x_OrderLineId => x_key_rec.dem_rec.line_id,
1240 x_Token1 => 'LINE',
1241 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
1242 x_Token2 => 'ORDER',
1243 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1244 x_Token3 => 'QUANTITY',
1245 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
1246 x_Token4 => 'CUSTITEM',
1247 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1248 x_Token5 => 'REQ_DATE',
1249 x_value5 => x_key_rec.dem_rec.request_date,
1250 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
1251 x_value6 => v_del_line_qty, --Bugfix 6159269
1252 x_Token7 => 'MATCH_ATTR',
1253 x_value7 => v_MatchAttrTxt);
1254 --
1255 IF (l_debug <> -1) THEN
1256 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE',x_key_rec.dem_rec.line_id);
1257 END IF;
1258 --
1259 END IF;
1260
1261 END IF; --Bugfix 6159269
1262 -- Bug 4297984 End
1263 ELSIF ProcessConstraint(x_Key_rec, v_Qty_rec, k_DELETE) THEN
1264 --
1265 --CancelRequirement(x_Sched_rec, x_Group_rec,
1266 --x_Key_rec, v_Qty_rec.available_to_cancel);
1267 IF x_Reconcile THEN
1268 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1269 v_Qty_rec.reconcile);
1270 END IF;
1271 --x_DeleteQty := v_Qty_rec.available_to_cancel;
1272 --rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1273 --
1274 ELSE
1275 --
1276 -- Call to check if Shipping allows delete
1277 -- Use 'D' for delete, 'U' for update, and 'C' for cancel
1278 --
1279 IF (l_debug <> -1) THEN
1280 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.dem_rec.line_id',x_key_rec.dem_rec.line_id);
1281 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.oe_line_id',x_key_rec.oe_line_id);
1282 END IF;
1283 --
1284 v_changed_attributes.action_flag := 'D';
1285 v_changed_attributes.source_line_id := nvl(x_Key_rec.oe_line_id, x_key_rec.dem_rec.line_id);
1286 --
1287 IF (l_debug <> -1) THEN
1288 rlm_core_sv.dlog(k_DEBUG,'source_line_id',v_changed_attributes.source_line_id);
1289 END IF;
1290 --
1291 RLM_EXTINTERFACE_SV.CheckShippingConstraints(
1292 x_source_code => v_source_code,
1293 x_changed_attributes => v_changed_attributes,
1294 x_return_status => v_return_status,
1295 x_action_allowed => v_action_allowed,
1296 x_action_message => v_action_message,
1297 x_ord_qty_allowed => v_ord_qty_allowed,
1298 x_header_id => x_Sched_rec.header_id,
1299 x_order_header_id => x_group_rec.setup_terms_rec.header_id);
1300 --
1301 IF (l_debug <> -1) THEN
1302 rlm_core_sv.dlog(k_DEBUG,'v_action_allowed',v_action_allowed);
1303 rlm_core_sv.dlog(k_DEBUG,'v_return_status',v_return_status);
1304 END IF;
1305 --
1306 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1307 --
1308 IF (l_debug <> -1) THEN
1309 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed. Unexpected Error');
1310 END IF;
1311 --
1312 RAISE e_group_error;
1313 --
1314 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1315 --
1316 IF (l_debug <> -1) THEN
1317 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed.');
1318 END IF;
1319 --
1320 RAISE e_group_error;
1321 --
1322 END IF;
1323 --
1324 IF (v_action_allowed = 'N') THEN
1325
1326 -- bug 5199318
1327 IF ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE, 0) THEN
1328 --{
1329 --
1330
1331 IF x_Reconcile THEN
1332 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec, x_key_rec.dem_rec.ordered_quantity);
1333 END IF;
1334
1335 --
1336 --}
1337 ELSE
1338 --{
1339 --
1340 -- Call again to see if Shipping allows Cancel
1341 -- Use 'D' for delete, 'U' for update, and 'C' for cancel
1342 --
1343 IF (l_debug <> -1) THEN
1344 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',x_Key_rec.oe_line_id);
1345 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',x_Key_rec.dem_rec.line_id);
1346 END IF;
1347 --
1348 v_changed_attributes.action_flag := 'C';
1349 v_changed_attributes.source_line_id := nvl(x_Key_rec.oe_line_id,
1350 x_key_rec.dem_rec.line_id);
1351 --
1352 IF (l_debug <> -1) THEN
1353 rlm_core_sv.dlog(k_DEBUG,'source_line_id',v_changed_attributes.source_line_id);
1354 END IF;
1355 --
1356 RLM_EXTINTERFACE_SV.CheckShippingConstraints(
1357 x_source_code => v_source_code,
1358 x_changed_attributes => v_changed_attributes,
1359 x_return_status => v_return_status,
1360 x_action_allowed => v_action_allowed,
1361 x_action_message => v_action_message,
1362 x_ord_qty_allowed => v_ord_qty_allowed,
1363 x_header_id => x_Sched_rec.header_id,
1364 x_order_header_id => x_group_rec.setup_terms_rec.header_id);
1365 --
1366 IF (l_debug <> -1) THEN
1367 rlm_core_sv.dlog(k_DEBUG,'v_action_allowed',v_action_allowed);
1368 rlm_core_sv.dlog(k_DEBUG,'v_return_status',v_return_status);
1369 END IF;
1370 --
1371 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1372 --
1373 IF (l_debug <> -1) THEN
1374 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed');
1375 END IF;
1376 --
1377 RAISE e_group_error;
1378 --
1379 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1380 --
1381 IF (l_debug <> -1) THEN
1382 rlm_core_sv.dpop(k_SDEBUG, 'CheckShippingConstraintsAPI Failed.');
1383 END IF;
1384 --
1385 RAISE e_group_error;
1386 --
1387 END IF;
1388 --
1389 IF (v_action_allowed = 'N') THEN
1390 --
1391 IF x_Reconcile THEN
1392 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
1393 v_Qty_rec.reconcile);
1394 END IF;
1395 --
1396 ELSE
1397 --
1398 IF NOT RemainOnFile(x_group_rec, x_key_rec) THEN
1399 --
1400 x_DeleteQty := 0;
1401 SetOperation(x_Key_rec, k_UPDATE, x_DeleteQty);
1402 --
1403 IF (l_debug <> -1) THEN
1404 rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1405 END IF;
1406 --
1407 END IF;
1408 --
1409 END IF;
1410 --}
1411 END IF; -- bug 5199318
1412 --
1413 ELSE
1414 --
1415 IF NOT RemainOnFile(x_group_rec, x_key_rec) THEN
1416 --
1417 SetOperation(x_Key_rec, k_DELETE);
1418 x_DeleteQty := v_Qty_rec.ordered;
1419 --
1420 --Bugfix 6131516 Start
1421 IF g_sch_line_qty >0 AND g_del_reconcile = 'Y' THEN
1422 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1423 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1424 --
1425 rlm_message_sv.app_error(
1426 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1427 x_MessageName => 'RLM_RECONCILE_DELETE_SEQ',
1428 x_InterfaceHeaderId => x_sched_rec.header_id,
1429 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1430 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1431 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1432 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1433 x_OrderLineId => NULL,
1434 x_Token1 => 'QUANTITY',
1435 x_value1 => g_sch_line_qty,
1436 x_Token2 => 'GROUP',
1437 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1438 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1439 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1440 x_Token3 => 'REQ_DATE',
1441 x_value3 => x_key_rec.req_rec.request_date,
1442 x_Token4 => 'START_DATE_TIME',
1443 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1444 x_Token5 => 'SEQ_INFO',
1445 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1446 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1447 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1448 x_Token6 => 'ORDER',
1449 x_value6 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1450 x_Token7 => 'LINE',
1451 x_value7 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
1452 x_Token8 => 'MATCH_ATTR',
1453 x_value8 => v_MatchAttrTxt);
1454 --
1455 IF (l_debug <> -1) THEN
1456 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1457 x_key_rec.req_rec.line_id);
1458 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1459 x_Key_rec.req_rec.cust_model_serial_number);
1460 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE_SEQ',
1461 x_Key_rec.req_rec.request_date);
1462 END IF;
1463 --
1464 ELSE
1465 --
1466 rlm_message_sv.app_error(
1467 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1468 x_MessageName => 'RLM_RECONCILE_DELETE',
1469 x_InterfaceHeaderId => x_sched_rec.header_id,
1470 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1471 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1472 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1473 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1474 x_OrderLineId => NULL,
1475 x_Token1 => 'QUANTITY',
1476 x_value1 => g_sch_line_qty,
1477 x_Token2 => 'GROUP',
1478 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1479 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1480 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1481 x_Token3 => 'REQ_DATE',
1482 x_value3 => x_key_rec.req_rec.request_date,
1483 x_Token4 => 'START_DATE_TIME',
1484 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1485 x_Token5 => 'SCHEDULE_LINE',
1486 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1487 x_Token6 => 'ORDER',
1488 x_value6 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
1489 x_Token7 => 'LINE',
1490 x_value7 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
1491 x_Token8 => 'MATCH_ATTR',
1492 x_value8 => v_MatchAttrTxt);
1493 --
1494 IF (l_debug <> -1) THEN
1495 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1496 x_key_rec.req_rec.line_id);
1497 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1498 x_Key_rec.req_rec.cust_model_serial_number);
1499 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_DELETE',
1500 x_Key_rec.req_rec.request_date);
1501 END IF;
1502 --
1503 END IF; /* Exception */
1504
1505 END IF;/* Check g_sch_line_qty*/
1506 --Bugfix 6131516 End
1507
1508 IF (l_debug <> -1) THEN
1509 rlm_core_sv.dlog(k_DEBUG,'x_DeleteQty',x_DeleteQty);
1510 END IF;
1511 --
1512 END IF;
1513 --
1514 END IF;
1515 --
1516 END IF;
1517 --
1518 IF (l_debug <> -1) THEN
1519 rlm_core_sv.dpop(k_SDEBUG);
1520 END IF;
1521 --
1522 EXCEPTION
1523 --
1524 WHEN e_group_error THEN
1525 --
1526 RAISE;
1527 --
1528 WHEN OTHERS THEN
1529 --
1530 rlm_message_sv.sql_error('rlm_rd_sv.DeleteRequirement',x_progress);
1531 --
1532 IF (l_debug <> -1) THEN
1533 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
1534 END IF;
1535 --
1536 raise;
1537
1538 END DeleteRequirement;
1539
1540 /*===========================================================================
1541
1542 PROCEDURE InsertRequirement
1543
1544 ===========================================================================*/
1545 PROCEDURE InsertRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
1546 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
1547 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
1548 x_Reconcile IN BOOLEAN,
1549 x_Quantity IN OUT NOCOPY NUMBER)
1550 IS
1551
1552 x_progress VARCHAR2(3) := '010';
1553 v_RF_Enabled VARCHAR2(1) := 'N';
1554 e_FrozenFences EXCEPTION;
1555 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
1556 v_Quantity NUMBER; -- Bug 4297984
1557
1558 BEGIN
1559 --
1560 IF (l_debug <> -1) THEN
1561 rlm_core_sv.dpush(k_SDEBUG,'InsertRequirement');
1562 rlm_core_sv.dlog(k_DEBUG,'x_Reconcile',x_Reconcile);
1563 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1564 rlm_core_sv.dlog(k_DEBUG,'request_date',x_key_rec.req_rec.request_date);
1565 END IF;
1566
1567 --logic to roll forward frozen fence goes here
1568
1569 v_RF_Enabled:=x_Group_rec.roll_forward_frozen_flag;
1570 --
1571 IF (l_debug <> -1) THEN
1572 rlm_core_sv.dlog(k_DEBUG,' Rollforward set to: ', v_RF_Enabled);
1573 END IF;
1574 --
1575 -- bug 4223359 first reconcile the quantity in the reconcile table before trying to
1576 -- insert the new requirement. If there is additional qty after reconciling then
1577 -- check for frozenfences and if not within frozen fence then insert that qty.
1578 --
1579 IF x_Quantity > 0 THEN
1580 --
1581 v_Quantity := x_Quantity; -- Bug 4297984
1582 --
1583 IF x_Reconcile THEN
1584 --
1585 RLM_TPA_SV.ReconcileShipments(x_Group_rec, x_Key_rec, x_Quantity);
1586 --
1587 IF (l_debug <> -1) THEN
1588 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1589 END IF;
1590 --
1591 Reconcile(x_Group_rec, x_Key_rec, x_Quantity);
1592 --
1593 END IF;
1594 --
1595 IF (l_debug <> -1) THEN
1596 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
1597 END IF;
1598 --
1599 IF x_Quantity = 0 THEN
1600 -- Bug 4297984 Start
1601 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1602 --
1603 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1604 --
1605 rlm_message_sv.app_error(
1606 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1607 x_MessageName => 'RLM_RECONCILE_ZERO_INSERT_SEQ',
1608 x_InterfaceHeaderId => x_sched_rec.header_id,
1609 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1610 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1611 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1612 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1613 x_OrderLineId => NULL,
1614 x_Token1 => 'QUANTITY',
1615 x_value1 => v_Quantity,
1616 x_Token2 => 'GROUP',
1617 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1618 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1619 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1620 x_Token3 => 'REQ_DATE',
1621 x_value3 => x_key_rec.req_rec.request_date,
1622 x_Token4 => 'START_DATE_TIME',
1623 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1624 x_Token5 => 'SEQ_INFO',
1625 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1626 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1627 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1628 x_Token6 => 'MATCH_ATTR',
1629 x_value6 => v_MatchAttrTxt);
1630 --
1631 IF (l_debug <> -1) THEN
1632 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1633 x_key_rec.req_rec.line_id);
1634 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1635 x_Key_rec.req_rec.cust_model_serial_number);
1636 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT_SEQ',
1637 x_Key_rec.req_rec.request_date);
1638 END IF;
1639 --
1640 ELSE
1641 --
1642 rlm_message_sv.app_error(
1643 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1644 x_MessageName => 'RLM_RECONCILE_ZERO_INSERT',
1645 x_InterfaceHeaderId => x_sched_rec.header_id,
1646 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1647 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1648 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1649 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1650 x_OrderLineId => NULL,
1651 x_Token1 => 'QUANTITY',
1652 x_value1 => v_Quantity,
1653 x_Token2 => 'GROUP',
1654 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1655 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1656 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1657 x_Token3 => 'REQ_DATE',
1658 x_value3 => x_key_rec.req_rec.request_date,
1659 x_Token4 => 'START_DATE_TIME',
1660 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1661 x_Token5 => 'SCHEDULE_LINE',
1662 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1663 x_Token6 => 'MATCH_ATTR',
1664 x_value6 => v_MatchAttrTxt);
1665 --
1666 IF (l_debug <> -1) THEN
1667 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1668 x_key_rec.req_rec.line_id);
1669 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1670 x_Key_rec.req_rec.cust_model_serial_number);
1671 rlm_core_sv.dlog(k_DEBUG,'RLM_RECONCILE_ZERO_INSERT',
1672 x_Key_rec.req_rec.request_date);
1673 END IF;
1674 --
1675 END IF;
1676 -- Bug 4297984 End
1677 ELSE
1678 --
1679 IF (l_debug <> -1) THEN
1680 rlm_core_sv.dlog(k_DEBUG,'schedule_source',x_Sched_rec.schedule_source);
1681 END IF;
1682 --
1683 -- start of bug fix 4223359
1684 --
1685 IF x_Sched_rec.schedule_source <> 'MANUAL' AND nvl(v_RF_Enabled,'N') = 'N' THEN
1686 --
1687 --Bugfix 10053830 Start
1688 /*IF IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date) OR
1689 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.schedule_date) THEN*/
1690 IF IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_key_rec.req_rec.request_date) OR
1691 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_key_rec.req_rec.schedule_date) THEN
1692 --Bugfix 10053830 End
1693 --
1694 IF (l_debug <> -1) THEN
1695 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
1696 x_key_rec.req_rec.line_id);
1697 rlm_core_sv.dlog(k_DEBUG, 'Not inserting line', x_key_rec.req_rec.line_id);
1698 rlm_core_sv.dlog(k_DEBUG, 'Qty not inserting ', x_quantity);
1699 END IF;
1700 --
1701 -- If not able to insert the new quantity due to frozen fence
1702 -- store that quantity with a negative quantity in the g_reconcile_tab
1703 -- for that calling store shipments as store shipment stores req_rec
1704 --
1705 x_Key_rec.req_rec.shipment_flag := NULL;
1706 --
1707 x_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
1708 --
1709 StoreShipments(x_Sched_rec, x_Group_rec, x_Key_rec, -x_quantity);
1710 --
1711 IF (l_debug <> -1) THEN
1712 --
1713 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.schedule_type',
1714 x_Key_rec.req_rec.schedule_type);
1715 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.shipment_flag',
1716 x_Key_rec.req_rec.shipment_flag);
1717 --
1718 END IF;
1719 --
1720 RAISE e_FrozenFences;
1721 --
1722 END IF;
1723 --
1724 END IF;
1725 --
1726 -- end of bug fix 4223359
1727 --
1728 IF v_RF_Enabled = 'Y' AND
1729 --Bugfix 10053830 Start
1730 /*IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date) AND
1731 x_Sched_rec.schedule_source <> 'MANUAL' THEN */
1732 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_key_rec.req_rec.request_date) AND
1733 x_Sched_rec.schedule_source <> 'MANUAL' THEN
1734 --Bugfix 10053830 End
1735 --
1736 IF (l_debug <> -1) THEN
1737 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.frozen_days',x_Group_rec.frozen_days);
1738 END IF;
1739
1740 -- Bugfix 8279132 Start
1741 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1742
1743 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1744 rlm_message_sv.app_error(
1745 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1746 x_MessageName => 'RLM_ROLL_FORWARD_SEQ',
1747 x_InterfaceHeaderId => x_sched_rec.header_id,
1748 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1749 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1750 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1751 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1752 x_OrderLineId => x_key_rec.dem_rec.line_id,
1753 x_Token1 => 'GROUP',
1754 x_value1 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1755 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1756 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1757 x_Token2 => 'REQ_DATE',
1758 x_value2 => x_key_rec.req_rec.request_date,
1759 x_Token3 => 'REC_LINE_QTY',
1760 x_value3 => x_Quantity,
1761 x_Token4 => 'NEW_REQ_DATE',
1762 x_value4 => TRUNC(rlm_dp_sv.g_dsp_start_time)+nvl(x_Group_rec.frozen_days,0), --Bugfix 10053830
1763 x_Token5 => 'SEQ_INFO',
1764 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL')||'-'||
1765 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1766 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1767 x_Token6 => 'MATCH_ATTR',
1768 x_value6 => v_MatchAttrTxt);
1769 --
1770 IF (l_debug <> -1) THEN
1771 rlm_core_sv.dlog(k_DEBUG,'The line is roll forwarded due to frozen fence',
1772 x_key_rec.req_rec.line_id);
1773 rlm_core_sv.dlog(k_DEBUG,'RLM_ROLL_FORWARD_SEQ',
1774 x_key_rec.req_rec.line_id);
1775 END IF;
1776
1777 ELSE
1778 rlm_message_sv.app_error(
1779 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1780 x_MessageName => 'RLM_ROLL_FORWARD',
1781 x_InterfaceHeaderId => x_sched_rec.header_id,
1782 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1783 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1784 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1785 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1786 x_OrderLineId => x_key_rec.dem_rec.line_id,
1787 x_Token1 => 'GROUP',
1788 x_value1 => 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_Token2 => 'REQ_DATE',
1792 x_value2 => x_key_rec.req_rec.request_date,
1793 x_Token3 => 'REC_LINE_QTY',
1794 x_value3 => x_Quantity,
1795 x_Token4 => 'NEW_REQ_DATE',
1796 x_value4 => TRUNC(rlm_dp_sv.g_dsp_start_time)+nvl(x_Group_rec.frozen_days,0), --Bugfix 10053830
1797 x_Token5 => 'SCHEDULE_LINE',
1798 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1799 x_Token6 => 'MATCH_ATTR',
1800 x_value6 => v_MatchAttrTxt);
1801 --
1802 IF (l_debug <> -1) THEN
1803 rlm_core_sv.dlog(k_DEBUG,'The line is roll forwarded due to frozen fence',
1804 x_key_rec.req_rec.line_id);
1805 rlm_core_sv.dlog(k_DEBUG,'RLM_ROLL_FORWARD',
1806 x_key_rec.req_rec.line_id);
1807 END IF;
1808 END IF;
1809 -- Bugfix 8279132 End
1810 --
1811 --x_key_rec.req_rec.request_date := TRUNC(SYSDATE) --Bugfix 10053830
1812 x_key_rec.req_rec.request_date := TRUNC(rlm_dp_sv.g_dsp_start_time) --Bugfix 10053830
1813 + nvl(x_Group_rec.frozen_days,0);
1814 --
1815 IF (l_debug <> -1) THEN
1816 rlm_core_sv.dlog(k_DEBUG,'request_date',x_key_rec.req_rec.request_date);
1817 END IF;
1818 --
1819 END IF;
1820 --
1821 IF v_RF_Enabled = 'Y' AND
1822 --Bugfix 10053830 Start
1823 /*IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.schedule_date) AND
1824 x_Sched_rec.schedule_source <> 'MANUAL' THEN */
1825 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_key_rec.req_rec.schedule_date) AND
1826 x_Sched_rec.schedule_source <> 'MANUAL' THEN
1827 --Bugfix 10053830 End
1828 --
1829 IF (l_debug <> -1) THEN
1830 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.frozen_days',x_Group_rec.frozen_days);
1831 END IF;
1832 --pdue
1833 --x_key_rec.req_rec.schedule_date := TRUNC(SYSDATE) --Bugfix 10053830
1834 x_key_rec.req_rec.schedule_date := TRUNC(rlm_dp_sv.g_dsp_start_time) --Bugfix 10053830
1835 + nvl(x_Group_rec.frozen_days,0);
1836 --
1837 IF (l_debug <> -1) THEN
1838 rlm_core_sv.dlog(k_DEBUG,'schedule_date',x_key_rec.req_rec.schedule_date);
1839 END IF;
1840 --
1841 END IF;
1842 --
1843 -- Bug 4351397 : Start
1844 --
1845 IF g_order_rec.request_date IS NOT NULL THEN
1846 --
1847 IF trunc(g_order_rec.request_date) < trunc(x_Key_rec.req_rec.request_date) THEN
1848 --
1849 SetOperation(x_Key_rec, k_INSERT, x_Quantity);
1850 --
1851 ELSE
1852 --
1853 IF (l_debug <> -1) THEN
1854 --
1855 rlm_core_sv.dlog(k_DEBUG,'Insertion will not happen as a demand populated by higher precedence ' ||
1856 g_order_rec.rla_schedule_type_code || ' schedule exists on ' ||
1857 g_order_rec.request_date);
1858 --
1859 END IF;
1860 --
1861 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec, v_MatchAttrTxt);
1862 --
1863 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1864 --
1865 rlm_message_sv.app_error(
1866 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1867 x_MessageName => 'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1868 x_InterfaceHeaderId => x_sched_rec.header_id,
1869 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1870 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1871 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1872 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1873 x_OrderLineId => NULL,
1874 x_Token1 => 'QUANTITY',
1875 x_value1 => x_Key_rec.req_rec.primary_quantity,
1876 x_Token2 => 'GROUP',
1877 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1878 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1879 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1880 x_Token3 => 'REQ_DATE',
1881 x_value3 => x_key_rec.req_rec.request_date,
1882 x_Token4 => 'START_DATE_TIME',
1883 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1884 x_Token5 => 'SCHEDULE_TYPE',
1885 x_value5 => g_order_rec.rla_schedule_type_code,
1886 x_Token6 => 'SCHEDULE_NUM',
1887 x_value6 => g_order_rec.industry_attribute3,
1888 x_Token7 => 'RECENT_REQ_DATE',
1889 x_value7 => g_order_rec.request_date,
1890 x_Token8 => 'ORDER',
1891 x_value8 => rlm_core_sv.get_order_number(g_order_rec.header_id),
1892 x_Token9 => 'SEQ_INFO',
1893 x_value9 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL') ||'-'||
1894 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
1895 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
1896 x_Token10 => 'MATCH_ATTR',
1897 x_value10 => v_MatchAttrTxt);
1898 --
1899 IF (l_debug <> -1) THEN
1900 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1901 x_key_rec.req_rec.line_id);
1902 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1903 x_Key_rec.req_rec.cust_model_serial_number);
1904 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT_SEQ',
1905 x_Key_rec.req_rec.request_date);
1906 END IF;
1907 --
1908 ELSE
1909 --
1910 rlm_message_sv.app_error(
1911 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1912 x_MessageName => 'RLM_LOW_PRECEDENCE_INSERT',
1913 x_InterfaceHeaderId => x_sched_rec.header_id,
1914 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1915 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1916 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1917 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1918 x_OrderLineId => NULL,
1919 x_Token1 => 'QUANTITY',
1920 x_value1 => x_Key_rec.req_rec.primary_quantity,
1921 x_Token2 => 'GROUP',
1922 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1923 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1924 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1925 x_Token3 => 'REQ_DATE',
1926 x_value3 => x_key_rec.req_rec.request_date,
1927 x_Token4 => 'START_DATE_TIME',
1928 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1929 x_Token5 => 'SCHEDULE_TYPE',
1930 x_value5 => g_order_rec.rla_schedule_type_code,
1931 x_Token6 => 'SCHEDULE_NUM',
1932 x_value6 => g_order_rec.industry_attribute3,
1933 x_Token7 => 'RECENT_REQ_DATE',
1934 x_value7 => g_order_rec.request_date,
1935 x_Token8 => 'ORDER',
1936 x_value8 => rlm_core_sv.get_order_number(g_order_rec.header_id),
1937 x_Token9 => 'SCHEDULE_LINE',
1938 x_value9 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
1939 x_Token10 => 'MATCH_ATTR',
1940 x_value10 => v_MatchAttrTxt);
1941 --
1942 IF (l_debug <> -1) THEN
1943 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1944 x_key_rec.req_rec.line_id);
1945 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1946 x_Key_rec.req_rec.cust_model_serial_number);
1947 rlm_core_sv.dlog(k_DEBUG,'RLM_LOW_PRECEDENCE_INSERT',
1948 x_Key_rec.req_rec.request_date);
1949 END IF;
1950 --
1951 END IF;
1952 --
1953 END IF ;
1954 --
1955 ELSE
1956 --
1957 SetOperation(x_Key_rec, k_INSERT, x_Quantity);
1958 --
1959 END IF;
1960 --
1961 -- Bug 4351397 : End
1962 --
1963 END IF;
1964 --
1965 END IF;
1966 --
1967 IF (l_debug <> -1) THEN
1968 rlm_core_sv.dpop(k_SDEBUG);
1969 END IF;
1970
1971 EXCEPTION
1972 WHEN e_FrozenFences THEN
1973 -- Bug 4297984 Start
1974 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
1975 --
1976 IF g_inc_exception <> 'Y' THEN --Bugfix 6159269
1977 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
1978 --
1979 rlm_message_sv.app_error(
1980 x_ExceptionLevel => rlm_message_sv.k_warn_level,
1981 x_MessageName => 'RLM_FROZEN_INSERT_SEQ',
1982 x_InterfaceHeaderId => x_sched_rec.header_id,
1983 x_InterfaceLineId => x_key_rec.req_rec.line_id,
1984 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
1985 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
1986 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
1987 x_OrderLineId => NULL,
1988 x_Token1 => 'QUANTITY',
1989 x_value1 => x_Key_rec.req_rec.primary_quantity,
1990 x_Token2 => 'GROUP',
1991 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
1992 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
1993 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
1994 x_Token3 => 'REQ_DATE',
1995 x_value3 => x_key_rec.req_rec.request_date,
1996 x_Token4 => 'START_DATE_TIME',
1997 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
1998 x_Token5 => 'SEQ_INFO',
1999 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL')||'-'||
2000 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
2001 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
2002 x_Token6 => 'MATCH_ATTR',
2003 x_value6 => v_MatchAttrTxt);
2004 --
2005 IF (l_debug <> -1) THEN
2006 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_INSERT_SEQ',
2007 x_key_rec.req_rec.line_id);
2008 rlm_core_sv.dpop(k_SDEBUG);
2009 END IF;
2010 --
2011 ELSE
2012 --
2013 rlm_message_sv.app_error(
2014 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2015 x_MessageName => 'RLM_FROZEN_INSERT',
2016 x_InterfaceHeaderId => x_sched_rec.header_id,
2017 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2018 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2019 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2020 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2021 x_OrderLineId => NULL,
2022 x_Token1 => 'QUANTITY',
2023 x_value1 => x_Key_rec.req_rec.primary_quantity,
2024 x_Token2 => 'GROUP',
2025 x_value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
2026 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
2027 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2028 x_Token3 => 'REQ_DATE',
2029 x_value3 => x_key_rec.req_rec.request_date,
2030 x_Token4 => 'START_DATE_TIME',
2031 x_value4 => to_date(x_key_rec.req_rec.industry_attribute2,'YYYY/MM/DD HH24:MI:SS'),
2032 x_Token5 => 'SCHEDULE_LINE',
2033 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
2034 x_Token6 => 'MATCH_ATTR',
2035 x_value6 => v_MatchAttrTxt);
2036 --
2037 IF (l_debug <> -1) THEN
2038 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_INSERT',
2039 x_key_rec.req_rec.line_id);
2040 rlm_core_sv.dpop(k_SDEBUG);
2041 END IF;
2042 --
2043 END IF;
2044 END IF; /*IF g_inc_exception */ --Bugfix 6159269
2045
2046 -- Bug 4297984 End
2047 WHEN OTHERS THEN
2048 rlm_message_sv.sql_error('rlm_rd_sv.InsertRequirement',x_progress);
2049 --
2050 IF (l_debug <> -1) THEN
2051 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2052 END IF;
2053 --
2054 raise;
2055
2056 END InsertRequirement;
2057
2058 /*===========================================================================
2059
2060 PROCEDURE UpdateRequirement
2061
2062 ===========================================================================*/
2063 PROCEDURE UpdateRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
2064 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
2065 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
2066 x_Quantity IN NUMBER)
2067 IS
2068
2069 v_Qty_rec t_Qty_rec;
2070 x_progress VARCHAR2(3) := '010';
2071 v_RF_Enabled VARCHAR2(1) := 'N';
2072 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
2073 v_line_id_tab t_matching_line;
2074
2075 BEGIN
2076 --
2077 IF (l_debug <> -1) THEN
2078 rlm_core_sv.dpush(k_SDEBUG,'UpdateRequirement');
2079 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
2080 END IF;
2081 --
2082 -- logic to get roll forward values
2083 v_RF_Enabled:=x_Group_rec.roll_forward_frozen_flag;
2084 --
2085 IF (l_debug <> -1) THEN
2086 rlm_core_sv.dlog(k_DEBUG, 'Rollforward set to: ', v_RF_Enabled);
2087 END IF;
2088 --
2089 --pdue
2090 --
2091 IF x_Sched_rec.schedule_source <> 'MANUAL' AND
2092 --Bugfix 10053830 Start
2093 /*(IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_Key_rec.req_rec.schedule_date) OR
2094 IsFrozen(TRUNC(SYSDATE),x_Group_rec,x_key_rec.req_rec.request_date)) THEN*/
2095 (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_Key_rec.req_rec.schedule_date) OR
2096 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time),x_Group_rec,x_key_rec.req_rec.request_date)) THEN
2097 --Bugfix 10053830 End
2098 --{
2099 IF nvl(v_RF_Enabled, 'N') = 'N' THEN
2100 --{
2101 -- Bug 4297984 Start
2102 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.dem_rec,v_MatchAttrTxt);
2103 --
2104 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
2105 --
2106 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
2107 --
2108 rlm_message_sv.app_error(
2109 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2110 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
2111 x_InterfaceHeaderId => x_sched_rec.header_id,
2112 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2113 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2114 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2115 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2116 x_OrderLineId => x_key_rec.dem_rec.line_id,
2117 x_Token1 => 'LINE',
2118 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
2119 x_Token2 => 'ORDER',
2120 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
2121 x_Token3 => 'QUANTITY',
2122 x_value3 => x_key_rec.dem_rec.ordered_quantity,
2123 x_Token4 => 'CUSTITEM',
2124 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2125 x_Token5 => 'REQ_DATE',
2126 x_value5 => x_key_rec.dem_rec.request_date,
2127 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
2128 x_value6 => g_sch_line_qty, --Bugfix 6159269
2129 x_Token7 => 'SEQ_INFO',
2130 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL')||'-'||
2131 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
2132 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
2133 x_Token8 => 'MATCH_ATTR',
2134 x_value8 => v_MatchAttrTxt);
2135 --
2136 IF (l_debug <> -1) THEN
2137 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
2138 x_key_rec.req_rec.line_id);
2139 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
2140 x_key_rec.req_rec.line_id);
2141 END IF;
2142 --
2143 ELSE
2144 --
2145 rlm_message_sv.app_error(
2146 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2147 x_MessageName => 'RLM_FROZEN_UPDATE',
2148 x_InterfaceHeaderId => x_sched_rec.header_id,
2149 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2150 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2151 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2152 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2153 x_OrderLineId => x_key_rec.dem_rec.line_id,
2154 x_Token1 => 'LINE',
2155 x_value1 =>rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
2156 x_Token2 => 'ORDER',
2157 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
2158 x_Token3 => 'QUANTITY',
2159 x_value3 => x_key_rec.dem_rec.ordered_quantity,
2160 x_Token4 => 'CUSTITEM',
2161 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2162 x_Token5 => 'REQ_DATE',
2163 x_value5 => x_key_rec.dem_rec.request_date,
2164 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
2165 x_value6 => g_sch_line_qty, --Bugfix 6159269
2166 x_Token7 => 'MATCH_ATTR',
2167 x_value7 => v_MatchAttrTxt);
2168 --
2169 IF (l_debug <> -1) THEN
2170 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
2171 x_key_rec.req_rec.line_id);
2172 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
2173 x_key_rec.req_rec.line_id);
2174 END IF;
2175 --
2176 END IF;
2177 --
2178 END IF; --Bugfix 6159269
2179 -- Bug 4297984 End
2180 --}
2181 ELSE
2182 --{
2183 IF (l_debug <> -1) THEN
2184 rlm_core_sv.dlog(k_DEBUG,'dem_rec.ordered_quantity:',
2185 x_key_rec.dem_rec.ordered_quantity);
2186 rlm_core_sv.dlog(k_DEBUG,'frozen_days:',
2187 x_Group_rec.frozen_days);
2188 END IF;
2189 --
2190 -- Bugfix 8279132 Start
2191 GetMatchAttributes(x_sched_rec, x_group_rec, x_key_rec.req_rec,v_MatchAttrTxt);
2192
2193 IF (x_sched_rec.schedule_type = 'SEQUENCED') THEN
2194 rlm_message_sv.app_error(
2195 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2196 x_MessageName => 'RLM_ROLL_FORWARD_SEQ',
2197 x_InterfaceHeaderId => x_sched_rec.header_id,
2198 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2199 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2200 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2201 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2202 x_OrderLineId => x_key_rec.dem_rec.line_id,
2203 x_Token1 => 'GROUP',
2204 x_value1 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
2205 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
2206 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2207 x_Token2 => 'REQ_DATE',
2208 x_value2 => x_key_rec.req_rec.request_date,
2209 x_Token3 => 'REC_LINE_QTY',
2210 x_value3 => x_Quantity,
2211 x_Token4 => 'NEW_REQ_DATE',
2212 x_value4 => TRUNC(rlm_dp_sv.g_dsp_start_time)+nvl(x_Group_rec.frozen_days,0), --Bugfix 10053830
2213 x_Token5 => 'SEQ_INFO',
2214 x_value5 => nvl(x_Key_rec.req_rec.cust_production_seq_num,'NULL')||'-'||
2215 nvl(x_Key_rec.req_rec.cust_model_serial_number,'NULL')||'-'||
2216 nvl(x_Key_rec.req_rec.customer_job,'NULL'),
2217 x_Token6 => 'MATCH_ATTR',
2218 x_value6 => v_MatchAttrTxt);
2219 --
2220 IF (l_debug <> -1) THEN
2221 rlm_core_sv.dlog(k_DEBUG,'The line is roll forwarded due to frozen fence',
2222 x_key_rec.req_rec.line_id);
2223 rlm_core_sv.dlog(k_DEBUG,'RLM_ROLL_FORWARD_SEQ',
2224 x_key_rec.req_rec.line_id);
2225 END IF;
2226
2227 ELSE
2228 rlm_message_sv.app_error(
2229 x_ExceptionLevel => rlm_message_sv.k_warn_level,
2230 x_MessageName => 'RLM_ROLL_FORWARD',
2231 x_InterfaceHeaderId => x_sched_rec.header_id,
2232 x_InterfaceLineId => x_key_rec.req_rec.line_id,
2233 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
2234 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
2235 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
2236 x_OrderLineId => x_key_rec.dem_rec.line_id,
2237 x_Token1 => 'GROUP',
2238 x_value1 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
2239 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
2240 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
2241 x_Token2 => 'REQ_DATE',
2242 x_value2 => x_key_rec.req_rec.request_date,
2243 x_Token3 => 'REC_LINE_QTY',
2244 x_value3 => x_Quantity,
2245 x_Token4 => 'NEW_REQ_DATE',
2246 x_value4 => TRUNC(rlm_dp_sv.g_dsp_start_time)+nvl(x_Group_rec.frozen_days,0), --Bugfix 10053830
2247 x_Token5 => 'SCHEDULE_LINE',
2248 x_value5 => rlm_core_sv.get_schedule_line_number(x_key_rec.req_rec.schedule_line_id),
2249 x_Token6 => 'MATCH_ATTR',
2250 x_value6 => v_MatchAttrTxt);
2251 --
2252 IF (l_debug <> -1) THEN
2253 rlm_core_sv.dlog(k_DEBUG,'The line is roll forwarded due to frozen fence',
2254 x_key_rec.req_rec.line_id);
2255 rlm_core_sv.dlog(k_DEBUG,'RLM_ROLL_FORWARD',
2256 x_key_rec.req_rec.line_id);
2257 END IF;
2258 END IF;
2259 -- Bugfix 8279132 End
2260 --x_key_rec.req_rec.request_date := TRUNC(SYSDATE) + --Bugfix 10053830
2261 x_key_rec.req_rec.request_date := TRUNC(rlm_dp_sv.g_dsp_start_time) + --Bugfix 10053830
2262 nvl(x_Group_rec.frozen_days,0);
2263 --x_key_rec.req_rec.schedule_Date := TRUNC(SYSDATE) + -Bugfix 10053830
2264 x_key_rec.req_rec.schedule_Date := TRUNC(rlm_dp_sv.g_dsp_start_time) + --Bugfix 10053830
2265 nvl(x_Group_rec.frozen_days,0);
2266 --
2267 IF (x_key_rec.dem_rec.ordered_quantity < x_Quantity ) THEN
2268 --
2269 SetOperation(x_Key_rec, k_INSERT,
2270 x_Quantity - x_key_rec.dem_rec.ordered_quantity);
2271 --
2272 ELSE
2273 --
2274 -- Bug 3999833 : Update the quantity on the OE line
2275 --
2276 SetOperation(x_Key_rec, k_UPDATE, x_Quantity);
2277 --
2278 END IF;
2279 --}
2280 END IF;
2281 --}
2282 ELSE
2283 --
2284 -- Bug 5122974
2285 --
2286 v_line_id_tab(0) := x_Key_rec.dem_rec.line_id;
2287 --
2288 IF not alreadyupdated(v_line_id_tab) THEN
2289 SetOperation(x_Key_rec, k_UPDATE, x_Quantity);
2290 else
2291 --
2292 if (x_Quantity < x_Key_rec.dem_rec.ordered_quantity) then
2293 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
2294 x_Key_rec, k_RECONCILE,
2295 x_Key_rec.req_rec.primary_quantity);
2296 end if;
2297 --
2298 end if;
2299 --
2300 -- End bug 5122974
2301
2302 END IF;
2303 --
2304 IF (l_debug <> -1) THEN
2305 rlm_core_sv.dpop(k_SDEBUG);
2306 END IF;
2307 --
2308 EXCEPTION
2309 WHEN OTHERS THEN
2310 rlm_message_sv.sql_error('rlm_rd_sv.UpdateRequirement',x_progress);
2311 --
2312 IF (l_debug <> -1) THEN
2313 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2314 END IF;
2315 --
2316 raise;
2317
2318 END UpdateRequirement;
2319
2320 /*===========================================================================
2321
2322 PROCEDURE GetQtyRec
2323
2324 ===========================================================================*/
2325 PROCEDURE GetQtyRec(x_Key_rec IN RLM_RD_SV.t_Key_rec,
2326 x_Qty_rec OUT NOCOPY t_Qty_rec)
2327 IS
2328
2329 x_progress VARCHAR2(3) := '010';
2330 BEGIN
2331
2332 IF (l_debug <> -1) THEN
2333 rlm_core_sv.dpush(k_SDEBUG,'GetQtyRec');
2334 rlm_core_sv.dpop(k_SDEBUG);
2335 END IF;
2336
2337 EXCEPTION
2338 WHEN OTHERS THEN
2339 rlm_message_sv.sql_error('rlm_rd_sv.GetQtyRec',x_progress);
2340 --
2341 IF (l_debug <> -1) THEN
2342 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2343 END IF;
2344 --
2345 raise;
2346
2347 END GetQtyRec;
2348
2349
2350 /*===========================================================================
2351
2352 PROCEDURE GetReq
2353
2354 ===========================================================================*/
2355 PROCEDURE GetReq(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec)
2356 IS
2357 x_progress VARCHAR2(3) := '010';
2358
2359 BEGIN
2360 --
2361 IF (l_debug <> -1) THEN
2362 rlm_core_sv.dpush(k_SDEBUG,'GetReq');
2363 END IF;
2364 --
2365 IF x_Key_rec.rlm_line_id IS NOT NULL THEN
2366 IF x_Key_rec.rlm_line_id <> NVL(x_Key_rec.req_rec.line_id,k_NNULL) THEN
2367 NULL;
2368 END IF;
2369 END IF;
2370 --
2371 IF (l_debug <> -1) THEN
2372 rlm_core_sv.dpop(k_SDEBUG);
2373 END IF;
2374 --
2375 EXCEPTION
2376 WHEN OTHERS THEN
2377 rlm_message_sv.sql_error('rlm_rd_sv.GetReq',x_progress);
2378 --
2379 IF (l_debug <> -1) THEN
2380 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2381 END IF;
2382 --
2383 raise;
2384
2385 END GetReq;
2386
2387
2388 /*===========================================================================
2389
2390 PROCEDURE GetDemand
2391
2392 ===========================================================================*/
2393 PROCEDURE GetDemand(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
2394 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
2395 IS
2396 x_progress VARCHAR2(3) := '010';
2397 v_sql VARCHAR2(32000);
2398 c_Demand t_Cursor_ref;
2399
2400 CURSOR c_blanket IS
2401 SELECT line_id,customer_production_line,customer_dock_code,request_date,
2402 schedule_ship_date,cust_po_number,item_revision customer_item_revision,
2403 customer_job,cust_model_serial_number,cust_production_seq_num,
2404 industry_attribute1,industry_attribute2,industry_attribute3,
2405 industry_attribute4,industry_attribute5,industry_attribute6,
2406 industry_attribute7,industry_attribute8,industry_attribute9,
2407 industry_attribute10,industry_attribute11,industry_attribute12,
2408 industry_attribute13,industry_attribute14,industry_attribute15,
2409 attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,
2410 attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,
2411 attribute13,attribute14,attribute15,demand_bucket_type_code,
2412 ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,
2413 ordered_item_id customer_item_id,inventory_item_id,header_id,
2414 ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,
2415 ordered_quantity,ordered_item,item_identifier_type,item_type_code,
2416 customer_line_number,blanket_number
2417 FROM oe_order_lines_all WHERE line_id = x_Key_rec.oe_line_id;
2418
2419 CURSOR c_order IS
2420 SELECT line_id,customer_production_line,customer_dock_code,request_date,
2421 schedule_ship_date,cust_po_number,item_revision customer_item_revision,
2422 customer_job,cust_model_serial_number,cust_production_seq_num,
2423 industry_attribute1,industry_attribute2,industry_attribute3,
2424 industry_attribute4,industry_attribute5,industry_attribute6,
2425 industry_attribute7,industry_attribute8,industry_attribute9,
2426 industry_attribute10,industry_attribute11,industry_attribute12,
2427 industry_attribute13,industry_attribute14,industry_attribute15,
2428 attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,
2429 attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,
2430 attribute13,attribute14,attribute15,demand_bucket_type_code,
2431 ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,
2432 ordered_item_id customer_item_id,inventory_item_id,header_id,
2433 ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,
2434 ordered_quantity,ordered_item,item_identifier_type,item_type_code,
2435 customer_line_number,NULL
2436 FROM oe_order_lines_all WHERE line_id = x_Key_rec.oe_line_id;
2437
2438 BEGIN
2439 --
2440 IF (l_debug <> -1) THEN
2441 rlm_core_sv.dpush(k_SDEBUG,'GetDemand');
2442 END IF;
2443 --
2444 IF x_Group_rec.setup_terms_rec.blanket_number IS NOT NULL THEN
2445 --
2446 OPEN c_blanket;
2447 --
2448 FETCH c_blanket INTO
2449 x_Key_rec.dem_rec.line_id,
2450 x_Key_rec.dem_rec.cust_production_line,
2451 x_Key_rec.dem_rec.customer_dock_code,
2452 x_Key_rec.dem_rec.request_date,
2453 x_Key_rec.dem_rec.schedule_date,
2454 x_Key_rec.dem_rec.cust_po_number,
2455 x_Key_rec.dem_rec.customer_item_revision,
2456 x_Key_rec.dem_rec.customer_job,
2457 x_Key_rec.dem_rec.cust_model_serial_number,
2458 x_Key_rec.dem_rec.cust_production_seq_num,
2459 x_Key_rec.dem_rec.industry_attribute1,
2460 x_Key_rec.dem_rec.industry_attribute2,
2461 x_Key_rec.dem_rec.industry_attribute3,
2462 x_Key_rec.dem_rec.industry_attribute4,
2463 x_Key_rec.dem_rec.industry_attribute5,
2464 x_Key_rec.dem_rec.industry_attribute6,
2465 x_Key_rec.dem_rec.industry_attribute7,
2466 x_Key_rec.dem_rec.industry_attribute8,
2467 x_Key_rec.dem_rec.industry_attribute9,
2468 x_Key_rec.dem_rec.industry_attribute10,
2469 x_Key_rec.dem_rec.industry_attribute11,
2470 x_Key_rec.dem_rec.industry_attribute12,
2471 x_Key_rec.dem_rec.industry_attribute13,
2472 x_Key_rec.dem_rec.industry_attribute14,
2473 x_Key_rec.dem_rec.industry_attribute15,
2474 x_Key_rec.dem_rec.attribute1,
2475 x_Key_rec.dem_rec.attribute2,
2476 x_Key_rec.dem_rec.attribute3,
2477 x_Key_rec.dem_rec.attribute4,
2478 x_Key_rec.dem_rec.attribute5,
2479 x_Key_rec.dem_rec.attribute6,
2480 x_Key_rec.dem_rec.attribute7,
2481 x_Key_rec.dem_rec.attribute8,
2482 x_Key_rec.dem_rec.attribute9,
2483 x_Key_rec.dem_rec.attribute10,
2484 x_Key_rec.dem_rec.attribute11,
2485 x_Key_rec.dem_rec.attribute12,
2486 x_Key_rec.dem_rec.attribute13,
2487 x_Key_rec.dem_rec.attribute14,
2488 x_Key_rec.dem_rec.attribute15,
2489 x_Key_rec.dem_rec.item_detail_subtype,
2490 x_Key_rec.dem_rec.ship_to_org_id,
2491 x_Key_rec.dem_rec.invoice_to_org_id,
2492 x_Key_rec.dem_rec.intmed_ship_to_org_id,
2493 x_Key_rec.dem_rec.customer_item_id,
2494 x_Key_rec.dem_rec.inventory_item_id,
2495 x_Key_rec.dem_rec.order_header_id,
2496 x_Key_rec.dem_rec.ship_from_org_id,
2497 x_Key_rec.dem_rec.schedule_type,
2498 x_Key_rec.dem_rec.authorized_to_ship_flag,
2499 x_Key_rec.dem_rec.ordered_quantity,
2500 x_Key_rec.dem_rec.customer_item_ext,
2501 x_Key_rec.dem_rec.item_identifier_type,
2502 x_Key_rec.dem_rec.item_detail_type,
2503 x_Key_rec.dem_rec.cust_po_line_num,
2504 x_Key_rec.dem_rec.blanket_number;
2505 --
2506 CLOSE c_blanket;
2507 --
2508 ELSE
2509 --
2510 OPEN c_order;
2511 --
2512 FETCH c_order INTO
2513 x_Key_rec.dem_rec.line_id,
2514 x_Key_rec.dem_rec.cust_production_line,
2515 x_Key_rec.dem_rec.customer_dock_code,
2516 x_Key_rec.dem_rec.request_date,
2517 x_Key_rec.dem_rec.schedule_date,
2518 x_Key_rec.dem_rec.cust_po_number,
2519 x_Key_rec.dem_rec.customer_item_revision,
2520 x_Key_rec.dem_rec.customer_job,
2521 x_Key_rec.dem_rec.cust_model_serial_number,
2522 x_Key_rec.dem_rec.cust_production_seq_num,
2523 x_Key_rec.dem_rec.industry_attribute1,
2524 x_Key_rec.dem_rec.industry_attribute2,
2525 x_Key_rec.dem_rec.industry_attribute3,
2526 x_Key_rec.dem_rec.industry_attribute4,
2527 x_Key_rec.dem_rec.industry_attribute5,
2528 x_Key_rec.dem_rec.industry_attribute6,
2529 x_Key_rec.dem_rec.industry_attribute7,
2530 x_Key_rec.dem_rec.industry_attribute8,
2531 x_Key_rec.dem_rec.industry_attribute9,
2532 x_Key_rec.dem_rec.industry_attribute10,
2533 x_Key_rec.dem_rec.industry_attribute11,
2534 x_Key_rec.dem_rec.industry_attribute12,
2535 x_Key_rec.dem_rec.industry_attribute13,
2536 x_Key_rec.dem_rec.industry_attribute14,
2537 x_Key_rec.dem_rec.industry_attribute15,
2538 x_Key_rec.dem_rec.attribute1,
2539 x_Key_rec.dem_rec.attribute2,
2540 x_Key_rec.dem_rec.attribute3,
2541 x_Key_rec.dem_rec.attribute4,
2542 x_Key_rec.dem_rec.attribute5,
2543 x_Key_rec.dem_rec.attribute6,
2544 x_Key_rec.dem_rec.attribute7,
2545 x_Key_rec.dem_rec.attribute8,
2546 x_Key_rec.dem_rec.attribute9,
2547 x_Key_rec.dem_rec.attribute10,
2548 x_Key_rec.dem_rec.attribute11,
2549 x_Key_rec.dem_rec.attribute12,
2550 x_Key_rec.dem_rec.attribute13,
2551 x_Key_rec.dem_rec.attribute14,
2552 x_Key_rec.dem_rec.attribute15,
2553 x_Key_rec.dem_rec.item_detail_subtype,
2554 x_Key_rec.dem_rec.ship_to_org_id,
2555 x_Key_rec.dem_rec.invoice_to_org_id,
2556 x_Key_rec.dem_rec.intmed_ship_to_org_id,
2557 x_Key_rec.dem_rec.customer_item_id,
2558 x_Key_rec.dem_rec.inventory_item_id,
2559 x_Key_rec.dem_rec.order_header_id,
2560 x_Key_rec.dem_rec.ship_from_org_id,
2561 x_Key_rec.dem_rec.schedule_type,
2562 x_Key_rec.dem_rec.authorized_to_ship_flag,
2563 x_Key_rec.dem_rec.ordered_quantity,
2564 x_Key_rec.dem_rec.customer_item_ext,
2565 x_Key_rec.dem_rec.item_identifier_type,
2566 x_Key_rec.dem_rec.item_detail_type,
2567 x_Key_rec.dem_rec.cust_po_line_num,
2568 x_Key_rec.dem_rec.blanket_number;
2569 --
2570 CLOSE c_order;
2571 --
2572 END IF;
2573 --
2574 IF (l_debug <> -1) THEN
2575 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.order_header_id',
2576 x_Key_rec.dem_rec.order_header_id);
2577 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.blanket_number',
2578 x_Key_rec.dem_rec.blanket_number);
2579 END IF;
2580 --
2581 IF (l_debug <> -1) THEN
2582 rlm_core_sv.dpop(k_SDEBUG);
2583 END IF;
2584 --
2585 EXCEPTION
2586 WHEN OTHERS THEN
2587 rlm_message_sv.sql_error('rlm_rd_sv.GetDemand',x_progress);
2588 --
2589 IF (l_debug <> -1) THEN
2590 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
2591 END IF;
2592 --
2593 raise;
2594
2595 END GetDemand;
2596
2597
2598 /*===========================================================================
2599
2600 PROCEDURE InitializeDemand
2601
2602 ===========================================================================*/
2603 PROCEDURE InitializeDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
2604 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
2605 x_Key_rec IN RLM_RD_SV.t_Key_rec,
2606 x_Demand_ref IN OUT NOCOPY t_Cursor_ref,
2607 x_DemandType IN VARCHAR2)
2608 IS
2609 x_progress VARCHAR2(3) := '010';
2610 v_select_clause VARCHAR2(32000);
2611 v_where_clause VARCHAR2(32000);
2612 v_sql VARCHAR2(32000);
2613 e_no_init EXCEPTION;
2614 v_request_date_str VARCHAR2(30);
2615 BEGIN
2616 --
2617 IF (l_debug <> -1) THEN
2618 rlm_core_sv.dpush(k_SDEBUG,'InitializeDemand');
2619 END IF;
2620 --
2621 g_InitDemandTab.DELETE;
2622 --
2623 IF x_DemandType NOT IN (k_ATS, k_NATS) THEN
2624 --
2625 RAISE e_no_init;
2626 --
2627 END IF;
2628 --
2629 v_select_clause :=
2630 'SELECT line_id,NVL(ordered_quantity,0),NVL(shipped_quantity,0),'||
2631 'sold_to_org_id,customer_production_line,customer_dock_code,'||
2632 'request_date,schedule_ship_date,cust_po_number,'||
2633 'item_revision customer_item_revision,customer_job,'||
2634 'cust_model_serial_number,cust_production_seq_num,industry_attribute1,'||
2635 'industry_attribute2,industry_attribute3,industry_attribute4,'||
2636 'industry_attribute5,industry_attribute6,industry_attribute7,'||
2637 'industry_attribute8,industry_attribute9,industry_attribute10,'||
2638 'industry_attribute11,industry_attribute12,industry_attribute13,'||
2639 'industry_attribute14,industry_attribute15,industry_context,'||
2640 'attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,'||
2641 'attribute7,attribute8,attribute9,attribute10,attribute11,attribute12,'||
2642 'attribute13,attribute14,attribute15,context,tp_attribute1,'||
2643 'tp_attribute2,tp_attribute3,tp_attribute4,tp_attribute5,tp_attribute6,'||
2644 'tp_attribute7,tp_attribute8,tp_attribute9,tp_attribute10,'||
2645 'tp_attribute11,tp_attribute12,tp_attribute13,tp_attribute14,'||
2646 'tp_attribute15,tp_context,demand_bucket_type_code,item_type_code,'||
2647 'ship_to_org_id,invoice_to_org_id,intmed_ship_to_org_id,'||
2648 'ordered_item_id customer_item_id,inventory_item_id,header_id,'||
2649 'ship_from_org_id,rla_schedule_type_code,authorized_to_ship_flag,'||
2650 'item_identifier_type,agreement_id,price_list_id,ordered_item,'||
2651 'order_quantity_uom,';
2652
2653 IF x_Group_rec.setup_terms_rec.blanket_number IS NOT NULL THEN
2654 --
2655 v_select_clause := v_select_clause || 'blanket_number FROM oe_order_lines';
2656 --
2657 ELSE
2658 --
2659 v_select_clause := v_select_clause || 'NULL FROM oe_order_lines';
2660 --
2661 END IF;
2662
2663 -- Mandatory Match Attributes
2664 v_where_clause :=
2665 ' WHERE header_id = :order_header_id' ||
2666 ' AND ship_to_org_id = :ship_to_org_id' ||
2667 ' AND ordered_item_id = :customer_item_id'||
2668 ' AND inventory_item_id= :inventory_item_id' ||
2669 ' AND NVL(intmed_ship_to_org_id,' || k_NNULL|| ') = NVL(:intmed_ship_to_org_id , '||k_NNULL || ')'|| --Bugfix 5911991
2670 ' AND (NVL(ordered_quantity,0) - NVL(shipped_quantity,0)) > 0' ||
2671 ' AND NVL(demand_bucket_type_code,'|| k_NNULL || ') = NVL(:item_detail_subtype,'||k_NNULL||')';
2672 --
2673 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.order_header_id;
2674 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.ship_to_org_id;
2675 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.customer_item_id;
2676 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.inventory_item_id;
2677 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.intmed_ship_to_org_id; --Bugfix 5911991
2678 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.item_detail_subtype;
2679 --
2680 -- Start of bug 4223359
2681 --If the disposition code is remain on File reconcile get all the open sales order lines
2682 --If the disposition code is remain on File then use horizon_start_date and horizon end date
2683 --If the disposition code is Cancel All then use SYSDATE
2684 --
2685 IF x_Group_rec.disposition_code = k_CANCEL_ALL THEN
2686 --
2687 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'') ';
2688 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(rlm_dp_sv.g_dsp_start_time), 'RRRR/MM/DD HH24:MI:SS'); --Bugfix 10053830
2689 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2690 --
2691 ELSIF x_Group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS THEN
2692 --
2693 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'') ';
2694 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(rlm_dp_sv.g_dsp_start_time) - NVL(x_group_rec.cutoff_days,0), 'RRRR/MM/DD HH24:MI:SS'); --Bugfix 10053830
2695 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2696 --
2697 ELSIF x_Group_rec.disposition_code = k_REMAIN_ON_FILE_RECONCILE THEN
2698 --
2699 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'') ';
2700 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2701 --
2702 ELSE
2703 --
2704 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'') ';
2705 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date), 'RRRR/MM/DD HH24:MI:SS');
2706 g_InitDemandTab(g_InitDemandTab.COUNT+1) := TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999, 'RRRR/MM/DD HH24:MI:SS');
2707 --
2708 END IF;
2709 --
2710 -- END of bug 4223359
2711 --
2712 -- Optional match
2713 v_request_date_str := TO_CHAR(x_Key_rec.req_rec.request_date,'RRRR/MM/DD HH24:MI:SS');
2714
2715 IF x_group_rec.match_across_rec.request_date = 'Y' THEN
2716 --
2717 v_where_clause := v_where_clause ||
2718 ' AND request_date = TO_DATE(:v_req_date,''RRRR/MM/DD HH24:MI:SS'')';
2719 g_InitDemandTab(g_InitDemandTab.COUNT+1) := v_request_date_str;
2720 --
2721 ELSE
2722 --
2723 IF x_group_rec.match_within_rec.request_date = 'Y' THEN
2724 --
2725 v_where_clause := v_where_clause ||
2726 ' AND request_date = DECODE(rla_schedule_type_code, :schedule_type, TO_DATE(:v_req_date,''RRRR/MM/DD HH24:MI:SS'')'||',request_date)';
2727 --
2728 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2729 g_InitDemandTab(g_InitDemandTab.COUNT+1) := v_request_date_str;
2730 END IF;
2731 --
2732 END IF;
2733 --
2734
2735 IF x_group_rec.match_across_rec.cust_production_line = 'Y' THEN
2736 --
2737 v_where_clause := v_where_clause ||
2738 ' AND NVL(customer_production_line,'''||k_VNULL||
2739 ''') = NVL(:customer_production_line, ''' || k_VNULL || ''')';
2740 --
2741 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_line;
2742 --
2743 ELSE
2744 --
2745 IF x_group_rec.match_within_rec.cust_production_line = 'Y' THEN
2746 --
2747 v_where_clause := v_where_clause ||
2748 ' AND NVL(customer_production_line,'''||k_VNULL||
2749 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_production_line,''' || k_VNULL ||
2750 '''), NVL(customer_production_line,'''||k_VNULL||'''))';
2751 --
2752 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2753 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_line;
2754 --
2755 END IF;
2756 --
2757 END IF;
2758 --
2759 IF x_group_rec.match_across_rec.customer_dock_code = 'Y' THEN
2760 --
2761 v_where_clause := v_where_clause ||
2762 ' AND NVL(customer_dock_code,'''||k_VNULL||
2763 ''') = NVL(:customer_dock_code,''' || k_VNULL || ''')';
2764 --
2765 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_dock_code;
2766 --
2767 ELSE
2768 --
2769 IF x_group_rec.match_within_rec.customer_dock_code = 'Y' THEN
2770 --
2771 v_where_clause := v_where_clause ||
2772 ' AND NVL(customer_dock_code,'''||k_VNULL||
2773 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_dock_code,''' || k_VNULL ||
2774 '''), NVL(customer_dock_code,'''||k_VNULL||'''))';
2775 --
2776 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2777 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_dock_code;
2778 --
2779 END IF;
2780 --
2781 END IF;
2782 --
2783 IF x_group_rec.match_across_rec.cust_po_number = 'Y' THEN
2784 --
2785 v_where_clause := v_where_clause ||
2786 ' AND NVL(cust_po_number,'''||k_VNULL||
2787 ''') = NVL(:cust_po_number,''' || k_VNULL || ''')';
2788 --
2789 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_po_number;
2790 --
2791 ELSE
2792 --
2793 IF x_group_rec.match_within_rec.cust_po_number = 'Y' THEN
2794 --
2795 v_where_clause := v_where_clause ||
2796 ' AND NVL(cust_po_number,'''||k_VNULL||
2797 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_po_number,''' || k_VNULL ||
2798 '''), NVL(cust_po_number,'''||k_VNULL||'''))';
2799 --
2800 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2801 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_po_number;
2802 --
2803 END IF;
2804 --
2805 END IF;
2806 --
2807 IF x_group_rec.match_across_rec.customer_item_revision = 'Y' THEN
2808 --
2809 v_where_clause := v_where_clause ||
2810 ' AND NVL(item_revision,'''||k_VNULL||
2811 ''') = NVL(:customer_item_revision,''' || k_VNULL || ''')';
2812 --
2813 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_item_revision;
2814 --
2815 ELSE
2816 --
2817 IF x_group_rec.match_within_rec.customer_item_revision = 'Y' THEN
2818 --
2819 v_where_clause := v_where_clause ||
2820 ' AND NVL(item_revision,'''||k_VNULL||
2821 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_item_revision,''' || k_VNULL ||
2822 '''), NVL(item_revision,'''||k_VNULL||'''))';
2823 --
2824 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2825 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_item_revision;
2826 --
2827 END IF;
2828 --
2829 END IF;
2830 --
2831 IF x_group_rec.match_across_rec.customer_job = 'Y' THEN
2832 --
2833 v_where_clause := v_where_clause ||
2834 ' AND NVL(customer_job,'''||k_VNULL||
2835 ''') = NVL(:customer_job,''' || k_VNULL || ''')';
2836 --
2837 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_job;
2838 --
2839 ELSE
2840 --
2841 IF x_group_rec.match_within_rec.customer_job = 'Y' THEN
2842 --
2843 v_where_clause := v_where_clause ||
2844 ' AND NVL(customer_job,'''||k_VNULL||
2845 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:customer_job, ''' || k_VNULL ||
2846 '''), NVL(customer_job,'''||k_VNULL||'''))';
2847 --
2848 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2849 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.customer_job;
2850 --
2851 END IF;
2852 --
2853 END IF;
2854 --
2855 IF x_group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
2856 --
2857 v_where_clause := v_where_clause ||
2858 ' AND NVL(cust_model_serial_number,'''||k_VNULL||
2859 ''') = NVL(:cust_model_serial_number,''' || k_VNULL || ''')';
2860 --
2861 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_model_serial_number;
2862 --
2863 ELSE
2864 --
2865 IF x_group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
2866 --
2867 v_where_clause := v_where_clause ||
2868 ' AND NVL(cust_model_serial_number,'''||k_VNULL||
2869 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_model_serial_num,''' || k_VNULL ||
2870 '''), NVL(cust_model_serial_number,'''||k_VNULL||'''))';
2871 --
2872 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2873 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_model_serial_number;
2874 --
2875 END IF;
2876 --
2877 END IF;
2878 --
2879 IF x_group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
2880 --
2881 v_where_clause := v_where_clause ||
2882 ' AND NVL(cust_production_seq_num,'''||k_VNULL||
2883 ''') = NVL(:cust_production_seq_num,''' || k_VNULL || ''')';
2884 --
2885 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_seq_num;
2886 --
2887 ELSE
2888 --
2889 IF x_group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
2890 --
2891 v_where_clause := v_where_clause ||
2892 ' AND NVL(cust_production_seq_num,'''||k_VNULL||
2893 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:cust_production_seq_num,''' || k_VNULL ||
2894 '''), NVL(cust_production_seq_num,'''||k_VNULL||'''))';
2895 --
2896 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2897 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.cust_production_seq_num;
2898 --
2899 END IF;
2900 --
2901 END IF;
2902 --
2903 IF x_group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
2904 --
2905 v_where_clause := v_where_clause ||
2906 ' AND NVL(industry_attribute1,'''||k_VNULL||
2907 ''') = NVL(:industry_attribute1,''' || k_VNULL || ''')';
2908 --
2909 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute1;
2910 --
2911 ELSE
2912 --
2913 IF x_group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
2914 --
2915 v_where_clause := v_where_clause ||
2916 ' AND NVL(industry_attribute1,'''||k_VNULL||
2917 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute1,''' || k_VNULL ||
2918 '''), NVL(industry_attribute1,'''||k_VNULL||'''))';
2919 --
2920 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2921 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute1;
2922 --
2923 END IF;
2924 --
2925 END IF;
2926 --
2927 IF x_group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
2928 --
2929 v_where_clause := v_where_clause ||
2930 ' AND NVL(industry_attribute2,'''||k_VNULL||
2931 ''') = NVL(:industry_attribute2,''' || k_VNULL || ''')';
2932 --
2933 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute2;
2934 --
2935 ELSE
2936 --
2937 IF x_group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
2938 --
2939 v_where_clause := v_where_clause ||
2940 ' AND NVL(industry_attribute2,'''||k_VNULL||
2941 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute2,''' || k_VNULL ||
2942 '''),NVL(industry_attribute2,'''||k_VNULL||'''))';
2943 --
2944 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2945 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute2;
2946 --
2947 END IF;
2948 --
2949 END IF;
2950 --
2951 IF x_group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
2952 --
2953 v_where_clause := v_where_clause ||
2954 ' AND NVL(industry_attribute4,'''||k_VNULL||
2955 ''') = NVL(:industry_attribute4, ''' || k_VNULL || ''')';
2956 --
2957 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute4;
2958 --
2959 ELSE
2960 --
2961 IF x_group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
2962 --
2963 v_where_clause := v_where_clause ||
2964 ' AND NVL(industry_attribute4,'''||k_VNULL||
2965 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute4,''' || k_VNULL ||
2966 '''),NVL(industry_attribute4,'''||k_VNULL||'''))';
2967 --
2968 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2969 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute4;
2970 --
2971 END IF;
2972 --
2973 END IF;
2974 --
2975 IF x_group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
2976 --
2977 v_where_clause := v_where_clause ||
2978 ' AND NVL(industry_attribute5,'''||k_VNULL||
2979 ''') = NVL(:industry_attribute5,''' || k_VNULL || ''')';
2980 --
2981 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute5;
2982 --
2983 ELSE
2984 --
2985 IF x_group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
2986 --
2987 v_where_clause := v_where_clause ||
2988 ' AND NVL(industry_attribute5,'''||k_VNULL||
2989 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute5,''' || k_VNULL ||
2990 '''),NVL(industry_attribute5,'''||k_VNULL||'''))';
2991 --
2992 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
2993 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute5;
2994 --
2995 END IF;
2996 --
2997 END IF;
2998 --
2999 IF x_group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
3000 --
3001 v_where_clause := v_where_clause ||
3002 ' AND NVL(industry_attribute6,'''||k_VNULL||
3003 ''') = NVL(:industry_attribute6,''' || k_VNULL || ''')';
3004 --
3005 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute6;
3006 --
3007 ELSE
3008 --
3009 IF x_group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
3010 --
3011 v_where_clause := v_where_clause ||
3012 ' AND NVL(industry_attribute6,'''||k_VNULL||
3013 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute6,''' || k_VNULL ||
3014 '''), NVL(industry_attribute6,'''||k_VNULL||'''))';
3015 --
3016 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3017 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute6;
3018 --
3019 END IF;
3020 --
3021 END IF;
3022 --
3023 IF x_group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
3024 --
3025 v_where_clause := v_where_clause ||
3026 ' AND NVL(industry_attribute10,'''||k_VNULL||
3027 ''') = NVL(:industry_attribute10,''' || k_VNULL || ''')';
3028 --
3029 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute10;
3030 --
3031 ELSE
3032 --
3033 IF x_group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
3034 --
3035 v_where_clause := v_where_clause ||
3036 ' AND NVL(industry_attribute10,'''||k_VNULL||
3037 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute10,''' || k_VNULL ||
3038 '''),NVL(industry_attribute10,'''||k_VNULL||'''))';
3039 --
3040 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3041 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute10;
3042 --
3043 END IF;
3044 --
3045 END IF;
3046 --
3047 IF x_group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
3048 --
3049 v_where_clause := v_where_clause ||
3050 ' AND NVL(industry_attribute11,'''||k_VNULL||
3051 ''') = NVL(:industry_attribute11,''' || k_VNULL || ''')';
3052 --
3053 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute11;
3054 --
3055 ELSE
3056 --
3057 IF x_group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
3058 --
3059 v_where_clause := v_where_clause ||
3060 ' AND NVL(industry_attribute11,'''||k_VNULL||
3061 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute11,''' || k_VNULL ||
3062 '''), NVL(industry_attribute11,'''||k_VNULL||'''))';
3063 --
3064 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3065 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute11;
3066 --
3067 END IF;
3068 --
3069 END IF;
3070 --
3071 IF x_group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
3072 --
3073 v_where_clause := v_where_clause ||
3074 ' AND NVL(industry_attribute12,'''||k_VNULL||
3075 ''') = NVL(:industry_attribute12,''' || k_VNULL || ''')';
3076 --
3077 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute12;
3078 --
3079 ELSE
3080 --
3081 IF x_group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
3082 --
3083 v_where_clause := v_where_clause ||
3084 ' AND NVL(industry_attribute12,'''||k_VNULL||
3085 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute12,''' || k_VNULL ||
3086 '''), NVL(industry_attribute12,'''||k_VNULL||'''))';
3087 --
3088 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3089 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute12;
3090 --
3091 END IF;
3092 --
3093 END IF;
3094 --
3095 IF x_group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
3096 --
3097 v_where_clause := v_where_clause ||
3098 ' AND NVL(industry_attribute13,'''||k_VNULL||
3099 ''') = NVL(:industry_attribute13,''' || k_VNULL || ''')';
3100 --
3101 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute13;
3102 --
3103 ELSE
3104 --
3105 IF x_group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
3106 --
3107 v_where_clause := v_where_clause ||
3108 ' AND NVL(industry_attribute13,'''||k_VNULL||
3109 ''') = DECODE(rla_schedule_type_code, :schedule_type,' ||
3110 ' NVL(:industry_attribute13,''' || k_VNULL || '''), NVL(industry_attribute13,'''||k_VNULL||'''))';
3111 --
3112 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3113 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute13;
3114 --
3115 END IF;
3116 --
3117 END IF;
3118 --
3119 IF x_group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
3120 --
3121 v_where_clause := v_where_clause ||
3122 ' AND NVL(industry_attribute14,'''||k_VNULL||
3123 ''') = NVL(:industry_attribute14,''' || k_VNULL || ''')';
3124 --
3125 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute14;
3126 --
3127 ELSE
3128 --
3129 IF x_group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
3130 --
3131 v_where_clause := v_where_clause ||
3132 ' AND NVL(industry_attribute14,'''||k_VNULL||
3133 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:industry_attribute14,''' || k_VNULL ||
3134 '''), NVL(industry_attribute14,'''||k_VNULL||'''))';
3135 --
3136 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3137 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute14;
3138 --
3139 END IF;
3140 --
3141 END IF;
3142 --
3143 IF g_ATP <> k_ATP THEN
3144 --
3145 v_where_clause := v_where_clause ||
3146 ' AND ship_from_org_id = :ship_from_org_id '||
3147 ' AND NVL(industry_attribute15,'''||k_VNULL||
3148 ''') = NVL(:industry_attribute15,''' || k_VNULL || ''')';
3149 --
3150 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Group_rec.ship_from_org_id;
3151 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.industry_attribute15;
3152 --
3153 END IF;
3154
3155 --
3156 IF x_group_rec.match_across_rec.attribute1 = 'Y' THEN
3157 --
3158 v_where_clause := v_where_clause ||
3159 ' AND NVL(attribute1,'''||k_VNULL||
3160 ''') = NVL(:attribute1, ''' || k_VNULL || ''')';
3161 --
3162 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute1;
3163 --
3164 ELSE
3165 --
3166 IF x_group_rec.match_within_rec.attribute1 = 'Y' THEN
3167 --
3168 v_where_clause := v_where_clause ||
3169 ' AND NVL(attribute1,'''||k_VNULL||
3170 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute2,''' || k_VNULL || '''), NVL(attribute2,'''||k_VNULL||'''))';
3171 --
3172 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3173 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute2;
3174 --
3175 END IF;
3176 --
3177 END IF;
3178 --
3179 IF x_group_rec.match_across_rec.attribute3 = 'Y' THEN
3180 --
3181 v_where_clause := v_where_clause ||
3182 ' AND NVL(attribute3,'''||k_VNULL||
3183 ''') = NVL(:attribute3,''' || k_VNULL || ''')';
3184 --
3185 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute3;
3186 --
3187 ELSE
3188 --
3189 IF x_group_rec.match_within_rec.attribute3 = 'Y' THEN
3190 --
3191 v_where_clause := v_where_clause ||
3192 ' AND NVL(attribute3,'''||k_VNULL||
3193 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute3,''' || k_VNULL ||
3194 '''), NVL(attribute3,'''||k_VNULL||'''))';
3195 --
3196 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3197 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute3;
3198 --
3199 END IF;
3200 --
3201 END IF;
3202 --
3203 IF x_group_rec.match_across_rec.attribute4 = 'Y' THEN
3204 --
3205 v_where_clause := v_where_clause ||
3206 ' AND NVL(attribute4,'''||k_VNULL||
3207 ''') = NVL(:attribute4,''' || k_VNULL || ''')';
3208 --
3209 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute4;
3210 --
3211 ELSE
3212 --
3213 IF x_group_rec.match_within_rec.attribute4 = 'Y' THEN
3214 --
3215 v_where_clause := v_where_clause ||
3216 ' AND NVL(attribute4,'''||k_VNULL||
3217 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute4,''' || k_VNULL ||
3218 '''), NVL(attribute4,'''||k_VNULL||'''))';
3219 --
3220 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3221 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute4;
3222 --
3223 END IF;
3224 --
3225 END IF;
3226 --
3227 IF x_group_rec.match_across_rec.attribute5 = 'Y' THEN
3228 --
3229 v_where_clause := v_where_clause ||
3230 ' AND NVL(attribute5,'''||k_VNULL||
3231 ''') = NVL(:attribute5,''' || k_VNULL || ''')';
3232 --
3233 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute5;
3234 --
3235 ELSE
3236 --
3237 IF x_group_rec.match_within_rec.attribute5 = 'Y' THEN
3238 --
3239 v_where_clause := v_where_clause ||
3240 ' AND NVL(attribute5,'''||k_VNULL||
3241 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute5,''' || k_VNULL ||
3242 '''), NVL(attribute5,'''||k_VNULL||'''))';
3243 --
3244 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3245 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute5;
3246 --
3247 END IF;
3248 --
3249 END IF;
3250 --
3251 IF x_group_rec.match_across_rec.attribute6 = 'Y' THEN
3252 --
3253 v_where_clause := v_where_clause ||
3254 ' AND NVL(attribute6,'''||k_VNULL||
3255 ''') = NVL(:attribute6,''' || k_VNULL || ''')';
3256 --
3257 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute6;
3258 --
3259 ELSE
3260 --
3261 IF x_group_rec.match_within_rec.attribute6 = 'Y' THEN
3262 --
3263 v_where_clause := v_where_clause ||
3264 ' AND NVL(attribute6,'''||k_VNULL||
3265 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute6,''' || k_VNULL ||
3266 '''), NVL(attribute6,'''||k_VNULL||'''))';
3267 --
3268 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3269 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute6;
3270 --
3271 END IF;
3272 --
3273 END IF;
3274 --
3275 IF x_group_rec.match_across_rec.attribute7 = 'Y' THEN
3276 --
3277 v_where_clause := v_where_clause ||
3278 ' AND NVL(attribute7,'''||k_VNULL||
3279 ''') = NVL(:attribute7,''' || k_VNULL || ''')';
3280 --
3281 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute7;
3282 --
3283 ELSE
3284 --
3285 IF x_group_rec.match_within_rec.attribute7 = 'Y' THEN
3286 --
3287 v_where_clause := v_where_clause ||
3288 ' AND NVL(attribute7,'''||k_VNULL||
3289 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute7,''' || k_VNULL ||
3290 '''), NVL(attribute7,'''||k_VNULL||'''))';
3291 --
3292 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3293 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute7;
3294 --
3295 END IF;
3296 --
3297 END IF;
3298 --
3299 IF x_group_rec.match_across_rec.attribute8 = 'Y' THEN
3300 --
3301 v_where_clause := v_where_clause ||
3302 ' AND NVL(attribute8,'''||k_VNULL||
3303 ''') = NVL(:attribute8,''' || k_VNULL || ''')';
3304 --
3305 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute8;
3306 --
3307 ELSE
3308 --
3309 IF x_group_rec.match_within_rec.attribute8 = 'Y' THEN
3310 --
3311 v_where_clause := v_where_clause ||
3312 ' AND NVL(attribute8,'''||k_VNULL||
3313 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute8,''' || k_VNULL ||
3314 '''), NVL(attribute8,'''||k_VNULL||'''))';
3315 --
3316 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3317 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute8;
3318 --
3319 END IF;
3320 --
3321 END IF;
3322 --
3323 IF x_group_rec.match_across_rec.attribute9 = 'Y' THEN
3324 --
3325 v_where_clause := v_where_clause ||
3326 ' AND NVL(attribute9,'''||k_VNULL||
3327 ''') = NVL(:attribute9,''' || k_VNULL || ''')';
3328 --
3329 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute9;
3330 --
3331 ELSE
3332 --
3333 IF x_group_rec.match_within_rec.attribute9 = 'Y' THEN
3334 --
3335 v_where_clause := v_where_clause ||
3336 ' AND NVL(attribute9,'''||k_VNULL||
3337 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute9,''' || k_VNULL ||
3338 '''), NVL(attribute9,'''||k_VNULL||'''))';
3339 --
3340 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3341 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute9;
3342 --
3343 END IF;
3344 --
3345 END IF;
3346 --
3347 IF x_group_rec.match_across_rec.attribute10 = 'Y' THEN
3348 --
3349 v_where_clause := v_where_clause ||
3350 ' AND NVL(attribute10,'''||k_VNULL||
3351 ''') = NVL(:attribute10,''' || k_VNULL || ''')';
3352 --
3353 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute10;
3354 --
3355 ELSE
3356 --
3357 IF x_group_rec.match_within_rec.attribute10 = 'Y' THEN
3358 --
3359 v_where_clause := v_where_clause ||
3360 ' AND NVL(attribute10,'''||k_VNULL||
3361 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute10,''' || k_VNULL ||
3362 '''), NVL(attribute10,'''||k_VNULL||'''))';
3363 --
3364 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3365 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute10;
3366 --
3367 END IF;
3368 --
3369 END IF;
3370 --
3371 IF x_group_rec.match_across_rec.attribute11 = 'Y' THEN
3372 --
3373 v_where_clause := v_where_clause ||
3374 ' AND NVL(attribute11,'''||k_VNULL||
3375 ''') = NVL(:attribute11,''' || k_VNULL || ''')';
3376 --
3377 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute11;
3378 --
3379 ELSE
3380 --
3381 IF x_group_rec.match_within_rec.attribute11 = 'Y' THEN
3382 --
3383 v_where_clause := v_where_clause ||
3384 ' AND NVL(attribute11,'''||k_VNULL||
3385 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute11, ''' || k_VNULL ||
3386 '''), NVL(attribute11,'''||k_VNULL||'''))';
3387 --
3388 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3389 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute11;
3390 --
3391 END IF;
3392 --
3393 END IF;
3394 --
3395 IF x_group_rec.match_across_rec.attribute12 = 'Y' THEN
3396 --
3397 v_where_clause := v_where_clause ||
3398 ' AND NVL(attribute12,'''||k_VNULL||
3399 ''') = NVL(:attribute12,''' || k_VNULL || ''')';
3400 --
3401 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute12;
3402 --
3403 ELSE
3404 --
3405 IF x_group_rec.match_within_rec.attribute12 = 'Y' THEN
3406 --
3407 v_where_clause := v_where_clause ||
3408 ' AND NVL(attribute12,'''||k_VNULL||
3409 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute12,''' || k_VNULL ||
3410 '''), NVL(attribute12,'''||k_VNULL||'''))';
3411 --
3412 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3413 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute12;
3414 --
3415 END IF;
3416 --
3417 END IF;
3418 --
3419 IF x_group_rec.match_across_rec.attribute13 = 'Y' THEN
3420 --
3421 v_where_clause := v_where_clause ||
3422 ' AND NVL(attribute13,'''||k_VNULL||
3423 ''') = NVL(:attribute13,''' || k_VNULL || ''')';
3424 --
3425 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute13;
3426 --
3427 ELSE
3428 --
3429 IF x_group_rec.match_within_rec.attribute13 = 'Y' THEN
3430 --
3431 v_where_clause := v_where_clause ||
3432 ' AND NVL(attribute13,'''||k_VNULL||
3433 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute13,''' || k_VNULL ||
3434 '''), NVL(attribute13,'''||k_VNULL||'''))';
3435 --
3436 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3437 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute13;
3438 --
3439 END IF;
3440 --
3441 END IF;
3442 --
3443 IF x_group_rec.match_across_rec.attribute14 = 'Y' THEN
3444 --
3445 v_where_clause := v_where_clause ||
3446 ' AND NVL(attribute14,'''||k_VNULL||
3447 ''') = NVL(:attribute14,''' || k_VNULL || ''')';
3448 --
3449 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute14;
3450 --
3451 ELSE
3452 --
3453 IF x_group_rec.match_within_rec.attribute14 = 'Y' THEN
3454 --
3455 v_where_clause := v_where_clause ||
3456 ' AND NVL(attribute14,'''||k_VNULL||
3457 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute14,''' || k_VNULL ||
3458 '''), NVL(attribute14,'''||k_VNULL||'''))';
3459 --
3460 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3461 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute14;
3462 --
3463 END IF;
3464 --
3465 END IF;
3466 --
3467 IF x_group_rec.match_across_rec.attribute15 = 'Y' THEN
3468 --
3469 v_where_clause := v_where_clause ||
3470 ' AND NVL(attribute15,'''||k_VNULL||
3471 ''') = NVL(:attribute15,''' || k_VNULL || ''')';
3472 --
3473 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute15;
3474 --
3475 ELSE
3476 --
3477 IF x_group_rec.match_within_rec.attribute15 = 'Y' THEN
3478 --
3479 v_where_clause := v_where_clause ||
3480 ' AND NVL(attribute15,'''||k_VNULL||
3481 ''') = DECODE(rla_schedule_type_code, :schedule_type, NVL(:attribute15,''' || k_VNULL ||
3482 '''), NVL(attribute15,'''||k_VNULL||'''))';
3483 --
3484 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Sched_rec.schedule_type;
3485 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_Key_rec.req_rec.attribute15;
3486 --
3487 END IF;
3488 --
3489 END IF;
3490 --
3491 -- R12 Perf Bug 5013956 : Use bind variable for ATS flag
3492 --
3493 v_where_clause := v_where_clause || ' AND authorized_to_ship_flag = :x_DemandType ORDER BY request_date DESC';
3494 g_InitDemandTab(g_InitDemandTab.COUNT+1) := x_DemandType;
3495 --
3496 IF (l_debug <> -1) THEN
3497 rlm_core_sv.dlog(k_DEBUG,'v_select_clause',v_select_clause);
3498 rlm_core_sv.dlog(k_DEBUG,'v_where_clause',v_where_clause);
3499 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for x_Demand_ref cursor', g_InitDemandTab.COUNT);
3500 END IF;
3501 --
3502 v_sql := v_select_clause || v_where_clause;
3503 --
3504 RLM_CORE_SV.OpenDynamicCursor(x_Demand_ref, v_sql, g_InitDemandTab);
3505 --
3506 IF (l_debug <> -1) THEN
3507 rlm_core_sv.dpop(k_SDEBUG);
3508 END IF;
3509 --
3510 EXCEPTION
3511 WHEN e_no_init THEN
3512 rlm_core_sv.dpop(k_SDEBUG,'Demand Type is not ATS or NATS');
3513
3514 WHEN OTHERS THEN
3515 rlm_message_sv.sql_error('rlm_rd_sv.InitializeDemand',x_progress);
3516 --
3517 IF (l_debug <> -1) THEN
3518 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3519 END IF;
3520 --
3521 raise;
3522
3523 END InitializeDemand;
3524
3525 /*===========================================================================
3526
3527 PROCEDURE InitializeSoGroup
3528
3529 ===========================================================================*/
3530 PROCEDURE InitializeSoGroup(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3531 x_Group_ref IN OUT NOCOPY rlm_rd_sv.t_Cursor_ref,
3532 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
3533 IS
3534 x_progress VARCHAR2(3) := '010';
3535
3536 BEGIN
3537 --
3538 IF (l_debug <> -1) THEN
3539 rlm_core_sv.dpush(k_SDEBUG,'InitializeSoGroup');
3540 END IF;
3541 --
3542 OPEN x_Group_ref FOR
3543 SELECT rih.customer_id,
3544 ril.ship_from_org_id,
3545 ril.ship_to_address_id,
3546 ril.ship_to_org_id,
3547 ril.customer_item_id,
3548 ril.inventory_item_id,
3549 ril.industry_attribute15,
3550 ril.intrmd_ship_to_id, --Bugfix 5911991
3551 ril.intmed_ship_to_org_id --Bugfix 5911991
3552 --ril.order_header_id,
3553 --ril.blanket_number
3554 --ril.cust_production_seq_num
3555 FROM rlm_interface_headers rih,
3556 rlm_interface_lines_all ril
3557 WHERE rih.header_id = x_Sched_rec.header_id
3558 AND rih.org_id = ril.org_id
3559 AND ril.header_id = rih.header_id
3560 AND ril.industry_attribute15 = x_Group_rec.ship_from_org_id
3561 AND ril.process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
3562 --AND ril.inventory_item_id = x_Group_rec.inventory_item_id
3563 AND ril.customer_item_id = x_Group_rec.customer_item_id
3564 AND ril.ship_to_address_id = x_Group_rec.ship_to_address_id
3565 -- blankets
3566 --AND ril.blanket_number IS NULL
3567 GROUP BY rih.customer_id,
3568 ril.ship_from_org_id,
3569 ril.ship_to_address_id,
3570 ril.ship_to_org_id,
3571 ril.customer_item_id,
3572 ril.inventory_item_id,
3573 ril.industry_attribute15,
3574 ril.intrmd_ship_to_id, --Bugfix 5911991
3575 ril.intmed_ship_to_org_id --Bugfix 5911991
3576 --ril.order_header_id,
3577 --ril.blanket_number
3578 --ril.cust_production_seq_num
3579 ORDER BY ril.ship_to_org_id,
3580 ril.customer_item_id;
3581 --
3582 IF (l_debug <> -1) THEN
3583 rlm_core_sv.dpop(k_SDEBUG);
3584 END IF;
3585 --
3586 EXCEPTION
3587 WHEN OTHERS THEN
3588 rlm_message_sv.sql_error('rlm_rd_sv.InitializeSoGroup',x_progress);
3589 --
3590 IF (l_debug <> -1) THEN
3591 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3592 END IF;
3593 --
3594 raise e_group_error;
3595
3596 END InitializeSoGroup;
3597
3598
3599 /*===========================================================================
3600
3601 PROCEDURE InitializeReq
3602
3603 ===========================================================================*/
3604 PROCEDURE InitializeReq(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3605 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
3606 x_Req_ref IN OUT NOCOPY t_Cursor_ref,
3607 x_ReqType IN VARCHAR2)
3608 IS
3609 x_progress VARCHAR2(3) := '010';
3610
3611 BEGIN
3612 --
3613 IF (l_debug <> -1) THEN
3614 rlm_core_sv.dpush(k_SDEBUG,'InitializeReq');
3615 rlm_core_sv.dlog(k_DEBUG,'x_ReqType', x_ReqType);
3616 END IF;
3617 --
3618 IF x_ReqType IN (k_NATS, k_ATS) THEN
3619 --
3620 IF (l_debug <> -1) THEN
3621 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id', x_Group_rec.ship_to_org_id);
3622 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
3623 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
3624 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
3625 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date', x_Sched_rec.sched_horizon_start_date);
3626 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date', x_Sched_rec.sched_horizon_end_date);
3627 END IF;
3628 --
3629 IF (x_ReqType = k_ATS) THEN
3630
3631 OPEN x_Req_ref FOR
3632 SELECT x_group_rec.customer_id,
3633 header_id,
3634 line_id,
3635 cust_production_line,
3636 customer_dock_code,
3637 request_date,
3638 schedule_date,
3639 cust_po_number,
3640 customer_item_revision,
3641 customer_job,
3642 cust_model_serial_number,
3643 cust_production_seq_num,
3644 industry_attribute1,
3645 industry_attribute2,
3646 industry_attribute3,
3647 industry_attribute4,
3648 industry_attribute5,
3649 industry_attribute6,
3650 industry_attribute7,
3651 industry_attribute8,
3652 industry_attribute9,
3653 industry_attribute10,
3654 industry_attribute11,
3655 industry_attribute12,
3656 industry_attribute13,
3657 industry_attribute14,
3658 industry_attribute15,
3659 industry_context,
3660 attribute1,
3661 attribute2,
3662 attribute3,
3663 attribute4,
3664 attribute5,
3665 attribute6,
3666 attribute7,
3667 attribute8,
3668 attribute9,
3669 attribute10,
3670 attribute11,
3671 attribute12,
3672 attribute13,
3673 attribute14,
3674 attribute15,
3675 attribute_category,
3676 tp_attribute1,
3677 tp_attribute2,
3678 tp_attribute3,
3679 tp_attribute4,
3680 tp_attribute5,
3681 tp_attribute6,
3682 tp_attribute7,
3683 tp_attribute8,
3684 tp_attribute9,
3685 tp_attribute10,
3686 tp_attribute11,
3687 tp_attribute12,
3688 tp_attribute13,
3689 tp_attribute14,
3690 tp_attribute15,
3691 tp_attribute_category,
3692 item_detail_type,
3693 item_detail_subtype,
3694 intrmd_ship_to_id,
3695 ship_to_org_id,
3696 invoice_to_org_id,
3697 primary_quantity,
3698 intmed_ship_to_org_id,
3699 customer_item_id,
3700 inventory_item_id,
3701 order_header_id,
3702 x_ReqType,
3703 ship_from_org_id,
3704 x_Sched_rec.schedule_type,
3705 'CUST' item_identifier_type,
3706 customer_item_ext,
3707 agreement_id,
3708 price_list_id,
3709 x_Sched_rec.schedule_header_id,
3710 schedule_line_id,
3711 process_status,
3712 uom_code,
3713 cust_po_line_num
3714 FROM rlm_interface_lines
3715 WHERE header_id = x_Sched_rec.header_id
3716 AND ship_from_org_id = x_Group_rec.ship_from_org_id
3717 AND industry_attribute15 = x_Group_rec.industry_attribute15
3718 AND ship_to_org_id = x_Group_rec.ship_to_org_id
3719 AND customer_item_id = x_Group_rec.customer_item_id
3720 AND inventory_item_id = x_Group_rec.inventory_item_id
3721 AND order_header_id = x_Group_rec.order_header_id
3722 AND NVL(intmed_ship_to_org_id ,K_NNULL) = NVL(x_Group_rec.intmed_ship_to_org_id, K_NNULL) --Bugfix 5911991
3723 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
3724 rlm_core_sv.k_PS_FROZEN_FIRM)
3725 AND (item_detail_type = k_FIRM OR item_detail_type = k_PAST_DUE_FIRM)
3726 ORDER BY request_date;
3727
3728 ELSE
3729
3730 OPEN x_Req_ref FOR
3731 SELECT x_group_rec.customer_id,
3732 header_id,
3733 line_id,
3734 cust_production_line,
3735 customer_dock_code,
3736 request_date,
3737 schedule_date,
3738 cust_po_number,
3739 customer_item_revision,
3740 customer_job,
3741 cust_model_serial_number,
3742 cust_production_seq_num,
3743 industry_attribute1,
3744 industry_attribute2,
3745 industry_attribute3,
3746 industry_attribute4,
3747 industry_attribute5,
3748 industry_attribute6,
3749 industry_attribute7,
3750 industry_attribute8,
3751 industry_attribute9,
3752 industry_attribute10,
3753 industry_attribute11,
3754 industry_attribute12,
3755 industry_attribute13,
3756 industry_attribute14,
3757 industry_attribute15,
3758 industry_context,
3759 attribute1,
3760 attribute2,
3761 attribute3,
3762 attribute4,
3763 attribute5,
3764 attribute6,
3765 attribute7,
3766 attribute8,
3767 attribute9,
3768 attribute10,
3769 attribute11,
3770 attribute12,
3771 attribute13,
3772 attribute14,
3773 attribute15,
3774 attribute_category,
3775 tp_attribute1,
3776 tp_attribute2,
3777 tp_attribute3,
3778 tp_attribute4,
3779 tp_attribute5,
3780 tp_attribute6,
3781 tp_attribute7,
3782 tp_attribute8,
3783 tp_attribute9,
3784 tp_attribute10,
3785 tp_attribute11,
3786 tp_attribute12,
3787 tp_attribute13,
3788 tp_attribute14,
3789 tp_attribute15,
3790 tp_attribute_category,
3791 item_detail_type,
3792 item_detail_subtype,
3793 intrmd_ship_to_id,
3794 ship_to_org_id,
3795 invoice_to_org_id,
3796 primary_quantity,
3797 intmed_ship_to_org_id,
3798 customer_item_id,
3799 inventory_item_id,
3800 order_header_id,
3801 x_ReqType,
3802 ship_from_org_id,
3803 x_Sched_rec.schedule_type,
3804 'CUST' item_identifier_type,
3805 customer_item_ext,
3806 agreement_id,
3807 price_list_id,
3808 x_Sched_rec.schedule_header_id,
3809 schedule_line_id,
3810 process_status,
3811 uom_code,
3812 cust_po_line_num
3813 FROM rlm_interface_lines
3814 WHERE header_id = x_Sched_rec.header_id
3815 AND ship_from_org_id = x_Group_rec.ship_from_org_id
3816 AND industry_attribute15 = x_Group_rec.industry_attribute15
3817 AND ship_to_org_id = x_Group_rec.ship_to_org_id
3818 AND customer_item_id = x_Group_rec.customer_item_id
3819 AND inventory_item_id = x_Group_rec.inventory_item_id
3820 AND NVL(intmed_ship_to_org_id ,K_NNULL) = NVL(x_Group_rec.intmed_ship_to_org_id, K_NNULL) --Bugfix 5911991
3821 AND order_header_id = x_Group_rec.order_header_id
3822 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
3823 rlm_core_sv.k_PS_FROZEN_FIRM)
3824 AND item_detail_type = k_FORECAST
3825 ORDER BY request_date;
3826
3827 END IF;
3828
3829 END IF;
3830 --
3831 IF (l_debug <> -1) THEN
3832 rlm_core_sv.dpop(k_SDEBUG);
3833 END IF;
3834 --
3835 EXCEPTION
3836 WHEN OTHERS THEN
3837 rlm_message_sv.sql_error('rlm_rd_sv.InitializeReq',x_progress);
3838 --
3839 IF (l_debug <> -1) THEN
3840 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3841 END IF;
3842 --
3843 raise e_group_error;
3844
3845 END InitializeReq;
3846
3847
3848 -- NOTE: cancel requirement may be obsolete
3849 /*===========================================================================
3850
3851 PROCEDURE CancelRequirement
3852
3853 ===========================================================================*/
3854 PROCEDURE CancelRequirement(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3855 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
3856 x_Key_rec IN RLM_RD_SV.t_Key_rec,
3857 x_CancelQty IN NUMBER)
3858 IS
3859 x_progress VARCHAR2(3) := '010';
3860
3861 BEGIN
3862 --
3863 IF (l_debug <> -1) THEN
3864 rlm_core_sv.dpush(k_SDEBUG,'CancelRequirement');
3865 rlm_core_sv.dlog(k_DEBUG,'x_CancelQty',x_CancelQty);
3866 END IF;
3867 --
3868 SetOperation(x_Key_rec, k_UPDATE, x_Key_rec.dem_rec.ordered_quantity - x_CancelQty);
3869 --
3870 IF (l_debug <> -1) THEN
3871 rlm_core_sv.dpop(k_SDEBUG);
3872 END IF;
3873 --
3874 EXCEPTION
3875 WHEN OTHERS THEN
3876 rlm_message_sv.sql_error('rlm_rd_sv.CancelRequirement',x_progress);
3877 --
3878 IF (l_debug <> -1) THEN
3879 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
3880 END IF;
3881 --
3882 raise;
3883
3884 END CancelRequirement;
3885
3886
3887 /*===========================================================================
3888
3889 PROCEDURE SynchronizeShipments
3890
3891 ===========================================================================*/
3892 PROCEDURE SynchronizeShipments(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
3893 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
3894 IS
3895 --
3896 v_InTransitQty NUMBER;
3897 --
3898 v_shipper_rec WSH_RLM_INTERFACE.t_shipper_rec;
3899 v_match_rec WSH_RLM_INTERFACE.t_optional_match_rec;
3900 --
3901 v_Key_rec t_Key_rec;
3902 --
3903 v_count NUMBER DEFAULT 0 ;
3904 v_shipment_date DATE;
3905 v_intransit_time NUMBER := 0;
3906 v_item_detail_subtype VARCHAR2(80);
3907 --
3908 x_progress VARCHAR2(3) DEFAULT '010';
3909 v_return_status VARCHAR2(240);
3910 --
3911 v_cumDiscrete NUMBER;
3912 e_cumDiscrete EXCEPTION;
3913 --
3914 v_match_ref t_Cursor_ref;
3915 v_Index NUMBER;
3916 v_intransit_calc_basis VARCHAR2(15);
3917 v_match_across_rule RLM_CORE_SV.t_Match_rec;
3918 v_match_within_rule RLM_CORE_SV.t_Match_rec;
3919 v_header_id NUMBER;
3920 v_Intransit NUMBER := 0;
3921 v_LineID NUMBER;
3922 v_min_horizon_date VARCHAR2(30);
3923 --
3924
3925 BEGIN
3926 --
3927 IF (l_debug <> -1) THEN
3928 rlm_core_sv.dpush(k_SDEBUG,'SynchronizeShipments');
3929 END IF;
3930 --
3931 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
3932 --
3933 --
3934 IF (l_debug <> -1) THEN
3935 rlm_core_sv.dlog(k_DEBUG,'ship_from_org_id', x_Group_rec.ship_from_org_id);
3936 rlm_core_sv.dlog(k_DEBUG, 'inventory_item_id', x_Group_rec.inventory_item_id);
3937 rlm_core_sv.dlog(k_DEBUG, 'ship_to_org_id', x_Group_rec.ship_to_org_id);
3938 rlm_core_sv.dlog(k_DEBUG,'customer_item_id', x_Group_rec.customer_item_id);
3939 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis', v_intransit_calc_basis);
3940 rlm_core_sv.dlog(k_DEBUG, 'Order Header Id', x_Group_rec.order_header_id);
3941 rlm_core_sv.dlog(k_DEBUG, 'Blanket Number', x_Group_rec.blanket_number);
3942 rlm_core_sv.dlog(k_DEBUG, 'g_BlktIntransits', g_BlktIntransits);
3943 rlm_core_sv.dlog(k_DEBUG, 'CUM Org Level',
3944 x_Group_rec.setup_terms_rec.cum_org_level_code);
3945 rlm_core_sv.dlog(k_DEBUG, 'x_Group_rec.isSourced', x_Group_rec.isSourced);
3946 END IF;
3947 --
3948 v_match_across_rule := x_Group_rec.match_across_rec;
3949 v_match_within_rule := x_Group_rec.match_within_rec;
3950 --
3951 IF (v_intransit_calc_basis = k_NONE OR v_intransit_calc_basis is NULL) THEN
3952 --
3953 IF (l_debug <> -1) THEN
3954 rlm_core_sv.dlog(k_DEBUG, 'All shipments assumed to have been received');
3955 rlm_core_sv.dpop(k_SDEBUG, 'Processing rule set to NONE or NULL');
3956 END IF;
3957 --
3958 RETURN;
3959 --
3960 END IF;
3961 --
3962 --
3963 SELECT COUNT(*)
3964 INTO v_cumDiscrete
3965 FROM rlm_interface_lines il,
3966 rlm_schedule_lines_all sl
3967 WHERE il.header_id = x_Sched_rec.header_id
3968 AND il.ship_from_org_id = x_Group_rec.ship_from_org_id
3969 AND il.ship_to_org_id = x_Group_rec.ship_to_org_id
3970 AND il.inventory_item_id = x_Group_rec.inventory_item_id
3971 AND il.customer_item_id = x_Group_rec.customer_item_id
3972 AND NVL(il.item_detail_type, ' ') NOT IN
3973 (rlm_manage_demand_sv.k_SHIP_RECEIPT_INFO,
3974 rlm_manage_demand_sv.k_AUTHORIZATION,
3975 rlm_manage_demand_sv.k_OTHER_DETAIL_TYPE)
3976 AND il.schedule_line_id = sl.line_id
3977 AND sl.qty_type_code = rlm_manage_demand_sv.k_CUMULATIVE
3978 AND il.org_id = sl.org_id;
3979 --
3980 IF (l_debug <> -1) THEN
3981 rlm_core_sv.dlog(k_DEBUG,'v_cumDiscrete', v_cumDiscrete);
3982 END IF;
3983 --
3984 IF v_cumDiscrete > 0 THEN
3985 --
3986 /*
3987 If the interface line has a CUMULATIVE qty_code then this means
3988 that its primary qty has been calculated based on the supplier cum.
3989 There is no need to re-calculate the in transit qty.
3990 See manage demand CumtoDiscrete procedure.
3991 */
3992 RAISE e_cumDiscrete;
3993 --
3994 END IF;
3995 --
3996 -- Customer CUM logic is as follows :
3997 --
3998 -- (a) If blankets are used and g_BlktIntransits = TRUE, it means
3999 -- that intransit quantity has already been calc. across all releases
4000 -- tied to the blanket. If not, proceed further.
4001 -- (b) If the group is sourced and the CUM org level is XXX/All SFs
4002 -- (which is what it should be), calculate intransit quantity
4003 -- ONLY ONCE across the sourced orgs and store it in the variable
4004 -- g_IntransitQty. Then for each sourced group, call
4005 -- SourceCUMIntransitQty to store a percent of g_IntransitQty
4006 -- in g_ReconcileTab. This percentage would come from the sourcing
4007 -- rules applied in Manage Demand.
4008 -- (c) If the group is not sourced, then calculate intransit quantity
4009 -- every time and store the intransit quantity in g_ReconcileTab.
4010 --
4011 IF (v_intransit_calc_basis = 'CUSTOMER_CUM') THEN
4012 --{
4013 IF ((x_Group_rec.blanket_number IS NOT NULL AND NOT g_BlktIntransits) OR
4014 (x_Group_rec.blanket_number IS NULL)) THEN
4015 --
4016 PopulateReconcileCumRec(x_Sched_rec, x_Group_rec); --Bugfix 7007638
4017 --{
4018 IF (x_Group_rec.isSourced AND
4019 x_Group_rec.setup_terms_rec.cum_org_level_code IN
4020 ('SHIP_TO_ALL_SHIP_FROMS', 'BILL_TO_ALL_SHIP_FROMS',
4021 'DELIVER_TO_ALL_SHIP_FROMS')) THEN
4022 --{
4023 IF g_RecCUM_tab.COUNT > 0 THEN
4024
4025 FOR v_Count IN 1..g_RecCUM_tab.COUNT LOOP --Bugfix 7007638
4026 --
4027 IF (g_IntransitQty = FND_API.G_MISS_NUM) THEN
4028 CalculateCUMIntransit(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count).line_id, g_IntransitQty);
4029 END IF;
4030 --
4031 IF (l_debug <> -1) THEN
4032 rlm_core_sv.dlog(k_DEBUG, 'Intransit Qty', g_IntransitQty);
4033 END IF;
4034 --
4035 IF g_IntransitQty > 0 THEN
4036 SourceCUMIntransitQty(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count));
4037 END IF;
4038 --
4039 g_IntransitQty := FND_API.G_MISS_NUM; --Bugfix 7007638
4040 --
4041 END LOOP; --Bugfix 7007638
4042
4043 END IF; --if count
4044 --}
4045 ELSE --if cum_org_level_code SHIP_TO_SHIP_FROM
4046 --{
4047 IF g_RecCUM_tab.COUNT > 0 THEN
4048 --
4049 FOR v_Count IN 1..g_RecCUM_tab.COUNT LOOP --Bugfix 7007638
4050 --
4051 CalculateCUMIntransit(x_Sched_rec, x_Group_rec, g_RecCUM_tab(v_Count).line_id, v_Intransit);
4052 --
4053 IF (l_debug <> -1) THEN
4054 rlm_core_sv.dlog(k_DEBUG, 'Intransit Qty', v_Intransit);
4055 END IF;
4056 --
4057 IF v_Intransit > 0 THEN
4058 --
4059 v_Key_rec.rlm_line_id := null;
4060 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
4061 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
4062 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
4063 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
4064 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
4065 v_Key_rec.req_rec.ship_from_org_id := x_Group_rec.ship_from_org_id;
4066 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
4067 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
4068 --
4069 -- Bugfix 7007638 Start
4070 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
4071 v_Key_rec.req_rec.cust_po_number := g_RecCUM_tab(v_Count).purchase_order_number;
4072 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
4073 v_Key_rec.req_rec.industry_attribute1 := g_RecCUM_tab(v_Count).cust_record_year;
4074 END IF;
4075 -- Bugfix 7007638 End
4076
4077 RLM_RD_SV.StoreShipments(x_Sched_rec, x_Group_rec,
4078 v_Key_rec, v_Intransit);
4079 --
4080 END IF;
4081 --
4082 g_IntransitQty := FND_API.G_MISS_NUM; --Bugfix 7007638
4083 --
4084 END LOOP; --Bugfix 7007638
4085
4086 END IF; --if count
4087 --}
4088 END IF; -- cum_org_level_code
4089 --
4090 IF (l_debug <> -1) THEN
4091 rlm_core_sv.dpop(k_SDEBUG);
4092 END IF;
4093 --
4094 IF (x_Group_rec.blanket_number IS NOT NULL AND NOT g_BlktIntransits) THEN
4095 g_BlktIntransits := TRUE;
4096 END IF;
4097 --
4098 RETURN;
4099 --}
4100 END IF; -- blanket_number
4101 --}
4102 ELSIF v_intransit_calc_basis IN (k_RECEIPT, k_SHIPMENT) THEN
4103 --{
4104 InitializeIntransitParam(x_Sched_rec, x_Group_rec,
4105 v_intransit_calc_basis, v_Shipper_rec,
4106 v_Shipment_date);
4107 --
4108 InitializeMatchRec(x_Sched_rec, x_Group_rec, v_match_ref);
4109 --
4110 IF (l_debug <> -1) THEN
4111 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.schedule_type', x_Sched_rec.schedule_type);
4112 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.sched_generation_date', x_Sched_rec.sched_generation_date);
4113 END IF;
4114 --
4115 WHILE FetchMatchRec(v_match_ref, v_match_rec) LOOP
4116 --
4117 PrintMatchRec(v_match_rec);
4118 --
4119 IF NOT AlreadyMatched(x_Group_rec, v_match_rec, v_Index) Then
4120 --
4121 RLM_EXTINTERFACE_SV.getIntransitQty (
4122 x_Group_rec.customer_id,
4123 x_Group_rec.ship_to_org_id,
4124 x_Group_rec.intmed_ship_to_org_id, --Bugfix 5911991
4125 x_Group_rec.ship_from_org_id,
4126 x_Group_rec.inventory_item_id,
4127 x_Group_rec.customer_item_id,
4128 x_Group_rec.order_header_id,
4129 NVL(x_Group_rec.blanket_number, k_NNULL),
4130 x_Sched_rec.org_id,
4131 x_Sched_rec.schedule_type,
4132 v_Shipper_rec,
4133 v_Shipment_date,
4134 v_match_within_rule,
4135 v_match_across_rule,
4136 v_match_rec,
4137 x_Sched_rec.header_id,
4138 v_InTransitQty,
4139 v_return_status);
4140
4141 --
4142 IF (l_debug <> -1) THEN
4143 rlm_core_sv.dlog(k_DEBUG, 'v_return_status', v_return_status);
4144 rlm_core_sv.dlog(k_DEBUG, 'v_InTransitQty', v_InTransitQty);
4145 END IF;
4146 --
4147 IF v_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
4148 --
4149 IF (l_debug <> -1) THEN
4150 rlm_core_sv.dpop(k_SDEBUG, 'GetIntransitQtyAPI Failed');
4151 END IF;
4152 --
4153 RAISE e_group_error;
4154 --
4155 ELSIF v_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
4156 --
4157 IF (l_debug <> -1) THEN
4158 rlm_core_sv.dpop(k_SDEBUG, 'GetIntransitQtyAPI Failed');
4159 END IF;
4160 --
4161 RAISE e_group_error;
4162 --
4163 END IF;
4164
4165 --
4166 -- to do JH : The line id os from schedule lines and not interface lines
4167 -- what implications of keeping this line id and also or line id as null?
4168 --
4169
4170 IF v_InTransitQty > 0 THEN
4171 --
4172 v_Key_rec.rlm_line_id := null;
4173 --
4174 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
4175 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
4176 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
4177 --v_Key_rec.req_rec.bill_to_address_id := x_Group_rec.bill_to_address_id;
4178 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
4179 --v_Key_rec.req_rec.intrmd_ship_to_id := x_Group_rec.intrmd_ship_to_id;
4180 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
4181 v_Key_rec.req_rec.ship_from_org_id := x_Group_rec.ship_from_org_id;
4182 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
4183 v_Key_rec.req_rec.cust_production_line := v_match_rec.cust_production_line;
4184 v_Key_rec.req_rec.customer_dock_code := v_match_rec.customer_dock_code;
4185 v_Key_rec.req_rec.cust_po_number := v_match_rec.cust_po_number;
4186 v_Key_rec.req_rec.customer_item_revision := v_match_rec.customer_item_revision;
4187 v_Key_rec.req_rec.customer_job := v_match_rec.customer_job;
4188 v_Key_rec.req_rec.cust_model_serial_number := v_match_rec.cust_model_serial_number;
4189 v_Key_rec.req_rec.cust_production_seq_num := v_match_rec.cust_production_seq_num;
4190 v_Key_rec.req_rec.industry_attribute1 := v_match_rec.industry_attribute1;
4191 v_Key_rec.req_rec.industry_attribute2 := v_match_rec.industry_attribute2;
4192 v_Key_rec.req_rec.industry_attribute3 := v_match_rec.industry_attribute3;
4193 v_Key_rec.req_rec.industry_attribute4 := v_match_rec.industry_attribute4;
4194 v_Key_rec.req_rec.industry_attribute5 := v_match_rec.industry_attribute5;
4195 v_Key_rec.req_rec.industry_attribute6 := v_match_rec.industry_attribute6;
4196 v_Key_rec.req_rec.industry_attribute7 := v_match_rec.industry_attribute7;
4197 v_Key_rec.req_rec.industry_attribute8 := v_match_rec.industry_attribute8;
4198 v_Key_rec.req_rec.industry_attribute9 := v_match_rec.industry_attribute9;
4199 v_Key_rec.req_rec.industry_attribute10 := v_match_rec.industry_attribute10;
4200 v_Key_rec.req_rec.industry_attribute11 := v_match_rec.industry_attribute11;
4201 v_Key_rec.req_rec.industry_attribute12 := v_match_rec.industry_attribute12;
4202 v_Key_rec.req_rec.industry_attribute13 := v_match_rec.industry_attribute13;
4203 v_Key_rec.req_rec.industry_attribute14 := v_match_rec.industry_attribute14;
4204 v_Key_rec.req_rec.industry_attribute15 := v_match_rec.industry_attribute15;
4205 v_Key_rec.req_rec.attribute1 := v_match_rec.attribute1;
4206 v_Key_rec.req_rec.attribute2 := v_match_rec.attribute2;
4207 v_Key_rec.req_rec.attribute3 := v_match_rec.attribute3;
4208 v_Key_rec.req_rec.attribute4 := v_match_rec.attribute4;
4209 v_Key_rec.req_rec.attribute5 := v_match_rec.attribute5;
4210 v_Key_rec.req_rec.attribute6 := v_match_rec.attribute6;
4211 v_Key_rec.req_rec.attribute7 := v_match_rec.attribute7;
4212 v_Key_rec.req_rec.attribute8 := v_match_rec.attribute8;
4213 v_Key_rec.req_rec.attribute9 := v_match_rec.attribute9;
4214 v_Key_rec.req_rec.attribute10 := v_match_rec.attribute10;
4215 v_Key_rec.req_rec.attribute11 := v_match_rec.attribute11;
4216 v_Key_rec.req_rec.attribute12 := v_match_rec.attribute12;
4217 v_Key_rec.req_rec.attribute13 := v_match_rec.attribute13;
4218 v_Key_rec.req_rec.attribute14 := v_match_rec.attribute14;
4219 v_Key_rec.req_rec.attribute15 := v_match_rec.attribute15;
4220 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
4221 v_Key_rec.req_rec.blanket_number := x_Group_rec.blanket_number;
4222 --
4223 StoreShipments(x_Sched_rec, x_Group_rec, v_Key_rec, v_IntransitQty);
4224 --
4225 END IF; /* if intransit_qty > 0 */
4226 --
4227 InsertIntransitMatchRec(v_match_rec, v_IntransitQty);
4228 --
4229 END IF; /* if not alreadymatched */
4230 --
4231 END LOOP; /* while fetchmatchrec */
4232 --}
4233 END IF; /*Intransit Basis*/
4234 --
4235 IF (l_debug <> -1) THEN
4236 rlm_core_sv.dpop(k_SDEBUG);
4237 END IF;
4238 --
4239 EXCEPTION
4240 --
4241 WHEN e_cumDiscrete THEN
4242 --
4243 IF (l_debug <> -1) THEN
4244 rlm_core_sv.dlog(k_DEBUG,'Intransit Calculations not needed as more than one CUM lines exist');
4245 rlm_core_sv.dpop(k_SDEBUG,'e_cumDiscrete');
4246 END IF;
4247 --
4248 WHEN OTHERS THEN
4249 rlm_message_sv.sql_error('rlm_rd_sv.SynchronizeShipments',x_progress);
4250 --
4251 IF (l_debug <> -1) THEN
4252 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4253 END IF;
4254 --
4255 raise;
4256
4257 END SynchronizeShipments;
4258
4259
4260 /*===========================================================================
4261
4262 FUNCTION MatchWithin
4263
4264 ===========================================================================*/
4265 FUNCTION MatchWithin(x_WithinString IN VARCHAR2,
4266 x_ColumnName IN VARCHAR2)
4267 RETURN VARCHAR2
4268 IS
4269
4270 x_progress VARCHAR2(3) := '010';
4271
4272 BEGIN
4273 --
4274 IF (l_debug <> -1) THEN
4275 rlm_core_sv.dpush(k_SDEBUG,'MatchWithin');
4276 rlm_core_sv.dpop(k_SDEBUG);
4277 END IF;
4278 --
4279 RETURN('Y');
4280
4281 EXCEPTION
4282 WHEN OTHERS THEN
4283 rlm_message_sv.sql_error('rlm_rd_sv.MatchWithin',x_progress);
4284 --
4285 IF (l_debug <> -1) THEN
4286 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4287 END IF;
4288 --
4289 raise;
4290
4291 END MatchWithin;
4292
4293
4294 /*===========================================================================
4295
4296 FUNCTION MatchAcross
4297
4298 ===========================================================================*/
4299 FUNCTION MatchAcross(x_AcrossString IN VARCHAR2,
4300 x_ColumnName IN VARCHAR2)
4301 RETURN VARCHAR2
4302 IS
4303 x_progress VARCHAR2(3) := '010';
4304
4305 BEGIN
4306 --
4307 IF (l_debug <> -1) THEN
4308 rlm_core_sv.dpush(k_SDEBUG,'MatchAcross');
4309 rlm_core_sv.dpop(k_SDEBUG);
4310 END IF;
4311 --
4312 RETURN('Y');
4313
4314 EXCEPTION
4315 WHEN OTHERS THEN
4316 rlm_message_sv.sql_error('rlm_rd_sv.MatchAcross',x_progress);
4317 --
4318 IF (l_debug <> -1) THEN
4319 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4320 END IF;
4321 --
4322 raise;
4323
4324 END MatchAcross;
4325
4326
4327 /*===========================================================================
4328
4329 PROCEDURE StoreShipments
4330
4331 ===========================================================================*/
4332 PROCEDURE StoreShipments(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
4333 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4334 x_Key_rec IN RLM_RD_SV.t_Key_rec,
4335 x_Quantity IN NUMBER)
4336 IS
4337
4338 v_Index NUMBER;
4339 x_progress VARCHAR2(3) := '010';
4340
4341 BEGIN
4342 --
4343 IF (l_debug <> -1) THEN
4344 rlm_core_sv.dpush(k_SDEBUG,'StoreShipments');
4345 END IF;
4346 --
4347 -- start of bug fix 4223359
4348 --
4349 IF x_Quantity > 0 THEN
4350 --
4351 IF RLM_TPA_SV.MatchShipments(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4352 --
4353 IF (l_debug <> -1) THEN
4354 rlm_core_sv.dlog(k_DEBUG,'v_index',v_Index);
4355 END IF;
4356 --
4357 g_Reconcile_tab(v_Index).ordered_quantity :=
4358 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + NVL(x_Quantity,0);
4359 --
4360 ELSE
4361 --
4362 IF g_Reconcile_tab.First is NULL THEN
4363 --
4364 g_Reconcile_tab(1) := x_Key_rec.req_rec;
4365 g_Reconcile_tab(1).ordered_quantity := NVL(x_Quantity, 0);
4366 --
4367 ELSE
4368 --
4369 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.req_rec;
4370 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := NVL(x_Quantity,0);
4371 --
4372 END IF;
4373 --
4374 IF (l_debug <> -1) THEN
4375 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4376 rlm_core_sv.dlog(k_DEBUG,'Added to reconcile table x_index',g_Reconcile_tab.LAST);
4377 END IF;
4378 --
4379 END IF;
4380 --
4381 ELSE
4382 --
4383 IF MatchReconcile(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4384 --
4385 g_Reconcile_tab(v_Index).ordered_quantity :=
4386 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + NVL(x_Quantity,0);
4387 --
4388 IF (l_debug <> -1) THEN
4389 rlm_core_sv.dlog(k_DEBUG,'v_index',v_Index);
4390 rlm_core_sv.dlog(k_DEBUG,'g_reconcile_tab.ordered_quantity',g_Reconcile_tab(v_Index).ordered_quantity);
4391 END IF;
4392 --
4393 ELSE
4394 --
4395 IF g_Reconcile_tab.First is NULL THEN
4396 --
4397 g_Reconcile_tab(1) := x_Key_rec.req_rec;
4398 g_Reconcile_tab(1).ordered_quantity := NVL(x_Quantity, 0);
4399 --
4400 ELSE
4401 --
4402 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.req_rec;
4403 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := NVL(x_Quantity,0);
4404 --
4405 END IF;
4406 --
4407 IF (l_debug <> -1) THEN
4408 rlm_core_sv.dlog(k_DEBUG,'New Line x_quantity',x_quantity);
4409 rlm_core_sv.dlog(k_DEBUG,'Added to reconcile table x_index',g_Reconcile_tab.LAST);
4410 END IF;
4411 --
4412 END IF;
4413 --
4414 END IF;
4415 --
4416 -- end of bug fix 4223359
4417 --
4418 IF (l_debug <> -1) THEN
4419 rlm_core_sv.dpop(k_SDEBUG);
4420 END IF;
4421 --
4422 EXCEPTION
4423 WHEN OTHERS THEN
4424 rlm_message_sv.sql_error('rlm_rd_sv.StoreShipments',x_progress);
4425 --
4426 IF (l_debug <> -1) THEN
4427 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4428 END IF;
4429 --
4430 raise;
4431
4432 END StoreShipments;
4433
4434
4435 /*===========================================================================
4436
4437 PROCEDURE ReconcileShipments
4438
4439 ===========================================================================*/
4440 PROCEDURE ReconcileShipments(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4441 x_Key_rec IN RLM_RD_SV.t_Key_rec,
4442 x_Quantity IN OUT NOCOPY NUMBER)
4443 IS
4444
4445 v_Index NUMBER;
4446 x_progress VARCHAR2(3) := '010';
4447
4448 BEGIN
4449 --
4450 IF (l_debug <> -1) THEN
4451 rlm_core_sv.dpush(k_SDEBUG,'ReconcileShipments');
4452 END IF;
4453 --
4454 IF RLM_TPA_SV.MatchShipments(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
4455 --
4456 IF (l_debug <> -1) THEN
4457 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4458 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab(v_Index).ordered_quantity',
4459 g_Reconcile_tab(v_Index).ordered_quantity);
4460 END IF;
4461 --
4462 -- start of bug fix 4223359
4463 --
4464 IF nvl(g_Reconcile_tab(v_Index).ordered_quantity,0) > NVL(x_Quantity,0)
4465 THEN
4466 --
4467 g_Reconcile_tab(v_Index).ordered_quantity :=
4468 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0)
4469 - NVL(x_Quantity,0);
4470 IF (l_debug <> -1) THEN
4471 rlm_core_sv.dlog(k_DEBUG,'new g_Reconcile_tab(v_Index).ordered_quantity',
4472 g_Reconcile_tab(v_Index).ordered_quantity);
4473 END IF;
4474 --
4475 x_Quantity := 0;
4476 --
4477 ELSE
4478 --
4479 x_Quantity := NVL(x_Quantity,0)
4480 - nvl(g_Reconcile_tab(v_Index).ordered_quantity,0);
4481 --
4482 IF (l_debug <> -1) THEN
4483 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
4484 rlm_core_sv.dlog(k_DEBUG,'Entry getting deleted from Reconcile Table', v_Index);
4485 rlm_core_sv.dlog(k_DEBUG,'deleted g_Reconcile_tab(v_Index).ordered_quantity',
4486 g_Reconcile_tab(v_Index).ordered_quantity);
4487
4488 END IF;
4489 --
4490 g_Reconcile_tab.DELETE(v_Index);
4491 --
4492 END IF;
4493 --
4494 END IF;
4495 --
4496 -- end of bug fix 4223359
4497 --
4498 IF (l_debug <> -1) THEN
4499 rlm_core_sv.dpop(k_SDEBUG);
4500 END IF;
4501 --
4502 EXCEPTION
4503 WHEN OTHERS THEN
4504 rlm_message_sv.sql_error('rlm_rd_sv.ReconcileShipments',x_progress);
4505 --
4506 IF (l_debug <> -1) THEN
4507 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4508 END IF;
4509 --
4510 raise;
4511
4512 END ReconcileShipments;
4513
4514 /*===========================================================================
4515
4516 FUNCTION MatchShipments
4517
4518 ===========================================================================*/
4519 FUNCTION MatchShipments(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4520 x_Current_rec IN RLM_RD_SV.t_Generic_rec,
4521 x_Index OUT NOCOPY NUMBER)
4522 RETURN BOOLEAN
4523 IS
4524 x_progress VARCHAR2(3) := '010';
4525
4526 v_Index NUMBER;
4527 v_Count NUMBER;
4528 b_Match BOOLEAN := FALSE;
4529 v_intransit_calc_basis VARCHAR2(15);
4530
4531 BEGIN
4532 --
4533 IF (l_debug <> -1) THEN
4534 rlm_core_sv.dpush(k_SDEBUG,'MatchShipments');
4535 END IF;
4536 --
4537 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
4538 --
4539 IF (l_debug <> -1) THEN
4540 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
4541 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
4542 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
4543 END IF;
4544 --
4545 -- Bug 2261743
4546 --
4547 IF g_Reconcile_tab.COUNT <> 0 THEN
4548 --
4549 -- 4223359 Changed the for loop to while as the entries in the PL/SQL table could be non-contiguous
4550 --
4551 v_Count := g_Reconcile_tab.FIRST;
4552 --
4553 WHILE v_Count is NOT NULL LOOP
4554 --
4555 IF nvl(g_Reconcile_tab(v_Count).shipment_flag,k_VNULL) = 'SHIPMENT' THEN
4556 --
4557 IF( v_intransit_calc_basis = 'CUSTOMER_CUM') THEN
4558 --
4559 IF Match_PO_RY_Reconcile(x_Group_rec, x_Current_rec, v_Index) THEN --Bugfix 7007638
4560 b_Match := TRUE;
4561 x_Index := v_Index; --Bugfix 7007638
4562 EXIT;
4563 END IF;
4564 --
4565 ELSE
4566 --
4567 IF MatchReconcile(x_Group_rec, x_Current_rec, v_Index) THEN
4568 b_Match := TRUE;
4569 x_Index := v_Index;
4570 EXIT;
4571 END IF;
4572 --
4573 END IF;
4574 --
4575 END IF;
4576 --
4577 v_Count := g_Reconcile_tab.next(v_Count);
4578 --
4579 END LOOP;
4580 --
4581 END IF;
4582 --
4583 IF (l_debug <> -1) THEN
4584 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
4585 rlm_core_sv.dlog(k_DEBUG, 'Returning index', x_Index);
4586 rlm_core_sv.dpop(k_SDEBUG);
4587 END IF;
4588 --
4589 RETURN(b_Match);
4590
4591 EXCEPTION
4592 WHEN OTHERS THEN
4593 rlm_message_sv.sql_error('rlm_rd_sv.MatchShipments',x_progress);
4594 --
4595 IF (l_debug <> -1) THEN
4596 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
4597 END IF;
4598 --
4599 raise;
4600
4601 END MatchShipments;
4602
4603 /*===========================================================================
4604
4605 FUNCTION Matchfrozen
4606
4607 Description: Added this function for bug 4223359
4608 this is required to find duplicate records in the g_reconcile_tab to
4609 print the aggregate frozenQty message
4610
4611 ===========================================================================*/
4612 FUNCTION MatchFrozen(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
4613 x_Index2 IN NUMBER,
4614 x_Current_rec IN t_Generic_rec,
4615 x_Index OUT NOCOPY NUMBER)
4616 RETURN BOOLEAN
4617 IS
4618 x_progress VARCHAR2(3) := '010';
4619 v_Index NUMBER;
4620 v_Count NUMBER;
4621 b_Match BOOLEAN := FALSE;
4622
4623 BEGIN
4624 --
4625 IF (l_debug <> -1) THEN
4626 rlm_core_sv.dpush(k_SDEBUG,'MatchFrozen');
4627 END IF;
4628 --
4629 IF (l_debug <> -1) THEN
4630 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
4631 rlm_core_sv.dlog(k_DEBUG,'x_index2', x_Index2);
4632 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
4633 rlm_core_sv.dlog(k_DEBUG,'x_current_rec.schedule_type', x_Current_rec.schedule_type);
4634 END IF;
4635 --
4636 IF g_Reconcile_tab.COUNT <> 0 THEN
4637 --
4638 v_Count := x_Index2;
4639 --
4640 WHILE v_Count IS NOT NULL LOOP
4641 --{
4642 b_Match := TRUE;
4643 --
4644 IF (l_debug <> -1) THEN
4645 rlm_core_sv.dlog(k_DEBUG,'schedule_type', g_Reconcile_tab(v_Count).schedule_type);
4646 END IF;
4647 --
4648 IF x_Current_rec.schedule_type = g_Reconcile_tab(v_Count).schedule_type THEN
4649 --{
4650 IF (l_debug <> -1) THEN
4651 rlm_core_sv.dlog(k_DEBUG,'Match Within Schedules only ');
4652 END IF;
4653 --
4654 IF x_Group_rec.match_within_rec.cust_po_number = 'Y' THEN
4655 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
4656 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
4657 b_Match := FALSE;
4658 END IF;
4659 END IF;
4660 --
4661 IF (l_debug <> -1) THEN
4662 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
4663 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
4664 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4665 END IF;
4666 --
4667 IF b_Match THEN
4668 IF x_Group_rec.match_within_rec.customer_item_revision = 'Y' THEN
4669 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
4670 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
4671 b_Match := FALSE;
4672 END IF;
4673 END IF;
4674 END IF;
4675 --
4676 IF (l_debug <> -1) THEN
4677 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
4678 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
4679 g_Reconcile_tab(v_Count).customer_item_revision);
4680 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4681 END IF;
4682 --
4683 IF b_Match THEN
4684 IF x_Group_rec.match_within_rec.customer_dock_code = 'Y' THEN
4685 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
4686 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
4687 b_Match := FALSE;
4688 END IF;
4689 END IF;
4690 END IF;
4691 --
4692 IF (l_debug <> -1) THEN
4693 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
4694 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
4695 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4696 END IF;
4697 --
4698 IF b_Match THEN
4699 IF x_Group_rec.match_within_rec.customer_job = 'Y' THEN
4700 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
4701 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
4702 b_Match := FALSE;
4703 END IF;
4704 END IF;
4705 END IF;
4706 --
4707 IF (l_debug <> -1) THEN
4708 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
4709 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
4710 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4711 END IF;
4712 --
4713 IF b_Match THEN
4714 IF x_Group_rec.match_within_rec.cust_production_line = 'Y' THEN
4715 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
4716 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
4717 b_Match := FALSE;
4718 END IF;
4719 END IF;
4720 END IF;
4721 --
4722 IF (l_debug <> -1) THEN
4723 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
4724 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
4725 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4726 END IF;
4727 --
4728 IF b_Match THEN
4729 IF x_Group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
4730 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
4731 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
4732 b_Match := FALSE;
4733 END IF;
4734 END IF;
4735 END IF;
4736 --
4737 IF (l_debug <> -1) THEN
4738 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
4739 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
4740 g_Reconcile_tab(v_Count).cust_model_serial_number);
4741 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4742 END IF;
4743 --
4744 IF b_Match THEN
4745 IF x_Group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
4746 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
4747 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
4748 b_Match := FALSE;
4749 END IF;
4750 END IF;
4751 END IF;
4752 --
4753 IF (l_debug <> -1) THEN
4754 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
4755 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
4756 g_Reconcile_tab(v_Count).cust_production_seq_num);
4757 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4758 END IF;
4759 --
4760 IF b_Match THEN
4761 IF x_Group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
4762 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
4763 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
4764 b_Match := FALSE;
4765 END IF;
4766 END IF;
4767 END IF;
4768 --
4769 IF (l_debug <> -1) THEN
4770 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
4771 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
4772 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4773 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
4774 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_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.industry_attribute4 = 'Y' THEN
4780 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
4781 NVL(g_Reconcile_tab(v_Count).industry_attribute4, 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, 'industry_attribute4', x_Current_rec.industry_attribute4);
4789 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
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.industry_attribute5 = 'Y' THEN
4795 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
4796 NVL(g_Reconcile_tab(v_Count).industry_attribute5, 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, 'industry_attribute5', x_Current_rec.industry_attribute5);
4804 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
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.industry_attribute6 = 'Y' THEN
4810 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
4811 NVL(g_Reconcile_tab(v_Count).industry_attribute6, 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, 'industry_attribute6', x_Current_rec.industry_attribute6);
4819 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
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.industry_attribute10 = 'Y' THEN
4825 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
4826 NVL(g_Reconcile_tab(v_Count).industry_attribute10, 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, 'industry_attribute10', x_Current_rec.industry_attribute10);
4834 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
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.industry_attribute11 = 'Y' THEN
4840 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
4841 NVL(g_Reconcile_tab(v_Count).industry_attribute11, 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, 'industry_attribute11', x_Current_rec.industry_attribute11);
4849 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
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.industry_attribute12 = 'Y' THEN
4855 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
4856 NVL(g_Reconcile_tab(v_Count).industry_attribute12, 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, 'industry_attribute12', x_Current_rec.industry_attribute12);
4864 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
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.industry_attribute13 = 'Y' THEN
4870 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
4871 NVL(g_Reconcile_tab(v_Count).industry_attribute13, 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, 'industry_attribute13', x_Current_rec.industry_attribute13);
4879 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
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.industry_attribute14 = 'Y' THEN
4885 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
4886 NVL(g_Reconcile_tab(v_Count).industry_attribute14, 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, 'industry_attribute14', x_Current_rec.industry_attribute14);
4894 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
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.industry_attribute15 = 'Y' THEN
4900 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
4901 NVL(g_Reconcile_tab(v_Count).industry_attribute15, 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, 'industry_attribute15', x_Current_rec.industry_attribute15);
4909 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
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.attribute1 = 'Y' THEN
4915 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
4916 NVL(g_Reconcile_tab(v_Count).attribute1, 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, 'attribute1', x_Current_rec.attribute1);
4924 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
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.attribute2 = 'Y' THEN
4930 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
4931 NVL(g_Reconcile_tab(v_Count).attribute2, 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, 'uattribute2', x_Current_rec.attribute2);
4939 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
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.attribute3 = 'Y' THEN
4945 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
4946 NVL(g_Reconcile_tab(v_Count).attribute3, 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, 'attribute3', x_Current_rec.attribute3);
4954 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
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.attribute4 = 'Y' THEN
4960 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
4961 NVL(g_Reconcile_tab(v_Count).attribute4, 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, 'attribute4', x_Current_rec.attribute4);
4969 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
4970 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4971 END IF;
4972 --
4973 IF b_Match THEN
4974 IF x_Group_rec.match_within_rec.attribute5 = 'Y' THEN
4975 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
4976 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
4977 b_Match := FALSE;
4978 END IF;
4979 END IF;
4980 END IF;
4981 --
4982 IF (l_debug <> -1) THEN
4983 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
4984 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
4985 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
4986 END IF;
4987 --
4988 IF b_Match THEN
4989 IF x_Group_rec.match_within_rec.attribute6 = 'Y' THEN
4990 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
4991 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
4992 b_Match := FALSE;
4993 END IF;
4994 END IF;
4995 END IF;
4996 --
4997 IF (l_debug <> -1) THEN
4998 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
4999 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
5000 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5001 END IF;
5002 --
5003 IF b_Match THEN
5004 IF x_Group_rec.match_within_rec.attribute7 = 'Y' THEN
5005 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
5006 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
5007 b_Match := FALSE;
5008 END IF;
5009 END IF;
5010 END IF;
5011 --
5012 IF (l_debug <> -1) THEN
5013 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
5014 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
5015 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5016 END IF;
5017 --
5018 IF b_Match THEN
5019 IF x_Group_rec.match_within_rec.attribute8 = 'Y' THEN
5020 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
5021 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
5022 b_Match := FALSE;
5023 END IF;
5024 END IF;
5025 END IF;
5026 --
5027 IF (l_debug <> -1) THEN
5028 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
5029 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
5030 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5031 END IF;
5032 --
5033 IF b_Match THEN
5034 IF x_Group_rec.match_within_rec.attribute9 = 'Y' THEN
5035 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
5036 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
5037 b_Match := FALSE;
5038 END IF;
5039 END IF;
5040 END IF;
5041 --
5042 IF (l_debug <> -1) THEN
5043 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
5044 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
5045 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5046 END IF;
5047 --
5048 IF b_Match THEN
5049 IF x_Group_rec.match_within_rec.attribute10 = 'Y' THEN
5050 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
5051 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
5052 b_Match := FALSE;
5053 END IF;
5054 END IF;
5055 END IF;
5056 --
5057 IF (l_debug <> -1) THEN
5058 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
5059 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
5060 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5061 END IF;
5062 --
5063 IF b_Match THEN
5064 IF x_Group_rec.match_within_rec.attribute11 = 'Y' THEN
5065 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
5066 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
5067 b_Match := FALSE;
5068 END IF;
5069 END IF;
5070 END IF;
5071 --
5072 IF (l_debug <> -1) THEN
5073 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
5074 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
5075 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5076 END IF;
5077 --
5078 IF b_Match THEN
5079 IF x_Group_rec.match_within_rec.attribute12 = 'Y' THEN
5080 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
5081 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
5082 b_Match := FALSE;
5083 END IF;
5084 END IF;
5085 END IF;
5086 --
5087 IF (l_debug <> -1) THEN
5088 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
5089 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
5090 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5091 END IF;
5092 --
5093 IF b_Match THEN
5094 IF x_Group_rec.match_within_rec.attribute13 = 'Y' THEN
5095 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
5096 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
5097 b_Match := FALSE;
5098 END IF;
5099 END IF;
5100 END IF;
5101 --
5102 IF (l_debug <> -1) THEN
5103 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
5104 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
5105 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5106 END IF;
5107 --
5108 IF b_Match THEN
5109 IF x_Group_rec.match_within_rec.attribute14 = 'Y' THEN
5110 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
5111 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
5112 b_Match := FALSE;
5113 END IF;
5114 END IF;
5115 END IF;
5116 --
5117 IF (l_debug <> -1) THEN
5118 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
5119 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
5120 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5121 END IF;
5122 --
5123 IF b_Match THEN
5124 IF x_Group_rec.match_within_rec.attribute15 = 'Y' THEN
5125 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
5126 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
5127 b_Match := FALSE;
5128 END IF;
5129 END IF;
5130 END IF;
5131 --
5132 IF (l_debug <> -1) THEN
5133 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
5134 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
5135 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5136 END IF;
5137 --
5138 --
5139 --}
5140 ELSIF x_Current_rec.schedule_type <> g_Reconcile_tab(v_Count).schedule_type THEN
5141 --
5142 --
5143 --{
5144 IF (l_debug <> -1) THEN
5145 rlm_core_sv.dlog(k_DEBUG,'Match across Schedules only ');
5146 END IF;
5147 --
5148 IF x_Group_rec.match_across_rec.cust_po_number = 'Y' THEN
5149 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
5150 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
5151 b_Match := FALSE;
5152 END IF;
5153 END IF;
5154 --
5155 IF (l_debug <> -1) THEN
5156 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
5157 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
5158 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5159 END IF;
5160 --
5161 IF b_Match THEN
5162 IF x_Group_rec.match_across_rec.customer_item_revision = 'Y' THEN
5163 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
5164 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
5165 b_Match := FALSE;
5166 END IF;
5167 END IF;
5168 END IF;
5169 --
5170 IF (l_debug <> -1) THEN
5171 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
5172 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
5173 g_Reconcile_tab(v_Count).customer_item_revision);
5174 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5175 END IF;
5176 --
5177 IF b_Match THEN
5178 IF x_Group_rec.match_across_rec.customer_dock_code = 'Y' THEN
5179 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
5180 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
5181 b_Match := FALSE;
5182 END IF;
5183 END IF;
5184 END IF;
5185 --
5186 IF (l_debug <> -1) THEN
5187 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
5188 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
5189 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5190 END IF;
5191 --
5192 IF b_Match THEN
5193 IF x_Group_rec.match_across_rec.customer_job = 'Y' THEN
5194 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
5195 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
5196 b_Match := FALSE;
5197 END IF;
5198 END IF;
5199 END IF;
5200 --
5201 IF (l_debug <> -1) THEN
5202 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
5203 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
5204 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5205 END IF;
5206 --
5207 IF b_Match THEN
5208 IF x_Group_rec.match_across_rec.cust_production_line = 'Y' THEN
5209 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
5210 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
5211 b_Match := FALSE;
5212 END IF;
5213 END IF;
5214 END IF;
5215 --
5216 IF (l_debug <> -1) THEN
5217 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
5218 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
5219 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5220 END IF;
5221 --
5222 IF b_Match THEN
5223 IF x_Group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
5224 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
5225 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
5226 b_Match := FALSE;
5227 END IF;
5228 END IF;
5229 END IF;
5230 --
5231 IF (l_debug <> -1) THEN
5232 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
5233 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
5234 g_Reconcile_tab(v_Count).cust_model_serial_number);
5235 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5236 END IF;
5237 --
5238 IF b_Match THEN
5239 IF x_Group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
5240 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
5241 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
5242 b_Match := FALSE;
5243 END IF;
5244 END IF;
5245 END IF;
5246 --
5247 IF (l_debug <> -1) THEN
5248 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
5249 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
5250 g_Reconcile_tab(v_Count).cust_production_seq_num);
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.industry_attribute1 = 'Y' THEN
5256 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
5257 NVL(g_Reconcile_tab(v_Count).industry_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, 'industry_attribute1', x_Current_rec.industry_attribute1);
5265 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_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.industry_attribute2 = 'Y' THEN
5271 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
5272 NVL(g_Reconcile_tab(v_Count).industry_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, 'industry_attribute2', x_Current_rec.industry_attribute2);
5280 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_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.industry_attribute4 = 'Y' THEN
5286 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
5287 NVL(g_Reconcile_tab(v_Count).industry_attribute4, 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, 'industry_attribute4', x_Current_rec.industry_attribute4);
5295 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
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.industry_attribute5 = 'Y' THEN
5301 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
5302 NVL(g_Reconcile_tab(v_Count).industry_attribute5, 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, 'industry_attribute5', x_Current_rec.industry_attribute5);
5310 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
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.industry_attribute6 = 'Y' THEN
5316 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
5317 NVL(g_Reconcile_tab(v_Count).industry_attribute6, 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, 'industry_attribute6', x_Current_rec.industry_attribute6);
5325 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
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.industry_attribute10 = 'Y' THEN
5331 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
5332 NVL(g_Reconcile_tab(v_Count).industry_attribute10, 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, 'industry_attribute10', x_Current_rec.industry_attribute10);
5340 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
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.industry_attribute11 = 'Y' THEN
5346 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
5347 NVL(g_Reconcile_tab(v_Count).industry_attribute11, 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, 'industry_attribute11', x_Current_rec.industry_attribute11);
5355 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
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.industry_attribute12 = 'Y' THEN
5361 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
5362 NVL(g_Reconcile_tab(v_Count).industry_attribute12, 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, 'industry_attribute12', x_Current_rec.industry_attribute12);
5370 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
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.industry_attribute13 = 'Y' THEN
5376 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
5377 NVL(g_Reconcile_tab(v_Count).industry_attribute13, 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, 'industry_attribute13', x_Current_rec.industry_attribute13);
5385 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
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.industry_attribute14 = 'Y' THEN
5391 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
5392 NVL(g_Reconcile_tab(v_Count).industry_attribute14, 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, 'industry_attribute14', x_Current_rec.industry_attribute14);
5400 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
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.industry_attribute15 = 'Y' THEN
5406 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
5407 NVL(g_Reconcile_tab(v_Count).industry_attribute15, 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, 'industry_attribute15', x_Current_rec.industry_attribute15);
5415 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
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.attribute1 = 'Y' THEN
5421 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
5422 NVL(g_Reconcile_tab(v_Count).attribute1, 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, 'attribute1', x_Current_rec.attribute1);
5430 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
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.attribute2 = 'Y' THEN
5436 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
5437 NVL(g_Reconcile_tab(v_Count).attribute2, 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, 'uattribute2', x_Current_rec.attribute2);
5445 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
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.attribute3 = 'Y' THEN
5451 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
5452 NVL(g_Reconcile_tab(v_Count).attribute3, 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, 'attribute3', x_Current_rec.attribute3);
5460 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
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.attribute4 = 'Y' THEN
5466 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
5467 NVL(g_Reconcile_tab(v_Count).attribute4, 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, 'attribute4', x_Current_rec.attribute4);
5475 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
5476 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5477 END IF;
5478 --
5479 IF b_Match THEN
5480 IF x_Group_rec.match_across_rec.attribute5 = 'Y' THEN
5481 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
5482 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
5483 b_Match := FALSE;
5484 END IF;
5485 END IF;
5486 END IF;
5487 --
5488 IF (l_debug <> -1) THEN
5489 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
5490 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
5491 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5492 END IF;
5493 --
5494 IF b_Match THEN
5495 IF x_Group_rec.match_across_rec.attribute6 = 'Y' THEN
5496 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
5497 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
5498 b_Match := FALSE;
5499 END IF;
5500 END IF;
5501 END IF;
5502 --
5503 IF (l_debug <> -1) THEN
5504 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
5505 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
5506 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5507 END IF;
5508 --
5509 IF b_Match THEN
5510 IF x_Group_rec.match_across_rec.attribute7 = 'Y' THEN
5511 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
5512 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
5513 b_Match := FALSE;
5514 END IF;
5515 END IF;
5516 END IF;
5517 --
5518 IF (l_debug <> -1) THEN
5519 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
5520 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
5521 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5522 END IF;
5523 --
5524 IF b_Match THEN
5525 IF x_Group_rec.match_across_rec.attribute8 = 'Y' THEN
5526 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
5527 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
5528 b_Match := FALSE;
5529 END IF;
5530 END IF;
5531 END IF;
5532 --
5533 IF (l_debug <> -1) THEN
5534 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
5535 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
5536 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5537 END IF;
5538 --
5539 IF b_Match THEN
5540 IF x_Group_rec.match_across_rec.attribute9 = 'Y' THEN
5541 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
5542 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
5543 b_Match := FALSE;
5544 END IF;
5545 END IF;
5546 END IF;
5547 --
5548 IF (l_debug <> -1) THEN
5549 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
5550 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
5551 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5552 END IF;
5553 --
5554 IF b_Match THEN
5555 IF x_Group_rec.match_across_rec.attribute10 = 'Y' THEN
5556 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
5557 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
5558 b_Match := FALSE;
5559 END IF;
5560 END IF;
5561 END IF;
5562 --
5563 IF (l_debug <> -1) THEN
5564 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
5565 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
5566 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5567 END IF;
5568 --
5569 IF b_Match THEN
5570 IF x_Group_rec.match_across_rec.attribute11 = 'Y' THEN
5571 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
5572 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
5573 b_Match := FALSE;
5574 END IF;
5575 END IF;
5576 END IF;
5577 --
5578 IF (l_debug <> -1) THEN
5579 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
5580 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
5581 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5582 END IF;
5583 --
5584 IF b_Match THEN
5585 IF x_Group_rec.match_across_rec.attribute12 = 'Y' THEN
5586 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
5587 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
5588 b_Match := FALSE;
5589 END IF;
5590 END IF;
5591 END IF;
5592 --
5593 IF (l_debug <> -1) THEN
5594 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
5595 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
5596 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5597 END IF;
5598 --
5599 IF b_Match THEN
5600 IF x_Group_rec.match_across_rec.attribute13 = 'Y' THEN
5601 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
5602 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
5603 b_Match := FALSE;
5604 END IF;
5605 END IF;
5606 END IF;
5607 --
5608 IF (l_debug <> -1) THEN
5609 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
5610 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
5611 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5612 END IF;
5613 --
5614 IF b_Match THEN
5615 IF x_Group_rec.match_across_rec.attribute14 = 'Y' THEN
5616 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
5617 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
5618 b_Match := FALSE;
5619 END IF;
5620 END IF;
5621 END IF;
5622 --
5623 IF (l_debug <> -1) THEN
5624 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
5625 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
5626 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5627 END IF;
5628 --
5629 IF b_Match THEN
5630 IF x_Group_rec.match_across_rec.attribute15 = 'Y' THEN
5631 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
5632 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
5633 b_Match := FALSE;
5634 END IF;
5635 END IF;
5636 END IF;
5637 --
5638 IF (l_debug <> -1) THEN
5639 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
5640 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
5641 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5642 END IF;
5643 --}
5644 ELSE
5645 --{
5646 b_Match := FALSE;
5647 IF (l_debug <> -1) THEN
5648 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5649 END IF;
5650 --}
5651 END IF;
5652 --
5653 IF b_Match THEN
5654 x_Index := v_Count;
5655 EXIT;
5656 END IF;
5657 --
5658 v_Count := g_Reconcile_Tab.next(v_Count);
5659 --
5660 --}
5661 END LOOP;
5662 --
5663 END IF;
5664 --
5665 IF (l_debug <> -1) THEN
5666 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
5667 rlm_core_sv.dlog(k_DEBUG,'x_index', x_index);
5668 rlm_core_sv.dpop(k_SDEBUG);
5669 END IF;
5670 --
5671 RETURN(b_Match);
5672 --
5673 EXCEPTION
5674 WHEN OTHERS THEN
5675 rlm_message_sv.sql_error('rlm_rd_sv.MatchFrozen',x_progress);
5676 --
5677 IF (l_debug <> -1) THEN
5678 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
5679 END IF;
5680 --
5681 raise;
5682
5683 END MatchFrozen;
5684
5685
5686 /*===========================================================================
5687
5688 FUNCTION MatchReconcile
5689
5690 ===========================================================================*/
5691 FUNCTION MatchReconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
5692 x_Current_rec IN t_Generic_rec,
5693 x_Index OUT NOCOPY NUMBER)
5694 RETURN BOOLEAN
5695 IS
5696 x_progress VARCHAR2(3) := '010';
5697 v_Count NUMBER;
5698 v_Index NUMBER;
5699 b_Match BOOLEAN := FALSE;
5700 v_intransit_calc_basis VARCHAR2(30) ;
5701
5702 BEGIN
5703 --
5704 IF (l_debug <> -1) THEN
5705 rlm_core_sv.dpush(k_SDEBUG,'MatchReconcile');
5706 rlm_core_sv.dlog(k_DEBUG, 'x_Current_rec.schedule_type',
5707 x_Current_rec.schedule_type);
5708 END IF;
5709 --
5710 -- Bug 2261743
5711 IF (l_debug <> -1) THEN
5712 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
5713 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
5714 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
5715 END IF;
5716
5717 IF g_Reconcile_tab.COUNT <> 0 THEN
5718 --
5719 -- bug 4223359 changed the for loop to while as the PL/SQL table to null entries in between
5720 --
5721 v_Count := g_Reconcile_tab.FIRST;
5722 --
5723 WHILE v_Count IS NOT NULL LOOP
5724 --{
5725 b_Match := TRUE;
5726 --
5727 IF (l_debug <> -1) THEN
5728 rlm_core_sv.dlog(k_DEBUG, 'g_Reconcile_Tab('||v_Count||').schedule_type',
5729 g_Reconcile_Tab(v_Count).schedule_type);
5730 END IF;
5731 -- Bug 5608510
5732 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
5733 --
5734 IF (l_debug <> -1) THEN
5735 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis ',x_Group_rec.setup_terms_rec.intransit_calc_basis);
5736 END IF;
5737 --
5738 IF x_Current_rec.schedule_type = g_Reconcile_tab(v_Count).schedule_type THEN
5739 --
5740 IF (l_debug <> -1) THEN
5741 rlm_core_sv.dlog(k_DEBUG,'Match Within Schedules only ');
5742 END IF;
5743 --
5744 IF x_Group_rec.match_within_rec.cust_po_number = 'Y' THEN
5745 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
5746 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
5747 b_Match := FALSE;
5748 END IF;
5749 END IF;
5750 --
5751 IF (l_debug <> -1) THEN
5752 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
5753 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
5754 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5755 END IF;
5756 --
5757 IF b_Match THEN
5758 IF x_Group_rec.match_within_rec.customer_item_revision = 'Y' THEN
5759 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
5760 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
5761 b_Match := FALSE;
5762 END IF;
5763 END IF;
5764 END IF;
5765 --
5766 IF (l_debug <> -1) THEN
5767 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
5768 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
5769 g_Reconcile_tab(v_Count).customer_item_revision);
5770 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5771 END IF;
5772 --
5773 IF b_Match THEN
5774 IF x_Group_rec.match_within_rec.customer_dock_code = 'Y' THEN
5775 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
5776 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
5777 b_Match := FALSE;
5778 END IF;
5779 END IF;
5780 END IF;
5781 --
5782 IF (l_debug <> -1) THEN
5783 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
5784 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
5785 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5786 END IF;
5787 --
5788 IF b_Match THEN
5789 IF x_Group_rec.match_within_rec.customer_job = 'Y' THEN
5790 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
5791 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
5792 b_Match := FALSE;
5793 END IF;
5794 END IF;
5795 END IF;
5796 --
5797 IF (l_debug <> -1) THEN
5798 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
5799 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
5800 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5801 END IF;
5802 --
5803 IF b_Match THEN
5804 IF x_Group_rec.match_within_rec.cust_production_line = 'Y' THEN
5805 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
5806 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
5807 b_Match := FALSE;
5808 END IF;
5809 END IF;
5810 END IF;
5811 --
5812 IF (l_debug <> -1) THEN
5813 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
5814 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
5815 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5816 END IF;
5817 --
5818 IF b_Match THEN
5819 IF x_Group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
5820 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
5821 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
5822 b_Match := FALSE;
5823 END IF;
5824 END IF;
5825 END IF;
5826 --
5827 IF (l_debug <> -1) THEN
5828 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
5829 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
5830 g_Reconcile_tab(v_Count).cust_model_serial_number);
5831 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5832 END IF;
5833 --
5834 IF b_Match THEN
5835 IF x_Group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
5836 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
5837 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
5838 b_Match := FALSE;
5839 END IF;
5840 END IF;
5841 END IF;
5842 --
5843 IF (l_debug <> -1) THEN
5844 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
5845 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
5846 g_Reconcile_tab(v_Count).cust_production_seq_num);
5847 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5848 END IF;
5849 --
5850 IF b_Match THEN
5851 IF x_Group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
5852 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
5853 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
5854 b_Match := FALSE;
5855 END IF;
5856 END IF;
5857 END IF;
5858 --
5859 IF (l_debug <> -1) THEN
5860 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
5861 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
5862 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5863 END IF;
5864 --
5865 --Bug 5608510
5866 --
5867 IF v_intransit_calc_basis = 'PART_SHIP_LINES' THEN
5868 IF b_Match THEN
5869 IF x_Group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
5870 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
5871 NVL(g_Reconcile_tab(v_Count).industry_attribute2, k_VNULL) THEN
5872 b_Match := FALSE;
5873 END IF;
5874 END IF;
5875 END IF;
5876 --
5877 IF (l_debug <> -1) THEN
5878 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
5879 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
5880 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5881 END IF;
5882 --
5883 IF b_Match THEN
5884 IF x_Group_rec.match_within_rec.request_date = 'Y' THEN
5885 IF NVL(x_Current_rec.request_date, k_DNULL) <>
5886 NVL(g_Reconcile_tab(v_Count).request_date, k_DNULL) THEN
5887 b_Match := FALSE;
5888 END IF;
5889 END IF;
5890 END IF;
5891 --
5892 --
5893 IF (l_debug <> -1) THEN
5894 rlm_core_sv.dlog(k_DEBUG, 'request_date', x_Current_rec.request_date);
5895 rlm_core_sv.dlog(k_DEBUG, 'rec request_date', g_Reconcile_tab(v_Count).request_date);
5896 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
5897 END IF;
5898 --
5899 END IF; --bugfix 5608510 ends
5900 --
5901 IF b_Match THEN
5902 IF x_Group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
5903 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
5904 NVL(g_Reconcile_tab(v_Count).industry_attribute4, 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, 'industry_attribute4', x_Current_rec.industry_attribute4);
5912 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
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.industry_attribute5 = 'Y' THEN
5918 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
5919 NVL(g_Reconcile_tab(v_Count).industry_attribute5, 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, 'industry_attribute5', x_Current_rec.industry_attribute5);
5927 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
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.industry_attribute6 = 'Y' THEN
5933 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
5934 NVL(g_Reconcile_tab(v_Count).industry_attribute6, 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, 'industry_attribute6', x_Current_rec.industry_attribute6);
5942 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
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.industry_attribute10 = 'Y' THEN
5948 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
5949 NVL(g_Reconcile_tab(v_Count).industry_attribute10, 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, 'industry_attribute10', x_Current_rec.industry_attribute10);
5957 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
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.industry_attribute11 = 'Y' THEN
5963 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
5964 NVL(g_Reconcile_tab(v_Count).industry_attribute11, 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, 'industry_attribute11', x_Current_rec.industry_attribute11);
5972 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
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.industry_attribute12 = 'Y' THEN
5978 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
5979 NVL(g_Reconcile_tab(v_Count).industry_attribute12, 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, 'industry_attribute12', x_Current_rec.industry_attribute12);
5987 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
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.industry_attribute13 = 'Y' THEN
5993 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
5994 NVL(g_Reconcile_tab(v_Count).industry_attribute13, 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, 'industry_attribute13', x_Current_rec.industry_attribute13);
6002 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
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.industry_attribute14 = 'Y' THEN
6008 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
6009 NVL(g_Reconcile_tab(v_Count).industry_attribute14, 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, 'industry_attribute14', x_Current_rec.industry_attribute14);
6017 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
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.industry_attribute15 = 'Y' THEN
6023 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
6024 NVL(g_Reconcile_tab(v_Count).industry_attribute15, 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, 'industry_attribute15', x_Current_rec.industry_attribute15);
6032 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
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.attribute1 = 'Y' THEN
6038 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
6039 NVL(g_Reconcile_tab(v_Count).attribute1, 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, 'attribute1', x_Current_rec.attribute1);
6047 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
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.attribute2 = 'Y' THEN
6053 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
6054 NVL(g_Reconcile_tab(v_Count).attribute2, 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, 'uattribute2', x_Current_rec.attribute2);
6062 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
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.attribute3 = 'Y' THEN
6068 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
6069 NVL(g_Reconcile_tab(v_Count).attribute3, 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, 'attribute3', x_Current_rec.attribute3);
6077 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
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.attribute4 = 'Y' THEN
6083 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
6084 NVL(g_Reconcile_tab(v_Count).attribute4, 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, 'attribute4', x_Current_rec.attribute4);
6092 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
6093 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6094 END IF;
6095 --
6096 IF b_Match THEN
6097 IF x_Group_rec.match_within_rec.attribute5 = 'Y' THEN
6098 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
6099 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
6100 b_Match := FALSE;
6101 END IF;
6102 END IF;
6103 END IF;
6104 --
6105 IF (l_debug <> -1) THEN
6106 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
6107 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
6108 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6109 END IF;
6110 --
6111 IF b_Match THEN
6112 IF x_Group_rec.match_within_rec.attribute6 = 'Y' THEN
6113 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
6114 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
6115 b_Match := FALSE;
6116 END IF;
6117 END IF;
6118 END IF;
6119 --
6120 IF (l_debug <> -1) THEN
6121 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
6122 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
6123 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6124 END IF;
6125 --
6126 IF b_Match THEN
6127 IF x_Group_rec.match_within_rec.attribute7 = 'Y' THEN
6128 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
6129 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
6130 b_Match := FALSE;
6131 END IF;
6132 END IF;
6133 END IF;
6134 --
6135 IF (l_debug <> -1) THEN
6136 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
6137 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
6138 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6139 END IF;
6140 --
6141 IF b_Match THEN
6142 IF x_Group_rec.match_within_rec.attribute8 = 'Y' THEN
6143 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
6144 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
6145 b_Match := FALSE;
6146 END IF;
6147 END IF;
6148 END IF;
6149 --
6150 IF (l_debug <> -1) THEN
6151 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
6152 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
6153 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6154 END IF;
6155 --
6156 IF b_Match THEN
6157 IF x_Group_rec.match_within_rec.attribute9 = 'Y' THEN
6158 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
6159 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
6160 b_Match := FALSE;
6161 END IF;
6162 END IF;
6163 END IF;
6164 --
6165 IF (l_debug <> -1) THEN
6166 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
6167 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
6168 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6169 END IF;
6170 --
6171 IF b_Match THEN
6172 IF x_Group_rec.match_within_rec.attribute10 = 'Y' THEN
6173 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
6174 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
6175 b_Match := FALSE;
6176 END IF;
6177 END IF;
6178 END IF;
6179 --
6180 IF (l_debug <> -1) THEN
6181 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
6182 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
6183 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6184 END IF;
6185 --
6186 IF b_Match THEN
6187 IF x_Group_rec.match_within_rec.attribute11 = 'Y' THEN
6188 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
6189 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
6190 b_Match := FALSE;
6191 END IF;
6192 END IF;
6193 END IF;
6194 --
6195 IF (l_debug <> -1) THEN
6196 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
6197 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
6198 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6199 END IF;
6200 --
6201 IF b_Match THEN
6202 IF x_Group_rec.match_within_rec.attribute12 = 'Y' THEN
6203 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
6204 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
6205 b_Match := FALSE;
6206 END IF;
6207 END IF;
6208 END IF;
6209 --
6210 IF (l_debug <> -1) THEN
6211 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
6212 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
6213 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6214 END IF;
6215 --
6216 IF b_Match THEN
6217 IF x_Group_rec.match_within_rec.attribute13 = 'Y' THEN
6218 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
6219 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
6220 b_Match := FALSE;
6221 END IF;
6222 END IF;
6223 END IF;
6224 --
6225 IF (l_debug <> -1) THEN
6226 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
6227 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
6228 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6229 END IF;
6230 --
6231 IF b_Match THEN
6232 IF x_Group_rec.match_within_rec.attribute14 = 'Y' THEN
6233 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
6234 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
6235 b_Match := FALSE;
6236 END IF;
6237 END IF;
6238 END IF;
6239 --
6240 IF (l_debug <> -1) THEN
6241 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
6242 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
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_within_rec.attribute15 = 'Y' THEN
6248 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
6249 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
6250 b_Match := FALSE;
6251 END IF;
6252 END IF;
6253 END IF;
6254 --
6255 IF (l_debug <> -1) THEN
6256 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
6257 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
6258 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6259 END IF;
6260 --
6261 --
6262 --
6263 ELSIF x_Current_rec.schedule_type <> g_Reconcile_tab(v_Count).schedule_type THEN
6264 --
6265 --
6266 --
6267 IF (l_debug <> -1) THEN
6268 rlm_core_sv.dlog(k_DEBUG,'Match across Schedules only ');
6269 END IF;
6270 --
6271 IF x_Group_rec.match_across_rec.cust_po_number = 'Y' THEN
6272 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
6273 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
6274 b_Match := FALSE;
6275 END IF;
6276 END IF;
6277 --
6278 IF (l_debug <> -1) THEN
6279 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
6280 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
6281 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6282 END IF;
6283 --
6284 IF b_Match THEN
6285 IF x_Group_rec.match_across_rec.customer_item_revision = 'Y' THEN
6286 IF NVL(x_Current_rec.customer_item_revision, k_VNULL) <>
6287 NVL(g_Reconcile_tab(v_Count).customer_item_revision, k_VNULL) THEN
6288 b_Match := FALSE;
6289 END IF;
6290 END IF;
6291 END IF;
6292 --
6293 IF (l_debug <> -1) THEN
6294 rlm_core_sv.dlog(k_DEBUG, 'customer_item_revision', x_Current_rec.customer_item_revision);
6295 rlm_core_sv.dlog(k_DEBUG, 'rec customer_item_revision',
6296 g_Reconcile_tab(v_Count).customer_item_revision);
6297 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6298 END IF;
6299 --
6300 IF b_Match THEN
6301 IF x_Group_rec.match_across_rec.customer_dock_code = 'Y' THEN
6302 IF NVL(x_Current_rec.customer_dock_code, k_VNULL) <>
6303 NVL(g_Reconcile_tab(v_Count).customer_dock_code, k_VNULL) THEN
6304 b_Match := FALSE;
6305 END IF;
6306 END IF;
6307 END IF;
6308 --
6309 IF (l_debug <> -1) THEN
6310 rlm_core_sv.dlog(k_DEBUG, 'customer_dock_code', x_Current_rec.customer_dock_code);
6311 rlm_core_sv.dlog(k_DEBUG, 'rec customer_dock_code', g_Reconcile_tab(v_Count).customer_dock_code);
6312 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6313 END IF;
6314 --
6315 IF b_Match THEN
6316 IF x_Group_rec.match_across_rec.customer_job = 'Y' THEN
6317 IF NVL(x_Current_rec.customer_job, k_VNULL) <>
6318 NVL(g_Reconcile_tab(v_Count).customer_job, k_VNULL) THEN
6319 b_Match := FALSE;
6320 END IF;
6321 END IF;
6322 END IF;
6323 --
6324 IF (l_debug <> -1) THEN
6325 rlm_core_sv.dlog(k_DEBUG, 'customer_job', x_Current_rec.customer_job);
6326 rlm_core_sv.dlog(k_DEBUG, 'rec customer_job', g_Reconcile_tab(v_Count).customer_job);
6327 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6328 END IF;
6329 --
6330 IF b_Match THEN
6331 IF x_Group_rec.match_across_rec.cust_production_line = 'Y' THEN
6332 IF NVL(x_Current_rec.cust_production_line, k_VNULL) <>
6333 NVL(g_Reconcile_tab(v_Count).cust_production_line, k_VNULL) THEN
6334 b_Match := FALSE;
6335 END IF;
6336 END IF;
6337 END IF;
6338 --
6339 IF (l_debug <> -1) THEN
6340 rlm_core_sv.dlog(k_DEBUG, 'cust_production_line', x_Current_rec.cust_production_line);
6341 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_line', g_Reconcile_tab(v_Count).cust_production_line);
6342 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6343 END IF;
6344 --
6345 IF b_Match THEN
6346 IF x_Group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
6347 IF NVL(x_Current_rec.cust_model_serial_number, k_VNULL) <>
6348 NVL(g_Reconcile_tab(v_Count).cust_model_serial_number, k_VNULL) THEN
6349 b_Match := FALSE;
6350 END IF;
6351 END IF;
6352 END IF;
6353 --
6354 IF (l_debug <> -1) THEN
6355 rlm_core_sv.dlog(k_DEBUG, 'cust_model_serial_number', x_Current_rec.cust_model_serial_number);
6356 rlm_core_sv.dlog(k_DEBUG, 'rec cust_model_serial_number',
6357 g_Reconcile_tab(v_Count).cust_model_serial_number);
6358 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6359 END IF;
6360 --
6361 IF b_Match THEN
6362 IF x_Group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
6363 IF NVL(x_Current_rec.cust_production_seq_num, k_VNULL) <>
6364 NVL(g_Reconcile_tab(v_Count).cust_production_seq_num, k_VNULL) THEN
6365 b_Match := FALSE;
6366 END IF;
6367 END IF;
6368 END IF;
6369 --
6370 IF (l_debug <> -1) THEN
6371 rlm_core_sv.dlog(k_DEBUG, 'cust_production_seq_num', x_Current_rec.cust_production_seq_num);
6372 rlm_core_sv.dlog(k_DEBUG, 'rec cust_production_seq_num',
6373 g_Reconcile_tab(v_Count).cust_production_seq_num);
6374 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6375 END IF;
6376 --
6377 IF b_Match THEN
6378 IF x_Group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
6379 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
6380 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
6381 b_Match := FALSE;
6382 END IF;
6383 END IF;
6384 END IF;
6385 --
6386 IF (l_debug <> -1) THEN
6387 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
6388 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
6389 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6390 END IF;
6391 --
6392 -- Bugfix 5608510
6393 IF v_intransit_calc_basis = 'PART_SHIP_LINES' THEN
6394
6395 IF b_Match THEN
6396 IF x_Group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
6397 IF NVL(x_Current_rec.industry_attribute2, k_VNULL) <>
6398 NVL(g_Reconcile_tab(v_Count).industry_attribute2, k_VNULL) THEN
6399 b_Match := FALSE;
6400 END IF;
6401 END IF;
6402 END IF;
6403 --
6404
6405 IF (l_debug <> -1) THEN
6406 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute2', x_Current_rec.industry_attribute2);
6407 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute2', g_Reconcile_tab(v_Count).industry_attribute2);
6408 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6409 END IF;
6410 --
6411 IF b_Match THEN
6412 IF x_Group_rec.match_across_rec.request_date = 'Y' THEN
6413 IF NVL(x_Current_rec.request_date, k_DNULL) <>
6414 NVL(g_Reconcile_tab(v_Count).request_date, k_DNULL) THEN
6415 b_Match := FALSE;
6416 END IF;
6417 END IF;
6418 END IF;
6419 --
6420 --
6421 IF (l_debug <> -1) THEN
6422 rlm_core_sv.dlog(k_DEBUG, 'request_date', x_Current_rec.request_date);
6423 rlm_core_sv.dlog(k_DEBUG, 'rec request_date', g_Reconcile_tab(v_Count).request_date);
6424 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6425 END IF;
6426 --
6427 END IF ; -- bugfix 5608510
6428 IF b_Match THEN
6429 IF x_Group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
6430 IF NVL(x_Current_rec.industry_attribute4, k_VNULL) <>
6431 NVL(g_Reconcile_tab(v_Count).industry_attribute4, 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, 'industry_attribute4', x_Current_rec.industry_attribute4);
6439 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute4', g_Reconcile_tab(v_Count).industry_attribute4);
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.industry_attribute5 = 'Y' THEN
6445 IF NVL(x_Current_rec.industry_attribute5, k_VNULL) <>
6446 NVL(g_Reconcile_tab(v_Count).industry_attribute5, 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, 'industry_attribute5', x_Current_rec.industry_attribute5);
6454 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute5', g_Reconcile_tab(v_Count).industry_attribute5);
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.industry_attribute6 = 'Y' THEN
6460 IF NVL(x_Current_rec.industry_attribute6, k_VNULL) <>
6461 NVL(g_Reconcile_tab(v_Count).industry_attribute6, 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, 'industry_attribute6', x_Current_rec.industry_attribute6);
6469 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute6', g_Reconcile_tab(v_Count).industry_attribute6);
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.industry_attribute10 = 'Y' THEN
6475 IF NVL(x_Current_rec.industry_attribute10, k_VNULL) <>
6476 NVL(g_Reconcile_tab(v_Count).industry_attribute10, 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, 'industry_attribute10', x_Current_rec.industry_attribute10);
6484 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute10', g_Reconcile_tab(v_Count).industry_attribute10);
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.industry_attribute11 = 'Y' THEN
6490 IF NVL(x_Current_rec.industry_attribute11, k_VNULL) <>
6491 NVL(g_Reconcile_tab(v_Count).industry_attribute11, 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, 'industry_attribute11', x_Current_rec.industry_attribute11);
6499 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute11', g_Reconcile_tab(v_Count).industry_attribute11);
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.industry_attribute12 = 'Y' THEN
6505 IF NVL(x_Current_rec.industry_attribute12, k_VNULL) <>
6506 NVL(g_Reconcile_tab(v_Count).industry_attribute12, 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, 'industry_attribute12', x_Current_rec.industry_attribute12);
6514 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute12', g_Reconcile_tab(v_Count).industry_attribute12);
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.industry_attribute13 = 'Y' THEN
6520 IF NVL(x_Current_rec.industry_attribute13, k_VNULL) <>
6521 NVL(g_Reconcile_tab(v_Count).industry_attribute13, 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, 'industry_attribute13', x_Current_rec.industry_attribute13);
6529 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute13', g_Reconcile_tab(v_Count).industry_attribute13);
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.industry_attribute14 = 'Y' THEN
6535 IF NVL(x_Current_rec.industry_attribute14, k_VNULL) <>
6536 NVL(g_Reconcile_tab(v_Count).industry_attribute14, 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, 'industry_attribute14', x_Current_rec.industry_attribute14);
6544 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute14', g_Reconcile_tab(v_Count).industry_attribute14);
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.industry_attribute15 = 'Y' THEN
6550 IF NVL(x_Current_rec.industry_attribute15, k_VNULL) <>
6551 NVL(g_Reconcile_tab(v_Count).industry_attribute15, 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, 'industry_attribute15', x_Current_rec.industry_attribute15);
6559 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute15', g_Reconcile_tab(v_Count).industry_attribute15);
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.attribute1 = 'Y' THEN
6565 IF NVL(x_Current_rec.attribute1, k_VNULL) <>
6566 NVL(g_Reconcile_tab(v_Count).attribute1, 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, 'attribute1', x_Current_rec.attribute1);
6574 rlm_core_sv.dlog(k_DEBUG, 'rec attribute1', g_Reconcile_tab(v_Count).attribute1);
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.attribute2 = 'Y' THEN
6580 IF NVL(x_Current_rec.attribute2, k_VNULL) <>
6581 NVL(g_Reconcile_tab(v_Count).attribute2, 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, 'uattribute2', x_Current_rec.attribute2);
6589 rlm_core_sv.dlog(k_DEBUG, 'rec attribute2', g_Reconcile_tab(v_Count).attribute2);
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.attribute3 = 'Y' THEN
6595 IF NVL(x_Current_rec.attribute3, k_VNULL) <>
6596 NVL(g_Reconcile_tab(v_Count).attribute3, 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, 'attribute3', x_Current_rec.attribute3);
6604 rlm_core_sv.dlog(k_DEBUG, 'rec attribute3', g_Reconcile_tab(v_Count).attribute3);
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.attribute4 = 'Y' THEN
6610 IF NVL(x_Current_rec.attribute4, k_VNULL) <>
6611 NVL(g_Reconcile_tab(v_Count).attribute4, 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, 'attribute4', x_Current_rec.attribute4);
6619 rlm_core_sv.dlog(k_DEBUG, 'rec attribute4', g_Reconcile_tab(v_Count).attribute4);
6620 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6621 END IF;
6622 --
6623 IF b_Match THEN
6624 IF x_Group_rec.match_across_rec.attribute5 = 'Y' THEN
6625 IF NVL(x_Current_rec.attribute5, k_VNULL) <>
6626 NVL(g_Reconcile_tab(v_Count).attribute5, k_VNULL) THEN
6627 b_Match := FALSE;
6628 END IF;
6629 END IF;
6630 END IF;
6631 --
6632 IF (l_debug <> -1) THEN
6633 rlm_core_sv.dlog(k_DEBUG, 'attribute5', x_Current_rec.attribute5);
6634 rlm_core_sv.dlog(k_DEBUG, 'rec attribute5', g_Reconcile_tab(v_Count).attribute5);
6635 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6636 END IF;
6637 --
6638 IF b_Match THEN
6639 IF x_Group_rec.match_across_rec.attribute6 = 'Y' THEN
6640 IF NVL(x_Current_rec.attribute6, k_VNULL) <>
6641 NVL(g_Reconcile_tab(v_Count).attribute6, k_VNULL) THEN
6642 b_Match := FALSE;
6643 END IF;
6644 END IF;
6645 END IF;
6646 --
6647 IF (l_debug <> -1) THEN
6648 rlm_core_sv.dlog(k_DEBUG, 'attribute6', x_Current_rec.attribute6);
6649 rlm_core_sv.dlog(k_DEBUG, 'rec attribute6', g_Reconcile_tab(v_Count).attribute6);
6650 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6651 END IF;
6652 --
6653 IF b_Match THEN
6654 IF x_Group_rec.match_across_rec.attribute7 = 'Y' THEN
6655 IF NVL(x_Current_rec.attribute7, k_VNULL) <>
6656 NVL(g_Reconcile_tab(v_Count).attribute7, k_VNULL) THEN
6657 b_Match := FALSE;
6658 END IF;
6659 END IF;
6660 END IF;
6661 --
6662 IF (l_debug <> -1) THEN
6663 rlm_core_sv.dlog(k_DEBUG, 'attribute7', x_Current_rec.attribute7);
6664 rlm_core_sv.dlog(k_DEBUG, 'rec attribute7', g_Reconcile_tab(v_Count).attribute7);
6665 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6666 END IF;
6667 --
6668 IF b_Match THEN
6669 IF x_Group_rec.match_across_rec.attribute8 = 'Y' THEN
6670 IF NVL(x_Current_rec.attribute8, k_VNULL) <>
6671 NVL(g_Reconcile_tab(v_Count).attribute8, k_VNULL) THEN
6672 b_Match := FALSE;
6673 END IF;
6674 END IF;
6675 END IF;
6676 --
6677 IF (l_debug <> -1) THEN
6678 rlm_core_sv.dlog(k_DEBUG, 'attribute8', x_Current_rec.attribute8);
6679 rlm_core_sv.dlog(k_DEBUG, 'rec attribute8', g_Reconcile_tab(v_Count).attribute8);
6680 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6681 END IF;
6682 --
6683 IF b_Match THEN
6684 IF x_Group_rec.match_across_rec.attribute9 = 'Y' THEN
6685 IF NVL(x_Current_rec.attribute9, k_VNULL) <>
6686 NVL(g_Reconcile_tab(v_Count).attribute9, k_VNULL) THEN
6687 b_Match := FALSE;
6688 END IF;
6689 END IF;
6690 END IF;
6691 --
6692 IF (l_debug <> -1) THEN
6693 rlm_core_sv.dlog(k_DEBUG, 'attribute9', x_Current_rec.attribute9);
6694 rlm_core_sv.dlog(k_DEBUG, 'rec attribute9', g_Reconcile_tab(v_Count).attribute9);
6695 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6696 END IF;
6697 --
6698 IF b_Match THEN
6699 IF x_Group_rec.match_across_rec.attribute10 = 'Y' THEN
6700 IF NVL(x_Current_rec.attribute10, k_VNULL) <>
6701 NVL(g_Reconcile_tab(v_Count).attribute10, k_VNULL) THEN
6702 b_Match := FALSE;
6703 END IF;
6704 END IF;
6705 END IF;
6706 --
6707 IF (l_debug <> -1) THEN
6708 rlm_core_sv.dlog(k_DEBUG, 'attribute10', x_Current_rec.attribute10);
6709 rlm_core_sv.dlog(k_DEBUG, 'rec attribute10', g_Reconcile_tab(v_Count).attribute10);
6710 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6711 END IF;
6712 --
6713 IF b_Match THEN
6714 IF x_Group_rec.match_across_rec.attribute11 = 'Y' THEN
6715 IF NVL(x_Current_rec.attribute11, k_VNULL) <>
6716 NVL(g_Reconcile_tab(v_Count).attribute11, k_VNULL) THEN
6717 b_Match := FALSE;
6718 END IF;
6719 END IF;
6720 END IF;
6721 --
6722 IF (l_debug <> -1) THEN
6723 rlm_core_sv.dlog(k_DEBUG, 'attribute11', x_Current_rec.attribute11);
6724 rlm_core_sv.dlog(k_DEBUG, 'rec attribute11', g_Reconcile_tab(v_Count).attribute11);
6725 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6726 END IF;
6727 --
6728 IF b_Match THEN
6729 IF x_Group_rec.match_across_rec.attribute12 = 'Y' THEN
6730 IF NVL(x_Current_rec.attribute12, k_VNULL) <>
6731 NVL(g_Reconcile_tab(v_Count).attribute12, k_VNULL) THEN
6732 b_Match := FALSE;
6733 END IF;
6734 END IF;
6735 END IF;
6736 --
6737 IF (l_debug <> -1) THEN
6738 rlm_core_sv.dlog(k_DEBUG, 'attribute12', x_Current_rec.attribute12);
6739 rlm_core_sv.dlog(k_DEBUG, 'rec attribute12', g_Reconcile_tab(v_Count).attribute12);
6740 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6741 END IF;
6742 --
6743 IF b_Match THEN
6744 IF x_Group_rec.match_across_rec.attribute13 = 'Y' THEN
6745 IF NVL(x_Current_rec.attribute13, k_VNULL) <>
6746 NVL(g_Reconcile_tab(v_Count).attribute13, k_VNULL) THEN
6747 b_Match := FALSE;
6748 END IF;
6749 END IF;
6750 END IF;
6751 --
6752 IF (l_debug <> -1) THEN
6753 rlm_core_sv.dlog(k_DEBUG, 'attribute13', x_Current_rec.attribute13);
6754 rlm_core_sv.dlog(k_DEBUG, 'rec attribute13', g_Reconcile_tab(v_Count).attribute13);
6755 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6756 END IF;
6757 --
6758 IF b_Match THEN
6759 IF x_Group_rec.match_across_rec.attribute14 = 'Y' THEN
6760 IF NVL(x_Current_rec.attribute14, k_VNULL) <>
6761 NVL(g_Reconcile_tab(v_Count).attribute14, k_VNULL) THEN
6762 b_Match := FALSE;
6763 END IF;
6764 END IF;
6765 END IF;
6766 --
6767 IF (l_debug <> -1) THEN
6768 rlm_core_sv.dlog(k_DEBUG, 'attribute14', x_Current_rec.attribute14);
6769 rlm_core_sv.dlog(k_DEBUG, 'rec attribute14', g_Reconcile_tab(v_Count).attribute14);
6770 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6771 END IF;
6772 --
6773 IF b_Match THEN
6774 IF x_Group_rec.match_across_rec.attribute15 = 'Y' THEN
6775 IF NVL(x_Current_rec.attribute15, k_VNULL) <>
6776 NVL(g_Reconcile_tab(v_Count).attribute15, k_VNULL) THEN
6777 b_Match := FALSE;
6778 END IF;
6779 END IF;
6780 END IF;
6781 --
6782 IF (l_debug <> -1) THEN
6783 rlm_core_sv.dlog(k_DEBUG, 'attribute15', x_Current_rec.attribute15);
6784 rlm_core_sv.dlog(k_DEBUG, 'rec attribute15', g_Reconcile_tab(v_Count).attribute15);
6785 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
6786 END IF;
6787 --
6788 END IF;
6789 --
6790 IF b_Match THEN
6791 --
6792 x_Index := v_Count;
6793 EXIT;
6794 --
6795 END IF;
6796 --
6797 v_Count := g_Reconcile_tab.NEXT(v_Count);
6798 --}
6799 END LOOP;
6800 --}
6801 END IF;
6802 --
6803 IF (l_debug <> -1) THEN
6804 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
6805 rlm_core_sv.dpop(k_SDEBUG);
6806 END IF;
6807 --
6808 RETURN(b_Match);
6809 --
6810 EXCEPTION
6811 WHEN OTHERS THEN
6812 rlm_message_sv.sql_error('rlm_rd_sv.MatchReconcile',x_progress);
6813 --
6814 IF (l_debug <> -1) THEN
6815 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6816 END IF;
6817 --
6818 raise;
6819
6820 END MatchReconcile;
6821
6822
6823 /*===========================================================================
6824
6825 PROCEDURE StoreReconcile
6826
6827 ===========================================================================*/
6828 PROCEDURE StoreReconcile(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
6829 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
6830 x_Key_rec IN RLM_RD_SV.t_Key_rec,
6831 x_Quantity IN NUMBER)
6832 IS
6833 --
6834 v_Index NUMBER;
6835 x_progress VARCHAR2(3) := '010';
6836 --
6837 BEGIN
6838 /*Bug 2263253 : Reverted the modifications done under bug 2194938 */
6839 --
6840 IF (l_debug <> -1) THEN
6841 rlm_core_sv.dpush(k_SDEBUG,'StoreReconcile');
6842 rlm_core_sv.dlog(k_DEBUG,'Quantity to be reconciled', x_Quantity);
6843 END IF;
6844 --
6845 IF MatchReconcile(x_Group_rec, x_Key_rec.dem_rec, v_Index) THEN
6846 --
6847 g_Reconcile_tab(v_Index).ordered_quantity:=
6848 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) + x_Quantity;
6849 --
6850 IF (l_debug <> -1) THEN
6851 rlm_core_sv.dlog(k_DEBUG,' Match Quantity ', g_Reconcile_tab(v_Index).ordered_quantity);
6852 END IF;
6853 --
6854 ELSE
6855 --
6856 -- bug 4223359 added this check as the PL/SQL table to null entries in between
6857 -- and the count is not necessarily the last element of the table
6858 --
6859 IF g_Reconcile_tab.First is NULL THEN
6860 --
6861 g_Reconcile_tab(1) := x_Key_rec.dem_rec;
6862 g_Reconcile_tab(1).ordered_quantity := x_Quantity;
6863 --
6864 ELSE
6865 --
6866 g_Reconcile_tab(g_Reconcile_tab.LAST+1) := x_Key_rec.dem_rec;
6867 g_Reconcile_tab(g_Reconcile_tab.LAST).ordered_quantity := x_Quantity;
6868 --
6869 END IF;
6870 --
6871 IF (l_debug <> -1) THEN
6872 rlm_core_sv.dlog(k_DEBUG,' New Line Quantity ', g_Reconcile_tab(g_Reconcile_tab.COUNT).ordered_quantity);
6873 END IF;
6874 --
6875 END IF;
6876 --
6877 IF (l_debug <> -1) THEN
6878 rlm_core_sv.dpop(k_SDEBUG);
6879 END IF;
6880
6881 EXCEPTION
6882 WHEN OTHERS THEN
6883 rlm_message_sv.sql_error('rlm_rd_sv.StoreReconcile',x_progress);
6884 --
6885 IF (l_debug <> -1) THEN
6886 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6887 END IF;
6888 --
6889 raise;
6890
6891 END StoreReconcile;
6892
6893
6894 /*===========================================================================
6895
6896 PROCEDURE Reconcile
6897
6898 ===========================================================================*/
6899 PROCEDURE Reconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
6900 x_Key_rec IN RLM_RD_SV.t_Key_rec,
6901 x_Quantity IN OUT NOCOPY NUMBER)
6902 IS
6903
6904 v_Index NUMBER;
6905 x_progress VARCHAR2(3) := '010';
6906
6907 BEGIN
6908 --
6909 IF (l_debug <> -1) THEN
6910 rlm_core_sv.dpush(k_SDEBUG,'Reconcile');
6911 END IF;
6912 --
6913 IF MatchReconcile(x_Group_rec, x_Key_rec.req_rec, v_Index) THEN
6914 --
6915 IF (l_debug <> -1) THEN
6916 rlm_core_sv.dlog(k_DEBUG,'v_Index',v_Index);
6917 END IF;
6918 --
6919 --start of bug 4223359
6920 --
6921 IF NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) < 0 THEN
6922 --
6923 IF (l_debug <> -1) THEN
6924 --
6925 rlm_core_sv.dlog(k_DEBUG,'ordered_quantity',g_Reconcile_tab(v_Index).ordered_quantity);
6926 rlm_core_sv.dpop(k_SDEBUG);
6927 --
6928 END IF;
6929 --
6930 return;
6931 --
6932 ELSIF NVL(g_Reconcile_tab(v_Index).ordered_quantity,0) > NVL(x_Quantity,0) THEN
6933 --
6934 g_Reconcile_tab(v_Index).ordered_quantity :=
6935 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0)
6936 - NVL(x_Quantity,0);
6937 --
6938 x_Quantity := 0;
6939 --
6940 ELSE
6941 --
6942 IF (l_debug <> -1) THEN
6943 --
6944 rlm_core_sv.dlog(k_DEBUG,'x_quantity',x_quantity);
6945 rlm_core_sv.dlog(k_DEBUG,'Entry getting deleted from Reconcile Table', v_Index);
6946 rlm_core_sv.dlog(k_DEBUG,'deleted g_Reconcile_tab(v_Index).ordered_quantity',
6947 g_Reconcile_tab(v_Index).ordered_quantity);
6948 --
6949 END IF;
6950 --
6951 x_Quantity := NVL(x_Quantity ,0)-
6952 NVL(g_Reconcile_tab(v_Index).ordered_quantity,0);
6953 g_Reconcile_tab.DELETE(v_Index);
6954 --
6955 END IF;
6956 --
6957 --end of bug 4223359
6958 --
6959 IF (l_debug <> -1) THEN
6960 rlm_core_sv.dlog(k_DEBUG,'x_Quantity',x_Quantity);
6961 END IF;
6962 --
6963 END IF;
6964 --
6965 IF (l_debug <> -1) THEN
6966 rlm_core_sv.dpop(k_SDEBUG);
6967 END IF;
6968 --
6969 EXCEPTION
6970 WHEN OTHERS THEN
6971 rlm_message_sv.sql_error('rlm_rd_sv.Reconcile',x_progress);
6972 --
6973 IF (l_debug <> -1) THEN
6974 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
6975 END IF;
6976 --
6977 raise;
6978
6979 END Reconcile;
6980
6981
6982 /*===========================================================================
6983
6984 FUNCTION AttributeChange
6985
6986 ===========================================================================*/
6987 FUNCTION AttributeChange(x_Key_rec IN RLM_RD_SV.t_Key_rec)
6988 RETURN BOOLEAN
6989 IS
6990
6991 b_Result BOOLEAN := TRUE;
6992 b_change BOOLEAN := FALSE;
6993 c_attr_cur t_Cursor_ref;
6994 x_progress VARCHAR2(3) := '010';
6995
6996 BEGIN
6997 --
6998 IF (l_debug <> -1) THEN
6999 rlm_core_sv.dpush(k_SDEBUG,'AttributeChange');
7000 END IF;
7001 --
7002 /*checks for an attribute change between dem rec
7003 and req rec. */
7004
7005 IF NVL(x_key_rec.req_rec.cust_po_number, k_VNULL) <>
7006 NVL(x_key_rec.dem_rec.cust_po_number, k_VNULL) THEN
7007 b_Change := TRUE;
7008 END IF;
7009 IF NOT b_Change THEN
7010 IF NVL(x_key_rec.req_rec.customer_item_revision, k_VNULL) <>
7011 NVL(x_key_rec.dem_rec.customer_item_revision, k_VNULL) THEN
7012 b_Change := TRUE;
7013 END IF;
7014 END IF;
7015 IF NOT b_Change THEN
7016 IF NVL(x_key_rec.req_rec.customer_dock_code, k_VNULL) <>
7017 NVL(x_key_rec.dem_rec.customer_dock_code, k_VNULL) THEN
7018 b_Change := TRUE;
7019 END IF;
7020 END IF;
7021 IF NOT b_Change THEN
7022 IF NVL(x_key_rec.req_rec.customer_job, k_VNULL) <>
7023 NVL(x_key_rec.dem_rec.customer_job, k_VNULL) THEN
7024 b_Change := TRUE;
7025 END IF;
7026 END IF;
7027 IF NOT b_Change THEN
7028 IF NVL(x_key_rec.req_rec.cust_production_line, k_VNULL) <>
7029 NVL(x_key_rec.dem_rec.cust_production_line, k_VNULL) THEN
7030 b_Change := TRUE;
7031 END IF;
7032 END IF;
7033 IF NOT b_Change THEN
7034 IF NVL(x_key_rec.req_rec.cust_model_serial_number, k_VNULL) <>
7035 NVL(x_key_rec.dem_rec.cust_model_serial_number, k_VNULL) THEN
7036 b_Change := TRUE;
7037 END IF;
7038 END IF;
7039 IF NOT b_Change THEN
7040 IF NVL(x_key_rec.req_rec.cust_production_seq_num, k_VNULL) <>
7041 NVL(x_key_rec.dem_rec.cust_production_seq_num, k_VNULL) THEN
7042 b_Change := TRUE;
7043 END IF;
7044 END IF;
7045 IF NOT b_Change THEN
7046 IF NVL(x_key_rec.req_rec.industry_attribute1, k_VNULL) <>
7047 NVL(x_key_rec.dem_rec.industry_attribute1, k_VNULL) THEN
7048 b_Change := TRUE;
7049 END IF;
7050 END IF;
7051 IF NOT b_Change THEN
7052 IF NVL(x_key_rec.req_rec.industry_attribute2, k_VNULL) <>
7053 NVL(x_key_rec.dem_rec.industry_attribute2, k_VNULL) THEN
7054 b_Change := TRUE;
7055 END IF;
7056 END IF;
7057 IF NOT b_Change THEN
7058 IF NVL(x_key_rec.req_rec.industry_attribute4, k_VNULL) <>
7059 NVL(x_key_rec.dem_rec.industry_attribute4, k_VNULL) THEN
7060 b_Change := TRUE;
7061 END IF;
7062 END IF;
7063 IF NOT b_Change THEN
7064 IF NVL(x_key_rec.req_rec.industry_attribute5, k_VNULL) <>
7065 NVL(x_key_rec.dem_rec.industry_attribute5, k_VNULL) THEN
7066 b_Change := TRUE;
7067 END IF;
7068 END IF;
7069 IF NOT b_Change THEN
7070 IF NVL(x_key_rec.req_rec.industry_attribute6, k_VNULL) <>
7071 NVL(x_key_rec.dem_rec.industry_attribute6, k_VNULL) THEN
7072 b_Change := TRUE;
7073 END IF;
7074 END IF;
7075 IF NOT b_Change THEN
7076 IF NVL(x_key_rec.req_rec.industry_attribute10, k_VNULL) <>
7077 NVL(x_key_rec.dem_rec.industry_attribute10, k_VNULL) THEN
7078 b_Change := TRUE;
7079 END IF;
7080 END IF;
7081 IF NOT b_Change THEN
7082 IF NVL(x_key_rec.req_rec.industry_attribute11, k_VNULL) <>
7083 NVL(x_key_rec.dem_rec.industry_attribute11, k_VNULL) THEN
7084 b_Change := TRUE;
7085 END IF;
7086 END IF;
7087 IF NOT b_Change THEN
7088 IF NVL(x_key_rec.req_rec.industry_attribute12, k_VNULL) <>
7089 NVL(x_key_rec.dem_rec.industry_attribute12, k_VNULL) THEN
7090 b_Change := TRUE;
7091 END IF;
7092 END IF;
7093 IF NOT b_Change THEN
7094 IF NVL(x_key_rec.req_rec.industry_attribute13, k_VNULL) <>
7095 NVL(x_key_rec.dem_rec.industry_attribute13, k_VNULL) THEN
7096 b_Change := TRUE;
7097 END IF;
7098 END IF;
7099 IF NOT b_Change THEN
7100 IF NVL(x_key_rec.req_rec.industry_attribute14, k_VNULL) <>
7101 NVL(x_key_rec.dem_rec.industry_attribute14, k_VNULL) THEN
7102 b_Change := TRUE;
7103 END IF;
7104 END IF;
7105 IF NOT b_Change THEN
7106 IF NVL(x_key_rec.req_rec.industry_attribute15, k_VNULL) <>
7107 NVL(x_key_rec.dem_rec.industry_attribute15, k_VNULL) THEN
7108 b_Change := TRUE;
7109 END IF;
7110 END IF;
7111 IF NOT b_Change THEN
7112 IF NVL(x_key_rec.req_rec.attribute1, k_VNULL) <>
7113 NVL(x_key_rec.dem_rec.attribute1, k_VNULL) THEN
7114 b_Change := TRUE;
7115 END IF;
7116 END IF;
7117 IF NOT b_Change THEN
7118 IF NVL(x_key_rec.req_rec.attribute2, k_VNULL) <>
7119 NVL(x_key_rec.dem_rec.attribute2, k_VNULL) THEN
7120 b_Change := TRUE;
7121 END IF;
7122 END IF;
7123 IF NOT b_Change THEN
7124 IF NVL(x_key_rec.req_rec.attribute3, k_VNULL) <>
7125 NVL(x_key_rec.dem_rec.attribute3, k_VNULL) THEN
7126 b_Change := TRUE;
7127 END IF;
7128 END IF;
7129 IF NOT b_Change THEN
7130 IF NVL(x_key_rec.req_rec.attribute4, k_VNULL) <>
7131 NVL(x_key_rec.dem_rec.attribute4, k_VNULL) THEN
7132 b_Change := TRUE;
7133 END IF;
7134 END IF;
7135 IF NOT b_Change THEN
7136 IF NVL(x_key_rec.req_rec.attribute5, k_VNULL) <>
7137 NVL(x_key_rec.dem_rec.attribute5, k_VNULL) THEN
7138 b_Change := TRUE;
7139 END IF;
7140 END IF;
7141 IF NOT b_Change THEN
7142 IF NVL(x_key_rec.req_rec.attribute6, k_VNULL) <>
7143 NVL(x_key_rec.dem_rec.attribute6, k_VNULL) THEN
7144 b_Change := TRUE;
7145 END IF;
7146 END IF;
7147 IF NOT b_Change THEN
7148 IF NVL(x_key_rec.req_rec.attribute7, k_VNULL) <>
7149 NVL(x_key_rec.dem_rec.attribute7, k_VNULL) THEN
7150 b_Change := TRUE;
7151 END IF;
7152 END IF;
7153 IF NOT b_Change THEN
7154 IF NVL(x_key_rec.req_rec.attribute8, k_VNULL) <>
7155 NVL(x_key_rec.dem_rec.attribute8, k_VNULL) THEN
7156 b_Change := TRUE;
7157 END IF;
7158 END IF;
7159 IF NOT b_Change THEN
7160 IF NVL(x_key_rec.req_rec.attribute9, k_VNULL) <>
7161 NVL(x_key_rec.dem_rec.attribute9, k_VNULL) THEN
7162 b_Change := TRUE;
7163 END IF;
7164 END IF;
7165 IF NOT b_Change THEN
7166 IF NVL(x_key_rec.req_rec.attribute10, k_VNULL) <>
7167 NVL(x_key_rec.dem_rec.attribute10, k_VNULL) THEN
7168 b_Change := TRUE;
7169 END IF;
7170 END IF;
7171 IF NOT b_Change THEN
7172 IF NVL(x_key_rec.req_rec.attribute12, k_VNULL) <>
7173 NVL(x_key_rec.dem_rec.attribute12, k_VNULL) THEN
7174 b_Change := TRUE;
7175 END IF;
7176 END IF;
7177 IF NOT b_Change THEN
7178 IF NVL(x_key_rec.req_rec.attribute13, k_VNULL) <>
7179 NVL(x_key_rec.dem_rec.attribute13, k_VNULL) THEN
7180 b_Change := TRUE;
7181 END IF;
7182 END IF;
7183 IF NOT b_Change THEN
7184 IF NVL(x_key_rec.req_rec.attribute14, k_VNULL) <>
7185 NVL(x_key_rec.dem_rec.attribute14, k_VNULL) THEN
7186 b_Change := TRUE;
7187 END IF;
7188 END IF;
7189 IF NOT b_Change THEN
7190 IF NVL(x_key_rec.req_rec.attribute15, k_VNULL) <>
7191 NVL(x_key_rec.dem_rec.attribute15, k_VNULL) THEN
7192 b_Change := TRUE;
7193 END IF;
7194 END IF;
7195
7196 IF b_Change THEN
7197 IF (l_debug <> -1) THEN
7198 rlm_core_sv.dpop(k_SDEBUG, 'true');
7199 END IF;
7200 ELSE
7201 --
7202 IF (l_debug <> -1) THEN
7203 rlm_core_sv.dpop(k_SDEBUG, 'false');
7204 END IF;
7205 --
7206 END IF;
7207
7208 RETURN(b_Change);
7209
7210 EXCEPTION
7211 WHEN OTHERS THEN
7212 rlm_message_sv.sql_error('rlm_rd_sv.AttributeChange',x_progress);
7213 --
7214 IF (l_debug <> -1) THEN
7215 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
7216 END IF;
7217 --
7218 raise;
7219
7220 END AttributeChange;
7221
7222
7223 /*===========================================================================
7224
7225 PROCEDURE ProcessPreHorizonATS
7226
7227 ===========================================================================*/
7228 PROCEDURE ProcessPreHorizonATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
7229 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
7230 IS
7231
7232 CURSOR c_PreHorizonDisp (x_OffsetDays NUMBER) IS
7233 SELECT line_id, rla_schedule_type_code
7234 FROM oe_order_lines
7235 WHERE header_id = x_Group_rec.order_header_id
7236 --global_atp
7237 AND ship_from_org_id =
7238 DECODE(g_ATP, k_ATP, ship_from_org_id,
7239 x_Group_rec.ship_from_org_id)
7240 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7241 AND ordered_item_id = x_Group_rec.customer_item_id
7242 AND inventory_item_id= x_Group_rec.inventory_item_id
7243 --pdue, global_atp
7244 AND NVL(industry_attribute15, k_VNULL) =
7245 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7246 NVL(x_Group_rec.industry_attribute15, k_VNULL))
7247 --bug 2181228
7248 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS')
7249 < (TRUNC(rlm_dp_sv.g_dsp_start_time) - x_OffsetDays) --Bugfix 10053830
7250 AND (NVL(ordered_quantity,0) -
7251 NVL(shipped_quantity,0) > 0)
7252 AND authorized_to_ship_flag = k_ATS
7253 ORDER BY request_date DESC;
7254
7255 v_Key_rec t_Key_rec;
7256 v_DeleteQty NUMBER;
7257 x_progress VARCHAR2(3) := '010';
7258 v_line_num oe_order_lines.line_number%TYPE;
7259
7260 BEGIN
7261 --
7262 IF (l_debug <> -1) THEN
7263 rlm_core_sv.dpush(k_SDEBUG,'ProcessPreHorizonATS');
7264 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id',x_Group_rec.order_header_id);
7265 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id',x_Group_rec.ship_from_org_id);
7266 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id',x_Group_rec.ship_to_org_id);
7267 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id',x_Group_rec.customer_item_id);
7268 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',x_Group_rec.inventory_item_id);
7269 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.disposition_code',x_Group_rec.disposition_code);
7270 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.cutoff_days',x_Group_rec.cutoff_days);
7271 END IF;
7272 --
7273 IF x_Group_rec.disposition_code IN (k_CANCEL_ALL, k_CANCEL_AFTER_N_DAYS) THEN
7274 --
7275 FOR c_PreHorizonDisp_rec IN c_PreHorizonDisp(nvl(x_Group_rec.cutoff_days,0)) LOOP
7276 --
7277 v_Key_rec.oe_line_id := c_PreHorizonDisp_rec.line_id;
7278 --
7279 IF (l_debug <> -1) THEN
7280 rlm_core_sv.dlog(k_DEBUG,'c_PreHorizonDisp_rec.line_id',
7281 c_PreHorizonDisp_rec.line_id);
7282 END IF;
7283 --
7284 GetDemand(v_Key_rec, x_Group_rec);
7285 --
7286 v_Key_rec.req_rec := v_Key_rec.dem_rec;
7287 --
7288 IF NVL(c_PreHorizonDisp_rec.rla_schedule_type_code, ' ')
7289 NOT IN (x_Group_rec.schedule_type_one,
7290 x_Group_rec.schedule_type_two,
7291 x_Group_rec.schedule_type_three)
7292 THEN
7293 --
7294 SELECT line_number INTO v_line_num
7295 FROM oe_order_lines_all
7296 WHERE line_id = c_PreHorizonDisp_rec.line_id;
7297 --
7298 rlm_message_sv.app_error(
7299 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7300 x_MessageName => 'RLM_WRONG_SCHEDTYPE',
7301 x_InterfaceHeaderId => x_sched_rec.header_id,
7302 x_InterfaceLineId => NULL,
7303 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7304 x_ScheduleLineId => NULL,
7305 x_OrderHeaderId => x_Group_rec.order_header_id,
7306 x_Token1 => 'LINENUM',
7307 x_value1 => v_line_num,
7308 x_Token2 => 'SCHEDTYPE',
7309 x_value2 => c_PreHorizonDisp_rec.rla_schedule_type_code );
7310 --
7311 IF (l_debug <> -1) THEN
7312 rlm_core_sv.dlog(k_DEBUG,'line_number', v_line_num);
7313 rlm_core_sv.dlog(k_DEBUG,'RLM_WRONG_SCHEDTYPE');
7314 END IF;
7315 --
7316 END IF;
7317 --
7318 IF SchedulePrecedence(x_Group_rec, x_sched_rec,c_PreHorizonDisp_rec.rla_schedule_type_code) THEN
7319 --
7320 DeleteRequirement(x_Sched_rec, x_Group_rec,
7321 v_Key_rec, k_NORECONCILE, v_DeleteQty);
7322 END IF;
7323 --
7324 END LOOP;
7325 --
7326 END IF;
7327 --
7328 IF (l_debug <> -1) THEN
7329 rlm_core_sv.dpop(k_SDEBUG);
7330 END IF;
7331 --
7332 EXCEPTION
7333
7334 WHEN e_group_error THEN
7335 --
7336 IF (l_debug <> -1) THEN
7337 rlm_core_sv.dlog(k_DEBUG,'group error');
7338 rlm_core_sv.dpop(k_SDEBUG);
7339 END IF;
7340 --
7341 raise e_group_error;
7342
7343 WHEN OTHERS THEN
7344 rlm_message_sv.sql_error('rlm_rd_sv.ProcessPreHorizonATS',x_progress);
7345 --
7346 IF (l_debug <> -1) THEN
7347 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
7348 END IF;
7349 --
7350 raise;
7351
7352 END ProcessPreHorizonATS;
7353
7354
7355 /*===========================================================================
7356
7357 PROCEDURE ProcessOld
7358 -- NOTE JH: open issue with bucket requirements overlapping end horizon date
7359
7360 ===========================================================================*/
7361 PROCEDURE ProcessOld(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
7362 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
7363 IS
7364 --
7365 -- Bug 3733520 : Modified cursor to select attributes that are
7366 -- selected in procedure GetDemand(). All calls to GetDemand()
7367 -- have been replaced with a call to AssignOEAttribValues().
7368 --
7369 CURSOR c_OldDemand (x_ATS_start_date DATE,
7370 x_NATS_start_date DATE) IS
7371 SELECT header_id,
7372 line_id,
7373 ship_from_org_id,
7374 ship_to_org_id,
7375 ordered_item_id,
7376 inventory_item_id,
7377 invoice_to_org_id,
7378 intmed_ship_to_org_id,
7379 demand_bucket_type_code,
7380 rla_schedule_type_code,
7381 authorized_to_ship_flag ATS,
7382 ordered_quantity orig_ordered_quantity,
7383 NVL(ordered_quantity,0) -
7384 NVL(shipped_quantity,0) ordered_quantity,
7385 ordered_item,
7386 item_identifier_type,
7387 item_type_code,
7388 DECODE(x_Group_rec.setup_terms_rec.blanket_number, NULL,
7389 NULL, blanket_number) blanket_number,
7390 customer_line_number,
7391 customer_production_line cust_production_line,
7392 customer_dock_code,
7393 request_date,
7394 schedule_ship_date,
7395 cust_po_number,
7396 item_revision customer_item_revision,
7397 customer_job,
7398 cust_model_serial_number,
7399 cust_production_seq_num,
7400 industry_attribute1,
7401 industry_attribute2,
7402 industry_attribute3,
7403 industry_attribute4,
7404 industry_attribute5,
7405 industry_attribute6,
7406 industry_attribute7,
7407 industry_attribute8,
7408 industry_attribute9,
7409 industry_attribute10,
7410 industry_attribute11,
7411 industry_attribute12,
7412 industry_attribute13,
7413 industry_attribute14,
7414 industry_attribute15,
7415 attribute1,
7416 attribute2,
7417 attribute3,
7418 attribute4,
7419 attribute5,
7420 attribute6,
7421 attribute7,
7422 attribute8,
7423 attribute9,
7424 attribute10,
7425 attribute11,
7426 attribute12,
7427 attribute13,
7428 attribute14,
7429 attribute15,
7430 to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS') + --request_date + --Bugfix 10277088
7431 DECODE(demand_bucket_type_code,
7432 k_WEEKLY,6.99999,
7433 k_MONTHLY,29.99999,
7434 k_QUARTERLY,89.99999,0.99999) end_date_time, --bug 3596869
7435 DECODE(x_Sched_rec.schedule_purpose,
7436 k_ADD,DECODE(rla_schedule_type_code,
7437 x_Group_rec.schedule_type_one, 3,
7438 x_Group_rec.schedule_type_two, 2,
7439 x_Group_rec.schedule_type_three, 1),
7440 DECODE(rla_schedule_type_code,
7441 x_Group_rec.schedule_type_one, 1,
7442 x_Group_rec.schedule_type_two, 2,
7443 x_Group_rec.schedule_type_three, 3)) schedule_hierarchy
7444 FROM oe_order_lines
7445 WHERE header_id = x_Group_rec.order_header_id
7446 AND open_flag = 'Y' /*2263270*/
7447 --global_atp
7448 AND ship_from_org_id =
7449 DECODE(g_ATP, k_ATP, ship_from_org_id,
7450 x_Group_rec.ship_from_org_id)
7451 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7452 AND ordered_item_id = x_Group_rec.customer_item_id
7453 AND inventory_item_id = x_Group_rec.inventory_item_id
7454 AND NVL(intmed_ship_to_org_id,k_NNULL)= NVL(x_Group_rec.intmed_ship_to_org_id,k_NNULL) --Bugfix 5911991
7455 --global_atp
7456 AND NVL(industry_attribute15, k_VNULL) =
7457 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7458 NVL(x_Group_rec.industry_attribute15, k_VNULL))
7459 --bug 4223359
7460 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS') BETWEEN /*bug3879857*/
7461 DECODE(authorized_to_ship_flag,k_ATS,
7462 DECODE(x_group_rec.disposition_code,
7463 k_REMAIN_ON_FILE, x_Sched_rec.sched_horizon_start_date,
7464 k_REMAIN_ON_FILE_RECONCILE, to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS'),
7465 TRUNC(rlm_dp_sv.g_dsp_start_time) - nvl(x_Group_rec.Cutoff_days,0)), TRUNC(rlm_dp_sv.g_dsp_start_time)) --Bugfix 10053830
7466 AND TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999
7467 --bug 2022158 (issue with sched_horizon_end_date timestamp)
7468 AND DECODE(x_Sched_rec.schedule_purpose,
7469 k_ADD, DECODE(rla_schedule_type_code,
7470 x_Group_rec.schedule_type_one, 2,
7471 x_Group_rec.schedule_type_two, 3,
7472 x_Group_rec.schedule_type_three, 4,0),
7473 DECODE(rla_schedule_type_code,
7474 x_Group_rec.schedule_type_one, 1,
7475 x_Group_rec.schedule_type_two, 2,
7476 x_Group_rec.schedule_type_three, 3,0)) <=
7477 DECODE(x_Sched_rec.schedule_type, x_Group_rec.schedule_type_one, 1,
7478 x_Group_rec.schedule_type_two, 2,
7479 x_Group_rec.schedule_type_three, 3)
7480 AND DECODE(x_Sched_rec.schedule_purpose,
7481 k_ADD,authorized_to_ship_flag,
7482 'N') = 'N'
7483 AND (NVL(ordered_quantity,0) - NVL(shipped_quantity,0) > 0)
7484 ORDER BY demand_bucket_type_code, schedule_hierarchy, end_date_time;
7485 --
7486 v_Quantity NUMBER;
7487 j NUMBER;
7488 v_Index NUMBER;
7489 v_Count NUMBER;
7490 v_Key_rec t_Key_rec;
7491 v_DeleteQty NUMBER;
7492 c_NewReq_ref t_Cursor_ref;
7493 v_Qty_rec t_Qty_rec;
7494 v_qty NUMBER;
7495 v_consume_quantity NUMBER;
7496 v_newref_qty NUMBER;
7497 v_newref_line_id RLM_INTERFACE_LINES.LINE_ID%TYPE;
7498 v_line_id RLM_INTERFACE_LINES.LINE_ID%TYPE;
7499 c_consume_ref t_Cursor_ref;
7500 v_consume_line_tab t_consume_tab;
7501 x_progress VARCHAR2(3) := '010';
7502 v_line_num oe_order_lines.line_number%type;
7503 e_WrongSchedType EXCEPTION;
7504 c_OldDemand_rec t_OEDemand_rec;
7505 v_ATS_start_date DATE;
7506 v_NATS_start_date DATE;
7507 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
7508 v_del_line_qty NUMBER :=0; --Bugfix 6159269
7509 --
7510 BEGIN
7511 --
7512 IF (l_debug <> -1) THEN
7513 rlm_core_sv.dpush(k_SDEBUG,'ProcessOld');
7514 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
7515 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
7516 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
7517 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',
7518 x_Group_rec.inventory_item_id);
7519 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id',
7520 x_Group_rec.ship_to_org_id);
7521 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_one', x_Group_rec.schedule_type_one);
7522 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_two',
7523 x_Group_rec.schedule_type_two);
7524 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.schedule_type_three',
7525 x_Group_rec.schedule_type_three);
7526 END IF;
7527 --
7528 /* We need to initialize the consume tab before the oldrec because the
7529 line should be matched against all old lines and consumed accordingly */
7530 --
7531 v_consume_line_tab.DELETE;
7532 --
7533 --
7534 -- FP Bug 3933822 jckwok
7535 IF (TRUNC(rlm_dp_sv.g_dsp_start_time) > x_Sched_rec.sched_horizon_start_date) --Bugfix 10053830
7536 THEN
7537 IF (x_group_rec.disposition_code = k_REMAIN_ON_FILE)
7538 THEN
7539 v_ATS_start_date := x_Sched_rec.sched_horizon_start_date;
7540 ELSIF (x_group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS)
7541 THEN
7542 v_ATS_start_date := TRUNC(rlm_dp_sv.g_dsp_start_time) - nvl(x_Group_rec.Cutoff_days,0); --Bugfix 10053830
7543 ELSE
7544 v_ATS_start_date := TRUNC(rlm_dp_sv.g_dsp_start_time); --Bugfix 10053830
7545 END IF;
7546
7547 v_NATS_start_date := TRUNC(rlm_dp_sv.g_dsp_start_time); --Bugfix 10053830
7548 ELSE
7549 v_ATS_start_date := x_Sched_rec.sched_horizon_start_date;
7550 v_NATS_start_date := x_Sched_rec.sched_horizon_start_date;
7551 END IF;
7552
7553 IF (l_debug <> -1) THEN
7554 rlm_core_sv.dlog(k_DEBUG,'x_ATS_start_date', v_ATS_start_date);
7555 rlm_core_sv.dlog(k_DEBUG,'x_NATS_start_date', v_NATS_start_date);
7556 END IF;
7557
7558 OPEN c_OldDemand(v_ATS_start_date , v_NATS_start_date);
7559 --End of FP Bug 3933822 changes --jckwok
7560 FETCH c_OldDemand INTO c_OldDemand_rec;
7561 WHILE c_OldDemand%FOUND LOOP
7562 --
7563 BEGIN
7564 --
7565 IF NVL(c_OldDemand_rec.rla_schedule_type_code, ' ')
7566 NOT IN (x_Group_rec.schedule_type_one,
7567 x_Group_rec.schedule_type_two,
7568 x_Group_rec.schedule_type_three)
7569 THEN
7570 RAISE e_WrongSchedType;
7571 END IF;
7572
7573 --
7574 IF (l_debug <> -1) THEN
7575 rlm_core_sv.dlog(k_DEBUG, '-------------------------------------------');
7576 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.line_id', c_OldDemand_rec.line_id);
7577 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_hierarchy',
7578 c_OldDemand_rec.schedule_hierarchy);
7579 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.end_date_time',
7580 c_OldDemand_rec.end_date_time);
7581 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_ship_date',
7582 c_OldDemand_rec.schedule_ship_date);
7583 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.request_date', c_OldDemand_rec.request_date);
7584 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.rla_schedule_type_code',
7585 c_OldDemand_rec.rla_schedule_type_code);
7586 END IF;
7587
7588 --
7589 /* We do need to select based on the item detail subtype as the weekly
7590 demand needs to be consumed by the daily demand as the weekly demand needs
7591 to be replaced by daily. Also we need to take into account the
7592 schedule date between old demands schedule date and end date.
7593 We have taken item_detail_type <= demand.item_method_type so that
7594 firm demand is never replaced by forecast data */
7595 --
7596 OPEN c_NewReq_ref FOR
7597 SELECT line_id, primary_quantity
7598 FROM rlm_interface_lines_all -- Bug 5223933
7599 WHERE header_id = x_Sched_rec.header_id
7600 --global_atp
7601 AND ship_from_org_id = x_Group_rec.ship_from_org_id
7602 AND ship_to_org_id = x_Group_rec.ship_to_org_id
7603 AND customer_item_id = x_Group_rec.customer_item_id
7604 AND inventory_item_id= x_Group_rec.inventory_item_id
7605 AND order_header_id= x_Group_rec.order_header_id
7606 AND item_detail_subtype = c_OldDemand_rec.demand_bucket_type_code
7607 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
7608 rlm_core_sv.k_PS_FROZEN_FIRM)
7609 --bug 2031077
7610 --AND NVL(invoice_to_org_id, k_NNULL) =
7611 -- NVL(c_OldDemand_rec.invoice_to_org_id, k_NNULL)
7612 -- bug 4502559
7613 AND NVL(intmed_ship_to_org_id, k_NNULL) =
7614 NVL(c_OldDemand_rec.intmed_ship_to_org_id, k_NNULL)
7615 AND NVL(ship_to_org_id, k_NNULL) =
7616 NVL(c_OldDemand_rec.ship_to_org_id, k_NNULL)
7617 AND NVL(cust_production_line, k_VNULL) =
7618 DECODE(x_Group_rec.match_across_rec.cust_production_line, 'Y',
7619 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7620 DECODE(x_Group_rec.match_within_rec.cust_production_line, 'Y',
7621 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7622 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
7623 NVL(cust_production_line, k_VNULL)),
7624 NVL(cust_production_line, k_VNULL)))
7625 AND NVL(customer_dock_code, k_VNULL) =
7626 DECODE(x_Group_rec.match_across_rec.customer_dock_code, 'Y',
7627 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7628 DECODE(x_Group_rec.match_within_rec.customer_dock_code, 'Y',
7629 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7630 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
7631 NVL(customer_dock_code, k_VNULL)),
7632 NVL(customer_dock_code, k_VNULL)))
7633 AND NVL(request_date, k_DNULL) =
7634 DECODE(x_Group_rec.match_across_rec.request_date, 'Y',
7635 NVL(c_OldDemand_rec.request_date, k_DNULL),
7636 DECODE(x_Group_rec.match_within_rec.request_date, 'Y',
7637 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7638 NVL(c_OldDemand_rec.request_date, k_DNULL),
7639 NVL(request_date, k_DNULL)),
7640 NVL(request_date, k_DNULL)))
7641 AND NVL(cust_po_number, k_VNULL) =
7642 DECODE(x_Group_rec.match_across_rec.cust_po_number, 'Y',
7643 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7644 DECODE(x_Group_rec.match_within_rec.cust_po_number, 'Y',
7645 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7646 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
7647 NVL(cust_po_number, k_VNULL)),
7648 NVL(cust_po_number, k_VNULL)))
7649 AND NVL(customer_item_revision, k_VNULL) =
7650 DECODE(x_Group_rec.match_across_rec.customer_item_revision, 'Y',
7651 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7652 DECODE(x_Group_rec.match_within_rec.customer_item_revision, 'Y',
7653 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7654 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
7655 NVL(customer_item_revision, k_VNULL)),
7656 NVL(customer_item_revision, k_VNULL)))
7657 AND NVL(customer_job, k_VNULL) =
7658 DECODE(x_Group_rec.match_across_rec.customer_job, 'Y',
7659 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7660 DECODE(x_Group_rec.match_within_rec.customer_job, 'Y',
7661 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7662 NVL(c_OldDemand_rec.customer_job, k_VNULL),
7663 NVL(customer_job, k_VNULL)),
7664 NVL(customer_job, k_VNULL)))
7665 AND NVL(cust_model_serial_number, k_VNULL) =
7666 DECODE(x_Group_rec.match_across_rec.cust_model_serial_number, 'Y',
7667 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7668 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number, 'Y',
7669 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7670 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
7671 NVL(cust_model_serial_number, k_VNULL)),
7672 NVL(cust_model_serial_number, k_VNULL)))
7673 AND NVL(cust_production_seq_num, k_VNULL) =
7674 DECODE(x_Group_rec.match_across_rec.cust_production_seq_num, 'Y',
7675 NVL(c_OldDemand_rec.cust_production_seq_num, k_VNULL),
7676 DECODE(x_Group_rec.match_within_rec.cust_production_seq_num, 'Y',
7677 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7678 NVL(c_OldDemand_rec.cust_production_seq_num, k_VNULL),
7679 NVL(cust_production_seq_num, k_VNULL)),
7680 NVL(cust_production_seq_num, k_VNULL)))
7681 AND NVL(industry_attribute1, k_VNULL) =
7682 DECODE(x_Group_rec.match_across_rec.industry_attribute1, 'Y',
7683 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7684 DECODE(x_Group_rec.match_within_rec.industry_attribute1, 'Y',
7685 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7686 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
7687 NVL(industry_attribute1, k_VNULL)),
7688 NVL(industry_attribute1, k_VNULL)))
7689 AND NVL(industry_attribute2, k_VNULL) =
7690 DECODE(x_Group_rec.match_across_rec.industry_attribute2, 'Y',
7691 NVL(c_OldDemand_rec.industry_attribute2, k_VNULL),
7692 DECODE(x_Group_rec.match_within_rec.industry_attribute2, 'Y',
7693 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7694 NVL(c_OldDemand_rec.industry_attribute2, k_VNULL),
7695 NVL(industry_attribute2, k_VNULL)),
7696 NVL(industry_attribute2, k_VNULL)))
7697 AND NVL(industry_attribute4, k_VNULL) =
7698 DECODE(x_Group_rec.match_across_rec.industry_attribute4, 'Y',
7699 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7700 DECODE(x_Group_rec.match_within_rec.industry_attribute4, 'Y',
7701 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7702 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
7703 NVL(industry_attribute4, k_VNULL)),
7704 NVL(industry_attribute4, k_VNULL)))
7705 AND NVL(industry_attribute5, k_VNULL) =
7706 DECODE(x_Group_rec.match_across_rec.industry_attribute5, 'Y',
7707 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7708 DECODE(x_Group_rec.match_within_rec.industry_attribute5, 'Y',
7709 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7710 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
7711 NVL(industry_attribute5, k_VNULL)),
7712 NVL(industry_attribute5, k_VNULL)))
7713 AND NVL(industry_attribute6, k_VNULL) =
7714 DECODE(x_Group_rec.match_across_rec.industry_attribute6, 'Y',
7715 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7716 DECODE(x_Group_rec.match_within_rec.industry_attribute6, 'Y',
7717 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7718 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
7719 NVL(industry_attribute6, k_VNULL)),
7720 NVL(industry_attribute6, k_VNULL)))
7721 AND NVL(industry_attribute10, k_VNULL) =
7722 DECODE(x_Group_rec.match_across_rec.industry_attribute10, 'Y',
7723 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7724 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y',
7725 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7726 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
7727 NVL(industry_attribute10, k_VNULL)),
7728 NVL(industry_attribute10, k_VNULL)))
7729 AND NVL(industry_attribute11, k_VNULL) =
7730 DECODE(x_Group_rec.match_across_rec.industry_attribute11, 'Y',
7731 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
7732 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y',
7733 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7734 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
7735 NVL(industry_attribute11, k_VNULL)),
7736 NVL(industry_attribute11, k_VNULL)))
7737 AND NVL(industry_attribute12, k_VNULL) =
7738 DECODE(x_Group_rec.match_across_rec.industry_attribute12, 'Y',
7739 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
7740 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y',
7741 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7742 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
7743 NVL(industry_attribute12, k_VNULL)),
7744 NVL(industry_attribute12, k_VNULL)))
7745 AND NVL(industry_attribute13, k_VNULL) =
7746 DECODE(x_Group_rec.match_across_rec.industry_attribute13, 'Y',
7747 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
7748 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y',
7749 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7750 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
7751 NVL(industry_attribute13, k_VNULL)),
7752 NVL(industry_attribute13, k_VNULL)))
7753 AND NVL(industry_attribute14, k_VNULL) =
7754 DECODE(x_Group_rec.match_across_rec.industry_attribute14, 'Y',
7755 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
7756 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y',
7757 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7758 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
7759 NVL(industry_attribute14, k_VNULL)),
7760 NVL(industry_attribute14, k_VNULL)))
7761 --global_atp?
7762 AND NVL(industry_attribute15, k_VNULL) =
7763 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
7764 NVL(c_OldDemand_rec.industry_attribute15, k_VNULL))
7765 AND NVL(attribute1, k_VNULL) =
7766 DECODE(x_Group_rec.match_across_rec.attribute1, 'Y',
7767 NVL(c_OldDemand_rec.attribute1, k_VNULL),
7768 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y',
7769 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7770 NVL(c_OldDemand_rec.attribute1, k_VNULL),
7771 NVL(attribute1, k_VNULL)),
7772 NVL(attribute1, k_VNULL)))
7773 AND NVL(attribute2, k_VNULL) =
7774 DECODE(x_Group_rec.match_across_rec.attribute2, 'Y',
7775 NVL(c_OldDemand_rec.attribute2, k_VNULL),
7776 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y',
7777 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7778 NVL(c_OldDemand_rec.attribute2, k_VNULL),
7779 NVL(attribute2, k_VNULL)),
7780 NVL(attribute2, k_VNULL)))
7781 AND NVL(attribute3, k_VNULL) =
7782 DECODE(x_Group_rec.match_across_rec.attribute3, 'Y',
7783 NVL(c_OldDemand_rec.attribute3, k_VNULL),
7784 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y',
7785 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7786 NVL(c_OldDemand_rec.attribute3, k_VNULL),
7787 NVL(attribute3, k_VNULL)),
7788 NVL(attribute3, k_VNULL)))
7789 AND NVL(attribute4, k_VNULL) =
7790 DECODE(x_Group_rec.match_across_rec.attribute4, 'Y',
7791 NVL(c_OldDemand_rec.attribute4, k_VNULL),
7792 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y',
7793 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7794 NVL(c_OldDemand_rec.attribute4, k_VNULL),
7795 NVL(attribute4, k_VNULL)),
7796 NVL(attribute4, k_VNULL)))
7797 AND NVL(attribute5, k_VNULL) =
7798 DECODE(x_Group_rec.match_across_rec.attribute5, 'Y',
7799 NVL(c_OldDemand_rec.attribute5, k_VNULL),
7800 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y',
7801 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7802 NVL(c_OldDemand_rec.attribute5, k_VNULL),
7803 NVL(attribute5, k_VNULL)),
7804 NVL(attribute5, k_VNULL)))
7805 AND NVL(attribute6, k_VNULL) =
7806 DECODE(x_Group_rec.match_across_rec.attribute6, 'Y',
7807 NVL(c_OldDemand_rec.attribute6, k_VNULL),
7808 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y',
7809 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7810 NVL(c_OldDemand_rec.attribute6, k_VNULL),
7811 NVL(attribute6, k_VNULL)),
7812 NVL(attribute6, k_VNULL)))
7813 AND NVL(attribute7, k_VNULL) =
7814 DECODE(x_Group_rec.match_across_rec.attribute7, 'Y',
7815 NVL(c_OldDemand_rec.attribute7, k_VNULL),
7816 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y',
7817 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7818 NVL(c_OldDemand_rec.attribute7, k_VNULL),
7819 NVL(attribute7, k_VNULL)),
7820 NVL(attribute7, k_VNULL)))
7821 AND NVL(attribute8, k_VNULL) =
7822 DECODE(x_Group_rec.match_across_rec.attribute8, 'Y',
7823 NVL(c_OldDemand_rec.attribute8, k_VNULL),
7824 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y',
7825 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7826 NVL(c_OldDemand_rec.attribute8, k_VNULL),
7827 NVL(attribute8, k_VNULL)),
7828 NVL(attribute8, k_VNULL)))
7829 AND NVL(attribute9, k_VNULL) =
7830 DECODE(x_Group_rec.match_across_rec.attribute9, 'Y',
7831 NVL(c_OldDemand_rec.attribute9, k_VNULL),
7832 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y',
7833 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7834 NVL(c_OldDemand_rec.attribute9, k_VNULL),
7835 NVL(attribute9, k_VNULL)),
7836 NVL(attribute9, k_VNULL)))
7837 AND NVL(attribute10, k_VNULL) =
7838 DECODE(x_Group_rec.match_across_rec.attribute10, 'Y',
7839 NVL(c_OldDemand_rec.attribute10, k_VNULL),
7840 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y',
7841 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7842 NVL(c_OldDemand_rec.attribute10, k_VNULL),
7843 NVL(attribute10, k_VNULL)),
7844 NVL(attribute10, k_VNULL)))
7845 AND NVL(attribute11, k_VNULL) =
7846 DECODE(x_Group_rec.match_across_rec.attribute11, 'Y',
7847 NVL(c_OldDemand_rec.attribute11, k_VNULL),
7848 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y',
7849 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7850 NVL(c_OldDemand_rec.attribute11, k_VNULL),
7851 NVL(attribute11, k_VNULL)),
7852 NVL(attribute11, k_VNULL)))
7853 AND NVL(attribute12, k_VNULL) =
7854 DECODE(x_Group_rec.match_across_rec.attribute12, 'Y',
7855 NVL(c_OldDemand_rec.attribute12, k_VNULL),
7856 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y',
7857 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7858 NVL(c_OldDemand_rec.attribute12, k_VNULL),
7859 NVL(attribute12, k_VNULL)),
7860 NVL(attribute12, k_VNULL)))
7861 AND NVL(attribute13, k_VNULL) =
7862 DECODE(x_Group_rec.match_across_rec.attribute13, 'Y',
7863 NVL(c_OldDemand_rec.attribute13, k_VNULL),
7864 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y',
7865 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7866 NVL(c_OldDemand_rec.attribute13, k_VNULL),
7867 NVL(attribute13, k_VNULL)),
7868 NVL(attribute13, k_VNULL)))
7869 AND NVL(attribute14, k_VNULL) =
7870 DECODE(x_Group_rec.match_across_rec.attribute14, 'Y',
7871 NVL(c_OldDemand_rec.attribute14, k_VNULL),
7872 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y',
7873 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7874 NVL(c_OldDemand_rec.attribute14, k_VNULL),
7875 NVL(attribute14, k_VNULL)),
7876 NVL(attribute14, k_VNULL)))
7877 AND NVL(attribute15, k_VNULL) =
7878 DECODE(x_Group_rec.match_across_rec.attribute15, 'Y',
7879 NVL(c_OldDemand_rec.attribute15, k_VNULL),
7880 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y',
7881 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
7882 NVL(c_OldDemand_rec.attribute15, k_VNULL),
7883 NVL(attribute15, k_VNULL)),
7884 NVL(attribute15, k_VNULL)));
7885 --
7886 FETCH c_NewReq_ref INTO v_newref_line_id, v_newref_qty;
7887 --
7888 IF (l_debug <> -1) THEN
7889 rlm_core_sv.dlog(k_DEBUG,'v_consume_quantity',v_consume_quantity);
7890 rlm_core_sv.dlog(k_DEBUG,'v_Count',v_Count);
7891 rlm_core_sv.dlog(k_DEBUG,'c_NewReq_ref%ROWCOUNT',c_NewReq_ref%ROWCOUNT);
7892 rlm_core_sv.dlog(k_DEBUG,'c_NewReq_ref%NOTFOUND',c_NewReq_ref%NOTFOUND);
7893 END IF;
7894 --
7895 IF c_NewReq_ref%NOTFOUND OR x_Sched_rec.schedule_purpose = k_ADD THEN
7896 --
7897 IF (l_debug <> -1) THEN
7898 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date',
7899 x_Sched_rec.sched_horizon_end_date);
7900 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.end_date_time',
7901 c_OldDemand_rec.end_date_time);
7902 END IF;
7903 --
7904 --pdue
7905 IF x_Sched_rec.schedule_source <> 'MANUAL' AND
7906 --Bugfix 10053830 Start
7907 /*IsFrozen(TRUNC(SYSDATE), x_Group_rec, c_OldDemand_rec.request_date)*/
7908 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, c_OldDemand_rec.request_date)
7909 --Bugfix 10053830 End
7910 AND x_Sched_rec.schedule_purpose <> k_ADD THEN
7911 --
7912 IF (l_debug <> -1) THEN
7913 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.line_id',
7914 c_OldDemand_rec.line_id);
7915 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.request_date',
7916 c_OldDemand_rec.request_date);
7917 rlm_core_sv.dlog(k_DEBUG,'c_OldDemand_rec.schedule_ship_date',
7918 c_OldDemand_rec.schedule_ship_date);
7919 END IF;
7920 --
7921 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
7922 StoreReconcile(x_Sched_rec, x_Group_rec, v_Key_rec,
7923 c_OldDemand_rec.ordered_quantity);
7924 --
7925 -- Bug 4297984 Start
7926 GetMatchAttributes(x_sched_rec,x_group_rec, v_Key_rec.dem_rec,v_MatchAttrTxt);
7927 --
7928 IF (c_OldDemand_rec.rla_schedule_type_code = 'SEQUENCED') THEN
7929 --
7930 rlm_message_sv.app_error(
7931 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7932 x_MessageName => 'RLM_FROZEN_DELETE_SEQ',
7933 x_InterfaceHeaderId => x_sched_rec.header_id,
7934 x_InterfaceLineId => NULL,
7935 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7936 x_ScheduleLineId => NULL,
7937 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
7938 x_OrderLineId => c_OldDemand_rec.line_id,
7939 x_Token1 => 'LINE',
7940 x_value1 => rlm_core_sv.get_order_line_number(c_OldDemand_rec.line_id),
7941 x_Token2 => 'ORDER',
7942 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
7943 x_Token3 => 'QUANTITY',
7944 x_value3 => c_OldDemand_rec.ordered_quantity,
7945 x_Token4 => 'CUSTITEM',
7946 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
7947 x_Token5 => 'REQ_DATE',
7948 x_value5 => c_OldDemand_rec.request_date,
7949 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
7950 x_value6 => v_del_line_qty, --Bugfix 6159269
7951 x_Token7 => 'SEQ_INFO',
7952 x_value7 => nvl(c_OldDemand_rec.cust_production_seq_num,'NULL') ||'-'||
7953 nvl(c_OldDemand_rec.cust_model_serial_number,'NULL')||'-'||
7954 nvl(c_OldDemand_rec.customer_job,'NULL'),
7955 x_Token8 => 'MATCH_ATTR',
7956 x_value8 => v_MatchAttrTxt);
7957 --
7958 IF (l_debug <> -1) THEN
7959 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE_SEQ',
7960 c_OldDemand_rec.line_id);
7961 END IF;
7962 --
7963 ELSE
7964 --
7965 rlm_message_sv.app_error(
7966 x_ExceptionLevel => rlm_message_sv.k_warn_level,
7967 x_MessageName => 'RLM_FROZEN_DELETE',
7968 x_InterfaceHeaderId => x_sched_rec.header_id,
7969 x_InterfaceLineId => NULL,
7970 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
7971 x_ScheduleLineId => NULL,
7972 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
7973 x_OrderLineId => c_OldDemand_rec.line_id,
7974 x_Token1 => 'LINE',
7975 x_value1 => rlm_core_sv.get_order_line_number(c_OldDemand_rec.line_id),
7976 x_Token2 => 'ORDER',
7977 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
7978 x_Token3 => 'QUANTITY',
7979 x_value3 => c_OldDemand_rec.ordered_quantity,
7980 x_Token4 => 'CUSTITEM',
7981 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
7982 x_Token5 => 'REQ_DATE',
7983 x_value5 => c_OldDemand_rec.request_date,
7984 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
7985 x_value6 => v_del_line_qty, --Bugfix 6159269
7986 x_Token7 => 'MATCH_ATTR',
7987 x_value7 => v_MatchAttrTxt);
7988 --
7989 IF (l_debug <> -1) THEN
7990 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_DELETE',
7991 c_OldDemand_rec.line_id);
7992 END IF;
7993 --
7994 END IF;
7995 -- Bug 4297984 End
7996 --
7997 ELSIF TRUNC(x_Sched_rec.sched_horizon_end_date) + 0.99999
7998 >= TRUNC(c_OldDemand_rec.end_date_time) AND
7999 x_Sched_rec.schedule_purpose <> k_ADD THEN
8000 --bug 1680657
8001 --
8002 IF (l_debug <> -1) THEN
8003 rlm_core_sv.dlog(k_DEBUG,'in no consume delete ');
8004 END IF;
8005 --
8006 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
8007 --
8008 v_Key_rec.req_rec := v_Key_rec.dem_rec;
8009 --
8010 DeleteRequirement(x_Sched_rec, x_Group_rec,
8011 v_Key_rec, k_RECONCILE, v_DeleteQty);
8012 --
8013 ELSE
8014 --
8015 IF (l_debug <> -1) THEN
8016 rlm_core_sv.dlog(k_DEBUG,'In consume -- c_OldDemand_rec.end_date_time',
8017 c_OldDemand_rec.end_date_time);
8018 END IF;
8019 --
8020 /* Consume demand -- We may need to loop through the new demand
8021 recs because there could be a case where
8022 we have multiple new lines which need to be consumed as 2
8023 or more old demands fall outside the new horizon and
8024 so we need to keep a track of which lines are consumed
8025 already and then consume the demand as it comes in. */
8026 --
8027 OPEN c_consume_ref FOR
8028 SELECT line_id, primary_quantity
8029 FROM rlm_interface_lines
8030 WHERE header_id = x_Sched_rec.header_id
8031 --global_atp
8032 AND ship_from_org_id = x_Group_rec.ship_from_org_id
8033 AND ship_to_org_id = x_Group_rec.ship_to_org_id
8034 AND customer_item_id = x_Group_rec.customer_item_id
8035 AND inventory_item_id= x_Group_rec.inventory_item_id
8036 AND order_header_id= x_Group_rec.order_header_id
8037 /*AND nvl(cust_production_seq_num, k_VNULL)=
8038 nvl(x_Group_rec.cust_production_seq_num,k_VNULL)*/
8039 AND item_detail_type in (
8040 DECODE(x_Sched_rec.schedule_purpose,
8041 k_ADD,
8042 1,0),
8043 DECODE(x_Sched_rec.schedule_purpose,
8044 k_ADD,
8045 0,1),DECODE(x_Sched_rec.schedule_purpose,
8046 k_ADD,
8047 0,2))
8048 AND DECODE(x_Sched_rec.schedule_purpose,
8049 k_ADD,
8050 item_detail_subtype,
8051 DECODE(item_detail_subtype,'AHEAD_BEHIND', k_LARGE,
8052 'CUM', k_LARGE, 'FINISHED', k_LARGE,
8053 'HOLDOUT_QTY', k_LARGE, 'INVENTORY_BAL', k_LARGE,
8054 'LABOR', k_LARGE, 'LABOR_MATERIAL', k_LARGE,
8055 'MATERIAL', k_LARGE, 'PRIOR_CUM_REQ', k_LARGE,
8056 'RECEIPT', k_LARGE, 'SHIPMENT', k_LARGE,
8057 item_detail_subtype)
8058 +1)
8059 <= c_OldDemand_rec.demand_bucket_type_code
8060 -- AND request_date BETWEEN c_OldDemand_rec.request_date --Bugfix 10277088
8061 AND to_date(industry_attribute2,'RRRR/MM/DD HH24:MI:SS') BETWEEN to_date(c_OldDemand_rec.industry_attribute2,'RRRR/MM/DD HH24:MI:SS') --Bugfix 10277088
8062 AND c_OldDemand_rec.end_date_time
8063 AND process_status = rlm_core_sv.k_PS_AVAILABLE
8064 --bug 2031077
8065 --AND NVL(invoice_to_org_id, k_NNULL) =
8066 -- NVL(c_OldDemand_rec.invoice_to_org_id, k_NNULL)
8067 AND NVL(intmed_ship_to_org_id, k_NNULL) =
8068 NVL(c_OldDemand_rec.intmed_ship_to_org_id, k_NNULL)
8069 /* including matching critera */
8070 AND NVL(cust_production_line, k_VNULL) =
8071 DECODE(x_Group_rec.match_across_rec.cust_production_line, 'Y',
8072 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
8073 DECODE(x_Group_rec.match_within_rec.cust_production_line, 'Y',
8074 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8075 NVL(c_OldDemand_rec.cust_production_line, k_VNULL),
8076 NVL(cust_production_line, k_VNULL)),
8077 NVL(cust_production_line, k_VNULL)))
8078 AND NVL(customer_dock_code, k_VNULL) =
8079 DECODE(x_Group_rec.match_across_rec.customer_dock_code, 'Y',
8080 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
8081 DECODE(x_Group_rec.match_within_rec.customer_dock_code, 'Y',
8082 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8083 NVL(c_OldDemand_rec.customer_dock_code, k_VNULL),
8084 NVL(customer_dock_code, k_VNULL)),
8085 NVL(customer_dock_code, k_VNULL)))
8086
8087 /* Fix for Bug #: 1588331
8088 For consumption, do not use request_date as a
8089 matching attribute across schedules */
8090
8091 AND NVL(cust_po_number, k_VNULL) =
8092 DECODE(x_Group_rec.match_across_rec.cust_po_number, 'Y',
8093 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
8094 DECODE(x_Group_rec.match_within_rec.cust_po_number, 'Y',
8095 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8096 NVL(c_OldDemand_rec.cust_po_number, k_VNULL),
8097 NVL(cust_po_number, k_VNULL)),
8098 NVL(cust_po_number, k_VNULL)))
8099 AND NVL(customer_item_revision, k_VNULL) =
8100 DECODE(x_Group_rec.match_across_rec.customer_item_revision, 'Y',
8101 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
8102 DECODE(x_Group_rec.match_within_rec.customer_item_revision, 'Y',
8103 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8104 NVL(c_OldDemand_rec.customer_item_revision, k_VNULL),
8105 NVL(customer_item_revision, k_VNULL)),
8106 NVL(customer_item_revision, k_VNULL)))
8107 AND NVL(customer_job, k_VNULL) =
8108 DECODE(x_Group_rec.match_across_rec.customer_job, 'Y',
8109 NVL(c_OldDemand_rec.customer_job, k_VNULL),
8110 DECODE(x_Group_rec.match_within_rec.customer_job, 'Y',
8111 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8112 NVL(c_OldDemand_rec.customer_job, k_VNULL),
8113 NVL(customer_job, k_VNULL)),
8114 NVL(customer_job, k_VNULL)))
8115 AND NVL(cust_model_serial_number, k_VNULL) =
8116 DECODE(x_Group_rec.match_across_rec.cust_model_serial_number, 'Y',
8117 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
8118 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number, 'Y',
8119 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8120 NVL(c_OldDemand_rec.cust_model_serial_number, k_VNULL),
8121 NVL(cust_model_serial_number, k_VNULL)),
8122 NVL(cust_model_serial_number, k_VNULL)))
8123 AND NVL(industry_attribute1, k_VNULL) =
8124 DECODE(x_Group_rec.match_across_rec.industry_attribute1, 'Y',
8125 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
8126 DECODE(x_Group_rec.match_within_rec.industry_attribute1, 'Y',
8127 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8128 NVL(c_OldDemand_rec.industry_attribute1, k_VNULL),
8129 NVL(industry_attribute1, k_VNULL)),
8130 NVL(industry_attribute1, k_VNULL)))
8131
8132 /* Fix for Bug #: 1588331
8133 For consumption, do not use industry_attribute2 as a
8134 matching attribute across schedules. */
8135
8136 AND NVL(industry_attribute4, k_VNULL) =
8137 DECODE(x_Group_rec.match_across_rec.industry_attribute4, 'Y',
8138 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
8139 DECODE(x_Group_rec.match_within_rec.industry_attribute4, 'Y',
8140 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8141 NVL(c_OldDemand_rec.industry_attribute4, k_VNULL),
8142 NVL(industry_attribute4, k_VNULL)),
8143 NVL(industry_attribute4, k_VNULL)))
8144 AND NVL(industry_attribute5, k_VNULL) =
8145 DECODE(x_Group_rec.match_across_rec.industry_attribute5, 'Y',
8146 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
8147 DECODE(x_Group_rec.match_within_rec.industry_attribute5, 'Y',
8148 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8149 NVL(c_OldDemand_rec.industry_attribute5, k_VNULL),
8150 NVL(industry_attribute5, k_VNULL)),
8151 NVL(industry_attribute5, k_VNULL)))
8152 AND NVL(industry_attribute6, k_VNULL) =
8153 DECODE(x_Group_rec.match_across_rec.industry_attribute6, 'Y',
8154 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
8155 DECODE(x_Group_rec.match_within_rec.industry_attribute6, 'Y',
8156 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8157 NVL(c_OldDemand_rec.industry_attribute6, k_VNULL),
8158 NVL(industry_attribute6, k_VNULL)),
8159 NVL(industry_attribute6, k_VNULL)))
8160 AND NVL(industry_attribute10, k_VNULL) =
8161 DECODE(x_Group_rec.match_across_rec.industry_attribute10, 'Y',
8162 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
8163 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y',
8164 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8165 NVL(c_OldDemand_rec.industry_attribute10, k_VNULL),
8166 NVL(industry_attribute10, k_VNULL)),
8167 NVL(industry_attribute10, k_VNULL)))
8168 AND NVL(industry_attribute11, k_VNULL) =
8169 DECODE(x_Group_rec.match_across_rec.industry_attribute11, 'Y',
8170 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
8171 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y',
8172 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8173 NVL(c_OldDemand_rec.industry_attribute11, k_VNULL),
8174 NVL(industry_attribute11, k_VNULL)),
8175 NVL(industry_attribute11, k_VNULL)))
8176 AND NVL(industry_attribute12, k_VNULL) =
8177 DECODE(x_Group_rec.match_across_rec.industry_attribute12, 'Y',
8178 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
8179 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y',
8180 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8181 NVL(c_OldDemand_rec.industry_attribute12, k_VNULL),
8182 NVL(industry_attribute12, k_VNULL)),
8183 NVL(industry_attribute12, k_VNULL)))
8184 AND NVL(industry_attribute13, k_VNULL) =
8185 DECODE(x_Group_rec.match_across_rec.industry_attribute13, 'Y',
8186 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
8187 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y',
8188 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8189 NVL(c_OldDemand_rec.industry_attribute13, k_VNULL),
8190 NVL(industry_attribute13, k_VNULL)),
8191 NVL(industry_attribute13, k_VNULL)))
8192 AND NVL(industry_attribute14, k_VNULL) =
8193 DECODE(x_Group_rec.match_across_rec.industry_attribute14, 'Y',
8194 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
8195 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y',
8196 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8197 NVL(c_OldDemand_rec.industry_attribute14, k_VNULL),
8198 NVL(industry_attribute14, k_VNULL)),
8199 NVL(industry_attribute14, k_VNULL)))
8200 --global_atp
8201 AND NVL(industry_attribute15, k_VNULL) =
8202 DECODE(g_ATP, k_ATP, NVL(industry_attribute15, k_VNULL),
8203 NVL(c_OldDemand_rec.industry_attribute15, k_VNULL))
8204 AND NVL(attribute1, k_VNULL) =
8205 DECODE(x_Group_rec.match_across_rec.attribute1, 'Y',
8206 NVL(c_OldDemand_rec.attribute1, k_VNULL),
8207 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y',
8208 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8209 NVL(c_OldDemand_rec.attribute1, k_VNULL),
8210 NVL(attribute1, k_VNULL)),
8211 NVL(attribute1, k_VNULL)))
8212 AND NVL(attribute2, k_VNULL) =
8213 DECODE(x_Group_rec.match_across_rec.attribute2, 'Y',
8214 NVL(c_OldDemand_rec.attribute2, k_VNULL),
8215 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y',
8216 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8217 NVL(c_OldDemand_rec.attribute2, k_VNULL),
8218 NVL(attribute2, k_VNULL)),
8219 NVL(attribute2, k_VNULL)))
8220 AND NVL(attribute3, k_VNULL) =
8221 DECODE(x_Group_rec.match_across_rec.attribute3, 'Y',
8222 NVL(c_OldDemand_rec.attribute3, k_VNULL),
8223 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y',
8224 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8225 NVL(c_OldDemand_rec.attribute3, k_VNULL),
8226 NVL(attribute3, k_VNULL)),
8227 NVL(attribute3, k_VNULL)))
8228 AND NVL(attribute4, k_VNULL) =
8229 DECODE(x_Group_rec.match_across_rec.attribute4, 'Y',
8230 NVL(c_OldDemand_rec.attribute4, k_VNULL),
8231 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y',
8232 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8233 NVL(c_OldDemand_rec.attribute4, k_VNULL),
8234 NVL(attribute4, k_VNULL)),
8235 NVL(attribute4, k_VNULL)))
8236 AND NVL(attribute5, k_VNULL) =
8237 DECODE(x_Group_rec.match_across_rec.attribute5, 'Y',
8238 NVL(c_OldDemand_rec.attribute5, k_VNULL),
8239 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y',
8240 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8241 NVL(c_OldDemand_rec.attribute5, k_VNULL),
8242 NVL(attribute5, k_VNULL)),
8243 NVL(attribute5, k_VNULL)))
8244 AND NVL(attribute6, k_VNULL) =
8245 DECODE(x_Group_rec.match_across_rec.attribute6, 'Y',
8246 NVL(c_OldDemand_rec.attribute6, k_VNULL),
8247 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y',
8248 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8249 NVL(c_OldDemand_rec.attribute6, k_VNULL),
8250 NVL(attribute6, k_VNULL)),
8251 NVL(attribute6, k_VNULL)))
8252 AND NVL(attribute7, k_VNULL) =
8253 DECODE(x_Group_rec.match_across_rec.attribute7, 'Y',
8254 NVL(c_OldDemand_rec.attribute7, k_VNULL),
8255 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y',
8256 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8257 NVL(c_OldDemand_rec.attribute7, k_VNULL),
8258 NVL(attribute7, k_VNULL)),
8259 NVL(attribute7, k_VNULL)))
8260 AND NVL(attribute8, k_VNULL) =
8261 DECODE(x_Group_rec.match_across_rec.attribute8, 'Y',
8262 NVL(c_OldDemand_rec.attribute8, k_VNULL),
8263 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y',
8264 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8265 NVL(c_OldDemand_rec.attribute8, k_VNULL),
8266 NVL(attribute8, k_VNULL)),
8267 NVL(attribute8, k_VNULL)))
8268 AND NVL(attribute9, k_VNULL) =
8269 DECODE(x_Group_rec.match_across_rec.attribute9, 'Y',
8270 NVL(c_OldDemand_rec.attribute9, k_VNULL),
8271 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y',
8272 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8273 NVL(c_OldDemand_rec.attribute9, k_VNULL),
8274 NVL(attribute9, k_VNULL)),
8275 NVL(attribute9, k_VNULL)))
8276 AND NVL(attribute10, k_VNULL) =
8277 DECODE(x_Group_rec.match_across_rec.attribute10, 'Y',
8278 NVL(c_OldDemand_rec.attribute10, k_VNULL),
8279 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y',
8280 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8281 NVL(c_OldDemand_rec.attribute10, k_VNULL),
8282 NVL(attribute10, k_VNULL)),
8283 NVL(attribute10, k_VNULL)))
8284 AND NVL(attribute11, k_VNULL) =
8285 DECODE(x_Group_rec.match_across_rec.attribute11, 'Y',
8286 NVL(c_OldDemand_rec.attribute11, k_VNULL),
8287 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y',
8288 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8289 NVL(c_OldDemand_rec.attribute11, k_VNULL),
8290 NVL(attribute11, k_VNULL)),
8291 NVL(attribute11, k_VNULL)))
8292 AND NVL(attribute12, k_VNULL) =
8293 DECODE(x_Group_rec.match_across_rec.attribute12, 'Y',
8294 NVL(c_OldDemand_rec.attribute12, k_VNULL),
8295 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y',
8296 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8297 NVL(c_OldDemand_rec.attribute12, k_VNULL),
8298 NVL(attribute12, k_VNULL)),
8299 NVL(attribute12, k_VNULL)))
8300 AND NVL(attribute13, k_VNULL) =
8301 DECODE(x_Group_rec.match_across_rec.attribute13, 'Y',
8302 NVL(c_OldDemand_rec.attribute13, k_VNULL),
8303 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y',
8304 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8305 NVL(c_OldDemand_rec.attribute13, k_VNULL),
8306 NVL(attribute13, k_VNULL)),
8307 NVL(attribute13, k_VNULL)))
8308 AND NVL(attribute14, k_VNULL) =
8309 DECODE(x_Group_rec.match_across_rec.attribute14, 'Y',
8310 NVL(c_OldDemand_rec.attribute14, k_VNULL),
8311 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y',
8312 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8313 NVL(c_OldDemand_rec.attribute14, k_VNULL),
8314 NVL(attribute14, k_VNULL)),
8315 NVL(attribute14, k_VNULL)))
8316 AND NVL(attribute15, k_VNULL) =
8317 DECODE(x_Group_rec.match_across_rec.attribute15, 'Y',
8318 NVL(c_OldDemand_rec.attribute15, k_VNULL),
8319 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y',
8320 DECODE(c_OldDemand_rec.rla_schedule_type_code, x_Sched_rec.schedule_type,
8321 NVL(c_OldDemand_rec.attribute15, k_VNULL),
8322 NVL(attribute15, k_VNULL)),
8323 NVL(attribute15, k_VNULL)));
8324
8325 /* We need the above query because we could have a case where the
8326 schedule date for both the lines are same but the item detail
8327 subtype is of less granularity in which case we will have
8328 to consume the old quantity, else replace.
8329 Also we do not need to check for non mandatory attributes
8330 in this case as they will be different */
8331 --
8332 v_consume_quantity := 0;
8333 --
8334 j := v_consume_line_tab.COUNT;
8335 --
8336 LOOP
8337 --
8338 FETCH c_consume_ref INTO v_line_id, v_qty;
8339 --
8340 EXIT WHEN c_consume_ref%NOTFOUND;
8341 --
8342 IF (l_debug <> -1) THEN
8343 rlm_core_sv.dlog(k_DEBUG,'consume_ref.v_line_id' , v_line_id);
8344 rlm_core_sv.dlog(k_DEBUG,'consume_ref.v_qty', v_qty);
8345 END IF;
8346 --
8347 IF isLineConsumable(v_consume_line_tab,v_line_id, v_index) THEN
8348 --
8349 j := j + 1;
8350 --
8351 IF c_OldDemand_rec.ordered_quantity >
8352 (v_consume_quantity + v_qty) THEN
8353 --
8354 IF (l_debug <> -1) THEN
8355 rlm_core_sv.dlog(k_DEBUG,'complete consumtion of qty' , v_qty);
8356 END IF;
8357 --
8358 v_consume_line_tab(j).quantity := v_qty;
8359 v_consume_line_tab(j).line_id := v_line_id;
8360 v_consume_quantity := v_consume_quantity + v_qty;
8361 --
8362 IF (l_debug <> -1) THEN
8363 rlm_core_sv.dlog(k_DEBUG,'v_consume_quantity',
8364 v_consume_quantity);
8365 END IF;
8366 --
8367 ELSE
8368 --
8369 v_qty := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8370 --
8371 IF (l_debug <> -1) THEN
8372 rlm_core_sv.dlog(k_DEBUG,'partial consumtion of qty', v_qty);
8373 rlm_core_sv.dlog(k_DEBUG,'partial consumtion of line',v_line_id);
8374 END IF;
8375 --
8376 v_consume_line_tab(j).quantity := v_qty;
8377 v_consume_line_tab(j).line_id := v_line_id;
8378 v_consume_quantity := v_consume_quantity + v_qty;
8379 --
8380 END IF;
8381 --
8382 IF (l_debug <> -1) THEN
8383 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(j).line_id',
8384 v_consume_line_tab(j).line_id);
8385 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(j).quantity',
8386 v_consume_line_tab(j).quantity);
8387 END IF;
8388 --
8389 ELSE
8390 --
8391 /* If the line is not consumable then we need to check if the line
8392 has been partially consumed in which case we need to consume
8393 the remaining qty */
8394 --
8395 IF (l_debug <> -1) THEN
8396 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Index).line_id',
8397 v_consume_line_tab(v_Index).line_id);
8398 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Index).quantity',
8399 v_consume_line_tab(v_Index).quantity);
8400 rlm_core_sv.dlog(k_DEBUG,'quantity for current line v_qty',v_qty);
8401 END IF;
8402 --
8403 IF v_consume_line_tab(v_Index).quantity <> v_qty THEN
8404 --
8405 /* This will ocur when there is partial consumption so
8406 we need to take into account only the difference between the
8407 two quantities */
8408 --
8409 IF (l_debug <> -1) THEN
8410 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line', v_line_id);
8411 END IF;
8412 --
8413 v_qty := v_qty - v_consume_line_tab(v_Index).quantity;
8414 --
8415 IF (l_debug <> -1) THEN
8416 rlm_core_sv.dlog(k_DEBUG,'v_qty',v_qty);
8417 END IF;
8418 --
8419 IF c_OldDemand_rec.ordered_quantity >
8420 (v_consume_quantity + v_qty) THEN
8421 --
8422 IF (l_debug <> -1) THEN
8423 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8424 completely', v_line_id);
8425 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8426 completely qty ', v_qty);
8427 END IF;
8428 --
8429 v_consume_line_tab(v_index).quantity :=
8430 v_consume_line_tab(v_index).quantity + v_qty;
8431 v_consume_quantity := v_consume_quantity + v_qty;
8432 --
8433 ELSE
8434 --
8435 v_qty := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8436 --
8437 IF (l_debug <> -1) THEN
8438 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8439 again partially',v_line_id);
8440 rlm_core_sv.dlog(k_DEBUG,'Consuming partially consumed line
8441 again partially qty ', v_qty);
8442 END IF;
8443 --
8444 v_consume_line_tab(v_index).quantity :=
8445 v_consume_line_tab(v_index).quantity + v_qty;
8446 v_consume_quantity := v_consume_quantity + v_qty;
8447 --
8448 END IF;
8449 --
8450 END IF;
8451 --
8452 END IF;
8453 --
8454 END LOOP;
8455 --
8456 IF (l_debug <> -1) THEN
8457 rlm_core_sv.dlog(k_DEBUG,'Total quantity to be consumed ',
8458 v_consume_quantity);
8459 END IF;
8460 --
8461 IF c_consume_ref%ROWCOUNT = 0 THEN
8462 -- If the rowcount is = 0 means that there are no lines to be consumed
8463 -- If the rowcount is = 0 means that there are no lines to be consumed
8464 -- so the old line needs to be deleted
8465 --
8466 IF (l_debug <> -1) THEN
8467 rlm_core_sv.dlog(k_DEBUG,'in rowcount = 0');
8468 rlm_core_sv.dlog(k_DEBUG,'No lines came into the
8469 schedule to be consumed so keep line as it is');
8470 END IF;
8471 --
8472 ELSIF v_consume_quantity > 0 THEN
8473 --
8474 v_Key_rec.oe_line_id := c_OldDemand_rec.line_id;
8475 --
8476 IF (l_debug <> -1) THEN
8477 rlm_core_sv.dlog(k_DEBUG,'oe_line_id',v_Key_rec.oe_line_id);
8478 END IF;
8479 --
8480 AssignOEAttribValues(v_Key_rec, c_OldDemand_rec);
8481 --
8482 v_Key_rec.req_rec := v_Key_rec.dem_rec;
8483 --
8484 v_quantity := c_OldDemand_rec.ordered_quantity - v_consume_quantity;
8485 --
8486 IF (l_debug <> -1) THEN
8487 rlm_core_sv.dlog(k_DEBUG,'v_quantity',v_quantity);
8488 END IF;
8489 --
8490 IF v_quantity = 0 THEN
8491 --
8492 DeleteRequirement(x_Sched_rec, x_Group_rec, v_Key_rec,
8493 k_RECONCILE, v_DeleteQty);
8494 --
8495 ELSE
8496 --
8497 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
8498 --
8499 --Bugfix 10053830 Start
8500 /*IF (NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec,
8501 v_Key_rec.dem_rec.request_date) OR
8502 IsFrozen(TRUNC(SYSDATE), x_Group_rec, v_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL') --Bugfix 8221799*/
8503 IF (NOT (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec,
8504 v_Key_rec.dem_rec.request_date) OR
8505 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, v_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL') --Bugfix 8221799
8506 --Bugfix 10053830 End
8507 AND NOT ProcessConstraint(v_Key_rec,v_Qty_rec,k_UPDATE,v_Quantity) THEN
8508 --
8509 IF (l_debug <> -1) THEN
8510 rlm_core_sv.dlog(k_DEBUG,'v_quantity',v_quantity);
8511 END IF;
8512 --
8513 --global_atp
8514 UpdateRequirement(x_Sched_rec, x_Group_rec, v_Key_rec,
8515 v_quantity);
8516 --
8517 ELSE
8518 -- irreconcileable differences
8519 --
8520 StoreReconcile(x_Sched_rec, x_Group_rec, v_Key_rec,
8521 v_consume_quantity);
8522 --
8523 END IF;
8524 --
8525 END IF;
8526 --
8527 END IF;
8528 --
8529 END IF;
8530 --
8531 ELSE
8532 --
8533 /* We add this new line to the consume tab so that these lines should not
8534 be considered for consumption later on.
8535 WE have added the difference between the New ref qty and what was
8536 there earlier. Hence we find that if this consume_line_tab.quantity
8537 > 0 then we should consume */
8538 --
8539 v_Count := v_consume_line_tab.COUNT + 1;
8540 --
8541 v_consume_line_tab(v_Count).line_id := v_Newref_line_id;
8542 v_consume_line_tab(v_Count).quantity := c_OldDemand_rec.ordered_quantity;
8543 --
8544 IF (l_debug <> -1) THEN
8545 rlm_core_sv.dlog(k_DEBUG,'new line addede to the consume tab');
8546 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Count).line_id',
8547 v_consume_line_tab(v_Count).line_id);
8548 rlm_core_sv.dlog(k_DEBUG,'v_consume_line_tab(v_Count).quantity',
8549 v_consume_line_tab(v_Count).quantity);
8550 END IF;
8551 --
8552 END IF;
8553 --
8554 CLOSE c_NewReq_ref;
8555
8556 EXCEPTION
8557 --
8558 WHEN e_WrongSchedType THEN
8559 --
8560 SELECT line_number INTO v_line_num
8561 FROM oe_order_lines
8562 WHERE line_id = c_OldDemand_rec.line_id;
8563 --
8564 IF (l_debug <> -1) THEN
8565 rlm_core_sv.dlog(k_DEBUG,'line_id', c_OldDemand_rec.line_id);
8566 rlm_core_sv.dlog(k_DEBUG,'rla_schedule_type_code',
8567 c_OldDemand_rec.rla_schedule_type_code);
8568 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_type',
8569 x_Sched_rec.schedule_type);
8570 rlm_core_sv.dlog(k_DEBUG,'line_number', v_line_num);
8571 rlm_core_sv.dlog(k_DEBUG,'RLM_WRONG_SCHEDTYPE');
8572 END IF;
8573 --
8574 rlm_message_sv.app_error(
8575 x_ExceptionLevel => rlm_message_sv.k_warn_level,
8576 x_MessageName => 'RLM_WRONG_SCHEDTYPE',
8577 x_InterfaceHeaderId => x_sched_rec.header_id,
8578 x_InterfaceLineId => NULL,
8579 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
8580 x_ScheduleLineId => NULL,
8581 x_OrderHeaderId => x_Group_rec.order_header_id,
8582 x_OrderLineId => c_OldDemand_rec.line_id,
8583 x_Token1 => 'LINENUM',
8584 x_value1 => v_line_num,
8585 x_Token2 => 'SCHEDTYPE',
8586 x_value2 => c_OldDemand_rec.rla_schedule_type_code );
8587 --
8588 END;
8589 --
8590 FETCH c_OldDemand INTO c_OldDemand_rec;
8591 --
8592 END LOOP;
8593 CLOSE c_OldDemand; --bug 4570658
8594 --
8595 IF (l_debug <> -1) THEN
8596 rlm_core_sv.dpop(k_SDEBUG);
8597 END IF;
8598 --
8599 EXCEPTION
8600
8601 WHEN e_group_error THEN
8602 --
8603 IF (l_debug <> -1) THEN
8604 rlm_core_sv.dlog(k_DEBUG,'group error');
8605 rlm_core_sv.dpop(k_SDEBUG);
8606 END IF;
8607 --
8608 raise e_group_error;
8609
8610 WHEN OTHERS THEN
8611 rlm_message_sv.sql_error('rlm_rd_sv.ProcessOld',x_progress);
8612 --
8613 IF (l_debug <> -1) THEN
8614 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8615 END IF;
8616 --
8617 raise;
8618
8619 END ProcessOld;
8620
8621
8622 /*===========================================================================
8623
8624 FUNCTION FetchReq
8625
8626 ===========================================================================*/
8627 FUNCTION FetchReq(x_Req_ref IN OUT NOCOPY t_Cursor_ref,
8628 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
8629 x_oe_line_id OUT NOCOPY NUMBER,
8630 x_SumOrderedQty OUT NOCOPY NUMBER,
8631 x_ScheduleType OUT NOCOPY VARCHAR2)
8632 RETURN BOOLEAN
8633 IS
8634 x_progress VARCHAR2(3) := '010';
8635
8636 BEGIN
8637 --
8638 IF (l_debug <> -1) THEN
8639 rlm_core_sv.dpush(k_SDEBUG,'FetchReq');
8640 END IF;
8641 --
8642 FETCH x_Req_Ref INTO
8643 x_oe_line_id,
8644 x_SumOrderedQty,
8645 x_ScheduleType, -- existing schedule_type
8646 x_Key_rec.req_rec.customer_id,
8647 x_Key_rec.req_rec.header_id,
8648 x_Key_rec.req_rec.line_id,
8649 x_Key_rec.req_rec.cust_production_line,
8650 x_Key_rec.req_rec.customer_dock_code,
8651 x_Key_rec.req_rec.request_date,
8652 x_Key_rec.req_rec.schedule_date,
8653 x_Key_rec.req_rec.cust_po_number,
8654 x_Key_rec.req_rec.customer_item_revision,
8655 x_Key_rec.req_rec.customer_job,
8656 x_Key_rec.req_rec.cust_model_serial_number,
8657 x_Key_rec.req_rec.cust_production_seq_num,
8658 x_Key_rec.req_rec.industry_attribute1,
8659 x_Key_rec.req_rec.industry_attribute2,
8660 x_Key_rec.req_rec.industry_attribute3,
8661 x_Key_rec.req_rec.industry_attribute4,
8662 x_Key_rec.req_rec.industry_attribute5,
8663 x_Key_rec.req_rec.industry_attribute6,
8664 x_Key_rec.req_rec.industry_attribute7,
8665 x_Key_rec.req_rec.industry_attribute8,
8666 x_Key_rec.req_rec.industry_attribute9,
8667 x_Key_rec.req_rec.industry_attribute10,
8668 x_Key_rec.req_rec.industry_attribute11,
8669 x_Key_rec.req_rec.industry_attribute12,
8670 x_Key_rec.req_rec.industry_attribute13,
8671 x_Key_rec.req_rec.industry_attribute14,
8672 x_Key_rec.req_rec.industry_attribute15,
8673 x_Key_rec.req_rec.industry_context,
8674 x_Key_rec.req_rec.attribute1,
8675 x_Key_rec.req_rec.attribute2,
8676 x_Key_rec.req_rec.attribute3,
8677 x_Key_rec.req_rec.attribute4,
8678 x_Key_rec.req_rec.attribute5,
8679 x_Key_rec.req_rec.attribute6,
8680 x_Key_rec.req_rec.attribute7,
8681 x_Key_rec.req_rec.attribute8,
8682 x_Key_rec.req_rec.attribute9,
8683 x_Key_rec.req_rec.attribute10,
8684 x_Key_rec.req_rec.attribute11,
8685 x_Key_rec.req_rec.attribute12,
8686 x_Key_rec.req_rec.attribute13,
8687 x_Key_rec.req_rec.attribute14,
8688 x_Key_rec.req_rec.attribute15,
8689 x_Key_rec.req_rec.attribute_category,
8690 x_Key_rec.req_rec.tp_attribute1,
8691 x_Key_rec.req_rec.tp_attribute2,
8692 x_Key_rec.req_rec.tp_attribute3,
8693 x_Key_rec.req_rec.tp_attribute4,
8694 x_Key_rec.req_rec.tp_attribute5,
8695 x_Key_rec.req_rec.tp_attribute6,
8696 x_Key_rec.req_rec.tp_attribute7,
8697 x_Key_rec.req_rec.tp_attribute8,
8698 x_Key_rec.req_rec.tp_attribute9,
8699 x_Key_rec.req_rec.tp_attribute10,
8700 x_Key_rec.req_rec.tp_attribute11,
8701 x_Key_rec.req_rec.tp_attribute12,
8702 x_Key_rec.req_rec.tp_attribute13,
8703 x_Key_rec.req_rec.tp_attribute14,
8704 x_Key_rec.req_rec.tp_attribute15,
8705 x_Key_rec.req_rec.tp_attribute_category,
8706 x_Key_rec.req_rec.item_detail_type,
8707 x_Key_rec.req_rec.item_detail_subtype,
8708 x_Key_rec.req_rec.intrmd_ship_to_id,
8709 x_Key_rec.req_rec.ship_to_org_id,
8710 x_Key_rec.req_rec.invoice_to_org_id,
8711 x_Key_rec.req_rec.primary_quantity,
8712 x_Key_rec.req_rec.intmed_ship_to_org_id,
8713 x_Key_rec.req_rec.customer_item_id,
8714 x_Key_rec.req_rec.inventory_item_id,
8715 x_Key_rec.req_rec.order_header_id,
8716 x_Key_rec.req_rec.authorized_to_ship_flag,
8717 x_Key_rec.req_rec.ship_from_org_id,
8718 x_Key_rec.req_rec.schedule_type, --incoming
8719 x_Key_rec.req_rec.item_identifier_type,
8720 x_Key_rec.req_rec.customer_item_ext,
8721 x_Key_rec.req_rec.agreement_id,
8722 x_Key_rec.req_rec.price_list_id,
8723 x_Key_rec.req_rec.schedule_header_id,
8724 x_Key_rec.req_rec.schedule_line_id,
8725 x_Key_rec.req_rec.process_status,
8726 x_Key_rec.req_rec.uom_code,
8727 x_Key_rec.req_rec.cust_po_line_num,
8728 x_Key_rec.req_rec.blanket_number;
8729
8730 --
8731 IF (l_debug <> -1) THEN
8732 rlm_core_sv.dlog(k_DEBUG, 'after fetch');
8733 END IF;
8734 --
8735 IF x_Req_ref%NOTFOUND THEN
8736 --
8737 IF (l_debug <> -1) THEN
8738 rlm_core_sv.dpop(k_SDEBUG, 'false');
8739 END IF;
8740 --
8741 RETURN(FALSE);
8742 --
8743 ELSE
8744 --
8745 IF (l_debug <> -1) THEN
8746 rlm_core_sv.dpop(k_SDEBUG, 'true');
8747 END IF;
8748 --
8749 RETURN(TRUE);
8750 --
8751 END IF;
8752 --
8753 EXCEPTION
8754 WHEN OTHERS THEN
8755 rlm_message_sv.sql_error('rlm_rd_sv.FetchReq',x_progress);
8756 --
8757 IF (l_debug <> -1) THEN
8758 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8759 END IF;
8760 --
8761 raise;
8762
8763 END FetchReq;
8764
8765
8766 /*===========================================================================
8767
8768 FUNCTION FetchDemand
8769
8770 ===========================================================================*/
8771 FUNCTION FetchDemand(x_Demand_ref IN OUT NOCOPY t_Cursor_ref,
8772 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec)
8773 RETURN BOOLEAN
8774 IS
8775 x_progress VARCHAR2(3) := '010';
8776
8777 BEGIN
8778 --
8779 IF (l_debug <> -1) THEN
8780 rlm_core_sv.dpush(k_SDEBUG,'FetchDemand');
8781 END IF;
8782 --
8783 FETCH x_Demand_ref INTO
8784 x_Key_rec.dem_rec.line_id,
8785 x_Key_rec.dem_rec.ordered_quantity,
8786 x_Key_rec.dem_rec.shipped_quantity,
8787 x_Key_rec.dem_rec.customer_id,
8788 x_Key_rec.dem_rec.cust_production_line,
8789 x_Key_rec.dem_rec.customer_dock_code,
8790 x_Key_rec.dem_rec.request_date,
8791 x_Key_rec.dem_rec.schedule_date,
8792 x_Key_rec.dem_rec.cust_po_number,
8793 x_Key_rec.dem_rec.customer_item_revision,
8794 x_Key_rec.dem_rec.customer_job,
8795 x_Key_rec.dem_rec.cust_model_serial_number,
8796 x_Key_rec.dem_rec.cust_production_seq_num,
8797 x_Key_rec.dem_rec.industry_attribute1,
8798 x_Key_rec.dem_rec.industry_attribute2,
8799 x_Key_rec.dem_rec.industry_attribute3,
8800 x_Key_rec.dem_rec.industry_attribute4,
8801 x_Key_rec.dem_rec.industry_attribute5,
8802 x_Key_rec.dem_rec.industry_attribute6,
8803 x_Key_rec.dem_rec.industry_attribute7,
8804 x_Key_rec.dem_rec.industry_attribute8,
8805 x_Key_rec.dem_rec.industry_attribute9,
8806 x_Key_rec.dem_rec.industry_attribute10,
8807 x_Key_rec.dem_rec.industry_attribute11,
8808 x_Key_rec.dem_rec.industry_attribute12,
8809 x_Key_rec.dem_rec.industry_attribute13,
8810 x_Key_rec.dem_rec.industry_attribute14,
8811 x_Key_rec.dem_rec.industry_attribute15,
8812 x_Key_rec.dem_rec.industry_context,
8813 x_Key_rec.dem_rec.attribute1,
8814 x_Key_rec.dem_rec.attribute2,
8815 x_Key_rec.dem_rec.attribute3,
8816 x_Key_rec.dem_rec.attribute4,
8817 x_Key_rec.dem_rec.attribute5,
8818 x_Key_rec.dem_rec.attribute6,
8819 x_Key_rec.dem_rec.attribute7,
8820 x_Key_rec.dem_rec.attribute8,
8821 x_Key_rec.dem_rec.attribute9,
8822 x_Key_rec.dem_rec.attribute10,
8823 x_Key_rec.dem_rec.attribute11,
8824 x_Key_rec.dem_rec.attribute12,
8825 x_Key_rec.dem_rec.attribute13,
8826 x_Key_rec.dem_rec.attribute14,
8827 x_Key_rec.dem_rec.attribute15,
8828 x_Key_rec.dem_rec.attribute_category,
8829 x_Key_rec.dem_rec.tp_attribute1,
8830 x_Key_rec.dem_rec.tp_attribute2,
8831 x_Key_rec.dem_rec.tp_attribute3,
8832 x_Key_rec.dem_rec.tp_attribute4,
8833 x_Key_rec.dem_rec.tp_attribute5,
8834 x_Key_rec.dem_rec.tp_attribute6,
8835 x_Key_rec.dem_rec.tp_attribute7,
8836 x_Key_rec.dem_rec.tp_attribute8,
8837 x_Key_rec.dem_rec.tp_attribute9,
8838 x_Key_rec.dem_rec.tp_attribute10,
8839 x_Key_rec.dem_rec.tp_attribute11,
8840 x_Key_rec.dem_rec.tp_attribute12,
8841 x_Key_rec.dem_rec.tp_attribute13,
8842 x_Key_rec.dem_rec.tp_attribute14,
8843 x_Key_rec.dem_rec.tp_attribute15,
8844 x_Key_rec.dem_rec.tp_attribute_category,
8845 x_Key_rec.dem_rec.item_detail_subtype,
8846 x_Key_rec.dem_rec.item_detail_type,
8847 x_Key_rec.dem_rec.ship_to_org_id,
8848 x_Key_rec.dem_rec.invoice_to_org_id,
8849 x_Key_rec.dem_rec.intmed_ship_to_org_id,
8850 x_Key_rec.dem_rec.customer_item_id,
8851 x_Key_rec.dem_rec.inventory_item_id,
8852 x_Key_rec.dem_rec.order_header_id,
8853 x_Key_rec.dem_rec.ship_from_org_id,
8854 x_Key_rec.dem_rec.schedule_type,
8855 x_Key_rec.dem_rec.authorized_to_ship_flag,
8856 x_Key_rec.dem_rec.item_identifier_type,
8857 x_Key_rec.dem_rec.agreement_id,
8858 x_Key_rec.dem_rec.price_list_id,
8859 x_Key_rec.dem_rec.customer_item_ext,
8860 x_key_rec.dem_rec.uom_code,
8861 x_Key_rec.dem_rec.blanket_number;
8862 --
8863 IF x_Demand_ref%NOTFOUND THEN
8864 --
8865 IF (l_debug <> -1) THEN
8866 rlm_core_sv.dpop(k_SDEBUG, 'false');
8867 END IF;
8868 --
8869 RETURN(FALSE);
8870 --
8871 ELSE
8872 --
8873 IF (l_debug <> -1) THEN
8874 rlm_core_sv.dpop(k_SDEBUG, 'true');
8875 END IF;
8876 --
8877 RETURN(TRUE);
8878 --
8879 END IF;
8880
8881 EXCEPTION
8882 WHEN OTHERS THEN
8883 rlm_message_sv.sql_error('rlm_rd_sv.FetchDemand',x_progress);
8884 --
8885 IF (l_debug <> -1) THEN
8886 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8887 END IF;
8888 --
8889 raise;
8890
8891 END FetchDemand;
8892
8893
8894 /*===========================================================================
8895
8896 FUNCTION SchedulePrecedence
8897
8898 ===========================================================================*/
8899 FUNCTION SchedulePrecedence(x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
8900 x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
8901 x_ScheduleType IN VARCHAR2)
8902 RETURN BOOLEAN
8903 IS
8904 v_cannot_replace NUMBER;
8905 x_progress VARCHAR2(3) := '010';
8906 BEGIN
8907 --
8908 IF (l_debug <> -1) THEN
8909 rlm_core_sv.dpush(k_SDEBUG,'SchedulePrecedence');
8910 rlm_core_sv.dlog(k_DEBUG,'x_ScheduleType', x_ScheduleType);
8911 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_one', x_group_rec.schedule_type_one);
8912 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_two', x_group_rec.schedule_type_two);
8913 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.schedule_type_three', x_group_rec.schedule_type_three);
8914 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.schedule_type', x_sched_rec.schedule_type);
8915 END IF;
8916 --
8917 -- If the given schedule line is less in hierarchy than the oe line
8918 -- schedule line then return false else return true
8919 --
8920 SELECT DECODE(x_ScheduleType,x_group_rec.schedule_type_one,1,
8921 x_group_rec.schedule_type_two,2,
8922 x_group_rec.schedule_type_three,3) -
8923 DECODE(x_Sched_rec.schedule_type,x_group_rec.schedule_type_one,1,
8924 x_group_rec.schedule_type_two,2,
8925 x_group_rec.schedule_type_three,3)
8926 INTO v_cannot_replace
8927 FROM dual;
8928 --
8929 IF (l_debug <> -1) THEN
8930 rlm_core_sv.dlog(k_DEBUG,'v_cannot_replace', v_cannot_replace);
8931 END IF;
8932 --
8933 IF v_cannot_replace <= 0 THEN
8934 --
8935 IF (l_debug <> -1) THEN
8936 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
8937 END IF;
8938 --
8939 RETURN TRUE;
8940 --
8941 ELSE
8942 --
8943 IF (l_debug <> -1) THEN
8944 rlm_core_sv.dpop(k_SDEBUG, 'false');
8945 END IF;
8946 --
8947 RETURN FALSE;
8948 --
8949 END IF;
8950
8951 EXCEPTION
8952 WHEN OTHERS THEN
8953 rlm_message_sv.sql_error('rlm_rd_sv.SchedulePrecedence',x_progress);
8954 --
8955 IF (l_debug <> -1) THEN
8956 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
8957 END IF;
8958 --
8959 raise;
8960
8961 END SchedulePrecedence;
8962
8963
8964 PROCEDURE CountMatchedDemand(x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
8965 x_key_rec IN RLM_RD_SV.t_Key_rec,
8966 x_rlm_line_id IN NUMBER,
8967 x_oe_line_id IN NUMBER,
8968 x_DemandCount IN OUT NOCOPY NUMBER,
8969 x_SumOrderedQty IN OUT NOCOPY NUMBER,
8970 x_SumOrderedQtyTmp IN OUT NOCOPY NUMBER)
8971 IS
8972 x_progress VARCHAR2(3) := '010';
8973 BEGIN
8974 --
8975 IF (l_debug <> -1) THEN
8976 rlm_core_sv.dpush(k_SDEBUG,'CountMatchedDemand');
8977 rlm_core_sv.dlog(k_DEBUG, 'Matched Demand Counter', x_DemandCount);
8978 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', x_rlm_line_id);
8979 rlm_core_sv.dlog(k_DEBUG, 'OM Line Id', x_oe_line_id);
8980 rlm_core_sv.dlog(k_DEBUG, 'x_SumOrderedQtyTmp', x_SumOrderedQtyTmp);
8981 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_type',
8982 x_Sched_rec.schedule_type);
8983 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.item_detail_subtype',
8984 x_Key_rec.req_rec.item_detail_subtype);
8985 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.invoice_to_org_id',
8986 x_Key_rec.req_rec.invoice_to_org_id);
8987 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.ship_to_org_id',
8988 x_Key_rec.req_rec.ship_to_org_id);
8989 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.intmed_ship_to_org_id',
8990 x_key_rec.req_rec.intmed_ship_to_org_id);
8991 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_line',
8992 x_key_rec.req_rec.cust_production_line);
8993 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_seq_num',
8994 x_key_rec.req_rec.cust_production_seq_num);
8995 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
8996 x_key_rec.req_rec.primary_quantity);
8997 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_production_line',
8998 x_key_rec.req_rec.cust_production_line);
8999 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
9000 x_key_rec.req_rec.primary_quantity);
9001 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_item_revision',
9002 x_key_rec.req_rec.customer_item_revision);
9003 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_job',
9004 x_key_rec.req_rec.customer_job);
9005 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_po_number',
9006 x_key_rec.req_rec.cust_po_number);
9007 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.customer_dock_code',
9008 x_key_rec.req_rec.customer_dock_code);
9009 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.cust_model_serial_number',
9010 x_key_rec.req_rec.cust_model_serial_number);
9011 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.request_date',
9012 x_key_rec.req_rec.request_date);
9013 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.schedule_date',
9014 x_key_rec.req_rec.schedule_date);
9015 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.schedule_purpose',
9016 x_Sched_rec.schedule_purpose);
9017 END IF;
9018 --
9019 x_SumOrderedQty := x_SumOrderedQty + x_SumOrderedQtyTmp;
9020 --
9021 x_DemandCount := x_DemandCount + 1;
9022 --
9023 IF (l_debug <> -1) THEN
9024 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty',x_SumOrderedQty);
9025 rlm_core_sv.dlog(k_DEBUG,'x_DemandCount',x_DemandCount);
9026 rlm_core_sv.dpop(k_SDEBUG);
9027 END IF;
9028 --
9029 EXCEPTION
9030
9031 WHEN e_group_error THEN
9032 --
9033 IF (l_debug <> -1) THEN
9034 rlm_core_sv.dlog(k_DEBUG,'group error');
9035 rlm_core_sv.dpop(k_SDEBUG);
9036 END IF;
9037 --
9038 raise e_group_error;
9039
9040 WHEN OTHERS THEN
9041 rlm_message_sv.sql_error('rlm_rd_sv.CountMatchedDemand',x_progress);
9042 --
9043 IF (l_debug <> -1) THEN
9044 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
9045 END IF;
9046 --
9047 raise;
9048
9049 END CountMatchedDemand;
9050
9051
9052 PROCEDURE ReconcileAction(x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
9053 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
9054 x_key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
9055 x_line_id_tab IN RLM_RD_SV.t_matching_line,
9056 x_DemandCount IN NUMBER,
9057 x_SumOrderedQty IN NUMBER,
9058 x_DemandType IN VARCHAR2)
9059 IS
9060 x_progress VARCHAR2(3) := '010';
9061 BEGIN
9062 --
9063 IF (l_debug <> -1) THEN
9064 rlm_core_sv.dpush(k_SDEBUG, 'ReconcileAction');
9065 END IF;
9066 --
9067 IF (x_DemandCount > 0) AND (NOT AlreadyUpdated(x_line_id_tab)) THEN
9068 --
9069 IF x_Sched_rec.schedule_purpose IN (k_DELETE, k_CANCEL) THEN
9070 --
9071 IF (l_debug <> -1) THEN
9072 rlm_core_sv.dlog(k_DEBUG,'Deleting requirement due to purpose code of '
9073 ,x_Sched_rec.schedule_purpose);
9074 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
9075 x_key_rec.req_rec.primary_quantity);
9076 END IF;
9077 --
9078 x_key_rec.req_rec.primary_quantity := x_SumOrderedQty -
9079 x_key_rec.req_rec.primary_quantity;
9080 --
9081 IF (l_debug <> -1) THEN
9082 rlm_core_sv.dlog(k_DEBUG,'new x_key_rec.req_rec.primary_quantity',
9083 x_key_rec.req_rec.primary_quantity);
9084 END IF;
9085 --
9086 ELSIF x_Sched_rec.schedule_purpose = k_ADD THEN
9087 --
9088 IF (l_debug <> -1) THEN
9089 rlm_core_sv.dlog(k_DEBUG,'Adding requirement due to purpose code of ',
9090 x_Sched_rec.schedule_purpose);
9091 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
9092 x_key_rec.req_rec.primary_quantity);
9093 END IF;
9094 --
9095 x_key_rec.req_rec.primary_quantity := x_SumOrderedQty +
9096 x_key_rec.req_rec.primary_quantity;
9097 --
9098 IF (l_debug <> -1) THEN
9099 rlm_core_sv.dlog(k_DEBUG,'new x_key_rec.req_rec.primary_quantity',
9100 x_key_rec.req_rec.primary_quantity);
9101 END IF;
9102 --
9103 END IF;
9104 --
9105 RLM_TPA_SV.UpdateDemand(x_Sched_rec, x_Group_rec, x_Key_rec,
9106 x_SumOrderedQty, x_DemandType);
9107 --
9108 -- this means that the req was not matched in OE so we should
9109 -- only insert the new requirement
9110 ELSIF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
9111 --
9112 IF (l_debug <> -1) THEN
9113 rlm_core_sv.dlog(k_DEBUG,'insert x_key_rec.req_rec.primary_quantity',
9114 x_key_rec.req_rec.primary_quantity);
9115 END IF;
9116 --
9117 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
9118 x_Key_rec, k_RECONCILE,
9119 x_Key_rec.req_rec.primary_quantity);
9120 --
9121 END IF;
9122 --
9123 IF (l_debug <> -1) THEN
9124 rlm_core_sv.dpop(k_SDEBUG);
9125 END IF;
9126 --
9127 EXCEPTION
9128
9129 WHEN e_group_error THEN
9130 --
9131 IF (l_debug <> -1) THEN
9132 rlm_core_sv.dlog(k_DEBUG,'group error');
9133 rlm_core_sv.dpop(k_SDEBUG);
9134 END IF;
9135 --
9136 raise e_group_error;
9137
9138 WHEN OTHERS THEN
9139 rlm_message_sv.sql_error('rlm_rd_sv.ReconcileAction',x_progress);
9140 --
9141 IF (l_debug <> -1) THEN
9142 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
9143 END IF;
9144 --
9145 raise;
9146
9147 END ReconcileAction;
9148
9149
9150 /* ============================================================================================
9151
9152 Procedure BuildMatchQuery
9153
9154 The following is the order of WHERE clause for each SQL
9155 x_Sql => uses v_where_clause1, v_where_clause2, w_where_clause1, v_where_clause1, v_where_clause2
9156 x_Sql1 => uses v_where_clause1, v_where_clause2
9157 x_Sql2 => uses w_where_clause1, v_where_clause1, v_where_clause2
9158
9159 ProcessATS calls BuildMatchQuery with the following parameter mapping
9160 v_ATSDemand => x_Sql
9161 v_NATSDemand => x_Sql1
9162 v_SumDemand => x_Sum_Sql
9163 v_NewDemand => x_Sql2
9164
9165 ProcessNATS calls BuildMatchQuery with the following parameter mapping
9166 v_ATSDemand => x_Sql1
9167 v_NATSDemand => x_Sql
9168 v_SumDemand => x_Sum_Sql
9169 v_NewDemand => x_Sql2
9170
9171 =============================================================================================== */
9172
9173 PROCEDURE BuildMatchQuery(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
9174 x_Group_Rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
9175 x_Demand_Type IN VARCHAR2,
9176 x_Sql OUT NOCOPY VARCHAR2,
9177 x_Sql1 OUT NOCOPY VARCHAR2,
9178 x_Sql2 OUT NOCOPY VARCHAR2,
9179 x_Sum_Sql OUT NOCOPY VARCHAR2)
9180 IS
9181 --
9182 x_progress VARCHAR2(3) := '010';
9183 v_Select_Clause VARCHAR2(32000);
9184 w_Select_Clause1 VARCHAR2(32000);
9185 w_Select_Clause2 VARCHAR2(32000);
9186 v_Where_Clause1 VARCHAR2(32000);
9187 w_Where_Clause1 VARCHAR2(32000);
9188 v_Where_Clause2 VARCHAR2(32000);
9189 v_Order_Clause VARCHAR2(5000);
9190 v_sum_clause VARCHAR2(32000);
9191 v_ATSWhere VARCHAR2(5000);
9192 v_NATSWhere VARCHAR2(5000);
9193 v_Date DATE;
9194 --
9195 BEGIN
9196 --
9197 IF (l_debug <> -1) THEN
9198 rlm_core_sv.dpush(k_SDEBUG, 'BuildMatchQuery');
9199 rlm_core_sv.dlog(k_DEBUG, 'Disposition Code', x_Group_rec.disposition_code);
9200 END IF;
9201
9202 v_select_clause :=
9203
9204 'SELECT /*+ leading(r) */ o.line_id,(NVL(o.ordered_quantity,0)-NVL(o.shipped_quantity,0)),'|| --Bugfix 12863728
9205 'o.rla_schedule_type_code,'|| x_group_rec.customer_id ||
9206 ',r.header_id interface_header_id, r.line_id interface_line_id,'||
9207 'r.cust_production_line,r.customer_dock_code,r.request_date,'||
9208 'r.schedule_date,r.cust_po_number,r.customer_item_revision,'||
9209 'r.customer_job,r.cust_model_serial_number,r.cust_production_seq_num,'||
9210 'r.industry_attribute1,r.industry_attribute2,r.industry_attribute3,'||
9211 'r.industry_attribute4,r.industry_attribute5,r.industry_attribute6,'||
9212 'r.industry_attribute7,r.industry_attribute8,r.industry_attribute9,'||
9213 'r.industry_attribute10,r.industry_attribute11,r.industry_attribute12,'||
9214 'r.industry_attribute13,r.industry_attribute14,r.industry_attribute15,'||
9215 'r.industry_context,r.attribute1,r.attribute2,r.attribute3,'||
9216 'r.attribute4,r.attribute5,r.attribute6,r.attribute7,r.attribute8,'||
9217 'r.attribute9,r.attribute10,r.attribute11,r.attribute12,r.attribute13,'||
9218 'r.attribute14,r.attribute15,r.attribute_category,r.tp_attribute1,'||
9219 'r.tp_attribute2,r.tp_attribute3,r.tp_attribute4,r.tp_attribute5,'||
9220 'r.tp_attribute6,r.tp_attribute7,r.tp_attribute8,r.tp_attribute9,'||
9221 'r.tp_attribute10,r.tp_attribute11,r.tp_attribute12,r.tp_attribute13,'||
9222 'r.tp_attribute14,r.tp_attribute15,r.tp_attribute_category,'||
9223 'r.item_detail_type,r.item_detail_subtype,r.intrmd_ship_to_id,'||
9224 'r.ship_to_org_id,r.invoice_to_org_id,r.primary_quantity,'||
9225 'r.intmed_ship_to_org_id,r.customer_item_id,r.inventory_item_id,'||
9226 'r.order_header_id,o.authorized_to_ship_flag,r.ship_from_org_id,''' ||
9227 x_sched_rec.schedule_type ||''',''CUST'' item_identifier_type,'||
9228 'r.customer_item_ext,r.agreement_id,r.price_list_id,'||
9229 x_Sched_rec.schedule_header_id ||
9230 ',r.schedule_line_id,r.process_status,r.uom_code,r.cust_po_line_num,r.blanket_number ' ||
9231 'FROM oe_order_lines_all o,rlm_interface_lines r ';
9232
9233 w_Select_Clause1 :=
9234
9235 'SELECT TO_NUMBER(NULL),TO_NUMBER(NULL),TO_CHAR(NULL),'||
9236 x_group_rec.customer_id ||
9237 ',r1.header_id interface_header_id, r1.line_id interface_line_id,'||
9238 'r1.cust_production_line,r1.customer_dock_code,r1.request_date,'||
9239 'r1.schedule_date,r1.cust_po_number,r1.customer_item_revision,'||
9240 'r1.customer_job,r1.cust_model_serial_number,r1.cust_production_seq_num,'||
9241 'r1.industry_attribute1,r1.industry_attribute2,r1.industry_attribute3,'||
9242 'r1.industry_attribute4,r1.industry_attribute5,r1.industry_attribute6,'||
9243 'r1.industry_attribute7,r1.industry_attribute8,r1.industry_attribute9,'||
9244 'r1.industry_attribute10,r1.industry_attribute11,r1.industry_attribute12,'||
9245 'r1.industry_attribute13,r1.industry_attribute14,r1.industry_attribute15,'||
9246 'r1.industry_context,r1.attribute1,r1.attribute2,r1.attribute3,'||
9247 'r1.attribute4,r1.attribute5,r1.attribute6,r1.attribute7,r1.attribute8,'||
9248 'r1.attribute9,r1.attribute10,r1.attribute11,r1.attribute12,r1.attribute13,'||
9249 'r1.attribute14,r1.attribute15,r1.attribute_category,r1.tp_attribute1,'||
9250 'r1.tp_attribute2,r1.tp_attribute3,r1.tp_attribute4,r1.tp_attribute5,'||
9251 'r1.tp_attribute6,r1.tp_attribute7,r1.tp_attribute8,r1.tp_attribute9,'||
9252 'r1.tp_attribute10,r1.tp_attribute11,r1.tp_attribute12,r1.tp_attribute13,'||
9253 'r1.tp_attribute14,r1.tp_attribute15,r1.tp_attribute_category,'||
9254 'r1.item_detail_type,r1.item_detail_subtype,r1.intrmd_ship_to_id,'||
9255 'r1.ship_to_org_id,r1.invoice_to_org_id,r1.primary_quantity,'||
9256 'r1.intmed_ship_to_org_id,r1.customer_item_id,r1.inventory_item_id,'||
9257 'r1.order_header_id,''' || x_Demand_Type ||
9258 ''' authorized_to_ship_flag,r1.ship_from_org_id,''' ||
9259 x_sched_rec.schedule_type ||''',''CUST'' item_identifier_type,'||
9260 'r1.customer_item_ext,r1.agreement_id,r1.price_list_id,'||
9261 x_Sched_rec.schedule_header_id ||
9262 ',r1.schedule_line_id,r1.process_status,r1.uom_code,r1.cust_po_line_num,r1.blanket_number ' ||
9263 'FROM rlm_interface_lines r1 ';
9264
9265 --
9266 v_where_clause1 :=
9267
9268 'WHERE o.header_id = r.order_header_id ' ||
9269 ' AND o.org_id = r.org_id ' ||
9270 ' AND o.header_id = :order_header_id' ||
9271 ' AND r.order_header_id = :order_header_id' ||
9272 ' AND o.open_flag = ''Y''' ||
9273 ' AND r.header_id = :header_id' ||
9274 ' AND o.ship_to_org_id = r.ship_to_org_id ' ||
9275 ' AND o.ship_to_org_id = :ship_to_org_id' ||
9276 ' AND r.ship_to_org_id = :ship_to_org_id' ||
9277 ' AND NVL(o.intmed_ship_to_org_id,-19999) = NVL(r.intmed_ship_to_org_id,-19999) ' ||
9278 ' AND o.ordered_item_id = r.customer_item_id ' ||
9279 ' AND o.ordered_item_id = :customer_item_id' ||
9280 ' AND r.customer_item_id = :customer_item_id' ||
9281 ' AND o.inventory_item_id = r.inventory_item_id ' ||
9282 ' AND o.inventory_item_id = :inventory_item_id '||
9283 ' AND r.inventory_item_id = :inventory_item_id ' ||
9284 ' AND o.demand_bucket_type_code = r.item_detail_subtype ' ||
9285 ' AND r.process_status IN ('||rlm_core_sv.k_PS_AVAILABLE||','||rlm_core_sv.k_PS_FROZEN_FIRM||')';
9286 --
9287 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.order_header_id;
9288 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.order_header_id;
9289 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Sched_rec.header_id;
9290 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_to_org_id;
9291 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_to_org_id;
9292 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.customer_item_id;
9293 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.customer_item_id;
9294 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.inventory_item_id;
9295 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.inventory_item_id;
9296 --
9297 --
9298 -- Optional Match
9299 IF x_group_rec.match_across_rec.request_date = 'Y' THEN
9300 --
9301 v_where_clause2 := v_where_clause2 ||
9302 ' AND o.request_date = r.request_date';
9303 --
9304 ELSE
9305 --
9306 IF x_group_rec.match_within_rec.request_date = 'Y' THEN
9307 --
9308 v_where_clause2 := v_where_clause2 ||
9309 ' AND o.request_date = DECODE(o.rla_schedule_type_code,:schedule_type, r.request_date, o.request_date)';
9310 --
9311 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9312 --
9313 END IF;
9314 --
9315 END IF;
9316 --
9317 IF x_group_rec.match_across_rec.cust_production_line = 'Y' THEN
9318 --
9319 v_where_clause2 := v_where_clause2 ||
9320 ' AND NVL(o.customer_production_line,'''||k_VNULL||
9321 ''') = NVL(r.cust_production_line,'''||k_VNULL|| ''')';
9322 --
9323 ELSE
9324 --
9325 IF x_group_rec.match_within_rec.cust_production_line = 'Y' THEN
9326 --
9327 v_where_clause2 := v_where_clause2 ||
9328 ' AND NVL(o.customer_production_line,'''||k_VNULL||
9329 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_production_line,'''||
9330 k_VNULL||'''), NVL(o.customer_production_line,'''||k_VNULL||'''))';
9331 --
9332 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9333 --
9334 END IF;
9335 --
9336 END IF;
9337 --
9338 IF x_group_rec.match_across_rec.customer_dock_code = 'Y' THEN
9339 --
9340 v_where_clause2 := v_where_clause2 ||
9341 ' AND NVL(o.customer_dock_code,'''||k_VNULL||
9342 ''') = NVL(r.customer_dock_code,'''||k_VNULL|| ''')';
9343 --
9344 ELSE
9345 --
9346 IF x_group_rec.match_within_rec.customer_dock_code = 'Y' THEN
9347 --
9348 v_where_clause2 := v_where_clause2 ||
9349 ' AND NVL(o.customer_dock_code,'''||k_VNULL||
9350 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_dock_code,'''||
9351 k_VNULL||'''), NVL(o.customer_dock_code,'''||k_VNULL||'''))';
9352 --
9353 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9354 --
9355 END IF;
9356 --
9357 END IF;
9358 --
9359 IF x_group_rec.match_across_rec.cust_po_number = 'Y' THEN
9360 --
9361 v_where_clause2 := v_where_clause2 ||
9362 ' AND NVL(o.cust_po_number,'''||k_VNULL||
9363 ''') = NVL(r.cust_po_number,'''||k_VNULL|| ''')';
9364 --
9365 ELSE
9366 --
9367 IF x_group_rec.match_within_rec.cust_po_number = 'Y' THEN
9368 --
9369 v_where_clause2 := v_where_clause2 ||
9370 ' AND NVL(o.cust_po_number,'''||k_VNULL||
9371 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_po_number,'''||
9372 k_VNULL||'''), NVL(o.cust_po_number,'''||k_VNULL||'''))';
9373 --
9374 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9375 --
9376 END IF;
9377 --
9378 END IF;
9379 --
9380 IF x_group_rec.match_across_rec.customer_item_revision = 'Y' THEN
9381 --
9382 v_where_clause2 := v_where_clause2 ||
9383 ' AND NVL(o.item_revision,'''||k_VNULL||
9384 ''') = NVL(r.customer_item_revision,'''||k_VNULL|| ''')';
9385 --
9386 ELSE
9387 --
9388 IF x_group_rec.match_within_rec.customer_item_revision = 'Y' THEN
9389 --
9390 v_where_clause2 := v_where_clause2 ||
9391 ' AND NVL(o.item_revision,'''||k_VNULL||
9392 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_item_revision,'''||
9393 k_VNULL||'''), NVL(o.item_revision,'''||k_VNULL||'''))';
9394 --
9395 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9396 --
9397 END IF;
9398 --
9399 END IF;
9400 --
9401 IF x_group_rec.match_across_rec.customer_job = 'Y' THEN
9402 --
9403 v_where_clause2 := v_where_clause2 ||
9404 ' AND NVL(o.customer_job,'''||k_VNULL||
9405 ''') = NVL(r.customer_job,'''||k_VNULL|| ''')';
9406 --
9407 ELSE
9408 --
9409 IF x_group_rec.match_within_rec.customer_job = 'Y' THEN
9410 --
9411 v_where_clause2 := v_where_clause2 ||
9412 ' AND NVL(o.customer_job,'''||k_VNULL||
9413 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.customer_job,'''||
9414 k_VNULL||'''), NVL(o.customer_job,'''||k_VNULL||'''))';
9415 --
9416 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9417 --
9418 END IF;
9419 --
9420 END IF;
9421 --
9422 IF x_group_rec.match_across_rec.cust_model_serial_number = 'Y' THEN
9423 --
9424 v_where_clause2 := v_where_clause2 ||
9425 ' AND NVL(o.cust_model_serial_number,'''||k_VNULL||
9426 ''') = NVL(r.cust_model_serial_number,'''||k_VNULL|| ''')';
9427 --
9428 ELSE
9429 --
9430 IF x_group_rec.match_within_rec.cust_model_serial_number = 'Y' THEN
9431 --
9432 v_where_clause2 := v_where_clause2 ||
9433 ' AND NVL(o.cust_model_serial_number,'''||k_VNULL||
9434 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_model_serial_number,'''||
9435 k_VNULL||'''), NVL(o.cust_model_serial_number,'''||k_VNULL||'''))';
9436 --
9437 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9438 --
9439 END IF;
9440 --
9441 END IF;
9442 --
9443 IF x_group_rec.match_across_rec.cust_production_seq_num = 'Y' THEN
9444 --
9445 v_where_clause2 := v_where_clause2 ||
9446 ' AND NVL(o.cust_production_seq_num,'''||k_VNULL||
9447 ''') = NVL(r.cust_production_seq_num,'''||k_VNULL|| ''')';
9448 --
9449 ELSE
9450 --
9451 IF x_group_rec.match_within_rec.cust_production_seq_num = 'Y' THEN
9452 --
9453 v_where_clause2 := v_where_clause2 ||
9454 ' AND NVL(o.cust_production_seq_num,'''||k_VNULL||
9455 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.cust_production_seq_num,'''||
9456 k_VNULL||'''), NVL(o.cust_production_seq_num,'''||k_VNULL||'''))';
9457 --
9458 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9459 --
9460 END IF;
9461 --
9462 END IF;
9463 --
9464 IF x_group_rec.match_across_rec.industry_attribute1 = 'Y' THEN
9465 --
9466 v_where_clause2 := v_where_clause2 ||
9467 ' AND NVL(o.industry_attribute1,'''||k_VNULL||
9468 ''') = NVL(r.industry_attribute1,'''||k_VNULL|| ''')';
9469 --
9470 ELSE
9471 --
9472 IF x_group_rec.match_within_rec.industry_attribute1 = 'Y' THEN
9473 --
9474 v_where_clause2 := v_where_clause2 ||
9475 ' AND NVL(o.industry_attribute1,'''||k_VNULL||
9476 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute1,'''||
9477 k_VNULL||'''), NVL(o.industry_attribute1,'''||k_VNULL||'''))';
9478 --
9479 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9480 --
9481 END IF;
9482 --
9483 END IF;
9484 --
9485 IF x_group_rec.match_across_rec.industry_attribute2 = 'Y' THEN
9486 --
9487 v_where_clause2 := v_where_clause2 ||
9488 ' AND NVL(o.industry_attribute2,'''||k_VNULL||
9489 ''') = NVL(r.industry_attribute2,'''||k_VNULL|| ''')';
9490 --
9491 ELSE
9492 --
9493 IF x_group_rec.match_within_rec.industry_attribute2 = 'Y' THEN
9494 --
9495 v_where_clause2 := v_where_clause2 ||
9496 ' AND NVL(o.industry_attribute2,'''||k_VNULL||
9497 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute2,'''||
9498 k_VNULL||'''), NVL(o.industry_attribute2,'''||k_VNULL||'''))';
9499 --
9500 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9501 --
9502 END IF;
9503 --
9504 END IF;
9505 --
9506 IF x_group_rec.match_across_rec.industry_attribute4 = 'Y' THEN
9507 --
9508 v_where_clause2 := v_where_clause2 ||
9509 ' AND NVL(o.industry_attribute4,'''||k_VNULL||
9510 ''') = NVL(r.industry_attribute4,'''||k_VNULL|| ''')';
9511 --
9512 ELSE
9513 --
9514 IF x_group_rec.match_within_rec.industry_attribute4 = 'Y' THEN
9515 --
9516 v_where_clause2 := v_where_clause2 ||
9517 ' AND NVL(o.industry_attribute4,'''||k_VNULL||
9518 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute4,'''||
9519 k_VNULL||'''), NVL(o.industry_attribute4,'''||k_VNULL||'''))';
9520 --
9521 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9522 --
9523 END IF;
9524 --
9525 END IF;
9526 --
9527 IF x_group_rec.match_across_rec.industry_attribute5 = 'Y' THEN
9528 --
9529 v_where_clause2 := v_where_clause2 ||
9530 ' AND NVL(o.industry_attribute5,'''||k_VNULL||
9531 ''') = NVL(r.industry_attribute5,'''||k_VNULL|| ''')';
9532 --
9533 ELSE
9534 --
9535 IF x_group_rec.match_within_rec.industry_attribute5 = 'Y' THEN
9536 --
9537 v_where_clause2 := v_where_clause2 ||
9538 ' AND NVL(o.industry_attribute5,'''||k_VNULL||
9539 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute5,'''||
9540 k_VNULL||'''), NVL(o.industry_attribute5,'''||k_VNULL||'''))';
9541 --
9542 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9543 --
9544 END IF;
9545 --
9546 END IF;
9547 --
9548 IF x_group_rec.match_across_rec.industry_attribute6 = 'Y' THEN
9549 --
9550 v_where_clause2 := v_where_clause2 ||
9551 ' AND NVL(o.industry_attribute6,'''||k_VNULL||
9552 ''') = NVL(r.industry_attribute6,'''||k_VNULL|| ''')';
9553 --
9554 ELSE
9555 --
9556 IF x_group_rec.match_within_rec.industry_attribute6 = 'Y' THEN
9557 --
9558 v_where_clause2 := v_where_clause2 ||
9559 ' AND NVL(o.industry_attribute6,'''||k_VNULL||
9560 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute6,'''||
9561 k_VNULL||'''), NVL(o.industry_attribute6,'''||k_VNULL||'''))';
9562 --
9563 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9564 --
9565 END IF;
9566 --
9567 END IF;
9568 --
9569 IF x_group_rec.match_across_rec.industry_attribute10 = 'Y' THEN
9570 --
9571 v_where_clause2 := v_where_clause2 ||
9572 ' AND NVL(o.industry_attribute10,'''||k_VNULL||
9573 ''') = NVL(r.industry_attribute10,'''||k_VNULL|| ''')';
9574 --
9575 ELSE
9576 --
9577 IF x_group_rec.match_within_rec.industry_attribute10 = 'Y' THEN
9578 --
9579 v_where_clause2 := v_where_clause2 ||
9580 ' AND NVL(o.industry_attribute10,'''||k_VNULL||
9581 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute10,'''||
9582 k_VNULL||'''), NVL(o.industry_attribute10,'''||k_VNULL||'''))';
9583 --
9584 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9585 --
9586 END IF;
9587 --
9588 END IF;
9589 --
9590 IF x_group_rec.match_across_rec.industry_attribute11 = 'Y' THEN
9591 --
9592 v_where_clause2 := v_where_clause2 ||
9593 ' AND NVL(o.industry_attribute11,'''||k_VNULL||
9594 ''') = NVL(r.industry_attribute11,'''||k_VNULL|| ''')';
9595 --
9596 ELSE
9597 --
9598 IF x_group_rec.match_within_rec.industry_attribute11 = 'Y' THEN
9599 --
9600 v_where_clause2 := v_where_clause2 ||
9601 ' AND NVL(o.industry_attribute11,'''||k_VNULL||
9602 ''') = DECODE(o.rla_schedule_type_code,:schedule_type, NVL(r.industry_attribute11,'''||
9603 k_VNULL||'''), NVL(o.industry_attribute11,'''||k_VNULL||'''))';
9604 --
9605 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9606 --
9607 END IF;
9608 --
9609 END IF;
9610 --
9611 IF x_group_rec.match_across_rec.industry_attribute12 = 'Y' THEN
9612 --
9613 v_where_clause2 := v_where_clause2 ||
9614 ' AND NVL(o.industry_attribute12,'''||k_VNULL||
9615 ''') = NVL(r.industry_attribute12,'''||k_VNULL|| ''')';
9616 --
9617 ELSE
9618 --
9619 IF x_group_rec.match_within_rec.industry_attribute12 = 'Y' THEN
9620 --
9621 v_where_clause2 := v_where_clause2 ||
9622 ' AND NVL(o.industry_attribute12,'''||k_VNULL||
9623 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute12,'''||
9624 k_VNULL||'''), NVL(o.industry_attribute12,'''||k_VNULL||'''))';
9625 --
9626 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9627 --
9628 END IF;
9629 --
9630 END IF;
9631 --
9632 IF x_group_rec.match_across_rec.industry_attribute13 = 'Y' THEN
9633 --
9634 v_where_clause2 := v_where_clause2 ||
9635 ' AND NVL(o.industry_attribute13,'''||k_VNULL||
9636 ''') = NVL(r.industry_attribute13,'''||k_VNULL|| ''')';
9637 --
9638 ELSE
9639 --
9640 IF x_group_rec.match_within_rec.industry_attribute13 = 'Y' THEN
9641 --
9642 v_where_clause2 := v_where_clause2 ||
9643 ' AND NVL(o.industry_attribute13,'''||k_VNULL||
9644 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute13,'''||
9645 k_VNULL||'''), NVL(o.industry_attribute13,'''||k_VNULL||'''))';
9646 --
9647 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9648 --
9649 END IF;
9650 --
9651 END IF;
9652 --
9653 IF x_group_rec.match_across_rec.industry_attribute14 = 'Y' THEN
9654 --
9655 v_where_clause2 := v_where_clause2 ||
9656 ' AND NVL(o.industry_attribute14,'''||k_VNULL||
9657 ''') = NVL(r.industry_attribute14,'''||k_VNULL|| ''')';
9658 --
9659 ELSE
9660 --
9661 IF x_group_rec.match_within_rec.industry_attribute14 = 'Y' THEN
9662 --
9663 v_where_clause2 := v_where_clause2 ||
9664 ' AND NVL(o.industry_attribute14,'''||k_VNULL||
9665 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.industry_attribute14,'''||
9666 k_VNULL||'''), NVL(o.industry_attribute14,'''||k_VNULL||'''))';
9667 --
9668 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9669 --
9670 END IF;
9671 --
9672 END IF;
9673 --
9674 IF x_group_rec.match_across_rec.attribute1 = 'Y' THEN
9675 --
9676 v_where_clause2 := v_where_clause2 ||
9677 ' AND NVL(o.attribute1,'''||k_VNULL||
9678 ''') = NVL(r.attribute1,'''||k_VNULL|| ''')';
9679 --
9680 ELSE
9681 --
9682 IF x_group_rec.match_within_rec.attribute1 = 'Y' THEN
9683 --
9684 v_where_clause2 := v_where_clause2 ||
9685 ' AND NVL(o.attribute1,'''||k_VNULL||
9686 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute1,'''||
9687 k_VNULL||'''), NVL(o.attribute1,'''||k_VNULL||'''))';
9688 --
9689 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9690 --
9691 END IF;
9692 --
9693 END IF;
9694 --
9695 IF x_group_rec.match_across_rec.attribute2 = 'Y' THEN
9696 --
9697 v_where_clause2 := v_where_clause2 ||
9698 ' AND NVL(o.attribute2,'''||k_VNULL||
9699 ''') = NVL(r.attribute2,'''||k_VNULL|| ''')';
9700 --
9701 ELSE
9702 --
9703 IF x_group_rec.match_within_rec.attribute2 = 'Y' THEN
9704 --
9705 v_where_clause2 := v_where_clause2 ||
9706 ' AND NVL(o.attribute2,'''||k_VNULL||
9707 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute2,'''||
9708 k_VNULL||'''), NVL(o.attribute2,'''||k_VNULL||'''))';
9709 --
9710 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9711 --
9712 END IF;
9713 --
9714 END IF;
9715 --
9716 IF x_group_rec.match_across_rec.attribute3 = 'Y' THEN
9717 --
9718 v_where_clause2 := v_where_clause2 ||
9719 ' AND NVL(o.attribute3,'''||k_VNULL||
9720 ''') = NVL(r.attribute3,'''||k_VNULL|| ''')';
9721 --
9722 ELSE
9723 --
9724 IF x_group_rec.match_within_rec.attribute3 = 'Y' THEN
9725 --
9726 v_where_clause2 := v_where_clause2 ||
9727 ' AND NVL(o.attribute3,'''||k_VNULL||
9728 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute3,'''||
9729 k_VNULL||'''), NVL(o.attribute3,'''||k_VNULL||'''))';
9730 --
9731 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9732 --
9733 END IF;
9734 --
9735 END IF;
9736 --
9737 IF x_group_rec.match_across_rec.attribute4 = 'Y' THEN
9738 --
9739 v_where_clause2 := v_where_clause2 ||
9740 ' AND NVL(o.attribute4,'''||k_VNULL||
9741 ''') = NVL(r.attribute4,'''||k_VNULL|| ''')';
9742 --
9743 ELSE
9744 --
9745 IF x_group_rec.match_within_rec.attribute4 = 'Y' THEN
9746 --
9747 v_where_clause2 := v_where_clause2 ||
9748 ' AND NVL(o.attribute4,'''||k_VNULL||
9749 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute4,'''||
9750 k_VNULL||'''), NVL(o.attribute4,'''||k_VNULL||'''))';
9751 --
9752 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9753 --
9754 END IF;
9755 --
9756 END IF;
9757 --
9758 IF x_group_rec.match_across_rec.attribute5 = 'Y' THEN
9759 --
9760 v_where_clause2 := v_where_clause2 ||
9761 ' AND NVL(o.attribute5,'''||k_VNULL||
9762 ''') = NVL(r.attribute5,'''||k_VNULL|| ''')';
9763 --
9764 ELSE
9765 --
9766 IF x_group_rec.match_within_rec.attribute5 = 'Y' THEN
9767 --
9768 v_where_clause2 := v_where_clause2 ||
9769 ' AND NVL(o.attribute5,'''||k_VNULL||
9770 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute5,'''||
9771 k_VNULL||'''), NVL(o.attribute5,'''||k_VNULL||'''))';
9772 --
9773 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9774 --
9775 END IF;
9776 --
9777 END IF;
9778 --
9779 IF x_group_rec.match_across_rec.attribute6 = 'Y' THEN
9780 --
9781 v_where_clause2 := v_where_clause2 ||
9782 ' AND NVL(o.attribute6,'''||k_VNULL||
9783 ''') = NVL(r.attribute6,'''||k_VNULL|| ''')';
9784 --
9785 ELSE
9786 --
9787 IF x_group_rec.match_within_rec.attribute6 = 'Y' THEN
9788 --
9789 v_where_clause2 := v_where_clause2 ||
9790 ' AND NVL(o.attribute6,'''||k_VNULL||
9791 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute6,'''||
9792 k_VNULL||'''), NVL(o.attribute6,'''||k_VNULL||'''))';
9793 --
9794 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9795 --
9796 END IF;
9797 --
9798 END IF;
9799 --
9800 IF x_group_rec.match_across_rec.attribute7 = 'Y' THEN
9801 --
9802 v_where_clause2 := v_where_clause2 ||
9803 ' AND NVL(o.attribute7,'''||k_VNULL||
9804 ''') = NVL(r.attribute7,'''||k_VNULL|| ''')';
9805 --
9806 ELSE
9807 --
9808 IF x_group_rec.match_within_rec.attribute7 = 'Y' THEN
9809 --
9810 v_where_clause2 := v_where_clause2 ||
9811 ' AND NVL(o.attribute7,'''||k_VNULL||
9812 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute7,'''||
9813 k_VNULL||'''), NVL(o.attribute7,'''||k_VNULL||'''))';
9814 --
9815 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9816 --
9817 END IF;
9818 --
9819 END IF;
9820 --
9821 IF x_group_rec.match_across_rec.attribute8 = 'Y' THEN
9822 --
9823 v_where_clause2 := v_where_clause2 ||
9824 ' AND NVL(o.attribute8,'''||k_VNULL||
9825 ''') = NVL(r.attribute8,'''||k_VNULL|| ''')';
9826 --
9827 ELSE
9828 --
9829 IF x_group_rec.match_within_rec.attribute8 = 'Y' THEN
9830 --
9831 v_where_clause2 := v_where_clause2 ||
9832 ' AND NVL(o.attribute8,'''||k_VNULL||
9833 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute8,'''||
9834 k_VNULL||'''), NVL(o.attribute8,'''||k_VNULL||'''))';
9835 --
9836 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9837 --
9838 END IF;
9839 --
9840 END IF;
9841 --
9842 IF x_group_rec.match_across_rec.attribute9 = 'Y' THEN
9843 --
9844 v_where_clause2 := v_where_clause2 ||
9845 ' AND NVL(o.attribute9,'''||k_VNULL||
9846 ''') = NVL(r.attribute9,'''||k_VNULL|| ''')';
9847 --
9848 ELSE
9849 --
9850 IF x_group_rec.match_within_rec.attribute9 = 'Y' THEN
9851 --
9852 v_where_clause2 := v_where_clause2 ||
9853 ' AND NVL(o.attribute9,'''||k_VNULL||
9854 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute9,'''||
9855 k_VNULL||'''), NVL(o.attribute9,'''||k_VNULL||'''))';
9856 --
9857 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9858 --
9859 END IF;
9860 --
9861 END IF;
9862 --
9863 IF x_group_rec.match_across_rec.attribute10 = 'Y' THEN
9864 --
9865 v_where_clause2 := v_where_clause2 ||
9866 ' AND NVL(o.attribute10,'''||k_VNULL||
9867 ''') = NVL(r.attribute10,'''||k_VNULL|| ''')';
9868 --
9869 ELSE
9870 --
9871 IF x_group_rec.match_within_rec.attribute10 = 'Y' THEN
9872 --
9873 v_where_clause2 := v_where_clause2 ||
9874 ' AND NVL(o.attribute10,'''||k_VNULL||
9875 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute10,'''||
9876 k_VNULL||'''), NVL(o.attribute10,'''||k_VNULL||'''))';
9877 --
9878 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9879 --
9880 END IF;
9881 --
9882 END IF;
9883 --
9884 IF x_group_rec.match_across_rec.attribute11 = 'Y' THEN
9885 --
9886 v_where_clause2 := v_where_clause2 ||
9887 ' AND NVL(o.attribute11,'''||k_VNULL||
9888 ''') = NVL(r.attribute11,'''||k_VNULL|| ''')';
9889 --
9890 ELSE
9891 --
9892 IF x_group_rec.match_within_rec.attribute11 = 'Y' THEN
9893 --
9894 v_where_clause2 := v_where_clause2 ||
9895 ' AND NVL(o.attribute11,'''||k_VNULL||
9896 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute11,'''||
9897 k_VNULL||'''), NVL(o.attribute11,'''||k_VNULL||'''))';
9898 --
9899 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9900 --
9901 END IF;
9902 --
9903 END IF;
9904 --
9905 IF x_group_rec.match_across_rec.attribute12 = 'Y' THEN
9906 --
9907 v_where_clause2 := v_where_clause2 ||
9908 ' AND NVL(o.attribute12,'''||k_VNULL||
9909 ''') = NVL(r.attribute12,'''||k_VNULL|| ''')';
9910 --
9911 ELSE
9912 --
9913 IF x_group_rec.match_within_rec.attribute12 = 'Y' THEN
9914 --
9915 v_where_clause2 := v_where_clause2 ||
9916 ' AND NVL(o.attribute12,'''||k_VNULL||
9917 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute12,'''||
9918 k_VNULL||'''), NVL(o.attribute12,'''||k_VNULL||'''))';
9919 --
9920 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9921 --
9922 END IF;
9923 --
9924 END IF;
9925 --
9926 IF x_group_rec.match_across_rec.attribute13 = 'Y' THEN
9927 --
9928 v_where_clause2 := v_where_clause2 ||
9929 ' AND NVL(o.attribute13,'''||k_VNULL||
9930 ''') = NVL(r.attribute13,'''||k_VNULL|| ''')';
9931 --
9932 ELSE
9933 --
9934 IF x_group_rec.match_within_rec.attribute13 = 'Y' THEN
9935 --
9936 v_where_clause2 := v_where_clause2 ||
9937 ' AND NVL(o.attribute13,'''||k_VNULL||
9938 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute13,'''||
9939 k_VNULL||'''), NVL(o.attribute13,'''||k_VNULL||'''))';
9940 --
9941 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9942 --
9943 END IF;
9944 --
9945 END IF;
9946 --
9947 IF x_group_rec.match_across_rec.attribute14 = 'Y' THEN
9948 --
9949 v_where_clause2 := v_where_clause2 ||
9950 ' AND NVL(o.attribute14,'''||k_VNULL||
9951 ''') = NVL(r.attribute14,'''||k_VNULL|| ''')';
9952 --
9953 ELSE
9954 --
9955 IF x_group_rec.match_within_rec.attribute14 = 'Y' THEN
9956 --
9957 v_where_clause2 := v_where_clause2 ||
9958 ' AND NVL(o.attribute14,'''||k_VNULL||
9959 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute14,'''||
9960 k_VNULL||'''), NVL(o.attribute14,'''||k_VNULL||'''))';
9961 --
9962 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9963 --
9964 END IF;
9965 --
9966 END IF;
9967 --
9968 IF x_group_rec.match_across_rec.attribute15 = 'Y' THEN
9969 --
9970 v_where_clause2 := v_where_clause2 ||
9971 ' AND NVL(o.attribute15,'''||k_VNULL||
9972 ''') = NVL(r.attribute15,'''||k_VNULL|| ''')';
9973 --
9974 ELSE
9975 --
9976 IF x_group_rec.match_within_rec.attribute15 = 'Y' THEN
9977 --
9978 v_where_clause2 := v_where_clause2 ||
9979 ' AND NVL(o.attribute15,'''||k_VNULL||
9980 ''') = DECODE(o.rla_schedule_type_code, :schedule_type, NVL(r.attribute15,'''||
9981 k_VNULL||'''), NVL(o.attribute15,'''||k_VNULL||'''))';
9982 --
9983 g_WhereTab2(g_WhereTab2.COUNT+1) := x_Sched_rec.schedule_type;
9984 --
9985 END IF;
9986 --
9987 END IF;
9988 --
9989
9990 w_where_clause1 :=
9991 'WHERE r1.order_header_id = :order_header_id' ||
9992 ' AND r1.header_id = :header_id' ||
9993 ' AND r1.ship_from_org_id = :ship_from_org_id' ||
9994 ' AND r1.industry_attribute15 = :industry_attribute15' ||
9995 ' AND r1.ship_to_org_id = :ship_to_org_id' ||
9996 ' AND r1.customer_item_id = :customer_item_id' ||
9997 ' AND r1.inventory_item_id = :inventory_item_id' ||
9998 ' AND r1.process_status IN ('||rlm_core_sv.k_PS_AVAILABLE||','||rlm_core_sv.k_PS_FROZEN_FIRM||')';
9999 --
10000 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.order_header_id;
10001 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Sched_rec.header_id;
10002 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.ship_from_org_id;
10003 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.industry_attribute15;
10004 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.ship_to_org_id;
10005 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.customer_item_id;
10006 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.inventory_item_id;
10007 --
10008 IF g_ATP <> k_ATP THEN
10009 --
10010 v_where_clause1 := v_where_clause1 ||
10011 ' AND o.ship_from_org_id = r.ship_from_org_id '||
10012 ' AND o.ship_from_org_id = :ship_from_org_id'||
10013 ' AND r.ship_from_org_id = :ship_from_org_id';
10014 --
10015 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_from_org_id;
10016 g_WhereTab1(g_WhereTab1.COUNT+1) := x_Group_rec.ship_from_org_id;
10017 --
10018 v_where_clause1 := v_where_clause1 ||
10019 ' AND NVL(o.industry_attribute15,'''||k_VNULL||
10020 ''') = NVL(r.industry_attribute15,'''||k_VNULL|| ''')';
10021 --
10022 END IF;
10023 --
10024
10025 -- match on blanket number only if blankets are used
10026 --
10027 IF x_Group_rec.blanket_number IS NOT NULL THEN
10028 v_where_clause1 := v_where_clause1 || ' AND o.blanket_number = r.blanket_number ';
10029 w_where_clause1 := w_where_clause1 || ' AND r1.blanket_number = :blanket_number ';
10030 --
10031 g_NewDemandTab(g_NewDemandTab.COUNT+1) := x_Group_rec.blanket_number;
10032 --
10033 END IF;
10034 --
10035
10036 IF x_Demand_Type = k_ATS THEN
10037 --
10038 -- Begin ArvinMeritor Change
10039 --
10040 IF x_Group_rec.disposition_code = k_CANCEL_ALL THEN
10041 --
10042 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'') ';
10043 --
10044 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(rlm_dp_sv.g_dsp_start_time),'RRRR/MM/DD HH24:MI:SS'); --Bugfix 10053830
10045 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
10046 --
10047 ELSIF x_Group_rec.disposition_code = k_CANCEL_AFTER_N_DAYS THEN
10048 --
10049 v_Date := rlm_dp_sv.g_dsp_start_time - nvl(x_Group_rec.cutoff_days, 0); --Bugfix 10053830
10050 rlm_core_sv.dlog(k_DEBUG, 'x_Group_rec.cutoff_days', x_Group_rec.cutoff_days);
10051 rlm_core_sv.dlog(k_DEBUG, 'v_Date', v_Date);
10052 --
10053 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'') ';
10054 --
10055 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(v_Date),'RRRR/MM/DD HH24:MI:SS');
10056 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
10057 --
10058 ELSIF x_Group_rec.disposition_code = k_REMAIN_ON_FILE_RECONCILE THEN
10059 --
10060 -- bug4223359 For 'RemainOnFileReconcile' consider all the open order lines to be matched.
10061 --
10062 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'') ';
10063 --
10064 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
10065 --
10066 ELSE
10067 --
10068 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'') ';
10069 --
10070 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date),'RRRR/MM/DD HH24:MI:SS');
10071 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
10072 --
10073 END IF;
10074 --
10075 v_where_clause1 := v_where_clause1 || ' AND ' || v_ATSWhere;
10076 --
10077 -- End ArvinMeritor Change
10078 --
10079 --
10080 v_where_clause1 := v_where_clause1 ||
10081 ' AND (r.item_detail_type = '''||k_FIRM||''' OR r.item_detail_type = '''||k_PAST_DUE_FIRM||''')'; --Bugfix 8597878 Added single quotes
10082 --
10083 w_where_clause1 := w_where_clause1 ||
10084 ' AND (r1.item_detail_type = '''||k_FIRM||''' OR r1.item_detail_type = '''||k_PAST_DUE_FIRM||''')'; --Bugfix 8597878 Added single quotes
10085
10086 -- this is to let ATS replace existing NATS
10087 x_Sql1 := v_select_clause ||
10088 v_where_clause1 ||
10089 v_where_clause2 ||
10090 ' AND o.authorized_to_ship_flag = ''N'' ';
10091
10092 -- this has to come after x_Sql1
10093 v_where_clause2 := v_where_clause2 ||
10094 ' AND o.authorized_to_ship_flag = ''Y'' ';
10095 --
10096 ELSE /* k_NATS */
10097 --
10098 -- Begin ArvinMeritor Change
10099 --
10100 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'') ';
10101 --
10102 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR(TRUNC(rlm_dp_sv.g_dsp_start_time),'RRRR/MM/DD HH24:MI:SS'); --Bugfix 10053830
10103 g_WhereTab1(g_WhereTab1.COUNT+1):= TO_CHAR((TRUNC(x_Sched_rec.sched_horizon_end_date)+0.99999),'RRRR/MM/DD HH24:MI:SS');
10104 --
10105 v_where_clause1 := v_where_clause1 || ' AND ' || v_NATSWhere;
10106 --
10107 -- End ArvinMeritor Change
10108 v_where_clause1 := v_where_clause1 ||
10109 ' AND r.item_detail_type = '''|| k_FORECAST||''''; --Bugfix 8597878 Added single quotes
10110 --
10111 w_where_clause1 := w_where_clause1 ||
10112 ' AND r1.item_detail_type = '''|| k_FORECAST||''''; --Bugfix 8597878 Added single quotes
10113
10114 -- this is to let NATS replace existing ATS
10115 x_Sql1 := v_select_clause ||
10116 v_where_clause1 ||
10117 v_where_clause2 ||
10118 ' AND o.authorized_to_ship_flag = ''Y'' ';
10119
10120 -- this has to come after x_Sql1
10121 v_where_clause2 := v_where_clause2 ||
10122 ' AND o.authorized_to_ship_flag = ''N'' ';
10123 --
10124 END IF;
10125 --
10126
10127 -- subquery
10128 w_select_clause2 :=
10129 '(SELECT ''X'' ' ||
10130 'FROM oe_order_lines_all o,rlm_interface_lines r ' ||
10131 v_where_clause1 ||
10132 v_where_clause2 ||
10133 ' AND r1.line_id = r.line_id) ';
10134
10135 v_order_clause :=
10136 ' ORDER BY request_date, line_id ';
10137 --
10138
10139 x_Sql2 := w_select_clause1 ||
10140 w_where_clause1 ||
10141 ' AND NOT EXISTS ' ||
10142 w_select_clause2 ||
10143 v_order_clause;
10144
10145
10146 x_Sql := v_select_clause ||
10147 v_where_clause1 ||
10148 v_where_clause2 ||
10149 ' UNION ALL ' || x_Sql2;
10150
10151 x_Sum_Sql := 'SELECT r.line_id, SUM(NVL(o.ordered_quantity,0)-NVL(o.shipped_quantity,0)), COUNT(1), MIN(o.line_id) ' ||
10152 'FROM rlm_interface_lines r, oe_order_lines_all o ' ||
10153 v_where_clause1 ||
10154 v_where_clause2 ||
10155 ' GROUP BY r.line_id ORDER BY line_id';
10156
10157 IF (l_debug <> -1) THEN
10158 rlm_core_sv.dlog(k_DEBUG, 'v_select_clause', v_select_clause);
10159 rlm_core_sv.dlog(k_DEBUG, 'v_ATSWhere', v_ATSWhere);
10160 rlm_core_sv.dlog(k_DEBUG, 'v_NATSWhere', v_NATSWhere);
10161 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1', substr(v_where_clause1, 1, 800));
10162 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1 Contd.', substr(v_where_clause1, 800, 1600));
10163 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause1 Contd.', substr(v_where_clause1, 1600, 2400));
10164 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2', substr(v_where_clause2, 1, 800));
10165 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2 Contd.', substr(v_where_clause2, 800, 1600));
10166 rlm_core_sv.dlog(k_DEBUG, 'v_where_clause2 Contd.', substr(v_where_clause2, 1600, 2400));
10167 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause1', w_select_clause1);
10168 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2', substr(w_select_clause2, 1, 800));
10169 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2 Contd.', substr(w_select_clause2, 800, 1600));
10170 rlm_core_sv.dlog(k_DEBUG, 'w_select_clause2 Contd.', substr(w_select_clause2, 1600, 2400));
10171 rlm_core_sv.dlog(k_DEBUG, 'w_where_clause1', w_where_clause1);
10172 rlm_core_sv.dlog(k_DEBUG, 'x_Sum_Sql', x_Sum_Sql);
10173 rlm_core_sv.dlog(k_DEBUG, 'v_order_clause', v_order_clause);
10174 rlm_core_sv.dpop(k_SDEBUG);
10175 END IF;
10176 --
10177
10178 EXCEPTION
10179
10180 WHEN OTHERS THEN
10181 rlm_message_sv.sql_error('rlm_rd_sv.BuildMatchQuery',x_progress);
10182 IF (l_debug <> -1) THEN
10183 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10184 END IF;
10185 RAISE;
10186
10187 END;
10188
10189
10190 /*===========================================================================
10191
10192 PROCEDURE ProcessATS -
10193 (1) New code with performance changes (dynamic sql)
10194
10195 ===========================================================================*/
10196
10197 PROCEDURE ProcessATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10198 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
10199 IS
10200
10201 v_Key_rec t_Key_rec;
10202 v_ScheduleType VARCHAR2(30);
10203 v_SumOrderedQty NUMBER DEFAULT 0;
10204 v_SumOrderedQtyTmp NUMBER DEFAULT 0;
10205 v_DemandCount NUMBER DEFAULT 0;
10206 v_LowestOeLineId NUMBER DEFAULT 0;
10207 v_line_id_tab t_matching_line;
10208 v_line_id_tmp NUMBER DEFAULT 0;
10209 --
10210 v_DeleteQty NUMBER;
10211 c_NATS t_Cursor_ref;
10212 c_Matched t_Cursor_ref;
10213 c_Sum t_Cursor_ref;
10214 x_progress VARCHAR2(3) := '010';
10215 v_NewCount NUMBER DEFAULT 0;
10216 v_AtsDemand VARCHAR2(32000);
10217 v_NatsDemand VARCHAR2(32000);
10218 v_SumDemand VARCHAR2(32000);
10219 v_NewDemand VARCHAR2(32000);
10220 v_LineId NUMBER;
10221 v_LineMatch t_Line_Match_Tab;
10222 v_LowestLineId NUMBER;
10223 v_min_horizon_date VARCHAR2(40);
10224 v_InTransitQty NUMBER :=0;
10225 v_ActualCount NUMBER;
10226 -- Bug 5608510
10227 v_total_ordered_qty NUMBER :=0;
10228 v_total_partial_shipped_qty NUMBER :=0;
10229 v_check_partial_flag VARCHAR2(1) :='N';
10230 --
10231 BEGIN
10232 --
10233 IF (l_debug <> -1) THEN
10234 rlm_core_sv.dpush(k_SDEBUG,'ProcessATS');
10235 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.header_id', x_Sched_rec.header_id);
10236 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
10237 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
10238 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
10239 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
10240 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.industry_attribute15', x_Group_rec.industry_attribute15);
10241 END IF;
10242
10243 IF(UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES', 'PART_SHIP_LINES' )) THEN
10244 --
10245 --Bug 3549475 jckwok
10246 --
10247 SELECT COUNT(*)
10248 INTO v_ActualCount
10249 FROM rlm_interface_lines il,
10250 rlm_schedule_lines_all sl
10251 WHERE il.header_id = x_Sched_rec.header_id
10252 AND il.ship_from_org_id = x_Group_rec.ship_from_org_id
10253 AND il.ship_to_org_id = x_Group_rec.ship_to_org_id
10254 AND il.inventory_item_id = x_Group_rec.inventory_item_id
10255 AND il.customer_item_id = x_Group_rec.customer_item_id
10256 AND il.schedule_line_id = sl.line_id
10257 AND NVL(il.item_detail_type, ' ')
10258 <> rlm_manage_demand_sv.k_SHIP_RECEIPT_INFO
10259 AND sl.qty_type_code = rlm_manage_demand_sv.k_ACTUAL
10260 AND il.org_id = sl.org_id;
10261 --
10262 IF (l_debug <> -1) THEN
10263 rlm_core_sv.dlog(k_DEBUG,'number of lines with qty_type_code ACTUAL: ',v_ActualCount);
10264 END IF;
10265 --
10266 IF (v_ActualCount > 0 ) THEN
10267 --
10268 SELECT TO_CHAR(TRUNC(min(request_date)), 'RRRR/MM/DD HH24:MI:SS')
10269 INTO v_min_horizon_date
10270 FROM rlm_interface_lines
10271 WHERE header_id=x_sched_rec.header_id
10272 AND inventory_item_id = x_group_rec.inventory_item_id
10273 AND customer_item_id = x_group_rec.customer_item_id
10274 AND Ship_from_org_id=x_group_rec.ship_from_org_id
10275 AND Ship_to_address_id=x_group_rec.ship_to_address_id;
10276
10277 IF (l_debug <> -1) THEN
10278 rlm_core_sv.dlog(k_DEBUG, 'v_min_request_date', v_min_horizon_date);
10279 END IF;
10280 --
10281 IF TO_DATE(v_min_horizon_date,'RRRR/MM/DD HH24:MI:SS') > x_Sched_rec.sched_horizon_start_date THEN
10282 --
10283 v_min_horizon_date:= TO_CHAR(TRUNC(x_Sched_rec.sched_horizon_start_date), 'RRRR/MM/DD HH24:MI:SS');
10284 --
10285 END IF;
10286 --
10287 IF (l_debug <> -1) THEN
10288 rlm_core_sv.dlog(k_DEBUG, 'v_min_horizon_date', v_min_horizon_date);
10289 END IF;
10290 END IF;
10291 END IF;
10292 --
10293 -- Delete all the bind variable tables
10294 --
10295 g_NewDemandTab.DELETE;
10296 g_WhereTab1.DELETE;
10297 g_WhereTab2.DELETE;
10298 g_BindVarTab.DELETE;
10299 --
10300 RLM_TPA_SV.BuildMatchQuery(x_sched_rec,
10301 x_Group_rec,
10302 k_ATS,
10303 v_AtsDemand,
10304 v_NatsDemand,
10305 v_NewDemand,
10306 v_SumDemand);
10307 --
10308 -- (1) Handle the case when incoming ATS match existing NATS
10309 --
10310 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10311 --
10312 IF (l_debug <> -1) THEN
10313 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NATS cursor', g_BindVarTab.COUNT);
10314 END IF;
10315 --
10316 RLM_CORE_SV.OpenDynamicCursor(c_NATS, v_NatsDemand, g_BindVarTab);
10317 --
10318 WHILE FetchReq(c_NATS,
10319 v_Key_rec,
10320 v_line_id_tmp,
10321 v_SumOrderedQtyTmp,
10322 v_ScheduleType)
10323
10324 LOOP
10325
10326 EXIT WHEN c_NATS%NOTFOUND;
10327 --
10328 IF (l_debug <> -1) THEN
10329 --
10330 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10331 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10332 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10333 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10334 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10335 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);
10336 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10337 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10338 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10339 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10340 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10341 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10342 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10343 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10344 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10345 --
10346 END IF;
10347
10348 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE, k_CANCEL, k_ADD) THEN
10349 --
10350 v_Key_rec.oe_line_id := v_line_id_tmp;
10351 --
10352 IF (l_debug <> -1) THEN
10353 rlm_core_sv.dlog(k_DEBUG, 'OM NATS Line Id', v_line_id_tmp);
10354 END IF;
10355 --
10356 GetDemand(v_Key_rec, x_Group_rec);
10357 --
10358 IF SchedulePrecedence(x_Group_rec, x_Sched_rec, v_ScheduleType) THEN
10359 --
10360 DeleteRequirement(x_Sched_rec, x_Group_rec,
10361 v_Key_rec, k_RECONCILE,
10362 v_DeleteQty);
10363 --
10364 END IF;
10365 --
10366 END IF;
10367 --
10368 END LOOP;
10369 CLOSE c_NATS;
10370 --
10371 -- (2) Find all the ATS and NATS demand that matches in OM
10372 --
10373 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10374 --
10375 IF (l_debug <> -1) THEN
10376 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_SumDemand cursor', g_BindVarTab.COUNT);
10377 END IF;
10378 --
10379 RLM_CORE_SV.OpenDynamicCursor(c_Sum, v_SumDemand, g_BindVarTab);
10380 --
10381 FETCH c_Sum INTO v_LowestLineId,
10382 v_SumOrderedQtyTmp,
10383 v_DemandCount,
10384 v_LowestOeLineId;
10385 IF c_Sum%FOUND THEN
10386 --
10387 v_LineMatch(0).sum_qty := v_SumOrderedQtyTmp;
10388 v_LineMatch(0).match_count := v_DemandCount;
10389 v_LineMatch(0).lowest_oelineid := v_LowestOeLineId;
10390 --
10391 IF (l_debug <> -1) THEN
10392 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10393 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10394 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10395 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10396 END IF;
10397 --
10398 LOOP
10399 FETCH c_Sum INTO v_LineId,
10400 v_SumOrderedQtyTmp,
10401 v_DemandCount,
10402 v_LowestOeLineId;
10403 EXIT WHEN c_Sum%NOTFOUND;
10404 v_LineMatch(v_LineId-v_LowestLineId).sum_qty := v_SumOrderedQtyTmp;
10405 v_LineMatch(v_LineId-v_LowestLineId).match_count := v_DemandCount;
10406 v_LineMatch(v_LineId-v_LowestLineId).lowest_oelineid := v_LowestOeLineId;
10407 IF (l_debug <> -1) THEN
10408 rlm_core_sv.dlog(k_DEBUG,'For RLM Line Id', v_LineId);
10409 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10410 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10411 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10412 END IF;
10413 END LOOP;
10414 --
10415 END IF;
10416 CLOSE c_Sum;
10417 --
10418 IF (l_debug <> -1) THEN
10419 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10420 END IF;
10421 --
10422 IF v_LineMatch.COUNT > 0 THEN
10423 --
10424 -- (3) Find all ATS demand that matched in OM
10425 --
10426 g_BindVarTab := BuildBindVarTab5(g_WhereTab1, g_WhereTab2, g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10427 --
10428 IF (l_debug <> -1) THEN
10429 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_ATSDemand cursor', g_BindVarTab.COUNT);
10430 rlm_core_sv.dlog(k_DEBUG,'Opening for v_AtsDemand');
10431 END IF;
10432 --
10433 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_ATSDemand, g_BindVarTab);
10434 --
10435 ELSE
10436 --
10437 -- (4) Find all ATS demand that did not match with lines in OM
10438 --
10439 g_BindVarTab := BuildBindVarTab3(g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10440 --
10441 IF (l_debug <> -1) THEN
10442 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NewDemand cursor', g_BindVarTab.COUNT);
10443 rlm_core_sv.dlog(k_DEBUG,'Opening for v_NewDemand');
10444 END IF;
10445 --
10446 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NewDemand, g_BindVarTab);
10447 --
10448 END IF;
10449 --
10450 WHILE FetchReq(c_Matched,
10451 v_Key_rec,
10452 v_line_id_tmp,
10453 v_SumOrderedQtyTmp,
10454 v_ScheduleType)
10455 LOOP
10456
10457 EXIT WHEN c_Matched%NOTFOUND;
10458 --
10459 IF (l_debug <> -1) THEN
10460 --
10461 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10462 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10463 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10464 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10465 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10466 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);
10467 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10468 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10469 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10470 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10471 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10472 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10473 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10474 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10475 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10476 --
10477 END IF;
10478 --
10479 g_sch_line_qty := v_Key_rec.req_rec.primary_quantity; --Bugfix 6131516
10480 -- start of bug fix 4223359
10481 --
10482 IF (v_key_rec.req_rec.process_status <> rlm_core_sv.k_PS_FROZEN_FIRM) THEN
10483 --
10484 FrozenFenceWarning(x_sched_rec, x_group_rec);
10485 --
10486 END IF;
10487 --
10488 -- end of bug fix 4223359
10489 --
10490 -- When there is NO MATCH
10491
10492 IF v_line_id_tmp IS NULL THEN
10493 --
10494 --Intransit Based on Shipped Lines
10495 --
10496 -- Bug 3549475 Added condition to check if there is at least one ACTUAL lines jckwok
10497 IF(UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES','PART_SHIP_LINES')
10498 AND v_ActualCount > 0) THEN
10499 --
10500 RLM_EXTINTERFACE_SV.GetIntransitShippedLines(x_Sched_rec,
10501 x_Group_rec,
10502 v_Key_rec.req_rec,
10503 v_min_horizon_date,
10504 v_InTransitQty);
10505 IF(v_InTransitQty >0 ) THEN
10506 --
10507 v_key_rec.req_rec.shipment_flag := 'SHIPMENT';
10508 StoreShipments(x_Sched_rec,
10509 x_Group_rec,
10510 v_Key_rec,
10511 v_InTransitQty);
10512 --
10513 END IF;
10514 --
10515 END IF;
10516
10517 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
10518 --
10519 v_NewCount := v_NewCount +1;
10520 --
10521 IF (l_debug <> -1) THEN
10522 rlm_core_sv.dlog(k_DEBUG,'v_NewCount', v_NewCount);
10523 END IF;
10524 --
10525 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
10526 v_Key_rec, k_RECONCILE,
10527 v_Key_rec.req_rec.primary_quantity);
10528 END IF;
10529 --
10530 -- When there is a MATCH
10531 ELSE
10532
10533 IF (l_debug <> -1) THEN
10534 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', v_Key_rec.req_rec.line_id);
10535 END IF;
10536 --
10537 IF v_line_id_tmp = v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).lowest_oelineid THEN
10538 --
10539 v_DemandCount := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).match_count;
10540 v_SumOrderedQty := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).sum_qty;
10541 v_line_id_tab(0) := v_line_id_tmp;
10542
10543 --Intransit Based on Shipped Lines
10544 -- Bug 5608510
10545 v_check_partial_flag := 'N' ;
10546 IF (UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) IN ('SHIPPED_LINES','PART_SHIP_LINES')
10547 AND v_ActualCount > 0) THEN
10548 --
10549 RLM_EXTINTERFACE_SV.GetIntransitShippedLines(x_Sched_rec,
10550 x_Group_rec,
10551 v_Key_rec.req_rec,
10552 v_min_horizon_date,
10553 v_InTransitQty);
10554 --Bug 5608510
10555 IF(v_InTransitQty >0 ) THEN
10556 --
10557 IF (UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis) = 'PART_SHIP_LINES' ) THEN
10558
10559 v_total_ordered_qty := 0 ;
10560 v_total_partial_shipped_qty := 0;
10561
10562 BEGIN
10563 SELECT SUM(nvl(ordered_quantity,0)) ,SUM(nvl(shipped_quantity,0))
10564 INTO v_total_ordered_qty, v_total_partial_shipped_qty
10565 FROM oe_order_lines oel
10566 WHERE oel.line_set_id IN
10567 (SELECT ol.line_set_id
10568 FROM oe_order_lines ol
10569 WHERE ol.line_id = v_line_id_tmp);
10570 --
10571 IF (l_debug <> -1) THEN
10572 rlm_core_sv.dlog(k_DEBUG,' Total Order Quantity', v_total_ordered_qty);
10573 rlm_core_sv.dlog(k_DEBUG,' Partial Shipped Quantity' , v_total_partial_shipped_qty);
10574 END IF;
10575 --
10576 EXCEPTION
10577 WHEN OTHERS THEN
10578 --
10579 IF (l_debug <> -1) THEN
10580 rlm_core_sv.dlog(k_DEBUG,'When Other Exception PART_SHIP_LINES',substr(sqlerrm,1,200));
10581 END IF;
10582 --
10583 END;
10584
10585 END IF ;
10586 --
10587 --
10588 IF ((v_InTransitQty < v_total_ordered_qty AND v_total_partial_shipped_qty > 0 )
10589 AND (v_total_ordered_qty > v_Key_rec.req_rec.primary_quantity )) THEN
10590 --
10591 IF v_Key_rec.req_rec.primary_quantity <> 0 THEN
10592 v_check_partial_flag := 'Y';
10593 END IF;
10594 --
10595 IF (l_debug <> -1) THEN
10596 rlm_core_sv.dlog(k_DEBUG,'Intransit Qty ',v_InTransitQty);
10597 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity ',v_Key_rec.req_rec.primary_quantity );
10598 rlm_core_sv.dlog(k_DEBUG,'v_check_partial_flag ',v_check_partial_flag );
10599 END IF;
10600 --
10601 ELSE
10602 --
10603 v_key_rec.req_rec.shipment_flag := 'SHIPMENT';
10604 StoreShipments(x_Sched_rec,
10605 x_Group_rec,
10606 v_Key_rec,
10607 v_InTransitQty);
10608 --
10609 END IF;
10610 --
10611 END IF;
10612 --
10613 END IF ;
10614 --
10615 --bug 5608510
10616 --
10617 IF v_check_partial_flag = 'N' THEN
10618 RLM_TPA_SV.ReconcileAction(x_sched_rec,
10619 x_group_rec,
10620 v_Key_rec,
10621 v_line_id_tab,
10622 v_DemandCount,
10623 v_SumOrderedQty,
10624 k_ATS);
10625 v_line_id_tab.DELETE;
10626 --
10627 END IF;
10628 --
10629 END IF;
10630 --
10631 END IF;
10632 END LOOP;
10633 --
10634 CLOSE c_Matched;
10635 --
10636 g_sch_line_qty :=0; --Bugfix 6159269
10637 IF (l_debug <> -1) THEN
10638 rlm_core_sv.dpop(k_SDEBUG);
10639 END IF;
10640 --
10641 EXCEPTION
10642
10643 WHEN e_group_error THEN
10644 --
10645 IF (l_debug <> -1) THEN
10646 rlm_core_sv.dlog(k_DEBUG,'group error');
10647 rlm_core_sv.dpop(k_SDEBUG);
10648 END IF;
10649 --
10650 raise e_group_error;
10651
10652 WHEN OTHERS THEN
10653 rlm_message_sv.sql_error('rlm_rd_sv.ProcessATS',x_progress);
10654 --
10655 IF (l_debug <> -1) THEN
10656 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10657 END IF;
10658 --
10659 raise;
10660
10661 END ProcessATS;
10662
10663
10664 /*===========================================================================
10665
10666 PROCEDURE ProcessNATS
10667 (1) New version with dynamic sql for performance changes
10668
10669 ===========================================================================*/
10670
10671 PROCEDURE ProcessNATS(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10672 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
10673 IS
10674
10675 v_Key_rec t_Key_rec;
10676 v_ScheduleType VARCHAR2(30);
10677 v_SumOrderedQty NUMBER DEFAULT 0;
10678 v_SumOrderedQtyTmp NUMBER DEFAULT 0;
10679 v_DemandCount NUMBER DEFAULT 0;
10680 v_LowestOeLineId NUMBER DEFAULT 0;
10681 v_line_id_tab t_matching_line;
10682 v_line_id_tmp NUMBER DEFAULT 0;
10683 --
10684 v_DeleteQty NUMBER;
10685 c_ATS t_Cursor_ref;
10686 c_Matched t_Cursor_ref;
10687 c_Sum t_Cursor_ref;
10688 x_progress VARCHAR2(3) := '010';
10689 v_NewCount NUMBER DEFAULT 0;
10690 v_NatsDemand VARCHAR2(32000);
10691 v_AtsDemand VARCHAR2(32000);
10692 v_SumDemand VARCHAR2(32000);
10693 v_NewDemand VARCHAR2(32000);
10694 v_LineId NUMBER;
10695 v_LineMatch t_Line_Match_Tab;
10696 v_LowestLineId NUMBER;
10697 --
10698 BEGIN
10699 --
10700 IF (l_debug <> -1) THEN
10701 rlm_core_sv.dpush(k_SDEBUG,'ProcessNATS');
10702 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.header_id', x_Sched_rec.header_id);
10703 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id', x_Group_rec.ship_from_org_id);
10704 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
10705 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
10706 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
10707 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.industry_attribute15', x_Group_rec.industry_attribute15);
10708 END IF;
10709 --
10710 -- Delete all the bind variable tables
10711 --
10712 g_NewDemandTab.DELETE;
10713 g_WhereTab1.DELETE;
10714 g_WhereTab2.DELETE;
10715 g_BindVarTab.DELETE;
10716 --
10717 RLM_TPA_SV.BuildMatchQuery(x_sched_rec,
10718 x_Group_rec,
10719 k_NATS,
10720 v_NatsDemand,
10721 v_AtsDemand,
10722 v_NewDemand,
10723 v_SumDemand);
10724 --
10725 -- (1) Handle the case when incoming NATS match existing ATS
10726 --
10727 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10728 --
10729 IF (l_debug <> -1) THEN
10730 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_ATSDemand cursor', g_BindVarTab.COUNT);
10731 END IF;
10732 --
10733 RLM_CORE_SV.OpenDynamicCursor(c_ATS, v_ATSDemand, g_BindVarTab);
10734 --
10735 WHILE FetchReq(c_ATS,
10736 v_Key_rec,
10737 v_line_id_tmp,
10738 v_SumOrderedQtyTmp,
10739 v_ScheduleType)
10740 LOOP
10741
10742 EXIT WHEN c_ATS%NOTFOUND;
10743 --
10744 IF (l_debug <> -1) THEN
10745 --
10746 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10747 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10748 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10749 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10750 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10751 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);
10752 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10753 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10754 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10755 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10756 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10757 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10758 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10759 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10760 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10761 --
10762 END IF;
10763
10764 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE, k_CANCEL, k_ADD) THEN
10765 --
10766 v_Key_rec.oe_line_id := v_line_id_tmp;
10767 --
10768 IF (l_debug <> -1) THEN
10769 rlm_core_sv.dlog(k_DEBUG, 'OM NATS Line Id', v_line_id_tmp);
10770 END IF;
10771 --
10772 GetDemand(v_Key_rec, x_Group_rec);
10773 --
10774 IF SchedulePrecedence(x_Group_rec, x_Sched_rec, v_ScheduleType) THEN
10775 --
10776 DeleteRequirement(x_Sched_rec, x_Group_rec,
10777 v_Key_rec, k_RECONCILE,
10778 v_DeleteQty);
10779 --
10780 END IF;
10781 --
10782 END IF;
10783 --
10784 END LOOP;
10785 --
10786 CLOSE c_ATS;
10787 --
10788 -- (2) Find all the ATS and NATS demand that matches in OM
10789 --
10790 g_BindVarTab := BuildBindVarTab2(g_WhereTab1, g_WhereTab2);
10791 --
10792 IF (l_debug <> -1) THEN
10793 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_SumDemand cursor', g_BindVarTab.COUNT);
10794 END IF;
10795 --
10796 RLM_CORE_SV.OpenDynamicCursor(c_Sum, v_SumDemand, g_BindVarTab);
10797 --
10798 FETCH c_Sum INTO v_LowestLineId,
10799 v_SumOrderedQtyTmp,
10800 v_DemandCount,
10801 v_LowestOeLineId;
10802 --
10803 IF c_Sum%FOUND THEN
10804 --
10805 v_LineMatch(0).sum_qty := v_SumOrderedQtyTmp;
10806 v_LineMatch(0).match_count := v_DemandCount;
10807 v_LineMatch(0).lowest_oelineid := v_LowestOeLineId;
10808 --
10809 IF (l_debug <> -1) THEN
10810 rlm_core_sv.dlog(k_DEBUG,'v_LowestLineId', v_LowestLineId);
10811 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10812 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10813 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10814 END IF;
10815 --
10816 LOOP
10817 FETCH c_Sum INTO v_LineId,
10818 v_SumOrderedQtyTmp,
10819 v_DemandCount,
10820 v_LowestOeLineId;
10821 EXIT WHEN c_Sum%NOTFOUND;
10822 v_LineMatch(v_LineId-v_LowestLineId).sum_qty := v_SumOrderedQtyTmp;
10823 v_LineMatch(v_LineId-v_LowestLineId).match_count := v_DemandCount;
10824 v_LineMatch(v_LineId-v_LowestLineId).lowest_oelineid := v_LowestOeLineId;
10825 --
10826 IF (l_debug <> -1) THEN
10827 rlm_core_sv.dlog(k_DEBUG,'RLM Line Id', v_LineId);
10828 rlm_core_sv.dlog(k_DEBUG,'Total matching order qty', v_SumOrderedQtyTmp);
10829 rlm_core_sv.dlog(k_DEBUG,'Number of matching lines', v_DemandCount);
10830 rlm_core_sv.dlog(k_DEBUG,'Min matching oe line id', v_LowestOeLineId);
10831 END IF;
10832 --
10833 END LOOP;
10834 --
10835 END IF;
10836 --
10837 --
10838 IF v_LineMatch.COUNT > 0 THEN
10839 --
10840 -- (3) Find all NATS demand that matched
10841 --
10842 g_BindVarTab := BuildBindVarTab5(g_WhereTab1, g_WhereTab2, g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10843 --
10844 IF (l_debug <> -1) THEN
10845 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NATS cursor', g_BindVarTab.COUNT);
10846 rlm_core_sv.dlog(k_DEBUG, 'Opening for v_NATSDemand');
10847 END IF;
10848 --
10849 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NatsDemand, g_BindVarTab);
10850 --
10851 ELSE
10852 --
10853 -- (4) Find all NATS demand that did not match in OM
10854 --
10855 g_BindVarTab := BuildBindVarTab3(g_NewDemandTab, g_WhereTab1, g_WhereTab2);
10856 --
10857 IF (l_debug <> -1) THEN
10858 rlm_core_sv.dlog(k_DEBUG, 'No. of bind variables for v_NewDemand cursor', g_BindVarTab.COUNT);
10859 rlm_core_sv.dlog(k_DEBUG,'Opening for v_NewDemand');
10860 END IF;
10861 --
10862 RLM_CORE_SV.OpenDynamicCursor(c_Matched, v_NewDemand, g_BindVarTab);
10863 --
10864 END IF;
10865 --
10866 WHILE FetchReq(c_Matched,
10867 v_Key_rec,
10868 v_line_id_tmp,
10869 v_SumOrderedQtyTmp,
10870 v_ScheduleType)
10871 LOOP
10872
10873 EXIT WHEN c_Matched%NOTFOUND;
10874 --
10875 IF (l_debug <> -1) THEN
10876 --
10877 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_start_date', x_sched_rec.sched_horizon_start_date);
10878 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.sched_horizon_end_date', x_sched_rec.sched_horizon_end_date);
10879 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.request_date', v_Key_rec.req_rec.request_date);
10880 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.primary_quantity', v_Key_rec.req_rec.primary_quantity);
10881 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_type', v_Key_rec.req_rec.item_detail_type);
10882 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);
10883 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_production_line', v_Key_rec.req_rec.cust_production_line);
10884 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_dock_code', v_Key_rec.req_rec.customer_dock_code);
10885 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_po_number', v_Key_rec.req_rec.cust_po_number);
10886 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_item_revision', v_Key_rec.req_rec.customer_item_revision);
10887 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.customer_job', v_Key_rec.req_rec.customer_job);
10888 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.cust_model_serial_number', v_Key_rec.req_rec.cust_model_serial_number);
10889 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.item_detail_subtype', v_Key_rec.req_rec.item_detail_subtype);
10890 rlm_core_sv.dlog(k_DEBUG,'v_Key_rec.req_rec.blanket_number', v_Key_rec.req_rec.blanket_number);
10891 rlm_core_sv.dlog(k_DEBUG,'v_line_id_tmp', v_line_id_tmp);
10892 --
10893 END IF;
10894 --
10895 g_sch_line_qty := v_Key_rec.req_rec.primary_quantity; --Bugfix 6159269
10896 -- When there is NO MATCH
10897 IF v_line_id_tmp IS NULL THEN
10898
10899 IF x_Sched_rec.schedule_purpose NOT IN (k_DELETE,k_CANCEL) THEN
10900 --
10901 v_NewCount := v_NewCount +1;
10902 --
10903 IF (l_debug <> -1) THEN
10904 rlm_core_sv.dlog(k_DEBUG,'v_NewCount', v_NewCount);
10905 END IF;
10906 --
10907 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
10908 v_Key_rec, k_RECONCILE,
10909 v_Key_rec.req_rec.primary_quantity);
10910 END IF;
10911
10912 -- When there is a MATCH
10913 ELSE
10914 --
10915 IF (l_debug <> -1) THEN
10916 rlm_core_sv.dlog(k_DEBUG, 'RLM Line Id', v_Key_rec.req_rec.line_id);
10917 END IF;
10918 --
10919 IF v_line_id_tmp = v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).lowest_oelineid THEN
10920 v_DemandCount := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).match_count;
10921 v_SumOrderedQty := v_LineMatch(v_Key_rec.req_rec.line_id-v_LowestLineId).sum_qty;
10922 v_line_id_tab(0) := v_line_id_tmp;
10923 --
10924 RLM_TPA_SV.ReconcileAction(x_sched_rec,
10925 x_group_rec,
10926 v_Key_rec,
10927 v_line_id_tab,
10928 v_DemandCount,
10929 v_SumOrderedQty,
10930 k_NATS);
10931 v_line_id_tab.DELETE;
10932 --
10933 END IF;
10934 --
10935 END IF;
10936 --
10937 END LOOP;
10938 --
10939 CLOSE c_Matched;
10940 --
10941 g_sch_line_qty :=0; --Bugfix 6159269
10942 --
10943 IF (l_debug <> -1) THEN
10944 rlm_core_sv.dpop(k_SDEBUG);
10945 END IF;
10946 --
10947 EXCEPTION
10948
10949 WHEN e_group_error THEN
10950 --
10951 IF (l_debug <> -1) THEN
10952 rlm_core_sv.dlog(k_DEBUG,'group error');
10953 rlm_core_sv.dpop(k_SDEBUG);
10954 END IF;
10955 --
10956 raise e_group_error;
10957
10958 WHEN OTHERS THEN
10959 rlm_message_sv.sql_error('rlm_rd_sv.ProcessNATS',x_progress);
10960 --
10961 IF (l_debug <> -1) THEN
10962 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
10963 END IF;
10964 --
10965 raise;
10966
10967 END ProcessNATS;
10968
10969
10970 /*===========================================================================
10971
10972 PROCEDURE UpdateDemand
10973
10974 ===========================================================================*/
10975 PROCEDURE UpdateDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
10976 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
10977 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
10978 x_SumOrderedQty IN NUMBER,
10979 x_DemandType IN VARCHAR2)
10980 IS
10981
10982 v_QtyDelta NUMBER;
10983 v_Qty_rec t_Qty_rec;
10984 v_Demand_ref t_Cursor_ref;
10985 v_DeleteQty NUMBER;
10986 x_progress VARCHAR2(3) := '010';
10987
10988 BEGIN
10989 --
10990 IF (l_debug <> -1) THEN
10991 rlm_core_sv.dpush(k_SDEBUG,'UpdateDemand');
10992 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty', x_SumOrderedQty);
10993 rlm_core_sv.dlog(k_DEBUG,'x_DemandType', x_DemandType);
10994 END IF;
10995 --
10996 RLM_TPA_SV.ReconcileShipments(x_Group_rec,
10997 x_Key_rec,
10998 x_Key_rec.req_rec.primary_quantity);
10999 --
11000 Reconcile(x_Group_rec,
11001 x_Key_rec,
11002 x_Key_rec.req_rec.primary_quantity);
11003 --
11004 InitializeDemand(x_Sched_rec,
11005 x_Group_rec,
11006 x_Key_rec,
11007 v_Demand_ref,
11008 x_DemandType);
11009 --
11010 IF (l_debug <> -1) THEN
11011 rlm_core_sv.dlog(k_DEBUG,'x_key_rec.req_rec.primary_quantity',
11012 x_key_rec.req_rec.primary_quantity);
11013 END IF;
11014 --
11015 CheckTolerance(x_Sched_rec,
11016 x_Group_rec,
11017 x_Key_rec,
11018 x_SumOrderedQty,
11019 x_key_rec.req_rec.primary_quantity);
11020 --
11021 IF x_Key_rec.req_rec.primary_quantity <= 0 THEN
11022 --
11023 g_del_reconcile := 'Y'; --Bugfix 6131516
11024 RLM_TPA_SV.DeleteDemand(x_Sched_rec,
11025 x_Group_rec,
11026 x_Key_rec,
11027 v_Demand_ref);
11028 --
11029 ELSIF x_Key_rec.req_rec.primary_quantity > x_SumOrderedQty THEN
11030 --
11031 RLM_TPA_SV.IncreaseDemand(x_Sched_rec,
11032 x_Group_rec,
11033 x_Key_rec,
11034 v_Demand_ref,
11035 x_SumOrderedQty);
11036 --
11037 ELSIF x_Key_rec.req_rec.primary_quantity < x_SumOrderedQty THEN
11038 --
11039 RLM_TPA_SV.DecreaseDemand(x_Sched_rec,
11040 x_Group_rec,
11041 x_Key_rec,
11042 v_Demand_ref,
11043 x_SumOrderedQty);
11044 --
11045 ELSIF x_Key_rec.req_rec.primary_quantity = x_SumOrderedQty THEN
11046 --
11047 RLM_TPA_SV.OtherDemand(x_Sched_rec,
11048 x_Group_rec,
11049 x_Key_rec,
11050 v_Demand_ref);
11051 --
11052 END IF;
11053 CLOSE v_Demand_ref;
11054 --
11055 IF (l_debug <> -1) THEN
11056 rlm_core_sv.dpop(k_SDEBUG);
11057 END IF;
11058 --
11059 EXCEPTION
11060 WHEN OTHERS THEN
11061 rlm_message_sv.sql_error('rlm_rd_sv.UpdateDemand',x_progress);
11062 --
11063 IF (l_debug <> -1) THEN
11064 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11065 END IF;
11066 --
11067 raise;
11068
11069 END UpdateDemand;
11070
11071
11072 /*===========================================================================
11073
11074 PROCEDURE DeleteDemand
11075
11076 ===========================================================================*/
11077 PROCEDURE DeleteDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11078 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11079 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11080 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref)
11081 IS
11082
11083 v_DeleteQty NUMBER;
11084 x_progress VARCHAR2(3) := '010';
11085
11086 BEGIN
11087 --
11088 IF (l_debug <> -1) THEN
11089 rlm_core_sv.dpush(k_SDEBUG,'DeleteDemand');
11090 END IF;
11091 --
11092 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
11093 --
11094 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11095 --
11096 DeleteRequirement(x_Sched_rec, x_Group_rec,
11097 x_Key_rec, k_RECONCILE,
11098 v_DeleteQty);
11099 --
11100 END IF;
11101 --
11102 END LOOP;
11103 --
11104 g_del_reconcile := 'N'; --Bugfix 6131516
11105 --
11106 IF (l_debug <> -1) THEN
11107 rlm_core_sv.dpop(k_SDEBUG);
11108 END IF;
11109 --
11110 EXCEPTION
11111
11112 WHEN e_group_error THEN
11113 --
11114 IF (l_debug <> -1) THEN
11115 rlm_core_sv.dlog(k_DEBUG,'group error');
11116 rlm_core_sv.dpop(k_SDEBUG);
11117 END IF;
11118 --
11119 raise e_group_error;
11120
11121 WHEN OTHERS THEN
11122 rlm_message_sv.sql_error('rlm_rd_sv.DeleteDemand',x_progress);
11123 --
11124 IF (l_debug <> -1) THEN
11125 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11126 END IF;
11127 --
11128 raise;
11129
11130 END DeleteDemand;
11131
11132
11133 /*===========================================================================
11134
11135 PROCEDURE IncreaseDemand
11136
11137 ===========================================================================*/
11138 PROCEDURE IncreaseDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11139 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11140 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11141 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref,
11142 x_SumOrderedQty IN NUMBER)
11143 IS
11144 --
11145 v_QtyDelta NUMBER;
11146 v_Qty_rec t_Qty_rec;
11147 x_progress VARCHAR2(3) := '010';
11148 IsSchedulePrecedence BOOLEAN := TRUE;
11149 v_Index NUMBER := 0;
11150 v_MatchAttrTxt VARCHAR2(2000); --Bugfix 6159269
11151 --
11152 BEGIN
11153 --
11154 IF (l_debug <> -1) THEN
11155 rlm_core_sv.dpush(k_SDEBUG,'IncreaseDemand');
11156 END IF;
11157 --
11158 v_QtyDelta := x_Key_rec.req_rec.primary_quantity - x_SumOrderedQty;
11159 --
11160 IF (l_debug <> -1) THEN
11161 rlm_core_sv.dlog(k_DEBUG,'v_QtyDelta',v_QtyDelta);
11162 END IF;
11163 --
11164 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
11165 --
11166 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11167 --
11168 IF (l_debug <> -1) THEN
11169 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.ordered_quantity',
11170 x_Key_rec.dem_rec.ordered_quantity);
11171 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.dem_rec.line_id',
11172 x_Key_rec.dem_rec.line_id);
11173 rlm_core_sv.dlog(k_DEBUG,'New Schedule of higher Precedence -- TRUE');
11174 END IF;
11175 --
11176 IsSchedulePrecedence := TRUE;
11177 --
11178 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
11179 --
11180 IF v_QtyDelta > 0 AND NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE,
11181 x_Key_rec.dem_rec.ordered_quantity + v_QtyDelta) THEN
11182
11183 --Bugfix 10053830 Start
11184 /*IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11185 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799*/
11186 IF NOT (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11187 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799
11188 --Bugfix 10053830 End
11189 --
11190 UpdateRequirement(x_Sched_rec, x_Group_rec,
11191 x_Key_rec, x_Key_rec.dem_rec.ordered_quantity + v_QtyDelta);
11192 v_QtyDelta := 0;
11193 --
11194 --Bugfix 6159269 START
11195 ELSE
11196
11197 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN
11198 g_inc_exception := 'Y';
11199 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11200 --
11201 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11202 --
11203 rlm_message_sv.app_error(
11204 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11205 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11206 x_InterfaceHeaderId => x_sched_rec.header_id,
11207 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11208 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11209 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11210 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11211 x_OrderLineId => x_key_rec.dem_rec.line_id,
11212 x_Token1 => 'LINE',
11213 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11214 x_Token2 => 'ORDER',
11215 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11216 x_Token3 => 'QUANTITY',
11217 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11218 x_Token4 => 'CUSTITEM',
11219 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11220 x_Token5 => 'REQ_DATE',
11221 x_value5 => x_key_rec.dem_rec.request_date,
11222 x_Token6 => 'SCH_LINE_QTY',
11223 x_value6 => g_sch_line_qty,
11224 x_Token7 => 'SEQ_INFO',
11225 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11226 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11227 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11228 x_Token8 => 'MATCH_ATTR',
11229 x_value8 => v_MatchAttrTxt);
11230 --
11231 IF (l_debug <> -1) THEN
11232 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11233 x_key_rec.req_rec.line_id);
11234 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11235 x_key_rec.req_rec.line_id);
11236 END IF;
11237 --
11238 ELSE
11239 --
11240 rlm_message_sv.app_error(
11241 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11242 x_MessageName => 'RLM_FROZEN_UPDATE',
11243 x_InterfaceHeaderId => x_sched_rec.header_id,
11244 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11245 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11246 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11247 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11248 x_OrderLineId => x_key_rec.dem_rec.line_id,
11249 x_Token1 => 'LINE',
11250 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11251 x_Token2 => 'ORDER',
11252 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11253 x_Token3 => 'QUANTITY',
11254 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11255 x_Token4 => 'CUSTITEM',
11256 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11257 x_Token5 => 'REQ_DATE',
11258 x_value5 => x_key_rec.dem_rec.request_date,
11259 x_Token6 => 'SCH_LINE_QTY',
11260 x_value6 => g_sch_line_qty,
11261 x_Token7 => 'MATCH_ATTR',
11262 x_value7 => v_MatchAttrTxt);
11263 --
11264 IF (l_debug <> -1) THEN
11265 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11266 x_key_rec.req_rec.line_id);
11267 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11268 x_key_rec.req_rec.line_id);
11269 END IF;
11270 --
11271 END IF; /* Exception */
11272
11273 END IF; /* Check g_sch_line_qty */
11274 --
11275 END IF; /* IsFrozen */
11276
11277 END IF; /* v_QtyDelta AND ProcessConstraint */
11278 --
11279 --Bugfix 6159269 END
11280 --
11281 -- Bug 3919971 : Add OE line to g_Accounted_tab, so DSP will not
11282 -- try to reconcile against the quantity again.
11283 -- Need to be accounted only after update requirement call
11284
11285 v_Index := g_Accounted_tab.COUNT+1;
11286 g_Accounted_tab(v_Index) := x_Key_rec.dem_rec;
11287 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11288 ELSE
11289 --
11290 IsSchedulePrecedence := FALSE;
11291 --
11292 IF (l_debug <> -1) THEN
11293 rlm_core_sv.dlog(k_DEBUG,'New Schedule of Lower Precedence -- FALSE');
11294 END IF;
11295 --
11296 END IF;
11297 --
11298 END LOOP;
11299 --
11300 IF v_QtyDelta <> 0 AND IsSchedulePrecedence THEN
11301 --
11302 RLM_TPA_SV.InsertRequirement(x_Sched_rec, x_Group_rec,
11303 x_Key_rec, k_NORECONCILE, v_QtyDelta);
11304 --
11305 END IF;
11306 g_inc_exception := 'N'; --Bugfix 6159269
11307 --
11308 IF (l_debug <> -1) THEN
11309 rlm_core_sv.dpop(k_SDEBUG);
11310 END IF;
11311 --
11312 EXCEPTION
11313 WHEN OTHERS THEN
11314 rlm_message_sv.sql_error('rlm_rd_sv.IncreaseDemand',x_progress);
11315 --
11316 IF (l_debug <> -1) THEN
11317 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11318 END IF;
11319 --
11320 raise;
11321
11322 END IncreaseDemand;
11323
11324
11325 /*===========================================================================
11326
11327 PROCEDURE DecreaseDemand
11328
11329 ===========================================================================*/
11330 PROCEDURE DecreaseDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11331 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11332 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11333 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref,
11334 x_SumOrderedQty IN NUMBER)
11335 IS
11336
11337 v_QtyDelta NUMBER;
11338 v_Qty_rec t_Qty_rec;
11339 v_DeleteQty NUMBER;
11340 x_progress VARCHAR2(3) := '010';
11341 v_Index NUMBER := 0;
11342 v_MatchAttrTxt VARCHAR2(2000); --Bugfix 6159269
11343 BEGIN
11344 --
11345 IF (l_debug <> -1) THEN
11346 rlm_core_sv.dpush(k_SDEBUG,'DecreaseDemand');
11347 rlm_core_sv.dlog(k_DEBUG,'x_SumOrderedQty',x_SumOrderedQty);
11348 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.req_rec.primary_quantity',
11349 x_Key_rec.req_rec.primary_quantity);
11350 END IF;
11351 --
11352 v_QtyDelta := x_SumOrderedQty - x_Key_rec.req_rec.primary_quantity;
11353 --
11354 IF (l_debug <> -1) THEN
11355 rlm_core_sv.dlog(k_DEBUG,'v_QtyDelta',v_QtyDelta);
11356 END IF;
11357 --
11358 WHILE FetchDemand(x_Demand_ref, x_Key_rec) AND v_QtyDelta >0 LOOP
11359 --
11360 IF (l_debug <> -1) THEN
11361 rlm_core_sv.dlog(k_DEBUG,'x_Key_rec.dem_rec.ordered_quantity',x_Key_rec.dem_rec.ordered_quantity);
11362 END IF;
11363 --
11364 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11365 --
11366 IF v_QtyDelta >= x_Key_rec.dem_rec.ordered_quantity THEN
11367 --
11368 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_DELETE,
11369 x_Key_rec.dem_rec.ordered_quantity-v_QtyDelta)
11370 AND (NOT
11371 --Bugfix 10053830 Start
11372 /*(IsFrozen(TRUNC(SYSDATE), x_Group_rec,
11373 x_Key_rec.dem_rec.request_date) OR
11374 IsFrozen(TRUNC(SYSDATE), x_Group_rec,
11375 x_Key_rec.dem_rec.schedule_date)) OR x_Sched_rec.schedule_source = 'MANUAL') THEN --Bugfix 8221799*/
11376 (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec,
11377 x_Key_rec.dem_rec.request_date) OR
11378 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec,
11379 x_Key_rec.dem_rec.schedule_date)) OR x_Sched_rec.schedule_source = 'MANUAL') THEN --Bugfix 8221799
11380 --Bugfix 10053830 End
11381 --
11382 DeleteRequirement(x_Sched_rec, x_Group_rec,
11383 x_Key_rec, k_RECONCILE,
11384 v_DeleteQty);
11385 v_QtyDelta := v_QtyDelta - x_Key_rec.dem_rec.ordered_quantity;
11386 --
11387 END IF;
11388 --
11389 ELSIF v_QtyDelta > 0 THEN
11390 --
11391 -- 4292516 added the check if req_rec.request_date falls within frozen fence also
11392 --
11393 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE, x_Key_rec.dem_rec.ordered_quantity - v_QtyDelta) THEN
11394 --Bugfix 10053830 Start
11395 /*IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11396 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799*/
11397 IF NOT (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11398 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799
11399 --Bugfix 10053830 End
11400 UpdateRequirement(x_Sched_rec, x_Group_rec, x_Key_rec, x_Key_rec.dem_rec.ordered_quantity - v_QtyDelta);
11401 --
11402 v_QtyDelta := 0;
11403 --
11404 --Bugfix 6159269 START
11405 ELSE
11406
11407 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN
11408 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11409 --
11410 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11411 --
11412 rlm_message_sv.app_error(
11413 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11414 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11415 x_InterfaceHeaderId => x_sched_rec.header_id,
11416 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11417 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11418 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11419 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11420 x_OrderLineId => x_key_rec.dem_rec.line_id,
11421 x_Token1 => 'LINE',
11422 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11423 x_Token2 => 'ORDER',
11424 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11425 x_Token3 => 'QUANTITY',
11426 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11427 x_Token4 => 'CUSTITEM',
11428 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11429 x_Token5 => 'REQ_DATE',
11430 x_value5 => x_key_rec.dem_rec.request_date,
11431 x_Token6 => 'SCH_LINE_QTY',
11432 x_value6 => g_sch_line_qty,
11433 x_Token7 => 'SEQ_INFO',
11434 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11435 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11436 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11437 x_Token8 => 'MATCH_ATTR',
11438 x_value8 => v_MatchAttrTxt);
11439 --
11440 IF (l_debug <> -1) THEN
11441 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11442 x_key_rec.req_rec.line_id);
11443 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11444 x_key_rec.req_rec.line_id);
11445 END IF;
11446 --
11447 ELSE
11448 --
11449 rlm_message_sv.app_error(
11450 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11451 x_MessageName => 'RLM_FROZEN_UPDATE',
11452 x_InterfaceHeaderId => x_sched_rec.header_id,
11453 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11454 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11455 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11456 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11457 x_OrderLineId => x_key_rec.dem_rec.line_id,
11458 x_Token1 => 'LINE',
11459 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11460 x_Token2 => 'ORDER',
11461 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11462 x_Token3 => 'QUANTITY',
11463 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11464 x_Token4 => 'CUSTITEM',
11465 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11466 x_Token5 => 'REQ_DATE',
11467 x_value5 => x_key_rec.dem_rec.request_date,
11468 x_Token6 => 'SCH_LINE_QTY',
11469 x_value6 => g_sch_line_qty,
11470 x_Token7 => 'MATCH_ATTR',
11471 x_value7 => v_MatchAttrTxt);
11472 --
11473 IF (l_debug <> -1) THEN
11474 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11475 x_key_rec.req_rec.line_id);
11476 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11477 x_key_rec.req_rec.line_id);
11478 END IF;
11479 --
11480 END IF; /* Exception */
11481
11482 END IF; /* g_sch_line_qty */
11483
11484 END IF; /* IsFrozen */
11485 --
11486 END IF; /* ProcessConstraint */
11487 --Bugfix 6159269 END
11488 --
11489 END IF;
11490 --
11491 -- Bug 3919971, 3999833 : Add OE line to g_Accounted_tab so DSP will
11492 -- not attempt reconciling this quantity again
11493 --
11494 v_Index := g_Accounted_Tab.COUNT+1;
11495 g_Accounted_tab(v_Index):= x_Key_rec.dem_rec;
11496 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11497 --
11498 END IF;
11499 --
11500 END LOOP;
11501 --
11502 IF v_QtyDelta <> 0 THEN
11503 -- irreconcileable differences
11504 StoreReconcile(x_Sched_rec, x_Group_rec, x_Key_rec,
11505 v_QtyDelta);
11506 END IF;
11507 --
11508 IF (l_debug <> -1) THEN
11509 rlm_core_sv.dpop(k_SDEBUG);
11510 END IF;
11511 --
11512 EXCEPTION
11513
11514 WHEN e_group_error THEN
11515 --
11516 IF (l_debug <> -1) THEN
11517 rlm_core_sv.dlog(k_DEBUG,'group error');
11518 rlm_core_sv.dpop(k_SDEBUG);
11519 END IF;
11520 --
11521 raise e_group_error;
11522
11523 WHEN OTHERS THEN
11524 rlm_message_sv.sql_error('rlm_rd_sv.DecreaseDemand',x_progress);
11525 --
11526 IF (l_debug <> -1) THEN
11527 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11528 END IF;
11529 --
11530 raise;
11531
11532 END DecreaseDemand;
11533
11534
11535 /*===========================================================================
11536
11537 PROCEDURE OtherDemand
11538
11539 ===========================================================================*/
11540 PROCEDURE OtherDemand(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
11541 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
11542 x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
11543 x_Demand_ref IN OUT NOCOPY RLM_RD_SV.t_Cursor_ref)
11544 IS
11545
11546 v_Qty_rec t_Qty_rec;
11547 x_progress VARCHAR2(3) := '010';
11548 v_Index NUMBER;
11549 v_MatchAttrTxt VARCHAR2(2000); -- Bug 4297984
11550 BEGIN
11551 --
11552 IF (l_debug <> -1) THEN
11553 rlm_core_sv.dpush(k_SDEBUG,'OtherDemand');
11554 END IF;
11555 --
11556 WHILE FetchDemand(x_Demand_ref, x_Key_rec) LOOP
11557 --
11558 IF SchedulePrecedence(x_Group_rec, x_sched_rec,x_Key_rec.dem_rec.schedule_type) THEN
11559
11560 --
11561 IF (l_debug <> -1) THEN
11562 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.dem_rec.ordered_quantity',
11563 x_Key_rec.dem_rec.ordered_quantity);
11564 rlm_core_sv.dlog(k_DEBUG, 'x_Key_rec.req_rec.primary_quantity',
11565 x_Key_rec.req_rec.primary_quantity);
11566 END IF;
11567
11568 --bug2308608
11569
11570 --IF AttributeChange(x_Key_rec) THEN
11571
11572 -- Bug 2802487
11573 -- Changes:
11574 -- (1) Pass x_Key_rec.dem_rec.ordered_quantity to
11575 -- ProcessConstraint instead of passing 0 quantity.
11576 -- (2) Pass x_Key_rec.dem_rec.ordered_quantity to
11577 -- UpdateRequirement.
11578 -- Result: if primary quantity equals SumOrderedQty,
11579 -- update SO line with the same existing quantity,
11580 -- or in other words, no ordered qty update would occur at all.
11581 -- Also update SO line with any attribute changes.
11582
11583 -- Bug 4297984 Start
11584 --Bugfix 10053830 Start
11585 /*IF NOT (IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11586 IsFrozen(TRUNC(SYSDATE), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799*/
11587 IF NOT (IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.dem_rec.request_date) OR
11588 IsFrozen(TRUNC(rlm_dp_sv.g_dsp_start_time), x_Group_rec, x_Key_rec.req_rec.request_date)) OR x_Sched_rec.schedule_source = 'MANUAL' THEN --Bugfix 8221799
11589 --Bugfix 10053830 End
11590 --
11591 IF NOT ProcessConstraint(x_Key_rec, v_Qty_rec, k_UPDATE_ATTR,
11592 x_Key_rec.dem_rec.ordered_quantity) THEN
11593 --
11594 UpdateRequirement(x_Sched_rec, x_Group_rec, x_Key_rec,
11595 x_Key_rec.dem_rec.ordered_quantity);
11596 --
11597 ELSE
11598 --
11599 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11600 --
11601 IF (x_Key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11602 --
11603 rlm_message_sv.app_error(
11604 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11605 x_MessageName => 'RLM_UNABLE_ATTR_UPDATE_SEQ',
11606 x_InterfaceHeaderId => x_sched_rec.header_id,
11607 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
11608 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11609 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
11610 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11611 x_OrderLineId => x_Key_rec.dem_rec.line_id,
11612 x_Token1 => 'LINE',
11613 x_value1 =>rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
11614 x_Token2 => 'ORDER',
11615 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11616 x_Token3 => 'QUANTITY',
11617 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
11618 x_Token4 => 'CUSTITEM',
11619 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11620 x_Token5 => 'REQ_DATE',
11621 x_value5 => x_key_rec.dem_rec.request_date,
11622 x_Token6 => 'SEQ_INFO',
11623 x_value6 => nvl(x_key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11624 nvl(x_key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11625 nvl(x_key_rec.dem_rec.customer_job,'NULL'),
11626 x_Token7 => 'MATCH_ATTR',
11627 x_value7 => v_MatchAttrTxt);
11628 --
11629 IF (l_debug <> -1) THEN
11630 rlm_core_sv.dlog(k_DEBUG,'Process Constraints on line',
11631 x_key_rec.req_rec.line_id);
11632 rlm_core_sv.dlog(k_DEBUG,'RLM_UNABLE_ATTR_UPDATE_SEQ',
11633 x_key_rec.req_rec.line_id);
11634 END IF;
11635 --
11636 ELSE
11637 --
11638 rlm_message_sv.app_error(
11639 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11640 x_MessageName => 'RLM_UNABLE_ATTR_UPDATE',
11641 x_InterfaceHeaderId => x_sched_rec.header_id,
11642 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
11643 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11644 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
11645 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11646 x_OrderLineId => x_Key_rec.dem_rec.line_id,
11647 x_Token1 => 'LINE',
11648 x_value1 => rlm_core_sv.get_order_line_number(x_Key_rec.dem_rec.line_id),
11649 x_Token2 => 'ORDER',
11650 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11651 x_Token3 => 'QUANTITY',
11652 x_value3 => x_Key_rec.dem_rec.ordered_quantity,
11653 x_Token4 => 'CUSTITEM',
11654 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11655 x_Token5 => 'REQ_DATE',
11656 x_value5 => x_key_rec.dem_rec.request_date,
11657 x_Token6 => 'MATCH_ATTR',
11658 x_value6 => v_MatchAttrTxt);
11659 --
11660 IF (l_debug <> -1) THEN
11661 rlm_core_sv.dlog(k_DEBUG,'Process Constraints on line',
11662 x_key_rec.req_rec.line_id);
11663 rlm_core_sv.dlog(k_DEBUG,'RLM_UNABLE_ATTR_UPDATE',
11664 x_key_rec.req_rec.line_id);
11665 END IF;
11666 --
11667 END IF;
11668 --
11669 END IF;
11670 --
11671 ELSE
11672 IF x_Key_rec.dem_rec.ordered_quantity <> g_sch_line_qty THEN --Bugfix 6159269
11673 GetMatchAttributes(x_sched_rec, x_group_rec, x_Key_rec.dem_rec,v_MatchAttrTxt);
11674 --
11675 IF (x_key_rec.dem_rec.schedule_type = 'SEQUENCED') THEN
11676 --
11677 rlm_message_sv.app_error(
11678 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11679 x_MessageName => 'RLM_FROZEN_UPDATE_SEQ',
11680 x_InterfaceHeaderId => x_sched_rec.header_id,
11681 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11682 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11683 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11684 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11685 x_OrderLineId => x_key_rec.dem_rec.line_id,
11686 x_Token1 => 'LINE',
11687 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11688 x_Token2 => 'ORDER',
11689 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11690 x_Token3 => 'QUANTITY',
11691 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11692 x_Token4 => 'CUSTITEM',
11693 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11694 x_Token5 => 'REQ_DATE',
11695 x_value5 => x_key_rec.dem_rec.request_date,
11696 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
11697 x_value6 => g_sch_line_qty, --Bugfix 6159269
11698 x_Token7 => 'SEQ_INFO',
11699 x_value7 => nvl(x_Key_rec.dem_rec.cust_production_seq_num,'NULL') ||'-'||
11700 nvl(x_Key_rec.dem_rec.cust_model_serial_number,'NULL')||'-'||
11701 nvl(x_Key_rec.dem_rec.customer_job,'NULL'),
11702 x_Token8 => 'MATCH_ATTR',
11703 x_value8 => v_MatchAttrTxt);
11704 --
11705 IF (l_debug <> -1) THEN
11706 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11707 x_key_rec.req_rec.line_id);
11708 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE_SEQ',
11709 x_key_rec.req_rec.line_id);
11710 END IF;
11711 --
11712 ELSE
11713 --
11714 rlm_message_sv.app_error(
11715 x_ExceptionLevel => rlm_message_sv.k_warn_level,
11716 x_MessageName => 'RLM_FROZEN_UPDATE',
11717 x_InterfaceHeaderId => x_sched_rec.header_id,
11718 x_InterfaceLineId => x_key_rec.req_rec.line_id,
11719 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
11720 x_ScheduleLineId => x_key_rec.req_rec.schedule_line_id,
11721 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
11722 x_OrderLineId => x_key_rec.dem_rec.line_id,
11723 x_Token1 => 'LINE',
11724 x_value1 => rlm_core_sv.get_order_line_number(x_key_rec.dem_rec.line_id),
11725 x_Token2 => 'ORDER',
11726 x_value2 => rlm_core_sv.get_order_number(x_group_rec.setup_terms_rec.header_id),
11727 x_Token3 => 'QUANTITY',
11728 x_value3 => x_key_rec.dem_rec.ordered_quantity,
11729 x_Token4 => 'CUSTITEM',
11730 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
11731 x_Token5 => 'REQ_DATE',
11732 x_value5 => x_key_rec.dem_rec.request_date,
11733 x_Token6 => 'SCH_LINE_QTY', --Bugfix 6159269
11734 x_value6 => g_sch_line_qty, --Bugfix 6159269
11735 x_Token7 => 'MATCH_ATTR',
11736 x_value7 => v_MatchAttrTxt);
11737 --
11738 IF (l_debug <> -1) THEN
11739 rlm_core_sv.dlog(k_DEBUG,'The line is within frozen fence',
11740 x_key_rec.req_rec.line_id);
11741 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_UPDATE',
11742 x_key_rec.req_rec.line_id);
11743 END IF;
11744 --
11745 END IF;
11746 END IF; --Bugfix 6159269
11747 --
11748 END IF; /* IsFrozen */
11749 -- Bug 4297984 End
11750
11751 --
11752 -- Bug 3919971 : Add OE line to g_Accounted_Tab so DSP will
11753 -- not attempt to reconcile the quantity again
11754 -- Bugfix 13397798
11755
11756 v_Index := g_Accounted_tab.COUNT+1;
11757 g_Accounted_Tab(v_Index) := x_Key_rec.dem_rec;
11758 g_Accounted_Tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11759
11760 END IF;
11761 --
11762 END LOOP;
11763 --
11764 IF (l_debug <> -1) THEN
11765 rlm_core_sv.dpop(k_SDEBUG);
11766 END IF;
11767 --
11768 EXCEPTION
11769 WHEN OTHERS THEN
11770 rlm_message_sv.sql_error('rlm_rd_sv.OtherDemand',x_progress);
11771 --
11772 IF (l_debug <> -1) THEN
11773 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11774 END IF;
11775 --
11776 raise;
11777
11778 END OtherDemand;
11779
11780
11781 /*===========================================================================
11782
11783 PROCEDURE SetOperation
11784
11785 ===========================================================================*/
11786 PROCEDURE SetOperation(x_Key_rec IN RLM_RD_SV.t_Key_rec,
11787 x_Operation IN VARCHAR2,
11788 x_Quantity IN NUMBER := NULL)
11789 IS
11790
11791 v_Index NUMBER;
11792 x_progress VARCHAR2(3) := '010';
11793 --pdue
11794 v_line_id_tab t_matching_line;
11795
11796 BEGIN
11797 --
11798 IF (l_debug <> -1) THEN
11799 rlm_core_sv.dpush(k_SDEBUG,'SetOperation');
11800 rlm_core_sv.dlog(k_DEBUG, 'x_Quantity',
11801 x_Quantity);
11802 END IF;
11803 --
11804 IF x_Operation = k_DELETE THEN
11805 --pdue, global_atp
11806 v_line_id_tab(0) := x_Key_rec.dem_rec.line_id;
11807 IF NOT AlreadyUpdated(v_line_id_tab) THEN
11808 --
11809 v_Index := g_Op_tab_Unschedule.COUNT + 1;
11810 g_Op_tab_Unschedule(v_Index) := x_Key_rec.dem_rec;
11811 g_Op_tab_Unschedule(v_Index).operation := OE_GLOBALS.G_OPR_DELETE;
11812 g_Op_tab_Unschedule(v_Index).ordered_quantity := x_Quantity;
11813 --
11814 IF (l_debug <> -1) THEN
11815 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).line_id',
11816 g_Op_tab_Unschedule(v_Index).line_id);
11817 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).operation',
11818 g_Op_tab_Unschedule(v_Index).operation);
11819 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ship_to_org_id',
11820 g_Op_tab_Unschedule(v_Index).ship_to_org_id);
11821 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).invoice_to_org_id',
11822 g_Op_tab_Unschedule(v_Index).invoice_to_org_id);
11823 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).inventory_item_id',
11824 g_Op_tab_Unschedule(v_Index).inventory_item_id);
11825 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).schedule_date',
11826 g_Op_tab_Unschedule(v_Index).schedule_date);
11827 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).request_date',
11828 g_Op_tab_Unschedule(v_Index).request_date);
11829 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ordered_quantity',
11830 g_Op_tab_Unschedule(v_Index).ordered_quantity);
11831 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).UOM_code',
11832 g_Op_tab_Unschedule(v_Index).UOM_code);
11833 END IF;
11834 --
11835 END IF;
11836 --
11837 ELSE
11838
11839 IF x_Operation = k_INSERT THEN
11840 --pdue
11841 v_Index := g_Op_tab.COUNT + 1;
11842 g_Op_tab(v_Index) := x_Key_rec.req_rec;
11843 g_Op_tab(v_Index).line_id := NULL;
11844 g_Op_tab(v_Index).operation := OE_GLOBALS.G_OPR_CREATE;
11845 g_Op_tab(v_Index).ordered_quantity := x_Quantity;
11846 --
11847 ELSIF x_Operation = k_UPDATE THEN
11848 --pdue, global_atp
11849 IF x_Quantity < x_Key_rec.dem_rec.ordered_quantity THEN
11850 --
11851 v_Index := g_Op_tab_Unschedule.COUNT + 1;
11852 g_Op_tab_Unschedule(v_Index) := x_Key_rec.req_rec;
11853 g_Op_tab_Unschedule(v_Index).operation := OE_GLOBALS.G_OPR_UPDATE;
11854 g_Op_tab_Unschedule(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11855 g_Op_tab_Unschedule(v_Index).ordered_quantity := x_Quantity;
11856 --
11857 IF (l_debug <> -1) THEN
11858 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).line_id',
11859 g_Op_tab_Unschedule(v_Index).line_id);
11860 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).operation',
11861 g_Op_tab_Unschedule(v_Index).operation);
11862 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ship_to_org_id',
11863 g_Op_tab_Unschedule(v_Index).ship_to_org_id);
11864 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).invoice_to_org_id',
11865 g_Op_tab_Unschedule(v_Index).invoice_to_org_id);
11866 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).inventory_item_id',
11867 g_Op_tab_Unschedule(v_Index).inventory_item_id);
11868 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).schedule_date',
11869 g_Op_tab_Unschedule(v_Index).schedule_date);
11870 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).request_date',
11871 g_Op_tab_Unschedule(v_Index).request_date);
11872 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).ordered_quantity',
11873 g_Op_tab_Unschedule(v_Index).ordered_quantity);
11874 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule(v_Index).UOM_code',
11875 g_Op_tab_Unschedule(v_Index).UOM_code);
11876 END IF;
11877 --
11878 ELSE
11879 --
11880 v_Index := g_Op_tab.COUNT + 1;
11881 g_Op_tab(v_Index) := x_Key_rec.req_rec;
11882 g_Op_tab(v_Index).operation := OE_GLOBALS.G_OPR_UPDATE;
11883 g_Op_tab(v_Index).line_id := x_Key_rec.dem_rec.line_id;
11884 g_Op_tab(v_Index).ordered_quantity := x_Quantity;
11885 --
11886 IF (l_debug <> -1) THEN
11887 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).line_id',
11888 g_Op_tab(v_Index).line_id);
11889 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).operation',
11890 g_Op_tab(v_Index).operation);
11891 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).ship_to_org_id',
11892 g_Op_tab(v_Index).ship_to_org_id);
11893 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).invoice_to_org_id',
11894 g_Op_tab(v_Index).invoice_to_org_id);
11895 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).inventory_item_id',
11896 g_Op_tab(v_Index).inventory_item_id);
11897 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).schedule_date',
11898 g_Op_tab(v_Index).schedule_date);
11899 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).request_date',
11900 g_Op_tab(v_Index).request_date);
11901 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).ordered_quantity',
11902 g_Op_tab(v_Index).ordered_quantity);
11903 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab(v_Index).UOM_code',
11904 g_Op_tab(v_Index).UOM_code);
11905 END IF;
11906 --
11907 END IF;
11908 --
11909 END IF;
11910 --
11911 END IF;
11912 --
11913 IF (l_debug <> -1) THEN
11914 rlm_core_sv.dpop(k_SDEBUG);
11915 END IF;
11916 --
11917 EXCEPTION
11918 WHEN OTHERS THEN
11919 rlm_message_sv.sql_error('rlm_rd_sv.SetOperation',x_progress);
11920 --
11921 IF (l_debug <> -1) THEN
11922 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11923 END IF;
11924 --
11925 raise;
11926
11927 END SetOperation;
11928
11929 /*===========================================================================
11930
11931 FUNCTION IsLineConsumable
11932
11933 ===========================================================================*/
11934 FUNCTION IsLineConsumable(x_consume_tab IN t_consume_tab,
11935 x_line_id IN RLM_INTERFACE_LINES.LINE_ID%TYPE,
11936 x_index OUT NOCOPY NUMBER)
11937 RETURN BOOLEAN
11938 IS
11939
11940 x_progress VARCHAR2(3) := '010';
11941 BEGIN
11942 --
11943 IF (l_debug <> -1) THEN
11944 rlm_core_sv.dpush(k_SDEBUG, 'IsLineConsumable');
11945 END IF;
11946 --
11947 FOR i IN 1..x_consume_tab.COUNT LOOP
11948 --
11949 IF x_consume_tab(i).line_id = x_line_id THEN
11950 --
11951 x_Index := i;
11952 --
11953 IF (l_debug <> -1) THEN
11954 rlm_core_sv.dlog(k_DEBUG, 'index', i);
11955 rlm_core_sv.dlog(k_DEBUG, 'returning False');
11956 rlm_core_sv.dpop(k_SDEBUG);
11957 END IF;
11958 --
11959 RETURN FALSE;
11960 --
11961 END IF;
11962 --
11963 END LOOP;
11964 --
11965 IF (l_debug <> -1) THEN
11966 rlm_core_sv.dlog(k_DEBUG, 'returning true');
11967 rlm_core_sv.dpop(k_SDEBUG);
11968 END IF;
11969 --
11970 RETURN TRUE;
11971 --
11972 EXCEPTION
11973 WHEN OTHERS THEN
11974 rlm_message_sv.sql_error('rlm_rd_sv.IsLineConsumable',x_progress);
11975 --
11976 IF (l_debug <> -1) THEN
11977 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
11978 END IF;
11979 --
11980 raise;
11981
11982 END IsLineConsumable;
11983
11984
11985 /*===========================================================================
11986
11987 FUNCTION UpdateGroupStatus
11988
11989 ===========================================================================*/
11990 PROCEDURE UpdateGroupStatus( x_header_id IN NUMBER,
11991 x_ScheduleHeaderId IN NUMBER,
11992 x_Group_rec IN rlm_dp_sv.t_Group_rec,
11993 x_status IN NUMBER,
11994 x_UpdateLevel IN VARCHAR2)
11995 IS
11996 x_progress VARCHAR2(3) := '010';
11997
11998 BEGIN
11999 --
12000 IF (l_debug <> -1) THEN
12001 rlm_core_sv.dpush(k_SDEBUG,'UpdateGroupStatus');
12002 rlm_core_sv.dlog(k_DEBUG,'UpdateGroupStatus to ', x_status);
12003 rlm_core_sv.dlog(k_DEBUG,'x_header_id ', x_header_id);
12004 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_from_org_id ',
12005 x_Group_rec.ship_from_org_id);
12006 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id ',
12007 x_Group_rec.order_header_id);
12008 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id ',
12009 x_Group_rec.ship_to_org_id);
12010 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id ',
12011 x_Group_rec.customer_item_id);
12012 rlm_core_sv.dlog(k_DEBUG,'x_ScheduleHeaderId ', x_ScheduleHeaderId);
12013 rlm_core_sv.dlog(k_DEBUG,'x_UpdateLevel to ', x_UpdateLevel);
12014 END IF;
12015 --
12016 IF x_UpdateLevel <> 'GROUP' THEN
12017 --
12018 UPDATE rlm_interface_lines
12019 SET process_status = x_Status
12020 WHERE header_id = x_header_id
12021 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
12022 rlm_core_sv.k_PS_FROZEN_FIRM)
12023 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
12024 --
12025 UPDATE rlm_schedule_lines
12026 SET process_status = x_Status
12027 WHERE header_id = x_ScheduleHeaderid
12028 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
12029 rlm_core_sv.k_PS_FROZEN_FIRM)
12030 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
12031 --
12032 ELSE
12033 --
12034 IF (l_debug <> -1) THEN
12035 rlm_core_sv.dlog(k_DEBUG,'Update Group');
12036 END IF;
12037 --
12038 UPDATE rlm_interface_lines
12039 SET process_status = x_Status
12040 WHERE header_id = x_header_id
12041 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12042 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12043 AND customer_item_id = x_Group_rec.customer_item_id
12044 AND inventory_item_id = x_Group_rec.inventory_item_id
12045 AND order_header_id = x_Group_rec.order_header_id
12046 /*AND nvl(cust_production_seq_num,k_VNULL) =
12047 nvl(x_Group_rec.cust_production_seq_num, k_VNULL)
12048 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
12049 rlm_core_sv.k_PS_FROZEN_FIRM) */
12050 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
12051 --
12052 IF (l_debug <> -1) THEN
12053 rlm_core_sv.dlog(k_DEBUG,'No of interface Lines Updated ', SQL%ROWCOUNT);
12054 END IF;
12055 --
12056 UPDATE rlm_schedule_lines
12057 SET process_status = x_Status
12058 WHERE header_id = x_ScheduleheaderId
12059 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12060 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12061 AND customer_item_id = x_Group_rec.customer_item_id
12062 AND inventory_item_id = x_Group_rec.inventory_item_id
12063 --AND order_header_id = x_Group_rec.order_header_id
12064 /*AND nvl(cust_production_seq_num, k_VNULL) =
12065 nvl(x_Group_rec.cust_production_seq_num, k_VNULL)*/
12066 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,
12067 rlm_core_sv.k_PS_FROZEN_FIRM, rlm_core_sv.k_PS_ERROR)
12068 AND item_detail_type IN (k_PAST_DUE_FIRM, k_FIRM, k_FORECAST, k_RECT);
12069 --
12070 END IF;
12071 --
12072 IF (l_debug <> -1) THEN
12073 rlm_core_sv.dlog(k_DEBUG,'No of Schedule Lines Updated ', SQL%ROWCOUNT);
12074 rlm_core_sv.dpop(k_SDEBUG);
12075 END IF;
12076 --
12077 EXCEPTION
12078 --
12079 WHEN OTHERS THEN
12080 --
12081 rlm_message_sv.sql_error('rlm_rd_sv.UpdateGroupStatus',x_progress);
12082 --
12083 IF (l_debug <> -1) THEN
12084 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12085 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12086 END IF;
12087 --
12088 RAISE ;
12089 --
12090 END UpdateGroupStatus;
12091
12092 /*===========================================================================
12093
12094 FUNCTION IsFrozen
12095
12096 ===========================================================================*/
12097 FUNCTION IsFrozen(x_horizon_start_date IN DATE,
12098 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
12099 x_ShipDate IN DATE)
12100 RETURN BOOLEAN
12101 IS
12102
12103 x_progress VARCHAR2(3) := '010';
12104
12105 BEGIN
12106 --
12107 IF (l_debug <> -1) THEN
12108 rlm_core_sv.dpush(k_SDEBUG,'IsFrozen');
12109 rlm_core_sv.dlog(k_DEBUG,'x_ShipToId',x_group_rec.ship_to_org_id);
12110 rlm_core_sv.dlog(k_DEBUG,'x_ShipfromOrgId',x_group_rec.ship_from_org_id);
12111 rlm_core_sv.dlog(k_DEBUG,'x_horizon_start_date',x_horizon_start_date);
12112 rlm_core_sv.dlog(k_DEBUG,'x_ShipDate',x_ShipDate);
12113 rlm_core_sv.dlog(k_DEBUG,'frozen_days',x_Group_rec.frozen_days);
12114 END IF;
12115 --
12116 /*
12117 --global_atp
12118 IF g_ATP = k_ATP THEN
12119 --
12120 IF (l_debug <> -1) THEN
12121 rlm_core_sv.dpop(k_SDEBUG,'FALSE');
12122 END IF;
12123 --
12124 RETURN FALSE;
12125 --
12126 END IF;
12127 */
12128
12129 /* check if the order line falls within the frozen fence */
12130 --
12131 IF ((to_date(to_char(x_ShipDate,'DD-MM-YYYY'),'DD-MM-YYYY')) <
12132 (to_date(to_char(x_horizon_start_date,'DD-MM-YYYY'),'DD-MM-YYYY') +
12133 x_Group_rec.frozen_days )) AND x_Group_rec.frozen_days <> 0 THEN
12134 --
12135 IF (l_debug <> -1) THEN
12136 rlm_core_sv.dpop(k_SDEBUG,'TRUE');
12137 END IF;
12138 --
12139 RETURN(TRUE);
12140 --
12141 ELSE
12142 --
12143 IF (l_debug <> -1) THEN
12144 rlm_core_sv.dpop(k_SDEBUG,'FALSE');
12145 END IF;
12146 --
12147 RETURN(FALSE);
12148 --
12149 END IF;
12150 --
12151 EXCEPTION
12152 --
12153 WHEN OTHERS THEN
12154 --
12155 rlm_message_sv.sql_error('rlm_rd_sv.IsFrozen', x_progress);
12156 --
12157 IF (l_debug <> -1) THEN
12158 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
12159 END IF;
12160 --
12161 RAISE;
12162 --
12163 END IsFrozen;
12164 --
12165 /*===========================================================================
12166
12167 FUNCTION LockHeaders
12168
12169 ===========================================================================*/
12170 FUNCTION LockHeaders (x_header_id IN NUMBER)
12171 RETURN BOOLEAN
12172 IS
12173 x_progress VARCHAR2(3) := '010';
12174
12175 CURSOR c IS
12176 SELECT *
12177 FROM rlm_interface_headers
12178 WHERE header_id = x_header_id
12179 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE,rlm_core_sv.k_PS_PARTIAL_PROCESSED)
12180 FOR UPDATE NOWAIT;
12181
12182 BEGIN
12183 --
12184 IF (l_debug <> -1) THEN
12185 rlm_core_sv.dpush(k_SDEBUG,'LockHeaders');
12186 rlm_core_sv.dlog(k_DEBUG,'Locking RLM_INTERFACE_HEADERS');
12187 END IF;
12188 --
12189 OPEN c;
12190 --
12191 CLOSE c;
12192 --
12193 IF (l_debug <> -1) THEN
12194 rlm_core_sv.dlog(k_DEBUG,'Returning True ');
12195 rlm_core_sv.dpop(k_SDEBUG);
12196 END IF;
12197 --
12198 RETURN TRUE;
12199 --
12200 EXCEPTION
12201 WHEN APP_EXCEPTION.RECORD_LOCK_EXCEPTION THEN
12202 --
12203 IF (l_debug <> -1) THEN
12204 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE');
12205 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12206 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12207 END IF;
12208 --
12209 RETURN FALSE;
12210 --
12211 WHEN OTHERS THEN
12212 rlm_message_sv.sql_error('rlm_rd_sv.LockHeaders',x_progress);
12213 --
12214 IF (l_debug <> -1) THEN
12215 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE OTHERS ');
12216 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12217 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12218 END IF;
12219 --
12220 RETURN FALSE;
12221
12222 END LockHeaders;
12223
12224 /*===========================================================================
12225
12226 PROCEDURE UpdateHeaderStatus
12227
12228 ===========================================================================*/
12229 PROCEDURE UpdateHeaderStatus( x_HeaderId IN NUMBER,
12230 x_ScheduleHeaderId IN NUMBER,
12231 x_status IN NUMBER)
12232 IS
12233 x_progress VARCHAR2(3) := '010';
12234
12235 BEGIN
12236 --
12237 IF (l_debug <> -1) THEN
12238 rlm_core_sv.dpush(k_SDEBUG,'UpdateHeaderStatus');
12239 rlm_core_sv.dlog(k_DEBUG,'UpdateHeaderStatus to ', x_status);
12240 END IF;
12241 --
12242 UPDATE rlm_interface_headers
12243 SET process_status = x_Status
12244 WHERE header_id = x_HeaderId;
12245
12246 UPDATE rlm_schedule_headers
12247 SET process_status = x_Status
12248 WHERE header_id = x_ScheduleHeaderId;
12249
12250 --
12251 IF (l_debug <> -1) THEN
12252 rlm_core_sv.dpop(k_SDEBUG);
12253 END IF;
12254 --
12255 EXCEPTION
12256 --
12257 WHEN OTHERS THEN
12258 --
12259 rlm_message_sv.sql_error('rlm_rd_sv.UpdateHeaderStatus',x_progress);
12260 --
12261 IF (l_debug <> -1) THEN
12262 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12263 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12264 END IF;
12265 --
12266 RAISE ;
12267 --
12268 END UpdateHeaderStatus;
12269
12270 /*===========================================================================
12271
12272 FUNCTION LockLines
12273
12274 ===========================================================================*/
12275 FUNCTION LockLines (x_Group_rec IN rlm_dp_sv.t_Group_rec,
12276 x_header_id IN NUMBER)
12277 RETURN BOOLEAN
12278 IS
12279 x_progress VARCHAR2(3) := '010';
12280
12281 CURSOR c IS
12282 SELECT *
12283 FROM rlm_interface_lines_all
12284 WHERE header_id = x_header_id
12285 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12286 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12287 AND customer_item_id = x_Group_rec.customer_item_id
12288 AND inventory_item_id = x_Group_rec.inventory_item_id
12289 --AND nvl(schedule_item_num,k_NNULL) = nvl(x_Group_rec.schedule_item_num, k_NNULL)
12290 AND order_header_id = x_Group_rec.order_header_id
12291 /*AND nvl(cust_production_seq_num,k_VNULL) = nvl(x_Group_rec.cust_production_seq_num, k_VNULL)*/
12292 AND process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
12293 FOR UPDATE NOWAIT;
12294
12295 BEGIN
12296 --
12297 IF (l_debug <> -1) THEN
12298 rlm_core_sv.dpush(k_SDEBUG,'LockLines');
12299 rlm_core_sv.dlog(k_DEBUG,'Locking RLM_INTERFACE_LINES');
12300 END IF;
12301 --
12302 OPEN c;
12303 --
12304 CLOSE c;
12305 --
12306 IF (l_debug <> -1) THEN
12307 rlm_core_sv.dlog(k_DEBUG,'Returning True ');
12308 rlm_core_sv.dpop(k_SDEBUG);
12309 END IF;
12310 --
12311 RETURN TRUE;
12312 --
12313 EXCEPTION
12314 WHEN APP_EXCEPTION.RECORD_LOCK_EXCEPTION THEN
12315 --
12316 IF (l_debug <> -1) THEN
12317 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE');
12318 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12319 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12320 END IF;
12321 --
12322 RETURN FALSE;
12323 --
12324 WHEN OTHERS THEN
12325 rlm_message_sv.sql_error('rlm_rd_sv.LockLines',x_progress);
12326 --
12327 IF (l_debug <> -1) THEN
12328 rlm_core_sv.dlog(k_DEBUG,'REturning FALSE OTHERS ');
12329 rlm_core_sv.dlog(k_DEBUG,'progress',x_Progress);
12330 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHER - sql error');
12331 END IF;
12332 --
12333 RETURN FALSE;
12334 --
12335 END LockLines;
12336
12337 /*===========================================================================
12338
12339 PROCEDURE NAME: CheckTolerance
12340
12341 ===========================================================================*/
12342
12343 PROCEDURE CheckTolerance(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12344 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
12345 x_Key_rec IN RLM_RD_SV.t_Key_rec,
12346 x_OldQty IN NUMBER,
12347 x_NewQty IN NUMBER)
12348 IS
12349
12350 v_PctDelta NUMBER;
12351 v_item_no VARCHAR2(80);
12352 v_Progress VARCHAR2(3) := '010';
12353 v_text VARCHAR2(2000) := NULL;
12354 x_DemandTolerancePos NUMBER;
12355 x_DemandToleranceNeg NUMBER;
12356 BEGIN
12357 --
12358 IF (l_debug <> -1) THEN
12359 rlm_core_sv.dpush(k_SDEBUG,'checktolerance');
12360 rlm_core_sv.dlog(k_DEBUG,'CustomerItemId',x_Group_rec.Customer_Item_Id);
12361 rlm_core_sv.dlog(k_DEBUG,'x_OldQty',x_OldQty);
12362 rlm_core_sv.dlog(k_DEBUG,'x_NewQty',x_NewQty);
12363 rlm_core_sv.dlog(k_DEBUG,'x_DemandTolerancePos',
12364 x_Group_rec.setup_terms_rec.demand_tolerance_above);
12365 rlm_core_sv.dlog(k_DEBUG,'x_DemandToleranceNeg',
12366 x_group_rec.setup_terms_rec.demand_tolerance_below);
12367 END IF;
12368 --
12369 -- Verify that the quantity change falls within the defined tolerance limits
12370 -- for the passed customer_item_id
12371 --
12372 x_DemandTolerancePos := x_Group_rec.setup_terms_rec.demand_tolerance_above;
12373 x_DemandToleranceNeg := x_Group_rec.setup_terms_rec.demand_tolerance_below;
12374 --
12375 IF nvl(x_OldQty,0) <> 0 THEN
12376 --
12377 v_PctDelta := ((x_NewQty - x_OldQty)/x_OldQty)*100;
12378 v_PctDelta := round(v_PctDelta,2);
12379 --
12380 IF (l_debug <> -1) THEN
12381 rlm_core_sv.dlog(k_DEBUG,'v_PctDelta',v_PctDelta);
12382 END IF;
12383 --
12384 IF (x_DemandTolerancePos < v_PctDelta) OR
12385 (x_DemandToleranceNeg < ABS(v_PctDelta)) THEN
12386 --
12387 rlm_message_sv.app_error(
12388 x_ExceptionLevel => rlm_message_sv.k_warn_level,
12389 x_MessageName => 'RLM_TOLERANCE_CHECK_FAILED',
12390 x_InterfaceHeaderId => x_sched_rec.header_id,
12391 x_InterfaceLineId => x_Key_rec.req_rec.line_id,
12392 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
12393 x_ScheduleLineId => x_Key_rec.req_rec.schedule_line_id,
12394 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
12395 x_OrderLineId => x_Key_rec.dem_rec.line_id,
12396 x_token1=>'CUSITEM',
12397 x_value1=>rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
12398 x_token2=>'PCT_DELTA1',
12399 x_value2=>v_PctDelta,
12400 x_token3=>'PCT_DELTA_POSITIVE',
12401 x_value3=>x_DemandTolerancePos,
12402 x_token4=>'PCT_DELTA_NEGATIVE',
12403 x_value4=>x_DemandToleranceNeg);
12404 --
12405 IF (l_debug <> -1) THEN
12406 rlm_core_sv.dlog(k_DEBUG,'WARNING:RLM_TOLERANCE_CHECK_FAILED');
12407 rlm_core_sv.dlog(k_DEBUG,'tolerance check failed');
12408 END IF;
12409 --
12410 END IF;
12411 --
12412 END IF;
12413 --
12414 IF (l_debug <> -1) THEN
12415 rlm_core_sv.dpop(k_SDEBUG);
12416 END IF;
12417 --
12418 EXCEPTION
12419 --
12420 WHEN OTHERS THEN
12421 --
12422 rlm_message_sv.sql_error('rlm_rd_sv.CheckTolerance', v_Progress);
12423 --
12424 IF (l_debug <> -1) THEN
12425 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: OTHERS - sql error');
12426 END IF;
12427 --
12428 raise;
12429 --
12430 END CheckTolerance;
12431 --
12432
12433 /*===========================================================================
12434
12435 FUNCTION NAME: AlreadyUpdated
12436
12437 ===========================================================================*/
12438 FUNCTION AlreadyUpdated(x_line_id_tab IN t_matching_line)
12439 RETURN BOOLEAN
12440 IS
12441 v_already_updated BOOLEAN DEFAULT FALSE;
12442 BEGIN
12443 --
12444 IF (l_debug <> -1) THEN
12445 --{
12446 rlm_core_sv.dpush(k_SDEBUG, 'AlreadyUpdated');
12447 rlm_core_sv.dlog(k_DEBUG, 'x_line_id_tab.COUNT', x_line_id_tab.COUNT);
12448 rlm_core_sv.dlog(k_DEBUG, 'x_line_id_tab(0)', x_line_id_tab(0));
12449 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab.COUNT', g_Op_tab.COUNT);
12450 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab_Unschedule.COUNT', g_Op_tab_Unschedule.COUNT);
12451 rlm_core_sv.dlog(k_DEBUG, 'g_Accounted_Tab.COUNT', g_Accounted_Tab.COUNT);
12452 --
12453 IF g_Op_tab.COUNT <> 0 THEN
12454 FOR i IN g_Op_Tab.FIRST..g_Op_Tab.LAST LOOP
12455 rlm_core_sv.dlog(k_DEBUG, 'g_Op_Tab('||i||').line_id',
12456 g_Op_Tab(i).line_id);
12457 END LOOP;
12458 END IF;
12459 --
12460 IF g_Op_Tab_Unschedule.COUNT <> 0 THEN
12461 FOR i IN g_Op_Tab_Unschedule.FIRST..g_Op_Tab_unschedule.LAST LOOP
12462 rlm_core_sv.dlog(k_DEBUG, 'g_Op_Tab_Unschedule('||i||').line_id',
12463 g_Op_Tab_Unschedule(i).line_id);
12464 END LOOP;
12465 END IF;
12466 --
12467 IF g_Accounted_Tab.COUNT <> 0 THEN
12468 FOR i IN g_Accounted_Tab.FIRST..g_Accounted_Tab.LAST LOOP
12469 rlm_core_sv.dlog(k_DEBUG, 'g_Accounted_Tab('||i||').line_id',
12470 g_Accounted_Tab(i).line_id);
12471 END LOOP;
12472 END IF;
12473 --}
12474 END IF;
12475 --
12476 IF (x_line_id_tab.COUNT = 0) THEN
12477 --
12478 IF (l_debug <> -1) THEN
12479 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12480 END IF;
12481 --
12482 RETURN FALSE;
12483 --
12484 END IF;
12485
12486 IF g_Op_tab.COUNT <> 0 THEN
12487 --
12488 FOR i IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12489 --
12490 FOR j IN g_Op_tab.FIRST..g_Op_tab.LAST LOOP
12491 --
12492 IF x_line_id_tab(i) = g_Op_tab(j).line_id THEN
12493 --
12494 IF (l_debug <> -1) THEN
12495 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(i));
12496 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12497 END IF;
12498 --
12499 RETURN TRUE;
12500 --
12501 END IF;
12502 --
12503 END LOOP;
12504 --
12505 END LOOP;
12506 --
12507 END IF;
12508 --
12509 --
12510 IF g_Accounted_tab.COUNT <> 0 THEN
12511 --
12512 FOR i IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12513 --
12514 FOR j IN g_Accounted_tab.FIRST..g_Accounted_tab.LAST LOOP
12515 --
12516 IF x_line_id_tab(i) = g_Accounted_tab(j).line_id THEN
12517 --
12518 IF (l_debug <> -1) THEN
12519 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(i));
12520 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12521 END IF;
12522 --
12523 RETURN TRUE;
12524 --
12525 END IF;
12526 --
12527 END LOOP;
12528 --
12529 END LOOP;
12530 --
12531 END IF;
12532 --
12533 --
12534 --global_atp
12535 --
12536 IF g_Op_tab_Unschedule.COUNT <> 0 THEN
12537 --
12538 FOR k IN x_line_id_tab.FIRST..x_line_id_tab.LAST LOOP
12539 --
12540 FOR l IN g_Op_tab_Unschedule.FIRST..g_Op_tab_Unschedule.LAST LOOP
12541 --
12542 IF x_line_id_tab(k) = g_Op_tab_Unschedule(l).line_id THEN
12543 --
12544 IF (l_debug <> -1) THEN
12545 rlm_core_sv.dlog(k_DEBUG, 'This line id has already been updated', x_line_id_tab(k));
12546 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
12547 END IF;
12548 --
12549 RETURN TRUE;
12550 --
12551 END IF;
12552 --
12553 END LOOP;
12554 --
12555 END LOOP;
12556 --
12557 IF (l_debug <> -1) THEN
12558 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12559 END IF;
12560 --
12561 RETURN FALSE;
12562 --
12563 ELSE
12564 --
12565 IF (l_debug <> -1) THEN
12566 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
12567 END IF;
12568 --
12569 RETURN FALSE;
12570 --
12571 END IF;
12572 --
12573 EXCEPTION
12574 --
12575 WHEN OTHERS THEN
12576 --
12577 IF (l_debug <> -1) THEN
12578 rlm_core_sv.dlog(k_DEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
12579 rlm_core_sv.dpop(k_SDEBUG, 'When Others - FALSE');
12580 END IF;
12581 --
12582 RETURN FALSE;
12583 --
12584
12585 END;
12586 --
12587 /*===========================================================================
12588
12589 FUNCTION NAME: GetTPContext
12590
12591 ===========================================================================*/
12592 PROCEDURE GetTPContext( x_sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12593 x_group_rec IN rlm_dp_sv.t_Group_rec,
12594 x_req_rec IN rlm_rd_sv.t_generic_rec,
12595 x_customer_number OUT NOCOPY VARCHAR2,
12596 x_ship_to_ece_locn_code OUT NOCOPY VARCHAR2,
12597 x_bill_to_ece_locn_code OUT NOCOPY VARCHAR2,
12598 x_inter_ship_to_ece_locn_code OUT NOCOPY VARCHAR2,
12599 x_tp_group_code OUT NOCOPY VARCHAR2,
12600 x_key_rec IN rlm_rd_sv.t_key_rec)
12601 IS
12602
12603 --
12604 v_Progress VARCHAR2(3) := '010';
12605 v_ece_tp_location_code_ext VARCHAR2(35);
12606 v_ece_tp_translator_code VARCHAR2(35);
12607 --
12608 BEGIN
12609 --
12610 --
12611 IF (l_debug <> -1) THEN
12612 rlm_core_sv.dpush(k_SDEBUG,'GetTPContext');
12613 END IF;
12614 --
12615 IF(x_sched_rec.header_id is not null) then
12616 --
12617 IF (l_debug <> -1) THEN
12618 rlm_core_sv.dlog(k_DEBUG,'customer_id', x_sched_rec.customer_id);
12619 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.ece_tp_translator_code',
12620 x_sched_rec.ece_tp_translator_code);
12621 rlm_core_sv.dlog(k_DEBUG,'x_sched_rec.ece_tp_location_code_ext',
12622 x_sched_rec.ece_tp_location_code_ext);
12623 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.ship_to_address_id',
12624 x_group_rec.ship_to_address_id);
12625 rlm_core_sv.dlog(k_DEBUG,'x_group_rec.bill_to_address_id',
12626 x_group_rec.bill_to_address_id);
12627 END IF;
12628 --
12629 IF x_sched_rec.ECE_TP_LOCATION_CODE_EXT is NOT NULL THEN
12630 --
12631 -- Following query is changed as per TCA obsolescence project.
12632 SELECT ETG.TP_GROUP_CODE
12633 INTO x_tp_group_code
12634 FROM ECE_TP_GROUP ETG,
12635 ECE_TP_HEADERS ETH,
12636 HZ_CUST_ACCT_SITES ACCT_SITE
12637 WHERE ETG.TP_GROUP_ID = ETH.TP_GROUP_ID
12638 and ETH.TP_HEADER_ID = ACCT_SITE.TP_HEADER_ID
12639 and ACCT_SITE.CUST_ACCOUNT_ID = x_sched_rec.CUSTOMER_ID
12640 and ACCT_SITE.ECE_TP_LOCATION_CODE = x_Sched_rec.ECE_TP_LOCATION_CODE_EXT;
12641
12642 ELSE
12643 x_tp_group_code := x_sched_rec.ECE_TP_TRANSLATOR_CODE;
12644 END IF;
12645 --
12646 BEGIN
12647 --
12648 -- Following query is changed as per TCA obsolescence project.
12649 SELECT ece_tp_location_code
12650 INTO x_ship_to_ece_locn_code
12651 FROM HZ_CUST_ACCT_SITES ACCT_SITE
12652 WHERE ACCT_SITE.CUST_ACCT_SITE_ID = x_group_rec.ship_to_address_id;
12653 --
12654 EXCEPTION
12655 WHEN NO_DATA_FOUND THEN
12656 x_ship_to_ece_locn_code := NULL;
12657 END;
12658 --
12659
12660 --
12661
12662 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12663 -- have the bill_to in x_group_rec. Code has been removed as a part of
12664 -- TCA OBSOLESCENCE PROJECT.
12665
12666 --
12667 IF x_sched_rec.customer_id is NOT NULL THEN
12668 --
12669 -- Following query is changed as per TCA obsolescence project.
12670 SELECT account_number
12671 INTO x_customer_number
12672 FROM HZ_CUST_ACCOUNTS CUST_ACCT
12673 WHERE CUST_ACCT.CUST_ACCOUNT_ID = x_sched_rec.customer_id;
12674 --
12675 END IF;
12676 --
12677 IF (l_debug <> -1) THEN
12678 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12679 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12680 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12681 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12682 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12683 END IF;
12684 --
12685 ELSIF(x_key_rec.req_rec.header_id is not NULL) THEN
12686 --
12687 IF (l_debug <> -1) THEN
12688 rlm_core_sv.dlog(k_DEBUG,'customer_id', x_key_rec.req_rec.customer_id);
12689 rlm_core_sv.dlog(k_DEBUG,'ship_to_address_id',
12690 x_key_rec.req_rec.ship_to_address_id);
12691 rlm_core_sv.dlog(k_DEBUG,'bill_to_address_id',
12692 x_key_rec.req_rec.bill_to_address_id);
12693 END IF;
12694 --
12695 SELECT ECE_TP_LOCATION_CODE_EXT, ECE_TP_TRANSLATOR_CODE
12696 INTO v_ece_tp_location_code_ext,v_ece_tp_translator_code
12697 FROM rlm_interface_headers
12698 WHERE header_id = x_key_rec.req_rec.header_id;
12699 --
12700 IF v_ECE_TP_LOCATION_CODE_EXT is NOT NULL THEN
12701 --
12702 -- Following query is changed as per TCA obsolescence project.
12703 SELECT ETG.TP_GROUP_CODE
12704 INTO x_tp_group_code
12705 FROM ECE_TP_GROUP ETG,
12706 ECE_TP_HEADERS ETH,
12707 HZ_CUST_ACCT_SITES ACCT_SITE
12708 WHERE ETG.TP_GROUP_ID = ETH.TP_GROUP_ID
12709 and ETH.TP_HEADER_ID = ACCT_SITE.TP_HEADER_ID
12710 and ACCT_SITE.ECE_TP_LOCATION_CODE = v_ECE_TP_LOCATION_CODE_EXT ;
12711 ELSE
12712 x_tp_group_code := v_ECE_TP_TRANSLATOR_CODE;
12713 END IF;
12714 --
12715 BEGIN
12716 --
12717 -- Following query is changed as per TCA obsolescence project.
12718 SELECT ece_tp_location_code
12719 INTO x_ship_to_ece_locn_code
12720 FROM HZ_CUST_ACCT_SITES
12721 WHERE CUST_ACCT_SITE_ID = x_key_rec.req_rec.ship_to_address_id;
12722 --
12723 EXCEPTION
12724 WHEN NO_DATA_FOUND THEN
12725 x_ship_to_ece_locn_code := NULL;
12726 END;
12727 --
12728
12729 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12730 -- have the bill_to in x_group_rec. Code has been removed as a part of
12731 -- TCA OBSOLESCENCE PROJECT.
12732
12733 --
12734 IF x_key_rec.req_rec.customer_id is NOT NULL THEN
12735 --
12736 -- Following query is changed as per TCA obsolescence project.
12737 SELECT account_number
12738 INTO x_customer_number
12739 FROM HZ_CUST_ACCOUNTS
12740 WHERE ACCOUNT_NUMBER = x_key_rec.req_rec.customer_id;
12741 --
12742 END IF;
12743 --
12744 IF (l_debug <> -1) THEN
12745 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12746 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12747 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12748 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12749 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12750 END IF;
12751 --
12752 ELSE
12753 --
12754 BEGIN
12755 --
12756 -- Following query is changed as per TCA obsolescence project.
12757 SELECT ece_tp_location_code
12758 INTO x_ship_to_ece_locn_code
12759 FROM HZ_CUST_ACCT_SITES
12760 WHERE CUST_ACCT_SITE_ID = x_group_rec.ship_to_address_id;
12761 --
12762 EXCEPTION
12763 WHEN NO_DATA_FOUND THEN
12764 x_ship_to_ece_locn_code := NULL;
12765 END;
12766 --
12767
12768 -- BUG 2204888 : Since we do not group by bill_to anymore, we would not
12769 -- have the bill_to in x_group_rec. Code has been removed as a part of
12770 -- TCA OBSOLESCENCE PROJECT.
12771
12772 --
12773 IF x_group_rec.customer_id is NOT NULL THEN
12774 --
12775 -- Following query is changed as per TCA obsolescence project.
12776 SELECT account_number
12777 INTO x_customer_number
12778 FROM HZ_CUST_ACCOUNTS CUST_ACCT
12779 WHERE CUST_ACCT.CUST_ACCOUNT_ID = x_sched_rec.customer_id;
12780 --
12781 END IF;
12782 --
12783 IF (l_debug <> -1) THEN
12784 rlm_core_sv.dlog(k_DEBUG, 'customer_number', x_customer_number);
12785 rlm_core_sv.dlog(k_DEBUG,'x_ship_to_ece_locn_code', x_ship_to_ece_locn_code);
12786 rlm_core_sv.dlog(k_DEBUG, 'x_bill_to_ece_locn_code', x_bill_to_ece_locn_code);
12787 rlm_core_sv.dlog(k_DEBUG, 'x_inter_ship_to_ece_locn_code', x_inter_ship_to_ece_locn_code);
12788 rlm_core_sv.dlog(k_DEBUG, 'x_tp_group_code',x_tp_group_code);
12789 END IF;
12790 --
12791 END IF;
12792 --
12793 IF (l_debug <> -1) THEN
12794 rlm_core_sv.dpop(k_SDEBUG);
12795 END IF;
12796 --
12797 EXCEPTION
12798 --
12799 WHEN NO_DATA_FOUND THEN
12800 --
12801 x_customer_number := NULL;
12802 --
12803 IF (l_debug <> -1) THEN
12804 rlm_core_sv.dlog(k_DEBUG, 'No data found for' , x_sched_rec.customer_id);
12805 rlm_core_sv.dpop(k_SDEBUG);
12806 END IF;
12807 --
12808 WHEN OTHERS THEN
12809 rlm_message_sv.sql_error('rlm_rd_sv.GetTPContext',v_Progress);
12810 --
12811 IF (l_debug <> -1) THEN
12812 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
12813 END IF;
12814 --
12815 raise;
12816 --
12817 END GetTPContext;
12818
12819
12820 PROCEDURE InitializeMatchRec(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
12821 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
12822 x_match_ref IN OUT NOCOPY t_Cursor_ref) IS
12823 --
12824 x_progress VARCHAR2(3) := '010';
12825 x_Query VARCHAR2(32767);
12826 --
12827 BEGIN
12828 --
12829 IF (l_debug <> -1) THEN
12830 rlm_core_sv.dpush(k_SDEBUG, 'InitializeMatchRec');
12831 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_org_id', x_Group_rec.ship_to_org_id);
12832 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.customer_item_id', x_Group_rec.customer_item_id);
12833 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id', x_Group_rec.inventory_item_id);
12834 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.order_header_id', x_Group_rec.order_header_id);
12835 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_start_date', x_Sched_rec.sched_horizon_start_date);
12836 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.sched_horizon_end_date', x_Sched_rec.sched_horizon_end_date);
12837 END IF;
12838 --
12839 OPEN x_match_ref FOR
12840 SELECT
12841 DECODE(x_Group_rec.match_within_rec.cust_production_line,'Y',cust_production_line, NULL),
12842 DECODE(x_Group_rec.match_within_rec.customer_dock_code,'Y',customer_dock_code,NULL),
12843 NULL,--request_date
12844 NULL,--schedule_date
12845 DECODE(x_Group_rec.match_within_rec.cust_po_number,'Y',cust_po_number,NULL),
12846 DECODE(x_Group_rec.match_within_rec.customer_item_revision,'Y', customer_item_revision, NULL),
12847 DECODE(x_Group_rec.match_within_rec.customer_job,'Y',customer_job, NULL),
12848 DECODE(x_Group_rec.match_within_rec.cust_model_serial_number,'Y',cust_model_serial_number, NULL),
12849 DECODE(x_Group_rec.match_within_rec.cust_production_seq_num,'Y',cust_production_seq_num,NULL),
12850 DECODE(x_Group_rec.match_within_rec.industry_attribute1,'Y', industry_attribute1,NULL),
12851 NULL,
12852 NULL,
12853 DECODE(x_Group_rec.match_within_rec.industry_attribute4,'Y', industry_attribute4,NULL),
12854 DECODE(x_Group_rec.match_within_rec.industry_attribute5,'Y', industry_attribute5,NULL),
12855 DECODE(x_Group_rec.match_within_rec.industry_attribute6,'Y', industry_attribute6,NULL),
12856 NULL,
12857 NULL,
12858 DECODE(x_Group_rec.match_within_rec.industry_attribute9, 'Y', industry_attribute9,NULL),
12859 DECODE(x_Group_rec.match_within_rec.industry_attribute10, 'Y', industry_attribute10,NULL),
12860 DECODE(x_Group_rec.match_within_rec.industry_attribute11, 'Y', industry_attribute11,NULL),
12861 DECODE(x_Group_rec.match_within_rec.industry_attribute12, 'Y', industry_attribute12,NULL),
12862 DECODE(x_Group_rec.match_within_rec.industry_attribute13, 'Y', industry_attribute13,NULL),
12863 DECODE(x_Group_rec.match_within_rec.industry_attribute14, 'Y', industry_attribute14,NULL),
12864 DECODE(x_Group_rec.match_within_rec.industry_attribute15, 'Y', industry_attribute15,NULL),
12865 DECODE(x_Group_rec.match_within_rec.attribute1, 'Y', attribute1, NULL),
12866 DECODE(x_Group_rec.match_within_rec.attribute2, 'Y', attribute2, NULL),
12867 DECODE(x_Group_rec.match_within_rec.attribute3, 'Y', attribute3, NULL),
12868 DECODE(x_Group_rec.match_within_rec.attribute4, 'Y', attribute4, NULL),
12869 DECODE(x_Group_rec.match_within_rec.attribute5, 'Y', attribute5, NULL),
12870 DECODE(x_Group_rec.match_within_rec.attribute6, 'Y', attribute6, NULL),
12871 DECODE(x_Group_rec.match_within_rec.attribute7, 'Y', attribute7, NULL),
12872 DECODE(x_Group_rec.match_within_rec.attribute8, 'Y', attribute8, NULL),
12873 DECODE(x_Group_rec.match_within_rec.attribute9, 'Y', attribute9, NULL),
12874 DECODE(x_Group_rec.match_within_rec.attribute10, 'Y', attribute10,NULL),
12875 DECODE(x_Group_rec.match_within_rec.attribute11, 'Y', attribute11,NULL),
12876 DECODE(x_Group_rec.match_within_rec.attribute12, 'Y', attribute12,NULL),
12877 DECODE(x_Group_rec.match_within_rec.attribute13, 'Y', attribute13,NULL),
12878 DECODE(x_Group_rec.match_within_rec.attribute14, 'Y', attribute14,NULL),
12879 DECODE(x_Group_rec.match_within_rec.attribute15, 'Y', attribute15,NULL)
12880 FROM rlm_interface_lines
12881 WHERE header_id = x_Sched_rec.header_id
12882 AND ship_from_org_id = x_Group_rec.ship_from_org_id
12883 AND ship_to_org_id = x_Group_rec.ship_to_org_id
12884 AND customer_item_id = x_Group_rec.customer_item_id
12885 AND inventory_item_id = x_Group_rec.inventory_item_id
12886 AND order_header_id = x_Group_rec.order_header_id
12887 AND item_detail_type IN (k_FIRM, k_FORECAST, k_PAST_DUE_FIRM);
12888 --
12889 IF (l_debug <> -1) THEN
12890 rlm_core_sv.dpop(k_SDEBUG, 'InitializeMatchRec');
12891 END IF;
12892 --
12893 EXCEPTION
12894 WHEN OTHERS THEN
12895 rlm_message_sv.sql_error('RLM_RD_SV.InitializeMatchRec', x_progress);
12896 --
12897 IF (l_debug <> -1) THEN
12898 rlm_core_sv.dpop(k_SDEBUG, 'EXCEPTION: ' || SUBSTR(SQLERRM,1,200));
12899 END IF;
12900 --
12901 RAISE e_group_error;
12902
12903 END InitializeMatchRec;
12904
12905
12906 FUNCTION FetchMatchRec(x_match_ref IN OUT NOCOPY t_Cursor_ref,
12907 x_opt_match_rec IN OUT NOCOPY WSH_RLM_INTERFACE.t_optional_match_rec)
12908 RETURN BOOLEAN IS
12909
12910 x_progress VARCHAR2(3) := '010';
12911
12912 BEGIN
12913 --
12914 IF (l_debug <> -1) THEN
12915 rlm_core_sv.dpush('FetchMatchRec');
12916 END IF;
12917 --
12918 FETCH x_match_ref INTO
12919 x_opt_match_rec.cust_production_line,
12920 x_opt_match_rec.customer_dock_code,
12921 x_opt_match_rec.request_date,
12922 x_opt_match_rec.schedule_date,
12923 x_opt_match_rec.cust_po_number,
12924 x_opt_match_rec.customer_item_revision,
12925 x_opt_match_rec.customer_job,
12926 x_opt_match_rec.cust_model_serial_number,
12927 x_opt_match_rec.cust_production_seq_num,
12928 x_opt_match_rec.industry_attribute1,
12929 x_opt_match_rec.industry_attribute2,
12930 x_opt_match_rec.industry_attribute3,
12931 x_opt_match_rec.industry_attribute4,
12932 x_opt_match_rec.industry_attribute5,
12933 x_opt_match_rec.industry_attribute6,
12934 x_opt_match_rec.industry_attribute7,
12935 x_opt_match_rec.industry_attribute8,
12936 x_opt_match_rec.industry_attribute9,
12937 x_opt_match_rec.industry_attribute10,
12938 x_opt_match_rec.industry_attribute11,
12939 x_opt_match_rec.industry_attribute12,
12940 x_opt_match_rec.industry_attribute13,
12941 x_opt_match_rec.industry_attribute14,
12942 x_opt_match_rec.industry_attribute15,
12943 x_opt_match_rec.attribute1,
12944 x_opt_match_rec.attribute2,
12945 x_opt_match_rec.attribute3,
12946 x_opt_match_rec.attribute4,
12947 x_opt_match_rec.attribute5,
12948 x_opt_match_rec.attribute6,
12949 x_opt_match_rec.attribute7,
12950 x_opt_match_rec.attribute8,
12951 x_opt_match_rec.attribute9,
12952 x_opt_match_rec.attribute10,
12953 x_opt_match_rec.attribute11,
12954 x_opt_match_rec.attribute12,
12955 x_opt_match_rec.attribute13,
12956 x_opt_match_rec.attribute14,
12957 x_opt_match_rec.attribute15;
12958 --
12959 IF x_match_ref%NOTFOUND THEN
12960 --
12961 IF (l_debug <> -1) THEN
12962 rlm_core_sv.dpop(k_SDEBUG, 'false');
12963 END IF;
12964 --
12965 RETURN (FALSE);
12966 --
12967 ELSE
12968 --
12969 IF (l_debug <> -1) THEN
12970 rlm_core_sv.dpop(k_SDEBUG, 'true');
12971 END IF;
12972 --
12973 RETURN (TRUE);
12974 --
12975 END IF;
12976 --
12977 EXCEPTION
12978 WHEN OTHERS THEN
12979 rlm_message_sv.sql_error('RLM_RD_SV.FetchMatchRec', x_progress);
12980 --
12981 IF (l_debug <> -1) THEN
12982 rlm_core_sv.dpop(k_SDEBUG, 'EXCEPTION: ' || SUBSTR(SQLERRM,1,200));
12983 END IF;
12984 --
12985 RAISE e_group_error;
12986 --
12987 END FetchMatchRec;
12988
12989
12990 PROCEDURE PrintMatchRec(x_opt_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec) IS
12991
12992 BEGIN
12993 --
12994 IF (l_debug <> -1) THEN
12995 rlm_core_sv.dpush(k_SDEBUG, 'PrintMatchRec');
12996 rlm_core_sv.dlog(k_DEBUG, 'Production Line', x_opt_match_rec.cust_production_line);
12997 rlm_core_sv.dlog(k_DEBUG, 'Customer dock code', x_opt_match_rec.customer_dock_code);
12998 rlm_core_sv.dlog(k_DEBUG, 'Cust PO Number', x_opt_match_rec.cust_po_number);
12999 rlm_core_sv.dlog(k_DEBUG, 'Customer item revision', x_opt_match_rec.customer_item_revision);
13000 rlm_core_sv.dlog(k_DEBUG, 'Customer job', x_opt_match_rec.customer_job);
13001 rlm_core_sv.dlog(k_DEBUG, 'Model serial number', x_opt_match_rec.cust_model_serial_number);
13002 rlm_core_sv.dlog(k_DEBUG, 'Prod seq num', x_opt_match_rec.cust_production_seq_num);
13003 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute1', x_opt_match_rec.industry_attribute1);
13004 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute2', x_opt_match_rec.industry_attribute1);
13005 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute4', x_opt_match_rec.industry_attribute4);
13006 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute5', x_opt_match_rec.industry_attribute5);
13007 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute6', x_opt_match_rec.industry_attribute6);
13008 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute9', x_opt_match_rec.industry_attribute9);
13009 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute10', x_opt_match_rec.industry_attribute10);
13010 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute11', x_opt_match_rec.industry_attribute11);
13011 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute12', x_opt_match_rec.industry_attribute12);
13012 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute13', x_opt_match_rec.industry_attribute13);
13013 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute14', x_opt_match_rec.industry_attribute14);
13014 rlm_core_sv.dlog(k_DEBUG, 'Industry attribute15', x_opt_match_rec.industry_attribute15);
13015 rlm_core_sv.dlog(k_DEBUG, 'Attribute1', x_opt_match_rec.attribute1);
13016 rlm_core_sv.dlog(k_DEBUG, 'Attribute2', x_opt_match_rec.attribute2);
13017 rlm_core_sv.dlog(k_DEBUG, 'Attribute3', x_opt_match_rec.attribute3);
13018 rlm_core_sv.dlog(k_DEBUG, 'Attribute4', x_opt_match_rec.attribute4);
13019 rlm_core_sv.dlog(k_DEBUG, 'Attribute5', x_opt_match_rec.attribute5);
13020 rlm_core_sv.dlog(k_DEBUG, 'Attribute6', x_opt_match_rec.attribute6);
13021 rlm_core_sv.dlog(k_DEBUG, 'Attribute7', x_opt_match_rec.attribute7);
13022 rlm_core_sv.dlog(k_DEBUG, 'Attribute8', x_opt_match_rec.attribute8);
13023 rlm_core_sv.dlog(k_DEBUG, 'Attribute9', x_opt_match_rec.attribute9);
13024 rlm_core_sv.dlog(k_DEBUG, 'Attribute10', x_opt_match_rec.attribute10);
13025 rlm_core_sv.dlog(k_DEBUG, 'Attribute11', x_opt_match_rec.attribute11);
13026 rlm_core_sv.dlog(k_DEBUG, 'Attribute12', x_opt_match_rec.attribute12);
13027 rlm_core_sv.dlog(k_DEBUG, 'Attribute13', x_opt_match_rec.attribute13);
13028 rlm_core_sv.dlog(k_DEBUG, 'Attribute14', x_opt_match_rec.attribute14);
13029 rlm_core_sv.dlog(k_DEBUG, 'Attribute15', x_opt_match_rec.attribute15);
13030 rlm_core_sv.dpop(k_SDEBUG, 'PrintMatchRec');
13031 END IF;
13032 --
13033 END PrintMatchRec;
13034
13035
13036 FUNCTION AlreadyMatched(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
13037 x_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec, x_Index OUT NOCOPY NUMBER)
13038 RETURN BOOLEAN
13039 IS
13040 --
13041 b_Match BOOLEAN;
13042 e_NoMatch EXCEPTION;
13043 x_progress VARCHAR2(3) := '010';
13044 --
13045 BEGIN
13046 --
13047 IF (l_debug <> -1) THEN
13048 rlm_core_sv.dpush(k_SDEBUG, 'AlreadyMatched');
13049 rlm_core_sv.dlog(k_DEBUG, '# of rows in intransit tab', g_IntransitTab.COUNT);
13050 END IF;
13051 --
13052 b_Match := FALSE;
13053 --
13054 IF g_IntransitTab.COUNT = 0 THEN
13055 --
13056 IF (l_debug <> -1) THEN
13057 rlm_core_sv.dpop(k_SDEBUG, 'false');
13058 END IF;
13059 --
13060 RETURN (FALSE);
13061 --
13062 END IF;
13063 --
13064 FOR i IN 1..g_IntransitTab.COUNT LOOP
13065 --
13066 BEGIN
13067 --
13068 IF (x_Group_rec.match_within_rec.cust_production_line = 'Y') THEN
13069 IF NVL(g_IntransitTab(i).cust_production_line, k_VNULL) <> NVL(x_match_rec.cust_production_line, k_VNULL) THEN
13070 --
13071 IF (l_debug <> -1) THEN
13072 rlm_core_sv.dlog(k_DEBUG, 'prod line didnt match');
13073 END IF;
13074 --
13075 RAISE e_NoMatch;
13076 END IF;
13077 END IF;
13078
13079 IF (x_Group_rec.match_within_rec.customer_dock_code = 'Y') THEN
13080 IF NVL(g_IntransitTab(i).customer_dock_code, k_VNULL) <> NVL(x_match_rec.customer_dock_code, k_VNULL) THEN
13081 --
13082 IF (l_debug <> -1) THEN
13083 rlm_core_sv.dlog(k_DEBUG, 'dock code didnt match');
13084 END IF;
13085 --
13086 RAISE e_NoMatch;
13087 --
13088 END IF;
13089 END IF;
13090
13091 IF (x_Group_rec.match_within_rec.cust_po_number = 'Y') THEN
13092 IF NVL(g_IntransitTab(i).cust_po_number, k_VNULL) <> NVL(x_match_rec.cust_po_number, k_VNULL) THEN
13093 --
13094 IF (l_debug <> -1) THEN
13095 rlm_core_sv.dlog(k_DEBUG, 'po num didnt match');
13096 END IF;
13097 --
13098 RAISE e_NoMatch;
13099 END IF;
13100 END IF;
13101
13102 IF (x_Group_rec.match_within_rec.customer_item_revision = 'Y') THEN
13103 IF NVL(g_IntransitTab(i).customer_item_revision, k_VNULL) <> NVL(x_match_rec.customer_item_revision, k_VNULL) THEN
13104 --
13105 IF (l_debug <> -1) THEN
13106 rlm_core_sv.dlog(k_DEBUG, 'cust item rev didnt match');
13107 END IF;
13108 --
13109 RAISE e_NoMatch;
13110 END IF;
13111 END IF;
13112
13113 IF (x_Group_rec.match_within_rec.customer_job = 'Y') THEN
13114 IF NVL(g_IntransitTab(i).customer_job, k_VNULL) <> NVL(x_match_rec.customer_job, k_VNULL) THEN
13115 --
13116 IF (l_debug <> -1) THEN
13117 rlm_core_sv.dlog(k_DEBUG, 'customer job didnt match');
13118 END IF;
13119 --
13120 RAISE e_NoMatch;
13121 END IF;
13122 END IF;
13123
13124 IF (x_Group_rec.match_within_rec.cust_model_serial_number = 'Y') THEN
13125 IF NVL(g_IntransitTab(i).cust_model_serial_number, k_VNULL) <> NVL(x_match_rec.cust_model_serial_number, k_VNULL) THEN
13126 --
13127 IF (l_debug <> -1) THEN
13128 rlm_core_sv.dlog(k_DEBUG, 'model serial no. didnt match');
13129 END IF;
13130 --
13131 RAISE e_NoMatch;
13132 END IF;
13133 END IF;
13134
13135 IF (x_Group_rec.match_within_rec.cust_production_seq_num = 'Y') THEN
13136 IF NVL(g_IntransitTab(i).cust_production_seq_num, k_VNULL) <> NVL(x_match_rec.cust_production_seq_num, k_VNULL) THEN
13137 --
13138 IF (l_debug <> -1) THEN
13139 rlm_core_sv.dlog(k_DEBUG, 'PSQ num didnt match');
13140 END IF;
13141 --
13142 RAISE e_NoMatch;
13143 END IF;
13144 END IF;
13145
13146 IF (x_Group_rec.match_within_rec.industry_attribute1 = 'Y') THEN
13147 IF NVL(g_IntransitTab(i).industry_attribute1, k_VNULL) <> NVL(x_match_rec.industry_attribute1, k_VNULL) THEN
13148 --
13149 IF (l_debug <> -1) THEN
13150 rlm_core_sv.dlog(k_DEBUG, 'IA1 num didnt match');
13151 END IF;
13152 --
13153 RAISE e_NoMatch;
13154 END IF;
13155 END IF;
13156
13157 IF (x_Group_rec.match_within_rec.industry_attribute4 = 'Y') THEN
13158 IF NVL(g_IntransitTab(i).industry_attribute4, k_VNULL) <> NVL(x_match_rec.industry_attribute4, k_VNULL) THEN
13159 --
13160 IF (l_debug <> -1) THEN
13161 rlm_core_sv.dlog(k_DEBUG, 'IA4 num didnt match');
13162 END IF;
13163 --
13164 RAISE e_NoMatch;
13165 END IF;
13166 END IF;
13167
13168 IF (x_Group_rec.match_within_rec.industry_attribute5 = 'Y') THEN
13169 IF NVL(g_IntransitTab(i).industry_attribute5, k_VNULL) <> NVL(x_match_rec.industry_attribute5, k_VNULL) THEN
13170 --
13171 IF (l_debug <> -1) THEN
13172 rlm_core_sv.dlog(k_DEBUG, 'IA5 num didnt match');
13173 END IF;
13174 --
13175 RAISE e_NoMatch;
13176 END IF;
13177 END IF;
13178
13179 IF (x_Group_rec.match_within_rec.industry_attribute6 = 'Y') THEN
13180 IF NVL(g_IntransitTab(i).industry_attribute6, k_VNULL) <> NVL(x_match_rec.industry_attribute6, k_VNULL) THEN
13181 --
13182 IF (l_debug <> -1) THEN
13183 rlm_core_sv.dlog(k_DEBUG, 'IA6 num didnt match');
13184 END IF;
13185 --
13186 RAISE e_NoMatch;
13187 END IF;
13188 END IF;
13189
13190 IF (x_Group_rec.match_within_rec.industry_attribute9 = 'Y') THEN
13191 IF NVL(g_IntransitTab(i).industry_attribute9, k_VNULL) <> NVL(x_match_rec.industry_attribute9, k_VNULL) THEN
13192 --
13193 IF (l_debug <> -1) THEN
13194 rlm_core_sv.dlog(k_DEBUG, 'IA9 num didnt match');
13195 END IF;
13196 --
13197 RAISE e_NoMatch;
13198 END IF;
13199 END IF;
13200
13201 IF (x_Group_rec.match_within_rec.industry_attribute10 = 'Y') THEN
13202 IF NVL(g_IntransitTab(i).industry_attribute10, k_VNULL) <> NVL(x_match_rec.industry_attribute10, k_VNULL) THEN
13203 --
13204 IF (l_debug <> -1) THEN
13205 rlm_core_sv.dlog(k_DEBUG, 'IA10 num didnt match');
13206 END IF;
13207 --
13208 RAISE e_NoMatch;
13209 END IF;
13210 END IF;
13211
13212 IF (x_Group_rec.match_within_rec.industry_attribute11 = 'Y') THEN
13213 IF NVL(g_IntransitTab(i).industry_attribute11, k_VNULL) <> NVL(x_match_rec.industry_attribute11, k_VNULL) THEN
13214 --
13215 IF (l_debug <> -1) THEN
13216 rlm_core_sv.dlog(k_DEBUG, 'IA11 num didnt match');
13217 END IF;
13218 --
13219 RAISE e_NoMatch;
13220 END IF;
13221 END IF;
13222
13223 IF (x_Group_rec.match_within_rec.industry_attribute12 = 'Y') THEN
13224 IF NVL(g_IntransitTab(i).industry_attribute12, k_VNULL) <> NVL(x_match_rec.industry_attribute12, k_VNULL) THEN
13225 --
13226 IF (l_debug <> -1) THEN
13227 rlm_core_sv.dlog(k_DEBUG, 'IA12 num didnt match');
13228 END IF;
13229 --
13230 RAISE e_NoMatch;
13231 END IF;
13232 END IF;
13233
13234 IF (x_Group_rec.match_within_rec.industry_attribute13 = 'Y') THEN
13235 IF NVL(g_IntransitTab(i).industry_attribute13, k_VNULL) <> NVL(x_match_rec.industry_attribute13, k_VNULL) THEN
13236 --
13237 IF (l_debug <> -1) THEN
13238 rlm_core_sv.dlog(k_DEBUG, 'IA13 num didnt match');
13239 END IF;
13240 --
13241 RAISE e_NoMatch;
13242 END IF;
13243 END IF;
13244
13245 IF (x_Group_rec.match_within_rec.industry_attribute14 = 'Y') THEN
13246 IF NVL(g_IntransitTab(i).industry_attribute14, k_VNULL) <> NVL(x_match_rec.industry_attribute14, k_VNULL) THEN
13247 --
13248 IF (l_debug <> -1) THEN
13249 rlm_core_sv.dlog(k_DEBUG, 'IA14 num didnt match');
13250 END IF;
13251 --
13252 RAISE e_NoMatch;
13253 END IF;
13254 END IF;
13255
13256 IF (x_Group_rec.match_within_rec.attribute1 = 'Y') THEN
13257 IF NVL(g_IntransitTab(i).attribute1, k_VNULL) <> NVL(x_match_rec.attribute1, k_VNULL) THEN
13258 --
13259 IF (l_debug <> -1) THEN
13260 rlm_core_sv.dlog(k_DEBUG, 'A1 num didnt match');
13261 END IF;
13262 --
13263 RAISE e_NoMatch;
13264 END IF;
13265 END IF;
13266
13267 IF (x_Group_rec.match_within_rec.attribute2 = 'Y') THEN
13268 IF NVL(g_IntransitTab(i).attribute2, k_VNULL) <> NVL(x_match_rec.attribute2, k_VNULL) THEN
13269 --
13270 IF (l_debug <> -1) THEN
13271 rlm_core_sv.dlog(k_DEBUG, 'A2 num didnt match');
13272 END IF;
13273 --
13274 RAISE e_NoMatch;
13275 END IF;
13276 END IF;
13277
13278 IF (x_Group_rec.match_within_rec.attribute3 = 'Y') THEN
13279 IF NVL(g_IntransitTab(i).attribute3, k_VNULL) <> NVL(x_match_rec.attribute3, k_VNULL) THEN
13280 --
13281 IF (l_debug <> -1) THEN
13282 rlm_core_sv.dlog(k_DEBUG, 'A3 num didnt match');
13283 END IF;
13284 --
13285 RAISE e_NoMatch;
13286 END IF;
13287 END IF;
13288
13289 IF (x_Group_rec.match_within_rec.attribute4 = 'Y') THEN
13290 IF NVL(g_IntransitTab(i).attribute4, k_VNULL) <> NVL(x_match_rec.attribute4, k_VNULL) THEN
13291 --
13292 IF (l_debug <> -1) THEN
13293 rlm_core_sv.dlog(k_DEBUG, 'A4 num didnt match');
13294 END IF;
13295 --
13296 RAISE e_NoMatch;
13297 END IF;
13298 END IF;
13299
13300 IF (x_Group_rec.match_within_rec.attribute5 = 'Y') THEN
13301 IF NVL(g_IntransitTab(i).attribute5, k_VNULL) <> NVL(x_match_rec.attribute5, k_VNULL) THEN
13302 --
13303 IF (l_debug <> -1) THEN
13304 rlm_core_sv.dlog(k_DEBUG, 'A5 num didnt match');
13305 END IF;
13306 --
13307 RAISE e_NoMatch;
13308 END IF;
13309 END IF;
13310
13311 IF (x_Group_rec.match_within_rec.attribute6 = 'Y') THEN
13312 IF NVL(g_IntransitTab(i).attribute6, k_VNULL) <> NVL(x_match_rec.attribute6, k_VNULL) THEN
13313 --
13314 IF (l_debug <> -1) THEN
13315 rlm_core_sv.dlog(k_DEBUG, 'A6 num didnt match');
13316 END IF;
13317 --
13318 RAISE e_NoMatch;
13319 END IF;
13320 END IF;
13321
13322 IF (x_Group_rec.match_within_rec.attribute7 = 'Y') THEN
13323 IF NVL(g_IntransitTab(i).attribute7, k_VNULL) <> NVL(x_match_rec.attribute7, k_VNULL) THEN
13324 --
13325 IF (l_debug <> -1) THEN
13326 rlm_core_sv.dlog(k_DEBUG, 'A7 num didnt match');
13327 END IF;
13328 --
13329 RAISE e_NoMatch;
13330 END IF;
13331 END IF;
13332
13333 IF (x_Group_rec.match_within_rec.attribute8 = 'Y') THEN
13334 IF NVL(g_IntransitTab(i).attribute8, k_VNULL) <> NVL(x_match_rec.attribute8, k_VNULL) THEN
13335 --
13336 IF (l_debug <> -1) THEN
13337 rlm_core_sv.dlog(k_DEBUG, 'A8 num didnt match');
13338 END IF;
13339 --
13340 RAISE e_NoMatch;
13341 END IF;
13342 END IF;
13343
13344 IF (x_Group_rec.match_within_rec.attribute9 = 'Y') THEN
13345 IF NVL(g_IntransitTab(i).attribute9, k_VNULL) <> NVL(x_match_rec.attribute9, k_VNULL) THEN
13346 --
13347 IF (l_debug <> -1) THEN
13348 rlm_core_sv.dlog(k_DEBUG, 'A9 num didnt match');
13349 END IF;
13350 --
13351 RAISE e_NoMatch;
13352 END IF;
13353 END IF;
13354
13355 IF (x_Group_rec.match_within_rec.attribute10 = 'Y') THEN
13356 IF NVL(g_IntransitTab(i).attribute10, k_VNULL) <> NVL(x_match_rec.attribute10, k_VNULL) THEN
13357 --
13358 IF (l_debug <> -1) THEN
13359 rlm_core_sv.dlog(k_DEBUG, 'A10 num didnt match');
13360 END IF;
13361 --
13362 RAISE e_NoMatch;
13363 END IF;
13364 END IF;
13365
13366 IF (x_Group_rec.match_within_rec.attribute11 = 'Y') THEN
13367 IF NVL(g_IntransitTab(i).attribute11, k_VNULL) <> NVL(x_match_rec.attribute11, k_VNULL) THEN
13368 --
13369 IF (l_debug <> -1) THEN
13370 rlm_core_sv.dlog(k_DEBUG, 'A11 num didnt match');
13371 END IF;
13372 --
13373 RAISE e_NoMatch;
13374 END IF;
13375 END IF;
13376
13377 IF (x_Group_rec.match_within_rec.attribute12 = 'Y') THEN
13378 IF NVL(g_IntransitTab(i).attribute12, k_VNULL) <> NVL(x_match_rec.attribute12, k_VNULL) THEN
13379 --
13380 IF (l_debug <> -1) THEN
13381 rlm_core_sv.dlog(k_DEBUG, 'A12 num didnt match');
13382 END IF;
13383 --
13384 RAISE e_NoMatch;
13385 END IF;
13386 END IF;
13387
13388 IF (x_Group_rec.match_within_rec.attribute13 = 'Y') THEN
13389 IF NVL(g_IntransitTab(i).attribute13, k_VNULL) <> NVL(x_match_rec.attribute13, k_VNULL) THEN
13390 --
13391 IF (l_debug <> -1) THEN
13392 rlm_core_sv.dlog(k_DEBUG, 'A13 num didnt match');
13393 END IF;
13394 --
13395 RAISE e_NoMatch;
13396 END IF;
13397 END IF;
13398
13399 IF (x_Group_rec.match_within_rec.attribute14 = 'Y') THEN
13400 IF NVL(g_IntransitTab(i).attribute14, k_VNULL) <> NVL(x_match_rec.attribute14, k_VNULL) THEN
13401 --
13402 IF (l_debug <> -1) THEN
13403 rlm_core_sv.dlog(k_DEBUG, 'A14 num didnt match');
13404 END IF;
13405 --
13406 RAISE e_NoMatch;
13407 END IF;
13408 END IF;
13409
13410 IF (x_Group_rec.match_within_rec.attribute15 = 'Y') THEN
13411 IF NVL(g_IntransitTab(i).attribute15, k_VNULL) <> NVL(x_match_rec.attribute15, k_VNULL) THEN
13412 --
13413 IF (l_debug <> -1) THEN
13414 rlm_core_sv.dlog(k_DEBUG, 'A15 num didnt match');
13415 END IF;
13416 --
13417 RAISE e_NoMatch;
13418 END IF;
13419 END IF;
13420 --
13421 b_Match := TRUE;
13422 --
13423 IF (l_debug <> -1) THEN
13424 rlm_core_sv.dlog(k_DEBUG, 'Matched with index', i);
13425 END IF;
13426 --
13427 x_Index := i;
13428 EXIT;
13429 --
13430 EXCEPTION
13431 WHEN e_NoMatch THEN
13432 null;
13433 END;
13434 --
13435 END LOOP;
13436 --
13437 IF (l_debug <> -1) THEN
13438 rlm_core_sv.dpop(k_SDEBUG, 'AlreadyMatched');
13439 END IF;
13440 --
13441 RETURN (b_Match);
13442 --
13443 END AlreadyMatched;
13444
13445 /*===========================================================================
13446
13447 FUNCTION NAME: MRPOnly
13448
13449 ===========================================================================*/
13450
13451 FUNCTION MRPOnly(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13452 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec)
13453 RETURN BOOLEAN
13454
13455 IS
13456 --
13457 v_Progress VARCHAR2(3) := '010';
13458 --
13459 BEGIN
13460 --
13461 IF (l_debug <> -1) THEN
13462 rlm_core_sv.dpush(k_SDEBUG, 'MRPOnly');
13463 rlm_core_sv.dlog(k_DEBUG, 'g_Op_tab.COUNT', g_Op_tab.COUNT);
13464 END IF;
13465 --
13466 IF x_Sched_rec.Schedule_Source <> 'MANUAL' THEN
13467
13468 IF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_PLANNING THEN
13469 --
13470 IF (l_debug <> -1) THEN
13471 rlm_core_sv.dlog(k_DEBUG, 'pln_mrp_forecast_day_from',
13472 x_group_rec.setup_terms_rec.pln_mrp_forecast_day_from);
13473 END IF;
13474 --
13475 IF x_Group_rec.setup_terms_rec.pln_mrp_forecast_day_from = 1 THEN
13476 --
13477 IF (l_debug <> -1) THEN
13478 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13479 END IF;
13480 --
13481 RETURN TRUE;
13482 --
13483 ELSE
13484 --
13485 IF (l_debug <> -1) THEN
13486 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13487 END IF;
13488 --
13489 RETURN FALSE;
13490 --
13491 END IF;
13492 --
13493 ELSIF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_SHIPPING THEN
13494 --
13495 IF (l_debug <> -1) THEN
13496 rlm_core_sv.dlog(k_DEBUG, 'shp_mrp_forecast_day_from',
13497 x_group_rec.setup_terms_rec.shp_mrp_forecast_day_from);
13498 END IF;
13499 --
13500 IF x_Group_rec.setup_terms_rec.shp_mrp_forecast_day_from = 1 THEN
13501 --
13502 IF (l_debug <> -1) THEN
13503 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13504 END IF;
13505 --
13506 RETURN TRUE;
13507 --
13508 ELSE
13509 --
13510 IF (l_debug <> -1) THEN
13511 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13512 END IF;
13513 --
13514 RETURN FALSE;
13515 --
13516 END IF;
13517 --
13518 ELSIF x_Sched_rec.Schedule_type = RLM_MANAGE_DEMAND_SV.k_SEQUENCED THEN
13519 --
13520 IF (l_debug <> -1) THEN
13521 rlm_core_sv.dlog(k_DEBUG, 'seq_mrp_forecast_day_from',
13522 x_group_rec.setup_terms_rec.seq_mrp_forecast_day_from);
13523 END IF;
13524 --
13525 IF x_Group_rec.setup_terms_rec.seq_mrp_forecast_day_from = 1 THEN
13526 --
13527 IF (l_debug <> -1) THEN
13528 rlm_core_sv.dpop(k_SDEBUG, 'TRUE');
13529 END IF;
13530 --
13531 RETURN TRUE;
13532 --
13533 ELSE
13534 --
13535 IF (l_debug <> -1) THEN
13536 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13537 END IF;
13538 --
13539 RETURN FALSE;
13540 --
13541 END IF;
13542 --
13543 ELSE
13544 --
13545 IF (l_debug <> -1) THEN
13546 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13547 END IF;
13548 --
13549 RETURN FALSE;
13550 --
13551 END IF;
13552 --
13553 ELSE
13554 --
13555 IF (l_debug <> -1) THEN
13556 rlm_core_sv.dpop(k_SDEBUG, 'FALSE');
13557 END IF;
13558 --
13559 RETURN FALSE;
13560 --
13561 END IF;
13562 --
13563 EXCEPTION
13564 --
13565 WHEN OTHERS THEN
13566 --
13567 rlm_message_sv.sql_error('RLM_RD_SV.MRPOnly', v_Progress);
13568 --
13569 IF (l_debug <> -1) THEN
13570 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '|| SUBSTR(SQLERRM,1,200));
13571 END IF;
13572 --
13573 raise;
13574 --
13575 END MRPOnly;
13576
13577
13578 PROCEDURE InsertIntransitMatchRec(x_match_rec IN WSH_RLM_INTERFACE.t_optional_match_rec,
13579 x_Quantity IN NUMBER) IS
13580 v_Index NUMBER;
13581
13582 BEGIN
13583 --
13584 IF (l_debug <> -1) THEN
13585 rlm_core_sv.dpush(k_SDEBUG, 'InsertIntransitMatchRec');
13586 END IF;
13587 --
13588 v_Index := g_IntransitTab.COUNT;
13589 --
13590 IF (l_debug <> -1) THEN
13591 rlm_core_sv.dlog(k_DEBUG, '# of rows in intransit table', v_Index);
13592 END IF;
13593 --
13594 g_IntransitTab(v_Index+1).cust_production_line := x_match_rec.cust_production_line;
13595 g_IntransitTab(v_Index+1).customer_dock_code := x_match_rec.customer_dock_code;
13596 g_IntransitTab(v_Index+1).request_date := NULL; --x_match_rec.request_date;
13597 g_IntransitTab(v_Index+1).schedule_date := NULL; --x_match_rec.schedule_date;
13598 g_IntransitTab(v_Index+1).cust_po_number := x_match_rec.cust_po_number;
13599 g_IntransitTab(v_Index+1).customer_item_revision := x_match_rec.customer_item_revision;
13600 g_IntransitTab(v_Index+1).customer_job := x_match_rec.customer_job;
13601 g_IntransitTab(v_Index+1).cust_model_serial_number := x_match_rec.cust_model_serial_number;
13602 g_IntransitTab(v_Index+1).cust_production_seq_num := x_match_rec.cust_production_seq_num;
13603 g_IntransitTab(v_Index+1).industry_attribute1 := x_match_rec.industry_attribute1;
13604 g_IntransitTab(v_Index+1).industry_attribute2 := NULL; --x_match_rec.industry_attribute2;
13605 g_IntransitTab(v_Index+1).industry_attribute3 := NULL; --x_match_rec.industry_attribute3;
13606 g_IntransitTab(v_Index+1).industry_attribute4 := x_match_rec.industry_attribute4;
13607 g_IntransitTab(v_Index+1).industry_attribute5 := x_match_rec.industry_attribute5;
13608 g_IntransitTab(v_Index+1).industry_attribute6 := x_match_rec.industry_attribute6;
13609 g_IntransitTab(v_Index+1).industry_attribute7 := NULL; --x_match_rec.industry_attribute7;
13610 g_IntransitTab(v_Index+1).industry_attribute8 := NULL; --x_match_rec.industry_attribute8;
13611 g_IntransitTab(v_Index+1).industry_attribute9 := x_match_rec.industry_attribute9;
13612 g_IntransitTab(v_Index+1).industry_attribute10 := x_match_rec.industry_attribute10;
13613 g_IntransitTab(v_Index+1).industry_attribute11 := x_match_rec.industry_attribute11;
13614 g_IntransitTab(v_Index+1).industry_attribute12 := x_match_rec.industry_attribute12;
13615 g_IntransitTab(v_Index+1).industry_attribute13 := x_match_rec.industry_attribute13;
13616 g_IntransitTab(v_Index+1).industry_attribute14 := x_match_rec.industry_attribute14;
13617 g_IntransitTab(v_Index+1).industry_attribute15 := x_match_rec.industry_attribute15;
13618 g_IntransitTab(v_Index+1).attribute1 := x_match_rec.attribute1;
13619 g_IntransitTab(v_Index+1).attribute2 := x_match_rec.attribute2;
13620 g_IntransitTab(v_Index+1).attribute3 := x_match_rec.attribute3;
13621 g_IntransitTab(v_Index+1).attribute4 := x_match_rec.attribute4;
13622 g_IntransitTab(v_Index+1).attribute5 := x_match_rec.attribute5;
13623 g_IntransitTab(v_Index+1).attribute6 := x_match_rec.attribute6;
13624 g_IntransitTab(v_Index+1).attribute7 := x_match_rec.attribute7;
13625 g_IntransitTab(v_Index+1).attribute8 := x_match_rec.attribute8;
13626 g_IntransitTab(v_Index+1).attribute9 := x_match_rec.attribute9;
13627 g_IntransitTab(v_Index+1).attribute10 := x_match_rec.attribute10;
13628 g_IntransitTab(v_Index+1).attribute11 := x_match_rec.attribute11;
13629 g_IntransitTab(v_Index+1).attribute12 := x_match_rec.attribute12;
13630 g_IntransitTab(v_Index+1).attribute13 := x_match_rec.attribute13;
13631 g_IntransitTab(v_Index+1).attribute14 := x_match_rec.attribute14;
13632 g_IntransitTab(v_Index+1).attribute15 := x_match_rec.attribute15;
13633 g_IntransitTab(v_Index+1).intransit_qty := x_Quantity;
13634 --
13635 IF (l_debug <> -1) THEN
13636 rlm_core_sv.dpop(k_SDEBUG, 'InsertIntransitMatchRec');
13637 END IF;
13638 --
13639 END InsertIntransitMatchRec;
13640
13641
13642 --
13643 -- Common to reconcile and manage demand
13644 -- Set up parameters to pass to shipping API
13645 --
13646 PROCEDURE InitializeIntransitParam(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13647 x_Group_rec IN rlm_dp_sv.t_Group_rec,
13648 x_intransit_calc_basis IN VARCHAR2,
13649 x_Shipper_rec IN OUT NOCOPY WSH_RLM_INTERFACE.t_shipper_rec,
13650 x_Shipment_date IN OUT NOCOPY DATE)
13651 IS
13652
13653 -- The shipper ID is stored in the item_detail_ref_value_1 field
13654 -- when the item detail type = 4 and the sub type = 'RECEIPT', 'SHIPMENT'
13655 --
13656 CURSOR c_RctShipperIds IS
13657 SELECT start_date_time,
13658 primary_quantity,
13659 -- do not use item_ref_value_1
13660 substr(item_detail_ref_value_1,1,29) shipper_Id,
13661 line_id
13662 FROM rlm_schedule_lines
13663 WHERE ship_from_org_id = x_Group_rec.ship_from_org_id
13664 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13665 AND inventory_item_id = x_Group_rec.inventory_item_id
13666 AND customer_item_id = x_Group_rec.customer_item_id
13667 AND item_detail_type = k_RECT
13668 AND qty_type_code = k_ACTUAL
13669 AND item_detail_subtype = k_RECEIPT
13670 ORDER BY start_date_time DESC;
13671
13672 CURSOR c_ShpShipperIds IS
13673 SELECT start_date_time,
13674 primary_quantity,
13675 -- do not use item_ref_value_1
13676 substr(item_detail_ref_value_1,1,29) shipper_Id,
13677 line_id
13678 FROM rlm_schedule_lines
13679 WHERE ship_from_org_id = x_Group_rec.ship_from_org_id
13680 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13681 AND inventory_item_id = x_Group_rec.inventory_item_id
13682 AND customer_item_id = x_Group_rec.customer_item_id
13683 AND item_detail_type = k_RECT
13684 AND qty_type_code = k_ACTUAL
13685 AND item_detail_subtype = k_SHIPMENT
13686 ORDER BY start_date_time DESC;
13687
13688 --
13689 -- This cursor is to select the most recent receipt
13690 -- line on the current schedule for each group
13691 --
13692
13693 CURSOR c_LastReceipt IS
13694 SELECT start_date_time,
13695 item_detail_subtype,
13696 item_detail_ref_value_1
13697 FROM rlm_interface_lines
13698 WHERE header_id = x_Sched_rec.header_id
13699 AND ship_from_org_id = x_Group_rec.ship_from_org_id
13700 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13701 AND inventory_item_id = x_Group_rec.inventory_item_id
13702 AND customer_item_id = x_Group_rec.customer_item_id
13703 AND item_detail_type = k_RECT
13704 AND qty_type_code = k_ACTUAL
13705 AND item_detail_subtype = k_RECEIPT
13706 ORDER BY start_date_time DESC;
13707
13708 --
13709 -- This cursor is to select the most recent shipment
13710 -- line on the current schedule for each group
13711 --
13712
13713 CURSOR c_LastShipment IS
13714 SELECT start_date_time,
13715 item_detail_subtype,
13716 item_detail_ref_value_1
13717 FROM rlm_interface_lines
13718 WHERE header_id = x_Sched_rec.header_id
13719 AND ship_from_org_id = x_Group_rec.ship_from_org_id
13720 AND ship_to_org_id = x_Group_rec.ship_to_org_id
13721 AND inventory_item_id = x_Group_rec.inventory_item_id
13722 AND customer_item_id = x_Group_rec.customer_item_id
13723 AND item_detail_type = k_RECT
13724 AND qty_type_code = k_ACTUAL
13725 AND item_detail_subtype = k_SHIPMENT
13726 ORDER BY start_date_time DESC;
13727 --
13728 v_intransit_time NUMBER := 0;
13729 v_intransit_calc_basis VARCHAR2(15);
13730 v_shipment_date DATE;
13731 v_item_detail_subtype VARCHAR2(80);
13732 v_count NUMBER DEFAULT 0;
13733 v_deliveryID VARCHAR2(35);
13734 --
13735
13736 BEGIN
13737 --
13738 IF (l_debug <> -1) THEN
13739 rlm_core_sv.dpush(k_SDEBUG, 'InitializeIntransitParam');
13740 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis', x_intransit_calc_basis);
13741 END IF;
13742 --
13743 IF (x_Group_rec.setup_terms_rec.time_uom_code = 'HR') THEN
13744 v_intransit_time := nvl(x_Group_rec.setup_terms_rec.intransit_time,0)/24;
13745 ELSE
13746 v_intransit_time := nvl(x_Group_rec.setup_terms_rec.intransit_time,0);
13747 END IF;
13748 --
13749 IF (x_intransit_calc_basis = k_RECEIPT) THEN
13750 --
13751 OPEN c_LastReceipt;
13752 FETCH c_LastReceipt INTO v_shipment_date, v_item_detail_subtype, v_deliveryID;
13753 --
13754 IF (c_LastReceipt%NOTFOUND) THEN
13755 --
13756 IF (l_debug <> -1) THEN
13757 rlm_core_sv.dlog(k_DEBUG, 'No receipt line, so shipment date = sched_gen_Date - intransit');
13758 END IF;
13759 --
13760 v_shipment_date := x_Sched_rec.sched_generation_date - v_intransit_time;
13761 x_shipper_rec.shipper_Id1 := NULL;
13762 x_Shipper_rec.shipper_Id2 := NULL;
13763 x_Shipper_rec.shipper_Id3 := NULL;
13764 x_Shipper_rec.shipper_Id4 := NULL;
13765 x_Shipper_rec.shipper_Id5 := NULL;
13766 --
13767 ELSIF (v_deliveryID is NOT NULL) THEN
13768 --
13769 IF (l_debug <> -1) THEN
13770 rlm_core_sv.dlog('Delivery ID present on schedule');
13771 END IF;
13772 --
13773 FOR v_RctSID IN c_RctShipperIds LOOP
13774 --
13775 IF (c_RctShipperIds%NOTFOUND OR v_count > 5) THEN
13776 EXIT;
13777 END IF;
13778 --
13779 v_count := v_count + 1;
13780 --
13781 IF (l_debug <> -1) THEN
13782 rlm_core_sv.dlog(k_DEBUG,'line_id', v_RctSID.line_id);
13783 rlm_core_sv.dlog(k_DEBUG,'start_date_time', v_RctSID.start_date_time);
13784 rlm_core_sv.dlog(k_DEBUG,'v_count', v_count);
13785 rlm_core_sv.dlog(k_DEBUG,'Shipper_id', v_RctSID.shipper_Id);
13786 END IF;
13787 --
13788 IF v_count = 1 THEN
13789 --
13790 x_shipper_rec.shipper_Id1 := v_RctSID.shipper_Id;
13791 --
13792 ELSIF v_count = 2 THEN
13793 --
13794 x_shipper_rec.shipper_Id2 := v_RctSID.shipper_Id;
13795 --
13796 ELSIF v_count = 3 THEN
13797 --
13798 x_shipper_rec.shipper_Id3 := v_RctSID.shipper_Id;
13799 --
13800 ELSIF v_count = 4 THEN
13801 --
13802 x_shipper_rec.shipper_Id4 := v_RctSID.shipper_Id;
13803 --
13804 ELSIF v_count = 5 THEN
13805 --
13806 x_shipper_rec.shipper_Id5 := v_RctSID.shipper_Id;
13807 --
13808 END IF;
13809 --
13810 END LOOP;
13811 --
13812 ELSIF (v_shipment_date IS NOT NULL) THEN
13813 --
13814 IF (l_debug <> -1) THEN
13815 rlm_core_sv.dlog(k_DEBUG, 'No delivery ID present on schedule');
13816 END IF;
13817 --
13818 v_shipment_date := v_shipment_date - v_intransit_time;
13819 x_shipper_rec.shipper_Id1 := NULL;
13820 x_Shipper_rec.shipper_Id2 := NULL;
13821 x_Shipper_rec.shipper_Id3 := NULL;
13822 x_Shipper_rec.shipper_Id4 := NULL;
13823 x_Shipper_rec.shipper_Id5 := NULL;
13824 --
13825 END IF;
13826 --
13827 IF (l_debug <> -1) THEN
13828 rlm_core_sv.dlog(k_DEBUG, 'v_item_detail_subtype', v_item_detail_subtype);
13829 rlm_core_sv.dlog(k_DEBUG, 'calculated shipment_date', v_shipment_date);
13830 END IF;
13831 --
13832 x_Shipment_date := v_shipment_date;
13833 CLOSE c_LastReceipt;
13834 --
13835 ELSIF (x_intransit_calc_basis = k_SHIPMENT) THEN
13836 --
13837 OPEN c_LastShipment;
13838 FETCH c_LastShipment INTO v_shipment_date, v_item_detail_subtype, v_deliveryID;
13839 --
13840 IF (c_LastShipment%NOTFOUND) THEN
13841 --
13842 IF (l_debug <> -1) THEN
13843 rlm_core_sv.dlog(k_DEBUG, 'No shipment line, so shipment date = sched_gen_Date');
13844 END IF;
13845 --
13846 v_shipment_date := x_Sched_rec.sched_generation_date;
13847 x_shipper_rec.shipper_Id1 := NULL;
13848 x_Shipper_rec.shipper_Id2 := NULL;
13849 x_Shipper_rec.shipper_Id3 := NULL;
13850 x_Shipper_rec.shipper_Id4 := NULL;
13851 x_Shipper_rec.shipper_Id5 := NULL;
13852 --
13853 ELSIF (v_deliveryID is NOT NULL) THEN
13854 --
13855 IF (l_debug <> -1) THEN
13856 rlm_core_sv.dlog('Delivery ID present on schedule');
13857 END IF;
13858 --
13859 FOR v_ShpSID IN c_ShpShipperIds LOOP
13860 --
13861 IF (c_ShpShipperIds%NOTFOUND OR v_count > 5) THEN
13862 EXIT;
13863 END IF;
13864 --
13865 v_count := v_count + 1;
13866 --
13867 IF (l_debug <> -1) THEN
13868 rlm_core_sv.dlog(k_DEBUG,'line_id', v_ShpSID.line_id);
13869 rlm_core_sv.dlog(k_DEBUG,'start_date_time', v_ShpSID.start_date_time);
13870 rlm_core_sv.dlog(k_DEBUG,'v_count', v_count);
13871 rlm_core_sv.dlog(k_DEBUG,'Shipper_id', v_ShpSID.shipper_Id);
13872 END IF;
13873 --
13874 IF v_count = 1 THEN
13875 --
13876 x_shipper_rec.shipper_Id1 := v_ShpSID.shipper_Id;
13877 --
13878 ELSIF v_count = 2 THEN
13879 --
13880 x_shipper_rec.shipper_Id2 := v_ShpSID.shipper_Id;
13881 --
13882 ELSIF v_count = 3 THEN
13883 --
13884 x_shipper_rec.shipper_Id3 := v_ShpSID.shipper_Id;
13885 --
13886 ELSIF v_count = 4 THEN
13887 --
13888 x_shipper_rec.shipper_Id4 := v_ShpSID.shipper_Id;
13889 --
13890 ELSIF v_count = 5 THEN
13891 --
13892 x_shipper_rec.shipper_Id5 := v_ShpSID.shipper_Id;
13893 --
13894 END IF;
13895 --
13896 END LOOP;
13897 --
13898 ELSIF (v_shipment_date IS NOT NULL) THEN
13899 --
13900 IF (l_debug <> -1) THEN
13901 rlm_core_sv.dlog(k_DEBUG, 'No delivery ID present on schedule');
13902 END IF;
13903 --
13904 x_shipper_rec.shipper_Id1 := NULL;
13905 x_Shipper_rec.shipper_Id2 := NULL;
13906 x_Shipper_rec.shipper_Id3 := NULL;
13907 x_Shipper_rec.shipper_Id4 := NULL;
13908 x_Shipper_rec.shipper_Id5 := NULL;
13909 --
13910 END IF;
13911 --
13912 IF (l_debug <> -1) THEN
13913 rlm_core_sv.dlog(k_DEBUG, 'v_item_detail_subtype', v_item_detail_subtype);
13914 rlm_core_sv.dlog(k_DEBUG, 'calculated shipment_date', v_shipment_date);
13915 END IF;
13916 --
13917 x_Shipment_date := v_shipment_date;
13918 CLOSE c_LastShipment;
13919 --
13920 END IF; /* if intransit_calc_basis */
13921 --
13922 IF (l_debug <> -1) THEN
13923 rlm_core_sv.dpop(k_SDEBUG, 'InitializeIntransitParam');
13924 END IF;
13925 --
13926 END InitializeIntransitParam;
13927
13928
13929 --
13930 -- Blanket Order Procedures
13931 --
13932 /*===========================================================================
13933
13934 PROCEDURE InitializeBlktGroup
13935
13936 ===========================================================================*/
13937 PROCEDURE InitializeBlktGrp(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
13938 x_Group_ref IN OUT NOCOPY rlm_rd_sv.t_Cursor_ref,
13939 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
13940 IS
13941 --
13942 x_progress VARCHAR2(3) := '010';
13943 --
13944 BEGIN
13945 --
13946 IF (l_debug <> -1) THEN
13947 rlm_core_sv.dpush(k_SDEBUG,'InitializeBlktGroup');
13948 END IF;
13949 --
13950 OPEN x_Group_ref FOR
13951 SELECT rih.customer_id,
13952 ril.ship_from_org_id,
13953 ril.ship_to_address_id,
13954 ril.ship_to_org_id,
13955 ril.customer_item_id,
13956 ril.inventory_item_id,
13957 ril.industry_attribute15,
13958 rso.rso_hdr_id,
13959 ril.blanket_number,
13960 rso.effective_start_date,
13961 ril.intrmd_ship_to_id, --Bugfix 5911991
13962 ril.intmed_ship_to_org_id --Bugfix 5911991
13963 FROM rlm_interface_headers rih,
13964 rlm_interface_lines_all ril,
13965 rlm_blanket_rso rso
13966 WHERE rih.header_id = x_Sched_rec.header_id
13967 AND rih.org_id = ril.org_id
13968 AND ril.header_id = rih.header_id
13969 AND ril.ship_from_org_id = x_Group_rec.ship_from_org_id
13970 AND ril.process_status IN (rlm_core_sv.k_PS_AVAILABLE, rlm_core_sv.k_PS_FROZEN_FIRM)
13971 AND ril.customer_item_id = x_Group_rec.customer_item_id
13972 AND ril.ship_to_address_id = x_Group_rec.ship_to_address_id
13973 AND ril.blanket_number = rso.blanket_number
13974 AND rih.customer_id = rso.customer_id
13975 AND item_detail_type IN (k_FIRM, k_FORECAST, k_PAST_DUE_FIRM)
13976 AND rso.customer_item_id = DECODE(x_Group_rec.setup_terms_rec.release_rule, 'PI',
13977 x_Group_rec.customer_item_id, K_NNULL)
13978 GROUP BY rih.customer_id,
13979 ril.ship_from_org_id,
13980 ril.ship_to_address_id,
13981 ril.ship_to_org_id,
13982 ril.customer_item_id,
13983 ril.inventory_item_id,
13984 ril.industry_attribute15,
13985 rso.rso_hdr_id,
13986 ril.blanket_number,
13987 rso.effective_start_date,
13988 ril.intrmd_ship_to_id, --Bugfix 5911991
13989 ril.intmed_ship_to_org_id --Bugfix 5911991
13990 ORDER BY ril.ship_from_org_id,
13991 ril.ship_to_org_id,
13992 ril.customer_item_id,
13993 rso.effective_start_date;
13994 --
13995 IF (l_debug <> -1) THEN
13996 rlm_core_sv.dpop(k_SDEBUG);
13997 END IF;
13998 --
13999 EXCEPTION
14000 --
14001 WHEN OTHERS THEN
14002 rlm_message_sv.sql_error('rlm_rd_sv.InitializeBlktGrp',x_progress);
14003 --
14004 IF (l_debug <> -1) THEN
14005 rlm_core_sv.dlog(k_DEBUG, 'When others of InitializeBlktGrp');
14006 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14007 END IF;
14008 --
14009 raise e_group_error;
14010 --
14011 END InitializeBlktGrp;
14012
14013
14014 /*===========================================================================
14015
14016 FUNCTION FetchBlktGroup
14017
14018 ===========================================================================*/
14019 FUNCTION FetchBlktGrp(x_Group_ref IN OUT NOCOPY t_Cursor_ref,
14020 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
14021 RETURN BOOLEAN
14022 IS
14023 --
14024 x_progress VARCHAR2(3) := '010';
14025 v_effective_start_date DATE;
14026 --
14027 BEGIN
14028 --
14029 IF (l_debug <> -1) THEN
14030 rlm_core_sv.dpush(k_SDEBUG,'FetchBlktGroup');
14031 END IF;
14032 --
14033 FETCH x_Group_ref INTO
14034 x_Group_rec.customer_id,
14035 x_Group_rec.ship_from_org_id,
14036 x_Group_rec.ship_to_address_id,
14037 x_Group_rec.ship_to_org_id,
14038 x_Group_rec.customer_item_id,
14039 x_Group_rec.inventory_item_id,
14040 x_Group_rec.industry_attribute15,
14041 x_Group_rec.order_header_id,
14042 x_Group_rec.blanket_number,
14043 v_effective_start_date,
14044 x_Group_rec.intrmd_ship_to_id, --Bugfix 5911991
14045 x_Group_rec.intmed_ship_to_org_id ; --Bugfix 5911991
14046 --
14047 IF (l_debug <> -1) THEN
14048 rlm_core_sv.dlog(k_DEBUG,'Blanket Number', x_Group_rec.blanket_number);
14049 rlm_core_sv.dlog(k_DEBUG,'Order header ID', x_Group_rec.order_header_id);
14050 rlm_core_sv.dlog(k_DEBUG,'v_effective_start_date',v_effective_start_date);
14051 END IF;
14052 --
14053 IF x_Group_ref%NOTFOUND THEN
14054 --
14055 IF (l_debug <> -1) THEN
14056 rlm_core_sv.dpop(k_SDEBUG, 'false');
14057 END IF;
14058 --
14059 RETURN(FALSE);
14060 ELSE
14061 --
14062 IF (l_debug <> -1) THEN
14063 rlm_core_sv.dpop(k_SDEBUG, 'true');
14064 END IF;
14065 --
14066 RETURN(TRUE);
14067 END IF;
14068 --
14069 EXCEPTION
14070 --
14071 WHEN OTHERS THEN
14072 rlm_message_sv.sql_error('rlm_rd_sv.FetchBlktGrp',x_progress);
14073 --
14074 IF (l_debug <> -1) THEN
14075 rlm_core_sv.dlog(k_DEBUG, 'When others of FetchBlktGrp');
14076 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14077 END IF;
14078 --
14079 raise;
14080 --
14081 END FetchBlktGrp;
14082
14083
14084 /* *
14085 * SQL Bind Project: These functions just build a combined table *
14086 * of bind variable values to be passed to RLM_CORE_SV.OpenDynamicCursor *
14087 */
14088 FUNCTION BuildBindVarTab3(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
14089 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab,
14090 p_Tab3 IN RLM_CORE_SV.t_dynamic_tab)
14091 RETURN RLM_CORE_SV.t_dynamic_tab IS
14092 --
14093 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
14094 x_Progress VARCHAR2(3) := '010';
14095 --
14096 BEGIN
14097 --
14098 IF (l_debug <> -1) THEN
14099 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab3');
14100 END IF;
14101 --
14102 FOR i IN 1..p_Tab1.COUNT LOOP
14103 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
14104 END LOOP;
14105 --
14106 FOR i IN 1..p_Tab2.COUNT LOOP
14107 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
14108 END LOOP;
14109 --
14110 FOR i IN 1..p_Tab3.COUNT LOOP
14111 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab3(i);
14112 END LOOP;
14113 --
14114 IF (l_debug <> -1) THEN
14115 rlm_core_sv.dpop(k_SDEBUG);
14116 END IF;
14117 --
14118 RETURN x_BindVarTab;
14119 --
14120 EXCEPTION
14121 --
14122 WHEN OTHERS THEN
14123 --
14124 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab3',x_progress);
14125 --
14126 IF (l_debug <> -1) THEN
14127 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
14128 END IF;
14129 --
14130 raise;
14131 --
14132 END BuildBindVarTab3;
14133
14134
14135 FUNCTION BuildBindVarTab5(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
14136 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab,
14137 p_Tab3 IN RLM_CORE_SV.t_dynamic_tab,
14138 p_Tab4 IN RLM_CORE_SV.t_dynamic_tab,
14139 p_Tab5 IN RLM_CORE_SV.t_dynamic_tab)
14140 RETURN RLM_CORE_SV.t_dynamic_tab IS
14141 --
14142 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
14143 x_Progress VARCHAR2(3) := '010';
14144 --
14145 BEGIN
14146 --
14147 IF (l_debug <> -1) THEN
14148 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab5');
14149 END IF;
14150 --
14151 FOR i IN 1..p_Tab1.COUNT LOOP
14152 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
14153 END LOOP;
14154 --
14155 FOR i IN 1..p_Tab2.COUNT LOOP
14156 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
14157 END LOOP;
14158 --
14159 FOR i IN 1..p_Tab3.COUNT LOOP
14160 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab3(i);
14161 END LOOP;
14162 --
14163 FOR i IN 1..p_Tab4.COUNT LOOP
14164 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab4(i);
14165 END LOOP;
14166 --
14167 FOR i IN 1..p_Tab5.COUNT LOOP
14168 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab5(i);
14169 END LOOP;
14170 --
14171 IF (l_debug <> -1) THEN
14172 rlm_core_sv.dpop(k_SDEBUG);
14173 END IF;
14174 --
14175 RETURN x_BindVarTab;
14176 --
14177 EXCEPTION
14178 --
14179 WHEN OTHERS THEN
14180 --
14181 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab5',x_progress);
14182 --
14183 IF (l_debug <> -1) THEN
14184 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
14185 END IF;
14186 --
14187 raise;
14188 --
14189 END BuildBindVarTab5;
14190
14191
14192 FUNCTION BuildBindVarTab2(p_Tab1 IN RLM_CORE_SV.t_dynamic_tab,
14193 p_Tab2 IN RLM_CORE_SV.t_dynamic_tab)
14194 RETURN RLM_CORE_SV.t_dynamic_tab IS
14195 --
14196 x_BindVarTab RLM_CORE_SV.t_dynamic_tab;
14197 x_Progress VARCHAR2(3) := '010';
14198 --
14199 BEGIN
14200 --
14201 IF (l_debug <> -1) THEN
14202 rlm_core_sv.dpush(k_SDEBUG, 'BuildBindVarTab2');
14203 END IF;
14204 --
14205 FOR i IN 1..p_Tab1.COUNT LOOP
14206 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab1(i);
14207 END LOOP;
14208 --
14209 FOR i IN 1..p_Tab2.COUNT LOOP
14210 x_BindVarTab(x_BindVarTab.COUNT+1) := p_Tab2(i);
14211 END LOOP;
14212 --
14213 IF (l_debug <> -1) THEN
14214 rlm_core_sv.dpop(k_SDEBUG);
14215 END IF;
14216 --
14217 RETURN x_BindVarTab;
14218 --
14219 EXCEPTION
14220 --
14221 WHEN OTHERS THEN
14222 --
14223 rlm_message_sv.sql_error('rlm_rd_sv.BuildBindVarTab2',x_progress);
14224 --
14225 IF (l_debug <> -1) THEN
14226 rlm_core_sv.dpop(k_SDEBUG, 'Exception ' || substr(SQLERRM, 1, 200));
14227 END IF;
14228 --
14229 raise;
14230 --
14231 END BuildBindVarTab2;
14232
14233
14234 /*============================================================================
14235
14236 PROCEDURE NAME: SourceCUMIntransitQty
14237
14238 ==============================================================================*/
14239 PROCEDURE SourceCUMIntransitQty(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
14240 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
14241 x_Cum_rec IN RLM_RD_SV.t_Ship_rec) --Bugfix 7007638
14242 IS
14243 --
14244 i NUMBER;
14245 j NUMBER;
14246 v_SrcIntransitTab RLM_MANAGE_DEMAND_SV.t_SrcIntransitQtyTab;
14247 v_Progress VARCHAR2(3);
14248 v_Key_rec t_Key_rec;
14249 --
14250 BEGIN
14251 --
14252 IF (l_debug <> -1) THEN
14253 rlm_core_sv.dpush(k_SDEBUG, 'SourceCUMIntransitQty');
14254 rlm_core_sv.dlog(k_DEBUG, 'IntransitQty to be sourced', g_IntransitQty);
14255 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab.COUNT', g_SourceTab.COUNT);
14256 --
14257 FOR i IN g_SourceTab.FIRST..g_SourceTab.LAST LOOP
14258 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab('||i||').organization_id',
14259 g_SourceTab(i).organization_id);
14260 rlm_core_sv.dlog(k_DEBUG, 'g_SourceTab('||i||').allocation_percent',
14261 g_SourceTab(i).allocation_percent);
14262 END LOOP;
14263 --
14264 END IF;
14265 --
14266 v_Progress := '010';
14267 --
14268 i := g_SourceTab.FIRST;
14269 j := 0;
14270 --
14271 WHILE i IS NOT NULL LOOP
14272 --{
14273 j := j+1;
14274 --
14275 v_SrcIntransitTab(j).intransit_qty :=
14276 ROUND(g_IntransitQty * g_SourceTab(i).allocation_percent/100);
14277 v_SrcIntransitTab(j).organization_id := g_SourceTab(i).organization_id;
14278 --
14279 IF (l_debug <> -1) THEN
14280 rlm_core_sv.dlog(k_DEBUG, 'v_SrcIntransitTab('||j||').intransit_qty',
14281 v_SrcIntransitTab(j).intransit_qty);
14282 rlm_core_sv.dlog(k_DEBUG, 'v_SrcIntransitTab('||j||').organization_id',
14283 v_SrcIntransitTab(j).organization_id);
14284 END IF;
14285 --
14286 i := g_SourceTab.NEXT(i);
14287 --}
14288 END LOOP;
14289 --
14290 v_Progress := '020';
14291 i := v_SrcIntransitTab.FIRST;
14292 --
14293 WHILE i IS NOT NULL LOOP
14294 --{
14295 IF v_SrcIntransitTab(i).organization_id = x_Group_rec.ship_from_org_id THEN
14296 --
14297 v_Key_rec.rlm_line_id := null;
14298 v_Key_rec.req_rec.customer_id := x_Group_rec.customer_id;
14299 v_Key_rec.req_rec.customer_item_id := x_Group_rec.customer_item_id;
14300 v_Key_rec.req_rec.inventory_item_id := x_Group_rec.inventory_item_id;
14301 v_Key_rec.req_rec.ship_to_org_id := x_Group_rec.ship_to_org_id;
14302 v_Key_rec.req_rec.order_header_id := x_Group_rec.order_header_id;
14303 v_Key_rec.req_rec.ship_from_org_id := v_SrcIntransitTab(i).organization_id;
14304 v_Key_rec.req_rec.shipment_flag := 'SHIPMENT';
14305 v_Key_rec.req_rec.schedule_type := x_Sched_rec.schedule_type;
14306 --
14307 -- Bugfix 7007638 Start
14308 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
14309 v_Key_rec.req_rec.cust_po_number := x_Cum_rec.purchase_order_number;
14310 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
14311 v_Key_rec.req_rec.industry_attribute1 := x_Cum_rec.cust_record_year;
14312 END IF;
14313 -- Bugfix 7007638 End
14314 RLM_RD_SV.StoreShipments(x_Sched_rec, x_Group_rec, v_Key_rec,
14315 v_SrcIntransitTab(i).intransit_qty);
14316 --
14317 END IF;
14318 --
14319 i := v_SrcIntransitTab.NEXT(i);
14320 --}
14321 END LOOP;
14322 --
14323 v_Progress := '030';
14324 --
14325 IF (l_debug <> -1) THEN
14326 rlm_core_sv.dpop(k_SDEBUG);
14327 END IF;
14328 --
14329 EXCEPTION
14330 --
14331 WHEN OTHERS THEN
14332 --
14333 rlm_message_sv.sql_error('RLM_RD_SV.SourceCUMIntransitQty',v_Progress);
14334 --
14335 IF (l_debug <> -1) THEN
14336 rlm_core_sv.dlog(k_DEBUG,'progress',v_Progress);
14337 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14338 END IF;
14339 --
14340 RAISE;
14341 --
14342 END SourceCUMIntransitQty;
14343
14344
14345
14346 PROCEDURE CalculateCUMIntransit(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
14347 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
14348 x_Line_id IN NUMBER, --Bugfix 7007638
14349 x_Intransit OUT NOCOPY NUMBER)
14350 IS
14351 --
14352 v_cum_key_record RLM_CUM_SV.cum_key_attrib_rec_type;
14353 v_cum_record RLM_CUM_SV.cum_rec_type;
14354 v_PrimaryQty NUMBER;
14355 v_CUMQty NUMBER;
14356 v_SupQty NUMBER;
14357 v_Intransit NUMBER;
14358 v_LineID NUMBER;
14359 v_Progress VARCHAR2(3);
14360 e_no_cum_key EXCEPTION;
14361 v_control_text VARCHAR2(100); --Bugfix 7007638
14362 v_control_value VARCHAR2(100); --Bugfix 7007638
14363 --
14364 BEGIN
14365 --
14366 IF (l_debug <> -1) THEN
14367 rlm_core_sv.dpush(k_SDEBUG, 'CalculateCUMIntransit');
14368 rlm_core_sv.dlog(k_DEBUG, 'x_Line_id', x_Line_id); --Bugfix 7007638
14369 END IF;
14370 --
14371 v_CUMQty := 0;
14372 v_SupQty := 0;
14373 v_Intransit := 0;
14374 v_Progress := '010';
14375 --
14376 SELECT x_group_rec.customer_id,
14377 customer_item_id,
14378 inventory_item_id,
14379 ship_from_org_id,
14380 intrmd_ship_to_id intrmd_ship_to_address_id,
14381 ship_to_address_id,
14382 bill_to_address_id,
14383 cust_po_number purchase_order_number,
14384 primary_quantity,
14385 item_detail_quantity,
14386 start_date_time,
14387 industry_attribute1 cust_record_year,
14388 line_id
14389 INTO v_cum_key_record.customer_id,
14390 v_cum_key_record.customer_item_id,
14391 v_cum_key_record.inventory_item_id,
14392 v_cum_key_record.ship_from_org_id,
14393 v_cum_key_record.intrmd_ship_to_address_id,
14394 v_cum_key_record.ship_to_address_id,
14395 v_cum_key_record.bill_to_address_id,
14396 v_cum_key_record.purchase_order_number,
14397 v_PrimaryQty,
14398 v_CUMQty,
14399 v_cum_key_record.cum_start_date,
14400 v_cum_key_record.cust_record_year,
14401 v_LineID
14402 FROM rlm_interface_lines
14403 WHERE header_id = x_Sched_rec.header_id
14404 AND item_detail_type = RLM_MANAGE_DEMAND_SV.k_SHIP_RECEIPT_INFO
14405 AND item_detail_subtype = RLM_MANAGE_DEMAND_SV.k_CUM
14406 AND ship_from_org_id = x_Group_rec.ship_from_org_id
14407 AND ship_to_address_id = x_Group_rec.ship_to_address_id
14408 AND inventory_item_id = x_Group_rec.inventory_item_id
14409 AND customer_item_id = x_Group_rec.customer_item_id
14410 AND line_id = x_Line_id --Bugfix 7007638
14411 ORDER BY start_date_time desc;
14412 --
14413 v_cum_key_record.create_cum_key_flag := 'N';
14414 RLM_TPA_SV.CalculateCUMKey(v_cum_key_record, v_cum_record);
14415 --
14416 v_Progress := '020';
14417 --
14418 IF v_cum_record.cum_key_id IS NULL THEN
14419 --Bugfix 7007638
14420 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
14421 rlm_message_sv.get_msg_text(
14422 x_message_name => 'RLM_CUM_CONTROL_PO',
14423 x_text => v_control_text);
14424 v_control_value := v_cum_key_record.purchase_order_number;
14425 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
14426 rlm_message_sv.get_msg_text(
14427 x_message_name => 'RLM_CUM_CONTROL_RY',
14428 x_text => v_control_text);
14429 v_control_value := v_cum_key_record.cust_record_year;
14430 ELSIF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_ONLY') THEN
14431 rlm_message_sv.get_msg_text(
14432 x_message_name => 'RLM_CUM_CONTROL_DATE',
14433 x_text => v_control_text);
14434 v_control_value := v_cum_key_record.cum_start_date;
14435 END IF;
14436 --Bugfix 7007638
14437 --
14438 RAISE e_No_Cum_Key;
14439 --
14440 ELSE
14441 --
14442 v_SupQty := NVL(v_cum_record.cum_qty,0) +
14443 NVL(v_cum_record.cum_qty_after_cutoff,0) +
14444 NVL(v_cum_record.cum_qty_to_be_accumulated,0);
14445 --
14446 END IF;
14447 --
14448 IF (l_debug <> -1) THEN
14449 rlm_core_sv.dlog(k_DEBUG, 'Supplier CUM Qty', v_SupQty);
14450 rlm_core_sv.dlog(k_DEBUG, 'Customer CUM Qty', v_CUMQty);
14451 END IF;
14452 --
14453 IF NVL(v_SupQty, 0) <> NVL(v_CUMQty, 0) THEN
14454 v_Intransit := v_SupQty - v_CUMQty;
14455 END IF;
14456 --
14457 x_Intransit := v_Intransit;
14458 v_Progress := '030';
14459 --
14460 IF (l_debug <> -1) THEN
14461 rlm_core_sv.dpop(k_SDEBUG);
14462 END IF;
14463 --
14464 EXCEPTION
14465 -- 4307505 [
14466 WHEN NO_DATA_FOUND THEN
14467 v_Intransit := 0;
14468 x_Intransit := 0;
14469 rlm_message_sv.app_error(
14470 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14471 x_MessageName => 'RLM_NO_CUM_INTRST_CUST_CUM',
14472 x_InterfaceHeaderId => x_sched_rec.header_id,
14473 x_InterfaceLineId => NULL,
14474 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14475 x_ScheduleLineId => NULL ,
14476 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14477 x_OrderLineId => NULL,
14478 x_Token1 => 'SHIP_TO',
14479 x_Value1 =>
14480 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14481 x_Token2 => 'CITEM',
14482 x_Value2 =>
14483 rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14484 x_GroupInfo => TRUE);
14485 --
14486 IF (l_debug <> -1) THEN
14487 rlm_core_sv.dlog(k_DEBUG,'- warning: RLM_CUM_STUP_NO_RECORD');
14488 rlm_core_sv.dlog(k_DEBUG,'- Intransit Qty = 0 considered to be 0 in this case');
14489 rlm_core_sv.dpop(k_SDEBUG);
14490 END IF;
14491 -- 4307505 ]
14492 WHEN e_no_cum_key THEN
14493 --
14494 rlm_message_sv.app_error(
14495 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14496 x_MessageName => 'RLM_CUM_KEY_MISSING',
14497 x_InterfaceHeaderId => x_sched_rec.header_id,
14498 x_InterfaceLineId => NULL,
14499 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14500 x_ScheduleLineId => NULL,
14501 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14502 x_OrderLineId => NULL,
14503 x_GroupInfo => TRUE,
14504 x_Token1 => 'GROUP', --Bugfix 7007638
14505 x_value1 => '-'||v_control_text||' '|| --Bugfix 7007638
14506 rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id)||'-'||
14507 rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id)||'-'||
14508 rlm_core_sv.get_item_number(x_group_rec.customer_item_id)||'-'||
14509 v_control_value);
14510 --
14511 IF (l_debug <> -1) THEN
14512 rlm_core_sv.dlog(k_DEBUG, 'No CUM Key Found - intransit qty no calc');
14513 rlm_core_sv.dpop(k_SDEBUG);
14514 END IF;
14515 --
14516 WHEN OTHERS THEN
14517 rlm_message_sv.sql_error('rlm_rd_sv.CalculateCUMIntransit',v_progress);
14518 --
14519 IF (l_debug <> -1) THEN
14520 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
14521 END IF;
14522 --
14523 raise;
14524 --
14525 END CalculateCUMIntransit;
14526
14527
14528 /*============================================================================
14529
14530 PROCEDURE NAME: AssignOEAttribValues
14531
14532 This procedure uses the information in p_OEDemand_rec structure to populate values
14533 for the dem_rec component of x_Key_rec. This is currently only called from
14534 procedure ProcessOld() and can eventually be used to eliminate calls to GetDemand().
14535
14536 ==============================================================================*/
14537 PROCEDURE AssignOEAttribValues(x_Key_rec IN OUT NOCOPY RLM_RD_SV.t_Key_rec,
14538 p_OEDemand_rec IN RLM_RD_SV.t_OEDemand_rec) IS
14539 BEGIN
14540 --
14541 IF (l_debug <> -1) THEN
14542 rlm_core_sv.dpush(k_SDEBUG, 'AssignOEAttribValues');
14543 END IF;
14544 --
14545 x_Key_rec.oe_line_id := p_OEDemand_rec.line_id;
14546 x_Key_rec.dem_rec.line_id := p_OEDemand_rec.line_id;
14547 x_Key_rec.dem_rec.request_date := p_OEDemand_rec.request_date;
14548 x_Key_rec.dem_rec.schedule_date := p_OEDemand_rec.schedule_ship_date;
14549 --
14550 x_Key_rec.dem_rec.ship_from_org_id := p_OEDemand_rec.ship_from_org_id;
14551 x_Key_rec.dem_rec.ship_to_org_id := p_OEDemand_rec.ship_to_org_id;
14552 x_Key_rec.dem_rec.invoice_to_org_id := p_OEDemand_rec.invoice_to_org_id;
14553 x_Key_rec.dem_rec.customer_item_id := p_OEDemand_rec.ordered_item_id;
14554 x_Key_rec.dem_rec.inventory_item_id := p_OEDemand_rec.inventory_item_id;
14555 x_Key_rec.dem_rec.order_header_id := p_OEDemand_rec.header_id;
14556 x_Key_rec.dem_rec.blanket_number := p_OEDemand_rec.blanket_number;
14557 x_Key_rec.dem_rec.customer_item_ext := p_OEDemand_rec.ordered_item;
14558 x_Key_rec.dem_rec.intmed_ship_to_org_id := p_OEDemand_rec.intmed_ship_to_org_id;
14559 --
14560 x_Key_rec.dem_rec.item_detail_type := p_OEDemand_rec.item_type_code;
14561 x_Key_rec.dem_rec.schedule_type := p_OEDemand_rec.rla_schedule_type_code;
14562 x_Key_rec.dem_rec.ordered_quantity := p_OEDemand_rec.orig_ordered_quantity;
14563 x_Key_rec.dem_rec.item_identifier_type := p_OEDemand_rec.item_identifier_type;
14564 x_Key_rec.dem_rec.item_detail_subtype := p_OEDemand_rec.demand_bucket_type_code;
14565 x_Key_rec.dem_rec.authorized_to_ship_flag := p_OEDemand_rec.authorized_to_ship_flag;
14566 --
14567 x_Key_rec.dem_rec.cust_po_line_num := p_OEDemand_rec.customer_line_number;
14568 x_Key_rec.dem_rec.customer_dock_code := p_OEDemand_rec.customer_dock_code;
14569 x_Key_rec.dem_rec.cust_po_number := p_OEDemand_rec.cust_po_number;
14570 x_Key_rec.dem_rec.customer_job := p_OEDemand_rec.customer_job;
14571 x_Key_rec.dem_rec.customer_item_revision := p_OEDemand_rec.customer_item_revision;
14572 x_Key_rec.dem_rec.cust_production_line := p_OEDemand_rec.cust_production_line;
14573 x_Key_rec.dem_rec.cust_production_seq_num := p_OEDemand_rec.cust_production_seq_num;
14574 x_Key_rec.dem_rec.cust_model_serial_number := p_OEDemand_rec.cust_model_serial_number;
14575 --
14576 x_Key_rec.dem_rec.industry_attribute1 := p_OEDemand_rec.industry_attribute1;
14577 x_Key_rec.dem_rec.industry_attribute2 := p_OEDemand_rec.industry_attribute2;
14578 x_Key_rec.dem_rec.industry_attribute3 := p_OEDemand_rec.industry_attribute3;
14579 x_Key_rec.dem_rec.industry_attribute4 := p_OEDemand_rec.industry_attribute4;
14580 x_Key_rec.dem_rec.industry_attribute5 := p_OEDemand_rec.industry_attribute5;
14581 x_Key_rec.dem_rec.industry_attribute6 := p_OEDemand_rec.industry_attribute6;
14582 x_Key_rec.dem_rec.industry_attribute7 := p_OEDemand_rec.industry_attribute7;
14583 x_Key_rec.dem_rec.industry_attribute8 := p_OEDemand_rec.industry_attribute8;
14584 x_Key_rec.dem_rec.industry_attribute9 := p_OEDemand_rec.industry_attribute9;
14585 x_Key_rec.dem_rec.industry_attribute10 := p_OEDemand_rec.industry_attribute10;
14586 x_Key_rec.dem_rec.industry_attribute11 := p_OEDemand_rec.industry_attribute11;
14587 x_Key_rec.dem_rec.industry_attribute12 := p_OEDemand_rec.industry_attribute12;
14588 x_Key_rec.dem_rec.industry_attribute13 := p_OEDemand_rec.industry_attribute13;
14589 x_Key_rec.dem_rec.industry_attribute14 := p_OEDemand_rec.industry_attribute14;
14590 x_Key_rec.dem_rec.industry_attribute15 := p_OEDemand_rec.industry_attribute15;
14591 --
14592 x_Key_rec.dem_rec.attribute1 := p_OEDemand_rec.attribute1;
14593 x_Key_rec.dem_rec.attribute2 := p_OEDemand_rec.attribute2;
14594 x_Key_rec.dem_rec.attribute3 := p_OEDemand_rec.attribute3;
14595 x_Key_rec.dem_rec.attribute4 := p_OEDemand_rec.attribute4;
14596 x_Key_rec.dem_rec.attribute5 := p_OEDemand_rec.attribute5;
14597 x_Key_rec.dem_rec.attribute6 := p_OEDemand_rec.attribute6;
14598 x_Key_rec.dem_rec.attribute7 := p_OEDemand_rec.attribute7;
14599 x_Key_rec.dem_rec.attribute8 := p_OEDemand_rec.attribute8;
14600 x_Key_rec.dem_rec.attribute9 := p_OEDemand_rec.attribute9;
14601 x_Key_rec.dem_rec.attribute10 := p_OEDemand_rec.attribute10;
14602 x_Key_rec.dem_rec.attribute11 := p_OEDemand_rec.attribute11;
14603 x_Key_rec.dem_rec.attribute12 := p_OEDemand_rec.attribute12;
14604 x_Key_rec.dem_rec.attribute13 := p_OEDemand_rec.attribute13;
14605 x_Key_rec.dem_rec.attribute14 := p_OEDemand_rec.attribute14;
14606 x_Key_rec.dem_rec.attribute15 := p_OEDemand_rec.attribute15;
14607 --
14608 IF (l_debug <> -1) THEN
14609 rlm_core_sv.dpop(k_SDEBUG);
14610 END IF;
14611 --
14612 EXCEPTION
14613 --
14614 WHEN OTHERS THEN
14615 --
14616 rlm_message_sv.sql_error('RLM_RD_SV.AssignOEAttribValues', '010');
14617 --
14618 IF (l_debug <> -1) THEN
14619 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
14620 rlm_core_sv.dpop(k_SDEBUG);
14621 END IF;
14622 --
14623 RAISE;
14624 --
14625 END AssignOEAttribValues;
14626
14627
14628 /*==============================================================================
14629 PROCEDURE NAME: FrozenFenceWarning
14630 Added this new procedure to give the overall frozen period warning for bug4223359
14631 ==============================================================================*/
14632
14633 PROCEDURE FrozenFenceWarning(x_sched_rec IN rlm_interface_headers%ROWTYPE,
14634 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec) IS
14635 --
14636 i NUMBER DEFAULT 0;
14637 v_index NUMBER DEFAULT 0;
14638 v_Count NUMBER DEFAULT 0;
14639 v_FrozenTab t_generic_Tab;
14640 x_frozenWarnQty NUMBER;
14641 v_frozenDays NUMBER;
14642 v_frozenFrom NUMBER;
14643 v_MatchAttrTxt VARCHAR2(2000);
14644 --
14645 BEGIN
14646 --{
14647 IF (l_debug > -1) THEN
14648 rlm_core_sv.dpush(k_SDEBUG, ' FrozenFenceWarning ');
14649 END IF;
14650 --
14651 IF x_Sched_rec.Schedule_type = 'PLANNING_RELEASE' THEN
14652 --
14653 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.pln_frozen_day_to,0) -
14654 nvl(x_Group_rec.setup_terms_rec.pln_frozen_day_from, 0) + 1;
14655 v_frozenFrom := x_group_rec.setup_terms_rec.pln_frozen_day_from;
14656 --
14657 ELSIF x_Sched_rec.Schedule_type = 'SHIPPING' THEN
14658 --
14659 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.shp_frozen_day_to,0) -
14660 nvl(x_Group_rec.setup_terms_rec.shp_frozen_day_from, 0) + 1;
14661 v_frozenFrom := x_group_rec.setup_terms_rec.shp_frozen_day_from;
14662 --
14663 ELSE
14664 --
14665 v_frozenDays := nvl(x_Group_rec.setup_terms_rec.seq_frozen_day_to,0) -
14666 nvl(x_Group_rec.setup_terms_rec.seq_frozen_day_from, 0) + 1;
14667 v_frozenFrom := x_group_rec.setup_terms_rec.seq_frozen_day_from;
14668 --
14669 END IF;
14670 --
14671 IF (l_debug > -1) THEN
14672 rlm_core_sv.dlog(k_DEBUG, 'g_isFirm', g_isFirm);
14673 rlm_core_sv.dlog(k_DEBUG, 'v_frozenDays', v_frozenDays);
14674 rlm_core_sv.dlog(k_DEBUG, 'x_Sched_rec.Schedule_Source', x_Sched_rec.Schedule_Source);
14675 END IF;
14676 --
14677 IF NOT g_isFirm AND x_Sched_rec.Schedule_Source <> 'MANUAL' AND v_frozenFrom is NOT NULL THEN
14678 --{
14679 g_isFirm := TRUE;
14680 --
14681 IF g_Reconcile_tab.COUNT <> 0 THEN
14682 --{
14683 v_Count := g_Reconcile_tab.FIRST;
14684 --
14685 WHILE v_Count is NOT NULL LOOP
14686 --{
14687 x_frozenWarnQty := g_Reconcile_tab(v_Count).ordered_quantity;
14688 --
14689 i := v_FrozenTab.count;
14690 --
14691 IF (l_debug <> -1) THEN
14692 rlm_core_sv.dlog(k_DEBUG, 'Begining of the loop Index i', i);
14693 rlm_core_sv.dlog(k_DEBUG, 'v_Count', v_Count);
14694 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenWarnQty', x_FrozenWarnQty);
14695 rlm_core_sv.dlog(k_DEBUG, 'request_date', g_Reconcile_tab(v_Count).request_date);
14696 rlm_core_sv.dlog(k_DEBUG, 'Customer request Date', g_Reconcile_tab(v_Count).industry_attribute2);
14697 END IF;
14698 --
14699 IF MatchFrozen(x_Group_rec, g_Reconcile_tab.NEXT(v_Count), g_Reconcile_tab(v_Count), v_Index) THEN
14700 --
14701 x_frozenWarnQty := x_frozenWarnQty + g_Reconcile_tab(v_Index).ordered_quantity;
14702 --
14703 IF (l_debug <> -1) THEN
14704 --
14705 rlm_core_sv.dlog(k_DEBUG, 'v_Index', v_Index);
14706 rlm_core_sv.dlog(k_DEBUG, 'ordered_quantity', g_Reconcile_tab(v_Index).ordered_quantity);
14707 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenWarnQty', x_FrozenWarnQty);
14708 --
14709 END IF;
14710 --
14711 END IF;
14712 --
14713 i := i + 1;
14714 v_FrozenTab(i) := g_Reconcile_tab(v_Count);
14715 v_FrozenTab(i).ordered_quantity := x_frozenWarnQty;
14716 --
14717 IF (l_debug <> -1) THEN
14718 rlm_core_sv.dlog(k_DEBUG, 'Ending of the loop Index i', i);
14719 END IF;
14720 --
14721 v_Count := g_Reconcile_tab.next(v_Count);
14722 --
14723 END LOOP;
14724 --}
14725 END IF;
14726 --}
14727 IF (l_debug <> -1) THEN
14728 rlm_core_sv.dlog(k_DEBUG, 'v_FrozenTab.COUNT', v_FrozenTab.COUNT);
14729 END IF;
14730 --
14731 IF v_FrozenTab.COUNT <> 0 THEN
14732 --{
14733 FOR v_Count IN v_frozenTab.FIRST..v_frozenTab.LAST LOOP
14734 --{
14735 GetMatchAttributes(x_sched_rec,x_group_rec, v_frozenTab(v_count), v_MatchAttrTxt);
14736 --
14737 IF v_MatchAttrTxt is NULL THEN
14738 --
14739 IF v_frozenTab(v_Count).ordered_quantity < 0 THEN
14740 --
14741 IF (l_debug <> -1) THEN
14742 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_WARN_UNDER:',
14743 v_frozenTab(v_Count).ordered_quantity);
14744 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14745 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14746 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14747 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14748 END IF;
14749 --
14750 rlm_message_sv.app_error(
14751 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14752 x_MessageName => 'RLM_FROZEN_OVERALL_WARN_UNDER',
14753 x_InterfaceHeaderId => x_sched_rec.header_id,
14754 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14755 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14756 x_OrderLineId => NULL,
14757 x_Token1 => 'ENDDATE',
14758 x_Value1 => TRUNC(rlm_dp_sv.g_dsp_start_time) + v_frozenDays - 1, --Bugfix 10053830
14759 x_Token2 => 'SHIP_FROM',
14760 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14761 x_Token3 => 'SHIP_TO',
14762 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14763 x_Token4 => 'CUSTITEM',
14764 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14765 x_Token5 => 'QUANTITY',
14766 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity));
14767 --
14768 ELSE
14769 --
14770 IF (l_debug <> -1) THEN
14771 --
14772 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_WARN_OVER:',
14773 v_frozenTab(v_Count).ordered_quantity);
14774 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14775 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14776 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14777 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14778 --
14779 END IF;
14780 --
14781 rlm_message_sv.app_error(
14782 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14783 x_MessageName => 'RLM_FROZEN_OVERALL_WARN_OVER',
14784 x_InterfaceHeaderId => x_sched_rec.header_id,
14785 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14786 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14787 x_OrderLineId => NULL,
14788 x_Token1 => 'ENDDATE',
14789 x_Value1 => TRUNC(rlm_dp_sv.g_dsp_start_time) + v_frozenDays - 1, --Bugfix 10053830
14790 x_Token2 => 'SHIP_FROM',
14791 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14792 x_Token3 => 'SHIP_TO',
14793 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14794 x_Token4 => 'CUSTITEM',
14795 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14796 x_Token5 => 'QUANTITY',
14797 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity));
14798 --
14799 END IF;
14800 --
14801 ELSE
14802 --
14803 IF v_frozenTab(v_Count).ordered_quantity < 0 THEN
14804 --
14805 IF (l_debug <> -1) THEN
14806 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_QTY_UNDER:',
14807 v_frozenTab(v_Count).ordered_quantity);
14808 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14809 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14810 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14811 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14812 END IF;
14813 --
14814 rlm_message_sv.app_error(
14815 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14816 x_MessageName => 'RLM_FROZEN_OVERALL_QTY_UNDER',
14817 x_InterfaceHeaderId => x_sched_rec.header_id,
14818 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14819 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14820 x_OrderLineId => NULL,
14821 x_Token1 => 'ENDDATE',
14822 x_Value1 => TRUNC(rlm_dp_sv.g_dsp_start_time) + v_frozenDays - 1, --Bugfix 10053830
14823 x_Token2 => 'SHIP_FROM',
14824 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14825 x_Token3 => 'SHIP_TO',
14826 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14827 x_Token4 => 'CUSTITEM',
14828 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14829 x_Token5 => 'QUANTITY',
14830 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity),
14831 x_Token6 => 'MATCH_ATTR',
14832 x_value6 => v_MatchAttrTxt);
14833 --
14834 ELSE
14835 --
14836 IF (l_debug <> -1) THEN
14837 --
14838 rlm_core_sv.dlog(k_DEBUG,'RLM_FROZEN_OVERALL_QTY_OVER:',
14839 v_frozenTab(v_Count).ordered_quantity);
14840 rlm_core_sv.dlog(k_DEBUG,'Ship from', x_group_rec.ship_from_org_id);
14841 rlm_core_sv.dlog(k_DEBUG,'Ship to', x_group_rec.ship_to_address_id );
14842 rlm_core_sv.dlog(k_DEBUG,'Customer Item Id', x_group_rec.customer_item_id);
14843 rlm_core_sv.dlog(k_DEBUG,'Matching Attributes', v_MatchAttrTxt);
14844 --
14845 END IF;
14846 --
14847 rlm_message_sv.app_error(
14848 x_ExceptionLevel => rlm_message_sv.k_warn_level,
14849 x_MessageName => 'RLM_FROZEN_OVERALL_QTY_OVER',
14850 x_InterfaceHeaderId => x_sched_rec.header_id,
14851 x_ScheduleHeaderId => x_sched_rec.schedule_header_id,
14852 x_OrderHeaderId => x_group_rec.setup_terms_rec.header_id,
14853 x_OrderLineId => NULL,
14854 x_Token1 => 'ENDDATE',
14855 x_Value1 => TRUNC(rlm_dp_sv.g_dsp_start_time) + v_frozenDays - 1, --Bugfix 10053830
14856 x_Token2 => 'SHIP_FROM',
14857 x_Value2 => rlm_core_sv.get_ship_from(x_group_rec.ship_from_org_id),
14858 x_Token3 => 'SHIP_TO',
14859 x_Value3 => rlm_core_sv.get_ship_to(x_group_rec.ship_to_address_id),
14860 x_Token4 => 'CUSTITEM',
14861 x_value4 => rlm_core_sv.get_item_number(x_group_rec.customer_item_id),
14862 x_Token5 => 'QUANTITY',
14863 x_value5 => abs(v_frozenTab(v_Count).ordered_quantity),
14864 x_Token6 => 'MATCH_ATTR',
14865 x_value6 => v_MatchAttrTxt);
14866 --
14867 END IF;
14868 --
14869 END IF ;
14870 --
14871 END LOOP;
14872 --}
14873 END IF;
14874 --}
14875 END IF;
14876 --}
14877 IF (l_debug <> -1) THEN
14878 rlm_core_sv.dpop(k_SDEBUG);
14879 END IF;
14880 --}
14881 EXCEPTION
14882 WHEN OTHERS THEN
14883 --
14884 rlm_message_sv.sql_error('RLM_RD_SV.FrozenFenceWarning', '010');
14885 --
14886 IF (l_debug <> -1) THEN
14887 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
14888 rlm_core_sv.dpop(k_SDEBUG);
14889 END IF;
14890 --
14891 --
14892 RAISE;
14893 --
14894 END FrozenFenceWarning;
14895
14896 /*==============================================================================
14897 PROCEDURE NAME: GetMatchAttributes
14898 Added this new procedure to get the matching attributes code value pair to display
14899 in the overall frozen fence message for bug 4223359.
14900 ==============================================================================*/
14901
14902 PROCEDURE GetMatchAttributes(x_sched_rec IN rlm_interface_headers%ROWTYPE,
14903 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec,
14904 x_frozenTabRec IN t_generic_rec,
14905 x_MatAttrCodeValue OUT NOCOPY VARCHAR2)
14906 IS
14907 --
14908 i NUMBER DEFAULT 0;
14909 v_lookupCode VARCHAR2(30);
14910 v_lookupMeaning VARCHAR2(80);
14911 v_ColumnName VARCHAR2(30);
14912 v_MatchCode VARCHAR2(2);
14913 v_MatchWithinRec rlm_core_sv.t_match_rec;
14914 -- v_MatchKey rlm_cust_shipto_terms.match_within_key%TYPE;
14915 v_first BOOLEAN := TRUE;
14916 --
14917 Cursor C(p_MatchCode in VARCHAR2,
14918 p_enabledFlag in VARCHAR2,
14919 p_lookupType in VARCHAR2)
14920 IS
14921 SELECT LOOKUP_CODE, MEANING
14922 FROM FND_LOOKUPS
14923 WHERE LOOKUP_TYPE = p_lookupType
14924 AND ENABLED_FLAG = p_enabledFlag
14925 AND SUBSTR(LOOKUP_CODE,INSTR(LOOKUP_CODE, ',') +1) = p_MatchCode;
14926 --
14927 Cursor c_flex_ind_attr(p_ColumnName IN VARCHAR2,
14928 p_descFlex IN VARCHAR2,
14929 p_enabledFlag IN VARCHAR2,
14930 p_appId IN NUMBER)
14931 IS
14932 SELECT FORM_ABOVE_PROMPT
14933 FROM FND_DESCR_FLEX_COL_USAGE_VL
14934 WHERE APPLICATION_ID = p_appId
14935 AND DESCRIPTIVE_FLEXFIELD_NAME = p_descFlex
14936 AND ENABLED_FLAG = p_enabledFlag
14937 AND APPLICATION_COLUMN_NAME = p_ColumnName;
14938 --
14939 Cursor c_flex_line_attr(p_ColumnName IN VARCHAR2,
14940 p_descFlex IN VARCHAR2,
14941 p_enabledFlag IN VARCHAR2,
14942 p_appId IN NUMBER)
14943 IS
14944 SELECT FORM_LEFT_PROMPT
14945 FROM FND_DESCR_FLEX_COL_USAGE_VL
14946 WHERE APPLICATION_ID = p_appId
14947 AND DESCRIPTIVE_FLEXFIELD_NAME = p_descFlex
14948 AND ENABLED_FLAG = p_enabledFlag
14949 AND APPLICATION_COLUMN_NAME = p_ColumnName;
14950 --
14951 BEGIN
14952 --
14953 IF (l_debug > -1) THEN
14954 rlm_core_sv.dpush(k_SDEBUG, 'GetMatchAttributes ');
14955 rlm_core_sv.dlog(k_DEBUG, 'match_within ', x_group_rec.match_within);
14956 END IF;
14957 --
14958 v_MatchCode := SUBSTR(x_Group_rec.match_within,1,1);
14959 i := 1;
14960 --
14961 WHILE v_MatchCode is NOT NULL LOOP
14962 --{
14963 IF (l_debug > -1) THEN
14964 rlm_core_sv.dlog(k_DEBUG, 'v_MatchCode ', v_MatchCode);
14965 END IF;
14966 --
14967 IF v_MatchCode <> 'C' AND v_MatchCode <> 'J' THEN
14968 --{
14969 OPEN c(v_matchCode, 'Y', 'RLM_OPTIONAL_MATCH_ATTRIBUTES');
14970 --{
14971 FETCH c INTO v_lookupCode, v_lookupMeaning;
14972 --
14973 v_ColumnName := SUBSTR(v_lookupCode, 1, INSTR(v_lookupCode, ',')-1);
14974 --
14975 IF (INSTR(v_ColumnName, 'INDUSTRY_ATTRIBUTE') = 1) THEN
14976 --
14977 OPEN c_flex_ind_attr(v_ColumnName, 'RLM_SCHEDULE_LINES', 'Y', 662);
14978 FETCH c_flex_ind_attr INTO v_lookupMeaning;
14979 CLOSE c_flex_ind_attr;
14980 --
14981 ELSIF(INSTR(v_ColumnName, 'ATTRIBUTE') = 1) THEN
14982 --
14983 OPEN c_flex_line_attr(v_ColumnName, 'OE_LINE_ATTRIBUTES', 'Y', 660);
14984 FETCH c_flex_line_attr INTO v_lookupMeaning;
14985 CLOSE c_flex_line_attr;
14986 --
14987 END IF;
14988 --
14989 IF v_first THEN
14990 --
14991 x_MatAttrCodeValue := v_lookupMeaning || '= ';
14992 --
14993 ELSE
14994 --
14995 x_MatAttrCodeValue := x_MatAttrCodeValue || ', ' || v_lookupMeaning || '= ';
14996 --
14997 END IF;
14998 --
14999 rlm_core_sv.populate_match_keys(v_MatchWithinRec, v_MatchCode);
15000 --
15001 IF v_MatchWithinRec.cust_po_number = 'Y' THEN
15002 --
15003 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_po_number;
15004 --
15005 ELSIF v_MatchWithinRec.customer_item_revision = 'Y' THEN
15006 --
15007 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_item_revision;
15008
15009 --
15010 ELSIF v_MatchWithinRec.customer_dock_code = 'Y' THEN
15011 --
15012 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_dock_code;
15013 --
15014 ELSIF v_MatchWithinRec.customer_job = 'Y' THEN
15015 --
15016 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.customer_job;
15017 --
15018 ELSIF v_MatchWithinRec.cust_production_line = 'Y' THEN
15019 --
15020 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_production_line;
15021 --
15022 ELSIF v_MatchWithinRec.cust_model_serial_number = 'Y' THEN
15023 --
15024 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_model_serial_number;
15025
15026 --
15027 ELSIF v_MatchWithinRec.cust_production_seq_num = 'Y' THEN
15028 --
15029 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.cust_production_seq_num;
15030
15031 --
15032 ELSIF v_MatchwithinRec.industry_attribute1 = 'Y' THEN
15033 --
15034 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute1;
15035 --
15036 ELSIF v_MatchwithinRec.industry_attribute4 = 'Y' THEN
15037 --
15038 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute4;
15039 --
15040 ELSIF v_MatchwithinRec.industry_attribute5 = 'Y' THEN
15041 --
15042 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute5;
15043 --
15044 IF (l_debug > -1) THEN
15045 rlm_core_sv.dlog(k_DEBUG, 'x_FrozenTabRec.industry_attribute5 ', x_FrozenTabRec.industry_attribute5);
15046 END IF;
15047 --
15048 ELSIF v_MatchwithinRec.industry_attribute6 = 'Y' THEN
15049 --
15050 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute6;
15051 --
15052 ELSIF v_MatchwithinRec.industry_attribute10 = 'Y' THEN
15053 --
15054 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute10;
15055 --
15056 ELSIF v_MatchwithinRec.industry_attribute11 = 'Y' THEN
15057 --
15058 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute11;
15059 --
15060 ELSIF v_MatchwithinRec.industry_attribute12 = 'Y' THEN
15061 --
15062 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute12;
15063 --
15064 ELSIF v_MatchwithinRec.industry_attribute13 = 'Y' THEN
15065 --
15066 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute13;
15067 --
15068 ELSIF v_MatchwithinRec.industry_attribute14 = 'Y' THEN
15069 --
15070 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute14;
15071 --
15072 -- ELSIF v_MatchwithinRec.industry_attribute15 = 'Y' THEN
15073 --
15074 -- x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.industry_attribute15;
15075
15076 --
15077 ELSIF v_MatchwithinRec.attribute1 = 'Y' THEN
15078 --
15079 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute1;
15080 --
15081 ELSIF v_MatchwithinRec.attribute2 = 'Y' THEN
15082 --
15083 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute2;
15084 --
15085 ELSIF v_MatchwithinRec.attribute3 = 'Y' THEN
15086 --
15087 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute3;
15088 --
15089 ELSIF v_MatchwithinRec.attribute4 = 'Y' THEN
15090 --
15091 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute4;
15092 --
15093 ELSIF v_MatchwithinRec.attribute5 = 'Y' THEN
15094 --
15095 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute5;
15096 --
15097 ELSIF v_MatchwithinRec.attribute6 = 'Y' THEN
15098 --
15099 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute6;
15100 --
15101 ELSIF v_MatchwithinRec.attribute7 = 'Y' THEN
15102 --
15103 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute7;
15104 --
15105 ELSIF v_MatchwithinRec.attribute8 = 'Y' THEN
15106 --
15107 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute8;
15108 --
15109 ELSIF v_MatchwithinRec.attribute9 = 'Y' THEN
15110 --
15111 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute9;
15112 --
15113 ELSIF v_MatchwithinRec.attribute10 = 'Y' THEN
15114 --
15115 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute10;
15116 --
15117 ELSIF v_MatchwithinRec.attribute11 = 'Y' THEN
15118 --
15119 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute11;
15120 --
15121 ELSIF v_MatchwithinRec.attribute12 = 'Y' THEN
15122 --
15123 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute12;
15124 --
15125 ELSIF v_MatchwithinRec.attribute13 = 'Y' THEN
15126 --
15127 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute13;
15128 --
15129 ELSIF v_MatchwithinRec.attribute14 = 'Y' THEN
15130 --
15131 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute14;
15132 --
15133 ELSIF v_MatchwithinRec.attribute15 = 'Y' THEN
15134 --
15135 x_MatAttrCodeValue := x_MatAttrCodeValue || x_FrozenTabRec.attribute15;
15136 --
15137 END IF;
15138 --
15139 IF (l_debug > -1) THEN
15140 rlm_core_sv.dlog(k_DEBUG, 'x_MatAttrCodeValue ', x_MatAttrCodeValue);
15141 END IF;
15142 --}
15143 CLOSE C;
15144 --
15145 v_first := FALSE;
15146 --}
15147 END IF;
15148 --
15149 i := i + 1;
15150 v_MatchCode := SUBSTR(x_Group_rec.match_within,i,1);
15151 --}
15152 END LOOP;
15153 --
15154 IF (l_debug <> -1) THEN
15155 rlm_core_sv.dpop(k_SDEBUG);
15156 END IF;
15157 --
15158 EXCEPTION
15159 WHEN OTHERS THEN
15160 --
15161 rlm_message_sv.sql_error('RLM_RD_SV.GetMatchAttributes', '010');
15162 --
15163 IF (l_debug <> -1) THEN
15164 rlm_core_sv.dlog(k_DEBUG, 'Unexpected error', SUBSTRB(SQLERRM, 1, 200));
15165 rlm_core_sv.dpop(k_SDEBUG);
15166 END IF;
15167 --
15168 RAISE;
15169 --
15170 END GetMatchAttributes;
15171 --}
15172
15173
15174 /*======================================================================
15175
15176 PROCEDURE NAME: ProcessReleases
15177
15178 DESCRIPTION: The following logic is used within this procedure
15179 (a) For a given SF/ST/CI, obtain the number of
15180 distinct releases tied to the demand lines.
15181 (b) For each such distinct release, call
15182 RecGroupDemand()
15183 (c) If any release was processed by DSP, set the output
15184 variable x_Processed to Y, so we do not call
15185 RecGroupDemand() again in procedure RecDemand().
15186
15187 =======================================================================*/
15188 PROCEDURE ProcessReleases(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
15189 x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
15190 x_Processed IN OUT NOCOPY VARCHAR2) IS
15191 --
15192 v_BlkGroup_ref t_Cursor_ref;
15193 v_BlkGroup_rec rlm_dp_sv.t_Group_rec;
15194 e_lines_locked EXCEPTION;
15195 v_sf_org_id NUMBER;
15196 v_rso_start_date DATE;
15197 --
15198 CURSOR c_getMaxRSO IS
15199 SELECT rso_hdr_id, effective_start_date
15200 FROM RLM_BLANKET_RSO
15201 WHERE blanket_number = v_BlkGroup_rec.setup_terms_rec.blanket_number
15202 AND customer_item_id =
15203 DECODE(v_BlkGroup_rec.setup_terms_rec.release_rule, 'PI',
15204 v_BlkGroup_rec.customer_item_id, k_NNULL)
15205 AND effective_start_date =
15206 (SELECT max(rlm.effective_start_date)
15207 FROM RLM_BLANKET_RSO rlm, OE_ORDER_HEADERS oe
15208 WHERE rlm.blanket_number = v_BlkGroup_rec.setup_terms_rec.blanket_number
15209 AND rlm.rso_hdr_id = oe.header_id
15210 AND rlm.customer_item_id =
15211 DECODE(v_BlkGroup_rec.setup_terms_rec.release_rule, 'PI',
15212 v_BlkGroup_rec.customer_item_id, K_NNULL)
15213 AND oe.open_flag = 'Y')
15214 ORDER BY rso_hdr_id DESC;
15215 --
15216 BEGIN
15217 --
15218 IF (l_debug <> -1) THEN
15219 rlm_core_sv.dpush(k_SDEBUG, 'ProcessReleases');
15220 END IF;
15221 x_Processed := 'N';
15222 --
15223 RLM_TPA_SV.InitializeBlktGrp(x_Sched_rec, v_BlkGroup_ref, x_Group_rec);
15224 --
15225 WHILE FetchBlktGrp(v_BlkGroup_ref, v_BlkGroup_rec) LOOP
15226 --{
15227 v_BlkGroup_rec.isSourced := x_Group_rec.isSourced;
15228 CallSetups(x_Sched_rec, v_BlkGroup_rec);
15229 --
15230 IF NOT LockLines(v_BlkGroup_rec, x_Sched_rec.header_id) THEN
15231 --
15232 IF (l_debug <> -1) THEN
15233 rlm_core_sv.dlog(k_DEBUG, 'RLM_LOCK_NOT_OBTAINED');
15234 END IF;
15235 --
15236 RAISE e_lines_locked;
15237 --
15238 END IF;
15239 --
15240 OPEN c_getMaxRSO;
15241 FETCH c_getMaxRSO INTO g_max_rso_hdr_id, v_rso_start_date;
15242 CLOSE c_getMaxRSO;
15243 --
15244 IF (l_debug <> -1) THEN
15245 rlm_core_sv.dlog(k_DEBUG, 'g_max_rso_hdr_id',g_max_rso_hdr_id);
15246 rlm_core_sv.dlog(k_DEBUG, 'v_rso_start_date',v_rso_start_date);
15247 END IF;
15248 --
15249 RecGroupDemand(x_Sched_rec, v_BlkGroup_rec);
15250 x_Processed := 'Y';
15251 --}
15252 END LOOP;
15253 --
15254 IF (l_debug <> -1) THEN
15255 rlm_core_sv.dpop(k_SDEBUG);
15256 END IF;
15257 --
15258 EXCEPTION
15259 --
15260 WHEN e_lines_locked THEN
15261 --
15262 IF (l_debug <> -1) THEN
15263 rlm_core_sv.dlog(k_DEBUG, 'e_lines_locked exception');
15264 rlm_core_sv.dpop(k_SDEBUG);
15265 END IF;
15266 --
15267 RAISE;
15268 --
15269 WHEN OTHERS THEN
15270 --
15271 IF (l_debug <> -1) THEN
15272 rlm_core_sv.dlog(k_DEBUG, 'SQLERRM', SUBSTRB(SQLERRM,1,200));
15273 rlm_core_sv.dpop(k_SDEBUG);
15274 END IF;
15275 --
15276 RAISE;
15277 --
15278 END ProcessReleases;
15279
15280 /*=========================================================================
15281
15282 PROCEDURE NAME: AssignMatchAttribValues
15283
15284 ===========================================================================*/
15285 -- Bug 4297984
15286 PROCEDURE AssignMatchAttribValues ( x_req_rec IN rlm_interface_lines_all%ROWTYPE,
15287 x_match_rec IN OUT NOCOPY RLM_RD_SV.t_generic_rec)
15288 IS
15289
15290 BEGIN
15291 --
15292 -- The x_match_rec populated here will be passed to RLM_RD_SV.GetMatchAttributes
15293 -- where we retrieve only the additional matching attribute columns. Hence only the
15294 -- additional matching attribute columns are populated here and the remaining fields
15295 -- defined in RLM_RD_SV.t_Generic_rec will be NULL. The function is needed
15296 -- as the RLM_RD_SV.GetMatchAttributes requires a RLM_RD_SV.t_Generic_rec argument type.
15297 --
15298 x_match_rec.cust_po_number := x_req_rec.cust_po_number ;
15299 x_match_rec.customer_item_revision := x_req_rec.customer_item_revision ;
15300 x_match_rec.customer_dock_code := x_req_rec.customer_dock_code ;
15301 x_match_rec.customer_job := x_req_rec.customer_job ;
15302 x_match_rec.cust_production_line := x_req_rec.cust_production_line ;
15303 x_match_rec.cust_model_serial_number := x_req_rec.cust_model_serial_number ;
15304 x_match_rec.cust_production_seq_num := x_req_rec.cust_production_seq_num ;
15305 x_match_rec.industry_attribute1 := x_req_rec.industry_attribute1 ;
15306 x_match_rec.industry_attribute2 := x_req_rec.industry_attribute2 ;
15307 x_match_rec.industry_attribute3 := x_req_rec.industry_attribute3 ;
15308 x_match_rec.industry_attribute4 := x_req_rec.industry_attribute4 ;
15309 x_match_rec.industry_attribute5 := x_req_rec.industry_attribute5 ;
15310 x_match_rec.industry_attribute6 := x_req_rec.industry_attribute6 ;
15311 x_match_rec.industry_attribute7 := x_req_rec.industry_attribute7 ;
15312 x_match_rec.industry_attribute8 := x_req_rec.industry_attribute8 ;
15313 x_match_rec.industry_attribute9 := x_req_rec.industry_attribute9 ;
15314 x_match_rec.industry_attribute10 := x_req_rec.industry_attribute10 ;
15315 x_match_rec.industry_attribute11 := x_req_rec.industry_attribute11 ;
15316 x_match_rec.industry_attribute12 := x_req_rec.industry_attribute12 ;
15317 x_match_rec.industry_attribute13 := x_req_rec.industry_attribute13 ;
15318 x_match_rec.industry_attribute14 := x_req_rec.industry_attribute14 ;
15319 x_match_rec.industry_attribute15 := x_req_rec.industry_attribute15 ;
15320 x_match_rec.attribute1 := x_req_rec.attribute1 ;
15321 x_match_rec.attribute2 := x_req_rec.attribute2 ;
15322 x_match_rec.attribute3 := x_req_rec.attribute3 ;
15323 x_match_rec.attribute4 := x_req_rec.attribute4 ;
15324 x_match_rec.attribute5 := x_req_rec.attribute5 ;
15325 x_match_rec.attribute6 := x_req_rec.attribute6 ;
15326 x_match_rec.attribute7 := x_req_rec.attribute7 ;
15327 x_match_rec.attribute8 := x_req_rec.attribute8 ;
15328 x_match_rec.attribute9 := x_req_rec.attribute9 ;
15329 x_match_rec.attribute10 := x_req_rec.attribute10 ;
15330 x_match_rec.attribute11 := x_req_rec.attribute11 ;
15331 x_match_rec.attribute12 := x_req_rec.attribute12 ;
15332 x_match_rec.attribute13 := x_req_rec.attribute13 ;
15333 x_match_rec.attribute14 := x_req_rec.attribute14 ;
15334 x_match_rec.attribute15 := x_req_rec.attribute15 ;
15335
15336 END AssignMatchAttribValues;
15337
15338 /*===========================================================================
15339
15340 PROCEDURE NAME: PopulateReconcileCumRec
15341
15342 ===========================================================================*/
15343 --Bugfix 7007638 Start
15344 PROCEDURE PopulateReconcileCumRec(x_Sched_rec IN RLM_INTERFACE_HEADERS%ROWTYPE,
15345 x_Group_rec IN OUT NOCOPY rlm_dp_sv.t_Group_rec)
15346 IS
15347
15348 CURSOR c_CUMRec IS
15349 SELECT x_group_rec.customer_id,
15350 customer_item_id,
15351 inventory_item_id,
15352 ship_from_org_id,
15353 intrmd_ship_to_id intrmd_ship_to_address_id,
15354 ship_to_address_id,
15355 bill_to_address_id,
15356 cust_po_number purchase_order_number,
15357 primary_quantity,
15358 item_detail_quantity,
15359 start_date_time,
15360 industry_attribute1 cust_record_year,
15361 line_id
15362 FROM rlm_interface_lines
15363 WHERE header_id = x_Sched_rec.header_id
15364 AND item_detail_type = RLM_MANAGE_DEMAND_SV.k_SHIP_RECEIPT_INFO
15365 AND item_detail_subtype = RLM_MANAGE_DEMAND_SV.k_CUM
15366 AND ship_from_org_id = x_Group_rec.ship_from_org_id
15367 AND ship_to_address_id = x_Group_rec.ship_to_address_id
15368 AND inventory_item_id = x_Group_rec.inventory_item_id
15369 AND customer_item_id = x_Group_rec.customer_item_id
15370 ORDER BY start_date_time desc;
15371 --
15372
15373 v_Progress VARCHAR2(3) := '010';
15374 v_Count NUMBER := 1;
15375
15376 BEGIN
15377 --
15378 IF (l_debug <> -1) THEN
15379 rlm_core_sv.dpush(k_SDEBUG,'PopulateReconcileCumRec');
15380 rlm_core_sv.dlog(k_DEBUG,'x_Sched_rec.Schedule_header_id',
15381 x_Sched_rec.Schedule_header_id);
15382 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.ship_to_address_id',
15383 x_Group_rec.ship_to_address_id);
15384 rlm_core_sv.dlog(k_DEBUG,'x_Group_rec.inventory_item_id',
15385 x_Group_rec.inventory_item_id);
15386 END IF;
15387 --
15388 g_RecCUM_tab.DELETE;
15389 --
15390 OPEN c_CUMRec;
15391 --
15392 LOOP
15393 FETCH c_CUMRec INTO g_RecCUM_rec;
15394 EXIT WHEN c_CUMRec%NOTFOUND;
15395
15396 g_RecCUM_tab(v_Count).customer_id := g_RecCUM_rec.customer_id;
15397 g_RecCUM_tab(v_Count).customer_item_id := g_RecCUM_rec.customer_item_id;
15398 g_RecCUM_tab(v_Count).inventory_item_id := g_RecCUM_rec.inventory_item_id;
15399 g_RecCUM_tab(v_Count).ship_from_org_id := g_RecCUM_rec.ship_from_org_id;
15400 g_RecCUM_tab(v_Count).intrmd_ship_to_address_id := g_RecCUM_rec.intrmd_ship_to_address_id;
15401 g_RecCUM_tab(v_Count).ship_to_address_id := g_RecCUM_rec.ship_to_address_id;
15402 g_RecCUM_tab(v_Count).bill_to_address_id := g_RecCUM_rec.bill_to_address_id;
15403 g_RecCUM_tab(v_Count).purchase_order_number := g_RecCUM_rec.purchase_order_number;
15404 g_RecCUM_tab(v_Count).primary_quantity := g_RecCUM_rec.primary_quantity;
15405 g_RecCUM_tab(v_Count).item_detail_quantity := g_RecCUM_rec.item_detail_quantity;
15406 g_RecCUM_tab(v_Count).start_date_time := g_RecCUM_rec.start_date_time;
15407 g_RecCUM_tab(v_Count).cust_record_year := g_RecCUM_rec.cust_record_year;
15408 g_RecCUM_tab(v_Count).line_id := g_RecCUM_rec.line_id;
15409
15410 IF (l_debug <> -1) THEN
15411 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').purchase_order_number', g_RecCUM_tab(v_Count).purchase_order_number);
15412 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').primary_quantity', g_RecCUM_tab(v_Count).primary_quantity);
15413 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').item_detail_quantity', g_RecCUM_tab(v_Count).item_detail_quantity);
15414 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').start_date_time', g_RecCUM_tab(v_Count).start_date_time);
15415 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').cust_record_year', g_RecCUM_tab(v_Count).cust_record_year);
15416 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab('||v_Count||').line_id', g_RecCUM_tab(v_Count).line_id);
15417 END IF;
15418
15419 v_Count := v_Count + 1;
15420
15421 END LOOP;
15422 --
15423 CLOSE c_CUMRec;
15424
15425 IF (l_debug <> -1) THEN
15426 rlm_core_sv.dlog(k_DEBUG,'g_RecCUM_tab.COUNT',g_RecCUM_tab.COUNT);
15427 rlm_core_sv.dpop(k_SDEBUG);
15428 END IF;
15429 --
15430 EXCEPTION
15431
15432 WHEN OTHERS THEN
15433 --
15434 rlm_message_sv.sql_error('rlm_rd_sv.PopulateReconcileCumRec',
15435 v_Progress);
15436 --
15437 IF (l_debug <> -1) THEN
15438 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
15439 END IF;
15440 --
15441 raise;
15442
15443 END PopulateReconcileCumRec;
15444
15445 /*===========================================================================
15446
15447 FUNCTION Match_PO_RY_Reconcile
15448
15449 ===========================================================================*/
15450 FUNCTION Match_PO_RY_Reconcile(x_Group_rec IN OUT NOCOPY RLM_DP_SV.t_Group_rec,
15451 x_Current_rec IN t_Generic_rec,
15452 x_Index OUT NOCOPY NUMBER)
15453 RETURN BOOLEAN
15454 IS
15455 x_progress VARCHAR2(3) := '010';
15456 v_Count NUMBER;
15457 v_Index NUMBER;
15458 b_Match BOOLEAN := FALSE;
15459 v_intransit_calc_basis VARCHAR2(30) ;
15460
15461 BEGIN
15462 --
15463 IF (l_debug <> -1) THEN
15464 rlm_core_sv.dpush(k_SDEBUG,'Match_PO_RY_Reconcile');
15465 rlm_core_sv.dlog(k_DEBUG, 'x_Current_rec.schedule_type',
15466 x_Current_rec.schedule_type);
15467 END IF;
15468 --
15469 IF (l_debug <> -1) THEN
15470 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.COUNT', g_Reconcile_tab.COUNT);
15471 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.FIRST', g_Reconcile_tab.FIRST);
15472 rlm_core_sv.dlog(k_DEBUG,'g_Reconcile_tab.LAST', g_Reconcile_tab.LAST);
15473 END IF;
15474
15475 IF g_Reconcile_tab.COUNT <> 0 THEN
15476 --{
15477 v_Count := g_Reconcile_tab.FIRST;
15478 --
15479 WHILE v_Count IS NOT NULL LOOP
15480 --{
15481 b_Match := TRUE;
15482 --
15483 IF (l_debug <> -1) THEN
15484 rlm_core_sv.dlog(k_DEBUG, 'g_Reconcile_Tab('||v_Count||').schedule_type',
15485 g_Reconcile_Tab(v_Count).schedule_type);
15486 END IF;
15487
15488 v_intransit_calc_basis := UPPER(x_Group_rec.setup_terms_rec.intransit_calc_basis);
15489 --
15490 IF (l_debug <> -1) THEN
15491 rlm_core_sv.dlog(k_DEBUG, 'Intransit calc basis ',x_Group_rec.setup_terms_rec.intransit_calc_basis);
15492 END IF;
15493 --
15494 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_PO','CUM_BY_PO_ONLY') THEN
15495 IF NVL(x_Current_rec.cust_po_number, k_VNULL) <>
15496 NVL(g_Reconcile_tab(v_Count).cust_po_number, k_VNULL) THEN
15497 b_Match := FALSE;
15498 END IF;
15499 END IF;
15500 --
15501 IF (l_debug <> -1) THEN
15502 rlm_core_sv.dlog(k_DEBUG, 'cust_po_number', x_Current_rec.cust_po_number);
15503 rlm_core_sv.dlog(k_DEBUG, 'rec cust_po_number', g_Reconcile_tab(v_Count).cust_po_number);
15504 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
15505 END IF;
15506 --
15507 IF b_Match THEN
15508 IF x_Group_rec.setup_terms_rec.cum_control_code IN ('CUM_BY_DATE_RECORD_YEAR') THEN
15509 IF NVL(x_Current_rec.industry_attribute1, k_VNULL) <>
15510 NVL(g_Reconcile_tab(v_Count).industry_attribute1, k_VNULL) THEN
15511 b_Match := FALSE;
15512 END IF;
15513 END IF;
15514 END IF;
15515 --
15516 IF (l_debug <> -1) THEN
15517 rlm_core_sv.dlog(k_DEBUG, 'industry_attribute1', x_Current_rec.industry_attribute1);
15518 rlm_core_sv.dlog(k_DEBUG, 'rec industry_attribute1', g_Reconcile_tab(v_Count).industry_attribute1);
15519 rlm_core_sv.dlog(k_DEBUG, 'b_Match', b_Match);
15520 END IF;
15521 --
15522 IF b_Match THEN
15523 --
15524 x_Index := v_Count;
15525 EXIT;
15526 --
15527 END IF;
15528 --
15529 v_Count := g_Reconcile_tab.NEXT(v_Count);
15530 --}
15531 END LOOP;
15532 --}
15533 END IF;
15534 --
15535 IF (l_debug <> -1) THEN
15536 rlm_core_sv.dlog(k_DEBUG,'b_match', b_Match);
15537 rlm_core_sv.dpop(k_SDEBUG);
15538 END IF;
15539 --
15540 RETURN(b_Match);
15541 --
15542 EXCEPTION
15543 WHEN OTHERS THEN
15544 rlm_message_sv.sql_error('rlm_rd_sv.Match_PO_RY_Reconcile',x_progress);
15545 --
15546 IF (l_debug <> -1) THEN
15547 rlm_core_sv.dpop(k_SDEBUG,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
15548 END IF;
15549 --
15550 raise;
15551
15552 END Match_PO_RY_Reconcile;
15553 --Bugfix 7007638 End
15554
15555 END RLM_RD_SV;