1 PACKAGE BODY ibe_quote_save_pvt AS
2 /* $Header: IBEVQCUB.pls 120.50.12020000.2 2012/08/14 06:40:59 amaheshw ship $ */
3 -- Start of Comments
4 -- Package name : IBE_Quote_Save_pvt
5 -- Purpose :--DBMS_PUT.PUT_line(' ');
6 -- NOTE :
7 -- End of Comments
8
9 l_true VARCHAR2(1) := FND_API.G_TRUE;
10 G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBE_Quote_Save_pvt';
11 G_FILE_NAME CONSTANT VARCHAR2(12) := 'IBEVQCUB.pls';
12
13 FUNCTION Compare(
14 p_qte_line_tbl_service IN ASO_Quote_Pub.Qte_Line_Tbl_Type
15 ,p_qte_line_dtl_tbl_service IN ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
16 ,p_qte_line_tbl_service_db IN ASO_Quote_Pub.Qte_Line_Tbl_Type
17 ,p_qte_line_dtl_tbl_service_db IN ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
18 ) RETURN varchar2
19 IS
20 l_qte_line_rec ASO_Quote_Pub.Qte_Line_Rec_Type
21 := ASO_Quote_Pub.g_miss_Qte_Line_rec;
22
23 l_same varchar2(1) := 'N';
24 l_found varchar2(1) := 'N';
25 l_index number := 1;
26 BEGIN
27 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
28 IBE_Util.Debug('compare: p_qte_line_tbl_service.count'
29 || p_qte_line_tbl_service.count);
30 END IF;
31 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
32 IBE_Util.Debug('compare: p_qte_line_tbl_service_db.count'
33 || p_qte_line_tbl_service_db.count);
34 END IF;
35 IF p_qte_line_tbl_service.count = p_qte_line_tbl_service_db.count THEN
36 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
37 IBE_Util.Debug(' start compare: ');
38 END IF;
39 FOR i in 1..p_qte_line_tbl_service.count LOOP
40 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
41 IBE_Util.Debug('compare: line i='||i);
42 END IF;
43 l_found := 'N';
44 l_index :=1;
45 WHILE l_found= 'N' and l_index <= p_qte_line_tbl_service_db.count
46 LOOP
47
48 IF p_qte_line_tbl_service(i).inventory_item_id
49 = p_qte_line_tbl_service_db(l_index).inventory_item_id
50 and p_qte_line_tbl_service(i).organization_id
51 = p_qte_line_tbl_service_db(l_index).organization_id
52 THEN
53 l_found := 'Y';
54
55 END IF;
56 l_index := l_index+1;
57 END LOOP;
58 IF l_found = 'N' THEN
59 l_same := 'N';
60 return l_same;
61 END IF;
62 l_same := 'Y';
63 END LOOP;
64
65 FOR i IN 1..p_qte_line_dtl_tbl_service.count
66 LOOP
67 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
68 IBE_Util.Debug('compare: detail line i='||i);
69 END IF;
70 l_found := 'N';
71 l_index :=1;
72 WHILE l_found= 'N' and l_index <= p_qte_line_dtl_tbl_service_db.count
73 LOOP
74 IF p_qte_line_dtl_tbl_service(i).SERVICE_DURATION
75 = p_qte_line_dtl_tbl_service_db(l_index).service_duration
76 and p_qte_line_dtl_tbl_service(i).service_period
77 = p_qte_line_dtl_tbl_service_db(l_index).service_period
78 THEN
79 l_found := 'Y';
80
81 END IF;
82 l_index := l_index +1;
83 END LOOP;
84 IF l_found = 'N' THEN
85 l_same := 'N';
86 return l_same;
87 END IF;
88 l_same := 'Y';
89 END LOOP;
90 END IF;
91
92 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
93 IBE_Util.Debug('compare: before return l_same = '||l_same);
94 END IF;
95
96 RETURN l_same;
97 END compare;
98
99
100 FUNCTION getLinetblfromdb(
101 p_quote_header_id IN NUMBER
102 ,p_qte_line_rec ASO_Quote_Pub.Qte_Line_Rec_Type
103 ) RETURN ASO_Quote_Pub.Qte_Line_tbl_Type
104 IS
105
106 l_qte_line_rec ASO_Quote_Pub.Qte_Line_Rec_Type
107 := ASO_Quote_Pub.g_miss_Qte_Line_rec;
108
109 l_qte_line_tbl ASO_Quote_Pub.Qte_Line_tbl_Type
110 := ASO_Quote_Pub.g_miss_Qte_Line_tbl;
111
112 cursor c_getlineinfo(p_quote_header_id number, l_inventory_item_id number)
113 is
114 select quote_line_id, item_type_code ,quantity, inventory_item_id
115 from aso_quote_lines
116 where quote_header_id = p_quote_header_id
117 and inventory_item_id = l_inventory_item_id;
118
119 BEGIN
120
121 OPEN c_getlineinfo(p_quote_header_id
122 ,p_qte_line_rec.inventory_item_id);
123 LOOP
124 FETCH c_getlineinfo into l_qte_line_rec.quote_line_id,
125 l_qte_line_rec.item_type_code,
126 l_qte_line_rec.quantity,
127 l_qte_line_rec.inventory_item_id;
128 EXIT WHEN c_getLineinfo%notfound;
129 l_qte_line_tbl(l_qte_line_tbl.count+1) := l_qte_line_rec;
130 END LOOP;
131 CLOSE c_getlineinfo;
132
133 return l_qte_line_tbl;
134
135 END getlinetblfromdb;
136
137 PROCEDURE log_Control_Rec_Values(
138 p_control_rec IN ASO_Quote_Pub.Control_Rec_Type
139 )
140 IS
141 BEGIN
142 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
143 IBE_Util.Debug('log_Control_Rec_Values BEGIN');
144 IBE_Util.Debug('change line logic pricing Test BEGIN');
145 IBE_Util.Debug('p_control_rec.last_update_date = ' || p_control_rec.last_update_date);
146 IBE_Util.Debug('p_control_rec.auto_version_flag = '|| p_control_rec.auto_version_flag);
147 IBE_Util.Debug('p_control_rec.pricing_request_type = '|| p_control_rec.pricing_request_type);
148 IBE_Util.Debug('p_control_rec.header_pricing_event = '|| p_control_rec.header_pricing_event );
149 IBE_Util.Debug('p_control_rec.line_pricing_event = ' || p_control_rec.line_pricing_event);
150 IBE_Util.Debug('p_control_rec.calculate_tax_flag = '|| p_control_rec.calculate_tax_flag);
151 IBE_Util.Debug('p_control_rec.calculate_freight_charge_flag = '|| p_control_rec.calculate_freight_charge_flag);
152 IBE_Util.Debug('p_control_rec.price_mode = ' || p_control_rec.price_mode);
153 IBE_Util.Debug('change line logic pricing Test END');
154 END IF;
155 END log_Control_Rec_Values;
156
157 Procedure Load_Service(
158 p_quote_header_id IN NUMBER
159 ,p_service_ref_line_id IN NUMBER
160 ,x_qte_line_tbl_service_db out nocopy ASO_Quote_Pub.Qte_Line_Tbl_Type
161 ,x_qte_line_dtl_tbl_service_db out nocopy ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
162 )
163 IS
164 l_qte_line_rec ASO_Quote_Pub.Qte_Line_Rec_Type
165 := ASO_Quote_Pub.g_miss_Qte_Line_rec;
166
167 l_qte_line_tbl ASO_Quote_Pub.Qte_Line_Tbl_Type
168 := ASO_Quote_Pub.g_miss_Qte_Line_tbl;
169
170 l_qte_line_dtl_rec ASO_Quote_Pub.Qte_Line_dtl_Rec_Type
171 := ASO_Quote_Pub.g_miss_Qte_Line_dtl_rec;
172
173 l_qte_line_dtl_tbl ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
174 := ASO_Quote_Pub.g_miss_Qte_Line_dtl_tbl;
175
176 CURSOR c_getlineinfo(p_quote_header_id NUMBER, p_service_ref_line_id NUMBER)
177 IS
178 select l.quote_line_id
179 ,l.item_type_code
180 ,l.quantity
181 ,l.inventory_item_id
182 ,l.organization_id
183 ,l.uom_code
184 ,dl.quote_line_detail_id
185 ,dl.service_duration
186 ,dl.service_period
187 from aso_quote_lines l, aso_quote_line_details dl
188 where l.quote_header_id = p_quote_header_id
189 and l.item_type_code = 'SRV'
190 and dl.service_ref_line_id = p_service_ref_line_id
191 and dl.quote_line_id = l.quote_line_id;
192 BEGIN
193 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
194 IBE_Util.Debug('at load_service p_service_ref_line_id ='
195 || p_service_ref_line_id);
196 END IF;
197
198 OPEN c_getlineinfo(p_quote_header_id
199 ,p_service_ref_line_id);
200 LOOP
201 FETCH c_getlineinfo into l_qte_line_rec.quote_line_id,
202 l_qte_line_rec.item_type_code,
203 l_qte_line_rec.quantity,
204 l_qte_line_rec.inventory_item_id,
205 l_qte_line_rec.organization_id,
206 l_qte_line_rec.uom_code,
207 l_qte_line_dtl_rec.quote_line_detail_id,
208 l_qte_line_dtl_rec.service_duration,
209 l_qte_line_dtl_rec.service_period;
210 EXIT WHEN c_getLineinfo%notfound;
211
212 l_qte_line_tbl(l_qte_line_tbl.count+1)
213 := l_qte_line_rec;
214
215 l_qte_line_dtl_tbl(l_qte_line_dtl_tbl.count+1)
216 := l_qte_line_dtl_rec;
217 END LOOP;
218 CLOSE c_getlineinfo;
219
220 x_qte_line_tbl_service_db := l_qte_line_tbl;
221 x_qte_line_dtl_tbl_service_db := l_qte_line_dtl_tbl;
222 END Load_service;
223
224 PROCEDURE find_service(
225 p_qte_line_index IN NUMBER
226 ,p_qte_line_tbl IN ASO_Quote_Pub.Qte_Line_Tbl_Type
227 ,p_qte_line_dtl_tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
228 ,x_qte_line_tbl_service OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
229 ,x_qte_line_dtl_tbl_service OUT NOCOPY ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
230 )
231 IS
232 l_qte_line_index NUMBER;
233 l_qte_line_dtl_rec ASO_Quote_Pub.Qte_Line_Dtl_rec_Type;
234
235 BEGIN
236 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
237 IBE_Util.Debug('at find_service p_qte_line_tbl.count= '
238 ||p_qte_line_tbl.count);
239 END IF;
240
241 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
242 IBE_Util.Debug('at find_service p_qte_line_dtl_tbl.count= '
243 ||p_qte_line_dtl_tbl.count);
244 END IF;
245 FOR i in 1..p_qte_line_dtl_tbl.count Loop
246 IF p_qte_line_dtl_tbl(i).service_ref_qte_line_index = p_qte_line_index THEN
247 l_qte_line_dtl_rec := p_qte_line_dtl_tbl(i);
248
249 l_qte_line_dtl_rec.SERVICE_REF_QTE_LINE_INDEX := i;
250 --this to avoide search again
251
252 x_qte_line_dtl_tbl_service(x_qte_line_dtl_tbl_service.count+1)
253 := l_qte_line_dtl_rec;
254
255 l_qte_line_index := p_qte_line_dtl_tbl(i).qte_line_index;
256
257 x_qte_line_tbl_service(x_qte_line_tbl_service.count+1)
258 := p_qte_line_tbl(l_qte_line_index);
259 END IF;
260
261 END LOOP;
262 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
263 IBE_Util.Debug('at find_service x_qte_line_dtl_tbl.count= '
264 ||x_qte_line_dtl_tbl_service.count);
265 END IF;
266 END Find_Service;
267
268
269 PROCEDURE load_serviceable_service(
270 p_quote_header_id IN NUMBER
271 ,p_qte_line_rec IN ASO_Quote_Pub.Qte_Line_Rec_Type
272 ,p_qte_line_tbl_service IN ASO_Quote_Pub.Qte_Line_Tbl_Type
273 ,p_qte_line_dtl_tbl_service IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
274 ,x_qte_line_rec_db OUT NOCOPY ASO_Quote_Pub.Qte_Line_Rec_Type
275 ,x_qte_line_tbl_service_db OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
276 ,x_qte_line_dtl_tbl_service_db OUT NOCOPY ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
277 )
278 IS
279 l_qte_line_tbl ASO_Quote_Pub.Qte_Line_Tbl_Type;
280 l_qte_line_tbl_service_db ASO_Quote_Pub.Qte_Line_Tbl_Type;
281 l_qte_line_dtl_tbl_service_db ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
282
283 l_index number :=1;
284 l_same varchar2(1) := 'N';
285 BEGIN
286 -- find all the serviceable items from database
287 l_qte_line_tbl := getLineTblfromdb(
288 p_quote_header_id => p_quote_header_id,
289 p_qte_line_rec => p_qte_line_rec);
290
291 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
292 IBE_Util.Debug('load_serviceable_service l_qte_line_tbl.count'||l_qte_line_tbl.count);
293 END IF;
294
295 WHILE l_same = 'N' and l_index <= l_qte_line_tbl.count LOOP
296 -- find all the service item from database for this serviceable item
297 Load_service(
298 p_quote_header_id => p_quote_header_id ,
299 p_service_ref_line_id => l_qte_line_tbl(l_index).quote_line_id,
300 x_qte_line_tbl_service_db => l_qte_line_tbl_service_db ,
301 x_qte_line_dtl_tbl_service_db => l_qte_line_dtl_tbl_service_db);
302 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
303 IBE_Util.Debug('load_serviceable_service l_qte_line_tbl_service_db.count '
304 ||l_qte_line_tbl_service_db.count);
305 END IF;
306
307 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
308 IBE_Util.Debug('load_serviceable_service l_qte_line_dtl_tbl_service_db.count '
309 ||l_qte_line_dtl_tbl_service_db.count);
310 END IF;
311 IF p_qte_line_tbl_service.count = l_qte_line_tbl_service_db.count THEN
312 IF p_qte_line_tbl_service.count > 0 THEN
313 l_same := compare
314 ( p_qte_line_tbl_service => p_qte_line_tbl_service
315 ,p_qte_line_dtl_tbl_service => p_qte_line_dtl_tbl_service
316 ,p_qte_line_tbl_service_db => l_qte_line_tbl_service_db
317 ,p_qte_line_dtl_tbl_service_db => l_qte_line_dtl_tbl_service_db);
318 ELSE
319 l_same := 'Y';
320 END IF;
321 END IF;
322
323 IF l_same = 'Y' THEN
324 x_qte_line_rec_db := l_qte_line_tbl(l_index);
325 x_qte_line_tbl_service_db := l_qte_line_tbl_service_db;
326 x_qte_line_dtl_tbl_service_db := l_qte_line_dtl_tbl_service_db;
327 END IF;
328 l_index := l_index + 1;
329 END LOOP;
330 END load_serviceable_service;
331
332
333 procedure updateserviceLine(
334 p_qte_line_rec IN ASO_Quote_Pub.Qte_Line_Rec_Type
335 ,p_qte_line_dtl_rec IN ASO_Quote_Pub.Qte_Line_dtl_Rec_Type
336 ,p_qte_line_tbl_db IN ASO_Quote_Pub.Qte_Line_Tbl_Type
337 ,p_qte_line_dtl_tbl_db IN ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
338 ,x_qte_line_rec OUT NOCOPY ASO_Quote_Pub.Qte_Line_Rec_Type
339 ,x_qte_line_dtl_rec OUT NOCOPY ASO_Quote_Pub.Qte_Line_dtl_Rec_Type
340 )
341 IS
342 l_qte_line_rec ASO_Quote_Pub.Qte_Line_Rec_Type
343 := ASO_Quote_Pub.g_miss_Qte_Line_rec;
344
345 l_qte_line_dtl_rec ASO_Quote_Pub.Qte_Line_dtl_Rec_Type
346 := ASO_Quote_Pub.g_miss_Qte_Line_dtl_rec;
347
348 l_found varchar2(1) := 'N';
349 l_index NUMBER := 1;
350 BEGIN
351
352 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
353 IBE_Util.Debug('updateserviceline p_qte_line_tbl_db.count='
354 ||p_qte_line_tbl_db.count);
355 END IF;
356
357
358 while l_found = 'N' and l_index <= p_qte_line_tbl_db.count Loop
359
360 IF p_qte_line_tbl_db(l_index).inventory_item_id = p_qte_line_rec.inventory_item_id
361 and p_qte_line_tbl_db(l_index).organization_id = p_qte_line_rec.organization_id
362 and p_qte_line_tbl_db(l_index).uom_code = p_qte_line_rec.uom_code then
363 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
364 IBE_Util.Debug('updateserviceline start update');
365 END IF;
366 l_qte_line_rec := p_qte_line_rec;
367 l_qte_line_dtl_rec := p_qte_line_dtl_rec;
368 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
369 IBE_Util.Debug('update service inventory_item_id'||l_qte_line_rec.inventory_item_id);
370 END IF;
371 l_qte_line_rec.quote_line_id := p_qte_line_tbl_db(l_index).quote_line_id;
372 l_qte_line_rec.quantity := p_qte_line_tbl_db(l_index).quantity
373 + l_qte_line_rec.quantity;
374 l_qte_line_rec.operation_code := 'UPDATE';
375
376 l_qte_line_dtl_rec.service_ref_qte_line_index
377 := FND_API.G_MISS_NUM;
378 l_qte_line_dtl_rec.qte_line_index
379 := FND_API.G_MISS_NUM;
380 l_qte_line_dtl_rec.operation_code
381 := 'UPDATE';
382 l_qte_line_dtl_rec.quote_line_id
383 := l_qte_line_rec.quote_line_id;
384 l_qte_line_dtl_rec.quote_line_detail_id
385 := p_qte_line_dtl_tbl_db(l_index).quote_line_detail_id;
386 l_found := 'Y';
387 END IF;
388 l_index := l_index +1;
389 END LOOP;
390
391 x_qte_line_rec := l_qte_line_rec;
392 x_qte_line_dtl_rec := l_qte_line_dtl_rec;
393
394 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
395 IBE_Util.Debug('update service inventory_item_id'||x_qte_line_rec.inventory_item_id);
396 IBE_Util.Debug('update service quote_line_id'||x_qte_line_rec.quote_line_id);
397 IBE_Util.Debug('update service quote_line_id'||x_qte_line_dtl_rec.quote_line_detail_id);
398 END IF;
399 END updateserviceline;
400
401 PROCEDURE header_agreements(
402 p_api_version IN NUMBER := 1 ,
403 p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE ,
404 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
405 x_return_status OUT NOCOPY VARCHAR2 ,
406 x_msg_count OUT NOCOPY NUMBER ,
407 x_msg_data OUT NOCOPY VARCHAR2 ,
408 p_qte_header_rec IN aso_quote_pub.Qte_Header_Rec_Type ,
409 p_hdr_payment_tbl IN aso_quote_pub.Payment_Tbl_Type,
410 x_hdr_payment_tbl OUT NOCOPY aso_quote_pub.Payment_Tbl_Type ) is
411
412 cursor c_term_id(p_contract_id number) is
413 select term_id
414 from oe_agreements
415 where agreement_id = p_contract_id;
416
417 cursor c_payment_id(p_quote_hdr_id number) is
418 select payment_id
419 from aso_payments
420 where quote_header_id = p_quote_hdr_id
421 and quote_line_id is null;
422
423 L_API_NAME CONSTANT VARCHAR2(30) := 'handle_header_agreements';
424 L_API_VERSION CONSTANT NUMBER := 1.0;
425 l_payment_id number := null;
426 l_payment_term_id number := fnd_api.g_miss_num;
427 l_hdr_payment_tbl aso_quote_pub.Payment_Tbl_Type;
428 counter number;
429 rec_term_id c_term_id%rowtype;
430 rec_payment_id c_payment_id%rowtype;
431
432 begin
433 -- Standard Start of API savepoint
434 SAVEPOINT handle_header_agreements_pvt;
435 -- Standard call to check for call compatibility.
436 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
437 p_api_version,
438 L_API_NAME ,
439 G_PKG_NAME )
440 THEN
441 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
442 END IF;
443 -- Initialize message list if p_init_msg_list is set to TRUE.
444 IF FND_API.To_Boolean(p_init_msg_list) THEN
445 FND_Msg_Pub.initialize;
446 END IF;
447 -- Initialize API return status to success
448 x_return_status := FND_API.G_RET_STS_SUCCESS;
449 -- API body
450
451 l_hdr_payment_tbl := p_hdr_payment_tbl;
452 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
453 ibe_util.debug('Incoming header payment rec has '||p_hdr_payment_tbl.count||' records');
454 ibe_util.debug('Incoming agreementId is '||p_qte_header_rec.contract_id );
455 END IF;
456
457 if(p_qte_header_rec.contract_id is null or p_qte_header_rec.contract_id <> fnd_api.g_miss_num) then
458 if(p_qte_header_rec.contract_id is not null
459 and p_qte_header_rec.contract_id <> fnd_api.g_miss_num) then
460 for rec_term_id in c_term_id(p_qte_header_rec.contract_id) loop
461 l_payment_term_id := rec_term_id.term_id;
462 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
463 ibe_util.debug('payment term id when contract id is not null and not g_miss '||l_payment_term_id);
464 END IF;
465 exit when c_term_id%notfound;
466 end loop;
467 elsif (p_qte_header_rec.contract_id is null ) then
468 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
469 ibe_util.debug('p_qte_header_rec.contract_id is null hence l_payment_term_id is null');
470 END IF;
471 -- changed 4/5/04 for bug 3551866
472 --l_payment_term_id := null;
473 l_payment_term_id := fnd_profile.value('IBE_DEFAULT_PAYMENT_TERM_ID');
474 end if;
475
476 if(p_hdr_payment_tbl.count>0) then
477 for counter in 1..p_hdr_payment_tbl.count loop
478 if (p_hdr_payment_tbl(counter).quote_header_id = p_qte_header_rec.quote_header_id
479 and (p_hdr_payment_tbl(counter).quote_line_id is null or
480 p_hdr_payment_tbl(counter).quote_line_id = fnd_api.g_miss_num) ) then
481 if(p_hdr_payment_tbl(counter).operation_code <> 'DELETE') then
482 l_hdr_payment_tbl(counter).payment_term_id := l_payment_term_id;
483 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
484 ibe_util.debug('header_payment_tbl.payment_term_id '||l_payment_term_id);
485 END IF;
486 end if;
487 end if;
488 end loop;
489 else
490 counter := 1;
491 for rec_payment_id in c_payment_id(p_qte_header_rec.quote_header_id) loop
492 l_payment_id := rec_payment_id.payment_id;
493 exit when c_payment_id%notfound;
494 end loop;
495 l_hdr_payment_tbl(counter).quote_header_id := p_qte_header_rec.quote_header_id;
496 l_hdr_payment_tbl(counter).quote_line_id := null;
497 if(l_payment_id is not null ) then
498 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
499 ibe_util.debug('Input payment table is empty but record in database');
500 END IF;
501 l_hdr_payment_tbl(counter).payment_id := l_payment_id;
502 l_hdr_payment_tbl(counter).payment_term_id := l_payment_term_id;
503 l_hdr_payment_tbl(counter).operation_code := 'UPDATE';
504 else
505 if (l_payment_term_id is not null) then
506 l_hdr_payment_tbl(counter).payment_term_id := l_payment_term_id;
507 l_hdr_payment_tbl(counter).operation_code := 'CREATE';
508 end if;
509 end if;
510 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
511 ibe_util.debug('outgoing payment table quote_header_id '||l_hdr_payment_tbl(1).quote_header_id);
512 ibe_util.debug('outgoing payment table quote_line_id '||l_hdr_payment_tbl(1).quote_line_id);
513 ibe_util.debug('outgoing payment table payment_id '||l_hdr_payment_tbl(1).payment_id);
514 ibe_util.debug('outgoing payment table payment_term_id '||l_hdr_payment_tbl(1).payment_term_id);
515 ibe_util.debug('outgoing payment table operation_code '||l_hdr_payment_tbl(1).operation_code);
516 END IF;
517
518 end if;
519 else
520 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
521 ibe_util.debug('Incoming agreement id is g_miss');
522 END IF;
523 end if;
524 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
525 ibe_util.debug('outgoing payment table from header_agreements API');
526 END IF;
527 x_hdr_payment_tbl := l_hdr_payment_tbl;
528
529 -- End of API body.
530
531 -- Standard check of p_commit.
532 IF FND_API.To_Boolean(p_commit) THEN
533 COMMIT WORK;
534 END IF;
535 -- Standard call to get message count and if count is 1, get message info.
536 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
537 p_count => x_msg_count ,
538 p_data => x_msg_data);
539
540 EXCEPTION
541 WHEN FND_API.G_EXC_ERROR THEN
542 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
543 ibe_util.debug('Expected error in IBE_QUOTE_SAVE_PVT.header_agreements');
544 END IF;
545 ROLLBACK TO handle_header_agreements_pvt;
546 x_return_status := FND_API.G_RET_STS_ERROR;
547 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
548 p_count => x_msg_count ,
549 p_data => x_msg_data);
550 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
551 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
552 ibe_util.debug('Unexpected error in IBE_QUOTE_SAVE_PVT.header_agreements');
553 END IF;
554 ROLLBACK TO handle_header_agreements_pvt;
555 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
556 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
557 p_count => x_msg_count ,
558 p_data => x_msg_data);
559 WHEN OTHERS THEN
560 ROLLBACK TO handle_header_agreements_pvt;
561 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
562 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
563 ibe_util.debug('Unknown error in IBE_QUOTE_SAVE_PVT.header_agreements');
564 END IF;
565 IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
566 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
567 L_API_NAME);
568 END IF;
569
570 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
571 p_count => x_msg_count ,
572 p_data => x_msg_data);
573
574 end header_agreements;
575
576 PROCEDURE Default_Header_Record(
577 p_qte_header_rec IN ASO_Quote_Pub.Qte_Header_Rec_Type ,
578 p_auto_update_active_quote IN VARCHAR2 := FND_API.G_TRUE ,
579 p_hdr_payment_tbl IN aso_quote_pub.Payment_Tbl_Type ,
580 x_hdr_payment_tbl OUT NOCOPY aso_quote_pub.Payment_Tbl_Type ,
581 x_qte_header_rec OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type,
582 x_return_status OUT NOCOPY VARCHAR2 ,
583 x_msg_count OUT NOCOPY NUMBER ,
584 x_msg_data OUT NOCOPY VARCHAR2
585 )
586 IS
587 l_duration NUMBER := NULL;
588 l_last_update_date DATE;
589 l_party_id NUMBER;
590 l_cust_account_id NUMBER;
591 l_contract_id NUMBER;
592 l_quote_source_code VARCHAR2(240);
593 l_resource_id NUMBER := NULL;
594 l_publish_flag VARCHAR2(1);
595 l_price_list_id NUMBER;
596 l_agmt_associated VARCHAR2(1):= FND_API.G_FALSE;
597 l_org_payment_id NUMBER := NULL;
598 l_installment_options VARCHAR2(30) := NULL;
599
600
601 BEGIN
602 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
603 IBE_Util.Debug('start Default_Header_Record');
604 END IF;
605 --DBMS_OUTPUT.PUT_line('p_qte_header_rec.quote_header_id '||p_qte_header_rec.quote_header_id);
606 x_qte_header_rec := p_qte_header_rec;
607 x_hdr_payment_tbl := p_hdr_payment_tbl;
608 -- need get active cart for account user (ignore passed in value)
609 IF p_qte_header_rec.quote_header_id = FND_API.G_MISS_NUM
610
611 AND p_qte_header_rec.quote_source_code = 'IStore Account'
612 AND (p_qte_header_rec.quote_name = 'IBE_PRMT_SC_UNNAMED' --MANNAMRA: Changed default quote name value from IBEACTIVECART to IBE_PRMT_SC_UNNAMED
613 --09/16/02
614 OR p_qte_header_rec.quote_name = FND_API.G_MISS_CHAR) THEN
615 --DBMS_OUTPUT.PUT_line('passed in qte_header_id is g_miss ');
616 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
617 IBE_Util.Debug(' need to get active cart');
618 END IF;
619 x_qte_header_rec.quote_header_id :=
620 IBE_Quote_Misc_pvt.Get_Active_Quote_ID(
621 p_party_id => p_qte_header_rec.party_id,
622 p_cust_account_id => p_qte_header_rec.cust_account_id);
623 -- create quote
624 IF x_qte_header_rec.quote_header_id = 0 THEN
625 x_qte_header_rec.quote_header_id := FND_API.G_MISS_NUM;
626 -- if create quote and contract_id(agreement_id) is not set
627 -- then check if there is user default agreement
628 IF x_qte_header_rec.contract_id = FND_API.G_MISS_NUM THEN
629 x_qte_header_rec.contract_id := NVL(FND_Profile.Value('IBE_USER_DEFAULT_AGREEMENT'),
630 FND_API.G_MISS_NUM);
631 END IF;
632 -- update quote
633 /*A quote header_id is passed in during every update quote operation*/
634 ELSE
635 IF NOT FND_API.To_Boolean(p_auto_update_active_quote) THEN
636 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
637 FND_Message.Set_Name('IBE', 'IBE_SC_QUOTE_NEED_REFRESH');
638 FND_Msg_Pub.Add;
639 END IF;
640
641 RAISE FND_API.G_EXC_ERROR; -- need error message
642 END IF;
643 END IF;
644 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
645 IBE_Util.Debug('after get active cart id = '|| x_qte_header_rec.quote_header_id);
646 END IF;
647 END IF;
648
649 -- if contract_id is set, then overwrite price_list_id field
650 IF x_qte_header_rec.contract_id <> FND_API.G_MISS_NUM THEN
651 -- if contract_id is null it is because the user wants to set to null.
652 -- just use price_list_id that is set.
653 IF x_qte_header_rec.contract_id IS NULL THEN
654 NULL;
655 -- if contract_id is not null, get its associated price list id from DB
656 ELSE
657 SELECT price_list_id
658 INTO x_qte_header_rec.price_list_id
659 FROM OE_Agreements_B
660 WHERE agreement_id = x_qte_header_rec.contract_id;
661
662 l_agmt_associated := FND_API.G_TRUE;
663 END IF;
664 END IF;
665
666 -- only set expiration date, default order_type_id, quote_category_code and quote_name
667 -- when quote_header_id is null
668
669 IF (x_qte_header_rec.quote_header_id = FND_API.G_MISS_NUM or x_qte_header_rec.quote_header_id is null) THEN
670
671 IF x_qte_header_rec.quote_name = FND_API.G_MISS_CHAR
672 AND (x_qte_header_rec.quote_source_code = 'IStore Walkin'
673 OR x_qte_header_rec.quote_source_code = 'IStore Account'
674 OR x_qte_header_rec.quote_source_code = 'IStore InstallBase'
675 OR x_qte_header_rec.quote_source_code = 'IStore ProcPunchout') THEN
676 x_qte_header_rec.quote_name := 'IBE_PRMT_SC_UNNAMED';--MANNAMRA: Changed default quote name value from IBEACTIVECART to IBE_PRMT_SC_UNNAMED
677 --09/16/02
678 END IF;
679
680 ELSE -- header_id is there
681 --DBMS_OUTPUT.PUT_line('before the select stmt ');
682 --DBMS_OUTPUT.PUT_line('x_qte_header_rec.quote_header_id '||x_qte_header_rec.quote_header_id);
683 SELECT party_id ,
684 cust_account_id ,
685 last_update_date,
686 contract_id ,
687 quote_source_code,
688 resource_id,
689 publish_flag,
690 price_list_id
691 INTO l_party_id ,
692 l_cust_account_id ,
693 l_last_update_date,
694 l_contract_id ,
695 l_quote_source_code,
696 l_resource_id,
697 l_publish_flag,
698 l_price_list_id
699 FROM aso_quote_headers_all
700 WHERE quote_header_id = x_qte_header_rec.quote_header_id;
701 --DBMS_OUTPUT.PUT_line('after select statement ');
702 -- set last_update_date
703 --Removing this check because this is already being done in validate_user_update
704 --IF x_qte_header_rec.last_update_date = FND_API.G_MISS_DATE THEN
705 x_qte_header_rec.last_update_date := l_last_update_date;
706 --END IF;
707
708 IF x_qte_header_rec.party_id = FND_API.G_MISS_NUM THEN
709 x_qte_header_rec.party_id := l_party_id;
710 END IF;
711
712 IF x_qte_header_rec.cust_account_id = FND_API.G_MISS_NUM THEN
713 x_qte_header_rec.cust_account_id := l_cust_account_id;
714 END IF;
715
716 /* Check if the quote_header_id is for a published quote then keep the price_list_id as whatever in the DB.
717 Ideally we do not want to change the price list id put in by the Sales Rep for Update of published Quotes.
718 This is true only when the agreement is not associated to the quote.*/
719 IF (l_resource_id is not null AND nvl(l_publish_flag,'N')='Y'
720 AND l_agmt_associated = FND_API.G_FALSE AND l_price_list_id is not null) THEN
721 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
722 IBE_UTIL.debug('Please revert back the price list id as in the DB,as this is a Published quote, price_list_id='||l_price_list_id);
723 END IF;
724 x_qte_header_rec.price_list_id := l_price_list_id;
725 END IF;
726
727 /* if agreement_id in DB is not null and the current record
728 does not have it set, use the value from DB.*/
729 IF x_qte_header_rec.contract_id = FND_API.G_MISS_NUM
730 AND l_contract_id IS NOT NULL THEN
731 x_qte_header_rec.contract_id := l_contract_id;
732
733 SELECT price_list_id
734 INTO x_qte_header_rec.price_list_id
735 FROM OE_Agreements_B
736 WHERE agreement_id = l_contract_id;
737 END IF;
738 --DBMS_OUTPUT.PUT_line('BEFORE header agreements ');
739 header_agreements(
740 p_api_version => 1.0 ,
741 p_init_msg_list => FND_API.G_TRUE ,
742 p_commit => FND_API.G_FALSE ,
743 x_return_status => x_return_status ,
744 x_msg_count => x_msg_count ,
745 x_msg_data => x_msg_data ,
746 p_qte_header_rec => x_qte_header_rec ,
747 p_hdr_payment_tbl => p_hdr_payment_tbl,
748 x_hdr_payment_tbl => x_hdr_payment_tbl);
749 --DBMS_OUTPUT.PUT_line('AFTER header agreements ');
750
751 IF x_qte_header_rec.quote_source_code = FND_API.G_MISS_CHAR THEN
752 x_qte_header_rec.quote_source_code := l_quote_source_code;
753 END IF;
754
755 -- expiration date doesn't change from 1st one set for sales rep
756 -- for self service, we want to avoid expiring the quote
757 /*
758 IF (x_qte_header_rec.resource_id = FND_API.G_MISS_NUM) AND
759 (l_resource_id is null) THEN
760 -- temporary way to have non-expiring self service quotes
761 x_qte_header_rec.quote_expiration_date := SYSDATE + 10000;
762 END IF;
763 */
764
765 END IF;
766
767 -- set price frozen date
768 -- Removed the code for setting the price frozen date for the bug# 2917587
769
770 -- default payment term id if pay now is enabled
771 IF x_hdr_payment_tbl.count=0 THEN
772 IBE_Util.Debug('no header payment record passed down so far.');
773 IBE_Util.Debug('checking if PAY NOW is turned on...');
774 IF x_qte_header_rec.org_id is NULL OR x_qte_header_rec.org_id=FND_API.G_MISS_NUM THEN
775 IBE_Util.Debug('x_qte_header_rec.org_id is null or GMISS');
776 l_installment_options := oe_sys_parameters.value(
777 param_name => 'INSTALLMENT_OPTIONS');
778 ELSE
779 IBE_Util.Debug('x_qte_header_rec.org_id='||x_qte_header_rec.org_id);
780 l_installment_options := oe_sys_parameters.value(
781 param_name => 'INSTALLMENT_OPTIONS',
782 p_org_id => x_qte_header_rec.org_id);
783 END IF;
784 IBE_Util.Debug('OM parameter INSTALLMENT_OPTIONS='||l_installment_options);
785
786 IF NVL(l_installment_options,'NONE')='ENABLE_PAY_NOW' THEN
787 IBE_Util.Debug('Pay Now is enabled.');
788 IF x_qte_header_rec.quote_header_id is null OR x_qte_header_rec.quote_header_id=FND_API.G_MISS_NUM THEN
789 IBE_Util.Debug('it is a new cart.');
790 ELSE
791 IBE_Util.Debug('existing cart,x_qte_header_rec.quote_header_id='|| x_qte_header_rec.quote_header_id);
792 IBE_Util.Debug('checking if a header payment record is already present...');
793 BEGIN
794 SELECT payment_id into l_org_payment_id FROM ASO_payments
795 WHERE QUOTE_HEADER_ID = x_qte_header_rec.quote_header_id AND quote_line_id is null;
796 IBE_Util.Debug('header payment record found,l_org_payment_id='||l_org_payment_id);
797 EXCEPTION
798 WHEN NO_DATA_FOUND THEN
799 l_org_payment_id := NULL;
800 IBE_Util.Debug('no header payment record found');
801 WHEN TOO_MANY_ROWS THEN
802 l_org_payment_id := FND_API.G_MISS_NUM;
803 IBE_Util.Debug('too many header payment records found');
804 END;
805 END IF;
806
807 IF x_qte_header_rec.quote_header_id is null OR l_org_payment_id is null THEN
808 IBE_Util.Debug('initializing header payment record...');
809 x_hdr_payment_tbl(1).PAYMENT_TERM_ID := FND_PROFILE.VALUE('IBE_DEFAULT_PAYMENT_TERM_ID');
810 IBE_Util.Debug('profile option IBE_DEFAULT_PAYMENT_TERM_ID='||x_hdr_payment_tbl(1).PAYMENT_TERM_ID);
811 IF x_qte_header_rec.quote_header_id is not null THEN
812 x_hdr_payment_tbl(1).QUOTE_HEADER_ID := x_qte_header_rec.quote_header_id;
813 END IF;
814 --x_hdr_payment_tbl(1).PAYMENT_TYPE_CODE := NULL;
815 x_hdr_payment_tbl(1).OPERATION_CODE := 'CREATE';
816 IBE_Util.Debug('header payment record is defaulted for Pay Now');
817 END IF;
818 ELSE
819 IBE_Util.Debug('Pay Now is turned off');
820 IBE_Util.Debug('no header payment record was populated');
821 END IF;
822 END IF;
823
824 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
825 IBE_Util.Debug('done Default_Header_Record');
826 END IF;
827
828 END Default_Header_Record;
829
830 procedure setLineDefaultVal(
831 p_quote_header_id in number
832 ,p_qte_line_tbl in ASO_Quote_Pub.QTE_LINE_TBL_TYPE
833 ,p_qte_line_dtl_tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
834 ,p_combinesameitem in VARCHAR2 := FND_API.G_MISS_CHAR
835 ,x_qte_line_tbl out nocopy ASO_Quote_Pub.QTE_LINE_TBL_TYPE
836 ,x_qte_line_dtl_tbl OUT NOCOPY ASO_Quote_Pub.QTE_LINE_DTL_TBL_TYPE
837 )
838 is
839 l_length NUMBER :=0;
840
841 l_combinesameitem VARCHAR2(2) := FND_API.G_MISS_CHAR;
842 l_quantity NUMBER;
843 l_marketing_source_code_id NUMBER;
844 l_quote_line_id NUMBER;
845 l_item_type_code VARCHAR2(30);
846
847 l_pricing_line_type_indicator VARCHAR2(3);
848 l_found_PRG varchar2(1) := 'N';
849
850 l_qte_line_rec_db ASO_Quote_Pub.QTE_LINE_REC_TYPE;
851 l_qte_line_tbl_service ASO_Quote_Pub.QTE_LINE_TBL_TYPE;
852 l_qte_line_dtl_tbl_service ASO_Quote_Pub.QTE_LINE_DTL_TBL_TYPE;
853
854 l_qte_line_tbl_service_db ASO_Quote_Pub.QTE_LINE_TBL_TYPE;
855 l_qte_line_dtl_tbl_service_db ASO_Quote_Pub.QTE_LINE_DTL_TBL_TYPE;
856
857 l_line_tbl_index NUMBER :=1;
858 l_line_dtl_tbl_index NUMBER :=1;
859
860 l_found varchar2(1);
861 l_qte_line_index NUMBER;
862 l_line_level_services VARCHAR2(1) := 'N';
863
864 --temp vars for OUT NOCOPY params
865 l_qte_line_tbl_tmp ASO_Quote_Pub.QTE_LINE_TBL_TYPE;
866 l_qte_line_dtl_tbl_tmp ASO_Quote_Pub.QTE_LINE_DTL_TBL_TYPE;
867
868
869 cursor c_getlineinfo(p_quote_header_id number, l_inventory_item_id number,l_uom_code varchar2)
870 is
871 select quote_line_id, item_type_code ,quantity,marketing_source_code_id
872 from aso_quote_lines
873 where quote_header_id = p_quote_header_id
874 and inventory_item_id = l_inventory_item_id and uom_code = l_uom_code;
875
876 cursor c_checkForPRG (p_quote_header_id number)
877 is
878 select pricing_line_type_indicator
879 from aso_quote_lines
880 where quote_header_id = p_quote_header_id;
881
882 BEGIN
883 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
884 IBE_Util.Debug('start setLineDefaultval');
885 END IF;
886
887
888 FOR i IN 1..p_qte_line_dtl_tbl.count LOOP
889 x_qte_line_dtl_tbl(i) := p_qte_line_dtl_tbl(i);
890 END LOOP;
891
892
893 FOR i IN 1..p_qte_line_tbl.count LOOP
894 x_qte_line_tbl(i) := p_qte_line_tbl(i);
895 if (x_qte_line_tbl(i).pricing_line_type_indicator = 'F') then
896 l_found_PRG := 'Y';
897 end if;
898 END LOOP;
899
900 -- added 1/26/04: Bug #3399026 -- need to check if target cart has PRG lines as well
901 open c_checkForPRG(p_quote_header_id);
902 loop
903 fetch c_checkForPRG into l_pricing_line_type_indicator;
904 exit when c_checkForPRG%notfound;
905 if (l_pricing_line_type_indicator = 'F') then
906 l_found_PRG := 'Y';
907 exit;
908 end if;
909 end loop;
910 close c_checkForPRG;
911
912 IF (p_combinesameitem = FND_API.G_MISS_CHAR) THEN
913 l_combinesameitem := FND_Profile.Value('IBE_SC_MERGE_SHOPCART_LINES');
914 Else
915 l_combinesameitem := p_combinesameitem;
916 END IF;
917
918 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
919 IBE_Util.Debug('Checking line level services profile');
920 IBE_Util.Debug('IBE_USE_SUPPORT: '||FND_Profile.Value('IBE_USE_SUPPORT'));
921 IBE_Util.Debug('IBE_USE_SUPPORT_CART_LEVEL '||FND_Profile.Value('IBE_USE_SUPPORT_CART_LEVEL'));
922 END IF;
923
924 IF (FND_Profile.Value('IBE_USE_SUPPORT') = 'Y' ) THEN
925
926 l_line_level_services := 'Y';
927 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
928 IBE_Util.Debug('line level services turned on');
929 END IF;
930
931 END IF;
932
933 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
934 IBE_Util.Debug('looping around input quote line table');
935 END IF;
936 FOR i in 1..p_qte_line_tbl.count LOOP
937
938 -- set quote_header_id
939 if ((x_qte_line_tbl(i).quote_header_id is null
940 or x_qte_line_tbl(i).quote_header_id = FND_API.G_MISS_NUM)
941 and (p_quote_header_id is not null
942 and p_quote_header_id <> FND_API.G_MISS_NUM)) then
943 x_qte_line_tbl(i).quote_header_id := p_quote_header_id;
944
945 if ((x_qte_line_tbl(i).quote_line_id is null
946 or x_qte_line_tbl(i).quote_line_id = FND_API.G_MISS_NUM)
947 and (x_qte_line_tbl(i).operation_code is null
948 or x_qte_line_tbl(i).operation_code = FND_API.G_MISS_CHAR)) then
949
950 x_qte_line_tbl(i).operation_code := 'CREATE';
951 END IF;
952 END IF;
953
954 -- treat quantity 0 as delete
955 IF (p_qte_line_tbl(i).quantity = 0) THEN
956 x_qte_line_tbl(i).operation_code := 'DELETE';
957 END IF;
958
959 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
960 IBE_Util.Debug(' l_combinesameitem='||l_combinesameitem);
961 IBE_Util.Debug('before combine item_type_code='||x_qte_line_tbl(i).item_type_code);
962 IBE_Util.Debug('inventory_item_id='||x_qte_line_tbl(i).inventory_item_id);
963 IBE_Util.Debug('quantity='||x_qte_line_tbl(i).quantity);
964 IBE_Util.Debug('operation_code='||x_qte_line_tbl(i).operation_code);
965 END IF;
966
967 -- combine same item
968 IF l_combinesameitem = 'Y'
969 and p_quote_header_id is not null
970 and p_quote_header_id <> FND_API.G_MISS_NUM
971 and x_qte_line_tbl(i).operation_code = 'CREATE'
972 and l_found_PRG = 'N' THEN
973
974 /*
975 -- 9/2/03: For Merging, SVA Case, don't compare SRV's
976 -- so, handle SVA case just like STD case
977 IF x_qte_line_tbl(i).item_type_code = 'SVA' THEN
978
979 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
980 IBE_Util.Debug('Current item type code in input quote line tbl is SVA');
981 END IF;
982
983 IF (l_line_level_services <> 'Y') THEN
984
985 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
986 IBE_Util.Debug('Entering combine same item logic: Line level services turned off');
987 END IF;
988
989 l_qte_line_tbl_service := ASO_Quote_Pub.g_miss_Qte_Line_tbl;
990 l_qte_line_dtl_tbl_service := ASO_Quote_Pub.g_miss_Qte_Line_dtl_tbl;
991 -- find service line and detail line based on servicable item
992 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
993 IBE_Util.Debug('call fnd_service with i='||i);
994 END IF;
995
996 find_service
997 ( p_qte_line_index => i -- serviceable index
998 ,p_qte_line_tbl => p_qte_line_tbl
999 ,p_qte_line_dtl_tbl => x_qte_line_dtl_tbl
1000 ,x_qte_line_tbl_service => l_qte_line_tbl_service
1001 ,x_qte_line_dtl_tbl_service => l_qte_line_dtl_tbl_service);
1002
1003 -- find a same servicable and service item from db
1004 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1005 IBE_Util.Debug('call load_serviceable_service ');
1006 END IF;
1007 load_serviceable_service
1008 ( p_quote_header_id => p_quote_header_id
1009 ,p_qte_line_rec => x_qte_line_tbl(i)
1010 ,p_qte_line_tbl_service => l_qte_line_tbl_service
1011 ,p_qte_line_dtl_tbl_service => l_qte_line_dtl_tbl_service
1012 ,x_qte_line_rec_db => l_qte_line_rec_db
1013 ,x_qte_line_tbl_service_db => l_qte_line_tbl_service_db
1014 ,x_qte_line_dtl_tbl_service_db => l_qte_line_dtl_tbl_service_db);
1015
1016 --- doing merge
1017 IF l_qte_line_rec_db.quote_line_id is not null
1018 and l_qte_line_rec_db.quote_line_id <> FND_API.G_MISS_NUM THEN
1019 --- setup servicable item
1020 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1021 IBE_Util.Debug('merge serviceable line_id'
1022 || l_qte_line_rec_db.quote_line_id);
1023 END IF;
1024
1025 x_qte_line_tbl(i).operation_code := 'UPDATE';
1026 x_qte_line_tbl(i).quantity := x_qte_line_tbl(i).quantity
1027 + nvl(l_qte_line_rec_db.quantity,0);
1028 x_qte_line_tbl(i).quote_line_id := l_qte_line_rec_db.quote_line_id;
1029 l_line_tbl_index :=1;
1030 l_line_dtl_tbl_index :=1;
1031
1032 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1033 IBE_Util.Debug('merge service line count='
1034 || l_qte_line_dtl_tbl_service.count);
1035 END IF;
1036
1037 FOR i in 1..l_qte_line_dtl_tbl_service.count LOOP
1038
1039 l_line_tbl_index := l_qte_line_dtl_tbl_service(i).qte_line_index;
1040 -- this line is hack
1041 l_line_dtl_tbl_index := l_qte_line_dtl_tbl_service(i).service_ref_qte_line_index;
1042
1043 updateserviceLine
1044 ( p_qte_line_rec => x_qte_line_tbl(l_line_tbl_index)
1045 ,p_qte_line_dtl_rec => x_qte_line_dtl_tbl(l_line_dtl_tbl_index)
1046 ,p_qte_line_tbl_db => l_qte_line_tbl_service_db
1047 ,p_qte_line_dtl_tbl_db => l_qte_line_dtl_tbl_service_db
1048 ,x_qte_line_rec => l_qte_line_tbl_tmp(l_line_tbl_index)
1049 ,x_qte_line_dtl_rec => l_qte_line_dtl_tbl_tmp(l_line_dtl_tbl_index));
1050
1051 x_qte_line_tbl(l_line_tbl_index) := l_qte_line_tbl_tmp(l_line_tbl_index);
1052 x_qte_line_dtl_tbl(l_line_dtl_tbl_index) := l_qte_line_dtl_tbl_tmp(l_line_dtl_tbl_index);
1053
1054 x_qte_line_dtl_tbl(l_line_dtl_tbl_index).service_ref_line_id
1055 := l_qte_line_rec_db.quote_line_id ;
1056
1057 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1058 IBE_Util.Debug('quote line id='
1059 ||x_qte_line_dtl_tbl(i).quote_line_id);
1060 END IF;
1061 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1062 IBE_Util.Debug('quote line detail id='
1063 ||x_qte_line_dtl_tbl(i).quote_line_detail_id);
1064 END IF;
1065 END LOOP;
1066
1067 END IF; -- end merge service item
1068 END IF; --line level services check
1069 -- 9/2/03: For Merging, SVA Case, don't compare SRV's
1070 -- so, handle SVA case just like STD case
1071 ELSE
1072 */
1073 l_quote_line_id := FND_API.G_MISS_NUM;
1074 l_item_type_code := FND_API.G_MISS_CHAR;
1075 l_quantity := FND_API.G_MISS_NUM;
1076 l_marketing_source_code_id := FND_API.G_MISS_NUM;
1077 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1078 IBE_Util.Debug('Calling the item cursor in MergeLines with uom_code'||x_qte_line_tbl(i).uom_code);
1079 END IF;
1080 open c_getlineinfo(p_quote_header_id
1081 ,x_qte_line_tbl(i).inventory_item_id,x_qte_line_tbl(i).uom_code);
1082 fetch c_getlineinfo into l_quote_line_id,
1083 l_item_type_code,
1084 l_quantity,
1085 l_marketing_source_code_id;
1086 close c_getlineinfo;
1087
1088
1089 IF (l_item_type_code is not null
1090 and ((l_item_type_code = 'STD') or ((l_item_type_code = 'SVA') and (l_line_level_services <> 'Y')) )
1091 and (l_quote_line_id is not null) ) THEN
1092
1093 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1094 IBE_Util.Debug('Dealing with a standard item');
1095 END IF;
1096 x_qte_line_tbl(i).operation_code := 'UPDATE';
1097 x_qte_line_tbl(i).quantity := x_qte_line_tbl(i).quantity
1098 + nvl(l_quantity,0);
1099 x_qte_line_tbl(i).quote_line_id := l_quote_line_id;
1100
1101 -- Fix for Bug#6015035, scnagara
1102 -- Added setting of dff attributes to G_MISS_CHAR when merge profile is on
1103 x_qte_line_tbl(i).ATTRIBUTE_CATEGORY := FND_API.G_MISS_CHAR;
1104 x_qte_line_tbl(i).ATTRIBUTE1 := FND_API.G_MISS_CHAR;
1105 x_qte_line_tbl(i).ATTRIBUTE2 := FND_API.G_MISS_CHAR;
1106 x_qte_line_tbl(i).ATTRIBUTE3 := FND_API.G_MISS_CHAR;
1107 x_qte_line_tbl(i).ATTRIBUTE4 := FND_API.G_MISS_CHAR;
1108 x_qte_line_tbl(i).ATTRIBUTE5 := FND_API.G_MISS_CHAR;
1109 x_qte_line_tbl(i).ATTRIBUTE6 := FND_API.G_MISS_CHAR;
1110 x_qte_line_tbl(i).ATTRIBUTE7 := FND_API.G_MISS_CHAR;
1111 x_qte_line_tbl(i).ATTRIBUTE8 := FND_API.G_MISS_CHAR;
1112 x_qte_line_tbl(i).ATTRIBUTE9 := FND_API.G_MISS_CHAR;
1113 x_qte_line_tbl(i).ATTRIBUTE10 := FND_API.G_MISS_CHAR;
1114 x_qte_line_tbl(i).ATTRIBUTE11 := FND_API.G_MISS_CHAR;
1115 x_qte_line_tbl(i).ATTRIBUTE12 := FND_API.G_MISS_CHAR;
1116 x_qte_line_tbl(i).ATTRIBUTE13 := FND_API.G_MISS_CHAR;
1117 x_qte_line_tbl(i).ATTRIBUTE14 := FND_API.G_MISS_CHAR;
1118 x_qte_line_tbl(i).ATTRIBUTE15 := FND_API.G_MISS_CHAR;
1119 -- End Fix for Bug#6015035, scnagara
1120
1121 --Fix for bug 2727665
1122 x_qte_line_tbl(i).item_type_code := l_item_type_code;
1123 --End fix for 2727665
1124 x_qte_line_tbl(i).marketing_source_code_id := l_marketing_source_code_id;
1125 END IF;
1126 END IF; -- end of combine item
1127
1128 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1129 IBE_Util.Debug('item_type_code='||x_qte_line_tbl(i).item_type_code);
1130 IBE_Util.Debug('inventory_item_id='||x_qte_line_tbl(i).inventory_item_id);
1131 IBE_Util.Debug('quantity='||x_qte_line_tbl(i).quantity);
1132 IBE_Util.Debug('operation_code='||x_qte_line_tbl(i).operation_code);
1133 IBE_Util.Debug('quote_line_id='||x_qte_line_tbl(i).quote_line_id);
1134 IBE_Util.Debug('quote_header_id='||x_qte_line_tbl(i).quote_header_id);
1135 END IF;
1136
1137
1138 -- set line_category_code
1139
1140 IF ( (x_qte_line_tbl(i).operation_code = 'CREATE')
1141 or (x_qte_line_tbl(i).operation_code is null)
1142 or (x_qte_line_tbl(i).operation_code = FND_API.G_MISS_CHAR))
1143 and ((x_qte_line_tbl(i).line_category_code is null )
1144 or (x_qte_line_tbl(i).line_category_code = FND_API.G_MISS_CHAR)) then
1145 x_qte_line_tbl(i).line_category_code := 'ORDER';
1146 END IF;
1147
1148 IF (((x_qte_line_tbl(i).operation_code = 'CREATE')
1149 or (x_qte_line_tbl(i).operation_code is null)
1150 or (x_qte_line_tbl(i).operation_code = FND_API.G_MISS_CHAR))
1151 and (x_qte_line_tbl(i).item_type_code = 'SRV' )
1152 and ((x_qte_line_tbl(i).start_date_active is null )
1153 or (x_qte_line_tbl(i).start_date_active = FND_API.G_MISS_DATE))) THEN
1154 x_qte_line_tbl(i).start_date_active := sysdate;
1155 END IF;
1156
1157 END LOOP;
1158
1159 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1160 IBE_Util.Debug('done setLinedefaultval');
1161 END IF;
1162 END setLineDefaultVal;
1163
1164 PROCEDURE DeleteSharees(
1165 p_api_version_number IN NUMBER
1166 ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
1167 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
1168 ,p_Quote_HEADER_ID IN NUMBER
1169 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
1170 ,X_Return_Status OUT NOCOPY VARCHAR2
1171 ,X_Msg_Count OUT NOCOPY NUMBER
1172 ,X_Msg_Data OUT NOCOPY VARCHAR2
1173 )
1174 IS
1175 l_api_name CONSTANT VARCHAR2(30) := 'DeleteSharees';
1176 l_api_version CONSTANT NUMBER := 1.0;
1177
1178 CURSOR c_get_recipients(c_quote_header_id number) is
1179 SELECT quote_sharee_id,
1180 party_id,
1181 cust_account_id,
1182 quote_sharee_number,
1183 contact_point_id,
1184 fnd.customer_id shared_by_party_id
1185 FROM IBE_SH_QUOTE_ACCESS, fnd_user fnd
1186 where quote_header_id = c_quote_header_id
1187 and ibe_sh_quote_access.created_by = fnd.user_id;
1188 rec_get_recipients c_get_recipients%rowtype;
1189 l_qte_access_rec IBE_QUOTE_SAVESHARE_pvt.quote_access_rec_type
1190 := IBE_QUOTE_SAVESHARE_pvt.G_MISS_QUOTE_ACCESS_REC;
1191
1192 BEGIN
1193 -- Standard Start of API savepoint
1194 SAVEPOINT DELETESHAREES_pvt;
1195 -- Standard call to check for call compatibility.
1196 IF NOT FND_API.Compatible_API_Call (l_api_version,
1197 P_Api_Version_Number,
1198 l_api_name,
1199 G_PKG_NAME )
1200 THEN
1201 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1202 END IF;
1203 -- Initialize message list if p_init_msg_list is set to TRUE.
1204 IF FND_API.To_Boolean( p_init_msg_list ) THEN
1205 FND_Msg_Pub.initialize;
1206 END IF;
1207 -- Initialize API return status to success
1208 x_return_status := FND_API.G_RET_STS_SUCCESS;
1209
1210 IF FND_API.To_Boolean(p_init_msg_list) THEN
1211 FND_Msg_Pub.initialize;
1212 END IF;
1213
1214 -- API body
1215
1216 -- need to delete contact point
1217 -- delete all shares need table handle and generate table handle
1218
1219 /*DELETE
1220 FROM ibe_sh_quote_access
1221 WHERE quote_header_id = p_quote_header_id;*/
1222
1223 FOR rec_get_recipients in c_get_recipients(p_Quote_HEADER_ID) LOOP
1224 l_qte_access_rec.quote_sharee_id := rec_get_recipients.quote_sharee_id;
1225 l_qte_access_rec.quote_sharee_number := rec_get_recipients.quote_sharee_number;
1226 l_qte_access_rec.party_id := rec_get_recipients.party_id;
1227 l_qte_access_rec.cust_account_id := rec_get_recipients.cust_account_id;
1228 l_qte_access_rec.contact_point_id := rec_get_recipients.contact_point_id;
1229 l_qte_access_rec.shared_by_party_id := rec_get_recipients.shared_by_party_id;
1230
1231 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1232 IBE_UTIL.DEBUG('DeleteSharees:Calling delete_recipient');
1233 END IF;
1234
1235 IBE_QUOTE_SAVESHARE_V2_PVT.DELETE_RECIPIENT(
1236 P_Quote_access_rec => l_qte_access_rec ,
1237 p_minisite_id => p_minisite_id ,
1238 --p_notes => p_notes ,
1239 x_return_status => x_return_status ,
1240 x_msg_count => x_msg_count ,
1241 x_msg_data => x_msg_data );
1242
1243 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1244 RAISE FND_API.G_EXC_ERROR;
1245 END IF;
1246 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1247 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1248 END IF;
1249 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1250 IBE_UTIL.DEBUG('DeleteSharees:Done calling delete_recipient');
1251 END IF;
1252 EXIT when c_get_recipients%notfound;
1253 END LOOP;
1254
1255 -- End of API body.
1256 -- Standard check of p_commit.
1257 IF FND_API.To_Boolean( p_commit ) THEN
1258 COMMIT WORK;
1259 END IF;
1260
1261 -- Standard call to get message count and if count is 1, get message info.
1262 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1263 p_count => x_msg_count ,
1264 p_data => x_msg_data);
1265 EXCEPTION
1266 WHEN FND_API.G_EXC_ERROR THEN
1267 ROLLBACK TO DELETESHAREES_pvt;
1268 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1269 IBE_UTIL.DEBUG('Expected error in IBE_QUOTE_SAVE_PVT.DeleteSharees');
1270 END IF;
1271 x_return_status := FND_API.G_RET_STS_ERROR;
1272 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1273 p_count => x_msg_count ,
1274 p_data => x_msg_data);
1275
1276 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1277 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1278 IBE_UTIL.DEBUG('Unexpected error in IBE_QUOTE_SAVE_PVT.DeleteSharees');
1279 END IF;
1280 ROLLBACK TO DELETESHAREES_pvt;
1281 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1282 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1283 p_count => x_msg_count ,
1284 p_data => x_msg_data);
1285 WHEN OTHERS THEN
1286 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1287 IBE_UTIL.DEBUG('Unknown error in IBE_QUOTE_SAVE_PVT.DeleteSharees');
1288 END IF;
1289 ROLLBACK TO DELETESHAREES_pvt;
1290 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1291 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
1292 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
1293 l_api_name);
1294 END IF;
1295 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1296 p_count => x_msg_count ,
1297 p_data => x_msg_data);
1298 END DeleteSharees;
1299
1300
1301 PROCEDURE Delete(
1302 p_api_version_number IN NUMBER := 1 ,
1303 p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE ,
1304 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
1305 x_return_status OUT NOCOPY VARCHAR2 ,
1306 x_msg_count OUT NOCOPY NUMBER ,
1307 x_msg_data OUT NOCOPY VARCHAR2 ,
1308 p_quote_header_id IN NUMBER ,
1309 p_expunge_flag IN VARCHAR2 := FND_API.G_TRUE ,
1310 p_minisite_id IN NUMBER :=FND_API.G_MISS_NUM ,
1311 p_last_update_date IN DATE := FND_API.G_MISS_DATE,
1312 p_Quote_access_tbl IN IBE_QUOTE_SAVESHARE_pvt.QUOTE_ACCESS_TBL_TYPE
1313 := IBE_QUOTE_SAVESHARE_pvt.G_miss_quote_access_Tbl ,
1314 p_notes IN VARCHAR2 := FND_API.G_MISS_CHAR,
1315 -- in even that we are deleting a shared cart
1316 -- could be owner or admin recipient
1317 p_initiator_party_id IN NUMBER :=FND_API.G_MISS_NUM ,
1318 p_initiator_account_id IN NUMBER :=FND_API.G_MISS_NUM
1319 )
1320 IS
1321 l_api_name CONSTANT VARCHAR2(30) := 'DELETE';
1322 l_api_version CONSTANT NUMBER := 1.0;
1323 l_quote_status VARCHAR2(15);
1324 l_quote_status_id NUMBER;
1325 l_quote_header_rec aso_quote_pub.Qte_Header_Rec_Type
1326 := aso_quote_pub.g_miss_qte_header_rec;
1327 l_quote_header_id NUMBER;
1328 l_last_update_date DATE;
1329 l_quote_recip_id NUMBER;
1330 l_party_id NUMBER;
1331 l_cust_account_id NUMBER;
1332 l_retrieval_number NUMBER := FND_API.G_MISS_NUM;
1333
1334 cursor c_get_quote_status is
1335 select quote_status_id
1336 from aso_quote_statuses_vl
1337 where status_code = 'INACTIVE';
1338
1339 cursor c_get_recip_id(c_qte_header_id number) is
1340 select quote_sharee_id
1341 from ibe_sh_quote_access
1342 where quote_header_id = c_qte_header_id;
1343
1344 cursor c_get_party_id is
1345 select party_id, cust_account_id
1346 from aso_quote_headers_all
1347 where quote_header_id = p_quote_header_id;
1348
1349
1350 rec_get_quote_status c_get_quote_status%rowtype;
1351 rec_get_recip_id c_get_recip_id%rowtype;
1352 rec_get_party_id c_get_party_id%rowtype;
1353
1354 BEGIN
1355 -- IBE_Util.Enable_Debug;
1356 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1357 IBE_Util.Debug('START IBE_Quote_Save_pvt.Delete()');
1358 END IF;
1359 --DBMS_OUTPUT.PUT_line('Begin IBE_Quote_Save_pvt.Delete()');
1360 -- Standard Start of API savepoint
1361 SAVEPOINT DELETE_pvt;
1362 -- Standard call to check for call compatibility.
1363 IF NOT FND_API.Compatible_API_Call (l_api_version,
1364 P_Api_Version_Number,
1365 l_api_name,
1366 G_PKG_NAME )
1367 THEN
1368 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1369 END IF;
1370 -- Initialize message list if p_init_msg_list is set to TRUE.
1371 IF FND_API.To_Boolean( p_init_msg_list ) THEN
1372 FND_Msg_Pub.initialize;
1373 END IF;
1374 -- Initialize API return status to success
1375 x_return_status := FND_API.G_RET_STS_SUCCESS;
1376
1377 -- API body
1378
1379 -- get quote owner partyid
1380 for rec_get_party_id in c_get_party_id loop
1381 l_party_id := rec_get_party_id.party_id;
1382 l_cust_account_id := rec_get_party_id.cust_account_id;
1383 exit when c_get_party_id%notfound;
1384 end loop;
1385 -- if initiator is specified, and owner is not initiator,
1386 -- send a retieval number here and to the save call (if expunge=F)
1387 if ((p_initiator_party_id <> FND_API.G_MISS_NUM) and l_party_id <> p_initiator_party_id) then
1388 select quote_sharee_number into l_retrieval_number
1389 from ibe_sh_quote_access
1390 where party_id = p_initiator_party_id
1391 and quote_header_id = p_quote_header_id
1392 and cust_account_id = p_initiator_account_id;
1393 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1394 IBE_UTIL.DEBUG('Recipient is deleting the cart. Partyid: ' || p_initiator_party_id || ' RetrievalNumber: ' || l_retrieval_number);
1395 END IF;
1396 end if;
1397 -- User Authentication
1398 --DBMS_OUTPUT.PUT_line('validate_user_update start ');
1399 -- if there is no qte access tbl, then we're in the owner only flow
1400 IF (nvl(p_Quote_access_tbl.count,0) = 0) THEN
1401 IBE_Quote_Misc_pvt.Validate_User_Update
1402 (
1403 p_init_msg_list => FND_API.G_TRUE
1404 ,p_quote_header_id => p_quote_header_id
1405 ,p_validate_user => FND_API.G_TRUE
1406 ,p_quote_retrieval_number => l_retrieval_number
1407 ,p_privilege_type_code => 'A'
1408 ,p_save_type => OP_DELETE_CART
1409 ,p_last_update_date => p_last_update_date
1410 ,x_return_status => x_return_status
1411 ,x_msg_count => x_msg_count
1412 ,x_msg_data => x_msg_data
1413
1414 );
1415 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1416 RAISE FND_API.G_EXC_ERROR;
1417 END IF;
1418 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1419 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1420 END IF;
1421 --DBMS_OUTPUT.PUT_line('validate_user_update start end ');
1422 END IF;
1423
1424 -- get quote stutus
1425 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1426 IBE_UTIL.DEBUG('get quote stutus');
1427 END IF;
1428 l_quote_status := IBE_Quote_Misc_pvt.get_Quote_status(p_quote_header_id);
1429
1430 IF (l_quote_status = 'NOT_EXIST') THEN
1431 --DBMS_OUTPUT.PUT_line('Quote not exists ');
1432 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1433 IBE_UTIL.DEBUG('Quote not exists ');
1434 END IF;
1435 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
1436 FND_Message.Set_Name('IBE', 'IBE_SC_NO_QUOTE_EXIST');
1437 FND_Msg_Pub.Add;
1438 END IF;
1439 RAISE FND_API.G_EXC_ERROR;
1440 ELSIF (l_quote_status = 'ORDERED') THEN
1441 --DBMS_OUTPUT.PUT_line('Quote ordered ');
1442 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1443 IBE_UTIL.DEBUG('Quote ordered ');
1444 END IF;
1445 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
1446 FND_Message.Set_Name('IBE', 'IBE_SC_QUOTE_IS_ORDERED');
1447 FND_Msg_Pub.Add;
1448 END IF;
1449 RAISE FND_API.G_EXC_ERROR;
1450 END IF;
1451 --Removing this validation because this is aleady being done in validate_user_update
1452 /* -- validate last_update_date
1453 IF (p_last_update_date is not null
1454 and p_last_update_date <> FND_API.G_MISS_DATE) THEN
1455 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1456 IBE_UTIL.DEBUG('validate last_update_date ');
1457 END IF;
1458 IBE_Quote_Misc_pvt.validateQuoteLastUpdateDate
1459 ( p_api_version_number => p_api_version_number
1460 ,p_quote_header_id => p_quote_header_id
1461 ,p_last_update_date => p_last_update_date
1462 ,X_Return_Status => x_return_status
1463 ,X_Msg_Count => x_msg_count
1464 ,X_Msg_Data => x_msg_data
1465 );
1466 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1467 RAISE FND_API.G_EXC_ERROR;
1468 END IF;
1469 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1470 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1471 END IF;
1472 END IF;*/
1473
1474 -- makulkar: Moving the deactivate quote code before expunge flag check. Bug 3715127.
1475
1476 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1477 IBE_UTIL.DEBUG('Quote_save_pvt.Delete: Ready to call deactivate_quote');
1478 END IF;
1479 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1480 IBE_UTIL.DEBUG('Ready to call IBE_QUOTE_SAVESHARE_V2_PVT.Stop_sharing');
1481 END IF;
1482 --DBMS_OUTPUT.PUT_line('Ready to call IBE_QUOTE_SAVESHARE_V2_PVT.Stop_sharing');
1483 -- Stop sharing this quote if this is a shared quote.
1484 IBE_QUOTE_SAVESHARE_V2_PVT.stop_sharing (
1485 p_quote_header_id => p_quote_header_id ,
1486 p_delete_context => 'IBE_SC_CART_DELETED',
1487 P_minisite_id => p_minisite_id ,
1488 p_notes => p_notes ,
1489 p_quote_access_tbl => p_quote_access_tbl ,
1490 p_api_version => p_api_version_number ,
1491 p_init_msg_list => fnd_api.g_false ,
1492 p_commit => fnd_api.g_false ,
1493 x_return_status => x_return_status ,
1494 x_msg_count => x_msg_count ,
1495 x_msg_data => x_msg_data );
1496
1497
1498 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1499 RAISE FND_API.G_EXC_ERROR;
1500 END IF;
1501
1502 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1503 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1504 END IF;
1505
1506 --DBMS_OUTPUT.PUT_line('Done calling IBE_QUOTE_SAVESHARE_V2_PVT.Stop_sharing ');
1507 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1508 IBE_UTIL.DEBUG('Done calling IBE_QUOTE_SAVESHARE_V2_PVT.Stop_sharing');
1509 END IF;
1510
1511
1512 --MANNAMRA:Changes for save/share project(09/12/02)
1513 /*If p_expunge_flag is true then call aso_quote_pub.delete, else
1514 invalidate the quote setting the quote status to 'INVALID' status
1515 and expiring the quote*/
1516
1517 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1518 IBE_UTIL.DEBUG('expunge flag is: '||p_expunge_flag);
1519 END IF;
1520 --dbms_output.put_line('expunge flag is: '||p_expunge_flag);
1521 IF(p_expunge_flag = FND_API.G_TRUE ) THEN
1522 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1523 IBE_Util.Debug('Expunge flag is true') ;
1524 END IF;
1525 --DBMS_OUTPUT.PUT_line('Expunge flag is true');
1526 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1527 IBE_Util.Debug('ASO_Quote_Pub.Delete_Quote() starts');
1528 END IF;
1529 --DBMS_OUTPUT.PUT_line('ASO_Quote_Pub.Delete_Quote() starts');
1530
1531
1532 ASO_Quote_Pub.Delete_quote(
1533 P_Api_Version_Number => P_Api_Version_Number
1534 ,P_Init_Msg_List => FND_API.G_FALSE
1535 ,P_Commit => FND_API.G_FALSE
1536 ,P_qte_header_id => P_Quote_Header_Id
1537 ,x_Return_Status => x_return_status
1538 ,x_Msg_Count => x_msg_count
1539 ,x_Msg_Data => x_msg_data );
1540
1541
1542
1543 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1544 IBE_Util.Debug('ASO_Quote_Pub.Delete_Quote() finishes');
1545 END IF;
1546 --DBMS_OUTPUT.PUT_line('ASO_Quote_Pub.Delete_Quote() finishes');
1547 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1548 RAISE FND_API.G_EXC_ERROR;
1549 END IF;
1550
1551 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1552 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1553 END IF;
1554
1555 ELSE
1556 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1557 IBE_Util.Debug('Expunge flag is false');
1558 END IF;
1559 --DBMS_OUTPUT.PUT_line(' Expunge flag is false');
1560 FOR rec_get_quote_status in c_get_quote_status LOOP
1561 l_quote_Status_id := rec_get_quote_status.quote_status_id;
1562 exit when c_get_quote_status%notfound;
1563 END LOOP;
1564 l_quote_header_rec.quote_header_id := p_quote_header_id;
1565 l_quote_header_rec.last_update_date := p_last_update_date;
1566 --Forcing the quote to inactivate
1567 l_quote_header_rec.quote_status_id := l_quote_Status_id;
1568 --Forcing the quote to expire
1569 l_quote_header_rec.quote_expiration_date := trunc(sysdate);
1570 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1571 IBE_Util.Debug('Values of quote header rec before calling Save API');
1572 END IF;
1573
1574 --DBMS_OUTPUT.PUT_line('l_quote_header_rec.quote_header_id :'||l_quote_header_rec.quote_header_id);
1575 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1576 IBE_UTIL.DEBUG('l_quote_header_rec.quote_header_id :'||l_quote_header_rec.quote_header_id);
1577 IBE_UTIL.DEBUG('l_quote_header_rec.quote_status_id :'||l_quote_header_rec.quote_status_id);
1578 IBE_UTIL.DEBUG('l_quote_header_rec.last_update_date :'||l_quote_header_rec.last_update_date);
1579 END IF;
1580 --DBMS_OUTPUT.PUT_line('calling save ');
1581 ibe_quote_save_pvt.save(
1582 p_api_version_number => p_api_version_number ,
1583 p_init_msg_list => fnd_api.g_false ,
1584 p_commit => fnd_api.g_false ,
1585 p_sharee_Number => l_retrieval_number ,
1586 p_save_type => OP_DELETE_CART ,
1587 p_qte_header_rec => l_Quote_header_rec ,
1588 x_quote_header_id => l_quote_header_id ,
1589 x_last_update_date => l_last_update_date ,
1590
1591 x_return_status => x_return_status ,
1592 x_msg_count => x_msg_count ,
1593 x_msg_data => x_msg_data);
1594
1595 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1596 RAISE FND_API.G_EXC_ERROR;
1597 END IF;
1598
1599 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1600 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1601 END IF;
1602 --DBMS_OUTPUT.PUT_line('Done calling save ');
1603 END IF; --expunge_flag check
1604
1605 -- End of API body.
1606
1607 -- Standard check of p_commit.
1608 IF FND_API.To_Boolean( p_commit ) THEN
1609 COMMIT WORK;
1610 END IF;
1611
1612 -- Standard call to get message count and if count is 1, get message info.
1613 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1614 p_count => x_msg_count ,
1615 p_data => x_msg_data);
1616 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1617 IBE_Util.Debug('End IBE_Quote_Save_pvt.Delete()');
1618 END IF;
1619 -- IBE_Util.Disable_Debug;
1620 EXCEPTION
1621 WHEN FND_API.G_EXC_ERROR THEN
1622 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1623 IBE_Util.Debug('Expected error: End IBE_Quote_Save_pvt.Delete()');
1624 END IF;
1625
1626 ROLLBACK TO DELETE_pvt;
1627 x_return_status := FND_API.G_RET_STS_ERROR;
1628 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1629 p_count => x_msg_count ,
1630 p_data => x_msg_data);
1631 --IBE_Util.Disable_Debug;
1632 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1633 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1634 IBE_Util.Debug('Unexpected error: End IBE_Quote_Save_pvt.Delete()');
1635 END IF;
1636 ROLLBACK TO DELETE_pvt;
1637 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1638 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1639 p_count => x_msg_count ,
1640 p_data => x_msg_data);
1641 -- IBE_Util.Disable_Debug;
1642 WHEN OTHERS THEN
1643 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1644 IBE_Util.Debug('Unknown error: End IBE_Quote_Save_pvt.Delete()');
1645 END IF;
1646 ROLLBACK TO DELETE_pvt;
1647 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1648 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
1649 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
1650 l_api_name);
1651 END IF;
1652 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1653 p_count => x_msg_count ,
1654 p_data => x_msg_data);
1655 --IBE_Util.Disable_Debug;
1656 END DELETE;
1657
1658
1659 PROCEDURE DeleteAllLines(
1660 p_api_version_number IN NUMBER := 1 ,
1661 p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE ,
1662 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
1663 x_return_status OUT NOCOPY VARCHAR2 ,
1664 x_msg_count OUT NOCOPY NUMBER ,
1665 x_msg_data OUT NOCOPY VARCHAR2 ,
1666 p_quote_header_id IN NUMBER ,
1667 p_last_update_date IN DATE := FND_API.G_MISS_DATE,
1668 p_sharee_number IN NUMBER := FND_API.G_MISS_NUM ,
1669 x_quote_header_id OUT NOCOPY NUMBER ,
1670 x_last_update_date OUT NOCOPY DATE
1671 )
1672 is
1673 l_api_name CONSTANT VARCHAR2(30) := 'DELETEALLLINES';
1674 l_api_version CONSTANT NUMBER := 1.0;
1675
1676 l_quote_line_id number;
1677 l_control_rec ASO_Quote_Pub.Control_Rec_Type;
1678 l_qte_header_rec ASO_Quote_Pub.QTE_HEADER_REC_TYPE
1679 := ASO_Quote_Pub.g_miss_qte_header_rec;
1680 l_qte_line_rec ASO_Quote_Pub.QTE_LINE_REC_TYPE
1681 := ASO_Quote_Pub.g_miss_qte_line_rec;
1682 l_qte_line_tbl ASO_Quote_Pub.QTE_LINE_TBL_TYPE
1683 := ASO_Quote_Pub.g_miss_qte_line_tbl;
1684
1685
1686 cursor c_getlineids(p_quote_header_id number) is
1687 select quote_line_id
1688 from aso_quote_lines
1689 where quote_header_id = p_quote_header_id;
1690 BEGIN
1691 -- Standard Start of API savepoint
1692 SAVEPOINT DELETEALLLINES_pvt;
1693 -- Standard call to check for call compatibility.
1694 IF NOT FND_API.Compatible_API_Call (l_api_version,
1695 P_Api_Version_Number,
1696 l_api_name,
1697 G_PKG_NAME )
1698 THEN
1699 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1700 END IF;
1701 -- Initialize message list if p_init_msg_list is set to TRUE.
1702 IF FND_API.To_Boolean( p_init_msg_list ) THEN
1703 FND_Msg_Pub.initialize;
1704 END IF;
1705 -- Initialize API return status to success
1706 x_return_status := FND_API.G_RET_STS_SUCCESS;
1707
1708 -- API body
1709
1710 -- User Authentication
1711 IBE_Quote_Misc_pvt.Validate_User_Update
1712 ( p_init_msg_list => p_init_msg_list
1713 ,p_quote_header_id => p_quote_header_id
1714 ,p_quote_retrieval_number => p_sharee_number
1715 ,p_validate_user => FND_API.G_TRUE
1716 ,x_return_status => x_return_status
1717 ,x_msg_count => x_msg_count
1718 ,x_msg_data => x_msg_data
1719 );
1720 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1721 RAISE FND_API.G_EXC_ERROR;
1722 END IF;
1723 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1724 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1725 END IF;
1726
1727 -- 8/24/2002
1728
1729 l_qte_header_rec.quote_header_id := p_quote_header_id;
1730
1731 open c_getlineids(p_quote_header_id);
1732 loop
1733 fetch c_getlineids into l_quote_line_id;
1734 exit when c_getlineids%notfound;
1735 l_qte_line_rec.quote_header_id := l_qte_header_rec.quote_header_id;
1736 l_qte_line_rec.quote_line_id := l_quote_line_id;
1737 l_qte_line_rec.operation_code := 'DELETE';
1738 l_qte_line_tbl(l_qte_line_tbl.count+1) := l_qte_line_rec;
1739 end loop;
1740 close c_getlineids;
1741
1742 l_control_rec.pricing_request_type := 'ASO';
1743 l_control_rec.header_pricing_event := FND_Profile.Value('IBE_INCART_PRICING_EVENT');
1744 l_control_rec.line_pricing_event := FND_API.G_MISS_CHAR;
1745 l_control_rec.calculate_freight_charge_flag := 'Y';
1746 l_control_rec.calculate_tax_flag := 'Y';
1747
1748 ibe_quote_save_pvt.SAVE
1749 ( p_api_version_number => p_api_version_number
1750 ,p_init_msg_list => FND_API.G_FALSE
1751 ,p_commit => FND_API.G_FALSE
1752 ,p_sharee_Number => p_sharee_Number
1753 ,p_qte_header_rec => l_qte_header_rec
1754 ,p_qte_line_tbl => l_qte_line_tbl
1755 ,p_control_rec => l_control_rec
1756 ,x_quote_header_id => x_quote_header_id
1757 ,x_last_update_date => x_last_update_date
1758 ,x_return_status => x_return_status
1759 ,x_msg_count => x_msg_count
1760 ,x_msg_data => x_msg_data
1761 );
1762 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1763 RAISE FND_API.G_EXC_ERROR;
1764 END IF;
1765 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1766 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1767 END IF;
1768
1769 -- End of API body.
1770 -- Standard check of p_commit.
1771 IF FND_API.To_Boolean( p_commit ) THEN
1772 COMMIT WORK;
1773 END IF;
1774
1775 -- Standard call to get message count and if count is 1, get message info.
1776
1777 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1778 p_count => x_msg_count ,
1779 p_data => x_msg_data);
1780
1781 EXCEPTION
1782 WHEN FND_API.G_EXC_ERROR THEN
1783 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1784 IBE_Util.Debug('Expected error: IBE_Quote_Save_pvt.DeleteAllLines()');
1785 END IF;
1786 ROLLBACK TO DELETEALLLINES_pvt;
1787 x_return_status := FND_API.G_RET_STS_ERROR;
1788 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1789 p_count => x_msg_count ,
1790 p_data => x_msg_data);
1791
1792 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1793 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1794 IBE_Util.Debug('Unexpected error:IBE_Quote_Save_pvt.DeleteAllLines()');
1795 END IF;
1796
1797 ROLLBACK TO DELETEALLLINES_pvt;
1798 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1799 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1800 p_count => x_msg_count,
1801 p_data => x_msg_data);
1802 WHEN OTHERS THEN
1803 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1804 IBE_Util.Debug('Unknown error: IBE_Quote_Save_pvt.DeleteAllLines()');
1805 END IF;
1806
1807 ROLLBACK TO DELETEALLLINES_pvt;
1808 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1809
1810 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
1811 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
1812 l_api_name);
1813 END IF;
1814 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1815 p_count => x_msg_count ,
1816 p_data => x_msg_data);
1817 END DeleteAllLines;
1818
1819
1820 PROCEDURE Set_Last_Update_Date(p_qte_header_id IN NUMBER,
1821 px_last_update_date OUT NOCOPY DATE)
1822 IS
1823 BEGIN
1824 IF p_qte_header_id <> FND_API.G_MISS_NUM THEN
1825 px_last_update_date := IBE_Quote_Misc_pvt.getQuoteLastUpdateDate(p_qte_header_id);
1826 END IF;
1827 END Set_Last_Update_Date;
1828
1829 -- formerly AddItemsToCart; the original addItemsToCart
1830 -- this is the one that handles adding of std, services, cartlevel services
1831 PROCEDURE AddItemsToCart_orig(
1832 P_Api_Version_Number IN NUMBER
1833 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
1834 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
1835 ,p_combineSameItem IN VARCHAR2 := FND_API.G_MISS_CHAR
1836 ,p_sharee_Number IN Number := FND_API.G_MISS_NUM
1837 ,p_sharee_party_id IN Number := FND_API.G_MISS_NUM
1838 ,p_sharee_cust_account_id IN Number := FND_API.G_MISS_NUM
1839 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
1840 ,p_changeowner IN VARCHAR2 := FND_API.G_FALSE
1841 ,p_Control_Rec IN ASO_Quote_Pub.Control_Rec_Type
1842 := ASO_Quote_Pub.G_Miss_Control_Rec
1843 ,p_ql_line_codes IN jtf_number_table := NULL
1844 ,p_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
1845 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
1846
1847 ,p_hd_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
1848 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
1849 ,p_hd_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
1850 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
1851 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
1852 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
1853 ,p_hd_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
1854 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
1855 ,p_hd_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
1856 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
1857 ,p_Qte_Line_Tbl IN ASO_Quote_Pub.Qte_Line_Tbl_Type
1858 := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL
1859 ,p_Qte_Line_Dtl_Tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
1860 := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL
1861 ,p_Line_Attr_Ext_Tbl IN ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
1862 := ASO_Quote_Pub.G_MISS_Line_Attribs_Ext_TBL
1863 ,p_line_rltship_tbl IN ASO_Quote_Pub.Line_Rltship_Tbl_Type
1864 := ASO_Quote_Pub.G_MISS_Line_Rltship_Tbl
1865 ,p_Price_Adjustment_Tbl IN ASO_Quote_Pub.Price_Adj_Tbl_Type
1866 := ASO_Quote_Pub.G_Miss_Price_Adj_Tbl
1867 ,p_Price_Adj_Attr_Tbl IN ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
1868 := ASO_Quote_Pub.G_Miss_PRICE_ADJ_ATTR_Tbl
1869 ,p_Price_Adj_Rltship_Tbl IN ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
1870 := ASO_Quote_Pub.G_Miss_Price_Adj_Rltship_Tbl
1871 ,p_Ln_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
1872 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
1873 ,p_Ln_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
1874 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
1875 ,p_Ln_Shipment_Tbl IN ASO_Quote_Pub.Shipment_Tbl_Type
1876 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
1877 ,p_Ln_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
1878 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
1879 ,p_Ln_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
1880 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
1881 ,P_save_flag IN NUMBER := SAVE_ADDTOCART
1882
1883 ,x_quote_header_id OUT NOCOPY varchar2
1884 ,x_Qte_Line_Tbl OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
1885 ,x_last_update_date OUT NOCOPY DATE
1886 ,X_Return_Status OUT NOCOPY VARCHAR2
1887 ,X_Msg_Count OUT NOCOPY NUMBER
1888 ,X_Msg_Data OUT NOCOPY VARCHAR2
1889 )
1890 is
1891
1892 l_api_name CONSTANT VARCHAR2(30) := 'AddItemsToCart';
1893 l_api_version CONSTANT NUMBER := 1.0;
1894
1895 lx_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type := p_Qte_Header_Rec;
1896 lx_Hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type := p_Hd_Price_Attributes_Tbl;
1897 lx_Hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type := p_Hd_Payment_Tbl;
1898
1899 lx_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type := p_Hd_Shipment_Tbl;
1900 lx_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type;
1901 lx_Hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type := p_Hd_Freight_Charge_Tbl;
1902 lx_Hd_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE := p_Hd_Tax_Detail_Tbl;
1903
1904 l_Qte_Line_Tbl ASO_Quote_Pub.Qte_Line_Tbl_Type;
1905 l_Qte_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
1906 lx_Qte_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
1907 lx_Line_Attr_Ext_Tbl ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type;
1908 lx_Line_rltship_tbl ASO_Quote_Pub.Line_Rltship_Tbl_Type;
1909
1910 lx_Ln_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
1911 lx_Ln_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
1912 lx_Ln_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
1913 lx_Ln_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
1914 lx_Ln_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
1915
1916 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type := p_Price_Adjustment_Tbl;
1917 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type := p_Price_Adj_Attr_Tbl;
1918 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type:= p_Price_Adj_Rltship_Tbl;
1919
1920 l_ibeItemTypeSize number;
1921 l_itemIdListSRVSize number;
1922 l_quoteLineSize number;
1923 l_quoteLineDetSize number;
1924
1925 l_svcIndex number;
1926 l_chkPrevRefLine number := NULL;
1927 l_itemIdListSRV jtf_number_table := NULL;
1928 l_uomCodeListSRV JTF_VARCHAR2_TABLE_100 := NULL;
1929 l_periodListSRV JTF_VARCHAR2_TABLE_100 := NULL;
1930 l_durationListSRV JTF_VARCHAR2_TABLE_100 := NULL;
1931
1932 l_isCartEmpty varchar2(1) := 'N';
1933 l_isCartSupp varchar2(1) := 'N';
1934 l_line_level_services varchar2(1) := 'N';
1935 l_numLines number := 0;
1936 l_hasSVA varchar2(1) := 'N';
1937 l_hasQueriedItems varchar2(1) := 'N';
1938
1939 l_suppLevelProfileValue varchar2(30);
1940 l_profValueSize number;
1941 l_commIndex number;
1942 l_startIndex number;
1943 l_quote_line_id number;
1944 l_checkActiveCartId number;
1945 l_attach_contract VARCHAR2(1);
1946 l_contract_template_id NUMBER;
1947 l_trans_Contract_templ_id NUMBER;
1948
1949 --temp vars for NOCOPY OUT params.
1950 lx_Qte_Header_Rec_tmp ASO_Quote_Pub.Qte_Header_Rec_Type := p_Qte_Header_Rec;
1951 lx_Hd_Price_Attributes_Tbl_tmp ASO_Quote_Pub.Price_Attributes_Tbl_Type := p_Hd_Price_Attributes_Tbl;
1952 lx_Hd_Payment_Tbl_tmp ASO_Quote_Pub.Payment_Tbl_Type := p_Hd_Payment_Tbl;
1953 lx_Hd_Shipment_Tbl_tmp ASO_Quote_Pub.Shipment_Tbl_Type := p_Hd_Shipment_Tbl;
1954 lx_Hd_Freight_Charge_Tbl_tmp ASO_Quote_Pub.Freight_Charge_Tbl_Type := p_Hd_Freight_Charge_Tbl;
1955 lx_Hd_Tax_Detail_Tbl_tmp ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE := p_Hd_Tax_Detail_Tbl;
1956 lx_Price_Adjustment_Tbl_tmp ASO_Quote_Pub.Price_Adj_Tbl_Type := p_Price_Adjustment_Tbl;
1957 lx_Price_Adj_Attr_Tbl_tmp ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type := p_Price_Adj_Attr_Tbl;
1958 lx_Price_Adj_Rltship_Tbl_tmp ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type:= p_Price_Adj_Rltship_Tbl;
1959
1960 l_suppLevelLookupName VARCHAR2(30);
1961
1962 cursor c_getServiceInvId (l_quote_header_id number)
1963 is
1964 select aqld.service_ref_line_id refLine, aql2.inventory_item_id invId
1965 from ASO_QUOTE_LINES aql,
1966 ASO_QUOTE_LINES aql2,
1967 ASO_QUOTE_LINE_DETAILS aqld
1968 where aql.item_type_code = 'SVA' and
1969 aql.quote_line_id = aqld.service_ref_line_id and
1970 aql.quote_header_id = l_quote_header_id and
1971 aqld.quote_line_id = aql2.quote_line_id
1972 order by aql2.QUOTE_LINE_ID;
1973
1974 cursor c_getItemInfo (l_inventory_item_id number, l_organization_id number)
1975 is
1976 select PRIMARY_UOM_CODE uomCode, SERVICE_DURATION_PERIOD_CODE period, SERVICE_DURATION duration
1977 from MTL_SYSTEM_ITEMS_VL
1978 where inventory_item_id = l_inventory_item_id and
1979 organization_id = l_organization_id;
1980
1981 Cursor c_find_service(c_service_ref_line_id number) is
1982 Select ql.quote_line_id
1983 From aso_quote_lines ql, aso_quote_line_details qld
1984 where ql.quote_line_id = qld.quote_line_id
1985 And qld.service_ref_line_id = c_service_ref_line_id;
1986
1987 rec_service c_getServiceInvId%rowtype;
1988 rec_itemInfo c_getItemInfo%rowtype;
1989 rec_find_service c_find_service%rowtype;
1990
1991 l_combinesameitem VARCHAR2(2) := FND_API.G_MISS_CHAR;
1992
1993 --maithili added for R12
1994 Cursor c_get_Marketing_source(p_quote_header_id NUMBER) is
1995 select marketing_source_code_id
1996 from aso_quote_headers_all
1997 where quote_header_id = p_quote_header_id;
1998
1999 l_marketing_source_code_id NUMBER;
2000
2001 l_Hd_Price_Attributes_Tbl_temp ASO_Quote_Pub.Price_Attributes_Tbl_Type;
2002 l_Hd_Price_Attributes_Tbl_DB ASO_Quote_Pub.Price_Attributes_Tbl_Type;
2003 l_pricingIndex NUMBER := 1;
2004
2005 Cursor c_get_hdr_pricing_attributes(p_quote_header_id NUMBER) is
2006 select pricing_attribute1
2007 from aso_price_attributes
2008 where quote_header_id = p_quote_header_id
2009 and quote_line_id is null;
2010
2011 rec_pricing_attr_info c_get_hdr_pricing_attributes%rowtype;
2012
2013 Cursor c_get_support_level(p_support_lookup_type VARCHAR2, p_support_lookup_code VARCHAR2) is
2014 select 1 from fnd_lookups
2015 where lookup_type = p_support_lookup_type
2016 and lookup_code = p_support_lookup_code;
2017
2018 support_level_check number;
2019
2020
2021 BEGIN
2022
2023 -- Standard Start of API savepoint
2024 SAVEPOINT AddItemsToCartorig_pvt;
2025
2026 -- Standard call to check for call compatibility.
2027 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
2028 P_Api_Version_Number,
2029 L_API_NAME ,
2030 G_PKG_NAME )
2031 THEN
2032 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2033 END IF;
2034
2035 -- Initialize message list if p_init_msg_list is set to TRUE.
2036 IF FND_API.To_Boolean(p_init_msg_list) THEN
2037 FND_Msg_Pub.initialize;
2038 END IF;
2039
2040 -- Initialize API return status to success
2041 x_return_status := FND_API.G_RET_STS_SUCCESS;
2042
2043 -- API body
2044
2045 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2046 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.AddItemsToCart_orig()');
2047 END IF;
2048
2049 lx_Hd_Payment_Tbl := p_Hd_Payment_Tbl;
2050 lx_Hd_Shipment_Tbl := p_Hd_Shipment_Tbl;
2051 lx_Hd_Tax_Detail_Tbl := p_Hd_Tax_Detail_Tbl;
2052 lx_Qte_Header_Rec := p_Qte_Header_Rec;
2053
2054 -- IBE_Util.Enable_Debug;
2055
2056 l_Qte_Line_Tbl := p_Qte_Line_Tbl;
2057 l_Qte_Line_Dtl_Tbl := p_Qte_Line_Dtl_Tbl;
2058
2059 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2060 IBE_Util.Debug('Save_flag in AddItemsToCart_orig is: '||p_save_flag);
2061 END IF;
2062
2063 -- Check for cart level support
2064 if (( FND_Profile.Value('IBE_USE_SUPPORT_CART_LEVEL') <> 'N') AND
2065 ((FND_Profile.Value('IBE_USE_SUPPORT') = 'N') OR (FND_Profile.Value('IBE_USE_SUPPORT') is null ))) then
2066 l_isCartSupp := 'Y';
2067 else
2068 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2069 IBE_Util.Debug('Cart level support turned off ');
2070 END IF;
2071 end if;
2072 -- Check for line level support
2073 IF ((FND_Profile.Value('IBE_USE_SUPPORT') <> 'N') and
2074 (FND_Profile.Value('IBE_USE_SUPPORT') is not null)) THEN
2075
2076 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2077 IBE_Util.Debug('Line level support profile turned on');
2078 END IF;
2079 l_line_level_services := 'Y';
2080 ELSE
2081 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2082 IBE_Util.Debug('Line level support profile turned off');
2083 END IF;
2084 END IF;
2085
2086 --DBMS_OUTPUT.PUT_line('l_isCartSupp='||l_isCartSupp);
2087 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2088 IBE_Util.Debug('l_isCartSupp='||l_isCartSupp);
2089 END IF;
2090
2091 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2092 IBE_Util.Debug('l_line_level_services = '||l_line_level_services);
2093 END IF;
2094
2095 IF (p_Qte_Header_Rec.quote_header_id is null) THEN
2096 l_isCartEmpty := 'Y';
2097 END IF;
2098 --DBMS_OUTPUT.PUT_line('l_isCartEmpty='||l_isCartEmpty);
2099 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2100 IBE_Util.Debug('l_isCartEmpty='||l_isCartEmpty);
2101 END IF;
2102
2103 --Cart level support logic
2104 IF (l_isCartSupp = 'Y') THEN
2105
2106 IF ((p_Qte_Header_Rec.quote_header_id is not null)
2107 and (p_Qte_Header_Rec.quote_header_id <> FND_API.G_MISS_NUM) ) THEN
2108 --Check the number of quote lines in the quote
2109 SELECT COUNT(*) INTO l_numLines
2110 FROM aso_quote_lines
2111 WHERE quote_header_id = p_Qte_Header_Rec.quote_header_id;
2112 END IF;
2113
2114 --DBMS_OUTPUT.PUT_line('l_numLines='||l_numLines);
2115 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2116 IBE_Util.Debug('l_numLines='||l_numLines);
2117 END IF;
2118
2119 IF ((l_isCartEmpty = 'Y') or (l_numLines = 0)) THEN
2120 l_isCartEmpty := 'Y';
2121 END IF;
2122
2123 --DBMS_OUTPUT.PUT_line('l_isCartEmpty='||l_isCartEmpty);
2124 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2125 IBE_Util.Debug('l_isCartEmpty='||l_isCartEmpty);
2126 END IF;
2127
2128 IF ((p_Qte_Header_Rec.quote_header_id is not null)
2129 and (p_Qte_Header_Rec.quote_header_id <> FND_API.G_MISS_NUM) ) THEN
2130 --Get the number of serviceable items in the quote
2131 SELECT COUNT(*) INTO l_numLines
2132 FROM aso_quote_lines
2133 WHERE quote_header_id = p_Qte_Header_Rec.quote_header_id and
2134 item_type_code = 'SVA';
2135 END IF;
2136
2137 IF (l_numLines > 0) THEN
2138 --Quote has serviceable items
2139 l_hasSVA := 'Y';
2140 END IF;
2141 --DBMS_OUTPUT.PUT_line('l_hasSVA='||l_hasSVA);
2142 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2143 IBE_Util.Debug('l_hasSVA='||l_hasSVA);
2144 END IF;
2145
2146 -- added 8/4/03: if merge case, we might not want to pass SRV info down
2147 IF (p_combinesameitem = FND_API.G_MISS_CHAR) THEN
2148 l_combinesameitem := FND_Profile.Value('IBE_SC_MERGE_SHOPCART_LINES');
2149 Else
2150 l_combinesameitem := p_combinesameitem;
2151 END IF;
2152
2153 IF ((p_ql_line_codes is not null) and (l_isCartSupp = 'Y') ) THEN -- for backward compatibility w/ addModelToCart
2154
2155 l_ibeItemTypeSize := p_ql_line_codes.count;
2156 l_quoteLineSize := l_Qte_Line_Tbl.count;
2157 l_quoteLineDetSize := p_Qte_Line_Dtl_Tbl.count;
2158
2159 FOR i in 1..l_ibeItemTypeSize LOOP
2160
2161 -- added 8/4/03: if merge case, we might not want to pass SRV info down
2162 l_numLines := 0;
2163 IF ((p_Qte_Header_Rec.quote_header_id is not null)
2164 and (p_Qte_Header_Rec.quote_header_id <> FND_API.G_MISS_NUM) ) THEN
2165 SELECT COUNT(inventory_item_id) INTO l_numLines
2166 FROM aso_quote_lines
2167 WHERE quote_header_id = p_Qte_Header_Rec.quote_header_id and
2168 inventory_item_id = l_Qte_Line_Tbl(i).inventory_item_id;
2169 END IF;
2170
2171 IF ((p_ql_line_codes(i) = SERVICEABLE_LINE_CODE) and
2172 ((l_combinesameitem is null) or (l_combinesameitem = 'N') or (l_numLines = 0)) ) THEN -- SVA
2173
2174 --DBMS_OUTPUT.PUT_line('Service! p_ql_line_codes(i)='||SERVICEABLE_LINE_CODE);
2175 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2176 IBE_Util.Debug('Service! p_ql_line_codes(i)='||SERVICEABLE_LINE_CODE);
2177 END IF;
2178
2179 -- if we have not gotten a list of the support services and cart is not empty
2180 IF ((l_itemIdListSRV is null)
2181 and (l_isCartEmpty = 'N') ) THEN
2182 --DBMS_OUTPUT.PUT_line('l_itemIdListSRV is null');
2183 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2184 IBE_Util.Debug('l_itemIdListSRV is null');
2185 END IF;
2186
2187 l_svcIndex := 1;
2188
2189 FOR rec_service in c_getServiceInvId( p_Qte_Header_Rec.quote_header_id) LOOP
2190
2191 IF(l_itemIdListSRV is NULL ) THEN
2192 l_itemIdListSRV := JTF_NUMBER_TABLE();
2193 END IF;
2194 IF (l_chkPrevRefLine is null) THEN -- if we're just starting
2195 --DBMS_OUTPUT.PUT_line('just starting: l_svcIndex ='||l_svcIndex);
2196 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2197 IBE_Util.Debug('just starting: l_svcIndex ='||l_svcIndex);
2198 END IF;
2199
2200 l_chkPrevRefLine := rec_service.refLine;
2201 l_itemIdListSRV.extend();
2202 l_itemIdListSRV(l_svcIndex) := rec_service.invId;
2203 l_svcIndex := l_svcIndex + 1;
2204 ELSE -- else we're not
2205 IF (l_chkPrevRefLine = rec_service.refLine) then -- if we have the same ref line as the previous
2206 --DBMS_OUTPUT.PUT_line('same ref line: l_svcIndex ='||l_svcIndex);
2207 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2208 IBE_Util.Debug('same ref line: l_svcIndex ='||l_svcIndex);
2209 END IF;
2210 l_itemIdListSRV.extend();
2211 l_itemIdListSRV(l_svcIndex) := rec_service.invId;
2212 l_svcIndex := l_svcIndex + 1;
2213 ELSE -- else we're done
2214 --DBMS_OUTPUT.PUT_line(' done: l_svcIndex ='||l_svcIndex);
2215 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2216 IBE_Util.Debug(' done: l_svcIndex ='||l_svcIndex);
2217 END IF;
2218 EXIT;
2219 END IF; --If we have the same service ref line as the previous one
2220 END IF; --If (l_chkPrevRefLine is null)
2221 EXIT WHEN c_getServiceInvId%notfound;
2222 END LOOP;
2223 END IF; --if l_itemIdListSRV is null and cart is not empty
2224
2225 -- if add 1st item to cart
2226 l_suppLevelLookupName := rtrim(ltrim(FND_Profile.Value('IBE_CART_LEVEL_SUPPORT_LOOKUP')));
2227 l_suppLevelProfileValue := rtrim(ltrim(FND_Profile.Value('IBE_PREFERED_SUPPORT_LEVEL')));
2228
2229
2230 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2231 IBE_Util.Debug('Support Level Lookup Name: ' || l_suppLevelLookupName);
2232 IBE_Util.Debug('Prefered Support Level : ' || l_suppLevelProfileValue);
2233 END IF;
2234
2235 OPEN c_get_support_level(l_suppLevelLookupName,l_suppLevelProfileValue);
2236 fetch c_get_support_level into support_level_check;
2237
2238 IF c_get_support_level%NOTFOUND THEN
2239 l_suppLevelProfileValue := null;
2240 END IF;
2241 CLOSE c_get_support_level;
2242
2243 --l_suppLevelProfileValue := '478,478';
2244 IF ((l_itemIdListSRV is null)
2245 and (l_suppLevelProfileValue is not null)
2246 and (l_suppLevelProfileValue <> 'NONE') and (l_hasSVA = 'N') ) THEN
2247 -- parse suppLevelProfileValue -- delimiter = ',' -> put in l_itemIdListSRV
2248 l_itemIdListSRV := JTF_NUMBER_TABLE();
2249 l_profValueSize := length(l_suppLevelProfileValue);
2250 l_startIndex := 1;
2251 --DBMS_OUTPUT.PUT_line(' start: l_profValueSize ='||l_profValueSize);
2252 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2253 IBE_Util.Debug(' start: l_profValueSize ='||l_profValueSize);
2254 END IF;
2255
2256 FOR firstItmIndx in 1..l_profValueSize LOOP
2257 l_commIndex := instr(l_suppLevelProfileValue, ',', 1, firstItmIndx);
2258 IF (l_commIndex = 0) THEN
2259 l_commIndex := l_profValueSize - l_startIndex + 1;
2260 ELSE
2261 l_commIndex := l_commIndex - l_startIndex;
2262 END IF;
2263 --DBMS_OUTPUT.PUT_line(' l_startIndex ='||l_startIndex);
2264 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2265 IBE_Util.Debug(' l_startIndex ='||l_startIndex);
2266 END IF;
2267 --DBMS_OUTPUT.PUT_line(' l_commIndex ='||l_commIndex);
2268 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2269 IBE_Util.Debug(' l_commIndex ='||l_commIndex);
2270 END IF;
2271
2272 l_itemIdListSRV.extend();
2273 --DBMS_OUTPUT.PUT_line(' substr(l_suppLevelProfileValue, l_startIndex, l_commIndex)='||substr(l_suppLevelProfileValue, l_startIndex, l_commIndex));
2274 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2275 IBE_Util.Debug(' substr(l_suppLevelProfileValue, l_startIndex, l_commIndex)='||substr(l_suppLevelProfileValue, l_startIndex, l_commIndex));
2276 END IF;
2277 l_itemIdListSRV(firstItmIndx) := to_number(substr(l_suppLevelProfileValue, l_startIndex, l_commIndex));
2278 l_startIndex := l_startIndex + l_commIndex + 1;
2279 --DBMS_OUTPUT.PUT_line(' l_itemIdListSRV(firstItmIndx)='||l_itemIdListSRV(firstItmIndx));
2280 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2281 IBE_Util.Debug(' l_itemIdListSRV(firstItmIndx)='||l_itemIdListSRV(firstItmIndx));
2282 END IF;
2283
2284 IF (l_startIndex > l_profValueSize) THEN
2285 EXIT;
2286 END IF;
2287
2288 END LOOP; --firstItmIndx in 1..l_profValueSize
2289 END IF; --If (IteIdListSRV is null)
2290
2291 IF (l_itemIdListSRV is null) THEN
2292 -- there are no SRV items found -- should exit
2293 exit;
2294 ELSE
2295 /*
2296 Once we have valid values for l_itemIdListSRV, build structures for services:
2297 ** continue from regular lines
2298 quote_line_tbl
2299 quote_line_details_tbl - pass in the correct line_index corresponding to the lines in quote_line_tbl
2300 */
2301
2302 -- for performance reasons we can keep track of values that have already been queried from mtl_system_items_vl table
2303 IF (l_uomCodeListSRV is null) THEN
2304 l_uomCodeListSRV := JTF_VARCHAR2_TABLE_100();
2305 l_periodListSRV := JTF_VARCHAR2_TABLE_100();
2306 l_durationListSRV := JTF_VARCHAR2_TABLE_100();
2307 ELSE
2308 l_hasQueriedItems := 'Y';
2309 END IF;
2310
2311 l_itemIdListSRVSize := l_itemIdListSRV.count;
2312 FOR j in 1..l_itemIdListSRVSize LOOP
2313
2314 -- for performance reasons we can keep track of values that have already been queried from mtl_system_items_vl table
2315 IF (l_hasQueriedItems = 'N') THEN
2316 OPEN c_getItemInfo (l_itemIdListSRV(j), l_Qte_Line_Tbl(i).organization_id);
2317 fetch c_getItemInfo into rec_itemInfo;
2318 close c_getItemInfo;
2319
2320 l_uomCodeListSRV.extend();
2321 l_uomCodeListSRV(j) := rec_itemInfo.uomCode;
2322 l_periodListSRV.extend();
2323 l_periodListSRV(j) := rec_itemInfo.period;
2324 l_durationListSRV.extend();
2325 l_durationListSRV(j):= rec_itemInfo.duration;
2326 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2327 IBE_Util.Debug('Quertying mtl_sytem_items_vl the first time');
2328 END IF;
2329 END IF; -- if we haven't queried mtl_system_items_vl table
2330
2331 l_Qte_Line_Tbl(l_quoteLineSize+j).quote_header_id := p_Qte_Header_Rec.quote_header_id;
2332 l_Qte_Line_Tbl(l_quoteLineSize+j).inventory_item_id := l_itemIdListSRV(j);
2333 l_Qte_Line_Tbl(l_quoteLineSize+j).organization_id := l_Qte_Line_Tbl(i).organization_id;
2334 l_Qte_Line_Tbl(l_quoteLineSize+j).quantity := l_Qte_Line_Tbl(i).quantity;
2335 l_Qte_Line_Tbl(l_quoteLineSize+j).uom_code := l_uomCodeListSRV(j); -- 'YR'
2336 l_Qte_Line_Tbl(l_quoteLineSize+j).operation_code := 'CREATE';
2337 l_Qte_Line_Tbl(l_quoteLineSize+j).start_date_active := sysdate;
2338 l_Qte_Line_Tbl(l_quoteLineSize+j).item_type_code := 'SRV';
2339
2340 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).qte_line_index := l_quoteLineSize+j;
2341 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).service_ref_type_code := 'QUOTE';
2342 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).service_ref_qte_line_index := i;
2343 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).operation_code := 'CREATE';
2344 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).service_period := l_periodListSRV(j); -- 'YR'
2345 l_Qte_Line_Dtl_Tbl(l_quoteLineDetSize+j).service_duration := l_durationListSRV(j); -- 3
2346 END LOOP;
2347 END IF; -- if there are service items
2348 END IF; -- SVA
2349
2350 l_quoteLineSize := l_Qte_Line_Tbl.count;
2351 l_quoteLineDetSize := l_Qte_Line_Dtl_Tbl.count;
2352 --DBMS_OUTPUT.PUT_line('i:'||i||' *inventory_item_id = '||l_Qte_Line_Tbl(i).inventory_item_id);
2353 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2354 IBE_Util.Debug('i:'||i||' *inventory_item_id = '||l_Qte_Line_Tbl(i).inventory_item_id);
2355 END IF;
2356 END LOOP; -- loop through p_ql_line_codes
2357 END IF; -- if p_ql_line_codes is not null
2358 ELSIF(l_line_level_services = 'Y') THEN
2359
2360 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2361 IBE_Util.Debug('Entering the logic for line level support');
2362 END IF;
2363
2364 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2365 IBE_Util.Debug('IBE_QUOTE_MISC_PVT.get_multi_svc_profile: '||IBE_QUOTE_MISC_PVT.get_multi_svc_profile);
2366 END IF;
2367
2368 --CHANGES FOR LINE LEVEL SERVICES
2369 IF(IBE_QUOTE_MISC_PVT.get_multi_svc_profile <> 'T') THEN
2370
2371 FOR i in 1..p_Qte_Line_Dtl_Tbl.count LOOP
2372 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2373 IBE_Util.Debug('p_Qte_Line_Dtl_Tbl(i).service_ref_type_code: '||p_Qte_Line_Dtl_Tbl(i).service_ref_type_code);
2374 IBE_Util.Debug('p_Qte_Line_Dtl_Tbl(i).operation_code: '||p_Qte_Line_Dtl_Tbl(i).operation_code);
2375 IBE_Util.Debug('p_Qte_Line_Dtl_Tbl(i).service_ref_line_id: '||p_Qte_Line_Dtl_Tbl(i).service_ref_line_id);
2376 END IF;
2377
2378 IF(p_Qte_Line_Dtl_Tbl(i).service_ref_type_code <> 'CUSTOMER_PRODUCT')
2379 and (p_Qte_Line_Dtl_Tbl(i).operation_code = 'CREATE') THEN
2380
2381
2382 IF(p_Qte_Line_Dtl_Tbl(i).service_ref_line_id is not null and
2383 p_Qte_Line_Dtl_Tbl(i).service_ref_line_id <> FND_API.g_miss_num) THEN
2384
2385 FOR rec_find_service in c_find_service(p_Qte_Line_Dtl_Tbl(i).service_ref_line_id) LOOP
2386 l_quote_line_id := rec_find_service.quote_line_id;
2387 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2388 IBE_Util.Debug('service aleady exists,l_quote_line_id: '||l_quote_line_id);
2389 END IF;
2390
2391 EXIT WHEN c_find_service%NOTFOUND;
2392 END LOOP;
2393
2394 IF(l_quote_line_id is not null) THEN
2395
2396 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2397 IBE_Util.Debug('Service item existing for the service item, deleting the existing one');
2398 END IF;
2399 l_Qte_Line_Tbl(l_Qte_Line_Tbl.count+1).quote_line_id := l_quote_line_id;
2400 l_Qte_Line_Tbl(l_Qte_Line_Tbl.count).operation_code := 'DELETE';
2401 END IF; --(if l_quote_line_id is not null)
2402
2403 END IF; --If(p_quote_line_detail_tbl.service_ref_line_id)
2404 END IF; --If (ref_type_code is 'customer_product')
2405 END LOOP;
2406 END IF; -- (Multiple services profile check)
2407 --END: CHANGES FOR LINE LEVEL SERVICES
2408 END IF; --line level services or cart level services
2409
2410 l_ibeItemTypeSize := l_Qte_Line_Tbl.count;
2411 for i in 1..l_ibeItemTypeSize loop
2412 --DBMS_OUTPUT.PUT_line('i:'||i||' *invId = '||l_Qte_Line_Tbl(i).inventory_item_id||' *type = '||l_Qte_Line_Tbl(i).item_type_code);
2413 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2414 IBE_Util.Debug('i: '||i||' *invId = '||l_Qte_Line_Tbl(i).inventory_item_id);
2415 IBE_Util.Debug(' *type = '||l_Qte_Line_Tbl(i).item_type_code);
2416 IBE_Util.Debug('l_Qte_Line_Tbl(i).operation_code: '||l_Qte_Line_Tbl(i).operation_code);
2417 END IF;
2418 end loop;
2419 l_ibeItemTypeSize := l_Qte_Line_Dtl_Tbl.count;
2420 FOR i in 1..l_ibeItemTypeSize LOOP
2421 --DBMS_OUTPUT.PUT_line('i:'||i||' *service_ref_qte_line_index = '||l_Qte_Line_Dtl_Tbl(i).service_ref_qte_line_index||' *qte_line_index = '||l_Qte_Line_Dtl_Tbl(i).qte_line_index);
2422 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2423 IBE_Util.Debug('i:'||i||' *service_ref_qte_line_index = '||l_Qte_Line_Dtl_Tbl(i).service_ref_qte_line_index||' *qte_line_index = '||l_Qte_Line_Dtl_Tbl(i).qte_line_index);
2424 IBE_Util.Debug('l_Qte_Line_Dtl_Tbl(i).service_period: '||l_Qte_Line_Dtl_Tbl(i).service_period);
2425 IBE_Util.Debug('l_Qte_Line_Dtl_Tbl(i).service_duration: '||l_Qte_Line_Dtl_Tbl(i).service_duration);
2426 IBE_Util.Debug('l_Qte_Line_Dtl_Tbl(i).service_ref_type_code: '||l_Qte_Line_Dtl_Tbl(i).service_ref_type_code);
2427 END IF;
2428 END LOOP;
2429
2430 --Added during line level services.
2431 --1. if doing express checkout of items then the api below will retrieve exp settings
2432
2433 IF(p_save_flag = SAVE_EXPRESSORDER) THEN
2434 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2435 IBE_Util.Debug(' Save_flag is: '||p_save_flag||' Calling IBE_ORD_ONECLICK_PVT.Get_Express_items_settings' );
2436 END IF;
2437
2438 IBE_ORD_ONECLICK_PVT.Get_Express_items_settings(
2439 x_qte_header_rec => lx_Qte_Header_Rec
2440 ,p_flag => 'ITEMS'
2441 ,x_payment_tbl => lx_Hd_Payment_Tbl
2442 ,x_hd_shipment_tbl => lx_Hd_Shipment_Tbl
2443 ,x_hd_tax_dtl_tbl => lx_Hd_Tax_Detail_Tbl);
2444 lx_qte_header_rec.quote_source_code := 'IStore Oneclick';
2445 l_attach_contract := FND_API.G_TRUE;
2446
2447 END IF; --(p_save_type = 'SAVE_EXPRESSORDER')
2448
2449 -- added 8/11/02: for Default Feature: we have to detect the case where we're defaulting:
2450 -- 1) We're creating an Account Active Cart
2451 -- 2) There's no other Account Active Cart for this particular user
2452 -- *Note that these conditions are copied from default_header_rec procedure
2453 IF p_qte_header_rec.quote_header_id = FND_API.G_MISS_NUM
2454 AND p_qte_header_rec.quote_source_code = 'IStore Account'
2455 AND (p_qte_header_rec.quote_name = 'IBE_PRMT_SC_UNNAMED' --MANNAMRA: 16/09/02:Changed IBEACTIVECART to IBEUNNAMED
2456 OR p_qte_header_rec.quote_name = FND_API.G_MISS_CHAR)
2457 AND (p_save_flag <> SAVE_EXPRESSORDER) THEN --Defaulting not required for express check out carts
2458
2459 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2460 IBE_Util.Debug(' need to get active cart');
2461 END IF;
2462 l_checkActiveCartId :=
2463 IBE_Quote_Misc_pvt.Get_Active_Quote_ID(
2464 p_party_id => p_qte_header_rec.party_id,
2465 p_cust_account_id => p_qte_header_rec.cust_account_id);
2466 -- create quote
2467 IF (l_checkActiveCartId = 0) THEN
2468 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2469 IBE_Util.Debug('About to call getHdrDefaultValues');
2470 END IF;
2471 getHdrDefaultValues(
2472 P_Api_Version_Number => p_api_version_number
2473 ,p_Init_Msg_List => p_init_msg_list
2474 ,p_Commit => p_commit
2475 ,p_minisite_id => l_Qte_Line_Tbl(1).minisite_id
2476 ,p_Qte_Header_Rec => p_Qte_Header_Rec
2477 ,p_hd_price_attributes_tbl => p_hd_price_attributes_tbl
2478 ,p_hd_payment_tbl => p_hd_payment_tbl
2479 ,p_hd_shipment_tbl => p_hd_shipment_tbl
2480 ,p_hd_freight_charge_tbl => p_hd_freight_charge_tbl
2481 ,p_hd_tax_detail_tbl => p_hd_tax_detail_tbl
2482 ,p_price_adjustment_tbl => p_price_adjustment_tbl
2483 ,p_price_adj_attr_tbl => p_price_adj_attr_tbl
2484 ,p_price_adj_rltship_tbl => p_price_adj_rltship_tbl
2485 ,x_Qte_Header_Rec => lx_Qte_Header_Rec
2486 ,x_Hd_Price_Attributes_Tbl => lx_Hd_Price_Attributes_Tbl
2487 ,x_Hd_Payment_Tbl => lx_Hd_Payment_Tbl
2488 ,x_Hd_Shipment_Tbl => lx_Hd_Shipment_Tbl
2489 ,x_Hd_Freight_Charge_Tbl => lx_Hd_Freight_Charge_Tbl
2490 ,x_Hd_Tax_Detail_Tbl => lx_Hd_Tax_Detail_Tbl
2491 ,x_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
2492 ,x_Price_Adj_Attr_Tbl => lx_Price_Adj_Attr_Tbl
2493 ,x_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
2494 ,x_last_update_date => x_last_update_date
2495 ,X_Return_Status => x_Return_Status
2496 ,X_Msg_Count => x_Msg_Count
2497 ,X_Msg_Data => x_Msg_Data
2498 );
2499
2500 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2501 RAISE FND_API.G_EXC_ERROR;
2502 END IF;
2503 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2504 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2505 END IF;
2506
2507 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2508 IBE_Util.Debug('Back from calling getHdrDefaultValues');
2509 END IF;
2510 END IF;
2511 END IF;
2512
2513 --maithili added for R12
2514 /*Check for marketing source code id in the DB, ignore passed in value if DB value already exists */
2515 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2516 IBE_Util.Debug('Mkt Source code check, lx_Qte_Header_Rec.marketing_source_code_id'||lx_Qte_Header_Rec.marketing_source_code_id);
2517 IBE_Util.Debug('Mkt Source code check, lx_Qte_Header_Rec.quote_header_id'||lx_Qte_Header_Rec.quote_header_id);
2518 END IF;
2519 IF lx_Qte_Header_Rec.marketing_source_code_id is not null and
2520 lx_Qte_Header_Rec.marketing_source_code_id <> fnd_api.g_miss_num and
2521 lx_Qte_Header_Rec.quote_header_id is not null and
2522 lx_Qte_Header_Rec.quote_header_id <> fnd_api.g_miss_num THEN
2523
2524 OPEN c_get_marketing_source(lx_Qte_Header_Rec.quote_header_id);
2525 FETCH c_get_marketing_source into l_marketing_source_code_id;
2526 CLOSE c_get_marketing_source;
2527
2528 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2529 IBE_Util.Debug('l_marketing_source_code_id'||l_marketing_source_code_id);
2530 END IF;
2531
2532 IF (l_marketing_source_code_id is not null) THEN
2533 lx_Qte_Header_Rec.marketing_source_code_id := FND_API.G_MISS_NUM;
2534 END IF;
2535 END IF;
2536 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2537 IBE_Util.Debug('After Mkt Source code check, lx_Qte_Header_Rec.marketing_source_code_id'||lx_Qte_Header_Rec.marketing_source_code_id);
2538 END IF;
2539
2540 /* Check Duplicate Header Promo Codes, If the passed in promo code value already exists in DB, then do not pass that */
2541 IF lx_Hd_Price_Attributes_Tbl.count > 0 THEN -- check Duplicate Promo code stuff only if the pricing attr tbl is not null
2542
2543 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2544 IBE_Util.Debug('Checking for duplicate promo codes'||lx_Hd_Price_Attributes_Tbl.count);
2545 END IF;
2546
2547 l_Hd_Price_Attributes_Tbl_temp := lx_Hd_Price_Attributes_Tbl;
2548
2549 -- Query existing promo codes and populate them in DB array.
2550 FOR rec_pricing_attr_info in c_get_hdr_pricing_attributes(lx_Qte_Header_Rec.quote_header_id) LOOP
2551 l_Hd_Price_Attributes_Tbl_DB(l_pricingIndex).pricing_attribute1 := rec_pricing_attr_info.pricing_attribute1;
2552 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2553 IBE_UTIL.debug('Existing Promo code in DB = '|| l_Hd_Price_Attributes_Tbl_DB(l_pricingIndex).pricing_attribute1 );
2554 IBE_UTIL.debug('pricing index = '|| l_pricingIndex );
2555 END IF;
2556 l_pricingIndex := l_pricingIndex + 1;
2557
2558 EXIT WHEN c_get_hdr_pricing_attributes%NOTFOUND;
2559 END LOOP;
2560
2561 FOR i IN 1..l_Hd_Price_Attributes_Tbl_temp.count LOOP
2562 If l_Hd_Price_Attributes_Tbl_temp(i).pricing_attribute1 IS NOT NULL
2563 AND l_Hd_Price_Attributes_Tbl_temp(i).pricing_attribute1 <> FND_API.G_MISS_CHAR THEN
2564 For j IN 1..l_Hd_Price_Attributes_Tbl_DB.count LOOP
2565 If l_Hd_Price_Attributes_Tbl_DB(j).pricing_attribute1 IS NOT NULL AND
2566 l_Hd_Price_Attributes_Tbl_temp(i).pricing_attribute1 = l_Hd_Price_Attributes_Tbl_DB(j).pricing_attribute1 THEN
2567 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2568 IBE_UTIL.debug('Duplicate Promo code = '|| l_Hd_Price_Attributes_Tbl_temp(i).pricing_attribute1||' found, setting pricing attribute rec to G_MISS_CHAR' );
2569 END IF;
2570 lx_Hd_Price_Attributes_Tbl(i).pricing_attribute1 := FND_API.G_MISS_CHAR;
2571 lx_Hd_Price_Attributes_Tbl(i).flex_title := FND_API.G_MISS_CHAR;
2572 lx_Hd_Price_Attributes_Tbl(i).pricing_context := FND_API.G_MISS_CHAR ;
2573 lx_Hd_Price_Attributes_Tbl(i).quote_header_id := FND_API.G_MISS_NUM;
2574 lx_Hd_Price_Attributes_Tbl(i).operation_code := FND_API.G_MISS_CHAR;
2575 END If;
2576 END LOOP; -- for j loop
2577 END IF; -- for checking not null check for temp array
2578 END LOOP;
2579
2580 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2581 IBE_Util.Debug('Before Save, lx_Hd_Price_Attributes_Tbl.count'||lx_Hd_Price_Attributes_Tbl.count);
2582 END IF;
2583 END IF;
2584
2585 Save(
2586 P_Api_Version_Number => p_api_version_number
2587 ,p_Init_Msg_List => p_init_msg_list
2588 ,p_Commit => p_commit
2589 ,p_combineSameItem => p_combineSameItem
2590 ,p_sharee_Number => p_sharee_Number
2591 ,p_sharee_party_id => p_sharee_party_id
2592 ,p_sharee_cust_account_id => p_sharee_cust_account_id
2593 ,p_minisite_id => p_minisite_id
2594 ,p_changeowner => p_changeowner
2595 ,p_save_type => p_save_flag
2596 ,p_Control_Rec => p_Control_Rec
2597 ,p_Qte_Header_Rec => lx_Qte_Header_Rec
2598 ,p_Qte_Line_Tbl => l_Qte_Line_Tbl
2599 ,p_Qte_Line_Dtl_Tbl => l_Qte_Line_Dtl_Tbl
2600
2601 ,p_hd_price_attributes_tbl => lx_Hd_Price_Attributes_Tbl
2602 ,p_hd_payment_tbl => lx_Hd_Payment_Tbl
2603 ,p_hd_shipment_tbl => lx_Hd_Shipment_Tbl
2604 ,p_hd_freight_charge_tbl => lx_Hd_Freight_Charge_Tbl
2605 ,p_hd_tax_detail_tbl => lx_Hd_Tax_Detail_Tbl
2606 ,p_line_attr_ext_tbl => p_line_attr_ext_tbl
2607 ,p_line_rltship_tbl => p_line_rltship_tbl
2608 ,p_price_adjustment_tbl => lx_Price_Adjustment_Tbl
2609 ,p_price_adj_attr_tbl => lx_Price_Adj_Attr_Tbl
2610 ,p_price_adj_rltship_tbl => lx_Price_Adj_Rltship_Tbl
2611 ,p_ln_price_attributes_tbl => p_ln_price_attributes_tbl
2612 ,p_ln_payment_tbl => p_ln_payment_tbl
2613 ,p_ln_shipment_tbl => p_ln_shipment_tbl
2614 ,p_ln_freight_charge_tbl => p_ln_freight_charge_tbl
2615 ,p_ln_tax_detail_tbl => p_ln_tax_detail_tbl
2616
2617 ,x_quote_header_id => x_quote_header_id
2618 ,x_last_update_date => x_last_update_date
2619 ,x_Qte_Header_Rec => lx_Qte_Header_Rec_tmp
2620 ,x_Hd_Price_Attributes_Tbl => lx_Hd_Price_Attributes_Tbl_tmp
2621 ,x_Hd_Payment_Tbl => lx_Hd_Payment_Tbl_tmp
2622 ,x_Hd_Shipment_Tbl => lx_Hd_Shipment_Tbl_tmp
2623 ,x_Hd_Shipment_Rec => lx_Hd_Shipment_Rec
2624 ,x_Hd_Freight_Charge_Tbl => lx_Hd_Freight_Charge_Tbl_tmp
2625 ,x_Hd_Tax_Detail_Tbl => lx_Hd_Tax_Detail_Tbl_tmp
2626 ,x_Qte_Line_Tbl => x_Qte_Line_Tbl
2627 ,x_Qte_Line_Dtl_Tbl => lx_Qte_Line_Dtl_Tbl
2628 ,x_Line_Attr_Ext_Tbl => lx_Line_Attr_Ext_Tbl
2629 ,x_Line_rltship_tbl => lx_Line_rltship_tbl
2630 ,x_Ln_Price_Attributes_Tbl => lx_Ln_Price_Attributes_Tbl
2631 ,x_Ln_Payment_Tbl => lx_Ln_Payment_Tbl
2632 ,x_Ln_Shipment_Tbl => lx_Ln_Shipment_Tbl
2633 ,x_Ln_Freight_Charge_Tbl => lx_Ln_Freight_Charge_Tbl
2634 ,x_Ln_Tax_Detail_Tbl => lx_Ln_Tax_Detail_Tbl
2635 ,x_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl_tmp
2636 ,x_Price_Adj_Attr_Tbl => lx_Price_Adj_Attr_Tbl_tmp
2637 ,x_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl_tmp
2638 ,X_Return_Status => x_Return_Status
2639 ,X_Msg_Count => x_Msg_Count
2640 ,X_Msg_Data => x_Msg_Data
2641 );
2642
2643 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2644 RAISE FND_API.G_EXC_ERROR;
2645 END IF;
2646 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2647 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2648 END IF;
2649
2650 lx_Qte_Header_Rec := lx_Qte_Header_Rec_tmp;
2651 lx_Hd_Price_Attributes_Tbl := lx_Hd_Price_Attributes_Tbl_tmp;
2652 lx_Hd_Payment_Tbl := lx_Hd_Payment_Tbl_tmp;
2653 lx_Hd_Shipment_Tbl := lx_Hd_Shipment_Tbl_tmp;
2654 lx_Hd_Freight_Charge_Tbl := lx_Hd_Freight_Charge_Tbl_tmp;
2655 lx_Hd_Tax_Detail_Tbl := lx_Hd_Tax_Detail_Tbl;
2656 lx_Price_Adjustment_Tbl := lx_Price_Adjustment_Tbl;
2657 lx_Price_Adj_Attr_Tbl := lx_Price_Adj_Attr_Tbl_tmp;
2658 lx_Price_Adj_Rltship_Tbl := lx_Price_Adj_Rltship_Tbl_tmp;
2659
2660 IF(l_attach_contract = FND_API.G_TRUE) THEN
2661 IF (FND_Profile.Value('OKC_ENABLE_SALES_CONTRACTS') = 'Y' ) THEN --Only if contracts is enabled
2662
2663 --instantiate a contract and associate to the quote
2664 /*mannamra: Chnages for MOAC : Bug 4682364*/
2665 --l_contract_template_id := FND_Profile.Value('ASO_DEFAULT_CONTRACT_TEMPLATE'); --Old style
2666 l_contract_template_id := to_number(ASO_UTILITY_PVT.GET_OU_ATTRIBUTE_VALUE(ASO_UTILITY_PVT.G_DEFAULT_CONTRACT_TEMPLATE)); --New style
2667 --
2668 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2669 IBE_UTIL.debug('l_contract_template_id = '||l_contract_template_id);
2670 end if;
2671 IF (l_contract_template_id is not null) THEN
2672
2673 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2674 IBE_UTIL.debug('l_contract_template_id = '||l_contract_template_id);
2675 IBE_UTIL.debug('Before calling OKC_TERMS_COPY_GRP.copy_terms_api, quoteheaderId = '||x_quote_header_id);
2676 END IF;
2677
2678 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2679 IBE_UTIL.debug('l_contract_template_id = '||l_contract_template_id);
2680 END IF;
2681
2682 OKC_TERMS_UTIL_GRP.get_translated_template(
2683 p_api_version => 1.0,
2684 p_init_msg_list => FND_API.g_false,
2685 p_template_id => l_contract_template_id, --this variable will have the translated template ID
2686 p_language => userenv('LANG'),
2687 p_document_type => 'QUOTE',
2688 x_template_id => l_trans_Contract_templ_id,
2689 x_return_status => x_return_status,
2690 x_msg_count => x_msg_count,
2691 x_msg_data => x_msg_data ) ;
2692
2693 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
2694 RAISE FND_API.G_EXC_ERROR;
2695 END IF;
2696 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
2697 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2698 END IF;
2699
2700 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2701 IBE_UTIL.debug('l_trans_Contract_templ_id = '||l_trans_Contract_templ_id);
2702 IBE_UTIL.debug('After calling OKC_TERMS_UTIL_GRP. get_translated_template(), quoteheaderId = '||lx_Qte_Header_Rec.quote_header_id);
2703 END IF;
2704
2705 OKC_TERMS_COPY_GRP.copy_terms(
2706 p_api_version =>1.0
2707 ,p_template_id => l_trans_Contract_templ_id
2708 ,p_target_doc_type => 'QUOTE'
2709 ,p_target_doc_id => lx_Qte_Header_Rec.quote_header_id
2710 ,p_article_effective_date => null
2711 ,p_validation_string => null
2712 ,x_return_status => x_return_status
2713 ,x_msg_count => x_msg_count
2714 ,x_msg_data => x_msg_data);
2715
2716 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2717 IBE_UTIL.debug('After copy_terms api, return status = '||x_return_status);
2718 END IF;
2719 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
2720 RAISE FND_API.G_EXC_ERROR;
2721 END IF;
2722 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
2723 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2724 END IF; --IF (l_contract_template_id is not null
2725 END IF; --IF (FND_Profile.Value('OKC_ENABLE_SALES_CONTRACTS') = 'Y'
2726 END IF;
2727 END IF; --if l_attach_contract is true;
2728
2729 -- End of API body.
2730 -- Standard check of p_commit.
2731 IF FND_API.To_Boolean( p_commit ) THEN
2732 COMMIT WORK;
2733 END IF;
2734
2735 -- Standard call to get message count and if count is 1, get message info.
2736 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2737 p_count => x_msg_count ,
2738 p_data => x_msg_data);
2739
2740 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2741 IBE_Util.Debug('End IBE_Quote_Save_pvt.AddItemsToCart_orig()');
2742 END IF;
2743 -- IBE_Util.Disable_Debug;
2744
2745 EXCEPTION
2746 WHEN FND_API.G_EXC_ERROR THEN
2747 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2748 IBE_Util.Debug('Expected error: IBE_Quote_Save_pvt.AddItemsToCart_orig()');
2749 END IF;
2750
2751 ROLLBACK TO AddItemsToCartorig_pvt;
2752 x_return_status := FND_API.G_RET_STS_ERROR;
2753 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2754 p_count => x_msg_count ,
2755 p_data => x_msg_data);
2756 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2757 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2758 IBE_Util.Debug('Unexpected error: IBE_Quote_Save_pvt.AddItemsToCart_orig()');
2759 END IF;
2760
2761 ROLLBACK TO AddItemsToCartorig_pvt;
2762 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2763 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2764 p_count => x_msg_count ,
2765 p_data => x_msg_data);
2766 WHEN OTHERS THEN
2767 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2768 IBE_Util.Debug('Unknown error: IBE_Quote_Save_pvt.AddItemsToCart_orig()');
2769 END IF;
2770
2771 ROLLBACK TO AddItemsToCartorig_pvt;
2772 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2773 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
2774 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2775 l_api_name);
2776 END IF;
2777 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2778 p_count => x_msg_count ,
2779 p_data => x_msg_data);
2780
2781 END AddItemsToCart_orig;
2782
2783 /*This function creates the XML message required by the CZ_CF_API.Validate API*/
2784 function get_xml_for_validate(p_model_item_id IN number,
2785 p_model_quantity IN number,
2786 p_quote_header_id IN number,
2787 p_inv_org_id IN number,
2788 p_quote_line_id IN number) return varchar2 is
2789 l_user_id varchar2(10);
2790 l_database_id varchar2(30);
2791 l_session_ticket varchar2(50);
2792 l_context_org_id varchar2(50);
2793 l_calling_application_id varchar2(10);
2794 l_responsibility_id varchar2(10);
2795 l_servlet_url varchar2(100);
2796 Str_database_id varchar2(1000);
2797 str_session_ticket varchar2(100);
2798 str_context_org_id varchar2(100);
2799 str_model_id varchar2(100);
2800 str_model_quantity varchar2(100);
2801 str_config_creation_date varchar2(100);
2802 str_calling_appl_id varchar2(100);
2803 str_responsibility_id varchar2(100);
2804 str_save_config_behaviour varchar2(100);
2805 str_teminate_msg_behavior varchar2(100);
2806 str_sbm_sbm_flag varchar2(100);
2807 str_sbm_client_header varchar2(100);
2808 str_sbm_client_line varchar2(100);
2809 str_xml_string varchar2(2000);
2810 begin
2811
2812 l_database_id := fnd_web_config.database_id;
2813 l_session_ticket :=cz_cf_api.icx_session_ticket;
2814 --l_context_org_id :=fnd_profile.value('ORG_ID');
2815 l_responsibility_id := fnd_profile.value('RESP_ID') ;
2816 l_calling_application_id := fnd_profile.value('RESP_APPL_ID');
2817 l_servlet_url := fnd_profile.value('CZ_UIMGR_URL') ;
2818 /*construct the XML string here*/
2819
2820 str_database_id := '<param+name="database_id">'||l_database_id||'</param>';
2821 str_session_ticket :='<param+name="icx_session_ticket">'||l_session_ticket||'</param>';
2822 str_context_org_id :='<param+name="context_org_id">'||p_inv_org_id||'</param>';
2823 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2824 IBE_Util.Debug('The Model item id passed to batch validate is '||to_char(p_model_item_id));
2825 END IF;
2826 str_model_id := '<param+name="model_id">'||to_char(p_model_item_id)||'</param>';
2827
2828 str_model_quantity :='<param+name="model_quantity">'||p_model_quantity||'</param>';
2829 str_config_creation_date :='<param+name="config_creation_date">'||to_char(sysdate,'mm-dd-yyyy-hh24-mi-ss')||'</param>';
2830 str_calling_appl_id := '<param+name="calling_application_id">'||l_calling_application_id||'</param>';
2831 str_responsibility_id := '<param+name="responsibility_id">'||l_responsibility_id||'</param>';
2832 str_save_config_behaviour:='<param+name="save_config_behavior">'||'new_revision'||'</param>';
2833 str_teminate_msg_behavior:='<param+name="terminate_msg_behavior">'||'full'||'</param>';
2834 -- added 12/13/02: for potential SBM bundles
2835 str_sbm_sbm_flag :='<param+name="sbm_flag">'||'true'||'</param>';
2836 str_sbm_client_header :='<param+name="client_header">'||to_char(p_quote_header_id)||'</param>';
2837 str_sbm_client_line :='<param+name="client_line">'||to_char(p_quote_line_id)||'</param>';
2838
2839 str_xml_string :='<initialize>'||str_database_id||str_session_ticket||str_context_org_id||str_model_id||str_model_quantity||str_config_creation_date;
2840 str_xml_string := str_xml_string || str_calling_appl_id||str_responsibility_id;
2841 str_xml_string := str_xml_string||str_save_config_behaviour||str_teminate_msg_behavior;
2842 str_xml_string := str_xml_string||str_sbm_sbm_flag||str_sbm_client_header||str_sbm_client_line||'</initialize>';
2843
2844 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2845 IBE_Util.Debug('The init msg string from get_xml_for_validate:'||str_xml_string);
2846 END IF;
2847 return str_xml_string;
2848 end get_xml_for_validate;
2849
2850 -- formerly AddModelsToCart
2851 -- same signature, but expanded to match the original addItemsToCart
2852 -- this should be the main entry point for all item types as it internally calls addItemsToCart_orig
2853 PROCEDURE AddItemsToCart(
2854 P_Api_Version_Number IN NUMBER
2855 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
2856 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
2857 -- this flag is no longer used or supported; rather items will come in with a line code indicating it is a bundle
2858 ,p_Bundle_Flag IN VARCHAR2 := FND_API.G_FALSE
2859 ,p_combineSameItem IN VARCHAR2 := FND_API.G_MISS_CHAR
2860 ,p_sharee_Number IN Number := FND_API.G_MISS_NUM
2861 ,p_sharee_party_id IN Number := FND_API.G_MISS_NUM
2862 ,p_sharee_cust_account_id IN Number := FND_API.G_MISS_NUM
2863 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
2864 ,p_changeowner IN VARCHAR2 := FND_API.G_FALSE
2865 ,p_Control_Rec IN ASO_Quote_Pub.Control_Rec_Type
2866 := ASO_Quote_Pub.G_Miss_Control_Rec
2867 ,p_ql_line_codes IN jtf_number_table := NULL
2868 ,p_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
2869 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
2870 ,p_hd_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
2871 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
2872 ,p_hd_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
2873 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
2874 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
2875 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
2876 ,p_hd_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
2877 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
2878 ,p_hd_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
2879 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
2880 ,p_Qte_Line_Tbl IN ASO_Quote_Pub.Qte_Line_Tbl_Type
2881 := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL
2882 ,p_Qte_Line_Dtl_Tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
2883 := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL
2884 ,p_Line_Attr_Ext_Tbl IN ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
2885 := ASO_Quote_Pub.G_MISS_Line_Attribs_Ext_TBL
2886 ,p_line_rltship_tbl IN ASO_Quote_Pub.Line_Rltship_Tbl_Type
2887 := ASO_Quote_Pub.G_MISS_Line_Rltship_Tbl
2888 ,p_Price_Adjustment_Tbl IN ASO_Quote_Pub.Price_Adj_Tbl_Type
2889 := ASO_Quote_Pub.G_Miss_Price_Adj_Tbl
2890 ,p_Price_Adj_Attr_Tbl IN ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
2891 := ASO_Quote_Pub.G_Miss_PRICE_ADJ_ATTR_Tbl
2892 ,p_Price_Adj_Rltship_Tbl IN ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
2893 := ASO_Quote_Pub.G_Miss_Price_Adj_Rltship_Tbl
2894 ,p_Ln_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
2895 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
2896 ,p_Ln_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
2897 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
2898 ,p_Ln_Shipment_Tbl IN ASO_Quote_Pub.Shipment_Tbl_Type
2899 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
2900 ,p_Ln_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
2901 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
2902 ,p_Ln_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
2903 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
2904 ,P_save_flag IN NUMBER := SAVE_ADDTOCART
2905 ,x_quote_header_id OUT NOCOPY varchar2
2906 ,x_Qte_Line_Tbl OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
2907 ,x_last_update_date OUT NOCOPY DATE
2908 ,X_Return_Status OUT NOCOPY VARCHAR2
2909 ,X_Msg_Count OUT NOCOPY NUMBER
2910 ,X_Msg_Data OUT NOCOPY VARCHAR2
2911 )
2912 is
2913
2914 l_api_name CONSTANT VARCHAR2(30) := 'ADDMODELSTOCART';
2915 l_api_version CONSTANT NUMBER := 1.0;
2916 lx_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type;
2917 lx_Hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
2918 lx_Hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
2919
2920 lx_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
2921 lx_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type;
2922 lx_Hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
2923 lx_Hd_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
2924
2925 lx_Qte_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
2926 lx_Line_Attr_Ext_Tbl ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type;
2927 lx_Line_rltship_tbl ASO_Quote_Pub.Line_Rltship_Tbl_Type;
2928
2929 lx_Ln_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
2930 lx_Ln_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
2931 lx_Ln_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
2932 lx_Ln_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
2933 lx_Ln_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
2934
2935 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
2936 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type;
2937 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
2938 /*Following parameters added for Education project*/
2939 loop_counter Number;
2940 l_xml_string_for_validate varchar2(2000); /*This holds the XML string to be passed to validate API*/
2941 lx_xml_from_validate varchar2(2000); /*This holds the XML string returned by validate API*/
2942 l_input_selection cz_cf_api.input_selection;
2943 l_cfg_input_list cz_cf_api.cfg_input_list;
2944 lx_cfg_output_pieces cz_cf_api.cfg_output_pieces;
2945 l_validation_status number;
2946 l_config_header_id number := fnd_api.g_miss_num;
2947 l_config_rev_num number;
2948 l_complete_config_flag varchar2(5);
2949 l_valid_config_flag varchar2(5);
2950 l_servlet_url varchar2(2000);
2951 l_qte_line_rec ASO_Quote_Pub.Qte_Line_rec_Type;
2952 l_qte_line_dtl_rec ASO_Quote_Pub.Qte_Line_Dtl_rec_Type;
2953 lx_msg_count number;
2954 lx_msg_data varchar2(2000);
2955 lx_quote_header_id number;
2956 l_control_rec ASO_Quote_Pub.control_rec_type;
2957 l_number_of_bundles number := 0;
2958 l_bundle_counter number := 0;
2959
2960
2961 BEGIN
2962 -- IBE_Util.Enable_Debug;
2963 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2964 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.AddItemsToCart() (new one)');
2965 END IF;
2966
2967 -- Standard Start of API savepoint
2968 SAVEPOINT ADDITEMSTOCART_pvt;
2969 -- Standard call to check for call compatibility.
2970 IF NOT FND_API.Compatible_API_Call (l_api_version,
2971 P_Api_Version_Number,
2972 l_api_name,
2973 G_PKG_NAME )
2974 THEN
2975 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2976 END IF;
2977 -- Initialize message list if p_init_msg_list is set to TRUE.
2978 IF FND_API.To_Boolean( p_init_msg_list ) THEN
2979 FND_Msg_Pub.initialize;
2980 END IF;
2981
2982 -- Initialize API return status to success
2983 x_return_status := FND_API.G_RET_STS_SUCCESS;
2984 -- API body
2985
2986 -- User Authentication
2987 IBE_Quote_Misc_pvt.Validate_User_Update
2988 ( p_init_msg_list => p_init_msg_list
2989 ,p_quote_header_id => p_Qte_Header_Rec.quote_header_id
2990 ,p_party_id => p_Qte_Header_Rec.party_id
2991 ,p_cust_account_id => p_Qte_Header_Rec.cust_account_id
2992 ,p_quote_retrieval_number => p_sharee_Number
2993 ,p_validate_user => FND_API.G_TRUE
2994 ,P_save_type => P_save_flag
2995 ,p_last_update_date => p_Qte_Header_Rec.last_update_date
2996 ,x_return_status => x_return_status
2997 ,x_msg_count => lx_msg_count
2998 ,x_msg_data => lx_msg_data
2999 );
3000
3001 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3002 RAISE FND_API.G_EXC_ERROR;
3003 END IF;
3004
3005 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3006 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3007 END IF;
3008
3009 /*Check whether we have any model bundles or not*/
3010 if (p_ql_line_codes is not null) then
3011 for i in 1..p_Qte_Line_Tbl.count loop
3012 if (p_ql_line_codes(i) = MODEL_BUNDLE_LINE_CODE) then
3013 -- skip non bundles, this loop is only to handle bundles
3014 l_number_of_bundles := l_number_of_bundles +1;
3015 end if;
3016 end loop;
3017 else
3018 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3019 IBE_Util.Debug('no line codes');
3020 END IF;
3021 end if;
3022 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3023 IBE_Util.Debug('l_number_of_bundles : '||l_number_of_bundles);
3024 END IF;
3025
3026 if (l_number_of_bundles = 0) then
3027 -- if no bundles, set to price in the first additemstocart_orig call
3028 -- as we will have no subsequent call to aso to price
3029 l_control_rec := p_control_rec;
3030 else
3031 /*Turn off the control record values here to avoid pricing until the last bundle loop*/
3032 l_control_rec.pricing_request_type := fnd_api.g_miss_char;
3033 l_control_rec.header_pricing_event := fnd_api.g_miss_char;
3034 l_control_rec.line_pricing_event := fnd_api.g_miss_char;
3035 l_control_rec.Calculate_tax_flag := 'N';
3036 l_control_rec.Calculate_freight_charge_flag := 'N';
3037 end if;
3038 -- Compulsory call to AddItemsToCart_orig - this call will take care of all
3039 -- standard, service, ui model, and model of the bundle items
3040 /*wrt to model bundles: Pass model_item_ids(p_Qte_line_Tbl) to AddItemsToCart and receive the table of model quote_line_ids returned by AddModelsToCart*/
3041 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3042 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.AddItemsToCart_orig()');
3043 END IF;
3044 AddItemsToCart_orig (
3045 P_Api_Version_Number => P_Api_version_number
3046 ,p_Init_Msg_List => p_init_msg_list
3047 ,p_Commit => p_Commit
3048 ,p_combineSameItem => p_combineSameItem
3049 ,p_sharee_Number => p_sharee_Number
3050 ,p_sharee_party_id => p_sharee_party_id
3051 ,p_sharee_cust_account_id => p_sharee_cust_account_id
3052 ,p_minisite_id => p_minisite_id
3053 ,p_changeowner => p_changeowner
3054 ,p_Control_Rec => l_Control_Rec
3055 ,p_ql_line_codes => p_ql_line_codes
3056 ,p_Qte_Header_Rec => p_Qte_Header_Rec
3057 ,p_hd_Price_Attributes_Tbl => p_hd_Price_Attributes_Tbl
3058 ,p_hd_Payment_Tbl => p_hd_Payment_Tbl
3059 ,p_hd_Shipment_TBL => p_hd_Shipment_TBL
3060 ,p_hd_Freight_Charge_Tbl => p_hd_Freight_Charge_Tbl
3061 ,p_hd_Tax_Detail_Tbl => p_hd_Tax_Detail_Tbl
3062 ,p_Qte_Line_Tbl => p_Qte_Line_Tbl
3063 ,p_Qte_Line_Dtl_Tbl => p_Qte_Line_Dtl_Tbl
3064 ,p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl
3065 ,p_line_rltship_tbl => p_line_rltship_tbl
3066 ,p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl
3067 ,p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl
3068 ,p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl
3069 ,p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl
3070 ,p_Ln_Payment_Tbl => p_Ln_Payment_Tbl
3071 ,p_Ln_Shipment_Tbl => p_Ln_Shipment_Tbl
3072 ,p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl
3073 ,p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl
3074 ,P_save_flag => P_save_flag
3075 ,x_quote_header_id => x_quote_header_id
3076 ,x_Qte_Line_Tbl => x_Qte_Line_Tbl
3077 ,x_last_update_date => x_last_update_date
3078 ,X_Return_Status => x_return_status
3079 ,X_Msg_Count => lx_msg_count
3080 ,X_Msg_Data => lx_msg_data
3081 );
3082 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3083 IBE_Util.Debug('End IBE_Quote_Save_pvt.AddItemsToCart_orig() : ' || x_return_status);
3084 END IF;
3085
3086 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3087 RAISE FND_API.G_EXC_ERROR;
3088 END IF;
3089
3090 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3091 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3092 END IF;
3093
3094 if (l_number_of_bundles > 0) then
3095 l_bundle_counter := 0;
3096 l_servlet_url := fnd_profile.value('CZ_UIMGR_URL');
3097 -- by now the control record has already been set not to price
3098 -- we will restore the input pricing parameters on the last loop
3099
3100 /*Loop through the model quote line ids obtained from the previous call to AddItemsToCart*/
3101 for loop_count in 1..x_qte_line_tbl.count loop
3102 if (p_ql_line_codes(loop_count) = MODEL_BUNDLE_LINE_CODE) then
3103 -- skip non bundles, this loop is only to handle bundles
3104 l_bundle_counter := l_bundle_counter +1;
3105
3106 /*reset the state of control record for the last bundle*/
3107 if(l_bundle_counter = l_number_of_bundles) then
3108 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3109 IBE_Util.Debug('restoring control record for pricing');
3110 END IF;
3111 l_control_rec := p_control_rec;
3112 end if;
3113
3114 /*Call Batch validation program here*/
3115 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3116 IBE_Util.Debug('Begin cz_cf_api.validate');
3117 END IF;
3118 cz_cf_api.validate(config_input_list =>l_cfg_input_list,
3119 init_message =>get_xml_for_validate(x_qte_line_tbl(loop_count).inventory_item_id,
3120 x_qte_line_tbl(loop_count).quantity,
3121 x_quote_header_id,
3122 x_qte_line_tbl(loop_count).organization_id,
3123 x_qte_line_tbl(loop_count).quote_line_id),
3124 config_messages =>lx_cfg_output_pieces,
3125 validation_status =>l_validation_status,
3126 url =>l_servlet_url);
3127 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3128 IBE_Util.Debug('End cz_cf_api.validate');
3129 END IF;
3130 /*Parse the XML message for config_header_id, config_rev_num returned by the Batch validate program*/
3131 lx_xml_from_validate := lx_cfg_output_pieces(1);
3132 l_config_header_id := to_number(substr(lx_xml_from_validate,(instr(lx_xml_from_validate, '<config_header_id>',1,1)+18),(instr(lx_xml_from_validate,'</config_header_id>',1,1)-(instr(lx_xml_from_validate, '<config_header_id>',1,1)+18))));
3133 l_config_rev_num := to_number(substr(lx_xml_from_validate,(instr(lx_xml_from_validate,'<config_rev_nbr>',1,1)+16),(instr(lx_xml_from_validate,'</config_rev_nbr>',1,1)-(instr(lx_xml_from_validate,'<config_rev_nbr>',1,1)+16))));
3134 l_valid_config_flag := substr(lx_xml_from_validate,(instr(lx_xml_from_validate,'<valid_configuration>',1,1)+21),(instr(lx_xml_from_validate,'</valid_configuration>',1,1)-(instr(lx_xml_from_validate,'<valid_configuration>',1,1)+21)));
3135 l_complete_config_flag :=
3136 substr(lx_xml_from_validate,(instr(lx_xml_from_validate,'<complete_configuration>',1,1)+24),(instr(lx_xml_from_validate,'</complete_configuration>',1,1)-(instr(lx_xml_from_validate,'<complete_configuration>',1,1)+24)));
3137 l_qte_line_rec := x_qte_line_tbl(loop_count);
3138
3139 /*Error handling if cz_cf_api.validate failed*/
3140 IF (l_config_header_id is NULL) THEN
3141 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3142 IBE_Util.Debug('Error in CZ_CF_API.Validate:Printing the terminate string: '||lx_xml_from_validate);
3143 END IF;
3144 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
3145 FND_Message.Set_Name('IBE','IBE_DSP_GENERIC_ERROR_TXT');
3146 FND_Message.Set_Token('IBE_DSP_GENERIC_ERROR_TXT',lx_xml_from_validate);
3147 FND_Msg_Pub.Add;
3148 END IF;
3149 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3150 END IF;
3151
3152
3153 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3154 IBE_Util.Debug('Printing values obtained from batch validation');
3155 IBE_Util.Debug('Config header id: '||l_config_header_id);
3156 IBE_Util.Debug('Config rev num: '||l_config_rev_num);
3157 IBE_Util.Debug('Valid config flag: '||l_valid_config_flag);
3158 IBE_Util.Debug('Complete config flag: '||l_complete_config_flag);
3159 END IF;
3160
3161 l_Qte_Line_Dtl_rec.quote_line_id := x_qte_line_tbl(loop_count).quote_line_id;
3162 if l_complete_config_flag = 'true' then
3163 l_Qte_Line_Dtl_rec.complete_configuration_flag := 'Y';
3164 else
3165 l_Qte_Line_Dtl_rec.complete_configuration_flag := 'N';
3166 end if;
3167 if l_valid_config_flag = 'true' then
3168 l_Qte_Line_Dtl_rec.valid_configuration_flag := 'Y';
3169 else
3170 l_Qte_Line_Dtl_rec.Valid_configuration_flag := 'N';
3171 end if;
3172
3173 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3174 IBE_Util.Debug('Begin ASO_CFG_PUB.get_config_details');
3175 END IF;
3176 /*Call GET_CONFIG_DETAILS here*/
3177 aso_cfg_pub.get_config_details(P_Api_Version_Number => P_Api_Version_Number,
3178 P_Init_Msg_List => P_Init_Msg_List,
3179 p_commit => p_commit ,
3180 p_config_rec => l_Qte_Line_Dtl_rec,
3181 p_model_line_rec => l_qte_line_rec,
3182 p_config_hdr_id => l_config_header_id ,
3183 p_config_rev_nbr => l_config_rev_num,
3184 p_quote_header_id => x_quote_header_id ,
3185 p_Control_Rec => l_Control_Rec,
3186 x_return_status => x_return_status,
3187 x_msg_count => x_msg_count,
3188 x_msg_data => x_msg_data
3189 );
3190 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3191 IBE_Util.Debug('End ASO_CFG_PUB.get_config_details : ' || x_return_status);
3192 END IF;
3193
3194 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3195 RAISE FND_API.G_EXC_ERROR;
3196 END IF;
3197
3198 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3199 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3200 END IF;
3201 end if; -- end if bundle
3202 end loop; -- end bundle loop over line records from the 1st call to add models
3203 end if; -- end if l_have_bundle_Flag = true
3204 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3205 IBE_Util.Debug('End IBE_Quote_Save_pvt.AddItemsToCart() (new one)');
3206 END IF;
3207
3208 EXCEPTION
3209 WHEN FND_API.G_EXC_ERROR THEN
3210 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3211 IBE_Util.Debug('Expected error: IBE_Quote_Save_pvt.AddItemsToCart() (new one)');
3212 END IF;
3213
3214 ROLLBACK TO ADDITEMSTOCART_pvt;
3215 x_return_status := FND_API.G_RET_STS_ERROR;
3216 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3217 p_count => x_msg_count ,
3218 p_data => x_msg_data);
3219
3220 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3221 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3222 IBE_Util.Debug('Unexpected error: IBE_Quote_Save_pvt.AddItemsToCart() (new one)');
3223 END IF;
3224 ROLLBACK TO ADDITEMSTOCART_pvt;
3225 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3226 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3227 p_count => x_msg_count ,
3228 p_data => x_msg_data);
3229
3230 WHEN OTHERS THEN
3231 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3232 IBE_Util.Debug('Unknown error: IBE_Quote_Save_pvt.AddItemsToCart) (new one)');
3233 END IF;
3234 ROLLBACK TO ADDITEMSTOCART_pvt;
3235 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3236 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
3237 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3238 l_api_name);
3239 END IF;
3240 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3241 p_count => x_msg_count ,
3242 p_data => x_msg_data);
3243 END AddItemsToCart;
3244
3245 procedure get_termid_pricelistid( p_qte_line_tbl in OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
3246 ,
3247 p_ln_Payment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Payment_Tbl_Type
3248
3249 ) is
3250 /*This cursor selects price_list_id and term_id(payment_term_id as in aso_payments) */
3251 cursor c_term_pricelist(p_agreement_id number) is
3252 select price_list_id, term_id
3253 from oe_agreements_b
3254 where agreement_id = p_agreement_id;
3255 /*This cursor selects payment_id from aso_payments based on the qte_header_id and quote_line_id*/
3256 cursor c_payment_id(p_quote_header_id number, p_quote_line_id number) is
3257 select payment_id
3258 from aso_payments
3259 where quote_header_id = p_quote_header_id
3260 and quote_line_id = p_quote_line_id;
3261
3262 rec_term_pricelist c_term_pricelist%rowtype;
3263 rec_payment_id c_payment_id%rowtype;
3264 l_price_list_id number := fnd_api.g_miss_num;
3265 l_term_id number := fnd_api.g_miss_num;
3266 l_payment_id number := fnd_api.g_miss_num;
3267
3268 l_ql_loop_counter number := 1; /* Loop counter for Quote line table*/
3269 l_pmt_loop_counter number := 1; /* Loop counter for input payment table*/
3270 l_pmt_rec_counter number := 1; /* Loop counter for new payment table*/
3271 l_ln_payment_tbl ASO_Quote_Pub.Payment_Tbl_Type;
3272 l_qte_line_tbl ASO_Quote_Pub.Qte_Line_Tbl_Type;
3273 l_found_input_rec varchar2(5) := FND_API.G_FALSE;
3274
3275 begin
3276
3277 l_Qte_Line_Tbl := p_qte_line_tbl;
3278 l_pmt_rec_counter := 1;
3279
3280 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3281 ibe_util.debug('Entered get_termid_pricelistid');
3282 END IF;
3283 if (l_qte_line_tbl.count = 0) then
3284 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3285 ibe_util.debug('Quote_line_table is empty');
3286 END IF;
3287 end if;
3288
3289 for l_ql_loop_counter in 1..l_qte_line_tbl.count loop
3290
3291 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3292 ibe_util.debug('Quote header id is : '||l_qte_line_tbl(l_ql_loop_counter).quote_header_id);
3293 ibe_util.debug('Quote line id is: '||l_qte_line_tbl(l_ql_loop_counter).quote_line_id);
3294 ibe_util.debug('Quote line loop counter: '||l_ql_loop_counter);
3295 ibe_util.debug('Agreement Id detected is : '||l_qte_line_tbl(l_ql_loop_counter).agreement_id);
3296 END IF;
3297
3298 if ((l_qte_line_tbl(l_ql_loop_counter).agreement_id is not null)
3299 and (l_qte_line_tbl(l_ql_loop_counter).agreement_id <> fnd_api.g_miss_num)) then
3300 --if the agreement id has a value in the quote_line_tbl
3301 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3302 ibe_util.debug('Non Empty agreement value');
3303 END IF;
3304 for rec_term_pricelist in c_term_pricelist(l_qte_line_tbl(l_ql_loop_counter).agreement_id) loop
3305 --retrieve price_list_id from oe_agreements
3306 l_price_list_id := rec_term_pricelist.price_list_id;
3307 l_term_id := rec_term_pricelist.term_id;
3308 end loop;
3309 elsif (l_qte_line_tbl(l_ql_loop_counter).agreement_id is null) then
3310 -- If agreement_id is null in the quote_line_tbl then anull price_list_id and payment_term_id
3311 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3312 ibe_util.debug('NULL Agreement value');
3313 END IF;
3314 l_price_list_id := null;
3315 l_term_id := null;
3316 end if;
3317
3318 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3319 ibe_util.debug('l_price_list_id : '||l_price_list_id);
3320 ibe_util.debug('l_term_id : '||l_term_id );
3321 END IF;
3322
3323 -- this if goes to the end of the loop since we have no continue operator
3324 if ((l_qte_line_tbl(l_ql_loop_counter).agreement_id is null) or
3325 (l_qte_line_tbl(l_ql_loop_counter).agreement_id <> fnd_api.g_miss_num)) then
3326
3327 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3328 ibe_util.debug('Processing agreement id info - either null or number');
3329 END IF;
3330 -- take care of price list id
3331 l_qte_line_tbl(l_ql_loop_counter).price_list_id := l_price_list_id;
3332
3333 -- now deal with payment term id -
3334 /*Check for the presence of the payment record in the database(aso_payments),
3335 if the record is present then operation code in the l_ln_payment_tbl= 'UPDATE'
3336 else it is 'CREATE'*/
3337 l_payment_id := fnd_api.g_miss_num;
3338 for rec_payment_id in c_payment_id( l_qte_line_tbl(l_ql_loop_counter).quote_header_id,
3339 l_qte_line_tbl(l_ql_loop_counter).quote_line_id) loop
3340 l_payment_id := rec_payment_id.payment_id;
3341 exit when c_payment_id%notfound;
3342 end loop;
3343
3344 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3345 ibe_util.debug('l_payment_id : '||l_payment_id );
3346 END IF;
3347 -- prep the current payment record
3348 l_found_input_rec := FND_API.G_FALSE;
3349 if (p_ln_payment_tbl.count > 0 ) then
3350 --loop through the payment table to identify the right qte_header_id and qte_line_id as in the line_record
3351 for l_pmt_loop_counter in 1..p_ln_payment_tbl.count loop
3352 if((p_ln_payment_tbl(l_pmt_loop_counter).quote_header_id = l_qte_line_tbl(l_ql_loop_counter).quote_header_id)
3353 and (p_ln_payment_tbl(l_pmt_loop_counter).quote_line_id = l_qte_line_tbl(l_ql_loop_counter).quote_line_id)) then
3354 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3355 ibe_util.debug('Found a passed in payment record.');
3356 END IF;
3357 l_found_input_rec := FND_API.G_TRUE;
3358 l_ln_payment_tbl(l_pmt_rec_counter) := p_ln_payment_tbl(l_pmt_loop_counter);
3359 l_ln_payment_tbl(l_pmt_rec_counter).payment_term_id := l_term_id;
3360 l_pmt_rec_counter := l_pmt_rec_counter + 1; --increment the payment table record counter
3361 end if;
3362 end loop;
3363 end if;
3364
3365 if ((l_found_input_rec = FND_API.G_FALSE) or
3366 (l_ln_payment_tbl(l_pmt_rec_counter).operation_code <> 'DELETE')) then
3367 if (l_payment_id <> fnd_api.g_miss_num ) then
3368 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3369 ibe_util.debug('Operation code is UPDATE');
3370 END IF;
3371 l_ln_payment_tbl(l_pmt_rec_counter).operation_code := 'UPDATE';
3372 l_ln_payment_tbl(l_pmt_rec_counter).payment_id := l_payment_id;
3373 l_ln_payment_tbl(l_pmt_rec_counter).quote_header_id := l_qte_line_tbl(l_ql_loop_counter).quote_header_id;
3374 l_ln_payment_tbl(l_pmt_rec_counter).quote_line_id := l_qte_line_tbl(l_ql_loop_counter).quote_line_id;
3375 l_ln_payment_tbl(l_pmt_rec_counter).payment_term_id := l_term_id;
3376 l_pmt_rec_counter := l_pmt_rec_counter + 1; --increment the payment table record counter
3377 else
3378 if ((l_term_id is not null) and (l_term_id <> fnd_api.g_miss_num)) then
3379 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3380 ibe_util.debug('Operation code is CREATE');
3381 END IF;
3382 l_ln_payment_tbl(l_pmt_rec_counter).operation_code := 'CREATE';
3383 l_ln_payment_tbl(l_pmt_rec_counter).quote_header_id := l_qte_line_tbl(l_ql_loop_counter).quote_header_id;
3384 l_ln_payment_tbl(l_pmt_rec_counter).quote_line_id := l_qte_line_tbl(l_ql_loop_counter).quote_line_id;
3385 l_ln_payment_tbl(l_pmt_rec_counter).payment_term_id := l_term_id;
3386 l_pmt_rec_counter := l_pmt_rec_counter + 1; --increment the payment table record counter
3387 end if;
3388 end if;
3389 end if;
3390
3391
3392 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3393 ibe_util.debug('OUT: l_pmt_rec_counter : '||l_pmt_rec_counter);
3394 END IF;
3395 if (l_ln_payment_tbl.count >= l_pmt_rec_counter) then
3396 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3397 ibe_util.debug('OUT: operation_code : '||l_ln_payment_tbl(l_pmt_rec_counter).operation_code);
3398 ibe_util.debug('OUT: quote_header_id : '||l_ln_payment_tbl(l_pmt_rec_counter).quote_header_id);
3399 ibe_util.debug('OUT: quote_line_id : '||l_ln_payment_tbl(l_pmt_rec_counter).quote_line_id);
3400 ibe_util.debug('OUT: payment_id : '||l_ln_payment_tbl(l_pmt_rec_counter).payment_id);
3401 ibe_util.debug('OUT: payment_term_id : '||l_ln_payment_tbl(l_pmt_rec_counter).payment_term_id);
3402 ibe_util.debug('OUT: price_list_id : '||l_qte_line_tbl(l_ql_loop_counter).price_list_id );
3403 END IF;
3404 end if;
3405
3406 --l_pmt_rec_counter := l_pmt_rec_counter + 1; --increment the payment table record counter
3407
3408
3409
3410 end if; -- end if agreement id not g_miss
3411
3412 end loop; --end loop for the loop around quote_line_table
3413
3414 p_ln_payment_tbl := l_ln_payment_tbl;
3415 p_Qte_Line_Tbl := l_qte_line_tbl;
3416
3417 end get_termid_pricelistid;
3418 /*Get_quote_expiration_date is used to determine the expiration date for a shopping cart.
3419 The number of days of expiration is different for saved carts and active carts and this
3420 number is determined from profile values 'IBE_EXP_ACTIVE_CART' and 'IBE_EXP_SAVE_CART' for
3421 active carts and saved carts respectively.*/
3422
3423 procedure GET_QUOTE_EXPIRATION_DATE(
3424 p_api_version IN NUMBER := 1.0 ,
3425 p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE ,
3426 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
3427 x_return_status OUT NOCOPY VARCHAR2 ,
3428 x_msg_count OUT NOCOPY NUMBER ,
3429 x_msg_data OUT NOCOPY VARCHAR2 ,
3430 p_quote_header_rec IN aso_quote_pub.qte_header_rec_type ,
3431 X_expiration_date OUT NOCOPY DATE) is
3432
3433 Cursor c_check_resource_name(quote_hdr_id number) is
3434 Select resource_id,quote_name
3435 from aso_quote_headers_all
3436 Where quote_header_id = quote_hdr_id;
3437
3438 G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBE_Quote_Save_pvt';
3439 l_api_name CONSTANT VARCHAR2(50) := 'Get_quote_expiration_date_pvt';
3440 l_api_version NUMBER := 1.0;
3441 Rec_check_resource_name c_check_resource_name%rowtype;
3442 L_db_resource_id number:= null;
3443 L_cart_name varchar2(2000);
3444 L_profile_value number:= fnd_api.g_miss_num;
3445 L_expiration_date date:= fnd_api.g_miss_date;
3446
3447 Begin
3448
3449 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3450 ibe_util.debug('Begin IEB_QUOTE_SAVE_pvt.GET_QUOTE_EXPIRATION_DATE()');
3451 END IF;
3452
3453 -- Standard Start of API savepoint
3454 SAVEPOINT Get_quote_exp_date_pvt;
3455
3456 -- Standard call to check for call compatibility.
3457 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
3458 p_api_version,
3459 L_API_NAME ,
3460 G_PKG_NAME )
3461 THEN
3462 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3463 END IF;
3464
3465 -- Initialize message list if p_init_msg_list is set to TRUE.
3466 IF FND_API.To_Boolean(p_init_msg_list) THEN
3467 FND_Msg_Pub.initialize;
3468 END IF;
3469
3470 -- Initialize API return status to success
3471 x_return_status := FND_API.G_RET_STS_SUCCESS;
3472
3473 --API Body
3474 x_expiration_date := fnd_api.g_miss_date;
3475 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3476 IBE_UTIL.debug('Incoming quote name into get_quote_exp_date is '||p_quote_header_rec.quote_name);
3477 END IF;
3478 --If no resource id in the quote header rec then check for one in the database
3479 If p_quote_header_rec.resource_id = fnd_api.g_miss_num then
3480 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3481 IBE_UTIL.debug('No resource id in the incoming quote_header_rec');
3482 END IF;
3483
3484 For rec_check_resource_name in c_check_resource_name(p_quote_header_rec.quote_header_id) loop
3485 L_db_resource_id := rec_check_resource_name.resource_id;
3486 L_cart_name := rec_check_resource_name.quote_name;
3487 Exit when c_check_resource_name%notfound;
3488 End loop;
3489 If (l_db_resource_id is null) then
3490 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3491 IBE_UTIL.debug('No resource id in the database for the given qte_hdr_id');
3492 END IF;
3493 If (((p_quote_header_rec.quote_name <> fnd_api.g_miss_char)
3494 and(p_quote_header_rec.quote_name is not null)
3495 and (p_quote_header_rec.quote_name<>'IBE_PRMT_SC_UNNAMED') --MANNAMRA: 16/09/02:Changed IBEACTIVECART to IBE_PRMT_SC_UNNAMED
3496 /* and(l_cart_name<> 'IBEACTIVECART') */
3497 )
3498 or((p_quote_header_rec.quote_name = fnd_api.g_miss_char)
3499 and (l_cart_name is not null)
3500 and (l_cart_name <>'IBE_PRMT_SC_UNNAMED'))) then --MANNAMRA: 16/09/02:Changed IBEACTIVECART to IBE_PRMT_SC_UNNAMED
3501 L_profile_value := FND_Profile.Value('IBE_EXP_SAVE_CART');
3502 Else
3503 L_profile_value := FND_Profile.Value('IBE_EXP_ACTIVE_CART');
3504 End If;
3505
3506 /*If((p_quote_header_rec.quote_name <> fnd_api.g_miss_char
3507 and p_quote_header_rec.quote_name <> 'IBEACTIVECART' )) then
3508 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3509 IBE_UTIL.debug('Using the IBE_EXP_SAVE_CART profile value');
3510 END IF;
3511 L_profile_value := FND_Profile.Value('IBE_EXP_SAVE_CART');
3512
3513 Elsif((l_cart_name = 'IBEACTIVECART')
3514 or(p_quote_header_rec.quote_name = 'IBEACTIVECART')) then
3515 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3516 IBE_UTIL.debug('Using the IBE_EXP_ACTIVE_CART profile value');
3517 END IF;
3518 L_profile_value := FND_Profile.Value('IBE_EXP_ACTIVE_CART');
3519 End if;*/
3520 x_expiration_date := trunc(sysdate)+nvl(l_profile_value,0);
3521 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3522 ibe_util.debug('Expiration date returned by get_quote_exp_date is suppressed');
3523 END IF;
3524 End if;
3525 End if;
3526
3527 -- Standard check of p_commit.
3528 IF FND_API.To_Boolean(p_commit) THEN
3529 COMMIT WORK;
3530 END IF;
3531
3532 -- Standard call to get message count and if count is 1, get message info.
3533 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3534 p_count => x_msg_count ,
3535 p_data => x_msg_data);
3536
3537 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3538 ibe_util.debug('End IBE_Quote_Save_pvt.GET_QUOTE_EXPIRATION_DATE()');
3539 END IF;
3540 EXCEPTION
3541 WHEN FND_API.G_EXC_ERROR THEN
3542 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3543 IBE_Util.Debug('Expected error: IBE_Quote_Save_pvt.Get_quote_expiration_date');
3544 END IF;
3545
3546 ROLLBACK TO Get_quote_exp_date_pvt;
3547 x_return_status := FND_API.G_RET_STS_ERROR;
3548 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3549 p_count => x_msg_count ,
3550 p_data => x_msg_data);
3551 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3552 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3553 IBE_Util.Debug('Unexpected error: IBE_Quote_Save_pvt.Get_quote_expiration_date');
3554 END IF;
3555
3556 ROLLBACK TO Get_quote_exp_date_pvt;
3557 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3558 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3559 p_count => x_msg_count ,
3560 p_data => x_msg_data);
3561 WHEN OTHERS THEN
3562 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3563 IBE_Util.Debug('Unknown error: IBE_Quote_Save_pvt.Get_quote_expiration_date');
3564 END IF;
3565
3566 ROLLBACK TO Get_quote_exp_date_pvt;
3567 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3568 IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
3569 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3570 L_API_NAME);
3571 END IF;
3572
3573 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3574 p_count => x_msg_count ,
3575 p_data => x_msg_data);
3576 End Get_Quote_expiration_date;
3577
3578 procedure request_for_sales_assistance (
3579 P_Api_Version IN NUMBER ,
3580 p_Init_Msg_List IN VARCHAR2:= FND_API.G_FALSE ,
3581 p_Commit IN VARCHAR2:= FND_API.G_FALSE ,
3582 x_return_status OUT NOCOPY VARCHAR2 ,
3583 x_msg_count OUT NOCOPY NUMBER ,
3584 x_msg_data OUT NOCOPY VARCHAR2 ,
3585 x_last_update_date OUT NOCOPY Date ,
3586 p_minisite_id IN NUMBER ,
3587 p_last_update_date IN Date ,
3588 p_quote_header_id IN NUMBER:= FND_API.G_MISS_NUM,
3589 p_party_id IN NUMBER:= FND_API.G_MISS_NUM,
3590 p_cust_account_id IN NUMBER:= FND_API.G_MISS_NUM,
3591 p_validate_user IN VARCHAR2:= FND_API.G_FALSE ,
3592 P_quote_name IN VARCHAR2 ,
3593 P_Reason_code IN VARCHAR2 ,
3594 P_url IN VARCHAR2:= FND_API.G_MISS_CHAR,
3595 P_COMMENTS IN VARCHAR2,
3596 p_retrieval_number IN NUMBER := FND_API.G_MISS_NUM,
3597 p_contract_context IN VARCHAR2 :='N',
3598 p_notes IN VARCHAR2 := NULL) is
3599
3600 Cursor c_find_resourceid(qte_hdr_id number) is
3601 select resource_id,ASSISTANCE_REASON_CODE
3602 from aso_quote_headers_all
3603 where quote_header_id = qte_hdr_id;
3604 /*Cursor c_get_jtf_resource(salesrep number) is
3605 select resource_id
3606 from jtf_rs_salesreps_mo_v
3607 where salesrep_id = salesrep;*/
3608 /*10/17/2005:Mannamra: Bug ref #4682364. Modified cursor for getting the resource.
3609 This query will get us the primary resource id */
3610 CURSOR c_get_jtf_resource (l_Srep VARCHAR2) IS
3611 SELECT Resource_Id
3612 /* FROM JTF_RS_SRP_VL */
3613 FROM JTF_RS_SALESREPS_MO_V
3614 WHERE Salesrep_number = l_Srep
3615 AND NVL(status,'A') = 'A'
3616 AND nvl(trunc(start_date_active), trunc(sysdate)) <= trunc(sysdate)
3617 AND nvl(trunc(end_date_active), trunc(sysdate)) >= trunc(sysdate) ;
3618
3619
3620 Cursor c_get_sr_user_id(resourceid number) is
3621 select user_id
3622 from jtf_rs_resource_extns
3623 where resource_id = resourceid;
3624 Cursor c_get_status_id(p_status_code varchar2) is
3625 select quote_status_id
3626 from aso_quote_statuses_b
3627 where status_code = p_status_code;
3628
3629 Cursor c_get_lkp_meaning(lkp_code varchar2) is
3630 select lookup_code, meaning
3631 from fnd_lookup_values_vl
3632 where lookup_code = lkp_code
3633 and lookup_type = 'IBE_SALES_ASSIST_REASONS_LK';
3634
3635
3636 G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBE_Quote_Save_pvt';
3637 l_api_name CONSTANT VARCHAR2(200) := 'Req_for_sales_asst_pvt';
3638 l_api_version NUMBER := 1.0;
3639
3640
3641 l_salesrep_id VARCHAR2(50);
3642 L_resource_id Number := fnd_api.g_miss_num;
3643 l_salesrep_user_id Number := fnd_api.g_miss_num;
3644 l_salesrep_user_name Varchar2(100) :=fnd_api.g_miss_char;
3645 L_qte_hdr_rec ASO_Quote_Pub.Qte_Header_Rec_Type
3646 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec;
3647 l_status_id number;
3648 lx_quote_header_id number;
3649 lX_return_status VARCHAR2(1);
3650 lx_msg_count NUMBER;
3651 lx_msg_data VARCHAR2(2000);
3652 lx_last_update_date DATE;
3653 l_check_resource_id NUMBER;
3654 l_reason_code_meaning fnd_lookup_values_vl.meaning%type;
3655 lx_jtf_note_id NUMBER;
3656 l_quote_status aso_quote_statuses_vl.status_code%type;
3657
3658 rec_get_SR_user_id c_get_SR_user_id%rowtype;
3659 rec_get_jtf_resource c_get_jtf_resource%rowtype;
3660 rec_find_resourceid c_find_resourceid%rowtype;
3661 rec_get_status_id c_get_status_id%rowtype;
3662 -- rec_get_lkp_meaning c_get_lkp_meaning%rowtype;
3663
3664 l_contract_template_id NUMBER;
3665 l_trans_Contract_template_id NUMBER;
3666 l_save_changes VARCHAR2(1);
3667 l_db_reason_code VARCHAR2(30);
3668
3669 Begin
3670 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3671 ibe_util.debug('Start IBE_Quote_Save_pvt.REQUEST_FOR_SALES_ASSISTANCE()');
3672 END IF;
3673
3674 -- Standard Start of API savepoint
3675 SAVEPOINT Req_for_sales_asst_pvt;
3676
3677 -- Standard call to check for call compatibility.
3678 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
3679 p_api_version,
3680 L_API_NAME ,
3681 G_PKG_NAME )
3682 THEN
3683 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3684 END IF;
3685
3686 -- Initialize message list if p_init_msg_list is set to TRUE.
3687 IF FND_API.To_Boolean(p_init_msg_list) THEN
3688 FND_Msg_Pub.initialize;
3689 END IF;
3690 -- Initialize API return status to success
3691 x_return_status := FND_API.G_RET_STS_SUCCESS;
3692
3693 --API Body
3694 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3695 IBE_UTIL.DEBUG('REQUEST_FOR_SALES_ASSISTANCE: Before Calling log_environment_info');
3696 END IF;
3697 IBE_Quote_Misc_pvt.log_environment_info();
3698 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3699 IBE_UTIL.DEBUG('REQUEST_FOR_SALES_ASSISTANCE: After Calling log_environment_info');
3700 IBE_UTIL.DEBUG('REQUEST_FOR_SALES_ASSISTANCE: p_retrieval_number = '||p_retrieval_number);
3701 END IF;
3702 -- User Authentication
3703 IBE_Quote_Misc_pvt.Validate_User_Update
3704 ( p_init_msg_list => p_Init_Msg_List
3705 ,p_quote_header_id => p_quote_header_id
3706 ,p_party_id => p_party_id
3707 ,p_cust_account_id => p_cust_account_id
3708 ,p_validate_user => p_validate_user
3709 ,p_quote_retrieval_number => p_retrieval_number
3710 ,p_save_type => SALES_ASSISTANCE
3711 ,p_last_update_date => p_last_update_date
3712 ,x_return_status => lx_return_status
3713 ,x_msg_count => lx_msg_count
3714 ,x_msg_data => lx_msg_data
3715 );
3716 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
3717 RAISE FND_API.G_EXC_ERROR;
3718 END IF;
3719 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3720 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3721 END IF;
3722 --obtaining the resource id from the database
3723 For rec_find_resourceid in c_find_resourceid(p_quote_header_id) loop
3724 l_resource_id := rec_find_resourceid.resource_id ;
3725 l_db_reason_code := rec_find_resourceid.ASSISTANCE_REASON_CODE;
3726 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3727 IBE_UTIL.DEBUG('REQUEST_FOR_SALES_ASSISTANCE: db_resource_id is'||l_resource_id);
3728 IBE_UTIL.DEBUG('REQUEST_FOR_SALES_ASSISTANCE: l_db_reason_code = '||l_db_reason_code);
3729 END IF;
3730 Exit when c_find_resourceid%notfound;
3731 End loop;
3732
3733 If l_resource_id is null then
3734 l_save_changes := 'Y';
3735 --Making the value_specific call to obtain the profile value at application level
3736 -- ASO_DEFAULT_PERSON_ID may be defined at resp and appl levels , so using VALUE call
3737
3738 /*--10/17/2005: Mannamra: In light of MOAC chages, default salesrep setting is no
3739 longer a profile value but is instead stored
3740 as Quoting parameter. Bug ref: 4682364*/
3741
3742 --l_salesrep_id := FND_Profile.Value('ASO_DEFAULT_PERSON_ID'); --Old code
3743 l_salesrep_id := ASO_UTILITY_PVT.GET_OU_ATTRIBUTE_VALUE(ASO_UTILITY_PVT.G_DEFAULT_SALESREP); --new way of getting the salesrep id
3744
3745 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3746 IBE_UTIL.debug('IBE_QUOTE_SAVE_PVT.Request_for_sales_assistance: salesrep id from quote_attrib: '||l_salesrep_id);
3747 END IF;
3748
3749 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3750 IBE_UTIL.debug('Salesrep id from ASO profile is '||l_salesrep_id);
3751 END IF;
3752 --Profile value(ASO_DEFAULT_PERSON_ID) has salesrep_id, obtain resource_id from the
3753 --table jtf_rs_salesreps_mo_v. --Old comment
3754 /*--10/17/2005: Mannamra: In light of MOAC chages, default salesrep setting is no
3755 longer a profile value but is instead stored
3756 as Quoting parameter.However we will still obtainb the resource id
3757 for the corresponding salesrep id from jtf_rs_salesreps_mo_v. Bug ref: 4682364*/
3758
3759 for rec_get_jtf_resource in c_get_jtf_resource(l_salesrep_id) loop
3760 L_resource_id := rec_get_jtf_resource.resource_id;
3761 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3762 IBE_UTIL.debug('IBE_QUOTE_SAVE_PVT.Request_for_sales_assistance: L_resource_id: '||L_resource_id);
3763 END IF;
3764
3765 exit when c_get_jtf_resource%notfound;
3766 end loop;
3767
3768 --obtain the status_id for 'DRAFT' from aso_quote_statuses_vl
3769 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3770 IBE_UTIL.debug('obtain the status_id for DRAFT from aso_quote_statuses_vl ');
3771 END IF;
3772
3773 for rec_get_status_id in c_get_status_id('DRAFT') loop
3774 l_status_id := rec_get_status_id.quote_status_id;
3775 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3776 IBE_UTIL.debug('IBE_QUOTE_SAVE_PVT.Request_for_sales_assistance: l_status_id: '||l_status_id);
3777 END IF;
3778
3779 -- --DBMS_OUTPUT.PUT_line('Quote Status id: '||l_status_id);
3780 exit when c_get_status_id%notfound;
3781 end loop;
3782 --prepare the quote_hdr_rec for SAVE API
3783 L_qte_hdr_rec.resource_id := l_resource_id;
3784 L_qte_hdr_rec.quote_name := p_quote_name;
3785 L_qte_hdr_rec.quote_status_id := l_status_id; -- change the quote_status from "SAVE DRAFT"(CART) to "DRAFT".
3786 L_qte_hdr_rec.publish_flag := 'Y';
3787 end if;
3788
3789 if(l_save_changes = 'Y' OR l_db_reason_code is null OR l_db_reason_code <> p_reason_code)then
3790 l_qte_hdr_rec.quote_header_id := p_quote_header_id;
3791 l_qte_hdr_rec.last_update_date := p_last_update_date;
3792 --IBE.Q RSA changes
3793 l_qte_hdr_rec.Assistance_Requested := 'Y';
3794 l_qte_hdr_rec.Assistance_Reason_Code := p_reason_code;
3795
3796
3797 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3798 IBE_UTIL.debug('Values assigned to quote_header_rec going into "Save" API');
3799 IBE_UTIL.debug('Quote_header_id '||p_quote_header_id);
3800 IBE_UTIL.debug('Quote_name '||p_quote_name);
3801 IBE_UTIL.debug('Resource_id '||l_resource_id);
3802 IBE_UTIL.debug('Quote_status_id '||l_status_id);
3803 IBE_UTIL.debug('p_reason_code '||p_reason_code);
3804 IBE_UTIL.debug('Calling Save in request_for_sales_assist()');
3805 END IF;
3806 ibe_quote_save_pvt.save(
3807 p_api_version_number => 1.0 ,
3808 p_init_msg_list => FND_API.G_FALSE ,
3809 p_commit => FND_API.G_FALSE ,
3810 p_qte_header_rec => L_qte_hdr_rec ,
3811 p_save_type => SALES_ASSISTANCE ,
3812 p_sharee_Number => p_retrieval_number ,
3813 x_quote_header_id => lx_quote_header_id ,
3814 x_last_update_date => lx_last_update_date ,
3815 x_return_status => lx_return_status ,
3816 x_msg_count => lx_msg_count ,
3817 x_msg_data => lx_msg_data);
3818 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
3819 RAISE FND_API.G_EXC_ERROR;
3820 END IF;
3821 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3822 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3823 END IF;
3824 -- For the bug, 3014723, retrieve the resource_id from aso_quote_headers, instead of using the cached profile value.
3825 For rec_find_resourceid in c_find_resourceid(p_quote_header_id) loop
3826 l_resource_id := rec_find_resourceid.resource_id ;
3827 Exit when c_find_resourceid%notfound;
3828 End loop;
3829 END IF;
3830
3831 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3832 IBE_UTIL.debug('IBE_QUOTE_SAVE_PVT.Request_for_sales_assistance: L_resource_id in quote: '||L_resource_id);
3833 END IF;
3834
3835
3836 --Obtain the salesrep user_id here
3837 for rec_get_SR_user_id in c_get_SR_user_id(l_resource_id) loop
3838 l_salesrep_user_id := rec_get_SR_user_id.user_id;
3839 exit when c_get_SR_user_id%notfound;
3840 end loop;
3841
3842 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3843 IBE_UTIL.debug('IBE_QUOTE_SAVE_PVT.Request_for_sales_assistance: l_salesrep_user_id who will get the notif: '||l_salesrep_user_id);
3844 END IF;
3845
3846
3847 /* IBE.Q changes, this code commented out. Contracts needs to be
3848 instantiated in all cases
3849 -- Create the contract if the contract_context is set to 'Y'.
3850 IF (p_contract_context = 'Y') THEN
3851 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3852 IBE_UTIL.debug('contract context is Yes, before calling get_terms_template');
3853 END IF;
3854 */
3855
3856 IF (FND_Profile.Value('OKC_ENABLE_SALES_CONTRACTS') = 'Y' ) THEN --Only if contracts is enabled
3857 --check whether ther is already a contract associated with the quote
3858 IF (OKC_TERMS_UTIL_GRP.Get_Terms_Template('QUOTE', p_quote_header_id) IS NULL) THEN
3859 --no contract associated with the quote yet, hence get the contract template id.
3860 --instantiate a contract and associate to the quote
3861 /*Mannamra: Changes for MOAC: Bug 4682364**/
3862 --l_contract_template_id := FND_Profile.Value('ASO_DEFAULT_CONTRACT_TEMPLATE'); --Old style
3863 l_contract_template_id := to_number(ASO_UTILITY_PVT.GET_OU_ATTRIBUTE_VALUE(ASO_UTILITY_PVT.G_DEFAULT_CONTRACT_TEMPLATE)); --New style
3864 /*Mannamra: End of changes for MOAC**/
3865 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3866 IBE_UTIL.debug('l_contract_template_id = '||l_contract_template_id);
3867 IBE_UTIL.debug('p_quote_header_id = '||p_quote_header_id);
3868 END IF;
3869 IF (l_contract_template_id is not null) THEN
3870
3871 OKC_TERMS_UTIL_GRP.get_Translated_template(
3872 p_api_version => 1.0,
3873 p_init_msg_list => FND_API.g_false,
3874 p_template_id => l_contract_template_id,
3875 p_language => userenv('LANG'),
3876 p_document_type => 'QUOTE',
3877 --this variable will have the translated template ID
3878 x_template_id => l_trans_Contract_template_id,
3879 x_return_status => x_return_status,
3880 x_msg_count => x_msg_count,
3881 x_msg_data => x_msg_data ) ;
3882 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
3883 RAISE FND_API.G_EXC_ERROR;
3884 END IF;
3885 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3886 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3887 END IF;
3888
3889 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3890 IBE_UTIL.debug('l_trans_Contract_templ_id = '||l_trans_Contract_template_id);
3891 END IF;
3892
3893 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3894 IBE_UTIL.debug('calling IBE_QUOTE_MISC_PVT.get_aso_quote_status');
3895 END IF;
3896 l_quote_status := IBE_QUOTE_MISC_PVT.get_aso_quote_status(p_quote_header_id);
3897 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3898 IBE_UTIL.debug('returned from IBE_QUOTE_MISC_PVT.get_aso_quote_status, l_quote_status = '||l_quote_status);
3899 END IF;
3900 IF(upper(l_quote_status) <> 'APPROVED') THEN
3901 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3902 IBE_UTIL.debug('calling OKC_XPRT_INT_GRP.get_contract_terms...');
3903 END IF;
3904 OKC_XPRT_INT_GRP.get_contract_terms(
3905 p_api_version => 1.0
3906 ,p_init_msg_list => FND_API.g_false
3907 ,P_document_type => 'QUOTE'
3908 ,P_document_id => p_quote_header_id
3909 ,P_template_id => l_trans_Contract_template_id
3910 ,P_called_from_UI => 'N'
3911 ,P_run_xprt_flag => 'Y'
3912 ,x_return_status => lx_return_status
3913 ,x_msg_count => lx_msg_count
3914 ,x_msg_data => lx_msg_data ) ;
3915
3916
3917 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3918 IBE_UTIL.debug('After OKC_XPRT_INT_GRP.get_contract_terms, return status = '||lx_return_status);
3919 END IF;
3920 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
3921 RAISE FND_API.G_EXC_ERROR;
3922 END IF;
3923 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3924 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3925 END IF;
3926
3927 END IF; -- IF(upper(l_quote_status) <> 'APPROVED')
3928 END IF; --IF (l_contract_template_id is not null) THEN
3929 END IF;
3930 END IF; --Only if contracts is enabled
3931
3932 /*Calling share_readonly to downgrade the access levels of all recipients to 'R' status,
3933 this is done because recipients cannot update a cart after it becomes a quote*/
3934
3935 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3936 IBE_UTIL.DEBUG('Calling share_readonly to downgrade the access levels of all recipients to R status');
3937 END IF;
3938 IBE_QUOTE_SAVESHARE_V2_PVT.share_readonly(
3939 p_quote_header_id => p_quote_header_id,
3940 P_minisite_id => p_minisite_id ,
3941 p_url => p_url ,
3942 p_api_version => 1.0 ,
3943 p_init_msg_list => FND_API.G_FALSE ,
3944 p_commit => FND_API.G_FALSE ,
3945 x_return_status => lx_return_status ,
3946 x_msg_count => lx_msg_count ,
3947 x_msg_data => lx_msg_data );
3948
3949 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
3950 RAISE FND_API.G_EXC_ERROR;
3951 END IF;
3952 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3953 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3954 END IF;
3955 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3956 IBE_UTIL.DEBUG('Done calling share_readonly');
3957 END IF;
3958
3959 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3960 IBE_UTIL.DEBUG('RSA:Calling deactivate API');
3961 END IF;
3962 IBE_QUOTE_SAVESHARE_V2_PVT.DEACTIVATE_QUOTE (
3963 P_Quote_header_id => p_quote_header_id,
3964 P_Party_id => p_party_id ,
3965 P_Cust_account_id => p_cust_account_id ,
3966 p_api_version => p_api_version ,
3967 p_init_msg_list => fnd_api.g_false ,
3968 p_commit => fnd_api.g_false ,
3969 x_return_status => lx_return_status ,
3970 x_msg_count => lx_msg_count ,
3971 x_msg_data => lx_msg_data );
3972 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
3973 RAISE FND_API.G_EXC_ERROR;
3974 END IF;
3975
3976 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3977 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3978 END IF;
3979 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3980 IBE_UTIL.DEBUG('RSA:Deactivate owner cart after sharing:Done');
3981 END IF;
3982
3983 /* Commenting the code (4 Dec, 03) as we are passing the meaning from the UI itself.
3984 -- For Contract Context get the reason_code_meaning from FND Message Code. Otherwise get the lookup meaning.
3985 IF (p_contract_context = 'Y') THEN
3986 fnd_message.set_name('IBE','IBE_CHKOUT_LIC_TERMS_CONDN');
3987 l_reason_code_meaning := fnd_message.get;
3988 ELSE
3989 --obtain the lookup_value of the reason_code lookup_code
3990 for rec_get_lkp_meaning in c_get_lkp_meaning(p_reason_code) loop
3991 l_reason_code_meaning := rec_get_lkp_meaning.meaning;
3992 l_reason_code_meaning := ':'||rec_get_lkp_meaning.meaning;
3993 exit when c_get_lkp_meaning%notfound;
3994 end loop;
3995 END IF;
3996 */
3997
3998
3999 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4000 IBE_UTIL.debug('Calling the workflow notification API');
4001 END IF;
4002 --Calling the workflow notification API. This API sends out an e-maiol each to the salesrep and the customer.
4003 IBE_WORKFLOW_pvt.NotifyForSalesAssistance(
4004 p_api_version => 1.0 ,
4005 p_init_msg_list => FND_API.G_FALSE ,
4006 p_quote_id => P_QUOTE_HEADER_ID ,
4007 p_customer_comments => P_COMMENTS ,
4008 p_salesrep_email_id => FND_API.G_MISS_CHAR ,
4009 p_salesrep_user_id => l_salesrep_user_id ,
4010 p_reason_code => P_Reason_code ,
4011 p_msite_id => p_minisite_id ,
4012 x_return_status => lx_return_status ,
4013 x_msg_count => lx_msg_count ,
4014 x_msg_data => lx_msg_data );
4015
4016 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
4017 RAISE FND_API.G_EXC_ERROR;
4018 END IF;
4019 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
4020 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4021 END IF;
4022
4023 --Bug 3204942 Start
4024 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4025 IBE_UTIL.debug('Calling the create_note API');
4026 END IF;
4027 IF (p_notes IS NOT NULL) THEN
4028 JTF_NOTES_PUB.create_note(
4029 p_api_version =>1.0,
4030 x_return_status => lx_return_status,
4031 x_msg_count => lx_msg_count,
4032 x_msg_data => lx_msg_data,
4033 p_source_object_id => p_quote_header_id,
4034 p_source_object_code => 'ASO_QUOTE',
4035 p_notes => p_notes,
4036 p_notes_detail => p_comments,
4037 p_note_status => 'I', --this is for note_status of Public
4038 x_jtf_note_id => lx_jtf_note_id,
4039 p_note_type => 'QOT_SALES_ASSIST' );
4040
4041 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
4042 RAISE FND_API.G_EXC_ERROR;
4043 END IF;
4044 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
4045 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4046 END IF;
4047 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4048 IBE_UTIL.debug('After Calling the create_note API, note_id ='||lx_jtf_note_id);
4049 END IF;
4050 END IF;
4051 --Bug 3204942 End
4052
4053 -- Standard check of p_commit.
4054 IF FND_API.To_Boolean(p_commit) THEN
4055 COMMIT WORK;
4056 END IF;
4057
4058 -- Standard call to get message count and if count is 1, get message info.
4059 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4060 p_count => lx_msg_count ,
4061 p_data => lx_msg_data);
4062
4063 EXCEPTION
4064 WHEN FND_API.G_EXC_ERROR THEN
4065 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4066 IBE_Util.Debug('Expected error: IBE_Quote_Save_pvt.Request_for_sales_assistance');
4067 END IF;
4068
4069 ROLLBACK TO Req_for_sales_asst_pvt;
4070 x_return_status := FND_API.G_RET_STS_ERROR;
4071 Set_Last_Update_Date(p_quote_header_id, x_last_update_date);
4072 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4073 p_count => lx_msg_count ,
4074 p_data => lx_msg_data);
4075 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4076 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4077 IBE_Util.Debug('Unexpected error: IBE_Quote_Save_pvt.Request_for_sales_assistance');
4078 END IF;
4079
4080 ROLLBACK TO Req_for_sales_asst_pvt;
4081 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4082 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4083 p_count => lx_msg_count ,
4084 p_data => lx_msg_data);
4085 WHEN OTHERS THEN
4086 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4087 IBE_Util.Debug('Unknown error: IBE_Quote_Save_pvt.Request_for_sales_assistance');
4088 END IF;
4089
4090 ROLLBACK TO Req_for_sales_asst_pvt;
4091 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4092 Set_Last_Update_Date(p_quote_header_id, x_last_update_date);
4093 IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
4094 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
4095 L_API_NAME);
4096 END IF;
4097
4098 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4099 p_count => lx_msg_count ,
4100 p_data => lx_msg_data);
4101
4102 End request_for_sales_assistance;
4103
4104 -- Overloaded SAVE to not handle any output record from OC.
4105 PROCEDURE Save(
4106 P_Api_Version_Number IN NUMBER
4107 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
4108 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
4109 ,p_auto_update_active_quote IN VARCHAR2 := FND_API.G_TRUE
4110 ,p_combineSameItem IN VARCHAR2 := FND_API.G_MISS_CHAR
4111
4112 ,p_sharee_Number IN Number := FND_API.G_MISS_NUM
4113 ,p_sharee_party_id IN Number := FND_API.G_MISS_NUM
4114 ,p_sharee_cust_account_id IN Number := FND_API.G_MISS_NUM
4115 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
4116 ,p_changeowner IN VARCHAR2 := FND_API.G_FALSE
4117
4118 ,p_Control_Rec IN ASO_Quote_Pub.Control_Rec_Type
4119 := ASO_Quote_Pub.G_Miss_Control_Rec
4120 ,p_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
4121 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
4122 ,p_hd_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
4123 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
4124 ,p_hd_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
4125 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
4126 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
4127 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
4128 ,p_hd_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
4129 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
4130 ,p_hd_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
4131 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
4132 ,p_Qte_Line_Tbl IN ASO_Quote_Pub.Qte_Line_Tbl_Type
4133 := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL
4134 ,p_Qte_Line_Dtl_Tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
4135 := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL
4136 ,p_Line_Attr_Ext_Tbl IN ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
4137 := ASO_Quote_Pub.G_MISS_Line_Attribs_Ext_TBL
4138 ,p_line_rltship_tbl IN ASO_Quote_Pub.Line_Rltship_Tbl_Type
4139 := ASO_Quote_Pub.G_MISS_Line_Rltship_Tbl
4140 ,p_Price_Adjustment_Tbl IN ASO_Quote_Pub.Price_Adj_Tbl_Type
4141 := ASO_Quote_Pub.G_Miss_Price_Adj_Tbl
4142 ,p_Price_Adj_Attr_Tbl IN ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
4143 := ASO_Quote_Pub.G_Miss_PRICE_ADJ_ATTR_Tbl
4144 ,p_Price_Adj_Rltship_Tbl IN ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
4145 := ASO_Quote_Pub.G_Miss_Price_Adj_Rltship_Tbl
4146 ,p_Ln_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
4147 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
4148 ,p_Ln_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
4149 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
4150 ,p_Ln_Shipment_Tbl IN ASO_Quote_Pub.Shipment_Tbl_Type
4151 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
4152 ,p_Ln_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
4153 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
4154 ,p_Ln_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
4155 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
4156 ,p_save_type IN NUMBER := FND_API.G_MISS_NUM
4157 ,x_quote_header_id OUT NOCOPY varchar2
4158 ,x_last_update_date OUT NOCOPY DATE
4159 ,X_Return_Status OUT NOCOPY VARCHAR2
4160 ,X_Msg_Count OUT NOCOPY NUMBER
4161 ,X_Msg_Data OUT NOCOPY VARCHAR2
4162 )
4163 is
4164 lx_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type;
4165 lx_Hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
4166 lx_Hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
4167
4168 lx_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
4169 lx_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type;
4170 lx_Hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
4171 lx_Hd_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
4172
4173 lx_Qte_Line_Tbl ASO_Quote_Pub.Qte_Line_Tbl_Type;
4174 lx_Qte_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
4175 lx_Line_Attr_Ext_Tbl ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type;
4176 lx_Line_rltship_tbl ASO_Quote_Pub.Line_Rltship_Tbl_Type;
4177
4178 lx_Ln_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
4179 lx_Ln_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
4180 lx_Ln_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
4181 lx_Ln_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
4182 lx_Ln_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
4183
4184 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
4185 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type;
4186 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
4187
4188 BEGIN
4189
4190 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4191 IBE_UTIL.DEBUG('Begin IBE_Quote_Save_pvt.Save(Overloaded SAVE)');
4192 END IF;
4193 -- Commented mo_global.init(IBE) call as it was causing access mode error reported in 11810302, 8852116
4194 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4195 IBE_UTIL.DEBUG('Before calling mo_global.init, input param=S');
4196 END IF;
4197 --mo_global.init('IBE'); -- bug 10113717
4198 mo_global.init('S'); -- bug 12775927
4199 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4200 IBE_UTIL.DEBUG('After calling mo_global.init)');
4201 END IF;
4202 Save(
4203 P_Api_Version_Number => p_api_version_number
4204 ,p_Init_Msg_List => p_init_msg_list
4205 ,p_Commit => p_commit
4206 ,p_auto_update_active_quote => p_auto_update_active_quote
4207 ,p_combineSameItem => p_combineSameItem
4208 ,p_sharee_Number => p_sharee_Number
4209 ,p_sharee_party_id => p_sharee_party_id
4210 ,p_sharee_cust_account_id => p_sharee_cust_account_id
4211 ,p_minisite_id => p_minisite_id
4212 ,p_changeowner => p_changeowner
4213 ,p_Control_Rec => p_Control_Rec
4214 ,p_Qte_Header_Rec => p_Qte_Header_Rec
4215 ,p_hd_Price_Attributes_Tbl => p_hd_Price_Attributes_Tbl
4216 ,p_hd_Payment_Tbl => p_hd_Payment_Tbl
4217 ,p_hd_Shipment_Tbl => p_hd_Shipment_Tbl
4218 ,p_hd_Freight_Charge_Tbl => p_hd_Freight_Charge_Tbl
4219 ,p_hd_Tax_Detail_Tbl => p_hd_Tax_Detail_tbl
4220 ,p_Qte_Line_Tbl => p_Qte_Line_Tbl
4221 ,p_Qte_Line_Dtl_Tbl => p_Qte_Line_Dtl_Tbl
4222 ,p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl
4223 ,p_line_rltship_tbl => p_line_rltship_tbl
4224 ,p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl
4225 ,p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl
4226 ,p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl
4227 ,p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl
4228 ,p_Ln_Payment_Tbl => p_Ln_Payment_Tbl
4229 ,p_Ln_Shipment_Tbl => p_Ln_Shipment_Tbl
4230 ,p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl
4231 ,p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl
4232 ,p_save_type => p_save_type
4233 ,x_quote_header_id => x_quote_header_id
4234 ,x_last_update_date => x_last_update_date
4235 ,x_Qte_Header_Rec => lx_Qte_Header_Rec
4236 ,x_Hd_Price_Attributes_Tbl => lx_Hd_Price_Attributes_Tbl
4237 ,x_Hd_Payment_Tbl => lx_Hd_Payment_Tbl
4238 ,x_Hd_Shipment_Tbl => lx_Hd_Shipment_Tbl
4239 ,x_Hd_Shipment_Rec => lx_Hd_Shipment_Rec
4240 ,x_Hd_Freight_Charge_Tbl => lx_Hd_Freight_Charge_Tbl
4241 ,x_Hd_Tax_Detail_Tbl => lx_Hd_Tax_Detail_Tbl
4242 ,x_Qte_Line_Tbl => lx_Qte_Line_Tbl
4243 ,x_Qte_Line_Dtl_Tbl => lx_Qte_Line_Dtl_Tbl
4244 ,x_Line_Attr_Ext_Tbl => lx_Line_Attr_Ext_Tbl
4245 ,x_Line_rltship_tbl => lx_Line_rltship_tbl
4246 ,x_Ln_Price_Attributes_Tbl => lx_Ln_Price_Attributes_Tbl
4247 ,x_Ln_Payment_Tbl => lx_Ln_Payment_Tbl
4248 ,x_Ln_Shipment_Tbl => lx_Ln_Shipment_Tbl
4249 ,x_Ln_Freight_Charge_Tbl => lx_Ln_Freight_Charge_Tbl
4250 ,x_Ln_Tax_Detail_Tbl => lx_Ln_Tax_Detail_Tbl
4251 ,x_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
4252 ,x_Price_Adj_Attr_Tbl => lx_Price_Adj_Attr_Tbl
4253 ,x_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
4254 ,X_Return_Status => x_Return_Status
4255 ,X_Msg_Count => x_Msg_Count
4256 ,X_Msg_Data => x_Msg_Data
4257 );
4258 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4259 IBE_UTIL.DEBUG('End IBE_Quote_Save_pvt.Save(Overloaded SAVE)');
4260 END IF;
4261 END Save;
4262
4263
4264
4265 PROCEDURE Save(
4266 P_Api_Version_Number IN NUMBER
4267 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
4268 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
4269 ,p_auto_update_active_quote IN VARCHAR2 := FND_API.G_TRUE
4270 ,p_combineSameItem IN VARCHAR2 := FND_API.G_MISS_CHAR
4271
4272 ,p_sharee_Number IN Number := FND_API.G_MISS_NUM
4273 ,p_sharee_party_id IN Number := FND_API.G_MISS_NUM
4274 ,p_sharee_cust_account_id IN Number := FND_API.G_MISS_NUM
4275 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
4276 ,p_changeowner IN VARCHAR2 := FND_API.G_FALSE
4277
4278 ,p_Control_Rec IN ASO_Quote_Pub.Control_Rec_Type
4279 := ASO_Quote_Pub.G_Miss_Control_Rec
4280 ,p_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
4281 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
4282 ,p_hd_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
4283 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
4284 ,p_hd_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
4285 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
4286 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
4287 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
4288 ,p_hd_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
4289 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
4290 ,p_hd_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
4291 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
4292 ,p_Qte_Line_Tbl IN ASO_Quote_Pub.Qte_Line_Tbl_Type
4293 := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL
4294 ,p_Qte_Line_Dtl_Tbl IN ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
4295 := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL
4296 ,p_Line_Attr_Ext_Tbl IN ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
4297 := ASO_Quote_Pub.G_MISS_Line_Attribs_Ext_TBL
4298 ,p_line_rltship_tbl IN ASO_Quote_Pub.Line_Rltship_Tbl_Type
4299 := ASO_Quote_Pub.G_MISS_Line_Rltship_Tbl
4300 ,p_Price_Adjustment_Tbl IN ASO_Quote_Pub.Price_Adj_Tbl_Type
4301 := ASO_Quote_Pub.G_Miss_Price_Adj_Tbl
4302 ,p_Price_Adj_Attr_Tbl IN ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
4303 := ASO_Quote_Pub.G_Miss_PRICE_ADJ_ATTR_Tbl
4304 ,p_Price_Adj_Rltship_Tbl IN ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
4305 := ASO_Quote_Pub.G_Miss_Price_Adj_Rltship_Tbl
4306 ,p_Ln_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
4307 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
4308 ,p_Ln_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
4309 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
4310 ,p_Ln_Shipment_Tbl IN ASO_Quote_Pub.Shipment_Tbl_Type
4311 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
4312 ,p_Ln_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
4313 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
4314 ,p_Ln_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
4315 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
4316 ,p_save_type IN NUMBER := FND_API.G_MISS_NUM
4317 ,x_quote_header_id OUT NOCOPY varchar2
4318 ,x_last_update_date OUT NOCOPY DATE
4319
4320 ,x_Qte_Header_Rec IN OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type
4321 ,x_Hd_Price_Attributes_Tbl IN OUT NOCOPY ASO_Quote_Pub.Price_Attributes_Tbl_Type
4322 ,x_Hd_Payment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Payment_Tbl_Type
4323 ,x_Hd_Shipment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Shipment_Tbl_Type
4324 ,x_Hd_Shipment_Rec IN OUT NOCOPY ASO_Quote_Pub.Shipment_Rec_Type
4325 ,x_Hd_Freight_Charge_Tbl IN OUT NOCOPY ASO_Quote_Pub.Freight_Charge_Tbl_Type
4326 ,x_Hd_Tax_Detail_Tbl IN OUT NOCOPY ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE
4327 ,x_Qte_Line_Tbl IN OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
4328 ,x_Qte_Line_Dtl_Tbl IN OUT NOCOPY ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
4329 ,x_Line_Attr_Ext_Tbl IN OUT NOCOPY ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
4330 ,x_Line_rltship_tbl IN OUT NOCOPY ASO_Quote_Pub.Line_Rltship_Tbl_Type
4331 ,x_Ln_Price_Attributes_Tbl IN OUT NOCOPY ASO_Quote_Pub.Price_Attributes_Tbl_Type
4332 ,x_Ln_Payment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Payment_Tbl_Type
4333 ,x_Ln_Shipment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Shipment_Tbl_Type
4334 ,x_Ln_Freight_Charge_Tbl IN OUT NOCOPY ASO_Quote_Pub.Freight_Charge_Tbl_Type
4335 ,x_Ln_Tax_Detail_Tbl IN OUT NOCOPY ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE
4336 ,x_Price_Adjustment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Price_Adj_Tbl_Type
4337 ,x_Price_Adj_Attr_Tbl IN OUT NOCOPY ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
4338 ,x_Price_Adj_Rltship_Tbl IN OUT NOCOPY ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
4339
4340 ,X_Return_Status OUT NOCOPY VARCHAR2
4341 ,X_Msg_Count OUT NOCOPY NUMBER
4342 ,X_Msg_Data OUT NOCOPY VARCHAR2
4343 )
4344 is
4345 l_api_name CONSTANT VARCHAR2(30) := 'SAVE';
4346 l_api_version CONSTANT NUMBER := 1.0;
4347 l_pricebasedonowner varchar2(100);
4348 l_count NUMBER;
4349 l_qte_header_rec ASO_Quote_Pub.Qte_Header_Rec_Type
4350 := ASO_Quote_Pub.g_miss_qte_header_rec;
4351 l_qte_line_tbl ASO_Quote_Pub.Qte_Line_Tbl_Type
4352 := ASO_Quote_Pub.g_miss_qte_line_tbl;
4353 l_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type
4354 := ASO_Quote_Pub.g_miss_shipment_rec;
4355 l_qte_line_dtl_tbl ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type
4356 := ASO_Quote_Pub.g_miss_qte_line_dtl_tbl;
4357 l_hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type
4358 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL;
4359 l_tmp_hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type
4360 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL;
4361 l_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type
4362 := ASO_Quote_Pub.g_miss_shipment_TBL;
4363 l_tmp_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type
4364 := ASO_Quote_Pub.g_miss_shipment_TBL;
4365 l_Ln_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
4366 l_privilege_type_code varchar2(30);
4367 ld_last_update_date date;
4368 l_is_quote_usable VARCHAR2(1);
4369 -- l_control_rec ASO_Quote_Pub.Control_Rec_Type;
4370
4371 l_upd_stmnt VARCHAR2(200);
4372
4373 l_temp_qte_line_tbl ASO_Quote_Pub.Qte_Line_Tbl_Type
4374 := ASO_Quote_Pub.g_miss_qte_line_tbl;
4375
4376 l_match_found VARCHAR2(6) := FND_API.G_FALSE;
4377
4378 l_combinesameitem VARCHAR2(2) := FND_API.G_MISS_CHAR;
4379
4380 qte_id NUMBER; -- change line logic pricing Test
4381 prc_sts_ind VARCHAR2(1);
4382 tax_sts_ind VARCHAR2(1);
4383
4384 /*This cursor retrieves payment_term_id and price_list_id for a given agreement id
4385 this modification added to support bundles in iStore */
4386 cursor c_term_pricelist(p_agreement_id number) is
4387 select term_id, price_list_id
4388 from oe_agreements_b
4389 where agreement_id = p_agreement_id;
4390
4391 Cursor c_quote_sts_id(p_status_code varchar2) is
4392 select quote_status_id
4393 from aso_quote_statuses_vl
4394 where status_code = p_status_code;
4395
4396 cursor c_pricing_indicators(qte_header_id number) is -- change line logic pricing Test
4397 select quote_header_id, pricing_status_indicator, tax_status_indicator from
4398 aso_quote_headers_all where quote_header_id = qte_header_id;
4399
4400 rec_term_pricelist c_term_pricelist%rowtype;
4401 rec_quote_sts_id c_quote_sts_id%rowtype;
4402 loop_count number;
4403 lx_quote_expiration_date date;
4404
4405 BEGIN
4406 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4407 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.Save()');
4408 END IF;
4409
4410 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4411 IBE_UTIL.DEBUG('Before calling mo_global.init, input param=S');
4412 END IF;
4413 --mo_global.init('IBE'); -- bug 10113717
4414 mo_global.init('S'); -- bug 12775927
4415 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4416 IBE_UTIL.DEBUG('After calling mo_global.init)');
4417 END IF;
4418
4419 -- Standard Start of API savepoint
4420 SAVEPOINT SAVE_pvt;
4421 -- Standard call to check for call compatibility.
4422 IF NOT FND_API.Compatible_API_Call (l_api_version,
4423 P_Api_Version_Number,
4424 l_api_name,
4425 G_PKG_NAME )
4426 THEN
4427 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4428 END IF;
4429
4430 -- Initialize message list if p_init_msg_list is set to TRUE.
4431 IF FND_API.To_Boolean( p_init_msg_list ) THEN
4432 FND_Msg_Pub.initialize;
4433 END IF;
4434
4435 -- Initialize API return status to success
4436 x_return_status := FND_API.G_RET_STS_SUCCESS;
4437
4438 -- API body
4439
4440 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4441 IBE_UTIL.DEBUG('SAVE: Before Calling log_environment_info');
4442 END IF;
4443 IBE_Quote_Misc_pvt.log_environment_info();
4444
4445 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4446 IBE_UTIL.DEBUG('SAVE: After Calling log_environment_info');
4447 END IF;
4448
4449 --DBMS_OUTPUT.PUT_line('IBE_Quote_Save_pvt.SAVE into api ');
4450 --DBMS_OUTPUT.PUT_line('In save qte_hdr_id is '||p_Qte_Header_Rec.quote_header_id);
4451 -- USer Authentication
4452 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4453 IBE_UTIL.DEBUG('SAVE: Before Calling Validate User');
4454 END IF;
4455
4456 IF(p_save_type <> OP_DELETE_CART) THEN
4457 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4458 IBE_UTIL.DEBUG('SAVE: Calling Validate User');
4459 END IF;
4460 IBE_Quote_Misc_pvt.Validate_User_Update
4461 ( p_init_msg_list => p_Init_Msg_List
4462 ,p_quote_header_id => p_Qte_Header_Rec.quote_header_id
4463 ,p_party_id => p_Qte_Header_Rec.party_id
4464 ,p_cust_account_id => p_Qte_Header_Rec.cust_account_id
4465 ,p_quote_retrieval_number => p_sharee_Number
4466 ,p_validate_user => FND_API.G_TRUE
4467 ,p_save_type => p_save_type
4468 ,p_last_update_date => p_Qte_Header_Rec.last_update_date
4469 ,x_return_status => x_return_status
4470 ,x_msg_count => x_msg_count
4471 ,x_msg_data => x_msg_data );
4472
4473 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4474 -- so that we can get the quote last update date in the exception block
4475 l_qte_header_rec.quote_header_id := p_Qte_Header_Rec.quote_header_id;
4476 RAISE FND_API.G_EXC_ERROR;
4477 END IF;
4478
4479 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4480 -- so that we can get the quote last update date in the exception block
4481 l_qte_header_rec.quote_header_id := p_Qte_Header_Rec.quote_header_id;
4482 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4483 END IF;
4484 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4485 IBE_UTIL.DEBUG('SAVE: Validate User End');
4486 END IF;
4487 END IF;
4488 -- set default value for header
4489 --DBMS_OUTPUT.PUT_line('befoe default_hdr_rec ');
4490 --DBMS_OUTPUT.PUT_line('p_qte_header_rec.quote_header_id '||p_qte_header_rec.quote_header_id);
4491 --Verify if the incoming quote is usable or not
4492 /*In this case we perticularly ensure that quote identified by p_qte_header_rec.quote_header_id
4493 has not expired because we do not want to allow updates on expired carts*/
4494 l_is_quote_usable := IBE_QUOTE_MISC_PVT.is_quote_usable(p_qte_header_rec.quote_header_id,
4495 p_Qte_Header_Rec.party_id,
4496 p_Qte_Header_Rec.cust_account_id);
4497 --Raise an error f the above validation failed
4498 IF(l_is_quote_usable = FND_API.G_FALSE) THEN
4499 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4500 FND_Message.Set_Name('IBE', 'IBE_SC_CART_EXPIRED');
4501 FND_Msg_Pub.Add;
4502 END IF;
4503 RAISE FND_API.G_EXC_ERROR;
4504 END IF;
4505 Default_Header_Record( p_qte_header_rec => p_qte_header_rec
4506 ,p_auto_update_active_quote => p_auto_update_active_quote
4507 ,x_qte_header_rec => l_qte_header_rec
4508 ,p_hdr_Payment_Tbl => p_hd_payment_tbl
4509 ,x_hdr_payment_tbl => l_hd_Payment_Tbl
4510 ,x_return_status => x_return_status
4511 ,x_msg_count => x_msg_count
4512 ,x_msg_data => x_msg_data );
4513 --DBMS_OUTPUT.PUT_line('after default_hdr_rec ');
4514 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4515 RAISE FND_API.G_EXC_ERROR;
4516 END IF;
4517
4518 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4519 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4520 END IF;
4521
4522 -- set default value for line
4523 --DBMS_OUTPUT.PUT_line('before setlinedefaultval ');
4524
4525 IF (p_combinesameitem = FND_API.G_MISS_CHAR) THEN
4526 l_combinesameitem := FND_Profile.Value('IBE_SC_MERGE_SHOPCART_LINES');
4527 Else
4528 l_combinesameitem := p_combinesameitem;
4529 END IF;
4530 -- bug 6146600, scnagara
4531 /* Commented the below merge logic, because when multiple support items were added,
4532 and merge profile was on, the support lines were combined into one line, and hence
4533 corresponding records of support items in quote line detail table p_qte_line_dtl_tbl
4534 will have QTE_LINE_INDEX containing invalid index. And data would be corrupted.
4535 Merge logic is incorporated in setLineDefaultVal api.
4536 */
4537 /*
4538 IF( l_combinesameitem = 'Y') THEN
4539 FOR i in 1..p_qte_line_tbl.count LOOP
4540 l_match_found := FND_API.G_FALSE;
4541 FOR j in 1..l_temp_qte_line_tbl.count LOOP
4542 IF((p_qte_line_tbl(i).inventory_item_id = l_temp_qte_line_tbl(j).inventory_item_id)
4543 and (p_qte_line_tbl(i).quantity <> FND_API.G_MISS_NUM)) THEN
4544 l_temp_qte_line_tbl(j).quantity := l_temp_qte_line_tbl(j).quantity + p_qte_line_tbl(i).quantity;
4545 l_match_found := FND_API.G_TRUE;
4546 EXIT;
4547 END IF;
4548 END LOOP;
4549 IF( NOT FND_API.To_Boolean(l_match_found) ) THEN
4550 l_temp_qte_line_tbl(l_temp_qte_line_tbl.count + 1) := p_qte_line_tbl(i);
4551 END IF;
4552 END LOOP;
4553 ELSE
4554 FOR i in 1..p_qte_line_tbl.count LOOP
4555 l_temp_qte_line_tbl(i) := p_qte_line_tbl(i);
4556 END LOOP;
4557 END IF;
4558 */
4559 setLineDefaultVal(l_qte_header_rec.quote_header_id
4560 -- ,l_temp_qte_line_tbl -- bug 6146600, scnagara
4561 ,p_qte_line_tbl -- bug 6146600, scnagara
4562 ,p_qte_line_dtl_tbl
4563 ,p_combinesameitem
4564 ,l_qte_line_tbl
4565 ,l_qte_line_dtl_tbl);
4566 --DBMS_OUTPUT.PUT_line('afetr setlinedefaultval ');
4567 -- get access privilege only when sharee number is there.
4568 /*This code validates the recipient's access level against the minimum required access level for a create/update
4569 operation which is "F"*/
4570
4571 IF ( ( p_sharee_Number is not null)
4572 and ( p_sharee_Number <> FND_API.G_MISS_NUM)) THEN
4573
4574 l_privilege_type_code := IBE_Quote_Misc_pvt.GetShareeprivilege(l_qte_header_rec.quote_header_id
4575 ,p_sharee_Number);
4576 IF ((l_privilege_type_code <> 'A')
4577 and (l_privilege_type_code <> 'F' )) THEN
4578 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4579 FND_Message.Set_Name('IBE', 'IBE_SC_ERR_PRIVILEGE');
4580 FND_Msg_Pub.Add;
4581 END IF;
4582 RAISE FND_API.G_EXC_ERROR; -- need error message
4583 END IF;
4584
4585 IF ( l_privilege_type_code <> 'A'
4586 and FND_API.To_Boolean(p_changeowner) )THEN
4587 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4588 FND_Message.Set_Name('IBE', 'IBE_SC_ERR_PRIVILEGE');
4589 FND_Msg_Pub.Add;
4590 END IF;
4591 RAISE FND_API.G_EXC_ERROR; -- need error message
4592 END IF;
4593 END IF; -- p_sharee_number is not null
4594
4595 IF(l_qte_header_rec.quote_expiration_date = fnd_api.g_miss_date) then
4596 get_quote_expiration_date(
4597 p_api_version => 1.0 ,
4598 p_init_msg_list => FND_API.G_TRUE ,
4599 p_commit => FND_API.G_FALSE ,
4600 x_return_status => x_return_status ,
4601 x_msg_count => x_msg_count ,
4602 x_msg_data => x_msg_data ,
4603 p_quote_header_rec => l_qte_header_rec ,
4604 x_expiration_date => lx_quote_expiration_date);
4605 l_qte_header_rec.quote_expiration_date := lx_quote_expiration_date;
4606
4607 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
4608 RAISE FND_API.G_EXC_ERROR;
4609 END IF;
4610 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
4611 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4612 END IF;
4613 END IF;
4614
4615 --DBMS_OUTPUT.PUT_line('after get_quote_exp_date ');
4616 --DBMS_OUTPUT.PUT_line('checking for p_hd_shipment_tbl ');
4617 IF (p_hd_shipment_tbl.count >0) then
4618 l_hd_shipment_rec := p_hd_shipment_tbl(1);
4619 END IF;
4620 --DBMS_OUTPUT.PUT_line('done checking for p_hd_shipment_tbl ');
4621 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4622 IBE_UTIL.debug('Quote expiration date from get_quote_exp_date() is suppressed');
4623 END IF;
4624
4625 log_Control_Rec_Values(p_control_rec); -- change line logic pricing Test
4626
4627 IF l_qte_header_rec.quote_header_id IS NOT NULL
4628 OR l_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM THEN
4629 OPEN c_pricing_indicators(l_qte_header_rec.quote_header_id); -- change line logic pricing Test
4630 FETCH c_pricing_indicators INTO qte_id, prc_sts_ind, tax_sts_ind;
4631 CLOSE c_pricing_indicators;
4632
4633 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4634 IBE_Util.Debug('change line logic pricing Test BEGIN');
4635 IBE_Util.Debug('qte_id = ' || qte_id);
4636 IBE_Util.Debug('prc_sts_ind = ' || prc_sts_ind);
4637 IBE_Util.Debug('tax_sts_ind = ' || tax_sts_ind);
4638 IBE_Util.Debug('change line logic pricing Test END');
4639 END IF;
4640 END IF;
4641
4642 /* Start of CREATE QUOTE or UPDATE QUOTE conditions*/
4643 /* "Create quote" is invoked if there is no incoming quote_header_id and no quote header id found
4644 in the database for the operating user, otherwise "Update quote" is invoked*/
4645
4646 IF l_qte_header_rec.quote_header_id IS NULL
4647 OR l_qte_header_rec.quote_header_id = FND_API.G_MISS_NUM THEN
4648
4649 --Fix for bug 2512597
4650 -- Force the quote_status_id to be 'STORE DRAFT' if there is no input value
4651 IF l_qte_header_rec.quote_status_id is null OR
4652 l_qte_header_rec.quote_status_id = fnd_api.g_miss_num then
4653 for rec_quote_sts_id in c_quote_sts_id('STORE DRAFT') loop
4654 l_qte_header_rec.quote_status_id := rec_quote_sts_id.quote_status_id;
4655 exit when c_quote_sts_id%notfound;
4656 end loop;
4657 END IF;
4658
4659 --End of fix for bug 2512597
4660
4661 -- create quote
4662
4663 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4664 IBE_Util.Debug('ASO_Quote_Pub.Create_Quote() starts');
4665 END IF;
4666
4667 /*Mannamra: Fix for Bug 4661967: This fix is required to save the payment type during
4668 "AddToCart" defaulting work*/
4669
4670 FOR loop_count in 1..l_Hd_Payment_Tbl.count LOOP
4671 IF (l_Hd_Payment_Tbl(loop_count).payment_type_code = 'CREDIT_CARD' and
4672 l_Hd_Payment_Tbl(loop_count).instr_assignment_id is not null) THEN
4673 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4674 IBE_UTIL.debug('Save: Input payment table Payment type is cc and assignment id is not null');
4675 END IF;
4676 l_Hd_Payment_Tbl(loop_count).payment_ref_number := '';
4677 END IF;
4678 END LOOP;
4679
4680 -- clear ASO global structures Bug 8327573/8360172
4681 ASO_PRICING_INT.G_LINE_REC := NULL;
4682 ASO_PRICING_INT.G_HEADER_REC := NULL;
4683 l_Qte_Header_Rec.MINISITE_ID := p_minisite_id ;
4684
4685 -- change line logic pricing
4686 IF (p_control_rec.header_pricing_event = FND_Profile.Value('IBE_INCART_PRICING_EVENT') and p_control_rec.price_mode = 'CHANGE_LINE' ) THEN
4687 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4688 IBE_UTIL.debug('Its a create quote, pricing is turned on, change line pricing is on ');
4689 IBE_UTIL.debug('Setting pricing indicators to C');
4690 END IF;
4691 l_Qte_Header_Rec.pricing_status_indicator := 'C';
4692 l_Qte_Header_Rec.tax_status_indicator := 'C';
4693 END IF;
4694
4695 ASO_Quote_Pub.Create_Quote(
4696 P_Api_Version_Number => P_Api_Version_Number ,
4697 P_Init_Msg_List => FND_API.G_FALSE ,
4698 P_Commit => FND_API.G_FALSE ,
4699 P_Control_Rec => p_control_rec ,
4700 P_qte_header_rec => l_Qte_Header_Rec ,
4701 P_Qte_Line_Tbl => l_Qte_Line_Tbl ,
4702 p_Line_rltship_tbl => p_Line_rltship_tbl ,
4703 p_Qte_Line_Dtl_Tbl => l_Qte_Line_Dtl_Tbl ,
4704 p_Hd_Price_Attributes_Tbl => p_Hd_Price_Attributes_Tbl ,
4705 p_Hd_Payment_Tbl => l_Hd_Payment_Tbl ,
4706 p_Hd_Shipment_rec => l_Hd_Shipment_Rec ,
4707 p_Hd_Tax_Detail_Tbl => p_Hd_Tax_Detail_Tbl ,
4708 p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl ,
4709 p_Ln_Payment_Tbl => p_Ln_Payment_Tbl ,
4710 p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl ,
4711 p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl ,
4712 p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl ,
4713 p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl ,
4714 p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl ,
4715 p_Hd_Freight_Charge_Tbl => p_Hd_Freight_Charge_Tbl ,
4716 p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl ,
4717 x_qte_header_rec => x_Qte_Header_Rec ,
4718 X_Qte_Line_Tbl => x_Qte_Line_Tbl ,
4719 X_Qte_Line_Dtl_Tbl => x_Qte_Line_Dtl_Tbl ,
4720 X_Hd_Price_Attributes_Tbl => X_Hd_Price_Attributes_Tbl ,
4721 X_Hd_Payment_Tbl => x_Hd_Payment_Tbl ,
4722 X_Hd_Shipment_Rec => x_Hd_Shipment_Rec ,
4723 X_Hd_Freight_Charge_Tbl => x_Hd_Freight_Charge_Tbl ,
4724 X_Hd_Tax_Detail_Tbl => x_Hd_Tax_Detail_Tbl ,
4725 X_Line_Attr_Ext_Tbl => x_Line_Attr_Ext_Tbl ,
4726 X_Line_rltship_tbl => x_Line_Rltship_Tbl ,
4727 X_Price_Adjustment_Tbl => x_Price_Adjustment_Tbl ,
4728 X_Price_Adj_Attr_Tbl => X_Price_Adj_Attr_Tbl ,
4729 X_Price_Adj_Rltship_Tbl => x_Price_Adj_Rltship_Tbl ,
4730 X_Ln_Price_Attributes_Tbl => X_Ln_Price_Attributes_Tbl,
4731 X_Ln_Payment_Tbl => x_Ln_Payment_Tbl ,
4732 X_Ln_Shipment_Tbl => x_Ln_Shipment_Tbl ,
4733 X_Ln_Freight_Charge_Tbl => x_Ln_Freight_Charge_Tbl ,
4734 X_Ln_Tax_Detail_Tbl => x_Ln_Tax_Detail_Tbl ,
4735 X_Return_Status => x_return_status ,
4736 X_Msg_Count => x_msg_count ,
4737 X_Msg_Data => x_msg_data );
4738
4739 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4740 RAISE FND_API.G_EXC_ERROR;
4741 END IF;
4742
4743 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4744 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4745 END IF;
4746
4747 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4748 IBE_Util.Debug('ASO_Quote_Pub.Create_Quote() finishes');
4749 END IF;
4750
4751 OPEN c_pricing_indicators(x_Qte_header_rec.quote_header_id); -- change line logic pricing Test
4752 FETCH c_pricing_indicators INTO qte_id, prc_sts_ind, tax_sts_ind;
4753 CLOSE c_pricing_indicators;
4754
4755 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4756 IBE_Util.Debug('change line logic pricing Test BEGIN');
4757 IBE_Util.Debug('qte_id = ' || qte_id);
4758 IBE_Util.Debug('prc_sts_ind = ' || prc_sts_ind);
4759 IBE_Util.Debug('tax_sts_ind = ' || tax_sts_ind);
4760 IBE_Util.Debug('change line logic pricing Test END');
4761 END IF;
4762
4763 -- Dynamic SQL for updating the MinisiteId in ASO_QUOTE_HEADER
4764 BEGIN
4765 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4766 IBE_Util.Debug('In Update Header MinisiteId Dynamic SQL');
4767 END IF;
4768 IF (p_minisite_id <> FND_API.G_MISS_NUM) THEN
4769 l_upd_stmnt := 'Update ASO_QUOTE_HEADERS_ALL set minisite_id = :1
4770 where quote_header_id = :2';
4771 EXECUTE IMMEDIATE l_upd_stmnt using p_minisite_id,x_Qte_header_rec.quote_header_id;
4772 IF SQL%ROWCOUNT <> 1 THEN
4773 RAISE FND_API.G_EXC_ERROR;
4774 END IF;
4775 END IF;
4776 EXCEPTION
4777 When OTHERS THEN
4778 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4779 FND_MESSAGE.set_name('IBE', 'IBE_UPDATE_MSITE_HDR_ERR');
4780 FND_MSG_PUB.add;
4781 END IF;
4782 RAISE FND_API.G_EXC_ERROR;
4783 END;
4784
4785 --- make sure there is not multiple active cart exist before commit
4786 /*IF ((p_qte_header_rec.quote_source_code = 'IStore Account')
4787 AND ( p_qte_header_rec.quote_name = 'IBEACTIVECART'
4788 OR p_qte_header_rec.quote_name = FND_API.G_MISS_CHAR )) then
4789 IF x_qte_header_rec.quote_header_id <>
4790 IBE_Quote_Misc_pvt.Get_Active_Quote_ID
4791 (p_party_id => x_qte_header_rec.party_id
4792 ,p_cust_account_id => x_qte_header_rec.cust_account_id
4793 ,p_only_max => FALSE) then
4794 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4795 FND_Message.Set_Name('IBE', 'IBE_SC_QUOTE_NEED_REFRESH');
4796 FND_Msg_Pub.Add;
4797 END IF;
4798 RAISE FND_API.G_EXC_ERROR; -- need error message
4799 END IF;
4800 END IF;*/
4801
4802 --MANNAMRA:Changes for save/share project(09/16/02)
4803 /* Callng activate quote here to track the above created cart in IBE_ACTIVE_CARTS_ALL table*/
4804 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4805 IBE_UTIL.DEBUG('DO not call activate_quote if p_save_type is DUPLCIATE_CART,p_save_type='||p_save_type);
4806 END IF;
4807
4808 IF (p_save_type <> OP_DUPLICATE_CART) THEN
4809 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4810 IBE_UTIL.DEBUG('Calling IBE_QUOTE_SAVESHARE_V2_PVT.ACTIVATE_QUOTE');
4811 IBE_UTIL.DEBUG('x_Qte_header_rec.quote_header_id: '||x_Qte_header_rec.quote_header_id);
4812 END IF;
4813 IBE_QUOTE_SAVESHARE_V2_PVT.ACTIVATE_QUOTE (
4814 P_Quote_header_rec => x_Qte_header_rec,
4815 P_Party_id => l_Qte_header_rec.party_id ,
4816 P_Cust_account_id => l_Qte_header_rec.cust_account_id,
4817 p_api_version => 1,
4818 p_init_msg_list => FND_API.G_TRUE,
4819 p_commit => FND_API.G_FALSE,
4820 x_return_status => x_return_status,
4821 x_msg_count => x_msg_count,
4822 x_msg_data => x_msg_data);
4823
4824 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
4825 RAISE FND_API.G_EXC_ERROR;
4826 END IF;
4827
4828 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
4829 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4830 END IF;
4831 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4832 IBE_UTIL.DEBUG('Finished calling ACTIVATE_QUOTE ');
4833 END IF;
4834 END IF;--Checking of p_save_type
4835 --MANNAMRA:End of changes for save/share project(09/16/02)
4836 else
4837 -- update cart
4838 --Convert Quote Status code to Status id
4839 IF (l_qte_header_rec.quote_status_id is null OR
4840 l_qte_header_rec.quote_status_id = fnd_api.g_miss_num) and
4841 (l_qte_header_rec.quote_status_code is not null OR
4842 l_qte_header_rec.quote_status_id <> fnd_api.g_miss_num) then
4843 for rec_quote_sts_id in c_quote_sts_id(l_qte_header_rec.quote_status_code) loop
4844 l_qte_header_rec.quote_status_id := rec_quote_sts_id.quote_status_id;
4845 exit when c_quote_sts_id%notfound;
4846 end loop;
4847 END IF;
4848 l_count := 0;
4849 l_tmp_hd_payment_tbl := IBE_Quote_Misc_pvt.getHeaderPaymentTbl(l_qte_header_rec.quote_header_id);
4850 IF l_tmp_hd_payment_tbl.COUNT > 0 THEN
4851 FOR I IN 1..p_hd_payment_tbl.COUNT LOOP
4852 IF l_hd_payment_tbl(I).operation_code = 'CREATE' THEN
4853 l_count := l_count + 1;
4854 IF l_tmp_hd_payment_tbl.COUNT > 0 THEN
4855 l_hd_payment_tbl(I).operation_code := 'UPDATE'; -- Bug# 1955991
4856 l_hd_payment_tbl(I).payment_id := l_tmp_hd_payment_tbl(I).payment_id;
4857 /*
4858 l_hd_payment_tbl(I).last_update_date :=
4859 IBE_Quote_Misc_pvt.getQuoteLastUpdateDate(l_qte_header_rec.quote_header_id); -- Bug# 1955991
4860 */
4861 /* Bug#1955991
4862 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4863 FND_Message.Set_Name('IBE', 'IBE_QUOTE_HDR_PMT_RCRD_EXISTS');
4864 FND_Msg_Pub.Add;
4865 END IF;
4866 RAISE FND_API.G_EXC_ERROR;
4867 */
4868 END IF;
4869 END IF;
4870 END LOOP;
4871 /* Bug#1955991
4872 IF l_count > 1 THEN -- Trying to create more than one header payment
4873 IF FND_Msg_Pub.Check_Msg_Level (FND_Msg_Pub.G_MSG_LVL_ERROR) THEN
4874 FND_Message.Set_Name('IBE', 'IBE_QUOTE_HDR_PMT_RCRD_EXISTS');
4875 FND_Msg_Pub.Add;
4876 END IF;
4877 RAISE FND_API.G_EXC_ERROR;
4878 END IF;
4879 */
4880 /* Added by Sri 09/06 since the header last update date should be the value in the db */
4881 l_qte_header_rec.last_update_date :=
4882 IBE_Quote_Misc_pvt.getQuoteLastUpdateDate(l_qte_header_rec.quote_header_id); -- Bug# 1955991
4883 END IF;
4884 l_hd_shipment_tbl := p_hd_shipment_tbl;
4885 -- More Bug# 1955991
4886 l_tmp_hd_shipment_tbl := ASO_UTILITY_PVT.Query_Shipment_Rows(
4887 p_qte_header_id => l_qte_header_rec.quote_header_id,
4888 p_qte_line_id => null);
4889
4890 IF l_tmp_hd_shipment_tbl.COUNT > 0 THEN
4891 FOR I IN 1..l_hd_shipment_tbl.COUNT LOOP
4892 IF l_hd_shipment_tbl(I).operation_code = 'CREATE' THEN
4893 l_hd_shipment_tbl(I).operation_code := 'UPDATE';
4894 l_hd_shipment_tbl(I).shipment_id := l_tmp_hd_shipment_tbl(I).shipment_id;
4895 /*
4896 l_hd_shipment_tbl(I).last_update_date :=
4897 IBE_Quote_Misc_pvt.getQuoteLastUpdateDate(l_qte_header_rec.quote_header_id); -- Bug# 1955991
4898 */
4899 END IF;
4900 END LOOP;
4901 /* Added by Sri 09/06 since the header last update date should be the value in the db */
4902 l_qte_header_rec.last_update_date :=
4903 IBE_Quote_Misc_pvt.getQuoteLastUpdateDate(l_qte_header_rec.quote_header_id); -- Bug# 1955991
4904
4905 END IF;
4906 -- End Bug# 1955991
4907
4908 --l_pricebasedonowner := FND_Profile.Value('IBE_SC_PRICE_BASED_ON_OWNER');
4909 l_ln_payment_tbl := p_Ln_Payment_Tbl;
4910 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4911 Ibe_util.debug('Printing quote_line_tbl passedd to get_termid_pricelistid');
4912 END IF;
4913 for counter in 1..l_qte_line_tbl.count loop
4914 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4915 Ibe_util.debug('Input commitment id to get_termid_pracelistid is: '||l_qte_line_tbl(counter).commitment_id);
4916 Ibe_util.debug('Input agreement id to get_termid_pricelistid is: '||l_qte_line_tbl(counter).agreement_id);
4917 Ibe_util.debug('Pricelist id before calling get_termid_pricelistid is: '||l_qte_line_tbl(counter).price_list_id);
4918 END IF;
4919 end loop;
4920 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4921 Ibe_util.debug('values of payment table passed to get_termid_pricelisted');
4922 END IF;
4923 For counter in 1..l_ln_payment_tbl.count loop
4924 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4925 Ibe_util.debug('Payment_term_id is: '||l_ln_payment_tbl(counter).payment_term_id);
4926 END IF;
4927 end loop;
4928
4929 get_termid_pricelistid( p_qte_line_tbl => l_qte_line_tbl,
4930 p_ln_payment_tbl => l_ln_payment_tbl);
4931 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4932 Ibe_util.debug('Printing commitment_id obtained from get_termid_pricelistid');
4933 END IF;
4934 For counter in 1..l_qte_line_tbl.count loop
4935 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4936 Ibe_util.debug('commitment id obtained from get_termid_pracelistid is: '||l_qte_line_tbl(counter).commitment_id);
4937 Ibe_util.debug('commitment id obtained from get_termid_pracelistid is: '||l_qte_line_tbl(counter).agreement_id);
4938 Ibe_util.debug('Pricelist id obtained from get_termid_pricelistid is: '||l_qte_line_tbl(counter).price_list_id);
4939 END IF;
4940 END LOOP;
4941
4942 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4943 Ibe_util.debug('values of payment table obtained from get_termid_pricelisted');
4944 END IF;
4945 FOR counter in 1..l_ln_payment_tbl.count LOOP
4946 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4947 Ibe_util.debug('l_ln_payment_tbl.Quote_header_id: '||l_ln_payment_tbl(counter).quote_header_id);
4948 Ibe_util.debug('l_ln_payment_tbl.Quote_line_id: '||l_ln_payment_tbl(counter).quote_line_id);
4949 Ibe_util.debug('l_ln_payment_tbl.payment_term_id: '||l_ln_payment_tbl(counter).payment_term_id);
4950 Ibe_util.debug('l_ln_payment_tbl.operation_code: '||l_ln_payment_tbl(counter).operation_code);
4951 END IF;
4952 END LOOP;
4953 /*if (p_sharee_Number is not null
4954 and p_sharee_Number <> FND_API.G_MISS_NUM
4955 and (l_pricebasedonowner = 'N')) then
4956 -- get price based on owner profile
4957 UpdateQuoteForSharee(
4958 p_api_version_number => p_api_version_number
4959 ,p_init_msg_list => FND_API.G_FALSE
4960 ,p_commit => FND_API.G_FALSE
4961 ,p_sharee_party_id => p_sharee_party_id
4962 ,p_sharee_cust_account_id => p_sharee_cust_account_id
4963 ,p_control_rec => p_control_rec
4964 ,p_qte_header_rec => l_qte_header_rec
4965 ,p_Hd_Price_Attributes_Tbl => p_Hd_Price_Attributes_Tbl
4966 ,p_Hd_Payment_Tbl => l_Hd_Payment_Tbl
4967 ,p_Hd_Shipment_Tbl => l_Hd_Shipment_Tbl
4968 ,p_Hd_Tax_Detail_Tbl => p_Hd_Tax_Detail_Tbl
4969 ,p_Hd_Freight_Charge_Tbl => p_Hd_Freight_Charge_Tbl
4970 ,p_qte_line_tbl => l_qte_line_tbl
4971 ,p_Qte_Line_Dtl_Tbl => l_Qte_Line_Dtl_Tbl
4972 ,p_Line_rltship_tbl => p_Line_rltship_tbl
4973 ,p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl
4974 ,p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl
4975 ,p_Ln_Payment_Tbl => l_Ln_Payment_Tbl
4976 ,p_Ln_Shipment_Tbl => p_Ln_Shipment_Tbl
4977 ,p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl
4978 ,p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl
4979 ,p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl
4980 ,p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl
4981 ,p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl
4982 ,x_qte_header_rec => x_qte_header_rec
4983 ,x_qte_line_tbl => x_qte_line_tbl
4984 ,X_Return_Status => X_Return_Status
4985 ,X_Msg_Count => X_Msg_Count
4986 ,X_Msg_Data => X_Msg_Data);
4987
4988 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4989 RAISE FND_API.G_EXC_ERROR;
4990 END IF;
4991
4992 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4993 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4994 END IF;
4995 else -- no sharee*/
4996
4997 FOR counter in 1..p_Price_Adjustment_Tbl.count LOOP
4998 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4999 Ibe_util.debug('p_Price_Adjustment_Tbl.operation_code: '||p_Price_Adjustment_Tbl(counter).operation_code);
5000 Ibe_util.debug('p_Price_Adjustment_Tbl.PRICE_ADJUSTMENT_ID: '||p_Price_Adjustment_Tbl(counter).PRICE_ADJUSTMENT_ID);
5001 Ibe_util.debug('p_Price_Adjustment_Tbl.qte_line_index: '||p_Price_Adjustment_Tbl(counter).qte_line_index);
5002 Ibe_util.debug('p_Price_Adjustment_Tbl.quote_line_id: '||p_Price_Adjustment_Tbl(counter).quote_line_id);
5003 Ibe_util.debug('p_Price_Adjustment_Tbl.Quote_header_id: '||p_Price_Adjustment_Tbl(counter).quote_header_id);
5004 END IF;
5005 END LOOP;
5006 FOR counter in 1..p_Price_Adj_Rltship_Tbl.count LOOP
5007 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5008 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.operation_code: '||p_Price_Adj_Rltship_Tbl(counter).operation_code);
5009 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.ADJ_RELATIONSHIP_ID: '||p_Price_Adj_Rltship_Tbl(counter).ADJ_RELATIONSHIP_ID);
5010 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.RLTD_PRICE_ADJ_INDEX: '||p_Price_Adj_Rltship_Tbl(counter).RLTD_PRICE_ADJ_INDEX);
5011 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.PRICE_ADJ_INDEX: '||p_Price_Adj_Rltship_Tbl(counter).PRICE_ADJ_INDEX);
5012 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.QTE_LINE_INDEX: '||p_Price_Adj_Rltship_Tbl(counter).QTE_LINE_INDEX);
5013 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.RLTD_PRICE_ADJ_Id: '||p_Price_Adj_Rltship_Tbl(counter).RLTD_PRICE_ADJ_Id);
5014 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.PRICE_ADJUSTMENT_ID: '||p_Price_Adj_Rltship_Tbl(counter).PRICE_ADJUSTMENT_ID);
5015 Ibe_util.debug('p_Price_Adj_Rltship_Tbl.QUOTE_LINE_ID: '||p_Price_Adj_Rltship_Tbl(counter).QUOTE_LINE_ID);
5016 END IF;
5017 END LOOP;
5018
5019 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5020 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() starts');
5021 IBE_Util.Debug('Save : COUNT: just before aso update' || p_Ln_Price_Attributes_Tbl.count);
5022 END IF;
5023 --DBMS_OUTPUT.PUT_line('calling IBE_Quote_Save_pvt.SAVE.UPDATE_QUOTE ');
5024 --DBMS_OUTPUT.PUT_line('before update_quote: '||l_qte_header_rec.quote_name);
5025 --DBMS_OUTPUT.PUT_line('before update_quote: '||l_qte_header_rec.quote_header_id);
5026 --DBMS_OUTPUT.PUT_line('before update_quote: '||l_qte_header_rec.quote_status_id);
5027 --DBMS_OUTPUT.PUT_line('before update_quote: '||l_qte_header_rec.quote_expiration_date);
5028 --DBMS_OUTPUT.PUT_line('before update_quote: '||l_qte_header_rec.quote_source_code);
5029
5030 -- clear ASO global structures,bug 8327573/8360172
5031
5032 ASO_PRICING_INT.G_LINE_REC := NULL;
5033 ASO_PRICING_INT.G_HEADER_REC := NULL;
5034
5035 ASO_Quote_Pub.Update_quote(
5036 P_Api_Version_Number => P_Api_Version_Number
5037 ,P_Init_Msg_List => FND_API.G_FALSE
5038 ,P_Commit => FND_API.G_FALSE
5039 ,P_Control_Rec => p_control_rec
5040 ,P_qte_header_rec => l_Qte_Header_Rec
5041 ,P_Qte_Line_Tbl => l_Qte_Line_Tbl
5042 ,p_Line_rltship_tbl => p_Line_rltship_tbl
5043 ,p_Qte_Line_Dtl_Tbl => l_Qte_Line_Dtl_Tbl
5044 ,p_Hd_Price_Attributes_Tbl => p_Hd_Price_Attributes_Tbl
5045 ,p_Hd_Payment_Tbl => l_Hd_Payment_Tbl
5046 ,p_Hd_Shipment_Tbl => l_Hd_Shipment_Tbl
5047 ,p_Hd_Tax_Detail_Tbl => p_Hd_Tax_Detail_Tbl
5048 ,p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl
5049 ,p_Ln_Payment_Tbl => l_Ln_Payment_Tbl
5050 ,p_Ln_Shipment_Tbl => p_Ln_Shipment_Tbl
5051 ,p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl
5052 ,p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl
5053 ,p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl
5054 ,p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl
5055 ,p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl
5056 ,p_Hd_Freight_Charge_Tbl => p_Hd_Freight_Charge_Tbl
5057 ,p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl
5058 ,x_qte_header_rec => x_Qte_Header_Rec
5059 ,X_Qte_Line_Tbl => x_Qte_Line_Tbl
5060 ,X_Qte_Line_Dtl_Tbl => x_Qte_Line_Dtl_Tbl
5061 ,x_Hd_Price_Attributes_Tbl => X_Hd_Price_Attributes_Tbl
5062 ,X_Hd_Payment_Tbl => x_Hd_Payment_Tbl
5063 ,X_Hd_Shipment_Tbl => x_Hd_Shipment_Tbl
5064 ,X_Hd_Freight_Charge_Tbl => x_Hd_Freight_Charge_Tbl
5065 ,X_Hd_Tax_Detail_Tbl => x_Hd_Tax_Detail_Tbl
5066 ,x_Line_Attr_Ext_Tbl => x_Line_Attr_Ext_Tbl
5067 ,X_Line_rltship_tbl => x_Line_Rltship_Tbl
5068 ,X_Price_Adjustment_Tbl => x_Price_Adjustment_Tbl
5069 ,X_Price_Adj_Attr_Tbl => X_Price_Adj_Attr_Tbl
5070 ,X_Price_Adj_Rltship_Tbl => x_Price_Adj_Rltship_Tbl
5071 ,X_Ln_Price_Attributes_Tbl => X_Ln_Price_Attributes_Tbl
5072 ,X_Ln_Payment_Tbl => x_Ln_Payment_Tbl
5073 ,X_Ln_Shipment_Tbl => x_Ln_Shipment_Tbl
5074 ,X_Ln_Freight_Charge_Tbl => x_Ln_Freight_Charge_Tbl
5075 ,X_Ln_Tax_Detail_Tbl => x_Ln_Tax_Detail_Tbl
5076 ,X_Return_Status => x_return_status
5077 ,X_Msg_Count => x_msg_count
5078 ,X_Msg_Data => x_msg_data);
5079
5080 --DBMS_OUTPUT.PUT_line('FINISH IBE_Quote_Save_pvt.SAVE.UPDATE_QUOTE ');
5081 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5082 RAISE FND_API.G_EXC_ERROR;
5083 END IF;
5084
5085 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5086 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5087 END IF;
5088 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5089 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() finishes : '|| x_return_status);
5090 END IF;
5091
5092 OPEN c_pricing_indicators(x_Qte_header_rec.quote_header_id); -- change line logic pricing Test
5093 FETCH c_pricing_indicators INTO qte_id, prc_sts_ind, tax_sts_ind;
5094 CLOSE c_pricing_indicators;
5095
5096 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5097 IBE_Util.Debug('change line logic pricing Test BEGIN');
5098 IBE_Util.Debug('qte_id = ' || qte_id);
5099 IBE_Util.Debug('prc_sts_ind = ' || prc_sts_ind);
5100 IBE_Util.Debug('tax_sts_ind = ' || tax_sts_ind);
5101 IBE_Util.Debug('change line logic pricing Test END');
5102 END IF;
5103
5104 --DBMS_OUTPUT.PUT_line('after update_quote: '||x_qte_header_rec.quote_name);
5105 --DBMS_OUTPUT.PUT_line('after update_quote: '||x_qte_header_rec.quote_header_id);
5106 --DBMS_OUTPUT.PUT_line('after update_quote: '||x_qte_header_rec.quote_status_id);
5107 --DBMS_OUTPUT.PUT_line('after update_quote: '||x_qte_header_rec.quote_expiration_date);
5108 --DBMS_OUTPUT.PUT_line('after update_quote: '||x_qte_header_rec.quote_source_code);
5109 END IF; -- end of create/update
5110
5111 x_quote_header_id := x_qte_header_rec.quote_header_id;
5112 x_last_update_date := x_qte_header_rec.last_update_date;
5113
5114 -- End of API body.
5115 -- Standard check of p_commit.
5116 IF FND_API.To_Boolean( p_commit ) THEN
5117 COMMIT WORK;
5118 END IF;
5119
5120 -- Standard call to get message count and if count is 1, get message info.
5121 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5122 p_count => x_msg_count ,
5123 p_data => x_msg_data);
5124 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5125 IBE_Util.Debug('Normal End IBE_Quote_Save_pvt.Save()');
5126 END IF;
5127 -- IBE_Util.Disable_Debug;
5128 EXCEPTION
5129 WHEN FND_API.G_EXC_ERROR THEN
5130 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5131 IBE_Util.Debug('Expected error IBE_Quote_Save_pvt.Save()');
5132 END IF;
5133 ROLLBACK TO SAVE_pvt;
5134 x_return_status := FND_API.G_RET_STS_ERROR;
5135 Set_Last_Update_Date(l_qte_header_rec.quote_header_id, x_last_update_date);
5136 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5137 p_count => x_msg_count ,
5138 p_data => x_msg_data);
5139 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5140 IBE_Util.Debug('Unexpected error IBE_Quote_Save_pvt.Save()');
5141 END IF;
5142 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5143 ROLLBACK TO SAVE_pvt;
5144 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5145 Set_Last_Update_Date(l_qte_header_rec.quote_header_id, x_last_update_date);
5146 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5147 p_count => x_msg_count ,
5148 p_data => x_msg_data);
5149 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5150 IBE_Util.Debug('Unknown exception End IBE_Quote_Save_pvt.Save()');
5151 END IF;
5152 WHEN OTHERS THEN
5153 ROLLBACK TO SAVE_pvt;
5154 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5155 Set_Last_Update_Date(l_qte_header_rec.quote_header_id, x_last_update_date);
5156 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
5157 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
5158 l_api_name);
5159 END IF;
5160 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5161 p_count => x_msg_count ,
5162 p_data => x_msg_data);
5163 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5164 IBE_Util.Debug('End IBE_Quote_Save_pvt.Save()');
5165 END IF;
5166
5167 END Save;
5168
5169
5170 PROCEDURE UpdateQuoteForSharee(
5171 p_api_version_number IN NUMBER
5172 ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
5173 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
5174
5175 ,p_sharee_Party_Id IN NUMBER
5176 ,p_sharee_Cust_account_Id IN NUMBER
5177 ,p_changeowner IN VARCHAR2 := FND_API.G_FALSE
5178
5179 ,P_Control_Rec IN ASO_Quote_Pub.Control_Rec_Type
5180 ,P_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
5181 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
5182 ,p_Hd_Price_Attributes_Tbl in ASO_Quote_Pub.Price_Attributes_Tbl_Type
5183 := ASO_Quote_Pub.G_MISS_Price_Attributes_Tbl
5184 ,p_Hd_Payment_Tbl in ASO_Quote_Pub.Payment_Tbl_Type
5185 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
5186 ,p_Hd_Shipment_Tbl in ASO_Quote_Pub.Shipment_Tbl_Type
5187 := ASO_Quote_Pub.G_MISS_SHIPMENT_Tbl
5188 ,p_Hd_Tax_Detail_Tbl in ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE
5189 := ASO_Quote_Pub.G_MISS_Tax_Detail_Tbl
5190 ,p_Hd_Freight_Charge_Tbl in ASO_Quote_Pub.Freight_Charge_Tbl_Type
5191 := ASO_Quote_Pub.G_MISS_Freight_Charge_Tbl
5192
5193 ,p_qte_line_tbl in ASO_Quote_Pub.Qte_Line_Tbl_Type
5194 := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL
5195 ,p_Qte_Line_Dtl_Tbl in ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type
5196 := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL
5197 ,p_Line_rltship_tbl in ASO_Quote_Pub.Line_Rltship_Tbl_Type
5198 := ASO_Quote_Pub.G_MISS_Line_Rltship_Tbl
5199 ,p_Line_Attr_Ext_Tbl in ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type
5200 := ASO_Quote_Pub.G_MISS_Line_Attribs_Ext_Tbl
5201 ,p_Ln_Price_Attributes_Tbl in ASO_Quote_Pub.Price_Attributes_Tbl_Type
5202 := ASO_Quote_Pub.G_MISS_Price_Attributes_Tbl
5203 ,p_Ln_Payment_Tbl in ASO_Quote_Pub.Payment_Tbl_Type
5204 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
5205 ,p_Ln_Shipment_Tbl in ASO_Quote_Pub.Shipment_Tbl_Type
5206 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
5207 ,p_Ln_Tax_Detail_Tbl in ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE
5208 := ASO_Quote_Pub.G_MISS_Tax_Detail_Tbl
5209 ,p_Ln_Freight_Charge_Tbl in ASO_Quote_Pub.Freight_Charge_Tbl_Type
5210 := ASO_Quote_Pub.G_MISS_Freight_Charge_Tbl
5211 ,p_Price_Adj_Attr_Tbl in ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
5212 := ASO_Quote_Pub.G_MISS_PRICE_ADJ_ATTR_Tbl
5213 ,p_Price_Adjustment_Tbl in ASO_Quote_Pub.Price_Adj_Tbl_Type
5214 := ASO_Quote_Pub.G_MISS_Price_Adj_Tbl
5215 ,p_Price_Adj_Rltship_Tbl in ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
5216 := ASO_Quote_Pub.G_MISS_Price_Adj_Rltship_Tbl
5217
5218 ,x_qte_header_rec OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type
5219 ,x_qte_line_tbl OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type
5220 ,X_Return_Status OUT NOCOPY VARCHAR2
5221 ,X_Msg_Count OUT NOCOPY NUMBER
5222 ,X_Msg_Data OUT NOCOPY VARCHAR2
5223 )
5224 IS
5225 l_api_name CONSTANT VARCHAR2(30) := 'UpdateQuoteForSharee';
5226 l_api_version CONSTANT NUMBER := 1.0;
5227
5228 l_quote_party_id number;
5229 l_quote_Cust_account_id number;
5230
5231 l_qte_header_rec ASO_Quote_Pub.QTE_HEADER_REC_TYPE;
5232 l_control_Rec ASO_Quote_Pub.Control_Rec_Type;
5233
5234
5235
5236 lx_Hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
5237 lx_Hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
5238 lx_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type;
5239 lx_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
5240 lx_Hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
5241 lx_Hd_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
5242
5243
5244 lx_Qte_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_Dtl_Tbl_Type;
5245 lx_Line_Attr_Ext_Tbl ASO_Quote_Pub.Line_Attribs_Ext_Tbl_Type;
5246 lx_Line_rltship_tbl ASO_Quote_Pub.Line_Rltship_Tbl_Type;
5247
5248 lx_Ln_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
5249 lx_Ln_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
5250 lx_Ln_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
5251 lx_Ln_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
5252 lx_Ln_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
5253
5254 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
5255 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type;
5256 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
5257 BEGIN
5258 -- IBE_Util.Enable_Debug;
5259 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5260 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.UpdateQuoteForSharee()');
5261 END IF;
5262
5263 -- Standard Start of API savepoint
5264 SAVEPOINT UpdateQuoteForSharee_pvt;
5265 -- Standard call to check for call compatibility.
5266 IF NOT FND_API.Compatible_API_Call (l_api_version,
5267 P_Api_Version_Number,
5268 l_api_name,
5269 G_PKG_NAME )
5270 THEN
5271 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5272 END IF;
5273
5274 -- Initialize message list if p_init_msg_list is set to TRUE.
5275
5276 IF FND_API.To_Boolean( p_init_msg_list ) THEN
5277 FND_Msg_Pub.initialize;
5278 END IF;
5279 -- Initialize API return status to success
5280 x_return_status := FND_API.G_RET_STS_SUCCESS;
5281
5282 -- API body
5283
5284 IBE_Quote_Misc_pvt.getQuoteOwner(
5285 p_api_version_number => p_api_version_number
5286 ,p_quote_header_id => p_qte_header_rec.quote_header_id
5287 ,x_party_id => l_quote_Party_id
5288 ,x_cust_account_id => l_quote_Cust_account_id
5289 ,X_Return_Status => x_return_status
5290 ,X_Msg_Count => x_msg_count
5291 ,X_Msg_Data => x_msg_data);
5292
5293 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5294 RAISE FND_API.G_EXC_ERROR;
5295 END IF;
5296
5297 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5298 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5299 END IF;
5300
5301 l_qte_header_rec := p_qte_header_rec;
5302 l_qte_header_rec.party_id := p_sharee_Party_id;
5303 l_qte_header_rec.cust_account_id := p_sharee_Cust_account_id;
5304
5305 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5306 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() starts');
5307 END IF;
5308
5309 ASO_Quote_Pub.Update_Quote(
5310 P_Api_Version_Number => P_Api_Version_Number
5311 ,P_Init_Msg_List => FND_API.G_FALSE
5312 ,P_Commit => FND_API.G_FALSE
5313 ,P_Control_Rec => p_control_rec
5314 ,P_qte_header_rec => l_Qte_Header_Rec
5315 ,P_Qte_Line_Tbl => p_Qte_Line_Tbl
5316 ,p_Line_rltship_tbl => p_Line_rltship_tbl
5317 ,p_Qte_Line_Dtl_Tbl => p_Qte_Line_Dtl_Tbl
5318 ,p_Hd_Price_Attributes_Tbl => p_Hd_Price_Attributes_Tbl
5319 ,p_Hd_Payment_Tbl => p_Hd_Payment_Tbl
5320 ,p_Hd_Shipment_Tbl => p_Hd_Shipment_Tbl
5321 ,p_Hd_Tax_Detail_Tbl => p_Hd_Tax_Detail_Tbl
5322 ,p_Ln_Price_Attributes_Tbl => p_Ln_Price_Attributes_Tbl
5323 ,p_Ln_Payment_Tbl => p_Ln_Payment_Tbl
5324 ,p_Ln_Shipment_Tbl => p_Ln_Shipment_Tbl
5325 ,p_Ln_Tax_Detail_Tbl => p_Ln_Tax_Detail_Tbl
5326 ,p_Price_Adj_Attr_Tbl => p_Price_Adj_Attr_Tbl
5327 ,p_Price_Adjustment_Tbl => p_Price_Adjustment_Tbl
5328 ,p_Price_Adj_Rltship_Tbl => p_Price_Adj_Rltship_Tbl
5329 ,p_Line_Attr_Ext_Tbl => p_Line_Attr_Ext_Tbl
5330 ,p_Hd_Freight_Charge_Tbl => p_Hd_Freight_Charge_Tbl
5331 ,p_Ln_Freight_Charge_Tbl => p_Ln_Freight_Charge_Tbl
5332
5333 ,x_qte_header_rec => x_Qte_Header_Rec
5334 ,X_Qte_Line_Tbl => x_Qte_Line_Tbl
5335 ,X_Qte_Line_Dtl_Tbl => lx_Qte_Line_Dtl_Tbl
5336 ,x_Hd_Price_Attributes_Tbl => lX_Hd_Price_Attributes_Tbl
5337 ,X_Hd_Payment_Tbl => lx_Hd_Payment_Tbl
5338 ,X_Hd_Shipment_Tbl => lx_Hd_Shipment_Tbl
5339 ,X_Hd_Freight_Charge_Tbl => lx_Hd_Freight_Charge_Tbl
5340 ,X_Hd_Tax_Detail_Tbl => lx_Hd_Tax_Detail_Tbl
5341 ,x_Line_Attr_Ext_Tbl => lx_Line_Attr_Ext_Tbl
5342 ,X_Line_rltship_tbl => lx_Line_Rltship_Tbl
5343 ,X_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
5344 ,X_Price_Adj_Attr_Tbl => lX_Price_Adj_Attr_Tbl
5345 ,X_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
5346 ,X_Ln_Price_Attributes_Tbl => lX_Ln_Price_Attributes_Tbl
5347 ,X_Ln_Payment_Tbl => lx_Ln_Payment_Tbl
5348 ,X_Ln_Shipment_Tbl => lx_Ln_Shipment_Tbl
5349 ,X_Ln_Freight_Charge_Tbl => lx_Ln_Freight_Charge_Tbl
5350 ,X_Ln_Tax_Detail_Tbl => lx_Ln_Tax_Detail_Tbl
5351 ,X_Return_Status => x_return_status
5352 ,X_Msg_Count => x_msg_count
5353 ,X_Msg_Data => x_msg_data);
5354
5355 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5356 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() finishes');
5357 END IF;
5358
5359 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5360 RAISE FND_API.G_EXC_ERROR;
5361 END IF;
5362
5363 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5364 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5365 END IF;
5366
5367 -- #2: set control_rec to NOT recalculate the price
5368 -- and set the owner back
5369
5370 if ( not fnd_api.To_Boolean(p_changeowner)) then
5371 l_qte_header_rec := p_qte_header_rec;
5372 l_qte_header_rec.last_update_date :=x_qte_header_rec.last_update_date;
5373
5374 l_qte_header_rec.party_id := l_Quote_Party_id;
5375 l_qte_header_rec.cust_account_id := l_Quote_Cust_account_id;
5376
5377 l_control_rec := ASO_Quote_Pub.G_MISS_Control_Rec;
5378
5379 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5380 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() starts');
5381 END IF;
5382
5383 ASO_Quote_Pub.Update_quote(
5384 P_Api_Version_Number => P_Api_Version_Number
5385 ,P_Init_Msg_List => FND_API.G_FALSE
5386 ,P_Commit => FND_API.G_FALSE
5387 ,P_qte_header_rec => l_Qte_Header_Rec
5388 ,x_qte_header_rec => x_Qte_Header_Rec
5389 ,X_Qte_Line_Tbl => x_Qte_Line_Tbl
5390 ,X_Qte_Line_Dtl_Tbl => lx_Qte_Line_Dtl_Tbl
5391 ,x_Hd_Price_Attributes_Tbl => lX_Hd_Price_Attributes_Tbl
5392 ,X_Hd_Payment_Tbl => lx_Hd_Payment_Tbl
5393 ,X_Hd_Shipment_Tbl => lx_Hd_Shipment_Tbl
5394 ,X_Hd_Freight_Charge_Tbl => lx_Hd_Freight_Charge_Tbl
5395 ,X_Hd_Tax_Detail_Tbl => lx_Hd_Tax_Detail_Tbl
5396 ,x_Line_Attr_Ext_Tbl => lx_Line_Attr_Ext_Tbl
5397 ,X_Line_rltship_tbl => lx_Line_Rltship_Tbl
5398 ,X_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
5399 ,X_Price_Adj_Attr_Tbl => lX_Price_Adj_Attr_Tbl
5400 ,X_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
5401 ,X_Ln_Price_Attributes_Tbl => lX_Ln_Price_Attributes_Tbl
5402 ,X_Ln_Payment_Tbl => lx_Ln_Payment_Tbl
5403 ,X_Ln_Shipment_Tbl => lx_Ln_Shipment_Tbl
5404 ,X_Ln_Freight_Charge_Tbl => lx_Ln_Freight_Charge_Tbl
5405 ,X_Ln_Tax_Detail_Tbl => lx_Ln_Tax_Detail_Tbl
5406 ,X_Return_Status => x_return_status
5407 ,X_Msg_Count => x_msg_count
5408 ,X_Msg_Data => x_msg_data);
5409
5410 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5411 IBE_Util.Debug('ASO_Quote_Pub.Update_Quote() finishes');
5412 END IF;
5413 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5414 RAISE FND_API.G_EXC_ERROR;
5415 END IF;
5416
5417 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5418 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5419 END IF;
5420 END IF;
5421
5422 -- End of API body.
5423 -- Standard check of p_commit.
5424 IF FND_API.To_Boolean( p_commit ) THEN
5425 COMMIT WORK;
5426 END IF;
5427
5428 -- Standard call to get message count and if count is 1, get message info.
5429 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5430 p_count => x_msg_count ,
5431 p_data => x_msg_data);
5432 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5433 IBE_Util.Debug('End IBE_Quote_Save_pvt.UpdateQuoteForSharee()');
5434 END IF;
5435 -- IBE_Util.Disable_Debug;
5436 EXCEPTION
5437 WHEN FND_API.G_EXC_ERROR THEN
5438 ROLLBACK TO UpdateQuoteForSharee_pvt;
5439 x_return_status := FND_API.G_RET_STS_ERROR;
5440 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5441 p_count => x_msg_count ,
5442 p_data => x_msg_data);
5443 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5444 IBE_Util.Debug('End IBE_Quote_Save_pvt.UpdateQuoteForSharee()');
5445 END IF;
5446 -- IBE_Util.Disable_Debug;
5447 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5448 ROLLBACK TO UpdateQuoteForSharee_pvt;
5449 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5450 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5451 p_count => x_msg_count ,
5452 p_data => x_msg_data);
5453 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5454 IBE_Util.Debug('End IBE_Quote_Save_pvt.UpdateQuoteForSharee()');
5455 END IF;
5456 -- IBE_Util.Disable_Debug;
5457 WHEN OTHERS THEN
5458 ROLLBACK TO UpdateQuoteForSharee_pvt;
5459 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5460
5461 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
5462 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
5463 l_api_name);
5464 END IF;
5465
5466 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5467 p_count => x_msg_count ,
5468 p_data => x_msg_data);
5469 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5470 IBE_Util.Debug('End IBE_Quote_Save_pvt.UpdateQuoteForSharee()');
5471 END IF;
5472 -- IBE_Util.Disable_Debug;
5473 END UpdateQuoteForSharee;
5474
5475
5476 /* ------------------------------ Default API's: Start -----------------*/
5477
5478 PROCEDURE getHdrDefaultValues(
5479 P_Api_Version_Number IN NUMBER
5480 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
5481 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
5482
5483 ,p_minisite_id IN NUMBER
5484
5485 ,p_Qte_Header_Rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
5486 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec
5487 ,p_hd_Price_Attributes_Tbl IN ASO_Quote_Pub.Price_Attributes_Tbl_Type
5488 := ASO_Quote_Pub.G_Miss_Price_Attributes_Tbl
5489 ,p_hd_Payment_Tbl IN ASO_Quote_Pub.Payment_Tbl_Type
5490 := ASO_Quote_Pub.G_MISS_PAYMENT_TBL
5491 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
5492 := ASO_Quote_Pub.G_MISS_SHIPMENT_TBL
5493 ,p_hd_Freight_Charge_Tbl IN ASO_Quote_Pub.Freight_Charge_Tbl_Type
5494 := ASO_Quote_Pub.G_Miss_Freight_Charge_Tbl
5495 ,p_hd_Tax_Detail_Tbl IN ASO_Quote_Pub.Tax_Detail_Tbl_Type
5496 := ASO_Quote_Pub.G_Miss_Tax_Detail_Tbl
5497 ,p_Price_Adjustment_Tbl IN ASO_Quote_Pub.Price_Adj_Tbl_Type
5498 := ASO_Quote_Pub.G_Miss_Price_Adj_Tbl
5499 ,p_Price_Adj_Attr_Tbl IN ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
5500 := ASO_Quote_Pub.G_Miss_PRICE_ADJ_ATTR_Tbl
5501 ,p_Price_Adj_Rltship_Tbl IN ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
5502 := ASO_Quote_Pub.G_Miss_Price_Adj_Rltship_Tbl
5503
5504 ,x_Qte_Header_Rec OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type
5505 ,x_hd_Price_Attributes_Tbl OUT NOCOPY ASO_Quote_Pub.Price_Attributes_Tbl_Type
5506 ,x_hd_Payment_Tbl OUT NOCOPY ASO_Quote_Pub.Payment_Tbl_Type
5507 ,x_hd_Shipment_TBL OUT NOCOPY ASO_Quote_Pub.Shipment_tbl_Type
5508 ,x_hd_Freight_Charge_Tbl OUT NOCOPY ASO_Quote_Pub.Freight_Charge_Tbl_Type
5509 ,x_hd_Tax_Detail_Tbl OUT NOCOPY ASO_Quote_Pub.Tax_Detail_Tbl_Type
5510 ,x_Price_Adjustment_Tbl OUT NOCOPY ASO_Quote_Pub.Price_Adj_Tbl_Type
5511 ,x_Price_Adj_Attr_Tbl OUT NOCOPY ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type
5512 ,x_Price_Adj_Rltship_Tbl OUT NOCOPY ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type
5513
5514 ,x_last_update_date OUT NOCOPY DATE
5515 ,X_Return_Status OUT NOCOPY VARCHAR2
5516 ,X_Msg_Count OUT NOCOPY NUMBER
5517 ,X_Msg_Data OUT NOCOPY VARCHAR2
5518 )
5519
5520 IS
5521
5522 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultValues';
5523 l_api_version CONSTANT NUMBER := 1.0;
5524
5525 lx_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type;
5526 lx_Hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
5527 lx_Hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
5528
5529 lx_Hd_Shipment_Tbl ASO_Quote_Pub.Shipment_Tbl_Type;
5530 lx_Hd_Shipment_Rec ASO_Quote_Pub.Shipment_Rec_Type;
5531 lx_Hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type ;
5532 lx_Hd_Tax_Detail_Tbl ASO_Quote_Pub.TAX_DETAIL_TBL_TYPE;
5533
5534 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
5535 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type;
5536 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
5537
5538 l_userType VARCHAR2(10);
5539 l_cvv2_setup VARCHAR2(1);
5540 l_statement_address_setup VARCHAR2(1);
5541 BEGIN
5542
5543 -- Standard Start of API savepoint
5544 SAVEPOINT getHdrDefaultValues_PVT;
5545
5546 -- Standard call to check for call compatibility.
5547 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
5548 P_Api_Version_Number,
5549 L_API_NAME ,
5550 G_PKG_NAME )
5551 THEN
5552 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5553 END IF;
5554
5555 -- Initialize message list if p_init_msg_list is set to TRUE.
5556 IF FND_API.To_Boolean(p_init_msg_list) THEN
5557 FND_Msg_Pub.initialize;
5558 END IF;
5559
5560 -- Initialize API return status to success
5561 x_return_status := FND_API.G_RET_STS_SUCCESS;
5562
5563 -- API body
5564
5565 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5566 IBE_Util.Debug('Start IBE_Quote_Save_pvt.getHdrDefaultValues()');
5567 IBE_Util.Debug('APPLE1:'||p_Qte_Header_Rec.party_id);
5568 -- IBE_Util.Debug('APPLE1:'||p_Qte_Header_Rec.cust_acct_id);
5569 IBE_Util.Debug('APPLE1:'||p_Qte_Header_Rec.quote_header_id);
5570 END IF;
5571
5572 -- We will call the various helper api's to get default values
5573 -- #* First we have to make sure we pass and get the right parameters
5574 lx_hd_Shipment_TBL := p_hd_Shipment_TBL;
5575 lx_qte_header_rec := p_qte_header_rec;
5576 lx_hd_Payment_Tbl := p_hd_Payment_Tbl;
5577 lx_hd_Tax_Detail_Tbl := p_hd_Tax_Detail_Tbl;
5578
5579 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5580 IBE_Util.Debug('APPLE2:'||lx_qte_header_rec.party_id);
5581 -- IBE_Util.Debug('APPLE2:'||lx_qte_header_rec.cust_acct_id);
5582 IBE_Util.Debug('APPLE2:'||lx_qte_header_rec.quote_header_id);
5583 END IF;
5584
5585 -- #1 Shipping Info
5586 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5587 IBE_Util.Debug('getHdrDefaultAddress() -- SHIPTO starts');
5588 END IF;
5589 getHdrDefaultAddress (
5590 P_Api_Version_Number => P_Api_Version_Number
5591 ,p_Init_Msg_List => p_Init_Msg_List
5592 ,p_Commit => p_Commit
5593 ,px_hd_Shipment_TBL => lx_hd_Shipment_TBL
5594 ,px_qte_header_rec => lx_qte_header_rec
5595 ,p_party_site_use => 'S'
5596 ,X_Return_Status => X_Return_Status
5597 ,X_Msg_Count => X_Msg_Count
5598 ,X_Msg_Data => X_Msg_Data
5599 );
5600 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5601 IBE_Util.Debug('getHdrDefaultAddress() -- SHIPTO finishes');
5602 END IF;
5603 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5604 RAISE FND_API.G_EXC_ERROR;
5605 END IF;
5606 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5607 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5608 END IF;
5609
5610 if (lx_hd_shipment_tbl.count <> 0) then
5611 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5612 IBE_Util.Debug('lx_hd_shipment_tbl.ship_to_party_site_id: '||lx_hd_shipment_tbl(1).ship_to_party_site_id);
5613 END IF;
5614 --dbms_output.put_line('lx_hd_shipment_tbl.ship_to_party_site_id: '||lx_hd_shipment_tbl(1).ship_to_party_site_id);
5615 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5616 IBE_Util.Debug('lx_hd_shipment_tbl.shipment_id: '||lx_hd_shipment_tbl(1).shipment_id);
5617 END IF;
5618 --dbms_output.put_line('lx_hd_shipment_tbl.shipment_id: '||lx_hd_shipment_tbl(1).shipment_id);
5619 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5620 IBE_Util.Debug('lx_hd_shipment_tbl.quote_header_id: '||lx_hd_shipment_tbl(1).quote_header_id);
5621 END IF;
5622 --dbms_output.put_line('lx_hd_shipment_tbl.quote_header_id: '||lx_hd_shipment_tbl(1).quote_header_id);
5623 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5624 IBE_Util.Debug('lx_hd_shipment_tbl.operation_code: '||lx_hd_shipment_tbl(1).operation_code);
5625 END IF;
5626 --dbms_output.put_line('lx_hd_shipment_tbl.operation_code: '||lx_hd_shipment_tbl(1).operation_code);
5627
5628 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5629 IBE_Util.Debug('*******************************');
5630 END IF;
5631 --dbms_output.put_line('*******************************');
5632
5633 -- 9/11/02: we only call this api if we were able to find the shipTo address because if we can't find
5634 -- this info, we can't default the contact
5635 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5636 IBE_Util.Debug('getHdrDefaultShipMethod() starts');
5637 END IF;
5638 getHdrDefaultShipMethod (
5639 P_Api_Version_Number => P_Api_Version_Number
5640 ,p_Init_Msg_List => p_Init_Msg_List
5641 ,p_Commit => p_Commit
5642 ,px_hd_Shipment_TBL => lx_hd_Shipment_TBL
5643 ,p_qte_header_rec => lx_qte_header_rec
5644 ,p_minisite_id => p_minisite_id
5645 ,X_Return_Status => X_Return_Status
5646 ,X_Msg_Count => X_Msg_Count
5647 ,X_Msg_Data => X_Msg_Data
5648 );
5649 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5650 IBE_Util.Debug('getHdrDefaultShipMethod() finishes');
5651 END IF;
5652 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5653 RAISE FND_API.G_EXC_ERROR;
5654 END IF;
5655 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5656 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5657 END IF;
5658
5659 if (lx_hd_Shipment_Tbl.count <> 0) then
5660 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5661 IBE_Util.Debug('lx_hd_Shipment_Tbl.shipment_id: '||lx_hd_Shipment_Tbl(1).shipment_id);
5662 END IF;
5663 --dbms_output.put_line('lx_hd_Shipment_Tbl.shipment_id: '||lx_hd_Shipment_Tbl(1).shipment_id);
5664 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5665 IBE_Util.Debug('lx_hd_Shipment_Tbl.quote_header_id: '||lx_hd_Shipment_Tbl(1).quote_header_id);
5666 END IF;
5667 --dbms_output.put_line('lx_hd_Shipment_Tbl.quote_header_id: '||lx_hd_Shipment_Tbl(1).quote_header_id);
5668 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5669 IBE_Util.Debug('lx_hd_Shipment_Tbl.operation_code: '||lx_hd_Shipment_Tbl(1).operation_code);
5670 END IF;
5671 --dbms_output.put_line('lx_hd_Shipment_Tbl.operation_code: '||lx_hd_Shipment_Tbl(1).operation_code);
5672 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5673 IBE_Util.Debug('lx_hd_Shipment_Tbl.SHIP_METHOD_CODE: '||lx_hd_Shipment_Tbl(1).SHIP_METHOD_CODE);
5674 END IF;
5675 --dbms_output.put_line('lx_hd_Shipment_Tbl.SHIP_METHOD_CODE: '||lx_hd_Shipment_Tbl(1).SHIP_METHOD_CODE);
5676
5677 end if;
5678 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5679 IBE_Util.Debug('*******************************');
5680 END IF;
5681 --dbms_output.put_line('*******************************');
5682 end if; -- if there is shipTo address
5683
5684 -- #2 Billing Info
5685 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5686 IBE_Util.Debug('getHdrDefaultAddress() -- BILLTO starts');
5687 IBE_Util.Debug('STAR 123 getHdrDefaultAddress()' || lx_qte_header_rec.party_id);
5688 END IF;
5689 getHdrDefaultAddress (
5690 P_Api_Version_Number => P_Api_Version_Number
5691 ,p_Init_Msg_List => p_Init_Msg_List
5692 ,p_Commit => p_Commit
5693 ,px_hd_Shipment_TBL => lx_hd_Shipment_TBL
5694 ,px_qte_header_rec => lx_qte_header_rec
5695 ,p_party_site_use => 'B'
5696 ,X_Return_Status => X_Return_Status
5697 ,X_Msg_Count => X_Msg_Count
5698 ,X_Msg_Data => X_Msg_Data
5699 );
5700 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5701 IBE_Util.Debug('getHdrDefaultAddress() -- BILLTO finishes');
5702 END IF;
5703 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5704 RAISE FND_API.G_EXC_ERROR;
5705 END IF;
5706 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5707 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5708 END IF;
5709
5710 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5711 IBE_Util.Debug('lx_qte_header_rec.INVOICE_TO_PARTY_SITE_ID: '||to_char(lx_qte_header_rec.INVOICE_TO_PARTY_SITE_ID));
5712 END IF;
5713 --dbms_output.put_line('lx_qte_header_rec.INVOICE_TO_PARTY_SITE_ID: '||to_char(lx_qte_header_rec.INVOICE_TO_PARTY_SITE_ID));
5714 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5715 IBE_Util.Debug('*******************************');
5716 END IF;
5717 --dbms_output.put_line('*******************************');
5718
5719 IBE_PAYMENT_INT_PVT.check_Payment_channel_setups
5720 (p_api_version => 1.0
5721 ,p_init_msg_list => FND_API.G_FALSE
5722 ,p_commit => FND_API.G_FALSE
5723 ,x_cvv2_setup => l_cvv2_setup
5724 ,x_statement_address_setup => l_statement_address_setup
5725 ,x_return_status => X_Return_Status
5726 ,x_msg_count => x_msg_count
5727 ,x_msg_data => x_msg_data );
5728 /*mannamra: Credit card consolidation: payment type defaulting should not kick in only when CVV2
5729 is mandatory so that user will be able to visit the
5730 billing page to provide the credit card cvv2 number*/
5731 IF(l_cvv2_setup <> FND_API.G_TRUE) THEN
5732
5733
5734 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5735 IBE_Util.Debug('getHdrDefaultPaymentMethod() starts');
5736 END IF;
5737 getHdrDefaultPaymentMethod (
5738 P_Api_Version_Number => P_Api_Version_Number
5739 ,p_Init_Msg_List => p_Init_Msg_List
5740 ,p_Commit => p_Commit
5741 ,px_hd_Payment_Tbl => lx_hd_Payment_Tbl
5742 ,p_qte_header_rec => lx_qte_header_rec
5743 ,p_minisite_id => p_minisite_id
5744 ,X_Return_Status => X_Return_Status
5745 ,X_Msg_Count => X_Msg_Count
5746 ,X_Msg_Data => X_Msg_Data
5747 );
5748 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5749 IBE_Util.Debug('getHdrDefaultPaymentMethod() finishes');
5750 END IF;
5751 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5752 RAISE FND_API.G_EXC_ERROR;
5753 END IF;
5754 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5755 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5756 END IF;
5757
5758 if (lx_hd_Payment_Tbl.count <> 0) then
5759 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5760 IBE_Util.Debug('lx_hd_Payment_Tbl.payment_id: '||lx_hd_Payment_Tbl(1).payment_id);
5761 END IF;
5762 --dbms_output.put_line('lx_hd_Payment_Tbl.payment_id: '||lx_hd_Payment_Tbl(1).payment_id);
5763 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5764 IBE_Util.Debug('lx_hd_Payment_Tbl.quote_header_id: '||lx_hd_Payment_Tbl(1).quote_header_id);
5765 END IF;
5766 --dbms_output.put_line('lx_hd_Payment_Tbl.quote_header_id: '||lx_hd_Payment_Tbl(1).quote_header_id);
5767 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5768 IBE_Util.Debug('lx_hd_Payment_Tbl.operation_code: '||lx_hd_Payment_Tbl(1).operation_code);
5769 END IF;
5770 --dbms_output.put_line('lx_hd_Payment_Tbl.operation_code: '||lx_hd_Payment_Tbl(1).operation_code);
5771 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5772 IBE_Util.Debug('lx_hd_Payment_Tbl.PAYMENT_TYPE_CODE: '||lx_hd_Payment_Tbl(1).PAYMENT_TYPE_CODE);
5773 END IF;
5774 --dbms_output.put_line('lx_hd_Payment_Tbl.PAYMENT_TYPE_CODE: '||lx_hd_Payment_Tbl(1).PAYMENT_TYPE_CODE);
5775
5776 --IBE_Util.Debug('lx_hd_Payment_Tbl.PAYMENT_REF_NUMBER: '||lx_hd_Payment_Tbl(1).PAYMENT_REF_NUMBER);
5777 --dbms_output.put_line('lx_hd_Payment_Tbl.PAYMENT_REF_NUMBER: '||lx_hd_Payment_Tbl(1).PAYMENT_REF_NUMBER);
5778 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5779 IBE_Util.Debug('lx_hd_Payment_Tbl.PAYMENT_TERM_ID: '||lx_hd_Payment_Tbl(1).PAYMENT_TERM_ID);
5780 END IF;
5781 --dbms_output.put_line('lx_hd_Payment_Tbl.PAYMENT_TERM_ID: '||lx_hd_Payment_Tbl(1).PAYMENT_TERM_ID);
5782 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5783 IBE_Util.Debug('lx_hd_Payment_Tbl.CREDIT_CARD_CODE: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_CODE);
5784 END IF;
5785 --dbms_output.put_line('lx_hd_Payment_Tbl.CREDIT_CARD_CODE: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_CODE);
5786 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5787 IBE_Util.Debug('lx_hd_Payment_Tbl.CREDIT_CARD_HOLDER_NAME: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_HOLDER_NAME);
5788 END IF;
5789 --dbms_output.put_line('lx_hd_Payment_Tbl.CREDIT_CARD_HOLDER_NAME: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_HOLDER_NAME);
5790 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5791 IBE_Util.Debug('lx_hd_Payment_Tbl.CREDIT_CARD_EXPIRATION_DATE: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_EXPIRATION_DATE);
5792 END IF;
5793 --dbms_output.put_line('lx_hd_Payment_Tbl.CREDIT_CARD_EXPIRATION_DATE: '||lx_hd_Payment_Tbl(1).CREDIT_CARD_EXPIRATION_DATE);
5794 end if;
5795 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5796 IBE_Util.Debug('*******************************');
5797 END IF;
5798 END IF; --l_cvv2_setup <> FND_API.G_TRUE
5799 --dbms_output.put_line('*******************************');
5800
5801 if ((lx_qte_header_rec.invoice_to_party_site_id <> fnd_api.g_miss_num) and (lx_qte_header_rec.invoice_to_party_site_id is not null) ) then
5802 -- 9/11/02: we only call this api if we were able to find the billTo address because if we can't find
5803 -- this info, we can't default the contact
5804 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5805 IBE_Util.Debug('getHdrDefaultTaxExemption() starts');
5806 END IF;
5807 getHdrDefaultTaxExemption (
5808 P_Api_Version_Number => P_Api_Version_Number
5809 ,p_Init_Msg_List => p_Init_Msg_List
5810 ,p_Commit => p_Commit
5811 ,px_hd_Tax_Detail_Tbl => lx_hd_Tax_Detail_Tbl
5812 ,p_qte_header_rec => lx_qte_header_rec
5813 ,X_Return_Status => X_Return_Status
5814 ,X_Msg_Count => X_Msg_Count
5815 ,X_Msg_Data => X_Msg_Data
5816 );
5817 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5818 IBE_Util.Debug('getHdrDefaultTaxExemption() finishes');
5819 END IF;
5820 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5821 RAISE FND_API.G_EXC_ERROR;
5822 END IF;
5823 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5824 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5825 END IF;
5826
5827 if (lx_hd_Tax_Detail_Tbl.count <> 0) then
5828 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5829 IBE_Util.Debug('lx_hd_Tax_Detail_Tbl.tax_detail_id: '||lx_hd_Tax_Detail_Tbl(1).tax_detail_id);
5830 END IF;
5831 --dbms_output.put_line('lx_hd_Tax_Detail_Tbl.tax_detail_id: '||lx_hd_Tax_Detail_Tbl(1).tax_detail_id);
5832 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5833 IBE_Util.Debug('lx_hd_Tax_Detail_Tbl.quote_header_id: '||lx_hd_Tax_Detail_Tbl(1).quote_header_id);
5834 END IF;
5835 --dbms_output.put_line('lx_hd_Tax_Detail_Tbl.quote_header_id: '||lx_hd_Tax_Detail_Tbl(1).quote_header_id);
5836 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5837 IBE_Util.Debug('lx_hd_Tax_Detail_Tbl.operation_code: '||lx_hd_Tax_Detail_Tbl(1).operation_code);
5838 END IF;
5839 --dbms_output.put_line('lx_hd_Tax_Detail_Tbl.operation_code: '||lx_hd_Tax_Detail_Tbl(1).operation_code);
5840 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5841 IBE_Util.Debug('lx_hd_Tax_Detail_Tbl.tax_exempt_flag: '||lx_hd_Tax_Detail_Tbl(1).tax_exempt_flag);
5842 END IF;
5843 --dbms_output.put_line('lx_hd_Tax_Detail_Tbl.tax_exempt_flag: '||lx_hd_Tax_Detail_Tbl(1).tax_exempt_flag);
5844
5845 end if;
5846 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5847 IBE_Util.Debug('*******************************');
5848 END IF;
5849 --dbms_output.put_line('*******************************');
5850 end if; -- if there is billTo address
5851
5852 -- #3 End Customer Info (added 1/24/05>
5853 l_userType := IBE_Quote_Misc_pvt.getUserType(lx_qte_header_rec.party_id);
5854 if (l_userType = 'B2B') then
5855 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5856 IBE_Util.Debug('getHdrDefaultEndCustomer() starts');
5857 END IF;
5858 getHdrDefaultEndCustomer (
5859 P_Api_Version_Number => P_Api_Version_Number
5860 ,p_Init_Msg_List => p_Init_Msg_List
5861 ,p_Commit => p_Commit
5862 ,px_Qte_Header_Rec => lx_Qte_Header_Rec
5863 ,p_hd_Shipment_TBL => lx_hd_Shipment_TBL
5864 ,X_Return_Status => X_Return_Status
5865 ,X_Msg_Count => X_Msg_Count
5866 ,X_Msg_Data => X_Msg_Data
5867 );
5868 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5869 IBE_Util.Debug('getHdrDefaultEndCustomer() finishes');
5870 END IF;
5871 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5872 RAISE FND_API.G_EXC_ERROR;
5873 END IF;
5874 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5875 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5876 END IF;
5877 end if;
5878
5879
5880 -- #* Finally we have to make sure we pass and get the right parameters
5881 x_hd_Shipment_TBL := lx_hd_Shipment_TBL;
5882 x_qte_header_rec := lx_qte_header_rec;
5883 x_hd_Payment_Tbl := lx_hd_Payment_Tbl;
5884 x_hd_Tax_Detail_Tbl := lx_hd_Tax_Detail_Tbl;
5885 --maithili added for R12, for creating header level offer codes
5886 x_hd_Price_Attributes_Tbl := p_hd_Price_Attributes_Tbl;
5887 -- End of API body.
5888 -- Standard check of p_commit.
5889 IF FND_API.To_Boolean( p_commit ) THEN
5890 COMMIT WORK;
5891 END IF;
5892
5893 -- Standard call to get message count and if count is 1, get message info.
5894 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5895 p_count => x_msg_count ,
5896 p_data => x_msg_data);
5897 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5898 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultValues()');
5899 END IF;
5900 --IBE_Util.Disable_Debug;
5901
5902 EXCEPTION
5903 WHEN FND_API.G_EXC_ERROR THEN
5904 ROLLBACK TO getHdrDefaultValues_PVT;
5905 x_return_status := FND_API.G_RET_STS_ERROR;
5906 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5907 p_count => x_msg_count ,
5908 p_data => x_msg_data);
5909 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5910 ROLLBACK TO getHdrDefaultValues_PVT;
5911 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5912 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5913 p_count => x_msg_count ,
5914 p_data => x_msg_data);
5915 WHEN OTHERS THEN
5916 ROLLBACK TO getHdrDefaultValues_PVT;
5917 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5918 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
5919 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
5920 l_api_name);
5921 END IF;
5922 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
5923 p_count => x_msg_count ,
5924 p_data => x_msg_data);
5925 END getHdrDefaultValues;
5926
5927
5928 PROCEDURE getHdrDefaultAddress(
5929 P_Api_Version_Number IN NUMBER
5930 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
5931 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
5932 ,px_hd_Shipment_TBL IN OUT NOCOPY ASO_Quote_Pub.Shipment_tbl_Type
5933 ,px_qte_header_rec IN OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type
5934 ,p_party_site_use IN varchar2
5935 ,X_Return_Status OUT NOCOPY VARCHAR2
5936 ,X_Msg_Count OUT NOCOPY NUMBER
5937 ,X_Msg_Data OUT NOCOPY VARCHAR2
5938 )
5939 is
5940
5941 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultAddress';
5942 l_api_version CONSTANT NUMBER := 1.0;
5943
5944 l_opCode varchar2(10) := 'CREATE';
5945 l_party_id number := px_qte_header_rec.party_id;
5946 lx_party_site_id number;
5947 l_shipment_id number := FND_API.G_MISS_NUM;
5948
5949 l_isDone varchar2(1) := 'N';
5950
5951 l_userType varchar2(30);
5952
5953 --shipTo
5954 cursor c_check_shipTo_rec_exist(l_quote_header_id number)
5955 is
5956 select shipment_id, SHIP_TO_PARTY_SITE_ID
5957 from ASO_shipments
5958 where QUOTE_HEADER_ID = l_quote_header_id and
5959 quote_line_id is null;
5960 rec_shipTo_rec_exist c_check_shipTo_rec_exist%rowtype;
5961
5962 cursor c_check_shipTo_partyId(l_quote_header_id number)
5963 is
5964 select ship_to_party_id
5965 from ASO_shipments
5966 where QUOTE_HEADER_ID = l_quote_header_id and
5967 quote_line_id is null and
5968 SHIP_TO_CUST_ACCOUNT_ID is null and
5969 SHIP_TO_PARTY_SITE_ID is null;
5970 rec_shipTo_partyId c_check_shipTo_partyId%rowtype;
5971
5972 -- billTo
5973 cursor c_check_billTo_rec_exist(l_quote_header_id number)
5974 is
5975 select quote_header_id, INVOICE_TO_PARTY_SITE_ID
5976 from ASO_quote_headers
5977 where QUOTE_HEADER_ID = l_quote_header_id;
5978 rec_billTo_rec_exist c_check_billTo_rec_exist%rowtype;
5979
5980 cursor c_check_billTo_partyId(l_quote_header_id number)
5981 is
5982 select invoice_to_party_id
5983 from ASO_quote_headers
5984 where QUOTE_HEADER_ID = l_quote_header_id and
5985 INVOICE_TO_CUST_ACCOUNT_ID is null and
5986 INVOICE_TO_PARTY_SITE_ID is null;
5987
5988 rec_billTo_partyId c_check_billTo_partyId%rowtype;
5989
5990 begin
5991
5992 -- Standard Start of API savepoint
5993 SAVEPOINT getHdrDefaultAddress_pvt;
5994
5995 -- Standard call to check for call compatibility.
5996 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
5997 P_Api_Version_Number,
5998 L_API_NAME ,
5999 G_PKG_NAME )
6000 THEN
6001 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6002 END IF;
6003
6004 -- Initialize message list if p_init_msg_list is set to TRUE.
6005 IF FND_API.To_Boolean(p_init_msg_list) THEN
6006 FND_Msg_Pub.initialize;
6007 END IF;
6008
6009 -- Initialize API return status to success
6010 x_return_status := FND_API.G_RET_STS_SUCCESS;
6011
6012 -- API body
6013
6014 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6015 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.getHdrDefaultAddress()');
6016 END IF;
6017 -- 1. for the merge cart cases, we have to check if there is shipment/billing address in the shipment/quote header record associated w/ the cart:
6018 /*
6019 *Here is the general algorithm:
6020 if there is already shipTo partySiteId -> we're done
6021 else if there is no shipmentId -> partyId = cookie's
6022 opCode = Create
6023 else
6024 opCode = Update
6025 if shipTo_partyId is not null -> partyId = shipTo_partyId
6026 else
6027 there is shipment record but no shipTo_partyId -> partyId = cookie's
6028 */
6029
6030 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6031 IBE_Util.Debug('getDefaultAddress: l_party_id ='||l_party_id);
6032 END IF;
6033 --DBMS_OUTPUT.PUT_line('getDefaultAddress: l_party_id ='||l_party_id);
6034 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6035 IBE_Util.Debug('getDefaultAddress: px_qte_header_rec.quote_header_id='||px_qte_header_rec.quote_header_id);
6036 END IF;
6037 --DBMS_OUTPUT.PUT_line('getDefaultAddress: px_qte_header_rec.quote_header_id='||px_qte_header_rec.quote_header_id);
6038 if ((px_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM) and (px_qte_header_rec.quote_header_id is not null)) then
6039 if (p_party_site_use = 'S') then
6040
6041 -- check to see if there is already a shipTo partySiteId
6042 open c_check_shipTo_rec_exist (px_qte_header_rec.quote_header_id);
6043 fetch c_check_shipTo_rec_exist into rec_shipTo_rec_exist;
6044 close c_check_shipTo_rec_exist;
6045
6046 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6047 IBE_Util.Debug('getDefaultAddress: px_qte_header_rec.quote_header_id ='||px_qte_header_rec.quote_header_id);
6048 END IF;
6049 --DBMS_OUTPUT.PUT_line('getDefaultAddress: px_qte_header_rec.quote_header_id ='||px_qte_header_rec.quote_header_id);
6050 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6051 IBE_Util.Debug('getDefaultAddress: rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID='||rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID);
6052 END IF;
6053 --DBMS_OUTPUT.PUT_line('getDefaultAddress: rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID='||rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID);
6054 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6055 IBE_Util.Debug('getDefaultAddress: rec_shipTo_rec_exist.shipment_id ='||rec_shipTo_rec_exist.shipment_id);
6056 END IF;
6057 --DBMS_OUTPUT.PUT_line('getDefaultAddress: rec_shipTo_rec_exist.shipment_id ='||rec_shipTo_rec_exist.shipment_id);
6058
6059 -- if there is already a shipTo partySiteId, we are done
6060 if ((rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID <> FND_API.G_MISS_NUM) and (rec_shipTo_rec_exist.SHIP_TO_PARTY_SITE_ID is not null)) then
6061 l_isDone := 'Y';
6062
6063 -- if there is no shipmentId
6064 elsif ((rec_shipTo_rec_exist.shipment_id = FND_API.G_MISS_NUM) or (rec_shipTo_rec_exist.shipment_id is null)) then
6065 l_party_id := px_qte_header_rec.party_id;
6066 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6067 IBE_Util.Debug('getDefaultAddress: l_party_id-no shipId-='||l_party_id);
6068 END IF;
6069 --DBMS_OUTPUT.PUT_line('getDefaultAddress: l_party_id-no shipId-='||l_party_id);
6070
6071 else
6072 l_opCode := 'UPDATE';
6073 l_shipment_id := rec_shipTo_rec_exist.shipment_id;
6074 -- if not, check if there is a shipTo partyId
6075 open c_check_shipTo_partyId (px_qte_header_rec.quote_header_id);
6076 fetch c_check_shipTo_partyId into rec_shipTo_partyId;
6077 close c_check_shipTo_partyId;
6078
6079 -- if there is shipTo contact
6080 if ((rec_shipTo_partyId.ship_to_party_id <> FND_API.G_MISS_NUM) and (rec_shipTo_partyId.ship_to_party_id is not null)) then
6081 l_party_id := rec_shipTo_partyId.ship_to_party_id;
6082 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6083 IBE_Util.Debug('getDefaultAddress: l_party_id-contact-='||l_party_id);
6084 END IF;
6085 --DBMS_OUTPUT.PUT_line('getDefaultAddress: l_party_id-contact-='||l_party_id);
6086 else
6087 l_party_id := px_qte_header_rec.party_id;
6088 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6089 IBE_Util.Debug('getDefaultAddress: l_party_id-soldTo-='||l_party_id);
6090 END IF;
6091 --DBMS_OUTPUT.PUT_line('getDefaultAddress: l_party_id-soldTo-='||l_party_id);
6092 end if;
6093
6094 end if;
6095
6096 elsif (p_party_site_use = 'B') then
6097
6098 -- check to see if there is already a billTo partySiteId
6099 open c_check_billTo_rec_exist (px_qte_header_rec.quote_header_id);
6100 fetch c_check_billTo_rec_exist into rec_billTo_rec_exist;
6101 close c_check_billTo_rec_exist;
6102
6103 -- if there is already a billTo partySiteId, we are done
6104 if ((rec_billTo_rec_exist.INVOICE_TO_PARTY_SITE_ID <> FND_API.G_MISS_NUM) and (rec_billTo_rec_exist.INVOICE_TO_PARTY_SITE_ID is not null)) then
6105 l_isDone := 'Y';
6106
6107 -- if there is no quote record (shouldn't happen; should also raise an error)
6108 elsif ((rec_billTo_rec_exist.quote_header_id = FND_API.G_MISS_NUM) or (rec_billTo_rec_exist.quote_header_id is null)) then
6109 l_party_id := px_qte_header_rec.party_id;
6110
6111 else
6112 l_opCode := 'UPDATE';
6113
6114 -- if not, check if there is a billTo partyId
6115 open c_check_billTo_partyId (px_qte_header_rec.quote_header_id);
6116 fetch c_check_billTo_partyId into rec_billTo_partyId;
6117 close c_check_billTo_partyId;
6118
6119 -- if there is billTo contact
6120 if ((rec_billTo_partyId.invoice_to_party_id <> FND_API.G_MISS_NUM) and (rec_billTo_partyId.invoice_to_party_id is not null)) then
6121 l_party_id := rec_billTo_partyId.invoice_to_party_id;
6122 else
6123 l_party_id := px_qte_header_rec.party_id;
6124 end if;
6125
6126 end if;
6127
6128 end if; -- check p_party_site_use
6129 end if; -- for merge cart cases
6130
6131 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6132 IBE_Util.Debug('l_party_id ='||l_party_id);
6133 END IF;
6134 --DBMS_OUTPUT.PUT_line('l_party_id ='||l_party_id);
6135 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6136 IBE_Util.Debug('p_party_site_use='||p_party_site_use);
6137 END IF;
6138 --DBMS_OUTPUT.PUT_line('p_party_site_use='||p_party_site_use);
6139 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6140 IBE_Util.Debug('l_orgId ='||MO_GLOBAL.get_current_org_id());
6141 END IF;
6142 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6143 IBE_Util.Debug('l_isDone ='||l_isDone);
6144 END IF;
6145 --DBMS_OUTPUT.PUT_line('l_isDone ='||l_isDone);
6146
6147 -- 2. if there isn't a record, continue
6148 if (l_isDone <> 'Y') then
6149 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6150 IBE_Util.Debug('Before calling IBE_ADDRESS_V2PVT.get_primary_address_id');
6151 END IF;
6152 --DBMS_OUTPUT.PUT_line('Before calling IBE_ADDRESS_V2PVT.get_primary_address_id');
6153 IBE_ADDRESS_V2PVT.get_primary_addr_id
6154 (
6155 p_api_version => p_Api_Version_Number
6156 ,p_init_msg_list => p_Init_Msg_List
6157 ,p_commit => p_Commit
6158 ,p_party_id => l_party_id
6159 ,p_site_use_type => p_party_site_use
6160 ,p_org_id => MO_Global.get_current_org_id()
6161 ,p_get_org_prim_addr => FND_API.G_TRUE
6162 ,x_return_status => x_return_status
6163 ,x_msg_count => x_msg_count
6164 ,x_msg_data => x_msg_data
6165 ,x_party_site_id => lx_party_site_id
6166 );
6167 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6168 RAISE FND_API.G_EXC_ERROR;
6169 END IF;
6170 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6171 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6172 END IF;
6173 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6174 IBE_Util.Debug('After calling IBE_ADDRESS_V2PVT.get_primary_address_id');
6175 END IF;
6176 --DBMS_OUTPUT.PUT_line('After calling IBE_ADDRESS_V2PVT.get_primary_address_id');
6177 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6178 IBE_Util.Debug('lx_party_site_id ='||lx_party_site_id);
6179 END IF;
6180 --DBMS_OUTPUT.PUT_line('lx_party_site_id ='||lx_party_site_id);
6181
6182 -- 2.1 populate the shipment/quote hdr record:
6183 if ((lx_party_site_id <> -1) and (lx_party_site_id <> fnd_api.g_miss_num) and (lx_party_site_id is not null) ) then
6184 l_userType := IBE_Quote_Misc_pvt.getUserType(px_qte_header_rec.party_id);
6185 if (p_party_site_use = 'S') then
6186 px_hd_Shipment_TBL(1).shipment_id := l_shipment_id;
6187 px_hd_Shipment_TBL(1).quote_header_id := px_qte_header_rec.quote_header_id;
6188 px_hd_Shipment_TBL(1).operation_code := l_opCode;
6189 px_hd_Shipment_TBL(1).SHIP_TO_PARTY_site_ID := lx_party_site_id;
6190 if ( ((rec_shipTo_partyId.ship_to_party_id = FND_API.G_MISS_NUM) or (rec_shipTo_partyId.ship_to_party_id is null)) and (l_userType = 'B2B') ) then
6191 px_hd_Shipment_TBL(1).SHIP_TO_PARTY_ID := px_qte_header_rec.party_id;
6192 end if;
6193 elsif (p_party_site_use = 'B') then
6194 px_qte_header_rec.INVOICE_TO_PARTY_SITE_ID := lx_party_site_id;
6195 if ( ((rec_billTo_partyId.invoice_to_party_id = FND_API.G_MISS_NUM) or (rec_billTo_partyId.invoice_to_party_id is null)) and (l_userType = 'B2B') ) then
6196 px_qte_header_rec.INVOICE_TO_PARTY_ID := px_qte_header_rec.party_id;
6197 end if;
6198 end if;
6199 end if;
6200
6201 end if; -- if (l_isDone <> 'Y')
6202
6203 -- End of API body.
6204 -- Standard check of p_commit.
6205 IF FND_API.To_Boolean( p_commit ) THEN
6206 COMMIT WORK;
6207 END IF;
6208
6209 -- Standard call to get message count and if count is 1, get message info.
6210 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6211 p_count => x_msg_count ,
6212 p_data => x_msg_data);
6213 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6214 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultAddress()');
6215 END IF;
6216 --IBE_Util.Disable_Debug;
6217
6218 EXCEPTION
6219 WHEN FND_API.G_EXC_ERROR THEN
6220 ROLLBACK TO getHdrDefaultAddress_pvt;
6221 x_return_status := FND_API.G_RET_STS_ERROR;
6222 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6223 p_count => x_msg_count ,
6224 p_data => x_msg_data);
6225 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6226 ROLLBACK TO getHdrDefaultAddress_pvt;
6227 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6228 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6229 p_count => x_msg_count ,
6230 p_data => x_msg_data);
6231 WHEN OTHERS THEN
6232 ROLLBACK TO getHdrDefaultAddress_pvt;
6233 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6234 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
6235 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
6236 l_api_name);
6237 END IF;
6238 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6239 p_count => x_msg_count ,
6240 p_data => x_msg_data);
6241
6242 end getHdrDefaultAddress;
6243
6244 PROCEDURE getHdrDefaultShipMethod(
6245 P_Api_Version_Number IN NUMBER
6246 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
6247 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
6248 ,px_hd_Shipment_TBL IN OUT NOCOPY ASO_Quote_Pub.Shipment_tbl_Type
6249 ,p_qte_header_rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
6250 ,p_minisite_id IN Number
6251 ,X_Return_Status OUT NOCOPY VARCHAR2
6252 ,X_Msg_Count OUT NOCOPY NUMBER
6253 ,X_Msg_Data OUT NOCOPY VARCHAR2
6254 )
6255
6256 is
6257
6258 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultShipMethod';
6259 l_api_version CONSTANT NUMBER := 1.0;
6260 l_opCode varchar2(10) := 'CREATE';
6261
6262 l_shipment_id number := FND_API.G_MISS_NUM;
6263 l_isDone varchar2(1) := 'N';
6264
6265 l_ship_method_code varchar2(30) := null;
6266 l_ship_method_code_first varchar2(30) := null;
6267 l_org_id number := MO_GLOBAL.get_current_org_id();
6268 l_prefSMValid varchar2(1) := 'N';
6269 l_index number := 1;
6270
6271 cursor c_check_shipTo_rec_exist(l_quote_header_id number)
6272 is
6273 select shipment_id, SHIP_METHOD_CODE
6274 from ASO_shipments
6275 where QUOTE_HEADER_ID = l_quote_header_id and
6276 quote_line_id is null;
6277 rec_shipTo_rec_exist c_check_shipTo_rec_exist%rowtype;
6278
6279 cursor c_get_MiniSiteOrg_ShipMethod(l_msite_id number, l_org_id number,l_ship_mthd varchar2, l_web_enabled varchar2, l_enabled_flag varchar2)
6280 is
6281 SELECT msite_information1
6282 FROM ibe_msite_information m, wsh_carrier_ship_methods o, oe_system_parameters_all oesp
6283 WHERE m.msite_id = l_msite_id
6284 AND m.msite_information_context = l_ship_mthd
6285 AND m.msite_information1 = o.ship_method_code
6286 AND oesp.org_id = l_org_id
6287 AND o.organization_id = oesp.master_organization_id
6288 AND o.web_enabled = l_web_enabled
6289 AND o.enabled_flag = l_enabled_flag
6290 Order by msite_information1;
6291
6292 rec_MiniSiteOrg_ShipMethod c_get_MiniSiteOrg_ShipMethod%rowtype;
6293
6294 begin
6295
6296 -- Standard Start of API savepoint
6297 SAVEPOINT getHdrDefaultShipMethod_pvt;
6298
6299 -- Standard call to check for call compatibility.
6300 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
6301 P_Api_Version_Number,
6302 L_API_NAME ,
6303 G_PKG_NAME )
6304 THEN
6305 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6306 END IF;
6307
6308 -- Initialize message list if p_init_msg_list is set to TRUE.
6309 IF FND_API.To_Boolean(p_init_msg_list) THEN
6310 FND_Msg_Pub.initialize;
6311 END IF;
6312
6313 -- Initialize API return status to success
6314 x_return_status := FND_API.G_RET_STS_SUCCESS;
6315
6316 -- API body
6317
6318 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6319 IBE_Util.Debug('Start IBE_Quote_Save_pvt.getHdrDefaultShipMethod()');
6320 END IF;
6321
6322 -- 1. for the merge cart cases, we have to check if there is shipment method in the shipment record associated w/ the cart:
6323 if ((p_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM) and (p_qte_header_rec.quote_header_id is not null)) then
6324
6325 -- check to see if there is already a ship method
6326 open c_check_shipTo_rec_exist (p_qte_header_rec.quote_header_id);
6327 fetch c_check_shipTo_rec_exist into rec_shipTo_rec_exist;
6328 close c_check_shipTo_rec_exist;
6329
6330 -- if there is already a ship method, we are done
6331 if ((rec_shipTo_rec_exist.SHIP_METHOD_CODE <> FND_API.G_MISS_char) and (rec_shipTo_rec_exist.SHIP_METHOD_CODE is not null)) then
6332 l_isDone := 'Y';
6333
6334 -- if there is shipmentId
6335 elsif ((rec_shipTo_rec_exist.shipment_id <> FND_API.G_MISS_NUM) and (rec_shipTo_rec_exist.shipment_id is not null)) then
6336 l_opCode := 'UPDATE';
6337 l_shipment_id := rec_shipTo_rec_exist.shipment_id;
6338 end if;
6339 end if; -- for merge cart cases
6340
6341 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6342 IBE_Util.Debug('l_opCode :'||l_opCode);
6343 END IF;
6344 --DBMS_OUTPUT.PUT_line('l_opCode :'||l_opCode);
6345 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6346 IBE_Util.Debug('l_shipment_id :'||l_shipment_id);
6347 END IF;
6348 --DBMS_OUTPUT.PUT_line('l_shipment_id :'||l_shipment_id);
6349
6350 -- 2. if there isn't a record, continue
6351 if (l_isDone <> 'Y') then
6352 -- 2.1 First, look at the prefered Shipment Method profile:
6353 -- if there is a value then we have to validate this value with the list of shipment methods
6354 -- created from an intersection of shipment methods in the minisite and those in the operation unit
6355 l_ship_method_code := FND_PROFILE.VALUE('IBE_PREFERED_SHIP_METHOD');
6356
6357 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6358 IBE_Util.Debug('l_ship_method_code :'||l_ship_method_code||'*');
6359 END IF;
6360 --DBMS_OUTPUT.PUT_line('l_ship_method_code :'||l_ship_method_code||'*');
6361 if (l_ship_method_code = '') then
6362 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6363 IBE_Util.Debug('l_ship_method_code is blank');
6364 END IF;
6365 --DBMS_OUTPUT.PUT_line('l_ship_method_code is blank');
6366 end if;
6367
6368 -- 2.2 the drop down value: intersection of the minisite ones and the org ones
6369 -- if there is not preferred ship method, we just take the the first row in the result set
6370 -- else we have to validate this value w/ this result set
6371
6372 for rec_MiniSiteOrg_ShipMethod in c_get_MiniSiteOrg_ShipMethod(p_minisite_id, l_org_id,'SHPMT_MTHD','Y','Y') loop
6373
6374 -- case 2.2: no preferred ship method -> so, take the first row of the result set
6375 if ((l_ship_method_code = FND_API.G_MISS_char) or (l_ship_method_code is null)) then
6376
6377 -- 11/14/02: we're changing the logic: if no preferred ship method, then don't default
6378 -- Now, as per ER#4663790, we need to default, so uncommenting the following line.
6379
6380 l_ship_method_code := rec_MiniSiteOrg_ShipMethod.msite_information1;
6381 -- l_ship_method_code := null; -- commenting for ER# 4663790
6382
6383 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6384 IBE_Util.Debug('case 2.2: l_ship_method_code :'||l_ship_method_code);
6385 END IF;
6386
6387 l_prefSMValid := 'Y';
6388 exit;
6389 else
6390 -- case 2.1: validate preferred ship method w/ the result set
6391 if (l_ship_method_code = rec_MiniSiteOrg_ShipMethod.msite_information1) then
6392 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6393 IBE_Util.Debug('case 2.1: l_ship_method_code :'||l_ship_method_code);
6394 END IF;
6395 l_prefSMValid := 'Y';
6396 exit;
6397 end if;
6398
6399 -- case 2.2 #2: if preferred ship method is not in result set, then take the first row of the result set
6400 -- Hence, we have to keep track of the first row
6401 if (l_index = 1) then
6402 l_ship_method_code_first := rec_MiniSiteOrg_ShipMethod.msite_information1;
6403 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6404 IBE_Util.Debug('l_ship_method_code_first :'||l_ship_method_code_first);
6405 END IF;
6406 l_index := 2;
6407 end if;
6408 end if;
6409
6410 exit when c_get_MiniSiteOrg_ShipMethod%notfound;
6411 end loop;
6412 --close c_get_MiniSiteOrg_ShipMethod;
6413
6414 -- case 2.2 #2:
6415 if (l_prefSMValid = 'N') then
6416
6417 -- 11/14/02: we're changing the logic: if no preferred ship method, then don't default
6418 -- Now, as per ER#4663790, we need to default, so uncommenting the following line.
6419 l_ship_method_code := l_ship_method_code_first;
6420
6421 -- 11/14/02: added this
6422
6423 -- l_ship_method_code := null; -- commenting for ER# 4663790
6424
6425 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6426 IBE_Util.Debug('case 2.2#2: l_ship_method_code :'||l_ship_method_code);
6427 END IF;
6428 --DBMS_OUTPUT.PUT_line('case 2.2#2: l_ship_method_code :'||l_ship_method_code);
6429 end if;
6430
6431 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6432 IBE_Util.Debug('Finally: l_ship_method_code :'||l_ship_method_code);
6433 END IF;
6434 --DBMS_OUTPUT.PUT_line('Finally: l_ship_method_code :'||l_ship_method_code);
6435 -- 2.3 populate the shipment record:
6436 if ((l_ship_method_code <> FND_API.G_MISS_char) and (l_ship_method_code is not null)) then
6437 px_hd_Shipment_TBL(1).shipment_id := l_shipment_id;
6438 px_hd_Shipment_TBL(1).quote_header_id := p_qte_header_rec.quote_header_id;
6439 px_hd_Shipment_TBL(1).operation_code := l_opCode;
6440 px_hd_Shipment_TBL(1).SHIP_METHOD_CODE := l_ship_method_code;
6441 end if;
6442
6443 end if; -- if (l_isDone <> 'Y')
6444
6445 -- End of API body.
6446 -- Standard check of p_commit.
6447 IF FND_API.To_Boolean( p_commit ) THEN
6448 COMMIT WORK;
6449 END IF;
6450
6451 -- Standard call to get message count and if count is 1, get message info.
6452 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6453 p_count => x_msg_count ,
6454 p_data => x_msg_data);
6455 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6456 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultShipMethod()');
6457 END IF;
6458 --IBE_Util.Disable_Debug;
6459
6460
6461 EXCEPTION
6462 WHEN FND_API.G_EXC_ERROR THEN
6463 ROLLBACK TO getHdrDefaultShipMethod_pvt;
6464 x_return_status := FND_API.G_RET_STS_ERROR;
6465 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6466 p_count => x_msg_count ,
6467 p_data => x_msg_data);
6468 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6469 ROLLBACK TO getHdrDefaultShipMethod_pvt;
6470 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6471 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6472 p_count => x_msg_count ,
6473 p_data => x_msg_data);
6474 WHEN OTHERS THEN
6475 ROLLBACK TO getHdrDefaultShipMethod_pvt;
6476 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6477 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
6478 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
6479 l_api_name);
6480 END IF;
6481 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6482 p_count => x_msg_count ,
6483 p_data => x_msg_data);
6484 end getHdrDefaultShipMethod;
6485
6486 PROCEDURE getHdrDefaultPaymentMethod(
6487 P_Api_Version_Number IN NUMBER
6488 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
6489 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
6490 ,px_hd_Payment_Tbl IN OUT NOCOPY ASO_Quote_Pub.Payment_Tbl_Type
6491 ,p_qte_header_rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
6492 ,p_minisite_id IN Number
6493 ,X_Return_Status OUT NOCOPY VARCHAR2
6494 ,X_Msg_Count OUT NOCOPY NUMBER
6495 ,X_Msg_Data OUT NOCOPY VARCHAR2
6496 )
6497
6498 is
6499
6500 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultPaymentMethod';
6501 l_api_version CONSTANT NUMBER := 1.0;
6502 l_opCode varchar2(10) := 'CREATE';
6503
6504 l_isDone varchar2(1) := 'N';
6505
6506 l_payment_id number := FND_API.G_MISS_NUM;
6507 l_payment_type_code varchar2(30) := null;
6508 lx_cc_assignment_id NUMBER;
6509
6510 l_isInvoice varchar2(1) := 'N';
6511 l_isCash varchar2(1) := 'N';
6512 l_isCheck varchar2(1) := 'N';
6513 G_PERM_VIEW_PAY_BOOK BOOLEAN;
6514 l_ret_credit_pref varchar2(5) :='Y';
6515 l_retain_cc varchar2(1) := 'Y';
6516
6517 cursor c_check_payment_rec_exist(l_quote_header_id number)
6518 is
6519 select payment_id, PAYMENT_TYPE_CODE
6520 from ASO_payments
6521 where QUOTE_HEADER_ID = l_quote_header_id and
6522 quote_line_id is null;
6523 rec_payment_rec_exist c_check_payment_rec_exist%rowtype;
6524
6525 cursor c_check_CC_enabled(l_msite_id number)
6526 is
6527 SELECT msite_information1
6528 FROM ibe_msite_information a, fnd_lookup_values b
6529 WHERE a.msite_id = l_msite_id
6530 AND a.msite_information1 = b.lookup_code
6531 AND a.msite_information1 = 'CREDIT_CARD'
6532 AND b.LOOKUP_TYPE = 'IBE_PAYMENT_TYPE'
6533 AND b.ENABLED_FLAG ='Y' AND (b.TAG='Y' or b.TAG is null)
6534 AND b.language = userenv('lang');
6535 rec_CC_enabled c_check_CC_enabled%rowtype;
6536
6537 cursor c_get_next_payment_type(l_msite_id number)
6538 is
6539 SELECT msite_information1
6540 FROM ibe_msite_information a, fnd_lookup_values b
6541 WHERE a.msite_id = l_msite_id
6542 AND a.msite_information1 = b.lookup_code
6543 AND a.msite_information1 <> 'CREDIT_CARD'
6544 AND b.LOOKUP_TYPE = 'IBE_PAYMENT_TYPE'
6545 AND b.ENABLED_FLAG ='Y' AND (b.TAG='Y' or b.TAG is null)
6546 AND b.language = userenv('lang');
6547 rec_next_payment_type c_get_next_payment_type%rowtype;
6548
6549 begin
6550
6551 -- Standard Start of API savepoint
6552 SAVEPOINT getHdrDefPmtMethod_pvt;
6553
6554 -- Standard call to check for call compatibility.
6555 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
6556 P_Api_Version_Number,
6557 L_API_NAME ,
6558 G_PKG_NAME )
6559 THEN
6560 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6561 END IF;
6562
6563 -- Initialize message list if p_init_msg_list is set to TRUE.
6564 IF FND_API.To_Boolean(p_init_msg_list) THEN
6565 FND_Msg_Pub.initialize;
6566 END IF;
6567
6568 -- Initialize API return status to success
6569 x_return_status := FND_API.G_RET_STS_SUCCESS;
6570
6571 -- API body
6572
6573 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6574 IBE_Util.Debug('Start IBE_Quote_Save_pvt.getHdrDefaultPaymentMethod()');
6575 END IF;
6576 -- 1. for the merge cart cases, we have to check if there is a payment record associated w/ the cart:
6577 if ((p_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM) and (p_qte_header_rec.quote_header_id is not null)) then
6578
6579 -- check to see if there is already a payment method
6580 open c_check_payment_rec_exist (p_qte_header_rec.quote_header_id);
6581 fetch c_check_payment_rec_exist into rec_payment_rec_exist;
6582 close c_check_payment_rec_exist;
6583
6584 -- if there is already a payment method, we are done
6585 -- 2/6/03: per Bug 2780574, we will not update the payment record, we will only create
6586 /*
6587 if ((rec_payment_rec_exist.PAYMENT_TYPE_CODE <> FND_API.G_MISS_char) and (rec_payment_rec_exist.PAYMENT_TYPE_CODE is not null)) then
6588 l_isDone := 'Y';
6589
6590 -- if there is paymentId
6591 elsif ((rec_payment_rec_exist.payment_id <> FND_API.G_MISS_NUM) and (rec_payment_rec_exist.payment_id is not null)) then
6592 l_opCode := 'UPDATE';
6593 l_payment_id := rec_payment_rec_exist.payment_id;
6594 end if;
6595 */
6596
6597 if ((rec_payment_rec_exist.payment_id <> FND_API.G_MISS_NUM) and (rec_payment_rec_exist.payment_id is not null)) then
6598 l_isDone := 'Y';
6599 end if;
6600 end if; -- for merge cart cases
6601
6602 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6603 IBE_Util.Debug('l_opCode :'||l_opCode);
6604 END IF;
6605 --DBMS_OUTPUT.PUT_line('l_opCode :'||l_opCode);
6606 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6607 IBE_Util.Debug('l_payment_id :'||l_payment_id);
6608 END IF;
6609 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6610 IBE_Util.Debug('l_isDone :'||l_isDone);
6611 END IF;
6612 --DBMS_OUTPUT.PUT_line('l_payment_id :'||l_payment_id);
6613
6614 -- 2. if there isn't a record, continue
6615 if (l_isDone <> 'Y') then
6616
6617 -- 2.1 Check to see if CC is enabled:
6618 open c_check_CC_enabled (p_minisite_id);
6619 fetch c_check_CC_enabled into rec_CC_enabled;
6620 close c_check_CC_enabled;
6621
6622 -- 2.2 if CC is enabled then we call IBE_CUSTOMER_ACCOUNTS.get_default_credit_card_info to see if there is a default credit card
6623 if ((rec_CC_enabled.msite_information1 <> FND_API.G_MISS_char) and (rec_CC_enabled.msite_information1 is not null)) then
6624
6625 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6626 IBE_Util.Debug('Before calling IBE_CUSTOMER_pvt.get_default_credit_card_info');
6627 END IF;
6628 --DBMS_OUTPUT.PUT_line('Before calling IBE_CUSTOMER_pvt.get_default_credit_card_info');
6629 /* CC consolidation */
6630
6631 l_ret_credit_pref := NVL(FND_PROFILE.VALUE('IBE_RETAIN_CC_PREFS'),'Y');
6632 G_PERM_VIEW_PAY_BOOK := IBE_UTIL.check_user_permission('IBE_USE_PAYMENT_BOOK');
6633
6634 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6635 IBE_Util.Debug('l_ret_credit_pref:'||l_ret_credit_pref);
6636
6637 IF(G_PERM_VIEW_PAY_BOOK) THEN
6638 Ibe_Util.debug(rpad('G_PERM_VIEW_PAY_BOOK',30)||':'||'TRUE');
6639 ELSE
6640 Ibe_Util.debug(rpad('G_PERM_VIEW_PAY_BOOK',30)||':'||'FALSE');
6641 END IF;
6642 END IF;
6643
6644 if ( not G_PERM_VIEW_PAY_BOOK or (l_ret_credit_pref = 'N')) then
6645 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6646 IBE_Util.Debug('padss is set: not querying cc pref : '||l_retain_cc);
6647 end if;
6648 l_retain_cc := 'N';
6649 end if;
6650
6651 if (l_retain_cc = 'Y') then
6652 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6653 IBE_Util.Debug('padss is not set: querying cc pref');
6654 end if;
6655
6656 IBE_CUSTOMER_pvt.get_default_credit_card_info(
6657 p_api_version => P_Api_Version_Number
6658 ,p_init_msg_list => p_Init_Msg_List
6659 ,p_commit => p_Commit
6660 ,p_cust_account_id => p_qte_header_rec.cust_account_id
6661 ,p_party_id => p_qte_header_rec.party_id
6662 ,p_mini_site_id => p_minisite_id
6663 ,x_return_status => x_return_status
6664 ,x_msg_count => x_msg_count
6665 ,x_msg_data => x_msg_data
6666 ,x_cc_assignment_id => lx_cc_assignment_id
6667 );
6668 end if;
6669
6670 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6671 RAISE FND_API.G_EXC_ERROR;
6672 END IF;
6673 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6674 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6675 END IF;
6676
6677 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6678 IBE_Util.Debug('After calling IBE_CUSTOMER_pvt.get_default_credit_card_info');
6679 END IF;
6680 --DBMS_OUTPUT.PUT_line('After calling IBE_CUSTOMER_pvt.get_default_credit_card_info');
6681 end if;
6682
6683 -- 2.3 if CC is not enabled or the call from 2.2 doesn't return a valid value,
6684 -- then we try to find the next enabled payment option in this order: invoice, cash, check
6685 --if ((lx_credit_card_num = FND_API.G_MISS_char) or (lx_credit_card_num is null)) then
6686 if ((lx_cc_assignment_id = FND_API.G_MISS_NUM) or (lx_cc_assignment_id is null)) then
6687 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6688 IBE_Util.Debug('lx_credit_card_num is null');
6689 END IF;
6690 --DBMS_OUTPUT.PUT_line('lx_credit_card_num is null');
6691
6692 /* 10/8/02: for bug 2608853: we're not going to default non-CC payment methods
6693 for rec_next_payment_type in c_get_next_payment_type(p_minisite_id) loop
6694 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6695 IBE_Util.Debug('rec_next_payment_type.msite_information1='||rec_next_payment_type.msite_information1||'*');
6696 END IF;
6697 --DBMS_OUTPUT.PUT_line('rec_next_payment_type.msite_information1='||rec_next_payment_type.msite_information1||'*');
6698 if (rec_next_payment_type.msite_information1 = 'INVOICE') then
6699 l_isInvoice := 'Y';
6700 exit;
6701 elsif (rec_next_payment_type.msite_information1 = 'CASH') then
6702 l_isCash := 'Y';
6703 elsif (rec_next_payment_type.msite_information1 = 'CHECK') then
6704 l_isCheck := 'Y';
6705 end if;
6706 exit when c_get_next_payment_type%notfound;
6707 end loop;
6708 --close c_get_next_payment_type;
6709
6710 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6711 IBE_Util.Debug('l_isInvoice ='||l_isInvoice);
6712 END IF;
6713 --DBMS_OUTPUT.PUT_line('l_isInvoice ='||l_isInvoice);
6714 if (l_isInvoice = 'Y') then
6715 l_payment_type_code := 'INVOICE';
6716 elsif (l_isCash = 'Y') then
6717 l_payment_type_code := 'CASH';
6718 elsif (l_isCheck = 'Y') then
6719 -- 8/29/02: we can't default check because check # is required
6720 --l_payment_type_code := 'CHECK';
6721 l_payment_type_code := null;
6722 end if;
6723 */
6724
6725 else
6726 l_payment_type_code := 'CREDIT_CARD';
6727 end if;
6728
6729 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6730 IBE_Util.Debug('l_payment_type_code ='||l_payment_type_code);
6731 END IF;
6732 --DBMS_OUTPUT.PUT_line('l_payment_type_code ='||l_payment_type_code);
6733
6734 -- 2.4 populate the payment record:
6735 -- Bug 11810302, scnagara, included check on p_qte_header_rec.invoice_to_party_site_id in the below if condition
6736 if ((l_payment_type_code <> FND_API.G_MISS_char) and (l_payment_type_code is not null) and (p_qte_header_rec.invoice_to_party_site_id <> fnd_api.g_miss_num) and (p_qte_header_rec.invoice_to_party_site_id is not null)) then
6737 px_hd_Payment_Tbl(1).payment_id := l_payment_id;
6738 px_hd_Payment_Tbl(1).quote_header_id := p_qte_header_rec.quote_header_id;
6739 px_hd_Payment_Tbl(1).operation_code := l_opCode;
6740 -- px_hd_Payment_Tbl(1).quote_shipment_index := 1; // not needed
6741
6742 if (l_payment_type_code = 'INVOICE') then
6743 l_payment_type_code := null;
6744 end if;
6745 px_hd_Payment_Tbl(1).PAYMENT_TYPE_CODE := l_payment_type_code;
6746 px_hd_Payment_Tbl(1).PAYMENT_TERM_ID := fnd_profile.value('IBE_DEFAULT_PAYMENT_TERM_ID');
6747
6748 /*CC consolidation*/
6749 if ((lx_cc_assignment_id <> FND_API.G_MISS_NUM) and (lx_cc_assignment_id is not null)) then
6750 px_hd_Payment_Tbl(1).INSTR_ASSIGNMENT_ID := lx_cc_assignment_id;
6751 px_hd_Payment_Tbl(1).PAYMENT_REF_NUMBER := null;
6752 px_hd_Payment_Tbl(1).CREDIT_CARD_CODE := null;
6753 px_hd_Payment_Tbl(1).CREDIT_CARD_HOLDER_NAME := null;
6754 px_hd_Payment_Tbl(1).CREDIT_CARD_EXPIRATION_DATE := null;
6755 else
6756 px_hd_Payment_Tbl(1).INSTR_ASSIGNMENT_ID := null;
6757 px_hd_Payment_Tbl(1).PAYMENT_REF_NUMBER := null;
6758 px_hd_Payment_Tbl(1).CREDIT_CARD_CODE := null;
6759 px_hd_Payment_Tbl(1).CREDIT_CARD_HOLDER_NAME := null;
6760 px_hd_Payment_Tbl(1).CREDIT_CARD_EXPIRATION_DATE := null;
6761 end if;
6762
6763 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6764 IBE_Util.Debug('done: populate the payment record');
6765 END IF;
6766 --DBMS_OUTPUT.PUT_line('done: populate the payment record');
6767 end if;
6768
6769 end if; -- if (l_isDone <> 'Y')
6770
6771 -- End of API body.
6772 -- Standard check of p_commit.
6773 IF FND_API.To_Boolean( p_commit ) THEN
6774 COMMIT WORK;
6775 END IF;
6776
6777 -- Standard call to get message count and if count is 1, get message info.
6778 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6779 p_count => x_msg_count ,
6780 p_data => x_msg_data);
6781 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6782 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultPaymentMethod()');
6783 END IF;
6784 --IBE_Util.Disable_Debug;
6785
6786 EXCEPTION
6787 WHEN FND_API.G_EXC_ERROR THEN
6788 ROLLBACK TO getHdrDefPmtMethod_pvt;
6789 x_return_status := FND_API.G_RET_STS_ERROR;
6790 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6791 p_count => x_msg_count ,
6792 p_data => x_msg_data);
6793 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6794 ROLLBACK TO getHdrDefPmtMethod_pvt;
6795 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6796 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6797 p_count => x_msg_count ,
6798 p_data => x_msg_data);
6799 WHEN OTHERS THEN
6800 ROLLBACK TO getHdrDefPmtMethod_pvt;
6801 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6802 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
6803 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
6804 l_api_name);
6805 END IF;
6806 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6807 p_count => x_msg_count ,
6808 p_data => x_msg_data);
6809 end getHdrDefaultPaymentMethod;
6810
6811 PROCEDURE getHdrDefaultTaxExemption(
6812 P_Api_Version_Number IN NUMBER
6813 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
6814 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
6815 ,px_hd_Tax_Detail_Tbl IN OUT NOCOPY ASO_Quote_Pub.Tax_Detail_Tbl_Type
6816 ,p_qte_header_rec IN ASO_Quote_Pub.Qte_Header_Rec_Type
6817 ,X_Return_Status OUT NOCOPY VARCHAR2
6818 ,X_Msg_Count OUT NOCOPY NUMBER
6819 ,X_Msg_Data OUT NOCOPY VARCHAR2
6820 )
6821
6822 is
6823
6824 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultTaxExemption';
6825 l_api_version CONSTANT NUMBER := 1.0;
6826 l_opCode varchar2(10) := 'CREATE';
6827
6828 l_isDone varchar2(1) := 'N';
6829
6830 l_tax_detail_id number := FND_API.G_MISS_NUM;
6831 l_payment_type_code varchar2(30) := null;
6832
6833 cursor c_check_tax_rec_exist(l_quote_header_id number)
6834 is
6835 select tax_detail_id, tax_exempt_flag
6836 from ASO_TAX_DETAILS
6837 where QUOTE_HEADER_ID = l_quote_header_id and
6838 quote_line_id is null;
6839 rec_tax_rec_exist c_check_tax_rec_exist%rowtype;
6840
6841 begin
6842
6843 -- Standard Start of API savepoint
6844 SAVEPOINT getHdrDefTaxExmpt_pvt;
6845
6846 -- Standard call to check for call compatibility.
6847 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
6848 P_Api_Version_Number,
6849 L_API_NAME ,
6850 G_PKG_NAME )
6851 THEN
6852 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6853 END IF;
6854
6855 -- Initialize message list if p_init_msg_list is set to TRUE.
6856 IF FND_API.To_Boolean(p_init_msg_list) THEN
6857 FND_Msg_Pub.initialize;
6858 END IF;
6859
6860 -- Initialize API return status to success
6861 x_return_status := FND_API.G_RET_STS_SUCCESS;
6862
6863 -- API body
6864
6865 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6866 IBE_Util.Debug('Start IBE_Quote_Save_pvt.getHdrDefaultTaxExemption()');
6867 END IF;
6868
6869 -- 1. for the merge cart cases, we have to check if there is tax exemption flag in the tax record associated w/ the cart:
6870 if ((p_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM) and (p_qte_header_rec.quote_header_id is not null)) then
6871
6872 -- check to see if there is already a tax exemption flag
6873 open c_check_tax_rec_exist (p_qte_header_rec.quote_header_id);
6874 fetch c_check_tax_rec_exist into rec_tax_rec_exist;
6875 close c_check_tax_rec_exist;
6876
6877 -- if there is already a shipTo partySiteId, we are done
6878 if ((rec_tax_rec_exist.tax_exempt_flag <> FND_API.G_MISS_char) and (rec_tax_rec_exist.tax_exempt_flag is not null)) then
6879 l_isDone := 'Y';
6880
6881 -- if there is tax_detail_id
6882 elsif ((rec_tax_rec_exist.tax_detail_id <> FND_API.G_MISS_NUM) and (rec_tax_rec_exist.tax_detail_id is not null)) then
6883 l_opCode := 'UPDATE';
6884 l_tax_detail_id := rec_tax_rec_exist.tax_detail_id;
6885 end if;
6886 end if; -- for merge cart cases
6887
6888 -- 2. if there isn't a record, continue
6889 if (l_isDone <> 'Y') then
6890 -- 2.1 populate the following fields:
6891 px_hd_Tax_Detail_Tbl(1).tax_detail_id := l_tax_detail_id;
6892 px_hd_Tax_Detail_Tbl(1).quote_header_id := p_qte_header_rec.quote_header_id;
6893 px_hd_Tax_Detail_Tbl(1).operation_code := l_opCode;
6894 -- px_hd_Tax_Detail_Tbl(1).quote_shipment_index := 1; // no need
6895 px_hd_Tax_Detail_Tbl(1).tax_exempt_flag := 'S';
6896 end if;
6897
6898 -- Standard call to get message count and if count is 1, get message info.
6899 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6900 p_count => x_msg_count ,
6901 p_data => x_msg_data);
6902 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6903 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultTaxExemption()');
6904 END IF;
6905 --IBE_Util.Disable_Debug;
6906
6907 EXCEPTION
6908 WHEN FND_API.G_EXC_ERROR THEN
6909 ROLLBACK TO getHdrDefTaxExmpt_pvt;
6910 x_return_status := FND_API.G_RET_STS_ERROR;
6911 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6912 p_count => x_msg_count ,
6913 p_data => x_msg_data);
6914 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6915 ROLLBACK TO getHdrDefTaxExmpt_pvt;
6916 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6917 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6918 p_count => x_msg_count ,
6919 p_data => x_msg_data);
6920 WHEN OTHERS THEN
6921 ROLLBACK TO getHdrDefTaxExmpt_pvt;
6922 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6923 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
6924 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
6925 l_api_name);
6926 END IF;
6927 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
6928 p_count => x_msg_count ,
6929 p_data => x_msg_data);
6930
6931 end getHdrDefaultTaxExemption;
6932
6933 PROCEDURE getHdrDefaultEndCustomer(
6934 P_Api_Version_Number IN NUMBER
6935 ,p_Init_Msg_List IN VARCHAR2 := FND_API.G_FALSE
6936 ,p_Commit IN VARCHAR2 := FND_API.G_FALSE
6937 ,p_hd_Shipment_TBL IN ASO_Quote_Pub.Shipment_tbl_Type
6938 ,px_qte_header_rec IN OUT NOCOPY ASO_Quote_Pub.Qte_Header_Rec_Type
6939 ,X_Return_Status OUT NOCOPY VARCHAR2
6940 ,X_Msg_Count OUT NOCOPY NUMBER
6941 ,X_Msg_Data OUT NOCOPY VARCHAR2
6942 )
6943 is
6944
6945 l_api_name CONSTANT VARCHAR2(30) := 'getHdrDefaultEndCustomer';
6946 l_api_version CONSTANT NUMBER := 1.0;
6947 l_isDone varchar2(1) := 'N';
6948
6949 cursor c_check_endTo_rec_exist(l_quote_header_id number)
6950 is
6951 select quote_header_id, end_customer_party_id, end_customer_cust_party_id, end_customer_party_site_id, end_customer_cust_account_id
6952 from ASO_quote_headers
6953 where QUOTE_HEADER_ID = l_quote_header_id;
6954 rec_endTo_rec_exist c_check_endTo_rec_exist%rowtype;
6955
6956 cursor c_get_shipTo_info(l_quote_header_id number)
6957 is
6958 select SHIP_TO_CUST_ACCOUNT_ID, ship_to_party_id, ship_to_party_site_id
6959 from aso_shipments
6960 where QUOTE_HEADER_ID = l_quote_header_id and
6961 quote_line_id is null;
6962 rec_shipTo_info c_get_shipTo_info%rowtype;
6963
6964 begin
6965
6966 -- Standard Start of API savepoint
6967 SAVEPOINT getHdrDefaultEndCustomer_pvt;
6968
6969 -- Standard call to check for call compatibility.
6970 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
6971 P_Api_Version_Number,
6972 L_API_NAME ,
6973 G_PKG_NAME )
6974 THEN
6975 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6976 END IF;
6977
6978 -- Initialize message list if p_init_msg_list is set to TRUE.
6979 IF FND_API.To_Boolean(p_init_msg_list) THEN
6980 FND_Msg_Pub.initialize;
6981 END IF;
6982
6983 -- Initialize API return status to success
6984 x_return_status := FND_API.G_RET_STS_SUCCESS;
6985
6986 -- API body
6987 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6988 IBE_Util.Debug('Begin IBE_Quote_Save_pvt.getHdrDefaultEndCustomer()');
6989 END IF;
6990
6991 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6992 IBE_Util.Debug('getHdrDefaultEndCustomer: px_qte_header_rec.quote_header_id='||px_qte_header_rec.quote_header_id);
6993 END IF;
6994
6995 if ((px_qte_header_rec.quote_header_id <> FND_API.G_MISS_NUM) and (px_qte_header_rec.quote_header_id is not null)) then
6996
6997 -- check to see if there is already an endTo info
6998 open c_check_endTo_rec_exist (px_qte_header_rec.quote_header_id);
6999 fetch c_check_endTo_rec_exist into rec_endTo_rec_exist;
7000 close c_check_endTo_rec_exist;
7001
7002 -- if there is no endTo info, then we shld try to default
7003 if ( ((rec_endTo_rec_exist.end_customer_PARTY_SITE_ID <> FND_API.G_MISS_NUM) and (rec_endTo_rec_exist.end_customer_PARTY_SITE_ID is not null)) or
7004 ((rec_endTo_rec_exist.end_customer_PARTY_SITE_ID <> FND_API.G_MISS_NUM) and (rec_endTo_rec_exist.end_customer_PARTY_SITE_ID is not null)) or
7005 ((rec_endTo_rec_exist.end_customer_cust_account_id <> FND_API.G_MISS_NUM) and (rec_endTo_rec_exist.end_customer_PARTY_SITE_ID is not null)) ) then
7006 l_isDone := 'Y';
7007 end if; -- check to see if we shld try to default
7008
7009 end if; -- for merge cart cases
7010
7011 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7012 IBE_Util.Debug('l_isDone ='||l_isDone);
7013 END IF;
7014
7015
7016 if (l_isDone <> 'Y') then
7017 if (p_hd_Shipment_TBL.count <> 0) then
7018 px_qte_header_rec.end_customer_cust_account_id := p_hd_Shipment_TBL(1).SHIP_TO_CUST_ACCOUNT_ID;
7019 px_qte_header_rec.end_customer_party_id := p_hd_Shipment_TBL(1).ship_to_party_id;
7020 px_qte_header_rec.end_customer_party_site_id := p_hd_Shipment_TBL(1).ship_to_party_site_id;
7021 else
7022 -- get shipto info directly from db
7023 open c_get_shipTo_info (px_qte_header_rec.quote_header_id);
7024 fetch c_get_shipTo_info into rec_shipTo_info;
7025 close c_get_shipTo_info;
7026
7027 px_qte_header_rec.end_customer_cust_account_id := rec_shipTo_info.SHIP_TO_CUST_ACCOUNT_ID;
7028 px_qte_header_rec.end_customer_party_id := rec_shipTo_info.ship_to_party_id;
7029 px_qte_header_rec.end_customer_party_site_id := rec_shipTo_info.ship_to_party_site_id;
7030 end if;
7031 end if; -- if (l_isDone <> 'Y')
7032
7033 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7034 IBE_Util.Debug('getHdrDefaultEndCustomer: px_qte_header_rec.end_customer_cust_account_id ='||px_qte_header_rec.end_customer_cust_account_id);
7035 IBE_Util.Debug('getHdrDefaultEndCustomer: px_qte_header_rec.end_customer_party_id ='||px_qte_header_rec.end_customer_party_id);
7036 IBE_Util.Debug('getHdrDefaultEndCustomer: px_qte_header_rec.end_customer_party_site_id ='||px_qte_header_rec.end_customer_party_site_id);
7037 END IF;
7038
7039 -- End of API body.
7040 -- Standard check of p_commit.
7041 IF FND_API.To_Boolean( p_commit ) THEN
7042 COMMIT WORK;
7043 END IF;
7044
7045 -- Standard call to get message count and if count is 1, get message info.
7046 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7047 p_count => x_msg_count ,
7048 p_data => x_msg_data);
7049 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7050 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultEndCustomer()');
7051 END IF;
7052 --IBE_Util.Disable_Debug;
7053
7054 EXCEPTION
7055 WHEN FND_API.G_EXC_ERROR THEN
7056 ROLLBACK TO getHdrDefaultEndCustomer_pvt;
7057 x_return_status := FND_API.G_RET_STS_ERROR;
7058 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7059 p_count => x_msg_count ,
7060 p_data => x_msg_data);
7061 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7062 ROLLBACK TO getHdrDefaultEndCustomer_pvt;
7063 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7064 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7065 p_count => x_msg_count ,
7066 p_data => x_msg_data);
7067 WHEN OTHERS THEN
7068 ROLLBACK TO getHdrDefaultEndCustomer_pvt;
7069 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7070 IF FND_Msg_Pub.Check_Msg_Level(FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR) THEN
7071 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
7072 l_api_name);
7073 END IF;
7074 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7075 p_count => x_msg_count ,
7076 p_data => x_msg_data);
7077
7078 end getHdrDefaultEndCustomer;
7079 /* ------------------------------ Default API's: End -----------------*/
7080
7081 PROCEDURE Create_Contract_For_Quote(
7082 P_Api_Version_Number IN NUMBER := OKC_API.G_MISS_NUM
7083 ,p_Init_Msg_List IN VARCHAR2 := OKC_API.G_FALSE
7084 ,p_quote_id IN OKX_QUOTE_HEADERS_V.ID1%TYPE
7085 ,p_rel_type IN OKC_K_REL_OBJS.RTY_CODE%TYPE := OKC_API.G_MISS_CHAR
7086 ,p_terms_agreed_flag IN VARCHAR2 := OKC_API.G_FALSE
7087 ,p_trace_mode IN VARCHAR2 := OKC_API.G_FALSE
7088 ,p_party_id IN NUMBER := FND_API.G_MISS_NUM
7089 ,p_cust_account_id IN NUMBER := FND_API.G_MISS_NUM
7090 ,p_quote_retrieval_number IN NUMBER := FND_API.G_MISS_NUM
7091 ,p_minisite_id IN NUMBER := FND_API.G_MISS_NUM
7092 ,p_validate_user IN VARCHAR2 := FND_API.G_FALSE
7093 ,p_url IN VARCHAR2 := FND_API.G_MISS_CHAR
7094 ,x_contract_id OUT NOCOPY OKC_K_HEADERS_B.ID%TYPE
7095 ,x_contract_number OUT NOCOPY OKC_K_HEADERS_B.CONTRACT_NUMBER%TYPE
7096 ,x_return_status OUT NOCOPY VARCHAR2
7097 ,x_msg_count OUT NOCOPY NUMBER
7098 ,x_msg_data OUT NOCOPY VARCHAR2
7099 )
7100 IS
7101
7102 l_api_name CONSTANT VARCHAR2(30) := 'Create_Contract_For_Quote';
7103 l_api_version CONSTANT NUMBER := 1.0;
7104
7105 BEGIN
7106
7107 -- Standard Start of API savepoint
7108 SAVEPOINT CREATECONTRACTFORQUOTE_pvt;
7109
7110 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7111 IBE_UTIL.DEBUG('REACHED CREATE_CONTRACT_FOR_QUOTE' || to_char(sysdate, 'mm/dd/yyyy:hh24:MI:SS'));
7112 END IF;
7113
7114
7115 -- Standard call to check for call compatibility.
7116 IF NOT FND_API.Compatible_API_Call(l_api_version,
7117 P_Api_Version_Number,
7118 l_api_name ,
7119 G_PKG_NAME )
7120 THEN
7121 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7122 END IF;
7123
7124 -- Initialize message list if p_init_msg_list is set to TRUE.
7125 IF FND_API.To_Boolean(p_Init_Msg_List) THEN
7126 FND_Msg_Pub.initialize;
7127 END IF;
7128 -- Initialize API return status to success
7129 x_return_status := FND_API.G_RET_STS_SUCCESS;
7130
7131 -- API body
7132
7133 -- User Authentication
7134 IBE_Quote_Misc_pvt.validate_user_update(
7135 p_init_msg_list => p_Init_Msg_List
7136 ,p_quote_header_id => p_quote_id
7137 ,p_party_id => p_party_id
7138 ,p_cust_account_id => p_cust_account_id
7139 ,p_quote_retrieval_number => p_quote_retrieval_number
7140 ,p_validate_user => p_validate_user
7141 ,x_return_status => x_return_status
7142 ,x_msg_count => x_msg_count
7143 ,x_msg_data => x_msg_data
7144 );
7145 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7146 RAISE FND_API.G_EXC_ERROR;
7147 END IF;
7148
7149 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7150 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7151 END IF;
7152
7153 --commented by makulkar for the bug 2572588.
7154 /*
7155 OKC_OC_INT_PUB.create_k_from_quote(
7156 p_api_version => P_Api_Version_Number
7157 ,p_init_msg_list => p_Init_Msg_List
7158 ,p_quote_id => p_quote_id
7159 ,p_rel_type => p_rel_type
7160 ,p_terms_agreed_flag => p_terms_agreed_flag
7161 ,p_trace_mode => p_trace_mode
7162 ,x_return_status => x_return_status
7163 ,x_msg_count => x_msg_count
7164 ,x_msg_data => x_msg_data
7165 ,x_contract_id => x_contract_id
7166 ,x_contract_number => x_contract_number
7167 );
7168 */
7169 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7170 IBE_Util.Debug('create contract, quote_id ='||p_quote_id);
7171 IBE_Util.Debug('create contract, rel_type ='||p_rel_type);
7172 IBE_Util.Debug('create contract, p_terms_agreed_flag ='||p_terms_agreed_flag);
7173 END IF;
7174
7175 aso_core_contracts_pub.create_contract(
7176 x_return_status => x_return_status
7177 ,x_msg_count => x_msg_count
7178 ,x_msg_data => x_msg_data
7179 ,x_contract_id => x_contract_id
7180 ,x_contract_number => x_contract_number
7181 ,p_api_version => P_Api_Version_Number
7182 ,p_init_msg_list => p_Init_Msg_List
7183 ,p_quote_id => p_quote_id
7184 ,p_rel_type => p_rel_type
7185 ,p_terms_agreed_flag => p_terms_agreed_flag
7186 );
7187
7188 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7189 RAISE FND_API.G_EXC_ERROR;
7190 END IF;
7191
7192 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7193 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7194 END IF;
7195
7196 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7197 IBE_Util.Debug('create contract, output contract_id ='||x_contract_id);
7198 IBE_Util.Debug('create contract, output contract_num ='||x_contract_number);
7199 END IF;
7200 /*Calling share_readonly to downgrade the access levels of all recipients to 'R' status,
7201 this is done because recipients cannot update a cart after it becomes a quote*/
7202 IF(IBE_UTIL.G_DEBUGON = 'Y') THEN
7203 IBE_UTIL.DEBUG('Calling share_readonly to downgrade the access levels of all recipients to R status');
7204 END IF;
7205 ibe_quote_saveshare_v2_pvt.share_readonly(
7206 p_quote_header_id => p_quote_id ,
7207 P_minisite_id => p_minisite_id ,
7208 p_api_version => P_Api_Version_Number,
7209 p_url => p_url ,
7210 p_init_msg_list => FND_API.G_FALSE ,
7211 p_commit => FND_API.G_FALSE ,
7212 x_return_status => x_return_status ,
7213 x_msg_count => x_msg_count ,
7214 x_msg_data => x_msg_data );
7215
7216 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7217 RAISE FND_API.G_EXC_ERROR;
7218 END IF;
7219 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7220 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7221 END IF;
7222 IF(IBE_UTIL.G_DEBUGON = 'Y') THEN
7223 IBE_UTIL.DEBUG('Done calling share_readonly');
7224 IBE_UTIL.DEBUG('Create_contract:Calling deactivate API');
7225 END IF;
7226
7227 IBE_QUOTE_SAVESHARE_V2_PVT.DEACTIVATE_QUOTE (
7228 P_Quote_header_id => p_quote_id ,
7229 P_Party_id => p_party_id ,
7230 P_Cust_account_id => p_cust_account_id ,
7231 p_api_version => P_Api_Version_Number,
7232 p_init_msg_list => fnd_api.g_false ,
7233 p_commit => fnd_api.g_false ,
7234 x_return_status => x_return_status ,
7235 x_msg_count => x_msg_count ,
7236 x_msg_data => x_msg_data );
7237 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7238 RAISE FND_API.G_EXC_ERROR;
7239 END IF;
7240
7241 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7242 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7243 END IF;
7244 IF(IBE_UTIL.G_DEBUGON = 'Y') THEN
7245 IBE_UTIL.DEBUG('Create_Contract:Deactivate owner cart after creating the contract:Done');
7246 END IF;
7247
7248
7249
7250 -- Standard call to get message count and if count is 1, get message info.
7251 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7252 p_count => x_msg_count ,
7253 p_data => x_msg_data);
7254 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7255 IBE_Util.Debug('End IBE_Quote_Save_pvt.getHdrDefaultTaxExemption()');
7256 END IF;
7257 --IBE_Util.Disable_Debug;
7258
7259
7260 EXCEPTION
7261
7262 WHEN FND_API.G_EXC_ERROR THEN
7263 ROLLBACK TO CREATECONTRACTFORQUOTE_pvt;
7264 x_return_status := FND_API.G_RET_STS_ERROR;
7265 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7266 p_count => x_msg_count,
7267 p_data => x_msg_data);
7268
7269 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7270 ROLLBACK TO CREATECONTRACTFORQUOTE_pvt;
7271 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7272 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7273 p_count => x_msg_count,
7274 p_data => x_msg_data);
7275
7276 WHEN OTHERS THEN
7277 ROLLBACK TO CREATECONTRACTFORQUOTE_pvt;
7278 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7279
7280 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7281 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,
7282 l_api_name);
7283 END IF;
7284
7285 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7286 p_count => x_msg_count,
7287 p_data => x_msg_data);
7288
7289 END CREATE_CONTRACT_FOR_QUOTE;
7290
7291 -- Duplicate Cart feature for 11.5.11 MaithiliK
7292
7293 PROCEDURE DUPLICATE_CART (
7294 P_Api_Version IN NUMBER ,
7295 p_Init_Msg_List IN VARCHAR2:= FND_API.G_FALSE ,
7296 p_Commit IN VARCHAR2:= FND_API.G_FALSE ,
7297 x_return_status OUT NOCOPY VARCHAR2 ,
7298 x_msg_count OUT NOCOPY NUMBER ,
7299 x_msg_data OUT NOCOPY VARCHAR2 ,
7300 x_last_update_date OUT NOCOPY Date ,
7301 x_quote_header_id OUT NOCOPY NUMBER ,
7302 p_last_update_date IN Date ,
7303 p_quote_header_id IN NUMBER:= FND_API.G_MISS_NUM,
7304 p_party_id IN NUMBER:= FND_API.G_MISS_NUM,
7305 p_cust_account_id IN NUMBER:= FND_API.G_MISS_NUM,
7306 p_validate_user IN VARCHAR2:= FND_API.G_FALSE ,
7307 P_new_quote_name IN VARCHAR2 ,
7308 p_retrieval_number IN NUMBER := FND_API.G_MISS_NUM,
7309 p_minisite_id IN NUMBER ) is
7310
7311 CURSOR c_check_for_quote(c_quote_header_id NUMBER) IS
7312 SELECT count(*) is_published_quote
7313 FROM ASO_QUOTE_HEADERS_ALL
7314 WHERE quote_header_id = c_quote_header_id
7315 AND resource_id is not null
7316 AND publish_flag = 'Y';
7317
7318 CURSOR c_is_shared_cart(c_quote_header_id NUMBER) IS
7319 select count(*) is_shared_cart
7320 from ibe_sh_quote_access
7321 where quote_header_id = c_quote_header_id;
7322
7323 rec_is_shared_cart c_is_shared_cart%rowtype;
7324 rec_check_for_quote c_check_for_quote%rowtype;
7325
7326
7327 G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBE_Quote_Save_pvt';
7328 l_api_name CONSTANT VARCHAR2(200) := 'Duplicate_cart';
7329 l_api_version NUMBER := 1.0;
7330
7331 l_to_qte_header_rec ASO_Quote_Pub.Qte_Header_Rec_Type
7332 := ASO_Quote_Pub.G_MISS_Qte_Header_Rec;
7333
7334 l_to_hd_shipment_tbl ASO_Quote_Pub.shipment_tbl_type;
7335
7336 l_to_qte_line_tbl ASO_Quote_Pub.qte_line_tbl_type;
7337 l_to_line_rltship_tbl ASO_Quote_Pub.Line_Rltship_tbl_Type;
7338 l_to_qte_line_dtl_tbl ASO_Quote_Pub.Qte_Line_Dtl_tbl_Type;
7339 l_to_line_attr_ext_tbl ASO_Quote_Pub.Line_Attribs_Ext_tbl_Type;
7340 l_to_ln_price_attributes_tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
7341
7342 -- added 12/22/03: PRG, no line merge
7343 l_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
7344 l_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
7345
7346 CURSOR c_get_orig_quote_details(p_quote_header_id NUMBER) IS
7347 SELECT order_type_id,currency_code, price_list_id -- bug 11805700,scnagara
7348 FROM aso_quote_headers
7349 WHERE quote_header_id = p_quote_header_id;
7350 l_order_type_id NUMBER;
7351 l_currency_code VARCHAR2(10);
7352 l_price_list_id NUMBER; -- bug 11805700,scnagara
7353
7354
7355 lx_quote_header_id NUMBER;
7356 lx_quote_number NUMBER;
7357 lx_return_status VARCHAR2(1);
7358 lx_msg_count NUMBER;
7359 lx_msg_data VARCHAR2(2000);
7360 lx_last_update_date DATE;
7361
7362 l_exp_date_profile_value NUMBER := FND_API.G_MISS_NUM;
7363 l_controlled_copy VARCHAR2(2) := FND_API.G_FALSE;
7364 l_copy_quote_header_rec ASO_Copy_Quote_Pub.Copy_Quote_Header_Rec_Type
7365 := ASO_Copy_Quote_Pub.G_MISS_Copy_Quote_Header_Rec;
7366 l_copy_quote_control_rec ASO_Copy_Quote_Pub.Copy_Quote_Control_Rec_Type
7367 := ASO_Copy_Quote_Pub.G_MISS_Copy_Quote_Control_Rec;
7368 l_quote_expiration_date DATE;
7369
7370 l_control_rec ASO_Quote_Pub.Control_Rec_Type;
7371 l_header_pricing_event VARCHAR2(30);
7372 Begin
7373
7374 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7375 ibe_util.debug('Start IBE_Quote_Save_pvt.DUPLICATE_CART()');
7376 IBE_UTIL.DEBUG('DUPLICATE_CART: Input values');
7377 IBE_UTIL.DEBUG('DUPLICATE_CART: p_last_update_date = '||p_last_update_date);
7378 IBE_UTIL.DEBUG('DUPLICATE_CART: p_party_id = '||p_party_id);
7379 IBE_UTIL.DEBUG('DUPLICATE_CART: p_cust_account_id = '||p_cust_account_id);
7380 IBE_UTIL.DEBUG('DUPLICATE_CART: p_validate_user = '||p_validate_user);
7381 IBE_UTIL.DEBUG('DUPLICATE_CART: P_new_quote_name = '||P_new_quote_name);
7382 IBE_UTIL.DEBUG('DUPLICATE_CART: p_retrieval_number = '||p_retrieval_number);
7383 IBE_UTIL.DEBUG('DUPLICATE_CART: p_minisite_id = '||p_minisite_id);
7384 END IF;
7385
7386 -- Standard Start of API savepoint
7387 SAVEPOINT Duplicate_Cart;
7388
7389 -- Standard call to check for call compatibility.
7390 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
7391 p_api_version,
7392 L_API_NAME ,
7393 G_PKG_NAME )
7394 THEN
7395 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7396 END IF;
7397
7398 -- Initialize message list if p_init_msg_list is set to TRUE.
7399 IF FND_API.To_Boolean(p_init_msg_list) THEN
7400 FND_Msg_Pub.initialize;
7401 END IF;
7402 -- Initialize API return status to success
7403 x_return_status := FND_API.G_RET_STS_SUCCESS;
7404
7405 --API Body
7406 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7407 IBE_UTIL.DEBUG('DUPLICATE_CART: Before Calling log_environment_info');
7408 END IF;
7409 IBE_Quote_Misc_pvt.log_environment_info();
7410 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7411 IBE_UTIL.DEBUG('DUPLICATE_CART: After Calling log_environment_info');
7412 IBE_UTIL.DEBUG('DUPLICATE_CART: p_retrieval_number = '||p_retrieval_number);
7413 IBE_UTIL.DEBUG('DUPLICATE_CART: p_new_quote_name = '||p_new_quote_name);
7414 END IF;
7415
7416 -- User Authentication
7417 IBE_Quote_Misc_pvt.Validate_User_Update
7418 ( p_init_msg_list => p_Init_Msg_List
7419 ,p_quote_header_id => p_quote_header_id
7420 ,p_party_id => p_party_id
7421 ,p_cust_account_id => p_cust_account_id
7422 ,p_validate_user => p_validate_user
7423 ,p_quote_retrieval_number => p_retrieval_number
7424 ,p_save_type => OP_DUPLICATE_CART
7425 ,p_last_update_date => p_last_update_date
7426 ,x_return_status => lx_return_status
7427 ,x_msg_count => lx_msg_count
7428 ,x_msg_data => lx_msg_data
7429 );
7430 IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
7431 RAISE FND_API.G_EXC_ERROR;
7432 END IF;
7433 IF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7434 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7435 END IF;
7436
7437 --Check for Shared Cart and Published Quote separately. If the cart is a Shared Cart (Even if end dated record)
7438 --OR published quote then set the l_controlled_copy flag to TRUE.
7439
7440 FOR rec_is_shared_cart in c_is_shared_cart(p_quote_header_id) LOOP
7441 IF (nvl(rec_is_shared_cart.is_shared_cart,0) > 0) THEN
7442 l_controlled_copy := FND_API.G_TRUE;
7443 END IF;
7444 END LOOP;
7445
7446 FOR rec_check_for_quote in c_check_for_quote(p_quote_header_id) LOOP
7447 IF (nvl(rec_check_for_quote.is_published_quote,0) > 0) THEN
7448 l_controlled_copy := FND_API.G_TRUE;
7449 END IF;
7450 END LOOP;
7451
7452 -- Get the expiration date from the Saved Cart expiration profile.
7453 l_exp_date_profile_value := FND_Profile.Value('IBE_EXP_SAVE_CART');
7454 l_quote_expiration_date := trunc(sysdate)+nvl(l_exp_date_profile_value,0);
7455
7456 -- Get Header Pricing event from IBE profile as it is needed for both calls (iStore duplicate cart logic and ASO copy quote)
7457 l_header_pricing_event := FND_Profile.Value('IBE_INCART_PRICING_EVENT');
7458
7459 -- If the cart is a shared cart or published quote, then copy only items and agreements and commitments if applicable
7460 -- Else call ASO copy_quote api to copy the entire cart.
7461
7462 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7463 IBE_UTIL.DEBUG('DUPLICATE_CART: l_controlled_copy='||l_controlled_copy);
7464 END IF;
7465
7466 IF (l_controlled_copy = FND_API.G_TRUE) THEN
7467 IBE_UTIL.DEBUG('l controlled copy is true, so calling istore apis for DUPLICATE');
7468 -- get order_type_id from the original quote header
7469 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7470 IBE_Util.Debug('Getting order_type_id,currency code from original quote header ' || p_quote_header_id);
7471 END IF;
7472
7473 OPEN c_get_orig_quote_details(p_quote_header_id);
7474 FETCH c_get_orig_quote_details INTO l_order_type_id,l_currency_code,l_price_list_id; -- bug 11805700, scnagara
7475 IF l_order_type_id IS NOT NULL THEN
7476 l_to_qte_header_rec.order_type_id := l_order_type_id;
7477 END IF;
7478 IF l_currency_code IS NOT NULL THEN
7479 l_to_qte_header_rec.currency_code := l_currency_code;
7480 END IF;
7481 IF l_price_list_id IS NOT NULL THEN
7482 l_to_qte_header_rec.price_list_id := l_price_list_id; -- bug 11805700, scnagara
7483 END IF;
7484 CLOSE c_get_orig_quote_details;
7485
7486 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7487 IBE_Util.Debug('order_type_id=' || l_order_type_id);
7488 IBE_Util.Debug('l_currency_code=' || l_currency_code);
7489 IBE_Util.Debug('l_price_list_id=' || l_price_list_id);
7490 END IF;
7491
7492 --construct header rec with other information
7493 l_to_qte_header_rec.quote_name := p_new_quote_name;
7494 l_to_qte_header_rec.party_id := p_party_id;
7495 l_to_qte_header_rec.cust_account_id := p_cust_account_id;
7496 l_to_qte_header_rec.quote_source_code := 'IStore Account';
7497 l_to_qte_header_rec.quote_expiration_date := l_quote_expiration_date;
7498
7499 -- get all line related information from original quote header id with p_mode = 'CONTROLLED_COPY'
7500 ibe_quote_saveshare_pvt.Copy_Lines
7501 ( p_api_version_number => 1.0
7502 ,p_init_msg_list => FND_API.G_FALSE
7503 ,p_commit => FND_API.G_FALSE
7504 ,x_Return_Status => x_Return_Status
7505 ,x_Msg_Count => x_Msg_Count
7506 ,x_Msg_Data => x_Msg_Data
7507 ,p_from_quote_header_id => p_quote_header_id
7508 ,p_to_quote_header_id => l_to_qte_header_rec.quote_header_id
7509 ,p_mode => 'CONTROLLED_COPY'
7510 ,x_qte_line_tbl => l_to_qte_line_tbl
7511 ,x_qte_line_dtl_tbl => l_to_qte_line_dtl_tbl
7512 ,x_line_attr_ext_tbl => l_to_line_attr_ext_tbl
7513 ,x_line_rltship_tbl => l_to_line_rltship_tbl
7514 ,x_ln_price_attributes_tbl => l_to_ln_price_attributes_tbl
7515 ,x_Price_Adjustment_tbl => l_Price_Adjustment_tbl
7516 ,x_Price_Adj_Rltship_tbl => l_Price_Adj_Rltship_tbl
7517 );
7518
7519 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7520 RAISE FND_API.G_EXC_ERROR;
7521 END IF;
7522 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7523 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7524 END IF;
7525
7526 l_to_hd_shipment_tbl(1).quote_header_id := l_to_qte_header_rec.quote_header_id;
7527
7528 -- Setup control record for pricing
7529 l_control_rec.pricing_request_type := 'ASO';
7530 l_control_rec.header_pricing_event := l_header_pricing_event;
7531 l_control_rec.line_pricing_event := FND_API.G_MISS_CHAR;
7532 l_control_rec.calculate_freight_charge_flag := 'Y';
7533 l_control_rec.calculate_tax_flag := 'Y';
7534
7535 -- Call save api to create a quote.
7536 IBE_Quote_Save_pvt.save(
7537 p_api_version_number => 1.0
7538 ,p_init_msg_list => FND_API.G_FALSE
7539 ,p_commit => FND_API.G_FALSE
7540 ,p_qte_header_rec => l_to_qte_header_rec
7541 ,p_Qte_Line_Tbl => l_to_qte_line_tbl
7542 ,p_Qte_Line_Dtl_Tbl => l_to_Qte_Line_Dtl_Tbl
7543 ,p_Line_rltship_tbl => l_to_Line_rltship_tbl
7544 ,p_save_type => OP_DUPLICATE_CART
7545 ,p_control_rec => l_control_rec
7546 ,p_hd_shipment_tbl => l_to_hd_shipment_tbl
7547 ,x_quote_header_id => lx_quote_header_id
7548 ,x_last_update_date => lx_last_update_date
7549 ,x_return_status => x_return_status
7550 ,x_msg_count => x_msg_count
7551 ,x_msg_data => x_msg_data
7552 );
7553 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7554 RAISE FND_API.G_EXC_ERROR;
7555 END IF;
7556 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7557 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7558 END IF;
7559
7560
7561
7562
7563 ELSE
7564 -- Regular cart, call ASO Copy Quote api for Duplicating an entire quote.
7565 l_copy_quote_header_rec.quote_header_id := p_quote_header_id;
7566 l_copy_quote_header_rec.quote_name := p_new_quote_name;
7567 l_copy_quote_header_rec.quote_expiration_date := l_quote_expiration_date;
7568 -- l_copy_quote_header_rec.pricing_status_indicator := 'I';
7569 l_copy_quote_control_rec.Pricing_Request_Type := 'ASO';
7570 l_copy_quote_control_rec.Header_Pricing_Event := l_header_pricing_event;
7571 l_copy_quote_control_rec.Calculate_Freight_Charge_Flag := 'Y';
7572 l_copy_quote_control_rec.Calculate_Tax_Flag := 'Y';
7573 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7574 IBE_UTIL.DEBUG('DUPLICATE_CART: Copy Quote Header Rec Values');
7575 IBE_UTIL.DEBUG('DUPLICATE_CART: quote_header_id = '||l_copy_quote_header_rec.quote_header_id);
7576 IBE_UTIL.DEBUG('DUPLICATE_CART: quote_name = '||l_copy_quote_header_rec.quote_name);
7577 IBE_UTIL.DEBUG('DUPLICATE_CART: quote_expiration_date = '||l_copy_quote_header_rec.quote_expiration_date);
7578 IBE_UTIL.DEBUG('DUPLICATE_CART: pricing_status_indicator = '||l_copy_quote_header_rec.pricing_status_indicator);
7579 IBE_UTIL.DEBUG('DUPLICATE_CART: Before calling ASO Copy Quote');
7580 END IF;
7581
7582 ASO_Copy_Quote_Pub.Copy_Quote(
7583 p_api_Version_Number => 1.0,
7584 p_init_msg_list => FND_API.G_FALSE,
7585 p_commit => FND_API.G_FALSE,
7586 p_copy_quote_header_rec => l_copy_quote_header_rec,
7587 p_copy_quote_control_rec => l_copy_quote_control_rec,
7588 x_qte_header_id => lx_quote_header_id,
7589 x_qte_number => lx_quote_number,
7590 x_return_status => lx_return_status,
7591 x_msg_count => lx_msg_count,
7592 x_msg_data => lx_msg_data);
7593
7594 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7595 IBE_UTIL.DEBUG('DUPLICATE_CART: After ASO Copy Quote call, return status='||lx_return_status);
7596 IBE_UTIL.DEBUG('DUPLICATE_CART: After ASO Copy Quote call, new quote header id='||lx_quote_header_id);
7597 END IF;
7598
7599 IF lx_return_status = FND_API.G_RET_STS_ERROR THEN
7600 RAISE FND_API.G_EXC_ERROR;
7601 END IF;
7602
7603 IF lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7604 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7605 END IF;
7606
7607
7608
7609
7610
7611 END IF;
7612 x_quote_header_id := lx_quote_header_id;
7613
7614 -- Standard call to get message count and if count is 1, get message info.
7615 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7616 p_count => x_msg_count ,
7617 p_data => x_msg_data);
7618 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7619 IBE_Util.Debug('End IBE_Quote_Save_pvt.Duplicate_cart');
7620 END IF;
7621 --IBE_Util.Disable_Debug;
7622
7623
7624 EXCEPTION
7625
7626 WHEN FND_API.G_EXC_ERROR THEN
7627 ROLLBACK TO Duplicate_Cart;
7628 x_return_status := FND_API.G_RET_STS_ERROR;
7629 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7630 p_count => x_msg_count,
7631 p_data => x_msg_data);
7632
7633 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7634 ROLLBACK TO Duplicate_Cart;
7635 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7636 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7637 p_count => x_msg_count,
7638 p_data => x_msg_data);
7639
7640 WHEN OTHERS THEN
7641 ROLLBACK TO Duplicate_Cart;
7642 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7643
7644 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7645 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,
7646 l_api_name);
7647 END IF;
7648
7649 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7650 p_count => x_msg_count,
7651 p_data => x_msg_data);
7652
7653
7654 END DUPLICATE_CART;
7655
7656 -- API NAME: RECONFIGURE_FROM_IB
7657 PROCEDURE RECONFIGURE_FROM_IB(
7658 p_api_version_number IN NUMBER := 1
7659 ,p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
7660 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
7661 ,p_Control_Rec IN ASO_QUOTE_PUB.Control_Rec_Type
7662 := ASO_QUOTE_PUB.G_Miss_Control_Rec
7663 ,p_Qte_Header_Rec IN ASO_QUOTE_PUB.Qte_Header_Rec_Type
7664 := ASO_QUOTE_PUB.G_MISS_Qte_Header_Rec
7665 ,p_instance_ids IN jtf_number_table := NULL
7666 ,x_config_line OUT NOCOPY ConfigCurTyp
7667 ,x_last_update_date OUT NOCOPY DATE
7668 ,x_return_status OUT NOCOPY VARCHAR2
7669 ,x_msg_count OUT NOCOPY NUMBER
7670 ,x_msg_data OUT NOCOPY VARCHAR2
7671 ) IS
7672 L_API_VERSION CONSTANT NUMBER := 1.0;
7673 l_api_name CONSTANT VARCHAR2(200) := 'Reconfigure_From_Ib';
7674 lx_last_update_date DATE;
7675 lx_quote_header_id NUMBER;
7676 l_inst_table_size NUMBER;
7677 l_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type;
7678 x_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type;
7679 l_control_rec ASO_Quote_Pub.Control_Rec_Type :=
7680 ASO_Quote_Pub.G_Miss_Control_Rec;
7681 l_instance_tbl ASO_QUOTE_HEADERS_PVT. Instance_Tbl_Type ;
7682 l_instance_rec ASO_QUOTE_HEADERS_PVT.Instance_rec_Type ;
7683
7684 l_refcursor_query VARCHAR2(1000) := 'select aql.quote_header_id,
7685 aql.quote_line_id,
7686 aql.inventory_item_id,
7687 aql.organization_id,
7688 aql.uom_code,
7689 aql.quantity,
7690 aqld.config_header_id,
7691 aqld.config_revision_num
7692 from aso_quote_lines_all aql,
7693 aso_quote_line_details AQLD
7694 where aqld.quote_line_id = aql.quote_line_id and
7695 aqld.ref_line_id is null and
7696 aql.quote_header_id = :1';
7697
7698 l_table_size PLS_INTEGER := 0;
7699 l_csi_config_rec CSI_CZ_INT.config_rec;
7700 l_instance_locked boolean := FALSE;
7701
7702 lx_Qte_Header_Rec ASO_Quote_Pub.Qte_Header_Rec_Type:=p_Qte_Header_Rec;
7703 lx_hd_Price_Attributes_Tbl ASO_Quote_Pub.Price_Attributes_Tbl_Type;
7704 lx_hd_Payment_Tbl ASO_Quote_Pub.Payment_Tbl_Type;
7705 lx_hd_Shipment_TBL ASO_Quote_Pub.Shipment_tbl_Type;
7706 lx_hd_Freight_Charge_Tbl ASO_Quote_Pub.Freight_Charge_Tbl_Type;
7707 lx_hd_Tax_Detail_Tbl ASO_Quote_Pub.Tax_Detail_Tbl_Type;
7708 lx_Price_Adjustment_Tbl ASO_Quote_Pub.Price_Adj_Tbl_Type;
7709 lx_Price_Adj_Attr_Tbl ASO_Quote_Pub.Price_Adj_Attr_Tbl_Type;
7710 lx_Price_Adj_Rltship_Tbl ASO_Quote_Pub.Price_Adj_Rltship_Tbl_Type;
7711
7712 BEGIN
7713 -- Standard Start of API savepoint
7714 SAVEPOINT Reconfigure_From_Ib;
7715
7716 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7717 IBE_UTIL.DEBUG('Begin Reconfigure_Form_IB');
7718 END IF;
7719
7720 -- Standard call to check for call compatibility.
7721 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
7722 P_Api_Version_Number,
7723 L_API_NAME ,
7724 G_PKG_NAME )
7725 THEN
7726 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7727 END IF;
7728
7729 -- Initialize message list if p_init_msg_list is set to TRUE.
7730 IF FND_API.To_Boolean(p_init_msg_list) THEN
7731 FND_Msg_Pub.initialize;
7732 END IF;
7733 -- Initialize API return status to success
7734 x_return_status := FND_API.G_RET_STS_SUCCESS;
7735
7736 --Call Check Instance Lock API
7737 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7738 IBE_UTIL.DEBUG('API CSI_CZ_INT.Check_Item_Instance_Lock() Starts');
7739 END IF;
7740
7741 l_table_size := p_instance_ids.COUNT;
7742 FOR i IN 1..l_table_size LOOP
7743 l_csi_config_rec.instance_id := p_instance_ids(i);
7744 l_instance_locked := CSI_CZ_INT.Check_Item_Instance_Lock(
7745 p_init_msg_list => p_init_msg_list
7746 ,p_config_rec => l_csi_config_rec
7747 ,x_return_status => x_return_status
7748 ,X_Msg_Count => x_Msg_Count
7749 ,X_Msg_Data => x_Msg_Data
7750 );
7751 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7752 IF(l_instance_locked = TRUE) THEN
7753 IBE_UTIL.debug('Instance Id '||p_instance_ids(i)||' islocked');
7754 ELSE
7755 IBE_UTIL.debug('Instance Id '||p_instance_ids(i)||' isNotlocked');
7756 END IF;
7757 END IF;
7758 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7759 RAISE FND_API.G_EXC_ERROR;
7760 END IF;
7761 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7762 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7763 END IF;
7764 IF (l_instance_locked = TRUE) THEN
7765 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7766 IBE_UTIL.debug('Instance Id '||p_instance_ids(i)||' is locked');
7767 END IF;
7768 x_return_status := FND_API.G_RET_STS_ERROR;
7769 FND_MESSAGE.Set_Name('FND', 'SQL_PLSQL_ERROR');
7770 FND_MESSAGE.Set_Token('ROUTINE', l_api_name);
7771 FND_MESSAGE.Set_Token('ERRNO', 'IB_INSTANCE_LOCKED');
7772 FND_MESSAGE.Set_Token('REASON','This instance is locked cannot reconfigure');
7773 FND_MSG_PUB.Add;
7774 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7775 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
7776 END IF;
7777 RAISE FND_API.G_EXC_ERROR;
7778 END IF;
7779 END LOOP;
7780
7781 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7782 IBE_UTIL.DEBUG('API CSI_CZ_INT.Check_Item_Instance_Lock() Ends::x_return_status'||x_return_status);
7783 END IF;
7784 --API Body
7785 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7786 IBE_UTIL.DEBUG('Call IBE_QUOTE_SAVE_PVT.Save()');
7787 END IF;
7788
7789 IBE_UTIL.DEBUG('Before call to getHdrDefaultValues()');
7790 getHdrDefaultValues(
7791 P_Api_Version_Number => p_api_version_number
7792 ,p_minisite_id => p_Qte_Header_Rec.minisite_id
7793 ,p_Qte_Header_Rec => p_Qte_Header_Rec
7794 ,x_Qte_Header_Rec => lx_Qte_Header_Rec
7795 ,x_hd_Price_Attributes_Tbl => lx_hd_Price_Attributes_Tbl
7796 ,x_hd_Payment_Tbl => lx_hd_Payment_Tbl
7797 ,x_hd_Shipment_TBL => lx_hd_Shipment_TBL
7798 ,x_hd_Freight_Charge_Tbl => lx_hd_Freight_Charge_Tbl
7799 ,x_hd_Tax_Detail_Tbl => lx_hd_Tax_Detail_Tbl
7800 ,x_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
7801 ,x_Price_Adj_Attr_Tbl => lx_Price_Adj_Attr_Tbl
7802 ,x_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
7803 ,x_last_update_date => x_last_update_date
7804 ,X_Return_Status => x_return_status
7805 ,X_Msg_Count => x_msg_count
7806 ,X_Msg_Data => x_msg_data
7807 );
7808 IBE_UTIL.DEBUG('After call to getHdrDefaultValues()');
7809
7810 Save(
7811 P_Api_Version_Number => p_api_version_number
7812 ,p_Init_Msg_List => p_init_msg_list
7813 ,p_Commit => p_commit
7814 ,p_Control_Rec => p_Control_Rec
7815 ,p_Qte_Header_Rec => lx_Qte_Header_Rec
7816 ,p_hd_Price_Attributes_Tbl => lx_hd_Price_Attributes_Tbl
7817 ,p_hd_Payment_Tbl => lx_hd_Payment_Tbl
7818 ,p_hd_Shipment_Tbl => lx_hd_Shipment_TBL
7819 ,p_hd_Freight_Charge_Tbl => lx_hd_Freight_Charge_Tbl
7820 ,p_hd_Tax_Detail_Tbl => lx_hd_Tax_Detail_Tbl
7821 ,p_Price_Adjustment_Tbl => lx_Price_Adjustment_Tbl
7822 ,p_Price_Adj_Attr_Tbl => lx_Price_Adj_Attr_Tbl
7823 ,p_Price_Adj_Rltship_Tbl => lx_Price_Adj_Rltship_Tbl
7824 ,x_quote_header_id => lx_quote_header_id
7825 ,x_last_update_date => lx_last_update_date
7826 ,X_Return_Status => x_Return_Status
7827 ,X_Msg_Count => x_Msg_Count
7828 ,X_Msg_Data => x_Msg_Data
7829 );
7830 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7831 RAISE FND_API.G_EXC_ERROR;
7832 END IF;
7833 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7834 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7835 END IF;
7836 --Instantiate Quote_Header_Rec and InstanceTable
7837 l_Qte_Header_Rec.quote_header_id := lx_quote_header_id;
7838 l_Qte_Header_Rec.last_update_date := lx_last_update_date;
7839
7840
7841 l_inst_table_size := p_instance_ids.COUNT;
7842 FOR i IN 1..l_inst_table_size LOOP
7843 l_instance_rec.instance_id := p_instance_ids(i);
7844 l_instance_tbl(i) := l_instance_rec;
7845 END LOOP;
7846 l_control_rec := p_control_rec;
7847 -- Call Config_Operations to copy the Config Details from CZ to ASO
7848 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7849 IBE_UTIL.DEBUG('API ASO_Config_Operations_Int.Config_Operations() Begin');
7850 END IF;
7851 ASO_CONFIG_OPERATIONS_INT.Config_Operations
7852 (
7853 P_Api_Version_Number => p_api_version_number
7854 ,p_Init_Msg_List => p_init_msg_list
7855 ,p_Commit => p_commit
7856 ,P_Control_Rec => l_control_rec
7857 ,P_Qte_Header_Rec => l_Qte_Header_Rec
7858 ,P_instance_tbl => l_instance_tbl
7859 ,p_operation_code => ASO_QUOTE_PUB.G_RECONFIGURE
7860 ,X_Return_Status => x_Return_Status
7861 ,X_Msg_Count => x_Msg_Count
7862 ,X_Msg_Data => x_Msg_Data
7863 ,x_Qte_Header_Rec => x_Qte_Header_Rec
7864 );
7865 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7866 IBE_UTIL.DEBUG('API CSI_CZ_INT.Check_Item_Instance_Lock() Ends::x_return_status'||x_return_status);
7867 END IF;
7868 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
7869 RAISE FND_API.G_EXC_ERROR;
7870 END IF;
7871 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
7872 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7873 END IF;
7874
7875 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7876 IBE_UTIL.DEBUG('Ref cursor x_config_line begin');
7877 END IF;
7878 open x_config_line for l_refcursor_query using l_Qte_Header_Rec.quote_header_id;
7879 -- End of API body.
7880 -- Standard check of p_commit.
7881 IF FND_API.To_Boolean( p_commit ) THEN
7882 COMMIT WORK;
7883 END IF;
7884
7885 -- Standard call to get message count and if count is 1, get message info.
7886 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
7887 p_count => x_msg_count ,
7888 p_data => x_msg_data);
7889 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7890 IBE_Util.Debug('End IBE_Quote_Save_pvt.Reconfigure_from_ib() end');
7891 END IF;
7892 EXCEPTION
7893 WHEN FND_API.G_EXC_ERROR THEN
7894 ROLLBACK TO Reconfigure_From_Ib;
7895 x_return_status := FND_API.G_RET_STS_ERROR;
7896 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7897 p_count => x_msg_count,
7898 p_data => x_msg_data);
7899
7900 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7901 ROLLBACK TO Reconfigure_From_Ib;
7902 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7903 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7904 p_count => x_msg_count,
7905 p_data => x_msg_data);
7906
7907 WHEN OTHERS THEN
7908 ROLLBACK TO Reconfigure_From_Ib;
7909 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7910
7911 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7912 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,
7913 l_api_name);
7914 END IF;
7915
7916 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
7917 p_count => x_msg_count,
7918 p_data => x_msg_data);
7919
7920 END RECONFIGURE_FROM_IB;
7921
7922 PROCEDURE ADD_CART_LEVEL_SERVICES(
7923 p_quote_header_id IN NUMBER,
7924 p_organization_id IN NUMBER,
7925 -- p_minisite_id IN NUMBER := FND_API.G_MISS_NUM,
7926 p_sva_line_id IN NUMBER,
7927 p_sva_line_qty IN NUMBER,
7928 p_svc_item_id_tbl IN JTF_NUMBER_TABLE,
7929 px_svc_period_tbl IN OUT NOCOPY JTF_VARCHAR2_TABLE_100,
7930 px_svc_duration_tbl IN OUT NOCOPY JTF_NUMBER_TABLE,
7931 px_svc_uom_tbl IN OUT NOCOPY JTF_VARCHAR2_TABLE_100,
7932
7933 px_quote_line_tbl IN OUT NOCOPY ASO_Quote_Pub.Qte_Line_Tbl_Type,
7934 px_line_rec_index IN OUT NOCOPY PLS_INTEGER,
7935 px_quote_line_dtl_tbl IN OUT NOCOPY ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type,
7936 px_dtl_rec_index IN OUT NOCOPY PLS_INTEGER)
7937 IS
7938
7939 i PLS_INTEGER := 1;
7940 l_idx PLS_INTEGER := 1;
7941 l_load_svc_detail BOOLEAN := FALSE;
7942
7943
7944 CURSOR c_get_svc_detail(p_svc_item_id NUMBER, p_org_id NUMBER) IS
7945 SELECT primary_uom_code, service_duration_period_code, service_duration
7946 FROM mtl_system_items
7947 WHERE inventory_item_id = p_svc_item_id and organization_id = p_org_id;
7948
7949 BEGIN
7950
7951 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7952 IBE_UTIL.debug('enter ADD_CART_LEVEL_SERVICES');
7953 END IF;
7954
7955 IF px_svc_period_tbl IS NULL THEN
7956 px_svc_period_tbl := JTF_VARCHAR2_TABLE_100();
7957 px_svc_duration_tbl := JTF_NUMBER_TABLE();
7958 px_svc_uom_tbl := JTF_VARCHAR2_TABLE_100();
7959 l_load_svc_detail := TRUE;
7960 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7961 IBE_UTIL.debug('l_load_svc_detail is true');
7962 END IF;
7963 ELSE
7964 l_load_svc_detail := FALSE;
7965 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7966 IBE_UTIL.debug('l_load_svc_detail is false');
7967 END IF;
7968 END IF;
7969
7970 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7971 IBE_UTIL.debug('loop through new svc items...');
7972 END IF;
7973 FOR i IN p_svc_item_id_tbl.FIRST..p_svc_item_id_tbl.LAST LOOP
7974 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7975 IBE_UTIL.debug('i='||i||', l_idx='||l_idx);
7976 END IF;
7977 IF l_load_svc_detail THEN
7978 px_svc_period_tbl.EXTEND;
7979 px_svc_duration_tbl.EXTEND;
7980 px_svc_uom_tbl.EXTEND;
7981 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7982 IBE_UTIL.debug('fetch service duration, period, and uom...');
7983 IBE_UTIL.debug('p_svc_item_id_tbl('||i||')='||p_svc_item_id_tbl(i));
7984 IBE_UTIL.debug('p_organization_id='||p_organization_id);
7985 END IF;
7986 OPEN c_get_svc_detail(p_svc_item_id_tbl(i),p_organization_id);
7987 FETCH c_get_svc_detail into px_svc_uom_tbl(l_idx),
7988 px_svc_period_tbl(l_idx),px_svc_duration_tbl(l_idx);
7989 CLOSE c_get_svc_detail;
7990 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7991 IBE_UTIL.debug('fetch is completed:');
7992 IBE_UTIL.debug('px_svc_uom_tbl('||l_idx||')='||px_svc_uom_tbl(l_idx));
7993 IBE_UTIL.debug('px_svc_period_tbl('||l_idx||')='||px_svc_period_tbl(l_idx));
7994 IBE_UTIL.debug('px_svc_duration_tbl('||l_idx||')='||px_svc_duration_tbl(l_idx));
7995 END IF;
7996 END IF;
7997
7998 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
7999 IBE_UTIL.debug('populate line rec, px_line_rec_index='||px_line_rec_index);
8000 END IF;
8001 px_quote_line_tbl(px_line_rec_index).item_type_code := 'SRV';
8002 px_quote_line_tbl(px_line_rec_index).operation_code := 'CREATE';
8003 px_quote_line_tbl(px_line_rec_index).quote_header_id := p_quote_header_id;
8004 px_quote_line_tbl(px_line_rec_index).inventory_item_id := p_svc_item_id_tbl(i);
8005 px_quote_line_tbl(px_line_rec_index).organization_id := p_organization_id;
8006 px_quote_line_tbl(px_line_rec_index).start_date_active := sysdate;
8007 px_quote_line_tbl(px_line_rec_index).uom_code := px_svc_uom_tbl(l_idx);
8008 -- always a dummy quantity to avoid vilation failure.
8009 -- ASO will derive the correct service quantities from SVA line
8010 px_quote_line_tbl(px_line_rec_index).quantity := p_sva_line_qty;
8011 --px_quote_line_tbl(px_line_rec_index).minisite_id := p_minisite_id;
8012
8013 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8014 IBE_UTIL.debug('populate line detail rec, px_dtl_rec_index='||px_dtl_rec_index);
8015 END IF;
8016 px_quote_line_dtl_tbl(px_dtl_rec_index).operation_code := 'CREATE';
8017 px_quote_line_dtl_tbl(px_dtl_rec_index).service_ref_line_id := p_sva_line_id;
8018 px_quote_line_dtl_tbl(px_dtl_rec_index).qte_line_index := px_line_rec_index;
8019 px_quote_line_dtl_tbl(px_dtl_rec_index).service_ref_type_code := 'QUOTE';
8020 px_quote_line_dtl_tbl(px_dtl_rec_index).service_period := px_svc_period_tbl(l_idx);
8021 IF px_svc_duration_tbl(l_idx) IS NOT NULL THEN
8022 px_quote_line_dtl_tbl(px_dtl_rec_index).service_duration := px_svc_duration_tbl(l_idx);
8023 END IF;
8024
8025 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8026 IBE_UTIL.debug('moving to next svc item ...');
8027 END IF;
8028 px_line_rec_index := px_line_rec_index + 1;
8029 px_dtl_rec_index := px_dtl_rec_index + 1;
8030 l_idx := l_idx + 1;
8031 END LOOP;
8032 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8033 IBE_UTIL.debug('exit ADD_CART_LEVEL_SERVICES with success');
8034 END IF;
8035 END ADD_CART_LEVEL_SERVICES;
8036
8037 PROCEDURE UPDATE_SUPPORT_AND_QUANTITY(
8038 p_api_version IN NUMBER,
8039 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
8040 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
8041 x_return_status OUT NOCOPY VARCHAR2,
8042 x_msg_count OUT NOCOPY NUMBER,
8043 x_msg_data OUT NOCOPY VARCHAR2,
8044
8045 p_quote_header_id IN NUMBER,
8046 p_quote_line_id_tbl IN JTF_NUMBER_TABLE := NULL,
8047 p_line_quantity_tbl IN JTF_NUMBER_TABLE := NULL,
8048 p_new_service_id_tbl IN JTF_NUMBER_TABLE := NULL,
8049 p_organization_id IN NUMBER := FND_API.G_MISS_NUM,
8050
8051 p_party_id IN NUMBER := FND_API.G_MISS_NUM,
8052 p_cust_account_id IN NUMBER := FND_API.G_MISS_NUM,
8053 p_sharee_number IN NUMBER := FND_API.G_MISS_NUM,
8054
8055 p_minisite_id IN NUMBER := FND_API.G_MISS_NUM,
8056 p_price_list_id IN NUMBER := FND_API.G_MISS_NUM,
8057 p_currency_code IN VARCHAR2 := FND_API.G_MISS_CHAR,
8058 p_header_pricing_event IN VARCHAR2 := FND_API.G_MISS_CHAR,
8059 p_save_type IN NUMBER := FND_API.G_MISS_NUM,
8060 p_last_update_date IN DATE := FND_API.G_MISS_DATE,
8061 x_last_update_date IN OUT NOCOPY DATE
8062 )
8063 IS
8064 l_api_name CONSTANT VARCHAR2(30) := 'UPDATE_SUPPORT_AND_QUANTITY';
8065 l_api_version CONSTANT NUMBER := 1.0;
8066
8067 l_sharee_party_id NUMBER := FND_API.G_MISS_NUM;
8068 l_sharee_cust_account_id NUMBER := FND_API.G_MISS_NUM;
8069
8070 l_quote_line_id_tbl JTF_NUMBER_TABLE := p_quote_line_id_tbl;
8071 l_line_quantity_tbl JTF_NUMBER_TABLE := p_line_quantity_tbl;
8072 l_new_service_id_tbl JTF_NUMBER_TABLE := p_new_service_id_tbl;
8073 l_new_service_period_tbl JTF_VARCHAR2_TABLE_100 := NULL;
8074 l_new_service_duration_tbl JTF_NUMBER_TABLE := NULL;
8075 l_new_service_uom_tbl JTF_VARCHAR2_TABLE_100 := NULL;
8076
8077 l_sva_line_size PLS_INTEGER := 0;
8078 l_curr_sva_line_id NUMBER := NULL;
8079 l_curr_line_qty NUMBER := NULL;
8080
8081 l_quote_header_id NUMBER := NULL;
8082 l_line_rec_size PLS_INTEGER := 0;
8083 l_line_qty_size PLS_INTEGER := 0;
8084 l_new_service_size PLS_INTEGER := 0;
8085 l_line_rec_index PLS_INTEGER := 1;
8086 l_dtl_rec_index PLS_INTEGER := 1;
8087 i PLS_INTEGER := 1;
8088
8089 l_map_index PLS_INTEGER := 1;
8090 l_deleted_svc_map_tbl JTF_VARCHAR2_TABLE_100 := NULL;
8091
8092 l_control_rec ASO_Quote_Pub.Control_Rec_Type := ASO_Quote_Pub.G_Miss_Control_Rec;
8093 l_quote_header_rec ASO_Quote_Pub.Qte_Header_Rec_Type := ASO_Quote_Pub.G_MISS_Qte_Header_Rec;
8094 l_quote_Line_Tbl ASO_Quote_Pub.Qte_Line_Tbl_Type := ASO_Quote_Pub.G_MISS_QTE_LINE_TBL;
8095 l_quote_Line_Dtl_Tbl ASO_Quote_Pub.Qte_Line_dtl_Tbl_Type := ASO_Quote_Pub.G_MISS_QTE_LINE_DTL_TBL;
8096
8097 CURSOR c_get_svc_lines(p_quote_header_id NUMBER) IS
8098 SELECT AQL.quote_line_id,ALD.service_ref_line_id,AQL.inventory_item_id
8099 FROM aso_quote_lines_all AQL, aso_quote_line_details ALD
8100 WHERE AQL.quote_header_id = p_quote_header_id and AQL.quote_line_id=ALD.quote_line_id
8101 and AQL.item_type_code='SRV'
8102 ORDER BY ALD.service_ref_line_id,AQL.inventory_item_id;
8103
8104 CURSOR c_get_sva_lines(p_quote_header_id NUMBER) IS
8105 SELECT quote_line_id, quantity FROM aso_quote_lines_all
8106 WHERE quote_header_id = p_quote_header_id and ITEM_TYPE_CODE='SVA'
8107 ORDER BY quote_line_id;
8108
8109 CURSOR c_get_line_qty(p_quote_line_id NUMBER) IS
8110 SELECT quantity FROM aso_quote_lines_all
8111 WHERE quote_line_id = p_quote_line_id;
8112 BEGIN
8113 -- Standard Start of API savepoint
8114 SAVEPOINT UPDATE_SUPPORT_LEVEL_AND_QTY;
8115
8116 -- Standard initialization tasks
8117 -- Standard call to check for call compatibility.
8118 IF NOT FND_API.Compatible_API_Call (l_api_version,p_api_version,l_api_name,G_PKG_NAME) THEN
8119 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8120 END IF;
8121
8122 -- Initialize message list if p_init_msg_list is set to TRUE.
8123 IF FND_API.to_Boolean(p_init_msg_list) THEN
8124 FND_MSG_PUB.initialize;
8125 END IF;
8126
8127 -- Initialize API return status to success.
8128 x_return_status := FND_API.G_RET_STS_SUCCESS;
8129
8130 -- Print debugging info.
8131 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8132 IBE_UTIL.debug(G_PKG_NAME||'.'||l_api_name||' Begin');
8133 IBE_UTIL.debug('p_quote_header_id = ' || p_quote_header_id);
8134 END IF;
8135
8136 IF p_quote_line_id_tbl IS NOT NULL THEN
8137 l_line_rec_size := p_quote_line_id_tbl.count;
8138 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8139 IBE_UTIL.debug('p_quote_line_id_tbl.count= ' ||l_line_rec_size);
8140 END IF;
8141 END IF;
8142
8143 IF p_line_quantity_tbl IS NOT NULL THEN
8144 l_line_qty_size := p_line_quantity_tbl.count;
8145 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8146 IBE_UTIL.debug('p_line_quantity_tbl.count= ' || l_line_qty_size);
8147 END IF;
8148 END IF;
8149
8150 IF p_new_service_id_tbl IS NOT NULL THEN
8151 l_new_service_size := p_new_service_id_tbl.count;
8152 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8153 IBE_UTIL.debug('p_new_service_id_tbl.count= ' || l_new_service_size);
8154 END IF;
8155 END IF;
8156
8157 -- validating input parameters
8158 IF p_quote_header_id IS NULL THEN
8159 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8160 IBE_UTIL.debug('Invalid input parameters, quote header id is null');
8161 END IF;
8162 x_return_status := FND_API.G_RET_STS_ERROR;
8163 FND_MESSAGE.Set_Name('FND', 'SQL_PLSQL_ERROR');
8164 FND_MESSAGE.Set_Token('ROUTINE', l_api_name);
8165 FND_MESSAGE.Set_Token('ERRNO', 'IBE_ST_INVALID_OPERATION');
8166 FND_MESSAGE.Set_Token('REASON', 'quote header id is null');
8167 FND_MSG_PUB.Add;
8168 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8169 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
8170 END IF;
8171 RAISE FND_API.G_EXC_ERROR;
8172 END IF;
8173
8174 IF l_line_qty_size>0 AND l_line_qty_size = l_line_rec_size THEN
8175 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8176 IBE_UTIL.debug('Need to update quantity');
8177 END IF;
8178 ELSIF l_line_qty_size=0 THEN
8179 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8180 IBE_UTIL.debug('No need to update quantity');
8181 END IF;
8182 ELSE
8183 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8184 IBE_UTIL.debug('Invalid input parameters, size of line records does not match size of line quantities');
8185 END IF;
8186 x_return_status := FND_API.G_RET_STS_ERROR;
8187 FND_MESSAGE.Set_Name('FND', 'SQL_PLSQL_ERROR');
8188 FND_MESSAGE.Set_Token('ROUTINE', l_api_name);
8189 FND_MESSAGE.Set_Token('ERRNO', 'IBE_ST_INVALID_OPERATION');
8190 FND_MESSAGE.Set_Token('REASON', 'size of line records does not match size of line quantities');
8191 FND_MSG_PUB.Add;
8192 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8193 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
8194 END IF;
8195 RAISE FND_API.G_EXC_ERROR;
8196 END IF;
8197
8198 -- update quantities
8199 IF l_line_qty_size>0 THEN
8200 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8201 IBE_UTIL.debug('updating quantities, l_line_rec_index='||l_line_rec_index);
8202 END IF;
8203 FOR l_line_rec_index IN 1..l_line_qty_size LOOP
8204 l_quote_line_tbl(l_line_rec_index).quote_header_id := p_quote_header_id;
8205 l_quote_line_tbl(l_line_rec_index).quote_line_id := p_quote_line_id_tbl(l_line_rec_index);
8206 l_quote_line_tbl(l_line_rec_index).quantity := p_line_quantity_tbl(l_line_rec_index);
8207 l_quote_line_tbl(l_line_rec_index).operation_code := 'UPDATE';
8208 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8209 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index);
8210 IBE_UTIL.debug('quote_line_id='||l_quote_line_tbl(l_line_rec_index).quote_line_id);
8211 IBE_UTIL.debug('quantity='||l_quote_line_tbl(l_line_rec_index).quantity);
8212 END IF;
8213 END LOOP;
8214 l_line_rec_index := l_line_rec_index + 1;
8215 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8216 IBE_UTIL.debug('quantities updated, l_line_rec_index='||l_line_rec_index);
8217 END IF;
8218 ELSIF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8219 IBE_UTIL.debug('no quantity updated, l_line_rec_index='||l_line_rec_index);
8220 END IF;
8221
8222 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8223 IBE_UTIL.debug('updating cart level support...');
8224 IBE_UTIL.debug('checking existing cart level services...');
8225 END IF;
8226
8227 FOR rec_svc_line IN c_get_svc_lines(p_quote_header_id) LOOP
8228 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8229 IBE_UTIL.debug('found service line:');
8230 IBE_UTIL.debug('service_ref_line_id='||rec_svc_line.service_ref_line_id);
8231 IBE_UTIL.debug('quote_line_id='||rec_svc_line.quote_line_id);
8232 IBE_UTIL.debug('l_curr_sva_line_id='||l_curr_sva_line_id);
8233 END IF;
8234 IF l_curr_sva_line_id IS NULL OR l_curr_sva_line_id <> rec_svc_line.service_ref_line_id THEN
8235 -- start a new sva line
8236 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8237 IBE_UTIL.debug('starts a new SVA line, l_curr_sva_line_id='||l_curr_sva_line_id);
8238 END IF;
8239
8240 IF l_curr_sva_line_id IS NOT NULL AND l_new_service_id_tbl IS NOT NULL THEN
8241 -- not the first sva line, add new services to previous SVA line first
8242 IF l_new_service_id_tbl.COUNT >0 THEN
8243 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8244 IBE_UTIL.debug('not the first sva line');
8245 IBE_UTIL.debug('adding new services to previous SVA line...:');
8246 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index);
8247 IBE_UTIL.debug('l_dtl_rec_index='||l_dtl_rec_index);
8248 END IF;
8249 ADD_CART_LEVEL_SERVICES(
8250 p_quote_header_id =>p_quote_header_id,
8251 p_organization_id =>p_organization_id,
8252 -- p_minisite_id =>p_minisite_id,
8253 p_sva_line_id =>l_curr_sva_line_id,
8254 p_sva_line_qty =>l_curr_line_qty,
8255 p_svc_item_id_tbl =>l_new_service_id_tbl,
8256 px_svc_period_tbl =>l_new_service_period_tbl,
8257 px_svc_duration_tbl =>l_new_service_duration_tbl,
8258 px_svc_uom_tbl =>l_new_service_uom_tbl,
8259 px_quote_line_tbl =>l_quote_line_tbl,
8260 px_line_rec_index =>l_line_rec_index,
8261 px_quote_line_dtl_tbl =>l_quote_line_dtl_tbl,
8262 px_dtl_rec_index =>l_dtl_rec_index);
8263 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8264 IBE_UTIL.debug('new services added:');
8265 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index);
8266 IBE_UTIL.debug('l_dtl_rec_index='||l_dtl_rec_index);
8267 END IF;
8268 ELSIF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8269 IBE_UTIL.debug('no new service need to be added.');
8270 END IF;
8271 END IF;
8272
8273 -- move to the new line
8274 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8275 IBE_UTIL.debug('initializing the new SVA line...');
8276 END IF;
8277 l_curr_sva_line_id := rec_svc_line.service_ref_line_id;
8278 l_sva_line_size := l_sva_line_size + 1;
8279 l_map_index := 1;
8280
8281 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8282 IBE_UTIL.debug('l_sva_line_size='||l_sva_line_size);
8283 IBE_UTIL.debug('checking if need to update quantity...');
8284 END IF;
8285 l_curr_line_qty := NULL;
8286 IF l_quote_line_id_tbl IS NOT NULL AND l_line_quantity_tbl IS NOT NULL THEN
8287 i := l_quote_line_id_tbl.FIRST;
8288 WHILE i <= l_quote_line_id_tbl.LAST LOOP
8289 IF l_quote_line_id_tbl(i) = l_curr_sva_line_id THEN
8290 l_curr_line_qty := p_line_quantity_tbl(i);
8291 l_quote_line_id_tbl.DELETE(i);
8292 l_line_quantity_tbl.DELETE(i);
8293 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8294 IBE_UTIL.debug('a new quantity is entered, l_curr_line_qty='||l_curr_line_qty);
8295 END IF;
8296 EXIT;
8297 ELSE
8298 i := l_quote_line_id_tbl.NEXT(i);
8299 END IF;
8300 END LOOP;
8301 END IF;
8302 IF l_curr_line_qty IS NULL THEN
8303 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8304 IBE_UTIL.debug('no quantity entered, loading from db...');
8305 END IF;
8306 OPEN c_get_line_qty(l_curr_sva_line_id);
8307 FETCH c_get_line_qty into l_curr_line_qty;
8308 CLOSE c_get_line_qty;
8309 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8310 IBE_UTIL.debug('quantity loaded, l_curr_line_qty='||l_curr_line_qty);
8311 END IF;
8312 END IF;
8313 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8314 IBE_UTIL.debug('new SVA line initialized, l_sva_line_size='||l_sva_line_size);
8315 END IF;
8316 ELSE
8317 l_map_index := l_map_index + 1;
8318 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8319 IBE_UTIL.debug('remains in the same SVA line');
8320 END IF;
8321 END IF;
8322
8323 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8324 IBE_UTIL.debug('ready to processe current svc line, l_line_rec_index='||l_line_rec_index);
8325 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index ||', l_dtl_rec_index='||l_dtl_rec_index);
8326 IBE_UTIL.debug('l_map_index='||l_map_index);
8327 END IF;
8328
8329 IF l_sva_line_size = 1 THEN
8330 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8331 IBE_UTIL.debug('The first SVA line detected');
8332 END IF;
8333 IF l_deleted_svc_map_tbl IS NULL THEN
8334 l_deleted_svc_map_tbl := JTF_VARCHAR2_TABLE_100();
8335 END IF;
8336 l_deleted_svc_map_tbl.EXTEND;
8337 l_deleted_svc_map_tbl(l_map_index) := 'DELETE';
8338 IF l_new_service_id_tbl IS NOT NULL AND l_new_service_id_tbl.count >0 THEN
8339 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8340 IBE_UTIL.debug('populating l_deleted_svc_map_tbl table,l_map_index='||l_map_index);
8341 END IF;
8342 i := l_new_service_id_tbl.FIRST;
8343 WHILE i <= l_new_service_id_tbl.LAST LOOP
8344 IF rec_svc_line.inventory_item_id = l_new_service_id_tbl(i) THEN
8345 l_deleted_svc_map_tbl(l_map_index) := 'KEEP'; -- keep the svc item
8346 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8347 IBE_UTIL.debug('skipping svc line, inventory_item_id='||rec_svc_line.inventory_item_id);
8348 END IF;
8349 l_new_service_id_tbl.DELETE(i);
8350 EXIT;
8351 ELSE
8352 i := l_new_service_id_tbl.NEXT(i);
8353 END IF;
8354 END LOOP;
8355 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8356 IBE_UTIL.debug('l_deleted_svc_map_tbl('||l_map_index||')='||l_deleted_svc_map_tbl(l_map_index));
8357 END IF;
8358 END IF;
8359 END IF;
8360
8361 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8362 IBE_UTIL.debug('applying l_deleted_svc_map_tbl table, service item='||rec_svc_line.inventory_item_id);
8363 IBE_UTIL.debug('l_map_index='||l_map_index||', opcode='||l_deleted_svc_map_tbl(l_map_index));
8364 END IF;
8365 IF l_deleted_svc_map_tbl(l_map_index) = 'DELETE' THEN
8366 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8367 IBE_UTIL.debug('deleting svc line, inventory_item_id='||rec_svc_line.inventory_item_id);
8368 END IF;
8369 l_quote_line_tbl(l_line_rec_index).operation_code := 'DELETE';
8370 l_quote_line_tbl(l_line_rec_index).quote_line_id := rec_svc_line.quote_line_id;
8371 l_quote_line_tbl(l_line_rec_index).quote_header_id := p_quote_header_id;
8372 l_line_rec_index := l_line_rec_index + 1;
8373 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8374 IBE_UTIL.debug('svc line deleted, l_line_rec_index='||l_line_rec_index);
8375 END IF;
8376 ELSIF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8377 IBE_UTIL.debug('svc line skipped (no change)');
8378 END IF;
8379 EXIT WHEN c_get_svc_lines%NOTFOUND;
8380 END LOOP;
8381
8382 IF l_sva_line_size > 0 AND l_new_service_id_tbl IS NOT NULL THEN
8383 -- add new services the last line if exist
8384 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8385 IBE_UTIL.debug('the last SVA line detected,l_sva_line_size='||l_sva_line_size);
8386 END IF;
8387 IF l_new_service_id_tbl.COUNT >0 THEN
8388 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8389 IBE_UTIL.debug('adding new services the last SVA line,l_new_service_id_tbl.COUNT='||l_new_service_id_tbl.COUNT);
8390 END IF;
8391 ADD_CART_LEVEL_SERVICES(
8392 p_quote_header_id =>p_quote_header_id,
8393 p_organization_id =>p_organization_id,
8394 -- p_minisite_id =>p_minisite_id,
8395 p_sva_line_id =>l_curr_sva_line_id,
8396 p_sva_line_qty =>l_curr_line_qty,
8397 p_svc_item_id_tbl =>l_new_service_id_tbl,
8398 px_svc_period_tbl =>l_new_service_period_tbl,
8399 px_svc_duration_tbl =>l_new_service_duration_tbl,
8400 px_svc_uom_tbl =>l_new_service_uom_tbl,
8401 px_quote_line_tbl =>l_quote_line_tbl,
8402 px_line_rec_index =>l_line_rec_index,
8403 px_quote_line_dtl_tbl =>l_quote_line_dtl_tbl,
8404 px_dtl_rec_index =>l_dtl_rec_index);
8405 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8406 IBE_UTIL.debug('new services added to the last SVA line,l_line_rec_index='||l_line_rec_index);
8407 IBE_UTIL.debug('l_dtl_rec_index='||l_dtl_rec_index);
8408 END IF;
8409 ELSIF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8410 IBE_UTIL.debug('no new service need to be added to the last SVA line.');
8411 END IF;
8412 ELSIF l_new_service_id_tbl IS NOT NULL AND l_new_service_id_tbl.COUNT >0 THEN
8413 -- no previous cart level services found,retrieve sva lines
8414 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8415 IBE_UTIL.debug('Current support level is NONE, directly adding new services...');
8416 IBE_UTIL.debug('Retrieving SVA lines, l_new_service_id_tbl.COUNT'||l_new_service_id_tbl.COUNT);
8417 END IF;
8418 FOR rec_sva_line IN c_get_sva_lines(p_quote_header_id) LOOP
8419 l_curr_sva_line_id := rec_sva_line.quote_line_id;
8420 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8421 IBE_UTIL.debug('found SVA line, l_curr_sva_line_id='||l_curr_sva_line_id);
8422 IBE_UTIL.debug('checking quantity...');
8423 END IF;
8424 l_curr_line_qty := NULL;
8425 IF l_quote_line_id_tbl IS NOT NULL AND p_line_quantity_tbl IS NOT NULL THEN
8426 i := l_quote_line_id_tbl.FIRST;
8427 WHILE i <= l_quote_line_id_tbl.LAST LOOP
8428 IF l_quote_line_id_tbl(i) = l_curr_sva_line_id THEN
8429 l_curr_line_qty := p_line_quantity_tbl(i);
8430 l_quote_line_id_tbl.DELETE(i);
8431 l_line_quantity_tbl.DELETE(i);
8432 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8433 IBE_UTIL.debug('a new quantity is entered, l_curr_line_qty='||l_curr_line_qty);
8434 END IF;
8435 EXIT;
8436 ELSE
8437 i := l_quote_line_id_tbl.NEXT(i);
8438 END IF;
8439 END LOOP;
8440 END IF;
8441 IF l_curr_line_qty IS NULL THEN
8442 l_curr_line_qty := rec_sva_line.quantity;
8443 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8444 IBE_UTIL.debug('no quantity entered, default from db: '||l_curr_line_qty);
8445 END IF;
8446 END IF;
8447
8448 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8449 IBE_UTIL.debug('before adding new services, l_curr_sva_line_id='||l_curr_sva_line_id);
8450 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index);
8451 IBE_UTIL.debug('l_dtl_rec_index='||l_dtl_rec_index);
8452 END IF;
8453 ADD_CART_LEVEL_SERVICES(
8454 p_quote_header_id =>p_quote_header_id,
8455 p_organization_id =>p_organization_id,
8456 -- p_minisite_id =>p_minisite_id,
8457 p_sva_line_id =>l_curr_sva_line_id,
8458 p_sva_line_qty =>l_curr_line_qty,
8459 p_svc_item_id_tbl =>l_new_service_id_tbl,
8460 px_svc_period_tbl =>l_new_service_period_tbl,
8461 px_svc_duration_tbl =>l_new_service_duration_tbl,
8462 px_svc_uom_tbl =>l_new_service_uom_tbl,
8463 px_quote_line_tbl =>l_quote_line_tbl,
8464 px_line_rec_index =>l_line_rec_index,
8465 px_quote_line_dtl_tbl =>l_quote_line_dtl_tbl,
8466 px_dtl_rec_index =>l_dtl_rec_index);
8467 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8468 IBE_UTIL.debug('new services added:');
8469 IBE_UTIL.debug('l_line_rec_index='||l_line_rec_index);
8470 IBE_UTIL.debug('l_dtl_rec_index='||l_dtl_rec_index);
8471 END IF;
8472 EXIT WHEN c_get_sva_lines%NOTFOUND;
8473 END LOOP;
8474 END IF;
8475
8476 IF l_quote_line_tbl IS NULL OR l_quote_line_tbl.count=0 THEN
8477 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8478 IBE_UTIL.debug('nothing to update, returning...');
8479 END IF;
8480 RETURN;
8481 END IF;
8482
8483 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8484 IBE_UTIL.debug('setup control record...');
8485 END IF;
8486 l_control_rec.pricing_request_type := 'ASO';
8487 l_control_rec.header_pricing_event := p_header_pricing_event;
8488 l_control_rec.calculate_tax_flag := 'Y';
8489 l_control_rec.calculate_freight_charge_flag := 'Y';
8490
8491 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8492 IBE_UTIL.debug('header_pricing_event='||p_header_pricing_event);
8493 IBE_UTIL.debug('setup header record...');
8494 END IF;
8495 l_quote_header_rec.pricing_status_indicator := 'C';
8496 l_quote_header_rec.tax_status_indicator := 'C';
8497 l_quote_header_rec.quote_header_id := p_quote_header_id;
8498 l_quote_header_rec.currency_code := p_currency_code;
8499 l_quote_header_rec.price_list_id := p_price_list_id;
8500
8501 IF (FND_Profile.Value('IBE_PRICE_CHANGED_LINES') = 'Y') THEN -- bug 10638145, scnagara
8502 l_control_rec.price_mode := 'CHANGE_LINE';
8503 l_quote_header_rec.PRICING_STATUS_INDICATOR := 'I';
8504 l_quote_header_rec.TAX_STATUS_INDICATOR := 'I';
8505 ELSE
8506 l_control_rec.price_mode := 'ENTIRE_QUOTE';
8507 l_quote_header_rec.PRICING_STATUS_INDICATOR := 'C';
8508 l_quote_header_rec.TAX_STATUS_INDICATOR := 'C';
8509 END IF;
8510
8511 IF p_sharee_number IS NULL THEN
8512 l_quote_header_rec.cust_account_id := p_cust_account_id;
8513 l_quote_header_rec.party_id := p_party_id;
8514 ELSE
8515 l_sharee_party_id := p_party_id;
8516 l_sharee_cust_account_id := p_cust_account_id;
8517 END IF;
8518 l_quote_header_rec.last_update_date := p_last_update_date;
8519
8520 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8521 IBE_UTIL.debug('quote_header_id='||p_quote_header_id);
8522 IBE_UTIL.debug('currency_code='||p_currency_code);
8523 IBE_UTIL.debug('price_list_id='||p_price_list_id);
8524 IBE_UTIL.debug('p_sharee_number='||p_sharee_number);
8525 IBE_UTIL.debug('cust_account_id='||p_cust_account_id);
8526 IBE_UTIL.debug('party_id='||p_party_id);
8527 IBE_UTIL.debug('l_sharee_party_id='||l_sharee_party_id);
8528 IBE_UTIL.debug('l_sharee_cust_account_id='||l_sharee_cust_account_id);
8529
8530 IBE_UTIL.debug('call IBE_QUOTE_SAVE_PVT.SAVE...');
8531 IBE_UTIL.debug('p_minisite_id='||p_minisite_id);
8532 IBE_UTIL.debug('p_save_type='||p_save_type);
8533 END IF;
8534 SAVE(p_api_version_number => p_api_version
8535 ,p_init_msg_list => FND_API.G_FALSE
8536 ,p_commit => FND_API.G_FALSE
8537 ,p_auto_update_active_quote => FND_API.G_FALSE
8538 ,p_combinesameitem => 1
8539
8540 ,p_sharee_number => p_sharee_number
8541 ,p_sharee_party_id => l_sharee_party_id
8542 ,p_sharee_cust_account_id => l_sharee_cust_account_id
8543
8544 ,p_minisite_id => p_minisite_id
8545 ,p_control_rec => l_control_rec
8546 ,p_qte_header_rec => l_quote_header_rec
8547 ,p_qte_line_tbl => l_quote_line_tbl
8548 ,p_qte_line_dtl_tbl => l_quote_line_dtl_tbl
8549 ,p_save_type => p_save_type
8550 ,x_quote_header_id => l_quote_header_id
8551 ,x_last_update_date => x_last_update_date
8552 ,x_return_status => x_return_status
8553 ,x_msg_count => x_msg_count
8554 ,x_msg_data => x_msg_data);
8555 IF (IBE_UTIL.G_DEBUGON = FND_API.G_TRUE) THEN
8556 IBE_UTIL.debug('returned from IBE_QUOTE_SAVE_PVT.SAVE');
8557 IBE_UTIL.debug('l_quote_header_id='||l_quote_header_id);
8558 IBE_UTIL.debug('x_last_update_date='||x_last_update_date);
8559 IBE_UTIL.debug('x_return_status='||x_return_status);
8560 IBE_UTIL.debug('x_msg_count='||x_msg_count);
8561 IBE_UTIL.debug('x_msg_data='||x_msg_data);
8562 IBE_UTIL.debug(G_PKG_NAME||'.'||l_api_name||' End');
8563 END IF;
8564 EXCEPTION
8565 WHEN FND_API.G_EXC_ERROR THEN
8566 ROLLBACK TO UPDATE_SUPPORT_LEVEL_AND_QTY;
8567 x_return_status := FND_API.G_RET_STS_ERROR;
8568 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
8569 p_count => x_msg_count,
8570 p_data => x_msg_data);
8571
8572 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8573 ROLLBACK TO UPDATE_SUPPORT_LEVEL_AND_QTY;
8574 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8575 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
8576 p_count => x_msg_count,
8577 p_data => x_msg_data);
8578
8579 WHEN OTHERS THEN
8580 ROLLBACK TO UPDATE_SUPPORT_LEVEL_AND_QTY;
8581 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8582 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8583 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
8584 END IF;
8585 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
8586 p_count => x_msg_count,
8587 p_data => x_msg_data);
8588 END UPDATE_SUPPORT_AND_QUANTITY;
8589
8590 END ibe_quote_save_pvt;