DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_RES_UTILITY_PVT

Source


1 PACKAGE BODY EAM_RES_UTILITY_PVT AS
2 /* $Header: EAMVRSUB.pls 120.1 2008/05/06 23:21:48 mashah ship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVRSUB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_RES_UTILITY_PVT
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  30-JUN-2002    Kenichi Nagumo     Initial Creation
21 ***************************************************************************/
22 
23 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'EAM_RES_UTILITY_PVT';
24 
25         /*********************************************************************
26         * Procedure     : Query_Row
27         * Parameters IN : wip entity id
28         *                 organization Id
29         *                 operation_seq_num
30         *                 resource_seq_num
31         * Parameters OUT NOCOPY: Resources column record
32         *                 Mesg token Table
33         *                 Return Status
34         * Purpose       : Procedure will query the database record
35         *                 and return with those records.
36         ***********************************************************************/
37 
38         PROCEDURE Query_Row
39         (  p_wip_entity_id       IN  NUMBER
40          , p_organization_id     IN  NUMBER
41          , p_operation_seq_num   IN  NUMBER
42          , p_resource_seq_num    IN  NUMBER
43          , x_eam_res_rec         OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_rec_type
44          , x_Return_status       OUT NOCOPY VARCHAR2
45         )
46         IS
47                 l_eam_res_rec           EAM_PROCESS_WO_PUB.eam_res_rec_type;
48                 l_return_status         VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
49                 l_dummy                 varchar2(10);
50         BEGIN
51 
52                 SELECT
53                          resource_id
54                        , uom_code
55                        , basis_type
56                        , usage_rate_or_amount
57                        , activity_id
58                        , scheduled_flag
59 		       , firm_flag
60                        , assigned_units
61 		       , maximum_assigned_units
62                        , autocharge_type
63                        , standard_rate_flag
64                        , applied_resource_units
65                        , applied_resource_value
66                        , start_date
67                        , completion_date
68                        , schedule_seq_num
69                        , substitute_group_num
70                        , replacement_group_num
71                        , attribute_category
72                        , attribute1
73                        , attribute2
74                        , attribute3
75                        , attribute4
76                        , attribute5
77                        , attribute6
78                        , attribute7
79                        , attribute8
80                        , attribute9
81                        , attribute10
82                        , attribute11
83                        , attribute12
84                        , attribute13
85                        , attribute14
86                        , attribute15
87                        , department_id
88                 INTO
89                          l_eam_res_rec.resource_id
90                        , l_eam_res_rec.uom_code
91                        , l_eam_res_rec.basis_type
92                        , l_eam_res_rec.usage_rate_or_amount
93                        , l_eam_res_rec.activity_id
94                        , l_eam_res_rec.scheduled_flag
95                        , l_eam_res_rec.firm_flag
96                        , l_eam_res_rec.assigned_units
97                        , l_eam_res_rec.maximum_assigned_units
98                        , l_eam_res_rec.autocharge_type
99                        , l_eam_res_rec.standard_rate_flag
100                        , l_eam_res_rec.applied_resource_units
101                        , l_eam_res_rec.applied_resource_value
102                        , l_eam_res_rec.start_date
103                        , l_eam_res_rec.completion_date
104                        , l_eam_res_rec.schedule_seq_num
105                        , l_eam_res_rec.substitute_group_num
106                        , l_eam_res_rec.replacement_group_num
107                        , l_eam_res_rec.attribute_category
108                        , l_eam_res_rec.attribute1
109                        , l_eam_res_rec.attribute2
110                        , l_eam_res_rec.attribute3
111                        , l_eam_res_rec.attribute4
112                        , l_eam_res_rec.attribute5
113                        , l_eam_res_rec.attribute6
114                        , l_eam_res_rec.attribute7
115                        , l_eam_res_rec.attribute8
116                        , l_eam_res_rec.attribute9
117                        , l_eam_res_rec.attribute10
118                        , l_eam_res_rec.attribute11
119                        , l_eam_res_rec.attribute12
120                        , l_eam_res_rec.attribute13
121                        , l_eam_res_rec.attribute14
122                        , l_eam_res_rec.attribute15
123                        , l_eam_res_rec.department_id
124                 FROM     wip_operation_resources
125                 WHERE    wip_entity_id = p_wip_entity_id
126                   AND    organization_id = p_organization_id
127                   AND    operation_seq_num = p_operation_seq_num
128                   AND    resource_seq_num = p_resource_seq_num;
129 
130                 x_return_status  := EAM_PROCESS_WO_PVT.G_RECORD_FOUND;
131                 x_eam_res_rec     := l_eam_res_rec;
132 
133         EXCEPTION
134                 WHEN NO_DATA_FOUND THEN
135                         x_return_status := EAM_PROCESS_WO_PVT.G_RECORD_NOT_FOUND;
136                         x_eam_res_rec    := l_eam_res_rec;
137 
138                 WHEN OTHERS THEN
139                         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
140                         x_eam_res_rec    := l_eam_res_rec;
141 
142         END Query_Row;
143 
144 
145         /********************************************************************
146         * Procedure     : Insert_Row
147         * Parameters IN : Resources column record
148         * Parameters OUT NOCOPY: Message Token Table
149         *                 Return Status
150         * Purpose       : Procedure will perfrom an insert into the
151         *                 win_operation_resources table.
152         *********************************************************************/
153 
154         PROCEDURE Insert_Row
155         (  p_eam_res_rec        IN  EAM_PROCESS_WO_PUB.eam_res_rec_type
156          , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
157          , x_return_Status      OUT NOCOPY VARCHAR2
158          )
159         IS
160 		l_return_status    VARCHAR2(30) := '';
161 		l_msg_count        NUMBER       := 0;
162 		l_msg_data         VARCHAR2(2000) := '';
163 
164         BEGIN
165 
166 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Writing Resource rec for ' || p_eam_res_rec.resource_seq_num); END IF;
167 
168 	-- bug no 3444091
169 	if p_eam_res_rec.start_date > p_eam_res_rec.completion_date then
170 		x_return_status := fnd_api.g_ret_sts_error;
171 		fnd_message.set_name('EAM','EAM_WO_RR_DT_ERR');
172                 return;
173 	end if;
174 
175                 INSERT INTO WIP_OPERATION_RESOURCES
176                        ( wip_entity_id
177                        , organization_id
178                        , operation_seq_num
179                        , resource_seq_num
180                        , resource_id
181                        , uom_code
182                        , basis_type
183                        , usage_rate_or_amount
184                        , activity_id
185                        , scheduled_flag
186 		       , firm_flag
187                        , assigned_units
188                        , maximum_assigned_units
189                        , autocharge_type
190                        , standard_rate_flag
191                        , applied_resource_units
192                        , applied_resource_value
193                        , start_date
194                        , completion_date
195                        , schedule_seq_num
196                        , substitute_group_num
197                        , replacement_group_num
198                        , attribute_category
199                        , attribute1
200                        , attribute2
201                        , attribute3
202                        , attribute4
203                        , attribute5
204                        , attribute6
205                        , attribute7
206                        , attribute8
207                        , attribute9
208                        , attribute10
209                        , attribute11
210                        , attribute12
211                        , attribute13
212                        , attribute14
213                        , attribute15
214                        , department_id
215                        , last_update_date
216                        , last_updated_by
217                        , creation_date
218                        , created_by
219                        , last_update_login
220                        , request_id
221                        , program_application_id
222                        , program_id
223                        , program_update_date)
224                 VALUES
225                        ( p_eam_res_rec.wip_entity_id
226                        , p_eam_res_rec.organization_id
227                        , p_eam_res_rec.operation_seq_num
228                        , p_eam_res_rec.resource_seq_num
229                        , p_eam_res_rec.resource_id
230                        , p_eam_res_rec.uom_code
231                        , p_eam_res_rec.basis_type
232                        , p_eam_res_rec.usage_rate_or_amount
233                        , p_eam_res_rec.activity_id
234                        , p_eam_res_rec.scheduled_flag
235                        , p_eam_res_rec.firm_flag
236                        , p_eam_res_rec.assigned_units
237                        , p_eam_res_rec.maximum_assigned_units
238                        , p_eam_res_rec.autocharge_type
239                        , p_eam_res_rec.standard_rate_flag
240                        , p_eam_res_rec.applied_resource_units
241                        , p_eam_res_rec.applied_resource_value
242                        , p_eam_res_rec.start_date
243                        , p_eam_res_rec.completion_date
244                        , p_eam_res_rec.schedule_seq_num
245                        , p_eam_res_rec.substitute_group_num
246                        , p_eam_res_rec.replacement_group_num
247                        , p_eam_res_rec.attribute_category
248                        , p_eam_res_rec.attribute1
249                        , p_eam_res_rec.attribute2
250                        , p_eam_res_rec.attribute3
251                        , p_eam_res_rec.attribute4
252                        , p_eam_res_rec.attribute5
253                        , p_eam_res_rec.attribute6
254                        , p_eam_res_rec.attribute7
255                        , p_eam_res_rec.attribute8
256                        , p_eam_res_rec.attribute9
257                        , p_eam_res_rec.attribute10
258                        , p_eam_res_rec.attribute11
259                        , p_eam_res_rec.attribute12
260                        , p_eam_res_rec.attribute13
261                        , p_eam_res_rec.attribute14
262                        , p_eam_res_rec.attribute15
263                        , p_eam_res_rec.department_id
264                        , SYSDATE
265                        , FND_GLOBAL.user_id
266                        , SYSDATE
267                        , FND_GLOBAL.user_id
268                        , FND_GLOBAL.login_id
269                        , p_eam_res_rec.request_id
270                        , p_eam_res_rec.program_application_id
271                        , p_eam_res_rec.program_id
272                        , SYSDATE);
273 
274 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Creating new resources') ; END IF;
275 
276 
277                 x_return_status := FND_API.G_RET_STS_SUCCESS;
278 
279 		  -- API is called to set the estimation_status
280 		  EAM_AutomaticEst.Auto_Reest_of_Cost(
281 		    p_wip_entity_id =>  p_eam_res_rec.wip_entity_id,
282 		    p_api_name => 'EAM',
283 		    p_req_line_id => NULL,
284 		    p_po_dist_id => NULL,
285 		    p_po_line_id => NULL,
286 		    p_inv_item_id => NULL,
287 		    p_org_id => p_eam_res_rec.organization_id,
288 		    p_resource_id => NULL,
289 		    x_return_status => l_return_status,
290 		    x_msg_count => l_msg_count,
291 		    x_msg_data => l_msg_data
292 		    );
293 
294 
295         EXCEPTION
296             WHEN OTHERS THEN
297                         EAM_ERROR_MESSAGE_PVT.Add_Error_Token
298                         (  p_message_name       => NULL
299                          , p_message_text       => G_PKG_NAME ||' :Inserting Record ' || SQLERRM
300                          , x_mesg_token_Tbl     => x_mesg_token_tbl
301                         );
302 
303                         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
304 
305         END Insert_Row;
306 
307         /********************************************************************
308         * Procedure     : Update_Row
309         * Parameters IN : Resources column record
310         * Parameters OUT NOCOPY: Message Token Table
311         *                 Return Status
312         * Purpose       : Procedure will perfrom an Update on the
313         *                 wip_operation_resources table.
314         *********************************************************************/
315 
316         PROCEDURE Update_Row
317         (  p_eam_res_rec        IN  EAM_PROCESS_WO_PUB.eam_res_rec_type
318          , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
319          , x_return_Status      OUT NOCOPY VARCHAR2
320          )
321         IS
322 		l_return_status              VARCHAR2(30) := '';
323 		l_msg_count                  NUMBER       := 0;
324 		l_msg_data                 VARCHAR2(2000) := '';
325 		l_usage_rate_or_amount           NUMBER   := 0;
326 
327 	BEGIN
328 
329 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Updating Resource: '|| p_eam_res_rec.resource_seq_num); END IF;
330 
331 -- bug no 3444091
332 	if p_eam_res_rec.start_date > p_eam_res_rec.completion_date then
333 		x_return_status := fnd_api.g_ret_sts_error;
334 		fnd_message.set_name('EAM','EAM_WO_RR_DT_ERR');
335                 return;
336 	end if;
337 
338 	   SELECT usage_rate_or_amount
339 	     INTO l_usage_rate_or_amount
340 	     FROM WIP_OPERATION_RESOURCES
341 	    WHERE wip_entity_id     = p_eam_res_rec.wip_entity_id
342               AND organization_id   = p_eam_res_rec.organization_id
343               AND operation_seq_num = p_eam_res_rec.operation_seq_num
344               AND resource_seq_num  = p_eam_res_rec.resource_seq_num;
345 
346                 UPDATE WIP_OPERATION_RESOURCES
347                 SET      resource_id                 = p_eam_res_rec.resource_id
348                        , uom_code                    = p_eam_res_rec.uom_code
349                        , basis_type                  = p_eam_res_rec.basis_type
350                        , usage_rate_or_amount        = p_eam_res_rec.usage_rate_or_amount
351                        , activity_id                 = p_eam_res_rec.activity_id
352                        , scheduled_flag              = p_eam_res_rec.scheduled_flag
353                        , firm_flag                   = p_eam_res_rec.firm_flag
354                        , assigned_units              = p_eam_res_rec.assigned_units
355                        , maximum_assigned_units      = p_eam_res_rec.maximum_assigned_units
356                        , autocharge_type             = p_eam_res_rec.autocharge_type
357                        , standard_rate_flag          = p_eam_res_rec.standard_rate_flag
358                        , applied_resource_units      = p_eam_res_rec.applied_resource_units
359                        , applied_resource_value      = p_eam_res_rec.applied_resource_value
360                        , start_date                  = p_eam_res_rec.start_date
361                        , completion_date             = p_eam_res_rec.completion_date
362                        , schedule_seq_num            = p_eam_res_rec.schedule_seq_num
363                        , substitute_group_num        = p_eam_res_rec.substitute_group_num
364                        , replacement_group_num       = p_eam_res_rec.replacement_group_num
365                        , attribute_category          = p_eam_res_rec.attribute_category
366                        , attribute1                  = p_eam_res_rec.attribute1
367                        , attribute2                  = p_eam_res_rec.attribute2
368                        , attribute3                  = p_eam_res_rec.attribute3
369                        , attribute4                  = p_eam_res_rec.attribute4
370                        , attribute5                  = p_eam_res_rec.attribute5
371                        , attribute6                  = p_eam_res_rec.attribute6
372                        , attribute7                  = p_eam_res_rec.attribute7
373                        , attribute8                  = p_eam_res_rec.attribute8
374                        , attribute9                  = p_eam_res_rec.attribute9
375                        , attribute10                 = p_eam_res_rec.attribute10
376                        , attribute11                 = p_eam_res_rec.attribute11
377                        , attribute12                 = p_eam_res_rec.attribute12
378                        , attribute13                 = p_eam_res_rec.attribute13
379                        , attribute14                 = p_eam_res_rec.attribute14
380                        , attribute15                 = p_eam_res_rec.attribute15
381                        , department_id               = p_eam_res_rec.department_id --added for 12.1 crew scheduling project
382                        , last_update_date            = SYSDATE
383                        , last_updated_by             = FND_GLOBAL.user_id
384                        , last_update_login           = FND_GLOBAL.login_id
385                        , request_id                  = p_eam_res_rec.request_id
386                        , program_application_id      = p_eam_res_rec.program_application_id
387                        , program_id                  = p_eam_res_rec.program_id
388                        , program_update_date         = SYSDATE
389                 WHERE    wip_entity_id     = p_eam_res_rec.wip_entity_id
390                   AND    organization_id   = p_eam_res_rec.organization_id
391                   AND    operation_seq_num = p_eam_res_rec.operation_seq_num
392                   AND    resource_seq_num  = p_eam_res_rec.resource_seq_num;
393 
394 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Updating resources') ; END IF;
395 
396                 x_return_status := FND_API.G_RET_STS_SUCCESS;
397 
398 		    -- comparing new usage rate with existing
399 		    IF ( p_eam_res_rec.usage_rate_or_amount <> l_usage_rate_or_amount )THEN
400 
401 		      -- API is called to set the estimation_status
402 		      EAM_AutomaticEst.Auto_Reest_of_Cost(
403 			p_wip_entity_id => p_eam_res_rec.wip_entity_id,
404 			p_api_name => 'EAM',
405 			p_req_line_id => NULL,
406 			p_po_dist_id => NULL,
407 			p_po_line_id => NULL,
408 			p_inv_item_id => NULL,
409 			p_org_id => p_eam_res_rec.organization_id,
410 			p_resource_id => NULL,
411 			x_return_status => l_return_status,
412 			x_msg_count => l_msg_count,
413 			x_msg_data => l_msg_data
414 			);
415 
416 		    END IF; /* ENDIF of comparing usage rate IF */
417 
418         END Update_Row;
419 
420         /********************************************************************
421         * Procedure     : Delete_Row
422         * Parameters IN : Resources column record
423         * Parameters OUT NOCOPY: Message Token Table
424         *                 Return Status
425         * Purpose       : Procedure will perfrom an Update on the
426         *                 wip_operation_resources table.
427         *********************************************************************/
428 
429         PROCEDURE Delete_Row
430         (  p_eam_res_rec        IN  EAM_PROCESS_WO_PUB.eam_res_rec_type
431          , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
432          , x_return_Status      OUT NOCOPY VARCHAR2
433          )
434         IS
435                 l_Mesg_Token_tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
436               --  l_return_status         VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
437 		l_return_status              VARCHAR2(30) := '';
438 		l_msg_count                  NUMBER       := 0;
439 		l_msg_data                 VARCHAR2(2000) := '';
440 
441 	BEGIN
442 
443 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Deleting Resource Usage') ; END IF;
444 
445                 EAM_RES_USAGE_UTILITY_PVT.Delete_Usage
446                 ( p_wip_entity_id      => p_eam_res_rec.wip_entity_id
447                 , p_organization_id    => p_eam_res_rec.organization_id
448                 , p_operation_seq_num  => p_eam_res_rec.operation_seq_num
449                 , p_resource_seq_num   => p_eam_res_rec.resource_seq_num
450                 , x_mesg_token_Tbl     => l_mesg_token_Tbl
451                 , x_return_Status      => l_return_Status
452                 );
453 
454 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Deleting Resource Instance for '|| p_eam_res_rec.resource_seq_num); END IF;
455 
456                 DELETE FROM WIP_OP_RESOURCE_INSTANCES
457                 WHERE    wip_entity_id     = p_eam_res_rec.wip_entity_id
458                   AND    organization_id   = p_eam_res_rec.organization_id
459                   AND    operation_seq_num = p_eam_res_rec.operation_seq_num
460                   AND    resource_seq_num  = p_eam_res_rec.resource_seq_num;
461 
462 
463 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Deleting Resource: '|| p_eam_res_rec.resource_seq_num); END IF;
464 
465                 DELETE FROM WIP_OPERATION_RESOURCES
466                 WHERE    wip_entity_id     = p_eam_res_rec.wip_entity_id
467                   AND    organization_id   = p_eam_res_rec.organization_id
468                   AND    operation_seq_num = p_eam_res_rec.operation_seq_num
469                   AND    resource_seq_num  = p_eam_res_rec.resource_seq_num;
470 
471                 x_return_status  := l_return_status;
472                 x_mesg_token_tbl := l_mesg_token_tbl;
473 --              x_return_status := FND_API.G_RET_STS_SUCCESS;
474 
475 		      -- API is called to set the estimation_status
476 		      EAM_AutomaticEst.Auto_Reest_of_Cost(
477 			p_wip_entity_id => p_eam_res_rec.wip_entity_id,
478 			p_api_name => 'EAM',
479 			p_req_line_id => NULL,
480 			p_po_dist_id => NULL,
481 			p_po_line_id => NULL,
482 			p_inv_item_id => NULL,
483 			p_org_id => p_eam_res_rec.organization_id,
484 			p_resource_id => NULL,
485 			x_return_status => l_return_status,
486 			x_msg_count => l_msg_count,
487 			x_msg_data => l_msg_data
488 			);
489 
490 
491         END Delete_Row;
492 
493 
494         /*********************************************************************
495         * Procedure     : Perform_Writes
496         * Parameters IN : Resources Column Record
497         * Parameters OUT NOCOPY: Messgae Token Table
498         *                 Return Status
499         * Purpose       : This is the only procedure that the user will have
500         *                 access to when he/she needs to perform any kind of
501         *                 writes to the wip_operations.
502         *********************************************************************/
503 
504         PROCEDURE Perform_Writes
505         (  p_eam_res_rec        IN  EAM_PROCESS_WO_PUB.eam_res_rec_type
506          , x_mesg_token_tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
507          , x_return_status      OUT NOCOPY VARCHAR2
508         )
509         IS
510                 l_Mesg_Token_tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
511                 l_return_status         VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
512         BEGIN
513 
514                 IF p_eam_res_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
515                 THEN
516                         Insert_Row
517                         (  p_eam_res_rec         => p_eam_res_rec
518                          , x_mesg_token_Tbl     => l_mesg_token_tbl
519                          , x_return_Status      => l_return_status
520                          );
521                 ELSIF p_eam_res_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
522                 THEN
523                         Update_Row
524                         (  p_eam_res_rec         => p_eam_res_rec
525                          , x_mesg_token_Tbl     => l_mesg_token_tbl
526                          , x_return_Status      => l_return_status
527                          );
528                 ELSIF p_eam_res_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE
529                 THEN
530                         Delete_Row
531                         (  p_eam_res_rec         => p_eam_res_rec
532                          , x_mesg_token_Tbl     => l_mesg_token_tbl
533                          , x_return_Status      => l_return_status
534                          );
535 
536                 END IF;
537 
538                 x_return_status := l_return_status;
539                 x_mesg_token_tbl := l_mesg_token_tbl;
540 
541         END Perform_Writes;
542 
543         FUNCTION  NUM_OF_ROW
544         ( p_wip_entity_id  IN NUMBER
545         , p_organization_id IN NUMBER
546         , p_operation_seq_num IN NUMBER
547         ) RETURN BOOLEAN IS
548 
549            l_count NUMBER := 0 ;
550 
551            BEGIN
552              SELECT  count(*)  into l_count
553                FROM dual
554                WHERE exists (
555                                  SELECT 1
556                                                          FROM wip_operation_resources
557                                                          WHERE operation_seq_num = p_operation_seq_num
558                                                          and wip_entity_id = p_wip_entity_id
559                                                          and organization_id = p_organization_id
560                                                    ) ;
561 
562                    IF ( l_count = 0 ) THEN
563                        return FALSE ;
564                    ELSE
565                            return TRUE ;
566                    END IF;
567 
568         END NUM_OF_ROW;
569 
570 
571 	PROCEDURE CREATE_OSP_REQ
572 	(
573 	 p_eam_res_tbl       IN    EAM_PROCESS_WO_PUB.eam_res_tbl_type
574          , x_return_status      OUT NOCOPY VARCHAR2
575 	)
576 	IS
577 	   I NUMBER;
578 	   l_eam_res_rec   EAM_PROCESS_WO_PUB.eam_res_rec_type;
579 
580 	BEGIN
581 	   x_return_status := FND_API.G_RET_STS_SUCCESS;
582 
583 	      FOR I IN 1..p_eam_res_tbl.COUNT LOOP
584 
585 
586 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Processing osp creation for resource'|| I || ' record') ; END IF ;
587 
588                 --  Load local records.
589                 l_eam_res_rec := p_eam_res_tbl(I);
590 
591                 IF(l_eam_res_rec.transaction_type= EAM_PROCESS_WO_PVT.G_OPR_CREATE  AND
592 		  l_eam_res_rec.autocharge_type=WIP_CONSTANTS.PO_RECEIPT) THEN
593 
594 		  IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('inside if to create req') ; END IF ;
595                     WIP_OSP.CREATE_REQUISITION(
596                                                P_Wip_Entity_Id          =>l_eam_res_rec.wip_entity_id,
597                                                P_Organization_Id        =>l_eam_res_rec.organization_id,
598                                                P_Repetitive_Schedule_Id =>NULL,
599                                                P_Operation_Seq_Num      =>l_eam_res_rec.operation_seq_num,
600                                                P_Resource_Seq_Num       =>l_eam_res_rec.resource_seq_num,
601                                                P_Run_ReqImport          =>WIP_CONSTANTS.YES
602                                                 );
603 		 END IF;
604 
605 
606 	    END LOOP;
607 	EXCEPTION
608 	  WHEN OTHERS THEN
609 	   x_return_status := EAM_ERROR_MESSAGE_PVT.G_STATUS_ERROR;
610 	   IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Exception in creating req for osp') ; END IF ;
611 	END CREATE_OSP_REQ;
612 
613 
614 
615 END EAM_RES_UTILITY_PVT;