DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_MAT_REQ_UTILITY_PVT

Source


1 PACKAGE BODY EAM_MAT_REQ_UTILITY_PVT AS
2 /* $Header: EAMVMRUB.pls 120.3 2005/11/17 22:26:34 mmaduska noship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVMRUB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_MAT_REQ_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_MAT_REQ_UTILITY_PVT';
24 
25         /*********************************************************************
26         * Procedure     : Query_Row
27         * Parameters IN : wip entity id
28         *                 organization Id
29         *                 operation_seq_num
30         *                 inventory_item_id
31         * Parameters OUT NOCOPY: Material Requirements 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_inventory_item_id   IN  NUMBER
43          , x_eam_mat_req_rec     OUT NOCOPY EAM_PROCESS_WO_PUB.eam_mat_req_rec_type
44          , x_Return_status       OUT NOCOPY VARCHAR2
45         )
46         IS
47                 l_eam_mat_req_rec       EAM_PROCESS_WO_PUB.eam_mat_req_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                          wip_entity_id
54                        , operation_seq_num
55                        , organization_id
56                        , inventory_item_id
57                        , quantity_per_assembly
58                        , department_id
59                        , wip_supply_type
60                        , date_required
61                        , required_quantity
62                        , quantity_issued
63                        , supply_subinventory
64                        , supply_locator_id
65                        , mrp_net_flag
66                        , mps_required_quantity
67                        , mps_date_required
68                        , component_sequence_id
69                        , comments
70                        , attribute_category
71                        , attribute1
72                        , attribute2
73                        , attribute3
74                        , attribute4
75                        , attribute5
76                        , attribute6
77                        , attribute7
78                        , attribute8
79                        , attribute9
80                        , attribute10
81                        , attribute11
82                        , attribute12
83                        , attribute13
84                        , attribute14
85                        , attribute15
86                        , auto_request_material
87                        , suggested_vendor_name
88                        , vendor_id
89                        , unit_price
90 		       , released_quantity
91                 INTO
92                          l_eam_mat_req_rec.wip_entity_id
93                        , l_eam_mat_req_rec.operation_seq_num
94                        , l_eam_mat_req_rec.organization_id
95                        , l_eam_mat_req_rec.inventory_item_id
96                        , l_eam_mat_req_rec.quantity_per_assembly
97                        , l_eam_mat_req_rec.department_id
98                        , l_eam_mat_req_rec.wip_supply_type
99                        , l_eam_mat_req_rec.date_required
100                        , l_eam_mat_req_rec.required_quantity
101                        , l_eam_mat_req_rec.quantity_issued
102                        , l_eam_mat_req_rec.supply_subinventory
103                        , l_eam_mat_req_rec.supply_locator_id
104                        , l_eam_mat_req_rec.mrp_net_flag
105                        , l_eam_mat_req_rec.mps_required_quantity
106                        , l_eam_mat_req_rec.mps_date_required
107                        , l_eam_mat_req_rec.component_sequence_id
108                        , l_eam_mat_req_rec.comments
109                        , l_eam_mat_req_rec.attribute_category
110                        , l_eam_mat_req_rec.attribute1
111                        , l_eam_mat_req_rec.attribute2
112                        , l_eam_mat_req_rec.attribute3
113                        , l_eam_mat_req_rec.attribute4
114                        , l_eam_mat_req_rec.attribute5
115                        , l_eam_mat_req_rec.attribute6
116                        , l_eam_mat_req_rec.attribute7
117                        , l_eam_mat_req_rec.attribute8
118                        , l_eam_mat_req_rec.attribute9
119                        , l_eam_mat_req_rec.attribute10
120                        , l_eam_mat_req_rec.attribute11
121                        , l_eam_mat_req_rec.attribute12
122                        , l_eam_mat_req_rec.attribute13
123                        , l_eam_mat_req_rec.attribute14
124                        , l_eam_mat_req_rec.attribute15
125                        , l_eam_mat_req_rec.auto_request_material
126                        , l_eam_mat_req_rec.suggested_vendor_name
127                        , l_eam_mat_req_rec.vendor_id
128                        , l_eam_mat_req_rec.unit_price
129 		       , l_eam_mat_req_rec.released_quantity
130                 FROM  wip_requirement_operations wro
131                 WHERE wro.wip_entity_id = p_wip_entity_id
132                 AND   wro.organization_id = p_organization_id
133                 AND   wro.operation_seq_num = p_operation_seq_num
134                 AND   wro.inventory_item_id = p_inventory_item_id;
135 
136                 x_return_status  := EAM_PROCESS_WO_PVT.G_RECORD_FOUND;
137                 x_eam_mat_req_rec     := l_eam_mat_req_rec;
138 
139         EXCEPTION
140                 WHEN NO_DATA_FOUND THEN
141                         x_return_status := EAM_PROCESS_WO_PVT.G_RECORD_NOT_FOUND;
142                         x_eam_mat_req_rec    := l_eam_mat_req_rec;
143 
144                 WHEN OTHERS THEN
145                         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
146                         x_eam_mat_req_rec    := l_eam_mat_req_rec;
147 
148         END Query_Row;
149 
150 
151         /********************************************************************
152         * Procedure     : Insert_Row
153         * Parameters IN : Material Requirements column record
154         * Parameters OUT NOCOPY: Message Token Table
155         *                 Return Status
156         * Purpose       : Procedure will perfrom an insert into the
157         *                 wip_operations table.
158         *********************************************************************/
159 
160         PROCEDURE Insert_Row
161         (  p_eam_mat_req_rec    IN  EAM_PROCESS_WO_PUB.eam_mat_req_rec_type
162          , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
163          , x_return_Status      OUT NOCOPY VARCHAR2
164          )
165         IS
166 		l_return_status    VARCHAR2(30);
167 		l_msg_count        NUMBER       := 0;
168 		l_msg_data         VARCHAR2(2000);
169 
170 		l_api_version	  CONSTANT NUMBER:=1;
171 		x_shortage_exists VARCHAR2(1);
172 		x_msg_count	  NUMBER;
173 		x_msg_data	  VARCHAR2(2000);
174 
175         BEGIN
176 
177 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Writing Material Requirements rec for ' || p_eam_mat_req_rec.inventory_item_id); END IF;
178 --Bug3946253:Remove round() for the date_required
179 
180 
181                 INSERT INTO WIP_REQUIREMENT_OPERATIONS
182                        ( wip_entity_id
183                        , operation_seq_num
184                        , organization_id
185                        , inventory_item_id
186                        , quantity_per_assembly
187                        , department_id
188                        , wip_supply_type
189                        , date_required
190                        , required_quantity
191                        , quantity_issued
192                        , supply_subinventory
193                        , supply_locator_id
194                        , mrp_net_flag
195                        , mps_required_quantity
196                        , mps_date_required
197                        , component_sequence_id
198                        , comments
199                        , attribute_category
200                        , attribute1
201                        , attribute2
202                        , attribute3
203                        , attribute4
204                        , attribute5
205                        , attribute6
206                        , attribute7
207                        , attribute8
208                        , attribute9
209                        , attribute10
210                        , attribute11
211                        , attribute12
212                        , attribute13
213                        , attribute14
214                        , attribute15
215 		       , released_quantity
216                        , auto_request_material
217                        , suggested_vendor_name
218                        , vendor_id
219                        , unit_price
220                        , basis_type
221                        , segment1
222                        , segment2
223                        , segment3
224                        , segment4
225                        , segment5
226                        , segment6
227                        , segment7
228                        , segment8
229                        , segment9
230                        , segment10
231                        , segment11
232                        , segment12
233                        , segment13
234                        , segment14
235                        , segment15
236                        , segment16
237                        , segment17
238                        , segment18
239                        , segment19
240                        , segment20
241                        , last_update_date
242                        , last_updated_by
243                        , creation_date
244                        , created_by
245                        , last_update_login
246                        , request_id
247                        , program_application_id
248                        , program_id
249                        , program_update_date)
250                 SELECT
251                          p_eam_mat_req_rec.wip_entity_id
252                        , p_eam_mat_req_rec.operation_seq_num
253                        , p_eam_mat_req_rec.organization_id
254                        , p_eam_mat_req_rec.inventory_item_id
255                        , p_eam_mat_req_rec.quantity_per_assembly
256                        , p_eam_mat_req_rec.department_id
257                        , p_eam_mat_req_rec.wip_supply_type
258                        , p_eam_mat_req_rec.date_required
259                        , p_eam_mat_req_rec.required_quantity
260                        , p_eam_mat_req_rec.quantity_issued
261                        , p_eam_mat_req_rec.supply_subinventory
262                        , p_eam_mat_req_rec.supply_locator_id
263                        , p_eam_mat_req_rec.mrp_net_flag
264                        , p_eam_mat_req_rec.mps_required_quantity
265                        , round(p_eam_mat_req_rec.mps_date_required,'DD')
266                        , p_eam_mat_req_rec.component_sequence_id
267                        , p_eam_mat_req_rec.comments
268                        , p_eam_mat_req_rec.attribute_category
269                        , p_eam_mat_req_rec.attribute1
270                        , p_eam_mat_req_rec.attribute2
271                        , p_eam_mat_req_rec.attribute3
272                        , p_eam_mat_req_rec.attribute4
273                        , p_eam_mat_req_rec.attribute5
274                        , p_eam_mat_req_rec.attribute6
275                        , p_eam_mat_req_rec.attribute7
276                        , p_eam_mat_req_rec.attribute8
277                        , p_eam_mat_req_rec.attribute9
278                        , p_eam_mat_req_rec.attribute10
279                        , p_eam_mat_req_rec.attribute11
280                        , p_eam_mat_req_rec.attribute12
281                        , p_eam_mat_req_rec.attribute13
282                        , p_eam_mat_req_rec.attribute14
283                        , p_eam_mat_req_rec.attribute15
284 		       , p_eam_mat_req_rec.released_quantity
285                        , p_eam_mat_req_rec.auto_request_material
286                        , p_eam_mat_req_rec.suggested_vendor_name
287                        , p_eam_mat_req_rec.vendor_id
288                        , p_eam_mat_req_rec.unit_price
289                        , null
290                        , msi.segment1
291                        , msi.segment2
292                        , msi.segment3
293                        , msi.segment4
294                        , msi.segment5
295                        , msi.segment6
296                        , msi.segment7
297                        , msi.segment8
298                        , msi.segment9
299                        , msi.segment10
300                        , msi.segment11
301                        , msi.segment12
302                        , msi.segment13
303                        , msi.segment14
304                        , msi.segment15
305                        , msi.segment16
306                        , msi.segment17
307                        , msi.segment18
308                        , msi.segment19
309                        , msi.segment20
310                        , SYSDATE
311                        , FND_GLOBAL.user_id
312                        , SYSDATE
313                        , FND_GLOBAL.user_id
314                        , FND_GLOBAL.login_id
315                        , p_eam_mat_req_rec.request_id
316                        , p_eam_mat_req_rec.program_application_id
317                        , p_eam_mat_req_rec.program_id
318                        , SYSDATE
319                 FROM     mtl_system_items msi
320                 WHERE    msi.inventory_item_id = p_eam_mat_req_rec.inventory_item_id
321                 AND      msi.organization_id = p_eam_mat_req_rec.organization_id
322 
323 
324                        ;--p_eam_mat_req_rec.program_update_date);
325 
326 
327 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Creating new Material Requirements') ; END IF;
328 
329                 x_return_status := FND_API.G_RET_STS_SUCCESS;
330 
331   -- bug number 2251186
332 		  -- API is called to set the estimation_status
333       --added for 3658112.do not call for unplanned materials
334          IF(p_eam_mat_req_rec.released_quantity is null OR p_eam_mat_req_rec.released_quantity<>0) THEN
335 		  EAM_AutomaticEst.Auto_Reest_of_Cost(
336 		    p_wip_entity_id =>  p_eam_mat_req_rec.wip_entity_id,
337 		    p_api_name => 'EAM',
338 		    p_req_line_id => NULL,
339 		    p_po_dist_id => NULL,
340 		    p_po_line_id => NULL,
341 		    p_inv_item_id => NULL,
342 		    p_org_id => p_eam_mat_req_rec.organization_id,
343 		    p_resource_id => NULL,
344 		    x_return_status => l_return_status,
345 		    x_msg_count => l_msg_count,
346 		    x_msg_data => l_msg_data
347 		    );
348             END IF;
349 
350 
351         EXCEPTION
352             WHEN OTHERS THEN
353                         EAM_ERROR_MESSAGE_PVT.Add_Error_Token
354                         (  p_message_name       => NULL
355                          , p_message_text       => G_PKG_NAME ||' :Inserting Record ' || SQLERRM
356                          , x_mesg_token_Tbl     => x_mesg_token_tbl
357                         );
358 
359                         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
360 
361         END Insert_Row;
362 
363 /********************************************************************
364 * Procedure     : Update_Row
365 * Parameters IN : Material Requirements column record
366 * Parameters OUT NOCOPY: Message Token Table
367 *                 Return Status
368 * Purpose       : Procedure will perfrom an Update on the
369 *                 wip_operations table.
370 *********************************************************************/
371 
372 PROCEDURE Update_Row
373 (  p_eam_mat_req_rec    IN  EAM_PROCESS_WO_PUB.eam_mat_req_rec_type
374  , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
375  , x_return_Status      OUT NOCOPY VARCHAR2
376  )
377 IS
378 		l_return_status    VARCHAR2(30) ;
379 		l_msg_count        NUMBER       := 0;
380 		l_msg_data         VARCHAR2(2000);
381 		l_req_qty          NUMBER       := 0;
382 		l_api_version	  CONSTANT NUMBER:=1;
383 		x_shortage_exists VARCHAR2(1);
384  BEGIN
385 
386 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Updating Material Requirements '|| p_eam_mat_req_rec.inventory_item_id); END IF;
387 
388 
389 
390    SELECT required_quantity
391     INTO l_req_qty
392     FROM WIP_REQUIREMENT_OPERATIONS
393    WHERE wip_entity_id     = p_eam_mat_req_rec.wip_entity_id
394      AND ( operation_seq_num = p_eam_mat_req_rec.operation_seq_num
395 				            OR operation_seq_num = 1 )
396      AND inventory_item_id = p_eam_mat_req_rec.inventory_item_id;
397 --Bug3946253:Remove round() for the date_required
398       UPDATE WIP_REQUIREMENT_OPERATIONS
399                 SET    quantity_per_assembly       = p_eam_mat_req_rec.quantity_per_assembly
400 		       , operation_seq_num           = p_eam_mat_req_rec.operation_seq_num  /* Added the column so that op seq num can be changed if it is 1 */
401                        , department_id               = p_eam_mat_req_rec.department_id
402                        , wip_supply_type             = p_eam_mat_req_rec.wip_supply_type
403                        , date_required               = p_eam_mat_req_rec.date_required
404                        , required_quantity           = p_eam_mat_req_rec.required_quantity
405                        , quantity_issued             = p_eam_mat_req_rec.quantity_issued
406                        , supply_subinventory         = p_eam_mat_req_rec.supply_subinventory
407                        , supply_locator_id           = p_eam_mat_req_rec.supply_locator_id
408                        , mrp_net_flag                = p_eam_mat_req_rec.mrp_net_flag
409                        , mps_required_quantity       = p_eam_mat_req_rec.mps_required_quantity
410                        , mps_date_required           = round(p_eam_mat_req_rec.mps_date_required, 'DD')
411                        , component_sequence_id       = p_eam_mat_req_rec.component_sequence_id
412                        , comments                    = p_eam_mat_req_rec.comments
413                        , attribute_category          = p_eam_mat_req_rec.attribute_category
414                        , attribute1                  = p_eam_mat_req_rec.attribute1
415                        , attribute2                  = p_eam_mat_req_rec.attribute2
416                        , attribute3                  = p_eam_mat_req_rec.attribute3
417                        , attribute4                  = p_eam_mat_req_rec.attribute4
418                        , attribute5                  = p_eam_mat_req_rec.attribute5
419                        , attribute6                  = p_eam_mat_req_rec.attribute6
420                        , attribute7                  = p_eam_mat_req_rec.attribute7
421                        , attribute8                  = p_eam_mat_req_rec.attribute8
422                        , attribute9                  = p_eam_mat_req_rec.attribute9
423                        , attribute10                 = p_eam_mat_req_rec.attribute10
424                        , attribute11                 = p_eam_mat_req_rec.attribute11
425                        , attribute12                 = p_eam_mat_req_rec.attribute12
426                        , attribute13                 = p_eam_mat_req_rec.attribute13
427                        , attribute14                 = p_eam_mat_req_rec.attribute14
428                        , attribute15                 = p_eam_mat_req_rec.attribute15
429 		       , released_quantity           = p_eam_mat_req_rec.released_quantity
430                        , auto_request_material       = p_eam_mat_req_rec.auto_request_material
431                        , suggested_vendor_name       = p_eam_mat_req_rec.suggested_vendor_name
432                        , vendor_id                   = p_eam_mat_req_rec.vendor_id
433                        , unit_price                  = p_eam_mat_req_rec.unit_price
434                        , last_update_date            = SYSDATE
435                        , last_updated_by             = FND_GLOBAL.user_id
436                        , last_update_login           = FND_GLOBAL.login_id
437                        , request_id                  = p_eam_mat_req_rec.request_id
438                        , program_application_id      = p_eam_mat_req_rec.program_application_id
439                        , program_id                  = p_eam_mat_req_rec.program_id
440                        , program_update_date         = SYSDATE
441                 WHERE    organization_id   = p_eam_mat_req_rec.organization_id
442                   AND    wip_entity_id     = p_eam_mat_req_rec.wip_entity_id
443                   AND  ( operation_seq_num = p_eam_mat_req_rec.operation_seq_num
444 				            OR operation_seq_num = 1 )                                                /* Added the check operation_seq_num = 1 so that op seq num can be changed if it is 1 */
445                   AND    inventory_item_id = p_eam_mat_req_rec.inventory_item_id;
446 
447                 x_return_status := FND_API.G_RET_STS_SUCCESS;
448 
449  --added for 3658112.do not call for unplanned materials
450          IF(p_eam_mat_req_rec.released_quantity is null OR p_eam_mat_req_rec.released_quantity<>0) THEN
451 		    -- comparing new quantity with existing quantity
452 		   IF ( p_eam_mat_req_rec.required_quantity <> l_req_qty )THEN
453 
454 		      -- API is called to set the estimation_status
455 		      EAM_AutomaticEst.Auto_Reest_of_Cost(
456 			p_wip_entity_id => p_eam_mat_req_rec.wip_entity_id,
457 			p_api_name => 'EAM',
458 			p_req_line_id => NULL,
459 			p_po_dist_id => NULL,
460 			p_po_line_id => NULL,
461 			p_inv_item_id => NULL,
462 			p_org_id => p_eam_mat_req_rec.organization_id,
463 			p_resource_id => NULL,
464 			x_return_status => l_return_status,
465 			x_msg_count => l_msg_count,
466 			x_msg_data => l_msg_data
467 			);
468 
469 		    END IF; /* ENDIF of comparing quantity IF */
470           END IF;
471 
472         END Update_Row;
473 
474 
475 
476         /********************************************************************
477         * Procedure     : Delete_Row
478         * Parameters IN : Material Requirements column record
479         * Parameters OUT NOCOPY: Message Token Table
480         *                 Return Status
481         * Purpose       : Procedure will perfrom an Delete on the
482         *                 wip_operations table.
483         *********************************************************************/
484 
485         PROCEDURE Delete_Row
486         (  p_eam_mat_req_rec    IN  EAM_PROCESS_WO_PUB.eam_mat_req_rec_type
487          , x_mesg_token_Tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
488          , x_return_Status      OUT NOCOPY VARCHAR2
489          )
490         IS
491 
492 		l_return_status    VARCHAR2(30);
493 		l_msg_count        NUMBER       := 0;
494 		l_msg_data         VARCHAR2(2000);
495 
496 		l_api_version	  CONSTANT NUMBER:=1;
497 		x_shortage_exists VARCHAR2(1);
498 
499         BEGIN
500 
501 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Deleting Material Requirements '|| p_eam_mat_req_rec.inventory_item_id); END IF;
502 
503       DELETE FROM WIP_REQUIREMENT_OPERATIONS
504                 WHERE    organization_id   = p_eam_mat_req_rec.organization_id
505                   AND    wip_entity_id     = p_eam_mat_req_rec.wip_entity_id
506                   AND    operation_seq_num = p_eam_mat_req_rec.operation_seq_num
507                   AND    inventory_item_id = p_eam_mat_req_rec.inventory_item_id;
508 
509                 x_return_status := FND_API.G_RET_STS_SUCCESS;
510 
511         --added for 3658112.do not call for unplanned materials
512          IF(p_eam_mat_req_rec.released_quantity is null OR p_eam_mat_req_rec.released_quantity<>0) THEN
513 		      -- API is called to set the estimation_status
514 		      EAM_AutomaticEst.Auto_Reest_of_Cost(
515 			p_wip_entity_id => p_eam_mat_req_rec.wip_entity_id,
516 			p_api_name => 'EAM',
517 			p_req_line_id => NULL,
518 			p_po_dist_id => NULL,
519 			p_po_line_id => NULL,
520 			p_inv_item_id => NULL,
521 			p_org_id => p_eam_mat_req_rec.organization_id,
522 			p_resource_id => NULL,
523 			x_return_status => l_return_status,
524 			x_msg_count => l_msg_count,
525 			x_msg_data => l_msg_data
526 			);
527 	END IF;
528 
529         END Delete_Row;
530 
531 
532         /*********************************************************************
533         * Procedure     : Perform_Writes
534         * Parameters IN : Material Requirements Record
535         * Parameters OUT NOCOPY: Messgae Token Table
536         *                 Return Status
537         * Purpose       : This is the only procedure that the user will have
538         *                 access to when he/she needs to perform any kind of
539         *                 writes to the wip_operations.
540         *********************************************************************/
541 
542         PROCEDURE Perform_Writes
543         (  p_eam_mat_req_rec    IN  EAM_PROCESS_WO_PUB.eam_mat_req_rec_type
544          , x_mesg_token_tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
545          , x_return_status      OUT NOCOPY VARCHAR2
546         )
547         IS
548                 l_Mesg_Token_tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
549                 l_return_status         VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
550         BEGIN
551 
552                 IF p_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
553                 THEN
554                         Insert_Row
555                         (  p_eam_mat_req_rec    => p_eam_mat_req_rec
556                          , x_mesg_token_Tbl     => l_mesg_token_tbl
557                          , x_return_Status      => l_return_status
558                          );
559                 ELSIF p_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
560                 THEN
561                         Update_Row
562                         (  p_eam_mat_req_rec    => p_eam_mat_req_rec
563                          , x_mesg_token_Tbl     => l_mesg_token_tbl
564                          , x_return_Status      => l_return_status
565                          );
566 
567                 ELSIF p_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE
568                 THEN
569                         Delete_Row
570                         (  p_eam_mat_req_rec    => p_eam_mat_req_rec
571                          , x_mesg_token_Tbl     => l_mesg_token_tbl
572                          , x_return_Status      => l_return_status
573                          );
574 
575                 END IF;
576 
577                 x_return_status := l_return_status;
578                 x_mesg_token_tbl := l_mesg_token_tbl;
579 
580         END Perform_Writes;
581 
582 
583        FUNCTION  NUM_OF_ROW
584        ( p_wip_entity_id  NUMBER
585 	   , p_organization_id NUMBER
586 	   , p_operation_seq_num NUMBER
587 	   ) RETURN BOOLEAN IS
588 
589 	   l_count NUMBER := 0 ;
590 
591 	   BEGIN
592 		   SELECT  count(*)  into l_count
593 	       FROM dual
594 	       WHERE exists (
595 	                         SELECT 1
596 							 FROM wip_requirement_operations
597 							 WHERE operation_seq_num = p_operation_seq_num
598 							 and wip_entity_id = p_wip_entity_id
599 							 and organization_id = p_organization_id
600 						   ) ;
601 
602 		   IF ( l_count = 0 ) THEN
603 		       return FALSE ;
604 		   ELSE
605 			   return TRUE ;
606 		   END IF;
607 
608       END NUM_OF_ROW;
609 
610 
611 
612 END EAM_MAT_REQ_UTILITY_PVT;