DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_RES_INST_VALIDATE_PVT

Source


1 PACKAGE BODY EAM_RES_INST_VALIDATE_PVT AS
2 /* $Header: EAMVRIVB.pls 120.2 2005/09/21 23:15:01 mmaduska noship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVRIVB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_RES_INST_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_INST_VALIDATE_PVT';
24 
25 g_token_tbl     EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
26 g_dummy         NUMBER;
27 
28     /*******************************************************************
29     * Procedure	: Check_Existence
30     * Returns	: None
31     * Parameters IN : Resource Instance Record
32     * Parameters OUT NOCOPY: Old Resource Instance Record
33     *                 Mesg Token Table
34     *                 Return Status
35     * Purpose	: Procedure will query the old Resource Instance
36     *             record and return it in old record variables. If the
37     *             Transaction Type is Create and the record already
38     *             exists the return status would be error or if the
39     *             transaction type is Update and the record
40     *             does not exist then the return status would be an
41     *             error as well. Mesg_Token_Table will carry the
42     *             error messsage and the tokens associated with the
43     *             message.
44     *********************************************************************/
45 
46      PROCEDURE Check_Existence
47      ( p_eam_res_inst_rec             IN  EAM_PROCESS_WO_PUB.eam_res_inst_rec_type
48      , x_old_eam_res_inst_rec         OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_inst_rec_type
49      , x_Mesg_Token_Tbl               OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
50      , x_return_status                OUT NOCOPY VARCHAR2
51         )
52      IS
53             l_token_tbl      EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
54             l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
55             l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
56             l_return_status  VARCHAR2(1);
57      BEGIN
58 
59 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Quering Resource Instance'); END IF;
60 
61         EAM_RES_INST_UTILITY_PVT.Query_Row
62         ( p_wip_entity_id       => p_eam_res_inst_rec.wip_entity_id
63         , p_organization_id     => p_eam_res_inst_rec.organization_id
64         , p_operation_seq_num   => p_eam_res_inst_rec.operation_seq_num
65         , p_resource_seq_num    => p_eam_res_inst_rec.resource_seq_num
66         , p_instance_id         => p_eam_res_inst_rec.instance_id
67         , p_serial_number       => p_eam_res_inst_rec.serial_number
68         , x_eam_res_inst_rec    => x_old_eam_res_inst_rec
69         , x_Return_status       => l_return_status
70         );
71 
72 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Query Row Returned with : ' || l_return_status); END IF;
73 
74         IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND AND
75             p_eam_res_inst_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
76         THEN
77 		l_token_tbl(1).token_name  := 'INSTANCE_NAME';
78 
79 		if p_eam_res_inst_rec.SERIAL_NUMBER is null then
80 
81 			select full_name
82 			into l_token_tbl(1).token_value
83 			from per_all_people_f papf,bom_resource_employees bre
84 			where bre.instance_id  = p_eam_res_inst_rec.instance_id
85 			and papf.person_id = bre.person_id
86 			and( trunc(sysdate) between papf.effective_start_date
87 			and papf.effective_end_date);
88 
89 		else
90 		            l_token_tbl(1).token_value := p_eam_res_inst_rec.serial_number;
91 		end if;
92 
93             l_out_mesg_token_tbl  := l_mesg_token_tbl;
94             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
95             (  x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
96              , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
97              , p_message_name   => 'EAM_RI_ALREADY_EXISTS'
98              , p_token_tbl      => l_token_tbl
99              );
100             l_mesg_token_tbl      := l_out_mesg_token_tbl;
101 
102             l_return_status := FND_API.G_RET_STS_ERROR;
103 
104         ELSIF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_NOT_FOUND AND
105              p_eam_res_inst_rec.transaction_type IN
106              (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
107         THEN
108             l_token_tbl(1).token_name  := 'INSTANCE_NAME';
109          --   l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
110 
111 		if p_eam_res_inst_rec.SERIAL_NUMBER is null then
112 
113 			select full_name
114 			into l_token_tbl(1).token_value
115 			from per_all_people_f papf,bom_resource_employees bre
116 			where bre.instance_id  = p_eam_res_inst_rec.instance_id
117 			and papf.person_id = bre.person_id
118 			and( trunc(sysdate) between papf.effective_start_date
119 			and papf.effective_end_date);
120 		else
121 		            l_token_tbl(1).token_value := p_eam_res_inst_rec.serial_number;
122 		end if;
123 
124             l_out_mesg_token_tbl  := l_mesg_token_tbl;
125             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
126                         (  x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
127                          , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
128                          , p_message_name   => 'EAM_RI_DOESNOT_EXISTS'
129                          , p_token_tbl      => l_token_tbl
130                          );
131             l_mesg_token_tbl      := l_out_mesg_token_tbl;
132 
133             l_return_status := FND_API.G_RET_STS_ERROR;
134 
135         ELSIF l_Return_status = FND_API.G_RET_STS_UNEXP_ERROR
136         THEN
137             l_out_mesg_token_tbl  := l_mesg_token_tbl;
138             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
139             (  x_Mesg_token_tbl     => l_out_Mesg_Token_Tbl
140              , p_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
141              , p_message_name       => NULL
142              , p_message_text       => 'Unexpected error while existence verification of ' || 'Resource Instance '|| p_eam_res_inst_rec.instance_id , p_token_tbl => l_token_tbl
143              );
144             l_mesg_token_tbl      := l_out_mesg_token_tbl;
145             l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
146 
147         ELSE /* Assign the relevant transaction type for SYNC operations */
148             IF p_eam_res_inst_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_SYNC THEN
149                IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND THEN
150                    x_old_eam_res_inst_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_UPDATE;
151                ELSE
152                    x_old_eam_res_inst_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_CREATE;
153                END IF;
154             END IF;
155             l_return_status := FND_API.G_RET_STS_SUCCESS;
156 
157         END IF;
158 
159         x_return_status := l_return_status;
160         x_mesg_token_tbl := l_mesg_token_tbl;
161     END Check_Existence;
162 
163 
164 
165     /********************************************************************
166     * Procedure     : Check_Attributes
167     * Parameters IN : Resource Instance Column record
168     *                 Old Resource Instance Column record
169     * Parameters OUT NOCOPY: Return Status
170     *                 Mesg Token Table
171     * Purpose       : Check_Attrbibutes procedure will validate every
172     *                 revised item attrbiute in its entirety.
173     **********************************************************************/
174 
175     PROCEDURE Check_Attributes
176         (  p_eam_res_inst_rec         IN EAM_PROCESS_WO_PUB.eam_res_inst_rec_type
177          , p_old_eam_res_inst_rec     IN EAM_PROCESS_WO_PUB.eam_res_inst_rec_type
178          , x_return_status            OUT NOCOPY VARCHAR2
179          , x_Mesg_Token_Tbl           OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
180     )
181     IS
182     l_err_text              VARCHAR2(2000) := NULL;
183     l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
184     l_out_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
185     l_Token_Tbl             EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
186 
187     BEGIN
188 
189 
190 --  operation_seq_num
191 
192 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating operation_seq_num . . . '); END IF;
193 
194    begin
195 
196    if (p_eam_res_inst_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)) then
197 
198     select 1
199       into g_dummy
200       from wip_operations wo
201      where wo.organization_id = p_eam_res_inst_rec.organization_id
202        and wo.wip_entity_id = p_eam_res_inst_rec.wip_entity_id
203        and wo.operation_seq_num = p_eam_res_inst_rec.operation_seq_num;
204 
205    end if;
206 
207     x_return_status := FND_API.G_RET_STS_SUCCESS;
208 
209   exception
210     when others then
211 
212       l_token_tbl(1).token_name  := 'OP_SEQ_NUM';
213       l_token_tbl(1).token_value :=  p_eam_res_inst_rec.operation_seq_num;
214 
215       l_out_mesg_token_tbl  := l_mesg_token_tbl;
216       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
217       (  p_message_name  => 'EAM_RI_OP_SEQ_INVALID'
218        , p_token_tbl     => l_token_tbl
219        , p_mesg_token_tbl     => l_mesg_token_tbl
220        , x_mesg_token_tbl     => l_out_mesg_token_tbl
221       );
222       l_mesg_token_tbl      := l_out_mesg_token_tbl;
223 
224       x_return_status := FND_API.G_RET_STS_ERROR;
225       x_mesg_token_tbl := l_mesg_token_tbl ;
226       return;
227 
228   end;
229 
230 
231 --  resource_seq_num
232 
233 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating resource_seq_num . . . '); END IF;
234 
235    begin
236 
237    if (p_eam_res_inst_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)) then
238 
239     select 1
240       into g_dummy
241       from wip_operation_resources wor
242      where wor.organization_id = p_eam_res_inst_rec.organization_id
243        and wor.wip_entity_id = p_eam_res_inst_rec.wip_entity_id
244        and wor.operation_seq_num = p_eam_res_inst_rec.operation_seq_num
245        and wor.resource_seq_num = p_eam_res_inst_rec.resource_seq_num;
246 
247    end if;
248 
249     x_return_status := FND_API.G_RET_STS_SUCCESS;
250 
251   exception
252     when others then
253 
254       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
255       l_token_tbl(1).token_value :=  p_eam_res_inst_rec.resource_seq_num;
256 
257       l_out_mesg_token_tbl  := l_mesg_token_tbl;
258       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
259       (  p_message_name  => 'EAM_RI_RES_SEQ_INVALID'
260        , p_token_tbl     => l_token_tbl
261        , p_mesg_token_tbl     => l_mesg_token_tbl
262        , x_mesg_token_tbl     => l_out_mesg_token_tbl
263       );
264       l_mesg_token_tbl      := l_out_mesg_token_tbl;
265 
266       x_return_status := FND_API.G_RET_STS_ERROR;
267       x_mesg_token_tbl := l_mesg_token_tbl ;
268       return;
269 
270   end;
271 
272 
273 --  instance_id
274 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating instance_id . . . '); END IF;
275 
276   declare
277     l_resource_type NUMBER;
278     l_resource_id   NUMBER;
279   begin
280 
281    if (p_eam_res_inst_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)) then
282 
283       select 1 into g_dummy from
284         bom_dept_res_instances bdri,
285         bom_department_resources bdr,
286         wip_operation_resources wor,
287         wip_operations wo where
288         wor.wip_entity_id = p_eam_res_inst_rec.wip_entity_id
289         and wor.organization_id = p_eam_res_inst_rec.organization_id
290         and wor.operation_seq_num = p_eam_res_inst_rec.operation_seq_num
291         and wor.resource_seq_num = p_eam_res_inst_rec.resource_seq_num
292         and (bdri.department_id = wo.department_id
293 	or bdri.department_id = bdr.share_from_dept_id)
294         and bdri.resource_id = wor.resource_id
295         and bdri.instance_id = p_eam_res_inst_rec.instance_id
296         and bdr.department_id = wo.department_id
297         and bdr.resource_id = wor.resource_id
298         and wo.wip_entity_id = wor.wip_entity_id
299         and wo.organization_id = wor.organization_id
300         and wo.operation_seq_num = wor.operation_seq_num;
301 
302    end if;
303 
304     x_return_status := FND_API.G_RET_STS_SUCCESS;
305 
306   exception
307     when TOO_MANY_ROWS then
308       -- Do nothing. Multiple rows mean multiple serial numbers
309       -- which are ok.
310       null;
311     when others then
312 
313           l_token_tbl(1).token_name  := 'INSTANCE_NAME';
314 	-- l_token_tbl(1).token_value :=  p_eam_res_inst_rec.resource_seq_num;
315 
316 	if p_eam_res_inst_rec.SERIAL_NUMBER is null then
317 			select full_name
318 			into l_token_tbl(1).token_value
319 			from per_all_people_f papf,bom_resource_employees bre
320 			where bre.instance_id  = p_eam_res_inst_rec.instance_id
321 			and papf.person_id = bre.person_id
322 			and( trunc(sysdate) between papf.effective_start_date
323 			and papf.effective_end_date);
324 	else
325             l_token_tbl(1).token_value := p_eam_res_inst_rec.serial_number;
326 	end if;
327 
328       l_out_mesg_token_tbl  := l_mesg_token_tbl;
329       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
330       (  p_message_name  => 'EAM_RI_INSTANCE_INVALID'
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       x_mesg_token_tbl := l_mesg_token_tbl ;
339       return;
340 
341   end;
342 
343 
344 
345 --  serial_number
346 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating serial_number . . . '); END IF;
347 
348   begin
349 
350    if (p_eam_res_inst_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)) then
351 
352     if (p_eam_res_inst_rec.serial_number is not NULL) then
353 
354       select 1
355         into g_dummy
356         from mtl_serial_numbers msn, bom_resource_equipments bre
357        where msn.inventory_item_id = bre.inventory_item_id
358          and msn.current_organization_id = bre.organization_id
359          and bre.instance_id = p_eam_res_inst_rec.instance_id
360          and msn.serial_number = p_eam_res_inst_rec.serial_number;
361 
362     end if;
363 
364    end if;
365 
366     x_return_status := FND_API.G_RET_STS_SUCCESS;
367 
368   exception
369     when others then
370 
371       l_token_tbl(1).token_name  := 'RES_SEQ_NUM';
372       l_token_tbl(1).token_value :=  p_eam_res_inst_rec.resource_seq_num;
373 
374       l_out_mesg_token_tbl  := l_mesg_token_tbl;
375       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
376       (  p_message_name  => 'EAM_RI_SERIAL_NUMBER_INVALID'
377        , p_token_tbl     => l_token_tbl
378        , p_mesg_token_tbl     => l_mesg_token_tbl
379        , x_mesg_token_tbl     => l_out_mesg_token_tbl
380       );
381       l_mesg_token_tbl      := l_out_mesg_token_tbl;
382 
383       x_return_status := FND_API.G_RET_STS_ERROR;
384       x_mesg_token_tbl := l_mesg_token_tbl ;
385       return;
386 
387   end;
388 
389 
390 --  start_date
391 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating start_date . . . '); END IF;
392 
393   begin
394 
395    if (p_eam_res_inst_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)) then
396 
397     if p_eam_res_inst_rec.start_date > p_eam_res_inst_rec.completion_date then
398       raise fnd_api.g_exc_unexpected_error;
399     end if;
400 
401    end if;
402 
403     x_return_status := FND_API.G_RET_STS_SUCCESS;
404 
405   exception
406     when others then
407 
408       l_token_tbl(1).token_name  := 'START_DATE';
409       l_token_tbl(1).token_value :=  p_eam_res_inst_rec.start_date;
410 
411       l_out_mesg_token_tbl  := l_mesg_token_tbl;
412       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
413       (  p_message_name  => 'EAM_RI_START_DATE_INVALID'
414        , p_token_tbl     => l_token_tbl
415        , p_mesg_token_tbl     => l_mesg_token_tbl
416        , x_mesg_token_tbl     => l_out_mesg_token_tbl
417       );
418       l_mesg_token_tbl      := l_out_mesg_token_tbl;
419 
420       x_return_status := FND_API.G_RET_STS_ERROR;
421       x_mesg_token_tbl := l_mesg_token_tbl ;
422       return;
423 
424   end;
425 
426   --  delete instance
427      IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating delete instance . . . '); END IF;
428 
429        declare
430          l_count_wt                NUMBER :=0;
431          l_count_wcti              NUMBER :=0;
432 	 l_resource_id		   NUMBER;
433 
434 	 CURSOR res_inst IS select RESOURCE_id
435          from wip_operation_resources
436 	 where wip_entity_id =  p_eam_res_inst_rec.wip_entity_id
437 	  and operation_seq_num     = p_eam_res_inst_rec.operation_seq_num
438           and resource_seq_num      = p_eam_res_inst_rec.resource_seq_num;
439        begin
440 
441        if (p_eam_res_inst_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE) then
442 
443     open res_inst;
444     fetch res_inst into l_resource_id;
445     close res_inst;
446 
447 
448              select count(*)
449              into l_count_wt
450              from DUAL
451 	     WHERE EXISTS (SELECT 1
452 	                    FROM wip_transactions
453 			    where wip_entity_id         = p_eam_res_inst_rec.wip_entity_id
454 			      and organization_id       = p_eam_res_inst_rec.organization_id
455 			      and operation_seq_num     = p_eam_res_inst_rec.operation_seq_num
456 			      and resource_seq_num      = p_eam_res_inst_rec.resource_seq_num
457 			      and resource_id           = l_resource_id
458 			      and instance_id		= p_eam_res_inst_rec.instance_id)
459 	      AND rownum <=1  ;
460 
461 
462 
463            if(l_count_wt > 0) then
464              raise fnd_api.g_exc_unexpected_error;
465            end if;
466 
467              select count(*)
468              into l_count_wcti
469              from DUAL
470 	     WHERE EXISTS (SELECT 1
471 	                    FROM wip_cost_txn_interface
472 			    where wip_entity_id         = p_eam_res_inst_rec.wip_entity_id
473 			      and organization_id       = p_eam_res_inst_rec.organization_id
474 			      and operation_seq_num     = p_eam_res_inst_rec.operation_seq_num
475 			      and resource_seq_num      = p_eam_res_inst_rec.resource_seq_num
476 			      and resource_id           = l_resource_id
477       			      and instance_id		= p_eam_res_inst_rec.instance_id)
478     	      AND rownum <=1  ;
479 
480 
481            if(l_count_wcti > 0) then
482              raise fnd_api.g_exc_unexpected_error;
483            end if;
484 
485 
486        end if;
487 
488          x_return_status := FND_API.G_RET_STS_SUCCESS;
489 
490        exception
491          when others then
492 
493            l_token_tbl(1).token_name  := 'WIP_ENTITY_ID';
494            l_token_tbl(1).token_value :=  p_eam_res_inst_rec.wip_entity_id;
495 
496            l_out_mesg_token_tbl  := l_mesg_token_tbl;
497            EAM_ERROR_MESSAGE_PVT.Add_Error_Token
498            (  p_message_name  => 'EAM_RES_INST_DELETE_INVALID'
499             , p_token_tbl     => l_token_tbl
500             , p_mesg_token_tbl     => l_mesg_token_tbl
501             , x_mesg_token_tbl     => l_out_mesg_token_tbl
502            );
503            l_mesg_token_tbl      := l_out_mesg_token_tbl;
504 
505            x_return_status := FND_API.G_RET_STS_ERROR;
506            x_mesg_token_tbl := l_mesg_token_tbl ;
507            return;
508 
509        end;
510 
511 
512         x_return_status := FND_API.G_RET_STS_SUCCESS;
513 
514         IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within Resource Instance Check Attributes . . . '); END IF;
515 
516     END Check_Attributes;
517 
518     /*********************************************************************
519     * Procedure     : Check_Required
520     * Parameters IN : Resource Instance column record
521     * Parameters OUT NOCOPY: Mesg Token Table
522     *                 Return_Status
523     * Purpose       :
524     **********************************************************************/
525 
526     PROCEDURE Check_Required
527         (  p_eam_res_inst_rec         IN EAM_PROCESS_WO_PUB.eam_res_inst_rec_type
528          , x_return_status            OUT NOCOPY VARCHAR2
529          , x_Mesg_Token_Tbl           OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
530          )
531     IS
532             l_Mesg_Token_Tbl          EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
533             l_out_Mesg_Token_Tbl          EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
534             l_Token_Tbl               EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
535     BEGIN
536 
537         x_return_status := FND_API.G_RET_STS_SUCCESS;
538 
539 
540         IF p_eam_res_inst_rec.wip_entity_id IS NULL
541         THEN
542             l_token_tbl(1).token_name  := 'INSTANCE_ID';
543             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
544 
545             l_out_mesg_token_tbl  := l_mesg_token_tbl;
546             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
547             (  p_message_name	=> 'EAM_RI_ENTITY_ID_REQUIRED'
548              , p_token_tbl		=> l_Token_tbl
549              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
550              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
551              );
552             l_mesg_token_tbl      := l_out_mesg_token_tbl;
553 
554             x_return_status := FND_API.G_RET_STS_ERROR;
555 
556         END IF;
557 
558 
559         IF p_eam_res_inst_rec.organization_id IS NULL
560         THEN
561             l_token_tbl(1).token_name  := 'INSTANCE_ID';
562             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
563 
564             l_out_mesg_token_tbl  := l_mesg_token_tbl;
565             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
566             (  p_message_name	=> 'EAM_RI_ORG_REQUIRED'
567              , p_token_tbl		=> l_Token_tbl
568              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
569              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
570              );
571             l_mesg_token_tbl      := l_out_mesg_token_tbl;
572 
573             x_return_status := FND_API.G_RET_STS_ERROR;
574 
575         END IF;
576 
577         IF p_eam_res_inst_rec.operation_seq_num IS NULL
578         THEN
579             l_token_tbl(1).token_name  := 'INSTANCE_ID';
580             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
581 
582             l_out_mesg_token_tbl  := l_mesg_token_tbl;
583             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
584             (  p_message_name	=> 'EAM_RI_OP_SEQ_REQUIRED'
585              , p_token_tbl		=> l_Token_tbl
586              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
587              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
588              );
589             l_mesg_token_tbl      := l_out_mesg_token_tbl;
590 
591             x_return_status := FND_API.G_RET_STS_ERROR;
592 
593         END IF;
594 
595 
596         IF p_eam_res_inst_rec.resource_seq_num IS NULL
597         THEN
598             l_token_tbl(1).token_name  := 'INSTANCE_ID';
599             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
600 
601             l_out_mesg_token_tbl  := l_mesg_token_tbl;
602             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
603             (  p_message_name	=> 'EAM_RI_RES_REQ_REQUIRED'
604              , p_token_tbl		=> l_Token_tbl
605              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
606              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
607              );
608             l_mesg_token_tbl      := l_out_mesg_token_tbl;
609 
610             x_return_status := FND_API.G_RET_STS_ERROR;
611 
612         END IF;
613 
614 
615         IF p_eam_res_inst_rec.instance_id IS NULL
616         THEN
617             l_token_tbl(1).token_name  := 'INSTANCE_ID';
618             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
619 
620             l_out_mesg_token_tbl  := l_mesg_token_tbl;
621             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
622             (  p_message_name	=> 'EAM_RI_INSTANCE_REQUIRED'
623              , p_token_tbl		=> l_Token_tbl
624              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
625              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
626              );
627             l_mesg_token_tbl      := l_out_mesg_token_tbl;
628 
629             x_return_status := FND_API.G_RET_STS_ERROR;
630 
631         END IF;
632 
633 
634         IF p_eam_res_inst_rec.start_date IS NULL
635         THEN
636             l_token_tbl(1).token_name  := 'INSTANCE_ID';
637             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
638 
639             l_out_mesg_token_tbl  := l_mesg_token_tbl;
640             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
641             (  p_message_name	=> 'EAM_RI_START_DATE_REQUIRED'
642              , p_token_tbl		=> l_Token_tbl
643              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
644              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
645              );
646             l_mesg_token_tbl      := l_out_mesg_token_tbl;
647 
648             x_return_status := FND_API.G_RET_STS_ERROR;
649 
650         END IF;
651 
652 
653         IF p_eam_res_inst_rec.completion_date IS NULL
654         THEN
655             l_token_tbl(1).token_name  := 'INSTANCE_ID';
656             l_token_tbl(1).token_value :=  p_eam_res_inst_rec.instance_id;
657 
658             l_out_mesg_token_tbl  := l_mesg_token_tbl;
659             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
660             (  p_message_name	=> 'EAM_RI_COMPL_DATE_REQUIRED'
661              , p_token_tbl		=> l_Token_tbl
662              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
663              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
664              );
665             l_mesg_token_tbl      := l_out_mesg_token_tbl;
666 
667             x_return_status := FND_API.G_RET_STS_ERROR;
668 
669         END IF;
670 
671 
672         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
673 
674     END Check_Required;
675 
676 END EAM_RES_INST_VALIDATE_PVT;