[Home] [Help]
PACKAGE BODY: APPS.EAM_RES_USAGE_UTILITY_PVT
Source
1 PACKAGE BODY EAM_RES_USAGE_UTILITY_PVT AS
2 /* $Header: EAMVRUUB.pls 120.2 2005/10/06 02:01:14 mmaduska noship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVRUUB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package EAM_RES_USAGE_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_USAGE_UTILITY_PVT';
24
25
26 /********************************************************************
27 * Procedure : Add Usage
28 * Parameters IN :
29 * Parameters OUT NOCOPY: Message Token Table
30 * Return Status
31 * Purpose : Procedure will perfrom an insert into the
32 * wip_operation_resource_usage table.
33 *********************************************************************/
34
35 PROCEDURE Add_Usage
36 ( p_eam_res_usage_rec IN EAM_PROCESS_WO_PUB.eam_res_usage_rec_type
37 , x_mesg_token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
38 , x_return_Status OUT NOCOPY VARCHAR2
39 )
40 IS
41 BEGIN
42
43 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Writing Resource Usage for ' || p_eam_res_usage_rec.resource_seq_num); END IF;
44
45 -- bug no 3444091
46 if p_eam_res_usage_rec.start_date > p_eam_res_usage_rec.completion_date then
47 x_return_status := fnd_api.g_ret_sts_error;
48 fnd_message.set_name('EAM','EAM_WO_RU_DT_ERR');
49 return;
50 end if;
51
52
53 INSERT INTO WIP_OPERATION_RESOURCE_USAGE
54 ( wip_entity_id
55 , operation_seq_num
56 , resource_seq_num
57 , organization_id
58 , instance_id
59 , serial_number
60 , start_date
61 , completion_date
62 , assigned_units
63 , last_update_date
64 , last_updated_by
65 , creation_date
66 , created_by
67 , last_update_login
68 , request_id
69 , program_application_id
70 , program_id
71 , program_update_date)
72 VALUES
73 ( p_eam_res_usage_rec.wip_entity_id
74 , p_eam_res_usage_rec.operation_seq_num
75 , p_eam_res_usage_rec.resource_seq_num
76 , p_eam_res_usage_rec.organization_id
77 , p_eam_res_usage_rec.instance_id
78 , p_eam_res_usage_rec.serial_number
79 , p_eam_res_usage_rec.start_date
80 , p_eam_res_usage_rec.completion_date
81 , p_eam_res_usage_rec.assigned_units
82 , SYSDATE
83 , FND_GLOBAL.user_id
84 , SYSDATE
85 , FND_GLOBAL.user_id
86 , FND_GLOBAL.login_id
87 , p_eam_res_usage_rec.request_id
88 , p_eam_res_usage_rec.program_application_id
89 , p_eam_res_usage_rec.program_id
90 , SYSDATE);
91
92
93 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Creating new Resource Usage') ; END IF;
94
95 x_return_status := FND_API.G_RET_STS_SUCCESS;
96
97 EXCEPTION
98 WHEN OTHERS THEN
99 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
100 ( p_message_name => NULL
101 , p_message_text => G_PKG_NAME ||' :Inserting Record ' || SQLERRM
102 , x_mesg_token_Tbl => x_mesg_token_tbl
103 );
104
105 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
106
107 END Add_Usage;
108
109 /********************************************************************
110 * Procedure : Delete_Usage
111 * Parameters IN :
112 * Parameters OUT NOCOPY: Message Token Table
113 * Return Status
114 * Purpose : Procedure will perfrom an Delete on the
115 * wip_operation_resource_usage table.
116 *********************************************************************/
117
118 PROCEDURE Delete_Usage
119 ( p_wip_entity_id IN NUMBER
120 , p_organization_id IN NUMBER
121 , p_operation_seq_num IN NUMBER
122 , p_resource_seq_num IN NUMBER
123 , x_mesg_token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
124 , x_return_Status OUT NOCOPY VARCHAR2
125 )
126 IS
127 BEGIN
128
129 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Deleting Resource Usage: '|| p_resource_seq_num); END IF;
130
131 DELETE FROM WIP_OPERATION_RESOURCE_USAGE
132 WHERE wip_entity_id = p_wip_entity_id
133 AND organization_id = p_organization_id
134 AND operation_seq_num = p_operation_seq_num
135 AND resource_seq_num = p_resource_seq_num;
136
137 x_return_status := FND_API.G_RET_STS_SUCCESS;
138
139 END Delete_Usage;
140
141
142 FUNCTION NUM_OF_ROW
143 ( p_eam_res_usage_tbl IN EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type
144 , p_wip_entity_id IN NUMBER
145 , p_organization_id IN NUMBER
146 , p_operation_seq_num IN NUMBER
147 , p_resource_seq_num IN NUMBER
148 ) RETURN BOOLEAN
149 IS
150
151 l_count NUMBER := 0;
152
153 l_eam_res_usage_rec EAM_PROCESS_WO_PUB.eam_res_usage_rec_type ;
154 l_eam_res_usage_tbl EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type ;
155
156 BEGIN
157
158 l_eam_res_usage_tbl := p_eam_res_usage_tbl ;
159
160 FOR I IN 1..l_eam_res_usage_tbl.COUNT LOOP
161
162 l_eam_res_usage_rec := l_eam_res_usage_tbl(I);
163
164 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Return status validation passed') ; END IF ;
165
166 IF ( l_eam_res_usage_rec.wip_entity_id = p_wip_entity_id and
167 l_eam_res_usage_rec.organization_id = p_organization_id and
168 l_eam_res_usage_rec.operation_seq_num = p_operation_seq_num and
169 l_eam_res_usage_rec.resource_seq_num = p_resource_seq_num
170 ) THEN
171
172 l_count := l_count + 1;
173
174 END IF;
175
176 END LOOP;
177
178 IF (l_count > 0) THEN
179 RETURN FALSE;
180 ELSE
181 RETURN TRUE;
182 END IF;
183
184 END NUM_OF_ROW;
185
186
187 END EAM_RES_USAGE_UTILITY_PVT;