[Home] [Help]
PACKAGE BODY: APPS.OE_QUOTE_UTIL
Source
1 PACKAGE BODY OE_Quote_Util AS
2 /* $Header: OEXUQUOB.pls 120.0.12010000.3 2009/05/13 10:47:52 smanian ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Quote_Util';
7
8 PROCEDURE Complete_Negotiation
9 (p_header_id IN NUMBER
10 ,x_return_status OUT NOCOPY VARCHAR2
11 ,x_msg_count OUT NOCOPY NUMBER
12 ,x_msg_data OUT NOCOPY VARCHAR2
13 )
14 IS
15
16 l_old_header_rec OE_Order_PUB.Header_Rec_Type;
17 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
18 l_header_rec OE_Order_PUB.Header_Rec_Type;
19 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
20 l_header_adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
21 l_line_adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
22 l_header_price_att_tbl OE_Order_PUB.Header_Price_Att_Tbl_Type;
23 l_line_price_att_tbl OE_Order_PUB.Line_Price_Att_Tbl_Type;
24 l_header_adj_att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type;
25 l_line_adj_att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
26 l_header_adj_assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
27 l_line_adj_assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
28 l_header_scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
29 l_line_scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
30 l_lot_serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
31 l_header_payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
32 l_line_payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
33 l_action_request_tbl OE_Order_PUB.request_tbl_type;
34 l_control_rec OE_GLOBALS.Control_Rec_Type;
35 l_return_status VARCHAR2(30);
36 l_msg_count NUMBER;
37 l_msg_data VARCHAR2(2000);
38 I NUMBER;
39 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
40
41 BEGIN
42
43 if l_debug_level > 0 then
44 oe_debug_pub.add('ENTER Complete_Negotiation',1);
45 end if;
46
47 x_return_status := FND_API.G_RET_STS_SUCCESS;
48
49
50 -- Query/Lock order header and lines
51
52 OE_Header_Util.Lock_Row
53 (p_header_id => p_header_id
54 ,p_x_header_rec => l_old_header_rec
55 ,x_return_status => l_return_status
56 );
57 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
58 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
59 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
60 RAISE FND_API.G_EXC_ERROR;
61 END IF;
62
63 OE_Line_Util.Lock_Rows
64 (p_header_id => p_header_id
65 ,x_line_tbl => l_old_line_tbl
66 ,x_return_status => l_return_status
67 );
68 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
69 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
70 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
71 RAISE FND_API.G_EXC_ERROR;
72 END IF;
73
74
75 -- Set attributes on header and lines to change phase
76 -- from negotiation to fulfillment
77
78 l_header_rec := l_old_header_rec;
79 l_line_tbl := l_old_line_tbl;
80
81 l_header_rec.operation := oe_globals.g_opr_update;
82 l_header_rec.transaction_phase_code := 'F';
83
84 IF l_header_rec.ordered_date IS NULL THEN
85 l_header_rec.ordered_date := FND_API.G_MISS_DATE;--bug8477340
86 END IF;
87
88 oe_debug_pub.add('old quote date :'||to_char(l_old_header_rec.quote_date
89 ,'DD-MON-YYYY HH24:MI:SS'));
90 oe_debug_pub.add('new quote date :'||to_char(l_header_rec.quote_date
91 ,'DD-MON-YYYY HH24:MI:SS'));
92 l_header_rec.flow_status_code := 'ENTERED';
93 -- Bug 3519935
94 -- Send reason as SYSTEM, this will be used if audit constraint to
95 -- require reason or versioning constraint to require reason is
96 -- applicable to this update operation.
97 l_header_rec.change_reason := 'SYSTEM';
98
99 I := l_line_tbl.FIRST;
100 WHILE I IS NOT NULL LOOP
101
102 l_line_tbl(I).operation := oe_globals.g_opr_update;
103 l_line_tbl(I).transaction_phase_code := 'F';
104 l_line_tbl(I).flow_status_code := 'ENTERED';
105
106 -- Following schedule dates should default in fulfillment phase
107 l_line_tbl(I).schedule_ship_date := fnd_api.g_miss_date;
108 l_line_tbl(I).schedule_arrival_date := fnd_api.g_miss_date;
109
110 -- Bug 3519935
111 -- Send reason as SYSTEM, this will be used if audit constraint to
112 -- require reason or versioning constraint to require reason is
113 -- applicable to this update operation.
114 l_line_tbl(I).change_reason := 'SYSTEM';
115
116 I := l_line_tbl.NEXT(I);
117
118 END LOOP;
119
120
121 -- Set global to indicate that call is from complete negotiation API
122
123 G_COMPLETE_NEG := 'Y';
124
125
126 -- Call process order for the update
127
128 OE_Order_PVT.Process_Order
129 (p_api_version_number => 1.0
130 -- no attribute validation needed
131 ,p_validation_level => fnd_api.g_valid_level_none
132 ,p_control_rec => l_control_rec
133 ,p_x_header_rec => l_header_rec
134 ,p_old_header_rec => l_old_header_rec
135 ,p_x_line_tbl => l_line_tbl
136 ,p_old_line_tbl => l_old_line_tbl
137 ,p_x_header_adj_tbl => l_header_adj_tbl
138 ,p_x_header_price_att_tbl => l_header_price_att_tbl
139 ,p_x_header_adj_att_tbl => l_header_adj_att_tbl
140 ,p_x_header_adj_assoc_tbl => l_header_adj_assoc_tbl
141 ,p_x_header_scredit_tbl => l_header_scredit_tbl
142 ,p_x_header_payment_tbl => l_header_payment_tbl
143 ,p_x_line_adj_tbl => l_line_adj_tbl
144 ,p_x_line_price_att_tbl => l_line_price_att_tbl
145 ,p_x_line_adj_att_tbl => l_line_adj_att_tbl
146 ,p_x_line_adj_assoc_tbl => l_line_adj_assoc_tbl
147 ,p_x_line_scredit_tbl => l_line_scredit_tbl
148 ,p_x_line_payment_tbl => l_line_payment_tbl
149 ,p_x_lot_serial_tbl => l_lot_serial_tbl
150 ,p_x_action_request_tbl => l_action_request_tbl
151 ,x_return_status => l_return_status
152 ,x_msg_count => l_msg_count
153 ,x_msg_data => l_msg_data
154 );
155
156 -- Re-set global to N after process order call
157 G_COMPLETE_NEG := 'N';
158
159 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
160 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
161 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
162 RAISE FND_API.G_EXC_ERROR;
163 END IF;
164
165 OE_MSG_PUB.Count_And_Get
166 ( p_count => x_msg_count
167 , p_data => x_msg_data
168 );
169
170 if l_debug_level > 0 then
171 oe_debug_pub.add('EXIT Complete_Negotiation',1);
172 end if;
173
174 EXCEPTION
175
176 WHEN FND_API.G_EXC_ERROR THEN
177 G_COMPLETE_NEG := 'N';
178 x_return_status := FND_API.G_RET_STS_ERROR;
179 OE_MSG_PUB.Count_And_Get
180 ( p_count => x_msg_count
181 , p_data => x_msg_data
182 );
183
184 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
185 G_COMPLETE_NEG := 'N';
186 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
187 OE_MSG_PUB.Count_And_Get
188 ( p_count => x_msg_count
189 , p_data => x_msg_data
190 );
191
192 WHEN OTHERS THEN
193 G_COMPLETE_NEG := 'N';
194 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
195 OE_MSG_PUB.Add_Exc_Msg
196 (G_PKG_NAME
197 ,'Complete_Negotiation'
198 );
199 END IF;
200 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
201 OE_MSG_PUB.Count_And_Get
202 ( p_count => x_msg_count
203 , p_data => x_msg_data
204 );
205
206 END Complete_Negotiation;
207
208 END OE_Quote_Util;