DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_BULK_HEADER_UTIL

Source


1 PACKAGE BODY OE_BULK_HEADER_UTIL AS
2 /* $Header: OEBUHDRB.pls 120.5 2011/09/05 10:25:47 aparava ship $ */
3 
4 G_PKG_NAME         CONSTANT     VARCHAR2(30):='OE_BULK_HEADER_UTIL';
5 
6 
7 ---------------------------------------------------------------------
8 -- PROCEDURE Load_Headers
9 --
10 -- Loads order headers in the batch from interface tables to
11 -- the record - p_header_rec
12 ---------------------------------------------------------------------
13 
14 PROCEDURE Load_Headers
15 ( p_batch_id                   IN NUMBER
16  ,p_header_rec                 IN OUT NOCOPY OE_BULK_ORDER_PVT.HEADER_REC_TYPE
17 )
18 IS
19 
20 CURSOR c_headers IS
21   SELECT
22        accounting_rule_id
23       ,accounting_rule_duration
24       ,agreement_id
25       ,h.attribute1
26       ,h.attribute10
27       ,h.attribute11
28       ,h.attribute12
29       ,h.attribute13
30       ,h.attribute14
31       ,h.attribute15
32       ,h.attribute16   --For bug 2184255
33       ,h.attribute17
34       ,h.attribute18
35       ,h.attribute19
36       ,h.attribute2
37       ,h.attribute20
38       ,h.attribute3
39       ,h.attribute4
40       ,h.attribute5
41       ,h.attribute6
42       ,h.attribute7
43       ,h.attribute8
44       ,h.attribute9
45       -- This will select booked_flag from headers interface table
46       -- But if null on headers interface, set booked_flag to 'Y'
47       -- if there is an action request with operation code: 'BOOK_ORDER'
48       ,nvl(h.booked_flag,decode(a.order_source_id,NULL,'N','Y'))
49       ,h.context
50       ,conversion_rate
51       ,conversion_rate_date
52       ,conversion_type_code
53       ,customer_preference_set_code
54       ,customer_po_number
55       ,deliver_to_contact_id
56       ,deliver_to_org_id
57       ,demand_class_code
58       ,earliest_schedule_limit
59       ,NULL                       -- first_ack_code
60       ,fob_point_code
61       ,NULL                       --freight_carrier_code for bug 3610475
62       ,freight_terms_code
63       ,global_attribute1
64       ,global_attribute10
65       ,global_attribute11
66       ,global_attribute12
67       ,global_attribute13
68       ,global_attribute14
69       ,global_attribute15
70       ,global_attribute16
71       ,global_attribute17
72       ,global_attribute18
73       ,global_attribute19
74       ,global_attribute2
75       ,global_attribute20
76       ,global_attribute3
77       ,global_attribute4
78       ,global_attribute5
79       ,global_attribute6
80       ,global_attribute7
81       ,global_attribute8
82       ,global_attribute9
83       ,global_attribute_category
84       ,TP_CONTEXT
85       ,TP_ATTRIBUTE1
86       ,TP_ATTRIBUTE2
87       ,TP_ATTRIBUTE3
88       ,TP_ATTRIBUTE4
89       ,TP_ATTRIBUTE5
90       ,TP_ATTRIBUTE6
91       ,TP_ATTRIBUTE7
92       ,TP_ATTRIBUTE8
93       ,TP_ATTRIBUTE9
94       ,TP_ATTRIBUTE10
95       ,TP_ATTRIBUTE11
96       ,TP_ATTRIBUTE12
97       ,TP_ATTRIBUTE13
98       ,TP_ATTRIBUTE14
99       ,TP_ATTRIBUTE15
100       -- Use pre-generated header_id value from interface tables
101       ,HEADER_ID                        -- OE_ORDER_HEADERS_S.NEXTVAL
102       ,invoice_to_contact_id
103       ,invoice_to_org_id
104       ,invoicing_rule_id
105       ,latest_schedule_limit
106       ,nvl(ordered_date, SYSDATE)
107       ,order_date_type_code
108       ,order_number
109       ,h.order_source_id
110       ,order_type_id
111       ,NULL   -- order_category_code
112       ,h.org_id
113       ,h.orig_sys_document_ref
114       ,partial_shipments_allowed
115       ,payment_term_id
116       ,price_list_id
117       ,sysdate
118       ,request_date
119       ,h.request_id
120 --      ,return_reason_code
121       ,salesrep_id
122       ,sales_channel_code
123       ,shipment_priority_code
124       ,shipping_method_code
125       ,ship_from_org_id
126       ,ship_tolerance_above
127       ,ship_tolerance_below
128       ,ship_to_contact_id
129       ,ship_to_org_id
130       ,sold_from_org_id
131       ,sold_to_contact_id
132       ,h.sold_to_org_id
133 --      ,source_document_id
134 --      ,source_document_type_id
135       ,tax_exempt_flag
136       ,tax_exempt_number
137       ,tax_exempt_reason_code
138       ,tax_point_code
139       ,transactional_curr_code
140       -- QUOTING changes - remove nvl on version number
141       ,version_number
142 --      ,change_reason
143 --      ,change_comments
144       ,h.change_sequence
145 --      ,change_request_code
146 --      ,ready_flag
147 --      ,status_flag
148 --      ,force_apply_flag
149 --      ,drop_ship_flag
150 --      ,customer_payment_term_id
151       ,payment_type_code
152       ,payment_amount
153       ,check_number
154       ,credit_card_code
155       ,credit_card_holder_name
156       ,credit_card_number
157       ,credit_card_expiration_date
158       ,credit_card_approval_code
159       ,credit_card_approval_date
160       ,shipping_instructions
161       ,packing_instructions
162       , 1                    --     lock_control
163       ,NULL                  --     order_type_name
164       ,NULL                  --     wf_process_name
165       ,xml_message_id
166 --abghosh
167       ,sold_to_site_use_id
168      -- end customer(Bug 5054618)
169 	,h.End_customer_contact_id
170 	,h.End_customer_id
171 	,h.End_customer_site_use_id
172 	,h.IB_owner_code
173 	,h.IB_current_location_code
174 	,h.IB_Installed_at_Location_code
175         ,null                  --     start_line_index
176         ,null                  --     end_line_index
177   FROM OE_HEADERS_IFACE_ALL h
178        ,OE_ACTIONS_INTERFACE a
179   WHERE h.batch_id = p_batch_id
180     AND NVL(h.error_flag ,'N') = 'N'
181     AND a.order_source_id(+) = h.order_source_id
182     AND a.orig_sys_document_ref(+) = h.orig_sys_document_ref
183     AND a.operation_code(+) = 'BOOK_ORDER'
184   ORDER BY h.order_source_id, h.orig_sys_document_ref;
185 
186 --For bug 3390458
187 CURSOR c_headers_rtrim IS
188   SELECT
189        accounting_rule_id
190       ,accounting_rule_duration
191       ,agreement_id
192       ,h.attribute1
193       ,h.attribute10
194       ,h.attribute11
195       ,h.attribute12
196       ,h.attribute13
197       ,h.attribute14
198       ,h.attribute15
199       ,h.attribute16   --For bug 2184255
200       ,h.attribute17
201       ,h.attribute18
202       ,h.attribute19
203       ,h.attribute2
204       ,h.attribute20
205       ,h.attribute3
206       ,h.attribute4
207       ,h.attribute5
208       ,h.attribute6
209       ,h.attribute7
210       ,h.attribute8
211       ,h.attribute9
212       -- This will select booked_flag from headers interface table
213       -- But if null on headers interface, set booked_flag to 'Y'
214       -- if there is an action request with operation code: 'BOOK_ORDER'
215       ,nvl(h.booked_flag,decode(a.order_source_id,NULL,'N','Y'))
216       ,h.context
217       ,conversion_rate
218       ,conversion_rate_date
219       ,conversion_type_code
220       ,customer_preference_set_code
221       ,RTRIM(customer_po_number,' ')--for bug 3390458
222       ,deliver_to_contact_id
223       ,deliver_to_org_id
224       ,demand_class_code
225       ,earliest_schedule_limit
226       ,NULL                       -- first_ack_code
227       ,fob_point_code
228       ,NULL                       --freight_carrier_code for bug 3610475
229       ,freight_terms_code
230       ,global_attribute1
231       ,global_attribute10
232       ,global_attribute11
233       ,global_attribute12
234       ,global_attribute13
235       ,global_attribute14
236       ,global_attribute15
237       ,global_attribute16
238       ,global_attribute17
239       ,global_attribute18
240       ,global_attribute19
241       ,global_attribute2
242       ,global_attribute20
243       ,global_attribute3
244       ,global_attribute4
245       ,global_attribute5
246       ,global_attribute6
247       ,global_attribute7
248       ,global_attribute8
249       ,global_attribute9
250       ,global_attribute_category
251       ,RTRIM(TP_CONTEXT,' ') -- 3390458
252       ,RTRIM(TP_ATTRIBUTE1,' ') -- 3390458
253       ,RTRIM(TP_ATTRIBUTE2,' ') -- 3390458
254       ,RTRIM(TP_ATTRIBUTE3,' ') -- 3390458
255       ,RTRIM(TP_ATTRIBUTE4,' ') -- 3390458
256       ,RTRIM(TP_ATTRIBUTE5,' ') -- 3390458
257       ,RTRIM(TP_ATTRIBUTE6,' ') -- 3390458
258       ,RTRIM(TP_ATTRIBUTE7,' ') -- 3390458
259       ,RTRIM(TP_ATTRIBUTE8,' ') -- 3390458
260       ,RTRIM(TP_ATTRIBUTE9,' ') -- 3390458
261       ,RTRIM(TP_ATTRIBUTE10,' ') -- 3390458
262       ,RTRIM(TP_ATTRIBUTE11,' ') -- 3390458
263       ,RTRIM(TP_ATTRIBUTE12,' ') -- 3390458
264       ,RTRIM(TP_ATTRIBUTE13,' ') -- 3390458
265       ,RTRIM(TP_ATTRIBUTE14,' ') -- 3390458
266       ,RTRIM(TP_ATTRIBUTE15,' ') -- 3390458
267       -- Use pre-generated header_id value from interface tables
268       ,HEADER_ID                        -- OE_ORDER_HEADERS_S.NEXTVAL
269       ,invoice_to_contact_id
270       ,invoice_to_org_id
271       ,invoicing_rule_id
272       ,latest_schedule_limit
273       ,nvl(ordered_date, SYSDATE)
274       ,order_date_type_code
275       ,order_number
276       ,h.order_source_id
277       ,order_type_id
278       ,NULL   -- order_category_code
279       ,h.org_id
280       ,h.orig_sys_document_ref
281       ,partial_shipments_allowed
282       ,payment_term_id
283       ,price_list_id
284       ,sysdate
285       ,request_date
286       ,h.request_id
287 --      ,return_reason_code
288       ,salesrep_id
289       ,sales_channel_code
290       ,shipment_priority_code
291       ,shipping_method_code
292       ,ship_from_org_id
293       ,ship_tolerance_above
294       ,ship_tolerance_below
295       ,ship_to_contact_id
296       ,ship_to_org_id
297       ,sold_from_org_id
298       ,sold_to_contact_id
299       ,h.sold_to_org_id
300 --      ,source_document_id
301 --      ,source_document_type_id
302       ,tax_exempt_flag
303       ,tax_exempt_number
304       ,tax_exempt_reason_code
305       ,tax_point_code
306       ,RTRIM(transactional_curr_code,' ') --for bug 3390458
307       -- QUOTING changes - remove nvl on version number
308       ,version_number
309 --      ,change_reason
310 --      ,change_comments
311       ,h.change_sequence
312 --      ,change_request_code
313 --      ,ready_flag
314 --      ,status_flag
315 --      ,force_apply_flag
316 --      ,drop_ship_flag
317 --      ,customer_payment_term_id
318       ,payment_type_code
319       ,payment_amount
320       ,check_number
321       ,credit_card_code
322       ,credit_card_holder_name
323       ,credit_card_number
324       ,credit_card_expiration_date
325       ,credit_card_approval_code
326       ,credit_card_approval_date
327       ,RTRIM(shipping_instructions,' ')--for bug 3390458
328       ,RTRIM(packing_instructions,' ')
329       , 1                    --     lock_control
330       ,NULL                  --     order_type_name
331       ,NULL                  --     wf_process_name
332       ,xml_message_id
333 --abghosh
334       ,sold_to_site_use_id
335      -- end customer (Bug 5054618)
336      ,h.End_customer_contact_id
337     ,h.End_customer_id
338     ,h.End_customer_site_use_id
339     ,h.IB_owner_code
340     ,h.IB_current_location_code
341     ,h.IB_Installed_at_Location_code
342     ,null                  --     start_line_index
343     ,null                  --     end_line_index
344   FROM OE_HEADERS_IFACE_ALL h
345        ,OE_ACTIONS_INTERFACE a
346   WHERE h.batch_id = p_batch_id
347     AND NVL(h.error_flag ,'N') = 'N'
348     AND a.order_source_id(+) = h.order_source_id
349     AND a.orig_sys_document_ref(+) = h.orig_sys_document_ref
350     AND a.operation_code(+) = 'BOOK_ORDER'
351   ORDER BY h.order_source_id, h.orig_sys_document_ref;
352 
353 BEGIN
354 
355 --for bug 3390458
356 IF OE_BULK_ORDER_IMPORT_PVT.G_RTRIM_IFACE_DATA = 'N'
357 THEN
358   oe_debug_pub.add('before OPEN c_header');
359 
360   OPEN c_headers;
361   FETCH c_headers BULK COLLECT
362   INTO
366      ,p_header_rec.attribute1
363       p_header_rec.accounting_rule_id
364      ,p_header_rec.accounting_rule_duration
365      ,p_header_rec.agreement_id
367      ,p_header_rec.attribute10
368      ,p_header_rec.attribute11
369      ,p_header_rec.attribute12
370      ,p_header_rec.attribute13
371      ,p_header_rec.attribute14
372      ,p_header_rec.attribute15
373      ,p_header_rec.attribute16   --For bug 2184255
374      ,p_header_rec.attribute17
375      ,p_header_rec.attribute18
376      ,p_header_rec.attribute19
377      ,p_header_rec.attribute2
378      ,p_header_rec.attribute20
379      ,p_header_rec.attribute3
380      ,p_header_rec.attribute4
381      ,p_header_rec.attribute5
382      ,p_header_rec.attribute6
383      ,p_header_rec.attribute7
384      ,p_header_rec.attribute8
385      ,p_header_rec.attribute9
386      ,p_header_rec.booked_flag
387      ,p_header_rec.context
388      ,p_header_rec.conversion_rate
389      ,p_header_rec.conversion_rate_date
390      ,p_header_rec.conversion_type_code
391      ,p_header_rec.customer_preference_set_code
392      ,p_header_rec.cust_po_number
393      ,p_header_rec.deliver_to_contact_id
394      ,p_header_rec.deliver_to_org_id
395      ,p_header_rec.demand_class_code
396      ,p_header_rec.earliest_schedule_limit
397      ,p_header_rec.first_ack_code
398      ,p_header_rec.fob_point_code
399      ,p_header_rec.freight_carrier_code
400      ,p_header_rec.freight_terms_code
401      ,p_header_rec.global_attribute1
402      ,p_header_rec.global_attribute10
403      ,p_header_rec.global_attribute11
404      ,p_header_rec.global_attribute12
405      ,p_header_rec.global_attribute13
406      ,p_header_rec.global_attribute14
407      ,p_header_rec.global_attribute15
408      ,p_header_rec.global_attribute16
409      ,p_header_rec.global_attribute17
410      ,p_header_rec.global_attribute18
411      ,p_header_rec.global_attribute19
412      ,p_header_rec.global_attribute2
413      ,p_header_rec.global_attribute20
414      ,p_header_rec.global_attribute3
415      ,p_header_rec.global_attribute4
416      ,p_header_rec.global_attribute5
417      ,p_header_rec.global_attribute6
418      ,p_header_rec.global_attribute7
419      ,p_header_rec.global_attribute8
420      ,p_header_rec.global_attribute9
421      ,p_header_rec.global_attribute_category
422      ,p_header_rec.TP_CONTEXT
423      ,p_header_rec.TP_ATTRIBUTE1
424      ,p_header_rec.TP_ATTRIBUTE2
425      ,p_header_rec.TP_ATTRIBUTE3
426      ,p_header_rec.TP_ATTRIBUTE4
427      ,p_header_rec.TP_ATTRIBUTE5
428      ,p_header_rec.TP_ATTRIBUTE6
429      ,p_header_rec.TP_ATTRIBUTE7
430      ,p_header_rec.TP_ATTRIBUTE8
431      ,p_header_rec.TP_ATTRIBUTE9
432      ,p_header_rec.TP_ATTRIBUTE10
433      ,p_header_rec.TP_ATTRIBUTE11
434      ,p_header_rec.TP_ATTRIBUTE12
435      ,p_header_rec.TP_ATTRIBUTE13
436      ,p_header_rec.TP_ATTRIBUTE14
437      ,p_header_rec.TP_ATTRIBUTE15
438      ,p_header_rec.header_id
439      ,p_header_rec.invoice_to_contact_id
440      ,p_header_rec.invoice_to_org_id
441      ,p_header_rec.invoicing_rule_id
442      ,p_header_rec.latest_schedule_limit
443      ,p_header_rec.ordered_date
444      ,p_header_rec.order_date_type_code
445      ,p_header_rec.order_number
446      ,p_header_rec.order_source_id
447      ,p_header_rec.order_type_id
448      ,p_header_rec.order_category_code
449      ,p_header_rec.org_id
450      ,p_header_rec.orig_sys_document_ref
451      ,p_header_rec.partial_shipments_allowed
452      ,p_header_rec.payment_term_id
453      ,p_header_rec.price_list_id
454      ,p_header_rec.pricing_date
455      ,p_header_rec.request_date
456      ,p_header_rec.request_id
457 --     ,p_header_rec.return_reason_code
458      ,p_header_rec.salesrep_id
459      ,p_header_rec.sales_channel_code
460      ,p_header_rec.shipment_priority_code
461      ,p_header_rec.shipping_method_code
462      ,p_header_rec.ship_from_org_id
463      ,p_header_rec.ship_tolerance_above
464      ,p_header_rec.ship_tolerance_below
465      ,p_header_rec.ship_to_contact_id
466      ,p_header_rec.ship_to_org_id
467      ,p_header_rec.sold_from_org_id
468      ,p_header_rec.sold_to_contact_id
469      ,p_header_rec.sold_to_org_id
470 --     ,p_header_rec.source_document_id
471 --     ,p_header_rec.source_document_type_id
472      ,p_header_rec.tax_exempt_flag
473      ,p_header_rec.tax_exempt_number
474      ,p_header_rec.tax_exempt_reason_code
475      ,p_header_rec.tax_point_code
476      ,p_header_rec.transactional_curr_code
477      ,p_header_rec.version_number
478 --     ,p_header_rec.change_reason
479 --     ,p_header_rec.change_comments
480      ,p_header_rec.change_sequence
481 --     ,p_header_rec.change_request_code
482 --     ,p_header_rec.ready_flag
483 --     ,p_header_rec.status_flag
484 --     ,p_header_rec.force_apply_flag
485 --     ,p_header_rec.drop_ship_flag
486 --     ,p_header_rec.customer_payment_term_id
487      ,p_header_rec.payment_type_code
488      ,p_header_rec.payment_amount
489      ,p_header_rec.check_number
490      ,p_header_rec.credit_card_code
491      ,p_header_rec.credit_card_holder_name
492      ,p_header_rec.credit_card_number
493      ,p_header_rec.credit_card_expiration_date
494      ,p_header_rec.credit_card_approval_code
495      ,p_header_rec.credit_card_approval_date
496      ,p_header_rec.shipping_instructions
497      ,p_header_rec.packing_instructions
498      ,p_header_rec.lock_control
499      ,p_header_rec.order_type_name
500      ,p_header_rec.wf_process_name
501      ,p_header_rec.xml_message_id
502 --abghosh
503      ,p_header_rec.sold_to_site_use_id
504      -- end customer (Bug 5054618)
505 ,p_header_rec.End_customer_contact_id
509 ,p_header_rec.IB_current_location
506 ,p_header_rec.End_customer_id
507 ,p_header_rec.End_customer_site_use_id
508 ,p_header_rec.IB_owner
510 ,p_header_rec.IB_Installed_at_Location
511 ,p_header_rec.start_line_index
512 ,p_header_rec.end_line_index
513 ;
514 ELSE
515   --for bug 3390458
516   oe_debug_pub.add('before OPEN c_header_rtrim');
517 
518   -- This code is added to rtrim text columns. It is controlled by the
519   -- input parameter to HVOP order import program.
520 
521   OPEN c_headers_rtrim;
522   FETCH c_headers_rtrim BULK COLLECT
523   INTO
524       p_header_rec.accounting_rule_id
525      ,p_header_rec.accounting_rule_duration
526      ,p_header_rec.agreement_id
527      ,p_header_rec.attribute1
528      ,p_header_rec.attribute10
529      ,p_header_rec.attribute11
530      ,p_header_rec.attribute12
531      ,p_header_rec.attribute13
532      ,p_header_rec.attribute14
533      ,p_header_rec.attribute15
534      ,p_header_rec.attribute16   --For bug 2184255
535      ,p_header_rec.attribute17
536      ,p_header_rec.attribute18
537      ,p_header_rec.attribute19
538      ,p_header_rec.attribute2
539      ,p_header_rec.attribute20
540      ,p_header_rec.attribute3
541      ,p_header_rec.attribute4
542      ,p_header_rec.attribute5
543      ,p_header_rec.attribute6
544      ,p_header_rec.attribute7
545      ,p_header_rec.attribute8
546      ,p_header_rec.attribute9
547      ,p_header_rec.booked_flag
548      ,p_header_rec.context
549      ,p_header_rec.conversion_rate
550      ,p_header_rec.conversion_rate_date
551      ,p_header_rec.conversion_type_code
552      ,p_header_rec.customer_preference_set_code
553      ,p_header_rec.cust_po_number
554      ,p_header_rec.deliver_to_contact_id
555      ,p_header_rec.deliver_to_org_id
556      ,p_header_rec.demand_class_code
557      ,p_header_rec.earliest_schedule_limit
558      ,p_header_rec.first_ack_code
559      ,p_header_rec.fob_point_code
560      ,p_header_rec.freight_carrier_code
561      ,p_header_rec.freight_terms_code
562      ,p_header_rec.global_attribute1
563      ,p_header_rec.global_attribute10
564      ,p_header_rec.global_attribute11
565      ,p_header_rec.global_attribute12
566      ,p_header_rec.global_attribute13
567      ,p_header_rec.global_attribute14
568      ,p_header_rec.global_attribute15
569      ,p_header_rec.global_attribute16
570      ,p_header_rec.global_attribute17
571      ,p_header_rec.global_attribute18
572      ,p_header_rec.global_attribute19
573      ,p_header_rec.global_attribute2
574      ,p_header_rec.global_attribute20
575      ,p_header_rec.global_attribute3
576      ,p_header_rec.global_attribute4
577      ,p_header_rec.global_attribute5
578      ,p_header_rec.global_attribute6
579      ,p_header_rec.global_attribute7
580      ,p_header_rec.global_attribute8
581      ,p_header_rec.global_attribute9
582      ,p_header_rec.global_attribute_category
583      ,p_header_rec.TP_CONTEXT
584      ,p_header_rec.TP_ATTRIBUTE1
585      ,p_header_rec.TP_ATTRIBUTE2
586      ,p_header_rec.TP_ATTRIBUTE3
587      ,p_header_rec.TP_ATTRIBUTE4
588      ,p_header_rec.TP_ATTRIBUTE5
589      ,p_header_rec.TP_ATTRIBUTE6
590      ,p_header_rec.TP_ATTRIBUTE7
591      ,p_header_rec.TP_ATTRIBUTE8
592      ,p_header_rec.TP_ATTRIBUTE9
593      ,p_header_rec.TP_ATTRIBUTE10
594      ,p_header_rec.TP_ATTRIBUTE11
595      ,p_header_rec.TP_ATTRIBUTE12
596      ,p_header_rec.TP_ATTRIBUTE13
597      ,p_header_rec.TP_ATTRIBUTE14
598      ,p_header_rec.TP_ATTRIBUTE15
599      ,p_header_rec.header_id
600      ,p_header_rec.invoice_to_contact_id
601      ,p_header_rec.invoice_to_org_id
602      ,p_header_rec.invoicing_rule_id
603      ,p_header_rec.latest_schedule_limit
604      ,p_header_rec.ordered_date
605      ,p_header_rec.order_date_type_code
606      ,p_header_rec.order_number
607      ,p_header_rec.order_source_id
608      ,p_header_rec.order_type_id
609      ,p_header_rec.order_category_code
610      ,p_header_rec.org_id
611      ,p_header_rec.orig_sys_document_ref
612      ,p_header_rec.partial_shipments_allowed
613      ,p_header_rec.payment_term_id
614      ,p_header_rec.price_list_id
615      ,p_header_rec.pricing_date
616      ,p_header_rec.request_date
617      ,p_header_rec.request_id
618 --     ,p_header_rec.return_reason_code
619      ,p_header_rec.salesrep_id
620      ,p_header_rec.sales_channel_code
621      ,p_header_rec.shipment_priority_code
622      ,p_header_rec.shipping_method_code
623      ,p_header_rec.ship_from_org_id
624      ,p_header_rec.ship_tolerance_above
625      ,p_header_rec.ship_tolerance_below
626      ,p_header_rec.ship_to_contact_id
627      ,p_header_rec.ship_to_org_id
628      ,p_header_rec.sold_from_org_id
629      ,p_header_rec.sold_to_contact_id
630      ,p_header_rec.sold_to_org_id
631 --     ,p_header_rec.source_document_id
632 --     ,p_header_rec.source_document_type_id
633      ,p_header_rec.tax_exempt_flag
634      ,p_header_rec.tax_exempt_number
635      ,p_header_rec.tax_exempt_reason_code
636      ,p_header_rec.tax_point_code
637      ,p_header_rec.transactional_curr_code
638      ,p_header_rec.version_number
639 --     ,p_header_rec.change_reason
640 --     ,p_header_rec.change_comments
641      ,p_header_rec.change_sequence
642 --     ,p_header_rec.change_request_code
643 --     ,p_header_rec.ready_flag
644 --     ,p_header_rec.status_flag
645 --     ,p_header_rec.force_apply_flag
646 --     ,p_header_rec.drop_ship_flag
647 --     ,p_header_rec.customer_payment_term_id
648      ,p_header_rec.payment_type_code
649      ,p_header_rec.payment_amount
650      ,p_header_rec.check_number
651      ,p_header_rec.credit_card_code
655      ,p_header_rec.credit_card_approval_code
652      ,p_header_rec.credit_card_holder_name
653      ,p_header_rec.credit_card_number
654      ,p_header_rec.credit_card_expiration_date
656      ,p_header_rec.credit_card_approval_date
657      ,p_header_rec.shipping_instructions
658      ,p_header_rec.packing_instructions
659      ,p_header_rec.lock_control
660      ,p_header_rec.order_type_name
661      ,p_header_rec.wf_process_name
662      ,p_header_rec.xml_message_id
663 --abghosh
664      ,p_header_rec.sold_to_site_use_id
665       -- end customer (Bug 5054618)
666  ,p_header_rec.End_customer_contact_id
667  ,p_header_rec.End_customer_id
668  ,p_header_rec.End_customer_site_use_id
669  ,p_header_rec.IB_owner
670  ,p_header_rec.IB_current_location
671  ,p_header_rec.IB_Installed_at_Location
672  ,p_header_rec.start_line_index
673  ,p_header_rec.end_line_index
674    ;
675 END IF;
676 
677 EXCEPTION
678   WHEN OTHERS THEN
679     oe_debug_pub.add('Others Error, Load_Headers');
680     oe_debug_pub.add(substr(sqlerrm,1,240));
681     OE_BULK_MSG_PUB.Add_Exc_Msg
682       (   G_PKG_NAME
683       ,   'Load_Headers'
684        );
685     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
686 END Load_Headers;
687 
688 
689 ---------------------------------------------------------------------
690 -- PROCEDURE Insert_Headers
691 --
692 -- BULK Inserts order headers into the OM tables from p_header_rec
693 ---------------------------------------------------------------------
694 
695 PROCEDURE Insert_Headers
696 ( p_header_rec               IN OE_BULK_ORDER_PVT.HEADER_REC_TYPE
697 , p_batch_id                 IN NUMBER
698 )
699 IS
700 
701 ctr NUMBER;
702 l_realtime_cc VARCHAR2(1);
703 
704 BEGIN
705 l_realtime_cc := OE_BULK_ORDER_PVT.G_REALTIME_CC_REQUIRED;
706 ctr := p_header_rec.header_id.count;
707 
708 FORALL i IN 1..ctr
709      INSERT INTO OE_ORDER_HEADERS_ALL
710        (ACCOUNTING_RULE_ID
711        ,ACCOUNTING_RULE_DURATION
712        ,AGREEMENT_ID
713        ,ATTRIBUTE1
714        ,ATTRIBUTE10
715        ,ATTRIBUTE11
716        ,ATTRIBUTE12
717        ,ATTRIBUTE13
718        ,ATTRIBUTE14
719        ,ATTRIBUTE15
720        ,ATTRIBUTE16   --For bug 2184255
721        ,ATTRIBUTE17
722        ,ATTRIBUTE18
723        ,ATTRIBUTE19
724        ,ATTRIBUTE2
725        ,ATTRIBUTE20
726        ,ATTRIBUTE3
727        ,ATTRIBUTE4
728        ,ATTRIBUTE5
729        ,ATTRIBUTE6
730        ,ATTRIBUTE7
731        ,ATTRIBUTE8
732        ,ATTRIBUTE9
733        ,BOOKED_FLAG
734        ,BOOKED_DATE
735        ,CANCELLED_FLAG
736        ,CONTEXT
737        ,CONVERSION_RATE
738        ,CONVERSION_RATE_DATE
739        ,CONVERSION_TYPE_CODE
740        --,CUSTOMER_PREFERENCE_SET_CODE
741        ,CREATED_BY
742        ,CREATION_DATE
743        ,CUST_PO_NUMBER
744        ,DELIVER_TO_CONTACT_ID
745        ,DELIVER_TO_ORG_ID
746        ,DEMAND_CLASS_CODE
747        --,FIRST_ACK_CODE
748        --,FIRST_ACK_DATE
749        --,EXPIRATION_DATE
750        ,EARLIEST_SCHEDULE_LIMIT
751        ,FOB_POINT_CODE
752        ,FREIGHT_CARRIER_CODE
753        ,FREIGHT_TERMS_CODE
754        ,GLOBAL_ATTRIBUTE1
755        ,GLOBAL_ATTRIBUTE10
756        ,GLOBAL_ATTRIBUTE11
757        ,GLOBAL_ATTRIBUTE12
758        ,GLOBAL_ATTRIBUTE13
759        ,GLOBAL_ATTRIBUTE14
760        ,GLOBAL_ATTRIBUTE15
761        ,GLOBAL_ATTRIBUTE16
762        ,GLOBAL_ATTRIBUTE17
763        ,GLOBAL_ATTRIBUTE18
764        ,GLOBAL_ATTRIBUTE19
765        ,GLOBAL_ATTRIBUTE2
766        ,GLOBAL_ATTRIBUTE20
767        ,GLOBAL_ATTRIBUTE3
768        ,GLOBAL_ATTRIBUTE4
769        ,GLOBAL_ATTRIBUTE5
770        ,GLOBAL_ATTRIBUTE6
771        ,GLOBAL_ATTRIBUTE7
772        ,GLOBAL_ATTRIBUTE8
773        ,GLOBAL_ATTRIBUTE9
774        ,GLOBAL_ATTRIBUTE_CATEGORY
775        ,HEADER_ID
776        ,INVOICE_TO_CONTACT_ID
777        ,INVOICE_TO_ORG_ID
778        ,INVOICING_RULE_ID
779        --,LAST_ACK_CODE
780        --,LAST_ACK_DATE
781        ,LAST_UPDATED_BY
782        ,LAST_UPDATE_DATE
783        --,LAST_UPDATE_LOGIN
784        ,LATEST_SCHEDULE_LIMIT
785        ,OPEN_FLAG
786        ,ORDERED_DATE
787        ,ORDER_DATE_TYPE_CODE
788        ,ORDER_NUMBER
789        ,ORDER_SOURCE_ID
790        ,ORDER_TYPE_ID
791        ,ORDER_CATEGORY_CODE
792        ,ORG_ID
793        ,ORIG_SYS_DOCUMENT_REF
794        ,PARTIAL_SHIPMENTS_ALLOWED
795        ,PAYMENT_TERM_ID
796        ,PRICE_LIST_ID
797        --,PRICE_REQUEST_CODE -- PROMOTIONS SEP/01
798        ,PRICING_DATE
799        --,PROGRAM_APPLICATION_ID
800        --,PROGRAM_ID
801        --,PROGRAM_UPDATE_DATE
802        ,REQUEST_DATE
803        ,REQUEST_ID
804        --,RETURN_REASON_CODE
805        ,SALESREP_ID
806        ,SALES_CHANNEL_CODE
807        ,SHIPMENT_PRIORITY_CODE
808        ,SHIPPING_METHOD_CODE
809        ,SHIP_FROM_ORG_ID
810        ,SHIP_TOLERANCE_ABOVE
811        ,SHIP_TOLERANCE_BELOW
812        ,SHIP_TO_CONTACT_ID
813        ,SHIP_TO_ORG_ID
814        ,SOLD_FROM_ORG_ID
815        ,SOLD_TO_CONTACT_ID
816        ,SOLD_TO_ORG_ID
817        --,SOURCE_DOCUMENT_ID
818        --,SOURCE_DOCUMENT_TYPE_ID
819        ,TAX_EXEMPT_FLAG
820        ,TAX_EXEMPT_NUMBER
821        ,TAX_EXEMPT_REASON_CODE
822        ,TAX_POINT_CODE
823        ,TRANSACTIONAL_CURR_CODE
824        ,VERSION_NUMBER
825        ,PAYMENT_TYPE_CODE
826        ,PAYMENT_AMOUNT
827        ,CHECK_NUMBER
831        ,CREDIT_CARD_EXPIRATION_DATE
828        ,CREDIT_CARD_CODE
829        ,CREDIT_CARD_HOLDER_NAME
830        ,CREDIT_CARD_NUMBER
832        ,CREDIT_CARD_APPROVAL_DATE
833        ,CREDIT_CARD_APPROVAL_CODE
834        ,CHANGE_SEQUENCE
835        --,DROP_SHIP_FLAG
836        --,CUSTOMER_PAYMENT_TERM_ID
837        ,SHIPPING_INSTRUCTIONS
838        ,PACKING_INSTRUCTIONS
839        ,FLOW_STATUS_CODE
840        --,MARKETING_SOURCE_CODE_ID
841        ,TP_ATTRIBUTE1
842        ,TP_ATTRIBUTE10
843        ,TP_ATTRIBUTE11
844        ,TP_ATTRIBUTE12
845        ,TP_ATTRIBUTE13
846        ,TP_ATTRIBUTE14
847        ,TP_ATTRIBUTE15
848        ,TP_ATTRIBUTE2
849        ,TP_ATTRIBUTE3
850        ,TP_ATTRIBUTE4
851        ,TP_ATTRIBUTE5
852        ,TP_ATTRIBUTE6
853        ,TP_ATTRIBUTE7
854        ,TP_ATTRIBUTE8
855        ,TP_ATTRIBUTE9
856        ,TP_CONTEXT
857        --,upgraded_flag
858        ,LOCK_CONTROL
859        ,XML_MESSAGE_ID
860        ,BATCH_ID
861        -- QUOTING changes
862        ,TRANSACTION_PHASE_CODE
863   -- abghosh
864        ,sold_to_site_use_id
865        --End Customer changes (Bug 5054618)
866        ,End_customer_contact_id
867 	,End_customer_id
868 	,End_customer_site_use_id
869 	,IB_owner
870 	,IB_current_location
871 	,IB_Installed_at_Location
872        )
873      VALUES
874        (p_header_rec.accounting_rule_id(i)
875        ,p_header_rec.accounting_rule_duration(i)
876        ,p_header_rec.agreement_id(i)
877        ,p_header_rec.attribute1(i)
878        ,p_header_rec.attribute10(i)
879        ,p_header_rec.attribute11(i)
880        ,p_header_rec.attribute12(i)
881        ,p_header_rec.attribute13(i)
882        ,p_header_rec.attribute14(i)
883        ,p_header_rec.attribute15(i)
884        ,p_header_rec.attribute16(i)   --For bug 2184255
885        ,p_header_rec.attribute17(i)
886        ,p_header_rec.attribute18(i)
887        ,p_header_rec.attribute19(i)
888        ,p_header_rec.attribute2(i)
889        ,p_header_rec.attribute20(i)
890        ,p_header_rec.attribute3(i)
891        ,p_header_rec.attribute4(i)
892        ,p_header_rec.attribute5(i)
893        ,p_header_rec.attribute6(i)
894        ,p_header_rec.attribute7(i)
895        ,p_header_rec.attribute8(i)
896        ,p_header_rec.attribute9(i)
897        ,DECODE(l_realtime_cc,'Y','N',p_header_rec.booked_flag(i)) -- added for HVOP CC support
898        ,decode(p_header_rec.booked_flag(i),'Y',sysdate,null) -- p_header_rec.booked_date(i)
899        ,'N'                                   -- p_header_rec.cancelled_flag(i)
900        ,p_header_rec.context(i)
901        ,p_header_rec.conversion_rate(i)
902        ,p_header_rec.conversion_rate_date(i)
903        ,p_header_rec.conversion_type_code(i)
904        --,p_header_rec.CUSTOMER_PREFERENCE_SET_CODE(i)
905        ,FND_GLOBAL.USER_ID                    -- p_header_rec.created_by(i)
906        ,sysdate                               -- p_header_rec.creation_date(i)
907        ,p_header_rec.cust_po_number(i)
908        ,p_header_rec.deliver_to_contact_id(i)
909        ,p_header_rec.deliver_to_org_id(i)
910        ,p_header_rec.demand_class_code(i)
911        -- p_header_rec.first_ack_code(i)
912        --,p_header_rec.first_ack_date(i)
913        --,p_header_rec.expiration_date(i)
914        ,p_header_rec.earliest_schedule_limit(i)
915        ,p_header_rec.fob_point_code(i)
916        ,p_header_rec.freight_carrier_code(i)
917        ,p_header_rec.freight_terms_code(i)
918        ,p_header_rec.global_attribute1(i)
919        ,p_header_rec.global_attribute10(i)
920        ,p_header_rec.global_attribute11(i)
921        ,p_header_rec.global_attribute12(i)
922        ,p_header_rec.global_attribute13(i)
923        ,p_header_rec.global_attribute14(i)
924        ,p_header_rec.global_attribute15(i)
925        ,p_header_rec.global_attribute16(i)
926        ,p_header_rec.global_attribute17(i)
927        ,p_header_rec.global_attribute18(i)
928        ,p_header_rec.global_attribute19(i)
929        ,p_header_rec.global_attribute2(i)
930        ,p_header_rec.global_attribute20(i)
931        ,p_header_rec.global_attribute3(i)
932        ,p_header_rec.global_attribute4(i)
933        ,p_header_rec.global_attribute5(i)
934        ,p_header_rec.global_attribute6(i)
935        ,p_header_rec.global_attribute7(i)
936        ,p_header_rec.global_attribute8(i)
937        ,p_header_rec.global_attribute9(i)
938        ,p_header_rec.global_attribute_category(i)
939        ,p_header_rec.header_id(i)
940        ,p_header_rec.invoice_to_contact_id(i)
941        ,p_header_rec.invoice_to_org_id(i)
942        ,p_header_rec.invoicing_rule_id(i)
943        --,p_header_rec.last_ack_code(i)
944        --,p_header_rec.last_ack_date(i)
945        ,FND_GLOBAL.USER_ID                  -- p_header_rec.last_updated_by(i)
946        ,sysdate                             -- p_header_rec.last_update_date(i)
947        --,p_header_rec.last_update_login(i)
948        ,p_header_rec.latest_schedule_limit(i)
949        ,'Y'                                 -- p_header_rec.open_flag(i)
950        ,p_header_rec.ordered_date(i)
951        ,p_header_rec.order_date_type_code(i)
952        ,p_header_rec.order_number(i)
953        ,p_header_rec.order_source_id(i)
954        ,p_header_rec.order_type_id(i)
955        ,p_header_rec.order_category_code(i)
956        ,p_header_rec.org_id(i)
957        ,p_header_rec.orig_sys_document_ref(i)
958        ,p_header_rec.partial_shipments_allowed(i)
959        ,p_header_rec.payment_term_id(i)
960        ,p_header_rec.price_list_id(i)
961        --,p_header_rec.price_request_code(i) -- PROMOTIONS SEP/01
962        ,p_header_rec.pricing_date(i)
963        --,p_header_rec.program_application_id(i)
964        --,p_header_rec.program_id(i)
968        --,p_header_rec.return_reason_code(i)
965        --,p_header_rec.program_update_date(i)
966        ,p_header_rec.request_date(i)
967        ,OE_BULK_ORDER_PVT.G_REQUEST_ID           -- p_header_rec.request_id(i)
969        ,p_header_rec.salesrep_id(i)
970        ,p_header_rec.sales_channel_code(i)
971        ,p_header_rec.shipment_priority_code(i)
972        ,p_header_rec.shipping_method_code(i)
973        ,p_header_rec.ship_from_org_id(i)
974        ,p_header_rec.ship_tolerance_above(i)
975        ,p_header_rec.ship_tolerance_below(i)
976        ,p_header_rec.ship_to_contact_id(i)
977        ,p_header_rec.ship_to_org_id(i)
978        ,OE_BULK_ORDER_IMPORT_PVT.G_ORG_ID       --OE_GLOBALS.G_ORG_ID /*Commented to fix Bug#12934232*/
979        ,p_header_rec.sold_to_contact_id(i)
980        ,p_header_rec.sold_to_org_id(i)
981        --,p_header_rec.source_document_id(i)
982        --,p_header_rec.source_document_type_id(i)
983        ,p_header_rec.tax_exempt_flag(i)
984        ,p_header_rec.tax_exempt_number(i)
985        ,p_header_rec.tax_exempt_reason_code(i)
986        ,p_header_rec.tax_point_code(i)
987        ,p_header_rec.transactional_curr_code(i)
988        ,p_header_rec.version_number(i)
989        ,p_header_rec.payment_type_code(i)
990        ,p_header_rec.payment_amount(i)
991        ,p_header_rec.check_number(i)
992        ,p_header_rec.credit_card_code(i)
993        ,p_header_rec.credit_card_holder_name(i)
994        ,p_header_rec.credit_card_number(i)
995        ,p_header_rec.credit_card_expiration_date(i)
996        ,p_header_rec.credit_card_approval_date(i)
997        ,p_header_rec.credit_card_approval_code(i)
998        ,p_header_rec.change_sequence(i)
999        --,p_header_rec.drop_ship_flag(i)
1000        --,p_header_rec.customer_payment_term_id(i)
1001        ,p_header_rec.shipping_instructions(i)
1002        ,p_header_rec.packing_instructions(i)
1003        ,decode(p_header_rec.booked_flag(i)
1004                ,'Y','BOOKED','ENTERED') -- ,p_header_rec.FLOW_STATUS_CODE(i)
1005        --,p_header_rec.marketing_source_code_id(i)
1006        ,p_header_rec.tp_attribute1(i)
1007        ,p_header_rec.tp_attribute10(i)
1008        ,p_header_rec.tp_attribute11(i)
1009        ,p_header_rec.tp_attribute12(i)
1010        ,p_header_rec.tp_attribute13(i)
1011        ,p_header_rec.tp_attribute14(i)
1012        ,p_header_rec.tp_attribute15(i)
1013        ,p_header_rec.tp_attribute2(i)
1014        ,p_header_rec.tp_attribute3(i)
1015        ,p_header_rec.tp_attribute4(i)
1016        ,p_header_rec.tp_attribute5(i)
1017        ,p_header_rec.tp_attribute6(i)
1018        ,p_header_rec.tp_attribute7(i)
1019        ,p_header_rec.tp_attribute8(i)
1020        ,p_header_rec.tp_attribute9(i)
1021        ,p_header_rec.tp_context(i)
1022        -- ,l_upgraded_flag(i)
1023        ,p_header_rec.lock_control(i)
1024        ,p_header_rec.xml_message_id(i)
1025        ,p_batch_id
1026        -- QUOTING changes
1027        -- Negotiation orders not supported with HVOP
1028        -- insert fulfillment (F) for transaction phase
1029        ,'F'
1030    --abghosh
1031        ,p_header_rec.sold_to_site_use_id(i)
1032 -- end customer (Bug 5054618)
1033  ,p_header_rec.End_customer_contact_id(i)
1034  ,p_header_rec.End_customer_id(i)
1035  ,p_header_rec.End_customer_site_use_id(i)
1036  ,p_header_rec.IB_owner(i)
1037  ,p_header_rec.IB_current_location(i)
1038  ,p_header_rec.IB_Installed_at_Location(i)
1039        );
1040 
1041 EXCEPTION
1042   WHEN OTHERS THEN
1043     oe_debug_pub.add('Others Error, Insert_Headers');
1044     oe_debug_pub.add(substr(sqlerrm,1,240));
1045     OE_BULK_MSG_PUB.Add_Exc_Msg
1046       (G_PKG_NAME
1047       ,'Insert_Headers'
1048        );
1049     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1050 END Insert_Headers;
1051 
1052 
1053 ---------------------------------------------------------------------
1054 -- PROCEDURE Create_Header_Scredits
1055 --
1056 -- BULK Inserts header sales credits into the OM tables from
1057 -- p_header_scredit_rec
1058 ---------------------------------------------------------------------
1059 
1060 PROCEDURE Create_Header_Scredits
1061 (p_header_scredit_rec             IN OE_BULK_ORDER_PVT.SCREDIT_REC_TYPE
1062 )
1063 IS
1064 BEGIN
1065 
1066   IF p_header_scredit_rec.header_id.COUNT = 0 THEN
1067      RETURN;
1068   END IF;
1069 
1070   FORALL I IN p_header_scredit_rec.header_id.FIRST..p_header_scredit_rec.header_id.LAST
1071     INSERT  INTO OE_SALES_CREDITS
1072     (
1073             CREATED_BY
1074     ,       CREATION_DATE
1075     ,       DW_UPDATE_ADVICE_FLAG
1076     ,       HEADER_ID
1077     ,       LAST_UPDATED_BY
1078     ,       LAST_UPDATE_DATE
1079     ,       LAST_UPDATE_LOGIN
1080     ,       LINE_ID
1081     ,       PERCENT
1082     ,       SALESREP_ID
1083     ,       sales_credit_type_id
1084     ,       SALES_CREDIT_ID
1085     ,       WH_UPDATE_DATE
1086     ,       ORIG_SYS_CREDIT_REF
1087     ,       LOCK_CONTROL
1088     )
1089     VALUES
1090     (
1091             FND_GLOBAL.USER_ID
1092     ,       sysdate
1093     ,       NULL
1094     ,       p_header_scredit_rec.header_id(i)
1095     ,       FND_GLOBAL.USER_ID
1096     ,       sysdate
1097     ,       FND_GLOBAL.USER_ID
1098     ,       NULL
1099     ,       100
1100     ,       p_header_scredit_rec.salesrep_id(i)
1101     ,       nvl(p_header_scredit_rec.Sales_Credit_Type_id(i),1)
1102     ,       OE_SALES_CREDITS_S.nextval
1103     ,       NULL
1104     ,       NULL
1105     ,       1
1106     );
1107 
1108 EXCEPTION
1109   WHEN OTHERS THEN
1110     OE_BULK_MSG_PUB.Add_Exc_Msg
1111       (   G_PKG_NAME
1112       ,   'Create_Header_Scredits'
1113        );
1114     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1117 END OE_BULK_HEADER_UTIL;
1115 END Create_Header_Scredits;
1116