DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_MASS_CHANGE_PVT

Source


1 PACKAGE BODY OE_MASS_CHANGE_PVT AS
2 /* $Header: OEXVMSCB.pls 120.8.12010000.5 2008/11/15 10:58:25 sgoli ship $ */
3 
4 -- 4020312
5 g_sel_rec_tbl OE_GLOBALS.Selected_Record_Tbl;
6 
7 --bug4529937 start
8 G_BLK_NAME        VARCHAR2(30);
9 G_NUM_OF_LINES    NUMBER;
10 G_HEADER_CHANGED  NUMBER;      --- added for  bug 6850537,7210480
11 
12 Function Lines_Remaining Return Varchar2
13 IS
14 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15 BEGIN
16   IF l_debug_level > 0 THEN
17      oe_debug_pub.add('In function Lines_Remaining',1);
18      oe_debug_pub.add('G_BLK_NAME' || G_BLK_NAME);
19      oe_debug_pub.add('G_NUM_OF_LINES' || G_NUM_OF_LINES);
20   END IF;
21 
22    --Start  Bug 6850537 ,7210480
23 
24     IF G_BLK_NAME = 'LINES_SUMMARY' THEN
25           IF G_NUM_OF_LINES = 0 OR G_HEADER_CHANGED =1 THEN
26            IF l_debug_level>0    THEN
27              oe_debug_pub.ADD('NO more lines remains or header_id has changed');
28            END IF;
29           RETURN('N');
30         ELSE
31            IF l_debug_level >0  THEN
32              oe_debug_pub.ADD('There are some line remaining ');
33            END IF;
34           RETURN('Y');
35         END IF;
36     END IF;
37    --End  Bug 6850537,7210480
38 
39   IF G_BLK_NAME = 'LINE' THEN
40      IF G_NUM_OF_LINES = 0 THEN
41 	IF l_debug_level > 0 THEN
42 	   oe_debug_pub.add('No more lines remaining');
43 	END IF;
44         RETURN('N');
45      ELSE
46 	IF l_debug_level > 0 THEN
47 	   oe_debug_pub.add('There are some more lines remaining');
48 	END IF;
49         RETURN('Y');
50      END IF;
51   ELSE
52      RETURN('N');
53   END IF;
54 END Lines_Remaining;
55 --bug4529937 end
56 
57 --===================================================================
58 -- PROCEDURE: Process_Order_Scalar : Performs mass change of header attributes
59 -- by calling Oe_Order_Pvt.Header for every header in p_sel_rec_tbl.
60 --
61 --    Caller : OE_MASSUPDATE.UpdateOrderAttributes (OEXOELIB.pld)
62 -- PARAMETERS:
63 --  p_sel_rec_tbl - List of selected header records for mass change.
64 
65 --===================================================================
66 
67 Procedure Process_Order_Scalar
68 
69 (   p_num_of_records       		 IN NUMBER
70 ,   p_sel_rec_tbl                   IN Oe_Globals.Selected_Record_Tbl
71 ,   p_multi_OU                      IN Boolean
72 --,   p_record_ids            		 IN VARCHAR2
73 ,   p_change_reason                 IN VARCHAR2
74 ,   p_change_comments               IN VARCHAR2
75 , p_msg_count OUT NOCOPY NUMBER
76 , p_msg_data OUT NOCOPY VARCHAR2
77 , p_return_status OUT NOCOPY VARCHAR2
78 ,   p_mc_err_handling_flag  		 IN NUMBER DEFAULT  FND_API.G_MISS_NUM
79 , p_error_count OUT NOCOPY NUMBER
80 ,   p_accounting_rule_id            IN NUMBER
81 ,   p_accounting_rule_duration      IN NUMBER
82 ,   p_agreement_id                  IN NUMBER
83 ,   p_attribute1                    IN VARCHAR2
84 ,   p_attribute10                   IN VARCHAR2
85 ,   p_attribute11                   IN VARCHAR2
86 ,   p_attribute12                   IN VARCHAR2
87 ,   p_attribute13                   IN VARCHAR2
88 ,   p_attribute14                   IN VARCHAR2
89 ,   p_attribute15                   IN VARCHAR2
90 ,   p_attribute16                   IN VARCHAR2   --For bug 2184255
91 ,   p_attribute17                   IN VARCHAR2
92 ,   p_attribute18                   IN VARCHAR2
93 ,   p_attribute19                   IN VARCHAR2
94 ,   p_attribute2                    IN VARCHAR2
95 ,   p_attribute20                   IN VARCHAR2
96 ,   p_attribute3                    IN VARCHAR2
97 ,   p_attribute4                    IN VARCHAR2
98 ,   p_attribute5                    IN VARCHAR2
99 ,   p_attribute6                    IN VARCHAR2
100 ,   p_attribute7                    IN VARCHAR2
101 ,   p_attribute8                    IN VARCHAR2
102 ,   p_attribute9                    IN VARCHAR2
103 ,   p_blanket_number                IN NUMBER
104 ,   p_context                       IN VARCHAR2
105 ,   p_conversion_rate               IN NUMBER
106 ,   p_conversion_rate_date          IN DATE
107 ,   p_conversion_type_code          IN VARCHAR2
108 ,   p_cust_po_number                IN VARCHAR2
109 ,   p_deliver_to_contact_id         IN NUMBER
110 ,   p_deliver_to_org_id             IN NUMBER
111 ,   p_demand_class_code             IN VARCHAR2
112 ,   p_expiration_date               IN DATE
113 ,   p_earliest_schedule_limit       IN NUMBER
114 ,   p_fob_point_code                IN VARCHAR2
115 ,   p_freight_carrier_code          IN VARCHAR2
116 ,   p_freight_terms_code            IN VARCHAR2
117 ,   p_global_attribute1             IN VARCHAR2
118 ,   p_global_attribute10            IN VARCHAR2
119 ,   p_global_attribute11            IN VARCHAR2
120 ,   p_global_attribute12            IN VARCHAR2
121 ,   p_global_attribute13            IN VARCHAR2
122 ,   p_global_attribute14            IN VARCHAR2
123 ,   p_global_attribute15            IN VARCHAR2
124 ,   p_global_attribute16            IN VARCHAR2
125 ,   p_global_attribute17            IN VARCHAR2
126 ,   p_global_attribute18            IN VARCHAR2
127 ,   p_global_attribute19            IN VARCHAR2
128 ,   p_global_attribute2             IN VARCHAR2
129 ,   p_global_attribute20            IN VARCHAR2
130 ,   p_global_attribute3             IN VARCHAR2
131 ,   p_global_attribute4             IN VARCHAR2
132 ,   p_global_attribute5             IN VARCHAR2
133 ,   p_global_attribute6             IN VARCHAR2
134 ,   p_global_attribute7             IN VARCHAR2
135 ,   p_global_attribute8             IN VARCHAR2
136 ,   p_global_attribute9             IN VARCHAR2
137 ,   p_global_attribute_category     IN VARCHAR2
138 ,   p_header_id                     IN NUMBER
139 ,   p_invoice_to_contact_id         IN NUMBER
140 ,   p_invoice_to_org_id             IN NUMBER
141 ,   p_invoicing_rule_id             IN NUMBER
142 ,   p_latest_schedule_limit         IN NUMBER
143 ,   p_ordered_date                  IN DATE
144 ,   p_order_date_type_code          IN VARCHAR2
145 ,   p_order_number                  IN NUMBER
146 ,   p_order_source_id               IN NUMBER
147 ,   p_order_type_id                 IN NUMBER
148 ,   p_org_id                        IN NUMBER
149 ,   p_orig_sys_document_ref         IN VARCHAR2
150 ,   p_partial_shipments_allowed     IN VARCHAR2
151 ,   p_payment_term_id               IN NUMBER
152 ,   p_price_list_id                 IN NUMBER
153 ,   p_pricing_date                  IN DATE
154 ,   p_request_date                  IN DATE
155 ,   p_shipment_priority_code        IN VARCHAR2
156 ,   p_shipping_method_code          IN VARCHAR2
157 ,   p_ship_from_org_id              IN NUMBER
158 ,   p_ship_tolerance_above          IN NUMBER
159 ,   p_ship_tolerance_below          IN NUMBER
160 ,   p_ship_to_contact_id            IN NUMBER
161 ,   p_ship_to_org_id                IN NUMBER
162 ,   p_sold_to_contact_id            IN NUMBER
163 ,   p_sold_to_org_id                IN NUMBER
164 ,   p_source_document_id            IN NUMBER
165 ,   p_source_document_type_id       IN NUMBER
166 ,   p_tax_exempt_flag               IN VARCHAR2
167 ,   p_tax_exempt_number             IN VARCHAR2
168 ,   p_tax_exempt_reason_code        IN VARCHAR2
169 ,   p_tax_point_code                IN VARCHAR2
170 ,   p_transactional_curr_code       IN VARCHAR2
171 ,   p_version_number                IN NUMBER
172 ,   p_accounting_rule               IN VARCHAR2
173 ,   p_agreement                     IN VARCHAR2
174 ,   p_conversion_type               IN VARCHAR2
175 ,   p_deliver_to_address1           IN VARCHAR2
176 ,   p_deliver_to_address2           IN VARCHAR2
177 ,   p_deliver_to_address3           IN VARCHAR2
178 ,   p_deliver_to_address4           IN VARCHAR2
179 ,   p_deliver_to_contact            IN VARCHAR2
180 ,   p_deliver_to_location           IN VARCHAR2
181 ,   p_deliver_to_org                IN VARCHAR2
182 ,   p_fob_point                     IN VARCHAR2
183 ,   p_freight_terms                 IN VARCHAR2
184 ,   p_invoice_to_address1           IN VARCHAR2
185 ,   p_invoice_to_address2           IN VARCHAR2
186 ,   p_invoice_to_address3           IN VARCHAR2
187 ,   p_invoice_to_address4           IN VARCHAR2
188 ,   p_invoice_to_contact            IN VARCHAR2
189 ,   p_invoice_to_location           IN VARCHAR2
190 ,   p_invoice_to_org                IN VARCHAR2
191 ,   p_invoicing_rule                IN VARCHAR2
192 ,   p_order_source                  IN VARCHAR2
193 ,   p_order_type                    IN VARCHAR2
194 ,   p_payment_term                  IN VARCHAR2
195 ,   p_price_list                    IN VARCHAR2
196 ,   p_shipment_priority             IN VARCHAR2
197 ,   p_ship_from_address1            IN VARCHAR2
198 ,   p_ship_from_address2            IN VARCHAR2
199 ,   p_ship_from_address3            IN VARCHAR2
200 ,   p_ship_from_address4            IN VARCHAR2
201 ,   p_ship_from_location            IN VARCHAR2
202 ,   p_ship_from_org                 IN VARCHAR2
203 ,   p_ship_to_address1              IN VARCHAR2
204 ,   p_ship_to_address2              IN VARCHAR2
205 ,   p_ship_to_address3              IN VARCHAR2
206 ,   p_ship_to_address4              IN VARCHAR2
207 ,   p_ship_to_contact               IN VARCHAR2
208 ,   p_ship_to_location              IN VARCHAR2
209 ,   p_ship_to_org                   IN VARCHAR2
210 ,   p_sold_to_contact               IN VARCHAR2
211 ,   p_sold_to_org                   IN VARCHAR2
212 ,   p_tax_exempt                    IN VARCHAR2
213 ,   p_tax_exempt_reason             IN VARCHAR2
214 ,   p_tax_point                     IN VARCHAR2
215 ,   p_salesrep_id                   IN NUMBER
216 ,   p_return_reason_code            IN VARCHAR2
217 ,   p_salesrep                      IN VARCHAR2
218 ,   p_return_reason                 IN VARCHAR2
219 ,   p_payment_type_code             IN VARCHAR2
220 ,   p_payment_amount                IN NUMBER
221 ,   p_check_number                  IN VARCHAR2
222 ,   p_credit_card_code              IN VARCHAR2
223 ,   p_credit_card_holder_name       IN VARCHAR2
224 ,   p_credit_card_number            IN VARCHAR2
225 ,   p_instrument_security_code      IN VARCHAR2  --bug 5191301
226 ,   p_credit_card_expiration_date   IN DATE
227 ,   p_credit_card_approval_date     IN DATE
228 ,   p_credit_card_approval_code     IN VARCHAR2
229 ,   p_payment_type                  IN VARCHAR2
230 ,   p_credit_card                   IN VARCHAR2
231 ,   p_first_ack_code                IN VARCHAR2
232 ,   p_first_ack_date                IN DATE
233 ,   p_last_ack_code                 IN VARCHAR2
234 ,   p_last_ack_date                 IN DATE
235 ,   p_tp_attribute1                    IN VARCHAR2
236 ,   p_tp_attribute10                   IN VARCHAR2
237 ,   p_tp_attribute11                   IN VARCHAR2
238 ,   p_tp_attribute12                   IN VARCHAR2
239 ,   p_tp_attribute13                   IN VARCHAR2
240 ,   p_tp_attribute14                   IN VARCHAR2
241 ,   p_tp_attribute15                   IN VARCHAR2
242 ,   p_tp_attribute2                    IN VARCHAR2
243 ,   p_tp_attribute3                    IN VARCHAR2
244 ,   p_tp_attribute4                    IN VARCHAR2
245 ,   p_tp_attribute5                    IN VARCHAR2
246 ,   p_tp_attribute6                    IN VARCHAR2
247 ,   p_tp_attribute7                    IN VARCHAR2
248 ,   p_tp_attribute8                    IN VARCHAR2
249 ,   p_tp_attribute9                    IN VARCHAR2
250 ,   p_tp_context                       IN VARCHAR2
251 ,   p_shipping_instructions            IN VARCHAR2
252 ,   p_packing_instructions             IN VARCHAR2
253 ,   p_sales_channel_code               IN VARCHAR2
254 --My Addition
255 ,   p_sold_to_address1                 IN VARCHAR2
256 ,   p_sold_to_address2                 IN VARCHAR2
257 ,   p_sold_to_address3                 IN VARCHAR2
258 ,   p_sold_to_address4                 IN VARCHAR2
259 ,   p_sold_to_location                 IN VARCHAR2
260 ,   p_sold_to_site_use_id              IN NUMBER
261 --end custoemr chagnes
262 ,   p_end_customer_contact_id          IN NUMBER
263 ,   p_end_customer_id                  IN NUMBER
264 ,   p_end_customer_site_use_id         IN NUMBER
265 ,   p_end_customer_address1            IN VARCHAR2
266 ,   p_end_customer_address2            IN VARCHAR2
267 ,   p_end_customer_address3            IN VARCHAR2
268 ,   p_end_customer_address4            IN VARCHAR2
269 ,   p_end_customer_contact             IN VARCHAR2
270 ,   p_end_customer_location            IN VARCHAR2
271 ,   p_ib_owner                         IN VARCHAR2
272 ,   p_ib_installed_at_location         IN VARCHAR2
273 ,   p_ib_current_location              IN VARCHAR2
274 ,   p_cascade_header_changes           IN VARCHAR2 -- Added for Cascade Header changes in Mass Change  ER 7509356
275 
276 
277 ) IS
278 l_header_rec                OE_Order_PUB.Header_Rec_Type;
279 l_old_header_rec            OE_Order_PUB.Header_Rec_Type;
280 l_control_rec               OE_GLOBALS.Control_Rec_Type;
281 l_x_header_rec              OE_Order_PUB.Header_Rec_Type;
282 l_mc_err_handling_flag      NUMBER  := p_mc_err_handling_flag ;
283 l_init_msg_list             VARCHAR2(1) := 'F';
284 l_return_status             VARCHAR2(30);
285 l_api_name         CONSTANT VARCHAR2(30)         := 'Process_Order_Scalar';
286 l_line_id         Number;
287 l_header_id         Number;
288 l_sold_to_org_id NUMBER := p_sold_to_org_id;
289 l_ship_to_org_id NUMBER := p_ship_to_org_id;
290 l_error_count   NUMBER :=0;
291 l_line_tbl oe_order_pub.line_tbl_type;
292 
293 j Integer;
294 initial Integer;
295 nextpos Integer;
296 l_current_org_id    Number;
297 begin
298 /*j := 1;
299 initial := 1;
300 nextpos := INSTR(p_record_ids,',',1,j) ;
301 */
302 OE_MSG_PUB.initialize;
303 --MOAC PI
304  IS_MASS_CHANGE := 'T'; -- Added for cascading header changes ER 7509356
305 FOR i IN p_sel_rec_tbl.first..p_sel_rec_tbl.last LOOP
306 --{
307  BEGIN
308      l_header_id := p_sel_rec_tbl(i).id1;
309      If p_multi_OU Then
310         If l_Current_org_id Is Null or l_current_org_id<> p_sel_rec_tbl(i).org_id THEN
311            MO_GLOBAL.SET_POLICY_CONTEXT('S',p_sel_rec_tbl(i).org_id);
312 	   OE_Order_Cache.Clear_Price_List(); --Added to clear price-list cache when there is org change (Bug # 5168409)
313            L_current_org_id:= p_sel_rec_tbl(i).org_id;
314         End If;
315      Else
316         If i = 1 Then
317            MO_GLOBAL.SET_POLICY_CONTEXT('S',p_sel_rec_tbl(i).org_id);
318         End If;
319      End If;
320     --MOAC PI
321    G_COUNTER:=G_COUNTER+1;
322  --dbms_output.put_line('ini='||to_char(initial)||'next='||to_char(nextpos));
323    l_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
324    l_old_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
325  --  l_header_id := to_number(substr(p_record_ids,initial, nextpos-initial));
326    --dbms_output.put_line('id='||to_char(l_header_id));
327 --   initial := nextpos + 1;
328  /*  j := j + 1;
329    nextpos := INSTR(p_record_ids,',',1,j);
330  */
331    l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
332    l_header_rec.header_id := l_header_id;
333 --   l_old_header_rec.header_id := l_header_id;
334 
335    SAVEPOINT Process_Order_Scalar;
336    OE_Header_Util.Lock_Row
337     (   x_return_status        => l_return_status
338     ,   p_x_header_rec         => l_x_header_rec
339     ,   p_header_id            => l_header_id);
340 
341      IF l_return_status  = FND_API.G_RET_STS_UNEXP_ERROR THEN
342         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
343     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
344         RAISE FND_API.G_EXC_ERROR;
345     END IF;
346 
347 
348 
349 
350    if p_accounting_rule_id is not null then
351      l_header_rec.accounting_rule_id:=p_accounting_rule_id;
352    end if;
353 
354    if p_accounting_rule_duration is not null then
355      l_header_rec.accounting_rule_duration:=p_accounting_rule_duration;
356    end if;
357 
358    if p_agreement_id is not null then
359      l_header_rec.agreement_id:=p_agreement_id;
360    end if;
361 
362    if p_attribute1 is not null then
363      l_header_rec.attribute1:=p_attribute1;
364    end if;
365 
366    if p_attribute10 is not null then
367      l_header_rec.attribute10:=p_attribute10;
368    end if;
369 
370    if p_attribute11 is not null then
371      l_header_rec.attribute11:=p_attribute11;
372    end if;
373 
374    if p_attribute12 is not null then
375      l_header_rec.attribute12:=p_attribute12;
376    end if;
377 
378    if p_attribute13 is not null then
379      l_header_rec.attribute13:=p_attribute13;
380    end if;
381 
382    if p_attribute14 is not null then
383      l_header_rec.attribute14:=p_attribute14;
384    end if;
385 
386    if p_attribute15 is not null then
387      l_header_rec.attribute15:=p_attribute15;
388    end if;
389 
390 -- for bug 2184255
391    if p_attribute16 is not null then
392      l_header_rec.attribute16:=p_attribute16;
393    end if;
394 
395    if p_attribute17 is not null then
396      l_header_rec.attribute17:=p_attribute17;
397    end if;
398 
399    if p_attribute18 is not null then
400      l_header_rec.attribute18:=p_attribute18;
401    end if;
402 
403    if p_attribute19 is not null then
404      l_header_rec.attribute19:=p_attribute19;
405    end if;
406 
407    if p_attribute2 is not null then
408      l_header_rec.attribute2:=p_attribute2;
409    end if;
410 
411    if p_attribute20 is not null then
412      l_header_rec.attribute20:=p_attribute20;
413    end if;
414 
415    if p_attribute3 is not null then
416      l_header_rec.attribute3:=p_attribute3;
417    end if;
418 
419    if p_attribute4 is not null then
420      l_header_rec.attribute4:=p_attribute4;
421    end if;
422 
423    if p_attribute5 is not null then
424      l_header_rec.attribute5:=p_attribute5;
425    end if;
426 
427    if p_attribute6 is not null then
428      l_header_rec.attribute6:=p_attribute6;
429    end if;
430 
431    if p_attribute7 is not null then
432      l_header_rec.attribute7:=p_attribute7;
433    end if;
434 
435    if p_attribute8 is not null then
436      l_header_rec.attribute8:=p_attribute8;
437    end if;
438 
439    if p_attribute9 is not null then
440      l_header_rec.attribute9:=p_attribute9;
441    end if;
442 
443    IF p_blanket_number is not null THEN
444      l_header_rec.blanket_number:=p_blanket_number;
445    END IF;
446 
447    if p_context is not null then
448      l_header_rec.context:=p_context;
449    end if;
450 
451    if p_conversion_rate_date is not null then
452      l_header_rec.conversion_rate_date:=p_conversion_rate_date;
453    end if;
454 
455    if p_conversion_rate is not null then
456      l_header_rec.conversion_rate:=p_conversion_rate;
457    end if;
458 
459    if p_conversion_type_code is not null then
460      l_header_rec.conversion_type_code:=p_conversion_type_code;
461    end if;
462 
463    if p_sales_Channel_Code is not null then
464      l_header_rec.sales_channel_code:=p_sales_channel_code;
465    end if;
466 
467    if p_shipping_instructions is not null then
468      l_header_rec.shipping_instructions:=p_shipping_instructions;
469    end if;
470 
471    if p_packing_instructions is not null then
472      l_header_rec.packing_instructions:=p_packing_instructions;
473    end if;
474 
475    if p_cust_po_number is not null then
476      l_header_rec.cust_po_number:=p_cust_po_number;
477    end if;
478 
479    if p_deliver_to_contact_id is not null then
480      l_header_rec.deliver_to_contact_id:=p_deliver_to_contact_id;
481    end if;
482 
483    if p_deliver_to_org_id is not null then
484      l_header_rec.deliver_to_org_id:=p_deliver_to_org_id;
485    end if;
486 
487    if p_demand_class_code is not null then
488      l_header_rec.demand_class_code:=p_demand_class_code;
489    end if;
490 
491    if p_expiration_date is not null then
492      l_header_rec.expiration_date:=p_expiration_date;
493    end if;
494 
495    if p_earliest_schedule_limit is not null then
496      l_header_rec.earliest_schedule_limit:=p_earliest_schedule_limit;
497    end if;
498 
499    if p_fob_point_code is not null then
500      l_header_rec.fob_point_code:=p_fob_point_code;
501    end if;
502 
503    if p_freight_carrier_code is not null then
504      l_header_rec.freight_carrier_code:=p_freight_carrier_code;
505    end if;
506 
507    if p_freight_terms_code is not null then
508      l_header_rec.freight_terms_code:=p_freight_terms_code;
509    end if;
510 
511    if p_global_attribute1 is not null then
512      l_header_rec.global_attribute1:=p_global_attribute1;
513    end if;
514 
515    if p_global_attribute10 is not null then
516      l_header_rec.global_attribute10:=p_global_attribute10;
517    end if;
518 
519    if p_global_attribute11 is not null then
520      l_header_rec.global_attribute11:=p_global_attribute11;
521    end if;
522 
523 
524    if p_global_attribute12 is not null then
525      l_header_rec.global_attribute12:=p_global_attribute12;
526    end if;
527 
528    if p_global_attribute13 is not null then
529      l_header_rec.global_attribute13:=p_global_attribute13;
530    end if;
531 
532    if p_global_attribute14 is not null then
533      l_header_rec.global_attribute14:=p_global_attribute14;
534    end if;
535 
536    if p_global_attribute15 is not null then
537      l_header_rec.global_attribute15:=p_global_attribute15;
538    end if;
539 
540    if p_global_attribute16 is not null then
541      l_header_rec.global_attribute16:=p_global_attribute16;
542    end if;
543 
544    if p_global_attribute17 is not null then
545      l_header_rec.global_attribute17:=p_global_attribute17;
546    end if;
547 
548    if p_global_attribute18 is not null then
549      l_header_rec.global_attribute18:=p_global_attribute18;
550    end if;
551 
552    if p_global_attribute19 is not null then
553      l_header_rec.global_attribute19:=p_global_attribute19;
554    end if;
555 
556    if p_global_attribute20 is not null then
557      l_header_rec.global_attribute20:=p_global_attribute20;
558    end if;
559 
560    if p_global_attribute2 is not null then
561      l_header_rec.global_attribute2:=p_global_attribute2;
562    end if;
563 
564    if p_global_attribute3 is not null then
565      l_header_rec.global_attribute3:=p_global_attribute3;
566    end if;
567 
568    if p_global_attribute4 is not null then
569      l_header_rec.global_attribute4:=p_global_attribute4;
570    end if;
571 
572    if p_global_attribute5 is not null then
573      l_header_rec.global_attribute5:=p_global_attribute5;
574    end if;
575 
576    if p_global_attribute6 is not null then
577      l_header_rec.global_attribute6:=p_global_attribute6;
578    end if;
579 
580    if p_global_attribute7 is not null then
581      l_header_rec.global_attribute7:=p_global_attribute7;
582    end if;
583 
584    if p_global_attribute8 is not null then
585      l_header_rec.global_attribute8:=p_global_attribute8;
586    end if;
587 
588    if p_global_attribute9 is not null then
589      l_header_rec.global_attribute9:=p_global_attribute9;
590    end if;
591 
592    if p_global_attribute_category is not null then
593      l_header_rec.global_attribute_category:=p_global_attribute_category;
594    end if;
595 
596    if p_header_id is not null then
597      l_header_rec.header_id:=p_header_id;
598    end if;
599 
600    if p_invoice_to_contact_id  is not null then
601      l_header_rec.invoice_to_contact_id :=p_invoice_to_contact_id ;
602    end if;
603 
604    if p_invoice_to_org_id is not null then
605      l_header_rec.invoice_to_org_id:=p_invoice_to_org_id;
606    end if;
607 
608    if p_invoicing_rule_id is not null then
609 	l_header_rec.invoicing_rule_id:=p_invoicing_rule_id;
610    end if;
611 
612    if p_latest_schedule_limit  is not null then
613      l_header_rec.latest_schedule_limit:=p_latest_schedule_limit;
614    end if;
615 
616    if p_ordered_date is not null then
617      l_header_rec.ordered_date:=p_ordered_date;
618    end if;
619 
620    if p_order_date_type_code is not null then
621 	l_header_rec.order_date_type_code:=p_order_date_type_code;
622    end if;
623 
624    if p_order_number is not null then
625 	l_header_rec.order_number:=p_order_number;
626    end if;
627 
628    if p_order_source_id  is not null then
629      l_header_rec.order_source_id:=p_order_source_id;
630    end if;
631 
632    if p_order_type_id is not null then
633      l_header_rec.order_type_id:=p_order_type_id;
634    end if;
635 
636    if  p_org_id is not null then
637 	l_header_rec.org_id:= p_org_id ;
638    end if;
639 
640    if p_orig_sys_document_ref is not null then
641 	l_header_rec.orig_sys_document_ref:=p_orig_sys_document_ref;
642    end if;
643 
644    if p_partial_shipments_allowed  is not null then
645      l_header_rec.partial_shipments_allowed:=p_partial_shipments_allowed;
646    end if;
647 
648    if p_payment_term_id is not null then
649      l_header_rec.payment_term_id:=p_payment_term_id;
650    end if;
651 
652    if  p_price_list_id is not null then
653 	l_header_rec.price_list_id:=p_price_list_id;
654    end if;
655 
656    if p_pricing_date  is not null then
657      l_header_rec.pricing_date:=p_pricing_date;
658    end if;
659 
660    if p_request_date is not null then
661      l_header_rec.request_date:=p_request_date;
662    end if;
663 
664    if  p_shipment_priority_code is not null then
665 	l_header_rec.shipment_priority_code:=p_shipment_priority_code;
666    end if;
667 
668    if p_shipping_method_code  is not null then
669      l_header_rec.shipping_method_code:=p_shipping_method_code;
670    end if;
671 
672    if p_ship_from_org_id is not null then
673      l_header_rec.ship_from_org_id:=p_ship_from_org_id;
674    end if;
675 
676    if   p_ship_tolerance_above is not null then
677 	l_header_rec.ship_tolerance_above:= p_ship_tolerance_above;
678    end if;
679 
680    if   p_ship_tolerance_below is not null then
681 	l_header_rec.ship_tolerance_below:= p_ship_tolerance_below;
682    end if;
683 
684    if p_ship_to_contact_id   is not null then
685      l_header_rec.ship_to_contact_id :=p_ship_to_contact_id ;
686    end if;
687 
688    if p_ship_to_org_id is not null then
689      l_header_rec.ship_to_org_id:=p_ship_to_org_id;
690    end if;
691 
692    if   p_sold_to_contact_id is not null then
693 	l_header_rec.sold_to_contact_id:=p_sold_to_contact_id;
694    end if;
695 
696    if   p_sold_to_org_id  is not null then
697 	l_header_rec.sold_to_org_id :=p_sold_to_org_id;
698    end if;
699 
700    if p_source_document_id   is not null then
701      l_header_rec.source_document_id:=p_source_document_id;
702    end if;
703 
704    if p_source_document_type_id is not null then
705      l_header_rec.source_document_type_id:=p_source_document_type_id;
706    end if;
707 
708    if   p_tax_exempt_flag is not null then
709 	l_header_rec.tax_exempt_flag:=p_tax_exempt_flag;
710    end if;
711 
712    if   p_tax_exempt_number  is not null then
713 	l_header_rec.tax_exempt_number:=p_tax_exempt_number;
714    end if;
715 
716    if p_tax_exempt_reason_code   is not null then
717      l_header_rec.tax_exempt_reason_code:=p_tax_exempt_reason_code;
718    end if;
719 
720    if p_tax_point_code is not null then
721      l_header_rec.tax_point_code:=p_tax_point_code;
722    end if;
723 
724    if p_transactional_curr_code is not null then
725 	l_header_rec.transactional_curr_code:=p_transactional_curr_code;
726    end if;
727 
728    if  p_version_number  is not null then
729 	l_header_rec.version_number:=p_version_number;
730    end if;
731 
732    if p_salesrep_id is not null then
733      l_header_rec.salesrep_id:=p_salesrep_id;
734    end if;
735 
736    if p_return_reason_code is not null then
737 	l_header_rec.return_reason_code:=p_return_reason_code;
738    end if;
739 
740    if  p_version_number  is not null then
741 	l_header_rec.version_number:=p_version_number;
742    end if;
743 
744    if p_payment_type_code is not null then
745      l_header_rec.payment_type_code:=p_payment_type_code;
746    end if;
747 
748    if p_payment_amount is not null then
749 	l_header_rec.payment_amount:=p_payment_amount;
750    end if;
751 
752    if  p_check_number  is not null then
753 	l_header_rec.check_number:=p_check_number;
754    end if;
755 
756    if p_credit_card_code is not null then
757      l_header_rec.credit_card_code:=p_credit_card_code;
758    end if;
759 
760    if p_credit_card_holder_name is not null then
761 	l_header_rec.credit_card_holder_name:=p_credit_card_holder_name;
762    end if;
763 
764    if  p_credit_card_number  is not null then
765 	l_header_rec.credit_card_number:=p_credit_card_number;
766    end if;
767 
768    --bug 5191301
769    if p_instrument_security_code is not null then
770       l_header_rec.instrument_security_code := p_instrument_security_code;
771    end if;
772    --bug 5191301
773 
774    if p_credit_card_expiration_date is not null then
775      l_header_rec.credit_card_expiration_date:=p_credit_card_expiration_date;
776    end if;
777 
778    if p_credit_card_approval_date is not null then
779      l_header_rec.credit_card_approval_date :=p_credit_card_approval_date;
780    end if;
781 
782    if p_credit_card_approval_code is not null then
783 	l_header_rec.credit_card_approval_code:=p_credit_card_approval_code;
784    end if;
785 
786    if p_credit_card_approval_code is not null then
787 	l_header_rec.credit_card_approval_code:=p_credit_card_approval_code;
788    end if;
789 
790    if  p_first_ack_code  is not null then
791 	l_header_rec.first_ack_code:=p_first_ack_code;
792    end if;
793 
794    if  p_first_ack_date  is not null then
795 	l_header_rec.first_ack_date:=p_first_ack_date;
796    end if;
797 
798    if  p_last_ack_code  is not null then
799 	l_header_rec.last_ack_code:=p_last_ack_code;
800    end if;
801 
802    if  p_last_ack_date  is not null then
803 	l_header_rec.last_ack_date:=p_last_ack_date;
804    end if;
805 
806    if p_tp_context is not null then
807      l_header_rec.tp_context:=p_tp_context;
808    end if;
809 
810    if p_tp_attribute1 is not null then
811      l_header_rec.tp_attribute1:=p_tp_attribute1;
812    end if;
813 
814    if p_tp_attribute2 is not null then
815      l_header_rec.tp_attribute2:=p_tp_attribute2;
816    end if;
817 
818    if p_tp_attribute3 is not null then
819      l_header_rec.tp_attribute3:=p_tp_attribute3;
820    end if;
821 
822    if p_tp_attribute4 is not null then
823      l_header_rec.tp_attribute4:=p_tp_attribute4;
824    end if;
825 
826    if p_tp_attribute5 is not null then
827      l_header_rec.tp_attribute5:=p_tp_attribute5;
828    end if;
829 
830    if p_tp_attribute6 is not null then
831      l_header_rec.tp_attribute6:=p_tp_attribute6;
832    end if;
833 
834    if p_tp_attribute7 is not null then
835      l_header_rec.tp_attribute7:=p_tp_attribute7;
836    end if;
837 
838    if p_tp_attribute8 is not null then
839      l_header_rec.tp_attribute8:=p_tp_attribute8;
840    end if;
841 
842    if p_tp_attribute9 is not null then
843      l_header_rec.tp_attribute9:=p_tp_attribute9;
844    end if;
845 
846    if p_tp_attribute10 is not null then
847      l_header_rec.tp_attribute10:=p_tp_attribute10;
848    end if;
849 
850    if p_tp_attribute11 is not null then
851      l_header_rec.tp_attribute11:=p_tp_attribute11;
852    end if;
853 
854    if p_tp_attribute12 is not null then
855      l_header_rec.tp_attribute12:=p_tp_attribute12;
856    end if;
857 
858    if p_tp_attribute13 is not null then
859      l_header_rec.tp_attribute13:=p_tp_attribute13;
860    end if;
861 
862    if p_tp_attribute14 is not null then
863      l_header_rec.tp_attribute14:=p_tp_attribute14;
864    end if;
865 
866    if p_tp_attribute15 is not null then
867      l_header_rec.tp_attribute15:=p_tp_attribute15;
868    end if;
869 
870   --My Addition
871    if p_sold_to_site_use_id is not null then
872      l_header_rec.sold_to_site_use_id:=p_sold_to_site_use_id;
873    end if;
874 
875    /* Start Audit Trail */
876    if p_change_reason is not null then
877      l_header_rec.change_reason := p_change_reason;
878    end if;
879 
880    if p_change_comments is not null then
881      l_header_rec.change_comments := p_change_comments;
882    end if;
883    /* End Audit Trail */
884 
885    /*End Customer Changes */
886    if p_end_customer_contact_id  is not null then
887       l_header_rec.end_customer_contact_id := p_end_customer_contact_id;
888    end if;
889    if p_end_customer_id is not null then
890       l_header_rec.end_customer_id := p_end_customer_id;
891    end if;
892    if   p_end_customer_site_use_id is not null then
893       l_header_rec.end_customer_site_use_id := p_end_customer_site_use_id;
894    end if;
895   if  p_ib_owner is not null then
896       l_header_rec.ib_owner := p_ib_owner;
897       end if;
898   if  p_ib_installed_at_location  is not null then
899      l_header_rec.ib_installed_at_location := p_ib_installed_at_location;
900      end if;
901   if  p_ib_current_location  is not null then
902      l_header_rec.ib_current_location := p_ib_current_location;
903      end if;
904 
905 
906    l_control_rec.controlled_operation:=TRUE;
907    l_control_rec.process:=FALSE;
908    l_control_rec.process_entity:=OE_GLOBALS.G_ENTITY_ALL;
909 
910    --added for bug 4882981
911    l_control_rec.check_security       := TRUE;
912    l_control_rec.clear_dependents     := TRUE;
913    l_control_rec.default_attributes   := TRUE;
914    l_control_rec.change_attributes    := TRUE;
915    l_control_rec.validate_entity      := TRUE;
916    l_control_rec.write_to_DB          := TRUE;
917    --End of bug 4882981
918 
919    Oe_Order_Pvt.Header
920     (
921         p_validation_level            => FND_API.G_VALID_LEVEL_FULL
922     ,   p_init_msg_list               => l_init_msg_list
923     ,   p_control_rec                 => l_control_rec
924     ,   p_x_header_rec                => l_header_rec
925     ,   p_x_old_header_rec            => l_old_header_rec
926     ,   x_return_status               => l_return_status
927     );
928 
929 
930      p_return_status := l_return_status;
931      OE_DEBUG_PUB.Add('return_status='||l_return_status);
932      if l_return_status in(FND_API.G_RET_STS_ERROR,
933 					  FND_API.G_RET_STS_UNEXP_ERROR) then
934 	  ROLLBACK TO SAVEPOINT Process_Order_Scalar;
935 	  G_ERROR_COUNT := G_ERROR_COUNT + 1;
936 
937          l_error_count := l_error_count + 1;
938          p_error_count := l_error_count;
939          OE_MSG_PUB.Count_And_Get
940             ( p_count => p_msg_count,
941               p_data  => p_msg_data
942             );
943       if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
944           OE_DEBUG_PUB.Add('EXIT_FIRST_ERROR  SKIP_CONTINUE');
945           exit;
946       else
947                OE_DEBUG_PUB.Add('SKIP_ALL');
948       end if;
949 
950      end if;
951  -- loop exception handling
952  Exception
953     WHEN FND_API.G_EXC_ERROR THEN
954         p_return_status := FND_API.G_RET_STS_ERROR ;
955         OE_MSG_PUB.Count_And_Get
956             ( p_count => p_msg_count,
957               p_data  => p_msg_data
958             );
959         l_error_count := l_error_count + 1;
960         p_error_count := l_error_count;
961 
962        G_ERROR_COUNT := G_ERROR_COUNT + 1;
963        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
964 
965      if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
966                 exit;
967         end if;
968 
969     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
970         p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
971         OE_MSG_PUB.Count_And_Get
972             ( p_count => p_msg_count,
973               p_data  => p_msg_data
974             );
975         l_error_count := l_error_count + 1;
976         p_error_count := l_error_count;
977 
978        G_ERROR_COUNT := G_ERROR_COUNT + 1;
979        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
980 
981      if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
982                 exit;
983      end if;
984 
985 
986    WHEN OTHERS THEN
987         p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
988         IF OE_MSG_PUB.Check_Msg_Level
989             (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
990         THEN
991   OE_MSG_PUB.Add_Exc_Msg
992                     (G_PKG_NAME,l_api_name
993                 );
994         END IF;
995         OE_MSG_PUB.Count_And_Get
996             ( p_count => p_msg_count,
997               p_data  => p_msg_data);
998         l_error_count := l_error_count + 1;
999         p_error_count := l_error_count;
1000 
1001        G_ERROR_COUNT := G_ERROR_COUNT + 1;
1002        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
1003 
1004      if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
1005                 exit;
1006         end if;
1007 
1008 END;
1009 
1010 --End LOOP; /* end of FOR loop */
1011   -- moved execution of delayed request inside the for loop for bug 4882981
1012  IF p_return_status = FND_API.G_RET_STS_SUCCESS THEN
1013  --{ SUCCESS from OE_ORDER_PVT.Header
1014  BEGIN
1015   -- call to post_line_process is not needed for headers mass change
1016   /*
1017 
1018     l_control_rec.controlled_operation := TRUE;
1019     l_control_rec.process              := TRUE;
1020     l_control_rec.process_entity       := OE_GLOBALS.G_ENTITY_ALL;
1021 
1022     l_control_rec.check_security       := FALSE;
1023     l_control_rec.clear_dependents     := FALSE;
1024     l_control_rec.default_attributes   := FALSE;
1025     l_control_rec.change_attributes    := FALSE;
1026     l_control_rec.validate_entity      := FALSE;
1027     l_control_rec.write_to_DB          := FALSE;
1028 
1029     --  Instruct API to clear its request table
1030 
1031     l_control_rec.clear_api_cache      := FALSE;
1032     l_control_rec.clear_api_requests   := TRUE;
1033 
1034      oe_line_util.Post_Line_Process
1035     (   p_control_rec    => l_control_rec
1036     ,   p_x_line_tbl   => l_line_tbl );
1037 
1038     */
1039 
1040     --added call to PRN for bug 4882981
1041 	 OE_Order_PVT.Process_Requests_And_Notify
1042             ( p_process_requests          => TRUE
1043             , p_notify                    => TRUE
1044             , x_return_status             => l_return_status
1045 	    , p_old_header_rec		  => l_old_header_rec
1046 	    , p_header_rec		  => l_header_rec );
1047 
1048 
1049      /*
1050      OE_DELAYED_REQUESTS_PVT.Process_Delayed_Requests(
1051                                              x_return_status => l_return_status
1052                                               );
1053 
1054 					      */
1055        oe_debug_pub.ADD('OEXVMSCB: Completed Process_Delayed_Requests '
1056                     || ' with return status' || l_return_status, 1);
1057 
1058 	oe_debug_pub.add('calling count and get to display errors');
1059 
1060        -- Bug 1809955
1061        -- Display any errors/messages that were caused
1062        -- as a result of the delayed request execution
1063        OE_MSG_PUB.Count_and_Get(
1064 				p_count => p_msg_count,
1065 				p_data => p_msg_data
1066 				);
1067 
1068        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1069                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1070        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1071                  RAISE FND_API.G_EXC_ERROR;
1072        END IF;
1073 
1074 
1075      oe_debug_pub.add('p_cascade_header_changes' || p_cascade_header_changes);
1076 --   Begin of Cascade Header changes in Mass Change ER 7509356
1077      IF p_cascade_header_changes = 'Y' THEN
1078      --{
1079      oe_debug_pub.add('Just before calling cascade_header_attributes from process_order_scalar for header_id :' || l_header_rec.header_id);
1080 
1081      OE_OE_FORM_HEADER.CASCADE_HEADER_ATTRIBUTES
1082                       (
1083                         p_old_db_header_rec      => l_old_header_rec
1084                        ,p_header_rec             => l_header_rec
1085                        ,x_return_status          => l_return_status
1086                        ,x_msg_count              => p_msg_count
1087                        ,x_msg_data               => p_msg_data
1088                       );
1089 
1090      oe_debug_pub.add('return_status from cascade_header_attributes '|| l_return_status);
1091        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1092                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1093        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1094                  RAISE FND_API.G_EXC_ERROR;
1095        END IF;
1096        --}
1097        END IF;
1098 --   End  of Cascade Header changes in Mass Change ER 7509356
1099 
1100 
1101 
1102 EXCEPTION
1103     WHEN FND_API.G_EXC_ERROR THEN
1104          l_error_count := l_error_count + 1;
1105          p_error_count := l_error_count;
1106        p_return_status := FND_API.G_RET_STS_ERROR ;
1107         OE_MSG_PUB.Count_And_Get
1108             ( p_count => p_msg_count,
1109               p_data  => p_msg_data
1110             );
1111        l_error_count := l_error_count + 1;
1112        p_error_count := l_error_count;
1113 
1114        G_ERROR_COUNT := G_ERROR_COUNT + 1;
1115        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
1116 
1117 
1118     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1119          l_error_count := l_error_count + 1;
1120          p_error_count := l_error_count;
1121         p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1122         OE_MSG_PUB.Count_And_Get
1123             ( p_count => p_msg_count,
1124               p_data  => p_msg_data
1125            );
1126       l_error_count := l_error_count + 1;
1127       p_error_count := l_error_count;
1128 
1129        G_ERROR_COUNT := G_ERROR_COUNT + 1;
1130        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
1131 
1132     WHEN OTHERS THEN
1133          l_error_count := l_error_count + 1;
1134          p_error_count := l_error_count;
1135         p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1136         IF OE_MSG_PUB.Check_Msg_Level
1137             (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1138         THEN
1139              OE_MSG_PUB.Add_Exc_Msg
1140                     (G_PKG_NAME,
1141                      l_api_name
1142                 );
1143         END IF;
1144         OE_MSG_PUB.Count_And_Get
1145             ( p_count => p_msg_count,
1146               p_data  => p_msg_data);
1147          l_error_count := l_error_count + 1;
1148         p_error_count := l_error_count;
1149 
1150        G_ERROR_COUNT := G_ERROR_COUNT + 1;
1151        ROLLBACK TO SAVEPOINT Process_Order_Scalar;
1152 
1153 END ;
1154 
1155 --} SUCCESS from OE_ORDER_PVT.Header
1156 END IF;
1157 --}
1158 END LOOP ; /* end for loop */  -- end bug 4882981
1159  IS_MASS_CHANGE := 'F'; -- Added for ER 7509356
1160 end Process_Order_Scalar;
1161 
1162 -- 4020312
1163 -- Process_Line_Scalar has been changed to group lines together before calling
1164 -- OE_ORDER_PVT.Lines so that lines belonging together like models and sets go
1165 -- for processing at one go.
1166 Procedure Process_Line_Scalar
1167 (   p_num_of_records                IN NUMBER
1168 ,   p_sel_rec_tbl                   IN Oe_Globals.Selected_Record_Tbl --MOAC PI
1169 ,   p_multi_OU                      IN Boolean --MOAC PI
1170 ,   p_change_reason                 IN VARCHAR2
1171 ,   p_change_comments               IN VARCHAR2
1172 ,   p_msg_count                     OUT NOCOPY NUMBER
1173 ,   p_msg_data                      OUT NOCOPY VARCHAR2
1174 ,   p_return_status                 OUT NOCOPY VARCHAR2
1175 ,   p_mc_err_handling_flag          IN NUMBER := FND_API.G_MISS_NUM
1176 ,   p_error_count                   OUT NOCOPY NUMBER
1177 ,   p_header_id                     IN  NUMBER
1178 ,   p_accounting_rule_id            IN NUMBER
1179 ,   p_accounting_rule_duration      IN NUMBER
1180 ,   p_actual_arrival_date           IN DATE
1181 ,   p_actual_shipment_date          IN DATE
1182 ,   p_agreement_id                  IN NUMBER
1183 ,   p_ato_line_id                   IN NUMBER
1184 ,   p_attribute1                    IN VARCHAR2
1185 ,   p_attribute10                   IN VARCHAR2
1186 ,   p_attribute11                   IN VARCHAR2
1187 ,   p_attribute12                   IN VARCHAR2
1188 ,   p_attribute13                   IN VARCHAR2
1189 ,   p_attribute14                   IN VARCHAR2
1190 ,   p_attribute15                   IN VARCHAR2
1191 ,   p_attribute16                   IN VARCHAR2   --For bug 2184255
1192 ,   p_attribute17                   IN VARCHAR2
1193 ,   p_attribute18                   IN VARCHAR2
1194 ,   p_attribute19                   IN VARCHAR2
1195 ,   p_attribute2                    IN VARCHAR2
1196 ,   p_attribute20                   IN VARCHAR2
1197 ,   p_attribute3                    IN VARCHAR2
1198 ,   p_attribute4                    IN VARCHAR2
1199 ,   p_attribute5                    IN VARCHAR2
1200 ,   p_attribute6                    IN VARCHAR2
1201 ,   p_attribute7                    IN VARCHAR2
1202 ,   p_attribute8                    IN VARCHAR2
1203 ,   p_attribute9                    IN VARCHAR2
1204 ,   p_blanket_number                IN NUMBER
1205 ,   p_blanket_line_number           IN NUMBER
1206 ,   p_blanket_version_number        IN NUMBER
1207 ,   p_context                       IN VARCHAR2
1208 ,   p_auto_selected_quantity        IN NUMBER
1209 ,   p_cancelled_quantity            In NUMBER
1210 ,   p_component_code                IN VARCHAR2
1211 ,   p_component_number              IN NUMBER
1212 ,   p_component_sequence_id         IN NUMBER
1213 ,   p_config_display_sequence       IN NUMBER
1214 ,   p_configuration_id              IN NUMBER
1215 ,   p_config_header_id              IN NUMBER
1216 ,   p_config_rev_nbr                IN NUMBER
1217 ,   p_credit_invoice_line_id        IN NUMBER
1218 ,   p_customer_dock_code            IN VARCHAR2
1219 ,   p_customer_job                  IN VARCHAR2
1220 ,   p_customer_production_line      IN VARCHAR2
1221 ,   p_customer_trx_line_id          IN NUMBER
1222 ,   p_cust_model_serial_number      IN VARCHAR2
1223 ,   p_cust_po_number                IN VARCHAR2
1224 ,   p_delivery_lead_time            IN NUMBER
1225 ,   p_deliver_to_contact_id         IN NUMBER
1226 ,   p_deliver_to_org_id             IN NUMBER
1227 ,   p_demand_bucket_type_code       IN VARCHAR2
1228 ,   p_demand_class_code             IN VARCHAR2
1229 ,   p_dep_plan_required_flag        IN VARCHAR2
1230 ,   p_earliest_acceptable_date      IN DATE
1231 ,   p_explosion_date                IN DATE
1232 ,   p_fob_point_code                IN VARCHAR2
1233 ,   p_freight_carrier_code          IN VARCHAR2
1234 ,   p_freight_terms_code            IN VARCHAR2
1235 ,   p_fulfilled_quantity            IN NUMBER
1236 ,   p_global_attribute1             IN VARCHAR2
1237 ,   p_global_attribute10            IN VARCHAR2
1238 ,   p_global_attribute11            IN VARCHAR2
1239 ,   p_global_attribute12            IN VARCHAR2
1240 ,   p_global_attribute13            IN VARCHAR2
1241 ,   p_global_attribute14            IN VARCHAR2
1242 ,   p_global_attribute15            IN VARCHAR2
1243 ,   p_global_attribute16            IN VARCHAR2
1244 ,   p_global_attribute17            IN VARCHAR2
1245 ,   p_global_attribute18            IN VARCHAR2
1246 ,   p_global_attribute19            IN VARCHAR2
1247 ,   p_global_attribute2             IN VARCHAR2
1248 ,   p_global_attribute20            IN VARCHAR2
1249 ,   p_global_attribute3             IN VARCHAR2
1250 ,   p_global_attribute4             IN VARCHAR2
1251 ,   p_global_attribute5             IN VARCHAR2
1252 ,   p_global_attribute6             IN VARCHAR2
1253 ,   p_global_attribute7             IN VARCHAR2
1254 ,   p_global_attribute8             IN VARCHAR2
1255 ,   p_global_attribute9             IN VARCHAR2
1256 ,   p_global_attribute_category     IN VARCHAR2
1257 ,   p_industry_attribute1           IN VARCHAR2
1258 ,   p_industry_attribute10          IN VARCHAR2
1259 ,   p_industry_attribute11          IN VARCHAR2
1260 ,   p_industry_attribute12          IN VARCHAR2
1261 ,   p_industry_attribute13          IN VARCHAR2
1262 ,   p_industry_attribute14          IN VARCHAR2
1263 ,   p_industry_attribute15          IN VARCHAR2
1264 ,   p_industry_attribute2           IN VARCHAR2
1265 ,   p_industry_attribute3           IN VARCHAR2
1266 ,   p_industry_attribute4           IN VARCHAR2
1267 ,   p_industry_attribute5           IN VARCHAR2
1268 ,   p_industry_attribute6           IN VARCHAR2
1269 ,   p_industry_attribute7           IN VARCHAR2
1270 ,   p_industry_attribute8           IN VARCHAR2
1271 ,   p_industry_attribute9           IN VARCHAR2
1272 ,   p_industry_context              IN VARCHAR2
1273 ,   p_intermed_ship_to_contact_id   IN NUMBER
1274 ,   p_intermed_ship_to_org_id       IN NUMBER
1275 ,   p_inventory_item_id             IN NUMBER
1276 ,   p_invoice_interface_status      IN VARCHAR2
1277 ,   p_invoice_to_contact_id         IN NUMBER
1278 ,   p_invoice_to_org_id             IN NUMBER
1279 ,   p_invoicing_rule_id             IN NUMBER
1280 ,   p_ordered_item_id               IN NUMBER
1281 ,   p_item_identifier_type          IN VARCHAR2
1282 ,   p_ordered_item                  IN VARCHAR2
1283 ,   p_item_revision                 IN VARCHAR2
1284 ,   p_item_type_code                IN VARCHAR2
1285 ,   p_latest_acceptable_date        IN DATE
1286 ,   p_line_category_code            IN VARCHAR2
1287 ,   p_line_id                       IN NUMBER
1288 ,   p_line_number                   IN NUMBER
1289 ,   p_line_type_id                  IN NUMBER
1290 ,   p_link_to_line_id               IN NUMBER
1291 ,   p_model_group_number            IN NUMBER
1292 ,   p_option_flag                   IN VARCHAR2
1293 ,   p_option_number                 IN NUMBER
1294 ,   p_ordered_quantity              IN NUMBER
1295 ,   p_order_quantity_uom            IN VARCHAR2
1296 ,   p_org_id                        IN NUMBER
1297 ,   p_orig_sys_document_ref         IN VARCHAR2
1298 ,   p_orig_sys_line_ref             IN VARCHAR2
1299 ,   p_payment_term_id               IN NUMBER
1300 ,   p_price_list_id                 IN NUMBER
1301 ,   p_pricing_attribute1            IN VARCHAR2
1302 ,   p_pricing_attribute10           IN VARCHAR2
1303 ,   p_pricing_attribute2            IN VARCHAR2
1304 ,   p_pricing_attribute3            IN VARCHAR2
1305 ,   p_pricing_attribute4            IN VARCHAR2
1306 ,   p_pricing_attribute5            IN VARCHAR2
1307 ,   p_pricing_attribute6            IN VARCHAR2
1308 ,   p_pricing_attribute7            IN VARCHAR2
1309 ,   p_pricing_attribute8            IN VARCHAR2
1310 ,   p_pricing_attribute9            IN VARCHAR2
1311 ,   p_pricing_context               IN VARCHAR2
1312 ,   p_pricing_date                  IN DATE
1313 ,   p_pricing_quantity              IN NUMBER
1314 ,   p_pricing_quantity_uom          IN VARCHAR2
1315 ,   p_project_id                    IN NUMBER
1316 ,   p_promise_date                  IN DATE
1317 ,   p_reference_header_id           IN NUMBER
1318 ,   p_reference_line_id             IN NUMBER
1319 ,   p_reference_type                IN VARCHAR2
1320 ,   p_request_date                  IN DATE
1321 ,   p_reserved_quantity             IN NUMBER
1322 ,   p_return_attribute1             IN VARCHAR2
1323 ,   p_return_attribute10            IN VARCHAR2
1324 ,   p_return_attribute11            IN VARCHAR2
1325 ,   p_return_attribute12            IN VARCHAR2
1326 ,   p_return_attribute13            IN VARCHAR2
1327 ,   p_return_attribute14            IN VARCHAR2
1328 ,   p_return_attribute15            IN VARCHAR2
1329 ,   p_return_attribute2             IN VARCHAR2
1330 ,   p_return_attribute3             IN VARCHAR2
1331 ,   p_return_attribute4             IN VARCHAR2
1332 ,   p_return_attribute5             IN VARCHAR2
1333 ,   p_return_attribute6             IN VARCHAR2
1334 ,   p_return_attribute7             IN VARCHAR2
1335 ,   p_return_attribute8             IN VARCHAR2
1336 ,   p_return_attribute9             IN VARCHAR2
1337 ,   p_return_context                IN VARCHAR2
1338 ,   p_rla_schedule_type_code        IN VARCHAR2
1339 ,   p_schedule_arrival_date         IN DATE
1340 ,   p_schedule_ship_date            IN DATE
1341 ,   p_schedule_action_code          IN VARCHAR2
1342 ,   p_schedule_status_code          IN VARCHAR2
1343 ,   p_shipment_number               IN NUMBER
1344 ,   p_shipment_priority_code        IN VARCHAR2
1345 ,   p_shipped_quantity              IN NUMBER
1346 ,   p_shipping_method_code          IN VARCHAR2
1347 ,   p_shipping_quantity             IN NUMBER
1348 ,   p_shipping_quantity_uom         IN VARCHAR2
1349 ,   p_ship_from_org_id              IN NUMBER
1350 ,   p_ship_tolerance_above          IN NUMBER
1351 ,   p_ship_tolerance_below          IN NUMBER
1352 ,   p_shipping_interfaced_flag      IN VARCHAR2
1353 ,   p_ship_to_contact_id            IN NUMBER
1354 ,   p_ship_to_org_id                IN NUMBER
1355 ,   p_ship_model_complete_flag      IN VARCHAR2
1356 ,   p_sold_to_org_id                IN NUMBER
1357 ,   p_sort_order                    IN VARCHAR2
1358 ,   p_source_document_id            IN NUMBER
1359 ,   p_source_document_line_id       IN NUMBER
1360 ,   p_source_document_type_id       IN NUMBER
1361 ,   p_source_type_code              IN VARCHAR2
1362 ,   p_task_id                       IN NUMBER
1363 ,   p_tax_code                      IN VARCHAR2
1364 ,   p_tax_date                      IN DATE
1365 ,   p_tax_exempt_flag               IN VARCHAR2
1366 ,   p_tax_exempt_number             IN VARCHAR2
1367 ,   p_tax_exempt_reason_code        IN VARCHAR2
1368 ,   p_tax_point_code                IN VARCHAR2
1369 ,   p_tax_rate                      IN NUMBER
1370 ,   p_tax_value                     IN NUMBER
1371 ,   p_top_model_line_id             IN NUMBER
1372 ,   p_unit_list_price               IN NUMBER
1373 ,   p_unit_selling_price            IN NUMBER
1374 ,   p_visible_demand_flag           IN VARCHAR2
1375 ,   p_accounting_rule               IN VARCHAR2
1376 ,   p_agreement                     IN VARCHAR2
1377 ,   p_customer_item                 IN VARCHAR2
1378 ,   p_deliver_to_address1           IN VARCHAR2
1379 ,   p_deliver_to_address2           IN VARCHAR2
1380 ,   p_deliver_to_address3           IN VARCHAR2
1381 ,   p_deliver_to_address4           IN VARCHAR2
1382 ,   p_deliver_to_contact            IN VARCHAR2
1383 ,   p_deliver_to_location           IN VARCHAR2
1384 ,   p_deliver_to_org                IN VARCHAR2
1385 ,   p_demand_bucket_type            IN VARCHAR2
1386 ,   p_fob_point                     IN VARCHAR2
1387 ,   p_freight_terms                 IN VARCHAR2
1388 ,   p_inventory_item                IN VARCHAR2
1389 ,   p_invoice_to_address1           IN VARCHAR2
1390 ,   p_invoice_to_address2           IN VARCHAR2
1391 ,   p_invoice_to_address3           IN VARCHAR2
1392 ,   p_invoice_to_address4           IN VARCHAR2
1393 ,   p_invoice_to_contact            IN VARCHAR2
1394 ,   p_invoice_to_location           IN VARCHAR2
1395 ,   p_invoice_to_org                IN VARCHAR2
1396 ,   p_invoicing_rule                IN VARCHAR2
1397 ,   p_intermed_ship_to_address1     IN VARCHAR2
1398 ,   p_intermed_ship_to_address2     IN VARCHAR2
1399 ,   p_intermed_ship_to_address3     IN VARCHAR2
1400 ,   p_intermed_ship_to_address4     IN VARCHAR2
1401 ,   p_intermed_ship_to_contact      IN VARCHAR2
1402 ,   p_intermed_ship_to_location     IN VARCHAR2
1403 ,   p_intermed_ship_to_org          IN VARCHAR2
1404 ,   p_item                          IN VARCHAR2
1405 ,   p_item_type                     IN VARCHAR2
1406 ,   p_line_type                     IN VARCHAR2
1407 ,   p_payment_term                  IN VARCHAR2
1408 ,   p_price_list                    IN VARCHAR2
1409 ,   p_project                       IN VARCHAR2
1410 ,   p_rla_schedule_type             IN VARCHAR2
1411 ,   p_shipment_priority             IN VARCHAR2
1412 ,   p_ship_from_address1            IN VARCHAR2
1413 ,   p_ship_from_address2            IN VARCHAR2
1414 ,   p_ship_from_address3            IN VARCHAR2
1415 ,   p_ship_from_address4            IN VARCHAR2
1416 ,   p_ship_from_location            IN VARCHAR2
1417 ,   p_ship_from_org                 IN VARCHAR2
1418 ,   p_ship_to_address1              IN VARCHAR2
1419 ,   p_ship_to_address2              IN VARCHAR2
1420 ,   p_ship_to_address3              IN VARCHAR2
1421 ,   p_ship_to_address4              IN VARCHAR2
1422 ,   p_ship_to_contact               IN VARCHAR2
1423 ,   p_ship_to_location              IN VARCHAR2
1424 ,   p_ship_to_org                   IN VARCHAR2
1425 ,   p_sold_to_org                   IN VARCHAR2
1426 ,   p_task                          IN VARCHAR2
1427 ,   p_tax_exempt                    IN VARCHAR2
1428 ,   p_tax_exempt_reason             IN VARCHAR2
1429 ,   p_tax_point                     IN VARCHAR2
1430 ,   p_split_from_line_id            IN NUMBER
1431 ,   p_cust_production_seq_num       IN VARCHAR2
1432 ,   p_authorized_to_ship_flag       IN VARCHAR2
1433 ,   p_veh_cus_item_cum_key_id       IN NUMBER
1434 ,   p_salesrep_id                   IN NUMBER
1435 ,   p_return_reason_code            IN VARCHAR2
1436 ,   p_arrival_set_id                IN NUMBER
1437 ,   p_ship_set_id                   IN NUMBER
1438 ,   p_over_ship_reason_code         IN VARCHAR2
1439 ,   p_over_ship_resolved_flag       IN VARCHAR2
1440 ,   p_industry_attribute16          IN VARCHAR2
1441 ,   p_industry_attribute17          IN VARCHAR2
1442 ,   p_industry_attribute18          IN VARCHAR2
1443 ,   p_industry_attribute19          IN VARCHAR2
1444 ,   p_industry_attribute20          IN VARCHAR2
1445 ,   p_industry_attribute21          IN VARCHAR2
1446 ,   p_industry_attribute22          IN VARCHAR2
1447 ,   p_industry_attribute23          IN VARCHAR2
1448 ,   p_industry_attribute24          IN VARCHAR2
1449 ,   p_industry_attribute25          IN VARCHAR2
1450 ,   p_industry_attribute26          IN VARCHAR2
1451 ,   p_industry_attribute27          IN VARCHAR2
1452 ,   p_industry_attribute28          IN VARCHAR2
1453 ,   p_industry_attribute29          IN VARCHAR2
1454 ,   p_industry_attribute30          IN VARCHAR2
1455 ,   p_veh_cus_item_cum_key          IN VARCHAR2
1456 ,   p_salesrep                      IN VARCHAR2
1457 ,   p_return_reason                 IN VARCHAR2
1458 ,   p_delivery                      IN VARCHAR2
1459 ,   p_arrival_set                   IN VARCHAR2
1460 ,   p_ship_set                      IN VARCHAR2
1461 ,   p_over_ship_reason              IN VARCHAR2
1462 ,   p_first_ack_code                IN VARCHAR2
1463 ,   p_first_ack_date                IN DATE
1464 ,   p_last_ack_code                 IN VARCHAR2
1465 ,   p_last_ack_date                 IN DATE
1466 ,   p_service_txn_reason_code       IN VARCHAR2
1467 ,   p_service_txn_comments          IN VARCHAR2
1468 ,   p_unit_selling_percent          IN NUMBER
1469 ,   p_unit_list_percent             IN NUMBER
1470 ,   p_unit_percent_base_price       IN NUMBER
1471 ,   p_service_duration              IN NUMBER
1472 ,   p_service_period                IN VARCHAR2
1473 ,   p_service_start_date            IN DATE
1474 ,   p_service_end_date              IN DATE
1475 ,   p_service_coterminate_flag      IN VARCHAR2
1476 ,   p_service_number                IN NUMBER
1477 ,   p_service_reference_type_code   IN VARCHAR2
1478 ,   p_service_reference_line_id     IN NUMBER
1479 ,   p_service_reference_system_id   IN NUMBER
1480 ,   p_tp_attribute1                 IN VARCHAR2
1481 ,   p_tp_attribute10                IN VARCHAR2
1482 ,   p_tp_attribute11                IN VARCHAR2
1483 ,   p_tp_attribute12                IN VARCHAR2
1484 ,   p_tp_attribute13                IN VARCHAR2
1485 ,   p_tp_attribute14                IN VARCHAR2
1486 ,   p_tp_attribute15                IN VARCHAR2
1487 ,   p_tp_attribute2                 IN VARCHAR2
1488 ,   p_tp_attribute3                 IN VARCHAR2
1489 ,   p_tp_attribute4                 IN VARCHAR2
1490 ,   p_tp_attribute5                 IN VARCHAR2
1491 ,   p_tp_attribute6                 IN VARCHAR2
1492 ,   p_tp_attribute7                 IN VARCHAR2
1493 ,   p_tp_attribute8                 IN VARCHAR2
1494 ,   p_tp_attribute9                 IN VARCHAR2
1495 ,   p_tp_context                    IN VARCHAR2
1496 ,   p_shipping_instructions         IN VARCHAR2
1497 ,   p_packing_instructions          IN VARCHAR2
1498 ,   p_planning_priority             IN VARCHAR2
1499 ,   p_calculate_price_flag          IN VARCHAR2
1500 --end custoemr chagnes
1501 ,   p_end_customer_contact_id       IN NUMBER
1502 ,   p_end_customer_id               IN NUMBER
1503 ,   p_end_customer_site_use_id      IN NUMBER
1504 ,   p_end_customer_address1         IN VARCHAR2
1505 ,   p_end_customer_address2         IN VARCHAR2
1506 ,   p_end_customer_address3         IN VARCHAR2
1507 ,   p_end_customer_address4         IN VARCHAR2
1508 ,   p_end_customer_contact          IN VARCHAR2
1509 ,   p_end_customer_location         IN VARCHAR2
1510 ,   p_ib_owner                      IN VARCHAR2
1511 ,   p_ib_installed_at_location      IN VARCHAR2
1512 ,   p_ib_current_location           IN VARCHAR2
1513 ,   p_block_name                    IN VARCHAR2 DEFAULT NULL
1514 ) IS
1515 initial                  Integer;
1516 j                        Integer;
1517 l_api_name      CONSTANT VARCHAR2(30) := 'Process_Line_Scalar';
1518 l_arrival_set_id         number;
1519 l_control_rec            OE_GLOBALS.Control_Rec_Type;
1520 l_counter                Integer := 0;
1521 l_current_org_id         Number;
1522 l_debug_level CONSTANT   NUMBER := oe_debug_pub.g_debug_level;
1523 l_error_count            NUMBER := 0;
1524 l_header_id              Number;
1525 l_init_msg_list          VARCHAR2(1) := FND_API.G_TRUE;
1526 l_line_id                Number;
1527 l_line_tbl               OE_ORDER_PUB.Line_Tbl_Type;
1528 l_mc_err_handling_flag   NUMBER := p_mc_err_handling_flag;
1529 l_num_of_records         NUMBER;
1530 l_old_arrival_set_id     number;
1531 l_old_header_id          number;
1532 l_old_line_tbl           OE_ORDER_PUB.Line_Tbl_Type;
1533 l_old_org_id             number;
1534 l_old_ship_set_id        number;
1535 l_old_top_model_line_id  number;
1536 l_rec                    number;
1537 l_return_status          VARCHAR2(30);
1538 l_ship_set_id            number;
1539 l_top_model_line_id      number;
1540 l_x_line_rec             OE_ORDER_PUB.Line_Rec_Type;
1541 nextpos                  Integer;
1542 
1543 CURSOR c1 IS SELECT x.id1, x.org_id, l.header_id, l.arrival_set_id,
1544                     l.ship_set_id, l.top_model_line_id
1545              FROM TABLE(OE_MASS_CHANGE_PVT.get_sel_rec_tbl) x,
1546                   oe_order_lines_all l
1547              WHERE l.line_id = x.id1
1548              ORDER BY l.header_id,
1549                       nvl(l.arrival_set_id, -1),
1550                       nvl(l.ship_set_id, -1),
1551                       nvl(l.top_model_line_id, -1);
1552 
1553 --Bug 7566697
1554 --Will be used to set the header level savepoint
1555 l_header_changed  BOOLEAN := TRUE;
1556 
1557 
1558 BEGIN
1559    IF l_debug_level > 0 THEN
1560       oe_debug_pub.add('Entering OE_MASS_CHANGE_PVT.Process_Line_Scalar');
1561    END IF;
1562 
1563    p_error_count := l_error_count;
1564 
1565    --bug4529937 start ----bug 6850537,7210480 added p_block_name ='LINES_SUMMARY'
1566    IF p_block_name = 'LINE' or p_block_name ='LINES_SUMMARY' THEN
1567       G_BLK_NAME := p_block_name;
1568       G_NUM_OF_LINES := p_num_of_records;
1569    END IF;
1570 
1571    IF l_debug_level > 0 THEN
1572       oe_debug_pub.add(' block_name:'|| p_block_name);
1573       oe_debug_pub.add(' num of records:'|| p_num_of_records);
1574    END IF;
1575    --bug4529937 end
1576 
1577  IS_MASS_CHANGE := 'T'; --Added for bug 4911340
1578 
1579    g_sel_rec_tbl := p_sel_rec_tbl;
1580    OPEN c1;
1581    FETCH c1 into l_line_id, l_current_org_id, l_header_id, l_arrival_set_id,
1582                  l_ship_set_id, l_top_model_line_id;
1583 
1584    l_old_org_id := l_current_org_id;
1585 
1586    MO_GLOBAL.SET_POLICY_CONTEXT('S',l_current_org_id);
1587 
1588    LOOP -- Outer loop
1589       -- Setting context whenever org_id changes.
1590       IF p_multi_ou AND l_current_org_id <> l_old_org_id THEN
1591          IF l_debug_level > 0 THEN
1592             oe_debug_pub.add('Setting policy - ' || l_current_org_id);
1593          END IF;
1594 
1595          MO_GLOBAL.SET_POLICY_CONTEXT('S',l_current_org_id);
1596       END IF;
1597 
1598       BEGIN
1599          IF l_debug_level > 0 THEN
1600             oe_debug_pub.add('l_rec - ' || l_rec);
1601          END IF;
1602 
1603          IF l_rec > 0 THEN
1604             l_init_msg_list :=   FND_API.G_FALSE;
1605          END IF;
1606 
1607          --Bug 7566697
1608          --Will be creating new savepoint only if the header has changed
1609          --This savepoint will used to rollback changes done to the whole order, in case of pricing error
1610          IF l_header_changed
1611          THEN
1612             OE_MASS_CHANGE_PVT.G_PRICING_ERROR := 'N';
1613             SAVEPOINT Pricing_Header_Savepoint;
1614          END IF;
1615 
1616          SAVEPOINT Process_Line_Scalar;
1617 
1618          l_rec     := 0;
1619 
1620          l_line_tbl      := OE_ORDER_PUB.G_MISS_LINE_TBL;
1621          l_old_line_tbl  := OE_ORDER_PUB.G_MISS_LINE_TBL;
1622          l_return_status := NULL;
1623 
1624          LOOP -- Inner loop
1625 
1626             G_COUNTER := G_COUNTER + 1;
1627 
1628             IF l_debug_level > 0 THEN
1629                oe_debug_pub.add('Line Id           - ' || l_line_id);
1630                oe_debug_pub.add('Org Id            - ' || l_current_org_id);
1631                oe_debug_pub.add('Header Id         - ' || l_header_id);
1632                oe_debug_pub.add('Arrival Set Id    - ' || l_arrival_set_id);
1633                oe_debug_pub.add('Ship Set Id       - ' || l_ship_set_id);
1634                oe_debug_pub.add('Top Model Line Id - ' || l_top_model_line_id);
1635             END IF;
1636 
1637             l_old_header_id         := l_header_id;
1638             l_old_arrival_set_id    := l_arrival_set_id;
1639             l_old_ship_set_id       := l_ship_set_id;
1640             l_old_top_model_line_id := l_top_model_line_id;
1641             l_old_org_id            := l_current_org_id;
1642 
1643             l_rec                       := l_rec + 1;
1644             l_line_tbl(l_rec)           := OE_ORDER_PUB.G_MISS_LINE_REC;
1645             l_line_tbl(l_rec).line_id   := l_line_id;
1646             l_line_tbl(l_rec).header_id := l_header_id;
1647 
1648             OE_Line_Util.Lock_Row ( x_return_status         => l_return_status,
1649                                     p_x_line_rec            => l_x_line_rec,
1650                                     p_line_id               => l_line_id );
1651 
1652             IF l_debug_level > 0 THEN
1653                OE_DEBUG_PUB.Add('After Lock Row - ' || l_return_status);
1654             END IF;
1655 
1656             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1657                RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1658             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1659                RAISE FND_API.G_EXC_ERROR;
1660             END IF;
1661 
1662             l_line_tbl(l_rec).operation := OE_GLOBALS.G_OPR_UPDATE;
1663 
1664             if p_ordered_quantity is NOT NULL then
1665                l_line_tbl(l_rec).ordered_quantity := p_ordered_quantity;
1666             end if;
1667 
1668             if p_change_reason is NOT NULL then
1669                l_line_tbl(l_rec).change_reason := p_change_reason;
1670             end if;
1671 
1672             if p_change_comments is not null then
1673                l_line_tbl(l_rec).change_comments := p_change_comments;
1674             end if;
1675 
1676             if p_order_quantity_uom is NOT NULL then
1677                l_line_tbl(l_rec).order_quantity_uom := p_order_quantity_uom;
1678             end if;
1679 
1680             if p_promise_date is NOT NULL then
1681                l_line_tbl(l_rec).promise_date  := p_promise_date;
1682             end if;
1683 
1684             if p_request_date is NOT NULL then
1685                l_line_tbl(l_rec).request_date  := p_request_date;
1686             end if;
1687 
1688             if p_schedule_ship_date is NOT NULL then
1689                l_line_tbl(l_rec).schedule_ship_date  := p_schedule_ship_date;
1690             end if;
1691 
1692             if p_price_list_id  is NOT NULL then
1693                l_line_tbl(l_rec).price_list_id  := p_price_list_id;
1694             end if;
1695 
1696             if  p_inventory_item_id is NOT NULL then
1697                l_line_tbl(l_rec).inventory_item_id := p_inventory_item_id;
1698                l_line_tbl(l_rec).ordered_item := p_ordered_item;
1699             end if;
1700 
1701             if p_accounting_rule_id  is NOT NULL then
1702                l_line_tbl(l_rec).accounting_rule_id  := p_accounting_rule_id;
1703             end if;
1704 
1705             if p_accounting_rule_duration  is NOT NULL then
1706                l_line_tbl(l_rec).accounting_rule_duration  := p_accounting_rule_duration;
1707             end if;
1708 
1709             if p_actual_arrival_date  is NOT NULL then
1710                l_line_tbl(l_rec).actual_arrival_date := p_actual_arrival_date;
1711             end if;
1712 
1713             if p_actual_shipment_date  is NOT NULL then
1714                l_line_tbl(l_rec).actual_shipment_date := p_actual_shipment_date;
1715             end if;
1716 
1717             if p_agreement_id  is NOT NULL then
1718                l_line_tbl(l_rec).agreement_id := p_agreement_id;
1719             end if;
1720 
1721             if p_shipping_instructions is not null then
1722                l_line_tbl(l_rec).shipping_instructions:=p_shipping_instructions;
1723             end if;
1724 
1725             if p_planning_priority is not null then
1726                l_line_tbl(l_rec).planning_priority:=p_planning_priority;
1727             end if;
1728 
1729             if p_packing_instructions is not null then
1730                l_line_tbl(l_rec).packing_instructions:=p_packing_instructions;
1731             end if;
1732 
1733             if p_ato_line_id  is NOT NULL then
1734                l_line_tbl(l_rec).ato_line_id := p_ato_line_id;
1735             end if;
1736 
1737             if p_attribute1  is NOT NULL then
1738                l_line_tbl(l_rec).attribute1 := p_attribute1;
1739             end if;
1740 
1741             if p_attribute10  is NOT NULL then
1742                l_line_tbl(l_rec).attribute10 := p_attribute10;
1743             end if;
1744 
1745             if p_attribute11  is NOT NULL then
1746                l_line_tbl(l_rec).attribute11 := p_attribute11;
1747             end if;
1748 
1749             if p_attribute12  is NOT NULL then
1750                l_line_tbl(l_rec).attribute12 := p_attribute12;
1751             end if;
1752 
1753             if p_attribute13  is NOT NULL then
1754                l_line_tbl(l_rec).attribute13 := p_attribute13;
1755             end if;
1756 
1757             if p_attribute14  is NOT NULL then
1758                l_line_tbl(l_rec).attribute14 := p_attribute14;
1759             end if;
1760 
1761             if p_attribute15  is NOT NULL then
1762                l_line_tbl(l_rec).attribute15 := p_attribute15;
1763             end if;
1764 
1765             -- For bug 2184255
1766             if p_attribute16  is NOT NULL then
1767                l_line_tbl(l_rec).attribute16 := p_attribute16;
1768             end if;
1769 
1770             if p_attribute17  is NOT NULL then
1771                l_line_tbl(l_rec).attribute17 := p_attribute17;
1772             end if;
1773 
1774             if p_attribute18  is NOT NULL then
1775                l_line_tbl(l_rec).attribute18 := p_attribute18;
1776             end if;
1777 
1778             if p_attribute19  is NOT NULL then
1779                l_line_tbl(l_rec).attribute19 := p_attribute19;
1780             end if;
1781 
1782             if p_attribute2  is NOT NULL then
1783                l_line_tbl(l_rec).attribute2 := p_attribute2;
1784             end if;
1785 
1786             if p_attribute20  is NOT NULL then
1787                l_line_tbl(l_rec).attribute20 := p_attribute20;
1788             end if;
1789 
1790             if p_attribute3  is NOT NULL then
1791                l_line_tbl(l_rec).attribute3 := p_attribute3;
1792             end if;
1793 
1794             if p_attribute4  is NOT NULL then
1795                l_line_tbl(l_rec).attribute4 := p_attribute4;
1796             end if;
1797 
1798             if p_attribute5  is NOT NULL then
1799                l_line_tbl(l_rec).attribute5 := p_attribute5;
1800             end if;
1801 
1802             if p_attribute6  is NOT NULL then
1803                l_line_tbl(l_rec).attribute6 := p_attribute6;
1804             end if;
1805 
1806             if p_attribute7  is NOT NULL then
1807                l_line_tbl(l_rec).attribute7 := p_attribute7;
1808             end if;
1809 
1810             if p_attribute8  is NOT NULL then
1811                l_line_tbl(l_rec).attribute8 := p_attribute8;
1812             end if;
1813 
1814             if p_attribute9  is NOT NULL then
1815                l_line_tbl(l_rec).attribute9 := p_attribute9;
1816             end if;
1817 
1818             if p_blanket_number is not null then
1819                l_line_tbl(l_rec).blanket_number:=p_blanket_number;
1820             end if;
1821 
1822             if p_blanket_line_number is not null then
1823                l_line_tbl(l_rec).blanket_line_number:=p_blanket_line_number;
1824             end if;
1825 
1826             if p_blanket_version_number is not null then
1827                l_line_tbl(l_rec).blanket_version_number:=p_blanket_version_number;
1828             end if;
1829 
1830             if p_context  is NOT NULL then
1831                l_line_tbl(l_rec).context := p_context;
1832             end if;
1833 
1834             if p_auto_selected_quantity  is NOT NULL then
1835                l_line_tbl(l_rec).auto_selected_quantity := p_auto_selected_quantity;
1836             end if;
1837 
1838             if p_cancelled_quantity  is NOT NULL then
1839                l_line_tbl(l_rec).cancelled_quantity := p_cancelled_quantity;
1840             end if;
1841 
1842             if p_component_code  is NOT NULL then
1843                l_line_tbl(l_rec).component_code := p_component_code;
1844             end if;
1845 
1846             if p_component_number  is NOT NULL then
1847                l_line_tbl(l_rec).component_number := p_component_number;
1848             end if;
1849 
1850             if p_component_sequence_id  is NOT NULL then
1851                l_line_tbl(l_rec).component_sequence_id := p_component_sequence_id;
1852             end if;
1853 
1854             if p_config_display_sequence  is NOT NULL then
1855                l_line_tbl(l_rec).config_display_sequence := p_config_display_sequence;
1856             end if;
1857 
1858             if p_configuration_id  is NOT NULL then
1859                l_line_tbl(l_rec).configuration_id := p_configuration_id;
1860             end if;
1861 
1862             if p_credit_invoice_line_id  is NOT NULL then
1863                l_line_tbl(l_rec).credit_invoice_line_id := p_credit_invoice_line_id;
1864             end if;
1865 
1866             if p_customer_dock_code  is NOT NULL then
1867                l_line_tbl(l_rec).customer_dock_code := p_customer_dock_code;
1868             end if;
1869 
1870             if p_customer_job  is NOT NULL then
1871                l_line_tbl(l_rec).customer_job := p_customer_job;
1872             end if;
1873 
1874             if p_customer_production_line  is NOT NULL then
1875                l_line_tbl(l_rec).customer_production_line := p_customer_production_line;
1876             end if;
1877 
1878             if p_customer_trx_line_id  is NOT NULL then
1879                l_line_tbl(l_rec).customer_trx_line_id := p_customer_trx_line_id;
1880             end if;
1881 
1882             if p_cust_model_serial_number  is NOT NULL then
1883                l_line_tbl(l_rec).cust_model_serial_number := p_cust_model_serial_number;
1884             end if;
1885 
1886             if p_cust_po_number  is NOT NULL then
1887                l_line_tbl(l_rec).cust_po_number := p_cust_po_number;
1888             end if;
1889 
1890             if p_delivery_lead_time  is NOT NULL then
1891                l_line_tbl(l_rec).delivery_lead_time := p_delivery_lead_time;
1892             end if;
1893 
1894             if p_deliver_to_contact_id  is NOT NULL then
1895                l_line_tbl(l_rec).deliver_to_contact_id := p_deliver_to_contact_id;
1896             end if;
1897 
1898             if p_deliver_to_org_id  is NOT NULL then
1899                l_line_tbl(l_rec).deliver_to_org_id := p_deliver_to_org_id;
1900             end if;
1901 
1902             if p_demand_bucket_type_code  is NOT NULL then
1903                l_line_tbl(l_rec).demand_bucket_type_code := p_demand_bucket_type_code;
1904             end if;
1905 
1906             if p_demand_class_code  is NOT NULL then
1907                l_line_tbl(l_rec).demand_class_code := p_demand_class_code;
1908             end if;
1909 
1910             if p_dep_plan_required_flag  is NOT NULL then
1911                l_line_tbl(l_rec).dep_plan_required_flag := p_dep_plan_required_flag;
1912             end if;
1913 
1914             if p_earliest_acceptable_date  is NOT NULL then
1915                l_line_tbl(l_rec).earliest_acceptable_date := p_earliest_acceptable_date;
1916             end if;
1917 
1918             if p_explosion_date  is NOT NULL then
1919                l_line_tbl(l_rec).explosion_date:= p_explosion_date;
1920             end if;
1921 
1922             if p_fob_point_code  is NOT NULL then
1923                l_line_tbl(l_rec).fob_point_code := p_fob_point_code;
1924             end if;
1925 
1926             if p_freight_carrier_code  is NOT NULL then
1927                l_line_tbl(l_rec).freight_carrier_code := p_freight_carrier_code;
1928             end if;
1929 
1930             if p_freight_terms_code  is NOT NULL then
1931                l_line_tbl(l_rec).freight_terms_code := p_freight_terms_code;
1932             end if;
1933 
1934             if p_fulfilled_quantity  is NOT NULL then
1935                l_line_tbl(l_rec).fulfilled_quantity := p_fulfilled_quantity;
1936             end if;
1937 
1938             if p_global_attribute1  is NOT NULL then
1939                l_line_tbl(l_rec).global_attribute1 := p_global_attribute1;
1940             end if;
1941 
1942             if p_global_attribute2  is NOT NULL then
1943                l_line_tbl(l_rec).global_attribute2 :=p_global_attribute2;
1944             end if;
1945 
1946             if p_global_attribute3  is NOT NULL then
1947                l_line_tbl(l_rec).global_attribute3 := p_global_attribute3;
1948             end if;
1949 
1950             if p_global_attribute4  is NOT NULL then
1951                l_line_tbl(l_rec).global_attribute4 := p_global_attribute4;
1952             end if;
1953 
1954             if p_global_attribute5  is NOT NULL then
1955                l_line_tbl(l_rec).global_attribute5 := p_global_attribute5;
1956             end if;
1957 
1958             if p_global_attribute6  is NOT NULL then
1959                l_line_tbl(l_rec).global_attribute6 := p_global_attribute6;
1960             end if;
1961 
1962             if p_global_attribute7  is NOT NULL then
1963                l_line_tbl(l_rec).global_attribute7 := p_global_attribute7;
1964             end if;
1965 
1966             if p_global_attribute8  is NOT NULL then
1967                l_line_tbl(l_rec).global_attribute8 := p_global_attribute8;
1968             end if;
1969 
1970             if p_global_attribute9  is NOT NULL then
1971                l_line_tbl(l_rec).global_attribute9 := p_global_attribute9;
1972             end if;
1973 
1974             if p_global_attribute10  is NOT NULL then
1975                l_line_tbl(l_rec).global_attribute10 := p_global_attribute10;
1976             end if;
1977 
1978             if p_global_attribute11  is NOT NULL then
1979                l_line_tbl(l_rec).global_attribute11 := p_global_attribute11;
1980             end if;
1981 
1982             if p_global_attribute12  is NOT NULL then
1983                l_line_tbl(l_rec).global_attribute12 := p_global_attribute12;
1984             end if;
1985 
1986             if p_global_attribute13  is NOT NULL then
1987                l_line_tbl(l_rec).global_attribute13 := p_global_attribute13;
1988             end if;
1989 
1990             if p_global_attribute14  is NOT NULL then
1991                l_line_tbl(l_rec).global_attribute14 := p_global_attribute14;
1992             end if;
1993 
1994             if p_global_attribute15  is NOT NULL then
1995                l_line_tbl(l_rec).global_attribute15 := p_global_attribute15;
1996             end if;
1997 
1998             if p_global_attribute16  is NOT NULL then
1999                l_line_tbl(l_rec).global_attribute16 := p_global_attribute16;
2000             end if;
2001 
2002             if p_global_attribute17  is NOT NULL then
2003                l_line_tbl(l_rec).global_attribute17 := p_global_attribute17;
2004             end if;
2005 
2006             if p_global_attribute18  is NOT NULL then
2007                l_line_tbl(l_rec).global_attribute18 := p_global_attribute18;
2008             end if;
2009 
2010             if p_global_attribute19  is NOT NULL then
2011                l_line_tbl(l_rec).global_attribute19 := p_global_attribute19;
2012             end if;
2013 
2014             if p_global_attribute20  is NOT NULL then
2015                l_line_tbl(l_rec).global_attribute20 := p_global_attribute20;
2016             end if;
2017 
2018             if p_global_attribute_category  is NOT NULL then
2019                l_line_tbl(l_rec).global_attribute_category := p_global_attribute_category;
2020             end if;
2021 
2022             if  p_industry_attribute1   is NOT NULL then
2023                l_line_tbl(l_rec).industry_attribute1  :=  p_industry_attribute1 ;
2024             end if;
2025 
2026             if  p_industry_attribute2   is NOT NULL then
2027                l_line_tbl(l_rec).industry_attribute2  :=  p_industry_attribute2 ;
2028             end if;
2029 
2030             if  p_industry_attribute3   is NOT NULL then
2031                l_line_tbl(l_rec).industry_attribute3  :=  p_industry_attribute3 ;
2032             end if;
2033 
2034             if  p_industry_attribute4   is NOT NULL then
2035                l_line_tbl(l_rec).industry_attribute4  :=  p_industry_attribute4 ;
2036             end if;
2037 
2038             if  p_industry_attribute5   is NOT NULL then
2039                l_line_tbl(l_rec).industry_attribute5  :=  p_industry_attribute5 ;
2040             end if;
2041 
2042             if  p_industry_attribute6   is NOT NULL then
2043                l_line_tbl(l_rec).industry_attribute6  :=  p_industry_attribute6 ;
2044             end if;
2045 
2046             if  p_industry_attribute7   is NOT NULL then
2047                l_line_tbl(l_rec).industry_attribute7  :=  p_industry_attribute7 ;
2048             end if;
2049 
2050             if  p_industry_attribute8   is NOT NULL then
2051                l_line_tbl(l_rec).industry_attribute8  :=  p_industry_attribute8 ;
2052             end if;
2053 
2054             if  p_industry_attribute9   is NOT NULL then
2055                l_line_tbl(l_rec).industry_attribute9  :=  p_industry_attribute9 ;
2056             end if;
2057 
2058             if  p_industry_attribute10   is NOT NULL then
2059                l_line_tbl(l_rec).industry_attribute10  :=  p_industry_attribute10 ;
2060             end if;
2061 
2062             if  p_industry_attribute11   is NOT NULL then
2063                l_line_tbl(l_rec).industry_attribute11  :=  p_industry_attribute11 ;
2064             end if;
2065 
2066             if  p_industry_attribute12   is NOT NULL then
2067                l_line_tbl(l_rec).industry_attribute12  :=  p_industry_attribute12 ;
2068             end if;
2069 
2070             if  p_industry_attribute13   is NOT NULL then
2071                l_line_tbl(l_rec).industry_attribute13  :=  p_industry_attribute13 ;
2072             end if;
2073 
2074             if  p_industry_attribute14   is NOT NULL then
2075                l_line_tbl(l_rec).industry_attribute14  :=  p_industry_attribute14 ;
2076             end if;
2077 
2078             if  p_industry_attribute15   is NOT NULL then
2079                l_line_tbl(l_rec).industry_attribute15  :=  p_industry_attribute15 ;
2080             end if;
2081 
2082             if  p_industry_attribute16   is NOT NULL then
2083                l_line_tbl(l_rec).industry_attribute16  :=  p_industry_attribute16 ;
2084             end if;
2085 
2086             if  p_industry_attribute17   is NOT NULL then
2087                l_line_tbl(l_rec).industry_attribute17  :=  p_industry_attribute17 ;
2088             end if;
2089 
2090             if  p_industry_attribute18   is NOT NULL then
2091                l_line_tbl(l_rec).industry_attribute18  :=  p_industry_attribute18 ;
2092             end if;
2093 
2094             if  p_industry_attribute19   is NOT NULL then
2095                l_line_tbl(l_rec).industry_attribute19  :=  p_industry_attribute19 ;
2096             end if;
2097 
2098             if  p_industry_attribute20   is NOT NULL then
2099                l_line_tbl(l_rec).industry_attribute20  :=  p_industry_attribute20 ;
2100             end if;
2101 
2102             if  p_industry_attribute21   is NOT NULL then
2103                l_line_tbl(l_rec).industry_attribute21  :=  p_industry_attribute21 ;
2104             end if;
2105 
2106             if  p_industry_attribute22   is NOT NULL then
2107                l_line_tbl(l_rec).industry_attribute22  :=  p_industry_attribute22 ;
2108             end if;
2109 
2110             if  p_industry_attribute23   is NOT NULL then
2111                l_line_tbl(l_rec).industry_attribute23  :=  p_industry_attribute23 ;
2112             end if;
2113 
2114             if  p_industry_attribute24   is NOT NULL then
2115                l_line_tbl(l_rec).industry_attribute24  :=  p_industry_attribute24 ;
2116             end if;
2117 
2118             if  p_industry_attribute25   is NOT NULL then
2119                l_line_tbl(l_rec).industry_attribute25  :=  p_industry_attribute25 ;
2120             end if;
2121 
2122             if  p_industry_attribute26   is NOT NULL then
2123                l_line_tbl(l_rec).industry_attribute26  :=  p_industry_attribute26 ;
2124             end if;
2125 
2126             if  p_industry_attribute27   is NOT NULL then
2127                l_line_tbl(l_rec).industry_attribute27  :=  p_industry_attribute27 ;
2128             end if;
2129 
2130             if  p_industry_attribute28   is NOT NULL then
2131                l_line_tbl(l_rec).industry_attribute28  :=  p_industry_attribute28 ;
2132             end if;
2133 
2134             if  p_industry_attribute29   is NOT NULL then
2135                l_line_tbl(l_rec).industry_attribute29  :=  p_industry_attribute29 ;
2136             end if;
2137 
2138             if  p_industry_attribute30   is NOT NULL then
2139                l_line_tbl(l_rec).industry_attribute30  :=  p_industry_attribute30 ;
2140             end if;
2141 
2142             if p_industry_context  is NOT NULL then
2143                l_line_tbl(l_rec).industry_context := p_industry_context;
2144             end if;
2145 
2146             if  p_intermed_ship_to_contact_id  is NOT NULL then
2147                l_line_tbl(l_rec).intermed_ship_to_contact_id := p_intermed_ship_to_contact_id;
2148             end if;
2149 
2150             if  p_intermed_ship_to_org_id   is NOT NULL then
2151                l_line_tbl(l_rec).intermed_ship_to_org_id :=p_intermed_ship_to_org_id ;
2152             end if;
2153 
2154             if  p_inventory_item_id is NOT NULL then
2155                l_line_tbl(l_rec).inventory_item_id:=  p_inventory_item_id;
2156             end if;
2157 
2158             if  p_invoice_interface_status is NOT NULL then
2159                l_line_tbl(l_rec).invoice_interface_status_code:= p_invoice_interface_status;
2160             end if;
2161 
2162             if   p_invoice_to_contact_id is NOT NULL then
2163                l_line_tbl(l_rec).invoice_to_contact_id:=  p_invoice_to_contact_id;
2164             end if;
2165 
2166             if  p_invoice_to_org_id is NOT NULL then
2167                l_line_tbl(l_rec).invoice_to_org_id:= p_invoice_to_org_id;
2168             end if;
2169 
2170             if  p_invoicing_rule_id is NOT NULL then
2171                l_line_tbl(l_rec).invoicing_rule_id :=p_invoicing_rule_id;
2172             end if;
2173 
2174             if  p_ordered_item_id is NOT NULL then
2175                l_line_tbl(l_rec).ordered_item_id:=  p_ordered_item_id;
2176             end if;
2177 
2178             if  p_item_identifier_type is NOT NULL then
2179                l_line_tbl(l_rec).item_identifier_type:= p_item_identifier_type;
2180             end if;
2181 
2182             if  p_ordered_item is NOT NULL then
2183                l_line_tbl(l_rec).ordered_item := p_ordered_item;
2184             end if;
2185 
2186             if  p_item_revision is NOT NULL then
2187                l_line_tbl(l_rec).item_revision:= p_item_revision;
2188             end if;
2189 
2190             if p_item_type_code is NOT NULL then
2191                l_line_tbl(l_rec).item_type_code :=p_item_type_code;
2192             end if;
2193 
2194             if p_latest_acceptable_date is NOT NULL then
2195                l_line_tbl(l_rec).latest_acceptable_date := p_latest_acceptable_date;
2196             end if;
2197 
2198             if p_line_category_code is NOT NULL then
2199                l_line_tbl(l_rec).line_category_code:= p_line_category_code;
2200             end if;
2201 
2202             if p_line_id is NOT NULL then
2203                l_line_tbl(l_rec).line_id := p_line_id;
2204             end if;
2205 
2206             if  p_line_number is NOT NULL then
2207                l_line_tbl(l_rec).line_number :=p_line_number;
2208             end if;
2209 
2210             if  p_line_type_id is NOT NULL then
2211                l_line_tbl(l_rec).line_type_id :=p_line_type_id;
2212             end if;
2213 
2214             if   p_link_to_line_id is NOT NULL then
2215                l_line_tbl(l_rec).link_to_line_id  :=p_link_to_line_id;
2216             end if;
2217 
2218             if  p_model_group_number is NOT NULL then
2219                l_line_tbl(l_rec).model_group_number:= p_model_group_number;
2220             end if;
2221 
2222             if  p_option_flag is NOT NULL then
2223                l_line_tbl(l_rec).option_flag := p_option_flag;
2224             end if;
2225 
2226             if  p_option_number is NOT NULL then
2227                l_line_tbl(l_rec).option_number :=p_option_number;
2228             end if;
2229 
2230             if  p_ordered_quantity is NOT NULL then
2231                l_line_tbl(l_rec).ordered_quantity :=p_ordered_quantity;
2232             end if;
2233 
2234             if  p_order_quantity_uom is NOT NULL then
2235                l_line_tbl(l_rec).order_quantity_uom :=p_order_quantity_uom;
2236             end if;
2237 
2238             if  p_orig_sys_document_ref is NOT NULL then
2239                l_line_tbl(l_rec).orig_sys_document_ref :=p_orig_sys_document_ref;
2240             end if;
2241 
2242             if  p_orig_sys_line_ref is NOT NULL then
2243                l_line_tbl(l_rec).orig_sys_line_ref :=p_orig_sys_line_ref;
2244             end if;
2245 
2246             if  p_payment_term_id is NOT NULL then
2247                l_line_tbl(l_rec).payment_term_id :=p_payment_term_id;
2248             end if;
2249 
2250             if  p_price_list_id is NOT NULL then
2251                l_line_tbl(l_rec).price_list_id :=p_price_list_id;
2252             end if;
2253 
2254             if  p_pricing_attribute1 is NOT NULL then
2255                l_line_tbl(l_rec).pricing_attribute1:= p_pricing_attribute1;
2256             end if;
2257 
2258             if  p_pricing_attribute10 is NOT NULL then
2259                l_line_tbl(l_rec).pricing_attribute10 :=p_pricing_attribute10;
2260             end if;
2261 
2262             if  p_pricing_attribute2 is NOT NULL then
2263                l_line_tbl(l_rec).pricing_attribute2 :=p_pricing_attribute2;
2264             end if;
2265 
2266             if  p_pricing_attribute3 is NOT NULL then
2267                l_line_tbl(l_rec).pricing_attribute3 :=p_pricing_attribute3;
2268             end if;
2269 
2270             if  p_pricing_attribute4 is NOT NULL then
2271                l_line_tbl(l_rec).pricing_attribute4 :=p_pricing_attribute4;
2272             end if;
2273 
2274             if  p_pricing_attribute5 is NOT NULL then
2275                l_line_tbl(l_rec).pricing_attribute5 :=p_pricing_attribute5;
2276             end if;
2277 
2278             if  p_pricing_attribute6 is NOT NULL then
2279                l_line_tbl(l_rec).pricing_attribute6 :=p_pricing_attribute6;
2280             end if;
2281 
2282             if  p_pricing_attribute7 is NOT NULL then
2283                l_line_tbl(l_rec).pricing_attribute7 :=p_pricing_attribute7;
2284             end if;
2285 
2286             if  p_pricing_attribute8 is NOT NULL then
2287                l_line_tbl(l_rec).pricing_attribute8 :=p_pricing_attribute8;
2288             end if;
2289 
2290             if  p_pricing_attribute9 is NOT NULL then
2291                l_line_tbl(l_rec).pricing_attribute9 :=p_pricing_attribute9;
2292             end if;
2293 
2294             if  p_pricing_context is NOT NULL then
2295                l_line_tbl(l_rec).pricing_context :=p_pricing_context;
2296             end if;
2297 
2298             if   p_pricing_date is NOT NULL then
2299                l_line_tbl(l_rec).pricing_date  :=p_pricing_date;
2300             end if;
2301 
2302             if   p_pricing_quantity is NOT NULL then
2303                l_line_tbl(l_rec).pricing_quantity :=p_pricing_quantity;
2304             end if;
2305 
2306             if   p_pricing_quantity_uom is NOT NULL then
2307                l_line_tbl(l_rec).pricing_quantity_uom:= p_pricing_quantity_uom;
2308             end if;
2309 
2310             if   p_project_id is NOT NULL then
2311                l_line_tbl(l_rec).project_id:= p_project_id;
2312             end if;
2313 
2314             if   p_promise_date is NOT NULL then
2315                l_line_tbl(l_rec).promise_date:= p_promise_date;
2316             end if;
2317 
2318             if    p_reference_header_id is NOT NULL then
2319                l_line_tbl(l_rec).reference_header_id  :=p_reference_header_id;
2320             end if;
2321 
2322             if  p_reference_line_id is NOT NULL then
2323                l_line_tbl(l_rec).reference_line_id :=p_reference_line_id;
2324             end if;
2325 
2326             if   p_reference_type is NOT NULL then
2327                l_line_tbl(l_rec).reference_type :=p_reference_type;
2328             end if;
2329 
2330             if    p_request_date  is NOT NULL then
2331                l_line_tbl(l_rec).request_date   :=p_request_date ;
2332             end if;
2333 
2334             if    p_reserved_quantity  is NOT NULL then
2335                l_line_tbl(l_rec).reserved_quantity :=p_reserved_quantity;
2336             end if;
2337 
2338             if    p_return_attribute1  is NOT NULL then
2339                l_line_tbl(l_rec).return_attribute1 :=p_return_attribute1;
2340             end if;
2341 
2342             if    p_return_attribute10  is NOT NULL then
2343                l_line_tbl(l_rec).return_attribute10 :=p_return_attribute10;
2344             end if;
2345 
2346             if    p_return_attribute11  is NOT NULL then
2347                l_line_tbl(l_rec).return_attribute11 :=p_return_attribute11;
2348             end if;
2349 
2350             if    p_return_attribute12  is NOT NULL then
2351                l_line_tbl(l_rec).return_attribute12 :=p_return_attribute12;
2352             end if;
2353 
2354             if    p_return_attribute13  is NOT NULL then
2355                l_line_tbl(l_rec).return_attribute13 :=p_return_attribute13;
2356             end if;
2357 
2358             if    p_return_attribute14  is NOT NULL then
2359                l_line_tbl(l_rec).return_attribute14 :=p_return_attribute14;
2360             end if;
2361 
2362             if    p_return_attribute2  is NOT NULL then
2363                l_line_tbl(l_rec).return_attribute2 :=p_return_attribute2;
2364             end if;
2365 
2366             if    p_return_attribute3  is NOT NULL then
2367                l_line_tbl(l_rec).return_attribute3 :=p_return_attribute3;
2368             end if;
2369 
2370             if    p_return_attribute4  is NOT NULL then
2371                l_line_tbl(l_rec).return_attribute4 :=p_return_attribute4;
2372             end if;
2373 
2374             if    p_return_attribute5  is NOT NULL then
2375                l_line_tbl(l_rec).return_attribute5 :=p_return_attribute5;
2376             end if;
2377 
2378             if    p_return_attribute6  is NOT NULL then
2379                l_line_tbl(l_rec).return_attribute6 :=p_return_attribute6;
2380             end if;
2381 
2382             if    p_return_attribute7  is NOT NULL then
2383                l_line_tbl(l_rec).return_attribute7 :=p_return_attribute7;
2384             end if;
2385 
2386             if    p_return_attribute8  is NOT NULL then
2387                l_line_tbl(l_rec).return_attribute8 :=p_return_attribute8;
2388             end if;
2389 
2390             if    p_return_attribute9  is NOT NULL then
2391                l_line_tbl(l_rec).return_attribute9 :=p_return_attribute9;
2392             end if;
2393 
2394             if    p_return_context  is NOT NULL then
2395                l_line_tbl(l_rec).return_context :=p_return_context;
2396             end if;
2397 
2398             if  p_rla_schedule_type_code  is NOT NULL then
2399                l_line_tbl(l_rec).rla_schedule_type_code :=p_rla_schedule_type_code;
2400             end if;
2401 
2402             if    p_schedule_arrival_date  is NOT NULL then
2403                l_line_tbl(l_rec).schedule_arrival_date :=p_schedule_arrival_date;
2404             end if;
2405 
2406             if    p_schedule_ship_date  is NOT NULL then
2407                l_line_tbl(l_rec).schedule_ship_date :=p_schedule_ship_date;
2408             end if;
2409 
2410             if    p_schedule_action_code  is NOT NULL then
2411                l_line_tbl(l_rec).schedule_action_code :=p_schedule_action_code;
2412             end if;
2413 
2414             if    p_schedule_status_code  is NOT NULL then
2415                l_line_tbl(l_rec).schedule_status_code :=p_schedule_status_code;
2416             end if;
2417 
2418             if    p_shipped_quantity  is NOT NULL then
2419                l_line_tbl(l_rec).shipped_quantity :=p_shipped_quantity;
2420             end if;
2421 
2422             if    p_shipment_number  is NOT NULL then
2423                l_line_tbl(l_rec).shipment_number :=p_shipment_number;
2424             end if;
2425 
2426             if     p_shipment_priority_code  is NOT NULL then
2427                l_line_tbl(l_rec).shipment_priority_code  :=p_shipment_priority_code;
2428             end if;
2429 
2430             if    p_shipping_method_code  is NOT NULL then
2431                l_line_tbl(l_rec).shipping_method_code:=p_shipping_method_code;
2432             end if;
2433 
2434             if    p_shipping_quantity  is NOT NULL then
2435                l_line_tbl(l_rec).shipping_quantity :=p_shipping_quantity;
2436             end if;
2437 
2438             if    p_shipping_quantity_uom  is NOT NULL then
2439                l_line_tbl(l_rec).shipping_quantity_uom :=p_shipping_quantity_uom;
2440             end if;
2441 
2442             if    p_ship_from_org_id  is NOT NULL then
2443                l_line_tbl(l_rec).ship_from_org_id :=p_ship_from_org_id;
2444             end if;
2445 
2446             if    p_ship_tolerance_above  is NOT NULL then
2447                l_line_tbl(l_rec).ship_tolerance_above :=p_ship_tolerance_above;
2448             end if;
2449 
2450             if    p_ship_tolerance_below  is NOT NULL then
2451                l_line_tbl(l_rec).ship_tolerance_below :=p_ship_tolerance_below;
2452             end if;
2453 
2454             if    p_shipping_interfaced_flag  is NOT NULL then
2455                l_line_tbl(l_rec).shipping_interfaced_flag :=p_shipping_interfaced_flag;
2456             end if;
2457 
2458             if    p_ship_to_contact_id  is NOT NULL then
2459                l_line_tbl(l_rec).ship_to_contact_id:=p_ship_to_contact_id;
2460             end if;
2461 
2462             if    p_ship_to_org_id  is NOT NULL then
2463                l_line_tbl(l_rec).ship_to_org_id :=p_ship_to_org_id;
2464             end if;
2465 
2466             if     p_ship_model_complete_flag  is NOT NULL then
2467                l_line_tbl(l_rec).ship_model_complete_flag := p_ship_model_complete_flag;
2468             end if;
2469 
2470             if    p_sold_to_org_id  is NOT NULL then
2471                l_line_tbl(l_rec).sold_to_org_id:=p_sold_to_org_id;
2472             end if;
2473 
2474             if    p_sort_order  is NOT NULL then
2475                l_line_tbl(l_rec).sort_order :=p_sort_order;
2476             end if;
2477 
2478             if    p_source_document_id  is NOT NULL then
2479                l_line_tbl(l_rec).source_document_id:=p_source_document_id;
2480             end if;
2481 
2482             if    p_source_document_line_id  is NOT NULL then
2483                l_line_tbl(l_rec).source_document_line_id :=p_source_document_line_id;
2484             end if;
2485 
2486             if    p_source_document_type_id  is NOT NULL then
2487                l_line_tbl(l_rec).source_document_type_id :=p_source_document_type_id;
2488             end if;
2489 
2490             if    p_source_type_code  is NOT NULL then
2491                l_line_tbl(l_rec).source_type_code :=p_source_type_code;
2492             end if;
2493 
2494             if    p_task_id  is NOT NULL then
2495                l_line_tbl(l_rec).task_id :=p_task_id;
2496             end if;
2497 
2498             if    p_tax_code  is NOT NULL then
2499                l_line_tbl(l_rec).tax_code :=p_tax_code;
2500             end if;
2501 
2502             if    p_tax_date is NOT NULL then
2503                l_line_tbl(l_rec).tax_date :=p_tax_date;
2504             end if;
2505 
2506             if     p_tax_exempt_flag  is NOT NULL then
2507                l_line_tbl(l_rec).tax_exempt_flag := p_tax_exempt_flag;
2508             end if;
2509 
2510             if    p_tax_exempt_number  is NOT NULL then
2511                l_line_tbl(l_rec).tax_exempt_number :=p_tax_exempt_number;
2512             end if;
2513 
2514             if    p_tax_exempt_reason_code  is NOT NULL then
2515                l_line_tbl(l_rec).tax_exempt_reason_code :=p_tax_exempt_reason_code;
2516             end if;
2517 
2518             if    p_tax_point_code  is NOT NULL then
2519                l_line_tbl(l_rec).tax_point_code :=p_tax_point_code;
2520             end if;
2521 
2522             if    p_tax_rate  is NOT NULL then
2523                l_line_tbl(l_rec).tax_rate :=p_tax_rate;
2524             end if;
2525 
2526             if    p_tax_value  is NOT NULL then
2527                l_line_tbl(l_rec).tax_value :=p_tax_value;
2528             end if;
2529 
2530             if    p_top_model_line_id  is NOT NULL then
2531                l_line_tbl(l_rec).top_model_line_id :=p_top_model_line_id;
2532             end if;
2533 
2534             if    p_unit_list_price  is NOT NULL then
2535                l_line_tbl(l_rec).unit_list_price :=p_unit_list_price;
2536             end if;
2537 
2538             if    p_unit_selling_price  is NOT NULL then
2539                l_line_tbl(l_rec).unit_selling_price :=p_unit_selling_price;
2540                --  bug 3926188 l_line_tbl(l_rec).calculate_price_flag := 'P';
2541             end if;
2542 
2543             if  p_visible_demand_flag  is NOT NULL then
2544                l_line_tbl(l_rec).visible_demand_flag :=p_visible_demand_flag;
2545             end if;
2546 
2547 
2548             if     p_split_from_line_id  is NOT NULL then
2549                l_line_tbl(l_rec).split_from_line_id := p_split_from_line_id;
2550             end if;
2551 
2552             if    p_cust_production_seq_num  is NOT NULL then
2553                l_line_tbl(l_rec).cust_production_seq_num :=p_cust_production_seq_num;
2554             end if;
2555 
2556             if    p_authorized_to_ship_flag  is NOT NULL then
2557                l_line_tbl(l_rec).authorized_to_ship_flag :=p_authorized_to_ship_flag;
2558             end if;
2559 
2560             if    p_veh_cus_item_cum_key_id  is NOT NULL then
2561                l_line_tbl(l_rec).veh_cus_item_cum_key_id :=p_veh_cus_item_cum_key_id;
2562             end if;
2563 
2564             if     p_salesrep_id  is NOT NULL then
2565                l_line_tbl(l_rec).salesrep_id:= p_salesrep_id;
2566             end if;
2567 
2568             if    p_return_reason_code  is NOT NULL then
2569                l_line_tbl(l_rec).return_reason_code :=p_return_reason_code;
2570             end if;
2571 
2572             if p_arrival_set_id  is NOT NULL then
2573                l_line_tbl(l_rec).arrival_set_id :=p_arrival_set_id;
2574             end if;
2575 
2576             if    p_ship_set_id  is NOT NULL then
2577                l_line_tbl(l_rec).ship_set_id :=p_ship_set_id;
2578             end if;
2579 
2580             if    p_over_ship_reason_code  is NOT NULL then
2581                l_line_tbl(l_rec).over_ship_reason_code :=p_over_ship_reason_code;
2582             end if;
2583 
2584             if    p_over_ship_resolved_flag  is NOT NULL then
2585                l_line_tbl(l_rec).over_ship_resolved_flag :=p_over_ship_resolved_flag;
2586             end if;
2587 
2588             if     p_first_ack_code  is NOT NULL then
2589                l_line_tbl(l_rec).first_ack_code := p_first_ack_code;
2590             end if;
2591 
2592             if    p_first_ack_date  is NOT NULL then
2593                l_line_tbl(l_rec).first_ack_date:=p_first_ack_date;
2594             end if;
2595 
2596             if    p_last_ack_code  is NOT NULL then
2597                l_line_tbl(l_rec).last_ack_code:=p_last_ack_code;
2598             end if;
2599 
2600             if    p_last_ack_date  is NOT NULL then
2601                l_line_tbl(l_rec).last_ack_date:=p_last_ack_date;
2602             end if;
2603 
2604             if    p_service_txn_reason_code is NOT NULL then
2605                l_line_tbl(l_rec).service_txn_reason_code := p_service_txn_reason_code;
2606             end if;
2607 
2608             if    p_service_txn_comments is NOT NULL then
2609                l_line_tbl(l_rec).service_txn_comments := p_service_txn_comments;
2610             end if;
2611 
2612             if    p_unit_selling_percent is NOT NULL then
2613                l_line_tbl(l_rec).unit_selling_percent := p_unit_selling_percent;
2614             end if;
2615 
2616             if    p_unit_list_percent is NOT NULL then
2617                l_line_tbl(l_rec).unit_list_percent := p_unit_list_percent;
2618             end if;
2619 
2620             if    p_unit_percent_base_price is NOT NULL then
2621                l_line_tbl(l_rec).unit_percent_base_price := p_unit_percent_base_price;
2622             end if;
2623 
2624             if    p_service_duration is NOT NULL then
2625                l_line_tbl(l_rec).service_duration := p_service_duration;
2626             end if;
2627 
2628             if    p_service_start_date is NOT NULL then
2629                l_line_tbl(l_rec).service_start_date := p_service_start_date;
2630             end if;
2631 
2632             if    p_service_period is NOT NULL then
2633                l_line_tbl(l_rec).service_period := p_service_period;
2634             end if;
2635 
2636             if    p_service_end_date is NOT NULL then
2637                l_line_tbl(l_rec).service_end_date := p_service_end_date;
2638             end if;
2639 
2640             if    p_service_coterminate_flag is NOT NULL then
2641                l_line_tbl(l_rec).service_coterminate_flag := p_service_coterminate_flag;
2642             end if;
2643 
2644             if    p_service_number is NOT NULL then
2645                l_line_tbl(l_rec).service_number := p_service_number;
2646             end if;
2647 
2648             if    p_service_reference_type_code is NOT NULL then
2649                l_line_tbl(l_rec).service_reference_type_code := p_service_reference_type_code;
2650             end if;
2651 
2652             if    p_service_reference_line_id is NOT NULL then
2653                l_line_tbl(l_rec).service_reference_line_id := p_service_reference_line_id;
2654             end if;
2655 
2656             if    p_service_reference_system_id is NOT NULL then
2657                l_line_tbl(l_rec).service_reference_system_id := p_service_reference_system_id;
2658             end if;
2659 
2660             if p_tp_context  is NOT NULL then
2661                l_line_tbl(l_rec).tp_context := p_tp_context;
2662             end if;
2663 
2664             if p_tp_attribute1  is NOT NULL then
2665                l_line_tbl(l_rec).tp_attribute1 := p_tp_attribute1;
2666             end if;
2667 
2668             if p_tp_attribute2  is NOT NULL then
2669                l_line_tbl(l_rec).tp_attribute2 := p_tp_attribute2;
2670             end if;
2671 
2672             if p_tp_attribute3  is NOT NULL then
2673                l_line_tbl(l_rec).tp_attribute3 := p_tp_attribute3;
2674             end if;
2675 
2676             if p_tp_attribute4  is NOT NULL then
2677                l_line_tbl(l_rec).tp_attribute4 := p_tp_attribute4;
2678             end if;
2679 
2680             if p_tp_attribute5  is NOT NULL then
2681                l_line_tbl(l_rec).tp_attribute5 := p_tp_attribute5;
2682             end if;
2683 
2684             if p_tp_attribute6  is NOT NULL then
2685                l_line_tbl(l_rec).tp_attribute6 := p_tp_attribute6;
2686             end if;
2687 
2688             if p_tp_attribute7  is NOT NULL then
2689                l_line_tbl(l_rec).tp_attribute7 := p_tp_attribute7;
2690             end if;
2691 
2692             if p_tp_attribute8  is NOT NULL then
2693                l_line_tbl(l_rec).tp_attribute8 := p_tp_attribute8;
2694             end if;
2695 
2696             if p_tp_attribute9  is NOT NULL then
2697                l_line_tbl(l_rec).tp_attribute9 := p_tp_attribute9;
2698             end if;
2699 
2700             if p_tp_attribute10  is NOT NULL then
2701                l_line_tbl(l_rec).tp_attribute10 := p_tp_attribute10;
2702             end if;
2703 
2704             if p_tp_attribute11  is NOT NULL then
2705                l_line_tbl(l_rec).tp_attribute11 := p_tp_attribute11;
2706             end if;
2707 
2708             if p_tp_attribute12  is NOT NULL then
2709                l_line_tbl(l_rec).tp_attribute12 := p_tp_attribute12;
2710             end if;
2711 
2712             if p_tp_attribute13  is NOT NULL then
2713                l_line_tbl(l_rec).tp_attribute13 := p_tp_attribute13;
2714             end if;
2715 
2716             if p_tp_attribute14  is NOT NULL then
2717                l_line_tbl(l_rec).tp_attribute14 := p_tp_attribute14;
2718             end if;
2719 
2720             if p_tp_attribute15  is NOT NULL then
2721                l_line_tbl(l_rec).tp_attribute15 := p_tp_attribute15;
2722             end if;
2723 
2724             if p_calculate_price_flag  is NOT NULL then
2725                l_line_tbl(l_rec).calculate_price_flag := p_calculate_price_flag;
2726             end if;
2727 
2728             if p_end_customer_contact_id is not null then
2729                l_line_tbl(l_rec).end_customer_contact_id := p_end_customer_contact_id;
2730             end if;
2731 
2732             if p_end_customer_id is not null then
2733                l_line_tbl(l_rec).end_customer_id :=  p_end_customer_id;
2734             end if;
2735 
2736             if  p_end_customer_site_use_id is not null then
2737                l_line_tbl(l_rec).end_customer_site_use_id := p_end_customer_site_use_id;
2738             end if;
2739 
2740             if  p_ib_owner is not null then
2741                l_line_tbl(l_rec).ib_owner := p_ib_owner;
2742             end if;
2743 
2744             if  p_ib_installed_at_location  is not null then
2745                l_line_tbl(l_rec).ib_installed_at_location := p_ib_installed_at_location;
2746             end if;
2747 
2748             if  p_ib_current_location  is not null then
2749                l_line_tbl(l_rec).ib_current_location := p_ib_current_location;
2750             end if;
2751 
2752             FETCH c1 into l_line_id, l_current_org_id, l_header_id, l_arrival_set_id,
2753                           l_ship_set_id, l_top_model_line_id;
2754             EXIT WHEN c1%notfound;
2755             --- Start bug 6850537,7210480
2756 
2757            IF l_header_id <> l_old_header_id
2758             THEN
2759               IF l_debug_level>0 THEN
2760                 oe_debug_pub.ADD('header id got changed'||l_header_id||' '||l_old_header_id);
2761                END IF;
2762              G_HEADER_CHANGED :=1;
2763 
2764              --Bug 7566697
2765              l_header_changed := TRUE;
2766            ELSE
2767              l_header_changed := FALSE;
2768            END IF;
2769 
2770         -- End bug 6850537 ,7210480
2771 
2772             -- If all old values are null then old line was a standard line.
2773             if ( l_old_arrival_set_id is null
2774                  and l_old_ship_set_id is null
2775                  and l_old_top_model_line_id is null )
2776             then
2777                exit;
2778             end if;
2779 
2780             if l_header_id <> l_old_header_id or
2781                nvl(l_arrival_set_id, 0) <> nvl(l_old_arrival_set_id, 0) or
2782                nvl(l_ship_set_id, 0) <> nvl(l_old_ship_set_id, 0) or
2783                nvl(l_top_model_line_id, 0) <> nvl(l_old_top_model_line_id, 0)
2784             then
2785                exit;
2786             end if;
2787 
2788          END LOOP;
2789 
2790          l_control_rec.controlled_operation := TRUE;
2791          l_control_rec.process              := FALSE;
2792          l_control_rec.process_entity       := OE_GLOBALS.G_ENTITY_ALL;
2793          l_control_rec.Process_Partial      := FALSE;
2794          l_control_rec.check_security       := TRUE;
2795          l_control_rec.clear_dependents     := TRUE;
2796          l_control_rec.default_attributes   := TRUE;
2797          l_control_rec.change_attributes    := TRUE;
2798          l_control_rec.validate_entity      := TRUE;
2799          l_control_rec.write_to_DB          := TRUE;
2800 
2801          --bug4529937 start --bug 6850537,7210480 added  p_block_name='LINES_SUMMARY'
2802          IF p_block_name = 'LINE' or p_block_name='LINES_SUMMARY' THEN
2803             G_NUM_OF_LINES := G_NUM_OF_LINES - l_line_tbl.count;
2804          END IF;
2805 
2806          IF l_debug_level > 0 THEN
2807             oe_debug_pub.add('Lines Remaining: ' || G_NUM_OF_LINES);
2808             OE_DEBUG_PUB.Add('Before Call to Process Order From MC');
2809          END IF;
2810          --bug4529937 end
2811 
2812          -- bug 4339639
2813          OE_Versioning_Util.G_UI_CALLED := TRUE;
2814 
2815          Oe_Order_Pvt.Lines
2816             (   p_validation_level            => FND_API.G_VALID_LEVEL_FULL,
2817                 p_init_msg_list               => l_init_msg_list,
2818                 p_control_rec                 => l_control_rec,
2819                 p_x_line_tbl                  => l_line_tbl,
2820                 p_x_old_line_tbl              => l_old_line_tbl,
2821                 x_return_status               => l_return_status);
2822 
2823          IF l_debug_level > 0 THEN
2824             OE_DEBUG_PUB.Add('After Call to Process Order From MC - ' || l_return_status);
2825          END IF;
2826 
2827          IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2828             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2829          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2830             RAISE FND_API.G_EXC_ERROR;
2831          END IF;
2832 
2833          l_control_rec.controlled_operation := TRUE;
2834          l_control_rec.process              := TRUE;
2835          l_control_rec.process_entity       := OE_GLOBALS.G_ENTITY_ALL;
2836 
2837          l_control_rec.check_security       := FALSE;
2838          l_control_rec.clear_dependents     := FALSE;
2839          l_control_rec.default_attributes   := FALSE;
2840          l_control_rec.change_attributes    := FALSE;
2841          l_control_rec.validate_entity      := FALSE;
2842          l_control_rec.write_to_DB          := FALSE;
2843 
2844          --  Instruct API to clear its request table
2845 
2846          l_control_rec.clear_api_cache      := FALSE;
2847          l_control_rec.clear_api_requests   := TRUE;
2848 
2849          oe_line_util.Post_Line_Process
2850             (   p_control_rec    => l_control_rec,
2851                 p_x_line_tbl   => l_line_tbl );
2852 
2853          -- added a call to PRN for bug 4882981
2854          OE_Order_PVT.Process_Requests_And_Notify
2855                    ( p_process_requests          => TRUE,
2856                      p_notify                    => TRUE,
2857                      x_return_status             => l_return_status,
2858                      p_old_line_tbl                  => l_old_line_tbl,
2859                      p_line_tbl              => l_line_tbl) ;
2860 
2861          IF l_debug_level > 0 THEN
2862             oe_debug_pub.ADD('OEXVMSCB: Completed Process_Delayed_Requests '
2863                              || ' with return status' || l_return_status, 2);
2864          END IF;
2865          G_HEADER_CHANGED :=NULL ;  -- - bug 6850537,7210480
2866          -- Bug 1809955
2867          -- Display any errors/messages that were caused
2868          -- as a result of the delayed request execution
2869          OE_MSG_PUB.Count_and_Get(p_count => p_msg_count,
2870                                   p_data => p_msg_data);
2871 
2872          IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2873             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2874          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2875             RAISE FND_API.G_EXC_ERROR;
2876          END IF;
2877       EXCEPTION
2878 
2879          WHEN FND_API.G_EXC_ERROR THEN
2880             IF l_debug_level > 0 THEN
2881                oe_debug_pub.ADD('Exception - FND_API.G_EXC_ERROR');
2882             END IF;
2883 
2884             p_return_status := FND_API.G_RET_STS_ERROR ;
2885             OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
2886             OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
2887 
2888             oe_delayed_requests_pvt.Clear_Request(x_return_status=> l_return_status);
2889 
2890             OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
2891 
2892             IF l_debug_level > 0 THEN
2893                oe_debug_pub.ADD ('OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT - '
2894                                  || OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT);
2895             END IF;
2896 
2897             IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- moved for the bug 3726337
2898                OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
2899             END IF;
2900 
2901             OE_MSG_PUB.Count_And_Get ( p_count => p_msg_count,
2902                                        p_data  => p_msg_data);
2903 
2904             l_error_count := l_error_count + 1;
2905             p_error_count := l_error_count;
2906 
2907             IF l_debug_level > 0 THEN
2908                oe_debug_pub.ADD ('l_line_tbl.count - ' || l_line_tbl.count);
2909             END IF;
2910 
2911             IF (l_line_tbl.count >0 ) then
2912                G_ERROR_COUNT := G_ERROR_COUNT +  l_line_tbl.COUNT;
2913             END IF;
2914 
2915             ROLLBACK TO SAVEPOINT Process_Line_Scalar;
2916 
2917             --Bug 7566697
2918             OE_Globals.G_PRICING_RECURSION := 'N';
2919             IF OE_MASS_CHANGE_PVT.G_PRICING_ERROR = 'Y'
2920             THEN
2921                oe_debug_pub.add('Pricing error has occured. Rolling back changes done to all lines');
2922                ROLLBACK TO SAVEPOINT Pricing_Header_Savepoint;
2923             END IF;
2924 
2925             IF l_debug_level > 0 THEN
2926                oe_debug_pub.ADD ('l_mc_err_handling_flag - ' || l_mc_err_handling_flag);
2927             END IF;
2928 
2929             if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
2930                OE_DEBUG_PUB.Add('EXIT_FIRST_ERROR  SKIP_CONTINUE');
2931                exit;
2932             else
2933                OE_DEBUG_PUB.Add('SKIP_ALL');
2934             end if;
2935 
2936          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2937             IF l_debug_level > 0 THEN
2938                oe_debug_pub.ADD('Exception - FND_API.G_EXC_UNEXPECTED_ERROR');
2939             END IF;
2940 
2941             p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2942             OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
2943             OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
2944 
2945             oe_delayed_requests_pvt.Clear_Request(x_return_status=> l_return_status);
2946 
2947             OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
2948 
2949             IF l_debug_level > 0 THEN
2950                oe_debug_pub.ADD ('OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT - '
2951                                  || OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT);
2952             END IF;
2953 
2954             IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- moved for the bug 3726337
2955                OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
2956             END IF;
2957 
2958             OE_MSG_PUB.Count_And_Get( p_count => p_msg_count,
2959                                       p_data  => p_msg_data);
2960 
2961             l_error_count := l_error_count + 1;
2962             p_error_count := l_error_count;
2963 
2964             IF l_debug_level > 0 THEN
2965                oe_debug_pub.ADD ('l_line_tbl.count - ' || l_line_tbl.count);
2966             END IF;
2967 
2968             IF (l_line_tbl.count >0 ) then
2969                G_ERROR_COUNT := G_ERROR_COUNT +  l_line_tbl.COUNT;
2970             END IF;
2971 
2972             ROLLBACK TO SAVEPOINT Process_Line_Scalar;
2973 
2974             --Bug 7566697
2975             OE_Globals.G_PRICING_RECURSION := 'N';
2976             IF OE_MASS_CHANGE_PVT.G_PRICING_ERROR = 'Y'
2977             THEN
2978                oe_debug_pub.add('Pricing error has occured. Rolling back changes done to all lines');
2979                ROLLBACK TO SAVEPOINT Pricing_Header_Savepoint;
2980             END IF;
2981 
2982             IF l_debug_level > 0 THEN
2983                oe_debug_pub.ADD ('l_mc_err_handling_flag - ' || l_mc_err_handling_flag);
2984             END IF;
2985 
2986             if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
2987                OE_DEBUG_PUB.Add('EXIT_FIRST_ERROR  SKIP_CONTINUE');
2988                exit;
2989             else
2990                OE_DEBUG_PUB.Add('SKIP_ALL');
2991             end if;
2992 
2993          WHEN OTHERS THEN
2994             IF l_debug_level > 0 THEN
2995                oe_debug_pub.ADD('Exception - FND_API.G_EXC_ERROR');
2996             END IF;
2997 
2998             p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2999             OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
3000             OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
3001 
3002             oe_delayed_requests_pvt.Clear_Request(x_return_status=> l_return_status);
3003 
3004             OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
3005 
3006             IF l_debug_level > 0 THEN
3007                oe_debug_pub.ADD ('OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT - '
3008                                  || OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT);
3009             END IF;
3010 
3011             IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- moved for the bug 3726337
3012                OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
3013             END IF;
3014 
3015             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
3016                OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME,
3017                                        l_api_name);
3018             END IF;
3019 
3020             OE_MSG_PUB.Count_And_Get ( p_count => p_msg_count,
3021                                        p_data  => p_msg_data);
3022 
3023             l_error_count := l_error_count + 1;
3024             p_error_count := l_error_count;
3025 
3026             IF l_debug_level > 0 THEN
3027                oe_debug_pub.ADD ('l_line_tbl.count - ' || l_line_tbl.count);
3028             END IF;
3029 
3030             IF (l_line_tbl.count >0 ) then
3031                G_ERROR_COUNT := G_ERROR_COUNT +  l_line_tbl.COUNT;
3032             END IF;
3033 
3034             ROLLBACK TO SAVEPOINT Process_Line_Scalar;
3035 
3036             --Bug 7566697
3037             OE_Globals.G_PRICING_RECURSION := 'N';
3038             IF OE_MASS_CHANGE_PVT.G_PRICING_ERROR = 'Y'
3039             THEN
3040                oe_debug_pub.add('Pricing error has occured. Rolling back changes done to all lines');
3041                ROLLBACK TO SAVEPOINT Pricing_Header_Savepoint;
3042             END IF;
3043 
3044 
3045             IF l_debug_level > 0 THEN
3046                oe_debug_pub.ADD ('l_mc_err_handling_flag - ' || l_mc_err_handling_flag);
3047             END IF;
3048 
3049             if l_mc_err_handling_flag in (EXIT_FIRST_ERROR,SKIP_CONTINUE) then
3050                OE_DEBUG_PUB.Add('EXIT_FIRST_ERROR  SKIP_CONTINUE');
3051                exit;
3052             else
3053                OE_DEBUG_PUB.Add('SKIP_ALL');
3054             end if;
3055       END;
3056 
3057       exit when c1%notfound;
3058    END LOOP;
3059 
3060    G_BLK_NAME := NULL;
3061    G_NUM_OF_LINES := NULL;
3062 G_HEADER_CHANGED :=NULL ;  -- - bug 6850537,7210480
3063    IS_MASS_CHANGE := 'F'; --Added for bug 4911340
3064 
3065    IF l_debug_level > 0 THEN
3066       oe_debug_pub.add('Exiting OE_MASS_CHANGE_PVT.Process_Line_Scalar');
3067    END IF;
3068 end Process_Line_Scalar;
3069 
3070 Procedure MC_Rollback
3071 IS
3072 begin
3073   rollback;
3074 end;
3075 
3076 Procedure Set_Counter
3077 IS
3078 begin
3079    G_COUNTER := 0;
3080 end;
3081 
3082 Function Get_Counter  return NUMBER
3083 IS
3084 begin
3085    return G_COUNTER;
3086 end;
3087 
3088 Procedure Set_Error_Count
3089 IS
3090 begin
3091    G_ERROR_COUNT := 0;
3092 end;
3093 
3094 Function Get_Error_Count  return NUMBER
3095 IS
3096 begin
3097    return G_ERROR_COUNT;
3098 end;
3099 
3100 Procedure save_messages
3101 IS
3102 l_count_msg NUMBER := OE_MSG_PUB.Count_Msg;
3103 begin
3104    OE_DEBUG_PUB.ADD('Inside save_messages',1);
3105    FOR I IN 1..l_count_msg  LOOP
3106    OE_DEBUG_PUB.ADD('calling insert_message',1);
3107     insert_message(I);
3108    End Loop;
3109    OE_DEBUG_PUB.ADD('exiting save_messages',1);
3110    commit;
3111 end;
3112 
3113 procedure insert_message (
3114          p_msg_index         IN NUMBER )
3115 IS
3116 l_msg_data        	       VARCHAR2(2000);
3117 l_entity_code                  VARCHAR2(30);
3118 l_entity_id                    NUMBER;
3119 l_header_id                    NUMBER;
3120 l_line_id                      NUMBER;
3121 l_orig_sys_document_ref        VARCHAR2(50);
3122 l_orig_sys_document_line_ref   VARCHAR2(50);
3123 l_source_document_id           NUMBER;
3124 l_source_document_line_id      NUMBER;
3125 l_attribute_code               VARCHAR2(30);
3126 
3127 BEGIN
3128  l_msg_data := OE_MSG_PUB.get(p_msg_index, 'F');
3129 
3130  /*OE_MSG_PUB.get_msg_context(
3131          p_msg_index
3132 	,l_entity_code
3133 	,l_entity_id
3134 	,l_header_id
3135 	,l_line_id
3136 	,l_orig_sys_document_ref
3137 	,l_orig_sys_document_line_ref
3138 	,l_source_document_id
3139 	,l_source_document_line_id
3140 	,l_attribute_code);*/
3141 
3142 OE_DEBUG_PUB.ADd('l_msg_data='||l_msg_data);
3143 
3144 /*
3145 if p_msg_index IS NOT NULL then
3146    insert into OE_ERROR_MESSAGES
3147    (  Transaction_id
3148      ,batch_request_Id
3149      ,message_text
3150      ,entity_code
3151      ,entity_id
3152      ,header_id
3153      ,line_id
3154      ,original_sys_document_ref
3155      ,original_sys_document_line_ref
3156      ,source_document_id
3157      ,source_document_line_id
3158      ,attribute_code
3159      ,CREATION_DATE
3160      ,CREATED_BY
3161      ,LAST_UPDATE_DATE
3162      ,LAST_UPDATED_BY
3163      ,LAST_UPDATE_LOGIN
3164      ,PROGRAM_APPLICATION_ID
3165      ,PROGRAM_ID
3166      ,PROGRAM_UPDATE_DATE
3167     ) VALUES
3168     ( oe_msg_id_S.NEXTVAL
3169      ,NULL
3170      ,l_msg_data
3171      ,l_entity_code
3172      ,l_entity_id
3173      ,l_header_id
3174      ,l_line_id
3175      ,l_orig_sys_document_ref
3176      ,l_orig_sys_document_line_ref
3177      ,l_source_document_id
3178      ,l_source_document_line_id
3179      ,l_attribute_code
3180      ,sysdate
3181      ,-1
3182      ,sysdate
3183      ,-1
3184      ,-1
3185      ,NULL
3186      ,NULL
3187      ,NULL
3188      );
3189   end if;
3190 */
3191 End insert_message;
3192 
3193 -- 4020312
3194 -- Function to pipeline the table of selected lines for mass change.
3195 FUNCTION get_sel_rec_tbl RETURN Sel_Rec_Tbl
3196 PIPELINED IS
3197    l_row OE_GLOBALS.Selected_Record_Type;
3198 BEGIN
3199    FOR i IN g_sel_rec_tbl.first..g_sel_rec_tbl.last LOOP
3200       l_row.id1    := g_sel_rec_tbl(i).id1;
3201       l_row.id2    := g_sel_rec_tbl(i).id2;
3202       l_row.id3    := g_sel_rec_tbl(i).id3;
3203       l_row.id4    := g_sel_rec_tbl(i).id4;
3204       l_row.id5    := g_sel_rec_tbl(i).id5;
3205       l_row.org_id := g_sel_rec_tbl(i).org_id;
3206       PIPE ROW (l_row);
3207    END LOOP;
3208    RETURN;
3209 END get_sel_rec_tbl;
3210 
3211 end OE_MASS_CHANGE_PVT;