[Home] [Help]
PACKAGE BODY: APPS.EAM_REQUEST_UTILITY_PVT
Source
1 PACKAGE BODY EAM_REQUEST_UTILITY_PVT AS
2 /* $Header: EAMVRQUB.pls 120.3 2010/11/08 09:53:00 somitra ship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVRQUB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package EAM_REQUEST_UTILITY_PVT
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 14-FEB-2005 mmaduska Initial Creation
21 ***************************************************************************/
22 PROCEDURE INSERT_ROW
23 ( p_eam_request_rec IN EAM_PROCESS_WO_PUB.eam_request_rec_type
24 , x_return_status OUT NOCOPY VARCHAR2
25 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
26 )
27 IS
28 BEGIN
29
30 IF p_eam_request_rec.request_type = 1 THEN
31 UPDATE WIP_EAM_WORK_REQUESTS
32 SET
33 wip_entity_id = p_eam_request_rec.wip_entity_id,
34 work_request_status_id = 4,
35 last_update_date = sysdate,
36 last_updated_by = FND_GLOBAL.user_id,
37 last_update_login = fnd_global.login_id
38 WHERE work_request_id = p_eam_request_rec.request_id
39 AND organization_id = p_eam_request_rec.organization_id;
40
41 END IF;
42
43 IF p_eam_request_rec.request_type = 2 THEN
44
45 INSERT INTO EAM_WO_SERVICE_ASSOCIATION
46 ( wo_service_entity_assoc_id,
47 maintenance_organization_id,
48 wip_entity_id,
49 service_request_id,
50 creation_date,
51 created_by,
52 last_update_login,
53 program_id,
54 attribute1,
55 attribute2,
56 attribute3,
57 attribute4,
58 attribute5,
59 attribute6,
60 attribute7,
61 attribute8,
62 attribute9,
63 attribute10,
64 attribute11,
65 attribute12,
66 attribute13,
67 attribute14,
68 attribute15,
69 attribute_category,
70 last_updated_by,
71 last_update_date,
72 enable_flag) -- Fix for 3773450
73 VALUES
74 ( p_eam_request_rec.SERVICE_ASSOC_ID,
75 p_eam_request_rec.organization_id,
76 p_eam_request_rec.wip_entity_id,
77 p_eam_request_rec.request_id,
78 sysdate,
79 FND_GLOBAL.USER_ID,
80 FND_GLOBAL.LOGIN_ID,
81 null,--fnd_global.conc_program_id,
82 null,
83 null,
84 null,
85 null,
86 null,
87 null,
88 null,
89 null,
90 null,
91 null,
92 null,
93 null,
94 null,
95 null,
96 null,
97 null,
98 fnd_global.user_id,
99 sysdate,
100 'Y'); -- Fix for 3773450
101 END IF;
102
103 --copy work request attachment to WO - Bug 10109869
104 copy_wr_attachment_to_wo(
105 p_eam_request_rec=>p_eam_request_rec,
106 x_return_status=>x_return_status
107 );
108
109 END INSERT_ROW;
110
111 PROCEDURE DELETE_ROW
112 ( p_eam_request_rec IN EAM_PROCESS_WO_PUB.eam_request_rec_type
113 , x_return_status OUT NOCOPY VARCHAR2
114 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
115 )
116 IS
117 BEGIN
118
119 IF p_eam_request_rec.request_type = 1 THEN
120
121 UPDATE WIP_EAM_WORK_REQUESTS
122 SET wip_entity_id = null,
123 work_request_status_id = 3,
124 last_update_date = sysdate,
125 last_updated_by = FND_GLOBAL.user_id
126 WHERE work_request_id = p_eam_request_rec.request_id
127 AND organization_id = p_eam_request_rec.organization_id;
128 END IF;
129
130 IF p_eam_request_rec.request_type = 2 THEN
131
132 UPDATE EAM_WO_SERVICE_ASSOCIATION -- Fix for 3773450
133 SET enable_flag = 'N',
134 last_update_date = sysdate,
135 last_updated_by = FND_GLOBAL.user_id,
136 last_update_login = FND_GLOBAL.login_id
137 WHERE service_request_id = p_eam_request_rec.request_id
138 AND wip_entity_id = p_eam_request_rec.wip_entity_id
139 AND maintenance_organization_id = p_eam_request_rec.organization_id
140 AND (enable_flag IS NULL or enable_flag = 'Y');
141
142 END IF;
143
144
145 END DELETE_ROW;
146
147 PROCEDURE copy_wr_attachment_to_wo
148 ( p_eam_request_rec IN EAM_PROCESS_WO_PUB.eam_request_rec_type
149 , x_return_status OUT NOCOPY VARCHAR2
150 )
151 IS
152
153 l_attachment_exists varchar2(1):='N';
154
155 BEGIN
156
157 BEGIN
158
159 select
160 'Y'
161 INTO
162 l_attachment_exists
163 from
164 fnd_attached_documents fad
165 where
166 fad.entity_name = 'EAM_WORK_REQUESTS' and
167 fad.pk1_value = to_char(p_eam_request_rec.request_id) and
168 rownum<2;
169
170 EXCEPTION
171 when NO_DATA_FOUND then
172 l_attachment_exists:='N';
173 END;
174
175
176 IF l_attachment_exists <> 'N' THEN
177
178 fnd_attached_documents2_pkg.copy_attachments(
179 X_from_entity_name => 'EAM_WORK_REQUESTS',
180 X_from_pk1_value => to_char(p_eam_request_rec.request_id),
181 X_from_pk2_value => '',
182 X_from_pk3_value => '',
183 X_from_pk4_value => '',
184 X_from_pk5_value => '',
185 X_to_entity_name => 'EAM_WORK_ORDERS',
186 X_to_pk1_value => to_char(p_eam_request_rec.organization_id),
187 X_to_pk2_value => to_char(p_eam_request_rec.wip_entity_id),
188 X_to_pk3_value => '',
189 X_to_pk4_value => '',
190 X_to_pk5_value => '',
191 X_created_by => FND_GLOBAL.USER_ID,
192 X_last_update_login => '',
193 X_program_application_id=> '',
194 X_program_id => '',
195 X_request_id => ''
196 );
197
198 END IF;
199
200 x_return_status := fnd_api.g_ret_sts_success;
201
202 exception
203 when others then
204 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
205 fnd_message.set_name('EAM', 'EAM_UNEXPECTED_ERROR');
206 fnd_message.set_token('ERROR_TEXT', SQLERRM);
207
208
209 END copy_wr_attachment_to_wo;
210
211
212 END EAM_REQUEST_UTILITY_PVT;