DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_RES_USAGE_VALIDATE_PVT

Source


1 PACKAGE BODY EAM_RES_USAGE_VALIDATE_PVT AS
2 /* $Header: EAMVRUVB.pls 115.3 2002/12/10 13:02:52 baroy noship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVRUVB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_RES_USAGE_VALIDATE_PVT
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  30-JUN-2002    Kenichi Nagumo     Initial Creation
21 ***************************************************************************/
22 
23 G_Pkg_Name      VARCHAR2(30) := 'EAM_RES_USAGE_VALIDATE_PVT';
24 
25 g_token_tbl     EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
26 g_dummy         NUMBER;
27 
28     /********************************************************************
29     * Procedure     : Check_Attributes
30     * Parameters IN : Resource Column record
31     *                 Old Resource Column record
32     * Parameters OUT NOCOPY: Return Status
33     *                 Mesg Token Table
34     * Purpose       : Check_Attrbibutes procedure will validate every
35     *                 revised item attrbiute in its entirety.
36     **********************************************************************/
37 
38     PROCEDURE Check_Attributes
39         (  p_eam_res_usage_rec       IN EAM_PROCESS_WO_PUB.eam_res_usage_rec_type
40          , x_return_status           OUT NOCOPY VARCHAR2
41          , x_Mesg_Token_Tbl          OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
42     )
43     IS
44     l_err_text              VARCHAR2(2000) := NULL;
45     l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
46     l_out_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
47     l_Token_Tbl             EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
48 
49     BEGIN
50 
51 
52 --  operation_seq_num
53 
54 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating operation_seq_num . . . '); END IF;
55 
56    begin
57 
58    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
59 
60     select 1
61       into g_dummy
62       from wip_operations wo
63      where wo.organization_id = p_eam_res_usage_rec.organization_id
64        and wo.wip_entity_id = p_eam_res_usage_rec.wip_entity_id
65        and wo.operation_seq_num = p_eam_res_usage_rec.operation_seq_num;
66 
67    end if;
68 
69     x_return_status := FND_API.G_RET_STS_SUCCESS;
70 
71   exception
72     when others then
73 
74       l_token_tbl(1).token_name  := 'OP_SEQ_NUM';
75       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.operation_seq_num;
76 
77       l_out_mesg_token_tbl  := l_mesg_token_tbl;
78       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
79       (  p_message_name  => 'EAM_RU_OP_SEQ_INVALID'
80        , p_token_tbl     => l_token_tbl
81        , p_mesg_token_tbl     => l_mesg_token_tbl
82        , x_mesg_token_tbl     => l_out_mesg_token_tbl
83       );
84       l_mesg_token_tbl      := l_out_mesg_token_tbl;
85 
86       x_return_status := FND_API.G_RET_STS_ERROR;
87       x_mesg_token_tbl := l_mesg_token_tbl ;
88       return;
89 
90   end;
91 
92 
93 --  resource_seq_num
94 
95 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating resource_seq_num . . . '); END IF;
96 
97    begin
98 
99    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
100 
101     select 1
102       into g_dummy
103       from wip_operation_resources wor
104      where wor.organization_id = p_eam_res_usage_rec.organization_id
105        and wor.wip_entity_id = p_eam_res_usage_rec.wip_entity_id
106        and wor.operation_seq_num = p_eam_res_usage_rec.operation_seq_num
107        and wor.resource_seq_num = p_eam_res_usage_rec.resource_seq_num;
108 
109    end if;
110 
111     x_return_status := FND_API.G_RET_STS_SUCCESS;
112 
113   exception
114     when others then
115 
116       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
117       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
118 
119       l_out_mesg_token_tbl  := l_mesg_token_tbl;
120       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
121       (  p_message_name  => 'EAM_RU_RES_SEQ_INVALID'
122        , p_token_tbl     => l_token_tbl
123        , p_mesg_token_tbl     => l_mesg_token_tbl
124        , x_mesg_token_tbl     => l_out_mesg_token_tbl
125       );
126       l_mesg_token_tbl      := l_out_mesg_token_tbl;
127 
128       x_return_status := FND_API.G_RET_STS_ERROR;
129       x_mesg_token_tbl := l_mesg_token_tbl ;
130       return;
131 
132   end;
133 
134 
135 --  instance_id
136 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating instance_id . . . '); END IF;
137 
138   begin
139 
140    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
141 
142       select count(*)
143         into g_dummy
144         from bom_resource_equipments
145        where instance_id = p_eam_res_usage_rec.instance_id
146          and organization_id = p_eam_res_usage_rec.organization_id;
147 
148    end if;
149 
150     x_return_status := FND_API.G_RET_STS_SUCCESS;
151 
152   exception
153     when others then
154 
155       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
156       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
157 
158       l_out_mesg_token_tbl  := l_mesg_token_tbl;
159       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
160       (  p_message_name  => 'EAM_RU_INSTANCE_INVALID'
161        , p_token_tbl     => l_token_tbl
162        , p_mesg_token_tbl     => l_mesg_token_tbl
163        , x_mesg_token_tbl     => l_out_mesg_token_tbl
164       );
165       l_mesg_token_tbl      := l_out_mesg_token_tbl;
166 
167       x_return_status := FND_API.G_RET_STS_ERROR;
168       x_mesg_token_tbl := l_mesg_token_tbl ;
169       return;
170 
171   end;
172 
173 
174 
175 --  serial_number
176 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating serial_number . . . '); END IF;
177 
178   begin
179 
180    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
181 
182     if (p_eam_res_usage_rec.serial_number is not NULL) then
183 
184       select count(*)
185         into g_dummy
186         from mtl_serial_numbers msn, bom_resource_equipments bre
187        where msn.inventory_item_id = bre.inventory_item_id
188          and msn.current_organization_id = bre.organization_id
189          and bre.instance_id = p_eam_res_usage_rec.instance_id
190          and msn.serial_number = p_eam_res_usage_rec.serial_number;
191 
192     end if;
193 
194    end if;
195 
196     x_return_status := FND_API.G_RET_STS_SUCCESS;
197 
198   exception
199     when others then
200 
201       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
202       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
203 
204       l_out_mesg_token_tbl  := l_mesg_token_tbl;
205       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
206       (  p_message_name  => 'EAM_RU_SERIAL_NUMBER_INVALID'
207        , p_token_tbl     => l_token_tbl
208        , p_mesg_token_tbl     => l_mesg_token_tbl
209        , x_mesg_token_tbl     => l_out_mesg_token_tbl
210       );
211       l_mesg_token_tbl      := l_out_mesg_token_tbl;
212 
213       x_return_status := FND_API.G_RET_STS_ERROR;
214       x_mesg_token_tbl := l_mesg_token_tbl ;
215       return;
216 
217   end;
218 
219 
220 --  start_date
221 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating start_date . . . '); END IF;
222 
223   begin
224 
225    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
226 
227     if p_eam_res_usage_rec.start_date > p_eam_res_usage_rec.completion_date then
228       raise fnd_api.g_exc_unexpected_error;
229     end if;
230 
231    end if;
232 
233     x_return_status := FND_API.G_RET_STS_SUCCESS;
234 
235   exception
236     when others then
237 
238       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
239       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
240 
241       l_out_mesg_token_tbl  := l_mesg_token_tbl;
242       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
243       (  p_message_name  => 'EAM_RU_START_DATE_INVALID'
244        , p_token_tbl     => l_token_tbl
245        , p_mesg_token_tbl     => l_mesg_token_tbl
246        , x_mesg_token_tbl     => l_out_mesg_token_tbl
247       );
248       l_mesg_token_tbl      := l_out_mesg_token_tbl;
249 
250       x_return_status := FND_API.G_RET_STS_ERROR;
251       x_mesg_token_tbl := l_mesg_token_tbl ;
252       return;
253 
254   end;
255 
256 
257 --  assigned_units
258 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating assigned_units . . . '); END IF;
259 
260   begin
261 
262    if (p_eam_res_usage_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
263 
264     if (p_eam_res_usage_rec.assigned_units < 0 ) then
265        raise fnd_api.g_exc_unexpected_error;
266     end if;
267 
268    end if;
269 
270     x_return_status := FND_API.G_RET_STS_SUCCESS;
271 
272   exception
273     when others then
274 
275       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
276       l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
277 
278       l_out_mesg_token_tbl  := l_mesg_token_tbl;
279       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
280       (  p_message_name  => 'EAM_RU_ASSIGNED_UNIT_INVALID'
281        , p_token_tbl     => l_token_tbl
282        , p_mesg_token_tbl     => l_mesg_token_tbl
283        , x_mesg_token_tbl     => l_out_mesg_token_tbl
284       );
285       l_mesg_token_tbl      := l_out_mesg_token_tbl;
286 
287       x_return_status := FND_API.G_RET_STS_ERROR;
288       x_mesg_token_tbl := l_mesg_token_tbl ;
289       return;
290 
291   end;
292 
293 
294         x_return_status := FND_API.G_RET_STS_SUCCESS;
295 
296         IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within Resource Check Attributes . . . '); END IF;
297 
298 
299     END Check_Attributes;
300 
301     /*********************************************************************
302     * Procedure     : Check_Required
303     * Parameters IN : Resource column record
304     * Parameters OUT NOCOPY: Mesg Token Table
305     *                 Return_Status
306     * Purpose       :
307     **********************************************************************/
308 
309     PROCEDURE Check_Required
310         (  p_eam_res_usage_rec       IN EAM_PROCESS_WO_PUB.eam_res_usage_rec_type
311          , x_return_status          OUT NOCOPY VARCHAR2
312          , x_Mesg_Token_Tbl         OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
313          )
314     IS
315             l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
316             l_out_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
317             l_Token_Tbl             EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
318     BEGIN
319 
320         x_return_status := FND_API.G_RET_STS_SUCCESS;
321 
322 
323         IF p_eam_res_usage_rec.wip_entity_id IS NULL
324         THEN
325             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
326             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
327 
328             l_out_mesg_token_tbl  := l_mesg_token_tbl;
329             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
330             (  p_message_name	=> 'EAM_RU_ENTITY_ID_REQUIRED'
331              , p_token_tbl		=> l_Token_tbl
332              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
333              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
334              );
335             l_mesg_token_tbl      := l_out_mesg_token_tbl;
336 
337             x_return_status := FND_API.G_RET_STS_ERROR;
338 
339         END IF;
340 
341 
342         IF p_eam_res_usage_rec.organization_id IS NULL
343         THEN
344             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
345             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
346 
347             l_out_mesg_token_tbl  := l_mesg_token_tbl;
348             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
349             (  p_message_name	=> 'EAM_RU_ORG_REQUIRED'
350              , p_token_tbl		=> l_Token_tbl
351              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
352              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
353              );
354             l_mesg_token_tbl      := l_out_mesg_token_tbl;
355 
356             x_return_status := FND_API.G_RET_STS_ERROR;
357 
358         END IF;
359 
360 
361         IF p_eam_res_usage_rec.operation_seq_num IS NULL
362         THEN
363             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
364             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
365 
366             l_out_mesg_token_tbl  := l_mesg_token_tbl;
367             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
368             (  p_message_name	=> 'EAM_RU_OP_SEQ_REQUIRED'
369              , p_token_tbl		=> l_Token_tbl
370              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
371              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
372              );
373             l_mesg_token_tbl      := l_out_mesg_token_tbl;
374 
375             x_return_status := FND_API.G_RET_STS_ERROR;
376 
377         END IF;
378 
379 
380         IF p_eam_res_usage_rec.resource_seq_num IS NULL
381         THEN
382             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
383             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
384 
385             l_out_mesg_token_tbl  := l_mesg_token_tbl;
386             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
387             (  p_message_name	=> 'EAM_RU_RES_SEQ_REQUIRED'
388              , p_token_tbl		=> l_Token_tbl
389              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
390              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
391              );
392             l_mesg_token_tbl      := l_out_mesg_token_tbl;
393 
394             x_return_status := FND_API.G_RET_STS_ERROR;
395 
396         END IF;
397 
398 
399         IF p_eam_res_usage_rec.start_date IS NULL
400         THEN
401             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
402             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
403 
404             l_out_mesg_token_tbl  := l_mesg_token_tbl;
405             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
406             (  p_message_name	=> 'EAM_RU_START_DATE_REQUIRED'
407              , p_token_tbl		=> l_Token_tbl
408              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
409              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
410              );
411             l_mesg_token_tbl      := l_out_mesg_token_tbl;
412 
413             x_return_status := FND_API.G_RET_STS_ERROR;
414 
415         END IF;
416 
417 
418         IF p_eam_res_usage_rec.completion_date IS NULL
419         THEN
420             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
421             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
422 
423             l_out_mesg_token_tbl  := l_mesg_token_tbl;
424             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
425             (  p_message_name	=> 'EAM_RU_COMPL_DATE_REQUIRED'
426              , p_token_tbl		=> l_Token_tbl
427              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
428              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
429              );
430             l_mesg_token_tbl      := l_out_mesg_token_tbl;
431 
432             x_return_status := FND_API.G_RET_STS_ERROR;
433 
434         END IF;
435 
436 
437         IF p_eam_res_usage_rec.assigned_units IS NULL
438         THEN
439             l_token_tbl(1).token_name  := 'RESOURCE_SEQ_NUM';
440             l_token_tbl(1).token_value :=  p_eam_res_usage_rec.resource_seq_num;
441 
442             l_out_mesg_token_tbl  := l_mesg_token_tbl;
443             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
444             (  p_message_name	=> 'EAM_RU_ASSIGNED_UNIT_REQUIRED'
445              , p_token_tbl		=> l_Token_tbl
446              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
447              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
448              );
449             l_mesg_token_tbl      := l_out_mesg_token_tbl;
450 
451             x_return_status := FND_API.G_RET_STS_ERROR;
452 
453         END IF;
454 
455 
456         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
457 
458     END Check_Required;
459 
460 END EAM_RES_USAGE_VALIDATE_PVT;