[Home] [Help]
PACKAGE BODY: APPS.ENG_VALIDATE_ECO_REVISION
Source
1 PACKAGE BODY ENG_Validate_Eco_Revision AS
2 /* $Header: ENGLREVB.pls 115.18 2002/12/12 17:01:34 akumar ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'ENG_Validate_Eco_Revision';
7 l_dummy VARCHAR2(80);
8
9 /****************************************************************************
10 *Procedure : Entity (Validate)
11 *Parameters IN : Eco Revisions Record of exposed columns
12 * Eco Revisions Record of unexposed columns
13 *Parameters OUT : Mesg Token Table
14 * Return_Status
15 *Purpose : Entity validation will execute the business logic to verify
16 * the correctness of the revisions record wrt to the trasaction
17 * type.
18 ****************************************************************************/
19 PROCEDURE Check_Entity
20 ( x_return_status OUT NOCOPY VARCHAR2
21 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
22 , p_eco_revision_rec IN ENG_Eco_PUB.Eco_Revision_Rec_Type
23 , p_Eco_Rev_Unexp_Rec IN Eng_Eco_Pub.Eco_Rev_Unexposed_Rec_Type
24 )
25 IS
26 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
27 l_dummy VARCHAR2(80);
28 l_processed BOOLEAN;
29 l_token_tbl Error_Handler.Token_Tbl_Type;
30 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
31 l_Err_Text VARCHAR2(2000);
32 BEGIN
33
34 --dbms_output.put_line('Performing ECO Revisions Entity validation . . .');
35
36 ENG_GLOBALS.Check_Approved_For_Process
37 ( p_change_notice => p_eco_revision_rec.Eco_Name,
38 p_organization_id => p_Eco_Rev_Unexp_Rec.organization_id,
39 x_processed => l_processed,
40 x_err_text => l_err_text
41 );
42
43 IF l_processed = TRUE
44 THEN
45 -- If the above process returns true then set the ECO approval.
46
47 BEGIN
48 ENG_GLOBALS.Set_Request_For_Approval
49 (p_change_notice => p_eco_revision_rec.Eco_Name,
50 p_organization_id => p_Eco_Rev_Unexp_Rec.organization_id,
51 x_err_text => l_err_text
52 );
53
54 EXCEPTION
55 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
56 l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
57 END;
58
59 END IF;
60
61 --dbms_output.put_line('Return Status so far ...before checking valid revision '
62 -- || l_return_status );
63
64 IF p_eco_revision_rec.Transaction_Type = ENG_GLOBALS.G_OPR_UPDATE AND
65 p_eco_revision_rec.new_revision IS NOT NULL
66 THEN
67 -- Verfiy that the user is not trying to change the revision to
68 -- a revision that already exists.
69
70 BEGIN
71 SELECT 'Valid'
72 INTO l_dummy
73 FROM sys.dual
74 WHERE NOT EXISTS
75 ( SELECT 1
76 FROM eng_change_order_revisions
77 WHERE revision =
78 p_eco_revision_rec.new_revision
79 AND change_notice =
80 p_eco_revision_rec.Eco_Name
81 );
82 EXCEPTION
83 WHEN NO_DATA_FOUND THEN
84 -- new revision record exists and should be
85 -- errored out
86
87 -- Set token values for the message
88 l_token_tbl(1).token_name := 'REVISION';
89 l_token_tbl(1).token_value :=
90 p_eco_revision_rec.new_revision;
91 l_token_tbl(2).token_name := 'ECO_NAME';
92 l_token_tbl(2).token_value :=
93 p_eco_revision_rec.eco_name;
94
95 Error_Handler.Add_Error_Token
96 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
97 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
98 , p_message_name => 'ENG_ECO_REVISION_NOT_UNIQUE'
99 , p_token_tbl => l_token_tbl
100 );
101 l_return_status := FND_API.G_RET_STS_ERROR;
102 END;
103 END IF;
104 x_return_status := l_return_status;
105 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
106
107 EXCEPTION
108
109 WHEN FND_API.G_EXC_ERROR THEN
110
111 x_return_status := FND_API.G_RET_STS_ERROR;
112
113 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
114
115 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
116
117 WHEN OTHERS THEN
118
119 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
120
121 END Check_Entity;
122
123 -- Procedure Attributes
124
125 PROCEDURE Check_Attributes
126 ( x_return_status OUT NOCOPY VARCHAR2
127 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
128 , p_eco_revision_rec IN ENG_Eco_PUB.Eco_Revision_Rec_Type
129 )
130 IS
131 BEGIN
132
133 x_return_status := FND_API.G_RET_STS_SUCCESS;
134
135 -- AT THE REVISIONS LEVEL THERE ARE NO COLUMNS APART FROM THE DESCRIPTIVE
136 -- FLEX WHICH CAN BE ATTRIBUTE VALIDATED.
137 -- VALIDITY OF ORGANIZATION_ID AND CHANGE_NOTICE WILL HAPPEN IN THE
138 -- EARLIER STEPS ITSELF.
139
140 -- Validate eco_revision attributes
141
142 --dbms_output.put_line('Performing ECO Revisions Attribute Validation . . .');
143
144 EXCEPTION
145
146 WHEN FND_API.G_EXC_ERROR THEN
147
148 x_return_status := FND_API.G_RET_STS_ERROR;
149
150 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
151
152 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
153
154 WHEN OTHERS THEN
155
156 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
157
158 END Check_Attributes;
159
160 -- Procedure Entity_Delete
161
162 PROCEDURE Check_Entity_Delete
163 ( x_return_status OUT NOCOPY VARCHAR2
164 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
165 , p_eco_revision_rec IN ENG_Eco_PUB.Eco_Revision_Rec_Type
166 , p_Eco_Rev_Unexp_Rec IN Eng_Eco_Pub.Eco_Rev_Unexposed_Rec_Type
167 )
168 IS
169 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
170 BEGIN
171
172 -- Validation of whether the ECO is implemented or canceled will
173 -- happen in earlier steps
174 -- so their is no Delete Validation
175
176 x_Return_Status := l_return_status;
177
178 END Check_Entity_Delete;
179
180 /*****************************************************************************
181 * Procedure : Check_Existence
182 * Parameters IN : ECO Revision exposed column record
183 * ECO Revision unexposed column record
184 * Parameters OUT: Old ECO Revision exposed column record
185 * Old ECO Revision unexposed column record
186 * Mesg Token Table
187 * Return Status
188 * Purpose : Check_Existence will poerform a query using the primary key
189 * information and will return a success if the operation is
190 * CREATE and the record EXISTS or will return an
191 * error if the operation is UPDATE and the record DOES NOT
192 * EXIST.
193 * In case of UPDATE if the record exists then the procedure
194 * will return the old record in the old entity parameters
195 * with a success status.
196 ****************************************************************************/
197 PROCEDURE Check_Existence
198 ( p_eco_revision_rec IN Eng_Eco_Pub.Eco_Revision_Rec_Type
199 , p_eco_rev_unexp_rec IN Eng_Eco_Pub.Eco_Rev_Unexposed_Rec_Type
200 , x_old_eco_revision_rec IN OUT NOCOPY Eng_Eco_Pub.Eco_Revision_Rec_Type
201 , x_old_eco_rev_unexp_rec IN OUT NOCOPY Eng_Eco_Pub.Eco_Rev_Unexposed_Rec_Type
202 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
203 , x_Return_Status OUT NOCOPY VARCHAR2
204 )
205 IS
206 l_token_tbl Error_Handler.Token_Tbl_Type;
207 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
208 l_return_status VARCHAR2(1);
209 BEGIN
210 l_Token_Tbl(1).Token_Name := 'REVISION';
211 l_Token_Tbl(1).Token_Value := p_eco_Revision_rec.revision;
212 l_token_tbl(2).Token_Name := 'ECO_NAME';
213 l_token_Tbl(2).Token_Value := p_eco_revision_rec.eco_name;
214
215 ENG_Eco_Revision_Util.Query_Row
216 ( p_Change_Notice => p_eco_revision_rec.eco_name
217 , p_Organization_Id => p_eco_rev_unexp_rec.organization_id
218 , p_Revision => p_eco_revision_rec.revision
219 , x_Eco_Revision_Rec => x_old_eco_revision_rec
220 , x_Eco_Rev_Unexp_Rec => x_old_eco_rev_unexp_rec
221 , x_Return_Status => l_return_status
222 );
223 IF l_return_status = Eng_Globals.G_RECORD_FOUND AND
224 p_eco_revision_rec.transaction_type = Eng_Globals.G_OPR_CREATE
225 THEN
226 Error_Handler.Add_Error_Token
227 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
228 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
229 , p_message_name => 'ENG_ECO_REV_ALREADY_EXISTS'
230 , p_token_tbl => l_token_tbl
231 );
232 l_return_status := FND_API.G_RET_STS_ERROR;
233 ELSIF l_return_status = Eng_Globals.G_RECORD_NOT_FOUND AND
234 p_eco_revision_rec.transaction_type IN
235 (Eng_Globals.G_OPR_UPDATE, Eng_Globals.G_OPR_DELETE)
236 THEN
237 Error_Handler.Add_Error_Token
238 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
239 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
240 , p_message_name => 'ENG_ECO_REV_DOESNOT_EXIST'
241 , p_token_tbl => l_token_tbl
242 );
243 l_return_status := FND_API.G_RET_STS_ERROR;
244 ELSIF l_Return_status = FND_API.G_RET_STS_UNEXP_ERROR
245 THEN
246 Error_Handler.Add_Error_Token
247 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
248 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
249 , p_message_name => 'ENG_REV_EXS_UNEXP_SKIP'
250 , p_token_tbl => l_token_tbl
251 );
252 ELSE
253 l_return_status := FND_API.G_RET_STS_SUCCESS;
254 END IF;
255
256 x_return_status := l_return_status;
257 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
258
259 END CHECK_EXISTENCE;
260
261 /**************************************************************************
262 * Procedure : Check_Access
263 * Parameters : Eco Revision unique key
264 * Parameters OUT: Mesg Token Table
265 * Return Status
266 * Purpose : Procedure will verify that the user has access to the
267 * current ECO before performing any operation on Revisions.
268 ****************************************************************************/
269 PROCEDURE Check_Access
270 ( p_revision IN VARCHAR2
271 , p_change_notice IN VARCHAR2
272 , p_organization_id IN NUMBER
273 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
274 , x_Return_Status OUT NOCOPY VARCHAR2
275 )
276 IS
277 l_token_tbl Error_Handler.Token_Tbl_Type;
278 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
279 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
280 BEGIN
281 --
282 -- Use the ECO Check Access procedure to verify if the user has
283 -- access to the current ECO.
284 --
285 l_token_tbl(1).token_name := 'REVISION';
286 l_token_tbl(1).token_value := p_revision;
287
288 --dbms_output.put_line('Revision: ' || p_Revision);
289 --dbms_output.put_line('ECO : ' || p_change_notice);
290 --dbms_output.put_line('Org : ' || to_char(p_organization_id));
291
292 --
293 -- Driving program must make sure to call the ECO Access check.
294 --
295 /**************************************
296 Eng_Validate_Eco.Check_Access
297 ( p_change_notice => p_change_notice
298 , p_organization_id => p_organization_id
299 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
300 , x_Return_Status => l_return_status
301 );
302
303 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
304 THEN
305 Error_Handler.Add_Error_Token
306 ( p_Message_Name => 'ENG_REV_ACCESS_FAT_FATAL'
307 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
308 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
309 , p_Token_Tbl => l_Token_Tbl
310 );
311 END IF;
312 **********************************************/
313
314 x_return_status := l_return_status;
315 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
316
317 END Check_Access;
318
319 /****************************************************************************
320 * Procedure Check_Required
321 * Parameters IN : Eco Revision exposed column record
322 * Parameters OUT: Mesg Token Tbl
323 * Purpose : Will check if all the required columns have beem filled in
324 * by the user.
325 ****************************************************************************/
326 PROCEDURE CHECK_REQUIRED
327 ( x_return_status OUT NOCOPY VARCHAR2
328 , p_eco_revision_rec IN ENG_Eco_PUB.Eco_Revision_Rec_Type
329 , x_mesg_token_tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
330 )
331 IS
332 l_mesg_token_tbl Error_Handler.Mesg_token_Tbl_Type;
333
334 BEGIN
335 IF p_eco_revision_rec.revision IS NULL OR
336 p_eco_revision_rec.revision = FND_API.G_MISS_CHAR
337 THEN
338 x_return_status := FND_API.G_RET_STS_ERROR;
339 Error_Handler.Add_Error_Token
340 ( x_mesg_token_tbl => x_mesg_token_tbl
341 , p_mesg_token_tbl => l_mesg_token_tbl
342 , p_message_name => 'ENG_REVISION_KEYCOL_NULL'
343 );
344 ELSE
345 x_return_status := FND_API.G_RET_STS_SUCCESS;
346 END IF;
347
348 END CHECK_REQUIRED;
349
350
351 END ENG_Validate_Eco_Revision;