DBA Data[Home] [Help]

PACKAGE BODY: APPS.AP_WEB_AUDIT_LIST_PUB

Source


1 PACKAGE BODY AP_WEB_AUDIT_LIST_PUB AS
2 /* $Header: apwpalab.pls 115.3 2004/07/01 07:47:40 jrautiai noship $ */
3 
4  /* =======================================================================
5   | Global Data Types
6   * ======================================================================*/
7 
8   G_PKG_NAME     CONSTANT VARCHAR2(30) := 'AP_WEB_AUDIT_LIST_PUB';
9 
10   G_MSG_UERROR    CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR;
11   G_MSG_ERROR     CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_ERROR;
12   G_MSG_SUCCESS   CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_SUCCESS;
13   G_MSG_HIGH      CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH;
14   G_MSG_MEDIUM    CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM;
15   G_MSG_LOW       CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW;
16 
17 /*========================================================================
18  | PUBLIC PROCEDUDE Audit_Employee
19  |
20  | DESCRIPTION
21  |   This procedure adds a employee to the Internet Expenses automated
22  |   audit list.
23  |
24  | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
25  |   Public API
26  |
27  | CALLS PROCEDURES/FUNCTIONS (local to this package body)
28  |
29  | RETURNS
30  |   Standard API parameters
31  |
32  | PARAMETERS
33  |   p_api_version      IN  Standard API paramater
34  |   p_init_msg_list    IN  Standard API paramater
35  |   p_commit           IN  Standard API paramater
36  |   p_validation_level IN  Standard API paramater
37  |   x_return_status    OUT Standard API paramater
38  |   x_msg_count        OUT Standard API paramater
39  |   x_msg_data         OUT Standard API paramater
40  |   p_emp_rec          IN  Employee record containg criteria used to find a given employee
41  |   p_audit_rec        IN  Audit record containg information about the record to be created
42  |   x_auto_audit_id    OUT Identifier of the new record created, if multiple created returns -1.
43  |
44  | MODIFICATION HISTORY
45  | Date                  Author            Description of Changes
46  | 05-Dec-2002           J Rautiainen      Created
47  |
48  *=======================================================================*/
49 PROCEDURE Audit_Employee(p_api_version      IN  NUMBER,
50                          p_init_msg_list    IN  VARCHAR2 := FND_API.G_FALSE,
51                          p_commit           IN  VARCHAR2 := FND_API.G_FALSE,
52                          p_validation_level IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
53                          x_return_status    OUT NOCOPY VARCHAR2,
54                          x_msg_count        OUT NOCOPY NUMBER,
55                          x_msg_data         OUT NOCOPY VARCHAR2,
56                          p_emp_rec          IN  Employee_Rec_Type,
57                          p_audit_rec        IN  Audit_Rec_Type,
58                          x_auto_audit_id    OUT NOCOPY NUMBER) IS
59 
60   l_api_name           CONSTANT VARCHAR2(30) := 'Change_Employee_Status';
61   l_api_version        CONSTANT NUMBER       := 1.0;
62   l_return_status      VARCHAR2(1);
63   l_emp_rec            Employee_Rec_Type;
64   l_audit_rec          Audit_Rec_Type;
65   l_auto_audit_id      NUMBER;
66 
67 BEGIN
68   -- Standard Start of API savepoint
69   SAVEPOINT Change_Employee_Status_PVT;
70 
71   -- Standard call to check for call compatibility.
72   IF NOT FND_API.Compatible_API_Call(l_api_version,
73                                      p_api_version,
74                                      l_api_name,
75 			             G_PKG_NAME) THEN
76 
77     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
78   END IF;
79 
80   -- Initialize message list if p_init_msg_list is set to TRUE.
81   IF FND_API.to_Boolean( p_init_msg_list ) THEN
82     FND_MSG_PUB.initialize;
83   END IF;
84 
85   --  Initialize API return status to success
86   x_return_status := FND_API.G_RET_STS_SUCCESS;
87 
88   l_emp_rec := p_emp_rec;
89   l_audit_rec := p_audit_rec;
90 
91   -- Validate required input
92   AP_WEB_AUDIT_LIST_VAL_PVT.Validate_Required_Input(l_emp_rec,
93                                                     l_audit_rec,
94                                                     l_return_status);
95 
96   -- If any errors happen abort API.
97   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
98     RAISE FND_API.G_EXC_ERROR;
99   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
100     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
101   END IF;
102 
103   -- Validate employee information
104   AP_WEB_AUDIT_LIST_VAL_PVT.Validate_Employee_Info(l_emp_rec,
105                                                    l_return_status);
106   -- If any errors happen abort API.
107   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
108     RAISE FND_API.G_EXC_ERROR;
109   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
110     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
111   END IF;
112 
113   -- Validate audit information
114   AP_WEB_AUDIT_LIST_VAL_PVT.Validate_Audit_Info(l_emp_rec,
115                                                 l_audit_rec,
116                                                 l_return_status);
117   -- If any errors happen abort API.
118   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
119     RAISE FND_API.G_EXC_ERROR;
120   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
121     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
122   END IF;
123 
124   -- If validations succesful, add employee to the audit list
125   AP_WEB_AUDIT_LIST_PVT.process_entry(l_emp_rec,
126                                       l_audit_rec,
127                                       l_return_status,
128                                       l_auto_audit_id);
129 
130   -- Set OUT values
131   x_auto_audit_id  := l_auto_audit_id;
132 
133   -- Standard check of p_commit.
134   IF FND_API.To_Boolean( p_commit ) THEN
135     COMMIT WORK;
136   END IF;
137 
138   -- Standard call to get message count and if count is 1, get message info.
139   FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data  => x_msg_data);
140 
141 EXCEPTION
142   WHEN FND_API.G_EXC_ERROR THEN
143     ROLLBACK TO Change_Employee_Status_PVT;
144     x_return_status := FND_API.G_RET_STS_ERROR;
145     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
146 
147   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
148     ROLLBACK TO Change_Employee_Status_PVT;
149     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
150     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
151 
152   WHEN OTHERS THEN
153     ROLLBACK TO Change_Employee_Status_PVT;
154     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
155 
156     IF FND_MSG_PUB.Check_Msg_Level THEN
157       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
158     END IF;
159 
160     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
161 
162 END Audit_Employee;
163 
164 /*========================================================================
165  | PUBLIC PROCEDUDE Deaudit_Employee
166  |
167  | DESCRIPTION
168  |   This procedure removes a employee from the Internet Expenses automated
169  |   audit list.
170  |
171  | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
172  |   Public API
173  |
174  | CALLS PROCEDURES/FUNCTIONS (local to this package body)
175  |
176  | RETURNS
177  |   Standard API parameters
178  |
179  | PARAMETERS
180  |   p_api_version      IN  Standard API paramater
181  |   p_init_msg_list    IN  Standard API paramater
182  |   p_commit           IN  Standard API paramater
183  |   p_validation_level IN  Standard API paramater
184  |   x_return_status    OUT Standard API paramater
185  |   x_msg_count        OUT Standard API paramater
186  |   x_msg_data         OUT Standard API paramater
187  |   p_emp_rec          IN  Employee record containg criteria used to find a given employee
188  |   p_date_range_rec   IN  Record containg date range
189  |
190  | MODIFICATION HISTORY
191  | Date                  Author            Description of Changes
192  | 29-Jun-2004           J Rautiainen      Created
193  |
194  *=======================================================================*/
195 PROCEDURE Deaudit_Employee(p_api_version      IN  NUMBER,
196                            p_init_msg_list    IN  VARCHAR2 := FND_API.G_FALSE,
197                            p_commit           IN  VARCHAR2 := FND_API.G_FALSE,
198                            p_validation_level IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
199                            x_return_status    OUT NOCOPY VARCHAR2,
200                            x_msg_count        OUT NOCOPY NUMBER,
201                            x_msg_data         OUT NOCOPY VARCHAR2,
202                            p_emp_rec          IN  Employee_Rec_Type,
203                            p_date_range_rec   IN  Date_Range_Type) IS
204 
205   l_api_name           CONSTANT VARCHAR2(30) := 'Remove_Employee_From_Audit';
206   l_api_version        CONSTANT NUMBER       := 1.0;
207   l_return_status      VARCHAR2(1);
208   l_emp_rec            Employee_Rec_Type;
209   l_date_range_rec     Date_Range_Type;
210 
211 BEGIN
212   -- Standard Start of API savepoint
213   SAVEPOINT Remove_Employee_From_Audit_PVT;
214 
215   -- Standard call to check for call compatibility.
216   IF NOT FND_API.Compatible_API_Call(l_api_version,
217                                      p_api_version,
218                                      l_api_name,
219 			             G_PKG_NAME) THEN
220 
221     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
222   END IF;
223 
224   -- Initialize message list if p_init_msg_list is set to TRUE.
225   IF FND_API.to_Boolean( p_init_msg_list ) THEN
226     FND_MSG_PUB.initialize;
227   END IF;
228 
229   --  Initialize API return status to success
230   x_return_status := FND_API.G_RET_STS_SUCCESS;
231 
232   l_emp_rec := p_emp_rec;
233   l_date_range_rec := p_date_range_rec;
234 
235   -- Validate required input
236   AP_WEB_AUDIT_LIST_VAL_PVT.Validate_Required_Input(l_emp_rec,
237                                                     l_date_range_rec,
238                                                     l_return_status);
239 
240   -- If any errors happen abort API.
241   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
242     RAISE FND_API.G_EXC_ERROR;
243   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
244     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
245   END IF;
246 
247   -- Validate employee information
248   AP_WEB_AUDIT_LIST_VAL_PVT.Validate_Employee_Info(l_emp_rec,
249                                                    l_return_status);
250   -- If any errors happen abort API.
251   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
252     RAISE FND_API.G_EXC_ERROR;
253   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
254     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
255   END IF;
256 
257   -- If any errors happen abort API.
258   IF l_return_status = FND_API.G_RET_STS_ERROR THEN
259     RAISE FND_API.G_EXC_ERROR;
260   ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
261     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
262   END IF;
263 
264   -- If validations succesful, add employee to the audit list
265   AP_WEB_AUDIT_LIST_PVT.remove_entries(l_emp_rec,
266                                        l_date_range_rec,
267                                        l_return_status);
268 
269   -- Standard check of p_commit.
270   IF FND_API.To_Boolean( p_commit ) THEN
271     COMMIT WORK;
272   END IF;
273 
274   -- Standard call to get message count and if count is 1, get message info.
275   FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data  => x_msg_data);
276 
277 EXCEPTION
278   WHEN FND_API.G_EXC_ERROR THEN
279     ROLLBACK TO Remove_Employee_From_Audit_PVT;
280     x_return_status := FND_API.G_RET_STS_ERROR;
281     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
282 
283   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
284     ROLLBACK TO Remove_Employee_From_Audit_PVT;
285     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
286     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
287 
288   WHEN OTHERS THEN
289     ROLLBACK TO Remove_Employee_From_Audit_PVT;
290     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
291 
292     IF FND_MSG_PUB.Check_Msg_Level THEN
293       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
294     END IF;
295 
296     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => x_msg_count, p_data  => x_msg_data);
297 
298 END Deaudit_Employee;
299 
300 END AP_WEB_AUDIT_LIST_PUB;