DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_OE_FORM_REASONS

Source


1 PACKAGE BODY Oe_Oe_Form_Reasons AS
2 /* $Header: OEXFREAB.pls 120.0 2005/06/01 02:38:00 appldev noship $ */
3 
4 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'Oe_Oe_Form_Header';
5 
6 PROCEDURE Apply_Reason(
7                           p_reason_type    IN VARCHAR2
8                         , p_reason_code    IN VARCHAR2
9                         , p_comments       IN VARCHAR2
10                         , p_entity_id      IN NUMBER
11                         , p_version_number IN NUMBER
12                         , p_entity_code    IN VARCHAR2
13                         , x_return_status  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
14                         , x_msg_count OUT NOCOPY NUMBER
15                         , x_msg_data OUT NOCOPY VARCHAR2
16                       )
17 
18 IS
19 l_reason_id Number;
20 BEGIN
21     oe_debug_pub.add('Entering Apply Reason');
22     OE_MSG_PUB.initialize;
23   IF p_reason_type IN ('OFFER_LOST','OFFER_LOST_REASON') THEN
24     OE_NEGOTIATE_WF.Lost
25                     (
26                      p_header_id =>p_entity_id,
27                      p_entity_code=>p_entity_code,
28                      p_version_number=>p_version_number,
29                      p_reason_type =>p_reason_type,
30                      p_reason_code =>p_reason_code,
31                      p_reason_comments=>p_comments ,
32                      x_return_status => x_return_status
33                      );
34   ELSIF p_reason_type IN ('CUSTOMER_REJECTION','CUSTOMER_REJECTION_REASON') THEN
35     oe_debug_pub.add('Enter Customer Rejection');
36     oe_debug_pub.add('Enter Customer Rejection'||p_entity_id);
37     oe_debug_pub.add('Enter Customer Rejection'||p_entity_code);
38     oe_debug_pub.add('Enter Customer Rejection'||p_version_number);
39     oe_debug_pub.add('Enter Customer Rejection'||p_reason_type);
40     OE_NEGOTIATE_WF.Customer_Rejected
41                     (
42                      p_header_id =>p_entity_id,
43                      p_entity_code=>p_entity_code,
44                      p_version_number=>p_version_number,
45                      p_reason_type =>p_reason_type,
46                      p_reason_code =>p_reason_code,
47                      p_reason_comments=>p_comments ,
48                      x_return_status => x_return_status
49                      );
50     oe_debug_pub.add('Exit Customer Rejection');
51 
52   ELSIF p_reason_type='CONTRACT_TERMINATION' THEN
53    OE_BLANKET_WF.Terminate(p_header_id => p_entity_id,
54                              p_terminated_by => nvl(FND_GLOBAL.USER_ID,-1),
55                              p_version_number => p_version_number,
56                              p_reason_type => p_reason_type,
57                              p_reason_code => p_reason_code,
58                              p_reason_comments => p_comments,
59                              x_return_status => x_return_status);
60   ELSE
61     OE_REASONS_UTIL.Apply_Reason
62                      (
63                       p_entity_code=>p_entity_code,
64                       p_entity_id =>p_entity_id,
65                       p_version_number =>p_version_number,
66                       p_reason_type =>p_reason_type,
67                       p_reason_code =>p_reason_code,
68                       p_reason_comments =>p_comments,
69                       x_reason_id =>l_reason_id,
70                       x_return_status =>x_return_status
71                       );
72   END IF;
73     IF x_return_status  = FND_API.G_RET_STS_UNEXP_ERROR THEN
74         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
75     ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
76         RAISE FND_API.G_EXC_ERROR;
77     END IF;
78 
79     x_return_status := FND_API.G_RET_STS_SUCCESS;
80 
81     --  Get message count and data
82 
83     OE_MSG_PUB.Count_And_Get
84     (   p_count                       => x_msg_count
85     ,   p_data                        => x_msg_data
86     );
87 
88     oe_debug_pub.add('Exiting OE_OE_FORM_REASONS');
89 
90 EXCEPTION
91 
92     WHEN FND_API.G_EXC_ERROR THEN
93 
94 
95         x_return_status := FND_API.G_RET_STS_ERROR;
96 
97         --  Get message count and data
98 
99         OE_MSG_PUB.Count_And_Get
100         (   p_count                       => x_msg_count
101         ,   p_data                        => x_msg_data
102         );
103 
104     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
105 
106 
107         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
108 
109         --  Get message count and data
110 
111         OE_MSG_PUB.Count_And_Get
112         (   p_count                       => x_msg_count
113         ,   p_data                        => x_msg_data
114         );
115 
116     WHEN OTHERS THEN
117 
118 	   OE_GLOBALS.G_UI_FLAG := FALSE;
119         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
120 
121         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
122         THEN
123             OE_MSG_PUB.Add_Exc_Msg
124             (   G_PKG_NAME
125             ,   'Apply_Reasons'
126             );
127         END IF;
128 
129         --  Get message count and data
130 
131         OE_MSG_PUB.Count_And_Get
132         (   p_count                       => x_msg_count
133         ,   p_data                        => x_msg_data
134         );
135 
136 END Apply_Reason;
137 
138 
139 PROCEDURE Submit_Draft(
140                           p_header_id      IN NUMBER
141                         , x_return_status  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
142                         , x_msg_count OUT NOCOPY NUMBER
143                         , x_msg_data OUT NOCOPY VARCHAR2
144 
145                       )
146 IS
147 BEGIN
148     oe_debug_pub.add('Entering OE_OE_FORM_REASONS.Submit_Draft');
149   OE_NEGOTIATE_WF.Submit_Draft(
150                           p_header_id=>  p_header_id,
151                           x_return_status=>  x_return_status
152                                );
153 
154 
155     IF x_return_status  = FND_API.G_RET_STS_UNEXP_ERROR THEN
156         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
157     ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
158         RAISE FND_API.G_EXC_ERROR;
159     END IF;
160 
161     x_return_status := FND_API.G_RET_STS_SUCCESS;
162 
163     --  Get message count and data
164 
165     OE_MSG_PUB.Count_And_Get
166     (   p_count                       => x_msg_count
167     ,   p_data                        => x_msg_data
168     );
169 
170     oe_debug_pub.add('Exiting OE_OE_FORM_REASONS.Submit_Draft');
171 EXCEPTION
172 
173     WHEN FND_API.G_EXC_ERROR THEN
174 
175 
176         x_return_status := FND_API.G_RET_STS_ERROR;
177 
178         --  Get message count and data
179 
180         OE_MSG_PUB.Count_And_Get
181         (   p_count                       => x_msg_count
182         ,   p_data                        => x_msg_data
183         );
184 
185     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
186 
187 
188         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
189 
190         --  Get message count and data
191 
192         OE_MSG_PUB.Count_And_Get
193         (   p_count                       => x_msg_count
194         ,   p_data                        => x_msg_data
195         );
196 
197     WHEN OTHERS THEN
198 
199 	   OE_GLOBALS.G_UI_FLAG := FALSE;
200         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
201 
202         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
203         THEN
204             OE_MSG_PUB.Add_Exc_Msg
205             (   G_PKG_NAME
206             ,   'Submit_Draft'
207             );
208         END IF;
209 
210         --  Get message count and data
211 
212         OE_MSG_PUB.Count_And_Get
213         (   p_count                       => x_msg_count
214         ,   p_data                        => x_msg_data
215         );
216 
217 END Submit_Draft;
218 
219 PROCEDURE Populate_Version_Number
220                       (
221                         x_return_status     OUT NOCOPY VARCHAR2
222                       , x_msg_count         OUT NOCOPY NUMBER
223                       , x_msg_data          OUT NOCOPY VARCHAR2
224                       , p_header_id         IN  NUMBER
225                       , p_order_version_number IN NUMBER
226                       )  IS
227 l_old_header_rec    OE_Order_PUB.Header_Rec_Type;
228 l_header_rec        OE_Order_PUB.Header_Rec_Type;
229 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
230 l_return_status               VARCHAR2(1);
231 BEGIN
232   IF p_header_id IS NOT NULL THEN
233     OE_Header_Util.Query_Row(p_header_id  => p_header_id,
234                             x_header_rec => l_old_header_rec);
235     l_header_rec:=l_old_header_rec;
236     l_header_rec.version_number:=p_order_version_number;
237     OE_GLOBALS.G_UI_FLAG := TRUE;
238     l_control_rec.controlled_operation := TRUE;
239     l_control_rec.check_security       := TRUE;
240     l_control_rec.clear_dependents     := TRUE;
241     l_control_rec.default_attributes   := TRUE;
242     l_control_rec.change_attributes    := TRUE;
243 
244     l_control_rec.validate_entity      := FALSE;
245     l_control_rec.write_to_DB          := FALSE;
246     l_control_rec.process              := FALSE;
247 
248     --  Instruct API to retain its caches
249 
250     l_control_rec.clear_api_cache      := FALSE;
251     l_control_rec.clear_api_requests   := FALSE;
252 
253      Oe_Order_Pvt.Header
254     (
255         p_validation_level            => FND_API.G_VALID_LEVEL_NONE
256     ,   p_init_msg_list               => FND_API.G_TRUE
257     ,   p_control_rec                 => l_control_rec
258     ,   p_x_header_rec                => l_header_rec
259     ,   p_x_old_header_rec            => l_old_header_rec
260     ,   x_return_status                => l_return_status
261     );
262 
263     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
264         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
265     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
266         RAISE FND_API.G_EXC_ERROR;
267     END IF;
268   END IF;
269 
270   OE_GLOBALS.G_UI_FLAG := FALSE;
271   x_return_status := FND_API.G_RET_STS_SUCCESS;
272 
273    OE_MSG_PUB.Count_And_Get
274     (   p_count                       => x_msg_count
275     ,   p_data                        => x_msg_data
276     );
277 
278 EXCEPTION
279 
280     WHEN FND_API.G_EXC_ERROR THEN
281 
282            OE_GLOBALS.G_UI_FLAG := FALSE;
283 
284         x_return_status := FND_API.G_RET_STS_ERROR;
285 
286         --  Get message count and data
287 
288         OE_MSG_PUB.Count_And_Get
289         (   p_count                       => x_msg_count
290         ,   p_data                        => x_msg_data
291         );
292 
293     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
294 
295            OE_GLOBALS.G_UI_FLAG := FALSE;
296 
297         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
298             --  Get message count and data
299 
300         OE_MSG_PUB.Count_And_Get
301         (   p_count                       => x_msg_count
302         ,   p_data                        => x_msg_data
303         );
304 
305     WHEN OTHERS THEN
306 
307            OE_GLOBALS.G_UI_FLAG := FALSE;
308 
309         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
310 
311         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
312         THEN
313             OE_MSG_PUB.Add_Exc_Msg
314             (   G_PKG_NAME
315             ,   'Populate_Version_Number'
316             );
317         END IF;
318 
319         --  Get message count and data
320 
321         OE_MSG_PUB.Count_And_Get
322         (   p_count                       => x_msg_count
323         ,   p_data                        => x_msg_data
324         );
325 
326 
327 END Populate_Version_Number;
328 
329 PROCEDURE Get_Reason_Rqd_Info
330                       (
331                         p_entity_id         IN  NUMBER
332                       , p_entity_code       IN VARCHAR2
333                       , x_audit_reason_capt OUT NOCOPY /* file.sql.39 change */ BOOLEAN
334                       , x_reason            OUT NOCOPY /* file.sql.39 change */ VARCHAR2
335                       , x_comments          OUT NOCOPY /* file.sql.39 change */ VARCHAR2
336                       , x_is_reason_rqd     OUT NOCOPY /* file.sql.39 change */ VARCHAR2
337                       , x_return_status     OUT NOCOPY VARCHAR2
338                       , x_msg_count         OUT NOCOPY NUMBER
339                       , x_msg_data          OUT NOCOPY VARCHAR2
340                       )  IS
341 BEGIN
342  x_audit_reason_capt:=
343                         OE_Versioning_Util.IS_AUDIT_REASON_CAPTURED
344                          (
345                            p_entity_code=>p_entity_code
346                         ,  p_entity_id=>p_entity_id
347                          );
348  OE_Versioning_Util.Get_Reason_Info(
349                                 x_reason_code=>x_reason,
350                                 x_reason_comments=>x_comments
351                                 );
352   x_is_reason_rqd:=OE_Versioning_Util.IS_REASON_RQD;
353 
354   oe_debug_pub.add('Is_Reason_Rqd:'||x_is_reason_rqd);
355   oe_debug_pub.add('x_reason:'||x_reason);
356   IF x_audit_reason_capt THEN
357    oe_debug_pub.add('audit reason captured');
358   ELSE
359    oe_debug_pub.add('audit reason not  captured');
360 
361   END IF;
362 
363   x_return_status := FND_API.G_RET_STS_SUCCESS;
364 
365    OE_MSG_PUB.Count_And_Get
366     (   p_count                       => x_msg_count
367     ,   p_data                        => x_msg_data
368     );
369 
370 EXCEPTION
371 
372     WHEN FND_API.G_EXC_ERROR THEN
373 
374 
375         x_return_status := FND_API.G_RET_STS_ERROR;
376 
377         --  Get message count and data
378 
379         OE_MSG_PUB.Count_And_Get
380         (   p_count                       => x_msg_count
381         ,   p_data                        => x_msg_data
382         );
383 
384     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
385 
386            OE_GLOBALS.G_UI_FLAG := FALSE;
387 
388         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
389             --  Get message count and data
390 
391         OE_MSG_PUB.Count_And_Get
392         (   p_count                       => x_msg_count
393         ,   p_data                        => x_msg_data
394         );
395 
396     WHEN OTHERS THEN
397 
398 
399         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
400 
401         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
402         THEN
403             OE_MSG_PUB.Add_Exc_Msg
404             (   G_PKG_NAME
405             ,   'Get_Reason_Rqd_Info'
406             );
407         END IF;
408 
409         --  Get message count and data
410 
411         OE_MSG_PUB.Count_And_Get
412         (   p_count                       => x_msg_count
413         ,   p_data                        => x_msg_data
414         );
415 
416 END Get_Reason_Rqd_Info;
417 
418 END Oe_Oe_Form_Reasons;
419